vis-core 0.23.1 → 0.23.3
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/editor/config.d.ts +19 -0
- package/dist/editor/index.d.ts +2 -11
- package/dist/editor/scripts.d.ts +5 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -4
- package/dist/index.module.js +71 -46
- package/dist/version.d.ts +1 -1
- package/dist/vis/base/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.module.js
CHANGED
|
@@ -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.
|
|
93
|
+
}, version = "0.23.3";
|
|
94
94
|
/**
|
|
95
95
|
* @license
|
|
96
96
|
* Copyright 2010-2024 Three.js Authors
|
|
@@ -48558,7 +48558,7 @@ class Command {
|
|
|
48558
48558
|
return e.type = this.type, e.id = this.id, e.name = this.name, e.updatable = this.updatable, e;
|
|
48559
48559
|
}
|
|
48560
48560
|
fromJSON(e) {
|
|
48561
|
-
if (this.type = e.type, this.id = e.id, this.name = e.name, this.updatable = e.updatable, !this.editor.jsonVersion && e.objectUuid) {
|
|
48561
|
+
if (this.type = e.type, this.id = e.id, this.name = e.name, this.updatable = e.updatable, !this.editor.config.meta.jsonVersion && e.objectUuid) {
|
|
48562
48562
|
const s = this.editor.objectByUuid(e.objectUuid);
|
|
48563
48563
|
s && (e.objectUuid = this.editor.uuidByObject(s));
|
|
48564
48564
|
const r = this.editor.baseObjectByUuid(e.objectUuid);
|
|
@@ -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
|
|
@@ -49627,24 +49627,39 @@ class Scripts {
|
|
|
49627
49627
|
beforeExecuteUndo: [],
|
|
49628
49628
|
afterExecuteUndo: [],
|
|
49629
49629
|
beforeShow: [],
|
|
49630
|
-
afterShow: []
|
|
49630
|
+
afterShow: [],
|
|
49631
|
+
beforeFromJSON: [],
|
|
49632
|
+
afterFromJSON: [],
|
|
49633
|
+
errorFromJSON: []
|
|
49631
49634
|
});
|
|
49632
49635
|
H0(this, "source", "");
|
|
49633
|
-
this.editor = e
|
|
49636
|
+
this.editor = e, this.addEvents({
|
|
49637
|
+
beforeFromJSON: () => {
|
|
49638
|
+
window.postMessage({ type: "vis-core.fromJSON.start" }), console.time("vis-core:time.fromJSON");
|
|
49639
|
+
},
|
|
49640
|
+
afterFromJSON: () => {
|
|
49641
|
+
window.postMessage({ type: "vis-core.fromJSON.end" }), console.timeEnd("vis-core:time.fromJSON");
|
|
49642
|
+
},
|
|
49643
|
+
errorFromJSON: () => {
|
|
49644
|
+
window.postMessage({ type: "vis-core.fromJSON.error" }), console.timeEnd("vis-core:time.fromJSON");
|
|
49645
|
+
}
|
|
49646
|
+
});
|
|
49634
49647
|
}
|
|
49635
|
-
|
|
49648
|
+
addEvents(e) {
|
|
49636
49649
|
for (const s in e) {
|
|
49637
49650
|
const r = s;
|
|
49638
49651
|
this.events[r] && this.events[r].push(e[r].bind(e));
|
|
49639
49652
|
}
|
|
49640
49653
|
}
|
|
49654
|
+
addStaticEvents(e) {
|
|
49655
|
+
this.addEvents(e());
|
|
49656
|
+
const s = e.toString().replace(/^\s+/gm, "").replace(/(\r\n|\n|\r)/gm, "");
|
|
49657
|
+
this.source !== s && (this.source = s, this.editor.emit("scriptsChanged"));
|
|
49658
|
+
}
|
|
49641
49659
|
fromJSON(e) {
|
|
49642
49660
|
try {
|
|
49643
|
-
|
|
49644
|
-
|
|
49645
|
-
`;
|
|
49646
|
-
const s = new Function(e)();
|
|
49647
|
-
this.add(s), this.source = e;
|
|
49661
|
+
const s = new Function(`return ${e}()`)();
|
|
49662
|
+
this.addEvents(s), this.source = e;
|
|
49648
49663
|
} catch (s) {
|
|
49649
49664
|
console.error(s);
|
|
49650
49665
|
}
|
|
@@ -49665,6 +49680,40 @@ class Scripts {
|
|
|
49665
49680
|
return r;
|
|
49666
49681
|
}
|
|
49667
49682
|
}
|
|
49683
|
+
class Config {
|
|
49684
|
+
constructor(e) {
|
|
49685
|
+
H0(this, "editor");
|
|
49686
|
+
H0(this, "meta", {
|
|
49687
|
+
name: "",
|
|
49688
|
+
key: "",
|
|
49689
|
+
open: !1,
|
|
49690
|
+
jsonVersion: "0.0.0",
|
|
49691
|
+
sdkVersion: "0.0.0"
|
|
49692
|
+
});
|
|
49693
|
+
this.editor = e;
|
|
49694
|
+
}
|
|
49695
|
+
setConfig(e, s) {
|
|
49696
|
+
this.meta[e] = s, this.editor.emit("configChanged", ai({}, this.meta));
|
|
49697
|
+
}
|
|
49698
|
+
fromJSON(e) {
|
|
49699
|
+
Object.keys(e).forEach((s) => {
|
|
49700
|
+
const r = s === "version" ? "jsonVersion" : s;
|
|
49701
|
+
r in this.meta && this.setConfig(r, e[s]);
|
|
49702
|
+
});
|
|
49703
|
+
}
|
|
49704
|
+
compareVersion() {
|
|
49705
|
+
compareVersion(this.meta.jsonVersion, this.meta.sdkVersion) === 1 && console.warn(
|
|
49706
|
+
"vis-core 版本过低,可能会出现问题",
|
|
49707
|
+
"json:" + this.meta.jsonVersion,
|
|
49708
|
+
"sdk:" + this.meta.sdkVersion
|
|
49709
|
+
);
|
|
49710
|
+
}
|
|
49711
|
+
toJSON() {
|
|
49712
|
+
return {
|
|
49713
|
+
version: this.meta.sdkVersion
|
|
49714
|
+
};
|
|
49715
|
+
}
|
|
49716
|
+
}
|
|
49668
49717
|
const jsonFetch = (c, e, s = !1) => {
|
|
49669
49718
|
const r = makePromiseCreator(!0), T = c.endsWith("gzip") || s;
|
|
49670
49719
|
return window.fetch(c).then((de) => {
|
|
@@ -49690,14 +49739,10 @@ class Editor {
|
|
|
49690
49739
|
H0(this, "history");
|
|
49691
49740
|
H0(this, "viewport");
|
|
49692
49741
|
H0(this, "scripts");
|
|
49742
|
+
H0(this, "config");
|
|
49693
49743
|
H0(this, "pencil");
|
|
49694
49744
|
H0(this, "on", this.events.on.bind(this.events));
|
|
49695
49745
|
H0(this, "emit", this.events.emit.bind(this.events));
|
|
49696
|
-
H0(this, "sdkVersion", version);
|
|
49697
|
-
H0(this, "jsonVersion");
|
|
49698
|
-
H0(this, "key");
|
|
49699
|
-
H0(this, "name");
|
|
49700
|
-
H0(this, "open", !1);
|
|
49701
49746
|
H0(this, "options");
|
|
49702
49747
|
H0(this, "selectOption", []);
|
|
49703
49748
|
H0(this, "selectOption2", []);
|
|
@@ -49717,7 +49762,7 @@ class Editor {
|
|
|
49717
49762
|
processUndosMaxFrameTime: Number.MAX_VALUE
|
|
49718
49763
|
}, e), this.events.setMaxListeners(9999999), this.viewport = new Viewport(this, {
|
|
49719
49764
|
visFactories: e.visFactories
|
|
49720
|
-
}), this.history = new History(this), this.scripts = new Scripts(this);
|
|
49765
|
+
}), this.history = new History(this), this.scripts = new Scripts(this), this.config = new Config(this), this.config.setConfig("sdkVersion", version);
|
|
49721
49766
|
}
|
|
49722
49767
|
getObjectMaterial(e, s) {
|
|
49723
49768
|
if (!e)
|
|
@@ -49812,7 +49857,7 @@ class Editor {
|
|
|
49812
49857
|
object: s.camera,
|
|
49813
49858
|
uuid: "camera"
|
|
49814
49859
|
}
|
|
49815
|
-
), !this.jsonVersion) {
|
|
49860
|
+
), !this.config.meta.jsonVersion) {
|
|
49816
49861
|
const Xe = new window.Map();
|
|
49817
49862
|
de.forEach((Ke, Je) => {
|
|
49818
49863
|
Xe.has(Ke.name) ? Ke.fixUuid = Ke.name + "_" + Je : (Ke.fixUuid = Ke.name, Xe.set(Ke.name, !0));
|
|
@@ -49842,7 +49887,7 @@ class Editor {
|
|
|
49842
49887
|
try {
|
|
49843
49888
|
s && !n$1(s) ? console.warn(
|
|
49844
49889
|
"fromJSON 第二个参数已修改,{beforeSetVisOptions:(r)=>r} 替代"
|
|
49845
|
-
) : s && this.scripts.
|
|
49890
|
+
) : s && this.scripts.addEvents(s), this.scripts.dispatch("beforeFromJSON");
|
|
49846
49891
|
let Ke;
|
|
49847
49892
|
if (typeof e == "string") {
|
|
49848
49893
|
const Je = this.options.assetsPrefix + e, { res: Qe } = yield jsonFetch(Je);
|
|
@@ -49856,20 +49901,16 @@ class Editor {
|
|
|
49856
49901
|
if (!Je || !Je.isValid)
|
|
49857
49902
|
throw new Error("need accessToken");
|
|
49858
49903
|
}
|
|
49859
|
-
if (
|
|
49860
|
-
"vis-core 版本过低,可能会出现问题",
|
|
49861
|
-
"json:" + Ke.c.version,
|
|
49862
|
-
"sdk:" + this.sdkVersion
|
|
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) {
|
|
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) {
|
|
49864
49905
|
const Je = parseTexture(Ke.v.bg.texture);
|
|
49865
49906
|
Je.colorSpace = SRGBColorSpace, this.viewport.vis.pencil.scene.background = Je;
|
|
49866
49907
|
}
|
|
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),
|
|
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(() => {
|
|
49868
49909
|
var Je;
|
|
49869
49910
|
(Je = this.viewport.vis) == null || Je.worker.dispose();
|
|
49870
|
-
}), Ke;
|
|
49911
|
+
}), this.scripts.dispatch("afterFromJSON"), Ke;
|
|
49871
49912
|
} catch (Ke) {
|
|
49872
|
-
throw
|
|
49913
|
+
throw this.scripts.dispatch("errorFromJSON"), new Error("fromJSON error:" + Ke);
|
|
49873
49914
|
}
|
|
49874
49915
|
});
|
|
49875
49916
|
}
|
|
@@ -49882,24 +49923,6 @@ class Editor {
|
|
|
49882
49923
|
}
|
|
49883
49924
|
setViewportVis(...e) {
|
|
49884
49925
|
}
|
|
49885
|
-
setConfig(e) {
|
|
49886
|
-
const s = {
|
|
49887
|
-
name: this.name,
|
|
49888
|
-
key: this.key,
|
|
49889
|
-
version: this.jsonVersion,
|
|
49890
|
-
open: this.open
|
|
49891
|
-
};
|
|
49892
|
-
e.name && typeof e.name == "string" && (this.name = e.name), e.key !== void 0 && (this.key = e.key), e.version !== void 0 && (this.jsonVersion = e.version), e.open !== void 0 && (this.open = e.open), this.emit(
|
|
49893
|
-
"configChanged",
|
|
49894
|
-
{
|
|
49895
|
-
name: this.name,
|
|
49896
|
-
key: this.key,
|
|
49897
|
-
version: this.jsonVersion,
|
|
49898
|
-
open: this.open
|
|
49899
|
-
},
|
|
49900
|
-
s
|
|
49901
|
-
);
|
|
49902
|
-
}
|
|
49903
49926
|
getDataURL() {
|
|
49904
49927
|
return this.pencil ? (this.pencil.render(), this.pencil.renderer.domElement.toDataURL()) : "";
|
|
49905
49928
|
}
|
|
@@ -50378,6 +50401,7 @@ class Base extends Event {
|
|
|
50378
50401
|
H0(this, "visName");
|
|
50379
50402
|
H0(this, "editor");
|
|
50380
50403
|
H0(this, "tier0", !1);
|
|
50404
|
+
H0(this, "_baseObjectByUuid");
|
|
50381
50405
|
H0(this, "initSettingsObj");
|
|
50382
50406
|
H0(this, "mouseButtonsActiveStore", null);
|
|
50383
50407
|
if (this.container = s.container, this.options = ai({
|
|
@@ -50431,7 +50455,8 @@ class Base extends Event {
|
|
|
50431
50455
|
return this.editor.fromJSON.bind(this.editor);
|
|
50432
50456
|
}
|
|
50433
50457
|
get baseObjectByUuid() {
|
|
50434
|
-
|
|
50458
|
+
var s;
|
|
50459
|
+
return ((s = this.editor) == null ? void 0 : s.baseObjectByUuid.bind(this.editor)) || this._baseObjectByUuid;
|
|
50435
50460
|
}
|
|
50436
50461
|
get objectByUuid() {
|
|
50437
50462
|
return this.editor.objectByUuid.bind(this.editor);
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "0.23.
|
|
1
|
+
declare const _default: "0.23.3";
|
|
2
2
|
export default _default;
|
package/dist/vis/base/index.d.ts
CHANGED
|
@@ -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;
|