@emuanalytics/flow-rdf-core 4.0.8 → 4.0.10
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/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/lib/expressions/functions/regex.mjs +1 -1
- package/dist/lib/map/plugins/export/map-exporter.mjs +6 -6
- package/dist/lib/state-store/state-store.mjs +25 -6
- package/dist/lib/utils/index.d.mts +1 -1
- package/dist/lib/utils/index.d.ts +1 -1
- package/dist/package.json.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -7,11 +7,15 @@ import 'lit-html';
|
|
|
7
7
|
import '@emuanalytics/flow-engine-client';
|
|
8
8
|
import '@emuanalytics/maplibre-gl';
|
|
9
9
|
|
|
10
|
+
type SyncAnnotationArg = string | string[] | {
|
|
11
|
+
scope?: string | string[];
|
|
12
|
+
name?: string;
|
|
13
|
+
};
|
|
10
14
|
interface SyncAnnotation<T = any> extends Annotation {
|
|
11
15
|
serialize(val: T, scope?: string): string;
|
|
12
16
|
deserialize(val: string, target?: T): T;
|
|
13
17
|
type: string;
|
|
14
|
-
arg?:
|
|
18
|
+
arg?: SyncAnnotationArg;
|
|
15
19
|
}
|
|
16
20
|
declare const serialize: PropertyDecorator & SyncAnnotation<any> & {
|
|
17
21
|
raw: PropertyDecorator & SyncAnnotation<any>;
|
|
@@ -19,7 +23,7 @@ declare const serialize: PropertyDecorator & SyncAnnotation<any> & {
|
|
|
19
23
|
number: PropertyDecorator & SyncAnnotation<number>;
|
|
20
24
|
json: PropertyDecorator & SyncAnnotation<Record<string, boolean>>;
|
|
21
25
|
state: PropertyDecorator & SyncAnnotation<any>;
|
|
22
|
-
for: (arg:
|
|
26
|
+
for: (arg: SyncAnnotationArg | undefined) => PropertyDecorator & SyncAnnotation<any>;
|
|
23
27
|
};
|
|
24
28
|
interface ReactiveAnnotation extends Annotation {
|
|
25
29
|
mobxAnnotation: any;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,11 +7,15 @@ import 'lit-html';
|
|
|
7
7
|
import '@emuanalytics/flow-engine-client';
|
|
8
8
|
import '@emuanalytics/maplibre-gl';
|
|
9
9
|
|
|
10
|
+
type SyncAnnotationArg = string | string[] | {
|
|
11
|
+
scope?: string | string[];
|
|
12
|
+
name?: string;
|
|
13
|
+
};
|
|
10
14
|
interface SyncAnnotation<T = any> extends Annotation {
|
|
11
15
|
serialize(val: T, scope?: string): string;
|
|
12
16
|
deserialize(val: string, target?: T): T;
|
|
13
17
|
type: string;
|
|
14
|
-
arg?:
|
|
18
|
+
arg?: SyncAnnotationArg;
|
|
15
19
|
}
|
|
16
20
|
declare const serialize: PropertyDecorator & SyncAnnotation<any> & {
|
|
17
21
|
raw: PropertyDecorator & SyncAnnotation<any>;
|
|
@@ -19,7 +23,7 @@ declare const serialize: PropertyDecorator & SyncAnnotation<any> & {
|
|
|
19
23
|
number: PropertyDecorator & SyncAnnotation<number>;
|
|
20
24
|
json: PropertyDecorator & SyncAnnotation<Record<string, boolean>>;
|
|
21
25
|
state: PropertyDecorator & SyncAnnotation<any>;
|
|
22
|
-
for: (arg:
|
|
26
|
+
for: (arg: SyncAnnotationArg | undefined) => PropertyDecorator & SyncAnnotation<any>;
|
|
23
27
|
};
|
|
24
28
|
interface ReactiveAnnotation extends Annotation {
|
|
25
29
|
mobxAnnotation: any;
|
|
@@ -105,7 +105,7 @@ const _MapExporter = class _MapExporter {
|
|
|
105
105
|
preserveDrawingBuffer: true,
|
|
106
106
|
transformRequest: this.transformMapRequest.bind(this)
|
|
107
107
|
});
|
|
108
|
-
mapCopy.on("styleimagemissing", this.handleMissingImage
|
|
108
|
+
mapCopy.on("styleimagemissing", (e) => this.handleMissingImage(e, mapCopy));
|
|
109
109
|
return new Promise((resolve) => {
|
|
110
110
|
mapCopy.once("load", () => {
|
|
111
111
|
Object.keys(this.map.maplibreMap.style.sourceCaches).forEach((sourceId) => {
|
|
@@ -138,18 +138,18 @@ const _MapExporter = class _MapExporter {
|
|
|
138
138
|
get: () => pixelRatio
|
|
139
139
|
});
|
|
140
140
|
}
|
|
141
|
-
async handleMissingImage(e) {
|
|
141
|
+
async handleMissingImage(e, mapCopy) {
|
|
142
142
|
const imageInfo = this.map.imageRegistry.getImage(e.id);
|
|
143
143
|
if (imageInfo === this.map.imageRegistry.unknownImage) {
|
|
144
|
-
console.error(`
|
|
144
|
+
console.error(`Export copy of map ${this.map.id}: Image '${e.id}' not registered`);
|
|
145
145
|
}
|
|
146
146
|
if (!imageInfo.image.complete) {
|
|
147
147
|
imageInfo.image.onload = () => {
|
|
148
|
-
|
|
149
|
-
|
|
148
|
+
mapCopy.updateImage(e.id, imageInfo.image);
|
|
149
|
+
mapCopy.redraw();
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
mapCopy.addImage(e.id, imageInfo.image, {
|
|
153
153
|
pixelRatio: imageInfo.pixelDensity,
|
|
154
154
|
sdf: imageInfo.recolor
|
|
155
155
|
});
|
|
@@ -6,7 +6,7 @@ import { collectStoredAnnotations } from '../utils/decorators.mjs';
|
|
|
6
6
|
import { randomId } from '../utils/random-id.mjs';
|
|
7
7
|
import { REACTIVE_ANNOTATION_TYPE, SYNC_ANNOTATION_TYPE } from './decorators.mjs';
|
|
8
8
|
import { ensureArray } from '../utils/ensure-array.mjs';
|
|
9
|
-
import { isDefined } from '../utils/type-checks.mjs';
|
|
9
|
+
import { isStringFull, isArrayFull, isPlainObject, isDefined } from '../utils/type-checks.mjs';
|
|
10
10
|
import { FlowCoreError } from '../errors/flow-error.mjs';
|
|
11
11
|
|
|
12
12
|
var __defProp = Object.defineProperty;
|
|
@@ -424,7 +424,17 @@ class StateStore {
|
|
|
424
424
|
serialize(format = "raw", scope) {
|
|
425
425
|
const annotations = this.serializationAnnotations;
|
|
426
426
|
const serializedProps = Object.keys(annotations).reduce((accum, prop) => {
|
|
427
|
-
const
|
|
427
|
+
const annotationArg = annotations[prop].arg;
|
|
428
|
+
let annotationScopes = [];
|
|
429
|
+
let persistedName;
|
|
430
|
+
if (isStringFull(annotationArg)) {
|
|
431
|
+
annotationScopes = [annotationArg];
|
|
432
|
+
} else if (isArrayFull(annotationArg)) {
|
|
433
|
+
annotationScopes = annotationArg;
|
|
434
|
+
} else if (isPlainObject(annotationArg)) {
|
|
435
|
+
annotationScopes = ensureArray(annotationArg?.scope ?? []);
|
|
436
|
+
persistedName = annotationArg?.name;
|
|
437
|
+
}
|
|
428
438
|
const annotationType = annotations[prop].type;
|
|
429
439
|
if (scope && annotationType !== "state" && !annotationScopes.includes(scope)) {
|
|
430
440
|
return accum;
|
|
@@ -432,7 +442,7 @@ class StateStore {
|
|
|
432
442
|
const val = this[prop];
|
|
433
443
|
if (isDefined(val)) {
|
|
434
444
|
const serializedValue = annotations[prop].serialize(val, scope);
|
|
435
|
-
accum[prop] = serializedValue;
|
|
445
|
+
accum[persistedName ?? prop] = serializedValue;
|
|
436
446
|
}
|
|
437
447
|
return accum;
|
|
438
448
|
}, {});
|
|
@@ -463,12 +473,21 @@ class StateStore {
|
|
|
463
473
|
deserializedValue = value;
|
|
464
474
|
break;
|
|
465
475
|
}
|
|
476
|
+
const annotations = this.serializationAnnotations;
|
|
477
|
+
const renameMap = {};
|
|
478
|
+
for (const [prop, annotation] of Object.entries(annotations)) {
|
|
479
|
+
const renamedProp = annotation.arg?.name ?? prop;
|
|
480
|
+
renameMap[renamedProp] = prop;
|
|
481
|
+
}
|
|
466
482
|
this.transaction(() => {
|
|
467
|
-
const annotations = this.serializationAnnotations;
|
|
468
483
|
Object.keys(deserializedValue).forEach((prop) => {
|
|
469
|
-
const
|
|
484
|
+
const originalProp = renameMap[prop];
|
|
485
|
+
const annotation = annotations[originalProp];
|
|
470
486
|
if (annotation) {
|
|
471
|
-
this[
|
|
487
|
+
this[originalProp] = annotation.deserialize(
|
|
488
|
+
deserializedValue[prop],
|
|
489
|
+
this[originalProp]
|
|
490
|
+
);
|
|
472
491
|
}
|
|
473
492
|
});
|
|
474
493
|
});
|
|
@@ -25,7 +25,7 @@ declare const isDate: (val: unknown) => val is Date;
|
|
|
25
25
|
declare const isValue: (val: unknown) => boolean;
|
|
26
26
|
declare const hasValue: (val: unknown) => boolean;
|
|
27
27
|
declare const isFunction: (val: unknown) => val is Function;
|
|
28
|
-
declare function isPlainObject(o: unknown):
|
|
28
|
+
declare function isPlainObject(o: unknown): o is object;
|
|
29
29
|
declare function isURL(val: unknown): val is string;
|
|
30
30
|
|
|
31
31
|
declare function ensureArray<T>(a: T | T[], ...rest: T[]): T[];
|
|
@@ -25,7 +25,7 @@ declare const isDate: (val: unknown) => val is Date;
|
|
|
25
25
|
declare const isValue: (val: unknown) => boolean;
|
|
26
26
|
declare const hasValue: (val: unknown) => boolean;
|
|
27
27
|
declare const isFunction: (val: unknown) => val is Function;
|
|
28
|
-
declare function isPlainObject(o: unknown):
|
|
28
|
+
declare function isPlainObject(o: unknown): o is object;
|
|
29
29
|
declare function isURL(val: unknown): val is string;
|
|
30
30
|
|
|
31
31
|
declare function ensureArray<T>(a: T | T[], ...rest: T[]): T[];
|
package/dist/package.json.mjs
CHANGED