@lostgradient/cinder 0.16.1 → 0.17.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 +185 -0
- package/README.md +33 -11
- package/components.json +53 -102
- package/dist/_internal/chart/chart-utilities.d.ts +1 -0
- package/dist/cli/index.js +63 -10
- package/dist/cli/mcp-dependencies.d.ts +4 -0
- package/dist/components/approval-card/approval-card.css +1 -6
- package/dist/components/approval-card/index.js +94 -55
- 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 +58 -9
- 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/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 +244 -199
- package/dist/components/invocation-rule-builder/invocation-rule-builder.css +8 -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 +261 -0
- package/dist/components/json-editor/json-editor.css +49 -0
- package/dist/components/{diff-viewer/diff-viewer.schema.js → json-editor/json-editor.schema.js} +37 -49
- package/dist/components/json-editor/json-editor.svelte.d.ts +21 -0
- package/dist/components/json-editor/json-editor.types.d.ts +25 -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 +158 -110
- 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/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/index.d.ts +47 -5
- package/dist/highlighters/shiki/index.js +58 -9
- package/dist/index.d.ts +4 -4
- package/dist/index.js +15347 -16138
- package/dist/server/components/access-gate/index.js +2 -5
- package/dist/server/components/approval-card/index.js +2 -2
- package/dist/server/components/area-chart/index.js +3 -3
- package/dist/server/components/bar-chart/index.js +3 -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/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 +1 -1
- package/dist/server/components/json-editor/index.js +13 -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 +1 -1
- 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/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/index.js +61 -25
- package/dist/server/index.js +105 -115
- 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-tf2n3ccm.js → index.server-1vfhzhkj.js} +1 -1
- package/dist/server/{index.server-jz5yxwde.js → index.server-4cbqjf14.js} +16 -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-93vt8ktj.js +95 -0
- 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-bf7d81b4.js → index.server-9vqfmhez.js} +16 -18
- 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-c5qv3p61.js → index.server-j87v28yy.js} +59 -30
- 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-g5jgq3jp.js → index.server-qxneqxf8.js} +40 -6
- 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-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-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/package.json +45 -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/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 +8 -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 +106 -83
- 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.css +49 -0
- package/src/components/json-editor/json-editor.examples.json +13 -0
- package/src/components/json-editor/json-editor.schema.json +57 -0
- package/src/components/json-editor/json-editor.schema.ts +62 -0
- package/src/components/json-editor/json-editor.svelte +104 -0
- package/src/components/json-editor/json-editor.types.ts +29 -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/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/index.ts +157 -17
- package/src/index.ts +5 -7
- package/src/styles/components.css +1 -1
- package/src/utilities/change-tracker.svelte.ts +1 -1
- 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
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ProseMirror plugin for decorating invalid `{{…}}` template placeholder tokens.
|
|
3
|
-
*
|
|
4
|
-
* Scans the document on every change, parses `{{…}}` tokens from each text block,
|
|
5
|
-
* validates them against the current candidate set, and applies inline decorations
|
|
6
|
-
* to invalid tokens with a CSS class and a `data-placeholder-validation-reason`
|
|
7
|
-
* attribute describing the failure.
|
|
8
|
-
*
|
|
9
|
-
* DEP-583: WYSIWYG invalid-token decoration for saved-prompt template authoring.
|
|
10
|
-
*/
|
|
11
|
-
import { Plugin, PluginKey } from 'prosemirror-state';
|
|
12
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
13
|
-
import { createLazyProsePlugin } from './milkdown-plugin-runtime.js';
|
|
14
|
-
import { parsePlaceholderTokens, validatePlaceholderTokens } from './template-placeholders.js';
|
|
15
|
-
import { textOffsetToBlockDocumentPosition } from './template-position-utilities.js';
|
|
16
|
-
/** Plugin key for the template invalid decoration plugin. */
|
|
17
|
-
export const templateInvalidDecorationPluginKey = new PluginKey('template-invalid-decoration');
|
|
18
|
-
/**
|
|
19
|
-
* Convert a text offset within a block node to a ProseMirror document position.
|
|
20
|
-
*
|
|
21
|
-
* Thin adapter over the shared `textOffsetToBlockDocumentPosition` utility.
|
|
22
|
-
* The parameter name `blockPosition` refers to the absolute document position
|
|
23
|
-
* of the block node itself (the value yielded by `document.descendants`).
|
|
24
|
-
* Internally it is converted to `blockContentStart = blockPosition + 1` before
|
|
25
|
-
* delegating to the shared walker.
|
|
26
|
-
*
|
|
27
|
-
* @internal Exported for testing only.
|
|
28
|
-
*
|
|
29
|
-
* @param block - The block-level ProseMirror node (paragraph, heading, etc.).
|
|
30
|
-
* @param blockPosition - The absolute document position of the block node itself.
|
|
31
|
-
* @param textOffset - A character offset into `block.textContent`.
|
|
32
|
-
* @returns The absolute ProseMirror position corresponding to `textOffset`.
|
|
33
|
-
*/
|
|
34
|
-
export function textOffsetToDocumentPosition(block, blockPosition, textOffset) {
|
|
35
|
-
// blockPosition is the node's own position (before its opening tag).
|
|
36
|
-
// blockContentStart = blockPosition + 1 is the position of the first
|
|
37
|
-
// character inside the block.
|
|
38
|
-
return textOffsetToBlockDocumentPosition(block, blockPosition + 1, textOffset);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Build decorations for all invalid `{{…}}` tokens in the document.
|
|
42
|
-
*
|
|
43
|
-
* Walks every block-level node, extracts its text content, parses placeholder
|
|
44
|
-
* tokens, validates them against the candidate set, and creates inline
|
|
45
|
-
* decorations for each invalid token.
|
|
46
|
-
*
|
|
47
|
-
* @internal Exported for testing only.
|
|
48
|
-
*
|
|
49
|
-
* @param document - The ProseMirror document node.
|
|
50
|
-
* @param candidates - Known placeholder candidates for validation.
|
|
51
|
-
* @param invalidClassName - CSS class applied to invalid token decorations.
|
|
52
|
-
* @returns An array of ProseMirror inline decorations.
|
|
53
|
-
*/
|
|
54
|
-
export function buildInvalidTokenDecorations(document, candidates, invalidClassName) {
|
|
55
|
-
const decorations = [];
|
|
56
|
-
document.descendants((node, position) => {
|
|
57
|
-
// Only process block-level nodes that contain inline content.
|
|
58
|
-
if (!node.isBlock || node.isAtom || !node.inlineContent)
|
|
59
|
-
return;
|
|
60
|
-
const textContent = node.textContent;
|
|
61
|
-
if (!textContent)
|
|
62
|
-
return;
|
|
63
|
-
const tokens = parsePlaceholderTokens(textContent);
|
|
64
|
-
if (tokens.length === 0)
|
|
65
|
-
return;
|
|
66
|
-
const { issues } = validatePlaceholderTokens(tokens, candidates);
|
|
67
|
-
for (const issue of issues) {
|
|
68
|
-
const from = textOffsetToDocumentPosition(node, position, issue.token.startOffset);
|
|
69
|
-
const to = textOffsetToDocumentPosition(node, position, issue.token.endOffset);
|
|
70
|
-
decorations.push(Decoration.inline(from, to, {
|
|
71
|
-
class: invalidClassName,
|
|
72
|
-
'data-placeholder-validation-reason': issue.reason,
|
|
73
|
-
}));
|
|
74
|
-
}
|
|
75
|
-
// Do not descend into children — we already processed the full text content
|
|
76
|
-
// of this block via textContent.
|
|
77
|
-
return false;
|
|
78
|
-
});
|
|
79
|
-
return decorations;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Create a Milkdown plugin that decorates invalid `{{…}}` template tokens.
|
|
83
|
-
*
|
|
84
|
-
* Caches the `DecorationSet` in plugin state and rebuilds it only when the
|
|
85
|
-
* document changes or when the candidate set/class name changes. For unchanged
|
|
86
|
-
* transactions the existing set is mapped through `tr.mapping` so ProseMirror
|
|
87
|
-
* can update decoration positions without a full document scan.
|
|
88
|
-
*
|
|
89
|
-
* The factory accepts accessor functions so the candidate set and class name
|
|
90
|
-
* can change at runtime without recreating the plugin.
|
|
91
|
-
*
|
|
92
|
-
* @param getCandidates - Returns the current set of placeholder candidates.
|
|
93
|
-
* @param getInvalidClassName - Returns the CSS class for invalid tokens.
|
|
94
|
-
* Defaults to returning `'template-placeholder-invalid'`.
|
|
95
|
-
* @returns A Milkdown-compatible plugin created via `$prose`.
|
|
96
|
-
*
|
|
97
|
-
* @example
|
|
98
|
-
* ```typescript
|
|
99
|
-
* const plugin = createTemplateInvalidDecorationPlugin(
|
|
100
|
-
* () => candidates,
|
|
101
|
-
* () => 'my-invalid-class',
|
|
102
|
-
* );
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
export function createTemplateInvalidDecorationPlugin(getCandidates, getInvalidClassName) {
|
|
106
|
-
const resolveInvalidClassName = () => getInvalidClassName?.() ?? 'template-placeholder-invalid';
|
|
107
|
-
return createLazyProsePlugin(() => {
|
|
108
|
-
return new Plugin({
|
|
109
|
-
key: templateInvalidDecorationPluginKey,
|
|
110
|
-
state: {
|
|
111
|
-
init(_config, editorState) {
|
|
112
|
-
const candidates = getCandidates();
|
|
113
|
-
const invalidClassName = resolveInvalidClassName();
|
|
114
|
-
const candidatesKey = JSON.stringify(candidates);
|
|
115
|
-
const decorationSpecs = buildInvalidTokenDecorations(editorState.doc, candidates, invalidClassName);
|
|
116
|
-
const decorations = decorationSpecs.length === 0
|
|
117
|
-
? DecorationSet.empty
|
|
118
|
-
: DecorationSet.create(editorState.doc, decorationSpecs);
|
|
119
|
-
return { decorations, candidatesKey, invalidClassName };
|
|
120
|
-
},
|
|
121
|
-
apply(transaction, pluginState, _oldEditorState, newEditorState) {
|
|
122
|
-
const nextCandidates = getCandidates();
|
|
123
|
-
const nextInvalidClassName = resolveInvalidClassName();
|
|
124
|
-
const nextCandidatesKey = JSON.stringify(nextCandidates);
|
|
125
|
-
const shouldRebuild = transaction.docChanged ||
|
|
126
|
-
nextCandidatesKey !== pluginState.candidatesKey ||
|
|
127
|
-
nextInvalidClassName !== pluginState.invalidClassName;
|
|
128
|
-
if (shouldRebuild) {
|
|
129
|
-
const decorationSpecs = buildInvalidTokenDecorations(newEditorState.doc, nextCandidates, nextInvalidClassName);
|
|
130
|
-
const decorations = decorationSpecs.length === 0
|
|
131
|
-
? DecorationSet.empty
|
|
132
|
-
: DecorationSet.create(newEditorState.doc, decorationSpecs);
|
|
133
|
-
return {
|
|
134
|
-
decorations,
|
|
135
|
-
candidatesKey: nextCandidatesKey,
|
|
136
|
-
invalidClassName: nextInvalidClassName,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
// Map existing decorations through the transaction's position mapping
|
|
140
|
-
// to keep them aligned when text is inserted/deleted elsewhere.
|
|
141
|
-
return {
|
|
142
|
-
decorations: pluginState.decorations.map(transaction.mapping, newEditorState.doc),
|
|
143
|
-
candidatesKey: pluginState.candidatesKey,
|
|
144
|
-
invalidClassName: pluginState.invalidClassName,
|
|
145
|
-
};
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
props: {
|
|
149
|
-
decorations(state) {
|
|
150
|
-
return templateInvalidDecorationPluginKey.getState(state)?.decorations ?? null;
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
}
|
|
@@ -1,355 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Template placeholder domain logic for saved-prompt/template authoring.
|
|
3
|
-
*
|
|
4
|
-
* Pure functions for JSON Schema candidate extraction, {{path}} token parsing,
|
|
5
|
-
* validation against known paths, and deterministic template resolution.
|
|
6
|
-
*
|
|
7
|
-
* DEP-582: No ProseMirror or DOM dependencies.
|
|
8
|
-
* DEP-625: For secure markdown rendering with sanitization, use renderTemplate from template-render.ts
|
|
9
|
-
*/
|
|
10
|
-
import { renderMarkdown } from '../markdown/rendering/index.js';
|
|
11
|
-
import { RESERVED_SEGMENTS } from './placeholder-security.js';
|
|
12
|
-
/** Valid placeholder path pattern: dot-separated identifiers starting with letter or underscore */
|
|
13
|
-
const PATH_REGEX = /^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)*$/;
|
|
14
|
-
/** Valid single path segment: one identifier (no dots) */
|
|
15
|
-
const SEGMENT_REGEX = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
16
|
-
function isRecord(value) {
|
|
17
|
-
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Validate a single path segment against security rules.
|
|
21
|
-
*
|
|
22
|
-
* DEP-625: Central security validation to prevent prototype pollution.
|
|
23
|
-
* - Blocks empty segments (e.g., from "user..name")
|
|
24
|
-
* - Enforces identifier rules (must match SEGMENT_REGEX)
|
|
25
|
-
* - Blocks reserved segments (case-insensitive)
|
|
26
|
-
* - Blocks segments starting with '__' (dunder properties)
|
|
27
|
-
*
|
|
28
|
-
* Returns true if the segment is blocked (invalid), false if allowed.
|
|
29
|
-
*
|
|
30
|
-
* @internal - Shared by template-placeholders.ts and preview-composer.ts
|
|
31
|
-
*/
|
|
32
|
-
export function isBlockedSegment(segment) {
|
|
33
|
-
// Block empty segments (e.g., from "user..name")
|
|
34
|
-
if (segment === '') {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
// Enforce identifier rules (must match SEGMENT_REGEX)
|
|
38
|
-
if (!SEGMENT_REGEX.test(segment)) {
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
// Block reserved segments (case-insensitive)
|
|
42
|
-
if (RESERVED_SEGMENTS.has(segment.toLowerCase())) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
// Block segments starting with '__' (dunder properties)
|
|
46
|
-
// Note: SEGMENT_REGEX allows '__' prefixes (e.g., '__proto__', '__custom__')
|
|
47
|
-
// since '_' is a valid identifier character. This check is the only guard
|
|
48
|
-
// against arbitrary '__'-prefixed segments not in RESERVED_SEGMENTS.
|
|
49
|
-
if (segment.startsWith('__')) {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Map a JSON Schema `type` value to a PlaceholderValueKind.
|
|
56
|
-
* Returns 'unknown' for missing or unsupported type values.
|
|
57
|
-
*/
|
|
58
|
-
function mapSchemaTypeToValueKind(type) {
|
|
59
|
-
switch (type) {
|
|
60
|
-
case 'string':
|
|
61
|
-
return 'string';
|
|
62
|
-
case 'number':
|
|
63
|
-
case 'integer':
|
|
64
|
-
return 'number';
|
|
65
|
-
case 'boolean':
|
|
66
|
-
return 'boolean';
|
|
67
|
-
case 'array':
|
|
68
|
-
return 'array';
|
|
69
|
-
case 'object':
|
|
70
|
-
return 'object';
|
|
71
|
-
default:
|
|
72
|
-
return 'unknown';
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Traverse a nested object by dot-separated path segments.
|
|
77
|
-
* Returns undefined if any segment is missing or a non-object intermediate is encountered.
|
|
78
|
-
*
|
|
79
|
-
* DEP-625: Hardened against prototype pollution attacks.
|
|
80
|
-
* - Validates all segments before resolution using isBlockedSegment()
|
|
81
|
-
* - Uses Object.hasOwn() to prevent prototype chain traversal
|
|
82
|
-
*
|
|
83
|
-
* This function enforces the same identifier rules as PATH_REGEX/SEGMENT_REGEX
|
|
84
|
-
* to ensure resolution behavior matches validation/candidate generation.
|
|
85
|
-
*/
|
|
86
|
-
function getNestedValue(values, path) {
|
|
87
|
-
const segments = path.split('.');
|
|
88
|
-
// Validate all segments before resolution (DEP-625)
|
|
89
|
-
for (const segment of segments) {
|
|
90
|
-
if (isBlockedSegment(segment)) {
|
|
91
|
-
return undefined;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
// Traverse the path using validated segments
|
|
95
|
-
let current = values;
|
|
96
|
-
for (const segment of segments) {
|
|
97
|
-
if (!isRecord(current)) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
// Use Object.hasOwn to avoid traversing the prototype chain. Without this
|
|
101
|
-
// guard, paths like "constructor" or "toString" resolve to inherited
|
|
102
|
-
// functions, which JSON.stringify coerces to the literal text "undefined"
|
|
103
|
-
// instead of the expected empty string.
|
|
104
|
-
if (!Object.hasOwn(current, segment)) {
|
|
105
|
-
return undefined;
|
|
106
|
-
}
|
|
107
|
-
current = current[segment];
|
|
108
|
-
}
|
|
109
|
-
return current;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Format a value for placeholder replacement using strict coercion rules.
|
|
113
|
-
*
|
|
114
|
-
* - undefined/null → ''
|
|
115
|
-
* - function/symbol → '' (JSON.stringify returns undefined for these types,
|
|
116
|
-
* which string concatenation coerces to the literal text "undefined")
|
|
117
|
-
* - string → unchanged
|
|
118
|
-
* - number/boolean/bigint → String(value)
|
|
119
|
-
* - array → map items then join(', ')
|
|
120
|
-
* - object → JSON.stringify(value)
|
|
121
|
-
*/
|
|
122
|
-
function formatValueForReplacement(value) {
|
|
123
|
-
if (value === undefined || value === null) {
|
|
124
|
-
return '';
|
|
125
|
-
}
|
|
126
|
-
// JSON.stringify returns undefined (not a string) for function and symbol
|
|
127
|
-
// values. String concatenation then coerces that to the literal text
|
|
128
|
-
// "undefined" rather than the expected empty string.
|
|
129
|
-
if (typeof value === 'function' || typeof value === 'symbol') {
|
|
130
|
-
return '';
|
|
131
|
-
}
|
|
132
|
-
if (typeof value === 'string') {
|
|
133
|
-
return value;
|
|
134
|
-
}
|
|
135
|
-
if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
|
|
136
|
-
return String(value);
|
|
137
|
-
}
|
|
138
|
-
if (Array.isArray(value)) {
|
|
139
|
-
return value
|
|
140
|
-
.map((item) => {
|
|
141
|
-
if (item === null || item === undefined) {
|
|
142
|
-
return '';
|
|
143
|
-
}
|
|
144
|
-
// Mirror the top-level function/symbol guard: JSON.stringify returns
|
|
145
|
-
// undefined for these types, and String() produces function source code
|
|
146
|
-
// or "Symbol(...)" — both inconsistent with the documented '' contract.
|
|
147
|
-
if (typeof item === 'function' || typeof item === 'symbol') {
|
|
148
|
-
return '';
|
|
149
|
-
}
|
|
150
|
-
if (typeof item === 'object') {
|
|
151
|
-
return JSON.stringify(item);
|
|
152
|
-
}
|
|
153
|
-
return String(item);
|
|
154
|
-
})
|
|
155
|
-
.join(', ');
|
|
156
|
-
}
|
|
157
|
-
return JSON.stringify(value);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Extract placeholder candidates from a JSON Schema by recursively walking `properties`.
|
|
161
|
-
*
|
|
162
|
-
* For each property:
|
|
163
|
-
* 1. Build the dot-separated path (e.g., "input.x").
|
|
164
|
-
* 2. Determine valueKind from the type field.
|
|
165
|
-
* 3. Extract description (string or undefined).
|
|
166
|
-
* 4. Emit a candidate for the current path.
|
|
167
|
-
* 5. If the property has nested properties, recurse (regardless of explicit type: 'object').
|
|
168
|
-
* 6. Silently ignore $ref, allOf, anyOf, oneOf, if/then/else, patternProperties, additionalProperties.
|
|
169
|
-
*
|
|
170
|
-
* Returns candidates sorted lexicographically by path.
|
|
171
|
-
*/
|
|
172
|
-
export function buildPlaceholderCandidatesFromJsonSchema(schema) {
|
|
173
|
-
const candidates = [];
|
|
174
|
-
function walk(properties, prefix) {
|
|
175
|
-
for (const key of Object.keys(properties)) {
|
|
176
|
-
// Skip keys that are not valid identifier segments — paths containing
|
|
177
|
-
// non-identifier characters (e.g. "first-name", "first.name") cannot
|
|
178
|
-
// be emitted as candidates because validatePlaceholderTokens would
|
|
179
|
-
// reject them as invalid_path_format and resolveTemplatePlaceholders
|
|
180
|
-
// would mis-resolve them by splitting on dots.
|
|
181
|
-
if (!SEGMENT_REGEX.test(key)) {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const property = properties[key];
|
|
185
|
-
if (!isRecord(property)) {
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
const path = prefix ? `${prefix}.${key}` : key;
|
|
189
|
-
const valueKind = mapSchemaTypeToValueKind(property['type']);
|
|
190
|
-
const description = typeof property['description'] === 'string' ? property['description'] : undefined;
|
|
191
|
-
candidates.push({ path, description, valueKind });
|
|
192
|
-
// Recurse into nested properties regardless of explicit type: 'object'
|
|
193
|
-
if (isRecord(property['properties'])) {
|
|
194
|
-
walk(property['properties'], path);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
if (isRecord(schema['properties'])) {
|
|
199
|
-
walk(schema['properties'], '');
|
|
200
|
-
}
|
|
201
|
-
return candidates.toSorted((a, b) => (a.path < b.path ? -1 : a.path > b.path ? 1 : 0));
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Parse all {{...}} tokens from the given text with source offsets.
|
|
205
|
-
*
|
|
206
|
-
* Scans for {{ delimiters and extracts tokens with:
|
|
207
|
-
* - raw: full text including delimiters
|
|
208
|
-
* - path: trimmed body between delimiters
|
|
209
|
-
* - startOffset/endOffset: source positions
|
|
210
|
-
* - closed: whether the token has a closing }}
|
|
211
|
-
*
|
|
212
|
-
* Never throws for any input.
|
|
213
|
-
*/
|
|
214
|
-
export function parsePlaceholderTokens(text) {
|
|
215
|
-
const tokens = [];
|
|
216
|
-
let position = 0;
|
|
217
|
-
while (position < text.length) {
|
|
218
|
-
const openIndex = text.indexOf('{{', position);
|
|
219
|
-
if (openIndex === -1) {
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
const closeIndex = text.indexOf('}}', openIndex + 2);
|
|
223
|
-
if (closeIndex !== -1) {
|
|
224
|
-
const raw = text.slice(openIndex, closeIndex + 2);
|
|
225
|
-
const path = raw.slice(2, -2).trim();
|
|
226
|
-
tokens.push({
|
|
227
|
-
raw,
|
|
228
|
-
path,
|
|
229
|
-
startOffset: openIndex,
|
|
230
|
-
endOffset: closeIndex + 2,
|
|
231
|
-
closed: true,
|
|
232
|
-
});
|
|
233
|
-
position = closeIndex + 2;
|
|
234
|
-
}
|
|
235
|
-
else {
|
|
236
|
-
const raw = text.slice(openIndex);
|
|
237
|
-
const path = raw.slice(2).trim();
|
|
238
|
-
tokens.push({
|
|
239
|
-
raw,
|
|
240
|
-
path,
|
|
241
|
-
startOffset: openIndex,
|
|
242
|
-
endOffset: text.length,
|
|
243
|
-
closed: false,
|
|
244
|
-
});
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return tokens;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Validate parsed tokens against a set of known placeholder candidates.
|
|
252
|
-
*
|
|
253
|
-
* Classifies each token as valid or invalid:
|
|
254
|
-
* - Unclosed tokens → malformed_token
|
|
255
|
-
* - Invalid path format → invalid_path_format
|
|
256
|
-
* - Path not in candidate set → unknown_placeholder
|
|
257
|
-
* - Otherwise → valid
|
|
258
|
-
*/
|
|
259
|
-
export function validatePlaceholderTokens(tokens, candidates) {
|
|
260
|
-
const candidatePaths = new Set(candidates.map((candidate) => candidate.path));
|
|
261
|
-
const validTokens = [];
|
|
262
|
-
const invalidTokens = [];
|
|
263
|
-
const issues = [];
|
|
264
|
-
for (const token of tokens) {
|
|
265
|
-
if (!token.closed) {
|
|
266
|
-
invalidTokens.push(token);
|
|
267
|
-
issues.push({ token, reason: 'malformed_token' });
|
|
268
|
-
}
|
|
269
|
-
else if (!PATH_REGEX.test(token.path)) {
|
|
270
|
-
invalidTokens.push(token);
|
|
271
|
-
issues.push({ token, reason: 'invalid_path_format' });
|
|
272
|
-
}
|
|
273
|
-
else if (!candidatePaths.has(token.path)) {
|
|
274
|
-
invalidTokens.push(token);
|
|
275
|
-
issues.push({ token, reason: 'unknown_placeholder' });
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
validTokens.push(token);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
return { validTokens, invalidTokens, issues };
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Resolve all placeholder tokens in the given text by substituting values.
|
|
285
|
-
*
|
|
286
|
-
* Iterates tokens in reverse order to preserve earlier offsets during string splicing.
|
|
287
|
-
* Unclosed tokens are left in the text unmodified.
|
|
288
|
-
* When candidatePaths is provided, unknown paths are reported as issues.
|
|
289
|
-
*/
|
|
290
|
-
export function resolveTemplatePlaceholders(text, values, candidatePaths) {
|
|
291
|
-
const tokens = parsePlaceholderTokens(text);
|
|
292
|
-
const candidateSet = candidatePaths ? new Set(candidatePaths) : undefined;
|
|
293
|
-
const issues = [];
|
|
294
|
-
// Iterate in reverse to preserve offsets during splicing. Issues are
|
|
295
|
-
// collected in reverse traversal order and sorted by startOffset before
|
|
296
|
-
// return so downstream consumers receive them in forward document order,
|
|
297
|
-
// consistent with validatePlaceholderTokens.
|
|
298
|
-
for (let i = tokens.length - 1; i >= 0; i--) {
|
|
299
|
-
const token = tokens[i];
|
|
300
|
-
if (!token)
|
|
301
|
-
continue;
|
|
302
|
-
if (!token.closed) {
|
|
303
|
-
continue;
|
|
304
|
-
}
|
|
305
|
-
const value = getNestedValue(values, token.path);
|
|
306
|
-
const replacement = formatValueForReplacement(value);
|
|
307
|
-
text = text.slice(0, token.startOffset) + replacement + text.slice(token.endOffset);
|
|
308
|
-
if (candidateSet && !candidateSet.has(token.path) && PATH_REGEX.test(token.path)) {
|
|
309
|
-
issues.push({ token, reason: 'unknown_placeholder' });
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
// Sort issues in forward document order so callers receive a consistent
|
|
313
|
-
// ordering regardless of whether they came from this function (which
|
|
314
|
-
// traverses tokens in reverse) or validatePlaceholderTokens (which
|
|
315
|
-
// traverses forward).
|
|
316
|
-
const sortedIssues = issues.toSorted((a, b) => a.token.startOffset - b.token.startOffset);
|
|
317
|
-
return { text, issues: sortedIssues };
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Render a template with placeholder substitution and markdown-to-HTML conversion.
|
|
321
|
-
*
|
|
322
|
-
* DEP-625: This function provides a secure rendering pipeline that:
|
|
323
|
-
* 1. Resolves placeholders using the hardened getNestedValue() (blocks prototype pollution)
|
|
324
|
-
* 2. Converts markdown to HTML using @cinder/markdown's sanitized pipeline
|
|
325
|
-
* 3. Sanitizes output via rehype-sanitize (blocks XSS attacks)
|
|
326
|
-
*
|
|
327
|
-
* Security guarantees:
|
|
328
|
-
* - Prototype pollution prevented via reserved segment blocking in getNestedValue()
|
|
329
|
-
* - XSS prevented via markdown pipeline's raw HTML removal and rehype-sanitize
|
|
330
|
-
* - Script tags, event handlers, and dangerous URLs are stripped
|
|
331
|
-
* - Only safe HTML tags and attributes are allowed
|
|
332
|
-
*
|
|
333
|
-
* @param template - Template string with {{placeholder}} tokens
|
|
334
|
-
* @param values - Data object for placeholder resolution
|
|
335
|
-
* @returns Sanitized HTML string safe for rendering
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* ```typescript
|
|
339
|
-
* const html = renderTemplate('# Hello {{name}}', { name: 'World' });
|
|
340
|
-
* // Returns: '<h1>Hello World</h1>'
|
|
341
|
-
*
|
|
342
|
-
* const xss = renderTemplate('<script>alert(1)</script>{{user}}', { user: 'Alice' });
|
|
343
|
-
* // Returns: 'Alice' (script tag removed by markdown pipeline)
|
|
344
|
-
* ```
|
|
345
|
-
*/
|
|
346
|
-
export function renderTemplate(template, values) {
|
|
347
|
-
// Resolve placeholders using the hardened path resolution from Phase 1
|
|
348
|
-
const { text } = resolveTemplatePlaceholders(template, values);
|
|
349
|
-
// Render markdown to sanitized HTML using the secure pipeline. The sync
|
|
350
|
-
// entry point intentionally does not handle KaTeX math — templates use
|
|
351
|
-
// Markdown for formatting but never LaTeX, and avoiding the math pipeline
|
|
352
|
-
// here keeps the editor bundle from pulling katex (~200 KB).
|
|
353
|
-
const result = renderMarkdown(text);
|
|
354
|
-
return result.html;
|
|
355
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared position-conversion utilities for template placeholder plugins.
|
|
3
|
-
*
|
|
4
|
-
* Both the completion plugin and the invalid-decoration plugin need to convert
|
|
5
|
-
* a character offset within a block's `textContent` to an absolute ProseMirror
|
|
6
|
-
* document position. This module provides a single canonical implementation so
|
|
7
|
-
* the two plugins cannot diverge.
|
|
8
|
-
*
|
|
9
|
-
* DEP-583: Extracted from template-completion-plugin and
|
|
10
|
-
* template-invalid-decoration-plugin to eliminate duplicated logic that
|
|
11
|
-
* previously had divergent atom-boundary behaviour.
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Convert a text-coordinate offset within a block's `textContent` to an
|
|
15
|
-
* absolute ProseMirror document position.
|
|
16
|
-
*
|
|
17
|
-
* Walks the block's inline children, counting only text characters (atom
|
|
18
|
-
* nodes such as `hard_break` and images contribute nothing to the text
|
|
19
|
-
* coordinate space, but `childOffset` already accounts for their document
|
|
20
|
-
* size). The function does **not** short-circuit after finding the first
|
|
21
|
-
* matching text node, so later text nodes can overwrite `result` correctly
|
|
22
|
-
* when `textOffset` falls exactly on a boundary between a text node and an
|
|
23
|
-
* atom.
|
|
24
|
-
*
|
|
25
|
-
* @param block - The block-level ProseMirror node (paragraph, heading, etc.).
|
|
26
|
-
* @param blockContentStart - The absolute document position of the first
|
|
27
|
-
* character inside the block (i.e. `$from.start()` or `blockPosition + 1`).
|
|
28
|
-
* @param textOffset - A character offset into `block.textContent`.
|
|
29
|
-
* @returns The absolute ProseMirror position corresponding to `textOffset`.
|
|
30
|
-
*
|
|
31
|
-
* @internal Exported for testing only.
|
|
32
|
-
*/
|
|
33
|
-
export function textOffsetToBlockDocumentPosition(block, blockContentStart, textOffset) {
|
|
34
|
-
let accumulated = 0;
|
|
35
|
-
let result = blockContentStart;
|
|
36
|
-
block.forEach((child, childOffset) => {
|
|
37
|
-
if (accumulated > textOffset)
|
|
38
|
-
return;
|
|
39
|
-
if (child.isText && child.text) {
|
|
40
|
-
const localOffset = textOffset - accumulated;
|
|
41
|
-
if (localOffset <= child.text.length) {
|
|
42
|
-
result = blockContentStart + childOffset + localOffset;
|
|
43
|
-
}
|
|
44
|
-
// Always advance accumulated so subsequent text nodes get the correct
|
|
45
|
-
// localOffset. The early-exit pattern (`accumulated = textOffset + 1`)
|
|
46
|
-
// must NOT be used here: when textOffset falls at the exact boundary
|
|
47
|
-
// between a text node and a following atom, the early exit would
|
|
48
|
-
// prevent the next iteration from overwriting `result` with the
|
|
49
|
-
// correct position.
|
|
50
|
-
accumulated += child.text.length;
|
|
51
|
-
}
|
|
52
|
-
else if (!child.isAtom) {
|
|
53
|
-
// Non-text, non-atom inline nodes (e.g., mark-wrapped spans) contribute
|
|
54
|
-
// their text to `block.textContent`, so we count them here to keep
|
|
55
|
-
// `accumulated` aligned with the text coordinate space. Atom nodes
|
|
56
|
-
// (hard_break, images) are intentionally excluded because they
|
|
57
|
-
// contribute zero text characters; `childOffset` already incorporates
|
|
58
|
-
// their document-position size.
|
|
59
|
-
accumulated += child.textContent.length;
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Secure template rendering with placeholder substitution and markdown-to-HTML conversion.
|
|
3
|
-
*
|
|
4
|
-
* DEP-625: This module is separated from template-placeholders.ts to avoid loading the
|
|
5
|
-
* heavy @cinder/markdown rendering pipeline for consumers that only need lightweight
|
|
6
|
-
* placeholder parsing/validation functions.
|
|
7
|
-
*
|
|
8
|
-
* @module
|
|
9
|
-
*/
|
|
10
|
-
import { renderMarkdown } from '../markdown/rendering/index.js';
|
|
11
|
-
import { resolveTemplatePlaceholders } from './template-placeholders.js';
|
|
12
|
-
/**
|
|
13
|
-
* Render a template with placeholder substitution and markdown-to-HTML conversion.
|
|
14
|
-
*
|
|
15
|
-
* DEP-625: This function provides a secure rendering pipeline that:
|
|
16
|
-
* 1. Resolves placeholders using the hardened getNestedValue() (blocks prototype pollution)
|
|
17
|
-
* 2. Converts markdown to HTML using @cinder/markdown's sanitized pipeline
|
|
18
|
-
* 3. Sanitizes output via rehype-sanitize (blocks XSS attacks)
|
|
19
|
-
*
|
|
20
|
-
* Security guarantees:
|
|
21
|
-
* - Prototype pollution prevented via reserved segment blocking in getNestedValue()
|
|
22
|
-
* - XSS prevented via markdown pipeline's raw HTML removal and rehype-sanitize
|
|
23
|
-
* - Script tags, event handlers, and dangerous URLs are stripped (entirely removed, including content)
|
|
24
|
-
* - Only safe HTML tags and attributes are allowed
|
|
25
|
-
*
|
|
26
|
-
* @param template - Template string with {{placeholder}} tokens
|
|
27
|
-
* @param values - Data object for placeholder resolution
|
|
28
|
-
* @returns Sanitized HTML string safe for rendering
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```typescript
|
|
32
|
-
* const html = renderTemplate('# Hello {{name}}', { name: 'World' });
|
|
33
|
-
* // Returns: '<h1>Hello World</h1>'
|
|
34
|
-
*
|
|
35
|
-
* const xss = renderTemplate('<script>alert(1)</script>{{user}}', { user: 'Alice' });
|
|
36
|
-
* // Returns: '<p>Alice</p>' (script tag and its contents removed; text wrapped in a paragraph by the markdown renderer)
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
export function renderTemplate(template, values) {
|
|
40
|
-
// Resolve placeholders using the hardened path resolution from Phase 1
|
|
41
|
-
const { text } = resolveTemplatePlaceholders(template, values);
|
|
42
|
-
// Render markdown to sanitized HTML using the existing secure pipeline
|
|
43
|
-
const result = renderMarkdown(text);
|
|
44
|
-
return result.html;
|
|
45
|
-
}
|