@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,3 +1,4 @@
1
+ import { LayoutController } from './layout/layout-controller';
1
2
  export default class ExtensionRoot extends HTMLElement {
2
3
  private state;
3
4
  private themeState;
@@ -16,6 +17,16 @@ export default class ExtensionRoot extends HTMLElement {
16
17
  */
17
18
  private unresolvedNames;
18
19
  private unregisterListener?;
20
+ private static scopeCounter;
21
+ private scopeId;
22
+ /**
23
+ * Pluggable layout strategy. Runtime default renders the settled CSS-Grid/flex
24
+ * view; the editor subclass swaps in a controller that adds the drag/resize
25
+ * adapter path. ExtensionRoot owns block rendering — the controller owns all
26
+ * layout side-effects on this host.
27
+ */
28
+ protected layout: LayoutController;
29
+ private getScopeId;
19
30
  /**
20
31
  * Optional function to wrap each rendered block element.
21
32
  * Called with the rendered block HTMLElement, must return an HTMLElement.
@@ -26,8 +37,45 @@ export default class ExtensionRoot extends HTMLElement {
26
37
  blockWrapper: ((rendered: HTMLElement) => HTMLElement) | null;
27
38
  static get observedAttributes(): string[];
28
39
  constructor();
29
- private wrapperCache;
30
- private withWrapper;
40
+ /**
41
+ * Rendered top-level children cached by stable block id.
42
+ *
43
+ * Keying on id (not BlockInstance identity) is what keeps entering layout
44
+ * mode cheap: a PROVIDE_THEME_STATE that re-materialises the same blocks
45
+ * into fresh instance objects reuses the existing wrapper element instead of
46
+ * recreating the whole subtree — which would otherwise tear down and
47
+ * re-request context for every nested `juo-text` and rip GridStack's managed
48
+ * elements out from under it.
49
+ *
50
+ * `render` is the memoised withWrapper closure (owns a stable outer wrapper
51
+ * element). `signature` is a content hash of the last-rendered block; when
52
+ * it is unchanged (e.g. only `canvasMode`/layout changed) we return the
53
+ * cached element without re-rendering at all. Any real content change —
54
+ * props/slots edited in place, a stub upgrading to its real definition at
55
+ * any depth — flips the signature and forces a re-render.
56
+ */
57
+ private childCache;
58
+ /**
59
+ * The layout engine the cached wrappers were built under. `withWrapper`
60
+ * (block.ts) picks the wrapper *element* (legacy chrome vs. minimal layout
61
+ * wrapper) once, at creation, from `layoutSystemEnabled`. The child cache
62
+ * keys on block id and reuses that memoised closure, so a live engine switch
63
+ * would otherwise keep the stale wrapper tag until a full refresh. Tracking
64
+ * the engine here lets us drop the cache when it flips, forcing fresh
65
+ * closures (and thus the correct wrapper element) on the next render.
66
+ */
67
+ private childCacheEngine;
68
+ /**
69
+ * Content hash of a block subtree: type, props, slot structure and the
70
+ * stub/real state of every node. Identity is deliberately excluded so a
71
+ * re-materialised-but-identical tree reuses its element; stub flags are
72
+ * included so a late-registered definition still re-renders even when its
73
+ * serialised props are unchanged.
74
+ */
75
+ private static signatureOf;
76
+ private renderChild;
77
+ /** Drop cached children whose ids are no longer rendered to avoid leaks. */
78
+ private pruneChildCache;
31
79
  private getSurface;
32
80
  private setStateFromThemeState;
33
81
  connectedCallback(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionRoot.d.ts","sourceRoot":"","sources":["../../src/web-components/ExtensionRoot.ts"],"names":[],"mappings":"AAmBA,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,uBAAuB,CAAC,CAAa;IAC7C,OAAO,CAAC,aAAa,CAAC,CAAa;IACnC,OAAO,CAAC,aAAa,CAA0C;IAE/D;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,kBAAkB,CAAC,CAAa;IAExC;;;;;;OAMG;IACI,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,WAAW,KAAK,WAAW,CAAC,GAAG,IAAI,CAAQ;IAE5E,MAAM,KAAK,kBAAkB,aAE5B;;IAMD,OAAO,CAAC,YAAY,CAGhB;IAEJ,OAAO,CAAC,WAAW;IAanB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,sBAAsB;IAM9B,iBAAiB;IAuHjB,wBAAwB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM,GAAG,IAAI;IAiBzB,oBAAoB;CAkBrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,aAAa,CAAC;KACrC;CACF"}
1
+ {"version":3,"file":"ExtensionRoot.d.ts","sourceRoot":"","sources":["../../src/web-components/ExtensionRoot.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAKnE,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,uBAAuB,CAAC,CAAa;IAC7C,OAAO,CAAC,aAAa,CAAC,CAAa;IACnC,OAAO,CAAC,aAAa,CAA0C;IAE/D;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe,CAAqB;IAC5C,OAAO,CAAC,kBAAkB,CAAC,CAAa;IACxC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAK;IAChC,OAAO,CAAC,OAAO,CAAuB;IAEtC;;;;;OAKG;IACH,SAAS,CAAC,MAAM,EAAE,gBAAgB,CAA8B;IAEhE,OAAO,CAAC,UAAU;IAOlB;;;;;;OAMG;IACI,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,WAAW,KAAK,WAAW,CAAC,GAAG,IAAI,CAAQ;IAE5E,MAAM,KAAK,kBAAkB,aAE5B;;IAMD;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,UAAU,CAOd;IAEJ;;;;;;;;OAQG;IACH,OAAO,CAAC,gBAAgB,CAAwB;IAEhD;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAiB1B,OAAO,CAAC,WAAW;IAsBnB,4EAA4E;IAC5E,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,UAAU;IAIlB,OAAO,CAAC,sBAAsB;IAM9B,iBAAiB;IA8JjB,wBAAwB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM,GAAG,IAAI;IAiBzB,oBAAoB;CAoBrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,oBAAoB,EAAE,aAAa,CAAC;KACrC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { default as ExtensionRoot } from '../ExtensionRoot';
2
+ /**
3
+ * Editor build of `juo-extension-root`. Identical to the runtime base except it
4
+ * swaps in the EditorLayoutController, which adds the drag/resize adapter path
5
+ * (and its `canvasMode` dependency). Keeping this in the editor bundle only is
6
+ * what keeps the editor layout-mode modules out of the storefront runtime.
7
+ */
8
+ export default class EditorExtensionRoot extends ExtensionRoot {
9
+ constructor();
10
+ }
11
+ //# sourceMappingURL=ExtensionRoot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionRoot.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/ExtensionRoot.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAG7C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,aAAa;;CAK7D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ExtensionRoot.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExtensionRoot.test.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/ExtensionRoot.test.ts"],"names":[],"mappings":""}
@@ -9,6 +9,7 @@ export default class InlineText extends HTMLElement {
9
9
  private boundHandleClick;
10
10
  private lastValue;
11
11
  private dispose?;
12
+ private domInitialized;
12
13
  static get observedAttributes(): string[];
13
14
  constructor();
14
15
  connectedCallback(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"InlineText.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/InlineText.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,kBAAkB,CAAmC;IAC7D,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,sBAAsB,CAAqC;IACnE,OAAO,CAAC,gBAAgB,CAA+B;IACvD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAC,CAAa;IAE7B,MAAM,KAAK,kBAAkB,aAE5B;;IAMD,iBAAiB;IA0CjB,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,oBAAoB;IAiD5B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAwC;IAEpE,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,UAAU;IA+BlB,wBAAwB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOzB,oBAAoB;CASrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,UAAU,CAAC;KACxB;CACF"}
1
+ {"version":3,"file":"InlineText.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/InlineText.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,WAAW;IACjD,OAAO,CAAC,YAAY,CAAsD;IAC1E,OAAO,CAAC,kBAAkB,CAAmC;IAC7D,OAAO,CAAC,QAAQ,CAAuB;IACvC,OAAO,CAAC,OAAO,CAAuB;IACtC,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,eAAe,CAA8B;IACrD,OAAO,CAAC,sBAAsB,CAAqC;IACnE,OAAO,CAAC,gBAAgB,CAA+B;IACvD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,OAAO,CAAC,CAAa;IAI7B,OAAO,CAAC,cAAc,CAAS;IAE/B,MAAM,KAAK,kBAAkB,aAE5B;;IAMD,iBAAiB;IA0CjB,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,CAAC,oBAAoB;IA2D5B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,WAAW;IAUnB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAwC;IAEpE,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,UAAU;IA+BlB,wBAAwB,CACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOzB,oBAAoB;CASrB;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,UAAU,EAAE,UAAU,CAAC;KACxB;CACF"}
@@ -0,0 +1,28 @@
1
+ import { LayoutApplyInputs, LayoutController, LayoutReactiveState } from '../layout/layout-controller';
2
+ /**
3
+ * Editor layout strategy: while layout (drag/resize) mode is active and a
4
+ * LayoutModeAdapter (GridStack) is registered, delegates layout to the adapter;
5
+ * otherwise falls back to the settled CSS-Grid/flex view via ViewLayoutController.
6
+ * Only ever loaded into the editor bundle — never the storefront runtime.
7
+ */
8
+ export declare class EditorLayoutController implements LayoutController {
9
+ private currentAdapter;
10
+ private readonly view;
11
+ private changeHandler;
12
+ readReactiveState(): LayoutReactiveState;
13
+ apply(host: HTMLElement, inputs: LayoutApplyInputs): void;
14
+ teardown(host: HTMLElement): void;
15
+ /**
16
+ * Idempotently unmount the currently-mounted LayoutModeAdapter. Swallows
17
+ * secondary teardown errors so a broken adapter can't wedge rendering.
18
+ */
19
+ private unmountAdapter;
20
+ /**
21
+ * Stable commit-time rects handler bound to `host`'s surface. Cached so the
22
+ * adapter always receives the same callback reference (created once per
23
+ * controller/host, mirroring the previous per-element handler).
24
+ */
25
+ private handlerFor;
26
+ private surfaceOf;
27
+ }
28
+ //# sourceMappingURL=editor-layout-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-layout-controller.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/editor-layout-controller.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,6BAA6B,CAAC;AAQrC;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,gBAAgB;IAC7D,OAAO,CAAC,cAAc,CAAkC;IACxD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA8B;IACnD,OAAO,CAAC,aAAa,CAAyD;IAE9E,iBAAiB,IAAI,mBAAmB;IAIxC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IA2DzD,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;IAKjC;;;OAGG;IACH,OAAO,CAAC,cAAc;IAUtB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,SAAS;CAGlB"}
@@ -0,0 +1,3 @@
1
+ import { LayoutModeAdapter } from '../layout-mode-adapter';
2
+ export declare function createGridStackAdapter(): LayoutModeAdapter;
3
+ //# sourceMappingURL=gridstack-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gridstack-adapter.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/gridstack-adapter.ts"],"names":[],"mappings":"AAkBA,OAAO,EAIL,KAAK,iBAAiB,EAGvB,MAAM,wBAAwB,CAAC;AAuehC,wBAAgB,sBAAsB,IAAI,iBAAiB,CAmd1D"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=gridstack-adapter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gridstack-adapter.test.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/gridstack-adapter.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Run `fn` (a mode swap) inside a View Transition when supported and motion is
3
+ * allowed; otherwise apply it instantly. Assigns per-block `view-transition-name`s
4
+ * so each block morphs from its old rect to its new rect, clearing them once the
5
+ * transition finishes. Used for EXIT/settle and the button toggle — entry-from-grab
6
+ * deliberately bypasses this for instant continuity.
7
+ */
8
+ export declare function withMorphTransition(fn: () => void): Promise<void>;
9
+ /**
10
+ * Enter layout mode from a click on a block's arrange handle ("click to arm").
11
+ * The mode swap is a smooth View Transition morph; the user then drags/resizes
12
+ * the block natively in GridStack. When `block` is given (the exact wrapper the
13
+ * operator grabbed), it is scrolled into view as part of the morph and then
14
+ * plays a one-shot "pop" so it doesn't get lost across the reflow. Passing the
15
+ * element — not an id — avoids targeting the wrong node when blocks share an id.
16
+ * Layout mode persists until an explicit exit (click-away / Escape / button);
17
+ * exit listeners are bound reactively from `canvasMode` in `initMorphController`.
18
+ */
19
+ export declare function enterLayout(block?: HTMLElement): void;
20
+ /** Smoothly morph back to view mode (click-away / Escape / button toggle off). */
21
+ export declare function exitToView(): void;
22
+ /**
23
+ * Wire the controller's lifecycle. Idempotent — safe to call on every load.
24
+ *
25
+ * - Binds/unbinds the click-away + Escape exit listeners from `canvasMode`, so
26
+ * exit works regardless of how layout mode was entered (click-to-arm or the
27
+ * "Edit layout" button).
28
+ * - Tracks an "interacting" flag from the adapter's drag/resize lifecycle so a
29
+ * pointerdown that ends a gesture can't be mistaken for click-away.
30
+ */
31
+ export declare function initMorphController(): void;
32
+ //# sourceMappingURL=morph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/morph.ts"],"names":[],"mappings":"AAuKA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCjE;AAyCD;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,WAAW,GAAG,IAAI,CAkBrD;AAED,kFAAkF;AAClF,wBAAgB,UAAU,IAAI,IAAI,CAMjC;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAa1C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=morph.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"morph.test.d.ts","sourceRoot":"","sources":["../../../src/web-components/editor/morph.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,55 @@
1
+ import { BlockInstance } from '../../block';
2
+ import { LayoutDocument } from '../../layout';
3
+ /**
4
+ * Reactive inputs a LayoutController reads inside the ExtensionRoot effect's
5
+ * TRACKED scope. Keeping these behind `readReactiveState()` is what lets the
6
+ * editor controller subscribe the effect to `canvasMode` while the runtime
7
+ * controller subscribes to nothing.
8
+ */
9
+ export type LayoutReactiveState = {
10
+ /** Whether the editor layout (drag/resize) mode is active. Always false at runtime. */
11
+ mode: boolean;
12
+ };
13
+ /**
14
+ * Everything a LayoutController needs to lay out a host's children. Assembled
15
+ * by ExtensionRoot each render pass; `children` are the already-rendered,
16
+ * cached block elements in render order (parallel to `extensionBlocks`).
17
+ */
18
+ export type LayoutApplyInputs = {
19
+ extensionBlocks: BlockInstance[];
20
+ children: HTMLElement[];
21
+ layoutDoc: LayoutDocument | null;
22
+ /** Stable per-host scope id for the generated grid stylesheet. */
23
+ scopeId: string;
24
+ reactive: LayoutReactiveState;
25
+ /**
26
+ * Whether the active theme opts into the grid layout engine
27
+ * (`GlobalStyles.layoutEngine === "grid-v1"`). The `grid-layout` attribute is
28
+ * a per-surface CAPABILITY flag; this is the theme-level ON switch. Both must
29
+ * be true for the grid path to run — legacy themes render the flex/stacked
30
+ * view even on grid-capable surfaces.
31
+ */
32
+ layoutEngineEnabled: boolean;
33
+ };
34
+ /**
35
+ * Pluggable layout strategy for ExtensionRoot. The runtime variant applies a
36
+ * CSS-Grid/flex view; the editor variant additionally delegates to a
37
+ * LayoutModeAdapter (GridStack) while in layout mode. ExtensionRoot owns block
38
+ * rendering; the controller owns all layout/geometry side-effects on the host.
39
+ */
40
+ export interface LayoutController {
41
+ /**
42
+ * Called in the effect's TRACKED scope so any signal reads register as
43
+ * effect dependencies (e.g. the editor controller reads `canvasMode` here so
44
+ * entering/exiting layout mode re-runs the effect).
45
+ */
46
+ readReactiveState(): LayoutReactiveState;
47
+ /** Called in untracked scope: apply layout to `host`. */
48
+ apply(host: HTMLElement, inputs: LayoutApplyInputs): void;
49
+ /**
50
+ * Idempotent: undo any persistent layout side-effect (adapter mount, grid
51
+ * containment). Called on empty/error render branches and on disconnect.
52
+ */
53
+ teardown(host: HTMLElement): void;
54
+ }
55
+ //# sourceMappingURL=layout-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-controller.d.ts","sourceRoot":"","sources":["../../../src/web-components/layout/layout-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,uFAAuF;IACvF,IAAI,EAAE,OAAO,CAAC;CACf,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,eAAe,EAAE,aAAa,EAAE,CAAC;IACjC,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC;IACjC,kEAAkE;IAClE,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B;;;;;;OAMG;IACH,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,iBAAiB,IAAI,mBAAmB,CAAC;IACzC,yDAAyD;IACzD,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAC1D;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;CACnC"}
@@ -0,0 +1,17 @@
1
+ import { LayoutApplyInputs, LayoutController, LayoutReactiveState } from './layout-controller';
2
+ /**
3
+ * Runtime layout strategy: renders the settled CSS-Grid view (or a flex column
4
+ * when no grid layout applies). No editor/canvas dependencies — this is the
5
+ * only layout code the storefront runtime bundle pulls in.
6
+ *
7
+ * Stateless: empty-block collapse is handled entirely in the generated CSS (an
8
+ * empty block sets `display:none` and row spacing is a per-item margin, so its
9
+ * row closes with no ghost gap), so there is nothing to observe or recompute at
10
+ * runtime.
11
+ */
12
+ export declare class ViewLayoutController implements LayoutController {
13
+ readReactiveState(): LayoutReactiveState;
14
+ apply(host: HTMLElement, inputs: LayoutApplyInputs): void;
15
+ teardown(host: HTMLElement): void;
16
+ }
17
+ //# sourceMappingURL=view-layout-controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-layout-controller.d.ts","sourceRoot":"","sources":["../../../src/web-components/layout/view-layout-controller.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B;;;;;;;;;GASG;AACH,qBAAa,oBAAqB,YAAW,gBAAgB;IAC3D,iBAAiB,IAAI,mBAAmB;IAIxC,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAyBzD,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;CAGlC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=view-layout-controller.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-layout-controller.test.d.ts","sourceRoot":"","sources":["../../../src/web-components/layout/view-layout-controller.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ export type GridLayoutItem = {
2
+ blockId: string;
3
+ element: HTMLElement;
4
+ };
5
+ /** Per-item boolean-attribute tags derived from the runtime layout. */
6
+ export type GridLayoutTags = {
7
+ /**
8
+ * Leader block ids (leftmost block of each divider row). Tagged with
9
+ * `data-juo-divider` so the surface stylesheet draws the full-width divider
10
+ * line above them.
11
+ */
12
+ dividerBlockIds?: ReadonlySet<string>;
13
+ /**
14
+ * Every block on a divider row. Tagged with `data-juo-divider-row` so the
15
+ * surface stylesheet adds the extra divider-row spacing (top margin) — only
16
+ * boundaries that actually show a divider grow; others keep the base row-gap.
17
+ */
18
+ dividerRowBlockIds?: ReadonlySet<string>;
19
+ /**
20
+ * Blocks currently spanning the full row width. Tagged with
21
+ * `data-juo-grid-full-width` so the block wrapper chrome can show the "fill"
22
+ * toggle as active.
23
+ */
24
+ fullWidthBlockIds?: ReadonlySet<string>;
25
+ };
26
+ export type GridLayoutInputs = GridLayoutTags & {
27
+ scopeId: string;
28
+ css: string;
29
+ items: GridLayoutItem[];
30
+ };
31
+ /**
32
+ * Assemble a CSS-Grid layout inside `host`:
33
+ * - host becomes the container-query container (container-type: inline-size)
34
+ * - a <style> child carries the scoped stylesheet
35
+ * - an inner [data-juo-layout] grid element holds the block items
36
+ * - each item element is tagged with data-block-id so projectToCss's
37
+ * `${scope} > [data-block-id]` rules match
38
+ *
39
+ * Replaces the host's children with [styleEl, gridEl]. The host/grid split is
40
+ * required because an element cannot be matched by its own @container query:
41
+ * the host hosts the container-query context; the inner grid (a descendant)
42
+ * is what the @container rules target.
43
+ */
44
+ export declare function applyGridLayout(host: HTMLElement, inputs: GridLayoutInputs): void;
45
+ /** Revert the container-query containment applied by applyGridLayout. */
46
+ export declare function clearGridLayout(host: HTMLElement): void;
47
+ //# sourceMappingURL=layout-grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-grid.d.ts","sourceRoot":"","sources":["../../src/web-components/layout-grid.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAEvE,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;OAIG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB,CAAC;AAqBF;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAgBjF;AAED,yEAAyE;AACzE,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAEvD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=layout-grid.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-grid.test.d.ts","sourceRoot":"","sources":["../../src/web-components/layout-grid.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import { GridRect, LayoutDocument } from '../layout';
2
+ /**
3
+ * Bubbling, composed DOM CustomEvents an adapter fires on its host while the
4
+ * user is actively manipulating the layout (drag/resize). The morph controller
5
+ * listens for these to drive the idle-settle timer that morphs back to view
6
+ * mode. They are interaction-lifecycle signals only — NOT commit events
7
+ * (commits flow through `onChange`). Programmatic updates must NOT emit them.
8
+ */
9
+ export declare const LAYOUT_INTERACTION_START = "juo-layout-interaction-start";
10
+ export declare const LAYOUT_INTERACTION_END = "juo-layout-interaction-end";
11
+ /**
12
+ * Class the morph controller toggles on a `.grid-stack-item` to play a one-shot
13
+ * "pop toward the operator" animation when layout mode is entered from that
14
+ * block. The keyframes live in the adapter's injected stylesheet (same DOM root
15
+ * as the grid), so the class is shared between the two modules here.
16
+ */
17
+ export declare const LAYOUT_POP_CLASS = "juo-layout-pop";
18
+ /**
19
+ * Final rects emitted by a LayoutModeAdapter at gesture commit (drop /
20
+ * resize-stop). Commit-time ingestion only — no streaming positions.
21
+ */
22
+ export type LayoutModeRectsChange = {
23
+ rects: Record<string, GridRect>;
24
+ /**
25
+ * The breakpoint the grid was rendering when the gesture committed. Threaded
26
+ * to the parent so the edit persists to that breakpoint's layout (the
27
+ * mobile/desktop orders are independent).
28
+ */
29
+ breakpoint: string;
30
+ };
31
+ export type LayoutModeMountInputs = {
32
+ layout: LayoutDocument;
33
+ /** Render-ordered block ids that the host currently governs. */
34
+ blockIds: string[];
35
+ /**
36
+ * For each blockId, the HTMLElement ExtensionRoot already created for
37
+ * that block (in render order). Adapters MAY reuse / wrap / replace
38
+ * these. The spike GridStack adapter replaces them with simplified
39
+ * placeholder widgets and ignores these elements.
40
+ */
41
+ blockElements: Record<string, HTMLElement>;
42
+ /** Stable scope id for the host (same value Phase 3 uses for the CSS-grid scope). */
43
+ scopeId: string;
44
+ /** Called by the adapter on gesture completion. */
45
+ onChange: (event: LayoutModeRectsChange) => void;
46
+ };
47
+ export interface LayoutModeAdapter {
48
+ readonly id: string;
49
+ mount(host: HTMLElement, inputs: LayoutModeMountInputs): void;
50
+ unmount(host: HTMLElement): void;
51
+ /** Optional in-place update when the adapter is already mounted on `host`. */
52
+ update?(host: HTMLElement, inputs: LayoutModeMountInputs): void;
53
+ }
54
+ export declare function registerLayoutModeAdapter(adapter: LayoutModeAdapter): void;
55
+ export declare function getLayoutModeAdapter(): LayoutModeAdapter | null;
56
+ export declare function clearLayoutModeAdapter(): void;
57
+ //# sourceMappingURL=layout-mode-adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-mode-adapter.d.ts","sourceRoot":"","sources":["../../src/web-components/layout-mode-adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,iCAAiC,CAAC;AACvE,eAAO,MAAM,sBAAsB,+BAA+B,CAAC;AAEnE;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,mBAAmB,CAAC;AAEjD;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IAChC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,cAAc,CAAC;IACvB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC3C,qFAAqF;IACrF,OAAO,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;IAC9D,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAAC;IACjC,8EAA8E;IAC9E,MAAM,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACjE;AAID,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAE1E;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,GAAG,IAAI,CAE/D;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=layout-mode-adapter.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-mode-adapter.test.d.ts","sourceRoot":"","sources":["../../src/web-components/layout-mode-adapter.test.ts"],"names":[],"mappings":""}
@@ -1,9 +1,103 @@
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, E, b as TranslationContext, M as ContextRoot } from "./juo-workflow-BlG9CcAG.js";
5
- import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-2xTGTu3K.js";
6
- import { a as createEditorBridge, b as createFocusInlineTextMessage, d as createUpdateBlockTranslationMessage } from "./bridge-w5KQ-czl.js";
4
+ import { i as injectContext, T as TranslationContext, C as ContextRoot } from "./css-runtime-ClH0MEYr.js";
5
+ import { V as ViewLayoutController, E as ExtensionRoot, B as Block } from "./ExtensionRoot-C3lVJEBl.js";
6
+ import { canvasMode, getActiveSurfaceContext, emitLayoutSetRects, effect } from "@juo/blocks";
7
+ import { getLayoutModeAdapter } from "./layout-mode-adapter-BBd4JRQd.js";
8
+ import { a as createEditorBridge, m as createFocusInlineTextMessage, J as createUpdateBlockTranslationMessage } from "./bridge-xiKEzCGR.js";
9
+ import { i as initMorphController } from "./morph-n4LMxOYo.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({
82
+ surface,
83
+ id: ctx.id,
84
+ rects: event.rects,
85
+ breakpoint: event.breakpoint
86
+ });
87
+ };
88
+ }
89
+ return this.changeHandler;
90
+ }
91
+ surfaceOf(host) {
92
+ return host.getAttribute("surface") === "overlay" ? "overlay" : "page";
93
+ }
94
+ }
95
+ class EditorExtensionRoot extends ExtensionRoot {
96
+ constructor() {
97
+ super();
98
+ this.layout = new EditorLayoutController();
99
+ }
100
+ }
7
101
  const _InlineText = class _InlineText extends HTMLElement {
8
102
  constructor() {
9
103
  super();
@@ -17,6 +111,10 @@ const _InlineText = class _InlineText extends HTMLElement {
17
111
  __publicField(this, "boundHandleClick", this.handleClick.bind(this));
18
112
  __publicField(this, "lastValue", null);
19
113
  __publicField(this, "dispose");
114
+ // One-time DOM/style setup guard — see initializeEditorMode. Persists across
115
+ // DOM moves so reconnecting (e.g. exiting layout mode) skips redundant,
116
+ // recalc-forcing style writes.
117
+ __publicField(this, "domInitialized", false);
20
118
  }
21
119
  static get observedAttributes() {
22
120
  return ["prop", "readonly"];
@@ -60,18 +158,21 @@ const _InlineText = class _InlineText extends HTMLElement {
60
158
  }
61
159
  initializeEditorMode() {
62
160
  this.editorBridge = createEditorBridge();
63
- this.contentEditable = "false";
64
- if (!this.isReadonly) {
65
- this.style.cursor = "text";
66
- this.style.borderRadius = "2px";
67
- this.style.outline = "0.5px solid transparent";
68
- this.style.outlineOffset = "2px";
69
- }
70
- if (!this.style.width) this.style.width = "100%";
71
- if (!this.style.overflowWrap) this.style.overflowWrap = "anywhere";
72
- if (!this.style.whiteSpace) this.style.whiteSpace = "pre-wrap";
73
- if (!this.isReadonly) {
74
- this.injectStyles();
161
+ if (!this.domInitialized) {
162
+ this.domInitialized = true;
163
+ this.contentEditable = "false";
164
+ if (!this.isReadonly) {
165
+ this.style.cursor = "text";
166
+ this.style.borderRadius = "2px";
167
+ this.style.outline = "0.5px solid transparent";
168
+ this.style.outlineOffset = "2px";
169
+ }
170
+ if (!this.style.width) this.style.width = "100%";
171
+ if (!this.style.overflowWrap) this.style.overflowWrap = "anywhere";
172
+ if (!this.style.whiteSpace) this.style.whiteSpace = "pre-wrap";
173
+ if (!this.isReadonly) {
174
+ this.injectStyles();
175
+ }
75
176
  }
76
177
  this.addEventListener("blur", this.boundHandleBlur);
77
178
  this.addEventListener("pointerdown", this.boundHandlePointerDown);
@@ -80,7 +181,7 @@ const _InlineText = class _InlineText extends HTMLElement {
80
181
  if (this.translationService && this.propName && this.blockType && this.blockId) {
81
182
  const key = this.propName;
82
183
  const fallbackText = this.textContent ?? "";
83
- this.dispose = E(() => {
184
+ this.dispose = effect(() => {
84
185
  const service = this.translationService;
85
186
  if (!service) return;
86
187
  void service.locale.value;
@@ -185,7 +286,7 @@ if (customElements.get("juo-context-root") == null) {
185
286
  customElements.define("juo-context-root", ContextRoot);
186
287
  }
187
288
  if (customElements.get("juo-extension-root") == null) {
188
- customElements.define("juo-extension-root", ExtensionRoot);
289
+ customElements.define("juo-extension-root", EditorExtensionRoot);
189
290
  }
190
291
  if (customElements.get("juo-block") == null) {
191
292
  customElements.define("juo-block", Block);
@@ -193,3 +294,15 @@ if (customElements.get("juo-block") == null) {
193
294
  if (customElements.get("juo-text") == null) {
194
295
  customElements.define("juo-text", InlineText);
195
296
  }
297
+ initMorphController();
298
+ void (async () => {
299
+ try {
300
+ const [{ createGridStackAdapter }, { registerLayoutModeAdapter }] = await Promise.all([
301
+ import("./gridstack-adapter-CDWbSpbt.js"),
302
+ import("./layout-mode-adapter-BBd4JRQd.js")
303
+ ]);
304
+ registerLayoutModeAdapter(createGridStackAdapter());
305
+ } catch (error) {
306
+ console.error("[blocks] failed to register GridStack adapter:", error);
307
+ }
308
+ })();