@quilted/create 0.2.18 → 0.2.20

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 (61) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/esm/app.mjs +8 -2
  3. package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/index.mjs +3 -3
  4. package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/async.mjs +1 -1
  5. package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/sync.mjs +1 -1
  6. package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/settings.mjs +1 -1
  7. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/index.mjs +3 -3
  8. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/async.mjs +1 -1
  9. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/sync.mjs +1 -1
  10. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/settings.mjs +1 -1
  11. package/build/esnext/app.esnext +10 -6
  12. package/build/tsconfig.tsbuildinfo +1 -1
  13. package/build/typescript/app.d.ts.map +1 -1
  14. package/package.json +1 -1
  15. package/source/app.ts +12 -5
  16. package/templates/app-basic/App.tsx +18 -22
  17. package/templates/app-basic/browser.tsx +8 -1
  18. package/templates/app-basic/foundation/html/HTML.test.tsx +46 -0
  19. package/templates/app-basic/foundation/{http/Headers.tsx → html/HTML.tsx} +50 -10
  20. package/templates/app-basic/foundation/html.ts +1 -1
  21. package/templates/app-basic/package.json +1 -1
  22. package/templates/app-basic/tsconfig.json +1 -1
  23. package/templates/app-empty/package.json +1 -1
  24. package/templates/app-empty/tsconfig.json +1 -1
  25. package/templates/app-graphql/App.tsx +24 -41
  26. package/templates/app-graphql/browser.tsx +9 -1
  27. package/templates/app-graphql/foundation/html/HTML.test.tsx +46 -0
  28. package/templates/app-graphql/foundation/{http/Headers.tsx → html/HTML.tsx} +50 -10
  29. package/templates/app-graphql/foundation/html.ts +1 -1
  30. package/templates/app-graphql/package.json +2 -1
  31. package/templates/app-graphql/server/graphql.ts +1 -1
  32. package/templates/app-graphql/server.tsx +8 -2
  33. package/templates/app-graphql/shared/graphql.ts +11 -0
  34. package/templates/app-graphql/tests/render/render.tsx +6 -1
  35. package/templates/app-graphql/tsconfig.json +1 -1
  36. package/templates/app-trpc/App.tsx +30 -46
  37. package/templates/app-trpc/browser.tsx +10 -1
  38. package/templates/app-trpc/foundation/html/HTML.test.tsx +46 -0
  39. package/templates/app-trpc/foundation/{http/Headers.tsx → html/HTML.tsx} +50 -10
  40. package/templates/app-trpc/foundation/html.ts +1 -1
  41. package/templates/app-trpc/package.json +1 -1
  42. package/templates/app-trpc/server.tsx +8 -2
  43. package/templates/app-trpc/shared/trpc.ts +4 -2
  44. package/templates/app-trpc/tsconfig.json +1 -1
  45. package/templates/module/tsconfig.json +1 -1
  46. package/templates/package/tsconfig.json +1 -1
  47. package/templates/server-basic/tsconfig.json +1 -1
  48. package/templates/workspace/tsconfig.json +1 -1
  49. package/tsconfig.json +1 -2
  50. package/templates/app-basic/foundation/html/Head.test.tsx +0 -25
  51. package/templates/app-basic/foundation/html/Head.tsx +0 -34
  52. package/templates/app-basic/foundation/http/Headers.test.tsx +0 -24
  53. package/templates/app-basic/foundation/http.ts +0 -1
  54. package/templates/app-graphql/foundation/html/Head.test.tsx +0 -25
  55. package/templates/app-graphql/foundation/html/Head.tsx +0 -34
  56. package/templates/app-graphql/foundation/http/Headers.test.tsx +0 -24
  57. package/templates/app-graphql/foundation/http.ts +0 -1
  58. package/templates/app-trpc/foundation/html/Head.test.tsx +0 -25
  59. package/templates/app-trpc/foundation/html/Head.tsx +0 -34
  60. package/templates/app-trpc/foundation/http/Headers.test.tsx +0 -24
  61. package/templates/app-trpc/foundation/http.ts +0 -1
