on-zero 0.4.37 → 0.4.39
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/cjs/createUseQuery.cjs +8 -1
- package/dist/cjs/createUseQuery.native.js +10 -1
- package/dist/cjs/createUseQuery.native.js.map +1 -1
- package/dist/cjs/createUseQueryDirect.cjs +3 -0
- package/dist/cjs/createUseQueryDirect.native.js +5 -0
- package/dist/cjs/createUseQueryDirect.native.js.map +1 -1
- package/dist/cjs/createZeroClient.cjs +76 -39
- package/dist/cjs/createZeroClient.native.js +51 -10
- package/dist/cjs/createZeroClient.native.js.map +1 -1
- package/dist/cjs/multiInstanceNested.test.cjs +1 -0
- package/dist/cjs/multiInstanceNested.test.native.js +1 -0
- package/dist/cjs/multiInstanceNested.test.native.js.map +1 -1
- package/dist/esm/createUseQuery.mjs +8 -1
- package/dist/esm/createUseQuery.mjs.map +1 -1
- package/dist/esm/createUseQuery.native.js +10 -1
- package/dist/esm/createUseQuery.native.js.map +1 -1
- package/dist/esm/createUseQueryDirect.mjs +3 -0
- package/dist/esm/createUseQueryDirect.mjs.map +1 -1
- package/dist/esm/createUseQueryDirect.native.js +5 -0
- package/dist/esm/createUseQueryDirect.native.js.map +1 -1
- package/dist/esm/createZeroClient.mjs +77 -40
- package/dist/esm/createZeroClient.mjs.map +1 -1
- package/dist/esm/createZeroClient.native.js +52 -11
- package/dist/esm/createZeroClient.native.js.map +1 -1
- package/dist/esm/multiInstanceNested.test.mjs +1 -0
- package/dist/esm/multiInstanceNested.test.mjs.map +1 -1
- package/dist/esm/multiInstanceNested.test.native.js +1 -0
- package/dist/esm/multiInstanceNested.test.native.js.map +1 -1
- package/package.json +3 -3
- package/src/createUseQuery.tsx +22 -1
- package/src/createUseQueryDirect.tsx +5 -0
- package/src/createZeroClient.tsx +105 -24
- package/src/multiInstanceNested.test.tsx +3 -0
- package/types/createUseQuery.d.ts.map +1 -1
- package/types/createUseQueryDirect.d.ts.map +1 -1
- package/types/createZeroClient.d.ts +4 -4
- package/types/createZeroClient.d.ts.map +1 -1
package/src/createUseQuery.tsx
CHANGED
|
@@ -63,6 +63,16 @@ export function createUseQuery<Schema extends ZeroSchema>({
|
|
|
63
63
|
DisabledContext: Context<QueryControlMode>
|
|
64
64
|
customQueries: AnyQueryRegistry
|
|
65
65
|
}): UseQueryHook<Schema> {
|
|
66
|
+
// SSG: return an inert hook. on-zero's bundled React copy isn't the same
|
|
67
|
+
// one the SSG build's renderer initialises, so hook dispatch returns null.
|
|
68
|
+
// an empty response matches how the wrapper behaves under DisabledContext
|
|
69
|
+
// anyway, so consumers see the same shape across SSG and the disabled
|
|
70
|
+
// client path. checking here (factory-time) instead of per-call keeps
|
|
71
|
+
// hook order stable so rules-of-hooks stays happy.
|
|
72
|
+
if (typeof window === 'undefined') {
|
|
73
|
+
return (() => EMPTY_RESPONSE) as UseQueryHook<Schema>
|
|
74
|
+
}
|
|
75
|
+
|
|
66
76
|
function useQuery(...args: any[]): any {
|
|
67
77
|
const disableMode = useContext(DisabledContext)
|
|
68
78
|
const lastRef = useRef<any>(EMPTY_RESPONSE)
|
|
@@ -75,7 +85,18 @@ export function createUseQuery<Schema extends ZeroSchema>({
|
|
|
75
85
|
return { queryRequest, options: opts }
|
|
76
86
|
}, [fn, paramsOrOptions, optionsArg])
|
|
77
87
|
|
|
78
|
-
|
|
88
|
+
// when disabled, force enabled=false through to zero's useQuery so its
|
|
89
|
+
// viewStore returns a disabled view (no zero.clientID read, no view
|
|
90
|
+
// subscription) and the stub Zero handed in by ProvideZero stays inert.
|
|
91
|
+
// we still call zeroUseQuery unconditionally so hook order stays stable
|
|
92
|
+
// across DisabledContext changes — the disable check after only affects
|
|
93
|
+
// the return value.
|
|
94
|
+
const effectiveOptions = disableMode
|
|
95
|
+
? typeof options === 'boolean'
|
|
96
|
+
? false
|
|
97
|
+
: { ...(options ?? {}), enabled: false }
|
|
98
|
+
: options
|
|
99
|
+
const out = zeroUseQuery(queryRequest, effectiveOptions)
|
|
79
100
|
|
|
80
101
|
if (process.env.NODE_ENV === 'development') {
|
|
81
102
|
if (process.env.DEBUG_ZERO_QUERIES === '1')
|
|
@@ -255,6 +255,11 @@ export function createUseQueryDirect<Schema extends ZeroSchema>({
|
|
|
255
255
|
getZero,
|
|
256
256
|
zeroVersion,
|
|
257
257
|
}: Parameters<CreateUseQueryDirect<Schema>>[0]): UseQueryHook<Schema> {
|
|
258
|
+
// SSG: return an inert hook — see createUseQuery for the rationale.
|
|
259
|
+
if (typeof window === 'undefined') {
|
|
260
|
+
return (() => EMPTY_RESPONSE) as UseQueryHook<Schema>
|
|
261
|
+
}
|
|
262
|
+
|
|
258
263
|
const directViewStore = new DirectViewStore()
|
|
259
264
|
|
|
260
265
|
function useQueryDirect(...args: any[]): any {
|
package/src/createZeroClient.tsx
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { defineQueries, defineQuery, Zero as ZeroClient } from '@rocicorp/zero'
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
useConnectionState,
|
|
4
|
+
useZero,
|
|
5
|
+
ZeroContext,
|
|
6
|
+
ZeroProvider,
|
|
7
|
+
} from '@rocicorp/zero/react'
|
|
3
8
|
import { createEmitter, type Emitter } from '@take-out/helpers'
|
|
4
9
|
import {
|
|
5
10
|
createContext,
|
|
@@ -294,8 +299,19 @@ export function createZeroClientInternal<
|
|
|
294
299
|
// permissionStrategy controls client behavior before server responds.
|
|
295
300
|
// built over a query hook so the facade can route permission checks down
|
|
296
301
|
// the same context vs direct path as the table's other queries.
|
|
297
|
-
|
|
298
|
-
|
|
302
|
+
// SSG: return an inert hook — see createUseQuery for rationale. checking
|
|
303
|
+
// here (factory-time) instead of per-call keeps hook order stable so
|
|
304
|
+
// rules-of-hooks stays happy.
|
|
305
|
+
const createUsePermission = (useQueryImpl: UseQueryHook<Schema>) => {
|
|
306
|
+
if (typeof window === 'undefined') {
|
|
307
|
+
return (() => null) as (
|
|
308
|
+
table: TableName | (string & {}),
|
|
309
|
+
objOrId: string | Partial<Row<any>> | undefined,
|
|
310
|
+
enabled?: boolean,
|
|
311
|
+
debug?: boolean,
|
|
312
|
+
) => boolean | null
|
|
313
|
+
}
|
|
314
|
+
return function usePermission(
|
|
299
315
|
table: TableName | (string & {}),
|
|
300
316
|
objOrId: string | Partial<Row<any>> | undefined,
|
|
301
317
|
enabled = typeof objOrId !== 'undefined',
|
|
@@ -337,6 +353,7 @@ export function createZeroClientInternal<
|
|
|
337
353
|
|
|
338
354
|
return null
|
|
339
355
|
}
|
|
356
|
+
}
|
|
340
357
|
|
|
341
358
|
const usePermission = createUsePermission(useQuery)
|
|
342
359
|
const usePermissionDirect = createUsePermission(useQueryDirect)
|
|
@@ -356,17 +373,45 @@ export function createZeroClientInternal<
|
|
|
356
373
|
// with different identities would thrash this slot.
|
|
357
374
|
let cachedZero: { key: string; instance: ZeroInstance } | null = null
|
|
358
375
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
376
|
+
// when ProvideZero is rendered without a real Zero instance (SSG, disable=true,
|
|
377
|
+
// or transiently while the active path is still creating its first instance),
|
|
378
|
+
// we want descendants' useZero() / useConnectionState() / on-zero useQuery to
|
|
379
|
+
// NOT throw — but also not run real queries. Hand them a stub Zero plus
|
|
380
|
+
// DisabledContext='empty':
|
|
381
|
+
// 1. zero/react's useZero() reads ZeroContext; the stub is truthy so it
|
|
382
|
+
// doesn't throw "useZero must be used within a ZeroProvider".
|
|
383
|
+
// 2. on-zero's useQuery wrapper forces enabled=false to the underlying
|
|
384
|
+
// zero useQuery when DisabledContext is set, so zero's viewStore.getView
|
|
385
|
+
// returns its disabled-view stub without ever reading zero.clientID or
|
|
386
|
+
// subscribing through the stub.
|
|
387
|
+
// 3. addContextToQuery(query, zero.context) is the only deep access in the
|
|
388
|
+
// query path; the stub's .context is a plain object so that call
|
|
389
|
+
// succeeds harmlessly.
|
|
390
|
+
// 4. useConnectionState reads zero.connection.state.{subscribe,current};
|
|
391
|
+
// we provide a perma-'closed' state with a no-op subscribe. consumers
|
|
392
|
+
// handle 'closed' as a normal disconnected state.
|
|
393
|
+
// This stub lets the provider tree render with stable shape regardless of
|
|
394
|
+
// whether Zero is active — so children never re-parent across enable/disable.
|
|
395
|
+
const DISABLED_ZERO_STUB_CONNECTION_STATE = {
|
|
396
|
+
current: { name: 'closed' as const },
|
|
397
|
+
subscribe: () => () => {},
|
|
398
|
+
}
|
|
399
|
+
const DISABLED_ZERO_STUB = {
|
|
400
|
+
context: {},
|
|
401
|
+
connection: { state: DISABLED_ZERO_STUB_CONNECTION_STATE },
|
|
402
|
+
} as unknown as ZeroInstance
|
|
403
|
+
|
|
404
|
+
type ProvideZeroProps = Omit<ZeroOptions<Schema, ZeroMutators>, 'schema' | 'mutators'> & {
|
|
368
405
|
children: ReactNode
|
|
369
406
|
authData?: AuthData | null
|
|
407
|
+
// when true, ProvideZero renders a stable shell with stub Zero — no real
|
|
408
|
+
// client is created, no websocket is opened, no IDB store is touched.
|
|
409
|
+
// useQuery descendants receive EMPTY_RESPONSE via DisabledContext='empty'.
|
|
410
|
+
// toggling this on/off NEVER re-parents children: the React tree shape is
|
|
411
|
+
// identical in both modes (active just mounts a sibling lifecycle, which
|
|
412
|
+
// doesn't shift children's position). use this when consumers need the
|
|
413
|
+
// provider tree mounted (e.g. inside a marketing splash that lazily
|
|
414
|
+
// upgrades to the real IDE) without paying for Zero until activation.
|
|
370
415
|
disable?: boolean
|
|
371
416
|
// 'http-pull' runs the stock zero client over stateless HTTP pull/push
|
|
372
417
|
// (no websocket, no resident server state) by intercepting the sync
|
|
@@ -378,7 +423,42 @@ export function createZeroClientInternal<
|
|
|
378
423
|
// awaited before a self-healing recovery reload — e.g. wait for the dev
|
|
379
424
|
// origin to be reachable so the reload doesn't hit a restarting server.
|
|
380
425
|
beforeReload?: () => Promise<void>
|
|
381
|
-
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const ProvideZero = ({ children, ...props }: ProvideZeroProps) => {
|
|
429
|
+
// SSG branch: NO HOOKS. on-zero's hooks call useRef/useState/useEffect
|
|
430
|
+
// through its bundled React copy, which the SSG build's runtime sees as
|
|
431
|
+
// null ("Cannot read properties of null (reading 'useRef')") because react
|
|
432
|
+
// isn't deduplicated across the bundle and on-zero's slot is undefined at
|
|
433
|
+
// render time. emit the stable shell synchronously instead. children
|
|
434
|
+
// re-parent ONCE at hydration (server: this branch; client: the active
|
|
435
|
+
// branch), but that happens before any heavy descendant (e.g. consumer
|
|
436
|
+
// F2CShell-style skip-first-render mounts) is in the tree — so the parent
|
|
437
|
+
// swap is invisible at the DOM layer (all our wrappers are
|
|
438
|
+
// Context.Providers with no DOM) and incurs no remount jank.
|
|
439
|
+
if (typeof window === 'undefined' || props.disable) {
|
|
440
|
+
return (
|
|
441
|
+
<AuthDataContext.Provider value={(props.authData ?? {}) as AuthData}>
|
|
442
|
+
<DisabledContext.Provider value="empty">
|
|
443
|
+
<ZeroContext.Provider value={DISABLED_ZERO_STUB as any}>
|
|
444
|
+
{children}
|
|
445
|
+
</ZeroContext.Provider>
|
|
446
|
+
</DisabledContext.Provider>
|
|
447
|
+
</AuthDataContext.Provider>
|
|
448
|
+
)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
return <ProvideZeroActive {...props}>{children}</ProvideZeroActive>
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const ProvideZeroActive = ({
|
|
455
|
+
children,
|
|
456
|
+
authData: authDataIn,
|
|
457
|
+
transport,
|
|
458
|
+
pullIntervalMs = 30_000,
|
|
459
|
+
beforeReload,
|
|
460
|
+
...props
|
|
461
|
+
}: Omit<ProvideZeroProps, 'disable'>) => {
|
|
382
462
|
// resolve the auth token first: a real logout (token gone) must clear
|
|
383
463
|
// authData so client mutators don't keep running as the old user, while a
|
|
384
464
|
// transient authData blip with the token still present (session refresh, tab
|
|
@@ -513,20 +593,21 @@ export function createZeroClientInternal<
|
|
|
513
593
|
}
|
|
514
594
|
}, [instance, auth])
|
|
515
595
|
|
|
516
|
-
//
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
596
|
+
// Always render the same shell shape, with or without an instance. While
|
|
597
|
+
// the instance is being constructed (first effect tick) we hand descendants
|
|
598
|
+
// the stub Zero plus DisabledContext='empty' so useZero/useQuery
|
|
599
|
+
// short-circuit instead of throwing. SetZeroInstance + ConnectionMonitor
|
|
600
|
+
// only mount once instance exists, as siblings of children — they NEVER
|
|
601
|
+
// wrap children, so toggling them never re-parents.
|
|
521
602
|
return (
|
|
522
603
|
<AuthDataContext.Provider value={authData}>
|
|
523
|
-
{instance ?
|
|
524
|
-
<
|
|
525
|
-
<SetZeroInstance />
|
|
526
|
-
<ConnectionMonitor zeroEvents={zeroEvents} />
|
|
604
|
+
<DisabledContext.Provider value={instance ? false : 'empty'}>
|
|
605
|
+
<ZeroContext.Provider value={instance ?? (DISABLED_ZERO_STUB as any)}>
|
|
606
|
+
{instance ? <SetZeroInstance /> : null}
|
|
607
|
+
{instance ? <ConnectionMonitor zeroEvents={zeroEvents} /> : null}
|
|
527
608
|
{children}
|
|
528
|
-
</
|
|
529
|
-
|
|
609
|
+
</ZeroContext.Provider>
|
|
610
|
+
</DisabledContext.Provider>
|
|
530
611
|
</AuthDataContext.Provider>
|
|
531
612
|
)
|
|
532
613
|
}
|
|
@@ -142,6 +142,9 @@ function ControlUserProbe({ id, ttl }: { id: string; ttl?: number }) {
|
|
|
142
142
|
|
|
143
143
|
function MaterializeProbe() {
|
|
144
144
|
const zero = useZero() as any
|
|
145
|
+
// ProvideZero hands children a stub Zero (no .materialize) until the real
|
|
146
|
+
// instance is created in an effect. skip on the stub render.
|
|
147
|
+
if (typeof zero.materialize !== 'function') return null
|
|
145
148
|
if (!zero.__onZeroMaterializeProbe) {
|
|
146
149
|
zero.__onZeroMaterializeProbe = true
|
|
147
150
|
const material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EAAE,KAAK,GAAG,OAAO,CAAA;IACtB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAsLD,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,UAAU,EAAE,EAC9D,eAAe,EACf,aAAa,EACb,OAAO,EACP,WAAW,GACZ,EAAE,UAAU,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,CAAC,CAuDpE"}
|
|
@@ -26,14 +26,14 @@ export type DirectQueryAdapter<Schema extends ZeroSchema> = (props: {
|
|
|
26
26
|
export declare function createZeroClient<Schema extends ZeroSchema, Models extends GenericModels>(options: CreateZeroClientOptions<Schema, Models>): {
|
|
27
27
|
instanceName: string;
|
|
28
28
|
zeroEvents: Emitter<ZeroEvent | null>;
|
|
29
|
-
ProvideZero: ({ children,
|
|
29
|
+
ProvideZero: ({ children, ...props }: Omit<ZeroOptions<Schema, GetZeroMutators<Models>>, "schema" | "mutators"> & {
|
|
30
30
|
children: ReactNode;
|
|
31
31
|
authData?: {} | null | undefined;
|
|
32
32
|
disable?: boolean;
|
|
33
33
|
transport?: "http-pull";
|
|
34
34
|
pullIntervalMs?: number;
|
|
35
35
|
beforeReload?: (() => Promise<void>) | undefined;
|
|
36
|
-
}) =>
|
|
36
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
37
37
|
ControlQueries: ({ children, action, whenDisabled, }: {
|
|
38
38
|
children: ReactNode;
|
|
39
39
|
action?: "enable" | "disable";
|
|
@@ -64,14 +64,14 @@ export declare function createZeroClientInternal<Schema extends ZeroSchema, Mode
|
|
|
64
64
|
}): {
|
|
65
65
|
instanceName: string;
|
|
66
66
|
zeroEvents: Emitter<ZeroEvent | null>;
|
|
67
|
-
ProvideZero: ({ children,
|
|
67
|
+
ProvideZero: ({ children, ...props }: Omit<ZeroOptions<Schema, GetZeroMutators<Models>>, "schema" | "mutators"> & {
|
|
68
68
|
children: ReactNode;
|
|
69
69
|
authData?: AuthData | null;
|
|
70
70
|
disable?: boolean;
|
|
71
71
|
transport?: "http-pull";
|
|
72
72
|
pullIntervalMs?: number;
|
|
73
73
|
beforeReload?: () => Promise<void>;
|
|
74
|
-
}) =>
|
|
74
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
75
75
|
ControlQueries: ({ children, action, whenDisabled, }: {
|
|
76
76
|
children: ReactNode;
|
|
77
77
|
action?: "enable" | "disable";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createZeroClient.d.ts","sourceRoot":"","sources":["../src/createZeroClient.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"createZeroClient.d.ts","sourceRoot":"","sources":["../src/createZeroClient.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,IAAI,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAO/E,OAAO,EAAiB,KAAK,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAQL,KAAK,OAAO,EACZ,KAAK,SAAS,EACf,MAAM,OAAO,CAAA;AAId,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAA;AAWzB,OAAO,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAOhE,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAClF,OAAO,KAAK,EACV,gBAAgB,EAChB,KAAK,EACL,GAAG,EAEH,WAAW,EACX,MAAM,IAAI,UAAU,EACrB,MAAM,gBAAgB,CAAA;AAEvB,KAAK,cAAc,GAAG;IAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AAEvE,MAAM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