@securitydept/client 0.3.0-beta.5 → 0.3.0-beta.6
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/{create-Bm-XRA3G.mjs → create-99Ksgl_O.mjs} +13 -634
- package/dist/create-99Ksgl_O.mjs.map +1 -0
- package/dist/handle-TnxwtQ4T.mjs +634 -0
- package/dist/handle-TnxwtQ4T.mjs.map +1 -0
- package/dist/{index-Ch8lrE44.d.mts → index-Cg_iY2yY.d.mts} +4 -21
- package/dist/{index-D5mW18cM.d.mts → index-DmIapvr-.d.mts} +50 -29
- package/dist/{index-BT-u3qNI.d.mts → index-O1A3CdBV.d.mts} +4 -18
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +9 -8
- package/dist/index.mjs.map +1 -1
- package/dist/{router-BJ8LqNJ1.mjs → router-DUh3bhLy.mjs} +4 -4
- package/dist/{router-BJ8LqNJ1.mjs.map → router-DUh3bhLy.mjs.map} +1 -1
- package/dist/rx/index.d.mts +1 -2
- package/dist/rx/index.mjs +1 -1
- package/dist/{rx-BoB32Dzg.mjs → rx-B3OU17wu.mjs} +1 -2
- package/dist/{rx-BoB32Dzg.mjs.map → rx-B3OU17wu.mjs.map} +1 -1
- package/dist/server/index.d.mts +1 -2
- package/dist/server/index.mjs +1 -1
- package/dist/server/index.mjs.map +1 -1
- package/dist/test/index.d.mts +2 -3
- package/dist/test/index.mjs +3 -3
- package/dist/test/index.mjs.map +1 -1
- package/dist/{uri-string-BfnIT4gJ.mjs → uri-string-BPNbIMgv.mjs} +5 -3
- package/dist/{uri-string-BfnIT4gJ.mjs.map → uri-string-BPNbIMgv.mjs.map} +1 -1
- package/dist/web/index.d.mts +16 -4
- package/dist/web/index.mjs +27 -21
- package/dist/web/index.mjs.map +1 -1
- package/dist/webext/index.d.mts +2 -3
- package/dist/webext/index.mjs +12 -10
- package/dist/webext/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/create-Bm-XRA3G.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-BJ8LqNJ1.mjs","names":["defineType","defineType","UriReferenceStringClass"],"sources":["../src/web/events/page-resume.ts","../src/web/page.ts","../src/web/router/router.ts"],"sourcesContent":["import {\n\tdefer,\n\tdistinctUntilChanged,\n\tfilter,\n\tfromEventPattern,\n\tmap,\n\tmerge,\n\ttype Observable,\n} from \"rxjs\";\nimport { type EventStreamTrait } from \"../../events/types\";\nimport { RxEventStream } from \"../../rx\";\n\nexport const PageResumeTriggerKind = {\n\tVisibility: \"visibility\",\n\tPageShow: \"pageshow\",\n\tFocus: \"focus\",\n\tOnline: \"online\",\n} as const;\n\nexport type PageResumeTriggerKind =\n\t(typeof PageResumeTriggerKind)[keyof typeof PageResumeTriggerKind];\n\nexport interface PageResumeEvent {\n\ttrigger: PageResumeTriggerKind;\n\tpersisted?: boolean;\n}\n\nexport interface PageResumeDocumentTarget {\n\taddEventListener(type: \"visibilitychange\", handler: EventListener): void;\n\tremoveEventListener(type: \"visibilitychange\", handler: EventListener): void;\n\tvisibilityState: DocumentVisibilityState;\n}\n\nexport interface PageResumeWindowTarget {\n\taddEventListener(\n\t\ttype: \"pageshow\" | \"focus\" | \"online\",\n\t\thandler: EventListener,\n\t): void;\n\tremoveEventListener(\n\t\ttype: \"pageshow\" | \"focus\" | \"online\",\n\t\thandler: EventListener,\n\t): void;\n}\n\nexport interface CreatePageResumeSourceOptions {\n\tdocumentTarget: PageResumeDocumentTarget | null | undefined;\n\twindowTarget: PageResumeWindowTarget | null | undefined;\n}\n\nexport function createPageResumeSource(\n\toptions: CreatePageResumeSourceOptions,\n): EventStreamTrait<PageResumeEvent> {\n\treturn RxEventStream.fromObservableInput(\n\t\tdefer(() => {\n\t\t\tconst { documentTarget, windowTarget } = options;\n\t\t\tconst streams: Observable<PageResumeEvent>[] = [];\n\n\t\t\tif (documentTarget) {\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) =>\n\t\t\t\t\t\t\tdocumentTarget.addEventListener(\"visibilitychange\", handler),\n\t\t\t\t\t\t(handler) =>\n\t\t\t\t\t\t\tdocumentTarget.removeEventListener(\"visibilitychange\", handler),\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tmap(() => documentTarget.visibilityState),\n\t\t\t\t\t\tdistinctUntilChanged(),\n\t\t\t\t\t\tfilter((visibilityState) => visibilityState === \"visible\"),\n\t\t\t\t\t\tmap(() => ({\n\t\t\t\t\t\t\ttrigger: PageResumeTriggerKind.Visibility,\n\t\t\t\t\t\t})),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (windowTarget) {\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) => windowTarget.addEventListener(\"pageshow\", handler),\n\t\t\t\t\t\t(handler) => windowTarget.removeEventListener(\"pageshow\", handler),\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tmap((event) => ({\n\t\t\t\t\t\t\ttrigger: PageResumeTriggerKind.PageShow,\n\t\t\t\t\t\t\tpersisted: Boolean((event as PageTransitionEvent).persisted),\n\t\t\t\t\t\t})),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) => windowTarget.addEventListener(\"focus\", handler),\n\t\t\t\t\t\t(handler) => windowTarget.removeEventListener(\"focus\", handler),\n\t\t\t\t\t).pipe(map(() => ({ trigger: PageResumeTriggerKind.Focus }))),\n\t\t\t\t);\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) => windowTarget.addEventListener(\"online\", handler),\n\t\t\t\t\t\t(handler) => windowTarget.removeEventListener(\"online\", handler),\n\t\t\t\t\t).pipe(map(() => ({ trigger: PageResumeTriggerKind.Online }))),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn merge(...streams);\n\t\t}),\n\t);\n}\n","import { type as defineType } from \"arktype\";\nimport { type EnvironmentValidators } from \"../environment/types\";\nimport { type PageLifecycleTrait } from \"../page\";\nimport {\n\tthrowValidationClientError,\n\tvalidateTraitInput,\n\tvalidateWithSchemaSync,\n\ttype WithTraitInputValidator,\n} from \"../validation\";\nimport {\n\tcreatePageResumeSource,\n\ttype PageResumeDocumentTarget,\n\ttype PageResumeWindowTarget,\n} from \"./events\";\n\nexport interface PageLifecycleForNativeWebCreateOptions {\n\tdocument?: PageResumeDocumentTarget | null;\n\twindow?: PageResumeWindowTarget | null;\n}\n\nconst PageResumeDocumentTargetSchema = defineType({\n\taddEventListener: \"Function\",\n\tremoveEventListener: \"Function\",\n\tvisibilityState: \"string\",\n});\n\nconst PageResumeWindowTargetSchema = defineType({\n\taddEventListener: \"Function\",\n\tremoveEventListener: \"Function\",\n});\n\nconst PageLifecycleForNativeWebUnavailableProbeSchema = defineType({\n\tdocument: \"null | undefined\",\n\twindow: \"null | undefined\",\n});\n\nconst PageLifecycleForNativeWebCreateOptionsSchema = defineType({\n\tdocument: PageResumeDocumentTargetSchema.or(\"null\").or(\"undefined\"),\n\twindow: PageResumeWindowTargetSchema.or(\"null\").or(\"undefined\"),\n});\n\nexport function createPageLifecycleForNativeWeb(\n\toptions: PageLifecycleForNativeWebCreateOptions &\n\t\tWithTraitInputValidator<Pick<EnvironmentValidators, \"pageLifecycle\">> = {},\n): PageLifecycleTrait | null {\n\tconst { validators, ...createOptions } = options;\n\tconst global = globalThis as {\n\t\tdocument?: PageResumeDocumentTarget;\n\t\twindow?: PageResumeWindowTarget;\n\t};\n\tconst resolvedCreateOptions = {\n\t\tdocument: global.document ?? null,\n\t\twindow: global.window ?? null,\n\t\t...createOptions,\n\t};\n\tconst unavailableProbeResult = validateWithSchemaSync(\n\t\tPageLifecycleForNativeWebUnavailableProbeSchema,\n\t\tresolvedCreateOptions,\n\t);\n\tif (unavailableProbeResult.success) {\n\t\treturn null;\n\t}\n\tvalidateTraitInput({\n\t\tvalue: resolvedCreateOptions,\n\t\tbundledSchema: PageLifecycleForNativeWebCreateOptionsSchema,\n\t\tvalidator: validators?.pageLifecycle,\n\t\tonInvalid: (failure) =>\n\t\t\tthrowValidationClientError({\n\t\t\t\tcode: \"web.page.invalid_native_web_page_lifecycle_options\",\n\t\t\t\tsource: \"web\",\n\t\t\t\tmessagePrefix:\n\t\t\t\t\t\"createPageLifecycleForNativeWeb could not validate pageLifecycleForNativeWebCreateOptions\",\n\t\t\t\tfailure,\n\t\t\t}),\n\t});\n\tconst documentTarget = resolvedCreateOptions.document ?? null;\n\tconst windowTarget = resolvedCreateOptions.window ?? null;\n\treturn {\n\t\tresume: createPageResumeSource({\n\t\t\tdocumentTarget,\n\t\t\twindowTarget,\n\t\t}),\n\t};\n}\n","import { type as defineType } from \"arktype\";\nimport { type EnvironmentValidators } from \"../../environment/types\";\nimport { ClientError, ClientErrorKind } from \"../../errors\";\nimport {\n\tRouterNavigationMode,\n\ttype RouterNavigationRequest,\n\ttype RouterTrait,\n} from \"../../router\";\nimport {\n\ttype UriReferenceString,\n\tUriReferenceString as UriReferenceStringClass,\n} from \"../../struct/uri-string\";\nimport {\n\tthrowValidationClientError,\n\tvalidateTraitInput,\n\tvalidateWithSchemaSync,\n\ttype WithTraitInputValidator,\n} from \"../../validation\";\n\nexport interface NativeWebNavigateEventLike {\n\treadonly destination?: {\n\t\treadonly url: string;\n\t\tgetState?(): unknown;\n\t};\n\treadonly navigationType?: \"push\" | \"replace\" | \"reload\" | \"traverse\";\n\treadonly canIntercept?: boolean;\n\treadonly signal?: AbortSignal;\n\tintercept(options?: { handler?: () => Promise<void> | void }): void;\n\tredirect?(url: string, options?: { history?: \"push\" | \"replace\" }): void;\n}\n\nexport interface NativeWebNavigationLike {\n\tnavigate(\n\t\turl: string,\n\t\toptions?: { history?: \"push\" | \"replace\"; state?: unknown },\n\t): { committed?: Promise<unknown>; finished?: Promise<unknown> } | void;\n\taddEventListener?(\n\t\ttype: \"navigate\",\n\t\thandler: (event: NativeWebNavigateEventLike) => void,\n\t): void;\n\tremoveEventListener?(\n\t\ttype: \"navigate\",\n\t\thandler: (event: NativeWebNavigateEventLike) => void,\n\t): void;\n}\n\nexport interface NativeWebLocationLike {\n\thref: string;\n\thash?: string;\n\tpathname?: string;\n\tsearch?: string;\n\torigin?: string;\n}\n\nexport interface NativeWebHistoryLike {\n\tpushState(data: unknown, unused: string, url?: string | URL | null): void;\n\treplaceState(data: unknown, unused: string, url?: string | URL | null): void;\n}\n\nexport interface NativeWebWindowLike {\n\tlocation?: NativeWebLocationLike;\n\thistory?: NativeWebHistoryLike;\n}\n\nexport interface RouterForNativeWebCreateOptions {\n\tnavigation?: NativeWebNavigationLike | null;\n\tlocation?: NativeWebLocationLike | null;\n\thistory?: NativeWebHistoryLike | null;\n\twindow?: NativeWebWindowLike | null;\n}\n\nexport interface ResolvedRouterForNativeWebCreateOptions {\n\tnavigation: NativeWebNavigationLike | null;\n\tlocation: NativeWebLocationLike | null;\n\thistory: NativeWebHistoryLike | null;\n\twindow: NativeWebWindowLike | null;\n}\n\nconst NativeWebNavigationLikeSchema = defineType({\n\tnavigate: \"Function\",\n\taddEventListener: \"Function?\",\n\tremoveEventListener: \"Function?\",\n});\n\nconst NativeWebLocationLikeSchema = defineType({\n\thref: \"string\",\n});\n\nconst NativeWebHistoryLikeSchema = defineType({\n\tpushState: \"Function\",\n\treplaceState: \"Function\",\n});\n\nconst NativeWebWindowLikeSchema = defineType({\n\tlocation: NativeWebLocationLikeSchema.optional(),\n\thistory: NativeWebHistoryLikeSchema.optional(),\n\topen: \"Function?\",\n});\n\nconst NullableNativeWebHistoryLikeSchema =\n\tNativeWebHistoryLikeSchema.or(\"null\").or(\"undefined\");\nconst NullableNativeWebWindowLikeSchema =\n\tNativeWebWindowLikeSchema.or(\"null\").or(\"undefined\");\n\nconst RouterForNativeWebCreateOptionsSchema = defineType({\n\tnavigation: NativeWebNavigationLikeSchema,\n\tlocation: NativeWebLocationLikeSchema.or(\"null\").or(\"undefined\"),\n\thistory: NullableNativeWebHistoryLikeSchema,\n\twindow: NullableNativeWebWindowLikeSchema,\n}).or({\n\tnavigation: \"null | undefined\",\n\tlocation: NativeWebLocationLikeSchema,\n\thistory: NullableNativeWebHistoryLikeSchema,\n\twindow: NullableNativeWebWindowLikeSchema,\n});\n\nconst RouterForNativeWebUnavailableProbeSchema = defineType({\n\tnavigation: \"null | undefined\",\n\tlocation: \"null | undefined\",\n\thistory: \"null | undefined\",\n\twindow: \"null | undefined\",\n});\n\nexport function createRouterForNativeWeb(\n\toptions: RouterForNativeWebCreateOptions &\n\t\tWithTraitInputValidator<Pick<EnvironmentValidators, \"router\">> = {},\n): RouterTrait | null {\n\tconst resolvedCreateOptions = resolveRouterForNativeWebCreateOptions(options);\n\tif (\n\t\tvalidateWithSchemaSync(\n\t\t\tRouterForNativeWebUnavailableProbeSchema,\n\t\t\tresolvedCreateOptions,\n\t\t).success\n\t) {\n\t\treturn null;\n\t}\n\tvalidateTraitInput({\n\t\tvalue: resolvedCreateOptions,\n\t\tbundledSchema: RouterForNativeWebCreateOptionsSchema,\n\t\tvalidator: options.validators?.router,\n\t\tonInvalid: (failure) =>\n\t\t\tthrowValidationClientError({\n\t\t\t\tcode: \"web.router.invalid_native_web_router_options\",\n\t\t\t\tsource: \"web\",\n\t\t\t\tmessagePrefix:\n\t\t\t\t\t\"createRouterForNativeWeb could not validate routerForNativeWebCreateOptions\",\n\t\t\t\tfailure,\n\t\t\t}),\n\t});\n\tconst router = new NativeWebRouter(resolvedCreateOptions);\n\treturn {\n\t\tcurrentUrl() {\n\t\t\treturn router.currentUrl();\n\t\t},\n\t\tnavigate(request) {\n\t\t\treturn router.navigate(request);\n\t\t},\n\t};\n}\n\nexport class NativeWebRouter implements RouterTrait {\n\tprotected readonly router: WebNavigationRouter | WebLegacyRouter;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tthis.router = options.navigation\n\t\t\t? new WebNavigationRouter(options)\n\t\t\t: new WebLegacyRouter(options);\n\t}\n\n\tcurrentUrl(): UriReferenceString | null {\n\t\treturn this.router.currentUrl();\n\t}\n\n\tnavigate(request: RouterNavigationRequest): void | Promise<void> {\n\t\treturn this.router.navigate(request);\n\t}\n}\n\nabstract class NativeWebRouterBase implements RouterTrait {\n\tprotected readonly location: NativeWebLocationLike | null;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tthis.location = options.location;\n\t}\n\n\tcurrentUrl(): UriReferenceString | null {\n\t\treturn this.location?.href\n\t\t\t? UriReferenceStringClass.parse(this.location.href)\n\t\t\t: null;\n\t}\n\n\tprotected resolveNavigationTarget(request: RouterNavigationRequest): string {\n\t\treturn request.url.toString();\n\t}\n\n\tabstract navigate(request: RouterNavigationRequest): void | Promise<void>;\n}\n\nexport class WebNavigationRouter extends NativeWebRouterBase {\n\tprotected readonly navigation: NativeWebNavigationLike;\n\tprotected readonly history: NativeWebHistoryLike | null;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tif (!options.navigation) {\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.navigation_unavailable\",\n\t\t\t\tmessage: \"WebNavigationRouter requires the Navigation API\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\tsuper(options);\n\t\tthis.navigation = options.navigation;\n\t\tthis.history = options.history;\n\t}\n\n\tasync navigate(request: RouterNavigationRequest): Promise<void> {\n\t\tconst target = this.resolveNavigationTarget(request);\n\t\tif (request.mode === RouterNavigationMode.External) {\n\t\t\tif (this.location) {\n\t\t\t\tthis.location.href = target;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.location_unavailable\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"Native web router cannot perform external navigation without location\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\t// Prefer History API for same-origin Push/Replace. Unintercepted\n\t\t// Navigation API navigations load a new document even for in-app path,\n\t\t// query, or hash changes, which breaks SPA routing and aborts in-flight\n\t\t// OIDC callback handling after the callback payload has been taken.\n\t\tif (this.history && this.isSameOriginNavigation(request.url)) {\n\t\t\tif (request.mode === RouterNavigationMode.Replace) {\n\t\t\t\tthis.history.replaceState(request.state ?? null, \"\", target);\n\t\t\t} else {\n\t\t\t\tthis.history.pushState(request.state ?? null, \"\", target);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst result = this.navigation.navigate(target, {\n\t\t\thistory:\n\t\t\t\trequest.mode === RouterNavigationMode.Replace\n\t\t\t\t\t? RouterNavigationMode.Replace\n\t\t\t\t\t: RouterNavigationMode.Push,\n\t\t\tstate: request.state,\n\t\t});\n\t\tawait result?.committed;\n\t}\n\n\tprivate isSameOriginNavigation(url: UriReferenceString): boolean {\n\t\tconst current = this.currentUrl();\n\t\tif (!current) {\n\t\t\treturn false;\n\t\t}\n\t\tif (url.isAbsolute() && current.isAbsolute()) {\n\t\t\treturn url.origin === current.origin;\n\t\t}\n\t\t// Relative targets inherit the current document origin.\n\t\treturn url.isRelative();\n\t}\n}\n\nexport class WebLegacyRouter extends NativeWebRouterBase {\n\tprotected readonly history: NativeWebHistoryLike | null;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tsuper(options);\n\t\tthis.history = options.history;\n\t}\n\n\tasync navigate(request: RouterNavigationRequest): Promise<void> {\n\t\tconst target = this.resolveNavigationTarget(request);\n\t\tif (request.mode === RouterNavigationMode.External) {\n\t\t\tif (this.location) {\n\t\t\t\tthis.location.href = target;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.location_unavailable\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"Native web router cannot perform external navigation without location\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\tif (!this.history) {\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.history_unavailable\",\n\t\t\t\tmessage: \"Native web router requires history for in-page navigation\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\tif (request.mode === RouterNavigationMode.Replace) {\n\t\t\tthis.history.replaceState(request.state ?? null, \"\", target);\n\t\t} else {\n\t\t\tthis.history.pushState(request.state ?? null, \"\", target);\n\t\t}\n\t}\n}\n\nexport function resolveRouterForNativeWebCreateOptions(\n\toptions: RouterForNativeWebCreateOptions = {},\n): ResolvedRouterForNativeWebCreateOptions {\n\tconst global = globalThis as {\n\t\tnavigation?: NativeWebNavigationLike;\n\t\tlocation?: NativeWebLocationLike;\n\t\thistory?: NativeWebHistoryLike;\n\t\twindow?: NativeWebWindowLike;\n\t};\n\tconst windowLike = Object.hasOwn(options, \"window\")\n\t\t? (options.window ?? null)\n\t\t: (global.window ?? null);\n\tconst navigation = Object.hasOwn(options, \"navigation\")\n\t\t? (options.navigation ?? null)\n\t\t: (global.navigation ?? null);\n\tconst location = Object.hasOwn(options, \"location\")\n\t\t? (options.location ?? null)\n\t\t: (windowLike?.location ?? global.location ?? null);\n\tconst history = Object.hasOwn(options, \"history\")\n\t\t? (options.history ?? null)\n\t\t: (windowLike?.history ?? global.history ?? null);\n\treturn {\n\t\twindow: windowLike,\n\t\tnavigation,\n\t\tlocation,\n\t\thistory,\n\t};\n}\n"],"mappings":";;;;;;AAYA,MAAa,wBAAwB;CACpC,YAAY;CACZ,UAAU;CACV,OAAO;CACP,QAAQ;CACR;AAgCD,SAAgB,uBACf,SACoC;CACpC,OAAO,cAAc,oBACpB,YAAY;EACX,MAAM,EAAE,gBAAgB,iBAAiB;EACzC,MAAM,UAAyC,EAAE;EAEjD,IAAI,gBACH,QAAQ,KACP,kBACE,YACA,eAAe,iBAAiB,oBAAoB,QAAQ,G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AAM,SAAS;CAMf,MAAM,aAAa,OAAO,OAAO,SAAS,SAAS,GAC/C,QAAQ,UAAU,OAClB,OAAO,UAAU;CAUrB,OAAO;EACN,QAAQ;EACR,YAXkB,OAAO,OAAO,SAAS,aAAa,GACnD,QAAQ,cAAc,OACtB,OAAO,cAAc;EAUxB,UATgB,OAAO,OAAO,SAAS,WAAW,GAC/C,QAAQ,YAAY,OACpB,YAAY,YAAY,OAAO,YAAY;EAQ9C,SAPe,OAAO,OAAO,SAAS,UAAU,GAC7C,QAAQ,WAAW,OACnB,YAAY,WAAW,OAAO,WAAW;EAM5C"}
|
|
1
|
+
{"version":3,"file":"router-DUh3bhLy.mjs","names":["defineType","defineType","UriReferenceStringClass"],"sources":["../src/web/events/page-resume.ts","../src/web/page.ts","../src/web/router/router.ts"],"sourcesContent":["import {\n\tdefer,\n\tdistinctUntilChanged,\n\tfilter,\n\tfromEventPattern,\n\tmap,\n\tmerge,\n\ttype Observable,\n} from \"rxjs\";\nimport { type EventStreamTrait } from \"../../events/types\";\nimport { RxEventStream } from \"../../rx\";\n\nexport const PageResumeTriggerKind = {\n\tVisibility: \"visibility\",\n\tPageShow: \"pageshow\",\n\tFocus: \"focus\",\n\tOnline: \"online\",\n} as const;\n\nexport type PageResumeTriggerKind =\n\t(typeof PageResumeTriggerKind)[keyof typeof PageResumeTriggerKind];\n\nexport interface PageResumeEvent {\n\ttrigger: PageResumeTriggerKind;\n\tpersisted?: boolean;\n}\n\nexport interface PageResumeDocumentTarget {\n\taddEventListener(type: \"visibilitychange\", handler: EventListener): void;\n\tremoveEventListener(type: \"visibilitychange\", handler: EventListener): void;\n\tvisibilityState: DocumentVisibilityState;\n}\n\nexport interface PageResumeWindowTarget {\n\taddEventListener(\n\t\ttype: \"pageshow\" | \"focus\" | \"online\",\n\t\thandler: EventListener,\n\t): void;\n\tremoveEventListener(\n\t\ttype: \"pageshow\" | \"focus\" | \"online\",\n\t\thandler: EventListener,\n\t): void;\n}\n\nexport interface CreatePageResumeSourceOptions {\n\tdocumentTarget: PageResumeDocumentTarget | null | undefined;\n\twindowTarget: PageResumeWindowTarget | null | undefined;\n}\n\nexport function createPageResumeSource(\n\toptions: CreatePageResumeSourceOptions,\n): EventStreamTrait<PageResumeEvent> {\n\treturn RxEventStream.fromObservableInput(\n\t\tdefer(() => {\n\t\t\tconst { documentTarget, windowTarget } = options;\n\t\t\tconst streams: Observable<PageResumeEvent>[] = [];\n\n\t\t\tif (documentTarget) {\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) =>\n\t\t\t\t\t\t\tdocumentTarget.addEventListener(\"visibilitychange\", handler),\n\t\t\t\t\t\t(handler) =>\n\t\t\t\t\t\t\tdocumentTarget.removeEventListener(\"visibilitychange\", handler),\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tmap(() => documentTarget.visibilityState),\n\t\t\t\t\t\tdistinctUntilChanged(),\n\t\t\t\t\t\tfilter((visibilityState) => visibilityState === \"visible\"),\n\t\t\t\t\t\tmap(() => ({\n\t\t\t\t\t\t\ttrigger: PageResumeTriggerKind.Visibility,\n\t\t\t\t\t\t})),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (windowTarget) {\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) => windowTarget.addEventListener(\"pageshow\", handler),\n\t\t\t\t\t\t(handler) => windowTarget.removeEventListener(\"pageshow\", handler),\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tmap((event) => ({\n\t\t\t\t\t\t\ttrigger: PageResumeTriggerKind.PageShow,\n\t\t\t\t\t\t\tpersisted: Boolean((event as PageTransitionEvent).persisted),\n\t\t\t\t\t\t})),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) => windowTarget.addEventListener(\"focus\", handler),\n\t\t\t\t\t\t(handler) => windowTarget.removeEventListener(\"focus\", handler),\n\t\t\t\t\t).pipe(map(() => ({ trigger: PageResumeTriggerKind.Focus }))),\n\t\t\t\t);\n\t\t\t\tstreams.push(\n\t\t\t\t\tfromEventPattern<Event>(\n\t\t\t\t\t\t(handler) => windowTarget.addEventListener(\"online\", handler),\n\t\t\t\t\t\t(handler) => windowTarget.removeEventListener(\"online\", handler),\n\t\t\t\t\t).pipe(map(() => ({ trigger: PageResumeTriggerKind.Online }))),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\treturn merge(...streams);\n\t\t}),\n\t);\n}\n","import { type as defineType } from \"arktype\";\nimport { type EnvironmentValidators } from \"../environment/types\";\nimport { type PageLifecycleTrait } from \"../page\";\nimport {\n\tthrowValidationClientError,\n\tvalidateTraitInput,\n\tvalidateWithSchemaSync,\n\ttype WithTraitInputValidator,\n} from \"../validation\";\nimport {\n\tcreatePageResumeSource,\n\ttype PageResumeDocumentTarget,\n\ttype PageResumeWindowTarget,\n} from \"./events\";\n\nexport interface PageLifecycleForNativeWebCreateOptions {\n\tdocument?: PageResumeDocumentTarget | null;\n\twindow?: PageResumeWindowTarget | null;\n}\n\nconst PageResumeDocumentTargetSchema = defineType({\n\taddEventListener: \"Function\",\n\tremoveEventListener: \"Function\",\n\tvisibilityState: \"string\",\n});\n\nconst PageResumeWindowTargetSchema = defineType({\n\taddEventListener: \"Function\",\n\tremoveEventListener: \"Function\",\n});\n\nconst PageLifecycleForNativeWebUnavailableProbeSchema = defineType({\n\tdocument: \"null | undefined\",\n\twindow: \"null | undefined\",\n});\n\nconst PageLifecycleForNativeWebCreateOptionsSchema = defineType({\n\tdocument: PageResumeDocumentTargetSchema.or(\"null\").or(\"undefined\"),\n\twindow: PageResumeWindowTargetSchema.or(\"null\").or(\"undefined\"),\n});\n\nexport function createPageLifecycleForNativeWeb(\n\toptions: PageLifecycleForNativeWebCreateOptions &\n\t\tWithTraitInputValidator<Pick<EnvironmentValidators, \"pageLifecycle\">> = {},\n): PageLifecycleTrait | null {\n\tconst { validators, ...createOptions } = options;\n\tconst global = globalThis as {\n\t\tdocument?: PageResumeDocumentTarget;\n\t\twindow?: PageResumeWindowTarget;\n\t};\n\tconst resolvedCreateOptions = {\n\t\tdocument: global.document ?? null,\n\t\twindow: global.window ?? null,\n\t\t...createOptions,\n\t};\n\tconst unavailableProbeResult = validateWithSchemaSync(\n\t\tPageLifecycleForNativeWebUnavailableProbeSchema,\n\t\tresolvedCreateOptions,\n\t);\n\tif (unavailableProbeResult.success) {\n\t\treturn null;\n\t}\n\tvalidateTraitInput({\n\t\tvalue: resolvedCreateOptions,\n\t\tbundledSchema: PageLifecycleForNativeWebCreateOptionsSchema,\n\t\tvalidator: validators?.pageLifecycle,\n\t\tonInvalid: (failure) =>\n\t\t\tthrowValidationClientError({\n\t\t\t\tcode: \"web.page.invalid_native_web_page_lifecycle_options\",\n\t\t\t\tsource: \"web\",\n\t\t\t\tmessagePrefix:\n\t\t\t\t\t\"createPageLifecycleForNativeWeb could not validate pageLifecycleForNativeWebCreateOptions\",\n\t\t\t\tfailure,\n\t\t\t}),\n\t});\n\tconst documentTarget = resolvedCreateOptions.document ?? null;\n\tconst windowTarget = resolvedCreateOptions.window ?? null;\n\treturn {\n\t\tresume: createPageResumeSource({\n\t\t\tdocumentTarget,\n\t\t\twindowTarget,\n\t\t}),\n\t};\n}\n","import { type as defineType } from \"arktype\";\nimport { type EnvironmentValidators } from \"../../environment/types\";\nimport { ClientError, ClientErrorKind } from \"../../errors\";\nimport {\n\tRouterNavigationMode,\n\ttype RouterNavigationRequest,\n\ttype RouterTrait,\n} from \"../../router\";\nimport {\n\ttype UriReferenceString,\n\tUriReferenceString as UriReferenceStringClass,\n} from \"../../struct/uri-string\";\nimport {\n\tthrowValidationClientError,\n\tvalidateTraitInput,\n\tvalidateWithSchemaSync,\n\ttype WithTraitInputValidator,\n} from \"../../validation\";\n\nexport interface NativeWebNavigateEventLike {\n\treadonly destination?: {\n\t\treadonly url: string;\n\t\tgetState?(): unknown;\n\t};\n\treadonly navigationType?: \"push\" | \"replace\" | \"reload\" | \"traverse\";\n\treadonly canIntercept?: boolean;\n\treadonly signal?: AbortSignal;\n\tintercept(options?: { handler?: () => Promise<void> | void }): void;\n\tredirect?(url: string, options?: { history?: \"push\" | \"replace\" }): void;\n}\n\nexport interface NativeWebNavigationLike {\n\tnavigate(\n\t\turl: string,\n\t\toptions?: { history?: \"push\" | \"replace\"; state?: unknown },\n\t): { committed?: Promise<unknown>; finished?: Promise<unknown> } | void;\n\taddEventListener?(\n\t\ttype: \"navigate\",\n\t\thandler: (event: NativeWebNavigateEventLike) => void,\n\t): void;\n\tremoveEventListener?(\n\t\ttype: \"navigate\",\n\t\thandler: (event: NativeWebNavigateEventLike) => void,\n\t): void;\n}\n\nexport interface NativeWebLocationLike {\n\thref: string;\n\thash?: string;\n\tpathname?: string;\n\tsearch?: string;\n\torigin?: string;\n}\n\nexport interface NativeWebHistoryLike {\n\tpushState(data: unknown, unused: string, url?: string | URL | null): void;\n\treplaceState(data: unknown, unused: string, url?: string | URL | null): void;\n}\n\nexport interface NativeWebWindowLike {\n\tlocation?: NativeWebLocationLike;\n\thistory?: NativeWebHistoryLike;\n}\n\nexport interface RouterForNativeWebCreateOptions {\n\tnavigation?: NativeWebNavigationLike | null;\n\tlocation?: NativeWebLocationLike | null;\n\thistory?: NativeWebHistoryLike | null;\n\twindow?: NativeWebWindowLike | null;\n}\n\nexport interface ResolvedRouterForNativeWebCreateOptions {\n\tnavigation: NativeWebNavigationLike | null;\n\tlocation: NativeWebLocationLike | null;\n\thistory: NativeWebHistoryLike | null;\n\twindow: NativeWebWindowLike | null;\n}\n\nconst NativeWebNavigationLikeSchema = defineType({\n\tnavigate: \"Function\",\n\taddEventListener: \"Function?\",\n\tremoveEventListener: \"Function?\",\n});\n\nconst NativeWebLocationLikeSchema = defineType({\n\thref: \"string\",\n});\n\nconst NativeWebHistoryLikeSchema = defineType({\n\tpushState: \"Function\",\n\treplaceState: \"Function\",\n});\n\nconst NativeWebWindowLikeSchema = defineType({\n\tlocation: NativeWebLocationLikeSchema.optional(),\n\thistory: NativeWebHistoryLikeSchema.optional(),\n\topen: \"Function?\",\n});\n\nconst NullableNativeWebHistoryLikeSchema =\n\tNativeWebHistoryLikeSchema.or(\"null\").or(\"undefined\");\nconst NullableNativeWebWindowLikeSchema =\n\tNativeWebWindowLikeSchema.or(\"null\").or(\"undefined\");\n\nconst RouterForNativeWebCreateOptionsSchema = defineType({\n\tnavigation: NativeWebNavigationLikeSchema,\n\tlocation: NativeWebLocationLikeSchema.or(\"null\").or(\"undefined\"),\n\thistory: NullableNativeWebHistoryLikeSchema,\n\twindow: NullableNativeWebWindowLikeSchema,\n}).or({\n\tnavigation: \"null | undefined\",\n\tlocation: NativeWebLocationLikeSchema,\n\thistory: NullableNativeWebHistoryLikeSchema,\n\twindow: NullableNativeWebWindowLikeSchema,\n});\n\nconst RouterForNativeWebUnavailableProbeSchema = defineType({\n\tnavigation: \"null | undefined\",\n\tlocation: \"null | undefined\",\n\thistory: \"null | undefined\",\n\twindow: \"null | undefined\",\n});\n\nexport function createRouterForNativeWeb(\n\toptions: RouterForNativeWebCreateOptions &\n\t\tWithTraitInputValidator<Pick<EnvironmentValidators, \"router\">> = {},\n): RouterTrait | null {\n\tconst resolvedCreateOptions = resolveRouterForNativeWebCreateOptions(options);\n\tif (\n\t\tvalidateWithSchemaSync(\n\t\t\tRouterForNativeWebUnavailableProbeSchema,\n\t\t\tresolvedCreateOptions,\n\t\t).success\n\t) {\n\t\treturn null;\n\t}\n\tvalidateTraitInput({\n\t\tvalue: resolvedCreateOptions,\n\t\tbundledSchema: RouterForNativeWebCreateOptionsSchema,\n\t\tvalidator: options.validators?.router,\n\t\tonInvalid: (failure) =>\n\t\t\tthrowValidationClientError({\n\t\t\t\tcode: \"web.router.invalid_native_web_router_options\",\n\t\t\t\tsource: \"web\",\n\t\t\t\tmessagePrefix:\n\t\t\t\t\t\"createRouterForNativeWeb could not validate routerForNativeWebCreateOptions\",\n\t\t\t\tfailure,\n\t\t\t}),\n\t});\n\tconst router = new NativeWebRouter(resolvedCreateOptions);\n\treturn {\n\t\tcurrentUrl() {\n\t\t\treturn router.currentUrl();\n\t\t},\n\t\tnavigate(request) {\n\t\t\treturn router.navigate(request);\n\t\t},\n\t};\n}\n\nexport class NativeWebRouter implements RouterTrait {\n\tprotected readonly router: WebNavigationRouter | WebLegacyRouter;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tthis.router = options.navigation\n\t\t\t? new WebNavigationRouter(options)\n\t\t\t: new WebLegacyRouter(options);\n\t}\n\n\tcurrentUrl(): UriReferenceString | null {\n\t\treturn this.router.currentUrl();\n\t}\n\n\tnavigate(request: RouterNavigationRequest): void | Promise<void> {\n\t\treturn this.router.navigate(request);\n\t}\n}\n\nabstract class NativeWebRouterBase implements RouterTrait {\n\tprotected readonly location: NativeWebLocationLike | null;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tthis.location = options.location;\n\t}\n\n\tcurrentUrl(): UriReferenceString | null {\n\t\treturn this.location?.href\n\t\t\t? UriReferenceStringClass.parse(this.location.href)\n\t\t\t: null;\n\t}\n\n\tprotected resolveNavigationTarget(request: RouterNavigationRequest): string {\n\t\treturn request.url.toString();\n\t}\n\n\tabstract navigate(request: RouterNavigationRequest): void | Promise<void>;\n}\n\nexport class WebNavigationRouter extends NativeWebRouterBase {\n\tprotected readonly navigation: NativeWebNavigationLike;\n\tprotected readonly history: NativeWebHistoryLike | null;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tif (!options.navigation) {\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.navigation_unavailable\",\n\t\t\t\tmessage: \"WebNavigationRouter requires the Navigation API\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\tsuper(options);\n\t\tthis.navigation = options.navigation;\n\t\tthis.history = options.history;\n\t}\n\n\tasync navigate(request: RouterNavigationRequest): Promise<void> {\n\t\tconst target = this.resolveNavigationTarget(request);\n\t\tif (request.mode === RouterNavigationMode.External) {\n\t\t\tif (this.location) {\n\t\t\t\tthis.location.href = target;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.location_unavailable\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"Native web router cannot perform external navigation without location\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\t// Prefer History API for same-origin Push/Replace. Unintercepted\n\t\t// Navigation API navigations load a new document even for in-app path,\n\t\t// query, or hash changes, which breaks SPA routing and aborts in-flight\n\t\t// OIDC callback handling after the callback payload has been taken.\n\t\tif (this.history && this.isSameOriginNavigation(request.url)) {\n\t\t\tif (request.mode === RouterNavigationMode.Replace) {\n\t\t\t\tthis.history.replaceState(request.state ?? null, \"\", target);\n\t\t\t} else {\n\t\t\t\tthis.history.pushState(request.state ?? null, \"\", target);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tconst result = this.navigation.navigate(target, {\n\t\t\thistory:\n\t\t\t\trequest.mode === RouterNavigationMode.Replace\n\t\t\t\t\t? RouterNavigationMode.Replace\n\t\t\t\t\t: RouterNavigationMode.Push,\n\t\t\tstate: request.state,\n\t\t});\n\t\tawait result?.committed;\n\t}\n\n\tprivate isSameOriginNavigation(url: UriReferenceString): boolean {\n\t\tconst current = this.currentUrl();\n\t\tif (!current) {\n\t\t\treturn false;\n\t\t}\n\t\tif (url.isAbsolute() && current.isAbsolute()) {\n\t\t\treturn url.origin === current.origin;\n\t\t}\n\t\t// Relative targets inherit the current document origin.\n\t\treturn url.isRelative();\n\t}\n}\n\nexport class WebLegacyRouter extends NativeWebRouterBase {\n\tprotected readonly history: NativeWebHistoryLike | null;\n\n\tconstructor(options: ResolvedRouterForNativeWebCreateOptions) {\n\t\tsuper(options);\n\t\tthis.history = options.history;\n\t}\n\n\tasync navigate(request: RouterNavigationRequest): Promise<void> {\n\t\tconst target = this.resolveNavigationTarget(request);\n\t\tif (request.mode === RouterNavigationMode.External) {\n\t\t\tif (this.location) {\n\t\t\t\tthis.location.href = target;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.location_unavailable\",\n\t\t\t\tmessage:\n\t\t\t\t\t\"Native web router cannot perform external navigation without location\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\tif (!this.history) {\n\t\t\tthrow new ClientError({\n\t\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\t\tcode: \"web.router.history_unavailable\",\n\t\t\t\tmessage: \"Native web router requires history for in-page navigation\",\n\t\t\t\tsource: \"web.router\",\n\t\t\t});\n\t\t}\n\t\tif (request.mode === RouterNavigationMode.Replace) {\n\t\t\tthis.history.replaceState(request.state ?? null, \"\", target);\n\t\t} else {\n\t\t\tthis.history.pushState(request.state ?? null, \"\", target);\n\t\t}\n\t}\n}\n\nexport function resolveRouterForNativeWebCreateOptions(\n\toptions: RouterForNativeWebCreateOptions = {},\n): ResolvedRouterForNativeWebCreateOptions {\n\tconst global = globalThis as {\n\t\tnavigation?: NativeWebNavigationLike;\n\t\tlocation?: NativeWebLocationLike;\n\t\thistory?: NativeWebHistoryLike;\n\t\twindow?: NativeWebWindowLike;\n\t};\n\tconst windowLike = Object.hasOwn(options, \"window\")\n\t\t? (options.window ?? null)\n\t\t: (global.window ?? null);\n\tconst navigation = Object.hasOwn(options, \"navigation\")\n\t\t? (options.navigation ?? null)\n\t\t: (global.navigation ?? null);\n\tconst location = Object.hasOwn(options, \"location\")\n\t\t? (options.location ?? null)\n\t\t: (windowLike?.location ?? global.location ?? null);\n\tconst history = Object.hasOwn(options, \"history\")\n\t\t? (options.history ?? null)\n\t\t: (windowLike?.history ?? global.history ?? null);\n\treturn {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AAQ,SAAS,qBAAqB,UAAU;GACnD,IAAI,KAAK,UAAU;IAClB,KAAK,SAAS,OAAO;IACrB;GACD;GACA,MAAM,IAAI,YAAY;IACrB,MAAM,gBAAgB;IACtB,MAAM;IACN,SACC;IACD,QAAQ;GACT,CAAC;EACF;EACA,IAAI,CAAC,KAAK,SACT,MAAM,IAAI,YAAY;GACrB,MAAM,gBAAgB;GACtB,MAAM;GACN,SAAS;GACT,QAAQ;EACT,CAAC;EAEF,IAAI,QAAQ,SAAS,qBAAqB,SACzC,KAAK,QAAQ,aAAa,QAAQ,SAAS,MAAM,IAAI,MAAM;OAE3D,KAAK,QAAQ,UAAU,QAAQ,SAAS,MAAM,IAAI,MAAM;CAE1D;AACD;AAEA,SAAgB,uCACf,UAA2C,CAAC,GACF;CAC1C,MAAM,SAAS;CAMf,MAAM,aAAa,OAAO,OAAO,SAAS,QAAQ,IAC9C,QAAQ,UAAU,OAClB,OAAO,UAAU;CAUrB,OAAO;EACN,QAAQ;EACR,YAXkB,OAAO,OAAO,SAAS,YAAY,IAClD,QAAQ,cAAc,OACtB,OAAO,cAAc;EAUxB,UATgB,OAAO,OAAO,SAAS,UAAU,IAC9C,QAAQ,YAAY,OACpB,YAAY,YAAY,OAAO,YAAY;EAQ9C,SAPe,OAAO,OAAO,SAAS,SAAS,IAC5C,QAAQ,WAAW,OACnB,YAAY,WAAW,OAAO,WAAW;CAM7C;AACD"}
|
package/dist/rx/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { F as ResourceSnapshot, I as ResourceStatus, L as ResourceTrait, T as TimeTrait, _ as RxEventStream, a as resourceFromSnapshots, c as RxComputedSignalCompat, d as RxSignalWatchCanceller, f as RxSignalWatchOptions, g as RxEventReplaySubject, h as RxStateSignalCompat, i as mapResource, l as RxSignalDirtyEvent, m as RxStateSignal, n as RxResourceOptions, o as rxResource, p as RxSignalWatchScheduler, r as RxResourceStreamContext, s as RxComputedSignal, t as RxResource, u as RxSignalOptions, v as RxEventSubject } from "../index-Cg_iY2yY.mjs";
|
|
2
2
|
import { Observable, ObservableInput, Observer, OperatorFunction } from "rxjs";
|
|
3
3
|
import { AsyncScheduler } from "rxjs/internal/scheduler/AsyncScheduler";
|
|
4
|
-
|
|
5
4
|
//#region src/rx/command.d.ts
|
|
6
5
|
declare const CommandResponseType: {
|
|
7
6
|
readonly Data: "data";
|
package/dist/rx/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { A as RxEventSubject, C as exhaustCommand, D as RxStateSignal, E as RxComputedSignal, O as RxEventReplaySubject, S as dispatchCommandLocallyToStream, T as unwrapCommandTerminalResponse, _ as commandResponseData, b as dispatchCommandByIdToStream, g as CommandResponseType, h as createAsyncSchedulerWithTimestampProvider, i as rxResource, k as RxEventStream, l as ResourceStatus, n as mapResource, r as resourceFromSnapshots, t as RxResource, v as concatCommand, w as switchCommand, x as dispatchCommandLocallyToPromise, y as dispatchCommandByIdToPromise } from "../rx-
|
|
1
|
+
import { A as RxEventSubject, C as exhaustCommand, D as RxStateSignal, E as RxComputedSignal, O as RxEventReplaySubject, S as dispatchCommandLocallyToStream, T as unwrapCommandTerminalResponse, _ as commandResponseData, b as dispatchCommandByIdToStream, g as CommandResponseType, h as createAsyncSchedulerWithTimestampProvider, i as rxResource, k as RxEventStream, l as ResourceStatus, n as mapResource, r as resourceFromSnapshots, t as RxResource, v as concatCommand, w as switchCommand, x as dispatchCommandLocallyToPromise, y as dispatchCommandByIdToPromise } from "../rx-B3OU17wu.mjs";
|
|
2
2
|
export { CommandResponseType, ResourceStatus, RxComputedSignal, RxEventReplaySubject, RxEventStream, RxEventSubject, RxResource, RxStateSignal, commandResponseData, concatCommand, createAsyncSchedulerWithTimestampProvider, dispatchCommandByIdToPromise, dispatchCommandByIdToStream, dispatchCommandLocallyToPromise, dispatchCommandLocallyToStream, exhaustCommand, mapResource, resourceFromSnapshots, rxResource, switchCommand, unwrapCommandTerminalResponse };
|
|
@@ -925,7 +925,6 @@ function flattenResourceSnapshot(sourceSnapshot, ...selectors) {
|
|
|
925
925
|
error = snapshot.error;
|
|
926
926
|
}
|
|
927
927
|
snapshot = select(snapshot.value).get();
|
|
928
|
-
break;
|
|
929
928
|
}
|
|
930
929
|
switch (snapshot.status) {
|
|
931
930
|
case ResourceStatus.Idle:
|
|
@@ -1103,4 +1102,4 @@ function rxResource(options) {
|
|
|
1103
1102
|
//#endregion
|
|
1104
1103
|
export { RxEventSubject as A, withDisposableStack as B, exhaustCommand as C, RxStateSignal as D, RxComputedSignal as E, SYMBOL_DISPOSE as F, UserRecovery as G, ClientErrorKind as H, SimpleDisposableStack as I, StdDisposableStack as L, isInteropObservableTrait as M, SYMBOL_ASYNC_DISPOSE as N, RxEventReplaySubject as O, SYMBOL_DISPOSABLE_STACK as P, createDisposableStack as R, dispatchCommandLocallyToStream as S, unwrapCommandTerminalResponse as T, ClientErrorSource as U, ClientError as V, ErrorPresentationTone as W, commandResponseData as _, ResourceSnapshotUpdateKind as a, dispatchCommandByIdToStream as b, whenResourceSnapshotValue as c, ResourceErrorCode as d, CancellationToken as f, CommandResponseType as g, createAsyncSchedulerWithTimestampProvider as h, rxResource as i, SYMBOL_OBSERVABLE as j, RxEventStream as k, ResourceStatus as l, isCancellationTokenTrait as m, mapResource as n, flattenResourceSnapshot as o, createCancellationTokenSource as p, resourceFromSnapshots as r, reduceResourceSnapshot as s, RxResource as t, ResourceError as u, concatCommand as v, switchCommand as w, dispatchCommandLocallyToPromise as x, dispatchCommandByIdToPromise as y, injectDisposableStackFrom as z };
|
|
1105
1104
|
|
|
1106
|
-
//# sourceMappingURL=rx-
|
|
1105
|
+
//# sourceMappingURL=rx-B3OU17wu.mjs.map
|