@my-react/react-reconciler-compact 0.0.13 → 0.0.15

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.
Files changed (41) hide show
  1. package/constants.js +1 -1
  2. package/dist/cjs/index.development.js +884 -1171
  3. package/dist/cjs/index.production.js +824 -1122
  4. package/dist/cjs/preload.development.js +548 -0
  5. package/dist/cjs/preload.production.js +548 -0
  6. package/dist/esm/index.mjs +1651 -1844
  7. package/dist/esm/preload.mjs +544 -0
  8. package/dist/types/api/append.d.ts.map +1 -1
  9. package/dist/types/api/create.d.ts.map +1 -1
  10. package/dist/types/api/position.d.ts.map +1 -1
  11. package/dist/types/api/ref.d.ts.map +1 -1
  12. package/dist/types/api/remove.d.ts.map +1 -1
  13. package/dist/types/api/update.d.ts.map +1 -1
  14. package/dist/types/config.d.ts.map +1 -1
  15. package/dist/types/constants.d.ts.map +1 -1
  16. package/dist/types/devtool.d.ts.map +1 -1
  17. package/dist/types/{dispatchFiber.d.ts → dispatch-fiber.d.ts} +1 -1
  18. package/dist/types/dispatch-fiber.d.ts.map +1 -0
  19. package/dist/types/{dispatchMap.d.ts → dispatch-map.d.ts} +1 -1
  20. package/dist/types/dispatch-map.d.ts.map +1 -0
  21. package/dist/types/{dispatchMount.d.ts → dispatch-mount.d.ts} +1 -1
  22. package/dist/types/dispatch-mount.d.ts.map +1 -0
  23. package/dist/types/{dispatchUpdate.d.ts → dispatch-update.d.ts} +1 -1
  24. package/dist/types/dispatch-update.d.ts.map +1 -0
  25. package/dist/types/dispatch.d.ts +35 -207
  26. package/dist/types/dispatch.d.ts.map +1 -1
  27. package/dist/types/feature.d.ts +46 -218
  28. package/dist/types/feature.d.ts.map +1 -1
  29. package/dist/types/hmr.d.ts.map +1 -1
  30. package/dist/types/index.d.ts.map +1 -1
  31. package/dist/types/polyfill.d.ts.map +1 -1
  32. package/dist/types/portal.d.ts +2 -2
  33. package/dist/types/portal.d.ts.map +1 -1
  34. package/dist/types/preload.d.ts +4 -0
  35. package/dist/types/preload.d.ts.map +1 -0
  36. package/index.d.ts +1 -1
  37. package/package.json +29 -5
  38. package/dist/types/dispatchFiber.d.ts.map +0 -1
  39. package/dist/types/dispatchMap.d.ts.map +0 -1
  40. package/dist/types/dispatchMount.d.ts.map +0 -1
  41. package/dist/types/dispatchUpdate.d.ts.map +0 -1
