@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
@@ -0,0 +1,118 @@
1
+ export type BreakpointId = string;
2
+ /**
3
+ * 0-indexed cell coordinates (c/r) and spans (w/h).
4
+ *
5
+ * `fill` is a sticky per-block flag: when true the block consumes all the free
6
+ * space in its row band (up to full width) and keeps doing so as neighbours move
7
+ * — see {@link applyFillExpansion}. It's toggled by the `fillWidth` command and
8
+ * cleared when the merchant manually resizes the block's width.
9
+ */
10
+ export type GridRect = {
11
+ c: number;
12
+ r: number;
13
+ w: number;
14
+ h: number;
15
+ fill?: boolean;
16
+ };
17
+ export type GridConfig = {
18
+ cols: number;
19
+ gap: number;
20
+ rowUnit: number;
21
+ };
22
+ export type ContainerQuery = {
23
+ maxWidth: number;
24
+ };
25
+ export type BreakpointDef = {
26
+ id: BreakpointId;
27
+ cols: number;
28
+ /** Absent for the base (widest) breakpoint; present for narrower ones. */
29
+ query?: ContainerQuery;
30
+ };
31
+ export type LayoutForBreakpoint = {
32
+ grid: GridConfig;
33
+ /** Keyed by Block.id — the ONLY thing the renderer reads. */
34
+ items: Record<string, GridRect>;
35
+ /** Engine-private (future zones/stacks/groups) — opaque to model/renderer. */
36
+ data?: unknown;
37
+ };
38
+ /**
39
+ * Identifier of a real layout-document engine format (the shape a persisted
40
+ * {@link LayoutDocument} is authored in). This is the canonical registry of
41
+ * engines — add `"grid-v2"` etc. here. It intentionally does NOT include
42
+ * `"legacy"`: legacy is the *absence* of the layout system, not a document
43
+ * format, so no doc is ever tagged `"legacy"`. The theme-level opt-in
44
+ * (`GlobalStyles.layoutEngine`) layers `"legacy"` on top of this set.
45
+ */
46
+ export type LayoutEngineId = "grid-v1";
47
+ export type LayoutDocument = {
48
+ version: 1;
49
+ engine: LayoutEngineId;
50
+ /** Ordered widest → narrowest; index 0 is the authored base. */
51
+ breakpoints: BreakpointDef[];
52
+ layouts: Partial<Record<BreakpointId, LayoutForBreakpoint>>;
53
+ };
54
+ /** Runtime context passed to engine methods: the resolved GridConfig plus the active breakpoint id. */
55
+ export type GridCtx = {
56
+ breakpoint: BreakpointId;
57
+ cols: number;
58
+ gap: number;
59
+ rowUnit: number;
60
+ };
61
+ export type LayoutCommand = {
62
+ kind: "add";
63
+ blockId: string;
64
+ rect?: GridRect;
65
+ } | {
66
+ kind: "move";
67
+ blockId: string;
68
+ to: {
69
+ c: number;
70
+ r: number;
71
+ };
72
+ } | {
73
+ kind: "resize";
74
+ blockId: string;
75
+ size: {
76
+ w: number;
77
+ h: number;
78
+ };
79
+ } | {
80
+ kind: "remove";
81
+ blockId: string;
82
+ } | {
83
+ kind: "setRects";
84
+ rects: Record<string, GridRect>;
85
+ }
86
+ /**
87
+ * Toggle a block's sticky `fill` flag. When enabled the block expands to
88
+ * consume the free space in its row band (and re-expands as neighbours move);
89
+ * when disabled it keeps its current width.
90
+ */
91
+ | {
92
+ kind: "fillWidth";
93
+ blockId: string;
94
+ };
95
+ export interface LayoutEngine {
96
+ id: LayoutEngineId;
97
+ applyCommand(doc: LayoutDocument, cmd: LayoutCommand, ctx: GridCtx): LayoutDocument;
98
+ reflow(doc: LayoutDocument, ctx: GridCtx): LayoutDocument;
99
+ }
100
+ export declare const GRID_V1_ENGINE_ID: LayoutEngineId;
101
+ /**
102
+ * The slot whose children the MVP LayoutDocument governs (the "page-root
103
+ * slot"). The editor's getLayoutBlockIds and the runtime ExtensionRoot
104
+ * grid container both key off this so they govern the SAME block set.
105
+ */
106
+ export declare const PAGE_ROOT_SLOT = "content";
107
+ export declare const DEFAULT_GRID: Readonly<GridConfig>;
108
+ /**
109
+ * Maximum number of blocks allowed side by side in a single row. Fill blocks
110
+ * split their free row-band space equally down to a floor of
111
+ * `ceil(cols / MAX_BLOCKS_PER_ROW)` columns; below that they wrap to a new
112
+ * full-width row (see `applyFillExpansion` in grid-utils). The GridStack
113
+ * adapter uses the same floor for per-widget `minW`, capping a row at this many
114
+ * blocks regardless of the live canvas width.
115
+ */
116
+ export declare const MAX_BLOCKS_PER_ROW = 3;
117
+ export declare const DEFAULT_BREAKPOINTS: readonly BreakpointDef[];
118
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/layout/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC;;;;;;;GAOG;AACH,MAAM,MAAM,QAAQ,GAAG;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AAElD,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,YAAY,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,0EAA0E;IAC1E,KAAK,CAAC,EAAE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AE,GACnC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAAE;AACvD;;;;GAIG;GACD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,cAAc,CAAC;IACnB,YAAY,CACV,GAAG,EAAE,cAAc,EACnB,GAAG,EAAE,aAAa,EAClB,GAAG,EAAE,OAAO,GACX,cAAc,CAAC;IAClB,MAAM,CAAC,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,OAAO,GAAG,cAAc,CAAC;CAC3D;AAED,eAAO,MAAM,iBAAiB,EAAE,cAA0B,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAsC,CAAC;AAErF;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,eAAO,MAAM,mBAAmB,EAAE,SAAS,aAAa,EAGvD,CAAC"}
@@ -0,0 +1,21 @@
1
+ const LAYOUT_INTERACTION_START = "juo-layout-interaction-start";
2
+ const LAYOUT_INTERACTION_END = "juo-layout-interaction-end";
3
+ const LAYOUT_POP_CLASS = "juo-layout-pop";
4
+ let current = null;
5
+ function registerLayoutModeAdapter(adapter) {
6
+ current = adapter;
7
+ }
8
+ function getLayoutModeAdapter() {
9
+ return current;
10
+ }
11
+ function clearLayoutModeAdapter() {
12
+ current = null;
13
+ }
14
+ export {
15
+ LAYOUT_INTERACTION_END,
16
+ LAYOUT_INTERACTION_START,
17
+ LAYOUT_POP_CLASS,
18
+ clearLayoutModeAdapter,
19
+ getLayoutModeAdapter,
20
+ registerLayoutModeAdapter
21
+ };
package/dist/main.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { Block, BlockInstance, BlockDefinition, BlockLocaleFile, BlockRenderer, BlockPreset, BlockPresets, } from './block';
2
2
  export { attachEmptyTracking, backfillInstanceDefaults, createBlockInstance, createBlockInstanceFromJSON, createBlockInstanceFromObject, createCeRenderer, defineBlock, defineBlockRuntime, getDefinedBlocks, hasRenderedContent, isStubDefinition, withWrapper, registerBlock, SelectedBlockContext, createSelectedBlock, BlockWrapperEvent, serializeBlocks, onRegisterBlock, } from './block';
