@contractspec/lib.surface-runtime 0.2.3 → 0.3.2

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 (153) hide show
  1. package/dist/adapters/ai-sdk-stub.js +1 -6
  2. package/dist/adapters/blocknote-stub.js +3 -8
  3. package/dist/adapters/dnd-kit-adapter.js +6 -11
  4. package/dist/adapters/dnd-kit-stub.js +1 -6
  5. package/dist/adapters/floating-ui-stub.js +4 -9
  6. package/dist/adapters/index.js +7 -176
  7. package/dist/adapters/interfaces.js +0 -1
  8. package/dist/adapters/motion-stub.js +2 -7
  9. package/dist/adapters/resizable-panels-stub.js +7 -12
  10. package/dist/browser/adapters/ai-sdk-stub.js +1 -5
  11. package/dist/browser/adapters/blocknote-stub.js +3 -7
  12. package/dist/browser/adapters/dnd-kit-adapter.js +6 -10
  13. package/dist/browser/adapters/dnd-kit-stub.js +1 -5
  14. package/dist/browser/adapters/floating-ui-stub.js +4 -8
  15. package/dist/browser/adapters/index.js +7 -175
  16. package/dist/browser/adapters/motion-stub.js +2 -6
  17. package/dist/browser/adapters/resizable-panels-stub.js +5 -9
  18. package/dist/browser/evals/golden-harness.js +4 -825
  19. package/dist/browser/examples/pm-workbench.bundle.js +2 -316
  20. package/dist/browser/i18n/catalogs/en.js +1 -5
  21. package/dist/browser/i18n/catalogs/es.js +1 -5
  22. package/dist/browser/i18n/catalogs/fr.js +1 -5
  23. package/dist/browser/i18n/catalogs/index.js +3 -133
  24. package/dist/browser/i18n/index.js +3 -168
  25. package/dist/browser/i18n/keys.js +1 -5
  26. package/dist/browser/i18n/messages.js +6 -137
  27. package/dist/browser/index.js +4 -2466
  28. package/dist/browser/react/BundleProvider.js +12 -19
  29. package/dist/browser/react/BundleRenderer.js +19 -662
  30. package/dist/browser/react/OverlayConflictResolver.js +12 -180
  31. package/dist/browser/react/PatchProposalCard.js +9 -177
  32. package/dist/browser/react/RegionRenderer.js +14 -60
  33. package/dist/browser/react/SlotRenderer.js +15 -58
  34. package/dist/browser/react/WidgetPalette.js +6 -10
  35. package/dist/browser/react/index.js +14 -790
  36. package/dist/browser/runtime/apply-surface-patch.js +3 -208
  37. package/dist/browser/runtime/audit-events.js +8 -19
  38. package/dist/browser/runtime/build-context.js +2 -6
  39. package/dist/browser/runtime/extension-registry.js +3 -9
  40. package/dist/browser/runtime/field-renderer-registry.js +5 -11
  41. package/dist/browser/runtime/index.js +54 -1487
  42. package/dist/browser/runtime/overlay-alignment.js +8 -19
  43. package/dist/browser/runtime/overlay-signer.js +2 -7
  44. package/dist/browser/runtime/override-store.js +3 -9
  45. package/dist/browser/runtime/planner-prompt.js +2 -6
  46. package/dist/browser/runtime/planner-tools.js +3 -9
  47. package/dist/browser/runtime/policy-eval.js +3 -135
  48. package/dist/browser/runtime/preference-adapter.js +2 -62
  49. package/dist/browser/runtime/resolve-bundle.js +10 -447
  50. package/dist/browser/runtime/resolve-preferences.js +3 -7
  51. package/dist/browser/runtime/rollback.js +2 -325
  52. package/dist/browser/runtime/widget-registry.js +1 -5
  53. package/dist/browser/spec/define-module-bundle.js +2 -67
  54. package/dist/browser/spec/index.js +9 -317
  55. package/dist/browser/spec/validate-bundle.js +3 -8
  56. package/dist/browser/spec/validate-surface-patch.js +5 -11
  57. package/dist/browser/telemetry/index.js +4 -16
  58. package/dist/browser/telemetry/surface-metrics.js +7 -16
  59. package/dist/evals/golden-context.js +0 -1
  60. package/dist/evals/golden-harness.js +4 -826
  61. package/dist/examples/pm-workbench.bundle.js +2 -317
  62. package/dist/i18n/catalogs/en.js +1 -6
  63. package/dist/i18n/catalogs/es.js +1 -6
  64. package/dist/i18n/catalogs/fr.js +1 -6
  65. package/dist/i18n/catalogs/index.js +3 -134
  66. package/dist/i18n/index.js +3 -169
  67. package/dist/i18n/keys.js +1 -6
  68. package/dist/i18n/messages.js +6 -138
  69. package/dist/index.js +4 -2467
  70. package/dist/node/adapters/ai-sdk-stub.js +1 -5
  71. package/dist/node/adapters/blocknote-stub.js +3 -7
  72. package/dist/node/adapters/dnd-kit-adapter.js +6 -10
  73. package/dist/node/adapters/dnd-kit-stub.js +1 -5
  74. package/dist/node/adapters/floating-ui-stub.js +4 -8
  75. package/dist/node/adapters/index.js +7 -175
  76. package/dist/node/adapters/motion-stub.js +2 -6
  77. package/dist/node/adapters/resizable-panels-stub.js +5 -9
  78. package/dist/node/evals/golden-harness.js +4 -825
  79. package/dist/node/examples/pm-workbench.bundle.js +2 -316
  80. package/dist/node/i18n/catalogs/en.js +1 -5
  81. package/dist/node/i18n/catalogs/es.js +1 -5
  82. package/dist/node/i18n/catalogs/fr.js +1 -5
  83. package/dist/node/i18n/catalogs/index.js +3 -133
  84. package/dist/node/i18n/index.js +3 -168
  85. package/dist/node/i18n/keys.js +1 -5
  86. package/dist/node/i18n/messages.js +6 -137
  87. package/dist/node/index.js +4 -2466
  88. package/dist/node/react/BundleProvider.js +12 -19
  89. package/dist/node/react/BundleRenderer.js +19 -662
  90. package/dist/node/react/OverlayConflictResolver.js +12 -180
  91. package/dist/node/react/PatchProposalCard.js +9 -177
  92. package/dist/node/react/RegionRenderer.js +14 -60
  93. package/dist/node/react/SlotRenderer.js +15 -58
  94. package/dist/node/react/WidgetPalette.js +6 -10
  95. package/dist/node/react/index.js +14 -790
  96. package/dist/node/runtime/apply-surface-patch.js +3 -208
  97. package/dist/node/runtime/audit-events.js +8 -19
  98. package/dist/node/runtime/build-context.js +2 -6
  99. package/dist/node/runtime/extension-registry.js +3 -9
  100. package/dist/node/runtime/field-renderer-registry.js +5 -11
  101. package/dist/node/runtime/index.js +54 -1487
  102. package/dist/node/runtime/overlay-alignment.js +8 -19
  103. package/dist/node/runtime/overlay-signer.js +2 -7
  104. package/dist/node/runtime/override-store.js +3 -9
  105. package/dist/node/runtime/planner-prompt.js +2 -6
  106. package/dist/node/runtime/planner-tools.js +3 -9
  107. package/dist/node/runtime/policy-eval.js +3 -135
  108. package/dist/node/runtime/preference-adapter.js +2 -62
  109. package/dist/node/runtime/resolve-bundle.js +10 -447
  110. package/dist/node/runtime/resolve-preferences.js +3 -7
  111. package/dist/node/runtime/rollback.js +2 -325
  112. package/dist/node/runtime/widget-registry.js +1 -5
  113. package/dist/node/spec/define-module-bundle.js +2 -67
  114. package/dist/node/spec/index.js +9 -317
  115. package/dist/node/spec/validate-bundle.js +3 -8
  116. package/dist/node/spec/validate-surface-patch.js +5 -11
  117. package/dist/node/telemetry/index.js +4 -16
  118. package/dist/node/telemetry/surface-metrics.js +7 -16
  119. package/dist/react/BundleProvider.js +12 -20
  120. package/dist/react/BundleRenderer.d.ts +3 -1
  121. package/dist/react/BundleRenderer.js +19 -663
  122. package/dist/react/OverlayConflictResolver.js +12 -181
  123. package/dist/react/PatchProposalCard.js +9 -178
  124. package/dist/react/RegionRenderer.js +14 -61
  125. package/dist/react/SlotRenderer.js +15 -59
  126. package/dist/react/WidgetPalette.js +6 -11
  127. package/dist/react/index.js +14 -791
  128. package/dist/runtime/apply-surface-patch.js +3 -209
  129. package/dist/runtime/audit-events.js +8 -20
  130. package/dist/runtime/build-context.js +2 -7
  131. package/dist/runtime/extension-registry.js +3 -10
  132. package/dist/runtime/field-renderer-registry.js +9 -16
  133. package/dist/runtime/index.js +54 -1488
  134. package/dist/runtime/overlay-alignment.js +8 -20
  135. package/dist/runtime/overlay-signer.js +2 -8
  136. package/dist/runtime/override-store.js +3 -10
  137. package/dist/runtime/planner-prompt.js +11 -9
  138. package/dist/runtime/planner-tools.js +4 -11
  139. package/dist/runtime/policy-eval.js +3 -136
  140. package/dist/runtime/preference-adapter.js +2 -63
  141. package/dist/runtime/resolve-bundle.js +10 -448
  142. package/dist/runtime/resolve-preferences.js +3 -8
  143. package/dist/runtime/rollback.js +2 -326
  144. package/dist/runtime/widget-registry.js +1 -6
  145. package/dist/spec/define-module-bundle.js +2 -68
  146. package/dist/spec/index.js +9 -318
  147. package/dist/spec/types.js +0 -1
  148. package/dist/spec/validate-bundle.js +3 -9
  149. package/dist/spec/validate-surface-patch.js +5 -12
  150. package/dist/spec/verification-snapshot-types.js +0 -1
  151. package/dist/telemetry/index.js +4 -17
  152. package/dist/telemetry/surface-metrics.js +7 -17
  153. package/package.json +7 -7
