@molecule/app-bonds-default-react 1.0.5 → 1.1.1

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/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+
1
2
  Apache License
2
3
  Version 2.0, January 2004
3
4
  http://www.apache.org/licenses/
@@ -34,21 +35,33 @@
34
35
 
35
36
  "Work" shall mean the work of authorship, whether in Source or
36
37
  Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work.
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
38
40
 
39
41
  "Derivative Works" shall mean any work, whether in Source or Object
40
42
  form, that is based on (or derived from) the Work and for which the
41
43
  editorial revisions, annotations, elaborations, or other modifications
42
- represent, as a whole, an original work of authorship.
43
-
44
- "Contribution" shall mean any work of authorship, including the
45
- original version of the Work and any modifications or additions
46
- to that Work, that is intentionally submitted to the Licensor for
47
- inclusion in the Work by the copyright owner or by an individual or
48
- Legal Entity authorized to submit on behalf of the copyright owner.
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
49
62
 
50
63
  "Contributor" shall mean Licensor and any individual or Legal Entity
51
- on behalf of whom a Contribution has been received by the Licensor and
64
+ on behalf of whom a Contribution has been received by Licensor and
52
65
  subsequently incorporated within the Work.
53
66
 
54
67
  2. Grant of Copyright License. Subject to the terms and conditions of
@@ -61,8 +74,18 @@
61
74
  3. Grant of Patent License. Subject to the terms and conditions of
62
75
  this License, each Contributor hereby grants to You a perpetual,
63
76
  worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
- patent license to make, have made, use, offer to sell, sell, import,
65
- and otherwise transfer the Work.
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
66
89
 
67
90
  4. Redistribution. You may reproduce and distribute copies of the
68
91
  Work or Derivative Works thereof in any medium, with or without
@@ -84,23 +107,87 @@
84
107
  (d) If the Work includes a "NOTICE" text file as part of its
85
108
  distribution, then any Derivative Works that You distribute must
86
109
  include a readable copy of the attribution notices contained
87
- within such NOTICE file.
88
-
89
- 5. Submission of Contributions.
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
90
138
 
91
139
  6. Trademarks. This License does not grant permission to use the trade
92
- names, trademarks, service marks, or product names of the Licensor.
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
93
143
 
94
144
  7. Disclaimer of Warranty. Unless required by applicable law or
95
- agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
-
98
- 8. Limitation of Liability. In no event and under no legal theory shall
99
- any Contributor be liable to You for damages.
100
-
101
- 9. Accepting Warranty or Additional Liability.
102
-
103
- Copyright 2026 Molecule Dev, Inc.
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
104
191
 
105
192
  Licensed under the Apache License, Version 2.0 (the "License");
106
193
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -3,7 +3,7 @@ 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-09-28T05:52:41.892Z
6
+ Generated: 2026-10-16T08:11:11.584Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-bonds-default-react
@@ -19,8 +19,11 @@ React fleet stack, replacing the byte-identical per-app files:
19
19
  whole scaffolded `src/main.tsx`: awaits `setupProviders()` BEFORE the
20
20
  first render, kicks off `authClient.initialize()` (best-effort), mounts
21
21
  `<App />` in StrictMode on `#root`, then registers the PWA.
22
- - `setupAllDefaultBonds()` — wires the SEVEN universal bonds in one call:
23
- fonts-arimo, routing-react-router, storage-localstorage, styling-tailwind
22
+ - `setupAllDefaultBonds()` — wires the EIGHT universal bonds in one call:
23
+ state (the vanilla `simpleProvider`, so `createStore()` works from the
24
+ first render — the documented `createStore()` + `useStore()` pattern needs
25
+ a provider bonded and nothing else in a scaffold wires one), fonts-arimo,
26
+ routing-react-router, storage-localstorage, styling-tailwind
24
27
  (registers the tailwind-merge class merger), theme-css-variables
25
28
  (light + dark via `getDefaultThemeProvider()`), ui-tailwind ClassMap,
26
29
  icons-molecule. Each also exists as an individual `setupApp*()` for apps
