@vcmap/core 5.0.0-rc.17 → 5.0.0-rc.18

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/index.d.ts CHANGED
@@ -8,25 +8,21 @@ export interface AppBackedCategoryOptions extends CategoryOptions {
8
8
  export class AppBackedCategory extends Category<VcsObject> {
9
9
  constructor(options: AppBackedCategoryOptions);
10
10
  protected _deserializeItem(config: VcsObjectOptions): Promise<VcsObject>;
11
+ setApp(app: VcsApp): void;
11
12
  serializeForContext(contextId: string): null;
13
+ toJSON(): AppBackedCategoryOptions;
12
14
  }
13
15
 
14
16
  /**
15
17
  */
16
18
  export interface CategoryOptions extends VcsObjectOptions {
17
- title?: string | {
18
- [key: string]: string;
19
- };
19
+ title?: string;
20
20
  /**
21
21
  * the class registry name on the current app to provide classes for this category. if provided, parseItems will deserialize using this class registry. See: {@link getObjectFromClassRegistry}.
22
22
  */
23
23
  classRegistryName?: string | symbol;
24
24
  featureProperty?: string | undefined;
25
25
  layerOptions?: VectorOptions;
26
- /**
27
- * items are not evaluated by the constructor but passed to parseItem during deserialization.
28
- */
29
- items?: object[];
30
26
  keyProperty?: string;
31
27
  }
32
28
 
@@ -39,9 +35,7 @@ export interface CategoryOptions extends VcsObjectOptions {
39
35
  export class Category<T extends Object|VcsObject> extends VcsObject {
40
36
  constructor(options: CategoryOptions);
41
37
  static getDefaultConfig(): CategoryOptions;
42
- title: string | {
43
- [key: string]: string;
44
- };
38
+ title: string;
45
39
  protected _app: VcsApp;
46
40
  protected _layer: VectorLayer;
47
41
  readonly classRegistryName: string | symbol;
@@ -81,7 +75,7 @@ export class Category<T extends Object|VcsObject> extends VcsObject {
81
75
  */
82
76
  protected _deserializeItem(config: any): Promise<T>;
83
77
  protected _serializeItem(item: T): object[];
84
- serializeForContext(contextId: string): CategoryOptions | null;
78
+ serializeForContext(contextId: string): any | null;
85
79
  /**
86
80
  * unique Name
87
81
  */
@@ -6408,21 +6402,6 @@ export function getDefaultCondition(attribute: string, isColor?: boolean): strin
6408
6402
 
6409
6403
  export const defaultExtrudedHeightCondition: string;
6410
6404
 
6411
- /**
6412
- */
6413
- export interface StyleItemLegendEntry {
6414
- /**
6415
- * the color to display
6416
- */
6417
- color: string;
6418
- /**
6419
- * the name to display for the given color
6420
- */
6421
- name: string | {
6422
- [key: string]: string;
6423
- };
6424
- }
6425
-
6426
6405
  /**
6427
6406
  */
6428
6407
  export interface StyleItemOptions extends VcsObjectOptions {
@@ -7489,6 +7468,8 @@ export class ViewPoint extends VcsObject {
7489
7468
  readonly className: string;
7490
7469
  }
7491
7470
 
7471
+ export const defaultDynamicContextId: string;
7472
+
7492
7473
  export class VcsApp {
7493
7474
  readonly id: string;
7494
7475
  /**
package/index.js CHANGED
@@ -139,7 +139,7 @@ export { wgs84ToMercatorTransformer, mercatorToWgs84Transformer, setDefaultProje
139
139
  export { default as SplitScreen } from './src/util/splitScreen.js';
140
140
  export { isSameOrigin } from './src/util/urlHelpers.js';
141
141
  export { propertyEqualsEpsilon, angleEqualsEpsilon, coordinateEqualsEpsilon, default as ViewPoint } from './src/util/viewpoint.js';
142
- export { getVcsAppById, default as VcsApp } from './src/vcsApp.js';
142
+ export { defaultDynamicContextId, getVcsAppById, default as VcsApp } from './src/vcsApp.js';
143
143
  export { contextIdSymbol, deserializeMap, deserializeViewPoint, deserializeLayer, serializeLayer, getLayerIndex, destroyCollection } from './src/vcsAppContextHelpers.js';
144
144
  export { default as VcsEvent } from './src/vcsEvent.js';
145
145
  export { default as VcsObject } from './src/vcsObject.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vcmap/core",
3
- "version": "5.0.0-rc.17",
3
+ "version": "5.0.0-rc.18",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -68,7 +68,8 @@
68
68
  "node_modules",
69
69
  "coverage",
70
70
  "index.js",
71
- "*.d.ts"
71
+ "*.d.ts",
72
+ "docs"
72
73
  ],
73
74
  "dependencies": {
74
75
  "@types/rbush": "^3.0.0",
@@ -57,6 +57,9 @@ class AppBackedCategory extends Category {
57
57
  return super._deserializeItem(config);
58
58
  }
59
59
 
60
+ /**
61
+ * @param {import("@vcmap/core").VcsApp} app
62
+ */
60
63
  setApp(app) {
61
64
  super.setApp(app);
62
65
  this.setCollection(this._app[this._collectionName]);
@@ -70,6 +73,16 @@ class AppBackedCategory extends Category {
70
73
  serializeForContext(contextId) {
71
74
  return null;
72
75
  }
76
+
77
+ /**
78
+ * @returns {AppBackedCategoryOptions}
79
+ */
80
+ toJSON() {
81
+ const config = /** @type {AppBackedCategoryOptions} */ (super.toJSON());
82
+ delete config.classRegistryName;
83
+ config.collectionName = this._collectionName;
84
+ return config;
85
+ }
73
86
  }
74
87
 
75
88
  export default AppBackedCategory;
@@ -15,11 +15,10 @@ import VcsEvent from '../vcsEvent.js';
15
15
 
16
16
  /**
17
17
  * @typedef {VcsObjectOptions} CategoryOptions
18
- * @property {string|Object<string, string>} [title]
18
+ * @property {string} [title]
19
19
  * @property {string|symbol} [classRegistryName] - the class registry name on the current app to provide classes for this category. if provided, parseItems will deserialize using this class registry. See: {@link getObjectFromClassRegistry}.
20
20
  * @property {string|undefined} [featureProperty]
21
21
  * @property {VectorOptions} [layerOptions={}]
22
- * @property {Array<Object>} [items] - items are not evaluated by the constructor but passed to parseItem during deserialization.
23
22
  * @property {string} [keyProperty=name]
24
23
  */
25
24
 
@@ -89,7 +88,6 @@ class Category extends VcsObject {
89
88
  classRegistryName: undefined,
90
89
  layerOptions: {},
91
90
  keyProperty: 'name',
92
- items: [],
93
91
  };
94
92
  }
95
93
 
@@ -100,7 +98,7 @@ class Category extends VcsObject {
100
98
  super(options);
101
99
  const defaultOptions = Category.getDefaultConfig();
102
100
  /**
103
- * @type {string|Object<string, string>}
101
+ * @type {string}
104
102
  */
105
103
  this.title = options.title || this.name;
106
104
  /**
@@ -381,7 +379,7 @@ class Category extends VcsObject {
381
379
 
382
380
  /**
383
381
  * @param {string} contextId
384
- * @returns {CategoryOptions|null}
382
+ * @returns {{ name: string, items: Array<Object>}|null}
385
383
  */
386
384
  serializeForContext(contextId) {
387
385
  if (this._collection.size === 0) {
@@ -394,6 +392,34 @@ class Category extends VcsObject {
394
392
  };
395
393
  }
396
394
 
395
+ /**
396
+ * @returns {CategoryOptions}
397
+ */
398
+ toJSON() {
399
+ const config = /** @type {CategoryOptions} */ (super.toJSON());
400
+
401
+ const defaultOptions = Category.getDefaultConfig();
402
+ if (this.title !== this.name) {
403
+ config.title = this.title;
404
+ }
405
+ if (this._featureProperty !== defaultOptions.featureProperty) {
406
+ config.featureProperty = this._featureProperty;
407
+ }
408
+ if (this._classRegistryName !== defaultOptions.classRegistryName) {
409
+ config.classRegistryName = this._classRegistryName;
410
+ }
411
+ if (Object.keys(this._layerOptions).length > 0) {
412
+ config.layerOptions = { ...this._layerOptions };
413
+ }
414
+ if (this._keyProperty !== defaultOptions.keyProperty) {
415
+ config.keyProperty = this._keyProperty;
416
+ }
417
+ return config;
418
+ }
419
+
420
+ /**
421
+ * @inheritDoc
422
+ */
397
423
  destroy() {
398
424
  super.destroy();
399
425
  if (this._app && this._layer) {
@@ -415,3 +441,4 @@ class Category extends VcsObject {
415
441
 
416
442
  export default Category;
417
443
  categoryClassRegistry.registerClass(Category.className, Category);
444
+
package/src/context.js CHANGED
@@ -1,4 +1,4 @@
1
- import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
1
+ import { v5 as uuidv5 } from 'uuid';
2
2
 
3
3
  /**
4
4
  * @typedef {Object} VcsAppConfig
@@ -17,7 +17,7 @@ import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';
17
17
  /**
18
18
  * @type {string}
19
19
  */
20
- const uuidNamespace = uuidv4();
20
+ const uniqueNamespace = '9c27cc2d-552f-4637-9194-09329ed4c1dc';
21
21
 
22
22
  /**
23
23
  * @class
@@ -36,7 +36,7 @@ class Context {
36
36
  * @type {string}
37
37
  * @private
38
38
  */
39
- this._checkSum = uuidv5(JSON.stringify(config), uuidNamespace);
39
+ this._checkSum = uuidv5(JSON.stringify(config), uniqueNamespace);
40
40
  /**
41
41
  * @type {string}
42
42
  * @private
@@ -6,13 +6,6 @@ import VcsObject from '../vcsObject.js';
6
6
  import VcsEvent from '../vcsEvent.js';
7
7
  import { styleClassRegistry } from '../classRegistry.js';
8
8
 
9
- /**
10
- * @typedef {Object} StyleItemLegendEntry
11
- * @property {string} color - the color to display
12
- * @property {string|Object<string, string>} name - the name to display for the given color
13
- * @api
14
- */
15
-
16
9
  /**
17
10
  * @typedef {VcsObjectOptions} StyleItemOptions
18
11
  * @property {number} [colorBlendMode=import("@vcmap/cesium").Cesium3DTileColorBlendMode.HIGHLIGHT] - colorBlendMode for 3D Tiledataset @see https://cesiumjs.org/import("@vcmap/cesium").Build/Documentation/Cesium3DTileColorBlendMode.html
package/src/vcsApp.js CHANGED
@@ -47,6 +47,11 @@ function getLogger() {
47
47
  */
48
48
  const vcsApps = new Map();
49
49
 
50
+ /**
51
+ * @type {string}
52
+ */
53
+ export const defaultDynamicContextId = '_defaultDynamicContext';
54
+
50
55
  /**
51
56
  * @class
52
57
  */
@@ -61,7 +66,7 @@ class VcsApp {
61
66
  * @type {Context}
62
67
  * @private
63
68
  */
64
- this._defaultDynamicContext = new Context({ id: '_defaultDynamicContext' });
69
+ this._defaultDynamicContext = new Context({ id: defaultDynamicContextId });
65
70
  /**
66
71
  * @type {Context}
67
72
  * @private