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