@flare-engine/deep-links 0.4.5 → 0.4.7
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.d.mts +7 -17
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +7 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Signal } from "@flare-engine/events";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
2
|
type ParamValue = string;
|
|
4
3
|
type Params = Record<string, ParamValue>;
|
|
5
4
|
interface DeepLinkMatch {
|
|
@@ -10,8 +9,6 @@ interface DeepLinkMatch {
|
|
|
10
9
|
/** Original URL the match was performed against. */
|
|
11
10
|
url: string;
|
|
12
11
|
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/router.d.ts
|
|
15
12
|
/**
|
|
16
13
|
* Route pattern like `/bench/:id` or `/shop/:category/:item`. Segments
|
|
17
14
|
* starting with `:` are captured; literal segments must match exactly.
|
|
@@ -21,14 +18,12 @@ interface RouteDefinition {
|
|
|
21
18
|
pattern: string;
|
|
22
19
|
scene: string;
|
|
23
20
|
}
|
|
24
|
-
declare class DeepLinkRouter {
|
|
21
|
+
export declare class DeepLinkRouter {
|
|
25
22
|
private routes;
|
|
26
23
|
register(pattern: string, scene: string): this;
|
|
27
24
|
registerAll(defs: readonly RouteDefinition[]): this;
|
|
28
25
|
match(url: string): DeepLinkMatch | null;
|
|
29
26
|
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/manager.d.ts
|
|
32
27
|
/**
|
|
33
28
|
* Platform adapter that surfaces incoming URLs to the router. Web ships a
|
|
34
29
|
* history-based adapter; RN consumers pass one that wires `Linking`.
|
|
@@ -43,7 +38,7 @@ interface DeepLinkManagerOptions {
|
|
|
43
38
|
router: DeepLinkRouter;
|
|
44
39
|
source: DeepLinkSource;
|
|
45
40
|
}
|
|
46
|
-
declare class DeepLinkManager {
|
|
41
|
+
export declare class DeepLinkManager {
|
|
47
42
|
readonly onMatch: Signal<DeepLinkMatch>;
|
|
48
43
|
readonly onUnmatched: Signal<string>;
|
|
49
44
|
private readonly router;
|
|
@@ -56,8 +51,6 @@ declare class DeepLinkManager {
|
|
|
56
51
|
stop(): void;
|
|
57
52
|
handle(url: string): DeepLinkMatch | null;
|
|
58
53
|
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/parse.d.ts
|
|
61
54
|
/**
|
|
62
55
|
* Parse a URL into its path segments and query params.
|
|
63
56
|
*
|
|
@@ -86,14 +79,12 @@ interface ParsedUrl {
|
|
|
86
79
|
segments: string[];
|
|
87
80
|
query: Params;
|
|
88
81
|
}
|
|
89
|
-
declare function parseUrl(url: string): ParsedUrl | null;
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/sources.d.ts
|
|
82
|
+
export declare function parseUrl(url: string): ParsedUrl | null;
|
|
92
83
|
/**
|
|
93
84
|
* In-memory source useful for tests and for host apps that want to push URLs
|
|
94
85
|
* manually (e.g., from a notification handler).
|
|
95
86
|
*/
|
|
96
|
-
declare function createMemorySource(initialUrl?: string | null): DeepLinkSource & {
|
|
87
|
+
export declare function createMemorySource(initialUrl?: string | null): DeepLinkSource & {
|
|
97
88
|
push(url: string): void;
|
|
98
89
|
};
|
|
99
90
|
/**
|
|
@@ -111,7 +102,7 @@ interface WebWindowLike {
|
|
|
111
102
|
* Web `popstate` + `location.href` adapter. Call `notify(url)` after any
|
|
112
103
|
* programmatic `history.pushState` if you want the manager to react.
|
|
113
104
|
*/
|
|
114
|
-
declare function createWebSource(win: WebWindowLike): DeepLinkSource & {
|
|
105
|
+
export declare function createWebSource(win: WebWindowLike): DeepLinkSource & {
|
|
115
106
|
notify(url: string): void;
|
|
116
107
|
};
|
|
117
108
|
/**
|
|
@@ -126,7 +117,6 @@ interface LinkingLike {
|
|
|
126
117
|
remove: () => void;
|
|
127
118
|
};
|
|
128
119
|
}
|
|
129
|
-
declare function createNativeSource(linking: LinkingLike): DeepLinkSource;
|
|
130
|
-
|
|
131
|
-
export { DeepLinkManager, type DeepLinkManagerOptions, type DeepLinkMatch, DeepLinkRouter, type DeepLinkSource, type LinkingLike, type ParamValue, type Params, type ParsedUrl, type RouteDefinition, createMemorySource, createNativeSource, createWebSource, parseUrl };
|
|
120
|
+
export declare function createNativeSource(linking: LinkingLike): DeepLinkSource;
|
|
121
|
+
export type { DeepLinkManagerOptions, DeepLinkMatch, DeepLinkSource, LinkingLike, ParamValue, Params, ParsedUrl, RouteDefinition };
|
|
132
122
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/router.ts","../src/manager.ts","../src/parse.ts","../src/sources.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/types.ts","../src/router.ts","../src/manager.ts","../src/parse.ts","../src/sources.ts"],"mappings":";KAAY;KACA,SAAS,eAAe;UAEnB;;EAEf;;EAEA,QAAQ;;EAER;;;;;;;UCDe;EACf;EACA;;qBAQW;UACH;EAER,SAAS,iBAAiB;EAK1B,YAAY,eAAe;EAK3B,MAAM,cAAc;;;;;;UCvBL;;EAEf,iBAAiB;;EAEjB,UAAU,UAAU;;UAGL;EACf,QAAQ;EACR,QAAQ;;qBAGG;WACF,SAAO,OAAA;WACP,aAAW;mBACH;mBACA;UACT;UACA;EAEI,YAAA,SAAS;MAKjB,WAAW;EAIT,SAAS;EAOf;EAOA,OAAO,cAAc;;;;;;;;;;;;;;;;;;UCjCN;EACf;;;;;;;EAOA;EACA;EACA,OAAO;;wBAGO,SAAS,cAAc;;;;;wBCzBvB,mBAAmB,6BAAmC;EACpE,KAAK;;;;;;UAwBG;EACR;IAAY;;EACZ,mBAAmB,cAAc;EACjC,sBAAsB,cAAc;;;;;;wBAOtB,gBAAgB,KAAK,gBAAgB;EACnD,OAAO;;;;;;UAmCQ;EACf,iBAAiB;EACjB,iBAAiB,aAAa,UAAU;IAAS;;IAA2B;;;wBAG9D,mBAAmB,SAAS,cAAc"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Signal } from "@flare-engine/events";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
2
|
type ParamValue = string;
|
|
4
3
|
type Params = Record<string, ParamValue>;
|
|
5
4
|
interface DeepLinkMatch {
|
|
@@ -10,8 +9,6 @@ interface DeepLinkMatch {
|
|
|
10
9
|
/** Original URL the match was performed against. */
|
|
11
10
|
url: string;
|
|
12
11
|
}
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/router.d.ts
|
|
15
12
|
/**
|
|
16
13
|
* Route pattern like `/bench/:id` or `/shop/:category/:item`. Segments
|
|
17
14
|
* starting with `:` are captured; literal segments must match exactly.
|
|
@@ -21,14 +18,12 @@ interface RouteDefinition {
|
|
|
21
18
|
pattern: string;
|
|
22
19
|
scene: string;
|
|
23
20
|
}
|
|
24
|
-
declare class DeepLinkRouter {
|
|
21
|
+
export declare class DeepLinkRouter {
|
|
25
22
|
private routes;
|
|
26
23
|
register(pattern: string, scene: string): this;
|
|
27
24
|
registerAll(defs: readonly RouteDefinition[]): this;
|
|
28
25
|
match(url: string): DeepLinkMatch | null;
|
|
29
26
|
}
|
|
30
|
-
//#endregion
|
|
31
|
-
//#region src/manager.d.ts
|
|
32
27
|
/**
|
|
33
28
|
* Platform adapter that surfaces incoming URLs to the router. Web ships a
|
|
34
29
|
* history-based adapter; RN consumers pass one that wires `Linking`.
|
|
@@ -43,7 +38,7 @@ interface DeepLinkManagerOptions {
|
|
|
43
38
|
router: DeepLinkRouter;
|
|
44
39
|
source: DeepLinkSource;
|
|
45
40
|
}
|
|
46
|
-
declare class DeepLinkManager {
|
|
41
|
+
export declare class DeepLinkManager {
|
|
47
42
|
readonly onMatch: Signal<DeepLinkMatch>;
|
|
48
43
|
readonly onUnmatched: Signal<string>;
|
|
49
44
|
private readonly router;
|
|
@@ -56,8 +51,6 @@ declare class DeepLinkManager {
|
|
|
56
51
|
stop(): void;
|
|
57
52
|
handle(url: string): DeepLinkMatch | null;
|
|
58
53
|
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/parse.d.ts
|
|
61
54
|
/**
|
|
62
55
|
* Parse a URL into its path segments and query params.
|
|
63
56
|
*
|
|
@@ -86,14 +79,12 @@ interface ParsedUrl {
|
|
|
86
79
|
segments: string[];
|
|
87
80
|
query: Params;
|
|
88
81
|
}
|
|
89
|
-
declare function parseUrl(url: string): ParsedUrl | null;
|
|
90
|
-
//#endregion
|
|
91
|
-
//#region src/sources.d.ts
|
|
82
|
+
export declare function parseUrl(url: string): ParsedUrl | null;
|
|
92
83
|
/**
|
|
93
84
|
* In-memory source useful for tests and for host apps that want to push URLs
|
|
94
85
|
* manually (e.g., from a notification handler).
|
|
95
86
|
*/
|
|
96
|
-
declare function createMemorySource(initialUrl?: string | null): DeepLinkSource & {
|
|
87
|
+
export declare function createMemorySource(initialUrl?: string | null): DeepLinkSource & {
|
|
97
88
|
push(url: string): void;
|
|
98
89
|
};
|
|
99
90
|
/**
|
|
@@ -111,7 +102,7 @@ interface WebWindowLike {
|
|
|
111
102
|
* Web `popstate` + `location.href` adapter. Call `notify(url)` after any
|
|
112
103
|
* programmatic `history.pushState` if you want the manager to react.
|
|
113
104
|
*/
|
|
114
|
-
declare function createWebSource(win: WebWindowLike): DeepLinkSource & {
|
|
105
|
+
export declare function createWebSource(win: WebWindowLike): DeepLinkSource & {
|
|
115
106
|
notify(url: string): void;
|
|
116
107
|
};
|
|
117
108
|
/**
|
|
@@ -126,7 +117,6 @@ interface LinkingLike {
|
|
|
126
117
|
remove: () => void;
|
|
127
118
|
};
|
|
128
119
|
}
|
|
129
|
-
declare function createNativeSource(linking: LinkingLike): DeepLinkSource;
|
|
130
|
-
|
|
131
|
-
export { DeepLinkManager, type DeepLinkManagerOptions, type DeepLinkMatch, DeepLinkRouter, type DeepLinkSource, type LinkingLike, type ParamValue, type Params, type ParsedUrl, type RouteDefinition, createMemorySource, createNativeSource, createWebSource, parseUrl };
|
|
120
|
+
export declare function createNativeSource(linking: LinkingLike): DeepLinkSource;
|
|
121
|
+
export type { DeepLinkManagerOptions, DeepLinkMatch, DeepLinkSource, LinkingLike, ParamValue, Params, ParsedUrl, RouteDefinition };
|
|
132
122
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/router.ts","../src/manager.ts","../src/parse.ts","../src/sources.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/types.ts","../src/router.ts","../src/manager.ts","../src/parse.ts","../src/sources.ts"],"mappings":";KAAY;KACA,SAAS,eAAe;UAEnB;;EAEf;;EAEA,QAAQ;;EAER;;;;;;;UCDe;EACf;EACA;;qBAQW;UACH;EAER,SAAS,iBAAiB;EAK1B,YAAY,eAAe;EAK3B,MAAM,cAAc;;;;;;UCvBL;;EAEf,iBAAiB;;EAEjB,UAAU,UAAU;;UAGL;EACf,QAAQ;EACR,QAAQ;;qBAGG;WACF,SAAO,OAAA;WACP,aAAW;mBACH;mBACA;UACT;UACA;EAEI,YAAA,SAAS;MAKjB,WAAW;EAIT,SAAS;EAOf;EAOA,OAAO,cAAc;;;;;;;;;;;;;;;;;;UCjCN;EACf;;;;;;;EAOA;EACA;EACA,OAAO;;wBAGO,SAAS,cAAc;;;;;wBCzBvB,mBAAmB,6BAAmC;EACpE,KAAK;;;;;;UAwBG;EACR;IAAY;;EACZ,mBAAmB,cAAc;EACjC,sBAAsB,cAAc;;;;;;wBAOtB,gBAAgB,KAAK,gBAAgB;EACnD,OAAO;;;;;;UAmCQ;EACf,iBAAiB;EACjB,iBAAiB,aAAa,UAAU;IAAS;;IAA2B;;;wBAG9D,mBAAmB,SAAS,cAAc"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
let _flare_engine_events = require("@flare-engine/events");
|
|
3
|
-
|
|
3
|
+
// src/manager.ts
|
|
4
4
|
var DeepLinkManager = class {
|
|
5
5
|
onMatch = new _flare_engine_events.Signal();
|
|
6
6
|
onUnmatched = new _flare_engine_events.Signal();
|
|
@@ -38,8 +38,7 @@ var DeepLinkManager = class {
|
|
|
38
38
|
return match;
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
-
|
|
42
|
-
//#region src/parse.ts
|
|
41
|
+
// src/parse.ts
|
|
43
42
|
function parseUrl(url) {
|
|
44
43
|
if (typeof url !== "string" || url.length === 0) return null;
|
|
45
44
|
let rest = url;
|
|
@@ -98,8 +97,7 @@ function safeDecode(s) {
|
|
|
98
97
|
return s;
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
|
|
102
|
-
//#region src/router.ts
|
|
100
|
+
// src/router.ts
|
|
103
101
|
var DeepLinkRouter = class {
|
|
104
102
|
routes = [];
|
|
105
103
|
register(pattern, scene) {
|
|
@@ -155,8 +153,7 @@ function tryMatch(route, segs) {
|
|
|
155
153
|
if (segs.length !== segCount) return null;
|
|
156
154
|
return out;
|
|
157
155
|
}
|
|
158
|
-
|
|
159
|
-
//#region src/sources.ts
|
|
156
|
+
// src/sources.ts
|
|
160
157
|
/**
|
|
161
158
|
* In-memory source useful for tests and for host apps that want to push URLs
|
|
162
159
|
* manually (e.g., from a notification handler).
|
|
@@ -217,7 +214,6 @@ function createNativeSource(linking) {
|
|
|
217
214
|
}
|
|
218
215
|
};
|
|
219
216
|
}
|
|
220
|
-
//#endregion
|
|
221
217
|
exports.DeepLinkManager = DeepLinkManager;
|
|
222
218
|
exports.DeepLinkRouter = DeepLinkRouter;
|
|
223
219
|
exports.createMemorySource = createMemorySource;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 // Null-prototype: query keys come straight from the URL, so an object literal\n // would answer `params.constructor` / `params.toString` with an inherited\n // value for a link that never carried that key.\n const query = Object.create(null) as 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 // Null-prototype, and Object.assign rather than a spread literal: a\n // spread would rebuild the object with Object.prototype and undo\n // parse.ts's guard.\n const combined = Object.assign(Object.create(null), parsed.query, params) as 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 // Path params (`:id`) are as URL-controlled as the query string.\n const out = Object.create(null) as 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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,IAAI,OAAO;GAKrB,IAAI,UAAU,SAAS,GAAG,IAAI,iBAAiB,YAAY,KAAK;GAChE,aAAa;IACX,UAAU,OAAO,OAAO;IACxB,IAAI,UAAU,SAAS,GAAG,IAAI,oBAAoB,YAAY,KAAK;GACrE;EACF;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"}
|
|
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 // Null-prototype: query keys come straight from the URL, so an object literal\n // would answer `params.constructor` / `params.toString` with an inherited\n // value for a link that never carried that key.\n const query = Object.create(null) as 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 // Null-prototype, and Object.assign rather than a spread literal: a\n // spread would rebuild the object with Object.prototype and undo\n // parse.ts's guard.\n const combined = Object.assign(Object.create(null), parsed.query, params) as 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 // Path params (`:id`) are as URL-controlled as the query string.\n const out = Object.create(null) as 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,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IAAI,OAAO;GACrB,aAAa,UAAU,OAAO,OAAO;EACvC;EACA,KAAK,KAAa;GAChB,KAAK,MAAM,KAAK,WAAW,EAAE,GAAG;EAClC;CACF;AACF;;;;;AAgBA,SAAgB,gBAAgB,KAE9B;CACA,MAAM,4BAAY,IAAI,IAA2B;CACjD,MAAM,cAAoB;EACxB,MAAM,OAAO,IAAI,SAAS;EAG1B,KAAK,MAAM,KAAK,CAAC,GAAG,SAAS,GAAG,EAAE,IAAI;CACxC;CACA,OAAO;EACL,gBAAgB;GACd,OAAO,IAAI,SAAS;EACtB;EACA,UAAU,SAAS;GACjB,UAAU,IAAI,OAAO;GAKrB,IAAI,UAAU,SAAS,GAAG,IAAI,iBAAiB,YAAY,KAAK;GAChE,aAAa;IACX,UAAU,OAAO,OAAO;IACxB,IAAI,UAAU,SAAS,GAAG,IAAI,oBAAoB,YAAY,KAAK;GACrE;EACF;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/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signal } from "@flare-engine/events";
|
|
2
|
-
|
|
2
|
+
// src/manager.ts
|
|
3
3
|
var DeepLinkManager = class {
|
|
4
4
|
onMatch = new Signal();
|
|
5
5
|
onUnmatched = new Signal();
|
|
@@ -37,8 +37,7 @@ var DeepLinkManager = class {
|
|
|
37
37
|
return match;
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
|
-
|
|
41
|
-
//#region src/parse.ts
|
|
40
|
+
// src/parse.ts
|
|
42
41
|
function parseUrl(url) {
|
|
43
42
|
if (typeof url !== "string" || url.length === 0) return null;
|
|
44
43
|
let rest = url;
|
|
@@ -97,8 +96,7 @@ function safeDecode(s) {
|
|
|
97
96
|
return s;
|
|
98
97
|
}
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
//#region src/router.ts
|
|
99
|
+
// src/router.ts
|
|
102
100
|
var DeepLinkRouter = class {
|
|
103
101
|
routes = [];
|
|
104
102
|
register(pattern, scene) {
|
|
@@ -154,8 +152,7 @@ function tryMatch(route, segs) {
|
|
|
154
152
|
if (segs.length !== segCount) return null;
|
|
155
153
|
return out;
|
|
156
154
|
}
|
|
157
|
-
|
|
158
|
-
//#region src/sources.ts
|
|
155
|
+
// src/sources.ts
|
|
159
156
|
/**
|
|
160
157
|
* In-memory source useful for tests and for host apps that want to push URLs
|
|
161
158
|
* manually (e.g., from a notification handler).
|
|
@@ -216,7 +213,6 @@ function createNativeSource(linking) {
|
|
|
216
213
|
}
|
|
217
214
|
};
|
|
218
215
|
}
|
|
219
|
-
//#endregion
|
|
220
216
|
export { DeepLinkManager, DeepLinkRouter, createMemorySource, createNativeSource, createWebSource, parseUrl };
|
|
221
217
|
|
|
222
218
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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 // Null-prototype: query keys come straight from the URL, so an object literal\n // would answer `params.constructor` / `params.toString` with an inherited\n // value for a link that never carried that key.\n const query = Object.create(null) as 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 // Null-prototype, and Object.assign rather than a spread literal: a\n // spread would rebuild the object with Object.prototype and undo\n // parse.ts's guard.\n const combined = Object.assign(Object.create(null), parsed.query, params) as 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 // Path params (`:id`) are as URL-controlled as the query string.\n const out = Object.create(null) as 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"],"m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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 // Null-prototype: query keys come straight from the URL, so an object literal\n // would answer `params.constructor` / `params.toString` with an inherited\n // value for a link that never carried that key.\n const query = Object.create(null) as 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 // Null-prototype, and Object.assign rather than a spread literal: a\n // spread would rebuild the object with Object.prototype and undo\n // parse.ts's guard.\n const combined = Object.assign(Object.create(null), parsed.query, params) as 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 // Path params (`:id`) are as URL-controlled as the query string.\n const out = Object.create(null) as 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,IAAI,WAAW,GAAG,OAAO;CACxD,IAAI,OAAO;CACX,IAAI,SAAwB;CAC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a;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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flare-engine/deep-links",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"description": "URL → scene+params router with web history + native Linking adapters",
|
|
5
5
|
"keywords": ["flare-engine", "deep-links", "router", "url"],
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"typecheck": "tsc --noEmit"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@flare-engine/events": "^0.4.
|
|
40
|
+
"@flare-engine/events": "^0.4.7"
|
|
41
41
|
},
|
|
42
42
|
"engines": {
|
|
43
43
|
"node": ">=20"
|