@next-buildr/editor 0.0.0-stage → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +4 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/app/builder-editor.d.ts +8 -0
- package/dist/app/builder-editor.d.ts.map +1 -0
- package/dist/app/builder-editor.js +14 -0
- package/dist/app/builder-editor.test.d.ts +2 -0
- package/dist/app/builder-editor.test.d.ts.map +1 -0
- package/dist/app/builder-editor.test.js +199 -0
- package/dist/app/config.d.ts +59 -0
- package/dist/app/config.d.ts.map +1 -0
- package/dist/app/config.js +18 -0
- package/dist/app/content-language.test.d.ts +2 -0
- package/dist/app/content-language.test.d.ts.map +1 -0
- package/dist/app/content-language.test.js +157 -0
- package/dist/app/editor-app.d.ts +17 -0
- package/dist/app/editor-app.d.ts.map +1 -0
- package/dist/app/editor-app.js +206 -0
- package/dist/app/editor-app.test.d.ts +2 -0
- package/dist/app/editor-app.test.d.ts.map +1 -0
- package/dist/app/editor-app.test.js +135 -0
- package/dist/app/layout.d.ts +32 -0
- package/dist/app/layout.d.ts.map +1 -0
- package/dist/app/layout.js +82 -0
- package/dist/app/manifest.d.ts +12 -0
- package/dist/app/manifest.d.ts.map +1 -0
- package/dist/app/manifest.js +17 -0
- package/dist/app/shell-panels.d.ts +15 -0
- package/dist/app/shell-panels.d.ts.map +1 -0
- package/dist/app/shell-panels.js +5 -0
- package/dist/app/small-screen.d.ts +12 -0
- package/dist/app/small-screen.d.ts.map +1 -0
- package/dist/app/small-screen.js +33 -0
- package/dist/app/small-screen.test.d.ts +2 -0
- package/dist/app/small-screen.test.d.ts.map +1 -0
- package/dist/app/small-screen.test.js +108 -0
- package/dist/app/status-info.d.ts +14 -0
- package/dist/app/status-info.d.ts.map +1 -0
- package/dist/app/status-info.js +34 -0
- package/dist/app/use-resizable.d.ts +34 -0
- package/dist/app/use-resizable.d.ts.map +1 -0
- package/dist/app/use-resizable.js +84 -0
- package/dist/canvas-host/canvas-frame.d.ts +53 -0
- package/dist/canvas-host/canvas-frame.d.ts.map +1 -0
- package/dist/canvas-host/canvas-frame.js +146 -0
- package/dist/canvas-host/canvas-frame.test.d.ts +2 -0
- package/dist/canvas-host/canvas-frame.test.d.ts.map +1 -0
- package/dist/canvas-host/canvas-frame.test.js +91 -0
- package/dist/canvas-host/host.d.ts +109 -0
- package/dist/canvas-host/host.d.ts.map +1 -0
- package/dist/canvas-host/host.js +293 -0
- package/dist/canvas-host/host.test.d.ts +2 -0
- package/dist/canvas-host/host.test.d.ts.map +1 -0
- package/dist/canvas-host/host.test.js +398 -0
- package/dist/canvas-host/index.d.ts +5 -0
- package/dist/canvas-host/index.d.ts.map +1 -0
- package/dist/canvas-host/index.js +2 -0
- package/dist/clipboard/clipboard.d.ts +38 -0
- package/dist/clipboard/clipboard.d.ts.map +1 -0
- package/dist/clipboard/clipboard.js +160 -0
- package/dist/clipboard/clipboard.test.d.ts +2 -0
- package/dist/clipboard/clipboard.test.d.ts.map +1 -0
- package/dist/clipboard/clipboard.test.js +457 -0
- package/dist/clipboard/format.d.ts +27 -0
- package/dist/clipboard/format.d.ts.map +1 -0
- package/dist/clipboard/format.js +37 -0
- package/dist/clipboard/index.d.ts +6 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +3 -0
- package/dist/clipboard/react.d.ts +20 -0
- package/dist/clipboard/react.d.ts.map +1 -0
- package/dist/clipboard/react.js +71 -0
- package/dist/dialogs/index.d.ts +2 -0
- package/dist/dialogs/index.d.ts.map +1 -0
- package/dist/dialogs/index.js +1 -0
- package/dist/dialogs/media-picker/index.d.ts +7 -0
- package/dist/dialogs/media-picker/index.d.ts.map +1 -0
- package/dist/dialogs/media-picker/index.js +3 -0
- package/dist/dialogs/media-picker/library.d.ts +17 -0
- package/dist/dialogs/media-picker/library.d.ts.map +1 -0
- package/dist/dialogs/media-picker/library.js +9 -0
- package/dist/dialogs/media-picker/media-picker.d.ts +18 -0
- package/dist/dialogs/media-picker/media-picker.d.ts.map +1 -0
- package/dist/dialogs/media-picker/media-picker.js +99 -0
- package/dist/dialogs/media-picker/media-picker.test.d.ts +2 -0
- package/dist/dialogs/media-picker/media-picker.test.d.ts.map +1 -0
- package/dist/dialogs/media-picker/media-picker.test.js +161 -0
- package/dist/dialogs/media-picker/media-ref.d.ts +28 -0
- package/dist/dialogs/media-picker/media-ref.d.ts.map +1 -0
- package/dist/dialogs/media-picker/media-ref.js +52 -0
- package/dist/dnd/check.d.ts +8 -0
- package/dist/dnd/check.d.ts.map +1 -0
- package/dist/dnd/check.js +12 -0
- package/dist/dnd/destinations.d.ts +15 -0
- package/dist/dnd/destinations.d.ts.map +1 -0
- package/dist/dnd/destinations.js +43 -0
- package/dist/dnd/dnd-react.test.d.ts +2 -0
- package/dist/dnd/dnd-react.test.d.ts.map +1 -0
- package/dist/dnd/dnd-react.test.js +93 -0
- package/dist/dnd/dnd.test.d.ts +2 -0
- package/dist/dnd/dnd.test.d.ts.map +1 -0
- package/dist/dnd/dnd.test.js +327 -0
- package/dist/dnd/engine.d.ts +85 -0
- package/dist/dnd/engine.d.ts.map +1 -0
- package/dist/dnd/engine.js +185 -0
- package/dist/dnd/fragment.d.ts +6 -0
- package/dist/dnd/fragment.d.ts.map +1 -0
- package/dist/dnd/fragment.js +18 -0
- package/dist/dnd/geometry.d.ts +30 -0
- package/dist/dnd/geometry.d.ts.map +1 -0
- package/dist/dnd/geometry.js +31 -0
- package/dist/dnd/index.d.ts +14 -0
- package/dist/dnd/index.d.ts.map +1 -0
- package/dist/dnd/index.js +7 -0
- package/dist/dnd/move-to-dialog.d.ts +13 -0
- package/dist/dnd/move-to-dialog.d.ts.map +1 -0
- package/dist/dnd/move-to-dialog.js +30 -0
- package/dist/dnd/react.d.ts +43 -0
- package/dist/dnd/react.d.ts.map +1 -0
- package/dist/dnd/react.js +185 -0
- package/dist/dnd/tree-target.d.ts +29 -0
- package/dist/dnd/tree-target.d.ts.map +1 -0
- package/dist/dnd/tree-target.js +97 -0
- package/dist/fonts/LICENSE-inter.txt +93 -0
- package/dist/fonts/inter-latin-400-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-500-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-600-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-400-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-500-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-600-normal.woff2 +0 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/messages/en.d.ts +335 -0
- package/dist/messages/en.d.ts.map +1 -0
- package/dist/messages/en.js +332 -0
- package/dist/messages/index.d.ts +16 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +22 -0
- package/dist/messages/pl.d.ts +3 -0
- package/dist/messages/pl.d.ts.map +1 -0
- package/dist/messages/pl.js +327 -0
- package/dist/panels/breadcrumbs/breadcrumbs.d.ts +6 -0
- package/dist/panels/breadcrumbs/breadcrumbs.d.ts.map +1 -0
- package/dist/panels/breadcrumbs/breadcrumbs.js +24 -0
- package/dist/panels/breadcrumbs/breadcrumbs.test.d.ts +2 -0
- package/dist/panels/breadcrumbs/breadcrumbs.test.d.ts.map +1 -0
- package/dist/panels/breadcrumbs/breadcrumbs.test.js +56 -0
- package/dist/panels/index.d.ts +9 -0
- package/dist/panels/index.d.ts.map +1 -0
- package/dist/panels/index.js +6 -0
- package/dist/panels/insert/catalog.d.ts +30 -0
- package/dist/panels/insert/catalog.d.ts.map +1 -0
- package/dist/panels/insert/catalog.js +76 -0
- package/dist/panels/insert/catalog.order.test.d.ts +2 -0
- package/dist/panels/insert/catalog.order.test.d.ts.map +1 -0
- package/dist/panels/insert/catalog.order.test.js +17 -0
- package/dist/panels/insert/category-name.d.ts +4 -0
- package/dist/panels/insert/category-name.d.ts.map +1 -0
- package/dist/panels/insert/category-name.js +8 -0
- package/dist/panels/insert/index.d.ts +3 -0
- package/dist/panels/insert/index.d.ts.map +1 -0
- package/dist/panels/insert/index.js +2 -0
- package/dist/panels/insert/insert-panel.d.ts +7 -0
- package/dist/panels/insert/insert-panel.d.ts.map +1 -0
- package/dist/panels/insert/insert-panel.js +155 -0
- package/dist/panels/insert/insert-panel.test.d.ts +2 -0
- package/dist/panels/insert/insert-panel.test.d.ts.map +1 -0
- package/dist/panels/insert/insert-panel.test.js +323 -0
- package/dist/panels/insert/target.d.ts +17 -0
- package/dist/panels/insert/target.d.ts.map +1 -0
- package/dist/panels/insert/target.js +48 -0
- package/dist/panels/inspector/controls/boolean.d.ts +4 -0
- package/dist/panels/inspector/controls/boolean.d.ts.map +1 -0
- package/dist/panels/inspector/controls/boolean.js +4 -0
- package/dist/panels/inspector/controls/compound.d.ts +15 -0
- package/dist/panels/inspector/controls/compound.d.ts.map +1 -0
- package/dist/panels/inspector/controls/compound.js +99 -0
- package/dist/panels/inspector/controls/compound.test.d.ts +2 -0
- package/dist/panels/inspector/controls/compound.test.d.ts.map +1 -0
- package/dist/panels/inspector/controls/compound.test.js +195 -0
- package/dist/panels/inspector/controls/icon.d.ts +5 -0
- package/dist/panels/inspector/controls/icon.d.ts.map +1 -0
- package/dist/panels/inspector/controls/icon.js +6 -0
- package/dist/panels/inspector/controls/index.d.ts +13 -0
- package/dist/panels/inspector/controls/index.d.ts.map +1 -0
- package/dist/panels/inspector/controls/index.js +11 -0
- package/dist/panels/inspector/controls/label.d.ts +4 -0
- package/dist/panels/inspector/controls/label.d.ts.map +1 -0
- package/dist/panels/inspector/controls/label.js +8 -0
- package/dist/panels/inspector/controls/link.d.ts +5 -0
- package/dist/panels/inspector/controls/link.d.ts.map +1 -0
- package/dist/panels/inspector/controls/link.js +6 -0
- package/dist/panels/inspector/controls/media.d.ts +9 -0
- package/dist/panels/inspector/controls/media.d.ts.map +1 -0
- package/dist/panels/inspector/controls/media.js +21 -0
- package/dist/panels/inspector/controls/number.d.ts +10 -0
- package/dist/panels/inspector/controls/number.d.ts.map +1 -0
- package/dist/panels/inspector/controls/number.js +33 -0
- package/dist/panels/inspector/controls/rich-text-model.d.ts +20 -0
- package/dist/panels/inspector/controls/rich-text-model.d.ts.map +1 -0
- package/dist/panels/inspector/controls/rich-text-model.js +91 -0
- package/dist/panels/inspector/controls/rich-text.d.ts +10 -0
- package/dist/panels/inspector/controls/rich-text.d.ts.map +1 -0
- package/dist/panels/inspector/controls/rich-text.js +159 -0
- package/dist/panels/inspector/controls/select.d.ts +5 -0
- package/dist/panels/inspector/controls/select.d.ts.map +1 -0
- package/dist/panels/inspector/controls/select.js +16 -0
- package/dist/panels/inspector/controls/select.test.d.ts +2 -0
- package/dist/panels/inspector/controls/select.test.d.ts.map +1 -0
- package/dist/panels/inspector/controls/select.test.js +43 -0
- package/dist/panels/inspector/controls/text.d.ts +4 -0
- package/dist/panels/inspector/controls/text.d.ts.map +1 -0
- package/dist/panels/inspector/controls/text.js +5 -0
- package/dist/panels/inspector/controls/textarea.d.ts +4 -0
- package/dist/panels/inspector/controls/textarea.d.ts.map +1 -0
- package/dist/panels/inspector/controls/textarea.js +4 -0
- package/dist/panels/inspector/controls/types.d.ts +16 -0
- package/dist/panels/inspector/controls/types.d.ts.map +1 -0
- package/dist/panels/inspector/controls/types.js +1 -0
- package/dist/panels/inspector/index.d.ts +17 -0
- package/dist/panels/inspector/index.d.ts.map +1 -0
- package/dist/panels/inspector/index.js +9 -0
- package/dist/panels/inspector/inspector.d.ts +16 -0
- package/dist/panels/inspector/inspector.d.ts.map +1 -0
- package/dist/panels/inspector/inspector.js +116 -0
- package/dist/panels/inspector/inspector.test.d.ts +2 -0
- package/dist/panels/inspector/inspector.test.d.ts.map +1 -0
- package/dist/panels/inspector/inspector.test.js +328 -0
- package/dist/panels/inspector/props-panel.d.ts +26 -0
- package/dist/panels/inspector/props-panel.d.ts.map +1 -0
- package/dist/panels/inspector/props-panel.js +117 -0
- package/dist/panels/inspector/styles/box-model.d.ts +20 -0
- package/dist/panels/inspector/styles/box-model.d.ts.map +1 -0
- package/dist/panels/inspector/styles/box-model.js +31 -0
- package/dist/panels/inspector/styles/index.d.ts +5 -0
- package/dist/panels/inspector/styles/index.d.ts.map +1 -0
- package/dist/panels/inspector/styles/index.js +2 -0
- package/dist/panels/inspector/styles/model.d.ts +55 -0
- package/dist/panels/inspector/styles/model.d.ts.map +1 -0
- package/dist/panels/inspector/styles/model.js +111 -0
- package/dist/panels/inspector/styles/segments.d.ts +18 -0
- package/dist/panels/inspector/styles/segments.d.ts.map +1 -0
- package/dist/panels/inspector/styles/segments.js +75 -0
- package/dist/panels/inspector/styles/sides-editor.d.ts +34 -0
- package/dist/panels/inspector/styles/sides-editor.d.ts.map +1 -0
- package/dist/panels/inspector/styles/sides-editor.js +86 -0
- package/dist/panels/inspector/styles/style-inspector.d.ts +15 -0
- package/dist/panels/inspector/styles/style-inspector.d.ts.map +1 -0
- package/dist/panels/inspector/styles/style-inspector.js +219 -0
- package/dist/panels/inspector/styles/style-inspector.test.d.ts +2 -0
- package/dist/panels/inspector/styles/style-inspector.test.d.ts.map +1 -0
- package/dist/panels/inspector/styles/style-inspector.test.js +265 -0
- package/dist/panels/inspector/styles/token-picker.d.ts +15 -0
- package/dist/panels/inspector/styles/token-picker.d.ts.map +1 -0
- package/dist/panels/inspector/styles/token-picker.js +23 -0
- package/dist/panels/inspector/styles/use-style-value.d.ts +28 -0
- package/dist/panels/inspector/styles/use-style-value.d.ts.map +1 -0
- package/dist/panels/inspector/styles/use-style-value.js +51 -0
- package/dist/panels/inspector/value.d.ts +20 -0
- package/dist/panels/inspector/value.d.ts.map +1 -0
- package/dist/panels/inspector/value.js +32 -0
- package/dist/panels/inspector/values/analyze.d.ts +49 -0
- package/dist/panels/inspector/values/analyze.d.ts.map +1 -0
- package/dist/panels/inspector/values/analyze.js +115 -0
- package/dist/panels/inspector/values/data.d.ts +18 -0
- package/dist/panels/inspector/values/data.d.ts.map +1 -0
- package/dist/panels/inspector/values/data.js +10 -0
- package/dist/panels/inspector/values/translation.d.ts +20 -0
- package/dist/panels/inspector/values/translation.d.ts.map +1 -0
- package/dist/panels/inspector/values/translation.js +25 -0
- package/dist/panels/inspector/values/value-editor.d.ts +30 -0
- package/dist/panels/inspector/values/value-editor.d.ts.map +1 -0
- package/dist/panels/inspector/values/value-editor.js +191 -0
- package/dist/panels/inspector/values/values.test.d.ts +2 -0
- package/dist/panels/inspector/values/values.test.d.ts.map +1 -0
- package/dist/panels/inspector/values/values.test.js +173 -0
- package/dist/panels/issues/collect.d.ts +70 -0
- package/dist/panels/issues/collect.d.ts.map +1 -0
- package/dist/panels/issues/collect.js +96 -0
- package/dist/panels/issues/index.d.ts +5 -0
- package/dist/panels/issues/index.d.ts.map +1 -0
- package/dist/panels/issues/index.js +2 -0
- package/dist/panels/issues/issues-panel.d.ts +17 -0
- package/dist/panels/issues/issues-panel.d.ts.map +1 -0
- package/dist/panels/issues/issues-panel.js +77 -0
- package/dist/panels/layers/flatten.d.ts +28 -0
- package/dist/panels/layers/flatten.d.ts.map +1 -0
- package/dist/panels/layers/flatten.js +61 -0
- package/dist/panels/layers/layers-panel.d.ts +14 -0
- package/dist/panels/layers/layers-panel.d.ts.map +1 -0
- package/dist/panels/layers/layers-panel.js +428 -0
- package/dist/panels/layers/layers-panel.test.d.ts +2 -0
- package/dist/panels/layers/layers-panel.test.d.ts.map +1 -0
- package/dist/panels/layers/layers-panel.test.js +315 -0
- package/dist/persistence/controller.d.ts +55 -0
- package/dist/persistence/controller.d.ts.map +1 -0
- package/dist/persistence/controller.js +341 -0
- package/dist/persistence/index.d.ts +6 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +3 -0
- package/dist/persistence/load.d.ts +35 -0
- package/dist/persistence/load.d.ts.map +1 -0
- package/dist/persistence/load.js +67 -0
- package/dist/persistence/persistence.test.d.ts +2 -0
- package/dist/persistence/persistence.test.d.ts.map +1 -0
- package/dist/persistence/persistence.test.js +483 -0
- package/dist/persistence/react.d.ts +18 -0
- package/dist/persistence/react.d.ts.map +1 -0
- package/dist/persistence/react.js +105 -0
- package/dist/persistence/types.d.ts +182 -0
- package/dist/persistence/types.d.ts.map +1 -0
- package/dist/persistence/types.js +1 -0
- package/dist/preview/index.d.ts +3 -0
- package/dist/preview/index.d.ts.map +1 -0
- package/dist/preview/index.js +2 -0
- package/dist/preview/prepare.d.ts +16 -0
- package/dist/preview/prepare.d.ts.map +1 -0
- package/dist/preview/prepare.js +21 -0
- package/dist/preview/preview.d.ts +27 -0
- package/dist/preview/preview.d.ts.map +1 -0
- package/dist/preview/preview.js +51 -0
- package/dist/preview/preview.test.d.ts +2 -0
- package/dist/preview/preview.test.d.ts.map +1 -0
- package/dist/preview/preview.test.js +129 -0
- package/dist/shortcuts/actions.d.ts +17 -0
- package/dist/shortcuts/actions.d.ts.map +1 -0
- package/dist/shortcuts/actions.js +85 -0
- package/dist/shortcuts/index.d.ts +11 -0
- package/dist/shortcuts/index.d.ts.map +1 -0
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/keys.d.ts +29 -0
- package/dist/shortcuts/keys.d.ts.map +1 -0
- package/dist/shortcuts/keys.js +100 -0
- package/dist/shortcuts/map.d.ts +17 -0
- package/dist/shortcuts/map.d.ts.map +1 -0
- package/dist/shortcuts/map.js +31 -0
- package/dist/shortcuts/registry.d.ts +32 -0
- package/dist/shortcuts/registry.d.ts.map +1 -0
- package/dist/shortcuts/registry.js +53 -0
- package/dist/shortcuts/shortcuts.d.ts +32 -0
- package/dist/shortcuts/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts/shortcuts.js +95 -0
- package/dist/shortcuts/shortcuts.test.d.ts +2 -0
- package/dist/shortcuts/shortcuts.test.d.ts.map +1 -0
- package/dist/shortcuts/shortcuts.test.js +263 -0
- package/dist/store/create-store.d.ts +13 -0
- package/dist/store/create-store.d.ts.map +1 -0
- package/dist/store/create-store.js +248 -0
- package/dist/store/index.d.ts +9 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +5 -0
- package/dist/store/locale.d.ts +23 -0
- package/dist/store/locale.d.ts.map +1 -0
- package/dist/store/locale.js +31 -0
- package/dist/store/react.d.ts +17 -0
- package/dist/store/react.d.ts.map +1 -0
- package/dist/store/react.js +32 -0
- package/dist/store/selection.d.ts +32 -0
- package/dist/store/selection.d.ts.map +1 -0
- package/dist/store/selection.js +84 -0
- package/dist/store/selection.test.d.ts +2 -0
- package/dist/store/selection.test.d.ts.map +1 -0
- package/dist/store/selection.test.js +95 -0
- package/dist/store/selectors.d.ts +18 -0
- package/dist/store/selectors.d.ts.map +1 -0
- package/dist/store/selectors.js +39 -0
- package/dist/store/store.test.d.ts +2 -0
- package/dist/store/store.test.d.ts.map +1 -0
- package/dist/store/store.test.js +331 -0
- package/dist/store/types.d.ts +114 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +1 -0
- package/dist/styles/tokens.test.d.ts +2 -0
- package/dist/styles/tokens.test.d.ts.map +1 -0
- package/dist/styles/tokens.test.js +199 -0
- package/dist/styles.css +2885 -0
- package/dist/toolbar/brand.d.ts +7 -0
- package/dist/toolbar/brand.d.ts.map +1 -0
- package/dist/toolbar/brand.js +11 -0
- package/dist/toolbar/breakpoint-control.d.ts +9 -0
- package/dist/toolbar/breakpoint-control.d.ts.map +1 -0
- package/dist/toolbar/breakpoint-control.js +23 -0
- package/dist/toolbar/editable-title.d.ts +14 -0
- package/dist/toolbar/editable-title.d.ts.map +1 -0
- package/dist/toolbar/editable-title.js +46 -0
- package/dist/toolbar/editable-title.test.d.ts +2 -0
- package/dist/toolbar/editable-title.test.d.ts.map +1 -0
- package/dist/toolbar/editable-title.test.js +53 -0
- package/dist/toolbar/index.d.ts +12 -0
- package/dist/toolbar/index.d.ts.map +1 -0
- package/dist/toolbar/index.js +5 -0
- package/dist/toolbar/locale-switcher.d.ts +10 -0
- package/dist/toolbar/locale-switcher.d.ts.map +1 -0
- package/dist/toolbar/locale-switcher.js +20 -0
- package/dist/toolbar/more-menu.d.ts +12 -0
- package/dist/toolbar/more-menu.d.ts.map +1 -0
- package/dist/toolbar/more-menu.js +47 -0
- package/dist/toolbar/panel-toggles.d.ts +9 -0
- package/dist/toolbar/panel-toggles.d.ts.map +1 -0
- package/dist/toolbar/panel-toggles.js +19 -0
- package/dist/toolbar/publish-dialog.d.ts +18 -0
- package/dist/toolbar/publish-dialog.d.ts.map +1 -0
- package/dist/toolbar/publish-dialog.js +49 -0
- package/dist/toolbar/publish.test.d.ts +2 -0
- package/dist/toolbar/publish.test.d.ts.map +1 -0
- package/dist/toolbar/publish.test.js +258 -0
- package/dist/toolbar/sample-picker.d.ts +18 -0
- package/dist/toolbar/sample-picker.d.ts.map +1 -0
- package/dist/toolbar/sample-picker.js +72 -0
- package/dist/toolbar/sample-picker.test.d.ts +2 -0
- package/dist/toolbar/sample-picker.test.d.ts.map +1 -0
- package/dist/toolbar/sample-picker.test.js +78 -0
- package/dist/toolbar/save-indicator.d.ts +8 -0
- package/dist/toolbar/save-indicator.d.ts.map +1 -0
- package/dist/toolbar/save-indicator.js +30 -0
- package/dist/toolbar/theme.d.ts +22 -0
- package/dist/toolbar/theme.d.ts.map +1 -0
- package/dist/toolbar/theme.js +46 -0
- package/dist/toolbar/theme.test.d.ts +2 -0
- package/dist/toolbar/theme.test.d.ts.map +1 -0
- package/dist/toolbar/theme.test.js +49 -0
- package/dist/toolbar/toolbar-centre.d.ts +13 -0
- package/dist/toolbar/toolbar-centre.d.ts.map +1 -0
- package/dist/toolbar/toolbar-centre.js +7 -0
- package/dist/toolbar/toolbar-left.d.ts +12 -0
- package/dist/toolbar/toolbar-left.d.ts.map +1 -0
- package/dist/toolbar/toolbar-left.js +16 -0
- package/dist/toolbar/toolbar-right.d.ts +19 -0
- package/dist/toolbar/toolbar-right.d.ts.map +1 -0
- package/dist/toolbar/toolbar-right.js +21 -0
- package/dist/toolbar/toolbar.d.ts +38 -0
- package/dist/toolbar/toolbar.d.ts.map +1 -0
- package/dist/toolbar/toolbar.js +27 -0
- package/dist/toolbar/toolbar.test.d.ts +2 -0
- package/dist/toolbar/toolbar.test.d.ts.map +1 -0
- package/dist/toolbar/toolbar.test.js +289 -0
- package/dist/toolbar/use-overflow-level.d.ts +9 -0
- package/dist/toolbar/use-overflow-level.d.ts.map +1 -0
- package/dist/toolbar/use-overflow-level.js +40 -0
- package/dist/toolbar/zoom-menu.d.ts +10 -0
- package/dist/toolbar/zoom-menu.d.ts.map +1 -0
- package/dist/toolbar/zoom-menu.js +17 -0
- package/dist/ui/icon.d.ts +102 -0
- package/dist/ui/icon.d.ts.map +1 -0
- package/dist/ui/icon.js +182 -0
- package/dist/ui/icon.test.d.ts +2 -0
- package/dist/ui/icon.test.d.ts.map +1 -0
- package/dist/ui/icon.test.js +115 -0
- package/dist/ui/index.d.ts +11 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +5 -0
- package/dist/ui/panel.d.ts +18 -0
- package/dist/ui/panel.d.ts.map +1 -0
- package/dist/ui/panel.js +21 -0
- package/dist/ui/portal.d.ts +14 -0
- package/dist/ui/portal.d.ts.map +1 -0
- package/dist/ui/portal.js +14 -0
- package/dist/ui/primitives.d.ts +190 -0
- package/dist/ui/primitives.d.ts.map +1 -0
- package/dist/ui/primitives.js +164 -0
- package/dist/ui/primitives.test.d.ts +2 -0
- package/dist/ui/primitives.test.d.ts.map +1 -0
- package/dist/ui/primitives.test.js +215 -0
- package/dist/ui/toast.d.ts +39 -0
- package/dist/ui/toast.d.ts.map +1 -0
- package/dist/ui/toast.js +76 -0
- package/dist/ui/toast.test.d.ts +2 -0
- package/dist/ui/toast.test.d.ts.map +1 -0
- package/dist/ui/toast.test.js +95 -0
- package/package.json +67 -3
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { NodeId } from '@next-buildr/core';
|
|
2
|
+
import { type CanvasMessage, type EditorMessage, type MessageType, type PayloadOf, type Rejection, type Transport } from '@next-buildr/core/protocol';
|
|
3
|
+
import { type StoreApi } from 'zustand/vanilla';
|
|
4
|
+
import type { BreakpointConfig } from '../app/config.ts';
|
|
5
|
+
import type { EditorStore } from '../store/index.ts';
|
|
6
|
+
type Init = PayloadOf<'editor:init'>;
|
|
7
|
+
type Message<T extends MessageType> = PayloadOf<T>;
|
|
8
|
+
export type LocalesConfig = Init['locales'];
|
|
9
|
+
export type CanvasMode = Init['mode'];
|
|
10
|
+
/** How long the canvas has to answer with `canvas:hello` before the error screen shows. */
|
|
11
|
+
export declare const DEFAULT_HANDSHAKE_TIMEOUT_MS = 10000;
|
|
12
|
+
export type CanvasStatus =
|
|
13
|
+
/** Waiting for the canvas to say hello. */
|
|
14
|
+
'connecting'
|
|
15
|
+
/** The canvas has its state and is rendering it. */
|
|
16
|
+
| 'initializing' | 'ready' | 'error';
|
|
17
|
+
export type CanvasErrorKind =
|
|
18
|
+
/** No `canvas:hello` in time: a wrong URL, a `frame-ancestors` CSP, an origin the canvas does not allow. */
|
|
19
|
+
'timeout'
|
|
20
|
+
/** The canvas was built with other components than the editor knows. */
|
|
21
|
+
| 'manifest'
|
|
22
|
+
/** The canvas speaks another protocol version. */
|
|
23
|
+
| 'protocol'
|
|
24
|
+
/** The canvas reported a fatal error. */
|
|
25
|
+
| 'canvas';
|
|
26
|
+
export interface CanvasError {
|
|
27
|
+
readonly kind: CanvasErrorKind;
|
|
28
|
+
readonly message: string;
|
|
29
|
+
/** What the peer reported, when it did (the versions, the hashes). */
|
|
30
|
+
readonly details?: Readonly<Record<string, string | number>>;
|
|
31
|
+
}
|
|
32
|
+
export interface CanvasHostState {
|
|
33
|
+
readonly status: CanvasStatus;
|
|
34
|
+
readonly error: CanvasError | undefined;
|
|
35
|
+
readonly breakpoint: string;
|
|
36
|
+
readonly width: number;
|
|
37
|
+
/** `'fit'` scales the canvas down to the room there is; a number is a scale. */
|
|
38
|
+
readonly zoom: 'fit' | number;
|
|
39
|
+
readonly locale: string;
|
|
40
|
+
readonly contextRef: string | null;
|
|
41
|
+
readonly mode: CanvasMode;
|
|
42
|
+
/** What the canvas reported about the document (bindings, nodes that failed to render). */
|
|
43
|
+
readonly diagnostics: Message<'diagnostics'>['items'];
|
|
44
|
+
/** How many times the canvas has said hello: more than one means it reloaded. */
|
|
45
|
+
readonly connections: number;
|
|
46
|
+
}
|
|
47
|
+
export interface CanvasFrames {
|
|
48
|
+
request(callback: () => void): unknown;
|
|
49
|
+
cancel(handle: unknown): void;
|
|
50
|
+
}
|
|
51
|
+
export interface CanvasHostOptions {
|
|
52
|
+
readonly store: EditorStore;
|
|
53
|
+
/** The editor's end of the channel (`createParentTransport`); its `onReject` should be `host.handleReject`. */
|
|
54
|
+
readonly transport: Transport<EditorMessage, CanvasMessage>;
|
|
55
|
+
/** Of the registry the editor knows (`RegistryManifest.hash`); the canvas must have been built with the same one. */
|
|
56
|
+
readonly manifestHash: string;
|
|
57
|
+
readonly locales: LocalesConfig;
|
|
58
|
+
readonly locale?: string;
|
|
59
|
+
readonly breakpoints: readonly BreakpointConfig[];
|
|
60
|
+
readonly breakpoint?: string;
|
|
61
|
+
readonly contextRef?: string | null;
|
|
62
|
+
readonly mode?: CanvasMode;
|
|
63
|
+
readonly handshakeTimeoutMs?: number;
|
|
64
|
+
/** Batches patches once per animation frame; `requestAnimationFrame` by default. */
|
|
65
|
+
readonly frames?: CanvasFrames;
|
|
66
|
+
readonly timers?: {
|
|
67
|
+
setTimeout(callback: () => void, ms: number): unknown;
|
|
68
|
+
clearTimeout(handle: unknown): void;
|
|
69
|
+
};
|
|
70
|
+
readonly onKeyDown?: (event: Message<'key:down'>) => void;
|
|
71
|
+
readonly onContextMenu?: (event: Message<'contextmenu'>) => void;
|
|
72
|
+
readonly onNodeDoubleClick?: (event: Message<'node:dblclick'>) => void;
|
|
73
|
+
/** The canvas's answer to `dnd:over`. */
|
|
74
|
+
readonly onDropTarget?: (event: Message<'dnd:target'>) => void;
|
|
75
|
+
/** A command the canvas asked for was refused (an inline edit on a locked node, a move the rules forbid). */
|
|
76
|
+
readonly onCommandError?: (error: {
|
|
77
|
+
readonly code: string;
|
|
78
|
+
readonly message: string;
|
|
79
|
+
}) => void;
|
|
80
|
+
}
|
|
81
|
+
export interface CanvasHost {
|
|
82
|
+
readonly state: StoreApi<CanvasHostState>;
|
|
83
|
+
setBreakpoint(id: string): void;
|
|
84
|
+
setZoom(zoom: 'fit' | number): void;
|
|
85
|
+
setLocale(locale: string): void;
|
|
86
|
+
setContextRef(contextRef: string | null): void;
|
|
87
|
+
setMode(mode: CanvasMode): void;
|
|
88
|
+
/** Forwards a palette or tree drag over the canvas, in the canvas's own coordinates. */
|
|
89
|
+
dndOver(point: {
|
|
90
|
+
x: number;
|
|
91
|
+
y: number;
|
|
92
|
+
}, item: Message<'dnd:over'>['item']): void;
|
|
93
|
+
dndLeave(): void;
|
|
94
|
+
scrollTo(id: NodeId): void;
|
|
95
|
+
/** For the transport's `onReject`: a canvas of another protocol version is told apart from noise. */
|
|
96
|
+
handleReject(rejection: Rejection): void;
|
|
97
|
+
destroy(): void;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The editor's side of the canvas (docs/editor.md#the-postmessage-protocol). It answers every
|
|
101
|
+
* `canvas:hello` with `editor:init` built from the store as it is then, so a canvas that reloads
|
|
102
|
+
* loses nothing; it forwards the store's changes (patches batched once per animation frame,
|
|
103
|
+
* selection and hover at once) and turns what the canvas reports into store actions. It holds
|
|
104
|
+
* no document of its own: the store is the truth, and the canvas a replica that can always be
|
|
105
|
+
* rebuilt with `doc:set`.
|
|
106
|
+
*/
|
|
107
|
+
export declare function createCanvasHost(options: CanvasHostOptions): CanvasHost;
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../../src/canvas-host/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EACL,KAA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CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAClF,QAAQ,IAAI,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,qGAAqG;IACrG,YAAY,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI,CAAC;IACzC,OAAO,IAAI,IAAI,CAAC;CACjB;AAsBD;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAkQvE"}
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { s } from '@next-buildr/core';
|
|
2
|
+
import { MAX_PATCHES, PROTOCOL_VERSION, } from '@next-buildr/core/protocol';
|
|
3
|
+
import { createStore } from 'zustand/vanilla';
|
|
4
|
+
/** The store's document is the protocol's (it is checked against `documentSchema` at both ends); only the readonly modifiers differ. */
|
|
5
|
+
const wire = (doc) => doc;
|
|
6
|
+
/** How long the canvas has to answer with `canvas:hello` before the error screen shows. */
|
|
7
|
+
export const DEFAULT_HANDSHAKE_TIMEOUT_MS = 10_000;
|
|
8
|
+
function defaultFrames() {
|
|
9
|
+
const g = globalThis;
|
|
10
|
+
return g.requestAnimationFrame !== undefined
|
|
11
|
+
? {
|
|
12
|
+
request: (cb) => g.requestAnimationFrame?.(cb),
|
|
13
|
+
cancel: (h) => g.cancelAnimationFrame?.(h),
|
|
14
|
+
}
|
|
15
|
+
: { request: (cb) => g.setTimeout(cb, 16), cancel: (h) => g.clearTimeout(h) };
|
|
16
|
+
}
|
|
17
|
+
function defaultTimers() {
|
|
18
|
+
const g = globalThis;
|
|
19
|
+
return { setTimeout: (cb, ms) => g.setTimeout(cb, ms), clearTimeout: (h) => g.clearTimeout(h) };
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The editor's side of the canvas (docs/editor.md#the-postmessage-protocol). It answers every
|
|
23
|
+
* `canvas:hello` with `editor:init` built from the store as it is then, so a canvas that reloads
|
|
24
|
+
* loses nothing; it forwards the store's changes (patches batched once per animation frame,
|
|
25
|
+
* selection and hover at once) and turns what the canvas reports into store actions. It holds
|
|
26
|
+
* no document of its own: the store is the truth, and the canvas a replica that can always be
|
|
27
|
+
* rebuilt with `doc:set`.
|
|
28
|
+
*/
|
|
29
|
+
export function createCanvasHost(options) {
|
|
30
|
+
const { store, transport } = options;
|
|
31
|
+
const frames = options.frames ?? defaultFrames();
|
|
32
|
+
const timers = options.timers ?? defaultTimers();
|
|
33
|
+
const timeoutMs = options.handshakeTimeoutMs ?? DEFAULT_HANDSHAKE_TIMEOUT_MS;
|
|
34
|
+
const first = options.breakpoints[0];
|
|
35
|
+
const chosen = options.breakpoints.find((b) => b.id === options.breakpoint) ??
|
|
36
|
+
options.breakpoints.find((b) => b.id === 'desktop') ??
|
|
37
|
+
first;
|
|
38
|
+
if (chosen === undefined)
|
|
39
|
+
throw new Error('at least one breakpoint is required');
|
|
40
|
+
const state = createStore(() => ({
|
|
41
|
+
status: 'connecting',
|
|
42
|
+
error: undefined,
|
|
43
|
+
breakpoint: chosen.id,
|
|
44
|
+
width: chosen.width,
|
|
45
|
+
zoom: 'fit',
|
|
46
|
+
locale: options.locale ?? options.locales.default,
|
|
47
|
+
contextRef: options.contextRef ?? null,
|
|
48
|
+
mode: options.mode ?? 'edit',
|
|
49
|
+
diagnostics: [],
|
|
50
|
+
connections: 0,
|
|
51
|
+
}));
|
|
52
|
+
const live = () => {
|
|
53
|
+
const { status } = state.getState();
|
|
54
|
+
return status === 'initializing' || status === 'ready';
|
|
55
|
+
};
|
|
56
|
+
// --- what goes to the canvas ---
|
|
57
|
+
let queue = [];
|
|
58
|
+
let resend = false;
|
|
59
|
+
let frame;
|
|
60
|
+
const sendDocument = () => {
|
|
61
|
+
const { doc, docVersion } = store.getState();
|
|
62
|
+
transport.send('doc:set', { doc: wire(doc), docVersion });
|
|
63
|
+
};
|
|
64
|
+
const flush = () => {
|
|
65
|
+
frame = undefined;
|
|
66
|
+
const pending = queue;
|
|
67
|
+
const whole = resend;
|
|
68
|
+
queue = [];
|
|
69
|
+
resend = false;
|
|
70
|
+
if (!live())
|
|
71
|
+
return;
|
|
72
|
+
if (whole)
|
|
73
|
+
return sendDocument();
|
|
74
|
+
const [head] = pending;
|
|
75
|
+
const last = pending[pending.length - 1];
|
|
76
|
+
if (head === undefined || last === undefined)
|
|
77
|
+
return;
|
|
78
|
+
const patches = pending.flatMap((change) => change.patches);
|
|
79
|
+
if (patches.length > MAX_PATCHES)
|
|
80
|
+
return sendDocument();
|
|
81
|
+
transport.send('doc:patch', {
|
|
82
|
+
from: head.from,
|
|
83
|
+
to: last.to,
|
|
84
|
+
patches: patches,
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
const schedule = () => {
|
|
88
|
+
if (frame === undefined)
|
|
89
|
+
frame = frames.request(flush);
|
|
90
|
+
};
|
|
91
|
+
const offChange = store.onChange((change) => {
|
|
92
|
+
if (!live())
|
|
93
|
+
return;
|
|
94
|
+
if (change.kind === 'set') {
|
|
95
|
+
queue = [];
|
|
96
|
+
resend = true;
|
|
97
|
+
}
|
|
98
|
+
else
|
|
99
|
+
queue.push(change);
|
|
100
|
+
schedule();
|
|
101
|
+
});
|
|
102
|
+
let sentSelection = store.getState().selectedIds;
|
|
103
|
+
let sentHover = store.getState().hoveredId;
|
|
104
|
+
const offState = store.subscribe((next) => {
|
|
105
|
+
if (next.selectedIds !== sentSelection) {
|
|
106
|
+
sentSelection = next.selectedIds;
|
|
107
|
+
if (live())
|
|
108
|
+
transport.send('selection:set', { ids: [...next.selectedIds] });
|
|
109
|
+
}
|
|
110
|
+
if (next.hoveredId !== sentHover) {
|
|
111
|
+
sentHover = next.hoveredId;
|
|
112
|
+
if (live())
|
|
113
|
+
transport.send('hover:set', { id: next.hoveredId });
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
const init = () => {
|
|
117
|
+
const host = state.getState();
|
|
118
|
+
const { doc, docVersion, selectedIds } = store.getState();
|
|
119
|
+
queue = [];
|
|
120
|
+
resend = false;
|
|
121
|
+
sentSelection = selectedIds;
|
|
122
|
+
sentHover = null;
|
|
123
|
+
transport.send('editor:init', {
|
|
124
|
+
doc: wire(doc),
|
|
125
|
+
docVersion,
|
|
126
|
+
selection: [...selectedIds],
|
|
127
|
+
viewport: { breakpoint: host.breakpoint, width: host.width },
|
|
128
|
+
contextRef: host.contextRef,
|
|
129
|
+
locale: host.locale,
|
|
130
|
+
locales: options.locales,
|
|
131
|
+
mode: host.mode,
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
// --- the handshake ---
|
|
135
|
+
let handshake;
|
|
136
|
+
const fail = (error) => state.setState({ status: 'error', error });
|
|
137
|
+
handshake = timers.setTimeout(() => {
|
|
138
|
+
if (state.getState().connections === 0) {
|
|
139
|
+
fail({
|
|
140
|
+
kind: 'timeout',
|
|
141
|
+
message: 'the canvas did not answer: check its URL, its Content-Security-Policy (frame-ancestors) and the origins it allows',
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}, timeoutMs);
|
|
145
|
+
const offs = [
|
|
146
|
+
transport.on('canvas:hello', (payload) => {
|
|
147
|
+
timers.clearTimeout(handshake);
|
|
148
|
+
const { protocol, rendererVersion, manifestHash } = payload;
|
|
149
|
+
state.setState((s0) => ({ connections: s0.connections + 1, diagnostics: [] }));
|
|
150
|
+
if (protocol !== PROTOCOL_VERSION) {
|
|
151
|
+
return fail({
|
|
152
|
+
kind: 'protocol',
|
|
153
|
+
message: 'the canvas speaks another protocol version',
|
|
154
|
+
details: { editor: PROTOCOL_VERSION, canvas: protocol },
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
if (manifestHash !== options.manifestHash) {
|
|
158
|
+
return fail({
|
|
159
|
+
kind: 'manifest',
|
|
160
|
+
message: 'the canvas was built with other components than the editor knows',
|
|
161
|
+
details: { editor: options.manifestHash, canvas: manifestHash, rendererVersion },
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
state.setState({ status: 'initializing', error: undefined });
|
|
165
|
+
init();
|
|
166
|
+
}),
|
|
167
|
+
transport.on('canvas:ready', () => {
|
|
168
|
+
if (state.getState().status === 'initializing')
|
|
169
|
+
state.setState({ status: 'ready' });
|
|
170
|
+
}),
|
|
171
|
+
transport.on('doc:resync-request', () => {
|
|
172
|
+
if (!live())
|
|
173
|
+
return;
|
|
174
|
+
queue = [];
|
|
175
|
+
resend = false;
|
|
176
|
+
sendDocument();
|
|
177
|
+
}),
|
|
178
|
+
transport.on('node:click', (payload) => {
|
|
179
|
+
const { modifiers, id, instance } = payload;
|
|
180
|
+
const mode = modifiers.shift
|
|
181
|
+
? 'add'
|
|
182
|
+
: modifiers.ctrl || modifiers.meta
|
|
183
|
+
? 'toggle'
|
|
184
|
+
: 'replace';
|
|
185
|
+
store.select(id, { mode, ...(instance !== undefined ? { instance } : {}) });
|
|
186
|
+
}),
|
|
187
|
+
transport.on('node:hover', (payload) => store.setHovered(payload.id)),
|
|
188
|
+
transport.on('node:dblclick', (payload) => options.onNodeDoubleClick?.(payload)),
|
|
189
|
+
transport.on('inline:commit', (payload) => {
|
|
190
|
+
const { locale, locales } = { locale: state.getState().locale, locales: options.locales };
|
|
191
|
+
const result = store.dispatch({
|
|
192
|
+
type: 'node.setProp',
|
|
193
|
+
payload: {
|
|
194
|
+
id: payload.id,
|
|
195
|
+
prop: payload.prop,
|
|
196
|
+
value: s(payload.value),
|
|
197
|
+
...(locale !== locales.default ? { locale } : {}),
|
|
198
|
+
},
|
|
199
|
+
}, { label: 'inline-edit' });
|
|
200
|
+
if (!result.ok)
|
|
201
|
+
options.onCommandError?.(result.error);
|
|
202
|
+
}),
|
|
203
|
+
transport.on('intent:move', (payload) => {
|
|
204
|
+
const result = store.dispatch({
|
|
205
|
+
type: 'node.move',
|
|
206
|
+
payload: {
|
|
207
|
+
ids: payload.ids,
|
|
208
|
+
parentId: payload.target.parentId,
|
|
209
|
+
slot: payload.target.slot,
|
|
210
|
+
index: payload.target.index,
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
if (!result.ok)
|
|
214
|
+
options.onCommandError?.(result.error);
|
|
215
|
+
}),
|
|
216
|
+
transport.on('dnd:target', (payload) => options.onDropTarget?.(payload)),
|
|
217
|
+
transport.on('key:down', (payload) => options.onKeyDown?.(payload)),
|
|
218
|
+
transport.on('contextmenu', (payload) => options.onContextMenu?.(payload)),
|
|
219
|
+
transport.on('diagnostics', (payload) => state.setState({ diagnostics: payload.items })),
|
|
220
|
+
transport.on('canvas:error', (payload) => {
|
|
221
|
+
if (payload.fatal)
|
|
222
|
+
fail({ kind: 'canvas', message: payload.message });
|
|
223
|
+
}),
|
|
224
|
+
];
|
|
225
|
+
const sendViewport = () => {
|
|
226
|
+
const { breakpoint, width } = state.getState();
|
|
227
|
+
if (live())
|
|
228
|
+
transport.send('viewport:set', { breakpoint, width });
|
|
229
|
+
};
|
|
230
|
+
return {
|
|
231
|
+
state,
|
|
232
|
+
setBreakpoint(id) {
|
|
233
|
+
const found = options.breakpoints.find((b) => b.id === id);
|
|
234
|
+
if (found === undefined)
|
|
235
|
+
return;
|
|
236
|
+
state.setState({ breakpoint: found.id, width: found.width });
|
|
237
|
+
sendViewport();
|
|
238
|
+
},
|
|
239
|
+
setZoom: (zoom) => state.setState({ zoom }),
|
|
240
|
+
setLocale(locale) {
|
|
241
|
+
if (!options.locales.locales.includes(locale))
|
|
242
|
+
return;
|
|
243
|
+
state.setState({ locale });
|
|
244
|
+
if (live())
|
|
245
|
+
transport.send('locale:set', { locale });
|
|
246
|
+
},
|
|
247
|
+
setContextRef(contextRef) {
|
|
248
|
+
state.setState({ contextRef });
|
|
249
|
+
if (live())
|
|
250
|
+
transport.send('context:set', { contextRef });
|
|
251
|
+
},
|
|
252
|
+
setMode(mode) {
|
|
253
|
+
state.setState({ mode });
|
|
254
|
+
if (live())
|
|
255
|
+
transport.send('mode:set', { mode });
|
|
256
|
+
},
|
|
257
|
+
dndOver: (point, item) => {
|
|
258
|
+
if (live())
|
|
259
|
+
transport.send('dnd:over', { point, item });
|
|
260
|
+
},
|
|
261
|
+
dndLeave: () => {
|
|
262
|
+
if (live())
|
|
263
|
+
transport.send('dnd:leave', {});
|
|
264
|
+
},
|
|
265
|
+
scrollTo: (id) => {
|
|
266
|
+
if (live())
|
|
267
|
+
transport.send('scroll:to', { id });
|
|
268
|
+
},
|
|
269
|
+
handleReject(rejection) {
|
|
270
|
+
if (rejection.reason !== 'version' || state.getState().status === 'error')
|
|
271
|
+
return;
|
|
272
|
+
timers.clearTimeout(handshake);
|
|
273
|
+
fail({
|
|
274
|
+
kind: 'protocol',
|
|
275
|
+
message: 'the canvas speaks another protocol version',
|
|
276
|
+
details: {
|
|
277
|
+
editor: PROTOCOL_VERSION,
|
|
278
|
+
...(rejection.protocol !== undefined ? { canvas: rejection.protocol } : {}),
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
destroy() {
|
|
283
|
+
timers.clearTimeout(handshake);
|
|
284
|
+
if (frame !== undefined)
|
|
285
|
+
frames.cancel(frame);
|
|
286
|
+
offChange();
|
|
287
|
+
offState();
|
|
288
|
+
for (const off of offs)
|
|
289
|
+
off();
|
|
290
|
+
transport.close();
|
|
291
|
+
},
|
|
292
|
+
};
|
|
293
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host.test.d.ts","sourceRoot":"","sources":["../../src/canvas-host/host.test.ts"],"names":[],"mappings":""}
|