@replohq/canopy-sdk 1.3.3 → 2.1.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 (42) hide show
  1. package/_vendor/replo-utils/lib/log.d.ts +11 -0
  2. package/_vendor/replo-utils/react/use-iframe-rpc-channel.d.ts +14 -0
  3. package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +14 -0
  4. package/_vendor/schemas/errors.d.ts +36 -15
  5. package/_vendor/schemas/generated/selectMode.d.ts +0 -85
  6. package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +100 -0
  7. package/_vendor/schemas/generated/selectModeIframeRpc.mjs +1 -0
  8. package/_vendor/schemas/iframeRpcChannel.d.ts +82 -0
  9. package/_vendor/schemas/iframeRpcChannel.mjs +361 -0
  10. package/_vendor/schemas/money.mjs +1 -112
  11. package/_vendor/schemas/selectMode.d.ts +0 -496
  12. package/_vendor/schemas/selectMode.mjs +3 -312
  13. package/_vendor/schemas/selectModeIframeRpc.d.ts +900 -0
  14. package/_vendor/schemas/selectModeIframeRpc.mjs +225 -0
  15. package/chunk-OFU2QEDR.mjs +163 -0
  16. package/chunk-YFJHLP53.mjs +197 -0
  17. package/editor/annotations/annotationController.js +1 -1
  18. package/editor/annotations/annotationController.js.map +2 -2
  19. package/editor/select-mode/EditorSelection.js +3 -15
  20. package/editor/select-mode/EditorSelection.js.map +2 -2
  21. package/editor/select-mode/fast-refresh-relay.js +2 -4
  22. package/editor/select-mode/fast-refresh-relay.js.map +2 -2
  23. package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +0 -4
  24. package/editor/select-mode/hooks/useEditModeStateMachine.js +76 -67
  25. package/editor/select-mode/hooks/useEditModeStateMachine.js.map +2 -2
  26. package/editor/select-mode/hooks/useParentMessaging.d.ts +6 -10
  27. package/editor/select-mode/hooks/useParentMessaging.js +43 -68
  28. package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
  29. package/editor/select-mode/hooks/useSelectModeController.js +5 -8
  30. package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
  31. package/editor/select-mode/hooks/useSelectionHover.js +4 -7
  32. package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
  33. package/editor/select-mode/hooks/useSelectionInteractions.js +14 -31
  34. package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
  35. package/editor/select-mode/hooks/useSelectionScrollSync.js +11 -18
  36. package/editor/select-mode/hooks/useSelectionScrollSync.js.map +2 -2
  37. package/editor/select-mode/iframeRpcChannel.d.ts +356 -0
  38. package/editor/select-mode/iframeRpcChannel.js +92 -0
  39. package/editor/select-mode/iframeRpcChannel.js.map +7 -0
  40. package/lib/canopy-error.js +1 -1
  41. package/lib/canopy-error.js.map +2 -2
  42. package/package.json +172 -1
