@netless/window-manager 1.0.13-test.19 → 1.0.13-test.20

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.mjs CHANGED
@@ -7782,7 +7782,6 @@ const setDefaultCameraBound = (view) => {
7782
7782
  minContentMode: () => 0.1
7783
7783
  });
7784
7784
  };
7785
- window.___local_log = window.___local_log || /* @__PURE__ */ new Set();
7786
7785
  class MainViewProxy {
7787
7786
  constructor(manager) {
7788
7787
  this.manager = manager;
@@ -19868,18 +19867,16 @@ const reconnectRefresher = new ReconnectRefresher({ emitter: internalEmitter });
19868
19867
  const _WindowManager = class extends InvisiblePlugin {
19869
19868
  constructor(context) {
19870
19869
  super(context);
19871
- this.version = "1.0.13-test.19";
19870
+ this.version = "1.0.13-test.20";
19872
19871
  this.dependencies = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.3.0", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.53" }, "devDependencies": { "@hyrious/dts": "^0.2.2", "@netless/app-docs-viewer": "^0.2.19", "@netless/app-media-player": "0.1.4", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "1.0.0-next.30", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "jspdf": "^2.5.1", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "side-effect-manager": "0.1.5", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.9.9", "vitest": "^0.14.1", "white-web-sdk": "^2.16.53" } };
19873
19872
  this.emitter = callbacks$1;
19874
19873
  this.viewMode = ViewMode.Broadcaster;
19875
19874
  this.isReplay = isPlayer(this.displayer);
19876
19875
  this._cursorUIDs = [];
19877
19876
  this.containerSizeRatio = _WindowManager.containerSizeRatio;
19878
- this.visibleStateListener = () => {
19879
- console.log("[window-manager] visibleStateListener isVisible:" + !document.hidden);
19880
- };
19881
19877
  this.onMainViewScenePathChangeHandler = (scenePath) => {
19882
19878
  const mainViewElement = this.mainView.divElement;
19879
+ this.logMainViewVisibilityDiagnostics("onMainViewScenePathChange", scenePath, mainViewElement);
19883
19880
  if (mainViewElement) {
19884
19881
  const backgroundImage = mainViewElement.querySelector(".background img");
19885
19882
  if (backgroundImage) {
@@ -19897,8 +19894,6 @@ const _WindowManager = class extends InvisiblePlugin {
19897
19894
  };
19898
19895
  _WindowManager.displayer = context.displayer;
19899
19896
  window.NETLESS_DEPS = { "dependencies": { "@juggle/resize-observer": "^3.3.1", "@netless/telebox-insider": "0.3.0", "emittery": "^0.9.2", "lodash": "^4.17.21", "p-retry": "^4.6.1", "uuid": "^7.0.3", "video.js": ">=7" }, "peerDependencies": { "jspdf": "2.5.1", "white-web-sdk": "^2.16.53" }, "devDependencies": { "@hyrious/dts": "^0.2.2", "@netless/app-docs-viewer": "^0.2.19", "@netless/app-media-player": "0.1.4", "@rollup/plugin-commonjs": "^20.0.0", "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@sveltejs/vite-plugin-svelte": "1.0.0-next.30", "@tsconfig/svelte": "^2.0.1", "@types/debug": "^4.1.7", "@types/lodash": "^4.14.182", "@types/lodash-es": "^4.17.4", "@types/uuid": "^8.3.1", "@typescript-eslint/eslint-plugin": "^4.30.0", "@typescript-eslint/parser": "^4.30.0", "@vitest/ui": "^0.14.1", "cypress": "^8.7.0", "dotenv": "^10.0.0", "eslint": "^7.32.0", "eslint-config-prettier": "^8.3.0", "eslint-plugin-svelte3": "^3.2.0", "jsdom": "^19.0.0", "jspdf": "^2.5.1", "less": "^4.1.1", "prettier": "^2.3.2", "prettier-plugin-svelte": "^2.4.0", "rollup-plugin-analyzer": "^4.0.0", "rollup-plugin-styles": "^3.14.1", "side-effect-manager": "0.1.5", "svelte": "^3.42.4", "typescript": "^4.5.5", "vite": "^2.9.9", "vitest": "^0.14.1", "white-web-sdk": "^2.16.53" } };
19900
- this.visibleStateListener();
19901
- document.addEventListener("visibilitychange", this.visibleStateListener);
19902
19897
  this.emitter.on("mainViewScenePathChange", this.onMainViewScenePathChangeHandler);
19903
19898
  }
19904
19899
  get Logger() {
@@ -20018,6 +20013,335 @@ const _WindowManager = class extends InvisiblePlugin {
20018
20013
  manager.emitter.on("mainViewScenePathChange", manager.onMainViewScenePathChangeHandler);
20019
20014
  return manager;
20020
20015
  }
20016
+ logMainViewVisibilityDiagnostics(tag, scenePath, mainViewElement) {
20017
+ var _a;
20018
+ const element2 = mainViewElement != null ? mainViewElement : (_a = this.mainView) == null ? void 0 : _a.divElement;
20019
+ const label = scenePath ? `${tag}:${scenePath}` : tag;
20020
+ const payload = this.collectMainViewVisibilityDiagnostics(element2, scenePath);
20021
+ this.emitMainViewVisibilityDiagnostic(label, payload.summary);
20022
+ if (payload.details) {
20023
+ this.emitMainViewVisibilityDiagnostic(`${label}:details`, payload.details);
20024
+ }
20025
+ }
20026
+ emitMainViewVisibilityDiagnostic(tag, payload) {
20027
+ var _a;
20028
+ const content = `[window-manager][visibility][${tag}] ${JSON.stringify(payload)}`;
20029
+ (_a = this._roomLogger) == null ? void 0 : _a.info(content);
20030
+ }
20031
+ collectMainViewVisibilityDiagnostics(mainViewElement, scenePath) {
20032
+ var _a, _b;
20033
+ const element2 = mainViewElement != null ? mainViewElement : null;
20034
+ const backgroundImage = element2 == null ? void 0 : element2.querySelector(".background img");
20035
+ const elementDiagnostic = element2 ? this.collectElementDiagnostic(element2) : null;
20036
+ const chainDiagnostics = element2 ? this.collectElementChainDiagnostics(element2) : [];
20037
+ const elementRect = (_b = (_a = element2 == null ? void 0 : element2.getBoundingClientRect) == null ? void 0 : _a.call(element2)) != null ? _b : null;
20038
+ const centerPoint = elementRect ? {
20039
+ x: elementRect.left + elementRect.width / 2,
20040
+ y: elementRect.top + elementRect.height / 2
20041
+ } : void 0;
20042
+ const topElement = centerPoint && Number.isFinite(centerPoint.x) && Number.isFinite(centerPoint.y) ? document.elementFromPoint(centerPoint.x, centerPoint.y) : null;
20043
+ const overlayStack = centerPoint && Number.isFinite(centerPoint.x) && Number.isFinite(centerPoint.y) && document.elementsFromPoint ? document.elementsFromPoint(centerPoint.x, centerPoint.y).slice(0, 10).map((item) => this.describeElement(item)).filter((item) => item !== null) : [];
20044
+ const topElementDiagnostic = topElement ? this.collectElementDiagnostic(topElement) : null;
20045
+ const backgroundImageDiagnostic = backgroundImage ? this.collectImageDiagnostic(backgroundImage) : null;
20046
+ const blockers = [];
20047
+ const warnings = [];
20048
+ const suspiciousAncestors = [];
20049
+ const mainViewBlockers = [];
20050
+ const mainViewWarnings = [];
20051
+ if (!element2) {
20052
+ blockers.push("mainViewElement.missing");
20053
+ }
20054
+ if (document.hidden || document.visibilityState === "hidden") {
20055
+ blockers.push("document.hidden");
20056
+ }
20057
+ if (elementDiagnostic) {
20058
+ this.appendRenderImpactIssues(
20059
+ "mainViewElement",
20060
+ elementDiagnostic,
20061
+ mainViewBlockers,
20062
+ mainViewWarnings
20063
+ );
20064
+ blockers.push(...mainViewBlockers);
20065
+ warnings.push(...mainViewWarnings);
20066
+ }
20067
+ chainDiagnostics.slice(1).forEach((diagnostic, index2) => {
20068
+ const ancestorBlockers = [];
20069
+ const ancestorWarnings = [];
20070
+ this.appendRenderImpactIssues(
20071
+ `ancestor[${index2 + 1}]`,
20072
+ diagnostic,
20073
+ ancestorBlockers,
20074
+ ancestorWarnings
20075
+ );
20076
+ if (ancestorBlockers.length > 0 || ancestorWarnings.length > 0) {
20077
+ blockers.push(...ancestorBlockers);
20078
+ warnings.push(...ancestorWarnings);
20079
+ suspiciousAncestors.push(this.pickRenderRelevantFields(diagnostic));
20080
+ }
20081
+ });
20082
+ let backgroundImageStatus = null;
20083
+ const backgroundImageBlockers = [];
20084
+ const backgroundImageWarnings = [];
20085
+ if (backgroundImageDiagnostic) {
20086
+ backgroundImageStatus = this.pickBackgroundImageStatus(backgroundImageDiagnostic);
20087
+ this.appendRenderImpactIssues(
20088
+ "backgroundImage",
20089
+ backgroundImageDiagnostic,
20090
+ backgroundImageBlockers,
20091
+ backgroundImageWarnings
20092
+ );
20093
+ blockers.push(...backgroundImageBlockers);
20094
+ warnings.push(...backgroundImageWarnings);
20095
+ if (backgroundImageDiagnostic.complete === false) {
20096
+ warnings.push("backgroundImage.loading");
20097
+ } else if (backgroundImageDiagnostic.naturalWidth === 0) {
20098
+ warnings.push("backgroundImage.empty");
20099
+ }
20100
+ }
20101
+ let topElementSummary = null;
20102
+ if (topElementDiagnostic) {
20103
+ const coveredByOutsideElement = Boolean(
20104
+ element2 && topElement && topElement !== element2 && !element2.contains(topElement)
20105
+ );
20106
+ topElementSummary = {
20107
+ node: topElementDiagnostic.node,
20108
+ coveredByOutsideElement
20109
+ };
20110
+ if (coveredByOutsideElement) {
20111
+ warnings.push(`center.coveredBy:${topElementDiagnostic.node}`);
20112
+ }
20113
+ }
20114
+ const summary = {
20115
+ scenePath: scenePath || null,
20116
+ timestamp: new Date().toISOString(),
20117
+ status: blockers.length > 0 ? "blocked" : warnings.length > 0 ? "uncertain" : "likely-renderable",
20118
+ canRender: blockers.length === 0,
20119
+ blockers,
20120
+ warnings
20121
+ };
20122
+ if (backgroundImageStatus && backgroundImageDiagnostic && (backgroundImageDiagnostic.complete === false || backgroundImageDiagnostic.naturalWidth === 0)) {
20123
+ summary.backgroundImage = backgroundImageStatus;
20124
+ }
20125
+ if (topElementSummary == null ? void 0 : topElementSummary.coveredByOutsideElement) {
20126
+ summary.coveringElement = topElementSummary.node;
20127
+ }
20128
+ const shouldEmitDetails = blockers.length > 0 || warnings.some(
20129
+ (warning) => warning !== "backgroundImage.loading" && warning !== "backgroundImage.empty"
20130
+ );
20131
+ const details = {};
20132
+ if ((mainViewBlockers.length > 0 || mainViewWarnings.length > 0) && elementDiagnostic) {
20133
+ details.mainViewElement = this.pickRenderRelevantFields(elementDiagnostic);
20134
+ }
20135
+ if (suspiciousAncestors.length > 0) {
20136
+ details.suspiciousAncestors = suspiciousAncestors;
20137
+ }
20138
+ if (backgroundImageDiagnostic && (backgroundImageBlockers.length > 0 || backgroundImageWarnings.length > 0 || backgroundImageDiagnostic.complete === false || backgroundImageDiagnostic.naturalWidth === 0)) {
20139
+ details.backgroundImage = {
20140
+ ...this.pickRenderRelevantFields(backgroundImageDiagnostic),
20141
+ loadState: backgroundImageStatus
20142
+ };
20143
+ }
20144
+ if ((topElementSummary == null ? void 0 : topElementSummary.coveredByOutsideElement) && topElementDiagnostic) {
20145
+ details.topElementAtCenter = {
20146
+ ...this.pickRenderRelevantFields(topElementDiagnostic),
20147
+ overlayStack
20148
+ };
20149
+ }
20150
+ return {
20151
+ summary,
20152
+ details: shouldEmitDetails && Object.keys(details).length > 0 ? details : null
20153
+ };
20154
+ }
20155
+ collectElementChainDiagnostics(element2) {
20156
+ const chain = [];
20157
+ let current = element2;
20158
+ while (current) {
20159
+ const diagnostic = this.collectElementDiagnostic(current);
20160
+ if (diagnostic) {
20161
+ chain.push(diagnostic);
20162
+ }
20163
+ current = current.parentElement;
20164
+ }
20165
+ return chain;
20166
+ }
20167
+ collectImageDiagnostic(image) {
20168
+ const diagnostic = this.collectElementDiagnostic(image);
20169
+ return {
20170
+ ...diagnostic,
20171
+ currentSrc: image.currentSrc,
20172
+ src: image.getAttribute("src"),
20173
+ complete: image.complete,
20174
+ naturalWidth: image.naturalWidth,
20175
+ naturalHeight: image.naturalHeight
20176
+ };
20177
+ }
20178
+ appendRenderImpactIssues(label, diagnostic, blockers, warnings) {
20179
+ const opacity = Number.parseFloat(diagnostic.opacity || "1");
20180
+ if (diagnostic.hiddenAttribute) {
20181
+ blockers.push(`${label}.hiddenAttribute`);
20182
+ }
20183
+ if (diagnostic.display === "none") {
20184
+ blockers.push(`${label}.display:none`);
20185
+ }
20186
+ if (diagnostic.visibility === "hidden" || diagnostic.visibility === "collapse") {
20187
+ blockers.push(`${label}.visibility:${diagnostic.visibility}`);
20188
+ }
20189
+ if (Number.isFinite(opacity) && opacity <= 0.01) {
20190
+ blockers.push(`${label}.opacity:${diagnostic.opacity}`);
20191
+ }
20192
+ if (diagnostic.contentVisibility === "hidden") {
20193
+ blockers.push(`${label}.contentVisibility:hidden`);
20194
+ }
20195
+ if (diagnostic.transform !== "none") {
20196
+ warnings.push(`${label}.transform`);
20197
+ }
20198
+ if (diagnostic.filter !== "none") {
20199
+ warnings.push(`${label}.filter`);
20200
+ }
20201
+ if (diagnostic.backdropFilter !== "none") {
20202
+ warnings.push(`${label}.backdropFilter`);
20203
+ }
20204
+ if (diagnostic.clipPath !== "none") {
20205
+ warnings.push(`${label}.clipPath`);
20206
+ }
20207
+ if (diagnostic.maskImage !== "none") {
20208
+ warnings.push(`${label}.maskImage`);
20209
+ }
20210
+ if (diagnostic.mixBlendMode !== "normal") {
20211
+ warnings.push(`${label}.mixBlendMode:${diagnostic.mixBlendMode}`);
20212
+ }
20213
+ }
20214
+ pickRenderRelevantFields(diagnostic) {
20215
+ var _a, _b, _c, _d, _e, _f;
20216
+ const result = {
20217
+ node: diagnostic.node,
20218
+ display: diagnostic.display,
20219
+ visibility: diagnostic.visibility,
20220
+ opacity: diagnostic.opacity,
20221
+ hiddenAttribute: diagnostic.hiddenAttribute,
20222
+ contentVisibility: diagnostic.contentVisibility,
20223
+ backgroundColor: diagnostic.backgroundColor,
20224
+ backgroundAlpha: (_b = (_a = diagnostic.backgroundColorChannels) == null ? void 0 : _a.a) != null ? _b : null,
20225
+ color: diagnostic.color,
20226
+ colorAlpha: (_d = (_c = diagnostic.colorChannels) == null ? void 0 : _c.a) != null ? _d : null,
20227
+ textFillColor: diagnostic.textFillColor,
20228
+ textFillAlpha: (_f = (_e = diagnostic.textFillColorChannels) == null ? void 0 : _e.a) != null ? _f : null
20229
+ };
20230
+ if (diagnostic.transform !== "none") {
20231
+ result.transform = diagnostic.transform;
20232
+ }
20233
+ if (diagnostic.filter !== "none") {
20234
+ result.filter = diagnostic.filter;
20235
+ }
20236
+ if (diagnostic.backdropFilter !== "none") {
20237
+ result.backdropFilter = diagnostic.backdropFilter;
20238
+ }
20239
+ if (diagnostic.mixBlendMode !== "normal") {
20240
+ result.mixBlendMode = diagnostic.mixBlendMode;
20241
+ }
20242
+ if (diagnostic.clipPath !== "none") {
20243
+ result.clipPath = diagnostic.clipPath;
20244
+ }
20245
+ if (diagnostic.maskImage !== "none") {
20246
+ result.maskImage = diagnostic.maskImage;
20247
+ }
20248
+ if (diagnostic.overflow !== "visible") {
20249
+ result.overflow = diagnostic.overflow;
20250
+ }
20251
+ if (diagnostic.zIndex !== "auto") {
20252
+ result.zIndex = diagnostic.zIndex;
20253
+ }
20254
+ return result;
20255
+ }
20256
+ pickBackgroundImageStatus(diagnostic) {
20257
+ return {
20258
+ found: true,
20259
+ complete: diagnostic.complete,
20260
+ currentSrc: diagnostic.currentSrc || diagnostic.src || "",
20261
+ naturalWidth: diagnostic.naturalWidth,
20262
+ naturalHeight: diagnostic.naturalHeight
20263
+ };
20264
+ }
20265
+ collectElementDiagnostic(element2) {
20266
+ if (!element2) {
20267
+ return null;
20268
+ }
20269
+ const style2 = window.getComputedStyle(element2);
20270
+ const htmlElement = element2;
20271
+ return {
20272
+ node: this.describeElement(element2),
20273
+ isConnected: element2.isConnected,
20274
+ hiddenAttribute: htmlElement.hidden,
20275
+ ariaHidden: htmlElement.getAttribute("aria-hidden"),
20276
+ opacity: style2.opacity,
20277
+ alpha: style2.opacity,
20278
+ display: style2.display,
20279
+ visibility: style2.visibility,
20280
+ backgroundColor: style2.backgroundColor,
20281
+ backgroundColorChannels: this.parseColorChannels(style2.backgroundColor),
20282
+ color: style2.color,
20283
+ colorChannels: this.parseColorChannels(style2.color),
20284
+ textFillColor: style2.getPropertyValue("-webkit-text-fill-color"),
20285
+ textFillColorChannels: this.parseColorChannels(
20286
+ style2.getPropertyValue("-webkit-text-fill-color")
20287
+ ),
20288
+ filter: style2.filter,
20289
+ backdropFilter: style2.getPropertyValue("backdrop-filter"),
20290
+ mixBlendMode: style2.mixBlendMode,
20291
+ transform: style2.transform,
20292
+ contentVisibility: style2.getPropertyValue("content-visibility"),
20293
+ clipPath: style2.clipPath,
20294
+ maskImage: style2.getPropertyValue("mask-image") || style2.getPropertyValue("-webkit-mask-image"),
20295
+ overflow: style2.overflow,
20296
+ zIndex: style2.zIndex
20297
+ };
20298
+ }
20299
+ describeElement(element2) {
20300
+ if (!element2) {
20301
+ return null;
20302
+ }
20303
+ const tagName = element2.tagName.toLowerCase();
20304
+ const id2 = element2.id ? `#${element2.id}` : "";
20305
+ const className = typeof element2.className === "string" && element2.className.trim() ? `.${element2.className.trim().replace(/\s+/g, ".")}` : "";
20306
+ return `${tagName}${id2}${className}`;
20307
+ }
20308
+ serializeRect(rect) {
20309
+ if (!rect) {
20310
+ return null;
20311
+ }
20312
+ return {
20313
+ x: rect.x,
20314
+ y: rect.y,
20315
+ width: rect.width,
20316
+ height: rect.height,
20317
+ top: rect.top,
20318
+ right: rect.right,
20319
+ bottom: rect.bottom,
20320
+ left: rect.left
20321
+ };
20322
+ }
20323
+ parseColorChannels(value) {
20324
+ const raw = (value == null ? void 0 : value.trim()) || "";
20325
+ if (!raw) {
20326
+ return { raw };
20327
+ }
20328
+ if (raw === "transparent") {
20329
+ return { raw, r: 0, g: 0, b: 0, a: 0 };
20330
+ }
20331
+ const matches = raw.match(/^rgba?\((.+)\)$/i);
20332
+ if (!matches) {
20333
+ return { raw };
20334
+ }
20335
+ const parts = matches[1].split(",").map((part) => part.trim());
20336
+ const [r2, g2, b2, a2] = parts.map((part) => Number(part));
20337
+ return {
20338
+ raw,
20339
+ r: Number.isFinite(r2) ? r2 : void 0,
20340
+ g: Number.isFinite(g2) ? g2 : void 0,
20341
+ b: Number.isFinite(b2) ? b2 : void 0,
20342
+ a: Number.isFinite(a2) ? a2 : raw.startsWith("rgb(") ? 1 : void 0
20343
+ };
20344
+ }
20021
20345
  static initManager(room) {
20022
20346
  return createInvisiblePlugin(room);
20023
20347
  }
@@ -20080,6 +20404,7 @@ const _WindowManager = class extends InvisiblePlugin {
20080
20404
  this.appManager.setBoxManager(boxManager);
20081
20405
  }
20082
20406
  this.bindMainView(mainViewElement, params.disableCameraTransform);
20407
+ this.logMainViewVisibilityDiagnostics("bindContainer.afterBindMainView");
20083
20408
  if (_WindowManager.wrapper) {
20084
20409
  (_a = this.cursorManager) == null ? void 0 : _a.setupWrapper(_WindowManager.wrapper);
20085
20410
  }
@@ -20576,7 +20901,6 @@ const _WindowManager = class extends InvisiblePlugin {
20576
20901
  (_e = _WindowManager.playground.parentNode) == null ? void 0 : _e.removeChild(_WindowManager.playground);
20577
20902
  }
20578
20903
  _WindowManager.params = void 0;
20579
- document.removeEventListener("visibilitychange", this.visibleStateListener);
20580
20904
  this.emitter.off("mainViewScenePathChange", this.onMainViewScenePathChangeHandler);
20581
20905
  (_f = this._iframeBridge) == null ? void 0 : _f.destroy();
20582
20906
  this._iframeBridge = void 0;