@contractspec/lib.surface-runtime 0.2.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 (232) hide show
  1. package/README.md +164 -0
  2. package/dist/adapters/ai-sdk-stub.d.ts +5 -0
  3. package/dist/adapters/ai-sdk-stub.js +13 -0
  4. package/dist/adapters/blocknote-stub.d.ts +6 -0
  5. package/dist/adapters/blocknote-stub.js +31 -0
  6. package/dist/adapters/dnd-kit-adapter.d.ts +13 -0
  7. package/dist/adapters/dnd-kit-adapter.js +44 -0
  8. package/dist/adapters/dnd-kit-stub.d.ts +6 -0
  9. package/dist/adapters/dnd-kit-stub.js +8 -0
  10. package/dist/adapters/floating-ui-stub.d.ts +6 -0
  11. package/dist/adapters/floating-ui-stub.js +19 -0
  12. package/dist/adapters/index.d.ts +11 -0
  13. package/dist/adapters/index.js +176 -0
  14. package/dist/adapters/interfaces.d.ts +75 -0
  15. package/dist/adapters/interfaces.js +1 -0
  16. package/dist/adapters/motion-stub.d.ts +7 -0
  17. package/dist/adapters/motion-stub.js +27 -0
  18. package/dist/adapters/motion-stub.test.d.ts +1 -0
  19. package/dist/adapters/resizable-panels-stub.d.ts +6 -0
  20. package/dist/adapters/resizable-panels-stub.js +46 -0
  21. package/dist/adapters/resizable-panels-stub.test.d.ts +1 -0
  22. package/dist/browser/adapters/ai-sdk-stub.js +12 -0
  23. package/dist/browser/adapters/blocknote-stub.js +30 -0
  24. package/dist/browser/adapters/dnd-kit-adapter.js +43 -0
  25. package/dist/browser/adapters/dnd-kit-stub.js +7 -0
  26. package/dist/browser/adapters/floating-ui-stub.js +18 -0
  27. package/dist/browser/adapters/index.js +175 -0
  28. package/dist/browser/adapters/interfaces.js +0 -0
  29. package/dist/browser/adapters/motion-stub.js +26 -0
  30. package/dist/browser/adapters/resizable-panels-stub.js +45 -0
  31. package/dist/browser/evals/golden-context.js +0 -0
  32. package/dist/browser/evals/golden-harness.js +848 -0
  33. package/dist/browser/examples/pm-workbench.bundle.js +476 -0
  34. package/dist/browser/i18n/catalogs/en.js +71 -0
  35. package/dist/browser/i18n/catalogs/es.js +32 -0
  36. package/dist/browser/i18n/catalogs/fr.js +32 -0
  37. package/dist/browser/i18n/catalogs/index.js +133 -0
  38. package/dist/browser/i18n/index.js +173 -0
  39. package/dist/browser/i18n/keys.js +19 -0
  40. package/dist/browser/i18n/messages.js +143 -0
  41. package/dist/browser/index.js +2466 -0
  42. package/dist/browser/react/BundleProvider.js +47 -0
  43. package/dist/browser/react/BundleRenderer.js +726 -0
  44. package/dist/browser/react/OverlayConflictResolver.js +255 -0
  45. package/dist/browser/react/PatchProposalCard.js +255 -0
  46. package/dist/browser/react/RegionRenderer.js +128 -0
  47. package/dist/browser/react/SlotRenderer.js +118 -0
  48. package/dist/browser/react/WidgetPalette.js +59 -0
  49. package/dist/browser/react/index.js +792 -0
  50. package/dist/browser/runtime/apply-surface-patch.js +322 -0
  51. package/dist/browser/runtime/audit-events.js +137 -0
  52. package/dist/browser/runtime/build-context.js +55 -0
  53. package/dist/browser/runtime/extension-registry.js +58 -0
  54. package/dist/browser/runtime/field-renderer-registry.js +145 -0
  55. package/dist/browser/runtime/index.js +1496 -0
  56. package/dist/browser/runtime/overlay-alignment.js +83 -0
  57. package/dist/browser/runtime/overlay-signer.js +15 -0
  58. package/dist/browser/runtime/override-store.js +52 -0
  59. package/dist/browser/runtime/planner-prompt.js +67 -0
  60. package/dist/browser/runtime/planner-tools.js +77 -0
  61. package/dist/browser/runtime/policy-eval.js +155 -0
  62. package/dist/browser/runtime/preference-adapter.js +67 -0
  63. package/dist/browser/runtime/resolve-bundle.js +767 -0
  64. package/dist/browser/runtime/resolve-preferences.js +59 -0
  65. package/dist/browser/runtime/rollback.js +347 -0
  66. package/dist/browser/runtime/widget-registry.js +36 -0
  67. package/dist/browser/spec/define-module-bundle.js +113 -0
  68. package/dist/browser/spec/index.js +319 -0
  69. package/dist/browser/spec/types.js +0 -0
  70. package/dist/browser/spec/validate-bundle.js +65 -0
  71. package/dist/browser/spec/validate-surface-patch.js +206 -0
  72. package/dist/browser/spec/verification-snapshot-types.js +0 -0
  73. package/dist/browser/telemetry/index.js +20 -0
  74. package/dist/browser/telemetry/surface-metrics.js +20 -0
  75. package/dist/evals/golden-context.d.ts +24 -0
  76. package/dist/evals/golden-context.js +1 -0
  77. package/dist/evals/golden-harness.d.ts +29 -0
  78. package/dist/evals/golden-harness.js +849 -0
  79. package/dist/evals/golden-harness.test.d.ts +1 -0
  80. package/dist/examples/pm-workbench.bundle.d.ts +177 -0
  81. package/dist/examples/pm-workbench.bundle.js +477 -0
  82. package/dist/i18n/catalogs/en.d.ts +1 -0
  83. package/dist/i18n/catalogs/en.js +72 -0
  84. package/dist/i18n/catalogs/es.d.ts +1 -0
  85. package/dist/i18n/catalogs/es.js +33 -0
  86. package/dist/i18n/catalogs/fr.d.ts +1 -0
  87. package/dist/i18n/catalogs/fr.js +33 -0
  88. package/dist/i18n/catalogs/index.d.ts +3 -0
  89. package/dist/i18n/catalogs/index.js +134 -0
  90. package/dist/i18n/index.d.ts +5 -0
  91. package/dist/i18n/index.js +174 -0
  92. package/dist/i18n/keys.d.ts +20 -0
  93. package/dist/i18n/keys.js +20 -0
  94. package/dist/i18n/messages.d.ts +5 -0
  95. package/dist/i18n/messages.js +144 -0
  96. package/dist/index.d.ts +4 -0
  97. package/dist/index.js +2467 -0
  98. package/dist/node/adapters/ai-sdk-stub.js +12 -0
  99. package/dist/node/adapters/blocknote-stub.js +30 -0
  100. package/dist/node/adapters/dnd-kit-adapter.js +43 -0
  101. package/dist/node/adapters/dnd-kit-stub.js +7 -0
  102. package/dist/node/adapters/floating-ui-stub.js +18 -0
  103. package/dist/node/adapters/index.js +175 -0
  104. package/dist/node/adapters/interfaces.js +0 -0
  105. package/dist/node/adapters/motion-stub.js +26 -0
  106. package/dist/node/adapters/resizable-panels-stub.js +45 -0
  107. package/dist/node/evals/golden-context.js +0 -0
  108. package/dist/node/evals/golden-harness.js +848 -0
  109. package/dist/node/examples/pm-workbench.bundle.js +476 -0
  110. package/dist/node/i18n/catalogs/en.js +71 -0
  111. package/dist/node/i18n/catalogs/es.js +32 -0
  112. package/dist/node/i18n/catalogs/fr.js +32 -0
  113. package/dist/node/i18n/catalogs/index.js +133 -0
  114. package/dist/node/i18n/index.js +173 -0
  115. package/dist/node/i18n/keys.js +19 -0
  116. package/dist/node/i18n/messages.js +143 -0
  117. package/dist/node/index.js +2466 -0
  118. package/dist/node/react/BundleProvider.js +47 -0
  119. package/dist/node/react/BundleRenderer.js +726 -0
  120. package/dist/node/react/OverlayConflictResolver.js +255 -0
  121. package/dist/node/react/PatchProposalCard.js +255 -0
  122. package/dist/node/react/RegionRenderer.js +128 -0
  123. package/dist/node/react/SlotRenderer.js +118 -0
  124. package/dist/node/react/WidgetPalette.js +59 -0
  125. package/dist/node/react/index.js +792 -0
  126. package/dist/node/runtime/apply-surface-patch.js +322 -0
  127. package/dist/node/runtime/audit-events.js +137 -0
  128. package/dist/node/runtime/build-context.js +55 -0
  129. package/dist/node/runtime/extension-registry.js +58 -0
  130. package/dist/node/runtime/field-renderer-registry.js +145 -0
  131. package/dist/node/runtime/index.js +1496 -0
  132. package/dist/node/runtime/overlay-alignment.js +83 -0
  133. package/dist/node/runtime/overlay-signer.js +15 -0
  134. package/dist/node/runtime/override-store.js +52 -0
  135. package/dist/node/runtime/planner-prompt.js +67 -0
  136. package/dist/node/runtime/planner-tools.js +77 -0
  137. package/dist/node/runtime/policy-eval.js +155 -0
  138. package/dist/node/runtime/preference-adapter.js +67 -0
  139. package/dist/node/runtime/resolve-bundle.js +767 -0
  140. package/dist/node/runtime/resolve-preferences.js +59 -0
  141. package/dist/node/runtime/rollback.js +347 -0
  142. package/dist/node/runtime/widget-registry.js +36 -0
  143. package/dist/node/spec/define-module-bundle.js +113 -0
  144. package/dist/node/spec/index.js +319 -0
  145. package/dist/node/spec/types.js +0 -0
  146. package/dist/node/spec/validate-bundle.js +65 -0
  147. package/dist/node/spec/validate-surface-patch.js +206 -0
  148. package/dist/node/spec/verification-snapshot-types.js +0 -0
  149. package/dist/node/telemetry/index.js +20 -0
  150. package/dist/node/telemetry/surface-metrics.js +20 -0
  151. package/dist/react/BundleProvider.d.ts +13 -0
  152. package/dist/react/BundleProvider.js +48 -0
  153. package/dist/react/BundleRenderer.d.ts +22 -0
  154. package/dist/react/BundleRenderer.js +727 -0
  155. package/dist/react/OverlayConflictResolver.d.ts +15 -0
  156. package/dist/react/OverlayConflictResolver.js +256 -0
  157. package/dist/react/PatchProposalCard.d.ts +13 -0
  158. package/dist/react/PatchProposalCard.js +256 -0
  159. package/dist/react/RegionRenderer.d.ts +13 -0
  160. package/dist/react/RegionRenderer.js +129 -0
  161. package/dist/react/SlotRenderer.d.ts +13 -0
  162. package/dist/react/SlotRenderer.js +119 -0
  163. package/dist/react/WidgetPalette.d.ts +12 -0
  164. package/dist/react/WidgetPalette.js +60 -0
  165. package/dist/react/index.d.ts +7 -0
  166. package/dist/react/index.js +793 -0
  167. package/dist/runtime/apply-surface-patch.d.ts +15 -0
  168. package/dist/runtime/apply-surface-patch.js +323 -0
  169. package/dist/runtime/apply-surface-patch.test.d.ts +1 -0
  170. package/dist/runtime/audit-events.d.ts +70 -0
  171. package/dist/runtime/audit-events.js +138 -0
  172. package/dist/runtime/audit-events.test.d.ts +1 -0
  173. package/dist/runtime/build-context.d.ts +9 -0
  174. package/dist/runtime/build-context.js +56 -0
  175. package/dist/runtime/extension-registry.d.ts +39 -0
  176. package/dist/runtime/extension-registry.js +59 -0
  177. package/dist/runtime/field-renderer-registry.d.ts +23 -0
  178. package/dist/runtime/field-renderer-registry.js +146 -0
  179. package/dist/runtime/field-renderer-registry.test.d.ts +1 -0
  180. package/dist/runtime/index.d.ts +16 -0
  181. package/dist/runtime/index.js +1497 -0
  182. package/dist/runtime/overlay-alignment.d.ts +49 -0
  183. package/dist/runtime/overlay-alignment.js +84 -0
  184. package/dist/runtime/overlay-alignment.test.d.ts +1 -0
  185. package/dist/runtime/overlay-signer.d.ts +15 -0
  186. package/dist/runtime/overlay-signer.js +16 -0
  187. package/dist/runtime/override-store.d.ts +44 -0
  188. package/dist/runtime/override-store.js +53 -0
  189. package/dist/runtime/override-store.test.d.ts +1 -0
  190. package/dist/runtime/planner-prompt.d.ts +39 -0
  191. package/dist/runtime/planner-prompt.js +68 -0
  192. package/dist/runtime/planner-prompt.test.d.ts +1 -0
  193. package/dist/runtime/planner-tools.d.ts +106 -0
  194. package/dist/runtime/planner-tools.js +78 -0
  195. package/dist/runtime/planner-tools.test.d.ts +1 -0
  196. package/dist/runtime/policy-eval.d.ts +23 -0
  197. package/dist/runtime/policy-eval.js +156 -0
  198. package/dist/runtime/preference-adapter.d.ts +6 -0
  199. package/dist/runtime/preference-adapter.js +68 -0
  200. package/dist/runtime/resolve-bundle.d.ts +68 -0
  201. package/dist/runtime/resolve-bundle.js +768 -0
  202. package/dist/runtime/resolve-bundle.test.d.ts +1 -0
  203. package/dist/runtime/resolve-preferences.d.ts +9 -0
  204. package/dist/runtime/resolve-preferences.js +60 -0
  205. package/dist/runtime/resolve-preferences.test.d.ts +1 -0
  206. package/dist/runtime/rollback.d.ts +21 -0
  207. package/dist/runtime/rollback.js +348 -0
  208. package/dist/runtime/rollback.test.d.ts +1 -0
  209. package/dist/runtime/widget-registry.d.ts +26 -0
  210. package/dist/runtime/widget-registry.js +37 -0
  211. package/dist/runtime/widget-registry.test.d.ts +1 -0
  212. package/dist/spec/define-module-bundle.d.ts +17 -0
  213. package/dist/spec/define-module-bundle.js +114 -0
  214. package/dist/spec/define-module-bundle.test.d.ts +1 -0
  215. package/dist/spec/index.d.ts +5 -0
  216. package/dist/spec/index.js +320 -0
  217. package/dist/spec/types.d.ts +494 -0
  218. package/dist/spec/types.js +1 -0
  219. package/dist/spec/validate-bundle.d.ts +23 -0
  220. package/dist/spec/validate-bundle.js +66 -0
  221. package/dist/spec/validate-bundle.test.d.ts +1 -0
  222. package/dist/spec/validate-surface-patch.d.ts +39 -0
  223. package/dist/spec/validate-surface-patch.js +207 -0
  224. package/dist/spec/validate-surface-patch.test.d.ts +1 -0
  225. package/dist/spec/verification-snapshot-types.d.ts +23 -0
  226. package/dist/spec/verification-snapshot-types.js +1 -0
  227. package/dist/spec/verification-snapshot.test.d.ts +5 -0
  228. package/dist/telemetry/index.d.ts +5 -0
  229. package/dist/telemetry/index.js +21 -0
  230. package/dist/telemetry/surface-metrics.d.ts +17 -0
  231. package/dist/telemetry/surface-metrics.js +21 -0
  232. package/package.json +920 -0
