archgine 1.0.58 → 1.0.60

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.
@@ -12,6 +12,7 @@ export declare class AppCvs<Config extends IApplicationConfig> extends Applicati
12
12
  mainScene: MainScene<Config>;
13
13
  animateScene: AnimateScene<Config>;
14
14
  director: AppDirector<Config>;
15
+ requestHeader: any;
15
16
  private _url?;
16
17
  private _layers?;
17
18
  private _tic?;
@@ -24,6 +25,7 @@ export declare class AppCvs<Config extends IApplicationConfig> extends Applicati
24
25
  bindEvents(): void;
25
26
  unbindEvents(): void;
26
27
  handleCameraChanged(): void;
28
+ setRequestHeader(requestHeader: any): AppCvs<any>;
27
29
  trans2LoadingScene(): Promise<void>;
28
30
  load(url?: string, layers?: string[]): Promise<void>;
29
31
  pushResources2Scene(res?: IObject2[]): void;
@@ -4010,7 +4010,7 @@ Fu.__DOMHandler = Eu;
4010
4010
  Fu.normalizeLineEndings = Le;
4011
4011
  Fu.DOMParser = Ie;
4012
4012
  var gr = Fu.DOMParser;
4013
- const Er = "1.0.58";
4013
+ const Er = "1.0.60";
4014
4014
  function vr() {
4015
4015
  return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
4016
4016
  }
