@juo/blocks 1.13.0 → 1.15.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.
Files changed (157) hide show
  1. package/dist/ExtensionRoot-C3lVJEBl.js +385 -0
  2. package/dist/block.d.ts.map +1 -1
  3. package/dist/block.devtools.test.d.ts +2 -0
  4. package/dist/block.devtools.test.d.ts.map +1 -0
  5. package/dist/{bridge-w5KQ-czl.js → bridge-xiKEzCGR.js} +146 -32
  6. package/dist/context.d.ts.map +1 -1
  7. package/dist/context.devtools.test.d.ts +2 -0
  8. package/dist/context.devtools.test.d.ts.map +1 -0
  9. package/dist/core.js +786 -37
  10. package/dist/{juo-workflow-BlG9CcAG.js → css-runtime-ClH0MEYr.js} +511 -618
  11. package/dist/devtools/env.d.ts +3 -0
  12. package/dist/devtools/env.d.ts.map +1 -0
  13. package/dist/devtools/hook.d.ts +40 -0
  14. package/dist/devtools/hook.d.ts.map +1 -0
  15. package/dist/devtools/index.d.ts +5 -0
  16. package/dist/devtools/index.d.ts.map +1 -0
  17. package/dist/devtools/instrumentation.d.ts +47 -0
  18. package/dist/devtools/instrumentation.d.ts.map +1 -0
  19. package/dist/devtools/protocol.d.ts +77 -0
  20. package/dist/devtools/protocol.d.ts.map +1 -0
  21. package/dist/devtools.js +11 -0
  22. package/dist/editor/bridge.d.ts +8 -0
  23. package/dist/editor/bridge.d.ts.map +1 -1
  24. package/dist/editor/canvas-mode-signal.d.ts +22 -0
  25. package/dist/editor/canvas-mode-signal.d.ts.map +1 -0
  26. package/dist/editor/canvas-mode.d.ts +15 -0
  27. package/dist/editor/canvas-mode.d.ts.map +1 -0
  28. package/dist/editor/canvas-mode.test.d.ts +2 -0
  29. package/dist/editor/canvas-mode.test.d.ts.map +1 -0
  30. package/dist/editor/components.d.ts +113 -0
  31. package/dist/editor/components.d.ts.map +1 -1
  32. package/dist/editor/components.test.d.ts.map +1 -1
  33. package/dist/editor/handler.d.ts.map +1 -1
  34. package/dist/editor/handler.test.d.ts +2 -0
  35. package/dist/editor/handler.test.d.ts.map +1 -0
  36. package/dist/editor/layout-command-emitter.d.ts +37 -0
  37. package/dist/editor/layout-command-emitter.d.ts.map +1 -0
  38. package/dist/editor/layout-command-emitter.test.d.ts +2 -0
  39. package/dist/editor/layout-command-emitter.test.d.ts.map +1 -0
  40. package/dist/editor/layout-system-signal.d.ts +21 -0
  41. package/dist/editor/layout-system-signal.d.ts.map +1 -0
  42. package/dist/editor/main.d.ts +1 -0
  43. package/dist/editor/main.d.ts.map +1 -1
  44. package/dist/editor/messages.d.ts +96 -3
  45. package/dist/editor/messages.d.ts.map +1 -1
  46. package/dist/editor/messages.test.d.ts +2 -0
  47. package/dist/editor/messages.test.d.ts.map +1 -0
  48. package/dist/editor/surface-context.d.ts +7 -0
  49. package/dist/editor/surface-context.d.ts.map +1 -0
  50. package/dist/editor/surface-context.test.d.ts +2 -0
  51. package/dist/editor/surface-context.test.d.ts.map +1 -0
  52. package/dist/editor/wrapper-shared.d.ts +31 -0
  53. package/dist/editor/wrapper-shared.d.ts.map +1 -0
  54. package/dist/editor.js +882 -57
  55. package/dist/gridstack-adapter-CDWbSpbt.js +5489 -0
  56. package/dist/index-JSv6UH_o.js +169 -0
  57. package/dist/layout/css-runtime.d.ts +41 -0
  58. package/dist/layout/css-runtime.d.ts.map +1 -0
  59. package/dist/layout/css-runtime.test.d.ts +2 -0
  60. package/dist/layout/css-runtime.test.d.ts.map +1 -0
  61. package/dist/layout/derive.d.ts +4 -0
  62. package/dist/layout/derive.d.ts.map +1 -0
  63. package/dist/layout/derive.test.d.ts +2 -0
  64. package/dist/layout/derive.test.d.ts.map +1 -0
  65. package/dist/layout/dividers.d.ts +34 -0
  66. package/dist/layout/dividers.d.ts.map +1 -0
  67. package/dist/layout/dividers.test.d.ts +2 -0
  68. package/dist/layout/dividers.test.d.ts.map +1 -0
  69. package/dist/layout/engine.d.ts +3 -0
  70. package/dist/layout/engine.d.ts.map +1 -0
  71. package/dist/layout/engine.test.d.ts +2 -0
  72. package/dist/layout/engine.test.d.ts.map +1 -0
  73. package/dist/layout/grid-utils.d.ts +57 -0
  74. package/dist/layout/grid-utils.d.ts.map +1 -0
  75. package/dist/layout/grid-utils.test.d.ts +2 -0
  76. package/dist/layout/grid-utils.test.d.ts.map +1 -0
  77. package/dist/layout/index.d.ts +13 -0
  78. package/dist/layout/index.d.ts.map +1 -0
  79. package/dist/layout/index.test.d.ts +2 -0
  80. package/dist/layout/index.test.d.ts.map +1 -0
  81. package/dist/layout/insert.d.ts +34 -0
  82. package/dist/layout/insert.d.ts.map +1 -0
  83. package/dist/layout/insert.test.d.ts +2 -0
  84. package/dist/layout/insert.test.d.ts.map +1 -0
  85. package/dist/layout/override.d.ts +10 -0
  86. package/dist/layout/override.d.ts.map +1 -0
  87. package/dist/layout/override.test.d.ts +2 -0
  88. package/dist/layout/override.test.d.ts.map +1 -0
  89. package/dist/layout/project-css.d.ts +6 -0
  90. package/dist/layout/project-css.d.ts.map +1 -0
  91. package/dist/layout/project-css.test.d.ts +2 -0
  92. package/dist/layout/project-css.test.d.ts.map +1 -0
  93. package/dist/layout/project-gridstack.d.ts +50 -0
  94. package/dist/layout/project-gridstack.d.ts.map +1 -0
  95. package/dist/layout/project-gridstack.test.d.ts +2 -0
  96. package/dist/layout/project-gridstack.test.d.ts.map +1 -0
  97. package/dist/layout/reconcile.d.ts +23 -0
  98. package/dist/layout/reconcile.d.ts.map +1 -0
  99. package/dist/layout/reconcile.test.d.ts +2 -0
  100. package/dist/layout/reconcile.test.d.ts.map +1 -0
  101. package/dist/layout/types.d.ts +118 -0
  102. package/dist/layout/types.d.ts.map +1 -0
  103. package/dist/layout-mode-adapter-BBd4JRQd.js +21 -0
  104. package/dist/main.d.ts +7 -1
  105. package/dist/main.d.ts.map +1 -1
  106. package/dist/morph-n4LMxOYo.js +182 -0
  107. package/dist/preact/block.d.ts.map +1 -1
  108. package/dist/preact.js +14 -10
  109. package/dist/project-gridstack-CM783oKI.js +52 -0
  110. package/dist/react/block.d.ts.map +1 -1
  111. package/dist/react.js +13 -9
  112. package/dist/registry.devtools.test.d.ts +2 -0
  113. package/dist/registry.devtools.test.d.ts.map +1 -0
  114. package/dist/theme-state.d.ts +16 -0
  115. package/dist/theme-state.d.ts.map +1 -1
  116. package/dist/theme-state.layout.test.d.ts +2 -0
  117. package/dist/theme-state.layout.test.d.ts.map +1 -0
  118. package/dist/theme-state.test.d.ts +2 -0
  119. package/dist/theme-state.test.d.ts.map +1 -0
  120. package/dist/vue/block.d.ts.map +1 -1
  121. package/dist/vue.js +22 -4
  122. package/dist/web-components/ExtensionRoot.d.ts +50 -2
  123. package/dist/web-components/ExtensionRoot.d.ts.map +1 -1
  124. package/dist/web-components/editor/ExtensionRoot.d.ts +11 -0
  125. package/dist/web-components/editor/ExtensionRoot.d.ts.map +1 -0
  126. package/dist/web-components/editor/ExtensionRoot.test.d.ts +2 -0
  127. package/dist/web-components/editor/ExtensionRoot.test.d.ts.map +1 -0
  128. package/dist/web-components/editor/InlineText.d.ts +1 -0
  129. package/dist/web-components/editor/InlineText.d.ts.map +1 -1
  130. package/dist/web-components/editor/editor-layout-controller.d.ts +28 -0
  131. package/dist/web-components/editor/editor-layout-controller.d.ts.map +1 -0
  132. package/dist/web-components/editor/gridstack-adapter.d.ts +3 -0
  133. package/dist/web-components/editor/gridstack-adapter.d.ts.map +1 -0
  134. package/dist/web-components/editor/gridstack-adapter.test.d.ts +2 -0
  135. package/dist/web-components/editor/gridstack-adapter.test.d.ts.map +1 -0
  136. package/dist/web-components/editor/morph.d.ts +32 -0
  137. package/dist/web-components/editor/morph.d.ts.map +1 -0
  138. package/dist/web-components/editor/morph.test.d.ts +2 -0
  139. package/dist/web-components/editor/morph.test.d.ts.map +1 -0
  140. package/dist/web-components/layout/layout-controller.d.ts +55 -0
  141. package/dist/web-components/layout/layout-controller.d.ts.map +1 -0
  142. package/dist/web-components/layout/view-layout-controller.d.ts +17 -0
  143. package/dist/web-components/layout/view-layout-controller.d.ts.map +1 -0
  144. package/dist/web-components/layout/view-layout-controller.test.d.ts +2 -0
  145. package/dist/web-components/layout/view-layout-controller.test.d.ts.map +1 -0
  146. package/dist/web-components/layout-grid.d.ts +47 -0
  147. package/dist/web-components/layout-grid.d.ts.map +1 -0
  148. package/dist/web-components/layout-grid.test.d.ts +2 -0
  149. package/dist/web-components/layout-grid.test.d.ts.map +1 -0
  150. package/dist/web-components/layout-mode-adapter.d.ts +57 -0
  151. package/dist/web-components/layout-mode-adapter.d.ts.map +1 -0
  152. package/dist/web-components/layout-mode-adapter.test.d.ts +2 -0
  153. package/dist/web-components/layout-mode-adapter.test.d.ts.map +1 -0
  154. package/dist/web-components-editor.js +130 -17
  155. package/dist/web-components-runtime.js +4 -3
  156. package/package.json +7 -2
  157. package/dist/ExtensionRoot-2xTGTu3K.js +0 -219
