@quilted/create 0.1.78 → 0.1.80

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 (103) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/cjs/app.cjs +8 -10
  3. package/build/esm/app.mjs +8 -10
  4. package/build/esnext/app.esnext +8 -10
  5. package/build/tsconfig.tsbuildinfo +1 -1
  6. package/build/typescript/app.d.ts.map +1 -1
  7. package/build/typescript/shared.d.ts +1 -1
  8. package/build/typescript/shared.d.ts.map +1 -1
  9. package/package.json +1 -1
  10. package/source/app.ts +16 -18
  11. package/source/shared.ts +0 -2
  12. package/templates/app-basic/App.tsx +37 -13
  13. package/templates/app-basic/browser.tsx +2 -2
  14. package/templates/app-basic/features/start/Start/Start.tsx +5 -0
  15. package/templates/app-basic/features/start.ts +5 -0
  16. package/templates/app-basic/foundation/frame/Frame.module.css +14 -0
  17. package/templates/app-basic/foundation/frame/Frame.tsx +7 -0
  18. package/templates/app-basic/foundation/frame.ts +1 -0
  19. package/templates/app-basic/foundation/{Head → html}/Head.test.tsx +4 -4
  20. package/templates/app-basic/foundation/html.ts +1 -0
  21. package/templates/{app-trpc/foundation/Http/Http.test.tsx → app-basic/foundation/http/Headers.test.tsx} +8 -8
  22. package/templates/app-basic/foundation/{Http/Http.tsx → http/Headers.tsx} +3 -3
  23. package/templates/app-basic/foundation/http.ts +1 -0
  24. package/templates/app-basic/server.tsx +18 -15
  25. package/templates/app-basic/shared/context.ts +1 -6
  26. package/templates/app-basic/tests/render/render.tsx +12 -12
  27. package/templates/app-basic/tests/render/types.ts +3 -5
  28. package/templates/app-basic/tests/render.ts +2 -2
  29. package/templates/app-basic/tsconfig.json +1 -1
  30. package/templates/app-empty/App.tsx +1 -1
  31. package/templates/app-empty/browser.tsx +1 -1
  32. package/templates/app-empty/server.tsx +18 -14
  33. package/templates/app-empty/tsconfig.json +1 -1
  34. package/templates/app-graphql/App.tsx +36 -26
  35. package/templates/app-graphql/browser.tsx +2 -2
  36. package/templates/app-graphql/features/{Start → start/Start}/Start.test.tsx +3 -7
  37. package/templates/app-graphql/features/start/Start/Start.tsx +14 -0
  38. package/templates/app-graphql/features/start.ts +5 -0
  39. package/templates/app-graphql/foundation/frame/Frame.module.css +14 -0
  40. package/templates/app-graphql/foundation/frame/Frame.tsx +7 -0
  41. package/templates/app-graphql/foundation/frame.ts +1 -0
  42. package/templates/{app-trpc/foundation/Head → app-graphql/foundation/html}/Head.test.tsx +4 -4
  43. package/templates/app-graphql/foundation/html.ts +1 -0
  44. package/templates/{app-basic/foundation/Http/Http.test.tsx → app-graphql/foundation/http/Headers.test.tsx} +8 -8
  45. package/templates/app-graphql/foundation/{Http/Http.tsx → http/Headers.tsx} +3 -3
  46. package/templates/app-graphql/foundation/http.ts +1 -0
  47. package/templates/app-graphql/graphql/schema.graphql +4 -2
  48. package/templates/app-graphql/server/graphql.ts +9 -4
  49. package/templates/app-graphql/server.tsx +36 -33
  50. package/templates/app-graphql/shared/context.ts +1 -6
  51. package/templates/app-graphql/tests/graphql.ts +3 -4
  52. package/templates/app-graphql/tests/render/render.tsx +16 -15
  53. package/templates/app-graphql/tests/render/types.ts +9 -10
  54. package/templates/app-graphql/tests/render.ts +2 -3
  55. package/templates/app-graphql/tsconfig.json +1 -1
  56. package/templates/app-trpc/App.tsx +39 -33
  57. package/templates/app-trpc/browser.tsx +2 -2
  58. package/templates/app-trpc/features/{Start → start/Start}/Start.test.tsx +2 -2
  59. package/templates/app-trpc/features/start/Start/Start.tsx +9 -0
  60. package/templates/app-trpc/features/start.ts +5 -0
  61. package/templates/app-trpc/foundation/frame/Frame.module.css +14 -0
  62. package/templates/app-trpc/foundation/frame/Frame.tsx +7 -0
  63. package/templates/app-trpc/foundation/frame.ts +1 -0
  64. package/templates/{app-graphql/foundation/Head → app-trpc/foundation/html}/Head.test.tsx +4 -4
  65. package/templates/app-trpc/foundation/html.ts +1 -0
  66. package/templates/{app-graphql/foundation/Http/Http.test.tsx → app-trpc/foundation/http/Headers.test.tsx} +8 -8
  67. package/templates/app-trpc/foundation/{Http/Http.tsx → http/Headers.tsx} +3 -3
  68. package/templates/app-trpc/foundation/http.ts +1 -0
  69. package/templates/app-trpc/server.tsx +20 -13
  70. package/templates/app-trpc/shared/context.ts +1 -6
  71. package/templates/app-trpc/tests/render/render.tsx +17 -16
  72. package/templates/app-trpc/tsconfig.json +1 -1
  73. package/templates/service-basic/service.ts +2 -2
  74. package/templates/app-basic/features/Start/Start.tsx +0 -12
  75. package/templates/app-basic/features/Start.tsx +0 -3
  76. package/templates/app-basic/foundation/Head.tsx +0 -1
  77. package/templates/app-basic/foundation/Http.tsx +0 -1
  78. package/templates/app-basic/foundation/Metrics/Metrics.tsx +0 -23
  79. package/templates/app-basic/foundation/Metrics.tsx +0 -1
  80. package/templates/app-graphql/features/Start/Start.tsx +0 -20
  81. package/templates/app-graphql/features/Start.tsx +0 -3
  82. package/templates/app-graphql/foundation/Head.tsx +0 -1
  83. package/templates/app-graphql/foundation/Http.tsx +0 -1
  84. package/templates/app-graphql/foundation/Metrics/Metrics.tsx +0 -23
  85. package/templates/app-graphql/foundation/Metrics.tsx +0 -1
  86. package/templates/app-single-file/App.tsx +0 -199
  87. package/templates/app-single-file/package.json +0 -35
  88. package/templates/app-single-file/quilt.project.ts +0 -5
  89. package/templates/app-single-file/tsconfig.json +0 -9
  90. package/templates/app-trpc/features/Start/Start.tsx +0 -16
  91. package/templates/app-trpc/features/Start.tsx +0 -3
  92. package/templates/app-trpc/foundation/Head.tsx +0 -1
  93. package/templates/app-trpc/foundation/Http.tsx +0 -1
  94. package/templates/app-trpc/foundation/Metrics/Metrics.tsx +0 -23
  95. package/templates/app-trpc/foundation/Metrics.tsx +0 -1
  96. /package/templates/app-basic/features/{Start → start/Start}/Start.module.css +0 -0
  97. /package/templates/app-basic/features/{Start → start/Start}/Start.test.tsx +0 -0
  98. /package/templates/app-basic/foundation/{Head → html}/Head.tsx +0 -0
  99. /package/templates/app-graphql/features/{Start → start/Start}/Start.module.css +0 -0
  100. /package/templates/app-graphql/features/{Start → start/Start}/StartQuery.graphql +0 -0
  101. /package/templates/app-graphql/foundation/{Head → html}/Head.tsx +0 -0
  102. /package/templates/app-trpc/features/{Start → start/Start}/Start.module.css +0 -0
  103. /package/templates/app-trpc/foundation/{Head → html}/Head.tsx +0 -0
