@quilted/create 0.3.3 → 0.3.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +230 -0
  2. package/build/esnext/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/index.esnext +1 -1
  3. package/build/esnext/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/async.esnext +1 -1
  4. package/build/esnext/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/sync.esnext +1 -1
  5. package/build/esnext/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.esnext +1 -1
  6. package/build/esnext/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/index.esnext +1 -1
  7. package/build/esnext/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/async.esnext +1 -1
  8. package/build/esnext/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/sync.esnext +1 -1
  9. package/build/esnext/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.esnext +1 -1
  10. package/package.json +1 -1
  11. package/templates/app-basic/App.tsx +8 -13
  12. package/templates/app-basic/browser.tsx +1 -1
  13. package/templates/app-basic/context/browser.ts +7 -3
  14. package/templates/app-basic/context/navigation.ts +6 -13
  15. package/templates/app-basic/context/preact.ts +9 -0
  16. package/templates/app-basic/context/server.ts +10 -3
  17. package/templates/app-basic/context/types.ts +20 -1
  18. package/templates/app-basic/package.json +1 -1
  19. package/templates/app-basic/tests/render/render.tsx +17 -22
  20. package/templates/app-basic/tests/render/types.ts +17 -13
  21. package/templates/app-basic/tests/render.ts +1 -1
  22. package/templates/app-empty/package.json +1 -1
  23. package/templates/app-graphql/App.tsx +10 -16
  24. package/templates/app-graphql/browser.tsx +1 -1
  25. package/templates/app-graphql/context/browser.ts +9 -13
  26. package/templates/app-graphql/context/navigation.ts +6 -13
  27. package/templates/app-graphql/context/preact.ts +9 -0
  28. package/templates/app-graphql/context/server.ts +13 -12
  29. package/templates/app-graphql/context/types.ts +23 -6
  30. package/templates/app-graphql/package.json +1 -1
  31. package/templates/app-graphql/tests/render/render.tsx +17 -37
  32. package/templates/app-graphql/tests/render/types.ts +20 -45
  33. package/templates/app-graphql/tests/render.ts +1 -1
  34. package/templates/app-trpc/App.tsx +15 -17
  35. package/templates/app-trpc/browser.tsx +1 -1
  36. package/templates/app-trpc/context/browser.ts +8 -4
  37. package/templates/app-trpc/context/navigation.ts +6 -13
  38. package/templates/app-trpc/context/preact.ts +9 -0
  39. package/templates/app-trpc/context/server.ts +11 -4
  40. package/templates/app-trpc/context/types.ts +27 -3
  41. package/templates/app-trpc/package.json +1 -1
  42. package/templates/app-trpc/tests/render/render.tsx +25 -29
  43. package/templates/app-trpc/tests/render/types.ts +17 -16
  44. package/templates/app-trpc/tests/render.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,235 @@
1
1
  # @quilted/create
2
2
 
