@emuanalytics/flow-rdf-core 4.0.0-preview.2 → 4.0.0-preview.4

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.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as mobx from 'mobx';
2
- import { isObservable, isComputed, isObservableArray, isObservableSet, isObservableMap, configure, makeObservable, observable as observable$1, computed as computed$1, action, runInAction, onBecomeObserved, onBecomeUnobserved, reaction, trace } from 'mobx';
2
+ import { isObservable, isComputed, isObservableArray, isObservableSet, isObservableMap, configure, makeObservable, observable as observable$1, computed as computed$1, action, runInAction, onBecomeObserved, onBecomeUnobserved, reaction, toJS, trace } from 'mobx';
3
3
  export { makeAutoObservable, makeObservable } from 'mobx';
4
4
  import Debug from 'debug';
5
5
  import { Client } from '@emuanalytics/flow-engine-client';
@@ -8,13 +8,14 @@ import { R as ReactiveExpression, F as FlowError, f as MapStyleChangeEvent, r as
8
8
  import maplibre from '@emuanalytics/maplibre-gl';
9
9
  import EventEmitter from 'eventemitter3';
10
10
  import { toStream } from 'mobx-utils';
11
- import { t as throttle, a as debounceWithArgs } from './shared/flow-rdf-core.2e456f93.mjs';
12
- import '@emuanalytics/maplibre-gl-style-spec';
11
+ import { t as throttle, a as debounceWithArgs } from './shared/flow-rdf-core.ea06a1d3.mjs';
12
+ import { compressToEncodedURIComponent, decompressFromEncodedURIComponent } from 'lz-string';
13
+ // import '@emuanalytics/maplibre-gl-style-spec';
13
14
  import 'parsimmon';
14
15
  import 'colorbrewer';
15
- import 'nanoid';
16
+ // import 'nanoid';
16
17
 
17
- const version = "4.0.0-preview.2";
18
+ const version = "4.0.0-preview.4";
18
19
 
19
20
  const CONSOLE_HIGHLIGHT_STYLE$1 = `
20
21
  padding: 2px 4px;
@@ -42,18 +43,72 @@ function getGlobal() {
42
43
  return mockGlobal;
43
44
  }
44
45
 
46
+ var __accessCheck = (obj, member, msg) => {
47
+ if (!member.has(obj))
48
+ throw TypeError("Cannot " + msg);
49
+ };
50
+ var __privateGet = (obj, member, getter) => {
51
+ __accessCheck(obj, member, "read from private field");
52
+ return getter ? getter.call(obj) : member.get(obj);
53
+ };
54
+ var __privateAdd = (obj, member, value) => {
55
+ if (member.has(obj))
56
+ throw TypeError("Cannot add the same private member more than once");
57
+ member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
58
+ };
59
+ var __privateSet = (obj, member, value, setter) => {
60
+ __accessCheck(obj, member, "write to private field");
61
+ setter ? setter.call(obj, value) : member.set(obj, value);
62
+ return value;
63
+ };
64
+ var _value, _settled, _status;
65
+ class WatchablePromise extends Promise {
66
+ constructor(executor) {
67
+ super((resolve, reject) => {
68
+ executor(
69
+ (value) => {
70
+ resolve(value);
71
+ __privateSet(this, _value, value);
72
+ __privateSet(this, _settled, true);
73
+ __privateSet(this, _status, "fulfilled");
74
+ },
75
+ (reason) => {
76
+ reject(reason);
77
+ __privateSet(this, _settled, true);
78
+ __privateSet(this, _status, "rejected");
79
+ }
80
+ );
81
+ });
82
+ __privateAdd(this, _value, void 0);
83
+ __privateAdd(this, _settled, false);
84
+ __privateAdd(this, _status, "pending");
85
+ }
86
+ get settled() {
87
+ return __privateGet(this, _settled);
88
+ }
89
+ get status() {
90
+ return __privateGet(this, _status);
91
+ }
92
+ get value() {
93
+ return __privateGet(this, _value);
94
+ }
95
+ }
96
+ _value = new WeakMap();
97
+ _settled = new WeakMap();
98
+ _status = new WeakMap();
99
+
45
100
  function deferred() {
46
101
  let methods;
47
- const promise = new Promise((resolve, reject) => {
102
+ const promise = new WatchablePromise((resolve, reject) => {
48
103
  methods = { resolve, reject };
49
104
  });
50
105
  return Object.assign(promise, methods);
51
106
  }
52
107
 
53
- var __defProp$d = Object.defineProperty;
54
- var __defNormalProp$d = (obj, key, value) => key in obj ? __defProp$d(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
55
- var __publicField$d = (obj, key, value) => {
56
- __defNormalProp$d(obj, typeof key !== "symbol" ? key + "" : key, value);
108
+ var __defProp$c = Object.defineProperty;
109
+ var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
110
+ var __publicField$c = (obj, key, value) => {
111
+ __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
57
112
  return value;
58
113
  };
59
114
  const FLOW_GLOBAL = "FDBG";
@@ -74,8 +129,8 @@ class Debugger {
74
129
  */
75
130
  constructor(context) {
76
131
  this.context = context;
77
- __publicField$d(this, "spyDisposer");
78
- __publicField$d(this, "watchDisposers", {});
132
+ __publicField$c(this, "spyDisposer");
133
+ __publicField$c(this, "watchDisposers", {});
79
134
  }
80
135
  /**
81
136
  * Install a 'watch' for the specified context state property path.
@@ -163,7 +218,7 @@ class Debugger {
163
218
  return Array.from(this.context.maps._maps.keys());
164
219
  }
165
220
  const mapPromise = this.context.maps.getMap(mapId);
166
- return mapPromise?.__zone_symbol__value;
221
+ return mapPromise?.value;
167
222
  }
168
223
  /**
169
224
  * Get a registered reactive query by ID.
@@ -173,7 +228,7 @@ class Debugger {
173
228
  return Array.from(this.context.queries._queries.keys());
174
229
  }
175
230
  const queryPromise = this.context.queries.getQuery(queryId);
176
- return queryPromise?.__zone_symbol__value;
231
+ return queryPromise?.value;
177
232
  }
178
233
  spyListener(event) {
179
234
  console.log(`%cspy`, CONSOLE_HIGHLIGHT_STYLE, event);
@@ -191,6 +246,7 @@ function installGlobalDebugger(dbg) {
191
246
  );
192
247
  const g = typeof global !== "undefined" ? global : window;
193
248
  g[FLOW_GLOBAL] = g[FLOW_GLOBAL] || {
249
+ context: dbg.context,
194
250
  watch: dbg.watch.bind(dbg),
195
251
  unwatch: dbg.unwatch.bind(dbg),
196
252
  set: dbg.set.bind(dbg),
@@ -284,16 +340,16 @@ function toJSHelper(source, options, __alreadySeen = null) {
284
340
  return res;
285
341
  }
286
342
 
287
- var __defProp$c = Object.defineProperty;
288
- var __defNormalProp$c = (obj, key, value) => key in obj ? __defProp$c(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
289
- var __publicField$c = (obj, key, value) => {
290
- __defNormalProp$c(obj, typeof key !== "symbol" ? key + "" : key, value);
343
+ var __defProp$b = Object.defineProperty;
344
+ var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
345
+ var __publicField$b = (obj, key, value) => {
346
+ __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
291
347
  return value;
292
348
  };
293
349
  const debug$4 = Debug("flow:map-registry");
294
350
  class MapRegistry {
295
351
  constructor() {
296
- __publicField$c(this, "_maps", /* @__PURE__ */ new Map());
352
+ __publicField$b(this, "_maps", /* @__PURE__ */ new Map());
297
353
  }
298
354
  /**
299
355
  * Register a Flo.w map.
@@ -335,16 +391,16 @@ class MapRegistry {
335
391
  }
336
392
  }
337
393
 
338
- var __defProp$b = Object.defineProperty;
339
- var __defNormalProp$b = (obj, key, value) => key in obj ? __defProp$b(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
340
- var __publicField$b = (obj, key, value) => {
341
- __defNormalProp$b(obj, typeof key !== "symbol" ? key + "" : key, value);
394
+ var __defProp$a = Object.defineProperty;
395
+ var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
396
+ var __publicField$a = (obj, key, value) => {
397
+ __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
342
398
  return value;
343
399
  };
344
400
  const debug$3 = Debug("flow:query-registry");
345
401
  class QueryRegistry {
346
402
  constructor() {
347
- __publicField$b(this, "_queries", /* @__PURE__ */ new Map());
403
+ __publicField$a(this, "_queries", /* @__PURE__ */ new Map());
348
404
  }
349
405
  /**
350
406
  * Register a Flo.w reactive query.
@@ -384,10 +440,10 @@ class QueryRegistry {
384
440
  }
385
441
  }
386
442
 
387
- var __defProp$a = Object.defineProperty;
388
- var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
389
- var __publicField$a = (obj, key, value) => {
390
- __defNormalProp$a(obj, typeof key !== "symbol" ? key + "" : key, value);
443
+ var __defProp$9 = Object.defineProperty;
444
+ var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
445
+ var __publicField$9 = (obj, key, value) => {
446
+ __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
391
447
  return value;
392
448
  };
393
449
  const DEFAULT_FLOW_HOST = "https://flow.emu-analytics.net";
@@ -404,13 +460,13 @@ const _FlowContext = class _FlowContext {
404
460
  * @param enableDebug Set to `true` to enable the debugger.
405
461
  */
406
462
  constructor(options) {
407
- __publicField$a(this, "_options");
408
- __publicField$a(this, "flowClient");
409
- __publicField$a(this, "state");
410
- __publicField$a(this, "maps", new MapRegistry());
411
- __publicField$a(this, "queries", new QueryRegistry());
463
+ __publicField$9(this, "_options");
464
+ __publicField$9(this, "flowClient");
465
+ __publicField$9(this, "state");
466
+ __publicField$9(this, "maps", new MapRegistry());
467
+ __publicField$9(this, "queries", new QueryRegistry());
412
468
  /** The Flo.w debugger. Available as `window.FDBG` in the browser's web developer console. */
413
- __publicField$a(this, "debugger");
469
+ __publicField$9(this, "debugger");
414
470
  this._options = {
415
471
  ..._FlowContext._defaultOptions,
416
472
  ...options
@@ -434,23 +490,23 @@ const _FlowContext = class _FlowContext {
434
490
  return expression.value;
435
491
  }
436
492
  };
437
- __publicField$a(_FlowContext, "_defaultOptions", {
493
+ __publicField$9(_FlowContext, "_defaultOptions", {
438
494
  id: DEFAULT_CONTEXT_ID,
439
495
  host: DEFAULT_FLOW_HOST,
440
496
  enableDebug: false
441
497
  });
442
498
  let FlowContext = _FlowContext;
443
499
 
444
- var __defProp$9 = Object.defineProperty;
445
- var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
446
- var __publicField$9 = (obj, key, value) => {
447
- __defNormalProp$9(obj, typeof key !== "symbol" ? key + "" : key, value);
500
+ var __defProp$8 = Object.defineProperty;
501
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
502
+ var __publicField$8 = (obj, key, value) => {
503
+ __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
448
504
  return value;
449
505
  };
450
506
  const debug$2 = Debug("flow:context-registry");
451
507
  const _ContextRegistry = class _ContextRegistry {
452
508
  constructor() {
453
- __publicField$9(this, "_contexts", /* @__PURE__ */ new Map());
509
+ __publicField$8(this, "_contexts", /* @__PURE__ */ new Map());
454
510
  }
455
511
  /**
456
512
  * Initialize a new Flo.w context.
@@ -493,16 +549,16 @@ const _ContextRegistry = class _ContextRegistry {
493
549
  return deferredContext?.deferred;
494
550
  }
495
551
  };
496
- __publicField$9(_ContextRegistry, "_defaultOptions", {
552
+ __publicField$8(_ContextRegistry, "_defaultOptions", {
497
553
  id: DEFAULT_CONTEXT_ID,
498
554
  host: "https://flow.emu-analytics.net"
499
555
  });
500
556
  let ContextRegistry = _ContextRegistry;
501
557
 
502
- var __defProp$8 = Object.defineProperty;
503
- var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
504
- var __publicField$8 = (obj, key, value) => {
505
- __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
558
+ var __defProp$7 = Object.defineProperty;
559
+ var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
560
+ var __publicField$7 = (obj, key, value) => {
561
+ __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
506
562
  return value;
507
563
  };
508
564
  class FlowRdfCoreGlobals {
@@ -514,8 +570,8 @@ class FlowRdfCoreGlobals {
514
570
  *
515
571
  * N.B: this version is unrelated to the package version.
516
572
  */
517
- __publicField$8(this, "version", 1);
518
- __publicField$8(this, "globalContextRegistry", new ContextRegistry());
573
+ __publicField$7(this, "version", 1);
574
+ __publicField$7(this, "globalContextRegistry", new ContextRegistry());
519
575
  }
520
576
  }
521
577
  let canMergeGlobalState = true;
@@ -563,15 +619,15 @@ function getGlobalState() {
563
619
  return globalState;
564
620
  }
565
621
 
566
- var __defProp$7 = Object.defineProperty;
567
- var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
568
- var __publicField$7 = (obj, key, value) => {
569
- __defNormalProp$7(obj, typeof key !== "symbol" ? key + "" : key, value);
622
+ var __defProp$6 = Object.defineProperty;
623
+ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
624
+ var __publicField$6 = (obj, key, value) => {
625
+ __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
570
626
  return value;
571
627
  };
572
628
  class MapLayerStyleBuilder {
573
629
  constructor() {
574
- __publicField$7(this, "_styles", /* @__PURE__ */ new Map());
630
+ __publicField$6(this, "_styles", /* @__PURE__ */ new Map());
575
631
  }
576
632
  static registerStyleBuilder(layerType, builder) {
577
633
  this._styleBuilders.set(layerType, builder);
@@ -629,11 +685,11 @@ class MapLayerStyleBuilder {
629
685
  }
630
686
  }
631
687
  }
632
- __publicField$7(MapLayerStyleBuilder, "_styleBuilders", /* @__PURE__ */ new Map());
688
+ __publicField$6(MapLayerStyleBuilder, "_styleBuilders", /* @__PURE__ */ new Map());
633
689
  class StyleExpression {
634
690
  constructor(_expr) {
635
691
  this._expr = _expr;
636
- __publicField$7(this, "__styleExpression", "styleexpression");
692
+ __publicField$6(this, "__styleExpression", "styleexpression");
637
693
  }
638
694
  toString() {
639
695
  return this._expr;
@@ -1950,19 +2006,19 @@ function layerStyle(layerType) {
1950
2006
  return MapLayerStyleBuilder.createStyleBuilder(layerType);
1951
2007
  }
1952
2008
 
1953
- var __defProp$6 = Object.defineProperty;
1954
- var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
1955
- var __publicField$6 = (obj, key, value) => {
1956
- __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
2009
+ var __defProp$5 = Object.defineProperty;
2010
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2011
+ var __publicField$5 = (obj, key, value) => {
2012
+ __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
1957
2013
  return value;
1958
2014
  };
1959
2015
  const _MapStyle = class _MapStyle {
1960
2016
  constructor() {
1961
- __publicField$6(this, "_state", null);
1962
- __publicField$6(this, "_baseStyle");
1963
- __publicField$6(this, "_sources", {});
1964
- __publicField$6(this, "_layers", {});
1965
- __publicField$6(this, "_layerOrder", []);
2017
+ __publicField$5(this, "_state", null);
2018
+ __publicField$5(this, "_baseStyle");
2019
+ __publicField$5(this, "_sources", {});
2020
+ __publicField$5(this, "_layers", {});
2021
+ __publicField$5(this, "_layerOrder", []);
1966
2022
  this._baseStyle = _MapStyle._defaultBaseStyle;
1967
2023
  makeObservable(
1968
2024
  this,
@@ -2114,7 +2170,7 @@ const _MapStyle = class _MapStyle {
2114
2170
  return insertionIndex;
2115
2171
  }
2116
2172
  };
2117
- __publicField$6(_MapStyle, "_defaultBaseStyle", Object.freeze({
2173
+ __publicField$5(_MapStyle, "_defaultBaseStyle", Object.freeze({
2118
2174
  version: 8,
2119
2175
  id: "default",
2120
2176
  name: "Default base style",
@@ -2123,18 +2179,18 @@ __publicField$6(_MapStyle, "_defaultBaseStyle", Object.freeze({
2123
2179
  }));
2124
2180
  let MapStyle = _MapStyle;
2125
2181
 
2126
- var __defProp$5 = Object.defineProperty;
2127
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2128
- var __publicField$5 = (obj, key, value) => {
2129
- __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
2182
+ var __defProp$4 = Object.defineProperty;
2183
+ var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2184
+ var __publicField$4 = (obj, key, value) => {
2185
+ __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
2130
2186
  return value;
2131
2187
  };
2132
2188
  Debug("flow:image-registry");
2133
2189
  const unknownImageSVG = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' class='flowicon'%3E%3C!--! Font Awesome Free 6.1.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc.--%3E%3Cpath d='M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256 256-114.6 256-256S397.4 0 256 0zm0 400c-18 0-32-14-32-32s13.1-32 32-32c17.1 0 32 14 32 32s-14.9 32-32 32zm69.1-142L280 286v2c0 13-11 24-24 24s-24-11-24-24v-16c0-8 4-16 12-21l57-34c7-4 11-11 11-19 0-12-10.9-22-22.9-22H238c-12.9 0-22 10-22 22 0 13-11 24-24 24s-24-11-24-24c0-39 31-70 69.1-70h51.1c40.8 0 71.8 31 71.8 70 0 24-13 47-34.9 60z'/%3E%3C/svg%3E`;
2134
2190
  class ImageRegistry {
2135
2191
  constructor() {
2136
- __publicField$5(this, "_registry", /* @__PURE__ */ new Map());
2137
- __publicField$5(this, "_unknownImage", null);
2192
+ __publicField$4(this, "_registry", /* @__PURE__ */ new Map());
2193
+ __publicField$4(this, "_unknownImage", null);
2138
2194
  }
2139
2195
  get unknownImage() {
2140
2196
  if (!this._unknownImage) {
@@ -2202,10 +2258,10 @@ class ImageRegistry {
2202
2258
  }
2203
2259
  }
2204
2260
 
2205
- var __defProp$4 = Object.defineProperty;
2206
- var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2207
- var __publicField$4 = (obj, key, value) => {
2208
- __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
2261
+ var __defProp$3 = Object.defineProperty;
2262
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2263
+ var __publicField$3 = (obj, key, value) => {
2264
+ __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
2209
2265
  return value;
2210
2266
  };
2211
2267
  const debug$1 = Debug("flow:map");
@@ -2213,24 +2269,20 @@ const MOUSE_MOVE_THROTTLE_DURATION = 100;
2213
2269
  const _FlowMap = class _FlowMap extends EventEmitter {
2214
2270
  constructor(options) {
2215
2271
  super();
2216
- __publicField$4(this, "_context");
2217
- __publicField$4(this, "_initialized");
2218
- __publicField$4(this, "_loading", true);
2219
- __publicField$4(this, "_debouncedEmitSourceEvent");
2220
- __publicField$4(this, "_imageRegistry", new ImageRegistry());
2221
- __publicField$4(this, "_options");
2222
- __publicField$4(this, "_pluginManager");
2223
- __publicField$4(this, "_resolveInitialized", () => {
2272
+ __publicField$3(this, "_context");
2273
+ __publicField$3(this, "_initialized");
2274
+ __publicField$3(this, "_loading", true);
2275
+ __publicField$3(this, "_debouncedEmitSourceEvent");
2276
+ __publicField$3(this, "_imageRegistry", new ImageRegistry());
2277
+ __publicField$3(this, "_options");
2278
+ __publicField$3(this, "_pluginManager");
2279
+ __publicField$3(this, "_resolveInitialized", () => {
2224
2280
  });
2225
- __publicField$4(this, "_style");
2226
- __publicField$4(this, "_styleUpdateSubscription", null);
2227
- __publicField$4(this, "_throttledMouseMove", throttle(this.handleMouseMove, {
2228
- delay: MOUSE_MOVE_THROTTLE_DURATION,
2229
- noLeading: true,
2230
- context: this
2231
- }));
2232
- __publicField$4(this, "maplibreMap");
2233
- __publicField$4(this, "updateMapStyle", (style) => {
2281
+ __publicField$3(this, "_style");
2282
+ __publicField$3(this, "_styleUpdateSubscription", null);
2283
+ __publicField$3(this, "_throttledMouseMove", throttle(this.handleMouseMove, MOUSE_MOVE_THROTTLE_DURATION, { context: this }));
2284
+ __publicField$3(this, "maplibreMap");
2285
+ __publicField$3(this, "updateMapStyle", (style) => {
2234
2286
  const oldStyle = this.maplibreMap.getStyle();
2235
2287
  const beforeEvent = new MapStyleChangeEvent("beforeStyleChanged", this, oldStyle, style);
2236
2288
  style = this._pluginManager.forwardStyleChangeEvent(
@@ -2247,8 +2299,7 @@ const _FlowMap = class _FlowMap extends EventEmitter {
2247
2299
  ...options
2248
2300
  };
2249
2301
  this._style = new MapStyle();
2250
- this._debouncedEmitSourceEvent = debounceWithArgs(this.emitEvent, {
2251
- delay: 20,
2302
+ this._debouncedEmitSourceEvent = debounceWithArgs(this.emitEvent, 20, {
2252
2303
  hash: (event) => event.source,
2253
2304
  context: this
2254
2305
  });
@@ -2273,6 +2324,14 @@ const _FlowMap = class _FlowMap extends EventEmitter {
2273
2324
  get styleSpecification() {
2274
2325
  return this._style.styleSpecification;
2275
2326
  }
2327
+ /**
2328
+ * @internal
2329
+ *
2330
+ * Used by map export to get images added to map.
2331
+ */
2332
+ get imageRegistry() {
2333
+ return this._imageRegistry;
2334
+ }
2276
2335
  addLayer(layerOrOptions) {
2277
2336
  const layer = isPlainObject(layerOrOptions) ? new MapLayer(layerOrOptions) : layerOrOptions;
2278
2337
  this._style.addLayer(layer);
@@ -2433,9 +2492,9 @@ const _FlowMap = class _FlowMap extends EventEmitter {
2433
2492
  }
2434
2493
  const options = {
2435
2494
  center: lngLat,
2436
- ...center.zoom && { zoom: center.zoom },
2437
- ...center.bearing && { bearing: center.bearing },
2438
- ...center.pitch && { pitch: center.pitch },
2495
+ ...isDefined(center.zoom) && { zoom: center.zoom },
2496
+ ...isDefined(center.bearing) && { bearing: center.bearing },
2497
+ ...isDefined(center.pitch) && { pitch: center.pitch },
2439
2498
  ...animationOptions
2440
2499
  };
2441
2500
  method.call(this.maplibreMap, options);
@@ -2453,6 +2512,17 @@ const _FlowMap = class _FlowMap extends EventEmitter {
2453
2512
  };
2454
2513
  this.maplibreMap.fitBounds(bounds, fitBoundsOptions);
2455
2514
  }
2515
+ getVisibleBounds() {
2516
+ const parentEl = this.container.parentElement;
2517
+ if (!parentEl) {
2518
+ return this.getBounds();
2519
+ }
2520
+ const mapRect = parentEl.getBoundingClientRect();
2521
+ const topLeft = this.maplibreMap.unproject([mapRect.x, mapRect.y]);
2522
+ const bottomRight = this.maplibreMap.unproject([mapRect.x + mapRect.width, mapRect.y + mapRect.height]);
2523
+ const bounds = [topLeft.lng, bottomRight.lat, bottomRight.lng, topLeft.lat];
2524
+ return bounds;
2525
+ }
2456
2526
  /**
2457
2527
  * Programmatically set feature state properties for a map feature.
2458
2528
  *
@@ -2627,23 +2697,23 @@ const _FlowMap = class _FlowMap extends EventEmitter {
2627
2697
  return requestParameters;
2628
2698
  }
2629
2699
  };
2630
- __publicField$4(_FlowMap, "_defaultOptions", {
2700
+ __publicField$3(_FlowMap, "_defaultOptions", {
2631
2701
  boxZoom: false,
2632
2702
  doubleClickZoom: false,
2633
2703
  featureClickTolerance: 0
2634
2704
  });
2635
2705
  let FlowMap = _FlowMap;
2636
2706
 
2637
- var __defProp$3 = Object.defineProperty;
2638
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2639
- var __publicField$3 = (obj, key, value) => {
2640
- __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
2707
+ var __defProp$2 = Object.defineProperty;
2708
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2709
+ var __publicField$2 = (obj, key, value) => {
2710
+ __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
2641
2711
  return value;
2642
2712
  };
2643
2713
  class AsyncCommitter {
2644
2714
  constructor() {
2645
- __publicField$3(this, "_requestId", 0);
2646
- __publicField$3(this, "_commitId", 0);
2715
+ __publicField$2(this, "_requestId", 0);
2716
+ __publicField$2(this, "_commitId", 0);
2647
2717
  }
2648
2718
  async resolve(promise) {
2649
2719
  this._requestId += 1;
@@ -2663,10 +2733,10 @@ class AsyncCommitter {
2663
2733
  }
2664
2734
  }
2665
2735
 
2666
- var __defProp$2 = Object.defineProperty;
2667
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2668
- var __publicField$2 = (obj, key, value) => {
2669
- __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
2736
+ var __defProp$1 = Object.defineProperty;
2737
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2738
+ var __publicField$1 = (obj, key, value) => {
2739
+ __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
2670
2740
  return value;
2671
2741
  };
2672
2742
  const debug = Debug("flow:query");
@@ -2674,13 +2744,13 @@ const DEFAULT_DELAY = 100;
2674
2744
  const _Query = class _Query {
2675
2745
  constructor(queryFn, transformFn, options) {
2676
2746
  this.queryFn = queryFn;
2677
- __publicField$2(this, "_options");
2678
- __publicField$2(this, "_committer", new AsyncCommitter());
2679
- __publicField$2(this, "_disposer", null);
2680
- __publicField$2(this, "_transformFn", (results) => results);
2681
- __publicField$2(this, "results", null);
2682
- __publicField$2(this, "busy", false);
2683
- __publicField$2(this, "error", null);
2747
+ __publicField$1(this, "_options");
2748
+ __publicField$1(this, "_committer", new AsyncCommitter());
2749
+ __publicField$1(this, "_disposer", null);
2750
+ __publicField$1(this, "_transformFn", (results) => results);
2751
+ __publicField$1(this, "results", null);
2752
+ __publicField$1(this, "busy", false);
2753
+ __publicField$1(this, "error", null);
2684
2754
  this._options = {
2685
2755
  ..._Query._defaultOptions,
2686
2756
  ...options
@@ -2791,7 +2861,7 @@ const _Query = class _Query {
2791
2861
  }
2792
2862
  }
2793
2863
  };
2794
- __publicField$2(_Query, "_defaultOptions", {
2864
+ __publicField$1(_Query, "_defaultOptions", {
2795
2865
  fireImmediately: true,
2796
2866
  delay: DEFAULT_DELAY
2797
2867
  });
@@ -2877,67 +2947,59 @@ function hasProp(target, prop) {
2877
2947
 
2878
2948
  const SYNC_ANNOTATION_TYPE = "state-sync-annotation";
2879
2949
  const REACTIVE_ANNOTATION_TYPE = "state-reactive-annotation";
2880
- const serializeString = {
2950
+ const serializeRaw = {
2881
2951
  annotationType: SYNC_ANNOTATION_TYPE,
2882
2952
  serialize(val) {
2883
- return val.toString();
2953
+ return toJS(val);
2884
2954
  },
2885
2955
  deserialize(val) {
2886
- return val.toString();
2956
+ return val;
2887
2957
  }
2888
2958
  };
2889
- const serializeNumber = {
2959
+ const serializeString = {
2890
2960
  annotationType: SYNC_ANNOTATION_TYPE,
2891
2961
  serialize(val) {
2892
2962
  return val.toString();
2893
2963
  },
2894
2964
  deserialize(val) {
2895
- return +val;
2965
+ return val;
2896
2966
  }
2897
2967
  };
2898
- const serializeStringArray = {
2968
+ const serializeNumber = {
2899
2969
  annotationType: SYNC_ANNOTATION_TYPE,
2900
2970
  serialize(val) {
2901
- return val.join(",");
2971
+ return val.toString();
2902
2972
  },
2903
2973
  deserialize(val) {
2904
- return val.split(",");
2974
+ return +val;
2905
2975
  }
2906
2976
  };
2907
- const serializeNumberArray = {
2977
+ const serializeJson = {
2908
2978
  annotationType: SYNC_ANNOTATION_TYPE,
2909
2979
  serialize(val) {
2910
- return val.join(",");
2980
+ return JSON.stringify(val);
2911
2981
  },
2912
2982
  deserialize(val) {
2913
- return val.split(",").map((n) => +n);
2983
+ return JSON.parse(val);
2914
2984
  }
2915
2985
  };
2916
2986
  const serializeState = {
2917
2987
  annotationType: SYNC_ANNOTATION_TYPE,
2918
2988
  serialize(val) {
2919
- const props = val.serialize();
2920
- const entries = Object.entries(props).map((entry) => `${entry[0]}=${entry[1]}`);
2921
- return entries.join(",");
2989
+ return val.serialize();
2922
2990
  },
2923
2991
  deserialize(val, target) {
2924
- const entries = val.split(",").reduce((accum, entry) => {
2925
- const parts = entry.split("=");
2926
- assert(parts.length === 2);
2927
- accum[parts[0]] = parts[1];
2928
- return accum;
2929
- }, {});
2930
- target.deserialize(entries);
2992
+ target.deserialize(val);
2931
2993
  return target;
2932
2994
  }
2933
2995
  };
2934
- const serialize = {
2996
+ const serialize = Object.assign(createDecoratorAnnotation(serializeRaw), {
2997
+ raw: createDecoratorAnnotation(serializeRaw),
2935
2998
  string: createDecoratorAnnotation(serializeString),
2936
2999
  number: createDecoratorAnnotation(serializeNumber),
2937
- stringArray: createDecoratorAnnotation(serializeStringArray),
2938
- numberArray: createDecoratorAnnotation(serializeNumberArray),
3000
+ json: createDecoratorAnnotation(serializeJson),
2939
3001
  state: createDecoratorAnnotation(serializeState)
2940
- };
3002
+ });
2941
3003
  function createReactiveAnnotation(mobxAnnotation) {
2942
3004
  return createDecoratorAnnotation({
2943
3005
  annotationType: REACTIVE_ANNOTATION_TYPE,
@@ -2945,45 +3007,15 @@ function createReactiveAnnotation(mobxAnnotation) {
2945
3007
  });
2946
3008
  }
2947
3009
  const observable = Object.assign(createReactiveAnnotation(mobx.observable), {
3010
+ deep: createReactiveAnnotation(mobx.observable.deep),
2948
3011
  ref: createReactiveAnnotation(mobx.observable.ref),
2949
- struct: createReactiveAnnotation(mobx.observable.ref),
3012
+ struct: createReactiveAnnotation(mobx.observable.struct),
2950
3013
  shallow: createReactiveAnnotation(mobx.observable.shallow)
2951
3014
  });
2952
3015
  const computed = Object.assign(createReactiveAnnotation(mobx.computed), {
2953
3016
  struct: createReactiveAnnotation(mobx.computed.struct)
2954
3017
  });
2955
3018
 
2956
- var __defProp$1 = Object.defineProperty;
2957
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2958
- var __publicField$1 = (obj, key, value) => {
2959
- __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
2960
- return value;
2961
- };
2962
- class Serializer {
2963
- constructor(target) {
2964
- __publicField$1(this, "target");
2965
- this.target = target;
2966
- }
2967
- }
2968
- class UrlSerializer extends Serializer {
2969
- constructor(target) {
2970
- super(target);
2971
- }
2972
- serialize(vals) {
2973
- const searchParams = new URLSearchParams(window.location.search);
2974
- Object.keys(vals).forEach((key) => searchParams.set(key, vals[key]));
2975
- const queryString = searchParams.toString();
2976
- const newUrl = queryString.length ? `${location.pathname}?${queryString}` : location.pathname;
2977
- window.history.replaceState(vals, "", newUrl);
2978
- }
2979
- deserialize() {
2980
- const searchParams = new URLSearchParams(window.location.search);
2981
- const values = {};
2982
- searchParams.forEach((val, key) => values[key] = val);
2983
- return values;
2984
- }
2985
- }
2986
-
2987
3019
  var __defProp = Object.defineProperty;
2988
3020
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
2989
3021
  var __publicField = (obj, key, value) => {
@@ -2995,7 +3027,6 @@ const StateStorCache = Symbol("FlowCoreStateStorCache");
2995
3027
  class StateStore {
2996
3028
  constructor() {
2997
3029
  __publicField(this, "serializationAnnotations", {});
2998
- __publicField(this, "serializer", new UrlSerializer(this));
2999
3030
  __publicField(this, "id");
3000
3031
  this.id = randomId("state");
3001
3032
  }
@@ -3113,7 +3144,7 @@ class StateStore {
3113
3144
  if (!annotations) {
3114
3145
  annotations = {};
3115
3146
  let current = target;
3116
- while (current && !current.hasOwnProperty(StateStoreMarker)) {
3147
+ while (current && !Object.prototype.hasOwnProperty.call(current, StateStoreMarker)) {
3117
3148
  Reflect.ownKeys(current).forEach((k) => {
3118
3149
  annotations[k] = !overrides ? true : k in overrides ? overrides[k] : true;
3119
3150
  });
@@ -3133,33 +3164,48 @@ class StateStore {
3133
3164
  };
3134
3165
  return mobx.makeObservable(target, annotations, { name: this.formattedName });
3135
3166
  }
3136
- serialize() {
3167
+ serialize(format = "raw") {
3137
3168
  const annotations = this.serializationAnnotations;
3138
3169
  const serializedProps = Object.keys(annotations).reduce((accum, prop) => {
3139
- accum[prop] = annotations[prop].serialize(this[prop]);
3170
+ const val = this[prop];
3171
+ if (isDefined(val)) {
3172
+ const serializedValue = annotations[prop].serialize(val);
3173
+ accum[prop] = serializedValue;
3174
+ }
3140
3175
  return accum;
3141
3176
  }, {});
3142
- return serializedProps;
3143
- }
3144
- deserialize(values) {
3177
+ switch (format) {
3178
+ case "json":
3179
+ return JSON.stringify(serializedProps);
3180
+ case "lz":
3181
+ return compressToEncodedURIComponent(JSON.stringify(serializedProps));
3182
+ default:
3183
+ return serializedProps;
3184
+ }
3185
+ }
3186
+ deserialize(value, format = "raw") {
3187
+ let deserializedValue;
3188
+ switch (format) {
3189
+ case "json":
3190
+ deserializedValue = JSON.parse(value);
3191
+ break;
3192
+ case "lz":
3193
+ deserializedValue = JSON.parse(decompressFromEncodedURIComponent(value));
3194
+ break;
3195
+ default:
3196
+ deserializedValue = value;
3197
+ break;
3198
+ }
3145
3199
  this.transaction(() => {
3146
3200
  const annotations = this.serializationAnnotations;
3147
- Object.keys(values).forEach((prop) => {
3201
+ Object.keys(deserializedValue).forEach((prop) => {
3148
3202
  const annotation = annotations[prop];
3149
3203
  if (annotation) {
3150
- this[prop] = annotation.deserialize(values[prop], this[prop]);
3204
+ this[prop] = annotation.deserialize(deserializedValue[prop], this[prop]);
3151
3205
  }
3152
3206
  });
3153
3207
  });
3154
3208
  }
3155
- startSerialization() {
3156
- const deserializedValues = this.serializer.deserialize();
3157
- this.deserialize(deserializedValues);
3158
- this.autorun(() => {
3159
- const serialiedValues = this.serialize();
3160
- this.serializer.serialize(serialiedValues);
3161
- });
3162
- }
3163
3209
  checkInitialized() {
3164
3210
  if (!this.initialized) {
3165
3211
  throw new FlowError(