@@ -1,8 +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 { z as injectContext, b as TranslationContext, E, M as ContextRoot } from "./juo-workflow-BlG9CcAG.js";
5
- import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-2xTGTu3K.js";
4
+ import { i as injectContext, T as TranslationContext, C as ContextRoot } from "./css-runtime-ClH0MEYr.js";
5
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-C3lVJEBl.js";
6
+ import { effect } from "@juo/blocks";
6
7
  class InlineText extends HTMLElement {
7
8
  constructor() {
8
9
  super(...arguments);
@@ -24,7 +25,7 @@ class InlineText extends HTMLElement {
24
25
  const blockId = (blockEl == null ? void 0 : blockEl.getAttribute("data-block-id")) ?? null;
25
26
  const service = injectContext(this, TranslationContext);
26
27
  const fallbackText = this.textContent ?? "";
27
- this.dispose = E(() => {
28
+ this.dispose = effect(() => {
28
29
  void service.locale.value;
29
30
  const resolved = service.resolve(blockType, blockId, key);
30
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.13.0",
4
+ "version": "1.15.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
  ".": {
@@ -52,6 +53,10 @@
52
53
  "./observability": {
53
54
  "types": "./dist/observability.d.ts",
54
55
  "default": "./dist/observability.js"
56
+ },
57
+ "./devtools": {
58
+ "types": "./dist/devtools.d.ts",
59
+ "default": "./dist/devtools.js"
55
60
  }
56
61
  },
57
62
  "dependencies": {
@@ -1,219 +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, J as subscribeContext, T as ThemeStateContext, E, L as withWrapper, K as n, f as backfillInstanceDefaults, F as isStubDefinition, G as onRegisterBlock } from "./juo-workflow-BlG9CcAG.js";
7
- class Block extends HTMLElement {
8
- constructor() {
9
- super();
10
- /** @description The block name to render */
11
- __publicField(this, "name", signal(null));
12
- __publicField(this, "disposeEffect");
13
- }
14
- static get observedAttributes() {
15
- return ["name"];
16
- }
17
- connectedCallback() {
18
- this.name.value = this.getAttribute("name") ?? null;
19
- this.disposeEffect = effect(() => {
20
- this.renderBlock(this.name.value);
21
- });
22
- }
23
- attributeChangedCallback(name, oldValue, newValue) {
24
- if (name === "name" && oldValue !== newValue) {
25
- this.name.value = newValue ?? null;
26
- }
27
- }
28
- disconnectedCallback() {
29
- if (this.disposeEffect) {
30
- this.disposeEffect();
31
- this.disposeEffect = void 0;
32
- }
33
- }
34
- renderBlock(name) {
35
- if (name == null) {
36
- reportBlockWarning("'name' attribute is required on <juo-block>", {
37
- site: "web-components.Block.renderBlock"
38
- });
39
- this.replaceChildren();
40
- return;
41
- }
42
- const props = Object.fromEntries(
43
- Array.from(this.attributes).map((attr) => [attr.name, attr.value])
44
- );
45
- try {
46
- const block = createBlockInstance(name, { props });
47
- this.replaceChildren(block.definition.render(block));
48
- } catch (error) {
49
- reportBlockError(error, {
50
- site: "web-components.Block.renderBlock",
51
- block: { id: "(none)", type: name },
52
- keys: { props: Object.keys(props) }
53
- });
54
- this.replaceChildren();
55
- }
56
- }
57
- }
58
- class ExtensionRoot extends HTMLElement {
59
- constructor() {
60
- super();
61
- __publicField(this, "state", d(null));
62
- __publicField(this, "themeState", null);
63
- __publicField(this, "unsubscribeThemeContext");
64
- __publicField(this, "disposeEffect");
65
- __publicField(this, "__vueInstance", null);
66
- /**
67
- * Names of top-level slot children that resolved to a stub on the last
68
- * render pass — i.e. blocks whose definition hasn't been registered yet.
69
- * Rebuilt on each render and consulted from the registration listener so
70
- * we only retrigger when a block we're actually waiting on lands.
71
- *
72
- * Only top-level children are tracked — nested stubs inside a registered
73
- * parent's renderer aren't currently handled (rare in practice; revisit
74
- * if it shows up).
75
- */
76
- __publicField(this, "unresolvedNames", /* @__PURE__ */ new Set());
77
- __publicField(this, "unregisterListener");
78
- /**
79
- * Optional function to wrap each rendered block element.
80
- * Called with the rendered block HTMLElement, must return an HTMLElement.
81
- * When set, the wrapper sits between the editor wrapper (outer) and the actual block (inner).
82
- * Must be set before blocks are first rendered; changing it afterwards has no effect
83
- * on already-cached block wrappers.
84
- */
85
- __publicField(this, "blockWrapper", null);
86
- __publicField(this, "wrapperCache", /* @__PURE__ */ new WeakMap());
87
- }
88
- static get observedAttributes() {
89
- return ["name", "surface"];
90
- }
91
- withWrapper(block) {
92
- if (!this.wrapperCache.has(block)) {
93
- const blockWrapper = this.blockWrapper;
94
- const wrapper = withWrapper((block2) => {
95
- const rendered = block2.definition.render({ ...block2, __vueInstance: this.__vueInstance });
96
- return blockWrapper ? blockWrapper(rendered) : rendered;
97
- });
98
- this.wrapperCache.set(block, wrapper);
99
- }
100
- return this.wrapperCache.get(block)(block);
101
- }
102
- getSurface() {
103
- return this.getAttribute("surface") === "overlay" ? "overlay" : "page";
104
- }
105
- setStateFromThemeState(themeState) {
106
- const surface = this.getSurface();
107
- this.state.value = surface === "overlay" ? themeState.overlay : themeState.page;
108
- }
109
- connectedCallback() {
110
- this.state.value = null;
111
- this.themeState = null;
112
- this.style.display = "flex";
113
- this.style.flexDirection = "column";
114
- this.style.maxWidth = "100%";
115
- this.unsubscribeThemeContext = subscribeContext(
116
- this,
117
- ThemeStateContext,
118
- (contextValue) => {
119
- this.themeState = contextValue;
120
- this.setStateFromThemeState(contextValue);
121
- }
122
- );
123
- this.disposeEffect = E(() => {
124
- const state = this.state.value;
125
- if (state == null) {
126
- this.replaceChildren();
127
- return;
128
- }
129
- const name = this.getAttribute("name");
130
- if (name == null) {
131
- console.error("'name' attribute is required");
132
- this.replaceChildren();
133
- return;
134
- }
135
- const blocks = state.blocks.value;
136
- n(() => {
137
- var _a;
138
- let extensionBlocks = [];
139
- try {
140
- extensionBlocks = (((_a = blocks.at(0)) == null ? void 0 : _a.slots) ?? {})[name] ?? [];
141
- for (const block of extensionBlocks) {
142
- if (block != null && typeof block === "object") {
143
- backfillInstanceDefaults(block);
144
- }
145
- }
146
- const children = extensionBlocks.map(
147
- (block) => this.withWrapper(block)
148
- );
149
- this.replaceChildren(...children);
150
- } catch (error) {
151
- reportBlockError(error, {
152
- site: "web-components.ExtensionRoot.effect",
153
- extra: {
154
- surface: this.getSurface(),
155
- name: this.getAttribute("name") ?? "(none)"
156
- }
157
- });
158
- this.replaceChildren();
159
- extensionBlocks = [];
160
- }
161
- this.unresolvedNames.clear();
162
- for (const block of extensionBlocks) {
163
- if (block != null && typeof block === "object" && isStubDefinition(block.definition)) {
164
- this.unresolvedNames.add(block.type);
165
- }
166
- }
167
- if (this.unresolvedNames.size > 0 && !this.unregisterListener) {
168
- this.unregisterListener = onRegisterBlock((name2) => {
169
- var _a2;
170
- if (!this.unresolvedNames.has(name2)) return;
171
- const stateRef = this.state.value;
172
- if (stateRef == null) return;
173
- const surfaceBlocks = stateRef.blocks.value;
174
- const slotName = this.getAttribute("name");
175
- if (slotName != null) {
176
- const children = (((_a2 = surfaceBlocks.at(0)) == null ? void 0 : _a2.slots) ?? {})[slotName] ?? [];
177
- for (const child of children) {
178
- if (child != null && typeof child === "object" && child.type === name2) {
179
- backfillInstanceDefaults(child);
180
- }
181
- }
182
- }
183
- this.state.value = { ...stateRef };
184
- });
185
- }
186
- });
187
- });
188
- }
189
- attributeChangedCallback(name, oldValue, newValue) {
190
- if ((name === "name" || name === "surface") && oldValue !== newValue && this.state.value) {
191
- if (name === "surface") {
192
- if (this.themeState) {
193
- this.setStateFromThemeState(this.themeState);
194
- return;
195
- }
196
- }
197
- this.state.value = { ...this.state.value };
198
- }
199
- }
200
- disconnectedCallback() {
201
- if (this.unsubscribeThemeContext) {
202
- this.unsubscribeThemeContext();
203
- this.unsubscribeThemeContext = void 0;
204
- }
205
- if (this.disposeEffect) {
206
- this.disposeEffect();
207
- this.disposeEffect = void 0;
208
- }
209
- if (this.unregisterListener) {
210
- this.unregisterListener();
211
- this.unregisterListener = void 0;
212
- }
213
- this.unresolvedNames.clear();
214
- }
215
- }
216
- export {
217
- Block as B,
218
- ExtensionRoot as E
219
- };