diff --git a/README.md b/README.md index 0d0956b..c8e7199 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Text diff ### 使用者影响 -升级到 Calcit 和 `@calcit/procs` **0.37.0** 后,请重新安装依赖、编译并刷新。文本输入、Run 输出、原 Map 存档和页面 HUD 继续适用。 +升级到 Calcit 和 `@calcit/procs` **0.38.0** 后,请重新安装依赖、编译并刷新。文本输入、Run 输出、原 Map 存档和页面 HUD 继续适用。 应用操作和 Reel 控制解码后通过 `ResolvedOp` union 区分,已有 Reel 标签和存档结构保持兼容。 Reel 使用 `State`。旧操作在入口解码,业务更新器接收具名操作。状态路径沿用 `CursorKey = Tag | String | Number`,已有 Map 或 Struct 存档仍在恢复时校验。恢复成功后才注册离页保存。 @@ -16,7 +16,7 @@ Reel 使用 `State`。旧操作在入口解码,业务更新器接 Use `calcit.cirru` and `deps.cirru`; do not restore the retired `compact.cirru` or `package.cirru`. Generated `js-out/` is not committed. -Use Node 24 and Yarn 4.18.0. Install Calcit 0.37.0 and Caps 0.1.1 separately +Use Node 24 and Yarn 4.18.0. Install Calcit 0.38.0 and Caps 0.1.1 separately (the latter follows [the official Caps installation](https://github.com/calcit-lang/caps)); Corepack/Yarn does not install Caps. Strict dependency installation and the original type/test gates are retained. Browser and production acceptance remain separate from successful compilation. diff --git a/calcit.cirru b/calcit.cirru index 462f0cf..fcb799f 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -98,14 +98,14 @@ 'dispatch! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn dispatch! (op) when config/dev? $ println |Dispatch: op - match (typed/decode-control op) - (:some control) - reset! *reel $ typed/apply-control updater @*reel control - (:none) - match (schema/decode-op op) - (:some action) + match (schema/decode-op op) + (:some resolved) + match resolved + (reel.typed/Control control) + reset! *reel $ typed/apply-control updater @*reel control + (text-diff.schema/Op action) reset! *reel $ typed/record-op updater @*reel action (generate-id!) (shared/now-ms) - (:none) &unit + (:none) &unit , &unit :examples $ [] :schema $ quote $ Fn AnyEnum (-> Unit) (:features :js-ffi) @@ -199,6 +199,10 @@ :hydrate-storage text-diff.schema/Store :examples $ [] :schema $ quote EnumDef + 'ResolvedOp $ %{} 'CodeEntry (:doc |) + :code $ quote $ defunion ResolvedOp text-diff.schema/Op reel.typed/Control + :examples $ [] + :schema $ quote UnionDef 'Store $ %{} 'CodeEntry (:doc |) :code $ quote $ defstruct Store :states $ Map Tag Dynamic @@ -207,21 +211,28 @@ :schema $ quote StructDef 'decode-op $ %{} 'CodeEntry (:doc |) :code $ quote $ defn decode-op (op) - match op - (:states cursor data) - Option :some $ Op :states - decode-map-as cursor $ List text-diff.schema/CursorKey - , data - (:content content) - Option :some $ Op :content $ decode-map-as content String - (:hydrate-storage data) - Option :some $ Op :hydrate-storage $ decode-map-as - if (struct? data) (&struct:to-map data) data - , text-diff.schema/Store - _ $ do (eprintln "|Unknown op:" op) (Option :none) + let + some-action $ fn (action) + hint-fn $ Fn text-diff.schema/ResolvedOp $ -> (Option text-diff.schema/ResolvedOp) + Option :some action + match (reel.typed/decode-control op) + (:some control) (some-action control) + (:none) + match op + (:states cursor data) + some-action $ Op :states + decode-map-as cursor $ List text-diff.schema/CursorKey + , data + (:content content) + some-action $ Op :content $ decode-map-as content String + (:hydrate-storage data) + some-action $ Op :hydrate-storage $ decode-map-as + if (struct? data) (&struct:to-map data) data + , text-diff.schema/Store + _ $ do (eprintln "|Unknown op:" op) (Option :none) :examples $ [] :schema $ quote $ Fn AnyEnum - -> $ Option text-diff.schema/Op + -> $ Option text-diff.schema/ResolvedOp 'store $ %{} 'CodeEntry (:doc |) :code $ quote $ def store Store :states ({}) :content | diff --git a/deps.cirru b/deps.cirru index 5bfe6a6..fda9421 100644 --- a/deps.cirru +++ b/deps.cirru @@ -1,5 +1,5 @@ -{} (:calcit-version |0.37.0) +{} (:calcit-version |0.38.0) :version |0.1.4 :dependencies $ {} (|Respo/reel.calcit |0.10.0) |Respo/respo-markdown.calcit |0.8.2 diff --git a/package.json b/package.json index 1c32e61..0b3a211 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "vite": "^8.3.1" }, "dependencies": { - "@calcit/procs": "0.37.0", + "@calcit/procs": "0.38.0", "cirru-color": "^0.2.4", "copy-text-to-clipboard": "^3.2.2", "dayjs": "^1.11.20", diff --git a/scripts/upgrade.test.mjs b/scripts/upgrade.test.mjs index 1f300ec..7ffdd1f 100644 --- a/scripts/upgrade.test.mjs +++ b/scripts/upgrade.test.mjs @@ -3,6 +3,7 @@ import test from 'node:test'; import * as c from '../js-out/calcit.core.mjs'; import { updater } from '../js-out/text-diff.updater.mjs'; import { decode_op, store } from '../js-out/text-diff.schema.mjs'; +import { Control } from '../js-out/reel.typed.mjs'; const tags = c.init_tags(['content', 'states']); const read = (value, key) => c.option_$o_unwrap(c.get(value, key)); @@ -36,3 +37,8 @@ test('cursor updates preserve content', () => { } assert.throws(() => apply(populated, ':: :states ([] :editor false) $ {}'), /CursorKey/); }); + +test('legacy Reel controls decode to the nominal control member', () => { + const control = c.option_$o_unwrap(decode_op(c.parse_cirru_edn(':: :reel/toggle'))); + assert.equal(c.option_$o_unwrap(c._$n_enum_$o_definition(control)), Control); +}); diff --git a/yarn.lock b/yarn.lock index 4c52ac7..f1acba0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,15 +12,15 @@ __metadata: languageName: node linkType: hard -"@calcit/procs@npm:0.37.0": - version: 0.37.0 - resolution: "@calcit/procs@npm:0.37.0" +"@calcit/procs@npm:0.38.0": + version: 0.38.0 + resolution: "@calcit/procs@npm:0.38.0" dependencies: "@calcit/finger-vec": "npm:0.1.1" "@calcit/ternary-tree": "npm:0.0.26" "@cirru/parser.ts": "npm:0.0.10" "@cirru/writer.ts": "npm:^0.1.9" - checksum: 10c0/38efd6a08b096419d41aa1d502a573ecbb415867caa18ee69142010e5d6c285f36f47d4e4334c33eff15617b1eff980f29662176422acb1bbf4fac5fdca83178 + checksum: 10c0/8d1910cc739b1b23b5d5b549fb519053b2a578ab05f11814d28c09fbf4c18be5d3a14f52ff3b9bea4c9a3a42ab79d56a59021cd533d68ecc5e26e61da1e347ba languageName: node linkType: hard @@ -278,7 +278,7 @@ __metadata: version: 0.0.0-use.local resolution: "calcit-workflow@workspace:." dependencies: - "@calcit/procs": "npm:0.37.0" + "@calcit/procs": "npm:0.38.0" bottom-tip: "npm:^0.1.5" cirru-color: "npm:^0.2.4" copy-text-to-clipboard: "npm:^3.2.2"