@wovvmap/runtime-core 0.0.0-stage → 1.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.
Files changed (35) hide show
  1. package/dist/discovery.d.ts +188 -0
  2. package/dist/discovery.d.ts.map +1 -0
  3. package/dist/discovery.js +706 -0
  4. package/dist/index.d.ts +6 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +5 -0
  7. package/dist/offline/ViewerOfflineCoordinator.d.ts +36 -0
  8. package/dist/offline/ViewerOfflineCoordinator.d.ts.map +1 -0
  9. package/dist/offline/ViewerOfflineCoordinator.js +215 -0
  10. package/dist/offline/ViewerOfflineRouteCoordinator.d.ts +57 -0
  11. package/dist/offline/ViewerOfflineRouteCoordinator.d.ts.map +1 -0
  12. package/dist/offline/ViewerOfflineRouteCoordinator.js +407 -0
  13. package/dist/offline/ViewerReconnectCoordinator.d.ts +36 -0
  14. package/dist/offline/ViewerReconnectCoordinator.d.ts.map +1 -0
  15. package/dist/offline/ViewerReconnectCoordinator.js +176 -0
  16. package/dist/offline/index.d.ts +8 -0
  17. package/dist/offline/index.d.ts.map +1 -0
  18. package/dist/offline/index.js +3 -0
  19. package/dist/offline/offlineMapStorage.d.ts +29 -0
  20. package/dist/offline/offlineMapStorage.d.ts.map +1 -0
  21. package/dist/offline/offlineMapStorage.js +1 -0
  22. package/dist/offline/offlineRouteStorage.d.ts +31 -0
  23. package/dist/offline/offlineRouteStorage.d.ts.map +1 -0
  24. package/dist/offline/offlineRouteStorage.js +1 -0
  25. package/dist/viewer.d.ts +74 -0
  26. package/dist/viewer.d.ts.map +1 -0
  27. package/dist/viewer.js +383 -0
  28. package/dist/viewerDisplay.d.ts +20 -0
  29. package/dist/viewerDisplay.d.ts.map +1 -0
  30. package/dist/viewerDisplay.js +35 -0
  31. package/dist/viewerStore.d.ts +49 -0
  32. package/dist/viewerStore.d.ts.map +1 -0
  33. package/dist/viewerStore.js +85 -0
  34. package/package.json +32 -3
  35. package/README.md +0 -3
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @file discovery.ts
3
+ * @description Shared per-viewer, per-channel catalog & search query coordinator for `@wovvmap/runtime-core`.
4
+ * Owns debounce scheduling, monotonic request sequencing (out-of-order stale response rejection),
5
+ * automatic pagination reset on query/filter/sort/target changes, bounded "load more" page appending,
6
+ * retry handling, and map-revision invalidation across `general`, `origin`, and `destination` channels.
7
+ *
8
+ * Hinglish: `@wovvmap/runtime-core` ke liye shared per-viewer, per-channel (`general`, `origin`, `destination`)
9
+ * catalog aur search query coordinator. Ye debounce, stale/out-of-order response rejection, query/filter/sort
10
+ * badalne par pagination reset, `loadMore` page append, retry aur map lifecycle invalidation sambhalta hai.
11
+ */
12
+ import { type CatalogDiscoveryChannel, type CatalogFilterInput, type CatalogFloorSecondarySortMode, type CatalogGroupMembersPage, type CatalogGroupMembersRequest, type CatalogPage, type CatalogPaginationInput, type CatalogSortMode, type CatalogTarget, type DiscoveryChannelSnapshot, type DiscoveryQueryParams, type NodeGroupSelectionRequest } from '@wovvmap/contracts';
13
+ import type { ViewerOperations } from './viewer.js';
14
+ export type { CatalogDiscoveryChannel, CatalogFloorSecondarySortMode, CatalogItemForTarget, DiscoveryChannelSnapshot, DiscoveryQueryParams, DiscoveryQueryStatus, } from '@wovvmap/contracts';
15
+ /**
16
+ * Per-channel discovery query controller managing debounced execution, stale-response rejection,
17
+ * pagination reset on filter/query/sort changes, `loadMore` appending, and `retry`.
18
+ *
19
+ * Hinglish: Ek single channel (`general`, `origin`, ya `destination`) ka query controller jo
20
+ * debounce, stale response rejection, pagination reset, `loadMore` aur `retry` manage karta hai.
21
+ */
22
+ export declare class DiscoveryChannelController<TTarget extends CatalogTarget = CatalogTarget> {
23
+ readonly channel: CatalogDiscoveryChannel;
24
+ private readonly getOperations;
25
+ private readonly getCommittedMallId;
26
+ private readonly defaultDebounceMs;
27
+ private readonly getActiveFloorIndex?;
28
+ private catalogEpoch;
29
+ private bookmarkSequence;
30
+ private bookmarks;
31
+ private bookmarkIds;
32
+ /** Keep immutable result references in the query owner; history receives only an opaque token.
33
+ * Hinglish: Loaded public rows channel cache mein rahein; history mein sirf chhota token jaye. */
34
+ captureBookmark(): string;
35
+ hasBookmark(key: string): boolean;
36
+ /** Restore settled pages without rereads; interrupted queries restart through normal stale guards.
37
+ * Hinglish: Ready pages API dobara nahi maangti; pending query safe path se restart ho. */
38
+ restoreBookmark(key: string): boolean;
39
+ /** Retain query/filter intent across offer changes; old bookmark results must be revalidated.
40
+ * Hinglish: Offer date par wahi query refresh ho; Back stale pages/highlights na laaye. */
41
+ refreshCatalog(): void;
42
+ /** Map/document replacement retires bookmarks; ordinary filter resets keep Back usable.
43
+ * Hinglish: Naye map ke purane tokens invalid hon; filter badalne se Back cache na mite. */
44
+ clearBookmarks(): void;
45
+ private snapshot;
46
+ private readonly emptyTargetSnapshots;
47
+ private readonly listeners;
48
+ private requestSeq;
49
+ private debounceTimer;
50
+ private pendingDebounceReject;
51
+ private lastParams;
52
+ private pinnedActiveFloorIndex;
53
+ constructor(channel: CatalogDiscoveryChannel, getOperations: () => Pick<ViewerOperations, 'getCatalog' | 'search' | 'getGroupMembers' | 'selectNodeGroup'>, getCommittedMallId: () => string, initialTarget?: TTarget, defaultDebounceMs?: number, getActiveFloorIndex?: (() => number | undefined) | undefined);
54
+ /** Read a stable empty view when this channel currently belongs to another target; never reset on read.
55
+ * Hinglish: Doosre target ki rows expose na karo; read par channel reset/query nahi hoti. */
56
+ getSnapshot: (target?: TTarget) => Readonly<DiscoveryChannelSnapshot<TTarget>>;
57
+ subscribe: (listener: () => void) => (() => void);
58
+ private updateSnapshot;
59
+ private clearDebounceTimer;
60
+ /**
61
+ * Executes a catalog or search query for this channel, resetting pagination to `offset: 0`.
62
+ * Supersedes any pending debounced or in-flight request on the same channel.
63
+ * Clears the previous result and its pagination together so failed/cancelled replacement queries
64
+ * cannot append a new query's page to old results.
65
+ *
66
+ * Hinglish: Is channel par catalog ya search query run karta hai (`offset: 0` se), purane
67
+ * pending/in-flight requests ko supersede karta hai aur purane results/pagination saath clear karta hai.
68
+ */
69
+ execute(params: DiscoveryQueryParams<TTarget>, options?: {
70
+ immediate?: boolean;
71
+ _preservePinnedFloor?: boolean;
72
+ }): Promise<CatalogPage<TTarget> | null>;
73
+ private resolveActionFloorIndex;
74
+ /**
75
+ * Updates the search query string on the current channel and schedules a debounced search.
76
+ * Resets pagination to `offset: 0`.
77
+ *
78
+ * Hinglish: Current channel ka search query text update karta hai (`offset: 0` reset ke saath).
79
+ */
80
+ setQuery(query: string, options?: {
81
+ immediate?: boolean;
82
+ debounceMs?: number;
83
+ activeFloorIndex?: number;
84
+ }): Promise<CatalogPage<TTarget> | null>;
85
+ /**
86
+ * Updates the filter criteria on the current channel and executes immediately (`offset: 0`).
87
+ *
88
+ * Hinglish: Current channel ka filter update karta hai aur `offset: 0` se query run karta hai.
89
+ */
90
+ setFilter(filter: CatalogFilterInput | undefined, options?: {
91
+ immediate?: boolean;
92
+ activeFloorIndex?: number;
93
+ }): Promise<CatalogPage<TTarget> | null>;
94
+ /**
95
+ * Updates the sort mode on the current channel and executes immediately (`offset: 0`).
96
+ * Forwards the latest active floor context for floor-proximity / floor-promotion sorts without
97
+ * requiring an automatic query on floor switch.
98
+ *
99
+ * Hinglish: Current channel ka sort mode update karta hai aur latest active floor context ke saath
100
+ * `offset: 0` se query run karta hai.
101
+ */
102
+ setSortBy(sortBy: CatalogSortMode | undefined, floorSecondarySortBy?: CatalogFloorSecondarySortMode, options?: {
103
+ immediate?: boolean;
104
+ activeFloorIndex?: number;
105
+ }): Promise<CatalogPage<TTarget> | null>;
106
+ /**
107
+ * Reads bounded member details for a multi-location store group while automatically forwarding
108
+ * this channel's active `mode`, `query`, `filter`, `sortBy`, `floorSecondarySortBy`, `activeFloorIndex`,
109
+ * `mallId`, and `expectedRevision` when not explicitly overridden in the request.
110
+ *
111
+ * Hinglish: Is channel ke active `query`, `filter`, `sortBy`, `floorSecondarySortBy` aur `activeFloorIndex`
112
+ * ko forward karte hue multi-location store group ke bounded member details fetch karta hai.
113
+ */
114
+ getGroupMembers(groupIdOrRequest: string | CatalogGroupMembersRequest, pagination?: CatalogPaginationInput): Promise<CatalogGroupMembersPage | null>;
115
+ /** Select a group with this channel's exact query context, without fetching its member pages.
116
+ * Hinglish: Wahi query/filter context se group select ho; selection ke liye members API dobara na chale. */
117
+ selectNodeGroup(groupIdOrRequest: string | NodeGroupSelectionRequest | null): Promise<void>;
118
+ /** Capture this channel's exact group scope for a different explicit SDK action (e.g. endpoints).
119
+ * Hinglish: Endpoint action ko bhi wahi query/filter/floor scope mile; UI mein mapping repeat nahi. */
120
+ getGroupSelectionRequest(groupId: string): NodeGroupSelectionRequest;
121
+ private createGroupRequest;
122
+ /**
123
+ * Fetches and appends the next page when `hasMore` is `true` and `nextOffset !== null`.
124
+ * Rejects duplicate in-flight `loadMore` calls and discards stale responses if the query or map changed.
125
+ *
126
+ * Hinglish: `hasMore` hone par next page fetch karke existing items me append karta hai.
127
+ */
128
+ loadMore(): Promise<CatalogPage<TTarget> | null>;
129
+ /**
130
+ * Retries the most recent query on this channel immediately.
131
+ *
132
+ * Hinglish: Is channel ki last query ko turant retry karta hai.
133
+ */
134
+ retry(options?: {
135
+ activeFloorIndex?: number;
136
+ }): Promise<CatalogPage<TTarget> | null>;
137
+ /**
138
+ * Cancels any pending debounce timer or in-flight request on this channel.
139
+ *
140
+ * Hinglish: Is channel ke pending debounce timer ya in-flight request ko cancel karta hai.
141
+ */
142
+ cancel(): void;
143
+ /**
144
+ * Resets this channel back to its initial idle state and invalidates any in-flight request.
145
+ *
146
+ * Hinglish: Is channel ko initial idle state par reset karta hai aur in-flight request invalidate karta hai.
147
+ */
148
+ reset(target?: TTarget): void;
149
+ private runRequest;
150
+ }
151
+ /**
152
+ * Per-viewer discovery coordinator owning isolated `DiscoveryChannelController` instances
153
+ * (`general`, `origin`, `destination`, or custom channel keys) and bounded `getGroupMembers` calls.
154
+ *
155
+ * Hinglish: Per-viewer discovery coordinator jo `general`, `origin`, `destination` channels
156
+ * aur bounded `getGroupMembers` calls own karta hai (bina kisi global singleton ke).
157
+ */
158
+ export declare class ViewerDiscoveryCoordinator {
159
+ private readonly getOperations;
160
+ private readonly getCommittedMallId;
161
+ private readonly getActiveFloorIndex?;
162
+ private readonly channels;
163
+ constructor(getOperations: () => Pick<ViewerOperations, 'getCatalog' | 'search' | 'getGroupMembers' | 'selectNodeGroup'>, getCommittedMallId: () => string, getActiveFloorIndex?: (() => number | undefined) | undefined);
164
+ /**
165
+ * Returns (or lazily creates) the isolated `DiscoveryChannelController` for the given channel name.
166
+ *
167
+ * Hinglish: Diye gaye channel (`general`, `origin`, `destination`) ka isolated controller return karta hai.
168
+ */
169
+ getChannel<TTarget extends CatalogTarget = 'stores'>(channel?: CatalogDiscoveryChannel, initialTarget?: TTarget): DiscoveryChannelController<TTarget>;
170
+ /**
171
+ * Reads bounded member details for a multi-location store group via the viewer transport.
172
+ * When an active store channel exists (`general` by default), forwards its active `mode`, `query`,
173
+ * `filter`, `sortBy`, `floorSecondarySortBy`, and `activeFloorIndex` unless overridden in `request`.
174
+ *
175
+ * Hinglish: Multi-location store group ke bounded member details transport ke zariye fetch karta hai.
176
+ */
177
+ getGroupMembers(request: CatalogGroupMembersRequest, channel?: CatalogDiscoveryChannel): Promise<CatalogGroupMembersPage | null>;
178
+ /** Refresh active bounded reads when catalog eligibility changes without a new map revision.
179
+ * Hinglish: Naya map load nahi; active channels apna same query scope dobara resolve karein. */
180
+ refreshCatalog(): void;
181
+ /**
182
+ * Cancels and resets all channels when the viewer unloads, switches malls, or is destroyed.
183
+ *
184
+ * Hinglish: Viewer unload, mall switch ya destroy hone par saare channels ko reset aur invalidate karta hai.
185
+ */
186
+ invalidateAll(): void;
187
+ }
188
+ //# sourceMappingURL=discovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"A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