@replohq/canopy-sdk 2.0.0 → 2.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 (52) hide show
  1. package/_vendor/replo-utils/lib/log.d.ts +11 -0
  2. package/_vendor/replo-utils/lib/misc.mjs +1 -1
  3. package/_vendor/replo-utils/react/use-iframe-rpc-channel.d.ts +14 -0
  4. package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +14 -0
  5. package/_vendor/schemas/errors.d.ts +36 -15
  6. package/_vendor/schemas/generated/selectMode.d.ts +0 -85
  7. package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +100 -0
  8. package/_vendor/schemas/generated/selectModeIframeRpc.mjs +1 -0
  9. package/_vendor/schemas/iframeRpcChannel.d.ts +82 -0
  10. package/_vendor/schemas/iframeRpcChannel.mjs +361 -0
  11. package/_vendor/schemas/money.mjs +2 -113
  12. package/_vendor/schemas/selectMode.d.ts +0 -496
  13. package/_vendor/schemas/selectMode.mjs +3 -312
  14. package/_vendor/schemas/selectModeIframeRpc.d.ts +900 -0
  15. package/_vendor/schemas/selectModeIframeRpc.mjs +225 -0
  16. package/cart/buy-now-action.js +4 -4
  17. package/cart/buy-now-action.js.map +2 -2
  18. package/chunk-7GWIUERW.mjs +197 -0
  19. package/{chunk-UWHM3FKU.mjs → chunk-H36NDYLG.mjs} +3 -3
  20. package/chunk-OFU2QEDR.mjs +163 -0
  21. package/editor/annotations/annotationController.js +1 -1
  22. package/editor/annotations/annotationController.js.map +2 -2
  23. package/editor/select-mode/EditorSelection.js +3 -15
  24. package/editor/select-mode/EditorSelection.js.map +2 -2
  25. package/editor/select-mode/fast-refresh-relay.js +2 -4
  26. package/editor/select-mode/fast-refresh-relay.js.map +2 -2
  27. package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +0 -4
  28. package/editor/select-mode/hooks/useEditModeStateMachine.js +76 -67
  29. package/editor/select-mode/hooks/useEditModeStateMachine.js.map +2 -2
  30. package/editor/select-mode/hooks/useParentMessaging.d.ts +6 -10
  31. package/editor/select-mode/hooks/useParentMessaging.js +43 -68
  32. package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
  33. package/editor/select-mode/hooks/useSelectModeController.js +5 -8
  34. package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
  35. package/editor/select-mode/hooks/useSelectionHover.js +4 -7
  36. package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
  37. package/editor/select-mode/hooks/useSelectionInteractions.js +14 -31
  38. package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
  39. package/editor/select-mode/hooks/useSelectionScrollSync.js +11 -18
  40. package/editor/select-mode/hooks/useSelectionScrollSync.js.map +2 -2
  41. package/editor/select-mode/iframeRpcChannel.d.ts +356 -0
  42. package/editor/select-mode/iframeRpcChannel.js +92 -0
  43. package/editor/select-mode/iframeRpcChannel.js.map +7 -0
  44. package/lib/canopy-error.js +1 -1
  45. package/lib/canopy-error.js.map +2 -2
  46. package/orders/order-status-schema.d.ts +161 -0
  47. package/orders/order-status-schema.js +83 -0
  48. package/orders/order-status-schema.js.map +7 -0
  49. package/orders/order-status.d.ts +11 -0
  50. package/orders/order-status.js +41 -0
  51. package/orders/order-status.js.map +7 -0
  52. package/package.json +9 -1
@@ -1,314 +1,5 @@
1
- import { parseJsonOrNull } from '../../chunk-VKO7P3ED.mjs';
2
- import { exhaustiveSwitch } from '../../chunk-UWHM3FKU.mjs';
1
+ export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeDefinedStyleSchema, selectModeFiberChainEntrySchema, selectModeFormatCommandSchema, selectModeInlineTextStatusSchema, selectModeOptimisticUpdatePayloadSchema, selectModeSelectionRectSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeStyleAtRuleSchema, selectModeStyleVariantSchema, selectModeTextMetricsSchema, selectModeTiptapActiveMarksSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData } from '../../chunk-7GWIUERW.mjs';
2
+ import '../../chunk-VKO7P3ED.mjs';
3
+ import '../../chunk-H36NDYLG.mjs';
3
4
  import '../../chunk-ILGEM42C.mjs';
4
5
  import '../../chunk-FNTGY7I5.mjs';
