@superblocksteam/library 2.0.174-next.0 → 2.0.175-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-tU0L2vSJ.js +5 -0
- package/dist/{build-manifest-BQAcrmit.js.map → build-manifest-tU0L2vSJ.js.map} +1 -1
- package/dist/{devtools-consolidated-C5sXwPGD.js → devtools-consolidated-DLnb73OV.js} +3 -5
- package/dist/{devtools-consolidated-C5sXwPGD.js.map → devtools-consolidated-DLnb73OV.js.map} +1 -1
- package/dist/{early-console-buffer-DMR1SCsN.js → early-console-buffer-B88uX-DV.js} +4 -5
- package/dist/{early-console-buffer-DMR1SCsN.js.map → early-console-buffer-B88uX-DV.js.map} +1 -1
- package/dist/jsx-dev-runtime/index.d.ts +2 -7
- package/dist/jsx-dev-runtime/index.d.ts.map +1 -1
- package/dist/jsx-dev-runtime/index.js +3 -6
- package/dist/jsx-dev-runtime/index.js.map +1 -1
- package/dist/jsx-runtime/index.d.ts +3 -6
- package/dist/jsx-runtime/index.d.ts.map +1 -1
- package/dist/jsx-runtime/index.js +1 -2
- package/dist/{root-store-G9HJE1Mf.js → jsx-wrapper-BAO7prWO.js} +771 -107
- package/dist/jsx-wrapper-BAO7prWO.js.map +1 -0
- package/dist/lib/index.d.ts +72 -179
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +311 -378
- package/dist/lib/index.js.map +1 -1
- package/dist/{logs-CUUgkcJf.js → logs-rwNn0yg7.js} +13 -13
- package/dist/{logs-CUUgkcJf.js.map → logs-rwNn0yg7.js.map} +1 -1
- package/dist/{sdk-api-discovery-_lfMr9d5.js → sdk-api-discovery-CtyMcIGP.js} +8 -12
- package/dist/{sdk-api-discovery-_lfMr9d5.js.map → sdk-api-discovery-CtyMcIGP.js.map} +1 -1
- package/package.json +36 -42
- package/dist/build-manifest-BQAcrmit.js +0 -6
- package/dist/jsx-wrapper-B0I9j3Al.js +0 -639
- package/dist/jsx-wrapper-B0I9j3Al.js.map +0 -1
- package/dist/rolldown-runtime-CiIaOW0V.js +0 -13
- package/dist/root-store-G9HJE1Mf.js.map +0 -1
- package/dist/utils-DXaAwgS_.js +0 -61
- package/dist/utils-DXaAwgS_.js.map +0 -1
|
@@ -1,19 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { initBrowserMetrics } from "@superblocksteam/telemetry/browser";
|
|
2
2
|
import { action, entries, isComputedProp, isObservableArray, isObservableMap, isObservableObject, makeAutoObservable, makeObservable, observable, observe, reaction, toJS, values } from "mobx";
|
|
3
3
|
import { matchRoutes } from "react-router";
|
|
4
|
-
import { URL_PARAMS, getQueryParams, pathStringToArray, toMobXPatch } from "@superblocksteam/library-shared";
|
|
4
|
+
import { NO_SELECT_ATTRIBUTE, SELECTOR_ID_ATTRIBUTE, SOURCE_ID_ATTRIBUTE, URL_PARAMS, getQueryParams, pathStringToArray, toMobXPatch } from "@superblocksteam/library-shared";
|
|
5
5
|
import * as React$1 from "react";
|
|
6
|
-
import { createContext, isValidElement, useCallback, useContext, useMemo, useSyncExternalStore } from "react";
|
|
7
|
-
import {
|
|
8
|
-
import { ApiResponseType,
|
|
9
|
-
import isString from "lodash/isString.js";
|
|
6
|
+
import React, { Component, createContext, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
7
|
+
import { throttle } from "lodash-es";
|
|
8
|
+
import { ApiResponseType, SUPERBLOCKS_AUTHORIZATION_HEADER, SUPERBLOCKS_REQUEST_ID_HEADER, ViewMode, decodeBytestrings } from "@superblocksteam/shared";
|
|
10
9
|
import { toast } from "sonner";
|
|
11
|
-
import styled from "styled-components";
|
|
10
|
+
import styled, { keyframes } from "styled-components";
|
|
12
11
|
import { NotificationPosition } from "@superblocksteam/library-shared/types";
|
|
13
|
-
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
13
|
import { ROOT_CONTEXT, context, propagation, trace } from "@opentelemetry/api";
|
|
14
|
+
import { CompositePropagator, W3CBaggagePropagator, W3CTraceContextPropagator } from "@opentelemetry/core";
|
|
15
|
+
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
16
|
+
import { resourceFromAttributes } from "@opentelemetry/resources";
|
|
17
|
+
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
18
|
+
import { WebTracerProvider } from "@opentelemetry/sdk-trace-web";
|
|
19
|
+
import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
|
|
15
20
|
import diff from "microdiff";
|
|
16
|
-
|
|
21
|
+
import { Observer } from "mobx-react-lite";
|
|
22
|
+
// \0rolldown/runtime.js
|
|
23
|
+
var __defProp = Object.defineProperty;
|
|
24
|
+
var __exportAll = (all, no_symbols) => {
|
|
25
|
+
let target = {};
|
|
26
|
+
for (var name in all) __defProp(target, name, {
|
|
27
|
+
get: all[name],
|
|
28
|
+
enumerable: true
|
|
29
|
+
});
|
|
30
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
// src/lib/internal-details/is-edit-mode.ts
|
|
17
34
|
const getIsEditMode = () => {
|
|
18
35
|
return window._SB_VIEW_MODE === "dev";
|
|
19
36
|
};
|
|
@@ -22,8 +39,7 @@ const isEditMode = () => {
|
|
|
22
39
|
if (editMode === void 0) editMode = getIsEditMode();
|
|
23
40
|
return editMode;
|
|
24
41
|
};
|
|
25
|
-
|
|
26
|
-
//#region src/lib/utils/clean-object.ts
|
|
42
|
+
// src/lib/utils/clean-object.ts
|
|
27
43
|
const isReactElement = (obj) => {
|
|
28
44
|
return obj && (obj.$$typeof === Symbol.for("react.element") || isValidElement(obj) || typeof Node !== "undefined" && obj instanceof Node);
|
|
29
45
|
};
|
|
@@ -60,8 +76,7 @@ function cleanObject(obj) {
|
|
|
60
76
|
return acc;
|
|
61
77
|
}, {});
|
|
62
78
|
}
|
|
63
|
-
|
|
64
|
-
//#region src/lib/internal-details/lib/iframe.ts
|
|
79
|
+
// src/lib/internal-details/lib/iframe.ts
|
|
65
80
|
function isEmbeddedBySuperblocksFirstParty() {
|
|
66
81
|
return typeof window !== "undefined" && window !== window.parent;
|
|
67
82
|
}
|
|
@@ -129,8 +144,7 @@ var SbIframeEventInternal = class extends Event {
|
|
|
129
144
|
};
|
|
130
145
|
var SbMessageHandler = class extends EventTarget {};
|
|
131
146
|
const iframeMessageHandler = new SbMessageHandler();
|
|
132
|
-
|
|
133
|
-
//#region src/edit-mode/base-editor-bridge.ts
|
|
147
|
+
// src/edit-mode/base-editor-bridge.ts
|
|
134
148
|
var DeployedParentBridge = class {
|
|
135
149
|
navigateTo(url, newWindow) {
|
|
136
150
|
sendMessageImmediately({
|
|
@@ -191,8 +205,7 @@ var DeployedParentBridge = class {
|
|
|
191
205
|
});
|
|
192
206
|
}
|
|
193
207
|
};
|
|
194
|
-
|
|
195
|
-
//#region src/edit-mode/get-edit-store.ts
|
|
208
|
+
// src/edit-mode/get-edit-store.ts
|
|
196
209
|
/**
|
|
197
210
|
* Get the global EditStore instance
|
|
198
211
|
* @returns The EditStore instance
|
|
@@ -201,8 +214,7 @@ function getEditStore() {
|
|
|
201
214
|
if (!window.__SUPERBLOCKS_EDITOR_HOOK__ || !window.__SUPERBLOCKS_EDITOR_HOOK__.isInitialized) throw new Error("EditStore not initialized");
|
|
202
215
|
return window.__SUPERBLOCKS_EDITOR_HOOK__;
|
|
203
216
|
}
|
|
204
|
-
|
|
205
|
-
//#region src/edit-mode/load-timings.ts
|
|
217
|
+
// src/edit-mode/load-timings.ts
|
|
206
218
|
const MARK_PREFIX = "sb-load:";
|
|
207
219
|
const SLOWEST_RESOURCE_COUNT = 5;
|
|
208
220
|
/** Records the first time this iframe document reaches a load milestone. */
|
|
@@ -265,8 +277,7 @@ function summarizeLoadTimings(input) {
|
|
|
265
277
|
}))
|
|
266
278
|
};
|
|
267
279
|
}
|
|
268
|
-
|
|
269
|
-
//#region src/edit-mode/message-queue.ts
|
|
280
|
+
// src/edit-mode/message-queue.ts
|
|
270
281
|
const MESSAGE_BATCH_TIME = 50;
|
|
271
282
|
const DEFAULT_KEY = "default";
|
|
272
283
|
var MessageQueue = class {
|
|
@@ -295,8 +306,7 @@ var MessageQueue = class {
|
|
|
295
306
|
}
|
|
296
307
|
};
|
|
297
308
|
var message_queue_default = new MessageQueue();
|
|
298
|
-
|
|
299
|
-
//#region src/edit-mode/superblocks-editor-bridge.ts
|
|
309
|
+
// src/edit-mode/superblocks-editor-bridge.ts
|
|
300
310
|
var SuperblocksEditorBridge = class SuperblocksEditorBridge {
|
|
301
311
|
static instance;
|
|
302
312
|
messagesToSend = [];
|
|
@@ -656,12 +666,11 @@ const MAX_AI_PROMPT_LENGTH = 16e3;
|
|
|
656
666
|
const TRUNCATION_SUFFIX = "... (truncated)";
|
|
657
667
|
function clampPromptLength(prompt) {
|
|
658
668
|
if (prompt.length <= MAX_AI_PROMPT_LENGTH) return prompt;
|
|
659
|
-
const available = Math.max(
|
|
669
|
+
const available = Math.max(15985, 0);
|
|
660
670
|
return `${prompt.slice(0, available)}${TRUNCATION_SUFFIX}`;
|
|
661
671
|
}
|
|
662
672
|
const editorBridge = SuperblocksEditorBridge.getInstance();
|
|
663
|
-
|
|
664
|
-
//#region src/lib/internal-details/location-store.ts
|
|
673
|
+
// src/lib/internal-details/location-store.ts
|
|
665
674
|
var LocationStore = class {
|
|
666
675
|
route;
|
|
667
676
|
rootStore;
|
|
@@ -707,106 +716,101 @@ var LocationStore = class {
|
|
|
707
716
|
};
|
|
708
717
|
}
|
|
709
718
|
};
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
return _extends$3 = Object.assign ? Object.assign.bind() : function(n) {
|
|
719
|
+
// src/lib/user-facing/assets/icons/system-danger.svg
|
|
720
|
+
var _path$5;
|
|
721
|
+
function _extends$5() {
|
|
722
|
+
return _extends$5 = Object.assign ? Object.assign.bind() : function(n) {
|
|
715
723
|
for (var e = 1; e < arguments.length; e++) {
|
|
716
724
|
var t = arguments[e];
|
|
717
725
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
718
726
|
}
|
|
719
727
|
return n;
|
|
720
|
-
}, _extends$
|
|
728
|
+
}, _extends$5.apply(null, arguments);
|
|
721
729
|
}
|
|
722
730
|
var SvgSystemDanger = function SvgSystemDanger(props) {
|
|
723
|
-
return
|
|
731
|
+
return /*#__PURE__*/ React$1.createElement("svg", _extends$5({
|
|
724
732
|
xmlns: "http://www.w3.org/2000/svg",
|
|
725
733
|
width: 16,
|
|
726
734
|
height: 16,
|
|
727
735
|
fill: "none"
|
|
728
|
-
}, props), _path$
|
|
736
|
+
}, props), _path$5 || (_path$5 = /*#__PURE__*/ React$1.createElement("path", {
|
|
729
737
|
fill: "currentColor",
|
|
730
738
|
fillRule: "evenodd",
|
|
731
739
|
d: "M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m.75-10a.75.75 0 0 0-1.5 0v3a.75.75 0 1 0 1.5 0zM8 9.75a1 1 0 1 0 0 2 1 1 0 0 0 0-2",
|
|
732
740
|
clipRule: "evenodd"
|
|
733
741
|
})));
|
|
734
742
|
};
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
return _extends$2 = Object.assign ? Object.assign.bind() : function(n) {
|
|
743
|
+
// src/lib/user-facing/assets/icons/system-error.svg
|
|
744
|
+
var _path$4;
|
|
745
|
+
function _extends$4() {
|
|
746
|
+
return _extends$4 = Object.assign ? Object.assign.bind() : function(n) {
|
|
740
747
|
for (var e = 1; e < arguments.length; e++) {
|
|
741
748
|
var t = arguments[e];
|
|
742
749
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
743
750
|
}
|
|
744
751
|
return n;
|
|
745
|
-
}, _extends$
|
|
752
|
+
}, _extends$4.apply(null, arguments);
|
|
746
753
|
}
|
|
747
754
|
var SvgSystemError = function SvgSystemError(props) {
|
|
748
|
-
return
|
|
755
|
+
return /*#__PURE__*/ React$1.createElement("svg", _extends$4({
|
|
749
756
|
xmlns: "http://www.w3.org/2000/svg",
|
|
750
757
|
width: 16,
|
|
751
758
|
height: 16,
|
|
752
759
|
fill: "none"
|
|
753
|
-
}, props), _path$
|
|
760
|
+
}, props), _path$4 || (_path$4 = /*#__PURE__*/ React$1.createElement("path", {
|
|
754
761
|
fill: "currentColor",
|
|
755
762
|
fillRule: "evenodd",
|
|
756
763
|
d: "M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0M5.942 5.058a.625.625 0 1 0-.884.884L7.116 8l-2.058 2.058a.625.625 0 1 0 .884.884L8 8.884l2.058 2.058a.625.625 0 1 0 .884-.884L8.884 8l2.058-2.058a.625.625 0 1 0-.884-.884L8 7.116z",
|
|
757
764
|
clipRule: "evenodd"
|
|
758
765
|
})));
|
|
759
766
|
};
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
|
|
767
|
+
// src/lib/user-facing/assets/icons/system-info.svg
|
|
768
|
+
var _path$3;
|
|
769
|
+
function _extends$3() {
|
|
770
|
+
return _extends$3 = Object.assign ? Object.assign.bind() : function(n) {
|
|
765
771
|
for (var e = 1; e < arguments.length; e++) {
|
|
766
772
|
var t = arguments[e];
|
|
767
773
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
768
774
|
}
|
|
769
775
|
return n;
|
|
770
|
-
}, _extends$
|
|
776
|
+
}, _extends$3.apply(null, arguments);
|
|
771
777
|
}
|
|
772
778
|
var SvgSystemInfo = function SvgSystemInfo(props) {
|
|
773
|
-
return
|
|
779
|
+
return /*#__PURE__*/ React$1.createElement("svg", _extends$3({
|
|
774
780
|
xmlns: "http://www.w3.org/2000/svg",
|
|
775
781
|
width: 16,
|
|
776
782
|
height: 16,
|
|
777
783
|
fill: "none"
|
|
778
|
-
}, props), _path$
|
|
784
|
+
}, props), _path$3 || (_path$3 = /*#__PURE__*/ React$1.createElement("path", {
|
|
779
785
|
fill: "currentColor",
|
|
780
786
|
d: "M8 1a7 7 0 1 0 7 7 7.014 7.014 0 0 0-7-7m-.135 3.23a.808.808 0 1 1 0 1.616.808.808 0 0 1 0-1.615m.673 7.54H8a.54.54 0 0 1-.538-.54V8a.538.538 0 1 1 0-1.077H8a.54.54 0 0 1 .538.539v3.23a.538.538 0 1 1 0 1.077"
|
|
781
787
|
})));
|
|
782
788
|
};
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
789
|
+
// src/lib/user-facing/assets/icons/system-success.svg
|
|
790
|
+
var _path$2;
|
|
791
|
+
function _extends$2() {
|
|
792
|
+
return _extends$2 = Object.assign ? Object.assign.bind() : function(n) {
|
|
788
793
|
for (var e = 1; e < arguments.length; e++) {
|
|
789
794
|
var t = arguments[e];
|
|
790
795
|
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
791
796
|
}
|
|
792
797
|
return n;
|
|
793
|
-
}, _extends.apply(null, arguments);
|
|
798
|
+
}, _extends$2.apply(null, arguments);
|
|
794
799
|
}
|
|
795
800
|
var SvgSystemSuccess = function SvgSystemSuccess(props) {
|
|
796
|
-
return
|
|
801
|
+
return /*#__PURE__*/ React$1.createElement("svg", _extends$2({
|
|
797
802
|
xmlns: "http://www.w3.org/2000/svg",
|
|
798
803
|
width: 16,
|
|
799
804
|
height: 16,
|
|
800
805
|
fill: "none"
|
|
801
|
-
}, props), _path || (_path =
|
|
806
|
+
}, props), _path$2 || (_path$2 = /*#__PURE__*/ React$1.createElement("path", {
|
|
802
807
|
fill: "currentColor",
|
|
803
808
|
fillRule: "evenodd",
|
|
804
809
|
d: "M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m3.442-8.058a.625.625 0 1 0-.884-.884L7.5 9.116 5.942 7.558a.625.625 0 1 0-.884.884l2 2c.244.244.64.244.884 0z",
|
|
805
810
|
clipRule: "evenodd"
|
|
806
811
|
})));
|
|
807
812
|
};
|
|
808
|
-
|
|
809
|
-
//#region src/lib/user-facing/styling/colors.ts
|
|
813
|
+
// src/lib/user-facing/styling/colors.ts
|
|
810
814
|
const colors = {
|
|
811
815
|
WHITE: "#FFFFFF",
|
|
812
816
|
BLACK: "#000000",
|
|
@@ -936,8 +940,7 @@ const CLASS_NAMES = {
|
|
|
936
940
|
CODE_EDITOR: "sb-code-editor",
|
|
937
941
|
ERROR_INLINE_MESSAGE: "sb-error-inline-message"
|
|
938
942
|
};
|
|
939
|
-
|
|
940
|
-
//#region src/lib/user-facing/utils/notification.tsx
|
|
943
|
+
// src/lib/user-facing/utils/notification.tsx
|
|
941
944
|
const activeNotifications = /* @__PURE__ */ new Map();
|
|
942
945
|
const StatusIconWrapper = styled.div`
|
|
943
946
|
color: ${(props) => props.color};
|
|
@@ -980,7 +983,7 @@ const messageWithCount = (key, message, dataTest) => {
|
|
|
980
983
|
count,
|
|
981
984
|
message
|
|
982
985
|
});
|
|
983
|
-
if (count > 1 &&
|
|
986
|
+
if (count > 1 && typeof message === "string") updatedMessage = `${message} (${count} times)`;
|
|
984
987
|
}
|
|
985
988
|
return styleMessage(updatedMessage, dataTest);
|
|
986
989
|
};
|
|
@@ -990,7 +993,7 @@ const messageWithCount = (key, message, dataTest) => {
|
|
|
990
993
|
* @returns A string key based on inputs
|
|
991
994
|
*/
|
|
992
995
|
const getKey = (type, message, description, duration) => {
|
|
993
|
-
return
|
|
996
|
+
return typeof message === "string" ? `${type}--${String(message)}--${description}--${duration}` : void 0;
|
|
994
997
|
};
|
|
995
998
|
const removeNotificationsWithKey = (key) => {
|
|
996
999
|
document.querySelectorAll(`[data-testid="notification_${key}"]`).forEach((el) => {
|
|
@@ -1019,7 +1022,6 @@ const getIcon = (type) => {
|
|
|
1019
1022
|
case "warning":
|
|
1020
1023
|
icon = /* @__PURE__ */ jsx(SvgSystemDanger, {});
|
|
1021
1024
|
color = colors.WARNING;
|
|
1022
|
-
break;
|
|
1023
1025
|
}
|
|
1024
1026
|
return /* @__PURE__ */ jsx(StatusIconWrapper, {
|
|
1025
1027
|
color,
|
|
@@ -1060,13 +1062,11 @@ function sendNotification({ message, description, duration, key = getKey("succes
|
|
|
1060
1062
|
onAutoClose: handleClose
|
|
1061
1063
|
});
|
|
1062
1064
|
}
|
|
1063
|
-
|
|
1064
|
-
//#region src/lib/utils/generate-id.ts
|
|
1065
|
+
// src/lib/utils/generate-id.ts
|
|
1065
1066
|
const generateId = () => {
|
|
1066
1067
|
return Math.random().toString(36).substring(2, 15);
|
|
1067
1068
|
};
|
|
1068
|
-
|
|
1069
|
-
//#region src/lib/internal-details/embed-store.ts
|
|
1069
|
+
// src/lib/internal-details/embed-store.ts
|
|
1070
1070
|
/**
|
|
1071
1071
|
* Store for managing embed properties and events.
|
|
1072
1072
|
* Used when the library is embedded in an external application (third-party embedding).
|
|
@@ -1117,15 +1117,13 @@ var EmbedStore = class {
|
|
|
1117
1117
|
}
|
|
1118
1118
|
};
|
|
1119
1119
|
const embedStore = new EmbedStore();
|
|
1120
|
-
|
|
1121
|
-
//#region src/lib/internal-details/scope/types.ts
|
|
1120
|
+
// src/lib/internal-details/scope/types.ts
|
|
1122
1121
|
const AppMode = {
|
|
1123
1122
|
EDIT: "EDIT",
|
|
1124
1123
|
PUBLISHED: "PUBLISHED",
|
|
1125
1124
|
PREVIEW: "PREVIEW"
|
|
1126
1125
|
};
|
|
1127
|
-
|
|
1128
|
-
//#region src/lib/internal-details/superblocks-context.tsx
|
|
1126
|
+
// src/lib/internal-details/superblocks-context.tsx
|
|
1129
1127
|
var SuperblocksAppContext = class {
|
|
1130
1128
|
context;
|
|
1131
1129
|
constructor() {
|
|
@@ -1226,8 +1224,7 @@ function getAppMode() {
|
|
|
1226
1224
|
}
|
|
1227
1225
|
return appMode;
|
|
1228
1226
|
}
|
|
1229
|
-
|
|
1230
|
-
//#region src/lib/internal-details/lib/resolve-id-singleton.ts
|
|
1227
|
+
// src/lib/internal-details/lib/resolve-id-singleton.ts
|
|
1231
1228
|
const EMBED_STRING = `embedded-`;
|
|
1232
1229
|
let promiseCount = 0;
|
|
1233
1230
|
const resolverMap = /* @__PURE__ */ new Map();
|
|
@@ -1331,8 +1328,55 @@ const tracker = new class ApiHmrTracker {
|
|
|
1331
1328
|
if (import.meta.hot) import.meta.hot.on("vite:beforeUpdate", () => {
|
|
1332
1329
|
tracker.incReloadCount();
|
|
1333
1330
|
});
|
|
1334
|
-
|
|
1335
|
-
|
|
1331
|
+
// src/lib/utils.ts
|
|
1332
|
+
var utils_exports = /* @__PURE__ */ __exportAll({
|
|
1333
|
+
getTracer: () => getTracer,
|
|
1334
|
+
initTracerProviderWithOrigin: () => initTracerProviderWithOrigin
|
|
1335
|
+
});
|
|
1336
|
+
const serviceName = "superblocks-ui-framework";
|
|
1337
|
+
let otlpEndpoint = void 0;
|
|
1338
|
+
const otlpPath = "/api/v1/traces";
|
|
1339
|
+
let metricsInitialized = false;
|
|
1340
|
+
let currentProvider;
|
|
1341
|
+
const ATTR_DEPLOYMENT_ENVIRONMENT_NAME = "deployment.environment.name";
|
|
1342
|
+
function initTracerProviderWithOrigin(windowOriginUrl) {
|
|
1343
|
+
otlpEndpoint = windowOriginUrl + otlpPath;
|
|
1344
|
+
const resource = resourceFromAttributes({
|
|
1345
|
+
[ATTR_DEPLOYMENT_ENVIRONMENT_NAME]: getEnvironmentFromHostname(new URL(windowOriginUrl).hostname),
|
|
1346
|
+
[ATTR_SERVICE_NAME]: serviceName
|
|
1347
|
+
});
|
|
1348
|
+
if (!metricsInitialized) {
|
|
1349
|
+
initBrowserMetrics({
|
|
1350
|
+
otlpUrl: windowOriginUrl + "/api/v1/metrics",
|
|
1351
|
+
resource,
|
|
1352
|
+
serviceName
|
|
1353
|
+
});
|
|
1354
|
+
metricsInitialized = true;
|
|
1355
|
+
}
|
|
1356
|
+
console.debug("Initializing direct OTLP tracer provider for iframe to:", otlpEndpoint);
|
|
1357
|
+
const provider = new WebTracerProvider({
|
|
1358
|
+
resource,
|
|
1359
|
+
spanProcessors: [new BatchSpanProcessor(new OTLPTraceExporter({ url: otlpEndpoint }))]
|
|
1360
|
+
});
|
|
1361
|
+
provider.register({ propagator: new CompositePropagator({ propagators: [new W3CBaggagePropagator(), new W3CTraceContextPropagator()] }) });
|
|
1362
|
+
currentProvider = provider;
|
|
1363
|
+
console.debug("Direct OTLP tracing initialized for iframe with dynamic origin");
|
|
1364
|
+
return provider;
|
|
1365
|
+
}
|
|
1366
|
+
function getEnvironmentFromHostname(hostname) {
|
|
1367
|
+
if (hostname.match(/^app\.superblocks(?:hq)?\.com/)) return "prod";
|
|
1368
|
+
else if (hostname.match(/^eu\.superblocks(?:hq)?\.com/)) return "prod-eu";
|
|
1369
|
+
else if (hostname.match(/^staging\.superblocks(?:hq)?\.com/)) return "staging";
|
|
1370
|
+
else if (hostname.match(/^dev\.superblocks(?:hq)?\.com/)) return "dev";
|
|
1371
|
+
else if (hostname.match(/^pr-[0-9]+(?:-cp)?\.superblocks(?:hq)?\.dev/)) return "ephemeral";
|
|
1372
|
+
else if (hostname.match(/^localhost/)) return "local";
|
|
1373
|
+
else return "other";
|
|
1374
|
+
}
|
|
1375
|
+
function getTracer(name) {
|
|
1376
|
+
if (!currentProvider) console.error("Tracer provider not initialized. Call initTracerProviderWithOrigin() first with a valid windowOriginUrl. Tracing will be disabled.");
|
|
1377
|
+
return trace.getTracer(name || serviceName);
|
|
1378
|
+
}
|
|
1379
|
+
// src/lib/tracing/context-utils.ts
|
|
1336
1380
|
function getContextFromTraceHeaders(traceHeaders) {
|
|
1337
1381
|
let parentContext = context.active();
|
|
1338
1382
|
try {
|
|
@@ -1351,8 +1395,7 @@ function getTraceContextHeadersFromSpan(span) {
|
|
|
1351
1395
|
propagation.inject(contextWithSpan, traceContextHeaders);
|
|
1352
1396
|
return traceContextHeaders;
|
|
1353
1397
|
}
|
|
1354
|
-
|
|
1355
|
-
//#region src/lib/internal-details/lib/features/api-utils.ts
|
|
1398
|
+
// src/lib/internal-details/lib/features/api-utils.ts
|
|
1356
1399
|
async function executeV2Api(params) {
|
|
1357
1400
|
const { body, apiName, controlFlowOnlyFiles, notifyOnSystemError, eventType, onMessage, processStreamEvents, responseType, abortController, baseUrl, viewMode, accessToken, token, maxResponseBytes, traceHeaders } = params;
|
|
1358
1401
|
let parentContext = context.active();
|
|
@@ -1685,6 +1728,7 @@ const boundRunRecordStepLogs = (stepLogs, reuse) => {
|
|
|
1685
1728
|
};
|
|
1686
1729
|
};
|
|
1687
1730
|
var ResponseSizeLimitError = class extends Error {
|
|
1731
|
+
limitBytes;
|
|
1688
1732
|
constructor(limitBytes) {
|
|
1689
1733
|
super(`Response blocked: exceeded orchestrator /execute response limit of ${limitBytes} bytes.`);
|
|
1690
1734
|
this.limitBytes = limitBytes;
|
|
@@ -1766,8 +1810,7 @@ const decodeBytestringsInV2ExecutionResponse = (response) => {
|
|
|
1766
1810
|
if (typedEvent?.end?.output?.result != null) typedEvent.end.output.result = decodeBytestrings(typedEvent.end.output.result, false);
|
|
1767
1811
|
});
|
|
1768
1812
|
};
|
|
1769
|
-
|
|
1770
|
-
//#region src/lib/internal-details/lib/features/file-utils.ts
|
|
1813
|
+
// src/lib/internal-details/lib/features/file-utils.ts
|
|
1771
1814
|
function isNativeFile(value) {
|
|
1772
1815
|
return typeof File !== "undefined" && value instanceof File;
|
|
1773
1816
|
}
|
|
@@ -1841,8 +1884,7 @@ async function getInputsWithFileMetadata(inputs) {
|
|
|
1841
1884
|
files: Object.values(filesForRequest)
|
|
1842
1885
|
};
|
|
1843
1886
|
}
|
|
1844
|
-
|
|
1845
|
-
//#region src/lib/internal-details/lib/features/url-utils.ts
|
|
1887
|
+
// src/lib/internal-details/lib/features/url-utils.ts
|
|
1846
1888
|
/**
|
|
1847
1889
|
* Ensures a base URL has a trailing slash for proper path joining.
|
|
1848
1890
|
*
|
|
@@ -1858,9 +1900,13 @@ async function getInputsWithFileMetadata(inputs) {
|
|
|
1858
1900
|
function withTrailingSlash(baseUrl) {
|
|
1859
1901
|
return baseUrl.endsWith("/") ? baseUrl : `${baseUrl}/`;
|
|
1860
1902
|
}
|
|
1861
|
-
|
|
1862
|
-
//#region src/lib/internal-details/lib/features/api-store.ts
|
|
1903
|
+
// src/lib/internal-details/lib/features/api-store.ts
|
|
1863
1904
|
const ENVIRONMENT_ALL = "*";
|
|
1905
|
+
const OrchestratorViewMode = {
|
|
1906
|
+
EDIT: 1,
|
|
1907
|
+
PREVIEW: 2,
|
|
1908
|
+
DEPLOYED: 3
|
|
1909
|
+
};
|
|
1864
1910
|
function getFetchByPathViewMode(appMode, editMode) {
|
|
1865
1911
|
if (appMode === AppMode.PREVIEW) return OrchestratorViewMode.PREVIEW;
|
|
1866
1912
|
if (appMode === AppMode.PUBLISHED) return OrchestratorViewMode.DEPLOYED;
|
|
@@ -1879,6 +1925,7 @@ function isAgentProfileSupported(agent, targetEnvironment) {
|
|
|
1879
1925
|
return supportedProfiles.includes(targetEnvironment);
|
|
1880
1926
|
}
|
|
1881
1927
|
var ApiManager = class {
|
|
1928
|
+
rootStore;
|
|
1882
1929
|
/**
|
|
1883
1930
|
* Pre-filtered agent URLs for the current profile, sent by the parent.
|
|
1884
1931
|
* Used as fallback for cloud orgs where URLs come from
|
|
@@ -2404,8 +2451,10 @@ var ApiManager = class {
|
|
|
2404
2451
|
const abortController = new AbortController();
|
|
2405
2452
|
(this.runningApiControllers[apiName] ??= /* @__PURE__ */ new Set()).add(abortController);
|
|
2406
2453
|
const forwardAbort = () => abortController.abort();
|
|
2407
|
-
if (options?.signal)
|
|
2408
|
-
|
|
2454
|
+
if (options?.signal) {
|
|
2455
|
+
if (options.signal.aborted) abortController.abort();
|
|
2456
|
+
else options.signal.addEventListener("abort", forwardAbort, { once: true });
|
|
2457
|
+
}
|
|
2409
2458
|
try {
|
|
2410
2459
|
let entryPoint = this.rootStore.getApiEntryPoint(apiName);
|
|
2411
2460
|
if (!entryPoint) {
|
|
@@ -2417,7 +2466,7 @@ var ApiManager = class {
|
|
|
2417
2466
|
}
|
|
2418
2467
|
if (!entryPoint && this.rootStore.sdkApiEnabled) try {
|
|
2419
2468
|
const rediscoveryT0 = performance.now();
|
|
2420
|
-
const { discoverAndRegisterSdkApis } = await import("./sdk-api-discovery-
|
|
2469
|
+
const { discoverAndRegisterSdkApis } = await import("./sdk-api-discovery-CtyMcIGP.js").then((n) => n.n);
|
|
2421
2470
|
await discoverAndRegisterSdkApis();
|
|
2422
2471
|
const rediscoveryMs = Math.round(performance.now() - rediscoveryT0);
|
|
2423
2472
|
discoveryMs += rediscoveryMs;
|
|
@@ -2630,8 +2679,7 @@ var ApiManager = class {
|
|
|
2630
2679
|
});
|
|
2631
2680
|
}
|
|
2632
2681
|
};
|
|
2633
|
-
|
|
2634
|
-
//#region src/lib/internal-details/lib/evaluator/sanitize-object.ts
|
|
2682
|
+
// src/lib/internal-details/lib/evaluator/sanitize-object.ts
|
|
2635
2683
|
const objectFallbackCache = /* @__PURE__ */ new WeakMap();
|
|
2636
2684
|
function sanitizeObject(obj) {
|
|
2637
2685
|
if (!objectFallbackCache.has(obj)) objectFallbackCache.set(obj, {});
|
|
@@ -2651,8 +2699,7 @@ function sanitizedToJS(value) {
|
|
|
2651
2699
|
if (value === null || value === void 0 || typeof value !== "object") return toJS(value);
|
|
2652
2700
|
return toJS(sanitizeObject(value));
|
|
2653
2701
|
}
|
|
2654
|
-
|
|
2655
|
-
//#region src/edit-mode/mobx-sync/create-patch.ts
|
|
2702
|
+
// src/edit-mode/mobx-sync/create-patch.ts
|
|
2656
2703
|
const microPatches = (oldValue, newValue, baseStr) => {
|
|
2657
2704
|
const cleanedOldValue = removeBindAndReactElements(oldValue);
|
|
2658
2705
|
const cleanedNewValue = removeBindAndReactElements(newValue);
|
|
@@ -2706,8 +2753,7 @@ const removeBindAndReactElements = (value) => {
|
|
|
2706
2753
|
return [key, removeBindAndReactElements(value)];
|
|
2707
2754
|
}));
|
|
2708
2755
|
};
|
|
2709
|
-
|
|
2710
|
-
//#region src/edit-mode/mobx-sync/deep-observe.ts
|
|
2756
|
+
// src/edit-mode/mobx-sync/deep-observe.ts
|
|
2711
2757
|
function buildPath(entry) {
|
|
2712
2758
|
if (!entry) return "ROOT";
|
|
2713
2759
|
const res = [];
|
|
@@ -2765,7 +2811,6 @@ function deepObserve(target, listener) {
|
|
|
2765
2811
|
const entry = entrySet.get(change.object[i]);
|
|
2766
2812
|
if (entry) entry.path = "" + i;
|
|
2767
2813
|
}
|
|
2768
|
-
break;
|
|
2769
2814
|
}
|
|
2770
2815
|
}
|
|
2771
2816
|
function observeRecursively(thing, parent, path) {
|
|
@@ -2798,8 +2843,7 @@ function deepObserve(target, listener) {
|
|
|
2798
2843
|
unobserveRecursively(target);
|
|
2799
2844
|
};
|
|
2800
2845
|
}
|
|
2801
|
-
|
|
2802
|
-
//#region src/edit-mode/mobx-sync/mobx-editor-sync.ts
|
|
2846
|
+
// src/edit-mode/mobx-sync/mobx-editor-sync.ts
|
|
2803
2847
|
/**
|
|
2804
2848
|
* Syncs a mobx store to the editor automatically through postmessage
|
|
2805
2849
|
*/
|
|
@@ -2811,7 +2855,7 @@ function startEditorSync(options) {
|
|
|
2811
2855
|
name: `editor-sync(${storeId})`
|
|
2812
2856
|
};
|
|
2813
2857
|
let initialState;
|
|
2814
|
-
if (keys) initialState = sanitizedToJS(
|
|
2858
|
+
if (keys) initialState = sanitizedToJS(Object.fromEntries(Object.keys(keys).filter((key) => key in store).map((key) => [key, Reflect.get(store, key)])));
|
|
2815
2859
|
else if (projection) initialState = sanitizedToJS(projection(store));
|
|
2816
2860
|
else initialState = sanitizedToJS(store);
|
|
2817
2861
|
editorBridge.initializeEditorSyncedStore({
|
|
@@ -2903,8 +2947,7 @@ function startEditorSync(options) {
|
|
|
2903
2947
|
disposers.forEach((disposer) => disposer());
|
|
2904
2948
|
};
|
|
2905
2949
|
}
|
|
2906
|
-
|
|
2907
|
-
//#region src/lib/internal-details/lib/features/type-defs-utils.ts
|
|
2950
|
+
// src/lib/internal-details/lib/features/type-defs-utils.ts
|
|
2908
2951
|
const analyzePropertyType = (propData, prop) => {
|
|
2909
2952
|
let dataType;
|
|
2910
2953
|
if (propData.dataType === "composite" && prop && typeof prop.getProps === "function") {
|
|
@@ -2923,13 +2966,13 @@ const analyzePropertyType = (propData, prop) => {
|
|
|
2923
2966
|
else dataType = "unknown";
|
|
2924
2967
|
return dataType;
|
|
2925
2968
|
};
|
|
2926
|
-
|
|
2927
|
-
//#region src/lib/internal-details/lib/features/component-registry.ts
|
|
2969
|
+
// src/lib/internal-details/lib/features/component-registry.ts
|
|
2928
2970
|
/**
|
|
2929
2971
|
* TODO: The component registry could be split into two a thin layer always on, and move some stuff to the EditStore.
|
|
2930
2972
|
* Some of the actions (rename, delete) and some of the data (isDroppable) are editor-only.
|
|
2931
2973
|
*/
|
|
2932
2974
|
var ComponentRegistry = class {
|
|
2975
|
+
rootStore;
|
|
2933
2976
|
_componentRegistry = /* @__PURE__ */ new Map();
|
|
2934
2977
|
_componentToType = /* @__PURE__ */ new WeakMap();
|
|
2935
2978
|
constructor(rootStore) {
|
|
@@ -3041,8 +3084,7 @@ var ComponentRegistry = class {
|
|
|
3041
3084
|
return this._componentToType.has(component);
|
|
3042
3085
|
}
|
|
3043
3086
|
};
|
|
3044
|
-
|
|
3045
|
-
//#region src/lib/internal-details/lib/root-store.ts
|
|
3087
|
+
// src/lib/internal-details/lib/root-store.ts
|
|
3046
3088
|
const ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG = "orchestrator.execute.response-size-limit.bytes";
|
|
3047
3089
|
/**
|
|
3048
3090
|
* Default user object for when no user info is available.
|
|
@@ -3250,7 +3292,629 @@ var RootStore = class {
|
|
|
3250
3292
|
}
|
|
3251
3293
|
};
|
|
3252
3294
|
var root_store_default = new RootStore();
|
|
3253
|
-
|
|
3254
|
-
|
|
3295
|
+
// src/lib/user-facing/assets/images/clark.svg
|
|
3296
|
+
var _path$1;
|
|
3297
|
+
var _path2;
|
|
3298
|
+
var _path3;
|
|
3299
|
+
var _path4;
|
|
3300
|
+
var _path5;
|
|
3301
|
+
var _path6;
|
|
3302
|
+
var _path7;
|
|
3303
|
+
var _defs;
|
|
3304
|
+
function _extends$1() {
|
|
3305
|
+
return _extends$1 = Object.assign ? Object.assign.bind() : function(n) {
|
|
3306
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
3307
|
+
var t = arguments[e];
|
|
3308
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
3309
|
+
}
|
|
3310
|
+
return n;
|
|
3311
|
+
}, _extends$1.apply(null, arguments);
|
|
3312
|
+
}
|
|
3313
|
+
var SvgClark = function SvgClark(props) {
|
|
3314
|
+
return /*#__PURE__*/ React$1.createElement("svg", _extends$1({
|
|
3315
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3316
|
+
width: 28,
|
|
3317
|
+
height: 20,
|
|
3318
|
+
fill: "none"
|
|
3319
|
+
}, props), _path$1 || (_path$1 = /*#__PURE__*/ React$1.createElement("path", {
|
|
3320
|
+
fill: "url(#clark_svg__a)",
|
|
3321
|
+
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"
|
|
3322
|
+
})), _path2 || (_path2 = /*#__PURE__*/ React$1.createElement("path", {
|
|
3323
|
+
fill: "#2A333D",
|
|
3324
|
+
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",
|
|
3325
|
+
opacity: .12
|
|
3326
|
+
})), _path3 || (_path3 = /*#__PURE__*/ React$1.createElement("path", {
|
|
3327
|
+
fill: "url(#clark_svg__b)",
|
|
3328
|
+
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"
|
|
3329
|
+
})), _path4 || (_path4 = /*#__PURE__*/ React$1.createElement("path", {
|
|
3330
|
+
fill: "#2A333D",
|
|
3331
|
+
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",
|
|
3332
|
+
opacity: .12
|
|
3333
|
+
})), _path5 || (_path5 = /*#__PURE__*/ React$1.createElement("path", {
|
|
3334
|
+
fill: "currentColor",
|
|
3335
|
+
fillRule: "evenodd",
|
|
3336
|
+
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",
|
|
3337
|
+
clipRule: "evenodd"
|
|
3338
|
+
})), _path6 || (_path6 = /*#__PURE__*/ React$1.createElement("path", {
|
|
3339
|
+
fill: "url(#clark_svg__c)",
|
|
3340
|
+
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",
|
|
3341
|
+
opacity: .5
|
|
3342
|
+
})), _path7 || (_path7 = /*#__PURE__*/ React$1.createElement("path", {
|
|
3343
|
+
fill: "url(#clark_svg__d)",
|
|
3344
|
+
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",
|
|
3345
|
+
opacity: .5
|
|
3346
|
+
})), _defs || (_defs = /*#__PURE__*/ React$1.createElement("defs", null, /*#__PURE__*/ React$1.createElement("linearGradient", {
|
|
3347
|
+
id: "clark_svg__a",
|
|
3348
|
+
x1: 21.636,
|
|
3349
|
+
x2: 17.027,
|
|
3350
|
+
y1: 4.149,
|
|
3351
|
+
y2: 8.785,
|
|
3352
|
+
gradientUnits: "userSpaceOnUse"
|
|
3353
|
+
}, /*#__PURE__*/ React$1.createElement("stop", { stopColor: "currentColor" }), /*#__PURE__*/ React$1.createElement("stop", {
|
|
3354
|
+
offset: 1,
|
|
3355
|
+
stopColor: "currentColor",
|
|
3356
|
+
stopOpacity: .84
|
|
3357
|
+
})), /*#__PURE__*/ React$1.createElement("linearGradient", {
|
|
3358
|
+
id: "clark_svg__b",
|
|
3359
|
+
x1: 4.534,
|
|
3360
|
+
x2: 10.643,
|
|
3361
|
+
y1: 6.603,
|
|
3362
|
+
y2: 9.712,
|
|
3363
|
+
gradientUnits: "userSpaceOnUse"
|
|
3364
|
+
}, /*#__PURE__*/ React$1.createElement("stop", { stopColor: "currentColor" }), /*#__PURE__*/ React$1.createElement("stop", {
|
|
3365
|
+
offset: 1,
|
|
3366
|
+
stopColor: "currentColor",
|
|
3367
|
+
stopOpacity: .84
|
|
3368
|
+
})), /*#__PURE__*/ React$1.createElement("linearGradient", {
|
|
3369
|
+
id: "clark_svg__c",
|
|
3370
|
+
x1: 15.788,
|
|
3371
|
+
x2: 16.004,
|
|
3372
|
+
y1: 13.866,
|
|
3373
|
+
y2: 15.093,
|
|
3374
|
+
gradientUnits: "userSpaceOnUse"
|
|
3375
|
+
}, /*#__PURE__*/ React$1.createElement("stop", {
|
|
3376
|
+
stopColor: "currentColor",
|
|
3377
|
+
stopOpacity: .6
|
|
3378
|
+
}), /*#__PURE__*/ React$1.createElement("stop", {
|
|
3379
|
+
offset: 1,
|
|
3380
|
+
stopColor: "currentColor"
|
|
3381
|
+
})), /*#__PURE__*/ React$1.createElement("linearGradient", {
|
|
3382
|
+
id: "clark_svg__d",
|
|
3383
|
+
x1: 15.704,
|
|
3384
|
+
x2: 16.07,
|
|
3385
|
+
y1: 13.597,
|
|
3386
|
+
y2: 15.67,
|
|
3387
|
+
gradientUnits: "userSpaceOnUse"
|
|
3388
|
+
}, /*#__PURE__*/ React$1.createElement("stop", {
|
|
3389
|
+
stopColor: "currentColor",
|
|
3390
|
+
stopOpacity: .6
|
|
3391
|
+
}), /*#__PURE__*/ React$1.createElement("stop", {
|
|
3392
|
+
offset: 1,
|
|
3393
|
+
stopColor: "currentColor"
|
|
3394
|
+
})))));
|
|
3395
|
+
};
|
|
3396
|
+
// src/lib/internal-details/internal-components/common.ts
|
|
3397
|
+
const ErrorIconContainer = styled.div`
|
|
3398
|
+
width: 60px;
|
|
3399
|
+
height: 60px;
|
|
3400
|
+
min-width: 60px;
|
|
3401
|
+
min-height: 60px;
|
|
3402
|
+
background: linear-gradient(135deg, #aab 0%, #000033 50%, #000066 100%);
|
|
3403
|
+
border-radius: 16px;
|
|
3404
|
+
display: flex;
|
|
3405
|
+
align-items: center;
|
|
3406
|
+
justify-content: center;
|
|
3407
|
+
margin: 0 auto 16px;
|
|
3408
|
+
flex-shrink: 0;
|
|
3409
|
+
animation: scaleIn 0.3s ease-out forwards;
|
|
3410
|
+
opacity: 0;
|
|
3411
|
+
box-shadow:
|
|
3412
|
+
0 0 1px black,
|
|
3413
|
+
0 4px 12px rgba(0, 85, 187, 0.15),
|
|
3414
|
+
0 2px 4px rgba(0, 85, 187, 0.05);
|
|
3415
|
+
|
|
3416
|
+
@keyframes scaleIn {
|
|
3417
|
+
from {
|
|
3418
|
+
transform: scale(0.8);
|
|
3419
|
+
opacity: 0;
|
|
3420
|
+
}
|
|
3421
|
+
to {
|
|
3422
|
+
transform: scale(1);
|
|
3423
|
+
opacity: 1;
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
`;
|
|
3427
|
+
const StyledClarkIcon = styled(SvgClark)`
|
|
3428
|
+
width: 54px;
|
|
3429
|
+
height: 54px;
|
|
3430
|
+
color: white;
|
|
3431
|
+
margin-top: 3px;
|
|
3432
|
+
margin-left: 1px;
|
|
3433
|
+
animation: scaleIn 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
|
|
3434
|
+
opacity: 0;
|
|
3435
|
+
|
|
3436
|
+
@keyframes scaleIn {
|
|
3437
|
+
0% {
|
|
3438
|
+
transform: scale(0.6);
|
|
3439
|
+
opacity: 0;
|
|
3440
|
+
}
|
|
3441
|
+
50% {
|
|
3442
|
+
transform: scale(1.1);
|
|
3443
|
+
}
|
|
3444
|
+
100% {
|
|
3445
|
+
transform: scale(1);
|
|
3446
|
+
opacity: 1;
|
|
3447
|
+
}
|
|
3448
|
+
}
|
|
3449
|
+
`;
|
|
3450
|
+
const ErrorTitle = styled.h2`
|
|
3451
|
+
font-family: Inter;
|
|
3452
|
+
color: rgba(0, 0, 0, 0.85);
|
|
3453
|
+
font-weight: 600;
|
|
3454
|
+
font-size: 24px;
|
|
3455
|
+
line-height: 1.35;
|
|
3456
|
+
text-align: center;
|
|
3457
|
+
margin-bottom: 6px;
|
|
3458
|
+
flex-shrink: 0;
|
|
3459
|
+
`;
|
|
3460
|
+
const ErrorMessage = styled.p`
|
|
3461
|
+
font-family: Inter;
|
|
3462
|
+
font-size: 14px;
|
|
3463
|
+
color: #6c7689;
|
|
3464
|
+
line-height: 1.5715;
|
|
3465
|
+
text-align: center;
|
|
3466
|
+
flex-shrink: 0;
|
|
3467
|
+
margin-top: 0;
|
|
3468
|
+
margin-bottom: 16px;
|
|
3469
|
+
`;
|
|
3470
|
+
const ErrorDetails = styled.details`
|
|
3471
|
+
margin-top: 24px;
|
|
3472
|
+
text-align: left;
|
|
3473
|
+
background-color: #f9fafb;
|
|
3474
|
+
border-radius: 6px;
|
|
3475
|
+
padding: 16px;
|
|
3476
|
+
box-shadow:
|
|
3477
|
+
0px 0px 1px 0px #22272f52,
|
|
3478
|
+
0px 1px 3px 0px #22272f1f;
|
|
3479
|
+
flex-shrink: 0;
|
|
3480
|
+
font-family: Inter;
|
|
3481
|
+
|
|
3482
|
+
&[open] summary {
|
|
3483
|
+
margin-bottom: 12px;
|
|
3484
|
+
}
|
|
3485
|
+
`;
|
|
3486
|
+
const ErrorSummary = styled.summary`
|
|
3487
|
+
cursor: pointer;
|
|
3488
|
+
font-weight: 500;
|
|
3489
|
+
color: #374151;
|
|
3490
|
+
font-size: 14px;
|
|
3491
|
+
user-select: none;
|
|
3492
|
+
`;
|
|
3493
|
+
const ErrorStack = styled.pre`
|
|
3494
|
+
font-size: 12px;
|
|
3495
|
+
color: #dc2626;
|
|
3496
|
+
overflow: auto;
|
|
3497
|
+
white-space: pre-wrap;
|
|
3498
|
+
margin: 16px;
|
|
3499
|
+
font-family: monospace;
|
|
3500
|
+
`;
|
|
3501
|
+
const ErrorContainer = styled.div`
|
|
3502
|
+
position: absolute;
|
|
3503
|
+
inset: 0;
|
|
3504
|
+
display: flex;
|
|
3505
|
+
align-items: center;
|
|
3506
|
+
justify-content: center;
|
|
3507
|
+
z-index: 10;
|
|
3508
|
+
background: rgba(255, 255, 255, 0.5);
|
|
3509
|
+
pointer-events: auto;
|
|
3510
|
+
`;
|
|
3511
|
+
const ErrorContent = styled.div`
|
|
3512
|
+
max-width: 700px;
|
|
3513
|
+
padding: 40px;
|
|
3514
|
+
overflow-y: auto;
|
|
3515
|
+
flex: 1;
|
|
3516
|
+
display: flex;
|
|
3517
|
+
flex-direction: column;
|
|
3518
|
+
gap: 20px;
|
|
3519
|
+
|
|
3520
|
+
opacity: 0;
|
|
3521
|
+
animation: fadeIn 0.3s ease-out forwards;
|
|
3522
|
+
|
|
3523
|
+
@keyframes fadeIn {
|
|
3524
|
+
from {
|
|
3525
|
+
opacity: 0;
|
|
3526
|
+
}
|
|
3527
|
+
to {
|
|
3528
|
+
opacity: 1;
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
`;
|
|
3532
|
+
const SecondaryButton = styled.button`
|
|
3533
|
+
color: ${colors.GREY_700};
|
|
3534
|
+
border: 1px solid ${colors.GREY_100};
|
|
3535
|
+
width: fit-content;
|
|
3536
|
+
border-radius: 4px;
|
|
3537
|
+
padding: 6px 12px;
|
|
3538
|
+
cursor: pointer;
|
|
3539
|
+
height: fit-content;
|
|
3540
|
+
font-size: 12px;
|
|
3541
|
+
|
|
3542
|
+
&:hover {
|
|
3543
|
+
opacity: 0.8;
|
|
3544
|
+
}
|
|
3545
|
+
|
|
3546
|
+
&:active {
|
|
3547
|
+
opacity: 0.6;
|
|
3548
|
+
}
|
|
3549
|
+
`;
|
|
3550
|
+
const ActionsContainer = styled.div`
|
|
3551
|
+
display: flex;
|
|
3552
|
+
gap: 12px;
|
|
3553
|
+
align-items: center;
|
|
3554
|
+
justify-content: center;
|
|
3555
|
+
`;
|
|
3556
|
+
// src/edit-mode/assets/ai-stars.svg
|
|
3557
|
+
var _path;
|
|
3558
|
+
function _extends() {
|
|
3559
|
+
return _extends = Object.assign ? Object.assign.bind() : function(n) {
|
|
3560
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
3561
|
+
var t = arguments[e];
|
|
3562
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
3563
|
+
}
|
|
3564
|
+
return n;
|
|
3565
|
+
}, _extends.apply(null, arguments);
|
|
3566
|
+
}
|
|
3567
|
+
var SvgAiStars = function SvgAiStars(props) {
|
|
3568
|
+
return /*#__PURE__*/ React$1.createElement("svg", _extends({
|
|
3569
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3570
|
+
width: 13,
|
|
3571
|
+
height: 14,
|
|
3572
|
+
fill: "none"
|
|
3573
|
+
}, props), _path || (_path = /*#__PURE__*/ React$1.createElement("path", {
|
|
3574
|
+
fill: "currentColor",
|
|
3575
|
+
fillRule: "evenodd",
|
|
3576
|
+
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",
|
|
3577
|
+
clipRule: "evenodd"
|
|
3578
|
+
})));
|
|
3579
|
+
};
|
|
3580
|
+
// src/lib/internal-details/internal-components/fix-with-clark-button.tsx
|
|
3581
|
+
const MAX_STACK_FRAMES = 10;
|
|
3582
|
+
const MAX_PROMPT_LENGTH = 8e3;
|
|
3583
|
+
function buildRuntimeErrorPrompt(error) {
|
|
3584
|
+
const defaultPrompt = "Fix this error: Unknown error";
|
|
3585
|
+
if (!error) return defaultPrompt;
|
|
3586
|
+
const [messageLine, ...rawFrames] = error.stack?.split("\n") ?? [];
|
|
3587
|
+
const message = (messageLine || error.message || error.toString()).trim();
|
|
3588
|
+
const filteredFrames = rawFrames.filter((line) => line && !line.includes("node_modules"));
|
|
3589
|
+
const selectedFrames = filteredFrames.slice(0, MAX_STACK_FRAMES);
|
|
3590
|
+
const omittedCount = filteredFrames.length - selectedFrames.length;
|
|
3591
|
+
const frameSection = [...selectedFrames, ...omittedCount > 0 ? [`... (${omittedCount} additional frame${omittedCount > 1 ? "s" : ""} omitted)`] : []].map((line) => line.trimEnd()).join("\n");
|
|
3592
|
+
const prompt = `Fix this error: ${frameSection ? `${message}\n${frameSection}` : message}`;
|
|
3593
|
+
if (prompt.length <= MAX_PROMPT_LENGTH) return prompt;
|
|
3594
|
+
const suffix = "... (truncated)";
|
|
3595
|
+
const availableChars = Math.max(7985, 0);
|
|
3596
|
+
return `${prompt.slice(0, availableChars)}${suffix}`;
|
|
3597
|
+
}
|
|
3598
|
+
const FixWithClarkButtonContainer = styled.button`
|
|
3599
|
+
padding: 6px 12px;
|
|
3600
|
+
background-color: ${colors.ACCENT_BLUE_500};
|
|
3601
|
+
border-radius: 4px;
|
|
3602
|
+
border: none;
|
|
3603
|
+
color: white;
|
|
3604
|
+
height: fit-content;
|
|
3605
|
+
display: flex;
|
|
3606
|
+
gap: 4px;
|
|
3607
|
+
cursor: pointer;
|
|
3608
|
+
transition: opacity 0.2s;
|
|
3609
|
+
font-size: 12px;
|
|
3610
|
+
align-items: center;
|
|
3611
|
+
|
|
3612
|
+
&:hover:not(:disabled) {
|
|
3613
|
+
opacity: 0.8;
|
|
3614
|
+
}
|
|
3615
|
+
|
|
3616
|
+
&:disabled {
|
|
3617
|
+
opacity: 0.5;
|
|
3618
|
+
cursor: not-allowed;
|
|
3619
|
+
}
|
|
3620
|
+
`;
|
|
3621
|
+
function FixWithClarkButton({ identifier, error, onClick }) {
|
|
3622
|
+
const isAiEditing = root_store_default.editStore?.ai.getIsEditing() ?? false;
|
|
3623
|
+
const handleFixWithAi = () => {
|
|
3624
|
+
onClick?.();
|
|
3625
|
+
if (identifier) editorBridge.addComponentToAiContext(identifier.sourceId, identifier.selectorId);
|
|
3626
|
+
const prompt = buildRuntimeErrorPrompt(error);
|
|
3627
|
+
editorBridge.aiGenerate(prompt, true);
|
|
3628
|
+
};
|
|
3629
|
+
return /* @__PURE__ */ jsxs(FixWithClarkButtonContainer, {
|
|
3630
|
+
onClick: handleFixWithAi,
|
|
3631
|
+
disabled: isAiEditing,
|
|
3632
|
+
children: [/* @__PURE__ */ jsx(SvgAiStars, {}), " Fix with Clark"]
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3635
|
+
// src/lib/internal-details/css-constants.ts
|
|
3636
|
+
const CSS_CLASSES = {
|
|
3637
|
+
SUSPENSE_FALLBACK: "sb-suspense-fallback",
|
|
3638
|
+
ANCHOR_NAME: "sb-anchor-name"
|
|
3639
|
+
};
|
|
3640
|
+
// src/lib/internal-details/lib/suspense/suspense-fallback.tsx
|
|
3641
|
+
const shimmerAnimation = keyframes`
|
|
3642
|
+
0% {
|
|
3643
|
+
background-position: -200px 0;
|
|
3644
|
+
}
|
|
3645
|
+
100% {
|
|
3646
|
+
background-position: calc(200px + 100%) 0;
|
|
3647
|
+
}
|
|
3648
|
+
`;
|
|
3649
|
+
const ShimmerDiv = styled.div`
|
|
3650
|
+
min-height: 12px;
|
|
3651
|
+
min-width: 12px;
|
|
3652
|
+
background-color: ${(props) => props.$backgroundColor};
|
|
3653
|
+
border-radius: ${(props) => props.$borderRadius};
|
|
3654
|
+
position: relative;
|
|
3655
|
+
overflow: hidden;
|
|
3656
|
+
background: linear-gradient(
|
|
3657
|
+
90deg,
|
|
3658
|
+
${(props) => props.$backgroundColor} 25%,
|
|
3659
|
+
${(props) => props.$shimmerHighlight} 50%,
|
|
3660
|
+
${(props) => props.$backgroundColor} 75%
|
|
3661
|
+
);
|
|
3662
|
+
background-size: max(100%, 200px) 100%;
|
|
3663
|
+
animation: ${shimmerAnimation} 5s infinite linear;
|
|
3664
|
+
`;
|
|
3665
|
+
/**
|
|
3666
|
+
* Default fallback component displayed while components are suspended.
|
|
3667
|
+
*/
|
|
3668
|
+
function SuspenseFallback({ style, className, noBorderRadius }) {
|
|
3669
|
+
const backgroundColor = "#f8f9fa";
|
|
3670
|
+
const shimmerHighlight = "#ffffff";
|
|
3671
|
+
const borderRadius = noBorderRadius ? "0px" : "4px";
|
|
3672
|
+
const classes = useMemo(() => [CSS_CLASSES.ANCHOR_NAME, className].filter(Boolean).join(" "), [className]);
|
|
3673
|
+
return /* @__PURE__ */ jsx(ShimmerDiv, {
|
|
3674
|
+
$backgroundColor: backgroundColor,
|
|
3675
|
+
$shimmerHighlight: shimmerHighlight,
|
|
3676
|
+
$borderRadius: borderRadius,
|
|
3677
|
+
style: style?.(),
|
|
3678
|
+
className: classes,
|
|
3679
|
+
"data-test": "suspense-fallback"
|
|
3680
|
+
});
|
|
3681
|
+
}
|
|
3682
|
+
// src/lib/user-facing/component-base/error-boundary.tsx
|
|
3683
|
+
const ErrorBoundaryContainer = styled.div`
|
|
3684
|
+
background: white;
|
|
3685
|
+
padding: 10px;
|
|
3686
|
+
display: flex;
|
|
3687
|
+
flex-direction: column;
|
|
3688
|
+
gap: 8px;
|
|
3689
|
+
border: 1px solid ${colors.GREY_100};
|
|
3690
|
+
border-left: 3px solid ${colors.RED_500};
|
|
3691
|
+
border-radius: 4px;
|
|
3692
|
+
width: 100%;
|
|
3693
|
+
color: ${colors.GREY_700};
|
|
3694
|
+
`;
|
|
3695
|
+
const ErrorDetailsContainer = styled.div`
|
|
3696
|
+
display: flex;
|
|
3697
|
+
flex-direction: column;
|
|
3698
|
+
gap: 8px;
|
|
3699
|
+
`;
|
|
3700
|
+
const ErrorActionsContainer = styled.div`
|
|
3701
|
+
display: flex;
|
|
3702
|
+
justify-content: flex-end;
|
|
3703
|
+
align-items: center;
|
|
3704
|
+
gap: 8px;
|
|
3705
|
+
`;
|
|
3706
|
+
var ErrorBoundary = class extends Component {
|
|
3707
|
+
state = {
|
|
3708
|
+
id: generateId(),
|
|
3709
|
+
hasError: false
|
|
3710
|
+
};
|
|
3711
|
+
disposeAutoReset;
|
|
3712
|
+
static getDerivedStateFromError(e) {
|
|
3713
|
+
const error = e instanceof Error ? e : new Error(typeof e === "object" && e !== null ? JSON.stringify(e) : String(e));
|
|
3714
|
+
return {
|
|
3715
|
+
id: generateId(),
|
|
3716
|
+
hasError: true,
|
|
3717
|
+
error
|
|
3718
|
+
};
|
|
3719
|
+
}
|
|
3720
|
+
componentDidCatch(error, errorInfo) {
|
|
3721
|
+
if (isEditMode()) root_store_default.editStore?.ai.handleRuntimeError({
|
|
3722
|
+
id: this.state.id,
|
|
3723
|
+
error: String(error),
|
|
3724
|
+
errorInfo,
|
|
3725
|
+
identifier: this.props.identifier
|
|
3726
|
+
});
|
|
3727
|
+
}
|
|
3728
|
+
reset = () => {
|
|
3729
|
+
if (isEditMode()) root_store_default.editStore?.ai.clearRuntimeError(this.state.id);
|
|
3730
|
+
this.setState({
|
|
3731
|
+
hasError: false,
|
|
3732
|
+
error: void 0
|
|
3733
|
+
});
|
|
3734
|
+
};
|
|
3735
|
+
componentWillUnmount() {
|
|
3736
|
+
if (this.state.hasError && isEditMode()) root_store_default.editStore?.ai.clearRuntimeError(this.state.id);
|
|
3737
|
+
this.disposeAutoReset?.();
|
|
3738
|
+
}
|
|
3739
|
+
handleFixWithClarkInitiated = () => {
|
|
3740
|
+
const ai = root_store_default.editStore?.ai;
|
|
3741
|
+
if (!ai) return;
|
|
3742
|
+
this.disposeAutoReset?.();
|
|
3743
|
+
this.disposeAutoReset = void 0;
|
|
3744
|
+
let sawStart = ai.getIsEditing();
|
|
3745
|
+
this.disposeAutoReset = reaction(() => ai.getIsEditing(), (isEditing) => {
|
|
3746
|
+
if (!sawStart && isEditing) sawStart = true;
|
|
3747
|
+
if (sawStart && !isEditing) {
|
|
3748
|
+
this.reset();
|
|
3749
|
+
this.disposeAutoReset?.();
|
|
3750
|
+
this.disposeAutoReset = void 0;
|
|
3751
|
+
}
|
|
3752
|
+
}, {
|
|
3753
|
+
fireImmediately: true,
|
|
3754
|
+
name: "error-boundary-ai-auto-reset"
|
|
3755
|
+
});
|
|
3756
|
+
};
|
|
3757
|
+
handleFixWithAi() {
|
|
3758
|
+
const { identifier } = this.props;
|
|
3759
|
+
if (identifier) editorBridge.addComponentToAiContext(identifier.sourceId, identifier.selectorId);
|
|
3760
|
+
let prompt = `Fix this error: `;
|
|
3761
|
+
if (this.state.error?.stack) {
|
|
3762
|
+
const lines = this.state.error.stack.split("\n");
|
|
3763
|
+
const nodeModulesIndex = lines.findIndex((line) => line.includes("node_modules"));
|
|
3764
|
+
const relevantLines = nodeModulesIndex > -1 ? lines.slice(0, nodeModulesIndex) : lines;
|
|
3765
|
+
prompt += relevantLines.slice(0, 5).join("\n");
|
|
3766
|
+
} else prompt += this.state.error?.toString();
|
|
3767
|
+
editorBridge.aiGenerate(prompt);
|
|
3768
|
+
}
|
|
3769
|
+
render() {
|
|
3770
|
+
if (this.state.hasError) return /* @__PURE__ */ jsx(Observer, { children: () => {
|
|
3771
|
+
if (root_store_default.editStore?.ai.getIsEditing() ?? false) return /* @__PURE__ */ jsx(SuspenseFallback, {});
|
|
3772
|
+
return /* @__PURE__ */ jsxs(ErrorBoundaryContainer, { children: [/* @__PURE__ */ jsxs(ErrorDetailsContainer, {
|
|
3773
|
+
"data-testid": "runtime-error-details",
|
|
3774
|
+
children: [/* @__PURE__ */ jsx("h3", { children: this.props.header || "Something went wrong." }), /* @__PURE__ */ jsxs("details", {
|
|
3775
|
+
style: { fontSize: "0.8em" },
|
|
3776
|
+
children: [/* @__PURE__ */ jsx("summary", {
|
|
3777
|
+
style: { paddingLeft: "0.25rem" },
|
|
3778
|
+
children: "Error details"
|
|
3779
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
3780
|
+
style: {
|
|
3781
|
+
marginTop: "0.5rem",
|
|
3782
|
+
maxWidth: "100%",
|
|
3783
|
+
overflowX: "auto",
|
|
3784
|
+
scrollbarWidth: "thin"
|
|
3785
|
+
},
|
|
3786
|
+
children: /* @__PURE__ */ jsx("pre", {
|
|
3787
|
+
style: { color: "gray" },
|
|
3788
|
+
children: /* @__PURE__ */ jsx("code", { children: this.state.error?.stack ? this.state.error.stack : this.state.error?.toString() })
|
|
3789
|
+
})
|
|
3790
|
+
})]
|
|
3791
|
+
})]
|
|
3792
|
+
}), /* @__PURE__ */ jsxs(ErrorActionsContainer, { children: [isEditMode() && /* @__PURE__ */ jsx(FixWithClarkButton, {
|
|
3793
|
+
onClick: this.handleFixWithClarkInitiated,
|
|
3794
|
+
error: this.state.error,
|
|
3795
|
+
identifier: this.props.identifier
|
|
3796
|
+
}), /* @__PURE__ */ jsx(SecondaryButton, {
|
|
3797
|
+
onClick: this.reset,
|
|
3798
|
+
children: "Try again"
|
|
3799
|
+
})] })] });
|
|
3800
|
+
} });
|
|
3801
|
+
return this.props.children;
|
|
3802
|
+
}
|
|
3803
|
+
};
|
|
3804
|
+
// src/lib/utils/widget-wrapper-naming.ts
|
|
3805
|
+
const getWidgetAnchorName = (selectorId) => {
|
|
3806
|
+
return `--widget-${selectorId}`;
|
|
3807
|
+
};
|
|
3808
|
+
const getWidgetRectAnchorName = (selectorId) => {
|
|
3809
|
+
return `--widget-rect-${selectorId}`;
|
|
3810
|
+
};
|
|
3811
|
+
// src/edit-mode/edit-wrapper.tsx
|
|
3812
|
+
if (typeof window !== "undefined" && typeof document.documentElement !== "undefined" && !("anchorName" in document.documentElement.style) && isEditMode()) import("@oddbird/css-anchor-positioning/fn").then(({ default: polyfill }) => polyfill()).catch((error) => console.warn("Failed to load the CSS anchor positioning polyfill", error));
|
|
3813
|
+
const createAnchorNameStyle = (props) => {
|
|
3814
|
+
return { "--anchor-name": getWidgetAnchorName(props.selectorId) };
|
|
3815
|
+
};
|
|
3816
|
+
// src/edit-mode/instance-tracker.ts
|
|
3817
|
+
/**
|
|
3818
|
+
* Tracks and recycles instance numbers for each sourceId to generate stable, unique selector IDs.
|
|
3819
|
+
* When components unmount, their instance numbers are released and can be reused.
|
|
3820
|
+
*/
|
|
3821
|
+
var InstanceTracker = class {
|
|
3822
|
+
sourceIdToUsedInstances = /* @__PURE__ */ new Map();
|
|
3823
|
+
getNextAvailableInstance(sourceId) {
|
|
3824
|
+
const usedInstances = this.sourceIdToUsedInstances.get(sourceId) ?? /* @__PURE__ */ new Set();
|
|
3825
|
+
let instance = 0;
|
|
3826
|
+
while (usedInstances.has(instance)) instance++;
|
|
3827
|
+
usedInstances.add(instance);
|
|
3828
|
+
this.sourceIdToUsedInstances.set(sourceId, usedInstances);
|
|
3829
|
+
return instance;
|
|
3830
|
+
}
|
|
3831
|
+
releaseInstance(sourceId, instance) {
|
|
3832
|
+
const usedInstances = this.sourceIdToUsedInstances.get(sourceId);
|
|
3833
|
+
if (usedInstances) {
|
|
3834
|
+
usedInstances.delete(instance);
|
|
3835
|
+
if (usedInstances.size === 0) this.sourceIdToUsedInstances.delete(sourceId);
|
|
3836
|
+
}
|
|
3837
|
+
}
|
|
3838
|
+
};
|
|
3839
|
+
const instanceTracker = new InstanceTracker();
|
|
3840
|
+
// src/edit-mode/jsx-wrapper.tsx
|
|
3841
|
+
const JSXContext = React.createContext({
|
|
3842
|
+
selectorId: "S-<unknown>",
|
|
3843
|
+
sourceId: "SB-<unknown>"
|
|
3844
|
+
});
|
|
3845
|
+
const makeWrappedComponent = (type) => {
|
|
3846
|
+
const isTag = typeof type === "string";
|
|
3847
|
+
const isRegisteredSbComponent = root_store_default.componentRegistry.hasComponent(type);
|
|
3848
|
+
const Component = React.forwardRef((props, ref) => {
|
|
3849
|
+
const { selectorId: parentSelectorId } = useJSXContext();
|
|
3850
|
+
const sourceId = props[SOURCE_ID_ATTRIBUTE];
|
|
3851
|
+
const noSelect = props[NO_SELECT_ATTRIBUTE];
|
|
3852
|
+
const instanceNumberRef = useRef();
|
|
3853
|
+
const selectorId = useRef("S-<unknown>");
|
|
3854
|
+
if (selectorId.current === "S-<unknown>") {
|
|
3855
|
+
instanceNumberRef.current = instanceTracker.getNextAvailableInstance(sourceId);
|
|
3856
|
+
selectorId.current = `S-x-${sourceId}-${instanceNumberRef.current}`;
|
|
3857
|
+
}
|
|
3858
|
+
useEffect(() => {
|
|
3859
|
+
root_store_default.editStore?.runtimeTrackingStore.registerComponent(selectorId.current, {
|
|
3860
|
+
sourceId,
|
|
3861
|
+
type,
|
|
3862
|
+
parentSelectorId,
|
|
3863
|
+
isSbComponent: isRegisteredSbComponent,
|
|
3864
|
+
isHtmlElement: isTag,
|
|
3865
|
+
noSelect
|
|
3866
|
+
});
|
|
3867
|
+
return () => {
|
|
3868
|
+
root_store_default.editStore?.runtimeTrackingStore.unregisterComponent(selectorId.current);
|
|
3869
|
+
if (instanceNumberRef.current !== void 0) instanceTracker.releaseInstance(sourceId, instanceNumberRef.current);
|
|
3870
|
+
};
|
|
3871
|
+
}, []);
|
|
3872
|
+
const disabled = Boolean(props.disabled);
|
|
3873
|
+
useEffect(() => {
|
|
3874
|
+
root_store_default.editStore?.runtimeTrackingStore.setComponentDisabled(selectorId.current, disabled);
|
|
3875
|
+
}, [disabled]);
|
|
3876
|
+
const jsxContext = useMemo(() => ({
|
|
3877
|
+
selectorId: selectorId.current,
|
|
3878
|
+
sourceId
|
|
3879
|
+
}), [sourceId]);
|
|
3880
|
+
const selectorProps = { [SELECTOR_ID_ATTRIBUTE]: selectorId.current };
|
|
3881
|
+
if (parentSelectorId) selectorProps["data-sb-parent-selector-id"] = parentSelectorId;
|
|
3882
|
+
const { style: propsStyle, className: propsClassName } = props;
|
|
3883
|
+
const style = useMemo(() => {
|
|
3884
|
+
return {
|
|
3885
|
+
...propsStyle,
|
|
3886
|
+
...createAnchorNameStyle({ selectorId: selectorId.current })
|
|
3887
|
+
};
|
|
3888
|
+
}, [propsStyle]);
|
|
3889
|
+
const className = useMemo(() => {
|
|
3890
|
+
return typeof propsClassName === "function" ? (...args) => ["sb-anchor-name", propsClassName(...args)].filter(Boolean).join(" ") : ["sb-anchor-name", propsClassName].filter(Boolean).join(" ");
|
|
3891
|
+
}, [propsClassName]);
|
|
3892
|
+
const element = React.createElement(type, {
|
|
3893
|
+
ref,
|
|
3894
|
+
...props,
|
|
3895
|
+
...selectorProps,
|
|
3896
|
+
className,
|
|
3897
|
+
style
|
|
3898
|
+
});
|
|
3899
|
+
if (!root_store_default.editStore?.isInitialized) return /* @__PURE__ */ jsx(JSXContext.Provider, {
|
|
3900
|
+
value: jsxContext,
|
|
3901
|
+
children: element
|
|
3902
|
+
});
|
|
3903
|
+
return /* @__PURE__ */ jsx(JSXContext.Provider, {
|
|
3904
|
+
value: jsxContext,
|
|
3905
|
+
children: /* @__PURE__ */ jsx(ErrorBoundary, { children: element })
|
|
3906
|
+
});
|
|
3907
|
+
});
|
|
3908
|
+
try {
|
|
3909
|
+
Component.displayName = typeof type === "string" ? type : type.displayName || type.name || "Component";
|
|
3910
|
+
} catch (e) {
|
|
3911
|
+
console.error("Error setting displayName", e);
|
|
3912
|
+
}
|
|
3913
|
+
return Component;
|
|
3914
|
+
};
|
|
3915
|
+
const useJSXContext = () => {
|
|
3916
|
+
return React.useContext(JSXContext);
|
|
3917
|
+
};
|
|
3918
|
+
export { useSuperblocksDataTags as A, getEditStore as B, tracker as C, SuperblocksContextProvider as D, resolveById as E, generateId as F, isEditMode as G, iframeMessageHandler as H, sendNotification as I, __exportAll as K, colors as L, useSuperblocksProfiles as M, useSuperblocksUser as N, getAppMode as O, embedStore as P, editorBridge as R, utils_exports as S, rejectById as T, isEmbeddedBySuperblocksFirstParty as U, getParentOrigin as V, sendMessageImmediately as W, ORCHESTRATOR_EXECUTE_RESPONSE_SIZE_LIMIT_FLAG as _, FixWithClarkButton as a, getContextFromTraceHeaders as b, ErrorContent as c, ErrorMessage as d, ErrorStack as f, StyledClarkIcon as g, SecondaryButton as h, getWidgetRectAnchorName as i, useSuperblocksGroups as j, useSuperblocksContext as k, 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, root_store_default as v, addNewPromise as w, initTracerProviderWithOrigin as x, createIframeSpan as y, markLoad as z };
|
|
3255
3919
|
|
|
3256
|
-
//# sourceMappingURL=
|
|
3920
|
+
//# sourceMappingURL=jsx-wrapper-BAO7prWO.js.map
|