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
27 changes: 12 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ http://r.tiye.me/Memkits/diffview/

### 使用者影响

CLI 与 `@calcit/procs` 配对升级到正式 **0.34.2**,需要重新安装完整模块图、
生成 JS 并完整刷新,不能跨工具链热重载旧 Reel。依赖使用正式 Reel **0.9.0**、
UI **0.14.1**、Respo **0.19.2**、JS-FFI **0.2.10**,传递 Router **0.11.2**。
CLI 与 `@calcit/procs` 配对升级到正式 **0.35.1**,需要重新安装完整模块图、
生成 JS 并完整刷新,不能跨工具链热重载旧 Reel。依赖使用正式 Reel **0.9.2**、
UI **0.15.1**、Respo **0.19.4**、JS-FFI **0.2.13**,传递 Router **0.12.1**。
不使用 main/hash 或 alpha,不关闭 Caps strict 解决冲突。

行/词差异、Sorted、Swap、Clear、原 ⌘E/⌘I/⌘K、存储 key `diffview` 和 Map 存档
Expand All @@ -21,19 +21,17 @@ UI **0.14.1**、Respo **0.19.2**、JS-FFI **0.2.10**,传递 Router **0.11.2**
文本仍由原 String decoder 拒绝,不在失败时写入状态。旧 Map 事件夹具改用 Respo
公开 event→EDN 适配,原六项测试及全部断言保留。

已有 DiffChunk、StoreData 和 `Map Tag String` site 配置保持,不新增无实际封闭模型
可对应的 union。存档入口仍接受原 Map/Struct,通过原 decoder 构造本地 StoreData;
原 inline hint 移到公开 schema,不再把这个函数显示为 untyped。Reel 仍接受原业务
Enum/匿名控制;开放 dispatch 和异构状态保留真实边界,不宣称 Dynamic 债务清零。
DiffChunk、StoreData 和 `Map Tag String` site 配置沿用。存档入口接受原 Map/Struct,
通过原 decoder 构造本地 StoreData。派发入口接收 Respo 与 Reel 的匿名枚举,
校验并转换为具名 `Op` 再写入 Reel。状态坐标使用 Respo 的 `CoordKey` union,
状态节点载荷继续接受异构数据。

根组件构建与 render! 同处 managed memo frame。开发 Reel 直接使用 typed State,
两个开发工具条件子节点采用 Option,四处 spacer 保持宽 16。官方同版本格式器/
query 比对 28 个原定义:四个 code 视图改变(含一处纯类型 hint 移位)、两个 schema、
两个 namespace import;其余代码、schema、文档、附带测试/示例和 FFI 元数据不变。
两个开发工具条件子节点采用 Option,四处 spacer 保持宽 16。

### 安装与原门禁

