@quilted/create 0.2.41 → 0.2.43

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 (38) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/index.mjs +2 -2
  3. package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/async.mjs +1 -1
  4. package/build/esm/node_modules/.pnpm/@nodelib_fs.stat@2.0.5/node_modules/@nodelib/fs.stat/out/providers/sync.mjs +1 -1
  5. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/async.mjs +1 -1
  6. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/stream.mjs +1 -1
  7. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/providers/sync.mjs +1 -1
  8. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/async.mjs +1 -1
  9. package/build/esm/node_modules/.pnpm/@nodelib_fs.walk@1.2.8/node_modules/@nodelib/fs.walk/out/readers/sync.mjs +1 -1
  10. package/package.json +1 -1
  11. package/templates/app-basic/App.tsx +3 -4
  12. package/templates/app-basic/browser.tsx +8 -13
  13. package/templates/app-basic/foundation/html/Head.test.tsx +42 -0
  14. package/templates/app-basic/foundation/html/Head.tsx +34 -0
  15. package/templates/app-basic/foundation/html.ts +1 -1
  16. package/templates/app-basic/server.tsx +89 -3
  17. package/templates/app-basic/tests/render/render.tsx +6 -3
  18. package/templates/app-empty/server.tsx +4 -3
  19. package/templates/app-graphql/App.tsx +3 -4
  20. package/templates/app-graphql/browser.tsx +9 -14
  21. package/templates/app-graphql/foundation/html/Head.test.tsx +42 -0
  22. package/templates/app-graphql/foundation/html/Head.tsx +34 -0
  23. package/templates/app-graphql/foundation/html.ts +1 -1
  24. package/templates/app-graphql/server.tsx +93 -9
  25. package/templates/app-graphql/tests/render/render.tsx +6 -3
  26. package/templates/app-trpc/App.tsx +3 -4
  27. package/templates/app-trpc/browser.tsx +11 -15
  28. package/templates/app-trpc/foundation/html/Head.test.tsx +42 -0
  29. package/templates/app-trpc/foundation/html/Head.tsx +34 -0
  30. package/templates/app-trpc/foundation/html.ts +1 -1
  31. package/templates/app-trpc/server.tsx +93 -8
  32. package/templates/app-trpc/tests/render/render.tsx +6 -3
  33. package/templates/app-basic/foundation/html/HTML.test.tsx +0 -46
  34. package/templates/app-basic/foundation/html/HTML.tsx +0 -159
  35. package/templates/app-graphql/foundation/html/HTML.test.tsx +0 -46
  36. package/templates/app-graphql/foundation/html/HTML.tsx +0 -159
  37. package/templates/app-trpc/foundation/html/HTML.test.tsx +0 -46
  38. package/templates/app-trpc/foundation/html/HTML.tsx +0 -159
