@wovvmap/navigation 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 +45 -2
- package/dist/endpoints/EndpointLookupPort.d.ts +16 -0
- package/dist/endpoints/EndpointLookupPort.d.ts.map +1 -0
- package/dist/endpoints/EndpointLookupPort.js +1 -0
- package/dist/endpoints/EndpointService.d.ts +49 -0
- package/dist/endpoints/EndpointService.d.ts.map +1 -0
- package/dist/endpoints/EndpointService.js +278 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/routes/RoutePlayback.d.ts +68 -0
- package/dist/routes/RoutePlayback.d.ts.map +1 -0
- package/dist/routes/RoutePlayback.js +771 -0
- package/dist/routes/RouteRestore.d.ts +24 -0
- package/dist/routes/RouteRestore.d.ts.map +1 -0
- package/dist/routes/RouteRestore.js +1 -0
- package/dist/routes/RouteService.d.ts +121 -0
- package/dist/routes/RouteService.d.ts.map +1 -0
- package/dist/routes/RouteService.js +1123 -0
- package/dist/routes/navigationConfig.d.ts +2 -0
- package/dist/routes/navigationConfig.d.ts.map +1 -0
- package/dist/routes/navigationConfig.js +3 -0
- package/package.json +33 -3
package/README.md
CHANGED
|
@@ -1,3 +1,46 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Navigation domain
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`EndpointService` owns one viewer's origin/destination pair. Checkpoint 7A.1 contains endpoint
|
|
4
|
+
selection only. Checkpoint 7A.2 connects the existing viewer and WebView; direction UI and routes
|
|
5
|
+
remain later work.
|
|
6
|
+
|
|
7
|
+
Hinglish: Har viewer ka origin/destination ek service manage karti hai. SDK connection 7A.2 mein hai; direction UI aur route baad mein hain.
|
|
8
|
+
|
|
9
|
+
- `@wovvmap/contracts` owns `EndpointReference`, `EndpointState`, `EndpointOperations` and the
|
|
10
|
+
shared `endpointsChanged` event name/payload.
|
|
11
|
+
- Inject `EndpointLookupPort`: `getIdentity()` reads the committed map; `resolve(reference, context)`
|
|
12
|
+
reads one canonical node, scoped store group or amenity-ID membership from existing indexes.
|
|
13
|
+
A missing, disabled or empty target returns `null`; invalid/stale reads throw. Group reads must
|
|
14
|
+
resolve complete eligible membership, not a loaded page. The representative is display-only.
|
|
15
|
+
- `setOrigin` / `setDestination` affect one role. Passing `null` clears that role. `swapEndpoints`
|
|
16
|
+
and `clearEndpoints` update the pair once. Invalid context/lookup results preserve the old pair.
|
|
17
|
+
- `getSnapshot()` returns a cached immutable public projection. `subscribe(listener)` is a change
|
|
18
|
+
notification; the listener reads the latest snapshot. Effective no-ops do not notify. The 7A.2
|
|
19
|
+
SDK binding forwards this projection as `endpointsChanged`; subscribing does not replay setters.
|
|
20
|
+
- Call `commitMap()` only after a successful committed-map replacement or clear. Pending, failed
|
|
21
|
+
and cancelled loads and same-session context restoration do not reset endpoints. Map identity
|
|
22
|
+
includes revision. A lookup cannot commit a result into a different revision.
|
|
23
|
+
- Call `refresh()` explicitly on catalog eligibility changes. It stages both existing intents and
|
|
24
|
+
commits once; unavailable targets clear only their own role. An error preserves both old roles.
|
|
25
|
+
The future adapter must resolve a concrete node independently of offer eligibility.
|
|
26
|
+
- Call `destroy()` on viewer teardown; it clears this instance without notifying or making an origin.
|
|
27
|
+
|
|
28
|
+
Hinglish: Set/clear sirf apna role badle; swap/clear-both ek action hai. Failed request mein half state
|
|
29
|
+
nahi hogi. Offer expiry par group ka scope dobara check hoga; concrete store sirf offer expire hone
|
|
30
|
+
se nahi hatega. Different floors valid hain; graph reachability baad mein aayegi.
|
|
31
|
+
|
|
32
|
+
Only affected candidate keys are held in a private `Set` for overlap and order-independent equality.
|
|
33
|
+
There is no full-map/shape traversal, raw NodePoint store, network access or framework dependency.
|
|
34
|
+
Public state contains the compact intent, name, member count, available floors, optional logo and
|
|
35
|
+
one compact representative. It excludes raw node details, all member keys, geometry and graph data.
|
|
36
|
+
|
|
37
|
+
Hinglish: Selected group ki keys compare karne ka kaam zaroori hai; poore map ya shapes ka extra loop
|
|
38
|
+
nahi hai. Ye private keys Native public state mein copy nahi hoti.
|
|
39
|
+
|
|
40
|
+
`SAME_LOCATION` means both candidate sets contain the same single key. Any other intersection is
|
|
41
|
+
`OVERLAPPING_LOCATIONS`. Both valid references remain visible; no candidate is silently removed.
|
|
42
|
+
Neither conflict-free endpoints nor a display representative imply a reachable or nearest route.
|
|
43
|
+
|
|
44
|
+
All methods are synchronous pure-domain operations. SDK transports wrap them in promises.
|
|
45
|
+
Port implementations must satisfy the canonical lookup contract; test fixtures are not production
|
|
46
|
+
map-data adapters. Checkpoint 7A.2 adds that adapter in sdk-web and real direct/WebView JSON parity tests.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { EndpointContext, EndpointMapIdentity, EndpointReference, EndpointSummary } from '@wovvmap/contracts';
|
|
2
|
+
/** Already-indexed, eligible candidates for one intent; keys are private runtime data.
|
|
3
|
+
* Hinglish: Sirf selected ref ki indexed keys; full NodePoint/map ka copy nahi. */
|
|
4
|
+
export interface ResolvedEndpointCandidates extends Pick<EndpointSummary, 'name' | 'representative' | 'logoUrl' | 'availableFloors'> {
|
|
5
|
+
readonly keys: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
/** The SDK composition root connects existing canonical node, scoped group and amenity indexes.
|
|
8
|
+
* Return null for missing/disabled/empty targets; throw on invalid scope or a stale read.
|
|
9
|
+
* Resolve against the supplied committed identity without scans, pagination or nearest-route guesses.
|
|
10
|
+
* Hinglish: SDK existing indexes jode; node/group/amenity ka sirf requested lookup ho.
|
|
11
|
+
* Missing/disabled target par null; stale/invalid read par error. Route/nearest yahan nahi. */
|
|
12
|
+
export interface EndpointLookupPort {
|
|
13
|
+
getIdentity(): EndpointMapIdentity | null;
|
|
14
|
+
resolve(reference: EndpointReference, context: Required<EndpointContext>): ResolvedEndpointCandidates | null;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=EndpointLookupPort.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointLookupPort.d.ts","sourceRoot":"","sources":["../../src/endpoints/EndpointLookupPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,iBAAiB,EACjB,eAAe,EAChB,MAAM,oBAAoB,CAAA;AAE3B;mFACmF;AACnF,MAAM,WAAW,0BAA2B,SAAQ,IAAI,CACtD,eAAe,EACf,MAAM,GAAG,gBAAgB,GAAG,SAAS,GAAG,iBAAiB,CAC1D;IACC,QAAQ,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CACjC;AAED;;;;+FAI+F;AAC/F,MAAM,WAAW,kBAAkB;IACjC,WAAW,IAAI,mBAAmB,GAAG,IAAI,CAAA;IACzC,OAAO,CACL,SAAS,EAAE,iBAAiB,EAC5B,OAAO,EAAE,QAAQ,CAAC,eAAe,CAAC,GACjC,0BAA0B,GAAG,IAAI,CAAA;CACrC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type EndpointContext, type EndpointOperations, type EndpointReference, type EndpointRole, type EndpointState, type EndpointReferences, type RouteSummary } from '@wovvmap/contracts';
|
|
2
|
+
import type { EndpointLookupPort } from './EndpointLookupPort.js';
|
|
3
|
+
/** One endpoint owner per viewer; no API, camera, renderer, UI or second node database.
|
|
4
|
+
* Hinglish: Har viewer ke endpoints ka ek owner; camera/API/UI ka kaam is class mein nahi. */
|
|
5
|
+
export declare class EndpointService implements EndpointOperations {
|
|
6
|
+
private readonly lookup;
|
|
7
|
+
private snapshot;
|
|
8
|
+
private origin;
|
|
9
|
+
private destination;
|
|
10
|
+
private readonly listeners;
|
|
11
|
+
private destroyed;
|
|
12
|
+
constructor(lookup: EndpointLookupPort);
|
|
13
|
+
/** Stable read projection; subscribers always read the latest accepted pair.
|
|
14
|
+
* Hinglish: Read se naya object nahi banta; subscriber latest accepted pair padhe. */
|
|
15
|
+
getSnapshot: () => EndpointState | null;
|
|
16
|
+
/** Runtime-only immutable keys for renderer/focus projection; never serialize them to the host store.
|
|
17
|
+
* Hinglish: Sirf runtime paint/focus ke liye resolved keys; public event/Native host mein nahi bhejne. */
|
|
18
|
+
getCandidateKeys(role: EndpointRole): readonly string[];
|
|
19
|
+
/** Observe effective changes for the future endpointsChanged binding; no command replay.
|
|
20
|
+
* Hinglish: Bridge/store yahan change sunenge; subscribe karne se setter dobara nahi chalta. */
|
|
21
|
+
subscribe: (listener: () => void) => (() => void);
|
|
22
|
+
/** Call after a successful committed-map replacement/clear, never on loadStart or load failure.
|
|
23
|
+
* Hinglish: Naya map successfully commit ho tab call karo; failed/cancelled load par nahi. */
|
|
24
|
+
commitMap(): EndpointState | null;
|
|
25
|
+
setOrigin(reference: EndpointReference | null, context?: EndpointContext): EndpointState;
|
|
26
|
+
setDestination(reference: EndpointReference | null, context?: EndpointContext): EndpointState;
|
|
27
|
+
swapEndpoints(context?: EndpointContext): EndpointState;
|
|
28
|
+
clearEndpoints(context?: EndpointContext): EndpointState;
|
|
29
|
+
/** Resolve both captured refs before one commit; a direction Back can retain a non-overlapping edited origin.
|
|
30
|
+
* Hinglish: Dono refs pehle valid hon; edited origin overlap kare to captured origin hi restore ho. */
|
|
31
|
+
restore(references: EndpointReferences, context?: EndpointContext, preserveOrigin?: boolean): EndpointState;
|
|
32
|
+
/** Prepare without publishing; adopt the route before endpoint subscribers observe the new pair.
|
|
33
|
+
* Hinglish: Pending restore purane endpoints na badle; commit par pair aur route saath ready hon. */
|
|
34
|
+
prepareRestore(references: EndpointReferences, context?: EndpointContext, physical?: readonly Pick<RouteSummary, 'origin' | 'destination'>[]): (adopt: (state: EndpointState) => void) => void;
|
|
35
|
+
/** Revalidate existing intents atomically after catalog eligibility changes, without a timer.
|
|
36
|
+
* Hinglish: Offer eligibility badle to existing refs ek saath check hon; timer/full scan nahi. */
|
|
37
|
+
refresh(): EndpointState;
|
|
38
|
+
/** Release only this viewer's candidates/subscribers; no event or default origin on teardown.
|
|
39
|
+
* Hinglish: Dispose mein sirf apna state/listeners chhode; default origin/event nahi. */
|
|
40
|
+
destroy(): void;
|
|
41
|
+
private setEndpoint;
|
|
42
|
+
private resolve;
|
|
43
|
+
private commitPair;
|
|
44
|
+
private requireMap;
|
|
45
|
+
private checkContext;
|
|
46
|
+
private assertAlive;
|
|
47
|
+
private notify;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=EndpointService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointService.d.ts","sourceRoot":"","sources":["../../src/endpoints/EndpointService.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,eAAe,EAEpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,aAAa,EAElB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAS9D;8FAC8F;AAC9F,qBAAa,eAAgB,YAAW,kBAAkB;IAO5C,OAAO,CAAC,QAAQ,CAAC,MAAM;IANnC,OAAO,CAAC,QAAQ,CAA6B;IAC7C,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwB;IAClD,OAAO,CAAC,SAAS,CAAQ;gBAEI,MAAM,EAAE,kBAAkB;IAIvD;0FACsF;IAC/E,WAAW,QAAO,aAAa,GAAG,IAAI,CAAiB;IAE9D;8GAC0G;IACnG,gBAAgB,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE;IAI9D;oGACgG;IACzF,SAAS,GAAI,UAAU,MAAM,IAAI,KAAG,CAAC,MAAM,IAAI,CAAC,CAItD;IAED;kGAC8F;IACvF,SAAS,IAAI,aAAa,GAAG,IAAI;IAmBjC,SAAS,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,aAAa;IAIxF,cAAc,CACnB,SAAS,EAAE,iBAAiB,GAAG,IAAI,EACnC,OAAO,CAAC,EAAE,eAAe,GACxB,aAAa;IAIT,aAAa,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,aAAa;IAKvD,cAAc,CAAC,OAAO,CAAC,EAAE,eAAe,GAAG,aAAa;IAK/D;2GACuG;IAChG,OAAO,CACZ,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,eAAe,EACzB,cAAc,UAAQ,GACrB,aAAa;IAWhB;yGACqG;IAC9F,cAAc,CACnB,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,eAAe,EACzB,QAAQ,GAAE,SAAS,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,aAAa,CAAC,EAAO,IA6B9D,OAAO,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,KAAG,IAAI;IAWtD;sGACkG;IAC3F,OAAO,IAAI,aAAa;IAS/B;6FACyF;IAClF,OAAO,IAAI,IAAI;IAQtB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,OAAO;IA8Cf,OAAO,CAAC,UAAU;IA8ClB,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { freezeEndpointReference, ViewerCommandError, } from '@wovvmap/contracts';
|
|
2
|
+
/** One endpoint owner per viewer; no API, camera, renderer, UI or second node database.
|
|
3
|
+
* Hinglish: Har viewer ke endpoints ka ek owner; camera/API/UI ka kaam is class mein nahi. */
|
|
4
|
+
export class EndpointService {
|
|
5
|
+
lookup;
|
|
6
|
+
snapshot = null;
|
|
7
|
+
origin = null;
|
|
8
|
+
destination = null;
|
|
9
|
+
listeners = new Set();
|
|
10
|
+
destroyed = false;
|
|
11
|
+
constructor(lookup) {
|
|
12
|
+
this.lookup = lookup;
|
|
13
|
+
this.commitMap();
|
|
14
|
+
}
|
|
15
|
+
/** Stable read projection; subscribers always read the latest accepted pair.
|
|
16
|
+
* Hinglish: Read se naya object nahi banta; subscriber latest accepted pair padhe. */
|
|
17
|
+
getSnapshot = () => this.snapshot;
|
|
18
|
+
/** Runtime-only immutable keys for renderer/focus projection; never serialize them to the host store.
|
|
19
|
+
* Hinglish: Sirf runtime paint/focus ke liye resolved keys; public event/Native host mein nahi bhejne. */
|
|
20
|
+
getCandidateKeys(role) {
|
|
21
|
+
return (role === 'origin' ? this.origin : this.destination)?.candidateKeys ?? EMPTY_KEYS;
|
|
22
|
+
}
|
|
23
|
+
/** Observe effective changes for the future endpointsChanged binding; no command replay.
|
|
24
|
+
* Hinglish: Bridge/store yahan change sunenge; subscribe karne se setter dobara nahi chalta. */
|
|
25
|
+
subscribe = (listener) => {
|
|
26
|
+
this.assertAlive();
|
|
27
|
+
this.listeners.add(listener);
|
|
28
|
+
return () => this.listeners.delete(listener);
|
|
29
|
+
};
|
|
30
|
+
/** Call after a successful committed-map replacement/clear, never on loadStart or load failure.
|
|
31
|
+
* Hinglish: Naya map successfully commit ho tab call karo; failed/cancelled load par nahi. */
|
|
32
|
+
commitMap() {
|
|
33
|
+
this.assertAlive();
|
|
34
|
+
const identity = this.lookup.getIdentity();
|
|
35
|
+
if (sameIdentity(this.snapshot, identity))
|
|
36
|
+
return this.snapshot;
|
|
37
|
+
this.origin = null;
|
|
38
|
+
this.destination = null;
|
|
39
|
+
this.snapshot = identity
|
|
40
|
+
? Object.freeze({
|
|
41
|
+
mallId: identity.mallId,
|
|
42
|
+
revision: identity.revision,
|
|
43
|
+
origin: null,
|
|
44
|
+
destination: null,
|
|
45
|
+
conflict: null,
|
|
46
|
+
})
|
|
47
|
+
: null;
|
|
48
|
+
this.notify();
|
|
49
|
+
return this.snapshot;
|
|
50
|
+
}
|
|
51
|
+
setOrigin(reference, context) {
|
|
52
|
+
return this.setEndpoint('origin', reference, context);
|
|
53
|
+
}
|
|
54
|
+
setDestination(reference, context) {
|
|
55
|
+
return this.setEndpoint('destination', reference, context);
|
|
56
|
+
}
|
|
57
|
+
swapEndpoints(context) {
|
|
58
|
+
const identity = this.requireMap(context);
|
|
59
|
+
return this.commitPair(this.destination, this.origin, identity);
|
|
60
|
+
}
|
|
61
|
+
clearEndpoints(context) {
|
|
62
|
+
const identity = this.requireMap(context);
|
|
63
|
+
return this.commitPair(null, null, identity);
|
|
64
|
+
}
|
|
65
|
+
/** Resolve both captured refs before one commit; a direction Back can retain a non-overlapping edited origin.
|
|
66
|
+
* Hinglish: Dono refs pehle valid hon; edited origin overlap kare to captured origin hi restore ho. */
|
|
67
|
+
restore(references, context, preserveOrigin = false) {
|
|
68
|
+
const identity = this.requireMap(context);
|
|
69
|
+
const origin = references.origin ? this.resolve(references.origin, identity) : null;
|
|
70
|
+
const destination = references.destination
|
|
71
|
+
? this.resolve(references.destination, identity)
|
|
72
|
+
: null;
|
|
73
|
+
const retained = preserveOrigin && this.origin && !getConflict(this.origin, destination) ? this.origin : origin;
|
|
74
|
+
return this.commitPair(retained, destination, identity);
|
|
75
|
+
}
|
|
76
|
+
/** Prepare without publishing; adopt the route before endpoint subscribers observe the new pair.
|
|
77
|
+
* Hinglish: Pending restore purane endpoints na badle; commit par pair aur route saath ready hon. */
|
|
78
|
+
prepareRestore(references, context, physical = []) {
|
|
79
|
+
const identity = this.requireMap(context);
|
|
80
|
+
const before = this.snapshot;
|
|
81
|
+
const bind = (reference) => reference?.kind === 'group'
|
|
82
|
+
? {
|
|
83
|
+
kind: 'group',
|
|
84
|
+
request: { ...reference.request, expectedRevision: identity.revision },
|
|
85
|
+
}
|
|
86
|
+
: reference;
|
|
87
|
+
const origin = references.origin ? this.resolve(bind(references.origin), identity) : null;
|
|
88
|
+
const destination = references.destination
|
|
89
|
+
? this.resolve(bind(references.destination), identity)
|
|
90
|
+
: null;
|
|
91
|
+
const conflict = getConflict(origin, destination);
|
|
92
|
+
if (!origin || !destination || conflict)
|
|
93
|
+
throw new ViewerCommandError('Saved endpoints are unavailable.', {
|
|
94
|
+
code: conflict ?? 'INVALID_ENDPOINT',
|
|
95
|
+
});
|
|
96
|
+
if (physical.some((pair) => !origin.keys.has(pair.origin.key) || !destination.keys.has(pair.destination.key)))
|
|
97
|
+
throw new ViewerCommandError('Saved physical endpoint is no longer eligible.', {
|
|
98
|
+
code: 'OFFLINE_ROUTE_STALE',
|
|
99
|
+
});
|
|
100
|
+
let used = false;
|
|
101
|
+
return (adopt) => {
|
|
102
|
+
this.requireMap(context);
|
|
103
|
+
if (used || this.snapshot !== before)
|
|
104
|
+
throw new ViewerCommandError('Endpoints changed during restore.', {
|
|
105
|
+
code: 'STALE_REVISION',
|
|
106
|
+
});
|
|
107
|
+
used = true;
|
|
108
|
+
this.commitPair(origin, destination, identity, adopt);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** Revalidate existing intents atomically after catalog eligibility changes, without a timer.
|
|
112
|
+
* Hinglish: Offer eligibility badle to existing refs ek saath check hon; timer/full scan nahi. */
|
|
113
|
+
refresh() {
|
|
114
|
+
const identity = this.requireMap();
|
|
115
|
+
const origin = this.origin ? this.resolve(this.origin.summary.reference, identity, true) : null;
|
|
116
|
+
const destination = this.destination
|
|
117
|
+
? this.resolve(this.destination.summary.reference, identity, true)
|
|
118
|
+
: null;
|
|
119
|
+
return this.commitPair(origin, destination, identity);
|
|
120
|
+
}
|
|
121
|
+
/** Release only this viewer's candidates/subscribers; no event or default origin on teardown.
|
|
122
|
+
* Hinglish: Dispose mein sirf apna state/listeners chhode; default origin/event nahi. */
|
|
123
|
+
destroy() {
|
|
124
|
+
this.destroyed = true;
|
|
125
|
+
this.origin = null;
|
|
126
|
+
this.destination = null;
|
|
127
|
+
this.snapshot = null;
|
|
128
|
+
this.listeners.clear();
|
|
129
|
+
}
|
|
130
|
+
setEndpoint(role, reference, context) {
|
|
131
|
+
const identity = this.requireMap(context);
|
|
132
|
+
const entry = reference ? this.resolve(reference, identity) : null;
|
|
133
|
+
return this.commitPair(role === 'origin' ? entry : this.origin, role === 'destination' ? entry : this.destination, identity);
|
|
134
|
+
}
|
|
135
|
+
resolve(reference, identity, allowMissing = false) {
|
|
136
|
+
const ownedReference = freezeEndpointReference(reference);
|
|
137
|
+
if (ownedReference.kind === 'group')
|
|
138
|
+
this.checkContext(ownedReference.request, identity);
|
|
139
|
+
const resolved = this.lookup.resolve(ownedReference, {
|
|
140
|
+
mallId: identity.mallId,
|
|
141
|
+
expectedRevision: identity.revision,
|
|
142
|
+
});
|
|
143
|
+
if (!resolved || !resolved.keys.length) {
|
|
144
|
+
if (allowMissing)
|
|
145
|
+
return null;
|
|
146
|
+
throw new ViewerCommandError('Endpoint target is unavailable in the committed map', {
|
|
147
|
+
code: reference.kind === 'node'
|
|
148
|
+
? 'NODE_NOT_FOUND'
|
|
149
|
+
: reference.kind === 'group'
|
|
150
|
+
? 'GROUP_NOT_FOUND'
|
|
151
|
+
: 'AMENITY_NOT_FOUND',
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
// Only affected candidates are indexed once; no NodePoint/shape traversal or public key array.
|
|
155
|
+
// Hinglish: Selected group ki keys ka ek Set; poore map/shape ka loop ya public list nahi.
|
|
156
|
+
const keys = new Set(resolved.keys);
|
|
157
|
+
const member = resolved.representative;
|
|
158
|
+
return {
|
|
159
|
+
keys,
|
|
160
|
+
candidateKeys: Object.freeze([...keys]),
|
|
161
|
+
signature: JSON.stringify(ownedReference),
|
|
162
|
+
summary: Object.freeze({
|
|
163
|
+
reference: ownedReference,
|
|
164
|
+
name: resolved.name,
|
|
165
|
+
representative: Object.freeze({
|
|
166
|
+
key: member.key,
|
|
167
|
+
floorIndex: member.floorIndex,
|
|
168
|
+
floorName: member.floorName,
|
|
169
|
+
type: member.type,
|
|
170
|
+
}),
|
|
171
|
+
...(resolved.logoUrl !== undefined ? { logoUrl: resolved.logoUrl } : {}),
|
|
172
|
+
memberCount: keys.size,
|
|
173
|
+
availableFloors: Object.freeze([...resolved.availableFloors]),
|
|
174
|
+
}),
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
commitPair(origin, destination, identity, adopt) {
|
|
178
|
+
// A lookup may synchronously replace/clear its map; never commit an old result into the new map.
|
|
179
|
+
// Hinglish: Lookup ke beech map replace ho to purana result naye map mein commit na ho.
|
|
180
|
+
if (!sameIdentity(identity, this.requireMap())) {
|
|
181
|
+
throw new ViewerCommandError('Map changed during endpoint resolution', {
|
|
182
|
+
code: 'STALE_REVISION',
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const sameOrigin = sameEntry(this.origin, origin);
|
|
186
|
+
const sameDestination = sameEntry(this.destination, destination);
|
|
187
|
+
if (sameOrigin && sameDestination) {
|
|
188
|
+
adopt?.(this.snapshot);
|
|
189
|
+
return this.snapshot;
|
|
190
|
+
}
|
|
191
|
+
const previous = { origin: this.origin, destination: this.destination, snapshot: this.snapshot };
|
|
192
|
+
this.origin = sameOrigin ? this.origin : origin;
|
|
193
|
+
this.destination = sameDestination ? this.destination : destination;
|
|
194
|
+
const state = Object.freeze({
|
|
195
|
+
mallId: identity.mallId,
|
|
196
|
+
revision: identity.revision,
|
|
197
|
+
origin: this.origin?.summary ?? null,
|
|
198
|
+
destination: this.destination?.summary ?? null,
|
|
199
|
+
conflict: getConflict(this.origin, this.destination),
|
|
200
|
+
});
|
|
201
|
+
this.snapshot = state;
|
|
202
|
+
try {
|
|
203
|
+
adopt?.(state);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
// A failed adoption rolls back only its own pair; a newer observer command must survive.
|
|
207
|
+
// Hinglish: Failed route old pair rakhe, par callback ka naya endpoint kabhi undo na ho.
|
|
208
|
+
if (this.snapshot === state) {
|
|
209
|
+
this.origin = previous.origin;
|
|
210
|
+
this.destination = previous.destination;
|
|
211
|
+
this.snapshot = previous.snapshot;
|
|
212
|
+
}
|
|
213
|
+
throw error;
|
|
214
|
+
}
|
|
215
|
+
if (this.snapshot === state)
|
|
216
|
+
this.notify();
|
|
217
|
+
return state;
|
|
218
|
+
}
|
|
219
|
+
requireMap(context) {
|
|
220
|
+
this.assertAlive();
|
|
221
|
+
const identity = this.lookup.getIdentity();
|
|
222
|
+
if (!identity)
|
|
223
|
+
throw new ViewerCommandError('No committed map', { code: 'NO_COMMITTED_MAP' });
|
|
224
|
+
if (!sameIdentity(this.snapshot, identity)) {
|
|
225
|
+
throw new ViewerCommandError('Commit the new map before setting endpoints', {
|
|
226
|
+
code: 'STALE_REVISION',
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
this.checkContext(context, identity);
|
|
230
|
+
return { mallId: identity.mallId, revision: identity.revision };
|
|
231
|
+
}
|
|
232
|
+
checkContext(context, identity) {
|
|
233
|
+
if (context?.mallId !== undefined && context.mallId !== identity.mallId) {
|
|
234
|
+
throw new ViewerCommandError('Endpoint belongs to another mall', { code: 'MALL_MISMATCH' });
|
|
235
|
+
}
|
|
236
|
+
if (context?.expectedRevision !== undefined && context.expectedRevision !== identity.revision) {
|
|
237
|
+
throw new ViewerCommandError('Endpoint belongs to another revision', {
|
|
238
|
+
code: 'STALE_REVISION',
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
assertAlive() {
|
|
243
|
+
if (this.destroyed)
|
|
244
|
+
throw new ViewerCommandError('Endpoint owner is destroyed', { code: 'VIEWER_DESTROYED' });
|
|
245
|
+
}
|
|
246
|
+
notify() {
|
|
247
|
+
for (const listener of this.listeners)
|
|
248
|
+
listener();
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
function sameIdentity(a, b) {
|
|
252
|
+
return a?.mallId === b?.mallId && a?.revision === b?.revision;
|
|
253
|
+
}
|
|
254
|
+
function sameEntry(a, b) {
|
|
255
|
+
if (a === b)
|
|
256
|
+
return true;
|
|
257
|
+
if (!a || !b || a.signature !== b.signature || a.keys.size !== b.keys.size)
|
|
258
|
+
return false;
|
|
259
|
+
for (const key of a.keys)
|
|
260
|
+
if (!b.keys.has(key))
|
|
261
|
+
return false;
|
|
262
|
+
return true;
|
|
263
|
+
}
|
|
264
|
+
function getConflict(origin, destination) {
|
|
265
|
+
if (!origin || !destination)
|
|
266
|
+
return null;
|
|
267
|
+
const smaller = origin.keys.size <= destination.keys.size ? origin.keys : destination.keys;
|
|
268
|
+
const other = smaller === origin.keys ? destination.keys : origin.keys;
|
|
269
|
+
for (const key of smaller) {
|
|
270
|
+
if (other.has(key)) {
|
|
271
|
+
return origin.keys.size === 1 && destination.keys.size === 1
|
|
272
|
+
? 'SAME_LOCATION'
|
|
273
|
+
: 'OVERLAPPING_LOCATIONS';
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
const EMPTY_KEYS = Object.freeze([]);
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared endpoint and route lifecycle ownership; proprietary planning remains in the private API.
|
|
3
|
+
* Hinglish: Endpoints aur route state common hain; graph/solver private, playback agle checkpoint mein hai.
|
|
4
|
+
*/
|
|
5
|
+
export { EndpointService } from './endpoints/EndpointService.js';
|
|
6
|
+
export type { EndpointLookupPort, ResolvedEndpointCandidates } from './endpoints/EndpointLookupPort.js';
|
|
7
|
+
export { resolveNavigationConfig } from './routes/navigationConfig.js';
|
|
8
|
+
export { RouteService } from './routes/RouteService.js';
|
|
9
|
+
export type { RouteServicePorts, RouteRenderHandle } from './routes/RouteService.js';
|
|
10
|
+
export type { RouteDisplayProvider, RouteRestoreCandidate, RouteRestoreLoader, } from './routes/RouteRestore.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAA;AAC7D,YAAY,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,MAAM,gCAAgC,CAAA;AACpG,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,YAAY,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACjF,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,uBAAuB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared endpoint and route lifecycle ownership; proprietary planning remains in the private API.
|
|
3
|
+
* Hinglish: Endpoints aur route state common hain; graph/solver private, playback agle checkpoint mein hai.
|
|
4
|
+
*/
|
|
5
|
+
export { EndpointService } from './endpoints/EndpointService.js';
|
|
6
|
+
export { resolveNavigationConfig } from './routes/navigationConfig.js';
|
|
7
|
+
export { RouteService } from './routes/RouteService.js';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type RoutePlaybackBinding, type RoutePlaybackDriver, type RoutePlaybackOptions, type RoutePlaybackState, type RoutePlaybackProgress } from '@wovvmap/contracts';
|
|
2
|
+
/** Display-only cursor. Replay never grants reverse travel through one-way/airport checkpoints.
|
|
3
|
+
* Hinglish: Clock/cursor yahan; allowed travel, graph aur security rules private backend mein hi hain. */
|
|
4
|
+
export declare class RoutePlayback implements RoutePlaybackDriver {
|
|
5
|
+
private readonly changed;
|
|
6
|
+
private readonly now;
|
|
7
|
+
private readonly current;
|
|
8
|
+
private readonly progressed;
|
|
9
|
+
private state;
|
|
10
|
+
private binding?;
|
|
11
|
+
private scope?;
|
|
12
|
+
private elapsed;
|
|
13
|
+
private playbackId;
|
|
14
|
+
private sequence;
|
|
15
|
+
private lastEmit;
|
|
16
|
+
private progress;
|
|
17
|
+
private distance;
|
|
18
|
+
private lastTime?;
|
|
19
|
+
private epoch;
|
|
20
|
+
private handoff?;
|
|
21
|
+
private presentationTimer?;
|
|
22
|
+
private countdownRemaining;
|
|
23
|
+
private countdownStartedAt?;
|
|
24
|
+
private finishDelay;
|
|
25
|
+
private completion?;
|
|
26
|
+
private pending?;
|
|
27
|
+
constructor(changed: () => void, now?: () => number, current?: () => boolean, progressed?: (value: Omit<RoutePlaybackProgress, 'routeSetId' | 'routeId'> | null) => void);
|
|
28
|
+
get snapshot(): Readonly<RoutePlaybackState>;
|
|
29
|
+
get progressSnapshot(): Omit<RoutePlaybackProgress, "routeId" | "routeSetId"> | null;
|
|
30
|
+
private get preferences();
|
|
31
|
+
private emitProgress;
|
|
32
|
+
get running(): boolean;
|
|
33
|
+
resetClock(): void;
|
|
34
|
+
interrupt(): void;
|
|
35
|
+
/** Manual input always cancels automatic presentation, even when simulation follow is off.
|
|
36
|
+
* Hinglish: Countdown/finish ka old camera action user ke pan/zoom ko overwrite na kare. */
|
|
37
|
+
beforeCameraChange(): void;
|
|
38
|
+
unavailable(): void;
|
|
39
|
+
private publish;
|
|
40
|
+
private cancel;
|
|
41
|
+
private release;
|
|
42
|
+
/** Retire resources/callbacks, retaining only viewer preferences, never a stale route scope.
|
|
43
|
+
* Hinglish: Clear/new route par old cursor khatam; mode/speed isi viewer mein bachein. */
|
|
44
|
+
retire(): void;
|
|
45
|
+
update(options: RoutePlaybackOptions): boolean;
|
|
46
|
+
start(binding: RoutePlaybackBinding, kind: 'play' | 'resume' | 'replay', before: () => void): Promise<void>;
|
|
47
|
+
pause(): void;
|
|
48
|
+
stop(): void;
|
|
49
|
+
/** Engine RAF only; no per-frame publication. Invalid/first deltas are zero, stalls capped at100ms.
|
|
50
|
+
* Hinglish: Har frame UI/Native event nahi; completion par sirf ek compact state update ho.
|
|
51
|
+
*/
|
|
52
|
+
tick(time: number): boolean;
|
|
53
|
+
/** Consume only the next server-approved visit; no graph lookup, floor watcher or second clock.
|
|
54
|
+
* Hinglish: Boundary par ek cancellable handoff; zero visits bhi finite ordered profile se aage badhein. */
|
|
55
|
+
private settle;
|
|
56
|
+
private remainingCountdown;
|
|
57
|
+
/** One deadline, no RAF/interval; only changed whole seconds reach host UI.
|
|
58
|
+
* Hinglish: Paused/hidden wall time simulation ya countdown mein catch-up na bane. */
|
|
59
|
+
private beginCountdown;
|
|
60
|
+
private activate;
|
|
61
|
+
private cancelCompletion;
|
|
62
|
+
/** Completion is semantic immediately; optional framing is cancellable presentation only.
|
|
63
|
+
* Hinglish: Replay/newer input ko delay block na kare; camera failure completed ko undo nahi kare. */
|
|
64
|
+
private finish;
|
|
65
|
+
private transition;
|
|
66
|
+
private advance;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=RoutePlayback.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutePlayback.d.ts","sourceRoot":"","sources":["../../src/routes/RoutePlayback.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EAEzB,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC3B,MAAM,oBAAoB,CAAA;AAQ3B;0GAC0G;AAC1G,qBAAa,aAAc,YAAW,mBAAmB;IA4BrD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IA9B7B,OAAO,CAAC,KAAK,CAGX;IACF,OAAO,CAAC,OAAO,CAAC,CAAsB;IACtC,OAAO,CAAC,KAAK,CAAC,CAAoB;IAClC,OAAO,CAAC,OAAO,CAAI;IACnB,OAAO,CAAC,UAAU,CAAI;IACtB,OAAO,CAAC,QAAQ,CAAI;IACpB,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,QAAQ,CAAqE;IACrF,OAAO,CAAC,QAAQ,CAAI;IACpB,OAAO,CAAC,QAAQ,CAAC,CAAQ;IACzB,OAAO,CAAC,KAAK,CAAI;IACjB,OAAO,CAAC,OAAO,CAAC,CAAiB;IACjC,OAAO,CAAC,iBAAiB,CAAC,CAA+B;IACzD,OAAO,CAAC,kBAAkB,CAAI;IAC9B,OAAO,CAAC,kBAAkB,CAAC,CAAQ;IACnC,OAAO,CAAC,WAAW,CAAI;IACvB,OAAO,CAAC,UAAU,CAAC,CAAiB;IACpC,OAAO,CAAC,OAAO,CAAC,CAKf;gBAEkB,OAAO,EAAE,MAAM,IAAI,EACnB,GAAG,GAAE,MAAM,MAAgC,EAC3C,OAAO,GAAE,MAAM,OAAoB,EACnC,UAAU,GAAE,CAC3B,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,YAAY,GAAG,SAAS,CAAC,GAAG,IAAI,KAChE,IAAe;IAEtB,IAAI,QAAQ,IAAI,QAAQ,CAAC,kBAAkB,CAAC,CAE3C;IACD,IAAI,gBAAgB,iEAEnB;IACD,OAAO,KAAK,WAAW,GAYtB;IACD,OAAO,CAAC,YAAY;IAuCpB,IAAI,OAAO,IAAI,OAAO,CAErB;IACD,UAAU,IAAI,IAAI;IAWlB,SAAS,IAAI,IAAI;IAQjB;gGAC4F;IAC5F,kBAAkB,IAAI,IAAI;IAU1B,WAAW,IAAI,IAAI;IAKnB,OAAO,CAAC,OAAO;IASf,OAAO,CAAC,MAAM;IAiBd,OAAO,CAAC,OAAO;IAKf;8FAC0F;IAC1F,MAAM,IAAI,IAAI;IAed,MAAM,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO;IA6F9C,KAAK,CACH,OAAO,EAAE,oBAAoB,EAC7B,IAAI,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,EAClC,MAAM,EAAE,MAAM,IAAI,GACjB,OAAO,CAAC,IAAI,CAAC;IA4KhB,KAAK,IAAI,IAAI;IA0Db,IAAI,IAAI,IAAI;IAWZ;;OAEG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAM3B;gHAC4G;IAC5G,OAAO,CAAC,MAAM;IAUd,OAAO,CAAC,kBAAkB;IAO1B;0FACsF;IACtF,OAAO,CAAC,cAAc;IAmDtB,OAAO,CAAC,QAAQ;IAWhB,OAAO,CAAC,gBAAgB;IAQxB;0GACsG;IACtG,OAAO,CAAC,MAAM;IAqCd,OAAO,CAAC,UAAU;IA8DlB,OAAO,CAAC,OAAO;CAkBhB"}
|