@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 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` lifecycle hooks.
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentf/web",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "description": "The native-first OTF Web runtime — signal-based reactivity and zero-VDOM DOM operations, paired with the IR-based compiler.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,9 +1,14 @@
1
- // Lifecycle hooks. `onMount`/`onCleanup` are compiler macros: the OpenTF
2
- // compiler collects their callbacks and wires them into a component's
3
- // connect/disconnect (Custom Element) or a page/layout factory's `__lifecycle`
4
- // record. These exports exist so the source-level `import { onMount } from
5
- // "@opentf/web"` resolves, and so calling them outside a compiled component (or
6
- // during SSR) is a safe no-op rather than a crash.
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
  };