@flare-engine/deep-links 0.2.1 → 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.js CHANGED
@@ -1,237 +1,231 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _flare_engine_events = require("@flare-engine/events");
3
+ //#region src/manager.ts
4
+ var DeepLinkManager = class {
5
+ onMatch = new _flare_engine_events.Signal();
6
+ onUnmatched = new _flare_engine_events.Signal();
7
+ router;
8
+ source;
9
+ unsubscribe = null;
10
+ _current = null;
11
+ constructor(options) {
12
+ this.router = options.router;
13
+ this.source = options.source;
14
+ }
15
+ get current() {
16
+ return this._current;
17
+ }
18
+ async start() {
19
+ if (this.unsubscribe) return;
20
+ this.unsubscribe = this.source.subscribe((url) => this.handle(url));
21
+ const initial = await Promise.resolve(this.source.getInitialUrl());
22
+ if (initial) this.handle(initial);
23
+ }
24
+ stop() {
25
+ if (this.unsubscribe) {
26
+ this.unsubscribe();
27
+ this.unsubscribe = null;
28
+ }
29
+ }
30
+ handle(url) {
31
+ const match = this.router.match(url);
32
+ if (!match) {
33
+ this.onUnmatched.emit(url);
34
+ return null;
35
+ }
36
+ this._current = match;
37
+ this.onMatch.emit(match);
38
+ return match;
39
+ }
17
40
  };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- DeepLinkManager: () => DeepLinkManager,