@@ -8,6 +8,7 @@ export declare class Adapter extends EventDispatcher {
8
8
  params: IApplicationConfig;
9
9
  boundingBox: Box2;
10
10
  offset: Vector2;
11
+ requestHeader: any;
11
12
  resources: Record<string, IObject2[]>;
12
13
  _resourcesMap: Record<string, IObject2>;
13
14
  _resourcesTree: ITree[];
@@ -21,6 +22,7 @@ export declare class Adapter extends EventDispatcher {
21
22
  constructor(config?: IApplicationConfig);
22
23
  destroy(): void;
23
24
  clear(): void;
25
+ setRequestHeader(requestHeader: any): Adapter;
24
26
  load(url: string, layers?: string[]): Promise<void>;
25
27
  init(str?: string): Promise<void>;
26
28
  loadBySax(url: string, layers?: string[]): Promise<void>;
@@ -7,6 +7,7 @@ export interface IApp {
7
7
  destroy(): void;
8
8
  resize(): void;
9
9
  start(): void;
10
+ setRequestHeader(requestHeader: any): IApp;
10
11
  load(url: string, layers?: string[], lv?: number, skeletons?: string[]): any;
11
12
  loadByString(str: string, layers?: string[], lv?: number): ITree[];
12
13
  setSkeletons(skeletons: string[]): void;
@@ -27,6 +27,7 @@ export declare class SvgApp<Config extends ISvgAppConfig> extends EventDispatche
27
27
  zoomBox: Box2;
28
28
  selectEnable: boolean;
29
29
  multiSelectEnable: boolean;
30
+ requestHeader: any;
30
31
  private readonly runningHandler;
31
32
  private readonly pointerOverHandler;
32
33
  private readonly pointerLeaveHandler;
@@ -43,7 +44,8 @@ export declare class SvgApp<Config extends ISvgAppConfig> extends EventDispatche
43
44
  start(): void;
44
45
  /** @description application's lifeCycle */
45
46
  running(time: DOMHighResTimeStamp): void;
46
- load(url: string, reqHeader?: any, layers?: string[], lv?: number, skeletons?: string[]): Promise<ITree[]>;
47
+ setRequestHeader(requestHeader: any): IApp;
48
+ load(url: string, layers?: string[], lv?: number, skeletons?: string[]): Promise<ITree[]>;
47
49
  loadByString(str: string, layers?: string[], lv?: number): ITree[];
48
50
  setSkeletons(skeletons: string[]): void;
49
51
  getLayers(lv?: number): ITree[] | undefined;
package/lib/index.mjs CHANGED
@@ -4010,7 +4010,7 @@ uu.__DOMHandler = La;
4010
4010
  uu.normalizeLineEndings = Td;
4011
4011
  uu.DOMParser = _d;
4012
4012
  var Gx = uu.DOMParser;
4013
- const Yx = "1.0.58";
4013
+ const Yx = "1.0.60";
4014
4014
  function Xx() {
4015
4015
  return typeof window < "u" && ({}.toString.call(window) === "[object Window]" || {}.toString.call(window) === "[object global]");
4016
4016
  }
@@ -12160,7 +12160,7 @@ class zd extends bE {
12160
12160
  isBelongsToAssetType(t, e) {
12161
12161
  e || (e = this.assetType);
12162
12162
  const i = this.getAssetsByType(e);
12163
- return i == null ? void 0 : i.hasOwnProperty(t);
12163
+ return i ? i == null ? void 0 : i.hasOwnProperty(t) : !1;
12164
12164
  }
12165
12165
  setAssetsMap(t, e = {}) {
12166
12166
  const i = this.chef.getElementById(xa(t));
@@ -12193,21 +12193,27 @@ class zd extends bE {
12193
12193
  return e ? Mt.keys(e) : i;
12194
12194
  }
12195
12195
  clearFillOrStroke(t = "fill") {
12196
- const e = this.getAssetsByType(this.assetType), i = Mt.keys(e);
12196
+ const e = this.getAssetsByType(this.assetType);
12197
+ if (!e) return;
12198
+ const i = Mt.keys(e);
12197
12199
  let a;
12198
12200
  for (let o = 0, l = i.length; o < l; o++)
12199
12201
  a = e[i[o]], !(!a || !a.hasAttribute(t)) && (a.removeAttribute(t), t === "stroke" && a.removeAttribute("stroke-width"));
12200
12202
  this.clearLegendBy(t);
12201
12203
  }
12202
12204
  clearFillOrStrokeByIds(t, e = "fill") {
12203
- const i = this.getAssetsByType(this.assetType), a = Mt.keys(i);
12205
+ const i = this.getAssetsByType(this.assetType);
12206
+ if (!i) return;
12207
+ const a = Mt.keys(i);
12204
12208
  let o;
12205
12209
  for (let l = 0, c = a.length; l < c; l++)
12206
12210
  t != null && t.length && !t.includes(a[l]) || (o = i[a[l]], !(!o || !o.hasAttribute(e)) && (o.removeAttribute(e), e === "stroke" && o.removeAttribute("stroke-width")));
12207
12211
  this.clearLegendBy(e);
12208
12212
  }
12209
12213
  setFillOrStrokeByIds(t, e, i = "fill") {
12210
- const a = this.getAssetsByType(this.assetType), o = Mt.keys(a);
12214
+ const a = this.getAssetsByType(this.assetType);
12215
+ if (!a) return;
12216
+ const o = Mt.keys(a);
12211
12217
  let l;
12212
12218
  for (let c = 0, f = o.length; c < f; c++)
12213
12219
  t.includes(o[c]) && (l = a[o[c]], l && (l.setAttribute(i, e), i === "stroke" && l.setAttribute("stroke-width", "7"), this.addLegend(i, e, o[c])));
@@ -12297,7 +12303,9 @@ class zd extends bE {
12297
12303
  // ====================== selected
12298
12304
  getIntersectObjects(t, e = dr.RM, i = []) {
12299
12305
  i.length = 0;
12300
- const a = [], o = this.getAssetsByType(e), l = Mt.keys(o);
12306
+ const a = [], o = this.getAssetsByType(e);
12307
+ if (!o) return i;
12308
+ const l = Mt.keys(o);
12301
12309
  for (let f = 0, d = l.length; f < d; f++) {
12302
12310
  const g = this.chef.getElementBoundingBox(o[l[f]].id);
12303
12311
  g && g.containsPoint(t.worldCoords) && a.push(o[l[f]]);
@@ -12368,11 +12376,13 @@ class zd extends bE {
12368
12376
  selectByIds(t, e = !1) {
12369
12377
  Array.isArray(t) || (t = [t]), e || this.clearSelected();
12370
12378
  const i = Mt.uniq(Mt.map(this.selectedList, (o) => o.getAttribute("id") || "")), a = this.getAssetsByType(this.assetType);
12371
- for (let o = t.length - 1; o >= 0; o--)
12372
- i.includes(t[o]) ? (this.clearSelectedById(t[o]), t.splice(o, 1)) : Object.hasOwnProperty.call(a, t[o]) && this.selectedList.push(a[t[o]]);
12373
- this.selectedList.forEach((o) => {
12374
- this.chef.setElementState2selected(o, !0);
12375
- });
12379
+ if (a) {
12380
+ for (let o = t.length - 1; o >= 0; o--)
12381
+ i.includes(t[o]) ? (this.clearSelectedById(t[o]), t.splice(o, 1)) : Object.hasOwnProperty.call(a, t[o]) && this.selectedList.push(a[t[o]]);
12382
+ this.selectedList.forEach((o) => {
12383
+ this.chef.setElementState2selected(o, !0);
12384
+ });
12385
+ }
12376
12386
  }
12377
12387
  getSelectedIds() {
12378
12388
  var e;
@@ -12405,6 +12415,7 @@ class zd extends bE {
12405
12415
  // }
12406
12416
  getElementsByBox(t) {
12407
12417
  const e = [], i = Object.keys(this.chef.boundingBoxMap), a = this.getAssetsByType(this.assetType);
12418
+ if (!a) return e;
12408
12419
  for (let o = 0, l = i.length; o < l; o++)
12409
12420
  if (a.hasOwnProperty(i[o]) && !(i[o].indexOf("-assets") > -1) && t.intersectsBox(this.chef.boundingBoxMap[i[o]])) {
12410
12421
  const c = a[i[o]];
@@ -17331,6 +17342,7 @@ class Wb extends rr {
17331
17342
  zoomBox = new Nt();
17332
17343
  selectEnable = !1;
17333
17344
  multiSelectEnable = !1;
17345
+ requestHeader = {};
17334
17346
  runningHandler = this.running.bind(this);
17335
17347
  pointerOverHandler = this.handlePointerOver.bind(this);
17336
17348
  pointerLeaveHandler = this.handlePointerLeave.bind(this);
@@ -17377,11 +17389,14 @@ class Wb extends rr {
17377
17389
  this.scene && (this.scene.update(), this.renderer.render(this.scene, this.view.camera), this.view.update(t), requestAnimationFrame(this.runningHandler));
17378
17390
  }
17379
17391
  // ======================= output business logic =======================
17392
+ setRequestHeader(t) {
17393
+ return this.requestHeader = t, this;
17394
+ }
17380
17395
  // @ts-ignore
17381
- async load(t, e = {}, i, a = 2, o) {
17396
+ async load(t, e, i = 2, a) {
17382
17397
  this.isLoadingScene || this.trans2LoadingScene(), await np(this.params.syncDelay);
17383
- const l = await new Bd().setRequestHeader(e).loadAsync(t);
17384
- return this.loadByString(l, i, a);
17398
+ const o = await new Bd().setRequestHeader(this.requestHeader).loadAsync(t);
17399
+ return this.loadByString(o, e, i);
17385
17400
  }
17386
17401
  loadByString(t, e, i = 2) {
17387
17402
  this.mainScene = new zd(this.params), this.mainScene.bind(t), this.view.setByBox(this.mainScene.viewBox);