@@ -0,0 +1,255 @@
1
+ // src/i18n/catalogs/en.ts
2
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
3
+ var enMessages = defineTranslation({
4
+ meta: {
5
+ key: "surface-runtime.messages",
6
+ version: "1.0.0",
7
+ domain: "surface-runtime",
8
+ description: "User-facing strings for surface-runtime UI components",
9
+ owners: ["platform"],
10
+ stability: "experimental"
11
+ },
12
+ locale: "en",
13
+ fallback: "en",
14
+ messages: {
15
+ "overlay.conflicts.title": {
16
+ value: "Overlay conflicts",
17
+ description: "Title for overlay conflict resolution banner"
18
+ },
19
+ "overlay.conflicts.keepScope": {
20
+ value: "Keep {scope}",
21
+ description: "Button to keep overlay from scope A or B"
22
+ },
23
+ "patch.accept": {
24
+ value: "Accept",
25
+ description: "Accept patch proposal button"
26
+ },
27
+ "patch.reject": {
28
+ value: "Reject",
29
+ description: "Reject patch proposal button"
30
+ },
31
+ "patch.addWidget": {
32
+ value: "Add {title} to {slot}",
33
+ description: "Insert node proposal summary"
34
+ },
35
+ "patch.removeItem": {
36
+ value: "Remove item",
37
+ description: "Remove node proposal summary"
38
+ },
39
+ "patch.switchLayout": {
40
+ value: "Switch to {layoutId} layout",
41
+ description: "Set layout proposal summary"
42
+ },
43
+ "patch.showField": {
44
+ value: "Show field {fieldId}",
45
+ description: "Reveal field proposal summary"
46
+ },
47
+ "patch.hideField": {
48
+ value: "Hide field {fieldId}",
49
+ description: "Hide field proposal summary"
50
+ },
51
+ "patch.moveTo": {
52
+ value: "Move to {slot}",
53
+ description: "Move node proposal summary"
54
+ },
55
+ "patch.replaceItem": {
56
+ value: "Replace item",
57
+ description: "Replace node proposal summary"
58
+ },
59
+ "patch.promote": {
60
+ value: "Promote {actionId}",
61
+ description: "Promote action proposal summary"
62
+ },
63
+ "patch.changes": {
64
+ value: "{count} changes",
65
+ description: "Multiple patch ops summary"
66
+ }
67
+ }
68
+ });
69
+
70
+ // src/i18n/catalogs/es.ts
71
+ import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
72
+ var esMessages = defineTranslation2({
73
+ meta: {
74
+ key: "surface-runtime.messages",
75
+ version: "1.0.0",
76
+ domain: "surface-runtime",
77
+ description: "User-facing strings for surface-runtime UI components",
78
+ owners: ["platform"],
79
+ stability: "experimental"
80
+ },
81
+ locale: "es",
82
+ fallback: "en",
83
+ messages: {
84
+ "overlay.conflicts.title": { value: "Conflictos de superposición" },
85
+ "overlay.conflicts.keepScope": { value: "Mantener {scope}" },
86
+ "patch.accept": { value: "Aceptar" },
87
+ "patch.reject": { value: "Rechazar" },
88
+ "patch.addWidget": { value: "Añadir {title} a {slot}" },
89
+ "patch.removeItem": { value: "Eliminar elemento" },
90
+ "patch.switchLayout": { value: "Cambiar a disposición {layoutId}" },
91
+ "patch.showField": { value: "Mostrar campo {fieldId}" },
92
+ "patch.hideField": { value: "Ocultar campo {fieldId}" },
93
+ "patch.moveTo": { value: "Mover a {slot}" },
94
+ "patch.replaceItem": { value: "Reemplazar elemento" },
95
+ "patch.promote": { value: "Promover {actionId}" },
96
+ "patch.changes": { value: "{count} cambios" }
97
+ }
98
+ });
99
+
100
+ // src/i18n/catalogs/fr.ts
101
+ import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
102
+ var frMessages = defineTranslation3({
103
+ meta: {
104
+ key: "surface-runtime.messages",
105
+ version: "1.0.0",
106
+ domain: "surface-runtime",
107
+ description: "User-facing strings for surface-runtime UI components",
108
+ owners: ["platform"],
109
+ stability: "experimental"
110
+ },
111
+ locale: "fr",
112
+ fallback: "en",
113
+ messages: {
114
+ "overlay.conflicts.title": { value: "Conflits de superposition" },
115
+ "overlay.conflicts.keepScope": { value: "Conserver {scope}" },
116
+ "patch.accept": { value: "Accepter" },
117
+ "patch.reject": { value: "Rejeter" },
118
+ "patch.addWidget": { value: "Ajouter {title} à {slot}" },
119
+ "patch.removeItem": { value: "Supprimer l'élément" },
120
+ "patch.switchLayout": { value: "Passer à la disposition {layoutId}" },
121
+ "patch.showField": { value: "Afficher le champ {fieldId}" },
122
+ "patch.hideField": { value: "Masquer le champ {fieldId}" },
123
+ "patch.moveTo": { value: "Déplacer vers {slot}" },
124
+ "patch.replaceItem": { value: "Remplacer l'élément" },
125
+ "patch.promote": { value: "Promouvoir {actionId}" },
126
+ "patch.changes": { value: "{count} modifications" }
127
+ }
128
+ });
129
+
130
+ // src/i18n/messages.ts
131
+ import {
132
+ createI18nFactory
133
+ } from "@contractspec/lib.contracts-spec/translations";
134
+ var factory = createI18nFactory({
135
+ specKey: "surface-runtime.messages",
136
+ catalogs: [enMessages, frMessages, esMessages]
137
+ });
138
+ var createSurfaceI18n = factory.create;
139
+ var getDefaultSurfaceI18n = factory.getDefault;
140
+
141
+ // src/i18n/keys.ts
142
+ var SURFACE_KEYS = {
143
+ "overlay.conflicts.title": "overlay.conflicts.title",
144
+ "overlay.conflicts.keepScope": "overlay.conflicts.keepScope",
145
+ "patch.accept": "patch.accept",
146
+ "patch.reject": "patch.reject",
147
+ "patch.addWidget": "patch.addWidget",
148
+ "patch.removeItem": "patch.removeItem",
149
+ "patch.switchLayout": "patch.switchLayout",
150
+ "patch.showField": "patch.showField",
151
+ "patch.hideField": "patch.hideField",
152
+ "patch.moveTo": "patch.moveTo",
153
+ "patch.replaceItem": "patch.replaceItem",
154
+ "patch.promote": "patch.promote",
155
+ "patch.changes": "patch.changes"
156
+ };
157
+
158
+ // src/i18n/index.ts
159
+ import {
160
+ resolveLocale,
161
+ isSupportedLocale,
162
+ DEFAULT_LOCALE,
163
+ SUPPORTED_LOCALES
164
+ } from "@contractspec/lib.contracts-spec/translations";
165
+
166
+ // src/react/OverlayConflictResolver.tsx
167
+ import { useMemo } from "react";
168
+ import { jsxDEV } from "react/jsx-dev-runtime";
169
+ "use client";
170
+ function OverlayConflictResolver({
171
+ conflicts,
172
+ onResolve,
173
+ locale
174
+ }) {
175
+ const i18n = useMemo(() => createSurfaceI18n(locale), [locale]);
176
+ return /* @__PURE__ */ jsxDEV("div", {
177
+ "data-overlay-conflicts": true,
178
+ style: {
179
+ padding: "12px",
180
+ marginBottom: "12px",
181
+ border: "1px solid var(--destructive, #ef4444)",
182
+ borderRadius: "8px",
183
+ backgroundColor: "var(--destructive/10, #fef2f2)"
184
+ },
185
+ children: [
186
+ /* @__PURE__ */ jsxDEV("div", {
187
+ style: {
188
+ fontSize: "14px",
189
+ fontWeight: 600,
190
+ marginBottom: "8px",
191
+ color: "var(--destructive, #ef4444)"
192
+ },
193
+ children: i18n.t("overlay.conflicts.title")
194
+ }, undefined, false, undefined, this),
195
+ conflicts.map((c) => /* @__PURE__ */ jsxDEV("div", {
196
+ style: {
197
+ padding: "8px",
198
+ marginBottom: "8px",
199
+ backgroundColor: "white",
200
+ borderRadius: "4px",
201
+ fontSize: "13px"
202
+ },
203
+ children: [
204
+ /* @__PURE__ */ jsxDEV("span", {
205
+ children: c.targetKey
206
+ }, undefined, false, undefined, this),
207
+ /* @__PURE__ */ jsxDEV("span", {
208
+ style: { margin: "0 8px", color: "#9ca3af" },
209
+ children: [
210
+ "(",
211
+ c.scopeA,
212
+ " vs ",
213
+ c.scopeB,
214
+ ")"
215
+ ]
216
+ }, undefined, true, undefined, this),
217
+ /* @__PURE__ */ jsxDEV("div", {
218
+ style: { marginTop: "8px", display: "flex", gap: "8px" },
219
+ children: [
220
+ /* @__PURE__ */ jsxDEV("button", {
221
+ type: "button",
222
+ onClick: () => onResolve({ targetKey: c.targetKey, chosenScope: "A" }),
223
+ style: {
224
+ padding: "4px 12px",
225
+ fontSize: "12px",
226
+ borderRadius: "4px",
227
+ border: "1px solid #e5e7eb",
228
+ backgroundColor: "white",
229
+ cursor: "pointer"
230
+ },
231
+ children: i18n.t("overlay.conflicts.keepScope", { scope: c.scopeA })
232
+ }, undefined, false, undefined, this),
233
+ /* @__PURE__ */ jsxDEV("button", {
234
+ type: "button",
235
+ onClick: () => onResolve({ targetKey: c.targetKey, chosenScope: "B" }),
236
+ style: {
237
+ padding: "4px 12px",
238
+ fontSize: "12px",
239
+ borderRadius: "4px",
240
+ border: "1px solid #e5e7eb",
241
+ backgroundColor: "white",
242
+ cursor: "pointer"
243
+ },
244
+ children: i18n.t("overlay.conflicts.keepScope", { scope: c.scopeB })
245
+ }, undefined, false, undefined, this)
246
+ ]
247
+ }, undefined, true, undefined, this)
248
+ ]
249
+ }, `${c.targetKey}-${c.overlayIdA}-${c.overlayIdB}`, true, undefined, this))
250
+ ]
251
+ }, undefined, true, undefined, this);
252
+ }
253
+ export {
254
+ OverlayConflictResolver
255
+ };
@@ -0,0 +1,255 @@
1
+ // src/i18n/catalogs/en.ts
2
+ import { defineTranslation } from "@contractspec/lib.contracts-spec/translations";
3
+ var enMessages = defineTranslation({
4
+ meta: {
5
+ key: "surface-runtime.messages",
6
+ version: "1.0.0",
7
+ domain: "surface-runtime",
8
+ description: "User-facing strings for surface-runtime UI components",
9
+ owners: ["platform"],
10
+ stability: "experimental"
11
+ },
12
+ locale: "en",
13
+ fallback: "en",
14
+ messages: {
15
+ "overlay.conflicts.title": {
16
+ value: "Overlay conflicts",
17
+ description: "Title for overlay conflict resolution banner"
18
+ },
19
+ "overlay.conflicts.keepScope": {
20
+ value: "Keep {scope}",
21
+ description: "Button to keep overlay from scope A or B"
22
+ },
23
+ "patch.accept": {
24
+ value: "Accept",
25
+ description: "Accept patch proposal button"
26
+ },
27
+ "patch.reject": {
28
+ value: "Reject",
29
+ description: "Reject patch proposal button"
30
+ },
31
+ "patch.addWidget": {
32
+ value: "Add {title} to {slot}",
33
+ description: "Insert node proposal summary"
34
+ },
35
+ "patch.removeItem": {
36
+ value: "Remove item",
37
+ description: "Remove node proposal summary"
38
+ },
39
+ "patch.switchLayout": {
40
+ value: "Switch to {layoutId} layout",
41
+ description: "Set layout proposal summary"
42
+ },
43
+ "patch.showField": {
44
+ value: "Show field {fieldId}",
45
+ description: "Reveal field proposal summary"
46
+ },
47
+ "patch.hideField": {
48
+ value: "Hide field {fieldId}",
49
+ description: "Hide field proposal summary"
50
+ },
51
+ "patch.moveTo": {
52
+ value: "Move to {slot}",
53
+ description: "Move node proposal summary"
54
+ },
55
+ "patch.replaceItem": {
56
+ value: "Replace item",
57
+ description: "Replace node proposal summary"
58
+ },
59
+ "patch.promote": {
60
+ value: "Promote {actionId}",
61
+ description: "Promote action proposal summary"
62
+ },
63
+ "patch.changes": {
64
+ value: "{count} changes",
65
+ description: "Multiple patch ops summary"
66
+ }
67
+ }
68
+ });
69
+
70
+ // src/i18n/catalogs/es.ts
71
+ import { defineTranslation as defineTranslation2 } from "@contractspec/lib.contracts-spec/translations";
72
+ var esMessages = defineTranslation2({
73
+ meta: {
74
+ key: "surface-runtime.messages",
75
+ version: "1.0.0",
76
+ domain: "surface-runtime",
77
+ description: "User-facing strings for surface-runtime UI components",
78
+ owners: ["platform"],
79
+ stability: "experimental"
80
+ },
81
+ locale: "es",
82
+ fallback: "en",
83
+ messages: {
84
+ "overlay.conflicts.title": { value: "Conflictos de superposición" },
85
+ "overlay.conflicts.keepScope": { value: "Mantener {scope}" },
86
+ "patch.accept": { value: "Aceptar" },
87
+ "patch.reject": { value: "Rechazar" },
88
+ "patch.addWidget": { value: "Añadir {title} a {slot}" },
89
+ "patch.removeItem": { value: "Eliminar elemento" },
90
+ "patch.switchLayout": { value: "Cambiar a disposición {layoutId}" },
91
+ "patch.showField": { value: "Mostrar campo {fieldId}" },
92
+ "patch.hideField": { value: "Ocultar campo {fieldId}" },
93
+ "patch.moveTo": { value: "Mover a {slot}" },
94
+ "patch.replaceItem": { value: "Reemplazar elemento" },
95
+ "patch.promote": { value: "Promover {actionId}" },
96
+ "patch.changes": { value: "{count} cambios" }
97
+ }
98
+ });
99
+
100
+ // src/i18n/catalogs/fr.ts
101
+ import { defineTranslation as defineTranslation3 } from "@contractspec/lib.contracts-spec/translations";
102
+ var frMessages = defineTranslation3({
103
+ meta: {
104
+ key: "surface-runtime.messages",
105
+ version: "1.0.0",
106
+ domain: "surface-runtime",
107
+ description: "User-facing strings for surface-runtime UI components",
108
+ owners: ["platform"],
109
+ stability: "experimental"
110
+ },
111
+ locale: "fr",
112
+ fallback: "en",
113
+ messages: {
114
+ "overlay.conflicts.title": { value: "Conflits de superposition" },
115
+ "overlay.conflicts.keepScope": { value: "Conserver {scope}" },
116
+ "patch.accept": { value: "Accepter" },
117
+ "patch.reject": { value: "Rejeter" },
118
+ "patch.addWidget": { value: "Ajouter {title} à {slot}" },
119
+ "patch.removeItem": { value: "Supprimer l'élément" },
120
+ "patch.switchLayout": { value: "Passer à la disposition {layoutId}" },
121
+ "patch.showField": { value: "Afficher le champ {fieldId}" },
122
+ "patch.hideField": { value: "Masquer le champ {fieldId}" },
123
+ "patch.moveTo": { value: "Déplacer vers {slot}" },
124
+ "patch.replaceItem": { value: "Remplacer l'élément" },
125
+ "patch.promote": { value: "Promouvoir {actionId}" },
126
+ "patch.changes": { value: "{count} modifications" }
127
+ }
128
+ });
129
+
130
+ // src/i18n/messages.ts
131
+ import {
132
+ createI18nFactory
133
+ } from "@contractspec/lib.contracts-spec/translations";
134
+ var factory = createI18nFactory({
135
+ specKey: "surface-runtime.messages",
136
+ catalogs: [enMessages, frMessages, esMessages]
137
+ });
138
+ var createSurfaceI18n = factory.create;
139
+ var getDefaultSurfaceI18n = factory.getDefault;
140
+
141
+ // src/i18n/keys.ts
142
+ var SURFACE_KEYS = {
143
+ "overlay.conflicts.title": "overlay.conflicts.title",
144
+ "overlay.conflicts.keepScope": "overlay.conflicts.keepScope",
145
+ "patch.accept": "patch.accept",
146
+ "patch.reject": "patch.reject",
147
+ "patch.addWidget": "patch.addWidget",
148
+ "patch.removeItem": "patch.removeItem",
149
+ "patch.switchLayout": "patch.switchLayout",
150
+ "patch.showField": "patch.showField",
151
+ "patch.hideField": "patch.hideField",
152
+ "patch.moveTo": "patch.moveTo",
153
+ "patch.replaceItem": "patch.replaceItem",
154
+ "patch.promote": "patch.promote",
155
+ "patch.changes": "patch.changes"
156
+ };
157
+
158
+ // src/i18n/index.ts
159
+ import {
160
+ resolveLocale,
161
+ isSupportedLocale,
162
+ DEFAULT_LOCALE,
163
+ SUPPORTED_LOCALES
164
+ } from "@contractspec/lib.contracts-spec/translations";
165
+
166
+ // src/react/PatchProposalCard.tsx
167
+ import { useMemo } from "react";
168
+ import { jsxDEV } from "react/jsx-dev-runtime";
169
+ "use client";
170
+ function PatchProposalCard({
171
+ proposal,
172
+ onAccept,
173
+ onReject,
174
+ locale
175
+ }) {
176
+ const i18n = useMemo(() => createSurfaceI18n(locale), [locale]);
177
+ const firstOp = proposal.ops[0];
178
+ const summary = proposal.ops.length === 1 && firstOp ? describeOp(firstOp, i18n) : i18n.t("patch.changes", { count: proposal.ops.length });
179
+ return /* @__PURE__ */ jsxDEV("div", {
180
+ "data-proposal-id": proposal.proposalId,
181
+ style: {
182
+ padding: "12px",
183
+ border: "1px solid var(--border, #e5e7eb)",
184
+ borderRadius: "8px",
185
+ marginBottom: "8px",
186
+ backgroundColor: "var(--muted, #f9fafb)"
187
+ },
188
+ children: [
189
+ /* @__PURE__ */ jsxDEV("div", {
190
+ style: { marginBottom: "8px", fontSize: "14px" },
191
+ children: summary
192
+ }, undefined, false, undefined, this),
193
+ /* @__PURE__ */ jsxDEV("div", {
194
+ style: { display: "flex", gap: "8px" },
195
+ children: [
196
+ /* @__PURE__ */ jsxDEV("button", {
197
+ type: "button",
198
+ onClick: () => onAccept(proposal.proposalId),
199
+ style: {
200
+ padding: "4px 12px",
201
+ fontSize: "13px",
202
+ borderRadius: "4px",
203
+ border: "none",
204
+ backgroundColor: "var(--primary, #3b82f6)",
205
+ color: "white",
206
+ cursor: "pointer"
207
+ },
208
+ children: i18n.t("patch.accept")
209
+ }, undefined, false, undefined, this),
210
+ /* @__PURE__ */ jsxDEV("button", {
211
+ type: "button",
212
+ onClick: () => onReject(proposal.proposalId),
213
+ style: {
214
+ padding: "4px 12px",
215
+ fontSize: "13px",
216
+ borderRadius: "4px",
217
+ border: "1px solid var(--border, #e5e7eb)",
218
+ backgroundColor: "transparent",
219
+ cursor: "pointer"
220
+ },
221
+ children: i18n.t("patch.reject")
222
+ }, undefined, false, undefined, this)
223
+ ]
224
+ }, undefined, true, undefined, this)
225
+ ]
226
+ }, undefined, true, undefined, this);
227
+ }
228
+ function describeOp(op, i18n) {
229
+ switch (op.op) {
230
+ case "insert-node":
231
+ return i18n.t("patch.addWidget", {
232
+ title: op.node?.title ?? op.node?.kind ?? "widget",
233
+ slot: op.slotId ?? "slot"
234
+ });
235
+ case "remove-node":
236
+ return i18n.t("patch.removeItem");
237
+ case "set-layout":
238
+ return i18n.t("patch.switchLayout", { layoutId: op.layoutId });
239
+ case "reveal-field":
240
+ return i18n.t("patch.showField", { fieldId: op.fieldId });
241
+ case "hide-field":
242
+ return i18n.t("patch.hideField", { fieldId: op.fieldId });
243
+ case "move-node":
244
+ return i18n.t("patch.moveTo", { slot: op.toSlotId ?? "slot" });
245
+ case "replace-node":
246
+ return i18n.t("patch.replaceItem");
247
+ case "promote-action":
248
+ return i18n.t("patch.promote", { actionId: op.actionId });
249
+ default:
250
+ return `${op.op}`;
251
+ }
252
+ }
253
+ export {
254
+ PatchProposalCard
255
+ };
@@ -0,0 +1,128 @@
1
+ // src/adapters/resizable-panels-stub.tsx
2
+ import { jsxDEV } from "react/jsx-dev-runtime";
3
+ var LAYOUT_STORAGE_KEY = "surface-runtime:panel-layout:";
4
+ var resizablePanelsAdapterStub = {
5
+ renderPanelGroup(region, ctx, renderChild) {
6
+ const direction = region.direction === "horizontal" ? "row" : "column";
7
+ return /* @__PURE__ */ jsxDEV("div", {
8
+ "data-panel-group": true,
9
+ "data-persist-key": region.persistKey,
10
+ style: {
11
+ display: "flex",
12
+ flexDirection: direction,
13
+ flex: 1,
14
+ minHeight: 0
15
+ },
16
+ children: region.children.map((child, i) => /* @__PURE__ */ jsxDEV("div", {
17
+ style: { flex: 1, minWidth: 0, minHeight: 0 },
18
+ children: renderChild(child, ctx)
19
+ }, i, false, undefined, this))
20
+ }, undefined, false, undefined, this);
21
+ },
22
+ async restoreLayout(persistKey) {
23
+ if (typeof localStorage === "undefined")
24
+ return null;
25
+ try {
26
+ const raw = localStorage.getItem(LAYOUT_STORAGE_KEY + persistKey);
27
+ if (!raw)
28
+ return null;
29
+ const parsed = JSON.parse(raw);
30
+ return Array.isArray(parsed) ? parsed : null;
31
+ } catch {
32
+ return null;
33
+ }
34
+ },
35
+ async saveLayout(persistKey, sizes) {
36
+ if (typeof localStorage === "undefined")
37
+ return;
38
+ try {
39
+ localStorage.setItem(LAYOUT_STORAGE_KEY + persistKey, JSON.stringify(sizes));
40
+ } catch {}
41
+ }
42
+ };
43
+
44
+ // src/react/RegionRenderer.tsx
45
+ import { jsxDEV as jsxDEV2 } from "react/jsx-dev-runtime";
46
+ function RegionRenderer({
47
+ region,
48
+ ctx,
49
+ renderSlot
50
+ }) {
51
+ const renderChild = (child, childCtx) => /* @__PURE__ */ jsxDEV2(RegionRenderer, {
52
+ region: child,
53
+ ctx: childCtx,
54
+ renderSlot
55
+ }, undefined, false, undefined, this);
56
+ switch (region.type) {
57
+ case "panel-group":
58
+ return resizablePanelsAdapterStub.renderPanelGroup(region, ctx, renderChild);
59
+ case "stack": {
60
+ const direction = region.direction === "horizontal" ? "row" : "column";
61
+ const gapMap = {
62
+ none: 0,
63
+ xs: 4,
64
+ sm: 8,
65
+ md: 16,
66
+ lg: 24
67
+ };
68
+ const gap = gapMap[region.gap ?? "md"];
69
+ return /* @__PURE__ */ jsxDEV2("div", {
70
+ "data-region": "stack",
71
+ style: {
72
+ display: "flex",
73
+ flexDirection: direction,
74
+ gap,
75
+ flex: 1,
76
+ minHeight: 0
77
+ },
78
+ children: region.children.map((child, i) => /* @__PURE__ */ jsxDEV2("div", {
79
+ style: { flex: 1, minWidth: 0, minHeight: 0 },
80
+ children: /* @__PURE__ */ jsxDEV2(RegionRenderer, {
81
+ region: child,
82
+ ctx,
83
+ renderSlot
84
+ }, undefined, false, undefined, this)
85
+ }, i, false, undefined, this))
86
+ }, undefined, false, undefined, this);
87
+ }
88
+ case "tabs":
89
+ return /* @__PURE__ */ jsxDEV2("div", {
90
+ "data-region": "tabs",
91
+ children: [
92
+ /* @__PURE__ */ jsxDEV2("div", {
93
+ role: "tablist",
94
+ children: region.tabs.map((t) => /* @__PURE__ */ jsxDEV2("button", {
95
+ type: "button",
96
+ role: "tab",
97
+ children: t.title
98
+ }, t.key, false, undefined, this))
99
+ }, undefined, false, undefined, this),
100
+ region.tabs[0] && /* @__PURE__ */ jsxDEV2(RegionRenderer, {
101
+ region: region.tabs[0].child,
102
+ ctx,
103
+ renderSlot
104
+ }, undefined, false, undefined, this)
105
+ ]
106
+ }, undefined, true, undefined, this);
107
+ case "slot":
108
+ return /* @__PURE__ */ jsxDEV2("div", {
109
+ "data-slot": region.slotId,
110
+ children: renderSlot(region.slotId, ctx)
111
+ }, undefined, false, undefined, this);
112
+ case "floating":
113
+ return /* @__PURE__ */ jsxDEV2("div", {
114
+ "data-floating": true,
115
+ "data-anchor": region.anchorSlotId,
116
+ children: /* @__PURE__ */ jsxDEV2(RegionRenderer, {
117
+ region: region.child,
118
+ ctx,
119
+ renderSlot
120
+ }, undefined, false, undefined, this)
121
+ }, undefined, false, undefined, this);
122
+ default:
123
+ return null;
124
+ }
125
+ }
126
+ export {
127
+ RegionRenderer
128
+ };