teamplay 0.5.0-alpha.12 → 0.5.0-alpha.13

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 { useValue, useValue$, useModel, useLocal, useLocal$, useLocalDoc, useLocalDoc$, useSession, useSession$, usePage, usePage$, 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, 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';
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 { useValue, useValue$, useModel, useLocal, useLocal$, useLocalDoc, useLocalDoc$, useSession, useSession$, usePage, usePage$, 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, 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';
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,3 @@
1
- export const useValue: any
2
- export const useValue$: any
3
- export const useModel: any
4
- export const useLocal: any
5
- export const useLocal$: any
6
- export const useLocalDoc: any
7
- export const useLocalDoc$: any
8
- export const useSession: any
9
- export const useSession$: any
10
- export const usePage: any
11
- export const usePage$: any
12
1
  export const useBatch: any
13
2
  export const useDoc: any
14
3
  export const useDoc$: any
@@ -6,71 +6,6 @@ import { isCompatEnv } from '../compatEnv.js';
6
6
  import { isQueryReady } from './queryReadiness.js';
7
7
  const $root = getRootSignal({ rootId: GLOBAL_ROOT_ID, rootFunction: universal$ });
8
8
  const emittedCompatWarnings = new Set();
9
- // Hook-compatible wrapper around $() for compatibility mode.
10
- export function useValue$(defaultValue) {
11
- return $root(defaultValue);
12
- }
13
- // Returns [value, $signal] similar to useState, but backed by $().
14
- export function useValue(defaultValue) {
15
- const $sig = useValue$(defaultValue);
16
- return [$sig.get(), $sig];
17
- }
18
- export function useModel(path) {
19
- if (arguments.length === 0 || path == null)
20
- return $root;
21
- if (path && typeof path.path === 'function')
22
- return path;
23
- if (typeof path !== 'string')
24
- throw Error('useModel() expects a string path or a signal');
25
- const segments = path.split('.').filter(Boolean);
26
- if (segments.length === 0)
27
- return $root;
28
- let $cursor = $root;
29
- for (const segment of segments) {
30
- $cursor = $cursor[segment];
31
- }
32
- return $cursor;
33
- }
34
- export function useLocal$(path) {
35
- const resolvedPath = resolveLocalPath(path);
36
- if (!resolvedPath)
37
- return $root;
38
- const segments = resolvedPath.split('.').filter(Boolean);
39
- let $cursor = $root;
40
- for (const segment of segments) {
41
- $cursor = $cursor[segment];
42
- }
43
- return $cursor;
44
- }
45
- export function useLocal(path) {
46
- const $sig = useLocal$(path);
47
- return [$sig.get(), $sig];
48
- }
49
- export function useLocalDoc$(collection, id) {
50
- if (collection == null)
51
- throw Error('useLocalDoc() expects a collection name');
52
- if (id == null)
53
- return undefined;
54
- return $root[collection][id];
55
- }
56
- export function useLocalDoc(collection, id) {
57
- const $doc = useLocalDoc$(collection, id);
58
- if (!$doc)
59
- return [undefined, undefined];
60
- return [$doc.get(), $doc];
61
- }
62
- export function useSession$(path) {
63
- return useLocal$(prefixLocalPath('_session', path));
64
- }
65
- export function useSession(path) {
66
- return useLocal(prefixLocalPath('_session', path));
67
- }
68
- export function usePage$(path) {
69
- return useLocal$(prefixLocalPath('_page', path));
70
- }
71
- export function usePage(path) {
72
- return useLocal(prefixLocalPath('_page', path));
73
- }
74
9
  export function useBatch() {
75
10
  const promise = promiseBatcher.getPromiseAll();
76
11
  if (promise)
@@ -256,29 +191,6 @@ export function useAsyncQueryDoc$(collection, query, options) {
256
191
  const [, $doc] = useAsyncQueryDoc(collection, query, options);
257
192
  return $doc;
258
193
  }
259
- function resolveLocalPath(path) {
260
- if (path && typeof path.path === 'function')
261
- return path.path();
262
- if (typeof path === 'string')
263
- return path;
264
- if (path == null)
265
- return '';
266
- throw Error('useLocal() expects a string path or a signal');
267
- }
268
- function prefixLocalPath(prefix, path) {
269
- if (path == null || path === '')
270
- return prefix;
271
- let resolved = path;
272
- if (path && typeof path.path === 'function')
273
- resolved = path.path();
274
- if (typeof resolved !== 'string')
275
- throw Error(`${prefix} hook expects a string path or a signal`);
276
- if (resolved.startsWith(prefix + '.'))
277
- return resolved;
278
- if (resolved === prefix)
279
- return resolved;
280
- return `${prefix}.${resolved}`;
281
- }
282
194
  function getDocSignal(collection, id, hookName) {
283
195
  if (typeof collection !== 'string') {
284
196
  throw Error(`[${hookName}] collection must be a string. Got: ${collection}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamplay",
3
- "version": "0.5.0-alpha.12",
3
+ "version": "0.5.0-alpha.13",
4
4
  "description": "Full-stack signals ORM with multiplayer",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -69,13 +69,13 @@
69
69
  "dependencies": {
70
70
  "@nx-js/observer-util": "^4.1.3",
71
71
  "@startupjs/sharedb-mingo-memory": "^4.0.0-2",
72
- "@teamplay/backend": "^0.5.0-alpha.9",
72
+ "@teamplay/backend": "^0.5.0-alpha.13",
73
73
  "@teamplay/cache": "^0.5.0-alpha.7",
74
74
  "@teamplay/channel": "^0.5.0-alpha.10",
75
75
  "@teamplay/debug": "^0.5.0-alpha.7",
76
- "@teamplay/schema": "^0.5.0-alpha.7",
76
+ "@teamplay/schema": "^0.5.0-alpha.13",
77
77
  "@teamplay/utils": "^0.5.0-alpha.7",
78
- "babel-plugin-teamplay": "^0.5.0-alpha.7",
78
+ "babel-plugin-teamplay": "^0.5.0-alpha.13",
79
79
  "diff-match-patch": "^1.0.5",
80
80
  "events": "^3.3.0",
81
81
  "json0-ot-diff": "^1.1.2",
@@ -134,5 +134,5 @@
134
134
  ]
135
135
  },
136
136
  "license": "MIT",
137
- "gitHead": "13e07eda7f31ee883390b3ad04bdc6ecfbcb7f4c"
137
+ "gitHead": "3b067b76508f175ddc12bff294f76682796185f8"
138
138
  }