@@ -1,46 +0,0 @@
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).toContainPreactComponent(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).toContainPreactComponent(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).toContainPreactComponent(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).toContainPreactComponent(ContentSecurityPolicy, {
43
- defaultSources: ["'self'"],
44
- });
45
- });
46
- });
@@ -1,159 +0,0 @@
1
- import type {RenderableProps} from 'preact';
2
- import Env from 'quilt:module/env';
3
- import {Title, Favicon, useBrowserRequest} from '@quilted/quilt/browser';
4
- import {
5
- CacheControl,
6
- ResponseHeader,
7
- ContentSecurityPolicy,
8
- PermissionsPolicy,
9
- SearchRobots,
10
- StrictTransportSecurity,
11
- Viewport,
12
- } from '@quilted/quilt/server';
13
-
14
- // This component sets details of the HTML page. If you need to customize
15
- // any of these details based on conditions like the active route, or some
16
- // state about the user, you can move these components to wherever in your
17
- // application you can read that state.
18
- //
19
- // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/html.md
20
- export function HTML({children}: RenderableProps<{}>) {
21
- return (
22
- <>
23
- <Headers />
24
- <Head />
25
- {children}
26
- </>
27
- );
28
- }
29
-
30
- function Headers() {
31
- const {url} = useBrowserRequest();
32
- const isHttps = new URL(url).protocol === 'https:';
33
-
34
- return (
35
- <>
36
- {/*
37
- * Disables the cache for this page, which is generally the best option
38
- * when dealing with authenticated content. If your site doesn’t have
39
- * authentication, or you have a better cache policy that works for your
40
- * app or deployment, make sure to update this component accordingly!
41
- *
42
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
43
- */}
44
- <CacheControl cache={false} />
45
-
46
- {/*
47
- * Sets a strict content security policy for this page. If you load
48
- * assets from other origins, or want to allow some more dangerous
49
- * resource loading techniques like `eval`, you can change the
50
- * `defaultSources` to be less restrictive, or add additional items
51
- * to the allowlist for more specific directives.
52
- *
53
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
54
- */}
55
- <ContentSecurityPolicy
56
- reportOnly={Env.MODE === 'development'}
57
- // By default, only allow sources from the page’s origin.
58
- defaultSources={["'self'"]}
59
- // In development, allow connections to local websockets for hot reloading.
60
- connectSources={
61
- Env.MODE === 'development'
62
- ? ["'self'", `${isHttps ? 'ws' : 'wss'}://localhost:*`]
63
- : undefined
64
- }
65
- // Includes `'unsafe-inline'` because CSS is often necessary in development,
66
- // and can be difficult to avoid in production.
67
- styleSources={["'self'", "'unsafe-inline'"]}
68
- // Includes `data:` so that an inline image can be used for the favicon.
69
- // If you do not use the `emoji` or `blank` favicons in your app, and you
70
- // do not load any other images as data URIs, you can remove this directive.
71
- imageSources={["'self'", 'data:']}
72
- // Don’t allow this page to be rendered as a frame from a different origin.
73
- frameAncestors={false}
74
- // Ensure that all requests made by this page are made over https, unless
75
- // it is being served over http (typically, during local development)
76
- upgradeInsecureRequests={isHttps}
77
- />
78
-
79
- {/*
80
- * Sets a strict permissions policy for this page, which limits access
81
- * to some native browser features.
82
- *
83
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
84
- */}
85
- <PermissionsPolicy
86
- // Disables Google’s Federated Learning of Cohorts (“FLoC”) tracking initiative.
87
- // @see https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea
88
- interestCohort={false}
89
- // Don’t use synchronous XHRs!
90
- // @see https://featurepolicy.info/policies/sync-xhr
91
- syncXhr={false}
92
- // Disables access to a few device APIs that are infrequently used
93
- // and prone to abuse. If your application uses these APIs intentionally,
94
- // feel free to remove the prop, or pass an array containing the origins
95
- // that should be allowed to use this feature (e.g., `['self']` to allow
96
- // only the main page’s origin).
97
- camera={false}
98
- microphone={false}
99
- geolocation={false}
100
- />
101
-
102
- {/*
103
- * Instructs browsers to only load this page over HTTPS using the
104
- * `Strict-Transport-Security` header.
105
- *
106
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
107
- */}
108
- {isHttps && <StrictTransportSecurity />}
109
-
110
- {/*
111
- * Controls how much information about the current page is included in
112
- * requests (through the `Referer` header). The default value
113
- * (strict-origin-when-cross-origin) means that only the origin is included
114
- * for cross-origin requests, while the origin, path, and querystring
115
- * are included for same-origin requests.
116
- *
117
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
118
- */}
119
- <ResponseHeader
120
- name="Referrer-Policy"
121
- value="strict-origin-when-cross-origin"
122
- />
123
-
124
- {/*
125
- * Instructs browsers to respect the MIME type in the `Content-Type` header.
126
- *
127
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
128
- */}
129
- <ResponseHeader name="X-Content-Type-Options" value="nosniff" />
130
- </>
131
- );
132
- }
133
-
134
- function Head() {
135
- return (
136
- <>
137
- {/* Sets the default `<title>` for this application. */}
138
- <Title>App</Title>
139
-
140
- {/*
141
- * Sets the default favicon used by the application. You can
142
- * change this to a different emoji, make it `blank`, or pass
143
- * a URL with the `source` prop.
144
- */}
145
- <Favicon emoji="🧶" />
146
-
147
- {/* Adds a responsive-friendly `viewport` `<meta>` tag. */}
148
- <Viewport cover />
149
-
150
- {/*
151
- * Disables all search indexing for this application. If you are
152
- * building an unauthenticated app, you probably want to remove
153
- * this component, or update it to control how your site is indexed
154
- * by search engines.
155
- */}
156
- <SearchRobots index={false} follow={false} />
157
- </>
158
- );
159
- }
@@ -1,46 +0,0 @@
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).toContainPreactComponent(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).toContainPreactComponent(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).toContainPreactComponent(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).toContainPreactComponent(ContentSecurityPolicy, {
43
- defaultSources: ["'self'"],
44
- });
45
- });
46
- });
@@ -1,159 +0,0 @@
1
- import type {RenderableProps} from 'preact';
2
- import Env from 'quilt:module/env';
3
- import {Title, Favicon, useBrowserRequest} from '@quilted/quilt/browser';
4
- import {
5
- CacheControl,
6
- ResponseHeader,
7
- ContentSecurityPolicy,
8
- PermissionsPolicy,
9
- SearchRobots,
10
- StrictTransportSecurity,
11
- Viewport,
12
- } from '@quilted/quilt/server';
13
-
14
- // This component sets details of the HTML page. If you need to customize
15
- // any of these details based on conditions like the active route, or some
16
- // state about the user, you can move these components to wherever in your
17
- // application you can read that state.
18
- //
19
- // @see https://github.com/lemonmade/quilt/blob/main/documentation/features/html.md
20
- export function HTML({children}: RenderableProps<{}>) {
21
- return (
22
- <>
23
- <Headers />
24
- <Head />
25
- {children}
26
- </>
27
- );
28
- }
29
-
30
- function Headers() {
31
- const {url} = useBrowserRequest();
32
- const isHttps = new URL(url).protocol === 'https:';
33
-
34
- return (
35
- <>
36
- {/*
37
- * Disables the cache for this page, which is generally the best option
38
- * when dealing with authenticated content. If your site doesn’t have
39
- * authentication, or you have a better cache policy that works for your
40
- * app or deployment, make sure to update this component accordingly!
41
- *
42
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
43
- */}
44
- <CacheControl cache={false} />
45
-
46
- {/*
47
- * Sets a strict content security policy for this page. If you load
48
- * assets from other origins, or want to allow some more dangerous
49
- * resource loading techniques like `eval`, you can change the
50
- * `defaultSources` to be less restrictive, or add additional items
51
- * to the allowlist for more specific directives.
52
- *
53
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
54
- */}
55
- <ContentSecurityPolicy
56
- reportOnly={Env.MODE === 'development'}
57
- // By default, only allow sources from the page’s origin.
58
- defaultSources={["'self'"]}
59
- // In development, allow connections to local websockets for hot reloading.
60
- connectSources={
61
- Env.MODE === 'development'
62
- ? ["'self'", `${isHttps ? 'ws' : 'wss'}://localhost:*`]
63
- : undefined
64
- }
65
- // Includes `'unsafe-inline'` because CSS is often necessary in development,
66
- // and can be difficult to avoid in production.
67
- styleSources={["'self'", "'unsafe-inline'"]}
68
- // Includes `data:` so that an inline image can be used for the favicon.
69
- // If you do not use the `emoji` or `blank` favicons in your app, and you
70
- // do not load any other images as data URIs, you can remove this directive.
71
- imageSources={["'self'", 'data:']}
72
- // Don’t allow this page to be rendered as a frame from a different origin.
73
- frameAncestors={false}
74
- // Ensure that all requests made by this page are made over https, unless
75
- // it is being served over http (typically, during local development)
76
- upgradeInsecureRequests={isHttps}
77
- />
78
-
79
- {/*
80
- * Sets a strict permissions policy for this page, which limits access
81
- * to some native browser features.
82
- *
83
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy
84
- */}
85
- <PermissionsPolicy
86
- // Disables Google’s Federated Learning of Cohorts (“FLoC”) tracking initiative.
87
- // @see https://www.eff.org/deeplinks/2021/03/googles-floc-terrible-idea
88
- interestCohort={false}
89
- // Don’t use synchronous XHRs!
90
- // @see https://featurepolicy.info/policies/sync-xhr
91
- syncXhr={false}
92
- // Disables access to a few device APIs that are infrequently used
93
- // and prone to abuse. If your application uses these APIs intentionally,
94
- // feel free to remove the prop, or pass an array containing the origins
95
- // that should be allowed to use this feature (e.g., `['self']` to allow
96
- // only the main page’s origin).
97
- camera={false}
98
- microphone={false}
99
- geolocation={false}
100
- />
101
-
102
- {/*
103
- * Instructs browsers to only load this page over HTTPS using the
104
- * `Strict-Transport-Security` header.
105
- *
106
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
107
- */}
108
- {isHttps && <StrictTransportSecurity />}
109
-
110
- {/*
111
- * Controls how much information about the current page is included in
112
- * requests (through the `Referer` header). The default value
113
- * (strict-origin-when-cross-origin) means that only the origin is included
114
- * for cross-origin requests, while the origin, path, and querystring
115
- * are included for same-origin requests.
116
- *
117
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy
118
- */}
119
- <ResponseHeader
120
- name="Referrer-Policy"
121
- value="strict-origin-when-cross-origin"
122
- />
123
-
124
- {/*
125
- * Instructs browsers to respect the MIME type in the `Content-Type` header.
126
- *
127
- * @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
128
- */}
129
- <ResponseHeader name="X-Content-Type-Options" value="nosniff" />
130
- </>
131
- );
132
- }
133
-
134
- function Head() {
135
- return (
136
- <>
137
- {/* Sets the default `<title>` for this application. */}
138
- <Title>App</Title>
139
-
140
- {/*
141
- * Sets the default favicon used by the application. You can
142
- * change this to a different emoji, make it `blank`, or pass
143
- * a URL with the `source` prop.
144
- */}
145
- <Favicon emoji="🧶" />
146
-
147
- {/* Adds a responsive-friendly `viewport` `<meta>` tag. */}
148
- <Viewport cover />
149
-
150
- {/*
151
- * Disables all search indexing for this application. If you are
152
- * building an unauthenticated app, you probably want to remove
153
- * this component, or update it to control how your site is indexed
154
- * by search engines.
155
- */}
156
- <SearchRobots index={false} follow={false} />
157
- </>
158
- );
159
- }