teamplay 0.4.0-alpha.34 → 0.4.0-alpha.35

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.
@@ -589,6 +589,9 @@ They are designed to behave close to StartupJS hooks, but adapted to Teamplay’
589
589
  General notes:
590
590
  - Hooks should be used inside `observer()` components to get reactive updates.
591
591
  - Sync hooks (`useDoc`, `useQuery`) use Suspense by default (via `useSub`).
592
+ - In compatibility mode, sync hooks are strict (`defer: false`) to match racer-like
593
+ semantics and avoid transient `undefined` / empty snapshots during fast navigation.
594
+ This is enforced by compat hooks (user `defer` option is ignored for sync hooks).
592
595
  - Async hooks (`useAsyncDoc`, `useAsyncQuery`) never throw; they return `undefined` until ready.
593
596
  - Batch hooks use a Suspense batch barrier (`useBatch`) and wait for both
594
597
  subscribe promises and DataTree materialization readiness.
@@ -84,7 +84,7 @@ export function useBatch () {
84
84
 
85
85
  export function useDoc$ (collection, id, options) {
86
86
  const $doc = getDocSignal(collection, id, 'useDoc')
87
- const normalizedOptions = options ? { ...options, async: false } : options
87
+ const normalizedOptions = normalizeSyncSubOptions(options)
88
88
  return useSub($doc, undefined, normalizedOptions)
89
89
  }
90
90
 
@@ -119,14 +119,14 @@ export function useAsyncDoc (collection, id, options) {
119
119
 
120
120
  export function useQuery$ (collection, query, options) {
121
121
  const $collection = getCollectionSignal(collection, query, 'useQuery')
122
- const normalizedOptions = options ? { ...options, async: false } : options
122
+ const normalizedOptions = normalizeSyncSubOptions(options)
123
123
  const $query = useSub($collection, normalizeQuery(query, 'useQuery'), normalizedOptions)
124
124
  return $query
125
125
  }
126
126
 
127
127
  export function useQuery (collection, query, options) {
128
128
  const $collection = getCollectionSignal(collection, query, 'useQuery')
129
- const normalizedOptions = options ? { ...options, async: false } : options
129
+ const normalizedOptions = normalizeSyncSubOptions(options)
130
130
  const $query = useSub($collection, normalizeQuery(query, 'useQuery'), normalizedOptions)
131
131
  return [$query.get(), $collection]
132
132
  }
@@ -324,6 +324,18 @@ const BATCH_SUB_OPTIONS = Object.freeze({
324
324
  defer: false
325
325
  })
326
326
 
327
+ function normalizeSyncSubOptions (options) {
328
+ if (!isCompatEnv()) {
329
+ return options ? { ...options, async: false } : options
330
+ }
331
+ return {
332
+ ...(options || {}),
333
+ async: false,
334
+ // Compat sync hooks are strict by design: no deferred snapshots between route/tab switches.
335
+ defer: false
336
+ }
337
+ }
338
+
327
339
  function getDocIdFromSignal ($doc) {
328
340
  const path = typeof $doc?.path === 'function' ? $doc.path() : ''
329
341
  const segments = path ? path.split('.').filter(Boolean) : []
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teamplay",
3
- "version": "0.4.0-alpha.34",
3
+ "version": "0.4.0-alpha.35",
4
4
  "description": "Full-stack signals ORM with multiplayer",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -81,5 +81,5 @@
81
81
  ]
82
82
  },
83
83
  "license": "MIT",
84
- "gitHead": "619024ea6ea3699ab461c279791a59e5a58334ab"
84
+ "gitHead": "92ba9ceb7dfb2ede1ccf1e7bb4d06cf71e2efafc"
85
85
  }