Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<Op, Store>`。旧操作在入口解码,业务更新器接收具名操作。状态路径沿用 `CursorKey = Tag | String | Number`,已有 Map 或 Struct 存档仍在恢复时校验。恢复成功后才注册离页保存。

Expand All @@ -16,7 +16,7 @@ Reel 使用 `State<Op, Store>`。旧操作在入口解码,业务更新器接
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.

Expand Down
51 changes: 31 additions & 20 deletions calcit.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion deps.cirru
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions scripts/upgrade.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
});
10 changes: 5 additions & 5 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.