@quilted/quilt 0.8.12 → 0.9.1
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 +39 -0
- package/build/esm/context/QuiltFrameworkContext.mjs +109 -0
- package/build/esm/context/testing.mjs +40 -0
- package/build/esm/context.mjs +2 -1
- package/build/esm/hono/node.mjs +1 -0
- package/build/esm/hono.mjs +1 -0
- package/build/esm/server.mjs +0 -1
- package/build/esnext/context/QuiltFrameworkContext.esnext +92 -0
- package/build/esnext/context/testing.esnext +33 -0
- package/build/esnext/context.esnext +2 -1
- package/build/esnext/hono/node.esnext +1 -0
- package/build/esnext/hono.esnext +1 -0
- package/build/esnext/server.esnext +0 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/context/QuiltFrameworkContext.d.ts +66 -0
- package/build/typescript/context/QuiltFrameworkContext.d.ts.map +1 -0
- package/build/typescript/context/testing.d.ts +41 -0
- package/build/typescript/context/testing.d.ts.map +1 -0
- package/build/typescript/context.d.ts +2 -1
- package/build/typescript/context.d.ts.map +1 -1
- package/build/typescript/hono/node.d.ts +2 -0
- package/build/typescript/hono/node.d.ts.map +1 -0
- package/build/typescript/hono.d.ts +2 -0
- package/build/typescript/hono.d.ts.map +1 -0
- package/build/typescript/modules/magic.d.ts +4 -4
- package/build/typescript/modules/magic.d.ts.map +1 -1
- package/build/typescript/server.d.ts +0 -1
- package/build/typescript/server.d.ts.map +1 -1
- package/package.json +44 -35
- package/source/context/QuiltFrameworkContext.tsx +176 -0
- package/source/context/testing.tsx +77 -0
- package/source/context.ts +14 -1
- package/source/hono/node.ts +1 -0
- package/source/hono.ts +1 -0
- package/source/modules/magic.ts +4 -4
- package/source/server.ts +0 -1
- package/tsconfig.json +1 -1
- package/build/esm/request-router/node.mjs +0 -1
- package/build/esm/request-router.mjs +0 -1
- package/build/esnext/request-router/node.esnext +0 -1
- package/build/esnext/request-router.esnext +0 -1
- package/build/typescript/globals.d.ts +0 -11
- package/build/typescript/globals.d.ts.map +0 -1
- package/build/typescript/request-router/node.d.ts +0 -2
- package/build/typescript/request-router/node.d.ts.map +0 -1
- package/build/typescript/request-router.d.ts +0 -2
- package/build/typescript/request-router.d.ts.map +0 -1
- package/source/request-router/node.ts +0 -1
- package/source/request-router.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,44 @@
|
|
|
1
1
|
# @quilted/quilt
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`e6fa47e`](https://github.com/lemonmade/quilt/commit/e6fa47e93981ce0eaebbe1546659aaa08cc22689) Thanks [@lemonmade](https://github.com/lemonmade)! - Update Preact and Signal dependencies
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`b1df5da`](https://github.com/lemonmade/quilt/commit/b1df5daff8441f8435a62b02b4ad3676d3ddcc3b), [`06b43bc`](https://github.com/lemonmade/quilt/commit/06b43bc44d271ce30798dc0b582870208bae1572), [`e6fa47e`](https://github.com/lemonmade/quilt/commit/e6fa47e93981ce0eaebbe1546659aaa08cc22689)]:
|
|
10
|
+
- @quilted/preact-browser@0.2.6
|
|
11
|
+
- @quilted/assets@0.1.11
|
|
12
|
+
- @quilted/preact-router@0.2.15
|
|
13
|
+
- @quilted/preact-performance@0.1.2
|
|
14
|
+
- @quilted/preact-localize@0.4.1
|
|
15
|
+
- @quilted/preact-context@0.1.4
|
|
16
|
+
- @quilted/preact-graphql@0.1.9
|
|
17
|
+
- @quilted/preact-signals@0.1.3
|
|
18
|
+
- @quilted/preact-testing@0.1.9
|
|
19
|
+
- @quilted/preact-workers@0.2.2
|
|
20
|
+
- @quilted/preact-async@0.1.22
|
|
21
|
+
- @quilted/react-dom@19.0.2
|
|
22
|
+
- @quilted/graphql@3.3.10
|
|
23
|
+
- @quilted/signals@0.2.4
|
|
24
|
+
- @quilted/threads@4.0.2
|
|
25
|
+
- @quilted/events@2.1.4
|
|
26
|
+
|
|
27
|
+
## 0.9.0
|
|
28
|
+
|
|
29
|
+
### Minor Changes
|
|
30
|
+
|
|
31
|
+
- [#872](https://github.com/lemonmade/quilt/pull/872) [`8bf65e7`](https://github.com/lemonmade/quilt/commit/8bf65e797f929ee95730323426c229409e65c9a4) Thanks [@lemonmade](https://github.com/lemonmade)! - Replace @quilted/request-router with Hono
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Updated dependencies [[`8bf65e7`](https://github.com/lemonmade/quilt/commit/8bf65e797f929ee95730323426c229409e65c9a4)]:
|
|
36
|
+
- @quilted/preact-localize@0.4.0
|
|
37
|
+
- @quilted/preact-browser@0.2.0
|
|
38
|
+
- @quilted/hono@0.2.0
|
|
39
|
+
- @quilted/preact-async@0.1.21
|
|
40
|
+
- @quilted/preact-router@0.2.13
|
|
41
|
+
|
|
3
42
|
## 0.8.12
|
|
4
43
|
|
|
5
44
|
### Patch Changes
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { useContext, useMemo, useLayoutEffect } from 'preact/hooks';
|
|
2
|
+
import { QuiltFrameworkContextPreact } from '@quilted/preact-context';
|
|
3
|
+
import { HTMLAttributes } from '@quilted/preact-browser';
|
|
4
|
+
import { signal } from '@quilted/preact-signals';
|
|
5
|
+
import { useAsyncActionCacheSerialization } from '@quilted/preact-async';
|
|
6
|
+
import { jsxs, Fragment, jsx } from 'preact/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Provides a `QuiltContext` value to the component tree. Accepts any declared
|
|
10
|
+
* `QuiltContext` fields as props and memoizes the context object so that
|
|
11
|
+
* consumers only re-render when a field they use actually changes.
|
|
12
|
+
*
|
|
13
|
+
* Also manages async hydration tracking and optional async action cache
|
|
14
|
+
* serialization — no separate `<AsyncContext>` needed.
|
|
15
|
+
*
|
|
16
|
+
* Use this component at the root of your application to provide navigation,
|
|
17
|
+
* localization, browser details, and other app-wide context.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* <QuiltFrameworkContext navigation={context.navigation} localization={context.localization}>
|
|
21
|
+
* <App />
|
|
22
|
+
* </QuiltFrameworkContext>
|
|
23
|
+
*/
|
|
24
|
+
function QuiltFrameworkContext({
|
|
25
|
+
navigation,
|
|
26
|
+
navigationEntry,
|
|
27
|
+
localization,
|
|
28
|
+
browser,
|
|
29
|
+
assets,
|
|
30
|
+
performance,
|
|
31
|
+
async: asyncProp,
|
|
32
|
+
graphql,
|
|
33
|
+
children
|
|
34
|
+
}) {
|
|
35
|
+
const parentContext = useContext(QuiltFrameworkContextPreact);
|
|
36
|
+
const asyncValue = useAsyncContext(asyncProp);
|
|
37
|
+
const memoizedValue = useMemo(() => ({
|
|
38
|
+
...parentContext,
|
|
39
|
+
...(navigation == null ? undefined : {
|
|
40
|
+
navigation
|
|
41
|
+
}),
|
|
42
|
+
...(navigationEntry == null ? undefined : {
|
|
43
|
+
navigationEntry
|
|
44
|
+
}),
|
|
45
|
+
...(localization == null ? undefined : {
|
|
46
|
+
localization
|
|
47
|
+
}),
|
|
48
|
+
...(browser == null ? undefined : {
|
|
49
|
+
browser
|
|
50
|
+
}),
|
|
51
|
+
...(assets == null ? undefined : {
|
|
52
|
+
assets
|
|
53
|
+
}),
|
|
54
|
+
...(performance == null ? undefined : {
|
|
55
|
+
performance
|
|
56
|
+
}),
|
|
57
|
+
async: asyncValue,
|
|
58
|
+
...(graphql == null ? undefined : {
|
|
59
|
+
graphql
|
|
60
|
+
})
|
|
61
|
+
}), [parentContext, navigation, navigationEntry, localization, browser, assets, performance, asyncValue, graphql]);
|
|
62
|
+
if (typeof document !== 'object') {
|
|
63
|
+
if (navigation?.cache) {
|
|
64
|
+
// Serialize the navigation cache for server-side rendering.
|
|
65
|
+
useAsyncActionCacheSerialization(navigation.cache, {
|
|
66
|
+
name: 'quilt:router'
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return jsxs(Fragment, {
|
|
71
|
+
children: [localization && jsx(HTMLAttributes, {
|
|
72
|
+
lang: localization.locale,
|
|
73
|
+
dir: localization.direction
|
|
74
|
+
}), jsx(QuiltFrameworkContextPreact.Provider, {
|
|
75
|
+
value: memoizedValue,
|
|
76
|
+
children: children
|
|
77
|
+
})]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function useAsyncContext({
|
|
81
|
+
cache: asyncCache,
|
|
82
|
+
components: asyncComponents,
|
|
83
|
+
serialize: asyncSerialize = true
|
|
84
|
+
} = {}) {
|
|
85
|
+
// Hydration signal: starts false on the server, flips to true after
|
|
86
|
+
// the first client-side render. Stable across re-renders via useRef.
|
|
87
|
+
const hydratedSignal = useMemo(() => signal(false), []);
|
|
88
|
+
if (typeof document === 'object') {
|
|
89
|
+
useLayoutEffect(() => {
|
|
90
|
+
hydratedSignal.value = true;
|
|
91
|
+
}, []);
|
|
92
|
+
}
|
|
93
|
+
if (typeof document !== 'object') {
|
|
94
|
+
// Serialize the async action cache for server-side rendering.
|
|
95
|
+
useAsyncActionCacheSerialization(asyncSerialize ? asyncCache : undefined, {
|
|
96
|
+
name: 'quilt:async',
|
|
97
|
+
optional: true
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
return useMemo(() => ({
|
|
101
|
+
cache: asyncCache,
|
|
102
|
+
components: asyncComponents,
|
|
103
|
+
get isHydrated() {
|
|
104
|
+
return hydratedSignal.value;
|
|
105
|
+
}
|
|
106
|
+
}), [asyncCache, asyncComponents, hydratedSignal]);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export { QuiltFrameworkContext };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useMemo } from 'preact/hooks';
|
|
2
|
+
import { QuiltFrameworkContextPreact } from '@quilted/preact-context';
|
|
3
|
+
import { TestNavigation } from '@quilted/preact-router/testing';
|
|
4
|
+
import { TestBrowser } from '@quilted/preact-browser/testing';
|
|
5
|
+
import { Localization } from '@quilted/preact-localize';
|
|
6
|
+
import { jsx } from 'preact/jsx-runtime';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Provides a `QuiltContext` configured with test-friendly instances of
|
|
10
|
+
* navigation, localization, and browser details. Use this in unit tests
|
|
11
|
+
* to wrap components that need Quilt context.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const navigation = new TestNavigation('/my-page');
|
|
15
|
+
* render(
|
|
16
|
+
* <QuiltFrameworkTestContext navigation={navigation} localization={new Localization('fr')}>
|
|
17
|
+
* <MyComponent />
|
|
18
|
+
* </QuiltFrameworkTestContext>
|
|
19
|
+
* );
|
|
20
|
+
*/
|
|
21
|
+
function QuiltFrameworkTestContext({
|
|
22
|
+
navigation,
|
|
23
|
+
localization = new Localization('en'),
|
|
24
|
+
browser,
|
|
25
|
+
children
|
|
26
|
+
}) {
|
|
27
|
+
const resolvedNavigation = useMemo(() => navigation ?? new TestNavigation(), [navigation]);
|
|
28
|
+
const resolvedBrowser = useMemo(() => browser ?? new TestBrowser(), [browser]);
|
|
29
|
+
const value = useMemo(() => ({
|
|
30
|
+
navigation: resolvedNavigation,
|
|
31
|
+
localization,
|
|
32
|
+
browser: resolvedBrowser
|
|
33
|
+
}), [resolvedNavigation, localization, resolvedBrowser]);
|
|
34
|
+
return jsx(QuiltFrameworkContextPreact.Provider, {
|
|
35
|
+
value: value,
|
|
36
|
+
children: children
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { QuiltFrameworkTestContext };
|
package/build/esm/context.mjs
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { QuiltFrameworkContextPreact, createOptionalContext, useQuiltContext } from '@quilted/preact-context';
|
|
2
|
+
export { QuiltFrameworkContext } from './context/QuiltFrameworkContext.mjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@quilted/hono/node';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@quilted/hono';
|
package/build/esm/server.mjs
CHANGED
|
@@ -2,4 +2,3 @@ export { renderToStaticMarkup, renderToString, renderToStringAsync } from 'preac
|
|
|
2
2
|
export * from '@quilted/preact-browser/server';
|
|
3
3
|
export * from '@quilted/assets';
|
|
4
4
|
export { parseAcceptLanguageHeader } from '@quilted/preact-localize';
|
|
5
|
-
export { createRequestRouterLocalization } from '@quilted/preact-localize/request-router';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'preact/jsx-runtime';
|
|
2
|
+
import { useContext, useMemo, useLayoutEffect } from 'preact/hooks';
|
|
3
|
+
import { QuiltFrameworkContextPreact } from '@quilted/preact-context';
|
|
4
|
+
import { HTMLAttributes } from '@quilted/preact-browser';
|
|
5
|
+
import { signal } from '@quilted/preact-signals';
|
|
6
|
+
import { useAsyncActionCacheSerialization } from '@quilted/preact-async';
|
|
7
|
+
|
|
8
|
+
function QuiltFrameworkContext({
|
|
9
|
+
navigation,
|
|
10
|
+
navigationEntry,
|
|
11
|
+
localization,
|
|
12
|
+
browser,
|
|
13
|
+
assets,
|
|
14
|
+
performance,
|
|
15
|
+
async: asyncProp,
|
|
16
|
+
graphql,
|
|
17
|
+
children
|
|
18
|
+
}) {
|
|
19
|
+
const parentContext = useContext(QuiltFrameworkContextPreact);
|
|
20
|
+
const asyncValue = useAsyncContext(asyncProp);
|
|
21
|
+
const memoizedValue = useMemo(
|
|
22
|
+
() => ({
|
|
23
|
+
...parentContext,
|
|
24
|
+
...navigation == null ? void 0 : { navigation },
|
|
25
|
+
...navigationEntry == null ? void 0 : { navigationEntry },
|
|
26
|
+
...localization == null ? void 0 : { localization },
|
|
27
|
+
...browser == null ? void 0 : { browser },
|
|
28
|
+
...assets == null ? void 0 : { assets },
|
|
29
|
+
...performance == null ? void 0 : { performance },
|
|
30
|
+
async: asyncValue,
|
|
31
|
+
...graphql == null ? void 0 : { graphql }
|
|
32
|
+
}),
|
|
33
|
+
[
|
|
34
|
+
parentContext,
|
|
35
|
+
navigation,
|
|
36
|
+
navigationEntry,
|
|
37
|
+
localization,
|
|
38
|
+
browser,
|
|
39
|
+
assets,
|
|
40
|
+
performance,
|
|
41
|
+
asyncValue,
|
|
42
|
+
graphql
|
|
43
|
+
]
|
|
44
|
+
);
|
|
45
|
+
if (typeof document !== "object") {
|
|
46
|
+
if (navigation?.cache) {
|
|
47
|
+
useAsyncActionCacheSerialization(navigation.cache, {
|
|
48
|
+
name: "quilt:router"
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
localization && /* @__PURE__ */ jsx(
|
|
54
|
+
HTMLAttributes,
|
|
55
|
+
{
|
|
56
|
+
lang: localization.locale,
|
|
57
|
+
dir: localization.direction
|
|
58
|
+
}
|
|
59
|
+
),
|
|
60
|
+
/* @__PURE__ */ jsx(QuiltFrameworkContextPreact.Provider, { value: memoizedValue, children })
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
function useAsyncContext({
|
|
64
|
+
cache: asyncCache,
|
|
65
|
+
components: asyncComponents,
|
|
66
|
+
serialize: asyncSerialize = true
|
|
67
|
+
} = {}) {
|
|
68
|
+
const hydratedSignal = useMemo(() => signal(false), []);
|
|
69
|
+
if (typeof document === "object") {
|
|
70
|
+
useLayoutEffect(() => {
|
|
71
|
+
hydratedSignal.value = true;
|
|
72
|
+
}, []);
|
|
73
|
+
}
|
|
74
|
+
if (typeof document !== "object") {
|
|
75
|
+
useAsyncActionCacheSerialization(asyncSerialize ? asyncCache : void 0, {
|
|
76
|
+
name: "quilt:async",
|
|
77
|
+
optional: true
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return useMemo(
|
|
81
|
+
() => ({
|
|
82
|
+
cache: asyncCache,
|
|
83
|
+
components: asyncComponents,
|
|
84
|
+
get isHydrated() {
|
|
85
|
+
return hydratedSignal.value;
|
|
86
|
+
}
|
|
87
|
+
}),
|
|
88
|
+
[asyncCache, asyncComponents, hydratedSignal]
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { QuiltFrameworkContext };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx } from 'preact/jsx-runtime';
|
|
2
|
+
import { useMemo } from 'preact/hooks';
|
|
3
|
+
import { QuiltFrameworkContextPreact } from '@quilted/preact-context';
|
|
4
|
+
import { TestNavigation } from '@quilted/preact-router/testing';
|
|
5
|
+
import { TestBrowser } from '@quilted/preact-browser/testing';
|
|
6
|
+
import { Localization } from '@quilted/preact-localize';
|
|
7
|
+
|
|
8
|
+
function QuiltFrameworkTestContext({
|
|
9
|
+
navigation,
|
|
10
|
+
localization = new Localization("en"),
|
|
11
|
+
browser,
|
|
12
|
+
children
|
|
13
|
+
}) {
|
|
14
|
+
const resolvedNavigation = useMemo(
|
|
15
|
+
() => navigation ?? new TestNavigation(),
|
|
16
|
+
[navigation]
|
|
17
|
+
);
|
|
18
|
+
const resolvedBrowser = useMemo(
|
|
19
|
+
() => browser ?? new TestBrowser(),
|
|
20
|
+
[browser]
|
|
21
|
+
);
|
|
22
|
+
const value = useMemo(
|
|
23
|
+
() => ({
|
|
24
|
+
navigation: resolvedNavigation,
|
|
25
|
+
localization,
|
|
26
|
+
browser: resolvedBrowser
|
|
27
|
+
}),
|
|
28
|
+
[resolvedNavigation, localization, resolvedBrowser]
|
|
29
|
+
);
|
|
30
|
+
return /* @__PURE__ */ jsx(QuiltFrameworkContextPreact.Provider, { value, children });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { QuiltFrameworkTestContext };
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { QuiltFrameworkContextPreact, createOptionalContext, useQuiltContext } from '@quilted/preact-context';
|
|
2
|
+
export { QuiltFrameworkContext } from './context/QuiltFrameworkContext.esnext';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@quilted/hono/node';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@quilted/hono';
|
|
@@ -2,4 +2,3 @@ export { renderToStaticMarkup, renderToString, renderToStringAsync } from 'preac
|
|
|
2
2
|
export * from '@quilted/preact-browser/server';
|
|
3
3
|
export * from '@quilted/assets';
|
|
4
4
|
export { parseAcceptLanguageHeader } from '@quilted/preact-localize';
|
|
5
|
-
export { createRequestRouterLocalization } from '@quilted/preact-localize/request-router';
|