@blueking/bk-weweb 0.0.35-beta.7 → 0.0.35-beta.9

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.esm.js CHANGED
@@ -1538,7 +1538,7 @@ var Script = class {
1538
1538
  scoped;
1539
1539
  url;
1540
1540
  constructor({ async, code, defer, fromHtml, initial, isModule, url }) {
1541
- this.code = code;
1541
+ this.code = code?.replace(STRICT_MODE_REGEX, "");
1542
1542
  this.async = async;
1543
1543
  this.defer = defer;
1544
1544
  this.isModule = isModule;
@@ -1574,11 +1574,15 @@ var Script = class {
1574
1574
  }
1575
1575
  if (app instanceof MicroInstanceModel) {
1576
1576
  const globalWindow = app.scopeJs ? app.sandBox?.proxyWindow || window : window;
1577
- const exportProp = getGlobalProp(globalWindow);
1577
+ const isIifeVar = !!this.code.replace(/\/\*[\s\S]*?\*\//g, "").match(/^\s*var\s/);
1578
+ const exportProp = getGlobalProp(globalWindow, isIifeVar);
1578
1579
  if (exportProp) {
1579
1580
  this.exportInstance = globalWindow[exportProp];
1580
1581
  if (!app.scopeJs) {
1581
- delete globalWindow[exportProp];
1582
+ const descriptor = Object.getOwnPropertyDescriptor(globalWindow, exportProp);
1583
+ if (descriptor?.configurable) {
1584
+ delete globalWindow[exportProp];
1585
+ }
1582
1586
  }
1583
1587
  }
1584
1588
  }
@@ -1593,7 +1597,7 @@ var Script = class {
1593
1597
  const isScopedLocation = app instanceof MicroAppModel && app.scopeLocation;
1594
1598
  app.registerRunningApp();
1595
1599
  new Function("window", "location", "history", scopedCode)(
1596
- app.sandBox.proxyWindow,
1600
+ app.sandBox.proxyWindow || window,
1597
1601
  isScopedLocation ? app.iframe.contentWindow.location : window.location,
1598
1602
  isScopedLocation ? app.iframe.contentWindow.history : window.history
1599
1603
  );
@@ -2785,7 +2789,7 @@ async function loadApp(props) {
2785
2789
  instance = new MicroAppModel(props);
2786
2790
  appCache.setApp(instance);
2787
2791
  } else {
2788
- instance.data = props.data || {};
2792
+ instance.data = props.data || instance.data || {};
2789
2793
  }
2790
2794
  await instance.start();
2791
2795
  return instance;
@@ -2809,6 +2813,7 @@ function loadInstance(props) {
2809
2813
  }, STATUS_CHECK_INTERVAL);
2810
2814
  return;
2811
2815
  }
2816
+ instance.data = props.data || instance.data || {};
2812
2817
  resolve(instance);
2813
2818
  });
2814
2819
  }