@voidhash/mimic-effect 1.0.0-beta.7 → 1.0.0-beta.8
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/.turbo/turbo-build.log +94 -94
- package/dist/DocumentInstance.cjs +255 -0
- package/dist/DocumentInstance.d.cts +74 -0
- package/dist/DocumentInstance.d.cts.map +1 -0
- package/dist/DocumentInstance.d.mts +74 -0
- package/dist/DocumentInstance.d.mts.map +1 -0
- package/dist/DocumentInstance.mjs +256 -0
- package/dist/DocumentInstance.mjs.map +1 -0
- package/dist/MimicClusterServerEngine.cjs +19 -203
- package/dist/MimicClusterServerEngine.d.cts.map +1 -1
- package/dist/MimicClusterServerEngine.d.mts.map +1 -1
- package/dist/MimicClusterServerEngine.mjs +24 -208
- package/dist/MimicClusterServerEngine.mjs.map +1 -1
- package/dist/MimicServerEngine.cjs +72 -10
- package/dist/MimicServerEngine.d.cts +12 -7
- package/dist/MimicServerEngine.d.cts.map +1 -1
- package/dist/MimicServerEngine.d.mts +12 -7
- package/dist/MimicServerEngine.d.mts.map +1 -1
- package/dist/MimicServerEngine.mjs +74 -12
- package/dist/MimicServerEngine.mjs.map +1 -1
- package/dist/Protocol.d.cts +1 -1
- package/dist/Protocol.d.mts +1 -1
- package/dist/index.cjs +2 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
- package/src/DocumentInstance.ts +510 -0
- package/src/MimicClusterServerEngine.ts +40 -357
- package/src/MimicServerEngine.ts +172 -36
- package/src/index.ts +3 -4
- package/tests/DocumentInstance.test.ts +669 -0
- package/dist/DocumentManager.cjs +0 -299
- package/dist/DocumentManager.d.cts +0 -67
- package/dist/DocumentManager.d.cts.map +0 -1
- package/dist/DocumentManager.d.mts +0 -67
- package/dist/DocumentManager.d.mts.map +0 -1
- package/dist/DocumentManager.mjs +0 -297
- package/dist/DocumentManager.mjs.map +0 -1
- package/src/DocumentManager.ts +0 -616
- package/tests/DocumentManager.test.ts +0 -335
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { MimicServerEngineConfig, PresenceEntry, PresenceEvent, PresenceSnapshot, ResolvedConfig } from "./Types.mjs";
|
|
2
|
+
import { ColdStorageError, HotStorageError } from "./Errors.mjs";
|
|
2
3
|
import { ServerMessage } from "./Protocol.mjs";
|
|
3
4
|
import { ColdStorageTag } from "./ColdStorage.mjs";
|
|
4
5
|
import { HotStorageTag } from "./HotStorage.mjs";
|
|
5
6
|
import { MimicAuthServiceTag } from "./MimicAuthService.mjs";
|
|
6
|
-
import {
|
|
7
|
+
import { SubmitResult } from "./DocumentInstance.mjs";
|
|
7
8
|
import { Context, Effect, Layer, Scope, Stream } from "effect";
|
|
8
9
|
import { Primitive, Transaction } from "@voidhash/mimic";
|
|
9
10
|
|
|
10
11
|
//#region src/MimicServerEngine.d.ts
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Error type for MimicServerEngine operations
|
|
15
|
+
*/
|
|
16
|
+
type MimicServerEngineError = ColdStorageError | HotStorageError;
|
|
12
17
|
/**
|
|
13
18
|
* MimicServerEngine service interface.
|
|
14
19
|
*
|
|
@@ -19,24 +24,24 @@ interface MimicServerEngine {
|
|
|
19
24
|
/**
|
|
20
25
|
* Submit a transaction to a document.
|
|
21
26
|
* Authorization is checked against the auth service.
|
|
22
|
-
* May fail with
|
|
27
|
+
* May fail with MimicServerEngineError if storage is unavailable.
|
|
23
28
|
*/
|
|
24
|
-
readonly submit: (documentId: string, transaction: Transaction.Transaction) => Effect.Effect<SubmitResult,
|
|
29
|
+
readonly submit: (documentId: string, transaction: Transaction.Transaction) => Effect.Effect<SubmitResult, MimicServerEngineError>;
|
|
25
30
|
/**
|
|
26
31
|
* Get document snapshot (current state and version).
|
|
27
|
-
* May fail with
|
|
32
|
+
* May fail with MimicServerEngineError if storage is unavailable.
|
|
28
33
|
*/
|
|
29
34
|
readonly getSnapshot: (documentId: string) => Effect.Effect<{
|
|
30
35
|
state: unknown;
|
|
31
36
|
version: number;
|
|
32
|
-
},
|
|
37
|
+
}, MimicServerEngineError>;
|
|
33
38
|
/**
|
|
34
39
|
* Subscribe to document broadcasts (transactions).
|
|
35
40
|
* Returns a stream of server messages.
|
|
36
41
|
* Requires a Scope for cleanup when the subscription ends.
|
|
37
|
-
* May fail with
|
|
42
|
+
* May fail with MimicServerEngineError if storage is unavailable.
|
|
38
43
|
*/
|
|
39
|
-
readonly subscribe: (documentId: string) => Effect.Effect<Stream.Stream<ServerMessage, never, never>,
|
|
44
|
+
readonly subscribe: (documentId: string) => Effect.Effect<Stream.Stream<ServerMessage, never, never>, MimicServerEngineError, Scope.Scope>;
|
|
40
45
|
/**
|
|
41
46
|
* Touch document to prevent idle garbage collection.
|
|
42
47
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimicServerEngine.d.mts","names":[],"sources":["../src/MimicServerEngine.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MimicServerEngine.d.mts","names":[],"sources":["../src/MimicServerEngine.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;AA0FqB,KAvCT,sBAAA,GAAyB,gBAuCT,GAvC4B,eAuC5B;;;;;;;AAoBjB,UA/CM,iBAAA,CA+CN;EACJ;;;;;EAgBA,SAAO,MAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,WAAA,EAxDG,WAAA,CAAY,WAwDf,EAAA,GAvDP,MAAA,CAAO,MAuDA,CAvDO,YAuDP,EAvDqB,sBAuDrB,CAAA;EAMoB;;;AACjC;gDAtDM,MAAA,CAAO;;;KAA4C;EA+D7C;AAmQb;;;;;EA7KE,SAAA,SAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GA3IK,MAAA,CAAO,MA2IZ,CA3ImB,MAAA,CAAO,MA2I1B,CA3IiC,aA2IjC,EAAA,KAAA,EAAA,KAAA,CAAA,EA3IwE,sBA2IxE,EA3IgG,KAAA,CAAM,KA2ItG,CAAA;EAEA;;;EAHC,SAAM,KAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GArIiC,MAAA,CAAO,MAqIxC,CAAA,IAAA,EAAA,KAAA,CAAA;EAAK;;;wDA9HP,MAAA,CAAO,OAAO;;;;0EAQV,kBACJ,MAAA,CAAO;;;;yEAQP,MAAA,CAAO;;;;;sDAQP,MAAA,CAAO,OAAO,MAAA,CAAO,OAAO,qCAAqC,KAAA,CAAM;;;;;mBAM3D,eAAe,SAAA,CAAU;;cAC3C;;;;cASY,oBAAA,SAA6B,yBAAA;cAmQ7B;;yBAhLwB,SAAA,CAAU,sBACrC,wBAAwB,aAC/B,KAAA,CAAM,MACP,6BAEA,iBAAiB,gBAAgB"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ColdStorageTag } from "./ColdStorage.mjs";
|
|
2
|
+
import { HotStorageTag } from "./HotStorage.mjs";
|
|
3
|
+
import { documentsActive, documentsEvicted } from "./Metrics.mjs";
|
|
4
|
+
import { DocumentInstance } from "./DocumentInstance.mjs";
|
|
5
|
+
import { PresenceManagerTag, layer } from "./PresenceManager.mjs";
|
|
6
|
+
import { Context, Duration, Effect, HashMap, Layer, Metric, Ref, Schedule, Stream } from "effect";
|
|
4
7
|
|
|
5
8
|
//#region src/MimicServerEngine.ts
|
|
6
9
|
/**
|
|
@@ -69,23 +72,82 @@ const resolveConfig = (config) => {
|
|
|
69
72
|
*/
|
|
70
73
|
const make = (config) => {
|
|
71
74
|
const resolvedConfig = resolveConfig(config);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const documentManager = yield* DocumentManagerTag;
|
|
75
|
+
return Layer.scoped(MimicServerEngineTag, Effect.gen(function* () {
|
|
76
|
+
const coldStorage = yield* ColdStorageTag;
|
|
77
|
+
const hotStorage = yield* HotStorageTag;
|
|
76
78
|
const presenceManager = yield* PresenceManagerTag;
|
|
79
|
+
const store = yield* Ref.make(HashMap.empty());
|
|
80
|
+
/**
|
|
81
|
+
* Get or create a document instance
|
|
82
|
+
*/
|
|
83
|
+
const getOrCreateDocument = Effect.fn("engine.document.get-or-create")(function* (documentId) {
|
|
84
|
+
const current = yield* Ref.get(store);
|
|
85
|
+
const existing = HashMap.get(current, documentId);
|
|
86
|
+
if (existing._tag === "Some") {
|
|
87
|
+
yield* Ref.set(existing.value.lastActivityTime, Date.now());
|
|
88
|
+
return existing.value.instance;
|
|
89
|
+
}
|
|
90
|
+
const instance = yield* DocumentInstance.make(documentId, {
|
|
91
|
+
schema: config.schema,
|
|
92
|
+
initial: config.initial,
|
|
93
|
+
maxTransactionHistory: resolvedConfig.maxTransactionHistory,
|
|
94
|
+
snapshot: resolvedConfig.snapshot
|
|
95
|
+
}, coldStorage, hotStorage);
|
|
96
|
+
const lastActivityTime = yield* Ref.make(Date.now());
|
|
97
|
+
yield* Ref.update(store, (map) => HashMap.set(map, documentId, {
|
|
98
|
+
instance,
|
|
99
|
+
lastActivityTime
|
|
100
|
+
}));
|
|
101
|
+
return instance;
|
|
102
|
+
});
|
|
103
|
+
yield* Effect.fn("engine.gc.start")(function* () {
|
|
104
|
+
yield* Effect.fn("engine.gc.loop")(function* () {
|
|
105
|
+
const current = yield* Ref.get(store);
|
|
106
|
+
const now = Date.now();
|
|
107
|
+
const maxIdleMs = Duration.toMillis(resolvedConfig.maxIdleTime);
|
|
108
|
+
for (const [documentId, entry] of current) if (now - (yield* Ref.get(entry.lastActivityTime)) >= maxIdleMs) {
|
|
109
|
+
yield* Effect.catchAll(entry.instance.saveSnapshot(), (e) => Effect.logError("Failed to save snapshot during eviction", {
|
|
110
|
+
documentId,
|
|
111
|
+
error: e
|
|
112
|
+
}));
|
|
113
|
+
yield* Ref.update(store, (map) => HashMap.remove(map, documentId));
|
|
114
|
+
yield* Metric.increment(documentsEvicted);
|
|
115
|
+
yield* Metric.incrementBy(documentsActive, -1);
|
|
116
|
+
yield* Effect.logInfo("Document evicted due to idle timeout", { documentId });
|
|
117
|
+
}
|
|
118
|
+
})().pipe(Effect.repeat(Schedule.spaced("1 minute")), Effect.fork);
|
|
119
|
+
})();
|
|
120
|
+
yield* Effect.addFinalizer(() => Effect.fn("engine.shutdown")(function* () {
|
|
121
|
+
const current = yield* Ref.get(store);
|
|
122
|
+
for (const [documentId, entry] of current) yield* Effect.catchAll(entry.instance.saveSnapshot(), (e) => Effect.logError("Failed to save snapshot during shutdown", {
|
|
123
|
+
documentId,
|
|
124
|
+
error: e
|
|
125
|
+
}));
|
|
126
|
+
yield* Effect.logInfo("MimicServerEngine shutdown complete");
|
|
127
|
+
})());
|
|
77
128
|
return {
|
|
78
|
-
submit: (documentId, transaction) =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
129
|
+
submit: (documentId, transaction) => Effect.gen(function* () {
|
|
130
|
+
return yield* (yield* getOrCreateDocument(documentId)).submit(transaction);
|
|
131
|
+
}),
|
|
132
|
+
getSnapshot: (documentId) => Effect.gen(function* () {
|
|
133
|
+
return (yield* getOrCreateDocument(documentId)).getSnapshot();
|
|
134
|
+
}),
|
|
135
|
+
subscribe: (documentId) => Effect.gen(function* () {
|
|
136
|
+
const instance = yield* getOrCreateDocument(documentId);
|
|
137
|
+
return Stream.fromPubSub(instance.pubsub);
|
|
138
|
+
}),
|
|
139
|
+
touch: (documentId) => Effect.gen(function* () {
|
|
140
|
+
const current = yield* Ref.get(store);
|
|
141
|
+
const existing = HashMap.get(current, documentId);
|
|
142
|
+
if (existing._tag === "Some") yield* Ref.set(existing.value.lastActivityTime, Date.now());
|
|
143
|
+
}),
|
|
82
144
|
getPresenceSnapshot: (documentId) => presenceManager.getSnapshot(documentId),
|
|
83
145
|
setPresence: (documentId, connectionId, entry) => presenceManager.set(documentId, connectionId, entry),
|
|
84
146
|
removePresence: (documentId, connectionId) => presenceManager.remove(documentId, connectionId),
|
|
85
147
|
subscribePresence: (documentId) => presenceManager.subscribe(documentId),
|
|
86
148
|
config: resolvedConfig
|
|
87
149
|
};
|
|
88
|
-
})
|
|
150
|
+
})).pipe(Layer.provide(layer));
|
|
89
151
|
};
|
|
90
152
|
const MimicServerEngine = {
|
|
91
153
|
Tag: MimicServerEngineTag,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimicServerEngine.mjs","names":["documentManagerLayer","presenceManagerLayer"],"sources":["../src/MimicServerEngine.ts"],"sourcesContent":["/**\n * @voidhash/mimic-effect - MimicServerEngine\n *\n * Core document management service for Mimic real-time collaboration.\n * Handles document lifecycle, storage, presence, and transaction processing.\n *\n * This is the engine layer - for WebSocket routes, use MimicServer.layerHttpLayerRouter().\n */\nimport {\n Context,\n Duration,\n Effect,\n Layer,\n Scope,\n Stream,\n} from \"effect\";\nimport type { Presence, Primitive, Transaction } from \"@voidhash/mimic\";\nimport type {\n MimicServerEngineConfig,\n PresenceEntry,\n PresenceEvent,\n PresenceSnapshot,\n ResolvedConfig,\n} from \"./Types\";\nimport type * as Protocol from \"./Protocol\";\nimport { ColdStorageTag } from \"./ColdStorage\";\nimport { HotStorageTag } from \"./HotStorage\";\nimport { MimicAuthServiceTag } from \"./MimicAuthService\";\nimport {\n DocumentManagerTag,\n DocumentManagerConfigTag,\n layer as documentManagerLayer,\n type SubmitResult,\n type DocumentManagerError,\n} from \"./DocumentManager\";\nimport {\n PresenceManagerTag,\n layer as presenceManagerLayer,\n} from \"./PresenceManager\";\n\n// =============================================================================\n// MimicServerEngine Interface\n// =============================================================================\n\n/**\n * MimicServerEngine service interface.\n *\n * Provides document management operations for Mimic collaboration.\n * Use MimicServer.layerHttpLayerRouter() to create WebSocket routes.\n */\nexport interface MimicServerEngine {\n /**\n * Submit a transaction to a document.\n * Authorization is checked against the auth service.\n * May fail with DocumentManagerError if storage is unavailable.\n */\n readonly submit: (\n documentId: string,\n transaction: Transaction.Transaction\n ) => Effect.Effect<SubmitResult, DocumentManagerError>;\n\n /**\n * Get document snapshot (current state and version).\n * May fail with DocumentManagerError if storage is unavailable.\n */\n readonly getSnapshot: (\n documentId: string\n ) => Effect.Effect<{ state: unknown; version: number }, DocumentManagerError>;\n\n /**\n * Subscribe to document broadcasts (transactions).\n * Returns a stream of server messages.\n * Requires a Scope for cleanup when the subscription ends.\n * May fail with DocumentManagerError if storage is unavailable.\n */\n readonly subscribe: (\n documentId: string\n ) => Effect.Effect<Stream.Stream<Protocol.ServerMessage, never, never>, DocumentManagerError, Scope.Scope>;\n\n /**\n * Touch document to prevent idle garbage collection.\n */\n readonly touch: (documentId: string) => Effect.Effect<void, never>;\n\n /**\n * Get presence snapshot for a document.\n */\n readonly getPresenceSnapshot: (\n documentId: string\n ) => Effect.Effect<PresenceSnapshot, never>;\n\n /**\n * Set presence for a connection.\n */\n readonly setPresence: (\n documentId: string,\n connectionId: string,\n entry: PresenceEntry\n ) => Effect.Effect<void, never>;\n\n /**\n * Remove presence for a connection.\n */\n readonly removePresence: (\n documentId: string,\n connectionId: string\n ) => Effect.Effect<void, never>;\n\n /**\n * Subscribe to presence events for a document.\n * Requires a Scope for cleanup when the subscription ends.\n */\n readonly subscribePresence: (\n documentId: string\n ) => Effect.Effect<Stream.Stream<PresenceEvent, never, never>, never, Scope.Scope>;\n\n /**\n * Resolved engine configuration.\n * Used by route layer to access schema, presence config, etc.\n */\n readonly config: ResolvedConfig<Primitive.AnyPrimitive>;\n}\n\n// =============================================================================\n// Context Tag\n// =============================================================================\n\n/**\n * Context tag for MimicServerEngine\n */\nexport class MimicServerEngineTag extends Context.Tag(\n \"@voidhash/mimic-effect/MimicServerEngine\"\n)<MimicServerEngineTag, MimicServerEngine>() {}\n\n// =============================================================================\n// Default Configuration\n// =============================================================================\n\nconst DEFAULT_MAX_IDLE_TIME = Duration.minutes(5);\nconst DEFAULT_MAX_TRANSACTION_HISTORY = 1000;\nconst DEFAULT_SNAPSHOT_INTERVAL = Duration.minutes(5);\nconst DEFAULT_SNAPSHOT_THRESHOLD = 100;\n\n/**\n * Resolve configuration with defaults\n */\nconst resolveConfig = <TSchema extends Primitive.AnyPrimitive>(\n config: MimicServerEngineConfig<TSchema>\n): ResolvedConfig<TSchema> => ({\n schema: config.schema,\n initial: config.initial,\n presence: config.presence,\n maxIdleTime: config.maxIdleTime\n ? Duration.decode(config.maxIdleTime)\n : DEFAULT_MAX_IDLE_TIME,\n maxTransactionHistory:\n config.maxTransactionHistory ?? DEFAULT_MAX_TRANSACTION_HISTORY,\n snapshot: {\n interval: config.snapshot?.interval\n ? Duration.decode(config.snapshot.interval)\n : DEFAULT_SNAPSHOT_INTERVAL,\n transactionThreshold:\n config.snapshot?.transactionThreshold ?? DEFAULT_SNAPSHOT_THRESHOLD,\n },\n});\n\n// =============================================================================\n// Factory\n// =============================================================================\n\n/**\n * Create a MimicServerEngine layer.\n *\n * This creates the core document management service. To expose it via WebSocket,\n * use MimicServer.layerHttpLayerRouter().\n *\n * @example\n * ```typescript\n * // 1. Create the engine\n * const Engine = MimicServerEngine.make({\n * schema: DocSchema,\n * initial: { title: \"Untitled\" },\n * presence: CursorPresence,\n * maxIdleTime: \"5 minutes\",\n * snapshot: { interval: \"5 minutes\", transactionThreshold: 100 },\n * })\n *\n * // 2. Create the WebSocket route\n * const MimicRoute = MimicServer.layerHttpLayerRouter({\n * path: \"/mimic\",\n * })\n *\n * // 3. Wire together\n * const MimicLive = MimicRoute.pipe(\n * Layer.provide(Engine),\n * Layer.provide(ColdStorage.InMemory.make()),\n * Layer.provide(HotStorage.InMemory.make()),\n * Layer.provide(MimicAuthService.NoAuth.make()),\n * )\n * ```\n */\nexport const make = <TSchema extends Primitive.AnyPrimitive>(\n config: MimicServerEngineConfig<TSchema>\n): Layer.Layer<\n MimicServerEngineTag,\n never,\n ColdStorageTag | HotStorageTag | MimicAuthServiceTag\n> => {\n const resolvedConfig = resolveConfig(config);\n\n // Create config layer for DocumentManager\n const configLayer = Layer.succeed(\n DocumentManagerConfigTag,\n resolvedConfig as ResolvedConfig<Primitive.AnyPrimitive>\n );\n\n // Create internal layers\n const internalLayers = Layer.mergeAll(\n documentManagerLayer.pipe(Layer.provide(configLayer)),\n presenceManagerLayer\n );\n\n return Layer.scoped(\n MimicServerEngineTag,\n Effect.fn(\"mimic-server-engine.make\")(function* () {\n const documentManager = yield* DocumentManagerTag;\n const presenceManager = yield* PresenceManagerTag;\n\n const engine: MimicServerEngine = {\n submit: (documentId, transaction) =>\n documentManager.submit(documentId, transaction),\n\n getSnapshot: (documentId) => documentManager.getSnapshot(documentId),\n\n subscribe: (documentId) =>\n documentManager.subscribe(documentId) as Effect.Effect<\n Stream.Stream<Protocol.ServerMessage, never, never>,\n never\n >,\n\n touch: (documentId) => documentManager.touch(documentId),\n\n getPresenceSnapshot: (documentId) =>\n presenceManager.getSnapshot(documentId),\n\n setPresence: (documentId, connectionId, entry) =>\n presenceManager.set(documentId, connectionId, entry),\n\n removePresence: (documentId, connectionId) =>\n presenceManager.remove(documentId, connectionId),\n\n subscribePresence: (documentId) =>\n presenceManager.subscribe(documentId),\n\n config: resolvedConfig as ResolvedConfig<Primitive.AnyPrimitive>,\n };\n\n return engine;\n })()\n ).pipe(Layer.provide(internalLayers));\n};\n\n// =============================================================================\n// Re-export namespace\n// =============================================================================\n\nexport const MimicServerEngine = {\n Tag: MimicServerEngineTag,\n make,\n};\n\n// =============================================================================\n// Re-export SubmitResult type\n// =============================================================================\n\nexport type { SubmitResult };\n"],"mappings":";;;;;;;;;;;;;;;;AAkIA,IAAa,uBAAb,cAA0C,QAAQ,IAChD,2CACD,EAA2C,CAAC;AAM7C,MAAM,wBAAwB,SAAS,QAAQ,EAAE;AACjD,MAAM,kCAAkC;AACxC,MAAM,4BAA4B,SAAS,QAAQ,EAAE;AACrD,MAAM,6BAA6B;;;;AAKnC,MAAM,iBACJ,WAC4B;;QAAC;EAC7B,QAAQ,OAAO;EACf,SAAS,OAAO;EAChB,UAAU,OAAO;EACjB,aAAa,OAAO,cAChB,SAAS,OAAO,OAAO,YAAY,GACnC;EACJ,gDACE,OAAO,8FAAyB;EAClC,UAAU;GACR,+BAAU,OAAO,8EAAU,YACvB,SAAS,OAAO,OAAO,SAAS,SAAS,GACzC;GACJ,oEACE,OAAO,gFAAU,6FAAwB;GAC5C;EACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCD,MAAa,QACX,WAKG;CACH,MAAM,iBAAiB,cAAc,OAAO;CAG5C,MAAM,cAAc,MAAM,QACxB,0BACA,eACD;CAGD,MAAM,iBAAiB,MAAM,SAC3BA,MAAqB,KAAK,MAAM,QAAQ,YAAY,CAAC,EACrDC,QACD;AAED,QAAO,MAAM,OACX,sBACA,OAAO,GAAG,2BAA2B,CAAC,aAAa;EACjD,MAAM,kBAAkB,OAAO;EAC/B,MAAM,kBAAkB,OAAO;AA+B/B,SA7BkC;GAChC,SAAS,YAAY,gBACnB,gBAAgB,OAAO,YAAY,YAAY;GAEjD,cAAc,eAAe,gBAAgB,YAAY,WAAW;GAEpE,YAAY,eACV,gBAAgB,UAAU,WAAW;GAKvC,QAAQ,eAAe,gBAAgB,MAAM,WAAW;GAExD,sBAAsB,eACpB,gBAAgB,YAAY,WAAW;GAEzC,cAAc,YAAY,cAAc,UACtC,gBAAgB,IAAI,YAAY,cAAc,MAAM;GAEtD,iBAAiB,YAAY,iBAC3B,gBAAgB,OAAO,YAAY,aAAa;GAElD,oBAAoB,eAClB,gBAAgB,UAAU,WAAW;GAEvC,QAAQ;GACT;GAGD,EAAE,CACL,CAAC,KAAK,MAAM,QAAQ,eAAe,CAAC;;AAOvC,MAAa,oBAAoB;CAC/B,KAAK;CACL;CACD"}
|
|
1
|
+
{"version":3,"file":"MimicServerEngine.mjs","names":["Metrics.documentsEvicted","Metrics.documentsActive","presenceManagerLayer"],"sources":["../src/MimicServerEngine.ts"],"sourcesContent":["/**\n * @voidhash/mimic-effect - MimicServerEngine\n *\n * Core document management service for Mimic real-time collaboration.\n * Handles document lifecycle, storage, presence, and transaction processing.\n *\n * This is the engine layer - for WebSocket routes, use MimicServer.layerHttpLayerRouter().\n */\nimport {\n Context,\n Duration,\n Effect,\n HashMap,\n Layer,\n Metric,\n Ref,\n Schedule,\n Scope,\n Stream,\n} from \"effect\";\nimport type { Primitive, Transaction } from \"@voidhash/mimic\";\nimport type {\n MimicServerEngineConfig,\n PresenceEntry,\n PresenceEvent,\n PresenceSnapshot,\n ResolvedConfig,\n} from \"./Types\";\nimport type * as Protocol from \"./Protocol\";\nimport { ColdStorageTag } from \"./ColdStorage\";\nimport { HotStorageTag } from \"./HotStorage\";\nimport { MimicAuthServiceTag } from \"./MimicAuthService\";\nimport {\n DocumentInstance,\n type SubmitResult,\n type DocumentInstance as DocumentInstanceType,\n} from \"./DocumentInstance\";\nimport {\n PresenceManagerTag,\n layer as presenceManagerLayer,\n} from \"./PresenceManager\";\nimport * as Metrics from \"./Metrics\";\nimport type { ColdStorageError, HotStorageError } from \"./Errors\";\n\n// =============================================================================\n// Types\n// =============================================================================\n\n/**\n * Error type for MimicServerEngine operations\n */\nexport type MimicServerEngineError = ColdStorageError | HotStorageError;\n\n// =============================================================================\n// MimicServerEngine Interface\n// =============================================================================\n\n/**\n * MimicServerEngine service interface.\n *\n * Provides document management operations for Mimic collaboration.\n * Use MimicServer.layerHttpLayerRouter() to create WebSocket routes.\n */\nexport interface MimicServerEngine {\n /**\n * Submit a transaction to a document.\n * Authorization is checked against the auth service.\n * May fail with MimicServerEngineError if storage is unavailable.\n */\n readonly submit: (\n documentId: string,\n transaction: Transaction.Transaction\n ) => Effect.Effect<SubmitResult, MimicServerEngineError>;\n\n /**\n * Get document snapshot (current state and version).\n * May fail with MimicServerEngineError if storage is unavailable.\n */\n readonly getSnapshot: (\n documentId: string\n ) => Effect.Effect<{ state: unknown; version: number }, MimicServerEngineError>;\n\n /**\n * Subscribe to document broadcasts (transactions).\n * Returns a stream of server messages.\n * Requires a Scope for cleanup when the subscription ends.\n * May fail with MimicServerEngineError if storage is unavailable.\n */\n readonly subscribe: (\n documentId: string\n ) => Effect.Effect<Stream.Stream<Protocol.ServerMessage, never, never>, MimicServerEngineError, Scope.Scope>;\n\n /**\n * Touch document to prevent idle garbage collection.\n */\n readonly touch: (documentId: string) => Effect.Effect<void, never>;\n\n /**\n * Get presence snapshot for a document.\n */\n readonly getPresenceSnapshot: (\n documentId: string\n ) => Effect.Effect<PresenceSnapshot, never>;\n\n /**\n * Set presence for a connection.\n */\n readonly setPresence: (\n documentId: string,\n connectionId: string,\n entry: PresenceEntry\n ) => Effect.Effect<void, never>;\n\n /**\n * Remove presence for a connection.\n */\n readonly removePresence: (\n documentId: string,\n connectionId: string\n ) => Effect.Effect<void, never>;\n\n /**\n * Subscribe to presence events for a document.\n * Requires a Scope for cleanup when the subscription ends.\n */\n readonly subscribePresence: (\n documentId: string\n ) => Effect.Effect<Stream.Stream<PresenceEvent, never, never>, never, Scope.Scope>;\n\n /**\n * Resolved engine configuration.\n * Used by route layer to access schema, presence config, etc.\n */\n readonly config: ResolvedConfig<Primitive.AnyPrimitive>;\n}\n\n// =============================================================================\n// Context Tag\n// =============================================================================\n\n/**\n * Context tag for MimicServerEngine\n */\nexport class MimicServerEngineTag extends Context.Tag(\n \"@voidhash/mimic-effect/MimicServerEngine\"\n)<MimicServerEngineTag, MimicServerEngine>() {}\n\n// =============================================================================\n// Default Configuration\n// =============================================================================\n\nconst DEFAULT_MAX_IDLE_TIME = Duration.minutes(5);\nconst DEFAULT_MAX_TRANSACTION_HISTORY = 1000;\nconst DEFAULT_SNAPSHOT_INTERVAL = Duration.minutes(5);\nconst DEFAULT_SNAPSHOT_THRESHOLD = 100;\n\n/**\n * Resolve configuration with defaults\n */\nconst resolveConfig = <TSchema extends Primitive.AnyPrimitive>(\n config: MimicServerEngineConfig<TSchema>\n): ResolvedConfig<TSchema> => ({\n schema: config.schema,\n initial: config.initial,\n presence: config.presence,\n maxIdleTime: config.maxIdleTime\n ? Duration.decode(config.maxIdleTime)\n : DEFAULT_MAX_IDLE_TIME,\n maxTransactionHistory:\n config.maxTransactionHistory ?? DEFAULT_MAX_TRANSACTION_HISTORY,\n snapshot: {\n interval: config.snapshot?.interval\n ? Duration.decode(config.snapshot.interval)\n : DEFAULT_SNAPSHOT_INTERVAL,\n transactionThreshold:\n config.snapshot?.transactionThreshold ?? DEFAULT_SNAPSHOT_THRESHOLD,\n },\n});\n\n// =============================================================================\n// Internal Types\n// =============================================================================\n\n/**\n * Store entry for a document instance with last activity time\n */\ninterface StoreEntry<TSchema extends Primitive.AnyPrimitive> {\n readonly instance: DocumentInstanceType<TSchema>;\n readonly lastActivityTime: Ref.Ref<number>;\n}\n\n// =============================================================================\n// Factory\n// =============================================================================\n\n/**\n * Create a MimicServerEngine layer.\n *\n * This creates the core document management service. To expose it via WebSocket,\n * use MimicServer.layerHttpLayerRouter().\n *\n * @example\n * ```typescript\n * // 1. Create the engine\n * const Engine = MimicServerEngine.make({\n * schema: DocSchema,\n * initial: { title: \"Untitled\" },\n * presence: CursorPresence,\n * maxIdleTime: \"5 minutes\",\n * snapshot: { interval: \"5 minutes\", transactionThreshold: 100 },\n * })\n *\n * // 2. Create the WebSocket route\n * const MimicRoute = MimicServer.layerHttpLayerRouter({\n * path: \"/mimic\",\n * })\n *\n * // 3. Wire together\n * const MimicLive = MimicRoute.pipe(\n * Layer.provide(Engine),\n * Layer.provide(ColdStorage.InMemory.make()),\n * Layer.provide(HotStorage.InMemory.make()),\n * Layer.provide(MimicAuthService.NoAuth.make()),\n * )\n * ```\n */\nexport const make = <TSchema extends Primitive.AnyPrimitive>(\n config: MimicServerEngineConfig<TSchema>\n): Layer.Layer<\n MimicServerEngineTag,\n never,\n ColdStorageTag | HotStorageTag | MimicAuthServiceTag\n> => {\n const resolvedConfig = resolveConfig(config);\n\n return Layer.scoped(\n MimicServerEngineTag,\n Effect.gen(function* () {\n const coldStorage = yield* ColdStorageTag;\n const hotStorage = yield* HotStorageTag;\n const presenceManager = yield* PresenceManagerTag;\n\n // Store: documentId -> StoreEntry\n const store = yield* Ref.make(\n HashMap.empty<string, StoreEntry<TSchema>>()\n );\n\n /**\n * Get or create a document instance\n */\n const getOrCreateDocument = Effect.fn(\"engine.document.get-or-create\")(\n function* (documentId: string) {\n const current = yield* Ref.get(store);\n const existing = HashMap.get(current, documentId);\n\n if (existing._tag === \"Some\") {\n // Update activity time\n yield* Ref.set(existing.value.lastActivityTime, Date.now());\n return existing.value.instance;\n }\n\n // Create new document instance\n const instance = yield* DocumentInstance.make(\n documentId,\n {\n schema: config.schema,\n initial: config.initial,\n maxTransactionHistory: resolvedConfig.maxTransactionHistory,\n snapshot: resolvedConfig.snapshot,\n },\n coldStorage,\n hotStorage\n );\n\n const lastActivityTime = yield* Ref.make(Date.now());\n\n // Store it\n yield* Ref.update(store, (map) =>\n HashMap.set(map, documentId, { instance, lastActivityTime })\n );\n\n return instance;\n }\n );\n\n /**\n * Start background GC fiber\n */\n const startGCFiber = Effect.fn(\"engine.gc.start\")(function* () {\n const gcLoop = Effect.fn(\"engine.gc.loop\")(function* () {\n const current = yield* Ref.get(store);\n const now = Date.now();\n const maxIdleMs = Duration.toMillis(resolvedConfig.maxIdleTime);\n\n for (const [documentId, entry] of current) {\n const lastActivity = yield* Ref.get(entry.lastActivityTime);\n if (now - lastActivity >= maxIdleMs) {\n // Save final snapshot before eviction (best effort)\n yield* Effect.catchAll(entry.instance.saveSnapshot(), (e) =>\n Effect.logError(\"Failed to save snapshot during eviction\", {\n documentId,\n error: e,\n })\n );\n\n // Remove from store\n yield* Ref.update(store, (map) => HashMap.remove(map, documentId));\n\n // Track eviction metrics\n yield* Metric.increment(Metrics.documentsEvicted);\n yield* Metric.incrementBy(Metrics.documentsActive, -1);\n\n yield* Effect.logInfo(\"Document evicted due to idle timeout\", {\n documentId,\n });\n }\n }\n });\n\n // Run GC every minute\n yield* gcLoop().pipe(\n Effect.repeat(Schedule.spaced(\"1 minute\")),\n Effect.fork\n );\n });\n\n // Start GC fiber\n yield* startGCFiber();\n\n // Cleanup on shutdown\n yield* Effect.addFinalizer(() =>\n Effect.fn(\"engine.shutdown\")(function* () {\n const current = yield* Ref.get(store);\n for (const [documentId, entry] of current) {\n // Best effort save - don't fail shutdown if storage is unavailable\n yield* Effect.catchAll(entry.instance.saveSnapshot(), (e) =>\n Effect.logError(\"Failed to save snapshot during shutdown\", {\n documentId,\n error: e,\n })\n );\n }\n yield* Effect.logInfo(\"MimicServerEngine shutdown complete\");\n })()\n );\n\n const engine: MimicServerEngine = {\n submit: (documentId, transaction) =>\n Effect.gen(function* () {\n const instance = yield* getOrCreateDocument(documentId);\n return yield* instance.submit(transaction);\n }),\n\n getSnapshot: (documentId) =>\n Effect.gen(function* () {\n const instance = yield* getOrCreateDocument(documentId);\n return instance.getSnapshot();\n }),\n\n subscribe: (documentId) =>\n Effect.gen(function* () {\n const instance = yield* getOrCreateDocument(documentId);\n return Stream.fromPubSub(instance.pubsub) as Stream.Stream<\n Protocol.ServerMessage,\n never,\n never\n >;\n }),\n\n touch: (documentId) =>\n Effect.gen(function* () {\n const current = yield* Ref.get(store);\n const existing = HashMap.get(current, documentId);\n if (existing._tag === \"Some\") {\n yield* Ref.set(existing.value.lastActivityTime, Date.now());\n }\n }),\n\n getPresenceSnapshot: (documentId) =>\n presenceManager.getSnapshot(documentId),\n\n setPresence: (documentId, connectionId, entry) =>\n presenceManager.set(documentId, connectionId, entry),\n\n removePresence: (documentId, connectionId) =>\n presenceManager.remove(documentId, connectionId),\n\n subscribePresence: (documentId) =>\n presenceManager.subscribe(documentId),\n\n config: resolvedConfig as ResolvedConfig<Primitive.AnyPrimitive>,\n };\n\n return engine;\n })\n ).pipe(Layer.provide(presenceManagerLayer));\n};\n\n// =============================================================================\n// Re-export namespace\n// =============================================================================\n\nexport const MimicServerEngine = {\n Tag: MimicServerEngineTag,\n make,\n};\n\n// =============================================================================\n// Re-export SubmitResult type\n// =============================================================================\n\nexport type { SubmitResult };\n"],"mappings":"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"}
|
package/dist/Protocol.d.cts
CHANGED
|
@@ -199,5 +199,5 @@ declare const presenceRemoveMessage: (id: string) => PresenceRemoveMessage;
|
|
|
199
199
|
*/
|
|
200
200
|
declare const presenceSnapshotMessage: (selfId: string, presences: Record<string, PresenceEntry>) => PresenceSnapshotMessage;
|
|
201
201
|
//#endregion
|
|
202
|
-
export { Protocol_d_exports, ServerBroadcast, ServerMessage
|
|
202
|
+
export { Protocol_d_exports, ServerBroadcast, ServerMessage };
|
|
203
203
|
//# sourceMappingURL=Protocol.d.cts.map
|
package/dist/Protocol.d.mts
CHANGED
|
@@ -199,5 +199,5 @@ declare const presenceRemoveMessage: (id: string) => PresenceRemoveMessage;
|
|
|
199
199
|
*/
|
|
200
200
|
declare const presenceSnapshotMessage: (selfId: string, presences: Record<string, PresenceEntry>) => PresenceSnapshotMessage;
|
|
201
201
|
//#endregion
|
|
202
|
-
export { Protocol_d_exports, ServerBroadcast, ServerMessage
|
|
202
|
+
export { Protocol_d_exports, ServerBroadcast, ServerMessage };
|
|
203
203
|
//# sourceMappingURL=Protocol.d.mts.map
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ const require_ColdStorage = require('./ColdStorage.cjs');
|
|
|
2
2
|
const require_Errors = require('./Errors.cjs');
|
|
3
3
|
const require_HotStorage = require('./HotStorage.cjs');
|
|
4
4
|
const require_Metrics = require('./Metrics.cjs');
|
|
5
|
-
const
|
|
5
|
+
const require_DocumentInstance = require('./DocumentInstance.cjs');
|
|
6
6
|
const require_PresenceManager = require('./PresenceManager.cjs');
|
|
7
7
|
const require_MimicServerEngine = require('./MimicServerEngine.cjs');
|
|
8
8
|
const require_MimicClusterServerEngine = require('./MimicClusterServerEngine.cjs');
|
|
@@ -15,9 +15,7 @@ exports.AuthorizationError = require_Errors.AuthorizationError;
|
|
|
15
15
|
exports.ColdStorage = require_ColdStorage.ColdStorage;
|
|
16
16
|
exports.ColdStorageError = require_Errors.ColdStorageError;
|
|
17
17
|
exports.ColdStorageTag = require_ColdStorage.ColdStorageTag;
|
|
18
|
-
exports.
|
|
19
|
-
exports.DocumentManagerConfigTag = require_DocumentManager.DocumentManagerConfigTag;
|
|
20
|
-
exports.DocumentManagerTag = require_DocumentManager.DocumentManagerTag;
|
|
18
|
+
exports.DocumentInstance = require_DocumentInstance.DocumentInstance;
|
|
21
19
|
exports.HotStorage = require_HotStorage.HotStorage;
|
|
22
20
|
exports.HotStorageError = require_Errors.HotStorageError;
|
|
23
21
|
exports.HotStorageTag = require_HotStorage.HotStorageTag;
|
package/dist/index.d.cts
CHANGED
|
@@ -4,10 +4,10 @@ import { Protocol_d_exports } from "./Protocol.cjs";
|
|
|
4
4
|
import { ColdStorage, ColdStorageTag } from "./ColdStorage.cjs";
|
|
5
5
|
import { HotStorage, HotStorageTag } from "./HotStorage.cjs";
|
|
6
6
|
import { MimicAuthService, MimicAuthServiceTag } from "./MimicAuthService.cjs";
|
|
7
|
-
import {
|
|
7
|
+
import { DocumentInstance, SubmitResult } from "./DocumentInstance.cjs";
|
|
8
8
|
import { MimicServerEngine, MimicServerEngineTag } from "./MimicServerEngine.cjs";
|
|
9
9
|
import { MimicClusterServerEngine } from "./MimicClusterServerEngine.cjs";
|
|
10
10
|
import { MimicServer } from "./MimicServer.cjs";
|
|
11
11
|
import { MimicMetrics } from "./Metrics.cjs";
|
|
12
12
|
import { PresenceManager, PresenceManagerTag } from "./PresenceManager.cjs";
|
|
13
|
-
export { AuthContext, AuthenticationError, AuthorizationError, ColdStorage, ColdStorageError, ColdStorageTag,
|
|
13
|
+
export { AuthContext, AuthenticationError, AuthorizationError, ColdStorage, ColdStorageError, ColdStorageTag, DocumentInstance, type DocumentInstance as DocumentInstanceInterface, DurationInput, HotStorage, HotStorageError, HotStorageTag, Initial, InitialContext, InitialFn, MessageParseError, MimicAuthService, MimicAuthServiceTag, MimicClusterServerEngine, MimicClusterServerEngineConfig, MimicError, MimicMetrics, MimicServer, MimicServerEngine, MimicServerEngineConfig, MimicServerEngineTag, type MimicServerRouteConfig, MissingDocumentIdError, Permission, PresenceEntry, PresenceEvent, PresenceManager, PresenceManagerTag, PresenceRemoveEvent, PresenceSnapshot, PresenceUpdateEvent, Protocol_d_exports as Protocol, ResolvedClusterConfig, ResolvedConfig, ResolvedRouteConfig, SnapshotConfig, StoredDocument, type SubmitResult, TransactionRejectedError, WalEntry, WalVersionGapError };
|
package/dist/index.d.mts
CHANGED
|
@@ -4,10 +4,10 @@ import { Protocol_d_exports } from "./Protocol.mjs";
|
|
|
4
4
|
import { ColdStorage, ColdStorageTag } from "./ColdStorage.mjs";
|
|
5
5
|
import { HotStorage, HotStorageTag } from "./HotStorage.mjs";
|
|
6
6
|
import { MimicAuthService, MimicAuthServiceTag } from "./MimicAuthService.mjs";
|
|
7
|
-
import {
|
|
7
|
+
import { DocumentInstance, SubmitResult } from "./DocumentInstance.mjs";
|
|
8
8
|
import { MimicServerEngine, MimicServerEngineTag } from "./MimicServerEngine.mjs";
|
|
9
9
|
import { MimicClusterServerEngine } from "./MimicClusterServerEngine.mjs";
|
|
10
10
|
import { MimicServer } from "./MimicServer.mjs";
|
|
11
11
|
import { MimicMetrics } from "./Metrics.mjs";
|
|
12
12
|
import { PresenceManager, PresenceManagerTag } from "./PresenceManager.mjs";
|
|
13
|
-
export { AuthContext, AuthenticationError, AuthorizationError, ColdStorage, ColdStorageError, ColdStorageTag,
|
|
13
|
+
export { AuthContext, AuthenticationError, AuthorizationError, ColdStorage, ColdStorageError, ColdStorageTag, DocumentInstance, type DocumentInstance as DocumentInstanceInterface, DurationInput, HotStorage, HotStorageError, HotStorageTag, Initial, InitialContext, InitialFn, MessageParseError, MimicAuthService, MimicAuthServiceTag, MimicClusterServerEngine, MimicClusterServerEngineConfig, MimicError, MimicMetrics, MimicServer, MimicServerEngine, MimicServerEngineConfig, MimicServerEngineTag, type MimicServerRouteConfig, MissingDocumentIdError, Permission, PresenceEntry, PresenceEvent, PresenceManager, PresenceManagerTag, PresenceRemoveEvent, PresenceSnapshot, PresenceUpdateEvent, Protocol_d_exports as Protocol, ResolvedClusterConfig, ResolvedConfig, ResolvedRouteConfig, SnapshotConfig, StoredDocument, type SubmitResult, TransactionRejectedError, WalEntry, WalVersionGapError };
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { ColdStorage, ColdStorageTag } from "./ColdStorage.mjs";
|
|
|
2
2
|
import { AuthenticationError, AuthorizationError, ColdStorageError, HotStorageError, MessageParseError, MissingDocumentIdError, TransactionRejectedError, WalVersionGapError } from "./Errors.mjs";
|
|
3
3
|
import { HotStorage, HotStorageTag } from "./HotStorage.mjs";
|
|
4
4
|
import { MimicMetrics } from "./Metrics.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { DocumentInstance } from "./DocumentInstance.mjs";
|
|
6
6
|
import { PresenceManager, PresenceManagerTag } from "./PresenceManager.mjs";
|
|
7
7
|
import { MimicServerEngine, MimicServerEngineTag } from "./MimicServerEngine.mjs";
|
|
8
8
|
import { MimicClusterServerEngine } from "./MimicClusterServerEngine.mjs";
|
|
@@ -10,4 +10,4 @@ import { Protocol_exports } from "./Protocol.mjs";
|
|
|
10
10
|
import { MimicAuthService, MimicAuthServiceTag } from "./MimicAuthService.mjs";
|
|
11
11
|
import { MimicServer } from "./MimicServer.mjs";
|
|
12
12
|
|
|
13
|
-
export { AuthenticationError, AuthorizationError, ColdStorage, ColdStorageError, ColdStorageTag,
|
|
13
|
+
export { AuthenticationError, AuthorizationError, ColdStorage, ColdStorageError, ColdStorageTag, DocumentInstance, HotStorage, HotStorageError, HotStorageTag, MessageParseError, MimicAuthService, MimicAuthServiceTag, MimicClusterServerEngine, MimicMetrics, MimicServer, MimicServerEngine, MimicServerEngineTag, MissingDocumentIdError, PresenceManager, PresenceManagerTag, Protocol_exports as Protocol, TransactionRejectedError, WalVersionGapError };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidhash/mimic-effect",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,14 +26,14 @@
|
|
|
26
26
|
"typescript": "5.8.3",
|
|
27
27
|
"vite-tsconfig-paths": "^5.1.4",
|
|
28
28
|
"vitest": "^3.2.4",
|
|
29
|
-
"@voidhash/tsconfig": "1.0.0-beta.
|
|
29
|
+
"@voidhash/tsconfig": "1.0.0-beta.8"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"@effect/platform": "^0.93.8",
|
|
33
33
|
"@effect/cluster": "^0.55.0",
|
|
34
34
|
"@effect/rpc": "^0.72.2",
|
|
35
35
|
"effect": "^3.19.12",
|
|
36
|
-
"@voidhash/mimic": "1.0.0-beta.
|
|
36
|
+
"@voidhash/mimic": "1.0.0-beta.8"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
39
39
|
"@effect/cluster": {
|