24
- DeepLinkRouter: () => DeepLinkRouter,
25
- createMemorySource: () => createMemorySource,
26
- createNativeSource: () => createNativeSource,
27
- createWebSource: () => createWebSource,
28
- parseUrl: () => parseUrl
29
- });
30
- module.exports = __toCommonJS(index_exports);
31
-
32
- // src/parse.ts
41
+ //#endregion
42
+ //#region src/parse.ts
33
43
  function parseUrl(url) {
34
- if (typeof url !== "string" || url.length === 0) return null;
35
- let rest = url;
36
- let scheme = null;
37
- let host = null;
38
- const schemeIdx = rest.indexOf("://");
39
- if (schemeIdx !== -1) {
40
- scheme = rest.slice(0, schemeIdx);
41
- rest = rest.slice(schemeIdx + 3);
42
- const slashIdx = rest.indexOf("/");
43
- if (slashIdx === -1) {
44
- host = rest;
45
- rest = "/";
46
- } else {
47
- host = rest.slice(0, slashIdx);
48
- rest = rest.slice(slashIdx);
49
- }
50
- }
51
- const hashIdx = rest.indexOf("#");
52
- if (hashIdx !== -1) rest = rest.slice(0, hashIdx);
53
- let path = rest;
54
- let queryStr = "";
55
- const qIdx = rest.indexOf("?");
56
- if (qIdx !== -1) {
57
- path = rest.slice(0, qIdx);
58
- queryStr = rest.slice(qIdx + 1);
59
- }
60
- const segments = path.split("/").filter((s) => s.length > 0).map(safeDecode);
61
- const query = {};
62
- if (queryStr.length > 0) {
63
- for (const pair of queryStr.split("&")) {
64
- if (pair.length === 0) continue;
65
- const eq = pair.indexOf("=");
66
- const rawKey = eq === -1 ? pair : pair.slice(0, eq);
67
- const rawVal = eq === -1 ? "" : pair.slice(eq + 1);
68
- const key = safeDecode(rawKey);
69
- if (key.length === 0) continue;
70
- query[key] = safeDecode(rawVal);
71
- }
72
- }
73
- return { scheme, host, segments, query };
44
+ if (typeof url !== "string" || url.length === 0) return null;
45
+ let rest = url;
46
+ let scheme = null;
47
+ let host = null;
48
+ const schemeIdx = rest.indexOf("://");
49
+ if (schemeIdx !== -1 && /^[a-zA-Z][a-zA-Z0-9+.-]*$/.test(rest.slice(0, schemeIdx))) {
50
+ scheme = rest.slice(0, schemeIdx);
51
+ rest = rest.slice(schemeIdx + 3);
52
+ const lower = scheme.toLowerCase();
53
+ if (lower === "http" || lower === "https") {
54
+ const delimIdx = rest.search(/[/?#]/);
55
+ if (delimIdx === -1) {
56
+ host = rest;
57
+ rest = "/";
58
+ } else {
59
+ host = rest.slice(0, delimIdx);
60
+ rest = rest.slice(delimIdx);
61
+ }
62
+ } else {
63
+ host = "";
64
+ if (rest.length === 0 || rest[0] !== "/") rest = `/${rest}`;
65
+ }
66
+ }
67
+ const hashIdx = rest.indexOf("#");
68
+ if (hashIdx !== -1) rest = rest.slice(0, hashIdx);
69
+ let path = rest;
70
+ let queryStr = "";
71
+ const qIdx = rest.indexOf("?");
72
+ if (qIdx !== -1) {
73
+ path = rest.slice(0, qIdx);
74
+ queryStr = rest.slice(qIdx + 1);
75
+ }
76
+ const segments = path.split("/").filter((s) => s.length > 0).map(safeDecode);
77
+ const query = {};
78
+ if (queryStr.length > 0) for (const pair of queryStr.split("&")) {
79
+ if (pair.length === 0) continue;
80
+ const eq = pair.indexOf("=");
81
+ const rawKey = eq === -1 ? pair : pair.slice(0, eq);
82
+ const rawVal = eq === -1 ? "" : pair.slice(eq + 1);
83
+ const key = safeDecode(rawKey);
84
+ if (key.length === 0) continue;
85
+ query[key] = safeDecode(rawVal);
86
+ }
87
+ return {
88
+ scheme,
89
+ host,
90
+ segments,
91
+ query
92
+ };
74
93
  }
75
94
  function safeDecode(s) {
76
- try {
77
- return decodeURIComponent(s.replace(/\+/g, "%20"));
78
- } catch {
79
- return s;
80
- }
95
+ try {
96
+ return decodeURIComponent(s.replace(/\+/g, "%20"));
97
+ } catch {
98
+ return s;
99
+ }
81
100
  }
82
-
83
- // src/router.ts
101
+ //#endregion
102
+ //#region src/router.ts
84
103
  var DeepLinkRouter = class {
85
- routes = [];
86
- register(pattern, scene) {
87
- this.routes.push({ scene, segments: compile(pattern) });
88
- return this;
89
- }
90
- registerAll(defs) {
91
- for (const def of defs) this.register(def.pattern, def.scene);
92
- return this;
93
- }
94
- match(url) {
95
- const parsed = parseUrl(url);
96
- if (!parsed) return null;
97
- for (const route of this.routes) {
98
- const params = tryMatch(route, parsed.segments);
99
- if (!params) continue;
100
- const combined = { ...parsed.query, ...params };
101
- return { scene: route.scene, params: combined, url };
102
- }
103
- return null;
104
- }
104
+ routes = [];
105
+ register(pattern, scene) {
106
+ this.routes.push({
107
+ scene,
108
+ segments: compile(pattern)
109
+ });
110
+ return this;
111
+ }
112
+ registerAll(defs) {
113
+ for (const def of defs) this.register(def.pattern, def.scene);
114
+ return this;
115
+ }
116
+ match(url) {
117
+ const parsed = parseUrl(url);
118
+ if (!parsed) return null;
119
+ for (const route of this.routes) {
120
+ const params = tryMatch(route, parsed.segments);
121
+ if (!params) continue;
122
+ const combined = {
123
+ ...parsed.query,
124
+ ...params
125
+ };
126
+ return {
127
+ scene: route.scene,
128
+ params: combined,
129
+ url
130
+ };
131
+ }
132
+ return null;
133
+ }
105
134
  };
106
135
  function compile(pattern) {
107
- return pattern.split("/").filter((s) => s.length > 0).map((s) => {
108
- if (s === "*") return { wildcard: true };
109
- if (s.startsWith(":")) return { param: s.slice(1) };
110
- return { literal: s };
111
- });
136
+ return pattern.split("/").filter((s) => s.length > 0).map((s) => {
137
+ if (s === "*") return { wildcard: true };
138
+ if (s.startsWith(":")) return { param: s.slice(1) };
139
+ return { literal: s };
140
+ });
112
141
  }
113
142
  function tryMatch(route, segs) {
114
- const out = {};
115
- const segCount = route.segments.length;
116
- for (let i = 0; i < segCount; i++) {
117
- const def = route.segments[i];
118
- if (!def) return null;
119
- if (def.wildcard) {
120
- out.rest = segs.slice(i).join("/");
121
- return out;
122
- }
123
- const actual = segs[i];
124
- if (actual === void 0) return null;
125
- if (def.literal !== void 0) {
126
- if (def.literal !== actual) return null;
127
- } else if (def.param !== void 0) {
128
- out[def.param] = actual;
129
- }
130
- }
131
- if (segs.length !== segCount) return null;
132
- return out;
143
+ const out = {};
144
+ const segCount = route.segments.length;
145
+ for (let i = 0; i < segCount; i++) {
146
+ const def = route.segments[i];
147
+ if (!def) return null;
148
+ if (def.wildcard) {
149
+ out.rest = segs.slice(i).join("/");
150
+ return out;
151
+ }
152
+ const actual = segs[i];
153
+ if (actual === void 0) return null;
154
+ if (def.literal !== void 0) {
155
+ if (def.literal !== actual) return null;
156
+ } else if (def.param !== void 0) out[def.param] = actual;
157
+ }
158
+ if (segs.length !== segCount) return null;
159
+ return out;
133
160
  }
134
-
135
- // src/manager.ts
136
- var import_events = require("@flare-engine/events");
137
- var DeepLinkManager = class {
138
- onMatch = new import_events.Signal();
139
- onUnmatched = new import_events.Signal();
140
- router;
141
- source;
142
- unsubscribe = null;
143
- _current = null;
144
- constructor(options) {
145
- this.router = options.router;
146
- this.source = options.source;
147
- }
148
- get current() {
149
- return this._current;
150
- }
151
- async start() {
152
- if (this.unsubscribe) return;
153
- this.unsubscribe = this.source.subscribe((url) => this.handle(url));
154
- const initial = await Promise.resolve(this.source.getInitialUrl());
155
- if (initial) this.handle(initial);
156
- }
157
- stop() {
158
- if (this.unsubscribe) {
159
- this.unsubscribe();
160
- this.unsubscribe = null;
161
- }
162
- }
163
- handle(url) {
164
- const match = this.router.match(url);
165
- if (!match) {
166
- this.onUnmatched.emit(url);
167
- return null;
168
- }
169
- this._current = match;
170
- this.onMatch.emit(match);
171
- return match;
172
- }
173
- };
174
-
175
- // src/sources.ts
161
+ //#endregion
162
+ //#region src/sources.ts
163
+ /**
164
+ * In-memory source useful for tests and for host apps that want to push URLs
165
+ * manually (e.g., from a notification handler).
166
+ */
176
167
  function createMemorySource(initialUrl = null) {
177
- let initial = initialUrl;
178
- const listeners = /* @__PURE__ */ new Set();
179
- return {
180
- getInitialUrl() {
181
- const v = initial;
182
- initial = null;
183
- return v;
184
- },
185
- subscribe(handler) {
186
- listeners.add(handler);
187
- return () => listeners.delete(handler);
188
- },
189
- push(url) {
190
- for (const l of listeners) l(url);
191
- }
192
- };
168
+ let initial = initialUrl;
169
+ const listeners = /* @__PURE__ */ new Set();
170
+ return {
171
+ getInitialUrl() {
172
+ const v = initial;
173
+ initial = null;
174
+ return v;
175
+ },
176
+ subscribe(handler) {
177
+ listeners.add(handler);
178
+ return () => listeners.delete(handler);
179
+ },
180
+ push(url) {
181
+ for (const l of listeners) l(url);
182
+ }
183
+ };
193
184
  }
185
+ /**
186
+ * Web `popstate` + `location.href` adapter. Call `notify(url)` after any
187
+ * programmatic `history.pushState` if you want the manager to react.
188
+ */
194
189
  function createWebSource(win) {
195
- const listeners = /* @__PURE__ */ new Set();
196
- const onPop = () => {
197
- const href = win.location.href;
198
- for (const l of listeners) l(href);
199
- };
200
- return {
201
- getInitialUrl() {
202
- return win.location.href;
203
- },
204
- subscribe(handler) {
205
- listeners.add(handler);
206
- win.addEventListener("popstate", onPop);
207
- return () => {
208
- listeners.delete(handler);
209
- win.removeEventListener("popstate", onPop);
210
- };
211
- },
212
- notify(url) {
213
- for (const l of listeners) l(url);
214
- }
215
- };
190
+ const listeners = /* @__PURE__ */ new Set();
191
+ const onPop = () => {
192
+ const href = win.location.href;
193
+ for (const l of [...listeners]) l(href);
194
+ };
195
+ return {
196
+ getInitialUrl() {
197
+ return win.location.href;
198
+ },
199
+ subscribe(handler) {
200
+ listeners.add(handler);
201
+ if (listeners.size === 1) win.addEventListener("popstate", onPop);
202
+ return () => {
203
+ listeners.delete(handler);
204
+ if (listeners.size === 0) win.removeEventListener("popstate", onPop);
205
+ };
206
+ },
207
+ notify(url) {
208
+ for (const l of [...listeners]) l(url);
209
+ }
210
+ };
216
211
  }
217
212
  function createNativeSource(linking) {
218
- return {
219
- getInitialUrl() {
220
- return linking.getInitialURL();
221
- },
222
- subscribe(handler) {
223
- const sub = linking.addEventListener("url", (e) => handler(e.url));
224
- return () => sub.remove();
225
- }
226
- };
213
+ return {
214
+ getInitialUrl() {
215
+ return linking.getInitialURL();
216
+ },
217
+ subscribe(handler) {
218
+ const sub = linking.addEventListener("url", (e) => handler(e.url));
219
+ return () => sub.remove();
220
+ }
221
+ };
227
222
  }
228
- // Annotate the CommonJS export names for ESM import in node:
229
- 0 && (module.exports = {
230
- DeepLinkManager,
231
- DeepLinkRouter,
232
- createMemorySource,
233
- createNativeSource,
234
- createWebSource,
235
- parseUrl
236
- });
223
+ //#endregion
224
+ exports.DeepLinkManager = DeepLinkManager;
225
+ exports.DeepLinkRouter = DeepLinkRouter;
226
+ exports.createMemorySource = createMemorySource;
227
+ exports.createNativeSource = createNativeSource;
228
+ exports.createWebSource = createWebSource;
229
+ exports.parseUrl = parseUrl;
230
+
237
231
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/parse.ts","../src/router.ts","../src/manager.ts","../src/sources.ts"],"sourcesContent":["export type { DeepLinkMatch, Params, ParamValue } from './types.js';\nexport { parseUrl, type ParsedUrl } from './parse.js';\nexport { DeepLinkRouter, type RouteDefinition } from './router.js';\nexport {\n DeepLinkManager,\n type DeepLinkManagerOptions,\n type DeepLinkSource,\n} from './manager.js';\nexport {\n createMemorySource,\n createWebSource,\n createNativeSource,\n type LinkingLike,\n} from './sources.js';\n","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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACgBO,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;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B,SAAsC;AACvE,SAAO;AAAA,IACL,gBAAgB;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.js","names":["Signal"],"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,IAAIA,qBAAAA,OAAsB;CAC7C,cAAuB,IAAIA,qBAAAA,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;;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