diff --git a/README.md b/README.md index 36f216f..cfbf86e 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ ClojureScript, beginners' home page ### 使用者影响 -升级到 Calcit 和 `@calcit/procs` **0.41.1** 后,请重新安装依赖、生成 JS 并刷新页面。导航、十份展示示例、代码高亮、旧 Map 存档和页面 HUD 继续适用。`content/*.cljs` 仍作为页面示例展示。 +升级到 Calcit 和 `@calcit/procs` **0.42.1** 后,请重新安装依赖、生成 JS 并刷新页面。导航、十份展示示例、代码高亮、旧 Map 存档和页面 HUD 继续适用。`content/*.cljs` 仍作为页面示例展示。 Logo 切换使用 `RespoEvent` 和具名 `Action`,状态路径校验为 `CoordKey`。开发面板直接使用类型化 Reel,渲染进入 Respo 的 memo frame。依赖配对正式 Respo **0.19.5**、Reel **0.11.0**、Markdown **0.8.2**、UI **0.15.2**、JS-FFI **0.2.13**,传递 Router **0.12.2**。 页面只派发具名 `Action`,Reel 面板和快捷键单独接收 `reel.typed/Control`,两者在更新状态时用联合类型匹配,缺席的工具 Logo 保持为 `Option`。Highlight.js 注册回调使用具名宿主类型。 diff --git a/calcit.cirru b/calcit.cirru index 3c685e3..18564d5 100644 --- a/calcit.cirru +++ b/calcit.cirru @@ -246,7 +246,7 @@ 'dispatch! $ %{} 'CodeEntry (:doc "|Dispatches a typed application action.") :code $ quote $ defn dispatch! (op) (dispatch-resolved! op) :examples $ [] - :schema $ quote $ Fn schema/Action (-> Unit) (:features :js-ffi) + :schema $ quote $ Fn schema/Action (-> Unit) (:features :js-ffi :state) 'dispatch-resolved! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn dispatch-resolved! (op) reset! *reel $ match op @@ -255,7 +255,7 @@ typed-reel/record-op updater @*reel action (generate-id!) (host/now-ms) , &unit :examples $ [] - :schema $ quote $ Fn schema/ResolvedAction (-> Unit) (:features :js-ffi) + :schema $ quote $ Fn schema/ResolvedAction (-> Unit) (:features :js-ffi :state) 'main! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn main! () println "|Running mode:" $ if config/dev? |dev |release @@ -283,7 +283,7 @@ dispatch! $ schema/Action :pick-case $ decode-map-as (rand-int 10) Number println "|App started." :examples $ [] - :schema $ quote $ Fn (-> Unit) (:features :js-ffi) + :schema $ quote $ Fn (-> Unit) (:features :io :js-ffi :state) 'mount-target $ %{} 'CodeEntry (:doc |) :code $ quote $ defn mount-target () let @@ -296,7 +296,7 @@ 'on-control! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn on-control! (control) (dispatch-resolved! control) :examples $ [] - :schema $ quote $ Fn reel.typed/Control (-> Unit) (:features :js-ffi) + :schema $ quote $ Fn reel.typed/Control (-> Unit) (:features :js-ffi :state) 'reload! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn reload! () if (js-nullish? build-errors) @@ -309,14 +309,14 @@ hud! |error build-errors , &unit :examples $ [] - :schema $ quote $ Fn (-> Unit) (:features :js-ffi) + :schema $ quote $ Fn (-> Unit) (:features :js-ffi :state) 'render-app! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn render-app! () render-with! (mount-target) fn () $ comp-container @*reel on-control! , dispatch! :examples $ [] - :schema $ quote $ Fn (-> Unit) (:features :js-ffi) + :schema $ quote $ Fn (-> Unit) (:features :js-ffi :state) 'save-store! $ %{} 'CodeEntry (:doc |) :code $ quote $ defn save-store! () let @@ -327,7 +327,7 @@ :content $ :content store :case-idx $ :case-idx store :examples $ [] - :schema $ quote $ Fn (-> Unit) + :schema $ quote $ Fn (-> Unit) (:features :state) :ns $ %{} 'NsEntry (:doc |) :code $ quote $ ns app.main :require @@ -349,7 +349,7 @@ :defs $ {} 'Action $ %{} 'CodeEntry (:doc |) :code $ quote $ defenum Action - :states (List respo.schema/CoordKey) Dynamic + :states (List respo.schema/CoordKey) StateValue :content String :pick-case Number :hydrate-storage app.schema/Store @@ -363,10 +363,14 @@ :code $ quote $ defstruct Showcase (:code String) (:text String) (:url String) :examples $ [] :schema $ quote StructDef + 'StateValue $ %{} 'CodeEntry (:doc |) + :code $ quote $ defunion StateValue Bool Number String Tag (List StateValue) (Map respo.schema/CoordKey StateValue) + :examples $ [] + :schema $ quote UnionDef 'Store $ %{} 'CodeEntry - :doc "|Application fields are concrete. Only the Respo component-state tree retains its existing heterogeneous payload contract; hydrate and updates must pass a runtime decoder." + :doc "|Application fields and the recursive Respo state tree are checked at hydration and update boundaries." :code $ quote $ defstruct Store - :states $ Map Tag Dynamic + :states $ Map respo.schema/CoordKey StateValue :content String :case-idx Number :examples $ [] @@ -394,7 +398,8 @@ :code $ quote $ let action $ restore-action $ format-cirru-edn {} - :states $ {} + :states $ {} $ :reel + {} $ :data false :content |saved :case-idx 3 match action @@ -402,6 +407,8 @@ do assert= |saved $ :content restored assert= 3 $ :case-idx restored + assert= (:states restored) + {} $ :reel $ {} (:data false) _ $ raise "|Expected hydration action" :tags $ #{} :regression :unit 'updater $ %{} 'CodeEntry (:doc |) @@ -410,7 +417,7 @@ (:states cursor s) assoc store :states $ decode-map-as update-state-tree (:states store) cursor s - Map Tag Dynamic + Map respo.schema/CoordKey app.schema/StateValue (:content c) (assoc store :content c) (:pick-case c) (assoc store :case-idx c) (:hydrate-storage d) d diff --git a/deps.cirru b/deps.cirru index 2ec76bf..3d0d9d5 100644 --- a/deps.cirru +++ b/deps.cirru @@ -1,4 +1,4 @@ -{} (:calcit-version |0.41.1) (:version |0.1.1) +{} (:calcit-version |0.42.1) (:version |0.1.1) :dependencies $ {} |Respo/respo.calcit |0.19.5 |Respo/reel.calcit |0.11.0 diff --git a/package.json b/package.json index 52a3a60..219b5c7 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "vite": "8.3.3" }, "dependencies": { - "@calcit/procs": "0.41.1", + "@calcit/procs": "0.42.1", "@calcit/std": "^0.0.2", "cirru-color": "^0.2.4", "copy-text-to-clipboard": "^3.2.2", diff --git a/yarn.lock b/yarn.lock index 9ef14cd..acd352a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,15 +12,15 @@ __metadata: languageName: node linkType: hard -"@calcit/procs@npm:0.41.1": - version: 0.41.1 - resolution: "@calcit/procs@npm:0.41.1" +"@calcit/procs@npm:0.42.1": + version: 0.42.1 + resolution: "@calcit/procs@npm:0.42.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/f14d3d61fdfc3fef4b7b215cc4c2be3923950b42ea19333d94e3fc689631545b2e6f56a8da31246971c7beaf1283d6f55a3af469a20bd9cb80be9352996d413f + checksum: 10c0/58e306e7bc72b258e07c33dae4d543241cd0c7ed6830262628bf61c734453d7907ef453af0b25a770ba911e9ce6ede19f869d9a78decea4589cf4ae1f7c40629 languageName: node linkType: hard @@ -229,7 +229,7 @@ __metadata: version: 0.0.0-use.local resolution: "clojure-script-org@workspace:." dependencies: - "@calcit/procs": "npm:0.41.1" + "@calcit/procs": "npm:0.42.1" "@calcit/std": "npm:^0.0.2" bottom-tip: "npm:^0.1.5" cirru-color: "npm:^0.2.4"