@blueking/bk-weweb 0.0.36-beta.20 → 0.0.36-beta.22

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 CHANGED
@@ -717,7 +717,6 @@ interface IInjectWindowAttrs {
717
717
  __BK_WEWEB_DATA__: Record<string, unknown>;
718
718
  /** 标识页面是否由BK WEWEB驱动 */
719
719
  __POWERED_BY_BK_WEWEB__: boolean;
720
- __BK_WEWEB_HAS_REWRITE__?: boolean;
721
720
  /** 原始 document 对象的引用 */
722
721
  rawDocument: Document;
723
722
  /** 原始 window 对象的引用 */
package/dist/index.esm.js CHANGED
@@ -241,9 +241,10 @@ var dispatchLinkOrScriptError = (element) => {
241
241
 
242
242
  // src/utils/fetch.ts
243
243
  var fetchSource = async (url, options = {}, app) => {
244
- if (typeof app?.fetchSource === "function") {
244
+ const runningApp = app || getCurrentRunningApp();
245
+ if (typeof runningApp?.fetchSource === "function") {
245
246
  try {
246
- return await app.fetchSource(url, options);
247
+ return await runningApp.fetchSource(url, options);
247
248
  } catch {
248
249
  return "";
249
250
  }
@@ -1275,7 +1276,8 @@ function createElementWithAppKey(rawDocument, app) {
1275
1276
  tagName,
1276
1277
  options
1277
1278
  );
1278
- element[APP_KEY_PROPERTY] = app.appCacheKey;
1279
+ const runningApp = getCurrentRunningApp();
1280
+ element[APP_KEY_PROPERTY] = runningApp?.appCacheKey || app.appCacheKey;
1279
1281
  if (element instanceof HTMLImageElement) {
1280
1282
  Object.defineProperty(element, "src", {
1281
1283
  get() {
@@ -1544,11 +1546,12 @@ var SandBox = class {
1544
1546
  const windowDescriptorSet = /* @__PURE__ */ new Set();
1545
1547
  const rawWindow = window;
1546
1548
  this.rawWindow = rawWindow;
1547
- this.rawDocument = createProxyDocument(document, app);
1549
+ const rawDocument = window.rawDocument || document;
1550
+ this.rawDocument = createProxyDocument(rawDocument, app);
1548
1551
  const fakeWindow = /* @__PURE__ */ Object.create({});
1549
1552
  fakeWindow.__BK_WEWEB_APP_KEY__ = app.appCacheKey;
1550
1553
  fakeWindow.__POWERED_BY_BK_WEWEB__ = true;
1551
- fakeWindow.rawDocument = document;
1554
+ fakeWindow.rawDocument = rawDocument;
1552
1555
  fakeWindow.rawWindow = rawWindow;
1553
1556
  fakeWindow.__proto__ = Window;
1554
1557
  this.fakeWindow = fakeWindow;
@@ -2446,9 +2449,20 @@ var AppCache = class {
2446
2449
  */
2447
2450
  getApp(name) {
2448
2451
  if (!name) return void 0;
2449
- const app = this.cache.get(name);
2452
+ let app = this.cache.get(name);
2450
2453
  if (app) return app;
2451
- return Array.from(this.cache.values()).find((item) => item.name === name);
2454
+ for (const item of Array.from(this.cache.values())) {
2455
+ if (item.name === name) {
2456
+ app = item;
2457
+ break;
2458
+ }
2459
+ const childApp = item?.sandBox?.proxyWindow?.__getAppOrInstance__()?.getApp(name);
2460
+ if (childApp) {
2461
+ app = childApp;
2462
+ break;
2463
+ }
2464
+ }
2465
+ return app;
2452
2466
  }
2453
2467
  /**
2454
2468
  * 删除缓存的应用实例