@voidhash/mimic-effect 0.0.2 → 0.0.4
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 +99 -14
- package/dist/DocumentManager.cjs +118 -0
- package/dist/DocumentManager.d.cts +45 -0
- package/dist/DocumentManager.d.cts.map +1 -0
- package/dist/DocumentManager.d.mts +45 -0
- package/dist/DocumentManager.d.mts.map +1 -0
- package/dist/DocumentManager.mjs +105 -0
- package/dist/DocumentManager.mjs.map +1 -0
- package/dist/DocumentProtocol.cjs +94 -0
- package/dist/DocumentProtocol.d.cts +113 -0
- package/dist/DocumentProtocol.d.cts.map +1 -0
- package/dist/DocumentProtocol.d.mts +113 -0
- package/dist/DocumentProtocol.d.mts.map +1 -0
- package/dist/DocumentProtocol.mjs +89 -0
- package/dist/DocumentProtocol.mjs.map +1 -0
- package/dist/MimicAuthService.cjs +55 -0
- package/dist/MimicAuthService.d.cts +65 -0
- package/dist/MimicAuthService.d.cts.map +1 -0
- package/dist/MimicAuthService.d.mts +65 -0
- package/dist/MimicAuthService.d.mts.map +1 -0
- package/dist/MimicAuthService.mjs +47 -0
- package/dist/MimicAuthService.mjs.map +1 -0
- package/dist/MimicConfig.cjs +52 -0
- package/dist/MimicConfig.d.cts +115 -0
- package/dist/MimicConfig.d.cts.map +1 -0
- package/dist/MimicConfig.d.mts +115 -0
- package/dist/MimicConfig.d.mts.map +1 -0
- package/dist/MimicConfig.mjs +43 -0
- package/dist/MimicConfig.mjs.map +1 -0
- package/dist/MimicDataStorage.cjs +83 -0
- package/dist/MimicDataStorage.d.cts +113 -0
- package/dist/MimicDataStorage.d.cts.map +1 -0
- package/dist/MimicDataStorage.d.mts +113 -0
- package/dist/MimicDataStorage.d.mts.map +1 -0
- package/dist/MimicDataStorage.mjs +74 -0
- package/dist/MimicDataStorage.mjs.map +1 -0
- package/dist/MimicServer.cjs +122 -0
- package/dist/MimicServer.d.cts +106 -0
- package/dist/MimicServer.d.cts.map +1 -0
- package/dist/MimicServer.d.mts +106 -0
- package/dist/MimicServer.d.mts.map +1 -0
- package/dist/MimicServer.mjs +116 -0
- package/dist/MimicServer.mjs.map +1 -0
- package/dist/PresenceManager.cjs +108 -0
- package/dist/PresenceManager.d.cts +91 -0
- package/dist/PresenceManager.d.cts.map +1 -0
- package/dist/PresenceManager.d.mts +91 -0
- package/dist/PresenceManager.d.mts.map +1 -0
- package/dist/PresenceManager.mjs +95 -0
- package/dist/PresenceManager.mjs.map +1 -0
- package/dist/WebSocketHandler.cjs +365 -0
- package/dist/WebSocketHandler.d.cts +34 -0
- package/dist/WebSocketHandler.d.cts.map +1 -0
- package/dist/WebSocketHandler.d.mts +34 -0
- package/dist/WebSocketHandler.d.mts.map +1 -0
- package/dist/WebSocketHandler.mjs +355 -0
- package/dist/WebSocketHandler.mjs.map +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.cjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs +14 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.mjs +27 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.cjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPrimitive.mjs +16 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs +18 -0
- package/dist/_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.mjs +12 -0
- package/dist/_virtual/rolldown_runtime.cjs +43 -0
- package/dist/{chunk-C6wwvPpM.mjs → _virtual/rolldown_runtime.mjs} +1 -1
- package/dist/auth/NoAuth.cjs +43 -0
- package/dist/auth/NoAuth.d.cts +22 -0
- package/dist/auth/NoAuth.d.cts.map +1 -0
- package/dist/auth/NoAuth.d.mts +22 -0
- package/dist/auth/NoAuth.d.mts.map +1 -0
- package/dist/auth/NoAuth.mjs +36 -0
- package/dist/auth/NoAuth.mjs.map +1 -0
- package/dist/errors.cjs +74 -0
- package/dist/errors.d.cts +89 -0
- package/dist/errors.d.cts.map +1 -0
- package/dist/errors.d.mts +89 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +67 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.cjs +29 -1227
- package/dist/index.d.cts +12 -795
- package/dist/index.d.mts +12 -795
- package/dist/index.mjs +13 -1162
- package/dist/storage/InMemoryDataStorage.cjs +57 -0
- package/dist/storage/InMemoryDataStorage.d.cts +19 -0
- package/dist/storage/InMemoryDataStorage.d.cts.map +1 -0
- package/dist/storage/InMemoryDataStorage.d.mts +19 -0
- package/dist/storage/InMemoryDataStorage.d.mts.map +1 -0
- package/dist/storage/InMemoryDataStorage.mjs +48 -0
- package/dist/storage/InMemoryDataStorage.mjs.map +1 -0
- package/package.json +3 -3
- package/src/DocumentManager.ts +2 -2
- package/src/MimicConfig.ts +22 -1
- package/src/MimicServer.ts +11 -161
- package/tests/DocumentManager.test.ts +61 -0
- package/tests/MimicConfig.test.ts +72 -0
- package/tests/MimicServer.test.ts +55 -162
- package/tsdown.config.ts +1 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @voidhash/mimic-effect@0.0.
|
|
2
|
+
> @voidhash/mimic-effect@0.0.4 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
|
|
@@ -8,16 +8,101 @@
|
|
|
8
8
|
[34mℹ[39m target: [34mes2017[39m
|
|
9
9
|
[34mℹ[39m tsconfig: [34mtsconfig.json[39m
|
|
10
10
|
[34mℹ[39m Build start
|
|
11
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[1mindex.cjs[22m
|
|
12
|
-
[34mℹ[39m [33m[CJS][39m
|
|
13
|
-
[34mℹ[39m [
|
|
14
|
-
[34mℹ[39m [
|
|
15
|
-
[34mℹ[39m [
|
|
16
|
-
[34mℹ[39m [
|
|
17
|
-
[34mℹ[39m [
|
|
18
|
-
[34mℹ[39m [
|
|
19
|
-
[
|
|
20
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[
|
|
21
|
-
[34mℹ[39m [33m[CJS][39m [2mdist/[
|
|
22
|
-
[34mℹ[39m [33m[CJS][39m
|
|
23
|
-
[
|
|
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.83 kB[22m [2m│ gzip: 2.46 kB[22m
|
|
13
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicServer.cjs [2m 5.93 kB[22m [2m│ gzip: 1.78 kB[22m
|
|
14
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentManager.cjs [2m 4.69 kB[22m [2m│ gzip: 1.38 kB[22m
|
|
15
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mPresenceManager.cjs [2m 4.25 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
16
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicDataStorage.cjs [2m 3.13 kB[22m [2m│ gzip: 0.96 kB[22m
|
|
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/[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
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mstorage/InMemoryDataStorage.cjs [2m 2.21 kB[22m [2m│ gzip: 0.80 kB[22m
|
|
21
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicAuthService.cjs [2m 2.12 kB[22m [2m│ gzip: 0.69 kB[22m
|
|
22
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mauth/NoAuth.cjs [2m 1.52 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
23
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/rolldown_runtime.cjs [2m 1.31 kB[22m [2m│ gzip: 0.61 kB[22m
|
|
24
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/objectSpread2.cjs [2m 0.95 kB[22m [2m│ gzip: 0.43 kB[22m
|
|
25
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/typeof.cjs [2m 0.53 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
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
|
+
[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
|
+
[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.04 kB
|
|
30
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicDataStorage.d.cts.map [2m1.96 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
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/[22mMimicAuthService.d.cts.map [2m0.97 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
33
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mMimicConfig.d.cts.map [2m0.88 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
34
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22merrors.d.cts.map [2m0.77 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
35
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mWebSocketHandler.d.cts.map [2m0.74 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
36
|
+
[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
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mDocumentManager.d.cts.map [2m0.52 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
39
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mstorage/InMemoryDataStorage.d.cts.map [2m0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
40
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22mauth/NoAuth.d.cts.map [2m0.22 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
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[32mMimicDataStorage.d.cts[39m [2m4.84 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
43
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicConfig.d.cts[39m [2m4.11 kB[22m [2m│ gzip: 1.11 kB[22m
|
|
44
|
+
[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
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mDocumentProtocol.d.cts[39m [2m3.78 kB[22m [2m│ gzip: 0.78 kB[22m
|
|
47
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mPresenceManager.d.cts[39m [2m3.00 kB[22m [2m│ gzip: 0.90 kB[22m
|
|
48
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mMimicAuthService.d.cts[39m [2m2.38 kB[22m [2m│ gzip: 0.77 kB[22m
|
|
49
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mDocumentManager.d.cts[39m [2m1.77 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
50
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mWebSocketHandler.d.cts[39m [2m1.73 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
51
|
+
[34mℹ[39m [33m[CJS][39m [2mdist/[22m[32mauth/NoAuth.d.cts[39m [2m0.72 kB[22m [2m│ gzip: 0.40 kB[22m
|
|
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: 41.59 kB
|
|
54
|
+
[32m✔[39m Build complete in [32m6093ms[39m
|
|
55
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[1mindex.mjs[22m [2m 1.45 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
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/[22mWebSocketHandler.mjs [2m12.36 kB[22m [2m│ gzip: 2.34 kB[22m
|
|
58
|
+
[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.84 kB[22m [2m│ gzip: 2.81 kB[22m
|
|
60
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.mjs.map [2m 9.65 kB[22m [2m│ gzip: 3.00 kB[22m
|
|
61
|
+
[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/[22mMimicConfig.mjs.map [2m 5.48 kB[22m [2m│ gzip: 1.50 kB[22m
|
|
63
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicServer.mjs [2m 5.12 kB[22m [2m│ gzip: 1.69 kB[22m
|
|
64
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicAuthService.mjs.map [2m 4.09 kB[22m [2m│ gzip: 1.10 kB[22m
|
|
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.75 kB[22m [2m│ gzip: 1.25 kB[22m
|
|
67
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22merrors.mjs.map [2m 3.53 kB[22m [2m│ gzip: 0.92 kB[22m
|
|
68
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mPresenceManager.mjs [2m 3.38 kB[22m [2m│ gzip: 1.06 kB[22m
|
|
69
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mstorage/InMemoryDataStorage.mjs.map [2m 2.84 kB[22m [2m│ gzip: 1.03 kB[22m
|
|
70
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicDataStorage.mjs [2m 2.66 kB[22m [2m│ gzip: 0.87 kB[22m
|
|
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/[22mMimicDataStorage.d.mts.map [2m 1.96 kB[22m [2m│ gzip: 0.73 kB[22m
|
|
73
|
+
[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
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mauth/NoAuth.mjs.map [2m 1.82 kB[22m [2m│ gzip: 0.68 kB[22m
|
|
76
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mMimicAuthService.mjs [2m 1.74 kB[22m [2m│ gzip: 0.61 kB[22m
|
|
77
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mstorage/InMemoryDataStorage.mjs [2m 1.68 kB[22m [2m│ gzip: 0.71 kB[22m
|
|
78
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentProtocol.d.mts.map [2m 1.35 kB[22m [2m│ gzip: 0.52 kB[22m
|
|
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/[22mMimicAuthService.d.mts.map [2m 0.97 kB[22m [2m│ gzip: 0.51 kB[22m
|
|
81
|
+
[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/[22mMimicConfig.d.mts.map [2m 0.88 kB[22m [2m│ gzip: 0.46 kB[22m
|
|
83
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22merrors.d.mts.map [2m 0.77 kB[22m [2m│ gzip: 0.36 kB[22m
|
|
84
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mWebSocketHandler.d.mts.map [2m 0.74 kB[22m [2m│ gzip: 0.35 kB[22m
|
|
85
|
+
[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
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mDocumentManager.d.mts.map [2m 0.52 kB[22m [2m│ gzip: 0.29 kB[22m
|
|
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
|
+
[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
|
|
90
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/rolldown_runtime.mjs [2m 0.35 kB[22m [2m│ gzip: 0.24 kB[22m
|
|
91
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/defineProperty.mjs [2m 0.35 kB[22m [2m│ gzip: 0.23 kB[22m
|
|
92
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m_virtual/_@oxc-project_runtime@0.103.0/helpers/toPropertyKey.mjs [2m 0.30 kB[22m [2m│ gzip: 0.21 kB[22m
|
|
93
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mstorage/InMemoryDataStorage.d.mts.map [2m 0.26 kB[22m [2m│ gzip: 0.18 kB[22m
|
|
94
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22mauth/NoAuth.d.mts.map [2m 0.22 kB[22m [2m│ gzip: 0.17 kB[22m
|
|
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[32mMimicDataStorage.d.mts[39m [2m 4.84 kB[22m [2m│ gzip: 1.19 kB[22m
|
|
97
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicConfig.d.mts[39m [2m 4.11 kB[22m [2m│ gzip: 1.11 kB[22m
|
|
98
|
+
[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
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mDocumentProtocol.d.mts[39m [2m 3.78 kB[22m [2m│ gzip: 0.78 kB[22m
|
|
101
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mPresenceManager.d.mts[39m [2m 3.00 kB[22m [2m│ gzip: 0.90 kB[22m
|
|
102
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mMimicAuthService.d.mts[39m [2m 2.38 kB[22m [2m│ gzip: 0.77 kB[22m
|
|
103
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mDocumentManager.d.mts[39m [2m 1.77 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
104
|
+
[34mℹ[39m [34m[ESM][39m [2mdist/[22m[32mWebSocketHandler.d.mts[39m [2m 1.73 kB[22m [2m│ gzip: 0.63 kB[22m
|
|
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
|
+
[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: 171.79 kB
|
|
108
|
+
[32m✔[39m Build complete in [32m6104ms[39m
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const require_MimicConfig = require('./MimicConfig.cjs');
|
|
3
|
+
const require_MimicDataStorage = require('./MimicDataStorage.cjs');
|
|
4
|
+
let effect_Effect = require("effect/Effect");
|
|
5
|
+
effect_Effect = require_rolldown_runtime.__toESM(effect_Effect);
|
|
6
|
+
let effect_Layer = require("effect/Layer");
|
|
7
|
+
effect_Layer = require_rolldown_runtime.__toESM(effect_Layer);
|
|
8
|
+
let effect_PubSub = require("effect/PubSub");
|
|
9
|
+
effect_PubSub = require_rolldown_runtime.__toESM(effect_PubSub);
|
|
10
|
+
let effect_Ref = require("effect/Ref");
|
|
11
|
+
effect_Ref = require_rolldown_runtime.__toESM(effect_Ref);
|
|
12
|
+
let effect_HashMap = require("effect/HashMap");
|
|
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
|
+
let effect_Stream = require("effect/Stream");
|
|
17
|
+
effect_Stream = require_rolldown_runtime.__toESM(effect_Stream);
|
|
18
|
+
let _voidhash_mimic_server = require("@voidhash/mimic/server");
|
|
19
|
+
|
|
20
|
+
//#region src/DocumentManager.ts
|
|
21
|
+
/**
|
|
22
|
+
* @since 0.0.1
|
|
23
|
+
* Document manager that handles multiple document instances.
|
|
24
|
+
*/
|
|
25
|
+
var DocumentManager_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
26
|
+
DocumentManagerTag: () => DocumentManagerTag,
|
|
27
|
+
layer: () => layer
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Context tag for DocumentManager.
|
|
31
|
+
*/
|
|
32
|
+
var DocumentManagerTag = class extends effect_Context.Tag("@voidhash/mimic-server-effect/DocumentManager")() {};
|
|
33
|
+
/**
|
|
34
|
+
* Create the DocumentManager service.
|
|
35
|
+
*/
|
|
36
|
+
const makeDocumentManager = effect_Effect.gen(function* () {
|
|
37
|
+
const config = yield* require_MimicConfig.MimicServerConfigTag;
|
|
38
|
+
const storage = yield* require_MimicDataStorage.MimicDataStorageTag;
|
|
39
|
+
const documents = yield* effect_Ref.make(effect_HashMap.empty());
|
|
40
|
+
const getOrCreateDocument = (documentId) => effect_Effect.gen(function* () {
|
|
41
|
+
const current = yield* effect_Ref.get(documents);
|
|
42
|
+
const existing = effect_HashMap.get(current, documentId);
|
|
43
|
+
if (existing._tag === "Some") {
|
|
44
|
+
yield* effect_Ref.update(existing.value.refCount, (n) => n + 1);
|
|
45
|
+
return existing.value;
|
|
46
|
+
}
|
|
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;
|
|
49
|
+
const pubsub = yield* effect_PubSub.unbounded();
|
|
50
|
+
const serverDocument = _voidhash_mimic_server.ServerDocument.make({
|
|
51
|
+
schema: config.schema,
|
|
52
|
+
initialState,
|
|
53
|
+
maxTransactionHistory: config.maxTransactionHistory,
|
|
54
|
+
onBroadcast: (transactionMessage) => {
|
|
55
|
+
const currentState = serverDocument.get();
|
|
56
|
+
effect_Effect.runFork(effect_Effect.gen(function* () {
|
|
57
|
+
if (currentState !== void 0) {
|
|
58
|
+
const transformedState = yield* storage.onSave(currentState);
|
|
59
|
+
yield* effect_Effect.catchAll(storage.save(documentId, transformedState), (error) => effect_Effect.logError("Failed to save document", error));
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
effect_Effect.runSync(effect_PubSub.publish(pubsub, {
|
|
63
|
+
type: "transaction",
|
|
64
|
+
transaction: transactionMessage.transaction,
|
|
65
|
+
version: transactionMessage.version
|
|
66
|
+
}));
|
|
67
|
+
},
|
|
68
|
+
onRejection: (transactionId, reason) => {
|
|
69
|
+
effect_Effect.runSync(effect_PubSub.publish(pubsub, {
|
|
70
|
+
type: "error",
|
|
71
|
+
transactionId,
|
|
72
|
+
reason
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
const instance = {
|
|
77
|
+
document: serverDocument,
|
|
78
|
+
pubsub,
|
|
79
|
+
refCount: yield* effect_Ref.make(1)
|
|
80
|
+
};
|
|
81
|
+
yield* effect_Ref.update(documents, (map) => effect_HashMap.set(map, documentId, instance));
|
|
82
|
+
return instance;
|
|
83
|
+
});
|
|
84
|
+
const submit = (documentId, transaction) => effect_Effect.gen(function* () {
|
|
85
|
+
return (yield* getOrCreateDocument(documentId)).document.submit(transaction);
|
|
86
|
+
});
|
|
87
|
+
const getSnapshot = (documentId) => effect_Effect.gen(function* () {
|
|
88
|
+
return (yield* getOrCreateDocument(documentId)).document.getSnapshot();
|
|
89
|
+
});
|
|
90
|
+
const subscribe = (documentId) => effect_Effect.gen(function* () {
|
|
91
|
+
const instance = yield* getOrCreateDocument(documentId);
|
|
92
|
+
const queue = yield* effect_PubSub.subscribe(instance.pubsub);
|
|
93
|
+
yield* effect_Effect.addFinalizer(() => effect_Effect.gen(function* () {
|
|
94
|
+
yield* effect_Ref.updateAndGet(instance.refCount, (n) => n - 1);
|
|
95
|
+
}));
|
|
96
|
+
return effect_Stream.fromQueue(queue);
|
|
97
|
+
});
|
|
98
|
+
return {
|
|
99
|
+
submit,
|
|
100
|
+
getSnapshot,
|
|
101
|
+
subscribe
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* Layer that provides DocumentManager.
|
|
106
|
+
* Requires MimicServerConfigTag and MimicDataStorageTag.
|
|
107
|
+
*/
|
|
108
|
+
const layer = effect_Layer.effect(DocumentManagerTag, makeDocumentManager);
|
|
109
|
+
|
|
110
|
+
//#endregion
|
|
111
|
+
exports.DocumentManagerTag = DocumentManagerTag;
|
|
112
|
+
Object.defineProperty(exports, 'DocumentManager_exports', {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () {
|
|
115
|
+
return DocumentManager_exports;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
exports.layer = layer;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ServerBroadcast, SnapshotMessage, SubmitResult } from "./DocumentProtocol.cjs";
|
|
2
|
+
import { MimicServerConfigTag } from "./MimicConfig.cjs";
|
|
3
|
+
import { MimicDataStorageTag } from "./MimicDataStorage.cjs";
|
|
4
|
+
import * as Layer from "effect/Layer";
|
|
5
|
+
import { Transaction } from "@voidhash/mimic";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import * as Context from "effect/Context";
|
|
8
|
+
import * as Scope from "effect/Scope";
|
|
9
|
+
import * as Stream from "effect/Stream";
|
|
10
|
+
|
|
11
|
+
//#region src/DocumentManager.d.ts
|
|
12
|
+
declare namespace DocumentManager_d_exports {
|
|
13
|
+
export { DocumentManager, DocumentManagerTag, layer };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Service interface for the DocumentManager.
|
|
17
|
+
*/
|
|
18
|
+
interface DocumentManager {
|
|
19
|
+
/**
|
|
20
|
+
* Submit a transaction to a document.
|
|
21
|
+
*/
|
|
22
|
+
readonly submit: (documentId: string, transaction: Transaction.Transaction) => Effect.Effect<SubmitResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a snapshot of a document.
|
|
25
|
+
*/
|
|
26
|
+
readonly getSnapshot: (documentId: string) => Effect.Effect<SnapshotMessage>;
|
|
27
|
+
/**
|
|
28
|
+
* Subscribe to broadcasts for a document.
|
|
29
|
+
* Returns a Stream of server broadcasts.
|
|
30
|
+
*/
|
|
31
|
+
readonly subscribe: (documentId: string) => Effect.Effect<Stream.Stream<ServerBroadcast>, never, Scope.Scope>;
|
|
32
|
+
}
|
|
33
|
+
declare const DocumentManagerTag_base: Context.TagClass<DocumentManagerTag, "@voidhash/mimic-server-effect/DocumentManager", DocumentManager>;
|
|
34
|
+
/**
|
|
35
|
+
* Context tag for DocumentManager.
|
|
36
|
+
*/
|
|
37
|
+
declare class DocumentManagerTag extends DocumentManagerTag_base {}
|
|
38
|
+
/**
|
|
39
|
+
* Layer that provides DocumentManager.
|
|
40
|
+
* Requires MimicServerConfigTag and MimicDataStorageTag.
|
|
41
|
+
*/
|
|
42
|
+
declare const layer: Layer.Layer<DocumentManagerTag, never, MimicServerConfigTag | MimicDataStorageTag>;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { DocumentManagerTag, DocumentManager_d_exports };
|
|
45
|
+
//# sourceMappingURL=DocumentManager.d.cts.map
|
|
@@ -0,0 +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;AA4KA;AACE,cA7KW,kBAAA,SAA2B,uBAAA,CA6KtC;;;;;cADW,OAAO,KAAA,CAAM,MACxB,2BAEA,uBAAuB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ServerBroadcast, SnapshotMessage, SubmitResult } from "./DocumentProtocol.mjs";
|
|
2
|
+
import { MimicServerConfigTag } from "./MimicConfig.mjs";
|
|
3
|
+
import { MimicDataStorageTag } from "./MimicDataStorage.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Context from "effect/Context";
|
|
7
|
+
import * as Stream from "effect/Stream";
|
|
8
|
+
import { Transaction } from "@voidhash/mimic";
|
|
9
|
+
import * as Scope from "effect/Scope";
|
|
10
|
+
|
|
11
|
+
//#region src/DocumentManager.d.ts
|
|
12
|
+
declare namespace DocumentManager_d_exports {
|
|
13
|
+
export { DocumentManager, DocumentManagerTag, layer };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Service interface for the DocumentManager.
|
|
17
|
+
*/
|
|
18
|
+
interface DocumentManager {
|
|
19
|
+
/**
|
|
20
|
+
* Submit a transaction to a document.
|
|
21
|
+
*/
|
|
22
|
+
readonly submit: (documentId: string, transaction: Transaction.Transaction) => Effect.Effect<SubmitResult>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a snapshot of a document.
|
|
25
|
+
*/
|
|
26
|
+
readonly getSnapshot: (documentId: string) => Effect.Effect<SnapshotMessage>;
|
|
27
|
+
/**
|
|
28
|
+
* Subscribe to broadcasts for a document.
|
|
29
|
+
* Returns a Stream of server broadcasts.
|
|
30
|
+
*/
|
|
31
|
+
readonly subscribe: (documentId: string) => Effect.Effect<Stream.Stream<ServerBroadcast>, never, Scope.Scope>;
|
|
32
|
+
}
|
|
33
|
+
declare const DocumentManagerTag_base: Context.TagClass<DocumentManagerTag, "@voidhash/mimic-server-effect/DocumentManager", DocumentManager>;
|
|
34
|
+
/**
|
|
35
|
+
* Context tag for DocumentManager.
|
|
36
|
+
*/
|
|
37
|
+
declare class DocumentManagerTag extends DocumentManagerTag_base {}
|
|
38
|
+
/**
|
|
39
|
+
* Layer that provides DocumentManager.
|
|
40
|
+
* Requires MimicServerConfigTag and MimicDataStorageTag.
|
|
41
|
+
*/
|
|
42
|
+
declare const layer: Layer.Layer<DocumentManagerTag, never, MimicServerConfigTag | MimicDataStorageTag>;
|
|
43
|
+
//#endregion
|
|
44
|
+
export { DocumentManagerTag, DocumentManager_d_exports };
|
|
45
|
+
//# sourceMappingURL=DocumentManager.d.mts.map
|
|
@@ -0,0 +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;AA4KA;AACE,cA7KW,kBAAA,SAA2B,uBAAA,CA6KtC;;;;;cADW,OAAO,KAAA,CAAM,MACxB,2BAEA,uBAAuB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { __export } from "./_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import { MimicServerConfigTag } from "./MimicConfig.mjs";
|
|
3
|
+
import { MimicDataStorageTag } from "./MimicDataStorage.mjs";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as PubSub from "effect/PubSub";
|
|
7
|
+
import * as Ref from "effect/Ref";
|
|
8
|
+
import * as HashMap from "effect/HashMap";
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
import * as Stream from "effect/Stream";
|
|
11
|
+
import { ServerDocument } from "@voidhash/mimic/server";
|
|
12
|
+
|
|
13
|
+
//#region src/DocumentManager.ts
|
|
14
|
+
/**
|
|
15
|
+
* @since 0.0.1
|
|
16
|
+
* Document manager that handles multiple document instances.
|
|
17
|
+
*/
|
|
18
|
+
var DocumentManager_exports = /* @__PURE__ */ __export({
|
|
19
|
+
DocumentManagerTag: () => DocumentManagerTag,
|
|
20
|
+
layer: () => layer
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Context tag for DocumentManager.
|
|
24
|
+
*/
|
|
25
|
+
var DocumentManagerTag = class extends Context.Tag("@voidhash/mimic-server-effect/DocumentManager")() {};
|
|
26
|
+
/**
|
|
27
|
+
* Create the DocumentManager service.
|
|
28
|
+
*/
|
|
29
|
+
const makeDocumentManager = Effect.gen(function* () {
|
|
30
|
+
const config = yield* MimicServerConfigTag;
|
|
31
|
+
const storage = yield* MimicDataStorageTag;
|
|
32
|
+
const documents = yield* Ref.make(HashMap.empty());
|
|
33
|
+
const getOrCreateDocument = (documentId) => Effect.gen(function* () {
|
|
34
|
+
const current = yield* Ref.get(documents);
|
|
35
|
+
const existing = HashMap.get(current, documentId);
|
|
36
|
+
if (existing._tag === "Some") {
|
|
37
|
+
yield* Ref.update(existing.value.refCount, (n) => n + 1);
|
|
38
|
+
return existing.value;
|
|
39
|
+
}
|
|
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;
|
|
42
|
+
const pubsub = yield* PubSub.unbounded();
|
|
43
|
+
const serverDocument = ServerDocument.make({
|
|
44
|
+
schema: config.schema,
|
|
45
|
+
initialState,
|
|
46
|
+
maxTransactionHistory: config.maxTransactionHistory,
|
|
47
|
+
onBroadcast: (transactionMessage) => {
|
|
48
|
+
const currentState = serverDocument.get();
|
|
49
|
+
Effect.runFork(Effect.gen(function* () {
|
|
50
|
+
if (currentState !== void 0) {
|
|
51
|
+
const transformedState = yield* storage.onSave(currentState);
|
|
52
|
+
yield* Effect.catchAll(storage.save(documentId, transformedState), (error) => Effect.logError("Failed to save document", error));
|
|
53
|
+
}
|
|
54
|
+
}));
|
|
55
|
+
Effect.runSync(PubSub.publish(pubsub, {
|
|
56
|
+
type: "transaction",
|
|
57
|
+
transaction: transactionMessage.transaction,
|
|
58
|
+
version: transactionMessage.version
|
|
59
|
+
}));
|
|
60
|
+
},
|
|
61
|
+
onRejection: (transactionId, reason) => {
|
|
62
|
+
Effect.runSync(PubSub.publish(pubsub, {
|
|
63
|
+
type: "error",
|
|
64
|
+
transactionId,
|
|
65
|
+
reason
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
const instance = {
|
|
70
|
+
document: serverDocument,
|
|
71
|
+
pubsub,
|
|
72
|
+
refCount: yield* Ref.make(1)
|
|
73
|
+
};
|
|
74
|
+
yield* Ref.update(documents, (map) => HashMap.set(map, documentId, instance));
|
|
75
|
+
return instance;
|
|
76
|
+
});
|
|
77
|
+
const submit = (documentId, transaction) => Effect.gen(function* () {
|
|
78
|
+
return (yield* getOrCreateDocument(documentId)).document.submit(transaction);
|
|
79
|
+
});
|
|
80
|
+
const getSnapshot = (documentId) => Effect.gen(function* () {
|
|
81
|
+
return (yield* getOrCreateDocument(documentId)).document.getSnapshot();
|
|
82
|
+
});
|
|
83
|
+
const subscribe = (documentId) => Effect.gen(function* () {
|
|
84
|
+
const instance = yield* getOrCreateDocument(documentId);
|
|
85
|
+
const queue = yield* PubSub.subscribe(instance.pubsub);
|
|
86
|
+
yield* Effect.addFinalizer(() => Effect.gen(function* () {
|
|
87
|
+
yield* Ref.updateAndGet(instance.refCount, (n) => n - 1);
|
|
88
|
+
}));
|
|
89
|
+
return Stream.fromQueue(queue);
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
submit,
|
|
93
|
+
getSnapshot,
|
|
94
|
+
subscribe
|
|
95
|
+
};
|
|
96
|
+
});
|
|
97
|
+
/**
|
|
98
|
+
* Layer that provides DocumentManager.
|
|
99
|
+
* Requires MimicServerConfigTag and MimicDataStorageTag.
|
|
100
|
+
*/
|
|
101
|
+
const layer = Layer.effect(DocumentManagerTag, makeDocumentManager);
|
|
102
|
+
|
|
103
|
+
//#endregion
|
|
104
|
+
export { DocumentManagerTag, DocumentManager_exports, layer };
|
|
105
|
+
//# sourceMappingURL=DocumentManager.mjs.map
|
|
@@ -0,0 +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 use configured initial state for new docs\n const initialState = rawState !== undefined\n ? yield* storage.onLoad(rawState)\n : config.initial;\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.InferState<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;EAGX,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"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let effect_Schema = require("effect/Schema");
|
|
3
|
+
effect_Schema = require_rolldown_runtime.__toESM(effect_Schema);
|
|
4
|
+
|
|
5
|
+
//#region src/DocumentProtocol.ts
|
|
6
|
+
/**
|
|
7
|
+
* @since 0.0.1
|
|
8
|
+
* Protocol and schema definitions for document communication.
|
|
9
|
+
*/
|
|
10
|
+
var DocumentProtocol_exports = /* @__PURE__ */ require_rolldown_runtime.__export({
|
|
11
|
+
AuthResultMessageSchema: () => AuthResultMessageSchema,
|
|
12
|
+
ErrorMessageSchema: () => ErrorMessageSchema,
|
|
13
|
+
OperationSchema: () => OperationSchema,
|
|
14
|
+
PongMessageSchema: () => PongMessageSchema,
|
|
15
|
+
ServerBroadcastSchema: () => ServerBroadcastSchema,
|
|
16
|
+
SnapshotMessageSchema: () => SnapshotMessageSchema,
|
|
17
|
+
SubmitResultSchema: () => SubmitResultSchema,
|
|
18
|
+
TransactionMessageSchema: () => TransactionMessageSchema,
|
|
19
|
+
TransactionSchema: () => TransactionSchema
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Schema for a transaction operation.
|
|
23
|
+
*/
|
|
24
|
+
const OperationSchema = effect_Schema.Struct({
|
|
25
|
+
kind: effect_Schema.String,
|
|
26
|
+
path: effect_Schema.Unknown,
|
|
27
|
+
payload: effect_Schema.Unknown
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Schema for a transaction.
|
|
31
|
+
*/
|
|
32
|
+
const TransactionSchema = effect_Schema.Struct({
|
|
33
|
+
id: effect_Schema.String,
|
|
34
|
+
ops: effect_Schema.Array(OperationSchema),
|
|
35
|
+
timestamp: effect_Schema.Number
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Schema for a server message that broadcasts a committed transaction.
|
|
39
|
+
*/
|
|
40
|
+
const TransactionMessageSchema = effect_Schema.Struct({
|
|
41
|
+
type: effect_Schema.Literal("transaction"),
|
|
42
|
+
transaction: TransactionSchema,
|
|
43
|
+
version: effect_Schema.Number
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Schema for a server message containing a snapshot.
|
|
47
|
+
*/
|
|
48
|
+
const SnapshotMessageSchema = effect_Schema.Struct({
|
|
49
|
+
type: effect_Schema.Literal("snapshot"),
|
|
50
|
+
state: effect_Schema.Unknown,
|
|
51
|
+
version: effect_Schema.Number
|
|
52
|
+
});
|
|
53
|
+
/**
|
|
54
|
+
* Schema for a server error message.
|
|
55
|
+
*/
|
|
56
|
+
const ErrorMessageSchema = effect_Schema.Struct({
|
|
57
|
+
type: effect_Schema.Literal("error"),
|
|
58
|
+
transactionId: effect_Schema.String,
|
|
59
|
+
reason: effect_Schema.String
|
|
60
|
+
});
|
|
61
|
+
/**
|
|
62
|
+
* Schema for a pong message.
|
|
63
|
+
*/
|
|
64
|
+
const PongMessageSchema = effect_Schema.Struct({ type: effect_Schema.Literal("pong") });
|
|
65
|
+
/**
|
|
66
|
+
* Schema for authentication result message.
|
|
67
|
+
*/
|
|
68
|
+
const AuthResultMessageSchema = effect_Schema.Struct({
|
|
69
|
+
type: effect_Schema.Literal("auth_result"),
|
|
70
|
+
success: effect_Schema.Boolean,
|
|
71
|
+
error: effect_Schema.optional(effect_Schema.String)
|
|
72
|
+
});
|
|
73
|
+
/**
|
|
74
|
+
* Union of all server broadcast messages.
|
|
75
|
+
*/
|
|
76
|
+
const ServerBroadcastSchema = effect_Schema.Union(TransactionMessageSchema, ErrorMessageSchema);
|
|
77
|
+
/**
|
|
78
|
+
* Result of submitting a transaction.
|
|
79
|
+
*/
|
|
80
|
+
const SubmitResultSchema = effect_Schema.Union(effect_Schema.Struct({
|
|
81
|
+
success: effect_Schema.Literal(true),
|
|
82
|
+
version: effect_Schema.Number
|
|
83
|
+
}), effect_Schema.Struct({
|
|
84
|
+
success: effect_Schema.Literal(false),
|
|
85
|
+
reason: effect_Schema.String
|
|
86
|
+
}));
|
|
87
|
+
|
|
88
|
+
//#endregion
|
|
89
|
+
Object.defineProperty(exports, 'DocumentProtocol_exports', {
|
|
90
|
+
enumerable: true,
|
|
91
|
+
get: function () {
|
|
92
|
+
return DocumentProtocol_exports;
|
|
93
|
+
}
|
|
94
|
+
});
|