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,928 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t, t.exports), e = null), t.exports), s = (e, n) => {
|
|
3
|
+
let r = {};
|
|
4
|
+
for (var i in e) t(r, i, {
|
|
5
|
+
get: e[i],
|
|
6
|
+
enumerable: !0
|
|
7
|
+
});
|
|
8
|
+
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
+
}, c = (e, i, o, s) => {
|
|
10
|
+
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
|
+
get: ((e) => i[e]).bind(null, d),
|
|
12
|
+
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
|
+
});
|
|
14
|
+
return e;
|
|
15
|
+
}, l = (n, r, o) => (o = n == null ? {} : e(i(n)), c(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
|
|
16
|
+
value: n,
|
|
17
|
+
enumerable: !0
|
|
18
|
+
}) : o, n)), u = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
19
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
20
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
21
|
+
}), d = 5e4, f = 2e4, p = 5e3, m = 120, h = /* @__PURE__ */ new Set([
|
|
22
|
+
"quad",
|
|
23
|
+
"qquad",
|
|
24
|
+
"enspace",
|
|
25
|
+
"thinspace",
|
|
26
|
+
"medspace",
|
|
27
|
+
"thickspace",
|
|
28
|
+
"negthinspace",
|
|
29
|
+
"displaystyle",
|
|
30
|
+
"textstyle",
|
|
31
|
+
"scriptstyle",
|
|
32
|
+
"scriptscriptstyle",
|
|
33
|
+
"limits",
|
|
34
|
+
"nolimits"
|
|
35
|
+
]), g = {
|
|
36
|
+
alpha: "alpha",
|
|
37
|
+
beta: "beta",
|
|
38
|
+
gamma: "gamma",
|
|
39
|
+
theta: "theta",
|
|
40
|
+
omega: "omega",
|
|
41
|
+
lambda: "lambda",
|
|
42
|
+
mu: "mu",
|
|
43
|
+
sigma: "sigma"
|
|
44
|
+
}, _ = /* @__PURE__ */ new Set([
|
|
45
|
+
"sin",
|
|
46
|
+
"cos",
|
|
47
|
+
"tan",
|
|
48
|
+
"arcsin",
|
|
49
|
+
"arccos",
|
|
50
|
+
"arctan",
|
|
51
|
+
"exp",
|
|
52
|
+
"ln",
|
|
53
|
+
"log",
|
|
54
|
+
"min",
|
|
55
|
+
"max"
|
|
56
|
+
]), v = {
|
|
57
|
+
"{": "lbrace",
|
|
58
|
+
"}": "rbrace",
|
|
59
|
+
"|": "vert",
|
|
60
|
+
"%": "percent",
|
|
61
|
+
"&": "amp",
|
|
62
|
+
"#": "hash",
|
|
63
|
+
_: "underscore",
|
|
64
|
+
$: "dollar"
|
|
65
|
+
};
|
|
66
|
+
function y(e) {
|
|
67
|
+
let t = [], n = 0, r = (e, n, r) => {
|
|
68
|
+
if (t.length >= f) throw new w("latex-budget", "Math input contains too many tokens.", r);
|
|
69
|
+
t.push({
|
|
70
|
+
kind: e,
|
|
71
|
+
value: n,
|
|
72
|
+
offset: r
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
for (; n < e.length;) {
|
|
76
|
+
let t = e[n];
|
|
77
|
+
if (t === " " || t === " " || t === "\r" || t === "\n") n += 1;
|
|
78
|
+
else if (t === "%") for (; n < e.length && e[n] !== "\n";) n += 1;
|
|
79
|
+
else if (t === "\\") {
|
|
80
|
+
if (n + 1 >= e.length) throw new w("latex-syntax", "Formula ends with a lone backslash.", n);
|
|
81
|
+
let t = e[n + 1];
|
|
82
|
+
if (t === "\\") {
|
|
83
|
+
r("command", "newline", n), n += 2;
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
if (/[A-Za-z]/.test(t)) {
|
|
87
|
+
let t = n + 1;
|
|
88
|
+
for (; t < e.length && /[A-Za-z]/.test(e[t]);) t += 1;
|
|
89
|
+
let i = e.slice(n + 1, t);
|
|
90
|
+
h.has(i) || r("command", i, n), n = t;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (t === " " || t === "," || t === ";" || t === ":" || t === "!") {
|
|
94
|
+
n += 2;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
let i = v[t];
|
|
98
|
+
if (i) {
|
|
99
|
+
r("command", i, n), n += 2;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
r("command", t, n), n += 2;
|
|
103
|
+
} else if (t === "θ") r("command", "theta", n), n += 1;
|
|
104
|
+
else if (t >= "0" && t <= "9") {
|
|
105
|
+
let t = /^(?:\d+(?:\.\d*)?|\.\d+)/.exec(e.slice(n));
|
|
106
|
+
r("number", t[0], n), n += t[0].length;
|
|
107
|
+
} else if (t === "." && e[n + 1] >= "0" && e[n + 1] <= "9") {
|
|
108
|
+
let t = /^(?:\d+(?:\.\d*)?|\.\d+)/.exec(e.slice(n));
|
|
109
|
+
r("number", t[0], n), n += t[0].length;
|
|
110
|
+
} else /[A-Za-z]/.test(t) ? (r("letter", t, n), n += 1) : (r("punct", t, n), n += 1);
|
|
111
|
+
}
|
|
112
|
+
return r("eof", "", e.length), t;
|
|
113
|
+
}
|
|
114
|
+
function b(e) {
|
|
115
|
+
return Object.prototype.hasOwnProperty.call(g, e);
|
|
116
|
+
}
|
|
117
|
+
function x(e) {
|
|
118
|
+
switch (e.kind) {
|
|
119
|
+
case "number":
|
|
120
|
+
case "letter": return !0;
|
|
121
|
+
case "punct": return e.value === "(" || e.value === "{" || e.value === "[" || e.value === "|";
|
|
122
|
+
case "command": {
|
|
123
|
+
let t = e.value;
|
|
124
|
+
return _.has(t) || b(t) ? !0 : t === "frac" || t === "dfrac" || t === "tfrac" || t === "sqrt" || t === "left" || t === "pi" || t === "mathrm" || t === "begin" || t === "lvert" || t === "vert" || t === "lbrace";
|
|
125
|
+
}
|
|
126
|
+
default: return !1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function S(e) {
|
|
130
|
+
if (e.kind === "punct") return e.value === "=" ? "eq" : e.value === "<" ? "lt" : e.value === ">" ? "gt" : null;
|
|
131
|
+
if (e.kind === "command") {
|
|
132
|
+
if (e.value === "ne" || e.value === "neq") return "ne";
|
|
133
|
+
if (e.value === "le" || e.value === "leq") return "le";
|
|
134
|
+
if (e.value === "ge" || e.value === "geq") return "ge";
|
|
135
|
+
}
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
var C = class {
|
|
139
|
+
tokens;
|
|
140
|
+
source;
|
|
141
|
+
pos = 0;
|
|
142
|
+
nodes = 0;
|
|
143
|
+
allowY;
|
|
144
|
+
constructor(e, t, n = {}) {
|
|
145
|
+
this.source = e, this.tokens = t, this.allowY = n.allowY === !0;
|
|
146
|
+
}
|
|
147
|
+
parseDocument() {
|
|
148
|
+
if (this.peek().kind === "eof") throw new w("latex-empty", "Formula is empty.", 0);
|
|
149
|
+
if (this.atLetter("y") && this.atPunctAt(1, "=") && (this.pos += 2), this.peek().kind === "eof") throw new w("latex-empty", "Missing expression after y.", this.peek().offset);
|
|
150
|
+
let e = this.parseAdditive(0), t = this.peek();
|
|
151
|
+
if (t.kind !== "eof") throw S(t) || t.kind === "punct" && t.value === "=" ? new w("latex-relation", "Plots support only explicit y = f(x) equations.", t.offset) : new w("latex-syntax", `Unexpected token "${this.raw(t)}".`, t.offset);
|
|
152
|
+
return e;
|
|
153
|
+
}
|
|
154
|
+
parseEquation() {
|
|
155
|
+
if (this.peek().kind === "eof") throw new w("latex-empty", "Formula is empty.", 0);
|
|
156
|
+
let e = this.parseAdditive(0), t = this.peek();
|
|
157
|
+
if (t.kind !== "punct" || t.value !== "=") throw new w("latex-relation", "Plot formulas must be written as an equation.", t.offset);
|
|
158
|
+
this.take();
|
|
159
|
+
let n = this.parseAdditive(0), r = this.peek();
|
|
160
|
+
if (r.kind !== "eof") throw new w("latex-syntax", `Unexpected token "${this.raw(r)}".`, r.offset);
|
|
161
|
+
return {
|
|
162
|
+
left: e,
|
|
163
|
+
right: n
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
peek(e = 0) {
|
|
167
|
+
return this.tokens[Math.min(this.pos + e, this.tokens.length - 1)];
|
|
168
|
+
}
|
|
169
|
+
take() {
|
|
170
|
+
return this.tokens[this.pos++];
|
|
171
|
+
}
|
|
172
|
+
atPunct(e) {
|
|
173
|
+
let t = this.peek();
|
|
174
|
+
return t.kind === "punct" && t.value === e;
|
|
175
|
+
}
|
|
176
|
+
atPunctAt(e, t) {
|
|
177
|
+
let n = this.peek(e);
|
|
178
|
+
return n.kind === "punct" && n.value === t;
|
|
179
|
+
}
|
|
180
|
+
atCommand(e) {
|
|
181
|
+
let t = this.peek();
|
|
182
|
+
return t.kind === "command" && t.value === e;
|
|
183
|
+
}
|
|
184
|
+
atLetter(e) {
|
|
185
|
+
let t = this.peek();
|
|
186
|
+
return t.kind === "letter" && t.value === e;
|
|
187
|
+
}
|
|
188
|
+
expectPunct(e) {
|
|
189
|
+
let t = this.peek();
|
|
190
|
+
if (t.kind !== "punct" || t.value !== e) throw new w("latex-syntax", `Missing "${e}".`, t.offset);
|
|
191
|
+
return this.take();
|
|
192
|
+
}
|
|
193
|
+
raw(e) {
|
|
194
|
+
return e.kind === "eof" ? "end of input" : e.kind === "command" ? `\\${e.value}` : this.source.slice(e.offset, e.offset + Math.max(1, e.value.length));
|
|
195
|
+
}
|
|
196
|
+
make(e, t, n) {
|
|
197
|
+
if (this.nodes += 1, this.nodes > p) throw new w("latex-budget", "Formula is too complex.", t);
|
|
198
|
+
if (n > m) throw new w("latex-budget", "Formula is nested too deeply.", t);
|
|
199
|
+
return e;
|
|
200
|
+
}
|
|
201
|
+
parseAdditive(e) {
|
|
202
|
+
let t = this.parseMultiplicative(e + 1, !1);
|
|
203
|
+
for (;;) {
|
|
204
|
+
let n = this.peek();
|
|
205
|
+
if (n.kind !== "punct" || n.value !== "+" && n.value !== "-") break;
|
|
206
|
+
let r = this.take().value, i = this.parseMultiplicative(e + 1, !1);
|
|
207
|
+
t = this.make({
|
|
208
|
+
kind: "binary",
|
|
209
|
+
op: r,
|
|
210
|
+
left: t,
|
|
211
|
+
right: i,
|
|
212
|
+
offset: n.offset
|
|
213
|
+
}, n.offset, e);
|
|
214
|
+
}
|
|
215
|
+
return t;
|
|
216
|
+
}
|
|
217
|
+
parseMultiplicative(e, t) {
|
|
218
|
+
let n = this.parseUnary(e + 1, t);
|
|
219
|
+
for (;;) {
|
|
220
|
+
let r = this.peek();
|
|
221
|
+
if (r.kind === "punct" && r.value === "/") {
|
|
222
|
+
this.take();
|
|
223
|
+
let i = this.parseUnary(e + 1, t);
|
|
224
|
+
n = this.make({
|
|
225
|
+
kind: "binary",
|
|
226
|
+
op: "/",
|
|
227
|
+
left: n,
|
|
228
|
+
right: i,
|
|
229
|
+
offset: r.offset
|
|
230
|
+
}, r.offset, e);
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
if (r.kind === "punct" && r.value === "*" || r.kind === "command" && (r.value === "cdot" || r.value === "times")) {
|
|
234
|
+
this.take();
|
|
235
|
+
let i = this.parseUnary(e + 1, t);
|
|
236
|
+
n = this.make({
|
|
237
|
+
kind: "binary",
|
|
238
|
+
op: "*",
|
|
239
|
+
left: n,
|
|
240
|
+
right: i,
|
|
241
|
+
offset: r.offset
|
|
242
|
+
}, r.offset, e);
|
|
243
|
+
continue;
|
|
244
|
+
}
|
|
245
|
+
if (t && r.kind === "command" && _.has(r.value) || !x(r)) break;
|
|
246
|
+
let i = this.parseUnary(e + 1, t);
|
|
247
|
+
n = this.make({
|
|
248
|
+
kind: "binary",
|
|
249
|
+
op: "*",
|
|
250
|
+
left: n,
|
|
251
|
+
right: i,
|
|
252
|
+
offset: r.offset
|
|
253
|
+
}, r.offset, e);
|
|
254
|
+
}
|
|
255
|
+
return n;
|
|
256
|
+
}
|
|
257
|
+
parseUnary(e, t) {
|
|
258
|
+
let n = this.peek();
|
|
259
|
+
if (n.kind === "punct" && (n.value === "+" || n.value === "-")) {
|
|
260
|
+
this.take();
|
|
261
|
+
let r = this.parseUnary(e + 1, t);
|
|
262
|
+
return n.value === "+" ? r : this.make({
|
|
263
|
+
kind: "unary",
|
|
264
|
+
op: "-",
|
|
265
|
+
operand: r,
|
|
266
|
+
offset: n.offset
|
|
267
|
+
}, n.offset, e);
|
|
268
|
+
}
|
|
269
|
+
return this.parsePower(e, t);
|
|
270
|
+
}
|
|
271
|
+
parsePower(e, t) {
|
|
272
|
+
let n = this.parseAtom(e + 1, t), r = this.peek();
|
|
273
|
+
if (r.kind === "punct" && r.value === "^") {
|
|
274
|
+
this.take();
|
|
275
|
+
let t = this.parseScriptArgument(e + 1);
|
|
276
|
+
return this.make({
|
|
277
|
+
kind: "binary",
|
|
278
|
+
op: "^",
|
|
279
|
+
left: n,
|
|
280
|
+
right: t,
|
|
281
|
+
offset: r.offset
|
|
282
|
+
}, r.offset, e);
|
|
283
|
+
}
|
|
284
|
+
return n;
|
|
285
|
+
}
|
|
286
|
+
parseScriptArgument(e) {
|
|
287
|
+
if (this.atPunct("{")) return this.parseBraceGroup(e + 1);
|
|
288
|
+
if (this.atPunct("+") || this.atPunct("-")) {
|
|
289
|
+
let t = this.take(), n = this.parseUnary(e + 1, !1);
|
|
290
|
+
return t.value === "+" ? n : this.make({
|
|
291
|
+
kind: "unary",
|
|
292
|
+
op: "-",
|
|
293
|
+
operand: n,
|
|
294
|
+
offset: t.offset
|
|
295
|
+
}, t.offset, e);
|
|
296
|
+
}
|
|
297
|
+
return this.parseUnary(e + 1, !1);
|
|
298
|
+
}
|
|
299
|
+
parseAtom(e, t) {
|
|
300
|
+
let n = this.peek();
|
|
301
|
+
if (n.kind === "number") {
|
|
302
|
+
this.take();
|
|
303
|
+
let t = Number(n.value);
|
|
304
|
+
if (!Number.isFinite(t)) throw new w("latex-number", `Number "${n.value}" is not finite.`, n.offset);
|
|
305
|
+
return this.make({
|
|
306
|
+
kind: "number",
|
|
307
|
+
value: t,
|
|
308
|
+
offset: n.offset
|
|
309
|
+
}, n.offset, e);
|
|
310
|
+
}
|
|
311
|
+
if (n.kind === "letter") return this.take(), this.variable(n.value, n.offset, e);
|
|
312
|
+
if (n.kind === "punct") {
|
|
313
|
+
if (n.value === "(") return this.parseParenthesized(e);
|
|
314
|
+
if (n.value === "{") return this.parseBraceGroup(e);
|
|
315
|
+
if (n.value === "[") return this.parseBracketGroup(e);
|
|
316
|
+
if (n.value === "|") return this.parsePlainAbs(e, n.offset);
|
|
317
|
+
throw new w("latex-syntax", `Cannot start an expression with "${n.value}".`, n.offset);
|
|
318
|
+
}
|
|
319
|
+
if (n.kind === "command") {
|
|
320
|
+
let t = n.value;
|
|
321
|
+
if (t === "frac" || t === "dfrac" || t === "tfrac") {
|
|
322
|
+
this.take();
|
|
323
|
+
let t = this.parseArgument(e + 1), r = this.parseArgument(e + 1);
|
|
324
|
+
return this.make({
|
|
325
|
+
kind: "binary",
|
|
326
|
+
op: "/",
|
|
327
|
+
left: t,
|
|
328
|
+
right: r,
|
|
329
|
+
offset: n.offset
|
|
330
|
+
}, n.offset, e);
|
|
331
|
+
}
|
|
332
|
+
if (t === "sqrt") {
|
|
333
|
+
this.take();
|
|
334
|
+
let t = null;
|
|
335
|
+
this.atPunct("[") && (this.take(), t = this.parseAdditive(e + 1), this.expectPunct("]"));
|
|
336
|
+
let r = this.parseArgument(e + 1);
|
|
337
|
+
return this.make({
|
|
338
|
+
kind: "call",
|
|
339
|
+
name: "sqrt",
|
|
340
|
+
args: [r],
|
|
341
|
+
base: t,
|
|
342
|
+
power: null,
|
|
343
|
+
offset: n.offset
|
|
344
|
+
}, n.offset, e);
|
|
345
|
+
}
|
|
346
|
+
if (t === "left") return this.parseLeft(e);
|
|
347
|
+
if (_.has(t)) return this.parseFunction(t, e);
|
|
348
|
+
if (t === "pi") return this.take(), this.make({
|
|
349
|
+
kind: "constant",
|
|
350
|
+
value: "pi",
|
|
351
|
+
offset: n.offset
|
|
352
|
+
}, n.offset, e);
|
|
353
|
+
if (b(t)) return this.take(), this.variable(g[t], n.offset, e);
|
|
354
|
+
if (t === "mathrm") {
|
|
355
|
+
this.take();
|
|
356
|
+
let t = this.readRawGroup();
|
|
357
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(t.raw)) throw new w("latex-name", "\\mathrm requires a valid parameter name.", t.offset);
|
|
358
|
+
return this.variable(t.raw, n.offset, e);
|
|
359
|
+
}
|
|
360
|
+
if (t === "begin") return this.parseCases(e);
|
|
361
|
+
if (t === "lvert" || t === "vert") return this.parseCommandAbs(e, n.offset);
|
|
362
|
+
throw t === "right" ? new w("latex-syntax", "\\right has no matching \\left.", n.offset) : t === "text" ? new w("latex-unsupported", "\\text is only allowed as the otherwise condition of a piecewise function.", n.offset) : new w("latex-unsupported", `Command \\${t} is not supported for computation.`, n.offset);
|
|
363
|
+
}
|
|
364
|
+
throw new w("latex-syntax", "Expression is incomplete.", n.offset);
|
|
365
|
+
}
|
|
366
|
+
parseArgument(e) {
|
|
367
|
+
if (this.atPunct("{")) return this.parseBraceGroup(e + 1);
|
|
368
|
+
if (this.peek().kind === "eof") throw new w("latex-syntax", "Command is missing an argument.", this.peek().offset);
|
|
369
|
+
return this.parseUnary(e + 1, !1);
|
|
370
|
+
}
|
|
371
|
+
parseParenthesized(e) {
|
|
372
|
+
let t = this.expectPunct("(");
|
|
373
|
+
if (this.atPunct(")")) throw new w("latex-syntax", "Missing expression inside parentheses.", t.offset);
|
|
374
|
+
let n = this.parseAdditive(e + 1);
|
|
375
|
+
return this.expectPunct(")"), n;
|
|
376
|
+
}
|
|
377
|
+
parseBraceGroup(e) {
|
|
378
|
+
let t = this.expectPunct("{");
|
|
379
|
+
if (this.atPunct("}")) throw new w("latex-syntax", "Missing expression inside braces.", t.offset);
|
|
380
|
+
let n = this.parseAdditive(e + 1);
|
|
381
|
+
return this.expectPunct("}"), n;
|
|
382
|
+
}
|
|
383
|
+
parseBracketGroup(e) {
|
|
384
|
+
let t = this.expectPunct("[");
|
|
385
|
+
if (this.atPunct("]")) throw new w("latex-syntax", "Missing expression inside brackets.", t.offset);
|
|
386
|
+
let n = this.parseAdditive(e + 1);
|
|
387
|
+
return this.expectPunct("]"), n;
|
|
388
|
+
}
|
|
389
|
+
parsePlainAbs(e, t) {
|
|
390
|
+
if (this.take(), this.atPunct("|")) throw new w("latex-syntax", "Absolute value is missing its contents.", t);
|
|
391
|
+
let n = this.parseAdditive(e + 1);
|
|
392
|
+
if (this.atPunct("|")) this.take();
|
|
393
|
+
else if (this.atCommand("rvert")) this.take();
|
|
394
|
+
else throw new w("latex-syntax", "Unpaired absolute value bar.", t);
|
|
395
|
+
return this.make({
|
|
396
|
+
kind: "abs",
|
|
397
|
+
value: n,
|
|
398
|
+
offset: t
|
|
399
|
+
}, t, e);
|
|
400
|
+
}
|
|
401
|
+
parseCommandAbs(e, t) {
|
|
402
|
+
if (this.take(), this.atCommand("rvert") || this.atCommand("vert") || this.atPunct("|")) throw new w("latex-syntax", "Absolute value is missing its contents.", t);
|
|
403
|
+
let n = this.parseAdditive(e + 1);
|
|
404
|
+
if (this.atCommand("rvert") || this.atCommand("vert") || this.atPunct("|")) this.take();
|
|
405
|
+
else throw new w("latex-syntax", "Unpaired absolute value bar.", t);
|
|
406
|
+
return this.make({
|
|
407
|
+
kind: "abs",
|
|
408
|
+
value: n,
|
|
409
|
+
offset: t
|
|
410
|
+
}, t, e);
|
|
411
|
+
}
|
|
412
|
+
parseLeft(e) {
|
|
413
|
+
let t = this.take(), n = this.readDelimiter(), r = this.parseAdditive(e + 1);
|
|
414
|
+
if (!this.atCommand("right")) throw new w("latex-syntax", "\\left has no matching \\right.", t.offset);
|
|
415
|
+
this.take();
|
|
416
|
+
let i = this.readDelimiter();
|
|
417
|
+
if (n === "|" && i !== "|") throw new w("latex-syntax", "Unpaired absolute value bar.", t.offset);
|
|
418
|
+
return n === "|" ? this.make({
|
|
419
|
+
kind: "abs",
|
|
420
|
+
value: r,
|
|
421
|
+
offset: t.offset
|
|
422
|
+
}, t.offset, e) : r;
|
|
423
|
+
}
|
|
424
|
+
readDelimiter() {
|
|
425
|
+
let e = this.peek();
|
|
426
|
+
if (e.kind === "punct" && (e.value === "(" || e.value === ")" || e.value === "[" || e.value === "]" || e.value === "|" || e.value === ".")) return this.take(), e.value;
|
|
427
|
+
if (e.kind === "command" && (e.value === "lbrace" || e.value === "rbrace" || e.value === "lvert" || e.value === "rvert" || e.value === "vert" || e.value === "Vert")) return this.take(), e.value === "lbrace" || e.value === "rbrace" ? "{" : e.value === "lvert" || e.value === "rvert" || e.value === "vert" ? "|" : "Vert";
|
|
428
|
+
throw new w("latex-syntax", "Missing delimiter after \\left/\\right.", e.offset);
|
|
429
|
+
}
|
|
430
|
+
variable(e, t, n) {
|
|
431
|
+
if (e === "y" && !this.allowY) throw new w("latex-name", "y is the plot output marker and cannot appear in the expression.", t);
|
|
432
|
+
return e === "e" || e === "pi" ? this.make({
|
|
433
|
+
kind: "constant",
|
|
434
|
+
value: e,
|
|
435
|
+
offset: t
|
|
436
|
+
}, t, n) : this.make({
|
|
437
|
+
kind: "variable",
|
|
438
|
+
name: e,
|
|
439
|
+
offset: t
|
|
440
|
+
}, t, n);
|
|
441
|
+
}
|
|
442
|
+
parseFunction(e, t) {
|
|
443
|
+
let n = this.take().offset, r = null, i = null;
|
|
444
|
+
e === "log" && this.atPunct("_") && (this.take(), r = this.parseScriptArgument(t + 1)), this.atPunct("^") && (this.take(), i = this.parseScriptArgument(t + 1));
|
|
445
|
+
let a = [];
|
|
446
|
+
if ((e === "min" || e === "max") && this.atPunct("(")) {
|
|
447
|
+
if (this.take(), this.atPunct(")")) throw new w("latex-syntax", `\\${e} requires at least one argument.`, n);
|
|
448
|
+
for (a.push(this.parseAdditive(t + 1)); this.atPunct(",");) this.take(), a.push(this.parseAdditive(t + 1));
|
|
449
|
+
this.expectPunct(")");
|
|
450
|
+
} else a.push(this.parseFunctionArgument(t + 1));
|
|
451
|
+
return this.make({
|
|
452
|
+
kind: "call",
|
|
453
|
+
name: e,
|
|
454
|
+
args: a,
|
|
455
|
+
base: r,
|
|
456
|
+
power: i,
|
|
457
|
+
offset: n
|
|
458
|
+
}, n, t);
|
|
459
|
+
}
|
|
460
|
+
parseFunctionArgument(e) {
|
|
461
|
+
if (this.atPunct("(")) {
|
|
462
|
+
this.take();
|
|
463
|
+
let t = this.parseAdditive(e + 1);
|
|
464
|
+
return this.expectPunct(")"), t;
|
|
465
|
+
}
|
|
466
|
+
return this.parseMultiplicative(e + 1, !0);
|
|
467
|
+
}
|
|
468
|
+
parseCases(e) {
|
|
469
|
+
let t = this.take(), n = this.readRawGroup();
|
|
470
|
+
if (n.raw.trim() !== "cases") throw new w("latex-unsupported", `Environment "${n.raw.trim()}" is not supported.`, n.offset);
|
|
471
|
+
let r = [];
|
|
472
|
+
for (; !this.atCommand("end");) {
|
|
473
|
+
if (this.peek().kind === "eof") throw new w("latex-syntax", "cases environment is missing \\end{cases}.", t.offset);
|
|
474
|
+
if (this.atCommand("newline")) {
|
|
475
|
+
this.take();
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
let n = this.parseAdditive(e + 1);
|
|
479
|
+
this.atPunct(",") && this.take();
|
|
480
|
+
let i = null;
|
|
481
|
+
if (this.atPunct("&") && (this.take(), i = this.parseCaseCondition(e + 1), this.atPunct(",") && this.take()), r.push({
|
|
482
|
+
value: n,
|
|
483
|
+
when: i
|
|
484
|
+
}), this.atCommand("newline")) {
|
|
485
|
+
this.take();
|
|
486
|
+
continue;
|
|
487
|
+
}
|
|
488
|
+
if (this.atCommand("end")) break;
|
|
489
|
+
let a = this.peek();
|
|
490
|
+
throw new w("latex-syntax", `Unexpected "${this.raw(a)}" after a cases branch.`, a.offset);
|
|
491
|
+
}
|
|
492
|
+
let i = this.take();
|
|
493
|
+
if (this.readRawGroup().raw.trim() !== "cases") throw new w("latex-syntax", "\\begin{cases} must be closed with \\end{cases}.", i.offset);
|
|
494
|
+
if (r.length === 0) throw new w("latex-syntax", "cases environment has no branches.", t.offset);
|
|
495
|
+
return this.make({
|
|
496
|
+
kind: "cases",
|
|
497
|
+
branches: r,
|
|
498
|
+
offset: t.offset
|
|
499
|
+
}, t.offset, e);
|
|
500
|
+
}
|
|
501
|
+
parseCaseCondition(e) {
|
|
502
|
+
if (this.atCommand("text")) {
|
|
503
|
+
let e = this.take(), t = this.readRawGroup();
|
|
504
|
+
if (t.raw.trim() !== "otherwise") throw new w("latex-unsupported", `Unsupported piecewise condition text "${t.raw.trim()}".`, e.offset);
|
|
505
|
+
return null;
|
|
506
|
+
}
|
|
507
|
+
let t = this.parseAdditive(e + 1), n = this.peek(), r = S(n);
|
|
508
|
+
if (!r) throw new w("latex-syntax", "Piecewise condition requires one comparison.", n.offset);
|
|
509
|
+
return this.take(), {
|
|
510
|
+
op: r,
|
|
511
|
+
left: t,
|
|
512
|
+
right: this.parseAdditive(e + 1)
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
readRawGroup() {
|
|
516
|
+
let e = this.expectPunct("{"), t = 1, n = this.pos;
|
|
517
|
+
for (; n < this.tokens.length; n += 1) {
|
|
518
|
+
let e = this.tokens[n];
|
|
519
|
+
if (e.kind === "eof") break;
|
|
520
|
+
if (e.kind === "punct") {
|
|
521
|
+
if (e.value === "{") t += 1;
|
|
522
|
+
else if (e.value === "}" && (--t, t === 0)) break;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (n >= this.tokens.length || this.tokens[n].kind === "eof") throw new w("latex-syntax", "Unclosed brace.", e.offset);
|
|
526
|
+
let r = this.tokens[n];
|
|
527
|
+
return this.pos = n + 1, {
|
|
528
|
+
raw: this.source.slice(e.offset + 1, r.offset),
|
|
529
|
+
offset: e.offset + 1
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
}, w = class extends Error {
|
|
533
|
+
code;
|
|
534
|
+
offset;
|
|
535
|
+
constructor(e, t, n = 0) {
|
|
536
|
+
super(t), this.name = "LatexError", this.code = e, this.offset = n;
|
|
537
|
+
}
|
|
538
|
+
};
|
|
539
|
+
// src/local/evaluation/math/evaluation.ts
|
|
540
|
+
function T(e, t, n) {
|
|
541
|
+
throw new w(e, t, n);
|
|
542
|
+
}
|
|
543
|
+
function E(e, t) {
|
|
544
|
+
return Number.isFinite(e) || T("latex-number", "Result is not finite.", t), e;
|
|
545
|
+
}
|
|
546
|
+
function D(e, t, n) {
|
|
547
|
+
if (e === "x") return t.x;
|
|
548
|
+
let r = t.env[e];
|
|
549
|
+
return r === void 0 && !Object.prototype.hasOwnProperty.call(t.env, e) && T("latex-variable", `Parameter "${e}" is not declared.`, n), typeof r == "number" && Number.isFinite(r) || T("latex-type", `Parameter "${e}" must be a finite number.`, n), r;
|
|
550
|
+
}
|
|
551
|
+
function O(e, t, n) {
|
|
552
|
+
return e === 0 && t < 0 && T("latex-divide-by-zero", "Negative powers of zero are undefined.", n), e < 0 && !Number.isInteger(t) && T("latex-domain", "A negative base with a non-integer exponent is not real.", n), E(e ** +t, n);
|
|
553
|
+
}
|
|
554
|
+
function k(e, t, n) {
|
|
555
|
+
let r = t ?? 2;
|
|
556
|
+
return (!Number.isFinite(r) || r <= 0) && T("latex-domain", "Root index must be positive.", n), e < 0 ? (Number.isInteger(r) && r % 2 != 0 || T("latex-domain", "A negative number has no real even root.", n), E(r === 3 ? -Math.cbrt(-e) : -((-e) ** (1 / r)), n)) : E(e ** (1 / r), n);
|
|
557
|
+
}
|
|
558
|
+
function A(e, t) {
|
|
559
|
+
let n = M(e.left, t), r = M(e.right, t);
|
|
560
|
+
switch (e.op) {
|
|
561
|
+
case "eq": return n === r;
|
|
562
|
+
case "ne": return n !== r;
|
|
563
|
+
case "lt": return n < r;
|
|
564
|
+
case "le": return n <= r;
|
|
565
|
+
case "gt": return n > r;
|
|
566
|
+
case "ge": return n >= r;
|
|
567
|
+
default: return !1;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
function j(e, t) {
|
|
571
|
+
let n = e.args.map((e) => M(e, t)), r = 0;
|
|
572
|
+
switch (e.name) {
|
|
573
|
+
case "sin":
|
|
574
|
+
r = Math.sin(n[0]);
|
|
575
|
+
break;
|
|
576
|
+
case "cos":
|
|
577
|
+
r = Math.cos(n[0]);
|
|
578
|
+
break;
|
|
579
|
+
case "tan":
|
|
580
|
+
Math.abs(Math.cos(n[0])) < 1e-15 && T("latex-domain", "tan is undefined at this point.", e.offset), r = Math.tan(n[0]);
|
|
581
|
+
break;
|
|
582
|
+
case "arcsin":
|
|
583
|
+
(n[0] < -1 || n[0] > 1) && T("latex-domain", "arcsin argument must be in [-1, 1].", e.offset), r = Math.asin(n[0]);
|
|
584
|
+
break;
|
|
585
|
+
case "arccos":
|
|
586
|
+
(n[0] < -1 || n[0] > 1) && T("latex-domain", "arccos argument must be in [-1, 1].", e.offset), r = Math.acos(n[0]);
|
|
587
|
+
break;
|
|
588
|
+
case "arctan":
|
|
589
|
+
r = Math.atan(n[0]);
|
|
590
|
+
break;
|
|
591
|
+
case "exp":
|
|
592
|
+
r = Math.exp(n[0]);
|
|
593
|
+
break;
|
|
594
|
+
case "ln":
|
|
595
|
+
n[0] <= 0 && T("latex-domain", "ln argument must be positive.", e.offset), r = Math.log(n[0]);
|
|
596
|
+
break;
|
|
597
|
+
case "log": {
|
|
598
|
+
let i = e.base ? M(e.base, t) : 10;
|
|
599
|
+
(i <= 0 || i === 1) && T("latex-domain", "Logarithm base must be positive and not equal to 1.", e.offset), n[0] <= 0 && T("latex-domain", "Logarithm argument must be positive.", e.offset), r = Math.log(n[0]) / Math.log(i);
|
|
600
|
+
break;
|
|
601
|
+
}
|
|
602
|
+
case "min":
|
|
603
|
+
r = Math.min(...n);
|
|
604
|
+
break;
|
|
605
|
+
case "max":
|
|
606
|
+
r = Math.max(...n);
|
|
607
|
+
break;
|
|
608
|
+
case "sqrt":
|
|
609
|
+
r = k(n[0], e.base ? M(e.base, t) : null, e.offset);
|
|
610
|
+
break;
|
|
611
|
+
default: T("latex-unsupported", "Unsupported function.", e.offset);
|
|
612
|
+
}
|
|
613
|
+
return e.power && (r = O(r, M(e.power, t), e.offset)), E(r, e.offset);
|
|
614
|
+
}
|
|
615
|
+
function M(e, t) {
|
|
616
|
+
let n = e.offset;
|
|
617
|
+
t.steps += 1, t.depth += 1;
|
|
618
|
+
try {
|
|
619
|
+
switch (t.steps > t.limit && T("latex-budget", "Math evaluation exceeded its budget.", n), t.depth > 1e3 && T("latex-budget", "Math evaluation is nested too deeply.", n), e.kind) {
|
|
620
|
+
case "number": return e.value;
|
|
621
|
+
case "constant": return e.value === "pi" ? Math.PI : Math.E;
|
|
622
|
+
case "variable": return D(e.name, t, e.offset);
|
|
623
|
+
case "unary": {
|
|
624
|
+
let n = M(e.operand, t);
|
|
625
|
+
return e.op === "-" ? -n : n;
|
|
626
|
+
}
|
|
627
|
+
case "binary": {
|
|
628
|
+
let n = M(e.left, t), r = M(e.right, t);
|
|
629
|
+
switch (e.op) {
|
|
630
|
+
case "+": return E(n + r, e.offset);
|
|
631
|
+
case "-": return E(n - r, e.offset);
|
|
632
|
+
case "*": return E(n * r, e.offset);
|
|
633
|
+
case "/": return r === 0 && T("latex-divide-by-zero", "Division by zero.", e.offset), E(n / r, e.offset);
|
|
634
|
+
case "^": return O(n, r, e.offset);
|
|
635
|
+
}
|
|
636
|
+
break;
|
|
637
|
+
}
|
|
638
|
+
case "abs": return E(Math.abs(M(e.value, t)), e.offset);
|
|
639
|
+
case "call": return j(e, t);
|
|
640
|
+
case "cases":
|
|
641
|
+
for (let n of e.branches) if (n.when === null || A(n.when, t)) return M(n.value, t);
|
|
642
|
+
T("latex-undefined", "No piecewise branch matched.", e.offset);
|
|
643
|
+
}
|
|
644
|
+
T("latex-unsupported", "Cannot compute this math structure.", n);
|
|
645
|
+
} finally {
|
|
646
|
+
--t.depth;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
// src/local/evaluation/math/latex.ts
|
|
650
|
+
function N(e, t) {
|
|
651
|
+
switch (e.kind) {
|
|
652
|
+
case "variable":
|
|
653
|
+
e.name !== "x" && t.add(e.name);
|
|
654
|
+
return;
|
|
655
|
+
case "number":
|
|
656
|
+
case "constant": return;
|
|
657
|
+
case "unary":
|
|
658
|
+
N(e.operand, t);
|
|
659
|
+
return;
|
|
660
|
+
case "binary":
|
|
661
|
+
N(e.left, t), N(e.right, t);
|
|
662
|
+
return;
|
|
663
|
+
case "abs":
|
|
664
|
+
N(e.value, t);
|
|
665
|
+
return;
|
|
666
|
+
case "call":
|
|
667
|
+
e.base && N(e.base, t), e.power && N(e.power, t);
|
|
668
|
+
for (let n of e.args) N(n, t);
|
|
669
|
+
return;
|
|
670
|
+
case "cases":
|
|
671
|
+
for (let n of e.branches) N(n.value, t), n.when && (N(n.when.left, t), N(n.when.right, t));
|
|
672
|
+
return;
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
function P(e, t, n, r) {
|
|
676
|
+
let i = [], a = (t) => {
|
|
677
|
+
switch (t.kind) {
|
|
678
|
+
case "variable": {
|
|
679
|
+
if (r.has(t.name)) return;
|
|
680
|
+
let a = n + t.offset, o = a + 1;
|
|
681
|
+
e.startsWith("\\mathrm", t.offset) ? o = n + e.indexOf("}", t.offset) + 1 : e[t.offset] === "\\" && (o = a + 1 + t.name.length), i.push({
|
|
682
|
+
name: t.name,
|
|
683
|
+
range: {
|
|
684
|
+
start: a,
|
|
685
|
+
end: o
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
case "unary":
|
|
691
|
+
a(t.operand);
|
|
692
|
+
return;
|
|
693
|
+
case "binary":
|
|
694
|
+
a(t.left), a(t.right);
|
|
695
|
+
return;
|
|
696
|
+
case "abs":
|
|
697
|
+
a(t.value);
|
|
698
|
+
return;
|
|
699
|
+
case "call":
|
|
700
|
+
t.base && a(t.base), t.power && a(t.power), t.args.forEach(a);
|
|
701
|
+
return;
|
|
702
|
+
case "cases":
|
|
703
|
+
for (let e of t.branches) a(e.value), e.when && (a(e.when.left), a(e.when.right));
|
|
704
|
+
return;
|
|
705
|
+
case "number":
|
|
706
|
+
case "constant": return;
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
return a(t), i;
|
|
710
|
+
}
|
|
711
|
+
function F(e) {
|
|
712
|
+
let t = e.trim(), n = e.length - e.trimStart().length;
|
|
713
|
+
if (W(t) === "polar") {
|
|
714
|
+
G(t);
|
|
715
|
+
let { right: e } = new C(t, y(t), { allowY: !0 }).parseEquation();
|
|
716
|
+
return P(t, e, n, /* @__PURE__ */ new Set(["theta"])).sort((e, t) => e.range.start - t.range.start);
|
|
717
|
+
}
|
|
718
|
+
let r = U(t);
|
|
719
|
+
if (r) {
|
|
720
|
+
let e = /* @__PURE__ */ new Set([
|
|
721
|
+
"x",
|
|
722
|
+
"y",
|
|
723
|
+
"t"
|
|
724
|
+
]), t = [];
|
|
725
|
+
for (let i of [{
|
|
726
|
+
text: r.x,
|
|
727
|
+
offset: r.xOffset
|
|
728
|
+
}, {
|
|
729
|
+
text: r.y,
|
|
730
|
+
offset: r.yOffset
|
|
731
|
+
}]) {
|
|
732
|
+
R(i.text);
|
|
733
|
+
let r = new C(i.text, y(i.text)).parseDocument();
|
|
734
|
+
t.push(...P(i.text, r, n + i.offset, e));
|
|
735
|
+
}
|
|
736
|
+
return t.sort((e, t) => e.range.start - t.range.start);
|
|
737
|
+
}
|
|
738
|
+
try {
|
|
739
|
+
return P(e, new C(e, y(e)).parseDocument(), 0, /* @__PURE__ */ new Set(["x", "y"])).sort((e, t) => e.range.start - t.range.start);
|
|
740
|
+
} catch (t) {
|
|
741
|
+
try {
|
|
742
|
+
let t = new C(e, y(e), { allowY: !0 }).parseEquation(), n = /* @__PURE__ */ new Set(["x", "y"]);
|
|
743
|
+
return [...P(e, t.left, 0, n), ...P(e, t.right, 0, n)].sort((e, t) => e.range.start - t.range.start);
|
|
744
|
+
} catch {
|
|
745
|
+
throw t;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
var I = /* @__PURE__ */ new Map();
|
|
750
|
+
function L(e, t, n) {
|
|
751
|
+
return {
|
|
752
|
+
source: e,
|
|
753
|
+
dependencies: n,
|
|
754
|
+
evaluate(e, n, r) {
|
|
755
|
+
if (typeof e != "number" || !Number.isFinite(e)) throw new w("latex-variable", "Plot input x must be a finite number.", 0);
|
|
756
|
+
let i = {
|
|
757
|
+
x: e,
|
|
758
|
+
env: n ?? {},
|
|
759
|
+
steps: r?.steps ?? 0,
|
|
760
|
+
limit: r?.limit ?? 2e4,
|
|
761
|
+
depth: 0
|
|
762
|
+
};
|
|
763
|
+
try {
|
|
764
|
+
return M(t, i);
|
|
765
|
+
} finally {
|
|
766
|
+
r && (r.steps = i.steps);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
};
|
|
770
|
+
}
|
|
771
|
+
function R(e) {
|
|
772
|
+
if (typeof e != "string") throw new w("latex-syntax", "Math source must be a string.", 0);
|
|
773
|
+
if (e.length > 5e4) throw new w("latex-budget", "Formula exceeds the length limit.", d);
|
|
774
|
+
let t = I.get(e);
|
|
775
|
+
if (t) return t;
|
|
776
|
+
let n = new C(e, y(e)).parseDocument(), r = /* @__PURE__ */ new Set();
|
|
777
|
+
N(n, r);
|
|
778
|
+
let i = L(e, n, [...r]);
|
|
779
|
+
return I.size >= 512 && I.clear(), I.set(e, i), i;
|
|
780
|
+
}
|
|
781
|
+
function z(e, t) {
|
|
782
|
+
switch (e.kind) {
|
|
783
|
+
case "variable": return e.name === t;
|
|
784
|
+
case "number":
|
|
785
|
+
case "constant": return !1;
|
|
786
|
+
case "unary": return z(e.operand, t);
|
|
787
|
+
case "binary": return z(e.left, t) || z(e.right, t);
|
|
788
|
+
case "abs": return z(e.value, t);
|
|
789
|
+
case "call": return e.base !== null && z(e.base, t) || e.power !== null && z(e.power, t) || e.args.some((e) => z(e, t));
|
|
790
|
+
case "cases": return e.branches.some((e) => z(e.value, t) || e.when !== null && (z(e.when.left, t) || z(e.when.right, t)));
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
function B(e, t) {
|
|
794
|
+
return e.kind === "variable" && e.name === t;
|
|
795
|
+
}
|
|
796
|
+
function V(e) {
|
|
797
|
+
let t = 0;
|
|
798
|
+
for (let n = 0; n < e.length; n += 1) {
|
|
799
|
+
let r = e[n];
|
|
800
|
+
if (r === "{") t += 1;
|
|
801
|
+
else if (r === "}") t = Math.max(0, t - 1);
|
|
802
|
+
else if (r === "=" && t === 0) return n;
|
|
803
|
+
}
|
|
804
|
+
return -1;
|
|
805
|
+
}
|
|
806
|
+
function H(e, t) {
|
|
807
|
+
let n = [], r = 0, i = 0, a = (r) => {
|
|
808
|
+
let a = e.slice(i, r), o = a.length - a.trimStart().length, s = a.trim();
|
|
809
|
+
s && n.push({
|
|
810
|
+
text: s,
|
|
811
|
+
offset: t + i + o
|
|
812
|
+
});
|
|
813
|
+
};
|
|
814
|
+
for (let t = 0; t < e.length; t += 1) {
|
|
815
|
+
let n = e[t];
|
|
816
|
+
n === "{" ? r += 1 : n === "}" ? r = Math.max(0, r - 1) : n === "\\" && e[t + 1] === "\\" && r === 0 && (a(t), i = t + 2, t += 1);
|
|
817
|
+
}
|
|
818
|
+
return a(e.length), n;
|
|
819
|
+
}
|
|
820
|
+
function U(e) {
|
|
821
|
+
let t = /^\\begin\{cases\}([\s\S]*)\\end\{cases\}$/u.exec(e);
|
|
822
|
+
if (!t) return null;
|
|
823
|
+
let n = t.index + 13, r = H(t[1], n);
|
|
824
|
+
if (r.length !== 2) return null;
|
|
825
|
+
let i = null, a = null;
|
|
826
|
+
for (let e of r) {
|
|
827
|
+
let t = V(e.text);
|
|
828
|
+
if (t < 0) return null;
|
|
829
|
+
let n = e.text.slice(0, t).trim(), r = e.text.slice(t + 1), o = r.length - r.trimStart().length, s = r.trim();
|
|
830
|
+
if (!s) return null;
|
|
831
|
+
let c = e.offset + t + 1 + o;
|
|
832
|
+
if (n === "x" && i === null) i = {
|
|
833
|
+
text: s,
|
|
834
|
+
offset: c
|
|
835
|
+
};
|
|
836
|
+
else if (n === "y" && a === null) a = {
|
|
837
|
+
text: s,
|
|
838
|
+
offset: c
|
|
839
|
+
};
|
|
840
|
+
else return null;
|
|
841
|
+
}
|
|
842
|
+
return i !== null && a !== null ? {
|
|
843
|
+
x: i.text,
|
|
844
|
+
y: a.text,
|
|
845
|
+
xOffset: i.offset,
|
|
846
|
+
yOffset: a.offset
|
|
847
|
+
} : null;
|
|
848
|
+
}
|
|
849
|
+
function W(e) {
|
|
850
|
+
let t = e.trim();
|
|
851
|
+
if (!t) return null;
|
|
852
|
+
if (/^\\begin\{cases\}/u.test(t)) return "parametric";
|
|
853
|
+
let n = V(t);
|
|
854
|
+
if (n < 0) return null;
|
|
855
|
+
if (t.slice(0, n).trim() === "r") return "polar";
|
|
856
|
+
if (t.slice(0, n).trim() !== "y") return "implicit";
|
|
857
|
+
try {
|
|
858
|
+
let { right: e } = new C(t, y(t), { allowY: !0 }).parseEquation();
|
|
859
|
+
return z(e, "y") ? "implicit" : "explicit";
|
|
860
|
+
} catch {
|
|
861
|
+
return "explicit";
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
function G(e) {
|
|
865
|
+
if (typeof e != "string") throw new w("latex-syntax", "Math source must be a string.", 0);
|
|
866
|
+
if (e.length > 5e4) throw new w("latex-budget", "Formula exceeds the length limit.", d);
|
|
867
|
+
let t = e.trim();
|
|
868
|
+
if (!t) throw new w("latex-empty", "Formula is empty.", 0);
|
|
869
|
+
let n = U(t);
|
|
870
|
+
if (n) {
|
|
871
|
+
let e = (e) => y(e).some((e) => e.kind === "letter" && e.value === "x");
|
|
872
|
+
if (e(n.x) || e(n.y)) throw new w("latex-variable", "Parametric formulas use t and cannot read x.", 0);
|
|
873
|
+
let r = R(n.x), i = R(n.y), a = /* @__PURE__ */ new Set();
|
|
874
|
+
for (let e of [...r.dependencies, ...i.dependencies]) e !== "t" && e !== "x" && e !== "y" && a.add(e);
|
|
875
|
+
return {
|
|
876
|
+
kind: "parametric",
|
|
877
|
+
source: t,
|
|
878
|
+
expression: r,
|
|
879
|
+
yExpression: i,
|
|
880
|
+
dependencies: [...a]
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
let { left: r, right: i } = new C(t, y(t), { allowY: !0 }).parseEquation();
|
|
884
|
+
if (B(r, "r") && W(t) === "polar") {
|
|
885
|
+
for (let e of [
|
|
886
|
+
"x",
|
|
887
|
+
"y",
|
|
888
|
+
"r"
|
|
889
|
+
]) if (z(i, e)) throw new w("latex-variable", `Polar formulas use theta and cannot read ${e}.`, i.offset);
|
|
890
|
+
let e = /* @__PURE__ */ new Set();
|
|
891
|
+
return N(i, e), e.delete("theta"), {
|
|
892
|
+
kind: "polar",
|
|
893
|
+
source: t,
|
|
894
|
+
expression: L(t, i, [...e]),
|
|
895
|
+
yExpression: null,
|
|
896
|
+
dependencies: [...e]
|
|
897
|
+
};
|
|
898
|
+
}
|
|
899
|
+
if (B(r, "y") && !z(i, "y")) {
|
|
900
|
+
let e = R(t);
|
|
901
|
+
return {
|
|
902
|
+
kind: "explicit",
|
|
903
|
+
source: t,
|
|
904
|
+
expression: e,
|
|
905
|
+
yExpression: null,
|
|
906
|
+
dependencies: e.dependencies
|
|
907
|
+
};
|
|
908
|
+
}
|
|
909
|
+
let a = {
|
|
910
|
+
kind: "binary",
|
|
911
|
+
op: "-",
|
|
912
|
+
left: r,
|
|
913
|
+
right: i,
|
|
914
|
+
offset: r.offset
|
|
915
|
+
}, o = /* @__PURE__ */ new Set();
|
|
916
|
+
return N(a, o), o.delete("x"), o.delete("y"), {
|
|
917
|
+
kind: "implicit",
|
|
918
|
+
source: t,
|
|
919
|
+
expression: L(t, a, [...o]),
|
|
920
|
+
yExpression: null,
|
|
921
|
+
dependencies: [...o]
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
var K = 100, q = 32;
|
|
925
|
+
function J(e) {
|
|
926
|
+
return Math.max(32, Math.min(100, Math.floor(e)));
|
|
927
|
+
}
|
|
928
|
+
export { J as a, w as c, u as d, l as f, G as i, o as l, q as n, F as o, R as r, W as s, K as t, s as u };
|