teamplay 0.5.0-alpha.15 → 0.5.0-alpha.16

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$, useQueryIds, useBatchQueryIds, useAsyncQueryIds, useQueryDoc, useQueryDoc$, useBatchQueryDoc, useBatchQueryDoc$, useAsyncQueryDoc, useAsyncQueryDoc$ } 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$, useQueryIds, useBatchQueryIds, useAsyncQueryIds, useQueryDoc, useQueryDoc$, useBatchQueryDoc, useBatchQueryDoc$, useAsyncQueryDoc, useAsyncQueryDoc$ } 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,14 +1,6 @@
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
6
  export const useQueryIds: any
@@ -11,15 +11,6 @@ export function useBatch() {
11
11
  if (promise)
12
12
  throw promise;
13
13
  }
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
14
  export function useBatchDoc(collection, id, options) {
24
15
  const $doc = useBatchDoc$(collection, id, options);
25
16
  if (!$doc)
@@ -31,16 +22,6 @@ export function useBatchDoc$(collection, id, _options) {
31
22
  const options = _options ? { ..._options, ...BATCH_SUB_OPTIONS } : BATCH_SUB_OPTIONS;
32
23
  return useSub($doc, undefined, options);
33
24
  }
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
25
  function useSubscribedQuery(collection, query, options, hookName, subscribe) {
45
26
  const normalizedQuery = normalizeQuery(query, hookName);
46
27
  const $collection = getCollectionSignal(collection, query, hookName);
@@ -56,22 +37,13 @@ function getExtraQuerySignal($query, normalizedQuery) {
56
37
  return $query;
57
38
  return isExtraQuery(normalizedQuery) ? $query.extra : $query;
58
39
  }
59
- export function useQuery$(collection, query, options) {
40
+ function useSyncQueryResult(collection, query, options, hookName) {
60
41
  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);
42
+ const { $collection, $query } = useSubscribedQuery(collection, query, normalizedOptions, hookName, useSub);
67
43
  return [$query.get(), $collection];
68
44
  }
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);
45
+ function useAsyncQueryResult(collection, query, options, hookName) {
46
+ const { $collection, $query } = useSubscribedQuery(collection, query, options, hookName, useAsyncSub);
75
47
  if (!$query)
76
48
  return [undefined, $collection];
77
49
  return [$query.get(), $collection];
@@ -92,7 +64,7 @@ export function useQueryIds(collection, ids = [], options = {}) {
92
64
  const list = Array.isArray(ids) ? ids.slice() : [];
93
65
  if (options?.reverse)
94
66
  list.reverse();
95
- const [docs, $collection] = useQuery(collection, { _id: { $in: list } }, options);
67
+ const [docs, $collection] = useSyncQueryResult(collection, { _id: { $in: list } }, options, 'useQueryIds');
96
68
  if (!docs)
97
69
  return [docs, $collection];
98
70
  const docsById = new Map();
@@ -124,7 +96,7 @@ export function useAsyncQueryIds(collection, ids = [], options = {}) {
124
96
  const list = Array.isArray(ids) ? ids.slice() : [];
125
97
  if (options?.reverse)
126
98
  list.reverse();
127
- const [docs, $collection] = useAsyncQuery(collection, { _id: { $in: list } }, options);
99
+ const [docs, $collection] = useAsyncQueryResult(collection, { _id: { $in: list } }, options, 'useAsyncQueryIds');
128
100
  if (docs == null)
129
101
  return [undefined, $collection];
130
102
  const docsById = new Map();
@@ -143,7 +115,7 @@ export function useQueryDoc(collection, query, options) {
143
115
  $limit: 1,
144
116
  $sort: normalized.$sort || { createdAt: -1 }
145
117
  };
146
- const [docs, $collection] = useQuery(collection, queryDoc, options);
118
+ const [docs, $collection] = useSyncQueryResult(collection, queryDoc, options, 'useQueryDoc');
147
119
  const doc = docs && docs[0];
148
120
  const docId = doc?._id ?? doc?.id;
149
121
  const $doc = docId != null ? $collection[docId] : undefined;
@@ -179,7 +151,7 @@ export function useAsyncQueryDoc(collection, query, options) {
179
151
  $limit: 1,
180
152
  $sort: normalized.$sort || { createdAt: -1 }
181
153
  };
182
- const [docs, $collection] = useAsyncQuery(collection, queryDoc, options);
154
+ const [docs, $collection] = useAsyncQueryResult(collection, queryDoc, options, 'useAsyncQueryDoc');
183
155
  if (docs == null)
184
156
  return [undefined, undefined];
185
157
  const doc = docs && docs[0];
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.16",
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": "a6f311fb793aeeba904b81416400e609ab597174"
138
138
  }