@juo/blocks 1.13.0-alpha.2 → 1.14.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/dist/ExtensionRoot-CRJx0Dtr.js +378 -0
- package/dist/block.d.ts +0 -50
- package/dist/block.d.ts.map +1 -1
- package/dist/{bridge-r7Yk8fjY.js → bridge-D838SWmN.js} +147 -42
- package/dist/context.d.ts.map +1 -1
- package/dist/core.js +1120 -2157
- package/dist/css-runtime-DWytAzZ5.js +1532 -0
- package/dist/editor/bridge.d.ts +8 -7
- package/dist/editor/bridge.d.ts.map +1 -1
- package/dist/editor/canvas-mode-signal.d.ts +22 -0
- package/dist/editor/canvas-mode-signal.d.ts.map +1 -0
- package/dist/editor/canvas-mode.d.ts +15 -0
- package/dist/editor/canvas-mode.d.ts.map +1 -0
- package/dist/editor/canvas-mode.test.d.ts +2 -0
- package/dist/editor/canvas-mode.test.d.ts.map +1 -0
- package/dist/editor/components.d.ts +113 -0
- package/dist/editor/components.d.ts.map +1 -1
- package/dist/editor/components.test.d.ts.map +1 -1
- package/dist/editor/handler.d.ts.map +1 -1
- package/dist/editor/handler.test.d.ts +2 -0
- package/dist/editor/handler.test.d.ts.map +1 -0
- package/dist/editor/layout-command-emitter.d.ts +31 -0
- package/dist/editor/layout-command-emitter.d.ts.map +1 -0
- package/dist/editor/layout-command-emitter.test.d.ts +2 -0
- package/dist/editor/layout-command-emitter.test.d.ts.map +1 -0
- package/dist/editor/layout-system-signal.d.ts +21 -0
- package/dist/editor/layout-system-signal.d.ts.map +1 -0
- package/dist/editor/main.d.ts +2 -2
- package/dist/editor/main.d.ts.map +1 -1
- package/dist/editor/messages.d.ts +90 -14
- package/dist/editor/messages.d.ts.map +1 -1
- package/dist/editor/surface-context.d.ts +7 -0
- package/dist/editor/surface-context.d.ts.map +1 -0
- package/dist/editor/surface-context.test.d.ts +2 -0
- package/dist/editor/surface-context.test.d.ts.map +1 -0
- package/dist/editor/wrapper-shared.d.ts +31 -0
- package/dist/editor/wrapper-shared.d.ts.map +1 -0
- package/dist/editor.js +887 -88
- package/dist/flows/WorkflowService.d.ts +2 -0
- package/dist/flows/WorkflowService.d.ts.map +1 -1
- package/dist/gridstack-adapter-DreG3XnB.js +5490 -0
- package/dist/layout/css-runtime.d.ts +41 -0
- package/dist/layout/css-runtime.d.ts.map +1 -0
- package/dist/layout/css-runtime.test.d.ts +2 -0
- package/dist/layout/css-runtime.test.d.ts.map +1 -0
- package/dist/layout/derive.d.ts +4 -0
- package/dist/layout/derive.d.ts.map +1 -0
- package/dist/layout/derive.test.d.ts +2 -0
- package/dist/layout/derive.test.d.ts.map +1 -0
- package/dist/layout/dividers.d.ts +34 -0
- package/dist/layout/dividers.d.ts.map +1 -0
- package/dist/layout/dividers.test.d.ts +2 -0
- package/dist/layout/dividers.test.d.ts.map +1 -0
- package/dist/layout/engine.d.ts +3 -0
- package/dist/layout/engine.d.ts.map +1 -0
- package/dist/layout/engine.test.d.ts +2 -0
- package/dist/layout/engine.test.d.ts.map +1 -0
- package/dist/layout/grid-utils.d.ts +57 -0
- package/dist/layout/grid-utils.d.ts.map +1 -0
- package/dist/layout/grid-utils.test.d.ts +2 -0
- package/dist/layout/grid-utils.test.d.ts.map +1 -0
- package/dist/layout/index.d.ts +12 -0
- package/dist/layout/index.d.ts.map +1 -0
- package/dist/layout/index.test.d.ts +2 -0
- package/dist/layout/index.test.d.ts.map +1 -0
- package/dist/layout/insert.d.ts +31 -0
- package/dist/layout/insert.d.ts.map +1 -0
- package/dist/layout/insert.test.d.ts +2 -0
- package/dist/layout/insert.test.d.ts.map +1 -0
- package/dist/layout/project-css.d.ts +6 -0
- package/dist/layout/project-css.d.ts.map +1 -0
- package/dist/layout/project-css.test.d.ts +2 -0
- package/dist/layout/project-css.test.d.ts.map +1 -0
- package/dist/layout/project-gridstack.d.ts +50 -0
- package/dist/layout/project-gridstack.d.ts.map +1 -0
- package/dist/layout/project-gridstack.test.d.ts +2 -0
- package/dist/layout/project-gridstack.test.d.ts.map +1 -0
- package/dist/layout/reconcile.d.ts +22 -0
- package/dist/layout/reconcile.d.ts.map +1 -0
- package/dist/layout/reconcile.test.d.ts +2 -0
- package/dist/layout/reconcile.test.d.ts.map +1 -0
- package/dist/layout/types.d.ts +118 -0
- package/dist/layout/types.d.ts.map +1 -0
- package/dist/layout-mode-adapter-BBd4JRQd.js +21 -0
- package/dist/main.d.ts +8 -4
- package/dist/main.d.ts.map +1 -1
- package/dist/morph-Dj-xvrwt.js +182 -0
- package/dist/preact.js +1 -1
- package/dist/project-gridstack-DYLMKSH1.js +52 -0
- package/dist/react.js +1 -1
- package/dist/services/customer/customerService.d.ts +2 -3
- package/dist/services/customer/customerService.d.ts.map +1 -1
- package/dist/services/customer/index.d.ts +0 -1
- package/dist/services/customer/index.d.ts.map +1 -1
- package/dist/services/customer/types.d.ts +1 -4
- package/dist/services/customer/types.d.ts.map +1 -1
- package/dist/services/index.d.ts +0 -3
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/login/index.d.ts +1 -3
- package/dist/services/login/index.d.ts.map +1 -1
- package/dist/services/login/loginService.d.ts +2 -6
- package/dist/services/login/loginService.d.ts.map +1 -1
- package/dist/services/orders/adapter.d.ts +0 -2
- package/dist/services/orders/adapter.d.ts.map +1 -1
- package/dist/services/orders/index.d.ts +1 -1
- package/dist/services/orders/index.d.ts.map +1 -1
- package/dist/services/product/adapter.d.ts +2 -27
- package/dist/services/product/adapter.d.ts.map +1 -1
- package/dist/services/product/index.d.ts +1 -1
- package/dist/services/product/index.d.ts.map +1 -1
- package/dist/services/product/productService.d.ts.map +1 -1
- package/dist/services/product/types.d.ts +0 -68
- package/dist/services/product/types.d.ts.map +1 -1
- package/dist/services/subscription/adapter.d.ts +2 -77
- package/dist/services/subscription/adapter.d.ts.map +1 -1
- package/dist/services/subscription/index.d.ts +1 -1
- package/dist/services/subscription/index.d.ts.map +1 -1
- package/dist/services/subscription/subscriptionService.d.ts +6 -1
- package/dist/services/subscription/subscriptionService.d.ts.map +1 -1
- package/dist/services/subscription/types.d.ts +9 -220
- package/dist/services/subscription/types.d.ts.map +1 -1
- package/dist/theme-state.d.ts +17 -2
- package/dist/theme-state.d.ts.map +1 -1
- package/dist/theme-state.layout.test.d.ts +2 -0
- package/dist/theme-state.layout.test.d.ts.map +1 -0
- package/dist/theme-state.test.d.ts +2 -0
- package/dist/theme-state.test.d.ts.map +1 -0
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/vue/block.d.ts.map +1 -1
- package/dist/vue.js +4 -25
- package/dist/web-components/ExtensionRoot.d.ts +50 -3
- package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
- package/dist/web-components/editor/ExtensionRoot.d.ts +11 -0
- package/dist/web-components/editor/ExtensionRoot.d.ts.map +1 -0
- package/dist/web-components/editor/ExtensionRoot.test.d.ts +2 -0
- package/dist/web-components/editor/ExtensionRoot.test.d.ts.map +1 -0
- package/dist/web-components/editor/InlineText.d.ts +1 -0
- package/dist/web-components/editor/InlineText.d.ts.map +1 -1
- package/dist/web-components/editor/editor-layout-controller.d.ts +28 -0
- package/dist/web-components/editor/editor-layout-controller.d.ts.map +1 -0
- package/dist/web-components/editor/gridstack-adapter.d.ts +3 -0
- package/dist/web-components/editor/gridstack-adapter.d.ts.map +1 -0
- package/dist/web-components/editor/gridstack-adapter.test.d.ts +2 -0
- package/dist/web-components/editor/gridstack-adapter.test.d.ts.map +1 -0
- package/dist/web-components/editor/morph.d.ts +32 -0
- package/dist/web-components/editor/morph.d.ts.map +1 -0
- package/dist/web-components/editor/morph.test.d.ts +2 -0
- package/dist/web-components/editor/morph.test.d.ts.map +1 -0
- package/dist/web-components/layout/layout-controller.d.ts +55 -0
- package/dist/web-components/layout/layout-controller.d.ts.map +1 -0
- package/dist/web-components/layout/view-layout-controller.d.ts +17 -0
- package/dist/web-components/layout/view-layout-controller.d.ts.map +1 -0
- package/dist/web-components/layout/view-layout-controller.test.d.ts +2 -0
- package/dist/web-components/layout/view-layout-controller.test.d.ts.map +1 -0
- package/dist/web-components/layout-grid.d.ts +47 -0
- package/dist/web-components/layout-grid.d.ts.map +1 -0
- package/dist/web-components/layout-grid.test.d.ts +2 -0
- package/dist/web-components/layout-grid.test.d.ts.map +1 -0
- package/dist/web-components/layout-mode-adapter.d.ts +51 -0
- package/dist/web-components/layout-mode-adapter.d.ts.map +1 -0
- package/dist/web-components/layout-mode-adapter.test.d.ts +2 -0
- package/dist/web-components/layout-mode-adapter.test.d.ts.map +1 -0
- package/dist/web-components-editor.js +125 -18
- package/dist/web-components-runtime.js +4 -4
- package/package.json +3 -2
- package/dist/ExtensionRoot-peABLAZZ.js +0 -231
- package/dist/block-B6s9jL7l.js +0 -966
- package/dist/block.devtools.test.d.ts +0 -2
- package/dist/block.devtools.test.d.ts.map +0 -1
- package/dist/context.devtools.test.d.ts +0 -2
- package/dist/context.devtools.test.d.ts.map +0 -1
- package/dist/devtools/env.d.ts +0 -3
- package/dist/devtools/env.d.ts.map +0 -1
- package/dist/devtools/hook.d.ts +0 -35
- package/dist/devtools/hook.d.ts.map +0 -1
- package/dist/devtools/index.d.ts +0 -4
- package/dist/devtools/index.d.ts.map +0 -1
- package/dist/devtools/protocol.d.ts +0 -91
- package/dist/devtools/protocol.d.ts.map +0 -1
- package/dist/devtools.js +0 -44
- package/dist/editor/overlays.d.ts +0 -14
- package/dist/editor/overlays.d.ts.map +0 -1
- package/dist/editor/overlays.test.d.ts +0 -2
- package/dist/editor/overlays.test.d.ts.map +0 -1
- package/dist/juo-workflow-DY4rd256.js +0 -868
- package/dist/overlay-wrapper.d.ts +0 -69
- package/dist/overlay-wrapper.d.ts.map +0 -1
- package/dist/overlay-wrapper.test.d.ts +0 -2
- package/dist/overlay-wrapper.test.d.ts.map +0 -1
- package/dist/overlays/OverlayService.d.ts +0 -34
- package/dist/overlays/OverlayService.d.ts.map +0 -1
- package/dist/overlays/OverlayService.test.d.ts +0 -2
- package/dist/overlays/OverlayService.test.d.ts.map +0 -1
- package/dist/registry.devtools.test.d.ts +0 -2
- package/dist/registry.devtools.test.d.ts.map +0 -1
- package/dist/services/customer/adapter.d.ts +0 -8
- package/dist/services/customer/adapter.d.ts.map +0 -1
- package/dist/services/login/adapter.d.ts +0 -32
- package/dist/services/login/adapter.d.ts.map +0 -1
- package/dist/services/order/adapter.d.ts +0 -9
- package/dist/services/order/adapter.d.ts.map +0 -1
- package/dist/services/order/index.d.ts +0 -5
- package/dist/services/order/index.d.ts.map +0 -1
- package/dist/services/order/orderService.d.ts +0 -7
- package/dist/services/order/orderService.d.ts.map +0 -1
- package/dist/services/order/types.d.ts +0 -21
- package/dist/services/order/types.d.ts.map +0 -1
- package/dist/services/product/adapter.test.d.ts +0 -2
- package/dist/services/product/adapter.test.d.ts.map +0 -1
- package/dist/services/schedules/adapter.d.ts +0 -71
- package/dist/services/schedules/adapter.d.ts.map +0 -1
- package/dist/services/schedules/adapter.test.d.ts +0 -2
- package/dist/services/schedules/adapter.test.d.ts.map +0 -1
- package/dist/services/schedules/index.d.ts +0 -5
- package/dist/services/schedules/index.d.ts.map +0 -1
- package/dist/services/schedules/schedulesService.d.ts +0 -11
- package/dist/services/schedules/schedulesService.d.ts.map +0 -1
- package/dist/services/schedules/schedulesService.test.d.ts +0 -2
- package/dist/services/schedules/schedulesService.test.d.ts.map +0 -1
- package/dist/services/schedules/types.d.ts +0 -226
- package/dist/services/schedules/types.d.ts.map +0 -1
- package/dist/services/settings/index.d.ts +0 -3
- package/dist/services/settings/index.d.ts.map +0 -1
- package/dist/services/settings/settingsService.d.ts +0 -7
- package/dist/services/settings/settingsService.d.ts.map +0 -1
- package/dist/services/settings/settingsService.test.d.ts +0 -2
- package/dist/services/settings/settingsService.test.d.ts.map +0 -1
- package/dist/services/settings/types.d.ts +0 -35
- package/dist/services/settings/types.d.ts.map +0 -1
- package/dist/services/shop/index.d.ts +0 -3
- package/dist/services/shop/index.d.ts.map +0 -1
- package/dist/services/shop/shopService.d.ts +0 -12
- package/dist/services/shop/shopService.d.ts.map +0 -1
- package/dist/services/shop/shopService.test.d.ts +0 -2
- package/dist/services/shop/shopService.test.d.ts.map +0 -1
- package/dist/services/shop/types.d.ts +0 -7
- package/dist/services/shop/types.d.ts.map +0 -1
- package/dist/services/subscription/adapter.test.d.ts +0 -2
- package/dist/services/subscription/adapter.test.d.ts.map +0 -1
- package/dist/services/subscription/types.test.d.ts +0 -2
- package/dist/services/subscription/types.test.d.ts.map +0 -1
- package/dist/theme-state.params.test.d.ts +0 -2
- package/dist/theme-state.params.test.d.ts.map +0 -1
- package/dist/theme-state.translations.test.d.ts +0 -2
- package/dist/theme-state.translations.test.d.ts.map +0 -1
|
@@ -1,10 +1,98 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import {
|
|
5
|
-
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
4
|
+
import { Q as injectContext, m as TranslationContext, a6 as ContextRoot } from "./css-runtime-DWytAzZ5.js";
|
|
5
|
+
import { V as ViewLayoutController, E as ExtensionRoot, B as Block } from "./ExtensionRoot-CRJx0Dtr.js";
|
|
6
|
+
import { canvasMode, getActiveSurfaceContext, emitLayoutSetRects, effect } from "@juo/blocks";
|
|
7
|
+
import { getLayoutModeAdapter } from "./layout-mode-adapter-BBd4JRQd.js";
|
|
8
|
+
import { c as createEditorBridge, d as createFocusInlineTextMessage, e as createUpdateBlockTranslationMessage } from "./bridge-D838SWmN.js";
|
|
9
|
+
import { i as initMorphController } from "./morph-Dj-xvrwt.js";
|
|
10
|
+
class EditorLayoutController {
|
|
11
|
+
constructor() {
|
|
12
|
+
__publicField(this, "currentAdapter", null);
|
|
13
|
+
__publicField(this, "view", new ViewLayoutController());
|
|
14
|
+
__publicField(this, "changeHandler", null);
|
|
15
|
+
}
|
|
16
|
+
readReactiveState() {
|
|
17
|
+
return { mode: canvasMode.value };
|
|
18
|
+
}
|
|
19
|
+
apply(host, inputs) {
|
|
20
|
+
const { extensionBlocks, children, layoutDoc, scopeId, reactive } = inputs;
|
|
21
|
+
const adapter = getLayoutModeAdapter();
|
|
22
|
+
const wantsAdapter = inputs.layoutEngineEnabled && host.hasAttribute("grid-layout") && layoutDoc != null && reactive.mode && adapter != null;
|
|
23
|
+
if (this.currentAdapter && this.currentAdapter !== adapter) {
|
|
24
|
+
this.unmountAdapter(host);
|
|
25
|
+
}
|
|
26
|
+
if (wantsAdapter) {
|
|
27
|
+
this.view.teardown(host);
|
|
28
|
+
const blockIds = extensionBlocks.map((block) => block.id);
|
|
29
|
+
const blockElements = {};
|
|
30
|
+
extensionBlocks.forEach((block, index) => {
|
|
31
|
+
blockElements[block.id] = children[index];
|
|
32
|
+
});
|
|
33
|
+
const adapterInputs = {
|
|
34
|
+
layout: layoutDoc,
|
|
35
|
+
blockIds,
|
|
36
|
+
blockElements,
|
|
37
|
+
scopeId,
|
|
38
|
+
onChange: this.handlerFor(host)
|
|
39
|
+
};
|
|
40
|
+
if (this.currentAdapter === adapter && adapter.update) {
|
|
41
|
+
adapter.update(host, adapterInputs);
|
|
42
|
+
} else {
|
|
43
|
+
this.unmountAdapter(host);
|
|
44
|
+
adapter.mount(host, adapterInputs);
|
|
45
|
+
this.currentAdapter = adapter;
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.unmountAdapter(host);
|
|
50
|
+
this.view.apply(host, inputs);
|
|
51
|
+
}
|
|
52
|
+
teardown(host) {
|
|
53
|
+
this.unmountAdapter(host);
|
|
54
|
+
this.view.teardown(host);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Idempotently unmount the currently-mounted LayoutModeAdapter. Swallows
|
|
58
|
+
* secondary teardown errors so a broken adapter can't wedge rendering.
|
|
59
|
+
*/
|
|
60
|
+
unmountAdapter(host) {
|
|
61
|
+
if (this.currentAdapter == null) return;
|
|
62
|
+
try {
|
|
63
|
+
this.currentAdapter.unmount(host);
|
|
64
|
+
} catch {
|
|
65
|
+
}
|
|
66
|
+
this.currentAdapter = null;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Stable commit-time rects handler bound to `host`'s surface. Cached so the
|
|
70
|
+
* adapter always receives the same callback reference (created once per
|
|
71
|
+
* controller/host, mirroring the previous per-element handler).
|
|
72
|
+
*/
|
|
73
|
+
handlerFor(host) {
|
|
74
|
+
if (this.changeHandler == null) {
|
|
75
|
+
this.changeHandler = (event) => {
|
|
76
|
+
const surface = this.surfaceOf(host);
|
|
77
|
+
const ctx = getActiveSurfaceContext(surface);
|
|
78
|
+
if (ctx == null) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
emitLayoutSetRects({ surface, id: ctx.id, rects: event.rects });
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
return this.changeHandler;
|
|
85
|
+
}
|
|
86
|
+
surfaceOf(host) {
|
|
87
|
+
return host.getAttribute("surface") === "overlay" ? "overlay" : "page";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
class EditorExtensionRoot extends ExtensionRoot {
|
|
91
|
+
constructor() {
|
|
92
|
+
super();
|
|
93
|
+
this.layout = new EditorLayoutController();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
8
96
|
const _InlineText = class _InlineText extends HTMLElement {
|
|
9
97
|
constructor() {
|
|
10
98
|
super();
|
|
@@ -18,6 +106,10 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
18
106
|
__publicField(this, "boundHandleClick", this.handleClick.bind(this));
|
|
19
107
|
__publicField(this, "lastValue", null);
|
|
20
108
|
__publicField(this, "dispose");
|
|
109
|
+
// One-time DOM/style setup guard — see initializeEditorMode. Persists across
|
|
110
|
+
// DOM moves so reconnecting (e.g. exiting layout mode) skips redundant,
|
|
111
|
+
// recalc-forcing style writes.
|
|
112
|
+
__publicField(this, "domInitialized", false);
|
|
21
113
|
}
|
|
22
114
|
static get observedAttributes() {
|
|
23
115
|
return ["prop", "readonly"];
|
|
@@ -61,18 +153,21 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
61
153
|
}
|
|
62
154
|
initializeEditorMode() {
|
|
63
155
|
this.editorBridge = createEditorBridge();
|
|
64
|
-
this.
|
|
65
|
-
|
|
66
|
-
this.
|
|
67
|
-
this.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
this.
|
|
156
|
+
if (!this.domInitialized) {
|
|
157
|
+
this.domInitialized = true;
|
|
158
|
+
this.contentEditable = "false";
|
|
159
|
+
if (!this.isReadonly) {
|
|
160
|
+
this.style.cursor = "text";
|
|
161
|
+
this.style.borderRadius = "2px";
|
|
162
|
+
this.style.outline = "0.5px solid transparent";
|
|
163
|
+
this.style.outlineOffset = "2px";
|
|
164
|
+
}
|
|
165
|
+
if (!this.style.width) this.style.width = "100%";
|
|
166
|
+
if (!this.style.overflowWrap) this.style.overflowWrap = "anywhere";
|
|
167
|
+
if (!this.style.whiteSpace) this.style.whiteSpace = "pre-wrap";
|
|
168
|
+
if (!this.isReadonly) {
|
|
169
|
+
this.injectStyles();
|
|
170
|
+
}
|
|
76
171
|
}
|
|
77
172
|
this.addEventListener("blur", this.boundHandleBlur);
|
|
78
173
|
this.addEventListener("pointerdown", this.boundHandlePointerDown);
|
|
@@ -81,7 +176,7 @@ const _InlineText = class _InlineText extends HTMLElement {
|
|
|
81
176
|
if (this.translationService && this.propName && this.blockType && this.blockId) {
|
|
82
177
|
const key = this.propName;
|
|
83
178
|
const fallbackText = this.textContent ?? "";
|
|
84
|
-
this.dispose =
|
|
179
|
+
this.dispose = effect(() => {
|
|
85
180
|
const service = this.translationService;
|
|
86
181
|
if (!service) return;
|
|
87
182
|
void service.locale.value;
|
|
@@ -186,7 +281,7 @@ if (customElements.get("juo-context-root") == null) {
|
|
|
186
281
|
customElements.define("juo-context-root", ContextRoot);
|
|
187
282
|
}
|
|
188
283
|
if (customElements.get("juo-extension-root") == null) {
|
|
189
|
-
customElements.define("juo-extension-root",
|
|
284
|
+
customElements.define("juo-extension-root", EditorExtensionRoot);
|
|
190
285
|
}
|
|
191
286
|
if (customElements.get("juo-block") == null) {
|
|
192
287
|
customElements.define("juo-block", Block);
|
|
@@ -194,3 +289,15 @@ if (customElements.get("juo-block") == null) {
|
|
|
194
289
|
if (customElements.get("juo-text") == null) {
|
|
195
290
|
customElements.define("juo-text", InlineText);
|
|
196
291
|
}
|
|
292
|
+
initMorphController();
|
|
293
|
+
void (async () => {
|
|
294
|
+
try {
|
|
295
|
+
const [{ createGridStackAdapter }, { registerLayoutModeAdapter }] = await Promise.all([
|
|
296
|
+
import("./gridstack-adapter-DreG3XnB.js"),
|
|
297
|
+
import("./layout-mode-adapter-BBd4JRQd.js")
|
|
298
|
+
]);
|
|
299
|
+
registerLayoutModeAdapter(createGridStackAdapter());
|
|
300
|
+
} catch (error) {
|
|
301
|
+
console.error("[blocks] failed to register GridStack adapter:", error);
|
|
302
|
+
}
|
|
303
|
+
})();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import {
|
|
5
|
-
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-
|
|
6
|
-
import {
|
|
4
|
+
import { Q as injectContext, m as TranslationContext, a6 as ContextRoot } from "./css-runtime-DWytAzZ5.js";
|
|
5
|
+
import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-CRJx0Dtr.js";
|
|
6
|
+
import { effect } from "@juo/blocks";
|
|
7
7
|
class InlineText extends HTMLElement {
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
@@ -25,7 +25,7 @@ class InlineText extends HTMLElement {
|
|
|
25
25
|
const blockId = (blockEl == null ? void 0 : blockEl.getAttribute("data-block-id")) ?? null;
|
|
26
26
|
const service = injectContext(this, TranslationContext);
|
|
27
27
|
const fallbackText = this.textContent ?? "";
|
|
28
|
-
this.dispose =
|
|
28
|
+
this.dispose = effect(() => {
|
|
29
29
|
void service.locale.value;
|
|
30
30
|
const resolved = service.resolve(blockType, blockId, key);
|
|
31
31
|
const isMissing = resolved === key || this.hasAttribute("fallback-on-empty") && resolved.trim() === "";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juo/blocks",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.14.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
"vite": "5.4.21",
|
|
19
19
|
"vite-plugin-dts": "4.5.4",
|
|
20
20
|
"vitest": "3.2.4",
|
|
21
|
-
"vue": "3.5.13"
|
|
21
|
+
"vue": "3.5.13",
|
|
22
|
+
"gridstack": "^11.5.1"
|
|
22
23
|
},
|
|
23
24
|
"exports": {
|
|
24
25
|
".": {
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { signal, effect, createBlockInstance } from "@juo/blocks";
|
|
5
|
-
import { reportBlockWarning, reportBlockError } from "./observability.js";
|
|
6
|
-
import { d, s as subscribeContext, E, w as withWrapper, n, b as backfillInstanceDefaults, a as isStubDefinition, o as onRegisterBlock } from "./block-B6s9jL7l.js";
|
|
7
|
-
import { a as ThemeStateContext } from "./juo-workflow-DY4rd256.js";
|
|
8
|
-
import { getHook } from "./devtools.js";
|
|
9
|
-
class Block extends HTMLElement {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
/** @description The block name to render */
|
|
13
|
-
__publicField(this, "name", signal(null));
|
|
14
|
-
__publicField(this, "disposeEffect");
|
|
15
|
-
}
|
|
16
|
-
static get observedAttributes() {
|
|
17
|
-
return ["name"];
|
|
18
|
-
}
|
|
19
|
-
connectedCallback() {
|
|
20
|
-
this.name.value = this.getAttribute("name") ?? null;
|
|
21
|
-
this.disposeEffect = effect(() => {
|
|
22
|
-
this.renderBlock(this.name.value);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
26
|
-
if (name === "name" && oldValue !== newValue) {
|
|
27
|
-
this.name.value = newValue ?? null;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
disconnectedCallback() {
|
|
31
|
-
if (this.disposeEffect) {
|
|
32
|
-
this.disposeEffect();
|
|
33
|
-
this.disposeEffect = void 0;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
renderBlock(name) {
|
|
37
|
-
if (name == null) {
|
|
38
|
-
reportBlockWarning("'name' attribute is required on <juo-block>", {
|
|
39
|
-
site: "web-components.Block.renderBlock"
|
|
40
|
-
});
|
|
41
|
-
this.replaceChildren();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const props = Object.fromEntries(
|
|
45
|
-
Array.from(this.attributes).map((attr) => [attr.name, attr.value])
|
|
46
|
-
);
|
|
47
|
-
try {
|
|
48
|
-
const block = createBlockInstance(name, { props });
|
|
49
|
-
this.replaceChildren(block.definition.render(block));
|
|
50
|
-
} catch (error) {
|
|
51
|
-
reportBlockError(error, {
|
|
52
|
-
site: "web-components.Block.renderBlock",
|
|
53
|
-
block: { id: "(none)", type: name },
|
|
54
|
-
keys: { props: Object.keys(props) }
|
|
55
|
-
});
|
|
56
|
-
this.replaceChildren();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
class ExtensionRoot extends HTMLElement {
|
|
61
|
-
constructor() {
|
|
62
|
-
super();
|
|
63
|
-
__publicField(this, "state", d(null));
|
|
64
|
-
__publicField(this, "themeState", null);
|
|
65
|
-
__publicField(this, "unsubscribeThemeContext");
|
|
66
|
-
__publicField(this, "disposeEffect");
|
|
67
|
-
__publicField(this, "__vueInstance", null);
|
|
68
|
-
/**
|
|
69
|
-
* Names of top-level slot children that resolved to a stub on the last
|
|
70
|
-
* render pass — i.e. blocks whose definition hasn't been registered yet.
|
|
71
|
-
* Rebuilt on each render and consulted from the registration listener so
|
|
72
|
-
* we only retrigger when a block we're actually waiting on lands.
|
|
73
|
-
*
|
|
74
|
-
* Only top-level children are tracked — nested stubs inside a registered
|
|
75
|
-
* parent's renderer aren't currently handled (rare in practice; revisit
|
|
76
|
-
* if it shows up).
|
|
77
|
-
*/
|
|
78
|
-
__publicField(this, "unresolvedNames", /* @__PURE__ */ new Set());
|
|
79
|
-
__publicField(this, "renderedIds", /* @__PURE__ */ new Set());
|
|
80
|
-
__publicField(this, "unregisterListener");
|
|
81
|
-
/**
|
|
82
|
-
* Optional function to wrap each rendered block element.
|
|
83
|
-
* Called with the rendered block HTMLElement, must return an HTMLElement.
|
|
84
|
-
* When set, the wrapper sits between the editor wrapper (outer) and the actual block (inner).
|
|
85
|
-
* Must be set before blocks are first rendered; changing it afterwards has no effect
|
|
86
|
-
* on already-cached block wrappers.
|
|
87
|
-
*/
|
|
88
|
-
__publicField(this, "blockWrapper", null);
|
|
89
|
-
__publicField(this, "wrapperCache", /* @__PURE__ */ new WeakMap());
|
|
90
|
-
}
|
|
91
|
-
static get observedAttributes() {
|
|
92
|
-
return ["name", "surface"];
|
|
93
|
-
}
|
|
94
|
-
withWrapper(block) {
|
|
95
|
-
if (!this.wrapperCache.has(block)) {
|
|
96
|
-
const blockWrapper = this.blockWrapper;
|
|
97
|
-
const wrapper = withWrapper((block2) => {
|
|
98
|
-
const rendered = block2.definition.render({ ...block2, __vueInstance: this.__vueInstance });
|
|
99
|
-
return blockWrapper ? blockWrapper(rendered) : rendered;
|
|
100
|
-
});
|
|
101
|
-
this.wrapperCache.set(block, wrapper);
|
|
102
|
-
}
|
|
103
|
-
return this.wrapperCache.get(block)(block);
|
|
104
|
-
}
|
|
105
|
-
getSurface() {
|
|
106
|
-
return this.getAttribute("surface") === "overlay" ? "overlay" : "page";
|
|
107
|
-
}
|
|
108
|
-
setStateFromThemeState(themeState) {
|
|
109
|
-
const surface = this.getSurface();
|
|
110
|
-
this.state.value = surface === "overlay" ? themeState.overlay : themeState.page;
|
|
111
|
-
}
|
|
112
|
-
connectedCallback() {
|
|
113
|
-
this.state.value = null;
|
|
114
|
-
this.themeState = null;
|
|
115
|
-
this.style.display = "flex";
|
|
116
|
-
this.style.flexDirection = "column";
|
|
117
|
-
this.style.maxWidth = "100%";
|
|
118
|
-
this.unsubscribeThemeContext = subscribeContext(
|
|
119
|
-
this,
|
|
120
|
-
ThemeStateContext,
|
|
121
|
-
(contextValue) => {
|
|
122
|
-
this.themeState = contextValue;
|
|
123
|
-
this.setStateFromThemeState(contextValue);
|
|
124
|
-
}
|
|
125
|
-
);
|
|
126
|
-
this.disposeEffect = E(() => {
|
|
127
|
-
const state = this.state.value;
|
|
128
|
-
if (state == null) {
|
|
129
|
-
this.replaceChildren();
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
const name = this.getAttribute("name");
|
|
133
|
-
if (name == null) {
|
|
134
|
-
console.error("'name' attribute is required");
|
|
135
|
-
this.replaceChildren();
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const blocks = state.blocks.value;
|
|
139
|
-
n(() => {
|
|
140
|
-
var _a;
|
|
141
|
-
let extensionBlocks = [];
|
|
142
|
-
try {
|
|
143
|
-
extensionBlocks = (((_a = blocks.at(0)) == null ? void 0 : _a.slots) ?? {})[name] ?? [];
|
|
144
|
-
for (const block of extensionBlocks) {
|
|
145
|
-
if (block != null && typeof block === "object") {
|
|
146
|
-
backfillInstanceDefaults(block);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
const children = extensionBlocks.map(
|
|
150
|
-
(block) => this.withWrapper(block)
|
|
151
|
-
);
|
|
152
|
-
this.replaceChildren(...children);
|
|
153
|
-
} catch (error) {
|
|
154
|
-
reportBlockError(error, {
|
|
155
|
-
site: "web-components.ExtensionRoot.effect",
|
|
156
|
-
extra: {
|
|
157
|
-
surface: this.getSurface(),
|
|
158
|
-
name: this.getAttribute("name") ?? "(none)"
|
|
159
|
-
}
|
|
160
|
-
});
|
|
161
|
-
this.replaceChildren();
|
|
162
|
-
extensionBlocks = [];
|
|
163
|
-
}
|
|
164
|
-
this.unresolvedNames.clear();
|
|
165
|
-
this.renderedIds.clear();
|
|
166
|
-
for (const block of extensionBlocks) {
|
|
167
|
-
if (block != null && typeof block === "object") {
|
|
168
|
-
this.renderedIds.add(block.id);
|
|
169
|
-
if (isStubDefinition(block.definition)) {
|
|
170
|
-
this.unresolvedNames.add(block.type);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (this.unresolvedNames.size > 0 && !this.unregisterListener) {
|
|
175
|
-
this.unregisterListener = onRegisterBlock((name2) => {
|
|
176
|
-
var _a2;
|
|
177
|
-
if (!this.unresolvedNames.has(name2)) return;
|
|
178
|
-
const stateRef = this.state.value;
|
|
179
|
-
if (stateRef == null) return;
|
|
180
|
-
const surfaceBlocks = stateRef.blocks.value;
|
|
181
|
-
const slotName = this.getAttribute("name");
|
|
182
|
-
if (slotName != null) {
|
|
183
|
-
const children = (((_a2 = surfaceBlocks.at(0)) == null ? void 0 : _a2.slots) ?? {})[slotName] ?? [];
|
|
184
|
-
for (const child of children) {
|
|
185
|
-
if (child != null && typeof child === "object" && child.type === name2) {
|
|
186
|
-
backfillInstanceDefaults(child);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
this.state.value = { ...stateRef };
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
attributeChangedCallback(name, oldValue, newValue) {
|
|
197
|
-
if ((name === "name" || name === "surface") && oldValue !== newValue && this.state.value) {
|
|
198
|
-
if (name === "surface") {
|
|
199
|
-
if (this.themeState) {
|
|
200
|
-
this.setStateFromThemeState(this.themeState);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
this.state.value = { ...this.state.value };
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
disconnectedCallback() {
|
|
208
|
-
if (this.unsubscribeThemeContext) {
|
|
209
|
-
this.unsubscribeThemeContext();
|
|
210
|
-
this.unsubscribeThemeContext = void 0;
|
|
211
|
-
}
|
|
212
|
-
if (this.disposeEffect) {
|
|
213
|
-
this.disposeEffect();
|
|
214
|
-
this.disposeEffect = void 0;
|
|
215
|
-
}
|
|
216
|
-
if (this.unregisterListener) {
|
|
217
|
-
this.unregisterListener();
|
|
218
|
-
this.unregisterListener = void 0;
|
|
219
|
-
}
|
|
220
|
-
const hook = getHook();
|
|
221
|
-
if (hook) {
|
|
222
|
-
for (const id of this.renderedIds) hook.emit("block:unmounted", { id });
|
|
223
|
-
}
|
|
224
|
-
this.renderedIds.clear();
|
|
225
|
-
this.unresolvedNames.clear();
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
export {
|
|
229
|
-
Block as B,
|
|
230
|
-
ExtensionRoot as E
|
|
231
|
-
};
|