vis-core 0.22.11 → 0.22.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.
@@ -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.11";
93
+ }, version = "0.22.12";
94
94
  /**
95
95
  * @license
96
96
  * Copyright 2010-2024 Three.js Authors
@@ -49327,27 +49327,27 @@ class History {
49327
49327
  }
49328
49328
  return e;
49329
49329
  }
49330
- fromJSON(e, s) {
49331
- var de;
49330
+ fromJSON(e) {
49331
+ var T;
49332
49332
  if (e === void 0) return;
49333
- let r = -1;
49334
- const T = e.i;
49335
- for (let Xe = 0; Xe < e.u.length; Xe++) {
49336
- const Ke = e.u[Xe];
49337
- if (T != null && T.length && ((de = Ke.newMap) != null && de.images) && Ke.newMap.images.forEach((Qe) => {
49338
- if (Qe.url.startsWith("$rp-")) {
49339
- const _e = parseInt(Qe.url.replace("$rp-", ""));
49340
- Qe.url = T[_e];
49333
+ let s = -1;
49334
+ const r = e.i;
49335
+ for (let de = 0; de < e.u.length; de++) {
49336
+ const Xe = e.u[de];
49337
+ if (r != null && r.length && ((T = Xe.newMap) != null && T.images) && Xe.newMap.images.forEach((Je) => {
49338
+ if (Je.url.startsWith("$rp-")) {
49339
+ const Qe = parseInt(Je.url.replace("$rp-", ""));
49340
+ Je.url = r[Qe];
49341
49341
  }
49342
- }), Ke.id <= r) {
49342
+ }), Xe.id <= s) {
49343
49343
  console.error("历史记录id错误");
49344
49344
  continue;
49345
49345
  }
49346
- if (Ke.id === 1 && Ke.visOptions && s && (Ke.visOptions = s(Ke.visOptions)), Ke.type === "SetOption" || !Ke.type)
49346
+ if (Xe.type === "SetOption" || !Xe.type)
49347
49347
  continue;
49348
- Ke.type.endsWith("Command") && (Ke.type = Ke.type.replace("Command", ""));
49349
- const Je = new Commands[Ke.type](this.editor);
49350
- Je.json = Ke, Je.id = Ke.id, Je.name = Ke.name, this.undos.push(Je), this.idCounter = Ke.id > this.idCounter ? Ke.id : this.idCounter, r = Ke.id;
49348
+ Xe.type.endsWith("Command") && (Xe.type = Xe.type.replace("Command", ""));
49349
+ const Ke = new Commands[Xe.type](this.editor);
49350
+ Ke.json = Xe, Ke.id = Xe.id, Ke.name = Xe.name, this.undos.push(Ke), this.idCounter = Xe.id > this.idCounter ? Xe.id : this.idCounter, s = Xe.id;
49351
49351
  }
49352
49352
  this.editor.emit("historyChanged", this.undos[this.undos.length - 1]);
49353
49353
  }
@@ -49356,14 +49356,15 @@ class History {
49356
49356
  const T = [...this.undos], de = T.length;
49357
49357
  let Xe = 0;
49358
49358
  const Ke = () => ei(this, null, function* () {
49359
+ var Qe, _e, $e;
49359
49360
  const Je = performance.now();
49360
49361
  for (; T.length > 0 && performance.now() - Je < e; ) {
49361
49362
  if (this.editor._dispose) {
49362
49363
  r("dispose");
49363
49364
  return;
49364
49365
  }
49365
- const Qe = T.shift();
49366
- yield this.executeUndo(Qe), yield this.editor.injectionModification(Qe, T), Xe += 1;
49366
+ const qe = T.shift(), st = (Qe = this.editor.hooks) != null && Qe.beforeExecuteUndo ? yield this.editor.hooks.beforeExecuteUndo(qe) : qe;
49367
+ 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;
49367
49368
  }
49368
49369
  this.editor.emit("progress", {
49369
49370
  type: "还原场景",
@@ -49421,25 +49422,26 @@ class Viewport {
49421
49422
  }
49422
49423
  setVis(r) {
49423
49424
  return ei(this, arguments, function* (e, s = {}) {
49424
- var de;
49425
+ var Xe, Ke;
49425
49426
  if (!this.options.visFactories && (this.editor.setViewportVis(e), !this.options.visFactories)) {
49426
49427
  console.error("visFactories is not defined");
49427
49428
  return;
49428
49429
  }
49429
49430
  if (this.vis = this.options.visFactories, this.vis.visName !== e)
49430
49431
  throw new Error(`visName is not match, import {${e}}`);
49431
- this.vis.setOptions(ai(ai({}, s), this.extendsOptions)), this.delLoadObj && (this.vis.delLoadArr = this.delLoadObj), this.vis.playing = this.editor.playing, this.vis.on("loaderProgress", (Xe, Ke) => {
49432
+ const T = (Xe = this.editor.hooks) != null && Xe.beforeSetVisOptions ? this.editor.hooks.beforeSetVisOptions(s) : s;
49433
+ 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) => {
49432
49434
  this.editor.emit("progress", {
49433
49435
  type: "下载资源",
49434
- value: Xe / Ke * 100 | 0
49436
+ value: Je / Qe * 100 | 0
49435
49437
  });
49436
49438
  }), this.vis.on("settingsChanged", () => {
49437
49439
  this.editor.emit("settingsChanged");
49438
49440
  }), this.vis.on("show", () => {
49439
49441
  this.editor.emit("visShow");
49440
49442
  }), yield this.vis.init();
49441
- const { pencil: T } = this.vis;
49442
- T.userData.EditorEnv = !this.editor.playing, this.editor.pencil = T, this.editor.changeSelectOption(), this.editor.playing || (this.initEvent(), this.editor.emit("visChanged", this.vis)), (de = this.vis) == null || de.pencil.event.on("object3dListChange", () => {
49443
+ const { pencil: de } = this.vis;
49444
+ 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", () => {
49443
49445
  this.editor.changeSelectOption();
49444
49446
  });
49445
49447
  });
@@ -49649,6 +49651,7 @@ class Editor {
49649
49651
  H0(this, "name");
49650
49652
  H0(this, "open", !1);
49651
49653
  H0(this, "options");
49654
+ H0(this, "hooks");
49652
49655
  H0(this, "selectOption", []);
49653
49656
  H0(this, "selectOption2", []);
49654
49657
  H0(this, "checkSelectOption", throttle(
@@ -49790,7 +49793,9 @@ class Editor {
49790
49793
  return ei(this, null, function* () {
49791
49794
  var r, T, de, Xe;
49792
49795
  try {
49793
- window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49796
+ s && !n$1(s) && console.warn(
49797
+ "fromJSON 第二个参数已修改,{beforeSetVisOptions:(r)=>r} 替代"
49798
+ ), this.hooks = s, window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49794
49799
  let Ke;
49795
49800
  if (typeof e == "string") {
49796
49801
  const Je = this.options.assetsPrefix + e, { res: Qe } = yield jsonFetch(Je);
@@ -49808,7 +49813,7 @@ class Editor {
49808
49813
  "vis-core 版本过低,可能会出现问题",
49809
49814
  "json:" + Ke.c.version,
49810
49815
  "sdk:" + this.sdkVersion
49811
- ), this.setConfig(Ke.c), this.history.fromJSON(Ke.h, s), this.viewport.fromJSON(Ke.v), yield this.history.processUndos(this.options.processUndosMaxFrameTime), (r = Ke.v.bg) != null && r.texture && this.viewport.vis) {
49816
+ ), 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) {
49812
49817
  const Je = parseTexture(Ke.v.bg.texture);
49813
49818
  Je.colorSpace = SRGBColorSpace, this.viewport.vis.pencil.scene.background = Je;
49814
49819
  }
@@ -49830,8 +49835,6 @@ class Editor {
49830
49835
  }
49831
49836
  setViewportVis(...e) {
49832
49837
  }
49833
- injectionModification(...e) {
49834
- }
49835
49838
  setConfig(e) {
49836
49839
  const s = {
49837
49840
  name: this.name,
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "0.22.11";
1
+ declare const _default: "0.22.12";
2
2
  export default _default;
@@ -73,7 +73,7 @@ export default class Base extends Event {
73
73
  tier0: boolean;
74
74
  constructor(options: BaseOptions);
75
75
  setOptions(options: Record<string, any>): void;
76
- get fromJSON(): (jsonOrUrl: Record<string, any> | string, extendVisOptions?: (json: any) => any) => Promise<Record<string, any>>;
76
+ get fromJSON(): (jsonOrUrl: Record<string, any> | string, hooks?: import("../../editor").Hooks) => Promise<Record<string, any>>;
77
77
  get baseObjectByUuid(): {
78
78
  (uuid: `arc${string}`, flag?: boolean): import("../all/objects/Arc").default;
79
79
  (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.11",
3
+ "version": "0.22.12",
4
4
  "scripts": {
5
5
  "start": "npm run version && PORT=5173 bundler-dev",
6
6
  "build:site": "npm run version && bundler",