@cfp-studio/iframe 18.0.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/index.d.mts +268 -0
- package/dist/index.d.ts +268 -0
- package/dist/index.mjs +991 -0
- package/package.json +22 -0
- package/preview/__previewjs_internal__/copy-cut-paste.ts +75 -0
- package/preview/__previewjs_internal__/error-message.ts +36 -0
- package/preview/__previewjs_internal__/index.ts +95 -0
- package/preview/__previewjs_internal__/links.ts +30 -0
- package/preview/__previewjs_internal__/logs.ts +131 -0
- package/preview/__previewjs_internal__/object-inspect.js +668 -0
- package/preview/__previewjs_internal__/renderer/index.tsx +12 -0
- package/preview/__previewjs_internal__/run-renderer.ts +112 -0
- package/preview/__previewjs_internal__/state.ts +11 -0
- package/preview/__previewjs_internal__/vite-hmr-listener.ts +74 -0
- package/preview/__previewjs_internal__/vscode-control.ts +58 -0
- package/preview/index.html +71 -0
|
@@ -0,0 +1,668 @@
|
|
|
1
|
+
// Source: https://github.com/inspect-js/object-inspect
|
|
2
|
+
// MIT License
|
|
3
|
+
// Copyright (c) 2013 James Halliday
|
|
4
|
+
|
|
5
|
+
var hasMap = typeof Map === "function" && Map.prototype;
|
|
6
|
+
var mapSizeDescriptor =
|
|
7
|
+
Object.getOwnPropertyDescriptor && hasMap
|
|
8
|
+
? Object.getOwnPropertyDescriptor(Map.prototype, "size")
|
|
9
|
+
: null;
|
|
10
|
+
var mapSize =
|
|
11
|
+
hasMap && mapSizeDescriptor && typeof mapSizeDescriptor.get === "function"
|
|
12
|
+
? mapSizeDescriptor.get
|
|
13
|
+
: null;
|
|
14
|
+
var mapForEach = hasMap && Map.prototype.forEach;
|
|
15
|
+
var hasSet = typeof Set === "function" && Set.prototype;
|
|
16
|
+
var setSizeDescriptor =
|
|
17
|
+
Object.getOwnPropertyDescriptor && hasSet
|
|
18
|
+
? Object.getOwnPropertyDescriptor(Set.prototype, "size")
|
|
19
|
+
: null;
|
|
20
|
+
var setSize =
|
|
21
|
+
hasSet && setSizeDescriptor && typeof setSizeDescriptor.get === "function"
|
|
22
|
+
? setSizeDescriptor.get
|
|
23
|
+
: null;
|
|
24
|
+
var setForEach = hasSet && Set.prototype.forEach;
|
|
25
|
+
var hasWeakMap = typeof WeakMap === "function" && WeakMap.prototype;
|
|
26
|
+
var weakMapHas = hasWeakMap ? WeakMap.prototype.has : null;
|
|
27
|
+
var hasWeakSet = typeof WeakSet === "function" && WeakSet.prototype;
|
|
28
|
+
var weakSetHas = hasWeakSet ? WeakSet.prototype.has : null;
|
|
29
|
+
var hasWeakRef = typeof WeakRef === "function" && WeakRef.prototype;
|
|
30
|
+
var weakRefDeref = hasWeakRef ? WeakRef.prototype.deref : null;
|
|
31
|
+
var booleanValueOf = Boolean.prototype.valueOf;
|
|
32
|
+
var objectToString = Object.prototype.toString;
|
|
33
|
+
var functionToString = Function.prototype.toString;
|
|
34
|
+
var $match = String.prototype.match;
|
|
35
|
+
var $slice = String.prototype.slice;
|
|
36
|
+
var $replace = String.prototype.replace;
|
|
37
|
+
var $toUpperCase = String.prototype.toUpperCase;
|
|
38
|
+
var $toLowerCase = String.prototype.toLowerCase;
|
|
39
|
+
var $test = RegExp.prototype.test;
|
|
40
|
+
var $concat = Array.prototype.concat;
|
|
41
|
+
var $join = Array.prototype.join;
|
|
42
|
+
var $arrSlice = Array.prototype.slice;
|
|
43
|
+
var $floor = Math.floor;
|
|
44
|
+
var bigIntValueOf =
|
|
45
|
+
typeof BigInt === "function" ? BigInt.prototype.valueOf : null;
|
|
46
|
+
var gOPS = Object.getOwnPropertySymbols;
|
|
47
|
+
var symToString =
|
|
48
|
+
typeof Symbol === "function" && typeof Symbol.iterator === "symbol"
|
|
49
|
+
? Symbol.prototype.toString
|
|
50
|
+
: null;
|
|
51
|
+
var hasShammedSymbols =
|
|
52
|
+
typeof Symbol === "function" && typeof Symbol.iterator === "object";
|
|
53
|
+
// ie, `has-tostringtag/shams
|
|
54
|
+
var toStringTag =
|
|
55
|
+
typeof Symbol === "function" &&
|
|
56
|
+
Symbol.toStringTag &&
|
|
57
|
+
(typeof Symbol.toStringTag === hasShammedSymbols ? "object" : "symbol")
|
|
58
|
+
? Symbol.toStringTag
|
|
59
|
+
: null;
|
|
60
|
+
var isEnumerable = Object.prototype.propertyIsEnumerable;
|
|
61
|
+
|
|
62
|
+
var gPO =
|
|
63
|
+
(typeof Reflect === "function"
|
|
64
|
+
? Reflect.getPrototypeOf
|
|
65
|
+
: Object.getPrototypeOf) ||
|
|
66
|
+
([].__proto__ === Array.prototype // eslint-disable-line no-proto
|
|
67
|
+
? function (O) {
|
|
68
|
+
return O.__proto__; // eslint-disable-line no-proto
|
|
69
|
+
}
|
|
70
|
+
: null);
|
|
71
|
+
|
|
72
|
+
function addNumericSeparator(num, str) {
|
|
73
|
+
if (
|
|
74
|
+
num === Infinity ||
|
|
75
|
+
num === -Infinity ||
|
|
76
|
+
num !== num ||
|
|
77
|
+
(num && num > -1000 && num < 1000) ||
|
|
78
|
+
$test.call(/e/, str)
|
|
79
|
+
) {
|
|
80
|
+
return str;
|
|
81
|
+
}
|
|
82
|
+
var sepRegex = /[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;
|
|
83
|
+
if (typeof num === "number") {
|
|
84
|
+
var int = num < 0 ? -$floor(-num) : $floor(num); // trunc(num)
|
|
85
|
+
if (int !== num) {
|
|
86
|
+
var intStr = String(int);
|
|
87
|
+
var dec = $slice.call(str, intStr.length + 1);
|
|
88
|
+
return (
|
|
89
|
+
$replace.call(intStr, sepRegex, "$&_") +
|
|
90
|
+
"." +
|
|
91
|
+
$replace.call($replace.call(dec, /([0-9]{3})/g, "$&_"), /_$/, "")
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return $replace.call(str, sepRegex, "$&_");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default function inspect_(obj, options, depth, seen) {
|
|
99
|
+
var opts = options || {};
|
|
100
|
+
|
|
101
|
+
if (
|
|
102
|
+
has(opts, "quoteStyle") &&
|
|
103
|
+
opts.quoteStyle !== "single" &&
|
|
104
|
+
opts.quoteStyle !== "double"
|
|
105
|
+
) {
|
|
106
|
+
throw new TypeError('option "quoteStyle" must be "single" or "double"');
|
|
107
|
+
}
|
|
108
|
+
if (
|
|
109
|
+
has(opts, "maxStringLength") &&
|
|
110
|
+
(typeof opts.maxStringLength === "number"
|
|
111
|
+
? opts.maxStringLength < 0 && opts.maxStringLength !== Infinity
|
|
112
|
+
: opts.maxStringLength !== null)
|
|
113
|
+
) {
|
|
114
|
+
throw new TypeError(
|
|
115
|
+
'option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`'
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
var customInspect = has(opts, "customInspect") ? opts.customInspect : true;
|
|
119
|
+
if (typeof customInspect !== "boolean" && customInspect !== "symbol") {
|
|
120
|
+
throw new TypeError(
|
|
121
|
+
"option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`"
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
if (
|
|
126
|
+
has(opts, "indent") &&
|
|
127
|
+
opts.indent !== null &&
|
|
128
|
+
opts.indent !== "\t" &&
|
|
129
|
+
!(parseInt(opts.indent, 10) === opts.indent && opts.indent > 0)
|
|
130
|
+
) {
|
|
131
|
+
throw new TypeError(
|
|
132
|
+
'option "indent" must be "\\t", an integer > 0, or `null`'
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
if (
|
|
136
|
+
has(opts, "numericSeparator") &&
|
|
137
|
+
typeof opts.numericSeparator !== "boolean"
|
|
138
|
+
) {
|
|
139
|
+
throw new TypeError(
|
|
140
|
+
'option "numericSeparator", if provided, must be `true` or `false`'
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
var numericSeparator = opts.numericSeparator;
|
|
144
|
+
|
|
145
|
+
if (typeof obj === "undefined") {
|
|
146
|
+
return "undefined";
|
|
147
|
+
}
|
|
148
|
+
if (obj === null) {
|
|
149
|
+
return "null";
|
|
150
|
+
}
|
|
151
|
+
if (typeof obj === "boolean") {
|
|
152
|
+
return obj ? "true" : "false";
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (typeof obj === "string") {
|
|
156
|
+
return inspectString(obj, opts);
|
|
157
|
+
}
|
|
158
|
+
if (typeof obj === "number") {
|
|
159
|
+
if (obj === 0) {
|
|
160
|
+
return Infinity / obj > 0 ? "0" : "-0";
|
|
161
|
+
}
|
|
162
|
+
var str = String(obj);
|
|
163
|
+
return numericSeparator ? addNumericSeparator(obj, str) : str;
|
|
164
|
+
}
|
|
165
|
+
if (typeof obj === "bigint") {
|
|
166
|
+
var bigIntStr = String(obj) + "n";
|
|
167
|
+
return numericSeparator ? addNumericSeparator(obj, bigIntStr) : bigIntStr;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
var maxDepth = typeof opts.depth === "undefined" ? 5 : opts.depth;
|
|
171
|
+
if (typeof depth === "undefined") {
|
|
172
|
+
depth = 0;
|
|
173
|
+
}
|
|
174
|
+
if (depth >= maxDepth && maxDepth > 0 && typeof obj === "object") {
|
|
175
|
+
return isArray(obj) ? "[Array]" : "[Object]";
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
var indent = getIndent(opts, depth);
|
|
179
|
+
|
|
180
|
+
if (typeof seen === "undefined") {
|
|
181
|
+
seen = [];
|
|
182
|
+
} else if (indexOf(seen, obj) >= 0) {
|
|
183
|
+
return "[Circular]";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
function inspect(value, from, noIndent) {
|
|
187
|
+
if (from) {
|
|
188
|
+
seen = $arrSlice.call(seen);
|
|
189
|
+
seen.push(from);
|
|
190
|
+
}
|
|
191
|
+
if (noIndent) {
|
|
192
|
+
var newOpts = {
|
|
193
|
+
depth: opts.depth,
|
|
194
|
+
};
|
|
195
|
+
if (has(opts, "quoteStyle")) {
|
|
196
|
+
newOpts.quoteStyle = opts.quoteStyle;
|
|
197
|
+
}
|
|
198
|
+
return inspect_(value, newOpts, depth + 1, seen);
|
|
199
|
+
}
|
|
200
|
+
return inspect_(value, opts, depth + 1, seen);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (typeof obj === "function") {
|
|
204
|
+
var name = nameOf(obj);
|
|
205
|
+
var keys = arrObjKeys(obj, inspect);
|
|
206
|
+
return (
|
|
207
|
+
"[Function" +
|
|
208
|
+
(name ? ": " + name : " (anonymous)") +
|
|
209
|
+
"]" +
|
|
210
|
+
(keys.length > 0 ? " { " + $join.call(keys, ", ") + " }" : "")
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (isSymbol(obj)) {
|
|
214
|
+
var symString = hasShammedSymbols
|
|
215
|
+
? $replace.call(String(obj), /^(Symbol\(.*\))_[^)]*$/, "$1")
|
|
216
|
+
: symToString.call(obj);
|
|
217
|
+
return typeof obj === "object" && !hasShammedSymbols
|
|
218
|
+
? markBoxed(symString)
|
|
219
|
+
: symString;
|
|
220
|
+
}
|
|
221
|
+
if (isElement(obj)) {
|
|
222
|
+
var s = "<" + $toLowerCase.call(String(obj.nodeName));
|
|
223
|
+
var attrs = obj.attributes || [];
|
|
224
|
+
for (var i = 0; i < attrs.length; i++) {
|
|
225
|
+
s +=
|
|
226
|
+
" " +
|
|
227
|
+
attrs[i].name +
|
|
228
|
+
"=" +
|
|
229
|
+
wrapQuotes(quote(attrs[i].value), "double", opts);
|
|
230
|
+
}
|
|
231
|
+
s += ">";
|
|
232
|
+
if (obj.childNodes && obj.childNodes.length) {
|
|
233
|
+
s += "...";
|
|
234
|
+
}
|
|
235
|
+
s += "</" + $toLowerCase.call(String(obj.nodeName)) + ">";
|
|
236
|
+
return s;
|
|
237
|
+
}
|
|
238
|
+
if (isArray(obj)) {
|
|
239
|
+
if (obj.length === 0) {
|
|
240
|
+
return "[]";
|
|
241
|
+
}
|
|
242
|
+
var xs = arrObjKeys(obj, inspect);
|
|
243
|
+
if (indent && !singleLineValues(xs)) {
|
|
244
|
+
return "[" + indentedJoin(xs, indent) + "]";
|
|
245
|
+
}
|
|
246
|
+
return "[ " + $join.call(xs, ", ") + " ]";
|
|
247
|
+
}
|
|
248
|
+
if (isError(obj)) {
|
|
249
|
+
var parts = arrObjKeys(obj, inspect);
|
|
250
|
+
if ("cause" in obj && !isEnumerable.call(obj, "cause")) {
|
|
251
|
+
return (
|
|
252
|
+
"{ [" +
|
|
253
|
+
String(obj) +
|
|
254
|
+
"] " +
|
|
255
|
+
$join.call(
|
|
256
|
+
$concat.call("[cause]: " + inspect(obj.cause), parts),
|
|
257
|
+
", "
|
|
258
|
+
) +
|
|
259
|
+
" }"
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
if (parts.length === 0) {
|
|
263
|
+
return "[" + String(obj) + "]";
|
|
264
|
+
}
|
|
265
|
+
return "{ [" + String(obj) + "] " + $join.call(parts, ", ") + " }";
|
|
266
|
+
}
|
|
267
|
+
if (typeof obj === "object" && customInspect) {
|
|
268
|
+
if (customInspect !== "symbol" && typeof obj.inspect === "function") {
|
|
269
|
+
return obj.inspect();
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (isMap(obj)) {
|
|
273
|
+
var mapParts = [];
|
|
274
|
+
mapForEach.call(obj, function (value, key) {
|
|
275
|
+
mapParts.push(inspect(key, obj, true) + " => " + inspect(value, obj));
|
|
276
|
+
});
|
|
277
|
+
return collectionOf("Map", mapSize.call(obj), mapParts, indent);
|
|
278
|
+
}
|
|
279
|
+
if (isSet(obj)) {
|
|
280
|
+
var setParts = [];
|
|
281
|
+
setForEach.call(obj, function (value) {
|
|
282
|
+
setParts.push(inspect(value, obj));
|
|
283
|
+
});
|
|
284
|
+
return collectionOf("Set", setSize.call(obj), setParts, indent);
|
|
285
|
+
}
|
|
286
|
+
if (isWeakMap(obj)) {
|
|
287
|
+
return weakCollectionOf("WeakMap");
|
|
288
|
+
}
|
|
289
|
+
if (isWeakSet(obj)) {
|
|
290
|
+
return weakCollectionOf("WeakSet");
|
|
291
|
+
}
|
|
292
|
+
if (isWeakRef(obj)) {
|
|
293
|
+
return weakCollectionOf("WeakRef");
|
|
294
|
+
}
|
|
295
|
+
if (isNumber(obj)) {
|
|
296
|
+
return markBoxed(inspect(Number(obj)));
|
|
297
|
+
}
|
|
298
|
+
if (isBigInt(obj)) {
|
|
299
|
+
return markBoxed(inspect(bigIntValueOf.call(obj)));
|
|
300
|
+
}
|
|
301
|
+
if (isBoolean(obj)) {
|
|
302
|
+
return markBoxed(booleanValueOf.call(obj));
|
|
303
|
+
}
|
|
304
|
+
if (isString(obj)) {
|
|
305
|
+
return markBoxed(inspect(String(obj)));
|
|
306
|
+
}
|
|
307
|
+
if (!isDate(obj) && !isRegExp(obj)) {
|
|
308
|
+
var ys = arrObjKeys(obj, inspect);
|
|
309
|
+
var isPlainObject = gPO
|
|
310
|
+
? gPO(obj) === Object.prototype
|
|
311
|
+
: obj instanceof Object || obj.constructor === Object;
|
|
312
|
+
var protoTag = obj instanceof Object ? "" : "null prototype";
|
|
313
|
+
var stringTag =
|
|
314
|
+
!isPlainObject && toStringTag && Object(obj) === obj && toStringTag in obj
|
|
315
|
+
? $slice.call(toStr(obj), 8, -1)
|
|
316
|
+
: protoTag
|
|
317
|
+
? "Object"
|
|
318
|
+
: "";
|
|
319
|
+
var constructorTag =
|
|
320
|
+
isPlainObject || typeof obj.constructor !== "function"
|
|
321
|
+
? ""
|
|
322
|
+
: obj.constructor.name
|
|
323
|
+
? obj.constructor.name + " "
|
|
324
|
+
: "";
|
|
325
|
+
var tag =
|
|
326
|
+
constructorTag +
|
|
327
|
+
(stringTag || protoTag
|
|
328
|
+
? "[" +
|
|
329
|
+
$join.call($concat.call([], stringTag || [], protoTag || []), ": ") +
|
|
330
|
+
"] "
|
|
331
|
+
: "");
|
|
332
|
+
if (ys.length === 0) {
|
|
333
|
+
return tag + "{}";
|
|
334
|
+
}
|
|
335
|
+
if (indent) {
|
|
336
|
+
return tag + "{" + indentedJoin(ys, indent) + "}";
|
|
337
|
+
}
|
|
338
|
+
return tag + "{ " + $join.call(ys, ", ") + " }";
|
|
339
|
+
}
|
|
340
|
+
return String(obj);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
function wrapQuotes(s, defaultStyle, opts) {
|
|
344
|
+
var quoteChar = (opts.quoteStyle || defaultStyle) === "double" ? '"' : "'";
|
|
345
|
+
return quoteChar + s + quoteChar;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function quote(s) {
|
|
349
|
+
return $replace.call(String(s), /"/g, """);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function isArray(obj) {
|
|
353
|
+
return (
|
|
354
|
+
toStr(obj) === "[object Array]" &&
|
|
355
|
+
(!toStringTag || !(typeof obj === "object" && toStringTag in obj))
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
function isDate(obj) {
|
|
359
|
+
return (
|
|
360
|
+
toStr(obj) === "[object Date]" &&
|
|
361
|
+
(!toStringTag || !(typeof obj === "object" && toStringTag in obj))
|
|
362
|
+
);
|
|
363
|
+
}
|
|
364
|
+
function isRegExp(obj) {
|
|
365
|
+
return (
|
|
366
|
+
toStr(obj) === "[object RegExp]" &&
|
|
367
|
+
(!toStringTag || !(typeof obj === "object" && toStringTag in obj))
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
function isError(obj) {
|
|
371
|
+
return (
|
|
372
|
+
toStr(obj) === "[object Error]" &&
|
|
373
|
+
(!toStringTag || !(typeof obj === "object" && toStringTag in obj))
|
|
374
|
+
);
|
|
375
|
+
}
|
|
376
|
+
function isString(obj) {
|
|
377
|
+
return (
|
|
378
|
+
toStr(obj) === "[object String]" &&
|
|
379
|
+
(!toStringTag || !(typeof obj === "object" && toStringTag in obj))
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
function isNumber(obj) {
|
|
383
|
+
return (
|
|
384
|
+
toStr(obj) === "[object Number]" &&
|
|
385
|
+
(!toStringTag || !(typeof obj === "object" && toStringTag in obj))
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
function isBoolean(obj) {
|
|
389
|
+
return (
|
|
390
|
+
toStr(obj) === "[object Boolean]" &&
|
|
391
|
+
(!toStringTag || !(typeof obj === "object" && toStringTag in obj))
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Symbol and BigInt do have Symbol.toStringTag by spec, so that can't be used to eliminate false positives
|
|
396
|
+
function isSymbol(obj) {
|
|
397
|
+
if (hasShammedSymbols) {
|
|
398
|
+
return obj && typeof obj === "object" && obj instanceof Symbol;
|
|
399
|
+
}
|
|
400
|
+
if (typeof obj === "symbol") {
|
|
401
|
+
return true;
|
|
402
|
+
}
|
|
403
|
+
if (!obj || typeof obj !== "object" || !symToString) {
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
try {
|
|
407
|
+
symToString.call(obj);
|
|
408
|
+
return true;
|
|
409
|
+
} catch (e) {}
|
|
410
|
+
return false;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
function isBigInt(obj) {
|
|
414
|
+
if (!obj || typeof obj !== "object" || !bigIntValueOf) {
|
|
415
|
+
return false;
|
|
416
|
+
}
|
|
417
|
+
try {
|
|
418
|
+
bigIntValueOf.call(obj);
|
|
419
|
+
return true;
|
|
420
|
+
} catch (e) {}
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
var hasOwn =
|
|
425
|
+
Object.prototype.hasOwnProperty ||
|
|
426
|
+
function (key) {
|
|
427
|
+
return key in this;
|
|
428
|
+
};
|
|
429
|
+
function has(obj, key) {
|
|
430
|
+
return hasOwn.call(obj, key);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
function toStr(obj) {
|
|
434
|
+
return objectToString.call(obj);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
function nameOf(f) {
|
|
438
|
+
if (f.name) {
|
|
439
|
+
return f.name;
|
|
440
|
+
}
|
|
441
|
+
var m = $match.call(functionToString.call(f), /^function\s*([\w$]+)/);
|
|
442
|
+
if (m) {
|
|
443
|
+
return m[1];
|
|
444
|
+
}
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
function indexOf(xs, x) {
|
|
449
|
+
if (xs.indexOf) {
|
|
450
|
+
return xs.indexOf(x);
|
|
451
|
+
}
|
|
452
|
+
for (var i = 0, l = xs.length; i < l; i++) {
|
|
453
|
+
if (xs[i] === x) {
|
|
454
|
+
return i;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return -1;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
function isMap(x) {
|
|
461
|
+
if (!mapSize || !x || typeof x !== "object") {
|
|
462
|
+
return false;
|
|
463
|
+
}
|
|
464
|
+
try {
|
|
465
|
+
mapSize.call(x);
|
|
466
|
+
try {
|
|
467
|
+
setSize.call(x);
|
|
468
|
+
} catch (s) {
|
|
469
|
+
return true;
|
|
470
|
+
}
|
|
471
|
+
return x instanceof Map; // core-js workaround, pre-v2.5.0
|
|
472
|
+
} catch (e) {}
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function isWeakMap(x) {
|
|
477
|
+
if (!weakMapHas || !x || typeof x !== "object") {
|
|
478
|
+
return false;
|
|
479
|
+
}
|
|
480
|
+
try {
|
|
481
|
+
weakMapHas.call(x, weakMapHas);
|
|
482
|
+
try {
|
|
483
|
+
weakSetHas.call(x, weakSetHas);
|
|
484
|
+
} catch (s) {
|
|
485
|
+
return true;
|
|
486
|
+
}
|
|
487
|
+
return x instanceof WeakMap; // core-js workaround, pre-v2.5.0
|
|
488
|
+
} catch (e) {}
|
|
489
|
+
return false;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
function isWeakRef(x) {
|
|
493
|
+
if (!weakRefDeref || !x || typeof x !== "object") {
|
|
494
|
+
return false;
|
|
495
|
+
}
|
|
496
|
+
try {
|
|
497
|
+
weakRefDeref.call(x);
|
|
498
|
+
return true;
|
|
499
|
+
} catch (e) {}
|
|
500
|
+
return false;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function isSet(x) {
|
|
504
|
+
if (!setSize || !x || typeof x !== "object") {
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
try {
|
|
508
|
+
setSize.call(x);
|
|
509
|
+
try {
|
|
510
|
+
mapSize.call(x);
|
|
511
|
+
} catch (m) {
|
|
512
|
+
return true;
|
|
513
|
+
}
|
|
514
|
+
return x instanceof Set; // core-js workaround, pre-v2.5.0
|
|
515
|
+
} catch (e) {}
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function isWeakSet(x) {
|
|
520
|
+
if (!weakSetHas || !x || typeof x !== "object") {
|
|
521
|
+
return false;
|
|
522
|
+
}
|
|
523
|
+
try {
|
|
524
|
+
weakSetHas.call(x, weakSetHas);
|
|
525
|
+
try {
|
|
526
|
+
weakMapHas.call(x, weakMapHas);
|
|
527
|
+
} catch (s) {
|
|
528
|
+
return true;
|
|
529
|
+
}
|
|
530
|
+
return x instanceof WeakSet; // core-js workaround, pre-v2.5.0
|
|
531
|
+
} catch (e) {}
|
|
532
|
+
return false;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
function isElement(x) {
|
|
536
|
+
if (!x || typeof x !== "object") {
|
|
537
|
+
return false;
|
|
538
|
+
}
|
|
539
|
+
if (typeof HTMLElement !== "undefined" && x instanceof HTMLElement) {
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
return typeof x.nodeName === "string" && typeof x.getAttribute === "function";
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
function inspectString(str, opts) {
|
|
546
|
+
if (str.length > opts.maxStringLength) {
|
|
547
|
+
var remaining = str.length - opts.maxStringLength;
|
|
548
|
+
var trailer =
|
|
549
|
+
"... " + remaining + " more character" + (remaining > 1 ? "s" : "");
|
|
550
|
+
return (
|
|
551
|
+
inspectString($slice.call(str, 0, opts.maxStringLength), opts) + trailer
|
|
552
|
+
);
|
|
553
|
+
}
|
|
554
|
+
// eslint-disable-next-line no-control-regex
|
|
555
|
+
var s = $replace.call(
|
|
556
|
+
$replace.call(str, /(['\\])/g, "\\$1"),
|
|
557
|
+
/[\x00-\x1f]/g,
|
|
558
|
+
lowbyte
|
|
559
|
+
);
|
|
560
|
+
return wrapQuotes(s, "single", opts);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
function lowbyte(c) {
|
|
564
|
+
var n = c.charCodeAt(0);
|
|
565
|
+
var x = {
|
|
566
|
+
8: "b",
|
|
567
|
+
9: "t",
|
|
568
|
+
10: "n",
|
|
569
|
+
12: "f",
|
|
570
|
+
13: "r",
|
|
571
|
+
}[n];
|
|
572
|
+
if (x) {
|
|
573
|
+
return "\\" + x;
|
|
574
|
+
}
|
|
575
|
+
return "\\x" + (n < 0x10 ? "0" : "") + $toUpperCase.call(n.toString(16));
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function markBoxed(str) {
|
|
579
|
+
return "Object(" + str + ")";
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
function weakCollectionOf(type) {
|
|
583
|
+
return type + " { ? }";
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function collectionOf(type, size, entries, indent) {
|
|
587
|
+
var joinedEntries = indent
|
|
588
|
+
? indentedJoin(entries, indent)
|
|
589
|
+
: $join.call(entries, ", ");
|
|
590
|
+
return type + " (" + size + ") {" + joinedEntries + "}";
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function singleLineValues(xs) {
|
|
594
|
+
for (var i = 0; i < xs.length; i++) {
|
|
595
|
+
if (indexOf(xs[i], "\n") >= 0) {
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return true;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
function getIndent(opts, depth) {
|
|
603
|
+
var baseIndent;
|
|
604
|
+
if (opts.indent === "\t") {
|
|
605
|
+
baseIndent = "\t";
|
|
606
|
+
} else if (typeof opts.indent === "number" && opts.indent > 0) {
|
|
607
|
+
baseIndent = $join.call(Array(opts.indent + 1), " ");
|
|
608
|
+
} else {
|
|
609
|
+
return null;
|
|
610
|
+
}
|
|
611
|
+
return {
|
|
612
|
+
base: baseIndent,
|
|
613
|
+
prev: $join.call(Array(depth + 1), baseIndent),
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
function indentedJoin(xs, indent) {
|
|
618
|
+
if (xs.length === 0) {
|
|
619
|
+
return "";
|
|
620
|
+
}
|
|
621
|
+
var lineJoiner = "\n" + indent.prev + indent.base;
|
|
622
|
+
return lineJoiner + $join.call(xs, "," + lineJoiner) + "\n" + indent.prev;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function arrObjKeys(obj, inspect) {
|
|
626
|
+
var isArr = isArray(obj);
|
|
627
|
+
var xs = [];
|
|
628
|
+
if (isArr) {
|
|
629
|
+
xs.length = obj.length;
|
|
630
|
+
for (var i = 0; i < obj.length; i++) {
|
|
631
|
+
xs[i] = has(obj, i) ? inspect(obj[i], obj) : "";
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
var syms = typeof gOPS === "function" ? gOPS(obj) : [];
|
|
635
|
+
var symMap;
|
|
636
|
+
if (hasShammedSymbols) {
|
|
637
|
+
symMap = {};
|
|
638
|
+
for (var k = 0; k < syms.length; k++) {
|
|
639
|
+
symMap["$" + syms[k]] = syms[k];
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
for (var key in obj) {
|
|
644
|
+
// eslint-disable-line no-restricted-syntax
|
|
645
|
+
if (!has(obj, key)) {
|
|
646
|
+
continue;
|
|
647
|
+
} // eslint-disable-line no-restricted-syntax, no-continue
|
|
648
|
+
if (isArr && String(Number(key)) === key && key < obj.length) {
|
|
649
|
+
continue;
|
|
650
|
+
} // eslint-disable-line no-restricted-syntax, no-continue
|
|
651
|
+
if (hasShammedSymbols && symMap["$" + key] instanceof Symbol) {
|
|
652
|
+
// this is to prevent shammed Symbols, which are stored as strings, from being included in the string key section
|
|
653
|
+
continue; // eslint-disable-line no-restricted-syntax, no-continue
|
|
654
|
+
} else if ($test.call(/[^\w$]/, key)) {
|
|
655
|
+
xs.push(inspect(key, obj) + ": " + inspect(obj[key], obj));
|
|
656
|
+
} else {
|
|
657
|
+
xs.push(key + ": " + inspect(obj[key], obj));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
if (typeof gOPS === "function") {
|
|
661
|
+
for (var j = 0; j < syms.length; j++) {
|
|
662
|
+
if (isEnumerable.call(obj, syms[j])) {
|
|
663
|
+
xs.push("[" + inspect(syms[j]) + "]: " + inspect(obj[syms[j]], obj));
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return xs;
|
|
668
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RendererLoader } from "../../../src";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 该函数目前是一个占位函数,在运行时会被特定框架的实现所替换。
|
|
5
|
+
*
|
|
6
|
+
* @returns 此函数理论上应返回渲染器,但当前实现会抛出错误。
|
|
7
|
+
* @throws {Error} 当该占位函数被调用时,会抛出“Dummy loader was invoked!”错误。
|
|
8
|
+
*/
|
|
9
|
+
export const loadRenderer: RendererLoader = () => {
|
|
10
|
+
// 这是一个占位函数,在运行时会被特定框架的实现所替换。
|
|
11
|
+
throw new Error("调用到占位 loader 函数");
|
|
12
|
+
};
|