@blueking/bk-weweb 0.0.29 → 0.0.30

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.
@@ -462,7 +462,7 @@ var SandBox = class {
462
462
  return Reflect.defineProperty(target, key, value);
463
463
  },
464
464
  deleteProperty: (target, key) => {
465
- if (target.hasOwnProperty(key)) {
465
+ if (Object.hasOwn(target, key)) {
466
466
  this.sameRawWindowKeySet.has(key) && this.sameRawWindowKeySet.delete(key);
467
467
  this.inRawWindowKeySet.has(key) && Reflect.deleteProperty(rawWindow, key);
468
468
  return Reflect.deleteProperty(target, key);
@@ -485,7 +485,7 @@ var SandBox = class {
485
485
  return this.app.iframe.contentWindow?.[key];
486
486
  }
487
487
  if (key === "hasOwnProperty")
488
- return (key2) => this.fakeWindow.hasOwnProperty(key2) || rawWindow.hasOwnProperty(key2);
488
+ return (key2) => Object.hasOwn(this.fakeWindow, key2) || Object.hasOwn(rawWindow, key2);
489
489
  if (key === "top" || key === "parent") {
490
490
  if (rawWindow === rawWindow.parent) {
491
491
  return this.proxyWindow;
@@ -505,10 +505,10 @@ var SandBox = class {
505
505
  return bindFunctionToRawWindow(rawWindow, rawValue);
506
506
  },
507
507
  getOwnPropertyDescriptor: (target, key) => {
508
- if (target.hasOwnProperty(key)) {
508
+ if (Object.hasOwn(target, key)) {
509
509
  return Object.getOwnPropertyDescriptor(target, key);
510
510
  }
511
- if (rawWindow.hasOwnProperty(key)) {
511
+ if (Object.hasOwn(rawWindow, key)) {
512
512
  windowDescriptorSet.add(key);
513
513
  const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key);
514
514
  if (descriptor && !descriptor.configurable) {
@@ -528,7 +528,7 @@ var SandBox = class {
528
528
  }
529
529
  if (key === "location") {
530
530
  Reflect.set(rawWindow, key, value);
531
- } else if (!target.hasOwnProperty(key) && rawWindow.hasOwnProperty(key) && !BK_WEWEB_INJECT_KEY_LIST.includes(key)) {
531
+ } else if (!Object.hasOwn(target, key) && Object.hasOwn(rawWindow, key) && !BK_WEWEB_INJECT_KEY_LIST.includes(key)) {
532
532
  const descriptor = Object.getOwnPropertyDescriptor(rawWindow, key);
533
533
  const { configurable, enumerable, writable } = descriptor;
534
534
  if (writable) {
@@ -570,7 +570,7 @@ var SandBox = class {
570
570
  * @param data data for sandbox
571
571
  * @description active hook for sandbox
572
572
  */
573
- activeated(data) {
573
+ activated(data) {
574
574
  if (!this.active) {
575
575
  this.active = true;
576
576
  this.rawDocument = createProxyDocument(document, this.app);
@@ -587,7 +587,9 @@ var SandBox = class {
587
587
  if (!this.active) return;
588
588
  this.active = false;
589
589
  this.resetWindowFunction();
590
- this.inRawWindowKeySet.forEach((key) => Reflect.deleteProperty(window, key));
590
+ for (const key of this.inRawWindowKeySet) {
591
+ Reflect.deleteProperty(window, key);
592
+ }
591
593
  this.inRawWindowKeySet.clear();
592
594
  this.resetDocumentAndBodyEvent?.();
593
595
  }
@@ -665,7 +667,7 @@ function resetNewElement(parent, child, app) {
665
667
  return child;
666
668
  }
667
669
  if (replaceInfo.script) {
668
- replaceInfo.script.excuteCode(app);
670
+ replaceInfo.script.executeCode(app);
669
671
  }
670
672
  if (replaceInfo.replace !== child) {
671
673
  return replaceInfo.replace;
@@ -683,7 +685,7 @@ function resetNewElement(parent, child, app) {
683
685
  return;
684
686
  }
685
687
  if (scriptInfo?.script) {
686
- scriptInfo.script.excuteCode(app);
688
+ scriptInfo.script.executeCode(app);
687
689
  }
688
690
  child.remove();
689
691
  } else if (child.textContent) {
@@ -697,7 +699,7 @@ function resetNewElement(parent, child, app) {
697
699
  });
698
700
  app.source.scripts.set(randomUrl(), scriptInstance);
699
701
  try {
700
- scriptInstance.excuteCode(app);
702
+ scriptInstance.executeCode(app);
701
703
  } catch (e) {
702
704
  console.error(e);
703
705
  } finally {
@@ -713,15 +715,15 @@ function resetNewElement(parent, child, app) {
713
715
  }
714
716
  return child;
715
717
  }
716
- function isSepcailElement(node) {
718
+ function isSpecialElement(node) {
717
719
  return node instanceof HTMLScriptElement || node instanceof HTMLStyleElement || node instanceof HTMLLinkElement;
718
720
  }
719
- function elmentAppendHandler(parent, newChild, rawMethod) {
721
+ function elementAppendHandler(parent, newChild, rawMethod) {
720
722
  if (newChild.__BK_WEWEB_APP_KEY__) {
721
723
  const app = appCache.getApp(newChild.__BK_WEWEB_APP_KEY__);
722
724
  if (app?.container) {
723
725
  const targetChild = resetNewElement(parent, newChild, app);
724
- const needKeepAlive = isSepcailElement(newChild) && !!app.keepAlive && !(app.container instanceof ShadowRoot);
726
+ const needKeepAlive = isSpecialElement(newChild) && !!app.keepAlive && !(app.container instanceof ShadowRoot);
725
727
  const container = needKeepAlive ? document.head : app?.container;
726
728
  setMarkElement(targetChild, app, needKeepAlive);
727
729
  return rawMethod.call(container, targetChild);
@@ -733,7 +735,7 @@ function elementInsertHandler(parent, newChild, passiveChild, rawMethod) {
733
735
  if (newChild.__BK_WEWEB_APP_KEY__) {
734
736
  const app = appCache.getApp(newChild.__BK_WEWEB_APP_KEY__);
735
737
  if (app?.container) {
736
- const needKeepAlive = isSepcailElement(newChild) && app.keepAlive && !(app.container instanceof ShadowRoot);
738
+ const needKeepAlive = isSpecialElement(newChild) && app.keepAlive && !(app.container instanceof ShadowRoot);
737
739
  const container = needKeepAlive ? document.head : app?.container;
738
740
  const targetChild = resetNewElement(parent, newChild, app);
739
741
  if (needKeepAlive) {
@@ -784,15 +786,15 @@ function rewriteBodyAndHeaderMethods() {
784
786
  }
785
787
  };
786
788
  HTMLBodyElement.prototype.appendChild = function appendChildNew(newChild) {
787
- if (newChild.__KEEP_ALIVE__ && isSepcailElement(newChild)) return headAppendChild.call(rawHead, newChild);
788
- return elmentAppendHandler(this, newChild, bodyAppendChild2);
789
+ if (newChild.__KEEP_ALIVE__ && isSpecialElement(newChild)) return headAppendChild.call(rawHead, newChild);
790
+ return elementAppendHandler(this, newChild, bodyAppendChild2);
789
791
  };
790
792
  HTMLBodyElement.prototype.append = function(...nodes) {
791
793
  nodes.forEach((node) => {
792
- if (node.__KEEP_ALIVE__ && isSepcailElement(node)) {
794
+ if (node.__KEEP_ALIVE__ && isSpecialElement(node)) {
793
795
  return headAppendChild.call(rawHead, node);
794
796
  }
795
- elmentAppendHandler(this, node, bodyAppendChild2);
797
+ elementAppendHandler(this, node, bodyAppendChild2);
796
798
  });
797
799
  };
798
800
  HTMLHeadElement.prototype.appendChild = HTMLBodyElement.prototype.appendChild;
@@ -1142,14 +1144,16 @@ var Style = class {
1142
1144
  }
1143
1145
  createStyleElement() {
1144
1146
  const styleElement = document.createElement("style");
1145
- if (styleElement.__BK_WEWEB_APP_KEY__) delete styleElement.__BK_WEWEB_APP_KEY__;
1147
+ if (styleElement.__BK_WEWEB_APP_KEY__) {
1148
+ styleElement.__BK_WEWEB_APP_KEY__ = void 0;
1149
+ }
1146
1150
  return styleElement;
1147
1151
  }
1148
1152
  /**
1149
1153
  * @param app 应用实例
1150
1154
  * @returns 返回执行后的style标签
1151
1155
  */
1152
- async excuteCode(app) {
1156
+ async executeCode(app) {
1153
1157
  app.registerRunningApp();
1154
1158
  let styleElement = this.createStyleElement();
1155
1159
  styleElement.setAttribute("type", "text/css");
@@ -1195,13 +1199,14 @@ var Style = class {
1195
1199
  const result = this.scopeRule(Array.from(rule.cssRules), prefix);
1196
1200
  return `@${packName} ${rule.conditionText} {${result}}`;
1197
1201
  }
1198
- resetUrlHost(cssText, baseURI, linkpath) {
1202
+ resetUrlHost(cssText, uri, linkPath) {
1203
+ let baseURI = uri;
1199
1204
  return cssText.replace(/url\(["']?([^)"']+)["']?\)/gm, (text, $1) => {
1200
1205
  if (/^(data|blob):/.test($1) || /^(https?:)?\/\//.test($1)) {
1201
1206
  return text;
1202
1207
  }
1203
- if (/^((\.\.?\/)|[^/])/.test($1) && linkpath) {
1204
- const pathArr = linkpath.split("/");
1208
+ if (/^((\.\.?\/)|[^/])/.test($1) && linkPath) {
1209
+ const pathArr = linkPath.split("/");
1205
1210
  pathArr.pop();
1206
1211
  baseURI = addUrlProtocol(`${pathArr.join("/")}/`);
1207
1212
  }
@@ -1311,18 +1316,18 @@ var Style = class {
1311
1316
  return styleElement;
1312
1317
  }
1313
1318
  };
1314
- async function excuteAppStyles(app, container) {
1319
+ async function executeAppStyles(app, container) {
1315
1320
  const styleList = Array.from(app.source.styles.values());
1316
1321
  const promiseList = [];
1317
- styleList.forEach((style) => {
1318
- promiseList.push(style.excuteCode(app));
1319
- });
1322
+ for (const style of styleList) {
1323
+ promiseList.push(style.executeCode(app));
1324
+ }
1320
1325
  await Promise.all(promiseList).then((styleElementList) => {
1321
- const parentElemnt = container || app.container;
1322
- if (app.keepAlive && !(parentElemnt instanceof ShadowRoot)) {
1326
+ const parentElement = container || app.container;
1327
+ if (app.keepAlive && !(parentElement instanceof ShadowRoot)) {
1323
1328
  document.head.append(...styleElementList);
1324
1329
  } else {
1325
- parentElemnt?.append(...styleElementList);
1330
+ parentElement?.append(...styleElementList);
1326
1331
  }
1327
1332
  });
1328
1333
  }
@@ -1380,12 +1385,12 @@ var MicroInstanceModel = class {
1380
1385
  if (this.container && container) {
1381
1386
  if (container instanceof Element) container?.setAttribute(CSS_ATTRIBUTE_KEY, this.name);
1382
1387
  const fragment = document.createDocumentFragment();
1383
- Array.from(this.container.childNodes).forEach((node) => {
1388
+ for (const node of Array.from(this.container.childNodes)) {
1384
1389
  fragment.appendChild(node);
1385
- });
1390
+ }
1386
1391
  container.appendChild(fragment);
1387
1392
  this.container = container;
1388
- this.sandBox?.activeated();
1393
+ this.sandBox?.activated();
1389
1394
  const scriptInfo = this.source?.getScript(this.url);
1390
1395
  callback?.(this, scriptInfo?.exportInstance);
1391
1396
  }
@@ -1399,17 +1404,17 @@ var MicroInstanceModel = class {
1399
1404
  this.container = container ?? this.container;
1400
1405
  this.state = "MOUNTING" /* MOUNTING */;
1401
1406
  if (this.container instanceof HTMLElement) {
1402
- this.container.setAttribute(CSS_ATTRIBUTE_KEY, this.name);
1407
+ this.container?.setAttribute(CSS_ATTRIBUTE_KEY, this.name);
1403
1408
  }
1404
1409
  this.container.innerHTML = "";
1405
1410
  const instanceWrap = document.createElement("div");
1406
1411
  const wrapId = `${this.name}-wrapper`;
1407
1412
  instanceWrap.setAttribute("id", wrapId);
1408
1413
  if (this.source?.styles.size) {
1409
- excuteAppStyles(this, this.container);
1414
+ executeAppStyles(this, this.container);
1410
1415
  }
1411
1416
  this.container.appendChild(instanceWrap);
1412
- this.sandBox?.activeated();
1417
+ this.sandBox?.activated();
1413
1418
  execAppScripts(this).finally(() => {
1414
1419
  this.state = "MOUNTED" /* MOUNTED */;
1415
1420
  const scriptInfo = this.source?.getScript(this.url);
@@ -1434,7 +1439,7 @@ var MicroInstanceModel = class {
1434
1439
  async start() {
1435
1440
  if (!this.source || ["ERROR" /* ERROR */, "UNSET" /* UNSET */].includes(this.status)) {
1436
1441
  this.source = new EntrySource(this.url);
1437
- await this.source.importEntery(this);
1442
+ await this.source.importEntry(this);
1438
1443
  }
1439
1444
  }
1440
1445
  unmount(needDestroy) {
@@ -1460,6 +1465,7 @@ var Script = class {
1460
1465
  async = false;
1461
1466
  code = "";
1462
1467
  defer = false;
1468
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1463
1469
  exportInstance;
1464
1470
  fromHtml;
1465
1471
  initial;
@@ -1478,39 +1484,41 @@ var Script = class {
1478
1484
  }
1479
1485
  /**
1480
1486
  * @param app 应用
1481
- * @param needRelaceScriptElement 是否需要替换script标签
1487
+ * @param needReplaceScriptElement 是否需要替换script标签
1482
1488
  * @returns 返回执行后的script标签或注释
1483
1489
  */
1484
- async excuteCode(app, needRelaceScriptElement = false) {
1490
+ async executeCode(app, needReplaceScriptElement = false) {
1485
1491
  try {
1486
1492
  if (!this.code) await this.getCode(app);
1487
1493
  if (app instanceof MicroInstanceModel) {
1488
- const golbalWindow = app.scopeJs ? app.sandBox?.proxyWindow || window : window;
1489
- noteGlobalProps(golbalWindow);
1494
+ const globalWindow = app.scopeJs ? app.sandBox?.proxyWindow || window : window;
1495
+ noteGlobalProps(globalWindow);
1490
1496
  }
1491
1497
  let scopedCode = this.code;
1492
1498
  scopedCode = this.transformCode(app);
1493
1499
  if (app.showSourceCode || this.isModule) {
1494
1500
  const scriptElement = document.createElement("script");
1495
- if (scriptElement.__BK_WEWEB_APP_KEY__) delete scriptElement.__BK_WEWEB_APP_KEY__;
1501
+ if (scriptElement.__BK_WEWEB_APP_KEY__) {
1502
+ scriptElement.__BK_WEWEB_APP_KEY__ = void 0;
1503
+ }
1496
1504
  app.registerRunningApp();
1497
1505
  this.executeSourceScript(scriptElement, scopedCode);
1498
- if (needRelaceScriptElement) return scriptElement;
1506
+ if (needReplaceScriptElement) return scriptElement;
1499
1507
  const needKeepAlive = !!app.keepAlive && !(app.container instanceof ShadowRoot);
1500
1508
  const container = needKeepAlive ? document.head : app.container;
1501
1509
  setMarkElement(scriptElement, app, needKeepAlive);
1502
1510
  container.appendChild(scriptElement);
1503
1511
  } else {
1504
1512
  this.executeMemoryScript(app, scopedCode);
1505
- if (needRelaceScriptElement) return document.createComment("\u3010bk-weweb\u3011dynamic script");
1513
+ if (needReplaceScriptElement) return document.createComment("\u3010bk-weweb\u3011dynamic script");
1506
1514
  }
1507
1515
  if (app instanceof MicroInstanceModel) {
1508
- const golbalWindow = app.scopeJs ? app.sandBox?.proxyWindow || window : window;
1509
- const exportProp = getGlobalProp(golbalWindow);
1516
+ const globalWindow = app.scopeJs ? app.sandBox?.proxyWindow || window : window;
1517
+ const exportProp = getGlobalProp(globalWindow);
1510
1518
  if (exportProp) {
1511
- this.exportInstance = golbalWindow[exportProp];
1519
+ this.exportInstance = globalWindow[exportProp];
1512
1520
  if (!app.scopeJs) {
1513
- delete golbalWindow[exportProp];
1521
+ delete globalWindow[exportProp];
1514
1522
  }
1515
1523
  }
1516
1524
  }
@@ -1536,7 +1544,7 @@ var Script = class {
1536
1544
  // 脚本标签执行
1537
1545
  executeSourceScript(scriptElement, scopedCode) {
1538
1546
  if (this.isModule) {
1539
- scriptElement.src = this.url + "?key=" + Date.now();
1547
+ scriptElement.src = `${this.url}?key=${Date.now()}`;
1540
1548
  scriptElement.setAttribute("type", "module");
1541
1549
  } else {
1542
1550
  scriptElement.textContent = scopedCode;
@@ -1570,23 +1578,27 @@ var Script = class {
1570
1578
  }
1571
1579
  // 转换脚本内容
1572
1580
  transformCode(app) {
1581
+ const sourceMapUrl = this.url ? `//# sourceURL=${this.url}
1582
+ ` : "";
1573
1583
  if (app.sandBox) {
1574
1584
  if (this.isModule) {
1575
1585
  return ` with(window.${app.sandBox.windowSymbolKey}){
1576
1586
  ;${this.code}
1577
1587
 
1588
+ ${sourceMapUrl}
1578
1589
  }`;
1579
1590
  }
1580
1591
  if (app.showSourceCode) {
1581
1592
  return `;(function(window, self, globalThis){
1582
- with(window){
1583
- ${getGlobalContextCode()}
1593
+ with(window){
1594
+ ${getGlobalContextCode()}
1584
1595
 
1585
- ${this.code}
1596
+ ${this.code}
1586
1597
 
1587
- }
1588
- }).call(window.${app.sandBox.windowSymbolKey},
1589
- window.${app.sandBox.windowSymbolKey}, window.${app.sandBox.windowSymbolKey}, window.${app.sandBox.windowSymbolKey});`;
1598
+ ${sourceMapUrl}
1599
+ }
1600
+ }).call(window.${app.sandBox.windowSymbolKey},
1601
+ window.${app.sandBox.windowSymbolKey}, window.${app.sandBox.windowSymbolKey}, window.${app.sandBox.windowSymbolKey});`;
1590
1602
  }
1591
1603
  return `
1592
1604
  with(window) {
@@ -1594,6 +1606,8 @@ var Script = class {
1594
1606
  ${getGlobalContextCode()}
1595
1607
 
1596
1608
  ${this.code}
1609
+
1610
+ ${sourceMapUrl}
1597
1611
  }
1598
1612
  catch(e) {
1599
1613
  console.error(e)
@@ -1605,7 +1619,10 @@ var Script = class {
1605
1619
  }
1606
1620
  };
1607
1621
  function shouldSkipProperty(global, p) {
1608
- return !global.hasOwnProperty(p) || !Number.isNaN(p) && p < global.length || typeof navigator !== "undefined" && navigator.userAgent.indexOf("Trident") !== -1 && global[p] && typeof window !== "undefined" && global[p].parent === window;
1622
+ return (
1623
+ // biome-ignore lint/suspicious/noPrototypeBuiltins: <explanation>
1624
+ !global.hasOwnProperty(p) || !Number.isNaN(p) && p < global.length || typeof navigator !== "undefined" && navigator.userAgent.indexOf("Trident") !== -1 && global[p] && typeof window !== "undefined" && global[p].parent === window
1625
+ );
1609
1626
  }
1610
1627
  function getGlobalProp(global, useFirstGlobalProp) {
1611
1628
  let cnt = 0;
@@ -1637,16 +1654,16 @@ function noteGlobalProps(global) {
1637
1654
  }
1638
1655
  async function execAppScripts(app) {
1639
1656
  const appScriptList = Array.from(app.source.scripts.values()).filter((script) => script.fromHtml || script.initial);
1640
- const commomList = appScriptList.filter((script) => !script.async && !script.defer || script.isModule);
1641
- await Promise.all(commomList.map((script) => script.getCode(app)));
1642
- await Promise.all(commomList.map((script) => script.excuteCode(app)));
1657
+ const commonList = appScriptList.filter((script) => !script.async && !script.defer || script.isModule);
1658
+ await Promise.all(commonList.map((script) => script.getCode(app)));
1659
+ await Promise.all(commonList.map((script) => script.executeCode(app)));
1643
1660
  const deferScriptList = [];
1644
1661
  const asyncScriptList = [];
1645
1662
  for (const script of appScriptList) {
1646
1663
  if (script.defer || script.async) {
1647
1664
  if (!script.code && script.defer) {
1648
- deferScriptList.push(script.excuteCode(app));
1649
- } else asyncScriptList.push(script.excuteCode(app));
1665
+ deferScriptList.push(script.executeCode(app));
1666
+ } else asyncScriptList.push(script.executeCode(app));
1650
1667
  }
1651
1668
  }
1652
1669
  await Promise.all([...asyncScriptList, ...deferScriptList]).catch((e) => {
@@ -1718,7 +1735,8 @@ var MicroAppModel = class {
1718
1735
  if (container && this.container) {
1719
1736
  if (container instanceof Element) container.setAttribute(CSS_ATTRIBUTE_KEY, this.name);
1720
1737
  const fragment = document.createDocumentFragment();
1721
- Array.from(this.container.childNodes).forEach((node) => {
1738
+ const list = Array.from(this.container.childNodes);
1739
+ for (const node of list) {
1722
1740
  node.__BK_WEWEB_APP_KEY__ = this.appCacheKey;
1723
1741
  Object.defineProperties(node, {
1724
1742
  ownerDocument: {
@@ -1728,12 +1746,12 @@ var MicroAppModel = class {
1728
1746
  }
1729
1747
  });
1730
1748
  fragment.appendChild(node);
1731
- });
1749
+ }
1732
1750
  container.innerHTML = "";
1733
1751
  container.appendChild(fragment);
1734
1752
  this.container = container;
1735
1753
  this.initShadowRootContainer();
1736
- this.sandBox?.activeated(this.data);
1754
+ this.sandBox?.activated(this.data);
1737
1755
  callback?.(this);
1738
1756
  }
1739
1757
  }
@@ -1788,7 +1806,7 @@ var MicroAppModel = class {
1788
1806
  if (this.container instanceof Element) this.container.setAttribute(CSS_ATTRIBUTE_KEY, this.name);
1789
1807
  const clonedNode = this.source.html.cloneNode(true);
1790
1808
  const fragment = document.createDocumentFragment();
1791
- Array.from(clonedNode.childNodes).forEach((node) => {
1809
+ for (const node of Array.from(clonedNode.childNodes)) {
1792
1810
  node.__BK_WEWEB_APP_KEY__ = this.appCacheKey;
1793
1811
  Object.defineProperties(node, {
1794
1812
  ownerDocument: {
@@ -1798,10 +1816,10 @@ var MicroAppModel = class {
1798
1816
  }
1799
1817
  });
1800
1818
  fragment.appendChild(node);
1801
- });
1819
+ }
1802
1820
  this.container.innerHTML = "";
1803
1821
  this.container.appendChild(fragment);
1804
- this.sandBox?.activeated(this.data);
1822
+ this.sandBox?.activated(this.data);
1805
1823
  execAppScripts(this).finally(() => {
1806
1824
  this.state = "MOUNTED" /* MOUNTED */;
1807
1825
  callback?.(this);
@@ -1828,7 +1846,7 @@ var MicroAppModel = class {
1828
1846
  this.iframe = iframe;
1829
1847
  }
1830
1848
  this.source = new EntrySource(this.url);
1831
- await this.source.importEntery(this);
1849
+ await this.source.importEntry(this);
1832
1850
  }
1833
1851
  }
1834
1852
  unmount(needDestroy = false) {
@@ -1946,7 +1964,7 @@ var EntrySource = class {
1946
1964
  url: nonceStr
1947
1965
  });
1948
1966
  this.scripts.set(nonceStr, scriptInstance);
1949
- replaceElement = document.createComment("\u3010bk-weweb\u3011script with texcontent");
1967
+ replaceElement = document.createComment("\u3010bk-weweb\u3011script with text content");
1950
1968
  !needReplaceELement && parent.replaceChild(replaceElement, script);
1951
1969
  return {
1952
1970
  replace: replaceElement,
@@ -1957,11 +1975,11 @@ var EntrySource = class {
1957
1975
  }
1958
1976
  collectScriptAndStyle(parent) {
1959
1977
  const links = Array.from(parent.querySelectorAll("link"));
1960
- links?.forEach((link) => {
1978
+ for (const link of links || []) {
1961
1979
  this.collectLink(link, link.parentElement);
1962
- });
1980
+ }
1963
1981
  const styles = Array.from(parent.querySelectorAll("style"));
1964
- styles?.forEach((style) => {
1982
+ for (const style of styles || []) {
1965
1983
  if (!style.hasAttribute("exclude") && !style.hasAttribute("ignore")) {
1966
1984
  this.styles.set(
1967
1985
  randomUrl(),
@@ -1973,21 +1991,21 @@ var EntrySource = class {
1973
1991
  );
1974
1992
  style.remove();
1975
1993
  }
1976
- });
1994
+ }
1977
1995
  const scripts = Array.from(parent.querySelectorAll("script"));
1978
- scripts?.forEach((script) => {
1996
+ for (const script of scripts) {
1979
1997
  this.collectScript(script, script.parentElement);
1980
- });
1998
+ }
1981
1999
  const metas = Array.from(parent.querySelectorAll("meta"));
1982
- metas?.forEach((meta) => {
2000
+ for (const meta of metas) {
1983
2001
  meta.parentElement.removeChild(meta);
1984
- });
2002
+ }
1985
2003
  const imgs = Array.from(parent.querySelectorAll("img"));
1986
- imgs?.forEach((img) => {
2004
+ for (const img of imgs) {
1987
2005
  if (img.hasAttribute("src")) {
1988
2006
  img.setAttribute("src", fillUpPath(img.getAttribute("src"), this.url));
1989
2007
  }
1990
- });
2008
+ }
1991
2009
  }
1992
2010
  getScript(url) {
1993
2011
  return this.scripts.get(url);
@@ -1995,7 +2013,7 @@ var EntrySource = class {
1995
2013
  getStyle(urlOrCode) {
1996
2014
  return this.styles.get(urlOrCode) || Array.from(this.styles.values()).find((style) => style.code === urlOrCode);
1997
2015
  }
1998
- async importEntery(app) {
2016
+ async importEntry(app) {
1999
2017
  if (app.initSource?.length) {
2000
2018
  const { collectScript, collectStyle } = await collectSource(app.initSource);
2001
2019
  if (collectScript) {
@@ -2013,7 +2031,7 @@ var EntrySource = class {
2013
2031
  if (!htmlStr) {
2014
2032
  htmlStr = await fetchSource(addUrlProtocol(this.url), { cache: "no-cache" }, app);
2015
2033
  if (!htmlStr) {
2016
- console.error("load app entry error, pleace check");
2034
+ console.error("load app entry error, place check");
2017
2035
  return Promise.reject();
2018
2036
  }
2019
2037
  }
@@ -2024,7 +2042,7 @@ var EntrySource = class {
2024
2042
  }
2025
2043
  wrapElement.innerHTML = htmlStr.replace(/<\/?head>/gim, "").replace(/<\/?body>/i, "");
2026
2044
  this.collectScriptAndStyle(wrapElement);
2027
- await excuteAppStyles(app, wrapElement);
2045
+ await executeAppStyles(app, wrapElement);
2028
2046
  this.html = wrapElement;
2029
2047
  }
2030
2048
  async importInstanceEntry(app) {
@@ -2033,7 +2051,7 @@ var EntrySource = class {
2033
2051
  jsStr = await fetchSource(this.url, { cache: "no-cache" }, app);
2034
2052
  }
2035
2053
  if (!jsStr) {
2036
- console.error("load app entry error, pleace check");
2054
+ console.error("load app entry error, place check");
2037
2055
  return Promise.reject();
2038
2056
  }
2039
2057
  this.scripts.set(