@emuanalytics/flow-rdf-core 4.0.9 → 4.0.11
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/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 +3 -3
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;
|
|
@@ -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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@emuanalytics/flow-rdf-core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"react": "^18.2.0",
|
|
60
60
|
"react-dom": "^18.2.0",
|
|
61
61
|
"storybook": "^7.1.1",
|
|
62
|
+
"tsx": "^4.19.1",
|
|
62
63
|
"typedoc": "^0.26.8",
|
|
63
64
|
"typedoc-plugin-markdown": "^4.2.9",
|
|
64
65
|
"typedoc-vitepress-theme": "^1.0.2",
|
|
65
|
-
"tsx": "^4.19.1",
|
|
66
66
|
"typescript": "^5.6.3",
|
|
67
67
|
"unbuild": "^2.0.0",
|
|
68
68
|
"vitest": "^2.1.1",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
},
|
|
72
72
|
"packageManager": "pnpm@7.33.0",
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@emuanalytics/flow-engine-client": "^
|
|
74
|
+
"@emuanalytics/flow-engine-client": "^2.0.3",
|
|
75
75
|
"@emuanalytics/mapbox-gl-draw": "^1.3.2",
|
|
76
76
|
"@emuanalytics/maplibre-gl": "^3.3.3",
|
|
77
77
|
"@emuanalytics/maplibre-gl-style-spec": "^19.3.1",
|