@oddsquad/vite-plugin-lit 0.2.2 → 0.3.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/CHANGELOG.md +64 -0
- package/LICENSE +28 -0
- package/README.md +153 -0
- package/bin.mjs +154 -0
- package/client.d.ts +61 -0
- package/dist/client/assets/browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js +69 -0
- package/dist/client/assets/browser-agent-rpc-BXhoSh1z-BvWe4sTJ.js.map +1 -0
- package/dist/client/assets/index-CFrVgNfS.js +9740 -0
- package/dist/client/assets/index-CFrVgNfS.js.map +1 -0
- package/{panel → dist/client}/index.html +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +2 -2
- package/index.js.map +1 -1
- package/lib/color-scheme.d.ts.map +1 -1
- package/lib/color-scheme.js +17 -21
- package/lib/color-scheme.js.map +1 -1
- package/lib/devframe/definition.d.ts +45 -0
- package/lib/devframe/definition.d.ts.map +1 -0
- package/lib/devframe/definition.js +547 -0
- package/lib/devframe/definition.js.map +1 -0
- package/lib/devframe/icon.d.ts +8 -0
- package/lib/devframe/icon.d.ts.map +1 -0
- package/lib/devframe/icon.js +21 -0
- package/lib/devframe/icon.js.map +1 -0
- package/lib/devframe/paths.d.ts +12 -0
- package/lib/devframe/paths.d.ts.map +1 -0
- package/lib/devframe/paths.js +38 -0
- package/lib/devframe/paths.js.map +1 -0
- package/lib/devframe/protocol.d.ts +218 -0
- package/lib/devframe/protocol.d.ts.map +1 -0
- package/lib/devframe/protocol.js +76 -0
- package/lib/devframe/protocol.js.map +1 -0
- package/lib/devframe/source.d.ts +49 -0
- package/lib/devframe/source.d.ts.map +1 -0
- package/lib/devframe/source.js +23 -0
- package/lib/devframe/source.js.map +1 -0
- package/lib/devframe/vite.d.ts +116 -0
- package/lib/devframe/vite.d.ts.map +1 -0
- package/lib/devframe/vite.js +291 -0
- package/lib/devframe/vite.js.map +1 -0
- package/lib/http.d.ts +29 -0
- package/lib/http.d.ts.map +1 -0
- package/lib/http.js +35 -0
- package/lib/http.js.map +1 -0
- package/lib/icons.d.ts +2 -0
- package/lib/icons.d.ts.map +1 -1
- package/lib/icons.js +10 -4
- package/lib/icons.js.map +1 -1
- package/lib/plugin.d.ts +15 -4
- package/lib/plugin.d.ts.map +1 -1
- package/lib/plugin.js +640 -574
- package/lib/plugin.js.map +1 -1
- package/lib/runtime/css.d.ts +2 -16
- package/lib/runtime/css.d.ts.map +1 -1
- package/lib/runtime/css.js +43 -36
- package/lib/runtime/css.js.map +1 -1
- package/lib/runtime/edge-panel.d.ts.map +1 -1
- package/lib/runtime/edge-panel.js +82 -91
- package/lib/runtime/edge-panel.js.map +1 -1
- package/lib/runtime/fonts.d.ts.map +1 -1
- package/lib/runtime/fonts.js +1 -1
- package/lib/runtime/fonts.js.map +1 -1
- package/lib/runtime/indicator.d.ts.map +1 -1
- package/lib/runtime/indicator.js +71 -74
- package/lib/runtime/indicator.js.map +1 -1
- package/lib/runtime/inspector/collect.d.ts.map +1 -1
- package/lib/runtime/inspector/collect.js +83 -90
- package/lib/runtime/inspector/collect.js.map +1 -1
- package/lib/runtime/inspector/highlight.d.ts +16 -0
- package/lib/runtime/inspector/highlight.d.ts.map +1 -0
- package/lib/runtime/inspector/highlight.js +66 -0
- package/lib/runtime/inspector/highlight.js.map +1 -0
- package/lib/runtime/inspector/install.d.ts.map +1 -1
- package/lib/runtime/inspector/install.js +180 -205
- package/lib/runtime/inspector/install.js.map +1 -1
- package/lib/runtime/inspector/serialize.d.ts.map +1 -1
- package/lib/runtime/inspector/serialize.js +86 -107
- package/lib/runtime/inspector/serialize.js.map +1 -1
- package/lib/runtime/intern.d.ts.map +1 -1
- package/lib/runtime/intern.js +31 -29
- package/lib/runtime/intern.js.map +1 -1
- package/lib/runtime/overrides.d.ts.map +1 -1
- package/lib/runtime/overrides.js +14 -13
- package/lib/runtime/overrides.js.map +1 -1
- package/lib/runtime/patch.d.ts +8 -0
- package/lib/runtime/patch.d.ts.map +1 -1
- package/lib/runtime/patch.js +321 -282
- package/lib/runtime/patch.js.map +1 -1
- package/lib/runtime/source-meta.d.ts.map +1 -1
- package/lib/runtime/source-meta.js +1 -1
- package/lib/runtime/source-meta.js.map +1 -1
- package/lib/runtime/source-overlay/editors.d.ts.map +1 -1
- package/lib/runtime/source-overlay/editors.js +27 -27
- package/lib/runtime/source-overlay/editors.js.map +1 -1
- package/lib/runtime/source-overlay/mask-path.d.ts.map +1 -1
- package/lib/runtime/source-overlay/mask-path.js +15 -15
- package/lib/runtime/source-overlay/mask-path.js.map +1 -1
- package/lib/runtime/source-overlay/overlay-element.d.ts.map +1 -1
- package/lib/runtime/source-overlay/overlay-element.js +347 -356
- package/lib/runtime/source-overlay/overlay-element.js.map +1 -1
- package/lib/runtime/source-overlay/source-host.d.ts.map +1 -1
- package/lib/runtime/source-overlay/source-host.js +64 -71
- package/lib/runtime/source-overlay/source-host.js.map +1 -1
- package/lib/runtime/source-overlay/template.d.ts.map +1 -1
- package/lib/runtime/source-overlay/template.js +3 -3
- package/lib/runtime/source-overlay/template.js.map +1 -1
- package/lib/runtime/source-overlay.d.ts.map +1 -1
- package/lib/runtime/source-overlay.js +5 -2
- package/lib/runtime/source-overlay.js.map +1 -1
- package/lib/runtime/timeline/clock.d.ts.map +1 -1
- package/lib/runtime/timeline/clock.js +2 -2
- package/lib/runtime/timeline/clock.js.map +1 -1
- package/lib/runtime/timeline/flash.d.ts +39 -0
- package/lib/runtime/timeline/flash.d.ts.map +1 -0
- package/lib/runtime/timeline/flash.js +169 -0
- package/lib/runtime/timeline/flash.js.map +1 -0
- package/lib/runtime/timeline/identity.d.ts.map +1 -1
- package/lib/runtime/timeline/identity.js +27 -27
- package/lib/runtime/timeline/identity.js.map +1 -1
- package/lib/runtime/timeline/input.d.ts.map +1 -1
- package/lib/runtime/timeline/input.js +54 -67
- package/lib/runtime/timeline/input.js.map +1 -1
- package/lib/runtime/timeline/install.d.ts.map +1 -1
- package/lib/runtime/timeline/install.js +38 -29
- package/lib/runtime/timeline/install.js.map +1 -1
- package/lib/runtime/timeline/lifecycle.d.ts +8 -0
- package/lib/runtime/timeline/lifecycle.d.ts.map +1 -1
- package/lib/runtime/timeline/lifecycle.js +149 -133
- package/lib/runtime/timeline/lifecycle.js.map +1 -1
- package/lib/runtime/timeline/public-api.d.ts.map +1 -1
- package/lib/runtime/timeline/public-api.js +9 -9
- package/lib/runtime/timeline/public-api.js.map +1 -1
- package/lib/runtime/timeline/render.d.ts.map +1 -1
- package/lib/runtime/timeline/render.js +70 -75
- package/lib/runtime/timeline/render.js.map +1 -1
- package/lib/runtime/timeline/transport.d.ts.map +1 -1
- package/lib/runtime/timeline/transport.js +39 -43
- package/lib/runtime/timeline/transport.js.map +1 -1
- package/lib/segmented-tabs.d.ts +3 -1
- package/lib/segmented-tabs.d.ts.map +1 -1
- package/lib/segmented-tabs.js +136 -107
- package/lib/segmented-tabs.js.map +1 -1
- package/lib/snapshot.d.ts +28 -0
- package/lib/snapshot.d.ts.map +1 -0
- package/lib/snapshot.js +57 -0
- package/lib/snapshot.js.map +1 -0
- package/lib/source-meta.d.ts.map +1 -1
- package/lib/source-meta.js +176 -162
- package/lib/source-meta.js.map +1 -1
- package/lib/timeline/derive.d.ts +152 -0
- package/lib/timeline/derive.d.ts.map +1 -0
- package/lib/timeline/derive.js +242 -0
- package/lib/timeline/derive.js.map +1 -0
- package/lib/timeline-plugin.d.ts.map +1 -1
- package/lib/timeline-plugin.js +304 -321
- package/lib/timeline-plugin.js.map +1 -1
- package/lib/tokens.d.ts.map +1 -1
- package/lib/tokens.js +17 -18
- package/lib/tokens.js.map +1 -1
- package/lib/transform.d.ts.map +1 -1
- package/lib/transform.js +62 -57
- package/lib/transform.js.map +1 -1
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +1 -1
- package/lib/types.js.map +1 -1
- package/lib/wrap-table.d.ts.map +1 -1
- package/lib/wrap-table.js +19 -17
- package/lib/wrap-table.js.map +1 -1
- package/package.json +77 -13
- package/types/hmr-incompatibility.d.ts +59 -0
- package/types/hmr-incompatibility.d.ts.map +1 -0
- package/types/hmr-incompatibility.js +30 -0
- package/types/hmr-incompatibility.js.map +1 -0
- package/types/in-page.d.ts +49 -0
- package/types/in-page.d.ts.map +1 -0
- package/types/in-page.js +33 -0
- package/types/in-page.js.map +1 -0
- package/types/inspector.d.ts.map +1 -1
- package/types/inspector.js.map +1 -1
- package/types/snapshot.d.ts +44 -0
- package/types/snapshot.d.ts.map +1 -0
- package/types/snapshot.js +7 -0
- package/types/snapshot.js.map +1 -0
- package/types/timeline.d.ts +11 -0
- package/types/timeline.d.ts.map +1 -1
- package/types/timeline.js.map +1 -1
- package/panel/components-view.d.ts +0 -60
- package/panel/components-view.d.ts.map +0 -1
- package/panel/components-view.js +0 -587
- package/panel/components-view.js.map +0 -1
- package/panel/devtools-settings.d.ts +0 -41
- package/panel/devtools-settings.d.ts.map +0 -1
- package/panel/devtools-settings.js +0 -463
- package/panel/devtools-settings.js.map +0 -1
- package/panel/lit-devtools-panel.d.ts +0 -37
- package/panel/lit-devtools-panel.d.ts.map +0 -1
- package/panel/lit-devtools-panel.js +0 -185
- package/panel/lit-devtools-panel.js.map +0 -1
- package/panel/timeline-event-list.d.ts +0 -43
- package/panel/timeline-event-list.d.ts.map +0 -1
- package/panel/timeline-event-list.js +0 -416
- package/panel/timeline-event-list.js.map +0 -1
- package/panel/timeline-layers.d.ts +0 -25
- package/panel/timeline-layers.d.ts.map +0 -1
- package/panel/timeline-layers.js +0 -96
- package/panel/timeline-layers.js.map +0 -1
- package/panel/timeline-view.d.ts +0 -38
- package/panel/timeline-view.d.ts.map +0 -1
- package/panel/timeline-view.js +0 -234
- package/panel/timeline-view.js.map +0 -1
|
@@ -14,120 +14,99 @@ const MAX_ITEMS = 8;
|
|
|
14
14
|
const MAX_STRING = 120;
|
|
15
15
|
/** A short type label for the details table's "type" column. */
|
|
16
16
|
export const typeTag = (value) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return `Map(${value.size})`;
|
|
28
|
-
if (value instanceof Set)
|
|
29
|
-
return `Set(${value.size})`;
|
|
30
|
-
if (value instanceof Node)
|
|
31
|
-
return 'Node';
|
|
32
|
-
const name = value.constructor?.name;
|
|
33
|
-
return name !== undefined && name !== 'Object' ? name : 'object';
|
|
17
|
+
if (value === null) return 'null';
|
|
18
|
+
if (Array.isArray(value)) return `Array(${value.length})`;
|
|
19
|
+
const t = typeof value;
|
|
20
|
+
if (t !== 'object' && t !== 'function') return t;
|
|
21
|
+
if (t === 'function') return 'function';
|
|
22
|
+
if (value instanceof Map) return `Map(${value.size})`;
|
|
23
|
+
if (value instanceof Set) return `Set(${value.size})`;
|
|
24
|
+
if (value instanceof Node) return 'Node';
|
|
25
|
+
const name = value.constructor?.name;
|
|
26
|
+
return name !== undefined && name !== 'Object' ? name : 'object';
|
|
34
27
|
};
|
|
35
|
-
const truncate = (s) =>
|
|
28
|
+
const truncate = (s) =>
|
|
29
|
+
s.length > MAX_STRING ? s.slice(0, MAX_STRING) + '…' : s;
|
|
36
30
|
const previewNode = (node) => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
31
|
+
if (node instanceof Element) {
|
|
32
|
+
const id = node.id ? `#${node.id}` : '';
|
|
33
|
+
return `<${node.tagName.toLowerCase()}${id}>`;
|
|
34
|
+
}
|
|
35
|
+
return `#${node.nodeName.toLowerCase()}`;
|
|
42
36
|
};
|
|
43
37
|
const serializeAt = (value, depth, seen) => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
items.push(`…+${arr.length - MAX_ITEMS}`);
|
|
88
|
-
return `${obj.constructor?.name ?? 'TypedArray'}(${arr.length}) [${items.join(', ')}]`;
|
|
38
|
+
if (value === null) return 'null';
|
|
39
|
+
if (value === undefined) return 'undefined';
|
|
40
|
+
// Narrow on `value` rather than a saved `typeof`: the compiler cannot carry
|
|
41
|
+
// a discriminant through a separate variable.
|
|
42
|
+
if (typeof value === 'string') return JSON.stringify(truncate(value));
|
|
43
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
44
|
+
return String(value);
|
|
45
|
+
}
|
|
46
|
+
if (typeof value === 'bigint') return `${value}n`;
|
|
47
|
+
if (typeof value === 'symbol') return value.toString();
|
|
48
|
+
if (typeof value === 'function') {
|
|
49
|
+
const name = value.name;
|
|
50
|
+
return name ? `ƒ ${name}()` : 'ƒ ()';
|
|
51
|
+
}
|
|
52
|
+
const obj = value;
|
|
53
|
+
if (seen.has(obj)) return '[Circular]';
|
|
54
|
+
if (value instanceof Node) return previewNode(value);
|
|
55
|
+
if (value instanceof Date) return value.toISOString();
|
|
56
|
+
if (value instanceof RegExp) return String(value);
|
|
57
|
+
if (value instanceof Map) return `Map(${value.size})`;
|
|
58
|
+
if (value instanceof Set) return `Set(${value.size})`;
|
|
59
|
+
if (depth >= MAX_DEPTH) {
|
|
60
|
+
return Array.isArray(value) ? `Array(${value.length})` : typeTag(value);
|
|
61
|
+
}
|
|
62
|
+
// Typed arrays are indexable but not `Array.isArray`; routing them through
|
|
63
|
+
// the generic object branch would make `Object.keys` materialize every index
|
|
64
|
+
// (e.g. a million-element Uint8Array) before slicing. Handle them as arrays.
|
|
65
|
+
if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {
|
|
66
|
+
const arr = value;
|
|
67
|
+
const shown = Math.min(arr.length, MAX_ITEMS);
|
|
68
|
+
const items = [];
|
|
69
|
+
for (let i = 0; i < shown; i++) items.push(String(arr[i]));
|
|
70
|
+
if (arr.length > MAX_ITEMS) items.push(`…+${arr.length - MAX_ITEMS}`);
|
|
71
|
+
return `${obj.constructor?.name ?? 'TypedArray'}(${arr.length}) [${items.join(', ')}]`;
|
|
72
|
+
}
|
|
73
|
+
seen.add(obj);
|
|
74
|
+
try {
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
const items = value
|
|
77
|
+
.slice(0, MAX_ITEMS)
|
|
78
|
+
.map((v) => serializeAt(v, depth + 1, seen));
|
|
79
|
+
if (value.length > MAX_ITEMS) items.push(`…+${value.length - MAX_ITEMS}`);
|
|
80
|
+
return `[${items.join(', ')}]`;
|
|
89
81
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
let v;
|
|
105
|
-
try {
|
|
106
|
-
v = value[k];
|
|
107
|
-
}
|
|
108
|
-
catch {
|
|
109
|
-
return `${k}: [getter threw]`;
|
|
110
|
-
}
|
|
111
|
-
return `${k}: ${serializeAt(v, depth + 1, seen)}`;
|
|
112
|
-
});
|
|
113
|
-
if (keys.length > MAX_ITEMS) {
|
|
114
|
-
parts.push(`…+${keys.length - MAX_ITEMS}`);
|
|
115
|
-
}
|
|
116
|
-
const name = obj.constructor?.name;
|
|
117
|
-
const prefix = name !== undefined && name !== 'Object' ? `${name} ` : '';
|
|
118
|
-
return `${prefix}{${parts.join(', ')}}`;
|
|
119
|
-
}
|
|
120
|
-
finally {
|
|
121
|
-
seen.delete(obj);
|
|
82
|
+
// Read each property individually (keys, not entries) so a single throwing
|
|
83
|
+
// getter degrades to a placeholder instead of aborting the whole preview.
|
|
84
|
+
const keys = Object.keys(value);
|
|
85
|
+
const parts = keys.slice(0, MAX_ITEMS).map((k) => {
|
|
86
|
+
let v;
|
|
87
|
+
try {
|
|
88
|
+
v = value[k];
|
|
89
|
+
} catch {
|
|
90
|
+
return `${k}: [getter threw]`;
|
|
91
|
+
}
|
|
92
|
+
return `${k}: ${serializeAt(v, depth + 1, seen)}`;
|
|
93
|
+
});
|
|
94
|
+
if (keys.length > MAX_ITEMS) {
|
|
95
|
+
parts.push(`…+${keys.length - MAX_ITEMS}`);
|
|
122
96
|
}
|
|
97
|
+
const name = obj.constructor?.name;
|
|
98
|
+
const prefix = name !== undefined && name !== 'Object' ? `${name} ` : '';
|
|
99
|
+
return `${prefix}{${parts.join(', ')}}`;
|
|
100
|
+
} finally {
|
|
101
|
+
seen.delete(obj);
|
|
102
|
+
}
|
|
123
103
|
};
|
|
124
104
|
/** Produce a readable one-line preview of `value`. Never throws. */
|
|
125
105
|
export const serialize = (value) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
}
|
|
106
|
+
try {
|
|
107
|
+
return serializeAt(value, 0, new WeakSet());
|
|
108
|
+
} catch {
|
|
109
|
+
return '[unserializable]';
|
|
110
|
+
}
|
|
132
111
|
};
|
|
133
|
-
//# sourceMappingURL=serialize.js.map
|
|
112
|
+
//# sourceMappingURL=serialize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"serialize.js","sourceRoot":"","sources":["../../../src/lib/runtime/inspector/serialize.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GA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;QACD,MAAM,IAAI,GAAG,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC;QACnC,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,OAAO,GAAG,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAC1C,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;AACH,CAAC,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAc,EAAU,EAAE;IAClD,IAAI,CAAC;QACH,OAAO,WAAW,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,OAAO,EAAE,CAAC,CAAC;IAC9C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,kBAAkB,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Compact, depth- and breadth-limited previews of arbitrary property values\n * for the inspector details pane. Values cross the transport as plain strings,\n * so this never needs to round-trip — it only has to be readable and safe\n * (circular refs, DOM nodes, functions, huge collections all handled).\n */\n\nconst MAX_DEPTH = 2;\nconst MAX_ITEMS = 8;\nconst MAX_STRING = 120;\n\n/** A short type label for the details table's \"type\" column. */\nexport const typeTag = (value: unknown): string => {\n if (value === null) return 'null';\n if (Array.isArray(value)) return `Array(${value.length})`;\n const t = typeof value;\n if (t !== 'object' && t !== 'function') return t;\n if (t === 'function') return 'function';\n if (value instanceof Map) return `Map(${value.size})`;\n if (value instanceof Set) return `Set(${value.size})`;\n if (value instanceof Node) return 'Node';\n const name = (value as object).constructor?.name;\n return name !== undefined && name !== 'Object' ? name : 'object';\n};\n\nconst truncate = (s: string): string =>\n s.length > MAX_STRING ? s.slice(0, MAX_STRING) + '…' : s;\n\nconst previewNode = (node: Node): string => {\n if (node instanceof Element) {\n const id = node.id ? `#${node.id}` : '';\n return `<${node.tagName.toLowerCase()}${id}>`;\n }\n return `#${node.nodeName.toLowerCase()}`;\n};\n\nconst serializeAt = (\n value: unknown,\n depth: number,\n seen: WeakSet<object>\n): string => {\n if (value === null) return 'null';\n if (value === undefined) return 'undefined';\n\n // Narrow on `value` rather than a saved `typeof`: the compiler cannot carry\n // a discriminant through a separate variable.\n if (typeof value === 'string') return JSON.stringify(truncate(value));\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (typeof value === 'bigint') return `${value}n`;\n if (typeof value === 'symbol') return value.toString();\n if (typeof value === 'function') {\n const name = (value as {name?: string}).name;\n return name ? `ƒ ${name}()` : 'ƒ ()';\n }\n\n const obj = value as object;\n if (seen.has(obj)) return '[Circular]';\n\n if (value instanceof Node) return previewNode(value);\n if (value instanceof Date) return value.toISOString();\n if (value instanceof RegExp) return String(value);\n if (value instanceof Map) return `Map(${value.size})`;\n if (value instanceof Set) return `Set(${value.size})`;\n\n if (depth >= MAX_DEPTH) {\n return Array.isArray(value) ? `Array(${value.length})` : typeTag(value);\n }\n\n // Typed arrays are indexable but not `Array.isArray`; routing them through\n // the generic object branch would make `Object.keys` materialize every index\n // (e.g. a million-element Uint8Array) before slicing. Handle them as arrays.\n if (ArrayBuffer.isView(value) && !(value instanceof DataView)) {\n const arr = value as unknown as {length: number; [i: number]: number};\n const shown = Math.min(arr.length, MAX_ITEMS);\n const items: string[] = [];\n for (let i = 0; i < shown; i++) items.push(String(arr[i]));\n if (arr.length > MAX_ITEMS) items.push(`…+${arr.length - MAX_ITEMS}`);\n return `${obj.constructor?.name ?? 'TypedArray'}(${arr.length}) [${items.join(', ')}]`;\n }\n\n seen.add(obj);\n try {\n if (Array.isArray(value)) {\n const items = value\n .slice(0, MAX_ITEMS)\n .map((v) => serializeAt(v, depth + 1, seen));\n if (value.length > MAX_ITEMS) items.push(`…+${value.length - MAX_ITEMS}`);\n return `[${items.join(', ')}]`;\n }\n // Read each property individually (keys, not entries) so a single throwing\n // getter degrades to a placeholder instead of aborting the whole preview.\n const keys = Object.keys(value as Record<string, unknown>);\n const parts = keys.slice(0, MAX_ITEMS).map((k) => {\n let v: unknown;\n try {\n v = (value as Record<string, unknown>)[k];\n } catch {\n return `${k}: [getter threw]`;\n }\n return `${k}: ${serializeAt(v, depth + 1, seen)}`;\n });\n if (keys.length > MAX_ITEMS) {\n parts.push(`…+${keys.length - MAX_ITEMS}`);\n }\n const name = obj.constructor?.name;\n const prefix = name !== undefined && name !== 'Object' ? `${name} ` : '';\n return `${prefix}{${parts.join(', ')}}`;\n } finally {\n seen.delete(obj);\n }\n};\n\n/** Produce a readable one-line preview of `value`. Never throws. */\nexport const serialize = (value: unknown): string => {\n try {\n return serializeAt(value, 0, new WeakSet());\n } catch {\n return '[unserializable]';\n }\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intern.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"intern.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/intern.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAuDH;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,OACb,MAAM,WACD,oBAAoB,KAC5B,oBAoBF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAClB,CAAC,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,GAAG,MAAM,EAAE,KAAK,EAAE,KAAK,OAAO,OAEnE,CAAC,MACF,MAAM,KACT,CAE0C,CAAC"}
|
package/lib/runtime/intern.js
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
// (e.g. via both an optimized and a raw URL).
|
|
8
8
|
const STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#intern');
|
|
9
9
|
const getState = () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const g = globalThis;
|
|
11
|
+
return (g[STATE_KEY] ??= {
|
|
12
|
+
byContent: new Map(),
|
|
13
|
+
canonicalOf: new WeakMap(),
|
|
14
|
+
});
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
17
|
* Builds a collision-free content key for a strings array.
|
|
@@ -22,11 +22,11 @@ const getState = () => {
|
|
|
22
22
|
* canonical array, or one shared `Template` would parse SVG as HTML.
|
|
23
23
|
*/
|
|
24
24
|
const contentKey = (ns, raw) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
let key = ns + '\x00' + raw.length;
|
|
26
|
+
for (const chunk of raw) {
|
|
27
|
+
key += '\x01' + chunk.length + '\x01' + chunk;
|
|
28
|
+
}
|
|
29
|
+
return key;
|
|
30
30
|
};
|
|
31
31
|
/**
|
|
32
32
|
* Returns the canonical strings array for `strings` within namespace `ns`.
|
|
@@ -37,26 +37,28 @@ const contentKey = (ns, raw) => {
|
|
|
37
37
|
* can raise its own error.
|
|
38
38
|
*/
|
|
39
39
|
export const intern = (ns, strings) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return canonical;
|
|
40
|
+
if (!Array.isArray(strings) || !Array.isArray(strings.raw)) {
|
|
41
|
+
return strings;
|
|
42
|
+
}
|
|
43
|
+
const state = getState();
|
|
44
|
+
const fast = state.canonicalOf.get(strings);
|
|
45
|
+
if (fast !== undefined) {
|
|
46
|
+
return fast;
|
|
47
|
+
}
|
|
48
|
+
const key = contentKey(ns, strings.raw);
|
|
49
|
+
let canonical = state.byContent.get(key);
|
|
50
|
+
if (canonical === undefined) {
|
|
51
|
+
canonical = strings;
|
|
52
|
+
state.byContent.set(key, canonical);
|
|
53
|
+
}
|
|
54
|
+
state.canonicalOf.set(strings, canonical);
|
|
55
|
+
return canonical;
|
|
57
56
|
};
|
|
58
57
|
/**
|
|
59
58
|
* Wraps a template tag so its strings argument is interned in `ns`.
|
|
60
59
|
*/
|
|
61
|
-
export const wrapTag =
|
|
62
|
-
|
|
60
|
+
export const wrapTag =
|
|
61
|
+
(tag, ns) =>
|
|
62
|
+
(strings, ...values) =>
|
|
63
|
+
tag(intern(ns, strings), ...values);
|
|
64
|
+
//# sourceMappingURL=intern.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intern.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"intern.js","sourceRoot":"","sources":["../../src/lib/runtime/intern.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA2BH,yEAAyE;AACzE,8CAA8C;AAC9C,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AAEjE,MAAM,QAAQ,GAAG,GAAgB,EAAE;IACjC,MAAM,CAAC,GAAG,UAAgE,CAAC;IAC3E,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK;QACvB,SAAS,EAAE,IAAI,GAAG,EAAE;QACpB,WAAW,EAAE,IAAI,OAAO,EAAE;KAC3B,CAAC,CAAC;AACL,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,CAAC,EAAU,EAAE,GAAsB,EAAU,EAAE;IAChE,IAAI,GAAG,GAAG,EAAE,GAAG,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;IACnC,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;QACxB,GAAG,IAAI,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;IAChD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,EAAU,EACV,OAA6B,EACP,EAAE;IACxB,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC;QACvB,CAAC,KAAK,CAAC,OAAO,CAAE,OAA2B,CAAC,GAAG,CAAC,EAChD,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;IACzB,MAAM,IAAI,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,GAAG,GAAG,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,SAAS,GAAG,OAAO,CAAC;QACpB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACtC,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC1C,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAGrB,GAAM,EACN,EAAU,EACP,EAAE,CACL,CAAC,CAAC,OAA6B,EAAE,GAAG,MAAe,EAAE,EAAE,CACrD,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,EAAE,GAAG,MAAM,CAAC,CAAM,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Template-strings interning.\n *\n * lit-html keys its template cache by the object identity of the\n * `TemplateStringsArray`, so when Vite HMR re-executes a module, every\n * template literal produces a fresh array and lit rebuilds the entire DOM\n * subtree. Interning canonicalizes strings arrays by content: unchanged\n * templates keep their identity across re-execution, so only the edited\n * template rebuilds its part.\n *\n * This module is dependency-free and must stay safe to load in any\n * environment (it is injected into user modules in dev).\n */\n\ninterface InternState {\n /** Content key → the canonical (first-seen) strings array. */\n byContent: Map<string, TemplateStringsArray>;\n /**\n * Fast path: per-call-site arrays recur on every render, so after the\n * first lookup we can map them to their canonical array with a single\n * WeakMap hit instead of rebuilding the content key.\n */\n canonicalOf: WeakMap<TemplateStringsArray, TemplateStringsArray>;\n}\n\n// Exactly one intern state per page, even if this module is loaded twice\n// (e.g. via both an optimized and a raw URL).\nconst STATE_KEY = Symbol.for('@lit-labs/vite-plugin-lit#intern');\n\nconst getState = (): InternState => {\n const g = globalThis as unknown as Record<symbol, InternState | undefined>;\n return (g[STATE_KEY] ??= {\n byContent: new Map(),\n canonicalOf: new WeakMap(),\n });\n};\n\n/**\n * Builds a collision-free content key for a strings array.\n *\n * Uses the `raw` chunks (cooked strings derive from raw) with length\n * prefixes so that chunk boundaries can never collide, namespaced per tag\n * type: `html` and `svg` templates with equal content must not share a\n * canonical array, or one shared `Template` would parse SVG as HTML.\n */\nconst contentKey = (ns: string, raw: readonly string[]): string => {\n let key = ns + '\\x00' + raw.length;\n for (const chunk of raw) {\n key += '\\x01' + chunk.length + '\\x01' + chunk;\n }\n return key;\n};\n\n/**\n * Returns the canonical strings array for `strings` within namespace `ns`.\n *\n * The first genuine `TemplateStringsArray` seen for a given content becomes\n * the canonical array; later content-equal arrays map onto it. Non-template\n * input (anything without a `raw` array) passes through untouched so lit\n * can raise its own error.\n */\nexport const intern = (\n ns: string,\n strings: TemplateStringsArray\n): TemplateStringsArray => {\n if (\n !Array.isArray(strings) ||\n !Array.isArray((strings as {raw?: unknown}).raw)\n ) {\n return strings;\n }\n const state = getState();\n const fast = state.canonicalOf.get(strings);\n if (fast !== undefined) {\n return fast;\n }\n const key = contentKey(ns, strings.raw);\n let canonical = state.byContent.get(key);\n if (canonical === undefined) {\n canonical = strings;\n state.byContent.set(key, canonical);\n }\n state.canonicalOf.set(strings, canonical);\n return canonical;\n};\n\n/**\n * Wraps a template tag so its strings argument is interned in `ns`.\n */\nexport const wrapTag = <\n T extends (strings: TemplateStringsArray, ...values: never[]) => unknown,\n>(\n tag: T,\n ns: string\n): T =>\n ((strings: TemplateStringsArray, ...values: never[]) =>\n tag(intern(ns, strings), ...values)) as T;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"overrides.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,yBAAyB,CAAC;AAEjC,kDAAkD;AAClD,KAAK,GAAG,GACJ;IAAC,EAAE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAA;CAAC,GAC1D,SAAS,CAAC;AAEd,mEAAmE;AACnE,eAAO,MAAM,YAAY,QAAO,gBAQ/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QACvB,GAAG,SACD,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,KAC1C,IAKF,CAAC"}
|
package/lib/runtime/overrides.js
CHANGED
|
@@ -8,18 +8,19 @@
|
|
|
8
8
|
* persisted override (written by the panel; same origin) and subscribes to the
|
|
9
9
|
* Vite HMR channel the server rebroadcasts panel changes on.
|
|
10
10
|
*/
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
SETTINGS_OVERRIDE_CHANNEL,
|
|
13
|
+
SETTINGS_OVERRIDE_LS_KEY,
|
|
14
|
+
} from '../../types/timeline.js';
|
|
12
15
|
/** Reads the persisted override; `{}` when unset or unparsable. */
|
|
13
16
|
export const readOverride = () => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
return {};
|
|
17
|
+
try {
|
|
18
|
+
const raw = localStorage.getItem(SETTINGS_OVERRIDE_LS_KEY);
|
|
19
|
+
if (raw !== null) return JSON.parse(raw);
|
|
20
|
+
} catch {
|
|
21
|
+
// storage unavailable / malformed — fall through to defaults
|
|
22
|
+
}
|
|
23
|
+
return {};
|
|
23
24
|
};
|
|
24
25
|
/**
|
|
25
26
|
* Applies the persisted override immediately, then again whenever the panel
|
|
@@ -27,7 +28,7 @@ export const readOverride = () => {
|
|
|
27
28
|
* object each time and should act only on the fields it owns.
|
|
28
29
|
*/
|
|
29
30
|
export const subscribeOverride = (hot, apply) => {
|
|
30
|
-
|
|
31
|
-
|
|
31
|
+
apply(readOverride());
|
|
32
|
+
hot?.on(SETTINGS_OVERRIDE_CHANNEL, (data) => apply(data ?? {}));
|
|
32
33
|
};
|
|
33
|
-
//# sourceMappingURL=overrides.js.map
|
|
34
|
+
//# sourceMappingURL=overrides.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../../src/lib/runtime/overrides.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;GAIG;AAEH,OAAO,EACL,yBAAyB,EACzB,wBAAwB,GAEzB,MAAM,yBAAyB,CAAC;AAOjC,mEAAmE;AACnE,MAAM,CAAC,MAAM,YAAY,GAAG,GAAqB,EAAE;IACjD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,wBAAwB,CAAC,CAAC;QAC3D,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAqB,CAAC;IAC/D,CAAC;IAAC,MAAM,CAAC;QACP,6DAA6D;IAC/D,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,GAAQ,EACR,KAA2C,EACrC,EAAE;IACR,KAAK,CAAC,YAAY,EAAE,CAAC,CAAC;IACtB,GAAG,EAAE,EAAE,CAAC,yBAAyB,EAAE,CAAC,IAAI,EAAE,EAAE,CAC1C,KAAK,CAAC,CAAC,IAAI,IAAI,EAAE,CAAqB,CAAC,CACxC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2026 Google LLC\n * SPDX-License-Identifier: BSD-3-Clause\n */\n\n/**\n * Browser-runtime side of the panel's live setting overrides. Reads the\n * persisted override (written by the panel; same origin) and subscribes to the\n * Vite HMR channel the server rebroadcasts panel changes on.\n */\n\nimport {\n SETTINGS_OVERRIDE_CHANNEL,\n SETTINGS_OVERRIDE_LS_KEY,\n type SettingsOverride,\n} from '../../types/timeline.js';\n\n/** Minimal `import.meta.hot` shape we rely on. */\ntype Hot =\n | {on: (event: string, cb: (data: unknown) => void) => void}\n | undefined;\n\n/** Reads the persisted override; `{}` when unset or unparsable. */\nexport const readOverride = (): SettingsOverride => {\n try {\n const raw = localStorage.getItem(SETTINGS_OVERRIDE_LS_KEY);\n if (raw !== null) return JSON.parse(raw) as SettingsOverride;\n } catch {\n // storage unavailable / malformed — fall through to defaults\n }\n return {};\n};\n\n/**\n * Applies the persisted override immediately, then again whenever the panel\n * pushes a change over the HMR channel. `apply` receives the full override\n * object each time and should act only on the fields it owns.\n */\nexport const subscribeOverride = (\n hot: Hot,\n apply: (override: SettingsOverride) => void\n): void => {\n apply(readOverride());\n hot?.on(SETTINGS_OVERRIDE_CHANNEL, (data) =>\n apply((data ?? {}) as SettingsOverride)\n );\n};\n"]}
|
package/lib/runtime/patch.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright 2026 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
5
|
*/
|
|
6
|
+
import { type HmrIncompatibilityEvent, type HmrIncompatibilityReason } from '../../types/hmr-incompatibility.js';
|
|
6
7
|
export interface PatchOptions {
|
|
7
8
|
/**
|
|
8
9
|
* Cycle `disconnectedCallback()`/`connectedCallback()` on live instances
|
|
@@ -21,6 +22,13 @@ export interface PatchOptions {
|
|
|
21
22
|
* Individual copies are best-effort (non-configurable slots are skipped).
|
|
22
23
|
*/
|
|
23
24
|
export declare const syncOwnMembers: (target: object, source: object, skip: ReadonlyArray<PropertyKey>) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Builds the structured event reported over {@link HMR_INCOMPATIBLE_CHANNEL}.
|
|
27
|
+
* Exported for unit testing; otherwise module-internal. Whether the send
|
|
28
|
+
* survives the `location.reload()` that may follow it can only be checked by
|
|
29
|
+
* hand against a real dev server.
|
|
30
|
+
*/
|
|
31
|
+
export declare const buildHmrIncompatibleEvent: (tagName: string, reason: HmrIncompatibilityReason, action: HmrIncompatibilityEvent['action']) => HmrIncompatibilityEvent;
|
|
24
32
|
/**
|
|
25
33
|
* Installs the `customElements.define` interceptor. Idempotent (per-page
|
|
26
34
|
* global guard); no-ops in environments without `customElements` (SSR).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../src/lib/runtime/patch.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAmBH,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC9B,MAAM,oCAAoC,CAAC;AAW5C,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,cAAc,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CACpC;AAsDD;;;;GAIG;AAEH,eAAO,MAAM,cAAc,WACjB,MAAM,UACN,MAAM,QACR,aAAa,CAAC,WAAW,CAAC,SA4BjC,CAAC;AA2IF;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,YAC3B,MAAM,UACP,wBAAwB,UACxB,uBAAuB,CAAC,QAAQ,CAAC,KACxC,uBAAwE,CAAC;AA0K5E;;;GAGG;AACH,eAAO,MAAM,OAAO,aAAa,YAAY,KAAQ,IA2EpD,CAAC"}
|