@askrjs/vite 0.0.14 → 0.2.1
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/image-node.js +1 -1
- package/dist/index.js +378 -126
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/image-node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import { r as IMAGE_METADATA_PATH, t as normalizeDeclarationOptions } from "./image-options-B-QnEqPc.js";
|
|
3
3
|
import { Image } from "./image.js";
|
|
4
|
-
import path from "node:path";
|
|
5
4
|
import { createHash } from "node:crypto";
|
|
5
|
+
import path from "node:path";
|
|
6
6
|
import { existsSync, readFileSync } from "node:fs";
|
|
7
7
|
import { fileURLToPath } from "node:url";
|
|
8
8
|
//#region src/image-node.ts
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,213 @@
|
|
|
2
2
|
import { n as normalizeImageOptions, r as IMAGE_METADATA_PATH, t as normalizeDeclarationOptions } from "./image-options-B-QnEqPc.js";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { Visitor, parseSync } from "oxc-parser";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
5
6
|
import fs from "node:fs/promises";
|
|
6
7
|
import path from "node:path";
|
|
7
|
-
|
|
8
|
+
//#region src/source-map-rewrites.ts
|
|
9
|
+
const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
10
|
+
const BASE64_VALUES = new Map([...BASE64].map((character, index) => [character, index]));
|
|
11
|
+
function decodeVlq(value, cursor) {
|
|
12
|
+
let result = 0;
|
|
13
|
+
let shift = 0;
|
|
14
|
+
for (;;) {
|
|
15
|
+
const digit = BASE64_VALUES.get(value[cursor.value++]);
|
|
16
|
+
if (digit === void 0) throw new Error("Invalid sourcemap VLQ segment.");
|
|
17
|
+
result += (digit & 31) << shift;
|
|
18
|
+
if ((digit & 32) === 0) break;
|
|
19
|
+
shift += 5;
|
|
20
|
+
}
|
|
21
|
+
const negative = (result & 1) === 1;
|
|
22
|
+
result >>= 1;
|
|
23
|
+
return negative ? -result : result;
|
|
24
|
+
}
|
|
25
|
+
function encodeVlq(value) {
|
|
26
|
+
let remaining = Math.abs(value) << 1 | (value < 0 ? 1 : 0);
|
|
27
|
+
let output = "";
|
|
28
|
+
do {
|
|
29
|
+
let digit = remaining & 31;
|
|
30
|
+
remaining >>>= 5;
|
|
31
|
+
if (remaining > 0) digit |= 32;
|
|
32
|
+
output += BASE64[digit];
|
|
33
|
+
} while (remaining > 0);
|
|
34
|
+
return output;
|
|
35
|
+
}
|
|
36
|
+
function decodeMappings(value) {
|
|
37
|
+
const lines = [];
|
|
38
|
+
let source = 0;
|
|
39
|
+
let originalLine = 0;
|
|
40
|
+
let originalColumn = 0;
|
|
41
|
+
let name = 0;
|
|
42
|
+
for (const encodedLine of value.split(";")) {
|
|
43
|
+
const segments = [];
|
|
44
|
+
let generatedColumn = 0;
|
|
45
|
+
for (const encoded of encodedLine.split(",")) {
|
|
46
|
+
if (!encoded) continue;
|
|
47
|
+
const cursor = { value: 0 };
|
|
48
|
+
generatedColumn += decodeVlq(encoded, cursor);
|
|
49
|
+
const segment = [generatedColumn];
|
|
50
|
+
if (cursor.value < encoded.length) {
|
|
51
|
+
source += decodeVlq(encoded, cursor);
|
|
52
|
+
originalLine += decodeVlq(encoded, cursor);
|
|
53
|
+
originalColumn += decodeVlq(encoded, cursor);
|
|
54
|
+
segment.push(source, originalLine, originalColumn);
|
|
55
|
+
if (cursor.value < encoded.length) {
|
|
56
|
+
name += decodeVlq(encoded, cursor);
|
|
57
|
+
segment.push(name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
segments.push(segment);
|
|
61
|
+
}
|
|
62
|
+
lines.push(segments);
|
|
63
|
+
}
|
|
64
|
+
return lines;
|
|
65
|
+
}
|
|
66
|
+
function encodeMappings(lines) {
|
|
67
|
+
let previousSource = 0;
|
|
68
|
+
let previousOriginalLine = 0;
|
|
69
|
+
let previousOriginalColumn = 0;
|
|
70
|
+
let previousName = 0;
|
|
71
|
+
return lines.map((segments) => {
|
|
72
|
+
let previousGeneratedColumn = 0;
|
|
73
|
+
return segments.map((segment) => {
|
|
74
|
+
let encoded = encodeVlq(segment[0] - previousGeneratedColumn);
|
|
75
|
+
previousGeneratedColumn = segment[0];
|
|
76
|
+
if (segment.length >= 4) {
|
|
77
|
+
encoded += encodeVlq(segment[1] - previousSource);
|
|
78
|
+
encoded += encodeVlq(segment[2] - previousOriginalLine);
|
|
79
|
+
encoded += encodeVlq(segment[3] - previousOriginalColumn);
|
|
80
|
+
previousSource = segment[1];
|
|
81
|
+
previousOriginalLine = segment[2];
|
|
82
|
+
previousOriginalColumn = segment[3];
|
|
83
|
+
if (segment.length === 5) {
|
|
84
|
+
encoded += encodeVlq(segment[4] - previousName);
|
|
85
|
+
previousName = segment[4];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return encoded;
|
|
89
|
+
}).join(",");
|
|
90
|
+
}).join(";");
|
|
91
|
+
}
|
|
92
|
+
function lineStarts(code) {
|
|
93
|
+
const starts = [0];
|
|
94
|
+
for (let index = 0; index < code.length; index += 1) if (code[index] === "\n") starts.push(index + 1);
|
|
95
|
+
return starts;
|
|
96
|
+
}
|
|
97
|
+
function offsetAt(starts, line, column) {
|
|
98
|
+
return (starts[line] ?? starts[starts.length - 1]) + column;
|
|
99
|
+
}
|
|
100
|
+
function positionAt(starts, offset) {
|
|
101
|
+
let low = 0;
|
|
102
|
+
let high = starts.length;
|
|
103
|
+
while (low + 1 < high) {
|
|
104
|
+
const middle = low + high >>> 1;
|
|
105
|
+
if (starts[middle] <= offset) low = middle;
|
|
106
|
+
else high = middle;
|
|
107
|
+
}
|
|
108
|
+
return [low, offset - starts[low]];
|
|
109
|
+
}
|
|
110
|
+
function forwardOffset(offset, edits) {
|
|
111
|
+
let delta = 0;
|
|
112
|
+
for (const edit of edits) {
|
|
113
|
+
if (offset < edit.start) break;
|
|
114
|
+
if (offset < edit.end) return edit.start + delta;
|
|
115
|
+
delta += edit.replacement.length - (edit.end - edit.start);
|
|
116
|
+
}
|
|
117
|
+
return offset + delta;
|
|
118
|
+
}
|
|
119
|
+
function reverseOffset(offset, edits) {
|
|
120
|
+
let delta = 0;
|
|
121
|
+
for (const edit of edits) {
|
|
122
|
+
const generatedStart = edit.start + delta;
|
|
123
|
+
const generatedEnd = generatedStart + edit.replacement.length;
|
|
124
|
+
if (offset < generatedStart) break;
|
|
125
|
+
if (offset < generatedEnd) return edit.start;
|
|
126
|
+
delta += edit.replacement.length - (edit.end - edit.start);
|
|
127
|
+
}
|
|
128
|
+
return offset - delta;
|
|
129
|
+
}
|
|
130
|
+
function normalize(lines) {
|
|
131
|
+
return lines.map((segments) => {
|
|
132
|
+
const sorted = segments.sort((left, right) => left[0] - right[0]);
|
|
133
|
+
return sorted.filter((segment, index) => index === 0 || segment[0] !== sorted[index - 1][0]);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
function mappingAt(lines, starts, offset) {
|
|
137
|
+
const [line, column] = positionAt(starts, offset);
|
|
138
|
+
let match;
|
|
139
|
+
for (const segment of lines[line] ?? []) {
|
|
140
|
+
if (segment[0] > column) break;
|
|
141
|
+
if (segment.length >= 4) match = segment;
|
|
142
|
+
}
|
|
143
|
+
return match;
|
|
144
|
+
}
|
|
145
|
+
/** Move generated coordinates after deterministic text edits. */
|
|
146
|
+
function remapGenerated(map, before, after, edits) {
|
|
147
|
+
const beforeStarts = lineStarts(before);
|
|
148
|
+
const afterStarts = lineStarts(after);
|
|
149
|
+
const decoded = decodeMappings(map.mappings);
|
|
150
|
+
const output = Array.from({ length: afterStarts.length }, () => []);
|
|
151
|
+
for (const [line, segments] of decoded.entries()) for (const segment of segments) {
|
|
152
|
+
const [nextLine, nextColumn] = positionAt(afterStarts, forwardOffset(offsetAt(beforeStarts, line, segment[0]), edits));
|
|
153
|
+
output[nextLine].push([nextColumn, ...segment.slice(1)]);
|
|
154
|
+
}
|
|
155
|
+
let delta = 0;
|
|
156
|
+
for (const edit of edits) {
|
|
157
|
+
if (edit.mapTo !== void 0) {
|
|
158
|
+
const mapped = mappingAt(decoded, beforeStarts, edit.mapTo);
|
|
159
|
+
if (mapped) {
|
|
160
|
+
const [line, column] = positionAt(afterStarts, edit.start + delta);
|
|
161
|
+
output[line].push([column, ...mapped.slice(1)]);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
delta += edit.replacement.length - (edit.end - edit.start);
|
|
165
|
+
}
|
|
166
|
+
return {
|
|
167
|
+
...map,
|
|
168
|
+
mappings: encodeMappings(normalize(output))
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** Move original coordinates back through deterministic text edits. */
|
|
172
|
+
function remapOriginal(map, original, rewritten, edits) {
|
|
173
|
+
const originalStarts = lineStarts(original);
|
|
174
|
+
const rewrittenStarts = lineStarts(rewritten);
|
|
175
|
+
const lines = decodeMappings(map.mappings);
|
|
176
|
+
for (const segments of lines) for (const segment of segments) {
|
|
177
|
+
if (segment.length < 4 || segment[1] !== 0) continue;
|
|
178
|
+
const [line, column] = positionAt(originalStarts, reverseOffset(offsetAt(rewrittenStarts, segment[2], segment[3]), edits));
|
|
179
|
+
segment[2] = line;
|
|
180
|
+
segment[3] = column;
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
...map,
|
|
184
|
+
mappings: encodeMappings(lines),
|
|
185
|
+
sourcesContent: map.sources?.map((_source, index) => index === 0 ? original : map.sourcesContent?.[index] ?? null)
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
/** Build a complete map for a rewritten source when no downstream map exists. */
|
|
189
|
+
function sourceMapForRewrite(original, rewritten, edits, id) {
|
|
190
|
+
const originalStarts = lineStarts(original);
|
|
191
|
+
const rewrittenStarts = lineStarts(rewritten);
|
|
192
|
+
const lines = Array.from({ length: rewrittenStarts.length }, () => []);
|
|
193
|
+
for (let offset = 0; offset < rewritten.length; offset += 1) {
|
|
194
|
+
const [generatedLine, generatedColumn] = positionAt(rewrittenStarts, offset);
|
|
195
|
+
const [originalLine, originalColumn] = positionAt(originalStarts, reverseOffset(offset, edits));
|
|
196
|
+
lines[generatedLine].push([
|
|
197
|
+
generatedColumn,
|
|
198
|
+
0,
|
|
199
|
+
originalLine,
|
|
200
|
+
originalColumn
|
|
201
|
+
]);
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
version: 3,
|
|
205
|
+
names: [],
|
|
206
|
+
sources: [id],
|
|
207
|
+
sourcesContent: [original],
|
|
208
|
+
mappings: encodeMappings(lines)
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
8
212
|
//#region src/template-optimizer.ts
|
|
9
213
|
const OPTIMIZED_PROPS = /* @__PURE__ */ new Set([
|
|
10
214
|
"class",
|
|
@@ -40,14 +244,20 @@ function collectCandidate(property, code, candidates) {
|
|
|
40
244
|
});
|
|
41
245
|
candidates.set(cacheKey, group);
|
|
42
246
|
}
|
|
43
|
-
function
|
|
247
|
+
function optimizeTemplateOutputWithEdits(code) {
|
|
44
248
|
const parsed = parseSync("askr-compiled.js", code, {
|
|
45
249
|
lang: "js",
|
|
46
250
|
sourceType: "module"
|
|
47
251
|
});
|
|
48
|
-
if (parsed.errors.length > 0) return
|
|
252
|
+
if (parsed.errors.length > 0) return {
|
|
253
|
+
code,
|
|
254
|
+
edits: []
|
|
255
|
+
};
|
|
49
256
|
const runtimeFactories = collectRuntimeFactories(parsed.program);
|
|
50
|
-
if (runtimeFactories.size === 0) return
|
|
257
|
+
if (runtimeFactories.size === 0) return {
|
|
258
|
+
code,
|
|
259
|
+
edits: []
|
|
260
|
+
};
|
|
51
261
|
const candidates = /* @__PURE__ */ new Map();
|
|
52
262
|
const identifiers = /* @__PURE__ */ new Set();
|
|
53
263
|
new Visitor({
|
|
@@ -76,10 +286,27 @@ function optimizeTemplateOutput(code) {
|
|
|
76
286
|
identifier
|
|
77
287
|
});
|
|
78
288
|
}
|
|
79
|
-
if (declarations.length === 0) return
|
|
289
|
+
if (declarations.length === 0) return {
|
|
290
|
+
code,
|
|
291
|
+
edits: []
|
|
292
|
+
};
|
|
293
|
+
const prefix = `${declarations.join("\n")}\n`;
|
|
294
|
+
const edits = [{
|
|
295
|
+
start: 0,
|
|
296
|
+
end: 0,
|
|
297
|
+
replacement: prefix,
|
|
298
|
+
mapTo: replacements[0].start
|
|
299
|
+
}, ...replacements.map(({ start, end, identifier }) => ({
|
|
300
|
+
start,
|
|
301
|
+
end,
|
|
302
|
+
replacement: identifier
|
|
303
|
+
})).sort((left, right) => left.start - right.start)];
|
|
80
304
|
let optimized = code;
|
|
81
305
|
for (const replacement of replacements.sort((left, right) => right.start - left.start)) optimized = optimized.slice(0, replacement.start) + replacement.identifier + optimized.slice(replacement.end);
|
|
82
|
-
return
|
|
306
|
+
return {
|
|
307
|
+
code: `${prefix}${optimized}`,
|
|
308
|
+
edits
|
|
309
|
+
};
|
|
83
310
|
}
|
|
84
311
|
//#endregion
|
|
85
312
|
//#region src/image-lexical.ts
|
|
@@ -130,6 +357,119 @@ function imageDeclarationMask(code) {
|
|
|
130
357
|
for (let match = IMAGE_IMPORT.exec(code); match; match = IMAGE_IMPORT.exec(code)) if (mask[match.index]) return mask;
|
|
131
358
|
}
|
|
132
359
|
//#endregion
|
|
360
|
+
//#region src/image-declarations.ts
|
|
361
|
+
const IMAGE_CALL = /\bimage\s*\(\s*new\s+URL\s*\(\s*(["'])([^"']+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
362
|
+
function staticJson(source, id) {
|
|
363
|
+
let output = "";
|
|
364
|
+
for (let index = 0; index < source.length;) {
|
|
365
|
+
const character = source[index];
|
|
366
|
+
if (/\s/.test(character) || "{}[]:".includes(character)) {
|
|
367
|
+
output += character;
|
|
368
|
+
index += 1;
|
|
369
|
+
continue;
|
|
370
|
+
}
|
|
371
|
+
if (character === ",") {
|
|
372
|
+
let next = index + 1;
|
|
373
|
+
while (/\s/.test(source[next] ?? "")) next += 1;
|
|
374
|
+
if (source[next] !== "}" && source[next] !== "]") output += character;
|
|
375
|
+
index += 1;
|
|
376
|
+
continue;
|
|
377
|
+
}
|
|
378
|
+
if (character === "\"" || character === "'") {
|
|
379
|
+
let end = index + 1;
|
|
380
|
+
while (end < source.length && source[end] !== character) {
|
|
381
|
+
if (source[end] === "\\") throw new Error(`@askrjs/vite image() option strings in ${id} cannot contain escape sequences.`);
|
|
382
|
+
end += 1;
|
|
383
|
+
}
|
|
384
|
+
if (end >= source.length) throw new Error(`@askrjs/vite found an unterminated image option in ${id}.`);
|
|
385
|
+
output += JSON.stringify(source.slice(index + 1, end));
|
|
386
|
+
index = end + 1;
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const number = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:e[+-]?\d+)?/i.exec(source.slice(index));
|
|
390
|
+
if (number) {
|
|
391
|
+
output += number[0];
|
|
392
|
+
index += number[0].length;
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
const identifier = /^[A-Za-z_]\w*/.exec(source.slice(index));
|
|
396
|
+
if (identifier) {
|
|
397
|
+
let next = index + identifier[0].length;
|
|
398
|
+
while (/\s/.test(source[next] ?? "")) next += 1;
|
|
399
|
+
if (source[next] === ":") output += JSON.stringify(identifier[0]);
|
|
400
|
+
else if ([
|
|
401
|
+
"true",
|
|
402
|
+
"false",
|
|
403
|
+
"null"
|
|
404
|
+
].includes(identifier[0])) output += identifier[0];
|
|
405
|
+
else throw new Error(`@askrjs/vite image() options in ${id} must not reference ${identifier[0]}; use a static object literal.`);
|
|
406
|
+
index += identifier[0].length;
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
throw new Error(`@askrjs/vite image() options in ${id} must be a static object literal so builds and direct SSG imports agree.`);
|
|
410
|
+
}
|
|
411
|
+
return output;
|
|
412
|
+
}
|
|
413
|
+
function staticOptions(source, id) {
|
|
414
|
+
const trimmed = source.trim();
|
|
415
|
+
if (!trimmed) return {};
|
|
416
|
+
let value;
|
|
417
|
+
try {
|
|
418
|
+
value = JSON.parse(staticJson(trimmed, id));
|
|
419
|
+
} catch (error) {
|
|
420
|
+
if (error instanceof Error && error.message.startsWith("@askrjs/vite")) throw error;
|
|
421
|
+
throw new Error(`@askrjs/vite could not parse image() options in ${id}.`, { cause: error });
|
|
422
|
+
}
|
|
423
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`@askrjs/vite image() options in ${id} must be an object literal.`);
|
|
424
|
+
return value;
|
|
425
|
+
}
|
|
426
|
+
function findCallEnd(code, start) {
|
|
427
|
+
let depth = 1;
|
|
428
|
+
let quote = "";
|
|
429
|
+
let escaped = false;
|
|
430
|
+
for (let index = start; index < code.length; index += 1) {
|
|
431
|
+
const character = code[index];
|
|
432
|
+
if (quote) {
|
|
433
|
+
if (escaped) escaped = false;
|
|
434
|
+
else if (character === "\\") escaped = true;
|
|
435
|
+
else if (character === quote) quote = "";
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
if (character === "\"" || character === "'") {
|
|
439
|
+
quote = character;
|
|
440
|
+
continue;
|
|
441
|
+
}
|
|
442
|
+
if (character === "(") depth += 1;
|
|
443
|
+
if (character === ")") {
|
|
444
|
+
depth -= 1;
|
|
445
|
+
if (depth === 0) return index;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
return -1;
|
|
449
|
+
}
|
|
450
|
+
function imageDeclarations(code, id) {
|
|
451
|
+
const mask = imageDeclarationMask(code);
|
|
452
|
+
if (!mask) return [];
|
|
453
|
+
const output = [];
|
|
454
|
+
IMAGE_CALL.lastIndex = 0;
|
|
455
|
+
for (let match = IMAGE_CALL.exec(code); match; match = IMAGE_CALL.exec(code)) {
|
|
456
|
+
if (!mask[match.index]) continue;
|
|
457
|
+
const afterUrl = IMAGE_CALL.lastIndex;
|
|
458
|
+
const end = findCallEnd(code, afterUrl);
|
|
459
|
+
if (end < 0) throw new Error(`@askrjs/vite found an unterminated image() call in ${id}.`);
|
|
460
|
+
const remainder = code.slice(afterUrl, end).trim();
|
|
461
|
+
if (remainder && !remainder.startsWith(",")) throw new Error(`@askrjs/vite could not parse image() declaration in ${id}.`);
|
|
462
|
+
output.push({
|
|
463
|
+
start: match.index,
|
|
464
|
+
end: end + 1,
|
|
465
|
+
source: match[2],
|
|
466
|
+
options: staticOptions(remainder.replace(/^,/, ""), id)
|
|
467
|
+
});
|
|
468
|
+
IMAGE_CALL.lastIndex = end + 1;
|
|
469
|
+
}
|
|
470
|
+
return output;
|
|
471
|
+
}
|
|
472
|
+
//#endregion
|
|
133
473
|
//#region src/image-inspection.ts
|
|
134
474
|
function positiveDimensions(width, height, format, transformable, animated = false) {
|
|
135
475
|
return width > 0 && height > 0 ? {
|
|
@@ -421,117 +761,6 @@ async function processImage(context, sourcePath, declarationOptions, globalOptio
|
|
|
421
761
|
}
|
|
422
762
|
//#endregion
|
|
423
763
|
//#region src/image-pipeline.ts
|
|
424
|
-
const IMAGE_CALL = /\bimage\s*\(\s*new\s+URL\s*\(\s*(["'])([^"']+)\1\s*,\s*import\.meta\.url\s*\)/g;
|
|
425
|
-
function staticJson(source, id) {
|
|
426
|
-
let output = "";
|
|
427
|
-
for (let index = 0; index < source.length;) {
|
|
428
|
-
const character = source[index];
|
|
429
|
-
if (/\s/.test(character) || "{}[]:".includes(character)) {
|
|
430
|
-
output += character;
|
|
431
|
-
index += 1;
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
if (character === ",") {
|
|
435
|
-
let next = index + 1;
|
|
436
|
-
while (/\s/.test(source[next] ?? "")) next += 1;
|
|
437
|
-
if (source[next] !== "}" && source[next] !== "]") output += character;
|
|
438
|
-
index += 1;
|
|
439
|
-
continue;
|
|
440
|
-
}
|
|
441
|
-
if (character === "\"" || character === "'") {
|
|
442
|
-
let end = index + 1;
|
|
443
|
-
while (end < source.length && source[end] !== character) {
|
|
444
|
-
if (source[end] === "\\") throw new Error(`@askrjs/vite image() option strings in ${id} cannot contain escape sequences.`);
|
|
445
|
-
end += 1;
|
|
446
|
-
}
|
|
447
|
-
if (end >= source.length) throw new Error(`@askrjs/vite found an unterminated image option in ${id}.`);
|
|
448
|
-
output += JSON.stringify(source.slice(index + 1, end));
|
|
449
|
-
index = end + 1;
|
|
450
|
-
continue;
|
|
451
|
-
}
|
|
452
|
-
const number = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:e[+-]?\d+)?/i.exec(source.slice(index));
|
|
453
|
-
if (number) {
|
|
454
|
-
output += number[0];
|
|
455
|
-
index += number[0].length;
|
|
456
|
-
continue;
|
|
457
|
-
}
|
|
458
|
-
const identifier = /^[A-Za-z_]\w*/.exec(source.slice(index));
|
|
459
|
-
if (identifier) {
|
|
460
|
-
let next = index + identifier[0].length;
|
|
461
|
-
while (/\s/.test(source[next] ?? "")) next += 1;
|
|
462
|
-
if (source[next] === ":") output += JSON.stringify(identifier[0]);
|
|
463
|
-
else if ([
|
|
464
|
-
"true",
|
|
465
|
-
"false",
|
|
466
|
-
"null"
|
|
467
|
-
].includes(identifier[0])) output += identifier[0];
|
|
468
|
-
else throw new Error(`@askrjs/vite image() options in ${id} must not reference ${identifier[0]}; use a static object literal.`);
|
|
469
|
-
index += identifier[0].length;
|
|
470
|
-
continue;
|
|
471
|
-
}
|
|
472
|
-
throw new Error(`@askrjs/vite image() options in ${id} must be a static object literal so builds and direct SSG imports agree.`);
|
|
473
|
-
}
|
|
474
|
-
return output;
|
|
475
|
-
}
|
|
476
|
-
function staticOptions(source, id) {
|
|
477
|
-
const trimmed = source.trim();
|
|
478
|
-
if (!trimmed) return {};
|
|
479
|
-
let value;
|
|
480
|
-
try {
|
|
481
|
-
value = JSON.parse(staticJson(trimmed, id));
|
|
482
|
-
} catch (error) {
|
|
483
|
-
if (error instanceof Error && error.message.startsWith("@askrjs/vite")) throw error;
|
|
484
|
-
throw new Error(`@askrjs/vite could not parse image() options in ${id}.`, { cause: error });
|
|
485
|
-
}
|
|
486
|
-
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`@askrjs/vite image() options in ${id} must be an object literal.`);
|
|
487
|
-
return value;
|
|
488
|
-
}
|
|
489
|
-
function findCallEnd(code, start) {
|
|
490
|
-
let depth = 1;
|
|
491
|
-
let quote = "";
|
|
492
|
-
let escaped = false;
|
|
493
|
-
for (let index = start; index < code.length; index += 1) {
|
|
494
|
-
const character = code[index];
|
|
495
|
-
if (quote) {
|
|
496
|
-
if (escaped) escaped = false;
|
|
497
|
-
else if (character === "\\") escaped = true;
|
|
498
|
-
else if (character === quote) quote = "";
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
if (character === "\"" || character === "'") {
|
|
502
|
-
quote = character;
|
|
503
|
-
continue;
|
|
504
|
-
}
|
|
505
|
-
if (character === "(") depth += 1;
|
|
506
|
-
if (character === ")") {
|
|
507
|
-
depth -= 1;
|
|
508
|
-
if (depth === 0) return index;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
return -1;
|
|
512
|
-
}
|
|
513
|
-
function declarations(code, id) {
|
|
514
|
-
const mask = imageDeclarationMask(code);
|
|
515
|
-
if (!mask) return [];
|
|
516
|
-
const output = [];
|
|
517
|
-
IMAGE_CALL.lastIndex = 0;
|
|
518
|
-
for (let match = IMAGE_CALL.exec(code); match; match = IMAGE_CALL.exec(code)) {
|
|
519
|
-
if (!mask[match.index]) continue;
|
|
520
|
-
const afterUrl = IMAGE_CALL.lastIndex;
|
|
521
|
-
const end = findCallEnd(code, afterUrl);
|
|
522
|
-
if (end < 0) throw new Error(`@askrjs/vite found an unterminated image() call in ${id}.`);
|
|
523
|
-
const remainder = code.slice(afterUrl, end).trim();
|
|
524
|
-
if (remainder && !remainder.startsWith(",")) throw new Error(`@askrjs/vite could not parse image() declaration in ${id}.`);
|
|
525
|
-
output.push({
|
|
526
|
-
start: match.index,
|
|
527
|
-
end: end + 1,
|
|
528
|
-
source: match[2],
|
|
529
|
-
options: staticOptions(remainder.replace(/^,/, ""), id)
|
|
530
|
-
});
|
|
531
|
-
IMAGE_CALL.lastIndex = end + 1;
|
|
532
|
-
}
|
|
533
|
-
return output;
|
|
534
|
-
}
|
|
535
764
|
function urlExpression(referenceId) {
|
|
536
765
|
return `import.meta.ROLLUP_FILE_URL_${referenceId}`;
|
|
537
766
|
}
|
|
@@ -586,23 +815,39 @@ var ImagePipeline = class {
|
|
|
586
815
|
this.#config = config;
|
|
587
816
|
}
|
|
588
817
|
async transform(context, code, id) {
|
|
589
|
-
|
|
818
|
+
return (await this.transformWithEdits(context, code, id))?.code;
|
|
819
|
+
}
|
|
820
|
+
async transformWithEdits(context, code, id) {
|
|
821
|
+
const found = imageDeclarations(code, id);
|
|
590
822
|
if (found.length === 0) return void 0;
|
|
591
823
|
if (!this.#config) throw new Error("@askrjs/vite image pipeline was not configured.");
|
|
592
824
|
if (this.#config.command !== "build") throw new Error("@askrjs/vite responsive image declarations currently require a Vite build.");
|
|
593
825
|
const cacheDir = path.join(this.#config.root, "node_modules/.cache/@askrjs/vite/images");
|
|
594
826
|
let transformed = code;
|
|
827
|
+
const edits = [];
|
|
595
828
|
for (const declaration of [...found].reverse()) {
|
|
596
829
|
const sourcePath = path.resolve(path.dirname(id.split("?", 1)[0]), declaration.source);
|
|
597
830
|
const key = declarationKey(sourcePath, declaration.options);
|
|
598
831
|
let processed = this.#processed.get(key);
|
|
832
|
+
if (processed) {
|
|
833
|
+
if (createHash("sha256").update(await fs.readFile(sourcePath)).digest("hex") !== processed.sourceHash) processed = void 0;
|
|
834
|
+
}
|
|
599
835
|
if (!processed) {
|
|
600
836
|
processed = await processImage(context, sourcePath, declaration.options, this.#options, cacheDir, this.#sharpLoader);
|
|
601
837
|
this.#processed.set(key, processed);
|
|
602
838
|
}
|
|
603
|
-
|
|
839
|
+
const replacement = imageExpression(processed);
|
|
840
|
+
edits.push({
|
|
841
|
+
start: declaration.start,
|
|
842
|
+
end: declaration.end,
|
|
843
|
+
replacement
|
|
844
|
+
});
|
|
845
|
+
transformed = `${transformed.slice(0, declaration.start)}${replacement}${transformed.slice(declaration.end)}`;
|
|
604
846
|
}
|
|
605
|
-
return
|
|
847
|
+
return {
|
|
848
|
+
code: transformed,
|
|
849
|
+
edits: edits.sort((left, right) => left.start - right.start)
|
|
850
|
+
};
|
|
606
851
|
}
|
|
607
852
|
async writeMetadata(context) {
|
|
608
853
|
if (!this.#config || this.#processed.size === 0) return;
|
|
@@ -704,11 +949,11 @@ function askrVitePlugin(options = {}) {
|
|
|
704
949
|
},
|
|
705
950
|
async transform(code, id) {
|
|
706
951
|
if (id.includes("node_modules")) return null;
|
|
707
|
-
const imageTransformed = imagePipeline ? await imagePipeline.
|
|
708
|
-
const input = imageTransformed ?? code;
|
|
952
|
+
const imageTransformed = imagePipeline ? await imagePipeline.transformWithEdits(this, code, id) : void 0;
|
|
953
|
+
const input = imageTransformed?.code ?? code;
|
|
709
954
|
if (!shouldTransform || !/\.(jsx|tsx)$/.test(id)) return imageTransformed ? {
|
|
710
|
-
code: imageTransformed,
|
|
711
|
-
map:
|
|
955
|
+
code: imageTransformed.code,
|
|
956
|
+
map: sourceMapForRewrite(code, imageTransformed.code, imageTransformed.edits, id)
|
|
712
957
|
} : null;
|
|
713
958
|
try {
|
|
714
959
|
const result = await (await loadTransformWithOxc())(input, id, {
|
|
@@ -720,9 +965,16 @@ function askrVitePlugin(options = {}) {
|
|
|
720
965
|
sourcemap: true
|
|
721
966
|
});
|
|
722
967
|
if (!result?.code) return null;
|
|
968
|
+
let map = result.map;
|
|
969
|
+
if (imageTransformed) map = remapOriginal(map, code, input, imageTransformed.edits);
|
|
970
|
+
if (!shouldOptimizeTemplates) return {
|
|
971
|
+
code: result.code,
|
|
972
|
+
map
|
|
973
|
+
};
|
|
974
|
+
const optimized = optimizeTemplateOutputWithEdits(result.code);
|
|
723
975
|
return {
|
|
724
|
-
code:
|
|
725
|
-
map: result.
|
|
976
|
+
code: optimized.code,
|
|
977
|
+
map: remapGenerated(map, result.code, optimized.code, optimized.edits)
|
|
726
978
|
};
|
|
727
979
|
} catch (error) {
|
|
728
980
|
const detail = error instanceof Error ? error.message : String(error);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["mime","#options","#processed","#sharpLoader","#config"],"sources":["../src/template-optimizer.ts","../src/image-lexical.ts","../src/image-inspection.ts","../src/image-transform.ts","../src/image-pipeline.ts","../src/jsx-plugin.ts"],"sourcesContent":["import { parseSync, Visitor, type ObjectProperty } from \"oxc-parser\";\n\nconst OPTIMIZED_PROPS = new Set([\"class\", \"className\", \"style\"]);\nconst JSX_RUNTIME_SOURCE = \"@askrjs/askr/jsx-runtime\";\nconst JSX_FACTORIES = new Set([\"jsx\", \"jsxs\", \"jsxDEV\"]);\n\ntype Candidate = {\n literal: string;\n start: number;\n end: number;\n};\n\nfunction importedName(specifier: { imported: { type: string; name?: string; value?: unknown } }) {\n return specifier.imported.type === \"Identifier\"\n ? specifier.imported.name\n : specifier.imported.value;\n}\n\nfunction collectRuntimeFactories(program: ReturnType<typeof parseSync>[\"program\"]): Set<string> {\n const factories = new Set<string>();\n\n for (const statement of program.body) {\n if (statement.type !== \"ImportDeclaration\" || statement.source.value !== JSX_RUNTIME_SOURCE) {\n continue;\n }\n\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === \"ImportSpecifier\" &&\n JSX_FACTORIES.has(String(importedName(specifier)))\n ) {\n factories.add(specifier.local.name);\n }\n }\n }\n\n return factories;\n}\n\nfunction collectCandidate(\n property: ObjectProperty,\n code: string,\n candidates: Map<string, Candidate[]>,\n) {\n if (\n property.kind !== \"init\" ||\n property.computed ||\n property.method ||\n property.key.type !== \"Identifier\" ||\n !OPTIMIZED_PROPS.has(property.key.name) ||\n property.value.type !== \"Literal\" ||\n typeof property.value.value !== \"string\"\n ) {\n return;\n }\n\n const literal = code.slice(property.value.start, property.value.end);\n const cacheKey = `${property.key.name}:${literal}`;\n const group = candidates.get(cacheKey) ?? [];\n group.push({\n literal,\n start: property.value.start,\n end: property.value.end,\n });\n candidates.set(cacheKey, group);\n}\n\nexport function optimizeTemplateOutput(code: string): string {\n const parsed = parseSync(\"askr-compiled.js\", code, {\n lang: \"js\",\n sourceType: \"module\",\n });\n if (parsed.errors.length > 0) return code;\n\n const runtimeFactories = collectRuntimeFactories(parsed.program);\n if (runtimeFactories.size === 0) return code;\n\n const candidates = new Map<string, Candidate[]>();\n const identifiers = new Set<string>();\n new Visitor({\n Identifier(identifier) {\n identifiers.add(identifier.name);\n },\n CallExpression(call) {\n if (\n call.callee.type !== \"Identifier\" ||\n !runtimeFactories.has(call.callee.name) ||\n call.arguments[1]?.type !== \"ObjectExpression\"\n ) {\n return;\n }\n\n for (const property of call.arguments[1].properties) {\n if (property.type === \"Property\") {\n collectCandidate(property, code, candidates);\n }\n }\n },\n }).visit(parsed.program);\n\n const declarations: string[] = [];\n const replacements: Array<{ start: number; end: number; identifier: string }> = [];\n let hoistIndex = 0;\n for (const group of candidates.values()) {\n if (group.length < 2) continue;\n\n let identifier: string;\n do {\n identifier = `__askrStaticLiteral${hoistIndex++}`;\n } while (identifiers.has(identifier));\n identifiers.add(identifier);\n declarations.push(`const ${identifier} = ${group[0].literal};`);\n for (const candidate of group) {\n replacements.push({ start: candidate.start, end: candidate.end, identifier });\n }\n }\n\n if (declarations.length === 0) return code;\n\n let optimized = code;\n for (const replacement of replacements.sort((left, right) => right.start - left.start)) {\n optimized =\n optimized.slice(0, replacement.start) +\n replacement.identifier +\n optimized.slice(replacement.end);\n }\n return `${declarations.join(\"\\n\")}\\n${optimized}`;\n}\n","const IMAGE_IMPORT = /from\\s+[\"']@askrjs\\/vite\\/image[\"']/g;\n\nfunction lexicalCodeMask(source: string): Uint8Array {\n const mask = new Uint8Array(source.length);\n let state: \"code\" | \"single\" | \"double\" | \"template\" | \"line-comment\" | \"block-comment\" = \"code\";\n let escaped = false;\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index]!;\n const next = source[index + 1];\n if (state === \"code\") {\n if (character === \"/\" && next === \"/\") {\n state = \"line-comment\";\n index += 1;\n } else if (character === \"/\" && next === \"*\") {\n state = \"block-comment\";\n index += 1;\n } else if (character === \"'\") state = \"single\";\n else if (character === '\"') state = \"double\";\n else if (character === \"`\") state = \"template\";\n else mask[index] = 1;\n continue;\n }\n if (state === \"line-comment\") {\n if (character === \"\\n\" || character === \"\\r\") {\n state = \"code\";\n mask[index] = 1;\n }\n continue;\n }\n if (state === \"block-comment\") {\n if (character === \"*\" && next === \"/\") {\n state = \"code\";\n index += 1;\n }\n continue;\n }\n if (escaped) escaped = false;\n else if (character === \"\\\\\") escaped = true;\n else if (\n (state === \"single\" && character === \"'\") ||\n (state === \"double\" && character === '\"') ||\n (state === \"template\" && character === \"`\")\n ) {\n state = \"code\";\n }\n }\n return mask;\n}\n\nexport function imageDeclarationMask(code: string): Uint8Array | undefined {\n const mask = lexicalCodeMask(code);\n IMAGE_IMPORT.lastIndex = 0;\n for (let match = IMAGE_IMPORT.exec(code); match; match = IMAGE_IMPORT.exec(code)) {\n if (mask[match.index]) return mask;\n }\n return undefined;\n}\n","export type AssetFormat = \"avif\" | \"webp\" | \"jpeg\" | \"png\" | \"gif\" | \"svg\";\n\nexport interface SourceInspection {\n width: number;\n height: number;\n format: AssetFormat;\n transformable: boolean;\n animated: boolean;\n}\n\nfunction positiveDimensions(\n width: number,\n height: number,\n format: AssetFormat,\n transformable: boolean,\n animated = false,\n): SourceInspection | undefined {\n return width > 0 && height > 0 ? { width, height, format, transformable, animated } : undefined;\n}\n\nfunction inspectPng(source: Buffer): SourceInspection | undefined {\n if (\n source.length < 24 ||\n !source.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))\n ) {\n return undefined;\n }\n return positiveDimensions(\n source.readUInt32BE(16),\n source.readUInt32BE(20),\n \"png\",\n true,\n source.includes(Buffer.from(\"acTL\")),\n );\n}\n\nfunction inspectGif(source: Buffer): SourceInspection | undefined {\n if (source.length < 10 || !/^GIF8[79]a$/.test(source.subarray(0, 6).toString(\"ascii\"))) {\n return undefined;\n }\n return positiveDimensions(source.readUInt16LE(6), source.readUInt16LE(8), \"gif\", false, true);\n}\n\nfunction exifOrientation(segment: Buffer): number | undefined {\n if (segment.length < 14 || segment.subarray(0, 6).toString(\"binary\") !== \"Exif\\0\\0\") {\n return undefined;\n }\n const tiff = 6;\n const byteOrder = segment.subarray(tiff, tiff + 2).toString(\"ascii\");\n const littleEndian = byteOrder === \"II\";\n if (!littleEndian && byteOrder !== \"MM\") return undefined;\n const read16 = (offset: number): number | undefined => {\n const absolute = tiff + offset;\n if (absolute < tiff || absolute + 2 > segment.length) return undefined;\n return littleEndian ? segment.readUInt16LE(absolute) : segment.readUInt16BE(absolute);\n };\n const read32 = (offset: number): number | undefined => {\n const absolute = tiff + offset;\n if (absolute < tiff || absolute + 4 > segment.length) return undefined;\n return littleEndian ? segment.readUInt32LE(absolute) : segment.readUInt32BE(absolute);\n };\n if (read16(2) !== 42) return undefined;\n const directoryOffset = read32(4);\n if (directoryOffset === undefined) return undefined;\n const entries = read16(directoryOffset);\n if (entries === undefined) return undefined;\n for (let index = 0; index < entries; index += 1) {\n const entry = directoryOffset + 2 + index * 12;\n if (read16(entry) !== 0x0112 || read16(entry + 2) !== 3 || read32(entry + 4) !== 1) {\n continue;\n }\n const orientation = read16(entry + 8);\n return orientation && orientation >= 1 && orientation <= 8 ? orientation : undefined;\n }\n return undefined;\n}\n\nfunction inspectJpeg(source: Buffer): SourceInspection | undefined {\n if (source.length < 4 || source[0] !== 0xff || source[1] !== 0xd8) return undefined;\n const startOfFrame = new Set([\n 0xc0, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, 0xc7, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf,\n ]);\n let orientation: number | undefined;\n let offset = 2;\n while (offset + 8 < source.length) {\n if (source[offset] !== 0xff) {\n offset += 1;\n continue;\n }\n while (source[offset] === 0xff) offset += 1;\n const marker = source[offset++]!;\n if (marker === 0xd8 || marker === 0xd9 || marker === 0x01) continue;\n if (marker >= 0xd0 && marker <= 0xd7) continue;\n if (offset + 2 > source.length) break;\n const length = source.readUInt16BE(offset);\n if (length < 2 || offset + length > source.length) break;\n if (marker === 0xe1) {\n orientation = exifOrientation(source.subarray(offset + 2, offset + length)) ?? orientation;\n }\n if (startOfFrame.has(marker) && length >= 7) {\n const width = source.readUInt16BE(offset + 5);\n const height = source.readUInt16BE(offset + 3);\n return positiveDimensions(\n orientation !== undefined && orientation >= 5 ? height : width,\n orientation !== undefined && orientation >= 5 ? width : height,\n \"jpeg\",\n true,\n );\n }\n offset += length;\n }\n return undefined;\n}\n\nfunction inspectSvg(source: Buffer): SourceInspection | undefined {\n const openingTag = source\n .subarray(0, 16_384)\n .toString(\"utf8\")\n .match(/<svg\\b[^>]*>/i)?.[0];\n if (!openingTag) return undefined;\n const numberAttribute = (name: string): number | undefined => {\n const value = openingTag.match(new RegExp(`\\\\b${name}\\\\s*=\\\\s*[\"']\\\\s*([0-9.]+)`, \"i\"))?.[1];\n const parsed = value ? Number(value) : Number.NaN;\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n };\n let width = numberAttribute(\"width\");\n let height = numberAttribute(\"height\");\n const viewBox = openingTag\n .match(/\\bviewBox\\s*=\\s*[\"']\\s*[-+0-9.e]+[ ,]+[-+0-9.e]+[ ,]+([-+0-9.e]+)[ ,]+([-+0-9.e]+)/i)\n ?.slice(1)\n .map(Number);\n if (!width && viewBox?.[0] && viewBox[0] > 0) width = viewBox[0];\n if (!height && viewBox?.[1] && viewBox[1] > 0) height = viewBox[1];\n if (!width && height && viewBox?.[0] && viewBox?.[1]) width = height * (viewBox[0] / viewBox[1]);\n if (!height && width && viewBox?.[0] && viewBox?.[1]) height = width / (viewBox[0] / viewBox[1]);\n return width && height ? positiveDimensions(width, height, \"svg\", false) : undefined;\n}\n\nfunction inspectWebp(source: Buffer): SourceInspection | undefined {\n if (\n source.length < 30 ||\n source.subarray(0, 4).toString(\"ascii\") !== \"RIFF\" ||\n source.subarray(8, 12).toString(\"ascii\") !== \"WEBP\"\n ) {\n return undefined;\n }\n const chunk = source.subarray(12, 16).toString(\"ascii\");\n if (chunk === \"VP8X\") {\n const width = 1 + source.readUIntLE(24, 3);\n const height = 1 + source.readUIntLE(27, 3);\n return positiveDimensions(width, height, \"webp\", false, Boolean(source[20]! & 0x02));\n }\n if (chunk === \"VP8 \") {\n return positiveDimensions(\n source.readUInt16LE(26) & 0x3fff,\n source.readUInt16LE(28) & 0x3fff,\n \"webp\",\n false,\n );\n }\n if (chunk === \"VP8L\" && source[20] === 0x2f) {\n const bits = source.readUInt32LE(21);\n return positiveDimensions(1 + (bits & 0x3fff), 1 + ((bits >>> 14) & 0x3fff), \"webp\", false);\n }\n return undefined;\n}\n\nfunction inspectAvif(source: Buffer): SourceInspection | undefined {\n if (source.length < 24 || source.subarray(4, 8).toString(\"ascii\") !== \"ftyp\") return undefined;\n const typeOffset = source.indexOf(Buffer.from(\"ispe\"));\n if (typeOffset < 0 || typeOffset + 16 > source.length) return undefined;\n return positiveDimensions(\n source.readUInt32BE(typeOffset + 8),\n source.readUInt32BE(typeOffset + 12),\n \"avif\",\n false,\n );\n}\n\nexport function inspectSource(sourcePath: string, source: Buffer): SourceInspection {\n const inspection =\n inspectPng(source) ??\n inspectGif(source) ??\n inspectJpeg(source) ??\n inspectSvg(source) ??\n inspectWebp(source) ??\n inspectAvif(source);\n if (!inspection) {\n throw new Error(\n `@askrjs/vite could not determine intrinsic dimensions for pass-through image ${sourcePath}.`,\n );\n }\n return inspection;\n}\n","import { createHash } from \"node:crypto\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { inspectSource, type AssetFormat } from \"./image-inspection\";\nimport { normalizeDeclarationOptions, normalizeImageOptions } from \"./image-options\";\nimport type { ImageOptions, ImageOutputFormat, ImagePipelineOptions } from \"./image-types\";\n\ntype SharpFactory = (typeof import(\"sharp\"))[\"default\"];\nexport type SharpLoader = () => Promise<SharpFactory>;\ntype TransformFormat = \"avif\" | \"webp\" | \"jpeg\" | \"png\";\n\nexport interface EmittedVariant {\n referenceId: string;\n width: number;\n height: number;\n format: AssetFormat;\n mime: string;\n}\n\nexport interface AssetPluginContext {\n emitFile(file: { type: \"asset\"; name: string; source: string | Uint8Array }): string;\n getFileName(referenceId: string): string;\n}\n\nexport interface ProcessedImage {\n declarationKey: string;\n sourcePath: string;\n sourceHash: string;\n declarationOptions: ImageOptions;\n transformKey: string;\n encoder: string;\n fallback: EmittedVariant;\n variants: EmittedVariant[];\n passThrough: boolean;\n}\n\nfunction hash(value: string | Buffer): string {\n return createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nexport function declarationKey(sourcePath: string, options: ImageOptions): string {\n return hash(`${sourcePath}\\0${JSON.stringify(normalizeDeclarationOptions(options))}`);\n}\n\nexport const defaultSharpLoader: SharpLoader = async () => (await import(\"sharp\")).default;\n\nasync function loadSharp(loader: SharpLoader): Promise<SharpFactory> {\n try {\n return await loader();\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ERR_MODULE_NOT_FOUND\") {\n throw new Error(\n '@askrjs/vite responsive images require the optional peer \"sharp\". Install sharp@^0.35.3 and rebuild.',\n { cause: error },\n );\n }\n throw error;\n }\n}\n\nfunction sourceFormat(format: string | undefined): \"jpeg\" | \"png\" | undefined {\n if (format === \"jpeg\" || format === \"jpg\") return \"jpeg\";\n return format === \"png\" ? \"png\" : undefined;\n}\n\nfunction extension(format: AssetFormat): string {\n return format === \"jpeg\" ? \"jpg\" : format;\n}\n\nfunction mime(format: AssetFormat): string {\n return format === \"jpeg\" ? \"image/jpeg\" : `image/${format}`;\n}\n\nfunction outputName(sourcePath: string, width: number, format: EmittedVariant[\"format\"]): string {\n const basename = path.basename(sourcePath, path.extname(sourcePath));\n return `${basename}-${width}.${extension(format)}`;\n}\n\nfunction outputHeight(\n width: number,\n sourceWidth: number,\n sourceHeight: number,\n aspectRatio: number | undefined,\n): number {\n return Math.max(1, Math.round(width / (aspectRatio ?? sourceWidth / sourceHeight)));\n}\n\nasync function encodedVariant(\n sharp: SharpFactory,\n source: Buffer,\n cacheDir: string,\n transformKey: string,\n width: number,\n height: number,\n format: TransformFormat,\n options: ReturnType<typeof normalizeImageOptions>,\n): Promise<Buffer> {\n const cachePath = path.join(cacheDir, `${transformKey}-${width}.${extension(format)}`);\n const cached = await fs.readFile(cachePath).catch(() => undefined);\n if (cached) return cached;\n\n let pipeline = sharp(source, { animated: false }).autoOrient();\n pipeline =\n options.fit === \"cover\"\n ? pipeline.resize({ width, height, fit: \"cover\", position: options.position })\n : pipeline.resize({ width, fit: \"inside\", withoutEnlargement: true });\n if (format === \"avif\") pipeline = pipeline.avif({ quality: options.quality.avif });\n else if (format === \"webp\") pipeline = pipeline.webp({ quality: options.quality.webp });\n else if (format === \"jpeg\") pipeline = pipeline.jpeg({ quality: options.quality.jpeg });\n else {\n pipeline = pipeline.png(\n options.quality.png === 100\n ? { compressionLevel: 9 }\n : { compressionLevel: 9, quality: options.quality.png },\n );\n }\n const encoded = await pipeline.toBuffer();\n await fs.mkdir(cacheDir, { recursive: true });\n await fs.writeFile(cachePath, encoded);\n return encoded;\n}\n\nfunction variantFormats(\n formats: readonly ImageOutputFormat[],\n fallback: \"jpeg\" | \"png\",\n): Array<\"avif\" | \"webp\" | \"jpeg\" | \"png\"> {\n const output: Array<\"avif\" | \"webp\" | \"jpeg\" | \"png\"> = [];\n for (const format of formats) {\n const resolved = format === \"source\" ? fallback : format;\n if (!output.includes(resolved)) output.push(resolved);\n }\n if (!output.includes(fallback)) output.push(fallback);\n return output;\n}\n\nfunction passThroughImage(\n context: AssetPluginContext,\n sourcePath: string,\n source: Buffer,\n width: number,\n height: number,\n format: AssetFormat,\n): { fallback: EmittedVariant; variants: EmittedVariant[] } {\n const referenceId = context.emitFile({ type: \"asset\", name: path.basename(sourcePath), source });\n const fallback = { referenceId, width, height, format, mime: mime(format) };\n return { fallback, variants: [fallback] };\n}\n\nexport async function processImage(\n context: AssetPluginContext,\n sourcePath: string,\n declarationOptions: ImageOptions,\n globalOptions: ImagePipelineOptions,\n cacheDir: string,\n sharpLoader: SharpLoader,\n): Promise<ProcessedImage> {\n const source = await fs.readFile(sourcePath);\n const sourceHash = hash(source);\n const normalized = normalizeImageOptions(globalOptions, declarationOptions);\n const inspection = inspectSource(sourcePath, source);\n const key = declarationKey(sourcePath, declarationOptions);\n const shouldPassThroughWithoutSharp =\n !inspection.transformable ||\n inspection.animated ||\n (normalized.fit === \"inside\" && inspection.width <= normalized.widths[0]!);\n if (shouldPassThroughWithoutSharp) {\n const encoder = \"passthrough\";\n return {\n declarationKey: key,\n sourcePath,\n sourceHash,\n declarationOptions: normalizeDeclarationOptions(declarationOptions),\n transformKey: hash(`${sourceHash}\\0${JSON.stringify(normalized)}\\0${encoder}`),\n encoder,\n ...passThroughImage(\n context,\n sourcePath,\n source,\n inspection.width,\n inspection.height,\n inspection.format,\n ),\n passThrough: true,\n };\n }\n const sharp = await loadSharp(sharpLoader);\n const metadata = await sharp(source, { animated: true }).metadata();\n const sourceWidth = metadata.autoOrient.width ?? metadata.width;\n const sourceHeight =\n (metadata.pages ?? 1) > 1\n ? (metadata.pageHeight ?? metadata.height)\n : (metadata.autoOrient.height ?? metadata.height);\n if (!sourceWidth || !sourceHeight) {\n throw new Error(`@askrjs/vite could not determine intrinsic dimensions for ${sourcePath}.`);\n }\n const encoder = `sharp@${sharp.versions.sharp}`;\n const transformKey = hash(`${sourceHash}\\0${JSON.stringify(normalized)}\\0${encoder}`);\n const fallbackFormat = sourceFormat(metadata.format);\n\n const shouldPassThrough = (metadata.pages ?? 1) > 1 || !fallbackFormat;\n if (shouldPassThrough) {\n return {\n declarationKey: key,\n sourcePath,\n sourceHash,\n declarationOptions: normalizeDeclarationOptions(declarationOptions),\n transformKey,\n encoder,\n ...passThroughImage(\n context,\n sourcePath,\n source,\n sourceWidth,\n sourceHeight,\n fallbackFormat ?? inspection.format,\n ),\n passThrough: true,\n };\n }\n\n const maximumWidth =\n normalized.fit === \"cover\"\n ? Math.min(sourceWidth, Math.floor(sourceHeight * normalized.aspectRatio!))\n : sourceWidth;\n if (maximumWidth < 1) {\n throw new Error(\n `@askrjs/vite cannot crop ${sourcePath} to aspect ratio ${normalized.aspectRatio} without upscaling.`,\n );\n }\n const widths = normalized.widths.filter((width) => width <= maximumWidth);\n if (!widths.includes(maximumWidth)) widths.push(maximumWidth);\n widths.sort((left, right) => left - right);\n const variants: EmittedVariant[] = [];\n for (const format of variantFormats(normalized.formats, fallbackFormat)) {\n for (const width of widths) {\n const height = outputHeight(\n width,\n sourceWidth,\n sourceHeight,\n normalized.fit === \"cover\" ? normalized.aspectRatio : undefined,\n );\n const buffer = await encodedVariant(\n sharp,\n source,\n cacheDir,\n transformKey,\n width,\n height,\n format,\n normalized,\n );\n variants.push({\n referenceId: context.emitFile({\n type: \"asset\",\n name: outputName(sourcePath, width, format),\n source: buffer,\n }),\n width,\n height,\n format,\n mime: mime(format),\n });\n }\n }\n return {\n declarationKey: key,\n sourcePath,\n sourceHash,\n declarationOptions: normalizeDeclarationOptions(declarationOptions),\n transformKey,\n encoder,\n fallback: variants.filter((variant) => variant.format === fallbackFormat).at(-1)!,\n variants,\n passThrough: false,\n };\n}\n","import fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { ResolvedConfig } from \"vite\";\nimport { imageDeclarationMask } from \"./image-lexical\";\nimport {\n IMAGE_METADATA_PATH,\n IMAGE_METADATA_VERSION,\n type ImageMetadataEntry,\n type ImageMetadataRecord,\n} from \"./image-metadata\";\nimport type { ImageOptions, ImagePipelineOptions, ResponsiveImage } from \"./image-types\";\nimport {\n declarationKey,\n defaultSharpLoader,\n processImage,\n type AssetPluginContext,\n type EmittedVariant,\n type ProcessedImage,\n type SharpLoader,\n} from \"./image-transform\";\n\ninterface Declaration {\n start: number;\n end: number;\n source: string;\n options: ImageOptions;\n}\n\nconst IMAGE_CALL = /\\bimage\\s*\\(\\s*new\\s+URL\\s*\\(\\s*([\"'])([^\"']+)\\1\\s*,\\s*import\\.meta\\.url\\s*\\)/g;\n\nfunction staticJson(source: string, id: string): string {\n let output = \"\";\n for (let index = 0; index < source.length;) {\n const character = source[index]!;\n if (/\\s/.test(character) || \"{}[]:\".includes(character)) {\n output += character;\n index += 1;\n continue;\n }\n if (character === \",\") {\n let next = index + 1;\n while (/\\s/.test(source[next] ?? \"\")) next += 1;\n if (source[next] !== \"}\" && source[next] !== \"]\") output += character;\n index += 1;\n continue;\n }\n if (character === '\"' || character === \"'\") {\n let end = index + 1;\n while (end < source.length && source[end] !== character) {\n if (source[end] === \"\\\\\") {\n throw new Error(\n `@askrjs/vite image() option strings in ${id} cannot contain escape sequences.`,\n );\n }\n end += 1;\n }\n if (end >= source.length) {\n throw new Error(`@askrjs/vite found an unterminated image option in ${id}.`);\n }\n output += JSON.stringify(source.slice(index + 1, end));\n index = end + 1;\n continue;\n }\n const number = /^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:e[+-]?\\d+)?/i.exec(source.slice(index));\n if (number) {\n output += number[0];\n index += number[0].length;\n continue;\n }\n const identifier = /^[A-Za-z_]\\w*/.exec(source.slice(index));\n if (identifier) {\n let next = index + identifier[0].length;\n while (/\\s/.test(source[next] ?? \"\")) next += 1;\n if (source[next] === \":\") output += JSON.stringify(identifier[0]);\n else if ([\"true\", \"false\", \"null\"].includes(identifier[0])) output += identifier[0];\n else {\n throw new Error(\n `@askrjs/vite image() options in ${id} must not reference ${identifier[0]}; use a static object literal.`,\n );\n }\n index += identifier[0].length;\n continue;\n }\n throw new Error(\n `@askrjs/vite image() options in ${id} must be a static object literal so builds and direct SSG imports agree.`,\n );\n }\n return output;\n}\n\nfunction staticOptions(source: string, id: string): ImageOptions {\n const trimmed = source.trim();\n if (!trimmed) return {};\n let value: unknown;\n try {\n value = JSON.parse(staticJson(trimmed, id));\n } catch (error) {\n if (error instanceof Error && error.message.startsWith(\"@askrjs/vite\")) throw error;\n throw new Error(`@askrjs/vite could not parse image() options in ${id}.`, { cause: error });\n }\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(`@askrjs/vite image() options in ${id} must be an object literal.`);\n }\n return value as ImageOptions;\n}\n\nfunction findCallEnd(code: string, start: number): number {\n let depth = 1;\n let quote = \"\";\n let escaped = false;\n for (let index = start; index < code.length; index += 1) {\n const character = code[index]!;\n if (quote) {\n if (escaped) escaped = false;\n else if (character === \"\\\\\") escaped = true;\n else if (character === quote) quote = \"\";\n continue;\n }\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n if (character === \"(\") depth += 1;\n if (character === \")\") {\n depth -= 1;\n if (depth === 0) return index;\n }\n }\n return -1;\n}\n\nfunction declarations(code: string, id: string): Declaration[] {\n const mask = imageDeclarationMask(code);\n if (!mask) return [];\n const output: Declaration[] = [];\n IMAGE_CALL.lastIndex = 0;\n for (let match = IMAGE_CALL.exec(code); match; match = IMAGE_CALL.exec(code)) {\n if (!mask[match.index]) continue;\n const afterUrl = IMAGE_CALL.lastIndex;\n const end = findCallEnd(code, afterUrl);\n if (end < 0) throw new Error(`@askrjs/vite found an unterminated image() call in ${id}.`);\n const remainder = code.slice(afterUrl, end).trim();\n if (remainder && !remainder.startsWith(\",\")) {\n throw new Error(`@askrjs/vite could not parse image() declaration in ${id}.`);\n }\n output.push({\n start: match.index,\n end: end + 1,\n source: match[2]!,\n options: staticOptions(remainder.replace(/^,/, \"\"), id),\n });\n IMAGE_CALL.lastIndex = end + 1;\n }\n return output;\n}\n\nfunction urlExpression(referenceId: string): string {\n return `import.meta.ROLLUP_FILE_URL_${referenceId}`;\n}\n\nfunction mime(format: EmittedVariant[\"format\"]): string {\n return format === \"jpeg\" ? \"image/jpeg\" : `image/${format}`;\n}\n\nfunction srcsetExpression(variants: readonly EmittedVariant[]): string {\n return `[${variants.map((variant) => `${urlExpression(variant.referenceId)} + ${JSON.stringify(` ${variant.width}w`)}`).join(\",\")}].join(\", \")`;\n}\n\nfunction imageExpression(processed: ProcessedImage): string {\n const fallbackVariants = processed.variants.filter(\n (variant) => variant.format === processed.fallback.format,\n );\n const modernFormats = [\"avif\", \"webp\"] as const;\n const sources = processed.passThrough\n ? []\n : modernFormats.flatMap((format) => {\n const variants = processed.variants.filter((variant) => variant.format === format);\n return variants.length === 0\n ? []\n : [`{type:${JSON.stringify(mime(format))},srcset:${srcsetExpression(variants)}}`];\n });\n return `image({__askrImage:true,src:${urlExpression(processed.fallback.referenceId)},${\n processed.passThrough ? \"\" : `srcset:${srcsetExpression(fallbackVariants)},`\n }width:${processed.fallback.width},height:${processed.fallback.height},sources:[${sources.join(\",\")}]})`;\n}\n\nfunction builtUrl(base: string, fileName: string): string {\n if (/^https?:\\/\\//.test(base))\n return new URL(fileName, base.endsWith(\"/\") ? base : `${base}/`).href;\n if (base === \"\" || base === \"./\" || base === \".\")\n return `${base === \".\" ? \"./\" : base}${fileName}`;\n return `${base.endsWith(\"/\") ? base : `${base}/`}${fileName}`;\n}\n\nfunction responsiveMetadata(\n processed: ProcessedImage,\n fileName: (referenceId: string) => string,\n base: string,\n): ResponsiveImage {\n const url = (variant: EmittedVariant) => builtUrl(base, fileName(variant.referenceId));\n const srcset = (variants: readonly EmittedVariant[]) =>\n variants.map((variant) => `${url(variant)} ${variant.width}w`).join(\", \");\n const fallbackVariants = processed.variants.filter(\n (variant) => variant.format === processed.fallback.format,\n );\n return {\n __askrImage: true,\n src: url(processed.fallback),\n ...(processed.passThrough ? {} : { srcset: srcset(fallbackVariants) }),\n width: processed.fallback.width,\n height: processed.fallback.height,\n sources: processed.passThrough\n ? []\n : ([\"avif\", \"webp\"] as const).flatMap((format) => {\n const variants = processed.variants.filter((variant) => variant.format === format);\n return variants.length === 0 ? [] : [{ type: mime(format), srcset: srcset(variants) }];\n }),\n };\n}\n\nexport class ImagePipeline {\n readonly #options: ImagePipelineOptions;\n readonly #processed = new Map<string, ProcessedImage>();\n readonly #sharpLoader: SharpLoader;\n #config: ResolvedConfig | undefined;\n\n constructor(options: ImagePipelineOptions, sharpLoader: SharpLoader = defaultSharpLoader) {\n this.#options = options;\n this.#sharpLoader = sharpLoader;\n }\n\n configure(config: ResolvedConfig): void {\n this.#config = config;\n }\n\n async transform(\n context: AssetPluginContext,\n code: string,\n id: string,\n ): Promise<string | undefined> {\n const found = declarations(code, id);\n if (found.length === 0) return undefined;\n if (!this.#config) throw new Error(\"@askrjs/vite image pipeline was not configured.\");\n if (this.#config.command !== \"build\") {\n throw new Error(\"@askrjs/vite responsive image declarations currently require a Vite build.\");\n }\n const cacheDir = path.join(this.#config.root, \"node_modules/.cache/@askrjs/vite/images\");\n let transformed = code;\n for (const declaration of [...found].reverse()) {\n const sourcePath = path.resolve(path.dirname(id.split(\"?\", 1)[0]!), declaration.source);\n const key = declarationKey(sourcePath, declaration.options);\n let processed = this.#processed.get(key);\n if (!processed) {\n processed = await processImage(\n context,\n sourcePath,\n declaration.options,\n this.#options,\n cacheDir,\n this.#sharpLoader,\n );\n this.#processed.set(key, processed);\n }\n transformed = `${transformed.slice(0, declaration.start)}${imageExpression(processed)}${transformed.slice(declaration.end)}`;\n }\n return transformed;\n }\n\n async writeMetadata(context: AssetPluginContext): Promise<void> {\n if (!this.#config || this.#processed.size === 0) return;\n const entries: Record<string, ImageMetadataEntry> = {};\n for (const processed of [...this.#processed.values()].sort((left, right) =>\n left.declarationKey.localeCompare(right.declarationKey),\n )) {\n entries[processed.declarationKey] = {\n sourcePath: processed.sourcePath,\n sourceHash: processed.sourceHash,\n declarationOptions: processed.declarationOptions,\n transformKey: processed.transformKey,\n encoder: processed.encoder,\n image: responsiveMetadata(\n processed,\n (referenceId) => context.getFileName(referenceId),\n this.#config.base,\n ),\n };\n }\n const record: ImageMetadataRecord = {\n version: IMAGE_METADATA_VERSION,\n entries,\n };\n const metadataPath = path.join(this.#config.root, IMAGE_METADATA_PATH);\n await fs.mkdir(path.dirname(metadataPath), { recursive: true });\n await fs.writeFile(metadataPath, `${JSON.stringify(record, null, 2)}\\n`, \"utf8\");\n }\n}\n","import { createRequire } from \"node:module\";\nimport type { Plugin } from \"vite\";\nimport { optimizeTemplateOutput } from \"./template-optimizer\";\nimport { ImagePipeline } from \"./image-pipeline\";\nimport type { ImagePipelineOptions } from \"./image-types\";\n\nconst require = createRequire(import.meta.url);\ntype TransformWithOxc = (typeof import(\"vite\"))[\"transformWithOxc\"];\nlet transformWithOxcPromise: Promise<TransformWithOxc> | undefined;\n\nasync function loadTransformWithOxc(): Promise<TransformWithOxc> {\n transformWithOxcPromise ??= (async () => {\n for (const packageName of [\"vite-plus\", \"vite\"] as const) {\n try {\n const buildTool = await import(packageName);\n if (typeof buildTool.transformWithOxc === \"function\") {\n return buildTool.transformWithOxc as TransformWithOxc;\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ERR_MODULE_NOT_FOUND\") throw error;\n }\n }\n throw new Error(\"@askrjs/vite requires either vite or vite-plus to transform JSX.\");\n })();\n return transformWithOxcPromise;\n}\n\n/** Options accepted by {@link askrVitePlugin}. */\nexport interface AskrVitePluginOptions {\n /** Transform `.jsx`/`.tsx` files with the Askr JSX runtime. Defaults to `true`. */\n transformJsx?: boolean;\n /** Hoist repeated JSX class/style literals using parsed compiled output. Defaults to `false`. */\n optimizeTemplates?: boolean;\n ssrPrecompile?: boolean;\n /** Opt into declared responsive image transforms. */\n images?: boolean | ImagePipelineOptions;\n}\n\n/**\n * Portable public plugin identity.\n *\n * Vite-compatible runners only require the plugin name. Keeping versioned Vite\n * hook types out of the installed declaration prevents consumers such as\n * vite-plus from comparing two distinct copies of Vite's recursive Plugin type.\n */\nexport interface AskrVitePlugin {\n readonly name: \"askr:vite\";\n}\n\n/**\n * Create the Askr Vite plugin, which transforms Askr JSX/TSX with oxc, wires\n * up dependency pre-bundling and aliasing for `@askrjs/askr`, and optionally\n * runs the responsive image pipeline and template optimizer.\n * JSX transform failures are reported through the active Vite/Rollup plugin\n * context with the source file and original transform detail.\n *\n * @param options Plugin configuration; all fields are optional.\n * @returns A Vite-compatible plugin object exposing the `askr:vite` name.\n */\nexport function askrVitePlugin(options: AskrVitePluginOptions = {}): AskrVitePlugin {\n const shouldTransform = options.transformJsx ?? true;\n const shouldOptimizeTemplates = options.optimizeTemplates ?? false;\n const imagePipeline = options.images\n ? new ImagePipeline(options.images === true ? {} : options.images)\n : undefined;\n const plugin = {\n name: \"askr:vite\" as const,\n enforce: \"pre\",\n config() {\n let askrEntry: string | null = null;\n try {\n askrEntry = require.resolve(\"@askrjs/askr\");\n } catch {\n askrEntry = null;\n }\n return {\n define: {\n __ASKR_OPTIMIZE_TEMPLATES__: JSON.stringify(shouldOptimizeTemplates),\n },\n resolve: {\n alias: askrEntry ? [{ find: \"@askrjs/askr\", replacement: askrEntry }] : [],\n dedupe: [\"@askrjs/askr\"],\n },\n optimizeDeps: {\n include: [\n \"@askrjs/askr\",\n \"@askrjs/askr/router\",\n \"@askrjs/askr/boot\",\n \"@askrjs/askr/control\",\n \"@askrjs/askr/fx\",\n \"@askrjs/askr/resources\",\n \"@askrjs/askr/data\",\n \"@askrjs/askr/foundations\",\n \"@askrjs/askr/foundations/icon\",\n \"@askrjs/askr/foundations/interactions\",\n \"@askrjs/askr/foundations/state\",\n \"@askrjs/askr/foundations/structures\",\n \"@askrjs/askr/foundations/utilities\",\n \"@askrjs/askr/jsx-runtime\",\n \"@askrjs/askr/jsx-dev-runtime\",\n ],\n },\n oxc: {\n jsx: { runtime: \"automatic\", importSource: \"@askrjs/askr\" },\n jsxInject: \"import { jsx, jsxs, Fragment } from '@askrjs/askr/jsx-runtime';\",\n },\n };\n },\n configResolved(config) {\n imagePipeline?.configure(config);\n },\n async transform(code, id) {\n if (id.includes(\"node_modules\")) return null;\n const imageTransformed = imagePipeline\n ? await imagePipeline.transform(this, code, id)\n : undefined;\n const input = imageTransformed ?? code;\n if (!shouldTransform || !/\\.(jsx|tsx)$/.test(id)) {\n return imageTransformed ? { code: imageTransformed, map: null } : null;\n }\n try {\n const transformWithOxc = await loadTransformWithOxc();\n const result = await transformWithOxc(input, id, {\n lang: id.endsWith(\".tsx\") ? \"tsx\" : \"jsx\",\n jsx: { runtime: \"automatic\", importSource: \"@askrjs/askr\" },\n sourcemap: true,\n });\n if (!result?.code) return null;\n return {\n code: shouldOptimizeTemplates ? optimizeTemplateOutput(result.code) : result.code,\n map: result.map,\n };\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n this.error(`@askrjs/vite failed to transform ${id}: ${detail}`);\n }\n },\n async writeBundle() {\n await imagePipeline?.writeMetadata(this);\n },\n } satisfies Plugin;\n return plugin;\n}\n"],"mappings":";;;;;;;;AAEA,MAAM,kCAAkB,IAAI,IAAI;CAAC;CAAS;CAAa;AAAO,CAAC;AAC/D,MAAM,qBAAqB;AAC3B,MAAM,gCAAgB,IAAI,IAAI;CAAC;CAAO;CAAQ;AAAQ,CAAC;AAQvD,SAAS,aAAa,WAA2E;CAC/F,OAAO,UAAU,SAAS,SAAS,eAC/B,UAAU,SAAS,OACnB,UAAU,SAAS;AACzB;AAEA,SAAS,wBAAwB,SAA+D;CAC9F,MAAM,4BAAY,IAAI,IAAY;CAElC,KAAK,MAAM,aAAa,QAAQ,MAAM;EACpC,IAAI,UAAU,SAAS,uBAAuB,UAAU,OAAO,UAAU,oBACvE;EAGF,KAAK,MAAM,aAAa,UAAU,YAChC,IACE,UAAU,SAAS,qBACnB,cAAc,IAAI,OAAO,aAAa,SAAS,CAAC,CAAC,GAEjD,UAAU,IAAI,UAAU,MAAM,IAAI;CAGxC;CAEA,OAAO;AACT;AAEA,SAAS,iBACP,UACA,MACA,YACA;CACA,IACE,SAAS,SAAS,UAClB,SAAS,YACT,SAAS,UACT,SAAS,IAAI,SAAS,gBACtB,CAAC,gBAAgB,IAAI,SAAS,IAAI,IAAI,KACtC,SAAS,MAAM,SAAS,aACxB,OAAO,SAAS,MAAM,UAAU,UAEhC;CAGF,MAAM,UAAU,KAAK,MAAM,SAAS,MAAM,OAAO,SAAS,MAAM,G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ChE;EACF;EACA,MAAM,cAAc;GAClB,MAAM,eAAe,cAAc,IAAI;EACzC;CAEU;AACd"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["mime","#options","#processed","#sharpLoader","#config"],"sources":["../src/source-map-rewrites.ts","../src/template-optimizer.ts","../src/image-lexical.ts","../src/image-declarations.ts","../src/image-inspection.ts","../src/image-transform.ts","../src/image-pipeline.ts","../src/jsx-plugin.ts"],"sourcesContent":["export interface TextEdit {\n start: number;\n end: number;\n replacement: string;\n mapTo?: number;\n}\n\nexport interface RawSourceMap {\n version: number;\n mappings: string;\n names?: string[];\n sources?: string[];\n sourcesContent?: Array<string | null>;\n file?: string;\n sourceRoot?: string;\n}\n\nconst BASE64 = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\nconst BASE64_VALUES = new Map([...BASE64].map((character, index) => [character, index]));\n\nfunction decodeVlq(value: string, cursor: { value: number }): number {\n let result = 0;\n let shift = 0;\n for (;;) {\n const digit = BASE64_VALUES.get(value[cursor.value++]);\n if (digit === undefined) throw new Error(\"Invalid sourcemap VLQ segment.\");\n result += (digit & 31) << shift;\n if ((digit & 32) === 0) break;\n shift += 5;\n }\n const negative = (result & 1) === 1;\n result >>= 1;\n return negative ? -result : result;\n}\n\nfunction encodeVlq(value: number): string {\n let remaining = (Math.abs(value) << 1) | (value < 0 ? 1 : 0);\n let output = \"\";\n do {\n let digit = remaining & 31;\n remaining >>>= 5;\n if (remaining > 0) digit |= 32;\n output += BASE64[digit];\n } while (remaining > 0);\n return output;\n}\n\nfunction decodeMappings(value: string): number[][][] {\n const lines: number[][][] = [];\n let source = 0;\n let originalLine = 0;\n let originalColumn = 0;\n let name = 0;\n for (const encodedLine of value.split(\";\")) {\n const segments: number[][] = [];\n let generatedColumn = 0;\n for (const encoded of encodedLine.split(\",\")) {\n if (!encoded) continue;\n const cursor = { value: 0 };\n generatedColumn += decodeVlq(encoded, cursor);\n const segment = [generatedColumn];\n if (cursor.value < encoded.length) {\n source += decodeVlq(encoded, cursor);\n originalLine += decodeVlq(encoded, cursor);\n originalColumn += decodeVlq(encoded, cursor);\n segment.push(source, originalLine, originalColumn);\n if (cursor.value < encoded.length) {\n name += decodeVlq(encoded, cursor);\n segment.push(name);\n }\n }\n segments.push(segment);\n }\n lines.push(segments);\n }\n return lines;\n}\n\nfunction encodeMappings(lines: number[][][]): string {\n let previousSource = 0;\n let previousOriginalLine = 0;\n let previousOriginalColumn = 0;\n let previousName = 0;\n return lines\n .map((segments) => {\n let previousGeneratedColumn = 0;\n return segments\n .map((segment) => {\n let encoded = encodeVlq(segment[0]! - previousGeneratedColumn);\n previousGeneratedColumn = segment[0]!;\n if (segment.length >= 4) {\n encoded += encodeVlq(segment[1]! - previousSource);\n encoded += encodeVlq(segment[2]! - previousOriginalLine);\n encoded += encodeVlq(segment[3]! - previousOriginalColumn);\n previousSource = segment[1]!;\n previousOriginalLine = segment[2]!;\n previousOriginalColumn = segment[3]!;\n if (segment.length === 5) {\n encoded += encodeVlq(segment[4]! - previousName);\n previousName = segment[4]!;\n }\n }\n return encoded;\n })\n .join(\",\");\n })\n .join(\";\");\n}\n\nfunction lineStarts(code: string): number[] {\n const starts = [0];\n for (let index = 0; index < code.length; index += 1) {\n if (code[index] === \"\\n\") starts.push(index + 1);\n }\n return starts;\n}\n\nfunction offsetAt(starts: number[], line: number, column: number): number {\n return (starts[line] ?? starts[starts.length - 1]!) + column;\n}\n\nfunction positionAt(starts: number[], offset: number): [number, number] {\n let low = 0;\n let high = starts.length;\n while (low + 1 < high) {\n const middle = (low + high) >>> 1;\n if (starts[middle]! <= offset) low = middle;\n else high = middle;\n }\n return [low, offset - starts[low]!];\n}\n\nfunction forwardOffset(offset: number, edits: readonly TextEdit[]): number {\n let delta = 0;\n for (const edit of edits) {\n if (offset < edit.start) break;\n if (offset < edit.end) return edit.start + delta;\n delta += edit.replacement.length - (edit.end - edit.start);\n }\n return offset + delta;\n}\n\nfunction reverseOffset(offset: number, edits: readonly TextEdit[]): number {\n let delta = 0;\n for (const edit of edits) {\n const generatedStart = edit.start + delta;\n const generatedEnd = generatedStart + edit.replacement.length;\n if (offset < generatedStart) break;\n if (offset < generatedEnd) return edit.start;\n delta += edit.replacement.length - (edit.end - edit.start);\n }\n return offset - delta;\n}\n\nfunction normalize(lines: number[][][]): number[][][] {\n return lines.map((segments) => {\n const sorted = segments.sort((left, right) => left[0]! - right[0]!);\n return sorted.filter((segment, index) => index === 0 || segment[0] !== sorted[index - 1]![0]);\n });\n}\n\nfunction mappingAt(lines: number[][][], starts: number[], offset: number): number[] | undefined {\n const [line, column] = positionAt(starts, offset);\n let match: number[] | undefined;\n for (const segment of lines[line] ?? []) {\n if (segment[0]! > column) break;\n if (segment.length >= 4) match = segment;\n }\n return match;\n}\n\n/** Move generated coordinates after deterministic text edits. */\nexport function remapGenerated(\n map: RawSourceMap,\n before: string,\n after: string,\n edits: readonly TextEdit[],\n): RawSourceMap {\n const beforeStarts = lineStarts(before);\n const afterStarts = lineStarts(after);\n const decoded = decodeMappings(map.mappings);\n const output: number[][][] = Array.from({ length: afterStarts.length }, () => []);\n for (const [line, segments] of decoded.entries()) {\n for (const segment of segments) {\n const offset = forwardOffset(offsetAt(beforeStarts, line, segment[0]!), edits);\n const [nextLine, nextColumn] = positionAt(afterStarts, offset);\n output[nextLine]!.push([nextColumn, ...segment.slice(1)]);\n }\n }\n let delta = 0;\n for (const edit of edits) {\n if (edit.mapTo !== undefined) {\n const mapped = mappingAt(decoded, beforeStarts, edit.mapTo);\n if (mapped) {\n const [line, column] = positionAt(afterStarts, edit.start + delta);\n output[line]!.push([column, ...mapped.slice(1)]);\n }\n }\n delta += edit.replacement.length - (edit.end - edit.start);\n }\n return { ...map, mappings: encodeMappings(normalize(output)) };\n}\n\n/** Move original coordinates back through deterministic text edits. */\nexport function remapOriginal(\n map: RawSourceMap,\n original: string,\n rewritten: string,\n edits: readonly TextEdit[],\n): RawSourceMap {\n const originalStarts = lineStarts(original);\n const rewrittenStarts = lineStarts(rewritten);\n const lines = decodeMappings(map.mappings);\n for (const segments of lines) {\n for (const segment of segments) {\n if (segment.length < 4 || segment[1] !== 0) continue;\n const offset = reverseOffset(offsetAt(rewrittenStarts, segment[2]!, segment[3]!), edits);\n const [line, column] = positionAt(originalStarts, offset);\n segment[2] = line;\n segment[3] = column;\n }\n }\n return {\n ...map,\n mappings: encodeMappings(lines),\n sourcesContent: map.sources?.map((_source, index) =>\n index === 0 ? original : (map.sourcesContent?.[index] ?? null),\n ),\n };\n}\n\n/** Build a complete map for a rewritten source when no downstream map exists. */\nexport function sourceMapForRewrite(\n original: string,\n rewritten: string,\n edits: readonly TextEdit[],\n id: string,\n): RawSourceMap {\n const originalStarts = lineStarts(original);\n const rewrittenStarts = lineStarts(rewritten);\n const lines: number[][][] = Array.from({ length: rewrittenStarts.length }, () => []);\n for (let offset = 0; offset < rewritten.length; offset += 1) {\n const [generatedLine, generatedColumn] = positionAt(rewrittenStarts, offset);\n const [originalLine, originalColumn] = positionAt(originalStarts, reverseOffset(offset, edits));\n lines[generatedLine]!.push([generatedColumn, 0, originalLine, originalColumn]);\n }\n return {\n version: 3,\n names: [],\n sources: [id],\n sourcesContent: [original],\n mappings: encodeMappings(lines),\n };\n}\n\nexport function traceSourcePosition(\n map: RawSourceMap,\n line: number,\n column: number,\n): { line: number; column: number } | undefined {\n const segments = decodeMappings(map.mappings)[line] ?? [];\n let match: number[] | undefined;\n for (const segment of segments) {\n if (segment[0]! > column) break;\n if (segment.length >= 4) match = segment;\n }\n return match ? { line: match[2]!, column: match[3]! } : undefined;\n}\n","import { parseSync, Visitor, type ObjectProperty } from \"oxc-parser\";\nimport type { TextEdit } from \"./source-map-rewrites\";\n\nconst OPTIMIZED_PROPS = new Set([\"class\", \"className\", \"style\"]);\nconst JSX_RUNTIME_SOURCE = \"@askrjs/askr/jsx-runtime\";\nconst JSX_FACTORIES = new Set([\"jsx\", \"jsxs\", \"jsxDEV\"]);\n\ntype Candidate = {\n literal: string;\n start: number;\n end: number;\n};\n\nfunction importedName(specifier: { imported: { type: string; name?: string; value?: unknown } }) {\n return specifier.imported.type === \"Identifier\"\n ? specifier.imported.name\n : specifier.imported.value;\n}\n\nfunction collectRuntimeFactories(program: ReturnType<typeof parseSync>[\"program\"]): Set<string> {\n const factories = new Set<string>();\n\n for (const statement of program.body) {\n if (statement.type !== \"ImportDeclaration\" || statement.source.value !== JSX_RUNTIME_SOURCE) {\n continue;\n }\n\n for (const specifier of statement.specifiers) {\n if (\n specifier.type === \"ImportSpecifier\" &&\n JSX_FACTORIES.has(String(importedName(specifier)))\n ) {\n factories.add(specifier.local.name);\n }\n }\n }\n\n return factories;\n}\n\nfunction collectCandidate(\n property: ObjectProperty,\n code: string,\n candidates: Map<string, Candidate[]>,\n) {\n if (\n property.kind !== \"init\" ||\n property.computed ||\n property.method ||\n property.key.type !== \"Identifier\" ||\n !OPTIMIZED_PROPS.has(property.key.name) ||\n property.value.type !== \"Literal\" ||\n typeof property.value.value !== \"string\"\n ) {\n return;\n }\n\n const literal = code.slice(property.value.start, property.value.end);\n const cacheKey = `${property.key.name}:${literal}`;\n const group = candidates.get(cacheKey) ?? [];\n group.push({\n literal,\n start: property.value.start,\n end: property.value.end,\n });\n candidates.set(cacheKey, group);\n}\n\nexport interface OptimizedTemplateOutput {\n code: string;\n edits: TextEdit[];\n}\n\nexport function optimizeTemplateOutputWithEdits(code: string): OptimizedTemplateOutput {\n const parsed = parseSync(\"askr-compiled.js\", code, {\n lang: \"js\",\n sourceType: \"module\",\n });\n if (parsed.errors.length > 0) return { code, edits: [] };\n\n const runtimeFactories = collectRuntimeFactories(parsed.program);\n if (runtimeFactories.size === 0) return { code, edits: [] };\n\n const candidates = new Map<string, Candidate[]>();\n const identifiers = new Set<string>();\n new Visitor({\n Identifier(identifier) {\n identifiers.add(identifier.name);\n },\n CallExpression(call) {\n if (\n call.callee.type !== \"Identifier\" ||\n !runtimeFactories.has(call.callee.name) ||\n call.arguments[1]?.type !== \"ObjectExpression\"\n ) {\n return;\n }\n\n for (const property of call.arguments[1].properties) {\n if (property.type === \"Property\") {\n collectCandidate(property, code, candidates);\n }\n }\n },\n }).visit(parsed.program);\n\n const declarations: string[] = [];\n const replacements: Array<{ start: number; end: number; identifier: string }> = [];\n let hoistIndex = 0;\n for (const group of candidates.values()) {\n if (group.length < 2) continue;\n\n let identifier: string;\n do {\n identifier = `__askrStaticLiteral${hoistIndex++}`;\n } while (identifiers.has(identifier));\n identifiers.add(identifier);\n declarations.push(`const ${identifier} = ${group[0].literal};`);\n for (const candidate of group) {\n replacements.push({ start: candidate.start, end: candidate.end, identifier });\n }\n }\n\n if (declarations.length === 0) return { code, edits: [] };\n\n const prefix = `${declarations.join(\"\\n\")}\\n`;\n const edits: TextEdit[] = [\n { start: 0, end: 0, replacement: prefix, mapTo: replacements[0]!.start },\n ...replacements\n .map(({ start, end, identifier }) => ({ start, end, replacement: identifier }))\n .sort((left, right) => left.start - right.start),\n ];\n let optimized = code;\n for (const replacement of replacements.sort((left, right) => right.start - left.start)) {\n optimized =\n optimized.slice(0, replacement.start) +\n replacement.identifier +\n optimized.slice(replacement.end);\n }\n return { code: `${prefix}${optimized}`, edits };\n}\n\nexport function optimizeTemplateOutput(code: string): string {\n return optimizeTemplateOutputWithEdits(code).code;\n}\n","const IMAGE_IMPORT = /from\\s+[\"']@askrjs\\/vite\\/image[\"']/g;\n\nfunction lexicalCodeMask(source: string): Uint8Array {\n const mask = new Uint8Array(source.length);\n let state: \"code\" | \"single\" | \"double\" | \"template\" | \"line-comment\" | \"block-comment\" = \"code\";\n let escaped = false;\n for (let index = 0; index < source.length; index += 1) {\n const character = source[index]!;\n const next = source[index + 1];\n if (state === \"code\") {\n if (character === \"/\" && next === \"/\") {\n state = \"line-comment\";\n index += 1;\n } else if (character === \"/\" && next === \"*\") {\n state = \"block-comment\";\n index += 1;\n } else if (character === \"'\") state = \"single\";\n else if (character === '\"') state = \"double\";\n else if (character === \"`\") state = \"template\";\n else mask[index] = 1;\n continue;\n }\n if (state === \"line-comment\") {\n if (character === \"\\n\" || character === \"\\r\") {\n state = \"code\";\n mask[index] = 1;\n }\n continue;\n }\n if (state === \"block-comment\") {\n if (character === \"*\" && next === \"/\") {\n state = \"code\";\n index += 1;\n }\n continue;\n }\n if (escaped) escaped = false;\n else if (character === \"\\\\\") escaped = true;\n else if (\n (state === \"single\" && character === \"'\") ||\n (state === \"double\" && character === '\"') ||\n (state === \"template\" && character === \"`\")\n ) {\n state = \"code\";\n }\n }\n return mask;\n}\n\nexport function imageDeclarationMask(code: string): Uint8Array | undefined {\n const mask = lexicalCodeMask(code);\n IMAGE_IMPORT.lastIndex = 0;\n for (let match = IMAGE_IMPORT.exec(code); match; match = IMAGE_IMPORT.exec(code)) {\n if (mask[match.index]) return mask;\n }\n return undefined;\n}\n","import { imageDeclarationMask } from \"./image-lexical\";\nimport type { ImageOptions } from \"./image-types\";\n\nexport interface ImageDeclaration {\n start: number;\n end: number;\n source: string;\n options: ImageOptions;\n}\n\nconst IMAGE_CALL = /\\bimage\\s*\\(\\s*new\\s+URL\\s*\\(\\s*([\"'])([^\"']+)\\1\\s*,\\s*import\\.meta\\.url\\s*\\)/g;\n\nfunction staticJson(source: string, id: string): string {\n let output = \"\";\n for (let index = 0; index < source.length;) {\n const character = source[index]!;\n if (/\\s/.test(character) || \"{}[]:\".includes(character)) {\n output += character;\n index += 1;\n continue;\n }\n if (character === \",\") {\n let next = index + 1;\n while (/\\s/.test(source[next] ?? \"\")) next += 1;\n if (source[next] !== \"}\" && source[next] !== \"]\") output += character;\n index += 1;\n continue;\n }\n if (character === '\"' || character === \"'\") {\n let end = index + 1;\n while (end < source.length && source[end] !== character) {\n if (source[end] === \"\\\\\") {\n throw new Error(\n `@askrjs/vite image() option strings in ${id} cannot contain escape sequences.`,\n );\n }\n end += 1;\n }\n if (end >= source.length) {\n throw new Error(`@askrjs/vite found an unterminated image option in ${id}.`);\n }\n output += JSON.stringify(source.slice(index + 1, end));\n index = end + 1;\n continue;\n }\n const number = /^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?(?:e[+-]?\\d+)?/i.exec(source.slice(index));\n if (number) {\n output += number[0];\n index += number[0].length;\n continue;\n }\n const identifier = /^[A-Za-z_]\\w*/.exec(source.slice(index));\n if (identifier) {\n let next = index + identifier[0].length;\n while (/\\s/.test(source[next] ?? \"\")) next += 1;\n if (source[next] === \":\") output += JSON.stringify(identifier[0]);\n else if ([\"true\", \"false\", \"null\"].includes(identifier[0])) output += identifier[0];\n else {\n throw new Error(\n `@askrjs/vite image() options in ${id} must not reference ${identifier[0]}; use a static object literal.`,\n );\n }\n index += identifier[0].length;\n continue;\n }\n throw new Error(\n `@askrjs/vite image() options in ${id} must be a static object literal so builds and direct SSG imports agree.`,\n );\n }\n return output;\n}\n\nfunction staticOptions(source: string, id: string): ImageOptions {\n const trimmed = source.trim();\n if (!trimmed) return {};\n let value: unknown;\n try {\n value = JSON.parse(staticJson(trimmed, id));\n } catch (error) {\n if (error instanceof Error && error.message.startsWith(\"@askrjs/vite\")) throw error;\n throw new Error(`@askrjs/vite could not parse image() options in ${id}.`, { cause: error });\n }\n if (!value || typeof value !== \"object\" || Array.isArray(value)) {\n throw new Error(`@askrjs/vite image() options in ${id} must be an object literal.`);\n }\n return value as ImageOptions;\n}\n\nfunction findCallEnd(code: string, start: number): number {\n let depth = 1;\n let quote = \"\";\n let escaped = false;\n for (let index = start; index < code.length; index += 1) {\n const character = code[index]!;\n if (quote) {\n if (escaped) escaped = false;\n else if (character === \"\\\\\") escaped = true;\n else if (character === quote) quote = \"\";\n continue;\n }\n if (character === '\"' || character === \"'\") {\n quote = character;\n continue;\n }\n if (character === \"(\") depth += 1;\n if (character === \")\") {\n depth -= 1;\n if (depth === 0) return index;\n }\n }\n return -1;\n}\n\nexport function imageDeclarations(code: string, id: string): ImageDeclaration[] {\n const mask = imageDeclarationMask(code);\n if (!mask) return [];\n const output: ImageDeclaration[] = [];\n IMAGE_CALL.lastIndex = 0;\n for (let match = IMAGE_CALL.exec(code); match; match = IMAGE_CALL.exec(code)) {\n if (!mask[match.index]) continue;\n const afterUrl = IMAGE_CALL.lastIndex;\n const end = findCallEnd(code, afterUrl);\n if (end < 0) throw new Error(`@askrjs/vite found an unterminated image() call in ${id}.`);\n const remainder = code.slice(afterUrl, end).trim();\n if (remainder && !remainder.startsWith(\",\")) {\n throw new Error(`@askrjs/vite could not parse image() declaration in ${id}.`);\n }\n output.push({\n start: match.index,\n end: end + 1,\n source: match[2]!,\n options: staticOptions(remainder.replace(/^,/, \"\"), id),\n });\n IMAGE_CALL.lastIndex = end + 1;\n }\n return output;\n}\n","export type AssetFormat = \"avif\" | \"webp\" | \"jpeg\" | \"png\" | \"gif\" | \"svg\";\n\nexport interface SourceInspection {\n width: number;\n height: number;\n format: AssetFormat;\n transformable: boolean;\n animated: boolean;\n}\n\nfunction positiveDimensions(\n width: number,\n height: number,\n format: AssetFormat,\n transformable: boolean,\n animated = false,\n): SourceInspection | undefined {\n return width > 0 && height > 0 ? { width, height, format, transformable, animated } : undefined;\n}\n\nfunction inspectPng(source: Buffer): SourceInspection | undefined {\n if (\n source.length < 24 ||\n !source.subarray(0, 8).equals(Buffer.from([137, 80, 78, 71, 13, 10, 26, 10]))\n ) {\n return undefined;\n }\n return positiveDimensions(\n source.readUInt32BE(16),\n source.readUInt32BE(20),\n \"png\",\n true,\n source.includes(Buffer.from(\"acTL\")),\n );\n}\n\nfunction inspectGif(source: Buffer): SourceInspection | undefined {\n if (source.length < 10 || !/^GIF8[79]a$/.test(source.subarray(0, 6).toString(\"ascii\"))) {\n return undefined;\n }\n return positiveDimensions(source.readUInt16LE(6), source.readUInt16LE(8), \"gif\", false, true);\n}\n\nfunction exifOrientation(segment: Buffer): number | undefined {\n if (segment.length < 14 || segment.subarray(0, 6).toString(\"binary\") !== \"Exif\\0\\0\") {\n return undefined;\n }\n const tiff = 6;\n const byteOrder = segment.subarray(tiff, tiff + 2).toString(\"ascii\");\n const littleEndian = byteOrder === \"II\";\n if (!littleEndian && byteOrder !== \"MM\") return undefined;\n const read16 = (offset: number): number | undefined => {\n const absolute = tiff + offset;\n if (absolute < tiff || absolute + 2 > segment.length) return undefined;\n return littleEndian ? segment.readUInt16LE(absolute) : segment.readUInt16BE(absolute);\n };\n const read32 = (offset: number): number | undefined => {\n const absolute = tiff + offset;\n if (absolute < tiff || absolute + 4 > segment.length) return undefined;\n return littleEndian ? segment.readUInt32LE(absolute) : segment.readUInt32BE(absolute);\n };\n if (read16(2) !== 42) return undefined;\n const directoryOffset = read32(4);\n if (directoryOffset === undefined) return undefined;\n const entries = read16(directoryOffset);\n if (entries === undefined) return undefined;\n for (let index = 0; index < entries; index += 1) {\n const entry = directoryOffset + 2 + index * 12;\n if (read16(entry) !== 0x0112 || read16(entry + 2) !== 3 || read32(entry + 4) !== 1) {\n continue;\n }\n const orientation = read16(entry + 8);\n return orientation && orientation >= 1 && orientation <= 8 ? orientation : undefined;\n }\n return undefined;\n}\n\nfunction inspectJpeg(source: Buffer): SourceInspection | undefined {\n if (source.length < 4 || source[0] !== 0xff || source[1] !== 0xd8) return undefined;\n const startOfFrame = new Set([\n 0xc0, 0xc1, 0xc2, 0xc3, 0xc5, 0xc6, 0xc7, 0xc9, 0xca, 0xcb, 0xcd, 0xce, 0xcf,\n ]);\n let orientation: number | undefined;\n let offset = 2;\n while (offset + 8 < source.length) {\n if (source[offset] !== 0xff) {\n offset += 1;\n continue;\n }\n while (source[offset] === 0xff) offset += 1;\n const marker = source[offset++]!;\n if (marker === 0xd8 || marker === 0xd9 || marker === 0x01) continue;\n if (marker >= 0xd0 && marker <= 0xd7) continue;\n if (offset + 2 > source.length) break;\n const length = source.readUInt16BE(offset);\n if (length < 2 || offset + length > source.length) break;\n if (marker === 0xe1) {\n orientation = exifOrientation(source.subarray(offset + 2, offset + length)) ?? orientation;\n }\n if (startOfFrame.has(marker) && length >= 7) {\n const width = source.readUInt16BE(offset + 5);\n const height = source.readUInt16BE(offset + 3);\n return positiveDimensions(\n orientation !== undefined && orientation >= 5 ? height : width,\n orientation !== undefined && orientation >= 5 ? width : height,\n \"jpeg\",\n true,\n );\n }\n offset += length;\n }\n return undefined;\n}\n\nfunction inspectSvg(source: Buffer): SourceInspection | undefined {\n const openingTag = source\n .subarray(0, 16_384)\n .toString(\"utf8\")\n .match(/<svg\\b[^>]*>/i)?.[0];\n if (!openingTag) return undefined;\n const numberAttribute = (name: string): number | undefined => {\n const value = openingTag.match(new RegExp(`\\\\b${name}\\\\s*=\\\\s*[\"']\\\\s*([0-9.]+)`, \"i\"))?.[1];\n const parsed = value ? Number(value) : Number.NaN;\n return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;\n };\n let width = numberAttribute(\"width\");\n let height = numberAttribute(\"height\");\n const viewBox = openingTag\n .match(/\\bviewBox\\s*=\\s*[\"']\\s*[-+0-9.e]+[ ,]+[-+0-9.e]+[ ,]+([-+0-9.e]+)[ ,]+([-+0-9.e]+)/i)\n ?.slice(1)\n .map(Number);\n if (!width && viewBox?.[0] && viewBox[0] > 0) width = viewBox[0];\n if (!height && viewBox?.[1] && viewBox[1] > 0) height = viewBox[1];\n if (!width && height && viewBox?.[0] && viewBox?.[1]) width = height * (viewBox[0] / viewBox[1]);\n if (!height && width && viewBox?.[0] && viewBox?.[1]) height = width / (viewBox[0] / viewBox[1]);\n return width && height ? positiveDimensions(width, height, \"svg\", false) : undefined;\n}\n\nfunction inspectWebp(source: Buffer): SourceInspection | undefined {\n if (\n source.length < 30 ||\n source.subarray(0, 4).toString(\"ascii\") !== \"RIFF\" ||\n source.subarray(8, 12).toString(\"ascii\") !== \"WEBP\"\n ) {\n return undefined;\n }\n const chunk = source.subarray(12, 16).toString(\"ascii\");\n if (chunk === \"VP8X\") {\n const width = 1 + source.readUIntLE(24, 3);\n const height = 1 + source.readUIntLE(27, 3);\n return positiveDimensions(width, height, \"webp\", false, Boolean(source[20]! & 0x02));\n }\n if (chunk === \"VP8 \") {\n return positiveDimensions(\n source.readUInt16LE(26) & 0x3fff,\n source.readUInt16LE(28) & 0x3fff,\n \"webp\",\n false,\n );\n }\n if (chunk === \"VP8L\" && source[20] === 0x2f) {\n const bits = source.readUInt32LE(21);\n return positiveDimensions(1 + (bits & 0x3fff), 1 + ((bits >>> 14) & 0x3fff), \"webp\", false);\n }\n return undefined;\n}\n\nfunction inspectAvif(source: Buffer): SourceInspection | undefined {\n if (source.length < 24 || source.subarray(4, 8).toString(\"ascii\") !== \"ftyp\") return undefined;\n const typeOffset = source.indexOf(Buffer.from(\"ispe\"));\n if (typeOffset < 0 || typeOffset + 16 > source.length) return undefined;\n return positiveDimensions(\n source.readUInt32BE(typeOffset + 8),\n source.readUInt32BE(typeOffset + 12),\n \"avif\",\n false,\n );\n}\n\nexport function inspectSource(sourcePath: string, source: Buffer): SourceInspection {\n const inspection =\n inspectPng(source) ??\n inspectGif(source) ??\n inspectJpeg(source) ??\n inspectSvg(source) ??\n inspectWebp(source) ??\n inspectAvif(source);\n if (!inspection) {\n throw new Error(\n `@askrjs/vite could not determine intrinsic dimensions for pass-through image ${sourcePath}.`,\n );\n }\n return inspection;\n}\n","import { createHash } from \"node:crypto\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { inspectSource, type AssetFormat } from \"./image-inspection\";\nimport { normalizeDeclarationOptions, normalizeImageOptions } from \"./image-options\";\nimport type { ImageOptions, ImageOutputFormat, ImagePipelineOptions } from \"./image-types\";\n\ntype SharpFactory = (typeof import(\"sharp\"))[\"default\"];\nexport type SharpLoader = () => Promise<SharpFactory>;\ntype TransformFormat = \"avif\" | \"webp\" | \"jpeg\" | \"png\";\n\nexport interface EmittedVariant {\n referenceId: string;\n width: number;\n height: number;\n format: AssetFormat;\n mime: string;\n}\n\nexport interface AssetPluginContext {\n emitFile(file: { type: \"asset\"; name: string; source: string | Uint8Array }): string;\n getFileName(referenceId: string): string;\n}\n\nexport interface ProcessedImage {\n declarationKey: string;\n sourcePath: string;\n sourceHash: string;\n declarationOptions: ImageOptions;\n transformKey: string;\n encoder: string;\n fallback: EmittedVariant;\n variants: EmittedVariant[];\n passThrough: boolean;\n}\n\nfunction hash(value: string | Buffer): string {\n return createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nexport function declarationKey(sourcePath: string, options: ImageOptions): string {\n return hash(`${sourcePath}\\0${JSON.stringify(normalizeDeclarationOptions(options))}`);\n}\n\nexport const defaultSharpLoader: SharpLoader = async () => (await import(\"sharp\")).default;\n\nasync function loadSharp(loader: SharpLoader): Promise<SharpFactory> {\n try {\n return await loader();\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ERR_MODULE_NOT_FOUND\") {\n throw new Error(\n '@askrjs/vite responsive images require the optional peer \"sharp\". Install sharp@^0.35.3 and rebuild.',\n { cause: error },\n );\n }\n throw error;\n }\n}\n\nfunction sourceFormat(format: string | undefined): \"jpeg\" | \"png\" | undefined {\n if (format === \"jpeg\" || format === \"jpg\") return \"jpeg\";\n return format === \"png\" ? \"png\" : undefined;\n}\n\nfunction extension(format: AssetFormat): string {\n return format === \"jpeg\" ? \"jpg\" : format;\n}\n\nfunction mime(format: AssetFormat): string {\n return format === \"jpeg\" ? \"image/jpeg\" : `image/${format}`;\n}\n\nfunction outputName(sourcePath: string, width: number, format: EmittedVariant[\"format\"]): string {\n const basename = path.basename(sourcePath, path.extname(sourcePath));\n return `${basename}-${width}.${extension(format)}`;\n}\n\nfunction outputHeight(\n width: number,\n sourceWidth: number,\n sourceHeight: number,\n aspectRatio: number | undefined,\n): number {\n return Math.max(1, Math.round(width / (aspectRatio ?? sourceWidth / sourceHeight)));\n}\n\nasync function encodedVariant(\n sharp: SharpFactory,\n source: Buffer,\n cacheDir: string,\n transformKey: string,\n width: number,\n height: number,\n format: TransformFormat,\n options: ReturnType<typeof normalizeImageOptions>,\n): Promise<Buffer> {\n const cachePath = path.join(cacheDir, `${transformKey}-${width}.${extension(format)}`);\n const cached = await fs.readFile(cachePath).catch(() => undefined);\n if (cached) return cached;\n\n let pipeline = sharp(source, { animated: false }).autoOrient();\n pipeline =\n options.fit === \"cover\"\n ? pipeline.resize({ width, height, fit: \"cover\", position: options.position })\n : pipeline.resize({ width, fit: \"inside\", withoutEnlargement: true });\n if (format === \"avif\") pipeline = pipeline.avif({ quality: options.quality.avif });\n else if (format === \"webp\") pipeline = pipeline.webp({ quality: options.quality.webp });\n else if (format === \"jpeg\") pipeline = pipeline.jpeg({ quality: options.quality.jpeg });\n else {\n pipeline = pipeline.png(\n options.quality.png === 100\n ? { compressionLevel: 9 }\n : { compressionLevel: 9, quality: options.quality.png },\n );\n }\n const encoded = await pipeline.toBuffer();\n await fs.mkdir(cacheDir, { recursive: true });\n await fs.writeFile(cachePath, encoded);\n return encoded;\n}\n\nfunction variantFormats(\n formats: readonly ImageOutputFormat[],\n fallback: \"jpeg\" | \"png\",\n): Array<\"avif\" | \"webp\" | \"jpeg\" | \"png\"> {\n const output: Array<\"avif\" | \"webp\" | \"jpeg\" | \"png\"> = [];\n for (const format of formats) {\n const resolved = format === \"source\" ? fallback : format;\n if (!output.includes(resolved)) output.push(resolved);\n }\n if (!output.includes(fallback)) output.push(fallback);\n return output;\n}\n\nfunction passThroughImage(\n context: AssetPluginContext,\n sourcePath: string,\n source: Buffer,\n width: number,\n height: number,\n format: AssetFormat,\n): { fallback: EmittedVariant; variants: EmittedVariant[] } {\n const referenceId = context.emitFile({ type: \"asset\", name: path.basename(sourcePath), source });\n const fallback = { referenceId, width, height, format, mime: mime(format) };\n return { fallback, variants: [fallback] };\n}\n\nexport async function processImage(\n context: AssetPluginContext,\n sourcePath: string,\n declarationOptions: ImageOptions,\n globalOptions: ImagePipelineOptions,\n cacheDir: string,\n sharpLoader: SharpLoader,\n): Promise<ProcessedImage> {\n const source = await fs.readFile(sourcePath);\n const sourceHash = hash(source);\n const normalized = normalizeImageOptions(globalOptions, declarationOptions);\n const inspection = inspectSource(sourcePath, source);\n const key = declarationKey(sourcePath, declarationOptions);\n const shouldPassThroughWithoutSharp =\n !inspection.transformable ||\n inspection.animated ||\n (normalized.fit === \"inside\" && inspection.width <= normalized.widths[0]!);\n if (shouldPassThroughWithoutSharp) {\n const encoder = \"passthrough\";\n return {\n declarationKey: key,\n sourcePath,\n sourceHash,\n declarationOptions: normalizeDeclarationOptions(declarationOptions),\n transformKey: hash(`${sourceHash}\\0${JSON.stringify(normalized)}\\0${encoder}`),\n encoder,\n ...passThroughImage(\n context,\n sourcePath,\n source,\n inspection.width,\n inspection.height,\n inspection.format,\n ),\n passThrough: true,\n };\n }\n const sharp = await loadSharp(sharpLoader);\n const metadata = await sharp(source, { animated: true }).metadata();\n const sourceWidth = metadata.autoOrient.width ?? metadata.width;\n const sourceHeight =\n (metadata.pages ?? 1) > 1\n ? (metadata.pageHeight ?? metadata.height)\n : (metadata.autoOrient.height ?? metadata.height);\n if (!sourceWidth || !sourceHeight) {\n throw new Error(`@askrjs/vite could not determine intrinsic dimensions for ${sourcePath}.`);\n }\n const encoder = `sharp@${sharp.versions.sharp}`;\n const transformKey = hash(`${sourceHash}\\0${JSON.stringify(normalized)}\\0${encoder}`);\n const fallbackFormat = sourceFormat(metadata.format);\n\n const shouldPassThrough = (metadata.pages ?? 1) > 1 || !fallbackFormat;\n if (shouldPassThrough) {\n return {\n declarationKey: key,\n sourcePath,\n sourceHash,\n declarationOptions: normalizeDeclarationOptions(declarationOptions),\n transformKey,\n encoder,\n ...passThroughImage(\n context,\n sourcePath,\n source,\n sourceWidth,\n sourceHeight,\n fallbackFormat ?? inspection.format,\n ),\n passThrough: true,\n };\n }\n\n const maximumWidth =\n normalized.fit === \"cover\"\n ? Math.min(sourceWidth, Math.floor(sourceHeight * normalized.aspectRatio!))\n : sourceWidth;\n if (maximumWidth < 1) {\n throw new Error(\n `@askrjs/vite cannot crop ${sourcePath} to aspect ratio ${normalized.aspectRatio} without upscaling.`,\n );\n }\n const widths = normalized.widths.filter((width) => width <= maximumWidth);\n if (!widths.includes(maximumWidth)) widths.push(maximumWidth);\n widths.sort((left, right) => left - right);\n const variants: EmittedVariant[] = [];\n for (const format of variantFormats(normalized.formats, fallbackFormat)) {\n for (const width of widths) {\n const height = outputHeight(\n width,\n sourceWidth,\n sourceHeight,\n normalized.fit === \"cover\" ? normalized.aspectRatio : undefined,\n );\n const buffer = await encodedVariant(\n sharp,\n source,\n cacheDir,\n transformKey,\n width,\n height,\n format,\n normalized,\n );\n variants.push({\n referenceId: context.emitFile({\n type: \"asset\",\n name: outputName(sourcePath, width, format),\n source: buffer,\n }),\n width,\n height,\n format,\n mime: mime(format),\n });\n }\n }\n return {\n declarationKey: key,\n sourcePath,\n sourceHash,\n declarationOptions: normalizeDeclarationOptions(declarationOptions),\n transformKey,\n encoder,\n fallback: variants.filter((variant) => variant.format === fallbackFormat).at(-1)!,\n variants,\n passThrough: false,\n };\n}\n","import { createHash } from \"node:crypto\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport type { ResolvedConfig } from \"vite\";\nimport { imageDeclarations } from \"./image-declarations\";\nimport {\n IMAGE_METADATA_PATH,\n IMAGE_METADATA_VERSION,\n type ImageMetadataEntry,\n type ImageMetadataRecord,\n} from \"./image-metadata\";\nimport type { ImagePipelineOptions, ResponsiveImage } from \"./image-types\";\nimport type { TextEdit } from \"./source-map-rewrites\";\nimport {\n declarationKey,\n defaultSharpLoader,\n processImage,\n type AssetPluginContext,\n type EmittedVariant,\n type ProcessedImage,\n type SharpLoader,\n} from \"./image-transform\";\n\nexport interface ImagePipelineTransform {\n code: string;\n edits: TextEdit[];\n}\n\nfunction urlExpression(referenceId: string): string {\n return `import.meta.ROLLUP_FILE_URL_${referenceId}`;\n}\n\nfunction mime(format: EmittedVariant[\"format\"]): string {\n return format === \"jpeg\" ? \"image/jpeg\" : `image/${format}`;\n}\n\nfunction srcsetExpression(variants: readonly EmittedVariant[]): string {\n return `[${variants.map((variant) => `${urlExpression(variant.referenceId)} + ${JSON.stringify(` ${variant.width}w`)}`).join(\",\")}].join(\", \")`;\n}\n\nfunction imageExpression(processed: ProcessedImage): string {\n const fallbackVariants = processed.variants.filter(\n (variant) => variant.format === processed.fallback.format,\n );\n const modernFormats = [\"avif\", \"webp\"] as const;\n const sources = processed.passThrough\n ? []\n : modernFormats.flatMap((format) => {\n const variants = processed.variants.filter((variant) => variant.format === format);\n return variants.length === 0\n ? []\n : [`{type:${JSON.stringify(mime(format))},srcset:${srcsetExpression(variants)}}`];\n });\n return `image({__askrImage:true,src:${urlExpression(processed.fallback.referenceId)},${\n processed.passThrough ? \"\" : `srcset:${srcsetExpression(fallbackVariants)},`\n }width:${processed.fallback.width},height:${processed.fallback.height},sources:[${sources.join(\",\")}]})`;\n}\n\nfunction builtUrl(base: string, fileName: string): string {\n if (/^https?:\\/\\//.test(base))\n return new URL(fileName, base.endsWith(\"/\") ? base : `${base}/`).href;\n if (base === \"\" || base === \"./\" || base === \".\")\n return `${base === \".\" ? \"./\" : base}${fileName}`;\n return `${base.endsWith(\"/\") ? base : `${base}/`}${fileName}`;\n}\n\nfunction responsiveMetadata(\n processed: ProcessedImage,\n fileName: (referenceId: string) => string,\n base: string,\n): ResponsiveImage {\n const url = (variant: EmittedVariant) => builtUrl(base, fileName(variant.referenceId));\n const srcset = (variants: readonly EmittedVariant[]) =>\n variants.map((variant) => `${url(variant)} ${variant.width}w`).join(\", \");\n const fallbackVariants = processed.variants.filter(\n (variant) => variant.format === processed.fallback.format,\n );\n return {\n __askrImage: true,\n src: url(processed.fallback),\n ...(processed.passThrough ? {} : { srcset: srcset(fallbackVariants) }),\n width: processed.fallback.width,\n height: processed.fallback.height,\n sources: processed.passThrough\n ? []\n : ([\"avif\", \"webp\"] as const).flatMap((format) => {\n const variants = processed.variants.filter((variant) => variant.format === format);\n return variants.length === 0 ? [] : [{ type: mime(format), srcset: srcset(variants) }];\n }),\n };\n}\n\nexport class ImagePipeline {\n readonly #options: ImagePipelineOptions;\n readonly #processed = new Map<string, ProcessedImage>();\n readonly #sharpLoader: SharpLoader;\n #config: ResolvedConfig | undefined;\n\n constructor(options: ImagePipelineOptions, sharpLoader: SharpLoader = defaultSharpLoader) {\n this.#options = options;\n this.#sharpLoader = sharpLoader;\n }\n\n configure(config: ResolvedConfig): void {\n this.#config = config;\n }\n\n async transform(\n context: AssetPluginContext,\n code: string,\n id: string,\n ): Promise<string | undefined> {\n return (await this.transformWithEdits(context, code, id))?.code;\n }\n\n async transformWithEdits(\n context: AssetPluginContext,\n code: string,\n id: string,\n ): Promise<ImagePipelineTransform | undefined> {\n const found = imageDeclarations(code, id);\n if (found.length === 0) return undefined;\n if (!this.#config) throw new Error(\"@askrjs/vite image pipeline was not configured.\");\n if (this.#config.command !== \"build\") {\n throw new Error(\"@askrjs/vite responsive image declarations currently require a Vite build.\");\n }\n const cacheDir = path.join(this.#config.root, \"node_modules/.cache/@askrjs/vite/images\");\n let transformed = code;\n const edits: TextEdit[] = [];\n for (const declaration of [...found].reverse()) {\n const sourcePath = path.resolve(path.dirname(id.split(\"?\", 1)[0]!), declaration.source);\n const key = declarationKey(sourcePath, declaration.options);\n let processed = this.#processed.get(key);\n if (processed) {\n const sourceHash = createHash(\"sha256\")\n .update(await fs.readFile(sourcePath))\n .digest(\"hex\");\n if (sourceHash !== processed.sourceHash) processed = undefined;\n }\n if (!processed) {\n processed = await processImage(\n context,\n sourcePath,\n declaration.options,\n this.#options,\n cacheDir,\n this.#sharpLoader,\n );\n this.#processed.set(key, processed);\n }\n const replacement = imageExpression(processed);\n edits.push({ start: declaration.start, end: declaration.end, replacement });\n transformed = `${transformed.slice(0, declaration.start)}${replacement}${transformed.slice(declaration.end)}`;\n }\n return { code: transformed, edits: edits.sort((left, right) => left.start - right.start) };\n }\n\n async writeMetadata(context: AssetPluginContext): Promise<void> {\n if (!this.#config || this.#processed.size === 0) return;\n const entries: Record<string, ImageMetadataEntry> = {};\n for (const processed of [...this.#processed.values()].sort((left, right) =>\n left.declarationKey.localeCompare(right.declarationKey),\n )) {\n entries[processed.declarationKey] = {\n sourcePath: processed.sourcePath,\n sourceHash: processed.sourceHash,\n declarationOptions: processed.declarationOptions,\n transformKey: processed.transformKey,\n encoder: processed.encoder,\n image: responsiveMetadata(\n processed,\n (referenceId) => context.getFileName(referenceId),\n this.#config.base,\n ),\n };\n }\n const record: ImageMetadataRecord = {\n version: IMAGE_METADATA_VERSION,\n entries,\n };\n const metadataPath = path.join(this.#config.root, IMAGE_METADATA_PATH);\n await fs.mkdir(path.dirname(metadataPath), { recursive: true });\n await fs.writeFile(metadataPath, `${JSON.stringify(record, null, 2)}\\n`, \"utf8\");\n }\n}\n","import { createRequire } from \"node:module\";\nimport type { Plugin } from \"vite\";\nimport {\n remapGenerated,\n remapOriginal,\n sourceMapForRewrite,\n type RawSourceMap,\n} from \"./source-map-rewrites\";\nimport { optimizeTemplateOutputWithEdits } from \"./template-optimizer\";\nimport { ImagePipeline } from \"./image-pipeline\";\nimport type { ImagePipelineOptions } from \"./image-types\";\n\nconst require = createRequire(import.meta.url);\ntype TransformWithOxc = (typeof import(\"vite\"))[\"transformWithOxc\"];\nlet transformWithOxcPromise: Promise<TransformWithOxc> | undefined;\n\nasync function loadTransformWithOxc(): Promise<TransformWithOxc> {\n transformWithOxcPromise ??= (async () => {\n for (const packageName of [\"vite-plus\", \"vite\"] as const) {\n try {\n const buildTool = await import(packageName);\n if (typeof buildTool.transformWithOxc === \"function\") {\n return buildTool.transformWithOxc as TransformWithOxc;\n }\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ERR_MODULE_NOT_FOUND\") throw error;\n }\n }\n throw new Error(\"@askrjs/vite requires either vite or vite-plus to transform JSX.\");\n })();\n return transformWithOxcPromise;\n}\n\n/** Options accepted by {@link askrVitePlugin}. */\nexport interface AskrVitePluginOptions {\n /** Transform `.jsx`/`.tsx` files with the Askr JSX runtime. Defaults to `true`. */\n transformJsx?: boolean;\n /** Hoist repeated JSX class/style literals using parsed compiled output. Defaults to `false`. */\n optimizeTemplates?: boolean;\n ssrPrecompile?: boolean;\n /** Opt into declared responsive image transforms. */\n images?: boolean | ImagePipelineOptions;\n}\n\n/**\n * Portable public plugin identity.\n *\n * Vite-compatible runners only require the plugin name. Keeping versioned Vite\n * hook types out of the installed declaration prevents consumers such as\n * vite-plus from comparing two distinct copies of Vite's recursive Plugin type.\n */\nexport interface AskrVitePlugin {\n readonly name: \"askr:vite\";\n}\n\n/**\n * Create the Askr Vite plugin, which transforms Askr JSX/TSX with oxc, wires\n * up dependency pre-bundling and aliasing for `@askrjs/askr`, and optionally\n * runs the responsive image pipeline and template optimizer.\n * JSX transform failures are reported through the active Vite/Rollup plugin\n * context with the source file and original transform detail.\n *\n * @param options Plugin configuration; all fields are optional.\n * @returns A Vite-compatible plugin object exposing the `askr:vite` name.\n */\nexport function askrVitePlugin(options: AskrVitePluginOptions = {}): AskrVitePlugin {\n const shouldTransform = options.transformJsx ?? true;\n const shouldOptimizeTemplates = options.optimizeTemplates ?? false;\n const imagePipeline = options.images\n ? new ImagePipeline(options.images === true ? {} : options.images)\n : undefined;\n const plugin = {\n name: \"askr:vite\" as const,\n enforce: \"pre\",\n config() {\n let askrEntry: string | null = null;\n try {\n askrEntry = require.resolve(\"@askrjs/askr\");\n } catch {\n askrEntry = null;\n }\n return {\n define: {\n __ASKR_OPTIMIZE_TEMPLATES__: JSON.stringify(shouldOptimizeTemplates),\n },\n resolve: {\n alias: askrEntry ? [{ find: \"@askrjs/askr\", replacement: askrEntry }] : [],\n dedupe: [\"@askrjs/askr\"],\n },\n optimizeDeps: {\n include: [\n \"@askrjs/askr\",\n \"@askrjs/askr/router\",\n \"@askrjs/askr/boot\",\n \"@askrjs/askr/control\",\n \"@askrjs/askr/fx\",\n \"@askrjs/askr/resources\",\n \"@askrjs/askr/data\",\n \"@askrjs/askr/foundations\",\n \"@askrjs/askr/foundations/icon\",\n \"@askrjs/askr/foundations/interactions\",\n \"@askrjs/askr/foundations/state\",\n \"@askrjs/askr/foundations/structures\",\n \"@askrjs/askr/foundations/utilities\",\n \"@askrjs/askr/jsx-runtime\",\n \"@askrjs/askr/jsx-dev-runtime\",\n ],\n },\n oxc: {\n jsx: { runtime: \"automatic\", importSource: \"@askrjs/askr\" },\n jsxInject: \"import { jsx, jsxs, Fragment } from '@askrjs/askr/jsx-runtime';\",\n },\n };\n },\n configResolved(config) {\n imagePipeline?.configure(config);\n },\n async transform(code, id) {\n if (id.includes(\"node_modules\")) return null;\n const imageTransformed = imagePipeline\n ? await imagePipeline.transformWithEdits(this, code, id)\n : undefined;\n const input = imageTransformed?.code ?? code;\n if (!shouldTransform || !/\\.(jsx|tsx)$/.test(id)) {\n return imageTransformed\n ? {\n code: imageTransformed.code,\n map: sourceMapForRewrite(code, imageTransformed.code, imageTransformed.edits, id),\n }\n : null;\n }\n try {\n const transformWithOxc = await loadTransformWithOxc();\n const result = await transformWithOxc(input, id, {\n lang: id.endsWith(\".tsx\") ? \"tsx\" : \"jsx\",\n jsx: { runtime: \"automatic\", importSource: \"@askrjs/askr\" },\n sourcemap: true,\n });\n if (!result?.code) return null;\n let map = result.map as RawSourceMap;\n if (imageTransformed) {\n map = remapOriginal(map, code, input, imageTransformed.edits);\n }\n if (!shouldOptimizeTemplates) return { code: result.code, map };\n const optimized = optimizeTemplateOutputWithEdits(result.code);\n return {\n code: optimized.code,\n map: remapGenerated(map, result.code, optimized.code, optimized.edits),\n };\n } catch (error) {\n const detail = error instanceof Error ? error.message : String(error);\n this.error(`@askrjs/vite failed to transform ${id}: ${detail}`);\n }\n },\n async writeBundle() {\n await imagePipeline?.writeMetadata(this);\n },\n } satisfies Plugin;\n return plugin;\n}\n"],"mappings":";;;;;;;;AAiBA,MAAM,SAAS;AACf,MAAM,gBAAgB,IAAI,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,WAAW,UAAU,CAAC,WAAW,KAAK,CAAC,CAAC;AAEvF,SAAS,UAAU,OAAe,QAAmC;CACnE,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,SAAS;EACP,MAAM,QAAQ,cAAc,IAAI,MAAM,OAAO,QAAQ;EACrD,IAAI,UAAU,KAA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AAc,IAAI;EACzC;CAEU;AACd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@askrjs/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Vite plugin for Askr JSX and template transforms",
|
|
5
5
|
"homepage": "https://github.com/askrjs/askr-vite#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -59,13 +59,13 @@
|
|
|
59
59
|
"prepublishOnly": "npm run check"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@askrjs/node": ">=0.0
|
|
62
|
+
"@askrjs/node": ">=0.2.0 <0.3.0",
|
|
63
63
|
"oxc-parser": "^0.144.0",
|
|
64
64
|
"parse5": "^8.0.1"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@askrjs/askr": ">=0.0
|
|
68
|
-
"@askrjs/server": ">=0.0
|
|
67
|
+
"@askrjs/askr": ">=0.2.0 <0.3.0",
|
|
68
|
+
"@askrjs/server": ">=0.2.0 <0.3.0",
|
|
69
69
|
"@types/node": "^26.2.0",
|
|
70
70
|
"publint": "^0.3.23",
|
|
71
71
|
"sharp": "^0.35.3",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"vitest": "^4.1.10"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@askrjs/askr": ">=0.0
|
|
78
|
+
"@askrjs/askr": ">=0.2.0 <0.3.0",
|
|
79
79
|
"sharp": "^0.35.3",
|
|
80
80
|
"vite": "^8.2.1",
|
|
81
81
|
"vite-plus": "^0.2.8"
|