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
|
@@ -1,2253 +0,0 @@
|
|
|
1
|
-
import { n as e } from "./props-DGlBk0e5.js";
|
|
2
|
-
import { F as t, K as n, L as r, M as i, P as a, Q as o, X as s, Y as c, Z as l, ct as u, k as d, lt as f, n as p, r as m, rt as h, t as g } from "./identity-MYJXKSkB.js";
|
|
3
|
-
import { $ as _, C as v, D as y, E as b, O as x, T as S, Z as ee, _ as C, a as w, c as T, d as te, h as ne, i as E, m as re, n as ie, nt as D, o as ae, p as oe, r as se, s as ce, t as le, v as ue, x as de } from "./config-validation-DXTynAw7.js";
|
|
4
|
-
// src/local/source/text-length.ts
|
|
5
|
-
function fe(e) {
|
|
6
|
-
if (typeof e != "string") return 0;
|
|
7
|
-
let t = 0;
|
|
8
|
-
for (let n of e) t += 1;
|
|
9
|
-
return t;
|
|
10
|
-
}
|
|
11
|
-
// src/local/contracts/types.ts
|
|
12
|
-
var pe = (e) => e.attrs?.bind ?? `@${e.id}`, O = class extends Error {
|
|
13
|
-
code;
|
|
14
|
-
constructor(e, t) {
|
|
15
|
-
super(t), this.name = "LocalFunctionError", this.code = e;
|
|
16
|
-
}
|
|
17
|
-
}, me = [
|
|
18
|
-
"en-US",
|
|
19
|
-
"zh-CN",
|
|
20
|
-
"de-DE",
|
|
21
|
-
"fr-FR",
|
|
22
|
-
"ja-JP"
|
|
23
|
-
], he = new Set(me), ge = /^[A-Z]{3}$/, _e = 20;
|
|
24
|
-
function k(e) {
|
|
25
|
-
throw new O("expression-domain", e);
|
|
26
|
-
}
|
|
27
|
-
function A(e, t) {
|
|
28
|
-
if (e.length > 1e5) throw new O("expression-budget", `${t} exceeds the ${u}-character limit.`);
|
|
29
|
-
return e;
|
|
30
|
-
}
|
|
31
|
-
function j(e) {
|
|
32
|
-
return he.has(e) || k(`Unsupported locale "${e}"; expected one of ${me.join(", ")}.`), e;
|
|
33
|
-
}
|
|
34
|
-
function ve(e, t) {
|
|
35
|
-
return (!Number.isInteger(e) || e < 0 || e > _e) && k(`${t} digits must be an integer from 0 to ${_e}.`), e;
|
|
36
|
-
}
|
|
37
|
-
function ye(e) {
|
|
38
|
-
if (!Number.isFinite(e)) throw new O("expression-number", "Value must be a finite number.");
|
|
39
|
-
return e;
|
|
40
|
-
}
|
|
41
|
-
function be(e) {
|
|
42
|
-
return e === 0 ? 0 : e;
|
|
43
|
-
}
|
|
44
|
-
function xe(e, t) {
|
|
45
|
-
let n = ye(e);
|
|
46
|
-
return n === 0 || Math.abs(n) < .5 * 10 ** -t ? 0 : n;
|
|
47
|
-
}
|
|
48
|
-
function Se(e, t) {
|
|
49
|
-
let n = ye(e);
|
|
50
|
-
return n === 0 || Math.abs(n) < .5 * 10 ** -(t + 2) ? 0 : n;
|
|
51
|
-
}
|
|
52
|
-
function Ce(e, t, n, r, i) {
|
|
53
|
-
let a;
|
|
54
|
-
try {
|
|
55
|
-
a = new Intl.NumberFormat(e, t);
|
|
56
|
-
} catch {
|
|
57
|
-
a = void 0;
|
|
58
|
-
}
|
|
59
|
-
return a === void 0 && k(i), A(a.format(n), r);
|
|
60
|
-
}
|
|
61
|
-
function we(e, t = 2, n = "en-US", r = !0) {
|
|
62
|
-
let i = j(n), a = ve(t, "formatNumber");
|
|
63
|
-
return typeof r != "boolean" && k("formatNumber grouping must be a boolean."), e === null ? "" : Ce(i, {
|
|
64
|
-
useGrouping: r,
|
|
65
|
-
minimumFractionDigits: a,
|
|
66
|
-
maximumFractionDigits: a,
|
|
67
|
-
roundingMode: "halfExpand"
|
|
68
|
-
}, xe(e, a), "Formatted number", `Cannot format a number for locale "${i}".`);
|
|
69
|
-
}
|
|
70
|
-
function Te(e, t = 0, n = "en-US") {
|
|
71
|
-
let r = j(n), i = ve(t, "formatPercent");
|
|
72
|
-
return e === null ? "" : Ce(r, {
|
|
73
|
-
style: "percent",
|
|
74
|
-
minimumFractionDigits: i,
|
|
75
|
-
maximumFractionDigits: i,
|
|
76
|
-
roundingMode: "halfExpand"
|
|
77
|
-
}, Se(e, i), "Formatted percentage", `Cannot format a percentage for locale "${r}".`);
|
|
78
|
-
}
|
|
79
|
-
function Ee(e, t = 2, n = "en-US") {
|
|
80
|
-
let r = j(n), i = ve(t, "formatScientific");
|
|
81
|
-
return e === null ? "" : Ce(r, {
|
|
82
|
-
notation: "scientific",
|
|
83
|
-
minimumFractionDigits: i,
|
|
84
|
-
maximumFractionDigits: i,
|
|
85
|
-
roundingMode: "halfExpand"
|
|
86
|
-
}, be(ye(e)), "Formatted number", `Cannot format a number for locale "${r}".`);
|
|
87
|
-
}
|
|
88
|
-
function De(e, t = "USD", n = 2, r = "en-US") {
|
|
89
|
-
let i = j(r);
|
|
90
|
-
ge.test(t) || k(`Currency "${t}" must be a three-letter uppercase code such as "USD".`);
|
|
91
|
-
let a = ve(n, "formatCurrency");
|
|
92
|
-
return e === null ? "" : Ce(i, {
|
|
93
|
-
style: "currency",
|
|
94
|
-
currency: t,
|
|
95
|
-
minimumFractionDigits: a,
|
|
96
|
-
maximumFractionDigits: a,
|
|
97
|
-
roundingMode: "halfExpand"
|
|
98
|
-
}, xe(e, a), "Formatted currency", `Currency code "${t}" is not accepted by Intl.`);
|
|
99
|
-
}
|
|
100
|
-
// src/local/evaluation/collection-functions.ts
|
|
101
|
-
function Oe() {
|
|
102
|
-
throw new O("expression-number", "The result is not a finite number.");
|
|
103
|
-
}
|
|
104
|
-
function M(e) {
|
|
105
|
-
if (!Number.isFinite(e)) throw new O("expression-value", "Numeric array members must be finite numbers.");
|
|
106
|
-
return e;
|
|
107
|
-
}
|
|
108
|
-
function ke(e) {
|
|
109
|
-
let t = 0;
|
|
110
|
-
for (let n of e) t += M(n);
|
|
111
|
-
return Number.isFinite(t) || Oe(), t;
|
|
112
|
-
}
|
|
113
|
-
function Ae(e) {
|
|
114
|
-
if (e.length === 0) return null;
|
|
115
|
-
let t = ke(e) / e.length;
|
|
116
|
-
return Number.isFinite(t) || Oe(), t;
|
|
117
|
-
}
|
|
118
|
-
function je(e) {
|
|
119
|
-
if (e.length === 0) return null;
|
|
120
|
-
let t = M(e[0]);
|
|
121
|
-
for (let n = 1; n < e.length; n += 1) {
|
|
122
|
-
let r = M(e[n]);
|
|
123
|
-
r < t && (t = r);
|
|
124
|
-
}
|
|
125
|
-
return t;
|
|
126
|
-
}
|
|
127
|
-
function Me(e) {
|
|
128
|
-
if (e.length === 0) return null;
|
|
129
|
-
let t = M(e[0]);
|
|
130
|
-
for (let n = 1; n < e.length; n += 1) {
|
|
131
|
-
let r = M(e[n]);
|
|
132
|
-
r > t && (t = r);
|
|
133
|
-
}
|
|
134
|
-
return t;
|
|
135
|
-
}
|
|
136
|
-
// src/local/evaluation/dates.ts
|
|
137
|
-
function Ne(e) {
|
|
138
|
-
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
139
|
-
if (!t) return null;
|
|
140
|
-
let n = Number(t[1]), r = Number(t[2]), i = Number(t[3]);
|
|
141
|
-
if (n < 1 || r < 1 || r > 12 || i < 1 || i > 31) return null;
|
|
142
|
-
let a = /* @__PURE__ */ new Date(0);
|
|
143
|
-
return a.setUTCFullYear(n, r - 1, i), a.getUTCFullYear() === n && a.getUTCMonth() === r - 1 && a.getUTCDate() === i ? a.getTime() : null;
|
|
144
|
-
}
|
|
145
|
-
// src/local/evaluation/data-functions.ts
|
|
146
|
-
function Pe(e) {
|
|
147
|
-
throw new O("expression-domain", e);
|
|
148
|
-
}
|
|
149
|
-
function Fe(e) {
|
|
150
|
-
return A(e.trim(), "trim result");
|
|
151
|
-
}
|
|
152
|
-
function Ie(e) {
|
|
153
|
-
return A(e.toLowerCase(), "lower result");
|
|
154
|
-
}
|
|
155
|
-
function Le(e) {
|
|
156
|
-
return A(e.toUpperCase(), "upper result");
|
|
157
|
-
}
|
|
158
|
-
function Re(e, t) {
|
|
159
|
-
return e.startsWith(t);
|
|
160
|
-
}
|
|
161
|
-
function ze(e, t) {
|
|
162
|
-
return e.endsWith(t);
|
|
163
|
-
}
|
|
164
|
-
function Be(e, t, n) {
|
|
165
|
-
t.length === 0 && Pe("replace search text must not be empty.");
|
|
166
|
-
let r = n.length - t.length;
|
|
167
|
-
if (r > 0) {
|
|
168
|
-
let n = 0, i = 0;
|
|
169
|
-
for (;;) {
|
|
170
|
-
let r = e.indexOf(t, i);
|
|
171
|
-
if (r < 0) break;
|
|
172
|
-
n += 1, i = r + t.length;
|
|
173
|
-
}
|
|
174
|
-
if (e.length + n * r > 1e5) throw new O("expression-budget", `replace result would exceed the ${u}-character limit.`);
|
|
175
|
-
}
|
|
176
|
-
let i = "", a = 0;
|
|
177
|
-
for (;;) {
|
|
178
|
-
let r = e.indexOf(t, a);
|
|
179
|
-
if (r < 0) break;
|
|
180
|
-
i += e.slice(a, r), i += n, a = r + t.length;
|
|
181
|
-
}
|
|
182
|
-
return i += e.slice(a), A(i, "replace result");
|
|
183
|
-
}
|
|
184
|
-
function Ve(e, t) {
|
|
185
|
-
return e < 0 ? Math.max(t + e, 0) : Math.min(e, t);
|
|
186
|
-
}
|
|
187
|
-
function He(e, t, n) {
|
|
188
|
-
Number.isInteger(t) || Pe("slice start must be an integer."), n !== void 0 && !Number.isInteger(n) && Pe("slice end must be an integer.");
|
|
189
|
-
let r = Array.from(e), i = r.length, a = Ve(t, i), o = n === void 0 ? i : Ve(n, i);
|
|
190
|
-
return o <= a ? "" : A(r.slice(a, o).join(""), "slice result");
|
|
191
|
-
}
|
|
192
|
-
var Ue = /* @__PURE__ */ new Map([
|
|
193
|
-
["days", 864e5],
|
|
194
|
-
["hours", 36e5],
|
|
195
|
-
["minutes", 6e4],
|
|
196
|
-
["seconds", 1e3],
|
|
197
|
-
["milliseconds", 1]
|
|
198
|
-
]), We = "days, hours, minutes, seconds or milliseconds";
|
|
199
|
-
function N(e) {
|
|
200
|
-
let t = Ne(e);
|
|
201
|
-
if (t === null) throw new O("expression-domain", `Date "${e}" must be a valid YYYY-MM-DD calendar date in years 0001-9999.`);
|
|
202
|
-
return t;
|
|
203
|
-
}
|
|
204
|
-
function Ge(e, t) {
|
|
205
|
-
let n = N(e), r = N(t);
|
|
206
|
-
return n === r ? 0 : n < r ? -1 : 1;
|
|
207
|
-
}
|
|
208
|
-
function Ke(e, t, n = "days") {
|
|
209
|
-
let r = Ue.get(n);
|
|
210
|
-
return r === void 0 && Pe(`dateDiff unit must be ${We}.`), (N(e) - N(t)) / r;
|
|
211
|
-
}
|
|
212
|
-
// src/local/evaluation/expression.ts
|
|
213
|
-
var P = class extends Error {
|
|
214
|
-
offset;
|
|
215
|
-
code;
|
|
216
|
-
constructor(e, t, n = 0) {
|
|
217
|
-
super(t), this.name = "LocalExpressionError", this.code = e, this.offset = n;
|
|
218
|
-
}
|
|
219
|
-
}, qe = /* @__PURE__ */ "abs.sqrt.floor.ceil.round.min.max.pow.sin.cos.tan.asin.acos.atan.exp.log.len.contains.clamp.sum.average.minOf.maxOf.formatNumber.formatPercent.formatScientific.formatCurrency.trim.lower.upper.startsWith.endsWith.replace.slice.dateCompare.dateDiff".split("."), Je = new Set(qe), Ye = /* @__PURE__ */ new Map([["pi", Math.PI], ["e", Math.E]]), Xe = /* @__PURE__ */ new Set([
|
|
220
|
-
"__proto__",
|
|
221
|
-
"prototype",
|
|
222
|
-
"constructor"
|
|
223
|
-
]), Ze = /* @__PURE__ */ new Set([
|
|
224
|
-
"string",
|
|
225
|
-
"number",
|
|
226
|
-
"boolean",
|
|
227
|
-
"null",
|
|
228
|
-
"array",
|
|
229
|
-
"number-array"
|
|
230
|
-
]), Qe = /* @__PURE__ */ new Set([
|
|
231
|
-
...qe,
|
|
232
|
-
"x",
|
|
233
|
-
"y",
|
|
234
|
-
"pi",
|
|
235
|
-
"e",
|
|
236
|
-
"true",
|
|
237
|
-
"false",
|
|
238
|
-
"null",
|
|
239
|
-
...Xe
|
|
240
|
-
]), $e = 4e3, et = 2e3, tt = 100, nt = 200, rt = 1e4, it = 250, at = u, ot = u, st = 500;
|
|
241
|
-
function ct(e) {
|
|
242
|
-
if (e.length > 1e4) return {
|
|
243
|
-
code: "expression-budget",
|
|
244
|
-
...D("local.budget.value.array", { limit: o }),
|
|
245
|
-
message: `Array exceeds the ${o}-item limit.`
|
|
246
|
-
};
|
|
247
|
-
let t = null, n = 0;
|
|
248
|
-
for (let r of e) if (typeof r == "string") {
|
|
249
|
-
if (t === "number") return {
|
|
250
|
-
code: "expression-value",
|
|
251
|
-
key: "error.array.homogeneous",
|
|
252
|
-
message: "Array elements must all be strings or all be numbers."
|
|
253
|
-
};
|
|
254
|
-
if (t = "string", r.length > 1e5) return {
|
|
255
|
-
code: "expression-budget",
|
|
256
|
-
...D("local.budget.value.array-member", { limit: u }),
|
|
257
|
-
message: `Array member exceeds the ${u}-character limit.`
|
|
258
|
-
};
|
|
259
|
-
if (n += r.length, n > 1e5) return {
|
|
260
|
-
code: "expression-budget",
|
|
261
|
-
...D("local.budget.value.array-contents", { limit: f }),
|
|
262
|
-
message: `Array contents exceed the ${f}-character limit.`
|
|
263
|
-
};
|
|
264
|
-
} else if (typeof r == "number") {
|
|
265
|
-
if (t === "string") return {
|
|
266
|
-
code: "expression-value",
|
|
267
|
-
key: "error.array.homogeneous",
|
|
268
|
-
message: "Array elements must all be strings or all be numbers."
|
|
269
|
-
};
|
|
270
|
-
if (t = "number", !Number.isFinite(r)) return {
|
|
271
|
-
code: "expression-value",
|
|
272
|
-
key: "error.array.finite",
|
|
273
|
-
message: "Array members must be finite numbers."
|
|
274
|
-
};
|
|
275
|
-
} else return {
|
|
276
|
-
code: "expression-value",
|
|
277
|
-
key: "error.array.members",
|
|
278
|
-
message: "Array members must be strings or finite numbers."
|
|
279
|
-
};
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
function lt(e) {
|
|
283
|
-
if (typeof e == "string") return e.length > 1e5 ? D("local.budget.value.string", { limit: u }) : null;
|
|
284
|
-
if (Array.isArray(e)) {
|
|
285
|
-
let t = ct(e);
|
|
286
|
-
return t ? D(t.key, t.params) : null;
|
|
287
|
-
}
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
function F(e) {
|
|
291
|
-
let t = lt(e);
|
|
292
|
-
return t ? _(t) : null;
|
|
293
|
-
}
|
|
294
|
-
var ut = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, dt = /[A-Za-z_]/, ft = /[A-Za-z0-9_]/;
|
|
295
|
-
function pt(e) {
|
|
296
|
-
let t = [], n = 0;
|
|
297
|
-
for (; n < e.length;) {
|
|
298
|
-
let r = e[n];
|
|
299
|
-
if (/\s/.test(r)) {
|
|
300
|
-
n += 1;
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
if (r >= "0" && r <= "9" || r === "." && /[0-9]/.test(e[n + 1] ?? "")) {
|
|
304
|
-
let r = ut.exec(e.slice(n));
|
|
305
|
-
if (!r) throw new P("expression-syntax", "Invalid number.", n);
|
|
306
|
-
let i = r[0], a = Number(i);
|
|
307
|
-
if (!Number.isFinite(a)) throw new P("expression-number", `Number must be finite: ${i}.`, n);
|
|
308
|
-
t.push({
|
|
309
|
-
kind: "number",
|
|
310
|
-
value: i,
|
|
311
|
-
start: n,
|
|
312
|
-
number: a
|
|
313
|
-
}), n += i.length;
|
|
314
|
-
continue;
|
|
315
|
-
}
|
|
316
|
-
if (r === "\"" || r === "'") {
|
|
317
|
-
let i = n, a = r, o = "", s = n + 1, c = !1;
|
|
318
|
-
for (; s < e.length;) {
|
|
319
|
-
let t = e[s];
|
|
320
|
-
if (t === a) {
|
|
321
|
-
c = !0, s += 1;
|
|
322
|
-
break;
|
|
323
|
-
}
|
|
324
|
-
if (t === "\n" || t === "\r") throw new P("expression-string", "String literals cannot span lines.", i);
|
|
325
|
-
if (t === "\\") {
|
|
326
|
-
let t = e[s + 1];
|
|
327
|
-
if (t === void 0) break;
|
|
328
|
-
switch (t) {
|
|
329
|
-
case "\\":
|
|
330
|
-
o += "\\";
|
|
331
|
-
break;
|
|
332
|
-
case "'":
|
|
333
|
-
o += "'";
|
|
334
|
-
break;
|
|
335
|
-
case "\"":
|
|
336
|
-
o += "\"";
|
|
337
|
-
break;
|
|
338
|
-
case "n":
|
|
339
|
-
o += "\n";
|
|
340
|
-
break;
|
|
341
|
-
case "t":
|
|
342
|
-
o += " ";
|
|
343
|
-
break;
|
|
344
|
-
default: throw new P("expression-string", `Unsupported escape \\${t}.`, s);
|
|
345
|
-
}
|
|
346
|
-
s += 2;
|
|
347
|
-
} else o += t, s += 1;
|
|
348
|
-
}
|
|
349
|
-
if (!c) throw new P("expression-string", "Unterminated string literal.", i);
|
|
350
|
-
if (o.length > at) throw new P("expression-budget", "String literal exceeds the length limit.", i);
|
|
351
|
-
t.push({
|
|
352
|
-
kind: "string",
|
|
353
|
-
value: o,
|
|
354
|
-
start: i
|
|
355
|
-
}), n = s;
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
if (dt.test(r)) {
|
|
359
|
-
let r = n + 1;
|
|
360
|
-
for (; r < e.length && ft.test(e[r]);) r += 1;
|
|
361
|
-
t.push({
|
|
362
|
-
kind: "ident",
|
|
363
|
-
value: e.slice(n, r),
|
|
364
|
-
start: n
|
|
365
|
-
}), n = r;
|
|
366
|
-
continue;
|
|
367
|
-
}
|
|
368
|
-
let i = e.slice(n, n + 2);
|
|
369
|
-
if (e.startsWith("!==", n) || e.startsWith("===", n)) throw new P("expression-syntax", `Unsupported operator ${e.slice(n, n + 3)}.`, n);
|
|
370
|
-
if (i === "==" || i === "!=" || i === "<=" || i === ">=" || i === "&&" || i === "||") t.push({
|
|
371
|
-
kind: "punct",
|
|
372
|
-
value: i,
|
|
373
|
-
start: n
|
|
374
|
-
}), n += 2;
|
|
375
|
-
else if ("+-*/%()!<>?:,[]".includes(r)) t.push({
|
|
376
|
-
kind: "punct",
|
|
377
|
-
value: r,
|
|
378
|
-
start: n
|
|
379
|
-
}), n += 1;
|
|
380
|
-
else throw r === "=" ? new P("expression-assignment", "Assignments are not supported.", n) : r === "." ? new P("expression-property", "Property access is not supported.", n) : r === "&" || r === "|" ? new P("expression-syntax", `Use ${r}${r} for logical operations.`, n) : new P("expression-syntax", `Unrecognized character "${r}".`, n);
|
|
381
|
-
}
|
|
382
|
-
return t.push({
|
|
383
|
-
kind: "eof",
|
|
384
|
-
value: "",
|
|
385
|
-
start: e.length
|
|
386
|
-
}), t;
|
|
387
|
-
}
|
|
388
|
-
var mt = {
|
|
389
|
-
abs: [1, 1],
|
|
390
|
-
sqrt: [1, 1],
|
|
391
|
-
floor: [1, 1],
|
|
392
|
-
ceil: [1, 1],
|
|
393
|
-
round: [1, 1],
|
|
394
|
-
min: [1, 2 ** 53 - 1],
|
|
395
|
-
max: [1, 2 ** 53 - 1],
|
|
396
|
-
pow: [2, 2],
|
|
397
|
-
sin: [1, 1],
|
|
398
|
-
cos: [1, 1],
|
|
399
|
-
tan: [1, 1],
|
|
400
|
-
asin: [1, 1],
|
|
401
|
-
acos: [1, 1],
|
|
402
|
-
atan: [1, 1],
|
|
403
|
-
exp: [1, 1],
|
|
404
|
-
log: [1, 1],
|
|
405
|
-
len: [1, 1],
|
|
406
|
-
contains: [2, 2],
|
|
407
|
-
clamp: [3, 3],
|
|
408
|
-
sum: [1, 1],
|
|
409
|
-
average: [1, 1],
|
|
410
|
-
minOf: [1, 1],
|
|
411
|
-
maxOf: [1, 1],
|
|
412
|
-
formatNumber: [1, 4],
|
|
413
|
-
formatPercent: [1, 3],
|
|
414
|
-
formatScientific: [1, 3],
|
|
415
|
-
formatCurrency: [1, 4],
|
|
416
|
-
trim: [1, 1],
|
|
417
|
-
lower: [1, 1],
|
|
418
|
-
upper: [1, 1],
|
|
419
|
-
startsWith: [2, 2],
|
|
420
|
-
endsWith: [2, 2],
|
|
421
|
-
replace: [3, 3],
|
|
422
|
-
slice: [2, 3],
|
|
423
|
-
dateCompare: [2, 2],
|
|
424
|
-
dateDiff: [2, 3]
|
|
425
|
-
};
|
|
426
|
-
function ht(e) {
|
|
427
|
-
let t = 0, n = [{
|
|
428
|
-
node: e,
|
|
429
|
-
depth: 1
|
|
430
|
-
}];
|
|
431
|
-
for (; n.length > 0;) {
|
|
432
|
-
let { node: e, depth: r } = n.pop();
|
|
433
|
-
switch (r > t && (t = r), e.kind) {
|
|
434
|
-
case "unary":
|
|
435
|
-
n.push({
|
|
436
|
-
node: e.operand,
|
|
437
|
-
depth: r + 1
|
|
438
|
-
});
|
|
439
|
-
break;
|
|
440
|
-
case "binary":
|
|
441
|
-
n.push({
|
|
442
|
-
node: e.left,
|
|
443
|
-
depth: r + 1
|
|
444
|
-
}), n.push({
|
|
445
|
-
node: e.right,
|
|
446
|
-
depth: r + 1
|
|
447
|
-
});
|
|
448
|
-
break;
|
|
449
|
-
case "conditional":
|
|
450
|
-
n.push({
|
|
451
|
-
node: e.test,
|
|
452
|
-
depth: r + 1
|
|
453
|
-
}), n.push({
|
|
454
|
-
node: e.consequent,
|
|
455
|
-
depth: r + 1
|
|
456
|
-
}), n.push({
|
|
457
|
-
node: e.alternate,
|
|
458
|
-
depth: r + 1
|
|
459
|
-
});
|
|
460
|
-
break;
|
|
461
|
-
case "call":
|
|
462
|
-
for (let t of e.args) n.push({
|
|
463
|
-
node: t,
|
|
464
|
-
depth: r + 1
|
|
465
|
-
});
|
|
466
|
-
break;
|
|
467
|
-
case "array":
|
|
468
|
-
for (let t of e.elements) n.push({
|
|
469
|
-
node: t,
|
|
470
|
-
depth: r + 1
|
|
471
|
-
});
|
|
472
|
-
break;
|
|
473
|
-
case "index": n.push({
|
|
474
|
-
node: e.target,
|
|
475
|
-
depth: r + 1
|
|
476
|
-
}), n.push({
|
|
477
|
-
node: e.index,
|
|
478
|
-
depth: r + 1
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
return t;
|
|
483
|
-
}
|
|
484
|
-
var gt = class {
|
|
485
|
-
tokens;
|
|
486
|
-
position = 0;
|
|
487
|
-
nodeCount = 0;
|
|
488
|
-
dependencyNames = [];
|
|
489
|
-
dependencySet = /* @__PURE__ */ new Set();
|
|
490
|
-
constructor(e) {
|
|
491
|
-
this.tokens = pt(e);
|
|
492
|
-
}
|
|
493
|
-
get dependencies() {
|
|
494
|
-
return this.dependencyNames;
|
|
495
|
-
}
|
|
496
|
-
parse() {
|
|
497
|
-
if (this.peek().kind === "eof") throw new P("expression-empty", "Expression is empty.", 0);
|
|
498
|
-
let e = this.parseConditional(0), t = this.peek();
|
|
499
|
-
if (t.kind !== "eof") throw new P("expression-syntax", `Unexpected content "${t.value}".`, t.start);
|
|
500
|
-
if (ht(e) > nt) throw new P("expression-budget", "Expression is nested too deeply.", e.start);
|
|
501
|
-
return e;
|
|
502
|
-
}
|
|
503
|
-
peek() {
|
|
504
|
-
return this.tokens[this.position];
|
|
505
|
-
}
|
|
506
|
-
next() {
|
|
507
|
-
let e = this.tokens[this.position];
|
|
508
|
-
return this.position += 1, e;
|
|
509
|
-
}
|
|
510
|
-
isPunct(e) {
|
|
511
|
-
let t = this.peek();
|
|
512
|
-
return t.kind === "punct" && t.value === e;
|
|
513
|
-
}
|
|
514
|
-
expect(e) {
|
|
515
|
-
let t = this.peek();
|
|
516
|
-
if (t.kind !== "punct" || t.value !== e) throw new P("expression-syntax", `Missing "${e}".`, t.start);
|
|
517
|
-
return this.next();
|
|
518
|
-
}
|
|
519
|
-
node(e, t, n) {
|
|
520
|
-
if (this.nodeCount += 1, this.nodeCount > et) throw new P("expression-budget", "Expression is too complex.", n);
|
|
521
|
-
if (t > tt) throw new P("expression-budget", "Expression is nested too deeply.", n);
|
|
522
|
-
return e;
|
|
523
|
-
}
|
|
524
|
-
parseConditional(e) {
|
|
525
|
-
let t = this.parseOr(e);
|
|
526
|
-
if (!this.isPunct("?")) return t;
|
|
527
|
-
let n = t.start;
|
|
528
|
-
this.next();
|
|
529
|
-
let r = this.parseConditional(e + 1);
|
|
530
|
-
this.expect(":");
|
|
531
|
-
let i = this.parseConditional(e + 1);
|
|
532
|
-
return this.node({
|
|
533
|
-
kind: "conditional",
|
|
534
|
-
test: t,
|
|
535
|
-
consequent: r,
|
|
536
|
-
alternate: i,
|
|
537
|
-
start: n
|
|
538
|
-
}, e, n);
|
|
539
|
-
}
|
|
540
|
-
parseOr(e) {
|
|
541
|
-
let t = this.parseAnd(e);
|
|
542
|
-
for (; this.isPunct("||");) {
|
|
543
|
-
let n = t.start;
|
|
544
|
-
this.next();
|
|
545
|
-
let r = this.parseAnd(e);
|
|
546
|
-
t = this.node({
|
|
547
|
-
kind: "binary",
|
|
548
|
-
operator: "||",
|
|
549
|
-
left: t,
|
|
550
|
-
right: r,
|
|
551
|
-
start: n
|
|
552
|
-
}, e, n);
|
|
553
|
-
}
|
|
554
|
-
return t;
|
|
555
|
-
}
|
|
556
|
-
parseAnd(e) {
|
|
557
|
-
let t = this.parseEquality(e);
|
|
558
|
-
for (; this.isPunct("&&");) {
|
|
559
|
-
let n = t.start;
|
|
560
|
-
this.next();
|
|
561
|
-
let r = this.parseEquality(e);
|
|
562
|
-
t = this.node({
|
|
563
|
-
kind: "binary",
|
|
564
|
-
operator: "&&",
|
|
565
|
-
left: t,
|
|
566
|
-
right: r,
|
|
567
|
-
start: n
|
|
568
|
-
}, e, n);
|
|
569
|
-
}
|
|
570
|
-
return t;
|
|
571
|
-
}
|
|
572
|
-
parseEquality(e) {
|
|
573
|
-
let t = this.parseRelational(e);
|
|
574
|
-
for (; this.isPunct("==") || this.isPunct("!=");) {
|
|
575
|
-
let n = t.start, r = this.next().value, i = this.parseRelational(e);
|
|
576
|
-
t = this.node({
|
|
577
|
-
kind: "binary",
|
|
578
|
-
operator: r,
|
|
579
|
-
left: t,
|
|
580
|
-
right: i,
|
|
581
|
-
start: n
|
|
582
|
-
}, e, n);
|
|
583
|
-
}
|
|
584
|
-
return t;
|
|
585
|
-
}
|
|
586
|
-
parseRelational(e) {
|
|
587
|
-
let t = this.parseAdditive(e);
|
|
588
|
-
for (; this.isPunct("<") || this.isPunct("<=") || this.isPunct(">") || this.isPunct(">=");) {
|
|
589
|
-
let n = t.start, r = this.next().value, i = this.parseAdditive(e);
|
|
590
|
-
t = this.node({
|
|
591
|
-
kind: "binary",
|
|
592
|
-
operator: r,
|
|
593
|
-
left: t,
|
|
594
|
-
right: i,
|
|
595
|
-
start: n
|
|
596
|
-
}, e, n);
|
|
597
|
-
}
|
|
598
|
-
return t;
|
|
599
|
-
}
|
|
600
|
-
parseAdditive(e) {
|
|
601
|
-
let t = this.parseMultiplicative(e);
|
|
602
|
-
for (; this.isPunct("+") || this.isPunct("-");) {
|
|
603
|
-
let n = t.start, r = this.next().value, i = this.parseMultiplicative(e);
|
|
604
|
-
t = this.node({
|
|
605
|
-
kind: "binary",
|
|
606
|
-
operator: r,
|
|
607
|
-
left: t,
|
|
608
|
-
right: i,
|
|
609
|
-
start: n
|
|
610
|
-
}, e, n);
|
|
611
|
-
}
|
|
612
|
-
return t;
|
|
613
|
-
}
|
|
614
|
-
parseMultiplicative(e) {
|
|
615
|
-
let t = this.parseUnary(e);
|
|
616
|
-
for (; this.isPunct("*") || this.isPunct("/") || this.isPunct("%");) {
|
|
617
|
-
let n = t.start, r = this.next().value, i = this.parseUnary(e);
|
|
618
|
-
t = this.node({
|
|
619
|
-
kind: "binary",
|
|
620
|
-
operator: r,
|
|
621
|
-
left: t,
|
|
622
|
-
right: i,
|
|
623
|
-
start: n
|
|
624
|
-
}, e, n);
|
|
625
|
-
}
|
|
626
|
-
return t;
|
|
627
|
-
}
|
|
628
|
-
parseUnary(e) {
|
|
629
|
-
let t = this.peek();
|
|
630
|
-
if (t.kind === "punct" && (t.value === "-" || t.value === "+" || t.value === "!")) {
|
|
631
|
-
this.next();
|
|
632
|
-
let n = this.parseUnary(e + 1);
|
|
633
|
-
return this.node({
|
|
634
|
-
kind: "unary",
|
|
635
|
-
operator: t.value,
|
|
636
|
-
operand: n,
|
|
637
|
-
start: t.start
|
|
638
|
-
}, e, t.start);
|
|
639
|
-
}
|
|
640
|
-
return this.parsePrimary(e);
|
|
641
|
-
}
|
|
642
|
-
parsePrimary(e) {
|
|
643
|
-
let t = this.parseAtom(e);
|
|
644
|
-
for (; this.isPunct("[");) {
|
|
645
|
-
let n = t.start;
|
|
646
|
-
this.next();
|
|
647
|
-
let r = this.parseConditional(e + 1);
|
|
648
|
-
this.expect("]"), t = this.node({
|
|
649
|
-
kind: "index",
|
|
650
|
-
target: t,
|
|
651
|
-
index: r,
|
|
652
|
-
start: n
|
|
653
|
-
}, e, n);
|
|
654
|
-
}
|
|
655
|
-
return t;
|
|
656
|
-
}
|
|
657
|
-
parseAtom(e) {
|
|
658
|
-
let t = this.peek();
|
|
659
|
-
if (t.kind === "number") return this.next(), this.node({
|
|
660
|
-
kind: "literal",
|
|
661
|
-
value: t.number,
|
|
662
|
-
start: t.start
|
|
663
|
-
}, e, t.start);
|
|
664
|
-
if (t.kind === "string") return this.next(), this.node({
|
|
665
|
-
kind: "literal",
|
|
666
|
-
value: t.value,
|
|
667
|
-
start: t.start
|
|
668
|
-
}, e, t.start);
|
|
669
|
-
if (t.kind === "ident") {
|
|
670
|
-
this.next();
|
|
671
|
-
let n = t.value;
|
|
672
|
-
if (this.isPunct("(")) {
|
|
673
|
-
if (!Je.has(n)) throw new P("expression-unknown-function", `Unknown function "${n}".`, t.start);
|
|
674
|
-
this.next();
|
|
675
|
-
let r = [];
|
|
676
|
-
if (!this.isPunct(")")) for (r.push(this.parseConditional(e + 1)); this.isPunct(",");) this.next(), r.push(this.parseConditional(e + 1));
|
|
677
|
-
this.expect(")");
|
|
678
|
-
let [i, a] = mt[n];
|
|
679
|
-
if (r.length < i || r.length > a) throw new P("expression-arity", `Function ${n} expects ${i === a ? `${i} ${i === 1 ? "argument" : "arguments"}` : i === 1 ? "at least one argument" : `${i}–${a} arguments`}.`, t.start);
|
|
680
|
-
return this.node({
|
|
681
|
-
kind: "call",
|
|
682
|
-
name: n,
|
|
683
|
-
args: r,
|
|
684
|
-
start: t.start
|
|
685
|
-
}, e, t.start);
|
|
686
|
-
}
|
|
687
|
-
if (n === "true" || n === "false") return this.node({
|
|
688
|
-
kind: "literal",
|
|
689
|
-
value: n === "true",
|
|
690
|
-
start: t.start
|
|
691
|
-
}, e, t.start);
|
|
692
|
-
if (n === "null") return this.node({
|
|
693
|
-
kind: "literal",
|
|
694
|
-
value: null,
|
|
695
|
-
start: t.start
|
|
696
|
-
}, e, t.start);
|
|
697
|
-
let r = Ye.get(n);
|
|
698
|
-
if (r !== void 0) return this.node({
|
|
699
|
-
kind: "literal",
|
|
700
|
-
value: r,
|
|
701
|
-
start: t.start
|
|
702
|
-
}, e, t.start);
|
|
703
|
-
if (Xe.has(n)) throw new P("expression-forbidden-name", `Name "${n}" is not allowed.`, t.start);
|
|
704
|
-
if (Je.has(n)) throw new P("expression-syntax", `Function ${n} must be called with parentheses.`, t.start);
|
|
705
|
-
return this.dependencySet.has(n) || (this.dependencySet.add(n), this.dependencyNames.push(n)), this.node({
|
|
706
|
-
kind: "reference",
|
|
707
|
-
name: n,
|
|
708
|
-
start: t.start
|
|
709
|
-
}, e, t.start);
|
|
710
|
-
}
|
|
711
|
-
if (t.kind === "punct" && t.value === "(") {
|
|
712
|
-
this.next();
|
|
713
|
-
let t = this.parseConditional(e + 1);
|
|
714
|
-
return this.expect(")"), t;
|
|
715
|
-
}
|
|
716
|
-
if (t.kind === "punct" && t.value === "[") {
|
|
717
|
-
this.next();
|
|
718
|
-
let n = [];
|
|
719
|
-
if (!this.isPunct("]")) for (n.push(this.parseConditional(e + 1)); this.isPunct(",");) this.next(), n.push(this.parseConditional(e + 1));
|
|
720
|
-
return this.expect("]"), this.node({
|
|
721
|
-
kind: "array",
|
|
722
|
-
elements: n,
|
|
723
|
-
start: t.start
|
|
724
|
-
}, e, t.start);
|
|
725
|
-
}
|
|
726
|
-
throw new P("expression-syntax", "Expected an expression.", t.start);
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
function I(e) {
|
|
730
|
-
switch (e) {
|
|
731
|
-
case "string": return "string";
|
|
732
|
-
case "number": return "number";
|
|
733
|
-
case "boolean": return "boolean";
|
|
734
|
-
case "null": return "null";
|
|
735
|
-
case "array": return "array";
|
|
736
|
-
case "number-array": return "number array";
|
|
737
|
-
}
|
|
738
|
-
}
|
|
739
|
-
function _t(e) {
|
|
740
|
-
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e == "boolean" ? "boolean" : typeof e == "number" ? "number" : "string";
|
|
741
|
-
}
|
|
742
|
-
function L(e, t) {
|
|
743
|
-
throw new P("expression-type", e, t);
|
|
744
|
-
}
|
|
745
|
-
function R(e, t, n, r) {
|
|
746
|
-
e !== t && L(`${r}, got ${I(e)}.`, n);
|
|
747
|
-
}
|
|
748
|
-
function vt(e, t) {
|
|
749
|
-
return e === t ? e : e === "null" ? t : t === "null" ? e : null;
|
|
750
|
-
}
|
|
751
|
-
function z(e, t) {
|
|
752
|
-
switch (e.kind) {
|
|
753
|
-
case "literal": return _t(e.value);
|
|
754
|
-
case "reference": {
|
|
755
|
-
if (typeof t != "object" || !t || !Object.prototype.hasOwnProperty.call(t, e.name)) throw new P("expression-unknown-name", `Variable "${e.name}" is not declared.`, e.start);
|
|
756
|
-
let n = t[e.name];
|
|
757
|
-
if (typeof n != "string" || !Ze.has(n)) throw new P("expression-value", `Variable "${e.name}" has an invalid type.`, e.start);
|
|
758
|
-
return n;
|
|
759
|
-
}
|
|
760
|
-
case "unary": {
|
|
761
|
-
let n = z(e.operand, t);
|
|
762
|
-
return e.operator === "!" ? (R(n, "boolean", e.start, "Logical not requires a boolean"), "boolean") : (R(n, "number", e.start, `Unary ${e.operator} requires a number`), "number");
|
|
763
|
-
}
|
|
764
|
-
case "binary": {
|
|
765
|
-
let n = z(e.left, t), r = z(e.right, t);
|
|
766
|
-
switch (e.operator) {
|
|
767
|
-
case "+": return n === "number" && r === "number" ? "number" : n === "string" && r === "string" ? "string" : L(`Operator "+" requires two numbers or two strings, got ${I(n)} and ${I(r)}.`, e.start);
|
|
768
|
-
case "-":
|
|
769
|
-
case "*":
|
|
770
|
-
case "/":
|
|
771
|
-
case "%": return R(n, "number", e.start, `Operator "${e.operator}" requires a number`), R(r, "number", e.start, `Operator "${e.operator}" requires a number`), "number";
|
|
772
|
-
case "<":
|
|
773
|
-
case "<=":
|
|
774
|
-
case ">":
|
|
775
|
-
case ">=": return n === "number" && r === "number" || n === "string" && r === "string" ? "boolean" : L(`Comparison operator "${e.operator}" requires two numbers or two strings, got ${I(n)} and ${I(r)}.`, e.start);
|
|
776
|
-
case "==":
|
|
777
|
-
case "!=": return n !== r && n !== "null" && r !== "null" ? L(`Equality comparison requires matching types, got ${I(n)} and ${I(r)}.`, e.start) : "boolean";
|
|
778
|
-
case "&&":
|
|
779
|
-
case "||": return R(n, "boolean", e.start, "Logical operators require booleans"), R(r, "boolean", e.start, "Logical operators require booleans"), "boolean";
|
|
780
|
-
}
|
|
781
|
-
break;
|
|
782
|
-
}
|
|
783
|
-
case "array": {
|
|
784
|
-
if (e.elements.length === 0) return "number-array";
|
|
785
|
-
let n = null;
|
|
786
|
-
for (let r of e.elements) {
|
|
787
|
-
let e = z(r, t);
|
|
788
|
-
if (e !== "string" && e !== "number") return L(`Array literals require string or number elements, got ${I(e)}.`, r.start);
|
|
789
|
-
if (n === null) n = e;
|
|
790
|
-
else if (n !== e) return L(`Array literals require elements of one type, got ${I(n)} and ${I(e)}.`, r.start);
|
|
791
|
-
}
|
|
792
|
-
return n === "string" ? "array" : "number-array";
|
|
793
|
-
}
|
|
794
|
-
case "index": {
|
|
795
|
-
let n = z(e.target, t);
|
|
796
|
-
return R(z(e.index, t), "number", e.start, "Array index must be a number"), n === "array" ? "string" : n === "number-array" ? "number" : L(`Index access requires an array, got ${I(n)}.`, e.start);
|
|
797
|
-
}
|
|
798
|
-
case "conditional": {
|
|
799
|
-
R(z(e.test, t), "boolean", e.start, "Conditional test must be a boolean");
|
|
800
|
-
let n = z(e.consequent, t), r = z(e.alternate, t);
|
|
801
|
-
if (n === "array" && e.alternate.kind === "array" && e.alternate.elements.length === 0 || r === "array" && e.consequent.kind === "array" && e.consequent.elements.length === 0) return "array";
|
|
802
|
-
let i = vt(n, r);
|
|
803
|
-
return i === null ? L(`Conditional branches must have matching types or one null, got ${I(n)} and ${I(r)}.`, e.start) : i;
|
|
804
|
-
}
|
|
805
|
-
case "call": {
|
|
806
|
-
let n = e.args.map((e) => z(e, t));
|
|
807
|
-
switch (e.name) {
|
|
808
|
-
case "abs":
|
|
809
|
-
case "sqrt":
|
|
810
|
-
case "floor":
|
|
811
|
-
case "ceil":
|
|
812
|
-
case "round":
|
|
813
|
-
case "sin":
|
|
814
|
-
case "cos":
|
|
815
|
-
case "tan":
|
|
816
|
-
case "asin":
|
|
817
|
-
case "acos":
|
|
818
|
-
case "atan":
|
|
819
|
-
case "exp":
|
|
820
|
-
case "log": return R(n[0], "number", e.start, `Function ${e.name} requires a number`), "number";
|
|
821
|
-
case "min":
|
|
822
|
-
case "max":
|
|
823
|
-
case "pow":
|
|
824
|
-
case "clamp":
|
|
825
|
-
for (let t of n) R(t, "number", e.start, `Function ${e.name} requires a number`);
|
|
826
|
-
return "number";
|
|
827
|
-
case "len": return n[0] !== "string" && n[0] !== "array" && n[0] !== "number-array" && L(`Function len requires a string or array, got ${I(n[0])}.`, e.start), "number";
|
|
828
|
-
case "contains":
|
|
829
|
-
if (n[0] === "number-array") return R(n[1], "number", e.start, "Function contains requires a numeric member"), "boolean";
|
|
830
|
-
if (n[0] === "string" || n[0] === "array") return R(n[1], "string", e.start, "Function contains requires a string member"), "boolean";
|
|
831
|
-
L(`Function contains requires a string or array, got ${I(n[0])}.`, e.start);
|
|
832
|
-
break;
|
|
833
|
-
case "sum":
|
|
834
|
-
case "average":
|
|
835
|
-
case "minOf":
|
|
836
|
-
case "maxOf": return R(n[0], "number-array", e.start, `Function ${e.name} requires a numeric array`), "number";
|
|
837
|
-
case "formatNumber":
|
|
838
|
-
case "formatPercent":
|
|
839
|
-
case "formatScientific": return n[0] !== "number" && n[0] !== "null" && L(`Function ${e.name} requires a number or null, got ${I(n[0])}.`, e.start), n[1] !== void 0 && R(n[1], "number", e.start, `Function ${e.name} requires numeric fraction digits`), n[2] !== void 0 && R(n[2], "string", e.start, `Function ${e.name} requires a string locale`), e.name === "formatNumber" && n[3] !== void 0 && R(n[3], "boolean", e.start, "Function formatNumber requires a boolean grouping flag"), "string";
|
|
840
|
-
case "formatCurrency": return n[0] !== "number" && n[0] !== "null" && L(`Function formatCurrency requires a number or null, got ${I(n[0])}.`, e.start), n[1] !== void 0 && R(n[1], "string", e.start, "Function formatCurrency requires a string currency code"), n[2] !== void 0 && R(n[2], "number", e.start, "Function formatCurrency requires numeric fraction digits"), n[3] !== void 0 && R(n[3], "string", e.start, "Function formatCurrency requires a string locale"), "string";
|
|
841
|
-
case "trim":
|
|
842
|
-
case "lower":
|
|
843
|
-
case "upper": return R(n[0], "string", e.start, `Function ${e.name} requires a string`), "string";
|
|
844
|
-
case "startsWith":
|
|
845
|
-
case "endsWith": return R(n[0], "string", e.start, `Function ${e.name} requires a string`), R(n[1], "string", e.start, `Function ${e.name} requires a string search value`), "boolean";
|
|
846
|
-
case "replace": return R(n[0], "string", e.start, "Function replace requires a string"), R(n[1], "string", e.start, "Function replace requires a string search value"), R(n[2], "string", e.start, "Function replace requires a string replacement"), "string";
|
|
847
|
-
case "slice": return R(n[0], "string", e.start, "Function slice requires a string"), R(n[1], "number", e.start, "Function slice requires a numeric start index"), n[2] !== void 0 && R(n[2], "number", e.start, "Function slice requires a numeric end index"), "string";
|
|
848
|
-
case "dateCompare": return R(n[0], "string", e.start, "Function dateCompare requires a date string"), R(n[1], "string", e.start, "Function dateCompare requires a date string"), "number";
|
|
849
|
-
case "dateDiff": return R(n[0], "string", e.start, "Function dateDiff requires a date string"), R(n[1], "string", e.start, "Function dateDiff requires a date string"), n[2] !== void 0 && R(n[2], "string", e.start, "Function dateDiff requires a string unit"), "number";
|
|
850
|
-
}
|
|
851
|
-
break;
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
throw new P("expression-type", "Unsupported expression.", 0);
|
|
855
|
-
}
|
|
856
|
-
function B(e, t, n = "expression-eval") {
|
|
857
|
-
throw new P(n, e, t);
|
|
858
|
-
}
|
|
859
|
-
function yt(e) {
|
|
860
|
-
if (typeof e != "object" || !e || Array.isArray(e)) throw new P("expression-value", "Expression environment must be an object.", 0);
|
|
861
|
-
}
|
|
862
|
-
function bt(e, t, n) {
|
|
863
|
-
if (e === null) return null;
|
|
864
|
-
if (typeof e == "string") {
|
|
865
|
-
let r = F(e);
|
|
866
|
-
if (r) throw new P("expression-budget", `Variable "${t}": ${r}`, n);
|
|
867
|
-
return e;
|
|
868
|
-
}
|
|
869
|
-
if (typeof e == "boolean") return e;
|
|
870
|
-
if (typeof e == "number") {
|
|
871
|
-
if (!Number.isFinite(e)) throw new P("expression-value", `Variable "${t}" must be a finite number.`, n);
|
|
872
|
-
return e;
|
|
873
|
-
}
|
|
874
|
-
if (Array.isArray(e)) {
|
|
875
|
-
let r = ct(e);
|
|
876
|
-
if (r) throw new P(r.code, `Variable "${t}": ${r.message}`, n);
|
|
877
|
-
return e;
|
|
878
|
-
}
|
|
879
|
-
throw new P("expression-value", `Variable "${t}" has an invalid value type.`, n);
|
|
880
|
-
}
|
|
881
|
-
function xt(e, t, n) {
|
|
882
|
-
return yt(e), Object.prototype.hasOwnProperty.call(e, t) || B(`Variable "${t}" is not declared.`, n, "expression-unknown-name"), bt(e[t], t, n);
|
|
883
|
-
}
|
|
884
|
-
function V(e, t, n = "Expected a number") {
|
|
885
|
-
return typeof e == "number" && Number.isFinite(e) || B(`${n}.`, t, "expression-type"), e;
|
|
886
|
-
}
|
|
887
|
-
function H(e, t, n = "Expected a boolean") {
|
|
888
|
-
return typeof e != "boolean" && B(`${n}.`, t, "expression-type"), e;
|
|
889
|
-
}
|
|
890
|
-
function U(e, t, n = "Expected a string") {
|
|
891
|
-
return typeof e != "string" && B(`${n}.`, t, "expression-type"), e;
|
|
892
|
-
}
|
|
893
|
-
function W(e, t, n) {
|
|
894
|
-
Array.isArray(e) || B(`${n}.`, t, "expression-type");
|
|
895
|
-
for (let r of e) typeof r == "number" && Number.isFinite(r) || B(`${n}.`, t, "expression-type");
|
|
896
|
-
return e;
|
|
897
|
-
}
|
|
898
|
-
function St(e, t) {
|
|
899
|
-
let n = ct(e);
|
|
900
|
-
return n && B(n.message, t, n.code), e;
|
|
901
|
-
}
|
|
902
|
-
function G(e, t) {
|
|
903
|
-
try {
|
|
904
|
-
return t();
|
|
905
|
-
} catch (t) {
|
|
906
|
-
throw t instanceof O ? new P(t.code, t.message, e) : t;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
function K(e, t) {
|
|
910
|
-
return Number.isNaN(e) && B("The result is undefined.", t, "expression-domain"), Number.isFinite(e) || B("The result is not a finite number.", t, "expression-number"), e;
|
|
911
|
-
}
|
|
912
|
-
function Ct(e, t) {
|
|
913
|
-
let n = Array.from(e), r = Array.from(t), i = Math.min(n.length, r.length);
|
|
914
|
-
for (let e = 0; e < i; e += 1) {
|
|
915
|
-
let t = n[e].codePointAt(0), i = r[e].codePointAt(0);
|
|
916
|
-
if (t !== i) return t < i ? -1 : 1;
|
|
917
|
-
}
|
|
918
|
-
return n.length === r.length ? 0 : n.length < r.length ? -1 : 1;
|
|
919
|
-
}
|
|
920
|
-
function wt(e, t) {
|
|
921
|
-
if (e === t) return !0;
|
|
922
|
-
if (Array.isArray(e) && Array.isArray(t)) {
|
|
923
|
-
if (e.length !== t.length) return !1;
|
|
924
|
-
for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
|
|
925
|
-
return !0;
|
|
926
|
-
}
|
|
927
|
-
return !1;
|
|
928
|
-
}
|
|
929
|
-
function Tt(e, t) {
|
|
930
|
-
return q(e, t, { steps: 0 }, 1);
|
|
931
|
-
}
|
|
932
|
-
function q(e, t, n, r) {
|
|
933
|
-
switch (n.steps += 1, n.steps > rt && B("Expression evaluation exceeded the step limit.", e.start, "expression-budget"), r > it && B("Expression evaluation is nested too deeply.", e.start, "expression-budget"), e.kind) {
|
|
934
|
-
case "literal": return e.value;
|
|
935
|
-
case "reference": return xt(t, e.name, e.start);
|
|
936
|
-
case "unary": {
|
|
937
|
-
let i = q(e.operand, t, n, r + 1);
|
|
938
|
-
if (e.operator === "!") return !H(i, e.start, "Logical not requires a boolean");
|
|
939
|
-
let a = V(i, e.start, `Unary ${e.operator} requires a number`);
|
|
940
|
-
return K(e.operator === "-" ? -a : a, e.start);
|
|
941
|
-
}
|
|
942
|
-
case "binary": {
|
|
943
|
-
if (e.operator === "&&" || e.operator === "||") {
|
|
944
|
-
let i = H(q(e.left, t, n, r + 1), e.start, "Logical operators require booleans");
|
|
945
|
-
return e.operator === "&&" && !i ? !1 : e.operator === "||" && i ? !0 : H(q(e.right, t, n, r + 1), e.start, "Logical operators require booleans");
|
|
946
|
-
}
|
|
947
|
-
let i = q(e.left, t, n, r + 1), a = q(e.right, t, n, r + 1);
|
|
948
|
-
switch (e.operator) {
|
|
949
|
-
case "+":
|
|
950
|
-
if (typeof i == "number" && typeof a == "number") return K(i + a, e.start);
|
|
951
|
-
if (typeof i == "string" && typeof a == "string") {
|
|
952
|
-
let t = i + a;
|
|
953
|
-
return t.length > at && B("String result exceeds the length limit.", e.start, "expression-budget"), t;
|
|
954
|
-
}
|
|
955
|
-
B("Operator \"+\" requires two numbers or two strings.", e.start, "expression-type");
|
|
956
|
-
case "-":
|
|
957
|
-
case "*":
|
|
958
|
-
case "/":
|
|
959
|
-
case "%": {
|
|
960
|
-
let t = V(i, e.start, `Operator "${e.operator}" requires a number`), n = V(a, e.start, `Operator "${e.operator}" requires a number`);
|
|
961
|
-
return (e.operator === "/" || e.operator === "%") && n === 0 && B("Division by zero.", e.start, "expression-divide-by-zero"), K(e.operator === "-" ? t - n : e.operator === "*" ? t * n : e.operator === "/" ? t / n : t % n, e.start);
|
|
962
|
-
}
|
|
963
|
-
case "==":
|
|
964
|
-
case "!=": {
|
|
965
|
-
let t = _t(i), n = _t(a);
|
|
966
|
-
t !== n && t !== "null" && n !== "null" && B("Equality comparison requires matching types.", e.start, "expression-type");
|
|
967
|
-
let r = wt(i, a);
|
|
968
|
-
return e.operator === "==" ? r : !r;
|
|
969
|
-
}
|
|
970
|
-
case "<":
|
|
971
|
-
case "<=":
|
|
972
|
-
case ">":
|
|
973
|
-
case ">=": {
|
|
974
|
-
let t;
|
|
975
|
-
return typeof i == "number" && typeof a == "number" ? t = i === a ? 0 : i < a ? -1 : 1 : typeof i == "string" && typeof a == "string" ? t = Ct(i, a) : B(`Comparison operator "${e.operator}" requires two numbers or two strings.`, e.start, "expression-type"), e.operator === "<" ? t < 0 : e.operator === "<=" ? t <= 0 : e.operator === ">" ? t > 0 : t >= 0;
|
|
976
|
-
}
|
|
977
|
-
}
|
|
978
|
-
break;
|
|
979
|
-
}
|
|
980
|
-
case "conditional": return q(H(q(e.test, t, n, r + 1), e.start, "Conditional test must be a boolean") ? e.consequent : e.alternate, t, n, r + 1);
|
|
981
|
-
case "array": {
|
|
982
|
-
let i = [];
|
|
983
|
-
for (let a of e.elements) i.push(q(a, t, n, r + 1));
|
|
984
|
-
return St(i, e.start);
|
|
985
|
-
}
|
|
986
|
-
case "index": {
|
|
987
|
-
let i = q(e.target, t, n, r + 1), a = V(q(e.index, t, n, r + 1), e.start, "Array index must be a number");
|
|
988
|
-
return Number.isSafeInteger(a) || B("Array index must be a finite integer.", e.start, "expression-index"), Array.isArray(i) || B("Index access requires an array.", e.start, "expression-type"), a < 0 || a >= i.length ? null : i[a];
|
|
989
|
-
}
|
|
990
|
-
case "call": {
|
|
991
|
-
let i = e.args.map((e) => q(e, t, n, r + 1));
|
|
992
|
-
switch (e.name) {
|
|
993
|
-
case "abs":
|
|
994
|
-
case "sqrt":
|
|
995
|
-
case "floor":
|
|
996
|
-
case "ceil":
|
|
997
|
-
case "round":
|
|
998
|
-
case "sin":
|
|
999
|
-
case "cos":
|
|
1000
|
-
case "tan":
|
|
1001
|
-
case "asin":
|
|
1002
|
-
case "acos":
|
|
1003
|
-
case "atan":
|
|
1004
|
-
case "exp":
|
|
1005
|
-
case "log": {
|
|
1006
|
-
let t = V(i[0], e.start, `Function ${e.name} requires a number`);
|
|
1007
|
-
e.name === "sqrt" && t < 0 && B("sqrt requires a non-negative argument.", e.start, "expression-domain"), e.name === "log" && t <= 0 && B("log requires a positive argument.", e.start, "expression-domain"), (e.name === "asin" || e.name === "acos") && (t < -1 || t > 1) && B(`${e.name} requires an argument between -1 and 1.`, e.start, "expression-domain");
|
|
1008
|
-
let n;
|
|
1009
|
-
switch (e.name) {
|
|
1010
|
-
case "abs":
|
|
1011
|
-
n = Math.abs(t);
|
|
1012
|
-
break;
|
|
1013
|
-
case "sqrt":
|
|
1014
|
-
n = Math.sqrt(t);
|
|
1015
|
-
break;
|
|
1016
|
-
case "floor":
|
|
1017
|
-
n = Math.floor(t);
|
|
1018
|
-
break;
|
|
1019
|
-
case "ceil":
|
|
1020
|
-
n = Math.ceil(t);
|
|
1021
|
-
break;
|
|
1022
|
-
case "round":
|
|
1023
|
-
n = Math.round(t);
|
|
1024
|
-
break;
|
|
1025
|
-
case "sin":
|
|
1026
|
-
n = Math.sin(t);
|
|
1027
|
-
break;
|
|
1028
|
-
case "cos":
|
|
1029
|
-
n = Math.cos(t);
|
|
1030
|
-
break;
|
|
1031
|
-
case "tan":
|
|
1032
|
-
n = Math.tan(t);
|
|
1033
|
-
break;
|
|
1034
|
-
case "asin":
|
|
1035
|
-
n = Math.asin(t);
|
|
1036
|
-
break;
|
|
1037
|
-
case "acos":
|
|
1038
|
-
n = Math.acos(t);
|
|
1039
|
-
break;
|
|
1040
|
-
case "atan":
|
|
1041
|
-
n = Math.atan(t);
|
|
1042
|
-
break;
|
|
1043
|
-
case "exp":
|
|
1044
|
-
n = Math.exp(t);
|
|
1045
|
-
break;
|
|
1046
|
-
default: n = Math.log(t);
|
|
1047
|
-
}
|
|
1048
|
-
return K(n, e.start);
|
|
1049
|
-
}
|
|
1050
|
-
case "min":
|
|
1051
|
-
case "max": {
|
|
1052
|
-
let t = V(i[0], e.start, `Function ${e.name} requires a number`);
|
|
1053
|
-
for (let n = 1; n < i.length; n += 1) {
|
|
1054
|
-
let r = V(i[n], e.start, `Function ${e.name} requires a number`);
|
|
1055
|
-
t = e.name === "min" ? Math.min(t, r) : Math.max(t, r);
|
|
1056
|
-
}
|
|
1057
|
-
return K(t, e.start);
|
|
1058
|
-
}
|
|
1059
|
-
case "pow": return K(V(i[0], e.start, "Function pow requires a number") ** +V(i[1], e.start, "Function pow requires a number"), e.start);
|
|
1060
|
-
case "clamp": {
|
|
1061
|
-
let t = V(i[0], e.start, "Function clamp requires a number"), n = V(i[1], e.start, "Function clamp requires a number"), r = V(i[2], e.start, "Function clamp requires a number");
|
|
1062
|
-
return n > r && B("clamp lower bound cannot exceed upper bound.", e.start, "expression-domain"), K(Math.min(r, Math.max(n, t)), e.start);
|
|
1063
|
-
}
|
|
1064
|
-
case "len": {
|
|
1065
|
-
let t = i[0];
|
|
1066
|
-
if (typeof t == "string") return fe(t);
|
|
1067
|
-
if (Array.isArray(t)) return t.length;
|
|
1068
|
-
B("Function len requires a string or array.", e.start, "expression-type");
|
|
1069
|
-
}
|
|
1070
|
-
case "contains": {
|
|
1071
|
-
let t = i[0], n = i[1];
|
|
1072
|
-
if (typeof t == "string") return t.includes(U(n, e.start, "Function contains requires a string member"));
|
|
1073
|
-
if (Array.isArray(t)) {
|
|
1074
|
-
if (typeof n == "string") {
|
|
1075
|
-
for (let n of t) typeof n != "string" && B("Function contains requires a string member for a string array.", e.start, "expression-type");
|
|
1076
|
-
return t.includes(n);
|
|
1077
|
-
}
|
|
1078
|
-
if (typeof n == "number" && Number.isFinite(n)) {
|
|
1079
|
-
for (let n of t) typeof n != "number" && B("Function contains requires a numeric member for a numeric array.", e.start, "expression-type");
|
|
1080
|
-
return t.includes(n);
|
|
1081
|
-
}
|
|
1082
|
-
B("Function contains requires a string or numeric member.", e.start, "expression-type");
|
|
1083
|
-
}
|
|
1084
|
-
B("Function contains requires a string or array.", e.start, "expression-type");
|
|
1085
|
-
}
|
|
1086
|
-
case "sum": {
|
|
1087
|
-
let t = W(i[0], e.start, "Function sum requires a numeric array");
|
|
1088
|
-
return G(e.start, () => ke(t));
|
|
1089
|
-
}
|
|
1090
|
-
case "average": {
|
|
1091
|
-
let t = W(i[0], e.start, "Function average requires a numeric array");
|
|
1092
|
-
return G(e.start, () => Ae(t));
|
|
1093
|
-
}
|
|
1094
|
-
case "minOf": {
|
|
1095
|
-
let t = W(i[0], e.start, "Function minOf requires a numeric array");
|
|
1096
|
-
return G(e.start, () => je(t));
|
|
1097
|
-
}
|
|
1098
|
-
case "maxOf": {
|
|
1099
|
-
let t = W(i[0], e.start, "Function maxOf requires a numeric array");
|
|
1100
|
-
return G(e.start, () => Me(t));
|
|
1101
|
-
}
|
|
1102
|
-
case "formatNumber": {
|
|
1103
|
-
let t = i[0] === null ? null : V(i[0], e.start, "Function formatNumber requires a number or null"), n = i[1] === void 0 ? 2 : V(i[1], e.start, "Function formatNumber requires numeric fraction digits"), r = i[2] === void 0 ? "en-US" : U(i[2], e.start, "Function formatNumber requires a string locale"), a = i[3] === void 0 || H(i[3], e.start, "Function formatNumber requires a boolean grouping flag");
|
|
1104
|
-
return G(e.start, () => we(t, n, r, a));
|
|
1105
|
-
}
|
|
1106
|
-
case "formatPercent": {
|
|
1107
|
-
let t = i[0] === null ? null : V(i[0], e.start, "Function formatPercent requires a number or null"), n = i[1] === void 0 ? 0 : V(i[1], e.start, "Function formatPercent requires numeric fraction digits"), r = i[2] === void 0 ? "en-US" : U(i[2], e.start, "Function formatPercent requires a string locale");
|
|
1108
|
-
return G(e.start, () => Te(t, n, r));
|
|
1109
|
-
}
|
|
1110
|
-
case "formatScientific": {
|
|
1111
|
-
let t = i[0] === null ? null : V(i[0], e.start, "Function formatScientific requires a number or null"), n = i[1] === void 0 ? 2 : V(i[1], e.start, "Function formatScientific requires numeric fraction digits"), r = i[2] === void 0 ? "en-US" : U(i[2], e.start, "Function formatScientific requires a string locale");
|
|
1112
|
-
return G(e.start, () => Ee(t, n, r));
|
|
1113
|
-
}
|
|
1114
|
-
case "formatCurrency": {
|
|
1115
|
-
let t = i[0] === null ? null : V(i[0], e.start, "Function formatCurrency requires a number or null"), n = i[1] === void 0 ? "USD" : U(i[1], e.start, "Function formatCurrency requires a string currency code"), r = i[2] === void 0 ? 2 : V(i[2], e.start, "Function formatCurrency requires numeric fraction digits"), a = i[3] === void 0 ? "en-US" : U(i[3], e.start, "Function formatCurrency requires a string locale");
|
|
1116
|
-
return G(e.start, () => De(t, n, r, a));
|
|
1117
|
-
}
|
|
1118
|
-
case "trim": return G(e.start, () => Fe(U(i[0], e.start, "Function trim requires a string")));
|
|
1119
|
-
case "lower": return G(e.start, () => Ie(U(i[0], e.start, "Function lower requires a string")));
|
|
1120
|
-
case "upper": return G(e.start, () => Le(U(i[0], e.start, "Function upper requires a string")));
|
|
1121
|
-
case "startsWith": return G(e.start, () => Re(U(i[0], e.start, "Function startsWith requires a string"), U(i[1], e.start, "Function startsWith requires a string search value")));
|
|
1122
|
-
case "endsWith": return G(e.start, () => ze(U(i[0], e.start, "Function endsWith requires a string"), U(i[1], e.start, "Function endsWith requires a string search value")));
|
|
1123
|
-
case "replace": {
|
|
1124
|
-
let t = U(i[0], e.start, "Function replace requires a string"), n = U(i[1], e.start, "Function replace requires a string search value"), r = U(i[2], e.start, "Function replace requires a string replacement");
|
|
1125
|
-
return G(e.start, () => Be(t, n, r));
|
|
1126
|
-
}
|
|
1127
|
-
case "slice": {
|
|
1128
|
-
let t = U(i[0], e.start, "Function slice requires a string"), n = V(i[1], e.start, "Function slice requires a numeric start index"), r = i[2] === void 0 ? void 0 : V(i[2], e.start, "Function slice requires a numeric end index");
|
|
1129
|
-
return G(e.start, () => He(t, n, r));
|
|
1130
|
-
}
|
|
1131
|
-
case "dateCompare": {
|
|
1132
|
-
let t = U(i[0], e.start, "Function dateCompare requires a date string"), n = U(i[1], e.start, "Function dateCompare requires a date string");
|
|
1133
|
-
return G(e.start, () => Ge(t, n));
|
|
1134
|
-
}
|
|
1135
|
-
case "dateDiff": {
|
|
1136
|
-
let t = U(i[0], e.start, "Function dateDiff requires a date string"), n = U(i[1], e.start, "Function dateDiff requires a date string"), r = i[2] === void 0 ? "days" : U(i[2], e.start, "Function dateDiff requires a string unit");
|
|
1137
|
-
return G(e.start, () => Ke(t, n, r));
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
break;
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
|
-
throw new P("expression-eval", "Unsupported expression.", 0);
|
|
1144
|
-
}
|
|
1145
|
-
var J = /* @__PURE__ */ new Map();
|
|
1146
|
-
function Et(e) {
|
|
1147
|
-
if (typeof e != "string") throw new P("expression-syntax", "Expression must be a string.", 0);
|
|
1148
|
-
if (e.length > $e) throw new P("expression-budget", `Expression exceeds the ${$e}-character limit.`, 0);
|
|
1149
|
-
let t = J.get(e);
|
|
1150
|
-
if (t) return t;
|
|
1151
|
-
let n = new gt(e), r = n.parse(), i = [...n.dependencies], a = Object.freeze({
|
|
1152
|
-
source: e,
|
|
1153
|
-
dependencies: i,
|
|
1154
|
-
evaluate(e) {
|
|
1155
|
-
return Tt(r, e);
|
|
1156
|
-
},
|
|
1157
|
-
inferType(e) {
|
|
1158
|
-
return z(r, e);
|
|
1159
|
-
}
|
|
1160
|
-
});
|
|
1161
|
-
if (J.size >= st) {
|
|
1162
|
-
let e = J.keys().next().value;
|
|
1163
|
-
e !== void 0 && J.delete(e);
|
|
1164
|
-
}
|
|
1165
|
-
return J.set(e, a), a;
|
|
1166
|
-
}
|
|
1167
|
-
function Dt(e) {
|
|
1168
|
-
if (e.length > ot) throw new P("expression-budget", "Interpolation template exceeds the length limit.", 0);
|
|
1169
|
-
let t = [], n = 0;
|
|
1170
|
-
for (;;) {
|
|
1171
|
-
let r = e.indexOf("{{", n);
|
|
1172
|
-
if (r < 0) {
|
|
1173
|
-
n < e.length && t.push({
|
|
1174
|
-
kind: "text",
|
|
1175
|
-
value: e.slice(n)
|
|
1176
|
-
});
|
|
1177
|
-
break;
|
|
1178
|
-
}
|
|
1179
|
-
r > n && t.push({
|
|
1180
|
-
kind: "text",
|
|
1181
|
-
value: e.slice(n, r)
|
|
1182
|
-
});
|
|
1183
|
-
let i = r + 2, a = "", o = !1;
|
|
1184
|
-
for (; i < e.length;) {
|
|
1185
|
-
let t = e[i];
|
|
1186
|
-
if (a !== "") {
|
|
1187
|
-
if (t === "\\") {
|
|
1188
|
-
i += 2;
|
|
1189
|
-
continue;
|
|
1190
|
-
}
|
|
1191
|
-
t === a && (a = ""), i += 1;
|
|
1192
|
-
} else if (t === "\"" || t === "'") a = t, i += 1;
|
|
1193
|
-
else {
|
|
1194
|
-
if (t === "{" && e[i + 1] === "{") throw new P("expression-interpolation", "Interpolations cannot be nested.", i);
|
|
1195
|
-
if (t === "}" && e[i + 1] === "}") {
|
|
1196
|
-
o = !0;
|
|
1197
|
-
break;
|
|
1198
|
-
}
|
|
1199
|
-
i += 1;
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
if (!o) throw new P("expression-interpolation", "Interpolation is missing }}.", r);
|
|
1203
|
-
let s = e.slice(r + 2, i);
|
|
1204
|
-
if (s.trim() === "") throw new P("expression-empty", "Interpolation expression is empty.", r + 2);
|
|
1205
|
-
t.push({
|
|
1206
|
-
kind: "expression",
|
|
1207
|
-
source: s,
|
|
1208
|
-
start: r + 2
|
|
1209
|
-
}), n = i + 2;
|
|
1210
|
-
}
|
|
1211
|
-
return t;
|
|
1212
|
-
}
|
|
1213
|
-
function Ot(e) {
|
|
1214
|
-
try {
|
|
1215
|
-
return Et(e.source);
|
|
1216
|
-
} catch (t) {
|
|
1217
|
-
throw t instanceof P ? new P(t.code, t.message, e.start + t.offset) : t;
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
function kt(e, t, n) {
|
|
1221
|
-
try {
|
|
1222
|
-
return e.evaluate(t);
|
|
1223
|
-
} catch (e) {
|
|
1224
|
-
throw e instanceof P ? new P(e.code, e.message, n + e.offset) : e;
|
|
1225
|
-
}
|
|
1226
|
-
}
|
|
1227
|
-
function At(e, t) {
|
|
1228
|
-
if (e === null) return "";
|
|
1229
|
-
if (typeof e == "string") return e;
|
|
1230
|
-
if (typeof e == "number") {
|
|
1231
|
-
if (!Number.isFinite(e)) throw new P("expression-value", "Cannot display a non-finite number.", t);
|
|
1232
|
-
return String(e);
|
|
1233
|
-
}
|
|
1234
|
-
if (typeof e == "boolean") return e ? "true" : "false";
|
|
1235
|
-
throw Array.isArray(e) ? new P("expression-type", "Cannot insert an array as text; convert it with a function such as len first.", t) : new P("expression-type", "Cannot display this value as text.", t);
|
|
1236
|
-
}
|
|
1237
|
-
function jt(e, t) {
|
|
1238
|
-
let n = [], r = 0;
|
|
1239
|
-
for (let i of e) {
|
|
1240
|
-
let e;
|
|
1241
|
-
if (e = i.kind === "text" ? i.value : At(kt(Ot(i), t, i.start), i.start), r += e.length, r > at) throw new P("expression-budget", "Interpolation result exceeds the length limit.", 0);
|
|
1242
|
-
n.push(e);
|
|
1243
|
-
}
|
|
1244
|
-
return n.join("");
|
|
1245
|
-
}
|
|
1246
|
-
function Mt(e, t) {
|
|
1247
|
-
if (typeof e != "string") throw new P("expression-interpolation", "Interpolation template must be a string.", 0);
|
|
1248
|
-
if (e.length > ot) throw new P("expression-budget", `Interpolation template exceeds the ${ot}-character limit.`, 0);
|
|
1249
|
-
return e.includes("{{") ? jt(Dt(e), t) : e;
|
|
1250
|
-
}
|
|
1251
|
-
function Nt(e) {
|
|
1252
|
-
if (typeof e != "string") throw new P("expression-interpolation", "Interpolation template must be a string.", 0);
|
|
1253
|
-
let t = /* @__PURE__ */ new Set();
|
|
1254
|
-
for (let n of Dt(e)) if (n.kind === "expression") for (let e of Ot(n).dependencies) t.add(e);
|
|
1255
|
-
return [...t];
|
|
1256
|
-
}
|
|
1257
|
-
// src/local/source/node-walk.ts
|
|
1258
|
-
function* Pt(e, t = !1) {
|
|
1259
|
-
let n = [{
|
|
1260
|
-
nodes: e,
|
|
1261
|
-
index: 0
|
|
1262
|
-
}];
|
|
1263
|
-
for (; n.length;) {
|
|
1264
|
-
let e = n[n.length - 1];
|
|
1265
|
-
if (e.index === e.nodes.length) {
|
|
1266
|
-
n.pop(), t && e.owner && (yield e.owner);
|
|
1267
|
-
continue;
|
|
1268
|
-
}
|
|
1269
|
-
let r = e.nodes[e.index++];
|
|
1270
|
-
t || (yield r), r.children?.length ? n.push({
|
|
1271
|
-
nodes: r.children,
|
|
1272
|
-
index: 0,
|
|
1273
|
-
owner: r
|
|
1274
|
-
}) : t && (yield r);
|
|
1275
|
-
}
|
|
1276
|
-
}
|
|
1277
|
-
// src/local/evaluation/computations.ts
|
|
1278
|
-
function Ft(e, t, n, r = "local.expression") {
|
|
1279
|
-
t instanceof P ? e(`${r}.${t.code || "invalid"}`, `Expression error: ${t.message}`, n + (Number.isFinite(t.offset) ? t.offset : 0)) : e(`${r}.invalid`, `Expression error: ${t instanceof Error ? t.message : String(t)}`, n);
|
|
1280
|
-
}
|
|
1281
|
-
function It(e) {
|
|
1282
|
-
return e instanceof P ? e : new P("expression-eval", e instanceof Error ? e.message : String(e), 0);
|
|
1283
|
-
}
|
|
1284
|
-
function Lt(e, t) {
|
|
1285
|
-
let n = new Set(e), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
1286
|
-
for (let t of e) r.set(t, 0);
|
|
1287
|
-
for (let a of e) for (let e of t(a)) {
|
|
1288
|
-
if (!n.has(e)) continue;
|
|
1289
|
-
r.set(a, (r.get(a) ?? 0) + 1);
|
|
1290
|
-
let t = i.get(e);
|
|
1291
|
-
t ? t.push(a) : i.set(e, [a]);
|
|
1292
|
-
}
|
|
1293
|
-
let a = [];
|
|
1294
|
-
for (let t of e) (r.get(t) ?? 0) === 0 && a.push(t);
|
|
1295
|
-
let o = [];
|
|
1296
|
-
for (let e = 0; e < a.length; e += 1) {
|
|
1297
|
-
let t = a[e];
|
|
1298
|
-
o.push(t);
|
|
1299
|
-
for (let e of i.get(t) ?? []) {
|
|
1300
|
-
let t = (r.get(e) ?? 0) - 1;
|
|
1301
|
-
r.set(e, t), t === 0 && a.push(e);
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
let s = new Set(o);
|
|
1305
|
-
return {
|
|
1306
|
-
order: o,
|
|
1307
|
-
cyclic: e.filter((e) => !s.has(e))
|
|
1308
|
-
};
|
|
1309
|
-
}
|
|
1310
|
-
function Rt(e) {
|
|
1311
|
-
let t = Object.keys(e), n = new Set(t);
|
|
1312
|
-
return Lt(t, (t) => {
|
|
1313
|
-
let r = e[t];
|
|
1314
|
-
return r ? r.dependencies.filter((e) => n.has(e)) : [];
|
|
1315
|
-
});
|
|
1316
|
-
}
|
|
1317
|
-
function zt(e, t, n, r = /* @__PURE__ */ new Set(), i) {
|
|
1318
|
-
let a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = [], l = /* @__PURE__ */ new Set();
|
|
1319
|
-
for (let t of e) s.has(t.name) || (s.set(t.name, t), c.push(t.name));
|
|
1320
|
-
let u = new Set(c);
|
|
1321
|
-
for (let e of c) {
|
|
1322
|
-
let t = s.get(e), r;
|
|
1323
|
-
try {
|
|
1324
|
-
r = i?.expression(t.source) ?? Et(t.source);
|
|
1325
|
-
} catch (r) {
|
|
1326
|
-
Ft(n, r, t.expressionOffset), l.add(e);
|
|
1327
|
-
continue;
|
|
1328
|
-
}
|
|
1329
|
-
a.set(e, r), o.set(e, [...r.dependencies]);
|
|
1330
|
-
}
|
|
1331
|
-
for (let e of c) if (!l.has(e)) {
|
|
1332
|
-
for (let r of o.get(e) ?? []) if (!(u.has(r) || Object.hasOwn(t, r))) {
|
|
1333
|
-
n("local.computation.unknown", `Reference to undeclared parameter ${r} in computation "${e}".`, s.get(e).expressionOffset + Math.max(0, s.get(e).source.indexOf(r))), l.add(e);
|
|
1334
|
-
break;
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
let d = /* @__PURE__ */ new Set();
|
|
1338
|
-
for (let e of c) {
|
|
1339
|
-
if (l.has(e)) continue;
|
|
1340
|
-
let i = s.get(e);
|
|
1341
|
-
if (i.kind === "const") for (let a of o.get(e) ?? []) {
|
|
1342
|
-
let o = u.has(a) ? s.get(a).kind : null;
|
|
1343
|
-
Object.hasOwn(t, a) ? (n("local.computation.const", `Constant "${e}" cannot depend on ${r.has(a) ? "external data" : "control parameter"} "${a}".`, i.expressionOffset + Math.max(0, i.source.indexOf(a))), d.add(e)) : o === "computed" && (n("local.computation.const", `Constant "${e}" cannot depend on computed value "${a}".`, i.expressionOffset + Math.max(0, i.source.indexOf(a))), d.add(e));
|
|
1344
|
-
}
|
|
1345
|
-
}
|
|
1346
|
-
let { order: f, cyclic: p } = Lt(c, (e) => o.get(e) ?? []);
|
|
1347
|
-
if (p.length > 0) {
|
|
1348
|
-
let e = new Set(p), t = [], r = /* @__PURE__ */ new Map(), i = p[0];
|
|
1349
|
-
for (; !r.has(i);) {
|
|
1350
|
-
r.set(i, t.length), t.push(i);
|
|
1351
|
-
let n = (o.get(i) ?? []).find((t) => e.has(t));
|
|
1352
|
-
if (n === void 0) break;
|
|
1353
|
-
i = n;
|
|
1354
|
-
}
|
|
1355
|
-
let a = r.has(i) ? t.slice(r.get(i)) : [p[0]], c = a.slice(0, 12).join(" → ") + (a.length > 12 ? " → …" : ` → ${a[0]}`);
|
|
1356
|
-
for (let e of a.slice(0, 100)) {
|
|
1357
|
-
let t = s.get(e);
|
|
1358
|
-
n("local.computation.cycle", `Computation "${e}" is part of a dependency cycle: ${c}.`, t.range.start, t.range.end);
|
|
1359
|
-
}
|
|
1360
|
-
for (let e of p) l.add(e);
|
|
1361
|
-
}
|
|
1362
|
-
for (let e of f) if (!l.has(e) && !(s.get(e).kind !== "const" || d.has(e)) && (o.get(e) ?? []).some((e) => u.has(e) ? s.get(e).kind === "const" && d.has(e) : !1)) {
|
|
1363
|
-
let t = s.get(e);
|
|
1364
|
-
n("local.computation.const", `Constant "${e}" indirectly depends on a value that is not a constant.`, t.expressionOffset), d.add(e);
|
|
1365
|
-
}
|
|
1366
|
-
let m = {}, h = { ...t };
|
|
1367
|
-
for (let e of f) {
|
|
1368
|
-
if (l.has(e)) continue;
|
|
1369
|
-
let t = s.get(e);
|
|
1370
|
-
if ((o.get(e) ?? []).some((e) => l.has(e))) {
|
|
1371
|
-
l.add(e);
|
|
1372
|
-
continue;
|
|
1373
|
-
}
|
|
1374
|
-
let r = a.get(e);
|
|
1375
|
-
try {
|
|
1376
|
-
let t = i ? i.infer(r, h) : r.inferType(h);
|
|
1377
|
-
m[e] = t, h[e] = t;
|
|
1378
|
-
} catch (r) {
|
|
1379
|
-
Ft(n, r, t.expressionOffset), l.add(e);
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
let g = {}, _ = {};
|
|
1383
|
-
for (let e of f) {
|
|
1384
|
-
if (l.has(e) || s.get(e).kind !== "const" || d.has(e)) continue;
|
|
1385
|
-
let t = s.get(e), r = a.get(e);
|
|
1386
|
-
try {
|
|
1387
|
-
let i = r.evaluate(_), a = F(i);
|
|
1388
|
-
if (a) {
|
|
1389
|
-
n("local.computation.budget", `Constant "${e}": ${a}`, t.expressionOffset), l.add(e);
|
|
1390
|
-
continue;
|
|
1391
|
-
}
|
|
1392
|
-
g[e] = Array.isArray(i) ? i.slice() : i, _[e] = g[e];
|
|
1393
|
-
} catch (r) {
|
|
1394
|
-
let i = It(r);
|
|
1395
|
-
n("local.computation.expression", `Constant "${e}" cannot be evaluated: ${i.message}`, t.expressionOffset + (Number.isFinite(i.offset) ? i.offset : 0)), l.add(e);
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
let v = {};
|
|
1399
|
-
for (let e of c) {
|
|
1400
|
-
let t = s.get(e);
|
|
1401
|
-
if (l.has(e) || m[e] === void 0) continue;
|
|
1402
|
-
let n = {
|
|
1403
|
-
name: e,
|
|
1404
|
-
kind: t.kind,
|
|
1405
|
-
source: t.source,
|
|
1406
|
-
dependencies: [...o.get(e) ?? []],
|
|
1407
|
-
type: m[e],
|
|
1408
|
-
nodeId: t.nodeId,
|
|
1409
|
-
range: { ...t.range }
|
|
1410
|
-
};
|
|
1411
|
-
t.kind === "const" && Object.hasOwn(g, e) && (n.value = g[e]), v[e] = n;
|
|
1412
|
-
}
|
|
1413
|
-
return {
|
|
1414
|
-
computations: v,
|
|
1415
|
-
kinds: m,
|
|
1416
|
-
order: f.filter((e) => !l.has(e)),
|
|
1417
|
-
expressions: a,
|
|
1418
|
-
constValues: g
|
|
1419
|
-
};
|
|
1420
|
-
}
|
|
1421
|
-
function Bt(e, t, n, r, i, a = /* @__PURE__ */ new Map()) {
|
|
1422
|
-
let o = {}, s = /* @__PURE__ */ new Map(), c = {};
|
|
1423
|
-
for (let [e, t] of Object.entries(r)) c[e] = t;
|
|
1424
|
-
for (let [e, t] of a) Object.defineProperty(c, e, {
|
|
1425
|
-
enumerable: !0,
|
|
1426
|
-
configurable: !0,
|
|
1427
|
-
get() {
|
|
1428
|
-
throw t;
|
|
1429
|
-
}
|
|
1430
|
-
});
|
|
1431
|
-
for (let [e, t] of Object.entries(i)) o[e] = t, c[e] = t;
|
|
1432
|
-
for (let r of t) {
|
|
1433
|
-
let t = e[r];
|
|
1434
|
-
if (!t || t.kind === "const") continue;
|
|
1435
|
-
let i = n.get(r);
|
|
1436
|
-
if (i) try {
|
|
1437
|
-
let e = i.evaluate(c), t = F(e);
|
|
1438
|
-
if (t) throw new P("expression-budget", t, 0);
|
|
1439
|
-
o[r] = e, c[r] = e;
|
|
1440
|
-
} catch (e) {
|
|
1441
|
-
let t = It(e);
|
|
1442
|
-
s.set(r, t), Object.defineProperty(c, r, {
|
|
1443
|
-
enumerable: !0,
|
|
1444
|
-
configurable: !0,
|
|
1445
|
-
get() {
|
|
1446
|
-
throw t;
|
|
1447
|
-
}
|
|
1448
|
-
});
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
return {
|
|
1452
|
-
values: o,
|
|
1453
|
-
errors: s
|
|
1454
|
-
};
|
|
1455
|
-
}
|
|
1456
|
-
// node_modules/devlop/lib/default.js
|
|
1457
|
-
function Vt() {}
|
|
1458
|
-
// node_modules/mdast-util-to-string/lib/index.js
|
|
1459
|
-
var Ht = {};
|
|
1460
|
-
function Ut(e, t) {
|
|
1461
|
-
let n = t || Ht;
|
|
1462
|
-
return Wt(e, typeof n.includeImageAlt != "boolean" || n.includeImageAlt, typeof n.includeHtml != "boolean" || n.includeHtml);
|
|
1463
|
-
}
|
|
1464
|
-
function Wt(e, t, n) {
|
|
1465
|
-
if (Kt(e)) {
|
|
1466
|
-
if ("value" in e) return e.type === "html" && !n ? "" : e.value;
|
|
1467
|
-
if (t && "alt" in e && e.alt) return e.alt;
|
|
1468
|
-
if ("children" in e) return Gt(e.children, t, n);
|
|
1469
|
-
}
|
|
1470
|
-
return Array.isArray(e) ? Gt(e, t, n) : "";
|
|
1471
|
-
}
|
|
1472
|
-
function Gt(e, t, n) {
|
|
1473
|
-
let r = [], i = -1;
|
|
1474
|
-
for (; ++i < e.length;) r[i] = Wt(e[i], t, n);
|
|
1475
|
-
return r.join("");
|
|
1476
|
-
}
|
|
1477
|
-
function Kt(e) {
|
|
1478
|
-
return !!(e && typeof e == "object");
|
|
1479
|
-
}
|
|
1480
|
-
// node_modules/micromark-util-chunked/index.js
|
|
1481
|
-
function qt(e, t, n, r) {
|
|
1482
|
-
let i = e.length, a = 0, o;
|
|
1483
|
-
if (t = t < 0 ? -t > i ? 0 : i + t : t > i ? i : t, n = n > 0 ? n : 0, r.length < 1e4) o = Array.from(r), o.unshift(t, n), e.splice(...o);
|
|
1484
|
-
else for (n && e.splice(t, n); a < r.length;) o = r.slice(a, a + 1e4), o.unshift(t, 0), e.splice(...o), a += 1e4, t += 1e4;
|
|
1485
|
-
}
|
|
1486
|
-
function Jt(e, t) {
|
|
1487
|
-
return e.length > 0 ? (qt(e, e.length, 0, t), e) : t;
|
|
1488
|
-
}
|
|
1489
|
-
// node_modules/micromark-util-combine-extensions/index.js
|
|
1490
|
-
var Yt = {}.hasOwnProperty;
|
|
1491
|
-
function Xt(e) {
|
|
1492
|
-
let t = {}, n = -1;
|
|
1493
|
-
for (; ++n < e.length;) Zt(t, e[n]);
|
|
1494
|
-
return t;
|
|
1495
|
-
}
|
|
1496
|
-
function Zt(e, t) {
|
|
1497
|
-
let n;
|
|
1498
|
-
for (n in t) {
|
|
1499
|
-
let r = (Yt.call(e, n) ? e[n] : void 0) || (e[n] = {}), i = t[n], a;
|
|
1500
|
-
if (i) for (a in i) {
|
|
1501
|
-
Yt.call(r, a) || (r[a] = []);
|
|
1502
|
-
let e = i[a];
|
|
1503
|
-
Qt(r[a], Array.isArray(e) ? e : e ? [e] : []);
|
|
1504
|
-
}
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
function Qt(e, t) {
|
|
1508
|
-
let n = -1, r = [];
|
|
1509
|
-
for (; ++n < t.length;) (t[n].add === "after" ? e : r).push(t[n]);
|
|
1510
|
-
qt(e, 0, 0, r);
|
|
1511
|
-
}
|
|
1512
|
-
// node_modules/micromark-util-normalize-identifier/index.js
|
|
1513
|
-
function $t(e) {
|
|
1514
|
-
return e.replace(/[\t\n\r ]+/g, " ").replace(/^ | $/g, "").toLowerCase().toUpperCase();
|
|
1515
|
-
}
|
|
1516
|
-
// node_modules/micromark-util-character/index.js
|
|
1517
|
-
var en = X(/[A-Za-z]/), tn = X(/[\dA-Za-z]/), nn = X(/[#-'*+\--9=?A-Z^-~]/);
|
|
1518
|
-
function rn(e) {
|
|
1519
|
-
return e !== null && (e < 32 || e === 127);
|
|
1520
|
-
}
|
|
1521
|
-
var an = X(/\d/), on = X(/[\dA-Fa-f]/), sn = X(/[!-/:-@[-`{-~]/);
|
|
1522
|
-
function cn(e) {
|
|
1523
|
-
return e !== null && e < -2;
|
|
1524
|
-
}
|
|
1525
|
-
function ln(e) {
|
|
1526
|
-
return e !== null && (e < 0 || e === 32);
|
|
1527
|
-
}
|
|
1528
|
-
function Y(e) {
|
|
1529
|
-
return e === -2 || e === -1 || e === 32;
|
|
1530
|
-
}
|
|
1531
|
-
var un = X(/\p{P}|\p{S}/u), dn = X(/\s/);
|
|
1532
|
-
function X(e) {
|
|
1533
|
-
return t;
|
|
1534
|
-
function t(t) {
|
|
1535
|
-
return t !== null && t > -1 && e.test(String.fromCharCode(t));
|
|
1536
|
-
}
|
|
1537
|
-
}
|
|
1538
|
-
// node_modules/micromark-factory-space/index.js
|
|
1539
|
-
function fn(e, t, n, r) {
|
|
1540
|
-
let i = r ? r - 1 : Infinity, a = 0;
|
|
1541
|
-
return o;
|
|
1542
|
-
function o(r) {
|
|
1543
|
-
return Y(r) ? (e.enter(n), s(r)) : t(r);
|
|
1544
|
-
}
|
|
1545
|
-
function s(r) {
|
|
1546
|
-
return Y(r) && a++ < i ? (e.consume(r), s) : (e.exit(n), t(r));
|
|
1547
|
-
}
|
|
1548
|
-
}
|
|
1549
|
-
function pn(e, t, n, r, i, a) {
|
|
1550
|
-
let o = 0;
|
|
1551
|
-
return s;
|
|
1552
|
-
function s(t) {
|
|
1553
|
-
return a > 0 && Y(t) ? (e.enter(r), c(t)) : l(t);
|
|
1554
|
-
}
|
|
1555
|
-
function c(t) {
|
|
1556
|
-
return Y(t) && o < a ? (e.consume(t), o++, c) : (e.exit(r), l(t));
|
|
1557
|
-
}
|
|
1558
|
-
function l(e) {
|
|
1559
|
-
return o >= i ? t(e) : n(e);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
// node_modules/micromark-util-classify-character/index.js
|
|
1563
|
-
function mn(e) {
|
|
1564
|
-
if (e === null || ln(e) || dn(e)) return 1;
|
|
1565
|
-
if (un(e)) return 2;
|
|
1566
|
-
}
|
|
1567
|
-
// node_modules/micromark-util-resolve-all/index.js
|
|
1568
|
-
function hn(e, t, n) {
|
|
1569
|
-
let r = [], i = -1;
|
|
1570
|
-
for (; ++i < e.length;) {
|
|
1571
|
-
let a = e[i].resolveAll;
|
|
1572
|
-
a && !r.includes(a) && (t = a(t, n), r.push(a));
|
|
1573
|
-
}
|
|
1574
|
-
return t;
|
|
1575
|
-
}
|
|
1576
|
-
// node_modules/micromark-core-commonmark/lib/blank-line.js
|
|
1577
|
-
var gn = {
|
|
1578
|
-
partial: !0,
|
|
1579
|
-
tokenize: _n
|
|
1580
|
-
};
|
|
1581
|
-
function _n(e, t, n) {
|
|
1582
|
-
return r;
|
|
1583
|
-
function r(t) {
|
|
1584
|
-
return Y(t) ? fn(e, i, "linePrefix")(t) : i(t);
|
|
1585
|
-
}
|
|
1586
|
-
function i(e) {
|
|
1587
|
-
return e === null || cn(e) ? t(e) : n(e);
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
// src/local/contracts/version.ts
|
|
1591
|
-
var vn = "local-draft-3", yn = /* @__PURE__ */ new Set([
|
|
1592
|
-
"table",
|
|
1593
|
-
"caption",
|
|
1594
|
-
"colgroup",
|
|
1595
|
-
"col",
|
|
1596
|
-
"thead",
|
|
1597
|
-
"tbody",
|
|
1598
|
-
"tfoot",
|
|
1599
|
-
"tr",
|
|
1600
|
-
"th",
|
|
1601
|
-
"td"
|
|
1602
|
-
]), bn = {
|
|
1603
|
-
colgroup: /* @__PURE__ */ new Set(["span"]),
|
|
1604
|
-
col: /* @__PURE__ */ new Set(["span"]),
|
|
1605
|
-
td: /* @__PURE__ */ new Set([
|
|
1606
|
-
"colspan",
|
|
1607
|
-
"rowspan",
|
|
1608
|
-
"headers",
|
|
1609
|
-
"align"
|
|
1610
|
-
]),
|
|
1611
|
-
th: /* @__PURE__ */ new Set([
|
|
1612
|
-
"colspan",
|
|
1613
|
-
"rowspan",
|
|
1614
|
-
"headers",
|
|
1615
|
-
"scope",
|
|
1616
|
-
"abbr",
|
|
1617
|
-
"align"
|
|
1618
|
-
])
|
|
1619
|
-
};
|
|
1620
|
-
function xn(e, t) {
|
|
1621
|
-
let n = t.trim();
|
|
1622
|
-
return [
|
|
1623
|
-
"colspan",
|
|
1624
|
-
"rowspan",
|
|
1625
|
-
"span"
|
|
1626
|
-
].includes(e) ? /^\d{1,5}$/.test(n) && Number(n) <= (e === "rowspan" ? 65534 : 1e3) && Number(n) >= (e === "rowspan" ? 0 : 1) : e === "align" ? x(t) !== null : e !== "scope" || [
|
|
1627
|
-
"row",
|
|
1628
|
-
"col",
|
|
1629
|
-
"rowgroup",
|
|
1630
|
-
"colgroup"
|
|
1631
|
-
].includes(n.toLowerCase());
|
|
1632
|
-
}
|
|
1633
|
-
// src/local/html/html-policy.ts
|
|
1634
|
-
var Sn = {
|
|
1635
|
-
b: "strong",
|
|
1636
|
-
strong: "strong",
|
|
1637
|
-
i: "emphasis",
|
|
1638
|
-
em: "emphasis",
|
|
1639
|
-
s: "delete",
|
|
1640
|
-
del: "delete",
|
|
1641
|
-
u: "underline",
|
|
1642
|
-
mark: "mark",
|
|
1643
|
-
sup: "sup",
|
|
1644
|
-
sub: "sub"
|
|
1645
|
-
}, Cn = /* @__PURE__ */ new Set([
|
|
1646
|
-
"br",
|
|
1647
|
-
"hr",
|
|
1648
|
-
"img",
|
|
1649
|
-
"col"
|
|
1650
|
-
]), wn = /* @__PURE__ */ new Set([
|
|
1651
|
-
"pre",
|
|
1652
|
-
"code",
|
|
1653
|
-
"script",
|
|
1654
|
-
"style",
|
|
1655
|
-
"textarea",
|
|
1656
|
-
"title",
|
|
1657
|
-
"xmp",
|
|
1658
|
-
"iframe",
|
|
1659
|
-
"noembed",
|
|
1660
|
-
"noframes",
|
|
1661
|
-
"plaintext"
|
|
1662
|
-
]), Tn = /* @__PURE__ */ new Set([
|
|
1663
|
-
"id",
|
|
1664
|
-
"title",
|
|
1665
|
-
"lang",
|
|
1666
|
-
"dir"
|
|
1667
|
-
]), En = {
|
|
1668
|
-
a: b,
|
|
1669
|
-
img: /* @__PURE__ */ new Set([
|
|
1670
|
-
"src",
|
|
1671
|
-
"alt",
|
|
1672
|
-
"width",
|
|
1673
|
-
"height"
|
|
1674
|
-
]),
|
|
1675
|
-
ol: /* @__PURE__ */ new Set(["start"]),
|
|
1676
|
-
details: /* @__PURE__ */ new Set(["open"]),
|
|
1677
|
-
...bn
|
|
1678
|
-
};
|
|
1679
|
-
function Dn(e, t, n) {
|
|
1680
|
-
let r = "";
|
|
1681
|
-
for (let i = t; i < n; i += 1) {
|
|
1682
|
-
let t = e[i];
|
|
1683
|
-
if (r) t === r && (r = "");
|
|
1684
|
-
else if (t === "\"" || t === "'") r = t;
|
|
1685
|
-
else if (t === ">") return i + 1;
|
|
1686
|
-
}
|
|
1687
|
-
return -1;
|
|
1688
|
-
}
|
|
1689
|
-
function On(e, t, n) {
|
|
1690
|
-
if (e.startsWith("<!-->", t)) return Math.min(n, t + 5);
|
|
1691
|
-
if (e.startsWith("<!--->", t)) return Math.min(n, t + 6);
|
|
1692
|
-
let r = e.indexOf("-->", t + 4);
|
|
1693
|
-
return r < 0 || r + 3 > n ? n : r + 3;
|
|
1694
|
-
}
|
|
1695
|
-
function kn(e) {
|
|
1696
|
-
return e.trim().replace(/[\u0000- ]+/g, "");
|
|
1697
|
-
}
|
|
1698
|
-
function An(e, t) {
|
|
1699
|
-
let n = /^([a-z][a-z0-9+.-]*):/i.exec(kn(e));
|
|
1700
|
-
if (!n) return !1;
|
|
1701
|
-
let r = n[1].toLowerCase();
|
|
1702
|
-
return t === "image" ? r !== "http" && r !== "https" : r !== "http" && r !== "https" && r !== "mailto" && r !== "tel";
|
|
1703
|
-
}
|
|
1704
|
-
function jn(e, t) {
|
|
1705
|
-
return t === "class" || t === "style" || /^on[a-z]/i.test(t) ? !1 : t === "align" && S.has(e) || Tn.has(t) || /^aria-[a-z0-9_.-]+$/.test(t) || /^data-[a-z0-9_.-]+$/.test(t) ? !0 : En[e]?.has(t) ?? !1;
|
|
1706
|
-
}
|
|
1707
|
-
function Mn(e, t) {
|
|
1708
|
-
return !(e === "dir" && ![
|
|
1709
|
-
"ltr",
|
|
1710
|
-
"rtl",
|
|
1711
|
-
"auto"
|
|
1712
|
-
].includes(t.trim().toLowerCase()) || e === "id" && t.trim() === "" || (e === "width" || e === "height") && !/^\d{1,6}$/.test(t.trim()) || e === "start" && !/^-?\d{1,9}$/.test(t.trim()) || !xn(e, t) || e === "href" && An(t, "link") || e === "src" && An(t, "image"));
|
|
1713
|
-
}
|
|
1714
|
-
function Nn(e, t) {
|
|
1715
|
-
return S.has(e) ? x(t) : null;
|
|
1716
|
-
}
|
|
1717
|
-
// src/local/parsing/parser-capabilities.ts
|
|
1718
|
-
var Pn = Object.freeze({}), Z = Object.freeze({
|
|
1719
|
-
id: g,
|
|
1720
|
-
version: p
|
|
1721
|
-
}), Fn = /* @__PURE__ */ new WeakMap(), In = /* @__PURE__ */ new WeakMap();
|
|
1722
|
-
function Ln(e, t = Z) {
|
|
1723
|
-
if (e.length === 0) return;
|
|
1724
|
-
let n = t.id === Z.id && t.version === Z.version;
|
|
1725
|
-
if (n) {
|
|
1726
|
-
let t = Fn.get(e);
|
|
1727
|
-
if (t) return t;
|
|
1728
|
-
}
|
|
1729
|
-
let i = m({
|
|
1730
|
-
protocol: r,
|
|
1731
|
-
id: t.id,
|
|
1732
|
-
version: t.version,
|
|
1733
|
-
components: e
|
|
1734
|
-
});
|
|
1735
|
-
return n && Fn.set(e, i), i;
|
|
1736
|
-
}
|
|
1737
|
-
function Rn(e, t, n, r, i = "reactive-md-config/v1") {
|
|
1738
|
-
let a = ne(e, { legacyProfiles: t.length > 0 ? n : [] }), o = [...a.legacyKeys, ...r !== void 0 && !a.legacyKeys.some((e) => e.key === r) ? [Object.freeze({
|
|
1739
|
-
profile: i,
|
|
1740
|
-
key: r
|
|
1741
|
-
})] : []];
|
|
1742
|
-
return te(e, a, o);
|
|
1743
|
-
}
|
|
1744
|
-
function zn(e) {
|
|
1745
|
-
return w(e) || E("assembly", "must be an object."), se(e, /* @__PURE__ */ new Set([
|
|
1746
|
-
"protocol",
|
|
1747
|
-
"presets",
|
|
1748
|
-
"components",
|
|
1749
|
-
"replacementPolicy",
|
|
1750
|
-
"themes"
|
|
1751
|
-
]), "assembly"), e.protocol !== "reactive-md-assembly/v1" && E("assembly.protocol", `must be "${i}".`), re(e);
|
|
1752
|
-
}
|
|
1753
|
-
function Bn(e, n = [], r = []) {
|
|
1754
|
-
let o = ue(r);
|
|
1755
|
-
if (w(e) || E("config", "must be an object."), se(e, le, "config"), e.protocol === "reactive-md-config/v2") {
|
|
1756
|
-
let t = zn(e.assembly), r = Rn(t, n, o);
|
|
1757
|
-
return d(t) > 16777216 && E("config", `serialized size exceeds the ${ie}-byte budget.`), r;
|
|
1758
|
-
}
|
|
1759
|
-
e.protocol !== "reactive-md-config/v1" && E("config.protocol", `must be "${t}" (or legacy "${a}").`);
|
|
1760
|
-
let s = ce(e.presets, Z, o)[0] ?? Z, c = C(s, o);
|
|
1761
|
-
c === void 0 && E("presets", `local.config.migration-unsupported: no compatibility profile matches preset "${s.id}" ${s.version}.`);
|
|
1762
|
-
let l = c.legacyKeys[0];
|
|
1763
|
-
l === void 0 && E("presets", `local.config.migration-unsupported: profile "${c.name}" has no legacy key mapping.`), T(c, n);
|
|
1764
|
-
let u = ae(e.components, n);
|
|
1765
|
-
u.some((e) => e.replaces !== void 0) && E("config", "replaces is not supported by reactive-md-config/v1.");
|
|
1766
|
-
let f = Ln(n, c.preset), p = Object.freeze({
|
|
1767
|
-
protocol: i,
|
|
1768
|
-
presets: Object.freeze(f ? [f] : []),
|
|
1769
|
-
components: u,
|
|
1770
|
-
replacementPolicy: "forbid",
|
|
1771
|
-
themes: Object.freeze([])
|
|
1772
|
-
}), m = Rn(p, n, o, n.length > 0 ? oe(c.preset, u) : void 0, l.profile);
|
|
1773
|
-
return d(p) > 16777216 && E("config", `serialized size exceeds the ${ie}-byte budget.`), m;
|
|
1774
|
-
}
|
|
1775
|
-
function Vn(e) {
|
|
1776
|
-
let t = In.get(e);
|
|
1777
|
-
if (t !== void 0) return t;
|
|
1778
|
-
let n = Ln(e), r = Object.freeze({
|
|
1779
|
-
protocol: i,
|
|
1780
|
-
presets: Object.freeze(n ? [n] : []),
|
|
1781
|
-
components: Object.freeze([]),
|
|
1782
|
-
replacementPolicy: "forbid",
|
|
1783
|
-
themes: Object.freeze([])
|
|
1784
|
-
}), a = ne(r).key;
|
|
1785
|
-
return In.set(e, a), a;
|
|
1786
|
-
}
|
|
1787
|
-
// src/local/configuration/options-core.ts
|
|
1788
|
-
var Hn = [
|
|
1789
|
-
"enableCss",
|
|
1790
|
-
"enableJavaScript",
|
|
1791
|
-
"enableExtendedHtml"
|
|
1792
|
-
], Un = Z;
|
|
1793
|
-
function Q(e) {
|
|
1794
|
-
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
1795
|
-
}
|
|
1796
|
-
var Wn = "local.options.invalid.host-components", Gn = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/, Kn = /* @__PURE__ */ new Set([
|
|
1797
|
-
"string",
|
|
1798
|
-
"number",
|
|
1799
|
-
"boolean",
|
|
1800
|
-
"enum"
|
|
1801
|
-
]), qn = /* @__PURE__ */ new Set([
|
|
1802
|
-
"leaf",
|
|
1803
|
-
"inline",
|
|
1804
|
-
"container"
|
|
1805
|
-
]), Jn = /* @__PURE__ */ new Set([
|
|
1806
|
-
"string",
|
|
1807
|
-
"number",
|
|
1808
|
-
"boolean"
|
|
1809
|
-
]), Yn = /* @__PURE__ */ new Set([
|
|
1810
|
-
"bind",
|
|
1811
|
-
"initial",
|
|
1812
|
-
"disabled"
|
|
1813
|
-
]), Xn = /* @__PURE__ */ new Set([
|
|
1814
|
-
"maxSyntaxNodes",
|
|
1815
|
-
"maxParseWork",
|
|
1816
|
-
"maxMarkdownDepth"
|
|
1817
|
-
]);
|
|
1818
|
-
function Zn(e, t, n) {
|
|
1819
|
-
if (!Object.hasOwn(e, t)) return {
|
|
1820
|
-
ok: !0,
|
|
1821
|
-
value: n
|
|
1822
|
-
};
|
|
1823
|
-
let r = e[t];
|
|
1824
|
-
if (r === void 0) return {
|
|
1825
|
-
ok: !0,
|
|
1826
|
-
value: n
|
|
1827
|
-
};
|
|
1828
|
-
if (typeof r != "number" || !Number.isSafeInteger(r) || r < 1) {
|
|
1829
|
-
let e = t === "maxSyntaxNodes" ? "max-syntax-nodes" : t === "maxParseWork" ? "max-parse-work" : "max-markdown-depth";
|
|
1830
|
-
return {
|
|
1831
|
-
ok: !1,
|
|
1832
|
-
message: `Compile option limits.${t} must be a positive safe integer.`,
|
|
1833
|
-
key: `local.options.invalid.${e}`
|
|
1834
|
-
};
|
|
1835
|
-
}
|
|
1836
|
-
return {
|
|
1837
|
-
ok: !0,
|
|
1838
|
-
value: r
|
|
1839
|
-
};
|
|
1840
|
-
}
|
|
1841
|
-
function $(e) {
|
|
1842
|
-
return {
|
|
1843
|
-
ok: !1,
|
|
1844
|
-
message: `Compile option hostComponents is invalid: ${e}`,
|
|
1845
|
-
key: Wn,
|
|
1846
|
-
detail: e
|
|
1847
|
-
};
|
|
1848
|
-
}
|
|
1849
|
-
function Qn(e, t) {
|
|
1850
|
-
if (e === void 0) return {
|
|
1851
|
-
ok: !0,
|
|
1852
|
-
binding: void 0
|
|
1853
|
-
};
|
|
1854
|
-
if (!Q(e)) return $(`${t} "binding" must be an object.`);
|
|
1855
|
-
for (let n of Object.keys(e)) if (![
|
|
1856
|
-
"kind",
|
|
1857
|
-
"initialRule",
|
|
1858
|
-
"min",
|
|
1859
|
-
"max",
|
|
1860
|
-
"step",
|
|
1861
|
-
"options",
|
|
1862
|
-
"exclusive"
|
|
1863
|
-
].includes(n)) return $(`${t} "binding" has unknown field "${n}".`);
|
|
1864
|
-
let n = e.kind;
|
|
1865
|
-
if (typeof n != "string" || !Jn.has(n)) return $(`${t} "binding.kind" has unsupported kind ${typeof n == "string" ? `"${n}"` : String(n)}.`);
|
|
1866
|
-
let r = { kind: n };
|
|
1867
|
-
if (Object.hasOwn(e, "exclusive") && e.exclusive !== void 0) {
|
|
1868
|
-
if (typeof e.exclusive != "boolean") return $(`${t} "binding.exclusive" must be a boolean.`);
|
|
1869
|
-
r.exclusive = e.exclusive;
|
|
1870
|
-
}
|
|
1871
|
-
if (Object.hasOwn(e, "initialRule") && e.initialRule !== void 0) {
|
|
1872
|
-
let n = e.initialRule;
|
|
1873
|
-
if (typeof n != "string" || ![
|
|
1874
|
-
"empty",
|
|
1875
|
-
"false",
|
|
1876
|
-
"nearest-zero",
|
|
1877
|
-
"min",
|
|
1878
|
-
"first-option"
|
|
1879
|
-
].includes(n)) return $(`${t} "binding.initialRule" is not supported.`);
|
|
1880
|
-
r.initialRule = n;
|
|
1881
|
-
}
|
|
1882
|
-
for (let n of [
|
|
1883
|
-
"min",
|
|
1884
|
-
"max",
|
|
1885
|
-
"step"
|
|
1886
|
-
]) {
|
|
1887
|
-
if (!Object.hasOwn(e, n) || e[n] === void 0) continue;
|
|
1888
|
-
if (r.kind !== "number") return $(`${t} "binding.${n}" is only valid for number bindings.`);
|
|
1889
|
-
let i = e[n];
|
|
1890
|
-
if (typeof i != "number" || !Number.isFinite(i)) return $(`${t} "binding.${n}" must be a finite number.`);
|
|
1891
|
-
r[n] = i;
|
|
1892
|
-
}
|
|
1893
|
-
if (r.kind === "number") {
|
|
1894
|
-
if (r.step !== void 0 && !(r.step > 0)) return $(`${t} "binding.step" must be greater than 0.`);
|
|
1895
|
-
if (r.min !== void 0 && r.max !== void 0 && r.min > r.max) return $(`${t} "binding.min" cannot exceed "binding.max".`);
|
|
1896
|
-
if (r.initialRule !== void 0 && !["min", "nearest-zero"].includes(r.initialRule)) return $(`${t} "binding.initialRule" must be "min" or "nearest-zero" for number bindings.`);
|
|
1897
|
-
r.initialRule ??= "nearest-zero";
|
|
1898
|
-
}
|
|
1899
|
-
let i = Object.hasOwn(e, "options") && e.options !== void 0;
|
|
1900
|
-
if (i) {
|
|
1901
|
-
if (r.kind !== "string") return $(`${t} "binding.options" is only valid for string bindings.`);
|
|
1902
|
-
let n = e.options;
|
|
1903
|
-
if (!Array.isArray(n) || n.length === 0) return $(`${t} "binding.options" must be a non-empty string array.`);
|
|
1904
|
-
if (n.length > 64) return $(`${t} "binding.options" accepts at most 64 values.`);
|
|
1905
|
-
let i = /* @__PURE__ */ new Set(), a = [];
|
|
1906
|
-
for (let e of n) {
|
|
1907
|
-
if (typeof e != "string" || e === "") return $(`${t} "binding.options" must be a non-empty string array.`);
|
|
1908
|
-
if (e.length > 128) return $(`${t} "binding.options" value exceeds the 128-character limit.`);
|
|
1909
|
-
if (i.has(e)) return $(`${t} "binding.options" value "${e}" is declared more than once.`);
|
|
1910
|
-
i.add(e), a.push(e);
|
|
1911
|
-
}
|
|
1912
|
-
r.options = a, r.initialRule ??= "first-option";
|
|
1913
|
-
}
|
|
1914
|
-
if (r.kind === "string") {
|
|
1915
|
-
let e = i ? "first-option" : "empty";
|
|
1916
|
-
if (r.initialRule !== void 0 && r.initialRule !== e) return $(`${t} "binding.initialRule" must be "${e}" for ${i ? "choice" : "string"} bindings.`);
|
|
1917
|
-
r.initialRule ??= e;
|
|
1918
|
-
}
|
|
1919
|
-
if (r.kind === "boolean") {
|
|
1920
|
-
if (r.initialRule !== void 0 && r.initialRule !== "false") return $(`${t} "binding.initialRule" must be "false" for boolean bindings.`);
|
|
1921
|
-
r.initialRule ??= "false";
|
|
1922
|
-
}
|
|
1923
|
-
return {
|
|
1924
|
-
ok: !0,
|
|
1925
|
-
binding: r
|
|
1926
|
-
};
|
|
1927
|
-
}
|
|
1928
|
-
function $n(e, t) {
|
|
1929
|
-
let r = [], i = /* @__PURE__ */ new Map();
|
|
1930
|
-
if (e === void 0) return {
|
|
1931
|
-
ok: !0,
|
|
1932
|
-
hostComponents: r,
|
|
1933
|
-
hostByName: i
|
|
1934
|
-
};
|
|
1935
|
-
if (!Array.isArray(e)) return $("must be an array.");
|
|
1936
|
-
if (e.length > 32) return $("accepts at most 32 components.");
|
|
1937
|
-
let a = /* @__PURE__ */ new Set();
|
|
1938
|
-
for (let e of t) a.add(e.name.toLowerCase());
|
|
1939
|
-
for (let e of v) a.add(e.name.toLowerCase());
|
|
1940
|
-
for (let e of y) a.add(e.toLowerCase());
|
|
1941
|
-
a.add("theme");
|
|
1942
|
-
for (let t = 0; t < e.length; t += 1) {
|
|
1943
|
-
let o = e[t], s = `hostComponents[${t}]`;
|
|
1944
|
-
if (!Q(o)) return $(`${s} must be an object.`);
|
|
1945
|
-
let c = o.name;
|
|
1946
|
-
if (typeof c != "string") return $(`${s} "name" must be a string.`);
|
|
1947
|
-
if (c.length > 128) return $(`${s} "name" exceeds the 128-character limit.`);
|
|
1948
|
-
if (!Gn.test(c)) return $(`${s} "name" ${c} must use lowercase kebab-case.`);
|
|
1949
|
-
if (a.has(c.toLowerCase())) return $(`${s} "name" ${c} conflicts with a built-in component, HTML tag or theme.`);
|
|
1950
|
-
if (i.has(c.toLowerCase())) return $(`${s} "name" ${c} is declared more than once.`);
|
|
1951
|
-
if (typeof o.form != "string" || !qn.has(o.form)) return $(`${s} "form" must be "leaf", "inline" or "container".`);
|
|
1952
|
-
let l = o.form, u = Qn(o.binding, s);
|
|
1953
|
-
if (!u.ok) return u;
|
|
1954
|
-
let d = u.binding, f = o.props;
|
|
1955
|
-
if (!Q(f)) return $(`${s} "props" must be an object.`);
|
|
1956
|
-
let p = {};
|
|
1957
|
-
for (let e of Object.keys(f)) {
|
|
1958
|
-
if (!Gn.test(e)) return $(`${s} property "${e}" must use lowercase kebab-case.`);
|
|
1959
|
-
if (d && Yn.has(e)) return $(`${s} property "${e}" is reserved by the host binding.`);
|
|
1960
|
-
let t = f[e];
|
|
1961
|
-
if (!Q(t)) return $(`${s} property "${e}" must be an object.`);
|
|
1962
|
-
let r = t.kind;
|
|
1963
|
-
if (typeof r != "string" || !Kn.has(r)) return $(`property "${e}" has unsupported kind ${typeof r == "string" ? `"${r}"` : String(r)}.`);
|
|
1964
|
-
let i = { kind: r };
|
|
1965
|
-
for (let n of ["required", "static"]) if (Object.hasOwn(t, n) && t[n] !== void 0) {
|
|
1966
|
-
if (typeof t[n] != "boolean") return $(`${s} property "${e}" "${n}" must be a boolean.`);
|
|
1967
|
-
i[n] = t[n];
|
|
1968
|
-
}
|
|
1969
|
-
let a = Object.hasOwn(t, "enum") && t.enum !== void 0;
|
|
1970
|
-
if (r !== "enum") {
|
|
1971
|
-
if (a) return $(`${s} property "${e}" has "enum" but kind is "${r}".`);
|
|
1972
|
-
} else {
|
|
1973
|
-
let n = t.enum;
|
|
1974
|
-
if (!Array.isArray(n) || n.length === 0) return $(`${s} property "${e}" "enum" must be a non-empty string array.`);
|
|
1975
|
-
if (n.length > 64) return $(`${s} property "${e}" "enum" accepts at most 64 values.`);
|
|
1976
|
-
let r = /* @__PURE__ */ new Set();
|
|
1977
|
-
for (let t of n) {
|
|
1978
|
-
if (typeof t != "string") return $(`${s} property "${e}" "enum" must be a non-empty string array.`);
|
|
1979
|
-
if (t.length > 128) return $(`${s} property "${e}" enum value exceeds the 128-character limit.`);
|
|
1980
|
-
if (r.has(t)) return $(`${s} property "${e}" enum value "${t}" is declared more than once.`);
|
|
1981
|
-
r.add(t);
|
|
1982
|
-
}
|
|
1983
|
-
i.enum = [...n];
|
|
1984
|
-
}
|
|
1985
|
-
let o = Object.hasOwn(t, "pattern") && t.pattern !== void 0;
|
|
1986
|
-
if (r !== "string") {
|
|
1987
|
-
if (o) return $(`${s} property "${e}" has "pattern" but kind is "${r}".`);
|
|
1988
|
-
} else if (o) {
|
|
1989
|
-
let r = t.pattern;
|
|
1990
|
-
if (typeof r != "string") return $(`${s} property "${e}" "pattern" must be a string.`);
|
|
1991
|
-
if (r.length > 512) return $(`${s} property "${e}" "pattern" exceeds the 512-character limit.`);
|
|
1992
|
-
try {
|
|
1993
|
-
new RegExp(r);
|
|
1994
|
-
} catch {
|
|
1995
|
-
return $(`${s} property "${e}" "pattern" is not a valid regular expression.`);
|
|
1996
|
-
}
|
|
1997
|
-
if (!n(r)) return $(`${s} property "${e}" "pattern" uses unsupported regex syntax; nested quantifiers, quantified alternation, backreferences and lookarounds are rejected.`);
|
|
1998
|
-
i.pattern = r;
|
|
1999
|
-
}
|
|
2000
|
-
p[e] = i;
|
|
2001
|
-
}
|
|
2002
|
-
let m = {
|
|
2003
|
-
name: c,
|
|
2004
|
-
form: l,
|
|
2005
|
-
props: p,
|
|
2006
|
-
...d ? { binding: d } : {}
|
|
2007
|
-
};
|
|
2008
|
-
r.push(m), i.set(c, m);
|
|
2009
|
-
}
|
|
2010
|
-
return {
|
|
2011
|
-
ok: !0,
|
|
2012
|
-
hostComponents: r,
|
|
2013
|
-
hostByName: i
|
|
2014
|
-
};
|
|
2015
|
-
}
|
|
2016
|
-
function er(e) {
|
|
2017
|
-
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2018
|
-
}
|
|
2019
|
-
function tr(e) {
|
|
2020
|
-
let t = e.static === !0 || e.dynamic === !1;
|
|
2021
|
-
if (e.kind === "enum") {
|
|
2022
|
-
let n = `^(?:${(e.enum ?? []).map(er).join("|")})$`;
|
|
2023
|
-
if (n.length <= 512) return {
|
|
2024
|
-
kind: "string",
|
|
2025
|
-
...e.required === !0 ? { required: !0 } : {},
|
|
2026
|
-
...t ? { static: !0 } : {},
|
|
2027
|
-
pattern: n
|
|
2028
|
-
};
|
|
2029
|
-
}
|
|
2030
|
-
let n = { kind: e.kind };
|
|
2031
|
-
return e.required === !0 && e.default === void 0 && (n.required = !0), t && (n.static = !0), e.enum && (n.enum = [...e.enum]), e.pattern !== void 0 && (n.pattern = e.pattern), n;
|
|
2032
|
-
}
|
|
2033
|
-
function nr(t) {
|
|
2034
|
-
let n = [], r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
2035
|
-
for (let a of t.components) {
|
|
2036
|
-
let t = {};
|
|
2037
|
-
for (let e of Object.keys(a.props)) t[e] = tr(a.props[e]);
|
|
2038
|
-
let o = e(a), s = {
|
|
2039
|
-
name: a.name,
|
|
2040
|
-
form: a.form,
|
|
2041
|
-
props: t,
|
|
2042
|
-
...o ? { binding: o } : {}
|
|
2043
|
-
};
|
|
2044
|
-
n.push(s), r.set(a.name, s), i.set(a.name, a);
|
|
2045
|
-
}
|
|
2046
|
-
return {
|
|
2047
|
-
hostComponents: n,
|
|
2048
|
-
hostByName: r,
|
|
2049
|
-
sdkByName: i
|
|
2050
|
-
};
|
|
2051
|
-
}
|
|
2052
|
-
function rr(e, t) {
|
|
2053
|
-
let n = /* @__PURE__ */ new Map();
|
|
2054
|
-
for (let t of e) n.set(t.name, t);
|
|
2055
|
-
let r = /* @__PURE__ */ new Map();
|
|
2056
|
-
for (let e of t.values()) r.set(e.name, e);
|
|
2057
|
-
for (let e of v) r.has(e.name) || r.set(e.name, ee(e));
|
|
2058
|
-
return {
|
|
2059
|
-
componentByName: n,
|
|
2060
|
-
schemaByName: r
|
|
2061
|
-
};
|
|
2062
|
-
}
|
|
2063
|
-
function ir(e) {
|
|
2064
|
-
let t = /* @__PURE__ */ new Map();
|
|
2065
|
-
for (let n of e) t.set(n.name, de(n));
|
|
2066
|
-
return t;
|
|
2067
|
-
}
|
|
2068
|
-
function ar(e, t) {
|
|
2069
|
-
let n = t.defaults, r = new Set(n.map((e) => e.name));
|
|
2070
|
-
if (e !== void 0 && !Q(e)) return {
|
|
2071
|
-
ok: !1,
|
|
2072
|
-
message: "Compile options must be an object.",
|
|
2073
|
-
key: "local.options.invalid.object"
|
|
2074
|
-
};
|
|
2075
|
-
let i = e ?? {}, a = {
|
|
2076
|
-
enableCss: !1,
|
|
2077
|
-
enableJavaScript: !1,
|
|
2078
|
-
enableExtendedHtml: !1
|
|
2079
|
-
};
|
|
2080
|
-
for (let e of Hn) {
|
|
2081
|
-
if (!Object.hasOwn(i, e)) continue;
|
|
2082
|
-
let t = i[e];
|
|
2083
|
-
if (t !== void 0) {
|
|
2084
|
-
if (typeof t != "boolean") return {
|
|
2085
|
-
ok: !1,
|
|
2086
|
-
message: `Compile option ${e} must be a boolean.`,
|
|
2087
|
-
key: "local.options.invalid.html-flag"
|
|
2088
|
-
};
|
|
2089
|
-
a[e] = t;
|
|
2090
|
-
}
|
|
2091
|
-
}
|
|
2092
|
-
let o = !1;
|
|
2093
|
-
if (Object.hasOwn(i, "markdownBreaks")) {
|
|
2094
|
-
let e = i.markdownBreaks;
|
|
2095
|
-
if (e !== void 0) {
|
|
2096
|
-
if (typeof e != "boolean") return {
|
|
2097
|
-
ok: !1,
|
|
2098
|
-
message: "Compile option markdownBreaks must be a boolean.",
|
|
2099
|
-
key: "local.options.invalid.markdown-breaks"
|
|
2100
|
-
};
|
|
2101
|
-
o = e;
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
let u = !0;
|
|
2105
|
-
if (Object.hasOwn(i, "strict")) {
|
|
2106
|
-
let e = i.strict;
|
|
2107
|
-
if (e !== void 0) {
|
|
2108
|
-
if (typeof e != "boolean") return {
|
|
2109
|
-
ok: !1,
|
|
2110
|
-
message: "Compile option strict must be a boolean.",
|
|
2111
|
-
key: "local.options.invalid.strict"
|
|
2112
|
-
};
|
|
2113
|
-
u = e;
|
|
2114
|
-
}
|
|
2115
|
-
}
|
|
2116
|
-
let d = i.limits, f = l, p = s, m = c;
|
|
2117
|
-
if (d !== void 0) {
|
|
2118
|
-
if (!Q(d)) return {
|
|
2119
|
-
ok: !1,
|
|
2120
|
-
message: "Compile option limits must be an object.",
|
|
2121
|
-
key: "local.options.invalid.limits"
|
|
2122
|
-
};
|
|
2123
|
-
for (let e of Object.keys(d)) if (!Xn.has(e) && d[e] !== void 0) return {
|
|
2124
|
-
ok: !1,
|
|
2125
|
-
message: `Compile option limits.${e} is not supported.`,
|
|
2126
|
-
key: "local.options.invalid.limits-unknown",
|
|
2127
|
-
detail: e
|
|
2128
|
-
};
|
|
2129
|
-
let e = Zn(d, "maxSyntaxNodes", f);
|
|
2130
|
-
if (!e.ok) return e;
|
|
2131
|
-
f = e.value;
|
|
2132
|
-
let t = Zn(d, "maxParseWork", p);
|
|
2133
|
-
if (!t.ok) return t;
|
|
2134
|
-
p = t.value;
|
|
2135
|
-
let n = Zn(d, "maxMarkdownDepth", m);
|
|
2136
|
-
if (!n.ok) return n;
|
|
2137
|
-
m = n.value;
|
|
2138
|
-
}
|
|
2139
|
-
let h = Object.hasOwn(i, "config") && i.config !== void 0, g = Object.hasOwn(i, "hostComponents") && i.hostComponents !== void 0;
|
|
2140
|
-
if (h && g) return {
|
|
2141
|
-
ok: !1,
|
|
2142
|
-
message: "Compile option config cannot be combined with hostComponents.",
|
|
2143
|
-
key: "local.options.invalid.config-conflict"
|
|
2144
|
-
};
|
|
2145
|
-
let _, v, y, b, x, S, C, w, T;
|
|
2146
|
-
if (h) {
|
|
2147
|
-
try {
|
|
2148
|
-
_ = t.readConfig(i.config, n);
|
|
2149
|
-
} catch (e) {
|
|
2150
|
-
let t = e instanceof Error ? e.message : String(e);
|
|
2151
|
-
return {
|
|
2152
|
-
ok: !1,
|
|
2153
|
-
message: `Compile option config is invalid: ${t}`,
|
|
2154
|
-
key: "local.options.invalid.config",
|
|
2155
|
-
detail: t
|
|
2156
|
-
};
|
|
2157
|
-
}
|
|
2158
|
-
let e = nr(_);
|
|
2159
|
-
v = e.hostComponents, y = e.hostByName, b = e.sdkByName, x = _.registry;
|
|
2160
|
-
let r = rr(x, ir(x));
|
|
2161
|
-
S = r.schemaByName, C = r.componentByName, w = new Set(_.components.map((e) => e.name)), T = /* @__PURE__ */ new Set();
|
|
2162
|
-
} else if (g) {
|
|
2163
|
-
let e = $n(i.hostComponents, n);
|
|
2164
|
-
if (!e.ok) return e;
|
|
2165
|
-
v = e.hostComponents, y = e.hostByName, b = /* @__PURE__ */ new Map(), x = n;
|
|
2166
|
-
let t = ir(n);
|
|
2167
|
-
for (let [n, r] of e.hostByName) t.set(n, ee({
|
|
2168
|
-
...r,
|
|
2169
|
-
legacyHost: !0
|
|
2170
|
-
}));
|
|
2171
|
-
let r = rr(n, t);
|
|
2172
|
-
S = r.schemaByName, C = r.componentByName, w = new Set(e.hostByName.keys()), T = new Set(e.hostByName.keys());
|
|
2173
|
-
} else {
|
|
2174
|
-
v = [], y = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map(), x = n;
|
|
2175
|
-
let e = rr(n, ir(n));
|
|
2176
|
-
S = e.schemaByName, C = e.componentByName, w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set();
|
|
2177
|
-
}
|
|
2178
|
-
return {
|
|
2179
|
-
ok: !0,
|
|
2180
|
-
maxSyntaxNodes: f,
|
|
2181
|
-
maxParseWork: p,
|
|
2182
|
-
maxMarkdownDepth: m,
|
|
2183
|
-
html: a,
|
|
2184
|
-
htmlActive: a.enableCss || a.enableJavaScript || a.enableExtendedHtml,
|
|
2185
|
-
markdownBreaks: o,
|
|
2186
|
-
strict: u,
|
|
2187
|
-
hostComponents: v,
|
|
2188
|
-
hostByName: y,
|
|
2189
|
-
..._ ? { config: _ } : {},
|
|
2190
|
-
sdkByName: b,
|
|
2191
|
-
registry: x,
|
|
2192
|
-
componentByName: C,
|
|
2193
|
-
schemaByName: S,
|
|
2194
|
-
defaultComponentNames: r,
|
|
2195
|
-
externalComponentNames: w,
|
|
2196
|
-
legacyHostNames: T,
|
|
2197
|
-
componentConfigKey: _ ? t.configKey(_) : t.defaultConfigKey,
|
|
2198
|
-
capabilities: t.capabilities ?? Pn,
|
|
2199
|
-
...t.preset ? { preset: t.preset } : {}
|
|
2200
|
-
};
|
|
2201
|
-
}
|
|
2202
|
-
function or(e, t = [], n) {
|
|
2203
|
-
let r = t.length > 0 ? Un : void 0;
|
|
2204
|
-
return ar(e, {
|
|
2205
|
-
defaults: t,
|
|
2206
|
-
...r ? { preset: r } : {},
|
|
2207
|
-
defaultConfigKey: Vn(t),
|
|
2208
|
-
readConfig: Bn,
|
|
2209
|
-
configKey: (e) => e.key,
|
|
2210
|
-
...n ? { capabilities: n } : {}
|
|
2211
|
-
});
|
|
2212
|
-
}
|
|
2213
|
-
function sr(e) {
|
|
2214
|
-
return e.componentConfigKey;
|
|
2215
|
-
}
|
|
2216
|
-
// src/local/evaluation/validation.ts
|
|
2217
|
-
var cr = "local.validation.failed", lr = "local.validation.expression", ur = "Validation failed.";
|
|
2218
|
-
function dr(e) {
|
|
2219
|
-
return e.length > 2e3 ? `${e.slice(0, h - 1)}…` : e;
|
|
2220
|
-
}
|
|
2221
|
-
function fr(e) {
|
|
2222
|
-
let t = e.trim();
|
|
2223
|
-
return t ? t.split(/\s+/) : [];
|
|
2224
|
-
}
|
|
2225
|
-
function pr(e) {
|
|
2226
|
-
let t = [0];
|
|
2227
|
-
for (let n = 0; n < e.length; n += 1) e[n] === "\n" && t.push(n + 1);
|
|
2228
|
-
return t;
|
|
2229
|
-
}
|
|
2230
|
-
function mr(e) {
|
|
2231
|
-
if (!e || typeof e != "object") return !1;
|
|
2232
|
-
let t = e, n = t.range;
|
|
2233
|
-
return typeof t.expression == "string" && typeof t.message == "string" && Array.isArray(t.fields) && !!n && Number.isFinite(n.start) && Number.isFinite(n.end);
|
|
2234
|
-
}
|
|
2235
|
-
function hr(e, t, n, r, i) {
|
|
2236
|
-
let a = e.length, o = Math.max(0, Math.min(a, Math.trunc(n.start))), s = Math.max(o + 1, Math.min(a, Math.trunc(n.end))), c = 0, l = Math.max(0, t.length - 1);
|
|
2237
|
-
for (; c < l;) {
|
|
2238
|
-
let e = Math.ceil((c + l) / 2);
|
|
2239
|
-
t[e] <= o ? c = e : l = e - 1;
|
|
2240
|
-
}
|
|
2241
|
-
return {
|
|
2242
|
-
code: r,
|
|
2243
|
-
message: i,
|
|
2244
|
-
severity: "error",
|
|
2245
|
-
range: {
|
|
2246
|
-
start: o,
|
|
2247
|
-
end: s
|
|
2248
|
-
},
|
|
2249
|
-
line: c + 1,
|
|
2250
|
-
column: o - t[c] + 1
|
|
2251
|
-
};
|
|
2252
|
-
}
|
|
2253
|
-
export { Qe as $, en as A, un as B, xn as C, mn as D, hn as E, on as F, qt as G, $t as H, sn as I, Bt as J, Ut as K, cn as L, nn as M, rn as N, fn as O, an as P, P as Q, ln as R, yn as S, gn as T, Xt as U, dn as V, Jt as W, zt as X, Rt as Y, Pt as Z, On as _, mr as a, pe as at, Mn as b, hr as c, or as d, Et as et, ar as f, Nn as g, Cn as h, dr as i, Nt as it, tn as j, pn as k, Hn as l, wn as m, cr as n, F as nt, pr as o, fe as ot, Sn as p, Vt as q, ur as r, lt as rt, fr as s, lr as t, Mt as tt, sr as u, Dn as v, vn as w, bn as x, jn as y, Y as z };
|