vis-core 0.22.15 → 0.23.1

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.22.15";
93
+ }, version = "0.23.1";
94
94
  /**
95
95
  * @license
96
96
  * Copyright 2010-2024 Three.js Authors
@@ -49361,15 +49361,14 @@ class History {
49361
49361
  const T = [...this.undos], de = T.length;
49362
49362
  let Xe = 0;
49363
49363
  const Ke = () => ei(this, null, function* () {
49364
- var Qe, _e, $e;
49365
49364
  const Je = performance.now();
49366
49365
  for (; T.length > 0 && performance.now() - Je < e; ) {
49367
49366
  if (this.editor._dispose) {
49368
49367
  r("dispose");
49369
49368
  return;
49370
49369
  }
49371
- const qe = T.shift(), st = (Qe = this.editor.hooks) != null && Qe.beforeExecuteUndo ? yield this.editor.hooks.beforeExecuteUndo(qe) : qe;
49372
- st && (yield this.executeUndo(st)), yield ($e = (_e = this.editor.hooks) == null ? void 0 : _e.afterExecuteUndo) == null ? void 0 : $e.call(_e, qe), Xe += 1;
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;
49373
49372
  }
49374
49373
  this.editor.emit("progress", {
49375
49374
  type: "还原场景",
@@ -49427,18 +49426,18 @@ class Viewport {
49427
49426
  }
49428
49427
  setVis(r) {
49429
49428
  return ei(this, arguments, function* (e, s = {}) {
49430
- var Xe, Ke;
49429
+ var Xe;
49431
49430
  if (!this.options.visFactories && (this.editor.setViewportVis(e), !this.options.visFactories)) {
49432
49431
  console.error("visFactories is not defined");
49433
49432
  return;
49434
49433
  }
49435
49434
  if (this.vis = this.options.visFactories, this.vis.visName !== e)
49436
49435
  throw new Error(`visName is not match, import {${e}}`);
49437
- const T = (Xe = this.editor.hooks) != null && Xe.beforeSetVisOptions ? this.editor.hooks.beforeSetVisOptions(s) : s;
49438
- this.vis.setOptions(ai(ai({}, T), this.extendsOptions)), this.delLoadObj && (this.vis.delLoadArr = this.delLoadObj), this.vis.playing = this.editor.playing, this.vis.on("loaderProgress", (Je, Qe) => {
49436
+ const T = this.editor.scripts.events.beforeSetVisOptions.length ? this.editor.scripts.dispatch("beforeSetVisOptions", s) : s;
49437
+ this.vis.setOptions(ai(ai({}, T), this.extendsOptions)), this.delLoadObj && (this.vis.delLoadArr = this.delLoadObj), this.vis.playing = this.editor.playing, this.vis.on("loaderProgress", (Ke, Je) => {
49439
49438
  this.editor.emit("progress", {
49440
49439
  type: "下载资源",
49441
- value: Je / Qe * 100 | 0
49440
+ value: Ke / Je * 100 | 0
49442
49441
  });
49443
49442
  }), this.vis.on("settingsChanged", () => {
49444
49443
  this.editor.emit("settingsChanged");
@@ -49446,7 +49445,7 @@ class Viewport {
49446
49445
  this.editor.emit("visShow");
49447
49446
  }), yield this.vis.init();
49448
49447
  const { pencil: de } = this.vis;
49449
- de.userData.EditorEnv = !this.editor.playing, this.editor.pencil = de, this.editor.changeSelectOption(), this.editor.playing || (this.initEvent(), this.editor.emit("visChanged", this.vis)), (Ke = this.vis) == null || Ke.pencil.event.on("object3dListChange", () => {
49448
+ de.userData.EditorEnv = !this.editor.playing, this.editor.pencil = de, this.editor.changeSelectOption(), this.editor.playing || (this.initEvent(), this.editor.emit("visChanged", this.vis)), (Xe = this.vis) == null || Xe.pencil.event.on("object3dListChange", () => {
49450
49449
  this.editor.changeSelectOption();
49451
49450
  });
49452
49451
  });
@@ -49602,17 +49601,13 @@ const compareVersion = (c, e) => {
49602
49601
  }
49603
49602
  compareVersion(c.c.version, "0.13.0") === -1 && c.h.u[0].visOptions.adcode === 0 && (c.h.u[0].visType = "world");
49604
49603
  }
49605
- if (compareVersion(c.c.version, "0.13.0") === -1 && c.h.u[0] && c.h.u[0].visType === "world" && (c.h.u[0].visType = "map", c.h.u[0].visOptions = {
49604
+ return compareVersion(c.c.version, "0.13.0") === -1 && c.h.u[0] && c.h.u[0].visType === "world" && (c.h.u[0].visType = "map", c.h.u[0].visOptions = {
49606
49605
  adcode: 0,
49607
49606
  mapDepth: 5,
49608
49607
  lineWidth: 2,
49609
49608
  worldPacificCentre: !0,
49610
49609
  extrudeLine: !1
49611
- }), c.h.u[0] && c.h.u[0].visType === "FJ" && (c.h.u[0].visType = "map2"), c.h.u[0] && c.h.u[0].visType === "map2") {
49612
- const { adcode: de } = c.h.u[0].visOptions;
49613
- de === 35e4 && (c.h.u[0].visOptions.drillDownHideParent = !0);
49614
- }
49615
- return compareVersion(c.c.version, "0.18.1") === -1 && c.h.u[0] && c.h.u[0].visType === "earth3" && (c.h.u[0].visType = "earth", c.h.u[0].visOptions.style = "countryPlate"), compareVersion(c.c.version, "0.18.14") === -1 && c.h.u[0] && c.h.u[0].visType === "map" && c.h.u.forEach((de) => {
49610
+ }), c.h.u[0] && c.h.u[0].visType === "FJ" && (c.h.u[0].visType = "map2"), compareVersion(c.c.version, "0.18.1") === -1 && c.h.u[0] && c.h.u[0].visType === "earth3" && (c.h.u[0].visType = "earth", c.h.u[0].visOptions.style = "countryPlate"), compareVersion(c.c.version, "0.18.14") === -1 && c.h.u[0] && c.h.u[0].visType === "map" && c.h.u.forEach((de) => {
49616
49611
  if (de.type === "SetSetting" && de.attributeName.startsWith("测试") && typeof de.newValue == "string" && de.newValue.includes(":::")) {
49617
49612
  const Xe = de.newValue.split(":::")[1];
49618
49613
  de.attributeName += ":::" + Xe, de.newValue = de.newValue.split(":::")[0], de.oldValue && typeof de.oldValue == "string" && (de.oldValue = de.oldValue.split(":::")[0]);
@@ -49622,8 +49617,55 @@ const compareVersion = (c, e) => {
49622
49617
  const Xe = de.attributeName.split(":::")[1];
49623
49618
  de.attributeName = de.attributeName.replace(Xe, `caId.${Xe}`);
49624
49619
  }
49625
- }), 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), c;
49626
- }, jsonFetch = (c, e, s = !1) => {
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
+ };
49622
+ class Scripts {
49623
+ constructor(e) {
49624
+ H0(this, "editor");
49625
+ H0(this, "events", {
49626
+ beforeSetVisOptions: [],
49627
+ beforeExecuteUndo: [],
49628
+ afterExecuteUndo: [],
49629
+ beforeShow: [],
49630
+ afterShow: []
49631
+ });
49632
+ H0(this, "source", "");
49633
+ this.editor = e;
49634
+ }
49635
+ add(e) {
49636
+ for (const s in e) {
49637
+ const r = s;
49638
+ this.events[r] && this.events[r].push(e[r].bind(e));
49639
+ }
49640
+ }
49641
+ fromJSON(e) {
49642
+ try {
49643
+ e = `
49644
+ return ${e}(vis);
49645
+ `;
49646
+ const s = new Function(e)();
49647
+ this.add(s), this.source = e;
49648
+ } catch (s) {
49649
+ console.error(s);
49650
+ }
49651
+ }
49652
+ toJSON() {
49653
+ return this.source;
49654
+ }
49655
+ clear() {
49656
+ Object.keys(this.events).forEach((e) => {
49657
+ this.events[e] = [];
49658
+ });
49659
+ }
49660
+ dispatch(e, ...s) {
49661
+ let r;
49662
+ for (const T of this.events[e])
49663
+ if (e === "beforeSetVisOptions" ? r = T(r != null ? r : s[0]) : r = T(this.editor.viewport.vis, ...s), r === !1)
49664
+ break;
49665
+ return r;
49666
+ }
49667
+ }
49668
+ const jsonFetch = (c, e, s = !1) => {
49627
49669
  const r = makePromiseCreator(!0), T = c.endsWith("gzip") || s;
49628
49670
  return window.fetch(c).then((de) => {
49629
49671
  let Xe = de;
@@ -49647,6 +49689,7 @@ class Editor {
49647
49689
  H0(this, "events", new EventEmitter());
49648
49690
  H0(this, "history");
49649
49691
  H0(this, "viewport");
49692
+ H0(this, "scripts");
49650
49693
  H0(this, "pencil");
49651
49694
  H0(this, "on", this.events.on.bind(this.events));
49652
49695
  H0(this, "emit", this.events.emit.bind(this.events));
@@ -49656,7 +49699,6 @@ class Editor {
49656
49699
  H0(this, "name");
49657
49700
  H0(this, "open", !1);
49658
49701
  H0(this, "options");
49659
- H0(this, "hooks");
49660
49702
  H0(this, "selectOption", []);
49661
49703
  H0(this, "selectOption2", []);
49662
49704
  H0(this, "checkSelectOption", throttle(
@@ -49675,7 +49717,7 @@ class Editor {
49675
49717
  processUndosMaxFrameTime: Number.MAX_VALUE
49676
49718
  }, e), this.events.setMaxListeners(9999999), this.viewport = new Viewport(this, {
49677
49719
  visFactories: e.visFactories
49678
- }), this.history = new History(this);
49720
+ }), this.history = new History(this), this.scripts = new Scripts(this);
49679
49721
  }
49680
49722
  getObjectMaterial(e, s) {
49681
49723
  if (!e)
@@ -49798,9 +49840,9 @@ class Editor {
49798
49840
  return ei(this, null, function* () {
49799
49841
  var r, T, de, Xe;
49800
49842
  try {
49801
- s && !n$1(s) && console.warn(
49843
+ s && !n$1(s) ? console.warn(
49802
49844
  "fromJSON 第二个参数已修改,{beforeSetVisOptions:(r)=>r} 替代"
49803
- ), this.hooks = s, window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49845
+ ) : s && this.scripts.add(s), window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49804
49846
  let Ke;
49805
49847
  if (typeof e == "string") {
49806
49848
  const Je = this.options.assetsPrefix + e, { res: Qe } = yield jsonFetch(Je);
@@ -49818,11 +49860,11 @@ class Editor {
49818
49860
  "vis-core 版本过低,可能会出现问题",
49819
49861
  "json:" + Ke.c.version,
49820
49862
  "sdk:" + this.sdkVersion
49821
- ), this.setConfig(Ke.c), this.history.fromJSON(Ke.h), this.viewport.fromJSON(Ke.v), yield this.history.processUndos(this.options.processUndosMaxFrameTime), (r = Ke.v.bg) != null && r.texture && this.viewport.vis) {
49863
+ ), this.setConfig(Ke.c), 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) {
49822
49864
  const Je = parseTexture(Ke.v.bg.texture);
49823
49865
  Je.colorSpace = SRGBColorSpace, this.viewport.vis.pencil.scene.background = Je;
49824
49866
  }
49825
- return (T = this.viewport.vis) == null || T.show(), (de = this.pencil.controls) == null || de.saveState(), this.select(null), console.timeEnd("vis-core:time.fromJSON"), window.postMessage({ type: "vis-core.fromJSON.end" }), (Xe = this.viewport.vis) != null && Xe.workerOnce && this.playing && window.requestIdleCallback(() => {
49867
+ 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), console.timeEnd("vis-core:time.fromJSON"), window.postMessage({ type: "vis-core.fromJSON.end" }), (Xe = this.viewport.vis) != null && Xe.workerOnce && this.playing && window.requestIdleCallback(() => {
49826
49868
  var Je;
49827
49869
  (Je = this.viewport.vis) == null || Je.worker.dispose();
49828
49870
  }), Ke;
@@ -49862,7 +49904,7 @@ class Editor {
49862
49904
  return this.pencil ? (this.pencil.render(), this.pencil.renderer.domElement.toDataURL()) : "";
49863
49905
  }
49864
49906
  dispose() {
49865
- this.events.removeAllListeners(), this.viewport.dispose(), this.history.clear(), this._dispose = !0;
49907
+ this.events.removeAllListeners(), this.viewport.dispose(), this.history.clear(), this.scripts.clear(), this._dispose = !0;
49866
49908
  }
49867
49909
  }
49868
49910
  const BLOCKLISTED_GPUS = [
@@ -132277,7 +132319,7 @@ class Map$1 extends Map$2 {
132277
132319
  polarAngle: 0.6690037180091797,
132278
132320
  mapDepth: [1, 0.3, 0.12],
132279
132321
  clickOusideBack: !0,
132280
- clickHandleDrillDown: !0,
132322
+ clickHandleDrillDown: !1,
132281
132323
  bottomPlane: !0,
132282
132324
  bottomPlaneWater: !1,
132283
132325
  parentBg: !0,
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "0.22.15";
1
+ declare const _default: "0.23.1";
2
2
  export default _default;
@@ -74,7 +74,7 @@ export default class Base extends Event {
74
74
  tier0: boolean;
75
75
  constructor(options: BaseOptions);
76
76
  setOptions(options: Record<string, any>): void;
77
- get fromJSON(): (jsonOrUrl: Record<string, any> | string, hooks?: import("../../editor").Hooks) => Promise<Record<string, any>>;
77
+ get fromJSON(): (jsonOrUrl: Record<string, any> | string, scripts?: Record<string, any>) => Promise<Record<string, any>>;
78
78
  get baseObjectByUuid(): {
79
79
  (uuid: `arc${string}`, flag?: boolean): Arc;
80
80
  (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.22.15",
3
+ "version": "0.23.1",
4
4
  "scripts": {
5
5
  "start": "npm run version && PORT=5173 bundler-dev",
6
6
  "build:site": "npm run version && bundler",