@securitydept/client 0.3.0-beta.6 → 0.3.0-beta.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/{create-99Ksgl_O.mjs → create-i5VyYgN6.mjs} +58 -21
- package/dist/create-i5VyYgN6.mjs.map +1 -0
- package/dist/{handle-TnxwtQ4T.mjs → handle-DwMgqe7R.mjs} +34 -30
- package/dist/handle-DwMgqe7R.mjs.map +1 -0
- package/dist/{index-DmIapvr-.d.mts → index-B9SEJGU2.d.mts} +61 -63
- package/dist/{index-O1A3CdBV.d.mts → index-BjCFWcmV.d.mts} +17 -4
- package/dist/{index-Cg_iY2yY.d.mts → index-CFAJ969E.d.mts} +79 -13
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +94 -95
- package/dist/index.mjs.map +1 -1
- package/dist/{router-DUh3bhLy.mjs → router-at5bTdJQ.mjs} +3 -3
- package/dist/{router-DUh3bhLy.mjs.map → router-at5bTdJQ.mjs.map} +1 -1
- package/dist/rx/index.d.mts +1 -1
- package/dist/rx/index.mjs +1 -1
- package/dist/{rx-B3OU17wu.mjs → rx-DM6Ouv-m.mjs} +21 -7
- package/dist/rx-DM6Ouv-m.mjs.map +1 -0
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/test/index.d.mts +2 -2
- package/dist/test/index.mjs +2 -2
- package/dist/web/index.d.mts +3 -16
- package/dist/web/index.mjs +4 -4
- package/dist/webext/index.d.mts +2 -2
- package/dist/webext/index.mjs +3 -3
- package/package.json +10 -1
- package/dist/create-99Ksgl_O.mjs.map +0 -1
- package/dist/handle-TnxwtQ4T.mjs.map +0 -1
- package/dist/rx-B3OU17wu.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
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 {\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;AACT;AAgCA,SAAgB,uBACf,SACoC;CACpC,OAAO,cAAc,oBACpB,YAAY;EACX,MAAM,EAAE,gBAAgB,iBAAiB;EACzC,MAAM,UAAyC,CAAC;EAEhD,IAAI,gBACH,QAAQ,KACP,kBACE,YACA,eAAe,iBAAiB,oBAAoB,OAAO,IAC3D,YACA,eAAe,oBAAoB,oBAAoB,OAAO,CAChE,CAAC,CAAC,KACD,UAAU,eAAe,eAAe,GACxC,qBAAqB,GACrB,QAAQ,oBAAoB,oBAAoB,SAAS,GACzD,WAAW,EACV,SAAS,sBAAsB,WAChC,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f,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"}
|
|
1
|
+
{"version":3,"file":"router-at5bTdJQ.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\twind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AS,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,4 +1,4 @@
|
|
|
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-
|
|
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-CFAJ969E.mjs";
|
|
2
2
|
import { Observable, ObservableInput, Observer, OperatorFunction } from "rxjs";
|
|
3
3
|
import { AsyncScheduler } from "rxjs/internal/scheduler/AsyncScheduler";
|
|
4
4
|
//#region src/rx/command.d.ts
|
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-DM6Ouv-m.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 };
|
|
@@ -38,6 +38,7 @@ const ClientErrorSource = {
|
|
|
38
38
|
};
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/errors/client-error.ts
|
|
41
|
+
const CLIENT_ERROR_SPAN_ATTRIBUTE_PROVIDER_ID = "@securitydept/client/error";
|
|
41
42
|
const userRecoveryValues = new Set(Object.values(UserRecovery));
|
|
42
43
|
function readUserRecovery(value) {
|
|
43
44
|
return typeof value === "string" && userRecoveryValues.has(value) ? value : void 0;
|
|
@@ -77,6 +78,7 @@ function readServerErrorBody(body) {
|
|
|
77
78
|
* policy decisions without requiring callers to unwrap `presentation`.
|
|
78
79
|
*/
|
|
79
80
|
var ClientError = class ClientError extends Error {
|
|
81
|
+
_spanContext;
|
|
80
82
|
kind;
|
|
81
83
|
/**
|
|
82
84
|
* Stable machine-readable error code.
|
|
@@ -92,6 +94,9 @@ var ClientError = class ClientError extends Error {
|
|
|
92
94
|
presentation;
|
|
93
95
|
/** Source subsystem or component that produced the error. */
|
|
94
96
|
source;
|
|
97
|
+
get spanContext() {
|
|
98
|
+
return this._spanContext;
|
|
99
|
+
}
|
|
95
100
|
constructor(options) {
|
|
96
101
|
super(options.message, { cause: options.cause });
|
|
97
102
|
this.name = "ClientError";
|
|
@@ -101,6 +106,11 @@ var ClientError = class ClientError extends Error {
|
|
|
101
106
|
this.retryable = options.retryable ?? this.recovery === UserRecovery.Retry;
|
|
102
107
|
this.presentation = options.presentation;
|
|
103
108
|
this.source = options.source;
|
|
109
|
+
if (options.span) this.captureSpanContext(options.span);
|
|
110
|
+
}
|
|
111
|
+
captureSpanContext(span) {
|
|
112
|
+
this._spanContext ??= span.getRootToNodeAttributes({ providerId: CLIENT_ERROR_SPAN_ATTRIBUTE_PROVIDER_ID });
|
|
113
|
+
return this;
|
|
104
114
|
}
|
|
105
115
|
/** Create a `ClientError` from a server error response body. */
|
|
106
116
|
static fromServerError(body, overrides) {
|
|
@@ -118,17 +128,19 @@ var ClientError = class ClientError extends Error {
|
|
|
118
128
|
recovery,
|
|
119
129
|
retryable: recovery === UserRecovery.Retry,
|
|
120
130
|
presentation,
|
|
121
|
-
source: overrides?.source
|
|
131
|
+
source: overrides?.source,
|
|
132
|
+
span: overrides?.span
|
|
122
133
|
});
|
|
123
134
|
}
|
|
124
135
|
static fromUnknown(error, options) {
|
|
125
|
-
if (error instanceof ClientError) return error;
|
|
136
|
+
if (error instanceof ClientError) return options.span ? error.captureSpanContext(options.span) : error;
|
|
126
137
|
return new ClientError({
|
|
127
138
|
kind: ClientErrorKind.Internal,
|
|
128
139
|
message: options.message,
|
|
129
140
|
code: options.code,
|
|
130
141
|
source: options.source,
|
|
131
|
-
cause: error
|
|
142
|
+
cause: error,
|
|
143
|
+
span: options.span
|
|
132
144
|
});
|
|
133
145
|
}
|
|
134
146
|
/**
|
|
@@ -152,7 +164,8 @@ var ClientError = class ClientError extends Error {
|
|
|
152
164
|
} : void 0
|
|
153
165
|
}, {
|
|
154
166
|
kind,
|
|
155
|
-
source
|
|
167
|
+
source,
|
|
168
|
+
span: options.span
|
|
156
169
|
});
|
|
157
170
|
}
|
|
158
171
|
return new ClientError({
|
|
@@ -161,7 +174,8 @@ var ClientError = class ClientError extends Error {
|
|
|
161
174
|
code: serverBody?.code ?? `http.${status}`,
|
|
162
175
|
recovery: fallbackRecovery,
|
|
163
176
|
retryable: status === 408 || status >= 500,
|
|
164
|
-
source
|
|
177
|
+
source,
|
|
178
|
+
span: options.span
|
|
165
179
|
});
|
|
166
180
|
}
|
|
167
181
|
};
|
|
@@ -1100,6 +1114,6 @@ function rxResource(options) {
|
|
|
1100
1114
|
return new RxResource(options);
|
|
1101
1115
|
}
|
|
1102
1116
|
//#endregion
|
|
1103
|
-
export { RxEventSubject as A, withDisposableStack as B, exhaustCommand as C, RxStateSignal as D, RxComputedSignal as E, SYMBOL_DISPOSE as F,
|
|
1117
|
+
export { RxEventSubject as A, withDisposableStack as B, exhaustCommand as C, RxStateSignal as D, RxComputedSignal as E, SYMBOL_DISPOSE as F, ErrorPresentationTone as G, ClientError as H, SimpleDisposableStack as I, UserRecovery as K, 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, ClientErrorKind as U, CLIENT_ERROR_SPAN_ATTRIBUTE_PROVIDER_ID as V, ClientErrorSource 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 };
|
|
1104
1118
|
|
|
1105
|
-
//# sourceMappingURL=rx-
|
|
1119
|
+
//# sourceMappingURL=rx-DM6Ouv-m.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rx-DM6Ouv-m.mjs","names":["BehaviorSubject"],"sources":["../src/errors/types.ts","../src/errors/client-error.ts","../src/compat/disposable.ts","../src/compat/observable.ts","../src/rx/event.ts","../src/rx/signal.ts","../src/rx/command.ts","../src/rx/environment.ts","../src/cancellation/create.ts","../src/signals/error.ts","../src/signals/types.ts","../src/signals/resource-snapshot.ts","../src/rx/resource.ts"],"sourcesContent":["// --- Error model ---\n// Dual-layer: machine-facing runtime error + user-facing presentation / recovery hint.\n\nimport { type SpanNodeAttributes } from \"../span/types\";\n\nexport type ClientErrorSpanContext = readonly SpanNodeAttributes[];\n\n/** Recovery actions the user might take. Aligned with server-side `UserRecovery`. */\nexport const UserRecovery = {\n\tNone: \"none\",\n\tRetry: \"retry\",\n\tRestartFlow: \"restart_flow\",\n\tReauthenticate: \"reauthenticate\",\n\tContactSupport: \"contact_support\",\n} as const;\n\nexport type UserRecovery = (typeof UserRecovery)[keyof typeof UserRecovery];\n\n/** Safe user-facing presentation supplied by a server error response. */\nexport interface ServerErrorPresentation {\n\tcode: string;\n\tmessage: string;\n\trecovery: UserRecovery;\n}\n\nexport const ErrorPresentationTone = {\n\tNeutral: \"neutral\",\n\tWarning: \"warning\",\n\tDanger: \"danger\",\n} as const;\n\nexport type ErrorPresentationTone =\n\t(typeof ErrorPresentationTone)[keyof typeof ErrorPresentationTone];\n\nexport interface ErrorRecoveryActionDescriptor {\n\trecovery: UserRecovery;\n\tlabel: string;\n\thref: string | null;\n}\n\nexport interface ErrorPresentationDescriptor {\n\tcode: string | null;\n\ttitle: string;\n\tdescription: string;\n\trecovery: UserRecovery;\n\ttone: ErrorPresentationTone;\n\tprimaryAction: ErrorRecoveryActionDescriptor | null;\n}\n\nexport interface ReadErrorPresentationDescriptorOptions {\n\tfallbackTitle?: string;\n\tfallbackDescription?: string;\n\tcodePresentations?: Readonly<Record<string, ErrorCodePresentation>>;\n\trecoveryLinks?: Partial<Record<UserRecovery, string>>;\n\trecoveryLabels?: Partial<Record<UserRecovery, string>>;\n\tcontextFormatter?: ClientErrorContextFormatter | null;\n}\n\nexport type ClientErrorContextFormatter = (\n\tcontext: ClientErrorSpanContext,\n) => string | undefined;\n\nexport interface ErrorCodePresentation {\n\ttitle: string;\n\tdescription: string;\n\ttone?: ErrorPresentationTone;\n\trecovery?: UserRecovery;\n}\n\n/** Machine-facing error kind discriminator. */\nexport const ClientErrorKind = {\n\tAuthorization: \"authorization\",\n\tTransport: \"transport\",\n\tServer: \"server\",\n\tProtocol: \"protocol\",\n\tStorage: \"storage\",\n\tConfiguration: \"configuration\",\n\tUnauthenticated: \"unauthenticated\",\n\tUnauthorized: \"unauthorized\",\n\tCancelled: \"cancelled\",\n\tTimeout: \"timeout\",\n\tInternal: \"internal\",\n} as const;\n\nexport type ClientErrorKind =\n\t(typeof ClientErrorKind)[keyof typeof ClientErrorKind];\n\n/** Stable source vocabulary for common client error producers. */\nexport const ClientErrorSource = {\n\tTransport: \"transport\",\n\tServer: \"server\",\n\tClient: \"client\",\n} as const;\n\nexport type ClientErrorSource =\n\t(typeof ClientErrorSource)[keyof typeof ClientErrorSource];\n","import { type SpanTrait } from \"../span/types\";\nimport {\n\tClientErrorKind,\n\tClientErrorSource,\n\ttype ClientErrorSpanContext,\n\ttype ServerErrorPresentation,\n\tUserRecovery,\n\ttype UserRecovery as UserRecoveryType,\n} from \"./types\";\n\nexport const CLIENT_ERROR_SPAN_ATTRIBUTE_PROVIDER_ID =\n\t\"@securitydept/client/error\";\n\ntype ServerErrorBody = {\n\tkind?: string;\n\tcode?: string;\n\tmessage?: string;\n\trecovery?: string;\n\tpresentation?: {\n\t\tcode?: string;\n\t\tmessage?: string;\n\t\trecovery?: string;\n\t};\n};\n\nexport interface ClientErrorFromUnknownOptions {\n\tmessage: string;\n\tcode: string;\n\tsource: string;\n\tspan?: SpanTrait;\n}\n\nexport interface ClientErrorFromHttpResponseOptions {\n\tstatus: number;\n\tbody?: unknown;\n\tsource?: string;\n\tspan?: SpanTrait;\n}\n\nconst userRecoveryValues = new Set<string>(Object.values(UserRecovery));\n\nfunction readUserRecovery(value: unknown): UserRecoveryType | undefined {\n\treturn typeof value === \"string\" && userRecoveryValues.has(value)\n\t\t? (value as UserRecoveryType)\n\t\t: undefined;\n}\n\nfunction mapServerErrorKind(\n\tkind: string | undefined,\n\tstatus: number,\n): ClientErrorKind {\n\tswitch (kind) {\n\t\tcase \"unauthenticated\":\n\t\t\treturn ClientErrorKind.Unauthenticated;\n\t\tcase \"unauthorized\":\n\t\t\treturn ClientErrorKind.Unauthorized;\n\t\tcase \"unavailable\":\n\t\tcase \"internal\":\n\t\t\treturn ClientErrorKind.Server;\n\t\tcase \"invalid_request\":\n\t\tcase \"conflict\":\n\t\t\treturn ClientErrorKind.Protocol;\n\t\tdefault:\n\t\t\treturn status === 401\n\t\t\t\t? ClientErrorKind.Unauthenticated\n\t\t\t\t: status === 403\n\t\t\t\t\t? ClientErrorKind.Unauthorized\n\t\t\t\t\t: status === 408\n\t\t\t\t\t\t? ClientErrorKind.Timeout\n\t\t\t\t\t\t: status >= 500\n\t\t\t\t\t\t\t? ClientErrorKind.Server\n\t\t\t\t\t\t\t: ClientErrorKind.Protocol;\n\t}\n}\n\nfunction readServerErrorBody(body: unknown): ServerErrorBody | undefined {\n\tif (!body || typeof body !== \"object\") {\n\t\treturn undefined;\n\t}\n\tconst record = body as Record<string, unknown>;\n\tconst error =\n\t\trecord.error && typeof record.error === \"object\"\n\t\t\t? (record.error as Record<string, unknown>)\n\t\t\t: record;\n\n\treturn {\n\t\tkind: typeof error.kind === \"string\" ? error.kind : undefined,\n\t\tcode: typeof error.code === \"string\" ? error.code : undefined,\n\t\tmessage: typeof error.message === \"string\" ? error.message : undefined,\n\t\trecovery: typeof error.recovery === \"string\" ? error.recovery : undefined,\n\t\tpresentation:\n\t\t\terror.presentation && typeof error.presentation === \"object\"\n\t\t\t\t? {\n\t\t\t\t\t\tcode:\n\t\t\t\t\t\t\ttypeof (error.presentation as Record<string, unknown>).code ===\n\t\t\t\t\t\t\t\"string\"\n\t\t\t\t\t\t\t\t? ((error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t\t.code as string)\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\ttypeof (error.presentation as Record<string, unknown>).message ===\n\t\t\t\t\t\t\t\"string\"\n\t\t\t\t\t\t\t\t? ((error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t\t.message as string)\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\trecovery:\n\t\t\t\t\t\t\ttypeof (error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t.recovery === \"string\"\n\t\t\t\t\t\t\t\t? ((error.presentation as Record<string, unknown>)\n\t\t\t\t\t\t\t\t\t\t.recovery as string)\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t};\n}\n\n/**\n * Base client error carrying both machine-facing context and an optional\n * user-facing presentation layer.\n *\n * Top-level `code` and `recovery` provide stable machine contracts for\n * policy decisions without requiring callers to unwrap `presentation`.\n */\nexport class ClientError extends Error {\n\tprivate _spanContext: ClientErrorSpanContext | undefined;\n\n\treadonly kind: ClientErrorKind;\n\n\t/**\n\t * Stable machine-readable error code.\n\t * Matches `presentation.code` when present, otherwise a default\n\t * derived from `kind`.\n\t */\n\treadonly code: string;\n\n\t/** Recovery hint at the machine level. */\n\treadonly recovery: UserRecoveryType;\n\n\t/** Whether this error is safe to retry. */\n\treadonly retryable: boolean;\n\n\t/** Structured user-facing error presentation from the server. */\n\treadonly presentation?: ServerErrorPresentation;\n\n\t/** Source subsystem or component that produced the error. */\n\treadonly source?: string;\n\n\tget spanContext(): ClientErrorSpanContext | undefined {\n\t\treturn this._spanContext;\n\t}\n\n\tconstructor(options: {\n\t\tkind: ClientErrorKind;\n\t\tmessage: string;\n\t\tcode?: string;\n\t\trecovery?: UserRecoveryType;\n\t\tretryable?: boolean;\n\t\tpresentation?: ServerErrorPresentation;\n\t\tsource?: string;\n\t\tcause?: unknown;\n\t\tspan?: SpanTrait;\n\t}) {\n\t\tsuper(options.message, { cause: options.cause });\n\t\tthis.name = \"ClientError\";\n\t\tthis.kind = options.kind;\n\t\tthis.code =\n\t\t\toptions.code ?? options.presentation?.code ?? `client.${options.kind}`;\n\t\tthis.recovery =\n\t\t\toptions.recovery ?? options.presentation?.recovery ?? UserRecovery.None;\n\t\tthis.retryable = options.retryable ?? this.recovery === UserRecovery.Retry;\n\t\tthis.presentation = options.presentation;\n\t\tthis.source = options.source;\n\t\tif (options.span) {\n\t\t\tthis.captureSpanContext(options.span);\n\t\t}\n\t}\n\n\tcaptureSpanContext(span: SpanTrait): this {\n\t\tthis._spanContext ??= span.getRootToNodeAttributes({\n\t\t\tproviderId: CLIENT_ERROR_SPAN_ATTRIBUTE_PROVIDER_ID,\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** Create a `ClientError` from a server error response body. */\n\tstatic fromServerError(\n\t\tbody: {\n\t\t\tkind?: string;\n\t\t\tcode?: string;\n\t\t\tmessage?: string;\n\t\t\trecovery?: string;\n\t\t\tpresentation?: {\n\t\t\t\tcode?: string;\n\t\t\t\tmessage?: string;\n\t\t\t\trecovery?: string;\n\t\t\t};\n\t\t},\n\t\toverrides?: {\n\t\t\tkind?: ClientErrorKind;\n\t\t\tsource?: string;\n\t\t\tspan?: SpanTrait;\n\t\t},\n\t): ClientError {\n\t\tconst rawPresentation = body.presentation;\n\t\tconst recovery =\n\t\t\treadUserRecovery(body.recovery) ??\n\t\t\treadUserRecovery(rawPresentation?.recovery) ??\n\t\t\tUserRecovery.None;\n\t\tconst presentation: ServerErrorPresentation | undefined =\n\t\t\trawPresentation?.code && rawPresentation.message\n\t\t\t\t? {\n\t\t\t\t\t\tcode: rawPresentation.code,\n\t\t\t\t\t\tmessage: rawPresentation.message,\n\t\t\t\t\t\trecovery: readUserRecovery(rawPresentation.recovery) ?? recovery,\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\n\t\treturn new ClientError({\n\t\t\tkind: overrides?.kind ?? mapServerErrorKind(body.kind, 400),\n\t\t\tmessage: body.message ?? presentation?.message ?? \"Unknown server error\",\n\t\t\tcode: body.code ?? presentation?.code,\n\t\t\trecovery,\n\t\t\tretryable: recovery === UserRecovery.Retry,\n\t\t\tpresentation,\n\t\t\tsource: overrides?.source,\n\t\t\tspan: overrides?.span,\n\t\t});\n\t}\n\n\tstatic fromUnknown(\n\t\terror: unknown,\n\t\toptions: ClientErrorFromUnknownOptions,\n\t): ClientError {\n\t\tif (error instanceof ClientError) {\n\t\t\treturn options.span ? error.captureSpanContext(options.span) : error;\n\t\t}\n\n\t\treturn new ClientError({\n\t\t\tkind: ClientErrorKind.Internal,\n\t\t\tmessage: options.message,\n\t\t\tcode: options.code,\n\t\t\tsource: options.source,\n\t\t\tcause: error,\n\t\t\tspan: options.span,\n\t\t});\n\t}\n\n\t/**\n\t * Create a `ClientError` from an HTTP response status and optional body.\n\t * Used when a non-success status is unexpected.\n\t */\n\tstatic fromHttpResponse(\n\t\toptions: ClientErrorFromHttpResponseOptions,\n\t): ClientError {\n\t\tconst { status, body } = options;\n\t\tconst serverBody = readServerErrorBody(body);\n\n\t\t// Derive kind and source from HTTP status first — these apply\n\t\t// whether or not the response carries a structured error body.\n\t\tconst kind = mapServerErrorKind(serverBody?.kind, status);\n\n\t\tconst source = options.source ?? ClientErrorSource.Server;\n\t\tconst fallbackRecovery: UserRecoveryType =\n\t\t\tkind === ClientErrorKind.Unauthenticated\n\t\t\t\t? UserRecovery.Reauthenticate\n\t\t\t\t: status === 408 || status >= 500\n\t\t\t\t\t? UserRecovery.Retry\n\t\t\t\t\t: UserRecovery.None;\n\n\t\t// If the server returned a structured error body, preserve it\n\t\t// but keep the status-derived kind/source.\n\t\tif (serverBody?.code && serverBody?.message) {\n\t\t\tconst recovery =\n\t\t\t\treadUserRecovery(serverBody.presentation?.recovery) ??\n\t\t\t\treadUserRecovery(serverBody.recovery) ??\n\t\t\t\tfallbackRecovery;\n\t\t\treturn ClientError.fromServerError(\n\t\t\t\t{\n\t\t\t\t\t...serverBody,\n\t\t\t\t\trecovery,\n\t\t\t\t\tpresentation: serverBody.presentation\n\t\t\t\t\t\t? { ...serverBody.presentation, recovery }\n\t\t\t\t\t\t: undefined,\n\t\t\t\t},\n\t\t\t\t{ kind, source, span: options.span },\n\t\t\t);\n\t\t}\n\n\t\treturn new ClientError({\n\t\t\tkind,\n\t\t\tmessage: serverBody?.message ?? `HTTP ${status}`,\n\t\t\tcode: serverBody?.code ?? `http.${status}`,\n\t\t\trecovery: fallbackRecovery,\n\t\t\tretryable: status === 408 || status >= 500,\n\t\t\tsource,\n\t\t\tspan: options.span,\n\t\t});\n\t}\n}\n","export const SYMBOL_DISPOSE: typeof Symbol.dispose =\n\ttypeof Symbol !== \"undefined\" && Symbol.dispose\n\t\t? Symbol.dispose\n\t\t: (\"@@dispose\" as unknown as typeof Symbol.dispose);\n\nexport interface DisposableTrait {\n\tdispose(): void;\n\t[SYMBOL_DISPOSE](): void;\n}\n\nexport const SYMBOL_ASYNC_DISPOSE: typeof Symbol.asyncDispose =\n\ttypeof Symbol !== \"undefined\" && Symbol.asyncDispose\n\t\t? Symbol.asyncDispose\n\t\t: (\"@@asyncDispose\" as unknown as typeof Symbol.asyncDispose);\n\nexport interface AsyncDisposableTrait {\n\tdispose(): Promise<void>;\n\t[SYMBOL_ASYNC_DISPOSE](): Promise<void>;\n}\n\nexport interface DisposableStackTrait extends DisposableTrait {\n\treadonly disposed: boolean;\n\tuse<T extends DisposableTrait>(disposable: T): T;\n\tdispose(): void;\n\t[SYMBOL_DISPOSE](): void;\n}\n\nexport const SYMBOL_DISPOSABLE_STACK = \"@@disposableStack\";\n\nexport function injectDisposableStackFrom(\n\targ: unknown,\n\tisOptions = false,\n): DisposableStackTrait | undefined {\n\treturn (\n\t\tisOptions && typeof arg === \"object\" && arg !== null\n\t\t\t? (arg as Record<PropertyKey, unknown>)[SYMBOL_DISPOSABLE_STACK]\n\t\t\t: arg\n\t) as DisposableStackTrait | undefined;\n}\n\nexport class SimpleDisposableStack implements DisposableStackTrait {\n\tprivate readonly stack: DisposableTrait[] = [];\n\tdisposed = false;\n\n\tuse<T extends DisposableTrait>(disposable: T): T {\n\t\tif (this.disposed) {\n\t\t\tthrow new ReferenceError(\"Disposable stack is already disposed\");\n\t\t}\n\t\tthis.stack.push(disposable);\n\t\treturn disposable;\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis.disposed = true;\n\t\tconst errors: unknown[] = [];\n\t\tfor (\n\t\t\tlet disposable = this.stack.pop();\n\t\t\tdisposable;\n\t\t\tdisposable = this.stack.pop()\n\t\t) {\n\t\t\ttry {\n\t\t\t\tdisposable.dispose();\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error);\n\t\t\t}\n\t\t}\n\t\tif (errors.length === 1) {\n\t\t\tthrow errors[0];\n\t\t}\n\t\tif (errors.length > 1) {\n\t\t\tthrow new AggregateError(errors, \"Failed to dispose disposable stack\");\n\t\t}\n\t}\n\n\t[SYMBOL_DISPOSE](): void {\n\t\tthis.dispose();\n\t}\n}\n\ninterface NativeDisposableStackLike {\n\treadonly disposed: boolean;\n\tuse<T extends DisposableTrait>(disposable: T): T;\n\tdispose(): void;\n}\n\ntype NativeDisposableStackConstructor = new () => NativeDisposableStackLike;\n\nexport class StdDisposableStack implements DisposableStackTrait {\n\tprivate readonly stack: NativeDisposableStackLike;\n\n\tconstructor(\n\t\tStack: NativeDisposableStackConstructor = (\n\t\t\tglobalThis as typeof globalThis & {\n\t\t\t\tDisposableStack: NativeDisposableStackConstructor;\n\t\t\t}\n\t\t).DisposableStack,\n\t) {\n\t\tthis.stack = new Stack();\n\t}\n\n\tget disposed(): boolean {\n\t\treturn this.stack.disposed;\n\t}\n\n\tuse<T extends DisposableTrait>(disposable: T): T {\n\t\treturn this.stack.use(disposable);\n\t}\n\n\tdispose(): void {\n\t\tthis.stack.dispose();\n\t}\n\n\t[SYMBOL_DISPOSE](): void {\n\t\tthis.dispose();\n\t}\n}\n\nexport function createDisposableStack(): DisposableStackTrait {\n\tconst Stack = (\n\t\tglobalThis as typeof globalThis & {\n\t\t\tDisposableStack?: NativeDisposableStackConstructor;\n\t\t}\n\t).DisposableStack;\n\treturn typeof Stack === \"function\"\n\t\t? new StdDisposableStack(Stack)\n\t\t: new SimpleDisposableStack();\n}\n\nexport function withDisposableStack(index: number, isOptions = false) {\n\treturn <TThis, TArgs extends unknown[], TReturn>(\n\t\ttarget: (this: TThis, ...args: TArgs) => TReturn,\n\t\t_context: ClassMethodDecoratorContext<\n\t\t\tTThis,\n\t\t\t(this: TThis, ...args: TArgs) => TReturn\n\t\t>,\n\t) =>\n\t\tfunction (this: TThis, ...args: TArgs): TReturn {\n\t\t\tconst disposableStack = createDisposableStack();\n\t\t\tconst injectedArgs = [...args] as unknown[];\n\t\t\tif (isOptions) {\n\t\t\t\tconst value = injectedArgs[index];\n\t\t\t\tinjectedArgs[index] = Object.assign(\n\t\t\t\t\t{},\n\t\t\t\t\ttypeof value === \"object\" && value !== null ? value : undefined,\n\t\t\t\t\t{ [SYMBOL_DISPOSABLE_STACK]: disposableStack },\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinjectedArgs[index] = disposableStack;\n\t\t\t}\n\n\t\t\tlet result: TReturn;\n\t\t\ttry {\n\t\t\t\tresult = target.call(this, ...(injectedArgs as TArgs));\n\t\t\t} catch (error) {\n\t\t\t\tdisposableStack.dispose();\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\ttypeof result === \"object\" &&\n\t\t\t\tresult !== null &&\n\t\t\t\t\"then\" in result &&\n\t\t\t\ttypeof result.then === \"function\"\n\t\t\t) {\n\t\t\t\treturn Promise.resolve(result).finally(() => {\n\t\t\t\t\tdisposableStack.dispose();\n\t\t\t\t}) as TReturn;\n\t\t\t}\n\n\t\t\tdisposableStack.dispose();\n\t\t\treturn result;\n\t\t};\n}\n","export const SYMBOL_OBSERVABLE: typeof Symbol.observable =\n\ttypeof Symbol !== \"undefined\" && Symbol.observable\n\t\t? Symbol.observable\n\t\t: (\"@@observable\" as unknown as typeof Symbol.observable);\n\n/** Subscription handle with explicit unsubscribe. */\nexport interface SubscriptionTrait {\n\tunsubscribe(): void;\n}\n\n/** Observer for event streams — mirrors the Observable observer pattern. */\nexport interface ObserverTrait<T> {\n\tnext(value: T): void;\n\terror(error: unknown): void;\n\tcomplete(): void;\n}\n\nexport interface SubscribableTrait<T> {\n\tsubscribe(observer: Partial<ObserverTrait<T>>): SubscriptionTrait;\n}\n\nexport interface InteropObservableTrait<T> {\n\t[SYMBOL_OBSERVABLE](): SubscribableTrait<T>;\n}\n\nexport type WithInteropObservableTraitCompat<\n\tO extends InteropObservableTrait<unknown>,\n\tT extends O extends InteropObservableTrait<infer U> ? U : never,\n> = O & InteropObservableTrait<T>;\n\nexport function isInteropObservableTrait<T>(\n\tvalue: unknown,\n): value is InteropObservableTrait<T> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\tSYMBOL_OBSERVABLE in value &&\n\t\ttypeof value[SYMBOL_OBSERVABLE] === \"function\"\n\t);\n}\n","import {\n\tfrom,\n\tObservable,\n\ttype ObservableInput,\n\ttype OperatorFunction,\n\tReplaySubject,\n\tSubject,\n} from \"rxjs\";\nimport {\n\ttype InteropObservableTrait,\n\tisInteropObservableTrait,\n\ttype SubscribableTrait,\n\tSYMBOL_OBSERVABLE,\n} from \"../compat\";\nimport {\n\ttype EventObserverTrait,\n\ttype EventStreamTrait,\n\ttype EventSubjectTrait,\n} from \"../events/types\";\n\nexport type RxEventStreamProducer<T> = (\n\tobserver: EventObserverTrait<T>,\n) => (() => void) | void;\n\nexport type RxEventStreamInput<T> =\n\t| ObservableInput<T>\n\t| InteropObservableTrait<T>\n\t| SubscribableTrait<T>;\n\nexport class RxEventStream<T>\n\textends Observable<T>\n\timplements EventStreamTrait<T>, InteropObservableTrait<T>\n{\n\tconstructor(source: RxEventStreamInput<T> | RxEventStreamProducer<T>) {\n\t\tsuper((subscriber) => {\n\t\t\tif (typeof source === \"function\") {\n\t\t\t\treturn source(subscriber);\n\t\t\t}\n\t\t\tif (isInteropObservableTrait<T>(source)) {\n\t\t\t\tconst subscription = source[SYMBOL_OBSERVABLE]().subscribe(subscriber);\n\t\t\t\treturn () => {\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t};\n\t\t\t}\n\t\t\tif (\n\t\t\t\ttypeof source === \"object\" &&\n\t\t\t\tsource !== null &&\n\t\t\t\t\"subscribe\" in source &&\n\t\t\t\ttypeof source.subscribe === \"function\"\n\t\t\t) {\n\t\t\t\tconst subscription = source.subscribe(subscriber);\n\t\t\t\treturn () => {\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst subscription = from(source as ObservableInput<T>).subscribe(\n\t\t\t\tsubscriber,\n\t\t\t);\n\t\t\treturn () => {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t};\n\t\t});\n\t}\n\n\t[SYMBOL_OBSERVABLE](): RxEventStream<T> {\n\t\treturn this;\n\t}\n\n\tstatic fromObservableInput<T>(\n\t\tinput: RxEventStreamInput<T>,\n\t): RxEventStream<T> {\n\t\tif (input instanceof RxEventStream) {\n\t\t\treturn input;\n\t\t}\n\t\treturn new RxEventStream(input);\n\t}\n\n\t// @ts-expect-error RxJS pipe overloads are intentionally narrowed to RxEventStream.\n\toverride pipe(): RxEventStream<T>;\n\toverride pipe<A>(op1: OperatorFunction<T, A>): RxEventStream<A>;\n\toverride pipe<A, B>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t): RxEventStream<B>;\n\toverride pipe<A, B, C>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t): RxEventStream<C>;\n\toverride pipe<A, B, C, D>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t\top4: OperatorFunction<C, D>,\n\t): RxEventStream<D>;\n\toverride pipe<A, B, C, D, E>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t\top4: OperatorFunction<C, D>,\n\t\top5: OperatorFunction<D, E>,\n\t): RxEventStream<E>;\n\toverride pipe<A, B, C, D, E, F>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t\top4: OperatorFunction<C, D>,\n\t\top5: OperatorFunction<D, E>,\n\t\top6: OperatorFunction<E, F>,\n\t): RxEventStream<F>;\n\toverride pipe<A, B, C, D, E, F, G>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t\top4: OperatorFunction<C, D>,\n\t\top5: OperatorFunction<D, E>,\n\t\top6: OperatorFunction<E, F>,\n\t\top7: OperatorFunction<F, G>,\n\t): RxEventStream<G>;\n\toverride pipe<A, B, C, D, E, F, G, H>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t\top4: OperatorFunction<C, D>,\n\t\top5: OperatorFunction<D, E>,\n\t\top6: OperatorFunction<E, F>,\n\t\top7: OperatorFunction<F, G>,\n\t\top8: OperatorFunction<G, H>,\n\t): RxEventStream<H>;\n\toverride pipe<A, B, C, D, E, F, G, H, I>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t\top4: OperatorFunction<C, D>,\n\t\top5: OperatorFunction<D, E>,\n\t\top6: OperatorFunction<E, F>,\n\t\top7: OperatorFunction<F, G>,\n\t\top8: OperatorFunction<G, H>,\n\t\top9: OperatorFunction<H, I>,\n\t): RxEventStream<I>;\n\toverride pipe<A, B, C, D, E, F, G, H, I>(\n\t\top1: OperatorFunction<T, A>,\n\t\top2: OperatorFunction<A, B>,\n\t\top3: OperatorFunction<B, C>,\n\t\top4: OperatorFunction<C, D>,\n\t\top5: OperatorFunction<D, E>,\n\t\top6: OperatorFunction<E, F>,\n\t\top7: OperatorFunction<F, G>,\n\t\top8: OperatorFunction<G, H>,\n\t\top9: OperatorFunction<H, I>,\n\t\t...operations: OperatorFunction<any, any>[]\n\t): RxEventStream<unknown>;\n\toverride pipe(\n\t\t...args: Parameters<Observable<T>[\"pipe\"]>\n\t): RxEventStream<unknown> {\n\t\tconst piped = super.pipe(...args);\n\t\treturn RxEventStream.fromObservableInput(piped);\n\t}\n}\n\nexport class RxEventSubject<T>\n\textends Subject<T>\n\timplements EventSubjectTrait<T>\n{\n\t[SYMBOL_OBSERVABLE](): RxEventStream<T> {\n\t\treturn this.asObservable();\n\t}\n\n\toverride asObservable(): RxEventStream<T> {\n\t\treturn RxEventStream.fromObservableInput(super.asObservable());\n\t}\n}\n\nexport class RxEventReplaySubject<T>\n\textends ReplaySubject<T>\n\timplements EventSubjectTrait<T>\n{\n\t[SYMBOL_OBSERVABLE](): RxEventStream<T> {\n\t\treturn this.asObservable();\n\t}\n\n\toverride asObservable(): RxEventStream<T> {\n\t\treturn RxEventStream.fromObservableInput(super.asObservable());\n\t}\n}\n","import {\n\tanimationFrameScheduler,\n\tasapScheduler,\n\taudit,\n\tauditTime,\n\tBehaviorSubject,\n\tconcat,\n\tdefer,\n\tdistinctUntilChanged,\n\tEMPTY,\n\tfromEventPattern,\n\ttype MonoTypeOperatorFunction,\n\tmap,\n\tmerge,\n\ttype Observable,\n\tof,\n\tSubject,\n\tshare,\n\tshareReplay,\n\tswitchMap,\n} from \"rxjs\";\nimport {\n\ttype InteropObservableTrait,\n\tSYMBOL_OBSERVABLE,\n\ttype WithInteropObservableTraitCompat,\n} from \"../compat\";\nimport {\n\ttype ReadableSignalTrait,\n\ttype SignalOptions,\n\ttype WritableSignalTrait,\n} from \"../signals/types\";\nimport { RxEventStream } from \"./event\";\n\nexport interface RxSignalDirtyEvent<T> {\n\tepoch: number;\n\tsignal: ReadableSignalTrait<T>;\n}\n\nexport type RxSignalOptions<T> = SignalOptions<T>;\n\nexport type RxSignalWatchScheduler<THandle = unknown> = (\n\tflush: () => void,\n) => THandle;\n\nexport type RxSignalWatchCanceller<THandle = unknown> = (\n\thandle: THandle,\n) => void;\n\nexport interface RxSignalWatchOptions {\n\tschedule: RxSignalWatchScheduler;\n\tcancel?: RxSignalWatchCanceller;\n}\n\nfunction watchOptionsToAuditOperator<T>(\n\toptions: RxSignalWatchOptions,\n): MonoTypeOperatorFunction<T> {\n\tif (options.schedule === globalThis.queueMicrotask) {\n\t\treturn auditTime(0, asapScheduler);\n\t}\n\tif (\n\t\toptions.schedule === globalThis.requestAnimationFrame &&\n\t\toptions.cancel === globalThis.cancelAnimationFrame\n\t) {\n\t\treturn auditTime(0, animationFrameScheduler);\n\t}\n\treturn audit(() =>\n\t\tfromEventPattern<void>(\n\t\t\t(handler) => options.schedule(() => handler()),\n\t\t\t(_handler, handle) => {\n\t\t\t\tif (options.cancel) {\n\t\t\t\t\toptions.cancel(handle);\n\t\t\t\t} else if (typeof handle === \"function\") {\n\t\t\t\t\thandle();\n\t\t\t\t}\n\t\t\t},\n\t\t),\n\t);\n}\n\nexport abstract class RxSignal<T>\n\timplements ReadableSignalTrait<T>, InteropObservableTrait<T>\n{\n\tprotected static globalEpoch = 0;\n\tprotected static currentContext: RxComputedSignal<any> | null = null;\n\n\tprotected valueEqVersion = 0;\n\n\treadonly equals: (a: unknown, b: unknown) => boolean;\n\tabstract get(): T;\n\tabstract dirtyObservable(): Observable<RxSignalDirtyEvent<T>>;\n\n\tprotected constructor(options: RxSignalOptions<T> | undefined) {\n\t\tthis.equals = (options?.equals ?? Object.is) as (\n\t\t\tleft: unknown,\n\t\t\tright: unknown,\n\t\t) => boolean;\n\t}\n\n\twatchStream(\n\t\toptions: RxSignalWatchOptions = { schedule: globalThis.queueMicrotask },\n\t): RxEventStream<void> {\n\t\treturn RxEventStream.fromObservableInput(\n\t\t\tthis.dirtyObservable().pipe(\n\t\t\t\twatchOptionsToAuditOperator(options),\n\t\t\t\tmap(() => undefined),\n\t\t\t\tshareReplay({ bufferSize: 1, refCount: true }),\n\t\t\t),\n\t\t);\n\t}\n\n\t[SYMBOL_OBSERVABLE](): RxEventStream<T> {\n\t\treturn RxEventStream.fromObservableInput(\n\t\t\tdefer(() =>\n\t\t\t\tconcat(\n\t\t\t\t\tof(this.get()),\n\t\t\t\t\tthis.dirtyObservable().pipe(map(() => this.get())),\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\t}\n\n\tabstract validateForEpoch(epoch: number): void;\n}\n\nexport class RxStateSignal<T>\n\textends RxSignal<T>\n\timplements InteropObservableTrait<T>, WritableSignalTrait<T>\n{\n\tprotected dirtySubject: Subject<RxSignalDirtyEvent<T>> = new Subject();\n\tprotected value: BehaviorSubject<T>;\n\n\tprotected constructor(\n\t\tinitialValue: T,\n\t\toptions: RxSignalOptions<T> | undefined,\n\t) {\n\t\tsuper(options);\n\t\tthis.value = new BehaviorSubject(initialValue);\n\t}\n\n\tset(input: T): void {\n\t\tconst changed = !this.equals(this.value.getValue(), input);\n\t\tthis.value.next(input);\n\t\tif (changed) {\n\t\t\tthis.valueEqVersion += 1;\n\t\t}\n\t\tRxSignal.globalEpoch += 1;\n\t\tthis.dirtySubject.next({\n\t\t\tepoch: RxSignal.globalEpoch,\n\t\t\tsignal: this,\n\t\t});\n\t}\n\n\tstatic fromInitialValue<T>(\n\t\tinitialValue: T,\n\t\toptions?: RxSignalOptions<T>,\n\t): RxStateSignalCompat<T> {\n\t\treturn new RxStateSignal<T>(initialValue, options);\n\t}\n\n\tget(): T {\n\t\tconst value = this.value.getValue();\n\t\tRxSignal.currentContext?.markDependency(this);\n\t\treturn value;\n\t}\n\n\toverride validateForEpoch(): void {}\n\n\toverride dirtyObservable(): Observable<RxSignalDirtyEvent<T>> {\n\t\treturn this.dirtySubject.asObservable();\n\t}\n\n\toverride [SYMBOL_OBSERVABLE](): RxEventStream<T> {\n\t\treturn RxEventStream.fromObservableInput(this.value.asObservable());\n\t}\n}\n\nexport type RxStateSignalCompat<T> = WithInteropObservableTraitCompat<\n\tRxStateSignal<T>,\n\tT\n>;\n\ntype AnyRxSignal = RxSignal<any> & { valueEqVersion: number };\n\ntype ComputedCacheState<T> =\n\t| { kind: \"empty\" }\n\t| { kind: \"value\"; value: T }\n\t| { kind: \"error\"; error: unknown };\n\nfunction haveSameSourceKeys(\n\tleft: ReadonlyMap<AnyRxSignal, number>,\n\tright: ReadonlyMap<AnyRxSignal, number>,\n): boolean {\n\tif (left.size !== right.size) {\n\t\treturn false;\n\t}\n\tconst leftSources = left.keys();\n\tconst rightSources = right.keys();\n\twhile (true) {\n\t\tconst leftSource = leftSources.next();\n\t\tconst rightSource = rightSources.next();\n\t\tif (leftSource.done || rightSource.done) {\n\t\t\treturn leftSource.done === rightSource.done;\n\t\t}\n\t\tif (leftSource.value !== rightSource.value) {\n\t\t\treturn false;\n\t\t}\n\t}\n}\n\nexport class RxComputedSignal<T> extends RxSignal<T> {\n\tprotected cacheState: ComputedCacheState<T> = { kind: \"empty\" };\n\tprotected sources: ReadonlyMap<AnyRxSignal, number> = new Map();\n\tprotected sourcesSubject: BehaviorSubject<ReadonlyMap<AnyRxSignal, number>> =\n\t\tnew BehaviorSubject(this.sources);\n\tprivate validatedEpoch = -1;\n\tprivate isComputing = false;\n\tprivate collectingSources: Map<AnyRxSignal, number> | null = null;\n\tprivate dirty$: Observable<RxSignalDirtyEvent<T>> | undefined;\n\n\tprotected constructor(\n\t\tprotected readonly computeFn: () => T,\n\t\toptions: RxSignalOptions<T> | undefined,\n\t) {\n\t\tsuper(options);\n\t}\n\n\tmarkDependency(signal: RxSignal<any>): void {\n\t\tconst source = signal as AnyRxSignal;\n\t\tthis.collectingSources?.set(source, source.valueEqVersion);\n\t}\n\n\tprotected cacheStatesEqual(\n\t\tleft: ComputedCacheState<T>,\n\t\tright: ComputedCacheState<T>,\n\t): boolean {\n\t\tif (left.kind !== right.kind) {\n\t\t\treturn false;\n\t\t}\n\t\tif (left.kind === \"empty\" || right.kind === \"empty\") {\n\t\t\treturn false;\n\t\t}\n\t\tif (left.kind === \"value\" && right.kind === \"value\") {\n\t\t\treturn this.equals(left.value, right.value);\n\t\t}\n\t\tif (left.kind === \"error\" && right.kind === \"error\") {\n\t\t\treturn Object.is(left.error, right.error);\n\t\t}\n\t\treturn false;\n\t}\n\n\tprotected recompute(): void {\n\t\tif (this.isComputing) {\n\t\t\tthrow new Error(\"Circular computed dependency detected\");\n\t\t}\n\t\tconst prevContext = RxSignal.currentContext;\n\t\tconst prevCollectingSources = this.collectingSources;\n\t\tconst nextSources = new Map<AnyRxSignal, number>();\n\t\tRxSignal.currentContext = this;\n\t\tthis.collectingSources = nextSources;\n\t\tthis.isComputing = true;\n\t\tlet nextCacheState: ComputedCacheState<T>;\n\t\ttry {\n\t\t\tconst computed = this.computeFn();\n\t\t\tnextCacheState = { kind: \"value\", value: computed };\n\t\t} catch (error) {\n\t\t\tnextCacheState = { kind: \"error\", error };\n\t\t} finally {\n\t\t\tthis.collectingSources = prevCollectingSources;\n\t\t\tRxSignal.currentContext = prevContext;\n\t\t\tthis.isComputing = false;\n\t\t}\n\t\tconst sourcesChanged = !haveSameSourceKeys(this.sources, nextSources);\n\t\tlet cacheStateChanged: boolean;\n\t\ttry {\n\t\t\tcacheStateChanged = !this.cacheStatesEqual(\n\t\t\t\tthis.cacheState,\n\t\t\t\tnextCacheState,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tnextCacheState = { kind: \"error\", error };\n\t\t\tcacheStateChanged = !this.cacheStatesEqual(\n\t\t\t\tthis.cacheState,\n\t\t\t\tnextCacheState,\n\t\t\t);\n\t\t}\n\t\tif (cacheStateChanged) {\n\t\t\tthis.valueEqVersion += 1;\n\t\t}\n\t\tthis.cacheState = nextCacheState;\n\t\tthis.sources = nextSources;\n\t\tif (sourcesChanged) {\n\t\t\tthis.sourcesSubject.next(nextSources);\n\t\t}\n\t\tif (nextCacheState.kind === \"error\") {\n\t\t\tthrow nextCacheState.error;\n\t\t}\n\t}\n\n\toverride validateForEpoch(epoch: number): void {\n\t\tif (this.validatedEpoch === epoch) {\n\t\t\treturn;\n\t\t}\n\t\ttry {\n\t\t\tif (this.cacheState.kind === \"empty\") {\n\t\t\t\tthis.recompute();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfor (const [source, version] of this.sources) {\n\t\t\t\ttry {\n\t\t\t\t\tsource.validateForEpoch(epoch);\n\t\t\t\t} catch {\n\t\t\t\t\tthis.recompute();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tif (source.valueEqVersion !== version) {\n\t\t\t\t\tthis.recompute();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tthis.validatedEpoch = epoch;\n\t\t}\n\t}\n\n\toverride get(): T {\n\t\tthis.validateForEpoch(RxSignal.globalEpoch);\n\t\tRxSignal.currentContext?.markDependency(this);\n\t\tswitch (this.cacheState.kind) {\n\t\t\tcase \"value\":\n\t\t\t\treturn this.cacheState.value;\n\t\t\tcase \"error\":\n\t\t\t\tthrow this.cacheState.error;\n\t\t\tcase \"empty\":\n\t\t\t\tthrow new Error(\"Computed signal has not been initialized\");\n\t\t}\n\t}\n\n\toverride dirtyObservable(): Observable<RxSignalDirtyEvent<T>> {\n\t\tif (!this.dirty$) {\n\t\t\tthis.dirty$ = defer(() => {\n\t\t\t\tthis.validateForEpoch(RxSignal.globalEpoch);\n\t\t\t\treturn this.sourcesSubject.asObservable().pipe(\n\t\t\t\t\tswitchMap((sources) =>\n\t\t\t\t\t\tsources.size === 0\n\t\t\t\t\t\t\t? EMPTY\n\t\t\t\t\t\t\t: merge(\n\t\t\t\t\t\t\t\t\t...[...sources.keys()].map((source) =>\n\t\t\t\t\t\t\t\t\t\tsource.dirtyObservable(),\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t).pipe(\n\t\t\t\t\t\t\t\t\tdistinctUntilChanged(\n\t\t\t\t\t\t\t\t\t\t(left, right) => left.epoch === right.epoch,\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tmap((dirtyDepEvent) => {\n\t\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\t\tepoch: dirtyDepEvent.epoch,\n\t\t\t\t\t\t\t\t\t\t\tsignal: this,\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}).pipe(share());\n\t\t}\n\t\treturn this.dirty$;\n\t}\n\n\tstatic computed<T>(\n\t\tfn: () => T,\n\t\toptions?: RxSignalOptions<T>,\n\t): RxComputedSignalCompat<T> {\n\t\treturn new RxComputedSignal<T>(fn, options);\n\t}\n}\n\nexport type RxComputedSignalCompat<T> = WithInteropObservableTraitCompat<\n\tRxComputedSignal<T>,\n\tT\n>;\n","/** biome-ignore-all lint/complexity/noBannedTypes: false negative */\nimport {\n\tconcatAll,\n\tfilter,\n\tfrom,\n\tlastValueFrom,\n\tmap,\n\tObservable,\n\ttype ObservableInput,\n\ttype Observer,\n\ttype OperatorFunction,\n\ttype Subscription,\n\ttakeLast,\n\ttakeWhile,\n\ttoArray,\n} from \"rxjs\";\nimport { ClientError, ClientErrorKind } from \"../errors\";\n\nexport const CommandResponseType = {\n\tData: \"data\",\n\tSuccess: \"success\",\n\tError: \"error\",\n\tCancel: \"cancel\",\n\tRejected: \"rejected\",\n} as const;\n\nexport type CommandResponseType =\n\t(typeof CommandResponseType)[keyof typeof CommandResponseType];\n\nexport type Command<Payload = unknown, Extra extends {} = {}> = Extra & {\n\treadonly payload: Payload;\n};\n\nexport type CommandDataResponse<TCmd extends Command, TData = unknown> = {\n\treadonly type: typeof CommandResponseType.Data;\n\treadonly command: TCmd;\n\treadonly data: TData;\n};\n\nexport type CommandSuccessResponse<TCmd extends Command> = {\n\treadonly type: typeof CommandResponseType.Success;\n\treadonly command: TCmd;\n};\n\nexport type CommandErrorResponse<TCmd extends Command> = {\n\treadonly type: typeof CommandResponseType.Error;\n\treadonly command: TCmd;\n\treadonly error: unknown;\n};\n\nexport type CommandCancelResponse<TCmd extends Command> = {\n\treadonly type: typeof CommandResponseType.Cancel;\n\treadonly command: TCmd;\n};\n\nexport type CommandRejectedResponse<TCmd extends Command> = {\n\treadonly type: typeof CommandResponseType.Rejected;\n\treadonly command: TCmd;\n\treadonly reason: string;\n};\n\nexport type CommandTerminalResponse<TCmd extends Command> =\n\t| CommandSuccessResponse<TCmd>\n\t| CommandErrorResponse<TCmd>\n\t| CommandCancelResponse<TCmd>\n\t| CommandRejectedResponse<TCmd>;\n\nexport type CommandResponse<TCmd extends Command, TData = unknown> =\n\t| CommandDataResponse<TCmd, TData>\n\t| CommandTerminalResponse<TCmd>;\n\nexport interface DispatchCommandBaseOptions<\n\tTCmd extends Command,\n\tTData = unknown,\n> {\n\treadonly requestStream: Pick<Observer<TCmd>, \"next\">;\n\treadonly responseStream: ObservableInput<CommandResponse<TCmd, TData>>;\n}\n\nexport interface DispatchCommandLocallyOptions<\n\tTPayload,\n\tTCommandExtra extends {} = {},\n\tTData = unknown,\n\tTCmd extends Command<TPayload, TCommandExtra> = Command<\n\t\tTPayload,\n\t\tTCommandExtra\n\t>,\n> extends DispatchCommandBaseOptions<TCmd, TData> {\n\treadonly payload: TPayload;\n\treadonly createCommandExtra?: (payload: TPayload) => TCommandExtra;\n}\n\nexport interface DispatchCommandByIdOptions<\n\tTCmd extends Command,\n\tTId,\n\tTData = unknown,\n> extends DispatchCommandBaseOptions<TCmd, TData> {\n\treadonly command: TCmd;\n\treadonly selectCommandId: (command: TCmd) => TId;\n\treadonly areIdsEqual?: (left: TId, right: TId) => boolean;\n}\n\nfunction createCommandCancellationError<TCmd extends Command>(\n\tcommand: TCmd,\n): Error {\n\treturn new ClientError({\n\t\tkind: ClientErrorKind.Cancelled,\n\t\tmessage: \"Command was cancelled before completion\",\n\t\tcause: {\n\t\t\tcommand,\n\t\t},\n\t});\n}\n\nfunction createCommandRejectedError<TCmd extends Command>(\n\tcommand: TCmd,\n\treason: string,\n): Error {\n\treturn new ClientError({\n\t\tkind: ClientErrorKind.Cancelled,\n\t\tmessage: `Command was rejected before execution: ${reason}`,\n\t\tcause: {\n\t\t\tcommand,\n\t\t\treason,\n\t\t},\n\t});\n}\n\nexport function isCommandDataResponse<TCmd extends Command, TData>(\n\tresponse: CommandResponse<TCmd, TData>,\n): response is CommandDataResponse<TCmd, TData> {\n\treturn response.type === CommandResponseType.Data;\n}\n\nexport function isCommandTerminalResponse<TCmd extends Command, TData>(\n\tresponse: CommandResponse<TCmd, TData>,\n): response is CommandTerminalResponse<TCmd> {\n\treturn response.type !== CommandResponseType.Data;\n}\n\nfunction dispatchCommand<TCmd extends Command, TData>(\n\tdispatch: () => void,\n\tmatches: (response: CommandResponse<TCmd, TData>) => boolean,\n): OperatorFunction<\n\tCommandResponse<TCmd, TData>,\n\tCommandResponse<TCmd, TData>\n> {\n\treturn (source$) =>\n\t\tnew Observable<CommandResponse<TCmd, TData>>((subscriber) => {\n\t\t\tconst subscription = source$\n\t\t\t\t.pipe(filter(matches), takeWhile(isCommandDataResponse, true))\n\t\t\t\t.subscribe(subscriber);\n\n\t\t\tif (subscription.closed) {\n\t\t\t\treturn subscription;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\tdispatch();\n\t\t\t} catch (error) {\n\t\t\t\tif (!subscription.closed) {\n\t\t\t\t\tsubscriber.error(error);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn subscription;\n\t\t});\n}\n\nexport function unwrapCommandTerminalResponse<TCmd extends Command>(\n\tresponse: CommandTerminalResponse<TCmd>,\n): void {\n\tswitch (response.type) {\n\t\tcase CommandResponseType.Success:\n\t\t\treturn;\n\t\tcase CommandResponseType.Error:\n\t\t\tthrow response.error;\n\t\tcase CommandResponseType.Cancel:\n\t\t\tthrow createCommandCancellationError(response.command);\n\t\tcase CommandResponseType.Rejected:\n\t\t\tthrow createCommandRejectedError(response.command, response.reason);\n\t}\n}\n\nexport function commandResponseData<\n\tTCmd extends Command,\n\tTData,\n>(): OperatorFunction<CommandResponse<TCmd, TData>, TData> {\n\treturn (source$) =>\n\t\tsource$.pipe(\n\t\t\tfilter((response): response is CommandDataResponse<TCmd, TData> => {\n\t\t\t\tif (isCommandDataResponse(response)) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tunwrapCommandTerminalResponse(response);\n\t\t\t\treturn false;\n\t\t\t}),\n\t\t\tmap((response) => response.data),\n\t\t);\n}\n\nexport function dispatchCommandLocallyToStream<\n\tTPayload,\n\tTCommandExtra extends {} = {},\n\tTData = unknown,\n\tTCmd extends Command<TPayload, TCommandExtra> = Command<\n\t\tTPayload,\n\t\tTCommandExtra\n\t>,\n>(\n\toptions: DispatchCommandLocallyOptions<TPayload, TCommandExtra, TData, TCmd>,\n): Observable<CommandResponse<TCmd, TData>> {\n\tconst command = {\n\t\tpayload: options.payload,\n\t\t...(options.createCommandExtra?.(options.payload) ?? {}),\n\t} as TCmd;\n\n\treturn from(options.responseStream).pipe(\n\t\tdispatchCommand(\n\t\t\t() => {\n\t\t\t\toptions.requestStream.next(command);\n\t\t\t},\n\t\t\t(response) => response.command === command,\n\t\t),\n\t);\n}\n\nexport function dispatchCommandByIdToStream<\n\tTCmd extends Command,\n\tTId,\n\tTData = unknown,\n>(\n\toptions: DispatchCommandByIdOptions<TCmd, TId, TData>,\n): Observable<CommandResponse<TCmd, TData>> {\n\tconst areIdsEqual = options.areIdsEqual ?? Object.is;\n\tconst commandId = options.selectCommandId(options.command);\n\n\treturn from(options.responseStream).pipe(\n\t\tdispatchCommand(\n\t\t\t() => {\n\t\t\t\toptions.requestStream.next(options.command);\n\t\t\t},\n\t\t\t(response) =>\n\t\t\t\tareIdsEqual(options.selectCommandId(response.command), commandId),\n\t\t),\n\t);\n}\n\nexport async function dispatchCommandLocallyToPromise<\n\tTPayload,\n\tTCommandExtra extends {} = {},\n\tTData = unknown,\n\tTCmd extends Command<TPayload, TCommandExtra> = Command<\n\t\tTPayload,\n\t\tTCommandExtra\n\t>,\n>(\n\toptions: DispatchCommandLocallyOptions<\n\t\tTPayload,\n\t\tTCommandExtra,\n\t\tTData,\n\t\tTCmd\n\t> & {},\n): Promise<CommandDataResponse<TCmd, TData>> {\n\tconst [data, terminal] = await lastValueFrom(\n\t\tdispatchCommandLocallyToStream(options).pipe(takeLast(2), toArray()),\n\t\t{\n\t\t\tdefaultValue: [],\n\t\t},\n\t);\n\tif (data === undefined) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\tmessage:\n\t\t\t\t\"the executor configuration of dispatchCommandLocallyToPromise should produce a valid data response.\",\n\t\t});\n\t}\n\tif (!isCommandDataResponse(data)) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\tmessage:\n\t\t\t\t\"the executor configuration of dispatchCommandLocallyToPromise should produce a valid data response.\",\n\t\t});\n\t}\n\tif (terminal === undefined) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Internal,\n\t\t\tmessage:\n\t\t\t\t\"the execution of dispatchCommandLocallyToPromise must produce a valid terminal response.\",\n\t\t});\n\t}\n\tif (!isCommandTerminalResponse(terminal)) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Internal,\n\t\t\tmessage:\n\t\t\t\t\"the execution of dispatchCommandLocallyToPromise must produce a valid terminal response.\",\n\t\t});\n\t}\n\tunwrapCommandTerminalResponse(terminal);\n\treturn data;\n}\n\nexport async function dispatchCommandByIdToPromise<\n\tTCmd extends Command,\n\tTId,\n\tTData = unknown,\n>(\n\toptions: DispatchCommandByIdOptions<TCmd, TId, TData>,\n): Promise<CommandDataResponse<TCmd, TData>> {\n\tconst [data, terminal] = await lastValueFrom(\n\t\tdispatchCommandByIdToStream(options).pipe(takeLast(2), toArray()),\n\t\t{\n\t\t\tdefaultValue: [],\n\t\t},\n\t);\n\tif (data === undefined) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\tmessage:\n\t\t\t\t\"the executor configuration of dispatchCommandLocallyToPromise should produce a valid data response.\",\n\t\t});\n\t}\n\tif (!isCommandDataResponse(data)) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Configuration,\n\t\t\tmessage:\n\t\t\t\t\"the executor configuration of dispatchCommandLocallyToPromise should produce a valid data response.\",\n\t\t});\n\t}\n\tif (terminal === undefined) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Internal,\n\t\t\tmessage:\n\t\t\t\t\"the execution of dispatchCommandLocallyToPromise must produce a valid terminal response.\",\n\t\t});\n\t}\n\tif (!isCommandTerminalResponse(terminal)) {\n\t\tthrow new ClientError({\n\t\t\tkind: ClientErrorKind.Internal,\n\t\t\tmessage:\n\t\t\t\t\"the execution of dispatchCommandLocallyToPromise must produce a valid terminal response.\",\n\t\t});\n\t}\n\tunwrapCommandTerminalResponse(terminal);\n\treturn data;\n}\n\nfunction createCommandExecutionStream<\n\tTCmd extends Command,\n\tTData = unknown,\n>(options: {\n\treadonly command: TCmd;\n\treadonly execute: (command: TCmd) => ObservableInput<TData>;\n\treadonly onStateEnd?: (command: TCmd) => void;\n}): Observable<CommandResponse<TCmd, TData>> {\n\treturn new Observable<CommandResponse<TCmd, TData>>((subscriber) => {\n\t\tlet didEmitTerminal = false;\n\n\t\tconst emitTerminal = (response: CommandTerminalResponse<TCmd>) => {\n\t\t\tif (didEmitTerminal) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdidEmitTerminal = true;\n\t\t\tsubscriber.next(response);\n\t\t\tsubscriber.complete();\n\t\t};\n\n\t\tconst subscription = from(options.execute(options.command)).subscribe({\n\t\t\tnext: (data) => {\n\t\t\t\tsubscriber.next({\n\t\t\t\t\ttype: CommandResponseType.Data,\n\t\t\t\t\tcommand: options.command,\n\t\t\t\t\tdata,\n\t\t\t\t});\n\t\t\t},\n\t\t\terror: (error) => {\n\t\t\t\temitTerminal({\n\t\t\t\t\ttype: CommandResponseType.Error,\n\t\t\t\t\tcommand: options.command,\n\t\t\t\t\terror,\n\t\t\t\t});\n\t\t\t},\n\t\t\tcomplete: () => {\n\t\t\t\temitTerminal({\n\t\t\t\t\ttype: CommandResponseType.Success,\n\t\t\t\t\tcommand: options.command,\n\t\t\t\t});\n\t\t\t},\n\t\t});\n\n\t\treturn () => {\n\t\t\tconst wasTerminalEmitted = didEmitTerminal;\n\t\t\tsubscription.unsubscribe();\n\t\t\toptions.onStateEnd?.(options.command);\n\n\t\t\tif (!wasTerminalEmitted) {\n\t\t\t\tsubscriber.next({\n\t\t\t\t\ttype: CommandResponseType.Cancel,\n\t\t\t\t\tcommand: options.command,\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\t});\n}\n\nexport function switchCommand<TCmd extends Command, TData = unknown>(\n\texecute: (command: TCmd) => ObservableInput<TData>,\n): OperatorFunction<TCmd, CommandResponse<TCmd, TData>> {\n\treturn (source$) =>\n\t\tnew Observable<CommandResponse<TCmd, TData>>((destination) => {\n\t\t\tlet innerSubscription: Subscription | null = null;\n\t\t\tlet currentCommand: TCmd | null = null;\n\t\t\tlet isComplete = false;\n\n\t\t\tconst checkComplete = () => {\n\t\t\t\tif (isComplete && !innerSubscription) {\n\t\t\t\t\tdestination.complete();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst sourceSubscription = source$.subscribe({\n\t\t\t\tnext: (command) => {\n\t\t\t\t\tconst cancelledCommand = currentCommand;\n\n\t\t\t\t\tinnerSubscription?.unsubscribe();\n\t\t\t\t\tinnerSubscription = null;\n\t\t\t\t\tcurrentCommand = null;\n\n\t\t\t\t\tif (cancelledCommand) {\n\t\t\t\t\t\tdestination.next({\n\t\t\t\t\t\t\ttype: CommandResponseType.Cancel,\n\t\t\t\t\t\t\tcommand: cancelledCommand,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentCommand = command;\n\t\t\t\t\tlet didCompleteSynchronously = false;\n\t\t\t\t\tconst nextInnerSubscription = createCommandExecutionStream({\n\t\t\t\t\t\tcommand,\n\t\t\t\t\t\texecute,\n\t\t\t\t\t}).subscribe({\n\t\t\t\t\t\tnext: (response) => {\n\t\t\t\t\t\t\tdestination.next(response);\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: (error) => {\n\t\t\t\t\t\t\tdestination.error(error);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcomplete: () => {\n\t\t\t\t\t\t\tdidCompleteSynchronously = true;\n\t\t\t\t\t\t\tinnerSubscription = null;\n\t\t\t\t\t\t\tcurrentCommand = null;\n\t\t\t\t\t\t\tcheckComplete();\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!didCompleteSynchronously) {\n\t\t\t\t\t\tinnerSubscription = nextInnerSubscription;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: (error) => {\n\t\t\t\t\tdestination.error(error);\n\t\t\t\t},\n\t\t\t\tcomplete: () => {\n\t\t\t\t\tisComplete = true;\n\t\t\t\t\tcheckComplete();\n\t\t\t\t},\n\t\t\t});\n\n\t\t\treturn () => {\n\t\t\t\tsourceSubscription.unsubscribe();\n\t\t\t\tinnerSubscription?.unsubscribe();\n\t\t\t};\n\t\t});\n}\n\nexport function concatCommand<TCmd extends Command, TData = unknown>(\n\texecute: (command: TCmd) => ObservableInput<TData>,\n): OperatorFunction<TCmd, CommandResponse<TCmd, TData>> {\n\treturn (source$: Observable<TCmd>) =>\n\t\tsource$.pipe(\n\t\t\tmap((command) =>\n\t\t\t\tcreateCommandExecutionStream({\n\t\t\t\t\tcommand,\n\t\t\t\t\texecute,\n\t\t\t\t}),\n\t\t\t),\n\t\t\tconcatAll(),\n\t\t);\n}\n\nexport const exhaustCommand =\n\t<TCmd extends Command, TData = unknown>(\n\t\texecute: (command: TCmd) => ObservableInput<TData>,\n\t) =>\n\t(source$: Observable<TCmd>) =>\n\t\tnew Observable<CommandResponse<TCmd, TData>>((destination) => {\n\t\t\tlet innerSubscription: Subscription | null = null;\n\t\t\tlet isComplete = false;\n\n\t\t\tconst checkComplete = () => {\n\t\t\t\tif (isComplete && !innerSubscription) {\n\t\t\t\t\tdestination.complete();\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst sourceSubscription = source$.subscribe({\n\t\t\t\tnext: (command) => {\n\t\t\t\t\tif (innerSubscription) {\n\t\t\t\t\t\tdestination.next({\n\t\t\t\t\t\t\ttype: CommandResponseType.Rejected,\n\t\t\t\t\t\t\tcommand,\n\t\t\t\t\t\t\treason: \"Pessimistic lock active.\",\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tlet didCompleteSynchronously = false;\n\t\t\t\t\tconst nextInnerSubscription = createCommandExecutionStream({\n\t\t\t\t\t\tcommand,\n\t\t\t\t\t\texecute,\n\t\t\t\t\t}).subscribe({\n\t\t\t\t\t\tnext: (response) => {\n\t\t\t\t\t\t\tdestination.next(response);\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror: (error) => {\n\t\t\t\t\t\t\tdestination.error(error);\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcomplete: () => {\n\t\t\t\t\t\t\tdidCompleteSynchronously = true;\n\t\t\t\t\t\t\tinnerSubscription = null;\n\t\t\t\t\t\t\tcheckComplete();\n\t\t\t\t\t\t},\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!didCompleteSynchronously) {\n\t\t\t\t\t\tinnerSubscription = nextInnerSubscription;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: (error) => {\n\t\t\t\t\tdestination.error(error);\n\t\t\t\t},\n\t\t\t\tcomplete: () => {\n\t\t\t\t\tisComplete = true;\n\t\t\t\t\tcheckComplete();\n\t\t\t\t},\n\t\t\t});\n\n\t\t\treturn () => {\n\t\t\t\tsourceSubscription.unsubscribe();\n\t\t\t\tinnerSubscription?.unsubscribe();\n\t\t\t};\n\t\t});\n","import { AsyncAction } from \"rxjs/internal/scheduler/AsyncAction\";\nimport { AsyncScheduler } from \"rxjs/internal/scheduler/AsyncScheduler\";\nimport { type TimerHandle } from \"rxjs/internal/scheduler/timerHandle\";\nimport { type TimeTrait } from \"../scheduling\";\n\nexport function createAsyncSchedulerWithTimestampProvider(\n\ttime: TimeTrait,\n): AsyncScheduler {\n\tclass TimeTraitAsyncAction<T> extends AsyncAction<T> {\n\t\tprotected override requestAsyncId(\n\t\t\tscheduler: AsyncScheduler,\n\t\t\t_id?: TimerHandle,\n\t\t\tdelay = 0,\n\t\t): TimerHandle {\n\t\t\treturn time.setTimeout(() => {\n\t\t\t\tscheduler.flush(this);\n\t\t\t}, delay) as TimerHandle;\n\t\t}\n\n\t\tprotected override recycleAsyncId(\n\t\t\t_scheduler: AsyncScheduler,\n\t\t\tid?: TimerHandle,\n\t\t\tdelay: number | null = 0,\n\t\t): TimerHandle | undefined {\n\t\t\tif (delay != null && this.delay === delay && this.pending === false) {\n\t\t\t\treturn id;\n\t\t\t}\n\n\t\t\tif (id !== undefined) {\n\t\t\t\ttime.clearTimeout(id);\n\t\t\t}\n\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\treturn new AsyncScheduler(TimeTraitAsyncAction, time.now);\n}\n","import { filter, map, type Observable, take } from \"rxjs\";\nimport { BehaviorSubject } from \"rxjs/internal/BehaviorSubject\";\nimport {\n\ttype DisposableTrait,\n\tisInteropObservableTrait,\n\tSYMBOL_DISPOSE,\n\tSYMBOL_OBSERVABLE,\n} from \"../compat\";\nimport { ClientError } from \"../errors/client-error\";\nimport { ClientErrorKind, ClientErrorSource } from \"../errors/types\";\nimport {\n\ttype CancellationTokenErrorData,\n\ttype CancellationTokenSourceTrait,\n\ttype CancellationTokenTrait,\n} from \"./types\";\n\ninterface CancellationTokenCancelledState extends CancellationTokenErrorData {\n\treadonly isCancelled: true;\n}\n\ntype CancellationTokenUncancelledState = undefined;\n\ntype CancellationTokenState =\n\t| CancellationTokenCancelledState\n\t| CancellationTokenUncancelledState;\n\nexport class CancellationToken implements CancellationTokenTrait {\n\tprivate cancellationState = new BehaviorSubject<CancellationTokenState>(\n\t\tundefined,\n\t);\n\n\tget isCancellationRequested(): boolean {\n\t\treturn this.cancellationState.getValue()?.isCancelled === true;\n\t}\n\n\tget reason(): unknown {\n\t\treturn this.cancellationState.getValue()?.reason;\n\t}\n\n\t/** @internal — called by `CancellationTokenSource`. */\n\t_cancel(reason: unknown): void {\n\t\tif (this.isCancellationRequested) {\n\t\t\treturn;\n\t\t}\n\t\tthis.cancellationState.next({\n\t\t\tisCancelled: true,\n\t\t\treason,\n\t\t\tcancellationError: new ClientError({\n\t\t\t\tkind: ClientErrorKind.Cancelled,\n\t\t\t\tmessage: \"Operation was cancelled\",\n\t\t\t\tcode: \"client.cancelled\",\n\t\t\t\tsource: ClientErrorSource.Client,\n\t\t\t\tcause: reason,\n\t\t\t}),\n\t\t});\n\t}\n\n\tonCancellationRequested(\n\t\tlistener: (errorData: CancellationTokenErrorData) => void,\n\t): DisposableTrait {\n\t\tconst cancellationState = this.cancellationState.getValue();\n\t\tif (cancellationState?.isCancelled) {\n\t\t\tlistener({\n\t\t\t\tcancellationError: cancellationState.cancellationError,\n\t\t\t\treason: cancellationState.reason,\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tdispose() {},\n\t\t\t\t[SYMBOL_DISPOSE]() {},\n\t\t\t};\n\t\t}\n\n\t\tconst subscription = this.asObservable().subscribe((errorData) => {\n\t\t\tlistener(errorData);\n\t\t});\n\n\t\treturn {\n\t\t\tdispose() {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t},\n\t\t\t[SYMBOL_DISPOSE]: () => {\n\t\t\t\tsubscription.unsubscribe();\n\t\t\t},\n\t\t};\n\t}\n\n\tthrowIfCancellationRequested(): void {\n\t\tconst cancellationState = this.cancellationState.getValue();\n\t\tif (cancellationState?.cancellationError) {\n\t\t\tthrow cancellationState.cancellationError;\n\t\t}\n\t}\n\n\tget cancellationError(): ClientError | undefined {\n\t\tconst cancellationState = this.cancellationState.getValue();\n\t\treturn cancellationState?.cancellationError;\n\t}\n\n\tprotected asObservable(): Observable<CancellationTokenErrorData> {\n\t\treturn this.cancellationState.pipe(\n\t\t\tfilter(\n\t\t\t\t(state): state is CancellationTokenCancelledState =>\n\t\t\t\t\t!!state?.isCancelled,\n\t\t\t),\n\t\t\ttake(1),\n\t\t\tmap((state) => ({\n\t\t\t\tcancellationError: state.cancellationError,\n\t\t\t\treason: state.reason,\n\t\t\t})),\n\t\t);\n\t}\n\n\t[SYMBOL_OBSERVABLE]() {\n\t\treturn this.asObservable();\n\t}\n}\n\nexport class CancellationTokenSource implements CancellationTokenSourceTrait {\n\treadonly token = new CancellationToken();\n\n\tcancel(reason?: unknown) {\n\t\tthis.token._cancel(reason);\n\t}\n}\n\n/**\n * Create a `CancellationTokenSource` that produces a cooperative cancellation token.\n */\nexport function createCancellationTokenSource(): CancellationTokenSourceTrait {\n\treturn new CancellationTokenSource();\n}\n\nexport function isCancellationTokenTrait(\n\tobj: unknown,\n): obj is CancellationTokenTrait {\n\treturn (\n\t\ttypeof obj === \"object\" &&\n\t\tobj !== null &&\n\t\ttypeof (obj as CancellationTokenTrait).isCancellationRequested ===\n\t\t\t\"boolean\" &&\n\t\ttypeof (obj as CancellationTokenTrait).onCancellationRequested ===\n\t\t\t\"function\" &&\n\t\ttypeof (obj as CancellationTokenTrait).throwIfCancellationRequested ===\n\t\t\t\"function\" &&\n\t\tisInteropObservableTrait(obj)\n\t);\n}\n","export const ResourceErrorCode = {\n\tValueUnavailable: \"resource.value_unavailable\",\n} as const;\n\nexport type ResourceErrorCode =\n\t(typeof ResourceErrorCode)[keyof typeof ResourceErrorCode];\n\nexport interface ResourceValueUnavailableErrorOptions {\n\treadonly status: string;\n}\n\nexport class ResourceError extends Error {\n\toverride readonly name = \"ResourceError\";\n\treadonly code: ResourceErrorCode;\n\treadonly status?: string;\n\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: { code: ResourceErrorCode; status?: string },\n\t) {\n\t\tsuper(message);\n\t\tthis.code = options.code;\n\t\tthis.status = options.status;\n\t}\n\n\tstatic valueUnavailable(\n\t\toptions: ResourceValueUnavailableErrorOptions,\n\t): ResourceError {\n\t\treturn new ResourceError(\n\t\t\t`Resource value is not available while status is \"${options.status}\".`,\n\t\t\t{\n\t\t\t\tcode: ResourceErrorCode.ValueUnavailable,\n\t\t\t\tstatus: options.status,\n\t\t\t},\n\t\t);\n\t}\n}\n","// --- Signal trait types ---\n\nimport { type CancellationTokenTrait } from \"../cancellation/types\";\nimport { type DisposableTrait, type InteropObservableTrait } from \"../compat\";\nimport { type EventStreamTrait } from \"../events/types\";\n\nexport interface SignalOptions<T> {\n\tequals?: (a: T, b: T) => boolean;\n}\n\n/**\n * Read-only signal interface.\n * Semantics align with TC39 Signals proposal, but uses an SDK-owned thin protocol\n * to avoid coupling to any specific polyfill or standard implementation.\n */\nexport interface ReadableSignalTrait<T> extends InteropObservableTrait<T> {\n\treadonly equals: (a: unknown, b: unknown) => boolean;\n\t/** Return the current snapshot value. */\n\tget(): T;\n\t/**\n\t * Watch value invalidations.\n\t * The stream does not emit the current value on subscription; use\n\t * `[SYMBOL_OBSERVABLE]()` when value replay is required.\n\t */\n\twatchStream(): EventStreamTrait<void>;\n}\n\n/**\n * Writable signal interface.\n * State transitions should be controlled by the client / service layer;\n * external consumers typically only see the read-only projection.\n */\nexport interface WritableSignalTrait<T> extends ReadableSignalTrait<T> {\n\tset(value: T): void;\n}\n\n/**\n * Computed (derived) signal — always read-only, value is derived from\n * other signals automatically.\n */\nexport interface ComputedSignalTrait<T> extends ReadableSignalTrait<T> {}\n\nexport const ResourceStatus = {\n\tIdle: \"idle\",\n\tLoading: \"loading\",\n\tLoadingError: \"loading_error\",\n\tReloading: \"reloading\",\n\tResolved: \"resolved\",\n\tError: \"error\",\n} as const;\n\nexport type ResourceStatus =\n\t(typeof ResourceStatus)[keyof typeof ResourceStatus];\n\nexport interface ResourceIdleSnapshot {\n\treadonly status: typeof ResourceStatus.Idle;\n}\n\nexport interface ResourceLoadingSnapshot {\n\treadonly status: typeof ResourceStatus.Loading;\n}\n\nexport interface ResourceLoadingErrorSnapshot {\n\treadonly status: typeof ResourceStatus.LoadingError;\n\treadonly error: unknown;\n}\n\nexport interface ResourceReloadingSnapshot<T> {\n\treadonly status: typeof ResourceStatus.Reloading;\n\treadonly value: T;\n}\n\nexport interface ResourceResolvedSnapshot<T> {\n\treadonly status: typeof ResourceStatus.Resolved;\n\treadonly value: T;\n}\n\nexport interface ResourceErrorSnapshot<T> {\n\treadonly status: typeof ResourceStatus.Error;\n\treadonly value: T;\n\treadonly error: unknown;\n}\n\nexport type ResourceSnapshot<T> =\n\t| ResourceIdleSnapshot\n\t| ResourceLoadingSnapshot\n\t| ResourceLoadingErrorSnapshot\n\t| ResourceReloadingSnapshot<T>\n\t| ResourceResolvedSnapshot<T>\n\t| ResourceErrorSnapshot<T>;\n\nexport interface ResourceWhenValueOptions {\n\treadonly cancellationToken?: CancellationTokenTrait;\n\treadonly staleValueWhenError?: boolean;\n}\n\nexport interface ResourceTrait<T>\n\textends DisposableTrait,\n\t\tInteropObservableTrait<ResourceSnapshot<T>> {\n\treadonly value: ReadableSignalTrait<T>;\n\treadonly status: ReadableSignalTrait<ResourceStatus>;\n\treadonly error: ReadableSignalTrait<unknown | undefined>;\n\treadonly isLoading: ReadableSignalTrait<boolean>;\n\treadonly snapshot: ReadableSignalTrait<ResourceSnapshot<T>>;\n\thasValue(): boolean;\n\twhenValue(options?: ResourceWhenValueOptions): Promise<T>;\n}\n","import { filter, firstValueFrom, from, map, merge, NEVER } from \"rxjs\";\nimport {\n\ttype ReadableSignalTrait,\n\ttype ResourceErrorSnapshot,\n\ttype ResourceLoadingErrorSnapshot,\n\ttype ResourceReloadingSnapshot,\n\ttype ResourceResolvedSnapshot,\n\ttype ResourceSnapshot,\n\tResourceStatus,\n\ttype ResourceWhenValueOptions,\n} from \"./types\";\n\nexport async function whenResourceSnapshotValue<T>(\n\tsnapshotSignal: ReadableSignalTrait<ResourceSnapshot<T>>,\n\toptions?: ResourceWhenValueOptions,\n): Promise<T> {\n\toptions?.cancellationToken?.throwIfCancellationRequested();\n\tconst staleValueWhenError = options?.staleValueWhenError ?? true;\n\tconst current = snapshotSignal.get();\n\tif (\n\t\tcurrent.status === ResourceStatus.Resolved ||\n\t\tcurrent.status === ResourceStatus.Reloading ||\n\t\t(current.status === ResourceStatus.Error && staleValueWhenError)\n\t) {\n\t\treturn current.value;\n\t}\n\tif (\n\t\tcurrent.status === ResourceStatus.LoadingError ||\n\t\tcurrent.status === ResourceStatus.Error\n\t) {\n\t\tthrow current.error;\n\t}\n\n\tconst snapshot = await firstValueFrom(\n\t\tmerge(\n\t\t\tfrom(snapshotSignal).pipe(\n\t\t\t\tfilter(\n\t\t\t\t\t(\n\t\t\t\t\t\tsnapshot,\n\t\t\t\t\t): snapshot is\n\t\t\t\t\t\t| ResourceResolvedSnapshot<T>\n\t\t\t\t\t\t| ResourceReloadingSnapshot<T>\n\t\t\t\t\t\t| ResourceLoadingErrorSnapshot\n\t\t\t\t\t\t| ResourceErrorSnapshot<T> =>\n\t\t\t\t\t\tsnapshot.status === ResourceStatus.Resolved ||\n\t\t\t\t\t\tsnapshot.status === ResourceStatus.Reloading ||\n\t\t\t\t\t\tsnapshot.status === ResourceStatus.LoadingError ||\n\t\t\t\t\t\tsnapshot.status === ResourceStatus.Error,\n\t\t\t\t),\n\t\t\t),\n\t\t\t(options?.cancellationToken\n\t\t\t\t? from(options.cancellationToken)\n\t\t\t\t: NEVER\n\t\t\t).pipe(\n\t\t\t\tmap(({ cancellationError }) => {\n\t\t\t\t\tthrow cancellationError;\n\t\t\t\t}),\n\t\t\t),\n\t\t),\n\t);\n\n\tif (snapshot.status === ResourceStatus.LoadingError) {\n\t\tthrow snapshot.error;\n\t}\n\tif (snapshot.status === ResourceStatus.Error && !staleValueWhenError) {\n\t\tthrow snapshot.error;\n\t}\n\treturn snapshot.value;\n}\n\ntype AnyResourceSnapshotSelector = (\n\t// More than four levels intentionally falls back to runtime composition.\n\tvalue: any,\n) => ReadableSignalTrait<ResourceSnapshot<unknown>>;\n\nexport function flattenResourceSnapshot<T1, T2>(\n\tsourceSnapshot: ResourceSnapshot<T1>,\n\tselect1: (value: T1) => ReadableSignalTrait<ResourceSnapshot<T2>>,\n): ResourceSnapshot<T2>;\nexport function flattenResourceSnapshot<T1, T2, T3>(\n\tsourceSnapshot: ResourceSnapshot<T1>,\n\tselect1: (value: T1) => ReadableSignalTrait<ResourceSnapshot<T2>>,\n\tselect2: (value: T2) => ReadableSignalTrait<ResourceSnapshot<T3>>,\n): ResourceSnapshot<T3>;\nexport function flattenResourceSnapshot<T1, T2, T3, T4>(\n\tsourceSnapshot: ResourceSnapshot<T1>,\n\tselect1: (value: T1) => ReadableSignalTrait<ResourceSnapshot<T2>>,\n\tselect2: (value: T2) => ReadableSignalTrait<ResourceSnapshot<T3>>,\n\tselect3: (value: T3) => ReadableSignalTrait<ResourceSnapshot<T4>>,\n): ResourceSnapshot<T4>;\nexport function flattenResourceSnapshot<T1, T2, T3, T4, T5>(\n\tsourceSnapshot: ResourceSnapshot<T1>,\n\tselect1: (value: T1) => ReadableSignalTrait<ResourceSnapshot<T2>>,\n\tselect2: (value: T2) => ReadableSignalTrait<ResourceSnapshot<T3>>,\n\tselect3: (value: T3) => ReadableSignalTrait<ResourceSnapshot<T4>>,\n\tselect4: (value: T4) => ReadableSignalTrait<ResourceSnapshot<T5>>,\n): ResourceSnapshot<T5>;\nexport function flattenResourceSnapshot(\n\tsourceSnapshot: ResourceSnapshot<unknown>,\n\tselect: AnyResourceSnapshotSelector,\n\t...selectors: readonly AnyResourceSnapshotSelector[]\n): ResourceSnapshot<unknown>;\n/**\n * Flatten nested resource snapshots while tracking each selected snapshot signal.\n * Ancestor reload and error states remain visible whenever the final snapshot has\n * a value; an ancestor error without a final value becomes a loading error.\n */\nexport function flattenResourceSnapshot(\n\tsourceSnapshot: ResourceSnapshot<unknown>,\n\t...selectors: readonly AnyResourceSnapshotSelector[]\n): ResourceSnapshot<unknown> {\n\tlet snapshot = sourceSnapshot;\n\tlet reloading = false;\n\tlet hasError = false;\n\tlet error: unknown;\n\n\tfor (const select of selectors) {\n\t\tswitch (snapshot.status) {\n\t\t\tcase ResourceStatus.Idle:\n\t\t\tcase ResourceStatus.Loading:\n\t\t\t\treturn hasError\n\t\t\t\t\t? { status: ResourceStatus.LoadingError, error }\n\t\t\t\t\t: snapshot;\n\t\t\tcase ResourceStatus.LoadingError:\n\t\t\t\treturn hasError\n\t\t\t\t\t? { status: ResourceStatus.LoadingError, error }\n\t\t\t\t\t: snapshot;\n\t\t\tcase ResourceStatus.Reloading:\n\t\t\t\treloading = true;\n\t\t\t\tsnapshot = select(snapshot.value).get();\n\t\t\t\tbreak;\n\t\t\tcase ResourceStatus.Resolved:\n\t\t\t\tsnapshot = select(snapshot.value).get();\n\t\t\t\tbreak;\n\t\t\tcase ResourceStatus.Error:\n\t\t\t\tif (!hasError) {\n\t\t\t\t\thasError = true;\n\t\t\t\t\terror = snapshot.error;\n\t\t\t\t}\n\t\t\t\tsnapshot = select(snapshot.value).get();\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tswitch (snapshot.status) {\n\t\tcase ResourceStatus.Idle:\n\t\tcase ResourceStatus.Loading:\n\t\tcase ResourceStatus.LoadingError:\n\t\t\treturn hasError\n\t\t\t\t? { status: ResourceStatus.LoadingError, error }\n\t\t\t\t: snapshot;\n\t\tcase ResourceStatus.Reloading:\n\t\t\treturn hasError\n\t\t\t\t? { status: ResourceStatus.Error, value: snapshot.value, error }\n\t\t\t\t: snapshot;\n\t\tcase ResourceStatus.Resolved:\n\t\t\treturn hasError\n\t\t\t\t? { status: ResourceStatus.Error, value: snapshot.value, error }\n\t\t\t\t: reloading\n\t\t\t\t\t? { status: ResourceStatus.Reloading, value: snapshot.value }\n\t\t\t\t\t: snapshot;\n\t\tcase ResourceStatus.Error:\n\t\t\treturn hasError\n\t\t\t\t? { status: ResourceStatus.Error, value: snapshot.value, error }\n\t\t\t\t: snapshot;\n\t}\n}\n\nexport const ResourceSnapshotUpdateKind = {\n\tLoad: \"load\",\n\tResolve: \"resolve\",\n\tFail: \"fail\",\n\tFailWithValue: \"fail_with_value\",\n} as const;\n\nexport type ResourceSnapshotUpdateKind =\n\t(typeof ResourceSnapshotUpdateKind)[keyof typeof ResourceSnapshotUpdateKind];\n\nexport type ResourceSnapshotUpdate<T> =\n\t| { readonly kind: typeof ResourceSnapshotUpdateKind.Load }\n\t| {\n\t\t\treadonly kind: typeof ResourceSnapshotUpdateKind.Resolve;\n\t\t\treadonly value: T;\n\t }\n\t| {\n\t\t\treadonly kind: typeof ResourceSnapshotUpdateKind.Fail;\n\t\t\treadonly error: unknown;\n\t }\n\t| {\n\t\t\treadonly kind: typeof ResourceSnapshotUpdateKind.FailWithValue;\n\t\t\treadonly value: T;\n\t\t\treadonly error: unknown;\n\t };\n\nexport function reduceResourceSnapshot<T>(\n\tprevious: ResourceSnapshot<T>,\n\tupdate: ResourceSnapshotUpdate<T>,\n): ResourceSnapshot<T> {\n\tswitch (update.kind) {\n\t\tcase ResourceSnapshotUpdateKind.Load:\n\t\t\treturn previous.status === ResourceStatus.Reloading ||\n\t\t\t\tprevious.status === ResourceStatus.Resolved ||\n\t\t\t\tprevious.status === ResourceStatus.Error\n\t\t\t\t? { status: ResourceStatus.Reloading, value: previous.value }\n\t\t\t\t: { status: ResourceStatus.Loading };\n\t\tcase ResourceSnapshotUpdateKind.Resolve:\n\t\t\treturn { status: ResourceStatus.Resolved, value: update.value };\n\t\tcase ResourceSnapshotUpdateKind.Fail:\n\t\t\treturn previous.status === ResourceStatus.Reloading ||\n\t\t\t\tprevious.status === ResourceStatus.Resolved ||\n\t\t\t\tprevious.status === ResourceStatus.Error\n\t\t\t\t? {\n\t\t\t\t\t\tstatus: ResourceStatus.Error,\n\t\t\t\t\t\tvalue: previous.value,\n\t\t\t\t\t\terror: update.error,\n\t\t\t\t\t}\n\t\t\t\t: {\n\t\t\t\t\t\tstatus: ResourceStatus.LoadingError,\n\t\t\t\t\t\terror: update.error,\n\t\t\t\t\t};\n\t\tcase ResourceSnapshotUpdateKind.FailWithValue:\n\t\t\treturn {\n\t\t\t\tstatus: ResourceStatus.Error,\n\t\t\t\tvalue: update.value,\n\t\t\t\terror: update.error,\n\t\t\t};\n\t}\n}\n","import {\n\tcatchError,\n\tdistinctUntilChanged,\n\tfilter,\n\tfinalize,\n\tfrom,\n\tmap,\n\ttype Observable,\n\ttype ObservableInput,\n\tof,\n\tswitchMap,\n\ttake,\n\ttakeUntil,\n} from \"rxjs\";\nimport {\n\ttype CancellationTokenTrait,\n\tcreateCancellationTokenSource,\n} from \"../cancellation\";\nimport {\n\ttype InteropObservableTrait,\n\tSYMBOL_DISPOSE,\n\tSYMBOL_OBSERVABLE,\n\ttype WithInteropObservableTraitCompat,\n} from \"../compat\";\nimport { ResourceError } from \"../signals/error\";\nimport {\n\tResourceSnapshotUpdateKind,\n\treduceResourceSnapshot,\n\twhenResourceSnapshotValue,\n} from \"../signals/resource-snapshot\";\nimport {\n\ttype ReadableSignalTrait,\n\ttype ResourceSnapshot,\n\tResourceStatus,\n\ttype ResourceTrait,\n\ttype ResourceWhenValueOptions,\n} from \"../signals/types\";\nimport { type RxEventStream } from \"./event\";\nimport {\n\tRxComputedSignal,\n\ttype RxComputedSignalCompat,\n\tRxStateSignal,\n\ttype RxStateSignalCompat,\n} from \"./signal\";\n\nexport {\n\ttype ResourceErrorSnapshot,\n\ttype ResourceIdleSnapshot,\n\ttype ResourceLoadingErrorSnapshot,\n\ttype ResourceLoadingSnapshot,\n\ttype ResourceReloadingSnapshot,\n\ttype ResourceResolvedSnapshot,\n\ttype ResourceSnapshot,\n\tResourceStatus,\n\ttype ResourceTrait,\n\ttype ResourceWhenValueOptions,\n} from \"../signals/types\";\n\nexport interface RxResourceStreamContext<T, R> {\n\treadonly request: R;\n\treadonly previous: ResourceSnapshot<T>;\n\treadonly cancellationToken: CancellationTokenTrait;\n}\n\nexport interface RxResourceOptions<T, R = undefined> {\n\treadonly request?: ReadableSignalTrait<R | undefined> | (() => R | undefined);\n\treadonly stream: (\n\t\tcontext: RxResourceStreamContext<T, R>,\n\t) => ObservableInput<T>;\n}\n\nabstract class RxResourceBase<T>\n\timplements ResourceTrait<T>, InteropObservableTrait<ResourceSnapshot<T>>\n{\n\tabstract readonly snapshot: ReadableSignalTrait<ResourceSnapshot<T>>;\n\treadonly value: RxComputedSignalCompat<T>;\n\treadonly status: RxComputedSignalCompat<ResourceStatus>;\n\treadonly error: RxComputedSignalCompat<unknown | undefined>;\n\treadonly isLoading: RxComputedSignalCompat<boolean>;\n\tprotected readonly destroyed = RxStateSignal.fromInitialValue(false);\n\tprotected readonly destroyed$ = from(this.destroyed).pipe(\n\t\tfilter((value): value is true => value),\n\t\ttake(1),\n\t);\n\n\tprotected constructor() {\n\t\tthis.value = RxComputedSignal.computed(() => {\n\t\t\tconst snapshot = this.snapshot.get();\n\t\t\tif (\n\t\t\t\tsnapshot.status === ResourceStatus.Resolved ||\n\t\t\t\tsnapshot.status === ResourceStatus.Reloading\n\t\t\t) {\n\t\t\t\treturn snapshot.value;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tsnapshot.status === ResourceStatus.LoadingError ||\n\t\t\t\tsnapshot.status === ResourceStatus.Error\n\t\t\t) {\n\t\t\t\tthrow snapshot.error;\n\t\t\t}\n\t\t\tthrow ResourceError.valueUnavailable({ status: snapshot.status });\n\t\t});\n\t\tthis.status = RxComputedSignal.computed(() => this.snapshot.get().status);\n\t\tthis.error = RxComputedSignal.computed(() => {\n\t\t\tconst snapshot = this.snapshot.get();\n\t\t\treturn snapshot.status === ResourceStatus.LoadingError ||\n\t\t\t\tsnapshot.status === ResourceStatus.Error\n\t\t\t\t? snapshot.error\n\t\t\t\t: undefined;\n\t\t});\n\t\tthis.isLoading = RxComputedSignal.computed(() => {\n\t\t\tconst status = this.snapshot.get().status;\n\t\t\treturn (\n\t\t\t\tstatus === ResourceStatus.Loading || status === ResourceStatus.Reloading\n\t\t\t);\n\t\t});\n\t}\n\n\thasValue(): boolean {\n\t\tconst status = this.snapshot.get().status;\n\t\treturn (\n\t\t\tstatus === ResourceStatus.Resolved || status === ResourceStatus.Reloading\n\t\t);\n\t}\n\n\tasync whenValue(options?: ResourceWhenValueOptions): Promise<T> {\n\t\treturn whenResourceSnapshotValue(this.snapshot, options);\n\t}\n\n\tdispose(): void {\n\t\tthis.destroyed.set(true);\n\t}\n\n\t[SYMBOL_DISPOSE](): void {\n\t\tthis.dispose();\n\t}\n\n\t[SYMBOL_OBSERVABLE](): RxEventStream<ResourceSnapshot<T>> {\n\t\treturn this.snapshot[SYMBOL_OBSERVABLE]() as RxEventStream<\n\t\t\tResourceSnapshot<T>\n\t\t>;\n\t}\n}\n\nexport class RxResource<T, R = undefined> extends RxResourceBase<T> {\n\treadonly snapshot: RxStateSignalCompat<ResourceSnapshot<T>>;\n\n\tconstructor(private readonly options: RxResourceOptions<T, R>) {\n\t\tsuper();\n\t\tthis.snapshot = RxStateSignal.fromInitialValue<ResourceSnapshot<T>>({\n\t\t\tstatus: ResourceStatus.Idle,\n\t\t});\n\t\tthis.destroyed$.subscribe(() => {\n\t\t\tthis.snapshot.set({ status: ResourceStatus.Idle });\n\t\t});\n\t\tthis.connect();\n\t}\n\n\tprivate connect(): void {\n\t\tconst configuredRequest = this.options.request;\n\t\tconst requestObservable: Observable<R | undefined> =\n\t\t\tconfiguredRequest && typeof configuredRequest !== \"function\"\n\t\t\t\t? from(configuredRequest).pipe(\n\t\t\t\t\t\tdistinctUntilChanged(\n\t\t\t\t\t\t\tconfiguredRequest.equals as (\n\t\t\t\t\t\t\t\tleft: R | undefined,\n\t\t\t\t\t\t\t\tright: R | undefined,\n\t\t\t\t\t\t\t) => boolean,\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t: of(\n\t\t\t\t\t\tconfiguredRequest && typeof configuredRequest === \"function\"\n\t\t\t\t\t\t\t? configuredRequest()\n\t\t\t\t\t\t\t: (undefined as R),\n\t\t\t\t\t);\n\t\tconst requestControlsLoading = configuredRequest !== undefined;\n\n\t\trequestObservable\n\t\t\t.pipe(\n\t\t\t\tswitchMap((request) => {\n\t\t\t\t\tif (requestControlsLoading && request === undefined) {\n\t\t\t\t\t\treturn of<ResourceSnapshot<T>>({ status: ResourceStatus.Idle });\n\t\t\t\t\t}\n\t\t\t\t\tconst previous = this.snapshot.get();\n\t\t\t\t\tconst loadingSnapshot = reduceResourceSnapshot(previous, {\n\t\t\t\t\t\tkind: ResourceSnapshotUpdateKind.Load,\n\t\t\t\t\t});\n\t\t\t\t\tthis.snapshot.set(loadingSnapshot);\n\n\t\t\t\t\tconst loadCancellation = createCancellationTokenSource();\n\t\t\t\t\treturn from(\n\t\t\t\t\t\tthis.options.stream({\n\t\t\t\t\t\t\trequest: request as R,\n\t\t\t\t\t\t\tprevious,\n\t\t\t\t\t\t\tcancellationToken: loadCancellation.token,\n\t\t\t\t\t\t}),\n\t\t\t\t\t).pipe(\n\t\t\t\t\t\tmap((value) =>\n\t\t\t\t\t\t\treduceResourceSnapshot(loadingSnapshot, {\n\t\t\t\t\t\t\t\tkind: ResourceSnapshotUpdateKind.Resolve,\n\t\t\t\t\t\t\t\tvalue,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcatchError((error: unknown) =>\n\t\t\t\t\t\t\tof(\n\t\t\t\t\t\t\t\treduceResourceSnapshot(loadingSnapshot, {\n\t\t\t\t\t\t\t\t\tkind: ResourceSnapshotUpdateKind.Fail,\n\t\t\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t\tfinalize(() => loadCancellation.cancel()),\n\t\t\t\t\t);\n\t\t\t\t}),\n\t\t\t\ttakeUntil(this.destroyed$),\n\t\t\t)\n\t\t\t.subscribe((snapshot) => this.snapshot.set(snapshot));\n\t}\n\n\tstatic create<T, R = undefined>(\n\t\toptions: RxResourceOptions<T, R>,\n\t): RxResource<T, R> {\n\t\treturn new RxResource(options);\n\t}\n}\n\nclass RxSnapshotResource<T> extends RxResourceBase<T> {\n\treadonly snapshot: RxComputedSignalCompat<ResourceSnapshot<T>>;\n\n\tconstructor(source: () => ResourceSnapshot<T>) {\n\t\tsuper();\n\t\tthis.snapshot = RxComputedSignal.computed(() =>\n\t\t\tthis.destroyed.get() ? { status: ResourceStatus.Idle } : source(),\n\t\t);\n\t}\n}\n\nexport function resourceFromSnapshots<T>(\n\tsource: () => ResourceSnapshot<T>,\n): WithInteropObservableTraitCompat<ResourceTrait<T>, ResourceSnapshot<T>> {\n\treturn new RxSnapshotResource(source);\n}\n\nexport function mapResource<T, U>(\n\tsource: ResourceTrait<T>,\n\tmapValue: (value: T) => U,\n): WithInteropObservableTraitCompat<ResourceTrait<U>, ResourceSnapshot<U>> {\n\treturn resourceFromSnapshots(() => {\n\t\tconst snapshot = source.snapshot.get();\n\t\tswitch (snapshot.status) {\n\t\t\tcase ResourceStatus.Idle:\n\t\t\tcase ResourceStatus.Loading:\n\t\t\tcase ResourceStatus.LoadingError:\n\t\t\t\treturn snapshot;\n\t\t\tcase ResourceStatus.Reloading:\n\t\t\tcase ResourceStatus.Resolved:\n\t\t\t\treturn { status: snapshot.status, value: mapValue(snapshot.value) };\n\t\t\tcase ResourceStatus.Error:\n\t\t\t\treturn {\n\t\t\t\t\tstatus: ResourceStatus.Error,\n\t\t\t\t\tvalue: mapValue(snapshot.value),\n\t\t\t\t\terror: snapshot.error,\n\t\t\t\t};\n\t\t}\n\t});\n}\n\nexport function rxResource<T, R = undefined>(\n\toptions: RxResourceOptions<T, R>,\n): WithInteropObservableTraitCompat<ResourceTrait<T>, ResourceSnapshot<T>> {\n\treturn new RxResource(options);\n}\n"],"mappings":";;;;;;AAQA,MAAa,eAAe;CAC3B,MAAM;CACN,OAAO;CACP,aAAa;CACb,gBAAgB;CAChB,gBAAgB;AACjB;AAWA,MAAa,wB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O;IAAE,QAAQ,SAAS;IAAQ,OAAO,SAAS,SAAS,KAAK;GAAE;GACnE,KAAK,eAAe,OACnB,OAAO;IACN,QAAQ,eAAe;IACvB,OAAO,SAAS,SAAS,KAAK;IAC9B,OAAO,SAAS;GACjB;EACF;CACD,CAAC;AACF;AAEA,SAAgB,WACf,SAC0E;CAC1E,OAAO,IAAI,WAAW,OAAO;AAC9B"}
|
package/dist/server/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Lt as CreateFoundationEnvironmentOptions, Vt as FoundationEnvironment, hn as BaseTransportTrait } from "../index-B9SEJGU2.mjs";
|
|
2
2
|
//#region src/server/transport.d.ts
|
|
3
3
|
interface ServerRequestContext {
|
|
4
4
|
headers: Record<string, string>;
|
package/dist/server/index.mjs
CHANGED
package/dist/test/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as IdleCallbackTrait, T as TimeTrait,
|
|
2
|
-
import {
|
|
1
|
+
import { C as IdleCallbackTrait, T as TimeTrait, on as SecuritydeptProvider, wt as EventSubjectTrait } from "../index-CFAJ969E.mjs";
|
|
2
|
+
import { Bt as EnvironmentValidators, Cr as PopupAttachResult, Er as PopupTrait, Hn as RouterTrait, Lt as CreateFoundationEnvironmentOptions, Mn as WithTraitInputValidator, Oi as PageLifecycleTrait, Tr as PopupOpenOptions, Vn as RouterNavigationRequest, Vt as FoundationEnvironment, _n as HttpResponse, ar as UriReferenceString, dn as SyncStorageTrait, gn as HttpRequest, hn as BaseTransportTrait } from "../index-B9SEJGU2.mjs";
|
|
3
3
|
//#region src/test/environment.d.ts
|
|
4
4
|
type EnvironmentCreatorOptions = {
|
|
5
5
|
providers?: readonly SecuritydeptProvider[];
|
package/dist/test/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { H as
|
|
2
|
-
import {
|
|
1
|
+
import { H as ClientError, U as ClientErrorKind, j as SYMBOL_OBSERVABLE } from "../rx-DM6Ouv-m.mjs";
|
|
2
|
+
import { $ as notMissingProvider, I as PopupAttachFailureReason, O as RouterNavigationMode, Q as getSecuritydeptProviderToken, R as throwValidationClientError, T as TIME_TRAIT_TOKEN, Z as createProviderIfTokenMissing, c as createInMemoryRecordStore, h as TRANSPORT_TRAIT_TOKEN, t as createFoundationEnvironment, z as validateTraitInput } from "../create-i5VyYgN6.mjs";
|
|
3
3
|
import { n as UriReferenceString } from "../uri-string-BPNbIMgv.mjs";
|
|
4
4
|
import { type } from "arktype";
|
|
5
5
|
//#region src/test/time.ts
|
package/dist/web/index.d.mts
CHANGED
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { _ as createPageResumeSource, a as NativeWebWindowLike, c as WebNavigationRouter, d as createPageLifecycleForNativeWeb, f as CreatePageResumeSourceOptions, g as PageResumeWindowTarget, h as PageResumeTriggerKind, i as NativeWebRouter, l as createRouterForNativeWeb, m as PageResumeEvent, n as NativeWebLocationLike, o as RouterForNativeWebCreateOptions, p as PageResumeDocumentTarget, r as NativeWebNavigationLike, s as WebLegacyRouter, t as NativeWebHistoryLike, u as PageLifecycleForNativeWebCreateOptions } from "../index-
|
|
4
|
-
//#region src/web/events/from-storage.d.ts
|
|
5
|
-
interface StorageEventTarget {
|
|
6
|
-
addEventListener(type: "storage", listener: EventListener): void;
|
|
7
|
-
removeEventListener(type: "storage", listener: EventListener): void;
|
|
8
|
-
}
|
|
9
|
-
interface FromStorageEventOptions {
|
|
10
|
-
storageEventTarget: StorageEventTarget;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Adapt browser `storage` events into an event stream.
|
|
14
|
-
*/
|
|
15
|
-
declare function fromStorageEvent(options: FromStorageEventOptions): EventStreamTrait<StorageEvent>;
|
|
16
|
-
//#endregion
|
|
1
|
+
import { Ct as EventStreamTrait, T as TimeTrait, ln as WithTraitDeps } from "../index-CFAJ969E.mjs";
|
|
2
|
+
import { Bt as EnvironmentValidators, Er as PopupTrait, Hn as RouterTrait, Lt as CreateFoundationEnvironmentOptions, Mn as WithTraitInputValidator, Vt as FoundationEnvironment, dn as SyncStorageTrait } from "../index-B9SEJGU2.mjs";
|
|
3
|
+
import { _ as createPageResumeSource, a as NativeWebWindowLike, b as fromStorageEvent, c as WebNavigationRouter, d as createPageLifecycleForNativeWeb, f as CreatePageResumeSourceOptions, g as PageResumeWindowTarget, h as PageResumeTriggerKind, i as NativeWebRouter, l as createRouterForNativeWeb, m as PageResumeEvent, n as NativeWebLocationLike, o as RouterForNativeWebCreateOptions, p as PageResumeDocumentTarget, r as NativeWebNavigationLike, s as WebLegacyRouter, t as NativeWebHistoryLike, u as PageLifecycleForNativeWebCreateOptions, v as FromStorageEventOptions, y as StorageEventTarget } from "../index-BjCFWcmV.mjs";
|
|
17
4
|
//#region src/web/popup.d.ts
|
|
18
5
|
interface PopupForNativeWebCreateOptions {
|
|
19
6
|
window?: unknown;
|
package/dist/web/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { A as RxEventSubject,
|
|
2
|
-
import { n as PopupServerWindowHandle, o as PopupErrorCode, t as PopupClientWindowHandle } from "../handle-
|
|
3
|
-
import {
|
|
4
|
-
import { a as createPageLifecycleForNativeWeb, i as createRouterForNativeWeb, n as WebLegacyRouter, o as PageResumeTriggerKind, r as WebNavigationRouter, s as createPageResumeSource, t as NativeWebRouter } from "../router-
|
|
1
|
+
import { A as RxEventSubject, H as ClientError, K as UserRecovery, U as ClientErrorKind, h as createAsyncSchedulerWithTimestampProvider, k as RxEventStream } from "../rx-DM6Ouv-m.mjs";
|
|
2
|
+
import { n as PopupServerWindowHandle, o as PopupErrorCode, t as PopupClientWindowHandle } from "../handle-DwMgqe7R.mjs";
|
|
3
|
+
import { $ as notMissingProvider, E as ROUTER_TRAIT_TOKEN, F as POPUP_TRAIT_TOKEN, H as PAGE_LIFECYCLE_TRAIT_TOKEN, I as PopupAttachFailureReason, Q as getSecuritydeptProviderToken, R as throwValidationClientError, T as TIME_TRAIT_TOKEN, V as validateWithSchemaSync, Z as createProviderIfTokenMissing, d as SESSION_STORAGE_TRAIT_TOKEN, f as StorageChangeEventOrigin, l as PERSISTENT_STORAGE_TRAIT_TOKEN, t as createFoundationEnvironment, z as validateTraitInput } from "../create-i5VyYgN6.mjs";
|
|
4
|
+
import { a as createPageLifecycleForNativeWeb, i as createRouterForNativeWeb, n as WebLegacyRouter, o as PageResumeTriggerKind, r as WebNavigationRouter, s as createPageResumeSource, t as NativeWebRouter } from "../router-at5bTdJQ.mjs";
|
|
5
5
|
import { filter, from, fromEventPattern, map, merge, take, timer } from "rxjs";
|
|
6
6
|
import { type } from "arktype";
|
|
7
7
|
//#region src/web/events/from-storage.ts
|
package/dist/webext/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as RouterForNativeWebCreateOptions, u as PageLifecycleForNativeWebCreateOptions } from "../index-
|
|
1
|
+
import { Bt as EnvironmentValidators, Hn as RouterTrait, Lt as CreateFoundationEnvironmentOptions, Mn as WithTraitInputValidator, Vt as FoundationEnvironment, ln as StorageTrait } from "../index-B9SEJGU2.mjs";
|
|
2
|
+
import { o as RouterForNativeWebCreateOptions, u as PageLifecycleForNativeWebCreateOptions } from "../index-BjCFWcmV.mjs";
|
|
3
3
|
//#region src/webext/router.d.ts
|
|
4
4
|
interface WebExtRouterBrowserLike {
|
|
5
5
|
runtime?: {
|
package/dist/webext/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { H as
|
|
2
|
-
import {
|
|
3
|
-
import { a as createPageLifecycleForNativeWeb, i as createRouterForNativeWeb } from "../router-
|
|
1
|
+
import { H as ClientError, U as ClientErrorKind } from "../rx-DM6Ouv-m.mjs";
|
|
2
|
+
import { $ as notMissingProvider, E as ROUTER_TRAIT_TOKEN, H as PAGE_LIFECYCLE_TRAIT_TOKEN, Q as getSecuritydeptProviderToken, R as throwValidationClientError, V as validateWithSchemaSync, Z as createProviderIfTokenMissing, d as SESSION_STORAGE_TRAIT_TOKEN, l as PERSISTENT_STORAGE_TRAIT_TOKEN, t as createFoundationEnvironment, z as validateTraitInput } from "../create-i5VyYgN6.mjs";
|
|
3
|
+
import { a as createPageLifecycleForNativeWeb, i as createRouterForNativeWeb } from "../router-at5bTdJQ.mjs";
|
|
4
4
|
import { type } from "arktype";
|
|
5
5
|
//#region src/webext/router.ts
|
|
6
6
|
const WebExtRuntimeRouterLikeSchema = type({ getURL: "Function" });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@securitydept/client",
|
|
3
|
-
"version": "0.3.0-beta.
|
|
3
|
+
"version": "0.3.0-beta.7",
|
|
4
4
|
"description": "Client of the SecurityDept TypeScript SDK, a layered authentication and authorization toolkit built as reusable Rust crates, a TypeScript client SDK workspace, and reference server/web apps.",
|
|
5
5
|
"author": "Zhou Yeheng <root@aitiotekt.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -64,8 +64,17 @@
|
|
|
64
64
|
"rxjs": "^7.8.2",
|
|
65
65
|
"uuid": "^14.0.1"
|
|
66
66
|
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"mnemonist": "^0.40.4"
|
|
69
|
+
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"mnemonist": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
67
75
|
"devDependencies": {
|
|
68
76
|
"@types/node": "^26.1.2",
|
|
77
|
+
"mnemonist": "^0.40.4",
|
|
69
78
|
"vitest": "^4.1.10"
|
|
70
79
|
},
|
|
71
80
|
"scripts": {
|