3
- export { ThemeStateContext, createThemeState, indexOverrides, type TranslationCatalogs, type TranslationMode, type TranslationScope, type TranslationOverride, type ThemeLocaleState, type ThemeState, type ThemeSurface, type ThemeSurfaceState, type GlobalStyles, type GlobalStyleColors, type ThemeType, DEFAULT_GLOBAL_STYLES, } from './theme-state';
3
+ export { ThemeStateContext, createThemeState, indexOverrides, type TranslationCatalogs, type TranslationMode, type TranslationScope, type TranslationOverride, type ThemeLocaleState, type ThemeState, type ThemeSurface, type ThemeSurfaceState, type GlobalStyles, type GlobalStyleColors, type ThemeType, type LayoutEngine, DEFAULT_GLOBAL_STYLES, } from './theme-state';
4
4
  export { TranslationContext, createTranslationService, type TranslationServiceOptions, type TranslationService, } from './translation';
5
5
  export { ContextRequestEvent, ContextProvideEvent, type ContextCallback, createContext, injectContext, provideContext, subscribeContext, type ContextType, type UnknownContext, } from './context';
6
6
  export { StateContext, createState } from './state';
@@ -8,5 +8,11 @@ export { waitForDevBlocksUrl, loadBlockRegistry } from './registry';
8
8
  export * from './utils';
