@flare-engine/deep-links 0.2.0 → 0.3.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/dist/index.mjs CHANGED
@@ -1,205 +1,225 @@
1
- // src/parse.ts
1
+ import { Signal } from "@flare-engine/events";
2
+ //#region src/manager.ts
3
+ var DeepLinkManager = class {
4
+ onMatch = new Signal();
5
+ onUnmatched = new Signal();
6
+ router;
7
+ source;
8
+ unsubscribe = null;
9
+ _current = null;
10
+ constructor(options) {
11
+ this.router = options.router;
12
+ this.source = options.source;
13
+ }
14
+ get current() {
15
+ return this._current;
16
+ }
17
+ async start() {
18
+ if (this.unsubscribe) return;
19
+ this.unsubscribe = this.source.subscribe((url) => this.handle(url));
20
+ const initial = await Promise.resolve(this.source.getInitialUrl());
21
+ if (initial) this.handle(initial);
22
+ }
23
+ stop() {
24
+ if (this.unsubscribe) {
25
+ this.unsubscribe();
26
+ this.unsubscribe = null;
27
+ }
28
+ }
29
+ handle(url) {
30
+ const match = this.router.match(url);
31
+ if (!match) {
32
+ this.onUnmatched.emit(url);
33
+ return null;
34
+ }
35
+ this._current = match;
36
+ this.onMatch.emit(match);
37
+ return match;
38
+ }
39
+ };
40
+ //#endregion
41
+ //#region src/parse.ts
2
42
  function parseUrl(url) {
3
- if (typeof url !== "string" || url.length === 0) return null;
4
- let rest = url;
5
- let scheme = null;
6
- let host = null;
7
- const schemeIdx = rest.indexOf("://");
8
- if (schemeIdx !== -1) {
9
- scheme = rest.slice(0, schemeIdx);
10
- rest = rest.slice(schemeIdx + 3);
11
- const slashIdx = rest.indexOf("/");
12
- if (slashIdx === -1) {
13
- host = rest;
14
- rest = "/";
15
- } else {
16
- host = rest.slice(0, slashIdx);
17
- rest = rest.slice(slashIdx);
18
- }
19
- }
20
- const hashIdx = rest.indexOf("#");
21
- if (hashIdx !== -1) rest = rest.slice(0, hashIdx);
22
- let path = rest;
23
- let queryStr = "";
24
- const qIdx = rest.indexOf("?");
25
- if (qIdx !== -1) {
26
- path = rest.slice(0, qIdx);
27
- queryStr = rest.slice(qIdx + 1);
28
- }
29
- const segments = path.split("/").filter((s) => s.length > 0).map(safeDecode);
30
- const query = {};
31
- if (queryStr.length > 0) {
32
- for (const pair of queryStr.split("&")) {
33
- if (pair.length === 0) continue;
34
- const eq = pair.indexOf("=");
35
- const rawKey = eq === -1 ? pair : pair.slice(0, eq);
36
- const rawVal = eq === -1 ? "" : pair.slice(eq + 1);
37
- const key = safeDecode(rawKey);
38
- if (key.length === 0) continue;
39
- query[key] = safeDecode(rawVal);
40
- }
41
- }
42
- return { scheme, host, segments, query };
43
+ if (typeof url !== "string" || url.length === 0) return null;
44
+ let rest = url;
45
+ let scheme = null;
46
+ let host = null;
47
+ const schemeIdx = rest.indexOf("://");
48
+ if (schemeIdx !== -1 && /^[a-zA-Z][a-zA-Z0-9+.-]*$/.test(rest.slice(0, schemeIdx))) {
49
+ scheme = rest.slice(0, schemeIdx);
50
+ rest = rest.slice(schemeIdx + 3);
51
+ const lower = scheme.toLowerCase();
52
+ if (lower === "http" || lower === "https") {
53
+ const delimIdx = rest.search(/[/?#]/);
54
+ if (delimIdx === -1) {
55
+ host = rest;
56
+ rest = "/";
57
+ } else {
58
+ host = rest.slice(0, delimIdx);
59
+ rest = rest.slice(delimIdx);
60
+ }
61
+ } else {
62
+ host = "";
63
+ if (rest.length === 0 || rest[0] !== "/") rest = `/${rest}`;
64
+ }
65
+ }
66
+ const hashIdx = rest.indexOf("#");
67
+ if (hashIdx !== -1) rest = rest.slice(0, hashIdx);
68
+ let path = rest;
69
+ let queryStr = "";
70
+ const qIdx = rest.indexOf("?");
71
+ if (qIdx !== -1) {
72
+ path = rest.slice(0, qIdx);
73
+ queryStr = rest.slice(qIdx + 1);
74
+ }
75
+ const segments = path.split("/").filter((s) => s.length > 0).map(safeDecode);
76
+ const query = {};
77
+ if (queryStr.length > 0) for (const pair of queryStr.split("&")) {
78
+ if (pair.length === 0) continue;
79
+ const eq = pair.indexOf("=");
80
+ const rawKey = eq === -1 ? pair : pair.slice(0, eq);
81
+ const rawVal = eq === -1 ? "" : pair.slice(eq + 1);
82
+ const key = safeDecode(rawKey);
83
+ if (key.length === 0) continue;
84
+ query[key] = safeDecode(rawVal);
85
+ }
86
+ return {
87
+ scheme,
88
+ host,
89
+ segments,
90
+ query
91
+ };
43
92
  }
44
93
  function safeDecode(s) {
45
- try {
46
- return decodeURIComponent(s.replace(/\+/g, "%20"));
47
- } catch {
48
- return s;
49
- }
94
+ try {
95
+ return decodeURIComponent(s.replace(/\+/g, "%20"));
96
+ } catch {
97
+ return s;
98
+ }
50
99
  }
51
-
52
- // src/router.ts
100
+ //#endregion
101
+ //#region src/router.ts
53
102
  var DeepLinkRouter = class {
54
- routes = [];
55
- register(pattern, scene) {
56
- this.routes.push({ scene, segments: compile(pattern) });
57
- return this;
58
- }
59
- registerAll(defs) {
60
- for (const def of defs) this.register(def.pattern, def.scene);
61
- return this;
62
- }
63
- match(url) {
64
- const parsed = parseUrl(url);
65
- if (!parsed) return null;
66
- for (const route of this.routes) {
67
- const params = tryMatch(route, parsed.segments);
68
- if (!params) continue;
69
- const combined = { ...parsed.query, ...params };
70
- return { scene: route.scene, params: combined, url };
71
- }
72
- return null;
73
- }
103
+ routes = [];
104
+ register(pattern, scene) {
105
+ this.routes.push({
106
+ scene,
107
+ segments: compile(pattern)
108
+ });
109
+ return this;
110
+ }
111
+ registerAll(defs) {
112
+ for (const def of defs) this.register(def.pattern, def.scene);
113
+ return this;
114
+ }
115
+ match(url) {
116
+ const parsed = parseUrl(url);
117
+ if (!parsed) return null;
118
+ for (const route of this.routes) {
119
+ const params = tryMatch(route, parsed.segments);
120
+ if (!params) continue;
121
+ const combined = {
122
+ ...parsed.query,
123
+ ...params
124
+ };
125
+ return {
126
+ scene: route.scene,
127
+ params: combined,
128
+ url
129
+ };
130
+ }
131
+ return null;
132
+ }
74
133
  };
75
134
  function compile(pattern) {
76
- return pattern.split("/").filter((s) => s.length > 0).map((s) => {
77
- if (s === "*") return { wildcard: true };
78
- if (s.startsWith(":")) return { param: s.slice(1) };
79
- return { literal: s };
80
- });
135
+ return pattern.split("/").filter((s) => s.length > 0).map((s) => {
136
+ if (s === "*") return { wildcard: true };
137
+ if (s.startsWith(":")) return { param: s.slice(1) };
138
+ return { literal: s };
139
+ });
81
140
  }
82
141
  function tryMatch(route, segs) {
83
- const out = {};
84
- const segCount = route.segments.length;
85
- for (let i = 0; i < segCount; i++) {
86
- const def = route.segments[i];
87
- if (!def) return null;
88
- if (def.wildcard) {
89
- out.rest = segs.slice(i).join("/");
90
- return out;
91
- }
92
- const actual = segs[i];
93
- if (actual === void 0) return null;
94
- if (def.literal !== void 0) {
95
- if (def.literal !== actual) return null;
96
- } else if (def.param !== void 0) {
97
- out[def.param] = actual;
98
- }
99
- }
100
- if (segs.length !== segCount) return null;
101
- return out;
142
+ const out = {};
143
+ const segCount = route.segments.length;
144
+ for (let i = 0; i < segCount; i++) {
145
+ const def = route.segments[i];
146
+ if (!def) return null;
147
+ if (def.wildcard) {
148
+ out.rest = segs.slice(i).join("/");
149
+ return out;
150
+ }
151
+ const actual = segs[i];
152
+ if (actual === void 0) return null;
153
+ if (def.literal !== void 0) {
154
+ if (def.literal !== actual) return null;
155
+ } else if (def.param !== void 0) out[def.param] = actual;
156
+ }
157
+ if (segs.length !== segCount) return null;
158
+ return out;
102
159
  }
103
-
104
- // src/manager.ts
105
- import { Signal } from "@flare-engine/events";
106
- var DeepLinkManager = class {
107
- onMatch = new Signal();
108
- onUnmatched = new Signal();
109
- router;
110
- source;
111
- unsubscribe = null;
112
- _current = null;
113
- constructor(options) {
114
- this.router = options.router;
115
- this.source = options.source;
116
- }
117
- get current() {
118
- return this._current;
119
- }
120
- async start() {
121
- if (this.unsubscribe) return;
122
- this.unsubscribe = this.source.subscribe((url) => this.handle(url));
123
- const initial = await Promise.resolve(this.source.getInitialUrl());
124
- if (initial) this.handle(initial);
125
- }
126
- stop() {
127
- if (this.unsubscribe) {
128
- this.unsubscribe();
129
- this.unsubscribe = null;
130
- }
131
- }
132
- handle(url) {
133
- const match = this.router.match(url);
134
- if (!match) {
135
- this.onUnmatched.emit(url);
136
- return null;
137
- }
138
- this._current = match;
139
- this.onMatch.emit(match);
140
- return match;
141
- }
142
- };
143
-
144
- // src/sources.ts
160
+ //#endregion
161
+ //#region src/sources.ts
162
+ /**
163
+ * In-memory source useful for tests and for host apps that want to push URLs
164
+ * manually (e.g., from a notification handler).
165
+ */
145
166
  function createMemorySource(initialUrl = null) {
146
- let initial = initialUrl;
147
- const listeners = /* @__PURE__ */ new Set();
148
- return {
149
- getInitialUrl() {
150
- const v = initial;
151
- initial = null;
152
- return v;
153
- },
154
- subscribe(handler) {
155
- listeners.add(handler);
156
- return () => listeners.delete(handler);
157
- },
158
- push(url) {
159
- for (const l of listeners) l(url);
160
- }
161
- };
167
+ let initial = initialUrl;
168
+ const listeners = /* @__PURE__ */ new Set();
169
+ return {
170
+ getInitialUrl() {
171
+ const v = initial;
172
+ initial = null;
173
+ return v;
174
+ },
175
+ subscribe(handler) {
176
+ listeners.add(handler);
177
+ return () => listeners.delete(handler);
178
+ },
179
+ push(url) {
180
+ for (const l of listeners) l(url);
181
+ }
182
+ };
162
183
  }
184
+ /**
185
+ * Web `popstate` + `location.href` adapter. Call `notify(url)` after any
186
+ * programmatic `history.pushState` if you want the manager to react.
187
+ */
163
188
  function createWebSource(win) {
164
- const listeners = /* @__PURE__ */ new Set();
165
- const onPop = () => {
166
- const href = win.location.href;
167
- for (const l of listeners) l(href);
168
- };
169
- return {
170
- getInitialUrl() {
171
- return win.location.href;
172
- },
173
- subscribe(handler) {
174
- listeners.add(handler);
175
- win.addEventListener("popstate", onPop);
176
- return () => {
177
- listeners.delete(handler);
178
- win.removeEventListener("popstate", onPop);
179
- };
180
- },
181
- notify(url) {
182
- for (const l of listeners) l(url);
183
- }
184
- };
189
+ const listeners = /* @__PURE__ */ new Set();
190
+ const onPop = () => {
191
+ const href = win.location.href;
192
+ for (const l of [...listeners]) l(href);
193
+ };
194
+ return {
195
+ getInitialUrl() {
196
+ return win.location.href;
197
+ },
198
+ subscribe(handler) {
199
+ listeners.add(handler);
200
+ if (listeners.size === 1) win.addEventListener("popstate", onPop);
201
+ return () => {
202
+ listeners.delete(handler);
203
+ if (listeners.size === 0) win.removeEventListener("popstate", onPop);
204
+ };
205
+ },
206
+ notify(url) {
207
+ for (const l of [...listeners]) l(url);
208
+ }
209
+ };
185
210
  }
186
211
  function createNativeSource(linking) {
187
- return {
188
- getInitialUrl() {
189
- return linking.getInitialURL();
190
- },
191
- subscribe(handler) {
192
- const sub = linking.addEventListener("url", (e) => handler(e.url));
193
- return () => sub.remove();
194
- }
195
- };
212
+ return {
213
+ getInitialUrl() {
214
+ return linking.getInitialURL();
215
+ },
216
+ subscribe(handler) {
217
+ const sub = linking.addEventListener("url", (e) => handler(e.url));
218
+ return () => sub.remove();
219
+ }
220
+ };
196
221
  }
197
- export {
198
- DeepLinkManager,
199
- DeepLinkRouter,
200
- createMemorySource,
201
- createNativeSource,
202
- createWebSource,
203
- parseUrl
204
- };
222
+ //#endregion
223
+ export { DeepLinkManager, DeepLinkRouter, createMemorySource, createNativeSource, createWebSource, parseUrl };
224
+
205
225
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/parse.ts","../src/router.ts","../src/manager.ts","../src/sources.ts"],"sourcesContent":["import type { Params } from './types.js';\n\n/**\n * Parse a `scheme://host/path?query` or `/path?query` URL into its path\n * segments and query params. Returns `null` if the input is malformed.\n *\n * This is intentionally minimal: it does not validate scheme, does not decode\n * fragments, and ignores username/password.\n */\nexport interface ParsedUrl {\n scheme: string | null;\n host: string | null;\n segments: string[];\n query: Params;\n}\n\nexport function parseUrl(url: string): ParsedUrl | null {\n if (typeof url !== 'string' || url.length === 0) return null;\n let rest = url;\n let scheme: string | null = null;\n let host: string | null = null;\n\n const schemeIdx = rest.indexOf('://');\n if (schemeIdx !== -1) {\n scheme = rest.slice(0, schemeIdx);\n rest = rest.slice(schemeIdx + 3);\n const slashIdx = rest.indexOf('/');\n if (slashIdx === -1) {\n host = rest;\n rest = '/';\n } else {\n host = rest.slice(0, slashIdx);\n rest = rest.slice(slashIdx);\n }\n }\n\n // Strip fragment.\n const hashIdx = rest.indexOf('#');\n if (hashIdx !== -1) rest = rest.slice(0, hashIdx);\n\n let path = rest;\n let queryStr = '';\n const qIdx = rest.indexOf('?');\n if (qIdx !== -1) {\n path = rest.slice(0, qIdx);\n queryStr = rest.slice(qIdx + 1);\n }\n\n const segments = path\n .split('/')\n .filter((s) => s.length > 0)\n .map(safeDecode);\n const query: Params = {};\n if (queryStr.length > 0) {\n for (const pair of queryStr.split('&')) {\n if (pair.length === 0) continue;\n const eq = pair.indexOf('=');\n const rawKey = eq === -1 ? pair : pair.slice(0, eq);\n const rawVal = eq === -1 ? '' : pair.slice(eq + 1);\n const key = safeDecode(rawKey);\n if (key.length === 0) continue;\n query[key] = safeDecode(rawVal);\n }\n }\n\n return { scheme, host, segments, query };\n}\n\nfunction safeDecode(s: string): string {\n try {\n return decodeURIComponent(s.replace(/\\+/g, '%20'));\n } catch {\n return s;\n }\n}\n","import { parseUrl } from './parse.js';\nimport type { DeepLinkMatch, Params } from './types.js';\n\n/**\n * Route pattern like `/bench/:id` or `/shop/:category/:item`. Segments\n * starting with `:` are captured; literal segments must match exactly.\n * The `*` segment matches the remainder of the path into a `rest` param.\n */\nexport interface RouteDefinition {\n pattern: string;\n scene: string;\n}\n\ninterface CompiledRoute {\n scene: string;\n segments: Array<{ literal?: string; param?: string; wildcard?: boolean }>;\n}\n\nexport class DeepLinkRouter {\n private routes: CompiledRoute[] = [];\n\n register(pattern: string, scene: string): this {\n this.routes.push({ scene, segments: compile(pattern) });\n return this;\n }\n\n registerAll(defs: readonly RouteDefinition[]): this {\n for (const def of defs) this.register(def.pattern, def.scene);\n return this;\n }\n\n match(url: string): DeepLinkMatch | null {\n const parsed = parseUrl(url);\n if (!parsed) return null;\n for (const route of this.routes) {\n const params = tryMatch(route, parsed.segments);\n if (!params) continue;\n const combined: Params = { ...parsed.query, ...params };\n return { scene: route.scene, params: combined, url };\n }\n return null;\n }\n}\n\nfunction compile(pattern: string): CompiledRoute['segments'] {\n return pattern\n .split('/')\n .filter((s) => s.length > 0)\n .map((s) => {\n if (s === '*') return { wildcard: true };\n if (s.startsWith(':')) return { param: s.slice(1) };\n return { literal: s };\n });\n}\n\nfunction tryMatch(route: CompiledRoute, segs: readonly string[]): Params | null {\n const out: Params = {};\n const segCount = route.segments.length;\n for (let i = 0; i < segCount; i++) {\n const def = route.segments[i];\n if (!def) return null;\n if (def.wildcard) {\n out.rest = segs.slice(i).join('/');\n return out;\n }\n const actual = segs[i];\n if (actual === undefined) return null;\n if (def.literal !== undefined) {\n if (def.literal !== actual) return null;\n } else if (def.param !== undefined) {\n out[def.param] = actual;\n }\n }\n if (segs.length !== segCount) return null;\n return out;\n}\n","import { Signal } from '@flare-engine/events';\nimport type { DeepLinkRouter } from './router.js';\nimport type { DeepLinkMatch } from './types.js';\n\n/**\n * Platform adapter that surfaces incoming URLs to the router. Web ships a\n * history-based adapter; RN consumers pass one that wires `Linking`.\n */\nexport interface DeepLinkSource {\n /** Current URL if the platform exposes one (e.g., `window.location.href`). */\n getInitialUrl(): Promise<string | null> | string | null;\n /** Register a handler for future URL updates; returns an unsubscribe. */\n subscribe(handler: (url: string) => void): () => void;\n}\n\nexport interface DeepLinkManagerOptions {\n router: DeepLinkRouter;\n source: DeepLinkSource;\n}\n\nexport class DeepLinkManager {\n readonly onMatch = new Signal<DeepLinkMatch>();\n readonly onUnmatched = new Signal<string>();\n private readonly router: DeepLinkRouter;\n private readonly source: DeepLinkSource;\n private unsubscribe: (() => void) | null = null;\n private _current: DeepLinkMatch | null = null;\n\n constructor(options: DeepLinkManagerOptions) {\n this.router = options.router;\n this.source = options.source;\n }\n\n get current(): DeepLinkMatch | null {\n return this._current;\n }\n\n async start(): Promise<void> {\n if (this.unsubscribe) return;\n this.unsubscribe = this.source.subscribe((url) => this.handle(url));\n const initial = await Promise.resolve(this.source.getInitialUrl());\n if (initial) this.handle(initial);\n }\n\n stop(): void {\n if (this.unsubscribe) {\n this.unsubscribe();\n this.unsubscribe = null;\n }\n }\n\n handle(url: string): DeepLinkMatch | null {\n const match = this.router.match(url);\n if (!match) {\n this.onUnmatched.emit(url);\n return null;\n }\n this._current = match;\n this.onMatch.emit(match);\n return match;\n }\n}\n","import type { DeepLinkSource } from './manager.js';\n\n/**\n * In-memory source useful for tests and for host apps that want to push URLs\n * manually (e.g., from a notification handler).\n */\nexport function createMemorySource(initialUrl: string | null = null): DeepLinkSource & {\n push(url: string): void;\n} {\n let initial = initialUrl;\n const listeners = new Set<(url: string) => void>();\n return {\n getInitialUrl() {\n const v = initial;\n initial = null;\n return v;\n },\n subscribe(handler) {\n listeners.add(handler);\n return () => listeners.delete(handler);\n },\n push(url: string) {\n for (const l of listeners) l(url);\n },\n };\n}\n\n/**\n * Minimal shape of the globals a web browser exposes. Defined locally so\n * we don't pull in DOM lib types across the monorepo.\n */\ninterface WebWindowLike {\n location: { href: string };\n addEventListener: (type: string, listener: () => void) => void;\n removeEventListener: (type: string, listener: () => void) => void;\n}\n\n/**\n * Web `popstate` + `location.href` adapter. Call `notify(url)` after any\n * programmatic `history.pushState` if you want the manager to react.\n */\nexport function createWebSource(win: WebWindowLike): DeepLinkSource & {\n notify(url: string): void;\n} {\n const listeners = new Set<(url: string) => void>();\n const onPop = (): void => {\n const href = win.location.href;\n for (const l of listeners) l(href);\n };\n return {\n getInitialUrl() {\n return win.location.href;\n },\n subscribe(handler) {\n listeners.add(handler);\n win.addEventListener('popstate', onPop);\n return () => {\n listeners.delete(handler);\n win.removeEventListener('popstate', onPop);\n };\n },\n notify(url: string) {\n for (const l of listeners) l(url);\n },\n };\n}\n\n/**\n * Minimal shape of the React Native `Linking` module. Passing this lets the\n * host wire deep links on iOS/Android without this package depending on RN.\n */\nexport interface LinkingLike {\n getInitialURL(): Promise<string | null>;\n addEventListener(type: 'url', handler: (event: { url: string }) => void): { remove: () => void };\n}\n\nexport function createNativeSource(linking: LinkingLike): DeepLinkSource {\n return {\n getInitialUrl() {\n return linking.getInitialURL();\n },\n subscribe(handler) {\n const sub = linking.addEventListener('url', (e) => handler(e.url));\n return () => sub.remove();\n },\n };\n}\n"],"mappings":";AAgBO,SAAS,SAAS,KAA+B;AACtD,MAAI,OAAO,QAAQ,YAAY,IAAI,WAAW,EAAG,QAAO;AACxD,MAAI,OAAO;AACX,MAAI,SAAwB;AAC5B,MAAI,OAAsB;AAE1B,QAAM,YAAY,KAAK,QAAQ,KAAK;AACpC,MAAI,cAAc,IAAI;AACpB,aAAS,KAAK,MAAM,GAAG,SAAS;AAChC,WAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,UAAM,WAAW,KAAK,QAAQ,GAAG;AACjC,QAAI,aAAa,IAAI;AACnB,aAAO;AACP,aAAO;AAAA,IACT,OAAO;AACL,aAAO,KAAK,MAAM,GAAG,QAAQ;AAC7B,aAAO,KAAK,MAAM,QAAQ;AAAA,IAC5B;AAAA,EACF;AAGA,QAAM,UAAU,KAAK,QAAQ,GAAG;AAChC,MAAI,YAAY,GAAI,QAAO,KAAK,MAAM,GAAG,OAAO;AAEhD,MAAI,OAAO;AACX,MAAI,WAAW;AACf,QAAM,OAAO,KAAK,QAAQ,GAAG;AAC7B,MAAI,SAAS,IAAI;AACf,WAAO,KAAK,MAAM,GAAG,IAAI;AACzB,eAAW,KAAK,MAAM,OAAO,CAAC;AAAA,EAChC;AAEA,QAAM,WAAW,KACd,MAAM,GAAG,EACT,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,EAC1B,IAAI,UAAU;AACjB,QAAM,QAAgB,CAAC;AACvB,MAAI,SAAS,SAAS,GAAG;AACvB,eAAW,QAAQ,SAAS,MAAM,GAAG,GAAG;AACtC,UAAI,KAAK,WAAW,EAAG;AACvB,YAAM,KAAK,KAAK,QAAQ,GAAG;AA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B;AACd,aAAO,QAAQ,cAAc;AAAA,IAC/B;AAAA,IACA,UAAU,SAAS;AACjB,YAAM,MAAM,QAAQ,iBAAiB,OAAO,CAAC,MAAM,QAAQ,EAAE,GAAG,CAAC;AACjE,aAAO,MAAM,IAAI,OAAO;AAAA,IAC1B;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/manager.ts","../src/parse.ts","../src/router.ts","../src/sources.ts"],"sourcesContent":["import { Signal } from '@flare-engine/events';\nimport type { DeepLinkRouter } from './router.js';\nimport type { DeepLinkMatch } from './types.js';\n\n/**\n * Platform adapter that surfaces incoming URLs to the router. Web ships a\n * history-based adapter; RN consumers pass one that wires `Linking`.\n */\nexport interface DeepLinkSource {\n /** Current URL if the platform exposes one (e.g., `window.location.href`). */\n getInitialUrl(): Promise<string | null> | string | null;\n /** Register a handler for future URL updates; returns an unsubscribe. */\n subscribe(handler: (url: string) => void): () => void;\n}\n\nexport interface DeepLinkManagerOptions {\n router: DeepLinkRouter;\n source: DeepLinkSource;\n}\n\nexport class DeepLinkManager {\n readonly onMatch = new Signal<DeepLinkMatch>();\n readonly onUnmatched = new Signal<string>();\n private readonly router: DeepLinkRouter;\n private readonly source: DeepLinkSource;\n private unsubscribe: (() => void) | null = null;\n private _current: DeepLinkMatch | null = null;\n\n constructor(options: DeepLinkManagerOptions) {\n this.router = options.router;\n this.source = options.source;\n }\n\n get current(): DeepLinkMatch | null {\n return this._current;\n }\n\n async start(): Promise<void> {\n if (this.unsubscribe) return;\n this.unsubscribe = this.source.subscribe((url) => this.handle(url));\n const initial = await Promise.resolve(this.source.getInitialUrl());\n if (initial) this.handle(initial);\n }\n\n stop(): void {\n if (this.unsubscribe) {\n this.unsubscribe();\n this.unsubscribe = null;\n }\n }\n\n handle(url: string): DeepLinkMatch | null {\n const match = this.router.match(url);\n if (!match) {\n this.onUnmatched.emit(url);\n return null;\n }\n this._current = match;\n this.onMatch.emit(match);\n return match;\n }\n}\n","import type { Params } from './types.js';\n\n/**\n * Parse a URL into its path segments and query params.\n *\n * Host extraction (tri-state `host` field):\n * - `http`/`https`: authority (everything before the first `/?#`) → `host`.\n * - Any other scheme (`myapp://`, etc.): `host = ''`; the entire post-`://`\n * remainder is treated as the path.\n * - Relative (schemeless) URL: `host = null`.\n *\n * The http authority substring retains userinfo/port as-is\n * (`https://user:pass@h:8080/p` → `host = 'user:pass@h:8080'`); routing\n * only uses `segments` + `query`, so `host` is informational only.\n *\n * Non-goals: opaque `scheme:` forms without `//` are treated as a relative\n * path; backslash paths are not normalised (RN Linking semantics, not WHATWG).\n */\nexport interface ParsedUrl {\n scheme: string | null;\n /**\n * Tri-state:\n * - `string` (non-empty): http/https authority (e.g. `'example.com'`).\n * - `''` (empty string): custom scheme, authority-less (e.g. `myapp://`).\n * - `null`: relative URL with no scheme.\n */\n host: string | null;\n segments: string[];\n query: Params;\n}\n\nexport function parseUrl(url: string): ParsedUrl | null {\n if (typeof url !== 'string' || url.length === 0) return null;\n let rest = url;\n let scheme: string | null = null;\n let host: string | null = null;\n\n const schemeIdx = rest.indexOf('://');\n if (schemeIdx !== -1 && /^[a-zA-Z][a-zA-Z0-9+.-]*$/.test(rest.slice(0, schemeIdx))) {\n scheme = rest.slice(0, schemeIdx);\n rest = rest.slice(schemeIdx + 3);\n const lower = scheme.toLowerCase();\n if (lower === 'http' || lower === 'https') {\n // Universal link: the authority precedes the first /?# delimiter.\n const delimIdx = rest.search(/[/?#]/);\n if (delimIdx === -1) {\n host = rest;\n rest = '/';\n } else {\n host = rest.slice(0, delimIdx);\n rest = rest.slice(delimIdx);\n }\n } else {\n // Custom (RN Linking) scheme: no authority — everything after :// is the path.\n host = '';\n if (rest.length === 0 || rest[0] !== '/') rest = `/${rest}`;\n }\n }\n\n // Strip fragment.\n const hashIdx = rest.indexOf('#');\n if (hashIdx !== -1) rest = rest.slice(0, hashIdx);\n\n let path = rest;\n let queryStr = '';\n const qIdx = rest.indexOf('?');\n if (qIdx !== -1) {\n path = rest.slice(0, qIdx);\n queryStr = rest.slice(qIdx + 1);\n }\n\n const segments = path\n .split('/')\n .filter((s) => s.length > 0)\n .map(safeDecode);\n const query: Params = {};\n if (queryStr.length > 0) {\n for (const pair of queryStr.split('&')) {\n if (pair.length === 0) continue;\n const eq = pair.indexOf('=');\n const rawKey = eq === -1 ? pair : pair.slice(0, eq);\n const rawVal = eq === -1 ? '' : pair.slice(eq + 1);\n const key = safeDecode(rawKey);\n if (key.length === 0) continue;\n query[key] = safeDecode(rawVal);\n }\n }\n\n return { scheme, host, segments, query };\n}\n\nfunction safeDecode(s: string): string {\n try {\n return decodeURIComponent(s.replace(/\\+/g, '%20'));\n } catch {\n return s;\n }\n}\n","import { parseUrl } from './parse.js';\nimport type { DeepLinkMatch, Params } from './types.js';\n\n/**\n * Route pattern like `/bench/:id` or `/shop/:category/:item`. Segments\n * starting with `:` are captured; literal segments must match exactly.\n * The `*` segment matches the remainder of the path into a `rest` param.\n */\nexport interface RouteDefinition {\n pattern: string;\n scene: string;\n}\n\ninterface CompiledRoute {\n scene: string;\n segments: Array<{ literal?: string; param?: string; wildcard?: boolean }>;\n}\n\nexport class DeepLinkRouter {\n private routes: CompiledRoute[] = [];\n\n register(pattern: string, scene: string): this {\n this.routes.push({ scene, segments: compile(pattern) });\n return this;\n }\n\n registerAll(defs: readonly RouteDefinition[]): this {\n for (const def of defs) this.register(def.pattern, def.scene);\n return this;\n }\n\n match(url: string): DeepLinkMatch | null {\n const parsed = parseUrl(url);\n if (!parsed) return null;\n for (const route of this.routes) {\n const params = tryMatch(route, parsed.segments);\n if (!params) continue;\n const combined: Params = { ...parsed.query, ...params };\n return { scene: route.scene, params: combined, url };\n }\n return null;\n }\n}\n\nfunction compile(pattern: string): CompiledRoute['segments'] {\n return pattern\n .split('/')\n .filter((s) => s.length > 0)\n .map((s) => {\n if (s === '*') return { wildcard: true };\n if (s.startsWith(':')) return { param: s.slice(1) };\n return { literal: s };\n });\n}\n\nfunction tryMatch(route: CompiledRoute, segs: readonly string[]): Params | null {\n const out: Params = {};\n const segCount = route.segments.length;\n for (let i = 0; i < segCount; i++) {\n const def = route.segments[i];\n if (!def) return null;\n if (def.wildcard) {\n out.rest = segs.slice(i).join('/');\n return out;\n }\n const actual = segs[i];\n if (actual === undefined) return null;\n if (def.literal !== undefined) {\n if (def.literal !== actual) return null;\n } else if (def.param !== undefined) {\n out[def.param] = actual;\n }\n }\n if (segs.length !== segCount) return null;\n return out;\n}\n","import type { DeepLinkSource } from './manager.js';\n\n/**\n * In-memory source useful for tests and for host apps that want to push URLs\n * manually (e.g., from a notification handler).\n */\nexport function createMemorySource(initialUrl: string | null = null): DeepLinkSource & {\n push(url: string): void;\n} {\n let initial = initialUrl;\n const listeners = new Set<(url: string) => void>();\n return {\n getInitialUrl() {\n const v = initial;\n initial = null;\n return v;\n },\n subscribe(handler) {\n listeners.add(handler);\n return () => listeners.delete(handler);\n },\n push(url: string) {\n for (const l of listeners) l(url);\n },\n };\n}\n\n/**\n * Minimal shape of the globals a web browser exposes. Defined locally so\n * we don't pull in DOM lib types across the monorepo.\n */\ninterface WebWindowLike {\n location: { href: string };\n addEventListener: (type: string, listener: () => void) => void;\n removeEventListener: (type: string, listener: () => void) => void;\n}\n\n/**\n * Web `popstate` + `location.href` adapter. Call `notify(url)` after any\n * programmatic `history.pushState` if you want the manager to react.\n */\nexport function createWebSource(win: WebWindowLike): DeepLinkSource & {\n notify(url: string): void;\n} {\n const listeners = new Set<(url: string) => void>();\n const onPop = (): void => {\n const href = win.location.href;\n // Snapshot: a handler that (un)subscribes during dispatch must not change\n // who receives this dispatch.\n for (const l of [...listeners]) l(href);\n };\n return {\n getInitialUrl() {\n return win.location.href;\n },\n subscribe(handler) {\n listeners.add(handler);\n // `onPop` is one shared closure, so the DOM dedupes identical\n // (type, listener, capture) registrations — ref-count the DOM listener\n // (add on first subscriber, remove on last) so one unsubscribe can't\n // kill navigation for the remaining subscribers.\n if (listeners.size === 1) win.addEventListener('popstate', onPop);\n return () => {\n listeners.delete(handler);\n if (listeners.size === 0) win.removeEventListener('popstate', onPop);\n };\n },\n notify(url: string) {\n for (const l of [...listeners]) l(url);\n },\n };\n}\n\n/**\n * Minimal shape of the React Native `Linking` module. Passing this lets the\n * host wire deep links on iOS/Android without this package depending on RN.\n */\nexport interface LinkingLike {\n getInitialURL(): Promise<string | null>;\n addEventListener(type: 'url', handler: (event: { url: string }) => void): { remove: () => void };\n}\n\nexport function createNativeSource(linking: LinkingLike): DeepLinkSource {\n return {\n getInitialUrl() {\n return linking.getInitialURL();\n },\n subscribe(handler) {\n const sub = linking.addEventListener('url', (e) => handler(e.url));\n return () => sub.remove();\n },\n };\n}\n"],"mappings":";;AAoBA,IAAa,kBAAb,MAA6B;CAC3B,UAAmB,IAAI,OAAsB;CAC7C,cAAuB,IAAI,OAAe;CAC1C;CACA;CACA,cAA2C;CAC3C,WAAyC;CAEzC,YAAY,SAAiC;EAC3C,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;CACxB;CAEA,IAAI,UAAgC;EAClC,OAAO,KAAK;CACd;CAEA,MAAM,QAAuB;EAC3B,IAAI,KAAK,aAAa;EACtB,KAAK,cAAc,KAAK,OAAO,WAAW,QAAQ,KAAK,OAAO,GAAG,CAAC;EAClE,MAAM,UAAU,MAAM,QAAQ,QAAQ,KAAK,OAAO,cAAc,CAAC;EACjE,IAAI,SAAS,KAAK,OAAO,OAAO;CAClC;CAEA,OAAa;EACX,IAAI,KAAK,aAAa;GACpB,KAAK,YAAY;GACjB,KAAK,cAAc;EACrB;CACF;CAEA,OAAO,KAAmC;EACxC,MAAM,QAAQ,KAAK,OAAO,MAAM,GAAG;EACnC,IAAI,CAAC,OAAO;GACV,KAAK,YAAY,KAAK,GAAG;GACzB,OAAO;EACT;EACA,KAAK,WAAW;EAChB,KAAK,QAAQ,KAAK,KAAK;EACvB,OAAO;CACT;AACF;;;AC9BA,SAAgB,SAAS,KAA+B;CACtD,IAAI,OAAO,QAAQ,YAAY,I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;EACA,OAAO,KAAa;GAClB,KAAK,MAAM,KAAK,CAAC,GAAG,SAAS,GAAG,EAAE,GAAG;EACvC;CACF;AACF;AAWA,SAAgB,mBAAmB,SAAsC;CACvE,OAAO;EACL,gBAAgB;GACd,OAAO,QAAQ,cAAc;EAC/B;EACA,UAAU,SAAS;GACjB,MAAM,MAAM,QAAQ,iBAAiB,QAAQ,MAAM,QAAQ,EAAE,GAAG,CAAC;GACjE,aAAa,IAAI,OAAO;EAC1B;CACF;AACF"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@flare-engine/deep-links",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "URL → scene+params router with web history + native Linking adapters",
5
5
  "keywords": ["flare-engine", "deep-links", "router", "url"],
6
- "license": "MIT",
6
+ "license": "Apache-2.0",
7
7
  "author": "Grzegorz Otto",
8
8
  "homepage": "https://github.com/grzott/flare-engine#readme",
9
9
  "bugs": {
@@ -19,20 +19,28 @@
19
19
  "types": "dist/index.d.ts",
20
20
  "exports": {
21
21
  ".": {
22
- "types": "./dist/index.d.ts",
23
- "import": "./dist/index.mjs",
24
- "require": "./dist/index.js"
22
+ "import": {
23
+ "types": "./dist/index.d.mts",
24
+ "default": "./dist/index.mjs"
25
+ },
26
+ "require": {
27
+ "types": "./dist/index.d.ts",
28
+ "default": "./dist/index.js"
29
+ }
25
30
  }
26
31
  },
27
- "files": ["dist", "README.md", "LICENSE"],
32
+ "files": ["dist", "README.md", "LICENSE", "NOTICE"],
28
33
  "scripts": {
29
- "build": "tsup",
34
+ "build": "tsdown",
30
35
  "test": "bun test",
31
36
  "lint": "biome check src/",
32
37
  "typecheck": "tsc --noEmit"
33
38
  },
34
39
  "dependencies": {
35
- "@flare-engine/events": "^0.2.0"
40
+ "@flare-engine/events": "^0.3.0"
41
+ },
42
+ "engines": {
43
+ "node": ">=20"
36
44
  },
37
45
  "publishConfig": {
38
46
  "access": "restricted",