@voidhash/mimic-effect 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +23 -23
- package/dist/DocumentManager.cjs +1 -1
- 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 +1 -1
- package/dist/DocumentManager.mjs.map +1 -1
- package/dist/MimicAuthService.d.cts +1 -1
- package/dist/MimicConfig.cjs +10 -2
- package/dist/MimicConfig.d.cts +34 -8
- package/dist/MimicConfig.d.cts.map +1 -1
- package/dist/MimicConfig.d.mts +34 -8
- package/dist/MimicConfig.d.mts.map +1 -1
- package/dist/MimicConfig.mjs +9 -2
- package/dist/MimicConfig.mjs.map +1 -1
- package/dist/MimicDataStorage.d.cts +1 -1
- package/dist/MimicServer.cjs +20 -17
- package/dist/MimicServer.d.cts +20 -10
- package/dist/MimicServer.d.cts.map +1 -1
- package/dist/MimicServer.d.mts +20 -10
- package/dist/MimicServer.d.mts.map +1 -1
- package/dist/MimicServer.mjs +20 -17
- package/dist/MimicServer.mjs.map +1 -1
- package/dist/PresenceManager.d.cts +1 -1
- package/package.json +3 -3
- package/src/DocumentManager.ts +5 -3
- package/src/MimicConfig.ts +79 -20
- package/src/MimicServer.ts +68 -42
- package/tests/DocumentManager.test.ts +63 -0
- package/tests/MimicConfig.test.ts +53 -10
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @voidhash/mimic-effect@0.0.
|
|
2
|
+
> @voidhash/mimic-effect@0.0.6 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
|
|
@@ -10,13 +10,13 @@
|
|
|
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
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
|
|
14
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentManager.cjs [2m 4.
|
|
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
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicConfig.cjs [2m 2.32 kB[22m [2m│ gzip: 0.79 kB[22m
|
|
20
20
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mstorage/InMemoryDataStorage.cjs [2m 2.21 kB[22m [2m│ gzip: 0.80 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
|
|
@@ -26,23 +26,23 @@
|
|
|
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: 52.
|
|
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/[
|
|
34
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.d.cts.map [2m0.84 kB[22m [2m│ gzip: 0.44 kB[22m
|
|
34
35
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22merrors.d.cts.map [2m0.77 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
35
36
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mWebSocketHandler.d.cts.map [2m0.74 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
36
37
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mPresenceManager.d.cts.map [2m0.69 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
37
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.d.cts.map [2m0.63 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
38
38
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentManager.d.cts.map [2m0.52 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
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[32mMimicConfig.d.cts[39m [2m5.14 kB[22m [2m│ gzip: 1.43 kB[22m
|
|
42
43
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicDataStorage.d.cts[39m [2m4.84 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
43
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[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
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicServer.d.cts[39m [2m4.00 kB[22m [2m│ gzip: 1.47 kB[22m
|
|
46
46
|
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mDocumentProtocol.d.cts[39m [2m3.78 kB[22m [2m│ gzip: 0.78 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
|
|
@@ -50,40 +50,40 @@
|
|
|
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 [32m6139ms[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
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
|
|
58
59
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mPresenceManager.mjs.map [2m10.45 kB[22m [2m│ gzip: 2.54 kB[22m
|
|
59
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.mjs.map [2m 9.
|
|
60
|
-
[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
|
|
61
62
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicDataStorage.mjs.map [2m 6.27 kB[22m [2m│ gzip: 1.55 kB[22m
|
|
62
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[
|
|
63
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.mjs [2m 5.12 kB[22m [2m│ gzip: 1.69 kB[22m
|
|
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
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicConfig.mjs [2m 1.90 kB[22m [2m│ gzip: 0.70 kB[22m
|
|
75
75
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mauth/NoAuth.mjs.map [2m 1.82 kB[22m [2m│ gzip: 0.68 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
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
|
|
82
|
-
[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
|
|
83
84
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22merrors.d.mts.map [2m 0.77 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
84
85
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mWebSocketHandler.d.mts.map [2m 0.74 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
85
86
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mPresenceManager.d.mts.map [2m 0.69 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
86
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.d.mts.map [2m 0.63 kB[22m [2m│ gzip: 0.33 kB[22m
|
|
87
87
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.d.mts.map [2m 0.52 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
88
88
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs [2m 0.47 kB[22m [2m│ gzip: 0.30 kB[22m
|
|
89
89
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs [2m 0.43 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
@@ -93,10 +93,10 @@
|
|
|
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[32mMimicConfig.d.mts[39m [2m 5.14 kB[22m [2m│ gzip: 1.42 kB[22m
|
|
96
97
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicDataStorage.d.mts[39m [2m 4.84 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
97
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[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
|
-
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicServer.d.mts[39m [2m 4.00 kB[22m [2m│ gzip: 1.47 kB[22m
|
|
100
100
|
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mDocumentProtocol.d.mts[39m [2m 3.78 kB[22m [2m│ gzip: 0.78 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
|
|
@@ -104,5 +104,5 @@
|
|
|
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 [32m6149ms[39m
|
package/dist/DocumentManager.cjs
CHANGED
|
@@ -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) : config.initial;
|
|
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,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ServerBroadcast, SnapshotMessage, SubmitResult } from "./DocumentProtocol.cjs";
|
|
2
2
|
import { MimicServerConfigTag } from "./MimicConfig.cjs";
|
|
3
3
|
import { MimicDataStorageTag } from "./MimicDataStorage.cjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
4
5
|
import * as Layer from "effect/Layer";
|
|
5
6
|
import { Transaction } from "@voidhash/mimic";
|
|
6
|
-
import * as Effect from "effect/Effect";
|
|
7
7
|
import * as Context from "effect/Context";
|
|
8
8
|
import * as Scope from "effect/Scope";
|
|
9
9
|
import * as Stream from "effect/Stream";
|
|
@@ -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
|
@@ -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) : config.initial;
|
|
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, or
|
|
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,4 +1,6 @@
|
|
|
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");
|
|
@@ -18,18 +20,24 @@ var MimicConfig_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
|
18
20
|
make: () => make
|
|
19
21
|
});
|
|
20
22
|
/**
|
|
23
|
+
* Check if a value is an InitialFn (function) rather than a plain object.
|
|
24
|
+
*/
|
|
25
|
+
const isInitialFn = (value) => typeof value === "function";
|
|
26
|
+
/**
|
|
21
27
|
* Create a MimicServerConfig from options.
|
|
22
28
|
*/
|
|
23
29
|
const make = (options) => {
|
|
24
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));
|
|
25
33
|
return {
|
|
26
|
-
schema
|
|
34
|
+
schema,
|
|
27
35
|
maxIdleTime: effect_Duration.decode((_options$maxIdleTime = options.maxIdleTime) !== null && _options$maxIdleTime !== void 0 ? _options$maxIdleTime : "5 minutes"),
|
|
28
36
|
maxTransactionHistory: (_options$maxTransacti = options.maxTransactionHistory) !== null && _options$maxTransacti !== void 0 ? _options$maxTransacti : 1e3,
|
|
29
37
|
heartbeatInterval: effect_Duration.decode((_options$heartbeatInt = options.heartbeatInterval) !== null && _options$heartbeatInt !== void 0 ? _options$heartbeatInt : "30 seconds"),
|
|
30
38
|
heartbeatTimeout: effect_Duration.decode((_options$heartbeatTim = options.heartbeatTimeout) !== null && _options$heartbeatTim !== void 0 ? _options$heartbeatTim : "10 seconds"),
|
|
31
39
|
presence: options.presence,
|
|
32
|
-
initial:
|
|
40
|
+
initial: initialFn
|
|
33
41
|
};
|
|
34
42
|
};
|
|
35
43
|
/**
|
package/dist/MimicConfig.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
1
2
|
import * as Layer from "effect/Layer";
|
|
2
3
|
import { Presence, Primitive } from "@voidhash/mimic";
|
|
3
4
|
import * as Context from "effect/Context";
|
|
@@ -6,8 +7,22 @@ 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 };
|
|
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
|
*
|
|
@@ -46,11 +61,12 @@ interface MimicServerConfig<TSchema extends Primitive.AnyPrimitive = Primitive.A
|
|
|
46
61
|
*/
|
|
47
62
|
readonly presence: Presence.AnyPresence | undefined;
|
|
48
63
|
/**
|
|
49
|
-
* Initial state for new documents.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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)
|
|
52
68
|
*/
|
|
53
|
-
readonly initial:
|
|
69
|
+
readonly initial: InitialFn<TSchema> | undefined;
|
|
54
70
|
}
|
|
55
71
|
/**
|
|
56
72
|
* Options for creating a MimicServerConfig.
|
|
@@ -88,14 +104,24 @@ interface MimicServerConfigOptions<TSchema extends Primitive.AnyPrimitive = Prim
|
|
|
88
104
|
readonly presence?: Presence.AnyPresence;
|
|
89
105
|
/**
|
|
90
106
|
* Initial state for new documents.
|
|
91
|
-
*
|
|
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
|
|
92
110
|
*
|
|
93
111
|
* Type-safe: required fields (without defaults) must be provided,
|
|
94
112
|
* while optional fields and fields with defaults can be omitted.
|
|
95
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
|
+
*
|
|
96
122
|
* @default undefined (documents start empty or use schema defaults)
|
|
97
123
|
*/
|
|
98
|
-
readonly initial?: Primitive.InferSetInput<TSchema>;
|
|
124
|
+
readonly initial?: Primitive.InferSetInput<TSchema> | InitialFn<TSchema>;
|
|
99
125
|
}
|
|
100
126
|
/**
|
|
101
127
|
* Create a MimicServerConfig from options.
|
|
@@ -111,5 +137,5 @@ declare class MimicServerConfigTag extends MimicServerConfigTag_base {}
|
|
|
111
137
|
*/
|
|
112
138
|
declare const layer: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => Layer.Layer<MimicServerConfigTag>;
|
|
113
139
|
//#endregion
|
|
114
|
-
export { MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
140
|
+
export { InitialFn, MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
115
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
|
*
|
|
@@ -46,11 +61,12 @@ interface MimicServerConfig<TSchema extends Primitive.AnyPrimitive = Primitive.A
|
|
|
46
61
|
*/
|
|
47
62
|
readonly presence: Presence.AnyPresence | undefined;
|
|
48
63
|
/**
|
|
49
|
-
* Initial state for new documents.
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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)
|
|
52
68
|
*/
|
|
53
|
-
readonly initial:
|
|
69
|
+
readonly initial: InitialFn<TSchema> | undefined;
|
|
54
70
|
}
|
|
55
71
|
/**
|
|
56
72
|
* Options for creating a MimicServerConfig.
|
|
@@ -88,14 +104,24 @@ interface MimicServerConfigOptions<TSchema extends Primitive.AnyPrimitive = Prim
|
|
|
88
104
|
readonly presence?: Presence.AnyPresence;
|
|
89
105
|
/**
|
|
90
106
|
* Initial state for new documents.
|
|
91
|
-
*
|
|
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
|
|
92
110
|
*
|
|
93
111
|
* Type-safe: required fields (without defaults) must be provided,
|
|
94
112
|
* while optional fields and fields with defaults can be omitted.
|
|
95
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
|
+
*
|
|
96
122
|
* @default undefined (documents start empty or use schema defaults)
|
|
97
123
|
*/
|
|
98
|
-
readonly initial?: Primitive.InferSetInput<TSchema>;
|
|
124
|
+
readonly initial?: Primitive.InferSetInput<TSchema> | InitialFn<TSchema>;
|
|
99
125
|
}
|
|
100
126
|
/**
|
|
101
127
|
* Create a MimicServerConfig from options.
|
|
@@ -111,5 +137,5 @@ declare class MimicServerConfigTag extends MimicServerConfigTag_base {}
|
|
|
111
137
|
*/
|
|
112
138
|
declare const layer: <TSchema extends Primitive.AnyPrimitive>(options: MimicServerConfigOptions<TSchema>) => Layer.Layer<MimicServerConfigTag>;
|
|
113
139
|
//#endregion
|
|
114
|
-
export { MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
140
|
+
export { InitialFn, MimicConfig_d_exports, MimicServerConfigOptions, MimicServerConfigTag };
|
|
115
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,4 +1,5 @@
|
|
|
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";
|
|
@@ -15,18 +16,24 @@ var MimicConfig_exports = /* @__PURE__ */ __export({
|
|
|
15
16
|
make: () => make
|
|
16
17
|
});
|
|
17
18
|
/**
|
|
19
|
+
* Check if a value is an InitialFn (function) rather than a plain object.
|
|
20
|
+
*/
|
|
21
|
+
const isInitialFn = (value) => typeof value === "function";
|
|
22
|
+
/**
|
|
18
23
|
* Create a MimicServerConfig from options.
|
|
19
24
|
*/
|
|
20
25
|
const make = (options) => {
|
|
21
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));
|
|
22
29
|
return {
|
|
23
|
-
schema
|
|
30
|
+
schema,
|
|
24
31
|
maxIdleTime: Duration.decode((_options$maxIdleTime = options.maxIdleTime) !== null && _options$maxIdleTime !== void 0 ? _options$maxIdleTime : "5 minutes"),
|
|
25
32
|
maxTransactionHistory: (_options$maxTransacti = options.maxTransactionHistory) !== null && _options$maxTransacti !== void 0 ? _options$maxTransacti : 1e3,
|
|
26
33
|
heartbeatInterval: Duration.decode((_options$heartbeatInt = options.heartbeatInterval) !== null && _options$heartbeatInt !== void 0 ? _options$heartbeatInt : "30 seconds"),
|
|
27
34
|
heartbeatTimeout: Duration.decode((_options$heartbeatTim = options.heartbeatTimeout) !== null && _options$heartbeatTim !== void 0 ? _options$heartbeatTim : "10 seconds"),
|
|
28
35
|
presence: options.presence,
|
|
29
|
-
initial:
|
|
36
|
+
initial: initialFn
|
|
30
37
|
};
|
|
31
38
|
};
|
|
32
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 { Primitive, Presence } from \"@voidhash/mimic\";\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
|
|
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"}
|
package/dist/MimicServer.cjs
CHANGED
|
@@ -94,23 +94,26 @@ const makeMimicHandler = effect_Effect.gen(function* () {
|
|
|
94
94
|
* );
|
|
95
95
|
* ```
|
|
96
96
|
*/
|
|
97
|
-
const layerHttpLayerRouter = (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
const
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
97
|
+
const layerHttpLayerRouter = (optionsEf) => {
|
|
98
|
+
return effect_Layer.unwrapScoped(effect_Effect.gen(function* () {
|
|
99
|
+
var _options$basePath, _options$authLayer, _options$storageLayer;
|
|
100
|
+
const options = yield* optionsEf;
|
|
101
|
+
const wsPath = `${(_options$basePath = options.basePath) !== null && _options$basePath !== void 0 ? _options$basePath : "/mimic"}/doc/*`;
|
|
102
|
+
const configLayer = require_MimicConfig.layer({
|
|
103
|
+
schema: options.schema,
|
|
104
|
+
maxTransactionHistory: options.maxTransactionHistory,
|
|
105
|
+
presence: options.presence,
|
|
106
|
+
initial: options.initial
|
|
107
|
+
});
|
|
108
|
+
const authLayer = (_options$authLayer = options.authLayer) !== null && _options$authLayer !== void 0 ? _options$authLayer : require_NoAuth.layerDefault;
|
|
109
|
+
const storageLayer = (_options$storageLayer = options.storageLayer) !== null && _options$storageLayer !== void 0 ? _options$storageLayer : require_InMemoryDataStorage.layerDefault;
|
|
110
|
+
const depsLayer = effect_Layer.mergeAll(configLayer, authLayer, storageLayer);
|
|
111
|
+
return effect_Layer.scopedDiscard(effect_Effect.gen(function* () {
|
|
112
|
+
const router = yield* _effect_platform.HttpLayerRouter.HttpRouter;
|
|
113
|
+
const handler = yield* makeMimicHandler;
|
|
114
|
+
yield* router.add("GET", wsPath, handler);
|
|
115
|
+
})).pipe(effect_Layer.provide(require_DocumentManager.layer), effect_Layer.provide(require_PresenceManager.layer), effect_Layer.provide(depsLayer));
|
|
116
|
+
}));
|
|
114
117
|
};
|
|
115
118
|
|
|
116
119
|
//#endregion
|