@danielx/civet 0.6.46 → 0.6.47
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/browser.js +21 -18
- package/dist/esbuild.js +27 -7
- package/dist/main.js +21 -18
- package/dist/main.mjs +21 -18
- package/dist/rollup.js +27 -7
- package/dist/unplugin-shared.mjs +27 -7
- package/dist/unplugin.js +27 -7
- package/dist/vite.js +27 -7
- package/dist/webpack.js +27 -7
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -4718,12 +4718,13 @@ ${input.slice(result.pos)}
|
|
|
4718
4718
|
var $R79 = $R(new RegExp("[+-]", "suy"));
|
|
4719
4719
|
var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
|
|
4720
4720
|
var $R81 = $R(new RegExp("[\\t ]*", "suy"));
|
|
4721
|
-
var $R82 = $R(new RegExp("[\\
|
|
4722
|
-
var $R83 = $R(new RegExp("\\
|
|
4723
|
-
var $R84 = $R(new RegExp("
|
|
4724
|
-
var $R85 = $R(new RegExp("(
|
|
4725
|
-
var $R86 = $R(new RegExp("
|
|
4726
|
-
var $R87 = $R(new RegExp("[ \\t]
|
|
4721
|
+
var $R82 = $R(new RegExp("[ \\t]*", "suy"));
|
|
4722
|
+
var $R83 = $R(new RegExp("\\r\\n|\\r|\\n", "suy"));
|
|
4723
|
+
var $R84 = $R(new RegExp("[\\s]*", "suy"));
|
|
4724
|
+
var $R85 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
|
|
4725
|
+
var $R86 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
|
|
4726
|
+
var $R87 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
|
|
4727
|
+
var $R88 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
|
|
4727
4728
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4728
4729
|
var statements = $4;
|
|
4729
4730
|
processProgram({
|
|
@@ -12430,19 +12431,21 @@ ${input.slice(result.pos)}
|
|
|
12430
12431
|
function Shebang(ctx, state) {
|
|
12431
12432
|
return $EVENT(ctx, state, "Shebang", Shebang$0);
|
|
12432
12433
|
}
|
|
12433
|
-
var CivetPrologue$0 = $
|
|
12434
|
-
var content =
|
|
12435
|
-
|
|
12434
|
+
var CivetPrologue$0 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
12435
|
+
var content = $3;
|
|
12436
|
+
var eos = $8;
|
|
12437
|
+
return { ...content, children: [...content.children, eos] };
|
|
12436
12438
|
});
|
|
12437
|
-
var CivetPrologue$1 = $
|
|
12438
|
-
var content =
|
|
12439
|
-
|
|
12439
|
+
var CivetPrologue$1 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
12440
|
+
var content = $3;
|
|
12441
|
+
var eos = $8;
|
|
12442
|
+
return { ...content, children: [...content.children, eos] };
|
|
12440
12443
|
});
|
|
12441
12444
|
var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
|
|
12442
12445
|
function CivetPrologue(ctx, state) {
|
|
12443
12446
|
return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
|
|
12444
12447
|
}
|
|
12445
|
-
var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($
|
|
12448
|
+
var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R84, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12446
12449
|
var options = $3;
|
|
12447
12450
|
return {
|
|
12448
12451
|
type: "CivetPrologue",
|
|
@@ -12453,7 +12456,7 @@ ${input.slice(result.pos)}
|
|
|
12453
12456
|
function CivetPrologueContent(ctx, state) {
|
|
12454
12457
|
return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
|
|
12455
12458
|
}
|
|
12456
|
-
var CivetOption$0 = $TR($EXPECT($
|
|
12459
|
+
var CivetOption$0 = $TR($EXPECT($R85, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12457
12460
|
const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
|
|
12458
12461
|
if (l)
|
|
12459
12462
|
return l.toUpperCase();
|
|
@@ -12474,7 +12477,7 @@ ${input.slice(result.pos)}
|
|
|
12474
12477
|
function UnknownPrologue(ctx, state) {
|
|
12475
12478
|
return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
|
|
12476
12479
|
}
|
|
12477
|
-
var TripleSlashDirective$0 = $S($R$0($EXPECT($
|
|
12480
|
+
var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
|
|
12478
12481
|
function TripleSlashDirective(ctx, state) {
|
|
12479
12482
|
return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
|
|
12480
12483
|
}
|
|
@@ -12488,13 +12491,13 @@ ${input.slice(result.pos)}
|
|
|
12488
12491
|
function PrologueString(ctx, state) {
|
|
12489
12492
|
return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
|
|
12490
12493
|
}
|
|
12491
|
-
var EOS$0 = $T($S($EXPECT($
|
|
12494
|
+
var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
|
|
12492
12495
|
return value[1];
|
|
12493
12496
|
});
|
|
12494
12497
|
function EOS(ctx, state) {
|
|
12495
12498
|
return $EVENT(ctx, state, "EOS", EOS$0);
|
|
12496
12499
|
}
|
|
12497
|
-
var EOL$0 = $TR($EXPECT($
|
|
12500
|
+
var EOL$0 = $TR($EXPECT($R88, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12498
12501
|
return { $loc, token: $0 };
|
|
12499
12502
|
});
|
|
12500
12503
|
function EOL(ctx, state) {
|
|
@@ -12988,7 +12991,7 @@ ${input.slice(result.pos)}
|
|
|
12988
12991
|
function Init(ctx, state) {
|
|
12989
12992
|
return $EVENT(ctx, state, "Init", Init$0);
|
|
12990
12993
|
}
|
|
12991
|
-
var Indent$0 = $TR($EXPECT($
|
|
12994
|
+
var Indent$0 = $TR($EXPECT($R82, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12992
12995
|
const level = getIndentLevel($0, module.config.tab);
|
|
12993
12996
|
return {
|
|
12994
12997
|
$loc,
|
package/dist/esbuild.js
CHANGED
|
@@ -48,7 +48,7 @@ var formatHost = {
|
|
|
48
48
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
49
|
};
|
|
50
50
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)
|
|
51
|
+
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)(\?transform)?$/.test(id);
|
|
52
52
|
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
53
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
54
|
if (options.dts && options.js) {
|
|
@@ -62,6 +62,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
65
66
|
return {
|
|
66
67
|
name: "unplugin-civet",
|
|
67
68
|
enforce: "pre",
|
|
@@ -159,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
159
160
|
resolveId(id, importer) {
|
|
160
161
|
if (/\0/.test(id))
|
|
161
162
|
return null;
|
|
162
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
163
164
|
return null;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
const absolutePath = rootDir != null && import_path.default.isAbsolute(id) ? import_path.default.join(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
166
|
+
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
+
if (isCivetTranspiled(id))
|
|
168
|
+
return relativeId.replace(/\?transform$/, "");
|
|
168
169
|
const relativePath = relativeId + outExt;
|
|
169
170
|
return relativePath;
|
|
170
171
|
},
|
|
@@ -211,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
211
212
|
return null;
|
|
212
213
|
},
|
|
213
214
|
vite: {
|
|
214
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
215
217
|
if (command === "build") {
|
|
216
218
|
return {
|
|
217
219
|
esbuild: {
|
|
@@ -221,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
221
223
|
};
|
|
222
224
|
}
|
|
223
225
|
return null;
|
|
226
|
+
},
|
|
227
|
+
async transformIndexHtml(html) {
|
|
228
|
+
return html.replace(
|
|
229
|
+
/<!--[^]*?-->|<[^<>]*>/g,
|
|
230
|
+
(tag) => tag.replace(
|
|
231
|
+
/<\s*script\b[^<>]*>/gi,
|
|
232
|
+
(script) => (
|
|
233
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
234
|
+
script.replace(
|
|
235
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
236
|
+
(attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
|
|
237
|
+
/(\.civet)(['"]?)$/,
|
|
238
|
+
(_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
|
|
239
|
+
) : attr
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
)
|
|
243
|
+
);
|
|
224
244
|
}
|
|
225
245
|
}
|
|
226
246
|
};
|
package/dist/main.js
CHANGED
|
@@ -4710,12 +4710,13 @@ var require_parser = __commonJS({
|
|
|
4710
4710
|
var $R79 = $R(new RegExp("[+-]", "suy"));
|
|
4711
4711
|
var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
|
|
4712
4712
|
var $R81 = $R(new RegExp("[\\t ]*", "suy"));
|
|
4713
|
-
var $R82 = $R(new RegExp("[\\
|
|
4714
|
-
var $R83 = $R(new RegExp("\\
|
|
4715
|
-
var $R84 = $R(new RegExp("
|
|
4716
|
-
var $R85 = $R(new RegExp("(
|
|
4717
|
-
var $R86 = $R(new RegExp("
|
|
4718
|
-
var $R87 = $R(new RegExp("[ \\t]
|
|
4713
|
+
var $R82 = $R(new RegExp("[ \\t]*", "suy"));
|
|
4714
|
+
var $R83 = $R(new RegExp("\\r\\n|\\r|\\n", "suy"));
|
|
4715
|
+
var $R84 = $R(new RegExp("[\\s]*", "suy"));
|
|
4716
|
+
var $R85 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
|
|
4717
|
+
var $R86 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
|
|
4718
|
+
var $R87 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
|
|
4719
|
+
var $R88 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
|
|
4719
4720
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4720
4721
|
var statements = $4;
|
|
4721
4722
|
processProgram({
|
|
@@ -12422,19 +12423,21 @@ var require_parser = __commonJS({
|
|
|
12422
12423
|
function Shebang(ctx, state) {
|
|
12423
12424
|
return $EVENT(ctx, state, "Shebang", Shebang$0);
|
|
12424
12425
|
}
|
|
12425
|
-
var CivetPrologue$0 = $
|
|
12426
|
-
var content =
|
|
12427
|
-
|
|
12426
|
+
var CivetPrologue$0 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
12427
|
+
var content = $3;
|
|
12428
|
+
var eos = $8;
|
|
12429
|
+
return { ...content, children: [...content.children, eos] };
|
|
12428
12430
|
});
|
|
12429
|
-
var CivetPrologue$1 = $
|
|
12430
|
-
var content =
|
|
12431
|
-
|
|
12431
|
+
var CivetPrologue$1 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
12432
|
+
var content = $3;
|
|
12433
|
+
var eos = $8;
|
|
12434
|
+
return { ...content, children: [...content.children, eos] };
|
|
12432
12435
|
});
|
|
12433
12436
|
var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
|
|
12434
12437
|
function CivetPrologue(ctx, state) {
|
|
12435
12438
|
return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
|
|
12436
12439
|
}
|
|
12437
|
-
var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($
|
|
12440
|
+
var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R84, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12438
12441
|
var options = $3;
|
|
12439
12442
|
return {
|
|
12440
12443
|
type: "CivetPrologue",
|
|
@@ -12445,7 +12448,7 @@ var require_parser = __commonJS({
|
|
|
12445
12448
|
function CivetPrologueContent(ctx, state) {
|
|
12446
12449
|
return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
|
|
12447
12450
|
}
|
|
12448
|
-
var CivetOption$0 = $TR($EXPECT($
|
|
12451
|
+
var CivetOption$0 = $TR($EXPECT($R85, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12449
12452
|
const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
|
|
12450
12453
|
if (l)
|
|
12451
12454
|
return l.toUpperCase();
|
|
@@ -12466,7 +12469,7 @@ var require_parser = __commonJS({
|
|
|
12466
12469
|
function UnknownPrologue(ctx, state) {
|
|
12467
12470
|
return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
|
|
12468
12471
|
}
|
|
12469
|
-
var TripleSlashDirective$0 = $S($R$0($EXPECT($
|
|
12472
|
+
var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
|
|
12470
12473
|
function TripleSlashDirective(ctx, state) {
|
|
12471
12474
|
return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
|
|
12472
12475
|
}
|
|
@@ -12480,13 +12483,13 @@ var require_parser = __commonJS({
|
|
|
12480
12483
|
function PrologueString(ctx, state) {
|
|
12481
12484
|
return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
|
|
12482
12485
|
}
|
|
12483
|
-
var EOS$0 = $T($S($EXPECT($
|
|
12486
|
+
var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
|
|
12484
12487
|
return value[1];
|
|
12485
12488
|
});
|
|
12486
12489
|
function EOS(ctx, state) {
|
|
12487
12490
|
return $EVENT(ctx, state, "EOS", EOS$0);
|
|
12488
12491
|
}
|
|
12489
|
-
var EOL$0 = $TR($EXPECT($
|
|
12492
|
+
var EOL$0 = $TR($EXPECT($R88, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12490
12493
|
return { $loc, token: $0 };
|
|
12491
12494
|
});
|
|
12492
12495
|
function EOL(ctx, state) {
|
|
@@ -12980,7 +12983,7 @@ var require_parser = __commonJS({
|
|
|
12980
12983
|
function Init(ctx, state) {
|
|
12981
12984
|
return $EVENT(ctx, state, "Init", Init$0);
|
|
12982
12985
|
}
|
|
12983
|
-
var Indent$0 = $TR($EXPECT($
|
|
12986
|
+
var Indent$0 = $TR($EXPECT($R82, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12984
12987
|
const level = getIndentLevel($0, module2.config.tab);
|
|
12985
12988
|
return {
|
|
12986
12989
|
$loc,
|
package/dist/main.mjs
CHANGED
|
@@ -4708,12 +4708,13 @@ var require_parser = __commonJS({
|
|
|
4708
4708
|
var $R79 = $R(new RegExp("[+-]", "suy"));
|
|
4709
4709
|
var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
|
|
4710
4710
|
var $R81 = $R(new RegExp("[\\t ]*", "suy"));
|
|
4711
|
-
var $R82 = $R(new RegExp("[\\
|
|
4712
|
-
var $R83 = $R(new RegExp("\\
|
|
4713
|
-
var $R84 = $R(new RegExp("
|
|
4714
|
-
var $R85 = $R(new RegExp("(
|
|
4715
|
-
var $R86 = $R(new RegExp("
|
|
4716
|
-
var $R87 = $R(new RegExp("[ \\t]
|
|
4711
|
+
var $R82 = $R(new RegExp("[ \\t]*", "suy"));
|
|
4712
|
+
var $R83 = $R(new RegExp("\\r\\n|\\r|\\n", "suy"));
|
|
4713
|
+
var $R84 = $R(new RegExp("[\\s]*", "suy"));
|
|
4714
|
+
var $R85 = $R(new RegExp("\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?", "suy"));
|
|
4715
|
+
var $R86 = $R(new RegExp("\\/\\/\\/[^\\r\\n]*", "suy"));
|
|
4716
|
+
var $R87 = $R(new RegExp("(?=[ \\t\\r\\n\\/#]|$)", "suy"));
|
|
4717
|
+
var $R88 = $R(new RegExp("\\r\\n|\\n|\\r|$", "suy"));
|
|
4717
4718
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4718
4719
|
var statements = $4;
|
|
4719
4720
|
processProgram({
|
|
@@ -12420,19 +12421,21 @@ var require_parser = __commonJS({
|
|
|
12420
12421
|
function Shebang(ctx, state) {
|
|
12421
12422
|
return $EVENT(ctx, state, "Shebang", Shebang$0);
|
|
12422
12423
|
}
|
|
12423
|
-
var CivetPrologue$0 = $
|
|
12424
|
-
var content =
|
|
12425
|
-
|
|
12424
|
+
var CivetPrologue$0 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), DoubleQuote, CivetPrologueContent, DoubleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
12425
|
+
var content = $3;
|
|
12426
|
+
var eos = $8;
|
|
12427
|
+
return { ...content, children: [...content.children, eos] };
|
|
12426
12428
|
});
|
|
12427
|
-
var CivetPrologue$1 = $
|
|
12428
|
-
var content =
|
|
12429
|
-
|
|
12429
|
+
var CivetPrologue$1 = $TS($S($EXPECT($R81, "CivetPrologue /[\\t ]*/"), SingleQuote, CivetPrologueContent, SingleQuote, SimpleStatementDelimiter, $EXPECT($R82, "CivetPrologue /[ \\t]*/"), $E($EXPECT($R83, "CivetPrologue /\\r\\n|\\r|\\n/")), $E(EOS)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
12430
|
+
var content = $3;
|
|
12431
|
+
var eos = $8;
|
|
12432
|
+
return { ...content, children: [...content.children, eos] };
|
|
12430
12433
|
});
|
|
12431
12434
|
var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
|
|
12432
12435
|
function CivetPrologue(ctx, state) {
|
|
12433
12436
|
return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
|
|
12434
12437
|
}
|
|
12435
|
-
var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($
|
|
12438
|
+
var CivetPrologueContent$0 = $TS($S($EXPECT($L210, 'CivetPrologueContent "civet"'), NonIdContinue, $Q(CivetOption), $EXPECT($R84, "CivetPrologueContent /[\\s]*/")), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
12436
12439
|
var options = $3;
|
|
12437
12440
|
return {
|
|
12438
12441
|
type: "CivetPrologue",
|
|
@@ -12443,7 +12446,7 @@ var require_parser = __commonJS({
|
|
|
12443
12446
|
function CivetPrologueContent(ctx, state) {
|
|
12444
12447
|
return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
|
|
12445
12448
|
}
|
|
12446
|
-
var CivetOption$0 = $TR($EXPECT($
|
|
12449
|
+
var CivetOption$0 = $TR($EXPECT($R85, "CivetOption /\\s+([+-]?)([a-zA-Z0-9-]+)(\\s*=\\s*([a-zA-Z0-9.+-]*))?/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12447
12450
|
const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
|
|
12448
12451
|
if (l)
|
|
12449
12452
|
return l.toUpperCase();
|
|
@@ -12464,7 +12467,7 @@ var require_parser = __commonJS({
|
|
|
12464
12467
|
function UnknownPrologue(ctx, state) {
|
|
12465
12468
|
return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
|
|
12466
12469
|
}
|
|
12467
|
-
var TripleSlashDirective$0 = $S($R$0($EXPECT($
|
|
12470
|
+
var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
|
|
12468
12471
|
function TripleSlashDirective(ctx, state) {
|
|
12469
12472
|
return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
|
|
12470
12473
|
}
|
|
@@ -12478,13 +12481,13 @@ var require_parser = __commonJS({
|
|
|
12478
12481
|
function PrologueString(ctx, state) {
|
|
12479
12482
|
return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
|
|
12480
12483
|
}
|
|
12481
|
-
var EOS$0 = $T($S($EXPECT($
|
|
12484
|
+
var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
|
|
12482
12485
|
return value[1];
|
|
12483
12486
|
});
|
|
12484
12487
|
function EOS(ctx, state) {
|
|
12485
12488
|
return $EVENT(ctx, state, "EOS", EOS$0);
|
|
12486
12489
|
}
|
|
12487
|
-
var EOL$0 = $TR($EXPECT($
|
|
12490
|
+
var EOL$0 = $TR($EXPECT($R88, "EOL /\\r\\n|\\n|\\r|$/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12488
12491
|
return { $loc, token: $0 };
|
|
12489
12492
|
});
|
|
12490
12493
|
function EOL(ctx, state) {
|
|
@@ -12978,7 +12981,7 @@ var require_parser = __commonJS({
|
|
|
12978
12981
|
function Init(ctx, state) {
|
|
12979
12982
|
return $EVENT(ctx, state, "Init", Init$0);
|
|
12980
12983
|
}
|
|
12981
|
-
var Indent$0 = $TR($EXPECT($
|
|
12984
|
+
var Indent$0 = $TR($EXPECT($R82, "Indent /[ \\t]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
|
12982
12985
|
const level = getIndentLevel($0, module.config.tab);
|
|
12983
12986
|
return {
|
|
12984
12987
|
$loc,
|
package/dist/rollup.js
CHANGED
|
@@ -48,7 +48,7 @@ var formatHost = {
|
|
|
48
48
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
49
|
};
|
|
50
50
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)
|
|
51
|
+
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)(\?transform)?$/.test(id);
|
|
52
52
|
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
53
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
54
|
if (options.dts && options.js) {
|
|
@@ -62,6 +62,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
65
66
|
return {
|
|
66
67
|
name: "unplugin-civet",
|
|
67
68
|
enforce: "pre",
|
|
@@ -159,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
159
160
|
resolveId(id, importer) {
|
|
160
161
|
if (/\0/.test(id))
|
|
161
162
|
return null;
|
|
162
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
163
164
|
return null;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
const absolutePath = rootDir != null && import_path.default.isAbsolute(id) ? import_path.default.join(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
166
|
+
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
+
if (isCivetTranspiled(id))
|
|
168
|
+
return relativeId.replace(/\?transform$/, "");
|
|
168
169
|
const relativePath = relativeId + outExt;
|
|
169
170
|
return relativePath;
|
|
170
171
|
},
|
|
@@ -211,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
211
212
|
return null;
|
|
212
213
|
},
|
|
213
214
|
vite: {
|
|
214
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
215
217
|
if (command === "build") {
|
|
216
218
|
return {
|
|
217
219
|
esbuild: {
|
|
@@ -221,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
221
223
|
};
|
|
222
224
|
}
|
|
223
225
|
return null;
|
|
226
|
+
},
|
|
227
|
+
async transformIndexHtml(html) {
|
|
228
|
+
return html.replace(
|
|
229
|
+
/<!--[^]*?-->|<[^<>]*>/g,
|
|
230
|
+
(tag) => tag.replace(
|
|
231
|
+
/<\s*script\b[^<>]*>/gi,
|
|
232
|
+
(script) => (
|
|
233
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
234
|
+
script.replace(
|
|
235
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
236
|
+
(attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
|
|
237
|
+
/(\.civet)(['"]?)$/,
|
|
238
|
+
(_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
|
|
239
|
+
) : attr
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
)
|
|
243
|
+
);
|
|
224
244
|
}
|
|
225
245
|
}
|
|
226
246
|
};
|
package/dist/unplugin-shared.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var formatHost = {
|
|
|
17
17
|
getCanonicalFileName: ts.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
18
18
|
};
|
|
19
19
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
20
|
-
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)
|
|
20
|
+
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)(\?transform)?$/.test(id);
|
|
21
21
|
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
22
22
|
var civetUnplugin = createUnplugin((options = {}) => {
|
|
23
23
|
if (options.dts && options.js) {
|
|
@@ -31,6 +31,7 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
31
31
|
let fsMap = /* @__PURE__ */ new Map();
|
|
32
32
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
33
33
|
let compilerOptions;
|
|
34
|
+
let rootDir;
|
|
34
35
|
return {
|
|
35
36
|
name: "unplugin-civet",
|
|
36
37
|
enforce: "pre",
|
|
@@ -128,12 +129,12 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
128
129
|
resolveId(id, importer) {
|
|
129
130
|
if (/\0/.test(id))
|
|
130
131
|
return null;
|
|
131
|
-
if (!isCivet(id))
|
|
132
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
132
133
|
return null;
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
const absolutePath = rootDir != null && path.isAbsolute(id) ? path.join(rootDir, id) : path.resolve(path.dirname(importer ?? ""), id);
|
|
135
|
+
const relativeId = path.relative(process.cwd(), absolutePath);
|
|
136
|
+
if (isCivetTranspiled(id))
|
|
137
|
+
return relativeId.replace(/\?transform$/, "");
|
|
137
138
|
const relativePath = relativeId + outExt;
|
|
138
139
|
return relativePath;
|
|
139
140
|
},
|
|
@@ -180,7 +181,8 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
180
181
|
return null;
|
|
181
182
|
},
|
|
182
183
|
vite: {
|
|
183
|
-
config(
|
|
184
|
+
config(config, { command }) {
|
|
185
|
+
rootDir = path.resolve(process.cwd(), config.root ?? "");
|
|
184
186
|
if (command === "build") {
|
|
185
187
|
return {
|
|
186
188
|
esbuild: {
|
|
@@ -190,6 +192,24 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
190
192
|
};
|
|
191
193
|
}
|
|
192
194
|
return null;
|
|
195
|
+
},
|
|
196
|
+
async transformIndexHtml(html) {
|
|
197
|
+
return html.replace(
|
|
198
|
+
/<!--[^]*?-->|<[^<>]*>/g,
|
|
199
|
+
(tag) => tag.replace(
|
|
200
|
+
/<\s*script\b[^<>]*>/gi,
|
|
201
|
+
(script) => (
|
|
202
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
203
|
+
script.replace(
|
|
204
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
205
|
+
(attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
|
|
206
|
+
/(\.civet)(['"]?)$/,
|
|
207
|
+
(_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
|
|
208
|
+
) : attr
|
|
209
|
+
)
|
|
210
|
+
)
|
|
211
|
+
)
|
|
212
|
+
);
|
|
193
213
|
}
|
|
194
214
|
}
|
|
195
215
|
};
|
package/dist/unplugin.js
CHANGED
|
@@ -46,7 +46,7 @@ var formatHost = {
|
|
|
46
46
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
47
47
|
};
|
|
48
48
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
49
|
-
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)
|
|
49
|
+
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)(\?transform)?$/.test(id);
|
|
50
50
|
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
51
51
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
52
52
|
if (options.dts && options.js) {
|
|
@@ -60,6 +60,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
60
60
|
let fsMap = /* @__PURE__ */ new Map();
|
|
61
61
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
62
62
|
let compilerOptions;
|
|
63
|
+
let rootDir;
|
|
63
64
|
return {
|
|
64
65
|
name: "unplugin-civet",
|
|
65
66
|
enforce: "pre",
|
|
@@ -157,12 +158,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
157
158
|
resolveId(id, importer) {
|
|
158
159
|
if (/\0/.test(id))
|
|
159
160
|
return null;
|
|
160
|
-
if (!isCivet(id))
|
|
161
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
161
162
|
return null;
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
const absolutePath = rootDir != null && import_path.default.isAbsolute(id) ? import_path.default.join(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
164
|
+
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
165
|
+
if (isCivetTranspiled(id))
|
|
166
|
+
return relativeId.replace(/\?transform$/, "");
|
|
166
167
|
const relativePath = relativeId + outExt;
|
|
167
168
|
return relativePath;
|
|
168
169
|
},
|
|
@@ -209,7 +210,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
209
210
|
return null;
|
|
210
211
|
},
|
|
211
212
|
vite: {
|
|
212
|
-
config(
|
|
213
|
+
config(config, { command }) {
|
|
214
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
213
215
|
if (command === "build") {
|
|
214
216
|
return {
|
|
215
217
|
esbuild: {
|
|
@@ -219,6 +221,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
219
221
|
};
|
|
220
222
|
}
|
|
221
223
|
return null;
|
|
224
|
+
},
|
|
225
|
+
async transformIndexHtml(html) {
|
|
226
|
+
return html.replace(
|
|
227
|
+
/<!--[^]*?-->|<[^<>]*>/g,
|
|
228
|
+
(tag) => tag.replace(
|
|
229
|
+
/<\s*script\b[^<>]*>/gi,
|
|
230
|
+
(script) => (
|
|
231
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
232
|
+
script.replace(
|
|
233
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
234
|
+
(attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
|
|
235
|
+
/(\.civet)(['"]?)$/,
|
|
236
|
+
(_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
|
|
237
|
+
) : attr
|
|
238
|
+
)
|
|
239
|
+
)
|
|
240
|
+
)
|
|
241
|
+
);
|
|
222
242
|
}
|
|
223
243
|
}
|
|
224
244
|
};
|
package/dist/vite.js
CHANGED
|
@@ -48,7 +48,7 @@ var formatHost = {
|
|
|
48
48
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
49
|
};
|
|
50
50
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)
|
|
51
|
+
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)(\?transform)?$/.test(id);
|
|
52
52
|
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
53
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
54
|
if (options.dts && options.js) {
|
|
@@ -62,6 +62,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
65
66
|
return {
|
|
66
67
|
name: "unplugin-civet",
|
|
67
68
|
enforce: "pre",
|
|
@@ -159,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
159
160
|
resolveId(id, importer) {
|
|
160
161
|
if (/\0/.test(id))
|
|
161
162
|
return null;
|
|
162
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
163
164
|
return null;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
const absolutePath = rootDir != null && import_path.default.isAbsolute(id) ? import_path.default.join(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
166
|
+
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
+
if (isCivetTranspiled(id))
|
|
168
|
+
return relativeId.replace(/\?transform$/, "");
|
|
168
169
|
const relativePath = relativeId + outExt;
|
|
169
170
|
return relativePath;
|
|
170
171
|
},
|
|
@@ -211,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
211
212
|
return null;
|
|
212
213
|
},
|
|
213
214
|
vite: {
|
|
214
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
215
217
|
if (command === "build") {
|
|
216
218
|
return {
|
|
217
219
|
esbuild: {
|
|
@@ -221,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
221
223
|
};
|
|
222
224
|
}
|
|
223
225
|
return null;
|
|
226
|
+
},
|
|
227
|
+
async transformIndexHtml(html) {
|
|
228
|
+
return html.replace(
|
|
229
|
+
/<!--[^]*?-->|<[^<>]*>/g,
|
|
230
|
+
(tag) => tag.replace(
|
|
231
|
+
/<\s*script\b[^<>]*>/gi,
|
|
232
|
+
(script) => (
|
|
233
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
234
|
+
script.replace(
|
|
235
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
236
|
+
(attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
|
|
237
|
+
/(\.civet)(['"]?)$/,
|
|
238
|
+
(_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
|
|
239
|
+
) : attr
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
)
|
|
243
|
+
);
|
|
224
244
|
}
|
|
225
245
|
}
|
|
226
246
|
};
|
package/dist/webpack.js
CHANGED
|
@@ -48,7 +48,7 @@ var formatHost = {
|
|
|
48
48
|
getCanonicalFileName: import_typescript.default.sys.useCaseSensitiveFileNames ? (f) => f : (f) => f.toLowerCase()
|
|
49
49
|
};
|
|
50
50
|
var isCivet = (id) => /\.civet$/.test(id);
|
|
51
|
-
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)
|
|
51
|
+
var isCivetTranspiled = (id) => /\.civet\.(m?)(j|t)s(x?)(\?transform)?$/.test(id);
|
|
52
52
|
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
53
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
54
54
|
if (options.dts && options.js) {
|
|
@@ -62,6 +62,7 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
62
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
63
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
64
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
65
66
|
return {
|
|
66
67
|
name: "unplugin-civet",
|
|
67
68
|
enforce: "pre",
|
|
@@ -159,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
159
160
|
resolveId(id, importer) {
|
|
160
161
|
if (/\0/.test(id))
|
|
161
162
|
return null;
|
|
162
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
163
164
|
return null;
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
const absolutePath = rootDir != null && import_path.default.isAbsolute(id) ? import_path.default.join(rootDir, id) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
|
|
166
|
+
const relativeId = import_path.default.relative(process.cwd(), absolutePath);
|
|
167
|
+
if (isCivetTranspiled(id))
|
|
168
|
+
return relativeId.replace(/\?transform$/, "");
|
|
168
169
|
const relativePath = relativeId + outExt;
|
|
169
170
|
return relativePath;
|
|
170
171
|
},
|
|
@@ -211,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
211
212
|
return null;
|
|
212
213
|
},
|
|
213
214
|
vite: {
|
|
214
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
215
217
|
if (command === "build") {
|
|
216
218
|
return {
|
|
217
219
|
esbuild: {
|
|
@@ -221,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
221
223
|
};
|
|
222
224
|
}
|
|
223
225
|
return null;
|
|
226
|
+
},
|
|
227
|
+
async transformIndexHtml(html) {
|
|
228
|
+
return html.replace(
|
|
229
|
+
/<!--[^]*?-->|<[^<>]*>/g,
|
|
230
|
+
(tag) => tag.replace(
|
|
231
|
+
/<\s*script\b[^<>]*>/gi,
|
|
232
|
+
(script) => (
|
|
233
|
+
// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
|
|
234
|
+
script.replace(
|
|
235
|
+
/([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
|
|
236
|
+
(attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
|
|
237
|
+
/(\.civet)(['"]?)$/,
|
|
238
|
+
(_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
|
|
239
|
+
) : attr
|
|
240
|
+
)
|
|
241
|
+
)
|
|
242
|
+
)
|
|
243
|
+
);
|
|
224
244
|
}
|
|
225
245
|
}
|
|
226
246
|
};
|