@@ -0,0 +1,46 @@
1
+ import {describe, it, expect} from 'vitest';
2
+ import {
3
+ CacheControl,
4
+ ContentSecurityPolicy,
5
+ SearchRobots,
6
+ Viewport,
7
+ } from '@quilted/quilt/server';
8
+
9
+ import {renderApp} from '~/tests/render.ts';
10
+
11
+ import {HTML} from './HTML.tsx';
12
+
13
+ describe('<HTML />', () => {
14
+ it('includes a responsive viewport tag', async () => {
15
+ const head = await renderApp(<HTML />);
16
+
17
+ expect(head).toContainReactComponent(Viewport, {
18
+ cover: true,
19
+ });
20
+ });
21
+
22
+ it('prevents search robots from indexing the application', async () => {
23
+ const head = await renderApp(<HTML />);
24
+
25
+ expect(head).toContainReactComponent(SearchRobots, {
26
+ index: false,
27
+ follow: false,
28
+ });
29
+ });
30
+
31
+ it('does not cache the response', async () => {
32
+ const headers = await renderApp(<HTML />);
33
+
34
+ expect(headers).toContainReactComponent(CacheControl, {
35
+ cache: false,
36
+ });
37
+ });
38
+
39
+ it('adds a content security policy with a strict default policy', async () => {
40
+ const headers = await renderApp(<HTML />);
41
+
42
+ expect(headers).toContainReactComponent(ContentSecurityPolicy, {
43
+ defaultSources: ["'self'"],
44
+ });
45
+ });
46
+ });
@@ -1,21 +1,34 @@
1
- import Env from '@quilted/quilt/env';
2
- import {useInitialUrl} from '@quilted/quilt/navigate';
1
+ import type {PropsWithChildren} from 'react';
2
+ import {Title, Favicon, useBrowserRequest} from '@quilted/quilt/browser';
3
3
  import {
4
4
  CacheControl,
5
5
  ResponseHeader,
6
6
  ContentSecurityPolicy,
7
7
  PermissionsPolicy,
8
+ SearchRobots,
8
9
  StrictTransportSecurity,
9
- } from '@quilted/quilt/http';
10
+ Viewport,
11
+ } from '@quilted/quilt/server';
10
12
 
11
- // This component sets details on the HTTP response for all HTML server-rendering
12
- // requests. If you need to customize any of these details based on conditions like
13
- // the active route, or some state about the user, you can move these components to
14
- // wherever in your application you can read that state.
13
+ // This component sets details of the HTML page. If you need to customize
14
+ // any of these details based on conditions like the active route, or some
15
+ // state about the user, you can move these components to wherever in your
16
+ // application you can read that state.
15
17
  //