@@ -72,7 +75,7 @@ bootstrapApp({
72
75
  ## Installation
73
76
 
74
77
  ```bash
75
- npm install @molecule/app-bonds-default-react @molecule/app-auth @molecule/app-charts @molecule/app-charts-chartjs @molecule/app-client-search @molecule/app-client-search-minisearch @molecule/app-code-editor @molecule/app-code-editor-monaco @molecule/app-command-palette @molecule/app-command-palette-cmdk @molecule/app-drag-drop @molecule/app-drag-drop-dndkit @molecule/app-fonts @molecule/app-fonts-arimo @molecule/app-http @molecule/app-icons @molecule/app-icons-molecule @molecule/app-keyboard-shortcuts @molecule/app-keyboard-shortcuts-hotkeys @molecule/app-maps @molecule/app-maps-leaflet @molecule/app-realtime @molecule/app-realtime-socketio @molecule/app-routing @molecule/app-routing-react-router @molecule/app-storage @molecule/app-storage-localstorage @molecule/app-styling-tailwind @molecule/app-theme @molecule/app-theme-css-variables @molecule/app-ui @molecule/app-ui-tailwind @molecule/app-video @molecule/app-video-hls @molecule/app-virtual-scroll @molecule/app-virtual-scroll-tanstack react react-dom
78
+ npm install @molecule/app-bonds-default-react @molecule/app-auth @molecule/app-charts @molecule/app-charts-chartjs @molecule/app-client-search @molecule/app-client-search-minisearch @molecule/app-code-editor @molecule/app-code-editor-monaco @molecule/app-command-palette @molecule/app-command-palette-cmdk @molecule/app-drag-drop @molecule/app-drag-drop-dndkit @molecule/app-fonts @molecule/app-fonts-arimo @molecule/app-http @molecule/app-icons @molecule/app-icons-molecule @molecule/app-keyboard-shortcuts @molecule/app-keyboard-shortcuts-hotkeys @molecule/app-maps @molecule/app-maps-leaflet @molecule/app-realtime @molecule/app-realtime-socketio @molecule/app-routing @molecule/app-routing-react-router @molecule/app-state @molecule/app-storage @molecule/app-storage-localstorage @molecule/app-styling-tailwind @molecule/app-theme @molecule/app-theme-css-variables @molecule/app-ui @molecule/app-ui-tailwind @molecule/app-video @molecule/app-video-hls @molecule/app-virtual-scroll @molecule/app-virtual-scroll-tanstack react react-dom
76
79
  npm install -D @types/react @types/react-dom
77
80
  ```
78
81
 
@@ -80,22 +83,37 @@ npm install -D @types/react @types/react-dom
80
83
 
81
84
  ### Functions
82
85
 
83
- #### `bootstrapApp(opts)`
86
+ #### `createDefaultHttpClient(baseURL)`
84
87
 
85
- Boot the React app: wire bonds, kick off auth initialization, mount
86
- `<App />` inside `<StrictMode>` to `#root`, and (optionally) register
87
- the PWA service worker.
88
+ Builds the default fetch-based HTTP client + wires it into
89
+ `@molecule/app-http`. Replaces the per-app `bonds/http-default.ts`
90
+ shipped by ~52 fleet apps.
88
91
 
89
- Replaces the 20-line per-app `src/main.tsx` that 97 fleet apps shipped
90
- byte-identically.
92
+ ```typescript
93
+ function createDefaultHttpClient(baseURL: string): {
94
+ httpClient: HttpClient
95
+ setupHttpDefault: () => void
96
+ }
97
+ ```
98
+
99
+ #### `createDefaultHttpClientWithAuthBearer(opts)`
100
+
101
+ Variant of `createDefaultHttpClient` that adds a request interceptor
102
+ injecting the JWT bearer token from the auth client AND (optionally)
103
+ stripping a leading `/api/` from request URLs.
104
+
105
+ Replaces ~20 per-app `bonds/http-default.ts` files that hand-roll
106
+ this same wiring. Pass `stripApiPrefix: true` when the app uses
107
+ `baseURL: '/api'` to handle pages that pass `/api/`-prefixed paths
108
+ (would otherwise resolve to `/api/api/...` and 404).
91
109
 
92
110
  ```typescript
93
- function bootstrapApp(opts: {
94
- App: ComponentType
95
- authClient: { initialize: () => Promise<void> }
96
- setupProviders: () => void | Promise<void>
97
- registerPWA?: () => void
98
- }): void
111
+ function createDefaultHttpClientWithAuthBearer(opts: {
112
+ baseURL: string
113
+ withCredentials?: boolean
114
+ stripApiPrefix?: boolean
115
+ getToken: () => string | null | undefined
116
+ }): { httpClient: HttpClient; setupHttpDefault: () => void }
99
117
  ```
100
118
 
101
119
  #### `createDefaultAuthClient(authConfig)`
@@ -113,23 +131,6 @@ function createDefaultAuthClient(authConfig: AuthClientConfig): {
113
131
  }
114
132
  ```
115
133
 
116
- #### `createDefaultAuthClientWithFetchClient(authConfig, fetchClientOptions)`
117
-
118
- Most aggressive variant — bonds a fetch-based HTTP client with the
119
- given `baseURL` (so molecule pkg `useGet('/path')` calls hit
120
- `${baseURL}/path` instead of the SPA's catch-all route), AND keeps
121
- its bearer token in sync with auth events.
122
-
123
- Used by apps where molecule packages render pricing / billing /
124
- other authed JSON-fetching screens that need both behaviors.
125
-
126
- ```typescript
127
- function createDefaultAuthClientWithFetchClient(
128
- authConfig: AuthClientConfig,
129
- fetchClientOptions: { baseURL: string; withCredentials?: boolean },
130
- ): { authClient: AuthClient<TUser>; setupAuthDefault: () => void }
131
- ```
132
-
133
134
  #### `createDefaultAuthClientWithHttpSync(authConfig)`
134
135
 
135
136
  Variant of `createDefaultAuthClient` that also keeps the bonded
@@ -148,37 +149,39 @@ function createDefaultAuthClientWithHttpSync(authConfig: AuthClientConfig): {
148
149
  }
149
150
  ```
150
151
 
151
- #### `createDefaultHttpClient(baseURL)`
152
+ #### `createDefaultAuthClientWithFetchClient(authConfig, fetchClientOptions)`
152
153
 
153
- Builds the default fetch-based HTTP client + wires it into
154
- `@molecule/app-http`. Replaces the per-app `bonds/http-default.ts`
155
- shipped by ~52 fleet apps.
154
+ Most aggressive variant — bonds a fetch-based HTTP client with the
155
+ given `baseURL` (so molecule pkg `useGet('/path')` calls hit
156
+ `${baseURL}/path` instead of the SPA's catch-all route), AND keeps
157
+ its bearer token in sync with auth events.
158
+
159
+ Used by apps where molecule packages render pricing / billing /
160
+ other authed JSON-fetching screens that need both behaviors.
156
161
 
157
162
  ```typescript
158
- function createDefaultHttpClient(baseURL: string): {
159
- httpClient: HttpClient
160
- setupHttpDefault: () => void
161
- }
163
+ function createDefaultAuthClientWithFetchClient(
164
+ authConfig: AuthClientConfig,
165
+ fetchClientOptions: { baseURL: string; withCredentials?: boolean },
166
+ ): { authClient: AuthClient<TUser>; setupAuthDefault: () => void }
162
167
  ```
163
168
 
164
- #### `createDefaultHttpClientWithAuthBearer(opts)`
169
+ #### `bootstrapApp(opts)`
165
170
 
166
- Variant of `createDefaultHttpClient` that adds a request interceptor
167
- injecting the JWT bearer token from the auth client AND (optionally)
168
- stripping a leading `/api/` from request URLs.
171
+ Boot the React app: wire bonds, kick off auth initialization, mount
172
+ `<App />` inside `<StrictMode>` to `#root`, and (optionally) register
173
+ the PWA service worker.
169
174
 
170
- Replaces ~20 per-app `bonds/http-default.ts` files that hand-roll
171
- this same wiring. Pass `stripApiPrefix: true` when the app uses
172
- `baseURL: '/api'` to handle pages that pass `/api/`-prefixed paths
173
- (would otherwise resolve to `/api/api/...` and 404).
175
+ Replaces the 20-line per-app `src/main.tsx` that 97 fleet apps shipped
176
+ byte-identically.
174
177
 
175
178
  ```typescript
176
- function createDefaultHttpClientWithAuthBearer(opts: {
177
- baseURL: string
178
- withCredentials?: boolean
179
- stripApiPrefix?: boolean
180
- getToken: () => string | null | undefined
181
- }): { httpClient: HttpClient; setupHttpDefault: () => void }
179
+ function bootstrapApp(opts: {
180
+ App: ComponentType
181
+ authClient: { initialize: () => Promise<void> }
182
+ setupProviders: () => void | Promise<void>
183
+ registerPWA?: () => void
184
+ }): void
182
185
  ```
183
186
 
184
187
  #### `getDefaultThemeProvider()`
@@ -189,19 +192,6 @@ Returns (and lazily constructs) the shared default CSS-variables theme provider.
189
192
  function getDefaultThemeProvider(): ThemeProvider
190
193
  ```
191
194
 
192
- #### `setupAllDefaultBonds()`
193
-
194
- Wires all 7 universal app-side bonds in one call — fonts, routing,
195
- storage, styling, theme, UI ClassMap, icons (in that order). Auth
196
-
197
- - i18n stay per-app because they need app-specific config.
198
-
199
- Replaces 9 individual setupX() calls in per-app `bonds/index.ts`.
200
-
201
- ```typescript
202
- function setupAllDefaultBonds(): void
203
- ```
204
-
205
195
  #### `setupAppFontsArimo()`
206
196
 
207
197
  Wires `@molecule/app-fonts-arimo` to `@molecule/app-fonts`.
@@ -226,6 +216,21 @@ Wires `@molecule/app-routing-react-router` to `@molecule/app-routing`.
226
216
  function setupAppRoutingReactRouter(): void
227
217
  ```
228
218
 
219
+ #### `setupAppStateSimple()`
220
+
221
+ Wires the framework-agnostic `simpleProvider` from `@molecule/app-state` as
222
+ the active state provider.
223
+
224
+ WITHOUT this, `createStore()` throws
225
+ `@molecule/app-state: No provider set. Call setProvider() first` — nothing
226
+ else in a scaffolded app wires the `state` bond, so the documented
227
+ `createStore()` + `useStore()` pattern failed at the first render and every
228
+ page came up blank while `tsc` passed (X1 flash-m65).
229
+
230
+ ```typescript
231
+ function setupAppStateSimple(): void
232
+ ```
233
+
229
234
  #### `setupAppStorageLocalstorage()`
230
235
 
231
236
  Wires `@molecule/app-storage-localstorage` to `@molecule/app-storage`.
@@ -262,6 +267,19 @@ Wires `@molecule/app-ui-tailwind` `classMap` to `@molecule/app-ui`.
262
267
  function setupAppUiTailwind(): void
263
268
  ```
264
269
 
270
+ #### `setupAllDefaultBonds()`
271
+
272
+ Wires all 8 universal app-side bonds in one call — state (the vanilla
273
+ `simpleProvider`, so `createStore()` works), fonts, routing, storage,
274
+ styling, theme, UI ClassMap, icons (in that order). Auth + i18n stay
275
+ per-app because they need app-specific config.
276
+
277
+ Replaces the individual setupX() calls in per-app `bonds/index.ts`.
278
+
279
+ ```typescript
280
+ function setupAllDefaultBonds(): void
281
+ ```
282
+
265
283
  ## Injection Notes
266
284
 
267
285
  ### Requirements
@@ -292,6 +310,7 @@ Peer dependencies:
292
310
  - `@molecule/app-realtime-socketio` ^1.0.1
293
311
  - `@molecule/app-routing` ^1.0.1
294
312
  - `@molecule/app-routing-react-router` ^1.0.1
313
+ - `@molecule/app-state` ^1.0.1
295
314
  - `@molecule/app-storage` ^1.0.1
296
315
  - `@molecule/app-storage-localstorage` ^1.0.1
297
316
  - `@molecule/app-styling-tailwind` ^1.0.1
@@ -332,6 +351,7 @@ Peer dependencies:
332
351
  - `@molecule/app-realtime-socketio`
333
352
  - `@molecule/app-routing`
334
353
  - `@molecule/app-routing-react-router`
354
+ - `@molecule/app-state`
335
355
  - `@molecule/app-storage`
336
356
  - `@molecule/app-storage-localstorage`
337
357
  - `@molecule/app-styling-tailwind`
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAOpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG;IACxD,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAMA;AAED;;;;;;;;;GASG;AACH,wBAAgB,qCAAqC,CAAC,IAAI,EAAE;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAC1C,GAAG;IACF,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAmBA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EAC7E,UAAU,EAAE,gBAAgB,GAC3B;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAMA;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EACzF,UAAU,EAAE,gBAAgB,GAC3B;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAwBA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EAC5F,UAAU,EAAE,gBAAgB,EAC5B,kBAAkB,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CA0BA"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AA8BpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG;IACxD,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAMA;AAED;;;;;;;;;GASG;AACH,wBAAgB,qCAAqC,CAAC,IAAI,EAAE;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAC1C,GAAG;IACF,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAmBA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EAC7E,UAAU,EAAE,gBAAgB,GAC3B;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAMA;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EACzF,UAAU,EAAE,gBAAgB,GAC3B;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CA2BA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EAC5F,UAAU,EAAE,gBAAgB,EAC5B,kBAAkB,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CA2BA"}
package/dist/auth.js CHANGED
@@ -1,5 +1,26 @@
1
1
  import { createJWTAuthClient, setClient } from '@molecule/app-auth';
2
- import { createFetchClient, getClient as getHttpClient, setClient as setHttpClient, } from '@molecule/app-http';
2
+ import { createFetchClient, getClient as getHttpClient, setAuthGate, setClient as setHttpClient, } from '@molecule/app-http';
3
+ /**
4
+ * Holds every HTTP request until this auth client's session restore has settled.
5
+ *
6
+ * Without it a page effect that fires on mount (fetching a profile's `following`
7
+ * flag, a feed, a `favorited` state) sends its request before `initialize()` has
8
+ * restored the session, so it leaves with no `Authorization` header and the server
9
+ * answers for an anonymous viewer. Localhost usually hides it — the restore wins
10
+ * the race against the first effect there — and the deployed URL exposes it, which
11
+ * is how X1 xr-molecule-flash-m95 spent ~25 min treating a "Follow" button on a
12
+ * followed user as database leftovers.
13
+ *
14
+ * `whenRestored()` resolves immediately when no restore is in flight, so a request
15
+ * made after boot never waits at all; it holds only while the restore is actually
16
+ * running. A provider without `whenRestored` (a bond that restores nothing) leaves
17
+ * requests ungated.
18
+ *
19
+ * @param authClient - The bonded auth client.
20
+ */
21
+ function registerAuthGate(authClient) {
22
+ setAuthGate(() => authClient.whenRestored?.() ?? Promise.resolve());
23
+ }
3
24
  /**
4
25
  * Builds the default fetch-based HTTP client + wires it into
5
26
  * `@molecule/app-http`. Replaces the per-app `bonds/http-default.ts`
@@ -91,6 +112,9 @@ export function createDefaultAuthClientWithHttpSync(authConfig) {
91
112
  authClient,
92
113
  setupAuthDefault: () => {
93
114
  setClient(authClient);
115
+ // Requests made while the session is still restoring wait for it, so a page
116
+ // effect that fetches viewer-dependent data on mount cannot race the restore.
117
+ registerAuthGate(authClient);
94
118
  const initialToken = authClient.getAccessToken();
95
119
  if (initialToken) {
96
120
  getHttpClient().setAuthToken(initialToken);
@@ -131,6 +155,7 @@ export function createDefaultAuthClientWithFetchClient(authConfig, fetchClientOp
131
155
  });
132
156
  setHttpClient(httpClient);
133
157
  setClient(authClient);
158
+ registerAuthGate(authClient);
134
159
  const initialToken = authClient.getAccessToken();
135
160
  if (initialToken) {
136
161
  httpClient.setAuthToken(initialToken);
package/dist/index.d.ts CHANGED
@@ -6,8 +6,11 @@
6
6
  * whole scaffolded `src/main.tsx`: awaits `setupProviders()` BEFORE the
7
7
  * first render, kicks off `authClient.initialize()` (best-effort), mounts
8
8
  * `<App />` in StrictMode on `#root`, then registers the PWA.
9
- * - `setupAllDefaultBonds()` — wires the SEVEN universal bonds in one call:
10
- * fonts-arimo, routing-react-router, storage-localstorage, styling-tailwind
9
+ * - `setupAllDefaultBonds()` — wires the EIGHT universal bonds in one call:
10
+ * state (the vanilla `simpleProvider`, so `createStore()` works from the
11
+ * first render — the documented `createStore()` + `useStore()` pattern needs
12
+ * a provider bonded and nothing else in a scaffold wires one), fonts-arimo,
13
+ * routing-react-router, storage-localstorage, styling-tailwind
11
14
  * (registers the tailwind-merge class merger), theme-css-variables
12
15
  * (light + dark via `getDefaultThemeProvider()`), ui-tailwind ClassMap,
13
16
  * icons-molecule. Each also exists as an individual `setupApp*()` for apps
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuFG;AAEH,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -6,8 +6,11 @@
6
6
  * whole scaffolded `src/main.tsx`: awaits `setupProviders()` BEFORE the
7
7
  * first render, kicks off `authClient.initialize()` (best-effort), mounts
8
8
  * `<App />` in StrictMode on `#root`, then registers the PWA.
9
- * - `setupAllDefaultBonds()` — wires the SEVEN universal bonds in one call:
10
- * fonts-arimo, routing-react-router, storage-localstorage, styling-tailwind
9
+ * - `setupAllDefaultBonds()` — wires the EIGHT universal bonds in one call:
10
+ * state (the vanilla `simpleProvider`, so `createStore()` works from the
11
+ * first render — the documented `createStore()` + `useStore()` pattern needs
12
+ * a provider bonded and nothing else in a scaffold wires one), fonts-arimo,
13
+ * routing-react-router, storage-localstorage, styling-tailwind
11
14
  * (registers the tailwind-merge class merger), theme-css-variables
12
15
  * (light + dark via `getDefaultThemeProvider()`), ui-tailwind ClassMap,
13
16
  * icons-molecule. Each also exists as an individual `setupApp*()` for apps
package/dist/setup.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Default app-side bond wirings (React + Tailwind + React Router +
2
+ * Default app-side bond wirings (state + React + Tailwind + React Router +
3
3
  * localStorage + Arimo font + Molecule icons).
4
4
  *
5
- * Centralizes 5 byte-identical `app/src/bonds/<name>.ts` setup
5
+ * Centralizes the byte-identical `app/src/bonds/<name>.ts` setup
6
6
  * functions that every flagship app shipped. Per-app bond files
7
7
  * become 1-line re-exports — `bonds/index.ts` import sites unchanged.
8
8
  *
@@ -21,6 +21,17 @@ export declare function setupAppFontsArimo(): void;
21
21
  export declare function setupAppIconsMolecule(): void;
22
22
  /** Wires `@molecule/app-routing-react-router` to `@molecule/app-routing`. */
23
23
  export declare function setupAppRoutingReactRouter(): void;
24
+ /**
25
+ * Wires the framework-agnostic `simpleProvider` from `@molecule/app-state` as
26
+ * the active state provider.
27
+ *
28
+ * WITHOUT this, `createStore()` throws
29
+ * `@molecule/app-state: No provider set. Call setProvider() first` — nothing
30
+ * else in a scaffolded app wires the `state` bond, so the documented
31
+ * `createStore()` + `useStore()` pattern failed at the first render and every
32
+ * page came up blank while `tsc` passed (X1 flash-m65).
33
+ */
34
+ export declare function setupAppStateSimple(): void;
24
35
  /** Wires `@molecule/app-storage-localstorage` to `@molecule/app-storage`. */
25
36
  export declare function setupAppStorageLocalstorage(): void;
26
37
  /**
@@ -36,11 +47,12 @@ export declare function setupAppThemeCssVariables(): void;
36
47
  /** Wires `@molecule/app-ui-tailwind` `classMap` to `@molecule/app-ui`. */
37
48
  export declare function setupAppUiTailwind(): void;
38
49
  /**
39
- * Wires all 7 universal app-side bonds in one call — fonts, routing,
40
- * storage, styling, theme, UI ClassMap, icons (in that order). Auth
41
- * + i18n stay per-app because they need app-specific config.
50
+ * Wires all 8 universal app-side bonds in one call — state (the vanilla
51
+ * `simpleProvider`, so `createStore()` works), fonts, routing, storage,
52
+ * styling, theme, UI ClassMap, icons (in that order). Auth + i18n stay
53
+ * per-app because they need app-specific config.
42
54
  *
43
- * Replaces 9 individual setupX() calls in per-app `bonds/index.ts`.
55
+ * Replaces the individual setupX() calls in per-app `bonds/index.ts`.
44
56
  */
45
57
  export declare function setupAllDefaultBonds(): void;
46
58
  //# sourceMappingURL=setup.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAYH,OAAO,EACL,+BAA+B,EAGhC,MAAM,mCAAmC,CAAA;AAe1C,uFAAuF;AACvF,wBAAgB,uBAAuB,IAAI,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAS5F;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,qEAAqE;AACrE,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,6EAA6E;AAC7E,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED,6EAA6E;AAC7E,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,4FAA4F;AAC5F,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAQ3C"}
1
+ {"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../src/setup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAgBH,OAAO,EACL,+BAA+B,EAGhC,MAAM,mCAAmC,CAAA;AAe1C,uFAAuF;AACvF,wBAAgB,uBAAuB,IAAI,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAS5F;AAED,kEAAkE;AAClE,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED,qEAAqE;AACrE,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,6EAA6E;AAC7E,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAED;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED,6EAA6E;AAC7E,wBAAgB,2BAA2B,IAAI,IAAI,CAElD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C;AAED,4FAA4F;AAC5F,wBAAgB,yBAAyB,IAAI,IAAI,CAEhD;AAED,0EAA0E;AAC1E,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAS3C"}
package/dist/setup.js CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * Default app-side bond wirings (React + Tailwind + React Router +
2
+ * Default app-side bond wirings (state + React + Tailwind + React Router +
3
3
  * localStorage + Arimo font + Molecule icons).
4
4
  *
5
- * Centralizes 5 byte-identical `app/src/bonds/<name>.ts` setup
5
+ * Centralizes the byte-identical `app/src/bonds/<name>.ts` setup
6
6
  * functions that every flagship app shipped. Per-app bond files
7
7
  * become 1-line re-exports — `bonds/index.ts` import sites unchanged.
8
8
  *
@@ -18,6 +18,7 @@ import { setIconSet } from '@molecule/app-icons';
18
18
  import { iconSet as moleculeIconSet } from '@molecule/app-icons-molecule';
19
19
  import { setRouter } from '@molecule/app-routing';
20
20
  import { provider as reactRouterProvider } from '@molecule/app-routing-react-router';
21
+ import { setProvider as setState, simpleProvider as defaultStateProvider, } from '@molecule/app-state';
21
22
  import { setProvider as setStorage } from '@molecule/app-storage';
22
23
  import { provider as localStorageProvider } from '@molecule/app-storage-localstorage';
23
24
  import { registerTailwindClassMerger } from '@molecule/app-styling-tailwind';
@@ -59,6 +60,19 @@ export function setupAppIconsMolecule() {
59
60
  export function setupAppRoutingReactRouter() {
60
61
  setRouter(reactRouterProvider);
61
62
  }
63
+ /**
64
+ * Wires the framework-agnostic `simpleProvider` from `@molecule/app-state` as
65
+ * the active state provider.
66
+ *
67
+ * WITHOUT this, `createStore()` throws
68
+ * `@molecule/app-state: No provider set. Call setProvider() first` — nothing
69
+ * else in a scaffolded app wires the `state` bond, so the documented
70
+ * `createStore()` + `useStore()` pattern failed at the first render and every
71
+ * page came up blank while `tsc` passed (X1 flash-m65).
72
+ */
73
+ export function setupAppStateSimple() {
74
+ setState(defaultStateProvider);
75
+ }
62
76
  /** Wires `@molecule/app-storage-localstorage` to `@molecule/app-storage`. */
63
77
  export function setupAppStorageLocalstorage() {
64
78
  setStorage(localStorageProvider);
@@ -82,13 +96,15 @@ export function setupAppUiTailwind() {
82
96
  setClassMap(classMap);
83
97
  }
84
98
  /**
85
- * Wires all 7 universal app-side bonds in one call — fonts, routing,
86
- * storage, styling, theme, UI ClassMap, icons (in that order). Auth
87
- * + i18n stay per-app because they need app-specific config.
99
+ * Wires all 8 universal app-side bonds in one call — state (the vanilla
100
+ * `simpleProvider`, so `createStore()` works), fonts, routing, storage,
101
+ * styling, theme, UI ClassMap, icons (in that order). Auth + i18n stay
102
+ * per-app because they need app-specific config.
88
103
  *
89
- * Replaces 9 individual setupX() calls in per-app `bonds/index.ts`.
104
+ * Replaces the individual setupX() calls in per-app `bonds/index.ts`.
90
105
  */
91
106
  export function setupAllDefaultBonds() {
107
+ setupAppStateSimple();
92
108
  setupAppFontsArimo();
93
109
  setupAppRoutingReactRouter();
94
110
  setupAppStorageLocalstorage();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-bonds-default-react",
3
- "version": "1.0.5",
3
+ "version": "1.1.1",
4
4
  "description": "Default app-side bond wirings for React+Tailwind+react-router+localStorage+Arimo font+molecule icons. 5 setup functions consolidating 665 byte-identical per-app bond wiring files across the fleet.",
5
5
  "homepage": "https://www.molecule.dev/packages/app-bonds-default-react",
6
6
  "type": "module",
@@ -38,19 +38,19 @@
38
38
  "directory": "packages/app/infrastructure/bonds-default-react"
39
39
  },
40
40
  "devDependencies": {
41
- "@molecule/app-auth": "1.1.1",
41
+ "@molecule/app-auth": "1.2.2",
42
42
  "@molecule/app-charts-chartjs": "1.0.2",
43
- "@molecule/app-client-search": "1.0.1",
44
- "@molecule/app-client-search-minisearch": "1.0.1",
43
+ "@molecule/app-client-search": "1.0.2",
44
+ "@molecule/app-client-search-minisearch": "1.0.3",
45
45
  "@molecule/app-code-editor": "1.0.2",
46
- "@molecule/app-code-editor-monaco": "1.0.2",
46
+ "@molecule/app-code-editor-monaco": "1.0.3",
47
47
  "@molecule/app-command-palette": "1.0.2",
48
48
  "@molecule/app-command-palette-cmdk": "1.0.2",
49
49
  "@molecule/app-drag-drop": "1.0.2",
50
50
  "@molecule/app-drag-drop-dndkit": "1.0.2",
51
51
  "@molecule/app-fonts": "1.1.0",
52
52
  "@molecule/app-fonts-arimo": "1.0.2",
53
- "@molecule/app-http": "1.0.2",
53
+ "@molecule/app-http": "1.1.2",
54
54
  "@molecule/app-icons": "1.0.2",
55
55
  "@molecule/app-icons-molecule": "1.0.2",
56
56
  "@molecule/app-keyboard-shortcuts": "1.0.2",
@@ -58,14 +58,15 @@
58
58
  "@molecule/app-maps-leaflet": "1.0.2",
59
59
  "@molecule/app-realtime": "1.0.2",
60
60
  "@molecule/app-realtime-socketio": "1.0.2",
61
- "@molecule/app-routing": "1.0.2",
61
+ "@molecule/app-routing": "1.0.3",
62
62
  "@molecule/app-routing-react-router": "1.0.2",
63
+ "@molecule/app-state": "1.0.3",
63
64
  "@molecule/app-storage": "1.0.2",
64
65
  "@molecule/app-storage-localstorage": "1.0.2",
65
66
  "@molecule/app-theme": "1.0.3",
66
67
  "@molecule/app-theme-css-variables": "1.0.3",
67
- "@molecule/app-ui": "1.3.2",
68
- "@molecule/app-ui-tailwind": "1.2.2",
68
+ "@molecule/app-ui": "1.3.6",
69
+ "@molecule/app-ui-tailwind": "1.2.6",
69
70
  "@molecule/app-video-hls": "1.0.2",
70
71
  "@molecule/app-virtual-scroll": "1.0.2",
71
72
  "@molecule/app-virtual-scroll-tanstack": "1.0.2",
@@ -103,6 +104,7 @@
103
104
  "@molecule/app-realtime-socketio": "^1.0.1",
104
105
  "@molecule/app-routing": "^1.0.1",
105
106
  "@molecule/app-routing-react-router": "^1.0.1",
107
+ "@molecule/app-state": "^1.0.1",
106
108
  "@molecule/app-storage": "^1.0.1",
107
109
  "@molecule/app-storage-localstorage": "^1.0.1",
108
110
  "@molecule/app-styling-tailwind": "^1.0.1",