ignotum 0.0.16 → 0.0.18
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/README.md +6 -6
- package/dist/cli/bin.mjs +13263 -2689
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/platform/_headers +3 -0
- package/dist/platform/_ignotum/v1.0/client.js +12 -0
- package/dist/runtime/{api-B4fwp5a2.d.ts → api-BnUKx9cj-D49Tf0rX.d.ts} +4 -3
- package/dist/runtime/api-C-tltz6s.js +31 -0
- package/dist/runtime/api-C-tltz6s.js.map +1 -0
- package/dist/runtime/artifact-BB5qzoa6.js +42 -0
- package/dist/runtime/artifact-BB5qzoa6.js.map +1 -0
- package/dist/runtime/{bootstrap-BTFScKAc.d.ts → bootstrap-DjTwGJao-DBx5zdFI.d.ts} +64 -64
- package/dist/runtime/{bootstrap-BISQSn_O.js → bootstrap-DlNIfH-r.js} +9 -9
- package/dist/runtime/bootstrap-DlNIfH-r.js.map +1 -0
- package/dist/runtime/client.d.ts +24 -20
- package/dist/runtime/client.js +9 -9
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/id-BI08JkmR.d.ts +1 -0
- package/dist/runtime/{id--1m0NuUL.js → id-BrEnxY-r.js} +118 -53
- package/dist/runtime/id-BrEnxY-r.js.map +1 -0
- package/dist/runtime/{image-Djtjy4Z8.js → image-gofzZeCm.js} +2 -2
- package/dist/runtime/image-gofzZeCm.js.map +1 -0
- package/dist/runtime/{index-D4seNHlX.d.ts → index-Biaw5vdF.d.ts} +2 -2
- package/dist/runtime/internal/api.d.ts +1 -1
- package/dist/runtime/internal/api.js +1 -30
- package/dist/runtime/internal/bootstrap.d.ts +1 -1
- package/dist/runtime/internal/bootstrap.js +1 -1
- package/dist/runtime/internal/client.d.ts +2 -2
- package/dist/runtime/internal/client.js +4 -4
- package/dist/runtime/internal/client.js.map +1 -1
- package/dist/runtime/internal/host.d.ts +4 -4
- package/dist/runtime/internal/host.js +4 -4
- package/dist/runtime/internal/routes.d.ts +1 -1
- package/dist/runtime/internal/routes.js +1 -1
- package/dist/runtime/internal/server.d.ts +3 -2
- package/dist/runtime/internal/server.js +2 -2
- package/dist/runtime/internal/server.js.map +1 -1
- package/dist/runtime/internal/types.d.ts +2 -2
- package/dist/runtime/internal/types.js +1 -1
- package/dist/runtime/{pagination-D3qd6s9N.js → pagination--f4kMKf6.js} +2 -2
- package/dist/runtime/{pagination-D3qd6s9N.js.map → pagination--f4kMKf6.js.map} +1 -1
- package/dist/runtime/pagination-BI08JkmR.d.ts +1 -0
- package/dist/runtime/{router-BSBI1oN1.js → router-C1eC9yy5.js} +462 -419
- package/dist/runtime/router-C1eC9yy5.js.map +1 -0
- package/dist/runtime/routes-DnU39R7c.js +152 -0
- package/dist/runtime/routes-DnU39R7c.js.map +1 -0
- package/dist/runtime/{schema-D1wOqiNH.js → schema-BSjepoNF.js} +271 -6
- package/dist/runtime/schema-BSjepoNF.js.map +1 -0
- package/dist/runtime/server.d.ts +5 -4
- package/dist/runtime/server.js +3 -3
- package/dist/runtime/server.js.map +1 -1
- package/dist/runtime/{sync-DzUwA8W9.js → sync-BwgS19Xy.js} +4 -16
- package/dist/runtime/sync-BwgS19Xy.js.map +1 -0
- package/dist/runtime/{sync-D-GK2sv9.d.ts → sync-By2hX5ev.d.ts} +1 -2
- package/dist/runtime/{types-DeCCyqLU-BIm7rU-0.d.ts → types-DeCCyqLU-CHx7KFtx.d.ts} +2 -2
- package/package.json +7 -1
- package/src/cli/agent-files.ts +2 -0
- package/src/cli/build/asset-names.ts +190 -0
- package/src/cli/build/managed-client.ts +151 -81
- package/src/cli/build/managed-server.ts +4 -4
- package/src/cli/build/managed.ts +5 -6
- package/src/cli/command.ts +7 -15
- package/src/cli/control-client.ts +7 -9
- package/src/cli/deploy.ts +45 -15
- package/src/cli/dev.ts +50 -99
- package/src/cli/image-assets.ts +5 -2
- package/src/cli/managed-client-boundaries.ts +6 -6
- package/src/cli/managed-dev-platform.ts +52 -66
- package/src/cli/managed-exports.ts +5 -66
- package/src/cli/new-app.ts +7 -2
- package/src/cli/path.ts +11 -0
- package/src/cli/route-codegen.ts +2 -1
- package/src/cli/route-static.ts +3 -2
- package/src/cli/upload-journal.ts +130 -0
- package/src/client/bootstrap.ts +1 -110
- package/src/client/errors.ts +1 -70
- package/src/client/files.ts +1 -233
- package/src/client/hooks.ts +1 -367
- package/src/client/id.ts +1 -263
- package/src/client/image.ts +1 -28
- package/src/client/index.ts +1 -126
- package/src/client/jsx-dev-runtime.ts +1 -2
- package/src/client/jsx-runtime.ts +1 -2
- package/src/client/managed-client.ts +1 -729
- package/src/client/managed-upgrade.ts +1 -283
- package/src/client/page-observers.ts +1 -77
- package/src/client/query.ts +1 -17
- package/src/client/recovery-journal.ts +1 -195
- package/src/client/route-boundaries.ts +1 -184
- package/src/client/router-history.ts +1 -152
- package/src/client/router-store.ts +1 -644
- package/src/client/router.ts +1 -324
- package/src/client/routes.ts +1 -28
- package/src/client/sync.ts +1 -286
- package/src/dev-runtime/id.ts +1 -1
- package/src/dev-runtime/managed-functions.ts +10 -18
- package/src/dev-runtime/managed-sync.ts +16 -16
- package/src/dev-runtime/sync.ts +6 -4
- package/src/internal/api.ts +1 -156
- package/src/internal/client.ts +1 -186
- package/src/internal/host.ts +1 -1
- package/src/internal/http-paths.ts +1 -4
- package/src/internal/routes.ts +1 -45
- package/src/internal/server.ts +1 -3
- package/src/internal/types.ts +1 -2
- package/src/server/index.ts +1 -27
- package/dist/cli/managed-release-WHYLZwaS.mjs +0 -10902
- package/dist/cli/managed-release-WHYLZwaS.mjs.map +0 -1
- package/dist/cli/managed-release.d.mts +0 -1
- package/dist/cli/managed-release.mjs +0 -14
- package/dist/cli/managed-release.mjs.map +0 -1
- package/dist/runtime/bootstrap-BISQSn_O.js.map +0 -1
- package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js +0 -269
- package/dist/runtime/descriptor-CTY4mtwS-cS43EbwS.js.map +0 -1
- package/dist/runtime/id--1m0NuUL.js.map +0 -1
- package/dist/runtime/id-CBOt2kDo.d.ts +0 -1
- package/dist/runtime/identity-QjtJRxBD.d.ts +0 -2
- package/dist/runtime/image-Djtjy4Z8.js.map +0 -1
- package/dist/runtime/internal/api.js.map +0 -1
- package/dist/runtime/pagination-CBOt2kDo.d.ts +0 -1
- package/dist/runtime/router-BSBI1oN1.js.map +0 -1
- package/dist/runtime/routes-Ce8TVP-T.js +0 -690
- package/dist/runtime/routes-Ce8TVP-T.js.map +0 -1
- package/dist/runtime/schema-D1wOqiNH.js.map +0 -1
- package/dist/runtime/sync-DzUwA8W9.js.map +0 -1
- package/src/cli/managed-release-bin.ts +0 -13
- package/src/cli/managed-release.ts +0 -260
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { n as writeManagedReleaseGraphs, nn as runMain, rn as layer } from "./managed-release-WHYLZwaS.mjs";
|
|
2
|
-
import { fileURLToPath } from "node:url";
|
|
3
|
-
import { Config, Effect, Path } from "effect";
|
|
4
|
-
//#region src/cli/managed-release-bin.ts
|
|
5
|
-
Effect.gen(function* () {
|
|
6
|
-
const path = yield* Path.Path;
|
|
7
|
-
const sdkDirectory = fileURLToPath(new URL("../../", import.meta.url));
|
|
8
|
-
const output = yield* Config.string("IGNOTUM_MANAGED_RELEASE_DIRECTORY").pipe(Config.withDefault(path.join(sdkDirectory, "dist/managed")));
|
|
9
|
-
yield* writeManagedReleaseGraphs(sdkDirectory, output);
|
|
10
|
-
}).pipe(Effect.provide(layer), runMain);
|
|
11
|
-
//#endregion
|
|
12
|
-
export {};
|
|
13
|
-
|
|
14
|
-
//# sourceMappingURL=managed-release.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"managed-release.mjs","names":["NodeServices.layer","NodeRuntime.runMain"],"sources":["../../src/cli/managed-release-bin.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { NodeRuntime, NodeServices } from \"@effect/platform-node\";\nimport { Config, Effect, Path } from \"effect\";\nimport { writeManagedReleaseGraphs } from \"./managed-release.js\";\n\nEffect.gen(function* () {\n const path = yield* Path.Path;\n const sdkDirectory = fileURLToPath(new URL(\"../../\", import.meta.url));\n const output = yield* Config.string(\"IGNOTUM_MANAGED_RELEASE_DIRECTORY\").pipe(\n Config.withDefault(path.join(sdkDirectory, \"dist/managed\")),\n );\n yield* writeManagedReleaseGraphs(sdkDirectory, output);\n}).pipe(Effect.provide(NodeServices.layer), NodeRuntime.runMain);\n"],"mappings":";;;;AAKA,OAAO,IAAI,aAAa;CACtB,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,eAAe,cAAc,IAAI,IAAI,UAAU,YAAY,GAAG,CAAC;CACrE,MAAM,SAAS,OAAO,OAAO,OAAO,mCAAmC,CAAC,CAAC,KACvE,OAAO,YAAY,KAAK,KAAK,cAAc,cAAc,CAAC,CAC5D;CACA,OAAO,0BAA0B,cAAc,MAAM;AACvD,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQA,KAAkB,GAAGC,OAAmB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap-BISQSn_O.js","names":["Versioned.upgrade","Versioned.initial","h"],"sources":["../../../shared/dist/routing/metadata.js","../../../shared/dist/routing.js","../../src/client/router-history.ts","../../src/client/router-store.ts","../../src/client/route-boundaries.ts","../../src/client/bootstrap.ts"],"sourcesContent":["import { Effect, Schema } from \"effect\";\nimport { LayoutMetadata, StaticMetadata, appDefinitionLimits } from \"@ignotum/contracts/app-definition\";\n//#region src/routing/metadata.ts\nconst MetadataInput = Schema.Struct({\n\tapplicationName: Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(256)),\n\tlayouts: Schema.Array(LayoutMetadata).check(Schema.isMaxLength(appDefinitionLimits.layouts)),\n\tpage: Schema.optional(StaticMetadata),\n\toutcome: Schema.Literals([\n\t\t\"Matched\",\n\t\t\"Invalid\",\n\t\t\"NotFound\"\n\t])\n}).annotate({ parseOptions: { onExcessProperty: \"error\" } });\nvar InvalidMetadata = class extends Schema.TaggedError()(\"InvalidMetadata\", { message: Schema.String }) {};\n/**\n* Layouts run from outermost to nearest. Values remain plain text: document writers must escape\n* HTML text and attributes, and browser writers must use textContent and setAttribute.\n* `remove` names managed tags absent from this result, including after navigation.\n*/\nconst resolveMetadata = Effect.fn(\"Routing.resolveMetadata\")(function* (input) {\n\tconst { applicationName, layouts, page, outcome } = yield* Schema.decodeEffect(MetadataInput)(input).pipe(Effect.mapError(() => InvalidMetadata.make({ message: \"Static metadata is invalid.\" })));\n\tlet title = applicationName;\n\tlet template;\n\tlet description;\n\tlet robots;\n\tfor (const layout of layouts) {\n\t\ttitle = layout.title ?? title;\n\t\ttemplate = layout.titleTemplate ?? template;\n\t\tdescription = layout.meta?.description ?? description;\n\t\trobots = layout.meta?.robots ?? robots;\n\t}\n\tconst matchedPage = outcome === \"NotFound\" ? void 0 : page;\n\tconst pageTitle = matchedPage?.title;\n\tif (pageTitle !== void 0) title = template === void 0 ? pageTitle : template.replace(\"%s\", () => pageTitle);\n\tdescription = matchedPage?.meta?.description ?? description;\n\trobots = outcome === \"Matched\" ? matchedPage?.meta?.robots ?? robots : \"noindex\";\n\tconst remove = [];\n\tif (description === void 0) remove.push(\"description\");\n\tif (robots === void 0) remove.push(\"robots\");\n\treturn {\n\t\ttitle,\n\t\tmeta: {\n\t\t\tdescription,\n\t\t\trobots\n\t\t},\n\t\tremove\n\t};\n});\n//#endregion\nexport { InvalidMetadata, MetadataInput, resolveMetadata };\n\n//# sourceMappingURL=metadata.js.map","import { RoutingDefinitionError, compilePatterns, matchDirectory, matchPattern, parsePattern, validateRoutePattern } from \"./routing/pattern.js\";\nimport { InvalidUrl, ParsedLocation, PartialLocation, UrlIssue, buildUrl, decodeRouteInputs, parseLocation } from \"./routing/url.js\";\nimport { InvalidMetadata, MetadataInput, resolveMetadata } from \"./routing/metadata.js\";\nimport { Effect } from \"effect\";\n//#region src/routing/index.ts\nconst reservedSegments = (segments) => segments[0] === \"_ignotum\";\n/** Accept a root-relative location before a URL parser can discard invalid dot segments. */\nconst matchLocation = Effect.fn(\"Routing.matchLocation\")(function* (patterns, input) {\n\tconst parsed = yield* parseLocation(input).pipe(Effect.result);\n\tif (parsed._tag === \"Failure\") {\n\t\tconst error = parsed.failure;\n\t\tconst partial = error.partial;\n\t\tconst segments = partial?.segments ?? [];\n\t\tconst reserved = reservedSegments(segments);\n\t\tconst branch = partial?.pathComplete ? matchPattern(patterns, segments) : matchDirectory(patterns, segments);\n\t\treturn {\n\t\t\t_tag: \"Invalid\",\n\t\t\tstatus: 400,\n\t\t\troute: !reserved && partial?.pathComplete ? branch.route : void 0,\n\t\t\tlayouts: reserved ? [] : branch.layouts,\n\t\t\treserved,\n\t\t\tlocation: void 0,\n\t\t\tissues: error.issues\n\t\t};\n\t}\n\tconst location = parsed.success;\n\tconst reserved = reservedSegments(location.segments);\n\tconst branch = matchPattern(patterns, location.segments);\n\tif (reserved || branch.route === void 0) return {\n\t\t_tag: \"NotFound\",\n\t\tstatus: 404,\n\t\tlayouts: reserved ? [] : branch.layouts,\n\t\treserved,\n\t\tlocation\n\t};\n\tconst route = branch.route;\n\tconst decoded = yield* decodeRouteInputs(route, branch.params, location.search).pipe(Effect.result);\n\tif (decoded._tag === \"Failure\") return {\n\t\t_tag: \"Invalid\",\n\t\tstatus: 400,\n\t\troute,\n\t\tlayouts: branch.layouts,\n\t\treserved: false,\n\t\tlocation,\n\t\tissues: decoded.failure.issues\n\t};\n\treturn {\n\t\t_tag: \"Matched\",\n\t\tstatus: 200,\n\t\troute,\n\t\tlayouts: branch.layouts,\n\t\treserved: false,\n\t\tlocation,\n\t\t...decoded.success\n\t};\n});\n/** Contains no URL, decoded values, or request-specific validation issues. */\nconst documentVariant = (outcome) => ({\n\toutcome: outcome._tag,\n\trouteId: outcome._tag === \"NotFound\" ? null : outcome.route?.id ?? null,\n\tlayoutIds: outcome.layouts.map((layout) => layout.id),\n\treserved: outcome.reserved\n});\nconst documentVariantKey = (outcome) => {\n\tconst variant = documentVariant(outcome);\n\treturn JSON.stringify([\n\t\tvariant.outcome,\n\t\tvariant.routeId,\n\t\tvariant.layoutIds,\n\t\tvariant.reserved\n\t]);\n};\n//#endregion\nexport { InvalidMetadata, InvalidUrl, MetadataInput, ParsedLocation, PartialLocation, RoutingDefinitionError, UrlIssue, buildUrl, compilePatterns, decodeRouteInputs, documentVariant, documentVariantKey, matchDirectory, matchLocation, matchPattern, parseLocation, parsePattern, resolveMetadata, validateRoutePattern };\n\n//# sourceMappingURL=routing.js.map","import * as Versioned from \"@ignotum/contracts/versioned\";\nimport { Deferred, Effect, Schema } from \"effect\";\n\nconst HistoryEntryV1 = Schema.Struct({ formatVersion: Schema.Literal(1), key: Schema.String });\nconst HistoryEntryV2 = Schema.Struct({\n formatVersion: Schema.Literal(2),\n key: Schema.String,\n index: Schema.NullOr(Schema.Int),\n});\nconst HistoryEntry = Versioned.upgrade(\n Versioned.initial(HistoryEntryV1),\n HistoryEntryV2,\n (old) => ({\n formatVersion: 2 as const,\n key: old.key,\n index: null,\n }),\n);\nconst HistoryState = Schema.Struct({ __ignotumRouter: HistoryEntry });\nconst StateObject = Schema.Record(Schema.String, Schema.Unknown);\nexport interface HistoryPosition {\n readonly key: string;\n readonly index: number;\n readonly href: string;\n}\nconst hrefOf = (browser: Window) =>\n `${browser.location.pathname}${browser.location.search}${browser.location.hash}`;\n\n/** Serializes router corrections to native traversal without adding duplicate entries. */\nexport class RouterHistory {\n committed: HistoryPosition;\n private actual: HistoryPosition;\n private readonly positions = new Map<string, number>();\n private seeking: { position: HistoryPosition; done: Deferred.Deferred<boolean> } | undefined;\n private readonly originalScrollRestoration;\n private direction = -1;\n private scrollPending = false;\n private expectedKey: string | undefined;\n readonly scroll = new Map<string, { x: number; y: number }>();\n constructor(\n private readonly browser: Window,\n private readonly onTraversal: (position: HistoryPosition) => void,\n ) {\n const parsed = Schema.decodeUnknownOption(HistoryState)(browser.history.state);\n const entry = parsed._tag === \"Some\" ? parsed.value.__ignotumRouter : undefined;\n this.actual = this.committed = {\n key: entry?.key ?? browser.crypto.randomUUID(),\n index: entry?.index ?? 0,\n href: hrefOf(browser),\n };\n this.write(this.actual, false);\n this.originalScrollRestoration = browser.history.scrollRestoration;\n browser.history.scrollRestoration = \"manual\";\n browser.addEventListener(\"popstate\", this.onPop);\n browser.addEventListener(\"scroll\", this.saveScroll);\n }\n private write(position: HistoryPosition, push: boolean): void {\n const parsed = Schema.decodeUnknownOption(StateObject)(this.browser.history.state);\n const owned = {\n __ignotumRouter: Schema.encodeSync(HistoryEntry)({\n formatVersion: 2,\n key: position.key,\n index: position.index,\n }),\n };\n const state = parsed._tag === \"Some\" ? { ...parsed.value, ...owned } : owned;\n if (push) this.browser.history.pushState(state, \"\", position.href);\n else this.browser.history.replaceState(state, \"\", position.href);\n this.positions.set(position.key, position.index);\n }\n saveScroll = (): void => {\n if (this.scrollPending) return;\n this.scroll.set(this.committed.key, { x: this.browser.scrollX, y: this.browser.scrollY });\n };\n captureScroll(): { x: number; y: number } {\n this.saveScroll();\n this.scrollPending = true;\n return (\n this.scroll.get(this.committed.key) ?? { x: this.browser.scrollX, y: this.browser.scrollY }\n );\n }\n finishScroll(): void {\n this.scrollPending = false;\n this.saveScroll();\n }\n restoreSourceScroll(): void {\n if (!this.scrollPending) return;\n const saved = this.scroll.get(this.committed.key);\n if (saved !== undefined) this.browser.scrollTo(saved.x, saved.y);\n this.finishScroll();\n }\n private onPop = (): void => {\n const parsed = Schema.decodeUnknownOption(HistoryState)(this.browser.history.state);\n const entry = parsed._tag === \"Some\" ? parsed.value.__ignotumRouter : undefined;\n const key = entry?.key ?? this.browser.crypto.randomUUID();\n const index = entry?.index ?? this.positions.get(key) ?? this.actual.index + this.direction;\n this.actual = { key, index, href: hrefOf(this.browser) };\n this.write(this.actual, false);\n const expected = this.expectedKey;\n this.expectedKey = undefined;\n const seeking = this.seeking;\n if (seeking !== undefined && (expected === key || seeking.position.key === key)) {\n this.advanceSeek();\n return;\n }\n if (seeking !== undefined) {\n this.seeking = undefined;\n Effect.runSync(Deferred.succeed(seeking.done, false));\n }\n this.onTraversal(this.actual);\n };\n private advanceSeek(): void {\n const seeking = this.seeking;\n if (seeking === undefined || this.expectedKey !== undefined) return;\n if (this.actual.key === seeking.position.key) {\n this.seeking = undefined;\n Effect.runSync(Deferred.succeed(seeking.done, true));\n } else {\n this.expectedKey = seeking.position.key;\n this.browser.history.go(seeking.position.index - this.actual.index);\n }\n }\n seek(position: HistoryPosition): Promise<boolean> {\n if (this.seeking !== undefined) {\n if (this.seeking.position.key === position.key)\n return Effect.runPromise(Deferred.await(this.seeking.done));\n Effect.runSync(Deferred.succeed(this.seeking.done, false));\n }\n const done = Deferred.makeUnsafe<boolean>();\n this.seeking = { position, done };\n this.advanceSeek();\n return Effect.runPromise(Deferred.await(done));\n }\n commit(position: HistoryPosition, kind: \"initial\" | \"push\" | \"replace\" | \"traverse\"): void {\n if (kind === \"push\" || kind === \"replace\") this.write(position, kind === \"push\");\n this.actual = this.committed = position;\n }\n back = (): void => {\n this.direction = -1;\n this.browser.history.back();\n };\n forward = (): void => {\n this.direction = 1;\n this.browser.history.forward();\n };\n dispose(): void {\n this.browser.removeEventListener(\"popstate\", this.onPop);\n this.browser.removeEventListener(\"scroll\", this.saveScroll);\n this.browser.history.scrollRestoration = this.originalScrollRestoration;\n if (this.seeking !== undefined) Effect.runSync(Deferred.succeed(this.seeking.done, false));\n }\n}\n","import type {\n AppModuleId,\n LayoutDefinition,\n ModuleExportReference,\n RouteDefinition,\n} from \"@ignotum/contracts/app-definition\";\nimport { ExecutionSelection } from \"@ignotum/contracts/platform\";\nimport { RouterHistory, type HistoryPosition } from \"./router-history.js\";\nimport {\n compilePatterns,\n matchLocation,\n resolveMetadata,\n type RouteOutcome,\n type UrlValue,\n type UrlIssue,\n} from \"@ignotum/shared/routing\";\nimport { Deferred, Effect, Predicate, Schema } from \"effect\";\nimport type { ComponentChildren, ComponentType } from \"preact\";\nimport type { NavigationResult, RouteLocation } from \"./routes.js\";\n\nexport interface RegisteredClientModule {\n readonly load: () => Promise<object>;\n readonly styles?: readonly string[];\n}\n\n/** Executable registration produced by the compiler, separate from the immutable declaration. */\nexport interface ClientRegistration {\n readonly applicationName: string;\n readonly routes: readonly RouteDefinition[];\n readonly layouts: readonly LayoutDefinition[];\n readonly modules: ReadonlyMap<AppModuleId, RegisteredClientModule>;\n readonly styles?: readonly string[];\n}\n\nexport interface RouterPageProps {\n readonly params: Readonly<Record<string, UrlValue>>;\n readonly searchParams: Readonly<Record<string, UrlValue>>;\n}\nexport interface RouterLayoutProps {\n readonly children: ComponentChildren;\n}\nexport interface ErrorBoundaryProps {\n readonly error: unknown;\n readonly retry: () => void;\n}\nexport interface InvalidBoundaryProps {\n readonly location: RouteLocation;\n readonly issues: readonly UrlIssue[];\n}\nexport interface NotFoundBoundaryProps {\n readonly location: RouteLocation;\n}\nconst ErrorComponent = Schema.declare((value): value is ComponentType<ErrorBoundaryProps> =>\n Predicate.isFunction(value),\n);\nconst InvalidComponent = Schema.declare((value): value is ComponentType<InvalidBoundaryProps> =>\n Predicate.isFunction(value),\n);\nconst NotFoundComponent = Schema.declare((value): value is ComponentType<NotFoundBoundaryProps> =>\n Predicate.isFunction(value),\n);\nconst PageModule = Schema.Struct({\n error: Schema.optional(ErrorComponent),\n invalid: Schema.optional(InvalidComponent),\n component: Schema.declare((value): value is ComponentType<RouterPageProps> =>\n Predicate.isFunction(value),\n ),\n});\nconst LayoutModule = Schema.Struct({\n error: Schema.optional(ErrorComponent),\n invalid: Schema.optional(InvalidComponent),\n notFound: Schema.optional(NotFoundComponent),\n component: Schema.declare((value): value is ComponentType<RouterLayoutProps> =>\n Predicate.isFunction(value),\n ),\n});\nconst ModuleExports = Schema.Record(Schema.String, Schema.Unknown);\n\nexport interface LoadedBranch {\n readonly outcome: RouteOutcome;\n readonly layouts: readonly {\n readonly id: LayoutDefinition[\"id\"];\n readonly component: ComponentType<RouterLayoutProps>;\n readonly error?: ComponentType<ErrorBoundaryProps>;\n readonly invalid?: ComponentType<InvalidBoundaryProps>;\n readonly notFound?: ComponentType<NotFoundBoundaryProps>;\n }[];\n readonly page: ComponentType<RouterPageProps> | undefined;\n readonly pageBoundaries?: {\n readonly error?: ComponentType<ErrorBoundaryProps>;\n readonly invalid?: ComponentType<InvalidBoundaryProps>;\n };\n}\nexport class BranchLoadError extends Schema.TaggedError<BranchLoadError>()(\"BranchLoadError\", {\n error: Schema.Unknown,\n branch: Schema.declare((value): value is LoadedBranch => Predicate.isObject(value)),\n}) {}\nexport type BlockerState =\n | { readonly status: \"idle\" }\n | {\n readonly status: \"blocked\";\n readonly from: RouteLocation;\n readonly to: RouteLocation;\n readonly proceed: () => void;\n readonly reset: () => void;\n };\nexport type NavigationState =\n | { readonly status: \"idle\" }\n | { readonly status: \"loading\"; readonly to: RouteLocation };\nexport interface RouterSnapshot {\n readonly location: RouteLocation | undefined;\n readonly branch: LoadedBranch | undefined;\n readonly navigation: NavigationState;\n readonly failure:\n | { readonly error: unknown; readonly retry: () => void; readonly branch?: LoadedBranch }\n | undefined;\n readonly commit: number;\n}\nexport interface NavigationOptions {\n readonly replace?: boolean;\n readonly scroll?: \"auto\" | \"preserve\";\n}\ninterface Transition {\n readonly id: number;\n readonly href: string;\n readonly location: RouteLocation;\n readonly kind: \"initial\" | \"push\" | \"replace\" | \"traverse\";\n readonly completion: Deferred.Deferred<NavigationResult>;\n readonly position: HistoryPosition;\n readonly scroll: \"auto\" | \"preserve\";\n readonly searchOnly: boolean;\n readonly sourceScroll: { readonly x: number; readonly y: number };\n}\n\nconst locationOf = (href: string, key: string, origin: string): RouteLocation => {\n const parsed = new URL(href, origin);\n let hash = parsed.hash.slice(1);\n try {\n hash = decodeURIComponent(hash);\n } catch {\n // Invalid fragments still need a readable location for the invalid-URL view.\n }\n return { pathname: parsed.pathname, search: parsed.search, hash, key };\n};\n\n/** One store per mount. Load caches contain code and CSS only, never component/query state. */\nexport class RouterStore {\n readonly selection: ExecutionSelection;\n private readonly patterns;\n private readonly listeners = new Set<() => void>();\n private readonly modules = new Map<AppModuleId, Promise<typeof ModuleExports.Type>>();\n private readonly styles = new Map<string, Promise<void>>();\n private readonly styleCleanups = new Set<() => void>();\n private readonly redirects = new Set<string>();\n private history: RouterHistory | undefined;\n private readonly blockers = new Set<symbol>();\n private blocked: { transition: Transition; remaining: Set<symbol> } | undefined;\n private upgrading = false;\n private admission:\n | { readonly validate: () => Promise<boolean>; readonly recoverLoad: () => Promise<void> }\n | undefined;\n private serial = 0;\n private transition: Transition | undefined;\n private committedHref: string | undefined;\n private disposed = false;\n private started = false;\n private snapshot: RouterSnapshot = {\n location: undefined,\n branch: undefined,\n navigation: { status: \"idle\" },\n failure: undefined,\n commit: 0,\n };\n\n constructor(\n private readonly registration: ClientRegistration,\n selection: ExecutionSelection,\n readonly browser: Window,\n ) {\n this.selection = Schema.decodeSync(ExecutionSelection)(selection);\n this.patterns = Effect.runSync(compilePatterns(registration.routes, registration.layouts));\n for (const reference of [\n ...registration.routes.map((route) => route.page),\n ...registration.layouts.map((layout) => layout.module),\n ]) {\n if (!registration.modules.has(reference.module))\n throw new Error(`Client module '${reference.module}' is missing from registration.`);\n }\n }\n\n getSnapshot = (): RouterSnapshot => this.snapshot;\n subscribe = (listener: () => void): (() => void) => {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n };\n private update(snapshot: RouterSnapshot): void {\n this.snapshot = snapshot;\n for (const listener of this.listeners) listener();\n }\n\n start(): Promise<NavigationResult> {\n if (this.started) throw new Error(\"The Ignotum router has already started.\");\n this.started = true;\n this.history = new RouterHistory(this.browser, this.onTraversal);\n this.browser.addEventListener(\"beforeunload\", this.onBeforeUnload);\n const position = this.history.committed;\n return this.transitionTo(position.href, \"initial\", position.key, {}, position);\n }\n\n private onTraversal = (position: HistoryPosition): void => {\n this.redirects.clear();\n // Native traversal already changed the address. Restore the source while confirmation/code waits.\n void this.history?.seek(this.history.committed);\n void this.transitionTo(position.href, \"traverse\", position.key, {}, position);\n };\n back = (): void => this.history?.back();\n forward = (): void => this.history?.forward();\n private onBeforeUnload = (event: BeforeUnloadEvent): void => {\n if (this.upgrading || this.blockers.size === 0) return;\n event.preventDefault();\n event.returnValue = \"\";\n };\n /** Internal platform upgrade entry; route confirmation never delays this reload. */\n stopForUpgrade = (): void => {\n if (this.disposed) return;\n this.upgrading = true;\n this.browser.removeEventListener(\"beforeunload\", this.onBeforeUnload);\n this.blockers.clear();\n this.cancelPending();\n };\n upgrade = (): void => {\n if (this.disposed) return;\n this.stopForUpgrade();\n this.browser.location.reload();\n };\n setAdmission(admission: NonNullable<RouterStore[\"admission\"]>): void {\n this.admission = admission;\n }\n setBlocker(id: symbol, when: boolean): void {\n if (when) this.blockers.add(id);\n else this.blockers.delete(id);\n if (!when && this.blocked?.remaining.delete(id) === true) this.releaseBlocked();\n }\n getBlocker(id: symbol): BlockerState {\n const blocked = this.blocked;\n const from = this.snapshot.location;\n if (blocked === undefined || from === undefined || !blocked.remaining.has(id))\n return { status: \"idle\" };\n return {\n status: \"blocked\",\n from,\n to: blocked.transition.location,\n proceed: () => {\n if (this.blocked !== blocked) return;\n blocked.remaining.delete(id);\n this.releaseBlocked();\n },\n reset: () => {\n if (this.blocked !== blocked) return;\n this.cancelPending();\n this.update({ ...this.snapshot, navigation: { status: \"idle\" } });\n },\n };\n }\n private releaseBlocked(): void {\n const blocked = this.blocked;\n if (blocked === undefined) return;\n if (blocked.remaining.size === 0) {\n this.blocked = undefined;\n this.loadTransition(blocked.transition);\n } else this.update({ ...this.snapshot });\n }\n\n navigate(\n href: string,\n options: NavigationOptions = {},\n redirect = false,\n ): Promise<NavigationResult> {\n if (this.disposed || this.upgrading) return Promise.resolve({ status: \"cancelled\" });\n if (!redirect) this.redirects.clear();\n if (href === this.committedHref) {\n this.cancelPending();\n this.update({ ...this.snapshot, navigation: { status: \"idle\" }, failure: undefined });\n return Promise.resolve({ status: \"committed\" });\n }\n if (redirect) {\n if (this.committedHref !== undefined) this.redirects.add(this.committedHref);\n if (this.redirects.has(href) || this.redirects.size >= 32) {\n const error = new Error(`Ignotum redirect loop at '${href}'.`);\n this.cancelPending();\n this.update({\n ...this.snapshot,\n navigation: { status: \"idle\" },\n failure: {\n error,\n retry: () => {\n this.redirects.clear();\n void this.navigate(href, options, true);\n },\n },\n });\n return Promise.resolve({ status: \"failed\", error });\n }\n }\n const key =\n options.replace === true\n ? (this.snapshot.location?.key ?? this.browser.crypto.randomUUID())\n : this.browser.crypto.randomUUID();\n return this.transitionTo(href, options.replace === true ? \"replace\" : \"push\", key, options);\n }\n\n preload = async (href: string): Promise<void> => {\n if (\n this.disposed ||\n this.upgrading ||\n (this.admission !== undefined && !(await this.admission.validate()))\n )\n return;\n const outcome = Effect.runSync(matchLocation(this.patterns, href));\n await this.loadBranch(outcome, false);\n };\n\n private cancelPending(): void {\n if (this.history !== undefined) void this.history.seek(this.history.committed);\n this.blocked = undefined;\n if (this.transition !== undefined)\n Effect.runSync(Deferred.succeed(this.transition.completion, { status: \"cancelled\" }));\n this.transition = undefined;\n }\n\n private transitionTo(\n href: string,\n kind: Transition[\"kind\"],\n key: string,\n options: NavigationOptions = {},\n historyPosition?: HistoryPosition,\n ): Promise<NavigationResult> {\n if (this.disposed || this.upgrading) return Promise.resolve({ status: \"cancelled\" });\n const sourceScroll = this.history?.captureScroll() ?? {\n x: this.browser.scrollX,\n y: this.browser.scrollY,\n };\n this.cancelPending();\n const location = locationOf(href, key, this.browser.location.origin);\n const previous = this.snapshot.location;\n const searchOnly =\n previous !== undefined &&\n previous.pathname === location.pathname &&\n previous.hash === location.hash;\n const completion = Deferred.makeUnsafe<NavigationResult>();\n const position = historyPosition ?? {\n key,\n href,\n index: (this.history?.committed.index ?? 0) + (kind === \"push\" ? 1 : 0),\n };\n const transition: Transition = {\n id: ++this.serial,\n href,\n location,\n kind,\n completion,\n position,\n scroll: options.scroll ?? (searchOnly ? \"preserve\" : \"auto\"),\n searchOnly,\n sourceScroll,\n };\n this.transition = transition;\n if (kind !== \"initial\" && this.blockers.size > 0 && this.snapshot.location !== undefined) {\n this.blocked = { transition, remaining: new Set(this.blockers) };\n this.update({ ...this.snapshot, navigation: { status: \"idle\" }, failure: undefined });\n } else this.loadTransition(transition);\n return Effect.runPromise(Deferred.await(completion));\n }\n\n private loadTransition(transition: Transition): void {\n const { href, location, kind } = transition;\n const outcome = Effect.runSync(matchLocation(this.patterns, href));\n this.update({\n ...this.snapshot,\n navigation: { status: \"loading\", to: location },\n failure: undefined,\n });\n const load = async () => {\n if (this.admission !== undefined && !(await this.admission.validate()))\n throw new Error(\"The app must verify its current selection before navigating.\");\n if (this.upgrading || this.disposed) throw new Error(\"The app is updating.\");\n return this.loadBranch(outcome);\n };\n void load().then(\n async (branch) => {\n if (this.transition !== transition || this.disposed) return;\n try {\n const history = this.history;\n if (history !== undefined) {\n const restored = await history.seek(history.committed);\n if (!restored || this.transition !== transition || this.disposed) return;\n if (kind === \"traverse\") {\n const arrived = await history.seek(transition.position);\n if (!arrived || this.transition !== transition || this.disposed) return;\n }\n history.commit(transition.position, kind);\n }\n this.applyMetadata(outcome);\n this.committedHref = href;\n this.update({\n location,\n branch,\n navigation: { status: \"idle\" },\n failure: undefined,\n commit: transition.id,\n });\n } catch (error) {\n this.fail(transition, error);\n }\n },\n (error) => {\n this.fail(transition, error);\n if (!this.upgrading) void this.admission?.recoverLoad();\n },\n );\n }\n\n /** Called by the mounted view after Preact has committed the destination DOM. */\n rendered(commit: number): void {\n if (this.transition?.id !== commit || this.snapshot.commit !== commit) {\n if (this.snapshot.navigation.status === \"idle\" && this.blocked === undefined)\n this.history?.restoreSourceScroll();\n return;\n }\n const transition = this.transition;\n const document = this.browser.document;\n if (!transition.searchOnly) {\n const target =\n document.querySelector<HTMLElement>(\"#app main, #app [role=main]\") ??\n document.getElementById(\"app\");\n if (target !== null) {\n const hadTabIndex = target.hasAttribute(\"tabindex\");\n if (!hadTabIndex) target.setAttribute(\"tabindex\", \"-1\");\n target.focus({ preventScroll: true });\n }\n }\n const saved = this.history?.scroll.get(transition.location.key);\n if (transition.kind === \"traverse\" && saved !== undefined)\n this.browser.scrollTo(saved.x, saved.y);\n else if (transition.scroll === \"auto\") {\n const target =\n transition.location.hash === \"\" ? null : document.getElementById(transition.location.hash);\n if (target !== null) target.scrollIntoView();\n else this.browser.scrollTo(0, 0);\n } else this.browser.scrollTo(transition.sourceScroll.x, transition.sourceScroll.y);\n this.history?.finishScroll();\n Effect.runSync(Deferred.succeed(this.transition.completion, { status: \"committed\" }));\n this.transition = undefined;\n }\n\n // oxlint-disable-next-line anti-slop/no-unknown-parameters -- Module loaders and DOM APIs can throw arbitrary values; NavigationResult preserves the original error.\n private fail(transition: Transition, error: unknown): void {\n if (this.transition !== transition || this.disposed) return;\n this.transition = undefined;\n const loadFailure = error instanceof BranchLoadError ? error : undefined;\n const originalError = loadFailure === undefined ? error : loadFailure.error;\n this.update({\n ...this.snapshot,\n navigation: { status: \"idle\" },\n failure: {\n error: originalError,\n branch: transition.kind === \"initial\" ? undefined : loadFailure?.branch,\n retry: () => {\n void this.transitionTo(\n transition.href,\n transition.kind,\n transition.location.key,\n { scroll: transition.scroll },\n transition.position,\n );\n },\n },\n });\n Effect.runSync(\n Deferred.succeed(transition.completion, { status: \"failed\", error: originalError }),\n );\n }\n\n private loadStyle(href: string): Promise<void> {\n const absolute = new URL(href, this.browser.location.origin).href;\n const cached = this.styles.get(absolute);\n if (cached !== undefined) return cached;\n const document = this.browser.document;\n const existing = Array.from(\n document.querySelectorAll<HTMLLinkElement>('link[rel=\"stylesheet\"]'),\n ).find((link) => link.href === absolute);\n if (existing?.sheet !== null && existing?.sheet !== undefined) return Promise.resolve();\n const link = existing ?? document.createElement(\"link\");\n const promise = Effect.runPromise(\n Effect.callback<void, Error>((resume) => {\n const cleanup = () => {\n link.removeEventListener(\"load\", onLoad);\n link.removeEventListener(\"error\", onError);\n this.styleCleanups.delete(cancel);\n };\n const onLoad = () => {\n cleanup();\n resume(Effect.void);\n };\n const onError = () => {\n cleanup();\n link.remove();\n resume(Effect.fail(new Error(`Could not load route stylesheet '${href}'.`)));\n };\n const cancel = () => {\n cleanup();\n if (existing === undefined) link.remove();\n resume(Effect.fail(new Error(\"Router disposed.\")));\n };\n this.styleCleanups.add(cancel);\n link.addEventListener(\"load\", onLoad);\n link.addEventListener(\"error\", onError);\n if (existing === undefined) {\n link.rel = \"stylesheet\";\n link.crossOrigin = \"anonymous\";\n link.href = absolute;\n document.head.append(link);\n }\n return Effect.sync(cleanup);\n }),\n ).catch((error) => {\n this.styles.delete(absolute);\n throw error;\n });\n this.styles.set(absolute, promise);\n return promise;\n }\n\n private loadModule(id: AppModuleId): Promise<typeof ModuleExports.Type> {\n const cached = this.modules.get(id);\n if (cached !== undefined) return cached;\n const module = this.registration.modules.get(id);\n if (module === undefined)\n return Promise.reject(new Error(`Client module '${id}' is not registered.`));\n const loaded = Promise.resolve()\n .then(module.load)\n .then(Schema.decodeUnknownSync(ModuleExports))\n .catch((error) => {\n this.modules.delete(id);\n throw error;\n });\n this.modules.set(id, loaded);\n return loaded;\n }\n private async loadExport(reference: ModuleExportReference): Promise<typeof Schema.Unknown.Type> {\n const exports = await this.loadModule(reference.module);\n if (!Object.hasOwn(exports, reference.exportName))\n throw new Error(`Module '${reference.module}' has no '${reference.exportName}' export.`);\n return exports[reference.exportName];\n }\n private async loadBranch(outcome: RouteOutcome, withStyles = true): Promise<LoadedBranch> {\n const route = outcome._tag === \"NotFound\" ? undefined : outcome.route;\n const available = new Map<LayoutDefinition[\"id\"], LoadedBranch[\"layouts\"][number]>();\n try {\n const [layouts, page] = await Promise.all([\n Promise.all(\n outcome.layouts.map(async (layout) => {\n const [loaded] = await Promise.all([\n this.loadExport(layout.module).then(Schema.decodeUnknownSync(LayoutModule)),\n withStyles\n ? Promise.all(\n (this.registration.modules.get(layout.module.module)?.styles ?? []).map(\n (href) => this.loadStyle(href),\n ),\n )\n : undefined,\n ]);\n const result = { id: layout.id, ...loaded };\n available.set(layout.id, result);\n return result;\n }),\n ),\n route === undefined\n ? undefined\n : this.loadExport(route.page).then(Schema.decodeUnknownSync(PageModule)),\n Promise.all(\n withStyles\n ? [\n ...(this.registration.styles ?? []),\n ...(route === undefined\n ? []\n : (this.registration.modules.get(route.page.module)?.styles ?? [])),\n ].map(async (href) => this.loadStyle(href))\n : [],\n ),\n ]);\n return { outcome, layouts, page: page?.component, pageBoundaries: page };\n } catch (error) {\n const layouts: Array<LoadedBranch[\"layouts\"][number]> = [];\n for (const definition of outcome.layouts) {\n const loaded = available.get(definition.id);\n if (loaded === undefined) break;\n layouts.push(loaded);\n }\n throw BranchLoadError.make({ error, branch: { outcome, layouts, page: undefined } });\n }\n }\n\n setRenderError(error: boolean): void {\n if (this.snapshot.branch !== undefined) this.applyMetadata(this.snapshot.branch.outcome, error);\n }\n\n private applyMetadata(outcome: RouteOutcome, renderError = false): void {\n const resolved = Effect.runSync(\n resolveMetadata({\n applicationName: this.registration.applicationName,\n layouts: outcome.layouts.map((layout) => layout.metadata),\n page: outcome._tag === \"NotFound\" ? undefined : outcome.route?.metadata,\n outcome: renderError ? \"Invalid\" : outcome._tag,\n }),\n );\n const document = this.browser.document;\n document.title = resolved.title;\n for (const name of [\"description\", \"robots\"] as const) {\n const tags = Array.from(\n document.head.querySelectorAll<HTMLMetaElement>(`meta[name=\"${name}\"]`),\n );\n const value = resolved.meta[name];\n if (value === undefined) {\n for (const tag of tags) tag.remove();\n continue;\n }\n const tag = tags.shift() ?? document.createElement(\"meta\");\n for (const duplicate of tags) duplicate.remove();\n tag.name = name;\n tag.content = value;\n if (!tag.isConnected) document.head.append(tag);\n }\n }\n\n dispose(): void {\n this.disposed = true;\n this.cancelPending();\n this.history?.dispose();\n this.browser.removeEventListener(\"beforeunload\", this.onBeforeUnload);\n for (const cleanup of this.styleCleanups) cleanup();\n this.listeners.clear();\n }\n}\n","import { createElement as h, Fragment, type ComponentChildren, type ComponentType } from \"preact\";\nimport { useErrorBoundary, useState } from \"preact/hooks\";\nimport type {\n ErrorBoundaryProps,\n LoadedBranch,\n RouterSnapshot,\n RouterStore,\n} from \"./router-store.js\";\nimport type { RouteLocation } from \"./routes.js\";\n\nexport const DefaultError = ({ error, retry }: ErrorBoundaryProps): ComponentChildren =>\n h(\n \"div\",\n { role: \"alert\" },\n error instanceof Error ? error.message : \"This page could not load or render. \",\n h(\"button\", { onClick: retry }, \"Retry\"),\n );\n\ninterface BoundaryProps {\n readonly children: ComponentChildren;\n readonly component: ComponentType<ErrorBoundaryProps>;\n readonly branch: LoadedBranch;\n readonly router: RouterStore;\n readonly onRetry?: () => void;\n}\nconst Boundary = ({\n children,\n component,\n branch,\n router,\n onRetry,\n}: BoundaryProps): ComponentChildren => {\n const [failure, setFailure] = useState<{\n readonly branch: LoadedBranch;\n readonly error: unknown;\n }>();\n const [, reset] = useErrorBoundary((error) => {\n setFailure({ branch, error });\n router.setRenderError(true);\n });\n return failure?.branch !== branch\n ? children\n : h(component, {\n error: failure.error,\n retry: () => {\n router.setRenderError(false);\n onRetry?.();\n setFailure(undefined);\n reset();\n },\n });\n};\n\nexport const Branch = ({\n branch,\n location,\n router,\n failure,\n}: {\n readonly branch: LoadedBranch;\n readonly location: RouteLocation;\n readonly router: RouterStore;\n readonly failure: RouterSnapshot[\"failure\"];\n}): ComponentChildren => {\n const outcome = branch.outcome;\n let child: ComponentChildren;\n let lastLayout = branch.layouts.length - 1;\n let boundaryOwner: number | undefined;\n if (outcome._tag === \"Matched\" && branch.page !== undefined) {\n child = h(branch.page, {\n key: outcome.route.id,\n params: outcome.params,\n searchParams: outcome.searchParams,\n });\n } else if (outcome._tag === \"Invalid\" && branch.pageBoundaries?.invalid !== undefined) {\n child = h(branch.pageBoundaries.invalid, { location, issues: outcome.issues });\n } else {\n child = h(\n \"main\",\n { \"data-ignotum-outcome\": outcome._tag },\n outcome._tag === \"Invalid\" ? \"Invalid URL\" : \"Page not found\",\n );\n for (let index = lastLayout; index >= 0; index--) {\n const layout = branch.layouts[index]!;\n if (outcome._tag === \"Invalid\" && layout.invalid !== undefined) {\n child = h(layout.invalid, { location, issues: outcome.issues });\n lastLayout = index;\n boundaryOwner = index;\n break;\n }\n if (outcome._tag === \"NotFound\" && layout.notFound !== undefined) {\n child = h(layout.notFound, { location });\n lastLayout = index;\n boundaryOwner = index;\n break;\n }\n }\n }\n if (branch.pageBoundaries?.error !== undefined && outcome._tag === \"Matched\")\n child = h(Boundary, {\n key: \"page-boundary\",\n component: branch.pageBoundaries.error,\n branch,\n router,\n children: child,\n });\n let sharedLayouts = 0;\n while (\n sharedLayouts <= lastLayout &&\n branch.layouts[sharedLayouts]?.id === failure?.branch?.layouts[sharedLayouts]?.id\n )\n sharedLayouts++;\n const loadFailure =\n failure === undefined\n ? null\n : h(LoadFailure, {\n failure,\n router,\n layouts: branch.layouts.slice(0, sharedLayouts),\n });\n for (let index = lastLayout; index >= 0; index--) {\n const layout = branch.layouts[index]!;\n if (layout.error !== undefined && index !== boundaryOwner)\n child = h(Boundary, {\n key: layout.id,\n component: layout.error,\n branch,\n router,\n children: child,\n });\n child = h(layout.component, {\n key: layout.id,\n children: h(Fragment, {}, child, index === sharedLayouts - 1 ? loadFailure : null),\n });\n }\n return h(Boundary, {\n component: DefaultError,\n branch,\n router,\n children: h(Fragment, {}, child, sharedLayouts === 0 ? loadFailure : null),\n });\n};\n\nexport const LoadFailure = ({\n failure,\n router,\n layouts,\n}: {\n readonly failure: NonNullable<RouterSnapshot[\"failure\"]>;\n readonly layouts?: LoadedBranch[\"layouts\"];\n readonly router: RouterStore;\n}): ComponentChildren => {\n const branch = failure.branch;\n if (branch === undefined)\n return h(\"div\", { \"data-ignotum-load-error\": \"\" }, h(DefaultError, failure));\n let child: ComponentChildren = h(DefaultError, failure);\n let found = false;\n for (const layout of [...(layouts ?? branch.layouts)].reverse()) {\n if (layout.error === undefined) continue;\n if (!found) {\n child = h(layout.error, { error: failure.error, retry: failure.retry });\n found = true;\n } else {\n child = h(Boundary, {\n component: layout.error,\n branch,\n router,\n onRetry: failure.retry,\n children: child,\n });\n }\n }\n return h(\n \"div\",\n { \"data-ignotum-load-error\": \"\" },\n h(Boundary, {\n component: DefaultError,\n branch,\n router,\n onRetry: failure.retry,\n children: child,\n }),\n );\n};\n","import type { ExecutionSelection } from \"@ignotum/contracts/platform\";\nimport { createElement, Fragment, render, type ComponentChildren } from \"preact\";\nimport { useLayoutEffect, useState } from \"preact/hooks\";\nimport { mountManagedSync } from \"./sync.js\";\nimport type { ManagedBrowserClient } from \"./managed-client.js\";\nimport { RouterContext, useRouterSnapshot } from \"./router.js\";\n// oxlint-disable-next-line anti-slop-effect/no-service-constructor-imports -- Each browser mount owns its router and releases it on disposal.\nimport { RouterStore, type ClientRegistration } from \"./router-store.js\";\n\nimport { Branch, LoadFailure } from \"./route-boundaries.js\";\n\nconst RouterView = ({ router }: { readonly router: RouterStore }): ComponentChildren => {\n const snapshot = useRouterSnapshot(router);\n useLayoutEffect(() => {\n router.rendered(snapshot.commit);\n }, [router, snapshot]);\n return createElement(\n RouterContext.Provider,\n { value: router },\n snapshot.branch === undefined || snapshot.location === undefined\n ? createElement(\"div\", { role: \"status\" }, snapshot.failure === undefined ? \"Loading…\" : null)\n : createElement(Branch, {\n branch: snapshot.branch,\n location: snapshot.location,\n router,\n failure: snapshot.failure,\n }),\n snapshot.failure !== undefined && snapshot.branch === undefined\n ? createElement(LoadFailure, { failure: snapshot.failure, router })\n : null,\n );\n};\n\nconst mounts = new WeakSet<Element>();\n\nconst ManagedStatus = ({ client }: { readonly client: ManagedBrowserClient }) => {\n const [snapshot, setSnapshot] = useState(client.upgrade.getSnapshot);\n useLayoutEffect(\n () => client.upgrade.subscribe(() => setSnapshot(client.upgrade.getSnapshot())),\n [client],\n );\n if (snapshot.phase === \"ready\" && snapshot.recovery.length === 0) return null;\n return createElement(\n \"aside\",\n {\n \"data-ignotum-update\": snapshot.phase,\n role: snapshot.phase === \"error\" ? \"alert\" : \"status\",\n },\n snapshot.message ?? (snapshot.phase === \"connecting\" ? \"Connecting to the app…\" : null),\n snapshot.recovery.length === 0\n ? null\n : createElement(\n \"ul\",\n null,\n snapshot.recovery.map((message) => createElement(\"li\", { key: message }, message)),\n ),\n snapshot.phase === \"error\"\n ? createElement(\"button\", { type: \"button\", onClick: () => client.retry() }, \"Reload app\")\n : null,\n snapshot.recovery.length === 0\n ? null\n : createElement(\n \"button\",\n { type: \"button\", onClick: client.upgrade.dismissRecovery },\n \"Dismiss\",\n ),\n );\n};\n\n/** The platform owns mounting. Generated registrations contain no Preact render/bootstrap code. */\nexport const mountClient = (registration: ClientRegistration, selection: ExecutionSelection) => {\n const root = window.document.getElementById(\"app\");\n if (root === null) throw new Error(\"Ignotum mount element is missing.\");\n if (mounts.has(root)) throw new Error(\"The Ignotum client is already mounted.\");\n const router = new RouterStore(registration, selection, window);\n const managed = mountManagedSync(selection, window, {\n stopAdmission: router.stopForUpgrade,\n reload: router.upgrade,\n });\n router.setAdmission({\n validate: managed.client.validate,\n recoverLoad: managed.client.recoverLoad,\n });\n render(\n createElement(\n Fragment,\n null,\n createElement(ManagedStatus, { client: managed.client }),\n createElement(RouterView, { router }),\n ),\n root,\n );\n const ready = managed.client\n .whenReady()\n .then((accepted) => (accepted ? router.start() : { status: \"cancelled\" as const }));\n mounts.add(root);\n let disposed = false;\n return {\n ready,\n upgrade: () => managed.client.upgrade.require(),\n dispose: () => {\n if (disposed) return;\n disposed = true;\n mounts.delete(root);\n router.dispose();\n managed.dispose();\n render(null, root);\n },\n };\n};\n"],"mappings":";;;;;;;AAGA,MAAM,gBAAgB,OAAO,OAAO;CACnC,iBAAiB,OAAO,OAAO,MAAM,OAAO,YAAY,CAAC,GAAG,OAAO,YAAY,GAAG,CAAC;CACnF,SAAS,OAAO,MAAM,cAAc,CAAC,CAAC,MAAM,OAAO,YAAY,oBAAoB,OAAO,CAAC;CAC3F,MAAM,OAAO,SAAS,cAAc;CACpC,SAAS,OAAO,SAAS;EACxB;EACA;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;EACtB,QAAQ,OAAO;CACjB,CAAC;CACD,OAAO,aAAa;EAClB,UAAU,QAAQ,OAAO;EACzB,aAAa,QAAQ,OAAO;CAC9B,CAAC;CACD,OACE,cACE,UACA,MACA,cAAc,eAAe,EAAE,QAAQ,QAAQ,OAAO,CAAC,GACvD,cAAc,YAAY,EAAE,OAAO,CAAC,CACtC,GACA,IACF;CACA,MAAM,QAAQ,QAAQ,OACnB,UAAU,CAAC,CACX,MAAM,aAAc,WAAW,OAAO,MAAM,IAAI,EAAE,QAAQ,YAAqB,CAAE;CACpF,OAAO,IAAI,IAAI;CACf,IAAI,WAAW;CACf,OAAO;EACL;EACA,eAAe,QAAQ,OAAO,QAAQ,QAAQ;EAC9C,eAAe;GACb,IAAI,UAAU;GACd,WAAW;GACX,OAAO,OAAO,IAAI;GAClB,OAAO,QAAQ;GACf,QAAQ,QAAQ;GAChB,OAAO,MAAM,IAAI;EACnB;CACF;AACF"}
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import { Effect, Function, Predicate, Schema } from "effect";
|
|
2
|
-
//#region ../contracts/dist/descriptor-CTY4mtwS.js
|
|
3
|
-
const ValueEvolutionTypeId = Symbol.for("ignotum/schema/ValueEvolution");
|
|
4
|
-
const evolutionRules = (value) => value[ValueEvolutionTypeId] ?? {};
|
|
5
|
-
const codec = (value) => Schema.toCodecJson(value);
|
|
6
|
-
const encode = (schema, value) => Schema.decodeUnknownSync(Schema.Json)(Schema.encodeUnknownSync(codec(schema), { onExcessProperty: "error" })(value));
|
|
7
|
-
const decode = (schema, value) => Schema.decodeUnknownSync(codec(schema), { onExcessProperty: "error" })(value);
|
|
8
|
-
const copy = (value) => Object.create(Object.getPrototypeOf(value), Object.getOwnPropertyDescriptors(value));
|
|
9
|
-
const isValueObject = Schema.is(Schema.Record(Schema.String, Schema.Unknown));
|
|
10
|
-
const attachEvolution = (value, rules = {}) => {
|
|
11
|
-
Object.defineProperty(value, ValueEvolutionTypeId, {
|
|
12
|
-
configurable: true,
|
|
13
|
-
value: rules
|
|
14
|
-
});
|
|
15
|
-
return Object.assign(value, {
|
|
16
|
-
default(defaultValue) {
|
|
17
|
-
if (getValueDescriptor(value)?.type === "optional") throw new Error("Defaults require a non-optional validator. A default already allows omission on creation.");
|
|
18
|
-
const defaultJson = JSON.stringify(encode(value, defaultValue));
|
|
19
|
-
const next = copy(value);
|
|
20
|
-
const constructor = Schema.withConstructorDefault(Effect.sync(() => decode(value, JSON.parse(defaultJson))))(value);
|
|
21
|
-
Object.defineProperty(next, "ast", {
|
|
22
|
-
value: constructor.ast,
|
|
23
|
-
configurable: true
|
|
24
|
-
});
|
|
25
|
-
return attachEvolution(next, {
|
|
26
|
-
...rules,
|
|
27
|
-
defaultJson
|
|
28
|
-
});
|
|
29
|
-
},
|
|
30
|
-
renameFrom(name) {
|
|
31
|
-
if (name.length === 0 || [
|
|
32
|
-
"id",
|
|
33
|
-
"createdAt",
|
|
34
|
-
"updatedAt"
|
|
35
|
-
].includes(name)) throw new Error(`Cannot rename reserved or empty field '${name}'.`);
|
|
36
|
-
return attachEvolution(copy(value), {
|
|
37
|
-
...rules,
|
|
38
|
-
renameFrom: name
|
|
39
|
-
});
|
|
40
|
-
},
|
|
41
|
-
from(previous, convert) {
|
|
42
|
-
if (getValueDescriptor(previous) === void 0) throw new Error("Historical values must use an Ignotum values validator.");
|
|
43
|
-
return attachEvolution(copy(value), {
|
|
44
|
-
...rules,
|
|
45
|
-
previous: [...rules.previous ?? [], {
|
|
46
|
-
schema: previous,
|
|
47
|
-
convert
|
|
48
|
-
}]
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
const withValueChildren = (value, children) => {
|
|
54
|
-
attachEvolution(value, {
|
|
55
|
-
...evolutionRules(value),
|
|
56
|
-
children
|
|
57
|
-
});
|
|
58
|
-
return value;
|
|
59
|
-
};
|
|
60
|
-
const validateFieldRenames = (fields) => {
|
|
61
|
-
const sources = /* @__PURE__ */ new Set();
|
|
62
|
-
for (const [name, field] of Object.entries(fields)) {
|
|
63
|
-
const source = evolutionRules(field).renameFrom;
|
|
64
|
-
if (source === void 0) continue;
|
|
65
|
-
if (source === name || Object.hasOwn(fields, source) || sources.has(source)) throw new Error(`Rename source '${source}' conflicts with another field.`);
|
|
66
|
-
sources.add(source);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
const mapChildren = (schema, value, visit, rename) => {
|
|
70
|
-
const children = evolutionRules(schema).children;
|
|
71
|
-
if (children === void 0) return value;
|
|
72
|
-
switch (children.type) {
|
|
73
|
-
case "object": {
|
|
74
|
-
if (!isValueObject(value)) return value;
|
|
75
|
-
const result = { ...value };
|
|
76
|
-
for (const [name, field] of Object.entries(children.fields)) {
|
|
77
|
-
const source = rename ? evolutionRules(field).renameFrom : void 0;
|
|
78
|
-
if (source !== void 0 && Object.hasOwn(result, source)) {
|
|
79
|
-
if (Object.hasOwn(result, name)) throw new Error(`Both '${name}' and its rename source '${source}' are present.`);
|
|
80
|
-
Object.defineProperty(result, name, {
|
|
81
|
-
value: result[source],
|
|
82
|
-
enumerable: true,
|
|
83
|
-
configurable: true,
|
|
84
|
-
writable: true
|
|
85
|
-
});
|
|
86
|
-
delete result[source];
|
|
87
|
-
}
|
|
88
|
-
const next = visit(field, Object.hasOwn(result, name) ? result[name] : void 0);
|
|
89
|
-
if (next !== void 0) Object.defineProperty(result, name, {
|
|
90
|
-
value: next,
|
|
91
|
-
enumerable: true,
|
|
92
|
-
configurable: true,
|
|
93
|
-
writable: true
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
98
|
-
case "array": return Array.isArray(value) ? value.map((item) => visit(children.value, item)) : value;
|
|
99
|
-
case "record": return isValueObject(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit(children.value, item)])) : value;
|
|
100
|
-
case "nullable": return value === null ? value : visit(children.value, value);
|
|
101
|
-
case "optional": return value === void 0 ? value : visit(children.value, value);
|
|
102
|
-
case "union":
|
|
103
|
-
for (const member of children.members) try {
|
|
104
|
-
const result = visit(member, value);
|
|
105
|
-
if (rename) decode(member, result);
|
|
106
|
-
else encode(member, result);
|
|
107
|
-
return result;
|
|
108
|
-
} catch {}
|
|
109
|
-
return value;
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
/** Apply creation defaults to decoded values, without accepting historical representations. */
|
|
113
|
-
const applyValueDefaults = (schema, value) => {
|
|
114
|
-
const rules = evolutionRules(schema);
|
|
115
|
-
if (value === void 0 && rules.defaultJson !== void 0) return decode(schema, JSON.parse(rules.defaultJson));
|
|
116
|
-
return mapChildren(schema, value, applyValueDefaults, false);
|
|
117
|
-
};
|
|
118
|
-
/** Convert a stored JSON value to the current representation, preserving already valid values. */
|
|
119
|
-
const evolveStoredValue = (schema, value) => {
|
|
120
|
-
try {
|
|
121
|
-
decode(schema, value);
|
|
122
|
-
return value;
|
|
123
|
-
} catch {}
|
|
124
|
-
const rules = evolutionRules(schema);
|
|
125
|
-
if (value === void 0 && rules.defaultJson !== void 0) return JSON.parse(rules.defaultJson);
|
|
126
|
-
let failure;
|
|
127
|
-
try {
|
|
128
|
-
const next = mapChildren(schema, value, evolveStoredValue, true);
|
|
129
|
-
decode(schema, next);
|
|
130
|
-
return next;
|
|
131
|
-
} catch (cause) {
|
|
132
|
-
failure = cause;
|
|
133
|
-
}
|
|
134
|
-
const matches = [];
|
|
135
|
-
for (const previous of rules.previous ?? []) try {
|
|
136
|
-
matches.push({
|
|
137
|
-
previous,
|
|
138
|
-
value: decode(previous.schema, value)
|
|
139
|
-
});
|
|
140
|
-
} catch {}
|
|
141
|
-
if (matches.length > 1) throw new Error("More than one historical validator matches this value.");
|
|
142
|
-
const match = matches[0];
|
|
143
|
-
if (match === void 0) throw failure;
|
|
144
|
-
return encode(schema, applyValueDefaults(schema, match.previous.convert(match.value)));
|
|
145
|
-
};
|
|
146
|
-
const evolveStoredFields = (schema, value) => Schema.decodeUnknownSync(Schema.JsonObject)(evolveStoredValue(schema, value));
|
|
147
|
-
const LiteralValue = Schema.Union([
|
|
148
|
-
Schema.String,
|
|
149
|
-
Schema.Finite,
|
|
150
|
-
Schema.Boolean
|
|
151
|
-
]);
|
|
152
|
-
const DescriptorField = Schema.Struct({
|
|
153
|
-
name: Schema.String,
|
|
154
|
-
value: Schema.suspend(() => ValueDescriptor)
|
|
155
|
-
});
|
|
156
|
-
const ValueDescriptor = Schema.Union([
|
|
157
|
-
Schema.Struct({
|
|
158
|
-
type: Schema.Literal("array"),
|
|
159
|
-
value: Schema.suspend(() => ValueDescriptor)
|
|
160
|
-
}),
|
|
161
|
-
Schema.Struct({ type: Schema.Literal("boolean") }),
|
|
162
|
-
Schema.Struct({ type: Schema.Literal("date") }),
|
|
163
|
-
Schema.Struct({
|
|
164
|
-
type: Schema.Literal("file"),
|
|
165
|
-
formats: Schema.Array(Schema.Literals([
|
|
166
|
-
"jpeg",
|
|
167
|
-
"png",
|
|
168
|
-
"webp",
|
|
169
|
-
"avif",
|
|
170
|
-
"gif"
|
|
171
|
-
])),
|
|
172
|
-
maxBytes: Schema.Int
|
|
173
|
-
}),
|
|
174
|
-
Schema.Struct({
|
|
175
|
-
type: Schema.Literal("error"),
|
|
176
|
-
tag: Schema.String,
|
|
177
|
-
fields: Schema.Array(DescriptorField)
|
|
178
|
-
}),
|
|
179
|
-
Schema.Struct({
|
|
180
|
-
type: Schema.Literal("id"),
|
|
181
|
-
table: Schema.String
|
|
182
|
-
}),
|
|
183
|
-
Schema.Struct({ type: Schema.Literal("userId") }),
|
|
184
|
-
Schema.Struct({ type: Schema.Literal("integer") }),
|
|
185
|
-
Schema.Struct({
|
|
186
|
-
type: Schema.Literal("literal"),
|
|
187
|
-
value: LiteralValue
|
|
188
|
-
}),
|
|
189
|
-
Schema.Struct({
|
|
190
|
-
type: Schema.Literal("literals"),
|
|
191
|
-
values: Schema.Array(LiteralValue)
|
|
192
|
-
}),
|
|
193
|
-
Schema.Struct({ type: Schema.Literal("never") }),
|
|
194
|
-
Schema.Struct({ type: Schema.Literal("null") }),
|
|
195
|
-
Schema.Struct({
|
|
196
|
-
type: Schema.Literal("nullable"),
|
|
197
|
-
value: Schema.suspend(() => ValueDescriptor)
|
|
198
|
-
}),
|
|
199
|
-
Schema.Struct({ type: Schema.Literal("number") }),
|
|
200
|
-
Schema.Struct({
|
|
201
|
-
type: Schema.Literal("object"),
|
|
202
|
-
fields: Schema.Array(DescriptorField)
|
|
203
|
-
}),
|
|
204
|
-
Schema.Struct({
|
|
205
|
-
type: Schema.Literal("optional"),
|
|
206
|
-
value: Schema.suspend(() => ValueDescriptor)
|
|
207
|
-
}),
|
|
208
|
-
Schema.Struct({
|
|
209
|
-
type: Schema.Literal("record"),
|
|
210
|
-
value: Schema.suspend(() => ValueDescriptor)
|
|
211
|
-
}),
|
|
212
|
-
Schema.Struct({
|
|
213
|
-
type: Schema.Literal("secret"),
|
|
214
|
-
value: Schema.suspend(() => ValueDescriptor)
|
|
215
|
-
}),
|
|
216
|
-
Schema.Struct({ type: Schema.Literal("string") }),
|
|
217
|
-
Schema.Struct({
|
|
218
|
-
type: Schema.Literal("union"),
|
|
219
|
-
members: Schema.Array(Schema.suspend(() => ValueDescriptor))
|
|
220
|
-
})
|
|
221
|
-
]);
|
|
222
|
-
const ValueDescriptorTypeId = Symbol.for("ignotum/schema/ValueDescriptor");
|
|
223
|
-
const attachValueDescriptor = Function.dual(2, (value, descriptor) => {
|
|
224
|
-
Object.defineProperty(value, ValueDescriptorTypeId, {
|
|
225
|
-
configurable: false,
|
|
226
|
-
enumerable: false,
|
|
227
|
-
value: descriptor,
|
|
228
|
-
writable: false
|
|
229
|
-
});
|
|
230
|
-
return attachEvolution(value);
|
|
231
|
-
});
|
|
232
|
-
const getValueDescriptor = (value) => {
|
|
233
|
-
if (!Predicate.hasProperty(value, ValueDescriptorTypeId)) return void 0;
|
|
234
|
-
return Schema.is(ValueDescriptor)(value[ValueDescriptorTypeId]) ? value[ValueDescriptorTypeId] : void 0;
|
|
235
|
-
};
|
|
236
|
-
const descriptorAllowedInEnvironment = (descriptor) => {
|
|
237
|
-
switch (descriptor.type) {
|
|
238
|
-
case "error":
|
|
239
|
-
case "file":
|
|
240
|
-
case "userId":
|
|
241
|
-
case "id": return false;
|
|
242
|
-
case "array":
|
|
243
|
-
case "nullable":
|
|
244
|
-
case "optional":
|
|
245
|
-
case "record":
|
|
246
|
-
case "secret": return descriptorAllowedInEnvironment(descriptor.value);
|
|
247
|
-
case "object": return descriptor.fields.every((field) => descriptorAllowedInEnvironment(field.value));
|
|
248
|
-
case "union": return descriptor.members.every(descriptorAllowedInEnvironment);
|
|
249
|
-
default: return true;
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
const descriptorFields = (fields) => {
|
|
253
|
-
const entries = [];
|
|
254
|
-
for (const name of Reflect.ownKeys(fields)) {
|
|
255
|
-
if (!Predicate.isString(name)) throw new Error("Ignotum value objects only support string field names.");
|
|
256
|
-
const field = fields[name];
|
|
257
|
-
const value = field === void 0 ? void 0 : getValueDescriptor(field);
|
|
258
|
-
if (value === void 0) throw new Error(`The field '${name}' must use an Ignotum values validator.`);
|
|
259
|
-
entries.push({
|
|
260
|
-
name,
|
|
261
|
-
value
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
return entries.sort((left, right) => left.name.localeCompare(right.name));
|
|
265
|
-
};
|
|
266
|
-
//#endregion
|
|
267
|
-
export { descriptorFields as a, validateFieldRenames as c, descriptorAllowedInEnvironment as i, withValueChildren as l, applyValueDefaults as n, evolveStoredFields as o, attachValueDescriptor as r, getValueDescriptor as s, ValueDescriptor as t };
|
|
268
|
-
|
|
269
|
-
//# sourceMappingURL=descriptor-CTY4mtwS-cS43EbwS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"descriptor-CTY4mtwS-cS43EbwS.js","names":[],"sources":["../../../contracts/dist/descriptor-CTY4mtwS.js"],"sourcesContent":["import { Effect, Function, Predicate, Schema } from \"effect\";\n//#region src/schema/evolution.ts\nconst ValueEvolutionTypeId = Symbol.for(\"ignotum/schema/ValueEvolution\");\nconst evolutionRules = (value) => value[ValueEvolutionTypeId] ?? {};\nconst codec = (value) => Schema.toCodecJson(value);\nconst encode = (schema, value) => Schema.decodeUnknownSync(Schema.Json)(Schema.encodeUnknownSync(codec(schema), { onExcessProperty: \"error\" })(value));\nconst decode = (schema, value) => Schema.decodeUnknownSync(codec(schema), { onExcessProperty: \"error\" })(value);\nconst copy = (value) => Object.create(Object.getPrototypeOf(value), Object.getOwnPropertyDescriptors(value));\nconst isValueObject = Schema.is(Schema.Record(Schema.String, Schema.Unknown));\nconst attachEvolution = (value, rules = {}) => {\n\tObject.defineProperty(value, ValueEvolutionTypeId, {\n\t\tconfigurable: true,\n\t\tvalue: rules\n\t});\n\treturn Object.assign(value, {\n\t\tdefault(defaultValue) {\n\t\t\tif (getValueDescriptor(value)?.type === \"optional\") throw new Error(\"Defaults require a non-optional validator. A default already allows omission on creation.\");\n\t\t\tconst defaultJson = JSON.stringify(encode(value, defaultValue));\n\t\t\tconst next = copy(value);\n\t\t\tconst constructor = Schema.withConstructorDefault(Effect.sync(() => decode(value, JSON.parse(defaultJson))))(value);\n\t\t\tObject.defineProperty(next, \"ast\", {\n\t\t\t\tvalue: constructor.ast,\n\t\t\t\tconfigurable: true\n\t\t\t});\n\t\t\treturn attachEvolution(next, {\n\t\t\t\t...rules,\n\t\t\t\tdefaultJson\n\t\t\t});\n\t\t},\n\t\trenameFrom(name) {\n\t\t\tif (name.length === 0 || [\n\t\t\t\t\"id\",\n\t\t\t\t\"createdAt\",\n\t\t\t\t\"updatedAt\"\n\t\t\t].includes(name)) throw new Error(`Cannot rename reserved or empty field '${name}'.`);\n\t\t\treturn attachEvolution(copy(value), {\n\t\t\t\t...rules,\n\t\t\t\trenameFrom: name\n\t\t\t});\n\t\t},\n\t\tfrom(previous, convert) {\n\t\t\tif (getValueDescriptor(previous) === void 0) throw new Error(\"Historical values must use an Ignotum values validator.\");\n\t\t\treturn attachEvolution(copy(value), {\n\t\t\t\t...rules,\n\t\t\t\tprevious: [...rules.previous ?? [], {\n\t\t\t\t\tschema: previous,\n\t\t\t\t\tconvert\n\t\t\t\t}]\n\t\t\t});\n\t\t}\n\t});\n};\nconst withValueChildren = (value, children) => {\n\tattachEvolution(value, {\n\t\t...evolutionRules(value),\n\t\tchildren\n\t});\n\treturn value;\n};\nconst validateFieldRenames = (fields) => {\n\tconst sources = /* @__PURE__ */ new Set();\n\tfor (const [name, field] of Object.entries(fields)) {\n\t\tconst source = evolutionRules(field).renameFrom;\n\t\tif (source === void 0) continue;\n\t\tif (source === name || Object.hasOwn(fields, source) || sources.has(source)) throw new Error(`Rename source '${source}' conflicts with another field.`);\n\t\tsources.add(source);\n\t}\n};\nconst mapChildren = (schema, value, visit, rename) => {\n\tconst children = evolutionRules(schema).children;\n\tif (children === void 0) return value;\n\tswitch (children.type) {\n\t\tcase \"object\": {\n\t\t\tif (!isValueObject(value)) return value;\n\t\t\tconst result = { ...value };\n\t\t\tfor (const [name, field] of Object.entries(children.fields)) {\n\t\t\t\tconst source = rename ? evolutionRules(field).renameFrom : void 0;\n\t\t\t\tif (source !== void 0 && Object.hasOwn(result, source)) {\n\t\t\t\t\tif (Object.hasOwn(result, name)) throw new Error(`Both '${name}' and its rename source '${source}' are present.`);\n\t\t\t\t\tObject.defineProperty(result, name, {\n\t\t\t\t\t\tvalue: result[source],\n\t\t\t\t\t\tenumerable: true,\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t\twritable: true\n\t\t\t\t\t});\n\t\t\t\t\tdelete result[source];\n\t\t\t\t}\n\t\t\t\tconst next = visit(field, Object.hasOwn(result, name) ? result[name] : void 0);\n\t\t\t\tif (next !== void 0) Object.defineProperty(result, name, {\n\t\t\t\t\tvalue: next,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn result;\n\t\t}\n\t\tcase \"array\": return Array.isArray(value) ? value.map((item) => visit(children.value, item)) : value;\n\t\tcase \"record\": return isValueObject(value) ? Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit(children.value, item)])) : value;\n\t\tcase \"nullable\": return value === null ? value : visit(children.value, value);\n\t\tcase \"optional\": return value === void 0 ? value : visit(children.value, value);\n\t\tcase \"union\":\n\t\t\tfor (const member of children.members) try {\n\t\t\t\tconst result = visit(member, value);\n\t\t\t\tif (rename) decode(member, result);\n\t\t\t\telse encode(member, result);\n\t\t\t\treturn result;\n\t\t\t} catch {}\n\t\t\treturn value;\n\t}\n};\n/** Apply creation defaults to decoded values, without accepting historical representations. */\nconst applyValueDefaults = (schema, value) => {\n\tconst rules = evolutionRules(schema);\n\tif (value === void 0 && rules.defaultJson !== void 0) return decode(schema, JSON.parse(rules.defaultJson));\n\treturn mapChildren(schema, value, applyValueDefaults, false);\n};\n/** Convert a stored JSON value to the current representation, preserving already valid values. */\nconst evolveStoredValue = (schema, value) => {\n\ttry {\n\t\tdecode(schema, value);\n\t\treturn value;\n\t} catch {}\n\tconst rules = evolutionRules(schema);\n\tif (value === void 0 && rules.defaultJson !== void 0) return JSON.parse(rules.defaultJson);\n\tlet failure;\n\ttry {\n\t\tconst next = mapChildren(schema, value, evolveStoredValue, true);\n\t\tdecode(schema, next);\n\t\treturn next;\n\t} catch (cause) {\n\t\tfailure = cause;\n\t}\n\tconst matches = [];\n\tfor (const previous of rules.previous ?? []) try {\n\t\tmatches.push({\n\t\t\tprevious,\n\t\t\tvalue: decode(previous.schema, value)\n\t\t});\n\t} catch {}\n\tif (matches.length > 1) throw new Error(\"More than one historical validator matches this value.\");\n\tconst match = matches[0];\n\tif (match === void 0) throw failure;\n\treturn encode(schema, applyValueDefaults(schema, match.previous.convert(match.value)));\n};\nconst evolveStoredFields = (schema, value) => Schema.decodeUnknownSync(Schema.JsonObject)(evolveStoredValue(schema, value));\n//#endregion\n//#region src/schema/descriptor.ts\nconst LiteralValue = Schema.Union([\n\tSchema.String,\n\tSchema.Finite,\n\tSchema.Boolean\n]);\nconst DescriptorField = Schema.Struct({\n\tname: Schema.String,\n\tvalue: Schema.suspend(() => ValueDescriptor)\n});\nconst ValueDescriptor = Schema.Union([\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"array\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"boolean\") }),\n\tSchema.Struct({ type: Schema.Literal(\"date\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"file\"),\n\t\tformats: Schema.Array(Schema.Literals([\n\t\t\t\"jpeg\",\n\t\t\t\"png\",\n\t\t\t\"webp\",\n\t\t\t\"avif\",\n\t\t\t\"gif\"\n\t\t])),\n\t\tmaxBytes: Schema.Int\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"error\"),\n\t\ttag: Schema.String,\n\t\tfields: Schema.Array(DescriptorField)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"id\"),\n\t\ttable: Schema.String\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"userId\") }),\n\tSchema.Struct({ type: Schema.Literal(\"integer\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"literal\"),\n\t\tvalue: LiteralValue\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"literals\"),\n\t\tvalues: Schema.Array(LiteralValue)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"never\") }),\n\tSchema.Struct({ type: Schema.Literal(\"null\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"nullable\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"number\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"object\"),\n\t\tfields: Schema.Array(DescriptorField)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"optional\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"record\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"secret\"),\n\t\tvalue: Schema.suspend(() => ValueDescriptor)\n\t}),\n\tSchema.Struct({ type: Schema.Literal(\"string\") }),\n\tSchema.Struct({\n\t\ttype: Schema.Literal(\"union\"),\n\t\tmembers: Schema.Array(Schema.suspend(() => ValueDescriptor))\n\t})\n]);\nconst ValueDescriptorTypeId = Symbol.for(\"ignotum/schema/ValueDescriptor\");\nconst attachValueDescriptor = Function.dual(2, (value, descriptor) => {\n\tObject.defineProperty(value, ValueDescriptorTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: descriptor,\n\t\twritable: false\n\t});\n\treturn attachEvolution(value);\n});\nconst getValueDescriptor = (value) => {\n\tif (!Predicate.hasProperty(value, ValueDescriptorTypeId)) return void 0;\n\treturn Schema.is(ValueDescriptor)(value[ValueDescriptorTypeId]) ? value[ValueDescriptorTypeId] : void 0;\n};\nconst descriptorContainsFile = (descriptor) => {\n\tswitch (descriptor.type) {\n\t\tcase \"file\": return true;\n\t\tcase \"array\":\n\t\tcase \"nullable\":\n\t\tcase \"optional\":\n\t\tcase \"record\":\n\t\tcase \"secret\": return descriptorContainsFile(descriptor.value);\n\t\tcase \"error\":\n\t\tcase \"object\": return descriptor.fields.some((field) => descriptorContainsFile(field.value));\n\t\tcase \"union\": return descriptor.members.some(descriptorContainsFile);\n\t\tdefault: return false;\n\t}\n};\nconst descriptorContainsSecret = (descriptor) => {\n\tswitch (descriptor.type) {\n\t\tcase \"secret\": return true;\n\t\tcase \"array\":\n\t\tcase \"nullable\":\n\t\tcase \"optional\":\n\t\tcase \"record\": return descriptorContainsSecret(descriptor.value);\n\t\tcase \"error\":\n\t\tcase \"object\": return descriptor.fields.some((field) => descriptorContainsSecret(field.value));\n\t\tcase \"union\": return descriptor.members.some(descriptorContainsSecret);\n\t\tdefault: return false;\n\t}\n};\nconst descriptorAllowedInEnvironment = (descriptor) => {\n\tswitch (descriptor.type) {\n\t\tcase \"error\":\n\t\tcase \"file\":\n\t\tcase \"userId\":\n\t\tcase \"id\": return false;\n\t\tcase \"array\":\n\t\tcase \"nullable\":\n\t\tcase \"optional\":\n\t\tcase \"record\":\n\t\tcase \"secret\": return descriptorAllowedInEnvironment(descriptor.value);\n\t\tcase \"object\": return descriptor.fields.every((field) => descriptorAllowedInEnvironment(field.value));\n\t\tcase \"union\": return descriptor.members.every(descriptorAllowedInEnvironment);\n\t\tdefault: return true;\n\t}\n};\nconst descriptorFields = (fields) => {\n\tconst entries = [];\n\tfor (const name of Reflect.ownKeys(fields)) {\n\t\tif (!Predicate.isString(name)) throw new Error(\"Ignotum value objects only support string field names.\");\n\t\tconst field = fields[name];\n\t\tconst value = field === void 0 ? void 0 : getValueDescriptor(field);\n\t\tif (value === void 0) throw new Error(`The field '${name}' must use an Ignotum values validator.`);\n\t\tentries.push({\n\t\t\tname,\n\t\t\tvalue\n\t\t});\n\t}\n\treturn entries.sort((left, right) => left.name.localeCompare(right.name));\n};\n//#endregion\nexport { descriptorContainsFile as a, getValueDescriptor as c, evolveStoredFields as d, evolveStoredValue as f, descriptorAllowedInEnvironment as i, applyValueDefaults as l, withValueChildren as m, ValueDescriptorTypeId as n, descriptorContainsSecret as o, validateFieldRenames as p, attachValueDescriptor as r, descriptorFields as s, ValueDescriptor as t, evolutionRules as u };\n\n//# sourceMappingURL=descriptor-CTY4mtwS.js.map"],"mappings":";;AAEA,MAAM,uBAAuB,OAAO,IAAI,+BAA+B;AACvE,MAAM,kBAAkB,UAAU,MAAM,yBAAyB,CAAC;AAClE,MAAM,SAAS,UAAU,OAAO,YAAY,KAAK;AACjD,MAAM,UAAU,QAAQ,UAAU,OAAO,kBAAkB,OAAO,IAAI,CAAC,CAAC,OAAO,kBAAkB,MAAM,MAAM,GAAG,EAAE,kBAAkB,QA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,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC;AACzE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"id--1m0NuUL.js","names":["Result"],"sources":["../../../contracts/dist/runtime/id.js","../../../contracts/dist/schema/file.js","../../../contracts/dist/runtime/value.js","../../../contracts/dist/runtime/result.js","../../../contracts/dist/versioned.js","../../../contracts/dist/id.js"],"sourcesContent":["import { Schema } from \"effect\";\n//#region src/runtime/id.ts\nconst IdAlphabet = \"0123456789abcdefghijklmnopqrstuvwxyz\";\nconst IdLength = 24;\nconst IdPrefix = Schema.String.check(Schema.isPattern(/^[a-z]+$/));\nconst IdPayloadPattern = /^[0-9a-z]{24}$/;\nconst withPrefix = (definition, idPrefix) => Object.assign(definition, { idPrefix });\nconst defineId = (prefix, brand) => {\n\tconst idPrefix = Schema.decodeSync(IdPrefix)(prefix);\n\treturn withPrefix(Schema.String.check(Schema.isPattern(new RegExp(`^${idPrefix}_[0-9a-z]{24}$`))).pipe(Schema.brand(brand)), idPrefix);\n};\nconst GeneratedId = withPrefix(Schema.String.check(Schema.isPattern(IdPayloadPattern)).pipe(Schema.brand(\"ignotum/id\")), void 0);\nconst AppId = defineId(\"app\", \"ignotum/hosted/AppId\");\nconst VersionId = defineId(\"dep\", \"ignotum/hosted/VersionId\");\nconst TeamId = defineId(\"team\", \"ignotum/hosted/TeamId\");\nconst TableId = defineId(\"table\", \"ignotum/runtime/TableId\");\nconst PlatformPrincipalId = defineId(\"prn\", \"ignotum/control/PlatformPrincipalId\");\nconst AuthSessionId = defineId(\"ses\", \"ignotum/auth/SessionId\");\nconst AuthAccountId = defineId(\"acct\", \"ignotum/auth/AccountId\");\nconst AuthVerificationId = defineId(\"ver\", \"ignotum/auth/VerificationId\");\nconst AuthMemberId = defineId(\"mbr\", \"ignotum/auth/MemberId\");\nconst AuthInvitationId = defineId(\"invt\", \"ignotum/auth/InvitationId\");\nconst AuthDeviceCodeId = defineId(\"dvc\", \"ignotum/auth/DeviceCodeId\");\nconst AuthInternalId = defineId(\"auth\", \"ignotum/auth/InternalId\");\nconst InvocationId = defineId(\"inv\", \"ignotum/sync/InvocationId\");\nconst SubscriptionId = defineId(\"sub\", \"ignotum/sync/SubscriptionId\");\nconst ConnectionId = defineId(\"conn\", \"ignotum/gateway/ConnectionId\");\nconst RuntimeRequestNonce = defineId(\"nonce\", \"ignotum/runtime/RequestNonce\");\nconst RequestId = defineId(\"req\", \"ignotum/runtime/RequestId\");\nconst DevDatabaseLockId = defineId(\"lock\", \"ignotum/dev/DatabaseLockId\");\nconst IdUserId = defineId(\"iid\", \"ignotum/id/AppUserId\");\nconst IdGlobalUserId = defineId(\"idu\", \"ignotum/id/GlobalUserId\");\nconst IdSessionId = defineId(\"ids\", \"ignotum/id/SessionId\");\nconst IdRequestId = defineId(\"idr\", \"ignotum/id/RequestId\");\nconst SessionEpoch = defineId(\"epoch\", \"ignotum/id/SessionEpoch\");\n//#endregion\nexport { AppId, AuthAccountId, AuthDeviceCodeId, AuthInternalId, AuthInvitationId, AuthMemberId, AuthSessionId, AuthVerificationId, ConnectionId, DevDatabaseLockId, GeneratedId, IdAlphabet, IdGlobalUserId, IdLength, IdRequestId, IdSessionId, IdUserId, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SessionEpoch, SubscriptionId, TableId, TeamId, VersionId, defineId };\n\n//# sourceMappingURL=id.js.map","import { defineId } from \"../runtime/id.js\";\nimport { Predicate, Schema, SchemaGetter } from \"effect\";\n//#region src/schema/file.ts\nconst fileFormats = [\n\t\"jpeg\",\n\t\"png\",\n\t\"webp\",\n\t\"avif\",\n\t\"gif\"\n];\nconst FileFormat = Schema.Literals(fileFormats);\nconst fileMimeTypes = {\n\tavif: \"image/avif\",\n\tgif: \"image/gif\",\n\tjpeg: \"image/jpeg\",\n\tpng: \"image/png\",\n\twebp: \"image/webp\"\n};\nconst fileLimits = {\n\tactiveGrantsPerConnection: 1024,\n\tdistinctFilesPerQuerySnapshot: 256,\n\tfileBytes: 10485760,\n\tfilesPerMutation: 8,\n\tfilenameBytes: 255,\n\tmutationBytes: 26214400,\n\tpreparationLifetimeMillis: 9e5,\n\tstagedBytesPerApp: 104857600\n};\nconst FileId = Object.assign(Schema.String.pipe(Schema.check(Schema.isPattern(/^file_[0-9A-Za-z_-]{20,128}$/)), Schema.brand(\"ignotum/file/FileId\")), { idPrefix: \"file\" });\nconst FileUploadToken = defineId(\"upload\", \"ignotum/file/FileUploadToken\");\nconst FileGrantToken = defineId(\"grant\", \"ignotum/file/FileGrantToken\");\nconst FileValueTypeId = Symbol.for(\"ignotum/file/FileValue\");\nconst FileGrantTypeId = Symbol.for(\"ignotum/file/FileGrant\");\nconst isFileValue = (value) => Predicate.isObject(value) && Predicate.hasProperty(value, FileValueTypeId) && Predicate.isObject(value[FileValueTypeId]) && Predicate.hasProperty(value[FileValueTypeId], \"id\") && Schema.is(FileId)(value[FileValueTypeId].id) && Predicate.hasProperty(value, \"format\") && Schema.is(FileFormat)(value.format) && Predicate.hasProperty(value, \"name\") && Predicate.isString(value.name) && Predicate.hasProperty(value, \"size\") && Predicate.isNumber(value.size) && Predicate.hasProperty(value, \"mimeType\") && value.mimeType === fileMimeTypes[value.format];\nconst buildFileValue = (id, metadata, grantUrl) => {\n\tconst value = {\n\t\tformat: metadata.format,\n\t\tmimeType: fileMimeTypes[metadata.format],\n\t\tname: metadata.name,\n\t\tsize: metadata.size\n\t};\n\tObject.defineProperty(value, FileValueTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: Object.freeze({ id }),\n\t\twritable: false\n\t});\n\tif (grantUrl !== void 0) Object.defineProperty(value, FileGrantTypeId, {\n\t\tconfigurable: false,\n\t\tenumerable: false,\n\t\tvalue: grantUrl,\n\t\twritable: false\n\t});\n\treturn Object.freeze(value);\n};\nconst makeFileValue = (id, metadata) => buildFileValue(id, metadata);\nconst fileIdOf = (value) => value[FileValueTypeId].id;\nconst grantFileValue = (value, url) => {\n\treturn buildFileValue(fileIdOf(value), value, url);\n};\nconst fileGrantUrlOf = (value) => value[FileGrantTypeId];\nconst EncodedFileValue = Schema.Struct({\n\t$ignotum: Schema.Literal(\"file\"),\n\tid: FileId,\n\tformat: FileFormat,\n\tname: Schema.String,\n\tsize: Schema.Int.check(Schema.isBetween({\n\t\tminimum: 0,\n\t\tmaximum: fileLimits.fileBytes\n\t}))\n});\nconst RuntimeFileMetadata = Schema.Struct({\n\tid: FileId,\n\tformat: FileFormat,\n\tname: Schema.String,\n\tsize: Schema.Int.check(Schema.isBetween({\n\t\tminimum: 0,\n\t\tmaximum: fileLimits.fileBytes\n\t}))\n});\nconst FilePath = Schema.Array(Schema.Union([Schema.String, Schema.Natural]));\nconst RuntimeFileOccurrence = Schema.Struct({\n\tpath: FilePath,\n\tfile: RuntimeFileMetadata\n});\nconst DecodedFileValue = Schema.declare(isFileValue, { title: \"FileValue\" });\nconst FileValue = EncodedFileValue.pipe(Schema.decodeTo(DecodedFileValue, {\n\tdecode: SchemaGetter.transform((encoded) => makeFileValue(encoded.id, {\n\t\tformat: encoded.format,\n\t\tname: encoded.name,\n\t\tsize: encoded.size\n\t})),\n\tencode: SchemaGetter.transform((value) => ({\n\t\t$ignotum: \"file\",\n\t\tformat: value.format,\n\t\tid: fileIdOf(value),\n\t\tname: value.name,\n\t\tsize: value.size\n\t}))\n}));\nconst constrainedFileValue = (formats, maxBytes) => FileValue.pipe(Schema.check(Schema.makeFilter((value) => {\n\tconst issues = [];\n\tif (!formats.includes(value.format)) issues.push({\n\t\tpath: [\"format\"],\n\t\tissue: `File format '${value.format}' is not allowed by this field.`\n\t});\n\tif (value.size > maxBytes) issues.push({\n\t\tpath: [\"size\"],\n\t\tissue: `File size ${value.size} exceeds this field's ${maxBytes} byte limit.`\n\t});\n\treturn issues;\n})));\nconst collectFileOccurrences = (value, path, occurrences) => {\n\tif (isFileValue(value)) {\n\t\toccurrences.push({\n\t\t\tfile: value,\n\t\t\tpath\n\t\t});\n\t\treturn;\n\t}\n\tif (globalThis.Array.isArray(value)) {\n\t\tfor (const [index, child] of value.entries()) collectFileOccurrences(child, [...path, index], occurrences);\n\t\treturn;\n\t}\n\tif (!Predicate.isObject(value) || Predicate.isDate(value)) return;\n\tfor (const [key, child] of Object.entries(value)) collectFileOccurrences(child, [...path, key], occurrences);\n};\nconst fileOccurrencesOf = (value) => {\n\tconst occurrences = [];\n\tcollectFileOccurrences(value, [], occurrences);\n\treturn occurrences;\n};\nconst runtimeFileOccurrencesOf = (value) => fileOccurrencesOf(value).map(({ file, path }) => ({\n\tpath,\n\tfile: {\n\t\tformat: file.format,\n\t\tid: fileIdOf(file),\n\t\tname: file.name,\n\t\tsize: file.size\n\t}\n}));\nconst collectEncodedFileOccurrences = (value, path, occurrences) => {\n\tif (Schema.is(EncodedFileValue)(value)) {\n\t\tconst file = Schema.decodeUnknownSync(EncodedFileValue)(value);\n\t\toccurrences.push({\n\t\t\tpath,\n\t\t\tfile: {\n\t\t\t\tformat: file.format,\n\t\t\t\tid: file.id,\n\t\t\t\tname: file.name,\n\t\t\t\tsize: file.size\n\t\t\t}\n\t\t});\n\t\treturn;\n\t}\n\tif (globalThis.Array.isArray(value)) {\n\t\tfor (const [index, child] of value.entries()) collectEncodedFileOccurrences(child, [...path, index], occurrences);\n\t\treturn;\n\t}\n\tif (!Schema.is(Schema.JsonObject)(value)) return;\n\tfor (const [key, child] of Object.entries(value)) collectEncodedFileOccurrences(child, [...path, key], occurrences);\n};\nconst encodedFileOccurrencesOf = (value) => {\n\tconst occurrences = [];\n\tcollectEncodedFileOccurrences(value, [], occurrences);\n\treturn occurrences;\n};\n//#endregion\nexport { EncodedFileValue, FileFormat, FileGrantToken, FileGrantTypeId, FileId, FilePath, FileUploadToken, FileValue, FileValueTypeId, RuntimeFileMetadata, RuntimeFileOccurrence, constrainedFileValue, encodedFileOccurrencesOf, fileFormats, fileGrantUrlOf, fileIdOf, fileLimits, fileMimeTypes, fileOccurrencesOf, grantFileValue, isFileValue, makeFileValue, runtimeFileOccurrencesOf };\n\n//# sourceMappingURL=file.js.map","import { EncodedFileValue, FileValue, isFileValue } from \"../schema/file.js\";\nimport { Predicate, Schema } from \"effect\";\n//#region src/runtime/value.ts\nconst TransportValueSchema = Schema.suspend(() => Schema.Union([\n\tSchema.Null,\n\tSchema.Boolean,\n\tSchema.Finite,\n\tSchema.String,\n\tSchema.Date,\n\tFileValue,\n\tSchema.Array(TransportValueSchema),\n\tSchema.Record(Schema.String, Schema.UndefinedOr(TransportValueSchema))\n]));\nconst TransportValueTypeSchema = Schema.toType(TransportValueSchema);\nconst TransportObjectTypeSchema = Schema.Record(Schema.String, Schema.UndefinedOr(TransportValueTypeSchema));\nconst encodeTransportValue = (value) => {\n\tif (Predicate.isDate(value)) return Schema.encodeSync(Schema.DateFromMillis)(value);\n\tif (isFileValue(value)) return Schema.encodeSync(FileValue)(value);\n\tif (globalThis.Array.isArray(value)) return value.map(encodeTransportValue);\n\tif (Predicate.isNumber(value)) return Schema.decodeSync(Schema.Finite)(value);\n\tif (Predicate.isNull(value) || Predicate.isString(value) || Predicate.isBoolean(value)) return value;\n\treturn Object.fromEntries(Object.entries(value).flatMap(([key, child]) => child === void 0 ? [] : [[key, encodeTransportValue(child)]]));\n};\nconst encodeTransportObject = (value) => Schema.decodeUnknownSync(Schema.JsonObject)(encodeTransportValue(Schema.decodeUnknownSync(TransportObjectTypeSchema)(value)));\nconst collectDatePaths = (value, path, paths) => {\n\tif (Predicate.isDate(value)) {\n\t\tSchema.decodeSync(Schema.Date)(value);\n\t\tpaths.push(path);\n\t\treturn;\n\t}\n\tif (isFileValue(value)) return;\n\tif (globalThis.Array.isArray(value)) {\n\t\tfor (const [index, child] of value.entries()) collectDatePaths(child, [...path, index], paths);\n\t\treturn;\n\t}\n\tif (value === void 0 || Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return;\n\tfor (const [key, child] of Object.entries(value)) collectDatePaths(child, [...path, key], paths);\n};\nconst datePathsOf = (value) => {\n\tconst paths = [];\n\tcollectDatePaths(value, [], paths);\n\treturn paths;\n};\nconst datePathsOfObject = (value) => datePathsOf(Schema.decodeUnknownSync(TransportObjectTypeSchema)(value));\nconst pathKey = (path) => JSON.stringify(path);\nconst decodeTransportValueAt = (value, path, encodedDatePaths) => {\n\tif (encodedDatePaths.has(pathKey(path))) return Schema.decodeUnknownSync(Schema.DateFromMillis)(value);\n\tif (Schema.is(EncodedFileValue)(value)) return Schema.decodeSync(FileValue)(value);\n\tif (globalThis.Array.isArray(value)) return value.map((item, index) => decodeTransportValueAt(item, [...path, index], encodedDatePaths));\n\tif (Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return value;\n\treturn Object.fromEntries(Object.entries(value).map(([key, item]) => [key, decodeTransportValueAt(item, [...path, key], encodedDatePaths)]));\n};\nconst decodeTransportValue = (value, datePaths) => decodeTransportValueAt(value, [], new Set(datePaths.map(pathKey)));\nconst decodeTransportObject = (value, datePaths) => {\n\tconst encodedDatePaths = new Set(datePaths.map(pathKey));\n\treturn Object.fromEntries(Object.entries(value).map(([key, child]) => [key, decodeTransportValueAt(child, [key], encodedDatePaths)]));\n};\n//#endregion\nexport { TransportObjectTypeSchema, TransportValueSchema, TransportValueTypeSchema, datePathsOf, datePathsOfObject, decodeTransportObject, decodeTransportValue, encodeTransportObject, encodeTransportValue };\n\n//# sourceMappingURL=value.js.map","import { RequestId } from \"./id.js\";\nimport { decodeTransportObject } from \"./value.js\";\nimport { Brand, Effect, Effectable, Function, Option, Predicate, Schema } from \"effect\";\n//#region src/runtime/result.ts\nconst ResultTypeId = Symbol.for(\"ignotum/runtime/result/Result\");\nconst CompletedResultTypeId = Symbol.for(\"ignotum/runtime/result/Completed\");\nconst PendingResultTypeId = Symbol.for(\"ignotum/runtime/result/Pending\");\nconst ErrorBrand = \"ignotum/error\";\nconst makeErrorValue = Brand.nominal();\nconst ErrorValueSchema = Schema.StructWithRest(Schema.Struct({ _tag: Schema.String }), [Schema.Record(Schema.String, Schema.Json)]).pipe(Schema.brand(ErrorBrand));\nvar InternalServerErrorCause = class extends Schema.TaggedError()(\"InternalServerError\", { requestId: RequestId }) {};\nconst InternalServerError = InternalServerErrorCause;\nconst InternalServerErrorSchema = InternalServerErrorCause.pipe(Schema.brand(ErrorBrand));\nconst effectOf = (value) => Predicate.hasProperty(value, ResultTypeId) ? value[ResultTypeId] : Effect.succeed(value);\nfunction makeResultEffectBase() {\n\tconst Base = function() {};\n\tBase.prototype = Effectable.Prototype({\n\t\tlabel: \"IgnotumResult\",\n\t\tevaluate() {\n\t\t\treturn this[ResultTypeId];\n\t\t}\n\t});\n\treturn Base;\n}\nconst ResultEffectBase = makeResultEffectBase();\nvar ResultOperation = class ResultOperation extends ResultEffectBase {\n\t[ResultTypeId];\n\tconstructor(effect, completed) {\n\t\tsuper();\n\t\tthis[ResultTypeId] = effect;\n\t\tif (completed !== void 0) Object.defineProperty(this, CompletedResultTypeId, { value: completed });\n\t}\n\tcatch(cases) {\n\t\tconst effectCases = {};\n\t\tfor (const [tag, handler] of Object.entries(cases)) if (Predicate.isFunction(handler)) effectCases[tag] = (failure) => effectOf(handler(failure));\n\t\tconst runtimeEffect = this[ResultTypeId];\n\t\tconst caught = Effect.catchTags(runtimeEffect, effectCases);\n\t\treturn new ResultOperation(caught);\n\t}\n};\nvar PendingQueryResult = class {\n\t[PendingResultTypeId] = PendingResultTypeId;\n};\nconst inspectResult = (value) => {\n\tif (!Predicate.hasProperty(value, CompletedResultTypeId)) return void 0;\n\treturn value[CompletedResultTypeId];\n};\nconst effectFromResult = (result) => result[ResultTypeId];\nconst resultFromEffect = (effect) => new ResultOperation(effect);\nconst isFailureResult = (result) => Predicate.hasProperty(result, CompletedResultTypeId) && Predicate.isObject(result[CompletedResultTypeId]) && Predicate.hasProperty(result[CompletedResultTypeId], \"type\") && result[CompletedResultTypeId].type === \"Failure\";\nconst succeed = (value) => new ResultOperation(Effect.succeed(value), {\n\ttype: \"Success\",\n\tvalue\n});\nconst fail = (error) => new ResultOperation(Effect.fail(error), {\n\ttype: \"Failure\",\n\terror\n});\nconst tryResult = (body) => {\n\treturn new ResultOperation(Effect.gen(body));\n};\nconst match = Function.dual(2, (result, matchers) => {\n\tif (result instanceof PendingQueryResult) {\n\t\tif (matchers.pending === void 0) throw new Error(\"A pending Result requires a pending matcher.\");\n\t\treturn matchers.pending();\n\t}\n\tif (!Predicate.hasProperty(result, ResultTypeId)) throw new Error(\"Unknown Result implementation.\");\n\tconst inspected = inspectResult(result);\n\tif (inspected?.type === \"Success\") {\n\t\tconst value = inspected.value;\n\t\treturn matchers.value(value);\n\t}\n\tif (!isFailureResult(result)) throw new Error(\"Unknown or incomplete Result operation.\");\n\tconst error = result[CompletedResultTypeId].error;\n\tif (error._tag === \"InternalServerError\") {\n\t\tconst internalError = Schema.decodeUnknownSync(InternalServerErrorSchema)(error);\n\t\tconst handler = matchers.internalError;\n\t\tif (handler === void 0) throw internalError;\n\t\treturn handler(internalError);\n\t}\n\tconst errorMatcher = matchers.error;\n\tif (errorMatcher === void 0) throw new Error(`No matcher was provided for ${error._tag}.`);\n\tif (Predicate.isFunction(errorMatcher)) return errorMatcher(error);\n\tconst handlers = errorMatcher;\n\tconst handler = Object.hasOwn(handlers, error._tag) ? handlers[error._tag] : void 0;\n\tif (handler === void 0) throw new Error(`No matcher was provided for ${error._tag}.`);\n\treturn handler(error);\n});\nconst pending = () => new PendingQueryResult();\nconst failureFromWire = (error, datePaths = []) => {\n\tconst internalError = Schema.decodeUnknownOption(InternalServerErrorSchema)(error);\n\tif (Option.isSome(internalError)) return fail(internalError.value);\n\tconst decoded = Schema.decodeUnknownOption(ErrorValueSchema)(error);\n\tif (Option.isNone(decoded)) throw new Error(\"The server returned an invalid application error.\");\n\tconst restored = decodeTransportObject(decoded.value, datePaths);\n\treturn fail(makeErrorValue({\n\t\t...restored,\n\t\t_tag: decoded.value._tag\n\t}));\n};\nconst documentNotFound = (table, id) => Brand.nominal()({\n\t_tag: \"DocumentNotFound\",\n\ttable,\n\tid\n});\nconst Result = {\n\tfail,\n\tmatch,\n\tsucceed,\n\ttry: tryResult\n};\n//#endregion\nexport { ErrorBrand, ErrorValueSchema, InternalServerError, InternalServerErrorSchema, Result, documentNotFound, effectFromResult, failureFromWire, inspectResult, match, pending, resultFromEffect };\n\n//# sourceMappingURL=result.js.map","import { Schema, SchemaGetter } from \"effect\";\n//#region src/versioned.ts\n/** Registers the first revision of a long-lived format. */\nconst initial = (schema) => schema;\n/** Adds one adjacent migration and keeps encoding on the new current revision. */\nconst upgrade = (previous, current, migrate) => {\n\tconst accepted = Schema.Union([previous, current]);\n\tconst isCurrent = Schema.is(current);\n\treturn accepted.pipe(Schema.decodeTo(Schema.toType(current), {\n\t\tdecode: SchemaGetter.transform((value) => {\n\t\t\tif (isCurrent(value)) return value;\n\t\t\treturn migrate(value);\n\t\t}),\n\t\tencode: SchemaGetter.transform((value) => value)\n\t}));\n};\n//#endregion\nexport { initial, upgrade };\n\n//# sourceMappingURL=versioned.js.map","import { initial } from \"./versioned.js\";\nimport { encodeCanonicalJson } from \"./json.js\";\nimport { ErrorBrand, resultFromEffect } from \"./runtime/result.js\";\nimport { Effect, Schema } from \"effect\";\n//#region src/id.ts\nconst DevelopmentUsername = Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9_-]{0,63}$/));\nconst UserId = DevelopmentUsername.pipe(Schema.brand(\"ignotum/id/UserId\"));\nconst User = Schema.Struct({\n\tid: UserId,\n\tname: Schema.optional(Schema.String),\n\temail: Schema.optional(Schema.String),\n\timage: Schema.optional(Schema.String)\n});\nconst ProfileField = Schema.Literals([\n\t\"name\",\n\t\"email\",\n\t\"image\"\n]);\nconst ProfileFields = Schema.Array(ProfileField).check(Schema.isUnique());\nconst IdRequired = Schema.TaggedStruct(\"IdRequired\", {}).pipe(Schema.brand(ErrorBrand));\nconst makeIdContext = (read) => ({\n\tcurrent: () => resultFromEffect(read),\n\trequire: () => resultFromEffect(read.pipe(Effect.flatMap((user) => user === null ? Effect.fail(IdRequired.make({})) : Effect.succeed(user))))\n});\nconst SessionState = Schema.Struct({\n\tsessionEpoch: Schema.String,\n\tviewRevision: Schema.Natural,\n\tuser: Schema.NullOr(User),\n\tvalidUntil: Schema.Finite\n});\nconst SessionResponse = Schema.Struct({\n\tdevelopment: Schema.optional(Schema.Literal(true)),\n\toutcome: Schema.optional(Schema.Literals([\n\t\t\"SignedIn\",\n\t\t\"ProfileUpdated\",\n\t\t\"Cancelled\"\n\t])),\n\t...SessionState.fields,\n\tserverTime: Schema.Finite,\n\texpiresAt: Schema.Finite\n});\nconst ReturnPath = Schema.String.check(Schema.makeFilter((value) => {\n\tif (!value.startsWith(\"/\") || value.startsWith(\"//\") || value.includes(\"\\\\\")) return false;\n\tconst url = new URL(value, \"https://app.ignotum.invalid\");\n\treturn url.origin === \"https://app.ignotum.invalid\" && url.pathname !== \"/_ignotum\" && !url.pathname.startsWith(\"/_ignotum/\");\n}, { message: \"Return to a path within this app.\" }));\nconst SessionRequest = Schema.Struct({\n\tintent: Schema.Literals([\"signIn\", \"requestProfile\"]),\n\tprofile: ProfileFields,\n\treturnTo: ReturnPath,\n\tsessionEpoch: Schema.String\n});\nconst SessionRedirect = Schema.Struct({\n\tredirectUrl: Schema.String,\n\texpiresAt: Schema.Finite\n});\nconst SessionOutcome = Schema.Literals([\n\t\"SignedIn\",\n\t\"ProfileUpdated\",\n\t\"Cancelled\"\n]);\nconst idLimits = {\n\tsessionMillis: 2592e6,\n\tleaseMillis: 3e4,\n\trefreshMillis: 2e4,\n\trequestMillis: 6e5,\n\tcodeMillis: 6e4,\n\trequestBytes: 16384,\n\tpendingRequests: 5\n};\nconst sessionPath = \"/_ignotum/v1/session\";\nconst sessionRequestsPath = `${sessionPath}/requests`;\nconst sessionCallbackPath = `${sessionPath}/callback`;\nconst sessionCookieName = \"__Host-ignotum-session\";\nconst idImagePath = \"/_ignotum/v1/id/image/\";\nconst idViewKey = (session) => encodeCanonicalJson([session.user, session.viewRevision]);\nconst DevelopmentSelectionV1 = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tusername: Schema.NullOr(DevelopmentUsername),\n\tepoch: Schema.String\n});\nconst DevelopmentSelection = initial(DevelopmentSelectionV1);\nconst developmentSelectionKey = \"ignotum.id.development\";\n//#endregion\nexport { DevelopmentSelection, DevelopmentUsername, IdRequired, ProfileField, ProfileFields, ReturnPath, SessionOutcome, SessionRedirect, SessionRequest, SessionResponse, SessionState, User, UserId, developmentSelectionKey, idImagePath, idLimits, idViewKey, makeIdContext, sessionCallbackPath, sessionCookieName, sessionPath, sessionRequestsPath };\n\n//# sourceMappingURL=id.js.map"],"mappings":";;AAEA,MAAM,aAAa;AAEnB,MAAM,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,UAAU,CAAC;AACjE,MAAM,mBAAmB;AACzB,MAAM,cAAc,YAAY,aAAa,OAAO,OAAO,YAAY,EAAE,SAAS,CAAC;AACnF,MAAM,YAAY,QAAQ,UAAU;CACnC,MAAM,WAAW,OAAO,WAAW,QAAQ,CAAC,CAAC,MAAM;CACnD,OAAO,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,IAAI,OAAO,IAAI,SAAS,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,KAAK,CAAC,GAAG,QAAQ;AACtI;AACA,MAAM,cAAc,WAAW,OAAO,OAAO,MAAM,OAAO,UAAU,gBAAgB,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM,YAAY,CAAC,GAAG,KAAK,CAAC;AAC/H,MAAM,QAAQ,SAAS,OAAO,sBAAsB;AACpD,MAAM,YAAY,SAAS,OAAO,0BAA0B;AAC7C,SAAS,QAAQ,uBAAuB;AACvD,MAAM,UAAU,SAAS,SAAS,yBAAyB;AAC/B,SAAS,OAAO,qCAAqC;AAC3D,SAAS,OAAO,wBAAwB;AACxC,SAAS,QAAQ,wBAAwB;AACpC,SAAS,OAAO,6BAA6B;AACnD,SAAS,OAAO,uBAAuB;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SAAS,oCAAoC,CAAC,CAAC;AACpD,MAAM,iBAAiB,OAAO,OAAO;CACpC,QAAQ,OAAO,SAAS,CAAC,UAAU,gBAAgB,CAAC;CACpD,SAAS;CACT,UAAU;CACV,cAAc,OAAO;AACtB,CAAC;AACD,MAAM,kBAAkB,OAAO,OAAO;CACrC,aAAa,OAAO;CACpB,WAAW,OAAO;AACnB,CAAC;AACD,MAAM,iBAAiB,OAAO,SAAS;CACtC;CACA;CACA;AACD,CAAC;AAUD,MAAM,cAAc;AACpB,MAAM,sBAAsB,GAAG,YAAY;AAU3C,MAAM,uBAAuB,QALE,OAAO,OAAO;CAC5C,eAAe,OAAO,QAAQ,CAAC;CAC/B,UAAU,OAAO,OAAO,mBAAmB;CAC3C,OAAO,OAAO;AACf,CACqC,CAAsB;AAC3D,MAAM,0BAA0B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./types-DeCCyqLU-BIm7rU-0.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"image-Djtjy4Z8.js","names":[],"sources":["../../src/client/image.ts"],"sourcesContent":["import { createElement, type JSX } from \"preact\";\n\ndeclare const ImageSourceTypeId: unique symbol;\n\n/** A compiler-provided reference to an imported image. */\nexport interface ImageSource {\n readonly type: \"ImageSource\";\n readonly url: string;\n readonly [ImageSourceTypeId]: true;\n}\n\nexport type ImageProps = Omit<\n JSX.ImgHTMLAttributes<HTMLImageElement>,\n \"alt\" | \"src\" | \"srcSet\" | \"srcset\"\n> & {\n readonly src: ImageSource;\n readonly alt: string;\n};\n\n/** Renders an imported image. */\nexport const Image = ({ src, alt, ...attributes }: ImageProps): JSX.Element =>\n createElement(\"img\", { ...attributes, src: src.url, alt });\n\n/** @internal Creates an image reference from a compiler-resolved URL. */\nexport const createImageSource = (url: string): ImageSource => {\n // SAFETY: This factory constructs the complete runtime representation; the brand exists only in types.\n return { type: \"ImageSource\", url } as ImageSource;\n};\n"],"mappings":";;;AAoBA,MAAa,SAAS,EAAE,KAAK,KAAK,GAAG,iBACnC,cAAc,OAAO;CAAE,GAAG;CAAY,KAAK,IAAI;CAAK;AAAI,CAAC;;AAG3D,MAAa,qBAAqB,QAA6B;CAE7D,OAAO;EAAE,MAAM;EAAe;CAAI;AACpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../../../src/internal/api.ts"],"sourcesContent":["import { Predicate } from \"effect\";\nimport type { Effect } from \"effect\";\n\nimport type { ErrorValue, InternalServerError } from \"@ignotum/contracts/runtime/result\";\nimport { FunctionAddress } from \"@ignotum/contracts/runtime/sync\";\nimport type { FileValue } from \"@ignotum/contracts/schema/file\";\n\nconst FunctionReferenceTypeId: unique symbol = Symbol.for(\"ignotum/internal/api/FunctionReference\");\ndeclare const FunctionReferenceTypesTypeId: unique symbol;\n\ntype FunctionKind = \"Mutation\" | \"Query\";\n\nexport type MutationInput<Value> = Value extends FileValue\n ? Value | File\n : Value extends Date\n ? Value\n : Value extends ReadonlyArray<infer Item>\n ? ReadonlyArray<MutationInput<Item>>\n : Value extends object\n ? { readonly [Key in keyof Value]: MutationInput<Value[Key]> }\n : Value;\n\nexport interface FunctionReference<\n Kind extends FunctionKind,\n Args,\n Success,\n Failure extends ErrorValue,\n> {\n readonly [FunctionReferenceTypeId]: FunctionAddress;\n readonly [FunctionReferenceTypesTypeId]?: {\n readonly kind: Kind;\n readonly args: Args;\n readonly value: Success;\n readonly error: Failure;\n };\n}\n\ntype ReferenceTypes<Reference> = Reference extends {\n readonly [FunctionReferenceTypesTypeId]?: infer Types;\n}\n ? Exclude<Types, undefined>\n : never;\n\nexport declare namespace FunctionReference {\n type Args<Reference> =\n ReferenceTypes<Reference> extends { readonly args: infer Args } ? Args : never;\n type Failure<Reference> =\n ReferenceTypes<Reference> extends {\n readonly error: infer Failure;\n }\n ? Failure\n : never;\n type Kind<Reference> =\n ReferenceTypes<Reference> extends { readonly kind: infer Kind } ? Kind : never;\n type Success<Reference> =\n ReferenceTypes<Reference> extends {\n readonly value: infer Success;\n }\n ? Success\n : never;\n}\n\ntype ReferenceOf<Definition> = Definition extends {\n readonly _tag: infer Kind extends FunctionKind;\n readonly handler: (\n ...arguments_: infer HandlerArguments\n ) => Generator<infer Yielded, infer Success, never>;\n}\n ? HandlerArguments extends readonly [infer _Context, ...infer Rest]\n ? FunctionReference<\n Kind,\n Rest extends readonly [infer Args, ...ReadonlyArray<unknown>]\n ? Kind extends \"Mutation\"\n ? MutationInput<Args>\n : Args\n : void,\n Success,\n | (Yielded extends Effect.Effect<unknown, infer Failure extends ErrorValue, never>\n ? Failure\n : never)\n | InternalServerError\n >\n : never\n : never;\n\ntype ApiModule<Module> = {\n readonly [FunctionName in keyof Module as FunctionName extends string\n ? ReferenceOf<Module[FunctionName]> extends never\n ? never\n : FunctionName\n : never]: ReferenceOf<Module[FunctionName]>;\n};\n\nexport type Api<Modules> = {\n readonly [ModuleName in keyof Modules]: ApiModule<Modules[ModuleName]>;\n};\n\nexport const functionPathOf = <\n Kind extends FunctionKind,\n Args,\n Success,\n Failure extends ErrorValue,\n>(\n reference: FunctionReference<Kind, Args, Success, Failure>,\n) => reference[FunctionReferenceTypeId];\n\nconst makeModuleReference = (moduleName: string) => {\n const references = new Map<string, object>();\n\n return new Proxy(\n {},\n {\n get: (_target, functionName) => {\n if (!Predicate.isString(functionName)) {\n return undefined;\n }\n\n const existing = references.get(functionName);\n if (existing !== undefined) {\n return existing;\n }\n\n const reference = {\n [FunctionReferenceTypeId]: FunctionAddress.make(`api.${moduleName}.${functionName}`),\n };\n references.set(functionName, reference);\n return reference;\n },\n },\n );\n};\n\nexport function createApi<Modules>(): Api<Modules>;\nexport function createApi() {\n const modules = new Map<string, object>();\n\n return new Proxy(\n {},\n {\n get: (_target, moduleName) => {\n if (!Predicate.isString(moduleName)) {\n return undefined;\n }\n\n const existing = modules.get(moduleName);\n if (existing !== undefined) {\n return existing;\n }\n\n const moduleReference = makeModuleReference(moduleName);\n modules.set(moduleName, moduleReference);\n return moduleReference;\n },\n },\n );\n}\n"],"mappings":";;;AAOA,MAAM,0BAAyC,OAAO,IAAI,wCAAwC;AA0FlG,MAAa,kBAMX,cACG,UAAU;AAEf,MAAM,uBAAuB,eAAuB;CAClD,MAAM,6BAAa,IAAI,IAAoB;CAE3C,OAAO,IAAI,MACT,CAAC,GACD,EACE,MAAM,SAAS,iBAAiB;EAC9B,IAAI,CAAC,UAAU,SAAS,YAAY,GAClC;EAGF,MAAM,WAAW,WAAW,IAAI,YAAY;EAC5C,IAAI,aAAa,KAAA,GACf,OAAO;EAGT,MAAM,YAAY,GACf,0BAA0B,gBAAgB,KAAK,OAAO,WAAW,GAAG,cAAc,EACrF;EACA,WAAW,IAAI,cAAc,SAAS;EACtC,OAAO;CACT,EACF,CACF;AACF;AAGA,SAAgB,YAAY;CAC1B,MAAM,0BAAU,IAAI,IAAoB;CAExC,OAAO,IAAI,MACT,CAAC,GACD,EACE,MAAM,SAAS,eAAe;EAC5B,IAAI,CAAC,UAAU,SAAS,UAAU,GAChC;EAGF,MAAM,WAAW,QAAQ,IAAI,UAAU;EACvC,IAAI,aAAa,KAAA,GACf,OAAO;EAGT,MAAM,kBAAkB,oBAAoB,UAAU;EACtD,QAAQ,IAAI,YAAY,eAAe;EACvC,OAAO;CACT,EACF,CACF;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import "./types-DeCCyqLU-BIm7rU-0.js";
|