From 55034b8f234915382fb12b10e10f6ccb5d4ef4b0 Mon Sep 17 00:00:00 2001 From: tiye Date: Thu, 12 Nov 2026 06:10:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=20Markup=20=E5=88=B0=20Calci?= =?UTF-8?q?t=200.41.1=20=E5=B9=B6=E6=94=B6=E7=B4=A7=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +-- calcit.cirru | 49 ++++++++++++++++++------------ deps.cirru | 2 +- package.json | 2 +- scripts/typed-reel-render.test.mjs | 10 +++--- yarn.lock | 10 +++--- 6 files changed, 45 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index af4e389..797c674 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,14 @@ Demo http://repo.respo-mvc.org/markup/ . ### Usages -本次候选 **0.0.6** 配对正式 Calcit / `@calcit/procs` **0.41.0**。 +本次候选 **0.0.6** 配对正式 Calcit / `@calcit/procs` **0.41.1**。 消费者需重新安装完整依赖图、生成 JS 并完整刷新页面。Content 输入、Run、Reel 调试工具、 存档 key 和格式保持;Demo 不新增 Markdown 解析功能。UI/Reel 跨 minor 升级可能有样式差异。 0.0.6 尚未发布,正式 tag 出现前不要将本分支当作已发布依赖。 依赖使用已发布的 Respo **0.19.5**、UI **0.15.2**、Reel **0.11.0**、JS-FFI **0.2.13**, 传递 Router **0.12.2**;不再使用 Reel / Router 的旧 alpha 图。 -编辑回调派发 `Op :edit-content`,将正文声明为 String,更新时保留原状态 Map 的其他字段。Reel 0.11.0 面板与快捷键通过独立回调传递 `Control`。输入值由公开 `event-value` 检查为 String。 +编辑回调派发 `Op :edit-content`,只携带光标和 String 正文,更新时从当前状态保留 Map 的其他字段。Reel 0.11.0 面板与快捷键通过独立回调传递 `Control`。输入值由公开 `event-value` 检查为 String。 原 Reel 的 `read-field` 已删除;此处直接读取数据,保留 Map/Struct 字段读取及缺失值语义。 两个间隔分别保持 8 / 8px,开发态子节点显式使用 Option。 根渲染和原 SSR 回归均按 Respo 的公开 managed memo frame 合同包住构造与渲染。 diff --git a/calcit.cirru b/calcit.cirru index c1ebc37..d755c8c 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -22,14 +22,7 @@ try-decode-map-as value $ List respo.schema/CoordKey (:ok checked) checked (:err _) (raise "|Expected List cursor") - state $ let - raw $ match (get states :data) - (:some value) - or value $ {} $ :content | - (:none) - {} $ :content | - if (struct? raw) (&struct:to-map raw) - decode-map-as raw $ Map Dynamic Dynamic + state $ schema/read-editor-data $ respo.cursor/get-state-at states ([] :data) content $ get state :content div {} $ :class-name $ str-spaced css/global css/row @@ -42,9 +35,9 @@ :style $ {} $ :height |320px :on-input $ fn (e d!) hint-fn $ Fn respo.schema/RespoEvent - Fn app.schema/Op $ -> Unit + Fn schema/Op $ -> Unit -> Unit - d! $ schema/Op :edit-content cursor state $ event-value e + d! $ schema/Op :edit-content cursor $ event-value e space-x 8 div {} $ :class-name css/expand @@ -53,7 +46,7 @@ button $ {} (:class-name css/button) (:inner-text |Run) :on-click $ fn (e d!) hint-fn $ Fn respo.schema/RespoEvent - Fn app.schema/Op $ -> Unit + Fn schema/Op $ -> Unit -> Unit match content (:some value) (println value) @@ -122,7 +115,7 @@ (:none) &unit render-app! add-watch! *reel :changes $ fn (reel prev) - hint-fn $ Fn (reel.typed/State app.schema/Op app.schema/Store) (reel.typed/State app.schema/Op app.schema/Store) (-> Unit) + hint-fn $ Fn (typed/State schema/Op schema/Store) (typed/State schema/Op schema/Store) (-> Unit) render-app! listen-devtools! |k on-control! set-before-unload! $ fn (event) @@ -160,7 +153,7 @@ if (nil? build-errors) do (remove-watch! *reel :changes) (clear-cache!) add-watch! *reel :changes $ fn (reel prev) - hint-fn $ Fn (reel.typed/State app.schema/Op app.schema/Store) (reel.typed/State app.schema/Op app.schema/Store) (-> Unit) + hint-fn $ Fn (typed/State schema/Op schema/Store) (typed/State schema/Op schema/Store) (-> Unit) render-app! reset! *reel $ typed/refresh updater @*reel schema/store hud! |ok~ |Ok @@ -194,7 +187,7 @@ :defs $ {} 'Op $ %{} 'CodeEntry (:doc |) :code $ quote $ defenum Op - :edit-content (List respo.schema/CoordKey) (Map Dynamic Dynamic) String + :edit-content (List respo.schema/CoordKey) String :hydrate-storage app.schema/Store :examples $ [] :schema $ quote EnumDef @@ -228,6 +221,21 @@ :examples $ [] :schema $ quote $ Fn Dynamic -> $ Option Store + 'read-editor-data $ %{} 'CodeEntry + :doc "|Normalizes the existing editor state while preserving its extension fields." + :code $ quote $ defn read-editor-data (raw-option) + let + raw $ match raw-option + (:some value) + or value $ {} $ :content | + (:none) + {} $ :content | + if (struct? raw) (&struct:to-map raw) + decode-map-as raw $ Map Dynamic Dynamic + :examples $ [] + :schema $ quote $ Fn (Option T) + -> $ Map Dynamic Dynamic + :generics T 'store $ %{} 'CodeEntry (:doc |) :code $ quote $ def store Store :states $ {} $ :cursor ([]) @@ -240,13 +248,16 @@ %{} 'CodeEntry (:doc |) :code $ quote $ defn updater (store op op-id op-time) match op - (:edit-content cursor previous content) - assoc store :states $ decode-map-as - update-state-tree (:states store) cursor $ assoc previous :content content - Map Dynamic Dynamic + (:edit-content cursor content) + let + states $ :states store + previous $ app.schema/read-editor-data $ get-state-at states (conj cursor :data) + assoc store :states $ decode-map-as + update-state-tree states cursor $ assoc previous :content content + Map Dynamic Dynamic (:hydrate-storage data) data :examples $ [] :schema $ quote $ Fn app.schema/Store app.schema/Op String Number (-> app.schema/Store) :ns $ %{} 'NsEntry (:doc |) :code $ quote $ ns app.updater - :require $ respo.cursor :refer $ update-state-tree + :require $ respo.cursor :refer $ update-state-tree get-state-at diff --git a/deps.cirru b/deps.cirru index 4770069..be0aa8a 100644 --- a/deps.cirru +++ b/deps.cirru @@ -1,5 +1,5 @@ -{} (:calcit-version |0.41.0) +{} (:calcit-version |0.41.1) :version |0.0.6 :dependencies $ {} (|Respo/reel.calcit |0.11.0) |Respo/respo-ui.calcit |0.15.2 diff --git a/package.json b/package.json index c021d10..5ebc1b9 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "packageManager": "yarn@4.18.0", "dependencies": { - "@calcit/procs": "0.41.0" + "@calcit/procs": "0.41.1" }, "devDependencies": { "bottom-tip": "^0.1.5", diff --git a/scripts/typed-reel-render.test.mjs b/scripts/typed-reel-render.test.mjs index f74a81c..def6f11 100644 --- a/scripts/typed-reel-render.test.mjs +++ b/scripts/typed-reel-render.test.mjs @@ -31,9 +31,11 @@ test('renders the typed Reel devtools with an empty history', () => { test('content edits survive Reel replay and the existing saved-state format', () => { const field = (value, key) => clt.get(value, clt.init_tags([key])[key]).extra[0]; - const t = clt.init_tags(['edit-content', 'other']); - const edit = clt._PCT__$o__$o_(Op, t['edit-content'], clt._$L_(), clt._$n__$M_(t.other, true), '中文🐈'); - const reel = record_op(updater, new_reel(store), edit, 'edit', 1); + const t = clt.init_tags(['edit-content', 'states', 'data', 'other']); + const previous = clt.assoc(store, t.states, + clt.assoc(field(store, 'states'), t.data, clt._$n__$M_(t.other, true))); + const edit = clt._PCT__$o__$o_(Op, t['edit-content'], clt._$L_(), '中文🐈'); + const reel = record_op(updater, new_reel(previous), edit, 'edit', 1); const current = field(reel, 'store'); assert.equal(field(field(field(current, 'states'), 'data'), 'content'), '中文🐈'); assert.equal(field(field(field(current, 'states'), 'data'), 'other'), true); @@ -41,7 +43,7 @@ test('content edits survive Reel replay and the existing saved-state format', () const restored = clt.option_$o_unwrap(decode_store(clt.parse_cirru_edn(clt.format_cirru_edn(current)))); assert.equal(clt.format_cirru_edn(restored), clt.format_cirru_edn(current)); assert.equal(clt.option_$o_unwrap(decode_store(current)), current); - assert.equal(clt.format_cirru_edn(field(refresh(updater, reel, store), 'store')), clt.format_cirru_edn(current)); + assert.equal(clt.format_cirru_edn(field(refresh(updater, reel, previous), 'store')), clt.format_cirru_edn(current)); assert.equal(clt.option_$o_none_$q_(decode_store(clt.parse_cirru_edn('{} (:states $ {} (:cursor |wrong))'))), true); assert.equal(clt.option_$o_none_$q_(decode_store(clt.parse_cirru_edn(PRE_031_ARCHIVE.replace(':cursor $ []', ':cursor |wrong')))), true); assert.equal(clt.option_$o_some_$q_(decode_store(clt.parse_cirru_edn('{} (:states $ {})'))), true); diff --git a/yarn.lock b/yarn.lock index 244149d..1ad6fff 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,15 +12,15 @@ __metadata: languageName: node linkType: hard -"@calcit/procs@npm:0.41.0": - version: 0.41.0 - resolution: "@calcit/procs@npm:0.41.0" +"@calcit/procs@npm:0.41.1": + version: 0.41.1 + resolution: "@calcit/procs@npm:0.41.1" 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/5de94b39e435363d0f80611b63914c9abd6b0afac3c77adf9b9846ac439fce319ac0780697364cabf67b2997d39495a1e72086e1496ac560c51bb57462f37628 + checksum: 10c0/f14d3d61fdfc3fef4b7b215cc4c2be3923950b42ea19333d94e3fc689631545b2e6f56a8da31246971c7beaf1283d6f55a3af469a20bd9cb80be9352996d413f languageName: node linkType: hard @@ -637,7 +637,7 @@ __metadata: version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: - "@calcit/procs": "npm:0.41.0" + "@calcit/procs": "npm:0.41.1" bottom-tip: "npm:^0.1.5" vite: "npm:8.3.3" languageName: unknown