vis-core 0.23.3 → 0.23.4

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.
@@ -90,7 +90,7 @@ const publicKeyPEM = "LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRz
90
90
  ).toString(CryptoJS.enc.Utf8), qe = JSON.parse($e), st = Date.now();
91
91
  return !qe.s || qe.s > st ? (this.token = void 0, "") : qe.e && qe.e < st ? (this.token = void 0, "") : (qe.isValid = Qe, qe);
92
92
  }
93
- }, version = "0.23.3";
93
+ }, version = "0.23.4";
94
94
  /**
95
95
  * @license
96
96
  * Copyright 2010-2024 Three.js Authors
@@ -49367,8 +49367,8 @@ class History {
49367
49367
  r("dispose");
49368
49368
  return;
49369
49369
  }
49370
- const Qe = T.shift(), _e = this.editor.scripts.events.beforeExecuteUndo.length ? this.editor.scripts.dispatch("beforeExecuteUndo", Qe) : Qe;
49371
- _e && (yield this.executeUndo(_e)), this.editor.scripts.events.afterExecuteUndo.length && this.editor.scripts.dispatch("afterExecuteUndo", Qe), Xe += 1;
49370
+ const Qe = T.shift(), _e = this.editor.hooks.events.beforeExecuteUndo.length ? this.editor.hooks.dispatch("beforeExecuteUndo", Qe) : Qe;
49371
+ _e && (yield this.executeUndo(_e)), this.editor.hooks.events.afterExecuteUndo.length && this.editor.hooks.dispatch("afterExecuteUndo", Qe), Xe += 1;
49372
49372
  }
49373
49373
  this.editor.emit("progress", {
49374
49374
  type: "还原场景",
@@ -49433,7 +49433,7 @@ class Viewport {
49433
49433
  }
49434
49434
  if (this.vis = this.options.visFactories, this.vis.visName !== e)
49435
49435
  throw new Error(`visName is not match, import {${e}}`);
49436
- const T = this.editor.scripts.events.beforeSetVisOptions.length ? this.editor.scripts.dispatch("beforeSetVisOptions", s) : s;
49436
+ const T = this.editor.hooks.events.beforeSetVisOptions.length ? this.editor.hooks.dispatch("beforeSetVisOptions", s) : s;
49437
49437
  this.vis.setOptions(ai(ai({}, T), this.extendsOptions)), this.delLoadObj && (this.vis.delLoadArr = this.delLoadObj), this.vis.playing = this.editor.playing, this.vis._baseObjectByUuid = this.editor.baseObjectByUuid.bind(this.editor), this.vis.on("loaderProgress", (Ke, Je) => {
49438
49438
  this.editor.emit("progress", {
49439
49439
  type: "下载资源",
@@ -49619,7 +49619,7 @@ const compareVersion = (c, e) => {
49619
49619
  }
49620
49620
  }), compareVersion(c.c.version, "0.21.24") === -1 && c.h.u[0] && c.h.u[0].visType === "map" && (T = (r = c.v) == null ? void 0 : r.eo) != null && T.parentBgCurvatureResolution && (delete c.v.eo.parentBgCurvatureResolution, c.v.eo.parentBgTopSegments = 400), compareVersion(c.c.version, "0.23.1") === -1 && c.h.u[0] && c.h.u[0].visType === "map2" && !c.h.u[0].visOptions.cityOnMap && (c.h.u[0].visOptions.clickHandleDrillDown = !0), c;
49621
49621
  };
49622
- class Scripts {
49622
+ class Hooks {
49623
49623
  constructor(e) {
49624
49624
  H0(this, "editor");
49625
49625
  H0(this, "events", {
@@ -49657,12 +49657,13 @@ class Scripts {
49657
49657
  this.source !== s && (this.source = s, this.editor.emit("scriptsChanged"));
49658
49658
  }
49659
49659
  fromJSON(e) {
49660
- try {
49661
- const s = new Function(`return ${e}()`)();
49662
- this.addEvents(s), this.source = e;
49663
- } catch (s) {
49664
- console.error(s);
49665
- }
49660
+ if (e)
49661
+ try {
49662
+ const s = new Function(`return ${e}()`)();
49663
+ this.addEvents(s), this.source = e;
49664
+ } catch (s) {
49665
+ console.error(s);
49666
+ }
49666
49667
  }
49667
49668
  toJSON() {
49668
49669
  return this.source;
@@ -49738,7 +49739,7 @@ class Editor {
49738
49739
  H0(this, "events", new EventEmitter());
49739
49740
  H0(this, "history");
49740
49741
  H0(this, "viewport");
49741
- H0(this, "scripts");
49742
+ H0(this, "hooks");
49742
49743
  H0(this, "config");
49743
49744
  H0(this, "pencil");
49744
49745
  H0(this, "on", this.events.on.bind(this.events));
@@ -49762,7 +49763,7 @@ class Editor {
49762
49763
  processUndosMaxFrameTime: Number.MAX_VALUE
49763
49764
  }, e), this.events.setMaxListeners(9999999), this.viewport = new Viewport(this, {
49764
49765
  visFactories: e.visFactories
49765
- }), this.history = new History(this), this.scripts = new Scripts(this), this.config = new Config(this), this.config.setConfig("sdkVersion", version);
49766
+ }), this.history = new History(this), this.hooks = new Hooks(this), this.config = new Config(this), this.config.setConfig("sdkVersion", version);
49766
49767
  }
49767
49768
  getObjectMaterial(e, s) {
49768
49769
  if (!e)
@@ -49887,30 +49888,34 @@ class Editor {
49887
49888
  try {
49888
49889
  s && !n$1(s) ? console.warn(
49889
49890
  "fromJSON 第二个参数已修改,{beforeSetVisOptions:(r)=>r} 替代"
49890
- ) : s && this.scripts.addEvents(s), this.scripts.dispatch("beforeFromJSON");
49891
+ ) : s && this.hooks.addEvents(s);
49891
49892
  let Ke;
49892
49893
  if (typeof e == "string") {
49893
- const Je = this.options.assetsPrefix + e, { res: Qe } = yield jsonFetch(Je);
49894
+ const Je = this.options.assetsPrefix + e;
49895
+ console.time("vis-core:time.json-fetch");
49896
+ const { res: Qe, err: _e } = yield jsonFetch(Je);
49897
+ if (console.timeEnd("vis-core:time.json-fetch"), _e)
49898
+ throw new Error("fromJSON error:" + _e);
49894
49899
  Ke = Qe;
49895
49900
  } else
49896
49901
  Ke = e;
49897
- if (Ke = fixJSON(Ke), Ke.at && (accessToken.token = Ke.at), !this.storage) {
49902
+ if (this.hooks.dispatch("beforeFromJSON"), Ke = fixJSON(Ke), Ke.at && (accessToken.token = Ke.at), !this.storage) {
49898
49903
  if (!accessToken.token)
49899
49904
  throw new Error("设置 token 或平台重新下载 JSON 文件");
49900
49905
  const Je = accessToken.getInfo();
49901
49906
  if (!Je || !Je.isValid)
49902
49907
  throw new Error("need accessToken");
49903
49908
  }
49904
- if (this.config.fromJSON(Ke.c), this.config.compareVersion(), this.history.fromJSON(Ke.h), this.viewport.fromJSON(Ke.v), Ke.s && this.scripts.fromJSON(Ke.s), yield this.history.processUndos(this.options.processUndosMaxFrameTime), (r = Ke.v.bg) != null && r.texture && this.viewport.vis) {
49909
+ if (this.config.fromJSON(Ke.c), this.history.fromJSON(Ke.h), this.viewport.fromJSON(Ke.v), this.hooks.fromJSON(Ke.s), this.config.compareVersion(), yield this.history.processUndos(this.options.processUndosMaxFrameTime), (r = Ke.v.bg) != null && r.texture && this.viewport.vis) {
49905
49910
  const Je = parseTexture(Ke.v.bg.texture);
49906
49911
  Je.colorSpace = SRGBColorSpace, this.viewport.vis.pencil.scene.background = Je;
49907
49912
  }
49908
- return this.scripts.dispatch("beforeShow"), (T = this.viewport.vis) == null || T.show(), this.scripts.dispatch("afterShow"), (de = this.pencil.controls) == null || de.saveState(), this.select(null), (Xe = this.viewport.vis) != null && Xe.workerOnce && this.playing && window.requestIdleCallback(() => {
49913
+ return this.hooks.dispatch("beforeShow"), (T = this.viewport.vis) == null || T.show(), this.hooks.dispatch("afterShow"), (de = this.pencil.controls) == null || de.saveState(), this.select(null), (Xe = this.viewport.vis) != null && Xe.workerOnce && this.playing && window.requestIdleCallback(() => {
49909
49914
  var Je;
49910
49915
  (Je = this.viewport.vis) == null || Je.worker.dispose();
49911
- }), this.scripts.dispatch("afterFromJSON"), Ke;
49916
+ }), this.hooks.dispatch("afterFromJSON"), Ke;
49912
49917
  } catch (Ke) {
49913
- throw this.scripts.dispatch("errorFromJSON"), new Error("fromJSON error:" + Ke);
49918
+ throw this.hooks.dispatch("errorFromJSON"), new Error("fromJSON error:" + Ke);
49914
49919
  }
49915
49920
  });
49916
49921
  }
@@ -49927,7 +49932,7 @@ class Editor {
49927
49932
  return this.pencil ? (this.pencil.render(), this.pencil.renderer.domElement.toDataURL()) : "";
49928
49933
  }
49929
49934
  dispose() {
49930
- this.events.removeAllListeners(), this.viewport.dispose(), this.history.clear(), this.scripts.clear(), this._dispose = !0;
49935
+ this.events.removeAllListeners(), this.viewport.dispose(), this.history.clear(), this.hooks.clear(), this._dispose = !0;
49931
49936
  }
49932
49937
  }
49933
49938
  const BLOCKLISTED_GPUS = [
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "0.23.3";
1
+ declare const _default: "0.23.4";
2
2
  export default _default;
@@ -75,7 +75,7 @@ export default class Base extends Event {
75
75
  constructor(options: BaseOptions);
76
76
  setOptions(options: Record<string, any>): void;
77
77
  _baseObjectByUuid: Editor['baseObjectByUuid'];
78
- get fromJSON(): (jsonOrUrl: Record<string, any> | string, scripts?: Record<string, any>) => Promise<Record<string, any>>;
78
+ get fromJSON(): (jsonOrUrl: Record<string, any> | string, hooks?: Record<string, any>) => Promise<Record<string, any>>;
79
79
  get baseObjectByUuid(): {
80
80
  (uuid: `arc${string}`, flag?: boolean): Arc;
81
81
  (uuid: `sprite${string}`, flag?: boolean): import("../all/objects/Sprite").default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vis-core",
3
- "version": "0.23.3",
3
+ "version": "0.23.4",
4
4
  "scripts": {
5
5
  "start": "npm run version && PORT=5173 bundler-dev",
6
6
  "build:site": "npm run version && bundler",