reactive-md 0.8.0 → 0.9.1
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-ch.md +54 -4
- package/CHANGELOG.md +55 -4
- package/CONTRIBUTING-ch.md +13 -2
- package/CONTRIBUTING.md +13 -2
- package/README-ch.md +132 -23
- package/README-en.md +130 -21
- package/README.md +128 -21
- package/SECURITY-ch.md +3 -3
- package/SECURITY.md +3 -3
- package/THIRD_PARTY_NOTICES.md +111 -1
- package/cli/args.mjs +51 -1
- package/cli/assets.mjs +6 -1
- package/cli/build.mjs +125 -9
- package/cli/fs-utils.mjs +3 -3
- package/cli/help.mjs +12 -5
- package/cli/init.mjs +1 -1
- package/cli/package.mjs +1 -0
- package/dist-library/LocalDocumentView-sthUP0ct.js +109 -0
- package/dist-library/LocalDocumentViewCore-GiWV3bey.js +9829 -0
- package/dist-library/LocalReactiveDocumentCore-ZjQSGyHE.js +275 -0
- package/dist-library/{authoring-BsfSwQRm.js → authoring-Dsune4Hy.js} +240 -218
- package/dist-library/compile-wUv8KEge.js +1249 -0
- package/dist-library/{compiler-core-kPiH-gOV.js → compiler-core-As_m-MNm.js} +5372 -5559
- package/dist-library/compiler-eOfcinZs.js +62 -0
- package/dist-library/component-state-BoLCGee4.js +801 -0
- package/dist-library/{component-state-D_cw_EHe.js → component-state-C52ZFJGl.js} +2 -2
- package/dist-library/{registry-B9Jc3FVe.js → config-BadfhjdP.js} +374 -457
- package/dist-library/{config-validation-DXTynAw7.js → config-validation-F47AcE6o.js} +549 -751
- package/dist-library/controls-CcT6n7k_.js +6740 -0
- package/dist-library/coordinate-CWS9p5q_.js +293 -0
- package/dist-library/data-table-Bgccxd7h.js +296 -0
- package/dist-library/{default-components-Z_YMio5P.js → default-components-BwQf0oP-.js} +344 -334
- package/dist-library/{math-display-BJz4gbFc.js → display-B-VhqVND.js} +1299 -1299
- package/dist-library/export-BqVmTXm8.js +369 -0
- package/dist-library/gallery-CY6mTx8i.js +360 -0
- package/dist-library/html-CNT4KD-2.js +757 -0
- package/dist-library/{math-sample-BGEW49zY.js → incremental-Dv0FSp_U.js} +476 -394
- package/dist-library/latex-1w7aQgD5.js +928 -0
- package/dist-library/layout-C0YlEPGr.js +562 -0
- package/dist-library/mount-preset-KxvtKgJb.js +13 -0
- package/dist-library/options-1aDLK7JY.js +121 -0
- package/dist-library/{react-ByOHunUW.js → package-core-WFK1RhAZ.js} +49 -55
- package/dist-library/{parser-standard-DlCk7sLo.js → parser-standard-Yuf3A_VI.js} +6605 -7097
- package/dist-library/plugin-packs-B1XPWcFs.js +18 -0
- package/dist-library/{identity-MYJXKSkB.js → preset-core-CKc5YXSM.js} +31 -31
- package/dist-library/{props-DGlBk0e5.js → props-sJ8vk0cr.js} +1 -1
- package/dist-library/react-BbyAgeXc.js +6070 -0
- package/dist-library/react-D5iGiUdL.js +7 -0
- package/dist-library/reactive-md-authoring.js +222 -223
- package/dist-library/reactive-md-build.js +126 -72
- package/dist-library/reactive-md-compiler-standard.js +12 -10
- package/dist-library/reactive-md-compiler.js +3 -3
- package/dist-library/reactive-md-default-packs.js +2 -2
- package/dist-library/reactive-md-default-preset.js +4 -4
- package/dist-library/reactive-md-export-assets.js +57 -0
- package/dist-library/reactive-md-export.js +5 -111
- package/dist-library/reactive-md-minimal-preset.js +24 -0
- package/dist-library/reactive-md-minimal-react-preset.js +26 -0
- package/dist-library/reactive-md-minimal-styles.js +80 -0
- package/dist-library/reactive-md-minimal.css +2 -0
- package/dist-library/reactive-md-pdf.js +7582 -0
- package/dist-library/reactive-md-plugin-chart.js +13 -0
- package/dist-library/reactive-md-plugin-data.js +17 -0
- package/dist-library/reactive-md-plugin-diagram.js +18 -0
- package/dist-library/reactive-md-plugin-forms.js +18 -0
- package/dist-library/reactive-md-plugin-gallery.js +12 -0
- package/dist-library/reactive-md-plugin-navigation.js +15 -0
- package/dist-library/reactive-md-plugin-network.js +222 -0
- package/dist-library/reactive-md-plugin-plot.js +24 -0
- package/dist-library/reactive-md-print.css +5 -0
- package/dist-library/reactive-md-react-minimal.js +28 -0
- package/dist-library/reactive-md-react-server.js +34 -32
- package/dist-library/reactive-md-react-unstyled.js +14 -9
- package/dist-library/reactive-md-react.js +14 -9
- package/dist-library/reactive-md-runtime-browser.js +847 -15
- package/dist-library/reactive-md-runtime.js +3 -3
- package/dist-library/reactive-md-sdk.js +8 -6
- package/dist-library/reactive-md-standalone-configured.js +16 -0
- package/dist-library/reactive-md-standalone-host.js +9 -438
- package/dist-library/reactive-md-testing-browser.js +5 -4
- package/dist-library/reactive-md-testing-react.js +46 -44
- package/dist-library/reactive-md-testing.js +45 -44
- package/dist-library/reactive-md-vite.js +135 -37
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +590 -498
- package/dist-library/registry-B9NGct4d.js +20 -0
- package/dist-library/registry-core-Bbad9Bm2.js +479 -0
- package/dist-library/{resources-BGt8mpDA.js → resources-D2GDQS0p.js} +45 -45
- package/dist-library/{runtime-Dkq7ldyg.js → runtime-B2fxeveq.js} +1 -1
- package/dist-library/runtime-kcA7bG7G.js +1282 -0
- package/dist-library/sample-bP4zHB3L.js +289 -0
- package/dist-library/{schema-ZFufO8V0.js → schema-BufhKUSM.js} +12 -11
- package/dist-library/sdk-core-BoJT1SIt.js +1166 -0
- package/dist-library/session-core-nmJHuR9c.js +452 -0
- package/dist-library/{shareable-DDVL4Fi9.js → shareable-DpbE-59H.js} +250 -283
- package/dist-library/tooltip-layer-HDLrSWs0.js +28 -0
- package/dist-library/types/authoring/catalog.d.ts +2 -3
- package/dist-library/types/authoring/editor-i18n.d.ts +1 -1
- package/dist-library/types/authoring/index.d.ts +1 -1
- package/dist-library/types/authoring/insert.d.ts +1 -1
- package/dist-library/types/authoring/templates.d.ts +2 -2
- package/dist-library/types/build/diagnostics.d.ts +1 -1
- package/dist-library/types/build/host.d.ts +1 -1
- package/dist-library/types/build/index.d.ts +1 -1
- package/dist-library/types/build/notices.d.ts +1 -1
- package/dist-library/types/build/resources.d.ts +1 -1
- package/dist-library/types/build/vite.d.ts +1 -1
- package/dist-library/types/compiler/index.d.ts +2 -2
- package/dist-library/types/compiler/result.d.ts +1 -1
- package/dist-library/types/compiler/standard.d.ts +2 -2
- package/dist-library/types/compiler/types.d.ts +1 -1
- package/dist-library/types/components/{controls.d.ts → controls/controls.d.ts} +2 -3
- package/dist-library/types/components/{numeric-sliders.d.ts → controls/numeric-sliders.d.ts} +1 -1
- package/dist-library/types/components/{gallery.d.ts → gallery/gallery.d.ts} +1 -1
- package/dist-library/types/components/{layout.d.ts → layout/layout.d.ts} +1 -1
- package/dist-library/types/components/minimal-preset.d.ts +2 -0
- package/dist-library/types/components/mount-preset.d.ts +4 -0
- package/dist-library/types/components/network/submit-button.d.ts +10 -0
- package/dist-library/types/components/plot/coordinate.d.ts +2 -0
- package/dist-library/types/components/plugins/chart.d.ts +2 -0
- package/dist-library/types/components/plugins/data.d.ts +2 -0
- package/dist-library/types/components/plugins/diagram.d.ts +2 -0
- package/dist-library/types/components/plugins/forms.d.ts +2 -0
- package/dist-library/types/components/plugins/gallery.d.ts +2 -0
- package/dist-library/types/components/plugins/navigation.d.ts +2 -0
- package/dist-library/types/components/plugins/network.d.ts +2 -0
- package/dist-library/types/components/plugins/plot.d.ts +2 -0
- package/dist-library/types/components/shared/visual-frame.d.ts +12 -0
- package/dist-library/types/components/{visuals.d.ts → shared/visuals.d.ts} +1 -7
- package/dist-library/types/components/{data-table.d.ts → table/data-table.d.ts} +2 -2
- package/dist-library/types/export/component-state.d.ts +1 -1
- package/dist-library/types/export/index.d.ts +2 -1
- package/dist-library/types/export/print-document.d.ts +18 -0
- package/dist-library/types/export/render-markup.d.ts +23 -0
- package/dist-library/types/export/requirements.d.ts +1 -1
- package/dist-library/types/export/resources.d.ts +1 -1
- package/dist-library/types/export/restoration.d.ts +1 -1
- package/dist-library/types/export-assets/index.d.ts +25 -0
- package/dist-library/types/local/compilation/compiler-attributes.d.ts +8 -0
- package/dist-library/types/local/compilation/compiler-bindings.d.ts +19 -0
- package/dist-library/types/local/compilation/compiler-capabilities.d.ts +3 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +11 -3
- package/dist-library/types/local/compilation/compiler-declarations.d.ts +32 -0
- package/dist-library/types/local/compilation/compiler-expressions.d.ts +32 -0
- package/dist-library/types/local/compilation/compiler-services.d.ts +62 -16
- package/dist-library/types/local/compilation/compiler-structure.d.ts +38 -3
- package/dist-library/types/local/compilation/compiler-tables.d.ts +30 -0
- package/dist-library/types/local/compilation/compiler-validation.d.ts +15 -0
- package/dist-library/types/local/compilation/compiler-values.d.ts +39 -1
- package/dist-library/types/local/compilation/compiler.d.ts +7 -14
- package/dist-library/types/local/compilation/dependencies.d.ts +1 -1
- package/dist-library/types/local/compilation/session/incremental.d.ts +75 -0
- package/dist-library/types/local/{session → compilation/session}/row-reuse.d.ts +1 -1
- package/dist-library/types/local/{session/compiler-cache.d.ts → compilation/session/semantic-cache.d.ts} +5 -19
- package/dist-library/types/local/compilation/streaming.d.ts +27 -0
- package/dist-library/types/local/configuration/capability-policy.d.ts +3 -0
- package/dist-library/types/local/{compilation → configuration}/component-kernel.d.ts +3 -79
- package/dist-library/types/local/configuration/diagnostic-messages.d.ts +1104 -1056
- package/dist-library/types/local/configuration/diagnostic-runtime-messages.d.ts +731 -0
- package/dist-library/types/local/configuration/diagnostics.d.ts +1 -1
- package/dist-library/types/local/configuration/kernel-value-rules.d.ts +66 -0
- package/dist-library/types/local/configuration/official-leaf-syntax.d.ts +24 -0
- package/dist-library/types/local/configuration/options-core.d.ts +5 -4
- package/dist-library/types/local/configuration/options.d.ts +2 -1
- package/dist-library/types/local/configuration/portable-options.d.ts +1 -1
- package/dist-library/types/local/configuration/schema-core.d.ts +1 -1
- package/dist-library/types/local/configuration/schema.d.ts +1 -1
- package/dist-library/types/local/css/author-css.d.ts +66 -0
- package/dist-library/types/local/evaluation/computations.d.ts +2 -2
- package/dist-library/types/local/evaluation/expression/compile.d.ts +30 -0
- package/dist-library/types/local/evaluation/expression/evaluation.d.ts +3 -0
- package/dist-library/types/local/evaluation/expression/inference.d.ts +4 -0
- package/dist-library/types/local/evaluation/expression/syntax.d.ts +72 -0
- package/dist-library/types/local/evaluation/expression/values.d.ts +56 -0
- package/dist-library/types/local/evaluation/{math-display.d.ts → math/display.d.ts} +2 -2
- package/dist-library/types/local/evaluation/math/evaluation.d.ts +10 -0
- package/dist-library/types/local/evaluation/{math.d.ts → math/latex.d.ts} +58 -17
- package/dist-library/types/local/evaluation/{math-sample.d.ts → math/sample.d.ts} +4 -2
- package/dist-library/types/local/evaluation/math/syntax.d.ts +72 -0
- package/dist-library/types/local/evaluation/validation.d.ts +1 -1
- package/dist-library/types/local/html/extended-fragment.d.ts +41 -0
- package/dist-library/types/local/html/html-details.d.ts +1 -1
- package/dist-library/types/local/html/html-entities.d.ts +11 -2
- package/dist-library/types/local/html/html-recovery.d.ts +1 -1
- package/dist-library/types/local/html/html-table.d.ts +1 -1
- package/dist-library/types/local/html/html.d.ts +40 -4
- package/dist-library/types/local/index.d.ts +14 -13
- package/dist-library/types/local/parsing/author-markdown.d.ts +11 -0
- package/dist-library/types/local/{markdown → parsing}/fast-markdown.d.ts +1 -1
- package/dist-library/types/local/{markdown → parsing}/footnotes.d.ts +1 -1
- package/dist-library/types/local/{markdown → parsing}/heading-anchors.d.ts +1 -1
- package/dist-library/types/local/parsing/html-attributes.d.ts +14 -0
- package/dist-library/types/local/parsing/parse-budget.d.ts +1 -1
- package/dist-library/types/local/{session → parsing}/parse-session.d.ts +5 -5
- package/dist-library/types/local/parsing/parser-capabilities.d.ts +7 -2
- package/dist-library/types/local/parsing/parser-convert.d.ts +26 -0
- package/dist-library/types/local/parsing/parser-core.d.ts +10 -4
- package/dist-library/types/local/parsing/parser-internals.d.ts +54 -0
- package/dist-library/types/local/parsing/parser-region.d.ts +46 -0
- package/dist-library/types/local/parsing/parser-standard.d.ts +3 -0
- package/dist-library/types/local/parsing/parser-tags.d.ts +108 -0
- package/dist-library/types/local/parsing/parser.d.ts +3 -3
- package/dist-library/types/local/{markdown → parsing}/plain-paragraphs.d.ts +1 -1
- package/dist-library/types/local/parsing/rmd-recovery.d.ts +1 -1
- package/dist-library/types/local/parsing/theme-declaration.d.ts +22 -0
- package/dist-library/types/local/rendering/document/ExtendedHtmlFragment.d.ts +14 -0
- package/dist-library/types/local/rendering/document/LocalDocumentView.d.ts +5 -0
- package/dist-library/types/local/rendering/{LocalDocumentView.d.ts → document/LocalDocumentViewCore.d.ts} +48 -9
- package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +6 -0
- package/dist-library/types/local/rendering/document/render-nodes.d.ts +24 -0
- package/dist-library/types/local/rendering/document/use-author-script.d.ts +3 -0
- package/dist-library/types/local/rendering/document/use-color-scheme.d.ts +10 -0
- package/dist-library/types/local/rendering/document/validation-state.d.ts +31 -0
- package/dist-library/types/local/rendering/document/view-render-context.d.ts +146 -0
- package/dist-library/types/local/rendering/{view-revision.d.ts → document/view-revision.d.ts} +31 -4
- package/dist-library/types/local/rendering/render-types.d.ts +1 -1
- package/dist-library/types/local/{widgets/table-surface.d.ts → rendering/table/data-table.d.ts} +3 -0
- package/dist-library/types/local/rendering/table/table-numeric-columns.d.ts +7 -0
- package/dist-library/types/local/runtime/author-script-protocol.d.ts +59 -0
- package/dist-library/types/local/runtime/retention.d.ts +1 -1
- package/dist-library/types/local/runtime/runtime-document.d.ts +71 -0
- package/dist-library/types/local/runtime/runtime-migration.d.ts +19 -0
- package/dist-library/types/local/runtime/runtime-values.d.ts +39 -0
- package/dist-library/types/local/runtime/runtime.d.ts +4 -2
- package/dist-library/types/local/runtime/state.d.ts +1 -1
- package/dist-library/types/local/source/authoring-syntax.d.ts +48 -0
- package/dist-library/types/local/source/authoring.d.ts +1 -1
- package/dist-library/types/local/source/source-context.d.ts +23 -0
- package/dist-library/types/local/source/source-migration.d.ts +2 -2
- package/dist-library/types/local/transport/compile-patch.d.ts +1 -1
- package/dist-library/types/local/transport/flat-compiled-data.d.ts +1 -1
- package/dist-library/types/local/transport/shared-data.d.ts +1 -1
- package/dist-library/types/local/transport/worker-handler.d.ts +30 -0
- package/dist-library/types/local/transport/worker-job.d.ts +28 -0
- package/dist-library/types/local/transport/worker.d.ts +32 -46
- package/dist-library/types/local/{contracts/types.d.ts → types.d.ts} +78 -21
- package/dist-library/types/pdf.d.ts +22 -0
- package/dist-library/types/presets/identity.d.ts +1 -0
- package/dist-library/types/presets/minimal.d.ts +2 -0
- package/dist-library/types/presets/plugin-packs.d.ts +1 -0
- package/dist-library/types/react/component-api.d.ts +20 -4
- package/dist-library/types/react/component-primitives.d.ts +10 -10
- package/dist-library/types/react/component-utils.d.ts +9 -1
- package/dist-library/types/react/index.d.ts +6 -5
- package/dist-library/types/{local/theme/i18n.d.ts → react/localization.d.ts} +2 -2
- package/dist-library/types/react/minimal.d.ts +13 -0
- package/dist-library/types/react/package-core.d.ts +67 -0
- package/dist-library/types/react/package.d.ts +3 -67
- package/dist-library/types/react/runtime/common.d.ts +1 -1
- package/dist-library/types/react/sdk-core.d.ts +115 -0
- package/dist-library/types/react/sdk.d.ts +4 -110
- package/dist-library/types/react/server.d.ts +2 -2
- package/dist-library/types/react/use-draft-field.d.ts +5 -1
- package/dist-library/types/runtime-services/browser/duplex.d.ts +163 -0
- package/dist-library/types/runtime-services/browser/http-sse.d.ts +117 -0
- package/dist-library/types/runtime-services/browser/index.d.ts +2 -1
- package/dist-library/types/runtime-services/component-state.d.ts +1 -1
- package/dist-library/types/runtime-services/index.d.ts +2 -0
- package/dist-library/types/runtime-services/network.d.ts +86 -0
- package/dist-library/types/runtime-services/runtime.d.ts +1 -1
- package/dist-library/types/sdk/config.d.ts +1 -1
- package/dist-library/types/sdk/index.d.ts +1 -0
- package/dist-library/types/sdk/props.d.ts +1 -1
- package/dist-library/types/sdk/registry-core.d.ts +1 -1
- package/dist-library/types/sdk/theme.d.ts +5 -4
- package/dist-library/types/sdk/types.d.ts +2 -2
- package/dist-library/types/shareable.d.ts +6 -5
- package/dist-library/types/standalone/diagnostics.d.ts +1 -1
- package/dist-library/types/standalone/host.d.ts +5 -0
- package/dist-library/types/standalone/payload.d.ts +1 -1
- package/dist-library/types/standalone/prepare.d.ts +2 -2
- package/dist-library/types/standalone/session-core.d.ts +68 -0
- package/dist-library/types/standalone/session.d.ts +6 -68
- package/dist-library/types/themes/contract.d.ts +7 -0
- package/dist-library/types/{local/theme/theme.d.ts → themes/document-theme.d.ts} +4 -3
- package/dist-library/types/vite/client.d.ts +19 -0
- package/dist-library/types/vite/index.d.ts +18 -3
- package/dist-library/types/vite/registration.d.ts +2 -2
- package/dist-library/{types-BFCrMrg0.js → types-BeNtPqdY.js} +1 -1
- package/dist-library/validation-BEBA_HvS.js +1121 -0
- package/dist-library/visual-frame-CyV1FXzs.js +48 -0
- package/dist-library/visuals-B5KSafVk.js +3 -0
- package/dist-library/visuals-BZbZYA7w.js +72572 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +146 -137
- package/docs/README-ch.md +16 -11
- package/docs/README.md +16 -11
- package/docs/compatibility/compatibility-ch.md +8 -8
- package/docs/compatibility/compatibility-en.md +8 -8
- package/docs/compatibility/source-versioning-ch.md +1 -1
- package/docs/compatibility/source-versioning-en.md +1 -1
- package/docs/development/component-development-ch.md +2 -2
- package/docs/development/component-development-en.md +2 -2
- package/docs/development/component-development-reference-ch.md +4 -4
- package/docs/development/component-development-reference-en.md +4 -4
- package/docs/development/component-protocol-ch.md +14 -14
- package/docs/development/component-protocol-en.md +14 -14
- package/docs/development/extension-tutorial-ch.md +308 -0
- package/docs/development/extension-tutorial-en.md +308 -0
- package/docs/development/local-module-layout-ch.md +10 -50
- package/docs/development/local-module-layout-en.md +9 -49
- package/docs/development/performance-overview-ch.md +174 -154
- package/docs/development/performance-overview-en.md +174 -154
- package/docs/guides/local-guide-ch.md +2 -2
- package/docs/guides/local-guide-en.md +2 -2
- package/docs/integration/author-tools-ch.md +2 -2
- package/docs/integration/author-tools-en.md +2 -2
- package/docs/integration/compiler-ch.md +4 -2
- package/docs/integration/compiler-en.md +4 -2
- package/docs/integration/directory-discovery-ch.md +5 -1
- package/docs/integration/directory-discovery-en.md +5 -1
- package/docs/integration/editor-ch.md +35 -5
- package/docs/integration/editor-en.md +42 -4
- package/docs/integration/extension-sdk-ch.md +6 -4
- package/docs/integration/extension-sdk-en.md +6 -4
- package/docs/integration/local-integration-ch.md +201 -19
- package/docs/integration/local-integration-en.md +194 -18
- package/docs/integration/network-host-ch.md +75 -0
- package/docs/integration/network-host-en.md +75 -0
- package/docs/integration/shareable-export-ch.md +58 -16
- package/docs/integration/shareable-export-en.md +57 -15
- package/docs/reference/html-compatibility-ch.md +20 -67
- package/docs/reference/html-compatibility-en.md +19 -64
- package/docs/reference/local-interaction-syntax-ch.md +199 -26
- package/docs/reference/local-interaction-syntax-en.md +194 -27
- package/docs/reference/public-api-ch.md +416 -0
- package/docs/reference/public-api-en.md +416 -0
- package/docs/reference/theme-protocol-ch.md +27 -8
- package/docs/reference/theme-protocol-en.md +46 -8
- package/docs/releases/release-0.4.0-ch.md +2 -2
- package/docs/releases/release-0.4.0-en.md +2 -2
- package/docs/releases/release-0.8.0-ch.md +19 -3
- package/docs/releases/release-0.8.0-en.md +19 -3
- package/docs/releases/release-0.9.0-ch.md +44 -0
- package/docs/releases/release-0.9.0-en.md +44 -0
- package/docs/releases/release-0.9.1-ch.md +29 -0
- package/docs/releases/release-0.9.1-en.md +29 -0
- package/examples/component-package/README-ch.md +1 -1
- package/examples/component-package/README.md +1 -1
- package/examples/conformance/README-ch.md +3 -3
- package/examples/conformance/README.md +3 -3
- package/examples/game-2048-package/README-ch.md +3 -9
- package/examples/game-2048-package/README.md +8 -12
- package/examples/integration/README-ch.md +21 -2
- package/examples/integration/README.md +21 -2
- package/examples/integration/extension-sdk/README-ch.md +1 -1
- package/examples/integration/extension-sdk/README.md +1 -1
- package/examples/integration/streaming/index.html +48 -0
- package/examples/integration/streaming/main.js +175 -0
- package/examples/integration/streaming/package.json +13 -0
- package/examples/integration/streaming/worker.js +3 -0
- package/examples/local/README-ch.md +3 -3
- package/examples/local/README.md +2 -2
- package/examples/local/minimal-budget.reactive.md +48 -0
- package/examples/minimal-extension/README-ch.md +78 -0
- package/examples/minimal-extension/README.md +78 -0
- package/examples/minimal-extension/index.html +15 -0
- package/examples/minimal-extension/package.json +26 -0
- package/examples/minimal-extension/sample/document.reactive.md +10 -0
- package/examples/minimal-extension/scripts/build.mjs +32 -0
- package/examples/minimal-extension/scripts/export.mjs +72 -0
- package/examples/minimal-extension/scripts/test-node.mjs +75 -0
- package/examples/minimal-extension/src/extension.tsx +90 -0
- package/examples/minimal-extension/src/preview.tsx +12 -0
- package/examples/minimal-extension/src/source.ts +4 -0
- package/examples/minimal-extension/tsconfig.json +14 -0
- package/examples/network-survey/README.md +200 -0
- package/examples/network-survey/index.html +49 -0
- package/examples/network-survey/package.json +26 -0
- package/examples/network-survey/sample/document.reactive.md +51 -0
- package/examples/network-survey/src/components.tsx +325 -0
- package/examples/network-survey/src/host.ts +316 -0
- package/examples/network-survey/src/main.tsx +91 -0
- package/examples/network-survey/src/source.ts +1 -0
- package/examples/network-survey/tsconfig.json +26 -0
- package/examples/network-survey/vite.config.ts +227 -0
- package/examples/sci-fi-theme/README-ch.md +4 -2
- package/examples/sci-fi-theme/README.md +4 -2
- package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -0
- package/examples/sci-fi-theme/demo/demo.css +129 -23
- package/examples/sci-fi-theme/demo/document.reactive.md +27 -6
- package/examples/sci-fi-theme/demo/main.tsx +45 -10
- package/examples/sci-fi-theme/docs/design-system-ch.md +6 -6
- package/examples/sci-fi-theme/package.json +2 -1
- package/examples/sci-fi-theme/src/components.css +1064 -154
- package/examples/sci-fi-theme/src/notch.css +142 -0
- package/examples/sci-fi-theme/src/sci-fi.css +3 -1
- package/examples/sci-fi-theme/src/theme.ts +2 -0
- package/examples/sci-fi-theme/src/tokens.css +512 -408
- package/examples/tetris-package/README-ch.md +4 -4
- package/examples/tetris-package/README.md +4 -4
- package/package.json +70 -3
- package/dist-library/LocalDocumentView-6trX7xJc.js +0 -97920
- package/dist-library/compiler--ea2CKQF.js +0 -61
- package/dist-library/component-state-Cq2K5gkS.js +0 -490
- package/dist-library/options-CX5m5n-J.js +0 -115
- package/dist-library/runtime-C-sbfpOX.js +0 -1157
- package/dist-library/types/local/contracts/locale.d.ts +0 -1
- package/dist-library/types/local/contracts/version.d.ts +0 -2
- package/dist-library/types/local/evaluation/dates.d.ts +0 -2
- package/dist-library/types/local/evaluation/expression.d.ts +0 -47
- package/dist-library/types/local/markdown/markdown-structure.d.ts +0 -3
- package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +0 -36
- package/dist-library/types/local/session/incremental.d.ts +0 -48
- package/dist-library/types/local/source/node-walk.d.ts +0 -3
- package/dist-library/types/local/source/text-length.d.ts +0 -13
- package/dist-library/types/local/theme/theme-name.d.ts +0 -3
- package/dist-library/types/local/widgets/visuals.d.ts +0 -25
- package/dist-library/types/react/default-theme.d.ts +0 -6
- package/dist-library/validation-W-bmny-x.js +0 -2253
- package/docs/development/releasing-ch.md +0 -12
- package/docs/development/releasing-en.md +0 -12
- package/docs/integration/codemirror-ch.md +0 -52
- package/docs/integration/codemirror-en.md +0 -29
- package/docs/integration/repository-split-ch.md +0 -40
- package/docs/integration/repository-split-en.md +0 -23
- package/docs/reference/computations-formatting-ch.md +0 -89
- package/docs/reference/computations-formatting-en.md +0 -89
- package/docs/reference/constraints-collections-ch.md +0 -104
- package/docs/reference/constraints-collections-en.md +0 -104
- package/docs/reference/local-components-v2-ch.md +0 -140
- package/docs/reference/local-components-v2-en.md +0 -106
- package/docs/reference/tolerance-ch.md +0 -64
- package/docs/reference/tolerance-en.md +0 -57
- /package/dist-library/types/components/{chart-motion.d.ts → chart/chart-motion.d.ts} +0 -0
- /package/dist-library/types/components/{default-chart-types.d.ts → chart/default-chart-types.d.ts} +0 -0
- /package/dist-library/types/components/{default-chart.d.ts → chart/default-chart.d.ts} +0 -0
- /package/dist-library/types/components/{diagram-inspector.d.ts → diagram/diagram-inspector.d.ts} +0 -0
- /package/dist-library/types/{local/widgets/diagram-layout.d.ts → components/diagram/layout.d.ts} +0 -0
- /package/dist-library/types/components/{mafs-plot-grid.d.ts → plot/mafs-plot-grid.d.ts} +0 -0
- /package/dist-library/types/components/{mafs-visuals.d.ts → plot/mafs-visuals.d.ts} +0 -0
- /package/dist-library/types/components/{use-hydrated.d.ts → shared/use-hydrated.d.ts} +0 -0
- /package/dist-library/types/local/{theme/colors.d.ts → configuration/color-values.d.ts} +0 -0
- /package/dist-library/types/local/evaluation/{collection-functions.d.ts → expression/collection-functions.d.ts} +0 -0
- /package/dist-library/types/local/evaluation/{data-functions.d.ts → expression/data-functions.d.ts} +0 -0
- /package/dist-library/types/local/evaluation/{formatting.d.ts → expression/formatting.d.ts} +0 -0
- /package/dist-library/types/local/{markdown → parsing}/markdown-blocks.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering/code}/code-block.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering/code}/code-languages.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering/image}/image-view.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering}/math-view.d.ts +0 -0
|
@@ -0,0 +1,1166 @@
|
|
|
1
|
+
import { O as e } from "./preset-core-CKc5YXSM.js";
|
|
2
|
+
import { M as t } from "./config-validation-F47AcE6o.js";
|
|
3
|
+
import { i as n, o as r } from "./props-sJ8vk0cr.js";
|
|
4
|
+
import { s as i } from "./config-BadfhjdP.js";
|
|
5
|
+
import { C as a, E as o, T as s, j as c, x as l } from "./component-state-BoLCGee4.js";
|
|
6
|
+
import { t as u } from "./runtime-B2fxeveq.js";
|
|
7
|
+
import { i as d } from "./resources-D2GDQS0p.js";
|
|
8
|
+
import { Component as f, createElement as p, useCallback as m, useEffect as h, useRef as g, useState as _ } from "react";
|
|
9
|
+
import { jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
10
|
+
// src/react/component-api.tsx
|
|
11
|
+
var b = Symbol("reactive-md.content-node");
|
|
12
|
+
function x(e) {
|
|
13
|
+
return e[b];
|
|
14
|
+
}
|
|
15
|
+
function S(e, t) {
|
|
16
|
+
return Object.defineProperty(e, b, {
|
|
17
|
+
value: t,
|
|
18
|
+
enumerable: !1,
|
|
19
|
+
configurable: !1,
|
|
20
|
+
writable: !1
|
|
21
|
+
}), Object.freeze(e);
|
|
22
|
+
}
|
|
23
|
+
var C = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;
|
|
24
|
+
function w(e) {
|
|
25
|
+
return e === null ? "" : typeof e == "string" ? e : typeof e == "number" ? Number.isFinite(e) ? String(e) : null : typeof e == "boolean" ? e ? "true" : "false" : null;
|
|
26
|
+
}
|
|
27
|
+
function T(e) {
|
|
28
|
+
if (!Number.isFinite(e)) return "—";
|
|
29
|
+
if (Object.is(e, -0)) return "0";
|
|
30
|
+
let t = Math.abs(e);
|
|
31
|
+
return t >= 0xe8d4a51000 || t > 0 && t < 1e-4 ? e.toExponential(3).replace(/(\.\d*?)0+e/, "$1e").replace(/\.e/, "e") : Number(e.toFixed(6)).toString();
|
|
32
|
+
}
|
|
33
|
+
function E(e) {
|
|
34
|
+
return Array.isArray(e) ? Object.freeze(e.slice()) : e === void 0 ? null : e;
|
|
35
|
+
}
|
|
36
|
+
function D(e) {
|
|
37
|
+
return Array.isArray(e) ? e.slice() : e;
|
|
38
|
+
}
|
|
39
|
+
function O(e, t, r, i) {
|
|
40
|
+
try {
|
|
41
|
+
return {
|
|
42
|
+
ok: !0,
|
|
43
|
+
value: n(e, t, r, i)
|
|
44
|
+
};
|
|
45
|
+
} catch (e) {
|
|
46
|
+
return {
|
|
47
|
+
ok: !1,
|
|
48
|
+
error: e
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
var ee = /* @__PURE__ */ new WeakMap(), k = /* @__PURE__ */ new WeakMap();
|
|
53
|
+
function te(e) {
|
|
54
|
+
k.delete(j(e));
|
|
55
|
+
}
|
|
56
|
+
var A = /* @__PURE__ */ new WeakMap(), ne = 4096, re = 512;
|
|
57
|
+
function j(e) {
|
|
58
|
+
let t = N.get(e);
|
|
59
|
+
return t || (t = Object.freeze({}), N.set(e, t)), t;
|
|
60
|
+
}
|
|
61
|
+
function ie(e, t, n) {
|
|
62
|
+
let { environment: r, node: i } = e, a = r.positionOf?.(i.range.start) ?? {
|
|
63
|
+
line: 1,
|
|
64
|
+
column: 1
|
|
65
|
+
}, o = n instanceof Error ? n.message : String(n);
|
|
66
|
+
return {
|
|
67
|
+
code: "local.component.prop",
|
|
68
|
+
message: `Component <${i.name ?? i.id}> prop "${t}" is invalid: ${o}`,
|
|
69
|
+
severity: "error",
|
|
70
|
+
range: {
|
|
71
|
+
start: i.range.start,
|
|
72
|
+
end: i.range.end
|
|
73
|
+
},
|
|
74
|
+
line: a.line,
|
|
75
|
+
column: a.column
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function ae(e, t, n) {
|
|
79
|
+
if (n.length === 0) return;
|
|
80
|
+
if (typeof window > "u") {
|
|
81
|
+
e.report(n);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
let r = A.get(t);
|
|
85
|
+
r || (r = {
|
|
86
|
+
diagnostics: [],
|
|
87
|
+
scheduled: !1,
|
|
88
|
+
report: e.report
|
|
89
|
+
}, A.set(t, r));
|
|
90
|
+
let i = r;
|
|
91
|
+
i.report = e.report;
|
|
92
|
+
for (let e of n) {
|
|
93
|
+
if (i.diagnostics.length >= re) break;
|
|
94
|
+
i.diagnostics.push(e);
|
|
95
|
+
}
|
|
96
|
+
if (i.scheduled) return;
|
|
97
|
+
i.scheduled = !0;
|
|
98
|
+
let a = () => {
|
|
99
|
+
i.scheduled = !1;
|
|
100
|
+
let e = i.diagnostics.splice(0);
|
|
101
|
+
e.length > 0 && i.report(e);
|
|
102
|
+
};
|
|
103
|
+
typeof queueMicrotask == "function" ? queueMicrotask(a) : setTimeout(a, 0);
|
|
104
|
+
}
|
|
105
|
+
function oe(e, t, n, r) {
|
|
106
|
+
if (!e) return {};
|
|
107
|
+
let i = t ?? {}, a = {}, o = r?.environment.mode === "static" && typeof window > "u", s = r !== void 0, c = r ? j(n) : null, l = null;
|
|
108
|
+
if (r && c && s) {
|
|
109
|
+
let e = o ? k : ee;
|
|
110
|
+
l = e.get(c) ?? null, l ? l.size > ne && l.clear() : (l = /* @__PURE__ */ new Map(), e.set(c, l));
|
|
111
|
+
}
|
|
112
|
+
let u = [];
|
|
113
|
+
for (let t of Object.keys(e.props)) {
|
|
114
|
+
let o = Object.hasOwn(i, t) && typeof i[t] == "string" ? i[t] : void 0, s = O(e, t, o, n);
|
|
115
|
+
if (s.ok) a[t] = s.value, r && l && l.delete(`${r.node.id}\u0000${t}`);
|
|
116
|
+
else if (a[t] = null, r) {
|
|
117
|
+
if (l) {
|
|
118
|
+
let e = `${r.node.id}\u0000${t}`, n = `${o ?? ""}\u0000${s.error instanceof Error ? s.error.message : String(s.error)}`;
|
|
119
|
+
if (l.get(e) === n) continue;
|
|
120
|
+
l.set(e, n);
|
|
121
|
+
}
|
|
122
|
+
u.push(ie(r, t, s.error));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return r && c && ae(r.environment, c, u), a;
|
|
126
|
+
}
|
|
127
|
+
function se(e) {
|
|
128
|
+
return e?.bindings ?? {};
|
|
129
|
+
}
|
|
130
|
+
function M(e, t, n, r) {
|
|
131
|
+
let i = r.get(e);
|
|
132
|
+
if (i) return i;
|
|
133
|
+
let a = e.type === "component" || e.type === "hostComponent", o = a ? t.definitionFor(e.name ?? "") : void 0, s = Object.freeze(a ? oe(o, e.attrs, t.runtime, {
|
|
134
|
+
environment: t,
|
|
135
|
+
node: e
|
|
136
|
+
}) : {}), c = (e.children ?? []).map((e) => M(e, t, n, r)), l = null;
|
|
137
|
+
if (a) try {
|
|
138
|
+
l = E(t.runtime.get(e));
|
|
139
|
+
} catch {
|
|
140
|
+
l = null;
|
|
141
|
+
}
|
|
142
|
+
else if (e.type === "interpolation") try {
|
|
143
|
+
l = E(t.runtime.evaluate(e.value ?? ""));
|
|
144
|
+
} catch {
|
|
145
|
+
l = null;
|
|
146
|
+
}
|
|
147
|
+
let u = S({
|
|
148
|
+
id: e.id,
|
|
149
|
+
kind: a ? "component" : e.type,
|
|
150
|
+
name: a ? e.name ?? "" : "",
|
|
151
|
+
...a && o ? { form: o.form } : {},
|
|
152
|
+
props: s,
|
|
153
|
+
attrs: Object.freeze({ ...e.attrs ?? {} }),
|
|
154
|
+
value: l,
|
|
155
|
+
text: typeof e.value == "string" ? e.value : "",
|
|
156
|
+
...e.lang === void 0 ? e.type === "math" || e.type === "inlineMath" ? { format: e.type } : {} : { format: e.lang },
|
|
157
|
+
visible: n,
|
|
158
|
+
children: Object.freeze(c),
|
|
159
|
+
range: Object.freeze({
|
|
160
|
+
start: e.range.start,
|
|
161
|
+
end: e.range.end
|
|
162
|
+
})
|
|
163
|
+
}, e);
|
|
164
|
+
return r.set(e, u), u;
|
|
165
|
+
}
|
|
166
|
+
var N = /* @__PURE__ */ new WeakMap();
|
|
167
|
+
function ce(e, t, n) {
|
|
168
|
+
let r = t === "static", i = N.get(e);
|
|
169
|
+
i || (i = Object.freeze({}), N.set(e, i));
|
|
170
|
+
let a = x, o = (e) => (e.length > 0 && n(e), e), s = (e, t) => {
|
|
171
|
+
let n = {
|
|
172
|
+
start: e.range.start,
|
|
173
|
+
end: e.range.end
|
|
174
|
+
};
|
|
175
|
+
return [{
|
|
176
|
+
code: "local.extension.write",
|
|
177
|
+
message: `Component <${e.name || e.id}> write failed: ${t instanceof Error ? t.message : String(t)}`,
|
|
178
|
+
severity: "error",
|
|
179
|
+
range: n,
|
|
180
|
+
line: 1,
|
|
181
|
+
column: 1
|
|
182
|
+
}];
|
|
183
|
+
};
|
|
184
|
+
return Object.freeze({
|
|
185
|
+
identity: i,
|
|
186
|
+
get(t, n) {
|
|
187
|
+
return E(e.get(a(t), n === "value" ? void 0 : n));
|
|
188
|
+
},
|
|
189
|
+
set(t, n, i) {
|
|
190
|
+
if (r) return s(t, /* @__PURE__ */ Error("Runtime is read-only in static mode."));
|
|
191
|
+
try {
|
|
192
|
+
return o(e.set(a(t), D(n), i === "value" ? void 0 : i));
|
|
193
|
+
} catch (e) {
|
|
194
|
+
return s(t, e);
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
setMany(t, n) {
|
|
198
|
+
if (r) return s(t, /* @__PURE__ */ Error("Runtime is read-only in static mode."));
|
|
199
|
+
try {
|
|
200
|
+
let r = {};
|
|
201
|
+
for (let [e, t] of Object.entries(n)) r[e] = D(t);
|
|
202
|
+
return o(e.setMany(a(t), r));
|
|
203
|
+
} catch (e) {
|
|
204
|
+
return s(t, e);
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
reset(t) {
|
|
208
|
+
if (!r) try {
|
|
209
|
+
e.reset(a(t));
|
|
210
|
+
} catch {}
|
|
211
|
+
},
|
|
212
|
+
resetToken(t) {
|
|
213
|
+
try {
|
|
214
|
+
return e.resetToken(a(t));
|
|
215
|
+
} catch {
|
|
216
|
+
return 0;
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
evaluate(t) {
|
|
220
|
+
return E(e.evaluate(t));
|
|
221
|
+
},
|
|
222
|
+
snapshot() {
|
|
223
|
+
try {
|
|
224
|
+
let t = e.snapshot(), n = {};
|
|
225
|
+
for (let [e, r] of Object.entries(t.state)) n[e] = E(r);
|
|
226
|
+
return {
|
|
227
|
+
revision: t.revision,
|
|
228
|
+
state: Object.freeze(n)
|
|
229
|
+
};
|
|
230
|
+
} catch {
|
|
231
|
+
return {
|
|
232
|
+
revision: 0,
|
|
233
|
+
state: {}
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
readSubmissionFields(t) {
|
|
238
|
+
let n = {
|
|
239
|
+
ok: !1,
|
|
240
|
+
field: t[0] ?? "",
|
|
241
|
+
reason: "unavailable"
|
|
242
|
+
};
|
|
243
|
+
if (r) return n;
|
|
244
|
+
try {
|
|
245
|
+
return e.readSubmissionFields?.(t) ?? n;
|
|
246
|
+
} catch {
|
|
247
|
+
return n;
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
registerSubmissionField(t, n) {
|
|
251
|
+
return r ? () => {} : e.registerSubmissionField?.(a(t), n) ?? (() => {});
|
|
252
|
+
},
|
|
253
|
+
validate() {
|
|
254
|
+
try {
|
|
255
|
+
return e.validate();
|
|
256
|
+
} catch {
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
text(t) {
|
|
261
|
+
try {
|
|
262
|
+
return e.text(t);
|
|
263
|
+
} catch {
|
|
264
|
+
return "";
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function le(e, t, n, r) {
|
|
270
|
+
return Object.freeze({
|
|
271
|
+
get: () => {
|
|
272
|
+
try {
|
|
273
|
+
return e.get(t, n);
|
|
274
|
+
} catch {
|
|
275
|
+
return null;
|
|
276
|
+
}
|
|
277
|
+
},
|
|
278
|
+
set: (i) => {
|
|
279
|
+
if (r) return {
|
|
280
|
+
ok: !1,
|
|
281
|
+
diagnostics: []
|
|
282
|
+
};
|
|
283
|
+
let a = e.set(t, i, n);
|
|
284
|
+
return {
|
|
285
|
+
ok: a.length === 0,
|
|
286
|
+
diagnostics: a
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function ue(e, t) {
|
|
292
|
+
let n = [], r = e.children, i = t.definitionFor(e.name), a = i?.rules?.find((e) => e.kind === "options-body"), o = a?.kind === "options-body" ? a.child : i?.structure?.child ?? "option", s = a?.kind === "options-body" ? a.valueAttribute : i?.structure?.valueAttribute ?? "value", c = 0;
|
|
293
|
+
for (let i of r) {
|
|
294
|
+
if (i.kind !== "component" || i.name !== o) continue;
|
|
295
|
+
let r = x(i), a = i.attrs[s] ?? `option-${c + 1}`;
|
|
296
|
+
c += 1;
|
|
297
|
+
let l = t.renderToText(r.children) || i.attrs[s] || "";
|
|
298
|
+
n.push(Object.freeze({
|
|
299
|
+
value: a,
|
|
300
|
+
content: i,
|
|
301
|
+
label: l,
|
|
302
|
+
render: () => t.renderInline(r.children, e.visible)
|
|
303
|
+
}));
|
|
304
|
+
}
|
|
305
|
+
return n;
|
|
306
|
+
}
|
|
307
|
+
function P(e, t) {
|
|
308
|
+
let n = e.children ?? [], r = n.filter((e) => !(e.type === "text" && !(e.value ?? "").trim())), i, a = "empty", o = "", s = null, c = null;
|
|
309
|
+
if (r.length === 1 && r[0].type === "interpolation") try {
|
|
310
|
+
i = t.runtime.evaluate(r[0].value ?? "");
|
|
311
|
+
let e = w(i);
|
|
312
|
+
i === null ? (a = "null", o = "") : typeof i == "string" ? (a = "string", o = i) : typeof i == "number" ? Number.isFinite(i) ? (a = "number", o = T(i), s = i) : (a = "error", o = t.locale === "zh" ? "无法计算" : "Cannot compute", c = t.locale === "zh" ? "结果不是有限数字" : "Result is not a finite number") : typeof i == "boolean" ? (a = "boolean", o = i ? "true" : "false") : (a = "array", o = e ?? "", c = t.locale === "zh" ? "数组需要先用 len 等函数转换" : "Arrays must first be converted with a function such as len");
|
|
313
|
+
} catch (e) {
|
|
314
|
+
a = "error", o = t.locale === "zh" ? "无法计算" : "Cannot compute", c = e instanceof Error ? e.message : String(e);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
let e = "", l = null, u = (n) => {
|
|
318
|
+
for (let r of n ?? []) if (r.type === "text" || r.type === "inlineCode" || r.type === "code") e += r.value ?? "";
|
|
319
|
+
else if (r.type === "interpolation") try {
|
|
320
|
+
let n = w(t.runtime.evaluate(r.value ?? ""));
|
|
321
|
+
n === null ? l ??= t.locale === "zh" ? "数组需要先用 len 等函数转换" : "Arrays must first be converted with a function such as len" : e += n;
|
|
322
|
+
} catch (n) {
|
|
323
|
+
l ??= n instanceof Error ? n.message : String(n), e += t.locale === "zh" ? "无法计算" : "Cannot compute";
|
|
324
|
+
}
|
|
325
|
+
else r.type === "inlineMath" || r.type === "math" ? e += r.value ?? "" : r.type === "image" ? e += r.alt ?? "" : r.children && r.children.length > 0 ? u(r.children) : r.value && (e += r.value);
|
|
326
|
+
};
|
|
327
|
+
u(n);
|
|
328
|
+
let d = r.length > 0 && r.every((e) => e.type === "text"), f = e.trim();
|
|
329
|
+
if (d && C.test(f)) {
|
|
330
|
+
let t = Number(f);
|
|
331
|
+
Number.isFinite(t) && (a = "number", o = e, s = t, i = t);
|
|
332
|
+
}
|
|
333
|
+
a === "empty" && (l ? (a = "error", o = t.locale === "zh" ? "无法计算" : "Cannot compute", c = l) : (a = f === "" ? "empty" : "string", o = e, i = e));
|
|
334
|
+
}
|
|
335
|
+
return Object.freeze({
|
|
336
|
+
text: o,
|
|
337
|
+
value: i,
|
|
338
|
+
kind: a,
|
|
339
|
+
numeric: s,
|
|
340
|
+
error: c,
|
|
341
|
+
render: () => t.renderInline(n, !0)
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
function de(e, t) {
|
|
345
|
+
let n = e.children.find((e) => e.kind === "table");
|
|
346
|
+
if (!n) return null;
|
|
347
|
+
let r = (x(n).children ?? []).filter((e) => e.type === "tableRow");
|
|
348
|
+
if (r.length === 0) return null;
|
|
349
|
+
let i = (r[0].children ?? []).map((e) => P(e, t));
|
|
350
|
+
return Object.freeze({
|
|
351
|
+
header: Object.freeze(i),
|
|
352
|
+
headerText: Object.freeze(i.map((e) => e.error ? t.locale === "zh" ? "无法计算" : "Cannot compute" : e.text)),
|
|
353
|
+
rows: Object.freeze(r.slice(1).map((e, n) => Object.freeze({
|
|
354
|
+
index: n,
|
|
355
|
+
cells: Object.freeze((e.children ?? []).map((e) => P(e, t)))
|
|
356
|
+
})))
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
function fe(e, t) {
|
|
360
|
+
let n = e["state-key"];
|
|
361
|
+
return s(typeof n == "string" ? n : t["state-key"]);
|
|
362
|
+
}
|
|
363
|
+
function pe(e) {
|
|
364
|
+
try {
|
|
365
|
+
return e.document.source;
|
|
366
|
+
} catch {
|
|
367
|
+
return "";
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
var F = /* @__PURE__ */ new WeakMap();
|
|
371
|
+
function I(e) {
|
|
372
|
+
if (e.services !== void 0) return e.services;
|
|
373
|
+
let t = F.get(e);
|
|
374
|
+
return t === void 0 && (t = u({ sourceDigest: a(pe(e)) }), F.set(e, t)), t;
|
|
375
|
+
}
|
|
376
|
+
function L(e, t) {
|
|
377
|
+
let n = t.definitionFor(e.name ?? ""), r = /* @__PURE__ */ new Map(), i = M(e, t, t.visible, r), a = ce(t.runtime, t.mode, t.report), s = t.services ?? I(t.runtime), u = n?.id ?? e.name ?? e.type, d = fe(i.props, i.attrs), f = null, p = () => (f === null && (f = s.state.handle({
|
|
378
|
+
nodeId: e.id,
|
|
379
|
+
component: u,
|
|
380
|
+
componentVersion: n?.version ?? "0.0.0",
|
|
381
|
+
stateKey: d,
|
|
382
|
+
stateVersion: 0
|
|
383
|
+
})), f), m = typeof i.props.seed == "number" && Number.isFinite(i.props.seed) ? i.props.seed : void 0, h = o({
|
|
384
|
+
explicitSeed: m,
|
|
385
|
+
documentSeed: s.randomSeed,
|
|
386
|
+
componentId: u,
|
|
387
|
+
nodeId: e.id,
|
|
388
|
+
stateKey: d
|
|
389
|
+
}), g = Object.freeze({
|
|
390
|
+
network: t.mode === "static" ? c : t.network ?? t.runtime.network ?? c,
|
|
391
|
+
random: Object.freeze({
|
|
392
|
+
seed: h,
|
|
393
|
+
derive: (e) => l(h, e)
|
|
394
|
+
}),
|
|
395
|
+
clock: s.clock,
|
|
396
|
+
scheduler: s.scheduler,
|
|
397
|
+
get state() {
|
|
398
|
+
return p();
|
|
399
|
+
}
|
|
400
|
+
}), _ = t.mode === "static", v = se(n), y = {};
|
|
401
|
+
for (let e of Object.keys(v)) y[e] = le(a, i, e, _);
|
|
402
|
+
let b = y.value ?? Object.freeze({
|
|
403
|
+
get: () => null,
|
|
404
|
+
set: () => ({
|
|
405
|
+
ok: !1,
|
|
406
|
+
diagnostics: []
|
|
407
|
+
})
|
|
408
|
+
}), S = Object.freeze({
|
|
409
|
+
render: () => t.renderChildren(e.children, t.visible),
|
|
410
|
+
inline: () => t.renderInline(e.children, t.visible),
|
|
411
|
+
text: () => t.renderToText(e.children),
|
|
412
|
+
items: () => i.children,
|
|
413
|
+
renderItems: (e, n) => t.renderChildren(e.map((e) => x(e)), n ?? t.visible),
|
|
414
|
+
renderInlineItems: (e, n) => t.renderInline(e.map((e) => x(e)), n ?? t.visible),
|
|
415
|
+
textOf: (e) => t.renderToText(e.map((e) => x(e))),
|
|
416
|
+
options: () => ue(i, t),
|
|
417
|
+
table: () => de(i, t),
|
|
418
|
+
math: () => i.children.filter((e) => e.kind === "math" || e.kind === "inlineMath")
|
|
419
|
+
}), C = Object.freeze({
|
|
420
|
+
value: b,
|
|
421
|
+
slots: Object.freeze(y),
|
|
422
|
+
isReadOnly: _,
|
|
423
|
+
get(e = "value") {
|
|
424
|
+
let t = y[e];
|
|
425
|
+
return t ? t.get() : null;
|
|
426
|
+
},
|
|
427
|
+
set(e, t) {
|
|
428
|
+
let n = y[e];
|
|
429
|
+
return n ? n.set(t) : {
|
|
430
|
+
ok: !1,
|
|
431
|
+
diagnostics: [{
|
|
432
|
+
code: "local.extension.binding",
|
|
433
|
+
message: `Component <${i.name || i.id}> has no binding slot "${e}".`,
|
|
434
|
+
severity: "error",
|
|
435
|
+
range: i.range,
|
|
436
|
+
line: 1,
|
|
437
|
+
column: 1
|
|
438
|
+
}]
|
|
439
|
+
};
|
|
440
|
+
},
|
|
441
|
+
setMany(e) {
|
|
442
|
+
if (_) return {
|
|
443
|
+
ok: !1,
|
|
444
|
+
diagnostics: []
|
|
445
|
+
};
|
|
446
|
+
let t = a.setMany(i, e);
|
|
447
|
+
return {
|
|
448
|
+
ok: t.length === 0,
|
|
449
|
+
diagnostics: t
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
}), w = Object.freeze({
|
|
453
|
+
fieldFor: (e) => t.validationFieldFor(x(e)),
|
|
454
|
+
hintFor: (e) => t.validationHintFor(x(e))
|
|
455
|
+
}), E = Object.freeze({
|
|
456
|
+
targetId: (e) => t.targetId(e),
|
|
457
|
+
anchorId: () => t.anchorId(e),
|
|
458
|
+
allowed: (e) => t.jumpAllowed(e),
|
|
459
|
+
jump: (e) => {
|
|
460
|
+
let n = t.targetId(e);
|
|
461
|
+
return n === void 0 ? "missing" : t.jumpTo(n);
|
|
462
|
+
}
|
|
463
|
+
}), D = Object.freeze({
|
|
464
|
+
resolve(e, n) {
|
|
465
|
+
if (!e) return null;
|
|
466
|
+
let r = e.trim();
|
|
467
|
+
if (!r) return null;
|
|
468
|
+
let i = r.replace(/[\u0000- ]+/g, ""), a = /^([a-z][a-z0-9+.-]*):/i.exec(i);
|
|
469
|
+
if (a) {
|
|
470
|
+
let e = a[1].toLowerCase();
|
|
471
|
+
if (!(n === "image" ? e === "http" || e === "https" : e === "http" || e === "https" || e === "mailto" || e === "tel")) return null;
|
|
472
|
+
}
|
|
473
|
+
if (!t.urlPolicy) return n === "image" ? null : r;
|
|
474
|
+
try {
|
|
475
|
+
return t.urlPolicy(r, n) ? r : null;
|
|
476
|
+
} catch {
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
image(e) {
|
|
481
|
+
let n = D.resolve(e, "image");
|
|
482
|
+
if (!n) return null;
|
|
483
|
+
if (!t.imageResolver) return n;
|
|
484
|
+
try {
|
|
485
|
+
let e = t.imageResolver(n);
|
|
486
|
+
return typeof e == "string" && e.trim() !== "" ? e : null;
|
|
487
|
+
} catch {
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
}), O = Object.freeze({
|
|
492
|
+
locale: t.locale,
|
|
493
|
+
t: (e, n) => t.locale === "zh" ? n : e,
|
|
494
|
+
formatNumber: T
|
|
495
|
+
});
|
|
496
|
+
return Object.freeze({
|
|
497
|
+
props: i.props,
|
|
498
|
+
authorStyle: t.authorStyle,
|
|
499
|
+
authorStyleText: t.authorStyleText,
|
|
500
|
+
dispatchAuthorAction: t.dispatchAuthorAction,
|
|
501
|
+
content: i,
|
|
502
|
+
services: g,
|
|
503
|
+
bindings: C,
|
|
504
|
+
children: S,
|
|
505
|
+
runtime: a,
|
|
506
|
+
instance: Object.freeze({
|
|
507
|
+
id: e.id,
|
|
508
|
+
componentId: n?.id ?? e.name ?? "",
|
|
509
|
+
range: Object.freeze({
|
|
510
|
+
start: e.range.start,
|
|
511
|
+
end: e.range.end
|
|
512
|
+
})
|
|
513
|
+
}),
|
|
514
|
+
mode: t.mode,
|
|
515
|
+
visible: t.visible,
|
|
516
|
+
disabled: t.disabled,
|
|
517
|
+
disabledInvalid: t.disabledInvalid,
|
|
518
|
+
resetToken: t.resetToken,
|
|
519
|
+
validation: w,
|
|
520
|
+
source: Object.freeze({ attributes: (n) => t.sourceAttributes(n ? x(n) : e, e.name) }),
|
|
521
|
+
navigation: E,
|
|
522
|
+
url: D,
|
|
523
|
+
locale: O,
|
|
524
|
+
report: t.report
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
var R = [
|
|
528
|
+
"interactive",
|
|
529
|
+
"static",
|
|
530
|
+
"ssr",
|
|
531
|
+
"offline"
|
|
532
|
+
];
|
|
533
|
+
function z(e) {
|
|
534
|
+
let t = e.capabilities;
|
|
535
|
+
if (t === void 0) return;
|
|
536
|
+
if (typeof t != "object" || !t || Array.isArray(t)) throw TypeError("Component capabilities must be an object.");
|
|
537
|
+
let n = {};
|
|
538
|
+
for (let e of R) {
|
|
539
|
+
let r = t[e];
|
|
540
|
+
if (r !== void 0) {
|
|
541
|
+
if (typeof r != "boolean") throw TypeError(`Component capability "${e}" must be a boolean.`);
|
|
542
|
+
n[e] = r;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
return n;
|
|
546
|
+
}
|
|
547
|
+
function B(e, t, n) {
|
|
548
|
+
if (t) {
|
|
549
|
+
if (typeof n.render != "function") throw TypeError("defineReactComponent requires a render function.");
|
|
550
|
+
if (n.renderStatic !== void 0 && typeof n.renderStatic != "function") throw TypeError("defineReactComponent renderStatic must be a function.");
|
|
551
|
+
if (t.static === !1 && t.ssr === !0) throw TypeError(`Component "${e.id ?? ""}" declares SSR without static rendering.`);
|
|
552
|
+
if (t.static === !1 && t.offline === !0) throw TypeError(`Component "${e.id ?? ""}" declares offline output without a static implementation.`);
|
|
553
|
+
if (t.interactive === !1 && t.offline === !0 && t.static !== !0) throw TypeError(`Component "${e.id ?? ""}" declares offline output without any renderable implementation.`);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
function me(e) {
|
|
557
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("defineReactComponent requires a component definition object.");
|
|
558
|
+
return e;
|
|
559
|
+
}
|
|
560
|
+
function he(t, n) {
|
|
561
|
+
let r = me(t);
|
|
562
|
+
if (!n || typeof n != "object") throw TypeError("defineReactComponent requires an implementation object.");
|
|
563
|
+
B(r, z(r), n);
|
|
564
|
+
let i;
|
|
565
|
+
try {
|
|
566
|
+
i = e(r);
|
|
567
|
+
} catch (e) {
|
|
568
|
+
throw TypeError(`Cannot bind a React implementation to component "${r.id}": ${e instanceof Error ? e.message : String(e)}`);
|
|
569
|
+
}
|
|
570
|
+
return Object.freeze({
|
|
571
|
+
definition: r,
|
|
572
|
+
digest: i,
|
|
573
|
+
render: n.render,
|
|
574
|
+
...n.renderStatic === void 0 ? {} : { renderStatic: n.renderStatic }
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
// src/react/component-utils.tsx
|
|
578
|
+
function ge(e) {
|
|
579
|
+
return {
|
|
580
|
+
context: e,
|
|
581
|
+
content: e.content,
|
|
582
|
+
props: e.props,
|
|
583
|
+
runtime: e.runtime,
|
|
584
|
+
bindings: e.bindings,
|
|
585
|
+
children: e.children,
|
|
586
|
+
mode: e.mode,
|
|
587
|
+
visible: e.visible,
|
|
588
|
+
disabled: e.disabled,
|
|
589
|
+
disabledInvalid: e.disabledInvalid,
|
|
590
|
+
resetToken: e.resetToken,
|
|
591
|
+
t: e.locale.t,
|
|
592
|
+
locale: e.locale.locale,
|
|
593
|
+
validation: e.validation,
|
|
594
|
+
source: e.source,
|
|
595
|
+
navigation: e.navigation,
|
|
596
|
+
url: e.url,
|
|
597
|
+
report: e.report,
|
|
598
|
+
render: (t, n) => e.children.renderItems(t ?? e.children.items(), n),
|
|
599
|
+
renderInline: (t, n) => e.children.renderInlineItems(t ?? e.children.items(), n)
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
function _e(e) {
|
|
603
|
+
let [n, r] = _(null), { locale: i, report: a, bindings: o } = e, s = m((e) => e.map((e) => t(e, i.locale)).join("; "), [i.locale]);
|
|
604
|
+
return {
|
|
605
|
+
write: m((e, t = "value") => {
|
|
606
|
+
let n = o.set(t, e);
|
|
607
|
+
return n.ok ? (r(null), !0) : (n.diagnostics.length > 0 ? (r(s(n.diagnostics)), a(n.diagnostics)) : r(i.t("Cannot write this value", "无法写入此值")), !1);
|
|
608
|
+
}, [
|
|
609
|
+
o,
|
|
610
|
+
i,
|
|
611
|
+
s,
|
|
612
|
+
a
|
|
613
|
+
]),
|
|
614
|
+
writeMany: m((e) => {
|
|
615
|
+
let t = o.setMany(e);
|
|
616
|
+
return t.ok ? (r(null), !0) : (t.diagnostics.length > 0 ? (r(s(t.diagnostics)), a(t.diagnostics)) : r(i.t("Cannot write this value", "无法写入此值")), !1);
|
|
617
|
+
}, [
|
|
618
|
+
o,
|
|
619
|
+
i,
|
|
620
|
+
s,
|
|
621
|
+
a
|
|
622
|
+
]),
|
|
623
|
+
error: n,
|
|
624
|
+
setError: r
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
function ve(e) {
|
|
628
|
+
return {
|
|
629
|
+
disabled: e.disabled,
|
|
630
|
+
invalid: e.disabledInvalid
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
function ye(e, t) {
|
|
634
|
+
return e.validation.fieldFor(t ?? e.content);
|
|
635
|
+
}
|
|
636
|
+
function be(e, t) {
|
|
637
|
+
return e.validation.hintFor(t ?? e.content);
|
|
638
|
+
}
|
|
639
|
+
function xe(e, t) {
|
|
640
|
+
return e.source.attributes(t);
|
|
641
|
+
}
|
|
642
|
+
function Se(e, t) {
|
|
643
|
+
let n = e.resetToken, r = g(n), i = g(t);
|
|
644
|
+
i.current = t, h(() => {
|
|
645
|
+
r.current !== n && (r.current = n, i.current());
|
|
646
|
+
}, [n]);
|
|
647
|
+
}
|
|
648
|
+
function Ce(e, t) {
|
|
649
|
+
return e.attrs[t];
|
|
650
|
+
}
|
|
651
|
+
function we(e, t, n = "") {
|
|
652
|
+
let r = e.props[t];
|
|
653
|
+
return typeof r == "string" ? r : typeof r == "number" ? Number.isFinite(r) ? String(r) : n : typeof r == "boolean" ? r ? "true" : "false" : e.content.attrs[t] === void 0 ? n : e.locale.t("Cannot compute", "无法计算");
|
|
654
|
+
}
|
|
655
|
+
function V(e, t, n) {
|
|
656
|
+
let r = e.props[t];
|
|
657
|
+
return typeof r == "number" && Number.isFinite(r) ? r : n;
|
|
658
|
+
}
|
|
659
|
+
function Te(e, t, n, r = "") {
|
|
660
|
+
let i = t.props[n];
|
|
661
|
+
return typeof i == "string" ? i : typeof i == "number" ? Number.isFinite(i) ? String(i) : r : typeof i == "boolean" ? i ? "true" : "false" : t.attrs[n] === void 0 ? r : e.locale.t("Cannot compute", "无法计算");
|
|
662
|
+
}
|
|
663
|
+
function Ee(e, t, n, r = !1) {
|
|
664
|
+
let i = t.props[n];
|
|
665
|
+
return typeof i == "boolean" ? i : r;
|
|
666
|
+
}
|
|
667
|
+
function De(e, t) {
|
|
668
|
+
if (e.content.attrs[t] === void 0) return {
|
|
669
|
+
present: !1,
|
|
670
|
+
error: !1
|
|
671
|
+
};
|
|
672
|
+
let n = e.props[t];
|
|
673
|
+
return typeof n == "number" && Number.isFinite(n) ? {
|
|
674
|
+
present: !0,
|
|
675
|
+
error: !1,
|
|
676
|
+
value: n
|
|
677
|
+
} : {
|
|
678
|
+
present: !0,
|
|
679
|
+
error: !0
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
function Oe(e, t) {
|
|
683
|
+
if (e.content.attrs[t] === void 0) return {
|
|
684
|
+
present: !1,
|
|
685
|
+
error: !1
|
|
686
|
+
};
|
|
687
|
+
let n = e.props[t];
|
|
688
|
+
return typeof n == "string" ? {
|
|
689
|
+
present: !0,
|
|
690
|
+
error: !1,
|
|
691
|
+
value: n
|
|
692
|
+
} : {
|
|
693
|
+
present: !0,
|
|
694
|
+
error: !0
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function H(e, t, n) {
|
|
698
|
+
if (e.content.attrs[t] === void 0) return {
|
|
699
|
+
ok: !0,
|
|
700
|
+
value: n
|
|
701
|
+
};
|
|
702
|
+
let r = e.props[t];
|
|
703
|
+
return typeof r == "boolean" ? {
|
|
704
|
+
ok: !0,
|
|
705
|
+
value: r
|
|
706
|
+
} : { ok: !1 };
|
|
707
|
+
}
|
|
708
|
+
function ke(e, t, n = !1) {
|
|
709
|
+
let r = H(e, t, n);
|
|
710
|
+
return r.ok ? r.value : n;
|
|
711
|
+
}
|
|
712
|
+
function Ae(e, t, n, r) {
|
|
713
|
+
if (e.content.attrs[t] === void 0) return {
|
|
714
|
+
tone: r,
|
|
715
|
+
error: !1
|
|
716
|
+
};
|
|
717
|
+
let i = e.props[t];
|
|
718
|
+
return typeof i == "string" && n.includes(i) ? {
|
|
719
|
+
tone: i,
|
|
720
|
+
error: !1
|
|
721
|
+
} : {
|
|
722
|
+
tone: r,
|
|
723
|
+
error: /\{\{/.test(e.content.attrs[t] ?? "")
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
function je(e) {
|
|
727
|
+
let t = e.attrs.color;
|
|
728
|
+
if (t === void 0) return;
|
|
729
|
+
let n = t.trim();
|
|
730
|
+
return n !== "" && r(n) ? n : void 0;
|
|
731
|
+
}
|
|
732
|
+
function Me(e) {
|
|
733
|
+
if (e) return {
|
|
734
|
+
"--local-accent": e,
|
|
735
|
+
"--local-accent-soft": `color-mix(in srgb, ${e} 14%, var(--surface))`,
|
|
736
|
+
"--local-accent-strong": e
|
|
737
|
+
};
|
|
738
|
+
}
|
|
739
|
+
function U(e) {
|
|
740
|
+
return e === null ? "" : typeof e == "string" ? e : typeof e == "number" ? Number.isFinite(e) ? String(e) : null : typeof e == "boolean" ? e ? "true" : "false" : null;
|
|
741
|
+
}
|
|
742
|
+
function Ne(e) {
|
|
743
|
+
return U(e) ?? "";
|
|
744
|
+
}
|
|
745
|
+
function Pe(e) {
|
|
746
|
+
try {
|
|
747
|
+
return e.runtime.get(e.content);
|
|
748
|
+
} catch {
|
|
749
|
+
return null;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function Fe(e, t, n) {
|
|
753
|
+
try {
|
|
754
|
+
let r = e.runtime.get(e.content, t);
|
|
755
|
+
return typeof r == "number" && Number.isFinite(r) ? r : n;
|
|
756
|
+
} catch {
|
|
757
|
+
return n;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
function Ie(e, t, n) {
|
|
761
|
+
return Math.min(n, Math.max(t, e));
|
|
762
|
+
}
|
|
763
|
+
function Le(e, t, n, r) {
|
|
764
|
+
let i = Number.isFinite(r) && r > 0 ? r : 1, a = Math.max(0, Math.floor((n - t) / i + 1e-9)), o = t + Math.max(0, Math.min(a, Math.round((e - t) / i))) * i;
|
|
765
|
+
return Number(o.toPrecision(15));
|
|
766
|
+
}
|
|
767
|
+
function Re(e, t, n, r, i, a = 1) {
|
|
768
|
+
let o = V(e, t, r), s = V(e, n, i);
|
|
769
|
+
o > s && ([o, s] = [s, o]);
|
|
770
|
+
let c = V(e, "step", a);
|
|
771
|
+
return {
|
|
772
|
+
min: o,
|
|
773
|
+
max: s,
|
|
774
|
+
step: Number.isFinite(c) && c > 0 ? c : 1
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
function ze(e) {
|
|
778
|
+
return e.trim() === "" ? "—" : e;
|
|
779
|
+
}
|
|
780
|
+
var W = (e) => e.startsWith("--") ? e : e.replace(/^ms-?/, "-ms").replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
781
|
+
function Be(e, t, n) {
|
|
782
|
+
let r = e.ownerDocument.createElement("span").style;
|
|
783
|
+
for (let [e, n] of Object.entries(t ?? {})) {
|
|
784
|
+
if (n == null) continue;
|
|
785
|
+
let t = W(e);
|
|
786
|
+
r.setProperty(t, String(n)), typeof n == "number" && !t.startsWith("--") && !r.getPropertyValue(t) && r.setProperty(t, `${n}px`);
|
|
787
|
+
}
|
|
788
|
+
let i = r.cssText;
|
|
789
|
+
return e.style.cssText = i + n, () => {
|
|
790
|
+
e.style.cssText = i;
|
|
791
|
+
};
|
|
792
|
+
}
|
|
793
|
+
function Ve(e) {
|
|
794
|
+
let t = e.authorStyle, n = e.authorStyleText, r = m((e) => {
|
|
795
|
+
if (!e || !t) return;
|
|
796
|
+
let n = Object.entries(t).map(([e, t]) => `${W(e)}:${t};`).join("");
|
|
797
|
+
e.style.cssText += n;
|
|
798
|
+
}, [t]);
|
|
799
|
+
return (e) => {
|
|
800
|
+
if (n) return {
|
|
801
|
+
style: {
|
|
802
|
+
...e,
|
|
803
|
+
"--rmd-author-inline": `initial;${n}`
|
|
804
|
+
},
|
|
805
|
+
ref: (t) => t ? Be(t, e, n) : void 0
|
|
806
|
+
};
|
|
807
|
+
if (!t) return {
|
|
808
|
+
style: e,
|
|
809
|
+
ref: void 0
|
|
810
|
+
};
|
|
811
|
+
let i = { ...e };
|
|
812
|
+
for (let [e, n] of Object.entries(t)) delete i[e], i[e] = n;
|
|
813
|
+
return {
|
|
814
|
+
style: i,
|
|
815
|
+
ref: r
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
}
|
|
819
|
+
function He({ label: e, value: t, hint: n, className: r = "", multiline: i = !1, authorRoot: a }) {
|
|
820
|
+
return /* @__PURE__ */ y("div", {
|
|
821
|
+
className: `md-control local-static-control ${r}`.trim(),
|
|
822
|
+
...a,
|
|
823
|
+
children: [
|
|
824
|
+
/* @__PURE__ */ v("span", {
|
|
825
|
+
className: "md-label",
|
|
826
|
+
children: e
|
|
827
|
+
}),
|
|
828
|
+
/* @__PURE__ */ v("span", {
|
|
829
|
+
className: `local-static-value${i ? " local-static-multiline" : ""}`,
|
|
830
|
+
"data-local-static-value": "",
|
|
831
|
+
children: t
|
|
832
|
+
}),
|
|
833
|
+
n ? /* @__PURE__ */ v("span", {
|
|
834
|
+
className: "md-hint",
|
|
835
|
+
children: n
|
|
836
|
+
}) : null
|
|
837
|
+
]
|
|
838
|
+
});
|
|
839
|
+
}
|
|
840
|
+
function Ue({ value: e, block: t = !1 }) {
|
|
841
|
+
return t ? /* @__PURE__ */ v("div", {
|
|
842
|
+
className: "local-print-value local-print-block",
|
|
843
|
+
"aria-hidden": "true",
|
|
844
|
+
"data-local-print-value": "",
|
|
845
|
+
children: e
|
|
846
|
+
}) : /* @__PURE__ */ v("span", {
|
|
847
|
+
className: "local-print-value",
|
|
848
|
+
"aria-hidden": "true",
|
|
849
|
+
"data-local-print-value": "",
|
|
850
|
+
children: e
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
function We({ message: e, id: t }) {
|
|
854
|
+
return e ? /* @__PURE__ */ v("span", {
|
|
855
|
+
id: t,
|
|
856
|
+
className: "field-error",
|
|
857
|
+
role: "alert",
|
|
858
|
+
children: e
|
|
859
|
+
}) : null;
|
|
860
|
+
}
|
|
861
|
+
function Ge({ message: e }) {
|
|
862
|
+
return /* @__PURE__ */ v("span", {
|
|
863
|
+
className: "local-error",
|
|
864
|
+
role: "alert",
|
|
865
|
+
children: e ?? "Cannot compute"
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
function Ke({ message: e }) {
|
|
869
|
+
return /* @__PURE__ */ v("span", {
|
|
870
|
+
className: "local-error local-tone-error",
|
|
871
|
+
role: "status",
|
|
872
|
+
children: e
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
function qe(e, t) {
|
|
876
|
+
let n = Math.max(0, Math.floor(e)), r = Math.floor(n / 60), i = n % 60;
|
|
877
|
+
return r === 0 ? t(`${i} seconds`, `${i} 秒`) : `${r}:${String(i).padStart(2, "0")}`;
|
|
878
|
+
}
|
|
879
|
+
function Je(e) {
|
|
880
|
+
return T(e);
|
|
881
|
+
}
|
|
882
|
+
function G(e, t, n = 0) {
|
|
883
|
+
if (!t || n > 64) return "";
|
|
884
|
+
let r = "";
|
|
885
|
+
for (let i of t) switch (i.kind) {
|
|
886
|
+
case "text":
|
|
887
|
+
case "inlineCode":
|
|
888
|
+
case "fallback":
|
|
889
|
+
r += i.text;
|
|
890
|
+
break;
|
|
891
|
+
case "interpolation":
|
|
892
|
+
try {
|
|
893
|
+
let t = U(e.runtime.evaluate(i.text));
|
|
894
|
+
r += t ?? e.locale.t("Cannot compute", "无法计算");
|
|
895
|
+
} catch {
|
|
896
|
+
r += e.locale.t("Cannot compute", "无法计算");
|
|
897
|
+
}
|
|
898
|
+
break;
|
|
899
|
+
case "break":
|
|
900
|
+
r += " ";
|
|
901
|
+
break;
|
|
902
|
+
default: r += G(e, i.children, n + 1);
|
|
903
|
+
}
|
|
904
|
+
return r;
|
|
905
|
+
}
|
|
906
|
+
function Ye(e, t) {
|
|
907
|
+
return G(e, t.content.children) || t.content.attrs.value || "";
|
|
908
|
+
}
|
|
909
|
+
// src/react/sdk-core.tsx
|
|
910
|
+
function Xe(e) {
|
|
911
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("defineReactComponent requires a component definition object.");
|
|
912
|
+
return e;
|
|
913
|
+
}
|
|
914
|
+
var K = /* @__PURE__ */ new WeakMap();
|
|
915
|
+
function q(e) {
|
|
916
|
+
let t = K.get(e);
|
|
917
|
+
if (t) return t;
|
|
918
|
+
let n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
|
|
919
|
+
for (let t of e.components) n.set(t.definition.name, t), r.set(t.definition.id, t);
|
|
920
|
+
let i = Object.freeze({
|
|
921
|
+
byName: n,
|
|
922
|
+
byId: r
|
|
923
|
+
});
|
|
924
|
+
return K.set(e, i), i;
|
|
925
|
+
}
|
|
926
|
+
function Ze(e) {
|
|
927
|
+
if (!e || typeof e != "object" || Array.isArray(e)) throw TypeError("createReactConfig components must be LocalReactComponent values.");
|
|
928
|
+
let t = e;
|
|
929
|
+
if (!t.definition || typeof t.definition != "object") throw TypeError("A React component is missing its manifest definition.");
|
|
930
|
+
if (typeof t.render != "function") throw TypeError("A React component is missing its render implementation.");
|
|
931
|
+
if (t.renderStatic !== void 0 && typeof t.renderStatic != "function") throw TypeError("A React component renderStatic must be a function.");
|
|
932
|
+
return t;
|
|
933
|
+
}
|
|
934
|
+
function Qe(t, n, r) {
|
|
935
|
+
let a = i(t), o = n?.components;
|
|
936
|
+
if (!Array.isArray(o)) throw TypeError("createReactConfig requires a components array.");
|
|
937
|
+
let s = n?.presets ?? [];
|
|
938
|
+
if (!Array.isArray(s)) throw TypeError("createReactConfig presets must be an array.");
|
|
939
|
+
let c = [], l = [], u = /* @__PURE__ */ new Set(), d = (t, n) => {
|
|
940
|
+
let r = Ze(t), i = Xe(r.definition), a = e(i);
|
|
941
|
+
if (r.digest !== a) throw TypeError(`React component "${i.id}" from ${n} has a stale digest; create it with defineReactComponent.`);
|
|
942
|
+
return c.push(r), r;
|
|
943
|
+
};
|
|
944
|
+
for (let e of r) {
|
|
945
|
+
let t = d(e, "the default React preset");
|
|
946
|
+
u.add(t);
|
|
947
|
+
}
|
|
948
|
+
for (let e of s) {
|
|
949
|
+
if (!e || typeof e != "object" || !Array.isArray(e.components)) throw TypeError("createReactConfig preset must expose a components array.");
|
|
950
|
+
for (let t of e.components) l.push(d(t, `preset "${e.id ?? ""}"`));
|
|
951
|
+
}
|
|
952
|
+
for (let e of o) l.push(d(e, "components"));
|
|
953
|
+
let f = [], p = [];
|
|
954
|
+
for (let t of a.registry) {
|
|
955
|
+
let n = e(t), r = c.filter((e) => e.definition.id === t.id && e.definition.name === t.name && e.definition.version === t.version && e.digest === n);
|
|
956
|
+
if (r.length === 0) {
|
|
957
|
+
if (c.some((e) => e.definition.id === t.id)) throw TypeError(`React component "${t.id}@${t.version}" does not match the installed manifest contract.`);
|
|
958
|
+
p.push(`${t.id}@${t.version}`);
|
|
959
|
+
} else {
|
|
960
|
+
if (r.length > 1) throw TypeError(`Component id "${t.id}" has more than one matching React implementation.`);
|
|
961
|
+
f.push(r[0]);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
if (p.length > 0) {
|
|
965
|
+
let e = new Set(a.registry.map((e) => e.id)), t = [...new Set(l.filter((t) => !e.has(t.definition.id)).map((e) => `${e.definition.id}@${e.definition.version}`))];
|
|
966
|
+
throw TypeError(`createReactConfig is missing implementations for: ${p.join(", ")}.` + (t.length === 0 ? "" : ` Supplied implementation(s) ${t.join(", ")} are not declared by this local config.`));
|
|
967
|
+
}
|
|
968
|
+
let m = new Map(f.map((e) => [e.definition.id, e])), h = new Map(f.map((e) => [e.definition.name, e])), g = f.filter((e) => !u.has(e)), _ = Object.freeze(a.themes.slice()), v = Object.freeze({
|
|
969
|
+
byName: new Map(h),
|
|
970
|
+
byId: new Map(m)
|
|
971
|
+
}), y = Object.freeze({
|
|
972
|
+
config: a,
|
|
973
|
+
components: Object.freeze(g),
|
|
974
|
+
implementations: Object.freeze(f),
|
|
975
|
+
themes: _,
|
|
976
|
+
hostRenderer: rt(v)
|
|
977
|
+
});
|
|
978
|
+
return K.set(y, v), y;
|
|
979
|
+
}
|
|
980
|
+
var J = class extends Error {
|
|
981
|
+
componentName;
|
|
982
|
+
constructor(e) {
|
|
983
|
+
super(`No React implementation is registered for <${e}>.`), this.name = "LocalReactExtensionMissingError", this.componentName = e;
|
|
984
|
+
}
|
|
985
|
+
};
|
|
986
|
+
function $e(e) {
|
|
987
|
+
try {
|
|
988
|
+
return e.snapshot().revision;
|
|
989
|
+
} catch {
|
|
990
|
+
return 0;
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
function et(e, t) {
|
|
994
|
+
if (typeof e != "string" || e.length === 0) return {
|
|
995
|
+
line: 1,
|
|
996
|
+
column: 1
|
|
997
|
+
};
|
|
998
|
+
let n = Math.max(0, Math.min(t, e.length)), r = 1, i = 0;
|
|
999
|
+
for (let t = 0; t < n; t += 1) e[t] === "\n" && (r += 1, i = t + 1);
|
|
1000
|
+
return {
|
|
1001
|
+
line: r,
|
|
1002
|
+
column: n - i + 1
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
function Y(e, t, n, r, i) {
|
|
1006
|
+
let { line: a, column: o } = et(r, n.start);
|
|
1007
|
+
return {
|
|
1008
|
+
code: e,
|
|
1009
|
+
message: `Component <${t}> failed: ${i instanceof Error ? i.message : String(i)}`,
|
|
1010
|
+
severity: "error",
|
|
1011
|
+
range: {
|
|
1012
|
+
start: n.start,
|
|
1013
|
+
end: n.end
|
|
1014
|
+
},
|
|
1015
|
+
line: a,
|
|
1016
|
+
column: o
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
var X = class extends f {
|
|
1020
|
+
state = { failed: !1 };
|
|
1021
|
+
static getDerivedStateFromError() {
|
|
1022
|
+
return { failed: !0 };
|
|
1023
|
+
}
|
|
1024
|
+
componentDidCatch(e) {
|
|
1025
|
+
try {
|
|
1026
|
+
this.props.report([Y("local.extension.render", this.props.name, this.props.range, this.props.source, e)]);
|
|
1027
|
+
} catch {}
|
|
1028
|
+
}
|
|
1029
|
+
componentDidUpdate(e) {
|
|
1030
|
+
this.state.failed && e.revision !== this.props.revision && this.setState({ failed: !1 });
|
|
1031
|
+
}
|
|
1032
|
+
render() {
|
|
1033
|
+
return this.state.failed ? p("span", {
|
|
1034
|
+
className: "local-host-component local-host-unavailable local-sdk-unavailable",
|
|
1035
|
+
"data-local-host-component": this.props.name,
|
|
1036
|
+
"data-local-host-reason": "error",
|
|
1037
|
+
"data-rmd-source-start": String(this.props.range.start),
|
|
1038
|
+
"data-rmd-source-end": String(this.props.range.end),
|
|
1039
|
+
"data-rmd-source-node": this.props.nodeId,
|
|
1040
|
+
"data-rmd-source-type": "hostComponent",
|
|
1041
|
+
"data-rmd-source-component": this.props.name,
|
|
1042
|
+
role: "note"
|
|
1043
|
+
}, `Component <${this.props.name}> is unavailable here.`) : this.props.children;
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
function tt({ implementation: e, node: t, environment: n }) {
|
|
1047
|
+
let r = e.definition.id.startsWith("reactive-md/"), i = n.mode === "static" ? "static" : "interactive";
|
|
1048
|
+
if (!r && !e.definition.capabilities[i]) throw Error(`Component ${e.definition.id} does not support ${i} rendering.`);
|
|
1049
|
+
let a = L(t, {
|
|
1050
|
+
runtime: n.runtime,
|
|
1051
|
+
authorStyle: n.authorStyle,
|
|
1052
|
+
authorStyleText: n.authorStyleText,
|
|
1053
|
+
dispatchAuthorAction: n.dispatchAuthorAction,
|
|
1054
|
+
network: n.network,
|
|
1055
|
+
services: n.services ?? n.runtime.services,
|
|
1056
|
+
mode: n.mode,
|
|
1057
|
+
locale: n.locale,
|
|
1058
|
+
visible: n.visible,
|
|
1059
|
+
disabled: n.disabled,
|
|
1060
|
+
disabledInvalid: n.disabledInvalid,
|
|
1061
|
+
resetToken: n.resetToken,
|
|
1062
|
+
definitionFor: n.definitionFor,
|
|
1063
|
+
validationFieldFor: n.validationField,
|
|
1064
|
+
validationHintFor: n.validationHint,
|
|
1065
|
+
sourceAttributes: n.sourceAttributes,
|
|
1066
|
+
renderChildren: (e, t) => n.renderChildren(e, t),
|
|
1067
|
+
renderInline: (e, t) => n.renderInline(e, t),
|
|
1068
|
+
renderToText: (e) => n.renderToText(e),
|
|
1069
|
+
report: n.report,
|
|
1070
|
+
targetId: n.targetId,
|
|
1071
|
+
anchorId: n.anchorId,
|
|
1072
|
+
jumpAllowed: n.jumpAllowed,
|
|
1073
|
+
jumpTo: n.jumpTo,
|
|
1074
|
+
urlPolicy: n.urlPolicy,
|
|
1075
|
+
imageResolver: n.imageResolver
|
|
1076
|
+
}), o = n.mode === "static" && e.renderStatic ? e.renderStatic : e.render;
|
|
1077
|
+
return p(o, a);
|
|
1078
|
+
}
|
|
1079
|
+
function Z(e, t, n) {
|
|
1080
|
+
let r = t.name ?? "", i = e.byName.get(r);
|
|
1081
|
+
if (!i) throw new J(r);
|
|
1082
|
+
let a;
|
|
1083
|
+
try {
|
|
1084
|
+
a = n.runtime.document.source;
|
|
1085
|
+
} catch {
|
|
1086
|
+
a = void 0;
|
|
1087
|
+
}
|
|
1088
|
+
let o = p(tt, {
|
|
1089
|
+
implementation: i,
|
|
1090
|
+
node: t,
|
|
1091
|
+
environment: n
|
|
1092
|
+
});
|
|
1093
|
+
return i.definition.id.startsWith("reactive-md/") ? o : p(X, {
|
|
1094
|
+
name: r,
|
|
1095
|
+
nodeId: t.id,
|
|
1096
|
+
revision: $e(n.runtime),
|
|
1097
|
+
range: t.range,
|
|
1098
|
+
source: a,
|
|
1099
|
+
report: n.report
|
|
1100
|
+
}, o);
|
|
1101
|
+
}
|
|
1102
|
+
function nt(e) {
|
|
1103
|
+
return (t, n) => Z(q(e), t, n);
|
|
1104
|
+
}
|
|
1105
|
+
function Q(e) {
|
|
1106
|
+
let t = "";
|
|
1107
|
+
for (let n of e ?? []) n.type === "text" || n.type === "inlineCode" || n.type === "code" ? t += n.value ?? "" : n.type === "math" || n.type === "inlineMath" || n.type === "image" ? t += n.value ?? n.alt ?? "" : t += Q(n.children);
|
|
1108
|
+
return t;
|
|
1109
|
+
}
|
|
1110
|
+
function rt(e) {
|
|
1111
|
+
return (t, n, r) => Z(e, t, {
|
|
1112
|
+
runtime: r.runtime,
|
|
1113
|
+
mode: r.mode,
|
|
1114
|
+
visible: r.visible,
|
|
1115
|
+
disabled: r.disabled,
|
|
1116
|
+
disabledInvalid: !1,
|
|
1117
|
+
resetToken: r.resetToken,
|
|
1118
|
+
locale: "en",
|
|
1119
|
+
renderChildren: (e, t) => r.render(e, t),
|
|
1120
|
+
renderInline: (e, t) => r.render(e, t),
|
|
1121
|
+
renderToText: (e) => Q(e),
|
|
1122
|
+
report: (e) => r.report(e),
|
|
1123
|
+
definitionFor: (t) => e.byName.get(t)?.definition,
|
|
1124
|
+
validationField: () => ({ invalid: !1 }),
|
|
1125
|
+
validationHint: () => null,
|
|
1126
|
+
sourceAttributes: () => ({}),
|
|
1127
|
+
targetId: () => void 0,
|
|
1128
|
+
anchorId: () => void 0,
|
|
1129
|
+
jumpAllowed: () => !1,
|
|
1130
|
+
jumpTo: () => "missing"
|
|
1131
|
+
});
|
|
1132
|
+
}
|
|
1133
|
+
function it(e, t) {
|
|
1134
|
+
let n = d(t, e.config);
|
|
1135
|
+
if (n.length || !t || typeof t != "object") return n;
|
|
1136
|
+
let r = t.components;
|
|
1137
|
+
if (!Array.isArray(r)) return n;
|
|
1138
|
+
let i = q(e);
|
|
1139
|
+
for (let e of r) i.byId.has(e.id) || n.push({
|
|
1140
|
+
code: "local.extension.renderer-missing",
|
|
1141
|
+
severity: "error",
|
|
1142
|
+
message: new J(e.name).message,
|
|
1143
|
+
range: {
|
|
1144
|
+
start: 0,
|
|
1145
|
+
end: 0
|
|
1146
|
+
},
|
|
1147
|
+
line: 1,
|
|
1148
|
+
column: 1
|
|
1149
|
+
});
|
|
1150
|
+
return n;
|
|
1151
|
+
}
|
|
1152
|
+
function $(e, t, n) {
|
|
1153
|
+
try {
|
|
1154
|
+
e.report([Y("local.extension.event", e.instance.componentId, e.instance.range, n, t)]);
|
|
1155
|
+
} catch {}
|
|
1156
|
+
}
|
|
1157
|
+
function at(e, t, n) {
|
|
1158
|
+
return (...r) => {
|
|
1159
|
+
try {
|
|
1160
|
+
t(...r);
|
|
1161
|
+
} catch (t) {
|
|
1162
|
+
$(e, t, n);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
export { U as A, xe as B, je as C, Ye as D, Re as E, Ae as F, he as G, be as H, Ve as I, ge as L, Le as M, ze as N, Ce as O, we as P, ve as R, Te as S, De as T, _e as U, ye as V, te as W, Ne as _, at as a, G as b, Ge as c, Ke as d, Me as f, Oe as g, Pe as h, $ as i, Fe as j, H as k, Ue as l, Ie as m, Qe as n, it as o, ke as p, nt as r, We as s, J as t, He as u, Je as v, V as w, Ee as x, qe as y, Se as z };
|