@molecule/app-react 1.6.3 → 1.6.5
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/README.md +43 -6
- package/dist/hooks/useStore.d.ts +15 -1
- package/dist/hooks/useStore.d.ts.map +1 -1
- package/dist/hooks/useStore.js +30 -4
- package/dist/hooks/useStore.js.map +1 -1
- package/dist/providers.d.ts +4 -1
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +14 -3
- package/dist/providers.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-10-
|
|
6
|
+
Generated: 2026-10-17T00:35:27.553Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-react
|
|
10
10
|
|
|
11
|
-
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
-
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
-
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
-
|
|
15
11
|
React framework bindings for the Molecule app stack.
|
|
16
12
|
|
|
17
13
|
Provides React hooks, contexts, and provider components for all molecule
|
|
@@ -19,6 +15,10 @@ core interfaces (auth, i18n, theme, routing, state, http, storage, logger,
|
|
|
19
15
|
chat, workspace, editor, preview), so framework-agnostic providers plug
|
|
20
16
|
into React idioms.
|
|
21
17
|
|
|
18
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
19
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
20
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
21
|
+
|
|
22
22
|
## Quick Start
|
|
23
23
|
|
|
24
24
|
```tsx
|
|
@@ -188,6 +188,27 @@ interface AuthClient<T = UserProfile> {
|
|
|
188
188
|
* Initializes auth state (e.g., from stored tokens).
|
|
189
189
|
*/
|
|
190
190
|
initialize(): Promise<void>
|
|
191
|
+
/**
|
|
192
|
+
* Resolves when the session restore started by `initialize()` has settled — the point
|
|
193
|
+
* after which the client knows whether this visitor is signed in.
|
|
194
|
+
*
|
|
195
|
+
* Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
|
|
196
|
+
* called, and after it has finished. A restore that failed resolves too (it settled the
|
|
197
|
+
* question), so an HTTP client can await this before every request without risking one
|
|
198
|
+
* held forever. That is what makes the fetch-before-restore race impossible: a page that
|
|
199
|
+
* fetches viewer-dependent data on mount waits here instead of going out anonymously
|
|
200
|
+
* (see `setAuthGate` in `@molecule/app-http`).
|
|
201
|
+
*
|
|
202
|
+
* Optional: a provider that restores no session has nothing to wait for. Without it, an
|
|
203
|
+
* HTTP client bonded to that provider sends first-paint requests unauthenticated.
|
|
204
|
+
*
|
|
205
|
+
* A provider whose restore sends a request THROUGH the gated HTTP client must send that
|
|
206
|
+
* request with `skipAuthGate: true` (`RequestConfig` in `@molecule/app-http`): the gate
|
|
207
|
+
* waits on this promise, so holding the restore's own request makes the gate wait on
|
|
208
|
+
* itself and stalls every request it holds until it times out. `createJWTAuthClient`'s
|
|
209
|
+
* restore does not need it — it uses `fetch`, not the bonded client.
|
|
210
|
+
*/
|
|
211
|
+
whenRestored?(): Promise<void>
|
|
191
212
|
/**
|
|
192
213
|
* Subscribes to auth state changes.
|
|
193
214
|
*/
|
|
@@ -2221,6 +2242,13 @@ function useStorage(): {
|
|
|
2221
2242
|
|
|
2222
2243
|
Hook to access the state provider from context.
|
|
2223
2244
|
|
|
2245
|
+
The context comes from `<StateProvider provider={…}>` or from
|
|
2246
|
+
`<MoleculeProvider>` — which supplies the provider bonded under
|
|
2247
|
+
`@molecule/app-state` by default, so a scaffolded app needs no `state` prop.
|
|
2248
|
+
|
|
2249
|
+
Only hooks that read the context call this; `useStore(store)` takes its store
|
|
2250
|
+
as an argument and works with no provider at all.
|
|
2251
|
+
|
|
2224
2252
|
```typescript
|
|
2225
2253
|
function useStateProvider(): StateProvider
|
|
2226
2254
|
```
|
|
@@ -2231,6 +2259,12 @@ function useStateProvider(): StateProvider
|
|
|
2231
2259
|
|
|
2232
2260
|
Hook to subscribe to a store with optional selector and equality function.
|
|
2233
2261
|
|
|
2262
|
+
The store is the argument, so this hook needs NO `StateProvider`: it reads
|
|
2263
|
+
`store.getState()` and subscribes with `store.subscribe()`, and never touches
|
|
2264
|
+
the state context. A store minted outside the `state` bond — the direct
|
|
2265
|
+
`createStoreWithActions()` / `createStore()` a provider package exports — is
|
|
2266
|
+
therefore as valid here as one `@molecule/app-state`'s `createStore()` made.
|
|
2267
|
+
|
|
2234
2268
|
```typescript
|
|
2235
2269
|
function useStore(store: Store<T>, options?: UseStoreOptions<T, S>): S
|
|
2236
2270
|
```
|
|
@@ -2637,7 +2671,10 @@ function PreviewProvider({
|
|
|
2637
2671
|
Combined provider for all molecule services.
|
|
2638
2672
|
|
|
2639
2673
|
Provides a convenient way to wrap your app with all molecule providers at once.
|
|
2640
|
-
Only providers that are passed will be included
|
|
2674
|
+
Only providers that are passed will be included — except `state`, which falls
|
|
2675
|
+
back to the state provider bonded under `@molecule/app-state` (set by
|
|
2676
|
+
`setupAllDefaultBonds()` or a state bond) so `useStore()` works without a
|
|
2677
|
+
`state` prop.
|
|
2641
2678
|
|
|
2642
2679
|
```typescript
|
|
2643
2680
|
function MoleculeProvider({
|
package/dist/hooks/useStore.d.ts
CHANGED
|
@@ -8,13 +8,27 @@ import type { UseStoreOptions } from '../types.js';
|
|
|
8
8
|
/**
|
|
9
9
|
* Hook to access the state provider from context.
|
|
10
10
|
*
|
|
11
|
+
* The context comes from `<StateProvider provider={…}>` or from
|
|
12
|
+
* `<MoleculeProvider>` — which supplies the provider bonded under
|
|
13
|
+
* `@molecule/app-state` by default, so a scaffolded app needs no `state` prop.
|
|
14
|
+
*
|
|
15
|
+
* Only hooks that read the context call this; `useStore(store)` takes its store
|
|
16
|
+
* as an argument and works with no provider at all.
|
|
17
|
+
*
|
|
11
18
|
* @returns The state provider from context
|
|
12
|
-
* @throws {Error}
|
|
19
|
+
* @throws {Error} when no `StateProvider` is above the component — the message
|
|
20
|
+
* names the fix (which provider to render, and the import for it).
|
|
13
21
|
*/
|
|
14
22
|
export declare function useStateProvider(): StateProvider;
|
|
15
23
|
/**
|
|
16
24
|
* Hook to subscribe to a store with optional selector and equality function.
|
|
17
25
|
*
|
|
26
|
+
* The store is the argument, so this hook needs NO `StateProvider`: it reads
|
|
27
|
+
* `store.getState()` and subscribes with `store.subscribe()`, and never touches
|
|
28
|
+
* the state context. A store minted outside the `state` bond — the direct
|
|
29
|
+
* `createStoreWithActions()` / `createStore()` a provider package exports — is
|
|
30
|
+
* therefore as valid here as one `@molecule/app-state`'s `createStore()` made.
|
|
31
|
+
*
|
|
18
32
|
* @param store - The store to subscribe to
|
|
19
33
|
* @param options - Hook options (selector, equalityFn)
|
|
20
34
|
* @returns The selected state
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../../src/hooks/useStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../../src/hooks/useStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAG/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAkBlD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAUhD;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CA6BtF;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAEpE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,EAAE,CAAC,EACzD,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EACf,MAAM,EAAE,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,GAC/F,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,CAAC,CAKtB"}
|
package/dist/hooks/useStore.js
CHANGED
|
@@ -6,24 +6,52 @@
|
|
|
6
6
|
import { useCallback, useContext, useRef, useSyncExternalStore } from 'react';
|
|
7
7
|
import { t } from '@molecule/app-i18n';
|
|
8
8
|
import { StateContext } from '../contexts.js';
|
|
9
|
+
/**
|
|
10
|
+
* The fix, appended to the error below — this hook is the one place that READS
|
|
11
|
+
* the context, so it is the one place that has to say where the context comes
|
|
12
|
+
* from. The sentences are code (an import, a component, a bond call), so they
|
|
13
|
+
* are appended in English rather than translated.
|
|
14
|
+
*/
|
|
15
|
+
const STATE_CONTEXT_FIX = ' To fix: render a state provider above this component — ' +
|
|
16
|
+
"`import { MoleculeProvider, StateProvider } from '@molecule/app-react'`; " +
|
|
17
|
+
'<MoleculeProvider> passes the provider bonded under `@molecule/app-state` ' +
|
|
18
|
+
'(bond one with `setupAllDefaultBonds()` from `@molecule/app-bonds-default-react`, ' +
|
|
19
|
+
'or `setProvider(provider)` from `@molecule/app-state`), and ' +
|
|
20
|
+
'<StateProvider provider={provider}> passes one you hold. ' +
|
|
21
|
+
'To read a store you already have, call useStore(store) instead — it subscribes to the ' +
|
|
22
|
+
'store it is given and needs no provider.';
|
|
9
23
|
/**
|
|
10
24
|
* Hook to access the state provider from context.
|
|
11
25
|
*
|
|
26
|
+
* The context comes from `<StateProvider provider={…}>` or from
|
|
27
|
+
* `<MoleculeProvider>` — which supplies the provider bonded under
|
|
28
|
+
* `@molecule/app-state` by default, so a scaffolded app needs no `state` prop.
|
|
29
|
+
*
|
|
30
|
+
* Only hooks that read the context call this; `useStore(store)` takes its store
|
|
31
|
+
* as an argument and works with no provider at all.
|
|
32
|
+
*
|
|
12
33
|
* @returns The state provider from context
|
|
13
|
-
* @throws {Error}
|
|
34
|
+
* @throws {Error} when no `StateProvider` is above the component — the message
|
|
35
|
+
* names the fix (which provider to render, and the import for it).
|
|
14
36
|
*/
|
|
15
37
|
export function useStateProvider() {
|
|
16
38
|
const provider = useContext(StateContext);
|
|
17
39
|
if (!provider) {
|
|
18
40
|
throw new Error(t('react.error.useStoreOutsideProvider', undefined, {
|
|
19
41
|
defaultValue: 'useStateProvider must be used within a StateProvider',
|
|
20
|
-
}));
|
|
42
|
+
}) + STATE_CONTEXT_FIX);
|
|
21
43
|
}
|
|
22
44
|
return provider;
|
|
23
45
|
}
|
|
24
46
|
/**
|
|
25
47
|
* Hook to subscribe to a store with optional selector and equality function.
|
|
26
48
|
*
|
|
49
|
+
* The store is the argument, so this hook needs NO `StateProvider`: it reads
|
|
50
|
+
* `store.getState()` and subscribes with `store.subscribe()`, and never touches
|
|
51
|
+
* the state context. A store minted outside the `state` bond — the direct
|
|
52
|
+
* `createStoreWithActions()` / `createStore()` a provider package exports — is
|
|
53
|
+
* therefore as valid here as one `@molecule/app-state`'s `createStore()` made.
|
|
54
|
+
*
|
|
27
55
|
* @param store - The store to subscribe to
|
|
28
56
|
* @param options - Hook options (selector, equalityFn)
|
|
29
57
|
* @returns The selected state
|
|
@@ -35,8 +63,6 @@ export function useStateProvider() {
|
|
|
35
63
|
* ```
|
|
36
64
|
*/
|
|
37
65
|
export function useStore(store, options) {
|
|
38
|
-
// Validate that we're within a StateProvider
|
|
39
|
-
useStateProvider();
|
|
40
66
|
const { selector, equalityFn } = options ?? {};
|
|
41
67
|
// Use a ref to track the previous selected value for equality comparison
|
|
42
68
|
const prevSelectedRef = useRef(undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.js","sourceRoot":"","sources":["../../src/hooks/useStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAE7E,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAG7C;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,QAAQ,GAAG,UAAU,CAAC,YAAY,CAAC,CAAA;IACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,CAAC,CAAC,qCAAqC,EAAE,SAAS,EAAE;YAClD,YAAY,EAAE,sDAAsD;SACrE,CAAC,
|
|
1
|
+
{"version":3,"file":"useStore.js","sourceRoot":"","sources":["../../src/hooks/useStore.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAA;AAE7E,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAGtC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAA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AAE,CAAC,KAAK,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAA;IAEjC,MAAM,SAAS,GAAG,WAAW,CAC3B,CAAC,aAAyB,EAAE,EAAE;QAC5B,OAAO,KAAK,CAAC,SAAS,CAAC,aAAa,CAAC,CAAA;IACvC,CAAC,EACD,CAAC,KAAK,CAAC,CACR,CAAA;IAED,OAAO,oBAAoB,CAAC,SAAS,EAAE,WAAW,EAAE,WAAW,CAAC,CAAA;AAClE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAI,KAAe;IAC5C,OAAO,KAAK,CAAC,QAAQ,CAAA;AACvB,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,cAAc,CAC5B,KAAe,EACf,MAAgG;IAEhG,OAAO,WAAW,CAChB,CAAC,GAAG,IAAU,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,EAClE,CAAC,KAAK,EAAE,MAAM,CAAC,CAChB,CAAA;AACH,CAAC"}
|
package/dist/providers.d.ts
CHANGED
|
@@ -163,7 +163,10 @@ export declare function PreviewProvider({ provider, children }: PreviewProviderP
|
|
|
163
163
|
* Combined provider for all molecule services.
|
|
164
164
|
*
|
|
165
165
|
* Provides a convenient way to wrap your app with all molecule providers at once.
|
|
166
|
-
* Only providers that are passed will be included
|
|
166
|
+
* Only providers that are passed will be included — except `state`, which falls
|
|
167
|
+
* back to the state provider bonded under `@molecule/app-state` (set by
|
|
168
|
+
* `setupAllDefaultBonds()` or a state bond) so `useStore()` works without a
|
|
169
|
+
* `state` prop.
|
|
167
170
|
*
|
|
168
171
|
* @param props - Component props (see {@link MoleculeProviderProps}) — each service is
|
|
169
172
|
* optional, and ONLY the services passed are provided to the tree.
|
package/dist/providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAA;AAsBzB,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAE5F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,GAAG,OAAO,EAAE,EACxC,MAAM,EACN,QAAQ,GACT,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,YAAY,CAI3C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,kBAAkB,GAAG,KAAK,CAAC,YAAY,CAE5F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAE5F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAE1F;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAExF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAEhG;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAE9F;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,iBAAiB,GAAG,KAAK,CAAC,YAAY,CAE1F;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,QAAQ,GACT,EAAE,sBAAsB,GAAG,KAAK,CAAC,YAAY,CAE7C;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,mBAAmB,GAAG,KAAK,CAAC,YAAY,CAE9F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,oBAAoB,GAAG,KAAK,CAAC,YAAY,CAEhG;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,KAAK,EACL,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,MAAM,EACN,IAAI,EACJ,SAAS,EACT,MAAM,EACN,OAAO,GACR,EAAE,qBAAqB,GAAG,KAAK,CAAC,YAAY,CA4D5C"}
|
package/dist/providers.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { getProvider as getStateProvider, hasProvider as hasStateProvider, } from '@molecule/app-state';
|
|
2
3
|
import { AuthContext, ChatContext, EditorContext, HttpContext, I18nContext, LoggerContext, PreviewContext, RouterContext, StateContext, StorageContext, ThemeContext, WorkspaceContext, } from './contexts.js';
|
|
3
4
|
/**
|
|
4
5
|
* Provider for state management.
|
|
@@ -182,7 +183,10 @@ export function PreviewProvider({ provider, children }) {
|
|
|
182
183
|
* Combined provider for all molecule services.
|
|
183
184
|
*
|
|
184
185
|
* Provides a convenient way to wrap your app with all molecule providers at once.
|
|
185
|
-
* Only providers that are passed will be included
|
|
186
|
+
* Only providers that are passed will be included — except `state`, which falls
|
|
187
|
+
* back to the state provider bonded under `@molecule/app-state` (set by
|
|
188
|
+
* `setupAllDefaultBonds()` or a state bond) so `useStore()` works without a
|
|
189
|
+
* `state` prop.
|
|
186
190
|
*
|
|
187
191
|
* @param props - Component props (see {@link MoleculeProviderProps}) — each service is
|
|
188
192
|
* optional, and ONLY the services passed are provided to the tree.
|
|
@@ -240,8 +244,15 @@ export function MoleculeProvider({ children, state, auth, theme, router, i18n, h
|
|
|
240
244
|
if (auth) {
|
|
241
245
|
result = _jsx(AuthContext.Provider, { value: auth, children: result });
|
|
242
246
|
}
|
|
243
|
-
|
|
244
|
-
|
|
247
|
+
// Fall back to the BONDED state provider: it is the singleton every
|
|
248
|
+
// `createStore()` reads, so `useStore()` inside a scaffolded app needs no
|
|
249
|
+
// `state` prop. Nothing wired the React context before, so the documented
|
|
250
|
+
// createStore()+useStore() pattern threw "useStateProvider must be used
|
|
251
|
+
// within a StateProvider" on a correctly-built app (X1 flash-m65). A
|
|
252
|
+
// `state` prop still wins — that is how an app overrides the bond.
|
|
253
|
+
const stateContext = state ?? (hasStateProvider() ? getStateProvider() : undefined);
|
|
254
|
+
if (stateContext) {
|
|
255
|
+
result = _jsx(StateContext.Provider, { value: stateContext, children: result });
|
|
245
256
|
}
|
|
246
257
|
return _jsx(_Fragment, { children: result });
|
|
247
258
|
}
|
package/dist/providers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.tsx"],"names":[],"mappings":";AAUA,OAAO,EACL,WAAW,IAAI,gBAAgB,EAC/B,WAAW,IAAI,gBAAgB,GAChC,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EACL,WAAW,EACX,WAAW,EACX,aAAa,EACb,WAAW,EACX,WAAW,EACX,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,gBAAgB,GACjB,MAAM,eAAe,CAAA;AAiBtB;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAsB;IACtE,OAAO,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAyB,CAAA;AACnF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAc,EACxC,MAAM,EACN,QAAQ,GACa;IACrB,OAAO,CACL,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,MAA6B,YAAG,QAAQ,GAAwB,CAC9F,CAAA;AACH,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAsB;IACtE,OAAO,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAAG,QAAQ,GAAyB,CAAA;AACnF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAuB;IACtE,OAAO,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAAG,QAAQ,GAA0B,CAAA;AACnF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,YAAY,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAqB;IACp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CAAC;IAED,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,GAAG,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YAAG,MAAM,GAAwB,CAAA;IAC7E,CAAC;IAED,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,GAAG,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YAAG,MAAM,GAAwB,CAAA;IAC7E,CAAC;IAED,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,GAAG,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YAAG,MAAM,GAA0B,CAAA;IACnF,CAAC;IAED,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,GAAG,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,MAAM,GAAyB,CAAA;IAChF,CAAC;IAED,IAAI,IAAI,EAAE,CAAC;QACT,MAAM,GAAG,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,YAAG,MAAM,GAAwB,CAAA;IAC7E,CAAC;IAED,oEAAoE;IACpE,0EAA0E;IAC1E,0EAA0E;IAC1E,wEAAwE;IACxE,qEAAqE;IACrE,mEAAmE;IACnE,MAAM,YAAY,GAAG,KAAK,IAAI,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAA;IACnF,IAAI,YAAY,EAAE,CAAC;QACjB,MAAM,GAAG,KAAC,YAAY,CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAAG,MAAM,GAAyB,CAAA;IACvF,CAAC;IAED,OAAO,4BAAG,MAAM,GAAI,CAAA;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-react",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.5",
|
|
4
4
|
"description": "React framework bindings for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
61
|
"@molecule/app-ai-models": "1.4.0",
|
|
62
|
+
"@molecule/app-bonds-default-react": "1.1.2",
|
|
62
63
|
"@molecule/app-i18n": "1.0.3",
|
|
63
64
|
"@testing-library/dom": "10.4.1",
|
|
64
65
|
"@testing-library/react": "16.3.2",
|