ignotum 0.0.0 → 0.0.2
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 +161 -0
- package/dist/cli/bin.d.mts +1 -0
- package/dist/cli/bin.mjs +1696 -0
- package/dist/cli/bin.mjs.map +1 -0
- package/dist/runtime/api-BXXIZc_Q.js +119 -0
- package/dist/runtime/api-BXXIZc_Q.js.map +1 -0
- package/dist/runtime/api-Cpx57mk3.d.ts +47 -0
- package/dist/runtime/client/jsx-dev-runtime.d.ts +2 -0
- package/dist/runtime/client/jsx-dev-runtime.js +2 -0
- package/dist/runtime/client/jsx-runtime.d.ts +2 -0
- package/dist/runtime/client/jsx-runtime.js +2 -0
- package/dist/runtime/client.d.ts +29 -0
- package/dist/runtime/client.js +364 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/index-BgWROoyk.d.ts +249 -0
- package/dist/runtime/internal/api.d.ts +2 -0
- package/dist/runtime/internal/api.js +2 -0
- package/dist/runtime/internal/server.d.ts +6 -0
- package/dist/runtime/internal/server.js +7 -0
- package/dist/runtime/internal/server.js.map +1 -0
- package/dist/runtime/internal/types.d.ts +2 -0
- package/dist/runtime/internal/types.js +2 -0
- package/dist/runtime/result-B2W-z2wG.js +136 -0
- package/dist/runtime/result-B2W-z2wG.js.map +1 -0
- package/dist/runtime/result-C1ZdsM6Y.d.ts +106 -0
- package/dist/runtime/schema-CNEVLF7D.js +116 -0
- package/dist/runtime/schema-CNEVLF7D.js.map +1 -0
- package/dist/runtime/server.d.ts +9 -0
- package/dist/runtime/server.js +9 -0
- package/dist/runtime/server.js.map +1 -0
- package/package.json +81 -2
- package/src/cli/agent-files.ts +35 -0
- package/src/cli/bin.ts +5 -0
- package/src/cli/client-plugin.ts +66 -0
- package/src/cli/codegen.ts +203 -0
- package/src/cli/command.ts +155 -0
- package/src/cli/dev.ts +206 -0
- package/src/cli/new-project.ts +377 -0
- package/src/cli/package-manager.ts +55 -0
- package/src/client/errors.ts +83 -0
- package/src/client/hooks.ts +141 -0
- package/src/client/index.ts +90 -0
- package/src/client/jsx-dev-runtime.ts +2 -0
- package/src/client/jsx-runtime.ts +2 -0
- package/src/client/query.ts +17 -0
- package/src/client/sync.ts +487 -0
- package/src/dev-runtime/database.ts +374 -0
- package/src/dev-runtime/dev-database.ts +199 -0
- package/src/dev-runtime/functions.ts +293 -0
- package/src/dev-runtime/id.ts +11 -0
- package/src/dev-runtime/sync.ts +473 -0
- package/src/internal/api.ts +141 -0
- package/src/internal/http-paths.ts +5 -0
- package/src/internal/server.ts +3 -0
- package/src/internal/types.ts +2 -0
- package/src/raw.d.ts +4 -0
- package/src/server/index.ts +8 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { a as Match, c as SettledResult, i as InternalServerError, o as QueryResult$1, r as ErrorValue } from "./result-C1ZdsM6Y.js";
|
|
2
|
+
import { n as FunctionReference } from "./api-Cpx57mk3.js";
|
|
3
|
+
import { Dispatch, Reducer, StateUpdater, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useReducer, useRef, useState } from "preact/hooks";
|
|
4
|
+
import { AnyComponent, Attributes, ClassAttributes, Component, ComponentChild, ComponentChildren, ComponentClass, ComponentConstructor, ComponentFactory, ComponentProps, ComponentType, Consumer, Context, ContextType, ErrorInfo, Fragment, FunctionComponent, FunctionalComponent, JSX, Key, PreactConsumer, PreactContext, PreactDOMAttributes, PreactProvider, Provider, Ref, RefCallback, RefObject, RenderableProps, TargetedAnimationEvent, TargetedClipboardEvent, TargetedCommandEvent, TargetedCompositionEvent, TargetedDragEvent, TargetedEvent, TargetedFocusEvent, TargetedInputEvent, TargetedKeyboardEvent, TargetedMouseEvent, TargetedPictureInPictureEvent, TargetedPointerEvent, TargetedSnapEvent, TargetedSubmitEvent, TargetedToggleEvent, TargetedTouchEvent, TargetedTransitionEvent, TargetedUIEvent, TargetedWheelEvent, VNode, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray } from "preact";
|
|
5
|
+
//#region src/client/query.d.ts
|
|
6
|
+
declare const QuerySkipTypeId: unique symbol;
|
|
7
|
+
interface QuerySkip {
|
|
8
|
+
readonly [QuerySkipTypeId]: typeof QuerySkipTypeId;
|
|
9
|
+
}
|
|
10
|
+
declare const Query: {
|
|
11
|
+
skip: QuerySkip;
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/client/hooks.d.ts
|
|
15
|
+
declare function useQuery<Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", void, Success, Failure>): QueryResult$1<Success, Failure>;
|
|
16
|
+
declare function useQuery<Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", void, Success, Failure>, args: QuerySkip): QueryResult$1<Success, Failure>;
|
|
17
|
+
declare function useQuery<Args extends object, Success, Failure extends ErrorValue>(reference: FunctionReference<"Query", Args, Success, Failure>, args: NoInfer<Args> | QuerySkip): QueryResult$1<Success, Failure>;
|
|
18
|
+
type Mutation<Args, Success, Failure extends ErrorValue> = [Args] extends [void] ? () => Promise<SettledResult<Success, Failure>> : (args: Args) => Promise<SettledResult<Success, Failure>>;
|
|
19
|
+
declare const useMutation: <Args extends object | void, Success, Failure extends ErrorValue>(reference: FunctionReference<"Mutation", Args, Success, Failure>) => Mutation<Args, Success, Failure>;
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/client/index.d.ts
|
|
22
|
+
declare const Result: {
|
|
23
|
+
match: Match;
|
|
24
|
+
};
|
|
25
|
+
type Result<Value, Error extends ErrorValue> = SettledResult<Value, Error>;
|
|
26
|
+
type QueryResult<Value, Error extends ErrorValue> = QueryResult$1<Value, Error>;
|
|
27
|
+
//#endregion
|
|
28
|
+
export { type AnyComponent, type Attributes, type ClassAttributes, Component, type ComponentChild, type ComponentChildren, type ComponentClass, type ComponentConstructor, type ComponentFactory, type ComponentProps, type ComponentType, type Consumer, type Context, type ContextType, type Dispatch, type ErrorInfo, Fragment, type FunctionComponent, type FunctionalComponent, type InternalServerError, type JSX, type Key, type PreactConsumer, type PreactContext, type PreactDOMAttributes, type PreactProvider, type Provider, Query, QueryResult, type QuerySkip, type Reducer, type Ref, type RefCallback, type RefObject, type RenderableProps, Result, type StateUpdater, type TargetedAnimationEvent, type TargetedClipboardEvent, type TargetedCommandEvent, type TargetedCompositionEvent, type TargetedDragEvent, type TargetedEvent, type TargetedFocusEvent, type TargetedInputEvent, type TargetedKeyboardEvent, type TargetedMouseEvent, type TargetedPictureInPictureEvent, type TargetedPointerEvent, type TargetedSnapEvent, type TargetedSubmitEvent, type TargetedToggleEvent, type TargetedTouchEvent, type TargetedTransitionEvent, type TargetedUIEvent, type TargetedWheelEvent, type VNode, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, useQuery, useReducer, useRef, useState };
|
|
29
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { a as decodeTransportValue, i as pending, n as Result$1, o as encodeTransportObject, r as failureFromWire } from "./result-B2W-z2wG.js";
|
|
2
|
+
import { a as Operation, c as ServerMessageJson, i as FunctionAddress, l as SubscriptionId, n as functionPathOf, o as ProtocolErrorCode, r as ClientMessageJson, s as RequestId } from "./api-BXXIZc_Q.js";
|
|
3
|
+
import { Cause, Context, Deferred, Duration, Effect, ErrorReporter, HashMap, Layer, ManagedRuntime, Predicate, Schedule, Schema } from "effect";
|
|
4
|
+
import { useCallback, useContext, useDebugValue, useDebugValue as useDebugValue$1, useEffect, useEffect as useEffect$1, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMemo as useMemo$1, useReducer, useRef, useState, useState as useState$1 } from "preact/hooks";
|
|
5
|
+
import * as Socket from "effect/unstable/socket/Socket";
|
|
6
|
+
import { Component, Fragment, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray } from "preact";
|
|
7
|
+
//#region src/client/errors.ts
|
|
8
|
+
/** @effect-diagnostics globalConsole:skip-file */
|
|
9
|
+
var ConnectionUnavailable = class extends Schema.TaggedError()("ConnectionUnavailable", {
|
|
10
|
+
cause: Schema.optional(Schema.Defect()),
|
|
11
|
+
message: Schema.String
|
|
12
|
+
}) {};
|
|
13
|
+
var InvalidClientMessage = class extends Schema.TaggedError()("InvalidClientMessage", {
|
|
14
|
+
cause: Schema.Defect(),
|
|
15
|
+
message: Schema.String
|
|
16
|
+
}) {};
|
|
17
|
+
var InvalidMutationArguments = class extends Schema.TaggedError()("InvalidMutationArguments", {
|
|
18
|
+
cause: Schema.Defect(),
|
|
19
|
+
function: FunctionAddress,
|
|
20
|
+
message: Schema.String
|
|
21
|
+
}) {};
|
|
22
|
+
var InvalidServerMessage = class extends Schema.TaggedError()("InvalidServerMessage", {
|
|
23
|
+
cause: Schema.Defect(),
|
|
24
|
+
message: Schema.String
|
|
25
|
+
}) {};
|
|
26
|
+
var ServerProtocolError = class extends Schema.TaggedError()("ServerProtocolError", {
|
|
27
|
+
code: ProtocolErrorCode,
|
|
28
|
+
message: Schema.String,
|
|
29
|
+
operation: Schema.optional(Operation)
|
|
30
|
+
}) {};
|
|
31
|
+
var MutationOutcomeUnknown = class extends Schema.TaggedError()("MutationOutcomeUnknown", {
|
|
32
|
+
cause: Schema.optional(Schema.Defect()),
|
|
33
|
+
function: FunctionAddress,
|
|
34
|
+
id: RequestId,
|
|
35
|
+
message: Schema.String
|
|
36
|
+
}) {};
|
|
37
|
+
const ClientInfrastructureError = Schema.Union([
|
|
38
|
+
ConnectionUnavailable,
|
|
39
|
+
InvalidClientMessage,
|
|
40
|
+
InvalidMutationArguments,
|
|
41
|
+
InvalidServerMessage,
|
|
42
|
+
ServerProtocolError,
|
|
43
|
+
MutationOutcomeUnknown
|
|
44
|
+
]);
|
|
45
|
+
const browserErrorReporter = ErrorReporter.make(({ attributes, error }) => {
|
|
46
|
+
globalThis.console.error("Ignotum infrastructure error", error, attributes);
|
|
47
|
+
});
|
|
48
|
+
const clientErrorReporterLayer = ErrorReporter.layer([browserErrorReporter]);
|
|
49
|
+
const reportClientError = Effect.fn("ClientErrorReporter.report")(function* (error) {
|
|
50
|
+
yield* ErrorReporter.report(Cause.fail(error));
|
|
51
|
+
});
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/client/query.ts
|
|
54
|
+
const QuerySkipTypeId = Symbol.for("ignotum/client/QuerySkip");
|
|
55
|
+
var QuerySkipToken = class {
|
|
56
|
+
[QuerySkipTypeId] = QuerySkipTypeId;
|
|
57
|
+
};
|
|
58
|
+
const skip = Object.freeze(new QuerySkipToken());
|
|
59
|
+
const Query = { skip };
|
|
60
|
+
const isQuerySkip = (value) => value === skip;
|
|
61
|
+
const syncPath = `/_ignotum/sync`;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/client/sync.ts
|
|
64
|
+
const canonicalJson = (value) => {
|
|
65
|
+
if (Predicate.isNull(value) || Predicate.isString(value) || Predicate.isNumber(value) || Predicate.isBoolean(value)) return JSON.stringify(value);
|
|
66
|
+
if (globalThis.Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
67
|
+
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`).join(",")}}`;
|
|
68
|
+
};
|
|
69
|
+
const queryKey = (functionAddress, args) => `${functionAddress}:${canonicalJson(args)}`;
|
|
70
|
+
const subscribeMessage = (entry) => ({
|
|
71
|
+
type: "Subscribe",
|
|
72
|
+
id: entry.subscriptionId,
|
|
73
|
+
function: entry.function,
|
|
74
|
+
args: entry.args
|
|
75
|
+
});
|
|
76
|
+
const makeQueryCache = (allocateId, sendLifecycleMessage) => {
|
|
77
|
+
const queries = /* @__PURE__ */ new Map();
|
|
78
|
+
const queryKeysById = /* @__PURE__ */ new Map();
|
|
79
|
+
return {
|
|
80
|
+
entries: () => queries.values(),
|
|
81
|
+
getById: (id) => {
|
|
82
|
+
const key = queryKeysById.get(id);
|
|
83
|
+
return key === void 0 ? void 0 : queries.get(key);
|
|
84
|
+
},
|
|
85
|
+
observe: Effect.fn("SyncClient.QueryCache.observe")(function* (functionAddress, args) {
|
|
86
|
+
const key = queryKey(functionAddress, args);
|
|
87
|
+
let entry = queries.get(key);
|
|
88
|
+
if (entry === void 0) {
|
|
89
|
+
const created = {
|
|
90
|
+
args,
|
|
91
|
+
function: functionAddress,
|
|
92
|
+
generation: 0,
|
|
93
|
+
listeners: /* @__PURE__ */ new Set(),
|
|
94
|
+
references: 0,
|
|
95
|
+
result: pending(),
|
|
96
|
+
subscriptionId: allocateId()
|
|
97
|
+
};
|
|
98
|
+
queries.set(key, created);
|
|
99
|
+
queryKeysById.set(created.subscriptionId, key);
|
|
100
|
+
yield* sendLifecycleMessage(subscribeMessage(created));
|
|
101
|
+
entry = created;
|
|
102
|
+
}
|
|
103
|
+
const observed = entry;
|
|
104
|
+
observed.references += 1;
|
|
105
|
+
observed.generation += 1;
|
|
106
|
+
let released = false;
|
|
107
|
+
return {
|
|
108
|
+
getSnapshot: () => observed.result,
|
|
109
|
+
subscribe: (listener) => {
|
|
110
|
+
observed.listeners.add(listener);
|
|
111
|
+
return () => observed.listeners.delete(listener);
|
|
112
|
+
},
|
|
113
|
+
release: Effect.gen(function* () {
|
|
114
|
+
if (released) return;
|
|
115
|
+
released = true;
|
|
116
|
+
observed.references -= 1;
|
|
117
|
+
if (observed.references !== 0) return;
|
|
118
|
+
const generation = ++observed.generation;
|
|
119
|
+
yield* Effect.sleep("25 millis");
|
|
120
|
+
if (observed.references !== 0 || observed.generation !== generation || queries.get(key) !== observed) return;
|
|
121
|
+
queries.delete(key);
|
|
122
|
+
queryKeysById.delete(observed.subscriptionId);
|
|
123
|
+
yield* sendLifecycleMessage({
|
|
124
|
+
type: "Unsubscribe",
|
|
125
|
+
id: observed.subscriptionId
|
|
126
|
+
});
|
|
127
|
+
})
|
|
128
|
+
};
|
|
129
|
+
}),
|
|
130
|
+
setError: (id, error) => {
|
|
131
|
+
const key = queryKeysById.get(id);
|
|
132
|
+
const entry = key === void 0 ? void 0 : queries.get(key);
|
|
133
|
+
if (entry === void 0) return;
|
|
134
|
+
entry.result = error;
|
|
135
|
+
for (const listener of entry.listeners) listener();
|
|
136
|
+
},
|
|
137
|
+
setResult: (id, result) => {
|
|
138
|
+
const key = queryKeysById.get(id);
|
|
139
|
+
const entry = key === void 0 ? void 0 : queries.get(key);
|
|
140
|
+
if (entry === void 0) return;
|
|
141
|
+
entry.result = result;
|
|
142
|
+
for (const listener of entry.listeners) listener();
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
const resultFromWire = Effect.fn("SyncClient.resultFromWire")((wire) => Effect.succeed(wire.type === "Success" ? Result$1.succeed(wire.value === void 0 ? void 0 : decodeTransportValue(wire.value, wire.dates ?? [])) : failureFromWire(wire.error, wire.dates)));
|
|
147
|
+
const syncClientInternals = {
|
|
148
|
+
makeQueryCache,
|
|
149
|
+
queryIdentity: queryKey,
|
|
150
|
+
resultFromWire
|
|
151
|
+
};
|
|
152
|
+
const socketUrl = () => {
|
|
153
|
+
const url = new URL(syncPath, globalThis.location.href);
|
|
154
|
+
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
155
|
+
return url.href;
|
|
156
|
+
};
|
|
157
|
+
var SyncClient = class SyncClient extends Context.Service()("ignotum/client/sync/SyncClient") {
|
|
158
|
+
static layer = Layer.effect(SyncClient, Effect.gen(function* () {
|
|
159
|
+
let nextOperationId = 0;
|
|
160
|
+
let mutations = HashMap.empty();
|
|
161
|
+
let writer;
|
|
162
|
+
const encode = (message) => Schema.encodeEffect(ClientMessageJson)(message).pipe(Effect.mapError((cause) => InvalidClientMessage.make({
|
|
163
|
+
cause,
|
|
164
|
+
message: "Could not encode an Ignotum sync message."
|
|
165
|
+
})));
|
|
166
|
+
const sendWith = (write, message) => encode(message).pipe(Effect.flatMap(write), Effect.mapError((cause) => Schema.is(InvalidClientMessage)(cause) ? cause : ConnectionUnavailable.make({
|
|
167
|
+
cause,
|
|
168
|
+
message: "The sync connection was lost."
|
|
169
|
+
})));
|
|
170
|
+
const send = (message) => writer === void 0 ? Effect.fail(ConnectionUnavailable.make({ message: "The sync connection is not ready." })) : sendWith(writer, message);
|
|
171
|
+
const queryCache = makeQueryCache(() => SubscriptionId.make(nextOperationId++), (message) => writer === void 0 ? Effect.void : send(message).pipe(Effect.catchTags({
|
|
172
|
+
ConnectionUnavailable: reportClientError,
|
|
173
|
+
InvalidClientMessage: reportClientError
|
|
174
|
+
})));
|
|
175
|
+
const rejectMutation = (requestId, error) => {
|
|
176
|
+
const pendingMutation = HashMap.getUnsafe(mutations, requestId);
|
|
177
|
+
if (pendingMutation === void 0) return Effect.void;
|
|
178
|
+
mutations = HashMap.remove(mutations, requestId);
|
|
179
|
+
return reportClientError(error).pipe(Effect.andThen(Deferred.fail(pendingMutation.deferred, error)), Effect.asVoid);
|
|
180
|
+
};
|
|
181
|
+
const handleMessage = Effect.fn("SyncClient.handleMessage")(function* (text) {
|
|
182
|
+
const message = yield* Schema.decodeEffect(ServerMessageJson)(text).pipe(Effect.mapError((cause) => InvalidServerMessage.make({
|
|
183
|
+
cause,
|
|
184
|
+
message: "The server returned an invalid sync message."
|
|
185
|
+
})));
|
|
186
|
+
switch (message.type) {
|
|
187
|
+
case "QuerySnapshot":
|
|
188
|
+
if (queryCache.getById(message.id) === void 0) return;
|
|
189
|
+
yield* resultFromWire(message.result).pipe(Effect.tap((result) => Effect.sync(() => queryCache.setResult(message.id, result))));
|
|
190
|
+
return;
|
|
191
|
+
case "MutationResult": {
|
|
192
|
+
const pendingMutation = HashMap.getUnsafe(mutations, message.id);
|
|
193
|
+
if (pendingMutation === void 0) return;
|
|
194
|
+
mutations = HashMap.remove(mutations, message.id);
|
|
195
|
+
yield* resultFromWire(message.result).pipe(Effect.flatMap((result) => Deferred.succeed(pendingMutation.deferred, result)));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
case "ProtocolError": {
|
|
199
|
+
const error = message.operation === void 0 ? ServerProtocolError.make({
|
|
200
|
+
code: message.code,
|
|
201
|
+
message: message.message
|
|
202
|
+
}) : ServerProtocolError.make({
|
|
203
|
+
code: message.code,
|
|
204
|
+
message: message.message,
|
|
205
|
+
operation: message.operation
|
|
206
|
+
});
|
|
207
|
+
if (message.operation?.type === "Mutate") yield* rejectMutation(message.operation.id, error);
|
|
208
|
+
else if (message.operation?.type === "Query") {
|
|
209
|
+
queryCache.setError(message.operation.id, error);
|
|
210
|
+
yield* reportClientError(error);
|
|
211
|
+
} else yield* reportClientError(error);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
const disconnect = Effect.gen(function* () {
|
|
217
|
+
writer = void 0;
|
|
218
|
+
const current = mutations;
|
|
219
|
+
mutations = HashMap.empty();
|
|
220
|
+
yield* Effect.forEach(HashMap.entries(current), ([id, pendingMutation]) => {
|
|
221
|
+
const error = MutationOutcomeUnknown.make({
|
|
222
|
+
function: pendingMutation.function,
|
|
223
|
+
id,
|
|
224
|
+
message: "The connection closed before the mutation outcome was known."
|
|
225
|
+
});
|
|
226
|
+
return reportClientError(error).pipe(Effect.andThen(Deferred.fail(pendingMutation.deferred, error)));
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
const connect = Effect.scoped(Effect.gen(function* () {
|
|
230
|
+
const socket = yield* Socket.makeWebSocket(socketUrl(), { closeCodeIsError: () => false });
|
|
231
|
+
const write = yield* socket.writer;
|
|
232
|
+
const onOpen = Effect.gen(function* () {
|
|
233
|
+
writer = write;
|
|
234
|
+
yield* Effect.forEach(queryCache.entries(), (entry) => sendWith(write, subscribeMessage(entry)));
|
|
235
|
+
}).pipe(Effect.tapError(reportClientError), Effect.ignore);
|
|
236
|
+
yield* socket.runString(handleMessage, { onOpen });
|
|
237
|
+
})).pipe(Effect.mapError((cause) => Schema.is(ClientInfrastructureError)(cause) ? cause : ConnectionUnavailable.make({
|
|
238
|
+
cause,
|
|
239
|
+
message: "The sync connection was lost."
|
|
240
|
+
})), Effect.ensuring(disconnect));
|
|
241
|
+
const reconnectSchedule = Schedule.exponential("250 millis").pipe(Schedule.modifyDelay(({ duration }) => Effect.succeed(Duration.min(duration, Duration.seconds(5)))), Schedule.jittered);
|
|
242
|
+
yield* connect.pipe(Effect.andThen(Effect.fail(ConnectionUnavailable.make({ message: "The sync connection closed; reconnecting." }))), Effect.tapError(reportClientError), Effect.retry(reconnectSchedule), Effect.forkScoped);
|
|
243
|
+
const observe = Effect.fn("SyncClient.observe")(function* (functionAddress, args) {
|
|
244
|
+
return yield* queryCache.observe(functionAddress, args);
|
|
245
|
+
});
|
|
246
|
+
const mutate = Effect.fn("SyncClient.mutate")(function* (functionAddress, args) {
|
|
247
|
+
const requestId = RequestId.make(nextOperationId++);
|
|
248
|
+
const deferred = yield* Deferred.make();
|
|
249
|
+
mutations = HashMap.set(mutations, requestId, {
|
|
250
|
+
deferred,
|
|
251
|
+
function: functionAddress
|
|
252
|
+
});
|
|
253
|
+
const message = {
|
|
254
|
+
type: "Mutate",
|
|
255
|
+
id: requestId,
|
|
256
|
+
function: functionAddress,
|
|
257
|
+
args
|
|
258
|
+
};
|
|
259
|
+
yield* Effect.gen(function* () {
|
|
260
|
+
const mutationWriter = writer;
|
|
261
|
+
if (mutationWriter === void 0) return yield* ConnectionUnavailable.make({ message: "The sync connection is not ready." });
|
|
262
|
+
return yield* sendWith(mutationWriter, message).pipe(Effect.mapError((error) => Schema.is(InvalidClientMessage)(error) ? error : MutationOutcomeUnknown.make({
|
|
263
|
+
cause: error,
|
|
264
|
+
function: functionAddress,
|
|
265
|
+
id: requestId,
|
|
266
|
+
message: "The connection failed while sending the mutation."
|
|
267
|
+
})));
|
|
268
|
+
}).pipe(Effect.tapError(reportClientError), Effect.tapError(() => Effect.sync(() => mutations = HashMap.remove(mutations, requestId))));
|
|
269
|
+
return yield* Deferred.await(deferred);
|
|
270
|
+
});
|
|
271
|
+
return SyncClient.of({
|
|
272
|
+
mutate,
|
|
273
|
+
observe
|
|
274
|
+
});
|
|
275
|
+
})).pipe(Layer.provide(Socket.layerWebSocketConstructorGlobal));
|
|
276
|
+
};
|
|
277
|
+
const syncRuntime = ManagedRuntime.make(SyncClient.layer.pipe(Layer.provideMerge(clientErrorReporterLayer)));
|
|
278
|
+
const hot = import.meta.hot;
|
|
279
|
+
if (hot !== void 0) hot.dispose(() => void syncRuntime.dispose());
|
|
280
|
+
//#endregion
|
|
281
|
+
//#region src/client/hooks.ts
|
|
282
|
+
function useQuery(reference, args) {
|
|
283
|
+
const functionPath = functionPathOf(reference);
|
|
284
|
+
const skipped = isQuerySkip(args);
|
|
285
|
+
const input = args === void 0 || skipped ? {} : args;
|
|
286
|
+
const jsonArgs = encodeTransportObject(input);
|
|
287
|
+
const identity = skipped ? `skip:${functionPath}` : syncClientInternals.queryIdentity(functionPath, jsonArgs);
|
|
288
|
+
const [state, setState] = useState$1(() => ({
|
|
289
|
+
identity,
|
|
290
|
+
result: pending()
|
|
291
|
+
}));
|
|
292
|
+
useDebugValue$1({
|
|
293
|
+
args: input,
|
|
294
|
+
function: functionPath,
|
|
295
|
+
result: state.result
|
|
296
|
+
});
|
|
297
|
+
useEffect$1(() => {
|
|
298
|
+
if (skipped) return;
|
|
299
|
+
let active = true;
|
|
300
|
+
let release;
|
|
301
|
+
syncRuntime.runPromise(Effect.gen(function* () {
|
|
302
|
+
return yield* (yield* SyncClient).observe(functionPath, jsonArgs);
|
|
303
|
+
})).then((observer) => {
|
|
304
|
+
if (!active) {
|
|
305
|
+
syncRuntime.runFork(observer.release);
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
const update = () => {
|
|
309
|
+
const result = observer.getSnapshot();
|
|
310
|
+
setState({
|
|
311
|
+
identity,
|
|
312
|
+
result
|
|
313
|
+
});
|
|
314
|
+
};
|
|
315
|
+
release = observer.subscribe(update);
|
|
316
|
+
update();
|
|
317
|
+
const releaseObserver = release;
|
|
318
|
+
release = () => {
|
|
319
|
+
releaseObserver();
|
|
320
|
+
syncRuntime.runFork(observer.release);
|
|
321
|
+
};
|
|
322
|
+
}, (error) => {
|
|
323
|
+
if (active && Schema.is(ClientInfrastructureError)(error)) setState({
|
|
324
|
+
identity,
|
|
325
|
+
result: error
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
return () => {
|
|
329
|
+
active = false;
|
|
330
|
+
release?.();
|
|
331
|
+
};
|
|
332
|
+
}, [identity]);
|
|
333
|
+
if (skipped) return pending();
|
|
334
|
+
if (state.identity !== identity) return pending();
|
|
335
|
+
const result = state.result;
|
|
336
|
+
if (Schema.is(ClientInfrastructureError)(result)) throw result;
|
|
337
|
+
return result;
|
|
338
|
+
}
|
|
339
|
+
const useMutation = (reference) => useMemo$1(() => {
|
|
340
|
+
const mutate = (args) => {
|
|
341
|
+
const functionPath = functionPathOf(reference);
|
|
342
|
+
const input = args === void 0 ? {} : args;
|
|
343
|
+
return syncRuntime.runPromise(Effect.gen(function* () {
|
|
344
|
+
const client = yield* SyncClient;
|
|
345
|
+
const jsonArgs = yield* Effect.try({
|
|
346
|
+
try: () => encodeTransportObject(input),
|
|
347
|
+
catch: (cause) => InvalidMutationArguments.make({
|
|
348
|
+
cause,
|
|
349
|
+
function: functionPath,
|
|
350
|
+
message: `Mutation arguments for ${functionPath} contain an unsupported value.`
|
|
351
|
+
})
|
|
352
|
+
}).pipe(Effect.tapError(reportClientError));
|
|
353
|
+
return yield* client.mutate(functionPath, jsonArgs);
|
|
354
|
+
}));
|
|
355
|
+
};
|
|
356
|
+
return mutate;
|
|
357
|
+
}, [reference]);
|
|
358
|
+
//#endregion
|
|
359
|
+
//#region src/client/index.ts
|
|
360
|
+
const Result = { match: Result$1.match };
|
|
361
|
+
//#endregion
|
|
362
|
+
export { Component, Fragment, Query, Result, cloneElement, createContext, createElement, createRef, h, isValidElement, toChildArray, useCallback, useContext, useDebugValue, useEffect, useErrorBoundary, useId, useImperativeHandle, useLayoutEffect, useMemo, useMutation, useQuery, useReducer, useRef, useState };
|
|
363
|
+
|
|
364
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":["Result","useState","useMemo","contractResult"],"sources":["../../src/client/errors.ts","../../src/client/query.ts","../../src/internal/http-paths.ts","../../src/client/sync.ts","../../src/client/hooks.ts","../../src/client/index.ts"],"sourcesContent":["/** @effect-diagnostics globalConsole:skip-file */\nimport { Cause, Effect, ErrorReporter, Schema } from \"effect\";\n\nimport {\n FunctionAddress,\n Operation,\n ProtocolErrorCode,\n RequestId,\n} 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 class MutationOutcomeUnknown extends Schema.TaggedError<MutationOutcomeUnknown>()(\n \"MutationOutcomeUnknown\",\n {\n cause: Schema.optional(Schema.Defect()),\n function: FunctionAddress,\n id: RequestId,\n message: Schema.String,\n },\n) {}\n\nexport const ClientInfrastructureError = Schema.Union([\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidMutationArguments,\n InvalidServerMessage,\n ServerProtocolError,\n MutationOutcomeUnknown,\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","export const ignotumPathPrefix = \"/_ignotum\";\nexport const syncPath = `${ignotumPathPrefix}/sync`;\n\nexport const isIgnotumPath = (pathname: string): boolean =>\n pathname === ignotumPathPrefix || pathname.startsWith(`${ignotumPathPrefix}/`);\n","import {\n Context,\n Deferred,\n Duration,\n Effect,\n HashMap,\n Layer,\n ManagedRuntime,\n Predicate,\n Schedule,\n Schema,\n} from \"effect\";\nimport * as Socket from \"effect/unstable/socket/Socket\";\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 RequestId,\n ServerMessageJson,\n SubscriptionId,\n decodeTransportValue,\n type ClientMessage,\n type FunctionAddress,\n type WireResult,\n} from \"@ignotum/contracts/runtime/sync\";\nimport {\n ClientInfrastructureError,\n ConnectionUnavailable,\n InvalidClientMessage,\n InvalidServerMessage,\n MutationOutcomeUnknown,\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 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: (id: SubscriptionId, result: QueryResult<unknown, ErrorValue>) => void;\n readonly observe: (\n functionAddress: FunctionAddress,\n args: Schema.Json,\n ) => Effect.Effect<QueryObserver>;\n}\n\nconst canonicalJson = (value: Schema.Json): string => {\n if (\n Predicate.isNull(value) ||\n Predicate.isString(value) ||\n Predicate.isNumber(value) ||\n Predicate.isBoolean(value)\n ) {\n return JSON.stringify(value);\n }\n if (globalThis.Array.isArray(value)) {\n return `[${value.map(canonicalJson).join(\",\")}]`;\n }\n\n return `{${Object.entries(value)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, child]) => `${JSON.stringify(key)}:${canonicalJson(child)}`)\n .join(\",\")}}`;\n};\n\nconst queryKey = (functionAddress: FunctionAddress, args: Schema.Json): string =>\n `${functionAddress}:${canonicalJson(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: () => 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 references: 0,\n result: pending(),\n subscriptionId: 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) => {\n const key = queryKeysById.get(id);\n const entry = key === undefined ? undefined : queries.get(key);\n if (entry === undefined) return;\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 syncClientInternals = { makeQueryCache, queryIdentity: queryKey, resultFromWire };\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 PendingMutation {\n readonly deferred: Deferred.Deferred<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >;\n readonly function: FunctionAddress;\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 let nextOperationId = 0;\n let mutations = HashMap.empty<RequestId, PendingMutation>();\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(\n () => SubscriptionId.make(nextOperationId++),\n (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 rejectMutation = (requestId: RequestId, error: ClientInfrastructureError) => {\n const pendingMutation = HashMap.getUnsafe(mutations, requestId);\n if (pendingMutation === undefined) {\n return Effect.void;\n }\n mutations = HashMap.remove(mutations, requestId);\n return reportClientError(error).pipe(\n Effect.andThen(Deferred.fail(pendingMutation.deferred, error)),\n Effect.asVoid,\n );\n };\n\n const handleMessage = Effect.fn(\"SyncClient.handleMessage\")(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\n switch (message.type) {\n case \"QuerySnapshot\": {\n const entry = queryCache.getById(message.id);\n if (entry === undefined) return;\n yield* resultFromWire(message.result).pipe(\n Effect.tap((result) => Effect.sync(() => queryCache.setResult(message.id, result))),\n );\n return;\n }\n case \"MutationResult\": {\n const pendingMutation = HashMap.getUnsafe(mutations, message.id);\n if (pendingMutation === undefined) return;\n mutations = HashMap.remove(mutations, message.id);\n yield* resultFromWire(message.result).pipe(\n Effect.flatMap((result) => Deferred.succeed(pendingMutation.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 === \"Mutate\") {\n yield* rejectMutation(message.operation.id, error);\n } else if (message.operation?.type === \"Query\") {\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 disconnect = Effect.gen(function* () {\n writer = undefined;\n const current = mutations;\n mutations = HashMap.empty();\n yield* Effect.forEach(HashMap.entries(current), ([id, pendingMutation]) => {\n const error = MutationOutcomeUnknown.make({\n function: pendingMutation.function,\n id,\n message: \"The connection closed before the mutation outcome was known.\",\n });\n return reportClientError(error).pipe(\n Effect.andThen(Deferred.fail(pendingMutation.deferred, error)),\n );\n });\n });\n\n const connect = Effect.scoped(\n Effect.gen(function* () {\n const socket = yield* Socket.makeWebSocket(socketUrl(), {\n closeCodeIsError: () => false,\n });\n const write = yield* socket.writer;\n const onOpen = Effect.gen(function* () {\n writer = write;\n yield* Effect.forEach(queryCache.entries(), (entry) =>\n sendWith(write, subscribeMessage(entry)),\n );\n }).pipe(Effect.tapError(reportClientError), Effect.ignore);\n\n yield* socket.runString(handleMessage, { onOpen });\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 requestId = RequestId.make(nextOperationId++);\n const deferred = yield* Deferred.make<\n IgnotumResult<unknown, ErrorValue>,\n ClientInfrastructureError\n >();\n mutations = HashMap.set(mutations, requestId, {\n deferred,\n function: functionAddress,\n });\n const message: ClientMessage = {\n type: \"Mutate\",\n id: requestId,\n function: functionAddress,\n args,\n };\n const sendMutation = Effect.gen(function* () {\n const mutationWriter = writer;\n if (mutationWriter === undefined) {\n return yield* ConnectionUnavailable.make({\n message: \"The sync connection is not ready.\",\n });\n }\n return yield* sendWith(mutationWriter, message).pipe(\n Effect.mapError((error) =>\n Schema.is(InvalidClientMessage)(error)\n ? error\n : MutationOutcomeUnknown.make({\n cause: error,\n function: functionAddress,\n id: requestId,\n message: \"The connection failed while sending the mutation.\",\n }),\n ),\n );\n });\n yield* sendMutation.pipe(\n Effect.tapError(reportClientError),\n Effect.tapError(() =>\n Effect.sync(() => (mutations = HashMap.remove(mutations, requestId))),\n ),\n );\n return yield* Deferred.await(deferred);\n },\n );\n\n return SyncClient.of({ mutate, observe });\n }),\n ).pipe(Layer.provide(Socket.layerWebSocketConstructorGlobal));\n}\n\nexport const syncRuntime = ManagedRuntime.make(\n SyncClient.layer.pipe(Layer.provideMerge(clientErrorReporterLayer)),\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 { 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\";\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":";;;;;;;;AAUA,IAAa,wBAAb,cAA2C,OAAO,YAAmC,CAAC,CACpF,yBACA;CACE,OAAO,OAAO,SAAS,OAAO,OAAO,CAAC;CACtC,SAAS,OAAO;AAClB,CACF,CAAC,CA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