@@ -0,0 +1,14 @@
1
+ *,
2
+ *::before,
3
+ *::after {
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ html,
8
+ body {
9
+ margin: 0;
10
+ }
11
+
12
+ .Frame {
13
+ padding: 1rem;
14
+ }
@@ -0,0 +1,7 @@
1
+ import type {PropsWithChildren} from '@quilted/quilt/react/tools';
2
+
3
+ import styles from './Frame.module.css';
4
+
5
+ export function Frame({children}: PropsWithChildren) {
6
+ return <div className={styles.Frame}>{children}</div>;
7
+ }
@@ -0,0 +1 @@
1
+ export {Frame} from './frame/Frame.tsx';
@@ -1,13 +1,13 @@
1
- import {Viewport, SearchRobots} from '@quilted/quilt/html';
2
1
  import {describe, it, expect} from '@quilted/quilt/testing';
2
+ import {Viewport, SearchRobots} from '@quilted/quilt/html';
3
3
 
4
- import {renderWithAppContext} from '~/tests/render.tsx';
4
+ import {renderApp} from '~/tests/render.ts';
5
5
 
6
6
  import {Head} from './Head.tsx';
7
7
 
8
8
  describe('<Head />', () => {
9
9
  it('includes a responsive viewport tag', async () => {
10
- const head = await renderWithAppContext(<Head />);
10
+ const head = await renderApp(<Head />);
11
11
 
12
12
  expect(head).toContainReactComponent(Viewport, {
13
13
  cover: true,
@@ -15,7 +15,7 @@ describe('<Head />', () => {
15
15
  });
16
16
 
17
17
  it('prevents search robots from indexing the application', async () => {
18
- const head = await renderWithAppContext(<Head />);
18
+ const head = await renderApp(<Head />);
19
19
 
20
20
  expect(head).toContainReactComponent(SearchRobots, {
21
21
  index: false,
@@ -0,0 +1 @@
1
+ export {Head} from './html/Head.tsx';
@@ -1,23 +1,23 @@
1
- import {CacheControl, ContentSecurityPolicy} from '@quilted/quilt/http';
2
1
  import {describe, it, expect} from '@quilted/quilt/testing';
2
+ import {CacheControl, ContentSecurityPolicy} from '@quilted/quilt/http';
3
3
 
4
- import {renderWithAppContext} from '~/tests/render.tsx';
4
+ import {renderApp} from '~/tests/render.ts';
5
5
 
6
- import {Http} from './Http.tsx';
6
+ import {Headers} from './Headers.tsx';
7
7
 
8
- describe('<Http />', () => {
8
+ describe('<Headers />', () => {
9
9
  it('does not cache the response', async () => {
10
- const http = await renderWithAppContext(<Http />);
10
+ const headers = await renderApp(<Headers />);
11
11
 
12
- expect(http).toContainReactComponent(CacheControl, {
12
+ expect(headers).toContainReactComponent(CacheControl, {
13
13
  cache: false,
14
14
  });
15
15
  });
16
16
 
17
17
  it('adds a content security policy with a strict default policy', async () => {
18
- const http = await renderWithAppContext(<Http />);
18
+ const headers = await renderApp(<Headers />);
19
19
 
20
- expect(http).toContainReactComponent(ContentSecurityPolicy, {
20
+ expect(headers).toContainReactComponent(ContentSecurityPolicy, {
21
21
  defaultSources: ["'self'"],
22
22
  });
23
23
  });
@@ -1,5 +1,5 @@
1
1
  import Env from '@quilted/quilt/env';
2
- import {useCurrentUrl} from '@quilted/quilt';
2
+ import {useInitialUrl} from '@quilted/quilt/navigate';
3
3
  import {
4
4
  CacheControl,
5
5
  ResponseHeader,
@@ -14,8 +14,8 @@ import {
14
14
  // wherever in your application you can read that state.
15
15
  //
16
16
  // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/http.md
17
- export function Http() {
18
- const isHttps = useCurrentUrl().protocol === 'https:';
17
+ export function Headers() {
18
+ const isHttps = useInitialUrl().protocol === 'https:';
19
19
 
20
20
  return (
21
21
  <>
@@ -0,0 +1 @@
1
+ export {Headers} from './http/Headers.tsx';
@@ -1,20 +1,23 @@
1
- import '@quilted/quilt/global';
2
- import {createRequestRouter, createServerRender} from '@quilted/quilt/server';
3
- import {createBrowserAssets} from '@quilted/quilt/magic/assets';
1
+ import '@quilted/quilt/globals';
2
+ import {RequestRouter} from '@quilted/quilt/request-router';
3
+ import {BrowserAssets} from '@quilted/quilt/magic/assets';
4
4
 
5
- const router = createRequestRouter();
5
+ const router = new RequestRouter();
6
+ const assets = new BrowserAssets();
6
7
 
7
8
  // For all GET requests, render our React application.
8
- router.get(
9
- createServerRender(
10
- async () => {
11
- const {default: App} = await import('./App.tsx');
12
- return <App />;
13
- },
14
- {
15
- assets: createBrowserAssets(),
16
- },
17
- ),
18
- );
9
+ router.get(async (request) => {
10
+ const [{App}, {renderToResponse}] = await Promise.all([
11
+ import('./App.tsx'),
12
+ import('@quilted/quilt/server'),
13
+ ]);
14
+
15
+ const response = await renderToResponse(<App />, {
16
+ request,
17
+ assets,
18
+ });
19
+
20
+ return response;
21
+ });
19
22
 
20
23
  export default router;
@@ -1,14 +1,9 @@
1
1
  import {
2
2
  createOptionalContext,
3
3
  createUseContextHook,
4
- createUseOptionalValueHook,
5
- } from '@quilted/quilt';
4
+ } from '@quilted/quilt/react/tools';
6
5
 
7
6
  export interface AppContext {}
8
7
 
9
8
  export const AppContextReact = createOptionalContext<AppContext>();
10
9
  export const useAppContext = createUseContextHook(AppContextReact);
11
-
12
- export function createUseAppContextHook<T>(hook: (context: AppContext) => T) {
13
- return createUseOptionalValueHook<T>(() => hook(useAppContext()));
14
- }
@@ -1,8 +1,6 @@
1
- import {
2
- createRender,
3
- QuiltAppTesting,
4
- createTestRouter,
5
- } from '@quilted/quilt/testing';
1
+ import {createRender} from '@quilted/quilt/react/testing';
2
+ import {TestRouting, TestRouter} from '@quilted/quilt/navigate/testing';
3
+ import {Localization} from '@quilted/quilt/localize';
6
4
 
7
5
  import {AppContextReact} from '~/shared/context.ts';
8
6
 
@@ -21,19 +19,21 @@ export const renderApp = createRender<
21
19
  // Create context that can be used by the `render` function, and referenced by test
22
20
  // authors on the `root.context` property. Context is used to share data between your
23
21
  // React tree and your test code, and is ideal for mocking out global context providers.
24
- context({router = createTestRouter()}) {
22
+ context({router = new TestRouter()}) {
25
23
  return {router};
26
24
  },
27
25
  // Render all of our app-wide context providers around each component under test.
28
- render(element, context, {locale}) {
26
+ render(element, context, {locale = 'en'}) {
29
27
  const {router} = context;
30
28
 
31
29
  return (
32
- <QuiltAppTesting routing={router} localization={locale}>
33
- <AppContextReact.Provider value={context}>
34
- {element}
35
- </AppContextReact.Provider>
36
- </QuiltAppTesting>
30
+ <Localization locale={locale}>
31
+ <TestRouting router={router}>
32
+ <AppContextReact.Provider value={context}>
33
+ {element}
34
+ </AppContextReact.Provider>
35
+ </TestRouting>
36
+ </Localization>
37
37
  );
38
38
  },
39
39
  async afterRender() {
@@ -1,9 +1,7 @@
1
- import type {createTestRouter} from '@quilted/quilt/testing';
1
+ import type {TestRouter} from '@quilted/quilt/navigate/testing';
2
2
 
3
3
  import type {AppContext} from '~/shared/context.ts';
4
4
 
5
- type Router = ReturnType<typeof createTestRouter>;
6
-
7
5
  export interface RenderOptions {
8
6
  /**
9
7
  * A custom router to use for this component test. You can use a
@@ -11,7 +9,7 @@ export interface RenderOptions {
11
9
  * its navigation method to check that components navigate as
12
10
  * you expect.
13
11
  */
14
- readonly router?: Router;
12
+ readonly router?: TestRouter;
15
13
 
16
14
  /**
17
15
  * A custom locale to use for this component test.
@@ -23,7 +21,7 @@ export interface RenderContext extends AppContext {
23
21
  /**
24
22
  * The router used for this component test.
25
23
  */
26
- readonly router: Router;
24
+ readonly router: TestRouter;
27
25
  }
28
26
 
29
27
  export interface RenderActions extends Record<string, never> {}
@@ -1,6 +1,6 @@
1
- import '@quilted/quilt/matchers';
1
+ import '@quilted/quilt/react/testing';
2
2
 
3
- export {createTestRouter} from '@quilted/quilt/testing';
3
+ export {TestRouter} from '@quilted/quilt/navigate/testing';
4
4
 
5
5
  export * from './render/types.ts';
6
6
  export {renderApp} from './render/render.tsx';
@@ -8,6 +8,6 @@
8
8
  }
9
9
  },
10
10
  "include": ["**/*"],
11
- "exclude": ["build", "quilt.project.ts", "**/*.test.ts", "**/*.test.tsx"],
11
+ "exclude": ["build", "quilt.project.ts"],
12
12
  "references": []
13
13
  }
@@ -1,3 +1,3 @@
1
- export default function App() {
1
+ export function App() {
2
2
  return <div>Hello world!</div>;
3
3
  }
@@ -1,6 +1,6 @@
1
1
  import {hydrateRoot} from 'react-dom/client';
2
2
 
3
- import App from './App.tsx';
3
+ import {App} from './App.tsx';
4
4
 
5
5
  const element = document.querySelector('#app')!;
6
6
 
@@ -1,19 +1,23 @@
1
- import {createRequestRouter, createServerRender} from '@quilted/quilt/server';
2
- import {createBrowserAssets} from '@quilted/quilt/magic/assets';
1
+ import '@quilted/quilt/globals';
2
+ import {RequestRouter} from '@quilted/quilt/request-router';
3
+ import {BrowserAssets} from '@quilted/quilt/magic/assets';
3
4
 
4
- const router = createRequestRouter();
5
+ const router = new RequestRouter();
6
+ const assets = new BrowserAssets();
5
7
 
6
8
  // For all GET requests, render our React application.
7
- router.get(
8
- createServerRender(
9
- async () => {
10
- const {default: App} = await import('./App.tsx');
11
- return <App />;
12
- },
13
- {
14
- assets: createBrowserAssets(),
15
- },
16
- ),
17
- );
9
+ router.get(async (request) => {
10
+ const [{App}, {renderToResponse}] = await Promise.all([
11
+ import('./App.tsx'),
12
+ import('@quilted/quilt/server'),
13
+ ]);
14
+
15
+ const response = await renderToResponse(<App />, {
16
+ request,
17
+ assets,
18
+ });
19
+
20
+ return response;
21
+ });
18
22
 
19
23
  export default router;
@@ -4,6 +4,6 @@
4
4
  "outDir": "build/typescript"
5
5
  },
6
6
  "include": ["**/*"],
7
- "exclude": ["build", "quilt.project.ts", "**/*.test.ts", "**/*.test.tsx"],
7
+ "exclude": ["build", "quilt.project.ts"],
8
8
  "references": []
9
9
  }
@@ -1,11 +1,9 @@
1
1
  import {useMemo} from 'react';
2
2
 
3
- import {
4
- QuiltApp,
5
- useRoutes,
6
- RoutePreloading,
7
- type PropsWithChildren,
8
- } from '@quilted/quilt';
3
+ import {HTML} from '@quilted/quilt/html';
4
+ import {Routing, useRoutes} from '@quilted/quilt/navigate';
5
+ import {Localization, useLocaleFromEnvironment} from '@quilted/quilt/localize';
6
+ import {type PropsWithChildren} from '@quilted/quilt/react/tools';
9
7
  import {
10
8
  GraphQLContext,
11
9
  createGraphQLHttpFetch,
@@ -15,27 +13,40 @@ import {
15
13
  import {ReactQueryContext} from '@quilted/react-query';
16
14
  import {QueryClient} from '@tanstack/react-query';
17
15
 
18
- import {Http} from './foundation/Http.tsx';
19
- import {Head} from './foundation/Head.tsx';
20
- import {Metrics} from './foundation/Metrics.tsx';
16
+ import {Head} from './foundation/html.ts';
17
+ import {Headers} from './foundation/http.ts';
18
+ import {Frame} from './foundation/frame.ts';
19
+
20
+ import {Start} from './features/start.ts';
21
21
 
22
- import {Start} from './features/Start.tsx';
22
+ import {
23
+ AppContextReact,
24
+ type AppContext as AppContextType,
25
+ } from './shared/context.ts';
23
26
 
24
- export interface Props {
27
+ export interface AppProps extends AppContextType {
25
28
  fetchGraphQL?: GraphQLFetch;
26
29
  }
27
30
 
28
31
  // The root component for your application. You will typically render any
29
32
  // app-wide context in this component.
30
- export default function App(props: Props) {
33
+ export function App(props: AppProps) {
34
+ const locale = useLocaleFromEnvironment() ?? 'en';
35
+
31
36
  return (
32
- <QuiltApp http={<Http />} html={<Head />}>
33
- <RoutePreloading>
34
- <AppContext {...props}>
35
- <Routes />
36
- </AppContext>
37
- </RoutePreloading>
38
- </QuiltApp>
37
+ <HTML>
38
+ <Localization locale={locale}>
39
+ <Routing>
40
+ <AppContext {...props}>
41
+ <Headers />
42
+ <Head />
43
+ <Frame>
44
+ <Routes />
45
+ </Frame>
46
+ </AppContext>
47
+ </Routing>
48
+ </Localization>
49
+ </HTML>
39
50
  );
40
51
  }
41
52
 
@@ -43,11 +54,7 @@ export default function App(props: Props) {
43
54
  // of routes, you may want to split this component into its own file.
44
55
  function Routes() {
45
56
  return useRoutes([
46
- {
47
- match: '/',
48
- render: <Start />,
49
- renderPreload: <Start.Preload />,
50
- },
57
+ {match: '/', render: <Start />, renderPreload: <Start.Preload />},
51
58
  ]);
52
59
  }
53
60
 
@@ -55,7 +62,8 @@ function Routes() {
55
62
  function AppContext({
56
63
  children,
57
64
  fetchGraphQL: customFetchGraphQL,
58
- }: PropsWithChildren<Props>) {
65
+ ...context
66
+ }: PropsWithChildren<AppProps>) {
59
67
  const {fetchGraphQL, queryClient} = useMemo(() => {
60
68
  return {
61
69
  fetchGraphQL:
@@ -67,7 +75,9 @@ function AppContext({
67
75
  return (
68
76
  <GraphQLContext fetch={fetchGraphQL}>
69
77
  <ReactQueryContext client={queryClient}>
70
- <Metrics>{children}</Metrics>
78
+ <AppContextReact.Provider value={context}>
79
+ {children}
80
+ </AppContextReact.Provider>
71
81
  </ReactQueryContext>
72
82
  </GraphQLContext>
73
83
  );
@@ -1,7 +1,7 @@
1
- import '@quilted/quilt/global';
1
+ import '@quilted/quilt/globals';
2
2
  import {hydrateRoot} from 'react-dom/client';
3
3
 
4
- import App from './App.tsx';
4
+ import {App} from './App.tsx';
5
5
 
6
6
  const element = document.querySelector('#app')!;
7
7
 
@@ -1,10 +1,6 @@
1
1
  import {describe, it, expect} from '@quilted/quilt/testing';
2
2
 
3
- import {
4
- renderApp,
5
- fillGraphQL,
6
- createGraphQLController,
7
- } from '~/tests/render.tsx';
3
+ import {renderApp, fillGraphQL, GraphQLController} from '~/tests/render.ts';
8
4
 
9
5
  import Start from './Start.tsx';
10
6
  import startQuery from './StartQuery.graphql';
@@ -12,11 +8,11 @@ import startQuery from './StartQuery.graphql';
12
8
  describe('<Start />', () => {
13
9
  it('welcomes the user with their name', async () => {
14
10
  const name = 'Winston';
15
- const graphql = createGraphQLController(fillGraphQL(startQuery, {name}));
11
+ const graphql = new GraphQLController([fillGraphQL(startQuery, {name})]);
16
12
 
17
13
  const start = await renderApp(<Start />, {graphql});
18
14
 
19
- expect(graphql).toHavePerformedGraphQLOperation(startQuery);
15
+ expect(graphql).toHavePerformedGraphQLQuery(startQuery);
20
16
  expect(start).toContainReactText(`Hello ${name}!`);
21
17
  });
22
18
  });
@@ -0,0 +1,14 @@
1
+ import {useGraphQLQuery} from '@quilted/react-query';
2
+
3
+ import styles from './Start.module.css';
4
+ import startQuery from './StartQuery.graphql';
5
+
6
+ export default function Start() {
7
+ const {data} = useGraphQLQuery(startQuery);
8
+
9
+ return (
10
+ <div className={styles.Start}>
11
+ {data ? `Hello ${data.name}!` : 'Hello!'}
12
+ </div>
13
+ );
14
+ }
@@ -0,0 +1,5 @@
1
+ import {createAsyncComponent} from '@quilted/quilt/async';
2
+
3
+ export const Start = createAsyncComponent(
4
+ () => import('./start/Start/Start.tsx'),
5
+ );
@@ -0,0 +1,14 @@
1
+ *,
2
+ *::before,
3
+ *::after {
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ html,
8
+ body {
9
+ margin: 0;
10
+ }
11
+
12
+ .Frame {
13
+ padding: 1rem;
14
+ }
@@ -0,0 +1,7 @@
1
+ import type {PropsWithChildren} from '@quilted/quilt/react/tools';
2
+
3
+ import styles from './Frame.module.css';
4
+
5
+ export function Frame({children}: PropsWithChildren) {
6
+ return <div className={styles.Frame}>{children}</div>;
7
+ }
@@ -0,0 +1 @@
1
+ export {Frame} from './frame/Frame.tsx';
@@ -1,13 +1,13 @@
1
- import {Viewport, SearchRobots} from '@quilted/quilt/html';
2
1
  import {describe, it, expect} from '@quilted/quilt/testing';
2
+ import {Viewport, SearchRobots} from '@quilted/quilt/html';
3
3
 
4
- import {renderWithAppContext} from '~/tests/render.tsx';
4
+ import {renderApp} from '~/tests/render.ts';
5
5
 
6
6
  import {Head} from './Head.tsx';
7
7
 
8
8
  describe('<Head />', () => {
9
9
  it('includes a responsive viewport tag', async () => {
10
- const head = await renderWithAppContext(<Head />);
10
+ const head = await renderApp(<Head />);
11
11
 
12
12
  expect(head).toContainReactComponent(Viewport, {
13
13
  cover: true,
@@ -15,7 +15,7 @@ describe('<Head />', () => {
15
15
  });
16
16
 
17
17
  it('prevents search robots from indexing the application', async () => {
18
- const head = await renderWithAppContext(<Head />);
18
+ const head = await renderApp(<Head />);
19
19
 
20
20
  expect(head).toContainReactComponent(SearchRobots, {
21
21
  index: false,
@@ -0,0 +1 @@
1
+ export {Head} from './html/Head.tsx';
@@ -1,23 +1,23 @@
1
- import {CacheControl, ContentSecurityPolicy} from '@quilted/quilt/http';
2
1
  import {describe, it, expect} from '@quilted/quilt/testing';
2
+ import {CacheControl, ContentSecurityPolicy} from '@quilted/quilt/http';
3
3
 
4
- import {renderWithAppContext} from '~/tests/render.tsx';
4
+ import {renderApp} from '~/tests/render.ts';
5
5
 
6
- import {Http} from './Http.tsx';
6
+ import {Headers} from './Headers.tsx';
7
7
 
8
- describe('<Http />', () => {
8
+ describe('<Headers />', () => {
9
9
  it('does not cache the response', async () => {
10
- const http = await renderWithAppContext(<Http />);
10
+ const headers = await renderApp(<Headers />);
11
11
 
12
- expect(http).toContainReactComponent(CacheControl, {
12
+ expect(headers).toContainReactComponent(CacheControl, {
13
13
  cache: false,
14
14
  });
15
15
  });
16
16
 
17
17
  it('adds a content security policy with a strict default policy', async () => {
18
- const http = await renderWithAppContext(<Http />);
18
+ const headers = await renderApp(<Headers />);
19
19
 
20
- expect(http).toContainReactComponent(ContentSecurityPolicy, {
20
+ expect(headers).toContainReactComponent(ContentSecurityPolicy, {
21
21
  defaultSources: ["'self'"],
22
22
  });
23
23
  });
@@ -1,5 +1,5 @@
1
1
  import Env from '@quilted/quilt/env';
2
- import {useCurrentUrl} from '@quilted/quilt';
2
+ import {useInitialUrl} from '@quilted/quilt/navigate';
3
3
  import {
4
4
  CacheControl,
5
5
  ResponseHeader,
@@ -14,8 +14,8 @@ import {
14
14
  // wherever in your application you can read that state.
15
15
  //
16
16
  // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/http.md
17
- export function Http() {
18
- const isHttps = useCurrentUrl().protocol === 'https:';
17
+ export function Headers() {
18
+ const isHttps = useInitialUrl().protocol === 'https:';
19
19
 
20
20
  return (
21
21
  <>
@@ -0,0 +1 @@
1
+ export {Headers} from './http/Headers.tsx';
@@ -1,7 +1,9 @@
1
- scalar Name
1
+ type Person {
2
+ name: String!
3
+ }
2
4
 
3
5
  type Query {
4
- name: Name!
6
+ me: Person!
5
7
  }
6
8
 
7
9
  schema {
@@ -7,11 +7,17 @@ import type {GraphQLResult, GraphQLSource} from '@quilted/quilt/graphql';
7
7
 
8
8
  import schemaSource, {type Schema} from '../graphql/schema.ts';
9
9
 
10
- const {createResolver, createQueryResolver} =
11
- createGraphQLResolverBuilder<Schema>();
10
+ interface GraphQLValues {
11
+ Person: {};
12
+ }
13
+
14
+ const {createResolver, createQueryResolver} = createGraphQLResolverBuilder<
15
+ Schema,
16
+ GraphQLValues
17
+ >();
12
18
 
13
19
  const Person = createResolver('Person', {
14
- name: 'Winston',
20
+ name: async () => 'Winston',
15
21
  });
16
22
 
17
23
  const Query = createQueryResolver({
@@ -35,7 +41,6 @@ export async function performGraphQLOperation<
35
41
  source: operation,
36
42
  operationName,
37
43
  variableValues: variables,
38
- rootValue: {name: () => 'Winston'},
39
44
  });
40
45
 
41
46
  return result as GraphQLResult<Data>;