@superblocksteam/library 2.0.149 → 2.0.150-next.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/dist/{build-manifest-Xi8oZhWX.js → build-manifest-BQAcrmit.js} +1 -1
- package/dist/{build-manifest-Xi8oZhWX.js.map → build-manifest-BQAcrmit.js.map} +1 -1
- package/dist/{devtools-consolidated--QF_TVsD.js → devtools-consolidated-C5sXwPGD.js} +1 -1
- package/dist/{devtools-consolidated--QF_TVsD.js.map → devtools-consolidated-C5sXwPGD.js.map} +1 -1
- package/dist/jsx-dev-runtime/index.js +2 -1
- package/dist/jsx-dev-runtime/index.js.map +1 -1
- package/dist/jsx-wrapper-c5W52jgK.js +638 -0
- package/dist/jsx-wrapper-c5W52jgK.js.map +1 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +8 -321
- package/dist/lib/index.js.map +1 -1
- package/dist/{logs-Bo--dJx2.js → logs-DwKJqoRc.js} +1 -1
- package/dist/{logs-Bo--dJx2.js.map → logs-DwKJqoRc.js.map} +1 -1
- package/dist/rolldown-runtime-CiIaOW0V.js +13 -0
- package/dist/{jsx-wrapper-CSTsctdq.js → root-store-CkTnQd84.js} +215 -665
- package/dist/root-store-CkTnQd84.js.map +1 -0
- package/dist/sdk-api-discovery-ekr6aG8h.js +366 -0
- package/dist/sdk-api-discovery-ekr6aG8h.js.map +1 -0
- package/dist/{utils-C-i9g4Qh.js → utils-kXteBlMZ.js} +2 -13
- package/dist/{utils-C-i9g4Qh.js.map → utils-kXteBlMZ.js.map} +1 -1
- package/package.json +4 -4
- package/dist/jsx-wrapper-CSTsctdq.js.map +0 -1
|
@@ -0,0 +1,638 @@
|
|
|
1
|
+
import { E as isEditMode, b as colors, n as root_store_default, v as generateId, x as editorBridge } from "./root-store-CkTnQd84.js";
|
|
2
|
+
import { reaction } from "mobx";
|
|
3
|
+
import { NO_SELECT_ATTRIBUTE, SELECTOR_ID_ATTRIBUTE, SOURCE_ID_ATTRIBUTE } from "@superblocksteam/library-shared";
|
|
4
|
+
import * as React$1 from "react";
|
|
5
|
+
import React, { Component, useEffect, useMemo, useRef } from "react";
|
|
6
|
+
import styled, { keyframes } from "styled-components";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { Observer } from "mobx-react-lite";
|
|
9
|
+
import polyfill from "@oddbird/css-anchor-positioning/fn";
|
|
10
|
+
//#region src/lib/user-facing/assets/images/clark.svg
|
|
11
|
+
var _path$1, _path2, _path3, _path4, _path5, _path6, _path7, _defs;
|
|
12
|
+
function _extends$1() {
|
|
13
|
+
return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
|
|
14
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
15
|
+
var t = arguments[e];
|
|
16
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
17
|
+
}
|
|
18
|
+
return n;
|
|
19
|
+
}, _extends$1.apply(null, arguments);
|
|
20
|
+
}
|
|
21
|
+
var SvgClark = function SvgClark(props) {
|
|
22
|
+
return /* @__PURE__ */ React$1.createElement("svg", _extends$1({
|
|
23
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
24
|
+
width: 28,
|
|
25
|
+
height: 20,
|
|
26
|
+
fill: "none"
|
|
27
|
+
}, props), _path$1 || (_path$1 = /* @__PURE__ */ React$1.createElement("path", {
|
|
28
|
+
fill: "url(#clark_svg__a)",
|
|
29
|
+
d: "M20.41 1.239a5.16 5.16 0 0 0-4.703 5.413l2.648-.232a2.227 2.227 0 1 1 2.886 2.49l.18 2.062.035.02c.575-.05 1.213-.454 1.57-.748 1.617-1.337 1.71-3.2 1.705-3.672 0-.063.047-.117.11-.123l.27-.024a.18.18 0 0 0 .167-.206c-.068-.444-.304-1.577-1.018-2.419-.064-.074-.019-.194.079-.203l.402-.035c.142-.012.218-.166.13-.28-.492-.64-1.994-2.26-4.46-2.043"
|
|
30
|
+
})), _path2 || (_path2 = /* @__PURE__ */ React$1.createElement("path", {
|
|
31
|
+
fill: "#2A333D",
|
|
32
|
+
d: "M18.333 6.987a2.226 2.226 0 0 0 2.411 2.024l.555-.048c-.612-2.74-1.987-3.551-1.987-3.551.153-.386 1.044-.836 1.044-.836a2.226 2.226 0 0 0-2.023 2.411",
|
|
33
|
+
opacity: .12
|
|
34
|
+
})), _path3 || (_path3 = /* @__PURE__ */ React$1.createElement("path", {
|
|
35
|
+
fill: "url(#clark_svg__b)",
|
|
36
|
+
d: "m6.65 12.564.045.492-.228-2.607A2.338 2.338 0 1 1 8.58 6.587l2.588-.226a5.16 5.16 0 0 0-5.371-3.584c-2.467.216-3.665 2.072-4.039 2.787-.066.127.035.266.177.253l.403-.035c.097-.008.162.102.113.186-.558.953-.593 2.11-.583 2.56a.18.18 0 0 0 .2.173l.27-.023a.12.12 0 0 1 .13.101c.078.467.492 2.285 2.317 3.32.402.228 1.291.515 1.866.465"
|
|
37
|
+
})), _path4 || (_path4 = /* @__PURE__ */ React$1.createElement("path", {
|
|
38
|
+
fill: "#2A333D",
|
|
39
|
+
d: "M9.161 7.938a2.337 2.337 0 0 1-2.124 2.53l-.582.052c.133-2.944 1.406-4.032 1.406-4.032-.227-.371-1.231-.675-1.231-.675A2.337 2.337 0 0 1 9.16 7.938",
|
|
40
|
+
opacity: .12
|
|
41
|
+
})), _path5 || (_path5 = /* @__PURE__ */ React$1.createElement("path", {
|
|
42
|
+
fill: "currentColor",
|
|
43
|
+
fillRule: "evenodd",
|
|
44
|
+
d: "M21.72 10.543c-.461-3.366-2.697-6.01-6.685-6.252-.109-.006-.163-.01-.202-.031a.2.2 0 0 1-.078-.084c-.02-.04-.02-.092-.02-.197v-.572a.192.192 0 0 0-.308-.153l-.938.708a.192.192 0 0 1-.309-.154v-.361a.192.192 0 0 0-.318-.145l-.807.717a9 9 0 0 1-.5.431 2 2 0 0 1-.305.2c-.119.069-.414.205-1.004.477-2.794 1.29-4.104 3.885-3.852 6.757.43 4.911 3.404 6.652 8.266 6.226 4.215-.368 7.758-2.469 7.06-7.567M11.64 10.2c.142.62-.16 1.221-.678 1.34-.518.12-1.053-.286-1.197-.907a1.3 1.3 0 0 1-.018-.521.384.384 0 1 0 .376-.667.8.8 0 0 1 .32-.153c.517-.12 1.053.287 1.196.908m7.042-.148c.51-.146.782-.761.606-1.374-.176-.612-.732-.99-1.242-.844a.83.83 0 0 0-.375.23.384.384 0 1 1-.284.713q-.01.211.052.431c.176.613.732.99 1.243.844m-5.448 3.596-.253-2.896a2.08 2.08 0 0 1 4.092-.685l.704 2.82a2.31 2.31 0 1 1-4.543.761",
|
|
45
|
+
clipRule: "evenodd"
|
|
46
|
+
})), _path6 || (_path6 = /* @__PURE__ */ React$1.createElement("path", {
|
|
47
|
+
fill: "url(#clark_svg__c)",
|
|
48
|
+
d: "M13.88 14.096a2.3 2.3 0 0 0 1.847.492 2.3 2.3 0 0 0 1.585-1.066 1.79 1.79 0 0 1-3.431.574",
|
|
49
|
+
opacity: .5
|
|
50
|
+
})), _path7 || (_path7 = /* @__PURE__ */ React$1.createElement("path", {
|
|
51
|
+
fill: "url(#clark_svg__d)",
|
|
52
|
+
d: "M13.191 13.144a2.312 2.312 0 0 0 4.465-.748l.123.491a2.31 2.31 0 1 1-4.544.761z",
|
|
53
|
+
opacity: .5
|
|
54
|
+
})), _defs || (_defs = /* @__PURE__ */ React$1.createElement("defs", null, /* @__PURE__ */ React$1.createElement("linearGradient", {
|
|
55
|
+
id: "clark_svg__a",
|
|
56
|
+
x1: 21.636,
|
|
57
|
+
x2: 17.027,
|
|
58
|
+
y1: 4.149,
|
|
59
|
+
y2: 8.785,
|
|
60
|
+
gradientUnits: "userSpaceOnUse"
|
|
61
|
+
}, /* @__PURE__ */ React$1.createElement("stop", { stopColor: "currentColor" }), /* @__PURE__ */ React$1.createElement("stop", {
|
|
62
|
+
offset: 1,
|
|
63
|
+
stopColor: "currentColor",
|
|
64
|
+
stopOpacity: .84
|
|
65
|
+
})), /* @__PURE__ */ React$1.createElement("linearGradient", {
|
|
66
|
+
id: "clark_svg__b",
|
|
67
|
+
x1: 4.534,
|
|
68
|
+
x2: 10.643,
|
|
69
|
+
y1: 6.603,
|
|
70
|
+
y2: 9.712,
|
|
71
|
+
gradientUnits: "userSpaceOnUse"
|
|
72
|
+
}, /* @__PURE__ */ React$1.createElement("stop", { stopColor: "currentColor" }), /* @__PURE__ */ React$1.createElement("stop", {
|
|
73
|
+
offset: 1,
|
|
74
|
+
stopColor: "currentColor",
|
|
75
|
+
stopOpacity: .84
|
|
76
|
+
})), /* @__PURE__ */ React$1.createElement("linearGradient", {
|
|
77
|
+
id: "clark_svg__c",
|
|
78
|
+
x1: 15.788,
|
|
79
|
+
x2: 16.004,
|
|
80
|
+
y1: 13.866,
|
|
81
|
+
y2: 15.093,
|
|
82
|
+
gradientUnits: "userSpaceOnUse"
|
|
83
|
+
}, /* @__PURE__ */ React$1.createElement("stop", {
|
|
84
|
+
stopColor: "currentColor",
|
|
85
|
+
stopOpacity: .6
|
|
86
|
+
}), /* @__PURE__ */ React$1.createElement("stop", {
|
|
87
|
+
offset: 1,
|
|
88
|
+
stopColor: "currentColor"
|
|
89
|
+
})), /* @__PURE__ */ React$1.createElement("linearGradient", {
|
|
90
|
+
id: "clark_svg__d",
|
|
91
|
+
x1: 15.704,
|
|
92
|
+
x2: 16.07,
|
|
93
|
+
y1: 13.597,
|
|
94
|
+
y2: 15.67,
|
|
95
|
+
gradientUnits: "userSpaceOnUse"
|
|
96
|
+
}, /* @__PURE__ */ React$1.createElement("stop", {
|
|
97
|
+
stopColor: "currentColor",
|
|
98
|
+
stopOpacity: .6
|
|
99
|
+
}), /* @__PURE__ */ React$1.createElement("stop", {
|
|
100
|
+
offset: 1,
|
|
101
|
+
stopColor: "currentColor"
|
|
102
|
+
})))));
|
|
103
|
+
};
|
|
104
|
+
//#endregion
|
|
105
|
+
//#region src/lib/internal-details/internal-components/common.ts
|
|
106
|
+
const ErrorIconContainer = styled.div`
|
|
107
|
+
width: 60px;
|
|
108
|
+
height: 60px;
|
|
109
|
+
min-width: 60px;
|
|
110
|
+
min-height: 60px;
|
|
111
|
+
background: linear-gradient(135deg, #aab 0%, #000033 50%, #000066 100%);
|
|
112
|
+
border-radius: 16px;
|
|
113
|
+
display: flex;
|
|
114
|
+
align-items: center;
|
|
115
|
+
justify-content: center;
|
|
116
|
+
margin: 0 auto 16px;
|
|
117
|
+
flex-shrink: 0;
|
|
118
|
+
animation: scaleIn 0.3s ease-out forwards;
|
|
119
|
+
opacity: 0;
|
|
120
|
+
box-shadow:
|
|
121
|
+
0 0 1px black,
|
|
122
|
+
0 4px 12px rgba(0, 85, 187, 0.15),
|
|
123
|
+
0 2px 4px rgba(0, 85, 187, 0.05);
|
|
124
|
+
|
|
125
|
+
@keyframes scaleIn {
|
|
126
|
+
from {
|
|
127
|
+
transform: scale(0.8);
|
|
128
|
+
opacity: 0;
|
|
129
|
+
}
|
|
130
|
+
to {
|
|
131
|
+
transform: scale(1);
|
|
132
|
+
opacity: 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
const StyledClarkIcon = styled(SvgClark)`
|
|
137
|
+
width: 54px;
|
|
138
|
+
height: 54px;
|
|
139
|
+
color: white;
|
|
140
|
+
margin-top: 3px;
|
|
141
|
+
margin-left: 1px;
|
|
142
|
+
animation: scaleIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
|
|
143
|
+
opacity: 0;
|
|
144
|
+
|
|
145
|
+
@keyframes scaleIn {
|
|
146
|
+
0% {
|
|
147
|
+
transform: scale(0.6);
|
|
148
|
+
opacity: 0;
|
|
149
|
+
}
|
|
150
|
+
50% {
|
|
151
|
+
transform: scale(1.1);
|
|
152
|
+
}
|
|
153
|
+
100% {
|
|
154
|
+
transform: scale(1);
|
|
155
|
+
opacity: 1;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
`;
|
|
159
|
+
const ErrorTitle = styled.h2`
|
|
160
|
+
font-family: Inter;
|
|
161
|
+
color: rgba(0, 0, 0, 0.85);
|
|
162
|
+
font-weight: 600;
|
|
163
|
+
font-size: 24px;
|
|
164
|
+
line-height: 1.35;
|
|
165
|
+
text-align: center;
|
|
166
|
+
margin-bottom: 6px;
|
|
167
|
+
flex-shrink: 0;
|
|
168
|
+
`;
|
|
169
|
+
const ErrorMessage = styled.p`
|
|
170
|
+
font-family: Inter;
|
|
171
|
+
font-size: 14px;
|
|
172
|
+
color: #6c7689;
|
|
173
|
+
line-height: 1.5715;
|
|
174
|
+
text-align: center;
|
|
175
|
+
flex-shrink: 0;
|
|
176
|
+
margin-top: 0;
|
|
177
|
+
margin-bottom: 16px;
|
|
178
|
+
`;
|
|
179
|
+
const ErrorDetails = styled.details`
|
|
180
|
+
margin-top: 24px;
|
|
181
|
+
text-align: left;
|
|
182
|
+
background-color: #f9fafb;
|
|
183
|
+
border-radius: 6px;
|
|
184
|
+
padding: 16px;
|
|
185
|
+
box-shadow:
|
|
186
|
+
0px 0px 1px 0px #22272f52,
|
|
187
|
+
0px 1px 3px 0px #22272f1f;
|
|
188
|
+
flex-shrink: 0;
|
|
189
|
+
font-family: Inter;
|
|
190
|
+
|
|
191
|
+
&[open] summary {
|
|
192
|
+
margin-bottom: 12px;
|
|
193
|
+
}
|
|
194
|
+
`;
|
|
195
|
+
const ErrorSummary = styled.summary`
|
|
196
|
+
cursor: pointer;
|
|
197
|
+
font-weight: 500;
|
|
198
|
+
color: #374151;
|
|
199
|
+
font-size: 14px;
|
|
200
|
+
user-select: none;
|
|
201
|
+
`;
|
|
202
|
+
const ErrorStack = styled.pre`
|
|
203
|
+
font-size: 12px;
|
|
204
|
+
color: #dc2626;
|
|
205
|
+
overflow: auto;
|
|
206
|
+
white-space: pre-wrap;
|
|
207
|
+
margin: 16px;
|
|
208
|
+
font-family: monospace;
|
|
209
|
+
`;
|
|
210
|
+
const ErrorContainer = styled.div`
|
|
211
|
+
position: absolute;
|
|
212
|
+
inset: 0;
|
|
213
|
+
display: flex;
|
|
214
|
+
align-items: center;
|
|
215
|
+
justify-content: center;
|
|
216
|
+
z-index: 10;
|
|
217
|
+
background: rgba(255, 255, 255, 0.5);
|
|
218
|
+
pointer-events: auto;
|
|
219
|
+
`;
|
|
220
|
+
const ErrorContent = styled.div`
|
|
221
|
+
max-width: 700px;
|
|
222
|
+
padding: 40px;
|
|
223
|
+
overflow-y: auto;
|
|
224
|
+
flex: 1;
|
|
225
|
+
display: flex;
|
|
226
|
+
flex-direction: column;
|
|
227
|
+
gap: 20px;
|
|
228
|
+
|
|
229
|
+
opacity: 0;
|
|
230
|
+
animation: fadeIn 0.3s ease-out forwards;
|
|
231
|
+
|
|
232
|
+
@keyframes fadeIn {
|
|
233
|
+
from {
|
|
234
|
+
opacity: 0;
|
|
235
|
+
}
|
|
236
|
+
to {
|
|
237
|
+
opacity: 1;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
`;
|
|
241
|
+
const SecondaryButton = styled.button`
|
|
242
|
+
color: ${colors.GREY_700};
|
|
243
|
+
border: 1px solid ${colors.GREY_100};
|
|
244
|
+
width: fit-content;
|
|
245
|
+
border-radius: 4px;
|
|
246
|
+
padding: 6px 12px;
|
|
247
|
+
cursor: pointer;
|
|
248
|
+
height: fit-content;
|
|
249
|
+
font-size: 12px;
|
|
250
|
+
|
|
251
|
+
&:hover {
|
|
252
|
+
opacity: 0.8;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
&:active {
|
|
256
|
+
opacity: 0.6;
|
|
257
|
+
}
|
|
258
|
+
`;
|
|
259
|
+
const ActionsContainer = styled.div`
|
|
260
|
+
display: flex;
|
|
261
|
+
gap: 12px;
|
|
262
|
+
align-items: center;
|
|
263
|
+
justify-content: center;
|
|
264
|
+
`;
|
|
265
|
+
//#endregion
|
|
266
|
+
//#region src/edit-mode/assets/ai-stars.svg
|
|
267
|
+
var _path;
|
|
268
|
+
function _extends() {
|
|
269
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
270
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
271
|
+
var t = arguments[e];
|
|
272
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
273
|
+
}
|
|
274
|
+
return n;
|
|
275
|
+
}, _extends.apply(null, arguments);
|
|
276
|
+
}
|
|
277
|
+
var SvgAiStars = function SvgAiStars(props) {
|
|
278
|
+
return /* @__PURE__ */ React$1.createElement("svg", _extends({
|
|
279
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
280
|
+
width: 13,
|
|
281
|
+
height: 14,
|
|
282
|
+
fill: "none"
|
|
283
|
+
}, props), _path || (_path = /* @__PURE__ */ React$1.createElement("path", {
|
|
284
|
+
fill: "currentColor",
|
|
285
|
+
fillRule: "evenodd",
|
|
286
|
+
d: "M10.5.9a.6.6 0 0 1 .586.472l.133.605a.4.4 0 0 0 .305.305l.605.132a.6.6 0 0 1 0 1.172l-.605.133a.4.4 0 0 0-.305.305l-.133.605a.6.6 0 0 1-1.172 0l-.132-.605a.4.4 0 0 0-.305-.305l-.605-.133a.6.6 0 0 1 0-1.172l.605-.132a.4.4 0 0 0 .305-.305l.132-.605A.6.6 0 0 1 10.5.9M5.077 3.833a.6.6 0 0 0-1.153 0l-.215.74A2.4 2.4 0 0 1 2.074 6.21l-.741.215a.6.6 0 0 0 0 1.153l.74.215A2.4 2.4 0 0 1 3.71 9.427l.215.74a.6.6 0 0 0 1.153 0l.215-.74a2.4 2.4 0 0 1 1.635-1.635l.74-.215a.6.6 0 0 0 0-1.153l-.74-.215a2.4 2.4 0 0 1-1.635-1.635zm6.01 5.539a.6.6 0 0 0-1.173 0l-.132.605a.4.4 0 0 1-.305.305l-.605.133a.6.6 0 0 0 0 1.172l.605.132a.4.4 0 0 1 .305.305l.132.605a.6.6 0 0 0 1.172 0l.133-.605a.4.4 0 0 1 .305-.305l.605-.132a.6.6 0 0 0 0-1.172l-.605-.133a.4.4 0 0 1-.305-.305z",
|
|
287
|
+
clipRule: "evenodd"
|
|
288
|
+
})));
|
|
289
|
+
};
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/lib/internal-details/internal-components/fix-with-clark-button.tsx
|
|
292
|
+
const MAX_STACK_FRAMES = 10;
|
|
293
|
+
const MAX_PROMPT_LENGTH = 8e3;
|
|
294
|
+
function buildRuntimeErrorPrompt(error) {
|
|
295
|
+
const defaultPrompt = "Fix this error: Unknown error";
|
|
296
|
+
if (!error) return defaultPrompt;
|
|
297
|
+
const [messageLine, ...rawFrames] = error.stack?.split("\n") ?? [];
|
|
298
|
+
const message = (messageLine || error.message || error.toString()).trim();
|
|
299
|
+
const filteredFrames = rawFrames.filter((line) => line && !line.includes("node_modules"));
|
|
300
|
+
const selectedFrames = filteredFrames.slice(0, MAX_STACK_FRAMES);
|
|
301
|
+
const omittedCount = filteredFrames.length - selectedFrames.length;
|
|
302
|
+
const frameSection = [...selectedFrames, ...omittedCount > 0 ? [`... (${omittedCount} additional frame${omittedCount > 1 ? "s" : ""} omitted)`] : []].map((line) => line.trimEnd()).join("\n");
|
|
303
|
+
const prompt = `Fix this error: ${frameSection ? `${message}\n${frameSection}` : message}`;
|
|
304
|
+
if (prompt.length <= MAX_PROMPT_LENGTH) return prompt;
|
|
305
|
+
const suffix = "... (truncated)";
|
|
306
|
+
const availableChars = Math.max(MAX_PROMPT_LENGTH - 15, 0);
|
|
307
|
+
return `${prompt.slice(0, availableChars)}${suffix}`;
|
|
308
|
+
}
|
|
309
|
+
const FixWithClarkButtonContainer = styled.button`
|
|
310
|
+
padding: 6px 12px;
|
|
311
|
+
background-color: ${colors.ACCENT_BLUE_500};
|
|
312
|
+
border-radius: 4px;
|
|
313
|
+
border: none;
|
|
314
|
+
color: white;
|
|
315
|
+
height: fit-content;
|
|
316
|
+
display: flex;
|
|
317
|
+
gap: 4px;
|
|
318
|
+
cursor: pointer;
|
|
319
|
+
transition: opacity 0.2s;
|
|
320
|
+
font-size: 12px;
|
|
321
|
+
align-items: center;
|
|
322
|
+
|
|
323
|
+
&:hover:not(:disabled) {
|
|
324
|
+
opacity: 0.8;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
&:disabled {
|
|
328
|
+
opacity: 0.5;
|
|
329
|
+
cursor: not-allowed;
|
|
330
|
+
}
|
|
331
|
+
`;
|
|
332
|
+
function FixWithClarkButton({ identifier, error, onClick }) {
|
|
333
|
+
const isAiEditing = root_store_default.editStore?.ai.getIsEditing() ?? false;
|
|
334
|
+
const handleFixWithAi = () => {
|
|
335
|
+
onClick?.();
|
|
336
|
+
if (identifier) editorBridge.addComponentToAiContext(identifier.sourceId, identifier.selectorId);
|
|
337
|
+
const prompt = buildRuntimeErrorPrompt(error);
|
|
338
|
+
editorBridge.aiGenerate(prompt, true);
|
|
339
|
+
};
|
|
340
|
+
return /* @__PURE__ */ jsxs(FixWithClarkButtonContainer, {
|
|
341
|
+
onClick: handleFixWithAi,
|
|
342
|
+
disabled: isAiEditing,
|
|
343
|
+
children: [/* @__PURE__ */ jsx(SvgAiStars, {}), " Fix with Clark"]
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/lib/internal-details/css-constants.ts
|
|
348
|
+
const CSS_CLASSES = {
|
|
349
|
+
SUSPENSE_FALLBACK: "sb-suspense-fallback",
|
|
350
|
+
ANCHOR_NAME: "sb-anchor-name"
|
|
351
|
+
};
|
|
352
|
+
//#endregion
|
|
353
|
+
//#region src/lib/internal-details/lib/suspense/suspense-fallback.tsx
|
|
354
|
+
const shimmerAnimation = keyframes`
|
|
355
|
+
0% {
|
|
356
|
+
background-position: -200px 0;
|
|
357
|
+
}
|
|
358
|
+
100% {
|
|
359
|
+
background-position: calc(200px + 100%) 0;
|
|
360
|
+
}
|
|
361
|
+
`;
|
|
362
|
+
const ShimmerDiv = styled.div`
|
|
363
|
+
min-height: 12px;
|
|
364
|
+
min-width: 12px;
|
|
365
|
+
background-color: ${(props) => props.$backgroundColor};
|
|
366
|
+
border-radius: ${(props) => props.$borderRadius};
|
|
367
|
+
position: relative;
|
|
368
|
+
overflow: hidden;
|
|
369
|
+
background: linear-gradient(
|
|
370
|
+
90deg,
|
|
371
|
+
${(props) => props.$backgroundColor} 25%,
|
|
372
|
+
${(props) => props.$shimmerHighlight} 50%,
|
|
373
|
+
${(props) => props.$backgroundColor} 75%
|
|
374
|
+
);
|
|
375
|
+
background-size: max(100%, 200px) 100%;
|
|
376
|
+
animation: ${shimmerAnimation} 5s infinite linear;
|
|
377
|
+
`;
|
|
378
|
+
/**
|
|
379
|
+
* Default fallback component displayed while components are suspended.
|
|
380
|
+
*/
|
|
381
|
+
function SuspenseFallback({ style, className, noBorderRadius }) {
|
|
382
|
+
const backgroundColor = "#f8f9fa";
|
|
383
|
+
const shimmerHighlight = "#ffffff";
|
|
384
|
+
const borderRadius = noBorderRadius ? "0px" : "4px";
|
|
385
|
+
const classes = useMemo(() => [CSS_CLASSES.ANCHOR_NAME, className].filter(Boolean).join(" "), [className]);
|
|
386
|
+
return /* @__PURE__ */ jsx(ShimmerDiv, {
|
|
387
|
+
$backgroundColor: backgroundColor,
|
|
388
|
+
$shimmerHighlight: shimmerHighlight,
|
|
389
|
+
$borderRadius: borderRadius,
|
|
390
|
+
style: style?.(),
|
|
391
|
+
className: classes,
|
|
392
|
+
"data-test": "suspense-fallback"
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
//#endregion
|
|
396
|
+
//#region src/lib/user-facing/component-base/error-boundary.tsx
|
|
397
|
+
const ErrorBoundaryContainer = styled.div`
|
|
398
|
+
background: white;
|
|
399
|
+
padding: 10px;
|
|
400
|
+
display: flex;
|
|
401
|
+
flex-direction: column;
|
|
402
|
+
gap: 8px;
|
|
403
|
+
border: 1px solid ${colors.GREY_100};
|
|
404
|
+
border-left: 3px solid ${colors.RED_500};
|
|
405
|
+
border-radius: 4px;
|
|
406
|
+
width: 100%;
|
|
407
|
+
color: ${colors.GREY_700};
|
|
408
|
+
`;
|
|
409
|
+
const ErrorDetailsContainer = styled.div`
|
|
410
|
+
display: flex;
|
|
411
|
+
flex-direction: column;
|
|
412
|
+
gap: 8px;
|
|
413
|
+
`;
|
|
414
|
+
const ErrorActionsContainer = styled.div`
|
|
415
|
+
display: flex;
|
|
416
|
+
justify-content: flex-end;
|
|
417
|
+
align-items: center;
|
|
418
|
+
gap: 8px;
|
|
419
|
+
`;
|
|
420
|
+
var ErrorBoundary = class extends Component {
|
|
421
|
+
state = {
|
|
422
|
+
id: generateId(),
|
|
423
|
+
hasError: false
|
|
424
|
+
};
|
|
425
|
+
disposeAutoReset;
|
|
426
|
+
static getDerivedStateFromError(e) {
|
|
427
|
+
const error = e instanceof Error ? e : new Error(typeof e === "object" && e !== null ? JSON.stringify(e) : String(e));
|
|
428
|
+
return {
|
|
429
|
+
id: generateId(),
|
|
430
|
+
hasError: true,
|
|
431
|
+
error
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
componentDidCatch(error, errorInfo) {
|
|
435
|
+
if (isEditMode()) root_store_default.editStore?.ai.handleRuntimeError({
|
|
436
|
+
id: this.state.id,
|
|
437
|
+
error: String(error),
|
|
438
|
+
errorInfo,
|
|
439
|
+
identifier: this.props.identifier
|
|
440
|
+
});
|
|
441
|
+
}
|
|
442
|
+
reset = () => {
|
|
443
|
+
if (isEditMode()) root_store_default.editStore?.ai.clearRuntimeError(this.state.id);
|
|
444
|
+
this.setState({
|
|
445
|
+
hasError: false,
|
|
446
|
+
error: void 0
|
|
447
|
+
});
|
|
448
|
+
};
|
|
449
|
+
componentWillUnmount() {
|
|
450
|
+
if (this.state.hasError && isEditMode()) root_store_default.editStore?.ai.clearRuntimeError(this.state.id);
|
|
451
|
+
this.disposeAutoReset?.();
|
|
452
|
+
}
|
|
453
|
+
handleFixWithClarkInitiated = () => {
|
|
454
|
+
const ai = root_store_default.editStore?.ai;
|
|
455
|
+
if (!ai) return;
|
|
456
|
+
this.disposeAutoReset?.();
|
|
457
|
+
this.disposeAutoReset = void 0;
|
|
458
|
+
let sawStart = ai.getIsEditing();
|
|
459
|
+
this.disposeAutoReset = reaction(() => ai.getIsEditing(), (isEditing) => {
|
|
460
|
+
if (!sawStart && isEditing) sawStart = true;
|
|
461
|
+
if (sawStart && !isEditing) {
|
|
462
|
+
this.reset();
|
|
463
|
+
this.disposeAutoReset?.();
|
|
464
|
+
this.disposeAutoReset = void 0;
|
|
465
|
+
}
|
|
466
|
+
}, {
|
|
467
|
+
fireImmediately: true,
|
|
468
|
+
name: "error-boundary-ai-auto-reset"
|
|
469
|
+
});
|
|
470
|
+
};
|
|
471
|
+
handleFixWithAi() {
|
|
472
|
+
const { identifier } = this.props;
|
|
473
|
+
if (identifier) editorBridge.addComponentToAiContext(identifier.sourceId, identifier.selectorId);
|
|
474
|
+
let prompt = `Fix this error: `;
|
|
475
|
+
if (this.state.error?.stack) {
|
|
476
|
+
const lines = this.state.error.stack.split("\n");
|
|
477
|
+
const nodeModulesIndex = lines.findIndex((line) => line.includes("node_modules"));
|
|
478
|
+
const relevantLines = nodeModulesIndex > -1 ? lines.slice(0, nodeModulesIndex) : lines;
|
|
479
|
+
prompt += relevantLines.slice(0, 5).join("\n");
|
|
480
|
+
} else prompt += this.state.error?.toString();
|
|
481
|
+
editorBridge.aiGenerate(prompt);
|
|
482
|
+
}
|
|
483
|
+
render() {
|
|
484
|
+
if (this.state.hasError) return /* @__PURE__ */ jsx(Observer, { children: () => {
|
|
485
|
+
if (root_store_default.editStore?.ai.getIsEditing() ?? false) return /* @__PURE__ */ jsx(SuspenseFallback, {});
|
|
486
|
+
return /* @__PURE__ */ jsxs(ErrorBoundaryContainer, { children: [/* @__PURE__ */ jsxs(ErrorDetailsContainer, {
|
|
487
|
+
"data-testid": "runtime-error-details",
|
|
488
|
+
children: [/* @__PURE__ */ jsx("h3", { children: this.props.header || "Something went wrong." }), /* @__PURE__ */ jsxs("details", {
|
|
489
|
+
style: { fontSize: "0.8em" },
|
|
490
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
491
|
+
style: { paddingLeft: "0.25rem" },
|
|
492
|
+
children: "Error details"
|
|
493
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
494
|
+
style: {
|
|
495
|
+
marginTop: "0.5rem",
|
|
496
|
+
maxWidth: "100%",
|
|
497
|
+
overflowX: "auto",
|
|
498
|
+
scrollbarWidth: "thin"
|
|
499
|
+
},
|
|
500
|
+
children: /* @__PURE__ */ jsx("pre", {
|
|
501
|
+
style: { color: "gray" },
|
|
502
|
+
children: /* @__PURE__ */ jsx("code", { children: this.state.error?.stack ? this.state.error.stack : this.state.error?.toString() })
|
|
503
|
+
})
|
|
504
|
+
})]
|
|
505
|
+
})]
|
|
506
|
+
}), /* @__PURE__ */ jsxs(ErrorActionsContainer, { children: [isEditMode() && /* @__PURE__ */ jsx(FixWithClarkButton, {
|
|
507
|
+
onClick: this.handleFixWithClarkInitiated,
|
|
508
|
+
error: this.state.error,
|
|
509
|
+
identifier: this.props.identifier
|
|
510
|
+
}), /* @__PURE__ */ jsx(SecondaryButton, {
|
|
511
|
+
onClick: this.reset,
|
|
512
|
+
children: "Try again"
|
|
513
|
+
})] })] });
|
|
514
|
+
} });
|
|
515
|
+
return this.props.children;
|
|
516
|
+
}
|
|
517
|
+
};
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/lib/utils/widget-wrapper-naming.ts
|
|
520
|
+
const getWidgetAnchorName = (selectorId) => {
|
|
521
|
+
return `--widget-${selectorId}`;
|
|
522
|
+
};
|
|
523
|
+
const getWidgetRectAnchorName = (selectorId) => {
|
|
524
|
+
return `--widget-rect-${selectorId}`;
|
|
525
|
+
};
|
|
526
|
+
//#endregion
|
|
527
|
+
//#region src/edit-mode/edit-wrapper.tsx
|
|
528
|
+
if (typeof window !== "undefined" && typeof document.documentElement !== "undefined" && !("anchorName" in document.documentElement.style)) polyfill();
|
|
529
|
+
const createAnchorNameStyle = (props) => {
|
|
530
|
+
return { "--anchor-name": getWidgetAnchorName(props.selectorId) };
|
|
531
|
+
};
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/edit-mode/instance-tracker.ts
|
|
534
|
+
/**
|
|
535
|
+
* Tracks and recycles instance numbers for each sourceId to generate stable, unique selector IDs.
|
|
536
|
+
* When components unmount, their instance numbers are released and can be reused.
|
|
537
|
+
*/
|
|
538
|
+
var InstanceTracker = class {
|
|
539
|
+
sourceIdToUsedInstances = /* @__PURE__ */ new Map();
|
|
540
|
+
getNextAvailableInstance(sourceId) {
|
|
541
|
+
const usedInstances = this.sourceIdToUsedInstances.get(sourceId) ?? /* @__PURE__ */ new Set();
|
|
542
|
+
let instance = 0;
|
|
543
|
+
while (usedInstances.has(instance)) instance++;
|
|
544
|
+
usedInstances.add(instance);
|
|
545
|
+
this.sourceIdToUsedInstances.set(sourceId, usedInstances);
|
|
546
|
+
return instance;
|
|
547
|
+
}
|
|
548
|
+
releaseInstance(sourceId, instance) {
|
|
549
|
+
const usedInstances = this.sourceIdToUsedInstances.get(sourceId);
|
|
550
|
+
if (usedInstances) {
|
|
551
|
+
usedInstances.delete(instance);
|
|
552
|
+
if (usedInstances.size === 0) this.sourceIdToUsedInstances.delete(sourceId);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
const instanceTracker = new InstanceTracker();
|
|
557
|
+
//#endregion
|
|
558
|
+
//#region src/edit-mode/jsx-wrapper.tsx
|
|
559
|
+
const JSXContext = React.createContext({
|
|
560
|
+
selectorId: "S-<unknown>",
|
|
561
|
+
sourceId: "SB-<unknown>"
|
|
562
|
+
});
|
|
563
|
+
const makeWrappedComponent = (type) => {
|
|
564
|
+
const isTag = typeof type === "string";
|
|
565
|
+
const isRegisteredSbComponent = root_store_default.componentRegistry.hasComponent(type);
|
|
566
|
+
const Component = React.forwardRef((props, ref) => {
|
|
567
|
+
const { selectorId: parentSelectorId } = useJSXContext();
|
|
568
|
+
const sourceId = props[SOURCE_ID_ATTRIBUTE];
|
|
569
|
+
const noSelect = props[NO_SELECT_ATTRIBUTE];
|
|
570
|
+
const instanceNumberRef = useRef();
|
|
571
|
+
const selectorId = useRef("S-<unknown>");
|
|
572
|
+
if (selectorId.current === "S-<unknown>") {
|
|
573
|
+
instanceNumberRef.current = instanceTracker.getNextAvailableInstance(sourceId);
|
|
574
|
+
selectorId.current = `S-x-${sourceId}-${instanceNumberRef.current}`;
|
|
575
|
+
}
|
|
576
|
+
useEffect(() => {
|
|
577
|
+
root_store_default.editStore?.runtimeTrackingStore.registerComponent(selectorId.current, {
|
|
578
|
+
sourceId,
|
|
579
|
+
type,
|
|
580
|
+
parentSelectorId,
|
|
581
|
+
isSbComponent: isRegisteredSbComponent,
|
|
582
|
+
isHtmlElement: isTag,
|
|
583
|
+
noSelect
|
|
584
|
+
});
|
|
585
|
+
return () => {
|
|
586
|
+
root_store_default.editStore?.runtimeTrackingStore.unregisterComponent(selectorId.current);
|
|
587
|
+
if (instanceNumberRef.current !== void 0) instanceTracker.releaseInstance(sourceId, instanceNumberRef.current);
|
|
588
|
+
};
|
|
589
|
+
}, []);
|
|
590
|
+
useEffect(() => {
|
|
591
|
+
root_store_default.editStore?.runtimeTrackingStore.updatePropsForComponent(selectorId.current, props);
|
|
592
|
+
}, [props]);
|
|
593
|
+
const jsxContext = useMemo(() => ({
|
|
594
|
+
selectorId: selectorId.current,
|
|
595
|
+
sourceId
|
|
596
|
+
}), [sourceId]);
|
|
597
|
+
const selectorProps = { [SELECTOR_ID_ATTRIBUTE]: selectorId.current };
|
|
598
|
+
if (parentSelectorId) selectorProps["data-sb-parent-selector-id"] = parentSelectorId;
|
|
599
|
+
const { style: propsStyle, className: propsClassName } = props;
|
|
600
|
+
const style = useMemo(() => {
|
|
601
|
+
return {
|
|
602
|
+
...propsStyle,
|
|
603
|
+
...createAnchorNameStyle({ selectorId: selectorId.current })
|
|
604
|
+
};
|
|
605
|
+
}, [propsStyle]);
|
|
606
|
+
const className = useMemo(() => {
|
|
607
|
+
return typeof propsClassName === "function" ? (...args) => ["sb-anchor-name", propsClassName(...args)].filter(Boolean).join(" ") : ["sb-anchor-name", propsClassName].filter(Boolean).join(" ");
|
|
608
|
+
}, [propsClassName]);
|
|
609
|
+
const element = React.createElement(type, {
|
|
610
|
+
ref,
|
|
611
|
+
...props,
|
|
612
|
+
...selectorProps,
|
|
613
|
+
className,
|
|
614
|
+
style
|
|
615
|
+
});
|
|
616
|
+
if (!root_store_default.editStore?.isInitialized) return /* @__PURE__ */ jsx(JSXContext.Provider, {
|
|
617
|
+
value: jsxContext,
|
|
618
|
+
children: element
|
|
619
|
+
});
|
|
620
|
+
return /* @__PURE__ */ jsx(JSXContext.Provider, {
|
|
621
|
+
value: jsxContext,
|
|
622
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: element })
|
|
623
|
+
});
|
|
624
|
+
});
|
|
625
|
+
try {
|
|
626
|
+
Component.displayName = typeof type === "string" ? type : type.displayName || type.name || "Component";
|
|
627
|
+
} catch (e) {
|
|
628
|
+
console.error("Error setting displayName", e);
|
|
629
|
+
}
|
|
630
|
+
return Component;
|
|
631
|
+
};
|
|
632
|
+
const useJSXContext = () => {
|
|
633
|
+
return React.useContext(JSXContext);
|
|
634
|
+
};
|
|
635
|
+
//#endregion
|
|
636
|
+
export { FixWithClarkButton as a, ErrorContent as c, ErrorMessage as d, ErrorStack as f, StyledClarkIcon as g, SecondaryButton as h, getWidgetRectAnchorName as i, ErrorDetails as l, ErrorTitle as m, useJSXContext as n, ActionsContainer as o, ErrorSummary as p, getWidgetAnchorName as r, ErrorContainer as s, makeWrappedComponent as t, ErrorIconContainer as u };
|
|
637
|
+
|
|
638
|
+
//# sourceMappingURL=jsx-wrapper-c5W52jgK.js.map
|