@@ -1,658 +1,15 @@
1
- // src/adapters/blocknote-stub.tsx
2
- import { jsxDEV } from "react/jsx-dev-runtime";
3
- var blocknoteAdapterStub = {
4
- supportsNode(_kind) {
5
- return false;
6
- },
7
- createSchema(_registry) {
8
- return {};
9
- },
10
- renderNode(node, _ctx) {
11
- return /* @__PURE__ */ jsxDEV("div", {
12
- "data-blocknote-stub": true,
13
- "data-node-id": node.nodeId,
14
- children: node.title ?? node.kind
15
- }, undefined, false, undefined, this);
16
- },
17
- async serialize(node) {
18
- return { nodeId: node.nodeId, kind: node.kind };
19
- },
20
- async deserialize(input) {
21
- const o = input;
22
- return {
23
- nodeId: o?.nodeId ?? "stub",
24
- kind: o?.kind ?? "custom-widget"
25
- };
26
- }
27
- };
28
-
29
- // src/adapters/motion-stub.ts
30
- var PACE_TOKENS = {
31
- deliberate: {
32
- durationMs: 300,
33
- enableEntrance: true,
34
- layout: true
35
- },
36
- balanced: {
37
- durationMs: 150,
38
- enableEntrance: true,
39
- layout: true
40
- },
41
- rapid: {
42
- durationMs: 50,
43
- enableEntrance: false,
44
- layout: false
45
- }
46
- };
47
- var motionAdapterStub = {
48
- getTokens(pace) {
49
- return PACE_TOKENS[pace] ?? PACE_TOKENS.balanced;
50
- }
51
- };
52
-
53
- // src/adapters/resizable-panels-stub.tsx
54
- import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
55
- var LAYOUT_STORAGE_KEY = "surface-runtime:panel-layout:";
56
- var resizablePanelsAdapterStub = {
57
- renderPanelGroup(region, ctx, renderChild) {
58
- const direction = region.direction === "horizontal" ? "row" : "column";
59
- return /* @__PURE__ */ jsxDEV2("div", {
60
- "data-panel-group": true,
61
- "data-persist-key": region.persistKey,
62
- style: {
63
- display: "flex",
64
- flexDirection: direction,
65
- flex: 1,
66
- minHeight: 0
67
- },
68
- children: region.children.map((child, i) => /* @__PURE__ */ jsxDEV2("div", {
69
- style: { flex: 1, minWidth: 0, minHeight: 0 },
70
- children: renderChild(child, ctx)
71
- }, i, false, undefined, this))
72
- }, undefined, false, undefined, this);
73
- },
74
- async restoreLayout(persistKey) {
75
- if (typeof localStorage === "undefined")
76
- return null;
77
- try {
78
- const raw = localStorage.getItem(LAYOUT_STORAGE_KEY + persistKey);
79
- if (!raw)
80
- return null;
81
- const parsed = JSON.parse(raw);
82
- return Array.isArray(parsed) ? parsed : null;
83
- } catch {
84
- return null;
85
- }
86
- },
87
- async saveLayout(persistKey, sizes) {
88
- if (typeof localStorage === "undefined")
89
- return;
90
- try {
91
- localStorage.setItem(LAYOUT_STORAGE_KEY + persistKey, JSON.stringify(sizes));
92
- } catch {}
93
- }
94
- };
95
-
96
- // src/telemetry/surface-metrics.ts
97
- import {
98
- createCounter,
99
- createHistogram
100
- } from "@contractspec/lib.observability/metrics";
101
- var METER_NAME = "@contractspec/lib.surface-runtime";
102
- var resolutionDurationMs = createHistogram("bundle_surface_resolution_duration_ms", "Time to resolve bundle spec to surface plan in milliseconds", METER_NAME);
103
- var patchAcceptanceCounter = createCounter("bundle_surface_patch_acceptance_total", "Total AI patch proposals accepted by user", METER_NAME);
104
- var patchRejectionCounter = createCounter("bundle_surface_patch_rejection_total", "Total AI patch proposals rejected by user", METER_NAME);
105
- var policyDenialCounter = createCounter("bundle_surface_policy_denial_total", "Total policy denials (actions denied by policy)", METER_NAME);
106
- var surfaceFallbackCounter = createCounter("bundle_surface_fallback_total", "Total surface or layout fallbacks during resolution", METER_NAME);
107
- var missingRendererCounter = createCounter("bundle_surface_renderer_missing_total", "Total slots with no renderer for requested node kind", METER_NAME);
108
-
109
- // src/i18n/catalogs/en.ts
110
- import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
111
- var enMessages = defineTranslation({
112
- meta: {
113
- key: "surface-runtime.messages",
114
- version: "1.0.0",
115
- domain: "surface-runtime",
116
- description: "User-facing strings for surface-runtime UI components",
117
- owners: ["platform"],
118
- stability: "experimental"
119
- },
120
- locale: "en",
121
- fallback: "en",
122
- messages: {
123
- "overlay.conflicts.title": {
124
- value: "Overlay conflicts",
125
- description: "Title for overlay conflict resolution banner"
126
- },
127
- "overlay.conflicts.keepScope": {
128
- value: "Keep {scope}",
129
- description: "Button to keep overlay from scope A or B"
130
- },
131
- "patch.accept": {
132
- value: "Accept",
133
- description: "Accept patch proposal button"
134
- },
135
- "patch.reject": {
136
- value: "Reject",
137
- description: "Reject patch proposal button"
138
- },
139
- "patch.addWidget": {
140
- value: "Add {title} to {slot}",
141
- description: "Insert node proposal summary"
142
- },
143
- "patch.removeItem": {
144
- value: "Remove item",
145
- description: "Remove node proposal summary"
146
- },
147
- "patch.switchLayout": {
148
- value: "Switch to {layoutId} layout",
149
- description: "Set layout proposal summary"
150
- },
151
- "patch.showField": {
152
- value: "Show field {fieldId}",
153
- description: "Reveal field proposal summary"
154
- },
155
- "patch.hideField": {
156
- value: "Hide field {fieldId}",
157
- description: "Hide field proposal summary"
158
- },
159
- "patch.moveTo": {
160
- value: "Move to {slot}",
161
- description: "Move node proposal summary"
162
- },
163
- "patch.replaceItem": {
164
- value: "Replace item",
165
- description: "Replace node proposal summary"
166
- },
167
- "patch.promote": {
168
- value: "Promote {actionId}",
169
- description: "Promote action proposal summary"
170
- },
171
- "patch.changes": {
172
- value: "{count} changes",
173
- description: "Multiple patch ops summary"
174
- }
175
- }
176
- });
177
-
178
- // src/i18n/catalogs/es.ts
179
- import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
180
- var esMessages = defineTranslation2({
181
- meta: {
182
- key: "surface-runtime.messages",
183
- version: "1.0.0",
184
- domain: "surface-runtime",
185
- description: "User-facing strings for surface-runtime UI components",
186
- owners: ["platform"],
187
- stability: "experimental"
188
- },
189
- locale: "es",
190
- fallback: "en",
191
- messages: {
192
- "overlay.conflicts.title": { value: "Conflictos de superposición" },
193
- "overlay.conflicts.keepScope": { value: "Mantener {scope}" },
194
- "patch.accept": { value: "Aceptar" },
195
- "patch.reject": { value: "Rechazar" },
196
- "patch.addWidget": { value: "Añadir {title} a {slot}" },
197
- "patch.removeItem": { value: "Eliminar elemento" },
198
- "patch.switchLayout": { value: "Cambiar a disposición {layoutId}" },
199
- "patch.showField": { value: "Mostrar campo {fieldId}" },
200
- "patch.hideField": { value: "Ocultar campo {fieldId}" },
201
- "patch.moveTo": { value: "Mover a {slot}" },
202
- "patch.replaceItem": { value: "Reemplazar elemento" },
203
- "patch.promote": { value: "Promover {actionId}" },
204
- "patch.changes": { value: "{count} cambios" }
205
- }
206
- });
207
-
208
- // src/i18n/catalogs/fr.ts
209
- import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
210
- var frMessages = defineTranslation3({
211
- meta: {
212
- key: "surface-runtime.messages",
213
- version: "1.0.0",
214
- domain: "surface-runtime",
215
- description: "User-facing strings for surface-runtime UI components",
216
- owners: ["platform"],
217
- stability: "experimental"
218
- },
219
- locale: "fr",
220
- fallback: "en",
221
- messages: {
222
- "overlay.conflicts.title": { value: "Conflits de superposition" },
223
- "overlay.conflicts.keepScope": { value: "Conserver {scope}" },
224
- "patch.accept": { value: "Accepter" },
225
- "patch.reject": { value: "Rejeter" },
226
- "patch.addWidget": { value: "Ajouter {title} à {slot}" },
227
- "patch.removeItem": { value: "Supprimer l'élément" },
228
- "patch.switchLayout": { value: "Passer à la disposition {layoutId}" },
229
- "patch.showField": { value: "Afficher le champ {fieldId}" },
230
- "patch.hideField": { value: "Masquer le champ {fieldId}" },
231
- "patch.moveTo": { value: "Déplacer vers {slot}" },
232
- "patch.replaceItem": { value: "Remplacer l'élément" },
233
- "patch.promote": { value: "Promouvoir {actionId}" },
234
- "patch.changes": { value: "{count} modifications" }
235
- }
236
- });
237
-
238
- // src/i18n/messages.ts
239
- import {
240
- createI18nFactory
241
- } from "@contractspec/lib.contracts-spec/translations";
242
- var factory = createI18nFactory({
243
- specKey: "surface-runtime.messages",
244
- catalogs: [enMessages, frMessages, esMessages]
245
- });
246
- var createSurfaceI18n = factory.create;
247
- var getDefaultSurfaceI18n = factory.getDefault;
248
-
249
- // src/i18n/keys.ts
250
- var SURFACE_KEYS = {
251
- "overlay.conflicts.title": "overlay.conflicts.title",
252
- "overlay.conflicts.keepScope": "overlay.conflicts.keepScope",
253
- "patch.accept": "patch.accept",
254
- "patch.reject": "patch.reject",
255
- "patch.addWidget": "patch.addWidget",
256
- "patch.removeItem": "patch.removeItem",
257
- "patch.switchLayout": "patch.switchLayout",
258
- "patch.showField": "patch.showField",
259
- "patch.hideField": "patch.hideField",
260
- "patch.moveTo": "patch.moveTo",
261
- "patch.replaceItem": "patch.replaceItem",
262
- "patch.promote": "patch.promote",
263
- "patch.changes": "patch.changes"
264
- };
265
-
266
- // src/i18n/index.ts
267
- import {
268
- resolveLocale,
269
- isSupportedLocale,
270
- DEFAULT_LOCALE,
271
- SUPPORTED_LOCALES
272
- } from "@contractspec/lib.contracts-spec/translations";
273
-
274
- // src/react/BundleProvider.tsx
275
- import { createContext, useContext } from "react";
276
- import { jsxDEV as jsxDEV3 } from "react/jsx-dev-runtime";
277
1
  "use client";
