@krate/runtime 0.4.0-rc.4 → 0.4.0-rc.5
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/class-helpers.d.ts +4 -4
- package/dist/class-helpers.js +5 -5
- package/dist/context.d.ts +18 -1
- package/dist/context.js +27 -7
- package/dist/dev-overlay.d.ts +22 -0
- package/dist/dev-overlay.js +145 -8
- package/dist/dev-overlay.test.js +41 -10
- package/dist/dom.js +5 -5
- package/dist/error-overlay.d.ts +1 -1
- package/dist/error-overlay.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/krate-dev.js +124 -7
- package/dist/krate-hydrate.js +1 -1
- package/dist/krate-runtime.js +1 -1
- package/dist/reconcile.js +25 -21
- package/dist/reconcile.test.d.ts +1 -0
- package/dist/reconcile.test.js +47 -0
- package/dist/router.js +6 -6
- package/dist/server-jsx-runtime.js +1 -1
- package/dist/server-renderer.js +14 -15
- package/dist/server.js +13 -13
- package/dist/server.test.d.ts +1 -0
- package/dist/server.test.js +26 -0
- package/dist/signal.d.ts +44 -10
- package/dist/signal.js +22 -15
- package/package.json +1 -1
package/dist/class-helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type ClassValue = string | number | boolean | null | undefined | ClassValue[] | Record<string, unknown>;
|
|
2
|
-
/** `clsx`
|
|
2
|
+
/** `clsx` - conditional class names from strings, arrays, and objects. */
|
|
3
3
|
export declare function clsx(...inputs: ClassValue[]): string;
|
|
4
4
|
/**
|
|
5
5
|
* Merge conflicting Tailwind utilities. This is a deliberately small subset:
|
|
@@ -8,7 +8,7 @@ export declare function clsx(...inputs: ClassValue[]): string;
|
|
|
8
8
|
* compiler folds literal calls and this covers dynamic joins.
|
|
9
9
|
*/
|
|
10
10
|
export declare function twMerge(...inputs: ClassValue[]): string;
|
|
11
|
-
/** `cn`
|
|
11
|
+
/** `cn` - `twMerge` over `clsx`, the shadcn/ui convention. */
|
|
12
12
|
export declare function cn(...inputs: ClassValue[]): string;
|
|
13
13
|
export interface CVAConfig {
|
|
14
14
|
variants?: Record<string, Record<string, string>>;
|
|
@@ -21,7 +21,7 @@ export interface CVAConfig {
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function cva(base: string, config?: CVAConfig): (props?: Record<string, unknown>) => string;
|
|
23
23
|
/**
|
|
24
|
-
* `Slot`
|
|
24
|
+
* `Slot` - renders its single child element instead of wrapping it, merging the
|
|
25
25
|
* Slot's own props onto that child. This is the `asChild` mechanic from
|
|
26
26
|
* shadcn/radix: `<Slot className="x"><a /></Slot>` returns the `<a>` with `x`
|
|
27
27
|
* merged onto it.
|
|
@@ -33,7 +33,7 @@ export declare function Slot(props: Record<string, unknown> & {
|
|
|
33
33
|
children?: unknown;
|
|
34
34
|
}): Node | null;
|
|
35
35
|
/**
|
|
36
|
-
* `cloneElement`
|
|
36
|
+
* `cloneElement` - apply extra props (and optional replacement children) to an
|
|
37
37
|
* existing node and return it. Used by `Slot`/`asChild` and by libraries that
|
|
38
38
|
* clone a single child.
|
|
39
39
|
*/
|
package/dist/class-helpers.js
CHANGED
|
@@ -23,7 +23,7 @@ function flattenClass(value, out) {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
/** `clsx`
|
|
26
|
+
/** `clsx` - conditional class names from strings, arrays, and objects. */
|
|
27
27
|
export function clsx(...inputs) {
|
|
28
28
|
const out = [];
|
|
29
29
|
for (const input of inputs)
|
|
@@ -58,7 +58,7 @@ export function twMerge(...inputs) {
|
|
|
58
58
|
function tailwindPropertyKey(token) {
|
|
59
59
|
let t = token;
|
|
60
60
|
let prefix = '';
|
|
61
|
-
// Strip a variant chain (hover:, md:, focus:
|
|
61
|
+
// Strip a variant chain (hover:, md:, focus: - anything before the last `:`).
|
|
62
62
|
const colon = t.lastIndexOf(':');
|
|
63
63
|
if (colon >= 0) {
|
|
64
64
|
prefix = t.slice(0, colon + 1);
|
|
@@ -69,7 +69,7 @@ function tailwindPropertyKey(token) {
|
|
|
69
69
|
const scale = dash >= 0 ? t.slice(dash + 1, dash + 2) : '';
|
|
70
70
|
return prefix + base + (scale && /[0-9]/.test(scale) ? '-' + scale : '');
|
|
71
71
|
}
|
|
72
|
-
/** `cn`
|
|
72
|
+
/** `cn` - `twMerge` over `clsx`, the shadcn/ui convention. */
|
|
73
73
|
export function cn(...inputs) {
|
|
74
74
|
return twMerge(clsx(...inputs));
|
|
75
75
|
}
|
|
@@ -123,7 +123,7 @@ function matchesCompound(compound, selection, defaults) {
|
|
|
123
123
|
return true;
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
|
-
* `Slot`
|
|
126
|
+
* `Slot` - renders its single child element instead of wrapping it, merging the
|
|
127
127
|
* Slot's own props onto that child. This is the `asChild` mechanic from
|
|
128
128
|
* shadcn/radix: `<Slot className="x"><a /></Slot>` returns the `<a>` with `x`
|
|
129
129
|
* merged onto it.
|
|
@@ -189,7 +189,7 @@ function kebab(name) {
|
|
|
189
189
|
return name.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
192
|
-
* `cloneElement`
|
|
192
|
+
* `cloneElement` - apply extra props (and optional replacement children) to an
|
|
193
193
|
* existing node and return it. Used by `Slot`/`asChild` and by libraries that
|
|
194
194
|
* clone a single child.
|
|
195
195
|
*/
|
package/dist/context.d.ts
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
+
import type { CSSScope, CSSFlagsScope } from './signal.js';
|
|
1
2
|
export interface Context<T> {
|
|
2
3
|
id: number;
|
|
3
4
|
defaultValue: T;
|
|
4
5
|
Provider: (props: {
|
|
5
6
|
value: T;
|
|
6
|
-
children?:
|
|
7
|
+
children?: any;
|
|
7
8
|
}) => Node;
|
|
8
9
|
useContext: () => T;
|
|
10
|
+
/** Alias for {@link Context.useContext}. */
|
|
11
|
+
use: () => T;
|
|
9
12
|
}
|
|
10
13
|
export declare function resetContexts(): void;
|
|
14
|
+
/**
|
|
15
|
+
* Create a context that carries a CSS scope handle (see {@link CSSScope}). The
|
|
16
|
+
* default is a harmless placeholder — a `<Provider>` value always wins — so no
|
|
17
|
+
* cast is needed:
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const TabsCtx = createScope<string>();
|
|
21
|
+
* // provide: <TabsCtx.Provider value={createCSSChoice('a')}>…</Provider>
|
|
22
|
+
* // consume: const tab = TabsCtx.use();
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare function createScope<T>(): Context<CSSScope<T>>;
|
|
26
|
+
/** Like {@link createScope} but for a `createCSSFlags` handle. */
|
|
27
|
+
export declare function createScopeFlags<K extends string>(): Context<CSSFlagsScope<K>>;
|
|
11
28
|
export declare function createContext<T>(defaultValue: T): Context<T>;
|
package/dist/context.js
CHANGED
|
@@ -10,9 +10,34 @@ export function resetContexts() {
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a context that carries a CSS scope handle (see {@link CSSScope}). The
|
|
15
|
+
* default is a harmless placeholder — a `<Provider>` value always wins — so no
|
|
16
|
+
* cast is needed:
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const TabsCtx = createScope<string>();
|
|
20
|
+
* // provide: <TabsCtx.Provider value={createCSSChoice('a')}>…</Provider>
|
|
21
|
+
* // consume: const tab = TabsCtx.use();
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export function createScope() {
|
|
25
|
+
return createContext({});
|
|
26
|
+
}
|
|
27
|
+
/** Like {@link createScope} but for a `createCSSFlags` handle. */
|
|
28
|
+
export function createScopeFlags() {
|
|
29
|
+
return createContext({});
|
|
30
|
+
}
|
|
13
31
|
export function createContext(defaultValue) {
|
|
14
32
|
const id = contextId++;
|
|
15
33
|
contextStack.set(id, [defaultValue]);
|
|
34
|
+
const useContext = () => {
|
|
35
|
+
const stack = contextStack.get(id);
|
|
36
|
+
if (stack && stack.length > 0) {
|
|
37
|
+
return stack[stack.length - 1];
|
|
38
|
+
}
|
|
39
|
+
return defaultValue;
|
|
40
|
+
};
|
|
16
41
|
return {
|
|
17
42
|
id,
|
|
18
43
|
defaultValue,
|
|
@@ -45,12 +70,7 @@ export function createContext(defaultValue) {
|
|
|
45
70
|
}
|
|
46
71
|
return container;
|
|
47
72
|
},
|
|
48
|
-
useContext
|
|
49
|
-
|
|
50
|
-
if (stack && stack.length > 0) {
|
|
51
|
-
return stack[stack.length - 1];
|
|
52
|
-
}
|
|
53
|
-
return defaultValue;
|
|
54
|
-
},
|
|
73
|
+
useContext,
|
|
74
|
+
use: useContext,
|
|
55
75
|
};
|
|
56
76
|
}
|
package/dist/dev-overlay.d.ts
CHANGED
|
@@ -6,6 +6,27 @@
|
|
|
6
6
|
* diagnostics (file:line:col + source + caret + hint) and client runtime errors,
|
|
7
7
|
* forwards runtime errors back to the dev server, and offers open-in-editor.
|
|
8
8
|
*/
|
|
9
|
+
interface MapSegment {
|
|
10
|
+
genCol: number;
|
|
11
|
+
src: number;
|
|
12
|
+
srcLine: number;
|
|
13
|
+
srcCol: number;
|
|
14
|
+
}
|
|
15
|
+
/** Decodes a Base64 VLQ mapping segment into a delta array. */
|
|
16
|
+
export declare function decodeVLQ(str: string): number[];
|
|
17
|
+
/** Decodes a v3 `mappings` string into per-generated-line segments. */
|
|
18
|
+
export declare function decodeMappings(mappings: string): MapSegment[][];
|
|
19
|
+
interface StackFrame {
|
|
20
|
+
prefix: string;
|
|
21
|
+
url: string;
|
|
22
|
+
line: number;
|
|
23
|
+
col: number;
|
|
24
|
+
suffix: string;
|
|
25
|
+
}
|
|
26
|
+
/** Parses a V8/Firefox stack line into its script location, if present. */
|
|
27
|
+
export declare function parseStackFrame(line: string): StackFrame | null;
|
|
28
|
+
/** Rewrites each mappable frame of a stack trace to its original location. */
|
|
29
|
+
export declare function symbolicateStack(stack: string): Promise<string>;
|
|
9
30
|
/**
|
|
10
31
|
* Route matcher: a segment starting with `[` matches anything; `[...x]` matches
|
|
11
32
|
* the rest. Exported (pure) for testing.
|
|
@@ -13,3 +34,4 @@
|
|
|
13
34
|
export declare function routeMatches(pattern: string, pathname: string, basePath?: string): boolean;
|
|
14
35
|
/** Initialise the dev overlay. Safe to call more than once. */
|
|
15
36
|
export declare function initDevOverlay(): void;
|
|
37
|
+
export {};
|
package/dist/dev-overlay.js
CHANGED
|
@@ -37,6 +37,129 @@ function stripBase(pathname, basePath) {
|
|
|
37
37
|
}
|
|
38
38
|
return pathname;
|
|
39
39
|
}
|
|
40
|
+
const B64_VLQ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
41
|
+
/** Decodes a Base64 VLQ mapping segment into a delta array. */
|
|
42
|
+
export function decodeVLQ(str) {
|
|
43
|
+
const out = [];
|
|
44
|
+
let shift = 0;
|
|
45
|
+
let value = 0;
|
|
46
|
+
for (let i = 0; i < str.length; i++) {
|
|
47
|
+
const digit = B64_VLQ.indexOf(str[i]);
|
|
48
|
+
if (digit === -1)
|
|
49
|
+
continue;
|
|
50
|
+
const cont = (digit & 32) !== 0;
|
|
51
|
+
value += (digit & 31) << shift;
|
|
52
|
+
if (cont) {
|
|
53
|
+
shift += 5;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const neg = (value & 1) === 1;
|
|
57
|
+
value >>= 1;
|
|
58
|
+
out.push(neg ? -value : value);
|
|
59
|
+
value = 0;
|
|
60
|
+
shift = 0;
|
|
61
|
+
}
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/** Decodes a v3 `mappings` string into per-generated-line segments. */
|
|
65
|
+
export function decodeMappings(mappings) {
|
|
66
|
+
const lines = [];
|
|
67
|
+
let src = 0;
|
|
68
|
+
let srcLine = 0;
|
|
69
|
+
let srcCol = 0;
|
|
70
|
+
for (const line of mappings.split(';')) {
|
|
71
|
+
const segs = [];
|
|
72
|
+
let genCol = 0;
|
|
73
|
+
if (line) {
|
|
74
|
+
for (const part of line.split(',')) {
|
|
75
|
+
if (!part)
|
|
76
|
+
continue;
|
|
77
|
+
const nums = decodeVLQ(part);
|
|
78
|
+
genCol += nums[0] || 0;
|
|
79
|
+
if (nums.length >= 4) {
|
|
80
|
+
src += nums[1];
|
|
81
|
+
srcLine += nums[2];
|
|
82
|
+
srcCol += nums[3];
|
|
83
|
+
segs.push({ genCol, src, srcLine, srcCol });
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
lines.push(segs);
|
|
88
|
+
}
|
|
89
|
+
return lines;
|
|
90
|
+
}
|
|
91
|
+
const mapCache = new Map();
|
|
92
|
+
async function loadSourceMap(url) {
|
|
93
|
+
const cached = mapCache.get(url);
|
|
94
|
+
if (cached)
|
|
95
|
+
return cached;
|
|
96
|
+
const p = (async () => {
|
|
97
|
+
try {
|
|
98
|
+
if (/^[a-z]+:\/\//i.test(url) && !url.startsWith(location.origin))
|
|
99
|
+
return null;
|
|
100
|
+
const res = await fetch(url + '.map');
|
|
101
|
+
if (!res.ok)
|
|
102
|
+
return null;
|
|
103
|
+
const json = await res.json();
|
|
104
|
+
if (!json || typeof json.mappings !== 'string')
|
|
105
|
+
return null;
|
|
106
|
+
return { sources: json.sources || [], lines: decodeMappings(json.mappings) };
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
})();
|
|
112
|
+
mapCache.set(url, p);
|
|
113
|
+
return p;
|
|
114
|
+
}
|
|
115
|
+
/** Parses a V8/Firefox stack line into its script location, if present. */
|
|
116
|
+
export function parseStackFrame(line) {
|
|
117
|
+
const patterns = [
|
|
118
|
+
/^(.*?)((?:https?:)?\/\/[^\s)]+|\/[^\s):]+):(\d+):(\d+)(.*)$/,
|
|
119
|
+
];
|
|
120
|
+
for (const re of patterns) {
|
|
121
|
+
const m = re.exec(line);
|
|
122
|
+
if (!m)
|
|
123
|
+
continue;
|
|
124
|
+
return { prefix: m[1], url: m[2], line: Number(m[3]), col: Number(m[4]), suffix: m[5] };
|
|
125
|
+
}
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
function remapLocation(map, line, col) {
|
|
129
|
+
const segs = map.lines[line - 1];
|
|
130
|
+
if (!segs || segs.length === 0)
|
|
131
|
+
return null;
|
|
132
|
+
let best = null;
|
|
133
|
+
for (const s of segs) {
|
|
134
|
+
if (s.genCol <= col - 1)
|
|
135
|
+
best = s;
|
|
136
|
+
else
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
if (!best)
|
|
140
|
+
best = segs[0];
|
|
141
|
+
const source = map.sources[best.src] || '';
|
|
142
|
+
return { source, line: best.srcLine + 1, col: best.srcCol + 1 };
|
|
143
|
+
}
|
|
144
|
+
/** Rewrites each mappable frame of a stack trace to its original location. */
|
|
145
|
+
export async function symbolicateStack(stack) {
|
|
146
|
+
if (!stack || stack.indexOf('.js') === -1)
|
|
147
|
+
return stack;
|
|
148
|
+
const lines = stack.split('\n');
|
|
149
|
+
const out = await Promise.all(lines.map(async (line) => {
|
|
150
|
+
const frame = parseStackFrame(line);
|
|
151
|
+
if (!frame)
|
|
152
|
+
return line;
|
|
153
|
+
const map = await loadSourceMap(frame.url);
|
|
154
|
+
if (!map)
|
|
155
|
+
return line;
|
|
156
|
+
const loc = remapLocation(map, frame.line, frame.col);
|
|
157
|
+
if (!loc)
|
|
158
|
+
return line;
|
|
159
|
+
return frame.prefix + loc.source + ':' + loc.line + ':' + loc.col + frame.suffix;
|
|
160
|
+
}));
|
|
161
|
+
return out.join('\n');
|
|
162
|
+
}
|
|
40
163
|
/**
|
|
41
164
|
* Route matcher: a segment starting with `[` matches anything; `[...x]` matches
|
|
42
165
|
* the rest. Exported (pure) for testing.
|
|
@@ -67,7 +190,7 @@ const STYLE = `
|
|
|
67
190
|
:host { all: initial; }
|
|
68
191
|
* { box-sizing: border-box; }
|
|
69
192
|
|
|
70
|
-
/*
|
|
193
|
+
/* palette */
|
|
71
194
|
:host {
|
|
72
195
|
--red: #f87171;
|
|
73
196
|
--green: #34d399;
|
|
@@ -78,7 +201,7 @@ const STYLE = `
|
|
|
78
201
|
--muted: #9ca3af;
|
|
79
202
|
}
|
|
80
203
|
|
|
81
|
-
/*
|
|
204
|
+
/* toolbar */
|
|
82
205
|
.toolbar {
|
|
83
206
|
position: fixed; left: 50%; bottom: 0; z-index: 2147483001;
|
|
84
207
|
transform: translate(-50%, 54%);
|
|
@@ -119,7 +242,7 @@ const STYLE = `
|
|
|
119
242
|
max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
120
243
|
}
|
|
121
244
|
|
|
122
|
-
/*
|
|
245
|
+
/* overlay */
|
|
123
246
|
.overlay {
|
|
124
247
|
position: fixed; inset: 0; z-index: 2147483000;
|
|
125
248
|
background: rgba(9, 9, 11, 0.72); backdrop-filter: blur(6px);
|
|
@@ -315,8 +438,10 @@ class KrateDev {
|
|
|
315
438
|
sse.addEventListener('client-error', (e) => {
|
|
316
439
|
try {
|
|
317
440
|
const d = JSON.parse(e.data);
|
|
318
|
-
if (d.clientError)
|
|
319
|
-
|
|
441
|
+
if (!d.clientError)
|
|
442
|
+
return;
|
|
443
|
+
const err = d.clientError;
|
|
444
|
+
this.addRuntime('Runtime Error', err.message, err.stack);
|
|
320
445
|
}
|
|
321
446
|
catch {
|
|
322
447
|
/* ignore */
|
|
@@ -326,15 +451,16 @@ class KrateDev {
|
|
|
326
451
|
captureRuntimeErrors() {
|
|
327
452
|
window.addEventListener('error', (e) => {
|
|
328
453
|
const stack = e.error?.stack || '';
|
|
454
|
+
const message = e.message || 'Unknown error';
|
|
329
455
|
this.report({
|
|
330
|
-
message
|
|
456
|
+
message,
|
|
331
457
|
stack,
|
|
332
458
|
url: e.filename,
|
|
333
459
|
line: e.lineno,
|
|
334
460
|
col: e.colno,
|
|
335
461
|
kind: 'error',
|
|
336
462
|
});
|
|
337
|
-
this.addRuntime('Runtime Error',
|
|
463
|
+
this.addRuntime('Runtime Error', message, stack);
|
|
338
464
|
});
|
|
339
465
|
window.addEventListener('unhandledrejection', (e) => {
|
|
340
466
|
const reason = e.reason;
|
|
@@ -363,9 +489,20 @@ class KrateDev {
|
|
|
363
489
|
}
|
|
364
490
|
}
|
|
365
491
|
addRuntime(title, message, stack) {
|
|
366
|
-
|
|
492
|
+
const entry = { title, message, stack };
|
|
493
|
+
this.runtimeErrors.push(entry);
|
|
367
494
|
this.setStatus(false);
|
|
368
495
|
this.render();
|
|
496
|
+
// Render immediately with the raw stack, then upgrade in place if a source
|
|
497
|
+
// map lets us point at the original location.
|
|
498
|
+
if (stack) {
|
|
499
|
+
void symbolicateStack(stack).then((mapped) => {
|
|
500
|
+
if (mapped && mapped !== stack) {
|
|
501
|
+
entry.stack = mapped;
|
|
502
|
+
this.render();
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
369
506
|
}
|
|
370
507
|
setStatus(ok) {
|
|
371
508
|
if (!this.toolbar)
|
package/dist/dev-overlay.test.js
CHANGED
|
@@ -15,7 +15,7 @@ class FakeEventSource {
|
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
FakeEventSource.last = null;
|
|
18
|
-
let
|
|
18
|
+
let overlay;
|
|
19
19
|
// File-level setup: globals must exist BEFORE the overlay module auto-inits on
|
|
20
20
|
// import, and the export is captured from the same module instance.
|
|
21
21
|
beforeAll(async () => {
|
|
@@ -27,8 +27,7 @@ beforeAll(async () => {
|
|
|
27
27
|
overlay: true,
|
|
28
28
|
toolbar: true,
|
|
29
29
|
};
|
|
30
|
-
|
|
31
|
-
routeMatches = mod.routeMatches;
|
|
30
|
+
overlay = await import('./dev-overlay');
|
|
32
31
|
});
|
|
33
32
|
function devRoot() {
|
|
34
33
|
const host = document.getElementById('krate-dev-root');
|
|
@@ -86,14 +85,46 @@ describe('dev-overlay', () => {
|
|
|
86
85
|
});
|
|
87
86
|
describe('routeMatches', () => {
|
|
88
87
|
it('matches unprefixed patterns against a base-path URL', () => {
|
|
89
|
-
expect(routeMatches('/about', '/docs/about', '/docs')).toBe(true);
|
|
90
|
-
expect(routeMatches('/about', '/docs/other', '/docs')).toBe(false);
|
|
91
|
-
expect(routeMatches('/', '/docs/', '/docs')).toBe(true);
|
|
88
|
+
expect(overlay.routeMatches('/about', '/docs/about', '/docs')).toBe(true);
|
|
89
|
+
expect(overlay.routeMatches('/about', '/docs/other', '/docs')).toBe(false);
|
|
90
|
+
expect(overlay.routeMatches('/', '/docs/', '/docs')).toBe(true);
|
|
92
91
|
});
|
|
93
92
|
it('matches root deployment and dynamic segments', () => {
|
|
94
|
-
expect(routeMatches('/about', '/about', '')).toBe(true);
|
|
95
|
-
expect(routeMatches('/blog/[slug]', '/blog/hello', '')).toBe(true);
|
|
96
|
-
expect(routeMatches('/blog/[slug]', '/blog/hello/x', '')).toBe(false);
|
|
97
|
-
expect(routeMatches('/docs/[...rest]', '/docs/a/b/c', '')).toBe(true);
|
|
93
|
+
expect(overlay.routeMatches('/about', '/about', '')).toBe(true);
|
|
94
|
+
expect(overlay.routeMatches('/blog/[slug]', '/blog/hello', '')).toBe(true);
|
|
95
|
+
expect(overlay.routeMatches('/blog/[slug]', '/blog/hello/x', '')).toBe(false);
|
|
96
|
+
expect(overlay.routeMatches('/docs/[...rest]', '/docs/a/b/c', '')).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
describe('source-map symbolication', () => {
|
|
100
|
+
it('decodes Base64 VLQ deltas', () => {
|
|
101
|
+
expect(overlay.decodeVLQ('AAAA')).toEqual([0, 0, 0, 0]);
|
|
102
|
+
expect(overlay.decodeVLQ('CAAA')).toEqual([1, 0, 0, 0]);
|
|
103
|
+
});
|
|
104
|
+
it('decodes mappings with cumulative source line deltas', () => {
|
|
105
|
+
const lines = overlay.decodeMappings('AAAA;AACA');
|
|
106
|
+
expect(lines).toHaveLength(2);
|
|
107
|
+
expect(lines[0][0]).toMatchObject({ genCol: 0, src: 0, srcLine: 0, srcCol: 0 });
|
|
108
|
+
expect(lines[1][0]).toMatchObject({ genCol: 0, src: 0, srcLine: 1, srcCol: 0 });
|
|
109
|
+
});
|
|
110
|
+
it('parses V8 and path-only stack frames', () => {
|
|
111
|
+
const a = overlay.parseStackFrame(' at foo (http://localhost:3000/index.abc.js:12:34)');
|
|
112
|
+
expect(a).toMatchObject({ url: 'http://localhost:3000/index.abc.js', line: 12, col: 34 });
|
|
113
|
+
const b = overlay.parseStackFrame(' at bar (/index.abc.js:5:6)');
|
|
114
|
+
expect(b).toMatchObject({ url: '/index.abc.js', line: 5, col: 6 });
|
|
115
|
+
expect(overlay.parseStackFrame('plain message')).toBeNull();
|
|
116
|
+
});
|
|
117
|
+
it('remaps a frame using a fetched map', async () => {
|
|
118
|
+
globalThis.fetch = async () => ({
|
|
119
|
+
ok: true,
|
|
120
|
+
json: async () => ({ version: 3, sources: ['src/foo.ts'], mappings: 'AAAA;AACA' }),
|
|
121
|
+
});
|
|
122
|
+
const out = await overlay.symbolicateStack('Error: x\n at foo (http://localhost:3000/index.abc.js:2:1)');
|
|
123
|
+
expect(out).toContain('src/foo.ts:2:1');
|
|
124
|
+
});
|
|
125
|
+
it('leaves the stack unchanged when no map is available', async () => {
|
|
126
|
+
globalThis.fetch = async () => ({ ok: false, json: async () => ({}) });
|
|
127
|
+
const stack = ' at foo (http://localhost:3000/missing.js:1:1)';
|
|
128
|
+
expect(await overlay.symbolicateStack(stack)).toBe(stack);
|
|
98
129
|
});
|
|
99
130
|
});
|
package/dist/dom.js
CHANGED
|
@@ -7,7 +7,7 @@ const EVENT_ALIASES = {
|
|
|
7
7
|
blur: 'focusout',
|
|
8
8
|
change: 'input',
|
|
9
9
|
};
|
|
10
|
-
//
|
|
10
|
+
// per-node effect tracking
|
|
11
11
|
// Reactive props/children create effects that must be disposed when the node is
|
|
12
12
|
// removed from the DOM (list items, conditional branches, SPA reconciliation).
|
|
13
13
|
// Without this, effects and their closures accumulate for the page's lifetime.
|
|
@@ -32,7 +32,7 @@ export function disposeNode(node) {
|
|
|
32
32
|
disposeNode(node.childNodes[i]);
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
//
|
|
35
|
+
// comment-marker DOM traversal
|
|
36
36
|
/**
|
|
37
37
|
* Find the matching end comment marker for a start marker.
|
|
38
38
|
* Searches forward among SIBLINGS ONLY (same parent/depth) for the next
|
|
@@ -82,7 +82,7 @@ export function insert(parent, value, startMarker) {
|
|
|
82
82
|
insertBefore(parent, value, endMarker);
|
|
83
83
|
}
|
|
84
84
|
else {
|
|
85
|
-
// No end marker found
|
|
85
|
+
// No end marker found - append at end
|
|
86
86
|
insertBefore(parent, value, null);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
@@ -214,11 +214,11 @@ export function mount(fn, container) {
|
|
|
214
214
|
export function hydrate(fn, container) {
|
|
215
215
|
const el = getContainer(container);
|
|
216
216
|
if (el.childNodes.length === 0) {
|
|
217
|
-
// Empty container
|
|
217
|
+
// Empty container - fall back to mount behavior
|
|
218
218
|
el.appendChild(fn());
|
|
219
219
|
return;
|
|
220
220
|
}
|
|
221
|
-
// SSR content exists
|
|
221
|
+
// SSR content exists - run the component to set up effects/signals.
|
|
222
222
|
// The freshly-built tree is only used to establish reactive subscriptions;
|
|
223
223
|
// it is not attached to the DOM, so dispose its effects to avoid leaks.
|
|
224
224
|
const tree = fn();
|
package/dist/error-overlay.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dev Error Overlay
|
|
2
|
+
* Dev Error Overlay - shows a styled error overlay in development mode.
|
|
3
3
|
* Catches unhandled errors and unhandled promise rejections,
|
|
4
4
|
* displays them in a dismissable overlay with file/line info.
|
|
5
5
|
*/
|
package/dist/error-overlay.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dev Error Overlay
|
|
2
|
+
* Dev Error Overlay - shows a styled error overlay in development mode.
|
|
3
3
|
* Catches unhandled errors and unhandled promise rejections,
|
|
4
4
|
* displays them in a dismissable overlay with file/line info.
|
|
5
5
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createSignal, createReducer, createCSSChoice, createCSSToggle, createCSSFlags, createCSSGroup, createCSSRange, createCSSStack, createEffect, createMemo, onCleanup, onMount, forwardRef, useRef, disposeAll } from './signal.js';
|
|
2
|
-
export type { CSSARIAOptions, CSSVars, CSSPrimitiveOptions, CSSStackActions, SignalOptions } from './signal.js';
|
|
2
|
+
export type { CSSARIAOptions, CSSVars, CSSPrimitiveOptions, CSSStackActions, CSSScope, CSSFlagsScope, SignalOptions } from './signal.js';
|
|
3
3
|
export { clearPersisted, readPersisted, writePersisted } from './storage.js';
|
|
4
4
|
export type { PersistOptions, PersistSpec, PersistStore, StorageLike } from './storage.js';
|
|
5
5
|
export { h, mount, hydrate, insert, clearNodes, disposeNode } from './dom.js';
|
|
@@ -8,7 +8,7 @@ export { initRouter, reinitRouter, navigate } from './router.js';
|
|
|
8
8
|
export type { NavigateOptions } from './router.js';
|
|
9
9
|
export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
|
|
10
10
|
export type { ClassValue, CVAConfig } from './class-helpers.js';
|
|
11
|
-
export { createContext, resetContexts } from './context.js';
|
|
11
|
+
export { createContext, createScope, createScopeFlags, resetContexts } from './context.js';
|
|
12
12
|
export { createResource } from './resource.js';
|
|
13
13
|
export type { Context } from './context.js';
|
|
14
14
|
export type { ResourceReturn, ResourceActions } from './resource.js';
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ export { h, mount, hydrate, insert, clearNodes, disposeNode } from './dom.js';
|
|
|
4
4
|
export { Fragment, jsx, jsxs } from './jsx-runtime.js';
|
|
5
5
|
export { initRouter, reinitRouter, navigate } from './router.js';
|
|
6
6
|
export { clsx, cn, cva, twMerge, Slot, cloneElement } from './class-helpers.js';
|
|
7
|
-
export { createContext, resetContexts } from './context.js';
|
|
7
|
+
export { createContext, createScope, createScopeFlags, resetContexts } from './context.js';
|
|
8
8
|
export { createResource } from './resource.js';
|
|
9
9
|
import './jsx-types.js';
|
|
10
10
|
import './css-modules.js';
|