@emuanalytics/flow-rdf-core 4.0.4 → 4.0.6

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.
Files changed (89) hide show
  1. package/README.md +1 -64
  2. package/dist/index.d.mts +36 -31
  3. package/dist/index.d.ts +36 -31
  4. package/dist/index.mjs +20 -3249
  5. package/dist/lib/context/context-registry.mjs +63 -0
  6. package/dist/lib/context/debugger.mjs +240 -0
  7. package/dist/lib/context/flow-context.mjs +61 -0
  8. package/dist/lib/context/global-state.mjs +70 -0
  9. package/dist/lib/context/map-registry.mjs +59 -0
  10. package/dist/lib/context/query-registry.mjs +53 -0
  11. package/dist/lib/errors/flow-error.mjs +10 -0
  12. package/dist/lib/errors/flow-expression-error.mjs +14 -0
  13. package/dist/lib/errors/flow-map-error.mjs +9 -0
  14. package/dist/lib/expressions/expression-parser.mjs +198 -0
  15. package/dist/lib/expressions/functions/from-palette.mjs +75 -0
  16. package/dist/lib/expressions/functions/regex.mjs +25 -0
  17. package/dist/lib/expressions/functions/state.mjs +25 -0
  18. package/dist/lib/expressions/parser-helpers.mjs +37 -0
  19. package/dist/lib/expressions/reactive-expression.mjs +253 -0
  20. package/dist/lib/map/flow-core-map.mjs +749 -0
  21. package/dist/lib/map/plugins/annotations/annotation-layers.mjs +163 -0
  22. package/dist/lib/map/plugins/annotations/annotation.events.mjs +27 -0
  23. package/dist/lib/map/plugins/annotations/annotation.plugin.mjs +498 -0
  24. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/modes/DirectModeOverride.mjs +67 -0
  25. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/modes/DragCircleMode.mjs +65 -0
  26. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/utils/create_supplementary_points_circle.mjs +15 -0
  27. package/dist/lib/map/plugins/annotations/maplibre-gl-draw-circle/lib/utils/drag_pan.mjs +20 -0
  28. package/dist/lib/map/plugins/data-join.plugin.mjs +173 -0
  29. package/dist/lib/map/plugins/export/export.plugin.mjs +21 -0
  30. package/dist/lib/map/plugins/export/map-exporter.mjs +177 -0
  31. package/dist/lib/map/plugins/hover-effect.plugin.mjs +58 -0
  32. package/dist/lib/map/plugins/index.d.mts +37 -72
  33. package/dist/lib/map/plugins/index.d.ts +37 -72
  34. package/dist/lib/map/plugins/index.mjs +11 -1810
  35. package/dist/lib/map/plugins/keyboard-shortcut-manager.mjs +120 -0
  36. package/dist/lib/map/plugins/map-plugin-base.mjs +25 -0
  37. package/dist/lib/map/plugins/plugin-manager.mjs +135 -0
  38. package/dist/lib/map/plugins/popup.plugin.mjs +55 -0
  39. package/dist/lib/map/plugins/selection/selection.events.mjs +21 -0
  40. package/dist/lib/map/plugins/selection/selection.plugin.mjs +136 -0
  41. package/dist/lib/map/plugins/selection/source-selection.mjs +156 -0
  42. package/dist/lib/map/plugins/url-sync.plugin.mjs +55 -0
  43. package/dist/lib/map/support/image-registry.mjs +82 -0
  44. package/dist/lib/map/support/map-events.mjs +71 -0
  45. package/dist/lib/map/support/map-feature-stream.mjs +158 -0
  46. package/dist/lib/map/support/map-popup.mjs +159 -0
  47. package/dist/lib/map/types.mjs +7 -0
  48. package/dist/lib/map-style/map-data-source.mjs +192 -0
  49. package/dist/lib/map-style/map-layer-style-builder-generated.mjs +1307 -0
  50. package/dist/lib/map-style/map-layer-style-builder.mjs +86 -0
  51. package/dist/lib/map-style/map-layer.mjs +223 -0
  52. package/dist/lib/map-style/map-style.mjs +178 -0
  53. package/dist/lib/queries/async-committer.mjs +30 -0
  54. package/dist/lib/queries/query.mjs +172 -0
  55. package/dist/lib/state-store/decorators.mjs +83 -0
  56. package/dist/lib/state-store/state-store.mjs +534 -0
  57. package/dist/lib/state-store/utils.mjs +7 -0
  58. package/dist/lib/utils/announce.mjs +12 -0
  59. package/dist/lib/utils/assert.mjs +12 -0
  60. package/dist/{shared/flow-rdf-core.187cb345.mjs → lib/utils/debounce.mjs} +3 -39
  61. package/dist/lib/utils/decorators.mjs +59 -0
  62. package/dist/lib/utils/deferred.mjs +11 -0
  63. package/dist/lib/utils/ensure-array.mjs +16 -0
  64. package/dist/{shared/flow-rdf-core.1f0901c5.mjs → lib/utils/feature-type-checks.mjs} +2 -2
  65. package/dist/lib/utils/functional.mjs +22 -0
  66. package/dist/lib/utils/global.mjs +18 -0
  67. package/dist/lib/utils/index.mjs +8 -5
  68. package/dist/lib/utils/random-id.mjs +9 -0
  69. package/dist/lib/utils/string-utils.mjs +3 -0
  70. package/dist/lib/utils/throttle.mjs +20 -0
  71. package/dist/{shared/flow-rdf-core.25e5f6d7.mjs → lib/utils/type-checks.mjs} +1 -26
  72. package/dist/lib/utils/watchable-promise.mjs +55 -0
  73. package/dist/package.json.mjs +3 -0
  74. package/dist/shared/{flow-rdf-core.4dde996e.d.cts → flow-rdf-core.cef13c7e.d.mts} +1315 -172
  75. package/dist/shared/{flow-rdf-core.4dde996e.d.ts → flow-rdf-core.cef13c7e.d.ts} +1315 -172
  76. package/package.json +4 -8
  77. package/dist/index.cjs +0 -3316
  78. package/dist/index.d.cts +0 -90
  79. package/dist/lib/map/plugins/index.cjs +0 -1850
  80. package/dist/lib/map/plugins/index.d.cts +0 -345
  81. package/dist/lib/utils/index.cjs +0 -48
  82. package/dist/lib/utils/index.d.cts +0 -160
  83. package/dist/shared/flow-rdf-core.06e85a6c.cjs +0 -1394
  84. package/dist/shared/flow-rdf-core.4dde996e.d.mts +0 -1916
  85. package/dist/shared/flow-rdf-core.55c169ca.cjs +0 -150
  86. package/dist/shared/flow-rdf-core.63162669.d.cts +0 -10
  87. package/dist/shared/flow-rdf-core.65045caf.mjs +0 -1360
  88. package/dist/shared/flow-rdf-core.a82b9be4.cjs +0 -34
  89. package/dist/shared/flow-rdf-core.f50908f0.cjs +0 -102
