teamplay 0.5.0-alpha.15 → 0.5.0-alpha.17

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/dist/index.d.ts CHANGED
@@ -57,7 +57,7 @@ export { default as sub } from './orm/sub.js';
57
57
  export { default as useSub, useAsyncSub, setUseDeferredValue as __setUseDeferredValue, setDefaultDefer as __setDefaultDefer } from './react/useSub.js';
58
58
  export { default as useSuspendMemo, useSuspendMemoByKey } from './react/useSuspendMemo.js';
59
59
  export declare const observer: ObserverFunction;
60
- export { useBatch, useDoc, useDoc$, useBatchDoc, useBatchDoc$, useAsyncDoc, useAsyncDoc$, useQuery, useQuery$, useAsyncQuery, useAsyncQuery$, useBatchQuery, useBatchQuery$, useQueryIds, useBatchQueryIds, useAsyncQueryIds, useQueryDoc, useQueryDoc$, useBatchQueryDoc, useBatchQueryDoc$, useAsyncQueryDoc, useAsyncQueryDoc$ } from './orm/Compat/hooksCompat.js';
60
+ export { useBatch, useBatchDoc, useBatchDoc$, useBatchQuery, useBatchQuery$, useBatchQueryIds, useBatchQueryDoc, useBatchQueryDoc$ } from './orm/Compat/hooksCompat.js';
61
61
  export { emit, useOn, useEmit } from './orm/Compat/eventsCompat.js';
62
62
  export { useDidUpdate, useOnce, useSyncEffect } from './react/helpers.js';
63
63
  export { connection, setConnection, getConnection, getDefaultFetchOnly, setDefaultFetchOnly, publicOnly, setPublicOnly } from './orm/connection.js';
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ export { default as sub } from "./orm/sub.js";
18
18
  export { default as useSub, useAsyncSub, setUseDeferredValue as __setUseDeferredValue, setDefaultDefer as __setDefaultDefer } from "./react/useSub.js";
19
19
  export { default as useSuspendMemo, useSuspendMemoByKey } from "./react/useSuspendMemo.js";
20
20
  export const observer = runtimeObserver;
21
- export { useBatch, useDoc, useDoc$, useBatchDoc, useBatchDoc$, useAsyncDoc, useAsyncDoc$, useQuery, useQuery$, useAsyncQuery, useAsyncQuery$, useBatchQuery, useBatchQuery$, useQueryIds, useBatchQueryIds, useAsyncQueryIds, useQueryDoc, useQueryDoc$, useBatchQueryDoc, useBatchQueryDoc$, useAsyncQueryDoc, useAsyncQueryDoc$ } from './orm/Compat/hooksCompat.js';
21
+ export { useBatch, useBatchDoc, useBatchDoc$, useBatchQuery, useBatchQuery$, useBatchQueryIds, useBatchQueryDoc, useBatchQueryDoc$ } from './orm/Compat/hooksCompat.js';
22
22
  export { emit, useOn, useEmit } from './orm/Compat/eventsCompat.js';
23
23
  export { useDidUpdate, useOnce, useSyncEffect } from "./react/helpers.js";
24
24
  export { connection, setConnection, getConnection, getDefaultFetchOnly, setDefaultFetchOnly, publicOnly, setPublicOnly } from "./orm/connection.js";
@@ -1,22 +1,8 @@
1
1
  export const useBatch: any
2
- export const useDoc: any
3
- export const useDoc$: any
4
2
  export const useBatchDoc: any
5
3
  export const useBatchDoc$: any
6
- export const useAsyncDoc: any
7
- export const useAsyncDoc$: any
8
- export const useQuery: any
9
- export const useQuery$: any
10
- export const useAsyncQuery: any
11
- export const useAsyncQuery$: any
12
4
  export const useBatchQuery: any
13
5
  export const useBatchQuery$: any
14
- export const useQueryIds: any
15
6
  export const useBatchQueryIds: any
16
- export const useAsyncQueryIds: any
17
- export const useQueryDoc: any
18
- export const useQueryDoc$: any
19
7
  export const useBatchQueryDoc: any
20
8
  export const useBatchQueryDoc$: any
21
- export const useAsyncQueryDoc: any
22
- export const useAsyncQueryDoc$: any
@@ -1,8 +1,7 @@
1
1
  import { getRootSignal, GLOBAL_ROOT_ID } from "../Root.js";
2
- import useSub, { useAsyncSub } from "../../react/useSub.js";
2
+ import useSub from "../../react/useSub.js";
3
3
  import universal$ from "../../react/universal$.js";
