@opentf/web 0.9.0 → 0.11.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/README.md +2 -1
- package/package.json +1 -1
- package/runtime/lifecycle.js +11 -6
- package/runtime/router.js +6 -0
package/README.md
CHANGED
|
@@ -25,7 +25,8 @@ and drive it with [`@opentf/web-cli`](https://github.com/Open-Tech-Foundation/We
|
|
|
25
25
|
`Portal`, `ErrorBoundary`, and event dispatch (`emit`).
|
|
26
26
|
- **Compiler macros** — authored in your components, resolved at compile time:
|
|
27
27
|
`$state`, `$derived`, `$ref`, `$context`, `$effect`, `$expose`, and the
|
|
28
|
-
`onMount` / `onCleanup`
|
|
28
|
+
`onMount` / `onCleanup` / `onResize` / `onVisibilityChange` / `onMediaQuery`
|
|
29
|
+
lifecycle hooks.
|
|
29
30
|
- **`<Link>`** — client-side navigation, shipped as JSX source and compiled by your
|
|
30
31
|
app's pipeline.
|
|
31
32
|
|
package/package.json
CHANGED
package/runtime/lifecycle.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
// Lifecycle hooks. `onMount`/`onCleanup
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
1
|
+
// Lifecycle hooks. `onMount`/`onCleanup`/`onResize`/`onMediaQuery`/
|
|
2
|
+
// `onVisibilityChange` are compiler macros: the OpenTF compiler collects their
|
|
3
|
+
// callbacks and wires them into a component's connect/disconnect (Custom
|
|
4
|
+
// Element) or a page/layout factory's `__lifecycle` record — the DOM hooks
|
|
5
|
+
// desugar to ResizeObserver/IntersectionObserver/matchMedia setup with
|
|
6
|
+
// automatic teardown. These exports exist so the source-level `import {
|
|
7
|
+
// onMount } from "@opentf/web"` resolves, and so calling them outside a
|
|
8
|
+
// compiled component (or during SSR) is a safe no-op rather than a crash.
|
|
7
9
|
|
|
8
10
|
export function onMount() {}
|
|
9
11
|
export function onCleanup() {}
|
|
12
|
+
export function onResize() {}
|
|
13
|
+
export function onMediaQuery() {}
|
|
14
|
+
export function onVisibilityChange() {}
|
package/runtime/router.js
CHANGED
|
@@ -338,7 +338,13 @@ export async function navigate(path, replace = false, isPop = false, hydrate = f
|
|
|
338
338
|
if (guard) {
|
|
339
339
|
let redirected = false;
|
|
340
340
|
const to = {
|
|
341
|
+
// `pathname` is the documented, platform-standard field (matches the URL API
|
|
342
|
+
// and `router.pathname`); `path` is kept as a back-compat alias. `fullPath`
|
|
343
|
+
// is the whole relative URL (pathname + query + hash), for guards that need to
|
|
344
|
+
// preserve or inspect the query/hash (e.g. redirect back after login).
|
|
345
|
+
pathname: url.pathname,
|
|
341
346
|
path: url.pathname,
|
|
347
|
+
fullPath: url.pathname + url.search + url.hash,
|
|
342
348
|
params: matchRoute(url.pathname)?.params || {},
|
|
343
349
|
query: Object.fromEntries(url.searchParams),
|
|
344
350
|
};
|