create-skybridge 0.0.0-cloudflare
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/index.d.ts +1 -0
- package/dist/index.js +283 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +33 -0
- package/index.js +8 -0
- package/package.json +36 -0
- package/template/AGENTS.md +1 -0
- package/template/README.md +97 -0
- package/template/_gitignore +5 -0
- package/template/_headers +2 -0
- package/template/alpic.json +3 -0
- package/template/dist/_headers +2 -0
- package/template/dist/assets/.vite/manifest.json +24 -0
- package/template/dist/assets/assets/magic-8-ball-DWG75vr4.js +10 -0
- package/template/dist/assets/assets/modal-provider-BQ1zWEcc.js +18 -0
- package/template/dist/assets/assets/style-CH_mzOKc.css +2 -0
- package/template/dist/server/src/index.js +56 -0
- package/template/dist/server/src/index.js.map +1 -0
- package/template/dist/server/src/vite-manifest.js +24 -0
- package/template/dist/tsconfig.tsbuildinfo +1 -0
- package/template/dist/web/src/helpers.js +3 -0
- package/template/dist/web/src/helpers.js.map +1 -0
- package/template/dist/web/src/widgets/magic-8-ball.js +11 -0
- package/template/dist/web/src/widgets/magic-8-ball.js.map +1 -0
- package/template/node_modules/.bin/alpic +21 -0
- package/template/node_modules/.bin/browserslist +21 -0
- package/template/node_modules/.bin/esbuild +21 -0
- package/template/node_modules/.bin/jiti +21 -0
- package/template/node_modules/.bin/nodemon +21 -0
- package/template/node_modules/.bin/sb +21 -0
- package/template/node_modules/.bin/skybridge +21 -0
- package/template/node_modules/.bin/terser +21 -0
- package/template/node_modules/.bin/tsc +21 -0
- package/template/node_modules/.bin/tsserver +21 -0
- package/template/node_modules/.bin/tsx +21 -0
- package/template/node_modules/.bin/vite +21 -0
- package/template/node_modules/.bin/workerd +21 -0
- package/template/node_modules/.bin/wrangler +21 -0
- package/template/node_modules/.bin/wrangler2 +21 -0
- package/template/node_modules/.bin/yaml +21 -0
- package/template/node_modules/.cache/wrangler/wrangler-account.json +6 -0
- package/template/node_modules/.mf/cf.json +1 -0
- package/template/node_modules/.vite/deps/_metadata.json +76 -0
- package/template/node_modules/.vite/deps/chunk-5WRI5ZAA.js +30 -0
- package/template/node_modules/.vite/deps/chunk-5WRI5ZAA.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-MEVQY4YB.js +991 -0
- package/template/node_modules/.vite/deps/chunk-MEVQY4YB.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-RKAOJUND.js +279 -0
- package/template/node_modules/.vite/deps/chunk-RKAOJUND.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-V2LKO732.js +267 -0
- package/template/node_modules/.vite/deps/chunk-V2LKO732.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-VNABIVRN.js +20196 -0
- package/template/node_modules/.vite/deps/chunk-VNABIVRN.js.map +7 -0
- package/template/node_modules/.vite/deps/chunk-YNOAPT43.js +634 -0
- package/template/node_modules/.vite/deps/chunk-YNOAPT43.js.map +7 -0
- package/template/node_modules/.vite/deps/lib-355XMAFY.js +56976 -0
- package/template/node_modules/.vite/deps/lib-355XMAFY.js.map +7 -0
- package/template/node_modules/.vite/deps/modal-provider-67CS7MKL.js +62 -0
- package/template/node_modules/.vite/deps/modal-provider-67CS7MKL.js.map +7 -0
- package/template/node_modules/.vite/deps/node_fs-3RO563AW.js +18 -0
- package/template/node_modules/.vite/deps/node_fs-3RO563AW.js.map +7 -0
- package/template/node_modules/.vite/deps/node_path-5FHEC5YD.js +18 -0
- package/template/node_modules/.vite/deps/node_path-5FHEC5YD.js.map +7 -0
- package/template/node_modules/.vite/deps/package.json +3 -0
- package/template/node_modules/.vite/deps/react-dom.js +6 -0
- package/template/node_modules/.vite/deps/react-dom.js.map +7 -0
- package/template/node_modules/.vite/deps/react-dom_client.js +7 -0
- package/template/node_modules/.vite/deps/react-dom_client.js.map +7 -0
- package/template/node_modules/.vite/deps/react.js +5 -0
- package/template/node_modules/.vite/deps/react.js.map +7 -0
- package/template/node_modules/.vite/deps/react_jsx-dev-runtime.js +265 -0
- package/template/node_modules/.vite/deps/react_jsx-dev-runtime.js.map +7 -0
- package/template/node_modules/.vite/deps/react_jsx-runtime.js +6 -0
- package/template/node_modules/.vite/deps/react_jsx-runtime.js.map +7 -0
- package/template/node_modules/.vite/deps/skybridge_web.js +1508 -0
- package/template/node_modules/.vite/deps/skybridge_web.js.map +7 -0
- package/template/package.json +36 -0
- package/template/server/src/index.ts +67 -0
- package/template/server/src/vite-manifest.d.ts +2 -0
- package/template/tsconfig.json +9 -0
- package/template/web/dist/.vite/manifest.json +24 -0
- package/template/web/dist/assets/magic-8-ball-DWG75vr4.js +10 -0
- package/template/web/dist/assets/modal-provider-BQ1zWEcc.js +18 -0
- package/template/web/dist/assets/style-CH_mzOKc.css +2 -0
- package/template/web/src/helpers.ts +4 -0
- package/template/web/src/index.css +154 -0
- package/template/web/src/widgets/magic-8-ball.tsx +27 -0
- package/template/web/vite.config.ts +15 -0
- package/template/wrangler.jsonc +12 -0
|
@@ -0,0 +1,1508 @@
|
|
|
1
|
+
import {
|
|
2
|
+
require_client
|
|
3
|
+
} from "./chunk-VNABIVRN.js";
|
|
4
|
+
import "./chunk-V2LKO732.js";
|
|
5
|
+
import {
|
|
6
|
+
AppsSdkAdaptor,
|
|
7
|
+
AppsSdkBridge,
|
|
8
|
+
McpAppAdaptor,
|
|
9
|
+
McpAppBridge,
|
|
10
|
+
SET_GLOBALS_EVENT_TYPE,
|
|
11
|
+
SetGlobalsEvent,
|
|
12
|
+
TOOL_RESPONSE_EVENT_TYPE,
|
|
13
|
+
getAdaptor,
|
|
14
|
+
useAppsSdkContext,
|
|
15
|
+
useHostContext,
|
|
16
|
+
useMcpAppContext
|
|
17
|
+
} from "./chunk-YNOAPT43.js";
|
|
18
|
+
import {
|
|
19
|
+
require_jsx_runtime
|
|
20
|
+
} from "./chunk-RKAOJUND.js";
|
|
21
|
+
import {
|
|
22
|
+
require_react
|
|
23
|
+
} from "./chunk-MEVQY4YB.js";
|
|
24
|
+
import {
|
|
25
|
+
__toESM
|
|
26
|
+
} from "./chunk-5WRI5ZAA.js";
|
|
27
|
+
|
|
28
|
+
// ../../../node_modules/.pnpm/zustand@5.0.11_@types+react@19.2.14_immer@9.0.21_react@19.2.4_use-sync-external-store@1.6.0_react@19.2.4_/node_modules/zustand/esm/vanilla.mjs
|
|
29
|
+
var createStoreImpl = (createState) => {
|
|
30
|
+
let state;
|
|
31
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
32
|
+
const setState = (partial, replace) => {
|
|
33
|
+
const nextState = typeof partial === "function" ? partial(state) : partial;
|
|
34
|
+
if (!Object.is(nextState, state)) {
|
|
35
|
+
const previousState = state;
|
|
36
|
+
state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
|
|
37
|
+
listeners.forEach((listener) => listener(state, previousState));
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const getState = () => state;
|
|
41
|
+
const getInitialState2 = () => initialState;
|
|
42
|
+
const subscribe = (listener) => {
|
|
43
|
+
listeners.add(listener);
|
|
44
|
+
return () => listeners.delete(listener);
|
|
45
|
+
};
|
|
46
|
+
const api = { setState, getState, getInitialState: getInitialState2, subscribe };
|
|
47
|
+
const initialState = state = createState(setState, getState, api);
|
|
48
|
+
return api;
|
|
49
|
+
};
|
|
50
|
+
var createStore = ((createState) => createState ? createStoreImpl(createState) : createStoreImpl);
|
|
51
|
+
|
|
52
|
+
// ../../../node_modules/.pnpm/zustand@5.0.11_@types+react@19.2.14_immer@9.0.21_react@19.2.4_use-sync-external-store@1.6.0_react@19.2.4_/node_modules/zustand/esm/react.mjs
|
|
53
|
+
var import_react = __toESM(require_react(), 1);
|
|
54
|
+
var identity = (arg) => arg;
|
|
55
|
+
function useStore(api, selector = identity) {
|
|
56
|
+
const slice = import_react.default.useSyncExternalStore(
|
|
57
|
+
api.subscribe,
|
|
58
|
+
import_react.default.useCallback(() => selector(api.getState()), [api, selector]),
|
|
59
|
+
import_react.default.useCallback(() => selector(api.getInitialState()), [api, selector])
|
|
60
|
+
);
|
|
61
|
+
import_react.default.useDebugValue(slice);
|
|
62
|
+
return slice;
|
|
63
|
+
}
|
|
64
|
+
var createImpl = (createState) => {
|
|
65
|
+
const api = createStore(createState);
|
|
66
|
+
const useBoundStore = (selector) => useStore(api, selector);
|
|
67
|
+
Object.assign(useBoundStore, api);
|
|
68
|
+
return useBoundStore;
|
|
69
|
+
};
|
|
70
|
+
var create = ((createState) => createState ? createImpl(createState) : createImpl);
|
|
71
|
+
|
|
72
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/double-indexed-kv.js
|
|
73
|
+
var DoubleIndexedKV = class {
|
|
74
|
+
constructor() {
|
|
75
|
+
this.keyToValue = /* @__PURE__ */ new Map();
|
|
76
|
+
this.valueToKey = /* @__PURE__ */ new Map();
|
|
77
|
+
}
|
|
78
|
+
set(key, value) {
|
|
79
|
+
this.keyToValue.set(key, value);
|
|
80
|
+
this.valueToKey.set(value, key);
|
|
81
|
+
}
|
|
82
|
+
getByKey(key) {
|
|
83
|
+
return this.keyToValue.get(key);
|
|
84
|
+
}
|
|
85
|
+
getByValue(value) {
|
|
86
|
+
return this.valueToKey.get(value);
|
|
87
|
+
}
|
|
88
|
+
clear() {
|
|
89
|
+
this.keyToValue.clear();
|
|
90
|
+
this.valueToKey.clear();
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/registry.js
|
|
95
|
+
var Registry = class {
|
|
96
|
+
constructor(generateIdentifier) {
|
|
97
|
+
this.generateIdentifier = generateIdentifier;
|
|
98
|
+
this.kv = new DoubleIndexedKV();
|
|
99
|
+
}
|
|
100
|
+
register(value, identifier) {
|
|
101
|
+
if (this.kv.getByValue(value)) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!identifier) {
|
|
105
|
+
identifier = this.generateIdentifier(value);
|
|
106
|
+
}
|
|
107
|
+
this.kv.set(identifier, value);
|
|
108
|
+
}
|
|
109
|
+
clear() {
|
|
110
|
+
this.kv.clear();
|
|
111
|
+
}
|
|
112
|
+
getIdentifier(value) {
|
|
113
|
+
return this.kv.getByValue(value);
|
|
114
|
+
}
|
|
115
|
+
getValue(identifier) {
|
|
116
|
+
return this.kv.getByKey(identifier);
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/class-registry.js
|
|
121
|
+
var ClassRegistry = class extends Registry {
|
|
122
|
+
constructor() {
|
|
123
|
+
super((c) => c.name);
|
|
124
|
+
this.classToAllowedProps = /* @__PURE__ */ new Map();
|
|
125
|
+
}
|
|
126
|
+
register(value, options) {
|
|
127
|
+
if (typeof options === "object") {
|
|
128
|
+
if (options.allowProps) {
|
|
129
|
+
this.classToAllowedProps.set(value, options.allowProps);
|
|
130
|
+
}
|
|
131
|
+
super.register(value, options.identifier);
|
|
132
|
+
} else {
|
|
133
|
+
super.register(value, options);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
getAllowedProps(value) {
|
|
137
|
+
return this.classToAllowedProps.get(value);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/util.js
|
|
142
|
+
function valuesOfObj(record) {
|
|
143
|
+
if ("values" in Object) {
|
|
144
|
+
return Object.values(record);
|
|
145
|
+
}
|
|
146
|
+
const values = [];
|
|
147
|
+
for (const key in record) {
|
|
148
|
+
if (record.hasOwnProperty(key)) {
|
|
149
|
+
values.push(record[key]);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return values;
|
|
153
|
+
}
|
|
154
|
+
function find(record, predicate) {
|
|
155
|
+
const values = valuesOfObj(record);
|
|
156
|
+
if ("find" in values) {
|
|
157
|
+
return values.find(predicate);
|
|
158
|
+
}
|
|
159
|
+
const valuesNotNever = values;
|
|
160
|
+
for (let i = 0; i < valuesNotNever.length; i++) {
|
|
161
|
+
const value = valuesNotNever[i];
|
|
162
|
+
if (predicate(value)) {
|
|
163
|
+
return value;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return void 0;
|
|
167
|
+
}
|
|
168
|
+
function forEach(record, run) {
|
|
169
|
+
Object.entries(record).forEach(([key, value]) => run(value, key));
|
|
170
|
+
}
|
|
171
|
+
function includes(arr, value) {
|
|
172
|
+
return arr.indexOf(value) !== -1;
|
|
173
|
+
}
|
|
174
|
+
function findArr(record, predicate) {
|
|
175
|
+
for (let i = 0; i < record.length; i++) {
|
|
176
|
+
const value = record[i];
|
|
177
|
+
if (predicate(value)) {
|
|
178
|
+
return value;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/custom-transformer-registry.js
|
|
185
|
+
var CustomTransformerRegistry = class {
|
|
186
|
+
constructor() {
|
|
187
|
+
this.transfomers = {};
|
|
188
|
+
}
|
|
189
|
+
register(transformer) {
|
|
190
|
+
this.transfomers[transformer.name] = transformer;
|
|
191
|
+
}
|
|
192
|
+
findApplicable(v) {
|
|
193
|
+
return find(this.transfomers, (transformer) => transformer.isApplicable(v));
|
|
194
|
+
}
|
|
195
|
+
findByName(name) {
|
|
196
|
+
return this.transfomers[name];
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/is.js
|
|
201
|
+
var getType = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
|
|
202
|
+
var isUndefined = (payload) => typeof payload === "undefined";
|
|
203
|
+
var isNull = (payload) => payload === null;
|
|
204
|
+
var isPlainObject = (payload) => {
|
|
205
|
+
if (typeof payload !== "object" || payload === null)
|
|
206
|
+
return false;
|
|
207
|
+
if (payload === Object.prototype)
|
|
208
|
+
return false;
|
|
209
|
+
if (Object.getPrototypeOf(payload) === null)
|
|
210
|
+
return true;
|
|
211
|
+
return Object.getPrototypeOf(payload) === Object.prototype;
|
|
212
|
+
};
|
|
213
|
+
var isEmptyObject = (payload) => isPlainObject(payload) && Object.keys(payload).length === 0;
|
|
214
|
+
var isArray = (payload) => Array.isArray(payload);
|
|
215
|
+
var isString = (payload) => typeof payload === "string";
|
|
216
|
+
var isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
|
|
217
|
+
var isBoolean = (payload) => typeof payload === "boolean";
|
|
218
|
+
var isRegExp = (payload) => payload instanceof RegExp;
|
|
219
|
+
var isMap = (payload) => payload instanceof Map;
|
|
220
|
+
var isSet = (payload) => payload instanceof Set;
|
|
221
|
+
var isSymbol = (payload) => getType(payload) === "Symbol";
|
|
222
|
+
var isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
|
|
223
|
+
var isError = (payload) => payload instanceof Error;
|
|
224
|
+
var isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
|
|
225
|
+
var isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
|
|
226
|
+
var isBigint = (payload) => typeof payload === "bigint";
|
|
227
|
+
var isInfinite = (payload) => payload === Infinity || payload === -Infinity;
|
|
228
|
+
var isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
|
|
229
|
+
var isURL = (payload) => payload instanceof URL;
|
|
230
|
+
|
|
231
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/pathstringifier.js
|
|
232
|
+
var escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
|
|
233
|
+
var stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
|
|
234
|
+
var parsePath = (string, legacyPaths) => {
|
|
235
|
+
const result = [];
|
|
236
|
+
let segment = "";
|
|
237
|
+
for (let i = 0; i < string.length; i++) {
|
|
238
|
+
let char = string.charAt(i);
|
|
239
|
+
if (!legacyPaths && char === "\\") {
|
|
240
|
+
const escaped = string.charAt(i + 1);
|
|
241
|
+
if (escaped === "\\") {
|
|
242
|
+
segment += "\\";
|
|
243
|
+
i++;
|
|
244
|
+
continue;
|
|
245
|
+
} else if (escaped !== ".") {
|
|
246
|
+
throw Error("invalid path");
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
const isEscapedDot = char === "\\" && string.charAt(i + 1) === ".";
|
|
250
|
+
if (isEscapedDot) {
|
|
251
|
+
segment += ".";
|
|
252
|
+
i++;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
const isEndOfSegment = char === ".";
|
|
256
|
+
if (isEndOfSegment) {
|
|
257
|
+
result.push(segment);
|
|
258
|
+
segment = "";
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
segment += char;
|
|
262
|
+
}
|
|
263
|
+
const lastSegment = segment;
|
|
264
|
+
result.push(lastSegment);
|
|
265
|
+
return result;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/transformer.js
|
|
269
|
+
function simpleTransformation(isApplicable, annotation, transform2, untransform) {
|
|
270
|
+
return {
|
|
271
|
+
isApplicable,
|
|
272
|
+
annotation,
|
|
273
|
+
transform: transform2,
|
|
274
|
+
untransform
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
var simpleRules = [
|
|
278
|
+
simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
|
|
279
|
+
simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
|
|
280
|
+
if (typeof BigInt !== "undefined") {
|
|
281
|
+
return BigInt(v);
|
|
282
|
+
}
|
|
283
|
+
console.error("Please add a BigInt polyfill.");
|
|
284
|
+
return v;
|
|
285
|
+
}),
|
|
286
|
+
simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
|
|
287
|
+
simpleTransformation(isError, "Error", (v, superJson) => {
|
|
288
|
+
const baseError = {
|
|
289
|
+
name: v.name,
|
|
290
|
+
message: v.message
|
|
291
|
+
};
|
|
292
|
+
if ("cause" in v) {
|
|
293
|
+
baseError.cause = v.cause;
|
|
294
|
+
}
|
|
295
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
296
|
+
baseError[prop] = v[prop];
|
|
297
|
+
});
|
|
298
|
+
return baseError;
|
|
299
|
+
}, (v, superJson) => {
|
|
300
|
+
const e = new Error(v.message, { cause: v.cause });
|
|
301
|
+
e.name = v.name;
|
|
302
|
+
e.stack = v.stack;
|
|
303
|
+
superJson.allowedErrorProps.forEach((prop) => {
|
|
304
|
+
e[prop] = v[prop];
|
|
305
|
+
});
|
|
306
|
+
return e;
|
|
307
|
+
}),
|
|
308
|
+
simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
|
|
309
|
+
const body = regex.slice(1, regex.lastIndexOf("/"));
|
|
310
|
+
const flags = regex.slice(regex.lastIndexOf("/") + 1);
|
|
311
|
+
return new RegExp(body, flags);
|
|
312
|
+
}),
|
|
313
|
+
simpleTransformation(
|
|
314
|
+
isSet,
|
|
315
|
+
"set",
|
|
316
|
+
// (sets only exist in es6+)
|
|
317
|
+
// eslint-disable-next-line es5/no-es6-methods
|
|
318
|
+
(v) => [...v.values()],
|
|
319
|
+
(v) => new Set(v)
|
|
320
|
+
),
|
|
321
|
+
simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
|
|
322
|
+
simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
|
|
323
|
+
if (isNaNValue(v)) {
|
|
324
|
+
return "NaN";
|
|
325
|
+
}
|
|
326
|
+
if (v > 0) {
|
|
327
|
+
return "Infinity";
|
|
328
|
+
} else {
|
|
329
|
+
return "-Infinity";
|
|
330
|
+
}
|
|
331
|
+
}, Number),
|
|
332
|
+
simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
|
|
333
|
+
return "-0";
|
|
334
|
+
}, Number),
|
|
335
|
+
simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
|
|
336
|
+
];
|
|
337
|
+
function compositeTransformation(isApplicable, annotation, transform2, untransform) {
|
|
338
|
+
return {
|
|
339
|
+
isApplicable,
|
|
340
|
+
annotation,
|
|
341
|
+
transform: transform2,
|
|
342
|
+
untransform
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
var symbolRule = compositeTransformation((s, superJson) => {
|
|
346
|
+
if (isSymbol(s)) {
|
|
347
|
+
const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
|
|
348
|
+
return isRegistered;
|
|
349
|
+
}
|
|
350
|
+
return false;
|
|
351
|
+
}, (s, superJson) => {
|
|
352
|
+
const identifier = superJson.symbolRegistry.getIdentifier(s);
|
|
353
|
+
return ["symbol", identifier];
|
|
354
|
+
}, (v) => v.description, (_, a, superJson) => {
|
|
355
|
+
const value = superJson.symbolRegistry.getValue(a[1]);
|
|
356
|
+
if (!value) {
|
|
357
|
+
throw new Error("Trying to deserialize unknown symbol");
|
|
358
|
+
}
|
|
359
|
+
return value;
|
|
360
|
+
});
|
|
361
|
+
var constructorToName = [
|
|
362
|
+
Int8Array,
|
|
363
|
+
Uint8Array,
|
|
364
|
+
Int16Array,
|
|
365
|
+
Uint16Array,
|
|
366
|
+
Int32Array,
|
|
367
|
+
Uint32Array,
|
|
368
|
+
Float32Array,
|
|
369
|
+
Float64Array,
|
|
370
|
+
Uint8ClampedArray
|
|
371
|
+
].reduce((obj, ctor) => {
|
|
372
|
+
obj[ctor.name] = ctor;
|
|
373
|
+
return obj;
|
|
374
|
+
}, {});
|
|
375
|
+
var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
|
|
376
|
+
const ctor = constructorToName[a[1]];
|
|
377
|
+
if (!ctor) {
|
|
378
|
+
throw new Error("Trying to deserialize unknown typed array");
|
|
379
|
+
}
|
|
380
|
+
return new ctor(v);
|
|
381
|
+
});
|
|
382
|
+
function isInstanceOfRegisteredClass(potentialClass, superJson) {
|
|
383
|
+
if (potentialClass?.constructor) {
|
|
384
|
+
const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
|
|
385
|
+
return isRegistered;
|
|
386
|
+
}
|
|
387
|
+
return false;
|
|
388
|
+
}
|
|
389
|
+
var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
|
|
390
|
+
const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
|
|
391
|
+
return ["class", identifier];
|
|
392
|
+
}, (clazz, superJson) => {
|
|
393
|
+
const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
|
|
394
|
+
if (!allowedProps) {
|
|
395
|
+
return { ...clazz };
|
|
396
|
+
}
|
|
397
|
+
const result = {};
|
|
398
|
+
allowedProps.forEach((prop) => {
|
|
399
|
+
result[prop] = clazz[prop];
|
|
400
|
+
});
|
|
401
|
+
return result;
|
|
402
|
+
}, (v, a, superJson) => {
|
|
403
|
+
const clazz = superJson.classRegistry.getValue(a[1]);
|
|
404
|
+
if (!clazz) {
|
|
405
|
+
throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
|
|
406
|
+
}
|
|
407
|
+
return Object.assign(Object.create(clazz.prototype), v);
|
|
408
|
+
});
|
|
409
|
+
var customRule = compositeTransformation((value, superJson) => {
|
|
410
|
+
return !!superJson.customTransformerRegistry.findApplicable(value);
|
|
411
|
+
}, (value, superJson) => {
|
|
412
|
+
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
413
|
+
return ["custom", transformer.name];
|
|
414
|
+
}, (value, superJson) => {
|
|
415
|
+
const transformer = superJson.customTransformerRegistry.findApplicable(value);
|
|
416
|
+
return transformer.serialize(value);
|
|
417
|
+
}, (v, a, superJson) => {
|
|
418
|
+
const transformer = superJson.customTransformerRegistry.findByName(a[1]);
|
|
419
|
+
if (!transformer) {
|
|
420
|
+
throw new Error("Trying to deserialize unknown custom value");
|
|
421
|
+
}
|
|
422
|
+
return transformer.deserialize(v);
|
|
423
|
+
});
|
|
424
|
+
var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
|
|
425
|
+
var transformValue = (value, superJson) => {
|
|
426
|
+
const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
|
|
427
|
+
if (applicableCompositeRule) {
|
|
428
|
+
return {
|
|
429
|
+
value: applicableCompositeRule.transform(value, superJson),
|
|
430
|
+
type: applicableCompositeRule.annotation(value, superJson)
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
|
|
434
|
+
if (applicableSimpleRule) {
|
|
435
|
+
return {
|
|
436
|
+
value: applicableSimpleRule.transform(value, superJson),
|
|
437
|
+
type: applicableSimpleRule.annotation
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
return void 0;
|
|
441
|
+
};
|
|
442
|
+
var simpleRulesByAnnotation = {};
|
|
443
|
+
simpleRules.forEach((rule) => {
|
|
444
|
+
simpleRulesByAnnotation[rule.annotation] = rule;
|
|
445
|
+
});
|
|
446
|
+
var untransformValue = (json, type, superJson) => {
|
|
447
|
+
if (isArray(type)) {
|
|
448
|
+
switch (type[0]) {
|
|
449
|
+
case "symbol":
|
|
450
|
+
return symbolRule.untransform(json, type, superJson);
|
|
451
|
+
case "class":
|
|
452
|
+
return classRule.untransform(json, type, superJson);
|
|
453
|
+
case "custom":
|
|
454
|
+
return customRule.untransform(json, type, superJson);
|
|
455
|
+
case "typed-array":
|
|
456
|
+
return typedArrayRule.untransform(json, type, superJson);
|
|
457
|
+
default:
|
|
458
|
+
throw new Error("Unknown transformation: " + type);
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
const transformation = simpleRulesByAnnotation[type];
|
|
462
|
+
if (!transformation) {
|
|
463
|
+
throw new Error("Unknown transformation: " + type);
|
|
464
|
+
}
|
|
465
|
+
return transformation.untransform(json, superJson);
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/accessDeep.js
|
|
470
|
+
var getNthKey = (value, n) => {
|
|
471
|
+
if (n > value.size)
|
|
472
|
+
throw new Error("index out of bounds");
|
|
473
|
+
const keys = value.keys();
|
|
474
|
+
while (n > 0) {
|
|
475
|
+
keys.next();
|
|
476
|
+
n--;
|
|
477
|
+
}
|
|
478
|
+
return keys.next().value;
|
|
479
|
+
};
|
|
480
|
+
function validatePath(path) {
|
|
481
|
+
if (includes(path, "__proto__")) {
|
|
482
|
+
throw new Error("__proto__ is not allowed as a property");
|
|
483
|
+
}
|
|
484
|
+
if (includes(path, "prototype")) {
|
|
485
|
+
throw new Error("prototype is not allowed as a property");
|
|
486
|
+
}
|
|
487
|
+
if (includes(path, "constructor")) {
|
|
488
|
+
throw new Error("constructor is not allowed as a property");
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
var getDeep = (object, path) => {
|
|
492
|
+
validatePath(path);
|
|
493
|
+
for (let i = 0; i < path.length; i++) {
|
|
494
|
+
const key = path[i];
|
|
495
|
+
if (isSet(object)) {
|
|
496
|
+
object = getNthKey(object, +key);
|
|
497
|
+
} else if (isMap(object)) {
|
|
498
|
+
const row = +key;
|
|
499
|
+
const type = +path[++i] === 0 ? "key" : "value";
|
|
500
|
+
const keyOfRow = getNthKey(object, row);
|
|
501
|
+
switch (type) {
|
|
502
|
+
case "key":
|
|
503
|
+
object = keyOfRow;
|
|
504
|
+
break;
|
|
505
|
+
case "value":
|
|
506
|
+
object = object.get(keyOfRow);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
} else {
|
|
510
|
+
object = object[key];
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return object;
|
|
514
|
+
};
|
|
515
|
+
var setDeep = (object, path, mapper) => {
|
|
516
|
+
validatePath(path);
|
|
517
|
+
if (path.length === 0) {
|
|
518
|
+
return mapper(object);
|
|
519
|
+
}
|
|
520
|
+
let parent = object;
|
|
521
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
522
|
+
const key = path[i];
|
|
523
|
+
if (isArray(parent)) {
|
|
524
|
+
const index = +key;
|
|
525
|
+
parent = parent[index];
|
|
526
|
+
} else if (isPlainObject(parent)) {
|
|
527
|
+
parent = parent[key];
|
|
528
|
+
} else if (isSet(parent)) {
|
|
529
|
+
const row = +key;
|
|
530
|
+
parent = getNthKey(parent, row);
|
|
531
|
+
} else if (isMap(parent)) {
|
|
532
|
+
const isEnd = i === path.length - 2;
|
|
533
|
+
if (isEnd) {
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
const row = +key;
|
|
537
|
+
const type = +path[++i] === 0 ? "key" : "value";
|
|
538
|
+
const keyOfRow = getNthKey(parent, row);
|
|
539
|
+
switch (type) {
|
|
540
|
+
case "key":
|
|
541
|
+
parent = keyOfRow;
|
|
542
|
+
break;
|
|
543
|
+
case "value":
|
|
544
|
+
parent = parent.get(keyOfRow);
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
const lastKey = path[path.length - 1];
|
|
550
|
+
if (isArray(parent)) {
|
|
551
|
+
parent[+lastKey] = mapper(parent[+lastKey]);
|
|
552
|
+
} else if (isPlainObject(parent)) {
|
|
553
|
+
parent[lastKey] = mapper(parent[lastKey]);
|
|
554
|
+
}
|
|
555
|
+
if (isSet(parent)) {
|
|
556
|
+
const oldValue = getNthKey(parent, +lastKey);
|
|
557
|
+
const newValue = mapper(oldValue);
|
|
558
|
+
if (oldValue !== newValue) {
|
|
559
|
+
parent.delete(oldValue);
|
|
560
|
+
parent.add(newValue);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
if (isMap(parent)) {
|
|
564
|
+
const row = +path[path.length - 2];
|
|
565
|
+
const keyToRow = getNthKey(parent, row);
|
|
566
|
+
const type = +lastKey === 0 ? "key" : "value";
|
|
567
|
+
switch (type) {
|
|
568
|
+
case "key": {
|
|
569
|
+
const newKey = mapper(keyToRow);
|
|
570
|
+
parent.set(newKey, parent.get(keyToRow));
|
|
571
|
+
if (newKey !== keyToRow) {
|
|
572
|
+
parent.delete(keyToRow);
|
|
573
|
+
}
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
case "value": {
|
|
577
|
+
parent.set(keyToRow, mapper(parent.get(keyToRow)));
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
return object;
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/plainer.js
|
|
586
|
+
var enableLegacyPaths = (version) => version < 1;
|
|
587
|
+
function traverse(tree, walker2, version, origin = []) {
|
|
588
|
+
if (!tree) {
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
591
|
+
const legacyPaths = enableLegacyPaths(version);
|
|
592
|
+
if (!isArray(tree)) {
|
|
593
|
+
forEach(tree, (subtree, key) => traverse(subtree, walker2, version, [
|
|
594
|
+
...origin,
|
|
595
|
+
...parsePath(key, legacyPaths)
|
|
596
|
+
]));
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const [nodeValue, children] = tree;
|
|
600
|
+
if (children) {
|
|
601
|
+
forEach(children, (child, key) => {
|
|
602
|
+
traverse(child, walker2, version, [
|
|
603
|
+
...origin,
|
|
604
|
+
...parsePath(key, legacyPaths)
|
|
605
|
+
]);
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
walker2(nodeValue, origin);
|
|
609
|
+
}
|
|
610
|
+
function applyValueAnnotations(plain, annotations, version, superJson) {
|
|
611
|
+
traverse(annotations, (type, path) => {
|
|
612
|
+
plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
|
|
613
|
+
}, version);
|
|
614
|
+
return plain;
|
|
615
|
+
}
|
|
616
|
+
function applyReferentialEqualityAnnotations(plain, annotations, version) {
|
|
617
|
+
const legacyPaths = enableLegacyPaths(version);
|
|
618
|
+
function apply(identicalPaths, path) {
|
|
619
|
+
const object = getDeep(plain, parsePath(path, legacyPaths));
|
|
620
|
+
identicalPaths.map((path2) => parsePath(path2, legacyPaths)).forEach((identicalObjectPath) => {
|
|
621
|
+
plain = setDeep(plain, identicalObjectPath, () => object);
|
|
622
|
+
});
|
|
623
|
+
}
|
|
624
|
+
if (isArray(annotations)) {
|
|
625
|
+
const [root, other] = annotations;
|
|
626
|
+
root.forEach((identicalPath) => {
|
|
627
|
+
plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
|
|
628
|
+
});
|
|
629
|
+
if (other) {
|
|
630
|
+
forEach(other, apply);
|
|
631
|
+
}
|
|
632
|
+
} else {
|
|
633
|
+
forEach(annotations, apply);
|
|
634
|
+
}
|
|
635
|
+
return plain;
|
|
636
|
+
}
|
|
637
|
+
var isDeep = (object, superJson) => isPlainObject(object) || isArray(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
|
|
638
|
+
function addIdentity(object, path, identities) {
|
|
639
|
+
const existingSet = identities.get(object);
|
|
640
|
+
if (existingSet) {
|
|
641
|
+
existingSet.push(path);
|
|
642
|
+
} else {
|
|
643
|
+
identities.set(object, [path]);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
function generateReferentialEqualityAnnotations(identitites, dedupe) {
|
|
647
|
+
const result = {};
|
|
648
|
+
let rootEqualityPaths = void 0;
|
|
649
|
+
identitites.forEach((paths) => {
|
|
650
|
+
if (paths.length <= 1) {
|
|
651
|
+
return;
|
|
652
|
+
}
|
|
653
|
+
if (!dedupe) {
|
|
654
|
+
paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
|
|
655
|
+
}
|
|
656
|
+
const [representativePath, ...identicalPaths] = paths;
|
|
657
|
+
if (representativePath.length === 0) {
|
|
658
|
+
rootEqualityPaths = identicalPaths.map(stringifyPath);
|
|
659
|
+
} else {
|
|
660
|
+
result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
if (rootEqualityPaths) {
|
|
664
|
+
if (isEmptyObject(result)) {
|
|
665
|
+
return [rootEqualityPaths];
|
|
666
|
+
} else {
|
|
667
|
+
return [rootEqualityPaths, result];
|
|
668
|
+
}
|
|
669
|
+
} else {
|
|
670
|
+
return isEmptyObject(result) ? void 0 : result;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
var walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
|
|
674
|
+
const primitive = isPrimitive(object);
|
|
675
|
+
if (!primitive) {
|
|
676
|
+
addIdentity(object, path, identities);
|
|
677
|
+
const seen = seenObjects.get(object);
|
|
678
|
+
if (seen) {
|
|
679
|
+
return dedupe ? {
|
|
680
|
+
transformedValue: null
|
|
681
|
+
} : seen;
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (!isDeep(object, superJson)) {
|
|
685
|
+
const transformed2 = transformValue(object, superJson);
|
|
686
|
+
const result2 = transformed2 ? {
|
|
687
|
+
transformedValue: transformed2.value,
|
|
688
|
+
annotations: [transformed2.type]
|
|
689
|
+
} : {
|
|
690
|
+
transformedValue: object
|
|
691
|
+
};
|
|
692
|
+
if (!primitive) {
|
|
693
|
+
seenObjects.set(object, result2);
|
|
694
|
+
}
|
|
695
|
+
return result2;
|
|
696
|
+
}
|
|
697
|
+
if (includes(objectsInThisPath, object)) {
|
|
698
|
+
return {
|
|
699
|
+
transformedValue: null
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
const transformationResult = transformValue(object, superJson);
|
|
703
|
+
const transformed = transformationResult?.value ?? object;
|
|
704
|
+
const transformedValue = isArray(transformed) ? [] : {};
|
|
705
|
+
const innerAnnotations = {};
|
|
706
|
+
forEach(transformed, (value, index) => {
|
|
707
|
+
if (index === "__proto__" || index === "constructor" || index === "prototype") {
|
|
708
|
+
throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
|
|
709
|
+
}
|
|
710
|
+
const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
|
|
711
|
+
transformedValue[index] = recursiveResult.transformedValue;
|
|
712
|
+
if (isArray(recursiveResult.annotations)) {
|
|
713
|
+
innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
|
|
714
|
+
} else if (isPlainObject(recursiveResult.annotations)) {
|
|
715
|
+
forEach(recursiveResult.annotations, (tree, key) => {
|
|
716
|
+
innerAnnotations[escapeKey(index) + "." + key] = tree;
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
});
|
|
720
|
+
const result = isEmptyObject(innerAnnotations) ? {
|
|
721
|
+
transformedValue,
|
|
722
|
+
annotations: !!transformationResult ? [transformationResult.type] : void 0
|
|
723
|
+
} : {
|
|
724
|
+
transformedValue,
|
|
725
|
+
annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
|
|
726
|
+
};
|
|
727
|
+
if (!primitive) {
|
|
728
|
+
seenObjects.set(object, result);
|
|
729
|
+
}
|
|
730
|
+
return result;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
// ../../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
|
|
734
|
+
function getType2(payload) {
|
|
735
|
+
return Object.prototype.toString.call(payload).slice(8, -1);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
// ../../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
|
|
739
|
+
function isArray2(payload) {
|
|
740
|
+
return getType2(payload) === "Array";
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
// ../../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
|
|
744
|
+
function isPlainObject2(payload) {
|
|
745
|
+
if (getType2(payload) !== "Object")
|
|
746
|
+
return false;
|
|
747
|
+
const prototype = Object.getPrototypeOf(payload);
|
|
748
|
+
return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
// ../../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isNull.js
|
|
752
|
+
function isNull2(payload) {
|
|
753
|
+
return getType2(payload) === "Null";
|
|
754
|
+
}
|
|
755
|
+
|
|
756
|
+
// ../../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isOneOf.js
|
|
757
|
+
function isOneOf(a, b, c, d, e) {
|
|
758
|
+
return (value) => a(value) || b(value) || !!c && c(value) || !!d && d(value) || !!e && e(value);
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
// ../../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isUndefined.js
|
|
762
|
+
function isUndefined2(payload) {
|
|
763
|
+
return getType2(payload) === "Undefined";
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// ../../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isNullOrUndefined.js
|
|
767
|
+
var isNullOrUndefined = isOneOf(isNull2, isUndefined2);
|
|
768
|
+
|
|
769
|
+
// ../../../node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
|
|
770
|
+
function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
|
|
771
|
+
const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
|
|
772
|
+
if (propType === "enumerable")
|
|
773
|
+
carry[key] = newVal;
|
|
774
|
+
if (includeNonenumerable && propType === "nonenumerable") {
|
|
775
|
+
Object.defineProperty(carry, key, {
|
|
776
|
+
value: newVal,
|
|
777
|
+
enumerable: false,
|
|
778
|
+
writable: true,
|
|
779
|
+
configurable: true
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
function copy(target, options = {}) {
|
|
784
|
+
if (isArray2(target)) {
|
|
785
|
+
return target.map((item) => copy(item, options));
|
|
786
|
+
}
|
|
787
|
+
if (!isPlainObject2(target)) {
|
|
788
|
+
return target;
|
|
789
|
+
}
|
|
790
|
+
const props = Object.getOwnPropertyNames(target);
|
|
791
|
+
const symbols = Object.getOwnPropertySymbols(target);
|
|
792
|
+
return [...props, ...symbols].reduce((carry, key) => {
|
|
793
|
+
if (key === "__proto__")
|
|
794
|
+
return carry;
|
|
795
|
+
if (isArray2(options.props) && !options.props.includes(key)) {
|
|
796
|
+
return carry;
|
|
797
|
+
}
|
|
798
|
+
const val = target[key];
|
|
799
|
+
const newVal = copy(val, options);
|
|
800
|
+
assignProp(carry, key, newVal, target, options.nonenumerable);
|
|
801
|
+
return carry;
|
|
802
|
+
}, {});
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// ../../../node_modules/.pnpm/superjson@2.2.6/node_modules/superjson/dist/index.js
|
|
806
|
+
var SuperJSON = class {
|
|
807
|
+
/**
|
|
808
|
+
* @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
|
|
809
|
+
*/
|
|
810
|
+
constructor({ dedupe = false } = {}) {
|
|
811
|
+
this.classRegistry = new ClassRegistry();
|
|
812
|
+
this.symbolRegistry = new Registry((s) => s.description ?? "");
|
|
813
|
+
this.customTransformerRegistry = new CustomTransformerRegistry();
|
|
814
|
+
this.allowedErrorProps = [];
|
|
815
|
+
this.dedupe = dedupe;
|
|
816
|
+
}
|
|
817
|
+
serialize(object) {
|
|
818
|
+
const identities = /* @__PURE__ */ new Map();
|
|
819
|
+
const output = walker(object, identities, this, this.dedupe);
|
|
820
|
+
const res = {
|
|
821
|
+
json: output.transformedValue
|
|
822
|
+
};
|
|
823
|
+
if (output.annotations) {
|
|
824
|
+
res.meta = {
|
|
825
|
+
...res.meta,
|
|
826
|
+
values: output.annotations
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
|
|
830
|
+
if (equalityAnnotations) {
|
|
831
|
+
res.meta = {
|
|
832
|
+
...res.meta,
|
|
833
|
+
referentialEqualities: equalityAnnotations
|
|
834
|
+
};
|
|
835
|
+
}
|
|
836
|
+
if (res.meta)
|
|
837
|
+
res.meta.v = 1;
|
|
838
|
+
return res;
|
|
839
|
+
}
|
|
840
|
+
deserialize(payload, options) {
|
|
841
|
+
const { json, meta } = payload;
|
|
842
|
+
let result = options?.inPlace ? json : copy(json);
|
|
843
|
+
if (meta?.values) {
|
|
844
|
+
result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
|
|
845
|
+
}
|
|
846
|
+
if (meta?.referentialEqualities) {
|
|
847
|
+
result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
|
|
848
|
+
}
|
|
849
|
+
return result;
|
|
850
|
+
}
|
|
851
|
+
stringify(object) {
|
|
852
|
+
return JSON.stringify(this.serialize(object));
|
|
853
|
+
}
|
|
854
|
+
parse(string) {
|
|
855
|
+
return this.deserialize(JSON.parse(string), { inPlace: true });
|
|
856
|
+
}
|
|
857
|
+
registerClass(v, options) {
|
|
858
|
+
this.classRegistry.register(v, options);
|
|
859
|
+
}
|
|
860
|
+
registerSymbol(v, identifier) {
|
|
861
|
+
this.symbolRegistry.register(v, identifier);
|
|
862
|
+
}
|
|
863
|
+
registerCustom(transformer, name) {
|
|
864
|
+
this.customTransformerRegistry.register({
|
|
865
|
+
name,
|
|
866
|
+
...transformer
|
|
867
|
+
});
|
|
868
|
+
}
|
|
869
|
+
allowErrorProps(...props) {
|
|
870
|
+
this.allowedErrorProps.push(...props);
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
SuperJSON.defaultInstance = new SuperJSON();
|
|
874
|
+
SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
|
|
875
|
+
SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
|
|
876
|
+
SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
|
|
877
|
+
SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
|
|
878
|
+
SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
|
|
879
|
+
SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
|
|
880
|
+
SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
|
|
881
|
+
SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
|
|
882
|
+
var dist_default = SuperJSON;
|
|
883
|
+
var serialize = SuperJSON.serialize;
|
|
884
|
+
var deserialize = SuperJSON.deserialize;
|
|
885
|
+
var stringify = SuperJSON.stringify;
|
|
886
|
+
var parse = SuperJSON.parse;
|
|
887
|
+
var registerClass = SuperJSON.registerClass;
|
|
888
|
+
var registerCustom = SuperJSON.registerCustom;
|
|
889
|
+
var registerSymbol = SuperJSON.registerSymbol;
|
|
890
|
+
var allowErrorProps = SuperJSON.allowErrorProps;
|
|
891
|
+
|
|
892
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/data-llm.js
|
|
893
|
+
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
894
|
+
var import_react2 = __toESM(require_react(), 1);
|
|
895
|
+
var WIDGET_CONTEXT_KEY = "__widget_context";
|
|
896
|
+
var nodes = /* @__PURE__ */ new Map();
|
|
897
|
+
function setNode(node) {
|
|
898
|
+
nodes.set(node.id, node);
|
|
899
|
+
onChange();
|
|
900
|
+
}
|
|
901
|
+
function removeNode(id) {
|
|
902
|
+
nodes.delete(id);
|
|
903
|
+
onChange();
|
|
904
|
+
}
|
|
905
|
+
function onChange() {
|
|
906
|
+
const description = getLLMDescriptionString();
|
|
907
|
+
const adaptor = getAdaptor();
|
|
908
|
+
adaptor.setWidgetState((prevState) => ({
|
|
909
|
+
...prevState,
|
|
910
|
+
[WIDGET_CONTEXT_KEY]: description
|
|
911
|
+
}));
|
|
912
|
+
}
|
|
913
|
+
var ParentIdContext = (0, import_react2.createContext)(null);
|
|
914
|
+
function DataLLM({ content, children }) {
|
|
915
|
+
const parentId = (0, import_react2.useContext)(ParentIdContext);
|
|
916
|
+
const id = (0, import_react2.useId)();
|
|
917
|
+
(0, import_react2.useEffect)(() => {
|
|
918
|
+
if (content) {
|
|
919
|
+
setNode({
|
|
920
|
+
id,
|
|
921
|
+
parentId,
|
|
922
|
+
content
|
|
923
|
+
});
|
|
924
|
+
} else {
|
|
925
|
+
removeNode(id);
|
|
926
|
+
}
|
|
927
|
+
return () => {
|
|
928
|
+
removeNode(id);
|
|
929
|
+
};
|
|
930
|
+
}, [id, parentId, content]);
|
|
931
|
+
return (0, import_jsx_runtime.jsx)(ParentIdContext.Provider, { value: id, children });
|
|
932
|
+
}
|
|
933
|
+
function getLLMDescriptionString() {
|
|
934
|
+
const byParent = /* @__PURE__ */ new Map();
|
|
935
|
+
for (const node of Array.from(nodes.values())) {
|
|
936
|
+
const key = node.parentId ?? null;
|
|
937
|
+
if (!byParent.has(key)) {
|
|
938
|
+
byParent.set(key, []);
|
|
939
|
+
}
|
|
940
|
+
byParent.get(key)?.push(node);
|
|
941
|
+
}
|
|
942
|
+
for (const list of byParent.values()) {
|
|
943
|
+
list.sort((a, b) => a.id.localeCompare(b.id));
|
|
944
|
+
}
|
|
945
|
+
const lines = [];
|
|
946
|
+
function traverseTree(parentId, depth) {
|
|
947
|
+
const children = byParent.get(parentId);
|
|
948
|
+
if (!children) {
|
|
949
|
+
return;
|
|
950
|
+
}
|
|
951
|
+
for (const child of children) {
|
|
952
|
+
if (child.content?.trim()) {
|
|
953
|
+
const indent = " ".repeat(depth);
|
|
954
|
+
lines.push(`${indent}- ${child.content.trim()}`);
|
|
955
|
+
}
|
|
956
|
+
traverseTree(child.id, depth + 1);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
traverseTree(null, 0);
|
|
960
|
+
return lines.join("\n");
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/helpers/state.js
|
|
964
|
+
function filterWidgetContext(state) {
|
|
965
|
+
if (state === null || state === void 0) {
|
|
966
|
+
return null;
|
|
967
|
+
}
|
|
968
|
+
const { [WIDGET_CONTEXT_KEY]: _, ...filteredState } = state;
|
|
969
|
+
return filteredState;
|
|
970
|
+
}
|
|
971
|
+
function injectWidgetContext(newState) {
|
|
972
|
+
if (newState === null) {
|
|
973
|
+
return null;
|
|
974
|
+
}
|
|
975
|
+
const currentState = getAdaptor().getHostContextStore("widgetState").getSnapshot();
|
|
976
|
+
if (currentState !== null && currentState !== void 0 && WIDGET_CONTEXT_KEY in currentState) {
|
|
977
|
+
return {
|
|
978
|
+
...newState,
|
|
979
|
+
[WIDGET_CONTEXT_KEY]: currentState[WIDGET_CONTEXT_KEY]
|
|
980
|
+
};
|
|
981
|
+
}
|
|
982
|
+
return newState;
|
|
983
|
+
}
|
|
984
|
+
function serializeState(value) {
|
|
985
|
+
return dist_default.parse(dist_default.stringify(value));
|
|
986
|
+
}
|
|
987
|
+
function getInitialState(defaultState) {
|
|
988
|
+
const widgetState = getAdaptor().getHostContextStore("widgetState").getSnapshot();
|
|
989
|
+
if (widgetState !== null && widgetState !== void 0) {
|
|
990
|
+
return filterWidgetContext(widgetState);
|
|
991
|
+
}
|
|
992
|
+
return typeof defaultState === "function" ? defaultState() : defaultState ?? null;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/create-store.js
|
|
996
|
+
function createStore2(storeCreator, defaultState) {
|
|
997
|
+
const initialState = getInitialState(defaultState);
|
|
998
|
+
const store = create()((...args) => {
|
|
999
|
+
const baseStore = storeCreator(...args);
|
|
1000
|
+
if (initialState !== null) {
|
|
1001
|
+
return { ...baseStore, ...initialState };
|
|
1002
|
+
}
|
|
1003
|
+
return baseStore;
|
|
1004
|
+
});
|
|
1005
|
+
store.subscribe((state) => {
|
|
1006
|
+
const serializedState = serializeState(state);
|
|
1007
|
+
if (serializedState !== null && serializedState !== void 0) {
|
|
1008
|
+
const stateToPersist = injectWidgetContext(serializedState);
|
|
1009
|
+
if (stateToPersist !== null) {
|
|
1010
|
+
getAdaptor().setWidgetState(stateToPersist);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
});
|
|
1014
|
+
return store;
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-call-tool.js
|
|
1018
|
+
var import_react3 = __toESM(require_react(), 1);
|
|
1019
|
+
var useCallTool = (name) => {
|
|
1020
|
+
const [{ status, data, error }, setCallToolState] = (0, import_react3.useState)({ status: "idle", data: void 0, error: void 0 });
|
|
1021
|
+
const callIdRef = (0, import_react3.useRef)(0);
|
|
1022
|
+
const adaptor = getAdaptor();
|
|
1023
|
+
const execute = async (toolArgs) => {
|
|
1024
|
+
const callId = ++callIdRef.current;
|
|
1025
|
+
setCallToolState({ status: "pending", data: void 0, error: void 0 });
|
|
1026
|
+
try {
|
|
1027
|
+
const data2 = await adaptor.callTool(name, toolArgs);
|
|
1028
|
+
if (callId === callIdRef.current) {
|
|
1029
|
+
setCallToolState({ status: "success", data: data2, error: void 0 });
|
|
1030
|
+
}
|
|
1031
|
+
return data2;
|
|
1032
|
+
} catch (error2) {
|
|
1033
|
+
if (callId === callIdRef.current) {
|
|
1034
|
+
setCallToolState({ status: "error", data: void 0, error: error2 });
|
|
1035
|
+
}
|
|
1036
|
+
throw error2;
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
const callToolAsync = ((toolArgs) => {
|
|
1040
|
+
if (toolArgs === void 0) {
|
|
1041
|
+
return execute(null);
|
|
1042
|
+
}
|
|
1043
|
+
return execute(toolArgs);
|
|
1044
|
+
});
|
|
1045
|
+
const callTool = ((firstArg, sideEffects) => {
|
|
1046
|
+
let toolArgs;
|
|
1047
|
+
if (firstArg && typeof firstArg === "object" && ("onSuccess" in firstArg || "onError" in firstArg || "onSettled" in firstArg)) {
|
|
1048
|
+
toolArgs = null;
|
|
1049
|
+
sideEffects = firstArg;
|
|
1050
|
+
} else {
|
|
1051
|
+
toolArgs = firstArg === void 0 ? null : firstArg;
|
|
1052
|
+
}
|
|
1053
|
+
execute(toolArgs).then((data2) => {
|
|
1054
|
+
sideEffects?.onSuccess?.(data2, toolArgs);
|
|
1055
|
+
sideEffects?.onSettled?.(data2, void 0, toolArgs);
|
|
1056
|
+
}).catch((error2) => {
|
|
1057
|
+
sideEffects?.onError?.(error2, toolArgs);
|
|
1058
|
+
sideEffects?.onSettled?.(void 0, error2, toolArgs);
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1061
|
+
const callToolState = {
|
|
1062
|
+
status,
|
|
1063
|
+
data,
|
|
1064
|
+
error,
|
|
1065
|
+
isIdle: status === "idle",
|
|
1066
|
+
isPending: status === "pending",
|
|
1067
|
+
isSuccess: status === "success",
|
|
1068
|
+
isError: status === "error"
|
|
1069
|
+
};
|
|
1070
|
+
return {
|
|
1071
|
+
...callToolState,
|
|
1072
|
+
callTool,
|
|
1073
|
+
callToolAsync
|
|
1074
|
+
};
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-tool-info.js
|
|
1078
|
+
function deriveStatus(input, output, responseMetadata) {
|
|
1079
|
+
if (input === null) {
|
|
1080
|
+
return "idle";
|
|
1081
|
+
}
|
|
1082
|
+
if (output === null && responseMetadata === null) {
|
|
1083
|
+
return "pending";
|
|
1084
|
+
}
|
|
1085
|
+
return "success";
|
|
1086
|
+
}
|
|
1087
|
+
function useToolInfo() {
|
|
1088
|
+
const input = useHostContext("toolInput");
|
|
1089
|
+
const output = useHostContext("toolOutput");
|
|
1090
|
+
const responseMetadata = useHostContext("toolResponseMetadata");
|
|
1091
|
+
const status = deriveStatus(input, output, responseMetadata);
|
|
1092
|
+
return {
|
|
1093
|
+
input,
|
|
1094
|
+
status,
|
|
1095
|
+
isIdle: status === "idle",
|
|
1096
|
+
isPending: status === "pending",
|
|
1097
|
+
isSuccess: status === "success",
|
|
1098
|
+
output,
|
|
1099
|
+
responseMetadata
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/generate-helpers.js
|
|
1104
|
+
function generateHelpers() {
|
|
1105
|
+
return {
|
|
1106
|
+
/**
|
|
1107
|
+
* Typed version of `useCallTool` that provides autocomplete for tool names
|
|
1108
|
+
* and type inference for inputs and outputs.
|
|
1109
|
+
*
|
|
1110
|
+
* @param name - The name of the widget to call. Autocompletes based on your server's widget registry.
|
|
1111
|
+
* @returns A hook with typed `callTool` function and `data` property.
|
|
1112
|
+
*
|
|
1113
|
+
* @example
|
|
1114
|
+
* ```typescript
|
|
1115
|
+
* const { callTool, data, isPending } = useCallTool("search-voyage");
|
|
1116
|
+
* // TypeScript knows callTool expects { destination: string }
|
|
1117
|
+
* callTool({ destination: "Spain" });
|
|
1118
|
+
*
|
|
1119
|
+
* // data.structuredContent is typed based on your outputSchema
|
|
1120
|
+
* if (data) {
|
|
1121
|
+
* console.log(data.structuredContent.results);
|
|
1122
|
+
* }
|
|
1123
|
+
* ```
|
|
1124
|
+
*/
|
|
1125
|
+
useCallTool: (name) => {
|
|
1126
|
+
return useCallTool(name);
|
|
1127
|
+
},
|
|
1128
|
+
/**
|
|
1129
|
+
* Typed version of `useToolInfo` that provides autocomplete for widget names
|
|
1130
|
+
* and type inference for inputs, outputs, and responseMetadata.
|
|
1131
|
+
*
|
|
1132
|
+
* @typeParam K - The name of the widget. Autocompletes based on your server's widget registry.
|
|
1133
|
+
* @returns A discriminated union with `status: "pending" | "success"` that narrows correctly.
|
|
1134
|
+
*
|
|
1135
|
+
* @example
|
|
1136
|
+
* ```typescript
|
|
1137
|
+
* const toolInfo = useToolInfo<"search-voyage">();
|
|
1138
|
+
* // toolInfo.input is typed as { destination: string; ... }
|
|
1139
|
+
* // toolInfo.output is typed as { results: Array<...>; ... }
|
|
1140
|
+
* // toolInfo.responseMetadata is typed based on _meta in callback return
|
|
1141
|
+
* // toolInfo.status narrows correctly: "pending" | "success"
|
|
1142
|
+
*
|
|
1143
|
+
* if (toolInfo.isPending) {
|
|
1144
|
+
* // TypeScript knows output and responseMetadata are undefined here
|
|
1145
|
+
* console.log(toolInfo.input.destination);
|
|
1146
|
+
* }
|
|
1147
|
+
*
|
|
1148
|
+
* if (toolInfo.isSuccess) {
|
|
1149
|
+
* // TypeScript knows output and responseMetadata are defined here
|
|
1150
|
+
* console.log(toolInfo.output.results);
|
|
1151
|
+
* console.log(toolInfo.responseMetadata);
|
|
1152
|
+
* }
|
|
1153
|
+
* ```
|
|
1154
|
+
*/
|
|
1155
|
+
useToolInfo: () => {
|
|
1156
|
+
return useToolInfo();
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
|
|
1161
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-display-mode.js
|
|
1162
|
+
var import_react4 = __toESM(require_react(), 1);
|
|
1163
|
+
function useDisplayMode() {
|
|
1164
|
+
const displayMode = useHostContext("displayMode");
|
|
1165
|
+
const adaptor = getAdaptor();
|
|
1166
|
+
const setDisplayMode = (0, import_react4.useCallback)((mode) => adaptor.requestDisplayMode(mode), [adaptor]);
|
|
1167
|
+
return [displayMode, setDisplayMode];
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-files.js
|
|
1171
|
+
function useFiles() {
|
|
1172
|
+
const adaptor = getAdaptor();
|
|
1173
|
+
return {
|
|
1174
|
+
upload: adaptor.uploadFile,
|
|
1175
|
+
getDownloadUrl: adaptor.getFileDownloadUrl
|
|
1176
|
+
};
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-layout.js
|
|
1180
|
+
function useLayout() {
|
|
1181
|
+
const theme = useHostContext("theme");
|
|
1182
|
+
const maxHeight = useHostContext("maxHeight");
|
|
1183
|
+
const safeArea = useHostContext("safeArea");
|
|
1184
|
+
return { theme, maxHeight, safeArea };
|
|
1185
|
+
}
|
|
1186
|
+
|
|
1187
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-open-external.js
|
|
1188
|
+
var import_react5 = __toESM(require_react(), 1);
|
|
1189
|
+
function useOpenExternal() {
|
|
1190
|
+
const adaptor = getAdaptor();
|
|
1191
|
+
const openExternal = (0, import_react5.useCallback)((href) => adaptor.openExternal(href), [adaptor]);
|
|
1192
|
+
return openExternal;
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-request-modal.js
|
|
1196
|
+
var import_react6 = __toESM(require_react(), 1);
|
|
1197
|
+
function useRequestModal() {
|
|
1198
|
+
const adaptor = getAdaptor();
|
|
1199
|
+
const view = useHostContext("view");
|
|
1200
|
+
const open = (0, import_react6.useCallback)((opts) => adaptor.openModal(opts), [adaptor]);
|
|
1201
|
+
return {
|
|
1202
|
+
isOpen: view.mode === "modal",
|
|
1203
|
+
params: view.params,
|
|
1204
|
+
open
|
|
1205
|
+
};
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1208
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-send-follow-up-message.js
|
|
1209
|
+
var import_react7 = __toESM(require_react(), 1);
|
|
1210
|
+
function useSendFollowUpMessage() {
|
|
1211
|
+
const adaptor = getAdaptor();
|
|
1212
|
+
const sendFollowUpMessage = (0, import_react7.useCallback)((prompt) => adaptor.sendFollowUpMessage(prompt), [adaptor]);
|
|
1213
|
+
return sendFollowUpMessage;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-set-open-in-app-url.js
|
|
1217
|
+
var import_react8 = __toESM(require_react(), 1);
|
|
1218
|
+
function useSetOpenInAppUrl() {
|
|
1219
|
+
const adaptor = getAdaptor();
|
|
1220
|
+
const setOpenInAppUrl = (0, import_react8.useCallback)((href) => adaptor.setOpenInAppUrl(href), [adaptor]);
|
|
1221
|
+
return setOpenInAppUrl;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-user.js
|
|
1225
|
+
function useUser() {
|
|
1226
|
+
const locale = useHostContext("locale");
|
|
1227
|
+
const userAgent = useHostContext("userAgent");
|
|
1228
|
+
return { locale, userAgent };
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/hooks/use-widget-state.js
|
|
1232
|
+
var import_react9 = __toESM(require_react(), 1);
|
|
1233
|
+
function useWidgetState(defaultState) {
|
|
1234
|
+
const adaptor = getAdaptor();
|
|
1235
|
+
const widgetStateFromBridge = useHostContext("widgetState");
|
|
1236
|
+
const [widgetState, _setWidgetState] = (0, import_react9.useState)(() => {
|
|
1237
|
+
if (widgetStateFromBridge !== null) {
|
|
1238
|
+
return filterWidgetContext(widgetStateFromBridge);
|
|
1239
|
+
}
|
|
1240
|
+
return typeof defaultState === "function" ? defaultState() : defaultState ?? null;
|
|
1241
|
+
});
|
|
1242
|
+
(0, import_react9.useEffect)(() => {
|
|
1243
|
+
if (widgetStateFromBridge !== null) {
|
|
1244
|
+
_setWidgetState(filterWidgetContext(widgetStateFromBridge));
|
|
1245
|
+
}
|
|
1246
|
+
}, [widgetStateFromBridge]);
|
|
1247
|
+
const setWidgetState = (0, import_react9.useCallback)((state) => {
|
|
1248
|
+
_setWidgetState((prevState) => {
|
|
1249
|
+
const newState = typeof state === "function" ? state(prevState) : state;
|
|
1250
|
+
const stateToSet = injectWidgetContext(newState);
|
|
1251
|
+
if (stateToSet !== null) {
|
|
1252
|
+
adaptor.setWidgetState(stateToSet);
|
|
1253
|
+
}
|
|
1254
|
+
return filterWidgetContext(stateToSet);
|
|
1255
|
+
});
|
|
1256
|
+
}, [adaptor]);
|
|
1257
|
+
return [widgetState, setWidgetState];
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/mount-widget.js
|
|
1261
|
+
var import_react10 = __toESM(require_react(), 1);
|
|
1262
|
+
var import_client = __toESM(require_client(), 1);
|
|
1263
|
+
|
|
1264
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/proxy.js
|
|
1265
|
+
var colors = {
|
|
1266
|
+
brand: "#6366f1",
|
|
1267
|
+
info: "#22223b",
|
|
1268
|
+
success: "#22c55e",
|
|
1269
|
+
error: "#ef4444"
|
|
1270
|
+
};
|
|
1271
|
+
function installOpenAILoggingProxy() {
|
|
1272
|
+
if (typeof window === "undefined" || !window.openai) {
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
const descriptor = Object.getOwnPropertyDescriptor(window, "openai");
|
|
1276
|
+
if (descriptor?.configurable === false || descriptor?.writable === false) {
|
|
1277
|
+
console.warn("[openai-proxy] window.openai is not configurable or writable, skipping proxy installation");
|
|
1278
|
+
return;
|
|
1279
|
+
}
|
|
1280
|
+
const originalOpenAI = window.openai;
|
|
1281
|
+
const handler = {
|
|
1282
|
+
get(target, prop, receiver) {
|
|
1283
|
+
const value = Reflect.get(target, prop, receiver);
|
|
1284
|
+
if (typeof value !== "function") {
|
|
1285
|
+
return value;
|
|
1286
|
+
}
|
|
1287
|
+
return (...args) => {
|
|
1288
|
+
const methodName = String(prop);
|
|
1289
|
+
console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
|
|
1290
|
+
console.log("%c← args:", `color: ${colors.info}`, args);
|
|
1291
|
+
const result = value.apply(target, args);
|
|
1292
|
+
if (result && typeof result.then === "function") {
|
|
1293
|
+
return result.then((resolved) => {
|
|
1294
|
+
console.log("%c→ resolved:", `color: ${colors.success}`, resolved);
|
|
1295
|
+
console.groupEnd();
|
|
1296
|
+
return resolved;
|
|
1297
|
+
}, (error) => {
|
|
1298
|
+
console.error("%c→ rejected:", `color: ${colors.error}`, error);
|
|
1299
|
+
console.groupEnd();
|
|
1300
|
+
throw error;
|
|
1301
|
+
});
|
|
1302
|
+
}
|
|
1303
|
+
console.log("%c→ returned:", `color: ${colors.success}`, result);
|
|
1304
|
+
console.groupEnd();
|
|
1305
|
+
return result;
|
|
1306
|
+
};
|
|
1307
|
+
},
|
|
1308
|
+
set(target, prop, value, receiver) {
|
|
1309
|
+
console.log(`%c[openai] %cupdate %c${String(prop)}`, `color: ${colors.brand}`, `color: ${colors.info}`, `color: ${colors.success}; font-weight: bold`, "←", value);
|
|
1310
|
+
return Reflect.set(target, prop, value, receiver);
|
|
1311
|
+
}
|
|
1312
|
+
};
|
|
1313
|
+
window.openai = new Proxy(originalOpenAI, handler);
|
|
1314
|
+
console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", `color: ${colors.brand}`, `color: ${colors.info}`);
|
|
1315
|
+
}
|
|
1316
|
+
|
|
1317
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/mount-widget.js
|
|
1318
|
+
var rootInstance = null;
|
|
1319
|
+
var mountWidget = (component) => {
|
|
1320
|
+
const rootElement = document.getElementById("root");
|
|
1321
|
+
if (!rootElement) {
|
|
1322
|
+
throw new Error("Root element not found");
|
|
1323
|
+
}
|
|
1324
|
+
if (!rootInstance) {
|
|
1325
|
+
rootInstance = (0, import_client.createRoot)(rootElement);
|
|
1326
|
+
}
|
|
1327
|
+
if (import.meta.env.DEV) {
|
|
1328
|
+
installOpenAILoggingProxy();
|
|
1329
|
+
}
|
|
1330
|
+
const hostType = window.skybridge?.hostType;
|
|
1331
|
+
(async () => {
|
|
1332
|
+
let app = component;
|
|
1333
|
+
if (hostType === "mcp-app") {
|
|
1334
|
+
const { ModalProvider } = await import("./modal-provider-67CS7MKL.js");
|
|
1335
|
+
app = (0, import_react10.createElement)(ModalProvider, null, component);
|
|
1336
|
+
}
|
|
1337
|
+
rootInstance.render((0, import_react10.createElement)(import_react10.StrictMode, null, app));
|
|
1338
|
+
})();
|
|
1339
|
+
};
|
|
1340
|
+
|
|
1341
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/plugin/transform-data-llm.js
|
|
1342
|
+
var LLM_IMPORT_SOURCE = "skybridge/web";
|
|
1343
|
+
function createBabelPlugin(t) {
|
|
1344
|
+
return {
|
|
1345
|
+
name: "data-llm-babel",
|
|
1346
|
+
visitor: {
|
|
1347
|
+
Program: {
|
|
1348
|
+
enter(path, state) {
|
|
1349
|
+
state.hasDataLLMImport = false;
|
|
1350
|
+
state.needsDataLLMImport = false;
|
|
1351
|
+
for (const node of path.node.body) {
|
|
1352
|
+
if (!t.isImportDeclaration(node)) {
|
|
1353
|
+
continue;
|
|
1354
|
+
}
|
|
1355
|
+
if (node.source.value !== LLM_IMPORT_SOURCE) {
|
|
1356
|
+
continue;
|
|
1357
|
+
}
|
|
1358
|
+
const hasSpecifier = node.specifiers.some((s) => t.isImportSpecifier(s) && t.isIdentifier(s.imported, { name: "DataLLM" }));
|
|
1359
|
+
if (hasSpecifier) {
|
|
1360
|
+
state.hasDataLLMImport = true;
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
},
|
|
1365
|
+
exit(path, state) {
|
|
1366
|
+
if (state.needsDataLLMImport && !state.hasDataLLMImport) {
|
|
1367
|
+
const importDecl = t.importDeclaration([
|
|
1368
|
+
t.importSpecifier(t.identifier("DataLLM"), t.identifier("DataLLM"))
|
|
1369
|
+
], t.stringLiteral(LLM_IMPORT_SOURCE));
|
|
1370
|
+
path.node.body.unshift(importDecl);
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
},
|
|
1374
|
+
JSXElement(path, state) {
|
|
1375
|
+
const opening = path.node.openingElement;
|
|
1376
|
+
const attributes = opening.attributes;
|
|
1377
|
+
const llmAttributeIndex = attributes.findIndex((attribute) => t.isJSXAttribute(attribute) && t.isJSXIdentifier(attribute.name, { name: "data-llm" }));
|
|
1378
|
+
if (llmAttributeIndex === -1) {
|
|
1379
|
+
return;
|
|
1380
|
+
}
|
|
1381
|
+
const llmAttribute = attributes[llmAttributeIndex];
|
|
1382
|
+
let contentExpression;
|
|
1383
|
+
if (t.isStringLiteral(llmAttribute.value)) {
|
|
1384
|
+
contentExpression = llmAttribute.value;
|
|
1385
|
+
} else if (t.isJSXExpressionContainer(llmAttribute.value)) {
|
|
1386
|
+
contentExpression = llmAttribute.value.expression;
|
|
1387
|
+
} else {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
const contentAttr = t.jsxAttribute(t.jsxIdentifier("content"), t.isStringLiteral(contentExpression) ? contentExpression : t.jsxExpressionContainer(contentExpression));
|
|
1391
|
+
const filteredAttributes = attributes.filter((_, index) => index !== llmAttributeIndex);
|
|
1392
|
+
const newOpening = t.jsxOpeningElement(opening.name, filteredAttributes, opening.selfClosing);
|
|
1393
|
+
const elementWithoutLlm = t.jsxElement(newOpening, path.node.closingElement, path.node.children, path.node.selfClosing);
|
|
1394
|
+
const llmOpening = t.jsxOpeningElement(t.jsxIdentifier("DataLLM"), [
|
|
1395
|
+
contentAttr
|
|
1396
|
+
]);
|
|
1397
|
+
const llmClosing = t.jsxClosingElement(t.jsxIdentifier("DataLLM"));
|
|
1398
|
+
const wrapped = t.jsxElement(llmOpening, llmClosing, [elementWithoutLlm], false);
|
|
1399
|
+
state.needsDataLLMImport = true;
|
|
1400
|
+
path.replaceWith(wrapped);
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
};
|
|
1404
|
+
}
|
|
1405
|
+
var transform = async (code, id) => {
|
|
1406
|
+
if (!/\.(jsx|tsx)$/.test(id)) {
|
|
1407
|
+
return null;
|
|
1408
|
+
}
|
|
1409
|
+
if (id.includes("node_modules")) {
|
|
1410
|
+
return null;
|
|
1411
|
+
}
|
|
1412
|
+
const { types: t, transformSync } = await import("./lib-355XMAFY.js");
|
|
1413
|
+
const babelOptions = {
|
|
1414
|
+
plugins: [createBabelPlugin(t)],
|
|
1415
|
+
parserOpts: {
|
|
1416
|
+
plugins: ["jsx", "typescript"]
|
|
1417
|
+
},
|
|
1418
|
+
filename: id,
|
|
1419
|
+
sourceFileName: id
|
|
1420
|
+
};
|
|
1421
|
+
const result = transformSync(code, babelOptions);
|
|
1422
|
+
if (!result || !result.code) {
|
|
1423
|
+
return null;
|
|
1424
|
+
}
|
|
1425
|
+
return {
|
|
1426
|
+
code: result.code,
|
|
1427
|
+
map: result.map || null
|
|
1428
|
+
};
|
|
1429
|
+
};
|
|
1430
|
+
|
|
1431
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/plugin/plugin.js
|
|
1432
|
+
function skybridge() {
|
|
1433
|
+
return {
|
|
1434
|
+
name: "skybridge",
|
|
1435
|
+
async config(config) {
|
|
1436
|
+
const { globSync } = await import("./node_fs-3RO563AW.js");
|
|
1437
|
+
const { basename, dirname, parse: parse2, resolve } = await import("./node_path-5FHEC5YD.js");
|
|
1438
|
+
const projectRoot = config.root || process.cwd();
|
|
1439
|
+
const flatWidgetPattern = resolve(projectRoot, "src/widgets/*.{js,ts,jsx,tsx,html}");
|
|
1440
|
+
const dirWidgetPattern = resolve(projectRoot, "src/widgets/*/index.tsx");
|
|
1441
|
+
const flatWidgets = globSync(flatWidgetPattern).map((file) => {
|
|
1442
|
+
const name = parse2(file).name;
|
|
1443
|
+
return [name, file];
|
|
1444
|
+
});
|
|
1445
|
+
const dirWidgets = globSync(dirWidgetPattern).map((file) => {
|
|
1446
|
+
const name = basename(dirname(file));
|
|
1447
|
+
return [name, file];
|
|
1448
|
+
});
|
|
1449
|
+
const input = Object.fromEntries([...flatWidgets, ...dirWidgets]);
|
|
1450
|
+
return {
|
|
1451
|
+
base: "/assets",
|
|
1452
|
+
build: {
|
|
1453
|
+
manifest: true,
|
|
1454
|
+
minify: true,
|
|
1455
|
+
cssCodeSplit: false,
|
|
1456
|
+
rollupOptions: {
|
|
1457
|
+
input
|
|
1458
|
+
}
|
|
1459
|
+
},
|
|
1460
|
+
experimental: {
|
|
1461
|
+
renderBuiltUrl: (filename) => {
|
|
1462
|
+
return {
|
|
1463
|
+
runtime: `window.skybridge.serverUrl + "/assets/${filename}"`
|
|
1464
|
+
};
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
};
|
|
1468
|
+
},
|
|
1469
|
+
enforce: "pre",
|
|
1470
|
+
async transform(code, id) {
|
|
1471
|
+
return await transform(code, id);
|
|
1472
|
+
}
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
// ../../../node_modules/.pnpm/skybridge@0.32.0_@modelcontextprotocol+sdk@1.27.1_zod@4.3.6__@skybridge+devtools@0.32.0_8c938528707c936d391357462b94034d/node_modules/skybridge/dist/web/types.js
|
|
1477
|
+
var import_react11 = __toESM(require_react(), 1);
|
|
1478
|
+
export {
|
|
1479
|
+
AppsSdkAdaptor,
|
|
1480
|
+
AppsSdkBridge,
|
|
1481
|
+
DataLLM,
|
|
1482
|
+
McpAppAdaptor,
|
|
1483
|
+
McpAppBridge,
|
|
1484
|
+
SET_GLOBALS_EVENT_TYPE,
|
|
1485
|
+
SetGlobalsEvent,
|
|
1486
|
+
TOOL_RESPONSE_EVENT_TYPE,
|
|
1487
|
+
WIDGET_CONTEXT_KEY,
|
|
1488
|
+
createStore2 as createStore,
|
|
1489
|
+
generateHelpers,
|
|
1490
|
+
getAdaptor,
|
|
1491
|
+
mountWidget,
|
|
1492
|
+
skybridge,
|
|
1493
|
+
useAppsSdkContext,
|
|
1494
|
+
useCallTool,
|
|
1495
|
+
useDisplayMode,
|
|
1496
|
+
useFiles,
|
|
1497
|
+
useHostContext,
|
|
1498
|
+
useLayout,
|
|
1499
|
+
useMcpAppContext,
|
|
1500
|
+
useOpenExternal,
|
|
1501
|
+
useRequestModal,
|
|
1502
|
+
useSendFollowUpMessage,
|
|
1503
|
+
useSetOpenInAppUrl,
|
|
1504
|
+
useToolInfo,
|
|
1505
|
+
useUser,
|
|
1506
|
+
useWidgetState
|
|
1507
|
+
};
|
|
1508
|
+
//# sourceMappingURL=skybridge_web.js.map
|