@lostgradient/cinder 0.16.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +203 -0
- package/README.md +33 -11
- package/components.json +54 -102
- package/dist/_internal/chart/chart-utilities.d.ts +1 -0
- package/dist/cli/index.js +64 -11
- package/dist/cli/mcp-dependencies.d.ts +4 -0
- package/dist/cli/types.d.ts +1 -0
- package/dist/components/approval-card/approval-card.css +1 -6
- package/dist/components/approval-card/index.js +171 -64
- package/dist/components/area-chart/index.js +40 -6
- package/dist/components/bar-chart/index.js +132 -83
- package/dist/components/code-block/index.js +133 -17
- package/dist/components/combobox/combobox.schema.js +14 -1
- package/dist/components/combobox/combobox.svelte.d.ts +12 -12
- package/dist/components/combobox/combobox.types.d.ts +11 -5
- package/dist/components/combobox/index.js +94 -16
- package/dist/components/command-menu/command-menu.css +9 -0
- package/dist/components/command-menu/index.js +7 -2
- package/dist/components/diff-statistics/diff-statistics.svelte.d.ts +3 -3
- package/dist/components/event-stream-viewer/index.js +3 -2
- package/dist/components/file-upload/file-upload.schema.js +5 -1
- package/dist/components/file-upload/file-upload.types.d.ts +2 -0
- package/dist/components/file-upload/index.js +37 -27
- package/dist/components/invocation-rule-builder/index.d.ts +1 -1
- package/dist/components/invocation-rule-builder/index.js +3656 -389
- package/dist/components/invocation-rule-builder/invocation-rule-builder.css +22 -0
- package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.d.ts +2 -2
- package/dist/components/invocation-rule-builder/invocation-rule-builder.schema.js +309 -193
- package/dist/components/invocation-rule-builder/invocation-rule-builder.svelte.d.ts +3 -2
- package/dist/components/invocation-rule-builder/invocation-rule-builder.types.d.ts +98 -31
- package/dist/components/json-editor/index.d.ts +5 -0
- package/dist/components/json-editor/index.js +329 -0
- package/dist/components/json-editor/json-editor-enhancement.d.ts +7 -0
- package/dist/components/json-editor/json-editor-enhancement.js +201 -0
- package/dist/components/json-editor/json-editor.css +117 -0
- package/dist/components/{diff-viewer/diff-viewer.schema.js → json-editor/json-editor.schema.js} +40 -48
- package/dist/components/json-editor/json-editor.svelte.d.ts +21 -0
- package/dist/components/json-editor/json-editor.types.d.ts +27 -0
- package/dist/components/{diff-viewer/diff-viewer.variables.js → json-editor/json-editor.variables.js} +4 -4
- package/dist/components/json-schema-editor/index.js +2041 -4165
- package/dist/components/json-schema-editor/json-schema-editor-state.svelte.d.ts +17 -1
- package/dist/components/json-schema-editor/json-schema-editor-types.d.ts +8 -1
- package/dist/components/json-schema-editor/json-schema-editor.css +35 -0
- package/dist/components/json-schema-editor/json-schema-editor.svelte.d.ts +0 -1
- package/dist/components/json-schema-editor/json-schema-validator.d.ts +9 -4
- package/dist/components/line-chart/index.js +40 -6
- package/dist/components/matrix-chart/index.js +40 -6
- package/dist/components/payload-inspector/index.js +10 -2
- package/dist/components/payload-inspector/payload-inspector.schema.js +11 -1
- package/dist/components/payload-inspector/payload-inspector.types.d.ts +20 -0
- package/dist/components/run-step-timeline/index.js +160 -111
- package/dist/components/run-step-timeline/run-step-timeline.css +46 -0
- package/dist/components/run-step-timeline/run-step-timeline.schema.js +26 -1
- package/dist/components/run-step-timeline/run-step-timeline.types.d.ts +22 -2
- package/dist/components/schedule-builder/index.js +165 -93
- package/dist/components/schedule-builder/schedule-builder.schema.js +8 -1
- package/dist/components/schedule-builder/schedule-builder.svelte.d.ts +1 -1
- package/dist/components/schedule-builder/schedule-builder.types.d.ts +12 -0
- package/dist/components/schema-form/index.d.ts +1 -1
- package/dist/components/schema-form/index.js +107 -25
- package/dist/components/schema-form/schema-form.schema.js +9 -1
- package/dist/components/schema-form/schema-form.svelte.d.ts +1 -1
- package/dist/components/schema-form/schema-form.types.d.ts +8 -0
- package/dist/components/sidebar/index.js +93 -42
- package/dist/components/sidebar/sidebar.css +7 -16
- package/dist/components/sidebar/sidebar.schema.js +8 -9
- package/dist/components/sidebar/sidebar.types.d.ts +14 -12
- package/dist/components/source-diff-viewer/source-diff-viewer.svelte.d.ts +2 -2
- package/dist/components/spectrogram/index.js +40 -6
- package/dist/components/spectrum-chart/index.js +40 -6
- package/dist/components/status-dot/index.js +3 -2
- package/dist/components/tabs/tabs.css +2 -0
- package/dist/components/textarea/textarea.svelte.d.ts +1 -1
- package/dist/components/toast-region/index.js +2 -2
- package/dist/components/toast-region/toast-region.css +1 -1
- package/dist/components/waveform/index.js +40 -6
- package/dist/highlighters/shiki/default.d.ts +5 -0
- package/dist/highlighters/shiki/default.js +278 -0
- package/dist/highlighters/shiki/index.d.ts +54 -5
- package/dist/highlighters/shiki/index.js +102 -16
- package/dist/index.d.ts +4 -4
- package/dist/index.js +15642 -16181
- package/dist/server/components/access-gate/index.js +2 -5
- package/dist/server/components/approval-card/index.js +3 -3
- package/dist/server/components/area-chart/index.js +3 -3
- package/dist/server/components/bar-chart/index.js +3 -3
- package/dist/server/components/combobox/index.js +5 -3
- package/dist/server/components/command-menu/index.js +1 -1
- package/dist/server/components/context-menu/index.js +5 -5
- package/dist/server/components/data-table/index.js +2 -2
- package/dist/server/components/diff-statistics/index.js +3 -5
- package/dist/server/components/dropdown/index.js +6 -7
- package/dist/server/components/event-stream-viewer/index.js +2 -2
- package/dist/server/components/file-upload/index.js +2 -3
- package/dist/server/components/icons/index.js +17 -26
- package/dist/server/components/inline-loading/index.js +1 -1
- package/dist/server/components/invocation-rule-builder/index.js +15 -2
- package/dist/server/components/json-editor/index.js +13 -0
- package/dist/server/components/json-editor/json-editor-enhancement.js +150 -0
- package/dist/server/components/json-schema-editor/index.js +4 -16
- package/dist/server/components/line-chart/index.js +3 -3
- package/dist/server/components/matrix-chart/index.js +2 -2
- package/dist/server/components/menu-bar/index.js +4 -4
- package/dist/server/components/payload-inspector/index.js +2 -2
- package/dist/server/components/run-step-timeline/index.js +2 -2
- package/dist/server/components/schedule-builder/index.js +3 -3
- package/dist/server/components/schema-form/index.js +1 -1
- package/dist/server/components/selection-popover/index.js +3 -5
- package/dist/server/components/sidebar/index.js +1 -1
- package/dist/server/components/spectrogram/index.js +2 -2
- package/dist/server/components/spectrum-chart/index.js +2 -2
- package/dist/server/components/status-dot/index.js +2 -2
- package/dist/server/components/surface/index.js +3 -5
- package/dist/server/components/table/index.js +2 -2
- package/dist/server/components/tabs/index.js +5 -5
- package/dist/server/components/toast-region/index.js +1 -1
- package/dist/server/components/toolbar/index.js +2 -3
- package/dist/server/components/waveform/index.js +2 -2
- package/dist/server/highlighters/shiki/default.js +39 -0
- package/dist/server/highlighters/shiki/index.js +9 -97
- package/dist/server/index.js +110 -119
- package/dist/server/{index.server-7yfz2t73.js → index.server-003t81xk.js} +1 -1
- package/dist/server/{index.server-gwgm8gqg.js → index.server-032p855q.js} +4 -4
- package/dist/server/{index.server-npxtkwjp.js → index.server-0gg1njz4.js} +3 -2
- package/dist/server/{index.server-c5qv3p61.js → index.server-0hjcds3y.js} +93 -47
- package/dist/server/{index.server-tf2n3ccm.js → index.server-1vfhzhkj.js} +1 -1
- package/dist/server/{index.server-bf7d81b4.js → index.server-20km2ga0.js} +17 -19
- package/dist/server/{index.server-jz5yxwde.js → index.server-4cbqjf14.js} +16 -7
- package/dist/server/{index.server-g5jgq3jp.js → index.server-62593nnh.js} +41 -7
- package/dist/server/{index.server-aqethy0w.js → index.server-66nm5gd5.js} +102 -26
- package/dist/server/{index.server-m0ezemav.js → index.server-6mnbznbt.js} +4 -2
- package/dist/server/{index.server-1nq8h5yb.js → index.server-6vbpz6dd.js} +40 -6
- package/dist/server/{index.server-796hb0r8.js → index.server-7qak74fg.js} +1 -1
- package/dist/server/{index.server-5exh7rmw.js → index.server-7ygdwxre.js} +57 -5
- package/dist/server/{index.server-q1d48s9t.js → index.server-8c6cck0y.js} +6 -4
- package/dist/server/{index.server-m8ya4p7w.js → index.server-8grn4zd3.js} +74 -14
- package/dist/server/{index.server-ep81fn23.js → index.server-9eccb2fc.js} +2 -2
- package/dist/server/{index.server-zncgb7mw.js → index.server-9nac5z11.js} +92 -49
- package/dist/server/index.server-c9gtmre4.js +178 -0
- package/dist/server/{index.server-nt304e00.js → index.server-dx58qant.js} +1 -1
- package/dist/server/{index.server-zh3r8vfd.js → index.server-fhrqsg97.js} +1 -1
- package/dist/server/{index.server-dq0k0qf6.js → index.server-geq56xaz.js} +10 -10
- package/dist/server/{index.server-51sxnete.js → index.server-hxveaqg1.js} +10 -10
- package/dist/server/{index.server-tez36va4.js → index.server-kvn6cj65.js} +1 -1
- package/dist/server/{index.server-s5g7reqp.js → index.server-mewms9dg.js} +2 -2
- package/dist/server/index.server-mm728d0w.js +20 -0
- package/dist/server/{index.server-5mc2vsy0.js → index.server-n0rbn5yf.js} +4 -2
- package/dist/server/{index.server-qv0kkre4.js → index.server-ng8y854r.js} +188 -107
- package/dist/server/{index.server-wasj5rbh.js → index.server-q5gvb174.js} +4 -4
- package/dist/server/{index.server-x1dha7bk.js → index.server-rnddtcb3.js} +4 -2
- package/dist/server/{index.server-7zpzspk6.js → index.server-s4wm4g2a.js} +30 -2
- package/dist/server/index.server-szgghcdh.js +887 -0
- package/dist/server/index.server-v73af5rk.js +111 -0
- package/dist/server/{index.server-thcda9ny.js → index.server-vd302sxz.js} +11 -4
- package/dist/server/{index.server-3sq9d73w.js → index.server-vz9hqkdq.js} +2 -2
- package/dist/server/{index.server-mvjzcna5.js → index.server-wg6ddzpa.js} +42 -20
- package/dist/server/{index.server-qke3ekjt.js → index.server-ww54rv4y.js} +1 -1
- package/dist/server/index.server-x4a15jpm.js +9 -0
- package/dist/server/{index.server-67q8dmbp.js → index.server-y2ncgt7p.js} +1 -1
- package/dist/server/{index.server-4x91gzy1.js → index.server-yqhww50r.js} +4 -4
- package/dist/server/{index.server-7798gc22.js → index.server-zfx4magq.js} +4 -2
- package/dist/utilities/json-highlight.d.ts +2 -0
- package/package.json +63 -288
- package/src/_internal/chart/chart-utilities.ts +74 -5
- package/src/components/approval-card/approval-card-actions.svelte +12 -28
- package/src/components/approval-card/approval-card.css +1 -6
- package/src/components/bar-chart/bar-chart.examples.json +1 -1
- package/src/components/bar-chart/bar-chart.svelte +3 -1
- package/src/components/code-block/code-block-default-highlighter.ts +2 -2
- package/src/components/combobox/combobox.schema.json +13 -0
- package/src/components/combobox/combobox.schema.ts +13 -0
- package/src/components/combobox/combobox.svelte +100 -14
- package/src/components/combobox/combobox.types.ts +11 -5
- package/src/components/command-menu/command-menu.css +9 -0
- package/src/components/command-menu/command-menu.svelte +9 -2
- package/src/components/file-upload/file-upload.schema.json +4 -0
- package/src/components/file-upload/file-upload.schema.ts +4 -0
- package/src/components/file-upload/file-upload.svelte +3 -3
- package/src/components/file-upload/file-upload.types.ts +2 -0
- package/src/components/invocation-rule-builder/index.ts +1 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.css +22 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.examples.json +6 -0
- package/src/components/invocation-rule-builder/invocation-rule-builder.schema.json +70 -7
- package/src/components/invocation-rule-builder/invocation-rule-builder.schema.ts +5 -250
- package/src/components/invocation-rule-builder/invocation-rule-builder.svelte +136 -99
- package/src/components/invocation-rule-builder/invocation-rule-builder.types.ts +145 -62
- package/src/components/json-editor/index.ts +6 -0
- package/src/components/json-editor/json-editor-enhancement.ts +48 -0
- package/src/components/json-editor/json-editor.css +117 -0
- package/src/components/json-editor/json-editor.examples.json +13 -0
- package/src/components/json-editor/json-editor.schema.json +61 -0
- package/src/components/json-editor/json-editor.schema.ts +67 -0
- package/src/components/json-editor/json-editor.svelte +164 -0
- package/src/components/json-editor/json-editor.types.ts +31 -0
- package/src/components/json-schema-editor/diff-view.svelte +26 -8
- package/src/components/json-schema-editor/form-view.svelte +1 -1
- package/src/components/json-schema-editor/json-schema-editor-state.svelte.ts +163 -56
- package/src/components/json-schema-editor/json-schema-editor-types.ts +8 -1
- package/src/components/json-schema-editor/json-schema-editor.css +35 -0
- package/src/components/json-schema-editor/json-schema-validator.ts +59 -25
- package/src/components/json-schema-editor/json-view.svelte +52 -18
- package/src/components/payload-inspector/payload-inspector.schema.json +8 -0
- package/src/components/payload-inspector/payload-inspector.schema.ts +10 -0
- package/src/components/payload-inspector/payload-inspector.svelte +2 -2
- package/src/components/payload-inspector/payload-inspector.types.ts +20 -0
- package/src/components/run-step-timeline/run-step-timeline.css +46 -0
- package/src/components/run-step-timeline/run-step-timeline.examples.json +3 -3
- package/src/components/run-step-timeline/run-step-timeline.schema.json +24 -0
- package/src/components/run-step-timeline/run-step-timeline.schema.ts +26 -0
- package/src/components/run-step-timeline/run-step-timeline.svelte +41 -4
- package/src/components/run-step-timeline/run-step-timeline.types.ts +22 -1
- package/src/components/run-step-timeline/run-step-timeline.utilities.ts +9 -1
- package/src/components/schedule-builder/schedule-builder.schema.json +7 -0
- package/src/components/schedule-builder/schedule-builder.schema.ts +8 -0
- package/src/components/schedule-builder/schedule-builder.svelte +94 -22
- package/src/components/schedule-builder/schedule-builder.types.ts +12 -0
- package/src/components/schema-form/index.ts +1 -0
- package/src/components/schema-form/schema-form-body.svelte +94 -17
- package/src/components/schema-form/schema-form.examples.json +1 -1
- package/src/components/schema-form/schema-form.schema.json +5 -0
- package/src/components/schema-form/schema-form.schema.ts +6 -0
- package/src/components/schema-form/schema-form.svelte +4 -0
- package/src/components/schema-form/schema-form.types.ts +9 -0
- package/src/components/side-navigation/side-navigation.examples.json +1 -1
- package/src/components/sidebar/sidebar.css +7 -16
- package/src/components/sidebar/sidebar.examples.json +3 -3
- package/src/components/sidebar/sidebar.schema.json +7 -8
- package/src/components/sidebar/sidebar.schema.ts +8 -8
- package/src/components/sidebar/sidebar.svelte +65 -27
- package/src/components/sidebar/sidebar.types.ts +14 -12
- package/src/components/status-dot/status-dot.svelte +6 -1
- package/src/components/tabs/tabs.css +2 -0
- package/src/components/toast-region/toast-region.css +1 -1
- package/src/components/toast-region/toast-region.examples.json +1 -1
- package/src/components/toast-region/toast-region.svelte +2 -2
- package/src/highlighters/shiki/default.ts +46 -0
- package/src/highlighters/shiki/index.ts +232 -23
- package/src/index.ts +5 -7
- package/src/styles/components.css +1 -1
- package/src/utilities/change-tracker.svelte.ts +1 -1
- package/src/utilities/json-highlight.ts +5 -0
- package/dist/commentary/anchor-decorations.d.ts +0 -86
- package/dist/commentary/anchor-decorations.js +0 -490
- package/dist/commentary/anchoring.d.ts +0 -93
- package/dist/commentary/anchoring.js +0 -157
- package/dist/commentary/comments/index.d.ts +0 -12
- package/dist/commentary/comments/index.js +0 -14
- package/dist/commentary/comments/mentions.d.ts +0 -43
- package/dist/commentary/comments/mentions.js +0 -65
- package/dist/commentary/comments/reanchor.d.ts +0 -86
- package/dist/commentary/comments/reanchor.js +0 -220
- package/dist/commentary/comments/types.d.ts +0 -260
- package/dist/commentary/comments/types.js +0 -83
- package/dist/commentary/comments/updates.d.ts +0 -102
- package/dist/commentary/comments/updates.js +0 -226
- package/dist/commentary/export/comments-export.d.ts +0 -42
- package/dist/commentary/export/comments-export.js +0 -258
- package/dist/commentary/export/index.d.ts +0 -12
- package/dist/commentary/export/index.js +0 -12
- package/dist/commentary/export/markdown-summary.d.ts +0 -31
- package/dist/commentary/export/markdown-summary.js +0 -218
- package/dist/commentary/export/types.d.ts +0 -162
- package/dist/commentary/export/types.js +0 -7
- package/dist/commentary/export/unified-diff.d.ts +0 -28
- package/dist/commentary/export/unified-diff.js +0 -250
- package/dist/commentary/index.d.ts +0 -6
- package/dist/commentary/index.js +0 -6
- package/dist/commentary/session/index.d.ts +0 -12
- package/dist/commentary/session/index.js +0 -14
- package/dist/commentary/session/persistence.d.ts +0 -92
- package/dist/commentary/session/persistence.js +0 -253
- package/dist/commentary/session/types.d.ts +0 -208
- package/dist/commentary/session/types.js +0 -26
- package/dist/commentary/session/updates.d.ts +0 -155
- package/dist/commentary/session/updates.js +0 -362
- package/dist/commentary/shared/anchor-types.d.ts +0 -116
- package/dist/commentary/shared/anchor-types.js +0 -9
- package/dist/components/diff-viewer/diff-controller.svelte.d.ts +0 -75
- package/dist/components/diff-viewer/diff-front-matter.svelte.d.ts +0 -28
- package/dist/components/diff-viewer/diff-line.svelte.d.ts +0 -22
- package/dist/components/diff-viewer/diff-summary-bar.svelte.d.ts +0 -13
- package/dist/components/diff-viewer/diff-toolbar.svelte.d.ts +0 -36
- package/dist/components/diff-viewer/diff-viewer.svelte.d.ts +0 -22
- package/dist/components/diff-viewer/diff-viewer.types.d.ts +0 -53
- package/dist/components/diff-viewer/front-matter-header.svelte.d.ts +0 -26
- package/dist/components/diff-viewer/index.d.ts +0 -4
- package/dist/components/diff-viewer/index.js +0 -2848
- package/dist/components/markdown-editor/editor-skeleton.svelte.d.ts +0 -10
- package/dist/components/markdown-editor/editor-toolbar/editor-toolbar.svelte.d.ts +0 -37
- package/dist/components/markdown-editor/editor-toolbar/index.d.ts +0 -11
- package/dist/components/markdown-editor/editor-toolbar/link-popover.svelte.d.ts +0 -30
- package/dist/components/markdown-editor/editor-toolbar/toolbar-button.svelte.d.ts +0 -19
- package/dist/components/markdown-editor/editor-toolbar/toolbar-dropdown.svelte.d.ts +0 -24
- package/dist/components/markdown-editor/editor-toolbar/toolbar-separator.svelte.d.ts +0 -7
- package/dist/components/markdown-editor/editor-toolbar/types.d.ts +0 -13
- package/dist/components/markdown-editor/index.css +0 -61
- package/dist/components/markdown-editor/index.d.ts +0 -4
- package/dist/components/markdown-editor/index.js +0 -7494
- package/dist/components/markdown-editor/markdown-editor.schema.d.ts +0 -3
- package/dist/components/markdown-editor/markdown-editor.schema.js +0 -177
- package/dist/components/markdown-editor/markdown-editor.svelte.d.ts +0 -29
- package/dist/components/markdown-editor/markdown-editor.types.d.ts +0 -100
- package/dist/components/markdown-editor/markdown-editor.variables.d.ts +0 -2
- package/dist/components/markdown-editor/markdown-editor.variables.js +0 -61
- package/dist/components/review-editor/comment-composer.svelte.d.ts +0 -37
- package/dist/components/review-editor/comment-list.svelte.d.ts +0 -19
- package/dist/components/review-editor/comment-sidebar.svelte.d.ts +0 -22
- package/dist/components/review-editor/export-actions.svelte.d.ts +0 -18
- package/dist/components/review-editor/focus-navigation.d.ts +0 -105
- package/dist/components/review-editor/front-matter-fields.svelte.d.ts +0 -10
- package/dist/components/review-editor/index.d.ts +0 -20
- package/dist/components/review-editor/index.js +0 -14731
- package/dist/components/review-editor/live-region.svelte.d.ts +0 -23
- package/dist/components/review-editor/review-editor-anchors.svelte.d.ts +0 -96
- package/dist/components/review-editor/review-editor-controls.svelte.d.ts +0 -41
- package/dist/components/review-editor/review-editor-exports.d.ts +0 -80
- package/dist/components/review-editor/review-editor-front-matter.d.ts +0 -28
- package/dist/components/review-editor/review-editor-impl.svelte.d.ts +0 -31
- package/dist/components/review-editor/review-editor-selection-geometry.d.ts +0 -10
- package/dist/components/review-editor/review-editor-selection-types.d.ts +0 -62
- package/dist/components/review-editor/review-editor-selection.svelte.d.ts +0 -50
- package/dist/components/review-editor/review-editor-state.svelte.d.ts +0 -77
- package/dist/components/review-editor/review-editor-threads.svelte.d.ts +0 -137
- package/dist/components/review-editor/review-editor.css +0 -273
- package/dist/components/review-editor/review-editor.schema.d.ts +0 -3
- package/dist/components/review-editor/review-editor.schema.js +0 -143
- package/dist/components/review-editor/review-editor.svelte.d.ts +0 -19
- package/dist/components/review-editor/review-editor.types.d.ts +0 -77
- package/dist/components/review-editor/review-editor.variables.d.ts +0 -2
- package/dist/components/review-editor/review-editor.variables.js +0 -61
- package/dist/components/review-editor/thread-popover.svelte.d.ts +0 -32
- package/dist/diff/index.d.ts +0 -2
- package/dist/diff/index.js +0 -1
- package/dist/diff/line-diff.d.ts +0 -84
- package/dist/diff/line-diff.js +0 -372
- package/dist/diff/types.d.ts +0 -1
- package/dist/diff/types.js +0 -1
- package/dist/editor/attach.d.ts +0 -30
- package/dist/editor/attach.js +0 -86
- package/dist/editor/bridge.d.ts +0 -110
- package/dist/editor/bridge.js +0 -260
- package/dist/editor/clipboard.d.ts +0 -19
- package/dist/editor/clipboard.js +0 -189
- package/dist/editor/commands.d.ts +0 -167
- package/dist/editor/commands.js +0 -728
- package/dist/editor/component-runtime.d.ts +0 -21
- package/dist/editor/component-runtime.js +0 -20
- package/dist/editor/editor.d.ts +0 -23
- package/dist/editor/editor.js +0 -256
- package/dist/editor/index.d.ts +0 -30
- package/dist/editor/index.js +0 -42
- package/dist/editor/keymap-plugin.d.ts +0 -56
- package/dist/editor/keymap-plugin.js +0 -157
- package/dist/editor/link-input-rule.d.ts +0 -4
- package/dist/editor/link-input-rule.js +0 -26
- package/dist/editor/milkdown-plugin-runtime.d.ts +0 -20
- package/dist/editor/milkdown-plugin-runtime.js +0 -43
- package/dist/editor/placeholder-security.d.ts +0 -22
- package/dist/editor/placeholder-security.js +0 -36
- package/dist/editor/placeholder.d.ts +0 -14
- package/dist/editor/placeholder.js +0 -56
- package/dist/editor/sanitize-html.d.ts +0 -32
- package/dist/editor/sanitize-html.js +0 -111
- package/dist/editor/template-completion-plugin.d.ts +0 -159
- package/dist/editor/template-completion-plugin.js +0 -615
- package/dist/editor/template-invalid-decoration-plugin.d.ts +0 -73
- package/dist/editor/template-invalid-decoration-plugin.js +0 -155
- package/dist/editor/template-placeholders.d.ts +0 -96
- package/dist/editor/template-placeholders.js +0 -355
- package/dist/editor/template-position-utilities.d.ts +0 -34
- package/dist/editor/template-position-utilities.js +0 -63
- package/dist/editor/template-render.d.ts +0 -37
- package/dist/editor/template-render.js +0 -45
- package/dist/editor/test-utilities.d.ts +0 -49
- package/dist/editor/test-utilities.js +0 -93
- package/dist/editor/types.d.ts +0 -234
- package/dist/editor/types.js +0 -8
- package/dist/markdown/diff/compute.d.ts +0 -28
- package/dist/markdown/diff/compute.js +0 -250
- package/dist/markdown/diff/frontmatter.d.ts +0 -66
- package/dist/markdown/diff/frontmatter.js +0 -135
- package/dist/markdown/diff/index.d.ts +0 -27
- package/dist/markdown/diff/index.js +0 -28
- package/dist/markdown/diff/line-diff.d.ts +0 -2
- package/dist/markdown/diff/line-diff.js +0 -1
- package/dist/markdown/diff/positions.d.ts +0 -66
- package/dist/markdown/diff/positions.js +0 -147
- package/dist/markdown/diff/types.d.ts +0 -78
- package/dist/markdown/diff/types.js +0 -7
- package/dist/markdown/index.d.ts +0 -2
- package/dist/markdown/index.js +0 -8
- package/dist/markdown/pipeline/ast.d.ts +0 -302
- package/dist/markdown/pipeline/ast.js +0 -417
- package/dist/markdown/pipeline/errors.d.ts +0 -37
- package/dist/markdown/pipeline/errors.js +0 -49
- package/dist/markdown/pipeline/frontmatter.d.ts +0 -127
- package/dist/markdown/pipeline/frontmatter.js +0 -438
- package/dist/markdown/pipeline/index.d.ts +0 -37
- package/dist/markdown/pipeline/index.js +0 -40
- package/dist/markdown/pipeline/parser.d.ts +0 -65
- package/dist/markdown/pipeline/parser.js +0 -106
- package/dist/markdown/pipeline/serializer.d.ts +0 -67
- package/dist/markdown/pipeline/serializer.js +0 -78
- package/dist/markdown/pipeline/strip-positions.d.ts +0 -20
- package/dist/markdown/pipeline/strip-positions.js +0 -28
- package/dist/markdown/pipeline/types.d.ts +0 -116
- package/dist/markdown/pipeline/types.js +0 -8
- package/dist/markdown/rendering/extract-code-blocks.d.ts +0 -16
- package/dist/markdown/rendering/extract-code-blocks.js +0 -27
- package/dist/markdown/rendering/highlighter.d.ts +0 -109
- package/dist/markdown/rendering/highlighter.js +0 -251
- package/dist/markdown/rendering/index.d.ts +0 -41
- package/dist/markdown/rendering/index.js +0 -46
- package/dist/markdown/rendering/mermaid-cache.d.ts +0 -55
- package/dist/markdown/rendering/mermaid-cache.js +0 -123
- package/dist/markdown/rendering/rehype-shiki-sync.d.ts +0 -57
- package/dist/markdown/rendering/rehype-shiki-sync.js +0 -354
- package/dist/markdown/rendering/render-async.d.ts +0 -43
- package/dist/markdown/rendering/render-async.js +0 -114
- package/dist/markdown/rendering/render-streaming.d.ts +0 -33
- package/dist/markdown/rendering/render-streaming.js +0 -123
- package/dist/markdown/rendering/render-worker.d.ts +0 -19
- package/dist/markdown/rendering/render-worker.js +0 -35
- package/dist/markdown/rendering/render.d.ts +0 -123
- package/dist/markdown/rendering/render.js +0 -477
- package/dist/markdown/rendering/sanitize-schema.d.ts +0 -24
- package/dist/markdown/rendering/sanitize-schema.js +0 -105
- package/dist/markdown/rendering/transform-urls.d.ts +0 -37
- package/dist/markdown/rendering/transform-urls.js +0 -51
- package/dist/markdown/rendering/types.d.ts +0 -51
- package/dist/markdown/rendering/types.js +0 -8
- package/dist/markdown/rendering/worker-dom-shim.d.ts +0 -87
- package/dist/markdown/rendering/worker-dom-shim.js +0 -50
- package/dist/markdown/utilities/safe-url.d.ts +0 -100
- package/dist/markdown/utilities/safe-url.js +0 -236
- package/dist/markdown/utilities/sort-keys.d.ts +0 -19
- package/dist/markdown/utilities/sort-keys.js +0 -33
- package/dist/server/commentary/anchor-decorations.js +0 -490
- package/dist/server/commentary/anchoring.js +0 -157
- package/dist/server/commentary/comments/index.js +0 -14
- package/dist/server/commentary/comments/mentions.js +0 -65
- package/dist/server/commentary/comments/reanchor.js +0 -220
- package/dist/server/commentary/comments/types.js +0 -83
- package/dist/server/commentary/comments/updates.js +0 -226
- package/dist/server/commentary/export/comments-export.js +0 -258
- package/dist/server/commentary/export/index.js +0 -12
- package/dist/server/commentary/export/markdown-summary.js +0 -218
- package/dist/server/commentary/export/types.js +0 -7
- package/dist/server/commentary/export/unified-diff.js +0 -250
- package/dist/server/commentary/index.js +0 -6
- package/dist/server/commentary/session/index.js +0 -14
- package/dist/server/commentary/session/persistence.js +0 -253
- package/dist/server/commentary/session/types.js +0 -26
- package/dist/server/commentary/session/updates.js +0 -362
- package/dist/server/commentary/shared/anchor-types.js +0 -9
- package/dist/server/components/diff-viewer/index.js +0 -33
- package/dist/server/components/markdown-editor/index.js +0 -52
- package/dist/server/components/review-editor/index.js +0 -3493
- package/dist/server/diff/index.js +0 -1
- package/dist/server/diff/line-diff.js +0 -372
- package/dist/server/diff/types.js +0 -1
- package/dist/server/editor/attach.js +0 -86
- package/dist/server/editor/bridge.js +0 -260
- package/dist/server/editor/clipboard.js +0 -189
- package/dist/server/editor/commands.js +0 -728
- package/dist/server/editor/component-runtime.js +0 -20
- package/dist/server/editor/editor.js +0 -256
- package/dist/server/editor/index.js +0 -42
- package/dist/server/editor/keymap-plugin.js +0 -157
- package/dist/server/editor/link-input-rule.js +0 -26
- package/dist/server/editor/milkdown-plugin-runtime.js +0 -43
- package/dist/server/editor/placeholder-security.js +0 -36
- package/dist/server/editor/placeholder.js +0 -56
- package/dist/server/editor/sanitize-html.js +0 -111
- package/dist/server/editor/template-completion-plugin.js +0 -615
- package/dist/server/editor/template-invalid-decoration-plugin.js +0 -155
- package/dist/server/editor/template-placeholders.js +0 -355
- package/dist/server/editor/template-position-utilities.js +0 -63
- package/dist/server/editor/template-render.js +0 -45
- package/dist/server/editor/test-utilities.js +0 -93
- package/dist/server/editor/types.js +0 -8
- package/dist/server/index.server-25wmev4e.js +0 -2
- package/dist/server/index.server-2c56kqws.js +0 -187
- package/dist/server/index.server-45n4s30n.js +0 -35
- package/dist/server/index.server-4jkqgp17.js +0 -1026
- package/dist/server/index.server-8nm871y8.js +0 -176
- package/dist/server/index.server-d04aj37r.js +0 -62
- package/dist/server/index.server-dg19y3m7.js +0 -9
- package/dist/server/index.server-g3726bja.js +0 -9
- package/dist/server/index.server-gyzmkrnz.js +0 -2
- package/dist/server/index.server-jp19145t.js +0 -9
- package/dist/server/index.server-n4jxy52q.js +0 -2
- package/dist/server/index.server-sghkqw5x.js +0 -421
- package/dist/server/index.server-w6am2dxc.js +0 -12
- package/dist/server/index.server-x66zvjfc.js +0 -1163
- package/dist/server/index.server-zdhv33ph.js +0 -124
- package/dist/server/index.server-zke5zt13.js +0 -9
- package/dist/server/markdown/diff/compute.js +0 -250
- package/dist/server/markdown/diff/frontmatter.js +0 -135
- package/dist/server/markdown/diff/index.js +0 -28
- package/dist/server/markdown/diff/line-diff.js +0 -1
- package/dist/server/markdown/diff/positions.js +0 -147
- package/dist/server/markdown/diff/types.js +0 -7
- package/dist/server/markdown/index.js +0 -8
- package/dist/server/markdown/pipeline/ast.js +0 -417
- package/dist/server/markdown/pipeline/errors.js +0 -49
- package/dist/server/markdown/pipeline/frontmatter.js +0 -438
- package/dist/server/markdown/pipeline/index.js +0 -40
- package/dist/server/markdown/pipeline/parser.js +0 -106
- package/dist/server/markdown/pipeline/serializer.js +0 -78
- package/dist/server/markdown/pipeline/strip-positions.js +0 -28
- package/dist/server/markdown/pipeline/types.js +0 -8
- package/dist/server/markdown/rendering/extract-code-blocks.js +0 -27
- package/dist/server/markdown/rendering/highlighter.js +0 -251
- package/dist/server/markdown/rendering/index.js +0 -46
- package/dist/server/markdown/rendering/mermaid-cache.js +0 -123
- package/dist/server/markdown/rendering/rehype-shiki-sync.js +0 -354
- package/dist/server/markdown/rendering/render-async.js +0 -114
- package/dist/server/markdown/rendering/render-streaming.js +0 -123
- package/dist/server/markdown/rendering/render-worker.js +0 -35
- package/dist/server/markdown/rendering/render.js +0 -477
- package/dist/server/markdown/rendering/sanitize-schema.js +0 -105
- package/dist/server/markdown/rendering/transform-urls.js +0 -51
- package/dist/server/markdown/rendering/types.js +0 -8
- package/dist/server/markdown/rendering/worker-dom-shim.js +0 -50
- package/dist/server/markdown/utilities/safe-url.js +0 -236
- package/dist/server/markdown/utilities/sort-keys.js +0 -33
- package/src/components/diff-viewer/diff-controller.svelte.ts +0 -250
- package/src/components/diff-viewer/diff-front-matter.svelte +0 -52
- package/src/components/diff-viewer/diff-line.svelte +0 -340
- package/src/components/diff-viewer/diff-summary-bar.svelte +0 -106
- package/src/components/diff-viewer/diff-toolbar.svelte +0 -182
- package/src/components/diff-viewer/diff-viewer.examples.json +0 -25
- package/src/components/diff-viewer/diff-viewer.schema.json +0 -61
- package/src/components/diff-viewer/diff-viewer.schema.ts +0 -70
- package/src/components/diff-viewer/diff-viewer.svelte +0 -400
- package/src/components/diff-viewer/diff-viewer.types.ts +0 -56
- package/src/components/diff-viewer/front-matter-header.svelte +0 -137
- package/src/components/diff-viewer/index.ts +0 -5
- package/src/components/markdown-editor/editor-skeleton.svelte +0 -85
- package/src/components/markdown-editor/editor-toolbar/editor-toolbar.svelte +0 -318
- package/src/components/markdown-editor/editor-toolbar/index.ts +0 -18
- package/src/components/markdown-editor/editor-toolbar/link-popover.svelte +0 -314
- package/src/components/markdown-editor/editor-toolbar/toolbar-button.svelte +0 -97
- package/src/components/markdown-editor/editor-toolbar/toolbar-dropdown.svelte +0 -106
- package/src/components/markdown-editor/editor-toolbar/toolbar-separator.svelte +0 -30
- package/src/components/markdown-editor/editor-toolbar/types.ts +0 -15
- package/src/components/markdown-editor/index.ts +0 -10
- package/src/components/markdown-editor/markdown-editor.examples.json +0 -19
- package/src/components/markdown-editor/markdown-editor.schema.json +0 -111
- package/src/components/markdown-editor/markdown-editor.schema.ts +0 -122
- package/src/components/markdown-editor/markdown-editor.svelte +0 -872
- package/src/components/markdown-editor/markdown-editor.types.ts +0 -124
- package/src/components/markdown-editor/markdown-editor.variables.json +0 -1
- package/src/components/markdown-editor/markdown-editor.variables.ts +0 -3
- package/src/components/markdown-editor/prosemirror.css +0 -76
- package/src/components/review-editor/comment-composer.svelte +0 -271
- package/src/components/review-editor/comment-list.svelte +0 -311
- package/src/components/review-editor/comment-sidebar.svelte +0 -449
- package/src/components/review-editor/export-actions.svelte +0 -188
- package/src/components/review-editor/focus-navigation.ts +0 -220
- package/src/components/review-editor/front-matter-fields.svelte +0 -159
- package/src/components/review-editor/index.ts +0 -59
- package/src/components/review-editor/live-region.svelte +0 -109
- package/src/components/review-editor/review-editor-anchors.svelte.ts +0 -219
- package/src/components/review-editor/review-editor-controls.svelte +0 -201
- package/src/components/review-editor/review-editor-exports.ts +0 -145
- package/src/components/review-editor/review-editor-front-matter.ts +0 -237
- package/src/components/review-editor/review-editor-impl.svelte +0 -1509
- package/src/components/review-editor/review-editor-selection-geometry.ts +0 -31
- package/src/components/review-editor/review-editor-selection-types.ts +0 -68
- package/src/components/review-editor/review-editor-selection.svelte.ts +0 -292
- package/src/components/review-editor/review-editor-state.svelte.ts +0 -117
- package/src/components/review-editor/review-editor-threads.svelte.ts +0 -435
- package/src/components/review-editor/review-editor.css +0 -273
- package/src/components/review-editor/review-editor.examples.json +0 -19
- package/src/components/review-editor/review-editor.schema.json +0 -83
- package/src/components/review-editor/review-editor.schema.ts +0 -88
- package/src/components/review-editor/review-editor.svelte +0 -18
- package/src/components/review-editor/review-editor.types.ts +0 -92
- package/src/components/review-editor/review-editor.variables.json +0 -1
- package/src/components/review-editor/review-editor.variables.ts +0 -3
- package/src/components/review-editor/thread-popover.svelte +0 -261
- /package/dist/components/{review-editor/review-editor.css.d.ts → json-editor/json-editor.css.d.ts} +0 -0
- /package/dist/components/{diff-viewer/diff-viewer.schema.d.ts → json-editor/json-editor.schema.d.ts} +0 -0
- /package/dist/components/{diff-viewer/diff-viewer.variables.d.ts → json-editor/json-editor.variables.d.ts} +0 -0
- /package/src/components/{diff-viewer/diff-viewer.variables.json → json-editor/json-editor.variables.json} +0 -0
- /package/src/components/{diff-viewer/diff-viewer.variables.ts → json-editor/json-editor.variables.ts} +0 -0
|
@@ -32,6 +32,31 @@ function serialise(value) {
|
|
|
32
32
|
function isPlainRecord(value) {
|
|
33
33
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Synchronous-only slice of what `validateMetaSchema` would say: catches
|
|
37
|
+
* the shapes it can reject without touching Ajv (no schema at all,
|
|
38
|
+
* non-object/boolean). Returns null when the shape is plausible and the
|
|
39
|
+
* real answer has to wait for the async check.
|
|
40
|
+
*
|
|
41
|
+
* Used to seed `metaResult` before a validation cycle goes 'pending' —
|
|
42
|
+
* without this, a known-bad draft (unparseable JSON, a bare array) would
|
|
43
|
+
* keep reporting whatever `metaResult.valid` happened to be from the
|
|
44
|
+
* *previous* schema until the async check catches up, which is exactly
|
|
45
|
+
* the stale-state window `onvalidate` consumers shouldn't see.
|
|
46
|
+
*/
|
|
47
|
+
function cheapMetaShapeCheck(schema) {
|
|
48
|
+
if (schema === null)
|
|
49
|
+
return { valid: false, errors: [] };
|
|
50
|
+
if (typeof schema === 'boolean')
|
|
51
|
+
return { valid: true, errors: [] };
|
|
52
|
+
if (typeof schema !== 'object' || Array.isArray(schema)) {
|
|
53
|
+
return {
|
|
54
|
+
valid: false,
|
|
55
|
+
errors: [{ path: '', message: 'Schema must be an object or boolean', keyword: '' }],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
35
60
|
export function createEditorState(options) {
|
|
36
61
|
// ---- Original (baseline) ----
|
|
37
62
|
let originalRawText = $state('');
|
|
@@ -63,6 +88,12 @@ export function createEditorState(options) {
|
|
|
63
88
|
let validationStatus = $state('valid');
|
|
64
89
|
let metaDebounceHandle = null;
|
|
65
90
|
let compileDebounceHandle = null;
|
|
91
|
+
// validateMetaSchema/tryCompile dynamically import Ajv, so every
|
|
92
|
+
// validation pass is now async. clearTimers() cancels pending *timers*
|
|
93
|
+
// but not an already-in-flight validation promise, so bumping this epoch
|
|
94
|
+
// is what actually invalidates stale in-flight work: any async callback
|
|
95
|
+
// checks its captured epoch against the current one before writing state.
|
|
96
|
+
let validationEpoch = 0;
|
|
66
97
|
function clearTimers() {
|
|
67
98
|
if (metaDebounceHandle !== null)
|
|
68
99
|
clearTimeout(metaDebounceHandle);
|
|
@@ -70,6 +101,7 @@ export function createEditorState(options) {
|
|
|
70
101
|
clearTimeout(compileDebounceHandle);
|
|
71
102
|
metaDebounceHandle = null;
|
|
72
103
|
compileDebounceHandle = null;
|
|
104
|
+
validationEpoch += 1;
|
|
73
105
|
}
|
|
74
106
|
function emitValidation(result) {
|
|
75
107
|
options.onvalidate?.(result);
|
|
@@ -118,21 +150,70 @@ export function createEditorState(options) {
|
|
|
118
150
|
}
|
|
119
151
|
return committed;
|
|
120
152
|
}
|
|
121
|
-
|
|
153
|
+
/**
|
|
154
|
+
* Resolve meta-schema validity for the current draft and, if no newer
|
|
155
|
+
* validation cycle has started in the meantime (see `validationEpoch`),
|
|
156
|
+
* write the result. Callers that need the raw result synchronously (e.g.
|
|
157
|
+
* `applyJsonDraft`, which gates a commit on it) should call
|
|
158
|
+
* `validateMetaSchema` directly instead.
|
|
159
|
+
*/
|
|
160
|
+
async function runMetaValidation(epoch) {
|
|
122
161
|
const schema = schemaToValidate();
|
|
123
162
|
if (schema === null) {
|
|
163
|
+
if (epoch !== validationEpoch)
|
|
164
|
+
return;
|
|
124
165
|
metaResult = { valid: false, errors: [] };
|
|
125
166
|
return;
|
|
126
167
|
}
|
|
127
|
-
|
|
168
|
+
const result = await validateMetaSchema(schema, detectActiveDraft(schema));
|
|
169
|
+
if (epoch !== validationEpoch)
|
|
170
|
+
return;
|
|
171
|
+
metaResult = result;
|
|
128
172
|
}
|
|
129
|
-
function runCompile() {
|
|
173
|
+
async function runCompile(epoch) {
|
|
130
174
|
const schema = schemaToValidate();
|
|
131
175
|
if (schema === null) {
|
|
176
|
+
if (epoch !== validationEpoch)
|
|
177
|
+
return;
|
|
132
178
|
compileResult = null;
|
|
133
179
|
return;
|
|
134
180
|
}
|
|
135
|
-
|
|
181
|
+
const result = await tryCompile(schema, detectActiveDraft(schema));
|
|
182
|
+
if (epoch !== validationEpoch)
|
|
183
|
+
return;
|
|
184
|
+
compileResult = result;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Refresh both meta-schema and compile status for the schema currently
|
|
188
|
+
* committed/drafted, then recompute the overall status and emit. Used by
|
|
189
|
+
* every mutating action (commit, undo, redo, revert, …) that doesn't need
|
|
190
|
+
* to gate its own outcome on the result — those actions apply immediately
|
|
191
|
+
* and this just brings the reported validation status up to date.
|
|
192
|
+
*/
|
|
193
|
+
async function refreshValidation(epoch) {
|
|
194
|
+
await Promise.all([runMetaValidation(epoch), runCompile(epoch)]);
|
|
195
|
+
if (epoch !== validationEpoch)
|
|
196
|
+
return;
|
|
197
|
+
recomputeStatus();
|
|
198
|
+
emitValidation(buildResult());
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Cancel in-flight validation, start a new epoch, and announce 'pending'.
|
|
202
|
+
* Clears `compileResult` (its `null` state is already what marks
|
|
203
|
+
* `recomputeStatus`/`buildResult` as pending) and seeds `metaResult` with
|
|
204
|
+
* whatever a cheap synchronous check can determine, so the pending emit
|
|
205
|
+
* never reports validity left over from a different schema.
|
|
206
|
+
*/
|
|
207
|
+
function beginValidationCycle() {
|
|
208
|
+
clearTimers();
|
|
209
|
+
const epoch = validationEpoch;
|
|
210
|
+
const cheapMeta = cheapMetaShapeCheck(schemaToValidate());
|
|
211
|
+
if (cheapMeta)
|
|
212
|
+
metaResult = cheapMeta;
|
|
213
|
+
compileResult = null;
|
|
214
|
+
validationStatus = 'pending';
|
|
215
|
+
emitValidation(buildResult({ status: 'pending' }));
|
|
216
|
+
return epoch;
|
|
136
217
|
}
|
|
137
218
|
function recomputeStatus() {
|
|
138
219
|
const parse = tryParseJson(jsonDraftText);
|
|
@@ -155,14 +236,15 @@ export function createEditorState(options) {
|
|
|
155
236
|
validationStatus = 'valid';
|
|
156
237
|
}
|
|
157
238
|
function scheduleValidation() {
|
|
158
|
-
|
|
159
|
-
// Pending until debounce window resolves
|
|
160
|
-
validationStatus = 'pending';
|
|
161
|
-
emitValidation(buildResult({ status: 'pending' }));
|
|
239
|
+
const epoch = beginValidationCycle();
|
|
162
240
|
metaDebounceHandle = setTimeout(() => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
241
|
+
void (async () => {
|
|
242
|
+
await runMetaValidation(epoch);
|
|
243
|
+
if (epoch !== validationEpoch)
|
|
244
|
+
return;
|
|
245
|
+
recomputeStatus();
|
|
246
|
+
emitValidation(buildResult());
|
|
247
|
+
})();
|
|
166
248
|
}, META_DEBOUNCE_MS);
|
|
167
249
|
// Skip compile for very large drafts — Ajv.compile is O(schema-size)
|
|
168
250
|
// synchronous main-thread work and at 100KB+ it stalls typing badly.
|
|
@@ -174,9 +256,13 @@ export function createEditorState(options) {
|
|
|
174
256
|
return;
|
|
175
257
|
}
|
|
176
258
|
compileDebounceHandle = setTimeout(() => {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
259
|
+
void (async () => {
|
|
260
|
+
await runCompile(epoch);
|
|
261
|
+
if (epoch !== validationEpoch)
|
|
262
|
+
return;
|
|
263
|
+
recomputeStatus();
|
|
264
|
+
emitValidation(buildResult());
|
|
265
|
+
})();
|
|
180
266
|
}, COMPILE_DEBOUNCE_MS);
|
|
181
267
|
}
|
|
182
268
|
function emitChange() {
|
|
@@ -214,10 +300,8 @@ export function createEditorState(options) {
|
|
|
214
300
|
history = null;
|
|
215
301
|
jsonDraftText = schemaResult.rawText || '';
|
|
216
302
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
recomputeStatus();
|
|
220
|
-
emitValidation(buildResult());
|
|
303
|
+
const epoch = beginValidationCycle();
|
|
304
|
+
void refreshValidation(epoch);
|
|
221
305
|
}
|
|
222
306
|
loadFrom(options.schema, options.original);
|
|
223
307
|
// ===== Derived =====
|
|
@@ -296,6 +380,13 @@ export function createEditorState(options) {
|
|
|
296
380
|
get validationStatus() {
|
|
297
381
|
return validationStatus;
|
|
298
382
|
},
|
|
383
|
+
/**
|
|
384
|
+
* `result.valid` is optimistic while `result.status === 'pending'` —
|
|
385
|
+
* on a cold mount, or any time a validation cycle has just started, the
|
|
386
|
+
* async Ajv check hasn't resolved yet and `valid` still reflects
|
|
387
|
+
* whatever the last settled check found (`true` by default). Gate on
|
|
388
|
+
* `status`, not `valid` alone.
|
|
389
|
+
*/
|
|
299
390
|
get validationResult() {
|
|
300
391
|
return buildResult();
|
|
301
392
|
},
|
|
@@ -312,17 +403,24 @@ export function createEditorState(options) {
|
|
|
312
403
|
scheduleValidation();
|
|
313
404
|
},
|
|
314
405
|
discardJsonDraft() {
|
|
315
|
-
clearTimers();
|
|
316
406
|
jsonDraftText = committedCanonicalText;
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
407
|
+
const epoch = beginValidationCycle();
|
|
408
|
+
void refreshValidation(epoch);
|
|
409
|
+
},
|
|
410
|
+
/**
|
|
411
|
+
* Apply the JSON draft as the committed schema. Async because the
|
|
412
|
+
* meta-schema check that gates the commit dynamically imports Ajv on
|
|
413
|
+
* first use — the commit itself only happens once that check resolves,
|
|
414
|
+
* so this can no longer report its outcome synchronously. Callers that
|
|
415
|
+
* only need to trigger the apply (the toolbar's Apply button) can call
|
|
416
|
+
* it without awaiting; callers that need the resulting boolean must
|
|
417
|
+
* await it.
|
|
418
|
+
*/
|
|
419
|
+
async applyJsonDraft() {
|
|
323
420
|
if (readonly)
|
|
324
421
|
return false;
|
|
325
422
|
clearTimers();
|
|
423
|
+
const epoch = validationEpoch;
|
|
326
424
|
const parsed = tryParseJson(jsonDraftText);
|
|
327
425
|
if (!parsed.ok)
|
|
328
426
|
return false;
|
|
@@ -330,9 +428,29 @@ export function createEditorState(options) {
|
|
|
330
428
|
if (typeof value !== 'boolean' && !isPlainRecord(value))
|
|
331
429
|
return false;
|
|
332
430
|
const schema = value;
|
|
333
|
-
const
|
|
334
|
-
|
|
431
|
+
const draft = detectActiveDraft(schema);
|
|
432
|
+
// Clear the previous compile result before announcing 'pending' — its
|
|
433
|
+
// `null` state is what recomputeStatus/buildResult treat as pending,
|
|
434
|
+
// so leaving a stale one behind would let a status recompute reuse
|
|
435
|
+
// compile info from whatever schema was committed before this draft.
|
|
436
|
+
compileResult = null;
|
|
437
|
+
validationStatus = 'pending';
|
|
438
|
+
emitValidation(buildResult({ status: 'pending' }));
|
|
439
|
+
const meta = await validateMetaSchema(schema, draft);
|
|
440
|
+
// A newer action (another apply, an undo, a reload, …) superseded
|
|
441
|
+
// this one while Ajv was loading — abandon rather than commit stale
|
|
442
|
+
// state or clobber whatever that newer action already wrote. Also
|
|
443
|
+
// recheck readonly directly: a parent can flip it while this await is
|
|
444
|
+
// in flight, and unlike other mutations that starts a new epoch,
|
|
445
|
+
// setReadonly doesn't — so it has to be checked explicitly here.
|
|
446
|
+
if (epoch !== validationEpoch || readonly)
|
|
335
447
|
return false;
|
|
448
|
+
if (!meta.valid) {
|
|
449
|
+
metaResult = meta;
|
|
450
|
+
recomputeStatus();
|
|
451
|
+
emitValidation(buildResult());
|
|
452
|
+
return false;
|
|
453
|
+
}
|
|
336
454
|
if (history) {
|
|
337
455
|
history.commit(schema, { label: 'apply JSON' });
|
|
338
456
|
}
|
|
@@ -343,59 +461,52 @@ export function createEditorState(options) {
|
|
|
343
461
|
history = useHistory(applyOptions);
|
|
344
462
|
}
|
|
345
463
|
jsonDraftText = serialise(history.current);
|
|
346
|
-
|
|
347
|
-
runCompile();
|
|
348
|
-
recomputeStatus();
|
|
464
|
+
metaResult = meta;
|
|
349
465
|
emitChange();
|
|
350
|
-
|
|
466
|
+
const compile = await tryCompile(schema, draft);
|
|
467
|
+
if (epoch === validationEpoch) {
|
|
468
|
+
compileResult = compile;
|
|
469
|
+
recomputeStatus();
|
|
470
|
+
emitValidation(buildResult());
|
|
471
|
+
}
|
|
351
472
|
return true;
|
|
352
473
|
},
|
|
353
474
|
commitFromForm(next, commitOptions) {
|
|
354
475
|
if (!history || readonly || jsonDraftIsDirty)
|
|
355
476
|
return;
|
|
356
|
-
clearTimers();
|
|
357
477
|
history.commit(next, commitOptions);
|
|
358
478
|
jsonDraftText = serialise(history.current);
|
|
359
|
-
runMetaValidation();
|
|
360
|
-
runCompile();
|
|
361
|
-
recomputeStatus();
|
|
362
479
|
emitChange();
|
|
363
|
-
|
|
480
|
+
const epoch = beginValidationCycle();
|
|
481
|
+
void refreshValidation(epoch);
|
|
364
482
|
},
|
|
365
483
|
undo() {
|
|
366
484
|
if (!history || readonly)
|
|
367
485
|
return undefined;
|
|
368
|
-
clearTimers();
|
|
369
486
|
const left = history.undo();
|
|
370
487
|
if (!left)
|
|
371
488
|
return undefined;
|
|
372
489
|
jsonDraftText = serialise(history.current);
|
|
373
|
-
runMetaValidation();
|
|
374
|
-
runCompile();
|
|
375
|
-
recomputeStatus();
|
|
376
490
|
emitChange();
|
|
377
|
-
|
|
491
|
+
const epoch = beginValidationCycle();
|
|
492
|
+
void refreshValidation(epoch);
|
|
378
493
|
return left.label;
|
|
379
494
|
},
|
|
380
495
|
redo() {
|
|
381
496
|
if (!history || readonly)
|
|
382
497
|
return undefined;
|
|
383
|
-
clearTimers();
|
|
384
498
|
const moved = history.redo();
|
|
385
499
|
if (!moved)
|
|
386
500
|
return undefined;
|
|
387
501
|
jsonDraftText = serialise(history.current);
|
|
388
|
-
runMetaValidation();
|
|
389
|
-
runCompile();
|
|
390
|
-
recomputeStatus();
|
|
391
502
|
emitChange();
|
|
392
|
-
|
|
503
|
+
const epoch = beginValidationCycle();
|
|
504
|
+
void refreshValidation(epoch);
|
|
393
505
|
return moved.label;
|
|
394
506
|
},
|
|
395
507
|
revert() {
|
|
396
508
|
if (readonly)
|
|
397
509
|
return;
|
|
398
|
-
clearTimers();
|
|
399
510
|
if (originalSchema !== null) {
|
|
400
511
|
const revertOptions = {
|
|
401
512
|
initial: originalSchema,
|
|
@@ -404,16 +515,15 @@ export function createEditorState(options) {
|
|
|
404
515
|
revertOptions.maxDepth = options.maxHistory;
|
|
405
516
|
history = useHistory(revertOptions);
|
|
406
517
|
jsonDraftText = originalCanonicalText;
|
|
407
|
-
runMetaValidation();
|
|
408
|
-
runCompile();
|
|
409
|
-
recomputeStatus();
|
|
410
518
|
emitChange();
|
|
411
|
-
|
|
519
|
+
const epoch = beginValidationCycle();
|
|
520
|
+
void refreshValidation(epoch);
|
|
412
521
|
options.onrevert?.({ restoredFrom: 'original-schema' });
|
|
413
522
|
}
|
|
414
523
|
else {
|
|
415
524
|
history = null;
|
|
416
525
|
jsonDraftText = originalRawText;
|
|
526
|
+
clearTimers();
|
|
417
527
|
metaResult = { valid: false, errors: [] };
|
|
418
528
|
compileResult = null;
|
|
419
529
|
recomputeStatus();
|
|
@@ -424,16 +534,13 @@ export function createEditorState(options) {
|
|
|
424
534
|
/** Update the active draft override; recomputes validation. */
|
|
425
535
|
setDraftOverride(next) {
|
|
426
536
|
draftOverride = next;
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
recomputeStatus();
|
|
430
|
-
emitValidation(buildResult());
|
|
537
|
+
const epoch = beginValidationCycle();
|
|
538
|
+
void refreshValidation(epoch);
|
|
431
539
|
},
|
|
432
540
|
/** Live-update the readonly flag (used to re-sync the prop after mount). */
|
|
433
541
|
setReadonly,
|
|
434
542
|
/** Reload from a new schema/original pair — used by schemaKey-triggered reset. */
|
|
435
543
|
reload(schemaInput, originalInput) {
|
|
436
|
-
clearTimers();
|
|
437
544
|
loadFrom(schemaInput, originalInput);
|
|
438
545
|
},
|
|
439
546
|
destroy() {
|
|
@@ -92,7 +92,14 @@ export type JsonSchemaValidationStatus = 'valid' | 'invalid' | 'pending';
|
|
|
92
92
|
|
|
93
93
|
export type JsonSchemaValidationResult = {
|
|
94
94
|
status: JsonSchemaValidationStatus;
|
|
95
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Meta-schema valid. Only a settled answer once a cheap synchronous shape
|
|
97
|
+
* check has ruled out `status === 'invalid'` cases (no schema, non-object)
|
|
98
|
+
* — for a plausibly-valid shape, `valid` stays optimistic (reflects
|
|
99
|
+
* whatever the previous check found, or `true` on a cold mount before the
|
|
100
|
+
* first Ajv chunk has resolved) until `status` moves off `'pending'`.
|
|
101
|
+
* Gate on `status`, not `valid` alone.
|
|
102
|
+
*/
|
|
96
103
|
valid: boolean;
|
|
97
104
|
errors: JsonSchemaValidationError[];
|
|
98
105
|
/** `null` when compile is deferred or not yet run. */
|
|
@@ -364,6 +364,41 @@
|
|
|
364
364
|
gap: var(--cinder-space-3);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
+
.cinder-jse-diff-lines {
|
|
368
|
+
margin: 0;
|
|
369
|
+
padding: var(--cinder-space-3);
|
|
370
|
+
overflow-x: auto;
|
|
371
|
+
border: 1px solid var(--cinder-border);
|
|
372
|
+
border-radius: var(--cinder-radius-md);
|
|
373
|
+
background: var(--cinder-surface-inset);
|
|
374
|
+
font-family: var(--cinder-font-mono);
|
|
375
|
+
font-size: var(--cinder-text-xs);
|
|
376
|
+
line-height: var(--cinder-leading-normal);
|
|
377
|
+
white-space: pre-wrap;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.cinder-jse-diff-line {
|
|
381
|
+
display: block;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.cinder-jse-diff-line__marker {
|
|
385
|
+
display: inline-block;
|
|
386
|
+
inline-size: 1.25em;
|
|
387
|
+
color: var(--cinder-text-muted);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
.cinder-jse-diff-line--added {
|
|
391
|
+
background: var(--cinder-color-success-bg);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.cinder-jse-diff-line--removed {
|
|
395
|
+
background: var(--cinder-color-danger-bg);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.cinder-jse-diff-line--modified {
|
|
399
|
+
background: var(--cinder-color-warning-bg);
|
|
400
|
+
}
|
|
401
|
+
|
|
367
402
|
/* ===== Form view ===== */
|
|
368
403
|
.cinder-jse-form-view {
|
|
369
404
|
display: flex;
|
|
@@ -11,12 +11,18 @@
|
|
|
11
11
|
*
|
|
12
12
|
* tryCompile uses a fresh Ajv instance per call so iterating on a schema
|
|
13
13
|
* with a stable $id never trips the "schema already exists" cache error.
|
|
14
|
+
*
|
|
15
|
+
* Ajv (~120KB across the three draft builds) is dynamically imported on
|
|
16
|
+
* first use rather than declared as a static dependency — mirrors the
|
|
17
|
+
* pattern in schema-form/schema-form-validation.ts. Both exported
|
|
18
|
+
* validation functions are therefore async.
|
|
14
19
|
*/
|
|
15
20
|
|
|
16
|
-
import Ajv from 'ajv';
|
|
17
|
-
import Ajv2019 from 'ajv/dist/2019.js';
|
|
18
|
-
import Ajv2020 from 'ajv/dist/2020.js';
|
|
21
|
+
import type Ajv from 'ajv';
|
|
22
|
+
import type Ajv2019 from 'ajv/dist/2019.js';
|
|
23
|
+
import type Ajv2020 from 'ajv/dist/2020.js';
|
|
19
24
|
|
|
25
|
+
import { createRetryingLoaderCache } from '../../utilities/retrying-loader-cache.ts';
|
|
20
26
|
import type {
|
|
21
27
|
JsonSchemaDraft,
|
|
22
28
|
JsonSchemaKnownDraft,
|
|
@@ -68,22 +74,41 @@ function resolveDraft(draft: JsonSchemaDraft | undefined): JsonSchemaKnownDraft
|
|
|
68
74
|
return draft;
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
// Reuse the shared retrying cache so concurrent imports coalesce and a
|
|
78
|
+
// transient rejected import is evicted for the next validation attempt.
|
|
79
|
+
const loadAjv = createRetryingLoaderCache(() => import('ajv').then((module) => module.default));
|
|
80
|
+
const loadAjv2019 = createRetryingLoaderCache(() =>
|
|
81
|
+
import('ajv/dist/2019.js').then((module) => module.default),
|
|
82
|
+
);
|
|
83
|
+
const loadAjv2020 = createRetryingLoaderCache(() =>
|
|
84
|
+
import('ajv/dist/2020.js').then((module) => module.default),
|
|
85
|
+
);
|
|
86
|
+
|
|
71
87
|
// Long-lived meta-schema validators. Safe to share — they don't compile the
|
|
72
88
|
// user's schema, only validate against the meta-schema.
|
|
73
89
|
let metaAjv2020: Ajv2020 | null = null;
|
|
74
90
|
let metaAjv2019: Ajv2019 | null = null;
|
|
75
91
|
let metaAjv07: Ajv | null = null;
|
|
76
92
|
|
|
77
|
-
function getMetaValidator(draft: JsonSchemaKnownDraft): Ajv | Ajv2020 | Ajv2019 {
|
|
93
|
+
async function getMetaValidator(draft: JsonSchemaKnownDraft): Promise<Ajv | Ajv2020 | Ajv2019> {
|
|
78
94
|
if (draft === '2020-12') {
|
|
79
|
-
if (!metaAjv2020)
|
|
95
|
+
if (!metaAjv2020) {
|
|
96
|
+
const Ajv2020Class = await loadAjv2020();
|
|
97
|
+
metaAjv2020 = new Ajv2020Class({ strict: false, allErrors: true });
|
|
98
|
+
}
|
|
80
99
|
return metaAjv2020;
|
|
81
100
|
}
|
|
82
101
|
if (draft === '2019-09') {
|
|
83
|
-
if (!metaAjv2019)
|
|
102
|
+
if (!metaAjv2019) {
|
|
103
|
+
const Ajv2019Class = await loadAjv2019();
|
|
104
|
+
metaAjv2019 = new Ajv2019Class({ strict: false, allErrors: true });
|
|
105
|
+
}
|
|
84
106
|
return metaAjv2019;
|
|
85
107
|
}
|
|
86
|
-
if (!metaAjv07)
|
|
108
|
+
if (!metaAjv07) {
|
|
109
|
+
const AjvClass = await loadAjv();
|
|
110
|
+
metaAjv07 = new AjvClass({ strict: false, allErrors: true });
|
|
111
|
+
}
|
|
87
112
|
return metaAjv07;
|
|
88
113
|
}
|
|
89
114
|
|
|
@@ -102,10 +127,10 @@ function ajvErrorsToValidationErrors(
|
|
|
102
127
|
* Validate a schema document against the meta-schema for the chosen draft.
|
|
103
128
|
* Boolean schemas (true / false) are always valid full-document schemas.
|
|
104
129
|
*/
|
|
105
|
-
export function validateMetaSchema(
|
|
130
|
+
export async function validateMetaSchema(
|
|
106
131
|
schema: unknown,
|
|
107
132
|
draft?: JsonSchemaDraft,
|
|
108
|
-
): { valid: boolean; errors: JsonSchemaValidationError[] } {
|
|
133
|
+
): Promise<{ valid: boolean; errors: JsonSchemaValidationError[] }> {
|
|
109
134
|
if (typeof schema === 'boolean') return { valid: true, errors: [] };
|
|
110
135
|
if (!isObject(schema)) {
|
|
111
136
|
return {
|
|
@@ -115,18 +140,20 @@ export function validateMetaSchema(
|
|
|
115
140
|
}
|
|
116
141
|
|
|
117
142
|
const resolved = resolveDraft(draft ?? detectDraft(schema));
|
|
118
|
-
const ajv = getMetaValidator(resolved);
|
|
119
143
|
try {
|
|
144
|
+
// getMetaValidator's dynamic import can reject (e.g. the module fails
|
|
145
|
+
// to load); ajv.validateSchema can throw synchronously (a schema
|
|
146
|
+
// referencing a meta-schema URI the instance doesn't know about, e.g.
|
|
147
|
+
// cross-draft $schema references). Both are schema-validation failures
|
|
148
|
+
// from the caller's perspective, not unhandled exceptions — the editor
|
|
149
|
+
// should surface either as a validation error, not crash the host.
|
|
150
|
+
const ajv = await getMetaValidator(resolved);
|
|
120
151
|
const valid = ajv.validateSchema(schema);
|
|
121
152
|
return {
|
|
122
153
|
valid: Boolean(valid),
|
|
123
154
|
errors: ajvErrorsToValidationErrors(ajv.errors),
|
|
124
155
|
};
|
|
125
156
|
} catch (error) {
|
|
126
|
-
// Ajv throws synchronously when a schema references a meta-schema URI the
|
|
127
|
-
// instance doesn't know about (e.g. cross-draft $schema references). Treat
|
|
128
|
-
// as an invalid schema rather than an unhandled exception — the editor
|
|
129
|
-
// should surface this as a validation error, not crash the host.
|
|
130
157
|
return {
|
|
131
158
|
valid: false,
|
|
132
159
|
errors: [
|
|
@@ -147,26 +174,33 @@ export function validateMetaSchema(
|
|
|
147
174
|
* Each call uses a fresh Ajv instance so repeated compilation of a schema
|
|
148
175
|
* with a stable $id does not collide with Ajv's internal cache.
|
|
149
176
|
*/
|
|
150
|
-
export function tryCompile(
|
|
177
|
+
export async function tryCompile(
|
|
151
178
|
schema: unknown,
|
|
152
179
|
draft?: JsonSchemaDraft,
|
|
153
|
-
): { ok: true } | { ok: false; error: string } {
|
|
180
|
+
): Promise<{ ok: true } | { ok: false; error: string }> {
|
|
154
181
|
if (typeof schema === 'boolean') return { ok: true };
|
|
155
182
|
if (!isObject(schema)) {
|
|
156
183
|
return { ok: false, error: 'Schema must be an object or boolean' };
|
|
157
184
|
}
|
|
158
185
|
|
|
159
186
|
const resolved = resolveDraft(draft ?? detectDraft(schema));
|
|
160
|
-
let ajv: Ajv | Ajv2020 | Ajv2019;
|
|
161
|
-
if (resolved === '2020-12') {
|
|
162
|
-
ajv = new Ajv2020({ strict: false, addUsedSchema: false });
|
|
163
|
-
} else if (resolved === '2019-09') {
|
|
164
|
-
ajv = new Ajv2019({ strict: false, addUsedSchema: false });
|
|
165
|
-
} else {
|
|
166
|
-
ajv = new Ajv({ strict: false, addUsedSchema: false });
|
|
167
|
-
}
|
|
168
|
-
|
|
169
187
|
try {
|
|
188
|
+
// The dynamic Ajv-class import can reject as readily as ajv.compile can
|
|
189
|
+
// throw — both are covered by this one try/catch so tryCompile always
|
|
190
|
+
// resolves to { ok } rather than letting an import failure surface as
|
|
191
|
+
// an unhandled rejection.
|
|
192
|
+
let ajv: Ajv | Ajv2020 | Ajv2019;
|
|
193
|
+
if (resolved === '2020-12') {
|
|
194
|
+
const Ajv2020Class = await loadAjv2020();
|
|
195
|
+
ajv = new Ajv2020Class({ strict: false, addUsedSchema: false });
|
|
196
|
+
} else if (resolved === '2019-09') {
|
|
197
|
+
const Ajv2019Class = await loadAjv2019();
|
|
198
|
+
ajv = new Ajv2019Class({ strict: false, addUsedSchema: false });
|
|
199
|
+
} else {
|
|
200
|
+
const AjvClass = await loadAjv();
|
|
201
|
+
ajv = new AjvClass({ strict: false, addUsedSchema: false });
|
|
202
|
+
}
|
|
203
|
+
|
|
170
204
|
ajv.compile(schema);
|
|
171
205
|
return { ok: true };
|
|
172
206
|
} catch (error) {
|
|
@@ -9,16 +9,41 @@ import Badge from '../badge/badge.svelte';
|
|
|
9
9
|
import Button from '../button/button.svelte';
|
|
10
10
|
import Textarea from '../textarea/textarea.svelte';
|
|
11
11
|
import { tryParseJson, validateMetaSchema } from './json-schema-validator.ts';
|
|
12
|
-
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
// Aliased to `editorState`, not `state` — a local variable literally named
|
|
13
|
+
// `state` shadows the `$state` rune identifier, so `$state(...)` below
|
|
14
|
+
// would compile as a legacy store auto-subscription to that variable
|
|
15
|
+
// instead of the rune call. json-schema-toolbar.svelte uses the same
|
|
16
|
+
// alias for the same reason.
|
|
17
|
+
let { state: editorState, idPrefix, class: className } = $props();
|
|
18
|
+
// Parse is synchronous; the meta-schema check is not (validateMetaSchema
|
|
19
|
+
// dynamically imports Ajv), so it's tracked as state updated from an
|
|
20
|
+
// effect rather than a $derived. The state container only debounces
|
|
21
|
+
// validation against the *committed* schema; this runs an immediate check
|
|
22
|
+
// on the *draft* so the user gets feedback on the current text without
|
|
23
|
+
// waiting for the debounce window.
|
|
24
|
+
const draftParse = $derived(tryParseJson(editorState.jsonDraftText));
|
|
25
|
+
let draftMeta = $state(null);
|
|
26
|
+
$effect(() => {
|
|
27
|
+
const parse = draftParse;
|
|
28
|
+
const activeDraft = editorState.activeDraft;
|
|
29
|
+
if (!parse.ok) {
|
|
30
|
+
draftMeta = null;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
// Reset before validating the new draft — otherwise a previously-valid
|
|
34
|
+
// result lingers until this resolves, which can briefly enable Apply
|
|
35
|
+
// and hide errors for content that hasn't actually been checked yet.
|
|
36
|
+
draftMeta = null;
|
|
37
|
+
// Guard against out-of-order resolution: if the draft changes again
|
|
38
|
+
// before this validation call resolves, ignore the stale result.
|
|
39
|
+
let cancelled = false;
|
|
40
|
+
void validateMetaSchema(parse.value, activeDraft).then((result) => {
|
|
41
|
+
if (!cancelled)
|
|
42
|
+
draftMeta = result;
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
cancelled = true;
|
|
46
|
+
};
|
|
22
47
|
});
|
|
23
48
|
const draftErrorMessage = $derived.by(() => {
|
|
24
49
|
if (!draftParse.ok)
|
|
@@ -28,23 +53,31 @@ const draftErrorMessage = $derived.by(() => {
|
|
|
28
53
|
}
|
|
29
54
|
return null;
|
|
30
55
|
});
|
|
31
|
-
const canApply = $derived(!
|
|
32
|
-
|
|
56
|
+
const canApply = $derived(!editorState.readonly &&
|
|
57
|
+
editorState.jsonDraftIsDirty &&
|
|
58
|
+
draftParse.ok &&
|
|
59
|
+
draftMeta?.valid === true);
|
|
60
|
+
const canDiscard = $derived(editorState.jsonDraftIsDirty && !editorState.readonly);
|
|
33
61
|
</script>
|
|
34
62
|
|
|
35
63
|
<div class={classNames('cinder-jse-json-view', className)}>
|
|
36
64
|
<div class="cinder-jse-json-view__toolbar">
|
|
37
|
-
{#if
|
|
65
|
+
{#if editorState.jsonDraftIsDirty}
|
|
38
66
|
<Badge variant="warning">Draft modified — Apply to commit</Badge>
|
|
39
67
|
{/if}
|
|
40
|
-
<Button
|
|
68
|
+
<Button
|
|
69
|
+
variant="primary"
|
|
70
|
+
size="sm"
|
|
71
|
+
disabled={!canApply}
|
|
72
|
+
onclick={() => void editorState.applyJsonDraft()}
|
|
73
|
+
>
|
|
41
74
|
Apply
|
|
42
75
|
</Button>
|
|
43
76
|
<Button
|
|
44
77
|
variant="secondary"
|
|
45
78
|
size="sm"
|
|
46
79
|
disabled={!canDiscard}
|
|
47
|
-
onclick={() =>
|
|
80
|
+
onclick={() => editorState.discardJsonDraft()}
|
|
48
81
|
>
|
|
49
82
|
Discard
|
|
50
83
|
</Button>
|
|
@@ -53,11 +86,12 @@ const canDiscard = $derived(state.jsonDraftIsDirty && !state.readonly);
|
|
|
53
86
|
<Textarea
|
|
54
87
|
id={`${idPrefix}-textarea`}
|
|
55
88
|
label="JSON"
|
|
56
|
-
value={
|
|
57
|
-
disabled={
|
|
89
|
+
value={editorState.jsonDraftText}
|
|
90
|
+
disabled={editorState.readonly}
|
|
58
91
|
rows={20}
|
|
59
92
|
class="cinder-jse-json-view__textarea"
|
|
60
|
-
oninput={(event: Event) =>
|
|
93
|
+
oninput={(event: Event) =>
|
|
94
|
+
editorState.setJsonDraftText((event.target as HTMLTextAreaElement).value)}
|
|
61
95
|
/>
|
|
62
96
|
|
|
63
97
|
{#if draftErrorMessage}
|