reactive-md 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG-ch.md +397 -333
- package/CHANGELOG.md +398 -334
- package/CONTRIBUTING-ch.md +22 -22
- package/CONTRIBUTING.md +22 -22
- package/README-ch.md +431 -431
- package/README-en.md +431 -431
- package/README.md +429 -429
- package/SECURITY-ch.md +83 -83
- package/SECURITY.md +83 -83
- package/THIRD_PARTY_NOTICES.md +0 -57
- package/bin/reactive-md.mjs +39 -39
- package/cli/args.mjs +263 -263
- package/cli/assets.mjs +395 -395
- package/cli/build.mjs +445 -445
- package/cli/check.mjs +444 -444
- package/cli/document.mjs +130 -130
- package/cli/errors.mjs +61 -61
- package/cli/fs-utils.mjs +133 -133
- package/cli/glob.mjs +203 -203
- package/cli/help.mjs +325 -323
- package/cli/init.mjs +1577 -1577
- package/cli/lint.mjs +177 -177
- package/cli/main.mjs +65 -65
- package/cli/migrate.mjs +368 -368
- package/cli/package-loader.mjs +41 -41
- package/cli/package.mjs +211 -211
- package/dist-library/LocalDocumentView-CP2QG86k.js +114 -0
- package/dist-library/{LocalDocumentViewCore-DXE0I0Qc.js → LocalDocumentViewCore-Cd6yMEkg.js} +379 -9445
- package/dist-library/LocalReactiveDocumentCore-VuYpZqdn.js +283 -0
- package/dist-library/LocalStaticDocumentView-DfX6bemE.js +147 -0
- package/dist-library/authoring-Bwu_zCWs.js +768 -0
- package/dist-library/chart-B1TUtzm-.js +3 -0
- package/dist-library/choice-values-BItGjPD2.js +58 -0
- package/dist-library/color-values-r8Wf7ALn.js +6 -0
- package/dist-library/compile-B35rfzKr.js +1742 -0
- package/dist-library/compile-cache-key-D21X2Obx.js +28 -0
- package/dist-library/compiler-DBwLawMZ.js +98 -0
- package/dist-library/{compiler-core-DDDdvuLy.js → compiler-core-kkDiQ1RK.js} +4202 -3496
- package/dist-library/component-kernel-CsJSabHX.js +372 -0
- package/dist-library/{component-state-BRwvTV0d.js → component-state-Da0G8Ajc.js} +1 -1
- package/dist-library/component-utils-ZM3jUJNy.js +339 -0
- package/dist-library/conditional-branches-CIhJXasR.js +17 -0
- package/dist-library/config-validation-DbmsWAEV.js +469 -0
- package/dist-library/controls-DRy5rzzN.js +5970 -0
- package/dist-library/controls-DWlx-AQl.js +3 -0
- package/dist-library/{coordinate-B1VFK9fd.js → coordinate-c54pHfgf.js} +89 -89
- package/dist-library/data-BtFlkJzp.js +3 -0
- package/dist-library/data-table-CSAkm1eU.js +290 -0
- package/dist-library/data-table-model-DruztQFt.js +391 -0
- package/dist-library/data-visuals-rZQUeQM0.js +384 -0
- package/dist-library/{default-components-s21NevON.js → default-components-B-39etG9.js} +518 -355
- package/dist-library/{config-DXLvctiZ.js → default-config-CCa8rm2k.js} +265 -230
- package/dist-library/default-options-By16CVw1.js +131 -0
- package/dist-library/{registry-D6OGkOcX.js → default-registry-DXJy66xj.js} +4 -4
- package/dist-library/default-schema-CeYiEW1K.js +33 -0
- package/dist-library/diagram-BLepzI8l.js +3 -0
- package/dist-library/display-Bb6hAG5T.js +2065 -0
- package/dist-library/dist-Cueh1Psp.js +4761 -0
- package/dist-library/{document-theme-C8J6UyNO.js → document-theme-CJvN-nC1.js} +246 -4
- package/dist-library/{export-CIAIPBov.js → export-BSV4E0jv.js} +135 -135
- package/dist-library/font-aliases-CKYjwn4o.js +4 -0
- package/dist-library/gallery-BC6FYTqw.js +3 -0
- package/dist-library/{gallery-Dv1rOvL0.js → gallery-DM2yTVZJ.js} +1 -1
- package/dist-library/{html-Cr4CBwAH.js → html-CY9mC3Sr.js} +49 -48
- package/dist-library/{incremental-9nx92u9c.js → incremental-B-wW4H3F.js} +537 -384
- package/dist-library/{display-B_uutKkN.js → katex-4ukd4ZxT.js} +1555 -3618
- package/dist-library/layout-CPQggKxk.js +592 -0
- package/dist-library/layout-CaDWsDof.js +3 -0
- package/dist-library/limits-CFERRrlC.js +10 -0
- package/dist-library/localization-COdJ6lw2.js +6 -0
- package/dist-library/mafs-CnzDC5CR.js +3 -0
- package/dist-library/math-view-CyGTS6kv.js +20 -0
- package/dist-library/motion-tokens-Czk0RDmS.js +283 -0
- package/dist-library/mount-preset-DtrCX4G8.js +24 -0
- package/dist-library/numeric-sliders-BmJ1LCLx.js +542 -0
- package/dist-library/{observability-4KqXhIEU.js → observability-BVQ16ByQ.js} +125 -43
- package/dist-library/package-core-Cu_r_qs7.js +128 -0
- package/dist-library/parser-BHl9Lxbw.js +8 -0
- package/dist-library/parser-standard-DDAKv_DZ.js +4872 -0
- package/dist-library/plugin-packs-CkI0floL.js +19 -0
- package/dist-library/preset-core-BKPbH_Nv.js +1371 -0
- package/dist-library/props-0iDqxlTk.js +174 -0
- package/dist-library/react-74jdGBmu.js +32 -0
- package/dist-library/reactive-md-authoring.js +315 -296
- package/dist-library/reactive-md-build.js +334 -43
- package/dist-library/reactive-md-compiler-session.js +4 -0
- package/dist-library/reactive-md-compiler-standard.js +10 -10
- package/dist-library/reactive-md-compiler.js +3 -3
- package/dist-library/reactive-md-contracts.js +6 -0
- package/dist-library/reactive-md-default-packs.js +32 -15
- package/dist-library/reactive-md-default-preset.js +7 -7
- package/dist-library/reactive-md-export.js +6 -5
- package/dist-library/reactive-md-minimal-preset.js +3 -2
- package/dist-library/reactive-md-minimal-react-preset.js +26 -23
- package/dist-library/reactive-md-minimal.css +1 -1
- package/dist-library/reactive-md-observability.js +125 -3
- package/dist-library/reactive-md-pack-style-manifest.js +805 -0
- package/dist-library/reactive-md-plugin-chart.js +14 -9
- package/dist-library/reactive-md-plugin-data.js +8 -8
- package/dist-library/reactive-md-plugin-diagram.js +7 -6
- package/dist-library/reactive-md-plugin-forms.js +14 -13
- package/dist-library/reactive-md-plugin-gallery.js +6 -5
- package/dist-library/reactive-md-plugin-navigation.js +8 -8
- package/dist-library/reactive-md-plugin-network.js +13 -13
- package/dist-library/reactive-md-plugin-plot.js +7 -6
- package/dist-library/reactive-md-print.css +304 -304
- package/dist-library/reactive-md-react-component-accordion.js +10 -0
- package/dist-library/reactive-md-react-component-alert.js +10 -0
- package/dist-library/reactive-md-react-component-anchor.js +10 -0
- package/dist-library/reactive-md-react-component-badge.js +10 -0
- package/dist-library/reactive-md-react-component-card.js +10 -0
- package/dist-library/reactive-md-react-component-chart.js +22 -0
- package/dist-library/reactive-md-react-component-checkbox.js +10 -0
- package/dist-library/reactive-md-react-component-checklist.js +10 -0
- package/dist-library/reactive-md-react-component-choices.js +10 -0
- package/dist-library/reactive-md-react-component-column.js +6 -0
- package/dist-library/reactive-md-react-component-coordinate.js +21 -0
- package/dist-library/reactive-md-react-component-counter.js +10 -0
- package/dist-library/reactive-md-react-component-data-table.js +14 -0
- package/dist-library/reactive-md-react-component-date.js +10 -0
- package/dist-library/reactive-md-react-component-diagram.js +22 -0
- package/dist-library/reactive-md-react-component-disclosure.js +10 -0
- package/dist-library/reactive-md-react-component-edge.js +22 -0
- package/dist-library/reactive-md-react-component-else.js +10 -0
- package/dist-library/reactive-md-react-component-gallery-item.js +10 -0
- package/dist-library/reactive-md-react-component-gallery.js +10 -0
- package/dist-library/reactive-md-react-component-grid.js +10 -0
- package/dist-library/reactive-md-react-component-if.js +10 -0
- package/dist-library/reactive-md-react-component-input.js +10 -0
- package/dist-library/reactive-md-react-component-jump.js +10 -0
- package/dist-library/reactive-md-react-component-multi-select.js +10 -0
- package/dist-library/reactive-md-react-component-node.js +22 -0
- package/dist-library/reactive-md-react-component-number.js +10 -0
- package/dist-library/reactive-md-react-component-option.js +10 -0
- package/dist-library/reactive-md-react-component-panel.js +10 -0
- package/dist-library/reactive-md-react-component-plot.js +26 -0
- package/dist-library/reactive-md-react-component-progress.js +10 -0
- package/dist-library/reactive-md-react-component-quiz.js +10 -0
- package/dist-library/reactive-md-react-component-radio-group.js +10 -0
- package/dist-library/reactive-md-react-component-range-slider.js +10 -0
- package/dist-library/reactive-md-react-component-section.js +10 -0
- package/dist-library/reactive-md-react-component-select.js +10 -0
- package/dist-library/reactive-md-react-component-slider.js +10 -0
- package/dist-library/reactive-md-react-component-step.js +10 -0
- package/dist-library/reactive-md-react-component-steps.js +10 -0
- package/dist-library/reactive-md-react-component-tab.js +10 -0
- package/dist-library/reactive-md-react-component-table.js +14 -0
- package/dist-library/reactive-md-react-component-tabs.js +10 -0
- package/dist-library/reactive-md-react-component-text.js +10 -0
- package/dist-library/reactive-md-react-component-textarea.js +10 -0
- package/dist-library/reactive-md-react-component-timeline.js +14 -0
- package/dist-library/reactive-md-react-component-timer.js +10 -0
- package/dist-library/reactive-md-react-component-toggle.js +10 -0
- package/dist-library/reactive-md-react-component-tooltip.js +10 -0
- package/dist-library/reactive-md-react-component-validation.js +10 -0
- package/dist-library/reactive-md-react-minimal.js +4 -4
- package/dist-library/reactive-md-react-pack-controls.js +44 -0
- package/dist-library/reactive-md-react-pack-data.js +21 -0
- package/dist-library/reactive-md-react-pack-layout.js +37 -0
- package/dist-library/reactive-md-react-pack-visuals.js +43 -0
- package/dist-library/reactive-md-react-packed.js +50 -0
- package/dist-library/reactive-md-react-server.js +29 -27
- package/dist-library/reactive-md-react-static-server.js +24 -0
- package/dist-library/reactive-md-react-static.js +1 -0
- package/dist-library/reactive-md-react-unstyled.js +15 -12
- package/dist-library/reactive-md-react.js +15 -12
- package/dist-library/reactive-md-scan.js +1 -0
- package/dist-library/reactive-md-sdk.js +23 -9
- package/dist-library/reactive-md-standalone-configured.js +2 -2
- package/dist-library/reactive-md-standalone-host.js +2 -2
- package/dist-library/reactive-md-testing-browser.js +2 -2
- package/dist-library/reactive-md-testing-react.js +32 -32
- package/dist-library/reactive-md-testing.js +12 -12
- package/dist-library/reactive-md-vite.js +25 -9
- package/dist-library/reactive-md-worker-pool.js +401 -0
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +97 -1554
- package/dist-library/registry-core-DxEaxhJ6.js +126 -0
- package/dist-library/render-nodes-B6j6Ip5I.js +9404 -0
- package/dist-library/requirements-C56sFIEs.js +157 -0
- package/dist-library/resources-6VaNgk-h.js +74 -0
- package/dist-library/rmd-pack-controls.css +1032 -0
- package/dist-library/rmd-pack-data.css +724 -0
- package/dist-library/rmd-pack-layout.css +1834 -0
- package/dist-library/rmd-pack-resource-chart.css +300 -0
- package/dist-library/rmd-pack-resource-controls.css +781 -0
- package/dist-library/rmd-pack-resource-data-visuals.css +501 -0
- package/dist-library/rmd-pack-resource-diagram.css +106 -0
- package/dist-library/rmd-pack-resource-gallery.css +346 -0
- package/dist-library/rmd-pack-resource-graphics.css +516 -0
- package/dist-library/rmd-pack-resource-layout.css +1489 -0
- package/dist-library/rmd-pack-resource-mafs-core.css +124 -0
- package/dist-library/rmd-pack-resource-mafs.css +129 -0
- package/dist-library/rmd-pack-resource-visual-base.css +224 -0
- package/dist-library/rmd-pack-visuals.css +1394 -0
- package/dist-library/runtime-BHeuLOv_.js +1369 -0
- package/dist-library/runtime-requirement-DzPO8raU.js +772 -0
- package/dist-library/schema-core-CDXfxdID.js +155 -0
- package/dist-library/sdk-core-CnE-n0Z7.js +1295 -0
- package/dist-library/{session-core-dxQCJBNa.js → session-core-C071yQwV.js} +147 -133
- package/dist-library/sha256-utf16-Bmandi_H.js +937 -0
- package/dist-library/shareable-CHCDnl6j.js +844 -0
- package/dist-library/shared-bTzN-F4g.js +3 -0
- package/dist-library/structural-views-30-YD_TJ.js +11 -0
- package/dist-library/table-surface-CfZn_tk-.js +13 -0
- package/dist-library/types/assemblies/compile-cache-key.d.ts +11 -0
- package/dist-library/types/assemblies/default-config.d.ts +35 -0
- package/dist-library/types/{local/configuration/options.d.ts → assemblies/default-options.d.ts} +4 -4
- package/dist-library/types/assemblies/default-registry.d.ts +18 -0
- package/dist-library/types/{local/configuration/schema.d.ts → assemblies/default-schema.d.ts} +4 -4
- package/dist-library/types/authoring/catalog.d.ts +14 -2
- package/dist-library/types/authoring/extensions.d.ts +1 -1
- package/dist-library/types/authoring/index.d.ts +4 -4
- package/dist-library/types/authoring/templates.d.ts +1 -1
- package/dist-library/types/compiler/index.d.ts +1 -0
- package/dist-library/types/compiler/session.d.ts +19 -0
- package/dist-library/types/compiler/standard.d.ts +1 -0
- package/dist-library/types/components/chart/default-chart-types.d.ts +3 -0
- package/dist-library/types/components/chart/default-chart.d.ts +7 -0
- package/dist-library/types/components/entries/accordion.d.ts +3 -0
- package/dist-library/types/components/entries/alert.d.ts +3 -0
- package/dist-library/types/components/entries/anchor.d.ts +3 -0
- package/dist-library/types/components/entries/badge.d.ts +3 -0
- package/dist-library/types/components/entries/card.d.ts +3 -0
- package/dist-library/types/components/entries/chart.d.ts +3 -0
- package/dist-library/types/components/entries/checkbox.d.ts +3 -0
- package/dist-library/types/components/entries/checklist.d.ts +3 -0
- package/dist-library/types/components/entries/choices.d.ts +3 -0
- package/dist-library/types/components/entries/column.d.ts +3 -0
- package/dist-library/types/components/entries/coordinate.d.ts +3 -0
- package/dist-library/types/components/entries/counter.d.ts +3 -0
- package/dist-library/types/components/entries/data-table.d.ts +3 -0
- package/dist-library/types/components/entries/date.d.ts +3 -0
- package/dist-library/types/components/entries/diagram.d.ts +3 -0
- package/dist-library/types/components/entries/disclosure.d.ts +3 -0
- package/dist-library/types/components/entries/edge.d.ts +3 -0
- package/dist-library/types/components/entries/else.d.ts +3 -0
- package/dist-library/types/components/entries/gallery-item.d.ts +3 -0
- package/dist-library/types/components/entries/gallery.d.ts +3 -0
- package/dist-library/types/components/entries/grid.d.ts +3 -0
- package/dist-library/types/components/entries/if.d.ts +3 -0
- package/dist-library/types/components/entries/input.d.ts +3 -0
- package/dist-library/types/components/entries/jump.d.ts +3 -0
- package/dist-library/types/components/entries/multi-select.d.ts +3 -0
- package/dist-library/types/components/entries/node.d.ts +3 -0
- package/dist-library/types/components/entries/number.d.ts +3 -0
- package/dist-library/types/components/entries/option.d.ts +3 -0
- package/dist-library/types/components/entries/panel.d.ts +3 -0
- package/dist-library/types/components/entries/plot.d.ts +3 -0
- package/dist-library/types/components/entries/progress.d.ts +3 -0
- package/dist-library/types/components/entries/quiz.d.ts +3 -0
- package/dist-library/types/components/entries/radio-group.d.ts +3 -0
- package/dist-library/types/components/entries/range-slider.d.ts +3 -0
- package/dist-library/types/components/entries/section.d.ts +3 -0
- package/dist-library/types/components/entries/select.d.ts +3 -0
- package/dist-library/types/components/entries/slider.d.ts +3 -0
- package/dist-library/types/components/entries/step.d.ts +3 -0
- package/dist-library/types/components/entries/steps.d.ts +3 -0
- package/dist-library/types/components/entries/tab.d.ts +3 -0
- package/dist-library/types/components/entries/table.d.ts +3 -0
- package/dist-library/types/components/entries/tabs.d.ts +3 -0
- package/dist-library/types/components/entries/text.d.ts +3 -0
- package/dist-library/types/components/entries/textarea.d.ts +3 -0
- package/dist-library/types/components/entries/timeline.d.ts +3 -0
- package/dist-library/types/components/entries/timer.d.ts +3 -0
- package/dist-library/types/components/entries/toggle.d.ts +3 -0
- package/dist-library/types/components/entries/tooltip.d.ts +3 -0
- package/dist-library/types/components/entries/validation.d.ts +3 -0
- package/dist-library/types/components/layout/layout.d.ts +6 -3
- package/dist-library/types/components/layout/structural-views.d.ts +3 -0
- package/dist-library/types/components/mount-preset.d.ts +2 -0
- package/dist-library/types/components/packs/controls.d.ts +2 -0
- package/dist-library/types/components/packs/data.d.ts +2 -0
- package/dist-library/types/components/packs/layout.d.ts +2 -0
- package/dist-library/types/components/packs/visuals.d.ts +2 -0
- package/dist-library/types/components/shared/data-visuals.d.ts +3 -0
- package/dist-library/types/components/shared/table-surface.d.ts +10 -0
- package/dist-library/types/components/shared/visual-helpers.d.ts +24 -0
- package/dist-library/types/components/shared/visuals.d.ts +1 -3
- package/dist-library/types/components/table/data-table-model.d.ts +141 -0
- package/dist-library/types/components/table/data-table.d.ts +3 -50
- package/dist-library/types/{local/configuration → contracts}/component-kernel.d.ts +9 -2
- package/dist-library/types/contracts/font-aliases.d.ts +18 -0
- package/dist-library/types/contracts/index.d.ts +8 -0
- package/dist-library/types/{local/configuration → contracts}/limits.d.ts +9 -1
- package/dist-library/types/contracts/localization.d.ts +6 -0
- package/dist-library/types/contracts/number-literal.d.ts +2 -0
- package/dist-library/types/contracts/runtime-types.d.ts +19 -0
- package/dist-library/types/contracts/sha256-utf16.d.ts +2 -0
- package/dist-library/types/export/index.d.ts +4 -1
- package/dist-library/types/local/compilation/cache-version.d.ts +1 -0
- package/dist-library/types/local/compilation/compile-status.d.ts +2 -0
- package/dist-library/types/local/compilation/compiler-bindings.d.ts +1 -1
- package/dist-library/types/local/compilation/compiler-capabilities.d.ts +4 -1
- package/dist-library/types/local/compilation/compiler-choices.d.ts +4 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +1 -1
- package/dist-library/types/local/compilation/compiler-declarations.d.ts +2 -1
- package/dist-library/types/local/compilation/compiler-embedding.d.ts +20 -0
- package/dist-library/types/local/compilation/compiler-expressions.d.ts +17 -5
- package/dist-library/types/local/compilation/compiler-macros.d.ts +18 -0
- package/dist-library/types/local/compilation/compiler-structure.d.ts +9 -3
- package/dist-library/types/local/compilation/compiler-tables.d.ts +4 -2
- package/dist-library/types/local/compilation/compiler-validation.d.ts +14 -7
- package/dist-library/types/local/compilation/compiler-values.d.ts +2 -3
- package/dist-library/types/local/compilation/compiler.d.ts +1 -1
- package/dist-library/types/local/compilation/component-usage.d.ts +2 -0
- package/dist-library/types/local/compilation/runtime-requirement.d.ts +3 -0
- package/dist-library/types/local/compilation/session/incremental.d.ts +5 -1
- package/dist-library/types/local/compilation/streaming.d.ts +1 -1
- package/dist-library/types/local/configuration/diagnostic-messages.d.ts +228 -2
- package/dist-library/types/local/configuration/diagnostic-runtime-messages.d.ts +40 -0
- package/dist-library/types/local/configuration/embedding.d.ts +4 -0
- package/dist-library/types/local/configuration/kernel-value-rules.d.ts +1 -1
- package/dist-library/types/local/configuration/options-core.d.ts +8 -2
- package/dist-library/types/local/evaluation/choice-values.d.ts +22 -0
- package/dist-library/types/local/evaluation/computations.d.ts +13 -5
- package/dist-library/types/local/evaluation/dataset.d.ts +4 -0
- package/dist-library/types/local/evaluation/expression/collection-functions.d.ts +13 -0
- package/dist-library/types/local/evaluation/expression/compile.d.ts +11 -4
- package/dist-library/types/local/evaluation/expression/data-functions.d.ts +23 -0
- package/dist-library/types/local/evaluation/expression/evaluation.d.ts +3 -1
- package/dist-library/types/local/evaluation/expression/internal-names.d.ts +8 -0
- package/dist-library/types/local/evaluation/expression/syntax.d.ts +19 -2
- package/dist-library/types/local/evaluation/expression/transform-budget.d.ts +13 -0
- package/dist-library/types/local/evaluation/expression/values.d.ts +9 -1
- package/dist-library/types/local/evaluation/validation.d.ts +8 -6
- package/dist-library/types/local/index.d.ts +10 -4
- package/dist-library/types/local/observability-core.d.ts +20 -1
- package/dist-library/types/local/observability.d.ts +2 -0
- package/dist-library/types/local/parsing/conditional-branches.d.ts +4 -0
- package/dist-library/types/local/parsing/parse-budget.d.ts +18 -2
- package/dist-library/types/local/parsing/parser-region.d.ts +13 -2
- package/dist-library/types/local/parsing/parser-tags.d.ts +6 -1
- package/dist-library/types/local/parsing/rmd-recovery.d.ts +8 -0
- package/dist-library/types/local/parsing/source-revision.d.ts +3 -0
- package/dist-library/types/local/performance-report.d.ts +70 -0
- package/dist-library/types/local/runtime/runtime-choices.d.ts +11 -0
- package/dist-library/types/local/runtime/runtime-pool.d.ts +14 -0
- package/dist-library/types/local/runtime/runtime.d.ts +3 -1
- package/dist-library/types/local/runtime/state.d.ts +30 -15
- package/dist-library/types/local/source/authoring-requirements.d.ts +3 -0
- package/dist-library/types/local/source/authoring-syntax.d.ts +3 -2
- package/dist-library/types/local/source/authoring.d.ts +10 -0
- package/dist-library/types/local/source/source-migration.d.ts +1 -0
- package/dist-library/types/local/transport/worker-handler.d.ts +3 -0
- package/dist-library/types/local/transport/worker-job.d.ts +12 -2
- package/dist-library/types/local/transport/worker-pool.d.ts +68 -0
- package/dist-library/types/local/transport/worker.d.ts +14 -0
- package/dist-library/types/local/types.d.ts +70 -27
- package/dist-library/types/observability.d.ts +1 -0
- package/dist-library/types/presets/default-semantics.d.ts +1 -1
- package/dist-library/types/presets/identity.d.ts +1 -8
- package/dist-library/types/presets/pack-style-entry.d.ts +3 -0
- package/dist-library/types/presets/pack-style-manifest.d.ts +11 -0
- package/dist-library/types/react/component-api.d.ts +24 -4
- package/dist-library/types/react/component-loader.d.ts +61 -0
- package/dist-library/types/react/component-primitives.d.ts +5 -5
- package/dist-library/types/react/component-utils.d.ts +11 -0
- package/dist-library/types/react/font-aliases.d.ts +2 -0
- package/dist-library/types/react/index.d.ts +9 -5
- package/dist-library/types/react/localization.d.ts +5 -6
- package/dist-library/types/react/minimal.d.ts +2 -2
- package/dist-library/types/react/package-core.d.ts +6 -0
- package/dist-library/types/react/packed.d.ts +17 -0
- package/dist-library/types/react/render-lifecycle.d.ts +9 -0
- package/dist-library/types/{local → react}/rendering/document/ExtendedHtmlFragment.d.ts +1 -1
- package/dist-library/types/{local → react}/rendering/document/LocalDocumentViewCore.d.ts +11 -4
- package/dist-library/types/react/rendering/document/LocalPooledDocumentView.d.ts +8 -0
- package/dist-library/types/react/rendering/document/LocalReactiveDocumentCore.d.ts +6 -0
- package/dist-library/types/react/rendering/document/LocalStaticDocumentView.d.ts +18 -0
- package/dist-library/types/react/rendering/document/StaticExternalSlot.d.ts +25 -0
- package/dist-library/types/react/rendering/document/StaticHostData.d.ts +14 -0
- package/dist-library/types/{local → react}/rendering/document/render-nodes.d.ts +8 -8
- package/dist-library/types/react/rendering/document/static-runtime.d.ts +11 -0
- package/dist-library/types/{local → react}/rendering/document/use-author-script.d.ts +2 -2
- package/dist-library/types/{local → react}/rendering/document/validation-state.d.ts +3 -3
- package/dist-library/types/{local → react}/rendering/document/view-render-context.d.ts +40 -8
- package/dist-library/types/{local → react}/rendering/document/view-revision.d.ts +5 -14
- package/dist-library/types/{local → react}/rendering/render-types.d.ts +5 -5
- package/dist-library/types/react/rendering/table/data-table.d.ts +5 -0
- package/dist-library/types/{local → react}/rendering/table/table-numeric-columns.d.ts +3 -3
- package/dist-library/types/react/sdk-core.d.ts +15 -4
- package/dist-library/types/react/sdk.d.ts +2 -1
- package/dist-library/types/react/server.d.ts +3 -10
- package/dist-library/types/react/static-server.d.ts +12 -0
- package/dist-library/types/scan/index.d.ts +15 -0
- package/dist-library/types/sdk/assembly.d.ts +3 -0
- package/dist-library/types/sdk/config.d.ts +2 -35
- package/dist-library/types/sdk/default-identity.d.ts +3 -0
- package/dist-library/types/sdk/font.d.ts +13 -0
- package/dist-library/types/sdk/index.d.ts +2 -1
- package/dist-library/types/sdk/preset.d.ts +9 -0
- package/dist-library/types/sdk/props.d.ts +8 -3
- package/dist-library/types/sdk/registry-core.d.ts +2 -2
- package/dist-library/types/sdk/registry.d.ts +2 -18
- package/dist-library/types/sdk/theme.d.ts +5 -0
- package/dist-library/types/sdk/types.d.ts +8 -2
- package/dist-library/types/sdk/version.d.ts +2 -0
- package/dist-library/types/shareable.d.ts +15 -3
- package/dist-library/types/standalone/prepare.d.ts +4 -2
- package/dist-library/types/standalone/session-core.d.ts +5 -2
- package/dist-library/types/vite/index.d.ts +3 -0
- package/dist-library/types/vite/registration.d.ts +1 -0
- package/dist-library/{types-Ib5kSScP.js → types-B4qG8J4S.js} +1 -1
- package/dist-library/types-FYhRWRn9.js +3 -0
- package/dist-library/use-hydrated-D1gFY2Dq.js +2655 -0
- package/dist-library/validation-DRuW0Wl9.js +433 -0
- package/dist-library/{version-DAxuGOG2.js → version-4wzhbvDG.js} +24 -33
- package/dist-library/visual-frame-y5RFhJ0_.js +19 -0
- package/dist-library/visual-helpers-UU6xiL8g.js +75 -0
- package/dist-library/visuals-7xzoL9ql.js +49340 -0
- package/dist-library/visuals-CdHezgh5.js +3 -0
- package/dist-library/worker-3ldRjOEG.js +1632 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +127 -366
- package/docs/README-ch.md +104 -101
- package/docs/README.md +104 -101
- package/docs/compatibility/api-stability-ch.md +1 -1
- package/docs/compatibility/api-stability-en.md +1 -1
- package/docs/compatibility/compatibility-ch.md +146 -146
- package/docs/compatibility/compatibility-en.md +146 -146
- package/docs/compatibility/compatibility-manifest.schema.json +3 -2
- package/docs/compatibility/deprecation-ch.md +2 -2
- package/docs/compatibility/deprecation-en.md +2 -2
- package/docs/compatibility/source-versioning-ch.md +170 -162
- package/docs/compatibility/source-versioning-en.md +171 -162
- package/docs/compatibility/support-matrix-ch.md +4 -3
- package/docs/compatibility/support-matrix-en.md +4 -3
- package/docs/development/component-development-ch.md +66 -66
- package/docs/development/component-development-en.md +66 -66
- package/docs/development/component-development-reference-ch.md +269 -253
- package/docs/development/component-development-reference-en.md +254 -238
- package/docs/development/component-protocol-ch.md +768 -748
- package/docs/development/component-protocol-en.md +770 -750
- package/docs/development/extension-tutorial-ch.md +308 -308
- package/docs/development/extension-tutorial-en.md +308 -308
- package/docs/development/performance-overview-ch.md +422 -422
- package/docs/development/performance-overview-en.md +422 -422
- package/docs/guides/local-guide-ch.md +621 -532
- package/docs/guides/local-guide-en.md +621 -532
- package/docs/integration/author-tools-ch.md +66 -64
- package/docs/integration/author-tools-en.md +66 -64
- package/docs/integration/compiler-ch.md +90 -49
- package/docs/integration/compiler-en.md +77 -36
- package/docs/integration/directory-discovery-en.md +1 -1
- package/docs/integration/editor-ch.md +295 -295
- package/docs/integration/editor-en.md +303 -303
- package/docs/integration/extension-sdk-ch.md +424 -394
- package/docs/integration/extension-sdk-en.md +409 -379
- package/docs/integration/local-integration-ch.md +648 -646
- package/docs/integration/local-integration-en.md +664 -662
- package/docs/integration/pdf-export-ch.md +42 -0
- package/docs/integration/pdf-export-en.md +42 -0
- package/docs/integration/shareable-export-ch.md +299 -307
- package/docs/integration/shareable-export-en.md +301 -309
- package/docs/reference/diagnostics-counting-ch.md +127 -104
- package/docs/reference/diagnostics-counting-en.md +127 -104
- package/docs/reference/html-compatibility-ch.md +93 -93
- package/docs/reference/html-compatibility-en.md +95 -95
- package/docs/reference/local-interaction-syntax-ch.md +913 -724
- package/docs/reference/local-interaction-syntax-en.md +911 -722
- package/docs/reference/public-api-ch.md +134 -21
- package/docs/reference/public-api-en.md +134 -21
- package/docs/reference/theme-protocol-ch.md +198 -198
- package/docs/reference/theme-protocol-en.md +217 -217
- package/docs/releases/release-0.10.0-ch.md +45 -0
- package/docs/releases/release-0.10.0-en.md +45 -0
- package/docs/releases/release-0.4.0-ch.md +91 -91
- package/docs/releases/release-0.4.0-en.md +91 -91
- package/docs/releases/release-0.4.1-ch.md +25 -25
- package/docs/releases/release-0.4.1-en.md +25 -25
- package/docs/releases/release-0.5.0-ch.md +43 -43
- package/docs/releases/release-0.5.0-en.md +43 -43
- package/docs/releases/release-0.5.1-ch.md +41 -41
- package/docs/releases/release-0.5.1-en.md +41 -41
- package/docs/releases/release-0.5.2-ch.md +37 -37
- package/docs/releases/release-0.5.2-en.md +37 -37
- package/docs/releases/release-0.5.3-ch.md +26 -26
- package/docs/releases/release-0.5.3-en.md +26 -26
- package/docs/releases/release-0.6.0-ch.md +59 -59
- package/docs/releases/release-0.6.0-en.md +59 -59
- package/docs/releases/release-0.6.1-ch.md +29 -29
- package/docs/releases/release-0.6.1-en.md +29 -29
- package/docs/releases/release-0.7.0-ch.md +86 -86
- package/docs/releases/release-0.7.0-en.md +86 -86
- package/docs/releases/release-0.9.3-ch.md +45 -0
- package/docs/releases/release-0.9.3-en.md +45 -0
- package/examples/component-package/README-ch.md +101 -101
- package/examples/component-package/README.md +133 -133
- package/examples/conformance/README-ch.md +55 -55
- package/examples/conformance/README.md +55 -55
- package/examples/conformance/component-protocol-1.json +482 -482
- package/examples/conformance/component-protocol-1.schema.json +76 -76
- package/examples/conformance/local-draft-1.json +50 -50
- package/examples/conformance/local-draft-2.json +212 -212
- package/examples/conformance/local-draft-4.json +441 -0
- package/examples/game-2048-package/LICENSE +21 -21
- package/examples/game-2048-package/NOTICES.md +11 -11
- package/examples/game-2048-package/README-ch.md +91 -91
- package/examples/game-2048-package/README.md +98 -98
- package/examples/game-2048-package/package.json +35 -35
- package/examples/game-2048-package/sample/document.reactive.md +17 -17
- package/examples/game-2048-package/scripts/build-export.mjs +44 -44
- package/examples/game-2048-package/scripts/build.mjs +130 -130
- package/examples/game-2048-package/scripts/verify.mjs +180 -180
- package/examples/game-2048-package/src/component.css +161 -161
- package/examples/game-2048-package/src/components.tsx +326 -326
- package/examples/game-2048-package/src/game-engine.ts +228 -228
- package/examples/game-2048-package/src/harness.tsx +34 -34
- package/examples/game-2048-package/src/manifest.ts +85 -85
- package/examples/game-2048-package/src/node-entry.ts +30 -30
- package/examples/game-2048-package/src/sample.ts +4 -4
- package/examples/game-2048-package/tsconfig.json +15 -15
- package/examples/integration/README-ch.md +114 -82
- package/examples/integration/README.md +114 -82
- package/examples/integration/chat-session/index.mjs +91 -0
- package/examples/integration/chat-session/package.json +10 -0
- package/examples/integration/core/index.mjs +32 -32
- package/examples/integration/extension-sdk/README-ch.md +24 -24
- package/examples/integration/extension-sdk/README.md +24 -24
- package/examples/integration/static-embed/embed.mjs +44 -0
- package/examples/integration/static-embed/index.html +12 -0
- package/examples/integration/static-embed/main.mjs +24 -0
- package/examples/integration/static-embed/references.mjs +5 -0
- package/examples/integration/static-embed/render.mjs +10 -0
- package/examples/integration/worker/index.html +19 -19
- package/examples/integration/worker/main.js +61 -61
- package/examples/integration/worker/package.json +13 -13
- package/examples/integration/worker/worker.js +3 -3
- package/examples/local/README-ch.md +76 -76
- package/examples/local/README.md +76 -76
- package/examples/local/charts.reactive.md +73 -73
- package/examples/local/recipes/invoice-zh.reactive.md +36 -36
- package/examples/local/recipes/invoice.reactive.md +36 -36
- package/examples/local/recipes/workshop-zh.reactive.md +33 -33
- package/examples/local/recipes/workshop.reactive.md +33 -33
- package/examples/local/showcase/README-ch.md +22 -22
- package/examples/local/showcase/README.md +31 -31
- package/examples/local/showcase/explore.reactive.md +102 -102
- package/examples/local/showcase/flow.reactive.md +86 -86
- package/examples/local/showcase/forms.reactive.md +126 -126
- package/examples/local/showcase/functions.reactive.md +119 -119
- package/examples/local/showcase/layout.reactive.md +100 -100
- package/examples/local/showcase/statistics.reactive.md +108 -108
- package/examples/local/showcase/tasks.reactive.md +89 -89
- package/examples/local/showcase/zh/explore.reactive.md +102 -102
- package/examples/local/showcase/zh/flow.reactive.md +86 -86
- package/examples/local/showcase/zh/forms.reactive.md +126 -126
- package/examples/local/showcase/zh/functions.reactive.md +119 -119
- package/examples/local/showcase/zh/layout.reactive.md +100 -100
- package/examples/local/showcase/zh/statistics.reactive.md +108 -108
- package/examples/local/showcase/zh/tasks.reactive.md +89 -89
- package/examples/minimal-extension/README-ch.md +78 -78
- package/examples/minimal-extension/README.md +78 -78
- package/examples/minimal-extension/index.html +15 -15
- package/examples/minimal-extension/package.json +26 -26
- package/examples/minimal-extension/sample/document.reactive.md +10 -10
- package/examples/minimal-extension/scripts/build.mjs +32 -32
- package/examples/minimal-extension/scripts/export.mjs +72 -72
- package/examples/minimal-extension/scripts/test-node.mjs +75 -75
- package/examples/minimal-extension/src/extension.tsx +90 -90
- package/examples/minimal-extension/src/preview.tsx +12 -12
- package/examples/minimal-extension/src/source.ts +4 -4
- package/examples/minimal-extension/tsconfig.json +14 -14
- package/examples/sci-fi-theme/README-ch.md +133 -133
- package/examples/sci-fi-theme/README.md +148 -148
- package/examples/sci-fi-theme/demo/acceptance.reactive.md +454 -454
- package/examples/sci-fi-theme/demo/demo.css +638 -638
- package/examples/sci-fi-theme/demo/document.reactive.md +206 -206
- package/examples/sci-fi-theme/demo/index.html +13 -13
- package/examples/sci-fi-theme/demo/main.tsx +215 -215
- package/examples/sci-fi-theme/docs/design-system-ch.md +245 -245
- package/examples/sci-fi-theme/docs/design-system.md +474 -474
- package/examples/sci-fi-theme/package.json +28 -28
- package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -98
- package/examples/sci-fi-theme/src/components.css +2370 -2370
- package/examples/sci-fi-theme/src/index.ts +6 -6
- package/examples/sci-fi-theme/src/notch.css +142 -142
- package/examples/sci-fi-theme/src/sci-fi.css +7 -7
- package/examples/sci-fi-theme/src/theme.ts +39 -39
- package/examples/sci-fi-theme/tsconfig.json +20 -20
- package/examples/sci-fi-theme/vite.config.ts +24 -24
- package/examples/tetris-package/LICENSE +21 -21
- package/examples/tetris-package/NOTICES.md +11 -11
- package/examples/tetris-package/README-ch.md +91 -91
- package/examples/tetris-package/README.md +95 -95
- package/examples/tetris-package/package.json +35 -35
- package/examples/tetris-package/sample/document.reactive.md +16 -16
- package/examples/tetris-package/scripts/build-export.mjs +44 -44
- package/examples/tetris-package/scripts/build.mjs +130 -130
- package/examples/tetris-package/scripts/verify.mjs +173 -173
- package/examples/tetris-package/src/component.css +145 -145
- package/examples/tetris-package/src/components.tsx +334 -334
- package/examples/tetris-package/src/harness.tsx +34 -34
- package/examples/tetris-package/src/manifests.ts +93 -93
- package/examples/tetris-package/src/node-entry.ts +16 -16
- package/examples/tetris-package/src/sample.ts +4 -4
- package/examples/tetris-package/src/tetris-engine.ts +325 -325
- package/examples/tetris-package/tsconfig.json +15 -15
- package/package.json +66 -2
- package/dist-library/LocalDocumentView-BuqgJZEY.js +0 -109
- package/dist-library/LocalReactiveDocumentCore-CWBe4Mm5.js +0 -275
- package/dist-library/authoring-Ci_KzJ0q.js +0 -892
- package/dist-library/compile-Dx6Uw3D9.js +0 -1249
- package/dist-library/compiler-dxLPB9Ym.js +0 -86
- package/dist-library/config-validation-D3D7Dy2J.js +0 -586
- package/dist-library/controls-DoZyLCrV.js +0 -6740
- package/dist-library/data-table-8-3F15Jf.js +0 -296
- package/dist-library/layout-BBB2VF0S.js +0 -562
- package/dist-library/mount-preset-DMZ5wd3t.js +0 -13
- package/dist-library/options-BBp9IcHm.js +0 -121
- package/dist-library/package-core-K5xesGqy.js +0 -117
- package/dist-library/parser-standard-CBA1-hdG.js +0 -9630
- package/dist-library/plugin-packs-Bh1HhLym.js +0 -19
- package/dist-library/preset-core-DeZPA8IE.js +0 -1298
- package/dist-library/props-sJ8vk0cr.js +0 -183
- package/dist-library/react-0DCh-Mar.js +0 -7
- package/dist-library/registry-core-C9xOunaw.js +0 -479
- package/dist-library/resources-B0x_w3s9.js +0 -229
- package/dist-library/runtime-BpQdZmFI.js +0 -1288
- package/dist-library/schema-BryM_VRW.js +0 -40
- package/dist-library/sdk-core-ChslheKs.js +0 -1167
- package/dist-library/shareable-B8xMoGEa.js +0 -814
- package/dist-library/types/local/rendering/document/LocalReactiveDocumentCore.d.ts +0 -6
- package/dist-library/types/local/rendering/table/data-table.d.ts +0 -13
- package/dist-library/types-daDo2c_w.js +0 -3
- package/dist-library/validation-B3RI0xOk.js +0 -1123
- package/dist-library/visual-frame-_rcd5HUv.js +0 -48
- package/dist-library/visuals-DkDhNdEZ.js +0 -72572
- /package/dist-library/types/{local/configuration → contracts}/color-values.d.ts +0 -0
- /package/dist-library/types/{local/html → contracts}/html-names.d.ts +0 -0
- /package/dist-library/types/{local/configuration → contracts}/schema-core.d.ts +0 -0
- /package/dist-library/types/{local → react}/rendering/code/code-block.d.ts +0 -0
- /package/dist-library/types/{local → react}/rendering/code/code-languages.d.ts +0 -0
- /package/dist-library/types/{local → react}/rendering/document/LocalDocumentView.d.ts +0 -0
- /package/dist-library/types/{local → react}/rendering/document/use-color-scheme.d.ts +0 -0
- /package/dist-library/types/{local → react}/rendering/image/image-view.d.ts +0 -0
- /package/dist-library/types/{local → react}/rendering/math-view.d.ts +0 -0
|
@@ -0,0 +1,1632 @@
|
|
|
1
|
+
import "./limits-CFERRrlC.js";
|
|
2
|
+
import { v as e } from "./document-theme-CJvN-nC1.js";
|
|
3
|
+
import { f as t } from "./compiler-core-kkDiQ1RK.js";
|
|
4
|
+
import { n, s as r } from "./sha256-utf16-Bmandi_H.js";
|
|
5
|
+
import { r as i } from "./compiler-DBwLawMZ.js";
|
|
6
|
+
import { c as a } from "./default-config-CCa8rm2k.js";
|
|
7
|
+
import { t as o } from "./default-options-By16CVw1.js";
|
|
8
|
+
import { n as s, r as c, t as l } from "./observability-core-Bcu7vpnl.js";
|
|
9
|
+
import { t as u } from "./authoring-Bwu_zCWs.js";
|
|
10
|
+
import { n as d } from "./incremental-B-wW4H3F.js";
|
|
11
|
+
import { n as f } from "./observability-BVQ16ByQ.js";
|
|
12
|
+
// src/local/transport/compile-patch.ts
|
|
13
|
+
var p = "patch-v1", m = 1, h = 4096, g = [
|
|
14
|
+
"initialState",
|
|
15
|
+
"bindings",
|
|
16
|
+
"bindingSlots",
|
|
17
|
+
"computations",
|
|
18
|
+
"dependencies",
|
|
19
|
+
"tableShapes"
|
|
20
|
+
];
|
|
21
|
+
function _(e) {
|
|
22
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
23
|
+
}
|
|
24
|
+
function v(e) {
|
|
25
|
+
return _(e) && typeof e.start == "number" && Number.isFinite(e.start) && typeof e.end == "number" && Number.isFinite(e.end);
|
|
26
|
+
}
|
|
27
|
+
function y() {
|
|
28
|
+
throw TypeError("Invalid local compile result patch");
|
|
29
|
+
}
|
|
30
|
+
function b(e, t) {
|
|
31
|
+
if (e === t) return !0;
|
|
32
|
+
if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
|
|
33
|
+
let n = Array.isArray(e);
|
|
34
|
+
if (n !== Array.isArray(t)) return !1;
|
|
35
|
+
if (n) {
|
|
36
|
+
let n = e, r = t;
|
|
37
|
+
if (n.length !== r.length) return !1;
|
|
38
|
+
for (let e = 0; e < n.length; e += 1) if (!b(n[e], r[e])) return !1;
|
|
39
|
+
return !0;
|
|
40
|
+
}
|
|
41
|
+
let r = e, i = t, a = Object.keys(r);
|
|
42
|
+
if (a.length !== Object.keys(i).length) return !1;
|
|
43
|
+
for (let e of a) if (!Object.hasOwn(i, e) || !b(r[e], i[e])) return !1;
|
|
44
|
+
return !0;
|
|
45
|
+
}
|
|
46
|
+
function x(e) {
|
|
47
|
+
return t(e, !1);
|
|
48
|
+
}
|
|
49
|
+
function S(e, t) {
|
|
50
|
+
if (typeof e != "string" || typeof t != "string" || e === t) return null;
|
|
51
|
+
let n = Math.min(e.length, t.length), r = 0;
|
|
52
|
+
for (; r < n && e.charCodeAt(r) === t.charCodeAt(r);) r += 1;
|
|
53
|
+
let i = e.length, a = t.length;
|
|
54
|
+
for (; i > r && a > r && e.charCodeAt(i - 1) === t.charCodeAt(a - 1);) --i, --a;
|
|
55
|
+
return {
|
|
56
|
+
from: r,
|
|
57
|
+
to: i,
|
|
58
|
+
insert: t.slice(r, a)
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function C(e) {
|
|
62
|
+
if (!_(e)) return null;
|
|
63
|
+
let { from: t, to: n, insert: r } = e;
|
|
64
|
+
return typeof t != "number" || !Number.isSafeInteger(t) || typeof n != "number" || !Number.isSafeInteger(n) || typeof r != "string" || t < 0 || n < t ? null : {
|
|
65
|
+
from: t,
|
|
66
|
+
to: n,
|
|
67
|
+
insert: r
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function w(e, t) {
|
|
71
|
+
let n = C(t);
|
|
72
|
+
return n === null || typeof e != "string" || n.to > e.length ? null : e.slice(0, n.from) + n.insert + e.slice(n.to);
|
|
73
|
+
}
|
|
74
|
+
function T(e) {
|
|
75
|
+
let t = {};
|
|
76
|
+
for (let [n, r] of Object.entries(e)) n !== "children" && (t[n] = r);
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
79
|
+
function ee(e, t) {
|
|
80
|
+
let n = Object.keys(e).filter((e) => e !== "children"), r = Object.keys(t).filter((e) => e !== "children");
|
|
81
|
+
if (n.length !== r.length) return !1;
|
|
82
|
+
for (let r of n) if (!Object.hasOwn(t, r) || !b(e[r], t[r])) return !1;
|
|
83
|
+
return !0;
|
|
84
|
+
}
|
|
85
|
+
function E(e) {
|
|
86
|
+
return e.children === void 0 ? void 0 : e.children.map((e) => e.id);
|
|
87
|
+
}
|
|
88
|
+
function D(e, t) {
|
|
89
|
+
let n = E(e), r = E(t);
|
|
90
|
+
if (n === void 0 || r === void 0) return n === r;
|
|
91
|
+
if (n.length !== r.length) return !1;
|
|
92
|
+
for (let e = 0; e < n.length; e += 1) if (n[e] !== r[e]) return !1;
|
|
93
|
+
return !0;
|
|
94
|
+
}
|
|
95
|
+
function O(e, t) {
|
|
96
|
+
if (!ee(e, t) || !D(e, t)) return !1;
|
|
97
|
+
if (!e.children || !t.children) return !0;
|
|
98
|
+
for (let n = 0; n < e.children.length; n += 1) if (!O(e.children[n], t.children[n])) return !1;
|
|
99
|
+
return !0;
|
|
100
|
+
}
|
|
101
|
+
function k(e, t) {
|
|
102
|
+
let n = Object.keys(e).filter((e) => e !== "children" && e !== "range"), r = Object.keys(t).filter((e) => e !== "children" && e !== "range");
|
|
103
|
+
if (n.length !== r.length) return null;
|
|
104
|
+
for (let r of n) if (!Object.hasOwn(t, r) || !b(e[r], t[r])) return null;
|
|
105
|
+
if (!v(e.range) || !v(t.range)) return null;
|
|
106
|
+
let i = e.range.start - t.range.start;
|
|
107
|
+
if (e.range.end !== t.range.end + i) return null;
|
|
108
|
+
let a = E(e), o = E(t);
|
|
109
|
+
if (a === void 0 || o === void 0) {
|
|
110
|
+
if (a !== o) return null;
|
|
111
|
+
} else {
|
|
112
|
+
if (a.length !== o.length) return null;
|
|
113
|
+
for (let n = 0; n < a.length; n += 1) if (a[n] !== o[n] || k(e.children[n], t.children[n]) !== i) return null;
|
|
114
|
+
}
|
|
115
|
+
return i;
|
|
116
|
+
}
|
|
117
|
+
function te(e, t) {
|
|
118
|
+
let n = Object.keys(e).filter((e) => e !== "children" && e !== "range"), r = Object.keys(t).filter((e) => e !== "children" && e !== "range");
|
|
119
|
+
if (n.length !== r.length) return null;
|
|
120
|
+
for (let r of n) if (!Object.hasOwn(t, r) || !b(e[r], t[r])) return null;
|
|
121
|
+
if (!v(e.range) || !v(t.range)) return null;
|
|
122
|
+
let i = e.range.start - t.range.start;
|
|
123
|
+
return e.range.end === t.range.end + i ? i : null;
|
|
124
|
+
}
|
|
125
|
+
function A(e) {
|
|
126
|
+
let t = /* @__PURE__ */ new Map(), n = [...e].reverse();
|
|
127
|
+
for (; n.length > 0;) {
|
|
128
|
+
let e = n.pop();
|
|
129
|
+
if (t.set(e.id, e), e.children) for (let t = e.children.length - 1; t >= 0; --t) n.push(e.children[t]);
|
|
130
|
+
}
|
|
131
|
+
return t;
|
|
132
|
+
}
|
|
133
|
+
function j(e, t, n, r) {
|
|
134
|
+
if (t !== void 0 && O(e, t)) return;
|
|
135
|
+
if (t === void 0) {
|
|
136
|
+
r.push({
|
|
137
|
+
id: e.id,
|
|
138
|
+
node: e
|
|
139
|
+
});
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
let i = k(e, t);
|
|
143
|
+
if (i !== null) {
|
|
144
|
+
i !== 0 && r.push({
|
|
145
|
+
id: e.id,
|
|
146
|
+
shift: i,
|
|
147
|
+
subtree: !0
|
|
148
|
+
});
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
let a = { id: e.id };
|
|
152
|
+
if (!ee(e, t)) {
|
|
153
|
+
let n = te(e, t);
|
|
154
|
+
n !== null && n !== 0 ? a.shift = n : a.data = T(e);
|
|
155
|
+
}
|
|
156
|
+
D(e, t) || (a.children = e.children === void 0 ? null : e.children.map((e) => e.id));
|
|
157
|
+
let o = r.length;
|
|
158
|
+
if (e.children) for (let t of e.children) j(t, n.get(t.id), n, r);
|
|
159
|
+
Object.keys(a).length > 1 ? r.splice(o, 0, a) : r.length > o && r.splice(o, 0, { id: e.id });
|
|
160
|
+
}
|
|
161
|
+
function ne(e, t) {
|
|
162
|
+
if (!_(e)) return { set: t };
|
|
163
|
+
let n = {}, r = [];
|
|
164
|
+
for (let [r, i] of Object.entries(t)) Object.hasOwn(e, r) && b(e[r], i) || (n[r] = i);
|
|
165
|
+
for (let n of Object.keys(e)) Object.hasOwn(t, n) || r.push(n);
|
|
166
|
+
return Object.keys(n).length === 0 && r.length === 0 ? null : {
|
|
167
|
+
...Object.keys(n).length === 0 ? {} : { set: n },
|
|
168
|
+
...r.length === 0 ? {} : { remove: r }
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
var re = /* @__PURE__ */ new WeakMap();
|
|
172
|
+
function ie(e) {
|
|
173
|
+
let t = 2;
|
|
174
|
+
for (let n = 0; n < e.length; n++) {
|
|
175
|
+
let r = e.charCodeAt(n);
|
|
176
|
+
if (r === 34 || r === 92) t += 2;
|
|
177
|
+
else if (r < 32) t += r === 8 || r === 9 || r === 10 || r === 12 || r === 13 ? 2 : 6;
|
|
178
|
+
else if (r < 128) t++;
|
|
179
|
+
else if (r < 2048) t += 2;
|
|
180
|
+
else if (r >= 55296 && r <= 56319) {
|
|
181
|
+
let r = e.charCodeAt(n + 1);
|
|
182
|
+
r >= 56320 && r <= 57343 ? (t += 4, n++) : t += 6;
|
|
183
|
+
} else t += r >= 56320 && r <= 57343 ? 6 : 3;
|
|
184
|
+
}
|
|
185
|
+
return t;
|
|
186
|
+
}
|
|
187
|
+
function M(e, t) {
|
|
188
|
+
if (e === null) return {
|
|
189
|
+
bytes: 4,
|
|
190
|
+
nodes: 0
|
|
191
|
+
};
|
|
192
|
+
let n = typeof e;
|
|
193
|
+
if (n === "string") return {
|
|
194
|
+
bytes: ie(e),
|
|
195
|
+
nodes: 0
|
|
196
|
+
};
|
|
197
|
+
if (n === "number") return {
|
|
198
|
+
bytes: Number.isFinite(e) ? String(e).length : 4,
|
|
199
|
+
nodes: 0
|
|
200
|
+
};
|
|
201
|
+
if (n === "boolean") return {
|
|
202
|
+
bytes: e === !0 ? 4 : 5,
|
|
203
|
+
nodes: 0
|
|
204
|
+
};
|
|
205
|
+
if (n !== "object") return {
|
|
206
|
+
bytes: 0,
|
|
207
|
+
nodes: 0
|
|
208
|
+
};
|
|
209
|
+
let r = e, i = re.get(r);
|
|
210
|
+
if (i !== void 0) return i;
|
|
211
|
+
if (t.has(r)) return {
|
|
212
|
+
bytes: 0,
|
|
213
|
+
nodes: 0
|
|
214
|
+
};
|
|
215
|
+
t.add(r);
|
|
216
|
+
let a, o = +!!P(e);
|
|
217
|
+
if (Array.isArray(e)) {
|
|
218
|
+
a = 2;
|
|
219
|
+
for (let n = 0; n < e.length; n += 1) {
|
|
220
|
+
n > 0 && (a += 1);
|
|
221
|
+
let r = M(e[n], t);
|
|
222
|
+
a += r.bytes || 4, o += r.nodes;
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
a = 2;
|
|
226
|
+
let e = 0;
|
|
227
|
+
for (let n in r) {
|
|
228
|
+
if (!Object.hasOwn(r, n)) continue;
|
|
229
|
+
let i = r[n];
|
|
230
|
+
if (i === void 0) continue;
|
|
231
|
+
e > 0 && (a += 1), e += 1, a += ie(n) + 1;
|
|
232
|
+
let s = M(i, t);
|
|
233
|
+
a += s.bytes, o += s.nodes;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
t.delete(r);
|
|
237
|
+
let s = {
|
|
238
|
+
bytes: a,
|
|
239
|
+
nodes: o
|
|
240
|
+
};
|
|
241
|
+
return re.set(r, s), s;
|
|
242
|
+
}
|
|
243
|
+
function ae(e, t) {
|
|
244
|
+
let n = e.document.nodes ?? [];
|
|
245
|
+
try {
|
|
246
|
+
let r = M(e, /* @__PURE__ */ new Set()), i = t.ok && typeof t.document.source == "string" ? t.document.source.length : 0;
|
|
247
|
+
if (r.bytes <= Math.max(i, h)) return {
|
|
248
|
+
patchBytes: r.bytes,
|
|
249
|
+
patchNodes: n.length,
|
|
250
|
+
preferFull: !1
|
|
251
|
+
};
|
|
252
|
+
let a = M(t, /* @__PURE__ */ new Set()), o = 0;
|
|
253
|
+
for (let e of n) e.node === void 0 ? e.data !== void 0 && (o += 1) : o += M(e.node, /* @__PURE__ */ new Set()).nodes;
|
|
254
|
+
let s = r.bytes * m >= a.bytes, c = a.nodes > 0 && o * m >= a.nodes;
|
|
255
|
+
return {
|
|
256
|
+
patchBytes: r.bytes,
|
|
257
|
+
fullBytes: a.bytes,
|
|
258
|
+
patchNodes: n.length,
|
|
259
|
+
fullNodes: a.nodes,
|
|
260
|
+
preferFull: s || c,
|
|
261
|
+
...s ? { reason: "bytes" } : c ? { reason: "nodes" } : {}
|
|
262
|
+
};
|
|
263
|
+
} catch {
|
|
264
|
+
return {
|
|
265
|
+
patchBytes: 0,
|
|
266
|
+
patchNodes: n.length,
|
|
267
|
+
preferFull: !1
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function oe(e, t) {
|
|
272
|
+
return le(e, t);
|
|
273
|
+
}
|
|
274
|
+
function se(e, t) {
|
|
275
|
+
let n = le(e, t);
|
|
276
|
+
return n ? {
|
|
277
|
+
patch: n,
|
|
278
|
+
cost: ae(n, t)
|
|
279
|
+
} : null;
|
|
280
|
+
}
|
|
281
|
+
function ce(e, t) {
|
|
282
|
+
let n = e.recoveries, r = t.recoveries;
|
|
283
|
+
return n === void 0 ? r === void 0 ? {} : { recoveries: r } : r !== void 0 && b(n, r) ? {} : { recoveries: r === void 0 ? null : r };
|
|
284
|
+
}
|
|
285
|
+
function le(e, t) {
|
|
286
|
+
try {
|
|
287
|
+
if (!e.ok || !t.ok) return null;
|
|
288
|
+
let n = e.document, r = t.document;
|
|
289
|
+
if (!_(n) || !_(r)) return null;
|
|
290
|
+
let i = {};
|
|
291
|
+
if (typeof n.source == "string" && typeof r.source == "string") {
|
|
292
|
+
let e = S(n.source, r.source);
|
|
293
|
+
e !== null && (i.source = e);
|
|
294
|
+
} else if (n.source !== r.source) return null;
|
|
295
|
+
let a = [], o = {}, s = {}, c = new Set(g), l = /* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)]);
|
|
296
|
+
for (let e of l) {
|
|
297
|
+
if (e === "source" || e === "nodes" || c.has(e)) continue;
|
|
298
|
+
let t = Object.hasOwn(r, e) && r[e] !== void 0, i = Object.hasOwn(n, e) && n[e] !== void 0;
|
|
299
|
+
t ? i && b(n[e], r[e]) || (o[e] = r[e]) : i && a.push(e);
|
|
300
|
+
}
|
|
301
|
+
for (let e of g) {
|
|
302
|
+
let t = Object.hasOwn(r, e) && r[e] !== void 0, i = Object.hasOwn(n, e) && n[e] !== void 0, c = i ? n[e] : void 0, l = t ? r[e] : void 0;
|
|
303
|
+
if (!t) {
|
|
304
|
+
i && a.push(e);
|
|
305
|
+
continue;
|
|
306
|
+
}
|
|
307
|
+
if (!_(l)) {
|
|
308
|
+
i && b(c, l) || (o[e] = l);
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
311
|
+
if (!i) {
|
|
312
|
+
s[e] = { set: l };
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
if (!_(c)) {
|
|
316
|
+
o[e] = l;
|
|
317
|
+
continue;
|
|
318
|
+
}
|
|
319
|
+
let u = ne(c, l);
|
|
320
|
+
u !== null && (s[e] = u);
|
|
321
|
+
}
|
|
322
|
+
let u = Array.isArray(n.nodes) ? n.nodes : [], d = Array.isArray(r.nodes) ? r.nodes : [], f = u.map((e) => e.id), m = d.map((e) => e.id), h = f.length !== m.length;
|
|
323
|
+
if (!h) {
|
|
324
|
+
for (let e = 0; e < f.length; e += 1) if (f[e] !== m[e]) {
|
|
325
|
+
h = !0;
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
let v = [], y = A(u);
|
|
330
|
+
for (let e of d) j(e, y.get(e.id), y, v);
|
|
331
|
+
return h && (i.roots = m), v.length > 0 && (i.nodes = v), a.length > 0 && (i.removed = a), Object.keys(o).length > 0 && (i.values = o), Object.keys(s).length > 0 && (i.records = s), {
|
|
332
|
+
kind: "result-patch",
|
|
333
|
+
protocol: p,
|
|
334
|
+
document: i,
|
|
335
|
+
...b(e.diagnostics, t.diagnostics) ? {} : { diagnostics: t.diagnostics },
|
|
336
|
+
...ce(e, t)
|
|
337
|
+
};
|
|
338
|
+
} catch {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
function N(e, t) {
|
|
343
|
+
let n = T(e);
|
|
344
|
+
return v(n.range) || y(), n.range = {
|
|
345
|
+
start: n.range.start + t,
|
|
346
|
+
end: n.range.end + t
|
|
347
|
+
}, e.children && (n.children = e.children.map((e) => N(e, t))), n;
|
|
348
|
+
}
|
|
349
|
+
function P(e) {
|
|
350
|
+
return _(e) && typeof e.id == "string" && typeof e.type == "string" && v(e.range);
|
|
351
|
+
}
|
|
352
|
+
function ue(e, t) {
|
|
353
|
+
_(t) || y(), t.set !== void 0 && !_(t.set) && y(), t.remove !== void 0 && !Array.isArray(t.remove) && y();
|
|
354
|
+
let n = {};
|
|
355
|
+
if (_(e)) for (let [t, r] of Object.entries(e)) Object.defineProperty(n, t, {
|
|
356
|
+
value: r,
|
|
357
|
+
enumerable: !0,
|
|
358
|
+
configurable: !0,
|
|
359
|
+
writable: !0
|
|
360
|
+
});
|
|
361
|
+
else e !== void 0 && y();
|
|
362
|
+
if (t.set) for (let [e, r] of Object.entries(t.set)) Object.defineProperty(n, e, {
|
|
363
|
+
value: x(r),
|
|
364
|
+
enumerable: !0,
|
|
365
|
+
configurable: !0,
|
|
366
|
+
writable: !0
|
|
367
|
+
});
|
|
368
|
+
if (t.remove) for (let e of t.remove) typeof e != "string" && y(), delete n[e];
|
|
369
|
+
return n;
|
|
370
|
+
}
|
|
371
|
+
function F(e, t) {
|
|
372
|
+
try {
|
|
373
|
+
if (!e.ok || !_(t) || t.kind !== "result-patch" || t.protocol !== "patch-v1") return null;
|
|
374
|
+
let n = t.document;
|
|
375
|
+
if (!_(n)) return null;
|
|
376
|
+
let r = e.document;
|
|
377
|
+
if (!_(r)) return null;
|
|
378
|
+
let i = {};
|
|
379
|
+
for (let [e, t] of Object.entries(r)) Object.defineProperty(i, e, {
|
|
380
|
+
value: t,
|
|
381
|
+
enumerable: !0,
|
|
382
|
+
configurable: !0,
|
|
383
|
+
writable: !0
|
|
384
|
+
});
|
|
385
|
+
if (n.removed !== void 0) {
|
|
386
|
+
if (!Array.isArray(n.removed)) return null;
|
|
387
|
+
for (let e of n.removed) {
|
|
388
|
+
if (typeof e != "string" || e === "nodes" || e === "source") return null;
|
|
389
|
+
delete i[e];
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
if (n.values !== void 0) {
|
|
393
|
+
if (!_(n.values)) return null;
|
|
394
|
+
for (let [e, t] of Object.entries(n.values)) {
|
|
395
|
+
if (e === "nodes" || e === "source") return null;
|
|
396
|
+
Object.defineProperty(i, e, {
|
|
397
|
+
value: x(t),
|
|
398
|
+
enumerable: !0,
|
|
399
|
+
configurable: !0,
|
|
400
|
+
writable: !0
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (n.records !== void 0) {
|
|
405
|
+
if (!_(n.records)) return null;
|
|
406
|
+
for (let e of Object.keys(n.records)) {
|
|
407
|
+
if (!g.includes(e)) return null;
|
|
408
|
+
let t = n.records[e];
|
|
409
|
+
t !== void 0 && (i[e] = ue(r[e], t));
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
let a = typeof r.source == "string" ? r.source : null;
|
|
413
|
+
if (a === null) return null;
|
|
414
|
+
if (n.source !== void 0) {
|
|
415
|
+
let e = C(n.source);
|
|
416
|
+
if (e === null) return null;
|
|
417
|
+
let t = w(a, e);
|
|
418
|
+
if (t === null) return null;
|
|
419
|
+
a = t;
|
|
420
|
+
}
|
|
421
|
+
i.source = a;
|
|
422
|
+
let o = Array.isArray(r.nodes) ? r.nodes : [], s = A(o), c = /* @__PURE__ */ new Map();
|
|
423
|
+
if (n.nodes !== void 0) {
|
|
424
|
+
if (!Array.isArray(n.nodes)) return null;
|
|
425
|
+
for (let e of n.nodes) {
|
|
426
|
+
if (!_(e) || typeof e.id != "string" || c.has(e.id)) return null;
|
|
427
|
+
c.set(e.id, e);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
let l;
|
|
431
|
+
if (n.roots !== void 0) {
|
|
432
|
+
if (!Array.isArray(n.roots)) return null;
|
|
433
|
+
l = [];
|
|
434
|
+
for (let e of n.roots) {
|
|
435
|
+
if (typeof e != "string") return null;
|
|
436
|
+
l.push(e);
|
|
437
|
+
}
|
|
438
|
+
} else l = o.map((e) => e.id);
|
|
439
|
+
let u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Set(), f = (e) => {
|
|
440
|
+
let t = u.get(e);
|
|
441
|
+
if (t !== void 0) return t;
|
|
442
|
+
d.has(e) && y();
|
|
443
|
+
let n = c.get(e), r = s.get(e);
|
|
444
|
+
if (n === void 0) return r === void 0 && y(), u.set(e, r), r;
|
|
445
|
+
if (_(n) || y(), n.node !== void 0) {
|
|
446
|
+
(n.data !== void 0 || n.children !== void 0 || n.shift !== void 0 || n.subtree) && y(), P(n.node) && n.node.id === e || y();
|
|
447
|
+
let t = x(n.node);
|
|
448
|
+
return u.set(e, t), t;
|
|
449
|
+
}
|
|
450
|
+
r === void 0 && n.data === void 0 && y(), n.subtree !== void 0 && n.subtree !== !0 && y(), n.shift !== void 0 && !Number.isSafeInteger(n.shift) && y(), n.data !== void 0 && n.shift !== void 0 && y(), n.children !== void 0 && n.children !== null && (!Array.isArray(n.children) || n.children.some((e) => typeof e != "string")) && y(), d.add(e);
|
|
451
|
+
let i;
|
|
452
|
+
if (n.subtree === !0) (r === void 0 || n.shift === void 0 || n.data !== void 0 || n.children !== void 0) && y(), i = N(r, n.shift);
|
|
453
|
+
else {
|
|
454
|
+
let t;
|
|
455
|
+
n.data === void 0 ? (r === void 0 && y(), t = T(r), n.shift !== void 0 && (v(t.range) || y(), t.range = {
|
|
456
|
+
start: t.range.start + n.shift,
|
|
457
|
+
end: t.range.end + n.shift
|
|
458
|
+
})) : (_(n.data) || y(), t = x(n.data), delete t.children, t.id !== e && y());
|
|
459
|
+
let a;
|
|
460
|
+
if (n.children !== void 0) a = n.children === null ? null : [...n.children];
|
|
461
|
+
else {
|
|
462
|
+
let e = r?.children;
|
|
463
|
+
a = e === void 0 ? void 0 : e.map((e) => e.id);
|
|
464
|
+
}
|
|
465
|
+
a === null ? delete t.children : a !== void 0 && (t.children = a.map(f)), i = t;
|
|
466
|
+
}
|
|
467
|
+
return d.delete(e), u.set(e, i), i;
|
|
468
|
+
}, p = l.map(f);
|
|
469
|
+
i.nodes = n.roots === void 0 && n.nodes === void 0 ? r.nodes : p;
|
|
470
|
+
let m = t.diagnostics === void 0 ? e.diagnostics : Array.isArray(t.diagnostics) ? x(t.diagnostics) : y();
|
|
471
|
+
if (t.recoveries !== void 0 && t.recoveries !== null && !Array.isArray(t.recoveries)) return null;
|
|
472
|
+
let h = e.status === void 0 ? {} : { status: e.status };
|
|
473
|
+
if (t.recoveries === null) return {
|
|
474
|
+
ok: !0,
|
|
475
|
+
document: i,
|
|
476
|
+
diagnostics: m,
|
|
477
|
+
...h
|
|
478
|
+
};
|
|
479
|
+
let b = t.recoveries === void 0 ? e.recoveries : x([...t.recoveries]);
|
|
480
|
+
return {
|
|
481
|
+
ok: !0,
|
|
482
|
+
document: i,
|
|
483
|
+
diagnostics: m,
|
|
484
|
+
...h,
|
|
485
|
+
...b === void 0 ? {} : { recoveries: b }
|
|
486
|
+
};
|
|
487
|
+
} catch {
|
|
488
|
+
return null;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
// src/local/transport/flat-compiled-data.ts
|
|
492
|
+
var I = "flat-v1";
|
|
493
|
+
function L(e) {
|
|
494
|
+
if (!e.ok) return !1;
|
|
495
|
+
let t = e.document.nodes.map((e) => ({
|
|
496
|
+
node: e,
|
|
497
|
+
depth: 0
|
|
498
|
+
}));
|
|
499
|
+
for (; t.length;) {
|
|
500
|
+
let { node: e, depth: n } = t.pop();
|
|
501
|
+
if (n >= 100) return !0;
|
|
502
|
+
if (e.children) for (let r of e.children) t.push({
|
|
503
|
+
node: r,
|
|
504
|
+
depth: n + 1
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
return !1;
|
|
508
|
+
}
|
|
509
|
+
function de(e) {
|
|
510
|
+
let t = [], n = /* @__PURE__ */ new Map(), r = [], i = (e) => {
|
|
511
|
+
if (typeof e == "object" && e) {
|
|
512
|
+
let i = n.get(e);
|
|
513
|
+
if (i !== void 0) return i;
|
|
514
|
+
let a = t.length, o = Array.isArray(e) ? [
|
|
515
|
+
1,
|
|
516
|
+
e.length,
|
|
517
|
+
[]
|
|
518
|
+
] : [2, []];
|
|
519
|
+
return n.set(e, a), t.push(o), r.push({
|
|
520
|
+
value: e,
|
|
521
|
+
record: o
|
|
522
|
+
}), a;
|
|
523
|
+
}
|
|
524
|
+
if (e !== null && ![
|
|
525
|
+
"string",
|
|
526
|
+
"number",
|
|
527
|
+
"boolean",
|
|
528
|
+
"undefined"
|
|
529
|
+
].includes(typeof e)) throw TypeError("Unsupported compiler wire value");
|
|
530
|
+
let i = t.length;
|
|
531
|
+
return t.push([0, e]), i;
|
|
532
|
+
};
|
|
533
|
+
for (i(e); r.length;) {
|
|
534
|
+
let { value: e, record: t } = r.pop(), n = t[0] === 1 ? t[2] : t[1];
|
|
535
|
+
for (let t of Object.keys(e)) n.push([t, i(e[t])]);
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
version: I,
|
|
539
|
+
records: t
|
|
540
|
+
};
|
|
541
|
+
}
|
|
542
|
+
function R(e) {
|
|
543
|
+
if (!e || typeof e != "object") return null;
|
|
544
|
+
let t = e;
|
|
545
|
+
if (t.version !== "flat-v1" || !Array.isArray(t.records) || t.records.length === 0 || t.records.length > 2e6) return null;
|
|
546
|
+
let n = t.records, r = Array(n.length), i = Array(n.length), a = 0;
|
|
547
|
+
for (let e = 0; e < n.length; e++) {
|
|
548
|
+
let t = n[e];
|
|
549
|
+
if (!Array.isArray(t)) return null;
|
|
550
|
+
if (t[0] === 0) {
|
|
551
|
+
if (t.length !== 2 || t[1] !== null && ![
|
|
552
|
+
"string",
|
|
553
|
+
"number",
|
|
554
|
+
"boolean",
|
|
555
|
+
"undefined"
|
|
556
|
+
].includes(typeof t[1])) return null;
|
|
557
|
+
r[e] = t[1], i[e] = [];
|
|
558
|
+
continue;
|
|
559
|
+
}
|
|
560
|
+
let o = t[0] === 1;
|
|
561
|
+
if (!o && t[0] !== 2 || t.length !== (o ? 3 : 2) || o && (!Number.isSafeInteger(t[1]) || t[1] < 0 || t[1] > 1e6)) return null;
|
|
562
|
+
let s = o ? t[2] : t[1];
|
|
563
|
+
if (!Array.isArray(s)) return null;
|
|
564
|
+
let c = /* @__PURE__ */ new Set(), l = [];
|
|
565
|
+
for (let e of s) if (!Array.isArray(e) || e.length !== 2 || typeof e[0] != "string" || !Number.isSafeInteger(e[1]) || e[1] < 0 || e[1] >= n.length || c.has(e[0]) || o && (e[0] === "length" || !/^(0|[1-9][0-9]*)$/.test(e[0]) || Number(e[0]) >= t[1]) || (c.add(e[0]), l.push(e[1]), ++a > 4e6)) return null;
|
|
566
|
+
r[e] = o ? Array(t[1]) : {}, i[e] = l;
|
|
567
|
+
}
|
|
568
|
+
let o = new Uint8Array(n.length), s = [{
|
|
569
|
+
index: 0,
|
|
570
|
+
child: 0
|
|
571
|
+
}];
|
|
572
|
+
o[0] = 1;
|
|
573
|
+
let c = 1;
|
|
574
|
+
for (; s.length;) {
|
|
575
|
+
let e = s[s.length - 1], t = i[e.index];
|
|
576
|
+
if (e.child === t.length) {
|
|
577
|
+
o[e.index] = 2, s.pop();
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
let n = t[e.child++];
|
|
581
|
+
if (o[n] === 1) return null;
|
|
582
|
+
o[n] === 0 && (o[n] = 1, c++, s.push({
|
|
583
|
+
index: n,
|
|
584
|
+
child: 0
|
|
585
|
+
}));
|
|
586
|
+
}
|
|
587
|
+
if (c !== n.length) return null;
|
|
588
|
+
for (let e = 0; e < n.length; e++) {
|
|
589
|
+
let t = n[e];
|
|
590
|
+
if (t[0] === 0) continue;
|
|
591
|
+
let i = t[0] === 1 ? t[2] : t[1];
|
|
592
|
+
for (let [t, n] of i) Object.defineProperty(r[e], t, {
|
|
593
|
+
value: r[n],
|
|
594
|
+
enumerable: !0,
|
|
595
|
+
writable: !0,
|
|
596
|
+
configurable: !0
|
|
597
|
+
});
|
|
598
|
+
}
|
|
599
|
+
return r[0];
|
|
600
|
+
}
|
|
601
|
+
// src/local/transport/worker-job.ts
|
|
602
|
+
var fe = 150, pe = 200, me = [
|
|
603
|
+
"maxSyntaxNodes",
|
|
604
|
+
"maxParseWork",
|
|
605
|
+
"maxMarkdownDepth",
|
|
606
|
+
"maxRawBodyChars"
|
|
607
|
+
];
|
|
608
|
+
function z(e) {
|
|
609
|
+
return e instanceof Error ? e.message : String(e);
|
|
610
|
+
}
|
|
611
|
+
function B() {
|
|
612
|
+
return typeof performance < "u" ? performance.now() : Date.now();
|
|
613
|
+
}
|
|
614
|
+
function V(e) {
|
|
615
|
+
return Number.isFinite(e) ? Math.max(0, Math.round(e)) : 0;
|
|
616
|
+
}
|
|
617
|
+
function H(e) {
|
|
618
|
+
let { parseMs: t, semanticMs: n, reuseMs: r, rebuildMs: i } = e.stages ?? {};
|
|
619
|
+
return {
|
|
620
|
+
...e.compiledBlocks === void 0 ? {} : { compiledBlocks: e.compiledBlocks },
|
|
621
|
+
...e.reusedBlocks === void 0 ? {} : { reusedBlocks: e.reusedBlocks },
|
|
622
|
+
...t === void 0 ? {} : { parseMs: V(t) },
|
|
623
|
+
...n === void 0 ? {} : { semanticMs: V(n) },
|
|
624
|
+
...r === void 0 ? {} : { reuseMs: V(r) },
|
|
625
|
+
...i === void 0 ? {} : { rebuildMs: V(i) }
|
|
626
|
+
};
|
|
627
|
+
}
|
|
628
|
+
function U(e, t, n) {
|
|
629
|
+
let r = {
|
|
630
|
+
tokens: [],
|
|
631
|
+
bindings: [],
|
|
632
|
+
diagnostics: []
|
|
633
|
+
};
|
|
634
|
+
if (n.ok && n.document.source !== e || !n.ok && n.diagnostics.some((e) => e.code.startsWith("local.budget") || e.code.startsWith("local.options."))) return r;
|
|
635
|
+
try {
|
|
636
|
+
return u(e, t, {
|
|
637
|
+
...n.ok ? { document: n.document } : {},
|
|
638
|
+
diagnostics: !1
|
|
639
|
+
});
|
|
640
|
+
} catch {
|
|
641
|
+
return {
|
|
642
|
+
tokens: [],
|
|
643
|
+
bindings: [],
|
|
644
|
+
diagnostics: []
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function he(e) {
|
|
649
|
+
return Array.isArray(e) ? e.length > 32 ? Array(33) : e.map((e) => {
|
|
650
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return e;
|
|
651
|
+
let t = e, n = { ...t }, r = t.props;
|
|
652
|
+
if (!r || typeof r != "object" || Array.isArray(r)) return n.props = r, n;
|
|
653
|
+
let i = {};
|
|
654
|
+
for (let [e, t] of Object.entries(r)) {
|
|
655
|
+
if (!t || typeof t != "object" || Array.isArray(t)) {
|
|
656
|
+
i[e] = t;
|
|
657
|
+
continue;
|
|
658
|
+
}
|
|
659
|
+
let n = t, r = { ...n };
|
|
660
|
+
Array.isArray(n.enum) && n.enum.length <= 64 && (r.enum = [...n.enum]), i[e] = r;
|
|
661
|
+
}
|
|
662
|
+
return n.props = i, n;
|
|
663
|
+
}) : e;
|
|
664
|
+
}
|
|
665
|
+
function W(e) {
|
|
666
|
+
if (e !== void 0) try {
|
|
667
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return e;
|
|
668
|
+
let t = e, i = {};
|
|
669
|
+
for (let e of n) Object.hasOwn(t, e) && (i[e] = t[e]);
|
|
670
|
+
if (Object.hasOwn(t, "markdownBreaks") && (i.markdownBreaks = t.markdownBreaks), Object.hasOwn(t, "embedding")) {
|
|
671
|
+
let e = t.embedding;
|
|
672
|
+
i.embedding = e === void 0 ? void 0 : r(e);
|
|
673
|
+
}
|
|
674
|
+
if (Object.hasOwn(t, "sourcePhase") && (i.sourcePhase = t.sourcePhase), Object.hasOwn(t, "strict") && (i.strict = t.strict), Object.hasOwn(t, "limits")) {
|
|
675
|
+
let e = t.limits;
|
|
676
|
+
if (e && typeof e == "object" && !Array.isArray(e)) {
|
|
677
|
+
let t = {};
|
|
678
|
+
for (let n of me) Object.hasOwn(e, n) && (t[n] = e[n]);
|
|
679
|
+
i.limits = t;
|
|
680
|
+
} else i.limits = e;
|
|
681
|
+
}
|
|
682
|
+
return Object.hasOwn(t, "hostComponents") && (i.hostComponents = he(t.hostComponents)), Object.hasOwn(t, "config") && (i.config = a(t.config)), i;
|
|
683
|
+
} catch {
|
|
684
|
+
return e;
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
function ge(e) {
|
|
688
|
+
try {
|
|
689
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return "";
|
|
690
|
+
let t = e.limits;
|
|
691
|
+
if (!t || typeof t != "object" || Array.isArray(t)) return "";
|
|
692
|
+
let n = (e) => {
|
|
693
|
+
let n = t;
|
|
694
|
+
if (!Object.hasOwn(n, e) || n[e] === void 0) return "-";
|
|
695
|
+
let r = n[e];
|
|
696
|
+
return `${typeof r}:${String(r)}`;
|
|
697
|
+
};
|
|
698
|
+
return `:${n("maxParseWork")}:${n("maxMarkdownDepth")}:${n("maxRawBodyChars")}`;
|
|
699
|
+
} catch {
|
|
700
|
+
return ":unreadable";
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
function _e(e) {
|
|
704
|
+
let t = o(e);
|
|
705
|
+
if (t !== "invalid") return t;
|
|
706
|
+
try {
|
|
707
|
+
return `invalid:${JSON.stringify(e)}`;
|
|
708
|
+
} catch {
|
|
709
|
+
return "invalid";
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
function G(e) {
|
|
713
|
+
return `${_e(e)}${ge(e)}`;
|
|
714
|
+
}
|
|
715
|
+
function ve(e, t, n, r, i) {
|
|
716
|
+
let a = e;
|
|
717
|
+
return typeof a.compileShared == "function" ? a.compileShared(t, n, r, i) : e.compile(t, n, r);
|
|
718
|
+
}
|
|
719
|
+
function ye(e) {
|
|
720
|
+
return e === "streaming" || e === "final";
|
|
721
|
+
}
|
|
722
|
+
function K(e) {
|
|
723
|
+
return e.stats;
|
|
724
|
+
}
|
|
725
|
+
function q(e, t, n, r) {
|
|
726
|
+
try {
|
|
727
|
+
e.postMessage({
|
|
728
|
+
id: t,
|
|
729
|
+
...r?.traceId === void 0 ? {} : {
|
|
730
|
+
traceId: r.traceId,
|
|
731
|
+
requestId: r.requestId,
|
|
732
|
+
sourceRevision: r.sourceRevision
|
|
733
|
+
},
|
|
734
|
+
...r?.documentId === void 0 ? {} : {
|
|
735
|
+
documentId: r.documentId,
|
|
736
|
+
revision: r.revision
|
|
737
|
+
},
|
|
738
|
+
ok: !1,
|
|
739
|
+
message: n
|
|
740
|
+
});
|
|
741
|
+
} catch {}
|
|
742
|
+
}
|
|
743
|
+
function be(e, t, n, r, i) {
|
|
744
|
+
try {
|
|
745
|
+
e.postMessage({
|
|
746
|
+
id: t.id,
|
|
747
|
+
...t.traceId === void 0 ? {} : {
|
|
748
|
+
traceId: t.traceId,
|
|
749
|
+
requestId: t.requestId,
|
|
750
|
+
sourceRevision: t.sourceRevision
|
|
751
|
+
},
|
|
752
|
+
ok: !1,
|
|
753
|
+
message: n,
|
|
754
|
+
retryFull: !0,
|
|
755
|
+
code: r,
|
|
756
|
+
...t.documentId === void 0 ? i === void 0 ? {} : { revision: i } : {
|
|
757
|
+
documentId: t.documentId,
|
|
758
|
+
revision: t.revision
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
} catch {}
|
|
762
|
+
}
|
|
763
|
+
function xe(e) {
|
|
764
|
+
return !!e && typeof e == "object" && (e.control === "dispose" || e.control === "cancel-preparation");
|
|
765
|
+
}
|
|
766
|
+
function J(e) {
|
|
767
|
+
if (!e || typeof e != "object") return !1;
|
|
768
|
+
let t = e;
|
|
769
|
+
return typeof t.from == "number" && Number.isSafeInteger(t.from) && typeof t.to == "number" && Number.isSafeInteger(t.to) && t.from >= 0 && t.to >= t.from && typeof t.insert == "string";
|
|
770
|
+
}
|
|
771
|
+
function Se(e, t = {}) {
|
|
772
|
+
let n = e === void 0 ? globalThis : e;
|
|
773
|
+
if (!n || typeof n.postMessage != "function") throw TypeError("startLocalCompileWorker requires a worker scope with postMessage");
|
|
774
|
+
let r = /* @__PURE__ */ new Map(), i = t.maxDocuments ?? 8;
|
|
775
|
+
if (!Number.isSafeInteger(i) || i < 1) throw RangeError("Invalid worker document limit");
|
|
776
|
+
let a = !1, o = s();
|
|
777
|
+
function s() {
|
|
778
|
+
let e = {
|
|
779
|
+
onmessage: null,
|
|
780
|
+
postMessage: (e) => n.postMessage(e)
|
|
781
|
+
};
|
|
782
|
+
return {
|
|
783
|
+
scope: e,
|
|
784
|
+
control: Ce(e, t)
|
|
785
|
+
};
|
|
786
|
+
}
|
|
787
|
+
function c() {
|
|
788
|
+
o.control.cancelPreparation();
|
|
789
|
+
for (let e of r.values()) e.control.cancelPreparation();
|
|
790
|
+
}
|
|
791
|
+
function l() {
|
|
792
|
+
if (!a) {
|
|
793
|
+
a = !0, n.onmessage = null, o.control.dispose();
|
|
794
|
+
for (let e of r.values()) e.control.dispose();
|
|
795
|
+
r.clear();
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
return n.onmessage = (e) => {
|
|
799
|
+
if (a) return;
|
|
800
|
+
let t = e?.data;
|
|
801
|
+
if (xe(t)) {
|
|
802
|
+
t.control === "dispose" ? l() : c();
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
if (typeof t?.documentId != "string") {
|
|
806
|
+
o.scope.onmessage?.(e);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
let { documentId: u, revision: d } = t;
|
|
810
|
+
if (u.length > 256 || d !== void 0 && (!Number.isSafeInteger(d) || d < 0)) {
|
|
811
|
+
q(n, t.id, "Invalid worker document or revision", t);
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
let f = r.get(u);
|
|
815
|
+
if (!f) {
|
|
816
|
+
if (typeof t.source != "string") {
|
|
817
|
+
be(n, t, "The document baseline is unavailable", "stale-base", d);
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
f = s();
|
|
821
|
+
}
|
|
822
|
+
if (r.delete(u), r.set(u, f), r.size > i) {
|
|
823
|
+
let e = r.keys().next().value;
|
|
824
|
+
r.get(e)?.control.dispose(), r.delete(e);
|
|
825
|
+
}
|
|
826
|
+
f.scope.onmessage?.(e);
|
|
827
|
+
}, {
|
|
828
|
+
dispose: l,
|
|
829
|
+
cancelPreparation: c,
|
|
830
|
+
get disposed() {
|
|
831
|
+
return a;
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
}
|
|
835
|
+
function Ce(e, t) {
|
|
836
|
+
let n = t.createSession ? t.createSession() : d(), r = n, i = t.preparationDelay, a = typeof i == "number" && Number.isFinite(i) ? Math.max(0, i) : 200, o = typeof r.prepareAsync == "function", s = null, c = 0, l = !1, u = null, f = null, m = 0, h, g = () => {
|
|
837
|
+
m += 1, f !== null && (f.aborted = !0, f = null), u !== null && (clearTimeout(u), u = null);
|
|
838
|
+
}, _ = () => new Promise((e) => {
|
|
839
|
+
typeof setTimeout == "function" ? setTimeout(e, 0) : e();
|
|
840
|
+
}), v = async (e) => {
|
|
841
|
+
if (l || e !== m) return;
|
|
842
|
+
let t = r.prepareAsync;
|
|
843
|
+
if (typeof t != "function") return;
|
|
844
|
+
let n = { aborted: !1 };
|
|
845
|
+
f = n;
|
|
846
|
+
let i = B(), a = !1;
|
|
847
|
+
try {
|
|
848
|
+
a = await t.call(r, n, _);
|
|
849
|
+
} catch {} finally {
|
|
850
|
+
f === n && (f = null), a && !n.aborted && !l && e === m && (h = V(B() - i));
|
|
851
|
+
}
|
|
852
|
+
}, y = () => {
|
|
853
|
+
if (l || !o) return;
|
|
854
|
+
g();
|
|
855
|
+
let e = m;
|
|
856
|
+
u = setTimeout(() => {
|
|
857
|
+
u = null, v(e);
|
|
858
|
+
}, a);
|
|
859
|
+
}, b = () => {
|
|
860
|
+
if (!l) {
|
|
861
|
+
l = !0, g();
|
|
862
|
+
try {
|
|
863
|
+
n.dispose();
|
|
864
|
+
} catch {}
|
|
865
|
+
e.onmessage = null;
|
|
866
|
+
}
|
|
867
|
+
}, x = (e) => ({
|
|
868
|
+
compileMs: e,
|
|
869
|
+
...H(K(n)),
|
|
870
|
+
...h === void 0 ? {} : { preparationMs: h }
|
|
871
|
+
}), S = (e) => {
|
|
872
|
+
let t = typeof e == "number" && Number.isSafeInteger(e) && e > 0 ? e : null;
|
|
873
|
+
return t === null ? c + 1 : t > c ? t : c + 1;
|
|
874
|
+
}, C = (t, r, i, a, o = !1, c) => {
|
|
875
|
+
let { id: l, traceId: u, requestId: d, sourceRevision: f } = t, m = s;
|
|
876
|
+
if (m === null) return !1;
|
|
877
|
+
let h = V(i), g = c === void 0 ? x(h) : {
|
|
878
|
+
...x(h),
|
|
879
|
+
...c
|
|
880
|
+
};
|
|
881
|
+
try {
|
|
882
|
+
let i = a ? {
|
|
883
|
+
id: l,
|
|
884
|
+
...m.documentId === void 0 ? {} : { documentId: m.documentId },
|
|
885
|
+
...u === void 0 ? {} : {
|
|
886
|
+
traceId: u,
|
|
887
|
+
requestId: d,
|
|
888
|
+
sourceRevision: f
|
|
889
|
+
},
|
|
890
|
+
ok: !0,
|
|
891
|
+
result: m.result,
|
|
892
|
+
duration: h,
|
|
893
|
+
incremental: K(n),
|
|
894
|
+
...m.sourcePhase === void 0 ? {} : { sourcePhase: m.sourcePhase },
|
|
895
|
+
protocol: p,
|
|
896
|
+
revision: r,
|
|
897
|
+
metrics: g
|
|
898
|
+
} : {
|
|
899
|
+
id: l,
|
|
900
|
+
...m.documentId === void 0 ? {} : {
|
|
901
|
+
documentId: m.documentId,
|
|
902
|
+
revision: t.revision,
|
|
903
|
+
metrics: g
|
|
904
|
+
},
|
|
905
|
+
...u === void 0 ? {} : {
|
|
906
|
+
traceId: u,
|
|
907
|
+
requestId: d,
|
|
908
|
+
sourceRevision: f
|
|
909
|
+
},
|
|
910
|
+
ok: !0,
|
|
911
|
+
result: m.result,
|
|
912
|
+
duration: h,
|
|
913
|
+
incremental: K(n),
|
|
914
|
+
...m.sourcePhase === void 0 ? {} : { sourcePhase: m.sourcePhase }
|
|
915
|
+
};
|
|
916
|
+
if (o && i.ok) {
|
|
917
|
+
let e = B();
|
|
918
|
+
i.analysis = U(m.source, m.options, m.result), i.metrics = {
|
|
919
|
+
...i.metrics,
|
|
920
|
+
analysisMs: V(B() - e)
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
if (m.deep && m.flatResults && i.ok) {
|
|
924
|
+
let { result: t, ...n } = i, r = {
|
|
925
|
+
...n,
|
|
926
|
+
flatResult: de(t)
|
|
927
|
+
};
|
|
928
|
+
e.postMessage(r);
|
|
929
|
+
} else e.postMessage(i);
|
|
930
|
+
return !0;
|
|
931
|
+
} catch (n) {
|
|
932
|
+
return q(e, l, `Could not return the compile result: ${z(n)}`, t), !1;
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
return e.onmessage = (t) => {
|
|
936
|
+
let r = t?.data;
|
|
937
|
+
if (xe(r)) {
|
|
938
|
+
r.control === "dispose" ? b() : g();
|
|
939
|
+
return;
|
|
940
|
+
}
|
|
941
|
+
if (!r || typeof r.id != "number") return;
|
|
942
|
+
if (typeof r.source == "string") {
|
|
943
|
+
let t = r, i = W(t.options), a = t.sourcePhase === void 0 ? i?.sourcePhase : t.sourcePhase;
|
|
944
|
+
if (a !== void 0 && !ye(a)) {
|
|
945
|
+
q(e, t.id, "The requested source phase is not supported: expected \"streaming\" or \"final\"", t);
|
|
946
|
+
return;
|
|
947
|
+
}
|
|
948
|
+
let o = a;
|
|
949
|
+
g();
|
|
950
|
+
let l = G(i), u = t.protocol === p, d = t.documentId === void 0 ? S(t.revision) : t.revision, f = B();
|
|
951
|
+
try {
|
|
952
|
+
if (s !== null && (s.optionsKey !== l || s.documentId !== t.documentId)) try {
|
|
953
|
+
n.clear();
|
|
954
|
+
} catch {}
|
|
955
|
+
let e = ve(n, t.source, i, o, t.collectPerformance === !0), r = V(B() - f);
|
|
956
|
+
c = d, s = {
|
|
957
|
+
source: t.source,
|
|
958
|
+
documentId: t.documentId,
|
|
959
|
+
revision: d,
|
|
960
|
+
options: i,
|
|
961
|
+
optionsKey: l,
|
|
962
|
+
result: e,
|
|
963
|
+
deep: L(e),
|
|
964
|
+
flatResults: t.flatResults === I,
|
|
965
|
+
...o === void 0 ? {} : { sourcePhase: o }
|
|
966
|
+
}, C(t, d, r, u, t.includeAuthorAnalysis === !0) && y();
|
|
967
|
+
} catch (n) {
|
|
968
|
+
q(e, t.id, z(n), t);
|
|
969
|
+
}
|
|
970
|
+
return;
|
|
971
|
+
}
|
|
972
|
+
if (r.protocol !== "patch-v1") return;
|
|
973
|
+
g();
|
|
974
|
+
let i = r, a = s, o = (t, n) => {
|
|
975
|
+
be(e, i, t, n, a?.revision);
|
|
976
|
+
};
|
|
977
|
+
if (a === null) {
|
|
978
|
+
o("No complete compile is available to patch", "stale-base");
|
|
979
|
+
return;
|
|
980
|
+
}
|
|
981
|
+
if ((a.sourcePhase ?? "final") !== "final") {
|
|
982
|
+
o("The baseline was compiled from a streaming snapshot", "phase-mismatch");
|
|
983
|
+
return;
|
|
984
|
+
}
|
|
985
|
+
if (typeof i.baseRevision != "number" || i.baseRevision !== a.revision) {
|
|
986
|
+
o("The requested base revision is not current", "stale-base");
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
if (i.optionsKey !== void 0 && i.optionsKey !== a.optionsKey) {
|
|
990
|
+
o("The options signature changed since the baseline", "options-mismatch");
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
if (!J(i.edit)) {
|
|
994
|
+
o("The source edit is invalid", "invalid-edit");
|
|
995
|
+
return;
|
|
996
|
+
}
|
|
997
|
+
let l = i.edit;
|
|
998
|
+
if (l.to > a.source.length) {
|
|
999
|
+
o("The source edit does not fit the baseline", "invalid-edit");
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
let u = a.source.slice(0, l.from) + l.insert + a.source.slice(l.to);
|
|
1003
|
+
if (typeof i.targetLength == "number" && u.length !== i.targetLength) {
|
|
1004
|
+
o("The source edit produced an unexpected length", "invalid-edit");
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
let d = i.documentId === void 0 ? S(i.revision) : i.revision;
|
|
1008
|
+
if (d <= a.revision) {
|
|
1009
|
+
o("The new revision must follow its baseline", "stale-base");
|
|
1010
|
+
return;
|
|
1011
|
+
}
|
|
1012
|
+
let f = B();
|
|
1013
|
+
try {
|
|
1014
|
+
let t = ve(n, u, a.options, a.sourcePhase, i.collectPerformance === !0), r = V(B() - f), o = a.revision, l = a.result;
|
|
1015
|
+
c = d, s = {
|
|
1016
|
+
documentId: a.documentId,
|
|
1017
|
+
source: u,
|
|
1018
|
+
revision: d,
|
|
1019
|
+
options: a.options,
|
|
1020
|
+
optionsKey: a.optionsKey,
|
|
1021
|
+
result: t,
|
|
1022
|
+
deep: L(t),
|
|
1023
|
+
flatResults: a.flatResults,
|
|
1024
|
+
...a.sourcePhase === void 0 ? {} : { sourcePhase: a.sourcePhase }
|
|
1025
|
+
};
|
|
1026
|
+
let m = null, g = 0;
|
|
1027
|
+
if (t.ok && l.ok && !s.deep && !a.deep) {
|
|
1028
|
+
let e = B();
|
|
1029
|
+
m = se(l, t), g = V(B() - e);
|
|
1030
|
+
}
|
|
1031
|
+
let _ = m?.patch ?? null;
|
|
1032
|
+
if (_ === null) {
|
|
1033
|
+
C(i, d, r, !0, i.includeAuthorAnalysis === !0) && y();
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
if (m !== null && m.cost.preferFull) {
|
|
1037
|
+
let e = m.cost, t = {
|
|
1038
|
+
patchEncodeMs: g,
|
|
1039
|
+
patchFallback: "cost",
|
|
1040
|
+
patchBytes: e.patchBytes,
|
|
1041
|
+
...e.fullBytes === void 0 ? {} : { fullBytes: e.fullBytes }
|
|
1042
|
+
};
|
|
1043
|
+
C(i, d, r, !0, i.includeAuthorAnalysis === !0, t) && y();
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
let v = {
|
|
1047
|
+
...x(r),
|
|
1048
|
+
patchEncodeMs: g,
|
|
1049
|
+
patchNodes: _.document.nodes?.length ?? 0,
|
|
1050
|
+
...h === void 0 ? {} : { preparationMs: h }
|
|
1051
|
+
};
|
|
1052
|
+
try {
|
|
1053
|
+
let s = {
|
|
1054
|
+
id: i.id,
|
|
1055
|
+
...a.documentId === void 0 ? {} : { documentId: a.documentId },
|
|
1056
|
+
...i.traceId === void 0 ? {} : {
|
|
1057
|
+
traceId: i.traceId,
|
|
1058
|
+
requestId: i.requestId,
|
|
1059
|
+
sourceRevision: i.sourceRevision
|
|
1060
|
+
},
|
|
1061
|
+
ok: !0,
|
|
1062
|
+
protocol: p,
|
|
1063
|
+
baseRevision: o,
|
|
1064
|
+
revision: d,
|
|
1065
|
+
patch: _,
|
|
1066
|
+
duration: r,
|
|
1067
|
+
incremental: K(n),
|
|
1068
|
+
...a.sourcePhase === void 0 ? {} : { sourcePhase: a.sourcePhase },
|
|
1069
|
+
metrics: v
|
|
1070
|
+
};
|
|
1071
|
+
if (i.includeAuthorAnalysis === !0) {
|
|
1072
|
+
let e = B();
|
|
1073
|
+
s.analysis = U(u, a.options, t), v.analysisMs = V(B() - e);
|
|
1074
|
+
}
|
|
1075
|
+
e.postMessage(s), y();
|
|
1076
|
+
} catch (t) {
|
|
1077
|
+
q(e, i.id, `Could not return the compile result: ${z(t)}`, i);
|
|
1078
|
+
}
|
|
1079
|
+
} catch (t) {
|
|
1080
|
+
q(e, i.id, z(t), i);
|
|
1081
|
+
}
|
|
1082
|
+
}, {
|
|
1083
|
+
dispose: b,
|
|
1084
|
+
cancelPreparation: g,
|
|
1085
|
+
get disposed() {
|
|
1086
|
+
return l;
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
}
|
|
1090
|
+
// src/local/transport/worker.ts
|
|
1091
|
+
function we(e, t) {
|
|
1092
|
+
if (!e || typeof e != "object") return !1;
|
|
1093
|
+
let n = e, r = (e) => e && Number.isSafeInteger(e.start) && Number.isSafeInteger(e.end) && e.start >= 0 && e.end >= e.start && e.end <= t;
|
|
1094
|
+
if (!Array.isArray(n.tokens) || n.tokens.length > t + 1 || !Array.isArray(n.bindings) || n.bindings.length > t + 1 || !Array.isArray(n.diagnostics)) return !1;
|
|
1095
|
+
let i = 0, a = 0;
|
|
1096
|
+
for (let e of n.tokens) {
|
|
1097
|
+
if (!e || typeof e.kind != "string" || !r(e.range) || e.range.start < i) return !1;
|
|
1098
|
+
i = e.range.end;
|
|
1099
|
+
}
|
|
1100
|
+
for (let e of n.bindings) if (!e || typeof e.name != "string" || !Array.isArray(e.declarations) || !Array.isArray(e.references) || (a += e.declarations.length + e.references.length, a > t + 1 || !e.declarations.every(r) || !e.references.every(r))) return !1;
|
|
1101
|
+
return !0;
|
|
1102
|
+
}
|
|
1103
|
+
function Te(e, t, n) {
|
|
1104
|
+
let r = W(t), i = n === void 0 ? Ee(t) : n, a = i === "streaming" || i === "final" ? i : void 0, o = i !== void 0 && a === void 0 ? i : void 0;
|
|
1105
|
+
return {
|
|
1106
|
+
source: e,
|
|
1107
|
+
options: r,
|
|
1108
|
+
optionsKey: G(r),
|
|
1109
|
+
scheduledAt: B(),
|
|
1110
|
+
sourcePhase: a === "streaming" ? "streaming" : "final",
|
|
1111
|
+
explicitPhase: i !== void 0,
|
|
1112
|
+
...o === void 0 ? {} : { invalidPhase: o }
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
function Ee(e) {
|
|
1116
|
+
try {
|
|
1117
|
+
return !e || typeof e != "object" || Array.isArray(e) ? void 0 : e.sourcePhase;
|
|
1118
|
+
} catch {
|
|
1119
|
+
return;
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
function Y(e, t) {
|
|
1123
|
+
return e.source === t.source && e.optionsKey === t.optionsKey && e.sourcePhase === t.sourcePhase && e.explicitPhase === t.explicitPhase && e.invalidPhase === t.invalidPhase;
|
|
1124
|
+
}
|
|
1125
|
+
function X(e) {
|
|
1126
|
+
return e.sourcePhase === "streaming" || e.explicitPhase ? { sourcePhase: e.sourcePhase } : {};
|
|
1127
|
+
}
|
|
1128
|
+
function Z(e, t) {
|
|
1129
|
+
return e.explicitPhase ? {
|
|
1130
|
+
ok: !1,
|
|
1131
|
+
diagnostics: [t],
|
|
1132
|
+
status: "failed"
|
|
1133
|
+
} : {
|
|
1134
|
+
ok: !1,
|
|
1135
|
+
diagnostics: [t]
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
function De() {
|
|
1139
|
+
return {
|
|
1140
|
+
ok: !1,
|
|
1141
|
+
status: "failed",
|
|
1142
|
+
diagnostics: [{
|
|
1143
|
+
code: "local.options.invalid",
|
|
1144
|
+
message: "Compile option sourcePhase must be \"streaming\" or \"final\".",
|
|
1145
|
+
severity: "error",
|
|
1146
|
+
range: {
|
|
1147
|
+
start: 0,
|
|
1148
|
+
end: 0
|
|
1149
|
+
},
|
|
1150
|
+
line: 1,
|
|
1151
|
+
column: 1,
|
|
1152
|
+
messageKey: "local.options.invalid.source-phase",
|
|
1153
|
+
phase: "host",
|
|
1154
|
+
recoverable: !1
|
|
1155
|
+
}]
|
|
1156
|
+
};
|
|
1157
|
+
}
|
|
1158
|
+
function Q(e) {
|
|
1159
|
+
if (!e || typeof e != "object") return !1;
|
|
1160
|
+
let t = e;
|
|
1161
|
+
return !(typeof t.ok != "boolean" || !Array.isArray(t.diagnostics) || t.ok && (!t.document || typeof t.document != "object"));
|
|
1162
|
+
}
|
|
1163
|
+
function Oe(e) {
|
|
1164
|
+
return e.ok && "patch" in e && e.patch !== void 0;
|
|
1165
|
+
}
|
|
1166
|
+
var ke = 160;
|
|
1167
|
+
function Ae(t) {
|
|
1168
|
+
let n = z(t).trim();
|
|
1169
|
+
return n.length === 0 ? "" : n.length > ke ? `${e(n, 159)}…` : n;
|
|
1170
|
+
}
|
|
1171
|
+
function $(e) {
|
|
1172
|
+
let t = Ae(e);
|
|
1173
|
+
return {
|
|
1174
|
+
code: "local.worker.compile",
|
|
1175
|
+
messageKey: t ? "local.worker.compile.detail" : "local.worker.compile",
|
|
1176
|
+
...t ? { params: { detail: t } } : {},
|
|
1177
|
+
phase: "worker",
|
|
1178
|
+
recoverable: !1,
|
|
1179
|
+
message: t ? `Compilation failed: ${t}` : "Compilation failed",
|
|
1180
|
+
severity: "error",
|
|
1181
|
+
range: {
|
|
1182
|
+
start: 0,
|
|
1183
|
+
end: 0
|
|
1184
|
+
},
|
|
1185
|
+
line: 1,
|
|
1186
|
+
column: 1
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
var je = class {
|
|
1190
|
+
options;
|
|
1191
|
+
delay;
|
|
1192
|
+
worker = null;
|
|
1193
|
+
timer = null;
|
|
1194
|
+
queued = null;
|
|
1195
|
+
inFlight = null;
|
|
1196
|
+
nextId = 1;
|
|
1197
|
+
nextRevision = 1;
|
|
1198
|
+
nextSourceRevision = 1;
|
|
1199
|
+
currentSourceRevision = 0;
|
|
1200
|
+
pending = !1;
|
|
1201
|
+
fallbackSession = null;
|
|
1202
|
+
disposed = !1;
|
|
1203
|
+
timeout = null;
|
|
1204
|
+
requestContexts = /* @__PURE__ */ new Map();
|
|
1205
|
+
obsoleteRequestIds = /* @__PURE__ */ new Set();
|
|
1206
|
+
reportedStaleRequestIds = /* @__PURE__ */ new Set();
|
|
1207
|
+
baseline = null;
|
|
1208
|
+
patchState = "unknown";
|
|
1209
|
+
startupFailure = null;
|
|
1210
|
+
constructor(e) {
|
|
1211
|
+
this.options = e;
|
|
1212
|
+
let t = e.delay;
|
|
1213
|
+
this.delay = typeof t == "number" && Number.isFinite(t) ? Math.max(0, t) : 150;
|
|
1214
|
+
try {
|
|
1215
|
+
let t = e.createWorker();
|
|
1216
|
+
t.onmessage = (e) => this.receive(e.data), t.onerror = (e) => {
|
|
1217
|
+
let t = e && typeof e.message == "string" ? String(e.message) : "";
|
|
1218
|
+
this.handleWorkerFailure(t || "The compile worker encountered an error");
|
|
1219
|
+
}, t.onmessageerror = () => this.handleWorkerFailure("The compile worker could not deliver the compile result"), this.worker = t;
|
|
1220
|
+
} catch (t) {
|
|
1221
|
+
this.worker = null, this.startupFailure = Ae(t), e.onModeChange?.("fallback", `Could not start the compile worker: ${z(t)}`);
|
|
1222
|
+
}
|
|
1223
|
+
}
|
|
1224
|
+
schedule(e, t, n, r) {
|
|
1225
|
+
if (this.disposed) return;
|
|
1226
|
+
let i = {
|
|
1227
|
+
...Te(e, t, r),
|
|
1228
|
+
sourceRevision: this.nextSourceRevision++,
|
|
1229
|
+
traceId: l()
|
|
1230
|
+
};
|
|
1231
|
+
this.currentSourceRevision = i.sourceRevision, this.inFlight && !Y(this.inFlight.job, i) && this.obsoleteRequestIds.add(this.inFlight.id), this.queued = i, n && typeof n.baseSource == "string" && J(n.edit) && n.edit.to <= n.baseSource.length && n.baseSource.slice(0, n.edit.from) + n.edit.insert + n.baseSource.slice(n.edit.to) === e && (this.queued.editHint = {
|
|
1232
|
+
baseSource: n.baseSource,
|
|
1233
|
+
edit: { ...n.edit }
|
|
1234
|
+
}), this.clearTimer(), i.sourcePhase === "streaming" && (this.baseline = null), this.setPending(!0), i.sourcePhase === "streaming" || !i.explicitPhase ? this.timer = setTimeout(() => {
|
|
1235
|
+
this.timer = null, this.drain();
|
|
1236
|
+
}, this.delay) : this.drain();
|
|
1237
|
+
}
|
|
1238
|
+
dispose() {
|
|
1239
|
+
if (this.disposed) return;
|
|
1240
|
+
this.disposed = !0, this.inFlight && (this.traceWorker(this.inFlight, "worker-cancel", { status: "disposed" }), this.obsoleteRequestIds.add(this.inFlight.id)), this.timeout !== null && clearTimeout(this.timeout), this.timeout = null, this.clearTimer(), this.queued = null, this.inFlight = null, this.resetProtocol();
|
|
1241
|
+
let e = this.worker;
|
|
1242
|
+
if (this.worker = null, e) {
|
|
1243
|
+
e.onmessage = null, e.onerror = null, e.onmessageerror = null;
|
|
1244
|
+
try {
|
|
1245
|
+
e.terminate();
|
|
1246
|
+
} catch {}
|
|
1247
|
+
}
|
|
1248
|
+
this.pending = !1, this.fallbackSession?.dispose(), this.fallbackSession = null;
|
|
1249
|
+
}
|
|
1250
|
+
drain() {
|
|
1251
|
+
if (this.disposed || this.timer !== null || this.inFlight !== null) return;
|
|
1252
|
+
let e = this.queued;
|
|
1253
|
+
e === null ? this.setPending(!1) : (this.queued = null, this.compile(e));
|
|
1254
|
+
}
|
|
1255
|
+
compile(e) {
|
|
1256
|
+
if (e.invalidPhase !== void 0) {
|
|
1257
|
+
this.deliver(e, {
|
|
1258
|
+
source: e.source,
|
|
1259
|
+
result: De(),
|
|
1260
|
+
duration: 0,
|
|
1261
|
+
mode: this.worker === null ? "fallback" : "worker",
|
|
1262
|
+
...e.options === void 0 ? {} : { options: e.options },
|
|
1263
|
+
metrics: { queueMs: V(B() - e.scheduledAt) }
|
|
1264
|
+
}), this.finishRun();
|
|
1265
|
+
return;
|
|
1266
|
+
}
|
|
1267
|
+
let t = this.worker;
|
|
1268
|
+
if (!t) {
|
|
1269
|
+
this.compileFallback(e);
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
e.sourcePhase === "streaming" && (this.baseline = null);
|
|
1273
|
+
let n = this.nextId++, r = this.nextRevision++, { traceId: i, sourceRevision: a } = e, o = B(), s = this.baseline, c = e.sourcePhase === "final" && this.patchState === "enabled" && s !== null && s.optionsKey === e.optionsKey, l = this.options.observer?.onTrace ? { collectPerformance: !0 } : void 0, u = c ? {
|
|
1274
|
+
traceId: i,
|
|
1275
|
+
requestId: n,
|
|
1276
|
+
sourceRevision: a,
|
|
1277
|
+
...l,
|
|
1278
|
+
id: n,
|
|
1279
|
+
protocol: p,
|
|
1280
|
+
baseRevision: s.revision,
|
|
1281
|
+
revision: r,
|
|
1282
|
+
edit: e.editHint?.baseSource === s.source ? e.editHint.edit : S(s.source, e.source) ?? {
|
|
1283
|
+
from: 0,
|
|
1284
|
+
to: 0,
|
|
1285
|
+
insert: ""
|
|
1286
|
+
},
|
|
1287
|
+
targetLength: e.source.length,
|
|
1288
|
+
optionsKey: e.optionsKey
|
|
1289
|
+
} : {
|
|
1290
|
+
traceId: i,
|
|
1291
|
+
requestId: n,
|
|
1292
|
+
sourceRevision: a,
|
|
1293
|
+
...l,
|
|
1294
|
+
id: n,
|
|
1295
|
+
source: e.source,
|
|
1296
|
+
...e.options === void 0 ? {} : { options: e.options },
|
|
1297
|
+
protocol: p,
|
|
1298
|
+
revision: r,
|
|
1299
|
+
flatResults: I,
|
|
1300
|
+
...e.sourcePhase === "streaming" || e.explicitPhase ? { sourcePhase: e.sourcePhase } : {}
|
|
1301
|
+
}, d = {
|
|
1302
|
+
id: n,
|
|
1303
|
+
job: e,
|
|
1304
|
+
startedAt: o,
|
|
1305
|
+
revision: r,
|
|
1306
|
+
traceId: i,
|
|
1307
|
+
sourceRevision: a
|
|
1308
|
+
};
|
|
1309
|
+
this.inFlight = d;
|
|
1310
|
+
let m = this.options.timeoutMs, h = typeof m == "number" && Number.isFinite(m) && m > 0 ? Math.min(2147483647, Math.ceil(m)) : 3e4;
|
|
1311
|
+
for (this.requestContexts.set(n, {
|
|
1312
|
+
traceId: i,
|
|
1313
|
+
sourceRevision: a
|
|
1314
|
+
}); this.requestContexts.size > 128;) {
|
|
1315
|
+
let e = this.requestContexts.keys().next().value;
|
|
1316
|
+
if (e === void 0) break;
|
|
1317
|
+
this.requestContexts.delete(e), this.obsoleteRequestIds.delete(e), this.reportedStaleRequestIds.delete(e);
|
|
1318
|
+
}
|
|
1319
|
+
if (this.timeout = setTimeout(() => {
|
|
1320
|
+
if (this.inFlight?.id !== n) return;
|
|
1321
|
+
let e = {
|
|
1322
|
+
...f("local.worker.timeout", {
|
|
1323
|
+
timeoutMs: h,
|
|
1324
|
+
requestId: n,
|
|
1325
|
+
sourceRevision: a
|
|
1326
|
+
}),
|
|
1327
|
+
phase: "worker"
|
|
1328
|
+
};
|
|
1329
|
+
this.obsoleteRequestIds.add(n), this.handleWorkerFailure(e.message, e);
|
|
1330
|
+
}, h), this.traceWorker(d, "worker-request"), !(this.disposed || this.inFlight !== d)) {
|
|
1331
|
+
this.options.includeAuthorAnalysis && (u.includeAuthorAnalysis = !0);
|
|
1332
|
+
try {
|
|
1333
|
+
t.postMessage(u);
|
|
1334
|
+
} catch (e) {
|
|
1335
|
+
this.obsoleteRequestIds.add(n), this.handleWorkerFailure(`Could not send the source to the compile worker: ${z(e)}`);
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
compileFallback(e, t) {
|
|
1340
|
+
if (this.disposed) return;
|
|
1341
|
+
e.sourcePhase === "streaming" && (this.baseline = null);
|
|
1342
|
+
let n = B(), { traceId: r, sourceRevision: a } = e;
|
|
1343
|
+
if (!this.isCurrentJob(e) || (c(this.options.observer, {
|
|
1344
|
+
type: "compile-start",
|
|
1345
|
+
...t === void 0 ? {} : { requestId: t },
|
|
1346
|
+
traceId: r,
|
|
1347
|
+
sourceRevision: a,
|
|
1348
|
+
timestamp: Date.now(),
|
|
1349
|
+
status: "fallback"
|
|
1350
|
+
}), !this.isCurrentJob(e))) {
|
|
1351
|
+
this.finishRun();
|
|
1352
|
+
return;
|
|
1353
|
+
}
|
|
1354
|
+
let o;
|
|
1355
|
+
try {
|
|
1356
|
+
let t = this.options.fallbackCompile ?? ((e, t, n) => (this.fallbackSession ??= d(), this.fallbackSession.compile(e, t, n)));
|
|
1357
|
+
o = e.explicitPhase ? t(e.source, e.options, e.sourcePhase) : e.options === void 0 ? t(e.source) : t(e.source, e.options);
|
|
1358
|
+
} catch (t) {
|
|
1359
|
+
o = Z(e, $(t));
|
|
1360
|
+
}
|
|
1361
|
+
let s = V(B() - n);
|
|
1362
|
+
if (!this.isCurrentJob(e)) this.finishRun();
|
|
1363
|
+
else {
|
|
1364
|
+
if (this.startupFailure !== null) {
|
|
1365
|
+
let n = this.startupFailure;
|
|
1366
|
+
if (this.startupFailure = null, c(this.options.observer, {
|
|
1367
|
+
type: "worker-error",
|
|
1368
|
+
...t === void 0 ? {} : { requestId: t },
|
|
1369
|
+
traceId: r,
|
|
1370
|
+
sourceRevision: a,
|
|
1371
|
+
timestamp: Date.now(),
|
|
1372
|
+
status: "failed",
|
|
1373
|
+
code: "local.worker.startup",
|
|
1374
|
+
...n ? { detail: n } : {}
|
|
1375
|
+
}), !this.isCurrentJob(e)) {
|
|
1376
|
+
this.finishRun();
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1380
|
+
c(this.options.observer, {
|
|
1381
|
+
type: "compile-end",
|
|
1382
|
+
...t === void 0 ? {} : { requestId: t },
|
|
1383
|
+
traceId: r,
|
|
1384
|
+
sourceRevision: a,
|
|
1385
|
+
timestamp: Date.now(),
|
|
1386
|
+
durationMs: s,
|
|
1387
|
+
status: i(o)
|
|
1388
|
+
}), this.isCurrentJob(e) && this.deliver(e, {
|
|
1389
|
+
source: e.source,
|
|
1390
|
+
result: o,
|
|
1391
|
+
duration: s,
|
|
1392
|
+
mode: "fallback",
|
|
1393
|
+
...this.options.includeAuthorAnalysis ? { analysis: U(e.source, e.options, o) } : {},
|
|
1394
|
+
...e.options === void 0 ? {} : { options: e.options },
|
|
1395
|
+
...X(e),
|
|
1396
|
+
metrics: { queueMs: V(n - e.scheduledAt) }
|
|
1397
|
+
}), this.finishRun();
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
isCurrentJob(e) {
|
|
1401
|
+
return !this.disposed && e.sourceRevision === this.currentSourceRevision;
|
|
1402
|
+
}
|
|
1403
|
+
receive(e) {
|
|
1404
|
+
if (this.disposed) return;
|
|
1405
|
+
let t = this.inFlight;
|
|
1406
|
+
if (!e) return;
|
|
1407
|
+
if (t && e.id === t.id && (e.requestId !== void 0 && e.requestId !== t.id || e.traceId !== void 0 && e.traceId !== t.traceId || e.sourceRevision !== void 0 && e.sourceRevision !== t.sourceRevision)) {
|
|
1408
|
+
this.reportStale(t.id, t.traceId, t.sourceRevision, this.queued?.sourceRevision), this.handleWorkerFailure("The compile worker returned a response with a mismatched request context.");
|
|
1409
|
+
return;
|
|
1410
|
+
}
|
|
1411
|
+
if (!t || e.id !== t.id) {
|
|
1412
|
+
if (Number.isSafeInteger(e.id) && e.id > 0 && this.obsoleteRequestIds.has(e.id)) {
|
|
1413
|
+
let t = this.requestContexts.get(e.id);
|
|
1414
|
+
t && this.reportStale(e.id, t.traceId, t.sourceRevision, this.queued?.sourceRevision);
|
|
1415
|
+
}
|
|
1416
|
+
return;
|
|
1417
|
+
}
|
|
1418
|
+
this.timeout !== null && clearTimeout(this.timeout), this.timeout = null;
|
|
1419
|
+
let n, r = 0;
|
|
1420
|
+
if (e.ok && "flatResult" in e) {
|
|
1421
|
+
let t = B(), i = R(e.flatResult);
|
|
1422
|
+
r = V(B() - t), n = Q(i) ? {
|
|
1423
|
+
...e,
|
|
1424
|
+
result: i
|
|
1425
|
+
} : {
|
|
1426
|
+
id: e.id,
|
|
1427
|
+
ok: !1,
|
|
1428
|
+
retryFull: !0,
|
|
1429
|
+
message: "Invalid flat compile result"
|
|
1430
|
+
};
|
|
1431
|
+
} else n = e;
|
|
1432
|
+
this.inFlight = null;
|
|
1433
|
+
let a = t.job, o = V(B() - t.startedAt), s = V(t.startedAt - a.scheduledAt), c = null, l = r, u = null, d = "worker", f;
|
|
1434
|
+
if (n.ok) {
|
|
1435
|
+
if (Oe(n)) {
|
|
1436
|
+
let e = B(), t = this.applyResponsePatch(a, n);
|
|
1437
|
+
l = V(B() - e), t !== null && (c = t, f = n.revision);
|
|
1438
|
+
} else {
|
|
1439
|
+
let e = n;
|
|
1440
|
+
Q(e.result) ? (c = e.result, f = typeof e.revision == "number" ? e.revision : void 0, a.sourcePhase === "streaming" || e.sourcePhase === "streaming" ? this.baseline = null : e.protocol === "patch-v1" && typeof e.revision == "number" && Number.isSafeInteger(e.revision) ? (this.patchState = "enabled", this.baseline = e.result.ok ? {
|
|
1441
|
+
source: a.source,
|
|
1442
|
+
optionsKey: a.optionsKey,
|
|
1443
|
+
revision: e.revision,
|
|
1444
|
+
result: e.result
|
|
1445
|
+
} : null) : (this.patchState = "legacy", this.baseline = null)) : u = "The compile worker returned an invalid result";
|
|
1446
|
+
}
|
|
1447
|
+
} else n.retryFull !== !0 && (u = n.message);
|
|
1448
|
+
let p = this.queued, m = p !== null && !Y(p, a);
|
|
1449
|
+
if (this.options.observer?.onTrace) {
|
|
1450
|
+
if (u !== null) this.traceWorker(t, "worker-error", {
|
|
1451
|
+
durationMs: o,
|
|
1452
|
+
queueMs: s,
|
|
1453
|
+
status: "failed",
|
|
1454
|
+
code: "local.worker.compile"
|
|
1455
|
+
});
|
|
1456
|
+
else {
|
|
1457
|
+
let e = n.ok ? n.metrics : void 0;
|
|
1458
|
+
this.traceWorker(t, "worker-response", {
|
|
1459
|
+
durationMs: o,
|
|
1460
|
+
queueMs: s,
|
|
1461
|
+
status: c ? i(c) : "retry",
|
|
1462
|
+
parseMs: e?.parseMs,
|
|
1463
|
+
semanticMs: e?.semanticMs,
|
|
1464
|
+
reuseMs: e?.reuseMs,
|
|
1465
|
+
rebuildMs: e?.rebuildMs,
|
|
1466
|
+
compiledBlocks: e?.compiledBlocks,
|
|
1467
|
+
reusedBlocks: e?.reusedBlocks
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
if (!this.disposed) {
|
|
1472
|
+
if (m && (this.obsoleteRequestIds.add(t.id), this.reportStale(t.id, t.traceId, t.sourceRevision, p.sourceRevision)), p !== null && !m && this.queued === p && (this.queued = null, this.clearTimer(), this.currentSourceRevision = a.sourceRevision), c !== null) m || this.deliver(a, {
|
|
1473
|
+
source: a.source,
|
|
1474
|
+
result: c,
|
|
1475
|
+
duration: V(n.ok ? n.duration : 0),
|
|
1476
|
+
mode: d,
|
|
1477
|
+
...n.ok && this.options.includeAuthorAnalysis && we(n.analysis, a.source.length) ? { analysis: n.analysis } : {},
|
|
1478
|
+
...a.options === void 0 ? {} : { options: a.options },
|
|
1479
|
+
...X(a),
|
|
1480
|
+
metrics: {
|
|
1481
|
+
queueMs: s,
|
|
1482
|
+
roundTripMs: o,
|
|
1483
|
+
...l > 0 ? { applyMs: l } : {},
|
|
1484
|
+
...n.ok && n.metrics ? { worker: n.metrics } : {}
|
|
1485
|
+
},
|
|
1486
|
+
...f === void 0 ? {} : { revision: f }
|
|
1487
|
+
}), this.finishRun();
|
|
1488
|
+
else if (u !== null) m || this.deliver(a, {
|
|
1489
|
+
source: a.source,
|
|
1490
|
+
result: Z(a, $(u)),
|
|
1491
|
+
duration: 0,
|
|
1492
|
+
mode: d,
|
|
1493
|
+
...a.options === void 0 ? {} : { options: a.options },
|
|
1494
|
+
...X(a),
|
|
1495
|
+
metrics: {
|
|
1496
|
+
queueMs: s,
|
|
1497
|
+
roundTripMs: o
|
|
1498
|
+
}
|
|
1499
|
+
}), this.finishRun();
|
|
1500
|
+
else {
|
|
1501
|
+
if (m) this.inFlight === null && this.resetProtocol();
|
|
1502
|
+
else {
|
|
1503
|
+
let e = this.recoverWithFullResult(a);
|
|
1504
|
+
if (e === "dispatched") return;
|
|
1505
|
+
e !== "abandoned" && (this.patchState = "disabled", this.baseline = null, this.deliver(a, {
|
|
1506
|
+
source: a.source,
|
|
1507
|
+
result: Z(a, $("The compile worker could not apply an incremental result patch")),
|
|
1508
|
+
duration: 0,
|
|
1509
|
+
mode: d,
|
|
1510
|
+
...a.options === void 0 ? {} : { options: a.options },
|
|
1511
|
+
...X(a),
|
|
1512
|
+
metrics: {
|
|
1513
|
+
queueMs: s,
|
|
1514
|
+
roundTripMs: o,
|
|
1515
|
+
...l > 0 ? { applyMs: l } : {}
|
|
1516
|
+
}
|
|
1517
|
+
}));
|
|
1518
|
+
}
|
|
1519
|
+
this.finishRun();
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
applyResponsePatch(e, t) {
|
|
1524
|
+
if (e.sourcePhase !== "final") return null;
|
|
1525
|
+
let n = this.baseline;
|
|
1526
|
+
if (n === null || n.optionsKey !== e.optionsKey || !Number.isSafeInteger(t.revision) || t.revision <= n.revision || t.baseRevision !== n.revision || t.protocol !== "patch-v1") return null;
|
|
1527
|
+
let r = F(n.result, t.patch);
|
|
1528
|
+
if (r === null || !r.ok || r.document.source !== e.source) return null;
|
|
1529
|
+
let i;
|
|
1530
|
+
if (e.sourcePhase === "final" && e.explicitPhase) i = r.recoveries === void 0 ? {
|
|
1531
|
+
...r,
|
|
1532
|
+
status: "valid"
|
|
1533
|
+
} : {
|
|
1534
|
+
...r,
|
|
1535
|
+
status: "recovered"
|
|
1536
|
+
};
|
|
1537
|
+
else if (r.ok && r.status !== void 0) {
|
|
1538
|
+
let e = { ...r };
|
|
1539
|
+
delete e.status, i = e;
|
|
1540
|
+
} else i = r;
|
|
1541
|
+
return this.baseline = {
|
|
1542
|
+
source: e.source,
|
|
1543
|
+
optionsKey: e.optionsKey,
|
|
1544
|
+
revision: t.revision,
|
|
1545
|
+
result: i
|
|
1546
|
+
}, i;
|
|
1547
|
+
}
|
|
1548
|
+
recoverWithFullResult(e) {
|
|
1549
|
+
return this.worker === null || (e.recovery ?? 0) >= 1 ? "spent" : this.disposed || this.inFlight !== null || !this.isCurrentJob(e) ? "abandoned" : (this.resetProtocol(), this.compile({
|
|
1550
|
+
...e,
|
|
1551
|
+
recovery: (e.recovery ?? 0) + 1
|
|
1552
|
+
}), "dispatched");
|
|
1553
|
+
}
|
|
1554
|
+
handleWorkerFailure(e, t = {
|
|
1555
|
+
...f("local.worker.error"),
|
|
1556
|
+
recoverable: !0
|
|
1557
|
+
}) {
|
|
1558
|
+
if (this.disposed) return;
|
|
1559
|
+
this.timeout !== null && clearTimeout(this.timeout), this.timeout = null, this.resetProtocol();
|
|
1560
|
+
let n = this.inFlight;
|
|
1561
|
+
this.inFlight = null, n && this.obsoleteRequestIds.add(n.id), this.degrade(e), !this.disposed && (n && this.traceWorker(n, t.code === "local.worker.timeout" ? "worker-timeout" : "worker-error", {
|
|
1562
|
+
code: t.code,
|
|
1563
|
+
durationMs: V(B() - n.startedAt)
|
|
1564
|
+
}), !this.disposed && (s(this.options.observer, t), !this.disposed && (n && (this.queued === null || Y(this.queued, n.job)) && (this.queued !== null && (this.queued = null, this.clearTimer(), this.currentSourceRevision = n.job.sourceRevision), this.compileFallback(n.job, n.id)), this.finishRun())));
|
|
1565
|
+
}
|
|
1566
|
+
degrade(e) {
|
|
1567
|
+
let t = this.worker;
|
|
1568
|
+
if (t) {
|
|
1569
|
+
this.worker = null, t.onmessage = null, t.onerror = null, t.onmessageerror = null;
|
|
1570
|
+
try {
|
|
1571
|
+
t.terminate();
|
|
1572
|
+
} catch {}
|
|
1573
|
+
this.options.onModeChange?.("fallback", e);
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
resetProtocol() {
|
|
1577
|
+
this.baseline = null, this.patchState = "unknown";
|
|
1578
|
+
}
|
|
1579
|
+
finishRun() {
|
|
1580
|
+
this.disposed || (this.drain(), !this.disposed && this.setPending(this.timer !== null || this.inFlight !== null || this.queued !== null));
|
|
1581
|
+
}
|
|
1582
|
+
deliver(e, t) {
|
|
1583
|
+
if (!this.isCurrentJob(e)) return;
|
|
1584
|
+
let n = this.baseline !== null && this.baseline.result === t.result, r = this.options.shareResults === !0 || !n ? t.result : x(t.result);
|
|
1585
|
+
for (let t of [...r.diagnostics, ...r.transientDiagnostics ?? []]) {
|
|
1586
|
+
if (!this.isCurrentJob(e)) return;
|
|
1587
|
+
s(this.options.observer, t);
|
|
1588
|
+
}
|
|
1589
|
+
this.isCurrentJob(e) && this.options.onResult({
|
|
1590
|
+
...t,
|
|
1591
|
+
result: r
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
traceWorker(e, t, n = {}) {
|
|
1595
|
+
this.options.observer?.onTrace && c(this.options.observer, {
|
|
1596
|
+
type: t,
|
|
1597
|
+
traceId: e.traceId,
|
|
1598
|
+
requestId: e.id,
|
|
1599
|
+
sourceRevision: e.sourceRevision,
|
|
1600
|
+
sourcePhase: e.job.sourcePhase,
|
|
1601
|
+
timestamp: Date.now(),
|
|
1602
|
+
...n
|
|
1603
|
+
});
|
|
1604
|
+
}
|
|
1605
|
+
reportStale(e, t, n, r) {
|
|
1606
|
+
if (this.disposed || this.reportedStaleRequestIds.has(e)) return;
|
|
1607
|
+
this.reportedStaleRequestIds.add(e);
|
|
1608
|
+
let i = "local.worker.stale-response", a = {
|
|
1609
|
+
...f(i, {
|
|
1610
|
+
requestId: e,
|
|
1611
|
+
sourceRevision: n,
|
|
1612
|
+
...r === void 0 ? {} : { currentRevision: r }
|
|
1613
|
+
}),
|
|
1614
|
+
phase: "worker"
|
|
1615
|
+
};
|
|
1616
|
+
c(this.options.observer, {
|
|
1617
|
+
type: "worker-stale-response",
|
|
1618
|
+
traceId: t,
|
|
1619
|
+
requestId: e,
|
|
1620
|
+
sourceRevision: n,
|
|
1621
|
+
timestamp: Date.now(),
|
|
1622
|
+
code: i
|
|
1623
|
+
}), !this.disposed && s(this.options.observer, a);
|
|
1624
|
+
}
|
|
1625
|
+
setPending(e) {
|
|
1626
|
+
this.pending !== e && (this.pending = e, this.options.onPendingChange?.(e));
|
|
1627
|
+
}
|
|
1628
|
+
clearTimer() {
|
|
1629
|
+
this.timer !== null && (clearTimeout(this.timer), this.timer = null);
|
|
1630
|
+
}
|
|
1631
|
+
};
|
|
1632
|
+
export { x as _, fe as a, b, G as c, W as d, I as f, w as g, F as h, Se as i, B as l, p as m, $ as n, pe as o, R as p, Q as r, H as s, je as t, V as u, S as v, oe as y };
|