4
4
  import * as promiseBatcher from "../../react/promiseBatcher.js";
5
- import { isCompatEnv } from '../compatEnv.js';
6
5
  import { isQueryReady } from './queryReadiness.js';
7
6
  const $root = getRootSignal({ rootId: GLOBAL_ROOT_ID, rootFunction: universal$ });
8
7
  const emittedCompatWarnings = new Set();
@@ -11,15 +10,6 @@ export function useBatch() {
11
10
  if (promise)
12
11
  throw promise;
13
12
  }
14
- export function useDoc$(collection, id, options) {
15
- const $doc = getDocSignal(collection, id, 'useDoc');
16
- const normalizedOptions = normalizeSyncSubOptions(options);
17
- return useSub($doc, undefined, normalizedOptions);
18
- }
19
- export function useDoc(collection, id, options) {
20
- const $doc = useDoc$(collection, id, options);
21
- return [$doc.get(), $doc];
22
- }
23
13
  export function useBatchDoc(collection, id, options) {
24
14
  const $doc = useBatchDoc$(collection, id, options);
25
15
  if (!$doc)
@@ -31,16 +21,6 @@ export function useBatchDoc$(collection, id, _options) {
31
21
  const options = _options ? { ..._options, ...BATCH_SUB_OPTIONS } : BATCH_SUB_OPTIONS;
32
22
  return useSub($doc, undefined, options);
33
23
  }
34
- export function useAsyncDoc$(collection, id, options) {
35
- const $doc = getDocSignal(collection, id, 'useAsyncDoc');
36
- return useAsyncSub($doc, undefined, options);
37
- }
38
- export function useAsyncDoc(collection, id, options) {
39
- const $doc = useAsyncDoc$(collection, id, options);
40
- if (!$doc)
41
- return [undefined, undefined];
42
- return [$doc.get(), $doc];
43
- }
44
24
  function useSubscribedQuery(collection, query, options, hookName, subscribe) {
45
25
  const normalizedQuery = normalizeQuery(query, hookName);
46
26
  const $collection = getCollectionSignal(collection, query, hookName);
@@ -56,26 +36,6 @@ function getExtraQuerySignal($query, normalizedQuery) {
56
36
  return $query;
57
37
  return isExtraQuery(normalizedQuery) ? $query.extra : $query;
58
38
  }
59
- export function useQuery$(collection, query, options) {
60
- const normalizedOptions = normalizeSyncSubOptions(options);
61
- const { $query } = useSubscribedQuery(collection, query, normalizedOptions, 'useQuery', useSub);
62
- return $query;
63
- }
64
- export function useQuery(collection, query, options) {
65
- const normalizedOptions = normalizeSyncSubOptions(options);
66
- const { $collection, $query } = useSubscribedQuery(collection, query, normalizedOptions, 'useQuery', useSub);
67
- return [$query.get(), $collection];
68
- }
69
- export function useAsyncQuery$(collection, query, options) {
70
- const { $query } = useSubscribedQuery(collection, query, options, 'useAsyncQuery', useAsyncSub);
71
- return $query;
72
- }
73
- export function useAsyncQuery(collection, query, options) {
74
- const { $collection, $query } = useSubscribedQuery(collection, query, options, 'useAsyncQuery', useAsyncSub);
75
- if (!$query)
76
- return [undefined, $collection];
77
- return [$query.get(), $collection];
78
- }
79
39
  export function useBatchQuery$(collection, query, _options) {
80
40
  const options = normalizeBatchSubOptions(_options);
81
41
  const { $query } = useSubscribedQuery(collection, query, options, 'useBatchQuery', useSub);
@@ -88,22 +48,6 @@ export function useBatchQuery(collection, query, _options) {
88
48
  return [undefined, $collection];
89
49
  return [$query.get(), $collection];
90
50
  }
91
- export function useQueryIds(collection, ids = [], options = {}) {
92
- const list = Array.isArray(ids) ? ids.slice() : [];
93
- if (options?.reverse)
94
- list.reverse();
95
- const [docs, $collection] = useQuery(collection, { _id: { $in: list } }, options);
96
- if (!docs)
97
- return [docs, $collection];
98
- const docsById = new Map();
99
- for (const doc of docs) {
100
- const id = doc?._id ?? doc?.id;
101
- if (id != null)
102
- docsById.set(id, doc);
103
- }
104
- const items = list.map(id => docsById.get(id)).filter(Boolean);
105
- return [items, $collection];
106
- }
107
51
  export function useBatchQueryIds(collection, ids = [], options = {}) {
108
52
  const list = Array.isArray(ids) ? ids.slice() : [];
109
53
  if (options?.reverse)
@@ -120,39 +64,6 @@ export function useBatchQueryIds(collection, ids = [], options = {}) {
120
64
  const items = list.map(id => docsById.get(id)).filter(Boolean);
121
65
  return [items, $collection];
122
66
  }
123
- export function useAsyncQueryIds(collection, ids = [], options = {}) {
124
- const list = Array.isArray(ids) ? ids.slice() : [];
125
- if (options?.reverse)
126
- list.reverse();
127
- const [docs, $collection] = useAsyncQuery(collection, { _id: { $in: list } }, options);
128
- if (docs == null)
129
- return [undefined, $collection];
130
- const docsById = new Map();
131
- for (const doc of docs) {
132
- const id = doc?._id ?? doc?.id;
133
- if (id != null)
134
- docsById.set(id, doc);
135
- }
136
- const items = list.map(id => docsById.get(id)).filter(Boolean);
137
- return [items, $collection];
138
- }
139
- export function useQueryDoc(collection, query, options) {
140
- const normalized = normalizeQuery(query, 'useQueryDoc');
141
- const queryDoc = {
142
- ...normalized,
143
- $limit: 1,
144
- $sort: normalized.$sort || { createdAt: -1 }
145
- };
146
- const [docs, $collection] = useQuery(collection, queryDoc, options);
147
- const doc = docs && docs[0];
148
- const docId = doc?._id ?? doc?.id;
149
- const $doc = docId != null ? $collection[docId] : undefined;
150
- return [doc, $doc];
151
- }
152
- export function useQueryDoc$(collection, query, options) {
153
- const [, $doc] = useQueryDoc(collection, query, options);
154
- return $doc;
155
- }
156
67
  export function useBatchQueryDoc(collection, query, options) {
157
68
  const normalized = normalizeQuery(query, 'useBatchQueryDoc');
158
69
  const queryDoc = {
@@ -172,25 +83,6 @@ export function useBatchQueryDoc$(collection, query, options) {
172
83
  const [, $doc] = useBatchQueryDoc(collection, query, options);
173
84
  return $doc;
174
85
  }
175
- export function useAsyncQueryDoc(collection, query, options) {
176
- const normalized = normalizeQuery(query, 'useAsyncQueryDoc');
177
- const queryDoc = {
178
- ...normalized,
179
- $limit: 1,
180
- $sort: normalized.$sort || { createdAt: -1 }
181
- };
182
- const [docs, $collection] = useAsyncQuery(collection, queryDoc, options);
183
- if (docs == null)
184
- return [undefined, undefined];
185
- const doc = docs && docs[0];
186
- const docId = doc?._id ?? doc?.id;
187
- const $doc = docId != null ? $collection[docId] : undefined;
188
- return [doc, $doc];
189
- }
190
- export function useAsyncQueryDoc$(collection, query, options) {
191
- const [, $doc] = useAsyncQueryDoc(collection, query, options);
192
- return $doc;
193
- }
194
86
  function getDocSignal(collection, id, hookName) {
195
87
  if (typeof collection !== 'string') {
196
88
  throw Error(`[${hookName}] collection must be a string. Got: ${collection}`);
@@ -251,17 +143,6 @@ const BATCH_SUB_OPTIONS = Object.freeze({
251
143
  // on route transitions and cause immediate reads from stale/empty local nodes.
252
144
  defer: false
253
145
  });
254
- function normalizeSyncSubOptions(options) {
255
- if (!isCompatEnv()) {
256
- return options ? { ...options, async: false } : options;
257
- }
258
- return {
259
- ...(options || {}),
260
- async: false,
261
- // Compat sync hooks are strict by design: no deferred snapshots between route/tab switches.
262
- defer: false
263
- };
264
- }
265
146
  function normalizeBatchSubOptions(options) {
266
147
  return options ? { ...options, ...BATCH_SUB_OPTIONS } : BATCH_SUB_OPTIONS;
267
148
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamplay",
3
- "version": "0.5.0-alpha.15",
3
+ "version": "0.5.0-alpha.17",
4
4
  "description": "Full-stack signals ORM with multiplayer",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -134,5 +134,5 @@
134
134
  ]
135
135
  },
136
136
  "license": "MIT",
137
- "gitHead": "87701e8a3d9512a71eb2faebf01901c939cc323b"
137
+ "gitHead": "26d5ef765255ec6a772718e50439dd3202924d3c"
138
138
  }