使用 Calcit 0.34.2、Caps 0.1.1、Node.js 24、Yarn 4.18.0。
使用 Calcit 0.35.1、Caps 0.1.1、Node.js 24、Yarn 4.18.0。
Caps 独立安装,见 [官方说明](https://github.com/calcit-lang/caps);Corepack/Yarn 不会安装它。
新解析 npm 包保留 60 分钟年龄门禁,无单包例外。lock 只更新 procs 配对;已有
undici Dependabot #48 单独保留。
Expand All @@ -53,11 +51,10 @@ node --test scripts/upgrade.test.mjs
Snapshot 使用官方 query/tree/edit 与 revision 事务,不用文本补丁或自行解析。

保留原 canonical、全定义、完整 strict、公开定义及原六项 Node 业务回归。
本轮正式五模块 Caps strict/toolchain、Yarn immutable、全部定义、28 个公开定义、
完整 strict(diagnostics=[])、原六项回归与 JS/Vite 构建通过;deprecated-call、
dynamic-method 为 0。没有 definition-attached tests,不把空测试称为通过。
0.35.1 的 Caps strict/toolchain、Yarn immutable、224 个完整定义、31 个公开定义、
完整 strict、原六项回归与 JS/Vite 构建通过。

普通可见 Chrome 在独立回环来源使用合成中文/emoji、多行文本,实际验证行/词模式、
此前 0.34.2 在普通 Chrome 的独立回环来源使用合成中文/emoji、多行文本,实际验证行/词模式、
Sorted 的重排等价、Swap、Clear、⌘快捷键及刷新恢复,无应用 pageerror。
另在两个全新回环来源通过可见夹具分别写入坏 EDN 与合法 EDN/错误 StoreData,
两次均检查启动失败、原 60 秒保存周期、离页和刷新后原文不变;只用合成数据,
Expand Down
104 changes: 69 additions & 35 deletions calcit.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{} (:description |) (:init-fn 'app.main/main!) (:mode :js) (:reload-fn 'app.main/reload!) (:target :browser)
:feature-policy $ {}
:modules $ [] |respo.calcit/ |respo-ui.calcit/ |reel.calcit/ |js-ffi/
:type-slots $ {} $ :dispatch-op 'Dynamic
:type-slots $ {} $ :dispatch-op |app.schema/DispatchOp
:files $ {}
'app.comp.container $ %{} 'FileEntry
:defs $ {}
Expand Down Expand Up @@ -40,7 +40,7 @@
sort-by-line $ :old-text store
sort-by-line $ :new-text store
differ (:old-text store) (:new-text store)
quote $ List app.schema/DiffChunk
List app.schema/DiffChunk
div
{} $ :class-name $ str-spaced css/global css/fullscreen css/column
comp-toolbar show-result? sorted? by-word?
Expand All @@ -57,7 +57,7 @@
:placeholder "|Old text"
:on-input $ fn (e d!)
hint-fn $ Fn respo.schema/RespoEvent
Fn Enum $ -> Unit
Fn AnyEnum $ -> Unit
-> Unit
d! $ :: :write-old $ let
value $ :value e
Expand All @@ -73,7 +73,7 @@
:placeholder "|New text"
:on-input $ fn (e d!)
hint-fn $ Fn respo.schema/RespoEvent
Fn Enum $ -> Unit
Fn AnyEnum $ -> Unit
-> Unit
d! $ :: :write-new $ let
value $ :value e
Expand All @@ -88,7 +88,7 @@
Option :some $ comp-inspect |Store store $ {} (:bottom |0px)
Option :none
:examples $ []
:schema $ quote $ Fn (reel.typed/State Enum app.schema/StoreData) (-> respo.schema/Component) (:features :js-ffi)
:schema $ quote $ Fn (reel.typed/State app.schema/Op app.schema/StoreData) (-> respo.schema/Component) (:features :js-ffi)
'comp-diff-view $ %{} 'CodeEntry (:doc |)
:code $ quote $ defcomp comp-diff-view (changes by-word?)
list->
Expand Down Expand Up @@ -130,33 +130,33 @@
{} $ :class-name css/row-center
comp-checked show-result? "|Result?(⌘ e)" $ fn (e d!)
hint-fn $ Fn respo.schema/RespoEvent
Fn Enum $ -> Unit
Fn AnyEnum $ -> Unit
-> Unit
d! $ :: :toggle-result
space-x 16
comp-checked sorted? |Sorted $ fn (e d!)
hint-fn $ Fn respo.schema/RespoEvent
Fn Enum $ -> Unit
Fn AnyEnum $ -> Unit
-> Unit
d! $ :: :toggle-sorted
space-x 16
comp-checked by-word? |ByWord $ fn (e d!)
hint-fn $ Fn respo.schema/RespoEvent
Fn Enum $ -> Unit
Fn AnyEnum $ -> Unit
-> Unit
d! $ :: :toggle-word
space-x 16
a $ {} (:class-name css/link) (:inner-text |Swap) (:title "|⌘ i")
:on-click $ fn (e d!)
hint-fn $ Fn respo.schema/RespoEvent
Fn Enum $ -> Unit
Fn AnyEnum $ -> Unit
-> Unit
d! $ :: :swap-text
space-x 16
a $ {} (:class-name css/link) (:inner-text |Clear) (:title "|⌘ k")
:on-click $ fn (e d!)
hint-fn $ Fn respo.schema/RespoEvent
Fn Enum $ -> Unit
Fn AnyEnum $ -> Unit
-> Unit
d! $ :: :clear-text
:examples $ []
Expand Down Expand Up @@ -244,20 +244,18 @@
'*reel $ %{} 'CodeEntry (:doc |)
:code $ quote $ defref *reel (typed-reel/new-reel schema/store)
:examples $ []
:schema $ quote $ Ref (reel.typed/State Enum app.schema/StoreData)
:schema $ quote $ Ref (reel.typed/State app.schema/Op app.schema/StoreData)
'dispatch! $ %{} 'CodeEntry (:doc |)
:code $ quote $ defn dispatch! (op)
when config/dev? $ js/console.log |Dispatch: op
if (enum? op)
match (typed-reel/decode-control op)
(:some control)
reset! *reel $ typed-reel/apply-control updater @*reel control
(:none)
reset! *reel $ typed-reel/record-op updater @*reel op (generate-id!) (host/now-ms)
raise "|Expected one operation enum"
match (typed-reel/decode-control op)
(:some control)
reset! *reel $ typed-reel/apply-control updater @*reel control
(:none)
reset! *reel $ typed-reel/record-op updater @*reel (schema/decode-op op) (generate-id!) (host/now-ms)
, &unit
:examples $ []
:schema $ quote $ Fn Dynamic (-> Unit) (:features :js-ffi)
:schema $ quote $ Fn AnyEnum (-> Unit) (:features :js-ffi)
'main! $ %{} 'CodeEntry (:doc |)
:code $ quote $ defn main! ()
if config/dev? $ load-console-formatter!
Expand All @@ -269,7 +267,7 @@
(:none) &unit
render-app!
add-watch! *reel :changes $ fn (r p)
hint-fn $ Fn (reel.typed/State Enum app.schema/StoreData) (reel.typed/State Enum app.schema/StoreData) (-> Unit)
hint-fn $ Fn (reel.typed/State app.schema/Op app.schema/StoreData) (reel.typed/State app.schema/Op app.schema/StoreData) (-> Unit)
render-app!
listen-devtools! |a dispatch!
browser/add-event-listener! |beforeunload $ fn (event)
Expand Down Expand Up @@ -314,7 +312,7 @@
if (js-nullish? build-errors)
do (remove-watch! *reel :changes) (clear-cache!)
add-watch! *reel :changes $ fn (reel prev)
hint-fn $ Fn (reel.typed/State Enum app.schema/StoreData) (reel.typed/State Enum app.schema/StoreData) (-> Unit)
hint-fn $ Fn (reel.typed/State app.schema/Op app.schema/StoreData) (reel.typed/State app.schema/Op app.schema/StoreData) (-> Unit)
render-app!
reset! *reel $ typed-reel/refresh updater @*reel schema/store
hud! |ok~ |Ok
Expand Down Expand Up @@ -357,14 +355,32 @@
:defs $ {}
'DiffChunk $ %{} 'CodeEntry (:doc |)
:code $ quote $ defstruct DiffChunk (:value String)
:added $ quote $ Option Bool
:removed $ quote $ Option Bool
:added $ Option Bool
:removed $ Option Bool
:count Number
:examples $ []
:schema $ quote StructDef
'DispatchOp $ %{} 'CodeEntry (:doc |)
:code $ quote $ def DispatchOp (:: :unhandled)
:examples $ []
:schema $ quote AnyEnum
'Op $ %{} 'CodeEntry (:doc |)
:code $ quote $ defenum Op
:states (List respo.schema/CoordKey) Dynamic
:write-old String
:write-new String
:hydrate-storage app.schema/StoreData
:toggle-sorted
:toggle-result
:toggle-word
:clear-text
:swap-text
:unknown AnyEnum
:examples $ []
:schema $ quote EnumDef
'StoreData $ %{} 'CodeEntry (:doc |)
:code $ quote $ defstruct StoreData
:states $ quote $ Map Tag Dynamic
:states $ Map Tag Dynamic
:page Tag
:sorted? Bool
:show-result? Bool
Expand All @@ -373,6 +389,27 @@
:new-text String
:examples $ []
:schema $ quote StructDef
'decode-op $ %{} 'CodeEntry (:doc |)
:code $ quote $ defn decode-op (raw)
match raw
(:states cursor data)
Op :states
decode-map-as cursor $ List respo.schema/CoordKey
, data
(:write-old text)
Op :write-old $ decode-map-as text String
(:write-new text)
Op :write-new $ decode-map-as text String
(:hydrate-storage data)
Op :hydrate-storage $ normalize-store data
(:toggle-sorted) (Op :toggle-sorted)
(:toggle-result) (Op :toggle-result)
(:toggle-word) (Op :toggle-word)
(:clear-text) (Op :clear-text)
(:swap-text) (Op :swap-text)
_ $ Op :unknown raw
:examples $ []
:schema $ quote $ Fn AnyEnum (-> app.schema/Op)
'normalize-store $ %{} 'CodeEntry (:doc |)
:code $ quote $ defn normalize-store (raw)
decode-map-as
Expand All @@ -394,15 +431,11 @@
match op
(:states cursor s)
assoc store :states $ decode-map-as
update-state-tree (:states store)
decode-map-as cursor $ quote $ List Dynamic
, s
quote $ Map Tag Dynamic
(:write-old d)
assoc store :old-text $ decode-map-as d 'String
(:write-new d)
assoc store :new-text $ decode-map-as d 'String
(:hydrate-storage d) (schema/normalize-store d)
update-state-tree (:states store) cursor s
Map Tag Dynamic
(:write-old d) (assoc store :old-text d)
(:write-new d) (assoc store :new-text d)
(:hydrate-storage d) d
(:toggle-sorted) (update store :sorted? not)
(:toggle-result) (update store :show-result? not)
(:toggle-word) (update store :by-word? not)
Expand All @@ -412,9 +445,10 @@
-> store
assoc :old-text $ :new-text store
assoc :new-text $ :old-text store
_ $ do (eprintln "|Unkown op:" op) store
(:unknown raw)
do (eprintln "|Unknown op:" raw) store
:examples $ []
:schema $ quote $ Fn app.schema/StoreData Enum String Number (-> app.schema/StoreData)
:schema $ quote $ Fn app.schema/StoreData app.schema/Op String Number (-> app.schema/StoreData)
:ns $ %{} 'NsEntry (:doc |)
:code $ quote $ ns app.updater
:require
Expand Down
12 changes: 6 additions & 6 deletions deps.cirru
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

{} (:calcit-version |0.34.2)
:version |0.1.3
:dependencies $ {} (|Respo/reel.calcit |0.9.0)
|Respo/respo-ui.calcit |0.14.1
|Respo/respo.calcit |0.19.2
|calcit-lang/js-ffi |0.2.10
{} (:calcit-version |0.35.1)
:version |0.1.4
:dependencies $ {} (|Respo/reel.calcit |0.9.2)
|Respo/respo-ui.calcit |0.15.1
|Respo/respo.calcit |0.19.4
|calcit-lang/js-ffi |0.2.13
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "calcit-workflow",
"version": "0.1.3",
"version": "0.1.4",
"description": "Online text diff viewer built with Calcit and Respo",
"main": "index.js",
"repository": {
Expand All @@ -20,7 +20,7 @@
"vite": "8.3.3"
},
"dependencies": {
"@calcit/procs": "0.34.2",
"@calcit/procs": "0.35.1",
"diff": "^8.0.2"
}
}
23 changes: 9 additions & 14 deletions scripts/upgrade.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,29 @@ import test from "node:test";