@@ -0,0 +1,63 @@
1
+ import Debug from 'debug';
2
+ import { deferred } from '../utils/deferred.mjs';
3
+ import { FlowContext, DEFAULT_CONTEXT_ID } from './flow-context.mjs';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __publicField = (obj, key, value) => {
8
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
+ return value;
10
+ };
11
+ const debug = Debug("flow:context-registry");
12
+ const _ContextRegistry = class _ContextRegistry {
13
+ constructor() {
14
+ __publicField(this, "_contexts", /* @__PURE__ */ new Map());
15
+ }
16
+ /**
17
+ * Initialize a new Flo.w context.
18
+ *
19
+ * @param options Context options.
20
+ */
21
+ initializeContext(options) {
22
+ options = { ..._ContextRegistry._defaultOptions, ...options };
23
+ debug(`Initializing context '${options.id}'`, options);
24
+ if (!this._contexts.get(options.id)) {
25
+ this._contexts.set(options.id, {
26
+ initialized: false,
27
+ deferred: deferred()
28
+ });
29
+ }
30
+ const registryEntry = this._contexts.get(options.id);
31
+ if (registryEntry.initialized) {
32
+ console.warn(`Context '${options.id}' has already been initialized. Skipping re-initialization.`);
33
+ }
34
+ const context = new FlowContext(options);
35
+ registryEntry.initialized = true;
36
+ registryEntry.deferred.resolve(context);
37
+ return context;
38
+ }
39
+ uninitializeContext(contextId = DEFAULT_CONTEXT_ID) {
40
+ if (!this._contexts.has(contextId)) {
41
+ console.warn(`Context '${contextId}' has not been initialized. Skipping uninitialization.`);
42
+ }
43
+ debug(`Uninitializing context '${contextId}'`);
44
+ this._contexts.delete(contextId);
45
+ }
46
+ getContext(id = DEFAULT_CONTEXT_ID) {
47
+ if (!this._contexts.get(id)) {
48
+ this._contexts.set(id, {
49
+ initialized: false,
50
+ deferred: deferred()
51
+ });
52
+ }
53
+ const deferredContext = this._contexts.get(id);
54
+ return deferredContext?.deferred;
55
+ }
56
+ };
57
+ __publicField(_ContextRegistry, "_defaultOptions", {
58
+ id: DEFAULT_CONTEXT_ID,
59
+ host: "https://flow.emu-analytics.net"
60
+ });
61
+ let ContextRegistry = _ContextRegistry;
62
+
63
+ export { ContextRegistry };
@@ -0,0 +1,240 @@
1
+ import * as mobx from 'mobx';
2
+ import { isObservable, isComputed, isObservableArray, isObservableSet, isObservableMap } from 'mobx';
3
+ import { isUndefined } from '../utils/type-checks.mjs';
4
+
5
+ var __defProp = Object.defineProperty;
6
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
+ var __publicField = (obj, key, value) => {
8
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
9
+ return value;
10
+ };
11
+ const FLOW_GLOBAL = "FDBG";
12
+ const CONSOLE_HIGHLIGHT_STYLE = `
13
+ padding: 2px 4px;
14
+ border-radius: 2px;
15
+ background: #389DFF;
16
+ color: white;`;
17
+ const CONSOLE_BOLD_STYLE = `font-weight: bold;`;
18
+ class Debugger {
19
+ /**
20
+ * Constructs a new Flo.w debugger instance.
21
+ *
22
+ * A new Flo.w debugger will be created automatically if the `enableDebug` option is
23
+ * specified when initializing a Flo.w context.
24
+ *
25
+ * @param context Flo.w context ID.
26
+ */
27
+ constructor(context) {
28
+ this.context = context;
29
+ __publicField(this, "spyDisposer");
30
+ __publicField(this, "watchDisposers", {});
31
+ }
32
+ /**
33
+ * Install a 'watch' for the specified context state property path.
34
+ *
35
+ * @param path Context state property path.
36
+ */
37
+ watch(path) {
38
+ if (!this.watchDisposers[path]) {
39
+ this.watchDisposers[path] = this.context.state.autorun(() => this.logStateValue(path));
40
+ }
41
+ }
42
+ /**
43
+ * Remove a previously-installed 'watch' for the specified context state property path.
44
+ *
45
+ * @param path Context state property path.
46
+ */
47
+ unwatch(path) {
48
+ if (path) {
49
+ if (this.watchDisposers[path]) {
50
+ this.watchDisposers[path]();
51
+ delete this.watchDisposers[path];
52
+ }
53
+ } else {
54
+ Object.keys(this.watchDisposers).forEach((key) => this.watchDisposers[key]());
55
+ this.watchDisposers = {};
56
+ }
57
+ }
58
+ /**
59
+ * Set a Flo.w context state property.
60
+ *
61
+ * @param path Context state property path
62
+ * @param value New value to set
63
+ */
64
+ set(path, value) {
65
+ this.context.state.set(path, value);
66
+ }
67
+ /**
68
+ * Read the value of a Flo.w context state property.
69
+ *
70
+ * @param keyOrPath Context state property path.
71
+ * @returns The context state property value.
72
+ */
73
+ get(keyOrPath) {
74
+ if (isUndefined(keyOrPath)) {
75
+ keyOrPath = [];
76
+ } else if (typeof keyOrPath === "string") {
77
+ if (keyOrPath.startsWith("$")) {
78
+ keyOrPath = keyOrPath.slice(1);
79
+ }
80
+ return this.get(keyOrPath.split("."));
81
+ }
82
+ let value = this.context.state;
83
+ const path = [...keyOrPath];
84
+ while (path.length > 0) {
85
+ if (value == null) {
86
+ value = void 0;
87
+ break;
88
+ }
89
+ const key = path.shift();
90
+ value = value[key];
91
+ }
92
+ return toJSHelper(value, {});
93
+ }
94
+ /**
95
+ * Enable verbose debugging of all reactive updates.
96
+ */
97
+ spy() {
98
+ this.unspy();
99
+ this.spyDisposer = mobx.spy(this.spyListener.bind(this));
100
+ }
101
+ /**
102
+ * Disable verbose debugging of all reactive updates.
103
+ */
104
+ unspy() {
105
+ if (this.spyDisposer) {
106
+ this.spyDisposer();
107
+ this.spyDisposer = void 0;
108
+ }
109
+ }
110
+ /**
111
+ * Get a registered map instance by ID.
112
+ */
113
+ maps(mapId) {
114
+ if (!mapId) {
115
+ return Array.from(this.context.maps._maps.keys());
116
+ }
117
+ const mapPromise = this.context.maps.getMap(mapId);
118
+ return mapPromise?.value;
119
+ }
120
+ /**
121
+ * Get a registered reactive query by ID.
122
+ */
123
+ queries(queryId) {
124
+ if (!queryId) {
125
+ return Array.from(this.context.queries._queries.keys());
126
+ }
127
+ const queryPromise = this.context.queries.getQuery(queryId);
128
+ return queryPromise?.value;
129
+ }
130
+ spyListener(event) {
131
+ console.log(`%cspy`, CONSOLE_HIGHLIGHT_STYLE, event);
132
+ }
133
+ logStateValue(path) {
134
+ const value = toJSHelper(this.context.state.get(path), { recurseEverything: false });
135
+ console.log(`%cwatch%c %s`, CONSOLE_HIGHLIGHT_STYLE, CONSOLE_BOLD_STYLE, path, value);
136
+ }
137
+ }
138
+ function installGlobalDebugger(dbg) {
139
+ console.log(
140
+ `%cFlow.w RDF Debbugger`,
141
+ CONSOLE_HIGHLIGHT_STYLE,
142
+ `Enabled for context '${dbg.context.id}' - access using ${FLOW_GLOBAL} in web developer console.`
143
+ );
144
+ const g = typeof global !== "undefined" ? global : window;
145
+ g[FLOW_GLOBAL] = g[FLOW_GLOBAL] || {
146
+ context: dbg.context,
147
+ watch: dbg.watch.bind(dbg),
148
+ unwatch: dbg.unwatch.bind(dbg),
149
+ set: dbg.set.bind(dbg),
150
+ get: dbg.get.bind(dbg),
151
+ spy: dbg.spy.bind(dbg),
152
+ maps: dbg.maps.bind(dbg),
153
+ queries: dbg.queries.bind(dbg),
154
+ unspy: dbg.unspy.bind(dbg)
155
+ };
156
+ }
157
+ function cache(map, key, value, options) {
158
+ if (options.detectCycles)
159
+ map.set(key, value);
160
+ return value;
161
+ }
162
+ function getPlainObjectKeys(object) {
163
+ const enumerables = /* @__PURE__ */ new Set();
164
+ for (const key in object)
165
+ enumerables.add(key);
166
+ Object.getOwnPropertySymbols(object).forEach(function(k) {
167
+ if (Object.getOwnPropertyDescriptor(object, k).enumerable)
168
+ enumerables.add(k);
169
+ });
170
+ return Array.from(enumerables);
171
+ }
172
+ function toJSHelper(source, options, __alreadySeen = null) {
173
+ if (!options.recurseEverything && !isObservable(source))
174
+ return source;
175
+ if (typeof source !== "object")
176
+ return source;
177
+ if (source === null)
178
+ return null;
179
+ if (source instanceof Date)
180
+ return source;
181
+ if (isComputed(source)) {
182
+ try {
183
+ const value = source.get();
184
+ return { computedValue: value };
185
+ } catch (e) {
186
+ return { computedValueException: e.message };
187
+ }
188
+ }
189
+ const detectCycles = options.detectCycles === true;
190
+ if (detectCycles && source !== null && __alreadySeen.has(source)) {
191
+ return __alreadySeen.get(source);
192
+ }
193
+ if (isObservableArray(source) || Array.isArray(source)) {
194
+ const res_1 = cache(__alreadySeen, source, [], options);
195
+ const toAdd = source.map(function(value) {
196
+ return toJSHelper(value, options, __alreadySeen);
197
+ });
198
+ res_1.length = toAdd.length;
199
+ for (let i = 0, l = toAdd.length; i < l; i++)
200
+ res_1[i] = toAdd[i];
201
+ return res_1;
202
+ }
203
+ if (isObservableSet(source) || Object.getPrototypeOf(source) === Set.prototype) {
204
+ if (options.exportMapsAsObjects === false) {
205
+ const res_2 = cache(__alreadySeen, source, /* @__PURE__ */ new Set(), options);
206
+ source.forEach(function(value) {
207
+ res_2.add(toJSHelper(value, options, __alreadySeen));
208
+ });
209
+ return res_2;
210
+ } else {
211
+ const res_3 = cache(__alreadySeen, source, [], options);
212
+ source.forEach(function(value) {
213
+ res_3.push(toJSHelper(value, options, __alreadySeen));
214
+ });
215
+ return res_3;
216
+ }
217
+ }
218
+ if (isObservableMap(source) || Object.getPrototypeOf(source) === Map.prototype) {
219
+ if (options.exportMapsAsObjects === false) {
220
+ const res_4 = cache(__alreadySeen, source, /* @__PURE__ */ new Map(), options);
221
+ source.forEach(function(value, key) {
222
+ res_4.set(key, toJSHelper(value, options, __alreadySeen));
223
+ });
224
+ return res_4;
225
+ } else {
226
+ const res_5 = cache(__alreadySeen, source, {}, options);
227
+ source.forEach(function(value, key) {
228
+ res_5[key] = toJSHelper(value, options, __alreadySeen);
229
+ });
230
+ return res_5;
231
+ }
232
+ }
233
+ const res = cache(__alreadySeen, source, {}, options);
234
+ getPlainObjectKeys(source).forEach(function(key) {
235
+ res[key] = toJSHelper(source[key], options, __alreadySeen);
236
+ });
237
+ return res;
238
+ }
239
+
240
+ export { Debugger, installGlobalDebugger };
@@ -0,0 +1,61 @@
1
+ import { Client } from '@emuanalytics/flow-engine-client';
2
+ import { Debugger, installGlobalDebugger } from './debugger.mjs';
3
+ import { MapRegistry } from './map-registry.mjs';
4
+ import { QueryRegistry } from './query-registry.mjs';
5
+ import { ReactiveExpression } from '../expressions/reactive-expression.mjs';
6
+
7
+ var __defProp = Object.defineProperty;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __publicField = (obj, key, value) => {
10
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
+ return value;
12
+ };
13
+ const DEFAULT_FLOW_HOST = "https://flow.emu-analytics.net";
14
+ const DEFAULT_CONTEXT_ID = "default";
15
+ const _FlowContext = class _FlowContext {
16
+ /**
17
+ * Constructs a new `FlowCoreContext`.
18
+ *
19
+ * Use [[ContextRegistry.initializeContext]] to create an instance of `FlowCoreContext`.
20
+ *
21
+ * @param options - The context options.
22
+ */
23
+ constructor(options) {
24
+ __publicField(this, "_options");
25
+ __publicField(this, "flowClient");
26
+ __publicField(this, "state");
27
+ __publicField(this, "maps", new MapRegistry());
28
+ __publicField(this, "queries", new QueryRegistry());
29
+ /** The Flo.w debugger. Available as `window.FDBG` in the browser's web developer console. */
30
+ __publicField(this, "debugger");
31
+ this._options = {
32
+ ..._FlowContext._defaultOptions,
33
+ ...options
34
+ };
35
+ if (!options.state.initialized) {
36
+ options.state.initialize();
37
+ }
38
+ this.flowClient = new Client(this._options.host, this._options.apiKey);
39
+ this.state = options.state;
40
+ if (options.enableDebug) {
41
+ this.debugger = new Debugger(this);
42
+ installGlobalDebugger(this.debugger);
43
+ }
44
+ }
45
+ get id() {
46
+ return this._options.id;
47
+ }
48
+ evaluateExpression(expr) {
49
+ const expression = new ReactiveExpression(expr);
50
+ expression.bindState(this.state);
51
+ return expression.value;
52
+ }
53
+ };
54
+ __publicField(_FlowContext, "_defaultOptions", {
55
+ id: DEFAULT_CONTEXT_ID,
56
+ host: DEFAULT_FLOW_HOST,
57
+ enableDebug: false
58
+ });
59
+ let FlowContext = _FlowContext;
60
+
61
+ export { DEFAULT_CONTEXT_ID, FlowContext };
@@ -0,0 +1,70 @@
1
+ import announce from '../utils/announce.mjs';
2
+ import { getGlobal } from '../utils/global.mjs';
3
+ import { ContextRegistry } from './context-registry.mjs';
4
+ import { configure } from 'mobx';
5
+
6
+ var __defProp = Object.defineProperty;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __publicField = (obj, key, value) => {
9
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
10
+ return value;
11
+ };
12
+ class FlowRdfCoreGlobals {
13
+ constructor() {
14
+ /**
15
+ * FlowRdfCoreGlobals version.
16
+ * Compatiblity with other versions loaded in memory as long as this version matches.
17
+ * It indicates that the global state still stores similar information
18
+ *
19
+ * N.B: this version is unrelated to the package version.
20
+ */
21
+ __publicField(this, "version", 1);
22
+ __publicField(this, "globalContextRegistry", new ContextRegistry());
23
+ }
24
+ }
25
+ let canMergeGlobalState = true;
26
+ let isolateCalled = false;
27
+ let globalState = function() {
28
+ const global = getGlobal();
29
+ if (global.__flowRdfCoreInstanceCount > 0 && !global.__flowRdfCoreGlobals) {
30
+ canMergeGlobalState = false;
31
+ }
32
+ if (global.__flowRdfCoreGlobals && global.__flowRdfCoreGlobals.version !== new FlowRdfCoreGlobals().version) {
33
+ canMergeGlobalState = false;
34
+ }
35
+ if (!canMergeGlobalState) {
36
+ setTimeout(() => {
37
+ if (!isolateCalled) {
38
+ throw new Error(
39
+ 'There are multiple, different versions of FlowRdfCore active. Make sure FlowRdfCore is loaded only once or use `configure({ isolateGlobalState: true })`",'
40
+ );
41
+ }
42
+ }, 1);
43
+ return new FlowRdfCoreGlobals();
44
+ } else if (global.__flowRdfCoreGlobals) {
45
+ global.__flowRdfCoreInstanceCount += 1;
46
+ return global.__flowRdfCoreGlobals;
47
+ } else {
48
+ global.__flowRdfCoreInstanceCount = 1;
49
+ configure({
50
+ enforceActions: "never"
51
+ });
52
+ announce();
53
+ return global.__flowRdfCoreGlobals = new FlowRdfCoreGlobals();
54
+ }
55
+ }();
56
+ function isolateGlobalState() {
57
+ isolateCalled = true;
58
+ if (canMergeGlobalState) {
59
+ const global = getGlobal();
60
+ if (--global.__flowRdfCoreInstanceCount === 0) {
61
+ global.__flowRdfCoreGlobals = void 0;
62
+ }
63
+ globalState = new FlowRdfCoreGlobals();
64
+ }
65
+ }
66
+ function getGlobalState() {
67
+ return globalState;
68
+ }
69
+
70
+ export { FlowRdfCoreGlobals, getGlobalState, isolateGlobalState };
@@ -0,0 +1,59 @@
1
+ import Debug from 'debug';
2
+ import { deferred } from '../utils/deferred.mjs';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => {
7
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
+ return value;
9
+ };
10
+ const debug = Debug("flow:map-registry");
11
+ class MapRegistry {
12
+ constructor() {
13
+ __publicField(this, "_maps", /* @__PURE__ */ new Map());
14
+ }
15
+ /**
16
+ * Register a Flo.w map.
17
+ *
18
+ * @param map Map to register.
19
+ */
20
+ registerMap(map) {
21
+ debug(`Registering map '${map.id}'`);
22
+ if (!this._maps.get(map.id)) {
23
+ this._maps.set(map.id, deferred());
24
+ }
25
+ const deferredMap = this._maps.get(map.id);
26
+ deferredMap.resolve(map);
27
+ return map;
28
+ }
29
+ /**
30
+ * Un-register a Flo.w map.
31
+ *
32
+ * ```mermaid
33
+ * graph TB
34
+ * mermaid.js --> TypeDoc;
35
+ * ```
36
+ *
37
+ * @param map - the map to unregister.
38
+ */
39
+ unregisterMap(map) {
40
+ debug(`Unregistering map '${map.id}'`);
41
+ this._maps.delete(map.id);
42
+ }
43
+ /**
44
+ * Retrieve the specified map.
45
+ *
46
+ * This method returns a promise that resolves when the map has been initialized.
47
+ *
48
+ * @param id Map ID.
49
+ */
50
+ getMap(id) {
51
+ if (!this._maps.get(id)) {
52
+ this._maps.set(id, deferred());
53
+ }
54
+ const deferredMap = this._maps.get(id);
55
+ return deferredMap;
56
+ }
57
+ }
58
+
59
+ export { MapRegistry };
@@ -0,0 +1,53 @@
1
+ import Debug from 'debug';
2
+ import { deferred } from '../utils/deferred.mjs';
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
+ var __publicField = (obj, key, value) => {
7
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
8
+ return value;
9
+ };
10
+ const debug = Debug("flow:query-registry");
11
+ class QueryRegistry {
12
+ constructor() {
13
+ __publicField(this, "_queries", /* @__PURE__ */ new Map());
14
+ }
15
+ /**
16
+ * Register a Flo.w reactive query.
17
+ *
18
+ * @param query Query to register.
19
+ */
20
+ registerQuery(query) {
21
+ debug(`Registering query '${query.id}'`);
22
+ if (!this._queries.get(query.id)) {
23
+ this._queries.set(query.id, deferred());
24
+ }
25
+ const deferredQuery = this._queries.get(query.id);
26
+ deferredQuery.resolve(query);
27
+ }
28
+ /**
29
+ * Un-register a Flo.w reactive query.
30
+ *
31
+ * @param query Query to unregister.
32
+ */
33
+ unregisterQuery(query) {
34
+ debug(`Unregistering map '${query.id}'`);
35
+ this._queries.delete(query.id);
36
+ }
37
+ /**
38
+ * Retrieve the specified query.
39
+ *
40
+ * This method returns a promise that resolves when the query has been initialized.
41
+ *
42
+ * @param id Map ID.
43
+ */
44
+ getQuery(id) {
45
+ if (!this._queries.get(id)) {
46
+ this._queries.set(id, deferred());
47
+ }
48
+ const deferredQuery = this._queries.get(id);
49
+ return deferredQuery;
50
+ }
51
+ }
52
+
53
+ export { QueryRegistry };
@@ -0,0 +1,10 @@
1
+ class FlowCoreError extends Error {
2
+ constructor(message, cause) {
3
+ super(message);
4
+ this.cause = cause;
5
+ this.name = this.constructor.name;
6
+ this.cause = cause;
7
+ }
8
+ }
9
+
10
+ export { FlowCoreError };
@@ -0,0 +1,14 @@
1
+ import { FlowCoreError } from './flow-error.mjs';
2
+
3
+ class FlowCoreExpressionError extends FlowCoreError {
4
+ constructor(expression, reason, errors) {
5
+ super(`Failed to evaluate expression:
6
+ ${expression}
7
+ ------
8
+ ${errors.join(", ")}`);
9
+ this.reason = reason;
10
+ this.errors = errors;
11
+ }
12
+ }
13
+
14
+ export { FlowCoreExpressionError };
@@ -0,0 +1,9 @@
1
+ import { FlowCoreError } from './flow-error.mjs';
2
+
3
+ class FlowMapError extends FlowCoreError {
4
+ constructor(message, originalError) {
5
+ super(message, originalError);
6
+ }
7
+ }
8
+
9
+ export { FlowMapError };