@@ -0,0 +1,225 @@
1
+ import { selectModeFormatCommandSchema, selectModeOptimisticUpdatePayloadSchema, selectModeSelectionTypeSchema, displayModeSchema, selectModeTiptapActiveMarksSchema, selectModeBoundingRectSchema, selectableDataSchema, selectModeSelectionRectSchema, selectModeClickPositionSchema, selectedElementSchema } from '../../chunk-YFJHLP53.mjs';
2
+ import '../../chunk-VKO7P3ED.mjs';
3
+ import '../../chunk-UWHM3FKU.mjs';
4
+ import '../../chunk-ILGEM42C.mjs';
5
+ import '../../chunk-FNTGY7I5.mjs';
6
+ import { z } from 'zod';
7
+
8
+ var SELECT_MODE_IFRAME_RPC_CHANNEL_ID = "replo:select-mode-iframe-rpc";
9
+ var SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION = 1;
10
+ var websiteBuilderToCanopyMethodConfig = {
11
+ symbolicateSelectedElement: {
12
+ inputSchema: selectedElementSchema,
13
+ outputSchema: selectedElementSchema,
14
+ timeoutMs: 1500
15
+ },
16
+ setDisplayMode: {
17
+ inputSchema: z.object({ displayMode: displayModeSchema }),
18
+ outputSchema: z.void()
19
+ },
20
+ // Declarative push of the parent's current selection type into the
21
+ // canopy iframe. Transitioning to `none` is canopy's signal to hide
22
+ // its in-iframe selection frame and drop any in-progress drag —
23
+ // there's no separate "clear" message because selection state always
24
+ // flows through agentUiState.
25
+ setSelectionType: {
26
+ inputSchema: z.object({ selectionType: selectModeSelectionTypeSchema }),
27
+ outputSchema: z.void()
28
+ },
29
+ applyOptimisticUpdate: {
30
+ inputSchema: z.object({
31
+ editId: z.string(),
32
+ payload: selectModeOptimisticUpdatePayloadSchema,
33
+ targetSelector: z.string(),
34
+ targetMode: z.enum(["primary", "group"])
35
+ }),
36
+ outputSchema: z.void()
37
+ },
38
+ markCommitted: {
39
+ inputSchema: z.object({
40
+ editId: z.string(),
41
+ sessionId: z.string()
42
+ }),
43
+ outputSchema: z.void()
44
+ },
45
+ resolveSessionOverrides: {
46
+ inputSchema: z.object({
47
+ sessionId: z.string(),
48
+ outcome: z.enum(["persisted", "failed"])
49
+ }),
50
+ outputSchema: z.void()
51
+ },
52
+ revertOverride: {
53
+ inputSchema: z.object({
54
+ editId: z.string()
55
+ }),
56
+ outputSchema: z.void()
57
+ },
58
+ enterEditMode: {
59
+ inputSchema: z.undefined(),
60
+ outputSchema: z.void()
61
+ },
62
+ exitEditMode: {
63
+ inputSchema: z.undefined(),
64
+ outputSchema: z.void()
65
+ },
66
+ formatCommand: {
67
+ inputSchema: z.object({
68
+ command: selectModeFormatCommandSchema
69
+ }),
70
+ outputSchema: z.void()
71
+ }
72
+ };
73
+ var canopyToWebsiteBuilderMethodConfig = {
74
+ requestInlineTextEdit: {
75
+ inputSchema: z.object({
76
+ editId: z.string(),
77
+ element: selectedElementSchema
78
+ }),
79
+ outputSchema: z.object({ allowed: z.boolean() }),
80
+ timeoutMs: 5e3
81
+ },
82
+ iframeReady: {
83
+ inputSchema: z.undefined(),
84
+ outputSchema: z.void()
85
+ },
86
+ elementSelected: {
87
+ inputSchema: z.object({
88
+ data: selectableDataSchema
89
+ }),
90
+ outputSchema: z.void()
91
+ },
92
+ hoverElement: {
93
+ inputSchema: z.object({
94
+ rect: selectModeBoundingRectSchema.nullable()
95
+ }),
96
+ outputSchema: z.void()
97
+ },
98
+ selectedElementRectUpdate: {
99
+ inputSchema: z.object({
100
+ rect: selectModeBoundingRectSchema,
101
+ clickPosition: selectModeClickPositionSchema
102
+ }),
103
+ outputSchema: z.void()
104
+ },
105
+ selectedAreaRectUpdate: {
106
+ inputSchema: z.object({
107
+ rect: selectModeBoundingRectSchema
108
+ }),
109
+ outputSchema: z.void()
110
+ },
111
+ dragRectUpdated: {
112
+ inputSchema: z.object({
113
+ dragRect: selectModeBoundingRectSchema.nullable(),
114
+ selectionRects: z.array(selectModeSelectionRectSchema)
115
+ }),
116
+ outputSchema: z.void()
117
+ },
118
+ areaSelected: {
119
+ inputSchema: z.object({
120
+ rect: selectModeBoundingRectSchema,
121
+ items: z.array(selectableDataSchema)
122
+ }),
123
+ outputSchema: z.void()
124
+ },
125
+ textCommitted: {
126
+ inputSchema: z.object({
127
+ editId: z.string(),
128
+ html: z.string(),
129
+ json: z.record(z.string(), z.unknown()),
130
+ originalInnerHTML: z.string()
131
+ }),
132
+ outputSchema: z.void()
133
+ },
134
+ editorStateUpdate: {
135
+ inputSchema: z.object({
136
+ activeMarks: selectModeTiptapActiveMarksSchema,
137
+ // Whether an inline text edit is currently open. Lets the parent show the
138
+ // inline formatting controls (and live mark state) only while editing.
139
+ isEditing: z.boolean()
140
+ }),
141
+ outputSchema: z.void()
142
+ },
143
+ fastRefreshComplete: {
144
+ inputSchema: z.undefined(),
145
+ outputSchema: z.void()
146
+ }
147
+ };
148
+ var selectModeParentMessageSchema = z.discriminatedUnion("method", [
149
+ z.object({
150
+ method: z.literal("setDisplayMode"),
151
+ data: websiteBuilderToCanopyMethodConfig.setDisplayMode.inputSchema
152
+ }),
153
+ z.object({
154
+ method: z.literal("setSelectionType"),
155
+ data: websiteBuilderToCanopyMethodConfig.setSelectionType.inputSchema
156
+ }),
157
+ z.object({
158
+ method: z.literal("applyOptimisticUpdate"),
159
+ data: websiteBuilderToCanopyMethodConfig.applyOptimisticUpdate.inputSchema
160
+ }),
161
+ z.object({
162
+ method: z.literal("markCommitted"),
163
+ data: websiteBuilderToCanopyMethodConfig.markCommitted.inputSchema
164
+ }),
165
+ z.object({
166
+ method: z.literal("resolveSessionOverrides"),
167
+ data: websiteBuilderToCanopyMethodConfig.resolveSessionOverrides.inputSchema
168
+ }),
169
+ z.object({
170
+ method: z.literal("revertOverride"),
171
+ data: websiteBuilderToCanopyMethodConfig.revertOverride.inputSchema
172
+ }),
173
+ z.object({
174
+ method: z.literal("enterEditMode")
175
+ }),
176
+ z.object({
177
+ method: z.literal("exitEditMode")
178
+ }),
179
+ z.object({
180
+ method: z.literal("formatCommand"),
181
+ data: websiteBuilderToCanopyMethodConfig.formatCommand.inputSchema
182
+ })
183
+ ]).describe("SelectModeParentMessage");
184
+ var selectModeIframeMessageSchema = z.discriminatedUnion("method", [
185
+ z.object({
186
+ method: z.literal("iframeReady")
187
+ }),
188
+ z.object({
189
+ method: z.literal("elementSelected"),
190
+ data: canopyToWebsiteBuilderMethodConfig.elementSelected.inputSchema
191
+ }),
192
+ z.object({
193
+ method: z.literal("hoverElement"),
194
+ data: canopyToWebsiteBuilderMethodConfig.hoverElement.inputSchema
195
+ }),
196
+ z.object({
197
+ method: z.literal("selectedElementRectUpdate"),
198
+ data: canopyToWebsiteBuilderMethodConfig.selectedElementRectUpdate.inputSchema
199
+ }),
200
+ z.object({
201
+ method: z.literal("selectedAreaRectUpdate"),
202
+ data: canopyToWebsiteBuilderMethodConfig.selectedAreaRectUpdate.inputSchema
203
+ }),
204
+ z.object({
205
+ method: z.literal("dragRectUpdated"),
206
+ data: canopyToWebsiteBuilderMethodConfig.dragRectUpdated.inputSchema
207
+ }),
208
+ z.object({
209
+ method: z.literal("areaSelected"),
210
+ data: canopyToWebsiteBuilderMethodConfig.areaSelected.inputSchema
211
+ }),
212
+ z.object({
213
+ method: z.literal("textCommitted"),
214
+ data: canopyToWebsiteBuilderMethodConfig.textCommitted.inputSchema
215
+ }),
216
+ z.object({
217
+ method: z.literal("editorStateUpdate"),
218
+ data: canopyToWebsiteBuilderMethodConfig.editorStateUpdate.inputSchema
219
+ }),
220
+ z.object({
221
+ method: z.literal("fastRefreshComplete")
222
+ })
223
+ ]).describe("SelectModeIframeMessage");
224
+
225
+ export { SELECT_MODE_IFRAME_RPC_CHANNEL_ID, SELECT_MODE_IFRAME_RPC_CHANNEL_VERSION, canopyToWebsiteBuilderMethodConfig, selectModeIframeMessageSchema, selectModeParentMessageSchema, websiteBuilderToCanopyMethodConfig };
@@ -0,0 +1,163 @@
1
+ import { v4 } from 'uuid';
2
+ import { z } from 'zod';
3
+
4
+ // ../replo-utils/lib/crypto.ts
5
+ function randomUUID() {
6
+ return v4();
7
+ }
8
+ var ReploError = class _ReploError extends Error {
9
+ config;
10
+ id;
11
+ constructor(config) {
12
+ super(config.message);
13
+ this.message = config.message ?? this.constructor.name;
14
+ this.config = config;
15
+ this.id = randomUUID();
16
+ const cause = config.cause;
17
+ if (cause) {
18
+ this.cause = cause;
19
+ if (cause instanceof _ReploError) {
20
+ this.config.additionalData = {
21
+ ...this.config.additionalData,
22
+ ...cause.config.additionalData
23
+ };
24
+ }
25
+ }
26
+ }
27
+ };
28
+ var errorUserFacingDetailsMessageSchema = z.object({
29
+ type: z.enum([
30
+ "toast",
31
+ "fullPageModal",
32
+ "shopifyStorePassword",
33
+ "billing.addPublishedElements",
34
+ "billing.addShopifyThemeProject",
35
+ "billing.addReploSite",
36
+ // Agent Billing ONLY
37
+ "agentBilling.shopifyThemeBuilder.publishedElements.exceeded",
38
+ "agentBilling.shopifyThemeBuilder.projects.exceeded",
39
+ "agentBilling.sites.exceeded",
40
+ "agentBilling.credits.exceeded",
41
+ "agentBilling.upgradeRequired"
42
+ ]),
43
+ message: z.string(),
44
+ isRecoverable: z.boolean().optional(),
45
+ // NOTE (Matt 2024-03-22): We support detail being an array of strings
46
+ // in FullPageModal only.
47
+ detail: z.array(z.string()).or(z.string()).optional(),
48
+ key: z.string(),
49
+ usage: z.object({
50
+ current: z.number(),
51
+ maximum: z.number()
52
+ }).optional(),
53
+ plan: z.string().optional(),
54
+ callToAction: z.discriminatedUnion("type", [
55
+ z.object({ type: z.literal("reload") }),
56
+ z.object({ type: z.literal("installApp") }),
57
+ z.object({ type: z.literal("goToHomepage") }),
58
+ z.object({ type: z.literal("navigateToProjectEditor") }),
59
+ z.object({ type: z.literal("closeModal") }),
60
+ z.object({
61
+ type: z.literal("navigateToLink"),
62
+ link: z.discriminatedUnion("type", [
63
+ z.object({ type: z.literal("errors.wrongJsonExtension") }),
64
+ z.object({ type: z.literal("errors.chunkingError") }),
65
+ z.object({ type: z.literal("errors.indexBackupError") }),
66
+ z.object({
67
+ type: z.literal("errors.shopifyIntegrationAlreadyAssigned")
68
+ }),
69
+ z.object({
70
+ type: z.literal("errors.shopifyIntegrationMissingAccessScopes"),
71
+ url: z.string()
72
+ }),
73
+ z.object({
74
+ type: z.literal("customLink"),
75
+ url: z.string()
76
+ }),
77
+ z.object({
78
+ type: z.literal(
79
+ "errors.projectConnectedToBillingIntegrationForShopifyWorkspace"
80
+ )
81
+ }),
82
+ z.object({ type: z.literal("errors.themeAssetSizeLimitExceeded") }),
83
+ z.object({ type: z.literal("errors.themeTotalSizeLimitExceeded") }),
84
+ z.object({
85
+ type: z.literal("errors.pageMetafieldDefinitionsChanged")
86
+ }),
87
+ z.object({ type: z.literal("settings.billing") })
88
+ ])
89
+ })
90
+ ]).optional()
91
+ }).describe("ErrorUserFacingDetailsWithMessage");
92
+ z.discriminatedUnion("type", [
93
+ /**
94
+ * Normal errors, show error UI depending on the type
95
+ */
96
+ errorUserFacingDetailsMessageSchema,
97
+ /**
98
+ * Errors which should be ignored by the frontend. This is uncommon, usually
99
+ * you want to show an error in the UI, and if you don't want to then you catch
100
+ * the error in your route.
101
+ */
102
+ z.object({
103
+ type: z.literal("uncommon_none"),
104
+ key: z.string(),
105
+ usage: z.object({
106
+ current: z.number(),
107
+ maximum: z.number()
108
+ }).optional(),
109
+ message: z.string().optional(),
110
+ isRecoverable: z.boolean().optional(),
111
+ detail: z.array(z.string()).or(z.string()).optional()
112
+ })
113
+ ]).describe("ErrorUserFacingDetails");
114
+ var IframeRpcChannelError = class extends ReploError {
115
+ };
116
+ var IframeRpcChannelTimeoutError = class extends IframeRpcChannelError {
117
+ constructor({ method, timeoutMs }) {
118
+ super({
119
+ message: `RPC method '${method}' timed out after ${timeoutMs}ms`,
120
+ additionalData: { method, timeoutMs }
121
+ });
122
+ }
123
+ };
124
+ var IframeRpcChannelRemoteError = class extends IframeRpcChannelError {
125
+ constructor({ method, message }) {
126
+ super({
127
+ message: `RPC method '${method}' failed: ${message}`,
128
+ additionalData: { method }
129
+ });
130
+ }
131
+ };
132
+ var IframeRpcChannelUnsubscribedError = class extends IframeRpcChannelError {
133
+ constructor({ method }) {
134
+ super({
135
+ message: `RPC was unsubscribed while '${method}' was pending`,
136
+ additionalData: { method }
137
+ });
138
+ }
139
+ };
140
+ var IframeRpcChannelUnknownMethodError = class extends IframeRpcChannelError {
141
+ constructor({ method }) {
142
+ super({
143
+ message: `Unknown RPC method '${method}'`,
144
+ additionalData: { method }
145
+ });
146
+ }
147
+ };
148
+ var IframeRpcChannelConfigurationError = class extends IframeRpcChannelError {
149
+ constructor({ message }) {
150
+ super({ message });
151
+ }
152
+ };
153
+ var IframeRpcChannelInvalidInputError = class extends IframeRpcChannelError {
154
+ constructor({ method, cause }) {
155
+ super({
156
+ message: `Invalid RPC input for '${method}': ${cause.message}`,
157
+ cause,
158
+ additionalData: { method }
159
+ });
160
+ }
161
+ };
162
+
163
+ export { IframeRpcChannelConfigurationError, IframeRpcChannelInvalidInputError, IframeRpcChannelRemoteError, IframeRpcChannelTimeoutError, IframeRpcChannelUnknownMethodError, IframeRpcChannelUnsubscribedError, ReploError, randomUUID };
@@ -0,0 +1,197 @@
1
+ import { parseJsonOrNull } from './chunk-VKO7P3ED.mjs';
2
+ import { exhaustiveSwitch } from './chunk-UWHM3FKU.mjs';
3
+ import { z } from 'zod';
4
+
5
+ // ../replo-utils/lib/parse.ts
6
+ function parseSchemaOrNull(value, schema) {
7
+ const parseResult = schema.safeParse(value);
8
+ return parseResult.success ? parseResult.data : null;
9
+ }
10
+ var SELECT_MODE_SELECTABLE_ATTRIBUTE = "data-replo-selectable";
11
+ var SELECT_MODE_SELECTABLE_PAYLOAD_ATTRIBUTE = "data-replo-selectable-payload";
12
+ var displayModeSchema = z.enum(["browse", "selection"]).describe("DisplayMode");
13
+ var selectModeInlineTextStatusSchema = z.enum(["editable", "dynamic"]).nullable().describe("SelectModeInlineTextStatus");
14
+ var selectModeTextMetricsSchema = z.object({
15
+ tightWidth: z.number(),
16
+ lineCount: z.number(),
17
+ lineHeight: z.number()
18
+ }).describe("SelectModeTextMetrics");
19
+ var selectModeClickPositionSchema = z.object({
20
+ x: z.number(),
21
+ y: z.number()
22
+ }).describe("SelectModeClickPosition");
23
+ var selectModeSourceLocationSchema = z.object({
24
+ filePath: z.string(),
25
+ lineNumber: z.number(),
26
+ columnNumber: z.number().optional(),
27
+ componentName: z.string().optional()
28
+ }).describe("SelectModeSourceLocation");
29
+ var selectModeFiberChainEntrySchema = z.object({
30
+ sourceLocation: selectModeSourceLocationSchema,
31
+ tagName: z.string().optional(),
32
+ componentName: z.string().optional(),
33
+ props: z.record(z.string(), z.unknown()).optional()
34
+ }).describe("SelectModeFiberChainEntry");
35
+ var selectModeBoundingRectSchema = z.object({
36
+ x: z.number(),
37
+ y: z.number(),
38
+ left: z.number(),
39
+ top: z.number(),
40
+ right: z.number(),
41
+ bottom: z.number(),
42
+ width: z.number(),
43
+ height: z.number()
44
+ }).describe("SelectModeBoundingRect");
45
+ var selectModeSelectionRectSchema = z.object({
46
+ id: z.string(),
47
+ rect: selectModeBoundingRectSchema
48
+ }).describe("SelectModeSelectionRect");
49
+ var selectModeStyleAtRuleSchema = z.object({
50
+ type: z.string(),
51
+ text: z.string()
52
+ }).describe("SelectModeStyleAtRule");
53
+ var selectModeStyleVariantSchema = z.object({
54
+ atRules: z.array(selectModeStyleAtRuleSchema),
55
+ pseudo: z.string().nullable()
56
+ }).describe("SelectModeStyleVariant");
57
+ var selectModeDefinedStyleSchema = z.object({
58
+ property: z.string(),
59
+ variant: selectModeStyleVariantSchema.nullable(),
60
+ className: z.string().nullable(),
61
+ raw: z.string(),
62
+ resolved: z.string()
63
+ }).describe("SelectModeDefinedStyle");
64
+ function transformRect({
65
+ rect,
66
+ offset
67
+ }) {
68
+ return {
69
+ x: rect.x + offset.left,
70
+ y: rect.y + offset.top,
71
+ left: rect.left + offset.left,
72
+ right: rect.right + offset.left,
73
+ top: rect.top + offset.top,
74
+ bottom: rect.bottom + offset.top,
75
+ width: rect.width,
76
+ height: rect.height
77
+ };
78
+ }
79
+ function transformPoint({
80
+ point,
81
+ offset
82
+ }) {
83
+ return {
84
+ x: point.x + offset.left,
85
+ y: point.y + offset.top
86
+ };
87
+ }
88
+ function getIframeOffset(iframe) {
89
+ if (!iframe) {
90
+ return { left: 0, top: 0 };
91
+ }
92
+ const iframeRect = iframe.getBoundingClientRect();
93
+ return { left: iframeRect.left, top: iframeRect.top };
94
+ }
95
+ var selectedElementSchema = z.object({
96
+ kind: z.literal("react-element"),
97
+ selector: z.string(),
98
+ tagName: z.string(),
99
+ elementType: z.string(),
100
+ textContent: z.string().nullable(),
101
+ rect: selectModeBoundingRectSchema,
102
+ textMetrics: selectModeTextMetricsSchema.nullable(),
103
+ outerHTML: z.string(),
104
+ definedStyles: z.array(selectModeDefinedStyleSchema).default([]),
105
+ inheritedStyles: z.record(z.string(), z.string()).default({}),
106
+ clickPosition: selectModeClickPositionSchema,
107
+ sourceLocation: selectModeSourceLocationSchema.optional(),
108
+ fiberChain: z.array(selectModeFiberChainEntrySchema).default([]),
109
+ siblingSelectors: z.array(z.string()).default([])
110
+ }).describe("SelectedElement");
111
+ var selectablePlanDataSchema = z.object({
112
+ kind: z.literal("plan"),
113
+ planId: z.string(),
114
+ label: z.string(),
115
+ rect: selectModeBoundingRectSchema
116
+ }).describe("SelectablePlanData");
117
+ var selectablePlanPayloadSchema = selectablePlanDataSchema.omit({ rect: true }).describe("SelectablePlanPayload");
118
+ var selectableDataPayloadSchema = z.discriminatedUnion("kind", [selectablePlanPayloadSchema]).describe("SelectableDataPayload");
119
+ var selectableDataSchema = z.discriminatedUnion("kind", [selectedElementSchema, selectablePlanDataSchema]).describe("SelectableData");
120
+ function transformSelectableData({
121
+ data,
122
+ offset
123
+ }) {
124
+ return exhaustiveSwitch(
125
+ data,
126
+ "kind"
127
+ )({
128
+ "react-element": (element) => ({
129
+ ...element,
130
+ rect: transformRect({ rect: element.rect, offset }),
131
+ clickPosition: transformPoint({
132
+ point: element.clickPosition,
133
+ offset
134
+ })
135
+ }),
136
+ plan: (plan) => ({
137
+ ...plan,
138
+ rect: transformRect({ rect: plan.rect, offset })
139
+ })
140
+ });
141
+ }
142
+ function readSelectablePayload(rawPayload) {
143
+ if (!rawPayload) {
144
+ return null;
145
+ }
146
+ const parsedPayload = parseJsonOrNull(rawPayload);
147
+ if (!parsedPayload) {
148
+ return null;
149
+ }
150
+ return parseSchemaOrNull(parsedPayload, selectableDataPayloadSchema);
151
+ }
152
+ var selectModeOptimisticUpdatePayloadSchema = z.discriminatedUnion("kind", [
153
+ z.object({
154
+ kind: z.literal("css"),
155
+ property: z.string(),
156
+ value: z.string().nullable()
157
+ }),
158
+ z.object({
159
+ kind: z.literal("content"),
160
+ innerHTML: z.string()
161
+ }),
162
+ z.object({
163
+ kind: z.literal("attribute"),
164
+ name: z.string(),
165
+ value: z.string()
166
+ })
167
+ ]).describe("SelectModeOptimisticUpdatePayload");
168
+ var selectModeTiptapActiveMarksSchema = z.object({
169
+ bold: z.boolean(),
170
+ italic: z.boolean(),
171
+ underline: z.boolean(),
172
+ strike: z.boolean()
173
+ }).describe("SelectModeTiptapActiveMarks");
174
+ var selectModeFormatCommandSchema = z.enum(["toggleBold", "toggleItalic", "toggleUnderline", "toggleStrike"]).describe("SelectModeFormatCommand");
175
+ var selectModeSelectionTypeSchema = z.enum(["none", "element", "area", "drag"]).describe("SelectModeSelectionType");
176
+ var selectModeSelectionSchema = z.discriminatedUnion("type", [
177
+ z.object({ type: z.literal("none") }),
178
+ z.object({
179
+ type: z.literal("element"),
180
+ data: selectableDataSchema
181
+ }),
182
+ z.object({
183
+ type: z.literal("area"),
184
+ rect: selectModeBoundingRectSchema,
185
+ items: z.array(selectableDataSchema)
186
+ }),
187
+ z.object({
188
+ type: z.literal("drag"),
189
+ dragRect: selectModeBoundingRectSchema,
190
+ // Bounding boxes of the selectables the drag currently intersects,
191
+ // rendered as lighter highlights so the user can see what the drag
192
+ // will capture before they release.
193
+ selectionRects: z.array(selectModeSelectionRectSchema)
194
+ })
195
+ ]).describe("SelectModeSelection");
196
+
197
+ 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 };
@@ -148,7 +148,7 @@ function buildMemberSpec({
148
148
  member,
149
149
  badgeCenter
150
150
  }) {
151
- const { marker } = member;
151
+ const marker = member.marker;
152
152
  return {
153
153
  id: marker.id,
154
154
  pageRect: member.rect,