278
- var BundlePlanContext = createContext(null);
279
- var PreferencesContext = createContext(null);
280
- var EditingContext = createContext(false);
281
- function BundleProvider({
282
- plan,
283
- children,
284
- isEditing = false
285
- }) {
286
- const preferences = plan.adaptation.appliedDimensions;
287
- return /* @__PURE__ */ jsxDEV3(BundlePlanContext.Provider, {
288
- value: plan,
289
- children: /* @__PURE__ */ jsxDEV3(PreferencesContext.Provider, {
290
- value: preferences,
291
- children: /* @__PURE__ */ jsxDEV3(EditingContext.Provider, {
292
- value: isEditing,
293
- children
294
- }, undefined, false, undefined, this)
295
- }, undefined, false, undefined, this)
296
- }, undefined, false, undefined, this);
297
- }
298
- function useIsEditing() {
299
- return useContext(EditingContext);
300
- }
301
- function useBundlePlan() {
302
- const value = useContext(BundlePlanContext);
303
- if (!value) {
304
- throw new Error("useBundlePlan must be used inside BundleProvider.");
305
- }
306
- return value;
307
- }
308
- function useBundlePreferences() {
309
- const value = useContext(PreferencesContext);
310
- if (!value) {
311
- throw new Error("useBundlePreferences must be used inside BundleProvider.");
312
- }
313
- return value;
314
- }
315
-
316
- // src/react/RegionRenderer.tsx
317
- import { jsxDEV as jsxDEV4 } from "react/jsx-dev-runtime";
318
- function RegionRenderer({
319
- region,
320
- ctx,
321
- renderSlot
322
- }) {
323
- const renderChild = (child, childCtx) => /* @__PURE__ */ jsxDEV4(RegionRenderer, {
324
- region: child,
325
- ctx: childCtx,
326
- renderSlot
327
- }, undefined, false, undefined, this);
328
- switch (region.type) {
329
- case "panel-group":
330
- return resizablePanelsAdapterStub.renderPanelGroup(region, ctx, renderChild);
331
- case "stack": {
332
- const direction = region.direction === "horizontal" ? "row" : "column";
333
- const gapMap = {
334
- none: 0,
335
- xs: 4,
336
- sm: 8,
337
- md: 16,
338
- lg: 24
339
- };
340
- const gap = gapMap[region.gap ?? "md"];
341
- return /* @__PURE__ */ jsxDEV4("div", {
342
- "data-region": "stack",
343
- style: {
344
- display: "flex",
345
- flexDirection: direction,
346
- gap,
347
- flex: 1,
348
- minHeight: 0
349
- },
350
- children: region.children.map((child, i) => /* @__PURE__ */ jsxDEV4("div", {
351
- style: { flex: 1, minWidth: 0, minHeight: 0 },
352
- children: /* @__PURE__ */ jsxDEV4(RegionRenderer, {
353
- region: child,
354
- ctx,
355
- renderSlot
356
- }, undefined, false, undefined, this)
357
- }, i, false, undefined, this))
358
- }, undefined, false, undefined, this);
359
- }
360
- case "tabs":
361
- return /* @__PURE__ */ jsxDEV4("div", {
362
- "data-region": "tabs",
363
- children: [
364
- /* @__PURE__ */ jsxDEV4("div", {
365
- role: "tablist",
366
- children: region.tabs.map((t) => /* @__PURE__ */ jsxDEV4("button", {
367
- type: "button",
368
- role: "tab",
369
- children: t.title
370
- }, t.key, false, undefined, this))
371
- }, undefined, false, undefined, this),
372
- region.tabs[0] && /* @__PURE__ */ jsxDEV4(RegionRenderer, {
373
- region: region.tabs[0].child,
374
- ctx,
375
- renderSlot
376
- }, undefined, false, undefined, this)
377
- ]
378
- }, undefined, true, undefined, this);
379
- case "slot":
380
- return /* @__PURE__ */ jsxDEV4("div", {
381
- "data-slot": region.slotId,
382
- children: renderSlot(region.slotId, ctx)
383
- }, undefined, false, undefined, this);
384
- case "floating":
385
- return /* @__PURE__ */ jsxDEV4("div", {
386
- "data-floating": true,
387
- "data-anchor": region.anchorSlotId,
388
- children: /* @__PURE__ */ jsxDEV4(RegionRenderer, {
389
- region: region.child,
390
- ctx,
391
- renderSlot
392
- }, undefined, false, undefined, this)
393
- }, undefined, false, undefined, this);
394
- default:
395
- return null;
396
- }
397
- }
398
-
399
- // src/react/SlotRenderer.tsx
400
- import { jsxDEV as jsxDEV5 } from "react/jsx-dev-runtime";
401
- function SlotRenderer({ slotId, ctx, nodes }) {
402
- if (nodes.length === 0) {
403
- return /* @__PURE__ */ jsxDEV5("div", {
404
- "data-slot-placeholder": true,
405
- "data-slot-id": slotId
406
- }, undefined, false, undefined, this);
407
- }
408
- return /* @__PURE__ */ jsxDEV5("div", {
409
- "data-slot": slotId,
410
- children: nodes.map((node) => /* @__PURE__ */ jsxDEV5(SlotNodeRenderer, {
411
- node,
412
- ctx,
413
- slotId
414
- }, node.nodeId, false, undefined, this))
415
- }, undefined, false, undefined, this);
416
- }
417
- function SlotNodeRenderer({
418
- node,
419
- ctx,
420
- slotId
421
- }) {
422
- if (blocknoteAdapterStub.supportsNode(node.kind)) {
423
- return blocknoteAdapterStub.renderNode(node, ctx);
424
- }
425
- if (node.kind === "entity-section") {
426
- return /* @__PURE__ */ jsxDEV5("section", {
427
- "data-node-id": node.nodeId,
428
- "data-kind": "entity-section",
429
- children: [
430
- /* @__PURE__ */ jsxDEV5("header", {
431
- "data-entity-section-header": true,
432
- children: node.title ?? "Section"
433
- }, undefined, false, undefined, this),
434
- /* @__PURE__ */ jsxDEV5("div", {
435
- "data-entity-section-content": true,
436
- children: node.children?.map((child) => child ? /* @__PURE__ */ jsxDEV5(SlotNodeRenderer, {
437
- node: child,
438
- ctx,
439
- slotId
440
- }, child.nodeId, false, undefined, this) : null)
441
- }, undefined, false, undefined, this)
442
- ]
443
- }, undefined, true, undefined, this);
444
- }
445
- if (node.kind === "entity-field") {
446
- const fieldId = node.sourceBinding?.fieldId;
447
- return /* @__PURE__ */ jsxDEV5("div", {
448
- "data-node-id": node.nodeId,
449
- "data-kind": "entity-field",
450
- "data-field-id": fieldId,
451
- children: [
452
- /* @__PURE__ */ jsxDEV5("span", {
453
- "data-entity-field-label": true,
454
- children: node.title ?? fieldId ?? "Field"
455
- }, undefined, false, undefined, this),
456
- /* @__PURE__ */ jsxDEV5("span", {
457
- "data-entity-field-value": true
458
- }, undefined, false, undefined, this)
459
- ]
460
- }, undefined, true, undefined, this);
461
- }
462
- missingRendererCounter.add(1, {
463
- nodeKind: node.kind,
464
- slotId
465
- });
466
- return /* @__PURE__ */ jsxDEV5("div", {
467
- "data-node-id": node.nodeId,
468
- "data-kind": node.kind,
469
- "data-renderer-missing": true,
470
- children: node.title ?? node.kind
471
- }, undefined, false, undefined, this);
472
- }
473
-
474
- // src/react/PatchProposalCard.tsx
475
- import { useMemo } from "react";
476
- import { jsxDEV as jsxDEV6 } from "react/jsx-dev-runtime";
477
- "use client";
478
- function PatchProposalCard({
479
- proposal,
480
- onAccept,
481
- onReject,
482
- locale
483
- }) {
484
- const i18n = useMemo(() => createSurfaceI18n(locale), [locale]);
485
- const firstOp = proposal.ops[0];
486
- const summary = proposal.ops.length === 1 && firstOp ? describeOp(firstOp, i18n) : i18n.t("patch.changes", { count: proposal.ops.length });
487
- return /* @__PURE__ */ jsxDEV6("div", {
488
- "data-proposal-id": proposal.proposalId,
489
- style: {
490
- padding: "12px",
491
- border: "1px solid var(--border, #e5e7eb)",
492
- borderRadius: "8px",
493
- marginBottom: "8px",
494
- backgroundColor: "var(--muted, #f9fafb)"
495
- },
496
- children: [
497
- /* @__PURE__ */ jsxDEV6("div", {
498
- style: { marginBottom: "8px", fontSize: "14px" },
499
- children: summary
500
- }, undefined, false, undefined, this),
501
- /* @__PURE__ */ jsxDEV6("div", {
502
- style: { display: "flex", gap: "8px" },
503
- children: [
504
- /* @__PURE__ */ jsxDEV6("button", {
505
- type: "button",
506
- onClick: () => onAccept(proposal.proposalId),
507
- style: {
508
- padding: "4px 12px",
509
- fontSize: "13px",
510
- borderRadius: "4px",
511
- border: "none",
512
- backgroundColor: "var(--primary, #3b82f6)",
513
- color: "white",
514
- cursor: "pointer"
515
- },
516
- children: i18n.t("patch.accept")
517
- }, undefined, false, undefined, this),
518
- /* @__PURE__ */ jsxDEV6("button", {
519
- type: "button",
520
- onClick: () => onReject(proposal.proposalId),
521
- style: {
522
- padding: "4px 12px",
523
- fontSize: "13px",
524
- borderRadius: "4px",
525
- border: "1px solid var(--border, #e5e7eb)",
526
- backgroundColor: "transparent",
527
- cursor: "pointer"
528
- },
529
- children: i18n.t("patch.reject")
530
- }, undefined, false, undefined, this)
531
- ]
532
- }, undefined, true, undefined, this)
533
- ]
534
- }, undefined, true, undefined, this);
535
- }
536
- function describeOp(op, i18n) {
537
- switch (op.op) {
538
- case "insert-node":
539
- return i18n.t("patch.addWidget", {
540
- title: op.node?.title ?? op.node?.kind ?? "widget",
541
- slot: op.slotId ?? "slot"
542
- });
543
- case "remove-node":
544
- return i18n.t("patch.removeItem");
545
- case "set-layout":
546
- return i18n.t("patch.switchLayout", { layoutId: op.layoutId });
547
- case "reveal-field":
548
- return i18n.t("patch.showField", { fieldId: op.fieldId });
549
- case "hide-field":
550
- return i18n.t("patch.hideField", { fieldId: op.fieldId });
551
- case "move-node":
552
- return i18n.t("patch.moveTo", { slot: op.toSlotId ?? "slot" });
553
- case "replace-node":
554
- return i18n.t("patch.replaceItem");
555
- case "promote-action":
556
- return i18n.t("patch.promote", { actionId: op.actionId });
557
- default:
558
- return `${op.op}`;
559
- }
560
- }
561
-
562
- // src/react/OverlayConflictResolver.tsx
563
- import { useMemo as useMemo2 } from "react";
564
- import { jsxDEV as jsxDEV7 } from "react/jsx-dev-runtime";
565
- "use client";
566
- function OverlayConflictResolver({
567
- conflicts,
568
- onResolve,
569
- locale
570
- }) {
571
- const i18n = useMemo2(() => createSurfaceI18n(locale), [locale]);
572
- return /* @__PURE__ */ jsxDEV7("div", {
573
- "data-overlay-conflicts": true,
574
- style: {
575
- padding: "12px",
576
- marginBottom: "12px",
577
- border: "1px solid var(--destructive, #ef4444)",
578
- borderRadius: "8px",
579
- backgroundColor: "var(--destructive/10, #fef2f2)"
580
- },
581
- children: [
582
- /* @__PURE__ */ jsxDEV7("div", {
583
- style: {
584
- fontSize: "14px",
585
- fontWeight: 600,
586
- marginBottom: "8px",
587
- color: "var(--destructive, #ef4444)"
588
- },
589
- children: i18n.t("overlay.conflicts.title")
590
- }, undefined, false, undefined, this),
591
- conflicts.map((c) => /* @__PURE__ */ jsxDEV7("div", {
592
- style: {
593
- padding: "8px",
594
- marginBottom: "8px",
595
- backgroundColor: "white",
596
- borderRadius: "4px",
597
- fontSize: "13px"
598
- },
599
- children: [
600
- /* @__PURE__ */ jsxDEV7("span", {
601
- children: c.targetKey
602
- }, undefined, false, undefined, this),
603
- /* @__PURE__ */ jsxDEV7("span", {
604
- style: { margin: "0 8px", color: "#9ca3af" },
605
- children: [
606
- "(",
607
- c.scopeA,
608
- " vs ",
609
- c.scopeB,
610
- ")"
611
- ]
612
- }, undefined, true, undefined, this),
613
- /* @__PURE__ */ jsxDEV7("div", {
614
- style: { marginTop: "8px", display: "flex", gap: "8px" },
615
- children: [
616
- /* @__PURE__ */ jsxDEV7("button", {
617
- type: "button",
618
- onClick: () => onResolve({ targetKey: c.targetKey, chosenScope: "A" }),
619
- style: {
620
- padding: "4px 12px",
621
- fontSize: "12px",
622
- borderRadius: "4px",
623
- border: "1px solid #e5e7eb",
624
- backgroundColor: "white",
625
- cursor: "pointer"
626
- },
627
- children: i18n.t("overlay.conflicts.keepScope", { scope: c.scopeA })
628
- }, undefined, false, undefined, this),
629
- /* @__PURE__ */ jsxDEV7("button", {
630
- type: "button",
631
- onClick: () => onResolve({ targetKey: c.targetKey, chosenScope: "B" }),
632
- style: {
633
- padding: "4px 12px",
634
- fontSize: "12px",
635
- borderRadius: "4px",
636
- border: "1px solid #e5e7eb",
637
- backgroundColor: "white",
638
- cursor: "pointer"
639
- },
640
- children: i18n.t("overlay.conflicts.keepScope", { scope: c.scopeB })
641
- }, undefined, false, undefined, this)
642
- ]
643
- }, undefined, true, undefined, this)
644
- ]
645
- }, `${c.targetKey}-${c.overlayIdA}-${c.overlayIdB}`, true, undefined, this))
646
- ]
647
- }, undefined, true, undefined, this);
648
- }
649
-
650
- // src/react/BundleRenderer.tsx
651
- import { jsxDEV as jsxDEV8, Fragment } from "react/jsx-dev-runtime";
652
- "use client";
653
- function BundleRenderer({
2
+ import { jsxDEV as jsxDEV_7x81h0kn, Fragment as Fragment_8vg9x3sq } from "react/jsx-dev-runtime";
3
+ import { useBundlePlan } from "./BundleProvider";
4
+ import { RegionRenderer } from "./RegionRenderer";
5
+ import { SlotRenderer } from "./SlotRenderer";
6
+ import { PatchProposalCard } from "./PatchProposalCard";
7
+ import { OverlayConflictResolver } from "./OverlayConflictResolver";
8
+ import { motionAdapterStub } from "../adapters/motion-stub";
9
+ export function BundleRenderer({
654
10
  assistantSlotId,
655
11
  assistantSlotContent,
12
+ slotContent,
656
13
  onPatchAccept,
657
14
  onPatchReject,
658
15
  onOverlayConflictResolve
@@ -667,12 +24,15 @@ function BundleRenderer({
667
24
  const proposals = plan.ai?.proposals?.filter((p) => p.approvalState === "proposed");
668
25
  const locale = plan.locale;
669
26
  const renderSlot = (slotId, slotCtx) => {
27
+ if (slotContent && slotId in slotContent && slotContent[slotId] != null) {
28
+ return slotContent[slotId];
29
+ }
670
30
  if (assistantSlotId && slotId === assistantSlotId) {
671
- return /* @__PURE__ */ jsxDEV8(Fragment, {
31
+ return /* @__PURE__ */ jsxDEV_7x81h0kn(Fragment_8vg9x3sq, {
672
32
  children: [
673
- proposals && proposals.length > 0 && onPatchAccept && onPatchReject && /* @__PURE__ */ jsxDEV8("div", {
33
+ proposals && proposals.length > 0 && onPatchAccept && onPatchReject && /* @__PURE__ */ jsxDEV_7x81h0kn("div", {
674
34
  style: { marginBottom: "12px" },
675
- children: proposals.map((p) => /* @__PURE__ */ jsxDEV8(PatchProposalCard, {
35
+ children: proposals.map((p) => /* @__PURE__ */ jsxDEV_7x81h0kn(PatchProposalCard, {
676
36
  proposal: p,
677
37
  onAccept: onPatchAccept,
678
38
  onReject: onPatchReject,
@@ -684,14 +44,14 @@ function BundleRenderer({
684
44
  }, undefined, true, undefined, this);
685
45
  }
686
46
  const nodes = getNodesForSlot(plan.nodes, slotId);
687
- return /* @__PURE__ */ jsxDEV8(SlotRenderer, {
47
+ return /* @__PURE__ */ jsxDEV_7x81h0kn(SlotRenderer, {
688
48
  slotId,
689
49
  ctx: slotCtx,
690
50
  nodes
691
51
  }, undefined, false, undefined, this);
692
52
  };
693
53
  const conflicts = plan.overlayConflicts ?? [];
694
- return /* @__PURE__ */ jsxDEV8("div", {
54
+ return /* @__PURE__ */ jsxDEV_7x81h0kn("div", {
695
55
  "data-bundle-key": plan.bundleKey,
696
56
  "data-surface-id": plan.surfaceId,
697
57
  "data-layout-id": plan.layoutId,
@@ -703,12 +63,12 @@ function BundleRenderer({
703
63
  transition: motionTokens.layout ? `all ${motionTokens.durationMs}ms ease` : undefined
704
64
  },
705
65
  children: [
706
- conflicts.length > 0 && onOverlayConflictResolve && /* @__PURE__ */ jsxDEV8(OverlayConflictResolver, {
66
+ conflicts.length > 0 && onOverlayConflictResolve && /* @__PURE__ */ jsxDEV_7x81h0kn(OverlayConflictResolver, {
707
67
  conflicts,
708
68
  onResolve: onOverlayConflictResolve,
709
69
  locale
710
70
  }, undefined, false, undefined, this),
711
- /* @__PURE__ */ jsxDEV8(RegionRenderer, {
71
+ /* @__PURE__ */ jsxDEV_7x81h0kn(RegionRenderer, {
712
72
  region: plan.layoutRoot,
713
73
  ctx,
714
74
  renderSlot
@@ -721,6 +81,3 @@ function getNodesForSlot(nodes, slotId) {
721
81
  return nodes;
722
82
  return [];
723
83
  }
724
- export {
725
- BundleRenderer
726
- };