@thatopen/components 2.4.0-alpha.5 → 2.4.0-alpha.7

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.
@@ -170,5 +170,15 @@ export declare class Classifier extends Component implements Disposable {
170
170
  * @throws Will throw an error if the fragment with the specified ID is not found.
171
171
  */
172
172
  resetColor(items: FRAGS.FragmentIdMap): void;
173
+ /**
174
+ * Exports the computed classification to persists them and import them back
175
+ * later for faster loading.
176
+ */
177
+ export(): string;
178
+ /**
179
+ * Imports a classification previously exported with .export().
180
+ * @param data the serialized classification to import.
181
+ */
182
+ import(data: string): void;
173
183
  protected saveItem(group: FRAGS.FragmentsGroup, systemName: string, className: string, expressID: number, parentID?: number | null): void;
174
184
  }
package/dist/index.cjs CHANGED
@@ -24090,6 +24090,47 @@ const _Classifier = class _Classifier extends Component {
24090
24090
  found.resetColor(ids);
24091
24091
  }
24092
24092
  }
24093
+ /**
24094
+ * Exports the computed classification to persists them and import them back
24095
+ * later for faster loading.
24096
+ */
24097
+ export() {
24098
+ const exported = {};
24099
+ for (const systemName in this.list) {
24100
+ exported[systemName] = {};
24101
+ const system = this.list[systemName];
24102
+ for (const groupName in system) {
24103
+ const group = system[groupName];
24104
+ exported[systemName][groupName] = {
24105
+ map: FRAGS__namespace.FragmentUtils.export(group.map),
24106
+ name: group.name,
24107
+ id: group.id
24108
+ };
24109
+ }
24110
+ }
24111
+ return JSON.stringify(exported);
24112
+ }
24113
+ /**
24114
+ * Imports a classification previously exported with .export().
24115
+ * @param data the serialized classification to import.
24116
+ */
24117
+ import(data) {
24118
+ const imported = JSON.parse(data);
24119
+ for (const systemName in imported) {
24120
+ if (!this.list[systemName]) {
24121
+ this.list[systemName] = {};
24122
+ }
24123
+ const system = imported[systemName];
24124
+ for (const groupName in system) {
24125
+ const group = system[groupName];
24126
+ this.list[systemName][groupName] = {
24127
+ map: FRAGS__namespace.FragmentUtils.import(group.map),
24128
+ name: group.name,
24129
+ id: group.id
24130
+ };
24131
+ }
24132
+ }
24133
+ }
24093
24134
  saveItem(group, systemName, className, expressID, parentID = null) {
24094
24135
  if (!this.list[systemName]) {
24095
24136
  this.list[systemName] = {};