@krate/runtime 0.5.0-alpha.3 → 0.5.0-alpha.4

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/dist/cache.js ADDED
@@ -0,0 +1,155 @@
1
+ /**
2
+ * `@krate/runtime/cache` - on-demand revalidation and the server data cache,
3
+ * mirroring `next/cache`. Also re-exported from `@krate/runtime/server`.
4
+ *
5
+ * - `revalidatePath(path, type?)` and `revalidateTag(tag)` invalidate the
6
+ * host's ISR page cache, region caches and data cache. Inside a server
7
+ * action or an API route the invalidation is applied before the response
8
+ * is sent (read-your-writes); actions also tell the client which paths and
9
+ * tags changed. They throw when called while a page renders or outside the
10
+ * Krate server (for example during a build).
11
+ * - `unstable_cache(fn, keyParts, { tags, revalidate })` caches an async
12
+ * function's JSON-serializable result.
13
+ * - `unstable_noStore()` marks the current render uncacheable.
14
+ */
15
+ import { cacheRuntime, currentRenderScope, currentRevalidateScope, dataCacheGetJSON, dataCacheSetJSON, markNoStore, recordCacheRead, } from './cache-scope.js';
16
+ function env(name) {
17
+ const proc = globalThis.process;
18
+ return (proc && proc.env && proc.env[name]) || '';
19
+ }
20
+ /** Logs targets the host could not revalidate (static pages, unknown routes). */
21
+ export function reportSkippedRevalidations(result) {
22
+ if (!result || !Array.isArray(result.skipped))
23
+ return;
24
+ for (const s of result.skipped) {
25
+ console.warn(`[krate] revalidation skipped for ${s.target}: ${s.reason}`);
26
+ }
27
+ }
28
+ /** Sends a revalidation to the host (used outside a request scope). */
29
+ export async function sendRevalidation(payload) {
30
+ const host = env('KRATE_HOST_URL');
31
+ const secret = env('KRATE_INTERNAL_SECRET');
32
+ if (!host || !secret) {
33
+ throw new Error('revalidation needs the Krate server: KRATE_HOST_URL / KRATE_INTERNAL_SECRET are not set');
34
+ }
35
+ const res = await fetch(host.replace(/\/$/, '') + '/__krate/internal/revalidate', {
36
+ method: 'POST',
37
+ headers: { 'content-type': 'application/json', 'x-krate-internal': secret },
38
+ body: JSON.stringify(payload),
39
+ });
40
+ const text = await res.text();
41
+ if (!res.ok)
42
+ throw new Error(`revalidation failed: host answered ${res.status} ${text}`);
43
+ const result = JSON.parse(text);
44
+ reportSkippedRevalidations(result);
45
+ return result;
46
+ }
47
+ function request(api, payload) {
48
+ if (currentRenderScope()) {
49
+ throw new Error(`${api}() cannot be called while a page renders. Call it from a server action ("use server") or an API route after the data changed.`);
50
+ }
51
+ // Same-process data cache entries go right away; the host fans the tags
52
+ // out to every other process and worker.
53
+ if (payload.tags.length)
54
+ cacheRuntime().invalidate({ tags: payload.tags });
55
+ const scope = currentRevalidateScope();
56
+ if (scope) {
57
+ scope.paths.push(...payload.paths);
58
+ scope.tags.push(...payload.tags);
59
+ return;
60
+ }
61
+ const go = globalThis._go_revalidate;
62
+ if (typeof go === 'function') {
63
+ // Embedded QuickJS API route: the Go host applies it synchronously.
64
+ const out = JSON.parse(go(JSON.stringify(payload)));
65
+ if (out.error)
66
+ throw new Error(`${api}() failed: ${out.error}`);
67
+ reportSkippedRevalidations(out);
68
+ return;
69
+ }
70
+ if (env('KRATE_HOST_URL') && env('KRATE_INTERNAL_SECRET') && typeof fetch === 'function') {
71
+ // Server code outside a request (a timer, a queue consumer): send now.
72
+ sendRevalidation(payload).catch((err) => {
73
+ console.error(`[krate] ${api}() failed:`, err);
74
+ });
75
+ return;
76
+ }
77
+ throw new Error(`${api}() can only run on the Krate server: in a server action, an API route, or server code under \`krate serve\` / \`krate dev\` (KRATE_HOST_URL is not set, e.g. during a build).`);
78
+ }
79
+ /**
80
+ * Invalidates the cached render of `path`. `type: "page"` (the default for a
81
+ * concrete URL) targets that page; a dynamic pattern such as `/blog/[slug]`
82
+ * targets every cached variant; `type: "layout"` targets every page under
83
+ * the path.
84
+ */
85
+ export function revalidatePath(path, type) {
86
+ if (typeof path !== 'string' || !path.startsWith('/')) {
87
+ throw new TypeError(`revalidatePath() expects an absolute path starting with "/", got ${JSON.stringify(path)}`);
88
+ }
89
+ if (type !== undefined && type !== 'page' && type !== 'layout') {
90
+ throw new TypeError(`revalidatePath() type must be "page" or "layout", got ${JSON.stringify(type)}`);
91
+ }
92
+ request('revalidatePath', { paths: [{ path, type: type || 'page' }], tags: [] });
93
+ }
94
+ /** Invalidates every cached page render, region and data entry that read `tag`. */
95
+ export function revalidateTag(tag) {
96
+ if (typeof tag !== 'string' || tag === '') {
97
+ throw new TypeError(`revalidateTag() expects a non-empty string tag, got ${JSON.stringify(tag)}`);
98
+ }
99
+ request('revalidateTag', { paths: [], tags: [tag] });
100
+ }
101
+ const pending = new Map();
102
+ /**
103
+ * Caches the JSON-serializable result of an async function. The cache key is
104
+ * the function source, keyParts and the call arguments. Results expire after
105
+ * `revalidate` seconds (never when false/omitted) and are invalidated by
106
+ * `revalidateTag` for any of `tags`. When called during a render, the tags
107
+ * and window are recorded on the page's cache entry too.
108
+ */
109
+ export function unstable_cache(fn, keyParts, options = {}) {
110
+ if (typeof fn !== 'function')
111
+ throw new TypeError('unstable_cache() expects a function');
112
+ const tags = (options.tags || []).filter((t) => typeof t === 'string' && t !== '');
113
+ const revalidate = options.revalidate;
114
+ if (revalidate !== undefined && revalidate !== false && !(typeof revalidate === 'number' && revalidate >= 0)) {
115
+ throw new TypeError('unstable_cache() revalidate must be a number of seconds or false');
116
+ }
117
+ const ttl = typeof revalidate === 'number' ? revalidate : Infinity;
118
+ const base = String(fn) + '\u0000' + JSON.stringify(keyParts || []);
119
+ return async (...args) => {
120
+ recordCacheRead(tags, revalidate === undefined ? false : revalidate);
121
+ if (ttl === 0)
122
+ return fn(...args);
123
+ const key = 'uc:' + base + '\u0000' + JSON.stringify(args);
124
+ const hit = dataCacheGetJSON(key);
125
+ if (hit !== undefined)
126
+ return JSON.parse(hit);
127
+ const running = pending.get(key);
128
+ if (running)
129
+ return running;
130
+ const epoch = cacheRuntime().epoch;
131
+ const p = (async () => {
132
+ const value = await fn(...args);
133
+ const json = JSON.stringify(value);
134
+ if (json === undefined) {
135
+ throw new TypeError('unstable_cache() results must be JSON-serializable (got undefined or a function)');
136
+ }
137
+ dataCacheSetJSON(key, json, ttl, tags, epoch);
138
+ return value;
139
+ })();
140
+ pending.set(key, p);
141
+ try {
142
+ return await p;
143
+ }
144
+ finally {
145
+ pending.delete(key);
146
+ }
147
+ };
148
+ }
149
+ /**
150
+ * Opts the current render out of caching: an ISR page rendered with it is
151
+ * served fresh and not stored. It has no effect outside a render.
152
+ */
153
+ export function unstable_noStore() {
154
+ markNoStore();
155
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,217 @@
1
+ import { AsyncLocalStorage } from 'node:async_hooks';
2
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
3
+ import { DataCache, cacheRuntime, currentRenderScope, installRenderStore, patchFetch, withCacheScope, } from './cache-scope.js';
4
+ import { revalidatePath, revalidateTag, unstable_cache, unstable_noStore } from './cache.js';
5
+ const RUNTIME_KEY = Symbol.for('krate.cache.runtime');
6
+ const REVALIDATE_KEY = Symbol.for('krate.revalidate.store');
7
+ function resetRuntime() {
8
+ delete globalThis[RUNTIME_KEY];
9
+ delete globalThis[REVALIDATE_KEY];
10
+ installRenderStore(new AsyncLocalStorage());
11
+ }
12
+ beforeEach(() => {
13
+ resetRuntime();
14
+ vi.unstubAllEnvs();
15
+ });
16
+ afterEach(() => {
17
+ vi.unstubAllGlobals();
18
+ vi.unstubAllEnvs();
19
+ delete globalThis._go_revalidate;
20
+ });
21
+ describe('DataCache', () => {
22
+ it('indexes entries by tag and expires them', () => {
23
+ vi.useFakeTimers();
24
+ try {
25
+ const c = new DataCache(10);
26
+ c.set('a', 1, 10, ['t1']);
27
+ c.set('b', 2, Infinity, ['t1', 't2']);
28
+ c.set('c', 3, 1, []);
29
+ expect(c.get('a')).toBe(1);
30
+ vi.advanceTimersByTime(1500);
31
+ expect(c.get('c')).toBeUndefined();
32
+ expect(c.invalidateTags(['t2'])).toBe(1);
33
+ expect(c.get('b')).toBeUndefined();
34
+ expect(c.get('a')).toBe(1);
35
+ expect(c.invalidateTags(['t1'])).toBe(1);
36
+ expect(c.size).toBe(0);
37
+ }
38
+ finally {
39
+ vi.useRealTimers();
40
+ }
41
+ });
42
+ it('evicts the oldest entry when full', () => {
43
+ const c = new DataCache(2);
44
+ c.set('a', 1, 10, ['x']);
45
+ c.set('b', 2, 10, []);
46
+ c.set('c', 3, 10, []);
47
+ expect(c.get('a')).toBeUndefined();
48
+ expect(c.invalidateTags(['x'])).toBe(0);
49
+ expect(c.size).toBe(2);
50
+ });
51
+ });
52
+ describe('withCacheScope', () => {
53
+ it('records tags and the smallest revalidate window across awaits', async () => {
54
+ const cached = unstable_cache(async (n) => n * 2, ['double'], { tags: ['math'], revalidate: 30 });
55
+ const other = unstable_cache(async () => 'x', ['other'], { tags: ['letters'], revalidate: 10 });
56
+ const { result, scope, invalidated } = await withCacheScope('/p', async () => {
57
+ const a = await cached(2);
58
+ await new Promise((r) => setTimeout(r, 1));
59
+ const b = await other();
60
+ expect(currentRenderScope()?.route).toBe('/p');
61
+ return `${a}${b}`;
62
+ });
63
+ expect(result).toBe('4x');
64
+ expect([...scope.tags].sort()).toEqual(['letters', 'math']);
65
+ expect(scope.revalidate).toBe(10);
66
+ expect(scope.noStore).toBe(false);
67
+ expect(invalidated).toBe(false);
68
+ expect(currentRenderScope()).toBeUndefined();
69
+ });
70
+ it('keeps concurrent scopes apart', async () => {
71
+ const tagged = (tag) => unstable_cache(async () => tag, [tag], { tags: [tag] });
72
+ const [a, b] = await Promise.all([
73
+ withCacheScope('/a', async () => {
74
+ await new Promise((r) => setTimeout(r, 2));
75
+ return tagged('a')();
76
+ }),
77
+ withCacheScope('/b', () => tagged('b')()),
78
+ ]);
79
+ expect([...a.scope.tags]).toEqual(['a']);
80
+ expect([...b.scope.tags]).toEqual(['b']);
81
+ });
82
+ it('marks unstable_noStore renders and invalidations that land mid-render', async () => {
83
+ const r1 = await withCacheScope('/n', () => {
84
+ unstable_noStore();
85
+ return 1;
86
+ });
87
+ expect(r1.scope.noStore).toBe(true);
88
+ const r2 = await withCacheScope('/i', async () => {
89
+ cacheRuntime().invalidate({ tags: ['z'] });
90
+ return 2;
91
+ });
92
+ expect(r2.invalidated).toBe(true);
93
+ });
94
+ });
95
+ describe('unstable_cache', () => {
96
+ it('caches by key parts and arguments until the tag is revalidated', async () => {
97
+ let calls = 0;
98
+ const getPost = unstable_cache(async (id) => ({ id, n: ++calls }), ['post'], { tags: ['posts'] });
99
+ expect(await getPost('a')).toEqual({ id: 'a', n: 1 });
100
+ expect(await getPost('a')).toEqual({ id: 'a', n: 1 });
101
+ expect(await getPost('b')).toEqual({ id: 'b', n: 2 });
102
+ const scope = { kind: 'action', paths: [], tags: [] };
103
+ const store = new AsyncLocalStorage();
104
+ globalThis[REVALIDATE_KEY] = store;
105
+ store.run(scope, () => revalidateTag('posts'));
106
+ expect(scope.tags).toEqual(['posts']);
107
+ expect(await getPost('a')).toEqual({ id: 'a', n: 3 });
108
+ });
109
+ it('dedupes concurrent misses', async () => {
110
+ let calls = 0;
111
+ const slow = unstable_cache(async () => {
112
+ calls++;
113
+ await new Promise((r) => setTimeout(r, 2));
114
+ return calls;
115
+ }, ['slow']);
116
+ const [a, b] = await Promise.all([slow(), slow()]);
117
+ expect(a).toBe(1);
118
+ expect(b).toBe(1);
119
+ expect(calls).toBe(1);
120
+ });
121
+ it('does not cache with revalidate 0 and rejects non-JSON results', async () => {
122
+ let calls = 0;
123
+ const fresh = unstable_cache(async () => ++calls, ['fresh'], { revalidate: 0 });
124
+ await fresh();
125
+ await fresh();
126
+ expect(calls).toBe(2);
127
+ const bad = unstable_cache(async () => undefined, ['bad']);
128
+ await expect(bad()).rejects.toThrow(/JSON-serializable/);
129
+ expect(() => unstable_cache(async () => 1, [], { revalidate: -1 })).toThrow(/revalidate/);
130
+ });
131
+ });
132
+ describe('revalidatePath / revalidateTag', () => {
133
+ it('queue on the request scope of an action or API route', () => {
134
+ const scope = { kind: 'action', paths: [], tags: [] };
135
+ const store = new AsyncLocalStorage();
136
+ globalThis[REVALIDATE_KEY] = store;
137
+ store.run(scope, () => {
138
+ revalidatePath('/blog/[slug]');
139
+ revalidatePath('/blog', 'layout');
140
+ revalidateTag('posts');
141
+ });
142
+ expect(scope.paths).toEqual([
143
+ { path: '/blog/[slug]', type: 'page' },
144
+ { path: '/blog', type: 'layout' },
145
+ ]);
146
+ expect(scope.tags).toEqual(['posts']);
147
+ });
148
+ it('throw while a page renders', async () => {
149
+ await expect(withCacheScope('/p', () => revalidateTag('x'))).rejects.toThrow(/while a page renders/);
150
+ });
151
+ it('throw outside the Krate server instead of doing nothing', () => {
152
+ expect(() => revalidatePath('/x')).toThrow(/KRATE_HOST_URL is not set/);
153
+ expect(() => revalidateTag('x')).toThrow(/KRATE_HOST_URL is not set/);
154
+ });
155
+ it('validate their arguments', () => {
156
+ expect(() => revalidatePath('relative')).toThrow(TypeError);
157
+ expect(() => revalidatePath('/x', 'tree')).toThrow(TypeError);
158
+ expect(() => revalidateTag('')).toThrow(TypeError);
159
+ });
160
+ it('call the Go host synchronously in the embedded runtime', () => {
161
+ const calls = [];
162
+ globalThis._go_revalidate = (json) => {
163
+ calls.push(json);
164
+ return JSON.stringify({ revalidated: [], skipped: [{ target: '/about', reason: 'static page' }] });
165
+ };
166
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
167
+ try {
168
+ revalidatePath('/about');
169
+ expect(JSON.parse(calls[0])).toEqual({ paths: [{ path: '/about', type: 'page' }], tags: [] });
170
+ expect(warn).toHaveBeenCalledWith(expect.stringContaining('/about: static page'));
171
+ }
172
+ finally {
173
+ warn.mockRestore();
174
+ }
175
+ globalThis._go_revalidate = () => JSON.stringify({ error: 'boom' });
176
+ expect(() => revalidateTag('t')).toThrow(/boom/);
177
+ });
178
+ it('post to the host outside a request scope when the host is configured', async () => {
179
+ vi.stubEnv('KRATE_HOST_URL', 'http://127.0.0.1:9');
180
+ vi.stubEnv('KRATE_INTERNAL_SECRET', 's3cret');
181
+ const fetchMock = vi.fn(async () => new Response(JSON.stringify({ revalidated: [], skipped: [] }), { status: 200 }));
182
+ vi.stubGlobal('fetch', fetchMock);
183
+ revalidateTag('posts');
184
+ await vi.waitFor(() => expect(fetchMock).toHaveBeenCalledTimes(1));
185
+ const [url, init] = fetchMock.mock.calls[0];
186
+ expect(url).toBe('http://127.0.0.1:9/__krate/internal/revalidate');
187
+ expect(init.headers['x-krate-internal']).toBe('s3cret');
188
+ expect(JSON.parse(String(init.body))).toEqual({ paths: [], tags: ['posts'] });
189
+ });
190
+ });
191
+ describe('patchFetch', () => {
192
+ it('caches tagged GET responses, records tags, and bypasses no-store', async () => {
193
+ let n = 0;
194
+ const base = vi.fn(async () => new Response(`body-${++n}`, { status: 200, headers: { 'x-n': String(n) } }));
195
+ vi.stubGlobal('fetch', base);
196
+ cacheRuntime().fetchPatched = false;
197
+ patchFetch();
198
+ const read = () => fetch('http://data/posts', { next: { tags: ['posts'], revalidate: 60 } });
199
+ const { result, scope } = await withCacheScope('/p', async () => (await read()).text());
200
+ expect(result).toBe('body-1');
201
+ expect([...scope.tags]).toEqual(['posts']);
202
+ expect(scope.revalidate).toBe(60);
203
+ expect(await (await read()).text()).toBe('body-1');
204
+ expect(base).toHaveBeenCalledTimes(1);
205
+ cacheRuntime().invalidate({ tags: ['posts'] });
206
+ expect(await (await read()).text()).toBe('body-2');
207
+ const ns = await withCacheScope('/q', async () => (await fetch('http://data/posts', { cache: 'no-store' })).text());
208
+ expect(ns.result).toBe('body-3');
209
+ expect(ns.scope.noStore).toBe(true);
210
+ // Plain requests and non-GET requests are passed through uncached.
211
+ await fetch('http://data/posts');
212
+ await fetch('http://data/posts', { method: 'POST', next: { revalidate: 60 } });
213
+ expect(base).toHaveBeenCalledTimes(5);
214
+ const plainInit = base.mock.calls[4][1];
215
+ expect(plainInit.next).toBeUndefined();
216
+ });
217
+ });
package/dist/effects.js CHANGED
@@ -18,7 +18,7 @@
18
18
  // insertion and layout cleanups immediately, passive cleanups in the passive
19
19
  // phase. Component boundaries come from owners: hydration scripts declare
20
20
  // them with krateOwner and runtime-created components get one from h().
21
- import { createEffect, krateGetOwner, krateSetOwner, krateOnAfterFlush, krateOnBeforeFlush, krateOnDispose, kratePendingFlush, runAfterFlush, untrack, krateCommitting, krateDisposeOwner, krateEpoch, kratePruneSnapshots, krateReadAt, krateTakeSyncLane, } from './signal.js';
21
+ import { createEffect, krateGetOwner, krateSetOwner, krateOnAfterFlush, krateOnBeforeFlush, krateOnDispose, kratePendingFlush, runAfterFlush, untrack, krateCommitting, krateDisposeOwner, krateEpoch, kratePruneSnapshots, krateReadAt, krateTakeSyncLane, krateCurrentScope, krateTagOwner, krateScopeOfId, } from './signal.js';
22
22
  const root = newOwner(null, null);
23
23
  const byId = new Map();
24
24
  // Last branch shown by each dynamic conditional slot, as reported by kbindCond.
@@ -37,7 +37,13 @@ const records = [];
37
37
  const liveEpochs = new Map();
38
38
  const unmountHooks = [];
39
39
  function newOwner(id, parent) {
40
- return { id, parent, children: [], hooks: [], disposed: false, shown: true, conds: [], slot: null, record: null };
40
+ // Components inherit the route scope of their parent component; top-level
41
+ // hydrated components take the scope their hydration code runs in.
42
+ const scope = parent && parent.parent !== null ? parent.scope : parent ? krateCurrentScope() : null;
43
+ const owner = { id, parent, children: [], hooks: [], disposed: false, shown: true, conds: [], slot: null, record: null, scope };
44
+ if (parent)
45
+ krateTagOwner(owner, scope);
46
+ return owner;
41
47
  }
42
48
  /**
43
49
  * Registers fn to run whenever a component owner unmounts (parent first),
@@ -390,6 +396,7 @@ export function createEffectDeps(fn, deps, phase = 'passive') {
390
396
  dirty: false,
391
397
  seq: seq++,
392
398
  stop: () => { },
399
+ scope: owner === root ? krateCurrentScope() : owner.scope,
393
400
  };
394
401
  owner.hooks.push(hook);
395
402
  if (owner.disposed)
@@ -671,7 +678,71 @@ export function krateDepsOf(value) {
671
678
  }
672
679
  return [value];
673
680
  }
674
- function unmountAll() {
681
+ // Partial teardown (soft navigation keeping layouts mounted): unmount every
682
+ // component of a torn-down route scope and forget its slot state.
683
+ function unmountExcept(gone) {
684
+ const passive = [];
685
+ for (const child of root.children.slice()) {
686
+ if (!gone(child.scope))
687
+ continue;
688
+ disposeTree(child, child.shown, passive);
689
+ const i = root.children.indexOf(child);
690
+ if (i >= 0)
691
+ root.children.splice(i, 1);
692
+ }
693
+ const keptHooks = [];
694
+ for (const hook of root.hooks) {
695
+ if (!gone(hook.scope)) {
696
+ keptHooks.push(hook);
697
+ continue;
698
+ }
699
+ hook.stop();
700
+ dirty.delete(hook);
701
+ if (hook.phase === 'passive') {
702
+ const c = takeCleanup(hook);
703
+ if (c)
704
+ passive.push(c);
705
+ }
706
+ else {
707
+ runCleanup(hook);
708
+ }
709
+ }
710
+ root.hooks = keptHooks;
711
+ for (const [id, owner] of Array.from(byId)) {
712
+ if (owner.disposed || gone(owner.scope))
713
+ byId.delete(id);
714
+ }
715
+ // Slot ids of a layout start with its scope id (the layout's ID prefix).
716
+ const keptId = (id) => !gone(krateScopeOfId(id));
717
+ for (const id of Array.from(condShown.keys()))
718
+ if (!keptId(id))
719
+ condShown.delete(id);
720
+ for (const id of Array.from(replacedSlots))
721
+ if (!keptId(id))
722
+ replacedSlots.delete(id);
723
+ for (let i = records.length - 1; i >= 0; i--) {
724
+ if (!keptId(records[i].id))
725
+ records.splice(i, 1);
726
+ }
727
+ for (const hook of Array.from(dirty))
728
+ if (hook.owner.disposed)
729
+ dirty.delete(hook);
730
+ passiveSetups = passiveSetups.filter(([h]) => !h.owner.disposed && !(h.owner === root && gone(h.scope)));
731
+ for (const c of passive) {
732
+ try {
733
+ untrack(c);
734
+ }
735
+ catch {
736
+ // Keep tearing down.
737
+ }
738
+ }
739
+ krateSetOwner(null);
740
+ }
741
+ function unmountAll(gone) {
742
+ if (gone) {
743
+ unmountExcept(gone);
744
+ return;
745
+ }
675
746
  // Page teardown: everything unmounts now, layout before passive.
676
747
  const passive = [];
677
748
  for (const child of root.children.slice()) {
package/dist/index.d.ts CHANGED
@@ -12,8 +12,8 @@ export { h, mount, hydrate, insert, clearNodes, disposeNode, krateApplyStyle } f
12
12
  export { krateList, krateBindList } from './list.js';
13
13
  export { krateCondSwap, krateCondDetached, krateCondReset, krateSanitizeAttr, BLOCKED_URL } from './slots.js';
14
14
  export { Fragment, jsx, jsxs } from './jsx-runtime.js';
15
- export { initRouter, reinitRouter, navigate } from './router.js';
16
- export type { NavigateOptions } from './router.js';
15
+ export { initRouter, reinitRouter, destroyRouter, navigate, krateRouter, subscribeNavigation, getNavigationState, getHistoryState, invalidatePrefetchCache, } from './router.js';
16
+ export type { NavigateOptions, NavigationState } from './router.js';
17
17
  export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
18
18
  export type { ClassValue, CVAConfig } from './class-helpers.js';
19
19
  export { createContext, createScope, createScopeFlags, resetContexts } from './context.js';
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ export { h, mount, hydrate, insert, clearNodes, disposeNode, krateApplyStyle } f
7
7
  export { krateList, krateBindList } from './list.js';
8
8
  export { krateCondSwap, krateCondDetached, krateCondReset, krateSanitizeAttr, BLOCKED_URL } from './slots.js';
9
9
  export { Fragment, jsx, jsxs } from './jsx-runtime.js';
10
- export { initRouter, reinitRouter, navigate } from './router.js';
10
+ export { initRouter, reinitRouter, destroyRouter, navigate, krateRouter, subscribeNavigation, getNavigationState, getHistoryState, invalidatePrefetchCache, } from './router.js';
11
11
  export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
12
12
  export { createContext, createScope, createScopeFlags, resetContexts } from './context.js';
13
13
  export { createResource } from './resource.js';