@accelint/map-toolkit 0.1.0 → 0.2.0
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/CHANGELOG.md +29 -0
- package/README.md +91 -18
- package/catalog-info.yaml +13 -10
- package/dist/deckgl/base-map/index.d.ts +91 -8
- package/dist/deckgl/base-map/index.js +26 -20
- package/dist/deckgl/base-map/index.js.map +1 -1
- package/dist/deckgl/base-map/provider.d.ts +133 -0
- package/dist/deckgl/base-map/provider.js +22 -0
- package/dist/deckgl/base-map/provider.js.map +1 -0
- package/dist/deckgl/base-map/types.d.ts +40 -0
- package/dist/deckgl/index.d.ts +3 -2
- package/dist/deckgl/index.js +1 -1
- package/dist/deckgl/text-layer/character-sets.d.ts +20 -0
- package/dist/deckgl/text-layer/character-sets.js +36 -0
- package/dist/deckgl/text-layer/character-sets.js.map +1 -0
- package/dist/deckgl/text-layer/default-settings.d.ts +5 -0
- package/dist/deckgl/text-layer/default-settings.js +23 -0
- package/dist/deckgl/text-layer/default-settings.js.map +1 -0
- package/dist/deckgl/text-layer/fiber.d.ts +31 -0
- package/dist/deckgl/text-layer/fiber.js +6 -0
- package/dist/deckgl/text-layer/fiber.js.map +1 -0
- package/dist/deckgl/text-layer/index.d.ts +43 -0
- package/dist/deckgl/text-layer/index.js +33 -0
- package/dist/deckgl/text-layer/index.js.map +1 -0
- package/dist/decorators/deckgl.js +3 -1
- package/dist/decorators/deckgl.js.map +1 -1
- package/dist/map-mode/events.d.ts +37 -0
- package/dist/map-mode/events.js +15 -0
- package/dist/map-mode/events.js.map +1 -0
- package/dist/map-mode/index.d.ts +6 -0
- package/dist/map-mode/index.js +5 -0
- package/dist/map-mode/index.js.map +1 -0
- package/dist/map-mode/store.d.ts +122 -0
- package/dist/map-mode/store.js +327 -0
- package/dist/map-mode/store.js.map +1 -0
- package/dist/map-mode/types.d.ts +83 -0
- package/dist/map-mode/types.js +3 -0
- package/dist/map-mode/types.js.map +1 -0
- package/dist/map-mode/use-map-mode.d.ts +54 -0
- package/dist/map-mode/use-map-mode.js +31 -0
- package/dist/map-mode/use-map-mode.js.map +1 -0
- package/dist/maplibre/hooks/use-maplibre.d.ts +34 -0
- package/dist/maplibre/hooks/use-maplibre.js +3 -2
- package/dist/maplibre/hooks/use-maplibre.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +43 -36
- package/dist/test/setup.d.ts +0 -2
- package/dist/test/setup.js +0 -11
- package/dist/test/setup.js.map +0 -1
|
@@ -1,21 +1,61 @@
|
|
|
1
1
|
import { Payload } from '@accelint/bus';
|
|
2
|
+
import { UniqueId } from '@accelint/core';
|
|
2
3
|
import { PickingInfo } from '@deck.gl/core';
|
|
3
4
|
import { MjolnirGestureEvent, MjolnirPointerEvent } from 'mjolnir.js';
|
|
4
5
|
import { MapEvents } from './events.js';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* PickingInfo without the viewport property, as it cannot be serialized through the event bus.
|
|
9
|
+
* The viewport contains function properties that would break serialization.
|
|
10
|
+
*/
|
|
6
11
|
type NonFuncPickingInfo = Omit<PickingInfo, 'viewport'>;
|
|
12
|
+
/**
|
|
13
|
+
* MjolnirGestureEvent without function properties and non-serializable objects.
|
|
14
|
+
* These properties are omitted to allow the event to be serialized through the event bus.
|
|
15
|
+
*/
|
|
7
16
|
type NonFuncMjolnirGestureEvent = Omit<MjolnirGestureEvent, 'stopPropagation' | 'preventDefault' | 'stopImmediatePropagation' | 'srcEvent' | 'rootElement' | 'target' | 'changedPointers' | 'pointers'>;
|
|
17
|
+
/**
|
|
18
|
+
* MjolnirPointerEvent without function properties and non-serializable objects.
|
|
19
|
+
* These properties are omitted to allow the event to be serialized through the event bus.
|
|
20
|
+
*/
|
|
8
21
|
type NonFuncMjolnirPointerEvent = Omit<MjolnirPointerEvent, 'stopPropagation' | 'preventDefault' | 'stopImmediatePropagation' | 'srcEvent' | 'rootElement' | 'target'>;
|
|
22
|
+
/**
|
|
23
|
+
* Payload for map click events emitted through the event bus.
|
|
24
|
+
* Contains picking information about what was clicked and the gesture event details.
|
|
25
|
+
*/
|
|
9
26
|
type MapClickPayload = {
|
|
27
|
+
/** Information about the picked object and its properties */
|
|
10
28
|
info: NonFuncPickingInfo;
|
|
29
|
+
/** The gesture event that triggered the click */
|
|
11
30
|
event: NonFuncMjolnirGestureEvent;
|
|
31
|
+
/** The map instance the event occurred within */
|
|
32
|
+
id: UniqueId;
|
|
12
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Payload for map hover events emitted through the event bus.
|
|
36
|
+
* Contains picking information about what is being hovered and the pointer event details.
|
|
37
|
+
*/
|
|
13
38
|
type MapHoverPayload = {
|
|
39
|
+
/** Information about the picked object and its properties */
|
|
14
40
|
info: NonFuncPickingInfo;
|
|
41
|
+
/** The pointer event that triggered the hover */
|
|
15
42
|
event: NonFuncMjolnirPointerEvent;
|
|
43
|
+
/** The map instance the event occurred within */
|
|
44
|
+
id: UniqueId;
|
|
16
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Type for map click events in the event bus.
|
|
48
|
+
* Combines the event name with the click payload.
|
|
49
|
+
*/
|
|
17
50
|
type MapClickEvent = Payload<typeof MapEvents.click, MapClickPayload>;
|
|
51
|
+
/**
|
|
52
|
+
* Type for map hover events in the event bus.
|
|
53
|
+
* Combines the event name with the hover payload.
|
|
54
|
+
*/
|
|
18
55
|
type MapHoverEvent = Payload<typeof MapEvents.hover, MapHoverPayload>;
|
|
56
|
+
/**
|
|
57
|
+
* Union type of all map event types that can be emitted through the event bus.
|
|
58
|
+
*/
|
|
19
59
|
type MapEventType = MapClickEvent | MapHoverEvent;
|
|
20
60
|
|
|
21
61
|
export type { MapClickEvent, MapClickPayload, MapEventType, MapHoverEvent, MapHoverPayload };
|
package/dist/deckgl/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
export { BaseMap,
|
|
1
|
+
export { BaseMap, BaseMapProps } from './base-map/index.js';
|
|
2
2
|
export { BASE_MAP_STYLE, PARAMETERS } from './base-map/constants.js';
|
|
3
3
|
export { MapEvents, MapEventsNamespace } from './base-map/events.js';
|
|
4
4
|
export { SymbolLayer, SymbolLayerProps } from './symbol-layer/index.js';
|
|
5
5
|
export { MapClickEvent, MapClickPayload, MapEventType, MapHoverEvent, MapHoverPayload } from './base-map/types.js';
|
|
6
6
|
import 'react/jsx-runtime';
|
|
7
|
-
import '@accelint/
|
|
7
|
+
import '@accelint/core';
|
|
8
8
|
import '@deckgl-fiber-renderer/types';
|
|
9
9
|
import '@deck.gl/layers';
|
|
10
10
|
import 'milsymbol';
|
|
11
11
|
import '@deck.gl/core';
|
|
12
|
+
import '@accelint/bus';
|
|
12
13
|
import 'mjolnir.js';
|
package/dist/deckgl/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BaseMap
|
|
1
|
+
export { BaseMap } from './base-map/index.js';
|
|
2
2
|
export { BASE_MAP_STYLE, PARAMETERS } from './base-map/constants.js';
|
|
3
3
|
export { MapEvents, MapEventsNamespace } from './base-map/events.js';
|
|
4
4
|
export { SymbolLayer } from './symbol-layer/index.js';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
type CharacterSetsKeys = keyof typeof CHARACTER_SETS;
|
|
2
|
+
declare const CHARACTER_SETS: Readonly<{
|
|
3
|
+
readonly ALL_NUMBERS: "1234567890";
|
|
4
|
+
readonly ASCII_ALL: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~";
|
|
5
|
+
readonly ASCII_ALPHA_NUMERIC: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
|
6
|
+
readonly ASCII_LETTERS: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
7
|
+
readonly ASCII_LETTERS_LOWERCASE: "abcdefghijklmnopqrstuvwxyz";
|
|
8
|
+
readonly ASCII_LETTERS_UPPERCASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
9
|
+
readonly ASCII_SYMBOLS: " !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~";
|
|
10
|
+
readonly AUTO: "auto";
|
|
11
|
+
readonly EXPANDED: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ1234567890 ¡¿¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷";
|
|
12
|
+
readonly LATIN_ALL: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ1234567890 ¡¿¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷";
|
|
13
|
+
readonly LATIN_ALPHA_NUMERIC: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ1234567890";
|
|
14
|
+
readonly LATIN_LETTERS: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ";
|
|
15
|
+
readonly LATIN_LETTERS_LOWERCASE: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿß";
|
|
16
|
+
readonly LATIN_LETTERS_UPPERCASE: "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ";
|
|
17
|
+
readonly LATIN_SYMBOLS: " ¡¿¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷";
|
|
18
|
+
}>;
|
|
19
|
+
|
|
20
|
+
export { CHARACTER_SETS, type CharacterSetsKeys };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const ALL_NUMBERS = "1234567890";
|
|
2
|
+
const ASCII_LETTERS_LOWERCASE = "abcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
const ASCII_LETTERS_UPPERCASE = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
4
|
+
const ASCII_SYMBOLS = " !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~";
|
|
5
|
+
const ASCII_LETTERS = `${ASCII_LETTERS_LOWERCASE}${ASCII_LETTERS_UPPERCASE}`;
|
|
6
|
+
const ASCII_ALPHA_NUMERIC = `${ASCII_LETTERS}${ALL_NUMBERS}`;
|
|
7
|
+
const ASCII_ALL = `${ASCII_LETTERS}${ALL_NUMBERS}${ASCII_SYMBOLS}`;
|
|
8
|
+
const AUTO = "auto";
|
|
9
|
+
const LATIN_LETTERS_LOWERCASE = "\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xEC\xED\xEE\xEF\xF0\xF1\xF2\xF3\xF4\xF5\xF6\xF8\xF9\xFA\xFB\xFC\xFD\xFE\xFF\xDF";
|
|
10
|
+
const LATIN_LETTERS_UPPERCASE = "\xC0\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xCA\xCB\xCC\xCD\xCE\xCF\xD0\xD1\xD2\xD3\xD4\xD5\xD6\xD8\xD9\xDA\xDB\xDC\xDD\xDE";
|
|
11
|
+
const LATIN_SYMBOLS = " \xA1\xBF\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9\xAA\xAB\xAC\xAD\xAE\xAF\xB0\xB1\xB2\xB3\xB4\xB5\xB6\xB7\xB8\xB9\xBA\xBB\xBC\xBD\xBE\xBF\xD7\xF7";
|
|
12
|
+
const LATIN_LETTERS = `${LATIN_LETTERS_LOWERCASE}${LATIN_LETTERS_UPPERCASE}`;
|
|
13
|
+
const LATIN_ALPHA_NUMERIC = `${LATIN_LETTERS}${ALL_NUMBERS}`;
|
|
14
|
+
const LATIN_ALL = `${LATIN_LETTERS}${ALL_NUMBERS}${LATIN_SYMBOLS}`;
|
|
15
|
+
const EXPANDED = `${ASCII_ALL}${LATIN_ALL}`;
|
|
16
|
+
const CHARACTER_SETS = Object.freeze({
|
|
17
|
+
ALL_NUMBERS,
|
|
18
|
+
ASCII_ALL,
|
|
19
|
+
ASCII_ALPHA_NUMERIC,
|
|
20
|
+
ASCII_LETTERS,
|
|
21
|
+
ASCII_LETTERS_LOWERCASE,
|
|
22
|
+
ASCII_LETTERS_UPPERCASE,
|
|
23
|
+
ASCII_SYMBOLS,
|
|
24
|
+
AUTO,
|
|
25
|
+
EXPANDED,
|
|
26
|
+
LATIN_ALL,
|
|
27
|
+
LATIN_ALPHA_NUMERIC,
|
|
28
|
+
LATIN_LETTERS,
|
|
29
|
+
LATIN_LETTERS_LOWERCASE,
|
|
30
|
+
LATIN_LETTERS_UPPERCASE,
|
|
31
|
+
LATIN_SYMBOLS
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export { CHARACTER_SETS };
|
|
35
|
+
//# sourceMappingURL=character-sets.js.map
|
|
36
|
+
//# sourceMappingURL=character-sets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/deckgl/text-layer/character-sets.ts"],"names":[],"mappings":"AAYA,MAAM,WAAA,GAAc,YAAA;AAEpB,MAAM,uBAAA,GAA0B,4BAAA;AAChC,MAAM,uBAAA,GAA0B,4BAAA;AAChC,MAAM,aAAA,GAAgB,mCAAA;AAEtB,MAAM,aAAA,GAAgB,CAAA,EAAG,uBAAuB,CAAA,EAAG,uBAAuB,CAAA,CAAA;AAC1E,MAAM,mBAAA,GAAsB,CAAA,EAAG,aAAa,CAAA,EAAG,WAAW,CAAA,CAAA;AAC1D,MAAM,YAAY,CAAA,EAAG,aAAa,CAAA,EAAG,WAAW,GAAG,aAAa,CAAA,CAAA;AAEhE,MAAM,IAAA,GAAO,MAAA;AAEb,MAAM,uBAAA,GAA0B,kIAAA;AAChC,MAAM,uBAAA,GAA0B,0HAAA;AAChC,MAAM,aAAA,GAAgB,2IAAA;AAEtB,MAAM,aAAA,GAAgB,CAAA,EAAG,uBAAuB,CAAA,EAAG,uBAAuB,CAAA,CAAA;AAC1E,MAAM,mBAAA,GAAsB,CAAA,EAAG,aAAa,CAAA,EAAG,WAAW,CAAA,CAAA;AAC1D,MAAM,YAAY,CAAA,EAAG,aAAa,CAAA,EAAG,WAAW,GAAG,aAAa,CAAA,CAAA;AAEhE,MAAM,QAAA,GAAW,CAAA,EAAG,SAAS,CAAA,EAAG,SAAS,CAAA,CAAA;AAIlC,MAAM,cAAA,GAAiB,OAAO,MAAA,CAAO;AAAA,EAC1C,WAAA;AAAA,EAEA,SAAA;AAAA,EACA,mBAAA;AAAA,EACA,aAAA;AAAA,EACA,uBAAA;AAAA,EACA,uBAAA;AAAA,EACA,aAAA;AAAA,EAEA,IAAA;AAAA,EACA,QAAA;AAAA,EAEA,SAAA;AAAA,EACA,mBAAA;AAAA,EACA,aAAA;AAAA,EACA,uBAAA;AAAA,EACA,uBAAA;AAAA,EACA;AACF,CAAU","file":"character-sets.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nconst ALL_NUMBERS = '1234567890';\n\nconst ASCII_LETTERS_LOWERCASE = 'abcdefghijklmnopqrstuvwxyz';\nconst ASCII_LETTERS_UPPERCASE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\nconst ASCII_SYMBOLS = ' !\"#$%&\\'()*+,-./:;<=>?@[]^_`{|}~';\n\nconst ASCII_LETTERS = `${ASCII_LETTERS_LOWERCASE}${ASCII_LETTERS_UPPERCASE}`;\nconst ASCII_ALPHA_NUMERIC = `${ASCII_LETTERS}${ALL_NUMBERS}`;\nconst ASCII_ALL = `${ASCII_LETTERS}${ALL_NUMBERS}${ASCII_SYMBOLS}`;\n\nconst AUTO = 'auto';\n\nconst LATIN_LETTERS_LOWERCASE = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿß';\nconst LATIN_LETTERS_UPPERCASE = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ';\nconst LATIN_SYMBOLS = ' ¡¿¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷';\n\nconst LATIN_LETTERS = `${LATIN_LETTERS_LOWERCASE}${LATIN_LETTERS_UPPERCASE}`;\nconst LATIN_ALPHA_NUMERIC = `${LATIN_LETTERS}${ALL_NUMBERS}`;\nconst LATIN_ALL = `${LATIN_LETTERS}${ALL_NUMBERS}${LATIN_SYMBOLS}`;\n\nconst EXPANDED = `${ASCII_ALL}${LATIN_ALL}`;\n\nexport type CharacterSetsKeys = keyof typeof CHARACTER_SETS;\n\nexport const CHARACTER_SETS = Object.freeze({\n ALL_NUMBERS,\n\n ASCII_ALL,\n ASCII_ALPHA_NUMERIC,\n ASCII_LETTERS,\n ASCII_LETTERS_LOWERCASE,\n ASCII_LETTERS_UPPERCASE,\n ASCII_SYMBOLS,\n\n AUTO,\n EXPANDED,\n\n LATIN_ALL,\n LATIN_ALPHA_NUMERIC,\n LATIN_LETTERS,\n LATIN_LETTERS_LOWERCASE,\n LATIN_LETTERS_UPPERCASE,\n LATIN_SYMBOLS,\n} as const);\n"]}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const defaultSettings = {
|
|
2
|
+
fontFamily: "system-ui, sans-serif",
|
|
3
|
+
fontSettings: {
|
|
4
|
+
fontSize: 22,
|
|
5
|
+
sdf: true,
|
|
6
|
+
buffer: 10,
|
|
7
|
+
cutoff: 0.19,
|
|
8
|
+
radius: 10,
|
|
9
|
+
smoothing: 0.1
|
|
10
|
+
},
|
|
11
|
+
fontWeight: 500,
|
|
12
|
+
getAlignmentBaseline: "center",
|
|
13
|
+
getColor: [255, 255, 255, 255],
|
|
14
|
+
getSize: 12,
|
|
15
|
+
getTextAnchor: "middle",
|
|
16
|
+
lineHeight: 1,
|
|
17
|
+
outlineColor: [0, 0, 0, 255],
|
|
18
|
+
outlineWidth: 2
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { defaultSettings };
|
|
22
|
+
//# sourceMappingURL=default-settings.js.map
|
|
23
|
+
//# sourceMappingURL=default-settings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/deckgl/text-layer/default-settings.ts"],"names":[],"mappings":"AAeO,MAAM,eAAA,GAA2C;AAAA,EACtD,UAAA,EAAY,uBAAA;AAAA,EACZ,YAAA,EAAc;AAAA,IACZ,QAAA,EAAU,EAAA;AAAA,IACV,GAAA,EAAK,IAAA;AAAA,IACL,MAAA,EAAQ,EAAA;AAAA,IACR,MAAA,EAAQ,IAAA;AAAA,IACR,MAAA,EAAQ,EAAA;AAAA,IACR,SAAA,EAAW;AAAA,GACb;AAAA,EACA,UAAA,EAAY,GAAA;AAAA,EACZ,oBAAA,EAAsB,QAAA;AAAA,EACtB,QAAA,EAAU,CAAC,GAAA,EAAK,GAAA,EAAK,KAAK,GAAG,CAAA;AAAA,EAC7B,OAAA,EAAS,EAAA;AAAA,EACT,aAAA,EAAe,QAAA;AAAA,EACf,UAAA,EAAY,CAAA;AAAA,EACZ,YAAA,EAAc,CAAC,CAAA,EAAG,CAAA,EAAG,GAAG,GAAG,CAAA;AAAA,EAC3B,YAAA,EAAc;AAChB","file":"default-settings.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport type { Color } from '@deck.gl/core';\nimport type { TextLayerProps } from '@deck.gl/layers';\n\nexport const defaultSettings: Partial<TextLayerProps> = {\n fontFamily: 'system-ui, sans-serif',\n fontSettings: {\n fontSize: 22,\n sdf: true,\n buffer: 10,\n cutoff: 0.19,\n radius: 10,\n smoothing: 0.1,\n },\n fontWeight: 500,\n getAlignmentBaseline: 'center',\n getColor: [255, 255, 255, 255] as Color,\n getSize: 12,\n getTextAnchor: 'middle',\n lineHeight: 1,\n outlineColor: [0, 0, 0, 255] as Color,\n outlineWidth: 2,\n} as const;\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { TextLayerProps } from './index.js';
|
|
2
|
+
import '@deck.gl/layers';
|
|
3
|
+
import './character-sets.js';
|
|
4
|
+
import 'type-fest';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
namespace React {
|
|
8
|
+
namespace JSX {
|
|
9
|
+
interface IntrinsicElements {
|
|
10
|
+
/**
|
|
11
|
+
* A styled text layer for DeckGL Fiber with enhanced styling capabilities.
|
|
12
|
+
*
|
|
13
|
+
* Provides customizable font styling, text outline support, and extended character sets.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* <textLayer
|
|
18
|
+
* id="my-text"
|
|
19
|
+
* data={textData}
|
|
20
|
+
* getText={d => d.text}
|
|
21
|
+
* getPosition={d => d.position}
|
|
22
|
+
* getSize={12}
|
|
23
|
+
* fontWeight={500}
|
|
24
|
+
* />
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
textLayer: TextLayerProps;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/deckgl/text-layer/fiber.ts"],"names":[],"mappings":";;;AAeA,MAAA,CAAO,EAAE,WAAW,CAAA","file":"fiber.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { extend } from '@deckgl-fiber-renderer/dom';\nimport { TextLayer, type TextLayerProps } from './index';\n\nextend({ TextLayer });\n\ndeclare global {\n namespace React {\n // biome-ignore lint/style/useNamingConvention: Built-in React namespace.\n namespace JSX {\n interface IntrinsicElements {\n /**\n * A styled text layer for DeckGL Fiber with enhanced styling capabilities.\n *\n * Provides customizable font styling, text outline support, and extended character sets.\n *\n * @example\n * ```tsx\n * <textLayer\n * id=\"my-text\"\n * data={textData}\n * getText={d => d.text}\n * getPosition={d => d.position}\n * getSize={12}\n * fontWeight={500}\n * />\n * ```\n */\n textLayer: TextLayerProps;\n }\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { TextLayerProps as TextLayerProps$1, TextLayer as TextLayer$1 } from '@deck.gl/layers';
|
|
2
|
+
import { CharacterSetsKeys } from './character-sets.js';
|
|
3
|
+
import { LiteralUnion } from 'type-fest';
|
|
4
|
+
|
|
5
|
+
interface TextLayerProps<TData = unknown> extends TextLayerProps$1<TData> {
|
|
6
|
+
characterSet?: LiteralUnion<CharacterSetsKeys, string>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A styled text layer that extends Deck.gl's TextLayer with enhanced styling capabilities.
|
|
10
|
+
*
|
|
11
|
+
* This layer provides:
|
|
12
|
+
* - Customizable font styling (size, weight, family, line height)
|
|
13
|
+
* - Text outline support
|
|
14
|
+
* - Extended character set support
|
|
15
|
+
* - Consistent styling based on design specifications
|
|
16
|
+
*
|
|
17
|
+
* Can be used directly with Deck.gl or as a JSX element with React Fiber:
|
|
18
|
+
* - React Fiber: `<textLayer id="text" data={[...]} ... />`
|
|
19
|
+
* - Direct: `new TextLayer({ id: 'text', data: [...], ... })`
|
|
20
|
+
*/
|
|
21
|
+
declare class TextLayer<TData = unknown> extends TextLayer$1<TData> {
|
|
22
|
+
static CHARACTER_SETS: Readonly<{
|
|
23
|
+
readonly ALL_NUMBERS: "1234567890";
|
|
24
|
+
readonly ASCII_ALL: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~";
|
|
25
|
+
readonly ASCII_ALPHA_NUMERIC: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
|
26
|
+
readonly ASCII_LETTERS: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
27
|
+
readonly ASCII_LETTERS_LOWERCASE: "abcdefghijklmnopqrstuvwxyz";
|
|
28
|
+
readonly ASCII_LETTERS_UPPERCASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
|
29
|
+
readonly ASCII_SYMBOLS: " !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~";
|
|
30
|
+
readonly AUTO: "auto";
|
|
31
|
+
readonly EXPANDED: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890 !\"#$%&'()*+,-./:;<=>?@[]^_`{|}~àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ1234567890 ¡¿¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷";
|
|
32
|
+
readonly LATIN_ALL: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ1234567890 ¡¿¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷";
|
|
33
|
+
readonly LATIN_ALPHA_NUMERIC: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ1234567890";
|
|
34
|
+
readonly LATIN_LETTERS: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿßÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ";
|
|
35
|
+
readonly LATIN_LETTERS_LOWERCASE: "àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿß";
|
|
36
|
+
readonly LATIN_LETTERS_UPPERCASE: "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ";
|
|
37
|
+
readonly LATIN_SYMBOLS: " ¡¿¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿×÷";
|
|
38
|
+
}>;
|
|
39
|
+
static layerName: string;
|
|
40
|
+
constructor(props: TextLayerProps<TData>);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { TextLayer, type TextLayerProps };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TextLayer as TextLayer$1 } from '@deck.gl/layers';
|
|
2
|
+
import { CHARACTER_SETS } from './character-sets.js';
|
|
3
|
+
import { defaultSettings } from './default-settings.js';
|
|
4
|
+
|
|
5
|
+
class TextLayer extends TextLayer$1 {
|
|
6
|
+
static CHARACTER_SETS = CHARACTER_SETS;
|
|
7
|
+
static layerName = "textLayer";
|
|
8
|
+
constructor(props) {
|
|
9
|
+
const {
|
|
10
|
+
characterSet = CHARACTER_SETS.EXPANDED,
|
|
11
|
+
fontSettings,
|
|
12
|
+
...rest
|
|
13
|
+
} = props;
|
|
14
|
+
super({
|
|
15
|
+
// set opinionated defaults
|
|
16
|
+
...defaultSettings,
|
|
17
|
+
// user props override defaults
|
|
18
|
+
...rest,
|
|
19
|
+
// handle special characterSet logic
|
|
20
|
+
characterSet: CHARACTER_SETS[characterSet] ?? characterSet,
|
|
21
|
+
fontSettings: {
|
|
22
|
+
// merge fontSettings
|
|
23
|
+
...defaultSettings.fontSettings,
|
|
24
|
+
// user props override defaults
|
|
25
|
+
...fontSettings
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export { TextLayer };
|
|
32
|
+
//# sourceMappingURL=index.js.map
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/deckgl/text-layer/index.ts"],"names":["DglTextLayer"],"mappings":";;;;AAuCO,MAAM,kBAAmCA,WAAA,CAAoB;AAAA,EAClE,OAAO,cAAA,GAAiB,cAAA;AAAA,EAExB,OAAgB,SAAA,GAAY,WAAA;AAAA,EAE5B,YAAY,KAAA,EAA8B;AACxC,IAAA,MAAM;AAAA,MACJ,eAAe,cAAA,CAAe,QAAA;AAAA,MAC9B,YAAA;AAAA,MACA,GAAG;AAAA,KACL,GAAI,KAAA;AAEJ,IAAA,KAAA,CAAM;AAAA;AAAA,MAEJ,GAAG,eAAA;AAAA;AAAA,MAGH,GAAG,IAAA;AAAA;AAAA,MAGH,YAAA,EACE,cAAA,CAAe,YAAiC,CAAA,IAAK,YAAA;AAAA,MAEvD,YAAA,EAAc;AAAA;AAAA,QAEZ,GAAG,eAAA,CAAgB,YAAA;AAAA;AAAA,QAGnB,GAAG;AAAA;AACL,KACD,CAAA;AAAA,EACH;AACF","file":"index.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {\n TextLayer as DglTextLayer,\n type TextLayerProps as DglTextLayerProps,\n} from '@deck.gl/layers';\nimport { CHARACTER_SETS, type CharacterSetsKeys } from './character-sets.js';\nimport { defaultSettings } from './default-settings.js';\nimport type { LiteralUnion } from 'type-fest';\n\nexport interface TextLayerProps<TData = unknown>\n extends DglTextLayerProps<TData> {\n // A union type that preserves autocompletion for CharacterSetsKeys while allowing any string.\n characterSet?: LiteralUnion<CharacterSetsKeys, string>;\n}\n\n/**\n * A styled text layer that extends Deck.gl's TextLayer with enhanced styling capabilities.\n *\n * This layer provides:\n * - Customizable font styling (size, weight, family, line height)\n * - Text outline support\n * - Extended character set support\n * - Consistent styling based on design specifications\n *\n * Can be used directly with Deck.gl or as a JSX element with React Fiber:\n * - React Fiber: `<textLayer id=\"text\" data={[...]} ... />`\n * - Direct: `new TextLayer({ id: 'text', data: [...], ... })`\n */\nexport class TextLayer<TData = unknown> extends DglTextLayer<TData> {\n static CHARACTER_SETS = CHARACTER_SETS;\n\n static override layerName = 'textLayer';\n\n constructor(props: TextLayerProps<TData>) {\n const {\n characterSet = CHARACTER_SETS.EXPANDED,\n fontSettings,\n ...rest\n } = props;\n\n super({\n // set opinionated defaults\n ...defaultSettings,\n\n // user props override defaults\n ...rest,\n\n // handle special characterSet logic\n characterSet:\n CHARACTER_SETS[characterSet as CharacterSetsKeys] ?? characterSet,\n\n fontSettings: {\n // merge fontSettings\n ...defaultSettings.fontSettings,\n\n // user props override defaults\n ...fontSettings,\n },\n });\n }\n}\n"]}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { uuid } from '@accelint/core';
|
|
2
3
|
import { BaseMap } from '../deckgl/base-map/index.js';
|
|
3
4
|
|
|
5
|
+
const STORYBOOK_MAP_ID = uuid();
|
|
4
6
|
const withDeckGL = () => {
|
|
5
7
|
return (Story) => {
|
|
6
|
-
return /* @__PURE__ */ jsx(BaseMap, { className: "h-dvh w-dvw", children: /* @__PURE__ */ jsx(Story, {}) });
|
|
8
|
+
return /* @__PURE__ */ jsx(BaseMap, { className: "h-dvh w-dvw", id: STORYBOOK_MAP_ID, children: /* @__PURE__ */ jsx(Story, {}) });
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
11
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/decorators/deckgl.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/decorators/deckgl.tsx"],"names":[],"mappings":";;;;AAmBA,MAAM,mBAAmB,IAAA,EAAK;AAEvB,MAAM,aAAa,MAAiB;AACzC,EAAA,OAAO,CAAC,KAAA,KAAU;AAChB,IAAA,uBACE,GAAA,CAAC,WAAQ,SAAA,EAAU,aAAA,EAAc,IAAI,gBAAA,EACnC,QAAA,kBAAA,GAAA,CAAC,SAAM,CAAA,EACT,CAAA;AAAA,EAEJ,CAAA;AACF","file":"deckgl.js","sourcesContent":["// __private-exports\n\n/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport { uuid } from '@accelint/core';\nimport { BaseMap } from '../deckgl/base-map';\nimport type { Decorator } from '@storybook/react';\n\n// Module-level constant - stable across all Storybook renders\nconst STORYBOOK_MAP_ID = uuid();\n\nexport const withDeckGL = (): Decorator => {\n return (Story) => {\n return (\n <BaseMap className='h-dvh w-dvw' id={STORYBOOK_MAP_ID}>\n <Story />\n </BaseMap>\n );\n };\n};\n"]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Namespace prefix for all map mode events.
|
|
3
|
+
*/
|
|
4
|
+
declare const MapModeEventsNamespace = "map-mode";
|
|
5
|
+
/**
|
|
6
|
+
* Event type constants for map mode state management.
|
|
7
|
+
*
|
|
8
|
+
* These events are emitted through the `@accelint/bus` event bus to coordinate
|
|
9
|
+
* map mode changes across components in a decoupled manner.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { useOn, useEmit } from '@accelint/bus/react';
|
|
14
|
+
* import { MapModeEvents } from '@accelint/map-toolkit/map-mode';
|
|
15
|
+
*
|
|
16
|
+
* // Listen for mode changes
|
|
17
|
+
* useOn(MapModeEvents.changed, (event) => {
|
|
18
|
+
* console.log('Mode changed to:', event.payload.currentMode);
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Emit a decision
|
|
22
|
+
* const emitDecision = useEmit(MapModeEvents.changeDecision);
|
|
23
|
+
* emitDecision({ authId, approved: true, owner: 'my-id', id });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
declare const MapModeEvents: {
|
|
27
|
+
/** Emitted when the map mode has successfully changed */
|
|
28
|
+
readonly changed: "map-mode:changed";
|
|
29
|
+
/** Emitted when a component requests a mode change */
|
|
30
|
+
readonly changeRequest: "map-mode:change:request";
|
|
31
|
+
/** Emitted when authorization is required for a mode change */
|
|
32
|
+
readonly changeAuthorization: "map-mode:change:authorization";
|
|
33
|
+
/** Emitted when an authorization decision is made (approve/reject) */
|
|
34
|
+
readonly changeDecision: "map-mode:change:decision";
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { MapModeEvents, MapModeEventsNamespace };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const MapModeEventsNamespace = "map-mode";
|
|
2
|
+
const MapModeEvents = {
|
|
3
|
+
/** Emitted when the map mode has successfully changed */
|
|
4
|
+
changed: `${MapModeEventsNamespace}:changed`,
|
|
5
|
+
/** Emitted when a component requests a mode change */
|
|
6
|
+
changeRequest: `${MapModeEventsNamespace}:change:request`,
|
|
7
|
+
/** Emitted when authorization is required for a mode change */
|
|
8
|
+
changeAuthorization: `${MapModeEventsNamespace}:change:authorization`,
|
|
9
|
+
/** Emitted when an authorization decision is made (approve/reject) */
|
|
10
|
+
changeDecision: `${MapModeEventsNamespace}:change:decision`
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { MapModeEvents, MapModeEventsNamespace };
|
|
14
|
+
//# sourceMappingURL=events.js.map
|
|
15
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/map-mode/events.ts"],"names":[],"mappings":"AAeO,MAAM,sBAAA,GAAyB;AAuB/B,MAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,OAAA,EAAS,GAAG,sBAAsB,CAAA,QAAA,CAAA;AAAA;AAAA,EAElC,aAAA,EAAe,GAAG,sBAAsB,CAAA,eAAA,CAAA;AAAA;AAAA,EAExC,mBAAA,EAAqB,GAAG,sBAAsB,CAAA,qBAAA,CAAA;AAAA;AAAA,EAE9C,cAAA,EAAgB,GAAG,sBAAsB,CAAA,gBAAA;AAC3C","file":"events.js","sourcesContent":["/*\n * Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at https://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/**\n * Namespace prefix for all map mode events.\n */\nexport const MapModeEventsNamespace = 'map-mode';\n\n/**\n * Event type constants for map mode state management.\n *\n * These events are emitted through the `@accelint/bus` event bus to coordinate\n * map mode changes across components in a decoupled manner.\n *\n * @example\n * ```ts\n * import { useOn, useEmit } from '@accelint/bus/react';\n * import { MapModeEvents } from '@accelint/map-toolkit/map-mode';\n *\n * // Listen for mode changes\n * useOn(MapModeEvents.changed, (event) => {\n * console.log('Mode changed to:', event.payload.currentMode);\n * });\n *\n * // Emit a decision\n * const emitDecision = useEmit(MapModeEvents.changeDecision);\n * emitDecision({ authId, approved: true, owner: 'my-id', id });\n * ```\n */\nexport const MapModeEvents = {\n /** Emitted when the map mode has successfully changed */\n changed: `${MapModeEventsNamespace}:changed`,\n /** Emitted when a component requests a mode change */\n changeRequest: `${MapModeEventsNamespace}:change:request`,\n /** Emitted when authorization is required for a mode change */\n changeAuthorization: `${MapModeEventsNamespace}:change:authorization`,\n /** Emitted when an authorization decision is made (approve/reject) */\n changeDecision: `${MapModeEventsNamespace}:change:decision`,\n} as const;\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { MapModeEvents, MapModeEventsNamespace } from './events.js';
|
|
2
|
+
export { MapModeStore, destroyStore, getOrCreateStore, getStore } from './store.js';
|
|
3
|
+
export { UseMapModeReturn, useMapMode } from './use-map-mode.js';
|
|
4
|
+
export { MapModeEventType, ModeChangeAuthorizationEvent, ModeChangeAuthorizationPayload, ModeChangeDecisionEvent, ModeChangeDecisionPayload, ModeChangeRequestEvent, ModeChangeRequestPayload, ModeChangedEvent, ModeChangedPayload } from './types.js';
|
|
5
|
+
import '@accelint/core';
|
|
6
|
+
import '@accelint/bus';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { MapModeEvents, MapModeEventsNamespace } from './events.js';
|
|
2
|
+
export { MapModeStore, destroyStore, getOrCreateStore, getStore } from './store.js';
|
|
3
|
+
export { useMapMode } from './use-map-mode.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { UniqueId } from '@accelint/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* External store for managing map mode state.
|
|
5
|
+
*
|
|
6
|
+
* This store implements the observable pattern for use with React's `useSyncExternalStore` hook.
|
|
7
|
+
* It manages all mode state, ownership tracking, authorization flow, and event bus communication
|
|
8
|
+
* outside of React's component tree.
|
|
9
|
+
*
|
|
10
|
+
* Each store instance is identified by a unique `id` and operates independently,
|
|
11
|
+
* enabling scenarios with multiple isolated map instances (e.g., main map + minimap).
|
|
12
|
+
* Stores communicate via the event bus and filter events by `id` to ensure isolation.
|
|
13
|
+
*
|
|
14
|
+
* The store always initializes in 'default' mode and does not accept a custom default mode.
|
|
15
|
+
*
|
|
16
|
+
* @see {getOrCreateStore} - Creates or retrieves a store for a given map instance
|
|
17
|
+
* @see {destroyStore} - Destroys a store and cleans up its resources
|
|
18
|
+
*/
|
|
19
|
+
declare class MapModeStore {
|
|
20
|
+
private readonly id;
|
|
21
|
+
private mode;
|
|
22
|
+
private readonly defaultMode;
|
|
23
|
+
private readonly modeOwners;
|
|
24
|
+
private readonly pendingRequests;
|
|
25
|
+
private readonly listeners;
|
|
26
|
+
private readonly bus;
|
|
27
|
+
private readonly unsubscribers;
|
|
28
|
+
constructor(id: UniqueId);
|
|
29
|
+
/**
|
|
30
|
+
* Get current mode snapshot (for useSyncExternalStore)
|
|
31
|
+
*/
|
|
32
|
+
getSnapshot: () => string;
|
|
33
|
+
/**
|
|
34
|
+
* Subscribe to mode changes (for useSyncExternalStore)
|
|
35
|
+
*/
|
|
36
|
+
subscribe: (listener: () => void) => (() => void);
|
|
37
|
+
/**
|
|
38
|
+
* Request a mode change
|
|
39
|
+
*
|
|
40
|
+
* If the mode change can be auto-accepted (no ownership conflicts), the mode changes immediately.
|
|
41
|
+
* Otherwise, an authorization request is emitted and stored as a pending request.
|
|
42
|
+
*
|
|
43
|
+
* **Important**: If the requester already has a pending authorization request, it will be replaced
|
|
44
|
+
* with this new request. Only one pending request per requester is maintained at a time.
|
|
45
|
+
*
|
|
46
|
+
* @param desiredMode - The mode to switch to (automatically trimmed of whitespace)
|
|
47
|
+
* @param requestOwner - Unique identifier of the component requesting the change (automatically trimmed of whitespace)
|
|
48
|
+
* @throws Error if either parameter is empty or whitespace-only
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* // First request from 'drawing-tool'
|
|
53
|
+
* store.requestModeChange('drawing', 'drawing-tool');
|
|
54
|
+
* // → Creates pending request with authId 'abc-123'
|
|
55
|
+
*
|
|
56
|
+
* // Second request from same 'drawing-tool' before first is resolved
|
|
57
|
+
* store.requestModeChange('measuring', 'drawing-tool');
|
|
58
|
+
* // → Replaces pending request, new authId 'def-456', old 'abc-123' is discarded
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
requestModeChange: (desiredMode: string, requestOwner: string) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Notify all subscribers of state change
|
|
64
|
+
*/
|
|
65
|
+
private notify;
|
|
66
|
+
/**
|
|
67
|
+
* Setup event listeners for bus events
|
|
68
|
+
*
|
|
69
|
+
* Note: Event listeners remain active even after early returns in handlers.
|
|
70
|
+
* This is by design - cleanup happens in destroy() which is called automatically
|
|
71
|
+
* by MapProvider on unmount. Consumers don't need to manually manage cleanup.
|
|
72
|
+
*/
|
|
73
|
+
private setupEventListeners;
|
|
74
|
+
/**
|
|
75
|
+
* Determine if a mode change request should be auto-accepted without authorization
|
|
76
|
+
*/
|
|
77
|
+
private shouldAutoAcceptRequest;
|
|
78
|
+
/**
|
|
79
|
+
* Handle mode change request logic
|
|
80
|
+
*/
|
|
81
|
+
private handleModeChangeRequest;
|
|
82
|
+
/**
|
|
83
|
+
* Handle authorization decision
|
|
84
|
+
*
|
|
85
|
+
* Processes approval/rejection decisions from mode owners. Only the current mode's owner
|
|
86
|
+
* can make authorization decisions. If a decision comes from a non-owner, a warning is
|
|
87
|
+
* logged and the decision is ignored to prevent unauthorized mode changes.
|
|
88
|
+
*
|
|
89
|
+
* @param payload - The authorization decision containing authId, approved status, and owner
|
|
90
|
+
*/
|
|
91
|
+
private handleAuthorizationDecision;
|
|
92
|
+
/**
|
|
93
|
+
* Approve a request and reject all others
|
|
94
|
+
*/
|
|
95
|
+
private approveRequestAndRejectOthers;
|
|
96
|
+
/**
|
|
97
|
+
* Handle pending requests when returning to default mode
|
|
98
|
+
*/
|
|
99
|
+
private handlePendingRequestsOnDefaultMode;
|
|
100
|
+
/**
|
|
101
|
+
* Set mode and notify listeners
|
|
102
|
+
*/
|
|
103
|
+
private setMode;
|
|
104
|
+
/**
|
|
105
|
+
* Clean up store resources
|
|
106
|
+
*/
|
|
107
|
+
destroy(): void;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Get or create a store for a given map instance
|
|
111
|
+
*/
|
|
112
|
+
declare function getOrCreateStore(id: UniqueId): MapModeStore;
|
|
113
|
+
/**
|
|
114
|
+
* Destroy and remove a store from the registry
|
|
115
|
+
*/
|
|
116
|
+
declare function destroyStore(id: UniqueId): void;
|
|
117
|
+
/**
|
|
118
|
+
* Get a store by map ID (for testing/advanced use)
|
|
119
|
+
*/
|
|
120
|
+
declare function getStore(id: UniqueId): MapModeStore | undefined;
|
|
121
|
+
|
|
122
|
+
export { MapModeStore, destroyStore, getOrCreateStore, getStore };
|