import { assoc, init_tags } from "../js-out/calcit.core.mjs";
import { comp_container } from "../js-out/app.comp.container.mjs";
import { store as defaultStore } from "../js-out/app.schema.mjs";
import { decode_op, store as defaultStore } from "../js-out/app.schema.mjs";
import { new_reel } from "../js-out/reel.typed.mjs";
import * as clt from "../js-out/calcit.core.mjs";
import { updater } from "../js-out/app.updater.mjs";
import { sort_by_line } from "../js-out/app.comp.container.mjs";
import { make_string } from "../js-out/respo.render.html.mjs";
import { event__GT_edn } from "../js-out/respo.util.format.mjs";
import { child_pair_value, component_$q_, component_tree } from "../js-out/respo.util.detect.mjs";
import { as_element, child_pair_value, component_$q_, component_tree, element_children, element_event } from "../js-out/respo.util.detect.mjs";

const t = init_tags(["states", "old-text", "new-text", "show-result?", "sorted?", "by-word?", "children", "event", "input", "click", "value", "data", "editor"]);
const t = init_tags(["states", "old-text", "new-text", "show-result?", "sorted?", "by-word?", "input", "click", "value", "data", "editor"]);
const unwrap = clt.option_$o_unwrap;
const read = (value, key) => unwrap(clt.get(value, key));
const op = (name, ...args) => clt._$o__$o_(init_tags([name])[name], ...args);
const apply = (store, name, ...args) => updater(store, op(name, ...args), "test", 0);
const apply = (store, name, ...args) => updater(store, decode_op(op(name, ...args)), "test", 0);
const render = (store) => comp_container(new_reel(store));