5
- import { z } from 'zod';
6
-
7
- // ../replo-utils/lib/parse.ts
8
- function parseSchemaOrNull(value, schema) {
9
- const parseResult = schema.safeParse(value);
10
- return parseResult.success ? parseResult.data : null;
11
- }
12
- var SELECT_MODE_SELECTABLE_ATTRIBUTE = "data-replo-selectable";
13
- var SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE = "data-replo-selectable-payload";
14
- var displayModeSchema = z.enum(["browse", "selection"]).describe("DisplayMode");
15
- var selectModeInlineTextStatusSchema = z.enum(["editable", "dynamic"]).nullable().describe("SelectModeInlineTextStatus");
16
- var selectModeTextMetricsSchema = z.object({
17
- tightWidth: z.number(),
18
- lineCount: z.number(),
19
- lineHeight: z.number()
20
- }).describe("SelectModeTextMetrics");
21
- var selectModeClickPositionSchema = z.object({
22
- x: z.number(),
23
- y: z.number()
24
- }).describe("SelectModeClickPosition");
25
- var selectModeSourceLocationSchema = z.object({
26
- filePath: z.string(),
27
- lineNumber: z.number(),
28
- columnNumber: z.number().optional(),
29
- componentName: z.string().optional()
30
- }).describe("SelectModeSourceLocation");
31
- var selectModeFiberChainEntrySchema = z.object({
32
- sourceLocation: selectModeSourceLocationSchema,
33
- tagName: z.string().optional(),
34
- componentName: z.string().optional(),
35
- props: z.record(z.string(), z.unknown()).optional()
36
- }).describe("SelectModeFiberChainEntry");
37
- var selectModeBoundingRectSchema = z.object({
38
- x: z.number(),
39
- y: z.number(),
40
- left: z.number(),
41
- top: z.number(),
42
- right: z.number(),
43
- bottom: z.number(),
44
- width: z.number(),
45
- height: z.number()
46
- }).describe("SelectModeBoundingRect");
47
- var selectModeSelectionRectSchema = z.object({
48
- id: z.string(),
49
- rect: selectModeBoundingRectSchema
50
- }).describe("SelectModeSelectionRect");
51
- var selectModeStyleAtRuleSchema = z.object({
52
- type: z.string(),
53
- text: z.string()
54
- }).describe("SelectModeStyleAtRule");
55
- var selectModeStyleVariantSchema = z.object({
56
- atRules: z.array(selectModeStyleAtRuleSchema),
57
- pseudo: z.string().nullable()
58
- }).describe("SelectModeStyleVariant");
59
- var selectModeDefinedStyleSchema = z.object({
60
- property: z.string(),
61
- variant: selectModeStyleVariantSchema.nullable(),
62
- className: z.string().nullable(),
63
- raw: z.string(),
64
- resolved: z.string()
65
- }).describe("SelectModeDefinedStyle");
66
- function transformRect({
67
- rect,
68
- offset
69
- }) {
70
- return {
71
- x: rect.x + offset.left,
72
- y: rect.y + offset.top,
73
- left: rect.left + offset.left,
74
- right: rect.right + offset.left,
75
- top: rect.top + offset.top,
76
- bottom: rect.bottom + offset.top,
77
- width: rect.width,
78
- height: rect.height
79
- };
80
- }
81
- function transformPoint({
82
- point,
83
- offset
84
- }) {
85
- return {
86
- x: point.x + offset.left,
87
- y: point.y + offset.top
88
- };
89
- }
90
- function getIframeOffset(iframe) {
91
- if (!iframe) {
92
- return { left: 0, top: 0 };
93
- }
94
- const iframeRect = iframe.getBoundingClientRect();
95
- return { left: iframeRect.left, top: iframeRect.top };
96
- }
97
- var selectedElementSchema = z.object({
98
- kind: z.literal("react-element"),
99
- selector: z.string(),
100
- tagName: z.string(),
101
- elementType: z.string(),
102
- textContent: z.string().nullable(),
103
- rect: selectModeBoundingRectSchema,
104
- textMetrics: selectModeTextMetricsSchema.nullable(),
105
- outerHTML: z.string(),
106
- definedStyles: z.array(selectModeDefinedStyleSchema).default([]),
107
- inheritedStyles: z.record(z.string(), z.string()).default({}),
108
- clickPosition: selectModeClickPositionSchema,
109
- sourceLocation: selectModeSourceLocationSchema.optional(),
110
- fiberChain: z.array(selectModeFiberChainEntrySchema).default([]),
111
- siblingSelectors: z.array(z.string()).default([])
112
- }).describe("SelectedElement");
113
- var selectablePlanDataSchema = z.object({
114
- kind: z.literal("plan"),
115
- planId: z.string(),
116
- label: z.string(),
117
- rect: selectModeBoundingRectSchema
118
- }).describe("SelectablePlanData");
119
- var selectablePlanPayloadSchema = selectablePlanDataSchema.omit({ rect: true }).describe("SelectablePlanPayload");
120
- var selectableDataPayloadSchema = z.discriminatedUnion("kind", [selectablePlanPayloadSchema]).describe("SelectableDataPayload");
121
- var selectableDataSchema = z.discriminatedUnion("kind", [selectedElementSchema, selectablePlanDataSchema]).describe("SelectableData");
122
- function transformSelectableData({
123
- data,
124
- offset
125
- }) {
126
- return exhaustiveSwitch(
127
- data,
128
- "kind"
129
- )({
130
- "react-element": (element) => ({
131
- ...element,
132
- rect: transformRect({ rect: element.rect, offset }),
133
- clickPosition: transformPoint({
134
- point: element.clickPosition,
135
- offset
136
- })
137
- }),
138
- plan: (plan) => ({
139
- ...plan,
140
- rect: transformRect({ rect: plan.rect, offset })
141
- })
142
- });
143
- }
144
- function readSelectablePayload(rawPayload) {
145
- if (!rawPayload) {
146
- return null;
147
- }
148
- const parsedPayload = parseJsonOrNull(rawPayload);
149
- if (!parsedPayload) {
150
- return null;
151
- }
152
- return parseSchemaOrNull(parsedPayload, selectableDataPayloadSchema);
153
- }
154
- var selectModeOptimisticUpdatePayloadSchema = z.discriminatedUnion("kind", [
155
- z.object({
156
- kind: z.literal("css"),
157
- property: z.string(),
158
- value: z.string().nullable()
159
- }),
160
- z.object({
161
- kind: z.literal("content"),
162
- innerHTML: z.string()
163
- }),
164
- z.object({
165
- kind: z.literal("attribute"),
166
- name: z.string(),
167
- value: z.string()
168
- })
169
- ]).describe("SelectModeOptimisticUpdatePayload");
170
- var selectModeTiptapActiveMarksSchema = z.object({
171
- bold: z.boolean(),
172
- italic: z.boolean(),
173
- underline: z.boolean(),
174
- strike: z.boolean()
175
- }).describe("SelectModeTiptapActiveMarks");
176
- var selectModeFormatCommandSchema = z.enum(["toggleBold", "toggleItalic", "toggleUnderline", "toggleStrike"]).describe("SelectModeFormatCommand");
177
- var selectModeSelectionTypeSchema = z.enum(["none", "element", "area", "drag"]).describe("SelectModeSelectionType");
178
- var selectModeSelectionSchema = z.discriminatedUnion("type", [
179
- z.object({ type: z.literal("none") }),
180
- z.object({
181
- type: z.literal("element"),
182
- data: selectableDataSchema
183
- }),
184
- z.object({
185
- type: z.literal("area"),
186
- rect: selectModeBoundingRectSchema,
187
- items: z.array(selectableDataSchema)
188
- }),
189
- z.object({
190
- type: z.literal("drag"),
191
- dragRect: selectModeBoundingRectSchema,
192
- // Bounding boxes of the selectables the drag currently intersects,
193
- // rendered as lighter highlights so the user can see what the drag
194
- // will capture before they release.
195
- selectionRects: z.array(selectModeSelectionRectSchema)
196
- })
197
- ]).describe("SelectModeSelection");
198
- var selectModeParentMessageSchema = z.discriminatedUnion("type", [
199
- z.object({
200
- type: z.literal("replo:select:setDisplayMode"),
201
- displayMode: displayModeSchema
202
- }),
203
- // Declarative push of the parent's current selection type into the
204
- // canopy iframe. Transitioning to `none` is canopy's signal to hide
205
- // its in-iframe selection frame and drop any in-progress drag —
206
- // there's no separate "clear" message because selection state always
207
- // flows through agentUiState.
208
- z.object({
209
- type: z.literal("replo:select:setSelectionType"),
210
- selectionType: selectModeSelectionTypeSchema
211
- }),
212
- z.object({
213
- type: z.literal("replo:select:applyOptimisticUpdate"),
214
- editId: z.string(),
215
- payload: selectModeOptimisticUpdatePayloadSchema,
216
- targetSelector: z.string(),
217
- targetMode: z.enum(["primary", "group"])
218
- }),
219
- z.object({
220
- type: z.literal("replo:select:markCommitted"),
221
- editId: z.string(),
222
- sessionId: z.string()
223
- }),
224
- z.object({
225
- type: z.literal("replo:select:resolveSessionOverrides"),
226
- sessionId: z.string(),
227
- outcome: z.enum(["persisted", "failed"])
228
- }),
229
- z.object({
230
- type: z.literal("replo:select:revertOverride"),
231
- editId: z.string()
232
- }),
233
- z.object({
234
- type: z.literal("replo:select:enterEditMode")
235
- }),
236
- z.object({
237
- type: z.literal("replo:select:exitEditMode")
238
- }),
239
- z.object({
240
- type: z.literal("replo:select:formatCommand"),
241
- command: selectModeFormatCommandSchema
242
- }),
243
- z.object({
244
- type: z.literal("replo:select:resolveEditRequest"),
245
- editId: z.string(),
246
- allowed: z.boolean()
247
- }),
248
- z.object({
249
- type: z.literal("replo:select:requestSymbolicate"),
250
- requestId: z.string(),
251
- element: selectedElementSchema
252
- })
253
- ]).describe("SelectModeParentMessage");
254
- var selectModeIframeMessageSchema = z.discriminatedUnion("type", [
255
- z.object({
256
- type: z.literal("replo:select:elementSelected"),
257
- data: selectableDataSchema
258
- }),
259
- z.object({
260
- type: z.literal("replo:select:hoverElement"),
261
- rect: selectModeBoundingRectSchema.nullable()
262
- }),
263
- z.object({
264
- type: z.literal("replo:select:iframeReady")
265
- }),
266
- z.object({
267
- type: z.literal("replo:select:selectedElementRectUpdate"),
268
- rect: selectModeBoundingRectSchema,
269
- clickPosition: selectModeClickPositionSchema
270
- }),
271
- z.object({
272
- type: z.literal("replo:select:selectedAreaRectUpdate"),
273
- rect: selectModeBoundingRectSchema
274
- }),
275
- z.object({
276
- type: z.literal("replo:select:dragRectUpdated"),
277
- dragRect: selectModeBoundingRectSchema.nullable(),
278
- selectionRects: z.array(selectModeSelectionRectSchema)
279
- }),
280
- z.object({
281
- type: z.literal("replo:select:areaSelected"),
282
- rect: selectModeBoundingRectSchema,
283
- items: z.array(selectableDataSchema)
284
- }),
285
- z.object({
286
- type: z.literal("replo:select:doubleClicked"),
287
- editId: z.string(),
288
- element: selectedElementSchema
289
- }),
290
- z.object({
291
- type: z.literal("replo:select:textCommitted"),
292
- editId: z.string(),
293
- html: z.string(),
294
- json: z.record(z.string(), z.unknown()),
295
- originalInnerHTML: z.string()
296
- }),
297
- z.object({
298
- type: z.literal("replo:select:editorStateUpdate"),
299
- activeMarks: selectModeTiptapActiveMarksSchema,
300
- // Whether an inline text edit is currently open. Lets the parent show the
301
- // inline formatting controls (and live mark state) only while editing.
302
- isEditing: z.boolean()
303
- }),
304
- z.object({
305
- type: z.literal("replo:select:fastRefreshComplete")
306
- }),
307
- z.object({
308
- type: z.literal("replo:select:symbolicateResult"),
309
- requestId: z.string(),
310
- element: selectedElementSchema
311
- })
312
- ]).describe("SelectModeIframeMessage");
313
-
314
- export { SELECT_MODE_SELECTABLE_ATTRIBUTE, SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE, displayModeSchema, getIframeOffset, readSelectablePayload, selectModeBoundingRectSchema, selectModeClickPositionSchema, selectModeDefinedStyleSchema, selectModeFiberChainEntrySchema, selectModeFormatCommandSchema, selectModeIframeMessageSchema, selectModeInlineTextStatusSchema, selectModeOptimisticUpdatePayloadSchema, selectModeParentMessageSchema, selectModeSelectionRectSchema, selectModeSelectionSchema, selectModeSelectionTypeSchema, selectModeSourceLocationSchema, selectModeStyleAtRuleSchema, selectModeStyleVariantSchema, selectModeTextMetricsSchema, selectModeTiptapActiveMarksSchema, selectableDataPayloadSchema, selectableDataSchema, selectablePlanDataSchema, selectablePlanPayloadSchema, selectedElementSchema, transformPoint, transformRect, transformSelectableData };