@jxsuite/studio 2.0.0 → 2.1.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/canvas.html +21 -0
- package/dist/chunks/Overlay.dev-qfjzkms8.js +23 -0
- package/dist/chunks/{Overlay.dev-cszx7yn5.js.map → Overlay.dev-qfjzkms8.js.map} +1 -1
- package/dist/chunks/{adapter-z8fkmbmv.js → adapter-qfnesn5v.js} +2 -2
- package/dist/chunks/{cf-settings-mmyv436d.js → cf-settings-73sh5z4p.js} +3 -3
- package/dist/chunks/{components-0hzentwq.js → components-2bpqp4mq.js} +5 -7
- package/dist/chunks/{components-0hzentwq.js.map → components-2bpqp4mq.js.map} +1 -1
- package/dist/chunks/content-source-34gnkbnn.js +38 -0
- package/dist/chunks/content-source-34gnkbnn.js.map +9 -0
- package/dist/chunks/convert-to-repeater-t8kxre5s.js +258 -0
- package/dist/chunks/convert-to-repeater-t8kxre5s.js.map +10 -0
- package/dist/chunks/extension-sections-6mqydz35.js +301 -0
- package/dist/chunks/extension-sections-6mqydz35.js.map +11 -0
- package/dist/chunks/files-8kn321h1.js +70 -0
- package/dist/chunks/files-8kn321h1.js.map +9 -0
- package/dist/chunks/{format-host-2c188n41.js → format-host-mkwsmt8d.js} +3 -3
- package/dist/chunks/git-panel-tjbr191d.js +51 -0
- package/dist/chunks/git-panel-tjbr191d.js.map +9 -0
- package/dist/chunks/{index-baeg2x3y.js → index-7pxchcce.js} +4 -3
- package/dist/chunks/{index-baeg2x3y.js.map → index-7pxchcce.js.map} +3 -3
- package/dist/chunks/{jx-validate-qx8degj7.js → jx-validate-v6qgknrs.js} +3 -3
- package/dist/chunks/layers-panel-87pb25km.js +58 -0
- package/dist/chunks/layers-panel-87pb25km.js.map +9 -0
- package/dist/chunks/{monaco-setup-zjdp9zdw.js → monaco-setup-e0yh25j4.js} +4 -75
- package/dist/chunks/{monaco-setup-zjdp9zdw.js.map → monaco-setup-e0yh25j4.js.map} +3 -4
- package/dist/chunks/publish-panel-m0fcgdrt.js +21 -0
- package/dist/chunks/publish-panel-m0fcgdrt.js.map +9 -0
- package/dist/chunks/quick-search-rhs6cbsb.js +53 -0
- package/dist/chunks/quick-search-rhs6cbsb.js.map +9 -0
- package/dist/chunks/right-panel-zpdxd98t.js +37 -0
- package/dist/chunks/right-panel-zpdxd98t.js.map +9 -0
- package/dist/chunks/section-registry-zmckaxf4.js +30 -0
- package/dist/chunks/section-registry-zmckaxf4.js.map +9 -0
- package/dist/chunks/sp-overlay.dev-9ran0sfq.js +18 -0
- package/dist/chunks/sp-overlay.dev-9ran0sfq.js.map +9 -0
- package/dist/chunks/sp-popover.dev-rebmdncr.js +9 -0
- package/dist/chunks/sp-popover.dev-rebmdncr.js.map +9 -0
- package/dist/chunks/sp-progress-circle.dev-5vkppfkt.js +15 -0
- package/dist/chunks/sp-progress-circle.dev-5vkppfkt.js.map +9 -0
- package/dist/chunks/sp-tooltip.dev-ykqrg8h5.js +15 -0
- package/dist/chunks/sp-tooltip.dev-ykqrg8h5.js.map +9 -0
- package/dist/chunks/{sp-tray.dev-pb2fsd65.js → sp-tray.dev-ey59vfh7.js} +10 -8
- package/dist/chunks/{sp-tray.dev-pb2fsd65.js.map → sp-tray.dev-ey59vfh7.js.map} +2 -2
- package/dist/chunks/{studio-9qr6fq7p.js → studio-0rqqhrdy.js} +10 -378
- package/dist/chunks/{studio-9qr6fq7p.js.map → studio-0rqqhrdy.js.map} +4 -14
- package/dist/chunks/{studio-5x6tqqec.js → studio-2sj1jj3v.js} +10 -8
- package/dist/chunks/{studio-5x6tqqec.js.map → studio-2sj1jj3v.js.map} +2 -2
- package/dist/chunks/{studio-h3fw0wn8.js → studio-3fk1ac9z.js} +6 -4
- package/dist/chunks/{studio-h3fw0wn8.js.map → studio-3fk1ac9z.js.map} +2 -2
- package/dist/chunks/studio-41exgzhq.js +6690 -0
- package/dist/chunks/studio-41exgzhq.js.map +38 -0
- package/dist/chunks/{studio-7v2bpweq.js → studio-4mqb9a0j.js} +6 -4
- package/dist/chunks/{studio-7v2bpweq.js.map → studio-4mqb9a0j.js.map} +2 -2
- package/dist/chunks/studio-50k77cca.js +1787 -0
- package/dist/chunks/studio-50k77cca.js.map +18 -0
- package/dist/chunks/{studio-56v3zwk6.js → studio-6a0h7sne.js} +10 -8
- package/dist/chunks/{studio-56v3zwk6.js.map → studio-6a0h7sne.js.map} +2 -2
- package/dist/chunks/studio-6f0am8f2.js +53 -0
- package/dist/chunks/studio-6f0am8f2.js.map +10 -0
- package/dist/chunks/studio-6nmjc5qk.js +7002 -0
- package/dist/chunks/studio-6nmjc5qk.js.map +32 -0
- package/dist/chunks/studio-7afd21nw.js +67 -0
- package/dist/chunks/studio-7afd21nw.js.map +10 -0
- package/dist/chunks/{studio-xze4zrs1.js → studio-7bmdvzne.js} +2 -2
- package/dist/chunks/studio-7bmdvzne.js.map +10 -0
- package/dist/chunks/studio-8jpzqk5s.js +128 -0
- package/dist/chunks/studio-8jpzqk5s.js.map +10 -0
- package/dist/chunks/studio-94m77tgk.js +1482 -0
- package/dist/chunks/studio-94m77tgk.js.map +13 -0
- package/dist/chunks/studio-9je6w5sq.js +1000 -0
- package/dist/chunks/studio-9je6w5sq.js.map +16 -0
- package/dist/chunks/{studio-w7c6kvk7.js → studio-a7pzveq1.js} +2 -2
- package/dist/chunks/{studio-97qcgvdn.js → studio-adn0z1k3.js} +14 -8
- package/dist/chunks/{studio-97qcgvdn.js.map → studio-adn0z1k3.js.map} +3 -3
- package/dist/chunks/{studio-kr88ryr7.js → studio-bsxxx3x2.js} +17 -15
- package/dist/chunks/{studio-kr88ryr7.js.map → studio-bsxxx3x2.js.map} +7 -6
- package/dist/chunks/studio-bw5dz6km.js +608 -0
- package/dist/chunks/studio-bw5dz6km.js.map +21 -0
- package/dist/chunks/studio-c6s5getc.js +4232 -0
- package/dist/chunks/studio-c6s5getc.js.map +39 -0
- package/dist/chunks/studio-cjm7fdjf.js +451 -0
- package/dist/chunks/studio-cjm7fdjf.js.map +14 -0
- package/dist/chunks/{studio-cx91mnh8.js → studio-ckwz4d3x.js} +53 -53
- package/dist/chunks/{studio-cx91mnh8.js.map → studio-ckwz4d3x.js.map} +5 -5
- package/dist/chunks/studio-dg7zyt5x.js +28 -0
- package/dist/chunks/studio-dg7zyt5x.js.map +10 -0
- package/dist/chunks/studio-dzcyvvvz.js +166 -0
- package/dist/chunks/studio-dzcyvvvz.js.map +10 -0
- package/dist/chunks/{studio-7kqe41sa.js → studio-evkr5d3b.js} +15 -7
- package/dist/chunks/{studio-7kqe41sa.js.map → studio-evkr5d3b.js.map} +5 -4
- package/dist/chunks/studio-f12h6177.js +411 -0
- package/dist/chunks/studio-f12h6177.js.map +13 -0
- package/dist/chunks/studio-hbp1s8m9.js +1817 -0
- package/dist/chunks/studio-hbp1s8m9.js.map +14 -0
- package/dist/chunks/studio-k2sxjph5.js +15295 -0
- package/dist/chunks/studio-k2sxjph5.js.map +235 -0
- package/dist/chunks/studio-myje51t3.js +385 -0
- package/dist/chunks/studio-myje51t3.js.map +12 -0
- package/dist/chunks/studio-na6rwzhw.js +353 -0
- package/dist/chunks/studio-na6rwzhw.js.map +11 -0
- package/dist/chunks/{studio-4k0m4fmp.js → studio-p471gg5n.js} +126 -3
- package/dist/chunks/studio-p471gg5n.js.map +14 -0
- package/dist/chunks/{studio-9bjwf0d4.js → studio-rgwcpast.js} +5 -46
- package/dist/chunks/{studio-9bjwf0d4.js.map → studio-rgwcpast.js.map} +4 -5
- package/dist/chunks/{studio-hhj92gcr.js → studio-s519zc99.js} +3 -3
- package/dist/chunks/studio-sas7mt3k.js +75 -0
- package/dist/chunks/studio-sas7mt3k.js.map +10 -0
- package/dist/chunks/studio-t5wqwzdh.js +74 -0
- package/dist/chunks/studio-t5wqwzdh.js.map +10 -0
- package/dist/chunks/{studio-9qpspwfn.js → studio-temv5bw4.js} +5 -5
- package/dist/chunks/{studio-9qpspwfn.js.map → studio-temv5bw4.js.map} +1 -1
- package/dist/chunks/{studio-qkvt37c0.js → studio-tr20m8g8.js} +669 -18
- package/dist/chunks/studio-tr20m8g8.js.map +9 -0
- package/dist/chunks/{studio-ygzav7z5.js → studio-v96qfnww.js} +5514 -4291
- package/dist/chunks/studio-v96qfnww.js.map +54 -0
- package/dist/chunks/studio-vcetc91k.js +659 -0
- package/dist/chunks/studio-vcetc91k.js.map +10 -0
- package/dist/chunks/{studio-n9zmpxjg.js → studio-vmymjefp.js} +2972 -4937
- package/dist/chunks/studio-vmymjefp.js.map +98 -0
- package/dist/chunks/{studio-bghqfmea.js → studio-wwseqyw0.js} +2 -2
- package/dist/chunks/studio-x9hmy5kr.js +390 -0
- package/dist/chunks/studio-x9hmy5kr.js.map +10 -0
- package/dist/chunks/studio-xa0ce0n7.js +335 -0
- package/dist/chunks/studio-xa0ce0n7.js.map +10 -0
- package/dist/chunks/studio-xm3dbxvn.js +378 -0
- package/dist/chunks/studio-xm3dbxvn.js.map +19 -0
- package/dist/chunks/{studio-nqw433kv.js → studio-xmvbhg31.js} +2 -2
- package/dist/chunks/studio-zv37yrfa.js +1054 -0
- package/dist/chunks/studio-zv37yrfa.js.map +13 -0
- package/dist/chunks/{ws-client-q7hkz3j9.js → ws-client-654ts66j.js} +6 -4
- package/dist/chunks/ws-client-654ts66j.js.map +11 -0
- package/dist/iframe-entry.js +668 -230
- package/dist/studio.js +23711 -35185
- package/index.html +35 -4685
- package/package.json +17 -15
- package/src/about/about-modal.ts +42 -11
- package/src/browse/library-commands.ts +240 -0
- package/src/browse/library-layouts.ts +369 -0
- package/src/browse/library-model.ts +396 -0
- package/src/browse/library-pane.ts +1049 -0
- package/src/browse/library-preview.ts +252 -0
- package/src/browse/library-source.ts +150 -0
- package/src/canvas/canvas-helpers.ts +33 -9
- package/src/canvas/canvas-live-render.ts +45 -29
- package/src/canvas/canvas-patcher.ts +151 -31
- package/src/canvas/canvas-perf.ts +46 -7
- package/src/canvas/canvas-render.ts +1092 -220
- package/src/canvas/canvas-surface.ts +240 -0
- package/src/canvas/canvas-utils.ts +1166 -124
- package/src/canvas/iframe-drop.ts +2 -1
- package/src/canvas/iframe-entry.ts +241 -4
- package/src/canvas/iframe-host.ts +1226 -143
- package/src/canvas/iframe-inline-edit.ts +31 -0
- package/src/canvas/iframe-interaction.ts +76 -16
- package/src/canvas/iframe-keys.ts +107 -45
- package/src/canvas/iframe-overlay.ts +38 -1
- package/src/canvas/iframe-protocol.ts +137 -2
- package/src/canvas/iframe-render.ts +70 -2
- package/src/canvas/iframe-slash.ts +6 -0
- package/src/canvas/path-mapping.ts +56 -6
- package/src/canvas/surface-registry.ts +292 -0
- package/src/collab/collab-commands.ts +244 -0
- package/src/collab/collab-session.ts +198 -32
- package/src/collab/collab-state.ts +28 -2
- package/src/collab/presence-chips.ts +100 -9
- package/src/commands/active-registry.ts +42 -0
- package/src/commands/app-commands.ts +176 -0
- package/src/commands/budget.ts +158 -0
- package/src/commands/command-args.ts +253 -0
- package/src/commands/context.ts +387 -0
- package/src/commands/defaults.ts +580 -0
- package/src/commands/keymap.ts +571 -0
- package/src/commands/levels.ts +345 -0
- package/src/commands/live-context.ts +193 -0
- package/src/commands/reference.ts +227 -0
- package/src/commands/registry.ts +293 -0
- package/src/component-props.ts +3 -2
- package/src/content/draft-state.ts +106 -0
- package/src/content/entry-commands.ts +282 -0
- package/src/content/entry-editor.ts +327 -0
- package/src/content/entry-fields.ts +116 -0
- package/src/content/entry-model.ts +175 -0
- package/src/editor/canvas-context-menu.ts +17 -11
- package/src/editor/canvas-slash-bridge.ts +11 -4
- package/src/editor/context-menu.ts +804 -204
- package/src/editor/convert-to-component.ts +31 -10
- package/src/editor/convert-to-repeater.ts +3 -2
- package/src/editor/inline-edit-apply.ts +5 -5
- package/src/editor/inline-edit.ts +86 -50
- package/src/editor/insert-zone-action.ts +1 -1
- package/src/editor/shortcuts.ts +1043 -329
- package/src/editor/slash-menu.ts +1 -0
- package/src/files/elements.ts +166 -0
- package/src/files/file-ops.ts +178 -31
- package/src/files/files.ts +898 -268
- package/src/files/fs-events.ts +21 -0
- package/src/files/media-meta.ts +203 -0
- package/src/files/media-paths.ts +141 -0
- package/src/files/media-upload.ts +7 -3
- package/src/files/media-usage.ts +189 -0
- package/src/github/github-auth.ts +235 -33
- package/src/github/github-publish.ts +80 -21
- package/src/grid/grid-controller.ts +152 -12
- package/src/grid/grid-layout.ts +225 -20
- package/src/grid/grid-open.ts +120 -0
- package/src/grid/grid-panel.ts +554 -39
- package/src/grid/grid-source.ts +27 -1
- package/src/grid/redirects-grid.ts +599 -0
- package/src/grid/redirects.ts +398 -0
- package/src/grid/sources/content-source.ts +108 -2
- package/src/i18n/i18n-commands.ts +322 -0
- package/src/new-project/add-repo-modal.ts +8 -10
- package/src/new-project/import-tab.ts +34 -9
- package/src/new-project/location-fields.ts +9 -1
- package/src/new-project/new-project-modal.ts +270 -262
- package/src/packages/jxsuite-update.ts +97 -48
- package/src/packages/pull-package-sync.ts +18 -9
- package/src/page-params.ts +2 -1
- package/src/panels/activity-bar.ts +152 -91
- package/src/panels/activity-panel.ts +481 -0
- package/src/panels/ai-chat/chat-markdown.ts +8 -3
- package/src/panels/ai-chat/chat-view.ts +245 -18
- package/src/panels/ai-chat/composer.ts +31 -5
- package/src/panels/ai-chat/sessions-view.ts +17 -10
- package/src/panels/ai-panel.ts +279 -120
- package/src/panels/block-action-bar.ts +1115 -224
- package/src/panels/bottom-dock.ts +337 -0
- package/src/panels/canvas-dnd-bridge.ts +37 -8
- package/src/panels/chat-panel.ts +29 -12
- package/src/panels/data-explorer.ts +254 -112
- package/src/panels/data-grid.ts +10 -4
- package/src/panels/dnd.ts +28 -51
- package/src/panels/editors.ts +434 -107
- package/src/panels/elements-panel.ts +66 -2
- package/src/panels/empty-state.ts +112 -0
- package/src/panels/events-panel.ts +596 -82
- package/src/panels/formula-workspace.ts +408 -218
- package/src/panels/frontmatter-fields.ts +51 -10
- package/src/panels/frontmatter-panel.ts +357 -79
- package/src/panels/git-panel.ts +375 -164
- package/src/panels/head-panel.ts +791 -85
- package/src/panels/i18n-panel.ts +592 -0
- package/src/panels/imports-panel.ts +95 -85
- package/src/panels/jump-bar.ts +584 -0
- package/src/panels/layers-panel.ts +1106 -328
- package/src/panels/left-panel.ts +109 -204
- package/src/panels/navigator-panels.ts +131 -0
- package/src/panels/overlays.ts +7 -2
- package/src/panels/pane-context.ts +1477 -0
- package/src/panels/pane-grid.ts +406 -0
- package/src/panels/panel-registry.ts +340 -0
- package/src/panels/panel-scheduler.ts +75 -0
- package/src/panels/problems-panel.ts +234 -0
- package/src/panels/properties-panel.ts +946 -1139
- package/src/panels/provenance.ts +258 -0
- package/src/panels/quick-search.ts +791 -122
- package/src/panels/right-panel.ts +228 -102
- package/src/panels/seo-modal.ts +395 -0
- package/src/panels/settings-pane.ts +203 -0
- package/src/panels/signals-panel.ts +354 -137
- package/src/panels/statement-editor.ts +41 -25
- package/src/panels/statusbar.ts +342 -106
- package/src/panels/style-panel.ts +974 -463
- package/src/panels/style-utils.ts +3 -3
- package/src/panels/stylebook-doc.ts +4 -2
- package/src/panels/stylebook-layers-panel.ts +3 -2
- package/src/panels/stylebook-panel.ts +51 -26
- package/src/panels/tab-strip.ts +1058 -78
- package/src/panels/target-line.ts +274 -0
- package/src/panels/toolbar.ts +631 -484
- package/src/panels/welcome-screen.ts +301 -198
- package/src/platform-errors.ts +26 -3
- package/src/platform.ts +96 -2
- package/src/platforms/cloud.ts +71 -8
- package/src/platforms/devserver.ts +92 -29
- package/src/publish/deploy-checklist.ts +383 -0
- package/src/publish/pages-service.ts +10 -1
- package/src/publish/publish-commands.ts +218 -0
- package/src/publish/publish-panel.ts +110 -16
- package/src/recent-projects.ts +3 -2
- package/src/services/a11y-report.ts +505 -0
- package/src/services/ai-models.ts +75 -2
- package/src/services/ai-project-tools.ts +29 -10
- package/src/services/ai-system-prompt.ts +53 -14
- package/src/services/ai-tools.ts +39 -3
- package/src/services/ai-writes.ts +154 -0
- package/src/services/announce.ts +97 -0
- package/src/services/automation.ts +424 -175
- package/src/services/cem-export.ts +9 -4
- package/src/services/clock.ts +61 -0
- package/src/services/document-assistant.ts +36 -8
- package/src/services/idle.ts +179 -0
- package/src/services/import-client.ts +26 -0
- package/src/services/monaco-buffer.ts +627 -0
- package/src/services/monaco-lazy.ts +36 -0
- package/src/services/notify.ts +271 -0
- package/src/services/profile.ts +155 -0
- package/src/services/references.ts +0 -0
- package/src/services/token-lint.ts +3 -2
- package/src/services/tool-executor.ts +53 -7
- package/src/services/trusted-types.ts +123 -0
- package/src/settings/contexts-section.ts +427 -0
- package/src/settings/contributed-section.ts +149 -11
- package/src/settings/css-vars-editor.ts +306 -349
- package/src/settings/defs-editor.ts +93 -34
- package/src/settings/dependencies-editor.ts +7 -7
- package/src/settings/extension-sections.ts +37 -5
- package/src/settings/general-settings.ts +204 -121
- package/src/settings/locales-section.ts +347 -0
- package/src/settings/preferences-accounts.ts +140 -0
- package/src/settings/preferences-dialog.ts +620 -0
- package/src/settings/preferences-keymap.ts +270 -0
- package/src/settings/project-sections.ts +260 -0
- package/src/settings/section-registry.ts +169 -0
- package/src/settings/settings-document.ts +385 -0
- package/src/shell.ts +1549 -0
- package/src/site-context.ts +45 -20
- package/src/state.ts +14 -275
- package/src/store.ts +88 -43
- package/src/studio.ts +790 -346
- package/src/style/live-preview.ts +36 -0
- package/src/style/project-styles.ts +349 -0
- package/src/style/token-ref.ts +123 -0
- package/src/tabs/patch-ops.ts +16 -4
- package/src/tabs/project-config.ts +416 -0
- package/src/tabs/selection.ts +323 -0
- package/src/tabs/tab.ts +182 -47
- package/src/tabs/transact.ts +209 -28
- package/src/types.ts +68 -13
- package/src/ui/ai-credentials-form.ts +39 -35
- package/src/ui/ai-managed-connect.ts +113 -0
- package/src/ui/dynamic-slot.ts +224 -81
- package/src/ui/expression-editor.ts +71 -63
- package/src/ui/field-input.ts +4 -6
- package/src/ui/field-row.ts +215 -38
- package/src/ui/form-controls.ts +194 -7
- package/src/ui/layers.ts +492 -69
- package/src/ui/media-picker.ts +115 -25
- package/src/ui/panel-resize.ts +109 -91
- package/src/ui/progress-modal.ts +131 -50
- package/src/ui/regions.ts +462 -0
- package/src/ui/schema-form.ts +229 -45
- package/src/ui/spectrum.ts +24 -8
- package/src/ui/timing.ts +49 -0
- package/src/ui/value-selector.ts +20 -0
- package/src/ui/value-source.ts +348 -0
- package/src/ui/virtual-window.ts +400 -0
- package/src/utils/edit-display.ts +3 -2
- package/src/utils/inherited-style.ts +67 -37
- package/src/view.ts +64 -78
- package/src/workspace/pane-derive.ts +1258 -0
- package/src/workspace/session.ts +317 -0
- package/src/workspace/workspace.ts +1345 -23
- package/styles/canvas.css +653 -0
- package/styles/forced-colors.css +106 -0
- package/styles/inspector.css +1454 -0
- package/styles/overlays.css +2704 -0
- package/styles/panels.css +1701 -0
- package/styles/shell.css +1423 -0
- package/styles/tokens.css +151 -0
- package/dist/chunks/Overlay.dev-cszx7yn5.js +0 -22
- package/dist/chunks/extension-sections-qct0gt8f.js +0 -531
- package/dist/chunks/extension-sections-qct0gt8f.js.map +0 -12
- package/dist/chunks/files-02zn5y24.js +0 -50
- package/dist/chunks/files-02zn5y24.js.map +0 -9
- package/dist/chunks/git-panel-mbb0y0hz.js +0 -28
- package/dist/chunks/git-panel-mbb0y0hz.js.map +0 -9
- package/dist/chunks/layers-panel-9qekmqk1.js +0 -26
- package/dist/chunks/layers-panel-9qekmqk1.js.map +0 -9
- package/dist/chunks/settings-modal-gj0hrah4.js +0 -29
- package/dist/chunks/settings-modal-gj0hrah4.js.map +0 -9
- package/dist/chunks/sp-overlay.dev-earn5as8.js +0 -17
- package/dist/chunks/sp-overlay.dev-earn5as8.js.map +0 -9
- package/dist/chunks/sp-popover.dev-frxtfejn.js +0 -8
- package/dist/chunks/sp-popover.dev-frxtfejn.js.map +0 -9
- package/dist/chunks/sp-progress-circle.dev-7tvw34h8.js +0 -14
- package/dist/chunks/sp-progress-circle.dev-7tvw34h8.js.map +0 -9
- package/dist/chunks/sp-tooltip.dev-a9fywesm.js +0 -21
- package/dist/chunks/sp-tooltip.dev-a9fywesm.js.map +0 -10
- package/dist/chunks/studio-4k0m4fmp.js.map +0 -13
- package/dist/chunks/studio-568nx4t5.js +0 -469
- package/dist/chunks/studio-568nx4t5.js.map +0 -14
- package/dist/chunks/studio-9smfzqhc.js +0 -19
- package/dist/chunks/studio-9smfzqhc.js.map +0 -10
- package/dist/chunks/studio-asvf0j9e.js +0 -429
- package/dist/chunks/studio-asvf0j9e.js.map +0 -13
- package/dist/chunks/studio-d77qm3pk.js +0 -3427
- package/dist/chunks/studio-d77qm3pk.js.map +0 -26
- package/dist/chunks/studio-j6gqyjf4.js +0 -1854
- package/dist/chunks/studio-j6gqyjf4.js.map +0 -18
- package/dist/chunks/studio-n9zmpxjg.js.map +0 -115
- package/dist/chunks/studio-qkvt37c0.js.map +0 -9
- package/dist/chunks/studio-rq0vxb19.js +0 -3744
- package/dist/chunks/studio-rq0vxb19.js.map +0 -22
- package/dist/chunks/studio-wd6ewdvd.js +0 -853
- package/dist/chunks/studio-wd6ewdvd.js.map +0 -12
- package/dist/chunks/studio-xq0t7n5t.js +0 -140
- package/dist/chunks/studio-xq0t7n5t.js.map +0 -10
- package/dist/chunks/studio-xze4zrs1.js.map +0 -10
- package/dist/chunks/studio-ygzav7z5.js.map +0 -46
- package/dist/chunks/studio-zmy7241e.js +0 -399
- package/dist/chunks/studio-zmy7241e.js.map +0 -12
- package/dist/chunks/ws-client-q7hkz3j9.js.map +0 -11
- package/src/browse/browse-modal.ts +0 -69
- package/src/browse/browse.ts +0 -904
- package/src/canvas/canvas-diff.ts +0 -216
- package/src/canvas/nested-site-style.ts +0 -58
- package/src/new-project/design-fields.ts +0 -264
- package/src/new-project/templates.ts +0 -61
- package/src/panels/tab-bar.ts +0 -548
- package/src/settings/settings-modal.ts +0 -203
- /package/dist/chunks/{adapter-z8fkmbmv.js.map → adapter-qfnesn5v.js.map} +0 -0
- /package/dist/chunks/{cf-settings-mmyv436d.js.map → cf-settings-73sh5z4p.js.map} +0 -0
- /package/dist/chunks/{format-host-2c188n41.js.map → format-host-mkwsmt8d.js.map} +0 -0
- /package/dist/chunks/{jx-validate-qx8degj7.js.map → jx-validate-v6qgknrs.js.map} +0 -0
- /package/dist/chunks/{studio-w7c6kvk7.js.map → studio-a7pzveq1.js.map} +0 -0
- /package/dist/chunks/{studio-hhj92gcr.js.map → studio-s519zc99.js.map} +0 -0
- /package/dist/chunks/{studio-bghqfmea.js.map → studio-wwseqyw0.js.map} +0 -0
- /package/dist/chunks/{studio-nqw433kv.js.map → studio-xmvbhg31.js.map} +0 -0
|
@@ -1,3744 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defaultContentFormat,
|
|
3
|
-
formatByName,
|
|
4
|
-
formatForPath
|
|
5
|
-
} from "./studio-97qcgvdn.js";
|
|
6
|
-
import {
|
|
7
|
-
getPlatform
|
|
8
|
-
} from "./studio-9smfzqhc.js";
|
|
9
|
-
import {
|
|
10
|
-
applyDocOpToDoc,
|
|
11
|
-
childArray,
|
|
12
|
-
cloneValue
|
|
13
|
-
} from "./studio-5ehhackm.js";
|
|
14
|
-
import {
|
|
15
|
-
__require
|
|
16
|
-
} from "./studio-md4gps17.js";
|
|
17
|
-
|
|
18
|
-
// ../../node_modules/@vue/shared/dist/shared.esm-bundler.js
|
|
19
|
-
function makeMap(str) {
|
|
20
|
-
const map = /* @__PURE__ */ Object.create(null);
|
|
21
|
-
for (const key of str.split(","))
|
|
22
|
-
map[key] = 1;
|
|
23
|
-
return (val) => (val in map);
|
|
24
|
-
}
|
|
25
|
-
var EMPTY_OBJ = Object.freeze({});
|
|
26
|
-
var EMPTY_ARR = Object.freeze([]);
|
|
27
|
-
var extend = Object.assign;
|
|
28
|
-
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
29
|
-
var hasOwn = (val, key) => hasOwnProperty.call(val, key);
|
|
30
|
-
var isArray = Array.isArray;
|
|
31
|
-
var isMap = (val) => toTypeString(val) === "[object Map]";
|
|
32
|
-
var isFunction = (val) => typeof val === "function";
|
|
33
|
-
var isString = (val) => typeof val === "string";
|
|
34
|
-
var isSymbol = (val) => typeof val === "symbol";
|
|
35
|
-
var isObject = (val) => val !== null && typeof val === "object";
|
|
36
|
-
var objectToString = Object.prototype.toString;
|
|
37
|
-
var toTypeString = (value) => objectToString.call(value);
|
|
38
|
-
var toRawType = (value) => {
|
|
39
|
-
return toTypeString(value).slice(8, -1);
|
|
40
|
-
};
|
|
41
|
-
var isIntegerKey = (key) => isString(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
42
|
-
var cacheStringFunction = (fn) => {
|
|
43
|
-
const cache = /* @__PURE__ */ Object.create(null);
|
|
44
|
-
return (str) => {
|
|
45
|
-
const hit = cache[str];
|
|
46
|
-
return hit || (cache[str] = fn(str));
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
var camelizeRE = /-\w/g;
|
|
50
|
-
var camelize = cacheStringFunction((str) => {
|
|
51
|
-
return str.replace(camelizeRE, (c) => c.slice(1).toUpperCase());
|
|
52
|
-
});
|
|
53
|
-
var hyphenateRE = /\B([A-Z])/g;
|
|
54
|
-
var hyphenate = cacheStringFunction((str) => str.replace(hyphenateRE, "-$1").toLowerCase());
|
|
55
|
-
var capitalize = cacheStringFunction((str) => {
|
|
56
|
-
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
57
|
-
});
|
|
58
|
-
var toHandlerKey = cacheStringFunction((str) => {
|
|
59
|
-
const s = str ? `on${capitalize(str)}` : ``;
|
|
60
|
-
return s;
|
|
61
|
-
});
|
|
62
|
-
var hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
63
|
-
var specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
64
|
-
var isBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`);
|
|
65
|
-
|
|
66
|
-
// ../../node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js
|
|
67
|
-
function warn(msg, ...args) {
|
|
68
|
-
console.warn(`[Vue warn] ${msg}`, ...args);
|
|
69
|
-
}
|
|
70
|
-
var activeEffectScope;
|
|
71
|
-
|
|
72
|
-
class EffectScope {
|
|
73
|
-
constructor(detached = false) {
|
|
74
|
-
this.detached = detached;
|
|
75
|
-
this._active = true;
|
|
76
|
-
this._on = 0;
|
|
77
|
-
this.effects = [];
|
|
78
|
-
this.cleanups = [];
|
|
79
|
-
this._isPaused = false;
|
|
80
|
-
this._warnOnRun = true;
|
|
81
|
-
this.__v_skip = true;
|
|
82
|
-
if (!detached && activeEffectScope) {
|
|
83
|
-
if (activeEffectScope.active) {
|
|
84
|
-
this.parent = activeEffectScope;
|
|
85
|
-
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(this) - 1;
|
|
86
|
-
} else {
|
|
87
|
-
this._active = false;
|
|
88
|
-
this._warnOnRun = false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
get active() {
|
|
93
|
-
return this._active;
|
|
94
|
-
}
|
|
95
|
-
pause() {
|
|
96
|
-
if (this._active) {
|
|
97
|
-
this._isPaused = true;
|
|
98
|
-
let i, l;
|
|
99
|
-
if (this.scopes) {
|
|
100
|
-
const scopes = this.scopes.slice();
|
|
101
|
-
for (i = 0, l = scopes.length;i < l; i++) {
|
|
102
|
-
scopes[i].pause();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
for (i = 0, l = this.effects.length;i < l; i++) {
|
|
106
|
-
this.effects[i].pause();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
resume() {
|
|
111
|
-
if (this._active) {
|
|
112
|
-
if (this._isPaused) {
|
|
113
|
-
this._isPaused = false;
|
|
114
|
-
let i, l;
|
|
115
|
-
if (this.scopes) {
|
|
116
|
-
const scopes = this.scopes.slice();
|
|
117
|
-
for (i = 0, l = scopes.length;i < l; i++) {
|
|
118
|
-
scopes[i].resume();
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
const effects = this.effects.slice();
|
|
122
|
-
for (i = 0, l = effects.length;i < l; i++) {
|
|
123
|
-
effects[i].resume();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
run(fn) {
|
|
129
|
-
if (this._active) {
|
|
130
|
-
const currentEffectScope = activeEffectScope;
|
|
131
|
-
try {
|
|
132
|
-
activeEffectScope = this;
|
|
133
|
-
return fn();
|
|
134
|
-
} finally {
|
|
135
|
-
activeEffectScope = currentEffectScope;
|
|
136
|
-
}
|
|
137
|
-
} else if (this._warnOnRun) {
|
|
138
|
-
warn(`cannot run an inactive effect scope.`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
on() {
|
|
142
|
-
if (++this._on === 1) {
|
|
143
|
-
this.prevScope = activeEffectScope;
|
|
144
|
-
activeEffectScope = this;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
off() {
|
|
148
|
-
if (this._on > 0 && --this._on === 0) {
|
|
149
|
-
if (activeEffectScope === this) {
|
|
150
|
-
activeEffectScope = this.prevScope;
|
|
151
|
-
} else {
|
|
152
|
-
let current = activeEffectScope;
|
|
153
|
-
while (current) {
|
|
154
|
-
if (current.prevScope === this) {
|
|
155
|
-
current.prevScope = this.prevScope;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
current = current.prevScope;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
this.prevScope = undefined;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
stop(fromParent) {
|
|
165
|
-
if (this._active) {
|
|
166
|
-
this._active = false;
|
|
167
|
-
let i, l;
|
|
168
|
-
for (i = 0, l = this.effects.length;i < l; i++) {
|
|
169
|
-
this.effects[i].stop();
|
|
170
|
-
}
|
|
171
|
-
this.effects.length = 0;
|
|
172
|
-
for (i = 0, l = this.cleanups.length;i < l; i++) {
|
|
173
|
-
this.cleanups[i]();
|
|
174
|
-
}
|
|
175
|
-
this.cleanups.length = 0;
|
|
176
|
-
if (this.scopes) {
|
|
177
|
-
const scopes = this.scopes.slice();
|
|
178
|
-
for (i = 0, l = scopes.length;i < l; i++) {
|
|
179
|
-
scopes[i].stop(true);
|
|
180
|
-
}
|
|
181
|
-
this.scopes.length = 0;
|
|
182
|
-
}
|
|
183
|
-
if (!this.detached && this.parent && !fromParent) {
|
|
184
|
-
const last = this.parent.scopes.pop();
|
|
185
|
-
if (last && last !== this) {
|
|
186
|
-
this.parent.scopes[this.index] = last;
|
|
187
|
-
last.index = this.index;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
this.parent = undefined;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
function effectScope(detached) {
|
|
195
|
-
return new EffectScope(detached);
|
|
196
|
-
}
|
|
197
|
-
function onScopeDispose(fn, failSilently = false) {
|
|
198
|
-
if (activeEffectScope) {
|
|
199
|
-
activeEffectScope.cleanups.push(fn);
|
|
200
|
-
} else if (!failSilently) {
|
|
201
|
-
warn(`onScopeDispose() is called when there is no active effect scope to be associated with.`);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
var activeSub;
|
|
205
|
-
var pausedQueueEffects = /* @__PURE__ */ new WeakSet;
|
|
206
|
-
|
|
207
|
-
class ReactiveEffect {
|
|
208
|
-
constructor(fn) {
|
|
209
|
-
this.fn = fn;
|
|
210
|
-
this.deps = undefined;
|
|
211
|
-
this.depsTail = undefined;
|
|
212
|
-
this.flags = 1 | 4;
|
|
213
|
-
this.next = undefined;
|
|
214
|
-
this.cleanup = undefined;
|
|
215
|
-
this.scheduler = undefined;
|
|
216
|
-
if (activeEffectScope) {
|
|
217
|
-
if (activeEffectScope.active) {
|
|
218
|
-
activeEffectScope.effects.push(this);
|
|
219
|
-
} else {
|
|
220
|
-
this.flags &= -2;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
pause() {
|
|
225
|
-
this.flags |= 64;
|
|
226
|
-
}
|
|
227
|
-
resume() {
|
|
228
|
-
if (this.flags & 64) {
|
|
229
|
-
this.flags &= -65;
|
|
230
|
-
if (pausedQueueEffects.has(this)) {
|
|
231
|
-
pausedQueueEffects.delete(this);
|
|
232
|
-
this.trigger();
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
notify() {
|
|
237
|
-
if (this.flags & 2 && !(this.flags & 32)) {
|
|
238
|
-
return;
|
|
239
|
-
}
|
|
240
|
-
if (!(this.flags & 8)) {
|
|
241
|
-
batch(this);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
run() {
|
|
245
|
-
if (!(this.flags & 1)) {
|
|
246
|
-
return this.fn();
|
|
247
|
-
}
|
|
248
|
-
this.flags |= 2;
|
|
249
|
-
cleanupEffect(this);
|
|
250
|
-
prepareDeps(this);
|
|
251
|
-
const prevEffect = activeSub;
|
|
252
|
-
const prevShouldTrack = shouldTrack;
|
|
253
|
-
activeSub = this;
|
|
254
|
-
shouldTrack = true;
|
|
255
|
-
try {
|
|
256
|
-
return this.fn();
|
|
257
|
-
} finally {
|
|
258
|
-
if (activeSub !== this) {
|
|
259
|
-
warn("Active effect was not restored correctly - this is likely a Vue internal bug.");
|
|
260
|
-
}
|
|
261
|
-
cleanupDeps(this);
|
|
262
|
-
activeSub = prevEffect;
|
|
263
|
-
shouldTrack = prevShouldTrack;
|
|
264
|
-
this.flags &= -3;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
stop() {
|
|
268
|
-
if (this.flags & 1) {
|
|
269
|
-
for (let link = this.deps;link; link = link.nextDep) {
|
|
270
|
-
removeSub(link);
|
|
271
|
-
}
|
|
272
|
-
this.deps = this.depsTail = undefined;
|
|
273
|
-
cleanupEffect(this);
|
|
274
|
-
this.onStop && this.onStop();
|
|
275
|
-
this.flags &= -2;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
trigger() {
|
|
279
|
-
if (this.flags & 64) {
|
|
280
|
-
pausedQueueEffects.add(this);
|
|
281
|
-
} else if (this.scheduler) {
|
|
282
|
-
this.scheduler();
|
|
283
|
-
} else {
|
|
284
|
-
this.runIfDirty();
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
runIfDirty() {
|
|
288
|
-
if (isDirty(this)) {
|
|
289
|
-
this.run();
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
get dirty() {
|
|
293
|
-
return isDirty(this);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
var batchDepth = 0;
|
|
297
|
-
var batchedSub;
|
|
298
|
-
var batchedComputed;
|
|
299
|
-
function batch(sub, isComputed = false) {
|
|
300
|
-
sub.flags |= 8;
|
|
301
|
-
if (isComputed) {
|
|
302
|
-
sub.next = batchedComputed;
|
|
303
|
-
batchedComputed = sub;
|
|
304
|
-
return;
|
|
305
|
-
}
|
|
306
|
-
sub.next = batchedSub;
|
|
307
|
-
batchedSub = sub;
|
|
308
|
-
}
|
|
309
|
-
function startBatch() {
|
|
310
|
-
batchDepth++;
|
|
311
|
-
}
|
|
312
|
-
function endBatch() {
|
|
313
|
-
if (--batchDepth > 0) {
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
if (batchedComputed) {
|
|
317
|
-
let e = batchedComputed;
|
|
318
|
-
batchedComputed = undefined;
|
|
319
|
-
while (e) {
|
|
320
|
-
const next = e.next;
|
|
321
|
-
e.next = undefined;
|
|
322
|
-
e.flags &= -9;
|
|
323
|
-
e = next;
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
let error;
|
|
327
|
-
while (batchedSub) {
|
|
328
|
-
let e = batchedSub;
|
|
329
|
-
batchedSub = undefined;
|
|
330
|
-
while (e) {
|
|
331
|
-
const next = e.next;
|
|
332
|
-
e.next = undefined;
|
|
333
|
-
e.flags &= -9;
|
|
334
|
-
if (e.flags & 1) {
|
|
335
|
-
try {
|
|
336
|
-
e.trigger();
|
|
337
|
-
} catch (err) {
|
|
338
|
-
if (!error)
|
|
339
|
-
error = err;
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
e = next;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
if (error)
|
|
346
|
-
throw error;
|
|
347
|
-
}
|
|
348
|
-
function prepareDeps(sub) {
|
|
349
|
-
for (let link = sub.deps;link; link = link.nextDep) {
|
|
350
|
-
link.version = -1;
|
|
351
|
-
link.prevActiveLink = link.dep.activeLink;
|
|
352
|
-
link.dep.activeLink = link;
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
function cleanupDeps(sub) {
|
|
356
|
-
let head;
|
|
357
|
-
let tail = sub.depsTail;
|
|
358
|
-
let link = tail;
|
|
359
|
-
while (link) {
|
|
360
|
-
const prev = link.prevDep;
|
|
361
|
-
if (link.version === -1) {
|
|
362
|
-
if (link === tail)
|
|
363
|
-
tail = prev;
|
|
364
|
-
removeSub(link);
|
|
365
|
-
removeDep(link);
|
|
366
|
-
} else {
|
|
367
|
-
head = link;
|
|
368
|
-
}
|
|
369
|
-
link.dep.activeLink = link.prevActiveLink;
|
|
370
|
-
link.prevActiveLink = undefined;
|
|
371
|
-
link = prev;
|
|
372
|
-
}
|
|
373
|
-
sub.deps = head;
|
|
374
|
-
sub.depsTail = tail;
|
|
375
|
-
}
|
|
376
|
-
function isDirty(sub) {
|
|
377
|
-
for (let link = sub.deps;link; link = link.nextDep) {
|
|
378
|
-
if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
if (sub._dirty) {
|
|
383
|
-
return true;
|
|
384
|
-
}
|
|
385
|
-
return false;
|
|
386
|
-
}
|
|
387
|
-
function refreshComputed(computed) {
|
|
388
|
-
if (computed.flags & 4 && !(computed.flags & 16)) {
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
computed.flags &= -17;
|
|
392
|
-
if (computed.globalVersion === globalVersion) {
|
|
393
|
-
return;
|
|
394
|
-
}
|
|
395
|
-
computed.globalVersion = globalVersion;
|
|
396
|
-
if (!computed.isSSR && computed.flags & 128 && (!computed.deps && !computed._dirty || !isDirty(computed))) {
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
computed.flags |= 2;
|
|
400
|
-
const dep = computed.dep;
|
|
401
|
-
const prevSub = activeSub;
|
|
402
|
-
const prevShouldTrack = shouldTrack;
|
|
403
|
-
activeSub = computed;
|
|
404
|
-
shouldTrack = true;
|
|
405
|
-
try {
|
|
406
|
-
prepareDeps(computed);
|
|
407
|
-
const value = computed.fn(computed._value);
|
|
408
|
-
if (dep.version === 0 || hasChanged(value, computed._value)) {
|
|
409
|
-
computed.flags |= 128;
|
|
410
|
-
computed._value = value;
|
|
411
|
-
dep.version++;
|
|
412
|
-
}
|
|
413
|
-
} catch (err) {
|
|
414
|
-
dep.version++;
|
|
415
|
-
throw err;
|
|
416
|
-
} finally {
|
|
417
|
-
activeSub = prevSub;
|
|
418
|
-
shouldTrack = prevShouldTrack;
|
|
419
|
-
cleanupDeps(computed);
|
|
420
|
-
computed.flags &= -3;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function removeSub(link, soft = false) {
|
|
424
|
-
const { dep, prevSub, nextSub } = link;
|
|
425
|
-
if (prevSub) {
|
|
426
|
-
prevSub.nextSub = nextSub;
|
|
427
|
-
link.prevSub = undefined;
|
|
428
|
-
}
|
|
429
|
-
if (nextSub) {
|
|
430
|
-
nextSub.prevSub = prevSub;
|
|
431
|
-
link.nextSub = undefined;
|
|
432
|
-
}
|
|
433
|
-
if (dep.subsHead === link) {
|
|
434
|
-
dep.subsHead = nextSub;
|
|
435
|
-
}
|
|
436
|
-
if (dep.subs === link) {
|
|
437
|
-
dep.subs = prevSub;
|
|
438
|
-
if (!prevSub && dep.computed) {
|
|
439
|
-
dep.computed.flags &= -5;
|
|
440
|
-
for (let l = dep.computed.deps;l; l = l.nextDep) {
|
|
441
|
-
removeSub(l, true);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
if (!soft && !--dep.sc && dep.map) {
|
|
446
|
-
dep.map.delete(dep.key);
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
function removeDep(link) {
|
|
450
|
-
const { prevDep, nextDep } = link;
|
|
451
|
-
if (prevDep) {
|
|
452
|
-
prevDep.nextDep = nextDep;
|
|
453
|
-
link.prevDep = undefined;
|
|
454
|
-
}
|
|
455
|
-
if (nextDep) {
|
|
456
|
-
nextDep.prevDep = prevDep;
|
|
457
|
-
link.nextDep = undefined;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
function effect(fn, options) {
|
|
461
|
-
if (fn.effect instanceof ReactiveEffect) {
|
|
462
|
-
fn = fn.effect.fn;
|
|
463
|
-
}
|
|
464
|
-
const e = new ReactiveEffect(fn);
|
|
465
|
-
if (options) {
|
|
466
|
-
extend(e, options);
|
|
467
|
-
}
|
|
468
|
-
try {
|
|
469
|
-
e.run();
|
|
470
|
-
} catch (err) {
|
|
471
|
-
e.stop();
|
|
472
|
-
throw err;
|
|
473
|
-
}
|
|
474
|
-
const runner = e.run.bind(e);
|
|
475
|
-
runner.effect = e;
|
|
476
|
-
return runner;
|
|
477
|
-
}
|
|
478
|
-
var shouldTrack = true;
|
|
479
|
-
var trackStack = [];
|
|
480
|
-
function pauseTracking() {
|
|
481
|
-
trackStack.push(shouldTrack);
|
|
482
|
-
shouldTrack = false;
|
|
483
|
-
}
|
|
484
|
-
function resetTracking() {
|
|
485
|
-
const last = trackStack.pop();
|
|
486
|
-
shouldTrack = last === undefined ? true : last;
|
|
487
|
-
}
|
|
488
|
-
function onEffectCleanup(fn, failSilently = false) {
|
|
489
|
-
if (activeSub instanceof ReactiveEffect) {
|
|
490
|
-
activeSub.cleanup = fn;
|
|
491
|
-
} else if (!failSilently) {
|
|
492
|
-
warn(`onEffectCleanup() was called when there was no active effect to associate with.`);
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
function cleanupEffect(e) {
|
|
496
|
-
const { cleanup } = e;
|
|
497
|
-
e.cleanup = undefined;
|
|
498
|
-
if (cleanup) {
|
|
499
|
-
const prevSub = activeSub;
|
|
500
|
-
activeSub = undefined;
|
|
501
|
-
try {
|
|
502
|
-
cleanup();
|
|
503
|
-
} finally {
|
|
504
|
-
activeSub = prevSub;
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
var globalVersion = 0;
|
|
509
|
-
|
|
510
|
-
class Link {
|
|
511
|
-
constructor(sub, dep) {
|
|
512
|
-
this.sub = sub;
|
|
513
|
-
this.dep = dep;
|
|
514
|
-
this.version = dep.version;
|
|
515
|
-
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = undefined;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
|
|
519
|
-
class Dep {
|
|
520
|
-
constructor(computed) {
|
|
521
|
-
this.computed = computed;
|
|
522
|
-
this.version = 0;
|
|
523
|
-
this.activeLink = undefined;
|
|
524
|
-
this.subs = undefined;
|
|
525
|
-
this.map = undefined;
|
|
526
|
-
this.key = undefined;
|
|
527
|
-
this.sc = 0;
|
|
528
|
-
this.__v_skip = true;
|
|
529
|
-
if (true) {
|
|
530
|
-
this.subsHead = undefined;
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
track(debugInfo) {
|
|
534
|
-
if (!activeSub || !shouldTrack || activeSub === this.computed) {
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
let link = this.activeLink;
|
|
538
|
-
if (link === undefined || link.sub !== activeSub) {
|
|
539
|
-
link = this.activeLink = new Link(activeSub, this);
|
|
540
|
-
if (!activeSub.deps) {
|
|
541
|
-
activeSub.deps = activeSub.depsTail = link;
|
|
542
|
-
} else {
|
|
543
|
-
link.prevDep = activeSub.depsTail;
|
|
544
|
-
activeSub.depsTail.nextDep = link;
|
|
545
|
-
activeSub.depsTail = link;
|
|
546
|
-
}
|
|
547
|
-
addSub(link);
|
|
548
|
-
} else if (link.version === -1) {
|
|
549
|
-
link.version = this.version;
|
|
550
|
-
if (link.nextDep) {
|
|
551
|
-
const next = link.nextDep;
|
|
552
|
-
next.prevDep = link.prevDep;
|
|
553
|
-
if (link.prevDep) {
|
|
554
|
-
link.prevDep.nextDep = next;
|
|
555
|
-
}
|
|
556
|
-
link.prevDep = activeSub.depsTail;
|
|
557
|
-
link.nextDep = undefined;
|
|
558
|
-
activeSub.depsTail.nextDep = link;
|
|
559
|
-
activeSub.depsTail = link;
|
|
560
|
-
if (activeSub.deps === link) {
|
|
561
|
-
activeSub.deps = next;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
if (activeSub.onTrack) {
|
|
566
|
-
activeSub.onTrack(extend({
|
|
567
|
-
effect: activeSub
|
|
568
|
-
}, debugInfo));
|
|
569
|
-
}
|
|
570
|
-
return link;
|
|
571
|
-
}
|
|
572
|
-
trigger(debugInfo) {
|
|
573
|
-
this.version++;
|
|
574
|
-
globalVersion++;
|
|
575
|
-
this.notify(debugInfo);
|
|
576
|
-
}
|
|
577
|
-
notify(debugInfo) {
|
|
578
|
-
startBatch();
|
|
579
|
-
try {
|
|
580
|
-
if (true) {
|
|
581
|
-
for (let head = this.subsHead;head; head = head.nextSub) {
|
|
582
|
-
if (head.sub.onTrigger && !(head.sub.flags & 8)) {
|
|
583
|
-
head.sub.onTrigger(extend({
|
|
584
|
-
effect: head.sub
|
|
585
|
-
}, debugInfo));
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
for (let link = this.subs;link; link = link.prevSub) {
|
|
590
|
-
if (link.sub.notify()) {
|
|
591
|
-
link.sub.dep.notify();
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
} finally {
|
|
595
|
-
endBatch();
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
function addSub(link) {
|
|
600
|
-
link.dep.sc++;
|
|
601
|
-
if (link.sub.flags & 4) {
|
|
602
|
-
const computed = link.dep.computed;
|
|
603
|
-
if (computed && !link.dep.subs) {
|
|
604
|
-
computed.flags |= 4 | 16;
|
|
605
|
-
for (let l = computed.deps;l; l = l.nextDep) {
|
|
606
|
-
addSub(l);
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
const currentTail = link.dep.subs;
|
|
610
|
-
if (currentTail !== link) {
|
|
611
|
-
link.prevSub = currentTail;
|
|
612
|
-
if (currentTail)
|
|
613
|
-
currentTail.nextSub = link;
|
|
614
|
-
}
|
|
615
|
-
if (link.dep.subsHead === undefined) {
|
|
616
|
-
link.dep.subsHead = link;
|
|
617
|
-
}
|
|
618
|
-
link.dep.subs = link;
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
var targetMap = /* @__PURE__ */ new WeakMap;
|
|
622
|
-
var ITERATE_KEY = /* @__PURE__ */ Symbol("Object iterate");
|
|
623
|
-
var MAP_KEY_ITERATE_KEY = /* @__PURE__ */ Symbol("Map keys iterate");
|
|
624
|
-
var ARRAY_ITERATE_KEY = /* @__PURE__ */ Symbol("Array iterate");
|
|
625
|
-
function track(target, type, key) {
|
|
626
|
-
if (shouldTrack && activeSub) {
|
|
627
|
-
let depsMap = targetMap.get(target);
|
|
628
|
-
if (!depsMap) {
|
|
629
|
-
targetMap.set(target, depsMap = /* @__PURE__ */ new Map);
|
|
630
|
-
}
|
|
631
|
-
let dep = depsMap.get(key);
|
|
632
|
-
if (!dep) {
|
|
633
|
-
depsMap.set(key, dep = new Dep);
|
|
634
|
-
dep.map = depsMap;
|
|
635
|
-
dep.key = key;
|
|
636
|
-
}
|
|
637
|
-
if (true) {
|
|
638
|
-
dep.track({
|
|
639
|
-
target,
|
|
640
|
-
type,
|
|
641
|
-
key
|
|
642
|
-
});
|
|
643
|
-
} else {}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
function trigger(target, type, key, newValue, oldValue, oldTarget) {
|
|
647
|
-
const depsMap = targetMap.get(target);
|
|
648
|
-
if (!depsMap) {
|
|
649
|
-
globalVersion++;
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
const run = (dep) => {
|
|
653
|
-
if (dep) {
|
|
654
|
-
if (true) {
|
|
655
|
-
dep.trigger({
|
|
656
|
-
target,
|
|
657
|
-
type,
|
|
658
|
-
key,
|
|
659
|
-
newValue,
|
|
660
|
-
oldValue,
|
|
661
|
-
oldTarget
|
|
662
|
-
});
|
|
663
|
-
} else {}
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
startBatch();
|
|
667
|
-
if (type === "clear") {
|
|
668
|
-
depsMap.forEach(run);
|
|
669
|
-
} else {
|
|
670
|
-
const targetIsArray = isArray(target);
|
|
671
|
-
const isArrayIndex = targetIsArray && isIntegerKey(key);
|
|
672
|
-
if (targetIsArray && key === "length") {
|
|
673
|
-
const newLength = Number(newValue);
|
|
674
|
-
depsMap.forEach((dep, key2) => {
|
|
675
|
-
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol(key2) && key2 >= newLength) {
|
|
676
|
-
run(dep);
|
|
677
|
-
}
|
|
678
|
-
});
|
|
679
|
-
} else {
|
|
680
|
-
if (key !== undefined || depsMap.has(undefined)) {
|
|
681
|
-
run(depsMap.get(key));
|
|
682
|
-
}
|
|
683
|
-
if (isArrayIndex) {
|
|
684
|
-
run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
685
|
-
}
|
|
686
|
-
switch (type) {
|
|
687
|
-
case "add":
|
|
688
|
-
if (!targetIsArray) {
|
|
689
|
-
run(depsMap.get(ITERATE_KEY));
|
|
690
|
-
if (isMap(target)) {
|
|
691
|
-
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
692
|
-
}
|
|
693
|
-
} else if (isArrayIndex) {
|
|
694
|
-
run(depsMap.get("length"));
|
|
695
|
-
}
|
|
696
|
-
break;
|
|
697
|
-
case "delete":
|
|
698
|
-
if (!targetIsArray) {
|
|
699
|
-
run(depsMap.get(ITERATE_KEY));
|
|
700
|
-
if (isMap(target)) {
|
|
701
|
-
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
702
|
-
}
|
|
703
|
-
}
|
|
704
|
-
break;
|
|
705
|
-
case "set":
|
|
706
|
-
if (isMap(target)) {
|
|
707
|
-
run(depsMap.get(ITERATE_KEY));
|
|
708
|
-
}
|
|
709
|
-
break;
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
endBatch();
|
|
714
|
-
}
|
|
715
|
-
function reactiveReadArray(array) {
|
|
716
|
-
const raw = toRaw(array);
|
|
717
|
-
if (raw === array)
|
|
718
|
-
return raw;
|
|
719
|
-
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
720
|
-
return isShallow(array) ? raw : raw.map(toReactive);
|
|
721
|
-
}
|
|
722
|
-
function shallowReadArray(arr) {
|
|
723
|
-
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
724
|
-
return arr;
|
|
725
|
-
}
|
|
726
|
-
function toWrapped(target, item) {
|
|
727
|
-
if (isReadonly(target)) {
|
|
728
|
-
return isReactive(target) ? toReadonly(toReactive(item)) : toReadonly(item);
|
|
729
|
-
}
|
|
730
|
-
return toReactive(item);
|
|
731
|
-
}
|
|
732
|
-
var arrayInstrumentations = {
|
|
733
|
-
__proto__: null,
|
|
734
|
-
[Symbol.iterator]() {
|
|
735
|
-
return iterator(this, Symbol.iterator, (item) => toWrapped(this, item));
|
|
736
|
-
},
|
|
737
|
-
concat(...args) {
|
|
738
|
-
return reactiveReadArray(this).concat(...args.map((x) => isArray(x) ? reactiveReadArray(x) : x));
|
|
739
|
-
},
|
|
740
|
-
entries() {
|
|
741
|
-
return iterator(this, "entries", (value) => {
|
|
742
|
-
value[1] = toWrapped(this, value[1]);
|
|
743
|
-
return value;
|
|
744
|
-
});
|
|
745
|
-
},
|
|
746
|
-
every(fn, thisArg) {
|
|
747
|
-
return apply(this, "every", fn, thisArg, undefined, arguments);
|
|
748
|
-
},
|
|
749
|
-
filter(fn, thisArg) {
|
|
750
|
-
return apply(this, "filter", fn, thisArg, (v) => v.map((item) => toWrapped(this, item)), arguments);
|
|
751
|
-
},
|
|
752
|
-
find(fn, thisArg) {
|
|
753
|
-
return apply(this, "find", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
754
|
-
},
|
|
755
|
-
findIndex(fn, thisArg) {
|
|
756
|
-
return apply(this, "findIndex", fn, thisArg, undefined, arguments);
|
|
757
|
-
},
|
|
758
|
-
findLast(fn, thisArg) {
|
|
759
|
-
return apply(this, "findLast", fn, thisArg, (item) => toWrapped(this, item), arguments);
|
|
760
|
-
},
|
|
761
|
-
findLastIndex(fn, thisArg) {
|
|
762
|
-
return apply(this, "findLastIndex", fn, thisArg, undefined, arguments);
|
|
763
|
-
},
|
|
764
|
-
forEach(fn, thisArg) {
|
|
765
|
-
return apply(this, "forEach", fn, thisArg, undefined, arguments);
|
|
766
|
-
},
|
|
767
|
-
includes(...args) {
|
|
768
|
-
return searchProxy(this, "includes", args);
|
|
769
|
-
},
|
|
770
|
-
indexOf(...args) {
|
|
771
|
-
return searchProxy(this, "indexOf", args);
|
|
772
|
-
},
|
|
773
|
-
join(separator) {
|
|
774
|
-
return reactiveReadArray(this).join(separator);
|
|
775
|
-
},
|
|
776
|
-
lastIndexOf(...args) {
|
|
777
|
-
return searchProxy(this, "lastIndexOf", args);
|
|
778
|
-
},
|
|
779
|
-
map(fn, thisArg) {
|
|
780
|
-
return apply(this, "map", fn, thisArg, undefined, arguments);
|
|
781
|
-
},
|
|
782
|
-
pop() {
|
|
783
|
-
return noTracking(this, "pop");
|
|
784
|
-
},
|
|
785
|
-
push(...args) {
|
|
786
|
-
return noTracking(this, "push", args);
|
|
787
|
-
},
|
|
788
|
-
reduce(fn, ...args) {
|
|
789
|
-
return reduce(this, "reduce", fn, args);
|
|
790
|
-
},
|
|
791
|
-
reduceRight(fn, ...args) {
|
|
792
|
-
return reduce(this, "reduceRight", fn, args);
|
|
793
|
-
},
|
|
794
|
-
shift() {
|
|
795
|
-
return noTracking(this, "shift");
|
|
796
|
-
},
|
|
797
|
-
some(fn, thisArg) {
|
|
798
|
-
return apply(this, "some", fn, thisArg, undefined, arguments);
|
|
799
|
-
},
|
|
800
|
-
splice(...args) {
|
|
801
|
-
return noTracking(this, "splice", args);
|
|
802
|
-
},
|
|
803
|
-
toReversed() {
|
|
804
|
-
return reactiveReadArray(this).toReversed();
|
|
805
|
-
},
|
|
806
|
-
toSorted(comparer) {
|
|
807
|
-
return reactiveReadArray(this).toSorted(comparer);
|
|
808
|
-
},
|
|
809
|
-
toSpliced(...args) {
|
|
810
|
-
return reactiveReadArray(this).toSpliced(...args);
|
|
811
|
-
},
|
|
812
|
-
unshift(...args) {
|
|
813
|
-
return noTracking(this, "unshift", args);
|
|
814
|
-
},
|
|
815
|
-
values() {
|
|
816
|
-
return iterator(this, "values", (item) => toWrapped(this, item));
|
|
817
|
-
}
|
|
818
|
-
};
|
|
819
|
-
function iterator(self2, method, wrapValue) {
|
|
820
|
-
const arr = shallowReadArray(self2);
|
|
821
|
-
const iter = arr[method]();
|
|
822
|
-
if (arr !== self2 && !isShallow(self2)) {
|
|
823
|
-
iter._next = iter.next;
|
|
824
|
-
iter.next = () => {
|
|
825
|
-
const result = iter._next();
|
|
826
|
-
if (!result.done) {
|
|
827
|
-
result.value = wrapValue(result.value);
|
|
828
|
-
}
|
|
829
|
-
return result;
|
|
830
|
-
};
|
|
831
|
-
}
|
|
832
|
-
return iter;
|
|
833
|
-
}
|
|
834
|
-
var arrayProto = Array.prototype;
|
|
835
|
-
function apply(self2, method, fn, thisArg, wrappedRetFn, args) {
|
|
836
|
-
const arr = shallowReadArray(self2);
|
|
837
|
-
const needsWrap = arr !== self2 && !isShallow(self2);
|
|
838
|
-
const methodFn = arr[method];
|
|
839
|
-
if (methodFn !== arrayProto[method]) {
|
|
840
|
-
const result2 = methodFn.apply(self2, args);
|
|
841
|
-
return needsWrap ? toReactive(result2) : result2;
|
|
842
|
-
}
|
|
843
|
-
let wrappedFn = fn;
|
|
844
|
-
if (arr !== self2) {
|
|
845
|
-
if (needsWrap) {
|
|
846
|
-
wrappedFn = function(item, index) {
|
|
847
|
-
return fn.call(this, toWrapped(self2, item), index, self2);
|
|
848
|
-
};
|
|
849
|
-
} else if (fn.length > 2) {
|
|
850
|
-
wrappedFn = function(item, index) {
|
|
851
|
-
return fn.call(this, item, index, self2);
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
856
|
-
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
857
|
-
}
|
|
858
|
-
function reduce(self2, method, fn, args) {
|
|
859
|
-
const arr = shallowReadArray(self2);
|
|
860
|
-
const needsWrap = arr !== self2 && !isShallow(self2);
|
|
861
|
-
let wrappedFn = fn;
|
|
862
|
-
let wrapInitialAccumulator = false;
|
|
863
|
-
if (arr !== self2) {
|
|
864
|
-
if (needsWrap) {
|
|
865
|
-
wrapInitialAccumulator = args.length === 0;
|
|
866
|
-
wrappedFn = function(acc, item, index) {
|
|
867
|
-
if (wrapInitialAccumulator) {
|
|
868
|
-
wrapInitialAccumulator = false;
|
|
869
|
-
acc = toWrapped(self2, acc);
|
|
870
|
-
}
|
|
871
|
-
return fn.call(this, acc, toWrapped(self2, item), index, self2);
|
|
872
|
-
};
|
|
873
|
-
} else if (fn.length > 3) {
|
|
874
|
-
wrappedFn = function(acc, item, index) {
|
|
875
|
-
return fn.call(this, acc, item, index, self2);
|
|
876
|
-
};
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
const result = arr[method](wrappedFn, ...args);
|
|
880
|
-
return wrapInitialAccumulator ? toWrapped(self2, result) : result;
|
|
881
|
-
}
|
|
882
|
-
function searchProxy(self2, method, args) {
|
|
883
|
-
const arr = toRaw(self2);
|
|
884
|
-
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
885
|
-
const res = arr[method](...args);
|
|
886
|
-
if ((res === -1 || res === false) && isProxy(args[0])) {
|
|
887
|
-
args[0] = toRaw(args[0]);
|
|
888
|
-
return arr[method](...args);
|
|
889
|
-
}
|
|
890
|
-
return res;
|
|
891
|
-
}
|
|
892
|
-
function noTracking(self2, method, args = []) {
|
|
893
|
-
pauseTracking();
|
|
894
|
-
startBatch();
|
|
895
|
-
const res = toRaw(self2)[method].apply(self2, args);
|
|
896
|
-
endBatch();
|
|
897
|
-
resetTracking();
|
|
898
|
-
return res;
|
|
899
|
-
}
|
|
900
|
-
var isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
901
|
-
var builtInSymbols = new Set(/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol));
|
|
902
|
-
function hasOwnProperty2(key) {
|
|
903
|
-
if (!isSymbol(key))
|
|
904
|
-
key = String(key);
|
|
905
|
-
const obj = toRaw(this);
|
|
906
|
-
track(obj, "has", key);
|
|
907
|
-
return obj.hasOwnProperty(key);
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
class BaseReactiveHandler {
|
|
911
|
-
constructor(_isReadonly = false, _isShallow = false) {
|
|
912
|
-
this._isReadonly = _isReadonly;
|
|
913
|
-
this._isShallow = _isShallow;
|
|
914
|
-
}
|
|
915
|
-
get(target, key, receiver) {
|
|
916
|
-
if (key === "__v_skip")
|
|
917
|
-
return target["__v_skip"];
|
|
918
|
-
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
919
|
-
if (key === "__v_isReactive") {
|
|
920
|
-
return !isReadonly2;
|
|
921
|
-
} else if (key === "__v_isReadonly") {
|
|
922
|
-
return isReadonly2;
|
|
923
|
-
} else if (key === "__v_isShallow") {
|
|
924
|
-
return isShallow2;
|
|
925
|
-
} else if (key === "__v_raw") {
|
|
926
|
-
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
927
|
-
return target;
|
|
928
|
-
}
|
|
929
|
-
return;
|
|
930
|
-
}
|
|
931
|
-
const targetIsArray = isArray(target);
|
|
932
|
-
if (!isReadonly2) {
|
|
933
|
-
let fn;
|
|
934
|
-
if (targetIsArray && (fn = arrayInstrumentations[key])) {
|
|
935
|
-
return fn;
|
|
936
|
-
}
|
|
937
|
-
if (key === "hasOwnProperty") {
|
|
938
|
-
return hasOwnProperty2;
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
const res = Reflect.get(target, key, isRef(target) ? target : receiver);
|
|
942
|
-
if (isSymbol(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
943
|
-
return res;
|
|
944
|
-
}
|
|
945
|
-
if (!isReadonly2) {
|
|
946
|
-
track(target, "get", key);
|
|
947
|
-
}
|
|
948
|
-
if (isShallow2) {
|
|
949
|
-
return res;
|
|
950
|
-
}
|
|
951
|
-
if (isRef(res)) {
|
|
952
|
-
const value = targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
953
|
-
return isReadonly2 && isObject(value) ? readonly(value) : value;
|
|
954
|
-
}
|
|
955
|
-
if (isObject(res)) {
|
|
956
|
-
return isReadonly2 ? readonly(res) : reactive(res);
|
|
957
|
-
}
|
|
958
|
-
return res;
|
|
959
|
-
}
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
963
|
-
constructor(isShallow2 = false) {
|
|
964
|
-
super(false, isShallow2);
|
|
965
|
-
}
|
|
966
|
-
set(target, key, value, receiver) {
|
|
967
|
-
let oldValue = target[key];
|
|
968
|
-
const isArrayWithIntegerKey = isArray(target) && isIntegerKey(key);
|
|
969
|
-
if (!this._isShallow) {
|
|
970
|
-
const isOldValueReadonly = isReadonly(oldValue);
|
|
971
|
-
if (!isShallow(value) && !isReadonly(value)) {
|
|
972
|
-
oldValue = toRaw(oldValue);
|
|
973
|
-
value = toRaw(value);
|
|
974
|
-
}
|
|
975
|
-
if (!isArrayWithIntegerKey && isRef(oldValue) && !isRef(value)) {
|
|
976
|
-
if (isOldValueReadonly) {
|
|
977
|
-
if (true) {
|
|
978
|
-
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target[key]);
|
|
979
|
-
}
|
|
980
|
-
return true;
|
|
981
|
-
} else {
|
|
982
|
-
oldValue.value = value;
|
|
983
|
-
return true;
|
|
984
|
-
}
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
const hadKey = isArrayWithIntegerKey ? Number(key) < target.length : hasOwn(target, key);
|
|
988
|
-
const result = Reflect.set(target, key, value, isRef(target) ? target : receiver);
|
|
989
|
-
if (target === toRaw(receiver) && result) {
|
|
990
|
-
if (!hadKey) {
|
|
991
|
-
trigger(target, "add", key, value);
|
|
992
|
-
} else if (hasChanged(value, oldValue)) {
|
|
993
|
-
trigger(target, "set", key, value, oldValue);
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
return result;
|
|
997
|
-
}
|
|
998
|
-
deleteProperty(target, key) {
|
|
999
|
-
const hadKey = hasOwn(target, key);
|
|
1000
|
-
const oldValue = target[key];
|
|
1001
|
-
const result = Reflect.deleteProperty(target, key);
|
|
1002
|
-
if (result && hadKey) {
|
|
1003
|
-
trigger(target, "delete", key, undefined, oldValue);
|
|
1004
|
-
}
|
|
1005
|
-
return result;
|
|
1006
|
-
}
|
|
1007
|
-
has(target, key) {
|
|
1008
|
-
const result = Reflect.has(target, key);
|
|
1009
|
-
if (!isSymbol(key) || !builtInSymbols.has(key)) {
|
|
1010
|
-
track(target, "has", key);
|
|
1011
|
-
}
|
|
1012
|
-
return result;
|
|
1013
|
-
}
|
|
1014
|
-
ownKeys(target) {
|
|
1015
|
-
track(target, "iterate", isArray(target) ? "length" : ITERATE_KEY);
|
|
1016
|
-
return Reflect.ownKeys(target);
|
|
1017
|
-
}
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
1021
|
-
constructor(isShallow2 = false) {
|
|
1022
|
-
super(true, isShallow2);
|
|
1023
|
-
}
|
|
1024
|
-
set(target, key) {
|
|
1025
|
-
if (true) {
|
|
1026
|
-
warn(`Set operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
1027
|
-
}
|
|
1028
|
-
return true;
|
|
1029
|
-
}
|
|
1030
|
-
deleteProperty(target, key) {
|
|
1031
|
-
if (true) {
|
|
1032
|
-
warn(`Delete operation on key "${String(key)}" failed: target is readonly.`, target);
|
|
1033
|
-
}
|
|
1034
|
-
return true;
|
|
1035
|
-
}
|
|
1036
|
-
}
|
|
1037
|
-
var mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler;
|
|
1038
|
-
var readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler;
|
|
1039
|
-
var toShallow = (value) => value;
|
|
1040
|
-
var getProto = (v) => Reflect.getPrototypeOf(v);
|
|
1041
|
-
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
1042
|
-
return function(...args) {
|
|
1043
|
-
const target = this["__v_raw"];
|
|
1044
|
-
const rawTarget = toRaw(target);
|
|
1045
|
-
const targetIsMap = isMap(rawTarget);
|
|
1046
|
-
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
1047
|
-
const isKeyOnly = method === "keys" && targetIsMap;
|
|
1048
|
-
const innerIterator = target[method](...args);
|
|
1049
|
-
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
1050
|
-
!isReadonly2 && track(rawTarget, "iterate", isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY);
|
|
1051
|
-
return extend(Object.create(innerIterator), {
|
|
1052
|
-
next() {
|
|
1053
|
-
const { value, done } = innerIterator.next();
|
|
1054
|
-
return done ? { value, done } : {
|
|
1055
|
-
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
1056
|
-
done
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
});
|
|
1060
|
-
};
|
|
1061
|
-
}
|
|
1062
|
-
function createReadonlyMethod(type) {
|
|
1063
|
-
return function(...args) {
|
|
1064
|
-
if (true) {
|
|
1065
|
-
const key = args[0] ? `on key "${args[0]}" ` : ``;
|
|
1066
|
-
warn(`${capitalize(type)} operation ${key}failed: target is readonly.`, toRaw(this));
|
|
1067
|
-
}
|
|
1068
|
-
return type === "delete" ? false : type === "clear" ? undefined : this;
|
|
1069
|
-
};
|
|
1070
|
-
}
|
|
1071
|
-
function createInstrumentations(readonly, shallow) {
|
|
1072
|
-
const instrumentations = {
|
|
1073
|
-
get(key) {
|
|
1074
|
-
const target = this["__v_raw"];
|
|
1075
|
-
const rawTarget = toRaw(target);
|
|
1076
|
-
const rawKey = toRaw(key);
|
|
1077
|
-
if (!readonly) {
|
|
1078
|
-
if (hasChanged(key, rawKey)) {
|
|
1079
|
-
track(rawTarget, "get", key);
|
|
1080
|
-
}
|
|
1081
|
-
track(rawTarget, "get", rawKey);
|
|
1082
|
-
}
|
|
1083
|
-
const { has } = getProto(rawTarget);
|
|
1084
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1085
|
-
if (has.call(rawTarget, key)) {
|
|
1086
|
-
return wrap(target.get(key));
|
|
1087
|
-
} else if (has.call(rawTarget, rawKey)) {
|
|
1088
|
-
return wrap(target.get(rawKey));
|
|
1089
|
-
} else if (target !== rawTarget) {
|
|
1090
|
-
target.get(key);
|
|
1091
|
-
}
|
|
1092
|
-
},
|
|
1093
|
-
get size() {
|
|
1094
|
-
const target = this["__v_raw"];
|
|
1095
|
-
!readonly && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
1096
|
-
return target.size;
|
|
1097
|
-
},
|
|
1098
|
-
has(key) {
|
|
1099
|
-
const target = this["__v_raw"];
|
|
1100
|
-
const rawTarget = toRaw(target);
|
|
1101
|
-
const rawKey = toRaw(key);
|
|
1102
|
-
if (!readonly) {
|
|
1103
|
-
if (hasChanged(key, rawKey)) {
|
|
1104
|
-
track(rawTarget, "has", key);
|
|
1105
|
-
}
|
|
1106
|
-
track(rawTarget, "has", rawKey);
|
|
1107
|
-
}
|
|
1108
|
-
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
1109
|
-
},
|
|
1110
|
-
forEach(callback, thisArg) {
|
|
1111
|
-
const observed = this;
|
|
1112
|
-
const target = observed["__v_raw"];
|
|
1113
|
-
const rawTarget = toRaw(target);
|
|
1114
|
-
const wrap = shallow ? toShallow : readonly ? toReadonly : toReactive;
|
|
1115
|
-
!readonly && track(rawTarget, "iterate", ITERATE_KEY);
|
|
1116
|
-
return target.forEach((value, key) => {
|
|
1117
|
-
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
};
|
|
1121
|
-
extend(instrumentations, readonly ? {
|
|
1122
|
-
add: createReadonlyMethod("add"),
|
|
1123
|
-
set: createReadonlyMethod("set"),
|
|
1124
|
-
delete: createReadonlyMethod("delete"),
|
|
1125
|
-
clear: createReadonlyMethod("clear")
|
|
1126
|
-
} : {
|
|
1127
|
-
add(value) {
|
|
1128
|
-
const target = toRaw(this);
|
|
1129
|
-
const proto = getProto(target);
|
|
1130
|
-
const rawValue = toRaw(value);
|
|
1131
|
-
const valueToAdd = !shallow && !isShallow(value) && !isReadonly(value) ? rawValue : value;
|
|
1132
|
-
const hadKey = proto.has.call(target, valueToAdd) || hasChanged(value, valueToAdd) && proto.has.call(target, value) || hasChanged(rawValue, valueToAdd) && proto.has.call(target, rawValue);
|
|
1133
|
-
if (!hadKey) {
|
|
1134
|
-
target.add(valueToAdd);
|
|
1135
|
-
trigger(target, "add", valueToAdd, valueToAdd);
|
|
1136
|
-
}
|
|
1137
|
-
return this;
|
|
1138
|
-
},
|
|
1139
|
-
set(key, value) {
|
|
1140
|
-
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
1141
|
-
value = toRaw(value);
|
|
1142
|
-
}
|
|
1143
|
-
const target = toRaw(this);
|
|
1144
|
-
const { has, get } = getProto(target);
|
|
1145
|
-
let hadKey = has.call(target, key);
|
|
1146
|
-
if (!hadKey) {
|
|
1147
|
-
key = toRaw(key);
|
|
1148
|
-
hadKey = has.call(target, key);
|
|
1149
|
-
} else if (true) {
|
|
1150
|
-
checkIdentityKeys(target, has, key);
|
|
1151
|
-
}
|
|
1152
|
-
const oldValue = get.call(target, key);
|
|
1153
|
-
target.set(key, value);
|
|
1154
|
-
if (!hadKey) {
|
|
1155
|
-
trigger(target, "add", key, value);
|
|
1156
|
-
} else if (hasChanged(value, oldValue)) {
|
|
1157
|
-
trigger(target, "set", key, value, oldValue);
|
|
1158
|
-
}
|
|
1159
|
-
return this;
|
|
1160
|
-
},
|
|
1161
|
-
delete(key) {
|
|
1162
|
-
const target = toRaw(this);
|
|
1163
|
-
const { has, get } = getProto(target);
|
|
1164
|
-
let hadKey = has.call(target, key);
|
|
1165
|
-
if (!hadKey) {
|
|
1166
|
-
key = toRaw(key);
|
|
1167
|
-
hadKey = has.call(target, key);
|
|
1168
|
-
} else if (true) {
|
|
1169
|
-
checkIdentityKeys(target, has, key);
|
|
1170
|
-
}
|
|
1171
|
-
const oldValue = get ? get.call(target, key) : undefined;
|
|
1172
|
-
const result = target.delete(key);
|
|
1173
|
-
if (hadKey) {
|
|
1174
|
-
trigger(target, "delete", key, undefined, oldValue);
|
|
1175
|
-
}
|
|
1176
|
-
return result;
|
|
1177
|
-
},
|
|
1178
|
-
clear() {
|
|
1179
|
-
const target = toRaw(this);
|
|
1180
|
-
const hadItems = target.size !== 0;
|
|
1181
|
-
const oldTarget = isMap(target) ? new Map(target) : new Set(target);
|
|
1182
|
-
const result = target.clear();
|
|
1183
|
-
if (hadItems) {
|
|
1184
|
-
trigger(target, "clear", undefined, undefined, oldTarget);
|
|
1185
|
-
}
|
|
1186
|
-
return result;
|
|
1187
|
-
}
|
|
1188
|
-
});
|
|
1189
|
-
const iteratorMethods = [
|
|
1190
|
-
"keys",
|
|
1191
|
-
"values",
|
|
1192
|
-
"entries",
|
|
1193
|
-
Symbol.iterator
|
|
1194
|
-
];
|
|
1195
|
-
iteratorMethods.forEach((method) => {
|
|
1196
|
-
instrumentations[method] = createIterableMethod(method, readonly, shallow);
|
|
1197
|
-
});
|
|
1198
|
-
return instrumentations;
|
|
1199
|
-
}
|
|
1200
|
-
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
1201
|
-
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
1202
|
-
return (target, key, receiver) => {
|
|
1203
|
-
if (key === "__v_isReactive") {
|
|
1204
|
-
return !isReadonly2;
|
|
1205
|
-
} else if (key === "__v_isReadonly") {
|
|
1206
|
-
return isReadonly2;
|
|
1207
|
-
} else if (key === "__v_raw") {
|
|
1208
|
-
return target;
|
|
1209
|
-
}
|
|
1210
|
-
return Reflect.get(hasOwn(instrumentations, key) && key in target ? instrumentations : target, key, receiver);
|
|
1211
|
-
};
|
|
1212
|
-
}
|
|
1213
|
-
var mutableCollectionHandlers = {
|
|
1214
|
-
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
1215
|
-
};
|
|
1216
|
-
var readonlyCollectionHandlers = {
|
|
1217
|
-
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
1218
|
-
};
|
|
1219
|
-
function checkIdentityKeys(target, has, key) {
|
|
1220
|
-
const rawKey = toRaw(key);
|
|
1221
|
-
if (rawKey !== key && has.call(target, rawKey)) {
|
|
1222
|
-
const type = toRawType(target);
|
|
1223
|
-
warn(`Reactive ${type} contains both the raw and reactive versions of the same object${type === `Map` ? ` as keys` : ``}, which can lead to inconsistencies. Avoid differentiating between the raw and reactive versions of an object and only use the reactive version if possible.`);
|
|
1224
|
-
}
|
|
1225
|
-
}
|
|
1226
|
-
var reactiveMap = /* @__PURE__ */ new WeakMap;
|
|
1227
|
-
var shallowReactiveMap = /* @__PURE__ */ new WeakMap;
|
|
1228
|
-
var readonlyMap = /* @__PURE__ */ new WeakMap;
|
|
1229
|
-
var shallowReadonlyMap = /* @__PURE__ */ new WeakMap;
|
|
1230
|
-
function targetTypeMap(rawType) {
|
|
1231
|
-
switch (rawType) {
|
|
1232
|
-
case "Object":
|
|
1233
|
-
case "Array":
|
|
1234
|
-
return 1;
|
|
1235
|
-
case "Map":
|
|
1236
|
-
case "Set":
|
|
1237
|
-
case "WeakMap":
|
|
1238
|
-
case "WeakSet":
|
|
1239
|
-
return 2;
|
|
1240
|
-
default:
|
|
1241
|
-
return 0;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
function reactive(target) {
|
|
1245
|
-
if (/* @__PURE__ */ isReadonly(target)) {
|
|
1246
|
-
return target;
|
|
1247
|
-
}
|
|
1248
|
-
return createReactiveObject(target, false, mutableHandlers, mutableCollectionHandlers, reactiveMap);
|
|
1249
|
-
}
|
|
1250
|
-
function readonly(target) {
|
|
1251
|
-
return createReactiveObject(target, true, readonlyHandlers, readonlyCollectionHandlers, readonlyMap);
|
|
1252
|
-
}
|
|
1253
|
-
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
1254
|
-
if (!isObject(target)) {
|
|
1255
|
-
if (true) {
|
|
1256
|
-
warn(`value cannot be made ${isReadonly2 ? "readonly" : "reactive"}: ${String(target)}`);
|
|
1257
|
-
}
|
|
1258
|
-
return target;
|
|
1259
|
-
}
|
|
1260
|
-
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
1261
|
-
return target;
|
|
1262
|
-
}
|
|
1263
|
-
if (target["__v_skip"] || !Object.isExtensible(target)) {
|
|
1264
|
-
return target;
|
|
1265
|
-
}
|
|
1266
|
-
const existingProxy = proxyMap.get(target);
|
|
1267
|
-
if (existingProxy) {
|
|
1268
|
-
return existingProxy;
|
|
1269
|
-
}
|
|
1270
|
-
const targetType = targetTypeMap(toRawType(target));
|
|
1271
|
-
if (targetType === 0) {
|
|
1272
|
-
return target;
|
|
1273
|
-
}
|
|
1274
|
-
const proxy = new Proxy(target, targetType === 2 ? collectionHandlers : baseHandlers);
|
|
1275
|
-
proxyMap.set(target, proxy);
|
|
1276
|
-
return proxy;
|
|
1277
|
-
}
|
|
1278
|
-
function isReactive(value) {
|
|
1279
|
-
if (/* @__PURE__ */ isReadonly(value)) {
|
|
1280
|
-
return /* @__PURE__ */ isReactive(value["__v_raw"]);
|
|
1281
|
-
}
|
|
1282
|
-
return !!(value && value["__v_isReactive"]);
|
|
1283
|
-
}
|
|
1284
|
-
function isReadonly(value) {
|
|
1285
|
-
return !!(value && value["__v_isReadonly"]);
|
|
1286
|
-
}
|
|
1287
|
-
function isShallow(value) {
|
|
1288
|
-
return !!(value && value["__v_isShallow"]);
|
|
1289
|
-
}
|
|
1290
|
-
function isProxy(value) {
|
|
1291
|
-
return value ? !!value["__v_raw"] : false;
|
|
1292
|
-
}
|
|
1293
|
-
function toRaw(observed) {
|
|
1294
|
-
const raw = observed && observed["__v_raw"];
|
|
1295
|
-
return raw ? /* @__PURE__ */ toRaw(raw) : observed;
|
|
1296
|
-
}
|
|
1297
|
-
var toReactive = (value) => isObject(value) ? /* @__PURE__ */ reactive(value) : value;
|
|
1298
|
-
var toReadonly = (value) => isObject(value) ? /* @__PURE__ */ readonly(value) : value;
|
|
1299
|
-
function isRef(r) {
|
|
1300
|
-
return r ? r["__v_isRef"] === true : false;
|
|
1301
|
-
}
|
|
1302
|
-
function ref(value) {
|
|
1303
|
-
return createRef(value, false);
|
|
1304
|
-
}
|
|
1305
|
-
function createRef(rawValue, shallow) {
|
|
1306
|
-
if (/* @__PURE__ */ isRef(rawValue)) {
|
|
1307
|
-
return rawValue;
|
|
1308
|
-
}
|
|
1309
|
-
return new RefImpl(rawValue, shallow);
|
|
1310
|
-
}
|
|
1311
|
-
|
|
1312
|
-
class RefImpl {
|
|
1313
|
-
constructor(value, isShallow2) {
|
|
1314
|
-
this.dep = new Dep;
|
|
1315
|
-
this["__v_isRef"] = true;
|
|
1316
|
-
this["__v_isShallow"] = false;
|
|
1317
|
-
this._rawValue = isShallow2 ? value : toRaw(value);
|
|
1318
|
-
this._value = isShallow2 ? value : toReactive(value);
|
|
1319
|
-
this["__v_isShallow"] = isShallow2;
|
|
1320
|
-
}
|
|
1321
|
-
get value() {
|
|
1322
|
-
if (true) {
|
|
1323
|
-
this.dep.track({
|
|
1324
|
-
target: this,
|
|
1325
|
-
type: "get",
|
|
1326
|
-
key: "value"
|
|
1327
|
-
});
|
|
1328
|
-
} else {}
|
|
1329
|
-
return this._value;
|
|
1330
|
-
}
|
|
1331
|
-
set value(newValue) {
|
|
1332
|
-
const oldValue = this._rawValue;
|
|
1333
|
-
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
1334
|
-
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
1335
|
-
if (hasChanged(newValue, oldValue)) {
|
|
1336
|
-
this._rawValue = newValue;
|
|
1337
|
-
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
1338
|
-
if (true) {
|
|
1339
|
-
this.dep.trigger({
|
|
1340
|
-
target: this,
|
|
1341
|
-
type: "set",
|
|
1342
|
-
key: "value",
|
|
1343
|
-
newValue,
|
|
1344
|
-
oldValue
|
|
1345
|
-
});
|
|
1346
|
-
} else {}
|
|
1347
|
-
}
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
class ComputedRefImpl {
|
|
1351
|
-
constructor(fn, setter, isSSR) {
|
|
1352
|
-
this.fn = fn;
|
|
1353
|
-
this.setter = setter;
|
|
1354
|
-
this._value = undefined;
|
|
1355
|
-
this.dep = new Dep(this);
|
|
1356
|
-
this.__v_isRef = true;
|
|
1357
|
-
this.deps = undefined;
|
|
1358
|
-
this.depsTail = undefined;
|
|
1359
|
-
this.flags = 16;
|
|
1360
|
-
this.globalVersion = globalVersion - 1;
|
|
1361
|
-
this.next = undefined;
|
|
1362
|
-
this.effect = this;
|
|
1363
|
-
this["__v_isReadonly"] = !setter;
|
|
1364
|
-
this.isSSR = isSSR;
|
|
1365
|
-
}
|
|
1366
|
-
notify() {
|
|
1367
|
-
this.flags |= 16;
|
|
1368
|
-
if (!(this.flags & 8) && activeSub !== this) {
|
|
1369
|
-
batch(this, true);
|
|
1370
|
-
return true;
|
|
1371
|
-
} else if (true)
|
|
1372
|
-
;
|
|
1373
|
-
}
|
|
1374
|
-
get value() {
|
|
1375
|
-
const link = this.dep.track({
|
|
1376
|
-
target: this,
|
|
1377
|
-
type: "get",
|
|
1378
|
-
key: "value"
|
|
1379
|
-
});
|
|
1380
|
-
refreshComputed(this);
|
|
1381
|
-
if (link) {
|
|
1382
|
-
link.version = this.dep.version;
|
|
1383
|
-
}
|
|
1384
|
-
return this._value;
|
|
1385
|
-
}
|
|
1386
|
-
set value(newValue) {
|
|
1387
|
-
if (this.setter) {
|
|
1388
|
-
this.setter(newValue);
|
|
1389
|
-
} else if (true) {
|
|
1390
|
-
warn("Write operation failed: computed value is readonly");
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
}
|
|
1394
|
-
function computed(getterOrOptions, debugOptions, isSSR = false) {
|
|
1395
|
-
let getter;
|
|
1396
|
-
let setter;
|
|
1397
|
-
if (isFunction(getterOrOptions)) {
|
|
1398
|
-
getter = getterOrOptions;
|
|
1399
|
-
} else {
|
|
1400
|
-
getter = getterOrOptions.get;
|
|
1401
|
-
setter = getterOrOptions.set;
|
|
1402
|
-
}
|
|
1403
|
-
const cRef = new ComputedRefImpl(getter, setter, isSSR);
|
|
1404
|
-
if (debugOptions && !isSSR) {
|
|
1405
|
-
cRef.onTrack = debugOptions.onTrack;
|
|
1406
|
-
cRef.onTrigger = debugOptions.onTrigger;
|
|
1407
|
-
}
|
|
1408
|
-
return cRef;
|
|
1409
|
-
}
|
|
1410
|
-
// ../schema/src/guards.ts
|
|
1411
|
-
function isJsonObject(value) {
|
|
1412
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1413
|
-
}
|
|
1414
|
-
function isRef2(value) {
|
|
1415
|
-
return isJsonObject(value) && typeof value.$ref === "string";
|
|
1416
|
-
}
|
|
1417
|
-
function isFunctionDef(value) {
|
|
1418
|
-
return isJsonObject(value) && value.$prototype === "Function";
|
|
1419
|
-
}
|
|
1420
|
-
function isExpressionDef(value) {
|
|
1421
|
-
return isJsonObject(value) && isJsonObject(value.$expression);
|
|
1422
|
-
}
|
|
1423
|
-
function isNamedFormulaDef(value) {
|
|
1424
|
-
return isExpressionDef(value) && Array.isArray(value.parameters) && value.parameters.length > 0;
|
|
1425
|
-
}
|
|
1426
|
-
function hasStructuredBody(value) {
|
|
1427
|
-
return isFunctionDef(value) && Array.isArray(value.body);
|
|
1428
|
-
}
|
|
1429
|
-
function isPrototypeDef(value) {
|
|
1430
|
-
return isJsonObject(value) && typeof value.$prototype === "string" && value.$prototype !== "Function";
|
|
1431
|
-
}
|
|
1432
|
-
function isServerFnDef(value) {
|
|
1433
|
-
return isJsonObject(value) && value.timing === "server" && typeof value.$src === "string" && typeof value.$export === "string" && !value.$prototype;
|
|
1434
|
-
}
|
|
1435
|
-
var SCHEMA_KEYWORDS = new Set([
|
|
1436
|
-
"type",
|
|
1437
|
-
"enum",
|
|
1438
|
-
"minimum",
|
|
1439
|
-
"maximum",
|
|
1440
|
-
"minLength",
|
|
1441
|
-
"maxLength",
|
|
1442
|
-
"pattern",
|
|
1443
|
-
"format",
|
|
1444
|
-
"items",
|
|
1445
|
-
"properties",
|
|
1446
|
-
"required",
|
|
1447
|
-
"description",
|
|
1448
|
-
"title",
|
|
1449
|
-
"$comment"
|
|
1450
|
-
]);
|
|
1451
|
-
function isMappedArray(value) {
|
|
1452
|
-
return isJsonObject(value) && value.$prototype === "Array";
|
|
1453
|
-
}
|
|
1454
|
-
function isTemplateString(value) {
|
|
1455
|
-
return typeof value === "string" && value.includes("${");
|
|
1456
|
-
}
|
|
1457
|
-
function bodyReturnsValue(body) {
|
|
1458
|
-
return /\breturn\b[^\S\n]*(?![;}\s]|$)/.test(body);
|
|
1459
|
-
}
|
|
1460
|
-
function isNestedStyle(value) {
|
|
1461
|
-
return typeof value === "object" && value !== null;
|
|
1462
|
-
}
|
|
1463
|
-
function getNestedStyle(style, key) {
|
|
1464
|
-
const value = style?.[key];
|
|
1465
|
-
return isNestedStyle(value) ? value : undefined;
|
|
1466
|
-
}
|
|
1467
|
-
function ensureNestedStyle(style, key) {
|
|
1468
|
-
const existing = style[key];
|
|
1469
|
-
if (isNestedStyle(existing)) {
|
|
1470
|
-
return existing;
|
|
1471
|
-
}
|
|
1472
|
-
const created = {};
|
|
1473
|
-
style[key] = created;
|
|
1474
|
-
return created;
|
|
1475
|
-
}
|
|
1476
|
-
function isEventBinding(value) {
|
|
1477
|
-
return isRef2(value) || isFunctionDef(value) || isExpressionDef(value);
|
|
1478
|
-
}
|
|
1479
|
-
function getEventBinding(node, key) {
|
|
1480
|
-
const value = node[key];
|
|
1481
|
-
return isEventBinding(value) ? value : undefined;
|
|
1482
|
-
}
|
|
1483
|
-
function paramNames(parameters) {
|
|
1484
|
-
if (!parameters) {
|
|
1485
|
-
return [];
|
|
1486
|
-
}
|
|
1487
|
-
return parameters.map((p) => typeof p === "string" ? p : p.name);
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
// src/state.ts
|
|
1491
|
-
function getNodeAtPath(doc, path) {
|
|
1492
|
-
let node = doc;
|
|
1493
|
-
for (const key of path) {
|
|
1494
|
-
if (node == null) {
|
|
1495
|
-
return;
|
|
1496
|
-
}
|
|
1497
|
-
node = node[key];
|
|
1498
|
-
}
|
|
1499
|
-
return node;
|
|
1500
|
-
}
|
|
1501
|
-
function childList(node) {
|
|
1502
|
-
return Array.isArray(node?.children) ? node.children : [];
|
|
1503
|
-
}
|
|
1504
|
-
function normalizeArrayChildren(node) {
|
|
1505
|
-
if (!node || typeof node !== "object") {
|
|
1506
|
-
return node;
|
|
1507
|
-
}
|
|
1508
|
-
if (Array.isArray(node)) {
|
|
1509
|
-
for (const child of node) {
|
|
1510
|
-
normalizeArrayChildren(child);
|
|
1511
|
-
}
|
|
1512
|
-
return node;
|
|
1513
|
-
}
|
|
1514
|
-
const n = node;
|
|
1515
|
-
const { children } = n;
|
|
1516
|
-
if (children && typeof children === "object" && !Array.isArray(children) && children.$prototype === "Array") {
|
|
1517
|
-
n.children = [children];
|
|
1518
|
-
}
|
|
1519
|
-
if (Array.isArray(n.children)) {
|
|
1520
|
-
for (const child of n.children) {
|
|
1521
|
-
normalizeArrayChildren(child);
|
|
1522
|
-
}
|
|
1523
|
-
}
|
|
1524
|
-
if (n.$prototype === "Array" && n.map && typeof n.map === "object") {
|
|
1525
|
-
normalizeArrayChildren(n.map);
|
|
1526
|
-
}
|
|
1527
|
-
if (n.cases && typeof n.cases === "object") {
|
|
1528
|
-
for (const caseDef of Object.values(n.cases)) {
|
|
1529
|
-
normalizeArrayChildren(caseDef);
|
|
1530
|
-
}
|
|
1531
|
-
}
|
|
1532
|
-
return node;
|
|
1533
|
-
}
|
|
1534
|
-
function parentElementPath(path) {
|
|
1535
|
-
return path.length >= 2 ? path.slice(0, -2) : null;
|
|
1536
|
-
}
|
|
1537
|
-
function childIndex(path) {
|
|
1538
|
-
return path.at(-1);
|
|
1539
|
-
}
|
|
1540
|
-
function pathKey(path) {
|
|
1541
|
-
return path.join("/");
|
|
1542
|
-
}
|
|
1543
|
-
function pathsEqual(a, b) {
|
|
1544
|
-
if (a === b) {
|
|
1545
|
-
return true;
|
|
1546
|
-
}
|
|
1547
|
-
if (!a || !b || a.length !== b.length) {
|
|
1548
|
-
return false;
|
|
1549
|
-
}
|
|
1550
|
-
return a.every((v, i) => v === b[i]);
|
|
1551
|
-
}
|
|
1552
|
-
function isAncestor(path, descendant) {
|
|
1553
|
-
if (path.length > descendant.length) {
|
|
1554
|
-
return false;
|
|
1555
|
-
}
|
|
1556
|
-
return path.every((v, i) => v === descendant[i]);
|
|
1557
|
-
}
|
|
1558
|
-
function flattenTree(doc, path = [], depth = 0) {
|
|
1559
|
-
const rows = [];
|
|
1560
|
-
collectRows(doc, path, depth, rows, false);
|
|
1561
|
-
return rows;
|
|
1562
|
-
}
|
|
1563
|
-
function collectRows(doc, path, depth, out, skipSelf) {
|
|
1564
|
-
if (typeof doc === "string" || typeof doc === "number" || typeof doc === "boolean") {
|
|
1565
|
-
if (!skipSelf) {
|
|
1566
|
-
out.push({ depth, node: doc, nodeType: "text", path });
|
|
1567
|
-
}
|
|
1568
|
-
return;
|
|
1569
|
-
}
|
|
1570
|
-
if (doc.$prototype === "Array") {
|
|
1571
|
-
if (!skipSelf) {
|
|
1572
|
-
out.push({ depth, node: doc, nodeType: "map", path });
|
|
1573
|
-
}
|
|
1574
|
-
const mapDef = doc.map;
|
|
1575
|
-
if (mapDef && typeof mapDef === "object") {
|
|
1576
|
-
collectRows(mapDef, [...path, "map"], depth + 1, out, false);
|
|
1577
|
-
}
|
|
1578
|
-
return;
|
|
1579
|
-
}
|
|
1580
|
-
if (!skipSelf) {
|
|
1581
|
-
out.push({ depth, node: doc, nodeType: "element", path });
|
|
1582
|
-
}
|
|
1583
|
-
if (doc.$props && (doc.tagName || "").includes("-") && !Array.isArray(doc.children)) {
|
|
1584
|
-
return;
|
|
1585
|
-
}
|
|
1586
|
-
const { children } = doc;
|
|
1587
|
-
if (Array.isArray(children)) {
|
|
1588
|
-
for (let i = 0;i < children.length; i++) {
|
|
1589
|
-
const childPath = [...path, "children", i];
|
|
1590
|
-
collectRows(children[i], childPath, depth + 1, out, false);
|
|
1591
|
-
}
|
|
1592
|
-
} else if (children && typeof children === "object" && children.$prototype === "Array") {
|
|
1593
|
-
collectRows(children, [...path, "children"], depth + 1, out, false);
|
|
1594
|
-
}
|
|
1595
|
-
if (doc.$switch && doc.cases && typeof doc.cases === "object") {
|
|
1596
|
-
for (const [caseName, caseDef] of Object.entries(doc.cases)) {
|
|
1597
|
-
const casePath = [...path, "cases", caseName];
|
|
1598
|
-
if (caseDef && typeof caseDef === "object" && caseDef.$ref) {
|
|
1599
|
-
out.push({
|
|
1600
|
-
depth: depth + 1,
|
|
1601
|
-
node: caseDef,
|
|
1602
|
-
nodeType: "case-ref",
|
|
1603
|
-
path: casePath
|
|
1604
|
-
});
|
|
1605
|
-
} else if (caseDef && typeof caseDef === "object") {
|
|
1606
|
-
out.push({
|
|
1607
|
-
depth: depth + 1,
|
|
1608
|
-
node: caseDef,
|
|
1609
|
-
nodeType: "case",
|
|
1610
|
-
path: casePath
|
|
1611
|
-
});
|
|
1612
|
-
collectRows(caseDef, casePath, depth + 2, out, true);
|
|
1613
|
-
}
|
|
1614
|
-
}
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
function nodeLabel(node) {
|
|
1618
|
-
if (!node) {
|
|
1619
|
-
return "?";
|
|
1620
|
-
}
|
|
1621
|
-
if (node.$prototype === "Array") {
|
|
1622
|
-
const { items } = node;
|
|
1623
|
-
const ref2 = (isRef2(items) ? items.$ref : undefined) || "items";
|
|
1624
|
-
return `Repeater → ${ref2}`;
|
|
1625
|
-
}
|
|
1626
|
-
if (node.$title) {
|
|
1627
|
-
return node.$title;
|
|
1628
|
-
}
|
|
1629
|
-
if (node.$id) {
|
|
1630
|
-
return node.$id;
|
|
1631
|
-
}
|
|
1632
|
-
if (node.tagName === "slot") {
|
|
1633
|
-
const name = node.attributes?.name;
|
|
1634
|
-
return typeof name === "string" && name.trim() ? `slot: ${name.trim()}` : "slot";
|
|
1635
|
-
}
|
|
1636
|
-
const tag = node.tagName ?? "div";
|
|
1637
|
-
const suffix = node.$switch ? " ⇆" : "";
|
|
1638
|
-
if (typeof node.textContent === "string" && node.textContent.length > 0) {
|
|
1639
|
-
return `${tag} — ${node.textContent.slice(0, 24)}${suffix}`;
|
|
1640
|
-
}
|
|
1641
|
-
return tag + suffix;
|
|
1642
|
-
}
|
|
1643
|
-
function createState(doc) {
|
|
1644
|
-
const initial = { document: doc, selection: null };
|
|
1645
|
-
return {
|
|
1646
|
-
canvas: {
|
|
1647
|
-
error: null,
|
|
1648
|
-
scope: null,
|
|
1649
|
-
status: "idle"
|
|
1650
|
-
},
|
|
1651
|
-
content: { frontmatter: {} },
|
|
1652
|
-
dirty: false,
|
|
1653
|
-
document: doc,
|
|
1654
|
-
documentPath: null,
|
|
1655
|
-
documentStack: [],
|
|
1656
|
-
fileHandle: null,
|
|
1657
|
-
handlersSource: null,
|
|
1658
|
-
history: [initial],
|
|
1659
|
-
historyIndex: 0,
|
|
1660
|
-
hover: null,
|
|
1661
|
-
mode: "component",
|
|
1662
|
-
selection: null,
|
|
1663
|
-
ui: {
|
|
1664
|
-
activeMedia: null,
|
|
1665
|
-
activeSelector: null,
|
|
1666
|
-
editingFunction: null,
|
|
1667
|
-
featureToggles: {},
|
|
1668
|
-
gitBranches: null,
|
|
1669
|
-
gitCommitMessage: "",
|
|
1670
|
-
gitDiffState: null,
|
|
1671
|
-
gitError: null,
|
|
1672
|
-
gitLoading: false,
|
|
1673
|
-
gitStatus: null,
|
|
1674
|
-
inspectorSections: {},
|
|
1675
|
-
pendingInlineEdit: null,
|
|
1676
|
-
rightTab: "properties",
|
|
1677
|
-
settingsTab: "stylebook",
|
|
1678
|
-
styleFilter: "",
|
|
1679
|
-
styleFilterActive: false,
|
|
1680
|
-
styleSections: {},
|
|
1681
|
-
styleShorthands: {},
|
|
1682
|
-
stylebookCustomizedOnly: false,
|
|
1683
|
-
stylebookFilter: "",
|
|
1684
|
-
stylebookSelection: null,
|
|
1685
|
-
stylebookTab: "elements",
|
|
1686
|
-
zoom: 1
|
|
1687
|
-
}
|
|
1688
|
-
};
|
|
1689
|
-
}
|
|
1690
|
-
var projectState = null;
|
|
1691
|
-
function setProjectState(ps) {
|
|
1692
|
-
projectState = ps;
|
|
1693
|
-
}
|
|
1694
|
-
function requireProjectState() {
|
|
1695
|
-
return projectState;
|
|
1696
|
-
}
|
|
1697
|
-
|
|
1698
|
-
// src/utils/studio-utils.ts
|
|
1699
|
-
function camelToKebab(str) {
|
|
1700
|
-
return str.replaceAll(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
1701
|
-
}
|
|
1702
|
-
function camelToLabel(prop) {
|
|
1703
|
-
return prop.replaceAll(/([A-Z])/g, " $1").replace(/^./, (c) => c.toUpperCase());
|
|
1704
|
-
}
|
|
1705
|
-
function toCamelCase(str) {
|
|
1706
|
-
return str.replaceAll(/[^a-zA-Z0-9]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^[A-Z]/, (c) => c.toLowerCase());
|
|
1707
|
-
}
|
|
1708
|
-
function kebabToLabel(val) {
|
|
1709
|
-
return val.replaceAll(/(^|-)(\w)/g, (_, sep, c) => (sep ? " " : "") + c.toUpperCase());
|
|
1710
|
-
}
|
|
1711
|
-
function propLabel(entry, prop) {
|
|
1712
|
-
return entry?.$label || camelToLabel(prop);
|
|
1713
|
-
}
|
|
1714
|
-
function attrLabel(entry, attr) {
|
|
1715
|
-
if (entry?.$label) {
|
|
1716
|
-
return entry.$label;
|
|
1717
|
-
}
|
|
1718
|
-
if (attr.includes("-")) {
|
|
1719
|
-
return attr.replaceAll(/(^|-)(\w)/g, (_, sep, c) => (sep ? " " : "") + c.toUpperCase());
|
|
1720
|
-
}
|
|
1721
|
-
return camelToLabel(attr);
|
|
1722
|
-
}
|
|
1723
|
-
function abbreviateValue(val) {
|
|
1724
|
-
const map = {
|
|
1725
|
-
baseline: "base",
|
|
1726
|
-
column: "col",
|
|
1727
|
-
"column-reverse": "col-r",
|
|
1728
|
-
contents: "cnt",
|
|
1729
|
-
"flex-end": "end",
|
|
1730
|
-
"flex-start": "start",
|
|
1731
|
-
"flow-root": "flow",
|
|
1732
|
-
inline: "inl",
|
|
1733
|
-
"inline-block": "i-blk",
|
|
1734
|
-
"inline-flex": "i-flx",
|
|
1735
|
-
"inline-grid": "i-grd",
|
|
1736
|
-
normal: "norm",
|
|
1737
|
-
nowrap: "no-wr",
|
|
1738
|
-
"row-reverse": "row-r",
|
|
1739
|
-
"space-around": "arnd",
|
|
1740
|
-
"space-between": "betw",
|
|
1741
|
-
"space-evenly": "even",
|
|
1742
|
-
stretch: "str",
|
|
1743
|
-
"wrap-reverse": "wr-rev"
|
|
1744
|
-
};
|
|
1745
|
-
return map[val] || val;
|
|
1746
|
-
}
|
|
1747
|
-
function inferInputType(entry) {
|
|
1748
|
-
if (entry.$shorthand === true) {
|
|
1749
|
-
return "shorthand";
|
|
1750
|
-
}
|
|
1751
|
-
if (entry.$input === "button-group") {
|
|
1752
|
-
return "button-group";
|
|
1753
|
-
}
|
|
1754
|
-
if (entry.$input === "media") {
|
|
1755
|
-
return "media";
|
|
1756
|
-
}
|
|
1757
|
-
if (entry.format === "color") {
|
|
1758
|
-
return "color";
|
|
1759
|
-
}
|
|
1760
|
-
if (entry.format === "uri-reference") {
|
|
1761
|
-
return "media";
|
|
1762
|
-
}
|
|
1763
|
-
if (entry.$units !== undefined) {
|
|
1764
|
-
return "number-unit";
|
|
1765
|
-
}
|
|
1766
|
-
if (entry.type === "number") {
|
|
1767
|
-
return "number";
|
|
1768
|
-
}
|
|
1769
|
-
if (Array.isArray(entry.enum)) {
|
|
1770
|
-
return "select";
|
|
1771
|
-
}
|
|
1772
|
-
if (Array.isArray(entry.examples) || Array.isArray(entry.presets)) {
|
|
1773
|
-
return "combobox";
|
|
1774
|
-
}
|
|
1775
|
-
return "text";
|
|
1776
|
-
}
|
|
1777
|
-
function findContentTypeSchema(documentPath, projectConfig) {
|
|
1778
|
-
if (!documentPath || !projectConfig?.content) {
|
|
1779
|
-
return null;
|
|
1780
|
-
}
|
|
1781
|
-
const docPath = documentPath.replaceAll("\\", "/");
|
|
1782
|
-
for (const [name, def2] of Object.entries(projectConfig.content)) {
|
|
1783
|
-
if (!def2.source || !def2.schema) {
|
|
1784
|
-
continue;
|
|
1785
|
-
}
|
|
1786
|
-
const src = def2.source.replace(/^\.\//, "").replace(/\/$/, "");
|
|
1787
|
-
const hasExt = src.includes(".") && !src.endsWith("/");
|
|
1788
|
-
if (hasExt) {
|
|
1789
|
-
if (docPath === src || docPath.endsWith(`/${src}`)) {
|
|
1790
|
-
return { name, schema: def2.schema };
|
|
1791
|
-
}
|
|
1792
|
-
} else {
|
|
1793
|
-
const ext = def2.format === "json" ? ".json" : formatByName(def2.format)?.extensions[0] ?? defaultContentFormat()?.extensions[0] ?? ".json";
|
|
1794
|
-
if (docPath.startsWith(`${src}/`) && docPath.endsWith(ext)) {
|
|
1795
|
-
return { name, schema: def2.schema };
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
return null;
|
|
1800
|
-
}
|
|
1801
|
-
function friendlyNameToVar(name, prefix) {
|
|
1802
|
-
const slug = name.trim().toLowerCase().replaceAll(/[^a-z0-9\s-]/g, "").replaceAll(/\s+/g, "-").replaceAll(/-+/g, "-").replaceAll(/^-|-$/g, "");
|
|
1803
|
-
if (!slug) {
|
|
1804
|
-
return "";
|
|
1805
|
-
}
|
|
1806
|
-
return `${prefix}${slug}`;
|
|
1807
|
-
}
|
|
1808
|
-
function varDisplayName(varName, prefix) {
|
|
1809
|
-
return varName.replace(new RegExp(`^${prefix.replaceAll(/[.*+?^${}()|[\]\\]/g, String.raw`\$&`)}`), "").replace(/^--/, "").replaceAll("-", " ").replaceAll(/\b\w/g, (c) => c.toUpperCase()) || varName;
|
|
1810
|
-
}
|
|
1811
|
-
function parseCemType(typeText) {
|
|
1812
|
-
if (!typeText) {
|
|
1813
|
-
return { kind: "text" };
|
|
1814
|
-
}
|
|
1815
|
-
const t = typeText.trim().replaceAll(/\s*\|\s*undefined\b/g, "").trim();
|
|
1816
|
-
if (t === "boolean") {
|
|
1817
|
-
return { kind: "boolean" };
|
|
1818
|
-
}
|
|
1819
|
-
if (t === "number") {
|
|
1820
|
-
return { kind: "number" };
|
|
1821
|
-
}
|
|
1822
|
-
const enumMatch = t.match(/^'[^']*'(\s*\|\s*'[^']*')+$/);
|
|
1823
|
-
if (enumMatch) {
|
|
1824
|
-
const options = [...t.matchAll(/'([^']*)'/g)].map((m) => m[1]);
|
|
1825
|
-
return { kind: "combobox", options };
|
|
1826
|
-
}
|
|
1827
|
-
return { kind: "text" };
|
|
1828
|
-
}
|
|
1829
|
-
function jsonClone(value) {
|
|
1830
|
-
return JSON.parse(JSON.stringify(value));
|
|
1831
|
-
}
|
|
1832
|
-
// src/tabs/patch-ops.ts
|
|
1833
|
-
var _consumer = null;
|
|
1834
|
-
function setPatchConsumer(consumer) {
|
|
1835
|
-
_consumer = consumer;
|
|
1836
|
-
}
|
|
1837
|
-
function getPatchConsumer() {
|
|
1838
|
-
return _consumer;
|
|
1839
|
-
}
|
|
1840
|
-
var _recording = null;
|
|
1841
|
-
var _docOps = null;
|
|
1842
|
-
var _fmOps = null;
|
|
1843
|
-
var _invertible = true;
|
|
1844
|
-
function beginRecording() {
|
|
1845
|
-
_recording = [];
|
|
1846
|
-
_docOps = [];
|
|
1847
|
-
_fmOps = [];
|
|
1848
|
-
_invertible = true;
|
|
1849
|
-
}
|
|
1850
|
-
function recordPatch(op) {
|
|
1851
|
-
if (_recording) {
|
|
1852
|
-
_recording.push(op);
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
function recordDocOp(pair) {
|
|
1856
|
-
if (_docOps) {
|
|
1857
|
-
_docOps.push(pair);
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
function recordFmOp(op) {
|
|
1861
|
-
if (_fmOps) {
|
|
1862
|
-
_fmOps.push(op);
|
|
1863
|
-
}
|
|
1864
|
-
}
|
|
1865
|
-
function endRecording() {
|
|
1866
|
-
const record = {
|
|
1867
|
-
docOps: _docOps ?? [],
|
|
1868
|
-
fmOps: _fmOps ?? [],
|
|
1869
|
-
invertible: _invertible,
|
|
1870
|
-
ops: _recording ?? []
|
|
1871
|
-
};
|
|
1872
|
-
_recording = null;
|
|
1873
|
-
_docOps = null;
|
|
1874
|
-
_fmOps = null;
|
|
1875
|
-
_invertible = true;
|
|
1876
|
-
return record;
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
|
-
// src/tabs/transact.ts
|
|
1880
|
-
var HISTORY_LIMIT = 100;
|
|
1881
|
-
var CHECKPOINT_INTERVAL = 20;
|
|
1882
|
-
function patchHistoryEnabled() {
|
|
1883
|
-
try {
|
|
1884
|
-
return typeof localStorage === "undefined" || !localStorage.getItem("jx-legacy-history");
|
|
1885
|
-
} catch {
|
|
1886
|
-
return true;
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
function setKeyPair(path, key, before, after) {
|
|
1890
|
-
return {
|
|
1891
|
-
forward: { key, op: "set-key", path, value: after },
|
|
1892
|
-
inverse: { key, op: "set-key", path, value: before }
|
|
1893
|
-
};
|
|
1894
|
-
}
|
|
1895
|
-
function shiftPrefixedIndex(parentPath, path, spliceIndex, delta, inclusive) {
|
|
1896
|
-
const d = parentPath.length;
|
|
1897
|
-
const isProperPrefix = d < path.length && parentPath.every((seg, i) => seg === path[i]);
|
|
1898
|
-
if (!isProperPrefix || path[d] !== "children" || typeof path[d + 1] !== "number") {
|
|
1899
|
-
return path;
|
|
1900
|
-
}
|
|
1901
|
-
const idx = path[d + 1];
|
|
1902
|
-
if (inclusive ? idx < spliceIndex : idx <= spliceIndex) {
|
|
1903
|
-
return path;
|
|
1904
|
-
}
|
|
1905
|
-
const shifted = [...path];
|
|
1906
|
-
shifted[d + 1] = idx + delta;
|
|
1907
|
-
return shifted;
|
|
1908
|
-
}
|
|
1909
|
-
var _transactObserver = null;
|
|
1910
|
-
function setTransactObserver(fn) {
|
|
1911
|
-
_transactObserver = fn;
|
|
1912
|
-
}
|
|
1913
|
-
var _transactGate = null;
|
|
1914
|
-
function setTransactGate(fn) {
|
|
1915
|
-
_transactGate = fn;
|
|
1916
|
-
}
|
|
1917
|
-
function transactDoc(tab, mutationFn, {
|
|
1918
|
-
skipHistory = false,
|
|
1919
|
-
origin = "user",
|
|
1920
|
-
coalesceKey = null
|
|
1921
|
-
} = {}) {
|
|
1922
|
-
if (!tab) {
|
|
1923
|
-
return;
|
|
1924
|
-
}
|
|
1925
|
-
if (origin !== "remote" && _transactGate?.(tab, origin)) {
|
|
1926
|
-
return;
|
|
1927
|
-
}
|
|
1928
|
-
const selectionBefore = tab.session.selection ? [...tab.session.selection] : null;
|
|
1929
|
-
beginRecording();
|
|
1930
|
-
let record;
|
|
1931
|
-
try {
|
|
1932
|
-
mutationFn(tab);
|
|
1933
|
-
} finally {
|
|
1934
|
-
record = endRecording();
|
|
1935
|
-
}
|
|
1936
|
-
const raw = toRaw(tab.doc.document);
|
|
1937
|
-
const newRef = { ...raw };
|
|
1938
|
-
const consumer = getPatchConsumer();
|
|
1939
|
-
const verdict = consumer === null ? { patchable: false, reason: "no-patch-consumer" } : record.ops.length === 0 ? { patchable: false, reason: "unrecorded-mutation" } : consumer.classify(tab, record.ops);
|
|
1940
|
-
if (verdict.patchable) {
|
|
1941
|
-
consumer.markConsumed(newRef);
|
|
1942
|
-
}
|
|
1943
|
-
tab.doc.document = newRef;
|
|
1944
|
-
if (verdict.patchable) {
|
|
1945
|
-
try {
|
|
1946
|
-
consumer.apply(tab, record.ops, record);
|
|
1947
|
-
} catch (error) {
|
|
1948
|
-
consumer.escalate(`patch-apply-failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
1949
|
-
}
|
|
1950
|
-
}
|
|
1951
|
-
if (!skipHistory && !_batchTab) {
|
|
1952
|
-
pushHistoryEntry(tab, raw, record, selectionBefore, coalesceKey);
|
|
1953
|
-
}
|
|
1954
|
-
tab.doc.dirty = true;
|
|
1955
|
-
_transactObserver?.(tab, record, origin);
|
|
1956
|
-
}
|
|
1957
|
-
function pushHistoryEntry(tab, raw, record, selectionBefore, coalesceKey = null) {
|
|
1958
|
-
const truncated = tab.history.snapshots.slice(0, tab.history.index + 1);
|
|
1959
|
-
const useOps = patchHistoryEnabled() && record.invertible && (record.docOps.length > 0 || record.fmOps.length > 0);
|
|
1960
|
-
const prev = truncated.at(-1);
|
|
1961
|
-
if (coalesceKey && useOps && prev && prev.coalesceKey === coalesceKey && prev.inverseOps) {
|
|
1962
|
-
prev.forwardOps = [...prev.forwardOps ?? [], ...record.docOps.map((pair) => pair.forward)];
|
|
1963
|
-
prev.inverseOps = [...prev.inverseOps, ...record.docOps.map((pair) => pair.inverse)];
|
|
1964
|
-
prev.selection = tab.session.selection ? [...tab.session.selection] : null;
|
|
1965
|
-
if (prev.document) {
|
|
1966
|
-
prev.document = jsonClone(raw);
|
|
1967
|
-
}
|
|
1968
|
-
tab.history.snapshots = truncated;
|
|
1969
|
-
tab.history.index = truncated.length - 1;
|
|
1970
|
-
return;
|
|
1971
|
-
}
|
|
1972
|
-
const needCheckpoint = !useOps || truncated.length % CHECKPOINT_INTERVAL === 0;
|
|
1973
|
-
truncated.push({
|
|
1974
|
-
document: needCheckpoint ? jsonClone(raw) : null,
|
|
1975
|
-
fmOps: useOps && record.fmOps.length > 0 ? record.fmOps : null,
|
|
1976
|
-
forwardOps: useOps ? record.docOps.map((p) => p.forward) : null,
|
|
1977
|
-
inverseOps: useOps ? record.docOps.map((p) => p.inverse) : null,
|
|
1978
|
-
coalesceKey,
|
|
1979
|
-
selection: tab.session.selection ? [...tab.session.selection] : null,
|
|
1980
|
-
selectionBefore
|
|
1981
|
-
});
|
|
1982
|
-
if (truncated.length > HISTORY_LIMIT) {
|
|
1983
|
-
if (!truncated[1].document) {
|
|
1984
|
-
truncated[1].document = materializeState(truncated, 1);
|
|
1985
|
-
}
|
|
1986
|
-
truncated.shift();
|
|
1987
|
-
}
|
|
1988
|
-
tab.history.snapshots = truncated;
|
|
1989
|
-
tab.history.index = truncated.length - 1;
|
|
1990
|
-
}
|
|
1991
|
-
function materializeState(snapshots, target) {
|
|
1992
|
-
let base = target;
|
|
1993
|
-
while (base >= 0 && !snapshots[base].document) {
|
|
1994
|
-
base -= 1;
|
|
1995
|
-
}
|
|
1996
|
-
if (base < 0) {
|
|
1997
|
-
throw new Error("history-missing-checkpoint");
|
|
1998
|
-
}
|
|
1999
|
-
const doc = jsonClone(snapshots[base].document);
|
|
2000
|
-
for (let i = base + 1;i <= target; i++) {
|
|
2001
|
-
for (const op of snapshots[i].forwardOps ?? []) {
|
|
2002
|
-
applyDocOpToDoc(doc, op);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
return doc;
|
|
2006
|
-
}
|
|
2007
|
-
function transact(tab, fn, opts) {
|
|
2008
|
-
transactDoc(tab, (t) => fn(t.doc.document), opts);
|
|
2009
|
-
}
|
|
2010
|
-
function applyExternalDocOps(tab, ops) {
|
|
2011
|
-
transactDoc(tab, (t) => {
|
|
2012
|
-
for (const op of ops) {
|
|
2013
|
-
applyDocOp(t, op);
|
|
2014
|
-
}
|
|
2015
|
-
}, { origin: "remote", skipHistory: true });
|
|
2016
|
-
}
|
|
2017
|
-
var DOC_META_KEYS = new Set(["state", "$media", "$head", "$elements", "imports", "$layout"]);
|
|
2018
|
-
function applyDocOp(tab, op) {
|
|
2019
|
-
const prev = op.op === "set-key" ? getNodeAtPath(tab.doc.document, op.path)?.[op.key] : null;
|
|
2020
|
-
applyDocOpToDoc(tab.doc.document, op);
|
|
2021
|
-
recordDocOp({ forward: op, inverse: op });
|
|
2022
|
-
switch (op.op) {
|
|
2023
|
-
case "set-key": {
|
|
2024
|
-
if (DOC_META_KEYS.has(op.key)) {
|
|
2025
|
-
recordPatch({ key: op.key, op: "doc-meta" });
|
|
2026
|
-
} else if (op.key === "style") {
|
|
2027
|
-
recordPatch({ op: "set-style", path: op.path });
|
|
2028
|
-
} else if (op.key === "textContent") {
|
|
2029
|
-
recordPatch({ op: "set-text", path: op.path });
|
|
2030
|
-
} else if (op.key === "attributes" || op.key === "cases" || op.key === "$props") {
|
|
2031
|
-
recordPatch({ op: "replace", path: op.path });
|
|
2032
|
-
} else {
|
|
2033
|
-
const isEvent = op.key.startsWith("on") && (isEventBinding(op.value) || isEventBinding(prev));
|
|
2034
|
-
recordPatch({ isEvent, key: op.key, op: "set-prop", path: op.path });
|
|
2035
|
-
}
|
|
2036
|
-
return;
|
|
2037
|
-
}
|
|
2038
|
-
case "insert-child": {
|
|
2039
|
-
recordPatch({ index: op.index, op: "insert", parentPath: op.parentPath });
|
|
2040
|
-
return;
|
|
2041
|
-
}
|
|
2042
|
-
case "remove-child": {
|
|
2043
|
-
recordPatch({ op: "remove", path: [...op.parentPath, "children", op.index] });
|
|
2044
|
-
return;
|
|
2045
|
-
}
|
|
2046
|
-
case "set-child": {
|
|
2047
|
-
recordPatch({ op: "replace", path: [...op.parentPath, "children", op.index] });
|
|
2048
|
-
return;
|
|
2049
|
-
}
|
|
2050
|
-
case "move-child": {
|
|
2051
|
-
recordPatch({
|
|
2052
|
-
fromPath: [...op.fromParentPath, "children", op.fromIndex],
|
|
2053
|
-
op: "move",
|
|
2054
|
-
toIndex: op.toIndex,
|
|
2055
|
-
toParentPath: op.toParentPath
|
|
2056
|
-
});
|
|
2057
|
-
break;
|
|
2058
|
-
}
|
|
2059
|
-
default: {
|
|
2060
|
-
break;
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
}
|
|
2064
|
-
var _batchTab = null;
|
|
2065
|
-
var _batchEndNotifier = null;
|
|
2066
|
-
function setBatchEndNotifier(fn) {
|
|
2067
|
-
_batchEndNotifier = fn;
|
|
2068
|
-
}
|
|
2069
|
-
function beginBatch(tab) {
|
|
2070
|
-
_batchTab = tab;
|
|
2071
|
-
}
|
|
2072
|
-
function endBatch2() {
|
|
2073
|
-
const tab = _batchTab;
|
|
2074
|
-
if (tab && !_historyDelegates.has(tab)) {
|
|
2075
|
-
const raw = toRaw(tab.doc.document);
|
|
2076
|
-
const snapshot = {
|
|
2077
|
-
document: jsonClone(raw),
|
|
2078
|
-
selection: tab.session.selection ? [...tab.session.selection] : null
|
|
2079
|
-
};
|
|
2080
|
-
const truncated = tab.history.snapshots.slice(0, tab.history.index + 1);
|
|
2081
|
-
truncated.push(snapshot);
|
|
2082
|
-
if (truncated.length > HISTORY_LIMIT) {
|
|
2083
|
-
truncated.shift();
|
|
2084
|
-
}
|
|
2085
|
-
tab.history.snapshots = truncated;
|
|
2086
|
-
tab.history.index = truncated.length - 1;
|
|
2087
|
-
}
|
|
2088
|
-
_batchTab = null;
|
|
2089
|
-
if (tab) {
|
|
2090
|
-
_batchEndNotifier?.(tab);
|
|
2091
|
-
}
|
|
2092
|
-
}
|
|
2093
|
-
function isBatching() {
|
|
2094
|
-
return _batchTab !== null;
|
|
2095
|
-
}
|
|
2096
|
-
var _historyDelegates = new WeakMap;
|
|
2097
|
-
function setHistoryDelegate(tab, delegate) {
|
|
2098
|
-
if (delegate) {
|
|
2099
|
-
_historyDelegates.set(tab, delegate);
|
|
2100
|
-
} else {
|
|
2101
|
-
_historyDelegates.delete(tab);
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
function canUndo(tab) {
|
|
2105
|
-
const delegate = _historyDelegates.get(tab);
|
|
2106
|
-
return delegate ? delegate.canUndo(tab) : tab.history.index > 0;
|
|
2107
|
-
}
|
|
2108
|
-
function canRedo(tab) {
|
|
2109
|
-
const delegate = _historyDelegates.get(tab);
|
|
2110
|
-
return delegate ? delegate.canRedo(tab) : tab.history.index < tab.history.snapshots.length - 1;
|
|
2111
|
-
}
|
|
2112
|
-
function restoreState(tab, index) {
|
|
2113
|
-
const { snapshots } = tab.history;
|
|
2114
|
-
tab.doc.document = materializeState(snapshots, index);
|
|
2115
|
-
const snap = snapshots[index];
|
|
2116
|
-
tab.session.selection = snap.selection ? [...toRaw(snap.selection)] : null;
|
|
2117
|
-
}
|
|
2118
|
-
function assertHistoryConsistency(tab, index) {
|
|
2119
|
-
try {
|
|
2120
|
-
if (typeof localStorage === "undefined" || !localStorage.getItem("jx-canvas-debug")) {
|
|
2121
|
-
return;
|
|
2122
|
-
}
|
|
2123
|
-
} catch {
|
|
2124
|
-
return;
|
|
2125
|
-
}
|
|
2126
|
-
const expected = JSON.stringify(materializeState(tab.history.snapshots, index));
|
|
2127
|
-
const actual = JSON.stringify(jsonClone(toRaw(tab.doc.document)));
|
|
2128
|
-
if (expected !== actual) {
|
|
2129
|
-
console.error("jx history: ops-based undo/redo diverged from checkpoint replay", {
|
|
2130
|
-
index
|
|
2131
|
-
});
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
function undo(tab) {
|
|
2135
|
-
const delegate = _historyDelegates.get(tab);
|
|
2136
|
-
if (delegate) {
|
|
2137
|
-
delegate.undo(tab);
|
|
2138
|
-
return;
|
|
2139
|
-
}
|
|
2140
|
-
if (tab.history.index <= 0) {
|
|
2141
|
-
return;
|
|
2142
|
-
}
|
|
2143
|
-
const entry = tab.history.snapshots[tab.history.index];
|
|
2144
|
-
const inverseOps = patchHistoryEnabled() ? entry.inverseOps : null;
|
|
2145
|
-
const fmOps = patchHistoryEnabled() ? entry.fmOps : null;
|
|
2146
|
-
if (inverseOps && inverseOps.length > 0 || fmOps && fmOps.length > 0) {
|
|
2147
|
-
transactDoc(tab, (t) => {
|
|
2148
|
-
if (inverseOps) {
|
|
2149
|
-
for (let i = inverseOps.length - 1;i >= 0; i--) {
|
|
2150
|
-
applyDocOp(t, toRaw(inverseOps[i]));
|
|
2151
|
-
}
|
|
2152
|
-
}
|
|
2153
|
-
if (fmOps) {
|
|
2154
|
-
for (let i = fmOps.length - 1;i >= 0; i--) {
|
|
2155
|
-
const op = toRaw(fmOps[i]);
|
|
2156
|
-
applyFmState(t, op.field, op.before);
|
|
2157
|
-
}
|
|
2158
|
-
}
|
|
2159
|
-
}, { origin: "history", skipHistory: true });
|
|
2160
|
-
tab.session.selection = entry.selectionBefore ? [...toRaw(entry.selectionBefore)] : null;
|
|
2161
|
-
tab.history.index -= 1;
|
|
2162
|
-
assertHistoryConsistency(tab, tab.history.index);
|
|
2163
|
-
} else {
|
|
2164
|
-
tab.history.index -= 1;
|
|
2165
|
-
restoreState(tab, tab.history.index);
|
|
2166
|
-
}
|
|
2167
|
-
tab.doc.dirty = true;
|
|
2168
|
-
}
|
|
2169
|
-
function redo(tab) {
|
|
2170
|
-
const delegate = _historyDelegates.get(tab);
|
|
2171
|
-
if (delegate) {
|
|
2172
|
-
delegate.redo(tab);
|
|
2173
|
-
return;
|
|
2174
|
-
}
|
|
2175
|
-
if (tab.history.index >= tab.history.snapshots.length - 1) {
|
|
2176
|
-
return;
|
|
2177
|
-
}
|
|
2178
|
-
const entry = tab.history.snapshots[tab.history.index + 1];
|
|
2179
|
-
const forwardOps = patchHistoryEnabled() ? entry.forwardOps : null;
|
|
2180
|
-
const fmOps = patchHistoryEnabled() ? entry.fmOps : null;
|
|
2181
|
-
if (forwardOps && forwardOps.length > 0 || fmOps && fmOps.length > 0) {
|
|
2182
|
-
transactDoc(tab, (t) => {
|
|
2183
|
-
if (forwardOps) {
|
|
2184
|
-
for (const op of forwardOps) {
|
|
2185
|
-
applyDocOp(t, toRaw(op));
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
if (fmOps) {
|
|
2189
|
-
for (const op of fmOps) {
|
|
2190
|
-
const raw = toRaw(op);
|
|
2191
|
-
applyFmState(t, raw.field, raw.after);
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
}, { origin: "history", skipHistory: true });
|
|
2195
|
-
tab.session.selection = entry.selection ? [...toRaw(entry.selection)] : null;
|
|
2196
|
-
tab.history.index += 1;
|
|
2197
|
-
assertHistoryConsistency(tab, tab.history.index);
|
|
2198
|
-
} else {
|
|
2199
|
-
tab.history.index += 1;
|
|
2200
|
-
restoreState(tab, tab.history.index);
|
|
2201
|
-
}
|
|
2202
|
-
tab.doc.dirty = true;
|
|
2203
|
-
}
|
|
2204
|
-
function mutateInsertNode(tab, parentPath, index, nodeDef) {
|
|
2205
|
-
const parent = getNodeAtPath(tab.doc.document, parentPath);
|
|
2206
|
-
if (!parent) {
|
|
2207
|
-
return;
|
|
2208
|
-
}
|
|
2209
|
-
childArray(parent).splice(index, 0, structuredClone(nodeDef));
|
|
2210
|
-
recordPatch({ index, op: "insert", parentPath });
|
|
2211
|
-
recordDocOp({
|
|
2212
|
-
forward: { index, node: cloneValue(nodeDef), op: "insert-child", parentPath },
|
|
2213
|
-
inverse: { index, op: "remove-child", parentPath }
|
|
2214
|
-
});
|
|
2215
|
-
}
|
|
2216
|
-
function mutateRemoveNode(tab, path) {
|
|
2217
|
-
if (!path || path.length < 2) {
|
|
2218
|
-
return;
|
|
2219
|
-
}
|
|
2220
|
-
const elemPath = parentElementPath(path);
|
|
2221
|
-
const idx = childIndex(path);
|
|
2222
|
-
const [removed] = getNodeAtPath(tab.doc.document, elemPath).children.splice(idx, 1);
|
|
2223
|
-
recordPatch({ op: "remove", path });
|
|
2224
|
-
recordDocOp({
|
|
2225
|
-
forward: { index: idx, op: "remove-child", parentPath: elemPath },
|
|
2226
|
-
inverse: { index: idx, node: cloneValue(removed), op: "insert-child", parentPath: elemPath }
|
|
2227
|
-
});
|
|
2228
|
-
if (tab.session.selection && isAncestor(path, tab.session.selection)) {
|
|
2229
|
-
tab.session.selection = null;
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
function mutateDuplicateNode(tab, path) {
|
|
2233
|
-
if (!path || path.length < 2) {
|
|
2234
|
-
return;
|
|
2235
|
-
}
|
|
2236
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2237
|
-
if (!node) {
|
|
2238
|
-
return;
|
|
2239
|
-
}
|
|
2240
|
-
const elemPath = parentElementPath(path);
|
|
2241
|
-
const idx = childIndex(path);
|
|
2242
|
-
const clone = structuredClone(toRaw(node));
|
|
2243
|
-
getNodeAtPath(tab.doc.document, elemPath).children.splice(idx + 1, 0, clone);
|
|
2244
|
-
recordPatch({ index: idx + 1, op: "insert", parentPath: elemPath });
|
|
2245
|
-
recordDocOp({
|
|
2246
|
-
forward: { index: idx + 1, node: cloneValue(clone), op: "insert-child", parentPath: elemPath },
|
|
2247
|
-
inverse: { index: idx + 1, op: "remove-child", parentPath: elemPath }
|
|
2248
|
-
});
|
|
2249
|
-
tab.session.selection = [...elemPath, "children", idx + 1];
|
|
2250
|
-
}
|
|
2251
|
-
function mutateWrapNode(tab, path, wrapperTag = "div") {
|
|
2252
|
-
if (!path || path.length < 2) {
|
|
2253
|
-
return;
|
|
2254
|
-
}
|
|
2255
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2256
|
-
if (!node) {
|
|
2257
|
-
return;
|
|
2258
|
-
}
|
|
2259
|
-
const elemPath = parentElementPath(path);
|
|
2260
|
-
const idx = childIndex(path);
|
|
2261
|
-
const wrapper = {
|
|
2262
|
-
children: [structuredClone(toRaw(node))],
|
|
2263
|
-
tagName: wrapperTag
|
|
2264
|
-
};
|
|
2265
|
-
const original = cloneValue(node);
|
|
2266
|
-
getNodeAtPath(tab.doc.document, elemPath).children.splice(idx, 1, wrapper);
|
|
2267
|
-
recordPatch({ op: "replace", path });
|
|
2268
|
-
recordDocOp({
|
|
2269
|
-
forward: { index: idx, node: cloneValue(wrapper), op: "set-child", parentPath: elemPath },
|
|
2270
|
-
inverse: { index: idx, node: original, op: "set-child", parentPath: elemPath }
|
|
2271
|
-
});
|
|
2272
|
-
tab.session.selection = [...elemPath, "children", idx];
|
|
2273
|
-
}
|
|
2274
|
-
function mutateMoveNode(tab, fromPath, toParentPath, toIndex) {
|
|
2275
|
-
const doc = tab.doc.document;
|
|
2276
|
-
const fromParentPath = parentElementPath(fromPath);
|
|
2277
|
-
const fromIdx = childIndex(fromPath);
|
|
2278
|
-
if (!fromParentPath || typeof fromIdx !== "number") {
|
|
2279
|
-
return;
|
|
2280
|
-
}
|
|
2281
|
-
const fromParent = getNodeAtPath(doc, fromParentPath);
|
|
2282
|
-
const toParent = getNodeAtPath(doc, toParentPath);
|
|
2283
|
-
if (!fromParent || !Array.isArray(fromParent.children) || !toParent) {
|
|
2284
|
-
return;
|
|
2285
|
-
}
|
|
2286
|
-
const [node] = fromParent.children.splice(fromIdx, 1);
|
|
2287
|
-
if (node === undefined) {
|
|
2288
|
-
return;
|
|
2289
|
-
}
|
|
2290
|
-
let adjustedIndex = toIndex;
|
|
2291
|
-
if (fromParent === toParent && fromIdx < toIndex) {
|
|
2292
|
-
adjustedIndex -= 1;
|
|
2293
|
-
}
|
|
2294
|
-
childArray(toParent).splice(adjustedIndex, 0, node);
|
|
2295
|
-
recordPatch({ fromPath, op: "move", toIndex: adjustedIndex, toParentPath });
|
|
2296
|
-
recordDocOp({
|
|
2297
|
-
forward: {
|
|
2298
|
-
fromIndex: fromIdx,
|
|
2299
|
-
fromParentPath,
|
|
2300
|
-
op: "move-child",
|
|
2301
|
-
toIndex: adjustedIndex,
|
|
2302
|
-
toParentPath
|
|
2303
|
-
},
|
|
2304
|
-
inverse: {
|
|
2305
|
-
fromIndex: adjustedIndex,
|
|
2306
|
-
fromParentPath: shiftPrefixedIndex(fromParentPath, toParentPath, fromIdx, -1, false),
|
|
2307
|
-
op: "move-child",
|
|
2308
|
-
toIndex: fromIdx,
|
|
2309
|
-
toParentPath: shiftPrefixedIndex(toParentPath, fromParentPath, adjustedIndex, 1, true)
|
|
2310
|
-
}
|
|
2311
|
-
});
|
|
2312
|
-
if (pathsEqual(tab.session.selection, fromPath)) {
|
|
2313
|
-
let idx = toIndex;
|
|
2314
|
-
if (fromParentPath.length === toParentPath.length && fromParentPath.every((v, i) => v === toParentPath[i]) && fromIdx < toIndex) {
|
|
2315
|
-
idx = toIndex - 1;
|
|
2316
|
-
}
|
|
2317
|
-
tab.session.selection = [...toParentPath, "children", idx];
|
|
2318
|
-
}
|
|
2319
|
-
}
|
|
2320
|
-
function mutateUpdateProperty(tab, path, key, value) {
|
|
2321
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2322
|
-
const prev = node[key];
|
|
2323
|
-
const before = cloneValue(prev);
|
|
2324
|
-
if (value === undefined || value === null || value === "") {
|
|
2325
|
-
delete node[key];
|
|
2326
|
-
} else {
|
|
2327
|
-
node[key] = value;
|
|
2328
|
-
}
|
|
2329
|
-
recordDocOp(setKeyPair(path, key, before, cloneValue(node[key])));
|
|
2330
|
-
if (key === "textContent") {
|
|
2331
|
-
recordPatch({ op: "set-text", path });
|
|
2332
|
-
} else if (key === "style") {
|
|
2333
|
-
recordPatch({ op: "set-style", path });
|
|
2334
|
-
} else {
|
|
2335
|
-
const bindingValue = value === undefined || value === null || value === "" ? prev : value;
|
|
2336
|
-
const isEvent = key.startsWith("on") && isEventBinding(bindingValue);
|
|
2337
|
-
recordPatch({ isEvent, key, op: "set-prop", path });
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
function mutateUpdateStyle(tab, path, prop, value) {
|
|
2341
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2342
|
-
const styleBefore = cloneValue(node.style);
|
|
2343
|
-
if (!node.style) {
|
|
2344
|
-
node.style = {};
|
|
2345
|
-
}
|
|
2346
|
-
if (value === undefined || value === "") {
|
|
2347
|
-
delete node.style[prop];
|
|
2348
|
-
} else {
|
|
2349
|
-
node.style[prop] = value;
|
|
2350
|
-
}
|
|
2351
|
-
if (Object.keys(node.style).length === 0) {
|
|
2352
|
-
delete node.style;
|
|
2353
|
-
}
|
|
2354
|
-
recordDocOp(setKeyPair(path, "style", styleBefore, cloneValue(node.style)));
|
|
2355
|
-
recordPatch({ op: "set-style", path });
|
|
2356
|
-
}
|
|
2357
|
-
function mutateUpdateAttribute(tab, path, attr, value) {
|
|
2358
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2359
|
-
const attrsBefore = cloneValue(node.attributes);
|
|
2360
|
-
if (!node.attributes) {
|
|
2361
|
-
node.attributes = {};
|
|
2362
|
-
}
|
|
2363
|
-
if (value === undefined || value === "") {
|
|
2364
|
-
delete node.attributes[attr];
|
|
2365
|
-
} else {
|
|
2366
|
-
node.attributes[attr] = value;
|
|
2367
|
-
}
|
|
2368
|
-
if (Object.keys(node.attributes).length === 0) {
|
|
2369
|
-
delete node.attributes;
|
|
2370
|
-
}
|
|
2371
|
-
recordDocOp(setKeyPair(path, "attributes", attrsBefore, cloneValue(node.attributes)));
|
|
2372
|
-
recordPatch({ attr, op: "set-attr", path });
|
|
2373
|
-
}
|
|
2374
|
-
function mutateUpdateMediaStyle(tab, path, mediaName, prop, value) {
|
|
2375
|
-
if (!mediaName) {
|
|
2376
|
-
return mutateUpdateStyle(tab, path, prop, value);
|
|
2377
|
-
}
|
|
2378
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2379
|
-
const styleBefore = cloneValue(node.style);
|
|
2380
|
-
if (!node.style) {
|
|
2381
|
-
node.style = {};
|
|
2382
|
-
}
|
|
2383
|
-
const key = `@${mediaName}`;
|
|
2384
|
-
const media = ensureNestedStyle(node.style, key);
|
|
2385
|
-
if (value === undefined || value === "") {
|
|
2386
|
-
delete media[prop];
|
|
2387
|
-
if (Object.keys(media).length === 0) {
|
|
2388
|
-
delete node.style[key];
|
|
2389
|
-
}
|
|
2390
|
-
} else {
|
|
2391
|
-
media[prop] = value;
|
|
2392
|
-
}
|
|
2393
|
-
if (Object.keys(node.style).length === 0) {
|
|
2394
|
-
delete node.style;
|
|
2395
|
-
}
|
|
2396
|
-
recordDocOp(setKeyPair(path, "style", styleBefore, cloneValue(node.style)));
|
|
2397
|
-
recordPatch({ op: "set-style", path });
|
|
2398
|
-
}
|
|
2399
|
-
function mutateUpdateNestedStyle(tab, path, selector, prop, value) {
|
|
2400
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2401
|
-
const styleBefore = cloneValue(node.style);
|
|
2402
|
-
if (!node.style) {
|
|
2403
|
-
node.style = {};
|
|
2404
|
-
}
|
|
2405
|
-
const block = ensureNestedStyle(node.style, selector);
|
|
2406
|
-
if (value === undefined || value === "") {
|
|
2407
|
-
delete block[prop];
|
|
2408
|
-
if (Object.keys(block).length === 0) {
|
|
2409
|
-
delete node.style[selector];
|
|
2410
|
-
}
|
|
2411
|
-
} else {
|
|
2412
|
-
block[prop] = value;
|
|
2413
|
-
}
|
|
2414
|
-
if (Object.keys(node.style).length === 0) {
|
|
2415
|
-
delete node.style;
|
|
2416
|
-
}
|
|
2417
|
-
recordDocOp(setKeyPair(path, "style", styleBefore, cloneValue(node.style)));
|
|
2418
|
-
recordPatch({ op: "set-style", path });
|
|
2419
|
-
}
|
|
2420
|
-
function mutateUpdateMediaNestedStyle(tab, path, mediaName, selector, prop, value) {
|
|
2421
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2422
|
-
const styleBefore = cloneValue(node.style);
|
|
2423
|
-
if (!node.style) {
|
|
2424
|
-
node.style = {};
|
|
2425
|
-
}
|
|
2426
|
-
const key = `@${mediaName}`;
|
|
2427
|
-
const media = ensureNestedStyle(node.style, key);
|
|
2428
|
-
const block = ensureNestedStyle(media, selector);
|
|
2429
|
-
if (value === undefined || value === "") {
|
|
2430
|
-
delete block[prop];
|
|
2431
|
-
if (Object.keys(block).length === 0) {
|
|
2432
|
-
delete media[selector];
|
|
2433
|
-
}
|
|
2434
|
-
if (Object.keys(media).length === 0) {
|
|
2435
|
-
delete node.style[key];
|
|
2436
|
-
}
|
|
2437
|
-
} else {
|
|
2438
|
-
block[prop] = value;
|
|
2439
|
-
}
|
|
2440
|
-
if (Object.keys(node.style).length === 0) {
|
|
2441
|
-
delete node.style;
|
|
2442
|
-
}
|
|
2443
|
-
recordDocOp(setKeyPair(path, "style", styleBefore, cloneValue(node.style)));
|
|
2444
|
-
recordPatch({ op: "set-style", path });
|
|
2445
|
-
}
|
|
2446
|
-
function mutateUpdateNestedStylePath(tab, path, stylePath, prop, value) {
|
|
2447
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2448
|
-
const styleBefore = cloneValue(node.style);
|
|
2449
|
-
if (!node.style) {
|
|
2450
|
-
node.style = {};
|
|
2451
|
-
}
|
|
2452
|
-
let obj = node.style;
|
|
2453
|
-
for (const seg of stylePath) {
|
|
2454
|
-
obj = ensureNestedStyle(obj, seg);
|
|
2455
|
-
}
|
|
2456
|
-
if (value === undefined || value === "") {
|
|
2457
|
-
delete obj[prop];
|
|
2458
|
-
let cur = node.style;
|
|
2459
|
-
for (let i = 0;i < stylePath.length && cur; i++) {
|
|
2460
|
-
const child = getNestedStyle(cur, stylePath[i]);
|
|
2461
|
-
if (child && Object.keys(child).length === 0) {
|
|
2462
|
-
delete cur[stylePath[i]];
|
|
2463
|
-
break;
|
|
2464
|
-
}
|
|
2465
|
-
cur = child;
|
|
2466
|
-
}
|
|
2467
|
-
} else {
|
|
2468
|
-
obj[prop] = value;
|
|
2469
|
-
}
|
|
2470
|
-
if (Object.keys(node.style).length === 0) {
|
|
2471
|
-
delete node.style;
|
|
2472
|
-
}
|
|
2473
|
-
recordDocOp(setKeyPair(path, "style", styleBefore, cloneValue(node.style)));
|
|
2474
|
-
recordPatch({ op: "set-style", path });
|
|
2475
|
-
}
|
|
2476
|
-
function mutateUpdateMediaNestedStylePath(tab, path, mediaName, stylePath, prop, value) {
|
|
2477
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2478
|
-
const styleBefore = cloneValue(node.style);
|
|
2479
|
-
if (!node.style) {
|
|
2480
|
-
node.style = {};
|
|
2481
|
-
}
|
|
2482
|
-
const key = `@${mediaName}`;
|
|
2483
|
-
const media = ensureNestedStyle(node.style, key);
|
|
2484
|
-
let obj = media;
|
|
2485
|
-
for (const seg of stylePath) {
|
|
2486
|
-
obj = ensureNestedStyle(obj, seg);
|
|
2487
|
-
}
|
|
2488
|
-
if (value === undefined || value === "") {
|
|
2489
|
-
delete obj[prop];
|
|
2490
|
-
let cur = media;
|
|
2491
|
-
for (let i = 0;i < stylePath.length && cur; i++) {
|
|
2492
|
-
const child = getNestedStyle(cur, stylePath[i]);
|
|
2493
|
-
if (child && Object.keys(child).length === 0) {
|
|
2494
|
-
delete cur[stylePath[i]];
|
|
2495
|
-
break;
|
|
2496
|
-
}
|
|
2497
|
-
cur = child;
|
|
2498
|
-
}
|
|
2499
|
-
if (Object.keys(media).length === 0) {
|
|
2500
|
-
delete node.style[key];
|
|
2501
|
-
}
|
|
2502
|
-
} else {
|
|
2503
|
-
obj[prop] = value;
|
|
2504
|
-
}
|
|
2505
|
-
if (Object.keys(node.style).length === 0) {
|
|
2506
|
-
delete node.style;
|
|
2507
|
-
}
|
|
2508
|
-
recordDocOp(setKeyPair(path, "style", styleBefore, cloneValue(node.style)));
|
|
2509
|
-
recordPatch({ op: "set-style", path });
|
|
2510
|
-
}
|
|
2511
|
-
function mutateReplaceStyle(tab, path, style) {
|
|
2512
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2513
|
-
const styleBefore = cloneValue(node.style);
|
|
2514
|
-
if (style && Object.keys(style).length > 0) {
|
|
2515
|
-
node.style = style;
|
|
2516
|
-
} else {
|
|
2517
|
-
delete node.style;
|
|
2518
|
-
}
|
|
2519
|
-
recordDocOp(setKeyPair(path, "style", styleBefore, cloneValue(node.style)));
|
|
2520
|
-
recordPatch({ op: "set-style", path });
|
|
2521
|
-
}
|
|
2522
|
-
function mutateAddDef(tab, name, def2) {
|
|
2523
|
-
const doc = tab.doc.document;
|
|
2524
|
-
const before = cloneValue(doc.state);
|
|
2525
|
-
if (!doc.state) {
|
|
2526
|
-
doc.state = {};
|
|
2527
|
-
}
|
|
2528
|
-
doc.state[name] = def2;
|
|
2529
|
-
recordDocOp(setKeyPair([], "state", before, cloneValue(doc.state)));
|
|
2530
|
-
recordPatch({ key: "state", op: "doc-meta" });
|
|
2531
|
-
}
|
|
2532
|
-
function mutateRemoveDef(tab, name) {
|
|
2533
|
-
const doc = tab.doc.document;
|
|
2534
|
-
if (doc.state) {
|
|
2535
|
-
const before = cloneValue(doc.state);
|
|
2536
|
-
delete doc.state[name];
|
|
2537
|
-
if (Object.keys(doc.state).length === 0) {
|
|
2538
|
-
delete doc.state;
|
|
2539
|
-
}
|
|
2540
|
-
recordDocOp(setKeyPair([], "state", before, cloneValue(doc.state)));
|
|
2541
|
-
recordPatch({ key: "state", op: "doc-meta" });
|
|
2542
|
-
}
|
|
2543
|
-
}
|
|
2544
|
-
function mutateUpdateDef(tab, name, updates) {
|
|
2545
|
-
const doc = tab.doc.document;
|
|
2546
|
-
const stateBefore = cloneValue(doc.state);
|
|
2547
|
-
if (!doc.state) {
|
|
2548
|
-
doc.state = {};
|
|
2549
|
-
}
|
|
2550
|
-
const existing = doc.state[name];
|
|
2551
|
-
const entry = existing == null ? {} : typeof existing !== "object" || Array.isArray(existing) ? { default: existing } : existing;
|
|
2552
|
-
doc.state[name] = entry;
|
|
2553
|
-
Object.assign(entry, updates);
|
|
2554
|
-
for (const k of Object.keys(entry)) {
|
|
2555
|
-
if (entry[k] === undefined || entry[k] === null) {
|
|
2556
|
-
delete entry[k];
|
|
2557
|
-
}
|
|
2558
|
-
}
|
|
2559
|
-
recordDocOp(setKeyPair([], "state", stateBefore, cloneValue(doc.state)));
|
|
2560
|
-
recordPatch({ key: "state", op: "doc-meta" });
|
|
2561
|
-
}
|
|
2562
|
-
function mutateRenameDef(tab, oldName, newName) {
|
|
2563
|
-
const doc = tab.doc.document;
|
|
2564
|
-
if (!doc.state || !doc.state[oldName]) {
|
|
2565
|
-
return;
|
|
2566
|
-
}
|
|
2567
|
-
const before = cloneValue(doc.state);
|
|
2568
|
-
doc.state[newName] = doc.state[oldName];
|
|
2569
|
-
delete doc.state[oldName];
|
|
2570
|
-
recordDocOp(setKeyPair([], "state", before, cloneValue(doc.state)));
|
|
2571
|
-
recordPatch({ key: "state", op: "doc-meta" });
|
|
2572
|
-
}
|
|
2573
|
-
function mutateUpdateMedia(tab, name, query) {
|
|
2574
|
-
const doc = tab.doc.document;
|
|
2575
|
-
const mediaBefore = cloneValue(doc.$media);
|
|
2576
|
-
if (!doc.$media) {
|
|
2577
|
-
doc.$media = {};
|
|
2578
|
-
}
|
|
2579
|
-
if (query === undefined || query === "") {
|
|
2580
|
-
delete doc.$media[name];
|
|
2581
|
-
if (Object.keys(doc.$media).length === 0) {
|
|
2582
|
-
delete doc.$media;
|
|
2583
|
-
}
|
|
2584
|
-
} else {
|
|
2585
|
-
doc.$media[name] = query;
|
|
2586
|
-
}
|
|
2587
|
-
recordDocOp(setKeyPair([], "$media", mediaBefore, cloneValue(doc.$media)));
|
|
2588
|
-
recordPatch({ key: "$media", op: "doc-meta" });
|
|
2589
|
-
}
|
|
2590
|
-
function mutateUpdateProp(tab, path, propName, value) {
|
|
2591
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2592
|
-
const propsBefore = cloneValue(node.$props);
|
|
2593
|
-
if (!node.$props) {
|
|
2594
|
-
node.$props = {};
|
|
2595
|
-
}
|
|
2596
|
-
if (value === undefined || value === null || value === "") {
|
|
2597
|
-
delete node.$props[propName];
|
|
2598
|
-
} else {
|
|
2599
|
-
node.$props[propName] = value;
|
|
2600
|
-
}
|
|
2601
|
-
if (Object.keys(node.$props).length === 0) {
|
|
2602
|
-
delete node.$props;
|
|
2603
|
-
}
|
|
2604
|
-
recordDocOp(setKeyPair(path, "$props", propsBefore, cloneValue(node.$props)));
|
|
2605
|
-
recordPatch({ op: "replace", path });
|
|
2606
|
-
}
|
|
2607
|
-
function mutateAddSwitchCase(tab, path, caseName, caseDef) {
|
|
2608
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2609
|
-
const before = cloneValue(node.cases);
|
|
2610
|
-
if (!node.cases) {
|
|
2611
|
-
node.cases = {};
|
|
2612
|
-
}
|
|
2613
|
-
node.cases[caseName] = caseDef || { tagName: "div", textContent: caseName };
|
|
2614
|
-
recordDocOp(setKeyPair(path, "cases", before, cloneValue(node.cases)));
|
|
2615
|
-
recordPatch({ op: "replace", path });
|
|
2616
|
-
}
|
|
2617
|
-
function mutateRemoveSwitchCase(tab, path, caseName) {
|
|
2618
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2619
|
-
if (node.cases) {
|
|
2620
|
-
const before = cloneValue(node.cases);
|
|
2621
|
-
delete node.cases[caseName];
|
|
2622
|
-
recordDocOp(setKeyPair(path, "cases", before, cloneValue(node.cases)));
|
|
2623
|
-
recordPatch({ op: "replace", path });
|
|
2624
|
-
}
|
|
2625
|
-
}
|
|
2626
|
-
function mutateRenameSwitchCase(tab, path, oldName, newName) {
|
|
2627
|
-
const node = getNodeAtPath(tab.doc.document, path);
|
|
2628
|
-
if (!node.cases || !node.cases[oldName]) {
|
|
2629
|
-
return;
|
|
2630
|
-
}
|
|
2631
|
-
const before = cloneValue(node.cases);
|
|
2632
|
-
node.cases[newName] = node.cases[oldName];
|
|
2633
|
-
delete node.cases[oldName];
|
|
2634
|
-
recordDocOp(setKeyPair(path, "cases", before, cloneValue(node.cases)));
|
|
2635
|
-
recordPatch({ op: "replace", path });
|
|
2636
|
-
}
|
|
2637
|
-
function mutateUpdateFrontmatter(tab, field, value) {
|
|
2638
|
-
const fm = tab.doc.content.frontmatter;
|
|
2639
|
-
const before = Object.hasOwn(fm, field) ? cloneValue(fm[field]) : undefined;
|
|
2640
|
-
const deletes = value === undefined || value === null || value === "";
|
|
2641
|
-
if (deletes) {
|
|
2642
|
-
delete fm[field];
|
|
2643
|
-
} else {
|
|
2644
|
-
fm[field] = value;
|
|
2645
|
-
}
|
|
2646
|
-
const after = deletes ? undefined : cloneValue(value);
|
|
2647
|
-
recordFmOp({ after, before, field });
|
|
2648
|
-
tab.doc.dirty = true;
|
|
2649
|
-
}
|
|
2650
|
-
function applyFmState(tab, field, value) {
|
|
2651
|
-
if (value === undefined) {
|
|
2652
|
-
delete tab.doc.content.frontmatter[field];
|
|
2653
|
-
} else {
|
|
2654
|
-
tab.doc.content.frontmatter[field] = value;
|
|
2655
|
-
}
|
|
2656
|
-
}
|
|
2657
|
-
|
|
2658
|
-
// src/collab/collab-state.ts
|
|
2659
|
-
var states = new WeakMap;
|
|
2660
|
-
var attachedPaths = new Map;
|
|
2661
|
-
function collabState(tab) {
|
|
2662
|
-
const key = toRaw(tab);
|
|
2663
|
-
let state = states.get(key);
|
|
2664
|
-
if (!state) {
|
|
2665
|
-
state = reactive({
|
|
2666
|
-
active: false,
|
|
2667
|
-
peers: [],
|
|
2668
|
-
readOnly: false,
|
|
2669
|
-
sourceCanonical: false,
|
|
2670
|
-
status: "detached"
|
|
2671
|
-
});
|
|
2672
|
-
states.set(key, state);
|
|
2673
|
-
}
|
|
2674
|
-
return state;
|
|
2675
|
-
}
|
|
2676
|
-
function registerCollabPath(path) {
|
|
2677
|
-
attachedPaths.set(path, (attachedPaths.get(path) ?? 0) + 1);
|
|
2678
|
-
}
|
|
2679
|
-
function unregisterCollabPath(path) {
|
|
2680
|
-
const count = attachedPaths.get(path) ?? 0;
|
|
2681
|
-
if (count <= 1) {
|
|
2682
|
-
attachedPaths.delete(path);
|
|
2683
|
-
} else {
|
|
2684
|
-
attachedPaths.set(path, count - 1);
|
|
2685
|
-
}
|
|
2686
|
-
}
|
|
2687
|
-
function isCollabPath(path) {
|
|
2688
|
-
return attachedPaths.has(path.replaceAll("\\", "/"));
|
|
2689
|
-
}
|
|
2690
|
-
|
|
2691
|
-
// src/collab/collab-session.ts
|
|
2692
|
-
var SYNC_TIMEOUT_MS = 8000;
|
|
2693
|
-
var MIRROR_DEBOUNCE_MS = 800;
|
|
2694
|
-
var MIRROR_MAX_LAG_MS = 2500;
|
|
2695
|
-
var collabModulePromise = null;
|
|
2696
|
-
function loadCollab() {
|
|
2697
|
-
collabModulePromise ??= import("./index-baeg2x3y.js");
|
|
2698
|
-
return collabModulePromise;
|
|
2699
|
-
}
|
|
2700
|
-
function maybePlatform() {
|
|
2701
|
-
try {
|
|
2702
|
-
return getPlatform();
|
|
2703
|
-
} catch {
|
|
2704
|
-
return null;
|
|
2705
|
-
}
|
|
2706
|
-
}
|
|
2707
|
-
var _serialize = null;
|
|
2708
|
-
function configureCollabSerializer(fn) {
|
|
2709
|
-
_serialize = fn;
|
|
2710
|
-
}
|
|
2711
|
-
var _parse = null;
|
|
2712
|
-
function configureCollabParser(fn) {
|
|
2713
|
-
_parse = fn;
|
|
2714
|
-
}
|
|
2715
|
-
var _notify = () => {};
|
|
2716
|
-
function configureCollabNotifier(fn) {
|
|
2717
|
-
_notify = fn ?? (() => {});
|
|
2718
|
-
}
|
|
2719
|
-
var runtimes = new WeakMap;
|
|
2720
|
-
function rawTab(tab) {
|
|
2721
|
-
return toRaw(tab);
|
|
2722
|
-
}
|
|
2723
|
-
function runtimeOf(tab) {
|
|
2724
|
-
return runtimes.get(rawTab(tab));
|
|
2725
|
-
}
|
|
2726
|
-
function runtimeFor(tab) {
|
|
2727
|
-
const key = rawTab(tab);
|
|
2728
|
-
let runtime = runtimes.get(key);
|
|
2729
|
-
if (!runtime) {
|
|
2730
|
-
runtime = { attaching: null, generation: 0, session: null, watcherInstalled: false };
|
|
2731
|
-
runtimes.set(key, runtime);
|
|
2732
|
-
}
|
|
2733
|
-
return runtime;
|
|
2734
|
-
}
|
|
2735
|
-
var hooksInstalled = false;
|
|
2736
|
-
function installGlobalHooks() {
|
|
2737
|
-
if (hooksInstalled) {
|
|
2738
|
-
return;
|
|
2739
|
-
}
|
|
2740
|
-
hooksInstalled = true;
|
|
2741
|
-
setTransactObserver(onTransact);
|
|
2742
|
-
setBatchEndNotifier(onBatchEnd);
|
|
2743
|
-
setTransactGate((tab) => {
|
|
2744
|
-
const session = runtimeOf(tab)?.session;
|
|
2745
|
-
if (session?.synced && collabState(tab).sourceCanonical && !session.inSourceMode) {
|
|
2746
|
-
_notify("Source editing in progress — structural edits are paused");
|
|
2747
|
-
return "source-canonical";
|
|
2748
|
-
}
|
|
2749
|
-
return null;
|
|
2750
|
-
});
|
|
2751
|
-
}
|
|
2752
|
-
function onTransact(tab, record, origin) {
|
|
2753
|
-
const session = runtimeOf(tab)?.session;
|
|
2754
|
-
if (!session || !session.synced) {
|
|
2755
|
-
return;
|
|
2756
|
-
}
|
|
2757
|
-
session.lastSeenRef = toRaw(tab.doc.document);
|
|
2758
|
-
if (origin === "remote") {
|
|
2759
|
-
scheduleMirror(session);
|
|
2760
|
-
return;
|
|
2761
|
-
}
|
|
2762
|
-
if (session.canWrite) {
|
|
2763
|
-
publishRecord(session, record);
|
|
2764
|
-
scheduleMirror(session);
|
|
2765
|
-
}
|
|
2766
|
-
}
|
|
2767
|
-
function onBatchEnd(tab) {
|
|
2768
|
-
const session = runtimeOf(tab)?.session;
|
|
2769
|
-
if (!session?.synced || session.batchOps === null) {
|
|
2770
|
-
return;
|
|
2771
|
-
}
|
|
2772
|
-
const ops = session.batchOps;
|
|
2773
|
-
const needsDiff = session.batchNeedsDiff;
|
|
2774
|
-
session.batchOps = null;
|
|
2775
|
-
session.batchNeedsDiff = false;
|
|
2776
|
-
if (!session.canWrite) {
|
|
2777
|
-
return;
|
|
2778
|
-
}
|
|
2779
|
-
session.undoManager?.stopCapturing();
|
|
2780
|
-
if (needsDiff) {
|
|
2781
|
-
publishDiff(session);
|
|
2782
|
-
} else if (ops.length > 0) {
|
|
2783
|
-
try {
|
|
2784
|
-
session.collab.applyDocOpsToY(session.handle.doc, ops, session.collab.LOCAL_ORIGIN);
|
|
2785
|
-
} catch {
|
|
2786
|
-
publishDiff(session);
|
|
2787
|
-
}
|
|
2788
|
-
}
|
|
2789
|
-
session.undoManager?.stopCapturing();
|
|
2790
|
-
}
|
|
2791
|
-
function publishRecord(session, record) {
|
|
2792
|
-
const forward = record.docOps.map((pair) => pair.forward);
|
|
2793
|
-
if (isBatching()) {
|
|
2794
|
-
session.batchOps ??= [];
|
|
2795
|
-
if (forward.length === 0) {
|
|
2796
|
-
session.batchNeedsDiff = true;
|
|
2797
|
-
} else {
|
|
2798
|
-
session.batchOps.push(...forward);
|
|
2799
|
-
}
|
|
2800
|
-
return;
|
|
2801
|
-
}
|
|
2802
|
-
if (forward.length === 0) {
|
|
2803
|
-
publishDiff(session);
|
|
2804
|
-
return;
|
|
2805
|
-
}
|
|
2806
|
-
try {
|
|
2807
|
-
session.collab.applyDocOpsToY(session.handle.doc, forward, session.collab.LOCAL_ORIGIN);
|
|
2808
|
-
} catch {
|
|
2809
|
-
publishDiff(session);
|
|
2810
|
-
}
|
|
2811
|
-
}
|
|
2812
|
-
function publishDiff(session) {
|
|
2813
|
-
const { collab, handle, tab } = session;
|
|
2814
|
-
const before = collab.yDocToJson(handle.doc);
|
|
2815
|
-
const after = jsonClone(toRaw(tab.doc.document));
|
|
2816
|
-
const ops = collab.diffDocs(before, after);
|
|
2817
|
-
if (ops === null) {
|
|
2818
|
-
collab.replaceYStructure(handle.doc, after, collab.LOCAL_ORIGIN);
|
|
2819
|
-
} else if (ops.length > 0) {
|
|
2820
|
-
try {
|
|
2821
|
-
collab.applyDocOpsToY(handle.doc, ops, collab.LOCAL_ORIGIN);
|
|
2822
|
-
} catch {
|
|
2823
|
-
collab.replaceYStructure(handle.doc, after, collab.LOCAL_ORIGIN);
|
|
2824
|
-
}
|
|
2825
|
-
}
|
|
2826
|
-
}
|
|
2827
|
-
function reconcileTabFromY(session) {
|
|
2828
|
-
const next = session.collab.yDocToJson(session.handle.doc);
|
|
2829
|
-
transactDoc(session.tab, (t) => {
|
|
2830
|
-
const target = t.doc.document;
|
|
2831
|
-
for (const key of Object.keys(target)) {
|
|
2832
|
-
if (!(key in next)) {
|
|
2833
|
-
delete target[key];
|
|
2834
|
-
}
|
|
2835
|
-
}
|
|
2836
|
-
Object.assign(target, next);
|
|
2837
|
-
}, { origin: "remote", skipHistory: true });
|
|
2838
|
-
}
|
|
2839
|
-
function isReconciler(session) {
|
|
2840
|
-
if (!session.canWrite) {
|
|
2841
|
-
return false;
|
|
2842
|
-
}
|
|
2843
|
-
const { awareness } = session.handle;
|
|
2844
|
-
let lowest = awareness.clientID;
|
|
2845
|
-
for (const [clientId, state] of awareness.getStates()) {
|
|
2846
|
-
if (state.canWrite !== false && clientId < lowest) {
|
|
2847
|
-
lowest = clientId;
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
return lowest === session.handle.awareness.clientID;
|
|
2851
|
-
}
|
|
2852
|
-
function scheduleMirror(session) {
|
|
2853
|
-
if (!_serialize || !isReconciler(session)) {
|
|
2854
|
-
return;
|
|
2855
|
-
}
|
|
2856
|
-
if (session.collab.canonicalOf(session.handle.doc) === "source") {
|
|
2857
|
-
return;
|
|
2858
|
-
}
|
|
2859
|
-
const now = Date.now();
|
|
2860
|
-
session.lastMirrorAt ??= now;
|
|
2861
|
-
if (now - session.lastMirrorAt >= MIRROR_MAX_LAG_MS) {
|
|
2862
|
-
if (session.mirrorTimer) {
|
|
2863
|
-
clearTimeout(session.mirrorTimer);
|
|
2864
|
-
session.mirrorTimer = null;
|
|
2865
|
-
}
|
|
2866
|
-
session.lastMirrorAt = now;
|
|
2867
|
-
mirrorNow(session);
|
|
2868
|
-
return;
|
|
2869
|
-
}
|
|
2870
|
-
if (session.mirrorTimer) {
|
|
2871
|
-
clearTimeout(session.mirrorTimer);
|
|
2872
|
-
}
|
|
2873
|
-
session.mirrorTimer = setTimeout(() => {
|
|
2874
|
-
session.mirrorTimer = null;
|
|
2875
|
-
session.lastMirrorAt = Date.now();
|
|
2876
|
-
mirrorNow(session);
|
|
2877
|
-
}, MIRROR_DEBOUNCE_MS);
|
|
2878
|
-
}
|
|
2879
|
-
async function mirrorNow(session) {
|
|
2880
|
-
if (!_serialize || !session.synced) {
|
|
2881
|
-
return;
|
|
2882
|
-
}
|
|
2883
|
-
try {
|
|
2884
|
-
const text = await _serialize(session.tab);
|
|
2885
|
-
session.collab.updateSourceText(session.handle.doc, text, session.collab.MIRROR_ORIGIN);
|
|
2886
|
-
} catch {}
|
|
2887
|
-
}
|
|
2888
|
-
async function sourceParseNow(session) {
|
|
2889
|
-
if (!_parse || !session.synced || !session.canWrite) {
|
|
2890
|
-
return;
|
|
2891
|
-
}
|
|
2892
|
-
const { collab, handle, tab } = session;
|
|
2893
|
-
const rev = collab.canonicalRevOf(handle.doc);
|
|
2894
|
-
const text = collab.sourceText(handle.doc).toString();
|
|
2895
|
-
let parsed;
|
|
2896
|
-
try {
|
|
2897
|
-
parsed = await _parse(tab, text);
|
|
2898
|
-
} catch {
|
|
2899
|
-
return;
|
|
2900
|
-
}
|
|
2901
|
-
if (!session.synced || collab.canonicalRevOf(handle.doc) !== rev) {
|
|
2902
|
-
return;
|
|
2903
|
-
}
|
|
2904
|
-
const ops = collab.diffDocs(collab.yDocToJson(handle.doc), parsed.document);
|
|
2905
|
-
if (ops === null) {
|
|
2906
|
-
collab.replaceYStructure(handle.doc, parsed.document, collab.MIRROR_ORIGIN);
|
|
2907
|
-
} else if (ops.length > 0) {
|
|
2908
|
-
try {
|
|
2909
|
-
collab.applyDocOpsToY(handle.doc, ops, collab.MIRROR_ORIGIN);
|
|
2910
|
-
} catch {
|
|
2911
|
-
collab.replaceYStructure(handle.doc, parsed.document, collab.MIRROR_ORIGIN);
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
const frontmatter = collab.frontmatterMap(handle.doc);
|
|
2915
|
-
const next = parsed.frontmatter ?? {};
|
|
2916
|
-
handle.doc.transact(() => {
|
|
2917
|
-
const sharedKeys = [...frontmatter.keys()];
|
|
2918
|
-
for (const key of sharedKeys) {
|
|
2919
|
-
if (!(key in next)) {
|
|
2920
|
-
frontmatter.delete(key);
|
|
2921
|
-
}
|
|
2922
|
-
}
|
|
2923
|
-
for (const [key, value] of Object.entries(next)) {
|
|
2924
|
-
if (!collab.deepEqual(frontmatter.get(key), value)) {
|
|
2925
|
-
frontmatter.set(key, value);
|
|
2926
|
-
}
|
|
2927
|
-
}
|
|
2928
|
-
}, collab.MIRROR_ORIGIN);
|
|
2929
|
-
}
|
|
2930
|
-
function collabSourceContext(tab) {
|
|
2931
|
-
const session = runtimeOf(tab)?.session;
|
|
2932
|
-
if (!session?.synced) {
|
|
2933
|
-
return null;
|
|
2934
|
-
}
|
|
2935
|
-
const { collab, handle } = session;
|
|
2936
|
-
return {
|
|
2937
|
-
awareness: handle.awareness,
|
|
2938
|
-
enter: async () => {
|
|
2939
|
-
session.inSourceMode = true;
|
|
2940
|
-
const local = handle.awareness.getLocalState();
|
|
2941
|
-
if (local) {
|
|
2942
|
-
handle.awareness.setLocalState({ ...local, mode: "source" });
|
|
2943
|
-
}
|
|
2944
|
-
if (!session.canWrite) {
|
|
2945
|
-
return;
|
|
2946
|
-
}
|
|
2947
|
-
let serialized = null;
|
|
2948
|
-
if (_serialize) {
|
|
2949
|
-
try {
|
|
2950
|
-
serialized = await _serialize(tab);
|
|
2951
|
-
} catch {
|
|
2952
|
-
serialized = null;
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
collab.acquireSourceCanonical(handle.doc, serialized ?? collab.sourceText(handle.doc).toString(), collab.LOCAL_ORIGIN);
|
|
2956
|
-
},
|
|
2957
|
-
leave: () => {
|
|
2958
|
-
session.inSourceMode = false;
|
|
2959
|
-
const local = handle.awareness.getLocalState();
|
|
2960
|
-
if (local) {
|
|
2961
|
-
handle.awareness.setLocalState({ ...local, mode: "structure" });
|
|
2962
|
-
}
|
|
2963
|
-
if (!session.canWrite) {
|
|
2964
|
-
return;
|
|
2965
|
-
}
|
|
2966
|
-
const others = collab.otherSourceEditors(handle.awareness, session.path, handle.awareness.clientID);
|
|
2967
|
-
if (others.length === 0) {
|
|
2968
|
-
sourceParseNow(session).then(() => {
|
|
2969
|
-
collab.releaseSourceCanonical(handle.doc, collab.LOCAL_ORIGIN);
|
|
2970
|
-
});
|
|
2971
|
-
}
|
|
2972
|
-
},
|
|
2973
|
-
localOrigin: collab.LOCAL_ORIGIN,
|
|
2974
|
-
readOnly: !session.canWrite,
|
|
2975
|
-
text: collab.sourceText(handle.doc)
|
|
2976
|
-
};
|
|
2977
|
-
}
|
|
2978
|
-
async function collabSave(tab) {
|
|
2979
|
-
const session = runtimeOf(tab)?.session;
|
|
2980
|
-
if (!session?.synced) {
|
|
2981
|
-
return false;
|
|
2982
|
-
}
|
|
2983
|
-
if (session.mirrorTimer) {
|
|
2984
|
-
clearTimeout(session.mirrorTimer);
|
|
2985
|
-
session.mirrorTimer = null;
|
|
2986
|
-
}
|
|
2987
|
-
if (session.canWrite) {
|
|
2988
|
-
await mirrorNow(session);
|
|
2989
|
-
}
|
|
2990
|
-
await session.handle.flush();
|
|
2991
|
-
return true;
|
|
2992
|
-
}
|
|
2993
|
-
async function flushAllCollab() {
|
|
2994
|
-
for (const tab of liveTabs) {
|
|
2995
|
-
const session = runtimeOf(tab)?.session;
|
|
2996
|
-
if (session?.synced) {
|
|
2997
|
-
await collabSave(tab);
|
|
2998
|
-
}
|
|
2999
|
-
}
|
|
3000
|
-
}
|
|
3001
|
-
var liveTabs = new Set;
|
|
3002
|
-
function ensureCollab(tab) {
|
|
3003
|
-
const platform = maybePlatform();
|
|
3004
|
-
if (!platform?.collab || !tab.documentPath) {
|
|
3005
|
-
return;
|
|
3006
|
-
}
|
|
3007
|
-
const runtime = runtimeFor(tab);
|
|
3008
|
-
if (runtime.watcherInstalled) {
|
|
3009
|
-
return;
|
|
3010
|
-
}
|
|
3011
|
-
runtime.watcherInstalled = true;
|
|
3012
|
-
installGlobalHooks();
|
|
3013
|
-
liveTabs.add(tab);
|
|
3014
|
-
tab.scope.run(() => {
|
|
3015
|
-
effect(() => {
|
|
3016
|
-
const drilled = (tab.session.documentStack?.length ?? 0) > 0;
|
|
3017
|
-
if (drilled) {
|
|
3018
|
-
detachSession(tab);
|
|
3019
|
-
} else {
|
|
3020
|
-
attachSession(tab);
|
|
3021
|
-
}
|
|
3022
|
-
});
|
|
3023
|
-
onScopeDispose(() => {
|
|
3024
|
-
liveTabs.delete(tab);
|
|
3025
|
-
detachSession(tab);
|
|
3026
|
-
});
|
|
3027
|
-
});
|
|
3028
|
-
}
|
|
3029
|
-
function rekeyCollab(tab) {
|
|
3030
|
-
const runtime = runtimeOf(tab);
|
|
3031
|
-
if (!runtime?.watcherInstalled) {
|
|
3032
|
-
ensureCollab(tab);
|
|
3033
|
-
return;
|
|
3034
|
-
}
|
|
3035
|
-
detachSession(tab);
|
|
3036
|
-
attachSession(tab);
|
|
3037
|
-
}
|
|
3038
|
-
async function attachSession(tab) {
|
|
3039
|
-
const runtime = runtimeFor(tab);
|
|
3040
|
-
if (runtime.session || runtime.attaching) {
|
|
3041
|
-
return;
|
|
3042
|
-
}
|
|
3043
|
-
const { documentPath: path } = tab;
|
|
3044
|
-
const platform = maybePlatform();
|
|
3045
|
-
if (!path || !platform?.collab) {
|
|
3046
|
-
return;
|
|
3047
|
-
}
|
|
3048
|
-
const { generation } = runtime;
|
|
3049
|
-
const state = collabState(tab);
|
|
3050
|
-
state.status = "connecting";
|
|
3051
|
-
const attempt = (async () => {
|
|
3052
|
-
try {
|
|
3053
|
-
const [collab, handle] = await Promise.all([loadCollab(), platform.collab(path)]);
|
|
3054
|
-
if (!handle) {
|
|
3055
|
-
state.status = "detached";
|
|
3056
|
-
return;
|
|
3057
|
-
}
|
|
3058
|
-
if (runtime.generation !== generation) {
|
|
3059
|
-
handle.destroy();
|
|
3060
|
-
return;
|
|
3061
|
-
}
|
|
3062
|
-
let timer = null;
|
|
3063
|
-
const timeout = new Promise((_, reject) => {
|
|
3064
|
-
timer = setTimeout(() => reject(new Error("collab-sync-timeout")), SYNC_TIMEOUT_MS);
|
|
3065
|
-
});
|
|
3066
|
-
try {
|
|
3067
|
-
await Promise.race([handle.whenSynced, timeout]);
|
|
3068
|
-
} finally {
|
|
3069
|
-
if (timer) {
|
|
3070
|
-
clearTimeout(timer);
|
|
3071
|
-
}
|
|
3072
|
-
}
|
|
3073
|
-
if (runtime.generation !== generation) {
|
|
3074
|
-
handle.destroy();
|
|
3075
|
-
return;
|
|
3076
|
-
}
|
|
3077
|
-
runtime.session = createSession(tab, path, collab, handle);
|
|
3078
|
-
state.active = true;
|
|
3079
|
-
state.status = "synced";
|
|
3080
|
-
state.readOnly = !runtime.session.canWrite;
|
|
3081
|
-
registerCollabPath(path);
|
|
3082
|
-
} catch {
|
|
3083
|
-
state.status = "detached";
|
|
3084
|
-
state.active = false;
|
|
3085
|
-
} finally {
|
|
3086
|
-
runtime.attaching = null;
|
|
3087
|
-
}
|
|
3088
|
-
})();
|
|
3089
|
-
runtime.attaching = attempt;
|
|
3090
|
-
await attempt;
|
|
3091
|
-
}
|
|
3092
|
-
function detachSession(tab) {
|
|
3093
|
-
const runtime = runtimeOf(tab);
|
|
3094
|
-
if (!runtime) {
|
|
3095
|
-
return;
|
|
3096
|
-
}
|
|
3097
|
-
runtime.generation += 1;
|
|
3098
|
-
const { session } = runtime;
|
|
3099
|
-
runtime.session = null;
|
|
3100
|
-
const state = collabState(tab);
|
|
3101
|
-
state.active = false;
|
|
3102
|
-
state.status = "detached";
|
|
3103
|
-
state.peers = [];
|
|
3104
|
-
if (!session) {
|
|
3105
|
-
return;
|
|
3106
|
-
}
|
|
3107
|
-
unregisterCollabPath(session.path);
|
|
3108
|
-
if (session.mirrorTimer) {
|
|
3109
|
-
clearTimeout(session.mirrorTimer);
|
|
3110
|
-
}
|
|
3111
|
-
if (session.sourceParseTimer) {
|
|
3112
|
-
clearTimeout(session.sourceParseTimer);
|
|
3113
|
-
}
|
|
3114
|
-
for (const dispose of session.disposers) {
|
|
3115
|
-
try {
|
|
3116
|
-
dispose();
|
|
3117
|
-
} catch {}
|
|
3118
|
-
}
|
|
3119
|
-
setHistoryDelegate(tab, null);
|
|
3120
|
-
tab.history.snapshots = [
|
|
3121
|
-
{
|
|
3122
|
-
document: jsonClone(toRaw(tab.doc.document)),
|
|
3123
|
-
selection: tab.session.selection ? [...tab.session.selection] : null
|
|
3124
|
-
}
|
|
3125
|
-
];
|
|
3126
|
-
tab.history.index = 0;
|
|
3127
|
-
session.undoManager?.destroy();
|
|
3128
|
-
session.handle.destroy();
|
|
3129
|
-
}
|
|
3130
|
-
function createSession(tab, path, collab, handle) {
|
|
3131
|
-
const identity = handle.identity();
|
|
3132
|
-
const session = {
|
|
3133
|
-
applyingRemoteFrontmatter: false,
|
|
3134
|
-
batchNeedsDiff: false,
|
|
3135
|
-
batchOps: null,
|
|
3136
|
-
canWrite: identity ? identity.permission !== "read" : true,
|
|
3137
|
-
collab,
|
|
3138
|
-
disposers: [],
|
|
3139
|
-
handle,
|
|
3140
|
-
inSourceMode: false,
|
|
3141
|
-
lastSeenRef: toRaw(tab.doc.document),
|
|
3142
|
-
mirrorTimer: null,
|
|
3143
|
-
path,
|
|
3144
|
-
sourceParseTimer: null,
|
|
3145
|
-
synced: false,
|
|
3146
|
-
tab,
|
|
3147
|
-
undoManager: null
|
|
3148
|
-
};
|
|
3149
|
-
const meta = collab.metaMap(handle.doc);
|
|
3150
|
-
if (meta.get("structureSeeded") === true) {
|
|
3151
|
-
const yJson = collab.yDocToJson(handle.doc);
|
|
3152
|
-
const tabJson = jsonClone(toRaw(tab.doc.document));
|
|
3153
|
-
if (!collab.deepEqual(yJson, tabJson)) {
|
|
3154
|
-
const ops = collab.diffDocs(tabJson, yJson);
|
|
3155
|
-
if (ops === null) {
|
|
3156
|
-
session.synced = true;
|
|
3157
|
-
reconcileTabFromY(session);
|
|
3158
|
-
session.synced = false;
|
|
3159
|
-
} else if (ops.length > 0) {
|
|
3160
|
-
applyExternalDocOps(tab, ops);
|
|
3161
|
-
}
|
|
3162
|
-
}
|
|
3163
|
-
session.applyingRemoteFrontmatter = true;
|
|
3164
|
-
const sharedFrontmatter = collab.frontmatterMap(handle.doc);
|
|
3165
|
-
for (const [key, value] of sharedFrontmatter.entries()) {
|
|
3166
|
-
tab.doc.content.frontmatter[key] = value;
|
|
3167
|
-
}
|
|
3168
|
-
session.applyingRemoteFrontmatter = false;
|
|
3169
|
-
} else if (session.canWrite) {
|
|
3170
|
-
collab.seedStructure(handle.doc, jsonClone(toRaw(tab.doc.document)), {
|
|
3171
|
-
frontmatter: jsonClone(toRaw(tab.doc.content.frontmatter)),
|
|
3172
|
-
origin: collab.SEED_ORIGIN,
|
|
3173
|
-
sourceFormat: tab.doc.sourceFormat
|
|
3174
|
-
});
|
|
3175
|
-
}
|
|
3176
|
-
session.lastSeenRef = toRaw(tab.doc.document);
|
|
3177
|
-
session.disposers.push(handle.onDirty((dirty) => {
|
|
3178
|
-
tab.doc.dirty = dirty;
|
|
3179
|
-
}));
|
|
3180
|
-
handle.awareness.setLocalState({
|
|
3181
|
-
canWrite: session.canWrite,
|
|
3182
|
-
focusedPath: path,
|
|
3183
|
-
structuralSelection: null,
|
|
3184
|
-
user: identity ? {
|
|
3185
|
-
avatarUrl: identity.avatarUrl,
|
|
3186
|
-
color: identity.color,
|
|
3187
|
-
login: identity.login,
|
|
3188
|
-
name: identity.name
|
|
3189
|
-
} : {
|
|
3190
|
-
color: collab.colorForKey(String(handle.awareness.clientID)),
|
|
3191
|
-
login: `guest-${handle.awareness.clientID % 1000}`
|
|
3192
|
-
}
|
|
3193
|
-
});
|
|
3194
|
-
const undoManager = new collab.UndoManager([collab.structureMap(handle.doc), collab.frontmatterMap(handle.doc)], { trackedOrigins: new Set([collab.LOCAL_ORIGIN]) });
|
|
3195
|
-
session.undoManager = undoManager;
|
|
3196
|
-
const onStackAdd = ({ stackItem }) => {
|
|
3197
|
-
stackItem.meta.set("selection", tab.session.selection ? [...tab.session.selection] : null);
|
|
3198
|
-
};
|
|
3199
|
-
const onStackPop = ({ stackItem }) => {
|
|
3200
|
-
const selection = stackItem.meta.get("selection");
|
|
3201
|
-
tab.session.selection = selection ? [...selection] : null;
|
|
3202
|
-
};
|
|
3203
|
-
undoManager.on("stack-item-added", onStackAdd);
|
|
3204
|
-
undoManager.on("stack-item-popped", onStackPop);
|
|
3205
|
-
session.disposers.push(() => {
|
|
3206
|
-
undoManager.off("stack-item-added", onStackAdd);
|
|
3207
|
-
undoManager.off("stack-item-popped", onStackPop);
|
|
3208
|
-
});
|
|
3209
|
-
setHistoryDelegate(tab, {
|
|
3210
|
-
canRedo: () => undoManager.canRedo(),
|
|
3211
|
-
canUndo: () => undoManager.canUndo(),
|
|
3212
|
-
redo: () => {
|
|
3213
|
-
undoManager.redo();
|
|
3214
|
-
},
|
|
3215
|
-
undo: () => {
|
|
3216
|
-
undoManager.undo();
|
|
3217
|
-
}
|
|
3218
|
-
});
|
|
3219
|
-
const structure = collab.structureMap(handle.doc);
|
|
3220
|
-
const structureObserver = (events, transaction) => {
|
|
3221
|
-
if (transaction.origin === collab.LOCAL_ORIGIN || !session.synced) {
|
|
3222
|
-
return;
|
|
3223
|
-
}
|
|
3224
|
-
const ops = collab.yEventsToDocOps(events);
|
|
3225
|
-
if (ops === null) {
|
|
3226
|
-
reconcileTabFromY(session);
|
|
3227
|
-
return;
|
|
3228
|
-
}
|
|
3229
|
-
if (ops.length === 0) {
|
|
3230
|
-
return;
|
|
3231
|
-
}
|
|
3232
|
-
try {
|
|
3233
|
-
applyExternalDocOps(tab, ops);
|
|
3234
|
-
} catch {
|
|
3235
|
-
reconcileTabFromY(session);
|
|
3236
|
-
}
|
|
3237
|
-
};
|
|
3238
|
-
structure.observeDeep(structureObserver);
|
|
3239
|
-
session.disposers.push(() => structure.unobserveDeep(structureObserver));
|
|
3240
|
-
const tabState = collabState(tab);
|
|
3241
|
-
tabState.sourceCanonical = collab.canonicalOf(handle.doc) === "source";
|
|
3242
|
-
const lockMeta = collab.metaMap(handle.doc);
|
|
3243
|
-
const lockObserver = () => {
|
|
3244
|
-
tabState.sourceCanonical = collab.canonicalOf(handle.doc) === "source";
|
|
3245
|
-
};
|
|
3246
|
-
lockMeta.observe(lockObserver);
|
|
3247
|
-
session.disposers.push(() => lockMeta.unobserve(lockObserver));
|
|
3248
|
-
const source = collab.sourceText(handle.doc);
|
|
3249
|
-
const sourceObserver = (_event, transaction) => {
|
|
3250
|
-
if (transaction.origin === collab.MIRROR_ORIGIN || !session.synced) {
|
|
3251
|
-
return;
|
|
3252
|
-
}
|
|
3253
|
-
if (collab.canonicalOf(handle.doc) !== "source") {
|
|
3254
|
-
return;
|
|
3255
|
-
}
|
|
3256
|
-
if (!collab.isSourceReconciler(handle.awareness, session.path)) {
|
|
3257
|
-
return;
|
|
3258
|
-
}
|
|
3259
|
-
if (session.sourceParseTimer) {
|
|
3260
|
-
clearTimeout(session.sourceParseTimer);
|
|
3261
|
-
}
|
|
3262
|
-
session.sourceParseTimer = setTimeout(() => {
|
|
3263
|
-
session.sourceParseTimer = null;
|
|
3264
|
-
sourceParseNow(session);
|
|
3265
|
-
}, 600);
|
|
3266
|
-
};
|
|
3267
|
-
source.observe(sourceObserver);
|
|
3268
|
-
session.disposers.push(() => source.unobserve(sourceObserver));
|
|
3269
|
-
const frontmatter = collab.frontmatterMap(handle.doc);
|
|
3270
|
-
const frontmatterObserver = (event, transaction) => {
|
|
3271
|
-
if (transaction.origin === collab.LOCAL_ORIGIN || !session.synced) {
|
|
3272
|
-
return;
|
|
3273
|
-
}
|
|
3274
|
-
session.applyingRemoteFrontmatter = true;
|
|
3275
|
-
try {
|
|
3276
|
-
for (const [key, change] of event.changes.keys) {
|
|
3277
|
-
if (change.action === "delete") {
|
|
3278
|
-
delete tab.doc.content.frontmatter[key];
|
|
3279
|
-
} else {
|
|
3280
|
-
tab.doc.content.frontmatter[key] = frontmatter.get(key);
|
|
3281
|
-
}
|
|
3282
|
-
}
|
|
3283
|
-
} finally {
|
|
3284
|
-
session.applyingRemoteFrontmatter = false;
|
|
3285
|
-
}
|
|
3286
|
-
};
|
|
3287
|
-
frontmatter.observe(frontmatterObserver);
|
|
3288
|
-
session.disposers.push(() => frontmatter.unobserve(frontmatterObserver));
|
|
3289
|
-
tab.scope.run(() => {
|
|
3290
|
-
let lastJson = JSON.stringify(tab.doc.content.frontmatter);
|
|
3291
|
-
effect(() => {
|
|
3292
|
-
const json = JSON.stringify(tab.doc.content.frontmatter);
|
|
3293
|
-
if (json === lastJson) {
|
|
3294
|
-
return;
|
|
3295
|
-
}
|
|
3296
|
-
lastJson = json;
|
|
3297
|
-
if (session.applyingRemoteFrontmatter || !session.synced || !session.canWrite) {
|
|
3298
|
-
return;
|
|
3299
|
-
}
|
|
3300
|
-
const local = JSON.parse(json);
|
|
3301
|
-
handle.doc.transact(() => {
|
|
3302
|
-
const sharedKeys = [...frontmatter.keys()];
|
|
3303
|
-
for (const key of sharedKeys) {
|
|
3304
|
-
if (!(key in local)) {
|
|
3305
|
-
frontmatter.delete(key);
|
|
3306
|
-
}
|
|
3307
|
-
}
|
|
3308
|
-
for (const [key, value] of Object.entries(local)) {
|
|
3309
|
-
if (!collab.deepEqual(frontmatter.get(key), value)) {
|
|
3310
|
-
frontmatter.set(key, value);
|
|
3311
|
-
}
|
|
3312
|
-
}
|
|
3313
|
-
}, collab.LOCAL_ORIGIN);
|
|
3314
|
-
scheduleMirror(session);
|
|
3315
|
-
});
|
|
3316
|
-
effect(() => {
|
|
3317
|
-
const structuralSelection = tab.session.selection ? [...tab.session.selection] : null;
|
|
3318
|
-
const local = handle.awareness.getLocalState();
|
|
3319
|
-
if (local) {
|
|
3320
|
-
handle.awareness.setLocalState({ ...local, structuralSelection });
|
|
3321
|
-
}
|
|
3322
|
-
});
|
|
3323
|
-
effect(() => {
|
|
3324
|
-
const ref2 = toRaw(tab.doc.document);
|
|
3325
|
-
queueMicrotask(() => {
|
|
3326
|
-
const current = runtimeOf(tab)?.session;
|
|
3327
|
-
if (current !== session || !session.synced || !session.canWrite) {
|
|
3328
|
-
return;
|
|
3329
|
-
}
|
|
3330
|
-
const nowRef = toRaw(tab.doc.document);
|
|
3331
|
-
if (nowRef !== ref2 || nowRef === session.lastSeenRef) {
|
|
3332
|
-
return;
|
|
3333
|
-
}
|
|
3334
|
-
session.lastSeenRef = nowRef;
|
|
3335
|
-
publishDiff(session);
|
|
3336
|
-
scheduleMirror(session);
|
|
3337
|
-
});
|
|
3338
|
-
});
|
|
3339
|
-
});
|
|
3340
|
-
const state = collabState(tab);
|
|
3341
|
-
const awarenessObserver = () => {
|
|
3342
|
-
const peers = [];
|
|
3343
|
-
for (const [clientId, peerState] of handle.awareness.getStates()) {
|
|
3344
|
-
if (clientId !== handle.awareness.clientID && peerState["user"]) {
|
|
3345
|
-
peers.push({ clientId, state: peerState });
|
|
3346
|
-
}
|
|
3347
|
-
}
|
|
3348
|
-
state.peers = peers;
|
|
3349
|
-
};
|
|
3350
|
-
awarenessObserver();
|
|
3351
|
-
handle.awareness.on("change", awarenessObserver);
|
|
3352
|
-
session.disposers.push(() => handle.awareness.off("change", awarenessObserver), handle.onStatus((status) => {
|
|
3353
|
-
if (status === "offline" || status === "connecting") {
|
|
3354
|
-
state.status = "offline";
|
|
3355
|
-
} else if (session.synced) {
|
|
3356
|
-
state.status = "synced";
|
|
3357
|
-
}
|
|
3358
|
-
}), handle.onReset(() => {
|
|
3359
|
-
detachSession(tab);
|
|
3360
|
-
attachSession(tab);
|
|
3361
|
-
}));
|
|
3362
|
-
session.synced = true;
|
|
3363
|
-
return session;
|
|
3364
|
-
}
|
|
3365
|
-
|
|
3366
|
-
// src/tabs/tab.ts
|
|
3367
|
-
function createDefaultUi(canvasMode, preview = false) {
|
|
3368
|
-
return {
|
|
3369
|
-
activeMedia: null,
|
|
3370
|
-
activeSelector: null,
|
|
3371
|
-
canvasMode,
|
|
3372
|
-
editZoom: 1,
|
|
3373
|
-
editingFormula: null,
|
|
3374
|
-
editingFunction: null,
|
|
3375
|
-
featureToggles: {},
|
|
3376
|
-
frontmatterOpen: true,
|
|
3377
|
-
gitBranches: null,
|
|
3378
|
-
gitCommitMessage: "",
|
|
3379
|
-
gitDiffState: null,
|
|
3380
|
-
gitError: null,
|
|
3381
|
-
gitLoading: false,
|
|
3382
|
-
gitStatus: null,
|
|
3383
|
-
inspectorSections: {},
|
|
3384
|
-
pendingInlineEdit: null,
|
|
3385
|
-
preview,
|
|
3386
|
-
previewColorScheme: "auto",
|
|
3387
|
-
previewParams: {},
|
|
3388
|
-
previewProps: null,
|
|
3389
|
-
rightTab: "properties",
|
|
3390
|
-
settingsTab: "stylebook",
|
|
3391
|
-
showLayout: true,
|
|
3392
|
-
styleFilter: "",
|
|
3393
|
-
styleFilterActive: false,
|
|
3394
|
-
styleSections: {},
|
|
3395
|
-
styleShorthands: {},
|
|
3396
|
-
stylebookCustomizedOnly: false,
|
|
3397
|
-
stylebookFilter: "",
|
|
3398
|
-
stylebookSelection: null,
|
|
3399
|
-
stylebookTab: "elements",
|
|
3400
|
-
zoom: 1
|
|
3401
|
-
};
|
|
3402
|
-
}
|
|
3403
|
-
var ALL_MODES = ["edit", "design", "preview", "source", "stylebook"];
|
|
3404
|
-
function createTab({
|
|
3405
|
-
id,
|
|
3406
|
-
documentPath = null,
|
|
3407
|
-
fileHandle = null,
|
|
3408
|
-
document: document2,
|
|
3409
|
-
frontmatter,
|
|
3410
|
-
sourceFormat = null,
|
|
3411
|
-
capabilities
|
|
3412
|
-
}) {
|
|
3413
|
-
const scope = effectScope();
|
|
3414
|
-
normalizeArrayChildren(document2);
|
|
3415
|
-
const resolvedModes = capabilities?.modes ?? inferModes(documentPath, sourceFormat);
|
|
3416
|
-
const initialCanvasMode = resolvedModes.find((m) => m !== "preview") ?? "edit";
|
|
3417
|
-
const initialPreview = resolvedModes[0] === "preview";
|
|
3418
|
-
const tab = scope.run(() => ({
|
|
3419
|
-
capabilities: { modes: resolvedModes },
|
|
3420
|
-
doc: reactive({
|
|
3421
|
-
content: { frontmatter: frontmatter || {} },
|
|
3422
|
-
dirty: false,
|
|
3423
|
-
document: document2,
|
|
3424
|
-
handlersSource: null,
|
|
3425
|
-
mode: inferDocumentMode(documentPath, sourceFormat),
|
|
3426
|
-
sourceFormat
|
|
3427
|
-
}),
|
|
3428
|
-
documentPath,
|
|
3429
|
-
fileHandle,
|
|
3430
|
-
history: reactive({
|
|
3431
|
-
index: 0,
|
|
3432
|
-
snapshots: [{ document: structuredClone(document2), selection: null }]
|
|
3433
|
-
}),
|
|
3434
|
-
id,
|
|
3435
|
-
scope,
|
|
3436
|
-
session: reactive({
|
|
3437
|
-
canvas: {
|
|
3438
|
-
error: null,
|
|
3439
|
-
livePreviews: null,
|
|
3440
|
-
pendingInlineEdit: null,
|
|
3441
|
-
scope: null,
|
|
3442
|
-
status: "idle"
|
|
3443
|
-
},
|
|
3444
|
-
clipboard: null,
|
|
3445
|
-
documentStack: [],
|
|
3446
|
-
hover: null,
|
|
3447
|
-
selection: null,
|
|
3448
|
-
ui: createDefaultUi(initialCanvasMode, initialPreview)
|
|
3449
|
-
})
|
|
3450
|
-
}));
|
|
3451
|
-
return tab;
|
|
3452
|
-
}
|
|
3453
|
-
function inferModes(documentPath, sourceFormat) {
|
|
3454
|
-
if (documentPath === "project.json") {
|
|
3455
|
-
return ["stylebook", "source"];
|
|
3456
|
-
}
|
|
3457
|
-
const format = formatByName(sourceFormat) ?? formatForPath(documentPath);
|
|
3458
|
-
if (format) {
|
|
3459
|
-
return format.studio?.modes ?? ["edit", "design", "preview", "source"];
|
|
3460
|
-
}
|
|
3461
|
-
return ALL_MODES;
|
|
3462
|
-
}
|
|
3463
|
-
function inferDocumentMode(documentPath, sourceFormat) {
|
|
3464
|
-
const format = formatByName(sourceFormat) ?? formatForPath(documentPath);
|
|
3465
|
-
if (format) {
|
|
3466
|
-
return format.studio?.documentMode?.default ?? "content";
|
|
3467
|
-
}
|
|
3468
|
-
return "component";
|
|
3469
|
-
}
|
|
3470
|
-
function disposeTab(tab) {
|
|
3471
|
-
tab.scope.stop();
|
|
3472
|
-
}
|
|
3473
|
-
|
|
3474
|
-
// src/workspace/workspace.ts
|
|
3475
|
-
var workspace = reactive({
|
|
3476
|
-
activeTabId: null,
|
|
3477
|
-
clipboard: null,
|
|
3478
|
-
componentRegistry: [],
|
|
3479
|
-
fileTree: {
|
|
3480
|
-
dirs: new Map,
|
|
3481
|
-
expanded: new Set,
|
|
3482
|
-
searchQuery: "",
|
|
3483
|
-
selectedPath: null
|
|
3484
|
-
},
|
|
3485
|
-
projectConfig: null,
|
|
3486
|
-
projectRoot: null,
|
|
3487
|
-
styleClipboard: null,
|
|
3488
|
-
tabOrder: [],
|
|
3489
|
-
tabs: new Map,
|
|
3490
|
-
ui: {
|
|
3491
|
-
activityBar: "files"
|
|
3492
|
-
}
|
|
3493
|
-
});
|
|
3494
|
-
var activeTab = computed(() => workspace.activeTabId ? workspace.tabs.get(workspace.activeTabId) ?? null : null);
|
|
3495
|
-
function setWorkspaceProject(root, config = null) {
|
|
3496
|
-
workspace.projectRoot = root;
|
|
3497
|
-
workspace.projectConfig = config;
|
|
3498
|
-
}
|
|
3499
|
-
function isTabActive(tab) {
|
|
3500
|
-
const active = activeTab.value;
|
|
3501
|
-
return tab !== null && active !== null && toRaw(active) === toRaw(tab);
|
|
3502
|
-
}
|
|
3503
|
-
function openTab(opts) {
|
|
3504
|
-
const tab = createTab(opts);
|
|
3505
|
-
workspace.tabs.set(tab.id, tab);
|
|
3506
|
-
workspace.tabOrder.push(tab.id);
|
|
3507
|
-
workspace.activeTabId = tab.id;
|
|
3508
|
-
ensureCollab(tab);
|
|
3509
|
-
return tab;
|
|
3510
|
-
}
|
|
3511
|
-
function closeTab(tabId) {
|
|
3512
|
-
const tab = workspace.tabs.get(tabId);
|
|
3513
|
-
if (!tab) {
|
|
3514
|
-
return;
|
|
3515
|
-
}
|
|
3516
|
-
disposeTab(tab);
|
|
3517
|
-
workspace.tabs.delete(tabId);
|
|
3518
|
-
workspace.tabOrder = workspace.tabOrder.filter((id) => id !== tabId);
|
|
3519
|
-
if (workspace.activeTabId === tabId) {
|
|
3520
|
-
workspace.activeTabId = workspace.tabOrder.at(-1) || null;
|
|
3521
|
-
}
|
|
3522
|
-
}
|
|
3523
|
-
function closeAllTabs() {
|
|
3524
|
-
const tabs = [...workspace.tabs.values()];
|
|
3525
|
-
workspace.tabs.clear();
|
|
3526
|
-
workspace.tabOrder = [];
|
|
3527
|
-
workspace.activeTabId = null;
|
|
3528
|
-
for (const tab of tabs) {
|
|
3529
|
-
disposeTab(tab);
|
|
3530
|
-
}
|
|
3531
|
-
}
|
|
3532
|
-
function replaceAllTabs(newTabOpts) {
|
|
3533
|
-
const oldIds = [...workspace.tabs.keys()];
|
|
3534
|
-
const oldTabs = [...workspace.tabs.values()];
|
|
3535
|
-
const newTab = createTab(newTabOpts);
|
|
3536
|
-
workspace.tabs.set(newTab.id, newTab);
|
|
3537
|
-
workspace.activeTabId = newTab.id;
|
|
3538
|
-
workspace.tabOrder = [newTab.id];
|
|
3539
|
-
ensureCollab(newTab);
|
|
3540
|
-
for (const id of oldIds) {
|
|
3541
|
-
if (id === newTab.id) {
|
|
3542
|
-
continue;
|
|
3543
|
-
}
|
|
3544
|
-
workspace.tabs.delete(id);
|
|
3545
|
-
}
|
|
3546
|
-
for (const tab of oldTabs) {
|
|
3547
|
-
disposeTab(tab);
|
|
3548
|
-
}
|
|
3549
|
-
return newTab;
|
|
3550
|
-
}
|
|
3551
|
-
function activateTab(tabId) {
|
|
3552
|
-
if (workspace.tabs.has(tabId)) {
|
|
3553
|
-
workspace.activeTabId = tabId;
|
|
3554
|
-
}
|
|
3555
|
-
}
|
|
3556
|
-
function renameTab(oldId, newId, newDocumentPath) {
|
|
3557
|
-
const tab = workspace.tabs.get(oldId);
|
|
3558
|
-
if (!tab) {
|
|
3559
|
-
return;
|
|
3560
|
-
}
|
|
3561
|
-
tab.id = newId;
|
|
3562
|
-
tab.documentPath = newDocumentPath;
|
|
3563
|
-
workspace.tabs.delete(oldId);
|
|
3564
|
-
workspace.tabs.set(newId, tab);
|
|
3565
|
-
workspace.tabOrder = workspace.tabOrder.map((id) => id === oldId ? newId : id);
|
|
3566
|
-
if (workspace.activeTabId === oldId) {
|
|
3567
|
-
workspace.activeTabId = newId;
|
|
3568
|
-
}
|
|
3569
|
-
rekeyCollab(tab);
|
|
3570
|
-
}
|
|
3571
|
-
// src/utils/strip-events.ts
|
|
3572
|
-
function stripEventHandlers(node) {
|
|
3573
|
-
if (!node || typeof node !== "object") {
|
|
3574
|
-
return node;
|
|
3575
|
-
}
|
|
3576
|
-
if (Array.isArray(node)) {
|
|
3577
|
-
return node.map((n) => stripEventHandlers(n));
|
|
3578
|
-
}
|
|
3579
|
-
const out = {};
|
|
3580
|
-
for (const [k, v] of Object.entries(node)) {
|
|
3581
|
-
if (k.startsWith("on") && isEventBinding(v)) {
|
|
3582
|
-
continue;
|
|
3583
|
-
}
|
|
3584
|
-
if (k === "children") {
|
|
3585
|
-
out.children = Array.isArray(v) ? v.map((c) => stripEventHandlers(c)) : stripEventHandlers(v);
|
|
3586
|
-
} else if (k === "cases" && typeof v === "object") {
|
|
3587
|
-
const cases = {};
|
|
3588
|
-
for (const [ck, cv] of Object.entries(v)) {
|
|
3589
|
-
cases[ck] = stripEventHandlers(cv);
|
|
3590
|
-
}
|
|
3591
|
-
out.cases = cases;
|
|
3592
|
-
} else if (k === "state" && typeof v === "object" && v !== null) {
|
|
3593
|
-
const state = {};
|
|
3594
|
-
for (const [sk, sv] of Object.entries(v)) {
|
|
3595
|
-
if (sv && typeof sv === "object" && sv.timing === "server") {
|
|
3596
|
-
continue;
|
|
3597
|
-
}
|
|
3598
|
-
state[sk] = sv;
|
|
3599
|
-
}
|
|
3600
|
-
out.state = state;
|
|
3601
|
-
} else if (k === "style" || k === "attributes" || k === "$media") {
|
|
3602
|
-
out[k] = v;
|
|
3603
|
-
} else {
|
|
3604
|
-
out[k] = v;
|
|
3605
|
-
}
|
|
3606
|
-
}
|
|
3607
|
-
return out;
|
|
3608
|
-
}
|
|
3609
|
-
|
|
3610
|
-
// src/store.ts
|
|
3611
|
-
var canvasWrap = null;
|
|
3612
|
-
var activityBar = null;
|
|
3613
|
-
var leftPanel = null;
|
|
3614
|
-
var rightPanel = null;
|
|
3615
|
-
var chatPanelEl = null;
|
|
3616
|
-
var toolbarEl = null;
|
|
3617
|
-
var statusbarEl = null;
|
|
3618
|
-
var frontmatterPanelEl = null;
|
|
3619
|
-
function initShellRefs() {
|
|
3620
|
-
canvasWrap = document.querySelector("#canvas-wrap");
|
|
3621
|
-
activityBar = document.querySelector("#activity-bar");
|
|
3622
|
-
leftPanel = document.querySelector("#left-panel");
|
|
3623
|
-
rightPanel = document.querySelector("#right-panel");
|
|
3624
|
-
chatPanelEl = document.querySelector("#chat-panel");
|
|
3625
|
-
toolbarEl = document.querySelector("#toolbar");
|
|
3626
|
-
statusbarEl = document.querySelector("#statusbar");
|
|
3627
|
-
frontmatterPanelEl = document.querySelector("#frontmatter-panel");
|
|
3628
|
-
}
|
|
3629
|
-
var canvasPanels = [];
|
|
3630
|
-
var VOID_ELEMENTS = new Set([
|
|
3631
|
-
"area",
|
|
3632
|
-
"base",
|
|
3633
|
-
"br",
|
|
3634
|
-
"col",
|
|
3635
|
-
"embed",
|
|
3636
|
-
"hr",
|
|
3637
|
-
"img",
|
|
3638
|
-
"input",
|
|
3639
|
-
"link",
|
|
3640
|
-
"meta",
|
|
3641
|
-
"param",
|
|
3642
|
-
"source",
|
|
3643
|
-
"track",
|
|
3644
|
-
"wbr"
|
|
3645
|
-
]);
|
|
3646
|
-
var COMMON_SELECTORS = [
|
|
3647
|
-
":hover",
|
|
3648
|
-
":focus",
|
|
3649
|
-
":active",
|
|
3650
|
-
":focus-within",
|
|
3651
|
-
":focus-visible",
|
|
3652
|
-
":disabled",
|
|
3653
|
-
":first-child",
|
|
3654
|
-
":last-child",
|
|
3655
|
-
"::before",
|
|
3656
|
-
"::after",
|
|
3657
|
-
"::placeholder"
|
|
3658
|
-
];
|
|
3659
|
-
function isNestedSelector(k) {
|
|
3660
|
-
return k.startsWith(":") || k.startsWith(".") || k.startsWith("&") || k.startsWith("[");
|
|
3661
|
-
}
|
|
3662
|
-
var _styleDebounceTimers = new Map;
|
|
3663
|
-
function debouncedStyleCommit(prop, ms, fn) {
|
|
3664
|
-
return (...args) => {
|
|
3665
|
-
clearTimeout(_styleDebounceTimers.get(prop));
|
|
3666
|
-
_styleDebounceTimers.set(prop, setTimeout(() => {
|
|
3667
|
-
_styleDebounceTimers.delete(prop);
|
|
3668
|
-
fn(...args);
|
|
3669
|
-
}, ms));
|
|
3670
|
-
};
|
|
3671
|
-
}
|
|
3672
|
-
function cancelStyleDebounce(prop) {
|
|
3673
|
-
clearTimeout(_styleDebounceTimers.get(prop));
|
|
3674
|
-
_styleDebounceTimers.delete(prop);
|
|
3675
|
-
}
|
|
3676
|
-
var _renderers = new Map;
|
|
3677
|
-
function registerRenderer(name, fn) {
|
|
3678
|
-
_renderers.set(name, fn);
|
|
3679
|
-
}
|
|
3680
|
-
function render() {
|
|
3681
|
-
for (const [name, fn] of _renderers.entries()) {
|
|
3682
|
-
try {
|
|
3683
|
-
fn();
|
|
3684
|
-
} catch (error) {
|
|
3685
|
-
console.error(`Renderer "${name}" failed:`, error);
|
|
3686
|
-
}
|
|
3687
|
-
}
|
|
3688
|
-
}
|
|
3689
|
-
function renderOnly(...names) {
|
|
3690
|
-
for (const name of names) {
|
|
3691
|
-
const fn = _renderers.get(name);
|
|
3692
|
-
if (!fn) {
|
|
3693
|
-
continue;
|
|
3694
|
-
}
|
|
3695
|
-
try {
|
|
3696
|
-
fn();
|
|
3697
|
-
} catch (error) {
|
|
3698
|
-
console.error(`Renderer "${name}" failed:`, error);
|
|
3699
|
-
}
|
|
3700
|
-
}
|
|
3701
|
-
}
|
|
3702
|
-
function updateSession(patch) {
|
|
3703
|
-
const tab = activeTab.value;
|
|
3704
|
-
if (tab) {
|
|
3705
|
-
if (patch.selection !== undefined) {
|
|
3706
|
-
tab.session.selection = patch.selection;
|
|
3707
|
-
}
|
|
3708
|
-
if (patch.hover !== undefined) {
|
|
3709
|
-
tab.session.hover = patch.hover;
|
|
3710
|
-
}
|
|
3711
|
-
if (patch.clipboard !== undefined) {
|
|
3712
|
-
tab.session.clipboard = patch.clipboard;
|
|
3713
|
-
}
|
|
3714
|
-
if (patch.ui) {
|
|
3715
|
-
for (const [k, v] of Object.entries(patch.ui)) {
|
|
3716
|
-
tab.session.ui[k] = v;
|
|
3717
|
-
}
|
|
3718
|
-
}
|
|
3719
|
-
if (patch.canvas) {
|
|
3720
|
-
for (const [k, v] of Object.entries(patch.canvas)) {
|
|
3721
|
-
tab.session.canvas[k] = v;
|
|
3722
|
-
}
|
|
3723
|
-
}
|
|
3724
|
-
}
|
|
3725
|
-
}
|
|
3726
|
-
function updateUi(field, value) {
|
|
3727
|
-
const tab = activeTab.value;
|
|
3728
|
-
if (tab) {
|
|
3729
|
-
tab.session.ui[field] = value;
|
|
3730
|
-
}
|
|
3731
|
-
}
|
|
3732
|
-
function updateCanvas(patch) {
|
|
3733
|
-
const tab = activeTab.value;
|
|
3734
|
-
if (tab) {
|
|
3735
|
-
for (const [k, v] of Object.entries(patch)) {
|
|
3736
|
-
tab.session.canvas[k] = v;
|
|
3737
|
-
}
|
|
3738
|
-
}
|
|
3739
|
-
}
|
|
3740
|
-
|
|
3741
|
-
export { isJsonObject, isRef2 as isRef, isFunctionDef, isExpressionDef, isNamedFormulaDef, hasStructuredBody, isPrototypeDef, isServerFnDef, isMappedArray, isTemplateString, bodyReturnsValue, getNestedStyle, getEventBinding, paramNames, effectScope, onScopeDispose, effect, onEffectCleanup, reactive, toRaw, isRef as isRef1, ref, computed, getNodeAtPath, childList, parentElementPath, childIndex, pathKey, pathsEqual, isAncestor, flattenTree, nodeLabel, createState, projectState, setProjectState, requireProjectState, setPatchConsumer, transactDoc, transact, beginBatch, endBatch2 as endBatch, isBatching, setHistoryDelegate, canUndo, canRedo, undo, redo, mutateInsertNode, mutateRemoveNode, mutateDuplicateNode, mutateWrapNode, mutateMoveNode, mutateUpdateProperty, mutateUpdateStyle, mutateUpdateAttribute, mutateUpdateMediaStyle, mutateUpdateNestedStyle, mutateUpdateMediaNestedStyle, mutateUpdateNestedStylePath, mutateUpdateMediaNestedStylePath, mutateReplaceStyle, mutateAddDef, mutateRemoveDef, mutateUpdateDef, mutateRenameDef, mutateUpdateMedia, mutateUpdateProp, mutateAddSwitchCase, mutateRemoveSwitchCase, mutateRenameSwitchCase, mutateUpdateFrontmatter, collabState, isCollabPath, camelToKebab, camelToLabel, toCamelCase, kebabToLabel, propLabel, attrLabel, abbreviateValue, inferInputType, findContentTypeSchema, friendlyNameToVar, varDisplayName, parseCemType, jsonClone, configureCollabSerializer, configureCollabParser, configureCollabNotifier, collabSourceContext, collabSave, flushAllCollab, workspace, activeTab, setWorkspaceProject, isTabActive, openTab, closeTab, closeAllTabs, replaceAllTabs, activateTab, renameTab, stripEventHandlers, canvasWrap, activityBar, leftPanel, rightPanel, chatPanelEl, toolbarEl, statusbarEl, frontmatterPanelEl, initShellRefs, canvasPanels, VOID_ELEMENTS, COMMON_SELECTORS, isNestedSelector, debouncedStyleCommit, cancelStyleDebounce, registerRenderer, render, renderOnly, updateSession, updateUi, updateCanvas };
|
|
3742
|
-
|
|
3743
|
-
//# debugId=46676D06D14A28A964756E2164756E21
|
|
3744
|
-
//# sourceMappingURL=studio-rq0vxb19.js.map
|