@voidhash/mimic-effect 0.0.3 → 0.0.5
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 +25 -25
- package/dist/DocumentManager.cjs +3 -3
- package/dist/DocumentManager.d.cts +1 -1
- package/dist/DocumentManager.d.cts.map +1 -1
- package/dist/DocumentManager.d.mts.map +1 -1
- package/dist/DocumentManager.mjs +2 -2
- package/dist/DocumentManager.mjs.map +1 -1
- package/dist/MimicConfig.cjs +12 -2
- package/dist/MimicConfig.d.cts +45 -3
- package/dist/MimicConfig.d.cts.map +1 -1
- package/dist/MimicConfig.d.mts +44 -2
- package/dist/MimicConfig.d.mts.map +1 -1
- package/dist/MimicConfig.mjs +11 -2
- package/dist/MimicConfig.mjs.map +1 -1
- package/dist/MimicDataStorage.d.cts +5 -5
- package/dist/MimicServer.cjs +21 -126
- package/dist/MimicServer.d.cts +25 -101
- package/dist/MimicServer.d.cts.map +1 -1
- package/dist/MimicServer.d.mts +25 -101
- package/dist/MimicServer.d.mts.map +1 -1
- package/dist/MimicServer.mjs +26 -130
- package/dist/MimicServer.mjs.map +1 -1
- package/dist/PresenceManager.cjs +2 -2
- package/dist/PresenceManager.mjs +1 -1
- package/dist/WebSocketHandler.cjs +2 -3
- package/dist/WebSocketHandler.d.cts +1 -1
- package/dist/WebSocketHandler.d.mts +1 -1
- package/dist/WebSocketHandler.mjs +2 -2
- package/dist/errors.d.cts +9 -9
- package/package.json +3 -3
- package/src/DocumentManager.ts +5 -3
- package/src/MimicConfig.ts +92 -12
- package/src/MimicServer.ts +76 -200
- package/tests/DocumentManager.test.ts +124 -0
- package/tests/MimicConfig.test.ts +115 -0
- package/tests/MimicServer.test.ts +55 -162
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @voidhash/mimic-effect@0.0.
|
|
2
|
+
> @voidhash/mimic-effect@0.0.5 build /home/runner/work/mimic/mimic/packages/mimic-effect
|
|
3
3
|
> tsdown
|
|
4
4
|
|
|
5
5
|
[34mℹ[39m tsdown [2mv0.18.2[22m powered by rolldown [2mv1.0.0-beta.55[22m
|
|
@@ -9,15 +9,15 @@
|
|
|
9
9
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
10
|
[34mℹ[39m Build start
|
|
11
11
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m [2m 2.79 kB[22m [2m│ gzip: 0.52 kB[22m
|
|
12
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mWebSocketHandler.cjs [2m13.
|
|
13
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.cjs [
|
|
14
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentManager.cjs [2m 4.
|
|
12
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mWebSocketHandler.cjs [2m13.83 kB[22m [2m│ gzip: 2.46 kB[22m
|
|
13
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.cjs [2m 6.03 kB[22m [2m│ gzip: 1.82 kB[22m
|
|
14
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentManager.cjs [2m 4.75 kB[22m [2m│ gzip: 1.40 kB[22m
|
|
15
15
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mPresenceManager.cjs [2m 4.25 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
16
16
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicDataStorage.cjs [2m 3.13 kB[22m [2m│ gzip: 0.96 kB[22m
|
|
17
17
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentProtocol.cjs [2m 2.85 kB[22m [2m│ gzip: 0.79 kB[22m
|
|
18
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicConfig.cjs [2m 2.77 kB[22m [2m│ gzip: 0.93 kB[22m
|
|
18
19
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22merrors.cjs [2m 2.33 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
19
20
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mstorage/InMemoryDataStorage.cjs [2m 2.21 kB[22m [2m│ gzip: 0.80 kB[22m
|
|
20
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicConfig.cjs [2m 2.15 kB[22m [2m│ gzip: 0.74 kB[22m
|
|
21
21
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicAuthService.cjs [2m 2.12 kB[22m [2m│ gzip: 0.69 kB[22m
|
|
22
22
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mauth/NoAuth.cjs [2m 1.52 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
23
23
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/rolldown_runtime.cjs [2m 1.31 kB[22m [2m│ gzip: 0.61 kB[22m
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs [2m 0.52 kB[22m [2m│ gzip: 0.32 kB[22m
|
|
27
27
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs [2m 0.40 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
28
28
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs [2m 0.37 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
29
|
-
[34mℹ[39m [33m[CJS][39m 18 files, total:
|
|
29
|
+
[34mℹ[39m [33m[CJS][39m 18 files, total: 52.65 kB
|
|
30
30
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicDataStorage.d.cts.map [2m1.96 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
31
31
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentProtocol.d.cts.map [2m1.35 kB[22m [2m│ gzip: 0.52 kB[22m
|
|
32
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicConfig.d.cts.map [2m1.03 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
32
33
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicAuthService.d.cts.map [2m0.97 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
33
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.d.cts.map [2m0.
|
|
34
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicConfig.d.cts.map [2m0.77 kB[22m [2m│ gzip: 0.41 kB[22m
|
|
34
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.d.cts.map [2m0.84 kB[22m [2m│ gzip: 0.44 kB[22m
|
|
35
35
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22merrors.d.cts.map [2m0.77 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
36
36
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mWebSocketHandler.d.cts.map [2m0.74 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
37
37
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mPresenceManager.d.cts.map [2m0.69 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
@@ -39,48 +39,48 @@
|
|
|
39
39
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mstorage/InMemoryDataStorage.d.cts.map [2m0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
40
40
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mauth/NoAuth.d.cts.map [2m0.22 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
41
41
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32m[1mindex.d.cts[22m[39m [2m1.52 kB[22m [2m│ gzip: 0.37 kB[22m
|
|
42
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[
|
|
42
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicConfig.d.cts[39m [2m5.14 kB[22m [2m│ gzip: 1.43 kB[22m
|
|
43
43
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicDataStorage.d.cts[39m [2m4.84 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
44
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicServer.d.cts[39m [2m4.62 kB[22m [2m│ gzip: 1.65 kB[22m
|
|
44
45
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32merrors.d.cts[39m [2m4.08 kB[22m [2m│ gzip: 0.75 kB[22m
|
|
45
46
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mDocumentProtocol.d.cts[39m [2m3.78 kB[22m [2m│ gzip: 0.78 kB[22m
|
|
46
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicConfig.d.cts[39m [2m3.47 kB[22m [2m│ gzip: 0.94 kB[22m
|
|
47
47
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mPresenceManager.d.cts[39m [2m3.00 kB[22m [2m│ gzip: 0.90 kB[22m
|
|
48
48
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicAuthService.d.cts[39m [2m2.38 kB[22m [2m│ gzip: 0.77 kB[22m
|
|
49
49
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mDocumentManager.d.cts[39m [2m1.77 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
50
50
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mWebSocketHandler.d.cts[39m [2m1.73 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
51
51
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mauth/NoAuth.d.cts[39m [2m0.72 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
52
52
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mstorage/InMemoryDataStorage.d.cts[39m [2m0.65 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
53
|
-
[34mℹ[39m [33m[CJS][39m 23 files, total:
|
|
54
|
-
[32m✔[39m Build complete in [
|
|
53
|
+
[34mℹ[39m [33m[CJS][39m 23 files, total: 43.60 kB
|
|
54
|
+
[32m✔[39m Build complete in [32m5200ms[39m
|
|
55
55
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.mjs[22m [2m 1.45 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
56
56
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mWebSocketHandler.mjs.map [2m29.74 kB[22m [2m│ gzip: 5.00 kB[22m
|
|
57
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[
|
|
58
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[
|
|
57
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mWebSocketHandler.mjs [2m12.36 kB[22m [2m│ gzip: 2.34 kB[22m
|
|
58
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.mjs.map [2m10.71 kB[22m [2m│ gzip: 3.31 kB[22m
|
|
59
59
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mPresenceManager.mjs.map [2m10.45 kB[22m [2m│ gzip: 2.54 kB[22m
|
|
60
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.mjs.map [2m 9.
|
|
61
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[
|
|
60
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.mjs.map [2m 9.97 kB[22m [2m│ gzip: 2.85 kB[22m
|
|
61
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicConfig.mjs.map [2m 7.76 kB[22m [2m│ gzip: 2.11 kB[22m
|
|
62
62
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicDataStorage.mjs.map [2m 6.27 kB[22m [2m│ gzip: 1.55 kB[22m
|
|
63
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[
|
|
63
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.mjs [2m 5.21 kB[22m [2m│ gzip: 1.72 kB[22m
|
|
64
64
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicAuthService.mjs.map [2m 4.09 kB[22m [2m│ gzip: 1.10 kB[22m
|
|
65
65
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentProtocol.mjs.map [2m 4.07 kB[22m [2m│ gzip: 1.01 kB[22m
|
|
66
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.mjs [2m 3.
|
|
66
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.mjs [2m 3.81 kB[22m [2m│ gzip: 1.26 kB[22m
|
|
67
67
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22merrors.mjs.map [2m 3.53 kB[22m [2m│ gzip: 0.92 kB[22m
|
|
68
68
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mPresenceManager.mjs [2m 3.38 kB[22m [2m│ gzip: 1.06 kB[22m
|
|
69
69
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mstorage/InMemoryDataStorage.mjs.map [2m 2.84 kB[22m [2m│ gzip: 1.03 kB[22m
|
|
70
70
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicDataStorage.mjs [2m 2.66 kB[22m [2m│ gzip: 0.87 kB[22m
|
|
71
71
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentProtocol.mjs [2m 2.44 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
72
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicConfig.mjs [2m 2.25 kB[22m [2m│ gzip: 0.84 kB[22m
|
|
72
73
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicDataStorage.d.mts.map [2m 1.96 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
73
74
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22merrors.mjs [2m 1.95 kB[22m [2m│ gzip: 0.57 kB[22m
|
|
74
75
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mauth/NoAuth.mjs.map [2m 1.82 kB[22m [2m│ gzip: 0.68 kB[22m
|
|
75
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicConfig.mjs [2m 1.75 kB[22m [2m│ gzip: 0.65 kB[22m
|
|
76
76
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicAuthService.mjs [2m 1.74 kB[22m [2m│ gzip: 0.61 kB[22m
|
|
77
77
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mstorage/InMemoryDataStorage.mjs [2m 1.68 kB[22m [2m│ gzip: 0.71 kB[22m
|
|
78
78
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentProtocol.d.mts.map [2m 1.35 kB[22m [2m│ gzip: 0.52 kB[22m
|
|
79
79
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mauth/NoAuth.mjs [2m 1.21 kB[22m [2m│ gzip: 0.56 kB[22m
|
|
80
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicConfig.d.mts.map [2m 1.03 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
80
81
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicAuthService.d.mts.map [2m 0.97 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
81
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.d.mts.map [2m 0.95 kB[22m [2m│ gzip: 0.43 kB[22m
|
|
82
82
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs [2m 0.90 kB[22m [2m│ gzip: 0.42 kB[22m
|
|
83
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[
|
|
83
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.d.mts.map [2m 0.84 kB[22m [2m│ gzip: 0.44 kB[22m
|
|
84
84
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22merrors.d.mts.map [2m 0.77 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
85
85
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mWebSocketHandler.d.mts.map [2m 0.74 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
86
86
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mPresenceManager.d.mts.map [2m 0.69 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
@@ -93,16 +93,16 @@
|
|
|
93
93
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mstorage/InMemoryDataStorage.d.mts.map [2m 0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
94
94
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mauth/NoAuth.d.mts.map [2m 0.22 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
95
95
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32m[1mindex.d.mts[22m[39m [2m 1.52 kB[22m [2m│ gzip: 0.37 kB[22m
|
|
96
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[
|
|
96
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicConfig.d.mts[39m [2m 5.14 kB[22m [2m│ gzip: 1.42 kB[22m
|
|
97
97
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicDataStorage.d.mts[39m [2m 4.84 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
98
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicServer.d.mts[39m [2m 4.62 kB[22m [2m│ gzip: 1.65 kB[22m
|
|
98
99
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32merrors.d.mts[39m [2m 4.08 kB[22m [2m│ gzip: 0.75 kB[22m
|
|
99
100
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mDocumentProtocol.d.mts[39m [2m 3.78 kB[22m [2m│ gzip: 0.78 kB[22m
|
|
100
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicConfig.d.mts[39m [2m 3.47 kB[22m [2m│ gzip: 0.94 kB[22m
|
|
101
101
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mPresenceManager.d.mts[39m [2m 3.00 kB[22m [2m│ gzip: 0.90 kB[22m
|
|
102
102
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicAuthService.d.mts[39m [2m 2.38 kB[22m [2m│ gzip: 0.77 kB[22m
|
|
103
103
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mDocumentManager.d.mts[39m [2m 1.77 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
104
104
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mWebSocketHandler.d.mts[39m [2m 1.73 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
105
105
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mauth/NoAuth.d.mts[39m [2m 0.72 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
106
106
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mstorage/InMemoryDataStorage.d.mts[39m [2m 0.65 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
107
|
-
[34mℹ[39m [34m[ESM][39m 52 files, total:
|
|
108
|
-
[32m✔[39m Build complete in [
|
|
107
|
+
[34mℹ[39m [34m[ESM][39m 52 files, total: 177.78 kB
|
|
108
|
+
[32m✔[39m Build complete in [32m5219ms[39m
|
package/dist/DocumentManager.cjs
CHANGED
|
@@ -5,14 +5,14 @@ let effect_Effect = require("effect/Effect");
|
|
|
5
5
|
effect_Effect = require_rolldown_runtime.__toESM(effect_Effect);
|
|
6
6
|
let effect_Layer = require("effect/Layer");
|
|
7
7
|
effect_Layer = require_rolldown_runtime.__toESM(effect_Layer);
|
|
8
|
-
let effect_Context = require("effect/Context");
|
|
9
|
-
effect_Context = require_rolldown_runtime.__toESM(effect_Context);
|
|
10
8
|
let effect_PubSub = require("effect/PubSub");
|
|
11
9
|
effect_PubSub = require_rolldown_runtime.__toESM(effect_PubSub);
|
|
12
10
|
let effect_Ref = require("effect/Ref");
|
|
13
11
|
effect_Ref = require_rolldown_runtime.__toESM(effect_Ref);
|
|
14
12
|
let effect_HashMap = require("effect/HashMap");
|
|
15
13
|
effect_HashMap = require_rolldown_runtime.__toESM(effect_HashMap);
|
|
14
|
+
let effect_Context = require("effect/Context");
|
|
15
|
+
effect_Context = require_rolldown_runtime.__toESM(effect_Context);
|
|
16
16
|
let effect_Stream = require("effect/Stream");
|
|
17
17
|
effect_Stream = require_rolldown_runtime.__toESM(effect_Stream);
|
|
18
18
|
let _voidhash_mimic_server = require("@voidhash/mimic/server");
|
|
@@ -45,7 +45,7 @@ const makeDocumentManager = effect_Effect.gen(function* () {
|
|
|
45
45
|
return existing.value;
|
|
46
46
|
}
|
|
47
47
|
const rawState = yield* effect_Effect.catchAll(storage.load(documentId), () => effect_Effect.succeed(void 0));
|
|
48
|
-
const initialState = rawState !== void 0 ? yield* storage.onLoad(rawState) : void 0;
|
|
48
|
+
const initialState = rawState !== void 0 ? yield* storage.onLoad(rawState) : config.initial !== void 0 ? yield* config.initial({ documentId }) : void 0;
|
|
49
49
|
const pubsub = yield* effect_PubSub.unbounded();
|
|
50
50
|
const serverDocument = _voidhash_mimic_server.ServerDocument.make({
|
|
51
51
|
schema: config.schema,
|
|
@@ -3,8 +3,8 @@ import { MimicServerConfigTag } from "./MimicConfig.cjs";
|
|
|
3
3
|
import { MimicDataStorageTag } from "./MimicDataStorage.cjs";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Layer from "effect/Layer";
|
|
6
|
-
import * as Context from "effect/Context";
|
|
7
6
|
import { Transaction } from "@voidhash/mimic";
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
8
|
import * as Scope from "effect/Scope";
|
|
9
9
|
import * as Stream from "effect/Stream";
|
|
10
10
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentManager.d.cts","names":[],"sources":["../src/DocumentManager.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;UA2CiB,eAAA;EAAA;;;EAOV,SAAO,MAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,WAAA,EADG,WAAA,CAAY,WACf,EAAA,GAAP,MAAA,CAAO,MAAA,CAAO,YAAP,CAAA;EAOO;;;EASjB,SAAO,WAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GATJ,MAAA,CAAO,MASH,CATU,eASV,CAAA;EAEP;;;AAEH;8CALM,MAAA,CAAO,OACV,MAAA,CAAO,OAAO,yBAEd,KAAA,CAAM;;cAET;;AAKD;
|
|
1
|
+
{"version":3,"file":"DocumentManager.d.cts","names":[],"sources":["../src/DocumentManager.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;UA2CiB,eAAA;EAAA;;;EAOV,SAAO,MAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,WAAA,EADG,WAAA,CAAY,WACf,EAAA,GAAP,MAAA,CAAO,MAAA,CAAO,YAAP,CAAA;EAOO;;;EASjB,SAAO,WAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GATJ,MAAA,CAAO,MASH,CATU,eASV,CAAA;EAEP;;;AAEH;8CALM,MAAA,CAAO,OACV,MAAA,CAAO,OAAO,yBAEd,KAAA,CAAM;;cAET;;AAKD;AA8KA;AACE,cA/KW,kBAAA,SAA2B,uBAAA,CA+KtC;;;;;cADW,OAAO,KAAA,CAAM,MACxB,2BAEA,uBAAuB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentManager.d.mts","names":[],"sources":["../src/DocumentManager.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;UA2CiB,eAAA;EAAA;;;EAOV,SAAO,MAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,WAAA,EADG,WAAA,CAAY,WACf,EAAA,GAAP,MAAA,CAAO,MAAA,CAAO,YAAP,CAAA;EAOO;;;EASjB,SAAO,WAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GATJ,MAAA,CAAO,MASH,CATU,eASV,CAAA;EAEP;;;AAEH;8CALM,MAAA,CAAO,OACV,MAAA,CAAO,OAAO,yBAEd,KAAA,CAAM;;cAET;;AAKD;
|
|
1
|
+
{"version":3,"file":"DocumentManager.d.mts","names":[],"sources":["../src/DocumentManager.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;UA2CiB,eAAA;EAAA;;;EAOV,SAAO,MAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,WAAA,EADG,WAAA,CAAY,WACf,EAAA,GAAP,MAAA,CAAO,MAAA,CAAO,YAAP,CAAA;EAOO;;;EASjB,SAAO,WAAA,EAAA,CAAA,UAAA,EAAA,MAAA,EAAA,GATJ,MAAA,CAAO,MASH,CATU,eASV,CAAA;EAEP;;;AAEH;8CALM,MAAA,CAAO,OACV,MAAA,CAAO,OAAO,yBAEd,KAAA,CAAM;;cAET;;AAKD;AA8KA;AACE,cA/KW,kBAAA,SAA2B,uBAAA,CA+KtC;;;;;cADW,OAAO,KAAA,CAAM,MACxB,2BAEA,uBAAuB"}
|
package/dist/DocumentManager.mjs
CHANGED
|
@@ -3,10 +3,10 @@ import { MimicServerConfigTag } from "./MimicConfig.mjs";
|
|
|
3
3
|
import { MimicDataStorageTag } from "./MimicDataStorage.mjs";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
5
|
import * as Layer from "effect/Layer";
|
|
6
|
-
import * as Context from "effect/Context";
|
|
7
6
|
import * as PubSub from "effect/PubSub";
|
|
8
7
|
import * as Ref from "effect/Ref";
|
|
9
8
|
import * as HashMap from "effect/HashMap";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
10
|
import * as Stream from "effect/Stream";
|
|
11
11
|
import { ServerDocument } from "@voidhash/mimic/server";
|
|
12
12
|
|
|
@@ -38,7 +38,7 @@ const makeDocumentManager = Effect.gen(function* () {
|
|
|
38
38
|
return existing.value;
|
|
39
39
|
}
|
|
40
40
|
const rawState = yield* Effect.catchAll(storage.load(documentId), () => Effect.succeed(void 0));
|
|
41
|
-
const initialState = rawState !== void 0 ? yield* storage.onLoad(rawState) : void 0;
|
|
41
|
+
const initialState = rawState !== void 0 ? yield* storage.onLoad(rawState) : config.initial !== void 0 ? yield* config.initial({ documentId }) : void 0;
|
|
42
42
|
const pubsub = yield* PubSub.unbounded();
|
|
43
43
|
const serverDocument = ServerDocument.make({
|
|
44
44
|
schema: config.schema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentManager.mjs","names":["instance: DocumentInstance","layer: Layer.Layer<\n DocumentManagerTag,\n never,\n MimicServerConfigTag | MimicDataStorageTag\n>"],"sources":["../src/DocumentManager.ts"],"sourcesContent":["/**\n * @since 0.0.1\n * Document manager that handles multiple document instances.\n */\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as PubSub from \"effect/PubSub\";\nimport * as Ref from \"effect/Ref\";\nimport * as HashMap from \"effect/HashMap\";\nimport * as Context from \"effect/Context\";\nimport * as Scope from \"effect/Scope\";\nimport * as Stream from \"effect/Stream\";\nimport type { Primitive, Transaction } from \"@voidhash/mimic\";\nimport { ServerDocument } from \"@voidhash/mimic/server\";\n\nimport * as Protocol from \"./DocumentProtocol.js\";\nimport { MimicServerConfigTag } from \"./MimicConfig.js\";\nimport { MimicDataStorageTag } from \"./MimicDataStorage.js\";\nimport { DocumentNotFoundError } from \"./errors.js\";\n\n// =============================================================================\n// Document Instance\n// =============================================================================\n\n/**\n * A managed document instance that holds state and manages subscribers.\n */\ninterface DocumentInstance {\n /** The underlying ServerDocument */\n readonly document: ServerDocument.ServerDocument<Primitive.AnyPrimitive>;\n /** PubSub for broadcasting messages to subscribers */\n readonly pubsub: PubSub.PubSub<Protocol.ServerBroadcast>;\n /** Reference count for cleanup */\n readonly refCount: Ref.Ref<number>;\n}\n\n// =============================================================================\n// Document Manager Service\n// =============================================================================\n\n/**\n * Service interface for the DocumentManager.\n */\nexport interface DocumentManager {\n /**\n * Submit a transaction to a document.\n */\n readonly submit: (\n documentId: string,\n transaction: Transaction.Transaction\n ) => Effect.Effect<Protocol.SubmitResult>;\n\n /**\n * Get a snapshot of a document.\n */\n readonly getSnapshot: (\n documentId: string\n ) => Effect.Effect<Protocol.SnapshotMessage>;\n\n /**\n * Subscribe to broadcasts for a document.\n * Returns a Stream of server broadcasts.\n */\n readonly subscribe: (\n documentId: string\n ) => Effect.Effect<\n Stream.Stream<Protocol.ServerBroadcast>,\n never,\n Scope.Scope\n >;\n}\n\n/**\n * Context tag for DocumentManager.\n */\nexport class DocumentManagerTag extends Context.Tag(\n \"@voidhash/mimic-server-effect/DocumentManager\"\n)<DocumentManagerTag, DocumentManager>() {}\n\n// =============================================================================\n// Document Manager Implementation\n// =============================================================================\n\n/**\n * Create the DocumentManager service.\n */\nconst makeDocumentManager = Effect.gen(function* () {\n const config = yield* MimicServerConfigTag;\n const storage = yield* MimicDataStorageTag;\n \n // Map of document ID to document instance\n const documents = yield* Ref.make(\n HashMap.empty<string, DocumentInstance>()\n );\n\n // Get or create a document instance\n const getOrCreateDocument = (\n documentId: string\n ): Effect.Effect<DocumentInstance> =>\n Effect.gen(function* () {\n const current = yield* Ref.get(documents);\n const existing = HashMap.get(current, documentId);\n\n if (existing._tag === \"Some\") {\n // Increment ref count\n yield* Ref.update(existing.value.refCount, (n) => n + 1);\n return existing.value;\n }\n\n // Load initial state from storage\n const rawState = yield* Effect.catchAll(\n storage.load(documentId),\n () => Effect.succeed(undefined)\n );\n\n // Transform loaded state with onLoad hook\n const initialState = rawState !== undefined\n ? yield* storage.onLoad(rawState)\n : undefined;\n\n // Create PubSub for broadcasting\n const pubsub = yield* PubSub.unbounded<Protocol.ServerBroadcast>();\n\n // Create ServerDocument with broadcast callback\n const serverDocument = ServerDocument.make({\n schema: config.schema,\n initialState: initialState as Primitive.
|
|
1
|
+
{"version":3,"file":"DocumentManager.mjs","names":["instance: DocumentInstance","layer: Layer.Layer<\n DocumentManagerTag,\n never,\n MimicServerConfigTag | MimicDataStorageTag\n>"],"sources":["../src/DocumentManager.ts"],"sourcesContent":["/**\n * @since 0.0.1\n * Document manager that handles multiple document instances.\n */\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport * as PubSub from \"effect/PubSub\";\nimport * as Ref from \"effect/Ref\";\nimport * as HashMap from \"effect/HashMap\";\nimport * as Context from \"effect/Context\";\nimport * as Scope from \"effect/Scope\";\nimport * as Stream from \"effect/Stream\";\nimport type { Primitive, Transaction } from \"@voidhash/mimic\";\nimport { ServerDocument } from \"@voidhash/mimic/server\";\n\nimport * as Protocol from \"./DocumentProtocol.js\";\nimport { MimicServerConfigTag } from \"./MimicConfig.js\";\nimport { MimicDataStorageTag } from \"./MimicDataStorage.js\";\nimport { DocumentNotFoundError } from \"./errors.js\";\n\n// =============================================================================\n// Document Instance\n// =============================================================================\n\n/**\n * A managed document instance that holds state and manages subscribers.\n */\ninterface DocumentInstance {\n /** The underlying ServerDocument */\n readonly document: ServerDocument.ServerDocument<Primitive.AnyPrimitive>;\n /** PubSub for broadcasting messages to subscribers */\n readonly pubsub: PubSub.PubSub<Protocol.ServerBroadcast>;\n /** Reference count for cleanup */\n readonly refCount: Ref.Ref<number>;\n}\n\n// =============================================================================\n// Document Manager Service\n// =============================================================================\n\n/**\n * Service interface for the DocumentManager.\n */\nexport interface DocumentManager {\n /**\n * Submit a transaction to a document.\n */\n readonly submit: (\n documentId: string,\n transaction: Transaction.Transaction\n ) => Effect.Effect<Protocol.SubmitResult>;\n\n /**\n * Get a snapshot of a document.\n */\n readonly getSnapshot: (\n documentId: string\n ) => Effect.Effect<Protocol.SnapshotMessage>;\n\n /**\n * Subscribe to broadcasts for a document.\n * Returns a Stream of server broadcasts.\n */\n readonly subscribe: (\n documentId: string\n ) => Effect.Effect<\n Stream.Stream<Protocol.ServerBroadcast>,\n never,\n Scope.Scope\n >;\n}\n\n/**\n * Context tag for DocumentManager.\n */\nexport class DocumentManagerTag extends Context.Tag(\n \"@voidhash/mimic-server-effect/DocumentManager\"\n)<DocumentManagerTag, DocumentManager>() {}\n\n// =============================================================================\n// Document Manager Implementation\n// =============================================================================\n\n/**\n * Create the DocumentManager service.\n */\nconst makeDocumentManager = Effect.gen(function* () {\n const config = yield* MimicServerConfigTag;\n const storage = yield* MimicDataStorageTag;\n \n // Map of document ID to document instance\n const documents = yield* Ref.make(\n HashMap.empty<string, DocumentInstance>()\n );\n\n // Get or create a document instance\n const getOrCreateDocument = (\n documentId: string\n ): Effect.Effect<DocumentInstance> =>\n Effect.gen(function* () {\n const current = yield* Ref.get(documents);\n const existing = HashMap.get(current, documentId);\n\n if (existing._tag === \"Some\") {\n // Increment ref count\n yield* Ref.update(existing.value.refCount, (n) => n + 1);\n return existing.value;\n }\n\n // Load initial state from storage\n const rawState = yield* Effect.catchAll(\n storage.load(documentId),\n () => Effect.succeed(undefined)\n );\n\n // Transform loaded state with onLoad hook, or compute initial state for new docs\n const initialState = rawState !== undefined\n ? yield* storage.onLoad(rawState)\n : config.initial !== undefined\n ? yield* config.initial({ documentId })\n : undefined;\n\n // Create PubSub for broadcasting\n const pubsub = yield* PubSub.unbounded<Protocol.ServerBroadcast>();\n\n // Create ServerDocument with broadcast callback\n const serverDocument = ServerDocument.make({\n schema: config.schema,\n initialState: initialState as Primitive.InferSetInput<typeof config.schema> | undefined,\n maxTransactionHistory: config.maxTransactionHistory,\n onBroadcast: (transactionMessage) => {\n // Get current state and save to storage\n const currentState = serverDocument.get();\n \n // Run save in background (fire-and-forget with error logging)\n Effect.runFork(\n Effect.gen(function* () {\n if (currentState !== undefined) {\n const transformedState = yield* storage.onSave(currentState);\n yield* Effect.catchAll(\n storage.save(documentId, transformedState),\n (error) => Effect.logError(\"Failed to save document\", error)\n );\n }\n })\n );\n\n // Broadcast to subscribers\n Effect.runSync(\n PubSub.publish(pubsub, {\n type: \"transaction\",\n transaction: transactionMessage.transaction as Protocol.Transaction,\n version: transactionMessage.version,\n })\n );\n },\n onRejection: (transactionId, reason) => {\n Effect.runSync(\n PubSub.publish(pubsub, {\n type: \"error\",\n transactionId,\n reason,\n })\n );\n },\n });\n\n const refCount = yield* Ref.make(1);\n\n const instance: DocumentInstance = {\n document: serverDocument,\n pubsub,\n refCount,\n };\n\n // Store in map\n yield* Ref.update(documents, (map) =>\n HashMap.set(map, documentId, instance)\n );\n\n return instance;\n });\n\n // Submit a transaction\n const submit = (\n documentId: string,\n transaction: Transaction.Transaction\n ): Effect.Effect<Protocol.SubmitResult> =>\n Effect.gen(function* () {\n const instance = yield* getOrCreateDocument(documentId);\n const result = instance.document.submit(transaction);\n return result;\n });\n\n // Get a snapshot\n const getSnapshot = (\n documentId: string\n ): Effect.Effect<Protocol.SnapshotMessage> =>\n Effect.gen(function* () {\n const instance = yield* getOrCreateDocument(documentId);\n const snapshot = instance.document.getSnapshot();\n return snapshot;\n });\n\n // Subscribe to broadcasts\n const subscribe = (\n documentId: string\n ): Effect.Effect<\n Stream.Stream<Protocol.ServerBroadcast>,\n never,\n Scope.Scope\n > =>\n Effect.gen(function* () {\n const instance = yield* getOrCreateDocument(documentId);\n\n // Subscribe to the PubSub\n const queue = yield* PubSub.subscribe(instance.pubsub);\n\n // Ensure cleanup on scope close\n yield* Effect.addFinalizer(() =>\n Effect.gen(function* () {\n // Decrement ref count\n const count = yield* Ref.updateAndGet(\n instance.refCount,\n (n) => n - 1\n );\n\n // If no more subscribers, we could clean up the document\n // For now, we keep it alive (could add idle timeout)\n })\n );\n\n // Convert queue to stream\n return Stream.fromQueue(queue);\n });\n\n const manager: DocumentManager = {\n submit,\n getSnapshot,\n subscribe,\n };\n\n return manager;\n});\n\n/**\n * Layer that provides DocumentManager.\n * Requires MimicServerConfigTag and MimicDataStorageTag.\n */\nexport const layer: Layer.Layer<\n DocumentManagerTag,\n never,\n MimicServerConfigTag | MimicDataStorageTag\n> = Layer.effect(DocumentManagerTag, makeDocumentManager);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2EA,IAAa,qBAAb,cAAwC,QAAQ,IAC9C,gDACD,EAAuC,CAAC;;;;AASzC,MAAM,sBAAsB,OAAO,IAAI,aAAa;CAClD,MAAM,SAAS,OAAO;CACtB,MAAM,UAAU,OAAO;CAGvB,MAAM,YAAY,OAAO,IAAI,KAC3B,QAAQ,OAAiC,CAC1C;CAGD,MAAM,uBACJ,eAEA,OAAO,IAAI,aAAa;EACtB,MAAM,UAAU,OAAO,IAAI,IAAI,UAAU;EACzC,MAAM,WAAW,QAAQ,IAAI,SAAS,WAAW;AAEjD,MAAI,SAAS,SAAS,QAAQ;AAE5B,UAAO,IAAI,OAAO,SAAS,MAAM,WAAW,MAAM,IAAI,EAAE;AACxD,UAAO,SAAS;;EAIlB,MAAM,WAAW,OAAO,OAAO,SAC7B,QAAQ,KAAK,WAAW,QAClB,OAAO,QAAQ,OAAU,CAChC;EAGD,MAAM,eAAe,aAAa,SAC9B,OAAO,QAAQ,OAAO,SAAS,GAC/B,OAAO,YAAY,SACjB,OAAO,OAAO,QAAQ,EAAE,YAAY,CAAC,GACrC;EAGN,MAAM,SAAS,OAAO,OAAO,WAAqC;EAGlE,MAAM,iBAAiB,eAAe,KAAK;GACzC,QAAQ,OAAO;GACD;GACd,uBAAuB,OAAO;GAC9B,cAAc,uBAAuB;IAEnC,MAAM,eAAe,eAAe,KAAK;AAGzC,WAAO,QACL,OAAO,IAAI,aAAa;AACtB,SAAI,iBAAiB,QAAW;MAC9B,MAAM,mBAAmB,OAAO,QAAQ,OAAO,aAAa;AAC5D,aAAO,OAAO,SACZ,QAAQ,KAAK,YAAY,iBAAiB,GACzC,UAAU,OAAO,SAAS,2BAA2B,MAAM,CAC7D;;MAEH,CACH;AAGD,WAAO,QACL,OAAO,QAAQ,QAAQ;KACrB,MAAM;KACN,aAAa,mBAAmB;KAChC,SAAS,mBAAmB;KAC7B,CAAC,CACH;;GAEH,cAAc,eAAe,WAAW;AACtC,WAAO,QACL,OAAO,QAAQ,QAAQ;KACrB,MAAM;KACN;KACA;KACD,CAAC,CACH;;GAEJ,CAAC;EAIF,MAAMA,WAA6B;GACjC,UAAU;GACV;GACA,UALe,OAAO,IAAI,KAAK,EAAE;GAMlC;AAGD,SAAO,IAAI,OAAO,YAAY,QAC5B,QAAQ,IAAI,KAAK,YAAY,SAAS,CACvC;AAED,SAAO;GACP;CAGJ,MAAM,UACJ,YACA,gBAEA,OAAO,IAAI,aAAa;AAGtB,UAFiB,OAAO,oBAAoB,WAAW,EAC/B,SAAS,OAAO,YAAY;GAEpD;CAGJ,MAAM,eACJ,eAEA,OAAO,IAAI,aAAa;AAGtB,UAFiB,OAAO,oBAAoB,WAAW,EAC7B,SAAS,aAAa;GAEhD;CAGJ,MAAM,aACJ,eAMA,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAO,oBAAoB,WAAW;EAGvD,MAAM,QAAQ,OAAO,OAAO,UAAU,SAAS,OAAO;AAGtD,SAAO,OAAO,mBACZ,OAAO,IAAI,aAAa;AAER,UAAO,IAAI,aACvB,SAAS,WACR,MAAM,IAAI,EACZ;IAID,CACH;AAGD,SAAO,OAAO,UAAU,MAAM;GAC9B;AAQJ,QANiC;EAC/B;EACA;EACA;EACD;EAGD;;;;;AAMF,MAAaC,QAIT,MAAM,OAAO,oBAAoB,oBAAoB"}
|
package/dist/MimicConfig.cjs
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let effect_Effect = require("effect/Effect");
|
|
3
|
+
effect_Effect = require_rolldown_runtime.__toESM(effect_Effect);
|
|
2
4
|
let effect_Layer = require("effect/Layer");
|
|
3
5
|
effect_Layer = require_rolldown_runtime.__toESM(effect_Layer);
|
|
4
6
|
let effect_Context = require("effect/Context");
|
|
5
7
|
effect_Context = require_rolldown_runtime.__toESM(effect_Context);
|
|
6
8
|
let effect_Duration = require("effect/Duration");
|
|
7
9
|
effect_Duration = require_rolldown_runtime.__toESM(effect_Duration);
|
|
10
|
+
let _voidhash_mimic = require("@voidhash/mimic");
|
|
8
11
|
|
|
9
12
|
//#region src/MimicConfig.ts
|
|
10
13
|
/**
|
|
@@ -17,17 +20,24 @@ var MimicConfig_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
|
17
20
|
make: () => make
|
|
18
21
|
});
|
|
19
22
|
/**
|
|
23
|
+
* Check if a value is an InitialFn (function) rather than a plain object.
|
|
24
|
+
*/
|
|
25
|
+
const isInitialFn = (value) => typeof value === "function";
|
|
26
|
+
/**
|
|
20
27
|
* Create a MimicServerConfig from options.
|
|
21
28
|
*/
|
|
22
29
|
const make = (options) => {
|
|
23
30
|
var _options$maxIdleTime, _options$maxTransacti, _options$heartbeatInt, _options$heartbeatTim;
|
|
31
|
+
const { initial, schema } = options;
|
|
32
|
+
const initialFn = initial === void 0 ? void 0 : isInitialFn(initial) ? (context) => effect_Effect.map(initial(context), (state) => _voidhash_mimic.Primitive.applyDefaults(schema, state)) : () => effect_Effect.succeed(_voidhash_mimic.Primitive.applyDefaults(schema, initial));
|
|
24
33
|
return {
|
|
25
|
-
schema
|
|
34
|
+
schema,
|
|
26
35
|
maxIdleTime: effect_Duration.decode((_options$maxIdleTime = options.maxIdleTime) !== null && _options$maxIdleTime !== void 0 ? _options$maxIdleTime : "5 minutes"),
|
|
27
36
|
maxTransactionHistory: (_options$maxTransacti = options.maxTransactionHistory) !== null && _options$maxTransacti !== void 0 ? _options$maxTransacti : 1e3,
|
|
28
37
|
heartbeatInterval: effect_Duration.decode((_options$heartbeatInt = options.heartbeatInterval) !== null && _options$heartbeatInt !== void 0 ? _options$heartbeatInt : "30 seconds"),
|
|
29
38
|
heartbeatTimeout: effect_Duration.decode((_options$heartbeatTim = options.heartbeatTimeout) !== null && _options$heartbeatTim !== void 0 ? _options$heartbeatTim : "10 seconds"),
|
|
30
|
-
presence: options.presence
|
|
39
|
+
presence: options.presence,
|
|
40
|
+
initial: initialFn
|
|
31
41
|
};
|
|
32
42
|
};
|
|
33
43
|
/**
|
package/dist/MimicConfig.d.cts
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import * as Layer from "effect/Layer";
|
|
2
|
-
import * as Context from "effect/Context";
|
|
3
3
|
import { Presence, Primitive } from "@voidhash/mimic";
|
|
4
|
+
import * as Context from "effect/Context";
|
|
4
5
|
import * as Duration from "effect/Duration";
|
|
5
6
|
import { DurationInput } from "effect/Duration";
|
|
6
7
|
|
|
7
8
|
//#region src/MimicConfig.d.ts
|
|
8
9
|
declare namespace MimicConfig_d_exports {
|
|
9
|
-
export { MimicServerConfig, MimicServerConfigOptions, MimicServerConfigTag, layer, make };
|
|
10
|
+
export { InitialContext, InitialFn, MimicServerConfig, MimicServerConfigOptions, MimicServerConfigTag, layer, make };
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Context available when computing initial state for a document.
|
|
14
|
+
*/
|
|
15
|
+
interface InitialContext {
|
|
16
|
+
/**
|
|
17
|
+
* The document ID being initialized.
|
|
18
|
+
*/
|
|
19
|
+
readonly documentId: string;
|
|
10
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Function that computes initial state for a document.
|
|
23
|
+
* Receives context with the document ID and returns an Effect that produces the initial state.
|
|
24
|
+
*/
|
|
25
|
+
type InitialFn<TSchema extends Primitive.AnyPrimitive> = (context: InitialContext) => Effect.Effect<Primitive.InferSetInput<TSchema>>;
|
|
11
26
|
/**
|
|
12
27
|
* Configuration for the Mimic server.
|
|
13
28
|
*
|
|
@@ -45,6 +60,13 @@ interface MimicServerConfig<TSchema extends Primitive.AnyPrimitive = Primitive.A
|
|
|
45
60
|
* @default undefined (presence disabled)
|
|
46
61
|
*/
|
|
47
62
|
readonly presence: Presence.AnyPresence | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Initial state function for new documents.
|
|
65
|
+
* Called when a document is created and no existing state is found in storage.
|
|
66
|
+
* Receives the document ID and returns an Effect that produces the initial state.
|
|
67
|
+
* @default undefined (documents start empty or use schema defaults)
|
|
68
|
+
*/
|
|
69
|
+
readonly initial: InitialFn<TSchema> | undefined;
|
|
48
70
|
}
|
|
49
71
|
/**
|
|
50
72
|
* Options for creating a MimicServerConfig.
|
|
@@ -80,6 +102,26 @@ interface MimicServerConfigOptions<TSchema extends Primitive.AnyPrimitive = Prim
|
|
|
80
102
|
* @default undefined (presence disabled)
|
|
81
103
|
*/
|
|
82
104
|
readonly presence?: Presence.AnyPresence;
|
|
105
|
+
/**
|
|
106
|
+
* Initial state for new documents.
|
|
107
|
+
* Can be either:
|
|
108
|
+
* - A plain object with the initial state values
|
|
109
|
+
* - A function that receives context (with documentId) and returns an Effect producing the initial state
|
|
110
|
+
*
|
|
111
|
+
* Type-safe: required fields (without defaults) must be provided,
|
|
112
|
+
* while optional fields and fields with defaults can be omitted.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Plain object
|
|
116
|
+
* initial: { title: "New Document", count: 0 }
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // Function returning Effect
|
|
120
|
+
* initial: ({ documentId }) => Effect.succeed({ title: `Doc ${documentId}`, count: 0 })
|
|
121
|
+
*
|
|
122
|
+
* @default undefined (documents start empty or use schema defaults)
|
|
123
|
+
*/
|
|
124
|
+
readonly initial?: Primitive.InferSetInput<TSchema> | InitialFn<TSchema>;
|
|
83
125
|
}
|
|
84
126
|
/**
|
|
85
127
|
* Create a MimicServerConfig from options.
|
|
@@ -95,5 +137,5 @@ declare class MimicServerConfigTag extends MimicServerConfigTag_base {}
|
|
|
95
137
|
*/
|
|
96
138
|
declare const layer: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => Layer.Layer<MimicServerConfigTag>;
|
|
97
139
|
//#endregion
|
|
98
|
-
export { MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
140
|
+
export { InitialFn, MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
99
141
|
//# sourceMappingURL=MimicConfig.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimicConfig.d.cts","names":[],"sources":["../src/MimicConfig.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MimicConfig.d.cts","names":[],"sources":["../src/MimicConfig.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;UAkBiB,cAAA;;;;;AAAjB;AAWA;;;;AAEmB,KAFP,SAEiB,CAAA,gBAFS,SAAA,CAAU,YAEnB,CAAA,GAAA,CAAA,OAAA,EADlB,cACkB,EAAA,GAAxB,MAAA,CAAO,MAAiB,CAAV,SAAA,CAAU,aAAA,CAAc,OAAd,CAAA,CAAA;;;AAY7B;;;;AAYwB,UAZP,iBAYgB,CAAA,gBAXf,SAAA,CAAU,YAWK,GAXU,SAAA,CAAU,YAWpB,CAAA,CAAA;EAYH;;;EAqBA,SAAA,MAAA,EAvCX,OAuCW;EAAV;;AAMpB;;EAC2C,SAAU,WAAA,EAxC7B,QAAA,CAAS,QAwCoB;EAKlC;;;;EA+BG,SAAS,qBAAA,EAAA,MAAA;EAqBc;;;;EAAoB,SAAA,iBAAA,EArFnC,QAAA,CAAS,QAqF0B;EAapD;;;;EAEQ,SAAA,gBAAA,EA9FQ,QAAA,CAAS,QA8FjB;EAAlB;;AAwBD;;;qBA/GmB,QAAA,CAAS;;;AAwH9B;AAOA;;;EACW,SAAA,OAAA,EAxHS,SAwHT,CAxHmB,OAwHnB,CAAA,GAAA,SAAA;;;;;UAlHM,yCACC,SAAA,CAAU,eAAe,SAAA,CAAU;;;;mBAKlC;;;;;yBAMM;;;;;;;;;;+BAYM;;;;;8BAMD;;;;;;sBAOR,QAAA,CAAS;;;;;;;;;;;;;;;;;;;;qBAqBV,SAAA,CAAU,cAAc,WAAW,UAAU;;;;;cAarD,uBAAwB,SAAA,CAAU,uBACpC,yBAAyB,aACjC,kBAAkB;cAwBnB;;;;cASW,oBAAA,SAA6B,yBAAA;;;;cAO7B,wBAAyB,SAAA,CAAU,uBACrC,yBAAyB,aACjC,KAAA,CAAM,MAAM"}
|
package/dist/MimicConfig.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import * as Layer from "effect/Layer";
|
|
2
3
|
import * as Context from "effect/Context";
|
|
3
4
|
import * as Duration from "effect/Duration";
|
|
@@ -6,8 +7,22 @@ import { Presence, Primitive } from "@voidhash/mimic";
|
|
|
6
7
|
|
|
7
8
|
//#region src/MimicConfig.d.ts
|
|
8
9
|
declare namespace MimicConfig_d_exports {
|
|
9
|
-
export { MimicServerConfig, MimicServerConfigOptions, MimicServerConfigTag, layer, make };
|
|
10
|
+
export { InitialContext, InitialFn, MimicServerConfig, MimicServerConfigOptions, MimicServerConfigTag, layer, make };
|
|
10
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Context available when computing initial state for a document.
|
|
14
|
+
*/
|
|
15
|
+
interface InitialContext {
|
|
16
|
+
/**
|
|
17
|
+
* The document ID being initialized.
|
|
18
|
+
*/
|
|
19
|
+
readonly documentId: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Function that computes initial state for a document.
|
|
23
|
+
* Receives context with the document ID and returns an Effect that produces the initial state.
|
|
24
|
+
*/
|
|
25
|
+
type InitialFn<TSchema extends Primitive.AnyPrimitive> = (context: InitialContext) => Effect.Effect<Primitive.InferSetInput<TSchema>>;
|
|
11
26
|
/**
|
|
12
27
|
* Configuration for the Mimic server.
|
|
13
28
|
*
|
|
@@ -45,6 +60,13 @@ interface MimicServerConfig<TSchema extends Primitive.AnyPrimitive = Primitive.A
|
|
|
45
60
|
* @default undefined (presence disabled)
|
|
46
61
|
*/
|
|
47
62
|
readonly presence: Presence.AnyPresence | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Initial state function for new documents.
|
|
65
|
+
* Called when a document is created and no existing state is found in storage.
|
|
66
|
+
* Receives the document ID and returns an Effect that produces the initial state.
|
|
67
|
+
* @default undefined (documents start empty or use schema defaults)
|
|
68
|
+
*/
|
|
69
|
+
readonly initial: InitialFn<TSchema> | undefined;
|
|
48
70
|
}
|
|
49
71
|
/**
|
|
50
72
|
* Options for creating a MimicServerConfig.
|
|
@@ -80,6 +102,26 @@ interface MimicServerConfigOptions<TSchema extends Primitive.AnyPrimitive = Prim
|
|
|
80
102
|
* @default undefined (presence disabled)
|
|
81
103
|
*/
|
|
82
104
|
readonly presence?: Presence.AnyPresence;
|
|
105
|
+
/**
|
|
106
|
+
* Initial state for new documents.
|
|
107
|
+
* Can be either:
|
|
108
|
+
* - A plain object with the initial state values
|
|
109
|
+
* - A function that receives context (with documentId) and returns an Effect producing the initial state
|
|
110
|
+
*
|
|
111
|
+
* Type-safe: required fields (without defaults) must be provided,
|
|
112
|
+
* while optional fields and fields with defaults can be omitted.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* // Plain object
|
|
116
|
+
* initial: { title: "New Document", count: 0 }
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* // Function returning Effect
|
|
120
|
+
* initial: ({ documentId }) => Effect.succeed({ title: `Doc ${documentId}`, count: 0 })
|
|
121
|
+
*
|
|
122
|
+
* @default undefined (documents start empty or use schema defaults)
|
|
123
|
+
*/
|
|
124
|
+
readonly initial?: Primitive.InferSetInput<TSchema> | InitialFn<TSchema>;
|
|
83
125
|
}
|
|
84
126
|
/**
|
|
85
127
|
* Create a MimicServerConfig from options.
|
|
@@ -95,5 +137,5 @@ declare class MimicServerConfigTag extends MimicServerConfigTag_base {}
|
|
|
95
137
|
*/
|
|
96
138
|
declare const layer: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => Layer.Layer<MimicServerConfigTag>;
|
|
97
139
|
//#endregion
|
|
98
|
-
export { MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
140
|
+
export { InitialFn, MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
99
141
|
//# sourceMappingURL=MimicConfig.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimicConfig.d.mts","names":[],"sources":["../src/MimicConfig.ts"],"sourcesContent":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MimicConfig.d.mts","names":[],"sources":["../src/MimicConfig.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;UAkBiB,cAAA;;;;;AAAjB;AAWA;;;;AAEmB,KAFP,SAEiB,CAAA,gBAFS,SAAA,CAAU,YAEnB,CAAA,GAAA,CAAA,OAAA,EADlB,cACkB,EAAA,GAAxB,MAAA,CAAO,MAAiB,CAAV,SAAA,CAAU,aAAA,CAAc,OAAd,CAAA,CAAA;;;AAY7B;;;;AAYwB,UAZP,iBAYgB,CAAA,gBAXf,SAAA,CAAU,YAWK,GAXU,SAAA,CAAU,YAWpB,CAAA,CAAA;EAYH;;;EAqBA,SAAA,MAAA,EAvCX,OAuCW;EAAV;;AAMpB;;EAC2C,SAAU,WAAA,EAxC7B,QAAA,CAAS,QAwCoB;EAKlC;;;;EA+BG,SAAS,qBAAA,EAAA,MAAA;EAqBc;;;;EAAoB,SAAA,iBAAA,EArFnC,QAAA,CAAS,QAqF0B;EAapD;;;;EAEQ,SAAA,gBAAA,EA9FQ,QAAA,CAAS,QA8FjB;EAAlB;;AAwBD;;;qBA/GmB,QAAA,CAAS;;;AAwH9B;AAOA;;;EACW,SAAA,OAAA,EAxHS,SAwHT,CAxHmB,OAwHnB,CAAA,GAAA,SAAA;;;;;UAlHM,yCACC,SAAA,CAAU,eAAe,SAAA,CAAU;;;;mBAKlC;;;;;yBAMM;;;;;;;;;;+BAYM;;;;;8BAMD;;;;;;sBAOR,QAAA,CAAS;;;;;;;;;;;;;;;;;;;;qBAqBV,SAAA,CAAU,cAAc,WAAW,UAAU;;;;;cAarD,uBAAwB,SAAA,CAAU,uBACpC,yBAAyB,aACjC,kBAAkB;cAwBnB;;;;cASW,oBAAA,SAA6B,yBAAA;;;;cAO7B,wBAAyB,SAAA,CAAU,uBACrC,yBAAyB,aACjC,KAAA,CAAM,MAAM"}
|
package/dist/MimicConfig.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { __export } from "./_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
2
3
|
import * as Layer from "effect/Layer";
|
|
3
4
|
import * as Context from "effect/Context";
|
|
4
5
|
import * as Duration from "effect/Duration";
|
|
6
|
+
import { Primitive } from "@voidhash/mimic";
|
|
5
7
|
|
|
6
8
|
//#region src/MimicConfig.ts
|
|
7
9
|
/**
|
|
@@ -14,17 +16,24 @@ var MimicConfig_exports = /* @__PURE__ */ __export({
|
|
|
14
16
|
make: () => make
|
|
15
17
|
});
|
|
16
18
|
/**
|
|
19
|
+
* Check if a value is an InitialFn (function) rather than a plain object.
|
|
20
|
+
*/
|
|
21
|
+
const isInitialFn = (value) => typeof value === "function";
|
|
22
|
+
/**
|
|
17
23
|
* Create a MimicServerConfig from options.
|
|
18
24
|
*/
|
|
19
25
|
const make = (options) => {
|
|
20
26
|
var _options$maxIdleTime, _options$maxTransacti, _options$heartbeatInt, _options$heartbeatTim;
|
|
27
|
+
const { initial, schema } = options;
|
|
28
|
+
const initialFn = initial === void 0 ? void 0 : isInitialFn(initial) ? (context) => Effect.map(initial(context), (state) => Primitive.applyDefaults(schema, state)) : () => Effect.succeed(Primitive.applyDefaults(schema, initial));
|
|
21
29
|
return {
|
|
22
|
-
schema
|
|
30
|
+
schema,
|
|
23
31
|
maxIdleTime: Duration.decode((_options$maxIdleTime = options.maxIdleTime) !== null && _options$maxIdleTime !== void 0 ? _options$maxIdleTime : "5 minutes"),
|
|
24
32
|
maxTransactionHistory: (_options$maxTransacti = options.maxTransactionHistory) !== null && _options$maxTransacti !== void 0 ? _options$maxTransacti : 1e3,
|
|
25
33
|
heartbeatInterval: Duration.decode((_options$heartbeatInt = options.heartbeatInterval) !== null && _options$heartbeatInt !== void 0 ? _options$heartbeatInt : "30 seconds"),
|
|
26
34
|
heartbeatTimeout: Duration.decode((_options$heartbeatTim = options.heartbeatTimeout) !== null && _options$heartbeatTim !== void 0 ? _options$heartbeatTim : "10 seconds"),
|
|
27
|
-
presence: options.presence
|
|
35
|
+
presence: options.presence,
|
|
36
|
+
initial: initialFn
|
|
28
37
|
};
|
|
29
38
|
};
|
|
30
39
|
/**
|
package/dist/MimicConfig.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MimicConfig.mjs","names":[],"sources":["../src/MimicConfig.ts"],"sourcesContent":["/**\n * @since 0.0.1\n * Configuration types for the Mimic server.\n */\nimport * as Context from \"effect/Context\";\nimport * as Duration from \"effect/Duration\";\nimport type { DurationInput } from \"effect/Duration\";\nimport * as Layer from \"effect/Layer\";\nimport
|
|
1
|
+
{"version":3,"file":"MimicConfig.mjs","names":["initialFn: InitialFn<TSchema> | undefined"],"sources":["../src/MimicConfig.ts"],"sourcesContent":["/**\n * @since 0.0.1\n * Configuration types for the Mimic server.\n */\nimport * as Context from \"effect/Context\";\nimport * as Duration from \"effect/Duration\";\nimport type { DurationInput } from \"effect/Duration\";\nimport * as Effect from \"effect/Effect\";\nimport * as Layer from \"effect/Layer\";\nimport { Primitive, Presence } from \"@voidhash/mimic\";\n\n// =============================================================================\n// Initial State Types\n// =============================================================================\n\n/**\n * Context available when computing initial state for a document.\n */\nexport interface InitialContext {\n /**\n * The document ID being initialized.\n */\n readonly documentId: string;\n}\n\n/**\n * Function that computes initial state for a document.\n * Receives context with the document ID and returns an Effect that produces the initial state.\n */\nexport type InitialFn<TSchema extends Primitive.AnyPrimitive> = (\n context: InitialContext\n) => Effect.Effect<Primitive.InferSetInput<TSchema>>;\n\n// =============================================================================\n// Mimic Server Configuration\n// =============================================================================\n\n/**\n * Configuration for the Mimic server.\n * \n * Note: Authentication and persistence are now handled by injectable services\n * (MimicAuthService and MimicDataStorage) rather than config options.\n */\nexport interface MimicServerConfig<\n TSchema extends Primitive.AnyPrimitive = Primitive.AnyPrimitive,\n> {\n /**\n * The schema defining the document structure.\n */\n readonly schema: TSchema;\n\n /**\n * Maximum idle time for a document before it is cleaned up.\n * @default \"5 minutes\"\n */\n readonly maxIdleTime: Duration.Duration;\n\n /**\n * Maximum number of processed transaction IDs to track for deduplication.\n * @default 1000\n */\n readonly maxTransactionHistory: number;\n\n /**\n * Heartbeat interval for WebSocket connections.\n * @default \"30 seconds\"\n */\n readonly heartbeatInterval: Duration.Duration;\n\n /**\n * Timeout for heartbeat responses before considering connection dead.\n * @default \"10 seconds\"\n */\n readonly heartbeatTimeout: Duration.Duration;\n\n /**\n * Optional presence schema for ephemeral per-user data.\n * When provided, enables presence features on WebSocket connections.\n * @default undefined (presence disabled)\n */\n readonly presence: Presence.AnyPresence | undefined;\n\n /**\n * Initial state function for new documents.\n * Called when a document is created and no existing state is found in storage.\n * Receives the document ID and returns an Effect that produces the initial state.\n * @default undefined (documents start empty or use schema defaults)\n */\n readonly initial: InitialFn<TSchema> | undefined;\n}\n\n/**\n * Options for creating a MimicServerConfig.\n */\nexport interface MimicServerConfigOptions<\n TSchema extends Primitive.AnyPrimitive = Primitive.AnyPrimitive,\n> {\n /**\n * The schema defining the document structure.\n */\n readonly schema: TSchema;\n\n /**\n * Maximum idle time for a document before it is cleaned up.\n * @default \"5 minutes\"\n */\n readonly maxIdleTime?: DurationInput;\n\n /**\n * Maximum number of processed transaction IDs to track for deduplication.\n * @default 1000\n */\n readonly maxTransactionHistory?: number;\n\n /**\n * Heartbeat interval for WebSocket connections.\n * @default \"30 seconds\"\n */\n readonly heartbeatInterval?: DurationInput;\n\n /**\n * Timeout for heartbeat responses.\n * @default \"10 seconds\"\n */\n readonly heartbeatTimeout?: DurationInput;\n\n /**\n * Optional presence schema for ephemeral per-user data.\n * When provided, enables presence features on WebSocket connections.\n * @default undefined (presence disabled)\n */\n readonly presence?: Presence.AnyPresence;\n\n /**\n * Initial state for new documents.\n * Can be either:\n * - A plain object with the initial state values\n * - A function that receives context (with documentId) and returns an Effect producing the initial state\n *\n * Type-safe: required fields (without defaults) must be provided,\n * while optional fields and fields with defaults can be omitted.\n *\n * @example\n * // Plain object\n * initial: { title: \"New Document\", count: 0 }\n *\n * @example\n * // Function returning Effect\n * initial: ({ documentId }) => Effect.succeed({ title: `Doc ${documentId}`, count: 0 })\n *\n * @default undefined (documents start empty or use schema defaults)\n */\n readonly initial?: Primitive.InferSetInput<TSchema> | InitialFn<TSchema>;\n}\n\n/**\n * Check if a value is an InitialFn (function) rather than a plain object.\n */\nconst isInitialFn = <TSchema extends Primitive.AnyPrimitive>(\n value: Primitive.InferSetInput<TSchema> | InitialFn<TSchema> | undefined\n): value is InitialFn<TSchema> => typeof value === \"function\";\n\n/**\n * Create a MimicServerConfig from options.\n */\nexport const make = <TSchema extends Primitive.AnyPrimitive>(\n options: MimicServerConfigOptions<TSchema>\n): MimicServerConfig<TSchema> => {\n const { initial, schema } = options;\n\n // Convert initial to a function that applies defaults\n const initialFn: InitialFn<TSchema> | undefined = initial === undefined\n ? undefined\n : isInitialFn<TSchema>(initial)\n ? (context) => Effect.map(\n initial(context),\n (state) => Primitive.applyDefaults(schema, state as Partial<Primitive.InferState<TSchema>>)\n ) as Effect.Effect<Primitive.InferSetInput<TSchema>>\n : () => Effect.succeed(\n Primitive.applyDefaults(schema, initial as Partial<Primitive.InferState<TSchema>>)\n ) as Effect.Effect<Primitive.InferSetInput<TSchema>>;\n\n return {\n schema,\n maxIdleTime: Duration.decode(options.maxIdleTime ?? \"5 minutes\"),\n maxTransactionHistory: options.maxTransactionHistory ?? 1000,\n heartbeatInterval: Duration.decode(options.heartbeatInterval ?? \"30 seconds\"),\n heartbeatTimeout: Duration.decode(options.heartbeatTimeout ?? \"10 seconds\"),\n presence: options.presence,\n initial: initialFn,\n };\n};\n\n// =============================================================================\n// Context Tag\n// =============================================================================\n\n/**\n * Context tag for MimicServerConfig.\n */\nexport class MimicServerConfigTag extends Context.Tag(\n \"@voidhash/mimic-server-effect/MimicServerConfig\"\n)<MimicServerConfigTag, MimicServerConfig>() {}\n\n/**\n * Create a Layer that provides MimicServerConfig.\n */\nexport const layer = <TSchema extends Primitive.AnyPrimitive>(\n options: MimicServerConfigOptions<TSchema>\n): Layer.Layer<MimicServerConfigTag> =>\n Layer.succeed(MimicServerConfigTag, make(options) as unknown as MimicServerConfig);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8JA,MAAM,eACJ,UACgC,OAAO,UAAU;;;;AAKnD,MAAa,QACX,YAC+B;;CAC/B,MAAM,EAAE,SAAS,WAAW;CAG5B,MAAMA,YAA4C,YAAY,SAC1D,SACA,YAAqB,QAAQ,IAC1B,YAAY,OAAO,IAClB,QAAQ,QAAQ,GACf,UAAU,UAAU,cAAc,QAAQ,MAAgD,CAC5F,SACK,OAAO,QACX,UAAU,cAAc,QAAQ,QAAkD,CACnF;AAEP,QAAO;EACL;EACA,aAAa,SAAS,+BAAO,QAAQ,kFAAe,YAAY;EAChE,gDAAuB,QAAQ,8FAAyB;EACxD,mBAAmB,SAAS,gCAAO,QAAQ,0FAAqB,aAAa;EAC7E,kBAAkB,SAAS,gCAAO,QAAQ,yFAAoB,aAAa;EAC3E,UAAU,QAAQ;EAClB,SAAS;EACV;;;;;AAUH,IAAa,uBAAb,cAA0C,QAAQ,IAChD,kDACD,EAA2C,CAAC;;;;AAK7C,MAAa,SACX,YAEA,MAAM,QAAQ,sBAAsB,KAAK,QAAQ,CAAiC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
4
|
+
import * as effect_Types0 from "effect/Types";
|
|
5
|
+
import * as effect_Cause0 from "effect/Cause";
|
|
6
6
|
|
|
7
7
|
//#region src/MimicDataStorage.d.ts
|
|
8
8
|
declare namespace MimicDataStorage_d_exports {
|
|
9
9
|
export { MimicDataStorage, MimicDataStorageTag, StorageDeleteError, StorageError, StorageLoadError, StorageSaveError, layer, layerEffect, make };
|
|
10
10
|
}
|
|
11
|
-
declare const StorageLoadError_base: new <A extends Record<string, any> = {}>(args:
|
|
11
|
+
declare const StorageLoadError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause0.YieldableError & {
|
|
12
12
|
readonly _tag: "StorageLoadError";
|
|
13
13
|
} & Readonly<A>;
|
|
14
14
|
/**
|
|
@@ -20,7 +20,7 @@ declare class StorageLoadError extends StorageLoadError_base<{
|
|
|
20
20
|
}> {
|
|
21
21
|
get message(): string;
|
|
22
22
|
}
|
|
23
|
-
declare const StorageSaveError_base: new <A extends Record<string, any> = {}>(args:
|
|
23
|
+
declare const StorageSaveError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause0.YieldableError & {
|
|
24
24
|
readonly _tag: "StorageSaveError";
|
|
25
25
|
} & Readonly<A>;
|
|
26
26
|
/**
|
|
@@ -32,7 +32,7 @@ declare class StorageSaveError extends StorageSaveError_base<{
|
|
|
32
32
|
}> {
|
|
33
33
|
get message(): string;
|
|
34
34
|
}
|
|
35
|
-
declare const StorageDeleteError_base: new <A extends Record<string, any> = {}>(args:
|
|
35
|
+
declare const StorageDeleteError_base: new <A extends Record<string, any> = {}>(args: effect_Types0.Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P] }) => effect_Cause0.YieldableError & {
|
|
36
36
|
readonly _tag: "StorageDeleteError";
|
|
37
37
|
} & Readonly<A>;
|
|
38
38
|
/**
|