@expofp/config 0.0.0-experimental.2d6c681
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 +40 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +12 -0
- package/dist/lib/apply-intents.d.ts +10 -0
- package/dist/lib/apply-intents.js +24 -0
- package/dist/lib/config-store.d.ts +8 -0
- package/dist/lib/config-store.js +16 -0
- package/dist/lib/debug-settings.d.ts +16 -0
- package/dist/lib/debug-settings.js +44 -0
- package/dist/lib/deprecated-url-params.d.ts +33 -0
- package/dist/lib/deprecated-url-params.js +72 -0
- package/dist/lib/json-schema.d.ts +67 -0
- package/dist/lib/json-schema.js +136 -0
- package/dist/lib/legacy-url.d.ts +162 -0
- package/dist/lib/legacy-url.js +416 -0
- package/dist/lib/load-config.d.ts +27 -0
- package/dist/lib/load-config.js +373 -0
- package/dist/lib/local-storage-codec.d.ts +44 -0
- package/dist/lib/local-storage-codec.js +76 -0
- package/dist/lib/normalize-fp-svg.d.ts +26 -0
- package/dist/lib/normalize-fp-svg.js +36 -0
- package/dist/lib/normalize-legacy-data.d.ts +13 -0
- package/dist/lib/normalize-legacy-data.js +90 -0
- package/dist/lib/rebooking.d.ts +19 -0
- package/dist/lib/rebooking.js +48 -0
- package/dist/lib/resource-urls.d.ts +52 -0
- package/dist/lib/resource-urls.js +203 -0
- package/dist/lib/serialize-config-resources.d.ts +46 -0
- package/dist/lib/serialize-config-resources.js +50 -0
- package/dist/lib/store-ref.d.ts +40 -0
- package/dist/lib/store-ref.js +56 -0
- package/dist/lib/strip-defaults.d.ts +27 -0
- package/dist/lib/strip-defaults.js +55 -0
- package/dist/lib/url-codec.d.ts +46 -0
- package/dist/lib/url-codec.js +165 -0
- package/dist/lib/url-intents.d.ts +40 -0
- package/dist/lib/url-intents.js +71 -0
- package/dist/lib/validate-flag.d.ts +10 -0
- package/dist/lib/validate-flag.js +36 -0
- package/dist/lib/validate-timing.d.ts +3 -0
- package/dist/lib/validate-timing.js +52 -0
- package/dist/lib/visit-resources.d.ts +99 -0
- package/dist/lib/visit-resources.js +209 -0
- package/package.json +36 -0
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Legacy URL grammar — the compact deep-link language the floor plan has always
|
|
3
|
+
* spoken (`?<slug>`, `?route:B-12:A-3:false`, `?tour=t1`, `?planner=a:b&from=c`,
|
|
4
|
+
* one-shot params like `?blue-dot=…` or `?viewermode=1`), as one pure codec:
|
|
5
|
+
*
|
|
6
|
+
* parseLegacyQuery(search) raw `location.search` → typed commands
|
|
7
|
+
* serializeSelection(selection) selection descriptor → `location.search`
|
|
8
|
+
*
|
|
9
|
+
* Both halves speak the SAME grammar, so shortcuts stay bidirectional: the slug
|
|
10
|
+
* a shared link carries is the slug the plan writes back when the visitor picks
|
|
11
|
+
* an entity (round-trip covered by tests). The floor plan maps commands to its
|
|
12
|
+
* public methods / stores and its UI state to a selection descriptor — nothing
|
|
13
|
+
* here touches a store or the DOM.
|
|
14
|
+
*
|
|
15
|
+
* Encoding contract (inherited from the legacy router, byte-compatible):
|
|
16
|
+
* the WHOLE query payload is one `encodeURIComponent` unit — `route:a:b`
|
|
17
|
+
* travels as `?route%3Aa%3Ab`, `planner&source=bookmarks` as
|
|
18
|
+
* `?planner%26source%3Dbookmarks` — and the parser decodes the whole string
|
|
19
|
+
* before splitting. Keys owned by the config layer (`UrlConfigSchema`) and
|
|
20
|
+
* intent-shortcut keys (`IntentsSchema` arm names) are consumed by `loadConfig`
|
|
21
|
+
* at boot, so the parser strips them from the residual slug here — one place
|
|
22
|
+
* knows the full key partition of the query.
|
|
23
|
+
*
|
|
24
|
+
* LEGACY GRAMMAR — frozen. Do not add keys or forms here. New URL capabilities
|
|
25
|
+
* are born in `UrlConfigSchema` (config keys) or `IntentsSchema` (intent
|
|
26
|
+
* arms). The parse side stays alive for links already shared in the wild, but
|
|
27
|
+
* only as a translator into those two channels; the sole legitimate consumer is
|
|
28
|
+
* `packages/floorplan/src/services/url-dispatch.ts` (lint-enforced).
|
|
29
|
+
*
|
|
30
|
+
* Keys whose capability has been retired keep one line each in
|
|
31
|
+
* {@link retiredKeys} — no translation, just enough for an old link to degrade
|
|
32
|
+
* to a clean plan instead of replaying as search text.
|
|
33
|
+
*/
|
|
34
|
+
import { IntentsSchema, UrlConfigSchema } from '@expofp/schema';
|
|
35
|
+
import { safeDecode } from '@expofp/utils';
|
|
36
|
+
import { DEPRECATED_URL_KEYS } from './deprecated-url-params.js';
|
|
37
|
+
/* ── Parse: location.search → commands ─────────────────────────────────────── */
|
|
38
|
+
/** Query keys consumed by `loadConfig` before dispatch: config slice + intent shortcuts. */
|
|
39
|
+
const configOwnedKeys = new Set([
|
|
40
|
+
...Object.keys(UrlConfigSchema.shape),
|
|
41
|
+
...IntentsSchema.options.map((arm) => arm.shape.name.value),
|
|
42
|
+
]);
|
|
43
|
+
/** One-shot keys the parser consumes into commands (never part of the slug). */
|
|
44
|
+
const oneShotKeys = new Set(['blue-dot', 'viewermode', 'previewMode', 'uiscale', 'resetuiscale']);
|
|
45
|
+
/**
|
|
46
|
+
* RETIRED keys — capability gone, only swallowed (in `key=value` form: a bare
|
|
47
|
+
* slug that merely spells one of these words still resolves via the catalog),
|
|
48
|
+
* so an old link opens a clean plan instead of replaying as search text. The
|
|
49
|
+
* list only ever shrinks; a parameter that still DOES something belongs in
|
|
50
|
+
* `UrlConfigSchema` or `IntentsSchema`, never here.
|
|
51
|
+
*
|
|
52
|
+
* | retired | canonical form today |
|
|
53
|
+
* | ---------------------- | ------------------------------- |
|
|
54
|
+
* | `centerxy=x,y` | `camera[x]` / `camera[y]` |
|
|
55
|
+
* | `center=lat,lng` | `camera[lat]` / `camera[lng]` |
|
|
56
|
+
* | `z=` | `camera[floor]` |
|
|
57
|
+
* | `bearing=` | `camera[bearing]` |
|
|
58
|
+
* | `zoomtime=` | `camera[zoomTime]` |
|
|
59
|
+
* | `roll=` | — internal renderer knob |
|
|
60
|
+
* | `hide=a,b` | `visibility[a]=false` |
|
|
61
|
+
* | `lang=` | `changeLanguage=` |
|
|
62
|
+
* | `preview=` | — the preview link needs none |
|
|
63
|
+
* | `copy_exh=` | — a removed development seed |
|
|
64
|
+
* | `pathway=id` | `showPathway[0]=id` |
|
|
65
|
+
* | `booths=a,b` | — part of `showPathway` |
|
|
66
|
+
* | `b=` / `ba=` | — bookmark import, removed |
|
|
67
|
+
* | `-pdf` | — a print mode that never was |
|
|
68
|
+
* | `build-route` | `startBuildRoute` |
|
|
69
|
+
* | `sw=` / `yah=` / `k=` | — readers live on in legacy |
|
|
70
|
+
* | `kiosk_<framing>=` | `kiosk[…]` — the anchor node |
|
|
71
|
+
*
|
|
72
|
+
* `sw`/`yah`/`k` still have readers in the legacy runtime (service-worker
|
|
73
|
+
* toggle, YAH-marker command, saved-kiosk id) but none here — the mobile SDK
|
|
74
|
+
* enums emit them and they die out with app installs; their sibling `?agenda`
|
|
75
|
+
* is translated by the shim instead. `kiosk_<framing>` is the 11 fields the
|
|
76
|
+
* old 14-key QR channel spoke beyond the surviving `kiosk_x/y/z` (those
|
|
77
|
+
* partition via {@link directReadKeys}); unswallowed, one replayed as search
|
|
78
|
+
* text — and beside a route slug its tail fused into the last colon-part,
|
|
79
|
+
* silently flipping the accessible flag. `tour=`
|
|
80
|
+
* keeps its live meaning (`selectTour` covers what the pathway link used it
|
|
81
|
+
* for), and retiring `b=`/`ba=` as plain keys drops their emulated query wipe:
|
|
82
|
+
* one-shots beside them now apply.
|
|
83
|
+
*/
|
|
84
|
+
const retiredKeys = new Set([
|
|
85
|
+
'centerxy',
|
|
86
|
+
'center',
|
|
87
|
+
'z',
|
|
88
|
+
'bearing',
|
|
89
|
+
'zoomtime',
|
|
90
|
+
'roll',
|
|
91
|
+
'hide',
|
|
92
|
+
'lang',
|
|
93
|
+
'preview',
|
|
94
|
+
'copy_exh',
|
|
95
|
+
'pathway',
|
|
96
|
+
'booths',
|
|
97
|
+
'b',
|
|
98
|
+
'ba',
|
|
99
|
+
'sw',
|
|
100
|
+
'yah',
|
|
101
|
+
'k',
|
|
102
|
+
// the framing/cosmetic 11 of the old 14-key kiosk QR channel — `kiosk_x/y/z`
|
|
103
|
+
// live on in directReadKeys, and the field names mirror KioskSchema
|
|
104
|
+
'kiosk_heading',
|
|
105
|
+
'kiosk_lat',
|
|
106
|
+
'kiosk_lng',
|
|
107
|
+
'kiosk_iconSizePercent',
|
|
108
|
+
'kiosk_uiScale',
|
|
109
|
+
'kiosk_mapRollDegrees',
|
|
110
|
+
'kiosk_mapInitialPtScale',
|
|
111
|
+
'kiosk_mapPtScale',
|
|
112
|
+
'kiosk_mapCenterX',
|
|
113
|
+
'kiosk_mapCenterY',
|
|
114
|
+
'kiosk_mapPitch',
|
|
115
|
+
]);
|
|
116
|
+
/** Retired keywords: a whole-slug word rather than a `key=value` pair. */
|
|
117
|
+
const retiredKeywords = new Set(['-pdf', 'build-route']);
|
|
118
|
+
/**
|
|
119
|
+
* The deprecated aliases the `loadConfig` compat shim still consumes — config
|
|
120
|
+
* keys as far as this codec is concerned, so they partition with
|
|
121
|
+
* `configOwnedKeys` and match in both spellings (which is what catches the
|
|
122
|
+
* SDKs' valueless `?agenda`, at the cost of a booth slugged `agenda`).
|
|
123
|
+
* TEMPORARY: when the shim goes, move these into `retiredKeys`.
|
|
124
|
+
*/
|
|
125
|
+
const deprecatedKeys = new Set(DEPRECATED_URL_KEYS);
|
|
126
|
+
/**
|
|
127
|
+
* Query keys owned by the DELIVERY PLATFORM, not the floor plan: `?expo=` is
|
|
128
|
+
* the routing param the sha-delivery platform materializes for expo-aware
|
|
129
|
+
* origins, and preview URLs (`/s/<sha>/?expo=…`) carry it literally in the
|
|
130
|
+
* page URL. Not a grammar
|
|
131
|
+
* extension — a third partition of the query alongside config-owned and
|
|
132
|
+
* one-shot keys: the parser strips these from the residual slug (in their
|
|
133
|
+
* `key=value` form only — a bare slug that merely spells `expo` still
|
|
134
|
+
* resolves via the catalog), and the floor plan's URL writer carries them
|
|
135
|
+
* verbatim across query rewrites ({@link splitPlatformParams}).
|
|
136
|
+
*
|
|
137
|
+
* Unlike config-owned keys, platform params do NOT classify a query as
|
|
138
|
+
* `ownedByConfig`: `?expo=…` alone DESCRIBES the empty selection — browser
|
|
139
|
+
* back onto it must clear the selection like any genuinely empty query,
|
|
140
|
+
* whereas config keys are instructions riding alongside the selection state.
|
|
141
|
+
*/
|
|
142
|
+
const platformParamKeys = new Set(['expo']);
|
|
143
|
+
/**
|
|
144
|
+
* Query keys the floor plan reads STRAIGHT from `location.search`: `?layer=`
|
|
145
|
+
* (init-layers) and `?kiosk_x/y/z` (the anchor a kiosk's route QR hands the
|
|
146
|
+
* scanning phone). Spelled out here — this package must not depend on the
|
|
147
|
+
* floor plan — so a reader change has to be mirrored. They partition like the
|
|
148
|
+
* platform's params: stripped in `key=value` form only, never `ownedByConfig`.
|
|
149
|
+
* Unpartitioned they replayed as search text, and the route QR's own link
|
|
150
|
+
* (`?route:…:true&kiosk_x=…`) lost its accessible flag — the 4th colon-part of
|
|
151
|
+
* a slug that had swallowed the whole `&kiosk_*` tail.
|
|
152
|
+
*/
|
|
153
|
+
const directReadKeys = new Set(['layer', 'kiosk_x', 'kiosk_y', 'kiosk_z']);
|
|
154
|
+
/**
|
|
155
|
+
* Companion keys of a primary form — read from `params` by its classifier,
|
|
156
|
+
* never part of the slug: `&title=` names a shared route (the route branch
|
|
157
|
+
* reads it; no canonical form exists). Stripped in `key=value` form only, like
|
|
158
|
+
* the partitions above — left in place, the tail fused into the route slug's
|
|
159
|
+
* last colon-part, where it silently flipped `:true` to false or ate a
|
|
160
|
+
* trailing FROM. A bare slug that merely spells `title` still resolves via
|
|
161
|
+
* the catalog. (The planner's `&source=`/`&from=` companions need no entry:
|
|
162
|
+
* that branch classifies on `params` before the slug is consulted, and the
|
|
163
|
+
* slug of a params-classified query is never replayed as search text.)
|
|
164
|
+
*/
|
|
165
|
+
const companionKeys = new Set(['title']);
|
|
166
|
+
export function parseLegacyQuery(search) {
|
|
167
|
+
const rawQuery = search.startsWith('?') ? search.slice(1) : search;
|
|
168
|
+
// the legacy contract: the payload is one encodeURIComponent unit
|
|
169
|
+
const decoded = safeDecode(rawQuery);
|
|
170
|
+
const params = new URLSearchParams(decoded);
|
|
171
|
+
return {
|
|
172
|
+
primary: classifyPrimary(residualSlug(decoded), params, hasOwnedParts(decoded)),
|
|
173
|
+
oneShots: collectOneShots(params),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function classifyPrimary(slug, params, owned) {
|
|
177
|
+
if (params.has('kiosk')) {
|
|
178
|
+
const value = params.get('kiosk');
|
|
179
|
+
return { type: 'kiosk', enabled: value === '1' ? true : value === '0' ? false : null };
|
|
180
|
+
}
|
|
181
|
+
if (slug === 'tours')
|
|
182
|
+
return { type: 'list', list: 'tours' };
|
|
183
|
+
if (slug.startsWith('tour='))
|
|
184
|
+
return { type: 'tour', tourId: slug.split('=')[1] };
|
|
185
|
+
if (params.has('planner')) {
|
|
186
|
+
return {
|
|
187
|
+
type: 'planner',
|
|
188
|
+
fromBookmarks: params.get('source') === 'bookmarks',
|
|
189
|
+
items: (params.get('planner') ?? '').split(':').filter(Boolean),
|
|
190
|
+
from: params.get('from') ?? undefined,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
if (slug.startsWith('route')) {
|
|
194
|
+
const parts = slug.split(':');
|
|
195
|
+
return {
|
|
196
|
+
type: 'route',
|
|
197
|
+
to: parts[1],
|
|
198
|
+
from: parts[2],
|
|
199
|
+
accessible: parts[3] === 'true',
|
|
200
|
+
waypoints: parts.slice(4),
|
|
201
|
+
title: params.get('title') ?? undefined,
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (slug === 'bookmarks')
|
|
205
|
+
return { type: 'list', list: 'bookmarks' };
|
|
206
|
+
if (slug === 'visited')
|
|
207
|
+
return { type: 'list', list: 'visited' };
|
|
208
|
+
if (slug === 'language')
|
|
209
|
+
return { type: 'list', list: 'language' };
|
|
210
|
+
if (slug === 'sessions')
|
|
211
|
+
return { type: 'list', list: 'sessions' };
|
|
212
|
+
if (slug === 'exhibitors')
|
|
213
|
+
return { type: 'list', list: 'exhibitors' };
|
|
214
|
+
if (slug === 'speakers')
|
|
215
|
+
return { type: 'list', list: 'speakers' };
|
|
216
|
+
if (slug.startsWith('exhibitors=')) {
|
|
217
|
+
const value = slug.slice('exhibitors='.length);
|
|
218
|
+
// `?exhibitors=` and `?exhibitors=true` are exactly the two values the
|
|
219
|
+
// FILTER manager reads as "open the exhibitors list" — classified as a
|
|
220
|
+
// selection, the link also selected an exhibitor named "true". Anything
|
|
221
|
+
// else after `exhibitors=` is a display-name list.
|
|
222
|
+
if (value === '' || value === 'true')
|
|
223
|
+
return { type: 'ownedByFilters' };
|
|
224
|
+
return { type: 'selectExhibitors', values: value.split(',') };
|
|
225
|
+
}
|
|
226
|
+
if (slug.includes('=') && (slug.startsWith('categories=') || /^poiTypes?=/.test(slug))) {
|
|
227
|
+
return { type: 'ownedByFilters' };
|
|
228
|
+
}
|
|
229
|
+
// Last, after every params-based branch above: a slug emptied because
|
|
230
|
+
// config/intent keys (or the deprecated aliases) owned the whole query is
|
|
231
|
+
// NOT the clear-selection command an empty query is — `select('')` would
|
|
232
|
+
// close whatever is open. Retired-only queries deliberately ARE (see
|
|
233
|
+
// hasOwnedParts).
|
|
234
|
+
if (!slug && owned) {
|
|
235
|
+
return { type: 'ownedByConfig' };
|
|
236
|
+
}
|
|
237
|
+
return { type: 'select', slug };
|
|
238
|
+
}
|
|
239
|
+
function collectOneShots(params) {
|
|
240
|
+
const oneShots = [];
|
|
241
|
+
if (params.get('heatmap') === 'true') {
|
|
242
|
+
oneShots.push({
|
|
243
|
+
type: 'heatmap',
|
|
244
|
+
yah: params.get('type') === 'yah',
|
|
245
|
+
kiosk: params.get('subtype') === 'kiosk',
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
const blueDot = params.get('blue-dot');
|
|
249
|
+
if (blueDot !== null) {
|
|
250
|
+
const p = blueDot.split(',');
|
|
251
|
+
const x = Number(p[0]);
|
|
252
|
+
const y = Number(p[1]);
|
|
253
|
+
if (p.length > 1 && Number.isFinite(x) && Number.isFinite(y)) {
|
|
254
|
+
oneShots.push({
|
|
255
|
+
type: 'blueDot',
|
|
256
|
+
x,
|
|
257
|
+
y,
|
|
258
|
+
layer: p[2],
|
|
259
|
+
lat: Number(p[3]) || undefined,
|
|
260
|
+
lng: Number(p[4]) || undefined,
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const viewerMode = params.get('viewermode');
|
|
265
|
+
if (viewerMode === '1' || viewerMode === 'true') {
|
|
266
|
+
oneShots.push({ type: 'viewerMode', enabled: true });
|
|
267
|
+
}
|
|
268
|
+
else if (viewerMode === '0' || viewerMode === 'false') {
|
|
269
|
+
oneShots.push({ type: 'viewerMode', enabled: false });
|
|
270
|
+
}
|
|
271
|
+
const previewMode = params.get('previewMode');
|
|
272
|
+
if (previewMode === 'true') {
|
|
273
|
+
oneShots.push({ type: 'previewMode', enabled: true });
|
|
274
|
+
}
|
|
275
|
+
else if (previewMode === 'false') {
|
|
276
|
+
oneShots.push({ type: 'previewMode', enabled: false });
|
|
277
|
+
}
|
|
278
|
+
if (params.has('resetuiscale')) {
|
|
279
|
+
oneShots.push({ type: 'resetUiScale' });
|
|
280
|
+
}
|
|
281
|
+
const uiScaleRaw = params.get('uiscale');
|
|
282
|
+
if (uiScaleRaw) {
|
|
283
|
+
const scale = parseFloat(uiScaleRaw.replace(',', '.'));
|
|
284
|
+
const valid = !Number.isNaN(scale) && scale >= 0.8 && scale <= 1.4;
|
|
285
|
+
oneShots.push({ type: 'uiScale', scale: valid ? scale : null, raw: uiScaleRaw });
|
|
286
|
+
}
|
|
287
|
+
return oneShots;
|
|
288
|
+
}
|
|
289
|
+
/** A retired part, matched in `key=value` form only (see {@link retiredKeys}). */
|
|
290
|
+
function isRetiredPart(part) {
|
|
291
|
+
if (retiredKeywords.has(part))
|
|
292
|
+
return true;
|
|
293
|
+
return retiredKeys.has(part.split('=')[0]) && part.includes('=');
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* A part `loadConfig` consumes: a config-slice key, an intent shortcut, or a
|
|
297
|
+
* deprecated alias — bracketed sub-keys and the valueless spelling included.
|
|
298
|
+
*/
|
|
299
|
+
function isConsumedByConfig(part) {
|
|
300
|
+
const rawKey = part.split('=')[0];
|
|
301
|
+
// the legacy scalar `?heatmap=true` is slug-resident (see residualSlug)
|
|
302
|
+
if (rawKey === 'heatmap')
|
|
303
|
+
return false;
|
|
304
|
+
const key = rawKey.split('[')[0];
|
|
305
|
+
return configOwnedKeys.has(key) || deprecatedKeys.has(key);
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Whether the query holds a part the config layer consumes. Retired and
|
|
309
|
+
* one-shot keys deliberately do NOT count: a query made only of those means
|
|
310
|
+
* nothing, keeping the legacy empty select (which closes the open panel).
|
|
311
|
+
*/
|
|
312
|
+
function hasOwnedParts(decoded) {
|
|
313
|
+
return decoded.split('&').some((part) => !!part && isConsumedByConfig(part));
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* The slug is the decoded query minus every key another consumer owns: the
|
|
317
|
+
* retired keys swallowed above, the platform's routing params, the keys the
|
|
318
|
+
* floor plan reads straight from the query ({@link directReadKeys}), the
|
|
319
|
+
* grammar's own companion keys ({@link companionKeys}), the config layer's
|
|
320
|
+
* keys and intent shortcuts (read by `loadConfig`), and the one-shot keys. `heatmap`/`type`/`subtype` stay in the slug — heatmap mode historically
|
|
321
|
+
* froze the URL with them in place (its data loader re-reads them), and the
|
|
322
|
+
* select fallback knows not to treat a query carrying `heatmap=true` as search
|
|
323
|
+
* text.
|
|
324
|
+
*/
|
|
325
|
+
function residualSlug(decoded) {
|
|
326
|
+
return decoded
|
|
327
|
+
.split('&')
|
|
328
|
+
.filter((part) => {
|
|
329
|
+
if (!part)
|
|
330
|
+
return false;
|
|
331
|
+
if (isRetiredPart(part))
|
|
332
|
+
return false;
|
|
333
|
+
const key = part.split('=')[0].split('[')[0];
|
|
334
|
+
// all stripped in `key=value` form only, so a booth named "expo",
|
|
335
|
+
// "layer" or "title" still resolves via the catalog
|
|
336
|
+
if ((platformParamKeys.has(key) || directReadKeys.has(key) || companionKeys.has(key)) &&
|
|
337
|
+
part.includes('=')) {
|
|
338
|
+
return false;
|
|
339
|
+
}
|
|
340
|
+
// Carve-out (retirement plan §4.8): `heatmap` is a UrlConfigSchema key
|
|
341
|
+
// now, so the canonical bracketed `heatmap[…]=` form is config-owned and
|
|
342
|
+
// strips like any other — but the legacy scalar `?heatmap=true` must
|
|
343
|
+
// KEEP its slug residency (the select fallback recognizes the literal
|
|
344
|
+
// `heatmap=true`; the frozen URL carries it for the data loader).
|
|
345
|
+
// `isConsumedByConfig` discriminates on the raw key: no bracket ⇒ legacy.
|
|
346
|
+
if (isConsumedByConfig(part))
|
|
347
|
+
return false;
|
|
348
|
+
return !oneShotKeys.has(key);
|
|
349
|
+
})
|
|
350
|
+
.join('&');
|
|
351
|
+
}
|
|
352
|
+
/* ── Platform routing params: the writer-side partition ────────────────────── */
|
|
353
|
+
/**
|
|
354
|
+
* Split a raw `location.search` into the floor plan's own query and the
|
|
355
|
+
* platform's routing params (`?expo=…` — {@link platformParamKeys}).
|
|
356
|
+
* Raw-segment level (split on `&`, no decoding): platform params travel
|
|
357
|
+
* outside the legacy grammar's single-`encodeURIComponent`-unit payload, and
|
|
358
|
+
* that payload must pass through untouched. The floor plan's single URL
|
|
359
|
+
* writer (`url-sync`) hides the platform half from what the app reads back
|
|
360
|
+
* and re-attaches it verbatim to every URL it writes — a preview URL
|
|
361
|
+
* `/s/<sha>/?expo=…` must survive reload and sharing after any rewrite.
|
|
362
|
+
* When no platform param is present, `search` is returned byte-identical.
|
|
363
|
+
*/
|
|
364
|
+
export function splitPlatformParams(search) {
|
|
365
|
+
const raw = search.startsWith('?') ? search.slice(1) : search;
|
|
366
|
+
if (!raw)
|
|
367
|
+
return { search, platform: '' };
|
|
368
|
+
const segments = raw.split('&');
|
|
369
|
+
const platform = segments.filter(isPlatformParam);
|
|
370
|
+
if (!platform.length)
|
|
371
|
+
return { search, platform: '' };
|
|
372
|
+
const app = segments.filter((segment) => !isPlatformParam(segment));
|
|
373
|
+
return { search: app.length ? '?' + app.join('&') : '', platform: platform.join('&') };
|
|
374
|
+
}
|
|
375
|
+
function isPlatformParam(segment) {
|
|
376
|
+
const eq = segment.indexOf('=');
|
|
377
|
+
return eq > 0 && platformParamKeys.has(segment.slice(0, eq));
|
|
378
|
+
}
|
|
379
|
+
/* ── Serialize: selection → location.search ────────────────────────────────── */
|
|
380
|
+
/**
|
|
381
|
+
* The selection's canonical query — `''` for none, else `?<payload>` with the
|
|
382
|
+
* whole payload as one `encodeURIComponent` unit (the legacy contract). This is
|
|
383
|
+
* the string the single URL writer puts in the address bar, byte-compatible
|
|
384
|
+
* with the URLs the legacy router wrote (shared links keep working).
|
|
385
|
+
*/
|
|
386
|
+
export function serializeSelection(selection) {
|
|
387
|
+
const queryRaw = selectionPayload(selection);
|
|
388
|
+
return queryRaw ? '?' + encodeURIComponent(queryRaw) : '';
|
|
389
|
+
}
|
|
390
|
+
function selectionPayload(selection) {
|
|
391
|
+
switch (selection.type) {
|
|
392
|
+
case 'none':
|
|
393
|
+
return '';
|
|
394
|
+
case 'slug':
|
|
395
|
+
return selection.slug;
|
|
396
|
+
case 'route': {
|
|
397
|
+
const to = selection.to ? `:${selection.to}` : '';
|
|
398
|
+
const from = selection.from ? `:${selection.from}` : '';
|
|
399
|
+
const accessible = selection.accessible ? ':true' : ':false';
|
|
400
|
+
const waypoints = (selection.waypoints ?? []).map((w) => `:${w}`).join('');
|
|
401
|
+
return `route${to}${from}${accessible}${waypoints}`;
|
|
402
|
+
}
|
|
403
|
+
case 'planner': {
|
|
404
|
+
const base = selection.fromBookmarks
|
|
405
|
+
? 'planner&source=bookmarks'
|
|
406
|
+
: `planner=${(selection.items ?? []).join(':')}`;
|
|
407
|
+
return selection.from ? `${base}&from=${selection.from}` : base;
|
|
408
|
+
}
|
|
409
|
+
case 'list':
|
|
410
|
+
return selection.list;
|
|
411
|
+
case 'tour':
|
|
412
|
+
return `tour=${selection.tourId}`;
|
|
413
|
+
case 'filter':
|
|
414
|
+
return `${selection.key}=${selection.value}`;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Ref } from '@expofp/resolve';
|
|
2
|
+
import { type Config, type Manifest, type Options } from '@expofp/schema';
|
|
3
|
+
import { type StorageLike } from './local-storage-codec.js';
|
|
4
|
+
/**
|
|
5
|
+
* Assemble the effective config — the runtime's single, complete copy of the
|
|
6
|
+
* expo data — by layering, lowest to highest precedence:
|
|
7
|
+
* manifest (+ its legacy data.js) → options → localStorage → URL.
|
|
8
|
+
*
|
|
9
|
+
* With a `legacyDataUrlBase` (live events), the manifest's `legacyDataVersion`
|
|
10
|
+
* pin — or, absent one, the version probe — settles the `?v=` cache-buster,
|
|
11
|
+
* refs to the sibling drawing / wayfinding files are
|
|
12
|
+
* derived from it (`data.js` never carries them), and all three legacy files —
|
|
13
|
+
* `data.js` evaluated to its `__data` document like every legacy `.js` file,
|
|
14
|
+
* asset-resolved and merged in — are fetched in parallel. A manifest can
|
|
15
|
+
* instead carry the merged data itself plus explicit refs (offline copies) —
|
|
16
|
+
* then nothing is derived. The config holds only the REFS; the payloads live
|
|
17
|
+
* in `@expofp/resolve`'s memo: `loadConfig` resolves `fpSvgJsRef` and
|
|
18
|
+
* `wfDataJsRef` before returning, so consumers read them synchronously with
|
|
19
|
+
* `getResolved` from then on. Legacy normalization and the rebooking merge
|
|
20
|
+
* run last, and the result is deep-frozen.
|
|
21
|
+
*
|
|
22
|
+
* `url` / `storage` are browser inputs (page query, `localStorage`); Node
|
|
23
|
+
* callers (the offline CLI) omit them, which also skips those layers and the
|
|
24
|
+
* rebooking token lookup.
|
|
25
|
+
*/
|
|
26
|
+
export declare function loadConfig(manifest: Manifest | Ref<Manifest>, options: Options, url?: string, storage?: StorageLike): Promise<Config>;
|
|
27
|
+
//# sourceMappingURL=load-config.d.ts.map
|