@quilted/quilt 0.5.158 → 0.6.0
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.
- package/CHANGELOG.md +34 -0
- package/build/esm/graphql/testing/matchers/operations.mjs +1 -1
- package/build/esm/graphql/testing/matchers/utilities.mjs +1 -1
- package/build/esm/graphql/testing/matchers.mjs +4 -3
- package/build/esm/graphql/testing.mjs +5 -1
- package/build/esm/react/testing.mjs +5 -2
- package/build/esnext/globals.esnext +1 -1
- package/build/esnext/graphql/testing/matchers/operations.esnext +49 -19
- package/build/esnext/graphql/testing/matchers/utilities.esnext +18 -15
- package/build/esnext/graphql/testing/matchers.esnext +4 -3
- package/build/esnext/graphql/testing.esnext +4 -1
- package/build/esnext/html/HTML.esnext +6 -9
- package/build/esnext/react/testing.esnext +4 -2
- package/build/esnext/server/ServerContext.esnext +14 -2
- package/build/esnext/server/preload.esnext +9 -10
- package/build/esnext/server/request-router.esnext +138 -141
- package/build/esnext/utilities/react.esnext +1 -4
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/globals.d.ts +1 -0
- package/build/typescript/globals.d.ts.map +1 -1
- package/build/typescript/graphql/testing/matchers/utilities.d.ts +1 -1
- package/build/typescript/graphql/testing/matchers/utilities.d.ts.map +1 -1
- package/build/typescript/graphql/testing/matchers.d.ts +10 -8
- package/build/typescript/graphql/testing/matchers.d.ts.map +1 -1
- package/build/typescript/graphql/testing.d.ts +7 -1
- package/build/typescript/graphql/testing.d.ts.map +1 -1
- package/build/typescript/modules.d.ts +23 -0
- package/build/typescript/modules.d.ts.map +1 -0
- package/build/typescript/react/testing.d.ts +7 -2
- package/build/typescript/react/testing.d.ts.map +1 -1
- package/configuration/rollup.config.js +3 -0
- package/package.json +66 -197
- package/source/globals.ts +2 -0
- package/source/graphql/testing/matchers/operations.ts +1 -1
- package/source/graphql/testing/matchers/utilities.ts +1 -1
- package/source/graphql/testing/matchers.ts +15 -22
- package/source/graphql/testing.ts +11 -1
- package/source/modules.ts +31 -0
- package/source/react/testing.ts +10 -3
- package/tsconfig.json +1 -3
- package/build/cjs/assets.cjs +0 -39
- package/build/cjs/async.cjs +0 -32
- package/build/cjs/env.cjs +0 -7
- package/build/cjs/events.cjs +0 -46
- package/build/cjs/globals.cjs +0 -21
- package/build/cjs/graphql/server.cjs +0 -14
- package/build/cjs/graphql/testing/matchers/operations.cjs +0 -42
- package/build/cjs/graphql/testing/matchers/utilities.cjs +0 -43
- package/build/cjs/graphql/testing/matchers.cjs +0 -10
- package/build/cjs/graphql/testing.cjs +0 -18
- package/build/cjs/graphql.cjs +0 -21
- package/build/cjs/html/HTML.cjs +0 -21
- package/build/cjs/html.cjs +0 -133
- package/build/cjs/http.cjs +0 -146
- package/build/cjs/index.cjs +0 -2
- package/build/cjs/localize.cjs +0 -46
- package/build/cjs/magic/app.cjs +0 -2
- package/build/cjs/magic/assets.cjs +0 -2
- package/build/cjs/magic/request-router.cjs +0 -2
- package/build/cjs/navigate/testing.cjs +0 -12
- package/build/cjs/navigate.cjs +0 -70
- package/build/cjs/performance.cjs +0 -26
- package/build/cjs/polyfills/abort-controller.cjs +0 -4
- package/build/cjs/polyfills/base.cjs +0 -4
- package/build/cjs/polyfills/crypto.cjs +0 -4
- package/build/cjs/polyfills/fetch-get-set-cookie.cjs +0 -4
- package/build/cjs/polyfills/fetch.cjs +0 -4
- package/build/cjs/polyfills/noop.cjs +0 -4
- package/build/cjs/react/testing.cjs +0 -30
- package/build/cjs/react/tools.cjs +0 -19
- package/build/cjs/react.cjs +0 -15
- package/build/cjs/request-router/index.cjs +0 -12
- package/build/cjs/request-router/node.cjs +0 -12
- package/build/cjs/server/ServerContext.cjs +0 -20
- package/build/cjs/server/preload.cjs +0 -37
- package/build/cjs/server/request-router.cjs +0 -266
- package/build/cjs/server.cjs +0 -114
- package/build/cjs/signals.cjs +0 -51
- package/build/cjs/static/StaticContext.cjs +0 -20
- package/build/cjs/static/index.cjs +0 -261
- package/build/cjs/static/render.cjs +0 -44
- package/build/cjs/testing.cjs +0 -12
- package/build/cjs/threads.cjs +0 -117
- package/build/cjs/utilities/react.cjs +0 -12
- package/build/esm/magic/request-router.mjs +0 -1
- package/build/esm/polyfills/abort-controller.mjs +0 -1
- package/build/esm/polyfills/base.mjs +0 -1
- package/build/esm/polyfills/crypto.mjs +0 -1
- package/build/esm/polyfills/fetch-get-set-cookie.mjs +0 -1
- package/build/esm/polyfills/fetch.mjs +0 -1
- package/build/esm/polyfills/noop.mjs +0 -1
- package/build/esm/static/StaticContext.mjs +0 -18
- package/build/esm/static/index.mjs +0 -259
- package/build/esm/static/render.mjs +0 -42
- package/build/esm/testing.mjs +0 -1
- package/build/esnext/magic/app.esnext +0 -1
- package/build/esnext/magic/assets.esnext +0 -1
- package/build/esnext/magic/request-router.esnext +0 -1
- package/build/esnext/polyfills/abort-controller.esnext +0 -1
- package/build/esnext/polyfills/base.esnext +0 -1
- package/build/esnext/polyfills/crypto.esnext +0 -1
- package/build/esnext/polyfills/fetch-get-set-cookie.esnext +0 -1
- package/build/esnext/polyfills/fetch.esnext +0 -1
- package/build/esnext/polyfills/noop.esnext +0 -1
- package/build/esnext/static/StaticContext.esnext +0 -18
- package/build/esnext/static/index.esnext +0 -259
- package/build/esnext/static/render.esnext +0 -42
- package/build/esnext/testing.esnext +0 -1
- package/build/typescript/App.d.ts +0 -48
- package/build/typescript/App.d.ts.map +0 -1
- package/build/typescript/TestApp.d.ts +0 -17
- package/build/typescript/TestApp.d.ts.map +0 -1
- package/build/typescript/global.d.ts +0 -8
- package/build/typescript/global.d.ts.map +0 -1
- package/build/typescript/magic/app.d.ts +0 -4
- package/build/typescript/magic/app.d.ts.map +0 -1
- package/build/typescript/magic/assets.d.ts +0 -5
- package/build/typescript/magic/assets.d.ts.map +0 -1
- package/build/typescript/magic/request-router.d.ts +0 -4
- package/build/typescript/magic/request-router.d.ts.map +0 -1
- package/build/typescript/matchers/graphql/operations.d.ts +0 -7
- package/build/typescript/matchers/graphql/operations.d.ts.map +0 -1
- package/build/typescript/matchers/graphql/utilities.d.ts +0 -8
- package/build/typescript/matchers/graphql/utilities.d.ts.map +0 -1
- package/build/typescript/matchers/graphql.d.ts +0 -9
- package/build/typescript/matchers/graphql.d.ts.map +0 -1
- package/build/typescript/matchers.d.ts +0 -3
- package/build/typescript/matchers.d.ts.map +0 -1
- package/build/typescript/polyfills/abort-controller.d.ts +0 -2
- package/build/typescript/polyfills/abort-controller.d.ts.map +0 -1
- package/build/typescript/polyfills/base.d.ts +0 -2
- package/build/typescript/polyfills/base.d.ts.map +0 -1
- package/build/typescript/polyfills/crypto.d.ts +0 -2
- package/build/typescript/polyfills/crypto.d.ts.map +0 -1
- package/build/typescript/polyfills/fetch-get-set-cookie.d.ts +0 -2
- package/build/typescript/polyfills/fetch-get-set-cookie.d.ts.map +0 -1
- package/build/typescript/polyfills/fetch.d.ts +0 -2
- package/build/typescript/polyfills/fetch.d.ts.map +0 -1
- package/build/typescript/polyfills/noop.d.ts +0 -2
- package/build/typescript/polyfills/noop.d.ts.map +0 -1
- package/build/typescript/react/index.d.ts +0 -3
- package/build/typescript/react/index.d.ts.map +0 -1
- package/build/typescript/react-dom/index.d.ts +0 -3
- package/build/typescript/react-dom/index.d.ts.map +0 -1
- package/build/typescript/server/index.d.ts +0 -16
- package/build/typescript/server/index.d.ts.map +0 -1
- package/build/typescript/static/StaticContext.d.ts +0 -13
- package/build/typescript/static/StaticContext.d.ts.map +0 -1
- package/build/typescript/static/index.d.ts +0 -20
- package/build/typescript/static/index.d.ts.map +0 -1
- package/build/typescript/static/render.d.ts +0 -19
- package/build/typescript/static/render.d.ts.map +0 -1
- package/build/typescript/testing.d.ts +0 -2
- package/build/typescript/testing.d.ts.map +0 -1
- package/quilt.project.ts +0 -5
- package/source/magic/app.ts +0 -5
- package/source/magic/assets.ts +0 -8
- package/source/magic/request-router.ts +0 -5
- package/source/polyfills/README.md +0 -3
- package/source/polyfills/abort-controller.ts +0 -1
- package/source/polyfills/base.ts +0 -1
- package/source/polyfills/crypto.ts +0 -1
- package/source/polyfills/fetch-get-set-cookie.ts +0 -1
- package/source/polyfills/fetch.ts +0 -1
- package/source/polyfills/noop.ts +0 -1
- package/source/static/StaticContext.tsx +0 -39
- package/source/static/index.tsx +0 -315
- package/source/static/render.tsx +0 -40
- package/source/testing.ts +0 -1
- /package/build/esm/{magic/app.mjs → modules.mjs} +0 -0
- /package/build/{esm/magic/assets.mjs → esnext/modules.esnext} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @quilted/quilt
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#645](https://github.com/lemonmade/quilt/pull/645) [`302ed847`](https://github.com/lemonmade/quilt/commit/302ed8479f9c035ef39d48137de958dba50690ca) Thanks [@lemonmade](https://github.com/lemonmade)! - Removed CommonJS support
|
|
8
|
+
|
|
9
|
+
The `require` export condition is no longer provided by any package. Quilt only supports ESModules, so if you need to use the CommonJS version, you will need to pre-process Quilt’s output code on your own.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`302ed847`](https://github.com/lemonmade/quilt/commit/302ed8479f9c035ef39d48137de958dba50690ca), [`302ed847`](https://github.com/lemonmade/quilt/commit/302ed8479f9c035ef39d48137de958dba50690ca), [`5d346a24`](https://github.com/lemonmade/quilt/commit/5d346a240ca95592c8623560ab1721935d6df1fa)]:
|
|
14
|
+
- @quilted/async@0.4.0
|
|
15
|
+
- @quilted/events@2.0.0
|
|
16
|
+
- @quilted/graphql@3.0.0
|
|
17
|
+
- @quilted/threads@2.0.0
|
|
18
|
+
- @quilted/useful-react-types@2.0.0
|
|
19
|
+
- @quilted/assets@0.1.0
|
|
20
|
+
- @quilted/react-assets@0.1.0
|
|
21
|
+
- @quilted/react-async@0.4.0
|
|
22
|
+
- @quilted/react-graphql@0.5.0
|
|
23
|
+
- @quilted/react-html@0.4.0
|
|
24
|
+
- @quilted/react-http@0.4.0
|
|
25
|
+
- @quilted/react-idle@0.4.0
|
|
26
|
+
- @quilted/react-localize@1.0.0
|
|
27
|
+
- @quilted/react-performance@0.2.0
|
|
28
|
+
- @quilted/react-router@0.4.0
|
|
29
|
+
- @quilted/react-server-render@0.4.0
|
|
30
|
+
- @quilted/react-signals@0.2.0
|
|
31
|
+
- @quilted/react-testing@0.6.0
|
|
32
|
+
- @quilted/react-utilities@0.2.0
|
|
33
|
+
- @quilted/react-workers@0.3.0
|
|
34
|
+
- @quilted/request-router@0.2.0
|
|
35
|
+
- @quilted/signals@0.2.0
|
|
36
|
+
|
|
3
37
|
## 0.5.158
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
@@ -10,7 +10,7 @@ function toHavePerformedGraphQLOperation(graphql, operation, variables) {
|
|
|
10
10
|
const foundByOperation = graphql.completed.all({
|
|
11
11
|
operation
|
|
12
12
|
});
|
|
13
|
-
const foundByVariables = variables == null ? foundByOperation : foundByOperation.filter(operation => Object.keys(variables).every(key =>
|
|
13
|
+
const foundByVariables = variables == null ? foundByOperation : foundByOperation.filter(operation => Object.keys(variables).every(key => Object.is(variables[key], (operation.variables ?? {})[key])));
|
|
14
14
|
const pass = foundByVariables.length > 0;
|
|
15
15
|
const {
|
|
16
16
|
name
|
|
@@ -3,7 +3,7 @@ import { GraphQLController } from '@quilted/graphql/testing';
|
|
|
3
3
|
|
|
4
4
|
function assertIsGraphQLController(graphql, {
|
|
5
5
|
expectation,
|
|
6
|
-
isNot
|
|
6
|
+
isNot = false
|
|
7
7
|
}) {
|
|
8
8
|
if (!(graphql instanceof GraphQLController)) {
|
|
9
9
|
throw new Error(matcherErrorMessage(matcherHint(`.${expectation}`, undefined, undefined, {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { expect } from '@quilted/testing';
|
|
2
1
|
import { toHavePerformedGraphQLOperation } from './matchers/operations.mjs';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const matchers = {
|
|
5
4
|
toHavePerformedGraphQLOperation,
|
|
6
5
|
toHavePerformedGraphQLQuery: toHavePerformedGraphQLOperation,
|
|
7
6
|
toHavePerformedGraphQLMutation: toHavePerformedGraphQLOperation
|
|
8
|
-
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { matchers };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import { expect } from 'vitest';
|
|
2
|
+
import { matchers } from './testing/matchers.mjs';
|
|
2
3
|
export * from '@quilted/graphql/testing';
|
|
3
4
|
export { GraphQLTesting } from '@quilted/react-graphql/testing';
|
|
5
|
+
|
|
6
|
+
// @ts-expect-error Incompatibilities between `expect()` and vitest
|
|
7
|
+
expect.extend(matchers);
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
1
|
+
import { expect } from 'vitest';
|
|
2
|
+
import { matchers } from '@quilted/react-testing/matchers';
|
|
3
3
|
export { createRender, destroyAll, render, rendered } from '@quilted/react-testing';
|
|
4
|
+
|
|
5
|
+
// @ts-expect-error Incompatibilities between `expect()` and vitest
|
|
6
|
+
expect.extend(matchers);
|
|
@@ -4,37 +4,67 @@ import { assertIsGraphQLController, diffVariables } from './utilities.esnext';
|
|
|
4
4
|
|
|
5
5
|
function toHavePerformedGraphQLOperation(graphql, operation, variables) {
|
|
6
6
|
assertIsGraphQLController(graphql, {
|
|
7
|
-
expectation:
|
|
7
|
+
expectation: "toHavePerformedGraphQLOperation",
|
|
8
8
|
isNot: this.isNot
|
|
9
9
|
});
|
|
10
10
|
const foundByOperation = graphql.completed.all({
|
|
11
11
|
operation
|
|
12
12
|
});
|
|
13
|
-
const foundByVariables = variables == null ? foundByOperation : foundByOperation.filter(
|
|
13
|
+
const foundByVariables = variables == null ? foundByOperation : foundByOperation.filter(
|
|
14
|
+
(operation2) => Object.keys(variables).every(
|
|
15
|
+
(key) => Object.is(
|
|
16
|
+
variables[key],
|
|
17
|
+
(operation2.variables ?? {})[key]
|
|
18
|
+
)
|
|
19
|
+
)
|
|
20
|
+
);
|
|
14
21
|
const pass = foundByVariables.length > 0;
|
|
15
|
-
const {
|
|
22
|
+
const { name } = normalizeOperation(operation);
|
|
23
|
+
const message = pass ? () => `${matcherHint(".not.toHavePerformedGraphQLOperation")}
|
|
24
|
+
|
|
25
|
+
Expected not to have performed GraphQL operation:
|
|
26
|
+
${EXPECTED_COLOR(
|
|
27
|
+
name
|
|
28
|
+
)}
|
|
29
|
+
${variables ? `With variables matching:
|
|
30
|
+
${printExpected(variables)}
|
|
31
|
+
` : ""}But ${foundByVariables.length} matching ${foundByVariables.length === 1 ? "operation was" : "operations were"} found.
|
|
32
|
+
` : () => `${`${matcherHint(".toHavePerformedGraphQLOperation")}
|
|
33
|
+
|
|
34
|
+
Expected to have performed GraphQL operation:
|
|
35
|
+
${EXPECTED_COLOR(
|
|
16
36
|
name
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
37
|
+
)}
|
|
38
|
+
${variables ? `With variables matching:
|
|
39
|
+
${printExpected(variables)}
|
|
40
|
+
` : ""}`}${foundByOperation.length === 0 ? `But no matching operations were found.
|
|
41
|
+
` : `But the ${foundByVariables.length === 1 ? "found operation has" : "found operations have"} the following variable differences:
|
|
42
|
+
|
|
43
|
+
${diffs(
|
|
44
|
+
foundByVariables,
|
|
45
|
+
variables,
|
|
46
|
+
this.expand
|
|
47
|
+
)}`}`;
|
|
48
|
+
return { pass, message };
|
|
23
49
|
}
|
|
24
50
|
function diffs(requests, variables, expand) {
|
|
25
|
-
return requests.reduce(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
return requests.reduce(
|
|
52
|
+
(diffs2, request, index) => `${diffs2}${index === 0 ? "" : "\n\n"}${normalizedDiff(
|
|
53
|
+
request,
|
|
54
|
+
variables,
|
|
55
|
+
{
|
|
56
|
+
expand,
|
|
57
|
+
showLegend: index === 0
|
|
58
|
+
}
|
|
59
|
+
)}`,
|
|
60
|
+
""
|
|
61
|
+
);
|
|
29
62
|
}
|
|
30
|
-
function normalizedDiff(request, variables, {
|
|
31
|
-
expand = false,
|
|
32
|
-
showLegend = false
|
|
33
|
-
}) {
|
|
63
|
+
function normalizedDiff(request, variables, { expand = false, showLegend = false }) {
|
|
34
64
|
const result = diffVariables(request.variables ?? {}, variables, {
|
|
35
65
|
expand
|
|
36
|
-
}) ||
|
|
37
|
-
return showLegend ? result : result.split(
|
|
66
|
+
}) || "";
|
|
67
|
+
return showLegend ? result : result.split("\n\n")[1];
|
|
38
68
|
}
|
|
39
69
|
|
|
40
70
|
export { toHavePerformedGraphQLOperation };
|
|
@@ -1,35 +1,38 @@
|
|
|
1
1
|
import { matcherErrorMessage, matcherHint, RECEIVED_COLOR, printWithType, printReceived, diff } from 'jest-matcher-utils';
|
|
2
2
|
import { GraphQLController } from '@quilted/graphql/testing';
|
|
3
3
|
|
|
4
|
-
function assertIsGraphQLController(graphql, {
|
|
5
|
-
expectation,
|
|
6
|
-
isNot
|
|
7
|
-
}) {
|
|
4
|
+
function assertIsGraphQLController(graphql, { expectation, isNot = false }) {
|
|
8
5
|
if (!(graphql instanceof GraphQLController)) {
|
|
9
|
-
throw new Error(
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
throw new Error(
|
|
7
|
+
matcherErrorMessage(
|
|
8
|
+
matcherHint(`.${expectation}`, void 0, void 0, { isNot }),
|
|
9
|
+
`${RECEIVED_COLOR(
|
|
10
|
+
"received"
|
|
11
|
+
)} value must be a @quilted/graphql/fixtures GraphQLController object`,
|
|
12
|
+
printWithType("Received", graphql, printReceived)
|
|
13
|
+
)
|
|
14
|
+
);
|
|
12
15
|
}
|
|
13
16
|
}
|
|
14
|
-
function diffVariables(actual, expected, {
|
|
15
|
-
expand = false
|
|
16
|
-
}) {
|
|
17
|
+
function diffVariables(actual, expected, { expand = false }) {
|
|
17
18
|
return diff(expected, getObjectSubset(actual, expected), {
|
|
18
19
|
expand
|
|
19
20
|
});
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
// Original from https://github.com/facebook/jest/blob/master/packages/expect/source/utils.ts#L107
|
|
23
22
|
function getObjectSubset(object, subset) {
|
|
24
23
|
if (Array.isArray(object)) {
|
|
25
24
|
if (Array.isArray(subset) && subset.length === object.length) {
|
|
26
|
-
return subset.map(
|
|
25
|
+
return subset.map(
|
|
26
|
+
(sub, i) => getObjectSubset(object[i], sub)
|
|
27
|
+
);
|
|
27
28
|
}
|
|
28
29
|
} else if (object instanceof Date) {
|
|
29
30
|
return object;
|
|
30
|
-
} else if (typeof object ===
|
|
31
|
+
} else if (typeof object === "object" && object !== null && typeof subset === "object" && subset !== null) {
|
|
31
32
|
const trimmed = {};
|
|
32
|
-
Object.keys(subset).filter(key => Reflect.has(object, key)).forEach(
|
|
33
|
+
Object.keys(subset).filter((key) => Reflect.has(object, key)).forEach(
|
|
34
|
+
(key) => trimmed[key] = getObjectSubset(object[key], subset[key])
|
|
35
|
+
);
|
|
33
36
|
if (Object.keys(trimmed).length > 0) {
|
|
34
37
|
return trimmed;
|
|
35
38
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { expect } from '@quilted/testing';
|
|
2
1
|
import { toHavePerformedGraphQLOperation } from './matchers/operations.esnext';
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
const matchers = {
|
|
5
4
|
toHavePerformedGraphQLOperation,
|
|
6
5
|
toHavePerformedGraphQLQuery: toHavePerformedGraphQLOperation,
|
|
7
6
|
toHavePerformedGraphQLMutation: toHavePerformedGraphQLOperation
|
|
8
|
-
}
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { matchers };
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
1
2
|
import { HttpContext, CookieContext } from '@quilted/react-http';
|
|
2
3
|
import { useHTMLUpdater } from '@quilted/react-html';
|
|
3
|
-
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
|
|
5
|
-
function HTML({
|
|
6
|
-
children
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
children: [/*#__PURE__*/jsx(HTMLUpdater, {}), children]
|
|
11
|
-
})
|
|
12
|
-
});
|
|
5
|
+
function HTML({ children }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(HttpContext, { children: /* @__PURE__ */ jsxs(CookieContext, { children: [
|
|
7
|
+
/* @__PURE__ */ jsx(HTMLUpdater, {}),
|
|
8
|
+
children
|
|
9
|
+
] }) });
|
|
13
10
|
}
|
|
14
11
|
function HTMLUpdater() {
|
|
15
12
|
useHTMLUpdater();
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import '
|
|
2
|
-
|
|
1
|
+
import { expect } from 'vitest';
|
|
2
|
+
import { matchers } from '@quilted/react-testing/matchers';
|
|
3
3
|
export { createRender, destroyAll, render, rendered } from '@quilted/react-testing';
|
|
4
|
+
|
|
5
|
+
expect.extend(matchers);
|
|
@@ -11,8 +11,20 @@ function ServerContext({
|
|
|
11
11
|
assets,
|
|
12
12
|
children
|
|
13
13
|
}) {
|
|
14
|
-
const normalizedUrl = typeof url ===
|
|
15
|
-
return maybeWrapContext(
|
|
14
|
+
const normalizedUrl = typeof url === "string" ? new URL(url) : url;
|
|
15
|
+
return maybeWrapContext(
|
|
16
|
+
AssetsContext,
|
|
17
|
+
assets,
|
|
18
|
+
maybeWrapContext(
|
|
19
|
+
HttpServerContext,
|
|
20
|
+
http,
|
|
21
|
+
maybeWrapContext(
|
|
22
|
+
HTMLContext,
|
|
23
|
+
html,
|
|
24
|
+
maybeWrapContext(InitialUrlContext, normalizedUrl, children)
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
);
|
|
16
28
|
}
|
|
17
29
|
|
|
18
30
|
export { ServerContext };
|
|
@@ -15,20 +15,19 @@ async function assetsForRequest(request, {
|
|
|
15
15
|
cacheKey: getCacheKey
|
|
16
16
|
}) {
|
|
17
17
|
const url = new URL(request.url);
|
|
18
|
-
const modules = url.searchParams.get(
|
|
19
|
-
const includeStyles = url.searchParams.get(
|
|
20
|
-
const includeScripts = url.searchParams.get(
|
|
21
|
-
const cacheKey =
|
|
22
|
-
const {
|
|
23
|
-
styles,
|
|
24
|
-
scripts
|
|
25
|
-
} = await assets.entry({
|
|
18
|
+
const modules = url.searchParams.get("modules")?.split(",") ?? [];
|
|
19
|
+
const includeStyles = url.searchParams.get("styles") !== "false";
|
|
20
|
+
const includeScripts = url.searchParams.get("scripts") !== "false";
|
|
21
|
+
const cacheKey = await getCacheKey?.(request, context) ?? await assets.cacheKey?.(request);
|
|
22
|
+
const { styles, scripts } = await assets.entry({
|
|
26
23
|
modules,
|
|
27
24
|
cacheKey
|
|
28
25
|
});
|
|
29
26
|
const result = {};
|
|
30
|
-
if (includeStyles)
|
|
31
|
-
|
|
27
|
+
if (includeStyles)
|
|
28
|
+
result.styles = styles;
|
|
29
|
+
if (includeScripts)
|
|
30
|
+
result.scripts = scripts;
|
|
32
31
|
return result;
|
|
33
32
|
}
|
|
34
33
|
|