teamplay 0.4.0 → 0.5.0-alpha.1

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.
Files changed (237) hide show
  1. package/babel-loader.cjs +1 -0
  2. package/babel.cjs +1 -0
  3. package/dist/connect/index.d.ts +1 -0
  4. package/dist/connect/index.js +9 -0
  5. package/dist/connect/lib/sharedb-crosstab-pubsub.d.cts +10 -0
  6. package/dist/connect/offline/index.d.ts +1 -0
  7. package/dist/connect/offline/index.js +126 -0
  8. package/dist/connect/offline/react-native.d.ts +10 -0
  9. package/dist/connect/offline/react-native.js +25 -0
  10. package/dist/connect/offline/web.d.ts +9 -0
  11. package/dist/connect/offline/web.js +12 -0
  12. package/dist/connect/sharedbConnection.d.cts +2 -0
  13. package/dist/connect/test.d.ts +1 -0
  14. package/dist/connect/test.js +12 -0
  15. package/dist/index.d.ts +66 -0
  16. package/dist/index.js +74 -0
  17. package/dist/orm/$.d.ts +9 -0
  18. package/dist/orm/$.js +34 -0
  19. package/dist/orm/Aggregation.d.ts +17 -0
  20. package/dist/orm/Aggregation.js +115 -0
  21. package/dist/orm/Cache.d.ts +9 -0
  22. package/dist/orm/Cache.js +32 -0
  23. package/dist/orm/Compat/SignalCompat.d.ts +3 -0
  24. package/dist/orm/Compat/SignalCompat.js +1542 -0
  25. package/dist/orm/Compat/eventsCompat.d.ts +3 -0
  26. package/dist/orm/Compat/eventsCompat.js +73 -0
  27. package/dist/orm/Compat/hooksCompat.d.ts +33 -0
  28. package/dist/orm/Compat/hooksCompat.js +360 -0
  29. package/dist/orm/Compat/modelEvents.d.ts +6 -0
  30. package/dist/orm/Compat/modelEvents.js +228 -0
  31. package/dist/orm/Compat/queryReadiness.d.ts +5 -0
  32. package/dist/orm/Compat/queryReadiness.js +185 -0
  33. package/dist/orm/Compat/refFallback.d.ts +13 -0
  34. package/dist/orm/Compat/refFallback.js +65 -0
  35. package/dist/orm/Compat/refRegistry.d.ts +6 -0
  36. package/dist/orm/Compat/refRegistry.js +54 -0
  37. package/dist/orm/Compat/silentContext.d.ts +5 -0
  38. package/dist/orm/Compat/silentContext.js +48 -0
  39. package/dist/orm/Compat/startStopCompat.d.ts +3 -0
  40. package/dist/orm/Compat/startStopCompat.js +217 -0
  41. package/dist/orm/Doc.d.ts +96 -0
  42. package/dist/orm/Doc.js +966 -0
  43. package/dist/orm/Query.d.ts +117 -0
  44. package/dist/orm/Query.js +1111 -0
  45. package/dist/orm/Reaction.d.ts +10 -0
  46. package/dist/orm/Reaction.js +41 -0
  47. package/dist/orm/Root.d.ts +22 -0
  48. package/dist/orm/Root.js +85 -0
  49. package/dist/orm/Signal.d.ts +12 -0
  50. package/dist/orm/Signal.js +7 -0
  51. package/dist/orm/SignalBase.d.ts +168 -0
  52. package/dist/orm/SignalBase.js +625 -0
  53. package/dist/orm/SubscriptionState.d.ts +17 -0
  54. package/dist/orm/SubscriptionState.js +123 -0
  55. package/dist/orm/Value.d.ts +9 -0
  56. package/dist/orm/Value.js +25 -0
  57. package/dist/orm/addModel.d.ts +6 -0
  58. package/dist/orm/addModel.js +39 -0
  59. package/dist/orm/associations.d.ts +18 -0
  60. package/dist/orm/associations.js +70 -0
  61. package/dist/orm/batchScheduler.d.ts +7 -0
  62. package/dist/orm/batchScheduler.js +62 -0
  63. package/dist/orm/compatEnv.d.ts +1 -0
  64. package/dist/orm/compatEnv.js +4 -0
  65. package/dist/orm/connection.d.ts +26 -0
  66. package/dist/orm/connection.js +38 -0
  67. package/dist/orm/dataTree.d.ts +34 -0
  68. package/dist/orm/dataTree.js +880 -0
  69. package/dist/orm/disposeRootContext.d.ts +4 -0
  70. package/dist/orm/disposeRootContext.js +59 -0
  71. package/dist/orm/getSignal.d.ts +16 -0
  72. package/dist/orm/getSignal.js +133 -0
  73. package/dist/orm/idFields.d.ts +14 -0
  74. package/dist/orm/idFields.js +95 -0
  75. package/dist/orm/index.d.ts +7 -0
  76. package/dist/orm/index.js +6 -0
  77. package/dist/orm/initModels.d.ts +5 -0
  78. package/dist/orm/initModels.js +74 -0
  79. package/dist/orm/missingDoc.d.ts +1 -0
  80. package/dist/orm/missingDoc.js +3 -0
  81. package/dist/orm/pluralize.d.ts +12 -0
  82. package/dist/orm/privateData.d.ts +22 -0
  83. package/dist/orm/privateData.js +170 -0
  84. package/dist/orm/rootContext.d.ts +78 -0
  85. package/dist/orm/rootContext.js +297 -0
  86. package/dist/orm/rootScope.d.ts +12 -0
  87. package/dist/orm/rootScope.js +46 -0
  88. package/dist/orm/signalArrayReaders.d.ts +22 -0
  89. package/dist/orm/signalArrayReaders.js +42 -0
  90. package/dist/orm/signalMetadata.d.ts +17 -0
  91. package/dist/orm/signalMetadata.js +56 -0
  92. package/dist/orm/signalMutationGuards.d.ts +4 -0
  93. package/dist/orm/signalMutationGuards.js +14 -0
  94. package/dist/orm/signalPathKind.d.ts +2 -0
  95. package/dist/orm/signalPathKind.js +10 -0
  96. package/dist/orm/signalPathRules.d.ts +6 -0
  97. package/dist/orm/signalPathRules.js +28 -0
  98. package/dist/orm/signalReads.d.ts +26 -0
  99. package/dist/orm/signalReads.js +64 -0
  100. package/dist/orm/signalRuntimeAccess.d.ts +16 -0
  101. package/dist/orm/signalRuntimeAccess.js +24 -0
  102. package/dist/orm/signalRuntimeDescriptor.d.ts +19 -0
  103. package/dist/orm/signalRuntimeDescriptor.js +97 -0
  104. package/dist/orm/signalStorageMutations.d.ts +18 -0
  105. package/dist/orm/signalStorageMutations.js +26 -0
  106. package/dist/orm/signalSymbols.d.ts +5 -0
  107. package/dist/orm/signalSymbols.js +5 -0
  108. package/dist/orm/signalValueMutations.d.ts +14 -0
  109. package/dist/orm/signalValueMutations.js +36 -0
  110. package/dist/orm/sub.d.ts +37 -0
  111. package/dist/orm/sub.js +187 -0
  112. package/dist/orm/subscriptionGcDelay.d.ts +4 -0
  113. package/dist/orm/subscriptionGcDelay.js +26 -0
  114. package/dist/orm/types/baseMethods.d.ts +43 -0
  115. package/dist/orm/types/baseMethods.js +1 -0
  116. package/dist/orm/types/jsonSchema.d.ts +75 -0
  117. package/dist/orm/types/jsonSchema.js +1 -0
  118. package/dist/orm/types/modelManifest.d.ts +37 -0
  119. package/dist/orm/types/modelManifest.js +1 -0
  120. package/dist/orm/types/path.d.ts +8 -0
  121. package/dist/orm/types/path.js +1 -0
  122. package/dist/orm/types/query.d.ts +29 -0
  123. package/dist/orm/types/query.js +1 -0
  124. package/dist/orm/types/signal.d.ts +132 -0
  125. package/dist/orm/types/signal.js +1 -0
  126. package/dist/react/compatComponentRegistry.d.ts +4 -0
  127. package/dist/react/compatComponentRegistry.js +19 -0
  128. package/dist/react/convertToObserver.d.ts +26 -0
  129. package/dist/react/convertToObserver.js +114 -0
  130. package/dist/react/executionContextTracker.d.ts +11 -0
  131. package/dist/react/executionContextTracker.js +28 -0
  132. package/dist/react/helpers.d.ts +34 -0
  133. package/dist/react/helpers.js +134 -0
  134. package/dist/react/observer.d.ts +22 -0
  135. package/dist/react/observer.js +8 -0
  136. package/dist/react/promiseBatcher.d.ts +13 -0
  137. package/dist/react/promiseBatcher.js +118 -0
  138. package/dist/react/renderAttemptDestroyer.d.ts +19 -0
  139. package/dist/react/renderAttemptDestroyer.js +46 -0
  140. package/dist/react/trapRender.d.ts +6 -0
  141. package/dist/react/trapRender.js +48 -0
  142. package/dist/react/universal$.d.ts +1 -0
  143. package/dist/react/universal$.js +18 -0
  144. package/dist/react/universalSub.d.ts +1 -0
  145. package/dist/react/universalSub.js +22 -0
  146. package/dist/react/useApi.d.ts +13 -0
  147. package/dist/react/useApi.js +67 -0
  148. package/dist/react/useSub.d.ts +102 -0
  149. package/dist/react/useSub.js +189 -0
  150. package/dist/react/useSuspendMemo.d.ts +3 -0
  151. package/dist/react/useSuspendMemo.js +102 -0
  152. package/dist/react/wrapIntoSuspense.d.ts +9 -0
  153. package/dist/react/wrapIntoSuspense.js +102 -0
  154. package/dist/server.d.ts +11 -0
  155. package/dist/server.js +28 -0
  156. package/dist/utils/MockFinalizationRegistry.d.ts +37 -0
  157. package/dist/utils/MockFinalizationRegistry.js +85 -0
  158. package/dist/utils/MockWeakRef.d.ts +12 -0
  159. package/dist/utils/MockWeakRef.js +23 -0
  160. package/dist/utils/isServer.d.ts +3 -0
  161. package/dist/utils/isServer.js +18 -0
  162. package/dist/utils/setDiffDeep.d.ts +1 -0
  163. package/dist/utils/setDiffDeep.js +61 -0
  164. package/dist/utils/useIsomorphicLayoutEffect.d.ts +3 -0
  165. package/dist/utils/useIsomorphicLayoutEffect.js +3 -0
  166. package/file-based-models.js +3 -0
  167. package/file-based-models.node.js +6 -0
  168. package/package.json +77 -32
  169. package/teamplay.models.auto-init.virtual.js +1 -0
  170. package/teamplay.models.virtual.js +1 -0
  171. package/connect/index.js +0 -9
  172. package/connect/offline/index.js +0 -124
  173. package/connect/offline/react-native.js +0 -28
  174. package/connect/offline/web.js +0 -15
  175. package/connect/test.js +0 -12
  176. package/index.d.ts +0 -106
  177. package/index.js +0 -125
  178. package/orm/$.js +0 -38
  179. package/orm/Aggregation.js +0 -117
  180. package/orm/Cache.js +0 -46
  181. package/orm/Compat/README.md +0 -1064
  182. package/orm/Compat/SignalCompat.js +0 -1479
  183. package/orm/Compat/eventsCompat.js +0 -79
  184. package/orm/Compat/hooksCompat.js +0 -374
  185. package/orm/Compat/modelEvents.js +0 -225
  186. package/orm/Compat/queryReadiness.js +0 -191
  187. package/orm/Compat/refFallback.js +0 -62
  188. package/orm/Compat/refRegistry.js +0 -61
  189. package/orm/Compat/silentContext.js +0 -51
  190. package/orm/Compat/startStopCompat.js +0 -207
  191. package/orm/Doc.js +0 -969
  192. package/orm/Query.js +0 -1127
  193. package/orm/Reaction.js +0 -48
  194. package/orm/Root.js +0 -88
  195. package/orm/Signal.js +0 -22
  196. package/orm/SignalBase.js +0 -696
  197. package/orm/SubscriptionState.js +0 -138
  198. package/orm/Value.js +0 -30
  199. package/orm/addModel.js +0 -31
  200. package/orm/associations.js +0 -97
  201. package/orm/batchScheduler.js +0 -62
  202. package/orm/compatEnv.js +0 -4
  203. package/orm/connection.js +0 -46
  204. package/orm/dataTree.js +0 -869
  205. package/orm/disposeRootContext.js +0 -68
  206. package/orm/getSignal.js +0 -130
  207. package/orm/idFields.js +0 -88
  208. package/orm/index.d.ts +0 -6
  209. package/orm/index.js +0 -5
  210. package/orm/missingDoc.js +0 -3
  211. package/orm/privateData.js +0 -181
  212. package/orm/rootContext.js +0 -313
  213. package/orm/rootScope.js +0 -51
  214. package/orm/sub.js +0 -151
  215. package/orm/subscriptionGcDelay.js +0 -32
  216. package/react/compatComponentRegistry.js +0 -20
  217. package/react/convertToObserver.js +0 -117
  218. package/react/executionContextTracker.js +0 -32
  219. package/react/helpers.js +0 -141
  220. package/react/observer.js +0 -9
  221. package/react/promiseBatcher.js +0 -115
  222. package/react/renderAttemptDestroyer.js +0 -47
  223. package/react/trapRender.js +0 -50
  224. package/react/universal$.js +0 -18
  225. package/react/universalSub.js +0 -21
  226. package/react/useApi.js +0 -63
  227. package/react/useSub.js +0 -169
  228. package/react/useSuspendMemo.js +0 -96
  229. package/react/wrapIntoSuspense.js +0 -119
  230. package/server.js +0 -31
  231. package/utils/MockFinalizationRegistry.js +0 -94
  232. package/utils/MockWeakRef.js +0 -25
  233. package/utils/isServer.js +0 -17
  234. package/utils/setDiffDeep.js +0 -58
  235. package/utils/useIsomorphicLayoutEffect.js +0 -4
  236. /package/{connect → dist/connect}/lib/sharedb-crosstab-pubsub.cjs +0 -0
  237. /package/{connect → dist/connect}/sharedbConnection.cjs +0 -0
