ignotum 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/cli/bin.mjs +269 -78
- package/dist/cli/bin.mjs.map +1 -1
- package/dist/runtime/client.js +27 -2
- package/dist/runtime/client.js.map +1 -1
- package/package.json +3 -3
- package/src/cli/build/client.ts +27 -11
- package/src/cli/build/public.ts +186 -0
- package/src/cli/build/server.ts +1 -0
- package/src/cli/client-config.ts +7 -0
package/dist/runtime/client.js
CHANGED
|
@@ -191,9 +191,13 @@ Schema.TaggedError()("FunctionUnavailable", {
|
|
|
191
191
|
//#endregion
|
|
192
192
|
//#region ../contracts/dist/deployment.js
|
|
193
193
|
const ArtifactPath = Schema.String.check(Schema.isPattern(/^(?!\/)(?![A-Za-z]:\/)(?!.*(?:^|\/)\.\.(?:\/|$))(?!.*(?:^|\/)\.(?:\/|$))(?!.*\/\/)[^\\\0]+$/)).pipe(Schema.brand("ignotum/deployment/ArtifactPath"));
|
|
194
|
+
const ClientPath = Schema.String.check(Schema.isPattern(/^\/(?!_ignotum(?:\/|$))(?:(?:[A-Za-z0-9._~-]+\/)*[A-Za-z0-9._~-]+\/?)?$/)).pipe(Schema.brand("ignotum/deployment/ClientPath"));
|
|
194
195
|
const Sha256 = Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/)).pipe(Schema.brand("ignotum/deployment/Sha256"));
|
|
195
196
|
const ArtifactKind = Schema.Literals([
|
|
196
197
|
"ClientAsset",
|
|
198
|
+
"ClientDocument",
|
|
199
|
+
"ClientManifest",
|
|
200
|
+
"ClientPublicFile",
|
|
197
201
|
"ClientShell",
|
|
198
202
|
"FunctionBundle",
|
|
199
203
|
"ServerManifest",
|
|
@@ -213,10 +217,28 @@ const ArtifactFile = Schema.Struct({
|
|
|
213
217
|
contentType: Schema.String,
|
|
214
218
|
contentEncoding: Schema.optional(Schema.String)
|
|
215
219
|
});
|
|
220
|
+
const ClientRoute = Schema.Struct({
|
|
221
|
+
pathname: ClientPath,
|
|
222
|
+
artifact: ArtifactReference
|
|
223
|
+
});
|
|
216
224
|
Schema.Struct({
|
|
217
225
|
formatVersion: Schema.Literal(1),
|
|
218
226
|
files: Schema.Array(ArtifactFile)
|
|
219
227
|
});
|
|
228
|
+
Schema.Struct({
|
|
229
|
+
formatVersion: Schema.Literal(1),
|
|
230
|
+
shell: ArtifactReference,
|
|
231
|
+
routes: Schema.Array(ClientRoute)
|
|
232
|
+
});
|
|
233
|
+
const ClientRoutingRoute = Schema.Struct({
|
|
234
|
+
pathname: ClientPath,
|
|
235
|
+
artifact: ArtifactPath
|
|
236
|
+
});
|
|
237
|
+
Schema.Struct({
|
|
238
|
+
formatVersion: Schema.Literal(1),
|
|
239
|
+
shell: ArtifactPath,
|
|
240
|
+
routes: Schema.Array(ClientRoutingRoute)
|
|
241
|
+
});
|
|
220
242
|
const SchemaSnapshotField = Schema.Struct({
|
|
221
243
|
name: Schema.String,
|
|
222
244
|
value: ValueDescriptor
|
|
@@ -241,14 +263,17 @@ Schema.Struct({
|
|
|
241
263
|
functions: Schema.Array(ServerFunctionArtifact)
|
|
242
264
|
});
|
|
243
265
|
ArtifactPath.make("inventory.json");
|
|
244
|
-
ArtifactPath.make("client/
|
|
266
|
+
ArtifactPath.make("client/manifest.json");
|
|
267
|
+
ArtifactPath.make("client/shell.html");
|
|
268
|
+
`${ArtifactPath.make("client/assets")}`;
|
|
269
|
+
`${ArtifactPath.make("client/routes")}`;
|
|
245
270
|
ArtifactPath.make("server/manifest.json");
|
|
246
271
|
ArtifactPath.make("server/schema.json");
|
|
247
272
|
//#endregion
|
|
248
273
|
//#region ../contracts/dist/runtime/transport.js
|
|
249
274
|
const runtimeInvocationPath = "/v1/invoke";
|
|
250
275
|
const runtimeRevisionPath = "/v1/revision";
|
|
251
|
-
const appSyncPath =
|
|
276
|
+
const appSyncPath = `/_ignotum/v1/sync`;
|
|
252
277
|
const RuntimeRequestPath = Schema.Literals([runtimeInvocationPath, runtimeRevisionPath]);
|
|
253
278
|
const RuntimeRequestTimestamp = Schema.FiniteFromString.pipe(Schema.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)), Schema.brand("ignotum/runtime/RequestTimestamp"));
|
|
254
279
|
const RuntimeRequestSignature = Sha256.pipe(Schema.brand("ignotum/runtime/RequestSignature"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["Result","useState","useMemo","contractResult"],"sources":["../../src/client/errors.ts","../../src/client/query.ts","../../../contracts/dist/json.js","../../../contracts/dist/runtime/hosted.js","../../../shared/dist/id.js","../../../contracts/dist/runtime/functions.js","../../../contracts/dist/deployment.js","../../../contracts/dist/runtime/transport.js","../../src/internal/http-paths.ts","../../src/client/sync.ts","../../src/client/hooks.ts","../../src/client/app.ts","../../src/client/index.ts"],"sourcesContent":["/** @effect-diagnostics globalConsole:skip-file */\nimport { Cause, Effect, ErrorReporter, Schema } from \"effect\";\n\nimport { FunctionAddress, Operation, ProtocolErrorCode } from \"@ignotum/contracts/runtime/sync\";\n\nexport class ConnectionUnavailable extends Schema.TaggedError<ConnectionUnavailable>()(\n \"ConnectionUnavailable\",\n {\n cause: Schema.optional(Schema.Defect()),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidClientMessage extends Schema.TaggedError<InvalidClientMessage>()(\n \"InvalidClientMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidMutationArguments extends Schema.TaggedError<InvalidMutationArguments>()(\n \"InvalidMutationArguments\",\n {\n cause: Schema.Defect(),\n function: FunctionAddress,\n message: Schema.String,\n },\n) {}\n\nexport class InvalidServerMessage extends Schema.TaggedError<InvalidServerMessage>()(\n \"InvalidServerMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class ServerProtocolError extends Schema.TaggedError<ServerProtocolError>()(\n \"ServerProtocolError\",\n {\n code: ProtocolErrorCode,\n message: Schema.String,\n operation: Schema.optional(Operation),\n },\n) {}\n\nexport const ClientInfrastructureError = Schema.Union([\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidMutationArguments,\n InvalidServerMessage,\n ServerProtocolError,\n]);\nexport type ClientInfrastructureError = typeof ClientInfrastructureError.Type;\n\nconst browserErrorReporter = ErrorReporter.make(({ attributes, error }) => {\n globalThis.console.error(\"Ignotum infrastructure error\", error, attributes);\n});\n\nexport const clientErrorReporterLayer = ErrorReporter.layer([browserErrorReporter]);\n\nexport const reportClientError = Effect.fn(\"ClientErrorReporter.report\")(function* (\n error: ClientInfrastructureError,\n) {\n yield* ErrorReporter.report(Cause.fail(error));\n});\n","const QuerySkipTypeId: unique symbol = Symbol.for(\"ignotum/client/QuerySkip\");\n\nexport interface QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId;\n}\n\nclass QuerySkipToken implements QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId = QuerySkipTypeId;\n}\n\nconst skip: QuerySkip = Object.freeze(new QuerySkipToken());\n\nexport const Query = { skip };\n\nexport const isQuerySkip = <Value extends object | undefined>(\n value: Value,\n): value is Value & QuerySkip => value === skip;\n","import { Array, Predicate, Schema, String } from \"effect\";\n//#region src/json.ts\nconst encodeScalar = (value) => Schema.decodeSync(Schema.String)(JSON.stringify(value));\nconst encodeCanonicalJson = (value) => {\n\tif (value === null || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return encodeScalar(value);\n\tif (Predicate.isObject(value)) return `{${Array.map(Array.sort(String.Order)(Object.keys(value)), (key) => {\n\t\tconst field = Schema.decodeUnknownSync(Schema.Json)(value[key]);\n\t\treturn `${encodeScalar(key)}:${encodeCanonicalJson(field)}`;\n\t}).join(\",\")}}`;\n\treturn `[${Schema.decodeUnknownSync(Schema.Array(Schema.Json))(value).map(encodeCanonicalJson).join(\",\")}]`;\n};\n//#endregion\nexport { encodeCanonicalJson };\n\n//# sourceMappingURL=json.js.map","import { AppId, ConnectionId, DeploymentId, DevDatabaseLockId, GeneratedId, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId } from \"./id.js\";\nimport { AppStateRevision, DeploymentGeneration, InvocationKey } from \"./identity.js\";\nimport { FunctionAddress, WireFailure, WireResult, WireSuccess } from \"./sync.js\";\nimport { encodeCanonicalJson } from \"../json.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/hosted.ts\nconst QueryKey = Schema.String.pipe(Schema.brand(\"ignotum/hosted/QueryKey\"));\nconst TableDependency = Schema.Struct({\n\ttype: Schema.Literal(\"Table\"),\n\ttableId: TableId\n});\nconst DocumentDependency = Schema.Struct({\n\ttype: Schema.Literal(\"Document\"),\n\ttableId: TableId,\n\tid: GeneratedId\n});\nconst DependencyKey = Schema.Union([TableDependency, DocumentDependency]);\nconst DependencySet = Schema.Array(DependencyKey);\nconst InvalidationSet = Schema.Array(DependencyKey);\nconst RuntimeQueryResult = Schema.Struct({\n\ttype: Schema.Literal(\"Query\"),\n\tresult: WireResult,\n\tdependencies: DependencySet,\n\tobservedRevision: AppStateRevision\n});\nconst RuntimeMutationSuccess = Schema.Struct({\n\ttype: Schema.Literal(\"Mutation\"),\n\tresult: WireSuccess,\n\tinvalidations: InvalidationSet,\n\tcommittedRevision: AppStateRevision\n});\nconst RuntimeMutationFailure = Schema.Struct({\n\ttype: Schema.Literal(\"Mutation\"),\n\tresult: WireFailure\n});\nconst RuntimeMutationResult = Schema.Union([RuntimeMutationSuccess, RuntimeMutationFailure]);\nconst RuntimeInvocationResult = Schema.Union([RuntimeQueryResult, RuntimeMutationResult]);\nconst InvocationBase = {\n\tappId: AppId,\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration,\n\tinvocationKey: InvocationKey,\n\tfunction: FunctionAddress,\n\targs: Schema.Json\n};\nconst QueryInvocation = Schema.Struct({\n\t...InvocationBase,\n\ttype: Schema.Literal(\"Query\")\n});\nconst MutationInvocation = Schema.Struct({\n\t...InvocationBase,\n\ttype: Schema.Literal(\"Mutation\"),\n\tinvocationId: InvocationId\n});\nconst RuntimeInvocation = Schema.Union([QueryInvocation, MutationInvocation]);\nconst RevisionCheck = Schema.Struct({\n\tappId: AppId,\n\texpectedRevision: AppStateRevision\n});\nconst RevisionCheckResult = Schema.Struct({ currentRevision: AppStateRevision });\nvar RuntimeDeploymentUnavailable = class extends Schema.TaggedError()(\"RuntimeDeploymentUnavailable\", {\n\tdeploymentId: DeploymentId,\n\tmessage: Schema.String\n}) {};\nconst RuntimeInvocationRejectionCode = Schema.Literals([\n\t\"FunctionUnavailable\",\n\t\"InvalidArguments\",\n\t\"InvocationIdConflict\",\n\t\"ResourceLimitExceeded\",\n\t\"UnknownFunction\",\n\t\"WrongFunctionKind\"\n]);\nvar RuntimeInvocationRejected = class extends Schema.TaggedError()(\"RuntimeInvocationRejected\", {\n\tcode: RuntimeInvocationRejectionCode,\n\tinvocationKey: InvocationKey,\n\tmessage: Schema.String\n}) {};\nvar RuntimeInvocationUnavailable = class extends Schema.TaggedError()(\"RuntimeInvocationUnavailable\", {\n\tinvocationKey: InvocationKey,\n\tmessage: Schema.String\n}) {};\nvar RuntimeRevisionRejected = class extends Schema.TaggedError()(\"RuntimeRevisionRejected\", {\n\tappId: AppId,\n\tmessage: Schema.String\n}) {};\nconst RuntimeTransportError = Schema.Union([\n\tRuntimeDeploymentUnavailable,\n\tRuntimeInvocationRejected,\n\tRuntimeInvocationUnavailable\n]);\nconst dependencyKey = (dependency) => dependency.type === \"Table\" ? encodeCanonicalJson([dependency.type, dependency.tableId]) : encodeCanonicalJson([\n\tdependency.type,\n\tdependency.tableId,\n\tdependency.id\n]);\nconst canonicalQueryKey = (deploymentId, functionAddress, args) => QueryKey.make(encodeCanonicalJson([\n\tdeploymentId,\n\tfunctionAddress,\n\targs\n]));\nconst canonicalInvocationInput = (deploymentId, functionKind, functionAddress, args) => encodeCanonicalJson([\n\tdeploymentId,\n\tfunctionKind,\n\tfunctionAddress,\n\targs\n]);\nconst mutationInvocationKey = (appId, invocationId) => InvocationKey.make(encodeCanonicalJson([appId, invocationId]));\nconst tableDependency = (tableId) => ({\n\ttype: \"Table\",\n\ttableId\n});\nconst documentDependency = (tableId, id) => ({\n\ttype: \"Document\",\n\ttableId,\n\tid\n});\n//#endregion\nexport { AppId, AppStateRevision, ConnectionId, DependencyKey, DependencySet, DeploymentGeneration, DeploymentId, DevDatabaseLockId, DocumentDependency, InvalidationSet, InvocationId, InvocationKey, MutationInvocation, PlatformPrincipalId, QueryInvocation, QueryKey, RequestId, RevisionCheck, RevisionCheckResult, RuntimeDeploymentUnavailable, RuntimeInvocation, RuntimeInvocationRejected, RuntimeInvocationRejectionCode, RuntimeInvocationResult, RuntimeInvocationUnavailable, RuntimeMutationFailure, RuntimeMutationResult, RuntimeMutationSuccess, RuntimeQueryResult, RuntimeRequestNonce, RuntimeRevisionRejected, RuntimeTransportError, SubscriptionId, TableDependency, TableId, TeamId, canonicalInvocationInput, canonicalQueryKey, dependencyKey, documentDependency, mutationInvocationKey, tableDependency };\n\n//# sourceMappingURL=hosted.js.map","import { Context, Effect, Layer, Schema } from \"effect\";\nimport { IdAlphabet, IdLength } from \"@ignotum/contracts/runtime/id\";\nimport { customAlphabet } from \"nanoid\";\n//#region src/id.ts\nconst decodeGenerated = (definition, payload) => Schema.decodeSync(definition)(definition.idPrefix === void 0 ? payload : `${definition.idPrefix}_${payload}`);\nvar IdGenerator = class IdGenerator extends Context.Service()(\"@ignotum/shared/id/IdGenerator\") {\n\tstatic layer = Layer.sync(IdGenerator, () => {\n\t\tconst generatePayload = customAlphabet(IdAlphabet, IdLength);\n\t\treturn IdGenerator.of({ generate: (definition) => Effect.sync(() => decodeGenerated(definition, generatePayload())) });\n\t});\n\tstatic deterministic = (startAt = 1) => Layer.sync(IdGenerator, () => {\n\t\tconst counters = /* @__PURE__ */ new Map();\n\t\treturn IdGenerator.of({ generate: (definition) => Effect.sync(() => {\n\t\t\tconst counter = (counters.get(definition.idPrefix) ?? startAt - 1) + 1;\n\t\t\tcounters.set(definition.idPrefix, counter);\n\t\t\treturn decodeGenerated(definition, counter.toString(36).padStart(IdLength, \"0\"));\n\t\t}) });\n\t});\n};\n//#endregion\nexport { IdGenerator };\n\n//# sourceMappingURL=id.js.map","import { FunctionAddress } from \"./sync.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/functions.ts\nconst FunctionKind = Schema.Literals([\"Mutation\", \"Query\"]);\nvar UnknownFunction = class extends Schema.TaggedError()(\"UnknownFunction\", {\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar WrongFunctionKind = class extends Schema.TaggedError()(\"WrongFunctionKind\", {\n\tactual: FunctionKind,\n\texpected: FunctionKind,\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar InvalidArguments = class extends Schema.TaggedError()(\"InvalidArguments\", {\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar FunctionUnavailable = class extends Schema.TaggedError()(\"FunctionUnavailable\", {\n\tcause: Schema.Defect(),\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\n//#endregion\nexport { FunctionKind, FunctionUnavailable, InvalidArguments, UnknownFunction, WrongFunctionKind };\n\n//# sourceMappingURL=functions.js.map","import { FunctionAddress } from \"./runtime/sync.js\";\nimport { FunctionKind } from \"./runtime/functions.js\";\nimport { t as ValueDescriptor } from \"./descriptor-t6BOEGw9.js\";\nimport { Schema } from \"effect\";\n//#region src/deployment.ts\nconst ArtifactPath = Schema.String.check(Schema.isPattern(/^(?!\\/)(?![A-Za-z]:\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))(?!.*(?:^|\\/)\\.(?:\\/|$))(?!.*\\/\\/)[^\\\\\\0]+$/)).pipe(Schema.brand(\"ignotum/deployment/ArtifactPath\"));\nconst Sha256 = Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/)).pipe(Schema.brand(\"ignotum/deployment/Sha256\"));\nconst ArtifactKind = Schema.Literals([\n\t\"ClientAsset\",\n\t\"ClientShell\",\n\t\"FunctionBundle\",\n\t\"ServerManifest\",\n\t\"SourceMap\",\n\t\"SchemaSnapshot\"\n]);\nconst ArtifactReference = Schema.Struct({\n\tpath: ArtifactPath,\n\tsize: Schema.Natural,\n\tsha256: Sha256\n});\nconst ArtifactFile = Schema.Struct({\n\tpath: ArtifactPath,\n\tsize: Schema.Natural,\n\tsha256: Sha256,\n\tkind: ArtifactKind,\n\tcontentType: Schema.String,\n\tcontentEncoding: Schema.optional(Schema.String)\n});\nconst DeploymentInventory = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tfiles: Schema.Array(ArtifactFile)\n});\nconst SchemaSnapshotField = Schema.Struct({\n\tname: Schema.String,\n\tvalue: ValueDescriptor\n});\nconst SchemaSnapshotTable = Schema.Struct({\n\tname: Schema.String,\n\tfields: Schema.Array(SchemaSnapshotField)\n});\nconst SchemaSnapshot = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\ttables: Schema.Array(SchemaSnapshotTable)\n});\nconst ServerFunctionArtifact = Schema.Struct({\n\taddress: FunctionAddress,\n\tkind: FunctionKind,\n\tbundle: ArtifactReference,\n\tsourceMap: ArtifactReference\n});\nconst ServerBuildManifest = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tschema: ArtifactReference,\n\tfunctions: Schema.Array(ServerFunctionArtifact)\n});\nconst deploymentInventoryPath = ArtifactPath.make(\"inventory.json\");\nconst clientShellPath = ArtifactPath.make(\"client/_shell.html\");\nconst serverManifestPath = ArtifactPath.make(\"server/manifest.json\");\nconst schemaSnapshotPath = ArtifactPath.make(\"server/schema.json\");\nconst deploymentArtifactLimits = {\n\tfileBytes: 16777216,\n\tfileCount: 512,\n\tinventoryBytes: 1048576,\n\tserverBytes: 67108864,\n\ttotalBytes: 134217728\n};\n//#endregion\nexport { ArtifactFile, ArtifactKind, ArtifactPath, ArtifactReference, DeploymentInventory, SchemaSnapshot, SchemaSnapshotField, SchemaSnapshotTable, ServerBuildManifest, ServerFunctionArtifact, Sha256, clientShellPath, deploymentArtifactLimits, deploymentInventoryPath, schemaSnapshotPath, serverManifestPath };\n\n//# sourceMappingURL=deployment.js.map","import { AppId, DeploymentId, RuntimeRequestNonce } from \"./id.js\";\nimport { Sha256 } from \"../deployment.js\";\nimport { encodeCanonicalJson } from \"../json.js\";\nimport { RuntimeInvocationRejectionCode } from \"./hosted.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/transport.ts\nconst runtimeInvocationPath = \"/v1/invoke\";\nconst runtimeRevisionPath = \"/v1/revision\";\nconst gatewayHealthPath = \"/_ignotum/health\";\nconst appSyncPath = \"/_ignotum/v1/sync\";\nconst RuntimeRequestPath = Schema.Literals([runtimeInvocationPath, runtimeRevisionPath]);\nconst RuntimeRequestTimestamp = Schema.FiniteFromString.pipe(Schema.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)), Schema.brand(\"ignotum/runtime/RequestTimestamp\"));\nconst RuntimeRequestSignature = Sha256.pipe(Schema.brand(\"ignotum/runtime/RequestSignature\"));\nconst RuntimeRequestHeaders = Schema.Struct({\n\tappId: AppId,\n\tdeploymentId: Schema.optional(DeploymentId),\n\tnonce: RuntimeRequestNonce,\n\ttimestamp: RuntimeRequestTimestamp,\n\tsignature: RuntimeRequestSignature\n});\nconst RuntimeSigningInput = Schema.Struct({\n\tmethod: Schema.Literal(\"POST\"),\n\tpath: RuntimeRequestPath,\n\ttimestamp: RuntimeRequestTimestamp,\n\tnonce: RuntimeRequestNonce,\n\tappId: AppId,\n\tdeploymentId: Schema.optional(DeploymentId),\n\tbodySha256: Sha256\n});\nconst runtimeRequestHeaderNames = {\n\tappId: \"x-ignotum-app-id\",\n\tdeploymentId: \"x-ignotum-deployment-id\",\n\tnonce: \"x-ignotum-nonce\",\n\tsignature: \"x-ignotum-signature\",\n\ttimestamp: \"x-ignotum-timestamp\"\n};\nconst appSyncRequestHeaderNames = {\n\tdeploymentId: \"x-ignotum-deployment-id\",\n\tgeneration: \"x-ignotum-deployment-generation\"\n};\nconst runtimeRequestMaxSkewMillis = 3e4;\nconst encodeRuntimeSigningInput = (input) => encodeCanonicalJson(input.deploymentId === void 0 ? {\n\tappId: input.appId,\n\tbodySha256: input.bodySha256,\n\tmethod: input.method,\n\tnonce: input.nonce,\n\tpath: input.path,\n\ttimestamp: input.timestamp\n} : {\n\tappId: input.appId,\n\tbodySha256: input.bodySha256,\n\tdeploymentId: input.deploymentId,\n\tmethod: input.method,\n\tnonce: input.nonce,\n\tpath: input.path,\n\ttimestamp: input.timestamp\n});\nconst RuntimeErrorCode = Schema.Literals([\n\t\"InvalidRequest\",\n\t\"InvalidSignature\",\n\t\"RequestExpired\",\n\t\"RequestReplay\",\n\t\"InvocationRejected\",\n\t\"RuntimeUnavailable\"\n]);\nconst RuntimeErrorResponse = Schema.Struct({\n\tcode: RuntimeErrorCode,\n\tmessage: Schema.String,\n\trejectionCode: Schema.optional(RuntimeInvocationRejectionCode)\n});\n//#endregion\nexport { RuntimeErrorCode, RuntimeErrorResponse, RuntimeRequestHeaders, RuntimeRequestNonce, RuntimeRequestPath, RuntimeRequestSignature, RuntimeRequestTimestamp, RuntimeSigningInput, appSyncPath, appSyncRequestHeaderNames, encodeRuntimeSigningInput, gatewayHealthPath, runtimeInvocationPath, runtimeRequestHeaderNames, runtimeRequestMaxSkewMillis, runtimeRevisionPath };\n\n//# sourceMappingURL=transport.js.map","import { appSyncPath } from \"@ignotum/contracts/runtime/transport\";\n\nexport const ignotumPathPrefix = \"/_ignotum\";\nexport const syncPath = appSyncPath;\n\nexport const isIgnotumPath = (pathname: string): boolean =>\n pathname === ignotumPathPrefix || pathname.startsWith(`${ignotumPathPrefix}/`);\n","import {\n Context,\n Deferred,\n Duration,\n Effect,\n Fiber,\n HashMap,\n Layer,\n ManagedRuntime,\n Schedule,\n Schema,\n} from \"effect\";\nimport * as Socket from \"effect/unstable/socket/Socket\";\nimport * as BrowserCrypto from \"@effect/platform-browser/BrowserCrypto\";\n\nimport { encodeCanonicalJson } from \"@ignotum/contracts/json\";\nimport { type AppStateRevision } from \"@ignotum/contracts/runtime/hosted\";\nimport { IdGenerator } from \"@ignotum/shared/id\";\n\nimport type {\n ErrorValue,\n QueryResult,\n Result as IgnotumResult,\n} from \"@ignotum/contracts/runtime/result\";\nimport { failureFromWire, pending, Result } from \"@ignotum/contracts/runtime/result\";\nimport {\n ClientMessageJson,\n DeploymentChangedCloseCode,\n InvocationId,\n ServerMessageJson,\n SubscriptionId,\n decodeTransportValue,\n type ClientMessage,\n type FunctionAddress,\n type ServerMessage,\n type SyncHandshake,\n type WireResult,\n} from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidServerMessage,\n ServerProtocolError,\n clientErrorReporterLayer,\n reportClientError,\n} from \"./errors.js\";\nimport { syncPath } from \"../internal/http-paths.js\";\n\ntype Listener = () => void;\ntype SocketWriter = (chunk: string) => Effect.Effect<void, Socket.SocketError>;\n\ninterface QueryEntry {\n readonly args: Schema.Json;\n readonly function: FunctionAddress;\n readonly listeners: Set<Listener>;\n readonly subscriptionId: SubscriptionId;\n generation: number;\n revision: AppStateRevision | undefined;\n references: number;\n result: QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n}\n\ninterface QueryObserver {\n readonly getSnapshot: () => QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n readonly release: Effect.Effect<void>;\n readonly subscribe: (listener: Listener) => () => void;\n}\n\ntype QueryLifecycleMessage = Extract<ClientMessage, { readonly type: \"Subscribe\" | \"Unsubscribe\" }>;\n\ninterface QueryCache {\n readonly entries: () => Iterable<QueryEntry>;\n readonly getById: (id: SubscriptionId) => QueryEntry | undefined;\n readonly setError: (id: SubscriptionId, error: ClientInfrastructureError) => void;\n readonly setResult: (\n id: SubscriptionId,\n result: QueryResult<unknown, ErrorValue>,\n revision: AppStateRevision,\n ) => void;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver>;\n}\n\nconst queryKey = (functionAddress: FunctionAddress, args: Schema.Json): string =>\n encodeCanonicalJson([functionAddress, args]);\n\nconst subscribeMessage = (entry: QueryEntry): QueryLifecycleMessage => ({\n type: \"Subscribe\",\n id: entry.subscriptionId,\n function: entry.function,\n args: entry.args,\n});\n\nconst makeQueryCache = (\n allocateId: Effect.Effect<SubscriptionId>,\n sendLifecycleMessage: (message: QueryLifecycleMessage) => Effect.Effect<void>,\n) => {\n const queries = new Map<string, QueryEntry>();\n const queryKeysById = new Map<SubscriptionId, string>();\n\n const observe = Effect.fn(\"SyncClient.QueryCache.observe\")(function* (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) {\n const key = queryKey(functionAddress, args);\n let entry = queries.get(key);\n\n if (entry === undefined) {\n const created: QueryEntry = {\n args,\n function: functionAddress,\n generation: 0,\n listeners: new Set(),\n revision: undefined,\n references: 0,\n result: pending(),\n subscriptionId: yield* allocateId,\n };\n queries.set(key, created);\n queryKeysById.set(created.subscriptionId, key);\n yield* sendLifecycleMessage(subscribeMessage(created));\n entry = created;\n }\n\n const observed = entry;\n observed.references += 1;\n observed.generation += 1;\n let released = false;\n return {\n getSnapshot: () => observed.result,\n subscribe: (listener: Listener) => {\n observed.listeners.add(listener);\n return () => observed.listeners.delete(listener);\n },\n release: Effect.gen(function* () {\n if (released) return;\n released = true;\n observed.references -= 1;\n if (observed.references !== 0) return;\n const generation = ++observed.generation;\n\n // Preact and HMR may release and reacquire an observer during one render handoff.\n // Keep the server subscription alive long enough for that handoff to reuse it.\n yield* Effect.sleep(\"25 millis\");\n if (\n observed.references !== 0 ||\n observed.generation !== generation ||\n queries.get(key) !== observed\n ) {\n return;\n }\n\n queries.delete(key);\n queryKeysById.delete(observed.subscriptionId);\n yield* sendLifecycleMessage({\n type: \"Unsubscribe\",\n id: observed.subscriptionId,\n });\n }),\n } satisfies QueryObserver;\n });\n\n return {\n entries: () => queries.values(),\n getById: (id: SubscriptionId) => {\n const key = queryKeysById.get(id);\n return key === undefined ? undefined : queries.get(key);\n },\n observe,\n setError: (id, error) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n entry.result = error;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n setResult: (id, result, revision) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n if (entry.revision !== undefined && revision < entry.revision) {\n return;\n }\n entry.revision = revision;\n entry.result = result;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n } satisfies QueryCache;\n};\n\nconst resultFromWire = Effect.fn(\"SyncClient.resultFromWire\")((wire: WireResult) =>\n Effect.succeed(\n wire.type === \"Success\"\n ? Result.succeed(\n wire.value === undefined ? undefined : decodeTransportValue(wire.value, wire.dates ?? []),\n )\n : failureFromWire(wire.error, wire.dates),\n ),\n);\n\nexport const shouldReloadForCloseCode = (code: number): boolean =>\n code === DeploymentChangedCloseCode;\n\nconst handshakesMatch = (first: SyncHandshake, next: SyncHandshake): boolean =>\n first.appId === next.appId &&\n first.deploymentId === next.deploymentId &&\n first.generation === next.generation;\n\ntype HandshakeDecision = \"Accept\" | \"Ignore\" | \"Reload\";\n\nconst handshakeDecision = (\n remembered: SyncHandshake | undefined,\n acceptedOnConnection: boolean,\n next: SyncHandshake,\n): HandshakeDecision => {\n if (remembered !== undefined && !handshakesMatch(remembered, next)) return \"Reload\";\n return acceptedOnConnection ? \"Ignore\" : \"Accept\";\n};\n\nexport const syncClientInternals = {\n makeQueryCache,\n handshakeDecision,\n queryIdentity: queryKey,\n resultFromWire,\n handshakesMatch,\n shouldReloadForCloseCode,\n};\n\nconst socketUrl = (): string => {\n const url = new URL(syncPath, globalThis.location.href);\n url.protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n return url.href;\n};\n\ninterface SyncClientService {\n readonly mutate: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<IgnotumResult<unknown, ErrorValue>, ClientInfrastructureError>;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver, ClientInfrastructureError>;\n}\n\ninterface PendingInvocation {\n readonly deferred: Deferred.Deferred<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >;\n readonly function: FunctionAddress;\n readonly message: Extract<ClientMessage, { readonly type: \"Invoke\" }>;\n}\n\nexport class SyncClient extends Context.Service<SyncClient, SyncClientService>()(\n \"ignotum/client/sync/SyncClient\",\n) {\n static readonly layer = Layer.effect(\n SyncClient,\n Effect.gen(function* () {\n const ids = yield* IdGenerator;\n let invocations = HashMap.empty<InvocationId, PendingInvocation>();\n let rememberedHandshake: SyncHandshake | undefined;\n let reloadRequested = false;\n let writer: SocketWriter | undefined;\n\n const encode = (message: ClientMessage) =>\n Schema.encodeEffect(ClientMessageJson)(message).pipe(\n Effect.mapError((cause) =>\n InvalidClientMessage.make({\n cause,\n message: \"Could not encode an Ignotum sync message.\",\n }),\n ),\n );\n\n const sendWith = (write: SocketWriter, message: ClientMessage) =>\n encode(message).pipe(\n Effect.flatMap(write),\n Effect.mapError((cause) =>\n Schema.is(InvalidClientMessage)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n );\n\n const send = (message: ClientMessage) =>\n writer === undefined\n ? Effect.fail(\n ConnectionUnavailable.make({ message: \"The sync connection is not ready.\" }),\n )\n : sendWith(writer, message);\n\n const queryCache = makeQueryCache(ids.generate(SubscriptionId), (message) =>\n writer === undefined\n ? Effect.void\n : send(message).pipe(\n Effect.catchTags({\n ConnectionUnavailable: reportClientError,\n InvalidClientMessage: reportClientError,\n }),\n ),\n );\n\n const rejectInvocation = (id: InvocationId, error: ClientInfrastructureError) => {\n const pendingInvocation = HashMap.getUnsafe(invocations, id);\n if (pendingInvocation === undefined) {\n return Effect.void;\n }\n invocations = HashMap.remove(invocations, id);\n return reportClientError(error).pipe(\n Effect.andThen(Deferred.fail(pendingInvocation.deferred, error)),\n Effect.asVoid,\n );\n };\n\n const handleMessage = Effect.fn(\"SyncClient.handleMessage\")(function* (\n message: Exclude<ServerMessage, SyncHandshake | { readonly type: \"DeploymentChanged\" }>,\n ) {\n switch (message.type) {\n case \"Snapshot\": {\n const entry = queryCache.getById(message.id);\n if (entry === undefined) return;\n yield* resultFromWire(message.result).pipe(\n Effect.tap((result) =>\n Effect.sync(() => queryCache.setResult(message.id, result, message.revision)),\n ),\n );\n return;\n }\n case \"Result\": {\n const pendingInvocation = HashMap.getUnsafe(invocations, message.id);\n if (pendingInvocation === undefined) return;\n invocations = HashMap.remove(invocations, message.id);\n yield* resultFromWire(message.result).pipe(\n Effect.flatMap((result) => Deferred.succeed(pendingInvocation.deferred, result)),\n );\n return;\n }\n case \"ProtocolError\": {\n const error =\n message.operation === undefined\n ? ServerProtocolError.make({\n code: message.code,\n message: message.message,\n })\n : ServerProtocolError.make({\n code: message.code,\n message: message.message,\n operation: message.operation,\n });\n if (message.operation?.type === \"Invocation\") {\n yield* rejectInvocation(message.operation.id, error);\n } else if (message.operation?.type === \"Subscription\") {\n queryCache.setError(message.operation.id, error);\n yield* reportClientError(error);\n } else {\n yield* reportClientError(error);\n }\n return;\n }\n }\n });\n\n const requestReload = () => {\n if (reloadRequested) return;\n reloadRequested = true;\n writer = undefined;\n globalThis.location.reload();\n };\n\n const disconnect = Effect.sync(() => {\n writer = undefined;\n });\n\n const connect = Effect.scoped(\n Effect.gen(function* () {\n if (reloadRequested) return yield* Effect.never;\n const socket = yield* Socket.makeWebSocket(socketUrl(), {\n closeCodeIsError: (code) => {\n if (shouldReloadForCloseCode(code)) requestReload();\n return false;\n },\n });\n const write = yield* socket.writer;\n const handshakeReceived = yield* Deferred.make<void>();\n let handshakeAccepted = false;\n const acceptHandshake = Effect.fn(\"SyncClient.acceptHandshake\")(function* (\n handshake: SyncHandshake,\n ) {\n const decision = handshakeDecision(rememberedHandshake, handshakeAccepted, handshake);\n if (decision === \"Reload\") {\n requestReload();\n return;\n }\n if (decision === \"Ignore\") return;\n rememberedHandshake = handshake;\n handshakeAccepted = true;\n writer = write;\n yield* Deferred.succeed(handshakeReceived, undefined);\n yield* Effect.gen(function* () {\n yield* Effect.forEach(queryCache.entries(), (entry) =>\n sendWith(write, subscribeMessage(entry)),\n );\n yield* Effect.forEach(HashMap.values(invocations), (pendingInvocation) =>\n sendWith(write, pendingInvocation.message),\n );\n }).pipe(Effect.tapError(reportClientError), Effect.ignore);\n });\n\n const handleText = Effect.fn(\"SyncClient.handleText\")(function* (text: string) {\n const message = yield* Schema.decodeEffect(ServerMessageJson)(text).pipe(\n Effect.mapError((cause) =>\n InvalidServerMessage.make({\n cause,\n message: \"The server returned an invalid sync message.\",\n }),\n ),\n );\n if (message.type === \"Handshake\") return yield* acceptHandshake(message);\n if (message.type === \"DeploymentChanged\") {\n requestReload();\n return;\n }\n if (!handshakeAccepted) {\n return yield* InvalidServerMessage.make({\n cause: new Error(\"The server sent a sync message before the handshake.\"),\n message: \"The server returned a sync message before the handshake.\",\n });\n }\n return yield* handleMessage(message);\n });\n\n const run = yield* socket.runString(handleText).pipe(Effect.forkChild);\n yield* Effect.raceFirst(\n Deferred.await(handshakeReceived).pipe(Effect.timeout(\"10 seconds\")),\n Fiber.join(run),\n );\n yield* Fiber.join(run);\n }),\n ).pipe(\n Effect.mapError((cause) =>\n Schema.is(ClientInfrastructureError)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n Effect.ensuring(disconnect),\n );\n\n const reconnectSchedule = Schedule.exponential(\"250 millis\").pipe(\n Schedule.modifyDelay(({ duration }) =>\n Effect.succeed(Duration.min(duration, Duration.seconds(5))),\n ),\n Schedule.jittered,\n );\n yield* connect.pipe(\n Effect.andThen(\n Effect.fail(\n ConnectionUnavailable.make({\n message: \"The sync connection closed; reconnecting.\",\n }),\n ),\n ),\n Effect.tapError(reportClientError),\n Effect.retry(reconnectSchedule),\n Effect.forkScoped,\n );\n\n const observe: SyncClientService[\"observe\"] = Effect.fn(\"SyncClient.observe\")(\n function* (functionAddress, args) {\n return yield* queryCache.observe(functionAddress, args);\n },\n );\n\n const mutate: SyncClientService[\"mutate\"] = Effect.fn(\"SyncClient.mutate\")(\n function* (functionAddress, args) {\n const invocationId = yield* ids.generate(InvocationId);\n const deferred = yield* Deferred.make<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >();\n const message: ClientMessage = {\n type: \"Invoke\",\n id: invocationId,\n kind: \"Mutation\",\n function: functionAddress,\n args,\n };\n invocations = HashMap.set(invocations, invocationId, {\n deferred,\n function: functionAddress,\n message,\n });\n if (writer !== undefined) {\n yield* sendWith(writer, message).pipe(\n Effect.catchTags({\n ConnectionUnavailable: reportClientError,\n InvalidClientMessage: (error) => rejectInvocation(invocationId, error),\n }),\n );\n }\n return yield* Deferred.await(deferred);\n },\n );\n\n return SyncClient.of({ mutate, observe });\n }),\n ).pipe(Layer.provide(Layer.merge(Socket.layerWebSocketConstructorGlobal, BrowserCrypto.layer)));\n}\n\nexport const syncRuntime = ManagedRuntime.make(\n SyncClient.layer.pipe(\n Layer.provideMerge(clientErrorReporterLayer),\n Layer.provideMerge(IdGenerator.layer),\n ),\n);\n\n// SAFETY: Vite adds this optional property to browser development modules.\nconst hot = (\n import.meta as ImportMeta & {\n readonly hot?: { readonly dispose: (cleanup: () => void) => void };\n }\n).hot;\nif (hot !== undefined) {\n hot.dispose(() => void syncRuntime.dispose());\n}\n","import { Effect, Schema } from \"effect\";\nimport { useDebugValue, useEffect, useMemo, useState } from \"preact/hooks\";\n\nimport { functionPathOf, type FunctionReference } from \"../internal/api.js\";\nimport { pending } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, QueryResult, SettledResult } from \"@ignotum/contracts/runtime/result\";\nimport { encodeTransportObject } from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n InvalidMutationArguments,\n reportClientError,\n} from \"./errors.js\";\nimport { isQuerySkip, type QuerySkip } from \"./query.js\";\nimport { SyncClient, syncClientInternals, syncRuntime } from \"./sync.js\";\n\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks are not pipeable functions.\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n): QueryResult<Success, Failure>;\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n args: QuerySkip,\n): QueryResult<Success, Failure>;\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args, Success, Failure>,\n args: NoInfer<Args> | QuerySkip,\n): QueryResult<Success, Failure>;\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks must remain direct calls so hook order is statically visible.\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args | void, Success, Failure>,\n args?: Args | QuerySkip,\n): QueryResult<Success, Failure> {\n const functionPath = functionPathOf(reference);\n const skipped = isQuerySkip(args);\n const input = args === undefined || skipped ? {} : args;\n const jsonArgs = encodeTransportObject(input);\n const identity = skipped\n ? `skip:${functionPath}`\n : syncClientInternals.queryIdentity(functionPath, jsonArgs);\n const [state, setState] = useState<{\n readonly identity: string;\n readonly result: QueryResult<Success, Failure> | ClientInfrastructureError;\n }>(() => ({ identity, result: pending() }));\n\n useDebugValue({ args: input, function: functionPath, result: state.result });\n useEffect(() => {\n if (skipped) return;\n\n let active = true;\n let release: (() => void) | undefined;\n\n void syncRuntime\n .runPromise(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n return yield* client.observe(functionPath, jsonArgs);\n }),\n )\n .then(\n (observer) => {\n if (!active) {\n syncRuntime.runFork(observer.release);\n return;\n }\n const update = () => {\n // SAFETY: the function reference couples this subscription's runtime\n // path to its generated success and failure types.\n const result = observer.getSnapshot() as\n | QueryResult<Success, Failure>\n | ClientInfrastructureError;\n setState({ identity, result });\n };\n release = observer.subscribe(update);\n update();\n const releaseObserver = release;\n release = () => {\n releaseObserver();\n syncRuntime.runFork(observer.release);\n };\n },\n (error) => {\n if (active && Schema.is(ClientInfrastructureError)(error)) {\n setState({ identity, result: error });\n }\n },\n );\n\n return () => {\n active = false;\n release?.();\n };\n }, [identity]);\n\n if (skipped) return pending();\n\n if (state.identity !== identity) {\n return pending();\n }\n\n const result = state.result;\n if (Schema.is(ClientInfrastructureError)(result)) throw result;\n return result;\n}\n\ntype Mutation<Args, Success, Failure extends ErrorValue> = [Args] extends [void]\n ? () => Promise<SettledResult<Success, Failure>>\n : (args: Args) => Promise<SettledResult<Success, Failure>>;\n\nexport const useMutation = <Args extends object | void, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Mutation\", Args, Success, Failure>,\n): Mutation<Args, Success, Failure> =>\n useMemo(() => {\n const mutate = (args: Args | undefined) => {\n const functionPath = functionPathOf(reference);\n const input = args === undefined ? {} : args;\n return syncRuntime.runPromise<SettledResult<Success, Failure>, ClientInfrastructureError>(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n const jsonArgs = yield* Effect.try({\n try: () => encodeTransportObject(input),\n catch: (cause) =>\n InvalidMutationArguments.make({\n cause,\n function: functionPath,\n message: `Mutation arguments for ${functionPath} contain an unsupported value.`,\n }),\n }).pipe(Effect.tapError(reportClientError));\n // SAFETY: generated function references bind the runtime path to the\n // declared public result types validated by the server executor.\n // oxlint-disable-next-line anti-slop/no-chained-type-assertions -- The untyped sync transport deliberately erases the generated reference's result parameters.\n return (yield* client.mutate(functionPath, jsonArgs)) as unknown as SettledResult<\n Success,\n Failure\n >;\n }),\n );\n };\n // SAFETY: the builder gives argument-free functions Args = void. At runtime\n // both call shapes normalize omitted arguments to the empty JSON object.\n return mutate as Mutation<Args, Success, Failure>;\n }, [reference]);\n","import type { ComponentType } from \"preact\";\n\nexport interface AppDefinition<Component extends ComponentType<{}> = ComponentType<{}>> {\n readonly component: Component;\n readonly title: string;\n}\n\nexport const app = <Component extends ComponentType<{}>>(\n definition: AppDefinition<Component>,\n): AppDefinition<Component> => {\n if (definition.title.trim().length === 0) {\n throw new Error(\"The app title must contain a non-whitespace character.\");\n }\n return definition;\n};\n","import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type {\n ErrorValue,\n QueryResult as ContractQueryResult,\n SettledResult,\n} from \"@ignotum/contracts/runtime/result\";\n\nexport const Result = { match: contractResult.match };\nexport type Result<Value, Error extends ErrorValue> = SettledResult<Value, Error>;\nexport type QueryResult<Value, Error extends ErrorValue> = ContractQueryResult<Value, Error>;\nexport type { InternalServerError } from \"@ignotum/contracts/runtime/result\";\nexport { useMutation, useQuery } from \"./hooks.js\";\nexport { Query } from \"./query.js\";\nexport type { QuerySkip } from \"./query.js\";\nexport { app } from \"./app.js\";\nexport type { AppDefinition } from \"./app.js\";\n\nexport {\n Component,\n Fragment,\n cloneElement,\n createContext,\n createElement,\n createRef,\n h,\n isValidElement,\n toChildArray,\n} from \"preact\";\nexport type {\n AnyComponent,\n Attributes,\n ClassAttributes,\n ComponentChild,\n ComponentChildren,\n ComponentClass,\n ComponentConstructor,\n ComponentFactory,\n ComponentProps,\n ComponentType,\n Consumer,\n Context,\n ContextType,\n ErrorInfo,\n FunctionComponent,\n FunctionalComponent,\n JSX,\n Key,\n PreactContext,\n PreactConsumer,\n PreactDOMAttributes,\n PreactProvider,\n Provider,\n Ref,\n RefCallback,\n RefObject,\n RenderableProps,\n TargetedAnimationEvent,\n TargetedClipboardEvent,\n TargetedCommandEvent,\n TargetedCompositionEvent,\n TargetedDragEvent,\n TargetedEvent,\n TargetedFocusEvent,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedMouseEvent,\n TargetedPictureInPictureEvent,\n TargetedPointerEvent,\n TargetedSnapEvent,\n TargetedSubmitEvent,\n TargetedToggleEvent,\n TargetedTouchEvent,\n TargetedTransitionEvent,\n TargetedUIEvent,\n TargetedWheelEvent,\n VNode,\n} from \"preact\";\nexport {\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useErrorBoundary,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from \"preact/hooks\";\nexport type { Dispatch, Reducer, StateUpdater } from \"preact/hooks\";\n"],"mappings":";;;;;;;;;;;AAKA,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CACpF,yBACA;CACE,OAAO,OAAO,SAAS,OAAO,OAAO,CAAC;CACtC,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,OAAO,OAAO,OAAO;CACrB,UAAU;CACV,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,sBAAb,cAAyC,OAAO,YAAiC,CAAC,CAChF,uBACA;CACE,MAAM;CACN,SAAS,OAAO;CAChB,WAAW,OAAO,SAAS,SAAS;AACtC,CACF,CAAC,CAAC,CAAC;AAEH,MAAa,4BAA4B,OAAO,MAAM;CACpD;CACA;CACA;CACA;CACA;AACF,CAAC;AAGD,MAAM,uBAAuB,cAAc,MAAM,EAAE,YAAY,YAAY;CACzE,WAAW,QAAQ,MAAM,gCAAgC,OAAO,UAAU;AAC5E,CAAC;AAED,MAAa,2BAA2B,cAAc,MAAM,CAAC,oBAAoB,CAAC;AAElF,MAAa,oBAAoB,OAAO,GAAG,4BAA4B,CAAC,CAAC,WACvE,OACA;CACA,OAAO,cAAc,OAAO,MAAM,KAAK,KAAK,CAAC;AAC/C,CAAC;;;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M,kBAAkB;GACxB,gBAAgB;IACd,gBAAgB;IAChB,YAAY,QAAQ,SAAS,OAAO;GACtC;EACF,IACC,UAAU;GACT,IAAI,UAAU,OAAO,GAAG,yBAAyB,CAAC,CAAC,KAAK,GACtD,SAAS;IAAE;IAAU,QAAQ;GAAM,CAAC;EAExC,CACF;EAEF,aAAa;GACX,SAAS;GACT,UAAU;EACZ;CACF,GAAG,CAAC,QAAQ,CAAC;CAEb,IAAI,SAAS,OAAO,QAAQ;CAE5B,IAAI,MAAM,aAAa,UACrB,OAAO,QAAQ;CAGjB,MAAM,SAAS,MAAM;CACrB,IAAI,OAAO,GAAG,yBAAyB,CAAC,CAAC,MAAM,GAAG,MAAM;CACxD,OAAO;AACT;AAMA,MAAa,eACX,cAEAC,gBAAc;CACZ,MAAM,UAAU,SAA2B;EACzC,MAAM,eAAe,eAAe,SAAS;EAC7C,MAAM,QAAQ,SAAS,KAAA,IAAY,CAAC,IAAI;EACxC,OAAO,YAAY,WACjB,OAAO,IAAI,aAAa;GACtB,MAAM,SAAS,OAAO;GACtB,MAAM,WAAW,OAAO,OAAO,IAAI;IACjC,WAAW,sBAAsB,KAAK;IACtC,QAAQ,UACN,yBAAyB,KAAK;KAC5B;KACA,UAAU;KACV,SAAS,0BAA0B,aAAa;IAClD,CAAC;GACL,CAAC,CAAC,CAAC,KAAK,OAAO,SAAS,iBAAiB,CAAC;GAI1C,OAAQ,OAAO,OAAO,OAAO,cAAc,QAAQ;EAIrD,CAAC,CACH;CACF;CAGA,OAAO;AACT,GAAG,CAAC,SAAS,CAAC;;;ACrIhB,MAAa,OACX,eAC6B;CAC7B,IAAI,WAAW,MAAM,KAAK,CAAC,CAAC,WAAW,GACrC,MAAM,IAAI,MAAM,wDAAwD;CAE1E,OAAO;AACT;;;ACPA,MAAa,SAAS,EAAE,OAAOC,SAAe,MAAM"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["Result","useState","useMemo","contractResult"],"sources":["../../src/client/errors.ts","../../src/client/query.ts","../../../contracts/dist/json.js","../../../contracts/dist/runtime/hosted.js","../../../shared/dist/id.js","../../../contracts/dist/runtime/functions.js","../../../contracts/dist/deployment.js","../../../contracts/dist/runtime/transport.js","../../src/internal/http-paths.ts","../../src/client/sync.ts","../../src/client/hooks.ts","../../src/client/app.ts","../../src/client/index.ts"],"sourcesContent":["/** @effect-diagnostics globalConsole:skip-file */\nimport { Cause, Effect, ErrorReporter, Schema } from \"effect\";\n\nimport { FunctionAddress, Operation, ProtocolErrorCode } from \"@ignotum/contracts/runtime/sync\";\n\nexport class ConnectionUnavailable extends Schema.TaggedError<ConnectionUnavailable>()(\n \"ConnectionUnavailable\",\n {\n cause: Schema.optional(Schema.Defect()),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidClientMessage extends Schema.TaggedError<InvalidClientMessage>()(\n \"InvalidClientMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class InvalidMutationArguments extends Schema.TaggedError<InvalidMutationArguments>()(\n \"InvalidMutationArguments\",\n {\n cause: Schema.Defect(),\n function: FunctionAddress,\n message: Schema.String,\n },\n) {}\n\nexport class InvalidServerMessage extends Schema.TaggedError<InvalidServerMessage>()(\n \"InvalidServerMessage\",\n {\n cause: Schema.Defect(),\n message: Schema.String,\n },\n) {}\n\nexport class ServerProtocolError extends Schema.TaggedError<ServerProtocolError>()(\n \"ServerProtocolError\",\n {\n code: ProtocolErrorCode,\n message: Schema.String,\n operation: Schema.optional(Operation),\n },\n) {}\n\nexport const ClientInfrastructureError = Schema.Union([\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidMutationArguments,\n InvalidServerMessage,\n ServerProtocolError,\n]);\nexport type ClientInfrastructureError = typeof ClientInfrastructureError.Type;\n\nconst browserErrorReporter = ErrorReporter.make(({ attributes, error }) => {\n globalThis.console.error(\"Ignotum infrastructure error\", error, attributes);\n});\n\nexport const clientErrorReporterLayer = ErrorReporter.layer([browserErrorReporter]);\n\nexport const reportClientError = Effect.fn(\"ClientErrorReporter.report\")(function* (\n error: ClientInfrastructureError,\n) {\n yield* ErrorReporter.report(Cause.fail(error));\n});\n","const QuerySkipTypeId: unique symbol = Symbol.for(\"ignotum/client/QuerySkip\");\n\nexport interface QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId;\n}\n\nclass QuerySkipToken implements QuerySkip {\n readonly [QuerySkipTypeId]: typeof QuerySkipTypeId = QuerySkipTypeId;\n}\n\nconst skip: QuerySkip = Object.freeze(new QuerySkipToken());\n\nexport const Query = { skip };\n\nexport const isQuerySkip = <Value extends object | undefined>(\n value: Value,\n): value is Value & QuerySkip => value === skip;\n","import { Array, Predicate, Schema, String } from \"effect\";\n//#region src/json.ts\nconst encodeScalar = (value) => Schema.decodeSync(Schema.String)(JSON.stringify(value));\nconst encodeCanonicalJson = (value) => {\n\tif (value === null || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return encodeScalar(value);\n\tif (Predicate.isObject(value)) return `{${Array.map(Array.sort(String.Order)(Object.keys(value)), (key) => {\n\t\tconst field = Schema.decodeUnknownSync(Schema.Json)(value[key]);\n\t\treturn `${encodeScalar(key)}:${encodeCanonicalJson(field)}`;\n\t}).join(\",\")}}`;\n\treturn `[${Schema.decodeUnknownSync(Schema.Array(Schema.Json))(value).map(encodeCanonicalJson).join(\",\")}]`;\n};\n//#endregion\nexport { encodeCanonicalJson };\n\n//# sourceMappingURL=json.js.map","import { AppId, ConnectionId, DeploymentId, DevDatabaseLockId, GeneratedId, InvocationId, PlatformPrincipalId, RequestId, RuntimeRequestNonce, SubscriptionId, TableId, TeamId } from \"./id.js\";\nimport { AppStateRevision, DeploymentGeneration, InvocationKey } from \"./identity.js\";\nimport { FunctionAddress, WireFailure, WireResult, WireSuccess } from \"./sync.js\";\nimport { encodeCanonicalJson } from \"../json.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/hosted.ts\nconst QueryKey = Schema.String.pipe(Schema.brand(\"ignotum/hosted/QueryKey\"));\nconst TableDependency = Schema.Struct({\n\ttype: Schema.Literal(\"Table\"),\n\ttableId: TableId\n});\nconst DocumentDependency = Schema.Struct({\n\ttype: Schema.Literal(\"Document\"),\n\ttableId: TableId,\n\tid: GeneratedId\n});\nconst DependencyKey = Schema.Union([TableDependency, DocumentDependency]);\nconst DependencySet = Schema.Array(DependencyKey);\nconst InvalidationSet = Schema.Array(DependencyKey);\nconst RuntimeQueryResult = Schema.Struct({\n\ttype: Schema.Literal(\"Query\"),\n\tresult: WireResult,\n\tdependencies: DependencySet,\n\tobservedRevision: AppStateRevision\n});\nconst RuntimeMutationSuccess = Schema.Struct({\n\ttype: Schema.Literal(\"Mutation\"),\n\tresult: WireSuccess,\n\tinvalidations: InvalidationSet,\n\tcommittedRevision: AppStateRevision\n});\nconst RuntimeMutationFailure = Schema.Struct({\n\ttype: Schema.Literal(\"Mutation\"),\n\tresult: WireFailure\n});\nconst RuntimeMutationResult = Schema.Union([RuntimeMutationSuccess, RuntimeMutationFailure]);\nconst RuntimeInvocationResult = Schema.Union([RuntimeQueryResult, RuntimeMutationResult]);\nconst InvocationBase = {\n\tappId: AppId,\n\tdeploymentId: DeploymentId,\n\tgeneration: DeploymentGeneration,\n\tinvocationKey: InvocationKey,\n\tfunction: FunctionAddress,\n\targs: Schema.Json\n};\nconst QueryInvocation = Schema.Struct({\n\t...InvocationBase,\n\ttype: Schema.Literal(\"Query\")\n});\nconst MutationInvocation = Schema.Struct({\n\t...InvocationBase,\n\ttype: Schema.Literal(\"Mutation\"),\n\tinvocationId: InvocationId\n});\nconst RuntimeInvocation = Schema.Union([QueryInvocation, MutationInvocation]);\nconst RevisionCheck = Schema.Struct({\n\tappId: AppId,\n\texpectedRevision: AppStateRevision\n});\nconst RevisionCheckResult = Schema.Struct({ currentRevision: AppStateRevision });\nvar RuntimeDeploymentUnavailable = class extends Schema.TaggedError()(\"RuntimeDeploymentUnavailable\", {\n\tdeploymentId: DeploymentId,\n\tmessage: Schema.String\n}) {};\nconst RuntimeInvocationRejectionCode = Schema.Literals([\n\t\"FunctionUnavailable\",\n\t\"InvalidArguments\",\n\t\"InvocationIdConflict\",\n\t\"ResourceLimitExceeded\",\n\t\"UnknownFunction\",\n\t\"WrongFunctionKind\"\n]);\nvar RuntimeInvocationRejected = class extends Schema.TaggedError()(\"RuntimeInvocationRejected\", {\n\tcode: RuntimeInvocationRejectionCode,\n\tinvocationKey: InvocationKey,\n\tmessage: Schema.String\n}) {};\nvar RuntimeInvocationUnavailable = class extends Schema.TaggedError()(\"RuntimeInvocationUnavailable\", {\n\tinvocationKey: InvocationKey,\n\tmessage: Schema.String\n}) {};\nvar RuntimeRevisionRejected = class extends Schema.TaggedError()(\"RuntimeRevisionRejected\", {\n\tappId: AppId,\n\tmessage: Schema.String\n}) {};\nconst RuntimeTransportError = Schema.Union([\n\tRuntimeDeploymentUnavailable,\n\tRuntimeInvocationRejected,\n\tRuntimeInvocationUnavailable\n]);\nconst dependencyKey = (dependency) => dependency.type === \"Table\" ? encodeCanonicalJson([dependency.type, dependency.tableId]) : encodeCanonicalJson([\n\tdependency.type,\n\tdependency.tableId,\n\tdependency.id\n]);\nconst canonicalQueryKey = (deploymentId, functionAddress, args) => QueryKey.make(encodeCanonicalJson([\n\tdeploymentId,\n\tfunctionAddress,\n\targs\n]));\nconst canonicalInvocationInput = (deploymentId, functionKind, functionAddress, args) => encodeCanonicalJson([\n\tdeploymentId,\n\tfunctionKind,\n\tfunctionAddress,\n\targs\n]);\nconst mutationInvocationKey = (appId, invocationId) => InvocationKey.make(encodeCanonicalJson([appId, invocationId]));\nconst tableDependency = (tableId) => ({\n\ttype: \"Table\",\n\ttableId\n});\nconst documentDependency = (tableId, id) => ({\n\ttype: \"Document\",\n\ttableId,\n\tid\n});\n//#endregion\nexport { AppId, AppStateRevision, ConnectionId, DependencyKey, DependencySet, DeploymentGeneration, DeploymentId, DevDatabaseLockId, DocumentDependency, InvalidationSet, InvocationId, InvocationKey, MutationInvocation, PlatformPrincipalId, QueryInvocation, QueryKey, RequestId, RevisionCheck, RevisionCheckResult, RuntimeDeploymentUnavailable, RuntimeInvocation, RuntimeInvocationRejected, RuntimeInvocationRejectionCode, RuntimeInvocationResult, RuntimeInvocationUnavailable, RuntimeMutationFailure, RuntimeMutationResult, RuntimeMutationSuccess, RuntimeQueryResult, RuntimeRequestNonce, RuntimeRevisionRejected, RuntimeTransportError, SubscriptionId, TableDependency, TableId, TeamId, canonicalInvocationInput, canonicalQueryKey, dependencyKey, documentDependency, mutationInvocationKey, tableDependency };\n\n//# sourceMappingURL=hosted.js.map","import { Context, Effect, Layer, Schema } from \"effect\";\nimport { IdAlphabet, IdLength } from \"@ignotum/contracts/runtime/id\";\nimport { customAlphabet } from \"nanoid\";\n//#region src/id.ts\nconst decodeGenerated = (definition, payload) => Schema.decodeSync(definition)(definition.idPrefix === void 0 ? payload : `${definition.idPrefix}_${payload}`);\nvar IdGenerator = class IdGenerator extends Context.Service()(\"@ignotum/shared/id/IdGenerator\") {\n\tstatic layer = Layer.sync(IdGenerator, () => {\n\t\tconst generatePayload = customAlphabet(IdAlphabet, IdLength);\n\t\treturn IdGenerator.of({ generate: (definition) => Effect.sync(() => decodeGenerated(definition, generatePayload())) });\n\t});\n\tstatic deterministic = (startAt = 1) => Layer.sync(IdGenerator, () => {\n\t\tconst counters = /* @__PURE__ */ new Map();\n\t\treturn IdGenerator.of({ generate: (definition) => Effect.sync(() => {\n\t\t\tconst counter = (counters.get(definition.idPrefix) ?? startAt - 1) + 1;\n\t\t\tcounters.set(definition.idPrefix, counter);\n\t\t\treturn decodeGenerated(definition, counter.toString(36).padStart(IdLength, \"0\"));\n\t\t}) });\n\t});\n};\n//#endregion\nexport { IdGenerator };\n\n//# sourceMappingURL=id.js.map","import { FunctionAddress } from \"./sync.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/functions.ts\nconst FunctionKind = Schema.Literals([\"Mutation\", \"Query\"]);\nvar UnknownFunction = class extends Schema.TaggedError()(\"UnknownFunction\", {\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar WrongFunctionKind = class extends Schema.TaggedError()(\"WrongFunctionKind\", {\n\tactual: FunctionKind,\n\texpected: FunctionKind,\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar InvalidArguments = class extends Schema.TaggedError()(\"InvalidArguments\", {\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\nvar FunctionUnavailable = class extends Schema.TaggedError()(\"FunctionUnavailable\", {\n\tcause: Schema.Defect(),\n\tfunction: FunctionAddress,\n\tmessage: Schema.String\n}) {};\n//#endregion\nexport { FunctionKind, FunctionUnavailable, InvalidArguments, UnknownFunction, WrongFunctionKind };\n\n//# sourceMappingURL=functions.js.map","import { FunctionAddress } from \"./runtime/sync.js\";\nimport { FunctionKind } from \"./runtime/functions.js\";\nimport { t as ValueDescriptor } from \"./descriptor-t6BOEGw9.js\";\nimport { Schema } from \"effect\";\n//#region src/deployment.ts\nconst ArtifactPath = Schema.String.check(Schema.isPattern(/^(?!\\/)(?![A-Za-z]:\\/)(?!.*(?:^|\\/)\\.\\.(?:\\/|$))(?!.*(?:^|\\/)\\.(?:\\/|$))(?!.*\\/\\/)[^\\\\\\0]+$/)).pipe(Schema.brand(\"ignotum/deployment/ArtifactPath\"));\nconst ClientPath = Schema.String.check(Schema.isPattern(/^\\/(?!_ignotum(?:\\/|$))(?:(?:[A-Za-z0-9._~-]+\\/)*[A-Za-z0-9._~-]+\\/?)?$/)).pipe(Schema.brand(\"ignotum/deployment/ClientPath\"));\nconst Sha256 = Schema.String.check(Schema.isPattern(/^[0-9a-f]{64}$/)).pipe(Schema.brand(\"ignotum/deployment/Sha256\"));\nconst ArtifactKind = Schema.Literals([\n\t\"ClientAsset\",\n\t\"ClientDocument\",\n\t\"ClientManifest\",\n\t\"ClientPublicFile\",\n\t\"ClientShell\",\n\t\"FunctionBundle\",\n\t\"ServerManifest\",\n\t\"SourceMap\",\n\t\"SchemaSnapshot\"\n]);\nconst ArtifactReference = Schema.Struct({\n\tpath: ArtifactPath,\n\tsize: Schema.Natural,\n\tsha256: Sha256\n});\nconst ArtifactFile = Schema.Struct({\n\tpath: ArtifactPath,\n\tsize: Schema.Natural,\n\tsha256: Sha256,\n\tkind: ArtifactKind,\n\tcontentType: Schema.String,\n\tcontentEncoding: Schema.optional(Schema.String)\n});\nconst ClientRoute = Schema.Struct({\n\tpathname: ClientPath,\n\tartifact: ArtifactReference\n});\nconst DeploymentInventory = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tfiles: Schema.Array(ArtifactFile)\n});\nconst ClientManifest = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tshell: ArtifactReference,\n\troutes: Schema.Array(ClientRoute)\n});\nconst ClientRoutingRoute = Schema.Struct({\n\tpathname: ClientPath,\n\tartifact: ArtifactPath\n});\nconst ClientRouting = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tshell: ArtifactPath,\n\troutes: Schema.Array(ClientRoutingRoute)\n});\nconst SchemaSnapshotField = Schema.Struct({\n\tname: Schema.String,\n\tvalue: ValueDescriptor\n});\nconst SchemaSnapshotTable = Schema.Struct({\n\tname: Schema.String,\n\tfields: Schema.Array(SchemaSnapshotField)\n});\nconst SchemaSnapshot = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\ttables: Schema.Array(SchemaSnapshotTable)\n});\nconst ServerFunctionArtifact = Schema.Struct({\n\taddress: FunctionAddress,\n\tkind: FunctionKind,\n\tbundle: ArtifactReference,\n\tsourceMap: ArtifactReference\n});\nconst ServerBuildManifest = Schema.Struct({\n\tformatVersion: Schema.Literal(1),\n\tschema: ArtifactReference,\n\tfunctions: Schema.Array(ServerFunctionArtifact)\n});\nconst deploymentInventoryPath = ArtifactPath.make(\"inventory.json\");\nconst clientManifestPath = ArtifactPath.make(\"client/manifest.json\");\nconst clientShellPath = ArtifactPath.make(\"client/shell.html\");\nconst clientAssetDirectory = ArtifactPath.make(\"client/assets\");\nconst clientAssetPathPrefix = `${clientAssetDirectory}/`;\nconst clientRouteDirectory = ArtifactPath.make(\"client/routes\");\nconst clientRoutePathPrefix = `${clientRouteDirectory}/`;\nconst clientPublicFileExtensions = [\n\t\".avif\",\n\t\".gif\",\n\t\".ico\",\n\t\".jpeg\",\n\t\".jpg\",\n\t\".pdf\",\n\t\".png\",\n\t\".webp\"\n];\nconst serverManifestPath = ArtifactPath.make(\"server/manifest.json\");\nconst schemaSnapshotPath = ArtifactPath.make(\"server/schema.json\");\nconst deploymentArtifactLimits = {\n\tfileBytes: 16777216,\n\tfileCount: 512,\n\tinventoryBytes: 1048576,\n\tserverBytes: 67108864,\n\ttotalBytes: 134217728\n};\n//#endregion\nexport { ArtifactFile, ArtifactKind, ArtifactPath, ArtifactReference, ClientManifest, ClientPath, ClientRoute, ClientRouting, ClientRoutingRoute, DeploymentInventory, SchemaSnapshot, SchemaSnapshotField, SchemaSnapshotTable, ServerBuildManifest, ServerFunctionArtifact, Sha256, clientAssetDirectory, clientAssetPathPrefix, clientManifestPath, clientPublicFileExtensions, clientRouteDirectory, clientRoutePathPrefix, clientShellPath, deploymentArtifactLimits, deploymentInventoryPath, schemaSnapshotPath, serverManifestPath };\n\n//# sourceMappingURL=deployment.js.map","import { AppId, DeploymentId, RuntimeRequestNonce } from \"./id.js\";\nimport { Sha256 } from \"../deployment.js\";\nimport { encodeCanonicalJson } from \"../json.js\";\nimport { RuntimeInvocationRejectionCode } from \"./hosted.js\";\nimport { Schema } from \"effect\";\n//#region src/runtime/transport.ts\nconst runtimeInvocationPath = \"/v1/invoke\";\nconst runtimeRevisionPath = \"/v1/revision\";\nconst ignotumPathPrefix = \"/_ignotum\";\nconst clientAssetUrlPrefix = `${ignotumPathPrefix}/assets/`;\nconst gatewayHealthPath = `${ignotumPathPrefix}/health`;\nconst appSyncPath = `${ignotumPathPrefix}/v1/sync`;\nconst RuntimeRequestPath = Schema.Literals([runtimeInvocationPath, runtimeRevisionPath]);\nconst RuntimeRequestTimestamp = Schema.FiniteFromString.pipe(Schema.check(Schema.isInt(), Schema.isGreaterThanOrEqualTo(0)), Schema.brand(\"ignotum/runtime/RequestTimestamp\"));\nconst RuntimeRequestSignature = Sha256.pipe(Schema.brand(\"ignotum/runtime/RequestSignature\"));\nconst RuntimeRequestHeaders = Schema.Struct({\n\tappId: AppId,\n\tdeploymentId: Schema.optional(DeploymentId),\n\tnonce: RuntimeRequestNonce,\n\ttimestamp: RuntimeRequestTimestamp,\n\tsignature: RuntimeRequestSignature\n});\nconst RuntimeSigningInput = Schema.Struct({\n\tmethod: Schema.Literal(\"POST\"),\n\tpath: RuntimeRequestPath,\n\ttimestamp: RuntimeRequestTimestamp,\n\tnonce: RuntimeRequestNonce,\n\tappId: AppId,\n\tdeploymentId: Schema.optional(DeploymentId),\n\tbodySha256: Sha256\n});\nconst runtimeRequestHeaderNames = {\n\tappId: \"x-ignotum-app-id\",\n\tdeploymentId: \"x-ignotum-deployment-id\",\n\tnonce: \"x-ignotum-nonce\",\n\tsignature: \"x-ignotum-signature\",\n\ttimestamp: \"x-ignotum-timestamp\"\n};\nconst appSyncRequestHeaderNames = {\n\tdeploymentId: \"x-ignotum-deployment-id\",\n\tgeneration: \"x-ignotum-deployment-generation\"\n};\nconst runtimeRequestMaxSkewMillis = 3e4;\nconst encodeRuntimeSigningInput = (input) => encodeCanonicalJson(input.deploymentId === void 0 ? {\n\tappId: input.appId,\n\tbodySha256: input.bodySha256,\n\tmethod: input.method,\n\tnonce: input.nonce,\n\tpath: input.path,\n\ttimestamp: input.timestamp\n} : {\n\tappId: input.appId,\n\tbodySha256: input.bodySha256,\n\tdeploymentId: input.deploymentId,\n\tmethod: input.method,\n\tnonce: input.nonce,\n\tpath: input.path,\n\ttimestamp: input.timestamp\n});\nconst RuntimeErrorCode = Schema.Literals([\n\t\"InvalidRequest\",\n\t\"InvalidSignature\",\n\t\"RequestExpired\",\n\t\"RequestReplay\",\n\t\"InvocationRejected\",\n\t\"RuntimeUnavailable\"\n]);\nconst RuntimeErrorResponse = Schema.Struct({\n\tcode: RuntimeErrorCode,\n\tmessage: Schema.String,\n\trejectionCode: Schema.optional(RuntimeInvocationRejectionCode)\n});\n//#endregion\nexport { RuntimeErrorCode, RuntimeErrorResponse, RuntimeRequestHeaders, RuntimeRequestNonce, RuntimeRequestPath, RuntimeRequestSignature, RuntimeRequestTimestamp, RuntimeSigningInput, appSyncPath, appSyncRequestHeaderNames, clientAssetUrlPrefix, encodeRuntimeSigningInput, gatewayHealthPath, ignotumPathPrefix, runtimeInvocationPath, runtimeRequestHeaderNames, runtimeRequestMaxSkewMillis, runtimeRevisionPath };\n\n//# sourceMappingURL=transport.js.map","import { appSyncPath } from \"@ignotum/contracts/runtime/transport\";\n\nexport const ignotumPathPrefix = \"/_ignotum\";\nexport const syncPath = appSyncPath;\n\nexport const isIgnotumPath = (pathname: string): boolean =>\n pathname === ignotumPathPrefix || pathname.startsWith(`${ignotumPathPrefix}/`);\n","import {\n Context,\n Deferred,\n Duration,\n Effect,\n Fiber,\n HashMap,\n Layer,\n ManagedRuntime,\n Schedule,\n Schema,\n} from \"effect\";\nimport * as Socket from \"effect/unstable/socket/Socket\";\nimport * as BrowserCrypto from \"@effect/platform-browser/BrowserCrypto\";\n\nimport { encodeCanonicalJson } from \"@ignotum/contracts/json\";\nimport { type AppStateRevision } from \"@ignotum/contracts/runtime/hosted\";\nimport { IdGenerator } from \"@ignotum/shared/id\";\n\nimport type {\n ErrorValue,\n QueryResult,\n Result as IgnotumResult,\n} from \"@ignotum/contracts/runtime/result\";\nimport { failureFromWire, pending, Result } from \"@ignotum/contracts/runtime/result\";\nimport {\n ClientMessageJson,\n DeploymentChangedCloseCode,\n InvocationId,\n ServerMessageJson,\n SubscriptionId,\n decodeTransportValue,\n type ClientMessage,\n type FunctionAddress,\n type ServerMessage,\n type SyncHandshake,\n type WireResult,\n} from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidServerMessage,\n ServerProtocolError,\n clientErrorReporterLayer,\n reportClientError,\n} from \"./errors.js\";\nimport { syncPath } from \"../internal/http-paths.js\";\n\ntype Listener = () => void;\ntype SocketWriter = (chunk: string) => Effect.Effect<void, Socket.SocketError>;\n\ninterface QueryEntry {\n readonly args: Schema.Json;\n readonly function: FunctionAddress;\n readonly listeners: Set<Listener>;\n readonly subscriptionId: SubscriptionId;\n generation: number;\n revision: AppStateRevision | undefined;\n references: number;\n result: QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n}\n\ninterface QueryObserver {\n readonly getSnapshot: () => QueryResult<unknown, ErrorValue> | ClientInfrastructureError;\n readonly release: Effect.Effect<void>;\n readonly subscribe: (listener: Listener) => () => void;\n}\n\ntype QueryLifecycleMessage = Extract<ClientMessage, { readonly type: \"Subscribe\" | \"Unsubscribe\" }>;\n\ninterface QueryCache {\n readonly entries: () => Iterable<QueryEntry>;\n readonly getById: (id: SubscriptionId) => QueryEntry | undefined;\n readonly setError: (id: SubscriptionId, error: ClientInfrastructureError) => void;\n readonly setResult: (\n id: SubscriptionId,\n result: QueryResult<unknown, ErrorValue>,\n revision: AppStateRevision,\n ) => void;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver>;\n}\n\nconst queryKey = (functionAddress: FunctionAddress, args: Schema.Json): string =>\n encodeCanonicalJson([functionAddress, args]);\n\nconst subscribeMessage = (entry: QueryEntry): QueryLifecycleMessage => ({\n type: \"Subscribe\",\n id: entry.subscriptionId,\n function: entry.function,\n args: entry.args,\n});\n\nconst makeQueryCache = (\n allocateId: Effect.Effect<SubscriptionId>,\n sendLifecycleMessage: (message: QueryLifecycleMessage) => Effect.Effect<void>,\n) => {\n const queries = new Map<string, QueryEntry>();\n const queryKeysById = new Map<SubscriptionId, string>();\n\n const observe = Effect.fn(\"SyncClient.QueryCache.observe\")(function* (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) {\n const key = queryKey(functionAddress, args);\n let entry = queries.get(key);\n\n if (entry === undefined) {\n const created: QueryEntry = {\n args,\n function: functionAddress,\n generation: 0,\n listeners: new Set(),\n revision: undefined,\n references: 0,\n result: pending(),\n subscriptionId: yield* allocateId,\n };\n queries.set(key, created);\n queryKeysById.set(created.subscriptionId, key);\n yield* sendLifecycleMessage(subscribeMessage(created));\n entry = created;\n }\n\n const observed = entry;\n observed.references += 1;\n observed.generation += 1;\n let released = false;\n return {\n getSnapshot: () => observed.result,\n subscribe: (listener: Listener) => {\n observed.listeners.add(listener);\n return () => observed.listeners.delete(listener);\n },\n release: Effect.gen(function* () {\n if (released) return;\n released = true;\n observed.references -= 1;\n if (observed.references !== 0) return;\n const generation = ++observed.generation;\n\n // Preact and HMR may release and reacquire an observer during one render handoff.\n // Keep the server subscription alive long enough for that handoff to reuse it.\n yield* Effect.sleep(\"25 millis\");\n if (\n observed.references !== 0 ||\n observed.generation !== generation ||\n queries.get(key) !== observed\n ) {\n return;\n }\n\n queries.delete(key);\n queryKeysById.delete(observed.subscriptionId);\n yield* sendLifecycleMessage({\n type: \"Unsubscribe\",\n id: observed.subscriptionId,\n });\n }),\n } satisfies QueryObserver;\n });\n\n return {\n entries: () => queries.values(),\n getById: (id: SubscriptionId) => {\n const key = queryKeysById.get(id);\n return key === undefined ? undefined : queries.get(key);\n },\n observe,\n setError: (id, error) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n entry.result = error;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n setResult: (id, result, revision) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\n if (entry.revision !== undefined && revision < entry.revision) {\n return;\n }\n entry.revision = revision;\n entry.result = result;\n for (const listener of entry.listeners) {\n listener();\n }\n },\n } satisfies QueryCache;\n};\n\nconst resultFromWire = Effect.fn(\"SyncClient.resultFromWire\")((wire: WireResult) =>\n Effect.succeed(\n wire.type === \"Success\"\n ? Result.succeed(\n wire.value === undefined ? undefined : decodeTransportValue(wire.value, wire.dates ?? []),\n )\n : failureFromWire(wire.error, wire.dates),\n ),\n);\n\nexport const shouldReloadForCloseCode = (code: number): boolean =>\n code === DeploymentChangedCloseCode;\n\nconst handshakesMatch = (first: SyncHandshake, next: SyncHandshake): boolean =>\n first.appId === next.appId &&\n first.deploymentId === next.deploymentId &&\n first.generation === next.generation;\n\ntype HandshakeDecision = \"Accept\" | \"Ignore\" | \"Reload\";\n\nconst handshakeDecision = (\n remembered: SyncHandshake | undefined,\n acceptedOnConnection: boolean,\n next: SyncHandshake,\n): HandshakeDecision => {\n if (remembered !== undefined && !handshakesMatch(remembered, next)) return \"Reload\";\n return acceptedOnConnection ? \"Ignore\" : \"Accept\";\n};\n\nexport const syncClientInternals = {\n makeQueryCache,\n handshakeDecision,\n queryIdentity: queryKey,\n resultFromWire,\n handshakesMatch,\n shouldReloadForCloseCode,\n};\n\nconst socketUrl = (): string => {\n const url = new URL(syncPath, globalThis.location.href);\n url.protocol = url.protocol === \"https:\" ? \"wss:\" : \"ws:\";\n return url.href;\n};\n\ninterface SyncClientService {\n readonly mutate: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<IgnotumResult<unknown, ErrorValue>, ClientInfrastructureError>;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver, ClientInfrastructureError>;\n}\n\ninterface PendingInvocation {\n readonly deferred: Deferred.Deferred<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >;\n readonly function: FunctionAddress;\n readonly message: Extract<ClientMessage, { readonly type: \"Invoke\" }>;\n}\n\nexport class SyncClient extends Context.Service<SyncClient, SyncClientService>()(\n \"ignotum/client/sync/SyncClient\",\n) {\n static readonly layer = Layer.effect(\n SyncClient,\n Effect.gen(function* () {\n const ids = yield* IdGenerator;\n let invocations = HashMap.empty<InvocationId, PendingInvocation>();\n let rememberedHandshake: SyncHandshake | undefined;\n let reloadRequested = false;\n let writer: SocketWriter | undefined;\n\n const encode = (message: ClientMessage) =>\n Schema.encodeEffect(ClientMessageJson)(message).pipe(\n Effect.mapError((cause) =>\n InvalidClientMessage.make({\n cause,\n message: \"Could not encode an Ignotum sync message.\",\n }),\n ),\n );\n\n const sendWith = (write: SocketWriter, message: ClientMessage) =>\n encode(message).pipe(\n Effect.flatMap(write),\n Effect.mapError((cause) =>\n Schema.is(InvalidClientMessage)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n );\n\n const send = (message: ClientMessage) =>\n writer === undefined\n ? Effect.fail(\n ConnectionUnavailable.make({ message: \"The sync connection is not ready.\" }),\n )\n : sendWith(writer, message);\n\n const queryCache = makeQueryCache(ids.generate(SubscriptionId), (message) =>\n writer === undefined\n ? Effect.void\n : send(message).pipe(\n Effect.catchTags({\n ConnectionUnavailable: reportClientError,\n InvalidClientMessage: reportClientError,\n }),\n ),\n );\n\n const rejectInvocation = (id: InvocationId, error: ClientInfrastructureError) => {\n const pendingInvocation = HashMap.getUnsafe(invocations, id);\n if (pendingInvocation === undefined) {\n return Effect.void;\n }\n invocations = HashMap.remove(invocations, id);\n return reportClientError(error).pipe(\n Effect.andThen(Deferred.fail(pendingInvocation.deferred, error)),\n Effect.asVoid,\n );\n };\n\n const handleMessage = Effect.fn(\"SyncClient.handleMessage\")(function* (\n message: Exclude<ServerMessage, SyncHandshake | { readonly type: \"DeploymentChanged\" }>,\n ) {\n switch (message.type) {\n case \"Snapshot\": {\n const entry = queryCache.getById(message.id);\n if (entry === undefined) return;\n yield* resultFromWire(message.result).pipe(\n Effect.tap((result) =>\n Effect.sync(() => queryCache.setResult(message.id, result, message.revision)),\n ),\n );\n return;\n }\n case \"Result\": {\n const pendingInvocation = HashMap.getUnsafe(invocations, message.id);\n if (pendingInvocation === undefined) return;\n invocations = HashMap.remove(invocations, message.id);\n yield* resultFromWire(message.result).pipe(\n Effect.flatMap((result) => Deferred.succeed(pendingInvocation.deferred, result)),\n );\n return;\n }\n case \"ProtocolError\": {\n const error =\n message.operation === undefined\n ? ServerProtocolError.make({\n code: message.code,\n message: message.message,\n })\n : ServerProtocolError.make({\n code: message.code,\n message: message.message,\n operation: message.operation,\n });\n if (message.operation?.type === \"Invocation\") {\n yield* rejectInvocation(message.operation.id, error);\n } else if (message.operation?.type === \"Subscription\") {\n queryCache.setError(message.operation.id, error);\n yield* reportClientError(error);\n } else {\n yield* reportClientError(error);\n }\n return;\n }\n }\n });\n\n const requestReload = () => {\n if (reloadRequested) return;\n reloadRequested = true;\n writer = undefined;\n globalThis.location.reload();\n };\n\n const disconnect = Effect.sync(() => {\n writer = undefined;\n });\n\n const connect = Effect.scoped(\n Effect.gen(function* () {\n if (reloadRequested) return yield* Effect.never;\n const socket = yield* Socket.makeWebSocket(socketUrl(), {\n closeCodeIsError: (code) => {\n if (shouldReloadForCloseCode(code)) requestReload();\n return false;\n },\n });\n const write = yield* socket.writer;\n const handshakeReceived = yield* Deferred.make<void>();\n let handshakeAccepted = false;\n const acceptHandshake = Effect.fn(\"SyncClient.acceptHandshake\")(function* (\n handshake: SyncHandshake,\n ) {\n const decision = handshakeDecision(rememberedHandshake, handshakeAccepted, handshake);\n if (decision === \"Reload\") {\n requestReload();\n return;\n }\n if (decision === \"Ignore\") return;\n rememberedHandshake = handshake;\n handshakeAccepted = true;\n writer = write;\n yield* Deferred.succeed(handshakeReceived, undefined);\n yield* Effect.gen(function* () {\n yield* Effect.forEach(queryCache.entries(), (entry) =>\n sendWith(write, subscribeMessage(entry)),\n );\n yield* Effect.forEach(HashMap.values(invocations), (pendingInvocation) =>\n sendWith(write, pendingInvocation.message),\n );\n }).pipe(Effect.tapError(reportClientError), Effect.ignore);\n });\n\n const handleText = Effect.fn(\"SyncClient.handleText\")(function* (text: string) {\n const message = yield* Schema.decodeEffect(ServerMessageJson)(text).pipe(\n Effect.mapError((cause) =>\n InvalidServerMessage.make({\n cause,\n message: \"The server returned an invalid sync message.\",\n }),\n ),\n );\n if (message.type === \"Handshake\") return yield* acceptHandshake(message);\n if (message.type === \"DeploymentChanged\") {\n requestReload();\n return;\n }\n if (!handshakeAccepted) {\n return yield* InvalidServerMessage.make({\n cause: new Error(\"The server sent a sync message before the handshake.\"),\n message: \"The server returned a sync message before the handshake.\",\n });\n }\n return yield* handleMessage(message);\n });\n\n const run = yield* socket.runString(handleText).pipe(Effect.forkChild);\n yield* Effect.raceFirst(\n Deferred.await(handshakeReceived).pipe(Effect.timeout(\"10 seconds\")),\n Fiber.join(run),\n );\n yield* Fiber.join(run);\n }),\n ).pipe(\n Effect.mapError((cause) =>\n Schema.is(ClientInfrastructureError)(cause)\n ? cause\n : ConnectionUnavailable.make({\n cause,\n message: \"The sync connection was lost.\",\n }),\n ),\n Effect.ensuring(disconnect),\n );\n\n const reconnectSchedule = Schedule.exponential(\"250 millis\").pipe(\n Schedule.modifyDelay(({ duration }) =>\n Effect.succeed(Duration.min(duration, Duration.seconds(5))),\n ),\n Schedule.jittered,\n );\n yield* connect.pipe(\n Effect.andThen(\n Effect.fail(\n ConnectionUnavailable.make({\n message: \"The sync connection closed; reconnecting.\",\n }),\n ),\n ),\n Effect.tapError(reportClientError),\n Effect.retry(reconnectSchedule),\n Effect.forkScoped,\n );\n\n const observe: SyncClientService[\"observe\"] = Effect.fn(\"SyncClient.observe\")(\n function* (functionAddress, args) {\n return yield* queryCache.observe(functionAddress, args);\n },\n );\n\n const mutate: SyncClientService[\"mutate\"] = Effect.fn(\"SyncClient.mutate\")(\n function* (functionAddress, args) {\n const invocationId = yield* ids.generate(InvocationId);\n const deferred = yield* Deferred.make<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >();\n const message: ClientMessage = {\n type: \"Invoke\",\n id: invocationId,\n kind: \"Mutation\",\n function: functionAddress,\n args,\n };\n invocations = HashMap.set(invocations, invocationId, {\n deferred,\n function: functionAddress,\n message,\n });\n if (writer !== undefined) {\n yield* sendWith(writer, message).pipe(\n Effect.catchTags({\n ConnectionUnavailable: reportClientError,\n InvalidClientMessage: (error) => rejectInvocation(invocationId, error),\n }),\n );\n }\n return yield* Deferred.await(deferred);\n },\n );\n\n return SyncClient.of({ mutate, observe });\n }),\n ).pipe(Layer.provide(Layer.merge(Socket.layerWebSocketConstructorGlobal, BrowserCrypto.layer)));\n}\n\nexport const syncRuntime = ManagedRuntime.make(\n SyncClient.layer.pipe(\n Layer.provideMerge(clientErrorReporterLayer),\n Layer.provideMerge(IdGenerator.layer),\n ),\n);\n\n// SAFETY: Vite adds this optional property to browser development modules.\nconst hot = (\n import.meta as ImportMeta & {\n readonly hot?: { readonly dispose: (cleanup: () => void) => void };\n }\n).hot;\nif (hot !== undefined) {\n hot.dispose(() => void syncRuntime.dispose());\n}\n","import { Effect, Schema } from \"effect\";\nimport { useDebugValue, useEffect, useMemo, useState } from \"preact/hooks\";\n\nimport { functionPathOf, type FunctionReference } from \"../internal/api.js\";\nimport { pending } from \"@ignotum/contracts/runtime/result\";\nimport type { ErrorValue, QueryResult, SettledResult } from \"@ignotum/contracts/runtime/result\";\nimport { encodeTransportObject } from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n InvalidMutationArguments,\n reportClientError,\n} from \"./errors.js\";\nimport { isQuerySkip, type QuerySkip } from \"./query.js\";\nimport { SyncClient, syncClientInternals, syncRuntime } from \"./sync.js\";\n\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks are not pipeable functions.\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n): QueryResult<Success, Failure>;\nexport function useQuery<Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", void, Success, Failure>,\n args: QuerySkip,\n): QueryResult<Success, Failure>;\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args, Success, Failure>,\n args: NoInfer<Args> | QuerySkip,\n): QueryResult<Success, Failure>;\n// @effect-diagnostics-next-line missingPipeableSignature:off React hooks must remain direct calls so hook order is statically visible.\nexport function useQuery<Args extends object, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Query\", Args | void, Success, Failure>,\n args?: Args | QuerySkip,\n): QueryResult<Success, Failure> {\n const functionPath = functionPathOf(reference);\n const skipped = isQuerySkip(args);\n const input = args === undefined || skipped ? {} : args;\n const jsonArgs = encodeTransportObject(input);\n const identity = skipped\n ? `skip:${functionPath}`\n : syncClientInternals.queryIdentity(functionPath, jsonArgs);\n const [state, setState] = useState<{\n readonly identity: string;\n readonly result: QueryResult<Success, Failure> | ClientInfrastructureError;\n }>(() => ({ identity, result: pending() }));\n\n useDebugValue({ args: input, function: functionPath, result: state.result });\n useEffect(() => {\n if (skipped) return;\n\n let active = true;\n let release: (() => void) | undefined;\n\n void syncRuntime\n .runPromise(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n return yield* client.observe(functionPath, jsonArgs);\n }),\n )\n .then(\n (observer) => {\n if (!active) {\n syncRuntime.runFork(observer.release);\n return;\n }\n const update = () => {\n // SAFETY: the function reference couples this subscription's runtime\n // path to its generated success and failure types.\n const result = observer.getSnapshot() as\n | QueryResult<Success, Failure>\n | ClientInfrastructureError;\n setState({ identity, result });\n };\n release = observer.subscribe(update);\n update();\n const releaseObserver = release;\n release = () => {\n releaseObserver();\n syncRuntime.runFork(observer.release);\n };\n },\n (error) => {\n if (active && Schema.is(ClientInfrastructureError)(error)) {\n setState({ identity, result: error });\n }\n },\n );\n\n return () => {\n active = false;\n release?.();\n };\n }, [identity]);\n\n if (skipped) return pending();\n\n if (state.identity !== identity) {\n return pending();\n }\n\n const result = state.result;\n if (Schema.is(ClientInfrastructureError)(result)) throw result;\n return result;\n}\n\ntype Mutation<Args, Success, Failure extends ErrorValue> = [Args] extends [void]\n ? () => Promise<SettledResult<Success, Failure>>\n : (args: Args) => Promise<SettledResult<Success, Failure>>;\n\nexport const useMutation = <Args extends object | void, Success, Failure extends ErrorValue>(\n reference: FunctionReference<\"Mutation\", Args, Success, Failure>,\n): Mutation<Args, Success, Failure> =>\n useMemo(() => {\n const mutate = (args: Args | undefined) => {\n const functionPath = functionPathOf(reference);\n const input = args === undefined ? {} : args;\n return syncRuntime.runPromise<SettledResult<Success, Failure>, ClientInfrastructureError>(\n Effect.gen(function* () {\n const client = yield* SyncClient;\n const jsonArgs = yield* Effect.try({\n try: () => encodeTransportObject(input),\n catch: (cause) =>\n InvalidMutationArguments.make({\n cause,\n function: functionPath,\n message: `Mutation arguments for ${functionPath} contain an unsupported value.`,\n }),\n }).pipe(Effect.tapError(reportClientError));\n // SAFETY: generated function references bind the runtime path to the\n // declared public result types validated by the server executor.\n // oxlint-disable-next-line anti-slop/no-chained-type-assertions -- The untyped sync transport deliberately erases the generated reference's result parameters.\n return (yield* client.mutate(functionPath, jsonArgs)) as unknown as SettledResult<\n Success,\n Failure\n >;\n }),\n );\n };\n // SAFETY: the builder gives argument-free functions Args = void. At runtime\n // both call shapes normalize omitted arguments to the empty JSON object.\n return mutate as Mutation<Args, Success, Failure>;\n }, [reference]);\n","import type { ComponentType } from \"preact\";\n\nexport interface AppDefinition<Component extends ComponentType<{}> = ComponentType<{}>> {\n readonly component: Component;\n readonly title: string;\n}\n\nexport const app = <Component extends ComponentType<{}>>(\n definition: AppDefinition<Component>,\n): AppDefinition<Component> => {\n if (definition.title.trim().length === 0) {\n throw new Error(\"The app title must contain a non-whitespace character.\");\n }\n return definition;\n};\n","import { Result as contractResult } from \"@ignotum/contracts/runtime/result\";\nimport type {\n ErrorValue,\n QueryResult as ContractQueryResult,\n SettledResult,\n} from \"@ignotum/contracts/runtime/result\";\n\nexport const Result = { match: contractResult.match };\nexport type Result<Value, Error extends ErrorValue> = SettledResult<Value, Error>;\nexport type QueryResult<Value, Error extends ErrorValue> = ContractQueryResult<Value, Error>;\nexport type { InternalServerError } from \"@ignotum/contracts/runtime/result\";\nexport { useMutation, useQuery } from \"./hooks.js\";\nexport { Query } from \"./query.js\";\nexport type { QuerySkip } from \"./query.js\";\nexport { app } from \"./app.js\";\nexport type { AppDefinition } from \"./app.js\";\n\nexport {\n Component,\n Fragment,\n cloneElement,\n createContext,\n createElement,\n createRef,\n h,\n isValidElement,\n toChildArray,\n} from \"preact\";\nexport type {\n AnyComponent,\n Attributes,\n ClassAttributes,\n ComponentChild,\n ComponentChildren,\n ComponentClass,\n ComponentConstructor,\n ComponentFactory,\n ComponentProps,\n ComponentType,\n Consumer,\n Context,\n ContextType,\n ErrorInfo,\n FunctionComponent,\n FunctionalComponent,\n JSX,\n Key,\n PreactContext,\n PreactConsumer,\n PreactDOMAttributes,\n PreactProvider,\n Provider,\n Ref,\n RefCallback,\n RefObject,\n RenderableProps,\n TargetedAnimationEvent,\n TargetedClipboardEvent,\n TargetedCommandEvent,\n TargetedCompositionEvent,\n TargetedDragEvent,\n TargetedEvent,\n TargetedFocusEvent,\n TargetedInputEvent,\n TargetedKeyboardEvent,\n TargetedMouseEvent,\n TargetedPictureInPictureEvent,\n TargetedPointerEvent,\n TargetedSnapEvent,\n TargetedSubmitEvent,\n TargetedToggleEvent,\n TargetedTouchEvent,\n TargetedTransitionEvent,\n TargetedUIEvent,\n TargetedWheelEvent,\n VNode,\n} from \"preact\";\nexport {\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useErrorBoundary,\n useId,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n} from \"preact/hooks\";\nexport type { Dispatch, Reducer, StateUpdater } from \"preact/hooks\";\n"],"mappings":";;;;;;;;;;;AAKA,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CACpF,yBACA;CACE,OAAO,OAAO,SAAS,OAAO,OAAO,CAAC;CACtC,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,OAAO,OAAO,OAAO;CACrB,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,IAAa,2BAAb,cAA8C,O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@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ignotum",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "Ignotum is an opinionated TypeScript application cloud.",
|
|
5
5
|
"author": "Johannes Schießl",
|
|
6
6
|
"repository": {
|
|
@@ -78,9 +78,9 @@
|
|
|
78
78
|
"@effect/platform-node": "4.0.0-rc.111",
|
|
79
79
|
"@effect/sql-sqlite-node": "4.0.0-rc.111",
|
|
80
80
|
"redis": "6.2.1",
|
|
81
|
-
"@ignotum/deployment": "1.0.0",
|
|
82
|
-
"@ignotum/runtime": "1.0.0",
|
|
83
81
|
"@ignotum/contracts": "1.0.0",
|
|
82
|
+
"@ignotum/runtime": "1.0.0",
|
|
83
|
+
"@ignotum/deployment": "1.0.0",
|
|
84
84
|
"@ignotum/shared": "1.0.0"
|
|
85
85
|
},
|
|
86
86
|
"engines": {
|
package/src/cli/build/client.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { Array, Effect, FileSystem, Path, String } from "effect";
|
|
2
2
|
import tailwindcss from "@tailwindcss/vite";
|
|
3
|
-
import {
|
|
3
|
+
import { ClientManifest, clientShellPath } from "@ignotum/contracts/deployment";
|
|
4
|
+
import { artifactReference, encodeCanonical, sha256, utf8Bytes } from "@ignotum/deployment";
|
|
4
5
|
|
|
5
6
|
import { resolveClientBuildConfig, validateClientFiles } from "../client-config.js";
|
|
6
7
|
import { loadClientEntryTitle } from "../client-entry.js";
|
|
7
8
|
import { clientEntryId, ignotumClientPlugin, renderClientDocument } from "../client-plugin.js";
|
|
8
9
|
import { moduleBoundariesPlugin } from "../module-boundaries.js";
|
|
9
10
|
import { InvalidBuildOutput, runViteBuild } from "./artifact.js";
|
|
11
|
+
import { copyPublicFiles } from "./public.js";
|
|
10
12
|
|
|
11
13
|
export interface ClientBuildResult {
|
|
12
14
|
readonly assets: number;
|
|
15
|
+
readonly manifestPath: string;
|
|
13
16
|
readonly shellPath: string;
|
|
14
17
|
}
|
|
15
18
|
|
|
@@ -36,9 +39,12 @@ export const buildClient = Effect.fn("Deploy.buildClient")(function* (
|
|
|
36
39
|
rolldownOptions: {
|
|
37
40
|
input: clientEntryId,
|
|
38
41
|
output: {
|
|
39
|
-
assetFileNames:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
assetFileNames: (asset) =>
|
|
43
|
+
asset.names.some((name) => name.endsWith(".css"))
|
|
44
|
+
? "assets/styles-[hash][extname]"
|
|
45
|
+
: "assets/[name]-[hash][extname]",
|
|
46
|
+
chunkFileNames: "assets/chunks/[name]-[hash].js",
|
|
47
|
+
entryFileNames: "assets/main-[hash].js",
|
|
42
48
|
},
|
|
43
49
|
},
|
|
44
50
|
sourcemap: false,
|
|
@@ -80,24 +86,34 @@ export const buildClient = Effect.fn("Deploy.buildClient")(function* (
|
|
|
80
86
|
if (clientFiles.iconPath !== undefined) {
|
|
81
87
|
const bytes = yield* fileSystem.readFile(clientFiles.iconPath);
|
|
82
88
|
const digest = yield* sha256(bytes);
|
|
83
|
-
const fileName = `icon-${digest}.svg`;
|
|
89
|
+
const fileName = `icon-${digest.slice(0, 16)}.svg`;
|
|
84
90
|
const assetsDirectory = path.join(outputDirectory, "assets");
|
|
85
91
|
yield* fileSystem.makeDirectory(assetsDirectory, { recursive: true });
|
|
86
92
|
yield* fileSystem.writeFile(path.join(assetsDirectory, fileName), bytes);
|
|
87
|
-
icon = `/assets/${fileName}`;
|
|
93
|
+
icon = `/_ignotum/assets/${fileName}`;
|
|
88
94
|
}
|
|
89
|
-
const shellPath = path.join(outputDirectory, "
|
|
95
|
+
const shellPath = path.join(outputDirectory, "shell.html");
|
|
90
96
|
const document = renderClientDocument({
|
|
91
97
|
icon,
|
|
92
|
-
scripts: [{ source: entryFile
|
|
93
|
-
styles,
|
|
98
|
+
scripts: [{ source: `_ignotum/${entryFile}`, type: "External" }],
|
|
99
|
+
styles: styles.map((style) => `_ignotum/${style}`),
|
|
94
100
|
title,
|
|
95
101
|
});
|
|
96
102
|
|
|
97
|
-
|
|
103
|
+
const shellBytes = utf8Bytes(document);
|
|
104
|
+
yield* fileSystem.writeFile(shellPath, shellBytes);
|
|
105
|
+
const publicBuild = yield* copyPublicFiles(appDirectory, outputDirectory);
|
|
106
|
+
const manifest = {
|
|
107
|
+
formatVersion: 1,
|
|
108
|
+
shell: yield* artifactReference(clientShellPath, shellBytes),
|
|
109
|
+
routes: publicBuild.routes,
|
|
110
|
+
} satisfies ClientManifest;
|
|
111
|
+
const manifestPath = path.join(outputDirectory, "manifest.json");
|
|
112
|
+
yield* fileSystem.writeFileString(manifestPath, `${encodeCanonical(ClientManifest, manifest)}\n`);
|
|
98
113
|
|
|
99
114
|
return {
|
|
100
|
-
assets: output.length + (icon === undefined ? 0 : 1),
|
|
115
|
+
assets: output.length + (icon === undefined ? 0 : 1) + publicBuild.files,
|
|
116
|
+
manifestPath,
|
|
101
117
|
shellPath,
|
|
102
118
|
} satisfies ClientBuildResult;
|
|
103
119
|
});
|