@accelint/map-toolkit 0.3.1 → 0.4.1
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 +49 -24
- package/catalog-info.yaml +5 -7
- package/dist/cursor-coordinates/index.d.ts +14 -3
- package/dist/cursor-coordinates/index.js +16 -3
- package/dist/cursor-coordinates/use-cursor-coordinates.d.ts +20 -6
- package/dist/cursor-coordinates/use-cursor-coordinates.js +247 -128
- package/dist/cursor-coordinates/use-cursor-coordinates.js.map +1 -1
- package/dist/deckgl/base-map/constants.d.ts +14 -12
- package/dist/deckgl/base-map/constants.js +26 -12
- package/dist/deckgl/base-map/constants.js.map +1 -1
- package/dist/deckgl/base-map/events.d.ts +6 -4
- package/dist/deckgl/base-map/events.js +18 -4
- package/dist/deckgl/base-map/events.js.map +1 -1
- package/dist/deckgl/base-map/index.d.ts +45 -18
- package/dist/deckgl/base-map/index.js +216 -148
- package/dist/deckgl/base-map/index.js.map +1 -1
- package/dist/deckgl/base-map/provider.d.ts +48 -32
- package/dist/deckgl/base-map/provider.js +122 -11
- package/dist/deckgl/base-map/provider.js.map +1 -1
- package/dist/deckgl/base-map/types.d.ts +49 -39
- package/dist/deckgl/base-map/types.js +11 -2
- package/dist/deckgl/index.d.ts +18 -13
- package/dist/deckgl/index.js +19 -6
- package/dist/deckgl/symbol-layer/fiber.d.ts +21 -10
- package/dist/deckgl/symbol-layer/fiber.js +18 -3
- package/dist/deckgl/symbol-layer/fiber.js.map +1 -1
- package/dist/deckgl/symbol-layer/index.d.ts +68 -54
- package/dist/deckgl/symbol-layer/index.js +105 -85
- package/dist/deckgl/symbol-layer/index.js.map +1 -1
- package/dist/deckgl/text-layer/character-sets.d.ts +19 -17
- package/dist/deckgl/text-layer/character-sets.js +40 -19
- package/dist/deckgl/text-layer/character-sets.js.map +1 -1
- package/dist/deckgl/text-layer/default-settings.d.ts +16 -2
- package/dist/deckgl/text-layer/default-settings.js +42 -18
- package/dist/deckgl/text-layer/default-settings.js.map +1 -1
- package/dist/deckgl/text-layer/fiber.d.ts +38 -27
- package/dist/deckgl/text-layer/fiber.js +18 -3
- package/dist/deckgl/text-layer/fiber.js.map +1 -1
- package/dist/deckgl/text-layer/index.d.ts +39 -25
- package/dist/deckgl/text-layer/index.js +47 -29
- package/dist/deckgl/text-layer/index.js.map +1 -1
- package/dist/decorators/deckgl.d.ts +16 -2
- package/dist/decorators/deckgl.js +25 -7
- package/dist/decorators/deckgl.js.map +1 -1
- package/dist/map-cursor/events.d.ts +16 -0
- package/dist/map-cursor/events.js +27 -0
- package/dist/map-cursor/events.js.map +1 -0
- package/dist/map-cursor/index.d.ts +17 -0
- package/dist/map-cursor/index.js +18 -0
- package/dist/map-cursor/store.d.ts +93 -0
- package/dist/map-cursor/store.js +351 -0
- package/dist/map-cursor/store.js.map +1 -0
- package/dist/map-cursor/types.d.ts +81 -0
- package/dist/map-cursor/types.js +12 -0
- package/dist/map-cursor/use-map-cursor.d.ts +99 -0
- package/dist/map-cursor/use-map-cursor.js +116 -0
- package/dist/map-cursor/use-map-cursor.js.map +1 -0
- package/dist/map-mode/events.d.ts +11 -9
- package/dist/map-mode/events.js +43 -9
- package/dist/map-mode/events.js.map +1 -1
- package/dist/map-mode/index.d.ts +17 -6
- package/dist/map-mode/index.js +18 -5
- package/dist/map-mode/store.d.ts +26 -3
- package/dist/map-mode/store.js +329 -265
- package/dist/map-mode/store.js.map +1 -1
- package/dist/map-mode/types.d.ts +49 -35
- package/dist/map-mode/types.js +11 -2
- package/dist/map-mode/use-map-mode.d.ts +21 -7
- package/dist/map-mode/use-map-mode.js +66 -23
- package/dist/map-mode/use-map-mode.js.map +1 -1
- package/dist/maplibre/constants.d.ts +10 -8
- package/dist/maplibre/constants.js +22 -8
- package/dist/maplibre/constants.js.map +1 -1
- package/dist/maplibre/hooks/use-maplibre.d.ts +17 -2
- package/dist/maplibre/hooks/use-maplibre.js +77 -31
- package/dist/maplibre/hooks/use-maplibre.js.map +1 -1
- package/dist/maplibre/index.d.ts +15 -3
- package/dist/maplibre/index.js +17 -4
- package/dist/viewport/constants.d.ts +8 -6
- package/dist/viewport/constants.js +20 -6
- package/dist/viewport/constants.js.map +1 -1
- package/dist/viewport/index.d.ts +18 -13
- package/dist/viewport/index.js +19 -6
- package/dist/viewport/types.d.ts +27 -17
- package/dist/viewport/types.js +11 -2
- package/dist/viewport/use-viewport-state.d.ts +29 -14
- package/dist/viewport/use-viewport-state.js +200 -87
- package/dist/viewport/use-viewport-state.js.map +1 -1
- package/dist/viewport/utils.d.ts +25 -10
- package/dist/viewport/utils.js +67 -37
- package/dist/viewport/utils.js.map +1 -1
- package/dist/viewport/viewport-size.d.ts +27 -15
- package/dist/viewport/viewport-size.js +54 -11
- package/dist/viewport/viewport-size.js.map +1 -1
- package/package.json +107 -78
- package/dist/cursor-coordinates/index.js.map +0 -1
- package/dist/deckgl/base-map/types.js.map +0 -1
- package/dist/deckgl/index.js.map +0 -1
- package/dist/map-mode/index.js.map +0 -1
- package/dist/map-mode/types.js.map +0 -1
- package/dist/maplibre/index.js.map +0 -1
- package/dist/metafile-esm.json +0 -1
- package/dist/viewport/index.js.map +0 -1
- package/dist/viewport/types.js.map +0 -1
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
'use client';
|
|
15
|
+
|
|
16
|
+
import { getOrCreateClearCursor, getOrCreateRequestCursorChange, getOrCreateServerSnapshot, getOrCreateSnapshot, getOrCreateSubscription } from "./store.js";
|
|
17
|
+
import { MapContext } from "../deckgl/base-map/provider.js";
|
|
18
|
+
import { useContext, useEffect, useMemo, useSyncExternalStore } from "react";
|
|
19
|
+
|
|
20
|
+
//#region src/map-cursor/use-map-cursor.ts
|
|
21
|
+
/**
|
|
22
|
+
* Hook to access the map cursor state and actions.
|
|
23
|
+
*
|
|
24
|
+
* This hook uses `useSyncExternalStore` to subscribe to map cursor state changes,
|
|
25
|
+
* providing concurrent-safe cursor state updates. Uses a fan-out pattern where
|
|
26
|
+
* a single bus listener per map instance notifies N React component subscribers.
|
|
27
|
+
*
|
|
28
|
+
* **Owner-based Priority System:**
|
|
29
|
+
* - Mode owners (from MapModeStore) have highest priority
|
|
30
|
+
* - Non-owners can set cursors only in default/ownerless modes
|
|
31
|
+
* - Rejected requests emit events with rejection reasons
|
|
32
|
+
*
|
|
33
|
+
* @param id - Optional map instance ID. If not provided, will use the ID from `MapContext`.
|
|
34
|
+
* @returns The current cursor, requestCursorChange function, and clearCursor function
|
|
35
|
+
* @throws Error if no `id` is provided and hook is used outside of `MapProvider`
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* // Inside MapProvider (within BaseMap children)
|
|
40
|
+
* function CustomDeckLayer() {
|
|
41
|
+
* const { cursor, requestCursorChange, clearCursor } = useMapCursor();
|
|
42
|
+
*
|
|
43
|
+
* const handleHover = (info: PickingInfo) => {
|
|
44
|
+
* if (info.object) {
|
|
45
|
+
* requestCursorChange('pointer', 'custom-layer-id');
|
|
46
|
+
* } else {
|
|
47
|
+
* clearCursor('custom-layer-id');
|
|
48
|
+
* }
|
|
49
|
+
* };
|
|
50
|
+
*
|
|
51
|
+
* return <ScatterplotLayer onHover={handleHover} />;
|
|
52
|
+
* }
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```tsx
|
|
57
|
+
* // Outside MapProvider - pass id directly
|
|
58
|
+
* function ExternalControl({ mapId }: { mapId: UniqueId }) {
|
|
59
|
+
* const { cursor, requestCursorChange } = useMapCursor(mapId);
|
|
60
|
+
*
|
|
61
|
+
* return (
|
|
62
|
+
* <button onClick={() => requestCursorChange('crosshair', 'external-control')}>
|
|
63
|
+
* Set Crosshair (current: {cursor})
|
|
64
|
+
* </button>
|
|
65
|
+
* );
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
function useMapCursor(id) {
|
|
70
|
+
const contextId = useContext(MapContext);
|
|
71
|
+
const actualId = id ?? contextId;
|
|
72
|
+
if (!actualId) throw new Error("useMapCursor requires either an id parameter or to be used within a MapProvider");
|
|
73
|
+
const cursor = useSyncExternalStore(getOrCreateSubscription(actualId), getOrCreateSnapshot(actualId), getOrCreateServerSnapshot(actualId));
|
|
74
|
+
return useMemo(() => ({
|
|
75
|
+
cursor,
|
|
76
|
+
requestCursorChange: getOrCreateRequestCursorChange(actualId),
|
|
77
|
+
clearCursor: getOrCreateClearCursor(actualId)
|
|
78
|
+
}), [cursor, actualId]);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Hook to automatically manage cursor for a component's lifecycle.
|
|
82
|
+
*
|
|
83
|
+
* This hook automatically requests a cursor when mounted and clears it when unmounted.
|
|
84
|
+
* Useful for components that need to consistently show a specific cursor.
|
|
85
|
+
*
|
|
86
|
+
* @param cursor - The cursor to request
|
|
87
|
+
* @param owner - The owner identifier
|
|
88
|
+
* @param id - Optional map instance ID
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* function DrawingMode() {
|
|
93
|
+
* useMapCursorEffect('crosshair', 'drawing-mode');
|
|
94
|
+
*
|
|
95
|
+
* return <div>Drawing mode active with crosshair cursor</div>;
|
|
96
|
+
* }
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
function useMapCursorEffect(cursor, owner, id) {
|
|
100
|
+
const { requestCursorChange, clearCursor } = useMapCursor(id);
|
|
101
|
+
useEffect(() => {
|
|
102
|
+
requestCursorChange(cursor, owner);
|
|
103
|
+
return () => {
|
|
104
|
+
clearCursor(owner);
|
|
105
|
+
};
|
|
106
|
+
}, [
|
|
107
|
+
cursor,
|
|
108
|
+
owner,
|
|
109
|
+
requestCursorChange,
|
|
110
|
+
clearCursor
|
|
111
|
+
]);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
export { useMapCursor, useMapCursorEffect };
|
|
116
|
+
//# sourceMappingURL=use-map-cursor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-map-cursor.js","names":[],"sources":["../../src/map-cursor/use-map-cursor.ts"],"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'use client';\n\nimport 'client-only';\nimport { useContext, useEffect, useMemo, useSyncExternalStore } from 'react';\nimport { MapContext } from '../deckgl/base-map/provider';\nimport {\n getOrCreateClearCursor,\n getOrCreateRequestCursorChange,\n getOrCreateServerSnapshot,\n getOrCreateSnapshot,\n getOrCreateSubscription,\n} from './store';\nimport type { UniqueId } from '@accelint/core';\nimport type { CSSCursorType } from './types';\n\n/**\n * Return value for the useMapCursor hook\n */\nexport type UseMapCursorReturn = {\n /** The current active cursor */\n cursor: CSSCursorType;\n /** Function to request a cursor change with ownership */\n requestCursorChange: (cursor: CSSCursorType, requestOwner: string) => void;\n /** Function to clear cursor for an owner */\n clearCursor: (owner: string) => void;\n};\n\n/**\n * Hook to access the map cursor state and actions.\n *\n * This hook uses `useSyncExternalStore` to subscribe to map cursor state changes,\n * providing concurrent-safe cursor state updates. Uses a fan-out pattern where\n * a single bus listener per map instance notifies N React component subscribers.\n *\n * **Owner-based Priority System:**\n * - Mode owners (from MapModeStore) have highest priority\n * - Non-owners can set cursors only in default/ownerless modes\n * - Rejected requests emit events with rejection reasons\n *\n * @param id - Optional map instance ID. If not provided, will use the ID from `MapContext`.\n * @returns The current cursor, requestCursorChange function, and clearCursor function\n * @throws Error if no `id` is provided and hook is used outside of `MapProvider`\n *\n * @example\n * ```tsx\n * // Inside MapProvider (within BaseMap children)\n * function CustomDeckLayer() {\n * const { cursor, requestCursorChange, clearCursor } = useMapCursor();\n *\n * const handleHover = (info: PickingInfo) => {\n * if (info.object) {\n * requestCursorChange('pointer', 'custom-layer-id');\n * } else {\n * clearCursor('custom-layer-id');\n * }\n * };\n *\n * return <ScatterplotLayer onHover={handleHover} />;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Outside MapProvider - pass id directly\n * function ExternalControl({ mapId }: { mapId: UniqueId }) {\n * const { cursor, requestCursorChange } = useMapCursor(mapId);\n *\n * return (\n * <button onClick={() => requestCursorChange('crosshair', 'external-control')}>\n * Set Crosshair (current: {cursor})\n * </button>\n * );\n * }\n * ```\n */\nexport function useMapCursor(id?: UniqueId): UseMapCursorReturn {\n const contextId = useContext(MapContext);\n const actualId = id ?? contextId;\n\n if (!actualId) {\n throw new Error(\n 'useMapCursor requires either an id parameter or to be used within a MapProvider',\n );\n }\n\n // Subscribe to store using useSyncExternalStore with fan-out pattern\n // Third parameter provides server snapshot for SSR/RSC compatibility\n const cursor = useSyncExternalStore(\n getOrCreateSubscription(actualId),\n getOrCreateSnapshot(actualId),\n getOrCreateServerSnapshot(actualId),\n );\n\n // Memoize the return value to prevent unnecessary re-renders\n return useMemo(\n () => ({\n cursor,\n requestCursorChange: getOrCreateRequestCursorChange(actualId),\n clearCursor: getOrCreateClearCursor(actualId),\n }),\n [cursor, actualId],\n );\n}\n\n/**\n * Hook to automatically manage cursor for a component's lifecycle.\n *\n * This hook automatically requests a cursor when mounted and clears it when unmounted.\n * Useful for components that need to consistently show a specific cursor.\n *\n * @param cursor - The cursor to request\n * @param owner - The owner identifier\n * @param id - Optional map instance ID\n *\n * @example\n * ```tsx\n * function DrawingMode() {\n * useMapCursorEffect('crosshair', 'drawing-mode');\n *\n * return <div>Drawing mode active with crosshair cursor</div>;\n * }\n * ```\n */\nexport function useMapCursorEffect(\n cursor: CSSCursorType,\n owner: string,\n id?: UniqueId,\n): void {\n const { requestCursorChange, clearCursor } = useMapCursor(id);\n\n useEffect(() => {\n requestCursorChange(cursor, owner);\n\n return () => {\n clearCursor(owner);\n };\n }, [cursor, owner, requestCursorChange, clearCursor]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA,SAAgB,aAAa,IAAmC;CAC9D,MAAM,YAAY,WAAW,WAAW;CACxC,MAAM,WAAW,MAAM;AAEvB,KAAI,CAAC,SACH,OAAM,IAAI,MACR,kFACD;CAKH,MAAM,SAAS,qBACb,wBAAwB,SAAS,EACjC,oBAAoB,SAAS,EAC7B,0BAA0B,SAAS,CACpC;AAGD,QAAO,eACE;EACL;EACA,qBAAqB,+BAA+B,SAAS;EAC7D,aAAa,uBAAuB,SAAS;EAC9C,GACD,CAAC,QAAQ,SAAS,CACnB;;;;;;;;;;;;;;;;;;;;;AAsBH,SAAgB,mBACd,QACA,OACA,IACM;CACN,MAAM,EAAE,qBAAqB,gBAAgB,aAAa,GAAG;AAE7D,iBAAgB;AACd,sBAAoB,QAAQ,MAAM;AAElC,eAAa;AACX,eAAY,MAAM;;IAEnB;EAAC;EAAQ;EAAO;EAAqB;EAAY,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/map-mode/events.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Namespace prefix for all map mode events.
|
|
3
4
|
*/
|
|
@@ -24,14 +25,15 @@ declare const MapModeEventsNamespace = "map-mode";
|
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
27
|
declare const MapModeEvents: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
/** Emitted when the map mode has successfully changed */
|
|
29
|
+
readonly changed: "map-mode:changed";
|
|
30
|
+
/** Emitted when a component requests a mode change */
|
|
31
|
+
readonly changeRequest: "map-mode:change:request";
|
|
32
|
+
/** Emitted when authorization is required for a mode change */
|
|
33
|
+
readonly changeAuthorization: "map-mode:change:authorization";
|
|
34
|
+
/** Emitted when an authorization decision is made (approve/reject) */
|
|
35
|
+
readonly changeDecision: "map-mode:change:decision";
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
+
//#endregion
|
|
37
38
|
export { MapModeEvents, MapModeEventsNamespace };
|
|
39
|
+
//# sourceMappingURL=events.d.ts.map
|
package/dist/map-mode/events.js
CHANGED
|
@@ -1,15 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
//#region src/map-mode/events.ts
|
|
15
|
+
/**
|
|
16
|
+
* Namespace prefix for all map mode events.
|
|
17
|
+
*/
|
|
1
18
|
const MapModeEventsNamespace = "map-mode";
|
|
19
|
+
/**
|
|
20
|
+
* Event type constants for map mode state management.
|
|
21
|
+
*
|
|
22
|
+
* These events are emitted through the `@accelint/bus` event bus to coordinate
|
|
23
|
+
* map mode changes across components in a decoupled manner.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* import { useOn, useEmit } from '@accelint/bus/react';
|
|
28
|
+
* import { MapModeEvents } from '@accelint/map-toolkit/map-mode';
|
|
29
|
+
*
|
|
30
|
+
* // Listen for mode changes
|
|
31
|
+
* useOn(MapModeEvents.changed, (event) => {
|
|
32
|
+
* console.log('Mode changed to:', event.payload.currentMode);
|
|
33
|
+
* });
|
|
34
|
+
*
|
|
35
|
+
* // Emit a decision
|
|
36
|
+
* const emitDecision = useEmit(MapModeEvents.changeDecision);
|
|
37
|
+
* emitDecision({ authId, approved: true, owner: 'my-id', id });
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
2
40
|
const MapModeEvents = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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`
|
|
41
|
+
changed: `${MapModeEventsNamespace}:changed`,
|
|
42
|
+
changeRequest: `${MapModeEventsNamespace}:change:request`,
|
|
43
|
+
changeAuthorization: `${MapModeEventsNamespace}:change:authorization`,
|
|
44
|
+
changeDecision: `${MapModeEventsNamespace}:change:decision`
|
|
11
45
|
};
|
|
12
46
|
|
|
47
|
+
//#endregion
|
|
13
48
|
export { MapModeEvents, MapModeEventsNamespace };
|
|
14
|
-
//# sourceMappingURL=events.js.map
|
|
15
49
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"events.js","names":[],"sources":["../../src/map-mode/events.ts"],"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"],"mappings":";;;;;;;;;;;;;;;;;AAeA,MAAa,yBAAyB;;;;;;;;;;;;;;;;;;;;;;AAuBtC,MAAa,gBAAgB;CAE3B,SAAS,GAAG,uBAAuB;CAEnC,eAAe,GAAG,uBAAuB;CAEzC,qBAAqB,GAAG,uBAAuB;CAE/C,gBAAgB,GAAG,uBAAuB;CAC3C"}
|
package/dist/map-mode/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { MapModeEvents, MapModeEventsNamespace } from "./events.js";
|
|
14
|
+
import { clearMapModeState, getCurrentModeOwner } from "./store.js";
|
|
15
|
+
import { UseMapModeReturn, useMapMode } from "./use-map-mode.js";
|
|
16
|
+
import { MapModeEventType, ModeChangeAuthorizationEvent, ModeChangeAuthorizationPayload, ModeChangeDecisionEvent, ModeChangeDecisionPayload, ModeChangeRequestEvent, ModeChangeRequestPayload, ModeChangedEvent, ModeChangedPayload } from "./types.js";
|
|
17
|
+
export { type MapModeEventType, MapModeEvents, MapModeEventsNamespace, type ModeChangeAuthorizationEvent, type ModeChangeAuthorizationPayload, type ModeChangeDecisionEvent, type ModeChangeDecisionPayload, type ModeChangeRequestEvent, type ModeChangeRequestPayload, type ModeChangedEvent, type ModeChangedPayload, type UseMapModeReturn, clearMapModeState, getCurrentModeOwner, useMapMode };
|
package/dist/map-mode/index.js
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
import { MapModeEvents, MapModeEventsNamespace } from "./events.js";
|
|
15
|
+
import { clearMapModeState, getCurrentModeOwner } from "./store.js";
|
|
16
|
+
import { useMapMode } from "./use-map-mode.js";
|
|
17
|
+
|
|
18
|
+
export { MapModeEvents, MapModeEventsNamespace, clearMapModeState, getCurrentModeOwner, useMapMode };
|
package/dist/map-mode/store.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 Hypergiant Galactic Systems Inc. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at https://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
2
12
|
|
|
13
|
+
import { UniqueId } from "@accelint/core";
|
|
14
|
+
|
|
15
|
+
//#region src/map-mode/store.d.ts
|
|
3
16
|
/**
|
|
4
17
|
* Creates or retrieves a cached subscription function for a given instanceId.
|
|
5
18
|
* Uses a fan-out pattern: 1 bus listener -> N React subscribers.
|
|
@@ -17,6 +30,15 @@ declare function getOrCreateSubscription(instanceId: UniqueId): (onStoreChange:
|
|
|
17
30
|
* @returns A snapshot function for useSyncExternalStore
|
|
18
31
|
*/
|
|
19
32
|
declare function getOrCreateSnapshot(instanceId: UniqueId): () => string;
|
|
33
|
+
/**
|
|
34
|
+
* Creates or retrieves a cached server snapshot function for a given instanceId.
|
|
35
|
+
* Server snapshots always return the default mode since mode state is client-only.
|
|
36
|
+
* Required for SSR/RSC compatibility with useSyncExternalStore.
|
|
37
|
+
*
|
|
38
|
+
* @param instanceId - The unique identifier for the map mode instance
|
|
39
|
+
* @returns A server snapshot function for useSyncExternalStore
|
|
40
|
+
*/
|
|
41
|
+
declare function getOrCreateServerSnapshot(instanceId: UniqueId): () => string;
|
|
20
42
|
/**
|
|
21
43
|
* Creates or retrieves a cached requestModeChange function for a given instanceId.
|
|
22
44
|
* This maintains referential stability for the function reference.
|
|
@@ -44,5 +66,6 @@ declare function getCurrentModeOwner(instanceId: UniqueId): string | undefined;
|
|
|
44
66
|
* ```
|
|
45
67
|
*/
|
|
46
68
|
declare function clearMapModeState(instanceId: UniqueId): void;
|
|
47
|
-
|
|
48
|
-
export { clearMapModeState, getCurrentModeOwner, getOrCreateRequestModeChange, getOrCreateSnapshot, getOrCreateSubscription };
|
|
69
|
+
//#endregion
|
|
70
|
+
export { clearMapModeState, getCurrentModeOwner, getOrCreateRequestModeChange, getOrCreateServerSnapshot, getOrCreateSnapshot, getOrCreateSubscription };
|
|
71
|
+
//# sourceMappingURL=store.d.ts.map
|