@@ -0,0 +1,217 @@
1
+ import { observe, raw, unobserve } from '@nx-js/observer-util';
2
+ import { getRoot } from "../Root.js";
3
+ import { scheduleReaction } from '../batchScheduler.js';
4
+ const START_REACTIONS = Symbol('compat start reactions');
5
+ const SKIP_TICK = Symbol('compat start skip tick');
6
+ export function compatStartOnRoot($root, targetPath, ...depsAndGetter) {
7
+ if (!isRootSignal($root))
8
+ throw Error('Signal.start() is only available on root signal');
9
+ if (typeof targetPath !== 'string')
10
+ throw Error('Signal.start() expects targetPath to be a string');
11
+ if (depsAndGetter.length < 1) {
12
+ throw Error('Signal.start() expects targetPath, dependencies, and a getter function');
13
+ }
14
+ const getter = depsAndGetter[depsAndGetter.length - 1];
15
+ if (typeof getter !== 'function') {
16
+ throw Error('Signal.start() expects the last argument to be a getter function');
17
+ }
18
+ const deps = depsAndGetter.slice(0, -1);
19
+ const targetSegments = parsePathSegments(targetPath);
20
+ const $target = resolveSignal($root, targetSegments);
21
+ const targetKey = $target.path();
22
+ const store = getStartStore($root);
23
+ const existing = store.get(targetKey);
24
+ if (existing)
25
+ existing.stop();
26
+ let lastSourceSnapshot = UNSET;
27
+ const reaction = observe(() => {
28
+ const resolvedDeps = [];
29
+ for (const dep of deps) {
30
+ const resolved = resolveStartDep(dep, $root);
31
+ if (resolved === SKIP_TICK)
32
+ return;
33
+ resolvedDeps.push(resolved);
34
+ }
35
+ let nextValue;
36
+ try {
37
+ nextValue = getter(...resolvedDeps);
38
+ }
39
+ catch (err) {
40
+ if (isThenable(err))
41
+ return;
42
+ throw err;
43
+ }
44
+ const sourceSnapshot = detachStartValue(nextValue);
45
+ if (lastSourceSnapshot !== UNSET && deepEqualStartValue(lastSourceSnapshot, sourceSnapshot)) {
46
+ return;
47
+ }
48
+ lastSourceSnapshot = sourceSnapshot;
49
+ const detachedValue = detachStartValue(sourceSnapshot);
50
+ // Keep the detached snapshot to avoid aliasing source and target.
51
+ // Old racer start() writes through diffDeep by default. In compat mode we must preserve
52
+ // that behavior, but also avoid reading the target reactively inside start(), otherwise
53
+ // start() subscribes to its own output and local child edits get immediately overwritten.
54
+ const maybePromise = $target.setDiffDeep(detachedValue);
55
+ if (maybePromise?.then) {
56
+ maybePromise
57
+ .then(() => { })
58
+ .catch(ignorePromiseRejection);
59
+ }
60
+ }, { scheduler: scheduleReaction });
61
+ store.set(targetKey, { stop: () => unobserve(reaction) });
62
+ return $target;
63
+ }
64
+ export function compatStopOnRoot($root, targetPath) {
65
+ if (!isRootSignal($root))
66
+ throw Error('Signal.stop() is only available on root signal');
67
+ if (typeof targetPath !== 'string')
68
+ throw Error('Signal.stop() expects targetPath to be a string');
69
+ const targetSegments = parsePathSegments(targetPath);
70
+ const $target = resolveSignal($root, targetSegments);
71
+ const targetKey = $target.path();
72
+ const store = getStartStore($root);
73
+ const existing = store.get(targetKey);
74
+ if (!existing)
75
+ return;
76
+ existing.stop();
77
+ store.delete(targetKey);
78
+ }
79
+ export function joinScopePath(scopePath, relativePath) {
80
+ if (typeof scopePath !== 'string')
81
+ scopePath = '';
82
+ const segments = [];
83
+ if (scopePath)
84
+ segments.push(...parsePathSegments(scopePath));
85
+ if (relativePath)
86
+ segments.push(...parsePathSegments(relativePath));
87
+ return segments.join('.');
88
+ }
89
+ function getStartStore($root) {
90
+ $root[START_REACTIONS] ??= new Map();
91
+ return $root[START_REACTIONS];
92
+ }
93
+ function resolveStartDep(dep, $root) {
94
+ try {
95
+ if (isSignalLike(dep))
96
+ return getStartDepValue(dep);
97
+ if (typeof dep === 'string')
98
+ return getStartDepValue(resolveSignal($root, parsePathSegments(dep)));
99
+ return dep;
100
+ }
101
+ catch (err) {
102
+ if (isThenable(err))
103
+ return SKIP_TICK;
104
+ throw err;
105
+ }
106
+ }
107
+ function getStartDepValue($signal) {
108
+ return readReactiveSnapshot($signal.get());
109
+ }
110
+ function readReactiveSnapshot(value) {
111
+ if (!value || typeof value !== 'object')
112
+ return value;
113
+ if (value instanceof Date)
114
+ return new Date(value);
115
+ if (Array.isArray(value)) {
116
+ const array = [];
117
+ for (let i = 0; i < value.length; i++) {
118
+ array[i] = readReactiveSnapshot(value[i]);
119
+ }
120
+ return array;
121
+ }
122
+ const object = new value.constructor();
123
+ for (const key in value) {
124
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
125
+ object[key] = readReactiveSnapshot(value[key]);
126
+ }
127
+ }
128
+ return object;
129
+ }
130
+ function isSignalLike(value) {
131
+ return value && typeof value.path === 'function' && typeof value.get === 'function';
132
+ }
133
+ function parsePathSegments(path) {
134
+ return path.split('.').filter(Boolean);
135
+ }
136
+ function resolveSignal($base, segments) {
137
+ let $cursor = $base;
138
+ for (const segment of segments)
139
+ $cursor = $cursor[segment];
140
+ return $cursor;
141
+ }
142
+ function isRootSignal($signal) {
143
+ return getRoot($signal) === $signal;
144
+ }
145
+ function ignorePromiseRejection() { }
146
+ function isThenable(value) {
147
+ return !!value && typeof value.then === 'function';
148
+ }
149
+ const UNSET = Symbol('compat start unset');
150
+ function detachStartValue(value) {
151
+ const rawValue = raw(value);
152
+ if (!rawValue || typeof rawValue !== 'object')
153
+ return rawValue;
154
+ if (typeof globalThis.structuredClone === 'function') {
155
+ try {
156
+ return globalThis.structuredClone(rawValue);
157
+ }
158
+ catch { }
159
+ }
160
+ return racerDeepCopy(rawValue);
161
+ }
162
+ function racerDeepCopy(value) {
163
+ if (value instanceof Date)
164
+ return new Date(value);
165
+ if (typeof value === 'object') {
166
+ if (value === null)
167
+ return null;
168
+ if (Array.isArray(value)) {
169
+ const array = [];
170
+ for (let i = value.length; i--;) {
171
+ array[i] = racerDeepCopy(value[i]);
172
+ }
173
+ return array;
174
+ }
175
+ const object = new value.constructor();
176
+ for (const key in value) {
177
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
178
+ object[key] = racerDeepCopy(value[key]);
179
+ }
180
+ }
181
+ return object;
182
+ }
183
+ return value;
184
+ }
185
+ function deepEqualStartValue(left, right) {
186
+ if (left === right)
187
+ return true;
188
+ if (Number.isNaN(left) && Number.isNaN(right))
189
+ return true;
190
+ if (left instanceof Date || right instanceof Date) {
191
+ return left instanceof Date && right instanceof Date && left.getTime() === right.getTime();
192
+ }
193
+ if (!left || !right || typeof left !== 'object' || typeof right !== 'object')
194
+ return false;
195
+ if (Array.isArray(left) || Array.isArray(right)) {
196
+ if (!Array.isArray(left) || !Array.isArray(right))
197
+ return false;
198
+ if (left.length !== right.length)
199
+ return false;
200
+ for (let i = 0; i < left.length; i++) {
201
+ if (!deepEqualStartValue(left[i], right[i]))
202
+ return false;
203
+ }
204
+ return true;
205
+ }
206
+ const leftKeys = Object.keys(left);
207
+ const rightKeys = Object.keys(right);
208
+ if (leftKeys.length !== rightKeys.length)
209
+ return false;
210
+ for (const key of leftKeys) {
211
+ if (!Object.prototype.hasOwnProperty.call(right, key))
212
+ return false;
213
+ if (!deepEqualStartValue(left[key], right[key]))
214
+ return false;
215
+ }
216
+ return true;
217
+ }
@@ -0,0 +1,96 @@
1
+ import type Signal from './Signal.js'
2
+
3
+ export type SubscriptionIntent = 'fetch' | 'subscribe'
4
+ export type TransportMode = 'idle' | 'fetch' | 'subscribe'
5
+ export type TransportPhase = 'stable' | 'transition'
6
+ export type SignalPathSegments = Array<string | number>
7
+
8
+ export interface ReadonlyMapView<TKey, TValue> extends Iterable<[TKey, TValue | undefined]> {
9
+ get (key: TKey): TValue | undefined
10
+ has (key: TKey): boolean
11
+ readonly size: number
12
+ keys (): IterableIterator<TKey>
13
+ values (): IterableIterator<TValue | undefined>
14
+ entries (): IterableIterator<[TKey, TValue | undefined]>
15
+ }
16
+
17
+ export interface PendingDestroyEntry {
18
+ timer?: ReturnType<typeof setTimeout>
19
+ force: boolean
20
+ promise: Promise<unknown>
21
+ resolve: () => void
22
+ reject: (error?: unknown) => void
23
+ }
24
+
25
+ export interface DocOwnerMeta {
26
+ hash: string
27
+ segments: SignalPathSegments
28
+ rootId?: string
29
+ }
30
+
31
+ export interface DocOwnerRecord extends DocOwnerMeta {
32
+ ownerKey: string
33
+ fetchCount: number
34
+ subscribeCount: number
35
+ }
36
+
37
+ export interface DocRuntimeEntry {
38
+ hash: string
39
+ segments: SignalPathSegments
40
+ mode: TransportMode
41
+ targetMode: TransportMode
42
+ phase: TransportPhase
43
+ runtime: Doc | null
44
+ owners: Set<string>
45
+ retainCount: number
46
+ pendingDestroy: PendingDestroyEntry | null
47
+ reconcilePromise: Promise<void> | null
48
+ }
49
+
50
+ export class Doc {
51
+ initialized?: boolean
52
+ collection: string
53
+ docId: string | number
54
+ requestedTransportMode: TransportMode
55
+ activeTransportMode: TransportMode
56
+ readonly subscribed: boolean
57
+ constructor (collection: string, docId: string | number)
58
+ init (): void
59
+ subscribe (options?: { mode?: Exclude<TransportMode, 'idle'> }): Promise<void>
60
+ unsubscribe (): Promise<void>
61
+ hasPending (): boolean
62
+ whenNothingPending (fn: () => void): void
63
+ destroy (): Promise<void>
64
+ dispose (): void
65
+ }
66
+
67
+ export type DocConstructor = new (collection: string, docId: string | number) => Doc
68
+
69
+ export class DocSubscriptions {
70
+ DocClass: DocConstructor
71
+ ownerRecords: Map<string, DocOwnerRecord>
72
+ entries: Map<string, DocRuntimeEntry>
73
+ subCount: ReadonlyMapView<string, number>
74
+ ownerFetchCount: ReadonlyMapView<string, number>
75
+ ownerSubscribeCount: ReadonlyMapView<string, number>
76
+ ownerMeta: ReadonlyMapView<string, DocOwnerMeta>
77
+ ownerKeysByHash: ReadonlyMapView<string, Set<string>>
78
+ docs: ReadonlyMapView<string, Doc>
79
+ pendingDestroyTimers: ReadonlyMapView<string, PendingDestroyEntry>
80
+ constructor (DocClass?: DocConstructor)
81
+ init ($doc: Signal): void
82
+ subscribe ($doc: Signal, options?: { intent?: SubscriptionIntent }): Promise<void> | void
83
+ unsubscribe ($doc: Signal, options?: { intent?: SubscriptionIntent }): Promise<void>
84
+ retain ($doc: Signal): void
85
+ release ($doc: Signal): Promise<void>
86
+ destroy (segments: SignalPathSegments): Promise<void>
87
+ clear (): Promise<void>
88
+ releaseRootOwnedSubscriptions (rootId: string): Promise<void>
89
+ flushPendingDestroys (): Promise<void>
90
+ scheduleDestroy (segments: SignalPathSegments, options?: { force?: boolean }): Promise<void> | void
91
+ cancelDestroy (hash: string): void
92
+ getOwnerMeta (ownerKey: string): DocOwnerMeta | undefined
93
+ getOwnerKeys (hash: string): Set<string> | undefined
94
+ }
95
+
96
+ export const docSubscriptions: DocSubscriptions