@quilted/quilt 0.9.1 → 0.9.2

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.
Files changed (2) hide show
  1. package/CHANGELOG.md +234 -0
  2. package/package.json +9 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,239 @@
1
1
  # @quilted/quilt
2
2
 
3
+ ## 0.9.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#894](https://github.com/lemonmade/quilt/pull/894) [`fb998d1`](https://github.com/lemonmade/quilt/commit/fb998d1d0a7fb7981184daa5307320477355ace8) Thanks [@lemonmade](https://github.com/lemonmade)! - Consolidate all framework context into a unified `QuiltContext` architecture.
8
+
9
+ Previously, Quilt's context was fragmented across many standalone provider components (`AsyncContext`, `GraphQLContext`, `EmailContext`, etc.), each backed by its own Preact context object. This release consolidates everything into a single `QuiltContext` interface, augmented by each package via TypeScript module declaration merging, and provided by a single `<QuiltFrameworkContext>` component.
10
+
11
+ ## Breaking changes
12
+
13
+ ### All packages: unified `QuiltContext` interface
14
+
15
+ Each `@quilted/*` package now augments a single `QuiltContext` interface from `@quilted/preact-context` rather than maintaining its own standalone context. If you were accessing any Quilt context values directly via `useContext(SomeSpecificContext)`, switch to the appropriate `use*` hook instead.
16
+
17
+ ### `@quilted/preact-router`: `useRouter` renamed to `useNavigation`
18
+
19
+ ```ts
20
+ // Before
21
+ import {useRouter} from '@quilted/quilt/navigation';
22
+ const router = useRouter();
23
+
24
+ // After
25
+ import {useNavigation} from '@quilted/quilt/navigation';
26
+ const navigation = useNavigation();
27
+ ```
28
+
29
+ ### `@quilted/preact-router`: `router` QuiltContext field renamed to `navigation`
30
+
31
+ The `QuiltContext` field that holds the navigation instance is now `navigation` instead of `router`. This affects any code that reads the field directly, and the prop name on `<QuiltFrameworkContext>`.
32
+
33
+ ```tsx
34
+ // Before
35
+ <QuiltFrameworkContext router={myNavigation} />
36
+
37
+ // After
38
+ <QuiltFrameworkContext navigation={myNavigation} />
39
+ ```
40
+
41
+ ### `@quilted/preact-router`: `TestRouter` renamed to `TestNavigation`
42
+
43
+ ```ts
44
+ // Before
45
+ import {TestRouter} from '@quilted/quilt/navigation/testing';
46
+
47
+ // After
48
+ import {TestNavigation} from '@quilted/quilt/navigation/testing';
49
+ ```
50
+
51
+ ### `@quilted/preact-browser`: `browserDetails` and `browserAssets` QuiltContext fields renamed
52
+
53
+ The `QuiltContext` fields for browser environment details and the asset manifest have shorter, cleaner names:
54
+
55
+ - `browserDetails` → `browser`
56
+ - `browserAssets` → `assets`
57
+
58
+ These affect the props on `<QuiltFrameworkContext>` and any direct reads of the context.
59
+
60
+ ```tsx
61
+ // Before
62
+ <QuiltFrameworkContext browserDetails={browser} browserAssets={assets} />
63
+
64
+ // After
65
+ <QuiltFrameworkContext browser={browser} assets={assets} />
66
+ ```
67
+
68
+ ### `@quilted/preact-localize`: `localize` QuiltContext field renamed to `localization`
69
+
70
+ The QuiltContext field and the corresponding `<QuiltFrameworkContext>` prop are now `localization`:
71
+
72
+ ```tsx
73
+ // Before
74
+ <QuiltFrameworkContext localize={localization} />
75
+
76
+ // After
77
+ <QuiltFrameworkContext localization={localization} />
78
+ ```
79
+
80
+ ### `@quilted/preact-localize`: `createLocalizedFormatting` and `createLocalization` removed
81
+
82
+ These factory functions have been removed. Use the `Localization` class directly:
83
+
84
+ ```ts
85
+ // Before
86
+ import {createLocalization} from '@quilted/preact-localize';
87
+ const localization = createLocalization('en');
88
+
89
+ // After
90
+ import {Localization} from '@quilted/preact-localize';
91
+ const localization = new Localization('en');
92
+ ```
93
+
94
+ ### `@quilted/preact-async`: `AsyncContext` component removed
95
+
96
+ The standalone `<AsyncContext>` provider component has been removed. Pass async context directly to `<QuiltFrameworkContext>` instead:
97
+
98
+ ```tsx
99
+ // Before
100
+ import {AsyncContext, AsyncActionCache} from '@quilted/quilt/async';
101
+
102
+ <AsyncContext cache={cache}>
103
+ <App />
104
+ </AsyncContext>;
105
+
106
+ // After
107
+ import {QuiltFrameworkContext} from '@quilted/quilt/context';
108
+ import {AsyncActionCache} from '@quilted/quilt/async';
109
+
110
+ <QuiltFrameworkContext async={{cache}}>
111
+ <App />
112
+ </QuiltFrameworkContext>;
113
+ ```
114
+
115
+ `QuiltFrameworkContext` handles cache serialization for server-side rendering automatically, so no other changes are required.
116
+
117
+ ### `@quilted/preact-graphql`: `GraphQLContext` component removed
118
+
119
+ The standalone `<GraphQLContext>` provider component has been removed. The two separate `graphqlRun` and `graphqlCache` props on `<QuiltFrameworkContext>` have been replaced with a single `graphql` prop that accepts a `GraphQLClient` instance (or any object with `fetch` and `cache` properties):
120
+
121
+ ```tsx
122
+ // Before
123
+ import {GraphQLContext} from '@quilted/quilt/graphql';
124
+
125
+ <QuiltFrameworkContext navigation={navigation}>
126
+ <GraphQLContext fetch={myFetch} cache={myCache}>
127
+ <App />
128
+ </GraphQLContext>
129
+ </QuiltFrameworkContext>;
130
+
131
+ // After — using the new GraphQLClient class
132
+ import {GraphQLClient} from '@quilted/quilt/graphql';
133
+
134
+ const graphql = new GraphQLClient(myFetch);
135
+
136
+ <QuiltFrameworkContext navigation={navigation} graphql={graphql}>
137
+ <App />
138
+ </QuiltFrameworkContext>;
139
+ ```
140
+
141
+ ### `@quilted/preact-email`: `EmailContext` removed
142
+
143
+ The standalone `EmailContext` Preact context object has been removed. Email components should use the new `useEmailManager()` hook to access the email manager, which reads from the unified `QuiltContext`:
144
+
145
+ ```ts
146
+ // Before
147
+ import {useContext} from 'preact/hooks';
148
+ import {EmailContext} from '@quilted/preact-email';
149
+ const email = useContext(EmailContext);
150
+
151
+ // After
152
+ import {useEmailManager} from '@quilted/preact-email';
153
+ const email = useEmailManager();
154
+ ```
155
+
156
+ ### `@quilted/quilt`: `QuiltContext` component renamed to `QuiltFrameworkContext`
157
+
158
+ The provider component is now named `QuiltFrameworkContext` to avoid a name clash with the `QuiltContext` TypeScript interface:
159
+
160
+ ```tsx
161
+ // Before
162
+ import {QuiltContext} from '@quilted/quilt/context';
163
+ <QuiltContext navigation={navigation}>...</QuiltContext>;
164
+
165
+ // After
166
+ import {QuiltFrameworkContext} from '@quilted/quilt/context';
167
+ <QuiltFrameworkContext navigation={navigation}>...</QuiltFrameworkContext>;
168
+ ```
169
+
170
+ ### `@quilted/quilt`: `QuiltTestContext` renamed to `QuiltFrameworkTestContext`, takes `localization` instead of `locale`
171
+
172
+ The test context helper component is now `QuiltFrameworkTestContext` and accepts a `Localization` instance directly instead of a locale string:
173
+
174
+ ```tsx
175
+ // Before
176
+ import {QuiltTestContext} from '@quilted/quilt/context/testing';
177
+ <QuiltTestContext locale="fr">...</QuiltTestContext>;
178
+
179
+ // After
180
+ import {QuiltFrameworkTestContext} from '@quilted/quilt/context/testing';
181
+ import {Localization} from '@quilted/quilt/localize';
182
+ <QuiltFrameworkTestContext localization={new Localization('fr')}>
183
+ ...
184
+ </QuiltFrameworkTestContext>;
185
+ ```
186
+
187
+ ## New features
188
+
189
+ ### `@quilted/graphql`: `GraphQLClient` class
190
+
191
+ A new `GraphQLClient` class bundles a GraphQL fetch function and an optional result cache into a single object. A cache is created automatically by default, configured to use the same fetch function:
192
+
193
+ ```ts
194
+ import {createGraphQLFetch, GraphQLClient} from '@quilted/quilt/graphql';
195
+
196
+ // Cache created automatically from the fetch function
197
+ const client = new GraphQLClient(createGraphQLFetch({url: '/graphql'}));
198
+
199
+ // Disable caching
200
+ const client = new GraphQLClient(myFetch, {cache: false});
201
+
202
+ // Share an existing cache
203
+ const cache = new GraphQLCache();
204
+ const client = new GraphQLClient(myFetch, {cache});
205
+
206
+ // Use the client
207
+ client.fetch(MyQuery, {variables: {id: '1'}});
208
+ client.cache?.query(MyQuery, {variables: {id: '1'}});
209
+ ```
210
+
211
+ ### `@quilted/preact-router`: `useNavigation()` hook
212
+
213
+ The renamed `useNavigation()` hook returns the active `Navigation` instance from context, providing access to the current URL, navigation history, and programmatic navigation.
214
+
215
+ ### `@quilted/preact-email`: `useEmailManager()` hook
216
+
217
+ A new `useEmailManager()` hook provides access to the `EmailManager` instance from the unified `QuiltContext`. Returns `undefined` outside of an email rendering context.
218
+
219
+ ### `@quilted/preact-async`: signal-backed `async.isHydrated`
220
+
221
+ The `AsyncContext` interface (accessed via `useQuiltContext('async')`) now includes an `isHydrated` boolean getter backed by a Preact signal. Any component that reads `async.isHydrated` will automatically re-render when the client hydration completes, without requiring a manual signal subscription.
222
+
223
+ ### `@quilted/localize`: `Localization` class documentation
224
+
225
+ The `Localization` class now has full JSDoc documentation on the class, constructor, all properties (`locale`, `direction`, `numberFormatter`, `dateTimeFormatter`), and all methods (`formatNumber`, `formatCurrency`, `formatDate`).
226
+
227
+ - Updated dependencies [[`fb998d1`](https://github.com/lemonmade/quilt/commit/fb998d1d0a7fb7981184daa5307320477355ace8)]:
228
+ - @quilted/graphql@3.4.0
229
+ - @quilted/preact-performance@0.1.3
230
+ - @quilted/preact-localize@0.4.2
231
+ - @quilted/preact-browser@0.2.7
232
+ - @quilted/preact-context@0.1.5
233
+ - @quilted/preact-graphql@0.1.10
234
+ - @quilted/preact-router@0.2.16
235
+ - @quilted/preact-async@0.1.23
236
+
3
237
  ## 0.9.1
4
238
 
5
239
  ### Patch Changes
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quilted/quilt",
3
3
  "type": "module",
4
- "version": "0.9.1",
4
+ "version": "0.9.2",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/lemonmade/quilt.git",
@@ -241,15 +241,15 @@
241
241
  "@quilted/assets": "^0.1.11",
242
242
  "@quilted/async": "^0.4.23",
243
243
  "@quilted/events": "^2.1.4",
244
- "@quilted/graphql": "^3.3.10",
244
+ "@quilted/graphql": "^3.4.0",
245
245
  "@quilted/hono": "^0.2.0",
246
- "@quilted/preact-async": "^0.1.22",
247
- "@quilted/preact-browser": "^0.2.6",
248
- "@quilted/preact-context": "^0.1.4",
249
- "@quilted/preact-graphql": "^0.1.9",
250
- "@quilted/preact-localize": "^0.4.1",
251
- "@quilted/preact-performance": "^0.1.2",
252
- "@quilted/preact-router": "^0.2.15",
246
+ "@quilted/preact-async": "^0.1.23",
247
+ "@quilted/preact-browser": "^0.2.7",
248
+ "@quilted/preact-context": "^0.1.5",
249
+ "@quilted/preact-graphql": "^0.1.10",
250
+ "@quilted/preact-localize": "^0.4.2",
251
+ "@quilted/preact-performance": "^0.1.3",
252
+ "@quilted/preact-router": "^0.2.16",
253
253
  "@quilted/preact-signals": "^0.1.3",
254
254
  "@quilted/preact-testing": "^0.1.9",
255
255
  "@quilted/preact-workers": "^0.2.2",