@flare-engine/deep-links 0.4.11 → 0.4.13

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.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 */\nexport interface 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,KAA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AI,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"}
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 */\nexport interface 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;CAClB,UAAU,IAAIA,qBAAAA,OAAsB;CACpC,cAAc,IAAIA,qBAAAA,OAAe;CACzB;CACA;CACT,cAAmC;CACnC,WAAiC;CAEzC,YAAY,SAAiC;EAC3C,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;CACxB;CAEA,IAAI,UAAgC;EAClC,OAAO,KAAK;CACd;CAEA,MAAM,QAAuB;E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EACA,UAAU,SAAS;GACjB,UAAU,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"}
@@ -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 */\nexport interface 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;CAC5B,IAAI,OAAsB;CAE1B,MAAM,YAAY,KAAK,QAAQ,KAAK;CACpC,IAAI,cAAc,MAAM,4BAA4B,KAAK,KAAK,MAAM,GAAG,SAAS,CAAC,GAAG;EAClF,SAAS,KAAK,MAAM,GAAG,SAAS;EAChC,OAAO,KAAK,MAAM,YAAY,CAAC;EAC/B,MAAM,QAAQ,OAAO,YAAY;EACjC,IAAI,UAAU,UAAU,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aAAa,IAAI,OAAO;EAC1B;CACF;AACF"}
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 */\nexport interface 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;CAClB,UAAU,IAAI,OAAsB;CACpC,cAAc,IAAI,OAAe;CACzB;CACA;CACT,cAAmC;CACnC,WAAiC;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;CACt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O,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flare-engine/deep-links",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
4
4
  "description": "URL → scene+params router with web history + native Linking adapters",
5
5
  "keywords": ["flare-engine", "deep-links", "router", "url", "react-native", "typescript"],
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.11"
40
+ "@flare-engine/events": "^0.4.13"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=20"