@blueking/bk-weweb 0.0.36-beta.19 → 0.0.36-beta.21

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
@@ -281,7 +281,7 @@ declare class SandBox {
281
281
  /** 代理的 window 对象 */
282
282
  readonly proxyWindow: WindowProxy & IInjectWindowAttrs;
283
283
  /** 原始 document 对象 */
284
- rawDocument: Record<string, any>;
284
+ rawDocument: Document;
285
285
  /** 原始 window 对象 */
286
286
  readonly rawWindow: Window;
287
287
  /** 在 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
  }
@@ -1271,7 +1272,10 @@ function createProxyBody(rawDocument, app) {
1271
1272
  }
1272
1273
  function createElementWithAppKey(rawDocument, app) {
1273
1274
  return function createElement(tagName, options) {
1274
- const element = rawDocument.createElement(tagName, options);
1275
+ const element = (window.rawDocument || rawDocument).createElement(
1276
+ tagName,
1277
+ options
1278
+ );
1275
1279
  element[APP_KEY_PROPERTY] = app.appCacheKey;
1276
1280
  if (element instanceof HTMLImageElement) {
1277
1281
  Object.defineProperty(element, "src", {
@@ -1541,12 +1545,11 @@ var SandBox = class {
1541
1545
  const windowDescriptorSet = /* @__PURE__ */ new Set();
1542
1546
  const rawWindow = window;
1543
1547
  this.rawWindow = rawWindow;
1544
- const rawDocument = window.rawDocument || document;
1545
- this.rawDocument = createProxyDocument(rawDocument, app);
1548
+ this.rawDocument = createProxyDocument(document, app);
1546
1549
  const fakeWindow = /* @__PURE__ */ Object.create({});
1547
1550
  fakeWindow.__BK_WEWEB_APP_KEY__ = app.appCacheKey;
1548
1551
  fakeWindow.__POWERED_BY_BK_WEWEB__ = true;
1549
- fakeWindow.rawDocument = rawDocument;
1552
+ fakeWindow.rawDocument = document;
1550
1553
  fakeWindow.rawWindow = rawWindow;
1551
1554
  fakeWindow.__proto__ = Window;
1552
1555
  this.fakeWindow = fakeWindow;