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 @@ -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 合同包住构造与渲染。
Expand Down
49 changes: 30 additions & 19 deletions calcit.cirru
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ([])
Expand All @@ -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
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.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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
10 changes: 6 additions & 4 deletions scripts/typed-reel-render.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,19 @@ 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);
assert.match(renderHtml(reel), /中文🐈/);
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);
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.