@replohq/canopy-sdk 3.0.5 → 3.0.7
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/crypto.d.ts +8 -0
- package/_vendor/replo-utils/lib/errors.d.ts +1 -0
- package/_vendor/replo-utils/lib/fonts.d.ts +12 -1
- package/_vendor/replo-utils/lib/fonts.mjs +61 -12
- package/_vendor/replo-utils/lib/geometry.mjs +0 -2
- package/_vendor/replo-utils/lib/json.d.ts +0 -4
- package/_vendor/replo-utils/lib/json.mjs +1 -4
- package/_vendor/replo-utils/lib/misc.d.ts +4 -0
- package/_vendor/replo-utils/lib/misc.mjs +2 -4
- package/_vendor/replo-utils/lib/posthogReplay.mjs +0 -2
- package/_vendor/replo-utils/lib/string.d.ts +0 -12
- package/_vendor/replo-utils/lib/url.d.ts +10 -3
- package/_vendor/replo-utils/lib/url.mjs +3 -4
- package/_vendor/replo-utils/react/use-iframe-rpc-channel.mjs +0 -1
- package/_vendor/schemas/agentBillingFeatureType.d.ts +1 -0
- package/_vendor/schemas/comments.d.ts +932 -0
- package/_vendor/schemas/designLibrary.d.ts +24 -1
- package/_vendor/schemas/designLibrary.mjs +76 -70
- package/_vendor/schemas/errors.d.ts +50 -45
- package/_vendor/schemas/generated/comments.d.ts +244 -0
- package/_vendor/schemas/generated/consent.d.ts +43 -2
- package/_vendor/schemas/generated/errors.d.ts +1 -0
- package/_vendor/schemas/generated/selectMode.d.ts +52 -1
- package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +64 -8
- package/_vendor/schemas/iframeRpcChannel.d.ts +13 -1
- package/_vendor/schemas/iframeRpcChannel.mjs +202 -19
- package/_vendor/schemas/loaderKeys.mjs +2 -4
- package/_vendor/schemas/{money.d.ts → moneyFormat.d.ts} +11 -9
- package/_vendor/schemas/moneyFormat.mjs +119 -0
- package/_vendor/schemas/pageAnnotations.d.ts +1 -1
- package/_vendor/schemas/pageAnnotations.mjs +1 -2
- package/_vendor/schemas/reploError.d.ts +43 -0
- package/_vendor/schemas/routing/match.mjs +0 -1
- package/_vendor/schemas/routing/rules.d.ts +2 -2
- package/_vendor/schemas/routing/rules.mjs +5 -8
- package/_vendor/schemas/savedStyles.d.ts +1 -1
- package/_vendor/schemas/selectMode.d.ts +272 -4
- package/_vendor/schemas/selectMode.mjs +4 -6
- package/_vendor/schemas/selectModeIframeRpc.d.ts +802 -111
- package/_vendor/schemas/selectModeIframeRpc.mjs +142 -47
- package/chunk-B7XDEXPL.mjs +19 -0
- package/chunk-CJIK4NVP.mjs +547 -0
- package/chunk-DINTPZM2.mjs +71 -0
- package/{chunk-AKZNN7F2.mjs → chunk-IQCJXNJU.mjs} +1 -1
- package/{chunk-H36NDYLG.mjs → chunk-PQEA6P4V.mjs} +40 -3
- package/{chunk-3A2F6BOM.mjs → chunk-YGLYUC6R.mjs} +21 -8
- package/editor/select-mode/iframeRpcChannel.d.ts +4 -4
- package/lib/tombstone.js +2 -2
- package/money.d.ts +1 -1
- package/orders/order-status-schema.d.ts +3 -3
- package/package.json +2 -2
- package/_vendor/replo-utils/lib/object.d.ts +0 -31
- package/_vendor/schemas/money.mjs +0 -1937
- package/chunk-544ZM65A.mjs +0 -203
- package/chunk-HGXQNZW7.mjs +0 -38
- package/chunk-ILGEM42C.mjs +0 -21
- package/chunk-QPGBIWJK.mjs +0 -195
- package/chunk-UJCSKKID.mjs +0 -23
- /package/{chunk-FNTGY7I5.mjs → chunk-JELVREEB.mjs} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Contentsquare" | "Segment" | "Northbeam" | "Gorgias" | "Converge" | "Cookiebot" | "snippet" | "custom" | "consentPlatform";
|
|
1
|
+
export type ReploScriptType = "GA4" | "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "X" | "Hotjar" | "MicrosoftClarity" | "Contentsquare" | "Segment" | "Northbeam" | "Gorgias" | "Converge" | "Mixpanel" | "HubSpot" | "Attentive" | "Alia" | "Cookiebot" | "Usercentrics" | "snippet" | "custom" | "consentPlatform";
|
|
2
2
|
export type ConsentCategory = "necessary" | "analytics" | "marketing" | "preferences" | "sale_of_data";
|
|
3
3
|
export type ConsentMode = "off" | "simple" | "per-category";
|
|
4
4
|
export type ScriptTagDescriptor = {
|
|
@@ -12,26 +12,67 @@ export type ScriptTagDescriptor = {
|
|
|
12
12
|
body: string;
|
|
13
13
|
module?: boolean;
|
|
14
14
|
};
|
|
15
|
+
export type XPixelEvents = {
|
|
16
|
+
pageView?: string;
|
|
17
|
+
productViewed?: string;
|
|
18
|
+
addToCart?: string;
|
|
19
|
+
startCheckout?: string;
|
|
20
|
+
purchase?: string;
|
|
21
|
+
};
|
|
22
|
+
export type ScriptRuntimeOwner = {
|
|
23
|
+
type: "gtm";
|
|
24
|
+
containerId: string;
|
|
25
|
+
} | {
|
|
26
|
+
type: "external";
|
|
27
|
+
};
|
|
28
|
+
export type MixpanelRegion = "us" | "eu" | "in";
|
|
15
29
|
export type ReploScriptEntry = {
|
|
16
|
-
type: "
|
|
30
|
+
type: "GoogleTagManager" | "Meta" | "TikTok" | "Pinterest" | "Reddit" | "Snapchat" | "Hotjar" | "MicrosoftClarity" | "Contentsquare" | "Segment" | "Northbeam" | "Gorgias" | "Converge" | "HubSpot" | "Attentive" | "Alia";
|
|
31
|
+
identifier: string;
|
|
32
|
+
requiredConsent?: ConsentCategory[];
|
|
33
|
+
usercentricsService?: string;
|
|
34
|
+
} | {
|
|
35
|
+
type: "GA4";
|
|
36
|
+
identifier: string;
|
|
37
|
+
requiredConsent?: ConsentCategory[];
|
|
38
|
+
runtimeOwner?: ScriptRuntimeOwner;
|
|
39
|
+
usercentricsService?: string;
|
|
40
|
+
} | {
|
|
41
|
+
type: "X";
|
|
17
42
|
identifier: string;
|
|
43
|
+
events?: Partial<XPixelEvents>;
|
|
18
44
|
requiredConsent?: ConsentCategory[];
|
|
45
|
+
usercentricsService?: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: "Mixpanel";
|
|
48
|
+
identifier: string;
|
|
49
|
+
region?: MixpanelRegion;
|
|
50
|
+
requiredConsent?: ConsentCategory[];
|
|
51
|
+
usercentricsService?: string;
|
|
19
52
|
} | {
|
|
20
53
|
type: "Cookiebot";
|
|
21
54
|
identifier: string;
|
|
22
55
|
requiredConsent?: ConsentCategory[];
|
|
56
|
+
} | {
|
|
57
|
+
type: "Usercentrics";
|
|
58
|
+
identifier: string;
|
|
59
|
+
loaderVersion?: "v2" | "v3";
|
|
60
|
+
runtimeOwner?: ScriptRuntimeOwner;
|
|
61
|
+
reploUsercentricsService?: string;
|
|
23
62
|
} | {
|
|
24
63
|
type: "snippet";
|
|
25
64
|
id: string;
|
|
26
65
|
body: string;
|
|
27
66
|
module?: boolean;
|
|
28
67
|
requiredConsent: ConsentCategory[];
|
|
68
|
+
usercentricsService?: string;
|
|
29
69
|
} | {
|
|
30
70
|
type: "custom";
|
|
31
71
|
id: string;
|
|
32
72
|
requiredConsent: ConsentCategory[];
|
|
33
73
|
src?: string;
|
|
34
74
|
body?: string;
|
|
75
|
+
usercentricsService?: string;
|
|
35
76
|
} | {
|
|
36
77
|
type: "consentPlatform";
|
|
37
78
|
id: string;
|
|
@@ -12,6 +12,7 @@ export type ErrorUserFacingDetailsWithMessage = {
|
|
|
12
12
|
maximum: number;
|
|
13
13
|
};
|
|
14
14
|
plan?: string;
|
|
15
|
+
featureType?: ("credits" | "shopifyThemeBuilder.publishedElements" | "sites" | "shopifyThemeBuilder.projects") | undefined;
|
|
15
16
|
callToAction?: {
|
|
16
17
|
type: "reload";
|
|
17
18
|
} | {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CommentAnchorElement } from "./comments";
|
|
2
|
+
export type DisplayMode = "browse" | "selection" | "comment";
|
|
2
3
|
export type SelectModeSelectionType = "none" | "element" | "area" | "drag";
|
|
3
4
|
export type SelectModeInlineTextStatus = "editable" | "dynamic" | "translated" | null;
|
|
4
5
|
export type SelectModeTextMetrics = {
|
|
@@ -34,6 +35,17 @@ export type SelectModeBoundingRect = {
|
|
|
34
35
|
width: number;
|
|
35
36
|
height: number;
|
|
36
37
|
};
|
|
38
|
+
export type SelectModeHoverRect = {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
left: number;
|
|
42
|
+
top: number;
|
|
43
|
+
right: number;
|
|
44
|
+
bottom: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
isSection?: boolean;
|
|
48
|
+
};
|
|
37
49
|
export type SelectModeSelectionRect = {
|
|
38
50
|
id: string;
|
|
39
51
|
rect: SelectModeBoundingRect;
|
|
@@ -53,16 +65,50 @@ export type SelectModeDefinedStyle = {
|
|
|
53
65
|
raw: string;
|
|
54
66
|
resolved: string;
|
|
55
67
|
};
|
|
68
|
+
export type SelectModeImageScope = {
|
|
69
|
+
kind: "all";
|
|
70
|
+
} | {
|
|
71
|
+
kind: "media";
|
|
72
|
+
media: string;
|
|
73
|
+
};
|
|
74
|
+
export type SelectModeImageSource = {
|
|
75
|
+
srcSet: string;
|
|
76
|
+
sizes: string;
|
|
77
|
+
media: string;
|
|
78
|
+
type: string;
|
|
79
|
+
previewUrl: string | null;
|
|
80
|
+
};
|
|
81
|
+
export type SelectModeImage = {
|
|
82
|
+
src: string;
|
|
83
|
+
currentSrc: string;
|
|
84
|
+
srcSet: string;
|
|
85
|
+
sizes: string;
|
|
86
|
+
previewUrl: string | null;
|
|
87
|
+
sources: SelectModeImageSource[];
|
|
88
|
+
};
|
|
89
|
+
export type SelectModeVideo = {
|
|
90
|
+
src: string;
|
|
91
|
+
currentSrc: string;
|
|
92
|
+
};
|
|
56
93
|
export type SelectedElement = {
|
|
57
94
|
kind: "react-element";
|
|
58
95
|
selector: string;
|
|
96
|
+
section?: {
|
|
97
|
+
selector: string;
|
|
98
|
+
};
|
|
59
99
|
tagName: string;
|
|
60
100
|
elementType: string;
|
|
61
101
|
textContent: string | null;
|
|
102
|
+
sectionLabel?: string;
|
|
62
103
|
rect: SelectModeBoundingRect;
|
|
63
104
|
textMetrics: SelectModeTextMetrics | null;
|
|
64
105
|
outerHTML: string;
|
|
106
|
+
image?: SelectModeImage;
|
|
107
|
+
video?: SelectModeVideo;
|
|
65
108
|
definedStyles: SelectModeDefinedStyle[];
|
|
109
|
+
authoredStyles: {
|
|
110
|
+
[x: string]: string;
|
|
111
|
+
};
|
|
66
112
|
inheritedStyles: {
|
|
67
113
|
[x: string]: string;
|
|
68
114
|
};
|
|
@@ -70,6 +116,7 @@ export type SelectedElement = {
|
|
|
70
116
|
sourceLocation?: SelectModeSourceLocation;
|
|
71
117
|
fiberChain: SelectModeFiberChainEntry[];
|
|
72
118
|
siblingSelectors: string[];
|
|
119
|
+
anchor?: CommentAnchorElement;
|
|
73
120
|
};
|
|
74
121
|
export type SelectablePlanData = {
|
|
75
122
|
kind: "plan";
|
|
@@ -85,7 +132,11 @@ export type SelectablePlanPayload = {
|
|
|
85
132
|
export type SelectableDataPayload = SelectablePlanPayload;
|
|
86
133
|
export type SelectableData = SelectedElement | SelectablePlanData;
|
|
87
134
|
export type SelectModeOptimisticUpdatePayload = {
|
|
135
|
+
kind: "image";
|
|
136
|
+
image: SelectModeImage;
|
|
137
|
+
} | {
|
|
88
138
|
kind: "css";
|
|
139
|
+
fontSource?: "google" | "site";
|
|
89
140
|
property: string;
|
|
90
141
|
value: string | null;
|
|
91
142
|
} | {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { SelectModeBoundingRect, DisplayMode, SelectModeSelectionType, SelectModeOptimisticUpdatePayload, SelectModeFormatCommand, SelectableData, SelectModeHoverRect, SelectModeClickPosition, SelectModeSelectionRect, SelectModeTiptapActiveMarks } from "./selectMode";
|
|
2
|
+
export type InlineEditFeedback = {
|
|
3
|
+
status: "pending" | "unavailable" | "failed";
|
|
4
|
+
rect: SelectModeBoundingRect;
|
|
5
5
|
};
|
|
6
6
|
export type IframeRuntimeBuildMetadata = {
|
|
7
7
|
packageName: string;
|
|
@@ -9,10 +9,60 @@ export type IframeRuntimeBuildMetadata = {
|
|
|
9
9
|
branch: string | null;
|
|
10
10
|
commit: string | null;
|
|
11
11
|
builtAt: string | null;
|
|
12
|
+
capabilities?: string[];
|
|
13
|
+
};
|
|
14
|
+
export type SectionCanvasSection = {
|
|
15
|
+
index: number;
|
|
16
|
+
startLine: number;
|
|
17
|
+
endLine: number;
|
|
18
|
+
label: string;
|
|
19
|
+
isLocked: boolean;
|
|
20
|
+
};
|
|
21
|
+
export type SectionCanvasState = {
|
|
22
|
+
pageFilePath: string;
|
|
23
|
+
sections: SectionCanvasSection[];
|
|
24
|
+
previewScale: number;
|
|
25
|
+
isDisabled: boolean;
|
|
26
|
+
insertingAt?: number | null;
|
|
27
|
+
occludedInsets?: {
|
|
28
|
+
left: number;
|
|
29
|
+
right: number;
|
|
30
|
+
} | null;
|
|
31
|
+
};
|
|
32
|
+
export type SectionCanvasRequest = {
|
|
33
|
+
type: "insert";
|
|
34
|
+
at: number;
|
|
35
|
+
} | {
|
|
36
|
+
type: "move";
|
|
37
|
+
moveId: string;
|
|
38
|
+
index: number;
|
|
39
|
+
to: number;
|
|
40
|
+
} | {
|
|
41
|
+
type: "remove";
|
|
42
|
+
index: number;
|
|
43
|
+
} | {
|
|
44
|
+
type: "undo";
|
|
45
|
+
} | {
|
|
46
|
+
type: "redo";
|
|
47
|
+
} | {
|
|
48
|
+
type: "cancelInsert";
|
|
49
|
+
};
|
|
50
|
+
export type SectionCanvasLayoutEntry = {
|
|
51
|
+
index: number;
|
|
52
|
+
startLine: number;
|
|
53
|
+
endLine: number;
|
|
54
|
+
rect: SelectModeBoundingRect;
|
|
12
55
|
};
|
|
13
56
|
export type SelectModeParentMessage = {
|
|
14
|
-
method: "
|
|
15
|
-
data:
|
|
57
|
+
method: "expandToSection";
|
|
58
|
+
data: {
|
|
59
|
+
targetSelector: string;
|
|
60
|
+
};
|
|
61
|
+
} | {
|
|
62
|
+
method: "setSectionPreview";
|
|
63
|
+
data: {
|
|
64
|
+
targetSelector: string | null;
|
|
65
|
+
};
|
|
16
66
|
} | {
|
|
17
67
|
method: "setDisplayMode";
|
|
18
68
|
data: {
|
|
@@ -70,7 +120,7 @@ export type SelectModeIframeMessage = {
|
|
|
70
120
|
} | {
|
|
71
121
|
method: "hoverElement";
|
|
72
122
|
data: {
|
|
73
|
-
rect:
|
|
123
|
+
rect: SelectModeHoverRect | null;
|
|
74
124
|
};
|
|
75
125
|
} | {
|
|
76
126
|
method: "selectedElementRectUpdate";
|
|
@@ -105,11 +155,17 @@ export type SelectModeIframeMessage = {
|
|
|
105
155
|
};
|
|
106
156
|
originalInnerHTML: string;
|
|
107
157
|
};
|
|
158
|
+
} | {
|
|
159
|
+
method: "inlineEditFeedbackChanged";
|
|
160
|
+
data: {
|
|
161
|
+
feedback: InlineEditFeedback | null;
|
|
162
|
+
};
|
|
108
163
|
} | {
|
|
109
164
|
method: "editorStateUpdate";
|
|
110
165
|
data: {
|
|
111
166
|
activeMarks: SelectModeTiptapActiveMarks;
|
|
112
|
-
|
|
167
|
+
isInlineEditing: boolean;
|
|
168
|
+
isInlineEditPending: boolean;
|
|
113
169
|
};
|
|
114
170
|
} | {
|
|
115
171
|
method: "fastRefreshComplete";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as z from "zod";
|
|
2
2
|
export type IframeRpcChannelMethodConfig = Record<string, {
|
|
3
3
|
inputSchema: z.ZodType;
|
|
4
4
|
outputSchema: z.ZodType;
|
|
@@ -50,6 +50,11 @@ type SubscriberWindow = {
|
|
|
50
50
|
type TargetIframeWindow = {
|
|
51
51
|
postMessage: (message: unknown, targetOrigin: string) => void;
|
|
52
52
|
};
|
|
53
|
+
export type IframeRpcVersionMismatch = {
|
|
54
|
+
channelIdentifier: string;
|
|
55
|
+
ownVersion: number;
|
|
56
|
+
peerVersion: number;
|
|
57
|
+
};
|
|
53
58
|
type IframeRpcChannelOptions<OutgoingMethods extends IframeRpcChannelMethodConfig, IncomingMethods extends IframeRpcChannelMethodConfig> = {
|
|
54
59
|
subscriberWindow: SubscriberWindow;
|
|
55
60
|
channelIdentifier: string;
|
|
@@ -60,6 +65,13 @@ type IframeRpcChannelOptions<OutgoingMethods extends IframeRpcChannelMethodConfi
|
|
|
60
65
|
outgoingMethods: OutgoingMethods;
|
|
61
66
|
incomingMethods: IncomingMethods;
|
|
62
67
|
handlers: IframeRpcChannelHandlers<IncomingMethods, OutgoingMethods>;
|
|
68
|
+
/**
|
|
69
|
+
* Called for every message from the expected peer on another version of
|
|
70
|
+
* this channel. The message itself is dropped: neither side can parse the
|
|
71
|
+
* other's protocol, so recovering (e.g. reloading the older side) is the
|
|
72
|
+
* caller's job.
|
|
73
|
+
*/
|
|
74
|
+
onPeerVersionMismatch?: (mismatch: IframeRpcVersionMismatch) => void;
|
|
63
75
|
};
|
|
64
76
|
export type IframeRpcChannel<OutgoingMethods extends IframeRpcChannelMethodConfig = IframeRpcChannelMethodConfig> = {
|
|
65
77
|
subscribe: () => () => void;
|
|
@@ -1,15 +1,158 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isNullish } from '../../chunk-
|
|
3
|
-
import '../../chunk-
|
|
4
|
-
import '
|
|
5
|
-
import '../../chunk-UJCSKKID.mjs';
|
|
6
|
-
import { z } from 'zod';
|
|
1
|
+
import { randomUUID, ReploError } from '../../chunk-DINTPZM2.mjs';
|
|
2
|
+
import { isNullish } from '../../chunk-PQEA6P4V.mjs';
|
|
3
|
+
import '../../chunk-JELVREEB.mjs';
|
|
4
|
+
import * as z from 'zod';
|
|
7
5
|
|
|
8
6
|
var defaultLogger = {
|
|
9
7
|
info: console.log,
|
|
10
8
|
debug: console.debug,
|
|
11
9
|
error: console.error
|
|
12
10
|
};
|
|
11
|
+
|
|
12
|
+
var FEATURE_TYPES = [
|
|
13
|
+
"credits",
|
|
14
|
+
"shopifyThemeBuilder.publishedElements",
|
|
15
|
+
"sites",
|
|
16
|
+
"shopifyThemeBuilder.projects"
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
var errorUserFacingDetailsMessageSchema = z.object({
|
|
20
|
+
type: z.enum([
|
|
21
|
+
"toast",
|
|
22
|
+
"fullPageModal",
|
|
23
|
+
"shopifyStorePassword",
|
|
24
|
+
"billing.addPublishedElements",
|
|
25
|
+
"billing.addShopifyThemeProject",
|
|
26
|
+
"billing.addReploSite",
|
|
27
|
+
"agentBilling.shopifyThemeBuilder.publishedElements.exceeded",
|
|
28
|
+
"agentBilling.shopifyThemeBuilder.projects.exceeded",
|
|
29
|
+
"agentBilling.sites.exceeded",
|
|
30
|
+
"agentBilling.credits.exceeded",
|
|
31
|
+
"agentBilling.upgradeRequired"
|
|
32
|
+
]),
|
|
33
|
+
message: z.string(),
|
|
34
|
+
isRecoverable: z.boolean().optional(),
|
|
35
|
+
detail: z.array(z.string()).or(z.string()).optional(),
|
|
36
|
+
key: z.string(),
|
|
37
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
38
|
+
usage: z.object({
|
|
39
|
+
current: z.number(),
|
|
40
|
+
maximum: z.number()
|
|
41
|
+
}).optional(),
|
|
42
|
+
plan: z.string().optional(),
|
|
43
|
+
featureType: z.enum(FEATURE_TYPES).optional().catch(void 0),
|
|
44
|
+
callToAction: z.discriminatedUnion("type", [
|
|
45
|
+
z.object({ type: z.literal("reload") }),
|
|
46
|
+
z.object({ type: z.literal("installApp") }),
|
|
47
|
+
z.object({ type: z.literal("goToHomepage") }),
|
|
48
|
+
z.object({ type: z.literal("navigateToProjectEditor") }),
|
|
49
|
+
z.object({ type: z.literal("closeModal") }),
|
|
50
|
+
z.object({
|
|
51
|
+
type: z.literal("navigateToLink"),
|
|
52
|
+
link: z.discriminatedUnion("type", [
|
|
53
|
+
z.object({ type: z.literal("errors.wrongJsonExtension") }),
|
|
54
|
+
z.object({ type: z.literal("errors.chunkingError") }),
|
|
55
|
+
z.object({ type: z.literal("errors.indexBackupError") }),
|
|
56
|
+
z.object({
|
|
57
|
+
type: z.literal("errors.shopifyIntegrationAlreadyAssigned")
|
|
58
|
+
}),
|
|
59
|
+
z.object({
|
|
60
|
+
type: z.literal("errors.shopifyIntegrationMissingAccessScopes"),
|
|
61
|
+
url: z.string()
|
|
62
|
+
}),
|
|
63
|
+
z.object({
|
|
64
|
+
type: z.literal("customLink"),
|
|
65
|
+
url: z.string()
|
|
66
|
+
}),
|
|
67
|
+
z.object({
|
|
68
|
+
type: z.literal(
|
|
69
|
+
"errors.projectConnectedToBillingIntegrationForShopifyWorkspace"
|
|
70
|
+
)
|
|
71
|
+
}),
|
|
72
|
+
z.object({ type: z.literal("errors.themeAssetSizeLimitExceeded") }),
|
|
73
|
+
z.object({ type: z.literal("errors.themeTotalSizeLimitExceeded") }),
|
|
74
|
+
z.object({
|
|
75
|
+
type: z.literal("errors.pageMetafieldDefinitionsChanged")
|
|
76
|
+
}),
|
|
77
|
+
z.object({ type: z.literal("settings.billing") })
|
|
78
|
+
])
|
|
79
|
+
})
|
|
80
|
+
]).optional()
|
|
81
|
+
}).describe("ErrorUserFacingDetailsWithMessage");
|
|
82
|
+
z.discriminatedUnion("type", [
|
|
83
|
+
errorUserFacingDetailsMessageSchema,
|
|
84
|
+
z.object({
|
|
85
|
+
type: z.literal("uncommon_none"),
|
|
86
|
+
key: z.string(),
|
|
87
|
+
usage: z.object({
|
|
88
|
+
current: z.number(),
|
|
89
|
+
maximum: z.number()
|
|
90
|
+
}).optional(),
|
|
91
|
+
message: z.string().optional(),
|
|
92
|
+
isRecoverable: z.boolean().optional(),
|
|
93
|
+
detail: z.array(z.string()).or(z.string()).optional()
|
|
94
|
+
})
|
|
95
|
+
]).describe("ErrorUserFacingDetails");
|
|
96
|
+
var IframeRpcChannelError = class extends ReploError {
|
|
97
|
+
};
|
|
98
|
+
var IframeRpcChannelTimeoutError = class extends IframeRpcChannelError {
|
|
99
|
+
constructor({ method, timeoutMs }) {
|
|
100
|
+
super({
|
|
101
|
+
message: `RPC method '${method}' timed out after ${timeoutMs}ms`,
|
|
102
|
+
additionalData: { method, timeoutMs }
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
var IframeRpcChannelTargetUnavailableError = class extends IframeRpcChannelError {
|
|
107
|
+
constructor({
|
|
108
|
+
callType,
|
|
109
|
+
method
|
|
110
|
+
}) {
|
|
111
|
+
super({
|
|
112
|
+
message: method ? `RPC target window was unavailable for '${method}'` : "RPC target window was unavailable for a response",
|
|
113
|
+
additionalData: { callType, method }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
var IframeRpcChannelRemoteError = class extends IframeRpcChannelError {
|
|
118
|
+
constructor({ method, message }) {
|
|
119
|
+
super({
|
|
120
|
+
message: `RPC method '${method}' failed: ${message}`,
|
|
121
|
+
additionalData: { method }
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
var IframeRpcChannelUnsubscribedError = class extends IframeRpcChannelError {
|
|
126
|
+
constructor({ method }) {
|
|
127
|
+
super({
|
|
128
|
+
message: `RPC was unsubscribed while '${method}' was pending`,
|
|
129
|
+
additionalData: { method }
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var IframeRpcChannelUnknownMethodError = class extends IframeRpcChannelError {
|
|
134
|
+
constructor({ method }) {
|
|
135
|
+
super({
|
|
136
|
+
message: `Unknown RPC method '${method}'`,
|
|
137
|
+
additionalData: { method }
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var IframeRpcChannelConfigurationError = class extends IframeRpcChannelError {
|
|
142
|
+
constructor({ message }) {
|
|
143
|
+
super({ message });
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var IframeRpcChannelInvalidInputError = class extends IframeRpcChannelError {
|
|
147
|
+
constructor({ method, cause }) {
|
|
148
|
+
super({
|
|
149
|
+
message: `Invalid RPC input for '${method}': ${cause.message}`,
|
|
150
|
+
cause,
|
|
151
|
+
additionalData: { method }
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
|
|
13
156
|
var iframeRpcCallResultSchema = z.discriminatedUnion("type", [
|
|
14
157
|
z.object({
|
|
15
158
|
type: z.literal("success"),
|
|
@@ -97,13 +240,14 @@ function createIframeRpcChannel(options) {
|
|
|
97
240
|
isExpectedMessage,
|
|
98
241
|
outgoingMethods,
|
|
99
242
|
incomingMethods,
|
|
100
|
-
handlers
|
|
243
|
+
handlers,
|
|
244
|
+
onPeerVersionMismatch
|
|
101
245
|
} = options;
|
|
102
246
|
const pendingRequests = /* @__PURE__ */ new Map();
|
|
103
247
|
let subscriberCount = 0;
|
|
104
248
|
let handlerMeta;
|
|
105
|
-
const postMessage = (call2) => {
|
|
106
|
-
|
|
249
|
+
const postMessage = (call2, targetWindow = getTargetWindow()) => {
|
|
250
|
+
targetWindow?.postMessage(
|
|
107
251
|
{
|
|
108
252
|
channelIdentifier,
|
|
109
253
|
version,
|
|
@@ -223,16 +367,37 @@ function createIframeRpcChannel(options) {
|
|
|
223
367
|
pendingRequest.resolve(parsedOutput.data);
|
|
224
368
|
};
|
|
225
369
|
const handleMessage = (event) => {
|
|
226
|
-
if (!isExpectedMessage(event)) {
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
370
|
const parsedMetadata = z.object({
|
|
230
371
|
channelIdentifier: z.literal(channelIdentifier),
|
|
231
|
-
version: z.
|
|
372
|
+
version: z.number()
|
|
232
373
|
}).safeParse(event.data);
|
|
233
374
|
if (!parsedMetadata.success) {
|
|
234
375
|
return;
|
|
235
376
|
}
|
|
377
|
+
if (!isExpectedMessage(event)) {
|
|
378
|
+
const isSiblingFrame = typeof document !== "undefined" && Array.from(document.querySelectorAll("iframe")).some((frame) => {
|
|
379
|
+
return event.source !== null && frame.contentWindow === event.source;
|
|
380
|
+
});
|
|
381
|
+
if (isSiblingFrame) {
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
defaultLogger.error("[iframeRpcChannel] Dropping unexpected message", {
|
|
385
|
+
channelIdentifier,
|
|
386
|
+
version,
|
|
387
|
+
origin: event.origin,
|
|
388
|
+
hasSource: Boolean(event.source)
|
|
389
|
+
});
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
const peerVersion = parsedMetadata.data.version;
|
|
393
|
+
if (peerVersion !== version) {
|
|
394
|
+
onPeerVersionMismatch?.({
|
|
395
|
+
channelIdentifier,
|
|
396
|
+
ownVersion: version,
|
|
397
|
+
peerVersion
|
|
398
|
+
});
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
236
401
|
const parsedCall = iframeRpcCallSchema.safeParse(event.data);
|
|
237
402
|
if (!parsedCall.success) {
|
|
238
403
|
return;
|
|
@@ -319,6 +484,15 @@ function createIframeRpcChannel(options) {
|
|
|
319
484
|
new IframeRpcChannelUnsubscribedError({ method })
|
|
320
485
|
);
|
|
321
486
|
}
|
|
487
|
+
const targetWindow = getTargetWindow();
|
|
488
|
+
if (!targetWindow) {
|
|
489
|
+
return Promise.reject(
|
|
490
|
+
new IframeRpcChannelTargetUnavailableError({
|
|
491
|
+
callType: "request",
|
|
492
|
+
method
|
|
493
|
+
})
|
|
494
|
+
);
|
|
495
|
+
}
|
|
322
496
|
const id = randomUUID();
|
|
323
497
|
const timeoutMs = definition.timeoutMs ?? 3e4;
|
|
324
498
|
return new Promise(
|
|
@@ -335,12 +509,21 @@ function createIframeRpcChannel(options) {
|
|
|
335
509
|
reject,
|
|
336
510
|
timeoutId
|
|
337
511
|
});
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
512
|
+
try {
|
|
513
|
+
postMessage(
|
|
514
|
+
{
|
|
515
|
+
type: "request",
|
|
516
|
+
id,
|
|
517
|
+
method,
|
|
518
|
+
data: parsedInput.data
|
|
519
|
+
},
|
|
520
|
+
targetWindow
|
|
521
|
+
);
|
|
522
|
+
} catch (error) {
|
|
523
|
+
clearTimeout(timeoutId);
|
|
524
|
+
pendingRequests.delete(id);
|
|
525
|
+
reject(error);
|
|
526
|
+
}
|
|
344
527
|
}
|
|
345
528
|
);
|
|
346
529
|
};
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var migrationCommand = `pnpm add --ignore-workspace @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove --ignore-workspace canopy-sdk
|
|
4
|
-
(if package.json lists "@replohq/canopy-sdk" instead of the "canopy-sdk" alias, run: pnpm remove --ignore-workspace @replohq/canopy-sdk)`;
|
|
1
|
+
var migrationCommand = `pnpm add @replohq/sdk@latest @replohq/sandbox-runtime@latest && pnpm remove canopy-sdk
|
|
2
|
+
(if package.json lists "@replohq/canopy-sdk" instead of the "canopy-sdk" alias, run: pnpm remove @replohq/canopy-sdk)`;
|
|
5
3
|
var providerComposition = `import { ReploProvider } from "@replohq/sdk/providers/replo-provider";
|
|
6
4
|
import { SandboxRuntime } from "@replohq/sandbox-runtime";
|
|
7
5
|
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReploError } from "./errors";
|
|
1
|
+
import { ReploError } from "./reploError";
|
|
3
2
|
export declare class InvalidAmountError extends ReploError {
|
|
4
3
|
}
|
|
5
4
|
export declare class UnsupportedCurrencyError extends ReploError {
|
|
6
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* True for currencies where Stripe deliberately differs from ISO — e.g. ISO
|
|
8
|
+
* calls IQD/LYD 3-decimal and ISK/UGX 0-decimal, but Stripe treats all four as
|
|
9
|
+
* 2-decimal (and MGA/MRU are ÷5, not decimal at all). Check it before sending
|
|
10
|
+
* minor units to Stripe, so a wrong-exponent amount can never be charged. When
|
|
11
|
+
* we launch one of these for Replo checkout, add a Stripe-verified override.
|
|
12
|
+
*/
|
|
13
|
+
export declare function stripeExponentDiffersFromIso(currencyCode: string): boolean;
|
|
14
|
+
export declare function assertStripeExponentMatchesIso(currencyCode: string): void;
|
|
7
15
|
/**
|
|
8
16
|
* Converts a decimal major-unit amount (e.g. "19.99", 19.99) into integer
|
|
9
|
-
* minor units (1999) using the currency's
|
|
17
|
+
* minor units (1999) using the currency's ISO-4217 exponent. Half-away-from-zero
|
|
10
18
|
* rounding for the non-negative amounts this domain uses (prices, totals),
|
|
11
19
|
* matching Stripe. Throws on non-numeric input.
|
|
12
20
|
*/
|
|
@@ -52,9 +60,3 @@ export declare function formatAmount({ amount, currencyCode, locale, }: {
|
|
|
52
60
|
currencyCode: string;
|
|
53
61
|
locale?: string;
|
|
54
62
|
}): string;
|
|
55
|
-
export declare const amountSchema: z.ZodNumber;
|
|
56
|
-
/** An amount in minor units paired with its ISO 4217 currency code. */
|
|
57
|
-
export declare const amountWithCurrencyCodeSchema: z.ZodObject<{
|
|
58
|
-
amount: z.ZodNumber;
|
|
59
|
-
currencyCode: z.ZodString;
|
|
60
|
-
}, z.core.$strip>;
|