reactive-md 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG-ch.md +54 -4
- package/CHANGELOG.md +55 -4
- package/CONTRIBUTING-ch.md +13 -2
- package/CONTRIBUTING.md +13 -2
- package/README-ch.md +132 -23
- package/README-en.md +130 -21
- package/README.md +128 -21
- package/SECURITY-ch.md +3 -3
- package/SECURITY.md +3 -3
- package/THIRD_PARTY_NOTICES.md +111 -1
- package/cli/args.mjs +51 -1
- package/cli/assets.mjs +6 -1
- package/cli/build.mjs +125 -9
- package/cli/fs-utils.mjs +3 -3
- package/cli/help.mjs +12 -5
- package/cli/init.mjs +1 -1
- package/cli/package.mjs +1 -0
- package/dist-library/LocalDocumentView-sthUP0ct.js +109 -0
- package/dist-library/LocalDocumentViewCore-GiWV3bey.js +9829 -0
- package/dist-library/LocalReactiveDocumentCore-ZjQSGyHE.js +275 -0
- package/dist-library/{authoring-BsfSwQRm.js → authoring-Dsune4Hy.js} +240 -218
- package/dist-library/compile-wUv8KEge.js +1249 -0
- package/dist-library/{compiler-core-kPiH-gOV.js → compiler-core-As_m-MNm.js} +5372 -5559
- package/dist-library/compiler-eOfcinZs.js +62 -0
- package/dist-library/component-state-BoLCGee4.js +801 -0
- package/dist-library/{component-state-D_cw_EHe.js → component-state-C52ZFJGl.js} +2 -2
- package/dist-library/{registry-B9Jc3FVe.js → config-BadfhjdP.js} +374 -457
- package/dist-library/{config-validation-DXTynAw7.js → config-validation-F47AcE6o.js} +549 -751
- package/dist-library/controls-CcT6n7k_.js +6740 -0
- package/dist-library/coordinate-CWS9p5q_.js +293 -0
- package/dist-library/data-table-Bgccxd7h.js +296 -0
- package/dist-library/{default-components-Z_YMio5P.js → default-components-BwQf0oP-.js} +344 -334
- package/dist-library/{math-display-BJz4gbFc.js → display-B-VhqVND.js} +1299 -1299
- package/dist-library/export-BqVmTXm8.js +369 -0
- package/dist-library/gallery-CY6mTx8i.js +360 -0
- package/dist-library/html-CNT4KD-2.js +757 -0
- package/dist-library/{math-sample-BGEW49zY.js → incremental-Dv0FSp_U.js} +476 -394
- package/dist-library/latex-1w7aQgD5.js +928 -0
- package/dist-library/layout-C0YlEPGr.js +562 -0
- package/dist-library/mount-preset-KxvtKgJb.js +13 -0
- package/dist-library/options-1aDLK7JY.js +121 -0
- package/dist-library/{react-ByOHunUW.js → package-core-WFK1RhAZ.js} +49 -55
- package/dist-library/{parser-standard-DlCk7sLo.js → parser-standard-Yuf3A_VI.js} +6605 -7097
- package/dist-library/plugin-packs-B1XPWcFs.js +18 -0
- package/dist-library/{identity-MYJXKSkB.js → preset-core-CKc5YXSM.js} +31 -31
- package/dist-library/{props-DGlBk0e5.js → props-sJ8vk0cr.js} +1 -1
- package/dist-library/react-BbyAgeXc.js +6070 -0
- package/dist-library/react-D5iGiUdL.js +7 -0
- package/dist-library/reactive-md-authoring.js +222 -223
- package/dist-library/reactive-md-build.js +126 -72
- package/dist-library/reactive-md-compiler-standard.js +12 -10
- package/dist-library/reactive-md-compiler.js +3 -3
- package/dist-library/reactive-md-default-packs.js +2 -2
- package/dist-library/reactive-md-default-preset.js +4 -4
- package/dist-library/reactive-md-export-assets.js +57 -0
- package/dist-library/reactive-md-export.js +5 -111
- package/dist-library/reactive-md-minimal-preset.js +24 -0
- package/dist-library/reactive-md-minimal-react-preset.js +26 -0
- package/dist-library/reactive-md-minimal-styles.js +80 -0
- package/dist-library/reactive-md-minimal.css +2 -0
- package/dist-library/reactive-md-pdf.js +7582 -0
- package/dist-library/reactive-md-plugin-chart.js +13 -0
- package/dist-library/reactive-md-plugin-data.js +17 -0
- package/dist-library/reactive-md-plugin-diagram.js +18 -0
- package/dist-library/reactive-md-plugin-forms.js +18 -0
- package/dist-library/reactive-md-plugin-gallery.js +12 -0
- package/dist-library/reactive-md-plugin-navigation.js +15 -0
- package/dist-library/reactive-md-plugin-network.js +222 -0
- package/dist-library/reactive-md-plugin-plot.js +24 -0
- package/dist-library/reactive-md-print.css +5 -0
- package/dist-library/reactive-md-react-minimal.js +28 -0
- package/dist-library/reactive-md-react-server.js +34 -32
- package/dist-library/reactive-md-react-unstyled.js +14 -9
- package/dist-library/reactive-md-react.js +14 -9
- package/dist-library/reactive-md-runtime-browser.js +847 -15
- package/dist-library/reactive-md-runtime.js +3 -3
- package/dist-library/reactive-md-sdk.js +8 -6
- package/dist-library/reactive-md-standalone-configured.js +16 -0
- package/dist-library/reactive-md-standalone-host.js +9 -438
- package/dist-library/reactive-md-testing-browser.js +5 -4
- package/dist-library/reactive-md-testing-react.js +46 -44
- package/dist-library/reactive-md-testing.js +45 -44
- package/dist-library/reactive-md-vite.js +135 -37
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +590 -498
- package/dist-library/registry-B9NGct4d.js +20 -0
- package/dist-library/registry-core-Bbad9Bm2.js +479 -0
- package/dist-library/{resources-BGt8mpDA.js → resources-D2GDQS0p.js} +45 -45
- package/dist-library/{runtime-Dkq7ldyg.js → runtime-B2fxeveq.js} +1 -1
- package/dist-library/runtime-kcA7bG7G.js +1282 -0
- package/dist-library/sample-bP4zHB3L.js +289 -0
- package/dist-library/{schema-ZFufO8V0.js → schema-BufhKUSM.js} +12 -11
- package/dist-library/sdk-core-BoJT1SIt.js +1166 -0
- package/dist-library/session-core-nmJHuR9c.js +452 -0
- package/dist-library/{shareable-DDVL4Fi9.js → shareable-DpbE-59H.js} +250 -283
- package/dist-library/tooltip-layer-HDLrSWs0.js +28 -0
- package/dist-library/types/authoring/catalog.d.ts +2 -3
- package/dist-library/types/authoring/editor-i18n.d.ts +1 -1
- package/dist-library/types/authoring/index.d.ts +1 -1
- package/dist-library/types/authoring/insert.d.ts +1 -1
- package/dist-library/types/authoring/templates.d.ts +2 -2
- package/dist-library/types/build/diagnostics.d.ts +1 -1
- package/dist-library/types/build/host.d.ts +1 -1
- package/dist-library/types/build/index.d.ts +1 -1
- package/dist-library/types/build/notices.d.ts +1 -1
- package/dist-library/types/build/resources.d.ts +1 -1
- package/dist-library/types/build/vite.d.ts +1 -1
- package/dist-library/types/compiler/index.d.ts +2 -2
- package/dist-library/types/compiler/result.d.ts +1 -1
- package/dist-library/types/compiler/standard.d.ts +2 -2
- package/dist-library/types/compiler/types.d.ts +1 -1
- package/dist-library/types/components/{controls.d.ts → controls/controls.d.ts} +2 -3
- package/dist-library/types/components/{numeric-sliders.d.ts → controls/numeric-sliders.d.ts} +1 -1
- package/dist-library/types/components/{gallery.d.ts → gallery/gallery.d.ts} +1 -1
- package/dist-library/types/components/{layout.d.ts → layout/layout.d.ts} +1 -1
- package/dist-library/types/components/minimal-preset.d.ts +2 -0
- package/dist-library/types/components/mount-preset.d.ts +4 -0
- package/dist-library/types/components/network/submit-button.d.ts +10 -0
- package/dist-library/types/components/plot/coordinate.d.ts +2 -0
- package/dist-library/types/components/plugins/chart.d.ts +2 -0
- package/dist-library/types/components/plugins/data.d.ts +2 -0
- package/dist-library/types/components/plugins/diagram.d.ts +2 -0
- package/dist-library/types/components/plugins/forms.d.ts +2 -0
- package/dist-library/types/components/plugins/gallery.d.ts +2 -0
- package/dist-library/types/components/plugins/navigation.d.ts +2 -0
- package/dist-library/types/components/plugins/network.d.ts +2 -0
- package/dist-library/types/components/plugins/plot.d.ts +2 -0
- package/dist-library/types/components/shared/visual-frame.d.ts +12 -0
- package/dist-library/types/components/{visuals.d.ts → shared/visuals.d.ts} +1 -7
- package/dist-library/types/components/{data-table.d.ts → table/data-table.d.ts} +2 -2
- package/dist-library/types/export/component-state.d.ts +1 -1
- package/dist-library/types/export/index.d.ts +2 -1
- package/dist-library/types/export/print-document.d.ts +18 -0
- package/dist-library/types/export/render-markup.d.ts +23 -0
- package/dist-library/types/export/requirements.d.ts +1 -1
- package/dist-library/types/export/resources.d.ts +1 -1
- package/dist-library/types/export/restoration.d.ts +1 -1
- package/dist-library/types/export-assets/index.d.ts +25 -0
- package/dist-library/types/local/compilation/compiler-attributes.d.ts +8 -0
- package/dist-library/types/local/compilation/compiler-bindings.d.ts +19 -0
- package/dist-library/types/local/compilation/compiler-capabilities.d.ts +3 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +11 -3
- package/dist-library/types/local/compilation/compiler-declarations.d.ts +32 -0
- package/dist-library/types/local/compilation/compiler-expressions.d.ts +32 -0
- package/dist-library/types/local/compilation/compiler-services.d.ts +62 -16
- package/dist-library/types/local/compilation/compiler-structure.d.ts +38 -3
- package/dist-library/types/local/compilation/compiler-tables.d.ts +30 -0
- package/dist-library/types/local/compilation/compiler-validation.d.ts +15 -0
- package/dist-library/types/local/compilation/compiler-values.d.ts +39 -1
- package/dist-library/types/local/compilation/compiler.d.ts +7 -14
- package/dist-library/types/local/compilation/dependencies.d.ts +1 -1
- package/dist-library/types/local/compilation/session/incremental.d.ts +75 -0
- package/dist-library/types/local/{session → compilation/session}/row-reuse.d.ts +1 -1
- package/dist-library/types/local/{session/compiler-cache.d.ts → compilation/session/semantic-cache.d.ts} +5 -19
- package/dist-library/types/local/compilation/streaming.d.ts +27 -0
- package/dist-library/types/local/configuration/capability-policy.d.ts +3 -0
- package/dist-library/types/local/{compilation → configuration}/component-kernel.d.ts +3 -79
- package/dist-library/types/local/configuration/diagnostic-messages.d.ts +1104 -1056
- package/dist-library/types/local/configuration/diagnostic-runtime-messages.d.ts +731 -0
- package/dist-library/types/local/configuration/diagnostics.d.ts +1 -1
- package/dist-library/types/local/configuration/kernel-value-rules.d.ts +66 -0
- package/dist-library/types/local/configuration/official-leaf-syntax.d.ts +24 -0
- package/dist-library/types/local/configuration/options-core.d.ts +5 -4
- package/dist-library/types/local/configuration/options.d.ts +2 -1
- package/dist-library/types/local/configuration/portable-options.d.ts +1 -1
- package/dist-library/types/local/configuration/schema-core.d.ts +1 -1
- package/dist-library/types/local/configuration/schema.d.ts +1 -1
- package/dist-library/types/local/css/author-css.d.ts +66 -0
- package/dist-library/types/local/evaluation/computations.d.ts +2 -2
- package/dist-library/types/local/evaluation/expression/compile.d.ts +30 -0
- package/dist-library/types/local/evaluation/expression/evaluation.d.ts +3 -0
- package/dist-library/types/local/evaluation/expression/inference.d.ts +4 -0
- package/dist-library/types/local/evaluation/expression/syntax.d.ts +72 -0
- package/dist-library/types/local/evaluation/expression/values.d.ts +56 -0
- package/dist-library/types/local/evaluation/{math-display.d.ts → math/display.d.ts} +2 -2
- package/dist-library/types/local/evaluation/math/evaluation.d.ts +10 -0
- package/dist-library/types/local/evaluation/{math.d.ts → math/latex.d.ts} +58 -17
- package/dist-library/types/local/evaluation/{math-sample.d.ts → math/sample.d.ts} +4 -2
- package/dist-library/types/local/evaluation/math/syntax.d.ts +72 -0
- package/dist-library/types/local/evaluation/validation.d.ts +1 -1
- package/dist-library/types/local/html/extended-fragment.d.ts +41 -0
- package/dist-library/types/local/html/html-details.d.ts +1 -1
- package/dist-library/types/local/html/html-entities.d.ts +11 -2
- package/dist-library/types/local/html/html-recovery.d.ts +1 -1
- package/dist-library/types/local/html/html-table.d.ts +1 -1
- package/dist-library/types/local/html/html.d.ts +40 -4
- package/dist-library/types/local/index.d.ts +14 -13
- package/dist-library/types/local/parsing/author-markdown.d.ts +11 -0
- package/dist-library/types/local/{markdown → parsing}/fast-markdown.d.ts +1 -1
- package/dist-library/types/local/{markdown → parsing}/footnotes.d.ts +1 -1
- package/dist-library/types/local/{markdown → parsing}/heading-anchors.d.ts +1 -1
- package/dist-library/types/local/parsing/html-attributes.d.ts +14 -0
- package/dist-library/types/local/parsing/parse-budget.d.ts +1 -1
- package/dist-library/types/local/{session → parsing}/parse-session.d.ts +5 -5
- package/dist-library/types/local/parsing/parser-capabilities.d.ts +7 -2
- package/dist-library/types/local/parsing/parser-convert.d.ts +26 -0
- package/dist-library/types/local/parsing/parser-core.d.ts +10 -4
- package/dist-library/types/local/parsing/parser-internals.d.ts +54 -0
- package/dist-library/types/local/parsing/parser-region.d.ts +46 -0
- package/dist-library/types/local/parsing/parser-standard.d.ts +3 -0
- package/dist-library/types/local/parsing/parser-tags.d.ts +108 -0
- package/dist-library/types/local/parsing/parser.d.ts +3 -3
- package/dist-library/types/local/{markdown → parsing}/plain-paragraphs.d.ts +1 -1
- package/dist-library/types/local/parsing/rmd-recovery.d.ts +1 -1
- package/dist-library/types/local/parsing/theme-declaration.d.ts +22 -0
- package/dist-library/types/local/rendering/document/ExtendedHtmlFragment.d.ts +14 -0
- package/dist-library/types/local/rendering/document/LocalDocumentView.d.ts +5 -0
- package/dist-library/types/local/rendering/{LocalDocumentView.d.ts → document/LocalDocumentViewCore.d.ts} +48 -9
- package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +6 -0
- package/dist-library/types/local/rendering/document/render-nodes.d.ts +24 -0
- package/dist-library/types/local/rendering/document/use-author-script.d.ts +3 -0
- package/dist-library/types/local/rendering/document/use-color-scheme.d.ts +10 -0
- package/dist-library/types/local/rendering/document/validation-state.d.ts +31 -0
- package/dist-library/types/local/rendering/document/view-render-context.d.ts +146 -0
- package/dist-library/types/local/rendering/{view-revision.d.ts → document/view-revision.d.ts} +31 -4
- package/dist-library/types/local/rendering/render-types.d.ts +1 -1
- package/dist-library/types/local/{widgets/table-surface.d.ts → rendering/table/data-table.d.ts} +3 -0
- package/dist-library/types/local/rendering/table/table-numeric-columns.d.ts +7 -0
- package/dist-library/types/local/runtime/author-script-protocol.d.ts +59 -0
- package/dist-library/types/local/runtime/retention.d.ts +1 -1
- package/dist-library/types/local/runtime/runtime-document.d.ts +71 -0
- package/dist-library/types/local/runtime/runtime-migration.d.ts +19 -0
- package/dist-library/types/local/runtime/runtime-values.d.ts +39 -0
- package/dist-library/types/local/runtime/runtime.d.ts +4 -2
- package/dist-library/types/local/runtime/state.d.ts +1 -1
- package/dist-library/types/local/source/authoring-syntax.d.ts +48 -0
- package/dist-library/types/local/source/authoring.d.ts +1 -1
- package/dist-library/types/local/source/source-context.d.ts +23 -0
- package/dist-library/types/local/source/source-migration.d.ts +2 -2
- package/dist-library/types/local/transport/compile-patch.d.ts +1 -1
- package/dist-library/types/local/transport/flat-compiled-data.d.ts +1 -1
- package/dist-library/types/local/transport/shared-data.d.ts +1 -1
- package/dist-library/types/local/transport/worker-handler.d.ts +30 -0
- package/dist-library/types/local/transport/worker-job.d.ts +28 -0
- package/dist-library/types/local/transport/worker.d.ts +32 -46
- package/dist-library/types/local/{contracts/types.d.ts → types.d.ts} +78 -21
- package/dist-library/types/pdf.d.ts +22 -0
- package/dist-library/types/presets/identity.d.ts +1 -0
- package/dist-library/types/presets/minimal.d.ts +2 -0
- package/dist-library/types/presets/plugin-packs.d.ts +1 -0
- package/dist-library/types/react/component-api.d.ts +20 -4
- package/dist-library/types/react/component-primitives.d.ts +10 -10
- package/dist-library/types/react/component-utils.d.ts +9 -1
- package/dist-library/types/react/index.d.ts +6 -5
- package/dist-library/types/{local/theme/i18n.d.ts → react/localization.d.ts} +2 -2
- package/dist-library/types/react/minimal.d.ts +13 -0
- package/dist-library/types/react/package-core.d.ts +67 -0
- package/dist-library/types/react/package.d.ts +3 -67
- package/dist-library/types/react/runtime/common.d.ts +1 -1
- package/dist-library/types/react/sdk-core.d.ts +115 -0
- package/dist-library/types/react/sdk.d.ts +4 -110
- package/dist-library/types/react/server.d.ts +2 -2
- package/dist-library/types/react/use-draft-field.d.ts +5 -1
- package/dist-library/types/runtime-services/browser/duplex.d.ts +163 -0
- package/dist-library/types/runtime-services/browser/http-sse.d.ts +117 -0
- package/dist-library/types/runtime-services/browser/index.d.ts +2 -1
- package/dist-library/types/runtime-services/component-state.d.ts +1 -1
- package/dist-library/types/runtime-services/index.d.ts +2 -0
- package/dist-library/types/runtime-services/network.d.ts +86 -0
- package/dist-library/types/runtime-services/runtime.d.ts +1 -1
- package/dist-library/types/sdk/config.d.ts +1 -1
- package/dist-library/types/sdk/index.d.ts +1 -0
- package/dist-library/types/sdk/props.d.ts +1 -1
- package/dist-library/types/sdk/registry-core.d.ts +1 -1
- package/dist-library/types/sdk/theme.d.ts +5 -4
- package/dist-library/types/sdk/types.d.ts +2 -2
- package/dist-library/types/shareable.d.ts +6 -5
- package/dist-library/types/standalone/diagnostics.d.ts +1 -1
- package/dist-library/types/standalone/host.d.ts +5 -0
- package/dist-library/types/standalone/payload.d.ts +1 -1
- package/dist-library/types/standalone/prepare.d.ts +2 -2
- package/dist-library/types/standalone/session-core.d.ts +68 -0
- package/dist-library/types/standalone/session.d.ts +6 -68
- package/dist-library/types/themes/contract.d.ts +7 -0
- package/dist-library/types/{local/theme/theme.d.ts → themes/document-theme.d.ts} +4 -3
- package/dist-library/types/vite/client.d.ts +19 -0
- package/dist-library/types/vite/index.d.ts +18 -3
- package/dist-library/types/vite/registration.d.ts +2 -2
- package/dist-library/{types-BFCrMrg0.js → types-BeNtPqdY.js} +1 -1
- package/dist-library/validation-BEBA_HvS.js +1121 -0
- package/dist-library/visual-frame-CyV1FXzs.js +48 -0
- package/dist-library/visuals-B5KSafVk.js +3 -0
- package/dist-library/visuals-BZbZYA7w.js +72572 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +146 -137
- package/docs/README-ch.md +16 -11
- package/docs/README.md +16 -11
- package/docs/compatibility/compatibility-ch.md +8 -8
- package/docs/compatibility/compatibility-en.md +8 -8
- package/docs/compatibility/source-versioning-ch.md +1 -1
- package/docs/compatibility/source-versioning-en.md +1 -1
- package/docs/development/component-development-ch.md +2 -2
- package/docs/development/component-development-en.md +2 -2
- package/docs/development/component-development-reference-ch.md +4 -4
- package/docs/development/component-development-reference-en.md +4 -4
- package/docs/development/component-protocol-ch.md +14 -14
- package/docs/development/component-protocol-en.md +14 -14
- package/docs/development/extension-tutorial-ch.md +308 -0
- package/docs/development/extension-tutorial-en.md +308 -0
- package/docs/development/local-module-layout-ch.md +10 -50
- package/docs/development/local-module-layout-en.md +9 -49
- package/docs/development/performance-overview-ch.md +174 -154
- package/docs/development/performance-overview-en.md +174 -154
- package/docs/guides/local-guide-ch.md +2 -2
- package/docs/guides/local-guide-en.md +2 -2
- package/docs/integration/author-tools-ch.md +2 -2
- package/docs/integration/author-tools-en.md +2 -2
- package/docs/integration/compiler-ch.md +4 -2
- package/docs/integration/compiler-en.md +4 -2
- package/docs/integration/directory-discovery-ch.md +5 -1
- package/docs/integration/directory-discovery-en.md +5 -1
- package/docs/integration/editor-ch.md +35 -5
- package/docs/integration/editor-en.md +42 -4
- package/docs/integration/extension-sdk-ch.md +6 -4
- package/docs/integration/extension-sdk-en.md +6 -4
- package/docs/integration/local-integration-ch.md +201 -19
- package/docs/integration/local-integration-en.md +194 -18
- package/docs/integration/network-host-ch.md +75 -0
- package/docs/integration/network-host-en.md +75 -0
- package/docs/integration/shareable-export-ch.md +58 -16
- package/docs/integration/shareable-export-en.md +57 -15
- package/docs/reference/html-compatibility-ch.md +20 -67
- package/docs/reference/html-compatibility-en.md +19 -64
- package/docs/reference/local-interaction-syntax-ch.md +199 -26
- package/docs/reference/local-interaction-syntax-en.md +194 -27
- package/docs/reference/public-api-ch.md +416 -0
- package/docs/reference/public-api-en.md +416 -0
- package/docs/reference/theme-protocol-ch.md +27 -8
- package/docs/reference/theme-protocol-en.md +46 -8
- package/docs/releases/release-0.4.0-ch.md +2 -2
- package/docs/releases/release-0.4.0-en.md +2 -2
- package/docs/releases/release-0.8.0-ch.md +19 -3
- package/docs/releases/release-0.8.0-en.md +19 -3
- package/docs/releases/release-0.9.0-ch.md +44 -0
- package/docs/releases/release-0.9.0-en.md +44 -0
- package/docs/releases/release-0.9.1-ch.md +29 -0
- package/docs/releases/release-0.9.1-en.md +29 -0
- package/examples/component-package/README-ch.md +1 -1
- package/examples/component-package/README.md +1 -1
- package/examples/conformance/README-ch.md +3 -3
- package/examples/conformance/README.md +3 -3
- package/examples/game-2048-package/README-ch.md +3 -9
- package/examples/game-2048-package/README.md +8 -12
- package/examples/integration/README-ch.md +21 -2
- package/examples/integration/README.md +21 -2
- package/examples/integration/extension-sdk/README-ch.md +1 -1
- package/examples/integration/extension-sdk/README.md +1 -1
- package/examples/integration/streaming/index.html +48 -0
- package/examples/integration/streaming/main.js +175 -0
- package/examples/integration/streaming/package.json +13 -0
- package/examples/integration/streaming/worker.js +3 -0
- package/examples/local/README-ch.md +3 -3
- package/examples/local/README.md +2 -2
- package/examples/local/minimal-budget.reactive.md +48 -0
- package/examples/minimal-extension/README-ch.md +78 -0
- package/examples/minimal-extension/README.md +78 -0
- package/examples/minimal-extension/index.html +15 -0
- package/examples/minimal-extension/package.json +26 -0
- package/examples/minimal-extension/sample/document.reactive.md +10 -0
- package/examples/minimal-extension/scripts/build.mjs +32 -0
- package/examples/minimal-extension/scripts/export.mjs +72 -0
- package/examples/minimal-extension/scripts/test-node.mjs +75 -0
- package/examples/minimal-extension/src/extension.tsx +90 -0
- package/examples/minimal-extension/src/preview.tsx +12 -0
- package/examples/minimal-extension/src/source.ts +4 -0
- package/examples/minimal-extension/tsconfig.json +14 -0
- package/examples/network-survey/README.md +200 -0
- package/examples/network-survey/index.html +49 -0
- package/examples/network-survey/package.json +26 -0
- package/examples/network-survey/sample/document.reactive.md +51 -0
- package/examples/network-survey/src/components.tsx +325 -0
- package/examples/network-survey/src/host.ts +316 -0
- package/examples/network-survey/src/main.tsx +91 -0
- package/examples/network-survey/src/source.ts +1 -0
- package/examples/network-survey/tsconfig.json +26 -0
- package/examples/network-survey/vite.config.ts +227 -0
- package/examples/sci-fi-theme/README-ch.md +4 -2
- package/examples/sci-fi-theme/README.md +4 -2
- package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -0
- package/examples/sci-fi-theme/demo/demo.css +129 -23
- package/examples/sci-fi-theme/demo/document.reactive.md +27 -6
- package/examples/sci-fi-theme/demo/main.tsx +45 -10
- package/examples/sci-fi-theme/docs/design-system-ch.md +6 -6
- package/examples/sci-fi-theme/package.json +2 -1
- package/examples/sci-fi-theme/src/components.css +1064 -154
- package/examples/sci-fi-theme/src/notch.css +142 -0
- package/examples/sci-fi-theme/src/sci-fi.css +3 -1
- package/examples/sci-fi-theme/src/theme.ts +2 -0
- package/examples/sci-fi-theme/src/tokens.css +512 -408
- package/examples/tetris-package/README-ch.md +4 -4
- package/examples/tetris-package/README.md +4 -4
- package/package.json +70 -3
- package/dist-library/LocalDocumentView-6trX7xJc.js +0 -97920
- package/dist-library/compiler--ea2CKQF.js +0 -61
- package/dist-library/component-state-Cq2K5gkS.js +0 -490
- package/dist-library/options-CX5m5n-J.js +0 -115
- package/dist-library/runtime-C-sbfpOX.js +0 -1157
- package/dist-library/types/local/contracts/locale.d.ts +0 -1
- package/dist-library/types/local/contracts/version.d.ts +0 -2
- package/dist-library/types/local/evaluation/dates.d.ts +0 -2
- package/dist-library/types/local/evaluation/expression.d.ts +0 -47
- package/dist-library/types/local/markdown/markdown-structure.d.ts +0 -3
- package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +0 -36
- package/dist-library/types/local/session/incremental.d.ts +0 -48
- package/dist-library/types/local/source/node-walk.d.ts +0 -3
- package/dist-library/types/local/source/text-length.d.ts +0 -13
- package/dist-library/types/local/theme/theme-name.d.ts +0 -3
- package/dist-library/types/local/widgets/visuals.d.ts +0 -25
- package/dist-library/types/react/default-theme.d.ts +0 -6
- package/dist-library/validation-W-bmny-x.js +0 -2253
- package/docs/development/releasing-ch.md +0 -12
- package/docs/development/releasing-en.md +0 -12
- package/docs/integration/codemirror-ch.md +0 -52
- package/docs/integration/codemirror-en.md +0 -29
- package/docs/integration/repository-split-ch.md +0 -40
- package/docs/integration/repository-split-en.md +0 -23
- package/docs/reference/computations-formatting-ch.md +0 -89
- package/docs/reference/computations-formatting-en.md +0 -89
- package/docs/reference/constraints-collections-ch.md +0 -104
- package/docs/reference/constraints-collections-en.md +0 -104
- package/docs/reference/local-components-v2-ch.md +0 -140
- package/docs/reference/local-components-v2-en.md +0 -106
- package/docs/reference/tolerance-ch.md +0 -64
- package/docs/reference/tolerance-en.md +0 -57
- /package/dist-library/types/components/{chart-motion.d.ts → chart/chart-motion.d.ts} +0 -0
- /package/dist-library/types/components/{default-chart-types.d.ts → chart/default-chart-types.d.ts} +0 -0
- /package/dist-library/types/components/{default-chart.d.ts → chart/default-chart.d.ts} +0 -0
- /package/dist-library/types/components/{diagram-inspector.d.ts → diagram/diagram-inspector.d.ts} +0 -0
- /package/dist-library/types/{local/widgets/diagram-layout.d.ts → components/diagram/layout.d.ts} +0 -0
- /package/dist-library/types/components/{mafs-plot-grid.d.ts → plot/mafs-plot-grid.d.ts} +0 -0
- /package/dist-library/types/components/{mafs-visuals.d.ts → plot/mafs-visuals.d.ts} +0 -0
- /package/dist-library/types/components/{use-hydrated.d.ts → shared/use-hydrated.d.ts} +0 -0
- /package/dist-library/types/local/{theme/colors.d.ts → configuration/color-values.d.ts} +0 -0
- /package/dist-library/types/local/evaluation/{collection-functions.d.ts → expression/collection-functions.d.ts} +0 -0
- /package/dist-library/types/local/evaluation/{data-functions.d.ts → expression/data-functions.d.ts} +0 -0
- /package/dist-library/types/local/evaluation/{formatting.d.ts → expression/formatting.d.ts} +0 -0
- /package/dist-library/types/local/{markdown → parsing}/markdown-blocks.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering/code}/code-block.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering/code}/code-languages.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering/image}/image-view.d.ts +0 -0
- /package/dist-library/types/local/{widgets → rendering}/math-view.d.ts +0 -0
|
@@ -0,0 +1,1249 @@
|
|
|
1
|
+
import { $ as e, lt as t, ut as n } from "./preset-core-CKc5YXSM.js";
|
|
2
|
+
import { B as r, P as i, j as a } from "./config-validation-F47AcE6o.js";
|
|
3
|
+
// src/local/evaluation/expression/values.ts
|
|
4
|
+
var o = class extends Error {
|
|
5
|
+
offset;
|
|
6
|
+
code;
|
|
7
|
+
constructor(e, t, n = 0) {
|
|
8
|
+
super(t), this.name = "LocalExpressionError", this.code = e, this.offset = n;
|
|
9
|
+
}
|
|
10
|
+
}, s = /* @__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("."), c = new Set(s), l = /* @__PURE__ */ new Map([["pi", Math.PI], ["e", Math.E]]), u = /* @__PURE__ */ new Set([
|
|
11
|
+
"__proto__",
|
|
12
|
+
"prototype",
|
|
13
|
+
"constructor"
|
|
14
|
+
]), ee = /* @__PURE__ */ new Set([
|
|
15
|
+
"string",
|
|
16
|
+
"number",
|
|
17
|
+
"boolean",
|
|
18
|
+
"null",
|
|
19
|
+
"array",
|
|
20
|
+
"number-array"
|
|
21
|
+
]), te = /* @__PURE__ */ new Set([
|
|
22
|
+
...s,
|
|
23
|
+
"x",
|
|
24
|
+
"y",
|
|
25
|
+
"pi",
|
|
26
|
+
"e",
|
|
27
|
+
"true",
|
|
28
|
+
"false",
|
|
29
|
+
"null",
|
|
30
|
+
...u
|
|
31
|
+
]), ne = 4e3, d = t;
|
|
32
|
+
function f(r) {
|
|
33
|
+
if (r.length > 1e4) return {
|
|
34
|
+
code: "expression-budget",
|
|
35
|
+
...i("local.budget.value.array", { limit: e }),
|
|
36
|
+
message: `Array exceeds the ${e}-item limit.`
|
|
37
|
+
};
|
|
38
|
+
let a = null, o = 0;
|
|
39
|
+
for (let e of r) if (typeof e == "string") {
|
|
40
|
+
if (a === "number") return {
|
|
41
|
+
code: "expression-value",
|
|
42
|
+
key: "error.array.homogeneous",
|
|
43
|
+
message: "Array elements must all be strings or all be numbers."
|
|
44
|
+
};
|
|
45
|
+
if (a = "string", e.length > 1e5) return {
|
|
46
|
+
code: "expression-budget",
|
|
47
|
+
...i("local.budget.value.array-member", { limit: t }),
|
|
48
|
+
message: `Array member exceeds the ${t}-character limit.`
|
|
49
|
+
};
|
|
50
|
+
if (o += e.length, o > 1e5) return {
|
|
51
|
+
code: "expression-budget",
|
|
52
|
+
...i("local.budget.value.array-contents", { limit: n }),
|
|
53
|
+
message: `Array contents exceed the ${n}-character limit.`
|
|
54
|
+
};
|
|
55
|
+
} else if (typeof e == "number") {
|
|
56
|
+
if (a === "string") return {
|
|
57
|
+
code: "expression-value",
|
|
58
|
+
key: "error.array.homogeneous",
|
|
59
|
+
message: "Array elements must all be strings or all be numbers."
|
|
60
|
+
};
|
|
61
|
+
if (a = "number", !Number.isFinite(e)) return {
|
|
62
|
+
code: "expression-value",
|
|
63
|
+
key: "error.array.finite",
|
|
64
|
+
message: "Array members must be finite numbers."
|
|
65
|
+
};
|
|
66
|
+
} else return {
|
|
67
|
+
code: "expression-value",
|
|
68
|
+
key: "error.array.members",
|
|
69
|
+
message: "Array members must be strings or finite numbers."
|
|
70
|
+
};
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
function p(e) {
|
|
74
|
+
if (typeof e == "string") return e.length > 1e5 ? i("local.budget.value.string", { limit: t }) : null;
|
|
75
|
+
if (Array.isArray(e)) {
|
|
76
|
+
let t = f(e);
|
|
77
|
+
return t ? i(t.key, t.params) : null;
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
function m(e) {
|
|
82
|
+
let t = p(e);
|
|
83
|
+
return t ? a(t) : null;
|
|
84
|
+
}
|
|
85
|
+
// src/local/evaluation/expression/syntax.ts
|
|
86
|
+
var re = /^(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?/, h = /[A-Za-z_]/, ie = /[A-Za-z0-9_]/;
|
|
87
|
+
function ae(e) {
|
|
88
|
+
let t = [], n = 0;
|
|
89
|
+
for (; n < e.length;) {
|
|
90
|
+
let r = e[n];
|
|
91
|
+
if (/\s/.test(r)) {
|
|
92
|
+
n += 1;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (r >= "0" && r <= "9" || r === "." && /[0-9]/.test(e[n + 1] ?? "")) {
|
|
96
|
+
let r = re.exec(e.slice(n));
|
|
97
|
+
if (!r) throw new o("expression-syntax", "Invalid number.", n);
|
|
98
|
+
let i = r[0], a = Number(i);
|
|
99
|
+
if (!Number.isFinite(a)) throw new o("expression-number", `Number must be finite: ${i}.`, n);
|
|
100
|
+
t.push({
|
|
101
|
+
kind: "number",
|
|
102
|
+
value: i,
|
|
103
|
+
start: n,
|
|
104
|
+
number: a
|
|
105
|
+
}), n += i.length;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (r === "\"" || r === "'") {
|
|
109
|
+
let i = n, a = r, s = "", c = n + 1, l = !1;
|
|
110
|
+
for (; c < e.length;) {
|
|
111
|
+
let t = e[c];
|
|
112
|
+
if (t === a) {
|
|
113
|
+
l = !0, c += 1;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
if (t === "\n" || t === "\r") throw new o("expression-string", "String literals cannot span lines.", i);
|
|
117
|
+
if (t === "\\") {
|
|
118
|
+
let t = e[c + 1];
|
|
119
|
+
if (t === void 0) break;
|
|
120
|
+
switch (t) {
|
|
121
|
+
case "\\":
|
|
122
|
+
s += "\\";
|
|
123
|
+
break;
|
|
124
|
+
case "'":
|
|
125
|
+
s += "'";
|
|
126
|
+
break;
|
|
127
|
+
case "\"":
|
|
128
|
+
s += "\"";
|
|
129
|
+
break;
|
|
130
|
+
case "n":
|
|
131
|
+
s += "\n";
|
|
132
|
+
break;
|
|
133
|
+
case "t":
|
|
134
|
+
s += " ";
|
|
135
|
+
break;
|
|
136
|
+
default: throw new o("expression-string", `Unsupported escape \\${t}.`, c);
|
|
137
|
+
}
|
|
138
|
+
c += 2;
|
|
139
|
+
} else s += t, c += 1;
|
|
140
|
+
}
|
|
141
|
+
if (!l) throw new o("expression-string", "Unterminated string literal.", i);
|
|
142
|
+
if (s.length > d) throw new o("expression-budget", "String literal exceeds the length limit.", i);
|
|
143
|
+
t.push({
|
|
144
|
+
kind: "string",
|
|
145
|
+
value: s,
|
|
146
|
+
start: i
|
|
147
|
+
}), n = c;
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (h.test(r)) {
|
|
151
|
+
let r = n + 1;
|
|
152
|
+
for (; r < e.length && ie.test(e[r]);) r += 1;
|
|
153
|
+
t.push({
|
|
154
|
+
kind: "ident",
|
|
155
|
+
value: e.slice(n, r),
|
|
156
|
+
start: n
|
|
157
|
+
}), n = r;
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
let i = e.slice(n, n + 2);
|
|
161
|
+
if (e.startsWith("!==", n) || e.startsWith("===", n)) throw new o("expression-syntax", `Unsupported operator ${e.slice(n, n + 3)}.`, n);
|
|
162
|
+
if (i === "==" || i === "!=" || i === "<=" || i === ">=" || i === "&&" || i === "||") t.push({
|
|
163
|
+
kind: "punct",
|
|
164
|
+
value: i,
|
|
165
|
+
start: n
|
|
166
|
+
}), n += 2;
|
|
167
|
+
else if ("+-*/%()!<>?:,[]".includes(r)) t.push({
|
|
168
|
+
kind: "punct",
|
|
169
|
+
value: r,
|
|
170
|
+
start: n
|
|
171
|
+
}), n += 1;
|
|
172
|
+
else throw r === "=" ? new o("expression-assignment", "Assignments are not supported.", n) : r === "." ? new o("expression-property", "Property access is not supported.", n) : r === "&" || r === "|" ? new o("expression-syntax", `Use ${r}${r} for logical operations.`, n) : new o("expression-syntax", `Unrecognized character "${r}".`, n);
|
|
173
|
+
}
|
|
174
|
+
return t.push({
|
|
175
|
+
kind: "eof",
|
|
176
|
+
value: "",
|
|
177
|
+
start: e.length
|
|
178
|
+
}), t;
|
|
179
|
+
}
|
|
180
|
+
var oe = {
|
|
181
|
+
abs: [1, 1],
|
|
182
|
+
sqrt: [1, 1],
|
|
183
|
+
floor: [1, 1],
|
|
184
|
+
ceil: [1, 1],
|
|
185
|
+
round: [1, 1],
|
|
186
|
+
min: [1, 2 ** 53 - 1],
|
|
187
|
+
max: [1, 2 ** 53 - 1],
|
|
188
|
+
pow: [2, 2],
|
|
189
|
+
sin: [1, 1],
|
|
190
|
+
cos: [1, 1],
|
|
191
|
+
tan: [1, 1],
|
|
192
|
+
asin: [1, 1],
|
|
193
|
+
acos: [1, 1],
|
|
194
|
+
atan: [1, 1],
|
|
195
|
+
exp: [1, 1],
|
|
196
|
+
log: [1, 1],
|
|
197
|
+
len: [1, 1],
|
|
198
|
+
contains: [2, 2],
|
|
199
|
+
clamp: [3, 3],
|
|
200
|
+
sum: [1, 1],
|
|
201
|
+
average: [1, 1],
|
|
202
|
+
minOf: [1, 1],
|
|
203
|
+
maxOf: [1, 1],
|
|
204
|
+
formatNumber: [1, 4],
|
|
205
|
+
formatPercent: [1, 3],
|
|
206
|
+
formatScientific: [1, 3],
|
|
207
|
+
formatCurrency: [1, 4],
|
|
208
|
+
trim: [1, 1],
|
|
209
|
+
lower: [1, 1],
|
|
210
|
+
upper: [1, 1],
|
|
211
|
+
startsWith: [2, 2],
|
|
212
|
+
endsWith: [2, 2],
|
|
213
|
+
replace: [3, 3],
|
|
214
|
+
slice: [2, 3],
|
|
215
|
+
dateCompare: [2, 2],
|
|
216
|
+
dateDiff: [2, 3]
|
|
217
|
+
};
|
|
218
|
+
function se(e) {
|
|
219
|
+
let t = 0, n = [{
|
|
220
|
+
node: e,
|
|
221
|
+
depth: 1
|
|
222
|
+
}];
|
|
223
|
+
for (; n.length > 0;) {
|
|
224
|
+
let { node: e, depth: r } = n.pop();
|
|
225
|
+
switch (r > t && (t = r), e.kind) {
|
|
226
|
+
case "unary":
|
|
227
|
+
n.push({
|
|
228
|
+
node: e.operand,
|
|
229
|
+
depth: r + 1
|
|
230
|
+
});
|
|
231
|
+
break;
|
|
232
|
+
case "binary":
|
|
233
|
+
n.push({
|
|
234
|
+
node: e.left,
|
|
235
|
+
depth: r + 1
|
|
236
|
+
}), n.push({
|
|
237
|
+
node: e.right,
|
|
238
|
+
depth: r + 1
|
|
239
|
+
});
|
|
240
|
+
break;
|
|
241
|
+
case "conditional":
|
|
242
|
+
n.push({
|
|
243
|
+
node: e.test,
|
|
244
|
+
depth: r + 1
|
|
245
|
+
}), n.push({
|
|
246
|
+
node: e.consequent,
|
|
247
|
+
depth: r + 1
|
|
248
|
+
}), n.push({
|
|
249
|
+
node: e.alternate,
|
|
250
|
+
depth: r + 1
|
|
251
|
+
});
|
|
252
|
+
break;
|
|
253
|
+
case "call":
|
|
254
|
+
for (let t of e.args) n.push({
|
|
255
|
+
node: t,
|
|
256
|
+
depth: r + 1
|
|
257
|
+
});
|
|
258
|
+
break;
|
|
259
|
+
case "array":
|
|
260
|
+
for (let t of e.elements) n.push({
|
|
261
|
+
node: t,
|
|
262
|
+
depth: r + 1
|
|
263
|
+
});
|
|
264
|
+
break;
|
|
265
|
+
case "index": n.push({
|
|
266
|
+
node: e.target,
|
|
267
|
+
depth: r + 1
|
|
268
|
+
}), n.push({
|
|
269
|
+
node: e.index,
|
|
270
|
+
depth: r + 1
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
return t;
|
|
275
|
+
}
|
|
276
|
+
var ce = class {
|
|
277
|
+
tokens;
|
|
278
|
+
position = 0;
|
|
279
|
+
nodeCount = 0;
|
|
280
|
+
dependencyNames = [];
|
|
281
|
+
dependencySet = /* @__PURE__ */ new Set();
|
|
282
|
+
dependencyStarts = /* @__PURE__ */ new Map();
|
|
283
|
+
constructor(e) {
|
|
284
|
+
this.tokens = ae(e);
|
|
285
|
+
}
|
|
286
|
+
get dependencies() {
|
|
287
|
+
return this.dependencyNames;
|
|
288
|
+
}
|
|
289
|
+
get dependencyOffsets() {
|
|
290
|
+
return this.dependencyStarts;
|
|
291
|
+
}
|
|
292
|
+
parse() {
|
|
293
|
+
if (this.peek().kind === "eof") throw new o("expression-empty", "Expression is empty.", 0);
|
|
294
|
+
let e = this.parseConditional(0), t = this.peek();
|
|
295
|
+
if (t.kind !== "eof") throw new o("expression-syntax", `Unexpected content "${t.value}".`, t.start);
|
|
296
|
+
if (se(e) > 200) throw new o("expression-budget", "Expression is nested too deeply.", e.start);
|
|
297
|
+
return e;
|
|
298
|
+
}
|
|
299
|
+
peek() {
|
|
300
|
+
return this.tokens[this.position];
|
|
301
|
+
}
|
|
302
|
+
next() {
|
|
303
|
+
let e = this.tokens[this.position];
|
|
304
|
+
return this.position += 1, e;
|
|
305
|
+
}
|
|
306
|
+
isPunct(e) {
|
|
307
|
+
let t = this.peek();
|
|
308
|
+
return t.kind === "punct" && t.value === e;
|
|
309
|
+
}
|
|
310
|
+
expect(e) {
|
|
311
|
+
let t = this.peek();
|
|
312
|
+
if (t.kind !== "punct" || t.value !== e) throw new o("expression-syntax", `Missing "${e}".`, t.start);
|
|
313
|
+
return this.next();
|
|
314
|
+
}
|
|
315
|
+
node(e, t, n) {
|
|
316
|
+
if (this.nodeCount += 1, this.nodeCount > 2e3) throw new o("expression-budget", "Expression is too complex.", n);
|
|
317
|
+
if (t > 100) throw new o("expression-budget", "Expression is nested too deeply.", n);
|
|
318
|
+
return e;
|
|
319
|
+
}
|
|
320
|
+
parseConditional(e) {
|
|
321
|
+
let t = this.parseOr(e);
|
|
322
|
+
if (!this.isPunct("?")) return t;
|
|
323
|
+
let n = t.start;
|
|
324
|
+
this.next();
|
|
325
|
+
let r = this.parseConditional(e + 1);
|
|
326
|
+
this.expect(":");
|
|
327
|
+
let i = this.parseConditional(e + 1);
|
|
328
|
+
return this.node({
|
|
329
|
+
kind: "conditional",
|
|
330
|
+
test: t,
|
|
331
|
+
consequent: r,
|
|
332
|
+
alternate: i,
|
|
333
|
+
start: n
|
|
334
|
+
}, e, n);
|
|
335
|
+
}
|
|
336
|
+
parseOr(e) {
|
|
337
|
+
let t = this.parseAnd(e);
|
|
338
|
+
for (; this.isPunct("||");) {
|
|
339
|
+
let n = t.start;
|
|
340
|
+
this.next();
|
|
341
|
+
let r = this.parseAnd(e);
|
|
342
|
+
t = this.node({
|
|
343
|
+
kind: "binary",
|
|
344
|
+
operator: "||",
|
|
345
|
+
left: t,
|
|
346
|
+
right: r,
|
|
347
|
+
start: n
|
|
348
|
+
}, e, n);
|
|
349
|
+
}
|
|
350
|
+
return t;
|
|
351
|
+
}
|
|
352
|
+
parseAnd(e) {
|
|
353
|
+
let t = this.parseEquality(e);
|
|
354
|
+
for (; this.isPunct("&&");) {
|
|
355
|
+
let n = t.start;
|
|
356
|
+
this.next();
|
|
357
|
+
let r = this.parseEquality(e);
|
|
358
|
+
t = this.node({
|
|
359
|
+
kind: "binary",
|
|
360
|
+
operator: "&&",
|
|
361
|
+
left: t,
|
|
362
|
+
right: r,
|
|
363
|
+
start: n
|
|
364
|
+
}, e, n);
|
|
365
|
+
}
|
|
366
|
+
return t;
|
|
367
|
+
}
|
|
368
|
+
parseEquality(e) {
|
|
369
|
+
let t = this.parseRelational(e);
|
|
370
|
+
for (; this.isPunct("==") || this.isPunct("!=");) {
|
|
371
|
+
let n = t.start, r = this.next().value, i = this.parseRelational(e);
|
|
372
|
+
t = this.node({
|
|
373
|
+
kind: "binary",
|
|
374
|
+
operator: r,
|
|
375
|
+
left: t,
|
|
376
|
+
right: i,
|
|
377
|
+
start: n
|
|
378
|
+
}, e, n);
|
|
379
|
+
}
|
|
380
|
+
return t;
|
|
381
|
+
}
|
|
382
|
+
parseRelational(e) {
|
|
383
|
+
let t = this.parseAdditive(e);
|
|
384
|
+
for (; this.isPunct("<") || this.isPunct("<=") || this.isPunct(">") || this.isPunct(">=");) {
|
|
385
|
+
let n = t.start, r = this.next().value, i = this.parseAdditive(e);
|
|
386
|
+
t = this.node({
|
|
387
|
+
kind: "binary",
|
|
388
|
+
operator: r,
|
|
389
|
+
left: t,
|
|
390
|
+
right: i,
|
|
391
|
+
start: n
|
|
392
|
+
}, e, n);
|
|
393
|
+
}
|
|
394
|
+
return t;
|
|
395
|
+
}
|
|
396
|
+
parseAdditive(e) {
|
|
397
|
+
let t = this.parseMultiplicative(e);
|
|
398
|
+
for (; this.isPunct("+") || this.isPunct("-");) {
|
|
399
|
+
let n = t.start, r = this.next().value, i = this.parseMultiplicative(e);
|
|
400
|
+
t = this.node({
|
|
401
|
+
kind: "binary",
|
|
402
|
+
operator: r,
|
|
403
|
+
left: t,
|
|
404
|
+
right: i,
|
|
405
|
+
start: n
|
|
406
|
+
}, e, n);
|
|
407
|
+
}
|
|
408
|
+
return t;
|
|
409
|
+
}
|
|
410
|
+
parseMultiplicative(e) {
|
|
411
|
+
let t = this.parseUnary(e);
|
|
412
|
+
for (; this.isPunct("*") || this.isPunct("/") || this.isPunct("%");) {
|
|
413
|
+
let n = t.start, r = this.next().value, i = this.parseUnary(e);
|
|
414
|
+
t = this.node({
|
|
415
|
+
kind: "binary",
|
|
416
|
+
operator: r,
|
|
417
|
+
left: t,
|
|
418
|
+
right: i,
|
|
419
|
+
start: n
|
|
420
|
+
}, e, n);
|
|
421
|
+
}
|
|
422
|
+
return t;
|
|
423
|
+
}
|
|
424
|
+
parseUnary(e) {
|
|
425
|
+
let t = this.peek();
|
|
426
|
+
if (t.kind === "punct" && (t.value === "-" || t.value === "+" || t.value === "!")) {
|
|
427
|
+
this.next();
|
|
428
|
+
let n = this.parseUnary(e + 1);
|
|
429
|
+
return this.node({
|
|
430
|
+
kind: "unary",
|
|
431
|
+
operator: t.value,
|
|
432
|
+
operand: n,
|
|
433
|
+
start: t.start
|
|
434
|
+
}, e, t.start);
|
|
435
|
+
}
|
|
436
|
+
return this.parsePrimary(e);
|
|
437
|
+
}
|
|
438
|
+
parsePrimary(e) {
|
|
439
|
+
let t = this.parseAtom(e);
|
|
440
|
+
for (; this.isPunct("[");) {
|
|
441
|
+
let n = t.start;
|
|
442
|
+
this.next();
|
|
443
|
+
let r = this.parseConditional(e + 1);
|
|
444
|
+
this.expect("]"), t = this.node({
|
|
445
|
+
kind: "index",
|
|
446
|
+
target: t,
|
|
447
|
+
index: r,
|
|
448
|
+
start: n
|
|
449
|
+
}, e, n);
|
|
450
|
+
}
|
|
451
|
+
return t;
|
|
452
|
+
}
|
|
453
|
+
parseAtom(e) {
|
|
454
|
+
let t = this.peek();
|
|
455
|
+
if (t.kind === "number") return this.next(), this.node({
|
|
456
|
+
kind: "literal",
|
|
457
|
+
value: t.number,
|
|
458
|
+
start: t.start
|
|
459
|
+
}, e, t.start);
|
|
460
|
+
if (t.kind === "string") return this.next(), this.node({
|
|
461
|
+
kind: "literal",
|
|
462
|
+
value: t.value,
|
|
463
|
+
start: t.start
|
|
464
|
+
}, e, t.start);
|
|
465
|
+
if (t.kind === "ident") {
|
|
466
|
+
this.next();
|
|
467
|
+
let n = t.value;
|
|
468
|
+
if (this.isPunct("(")) {
|
|
469
|
+
if (!c.has(n)) throw new o("expression-unknown-function", `Unknown function "${n}".`, t.start);
|
|
470
|
+
this.next();
|
|
471
|
+
let r = [];
|
|
472
|
+
if (!this.isPunct(")")) for (r.push(this.parseConditional(e + 1)); this.isPunct(",");) this.next(), r.push(this.parseConditional(e + 1));
|
|
473
|
+
this.expect(")");
|
|
474
|
+
let [i, a] = oe[n];
|
|
475
|
+
if (r.length < i || r.length > a) throw new o("expression-arity", `Function ${n} expects ${i === a ? `${i} ${i === 1 ? "argument" : "arguments"}` : i === 1 ? "at least one argument" : `${i}–${a} arguments`}.`, t.start);
|
|
476
|
+
return this.node({
|
|
477
|
+
kind: "call",
|
|
478
|
+
name: n,
|
|
479
|
+
args: r,
|
|
480
|
+
start: t.start
|
|
481
|
+
}, e, t.start);
|
|
482
|
+
}
|
|
483
|
+
if (n === "true" || n === "false") return this.node({
|
|
484
|
+
kind: "literal",
|
|
485
|
+
value: n === "true",
|
|
486
|
+
start: t.start
|
|
487
|
+
}, e, t.start);
|
|
488
|
+
if (n === "null") return this.node({
|
|
489
|
+
kind: "literal",
|
|
490
|
+
value: null,
|
|
491
|
+
start: t.start
|
|
492
|
+
}, e, t.start);
|
|
493
|
+
let r = l.get(n);
|
|
494
|
+
if (r !== void 0) return this.node({
|
|
495
|
+
kind: "literal",
|
|
496
|
+
value: r,
|
|
497
|
+
start: t.start
|
|
498
|
+
}, e, t.start);
|
|
499
|
+
if (u.has(n)) throw new o("expression-forbidden-name", `Name "${n}" is not allowed.`, t.start);
|
|
500
|
+
if (c.has(n)) throw new o("expression-syntax", `Function ${n} must be called with parentheses.`, t.start);
|
|
501
|
+
return this.dependencySet.has(n) || (this.dependencySet.add(n), this.dependencyNames.push(n), this.dependencyStarts.set(n, t.start)), this.node({
|
|
502
|
+
kind: "reference",
|
|
503
|
+
name: n,
|
|
504
|
+
start: t.start
|
|
505
|
+
}, e, t.start);
|
|
506
|
+
}
|
|
507
|
+
if (t.kind === "punct" && t.value === "(") {
|
|
508
|
+
this.next();
|
|
509
|
+
let t = this.parseConditional(e + 1);
|
|
510
|
+
return this.expect(")"), t;
|
|
511
|
+
}
|
|
512
|
+
if (t.kind === "punct" && t.value === "[") {
|
|
513
|
+
this.next();
|
|
514
|
+
let n = [];
|
|
515
|
+
if (!this.isPunct("]")) for (n.push(this.parseConditional(e + 1)); this.isPunct(",");) this.next(), n.push(this.parseConditional(e + 1));
|
|
516
|
+
return this.expect("]"), this.node({
|
|
517
|
+
kind: "array",
|
|
518
|
+
elements: n,
|
|
519
|
+
start: t.start
|
|
520
|
+
}, e, t.start);
|
|
521
|
+
}
|
|
522
|
+
throw new o("expression-syntax", "Expected an expression.", t.start);
|
|
523
|
+
}
|
|
524
|
+
}, g = class extends Error {
|
|
525
|
+
code;
|
|
526
|
+
constructor(e, t) {
|
|
527
|
+
super(t), this.name = "LocalFunctionError", this.code = e;
|
|
528
|
+
}
|
|
529
|
+
}, _ = [
|
|
530
|
+
"en-US",
|
|
531
|
+
"zh-CN",
|
|
532
|
+
"de-DE",
|
|
533
|
+
"fr-FR",
|
|
534
|
+
"ja-JP"
|
|
535
|
+
], le = new Set(_), ue = /^[A-Z]{3}$/, v = 20, de = { signDisplay: "negative" };
|
|
536
|
+
function y(e) {
|
|
537
|
+
throw new g("expression-domain", e);
|
|
538
|
+
}
|
|
539
|
+
function b(e, n) {
|
|
540
|
+
if (e.length > 1e5) throw new g("expression-budget", `${n} exceeds the ${t}-character limit.`);
|
|
541
|
+
return e;
|
|
542
|
+
}
|
|
543
|
+
function x(e) {
|
|
544
|
+
return le.has(e) || y(`Unsupported locale "${e}"; expected one of ${_.join(", ")}.`), e;
|
|
545
|
+
}
|
|
546
|
+
function S(e, t) {
|
|
547
|
+
return (!Number.isInteger(e) || e < 0 || e > v) && y(`${t} digits must be an integer from 0 to ${v}.`), e;
|
|
548
|
+
}
|
|
549
|
+
function C(e) {
|
|
550
|
+
if (!Number.isFinite(e)) throw new g("expression-number", "Value must be a finite number.");
|
|
551
|
+
return e;
|
|
552
|
+
}
|
|
553
|
+
function w(e, t, n, r, i) {
|
|
554
|
+
let a;
|
|
555
|
+
try {
|
|
556
|
+
a = new Intl.NumberFormat(e, {
|
|
557
|
+
...t,
|
|
558
|
+
...de
|
|
559
|
+
});
|
|
560
|
+
} catch {
|
|
561
|
+
a = void 0;
|
|
562
|
+
}
|
|
563
|
+
return a === void 0 && y(i), b(a.format(n), r);
|
|
564
|
+
}
|
|
565
|
+
function fe(e, t = 2, n = "en-US", r = !0) {
|
|
566
|
+
let i = x(n), a = S(t, "formatNumber");
|
|
567
|
+
return typeof r != "boolean" && y("formatNumber grouping must be a boolean."), e === null ? "" : w(i, {
|
|
568
|
+
useGrouping: r,
|
|
569
|
+
minimumFractionDigits: a,
|
|
570
|
+
maximumFractionDigits: a,
|
|
571
|
+
roundingMode: "halfExpand"
|
|
572
|
+
}, C(e), "Formatted number", `Cannot format a number for locale "${i}".`);
|
|
573
|
+
}
|
|
574
|
+
function pe(e, t = 0, n = "en-US") {
|
|
575
|
+
let r = x(n), i = S(t, "formatPercent");
|
|
576
|
+
return e === null ? "" : w(r, {
|
|
577
|
+
style: "percent",
|
|
578
|
+
minimumFractionDigits: i,
|
|
579
|
+
maximumFractionDigits: i,
|
|
580
|
+
roundingMode: "halfExpand"
|
|
581
|
+
}, C(e), "Formatted percentage", `Cannot format a percentage for locale "${r}".`);
|
|
582
|
+
}
|
|
583
|
+
function me(e, t = 2, n = "en-US") {
|
|
584
|
+
let r = x(n), i = S(t, "formatScientific");
|
|
585
|
+
return e === null ? "" : w(r, {
|
|
586
|
+
notation: "scientific",
|
|
587
|
+
minimumFractionDigits: i,
|
|
588
|
+
maximumFractionDigits: i,
|
|
589
|
+
roundingMode: "halfExpand"
|
|
590
|
+
}, C(e), "Formatted number", `Cannot format a number for locale "${r}".`);
|
|
591
|
+
}
|
|
592
|
+
function he(e, t = "USD", n = 2, r = "en-US") {
|
|
593
|
+
let i = x(r);
|
|
594
|
+
ue.test(t) || y(`Currency "${t}" must be a three-letter uppercase code such as "USD".`);
|
|
595
|
+
let a = S(n, "formatCurrency");
|
|
596
|
+
return e === null ? "" : w(i, {
|
|
597
|
+
style: "currency",
|
|
598
|
+
currency: t,
|
|
599
|
+
minimumFractionDigits: a,
|
|
600
|
+
maximumFractionDigits: a,
|
|
601
|
+
roundingMode: "halfExpand"
|
|
602
|
+
}, C(e), "Formatted currency", `Currency code "${t}" is not accepted by Intl.`);
|
|
603
|
+
}
|
|
604
|
+
// src/local/evaluation/expression/inference.ts
|
|
605
|
+
function T(e) {
|
|
606
|
+
switch (e) {
|
|
607
|
+
case "string": return "string";
|
|
608
|
+
case "number": return "number";
|
|
609
|
+
case "boolean": return "boolean";
|
|
610
|
+
case "null": return "null";
|
|
611
|
+
case "array": return "array";
|
|
612
|
+
case "number-array": return "number array";
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function E(e) {
|
|
616
|
+
return e === null ? "null" : Array.isArray(e) ? "array" : typeof e == "boolean" ? "boolean" : typeof e == "number" ? "number" : "string";
|
|
617
|
+
}
|
|
618
|
+
function D(e, t) {
|
|
619
|
+
throw new o("expression-type", e, t);
|
|
620
|
+
}
|
|
621
|
+
function O(e, t, n, r) {
|
|
622
|
+
e !== t && D(`${r}, got ${T(e)}.`, n);
|
|
623
|
+
}
|
|
624
|
+
function ge(e, t) {
|
|
625
|
+
return e === t ? e : e === "null" ? t : t === "null" ? e : null;
|
|
626
|
+
}
|
|
627
|
+
function k(e, t) {
|
|
628
|
+
switch (e.kind) {
|
|
629
|
+
case "literal": return E(e.value);
|
|
630
|
+
case "reference": {
|
|
631
|
+
if (typeof t != "object" || !t || !Object.prototype.hasOwnProperty.call(t, e.name)) throw new o("expression-unknown-name", `Variable "${e.name}" is not declared.`, e.start);
|
|
632
|
+
let n = t[e.name];
|
|
633
|
+
if (typeof n != "string" || !ee.has(n)) throw new o("expression-value", `Variable "${e.name}" has an invalid type.`, e.start);
|
|
634
|
+
return n;
|
|
635
|
+
}
|
|
636
|
+
case "unary": {
|
|
637
|
+
let n = k(e.operand, t);
|
|
638
|
+
return e.operator === "!" ? (O(n, "boolean", e.start, "Logical not requires a boolean"), "boolean") : (O(n, "number", e.start, `Unary ${e.operator} requires a number`), "number");
|
|
639
|
+
}
|
|
640
|
+
case "binary": {
|
|
641
|
+
let n = k(e.left, t), r = k(e.right, t);
|
|
642
|
+
switch (e.operator) {
|
|
643
|
+
case "+": return n === "number" && r === "number" ? "number" : n === "string" && r === "string" ? "string" : D(`Operator "+" requires two numbers or two strings, got ${T(n)} and ${T(r)}.`, e.start);
|
|
644
|
+
case "-":
|
|
645
|
+
case "*":
|
|
646
|
+
case "/":
|
|
647
|
+
case "%": return O(n, "number", e.start, `Operator "${e.operator}" requires a number`), O(r, "number", e.start, `Operator "${e.operator}" requires a number`), "number";
|
|
648
|
+
case "<":
|
|
649
|
+
case "<=":
|
|
650
|
+
case ">":
|
|
651
|
+
case ">=": return n === "number" && r === "number" || n === "string" && r === "string" ? "boolean" : D(`Comparison operator "${e.operator}" requires two numbers or two strings, got ${T(n)} and ${T(r)}.`, e.start);
|
|
652
|
+
case "==":
|
|
653
|
+
case "!=": return n !== r && n !== "null" && r !== "null" ? D(`Equality comparison requires matching types, got ${T(n)} and ${T(r)}.`, e.start) : "boolean";
|
|
654
|
+
case "&&":
|
|
655
|
+
case "||": return O(n, "boolean", e.start, "Logical operators require booleans"), O(r, "boolean", e.start, "Logical operators require booleans"), "boolean";
|
|
656
|
+
}
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
case "array": {
|
|
660
|
+
if (e.elements.length === 0) return "number-array";
|
|
661
|
+
let n = null;
|
|
662
|
+
for (let r of e.elements) {
|
|
663
|
+
let e = k(r, t);
|
|
664
|
+
if (e !== "string" && e !== "number") return D(`Array literals require string or number elements, got ${T(e)}.`, r.start);
|
|
665
|
+
if (n === null) n = e;
|
|
666
|
+
else if (n !== e) return D(`Array literals require elements of one type, got ${T(n)} and ${T(e)}.`, r.start);
|
|
667
|
+
}
|
|
668
|
+
return n === "string" ? "array" : "number-array";
|
|
669
|
+
}
|
|
670
|
+
case "index": {
|
|
671
|
+
let n = k(e.target, t);
|
|
672
|
+
return O(k(e.index, t), "number", e.start, "Array index must be a number"), n === "array" ? "string" : n === "number-array" ? "number" : D(`Index access requires an array, got ${T(n)}.`, e.start);
|
|
673
|
+
}
|
|
674
|
+
case "conditional": {
|
|
675
|
+
O(k(e.test, t), "boolean", e.start, "Conditional test must be a boolean");
|
|
676
|
+
let n = k(e.consequent, t), r = k(e.alternate, t);
|
|
677
|
+
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";
|
|
678
|
+
let i = ge(n, r);
|
|
679
|
+
return i === null ? D(`Conditional branches must have matching types or one null, got ${T(n)} and ${T(r)}.`, e.start) : i;
|
|
680
|
+
}
|
|
681
|
+
case "call": {
|
|
682
|
+
let n = e.args.map((e) => k(e, t));
|
|
683
|
+
switch (e.name) {
|
|
684
|
+
case "abs":
|
|
685
|
+
case "sqrt":
|
|
686
|
+
case "floor":
|
|
687
|
+
case "ceil":
|
|
688
|
+
case "round":
|
|
689
|
+
case "sin":
|
|
690
|
+
case "cos":
|
|
691
|
+
case "tan":
|
|
692
|
+
case "asin":
|
|
693
|
+
case "acos":
|
|
694
|
+
case "atan":
|
|
695
|
+
case "exp":
|
|
696
|
+
case "log": return O(n[0], "number", e.start, `Function ${e.name} requires a number`), "number";
|
|
697
|
+
case "min":
|
|
698
|
+
case "max":
|
|
699
|
+
case "pow":
|
|
700
|
+
case "clamp":
|
|
701
|
+
for (let t of n) O(t, "number", e.start, `Function ${e.name} requires a number`);
|
|
702
|
+
return "number";
|
|
703
|
+
case "len": return n[0] !== "string" && n[0] !== "array" && n[0] !== "number-array" && D(`Function len requires a string or array, got ${T(n[0])}.`, e.start), "number";
|
|
704
|
+
case "contains":
|
|
705
|
+
if (n[0] === "number-array") return O(n[1], "number", e.start, "Function contains requires a numeric member"), "boolean";
|
|
706
|
+
if (n[0] === "string" || n[0] === "array") return O(n[1], "string", e.start, "Function contains requires a string member"), "boolean";
|
|
707
|
+
D(`Function contains requires a string or array, got ${T(n[0])}.`, e.start);
|
|
708
|
+
break;
|
|
709
|
+
case "sum":
|
|
710
|
+
case "average":
|
|
711
|
+
case "minOf":
|
|
712
|
+
case "maxOf": return O(n[0], "number-array", e.start, `Function ${e.name} requires a numeric array`), "number";
|
|
713
|
+
case "formatNumber":
|
|
714
|
+
case "formatPercent":
|
|
715
|
+
case "formatScientific": return n[0] !== "number" && n[0] !== "null" && D(`Function ${e.name} requires a number or null, got ${T(n[0])}.`, e.start), n[1] !== void 0 && O(n[1], "number", e.start, `Function ${e.name} requires numeric fraction digits`), n[2] !== void 0 && O(n[2], "string", e.start, `Function ${e.name} requires a string locale`), e.name === "formatNumber" && n[3] !== void 0 && O(n[3], "boolean", e.start, "Function formatNumber requires a boolean grouping flag"), "string";
|
|
716
|
+
case "formatCurrency": return n[0] !== "number" && n[0] !== "null" && D(`Function formatCurrency requires a number or null, got ${T(n[0])}.`, e.start), n[1] !== void 0 && O(n[1], "string", e.start, "Function formatCurrency requires a string currency code"), n[2] !== void 0 && O(n[2], "number", e.start, "Function formatCurrency requires numeric fraction digits"), n[3] !== void 0 && O(n[3], "string", e.start, "Function formatCurrency requires a string locale"), "string";
|
|
717
|
+
case "trim":
|
|
718
|
+
case "lower":
|
|
719
|
+
case "upper": return O(n[0], "string", e.start, `Function ${e.name} requires a string`), "string";
|
|
720
|
+
case "startsWith":
|
|
721
|
+
case "endsWith": return O(n[0], "string", e.start, `Function ${e.name} requires a string`), O(n[1], "string", e.start, `Function ${e.name} requires a string search value`), "boolean";
|
|
722
|
+
case "replace": return O(n[0], "string", e.start, "Function replace requires a string"), O(n[1], "string", e.start, "Function replace requires a string search value"), O(n[2], "string", e.start, "Function replace requires a string replacement"), "string";
|
|
723
|
+
case "slice": return O(n[0], "string", e.start, "Function slice requires a string"), O(n[1], "number", e.start, "Function slice requires a numeric start index"), n[2] !== void 0 && O(n[2], "number", e.start, "Function slice requires a numeric end index"), "string";
|
|
724
|
+
case "dateCompare": return O(n[0], "string", e.start, "Function dateCompare requires a date string"), O(n[1], "string", e.start, "Function dateCompare requires a date string"), "number";
|
|
725
|
+
case "dateDiff": return O(n[0], "string", e.start, "Function dateDiff requires a date string"), O(n[1], "string", e.start, "Function dateDiff requires a date string"), n[2] !== void 0 && O(n[2], "string", e.start, "Function dateDiff requires a string unit"), "number";
|
|
726
|
+
}
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
throw new o("expression-type", "Unsupported expression.", 0);
|
|
731
|
+
}
|
|
732
|
+
// src/local/evaluation/expression/collection-functions.ts
|
|
733
|
+
function A() {
|
|
734
|
+
throw new g("expression-number", "The result is not a finite number.");
|
|
735
|
+
}
|
|
736
|
+
function j(e) {
|
|
737
|
+
if (!Number.isFinite(e)) throw new g("expression-value", "Numeric array members must be finite numbers.");
|
|
738
|
+
return e;
|
|
739
|
+
}
|
|
740
|
+
function M(e) {
|
|
741
|
+
let t = 0;
|
|
742
|
+
for (let n of e) t += j(n);
|
|
743
|
+
return Number.isFinite(t) || A(), t;
|
|
744
|
+
}
|
|
745
|
+
function _e(e) {
|
|
746
|
+
if (e.length === 0) return null;
|
|
747
|
+
let t = M(e) / e.length;
|
|
748
|
+
return Number.isFinite(t) || A(), t;
|
|
749
|
+
}
|
|
750
|
+
function N(e) {
|
|
751
|
+
if (e.length === 0) return null;
|
|
752
|
+
let t = j(e[0]);
|
|
753
|
+
for (let n = 1; n < e.length; n += 1) {
|
|
754
|
+
let r = j(e[n]);
|
|
755
|
+
r < t && (t = r);
|
|
756
|
+
}
|
|
757
|
+
return t;
|
|
758
|
+
}
|
|
759
|
+
function P(e) {
|
|
760
|
+
if (e.length === 0) return null;
|
|
761
|
+
let t = j(e[0]);
|
|
762
|
+
for (let n = 1; n < e.length; n += 1) {
|
|
763
|
+
let r = j(e[n]);
|
|
764
|
+
r > t && (t = r);
|
|
765
|
+
}
|
|
766
|
+
return t;
|
|
767
|
+
}
|
|
768
|
+
// src/local/evaluation/expression/data-functions.ts
|
|
769
|
+
function F(e) {
|
|
770
|
+
throw new g("expression-domain", e);
|
|
771
|
+
}
|
|
772
|
+
function I(e) {
|
|
773
|
+
return b(e.trim(), "trim result");
|
|
774
|
+
}
|
|
775
|
+
function ve(e) {
|
|
776
|
+
return b(e.toLowerCase(), "lower result");
|
|
777
|
+
}
|
|
778
|
+
function ye(e) {
|
|
779
|
+
return b(e.toUpperCase(), "upper result");
|
|
780
|
+
}
|
|
781
|
+
function be(e, t) {
|
|
782
|
+
return e.startsWith(t);
|
|
783
|
+
}
|
|
784
|
+
function xe(e, t) {
|
|
785
|
+
return e.endsWith(t);
|
|
786
|
+
}
|
|
787
|
+
function Se(e, n, r) {
|
|
788
|
+
n.length === 0 && F("replace search text must not be empty.");
|
|
789
|
+
let i = r.length - n.length;
|
|
790
|
+
if (i > 0) {
|
|
791
|
+
let r = 0, a = 0;
|
|
792
|
+
for (;;) {
|
|
793
|
+
let t = e.indexOf(n, a);
|
|
794
|
+
if (t < 0) break;
|
|
795
|
+
r += 1, a = t + n.length;
|
|
796
|
+
}
|
|
797
|
+
if (e.length + r * i > 1e5) throw new g("expression-budget", `replace result would exceed the ${t}-character limit.`);
|
|
798
|
+
}
|
|
799
|
+
let a = "", o = 0;
|
|
800
|
+
for (;;) {
|
|
801
|
+
let t = e.indexOf(n, o);
|
|
802
|
+
if (t < 0) break;
|
|
803
|
+
a += e.slice(o, t), a += r, o = t + n.length;
|
|
804
|
+
}
|
|
805
|
+
return a += e.slice(o), b(a, "replace result");
|
|
806
|
+
}
|
|
807
|
+
function L(e, t) {
|
|
808
|
+
return e < 0 ? Math.max(t + e, 0) : Math.min(e, t);
|
|
809
|
+
}
|
|
810
|
+
function Ce(e, t, n) {
|
|
811
|
+
Number.isInteger(t) || F("slice start must be an integer."), n !== void 0 && !Number.isInteger(n) && F("slice end must be an integer.");
|
|
812
|
+
let r = Array.from(e), i = r.length, a = L(t, i), o = n === void 0 ? i : L(n, i);
|
|
813
|
+
return o <= a ? "" : b(r.slice(a, o).join(""), "slice result");
|
|
814
|
+
}
|
|
815
|
+
var we = /* @__PURE__ */ new Map([
|
|
816
|
+
["days", 864e5],
|
|
817
|
+
["hours", 36e5],
|
|
818
|
+
["minutes", 6e4],
|
|
819
|
+
["seconds", 1e3],
|
|
820
|
+
["milliseconds", 1]
|
|
821
|
+
]), Te = "days, hours, minutes, seconds or milliseconds";
|
|
822
|
+
function R(e) {
|
|
823
|
+
let t = Oe(e);
|
|
824
|
+
if (t === null) throw new g("expression-domain", `Date "${e}" must be a valid YYYY-MM-DD calendar date in years 0001-9999.`);
|
|
825
|
+
return t;
|
|
826
|
+
}
|
|
827
|
+
function Ee(e, t) {
|
|
828
|
+
let n = R(e), r = R(t);
|
|
829
|
+
return n === r ? 0 : n < r ? -1 : 1;
|
|
830
|
+
}
|
|
831
|
+
function De(e, t, n = "days") {
|
|
832
|
+
let r = we.get(n);
|
|
833
|
+
return r === void 0 && F(`dateDiff unit must be ${Te}.`), (R(e) - R(t)) / r;
|
|
834
|
+
}
|
|
835
|
+
function Oe(e) {
|
|
836
|
+
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
837
|
+
if (!t) return null;
|
|
838
|
+
let n = Number(t[1]), r = Number(t[2]), i = Number(t[3]);
|
|
839
|
+
if (n < 1 || r < 1 || r > 12 || i < 1 || i > 31) return null;
|
|
840
|
+
let a = /* @__PURE__ */ new Date(0);
|
|
841
|
+
return a.setUTCFullYear(n, r - 1, i), a.getUTCFullYear() === n && a.getUTCMonth() === r - 1 && a.getUTCDate() === i ? a.getTime() : null;
|
|
842
|
+
}
|
|
843
|
+
// src/local/evaluation/expression/evaluation.ts
|
|
844
|
+
function z(e, t, n = "expression-eval") {
|
|
845
|
+
throw new o(n, e, t);
|
|
846
|
+
}
|
|
847
|
+
function ke(e) {
|
|
848
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw new o("expression-value", "Expression environment must be an object.", 0);
|
|
849
|
+
}
|
|
850
|
+
function Ae(e, t, n) {
|
|
851
|
+
if (e === null) return null;
|
|
852
|
+
if (typeof e == "string") {
|
|
853
|
+
let r = m(e);
|
|
854
|
+
if (r) throw new o("expression-budget", `Variable "${t}": ${r}`, n);
|
|
855
|
+
return e;
|
|
856
|
+
}
|
|
857
|
+
if (typeof e == "boolean") return e;
|
|
858
|
+
if (typeof e == "number") {
|
|
859
|
+
if (!Number.isFinite(e)) throw new o("expression-value", `Variable "${t}" must be a finite number.`, n);
|
|
860
|
+
return e;
|
|
861
|
+
}
|
|
862
|
+
if (Array.isArray(e)) {
|
|
863
|
+
let r = f(e);
|
|
864
|
+
if (r) throw new o(r.code, `Variable "${t}": ${r.message}`, n);
|
|
865
|
+
return e;
|
|
866
|
+
}
|
|
867
|
+
throw new o("expression-value", `Variable "${t}" has an invalid value type.`, n);
|
|
868
|
+
}
|
|
869
|
+
function je(e, t, n) {
|
|
870
|
+
return ke(e), Object.prototype.hasOwnProperty.call(e, t) || z(`Variable "${t}" is not declared.`, n, "expression-unknown-name"), Ae(e[t], t, n);
|
|
871
|
+
}
|
|
872
|
+
function B(e, t, n = "Expected a number") {
|
|
873
|
+
return typeof e == "number" && Number.isFinite(e) || z(`${n}.`, t, "expression-type"), e;
|
|
874
|
+
}
|
|
875
|
+
function V(e, t, n = "Expected a boolean") {
|
|
876
|
+
return typeof e != "boolean" && z(`${n}.`, t, "expression-type"), e;
|
|
877
|
+
}
|
|
878
|
+
function H(e, t, n = "Expected a string") {
|
|
879
|
+
return typeof e != "string" && z(`${n}.`, t, "expression-type"), e;
|
|
880
|
+
}
|
|
881
|
+
function U(e, t, n) {
|
|
882
|
+
Array.isArray(e) || z(`${n}.`, t, "expression-type");
|
|
883
|
+
for (let r of e) typeof r == "number" && Number.isFinite(r) || z(`${n}.`, t, "expression-type");
|
|
884
|
+
return e;
|
|
885
|
+
}
|
|
886
|
+
function Me(e, t) {
|
|
887
|
+
let n = f(e);
|
|
888
|
+
return n && z(n.message, t, n.code), e;
|
|
889
|
+
}
|
|
890
|
+
function W(e, t) {
|
|
891
|
+
try {
|
|
892
|
+
return t();
|
|
893
|
+
} catch (t) {
|
|
894
|
+
throw t instanceof g ? new o(t.code, t.message, e) : t;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
function G(e, t) {
|
|
898
|
+
return Number.isNaN(e) && z("The result is undefined.", t, "expression-domain"), Number.isFinite(e) || z("The result is not a finite number.", t, "expression-number"), e;
|
|
899
|
+
}
|
|
900
|
+
function Ne(e, t) {
|
|
901
|
+
let n = Array.from(e), r = Array.from(t), i = Math.min(n.length, r.length);
|
|
902
|
+
for (let e = 0; e < i; e += 1) {
|
|
903
|
+
let t = n[e].codePointAt(0), i = r[e].codePointAt(0);
|
|
904
|
+
if (t !== i) return t < i ? -1 : 1;
|
|
905
|
+
}
|
|
906
|
+
return n.length === r.length ? 0 : n.length < r.length ? -1 : 1;
|
|
907
|
+
}
|
|
908
|
+
function Pe(e, t) {
|
|
909
|
+
if (e === t) return !0;
|
|
910
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
911
|
+
if (e.length !== t.length) return !1;
|
|
912
|
+
for (let n = 0; n < e.length; n += 1) if (e[n] !== t[n]) return !1;
|
|
913
|
+
return !0;
|
|
914
|
+
}
|
|
915
|
+
return !1;
|
|
916
|
+
}
|
|
917
|
+
function Fe(e, t) {
|
|
918
|
+
return K(e, t, { steps: 0 }, 1);
|
|
919
|
+
}
|
|
920
|
+
function K(e, t, n, i) {
|
|
921
|
+
switch (n.steps += 1, n.steps > 1e4 && z("Expression evaluation exceeded the step limit.", e.start, "expression-budget"), i > 250 && z("Expression evaluation is nested too deeply.", e.start, "expression-budget"), e.kind) {
|
|
922
|
+
case "literal": return e.value;
|
|
923
|
+
case "reference": return je(t, e.name, e.start);
|
|
924
|
+
case "unary": {
|
|
925
|
+
let r = K(e.operand, t, n, i + 1);
|
|
926
|
+
if (e.operator === "!") return !V(r, e.start, "Logical not requires a boolean");
|
|
927
|
+
let a = B(r, e.start, `Unary ${e.operator} requires a number`);
|
|
928
|
+
return G(e.operator === "-" ? -a : a, e.start);
|
|
929
|
+
}
|
|
930
|
+
case "binary": {
|
|
931
|
+
if (e.operator === "&&" || e.operator === "||") {
|
|
932
|
+
let r = V(K(e.left, t, n, i + 1), e.start, "Logical operators require booleans");
|
|
933
|
+
return e.operator === "&&" && !r ? !1 : e.operator === "||" && r ? !0 : V(K(e.right, t, n, i + 1), e.start, "Logical operators require booleans");
|
|
934
|
+
}
|
|
935
|
+
let r = K(e.left, t, n, i + 1), a = K(e.right, t, n, i + 1);
|
|
936
|
+
switch (e.operator) {
|
|
937
|
+
case "+":
|
|
938
|
+
if (typeof r == "number" && typeof a == "number") return G(r + a, e.start);
|
|
939
|
+
if (typeof r == "string" && typeof a == "string") {
|
|
940
|
+
let t = r + a;
|
|
941
|
+
return t.length > d && z("String result exceeds the length limit.", e.start, "expression-budget"), t;
|
|
942
|
+
}
|
|
943
|
+
z("Operator \"+\" requires two numbers or two strings.", e.start, "expression-type");
|
|
944
|
+
case "-":
|
|
945
|
+
case "*":
|
|
946
|
+
case "/":
|
|
947
|
+
case "%": {
|
|
948
|
+
let t = B(r, e.start, `Operator "${e.operator}" requires a number`), n = B(a, e.start, `Operator "${e.operator}" requires a number`);
|
|
949
|
+
return (e.operator === "/" || e.operator === "%") && n === 0 && z("Division by zero.", e.start, "expression-divide-by-zero"), G(e.operator === "-" ? t - n : e.operator === "*" ? t * n : e.operator === "/" ? t / n : t % n, e.start);
|
|
950
|
+
}
|
|
951
|
+
case "==":
|
|
952
|
+
case "!=": {
|
|
953
|
+
let t = E(r), n = E(a);
|
|
954
|
+
t !== n && t !== "null" && n !== "null" && z("Equality comparison requires matching types.", e.start, "expression-type");
|
|
955
|
+
let i = Pe(r, a);
|
|
956
|
+
return e.operator === "==" ? i : !i;
|
|
957
|
+
}
|
|
958
|
+
case "<":
|
|
959
|
+
case "<=":
|
|
960
|
+
case ">":
|
|
961
|
+
case ">=": {
|
|
962
|
+
let t;
|
|
963
|
+
return typeof r == "number" && typeof a == "number" ? t = r === a ? 0 : r < a ? -1 : 1 : typeof r == "string" && typeof a == "string" ? t = Ne(r, a) : z(`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;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
break;
|
|
967
|
+
}
|
|
968
|
+
case "conditional": return K(V(K(e.test, t, n, i + 1), e.start, "Conditional test must be a boolean") ? e.consequent : e.alternate, t, n, i + 1);
|
|
969
|
+
case "array": {
|
|
970
|
+
let r = [];
|
|
971
|
+
for (let a of e.elements) r.push(K(a, t, n, i + 1));
|
|
972
|
+
return Me(r, e.start);
|
|
973
|
+
}
|
|
974
|
+
case "index": {
|
|
975
|
+
let r = K(e.target, t, n, i + 1), a = B(K(e.index, t, n, i + 1), e.start, "Array index must be a number");
|
|
976
|
+
return Number.isSafeInteger(a) || z("Array index must be a finite integer.", e.start, "expression-index"), Array.isArray(r) || z("Index access requires an array.", e.start, "expression-type"), a < 0 || a >= r.length ? null : r[a];
|
|
977
|
+
}
|
|
978
|
+
case "call": {
|
|
979
|
+
let a = e.args.map((e) => K(e, t, n, i + 1));
|
|
980
|
+
switch (e.name) {
|
|
981
|
+
case "abs":
|
|
982
|
+
case "sqrt":
|
|
983
|
+
case "floor":
|
|
984
|
+
case "ceil":
|
|
985
|
+
case "round":
|
|
986
|
+
case "sin":
|
|
987
|
+
case "cos":
|
|
988
|
+
case "tan":
|
|
989
|
+
case "asin":
|
|
990
|
+
case "acos":
|
|
991
|
+
case "atan":
|
|
992
|
+
case "exp":
|
|
993
|
+
case "log": {
|
|
994
|
+
let t = B(a[0], e.start, `Function ${e.name} requires a number`);
|
|
995
|
+
e.name === "sqrt" && t < 0 && z("sqrt requires a non-negative argument.", e.start, "expression-domain"), e.name === "log" && t <= 0 && z("log requires a positive argument.", e.start, "expression-domain"), (e.name === "asin" || e.name === "acos") && (t < -1 || t > 1) && z(`${e.name} requires an argument between -1 and 1.`, e.start, "expression-domain");
|
|
996
|
+
let n;
|
|
997
|
+
switch (e.name) {
|
|
998
|
+
case "abs":
|
|
999
|
+
n = Math.abs(t);
|
|
1000
|
+
break;
|
|
1001
|
+
case "sqrt":
|
|
1002
|
+
n = Math.sqrt(t);
|
|
1003
|
+
break;
|
|
1004
|
+
case "floor":
|
|
1005
|
+
n = Math.floor(t);
|
|
1006
|
+
break;
|
|
1007
|
+
case "ceil":
|
|
1008
|
+
n = Math.ceil(t);
|
|
1009
|
+
break;
|
|
1010
|
+
case "round":
|
|
1011
|
+
n = Math.round(t);
|
|
1012
|
+
break;
|
|
1013
|
+
case "sin":
|
|
1014
|
+
n = Math.sin(t);
|
|
1015
|
+
break;
|
|
1016
|
+
case "cos":
|
|
1017
|
+
n = Math.cos(t);
|
|
1018
|
+
break;
|
|
1019
|
+
case "tan":
|
|
1020
|
+
n = Math.tan(t);
|
|
1021
|
+
break;
|
|
1022
|
+
case "asin":
|
|
1023
|
+
n = Math.asin(t);
|
|
1024
|
+
break;
|
|
1025
|
+
case "acos":
|
|
1026
|
+
n = Math.acos(t);
|
|
1027
|
+
break;
|
|
1028
|
+
case "atan":
|
|
1029
|
+
n = Math.atan(t);
|
|
1030
|
+
break;
|
|
1031
|
+
case "exp":
|
|
1032
|
+
n = Math.exp(t);
|
|
1033
|
+
break;
|
|
1034
|
+
default: n = Math.log(t);
|
|
1035
|
+
}
|
|
1036
|
+
return G(n, e.start);
|
|
1037
|
+
}
|
|
1038
|
+
case "min":
|
|
1039
|
+
case "max": {
|
|
1040
|
+
let t = B(a[0], e.start, `Function ${e.name} requires a number`);
|
|
1041
|
+
for (let n = 1; n < a.length; n += 1) {
|
|
1042
|
+
let r = B(a[n], e.start, `Function ${e.name} requires a number`);
|
|
1043
|
+
t = e.name === "min" ? Math.min(t, r) : Math.max(t, r);
|
|
1044
|
+
}
|
|
1045
|
+
return G(t, e.start);
|
|
1046
|
+
}
|
|
1047
|
+
case "pow": return G(B(a[0], e.start, "Function pow requires a number") ** +B(a[1], e.start, "Function pow requires a number"), e.start);
|
|
1048
|
+
case "clamp": {
|
|
1049
|
+
let t = B(a[0], e.start, "Function clamp requires a number"), n = B(a[1], e.start, "Function clamp requires a number"), r = B(a[2], e.start, "Function clamp requires a number");
|
|
1050
|
+
return n > r && z("clamp lower bound cannot exceed upper bound.", e.start, "expression-domain"), G(Math.min(r, Math.max(n, t)), e.start);
|
|
1051
|
+
}
|
|
1052
|
+
case "len": {
|
|
1053
|
+
let t = a[0];
|
|
1054
|
+
if (typeof t == "string") return r(t);
|
|
1055
|
+
if (Array.isArray(t)) return t.length;
|
|
1056
|
+
z("Function len requires a string or array.", e.start, "expression-type");
|
|
1057
|
+
}
|
|
1058
|
+
case "contains": {
|
|
1059
|
+
let t = a[0], n = a[1];
|
|
1060
|
+
if (typeof t == "string") return t.includes(H(n, e.start, "Function contains requires a string member"));
|
|
1061
|
+
if (Array.isArray(t)) {
|
|
1062
|
+
if (typeof n == "string") {
|
|
1063
|
+
for (let n of t) typeof n != "string" && z("Function contains requires a string member for a string array.", e.start, "expression-type");
|
|
1064
|
+
return t.includes(n);
|
|
1065
|
+
}
|
|
1066
|
+
if (typeof n == "number" && Number.isFinite(n)) {
|
|
1067
|
+
for (let n of t) typeof n != "number" && z("Function contains requires a numeric member for a numeric array.", e.start, "expression-type");
|
|
1068
|
+
return t.includes(n);
|
|
1069
|
+
}
|
|
1070
|
+
z("Function contains requires a string or numeric member.", e.start, "expression-type");
|
|
1071
|
+
}
|
|
1072
|
+
z("Function contains requires a string or array.", e.start, "expression-type");
|
|
1073
|
+
}
|
|
1074
|
+
case "sum": {
|
|
1075
|
+
let t = U(a[0], e.start, "Function sum requires a numeric array");
|
|
1076
|
+
return W(e.start, () => M(t));
|
|
1077
|
+
}
|
|
1078
|
+
case "average": {
|
|
1079
|
+
let t = U(a[0], e.start, "Function average requires a numeric array");
|
|
1080
|
+
return W(e.start, () => _e(t));
|
|
1081
|
+
}
|
|
1082
|
+
case "minOf": {
|
|
1083
|
+
let t = U(a[0], e.start, "Function minOf requires a numeric array");
|
|
1084
|
+
return W(e.start, () => N(t));
|
|
1085
|
+
}
|
|
1086
|
+
case "maxOf": {
|
|
1087
|
+
let t = U(a[0], e.start, "Function maxOf requires a numeric array");
|
|
1088
|
+
return W(e.start, () => P(t));
|
|
1089
|
+
}
|
|
1090
|
+
case "formatNumber": {
|
|
1091
|
+
let t = a[0] === null ? null : B(a[0], e.start, "Function formatNumber requires a number or null"), n = a[1] === void 0 ? 2 : B(a[1], e.start, "Function formatNumber requires numeric fraction digits"), r = a[2] === void 0 ? "en-US" : H(a[2], e.start, "Function formatNumber requires a string locale"), i = a[3] === void 0 || V(a[3], e.start, "Function formatNumber requires a boolean grouping flag");
|
|
1092
|
+
return W(e.start, () => fe(t, n, r, i));
|
|
1093
|
+
}
|
|
1094
|
+
case "formatPercent": {
|
|
1095
|
+
let t = a[0] === null ? null : B(a[0], e.start, "Function formatPercent requires a number or null"), n = a[1] === void 0 ? 0 : B(a[1], e.start, "Function formatPercent requires numeric fraction digits"), r = a[2] === void 0 ? "en-US" : H(a[2], e.start, "Function formatPercent requires a string locale");
|
|
1096
|
+
return W(e.start, () => pe(t, n, r));
|
|
1097
|
+
}
|
|
1098
|
+
case "formatScientific": {
|
|
1099
|
+
let t = a[0] === null ? null : B(a[0], e.start, "Function formatScientific requires a number or null"), n = a[1] === void 0 ? 2 : B(a[1], e.start, "Function formatScientific requires numeric fraction digits"), r = a[2] === void 0 ? "en-US" : H(a[2], e.start, "Function formatScientific requires a string locale");
|
|
1100
|
+
return W(e.start, () => me(t, n, r));
|
|
1101
|
+
}
|
|
1102
|
+
case "formatCurrency": {
|
|
1103
|
+
let t = a[0] === null ? null : B(a[0], e.start, "Function formatCurrency requires a number or null"), n = a[1] === void 0 ? "USD" : H(a[1], e.start, "Function formatCurrency requires a string currency code"), r = a[2] === void 0 ? 2 : B(a[2], e.start, "Function formatCurrency requires numeric fraction digits"), i = a[3] === void 0 ? "en-US" : H(a[3], e.start, "Function formatCurrency requires a string locale");
|
|
1104
|
+
return W(e.start, () => he(t, n, r, i));
|
|
1105
|
+
}
|
|
1106
|
+
case "trim": return W(e.start, () => I(H(a[0], e.start, "Function trim requires a string")));
|
|
1107
|
+
case "lower": return W(e.start, () => ve(H(a[0], e.start, "Function lower requires a string")));
|
|
1108
|
+
case "upper": return W(e.start, () => ye(H(a[0], e.start, "Function upper requires a string")));
|
|
1109
|
+
case "startsWith": return W(e.start, () => be(H(a[0], e.start, "Function startsWith requires a string"), H(a[1], e.start, "Function startsWith requires a string search value")));
|
|
1110
|
+
case "endsWith": return W(e.start, () => xe(H(a[0], e.start, "Function endsWith requires a string"), H(a[1], e.start, "Function endsWith requires a string search value")));
|
|
1111
|
+
case "replace": {
|
|
1112
|
+
let t = H(a[0], e.start, "Function replace requires a string"), n = H(a[1], e.start, "Function replace requires a string search value"), r = H(a[2], e.start, "Function replace requires a string replacement");
|
|
1113
|
+
return W(e.start, () => Se(t, n, r));
|
|
1114
|
+
}
|
|
1115
|
+
case "slice": {
|
|
1116
|
+
let t = H(a[0], e.start, "Function slice requires a string"), n = B(a[1], e.start, "Function slice requires a numeric start index"), r = a[2] === void 0 ? void 0 : B(a[2], e.start, "Function slice requires a numeric end index");
|
|
1117
|
+
return W(e.start, () => Ce(t, n, r));
|
|
1118
|
+
}
|
|
1119
|
+
case "dateCompare": {
|
|
1120
|
+
let t = H(a[0], e.start, "Function dateCompare requires a date string"), n = H(a[1], e.start, "Function dateCompare requires a date string");
|
|
1121
|
+
return W(e.start, () => Ee(t, n));
|
|
1122
|
+
}
|
|
1123
|
+
case "dateDiff": {
|
|
1124
|
+
let t = H(a[0], e.start, "Function dateDiff requires a date string"), n = H(a[1], e.start, "Function dateDiff requires a date string"), r = a[2] === void 0 ? "days" : H(a[2], e.start, "Function dateDiff requires a string unit");
|
|
1125
|
+
return W(e.start, () => De(t, n, r));
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
break;
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
throw new o("expression-eval", "Unsupported expression.", 0);
|
|
1132
|
+
}
|
|
1133
|
+
// src/local/evaluation/expression/compile.ts
|
|
1134
|
+
var q = t, Ie = 500, J = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new WeakMap();
|
|
1135
|
+
function Le(e, t) {
|
|
1136
|
+
return Y.get(e)?.get(t);
|
|
1137
|
+
}
|
|
1138
|
+
function X(e) {
|
|
1139
|
+
if (typeof e != "string") throw new o("expression-syntax", "Expression must be a string.", 0);
|
|
1140
|
+
if (e.length > 4e3) throw new o("expression-budget", `Expression exceeds the ${ne}-character limit.`, 0);
|
|
1141
|
+
let t = J.get(e);
|
|
1142
|
+
if (t) return t;
|
|
1143
|
+
let n = new ce(e), r = n.parse(), i = [...n.dependencies], a = Object.freeze({
|
|
1144
|
+
source: e,
|
|
1145
|
+
dependencies: i,
|
|
1146
|
+
evaluate(e) {
|
|
1147
|
+
return Fe(r, e);
|
|
1148
|
+
},
|
|
1149
|
+
inferType(e) {
|
|
1150
|
+
return k(r, e);
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
if (J.size >= Ie) {
|
|
1154
|
+
let e = J.keys().next().value;
|
|
1155
|
+
e !== void 0 && J.delete(e);
|
|
1156
|
+
}
|
|
1157
|
+
return Y.set(a, n.dependencyOffsets), J.set(e, a), a;
|
|
1158
|
+
}
|
|
1159
|
+
function Z(e) {
|
|
1160
|
+
if (e.length > q) throw new o("expression-budget", "Interpolation template exceeds the length limit.", 0);
|
|
1161
|
+
let t = [], n = 0;
|
|
1162
|
+
for (;;) {
|
|
1163
|
+
let r = e.indexOf("{{", n);
|
|
1164
|
+
if (r < 0) {
|
|
1165
|
+
n < e.length && t.push({
|
|
1166
|
+
kind: "text",
|
|
1167
|
+
value: e.slice(n)
|
|
1168
|
+
});
|
|
1169
|
+
break;
|
|
1170
|
+
}
|
|
1171
|
+
r > n && t.push({
|
|
1172
|
+
kind: "text",
|
|
1173
|
+
value: e.slice(n, r)
|
|
1174
|
+
});
|
|
1175
|
+
let i = r + 2, a = "", s = !1;
|
|
1176
|
+
for (; i < e.length;) {
|
|
1177
|
+
let t = e[i];
|
|
1178
|
+
if (a !== "") {
|
|
1179
|
+
if (t === "\\") {
|
|
1180
|
+
i += 2;
|
|
1181
|
+
continue;
|
|
1182
|
+
}
|
|
1183
|
+
t === a && (a = ""), i += 1;
|
|
1184
|
+
} else if (t === "\"" || t === "'") a = t, i += 1;
|
|
1185
|
+
else {
|
|
1186
|
+
if (t === "{" && e[i + 1] === "{") throw new o("expression-interpolation", "Interpolations cannot be nested.", i);
|
|
1187
|
+
if (t === "}" && e[i + 1] === "}") {
|
|
1188
|
+
s = !0;
|
|
1189
|
+
break;
|
|
1190
|
+
}
|
|
1191
|
+
i += 1;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1194
|
+
if (!s) throw new o("expression-interpolation", "Interpolation is missing }}.", r);
|
|
1195
|
+
let c = e.slice(r + 2, i);
|
|
1196
|
+
if (c.trim() === "") throw new o("expression-empty", "Interpolation expression is empty.", r + 2);
|
|
1197
|
+
t.push({
|
|
1198
|
+
kind: "expression",
|
|
1199
|
+
source: c,
|
|
1200
|
+
start: r + 2
|
|
1201
|
+
}), n = i + 2;
|
|
1202
|
+
}
|
|
1203
|
+
return t;
|
|
1204
|
+
}
|
|
1205
|
+
function Q(e) {
|
|
1206
|
+
try {
|
|
1207
|
+
return X(e.source);
|
|
1208
|
+
} catch (t) {
|
|
1209
|
+
throw t instanceof o ? new o(t.code, t.message, e.start + t.offset) : t;
|
|
1210
|
+
}
|
|
1211
|
+
}
|
|
1212
|
+
function $(e, t, n) {
|
|
1213
|
+
try {
|
|
1214
|
+
return e.evaluate(t);
|
|
1215
|
+
} catch (e) {
|
|
1216
|
+
throw e instanceof o ? new o(e.code, e.message, n + e.offset) : e;
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
function Re(e, t) {
|
|
1220
|
+
if (e === null) return "";
|
|
1221
|
+
if (typeof e == "string") return e;
|
|
1222
|
+
if (typeof e == "number") {
|
|
1223
|
+
if (!Number.isFinite(e)) throw new o("expression-value", "Cannot display a non-finite number.", t);
|
|
1224
|
+
return String(e);
|
|
1225
|
+
}
|
|
1226
|
+
if (typeof e == "boolean") return e ? "true" : "false";
|
|
1227
|
+
throw Array.isArray(e) ? new o("expression-type", "Cannot insert an array as text; convert it with a function such as len first.", t) : new o("expression-type", "Cannot display this value as text.", t);
|
|
1228
|
+
}
|
|
1229
|
+
function ze(e, t) {
|
|
1230
|
+
let n = [], r = 0;
|
|
1231
|
+
for (let i of e) {
|
|
1232
|
+
let e;
|
|
1233
|
+
if (e = i.kind === "text" ? i.value : Re($(Q(i), t, i.start), i.start), r += e.length, r > d) throw new o("expression-budget", "Interpolation result exceeds the length limit.", 0);
|
|
1234
|
+
n.push(e);
|
|
1235
|
+
}
|
|
1236
|
+
return n.join("");
|
|
1237
|
+
}
|
|
1238
|
+
function Be(e, t) {
|
|
1239
|
+
if (typeof e != "string") throw new o("expression-interpolation", "Interpolation template must be a string.", 0);
|
|
1240
|
+
if (e.length > q) throw new o("expression-budget", `Interpolation template exceeds the ${q}-character limit.`, 0);
|
|
1241
|
+
return e.includes("{{") ? ze(Z(e), t) : e;
|
|
1242
|
+
}
|
|
1243
|
+
function Ve(e) {
|
|
1244
|
+
if (typeof e != "string") throw new o("expression-interpolation", "Interpolation template must be a string.", 0);
|
|
1245
|
+
let t = /* @__PURE__ */ new Set();
|
|
1246
|
+
for (let n of Z(e)) if (n.kind === "expression") for (let e of Q(n).dependencies) t.add(e);
|
|
1247
|
+
return [...t];
|
|
1248
|
+
}
|
|
1249
|
+
export { o as a, p as c, Ve as i, Le as n, te as o, Be as r, m as s, X as t };
|