9
9
  export * from './services';
10
10
  export * from './flows';
11
+ export * from './layout';
12
+ export { registerLayoutModeAdapter, getLayoutModeAdapter, clearLayoutModeAdapter, type LayoutModeAdapter, type LayoutModeMountInputs, type LayoutModeRectsChange, } from './web-components/layout-mode-adapter';
13
+ export { canvasMode } from './editor/canvas-mode-signal';
14
+ export { layoutSystemEnabled, setLayoutSystemEnabled, } from './editor/layout-system-signal';
15
+ export { setActiveSurfaceContext, getActiveSurfaceContext, clearAllSurfaceContexts, } from './editor/surface-context';
16
+ export { setLayoutCommandEmitter, emitLayoutSetRects, setLayoutCommandDispatcher, emitLayoutCommand, type LayoutCommandEmitter, type LayoutSetRectsEvent, type LayoutCommandDispatcher, type LayoutCommandEvent, } from './editor/layout-command-emitter';
11
17
  export { Signal, signal, effect, computed, untracked, } from '@preact/signals-core';
12
18
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,KAAK,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,EAC7B,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,eAAe,EACpB,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpE,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AAExB,OAAO,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,GACV,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,KAAK,EACL,aAAa,EACb,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,mBAAmB,EACnB,2BAA2B,EAC3B,6BAA6B,EAC7B,gBAAgB,EAChB,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EACf,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,GACxB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,eAAe,EACpB,aAAa,EACb,aAAa,EACb,cAAc,EACd,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpE,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AAEzB,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,GAC3B,MAAM,sCAAsC,CAAC;AAO9C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EACL,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,EAC1B,iBAAiB,EACjB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,GACxB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,MAAM,EACN,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAS,GACV,MAAM,sBAAsB,CAAC"}
@@ -0,0 +1,182 @@
1
+ import { canvasMode, effect } from "@juo/blocks";
2
+ import { g as getEditorBridge, c as createLayoutingModeChangedMessage, W as WRAPPER_SELECTOR } from "./bridge-xiKEzCGR.js";
3
+ import { LAYOUT_INTERACTION_START, LAYOUT_INTERACTION_END, LAYOUT_POP_CLASS } from "./layout-mode-adapter-BBd4JRQd.js";
4
+ function setCanvasMode(enabled) {
5
+ var _a;
6
+ if (canvasMode.value === enabled) return;
7
+ (_a = getEditorBridge()) == null ? void 0 : _a.preserveScrollAcrossReflow();
8
+ canvasMode.value = enabled;
9
+ }
10
+ function resetCanvasMode() {
11
+ canvasMode.value = false;
12
+ }
13
+ let interacting = false;
14
+ let exitListenersBound = false;
15
+ let initialized = false;
16
+ function notifyParentMode(enabled) {
17
+ var _a;
18
+ (_a = getEditorBridge()) == null ? void 0 : _a.sendMessage(createLayoutingModeChangedMessage({ enabled }));
19
+ }
20
+ function prefersReducedMotion() {
21
+ return typeof window !== "undefined" && typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
22
+ }
23
+ const VT_STYLE_ID = "juo-morph-vt-style";
24
+ const VT_NAME_PREFIX = "juo-block-";
25
+ function ensureViewTransitionCss() {
26
+ if (typeof document === "undefined" || document.getElementById(VT_STYLE_ID)) {
27
+ return;
28
+ }
29
+ const style = document.createElement("style");
30
+ style.id = VT_STYLE_ID;
31
+ style.textContent = `
32
+ ::view-transition-group(*) {
33
+ animation-duration: 380ms;
34
+ animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
35
+ }
36
+ `;
37
+ (document.head ?? document.documentElement).appendChild(style);
38
+ }
39
+ function collectBlockWrappers() {
40
+ const out = [];
41
+ const seen = /* @__PURE__ */ new Set();
42
+ const walk = (root) => {
43
+ if (seen.has(root)) return;
44
+ seen.add(root);
45
+ for (const el of Array.from(
46
+ root.querySelectorAll(WRAPPER_SELECTOR)
47
+ )) {
48
+ out.push(el);
49
+ }
50
+ for (const el of Array.from(root.querySelectorAll("*"))) {
51
+ const sr = el.shadowRoot;
52
+ if (sr != null) walk(sr);
53
+ }
54
+ };
55
+ walk(document);
56
+ return out;
57
+ }
58
+ function viewTransitionName(blockId) {
59
+ return VT_NAME_PREFIX + blockId.replace(/[^a-zA-Z0-9_-]/g, "_");
60
+ }
61
+ function findWrapper(blockId) {
62
+ for (const el of collectBlockWrappers()) {
63
+ if (el.getAttribute("data-block-id") === blockId) return el;
64
+ }
65
+ return null;
66
+ }
67
+ function resolveWrapper(block) {
68
+ if (block.isConnected) return block;
69
+ const id = block.getAttribute("data-block-id");
70
+ return id != null ? findWrapper(id) : null;
71
+ }
72
+ function scrollBlockIntoView(block) {
73
+ const el = resolveWrapper(block);
74
+ if (el == null || typeof el.scrollIntoView !== "function") return;
75
+ el.scrollIntoView({ block: "start", inline: "nearest" });
76
+ }
77
+ function popBlock(block) {
78
+ const wrapper = resolveWrapper(block);
79
+ const item = wrapper == null ? void 0 : wrapper.closest(".grid-stack-item");
80
+ if (item == null) return;
81
+ item.classList.remove(LAYOUT_POP_CLASS);
82
+ void item.offsetWidth;
83
+ item.classList.add(LAYOUT_POP_CLASS);
84
+ const clear = () => item.classList.remove(LAYOUT_POP_CLASS);
85
+ item.addEventListener("animationend", clear, { once: true });
86
+ if (typeof setTimeout === "function") setTimeout(clear, 450);
87
+ }
88
+ function withMorphTransition(fn) {
89
+ const doc = document;
90
+ if (typeof doc.startViewTransition !== "function" || prefersReducedMotion()) {
91
+ fn();
92
+ return Promise.resolve();
93
+ }
94
+ ensureViewTransitionCss();
95
+ const wrappers = collectBlockWrappers();
96
+ for (const el of wrappers) {
97
+ const id = el.getAttribute("data-block-id");
98
+ if (id != null) el.style.viewTransitionName = viewTransitionName(id);
99
+ }
100
+ const clearNames = () => {
101
+ for (const el of wrappers) el.style.viewTransitionName = "";
102
+ };
103
+ let transition;
104
+ try {
105
+ transition = doc.startViewTransition(() => {
106
+ fn();
107
+ });
108
+ } catch {
109
+ fn();
110
+ clearNames();
111
+ return Promise.resolve();
112
+ }
113
+ if (transition.finished != null) {
114
+ return Promise.resolve(transition.finished).then(clearNames, clearNames);
115
+ }
116
+ clearNames();
117
+ return Promise.resolve();
118
+ }
119
+ function isInsideGridItem(e) {
120
+ const path = typeof e.composedPath === "function" ? e.composedPath() : [];
121
+ return path.some(
122
+ (n) => n instanceof Element && (n.classList.contains("grid-stack-item") || n.classList.contains("grid-stack-item-content"))
123
+ );
124
+ }
125
+ function onExitPointerDown(e) {
126
+ if (interacting || isInsideGridItem(e)) return;
127
+ exitToView();
128
+ }
129
+ function onExitKeyDown(e) {
130
+ if (e.key === "Escape") exitToView();
131
+ }
132
+ function bindExitListeners() {
133
+ if (exitListenersBound || typeof document === "undefined") return;
134
+ exitListenersBound = true;
135
+ document.addEventListener("pointerdown", onExitPointerDown, true);
136
+ document.addEventListener("keydown", onExitKeyDown, true);
137
+ }
138
+ function unbindExitListeners() {
139
+ if (!exitListenersBound) return;
140
+ exitListenersBound = false;
141
+ document.removeEventListener("pointerdown", onExitPointerDown, true);
142
+ document.removeEventListener("keydown", onExitKeyDown, true);
143
+ }
144
+ function enterLayout(block) {
145
+ if (canvasMode.value) {
146
+ notifyParentMode(true);
147
+ return;
148
+ }
149
+ const done = withMorphTransition(() => {
150
+ setCanvasMode(true);
151
+ if (block != null) scrollBlockIntoView(block);
152
+ });
153
+ notifyParentMode(true);
154
+ if (block != null) void done.then(() => popBlock(block));
155
+ }
156
+ function exitToView() {
157
+ if (!canvasMode.value) return;
158
+ withMorphTransition(() => {
159
+ setCanvasMode(false);
160
+ });
161
+ notifyParentMode(false);
162
+ }
163
+ function initMorphController() {
164
+ if (initialized || typeof document === "undefined") return;
165
+ initialized = true;
166
+ effect(() => {
167
+ if (canvasMode.value) bindExitListeners();
168
+ else unbindExitListeners();
169
+ });
170
+ document.addEventListener(LAYOUT_INTERACTION_START, () => {
171
+ interacting = true;
172
+ });
173
+ document.addEventListener(LAYOUT_INTERACTION_END, () => {
174
+ interacting = false;
175
+ });
176
+ }
177
+ export {
178
+ enterLayout as e,
179
+ initMorphController as i,
180
+ resetCanvasMode as r,
181
+ setCanvasMode as s
182
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/preact/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAyBjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,GAAG,EAC1C,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAmCvC;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAC5C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAoEvC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/preact/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAqC,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE/E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA0BjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,GAAG,EAC1C,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,GAC1B,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAuCvC;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAC5C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAoEvC"}
package/dist/preact.js CHANGED
@@ -6,7 +6,8 @@ import { useState, useRef, useEffect, useContext as useContext$1, useMemo } from
6
6
  import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-VhmfGB3N.js";
7
7
  import { t } from "./block-VhmfGB3N.js";
8
8
  import { createContext, h, render } from "preact";
9
- import { a as createEditorBridge } from "./bridge-w5KQ-czl.js";
9
+ import { g as getInstrumentation } from "./index-JSv6UH_o.js";
10
+ import { a as createEditorBridge } from "./bridge-xiKEzCGR.js";
10
11
  function toState(signal) {
11
12
  const [value, setValue] = useState(() => getSignalValue(signal));
12
13
  const disposeRef = useRef(null);
@@ -122,15 +123,18 @@ function createPreactRenderer(component) {
122
123
  const wrapper = document.createElement("div");
123
124
  wrapper.setAttribute("data-block-id", block.id);
124
125
  wrapper.setAttribute("data-block-type", block.type);
125
- render(
126
- h(ContextProvider, {
127
- children: h(
128
- component,
129
- { ...block.props, ...renderSlots(block.slots) }
130
- )
131
- }),
132
- wrapper
133
- );
126
+ const renderTree = (props) => {
127
+ render(
128
+ h(ContextProvider, {
129
+ children: h(
130
+ component,
131
+ { ...props, ...renderSlots(block.slots) }
132
+ )
133
+ }),
134
+ wrapper
135
+ );
136
+ };
137
+ renderTree(getInstrumentation().bindLiveProps(block, renderTree));
134
138
  attachEmptyTracking(wrapper);
135
139
  return wrapper;
136
140
  };
@@ -0,0 +1,52 @@
1
+ import { r as resolveLayout } from "./css-runtime-ClH0MEYr.js";
2
+ const MIN_BLOCK_ROWS = 2;
3
+ const MIN_BLOCK_PX = 200;
4
+ function resolveActiveBreakpoint(doc, containerWidthPx) {
5
+ var _a;
6
+ const baseId = ((_a = doc.breakpoints[0]) == null ? void 0 : _a.id) ?? "desktop";
7
+ if (!(containerWidthPx > 0)) return baseId;
8
+ let active = baseId;
9
+ for (const bp of doc.breakpoints.slice(1)) {
10
+ if (bp.query && containerWidthPx <= bp.query.maxWidth) active = bp.id;
11
+ }
12
+ return active;
13
+ }
14
+ function projectToGridStack(doc, breakpointId) {
15
+ const layout = resolveLayout(doc, breakpointId);
16
+ const widgets = Object.keys(layout.items).map((id) => {
17
+ const rect = layout.items[id];
18
+ return {
19
+ id,
20
+ x: rect.c,
21
+ y: rect.r,
22
+ w: rect.w,
23
+ h: Math.max(rect.h, MIN_BLOCK_ROWS),
24
+ minH: MIN_BLOCK_ROWS,
25
+ filled: rect.fill === true
26
+ };
27
+ });
28
+ return {
29
+ options: {
30
+ column: layout.grid.cols,
31
+ cellHeight: layout.grid.rowUnit,
32
+ // GridStack applies margin on each side of a widget; halving gap achieves
33
+ // the same visual spacing as CSS gap. May be fractional for odd gap values.
34
+ margin: layout.grid.gap / 2,
35
+ // Row-aligned MVP: gravity on (compaction) so reordering pulls blocks up
36
+ // and never leaves empty rows. float:true would allow free/masonry
37
+ // placement, producing the "weird gaps" seen in portal rendering.
38
+ float: false,
39
+ // OFF: the merchant owns cell height via the resize handle. Whitespace is
40
+ // avoided by a pure-CSS fill chain in the adapter, not content measurement
41
+ // (which proved circular and caused unbounded grow loops).
42
+ sizeToContent: false
43
+ },
44
+ widgets
45
+ };
46
+ }
47
+ export {
48
+ MIN_BLOCK_ROWS as M,
49
+ MIN_BLOCK_PX as a,
50
+ projectToGridStack as p,
51
+ resolveActiveBreakpoint as r
52
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/react/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAuBjD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAmCvC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,GAAG,EAC3C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACjC,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAyEvC"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/react/block.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAwBjD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EACzC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,GAChC,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAuCvC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,GAAG,GAAG,EAC3C,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EACjC,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnD,CAAC,KAAK,EAAE,aAAa,KAAK,WAAW,CAyEvC"}
package/dist/react.js CHANGED
@@ -6,7 +6,8 @@ import React, { useSyncExternalStore, createContext, useState, useContext as use
6
6
  import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-VhmfGB3N.js";
7
7
  import { t } from "./block-VhmfGB3N.js";
8
8
  import { createRoot } from "react-dom/client";
9
- import { a as createEditorBridge } from "./bridge-w5KQ-czl.js";
9
+ import { g as getInstrumentation } from "./index-JSv6UH_o.js";
10
+ import { a as createEditorBridge } from "./bridge-xiKEzCGR.js";
10
11
  function toState(signal) {
11
12
  const subscribe = (callback) => {
12
13
  const dispose = effect(() => {
@@ -105,14 +106,17 @@ function createReactRenderer(component) {
105
106
  wrapper.setAttribute("data-block-id", block.id);
106
107
  wrapper.setAttribute("data-block-type", block.type);
107
108
  const root = createRoot(wrapper);
108
- root.render(
109
- React.createElement(ContextProvider, {
110
- children: React.createElement(
111
- component,
112
- { ...block.props, ...renderSlots(block.slots) }
113
- )
114
- })
115
- );
109
+ const renderTree = (props) => {
110
+ root.render(
111
+ React.createElement(ContextProvider, {
112
+ children: React.createElement(
113
+ component,
114
+ { ...props, ...renderSlots(block.slots) }
115
+ )
116
+ })
117
+ );
118
+ };
119
+ renderTree(getInstrumentation().bindLiveProps(block, renderTree));
116
120
  attachEmptyTracking(wrapper);
117
121
  return wrapper;
118
122
  };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=registry.devtools.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.devtools.test.d.ts","sourceRoot":"","sources":["../src/registry.devtools.test.ts"],"names":[],"mappings":""}
@@ -1,6 +1,7 @@
1
1
  import { ReadonlySignal, Signal } from '@preact/signals-core';
2
2
  import { Block, BlockInstance } from './block';
3
3
  import { RouterService } from './services/router';
4
+ import { LayoutDocument, LayoutEngineId } from './layout';
4
5
  export type ThemeSurface = "page" | "overlay";
5
6
  export type GlobalStyleColors = {
6
7
  accent: string;
@@ -14,6 +15,17 @@ export type GlobalStyleColors = {
14
15
  background: string;
15
16
  };
16
17
  export type ThemeType = "neutral" | "warm" | "cold";
18
+ /**
19
+ * Which layout engine renders this theme. Absent is treated as "legacy" so
20
+ * existing themes need no migration. "grid-v1" opts the theme into the
21
+ * grid-based layout system (grid rendering + arrange mode + the layout block
22
+ * wrapper); "legacy" is the classic stacked/flex editing experience.
23
+ *
24
+ * Built by extending the real engine ids ({@link LayoutEngineId}) with the
25
+ * `"legacy"` sentinel (= layout system off). Adding a new engine format only
26
+ * requires touching `LayoutEngineId` in `layout/types.ts`.
27
+ */
28
+ export type LayoutEngine = LayoutEngineId | "legacy";
17
29
  export type GlobalStyles = {
18
30
  volume: "compact" | "comfort" | "spacious";
19
31
  style: "bare" | "ghost" | "tinted" | "solid" | "layered";
@@ -23,10 +35,13 @@ export type GlobalStyles = {
23
35
  theme: "preset" | "custom";
24
36
  themeType: ThemeType;
25
37
  colors: GlobalStyleColors;
38
+ /** Opt-in layout engine version. Omitted/undefined => legacy. */
39
+ layoutEngine?: LayoutEngine;
26
40
  };
27
41
  export declare const DEFAULT_GLOBAL_STYLES: GlobalStyles;
28
42
  export type ThemeSurfaceState = {
29
43
  blocks: Signal<BlockInstance[]>;
44
+ layout: Signal<LayoutDocument | null>;
30
45
  };
31
46
  export type TranslationMode = "override" | "default";
32
47
  export type TranslationScope = {
@@ -77,6 +92,7 @@ export declare function indexOverrides(overrides: TranslationOverride[]): {
77
92
  export declare function createThemeState(deps: {
78
93
  resolve: (surface: ThemeSurface, path: string) => Promise<{
79
94
  blocks: Block[];
95
+ layout?: LayoutDocument | null;
80
96
  } | null>;
81
97
  translations?: {
82
98
  resolveTranslations: (locale: string) => Promise<TranslationOverride[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"theme-state.d.ts","sourceRoot":"","sources":["../src/theme-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEhF,OAAO,EAIL,KAAK,KAAK,EAEV,KAAK,aAAa,EAGnB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;AAE9C,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,S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M,CAAC,CAAC,CAAC;CAChD,CAmBA;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,OAAO,EAAE,CACP,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE,MAAM,KACT,OAAO,CAAC;QAAE,MAAM,EAAE,KAAK,EAAE,CAAC;QAAC,MAAM,CAAC,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACzE,YAAY,CAAC,EAAE;QACb,mBAAmB,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;KACzE,CAAC;IACF,mBAAmB,CAAC,EAAE,YAAY,CAAC;IACnC,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,WAAW,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,IAAI,CAAC;CAC9E,GAAG,UAAU,CAwLb"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=theme-state.layout.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-state.layout.test.d.ts","sourceRoot":"","sources":["../src/theme-state.layout.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=theme-state.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-state.test.d.ts","sourceRoot":"","sources":["../src/theme-state.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/vue/block.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EAGR,SAAS,EAUV,MAAM,KAAK,CAAC;AACb,OAAO,EAEL,aAAa,EAEb,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2B9B,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,WAuCZ,aAAa,iBA6D7B;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,yCAoCrD"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/vue/block.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EAGR,SAAS,EAUV,MAAM,KAAK,CAAC;AAEb,OAAO,EAEL,aAAa,EAEb,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAGrB,OAAO,EAAE,kBAAkB,EAAE,CAAC;AA2B9B,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,WA0CZ,aAAa,iBA+E7B;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,yCAoCrD"}
package/dist/vue.js CHANGED
@@ -1,7 +1,8 @@
1
1
  import { customRef, toValue, watchEffect, defineComponent, ref, getCurrentInstance, onMounted, provide, h, renderSlot, inject, computed, useHost, defineCustomElement, triggerRef, render, shallowRef } from "vue";
2
+ import { g as getInstrumentation } from "./index-JSv6UH_o.js";
2
3
  import { effect, signal, injectContext, provideContext, createCeRenderer, attachEmptyTracking } from "@juo/blocks";
3
4
  import { hasRenderedContent } from "@juo/blocks";
4
- import { c as createRegisterBlockTranslationKeysMessage, a as createEditorBridge } from "./bridge-w5KQ-czl.js";
5
+ import { v as createRegisterBlockTranslationKeysMessage, a as createEditorBridge } from "./bridge-xiKEzCGR.js";
5
6
  const signalsMap = /* @__PURE__ */ new WeakMap();
6
7
  function toSignal(ref2) {
7
8
  if (!signalsMap.has(ref2)) {
@@ -179,7 +180,8 @@ function createVueRenderer(component, options) {
179
180
  const parentInstance = block.__vueInstance;
180
181
  const existing = cache.get(block.id);
181
182
  if (existing && existing.parentInstance === parentInstance) {
182
- existing.propsRef.value = block.props;
183
+ existing.baseProps = block.props;
184
+ existing.propsRef.value = getInstrumentation().resolveProps(block);
183
185
  existing.slotsRef.value = block.slots;
184
186
  triggerRef(existing.slotsRef);
185
187
  return existing.wrapper;
@@ -187,7 +189,17 @@ function createVueRenderer(component, options) {
187
189
  if (existing) {
188
190
  render(null, existing.wrapper);
189
191
  }
190
- const propsRef = shallowRef(block.props);
192
+ const propsRef = shallowRef({});
193
+ propsRef.value = getInstrumentation().bindLiveProps(
194
+ block,
195
+ (p) => {
196
+ propsRef.value = p;
197
+ },
198
+ () => {
199
+ var _a;
200
+ return ((_a = cache.get(block.id)) == null ? void 0 : _a.baseProps) ?? block.props;
201
+ }
202
+ );
191
203
  const slotsRef = shallowRef(
192
204
  block.slots
193
205
  );
@@ -218,7 +230,13 @@ function createVueRenderer(component, options) {
218
230
  if (!existing) {
219
231
  attachEmptyTracking(wrapper);
220
232
  }
221
- cache.set(block.id, { wrapper, propsRef, slotsRef, parentInstance });
233
+ cache.set(block.id, {
234
+ wrapper,
235
+ propsRef,
236
+ slotsRef,
237
+ parentInstance,
238
+ baseProps: block.props
239
+ });
222
240
  return wrapper;
223
241
  };
224
242
  }