@@ -0,0 +1,544 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
16
+
17
+
18
+ var __assign = function() {
19
+ __assign = Object.assign || function __assign(t) {
20
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
21
+ s = arguments[i];
22
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+
29
+ function __awaiter(thisArg, _arguments, P, generator) {
30
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
31
+ return new (P || (P = Promise))(function (resolve, reject) {
32
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
33
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
34
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
35
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
36
+ });
37
+ }
38
+
39
+ function __generator(thisArg, body) {
40
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
41
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
42
+ function verb(n) { return function (v) { return step([n, v]); }; }
43
+ function step(op) {
44
+ if (f) throw new TypeError("Generator is already executing.");
45
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
46
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
47
+ if (y = 0, t) op = [op[0] & 2, t.value];
48
+ switch (op[0]) {
49
+ case 0: case 1: t = op; break;
50
+ case 4: _.label++; return { value: op[1], done: false };
51
+ case 5: _.label++; y = op[1]; op = [0]; continue;
52
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
53
+ default:
54
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
55
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
56
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
57
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
58
+ if (t[2]) _.ops.pop();
59
+ _.trys.pop(); continue;
60
+ }
61
+ op = body.call(thisArg, _);
62
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
63
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
64
+ }
65
+ }
66
+
67
+ function __spreadArray(to, from, pack) {
68
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
69
+ if (ar || !(i in from)) {
70
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
71
+ ar[i] = from[i];
72
+ }
73
+ }
74
+ return to.concat(ar || Array.prototype.slice.call(from));
75
+ }
76
+
77
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
78
+ var e = new Error(message);
79
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
80
+ };
81
+
82
+ /* eslint-disable @typescript-eslint/no-unused-vars */
83
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
84
+ function loadRemoteScript(url_1) {
85
+ return __awaiter(this, arguments, void 0, function (url, options) {
86
+ var _a, timeout, _b, context, _c, useEval, controller_1, timeoutId, response, code, error_1, errorMsg;
87
+ if (options === void 0) { options = {}; }
88
+ return __generator(this, function (_d) {
89
+ switch (_d.label) {
90
+ case 0:
91
+ _a = options.timeout, timeout = _a === void 0 ? 10000 : _a, _b = options.context, context = _b === void 0 ? {} : _b, _c = options.useEval, useEval = _c === void 0 ? false : _c;
92
+ _d.label = 1;
93
+ case 1:
94
+ _d.trys.push([1, 5, , 6]);
95
+ controller_1 = new AbortController();
96
+ timeoutId = setTimeout(function () { return controller_1.abort(); }, timeout);
97
+ return [4 /*yield*/, fetch(url, {
98
+ signal: controller_1.signal,
99
+ })];
100
+ case 2:
101
+ response = _d.sent();
102
+ if (!response.ok) {
103
+ throw new Error("HTTP ".concat(response.status, ": ").concat(response.statusText));
104
+ }
105
+ return [4 /*yield*/, response.text()];
106
+ case 3:
107
+ code = _d.sent();
108
+ clearTimeout(timeoutId);
109
+ // 根据环境选择执行方式
110
+ return [4 /*yield*/, executeScript(code, url, { context: context, useEval: useEval })];
111
+ case 4:
112
+ // 根据环境选择执行方式
113
+ _d.sent();
114
+ return [3 /*break*/, 6];
115
+ case 5:
116
+ error_1 = _d.sent();
117
+ if ((error_1 === null || error_1 === void 0 ? void 0 : error_1.name) === "AbortError") {
118
+ throw new Error("\u52A0\u8F7D\u8FDC\u7A0B\u811A\u672C\u8D85\u65F6 (".concat(timeout, "ms)"));
119
+ }
120
+ errorMsg = (error_1 === null || error_1 === void 0 ? void 0 : error_1.message) || String(error_1);
121
+ throw new Error("\u52A0\u8F7D\u8FDC\u7A0B\u811A\u672C\u5931\u8D25: ".concat(errorMsg));
122
+ case 6: return [2 /*return*/];
123
+ }
124
+ });
125
+ });
126
+ }
127
+ function executeScript(code, url, options) {
128
+ return __awaiter(this, void 0, void 0, function () {
129
+ var _a, context, _b, useEval, env, _c;
130
+ return __generator(this, function (_d) {
131
+ switch (_d.label) {
132
+ case 0:
133
+ _a = options.context, context = _a === void 0 ? {} : _a, _b = options.useEval, useEval = _b === void 0 ? false : _b;
134
+ env = detectEnvironment();
135
+ _c = env;
136
+ switch (_c) {
137
+ case "bun": return [3 /*break*/, 1];
138
+ case "node": return [3 /*break*/, 3];
139
+ case "browser": return [3 /*break*/, 5];
140
+ case "webworker": return [3 /*break*/, 7];
141
+ }
142
+ return [3 /*break*/, 9];
143
+ case 1: return [4 /*yield*/, executeInBun(code, url, context)];
144
+ case 2:
145
+ _d.sent();
146
+ return [3 /*break*/, 10];
147
+ case 3: return [4 /*yield*/, executeInNode(code, url, context)];
148
+ case 4:
149
+ _d.sent();
150
+ return [3 /*break*/, 10];
151
+ case 5: return [4 /*yield*/, executeInBrowser(code, url, context, useEval)];
152
+ case 6:
153
+ _d.sent();
154
+ return [3 /*break*/, 10];
155
+ case 7: return [4 /*yield*/, executeInWebWorker(code, url, context, useEval)];
156
+ case 8:
157
+ _d.sent();
158
+ return [3 /*break*/, 10];
159
+ case 9: throw new Error("未知的 JavaScript 环境");
160
+ case 10: return [2 /*return*/];
161
+ }
162
+ });
163
+ });
164
+ }
165
+ function detectEnvironment() {
166
+ // 检测 Bun
167
+ // @ts-ignore
168
+ if (typeof Bun !== "undefined" && typeof Bun === "object") {
169
+ return "bun";
170
+ }
171
+ // 检测 Node.js
172
+ if (typeof process !== "undefined" && process.versions && process.versions.node) {
173
+ return "node";
174
+ }
175
+ // 检测 Web Worker 环境 (must check before browser since workers don't have window/document)
176
+ if (typeof self !== "undefined" && typeof importScripts === "function") {
177
+ return "webworker";
178
+ }
179
+ // 检测浏览器环境
180
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
181
+ return "browser";
182
+ }
183
+ // 默认为浏览器环境(保守策略)
184
+ return "browser";
185
+ }
186
+ // 安全的 Base64 编码函数(跨环境兼容)
187
+ function safeBase64Encode(str) {
188
+ // Node.js 环境
189
+ if (typeof Buffer !== "undefined") {
190
+ return Buffer.from(str, "utf-8").toString("base64");
191
+ }
192
+ // 浏览器环境
193
+ if (typeof btoa !== "undefined") {
194
+ // 处理 Unicode 字符
195
+ var utf8Bytes_1 = new TextEncoder().encode(str);
196
+ var binary = "";
197
+ for (var i = 0; i < utf8Bytes_1.length; i++) {
198
+ binary += String.fromCharCode(utf8Bytes_1[i]);
199
+ }
200
+ return btoa(binary);
201
+ }
202
+ // 回退方案:手动实现 Base64 编码
203
+ var base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
204
+ var utf8Bytes = new TextEncoder().encode(str);
205
+ var result = "";
206
+ for (var i = 0; i < utf8Bytes.length; i += 3) {
207
+ var a = utf8Bytes[i];
208
+ var b = i + 1 < utf8Bytes.length ? utf8Bytes[i + 1] : 0;
209
+ var c = i + 2 < utf8Bytes.length ? utf8Bytes[i + 2] : 0;
210
+ var bitmap = (a << 16) | (b << 8) | c;
211
+ result += base64Chars[(bitmap >> 18) & 63];
212
+ result += base64Chars[(bitmap >> 12) & 63];
213
+ result += i + 1 < utf8Bytes.length ? base64Chars[(bitmap >> 6) & 63] : "=";
214
+ result += i + 2 < utf8Bytes.length ? base64Chars[bitmap & 63] : "=";
215
+ }
216
+ return result;
217
+ }
218
+ // Bun 环境执行
219
+ function executeInBun(code, url, context) {
220
+ return __awaiter(this, void 0, void 0, function () {
221
+ var base64Code, dataUrl;
222
+ return __generator(this, function (_a) {
223
+ switch (_a.label) {
224
+ case 0:
225
+ _a.trys.push([0, 2, , 4]);
226
+ base64Code = safeBase64Encode(code);
227
+ dataUrl = "data:application/javascript;base64,".concat(base64Code);
228
+ return [4 /*yield*/, import(/* @vite-ignore */ dataUrl)];
229
+ case 1:
230
+ _a.sent();
231
+ return [2 /*return*/];
232
+ case 2:
233
+ _a.sent();
234
+ // 方法2: 使用 VM 回退
235
+ return [4 /*yield*/, executeWithVM(code, url, context)];
236
+ case 3:
237
+ // 方法2: 使用 VM 回退
238
+ _a.sent();
239
+ return [3 /*break*/, 4];
240
+ case 4: return [2 /*return*/];
241
+ }
242
+ });
243
+ });
244
+ }
245
+ // Node.js 环境执行
246
+ function executeInNode(code, url, context) {
247
+ return __awaiter(this, void 0, void 0, function () {
248
+ var error_3, base64Code, dataUrl, importError_1, errorMsg, importErrorMsg;
249
+ return __generator(this, function (_a) {
250
+ switch (_a.label) {
251
+ case 0:
252
+ _a.trys.push([0, 2, , 7]);
253
+ // 方法1: 使用 VM 模块
254
+ return [4 /*yield*/, executeWithVM(code, url, context)];
255
+ case 1:
256
+ // 方法1: 使用 VM 模块
257
+ _a.sent();
258
+ return [3 /*break*/, 7];
259
+ case 2:
260
+ error_3 = _a.sent();
261
+ _a.label = 3;
262
+ case 3:
263
+ _a.trys.push([3, 5, , 6]);
264
+ base64Code = safeBase64Encode(code);
265
+ dataUrl = "data:application/javascript;base64,".concat(base64Code);
266
+ return [4 /*yield*/, import(/* @vite-ignore */ dataUrl)];
267
+ case 4:
268
+ _a.sent();
269
+ return [3 /*break*/, 6];
270
+ case 5:
271
+ importError_1 = _a.sent();
272
+ errorMsg = (error_3 === null || error_3 === void 0 ? void 0 : error_3.message) || String(error_3);
273
+ importErrorMsg = (importError_1 === null || importError_1 === void 0 ? void 0 : importError_1.message) || String(importError_1);
274
+ throw new Error("Node.js \u6267\u884C\u5931\u8D25: ".concat(errorMsg, ", ").concat(importErrorMsg));
275
+ case 6: return [3 /*break*/, 7];
276
+ case 7: return [2 /*return*/];
277
+ }
278
+ });
279
+ });
280
+ }
281
+ // 浏览器环境执行
282
+ function executeInBrowser(code, url, context, useEval) {
283
+ return __awaiter(this, void 0, void 0, function () {
284
+ return __generator(this, function (_a) {
285
+ switch (_a.label) {
286
+ case 0:
287
+ // 浏览器环境的安全考虑
288
+ if (!useEval && isPotentiallyUnsafe(code)) {
289
+ throw new Error("代码包含潜在不安全内容,如需执行请设置 useEval: true");
290
+ }
291
+ _a.label = 1;
292
+ case 1:
293
+ _a.trys.push([1, 3, , 4]);
294
+ // 方法1: 使用 script 标签插入 (最安全)
295
+ return [4 /*yield*/, executeWithScriptTag(code)];
296
+ case 2:
297
+ // 方法1: 使用 script 标签插入 (最安全)
298
+ _a.sent();
299
+ return [3 /*break*/, 4];
300
+ case 3:
301
+ _a.sent();
302
+ // 方法2: 使用 eval (需要显式启用)
303
+ if (useEval) {
304
+ executeWithEval(code, context);
305
+ }
306
+ else {
307
+ throw new Error("浏览器执行失败,请启用 useEval 选项或检查 CSP 设置");
308
+ }
309
+ return [3 /*break*/, 4];
310
+ case 4: return [2 /*return*/];
311
+ }
312
+ });
313
+ });
314
+ }
315
+ // 通用 VM 执行 (Node.js/Bun)
316
+ function executeWithVM(code, url, context) {
317
+ return __awaiter(this, void 0, void 0, function () {
318
+ var vm, sandbox, vmContext, script, error_5, errorMsg;
319
+ return __generator(this, function (_a) {
320
+ switch (_a.label) {
321
+ case 0:
322
+ _a.trys.push([0, 2, , 3]);
323
+ return [4 /*yield*/, import('vm')];
324
+ case 1:
325
+ vm = _a.sent();
326
+ sandbox = __assign(__assign(__assign({
327
+ // 基础全局变量
328
+ console: console, setTimeout: setTimeout, setInterval: setInterval, clearTimeout: clearTimeout, clearInterval: clearInterval, URL: URL, URLSearchParams: URLSearchParams,
329
+ // 内置对象
330
+ Object: Object, Array: Array, String: String, Number: Number, Boolean: Boolean, Symbol: Symbol, Date: Date, RegExp: RegExp, Error: Error, TypeError: TypeError, RangeError: RangeError, SyntaxError: SyntaxError, Map: Map, Set: Set, WeakMap: WeakMap, WeakSet: WeakSet, Promise: Promise, JSON: JSON, Math: Math }, (typeof global !== "undefined" ? { global: global } : {})), (typeof process !== "undefined" ? { process: process } : {})), context);
331
+ vmContext = vm.createContext(sandbox);
332
+ script = new vm.Script(code, {
333
+ filename: url,
334
+ lineOffset: 0,
335
+ columnOffset: 0,
336
+ });
337
+ script.runInContext(vmContext);
338
+ return [3 /*break*/, 3];
339
+ case 2:
340
+ error_5 = _a.sent();
341
+ errorMsg = (error_5 === null || error_5 === void 0 ? void 0 : error_5.message) || String(error_5);
342
+ throw new Error("VM \u6267\u884C\u5931\u8D25: ".concat(errorMsg));
343
+ case 3: return [2 /*return*/];
344
+ }
345
+ });
346
+ });
347
+ }
348
+ // Web Worker 环境执行
349
+ function executeInWebWorker(code, _url, context, useEval) {
350
+ return __awaiter(this, void 0, void 0, function () {
351
+ var blob, blobUrl;
352
+ return __generator(this, function (_a) {
353
+ if (!useEval && isPotentiallyUnsafe(code)) {
354
+ throw new Error("代码包含潜在不安全内容,如需执行请设置 useEval: true");
355
+ }
356
+ try {
357
+ blob = new Blob([code], { type: "application/javascript" });
358
+ blobUrl = URL.createObjectURL(blob);
359
+ try {
360
+ importScripts(blobUrl);
361
+ }
362
+ finally {
363
+ URL.revokeObjectURL(blobUrl);
364
+ }
365
+ }
366
+ catch (error) {
367
+ // 方法2: 使用 Function 构造函数 (回退方案)
368
+ if (useEval) {
369
+ executeWithEval(code, context);
370
+ }
371
+ else {
372
+ throw new Error("Web Worker 执行失败,请启用 useEval 选项或检查 CSP 设置");
373
+ }
374
+ }
375
+ return [2 /*return*/];
376
+ });
377
+ });
378
+ }
379
+ // 浏览器 script 标签执行
380
+ function executeWithScriptTag(code, url) {
381
+ // 检查是否在浏览器环境
382
+ if (typeof document === "undefined") {
383
+ throw new Error("document 未定义,不在浏览器环境中");
384
+ }
385
+ return new Promise(function (resolve, reject) {
386
+ // 创建 script 元素
387
+ var script = document.createElement("script");
388
+ // 使用 Blob URL 避免 CSP 问题
389
+ var blob = new Blob([code], { type: "application/javascript" });
390
+ var blobUrl = URL.createObjectURL(blob);
391
+ script.src = blobUrl;
392
+ // 清理函数
393
+ var cleanup = function () {
394
+ URL.revokeObjectURL(blobUrl);
395
+ // 从 DOM 中移除 script 标签以防止内存泄漏
396
+ if (script.parentNode) {
397
+ script.parentNode.removeChild(script);
398
+ }
399
+ };
400
+ // 设置错误处理
401
+ script.onerror = function () {
402
+ cleanup();
403
+ reject(new Error("Script 标签加载失败"));
404
+ };
405
+ script.onload = function () {
406
+ cleanup();
407
+ resolve();
408
+ };
409
+ // 添加到 DOM
410
+ document.head.appendChild(script);
411
+ });
412
+ }
413
+ // 浏览器 eval 执行
414
+ function executeWithEval(code, context) {
415
+ // 在特定上下文中执行
416
+ var contextKeys = Object.keys(context);
417
+ var contextValues = Object.values(context);
418
+ try {
419
+ // 使用 Function 构造函数比直接 eval 稍安全
420
+ var func = new (Function.bind.apply(Function, __spreadArray(__spreadArray([void 0], contextKeys, false), ["\n \"use strict\";\n ".concat(code, "\n ")], false)))();
421
+ func.apply(void 0, contextValues);
422
+ }
423
+ catch (error) {
424
+ // 回退到间接 eval
425
+ try {
426
+ var indirectEval = eval;
427
+ indirectEval(code);
428
+ }
429
+ catch (evalError) {
430
+ var errorMsg = (evalError === null || evalError === void 0 ? void 0 : evalError.message) || String(evalError);
431
+ throw new Error("Eval \u6267\u884C\u5931\u8D25: ".concat(errorMsg));
432
+ }
433
+ }
434
+ }
435
+ // 增强的安全检查
436
+ function isPotentiallyUnsafe(code) {
437
+ var unsafePatterns = [
438
+ // Cookie 和存储访问
439
+ /document\.cookie/i,
440
+ /localStorage/i,
441
+ /sessionStorage/i,
442
+ /indexedDB/i,
443
+ // 动态代码执行
444
+ /\beval\s*\(/i,
445
+ /Function\s*\(/i,
446
+ /setTimeout\s*\(\s*["'`]/i, // setTimeout with string
447
+ /setInterval\s*\(\s*["'`]/i, // setInterval with string
448
+ // 动态脚本和 DOM 操作
449
+ /script\.src/i,
450
+ /\.innerHTML/i,
451
+ /\.outerHTML/i,
452
+ /document\.write/i,
453
+ /document\.writeln/i,
454
+ // 动态属性访问(可能绕过检查)
455
+ /\[["'`]eval["'`]\]/i,
456
+ /\[["'`]cookie["'`]\]/i,
457
+ /\[["'`]localStorage["'`]\]/i,
458
+ // import() 动态导入
459
+ /import\s*\(/i,
460
+ // 危险的 DOM API
461
+ /\.insertAdjacentHTML/i,
462
+ /createContextualFragment/i,
463
+ ];
464
+ return unsafePatterns.some(function (pattern) { return pattern.test(code); });
465
+ }
466
+ // 安全的 require 函数模拟
467
+ function createSafeRequire() {
468
+ if (typeof require !== "undefined") {
469
+ return require;
470
+ }
471
+ // 在浏览器环境中返回一个安全的模拟 require
472
+ return function (id) {
473
+ throw new Error("require('".concat(id, "') \u5728\u6D4F\u89C8\u5668\u73AF\u5883\u4E2D\u4E0D\u53EF\u7528"));
474
+ };
475
+ }
476
+ // 增强的模块加载版本(支持导出)
477
+ function loadRemoteModule(url_1) {
478
+ return __awaiter(this, arguments, void 0, function (url, options) {
479
+ var _a, context, moduleExports, moduleContext;
480
+ if (options === void 0) { options = {}; }
481
+ return __generator(this, function (_b) {
482
+ switch (_b.label) {
483
+ case 0:
484
+ _a = options.context, context = _a === void 0 ? {} : _a;
485
+ moduleExports = {};
486
+ moduleContext = __assign({ exports: moduleExports, module: { exports: moduleExports }, require: createSafeRequire() }, context);
487
+ return [4 /*yield*/, loadRemoteScript(url, __assign(__assign({}, options), { context: moduleContext }))];
488
+ case 1:
489
+ _b.sent();
490
+ return [2 /*return*/, moduleContext.module.exports];
491
+ }
492
+ });
493
+ });
494
+ }
495
+
496
+ var preloadDevToolRuntimeAuto = function () { return __awaiter(void 0, void 0, void 0, function () {
497
+ return __generator(this, function (_a) {
498
+ switch (_a.label) {
499
+ case 0:
500
+ if (globalThis["__MY_REACT_DEVTOOL_INTERNAL__"])
501
+ return [2 /*return*/];
502
+ // load core runtime
503
+ return [4 /*yield*/, loadRemoteModule("https://mrwangjusttodo.github.io/myreact-devtools/bundle/hook.js", { context: { globalThis: globalThis } })];
504
+ case 1:
505
+ // load core runtime
506
+ _a.sent();
507
+ return [2 /*return*/];
508
+ }
509
+ });
510
+ }); };
511
+ var preloadDevToolRuntimeSocketIO = function () { return __awaiter(void 0, void 0, void 0, function () {
512
+ return __generator(this, function (_a) {
513
+ switch (_a.label) {
514
+ case 0:
515
+ if (globalThis["__MY_REACT_DEVTOOL_INTERNAL__"])
516
+ return [2 /*return*/];
517
+ // load core runtime
518
+ // also load socket.io
519
+ return [4 /*yield*/, loadRemoteModule("https://mrwangjusttodo.github.io/myreact-devtools/bundle/bundle-dev.js", { context: { globalThis: globalThis } })];
520
+ case 1:
521
+ // load core runtime
522
+ // also load socket.io
523
+ _a.sent();
524
+ return [2 /*return*/];
525
+ }
526
+ });
527
+ }); };
528
+ var preloadDevToolRuntimeWebsocket = function () { return __awaiter(void 0, void 0, void 0, function () {
529
+ return __generator(this, function (_a) {
530
+ switch (_a.label) {
531
+ case 0:
532
+ if (globalThis["__MY_REACT_DEVTOOL_INTERNAL__"])
533
+ return [2 /*return*/];
534
+ // load core runtime
535
+ return [4 /*yield*/, loadRemoteModule("https://mrwangjusttodo.github.io/myreact-devtools/bundle/bundle-ws-dev.js", { context: { globalThis: globalThis } })];
536
+ case 1:
537
+ // load core runtime
538
+ _a.sent();
539
+ return [2 /*return*/];
540
+ }
541
+ });
542
+ }); };
543
+
544
+ export { preloadDevToolRuntimeAuto, preloadDevToolRuntimeSocketIO, preloadDevToolRuntimeWebsocket };
@@ -1 +1 @@
1
- {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../../src/api/append.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAyC,MAAM,4BAA4B,CAAC;AAK1G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,MAAM,cAAe,kBAAkB,UAAU,gBAAgB,WAAW,GAAG,SAmD3F,CAAC"}
1
+ {"version":3,"file":"append.d.ts","sourceRoot":"","sources":["../../../src/api/append.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAyC,MAAM,4BAA4B,CAAC;AAK1G,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,MAAM,GAAI,WAAW,kBAAkB,EAAE,QAAQ,gBAAgB,EAAE,SAAS,GAAG,SAmD3F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/api/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAyB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,eAAO,MAAM,MAAM,cAAe,kBAAkB,UAAU,gBAAgB,WAAW,GAAG,SA0C3F,CAAC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/api/create.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAyB,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE1F,eAAO,MAAM,MAAM,GAAI,WAAW,kBAAkB,EAAE,QAAQ,gBAAgB,EAAE,SAAS,GAAG,SA0C3F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/api/position.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAC;AA6G1F,eAAO,MAAM,QAAQ,cAAe,kBAAkB,UAAU,gBAAgB,WAAW,GAAG,SAgB7F,CAAC"}
1
+ {"version":3,"file":"position.d.ts","sourceRoot":"","sources":["../../../src/api/position.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAC;AA6G1F,eAAO,MAAM,QAAQ,GAAI,WAAW,kBAAkB,EAAE,QAAQ,gBAAgB,EAAE,SAAS,GAAG,SAgB7F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../../src/api/ref.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,MAAM,WAAY,gBAAgB,UAAU,GAAG,SAwE3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,WAAY,gBAAgB,SAoBhD,CAAC"}
1
+ {"version":3,"file":"ref.d.ts","sourceRoot":"","sources":["../../../src/api/ref.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,QAAQ,gBAAgB,EAAE,QAAQ,GAAG,SAwE3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,QAAQ,gBAAgB,SAoBhD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/api/remove.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAC;AAE1F,eAAO,MAAM,MAAM,cAAe,kBAAkB,UAAU,gBAAgB,WAAW,GAAG,SAyB3F,CAAC"}
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/api/remove.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,4BAA4B,CAAC;AAE1F,eAAO,MAAM,MAAM,GAAI,WAAW,kBAAkB,EAAE,QAAQ,gBAAgB,EAAE,SAAS,GAAG,SAyB3F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/api/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,MAAM,cAAe,kBAAkB,UAAU,gBAAgB,WAAW,GAAG,SAwC3F,CAAC"}
1
+ {"version":3,"file":"update.d.ts","sourceRoot":"","sources":["../../../src/api/update.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAG9E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,MAAM,GAAI,WAAW,kBAAkB,EAAE,QAAQ,gBAAgB,EAAE,SAAS,GAAG,SAwC3F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB;;CAAmB,CAAC;AA0BrD,eAAO,MAAM,WAAW,WAAY,GAAG,SAMtC,CAAC"}
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,oBAAoB;;CAAmB,CAAC;AA0BrD,eAAO,MAAM,WAAW,GAAI,QAAQ,GAAG,SAMtC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,IAAI,CAAA;AAC/B,eAAO,MAAM,UAAU,IAAI,CAAA;AAG3B,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,cAAc,IAAI,CAAC;AAChC,eAAO,MAAM,UAAU,IAAI,CAAC;AAG5B,eAAO,MAAM,oBAAoB,IAAI,CAAC;AACtC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,iBAAiB,IAAI,CAAC;AACnC,eAAO,MAAM,eAAe,IAAI,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"devtool.d.ts","sourceRoot":"","sources":["../../src/devtool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD,eAAO,MAAM,cAAc,uCAAuC,CAAC;AAEnE,eAAO,MAAM,iBAAiB,aAAc,oBAAoB,SAU/D,CAAC;AAEF,eAAO,MAAM,eAAe,aAAc,oBAAoB,SAY7D,CAAC;AAEF,eAAO,MAAM,iBAAiB,aAAc,oBAAoB,SAM/D,CAAC"}
1
+ {"version":3,"file":"devtool.d.ts","sourceRoot":"","sources":["../../src/devtool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAEvE,eAAO,MAAM,cAAc,2BAA2B,CAAC;AAEvD,eAAO,MAAM,cAAc,uCAAuC,CAAC;AAEnE,eAAO,MAAM,iBAAiB,GAAI,UAAU,oBAAoB,SAU/D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,UAAU,oBAAoB,SAY7D,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,UAAU,oBAAoB,SAM/D,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { ReconcilerDispatch } from "./dispatch";
2
2
  import type { MyReactFiberNode } from "@my-react/react-reconciler";
3
3
  export declare const ReconcilerDispatchFiber: (renderDispatch: ReconcilerDispatch, fiber: MyReactFiberNode) => void;
4
- //# sourceMappingURL=dispatchFiber.d.ts.map
4
+ //# sourceMappingURL=dispatch-fiber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-fiber.d.ts","sourceRoot":"","sources":["../../src/dispatch-fiber.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,eAAO,MAAM,uBAAuB,GAAI,gBAAgB,kBAAkB,EAAE,OAAO,gBAAgB,SAqBlG,CAAC"}
@@ -5,4 +5,4 @@ export declare const unmountMap: (dispatch: ReconcilerDispatch, fiber: MyReactFi
5
5
  export declare const getFiberWithNativeNode: (fiber: MyReactFiberNode | null, transform: (f: MyReactFiberNode) => MyReactFiberNode | null) => MyReactFiberNode | null;
6
6
  export declare const getValidParentFiberWithNode: (_dispatch: ReconcilerDispatch, _fiber: MyReactFiberNode) => MyReactFiberNode;
7
7
  export declare const getInsertBeforeNodeFromSiblingAndParent: (fiber: MyReactFiberNode | null, parentFiber: MyReactFiberNode | null) => MyReactFiberNode | null;
8
- //# sourceMappingURL=dispatchMap.d.ts.map
8
+ //# sourceMappingURL=dispatch-map.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-map.d.ts","sourceRoot":"","sources":["../../src/dispatch-map.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAA2C,MAAM,4BAA4B,CAAC;AAE5G,eAAO,MAAM,UAAU,GAAI,UAAU,kBAAkB,EAAE,OAAO,gBAAgB,EAAE,QAAQ,GAAG,SAgD5F,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,UAAU,kBAAkB,EAAE,OAAO,gBAAgB,SAI/E,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,OAAO,gBAAgB,GAAG,IAAI,EAC9B,WAAW,CAAC,CAAC,EAAE,gBAAgB,KAAK,gBAAgB,GAAG,IAAI,KAC1D,gBAAgB,GAAG,IAYrB,CAAC;AAEF,eAAO,MAAM,2BAA2B,GAAI,WAAW,kBAAkB,EAAE,QAAQ,gBAAgB,qBAUlG,CAAC;AA4BF,eAAO,MAAM,uCAAuC,GAAI,OAAO,gBAAgB,GAAG,IAAI,EAAE,aAAa,gBAAgB,GAAG,IAAI,KAAG,gBAAgB,GAAG,IAUjJ,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import type { ReconcilerDispatch } from "./dispatch";
2
2
  import type { MyReactFiberNode } from "@my-react/react-reconciler";
3
3
  export declare const ReconcilerDispatchMount: (_dispatch: ReconcilerDispatch, _fiber: MyReactFiberNode, config: any) => void;
4
- //# sourceMappingURL=dispatchMount.d.ts.map
4
+ //# sourceMappingURL=dispatch-mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-mount.d.ts","sourceRoot":"","sources":["../../src/dispatch-mount.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAMnE,eAAO,MAAM,uBAAuB,GAAI,WAAW,kBAAkB,EAAE,QAAQ,gBAAgB,EAAE,QAAQ,GAAG,SAgG3G,CAAC"}
@@ -2,4 +2,4 @@ import type { ReconcilerDispatch } from "./dispatch";
2
2
  import type { MyReactFiberNode } from "@my-react/react-reconciler";
3
3
  import type { ListTree } from "@my-react/react-shared";
4
4
  export declare const ReconcilerDispatchUpdate: (_dispatch: ReconcilerDispatch, _list: ListTree<MyReactFiberNode>, config: any, sync?: boolean) => void;
5
- //# sourceMappingURL=dispatchUpdate.d.ts.map
5
+ //# sourceMappingURL=dispatch-update.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatch-update.d.ts","sourceRoot":"","sources":["../../src/dispatch-update.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAMvD,eAAO,MAAM,wBAAwB,GAAI,WAAW,kBAAkB,EAAE,OAAO,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,GAAG,EAAE,OAAO,OAAO,SAgJrI,CAAC"}