@tmagic/stage 1.0.0-rc.11 → 1.0.0-rc.12

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.
@@ -79,11 +79,6 @@ const isSameDomain = (targetUrl = "", source = globalThis.location.host) => {
79
79
  return true;
80
80
  return getHost(targetUrl) === source;
81
81
  };
82
- const isAbsolute = (el) => {
83
- if (!el)
84
- return false;
85
- return getComputedStyle(el).position === "absolute";
86
- };
87
82
  const isRelative = (el) => {
88
83
  if (!el)
89
84
  return false;
@@ -124,15 +119,15 @@ const getMode = (el) => {
124
119
  };
125
120
  const getScrollParent = (element, includeHidden = false) => {
126
121
  let style = getComputedStyle(element);
122
+ const excludeStaticParent = style.position === "absolute";
127
123
  const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/;
128
- if (isFixed(element))
124
+ if (style.position === "fixed")
129
125
  return null;
130
126
  for (let parent = element; parent.parentElement; ) {
131
127
  parent = parent.parentElement;
132
128
  style = getComputedStyle(parent);
133
- if (isAbsolute(element) && isStatic(element)) {
129
+ if (excludeStaticParent && style.position === "static")
134
130
  continue;
135
- }
136
131
  if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX))
137
132
  return parent;
138
133
  }
@@ -215,7 +210,7 @@ class StageDragResize extends EventEmitter {
215
210
  if (!this.moveable)
216
211
  throw new Error("\u672A\u521D\u59CB\u5316moveable");
217
212
  if (!el)
218
- throw new Error("\u4E3A\u9009\u4E2D\u4EFB\u4F55\u8282\u70B9");
213
+ throw new Error("\u672A\u9009\u4E2D\u4EFB\u4F55\u8282\u70B9");
219
214
  this.target = el;
220
215
  this.init(el);
221
216
  Object.entries(this.moveableOptions).forEach(([key, value]) => {
@@ -290,7 +285,7 @@ class StageDragResize extends EventEmitter {
290
285
  }
291
286
  bindResizeEvent() {
292
287
  if (!this.moveable)
293
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
288
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
294
289
  const frame = {
295
290
  left: 0,
296
291
  top: 0
@@ -324,7 +319,7 @@ class StageDragResize extends EventEmitter {
324
319
  }
325
320
  bindDragEvent() {
326
321
  if (!this.moveable)
327
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
322
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
328
323
  const frame = {
329
324
  left: 0,
330
325
  top: 0
@@ -366,7 +361,7 @@ class StageDragResize extends EventEmitter {
366
361
  }
367
362
  bindRotateEvent() {
368
363
  if (!this.moveable)
369
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
364
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
370
365
  this.moveable.on("rotateStart", (e) => {
371
366
  this.dragStatus = "start" /* START */;
372
367
  this.moveableHelper?.onRotateStart(e);
@@ -390,7 +385,7 @@ class StageDragResize extends EventEmitter {
390
385
  }
391
386
  bindScaleEvent() {
392
387
  if (!this.moveable)
393
- throw new Error("moveable \u4E3A\u521D\u59CB\u5316");
388
+ throw new Error("moveable \u672A\u521D\u59CB\u5316");
394
389
  this.moveable.on("scaleStart", (e) => {
395
390
  this.dragStatus = "start" /* START */;
396
391
  this.moveableHelper?.onScaleStart(e);
@@ -1077,6 +1072,9 @@ class StageRender extends EventEmitter {
1077
1072
  }
1078
1073
  }
1079
1074
  this.emit("onload");
1075
+ this.contentWindow.postMessage({
1076
+ tmagicRuntimeReady: true
1077
+ }, "*");
1080
1078
  };
1081
1079
  this.core = core;
1082
1080
  this.runtimeUrl = core.config.runtimeUrl || "";
@@ -1243,10 +1241,10 @@ class StageCore extends EventEmitter {
1243
1241
  setZoom(zoom = DEFAULT_ZOOM) {
1244
1242
  this.zoom = zoom;
1245
1243
  }
1246
- mount(el) {
1244
+ async mount(el) {
1247
1245
  this.container = el;
1248
1246
  const { mask, renderer } = this;
1249
- renderer.mount(el);
1247
+ await renderer.mount(el);
1250
1248
  mask.mount(el);
1251
1249
  this.emit("mounted");
1252
1250
  }