16
- // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/http.md
17
- export function Headers() {
18
- const isHttps = useInitialUrl().protocol === 'https:';
18
+ // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/html.md
19
+ export function HTML({children}: PropsWithChildren) {
20
+ return (
21
+ <>
22
+ <Headers />
23
+ <Head />
24
+ {children}
25
+ </>
26
+ );
27
+ }
28
+
29
+ function Headers() {
30
+ const {url} = useBrowserRequest();
31
+ const isHttps = new URL(url).protocol === 'https:';
19
32
 
20
33
  return (
21
34
  <>
@@ -116,3 +129,30 @@ export function Headers() {
116
129
  </>
117
130
  );
118
131
  }
132
+
133
+ function Head() {
134
+ return (
135
+ <>
136
+ {/* Sets the default `<title>` for this application. */}
137
+ <Title>App</Title>
138
+
139
+ {/*
140
+ * Sets the default favicon used by the application. You can
141
+ * change this to a different emoji, make it `blank`, or pass
142
+ * a URL with the `source` prop.
143
+ */}
144
+ <Favicon emoji="🧶" />
145
+
146
+ {/* Adds a responsive-friendly `viewport` `<meta>` tag. */}
147
+ <Viewport cover />
148
+
149
+ {/*
150
+ * Disables all search indexing for this application. If you are
151
+ * building an unauthenticated app, you probably want to remove
152
+ * this component, or update it to control how your site is indexed
153
+ * by search engines.
154
+ */}
155
+ <SearchRobots index={false} follow={false} />
156
+ </>
157
+ );
158
+ }
@@ -1 +1 @@
1
- export {Head} from './html/Head.tsx';
1
+ export {HTML} from './html/HTML.tsx';
@@ -21,7 +21,7 @@
21
21
  "@types/react": "^18.2.0",
22
22
  "@types/react-dom": "^18.2.0",
23
23
  "jsdom": "^24.0.0",
24
- "preact": "^10.20.0",
24
+ "preact": "^10.21.0",
25
25
  "react": "npm:@quilted/react@^18.2.0",
26
26
  "react-dom": "npm:@quilted/react-dom@^18.2.0",
27
27
  "zod": "^3.22.0"
@@ -25,13 +25,19 @@ router.any(
25
25
 
26
26
  // For all GET requests, render our React application.
27
27
  router.get(async (request) => {
28
- const [{App}, {renderToResponse}] = await Promise.all([
28
+ const [{App}, {renderToResponse}, {QueryClient}] = await Promise.all([
29
29
  import('./App.tsx'),
30
30
  import('@quilted/quilt/server'),
31
+ import('@tanstack/react-query'),
31
32
  ]);
32
33
 
33
34
  const response = await renderToResponse(
34
- <App trpc={createDirectClient(appRouter)} />,
35
+ <App
36
+ context={{
37
+ trpc: createDirectClient(appRouter),
38
+ queryClient: new QueryClient(),
39
+ }}
40
+ />,
35
41
  {
36
42
  request,
37
43
  assets,
@@ -1,10 +1,11 @@
1
- import {type TRPCClient} from '@trpc/client';
1
+ import type {TRPCClient} from '@trpc/client';
2
2
  import {createTRPCReact, type CreateTRPCReact} from '@trpc/react-query';
3
+ import type {QueryClient} from '@tanstack/react-query';
3
4
 
4
5
  // Get access to our app’s router type signature, which will
5
6
  // provide strong typing on the queries and mutations we can
6
7
  // perform.
7
- import {type AppRouter} from '../trpc.ts';
8
+ import type {AppRouter} from '../trpc.ts';
8
9
 
9
10
  export const trpc: CreateTRPCReact<AppRouter, unknown, null> =
10
11
  createTRPCReact<AppRouter>();
@@ -12,5 +13,6 @@ export const trpc: CreateTRPCReact<AppRouter, unknown, null> =
12
13
  declare module '~/shared/context.ts' {
13
14
  interface AppContext {
14
15
  trpc: TRPCClient<AppRouter>;
16
+ queryClient: QueryClient;
15
17
  }
16
18
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@quilted/craft/typescript/project.json",
2
+ "extends": "@quilted/typescript/project.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "build/typescript",
5
5
  "paths": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@quilted/craft/typescript/project.json",
2
+ "extends": "@quilted/typescript/tsconfig.project.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "build/typescript"
5
5
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@quilted/craft/typescript/project.json",
2
+ "extends": "@quilted/typescript/tsconfig.project.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "source",
5
5
  "outDir": "build/typescript"
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@quilted/craft/typescript/project.json",
2
+ "extends": "@quilted/typescript/tsconfig.project.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "build/typescript"
5
5
  },
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@quilted/craft/typescript/workspace.json",
2
+ "extends": "@quilted/typescript/tsconfig.workspace.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "build/typescript"
5
5
  },
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "extends": "@quilted/craft/typescript/project.json",
2
+ "extends": "@quilted/typescript/tsconfig.project.json",
3
3
  "compilerOptions": {
4
4
  "rootDir": "source",
5
5
  "outDir": "build/typescript"
@@ -8,7 +8,6 @@
8
8
  "exclude": ["**/*.test.ts", "**/*.test.tsx"],
9
9
  "references": [
10
10
  {"path": "../quilt"},
11
- {"path": "../craft"},
12
11
  {"path": "../cli-kit"},
13
12
  {"path": "../events"}
14
13
  ]
@@ -1,25 +0,0 @@
1
- import {describe, it, expect} from 'vitest';
2
- import {Viewport, SearchRobots} from '@quilted/quilt/html';
3
-
4
- import {renderApp} from '~/tests/render.ts';
5
-
6
- import {Head} from './Head.tsx';
7
-
8
- describe('<Head />', () => {
9
- it('includes a responsive viewport tag', async () => {
10
- const head = await renderApp(<Head />);
11
-
12
- expect(head).toContainReactComponent(Viewport, {
13
- cover: true,
14
- });
15
- });
16
-
17
- it('prevents search robots from indexing the application', async () => {
18
- const head = await renderApp(<Head />);
19
-
20
- expect(head).toContainReactComponent(SearchRobots, {
21
- index: false,
22
- follow: false,
23
- });
24
- });
25
- });
@@ -1,34 +0,0 @@
1
- import {Title, Viewport, Favicon, SearchRobots} from '@quilted/quilt/html';
2
-
3
- // This component sets details of the HTML page. If you need to customize
4
- // any of these details based on conditions like the active route, or some
5
- // state about the user, you can move these components to wherever in your
6
- // application you can read that state.
7
- //
8
- // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/html.md
9
- export function Head() {
10
- return (
11
- <>
12
- {/* Sets the default `<title>` for this application. */}
13
- <Title>App</Title>
14
-
15
- {/*
16
- * Sets the default favicon used by the application. You can
17
- * change this to a different emoji, make it `blank`, or pass
18
- * a URL with the `source` prop.
19
- */}
20
- <Favicon emoji="🧶" />
21
-
22
- {/* Adds a responsive-friendly `viewport` `<meta>` tag. */}
23
- <Viewport cover />
24
-
25
- {/*
26
- * Disables all search indexing for this application. If you are
27
- * building an unauthenticated app, you probably want to remove
28
- * this component, or update it to control how your site is indexed
29
- * by search engines.
30
- */}
31
- <SearchRobots index={false} follow={false} />
32
- </>
33
- );
34
- }
@@ -1,24 +0,0 @@
1
- import {describe, it, expect} from 'vitest';
2
- import {CacheControl, ContentSecurityPolicy} from '@quilted/quilt/http';
3
-
4
- import {renderApp} from '~/tests/render.ts';
5
-
6
- import {Headers} from './Headers.tsx';
7
-
8
- describe('<Headers />', () => {
9
- it('does not cache the response', async () => {
10
- const headers = await renderApp(<Headers />);
11
-
12
- expect(headers).toContainReactComponent(CacheControl, {
13
- cache: false,
14
- });
15
- });
16
-
17
- it('adds a content security policy with a strict default policy', async () => {
18
- const headers = await renderApp(<Headers />);
19
-
20
- expect(headers).toContainReactComponent(ContentSecurityPolicy, {
21
- defaultSources: ["'self'"],
22
- });
23
- });
24
- });
@@ -1 +0,0 @@
1
- export {Headers} from './http/Headers.tsx';
@@ -1,25 +0,0 @@
1
- import {describe, it, expect} from 'vitest';
2
- import {Viewport, SearchRobots} from '@quilted/quilt/html';
3
-
4
- import {renderApp} from '~/tests/render.ts';
5
-
6
- import {Head} from './Head.tsx';
7
-
8
- describe('<Head />', () => {
9
- it('includes a responsive viewport tag', async () => {
10
- const head = await renderApp(<Head />);
11
-
12
- expect(head).toContainReactComponent(Viewport, {
13
- cover: true,
14
- });
15
- });
16
-
17
- it('prevents search robots from indexing the application', async () => {
18
- const head = await renderApp(<Head />);
19
-
20
- expect(head).toContainReactComponent(SearchRobots, {
21
- index: false,
22
- follow: false,
23
- });
24
- });
25
- });
@@ -1,34 +0,0 @@
1
- import {Title, Viewport, Favicon, SearchRobots} from '@quilted/quilt/html';
2
-
3
- // This component sets details of the HTML page. If you need to customize
4
- // any of these details based on conditions like the active route, or some
5
- // state about the user, you can move these components to wherever in your
6
- // application you can read that state.
7
- //
8
- // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/html.md
9
- export function Head() {
10
- return (
11
- <>
12
- {/* Sets the default `<title>` for this application. */}
13
- <Title>App</Title>
14
-
15
- {/*
16
- * Sets the default favicon used by the application. You can
17
- * change this to a different emoji, make it `blank`, or pass
18
- * a URL with the `source` prop.
19
- */}
20
- <Favicon emoji="🧶" />
21
-
22
- {/* Adds a responsive-friendly `viewport` `<meta>` tag. */}
23
- <Viewport cover />
24
-
25
- {/*
26
- * Disables all search indexing for this application. If you are
27
- * building an unauthenticated app, you probably want to remove
28
- * this component, or update it to control how your site is indexed
29
- * by search engines.
30
- */}
31
- <SearchRobots index={false} follow={false} />
32
- </>
33
- );
34
- }
@@ -1,24 +0,0 @@
1
- import {describe, it, expect} from 'vitest';
2
- import {CacheControl, ContentSecurityPolicy} from '@quilted/quilt/http';
3
-
4
- import {renderApp} from '~/tests/render.ts';
5
-
6
- import {Headers} from './Headers.tsx';
7
-
8
- describe('<Headers />', () => {
9
- it('does not cache the response', async () => {
10
- const headers = await renderApp(<Headers />);
11
-
12
- expect(headers).toContainReactComponent(CacheControl, {
13
- cache: false,
14
- });
15
- });
16
-
17
- it('adds a content security policy with a strict default policy', async () => {
18
- const headers = await renderApp(<Headers />);
19
-
20
- expect(headers).toContainReactComponent(ContentSecurityPolicy, {
21
- defaultSources: ["'self'"],
22
- });
23
- });
24
- });
@@ -1 +0,0 @@
1
- export {Headers} from './http/Headers.tsx';
@@ -1,25 +0,0 @@
1
- import {describe, it, expect} from 'vitest';
2
- import {Viewport, SearchRobots} from '@quilted/quilt/html';
3
-
4
- import {renderApp} from '~/tests/render.ts';
5
-
6
- import {Head} from './Head.tsx';
7
-
8
- describe('<Head />', () => {
9
- it('includes a responsive viewport tag', async () => {
10
- const head = await renderApp(<Head />);
11
-
12
- expect(head).toContainReactComponent(Viewport, {
13
- cover: true,
14
- });
15
- });
16
-
17
- it('prevents search robots from indexing the application', async () => {
18
- const head = await renderApp(<Head />);
19
-
20
- expect(head).toContainReactComponent(SearchRobots, {
21
- index: false,
22
- follow: false,
23
- });
24
- });
25
- });
@@ -1,34 +0,0 @@
1
- import {Title, Viewport, Favicon, SearchRobots} from '@quilted/quilt/html';
2
-
3
- // This component sets details of the HTML page. If you need to customize
4
- // any of these details based on conditions like the active route, or some
5
- // state about the user, you can move these components to wherever in your
6
- // application you can read that state.
7
- //
8
- // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/html.md
9
- export function Head() {
10
- return (
11
- <>
12
- {/* Sets the default `<title>` for this application. */}
13
- <Title>App</Title>
14
-
15
- {/*
16
- * Sets the default favicon used by the application. You can
17
- * change this to a different emoji, make it `blank`, or pass
18
- * a URL with the `source` prop.
19
- */}
20
- <Favicon emoji="🧶" />
21
-
22
- {/* Adds a responsive-friendly `viewport` `<meta>` tag. */}
23
- <Viewport cover />
24
-
25
- {/*
26
- * Disables all search indexing for this application. If you are
27
- * building an unauthenticated app, you probably want to remove
28
- * this component, or update it to control how your site is indexed
29
- * by search engines.
30
- */}
31
- <SearchRobots index={false} follow={false} />
32
- </>
33
- );
34
- }
@@ -1,24 +0,0 @@
1
- import {describe, it, expect} from 'vitest';
2
- import {CacheControl, ContentSecurityPolicy} from '@quilted/quilt/http';
3
-
4
- import {renderApp} from '~/tests/render.ts';
5
-
6
- import {Headers} from './Headers.tsx';
7
-
8
- describe('<Headers />', () => {
9
- it('does not cache the response', async () => {
10
- const headers = await renderApp(<Headers />);
11
-
12
- expect(headers).toContainReactComponent(CacheControl, {
13
- cache: false,
14
- });
15
- });
16
-
17
- it('adds a content security policy with a strict default policy', async () => {
18
- const headers = await renderApp(<Headers />);
19
-
20
- expect(headers).toContainReactComponent(ContentSecurityPolicy, {
21
- defaultSources: ["'self'"],
22
- });
23
- });
24
- });
@@ -1 +0,0 @@
1
- export {Headers} from './http/Headers.tsx';