@replohq/canopy-sdk 0.11.1 → 0.13.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.
- package/_vendor/replo-utils/lib/misc.d.ts +18 -1
- package/_vendor/replo-utils/lib/misc.mjs +1 -1
- package/_vendor/schemas/designLibrary.d.ts +4 -4
- package/_vendor/schemas/errors.mjs +1 -1
- package/_vendor/schemas/generated/selectMode.d.ts +102 -0
- package/_vendor/schemas/savedStyles.d.ts +2 -2
- package/_vendor/schemas/selectMode.d.ts +471 -0
- package/_vendor/schemas/selectMode.mjs +119 -3
- package/{chunk-RUJDCFMG.mjs → chunk-OCB5XQYL.mjs} +1 -1
- package/editor/LinkInterceptor.js +4 -0
- package/editor/LinkInterceptor.js.map +2 -2
- package/editor/select-mode/EditorSelection.js +74 -1
- package/editor/select-mode/EditorSelection.js.map +2 -2
- package/editor/select-mode/descriptor/elementDescriptor.d.ts +13 -2
- package/editor/select-mode/descriptor/elementDescriptor.js +19 -31
- package/editor/select-mode/descriptor/elementDescriptor.js.map +2 -2
- package/editor/select-mode/descriptor/styleExtraction.d.ts +3 -0
- package/editor/select-mode/descriptor/styleExtraction.js +271 -0
- package/editor/select-mode/descriptor/styleExtraction.js.map +7 -0
- package/editor/select-mode/displayModeStore.d.ts +10 -0
- package/editor/select-mode/displayModeStore.js +47 -0
- package/editor/select-mode/displayModeStore.js.map +7 -0
- package/editor/select-mode/fast-refresh-relay.d.ts +3 -0
- package/editor/select-mode/fast-refresh-relay.js +35 -0
- package/editor/select-mode/fast-refresh-relay.js.map +7 -0
- package/editor/select-mode/fiber.d.ts +17 -0
- package/editor/select-mode/fiber.js +103 -34
- package/editor/select-mode/fiber.js.map +2 -2
- package/editor/select-mode/hooks/useEditModeStateMachine.d.ts +20 -0
- package/editor/select-mode/hooks/useEditModeStateMachine.js +226 -0
- package/editor/select-mode/hooks/useEditModeStateMachine.js.map +7 -0
- package/editor/select-mode/hooks/useOptimisticOverrides.d.ts +20 -0
- package/editor/select-mode/hooks/useOptimisticOverrides.js +284 -0
- package/editor/select-mode/hooks/useOptimisticOverrides.js.map +7 -0
- package/editor/select-mode/hooks/useParentMessaging.d.ts +17 -2
- package/editor/select-mode/hooks/useParentMessaging.js +66 -1
- package/editor/select-mode/hooks/useParentMessaging.js.map +2 -2
- package/editor/select-mode/hooks/useSelectModeController.js +5 -6
- package/editor/select-mode/hooks/useSelectModeController.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionHover.js +16 -1
- package/editor/select-mode/hooks/useSelectionHover.js.map +2 -2
- package/editor/select-mode/hooks/useSelectionInteractions.d.ts +7 -2
- package/editor/select-mode/hooks/useSelectionInteractions.js +57 -18
- package/editor/select-mode/hooks/useSelectionInteractions.js.map +2 -2
- package/editor/select-mode/hooks/useSiblingResolution.d.ts +6 -0
- package/editor/select-mode/hooks/useSiblingResolution.js +59 -0
- package/editor/select-mode/hooks/useSiblingResolution.js.map +7 -0
- package/editor/select-mode/inlineTextMarks.d.ts +6 -0
- package/editor/select-mode/inlineTextMarks.js +25 -0
- package/editor/select-mode/inlineTextMarks.js.map +7 -0
- package/editor/select-mode/interactions/selectionGeometry.js +4 -0
- package/editor/select-mode/interactions/selectionGeometry.js.map +2 -2
- package/editor/select-mode/selectionFrame.d.ts +5 -0
- package/editor/select-mode/selectionFrame.js +25 -1
- package/editor/select-mode/selectionFrame.js.map +2 -2
- package/editor/select-mode/symbolicate.js +32 -10
- package/editor/select-mode/symbolicate.js.map +2 -2
- package/editor/select-mode/tiptapInlineEditor.d.ts +23 -0
- package/editor/select-mode/tiptapInlineEditor.js +120 -0
- package/editor/select-mode/tiptapInlineEditor.js.map +7 -0
- package/next/config.js +11 -9
- package/next/config.js.map +2 -2
- package/package.json +9 -1
|
@@ -17,14 +17,19 @@ type StructureRecord<UnionType extends {
|
|
|
17
17
|
}, ResultType> = {
|
|
18
18
|
[MemberType in UnionType as MemberType["type"]]: ResultType | ((value: MemberType) => ResultType);
|
|
19
19
|
};
|
|
20
|
+
type StructureRecordBareString<UnionType extends string, ResultType> = {
|
|
21
|
+
[MemberType in UnionType]: ResultType | ((value: MemberType) => ResultType);
|
|
22
|
+
};
|
|
20
23
|
type StructureRecordGeneric<UnionType extends Record<KeyType, string>, ResultType, KeyType extends keyof UnionType> = {
|
|
21
24
|
[MemberType in UnionType as MemberType[KeyType]]: ResultType | ((value: MemberType) => ResultType);
|
|
22
25
|
};
|
|
23
26
|
/**
|
|
24
27
|
* @returns A function which can be used to create an exhaustive switch over all
|
|
25
|
-
* types of a discriminated union, based on a given key
|
|
28
|
+
* types of a discriminated union, based on a given key, or over all members of
|
|
29
|
+
* a bare string union.
|
|
26
30
|
*
|
|
27
31
|
* When no key is provided, it defaults to using "type" as the discriminant.
|
|
32
|
+
* When the value is a bare string union, the value is its own discriminant.
|
|
28
33
|
*
|
|
29
34
|
* Examples:
|
|
30
35
|
*
|
|
@@ -52,6 +57,17 @@ type StructureRecordGeneric<UnionType extends Record<KeyType, string>, ResultTyp
|
|
|
52
57
|
* }) // type of result is inferred to be string
|
|
53
58
|
* ```
|
|
54
59
|
*
|
|
60
|
+
* With a bare string union:
|
|
61
|
+
* ```
|
|
62
|
+
* type OneOrTwo = "one" | "two"
|
|
63
|
+
*
|
|
64
|
+
* let oneOrTwo = ...
|
|
65
|
+
* let result = exhaustiveSwitch(oneOrTwo)({
|
|
66
|
+
* one: 1, // cases can be plain values...
|
|
67
|
+
* two: () => 1 + 1, // ...or functions, evaluated lazily
|
|
68
|
+
* }) // type of result is inferred to be number
|
|
69
|
+
* ```
|
|
70
|
+
*
|
|
55
71
|
* Typescript will error if you forget a case, or if you assume the wrong type
|
|
56
72
|
* for a case value. The switch also returns the value you return from the
|
|
57
73
|
* function mapping, so it works well for "extension" methods where you want to
|
|
@@ -59,6 +75,7 @@ type StructureRecordGeneric<UnionType extends Record<KeyType, string>, ResultTyp
|
|
|
59
75
|
*
|
|
60
76
|
* Works well for many of our types, like ComponentActionType, Action, etc
|
|
61
77
|
*/
|
|
78
|
+
export declare function exhaustiveSwitch<UnionType extends string>(value: UnionType): <ResultType>(cases: StructureRecordBareString<UnionType, ResultType>) => ResultType;
|
|
62
79
|
export declare function exhaustiveSwitch<UnionType extends {
|
|
63
80
|
type: string;
|
|
64
81
|
}>(value: UnionType): <ResultType>(cases: StructureRecord<UnionType, ResultType>) => ResultType;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isFunction_default as isFunction, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning } from '../../../chunk-
|
|
1
|
+
export { coerceNumberToString, deepCloneAndMergeReplacingArrays, errorMessage, exhaustiveSwitch, formatFileSize, getFromRecordOrNull, hasOwnProperty, invariant, isEmpty, isFunction_default as isFunction, isNotNullish, isNullish, isPrimitive, mergeReplacingArrays, mergeReplacingObjects, noop, preventDefault, sleep, warning } from '../../../chunk-OCB5XQYL.mjs';
|
|
2
2
|
export { isNumber_default as isNumber, isString_default as isString } from '../../../chunk-ILGEM42C.mjs';
|
|
3
3
|
import '../../../chunk-FNTGY7I5.mjs';
|
|
@@ -57,9 +57,9 @@ export declare const savedTextStyleSchema: z.ZodObject<{
|
|
|
57
57
|
}>>;
|
|
58
58
|
textDecoration: z.ZodOptional<z.ZodEnum<{
|
|
59
59
|
none: "none";
|
|
60
|
+
italic: "italic";
|
|
60
61
|
underline: "underline";
|
|
61
62
|
"line-through": "line-through";
|
|
62
|
-
italic: "italic";
|
|
63
63
|
}>>;
|
|
64
64
|
textShadow: z.ZodOptional<z.ZodString>;
|
|
65
65
|
textStroke: z.ZodOptional<z.ZodString>;
|
|
@@ -131,9 +131,9 @@ export declare const designLibrarySavedStylesSchema: z.ZodRecord<z.ZodString, z.
|
|
|
131
131
|
}>>;
|
|
132
132
|
textDecoration: z.ZodOptional<z.ZodEnum<{
|
|
133
133
|
none: "none";
|
|
134
|
+
italic: "italic";
|
|
134
135
|
underline: "underline";
|
|
135
136
|
"line-through": "line-through";
|
|
136
|
-
italic: "italic";
|
|
137
137
|
}>>;
|
|
138
138
|
textShadow: z.ZodOptional<z.ZodString>;
|
|
139
139
|
textStroke: z.ZodOptional<z.ZodString>;
|
|
@@ -210,9 +210,9 @@ export declare const designLibrarySchema: z.ZodObject<{
|
|
|
210
210
|
}>>;
|
|
211
211
|
textDecoration: z.ZodOptional<z.ZodEnum<{
|
|
212
212
|
none: "none";
|
|
213
|
+
italic: "italic";
|
|
213
214
|
underline: "underline";
|
|
214
215
|
"line-through": "line-through";
|
|
215
|
-
italic: "italic";
|
|
216
216
|
}>>;
|
|
217
217
|
textShadow: z.ZodOptional<z.ZodString>;
|
|
218
218
|
textStroke: z.ZodOptional<z.ZodString>;
|
|
@@ -287,9 +287,9 @@ export declare const designLibrarySavedStyleMetadataSchema: z.ZodObject<{
|
|
|
287
287
|
}>>;
|
|
288
288
|
textDecoration: z.ZodOptional<z.ZodEnum<{
|
|
289
289
|
none: "none";
|
|
290
|
+
italic: "italic";
|
|
290
291
|
underline: "underline";
|
|
291
292
|
"line-through": "line-through";
|
|
292
|
-
italic: "italic";
|
|
293
293
|
}>>;
|
|
294
294
|
textShadow: z.ZodOptional<z.ZodString>;
|
|
295
295
|
textStroke: z.ZodOptional<z.ZodString>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isSymbol_default, toString_default } from '../../chunk-QFYIXADC.mjs';
|
|
2
|
-
import { MapCache_default, exhaustiveSwitch, hasOwnProperty, identity_default, baseFor_default, keys_default, Stack_default, isLength_default, isIndex_default, isArguments_default, getTag_default, isBuffer_default, isTypedArray_default, eq_default, Uint8Array_default, getAllKeys_default, baseAssignValue_default } from '../../chunk-
|
|
2
|
+
import { MapCache_default, exhaustiveSwitch, hasOwnProperty, identity_default, baseFor_default, keys_default, Stack_default, isLength_default, isIndex_default, isArguments_default, getTag_default, isBuffer_default, isTypedArray_default, eq_default, Uint8Array_default, getAllKeys_default, baseAssignValue_default } from '../../chunk-OCB5XQYL.mjs';
|
|
3
3
|
import { isObject_default } from '../../chunk-ILGEM42C.mjs';
|
|
4
4
|
import { Symbol_default, isArray_default, isObjectLike_default } from '../../chunk-FNTGY7I5.mjs';
|
|
5
5
|
import { z, ZodError } from 'zod';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export type DisplayMode = "browse" | "selection";
|
|
2
2
|
export type SelectModeSelectionType = "none" | "element" | "area" | "drag";
|
|
3
|
+
export type SelectModeInlineTextStatus = "editable" | "dynamic" | null;
|
|
3
4
|
export type SelectModeTextMetrics = {
|
|
4
5
|
tightWidth: number;
|
|
5
6
|
lineCount: number;
|
|
@@ -15,6 +16,14 @@ export type SelectModeSourceLocation = {
|
|
|
15
16
|
columnNumber?: number;
|
|
16
17
|
componentName?: string;
|
|
17
18
|
};
|
|
19
|
+
export type SelectModeFiberChainEntry = {
|
|
20
|
+
sourceLocation: SelectModeSourceLocation;
|
|
21
|
+
tagName?: string;
|
|
22
|
+
componentName?: string;
|
|
23
|
+
props?: {
|
|
24
|
+
[x: string]: unknown;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
18
27
|
export type SelectModeBoundingRect = {
|
|
19
28
|
x: number;
|
|
20
29
|
y: number;
|
|
@@ -29,6 +38,21 @@ export type SelectModeSelectionRect = {
|
|
|
29
38
|
id: string;
|
|
30
39
|
rect: SelectModeBoundingRect;
|
|
31
40
|
};
|
|
41
|
+
export type SelectModeStyleAtRule = {
|
|
42
|
+
type: string;
|
|
43
|
+
text: string;
|
|
44
|
+
};
|
|
45
|
+
export type SelectModeStyleVariant = {
|
|
46
|
+
atRules: SelectModeStyleAtRule[];
|
|
47
|
+
pseudo: string | null;
|
|
48
|
+
};
|
|
49
|
+
export type SelectModeDefinedStyle = {
|
|
50
|
+
property: string;
|
|
51
|
+
variant: SelectModeStyleVariant | null;
|
|
52
|
+
className: string | null;
|
|
53
|
+
raw: string;
|
|
54
|
+
resolved: string;
|
|
55
|
+
};
|
|
32
56
|
export type SelectedElement = {
|
|
33
57
|
kind: "react-element";
|
|
34
58
|
selector: string;
|
|
@@ -38,8 +62,14 @@ export type SelectedElement = {
|
|
|
38
62
|
rect: SelectModeBoundingRect;
|
|
39
63
|
textMetrics: SelectModeTextMetrics | null;
|
|
40
64
|
outerHTML: string;
|
|
65
|
+
definedStyles: SelectModeDefinedStyle[];
|
|
66
|
+
inheritedStyles: {
|
|
67
|
+
[x: string]: string;
|
|
68
|
+
};
|
|
41
69
|
clickPosition: SelectModeClickPosition;
|
|
42
70
|
sourceLocation?: SelectModeSourceLocation;
|
|
71
|
+
fiberChain: SelectModeFiberChainEntry[];
|
|
72
|
+
siblingSelectors: string[];
|
|
43
73
|
};
|
|
44
74
|
export type SelectablePlanData = {
|
|
45
75
|
kind: "plan";
|
|
@@ -54,6 +84,25 @@ export type SelectablePlanPayload = {
|
|
|
54
84
|
};
|
|
55
85
|
export type SelectableDataPayload = SelectablePlanPayload;
|
|
56
86
|
export type SelectableData = SelectedElement | SelectablePlanData;
|
|
87
|
+
export type SelectModeOptimisticUpdatePayload = {
|
|
88
|
+
kind: "css";
|
|
89
|
+
property: string;
|
|
90
|
+
value: string | null;
|
|
91
|
+
} | {
|
|
92
|
+
kind: "content";
|
|
93
|
+
innerHTML: string;
|
|
94
|
+
} | {
|
|
95
|
+
kind: "attribute";
|
|
96
|
+
name: string;
|
|
97
|
+
value: string;
|
|
98
|
+
};
|
|
99
|
+
export type SelectModeTiptapActiveMarks = {
|
|
100
|
+
bold: boolean;
|
|
101
|
+
italic: boolean;
|
|
102
|
+
underline: boolean;
|
|
103
|
+
strike: boolean;
|
|
104
|
+
};
|
|
105
|
+
export type SelectModeFormatCommand = "toggleBold" | "toggleItalic" | "toggleUnderline" | "toggleStrike";
|
|
57
106
|
export type SelectModeSelection = {
|
|
58
107
|
type: "none";
|
|
59
108
|
} | {
|
|
@@ -74,6 +123,37 @@ export type SelectModeParentMessage = {
|
|
|
74
123
|
} | {
|
|
75
124
|
type: "replo:select:setSelectionType";
|
|
76
125
|
selectionType: SelectModeSelectionType;
|
|
126
|
+
} | {
|
|
127
|
+
type: "replo:select:applyOptimisticUpdate";
|
|
128
|
+
editId: string;
|
|
129
|
+
payload: SelectModeOptimisticUpdatePayload;
|
|
130
|
+
targetMode: "primary" | "group";
|
|
131
|
+
} | {
|
|
132
|
+
type: "replo:select:markCommitted";
|
|
133
|
+
editId: string;
|
|
134
|
+
sessionId: string;
|
|
135
|
+
} | {
|
|
136
|
+
type: "replo:select:resolveSessionOverrides";
|
|
137
|
+
sessionId: string;
|
|
138
|
+
outcome: "persisted" | "failed";
|
|
139
|
+
} | {
|
|
140
|
+
type: "replo:select:revertOverride";
|
|
141
|
+
editId: string;
|
|
142
|
+
} | {
|
|
143
|
+
type: "replo:select:enterEditMode";
|
|
144
|
+
} | {
|
|
145
|
+
type: "replo:select:exitEditMode";
|
|
146
|
+
} | {
|
|
147
|
+
type: "replo:select:formatCommand";
|
|
148
|
+
command: SelectModeFormatCommand;
|
|
149
|
+
} | {
|
|
150
|
+
type: "replo:select:resolveEditRequest";
|
|
151
|
+
editId: string;
|
|
152
|
+
allowed: boolean;
|
|
153
|
+
} | {
|
|
154
|
+
type: "replo:select:requestSymbolicate";
|
|
155
|
+
requestId: string;
|
|
156
|
+
element: SelectedElement;
|
|
77
157
|
};
|
|
78
158
|
export type SelectModeIframeMessage = {
|
|
79
159
|
type: "replo:select:elementSelected";
|
|
@@ -98,4 +178,26 @@ export type SelectModeIframeMessage = {
|
|
|
98
178
|
type: "replo:select:areaSelected";
|
|
99
179
|
rect: SelectModeBoundingRect;
|
|
100
180
|
items: SelectableData[];
|
|
181
|
+
} | {
|
|
182
|
+
type: "replo:select:doubleClicked";
|
|
183
|
+
editId: string;
|
|
184
|
+
element: SelectedElement;
|
|
185
|
+
} | {
|
|
186
|
+
type: "replo:select:textCommitted";
|
|
187
|
+
editId: string;
|
|
188
|
+
html: string;
|
|
189
|
+
json: {
|
|
190
|
+
[x: string]: unknown;
|
|
191
|
+
};
|
|
192
|
+
originalInnerHTML: string;
|
|
193
|
+
} | {
|
|
194
|
+
type: "replo:select:editorStateUpdate";
|
|
195
|
+
activeMarks: SelectModeTiptapActiveMarks;
|
|
196
|
+
isEditing: boolean;
|
|
197
|
+
} | {
|
|
198
|
+
type: "replo:select:fastRefreshComplete";
|
|
199
|
+
} | {
|
|
200
|
+
type: "replo:select:symbolicateResult";
|
|
201
|
+
requestId: string;
|
|
202
|
+
element: SelectedElement;
|
|
101
203
|
};
|
|
@@ -65,9 +65,9 @@ export declare const savedStyleTextAttributesSchema: z.ZodObject<{
|
|
|
65
65
|
}>>;
|
|
66
66
|
textDecoration: z.ZodOptional<z.ZodEnum<{
|
|
67
67
|
none: "none";
|
|
68
|
+
italic: "italic";
|
|
68
69
|
underline: "underline";
|
|
69
70
|
"line-through": "line-through";
|
|
70
|
-
italic: "italic";
|
|
71
71
|
}>>;
|
|
72
72
|
textShadow: z.ZodOptional<z.ZodString>;
|
|
73
73
|
textStroke: z.ZodOptional<z.ZodString>;
|
|
@@ -125,9 +125,9 @@ export declare const savedStyleAttributesSchema: z.ZodDiscriminatedUnion<[z.ZodO
|
|
|
125
125
|
}>>;
|
|
126
126
|
textDecoration: z.ZodOptional<z.ZodEnum<{
|
|
127
127
|
none: "none";
|
|
128
|
+
italic: "italic";
|
|
128
129
|
underline: "underline";
|
|
129
130
|
"line-through": "line-through";
|
|
130
|
-
italic: "italic";
|
|
131
131
|
}>>;
|
|
132
132
|
textShadow: z.ZodOptional<z.ZodString>;
|
|
133
133
|
textStroke: z.ZodOptional<z.ZodString>;
|