3
+ ## 0.3.5
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
+ ## 0.3.4
228
+
229
+ ### Patch Changes
230
+
231
+ - [`e6fa47e`](https://github.com/lemonmade/quilt/commit/e6fa47e93981ce0eaebbe1546659aaa08cc22689) Thanks [@lemonmade](https://github.com/lemonmade)! - Update Preact and Signal dependencies
232
+
3
233
  ## 0.3.3
4
234
 
5
235
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import { __exports as out } from '../../../../../../../_virtual/index11.esnext';
1
+ import { __exports as out } from '../../../../../../../_virtual/index10.esnext';
2
2
  import { __require as requireAsync } from './providers/async.esnext';
3
3
  import { __require as requireSync } from './providers/sync.esnext';
4
4
  import { __require as requireSettings } from './settings.esnext';
@@ -1,4 +1,4 @@
1
- import { __exports as async } from '../../../../../../../../_virtual/async4.esnext';
1
+ import { __exports as async } from '../../../../../../../../_virtual/async3.esnext';
2
2
 
3
3
  var hasRequiredAsync;
4
4
  function requireAsync() {
@@ -1,4 +1,4 @@
1
- import { __exports as sync } from '../../../../../../../../_virtual/sync4.esnext';
1
+ import { __exports as sync } from '../../../../../../../../_virtual/sync3.esnext';
2
2
 
3
3
  var hasRequiredSync;
4
4
  function requireSync() {
@@ -1,4 +1,4 @@
1
- import { __exports as settings } from '../../../../../../../_virtual/settings3.esnext';
1
+ import { __exports as settings } from '../../../../../../../_virtual/settings2.esnext';
2
2
  import { __require as requireFs } from './adapters/fs.esnext';
3
3
 
4
4
  var hasRequiredSettings;
@@ -1,4 +1,4 @@
1
- import { __exports as out } from '../../../../../../../_virtual/index10.esnext';
1
+ import { __exports as out } from '../../../../../../../_virtual/index11.esnext';
2
2
  import { __require as requireAsync } from './providers/async.esnext';
3
3
  import { __require as requireStream } from './providers/stream.esnext';
4
4
  import { __require as requireSync } from './providers/sync.esnext';
@@ -1,4 +1,4 @@
1
- import { __exports as async } from '../../../../../../../../_virtual/async3.esnext';
1
+ import { __exports as async } from '../../../../../../../../_virtual/async4.esnext';
2
2
  import { __require as requireAsync$1 } from '../readers/async.esnext';
3
3
 
4
4
  var hasRequiredAsync;
@@ -1,4 +1,4 @@
1
- import { __exports as sync } from '../../../../../../../../_virtual/sync3.esnext';
1
+ import { __exports as sync } from '../../../../../../../../_virtual/sync4.esnext';
2
2
  import { __require as requireSync$1 } from '../readers/sync.esnext';
3
3
 
4
4
  var hasRequiredSync;
@@ -1,4 +1,4 @@
1
- import { __exports as settings } from '../../../../../../../_virtual/settings2.esnext';
1
+ import { __exports as settings } from '../../../../../../../_virtual/settings3.esnext';
2
2
  import path__default from 'node:path';
3
3
  import { __require as requireOut } from '../../../../../@nodelib_fs.scandir@2.1.5/node_modules/@nodelib/fs.scandir/out/index.esnext';
4
4
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@quilted/create",
3
3
  "type": "module",
4
- "version": "0.3.3",
4
+ "version": "0.3.5",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,6 +1,6 @@
1
1
  import {NotFound} from '@quilted/quilt/server';
2
- import {Navigation} from '@quilted/quilt/navigation';
3
- import {Localization} from '@quilted/quilt/localize';
2
+ import {Routes} from '@quilted/quilt/navigation';
3
+ import {QuiltFrameworkContext} from '@quilted/quilt/context';
4
4
 
5
5
  import {Head} from './foundation/html.ts';
6
6
  import {Frame} from './foundation/frame.ts';
@@ -15,8 +15,6 @@ export interface AppProps {
15
15
  context: AppContext;
16
16
  }
17
17
 
18
- // Define the routes for your application. If you have a lot of routes, you
19
- // might want to split this into a separate file.
20
18
  const routes = [
21
19
  routeWithAppContext('*', {
22
20
  render: (children) => <Frame>{children}</Frame>,
@@ -32,19 +30,16 @@ const routes = [
32
30
  }),
33
31
  ];
34
32
 
35
- // The root component for your application. You will typically render any
36
- // app-wide context in this component.
37
33
  export function App({context}: AppProps) {
38
34
  return (
39
35
  <AppContextPreact.Provider value={context}>
40
- <Localization>
36
+ <QuiltFrameworkContext
37
+ navigation={context.navigation}
38
+ localization={context.localization}
39
+ >
41
40
  <Head />
42
- <Navigation
43
- router={context.navigation.router}
44
- routes={routes}
45
- context={context}
46
- />
47
- </Localization>
41
+ <Routes list={routes} context={context} />
42
+ </QuiltFrameworkContext>
48
43
  </AppContextPreact.Provider>
49
44
  );
50
45
  }
@@ -14,7 +14,7 @@ const app = new BrowserApp(<App context={context} />, {context});
14
14
  // @example
15
15
  // ```js
16
16
  // // Log the current URL
17
- // console.log(globalThis.app.context.router.currentRequest.url);
17
+ // console.log(globalThis.app.context.navigation.currentRequest.url);
18
18
  // ```
19
19
  Object.defineProperty(globalThis, 'app', {
20
20
  value: app,
@@ -1,10 +1,14 @@
1
+ import {Navigation} from '@quilted/quilt/navigation';
2
+ import {Localization} from '@quilted/quilt/localize';
3
+
1
4
  import type {AppContext} from './types.ts';
2
- import {NavigationForApp} from './navigation.ts';
3
5
 
4
6
  export class BrowserAppContext implements AppContext {
5
- readonly navigation: NavigationForApp;
7
+ readonly navigation: Navigation;
8
+ readonly localization: Localization;
6
9
 
7
10
  constructor() {
8
- this.navigation = new NavigationForApp();
11
+ this.navigation = new Navigation();
12
+ this.localization = new Localization(navigator.language);
9
13
  }
10
14
  }
@@ -1,17 +1,10 @@
1
- import {createContextRouteFunction, Router} from '@quilted/quilt/navigation';
1
+ import {
2
+ createContextRouteFunction,
3
+ Navigation,
4
+ } from '@quilted/quilt/navigation';
2
5
 
3
6
  import type {AppContext} from './types.ts';
4
7
 
5
- export interface Navigation {
6
- readonly router: Router;
7
- }
8
-
9
- export class NavigationForApp implements Navigation {
10
- readonly router: Router;
11
-
12
- constructor(url?: string | URL) {
13
- this.router = new Router(url);
14
- }
15
- }
16
-
17
8
  export const routeWithAppContext = createContextRouteFunction<AppContext>();
9
+
10
+ export {Navigation};
@@ -2,5 +2,14 @@ import {createOptionalContext} from '@quilted/quilt/context';
2
2
 
3
3
  import type {AppContext} from './types.ts';
4
4
 
5
+ /**
6
+ * The Preact context object for this application's shared context.
7
+ * Provide it in `App.tsx` via `<AppContextPreact.Provider value={context}>`.
8
+ */
5
9
  export const AppContextPreact = createOptionalContext<AppContext>();
10
+
11
+ /**
12
+ * Returns the app's shared context. All fields in `AppContext` are required
13
+ * and will be available anywhere inside `<AppContextPreact.Provider>`.
14
+ */
6
15
  export const useAppContext = AppContextPreact.use;
@@ -1,10 +1,17 @@
1
+ import {Navigation} from '@quilted/quilt/navigation';
2
+ import {Localization, parseAcceptLanguageHeader} from '@quilted/quilt/localize';
3
+
1
4
  import type {AppContext} from './types.ts';
2
- import {NavigationForApp} from './navigation.ts';
3
5
 
4
6
  export class ServerAppContext implements AppContext {
5
- readonly navigation: NavigationForApp;
7
+ readonly navigation: Navigation;
8
+ readonly localization: Localization;
6
9
 
7
10
  constructor(request: Request) {
8
- this.navigation = new NavigationForApp(request.url);
11
+ this.navigation = new Navigation(request.url);
12
+ this.localization = new Localization(
13
+ parseAcceptLanguageHeader(request.headers.get('Accept-Language') ?? '') ??
14
+ 'en',
15
+ );
9
16
  }
10
17
  }
@@ -1,5 +1,24 @@
1
- import type {Navigation} from './navigation.ts';
1
+ import type {Navigation} from '@quilted/quilt/navigation';
2
+ import type {Localization} from '@quilted/quilt/localize';
2
3
 
4
+ /**
5
+ * The shared context for this application. Values in this object are
6
+ * available to all components in the app via `useQuiltContext()` hooks
7
+ * or the `useAppContext()` convenience hook.
8
+ *
9
+ * This interface extends a subset of `QuiltContext`, providing the
10
+ * navigation and localization fields as required (non-optional) values.
11
+ */
3
12
  export interface AppContext {
13
+ /**
14
+ * The navigation instance for this application. Manages the current URL,
15
+ * browser history, and programmatic navigation.
16
+ */
4
17
  readonly navigation: Navigation;
18
+
19
+ /**
20
+ * The localization instance for this application. Contains the active
21
+ * locale and formatting utilities for numbers, dates, currencies, and more.
22
+ */
23
+ readonly localization: Localization;
5
24
  }
@@ -18,7 +18,7 @@
18
18
  "@quilted/quilt": "^0.9.0",
19
19
  "hono": "^4.8.0",
20
20
  "jsdom": "^26.0.0",
21
- "preact": "^10.26.0",
21
+ "preact": "^10.29.0",
22
22
  "react": "npm:@quilted/react@^19.0.0",
23
23
  "react-dom": "npm:@quilted/react-dom@^19.0.0"
24
24
  },
@@ -1,12 +1,8 @@
1
1
  import {createRender} from '@quilted/quilt/testing';
2
- import {
3
- BrowserDetailsContext,
4
- BrowserTestMock,
5
- } from '@quilted/quilt/browser/testing';
6
- import {Navigation, TestRouter} from '@quilted/quilt/navigation/testing';
2
+ import {TestBrowser} from '@quilted/quilt/browser/testing';
3
+ import {TestNavigation} from '@quilted/quilt/navigation/testing';
7
4
  import {Localization} from '@quilted/quilt/localize';
8
-
9
- import {AppContextPreact} from '~/context/preact.ts';
5
+ import {QuiltFrameworkTestContext} from '@quilted/quilt/context/testing';
10
6
 
11
7
  import {RenderOptions, RenderContext, RenderActions} from './types.ts';
12
8
 
@@ -23,24 +19,23 @@ export const renderApp = createRender<
23
19
  // Create context that can be used by the `render` function, and referenced by test
24
20
  // authors on the `root.context` property. Context is used to share data between your
25
21
  // React tree and your test code, and is ideal for mocking out global context providers.
26
- context({router = new TestRouter(), browser = new BrowserTestMock()}) {
27
- return {navigation: {router}, browser};
22
+ context({
23
+ navigation = new TestNavigation(),
24
+ browser = new TestBrowser(),
25
+ localization = new Localization('en'),
26
+ }) {
27
+ return {navigation, browser, localization};
28
28
  },
29
29
  // Render all of our app-wide context providers around each component under test.
30
- render(element, context, {locale = 'en'}) {
31
- const {
32
- navigation: {router},
33
- browser,
34
- } = context;
35
-
30
+ render(element, {navigation, browser, localization}) {
36
31
  return (
37
- <AppContextPreact.Provider value={context}>
38
- <BrowserDetailsContext.Provider value={browser}>
39
- <Localization locale={locale}>
40
- <Navigation router={router}>{element}</Navigation>
41
- </Localization>
42
- </BrowserDetailsContext.Provider>
43
- </AppContextPreact.Provider>
32
+ <QuiltFrameworkTestContext
33
+ navigation={navigation}
34
+ browser={browser}
35
+ localization={localization}
36
+ >
37
+ {element}
38
+ </QuiltFrameworkTestContext>
44
39
  );
45
40
  },
46
41
  async afterRender() {
@@ -1,38 +1,42 @@
1
- import type {TestRouter} from '@quilted/quilt/navigation/testing';
2
- import type {BrowserTestMock} from '@quilted/quilt/browser/testing';
3
-
4
- import type {AppContext} from '~/context/types.ts';
1
+ import type {TestNavigation} from '@quilted/quilt/navigation/testing';
2
+ import type {TestBrowser} from '@quilted/quilt/browser/testing';
3
+ import type {Localization} from '@quilted/quilt/localize';
5
4
 
6
5
  export interface RenderOptions {
7
6
  /**
8
- * A custom router to use for this component test. You can use a
7
+ * A custom navigation to use for this component test. You can use a
9
8
  * custom router to simulate a particular URL, and you can spy on
10
9
  * its navigation method to check that components navigate as
11
10
  * you expect.
12
11
  */
13
- readonly router?: TestRouter;
12
+ readonly navigation?: TestNavigation;
14
13
 
15
14
  /**
16
15
  * A custom environment for this component test.
17
16
  */
18
- readonly browser?: BrowserTestMock;
17
+ readonly browser?: TestBrowser;
19
18
 
20
19
  /**
21
- * A custom locale to use for this component test.
20
+ * A custom localization instance to use for this component test.
22
21
  */
23
- readonly locale?: string;
22
+ readonly localization?: Localization;
24
23
  }
25
24
 
26
- export interface RenderContext extends AppContext {
25
+ export interface RenderContext {
27
26
  /**
28
- * The router used for this component test.
27
+ * The navigation used for this component test.
29
28
  */
30
- readonly navigation: {router: TestRouter};
29
+ readonly navigation: TestNavigation;
31
30
 
32
31
  /**
33
32
  * The browser environment for this component test.
34
33
  */
35
- readonly browser: BrowserTestMock;
34
+ readonly browser: TestBrowser;
35
+
36
+ /**
37
+ * The localization used for this component test.
38
+ */
39
+ readonly localization: Localization;
36
40
  }
37
41
 
38
42
  export interface RenderActions extends Record<string, never> {}
@@ -1,6 +1,6 @@
1
1
  import '@quilted/quilt/testing';
2
2
 
3
- export {TestRouter} from '@quilted/quilt/navigation/testing';
3
+ export {TestNavigation} from '@quilted/quilt/navigation/testing';
4
4
 
5
5
  export * from './render/types.ts';
6
6
  export {renderApp} from './render/render.tsx';
@@ -17,7 +17,7 @@
17
17
  "devDependencies": {
18
18
  "@quilted/quilt": "^0.9.0",
19
19
  "hono": "^4.8.0",
20
- "preact": "^10.26.0",
20
+ "preact": "^10.29.0",
21
21
  "react": "npm:@quilted/react@^19.0.0",
22
22
  "react-dom": "npm:@quilted/react-dom@^19.0.0"
23
23
  },
@@ -1,7 +1,6 @@
1
1
  import {NotFound} from '@quilted/quilt/server';
2
- import {GraphQLContext} from '@quilted/quilt/graphql';
3
- import {Navigation} from '@quilted/quilt/navigation';
4
- import {Localization} from '@quilted/quilt/localize';
2
+ import {Routes} from '@quilted/quilt/navigation';
3
+ import {QuiltFrameworkContext} from '@quilted/quilt/context';
5
4
 
6
5
  import {Head} from './foundation/html.ts';
7
6
  import {Frame} from './foundation/frame.ts';
@@ -24,7 +23,7 @@ const routes = [
24
23
  children: [
25
24
  routeWithAppContext('/', {
26
25
  async load({context: {graphql}}) {
27
- await Promise.all([Home.load(), graphql.cache.query(homeQuery)]);
26
+ await Promise.all([Home.load(), graphql.cache?.query(homeQuery)]);
28
27
  },
29
28
  render: <Home />,
30
29
  }),
@@ -38,19 +37,14 @@ const routes = [
38
37
  export function App({context}: AppProps) {
39
38
  return (
40
39
  <AppContextPreact.Provider value={context}>
41
- <GraphQLContext
42
- fetch={context.graphql.fetch}
43
- cache={context.graphql.cache}
40
+ <QuiltFrameworkContext
41
+ navigation={context.navigation}
42
+ localization={context.localization}
43
+ graphql={context.graphql}
44
44
  >
45
- <Localization>
46
- <Head />
47
- <Navigation
48
- router={context.navigation.router}
49
- routes={routes}
50
- context={context}
51
- />
52
- </Localization>
53
- </GraphQLContext>
45
+ <Head />
46
+ <Routes list={routes} context={context} />
47
+ </QuiltFrameworkContext>
54
48
  </AppContextPreact.Provider>
55
49
  );
56
50
  }