function handlers(node, kind) {
if (component_$q_(node)) return handlers(unwrap(component_tree(node)), kind);
const element = as_element(node);
const result = [];
const events = clt.get(node, t.event);
if (clt.option_$o_some_$q_(events)) {
const handler = clt.get(unwrap(events), kind);
if (clt.option_$o_some_$q_(handler)) result.push(unwrap(handler));
}
const children = clt.get(node, t.children);
if (clt.option_$o_some_$q_(children)) {
for (const pair of unwrap(children).toArray()) result.push(...handlers(child_pair_value(pair), kind));
}
const handler = clt.get(element_event(element), kind);
if (clt.option_$o_some_$q_(handler)) result.push(unwrap(handler));
for (const pair of element_children(element).toArray()) result.push(...handlers(child_pair_value(pair), kind));
return result;
}

Expand Down Expand Up @@ -64,7 +59,7 @@ test("textarea callbacks dispatch one Enum and preserve missing-value fallback",
let store = defaultStore;
const dispatch = (...args) => {
assert.equal(args.length, 1);
store = updater(store, args[0], "test", 0);
store = updater(store, decode_op(args[0]), "test", 0);
};
handler(event__GT_edn({type: "input", target: {value: `text-${index}`}}), dispatch);
const field = index === 0 ? t["old-text"] : t["new-text"];
Expand Down
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.