vis-core 0.23.1 → 0.23.2

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.1";
93
+ }, version = "0.23.2";
94
94
  /**
95
95
  * @license
96
96
  * Copyright 2010-2024 Three.js Authors
@@ -49434,7 +49434,7 @@ class Viewport {
49434
49434
  if (this.vis = this.options.visFactories, this.vis.visName !== e)
49435
49435
  throw new Error(`visName is not match, import {${e}}`);
49436
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) => {
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: "下载资源",
49440
49440
  value: Ke / Je * 100 | 0
@@ -49632,19 +49632,21 @@ class Scripts {
49632
49632
  H0(this, "source", "");
49633
49633
  this.editor = e;
49634
49634
  }
49635
- add(e) {
49635
+ addEvents(e) {
49636
49636
  for (const s in e) {
49637
49637
  const r = s;
49638
49638
  this.events[r] && this.events[r].push(e[r].bind(e));
49639
49639
  }
49640
49640
  }
49641
+ addStaticEvents(e) {
49642
+ this.addEvents(e());
49643
+ const s = e.toString().replace(/^\s+/gm, "").replace(/(\r\n|\n|\r)/gm, "");
49644
+ this.source !== s && (this.source = s, this.editor.emit("scriptsChanged"));
49645
+ }
49641
49646
  fromJSON(e) {
49642
49647
  try {
49643
- e = `
49644
- return ${e}(vis);
49645
- `;
49646
- const s = new Function(e)();
49647
- this.add(s), this.source = e;
49648
+ const s = new Function(`return ${e}()`)();
49649
+ this.addEvents(s), this.source = e;
49648
49650
  } catch (s) {
49649
49651
  console.error(s);
49650
49652
  }
@@ -49842,7 +49844,7 @@ class Editor {
49842
49844
  try {
49843
49845
  s && !n$1(s) ? console.warn(
49844
49846
  "fromJSON 第二个参数已修改,{beforeSetVisOptions:(r)=>r} 替代"
49845
- ) : s && this.scripts.add(s), window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49847
+ ) : s && this.scripts.addEvents(s), window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
49846
49848
  let Ke;
49847
49849
  if (typeof e == "string") {
49848
49850
  const Je = this.options.assetsPrefix + e, { res: Qe } = yield jsonFetch(Je);
@@ -50378,6 +50380,7 @@ class Base extends Event {
50378
50380
  H0(this, "visName");
50379
50381
  H0(this, "editor");
50380
50382
  H0(this, "tier0", !1);
50383
+ H0(this, "_baseObjectByUuid");
50381
50384
  H0(this, "initSettingsObj");
50382
50385
  H0(this, "mouseButtonsActiveStore", null);
50383
50386
  if (this.container = s.container, this.options = ai({
@@ -50431,7 +50434,8 @@ class Base extends Event {
50431
50434
  return this.editor.fromJSON.bind(this.editor);
50432
50435
  }
50433
50436
  get baseObjectByUuid() {
50434
- return this.editor.baseObjectByUuid.bind(this.editor);
50437
+ var s;
50438
+ return ((s = this.editor) == null ? void 0 : s.baseObjectByUuid.bind(this.editor)) || this._baseObjectByUuid;
50435
50439
  }
50436
50440
  get objectByUuid() {
50437
50441
  return this.editor.objectByUuid.bind(this.editor);
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- declare const _default: "0.23.1";
1
+ declare const _default: "0.23.2";
2
2
  export default _default;
@@ -74,6 +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
+ _baseObjectByUuid: Editor['baseObjectByUuid'];
77
78
  get fromJSON(): (jsonOrUrl: Record<string, any> | string, scripts?: Record<string, any>) => Promise<Record<string, any>>;
78
79
  get baseObjectByUuid(): {
79
80
  (uuid: `arc${string}`, flag?: boolean): Arc;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vis-core",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
4
4
  "scripts": {
5
5
  "start": "npm run version && PORT=5173 bundler-dev",
6
6
  "build:site": "npm run version && bundler",