@wovvmap/ui-headless 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.
- package/README.md +24 -2
- package/dist/HeaderInfoController.d.ts +44 -0
- package/dist/HeaderInfoController.d.ts.map +1 -0
- package/dist/HeaderInfoController.js +112 -0
- package/dist/appearance.d.ts +26 -0
- package/dist/appearance.d.ts.map +1 -0
- package/dist/appearance.js +117 -0
- package/dist/classic/ClassicController.d.ts +124 -0
- package/dist/classic/ClassicController.d.ts.map +1 -0
- package/dist/classic/ClassicController.js +1131 -0
- package/dist/classic/classic.types.d.ts +111 -0
- package/dist/classic/classic.types.d.ts.map +1 -0
- package/dist/classic/classic.types.js +1 -0
- package/dist/classic/index.d.ts +3 -0
- package/dist/classic/index.d.ts.map +1 -0
- package/dist/classic/index.js +2 -0
- package/dist/components.d.ts +253 -0
- package/dist/components.d.ts.map +1 -0
- package/dist/components.js +30 -0
- package/dist/directions/DirectionController.d.ts +76 -0
- package/dist/directions/DirectionController.d.ts.map +1 -0
- package/dist/directions/DirectionController.js +467 -0
- package/dist/directions/direction.types.d.ts +81 -0
- package/dist/directions/direction.types.d.ts.map +1 -0
- package/dist/directions/direction.types.js +1 -0
- package/dist/directions/directionPresentation.d.ts +17 -0
- package/dist/directions/directionPresentation.d.ts.map +1 -0
- package/dist/directions/directionPresentation.js +34 -0
- package/dist/flow/DiscoveryFlowController.d.ts +36 -0
- package/dist/flow/DiscoveryFlowController.d.ts.map +1 -0
- package/dist/flow/DiscoveryFlowController.js +162 -0
- package/dist/flow/FlowHistoryController.d.ts +14 -0
- package/dist/flow/FlowHistoryController.d.ts.map +1 -0
- package/dist/flow/FlowHistoryController.js +31 -0
- package/dist/flow/index.d.ts +3 -0
- package/dist/flow/index.d.ts.map +1 -0
- package/dist/flow/index.js +2 -0
- package/dist/gallery/PromotionGalleryController.d.ts +32 -0
- package/dist/gallery/PromotionGalleryController.d.ts.map +1 -0
- package/dist/gallery/PromotionGalleryController.js +80 -0
- package/dist/gallery/index.d.ts +2 -0
- package/dist/gallery/index.d.ts.map +1 -0
- package/dist/gallery/index.js +1 -0
- package/dist/headerInfo.d.ts +27 -0
- package/dist/headerInfo.d.ts.map +1 -0
- package/dist/headerInfo.js +70 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/presentation.d.ts +49 -0
- package/dist/presentation.d.ts.map +1 -0
- package/dist/presentation.js +116 -0
- package/dist/routes/RoutePreviewController.d.ts +61 -0
- package/dist/routes/RoutePreviewController.d.ts.map +1 -0
- package/dist/routes/RoutePreviewController.js +321 -0
- package/dist/routes/playback/RoutePlaybackController.d.ts +26 -0
- package/dist/routes/playback/RoutePlaybackController.d.ts.map +1 -0
- package/dist/routes/playback/RoutePlaybackController.js +115 -0
- package/dist/routes/routePlayback.types.d.ts +38 -0
- package/dist/routes/routePlayback.types.d.ts.map +1 -0
- package/dist/routes/routePlayback.types.js +1 -0
- package/dist/routes/routePreview.types.d.ts +71 -0
- package/dist/routes/routePreview.types.d.ts.map +1 -0
- package/dist/routes/routePreview.types.js +1 -0
- package/dist/routes/routePreviewPresentation.d.ts +8 -0
- package/dist/routes/routePreviewPresentation.d.ts.map +1 -0
- package/dist/routes/routePreviewPresentation.js +26 -0
- package/dist/routes/routeStepIcons.d.ts +15 -0
- package/dist/routes/routeStepIcons.d.ts.map +1 -0
- package/dist/routes/routeStepIcons.js +102 -0
- package/dist/routes/routeStepPresentation.d.ts +5 -0
- package/dist/routes/routeStepPresentation.d.ts.map +1 -0
- package/dist/routes/routeStepPresentation.js +15 -0
- package/dist/routes/routeSteps.types.d.ts +51 -0
- package/dist/routes/routeSteps.types.d.ts.map +1 -0
- package/dist/routes/routeSteps.types.js +1 -0
- package/dist/routes/steps/RouteStepsController.d.ts +49 -0
- package/dist/routes/steps/RouteStepsController.d.ts.map +1 -0
- package/dist/routes/steps/RouteStepsController.js +312 -0
- package/dist/saved-routes/SavedRoutesController.d.ts +76 -0
- package/dist/saved-routes/SavedRoutesController.d.ts.map +1 -0
- package/dist/saved-routes/SavedRoutesController.js +366 -0
- package/dist/storeHours.d.ts +19 -0
- package/dist/storeHours.d.ts.map +1 -0
- package/dist/storeHours.js +155 -0
- package/dist/storeList.d.ts +19 -0
- package/dist/storeList.d.ts.map +1 -0
- package/dist/storeList.js +21 -0
- package/dist/theme.d.ts +42 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +56 -0
- package/package.json +32 -3
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
import { OfflineRouteCommands, freezeOfflineRouteState, } from '@wovvmap/contracts';
|
|
2
|
+
/** Normalize sync direct methods and asynchronous WebView operations at one presentation boundary.
|
|
3
|
+
* Hinglish: Har component mein wrappers repeat na hon; actual commands same SDK owner ko jayenge. */
|
|
4
|
+
export function createSavedRoutesBindings(source) {
|
|
5
|
+
const names = [
|
|
6
|
+
...Object.keys(OfflineRouteCommands),
|
|
7
|
+
'getRoute',
|
|
8
|
+
'getOfflineState',
|
|
9
|
+
'prepareOfflineMap',
|
|
10
|
+
'configureOffline',
|
|
11
|
+
'cancelOfflineOperation',
|
|
12
|
+
];
|
|
13
|
+
return {
|
|
14
|
+
...Object.fromEntries(names.map((name) => [
|
|
15
|
+
name,
|
|
16
|
+
(...args) => Promise.resolve().then(() => Reflect.apply(source[name], source, args)),
|
|
17
|
+
])),
|
|
18
|
+
on: source.on.bind(source),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Safe shared error presentation, never raw server/source/credential diagnostics.
|
|
22
|
+
* Hinglish: Dono UI mein same helpful message; private exception text ya IDs user ko na dikhayein. */
|
|
23
|
+
function message(error) {
|
|
24
|
+
const code = error?.code;
|
|
25
|
+
const messages = {
|
|
26
|
+
OFFLINE_MAP_REQUIRED: 'Save this map for offline use before saving a route.',
|
|
27
|
+
OFFLINE_ROUTE_UNSUPPORTED: 'Saved routes are unavailable in this configuration.',
|
|
28
|
+
OFFLINE_ROUTE_EXPIRED: 'This saved route has expired. Connect and generate a new route.',
|
|
29
|
+
OFFLINE_ROUTE_STALE: 'This saved route does not match the current map or policy.',
|
|
30
|
+
OFFLINE_ROUTE_NOT_FOUND: 'This saved route is no longer available.',
|
|
31
|
+
OFFLINE_ROUTE_INVALID: 'This saved route could not be verified.',
|
|
32
|
+
OFFLINE_ROUTE_LIMIT: 'Saved-route storage is full. Remove a saved route and try again.',
|
|
33
|
+
CANCELLED: '',
|
|
34
|
+
UNAUTHORIZED: 'Sign in to save this route.',
|
|
35
|
+
FORBIDDEN: 'This route cannot be saved with the current access.',
|
|
36
|
+
ROUTE_EXPIRED: 'Generate a new route before saving.',
|
|
37
|
+
};
|
|
38
|
+
return code && messages[code] !== undefined
|
|
39
|
+
? messages[code]
|
|
40
|
+
: 'Unable to complete the saved-route action. Try again.';
|
|
41
|
+
}
|
|
42
|
+
/** Presentation queries and disclosure only; accepted routes and durable jobs remain SDK-owned.
|
|
43
|
+
* Hinglish: List/open/confirm UI state yahan; save/restore logic, graph aur geometry SDK mein rahein. */
|
|
44
|
+
export class SavedRoutesController {
|
|
45
|
+
api;
|
|
46
|
+
restored;
|
|
47
|
+
listeners = new Set();
|
|
48
|
+
opened = false;
|
|
49
|
+
loading = false;
|
|
50
|
+
items = [];
|
|
51
|
+
error = null;
|
|
52
|
+
confirmId = null;
|
|
53
|
+
request = 0;
|
|
54
|
+
pending = null;
|
|
55
|
+
stateVersion = 0;
|
|
56
|
+
routeVersion = 0;
|
|
57
|
+
mapVersion = 0;
|
|
58
|
+
expiryTimer;
|
|
59
|
+
mapBusy = false;
|
|
60
|
+
mapReady = false;
|
|
61
|
+
operation = 0;
|
|
62
|
+
connected = 0;
|
|
63
|
+
syncRequest = 0;
|
|
64
|
+
route = null;
|
|
65
|
+
state = {
|
|
66
|
+
enabled: false,
|
|
67
|
+
supported: false,
|
|
68
|
+
status: 'disabled',
|
|
69
|
+
savedRoute: null,
|
|
70
|
+
error: null,
|
|
71
|
+
};
|
|
72
|
+
snapshot = this.read();
|
|
73
|
+
constructor(api, restored = () => { }) {
|
|
74
|
+
this.api = api;
|
|
75
|
+
this.restored = restored;
|
|
76
|
+
}
|
|
77
|
+
getSnapshot = () => this.snapshot;
|
|
78
|
+
subscribe = (listener) => {
|
|
79
|
+
this.listeners.add(listener);
|
|
80
|
+
return () => this.listeners.delete(listener);
|
|
81
|
+
};
|
|
82
|
+
connect = () => {
|
|
83
|
+
const connection = ++this.connected;
|
|
84
|
+
const off = [
|
|
85
|
+
this.api.on('offlineRouteChanged', (state) => {
|
|
86
|
+
++this.stateVersion;
|
|
87
|
+
this.state = freezeOfflineRouteState(state);
|
|
88
|
+
this.error = state.error ? message(state.error) : null;
|
|
89
|
+
this.publish();
|
|
90
|
+
if (this.opened && !this.read().busy)
|
|
91
|
+
void this.refresh();
|
|
92
|
+
}),
|
|
93
|
+
this.api.on('offlineChanged', (state) => {
|
|
94
|
+
++this.mapVersion;
|
|
95
|
+
this.mapBusy = ['saving', 'removing'].includes(state.status);
|
|
96
|
+
this.mapReady = state.status === 'ready';
|
|
97
|
+
if (state.status === 'error')
|
|
98
|
+
this.error = 'This map could not be saved for offline use.';
|
|
99
|
+
this.publish();
|
|
100
|
+
}),
|
|
101
|
+
this.api.on('routeChanged', (route) => {
|
|
102
|
+
++this.routeVersion;
|
|
103
|
+
this.route = route;
|
|
104
|
+
this.publish();
|
|
105
|
+
}),
|
|
106
|
+
this.api.on('loaded', () => {
|
|
107
|
+
this.items = [];
|
|
108
|
+
this.close();
|
|
109
|
+
void this.sync();
|
|
110
|
+
}),
|
|
111
|
+
];
|
|
112
|
+
void this.sync();
|
|
113
|
+
return () => {
|
|
114
|
+
off.forEach((stop) => stop());
|
|
115
|
+
queueMicrotask(() => {
|
|
116
|
+
if (connection === this.connected) {
|
|
117
|
+
if (this.pending === 'restore' || this.state.status === 'restoring')
|
|
118
|
+
void this.api.cancelOfflineRouteOperation().catch(() => { });
|
|
119
|
+
++this.connected;
|
|
120
|
+
++this.request;
|
|
121
|
+
++this.operation;
|
|
122
|
+
clearTimeout(this.expiryTimer);
|
|
123
|
+
this.pending = null;
|
|
124
|
+
this.opened = false;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
async sync() {
|
|
130
|
+
const connection = this.connected;
|
|
131
|
+
const request = ++this.syncRequest;
|
|
132
|
+
const stateVersion = this.stateVersion, routeVersion = this.routeVersion, mapVersion = this.mapVersion;
|
|
133
|
+
try {
|
|
134
|
+
const [state, route, offline] = await Promise.all([
|
|
135
|
+
this.api.getOfflineRouteState(),
|
|
136
|
+
this.api.getRoute(),
|
|
137
|
+
this.api.getOfflineState(),
|
|
138
|
+
]);
|
|
139
|
+
if (connection !== this.connected || request !== this.syncRequest)
|
|
140
|
+
return;
|
|
141
|
+
if (stateVersion === this.stateVersion) {
|
|
142
|
+
this.state = freezeOfflineRouteState(state);
|
|
143
|
+
if (state.error && !this.error)
|
|
144
|
+
this.error = message(state.error);
|
|
145
|
+
}
|
|
146
|
+
if (routeVersion === this.routeVersion)
|
|
147
|
+
this.route = route;
|
|
148
|
+
if (mapVersion === this.mapVersion) {
|
|
149
|
+
this.mapReady = offline.status === 'ready';
|
|
150
|
+
this.mapBusy = ['saving', 'removing'].includes(offline.status);
|
|
151
|
+
}
|
|
152
|
+
this.publish();
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
if (connection === this.connected && request === this.syncRequest) {
|
|
156
|
+
this.error = message(error);
|
|
157
|
+
this.publish();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
open = () => {
|
|
162
|
+
this.opened = true;
|
|
163
|
+
this.confirmId = null;
|
|
164
|
+
this.publish();
|
|
165
|
+
void this.refresh();
|
|
166
|
+
};
|
|
167
|
+
close = () => {
|
|
168
|
+
if (this.state.status === 'restoring' || this.pending === 'restore')
|
|
169
|
+
void this.api.cancelOfflineRouteOperation().catch(() => { });
|
|
170
|
+
this.dismiss();
|
|
171
|
+
this.publish();
|
|
172
|
+
};
|
|
173
|
+
/** Retire list reads on every exit, including successful Restore without cancelling its preview.
|
|
174
|
+
* Hinglish: Close aur restored preview dono par purani list/timer band hon; accepted path na mite. */
|
|
175
|
+
dismiss() {
|
|
176
|
+
++this.request;
|
|
177
|
+
++this.operation;
|
|
178
|
+
clearTimeout(this.expiryTimer);
|
|
179
|
+
this.pending = null;
|
|
180
|
+
this.opened = false;
|
|
181
|
+
this.loading = false;
|
|
182
|
+
this.confirmId = null;
|
|
183
|
+
}
|
|
184
|
+
refresh = async () => {
|
|
185
|
+
const request = ++this.request;
|
|
186
|
+
this.loading = true;
|
|
187
|
+
this.error = null;
|
|
188
|
+
this.publish();
|
|
189
|
+
try {
|
|
190
|
+
const items = await this.api.getSavedRoutes();
|
|
191
|
+
if (request === this.request) {
|
|
192
|
+
this.items = items.filter((item) => item.validUntil > Date.now());
|
|
193
|
+
this.scheduleExpiry();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (request === this.request)
|
|
198
|
+
this.error = message(error);
|
|
199
|
+
}
|
|
200
|
+
finally {
|
|
201
|
+
if (request === this.request) {
|
|
202
|
+
this.loading = false;
|
|
203
|
+
this.publish();
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
save = () => {
|
|
208
|
+
const route = this.route;
|
|
209
|
+
if (!this.snapshot.canSave || !route?.routeSet || !route.selectedRouteId)
|
|
210
|
+
return;
|
|
211
|
+
void this.run(() => this.api.prepareOfflineRoute({
|
|
212
|
+
routeSetId: route.routeSet.routeSetId,
|
|
213
|
+
routeId: route.selectedRouteId,
|
|
214
|
+
}));
|
|
215
|
+
};
|
|
216
|
+
restore = (id) => {
|
|
217
|
+
if (this.snapshot.busy)
|
|
218
|
+
return;
|
|
219
|
+
const request = ++this.operation;
|
|
220
|
+
this.pending = 'restore';
|
|
221
|
+
this.publish();
|
|
222
|
+
void Promise.resolve()
|
|
223
|
+
.then(() => {
|
|
224
|
+
if (request !== this.operation)
|
|
225
|
+
return;
|
|
226
|
+
return this.api.restoreOfflineRoute(id);
|
|
227
|
+
})
|
|
228
|
+
.then((result) => {
|
|
229
|
+
if (!result)
|
|
230
|
+
return;
|
|
231
|
+
if (request !== this.operation)
|
|
232
|
+
return;
|
|
233
|
+
this.dismiss();
|
|
234
|
+
this.error = null;
|
|
235
|
+
this.restored();
|
|
236
|
+
this.publish();
|
|
237
|
+
})
|
|
238
|
+
.catch((error) => {
|
|
239
|
+
if (request === this.operation) {
|
|
240
|
+
this.pending = null;
|
|
241
|
+
this.error = message(error);
|
|
242
|
+
this.publish();
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
confirmRemove = (id) => {
|
|
247
|
+
this.confirmId = id;
|
|
248
|
+
this.publish();
|
|
249
|
+
};
|
|
250
|
+
remove = () => {
|
|
251
|
+
const id = this.confirmId;
|
|
252
|
+
if (!id || this.snapshot.busy)
|
|
253
|
+
return;
|
|
254
|
+
this.confirmId = null;
|
|
255
|
+
void this.run(() => this.api.removeOfflineRoute(id));
|
|
256
|
+
};
|
|
257
|
+
cancel = () => {
|
|
258
|
+
void this.run(async () => {
|
|
259
|
+
if (this.mapBusy)
|
|
260
|
+
await this.api.cancelOfflineOperation();
|
|
261
|
+
return this.api.cancelOfflineRouteOperation();
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
saveMap = () => {
|
|
265
|
+
if (this.snapshot.busy)
|
|
266
|
+
return;
|
|
267
|
+
const request = ++this.operation;
|
|
268
|
+
this.pending = 'action';
|
|
269
|
+
this.publish();
|
|
270
|
+
void this.api
|
|
271
|
+
.configureOffline({ enabled: true })
|
|
272
|
+
.then(async () => {
|
|
273
|
+
if (request !== this.operation)
|
|
274
|
+
return;
|
|
275
|
+
const version = this.mapVersion;
|
|
276
|
+
const state = await this.api.prepareOfflineMap();
|
|
277
|
+
if (request === this.operation && version === this.mapVersion) {
|
|
278
|
+
this.mapBusy = ['saving', 'removing'].includes(state.status);
|
|
279
|
+
this.mapReady = state.status === 'ready';
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
.catch((error) => {
|
|
283
|
+
if (request === this.operation)
|
|
284
|
+
this.error = message(error);
|
|
285
|
+
})
|
|
286
|
+
.finally(() => {
|
|
287
|
+
if (request === this.operation) {
|
|
288
|
+
this.pending = null;
|
|
289
|
+
this.publish();
|
|
290
|
+
}
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
async run(operation) {
|
|
294
|
+
const request = ++this.operation, version = this.stateVersion;
|
|
295
|
+
this.pending = 'action';
|
|
296
|
+
this.publish();
|
|
297
|
+
try {
|
|
298
|
+
const state = await operation();
|
|
299
|
+
if (request !== this.operation)
|
|
300
|
+
return;
|
|
301
|
+
if (version === this.stateVersion) {
|
|
302
|
+
this.state = state;
|
|
303
|
+
this.error = state.error ? message(state.error) : null;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
catch (error) {
|
|
307
|
+
if (request === this.operation)
|
|
308
|
+
this.error = message(error);
|
|
309
|
+
}
|
|
310
|
+
finally {
|
|
311
|
+
if (request === this.operation) {
|
|
312
|
+
this.pending = null;
|
|
313
|
+
this.publish();
|
|
314
|
+
// Completion can precede the Native ACK; refresh after releasing the local busy guard as well.
|
|
315
|
+
// Hinglish: Ready event pehle aaya ho tab bhi Remove ke baad stale row list mein na rahe.
|
|
316
|
+
if (this.opened && !this.snapshot.busy && !this.error && !this.state.error)
|
|
317
|
+
void this.refresh();
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
read() {
|
|
322
|
+
const busy = !!this.pending ||
|
|
323
|
+
this.mapBusy ||
|
|
324
|
+
['saving', 'removing', 'restoring'].includes(this.state.status);
|
|
325
|
+
const saved = !!this.route?.routeSet &&
|
|
326
|
+
this.state.selection?.routeSetId === this.route.routeSet.routeSetId &&
|
|
327
|
+
!!this.state.savedRoute;
|
|
328
|
+
return {
|
|
329
|
+
open: this.opened,
|
|
330
|
+
loading: this.loading,
|
|
331
|
+
busy,
|
|
332
|
+
enabled: this.state.enabled,
|
|
333
|
+
supported: this.state.supported,
|
|
334
|
+
saved,
|
|
335
|
+
canSave: this.state.enabled &&
|
|
336
|
+
this.state.supported &&
|
|
337
|
+
!busy &&
|
|
338
|
+
!saved &&
|
|
339
|
+
!!this.route?.routeSet &&
|
|
340
|
+
!!this.route.selectedRouteId &&
|
|
341
|
+
['preview', 'guiding'].includes(this.route.stage),
|
|
342
|
+
status: this.state.status,
|
|
343
|
+
items: this.items,
|
|
344
|
+
error: this.error,
|
|
345
|
+
needsMap: !this.mapReady && this.state.error?.code === 'OFFLINE_MAP_REQUIRED',
|
|
346
|
+
confirmId: this.confirmId,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
/** One bounded deadline removes expired rows while a list stays open; no polling or render-time clock.
|
|
350
|
+
* Hinglish: List khuli rahe tab expiry par row hate; har render ya frame mein DB read nahi. */
|
|
351
|
+
scheduleExpiry() {
|
|
352
|
+
clearTimeout(this.expiryTimer);
|
|
353
|
+
if (!this.opened || !this.items.length)
|
|
354
|
+
return;
|
|
355
|
+
const deadline = Math.min(...this.items.map((item) => item.validUntil));
|
|
356
|
+
this.expiryTimer = setTimeout(() => {
|
|
357
|
+
this.items = this.items.filter((item) => item.validUntil > Date.now());
|
|
358
|
+
this.publish();
|
|
359
|
+
this.scheduleExpiry();
|
|
360
|
+
}, Math.max(1, Math.min(2_147_483_647, deadline - Date.now())));
|
|
361
|
+
}
|
|
362
|
+
publish() {
|
|
363
|
+
this.snapshot = this.read();
|
|
364
|
+
this.listeners.forEach((listener) => listener());
|
|
365
|
+
}
|
|
366
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PublicNodeData, WeeklyHours } from '@wovvmap/contracts';
|
|
2
|
+
export interface StoreHoursPresentation {
|
|
3
|
+
readonly status: 'open' | 'closed' | 'unknown';
|
|
4
|
+
readonly summary: string;
|
|
5
|
+
readonly weekly: readonly {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}[];
|
|
9
|
+
}
|
|
10
|
+
/** Format the bounded public week and resolve current/next opening in the caller's clock context.
|
|
11
|
+
* Hinglish: Public weekly hours se status mile; timezone diya ho to device timezone se guess nahi hoga. */
|
|
12
|
+
export declare function getStoreHoursPresentation(hours?: WeeklyHours, options?: {
|
|
13
|
+
now?: Date;
|
|
14
|
+
timeZone?: string;
|
|
15
|
+
}): StoreHoursPresentation | null;
|
|
16
|
+
/** At most two public taxonomy labels, with zero IDs preserved and duplicate names omitted.
|
|
17
|
+
* Hinglish: Sirf category/subcategory ke public labels hain; node/category lists ka scan nahi. */
|
|
18
|
+
export declare function getStoreCategoryLabels(node: PublicNodeData): readonly string[];
|
|
19
|
+
//# sourceMappingURL=storeHours.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storeHours.d.ts","sourceRoot":"","sources":["../src/storeHours.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAcrE,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAA;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAC7D;AA0DD;2GAC2G;AAC3G,wBAAgB,yBAAyB,CACvC,KAAK,CAAC,EAAE,WAAW,EACnB,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC9C,sBAAsB,GAAG,IAAI,CAoE/B;AAED;kGACkG;AAClG,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,cAAc,GAAG,SAAS,MAAM,EAAE,CAQ9E"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
const days = [
|
|
2
|
+
['sun', 'Sunday'],
|
|
3
|
+
['mon', 'Monday'],
|
|
4
|
+
['tue', 'Tuesday'],
|
|
5
|
+
['wed', 'Wednesday'],
|
|
6
|
+
['thu', 'Thursday'],
|
|
7
|
+
['fri', 'Friday'],
|
|
8
|
+
['sat', 'Saturday'],
|
|
9
|
+
];
|
|
10
|
+
const dayMinutes = 1440;
|
|
11
|
+
const weekMinutes = 7 * dayMinutes;
|
|
12
|
+
/** Parse the existing 12/24-hour source text; invalid input remains unknown, never Closed.
|
|
13
|
+
* Hinglish: Existing AM/PM ya24-hour text padho; invalid data se Closed guess nahi karna. */
|
|
14
|
+
function minuteOfDay(value) {
|
|
15
|
+
const match = value?.trim().match(/^(\d{1,2})(?::(\d{2}))?(?::(\d{2}))?\s*(a\.?m\.?|p\.?m\.?)?$/i);
|
|
16
|
+
if (!match)
|
|
17
|
+
return null;
|
|
18
|
+
const hour = Number(match[1]);
|
|
19
|
+
const minute = Number(match[2] ?? 0);
|
|
20
|
+
const second = Number(match[3] ?? 0);
|
|
21
|
+
const period = match[4]?.replace(/\./g, '').toLowerCase();
|
|
22
|
+
if (minute > 59 || second > 59 || (period ? hour < 1 || hour > 12 : hour > 24))
|
|
23
|
+
return null;
|
|
24
|
+
if (hour === 24 && (minute !== 0 || second !== 0))
|
|
25
|
+
return null;
|
|
26
|
+
return (period ? (hour % 12) + (period === 'pm' ? 12 : 0) : hour) * 60 + minute;
|
|
27
|
+
}
|
|
28
|
+
function timeLabel(minutes) {
|
|
29
|
+
const hour = Math.floor(minutes / 60) % 24;
|
|
30
|
+
return `${hour % 12 || 12}:${String(minutes % 60).padStart(2, '0')} ${hour < 12 ? 'a.m.' : 'p.m.'}`;
|
|
31
|
+
}
|
|
32
|
+
function clockParts(now, timeZone) {
|
|
33
|
+
if (!Number.isFinite(now.getTime()))
|
|
34
|
+
return null;
|
|
35
|
+
if (!timeZone)
|
|
36
|
+
return { day: now.getDay(), minute: now.getHours() * 60 + now.getMinutes() };
|
|
37
|
+
try {
|
|
38
|
+
const parts = new Intl.DateTimeFormat('en-US', {
|
|
39
|
+
timeZone,
|
|
40
|
+
weekday: 'short',
|
|
41
|
+
hour: '2-digit',
|
|
42
|
+
minute: '2-digit',
|
|
43
|
+
hourCycle: 'h23',
|
|
44
|
+
}).formatToParts(now);
|
|
45
|
+
const values = Object.fromEntries(parts.map((part) => [part.type, part.value]));
|
|
46
|
+
const day = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'].indexOf(values.weekday);
|
|
47
|
+
return { day, minute: Number(values.hour) * 60 + Number(values.minute) };
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/** Merge only the seven daily intervals across a week boundary, including adjoining opening periods.
|
|
54
|
+
* Hinglish: Sirf saat daily intervals ke maximum21 checks hain; map nodes ka koi scan nahi. */
|
|
55
|
+
function continuousClosing(intervals, current) {
|
|
56
|
+
let closing = null;
|
|
57
|
+
for (const shift of [-weekMinutes, 0, weekMinutes]) {
|
|
58
|
+
for (const interval of intervals) {
|
|
59
|
+
const start = interval.start + shift;
|
|
60
|
+
const end = interval.end + shift;
|
|
61
|
+
if (start <= current && current < end)
|
|
62
|
+
closing = Math.max(closing ?? end, end);
|
|
63
|
+
if (closing !== null && start <= closing && end > closing)
|
|
64
|
+
closing = end;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return closing;
|
|
68
|
+
}
|
|
69
|
+
/** Format the bounded public week and resolve current/next opening in the caller's clock context.
|
|
70
|
+
* Hinglish: Public weekly hours se status mile; timezone diya ho to device timezone se guess nahi hoga. */
|
|
71
|
+
export function getStoreHoursPresentation(hours, options = {}) {
|
|
72
|
+
if (!hours)
|
|
73
|
+
return null;
|
|
74
|
+
const clock = clockParts(options.now ?? new Date(), options.timeZone);
|
|
75
|
+
const current = clock ? clock.day * dayMinutes + clock.minute : 0;
|
|
76
|
+
const weekly = [];
|
|
77
|
+
let todayKnown = false;
|
|
78
|
+
const intervals = [];
|
|
79
|
+
let nextOpening = Infinity;
|
|
80
|
+
for (let index = 0; index < days.length; index++) {
|
|
81
|
+
const [key, label] = days[index];
|
|
82
|
+
const source = hours[key];
|
|
83
|
+
if (!source?.open && !source?.close)
|
|
84
|
+
continue;
|
|
85
|
+
const explicitlyClosed = source.open?.trim().toLowerCase() === 'closed' ||
|
|
86
|
+
source.close?.trim().toLowerCase() === 'closed';
|
|
87
|
+
const open = minuteOfDay(source.open);
|
|
88
|
+
const close = minuteOfDay(source.close);
|
|
89
|
+
const valid = open !== null && close !== null;
|
|
90
|
+
weekly.push({
|
|
91
|
+
label,
|
|
92
|
+
value: explicitlyClosed
|
|
93
|
+
? 'Closed'
|
|
94
|
+
: valid
|
|
95
|
+
? `${timeLabel(open)} – ${timeLabel(close)}`
|
|
96
|
+
: [source.open, source.close].filter(Boolean).join(' – '),
|
|
97
|
+
});
|
|
98
|
+
if (!clock)
|
|
99
|
+
continue;
|
|
100
|
+
if (index === clock.day)
|
|
101
|
+
todayKnown = explicitlyClosed || valid;
|
|
102
|
+
if (explicitlyClosed || !valid)
|
|
103
|
+
continue;
|
|
104
|
+
const start = index * dayMinutes + open;
|
|
105
|
+
const end = index * dayMinutes + close + (close <= open ? dayMinutes : 0);
|
|
106
|
+
intervals.push({ start, end });
|
|
107
|
+
const upcoming = start > current ? start : start + weekMinutes;
|
|
108
|
+
nextOpening = Math.min(nextOpening, upcoming);
|
|
109
|
+
}
|
|
110
|
+
if (!weekly.length)
|
|
111
|
+
return null;
|
|
112
|
+
const closing = clock ? continuousClosing(intervals, current) : null;
|
|
113
|
+
if (!clock || (!todayKnown && closing === null))
|
|
114
|
+
return { status: 'unknown', summary: 'Hours unavailable', weekly };
|
|
115
|
+
if (closing !== null) {
|
|
116
|
+
if (closing - current >= weekMinutes)
|
|
117
|
+
return { status: 'open', summary: '24 hours', weekly };
|
|
118
|
+
const daysAway = Math.floor(closing / dayMinutes) - clock.day;
|
|
119
|
+
const when = daysAway === 0
|
|
120
|
+
? ''
|
|
121
|
+
: daysAway === 1
|
|
122
|
+
? ' tomorrow'
|
|
123
|
+
: ` on ${days[Math.floor(closing / dayMinutes) % 7][1]}`;
|
|
124
|
+
return {
|
|
125
|
+
status: 'open',
|
|
126
|
+
summary: `Closes${when} at ${timeLabel(closing % dayMinutes)}`,
|
|
127
|
+
weekly,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
const nextDay = Math.floor(nextOpening / dayMinutes);
|
|
131
|
+
const when = nextDay === clock.day
|
|
132
|
+
? 'today'
|
|
133
|
+
: nextDay === clock.day + 1
|
|
134
|
+
? 'tomorrow'
|
|
135
|
+
: days[nextDay % 7]?.[1];
|
|
136
|
+
return {
|
|
137
|
+
status: 'closed',
|
|
138
|
+
summary: Number.isFinite(nextOpening)
|
|
139
|
+
? `Opens ${when} at ${timeLabel(nextOpening % dayMinutes)}`
|
|
140
|
+
: 'Next opening time unavailable',
|
|
141
|
+
weekly,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
/** At most two public taxonomy labels, with zero IDs preserved and duplicate names omitted.
|
|
145
|
+
* Hinglish: Sirf category/subcategory ke public labels hain; node/category lists ka scan nahi. */
|
|
146
|
+
export function getStoreCategoryLabels(node) {
|
|
147
|
+
const category = node.categoryName || node.categoryCode;
|
|
148
|
+
const subcategory = node.subCategoryName || node.subCategoryCode;
|
|
149
|
+
const result = [];
|
|
150
|
+
if (category !== undefined && category !== '')
|
|
151
|
+
result.push(String(category));
|
|
152
|
+
if (subcategory !== undefined && subcategory !== '' && String(subcategory) !== result[0])
|
|
153
|
+
result.push(String(subcategory));
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CatalogStoreRow, PublicNodeData } from '@wovvmap/contracts';
|
|
2
|
+
import type { StoreGroupExpansion } from './components.js';
|
|
3
|
+
export type StoreListEntry = {
|
|
4
|
+
kind: 'row';
|
|
5
|
+
row: CatalogStoreRow;
|
|
6
|
+
index: number;
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'member';
|
|
9
|
+
node: PublicNodeData;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'status';
|
|
12
|
+
};
|
|
13
|
+
/** Index directly into one virtual list; only visible entries are materialized by the view.
|
|
14
|
+
* Hinglish: Har index O(1) hai; expand/scroll par poore 10,000 rows ka loop nahi. */
|
|
15
|
+
export declare function createStoreListCollection(items: readonly CatalogStoreRow[], expansion?: StoreGroupExpansion): {
|
|
16
|
+
count: number;
|
|
17
|
+
getItem(index: number): StoreListEntry;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=storeList.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storeList.d.ts","sourceRoot":"","sources":["../src/storeList.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACzE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAEvD,MAAM,MAAM,cAAc,GACtB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpD;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,GACxC;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAA;AAEtB;qFACqF;AACrF,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,SAAS,eAAe,EAAE,EACjC,SAAS,CAAC,EAAE,mBAAmB;;mBAYd,MAAM,GAAG,cAAc;EAQzC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Index directly into one virtual list; only visible entries are materialized by the view.
|
|
2
|
+
* Hinglish: Har index O(1) hai; expand/scroll par poore 10,000 rows ka loop nahi. */
|
|
3
|
+
export function createStoreListCollection(items, expansion) {
|
|
4
|
+
const parent = expansion ? items[expansion.index] : undefined;
|
|
5
|
+
const group = parent?.kind === 'group' && parent.group.groupId === expansion?.groupId ? expansion : undefined;
|
|
6
|
+
const memberCount = group?.items.length ?? 0;
|
|
7
|
+
const statusCount = group && (group.isLoading || group.error || group.hasMore || !memberCount) ? 1 : 0;
|
|
8
|
+
const insertion = group ? group.index + 1 : items.length;
|
|
9
|
+
const added = memberCount + statusCount;
|
|
10
|
+
return {
|
|
11
|
+
count: items.length + added,
|
|
12
|
+
getItem(index) {
|
|
13
|
+
if (group && index >= insertion && index < insertion + memberCount)
|
|
14
|
+
return { kind: 'member', node: group.items[index - insertion] };
|
|
15
|
+
if (group && statusCount && index === insertion + memberCount)
|
|
16
|
+
return { kind: 'status' };
|
|
17
|
+
const rowIndex = index >= insertion + added ? index - added : index;
|
|
18
|
+
return { kind: 'row', row: items[rowIndex], index: rowIndex };
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Per-instance presentation tokens; changing them never changes the map theme.
|
|
2
|
+
* Hinglish: Ye sirf UI ke colors hain; inse map load ya camera change nahi hota. */
|
|
3
|
+
export interface UIChrome {
|
|
4
|
+
readonly background: string;
|
|
5
|
+
readonly text: string;
|
|
6
|
+
readonly inactiveBackground: string;
|
|
7
|
+
readonly gradient?: {
|
|
8
|
+
readonly colors: readonly [string, string, ...string[]];
|
|
9
|
+
readonly direction?: 'vertical' | 'diagonal';
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface UITheme {
|
|
13
|
+
primary: string;
|
|
14
|
+
surface: string;
|
|
15
|
+
surfaceMuted: string;
|
|
16
|
+
text: string;
|
|
17
|
+
textMuted: string;
|
|
18
|
+
border: string;
|
|
19
|
+
selected: string;
|
|
20
|
+
selectedText: string;
|
|
21
|
+
error: string;
|
|
22
|
+
radius: number;
|
|
23
|
+
spacing: number;
|
|
24
|
+
fontFamily: string;
|
|
25
|
+
/** Header/footer paint stays separate from card surfaces and active-button text.
|
|
26
|
+
* Hinglish: Header/footer, white cards aur active button ke text ke alag roles hain. */
|
|
27
|
+
chrome?: UIChrome;
|
|
28
|
+
onPrimary?: string;
|
|
29
|
+
hover?: string;
|
|
30
|
+
success?: string;
|
|
31
|
+
colorScheme?: 'light' | 'dark';
|
|
32
|
+
}
|
|
33
|
+
export type UIThemeInput = 'light' | 'dark' | Partial<UITheme>;
|
|
34
|
+
export declare const lightUITheme: Readonly<UITheme>;
|
|
35
|
+
export declare const darkUITheme: Readonly<UITheme>;
|
|
36
|
+
/** Explicit token resolution without a mutable global provider.
|
|
37
|
+
* Hinglish: Har component apna theme le sakta hai; doosre viewer ka color nahi badlega. */
|
|
38
|
+
export declare function resolveUITheme(theme?: UIThemeInput): Readonly<UITheme>;
|
|
39
|
+
/** Inactive controls placed on chrome inherit its contrast without changing normal cards.
|
|
40
|
+
* Hinglish: Header/footer tabs ka contrast alag mile; card/floor ki white surface same rahe. */
|
|
41
|
+
export declare function getChromeControlTheme(input?: UIThemeInput): Readonly<UITheme>;
|
|
42
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../src/theme.ts"],"names":[],"mappings":"AAAA;oFACoF;AACpF,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAA;IACnC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAClB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;QACvD,QAAQ,CAAC,SAAS,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;KAC7C,CAAA;CACF;AAED,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB;4FACwF;IACxF,MAAM,CAAC,EAAE,QAAQ,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAC/B;AAED,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAE9D,eAAO,MAAM,YAAY,EAAE,QAAQ,CAAC,OAAO,CAezC,CAAA;AACF,eAAO,MAAM,WAAW,EAAE,QAAQ,CAAC,OAAO,CAaxC,CAAA;AAEF;2FAC2F;AAC3F,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAItE;AAED;gGACgG;AAChG,wBAAgB,qBAAqB,CAAC,KAAK,CAAC,EAAE,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,CAa7E"}
|