@danielx/civet 0.6.45 → 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/README.md +1 -1
- package/dist/browser.js +21 -22
- package/dist/civet +0 -4
- package/dist/esbuild.js +33 -9
- package/dist/main.js +21 -22
- package/dist/main.mjs +21 -22
- package/dist/rollup.js +33 -9
- package/dist/unplugin-shared.mjs +33 -9
- package/dist/unplugin.js +33 -9
- package/dist/vite.js +33 -9
- package/dist/webpack.js +33 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ The modern way to write TypeScript.
|
|
|
20
20
|
(including metaframeworks such as Astro),
|
|
21
21
|
<!--
|
|
22
22
|
[esbuild](source/esbuild-plugin.civet),
|
|
23
|
-
[Vite](https://github.com/
|
|
23
|
+
[Vite](https://github.com/edemaine/vite-plugin-civet),
|
|
24
24
|
-->
|
|
25
25
|
[Babel](source/babel-plugin.mjs),
|
|
26
26
|
[Gulp](integration/gulp),
|
package/dist/browser.js
CHANGED
|
@@ -820,7 +820,6 @@ ${input.slice(result.pos)}
|
|
|
820
820
|
const part = strWithSubstitutions[i2];
|
|
821
821
|
results1.push(part.token ?? "s");
|
|
822
822
|
}
|
|
823
|
-
;
|
|
824
823
|
return results1;
|
|
825
824
|
})().join("");
|
|
826
825
|
const dedent = /^[ \t]*\r?\n/.test(stringPart) ? getIndentOfBlockString(stringPart, tab) : false;
|
|
@@ -2307,7 +2306,6 @@ ${input.slice(result.pos)}
|
|
|
2307
2306
|
if (!condition?.expression) {
|
|
2308
2307
|
return;
|
|
2309
2308
|
}
|
|
2310
|
-
;
|
|
2311
2309
|
let { expression } = condition;
|
|
2312
2310
|
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && expression.children.length === 2 && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
|
|
2313
2311
|
const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
|
|
@@ -4720,12 +4718,13 @@ ${input.slice(result.pos)}
|
|
|
4720
4718
|
var $R79 = $R(new RegExp("[+-]", "suy"));
|
|
4721
4719
|
var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
|
|
4722
4720
|
var $R81 = $R(new RegExp("[\\t ]*", "suy"));
|
|
4723
|
-
var $R82 = $R(new RegExp("[\\
|
|
4724
|
-
var $R83 = $R(new RegExp("\\
|
|
4725
|
-
var $R84 = $R(new RegExp("
|
|
4726
|
-
var $R85 = $R(new RegExp("(
|
|
4727
|
-
var $R86 = $R(new RegExp("
|
|
4728
|
-
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"));
|
|
4729
4728
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4730
4729
|
var statements = $4;
|
|
4731
4730
|
processProgram({
|
|
@@ -12432,19 +12431,21 @@ ${input.slice(result.pos)}
|
|
|
12432
12431
|
function Shebang(ctx, state) {
|
|
12433
12432
|
return $EVENT(ctx, state, "Shebang", Shebang$0);
|
|
12434
12433
|
}
|
|
12435
|
-
var CivetPrologue$0 = $
|
|
12436
|
-
var content =
|
|
12437
|
-
|
|
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] };
|
|
12438
12438
|
});
|
|
12439
|
-
var CivetPrologue$1 = $
|
|
12440
|
-
var content =
|
|
12441
|
-
|
|
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] };
|
|
12442
12443
|
});
|
|
12443
12444
|
var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
|
|
12444
12445
|
function CivetPrologue(ctx, state) {
|
|
12445
12446
|
return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
|
|
12446
12447
|
}
|
|
12447
|
-
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) {
|
|
12448
12449
|
var options = $3;
|
|
12449
12450
|
return {
|
|
12450
12451
|
type: "CivetPrologue",
|
|
@@ -12455,7 +12456,7 @@ ${input.slice(result.pos)}
|
|
|
12455
12456
|
function CivetPrologueContent(ctx, state) {
|
|
12456
12457
|
return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
|
|
12457
12458
|
}
|
|
12458
|
-
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) {
|
|
12459
12460
|
const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
|
|
12460
12461
|
if (l)
|
|
12461
12462
|
return l.toUpperCase();
|
|
@@ -12476,7 +12477,7 @@ ${input.slice(result.pos)}
|
|
|
12476
12477
|
function UnknownPrologue(ctx, state) {
|
|
12477
12478
|
return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
|
|
12478
12479
|
}
|
|
12479
|
-
var TripleSlashDirective$0 = $S($R$0($EXPECT($
|
|
12480
|
+
var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
|
|
12480
12481
|
function TripleSlashDirective(ctx, state) {
|
|
12481
12482
|
return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
|
|
12482
12483
|
}
|
|
@@ -12490,13 +12491,13 @@ ${input.slice(result.pos)}
|
|
|
12490
12491
|
function PrologueString(ctx, state) {
|
|
12491
12492
|
return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
|
|
12492
12493
|
}
|
|
12493
|
-
var EOS$0 = $T($S($EXPECT($
|
|
12494
|
+
var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
|
|
12494
12495
|
return value[1];
|
|
12495
12496
|
});
|
|
12496
12497
|
function EOS(ctx, state) {
|
|
12497
12498
|
return $EVENT(ctx, state, "EOS", EOS$0);
|
|
12498
12499
|
}
|
|
12499
|
-
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) {
|
|
12500
12501
|
return { $loc, token: $0 };
|
|
12501
12502
|
});
|
|
12502
12503
|
function EOL(ctx, state) {
|
|
@@ -12990,7 +12991,7 @@ ${input.slice(result.pos)}
|
|
|
12990
12991
|
function Init(ctx, state) {
|
|
12991
12992
|
return $EVENT(ctx, state, "Init", Init$0);
|
|
12992
12993
|
}
|
|
12993
|
-
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) {
|
|
12994
12995
|
const level = getIndentLevel($0, module.config.tab);
|
|
12995
12996
|
return {
|
|
12996
12997
|
$loc,
|
|
@@ -14356,7 +14357,6 @@ ${input.slice(result.pos)}
|
|
|
14356
14357
|
if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
|
|
14357
14358
|
options.parseOptions.coffeeCompat = true;
|
|
14358
14359
|
}
|
|
14359
|
-
;
|
|
14360
14360
|
const { hits, trace, noCache } = options;
|
|
14361
14361
|
let events;
|
|
14362
14362
|
if (!noCache) {
|
|
@@ -14451,7 +14451,6 @@ ${counts}`;
|
|
|
14451
14451
|
if (uncacheable.has(ruleName)) {
|
|
14452
14452
|
return;
|
|
14453
14453
|
}
|
|
14454
|
-
;
|
|
14455
14454
|
const [stateKey, tagKey] = getStateKey();
|
|
14456
14455
|
const key = [tagKey, stateKey, state.pos, ruleName];
|
|
14457
14456
|
if (stateCache.has(key)) {
|
package/dist/civet
CHANGED
|
@@ -113,7 +113,6 @@ parseArgs = function(args) {
|
|
|
113
113
|
char = ref[i1];
|
|
114
114
|
results.push(`-${char}`);
|
|
115
115
|
}
|
|
116
|
-
;
|
|
117
116
|
return results;
|
|
118
117
|
})());
|
|
119
118
|
continue;
|
|
@@ -178,7 +177,6 @@ parseArgs = function(args) {
|
|
|
178
177
|
}
|
|
179
178
|
i++;
|
|
180
179
|
}
|
|
181
|
-
;
|
|
182
180
|
return { filenames, scriptArgs, options };
|
|
183
181
|
};
|
|
184
182
|
readFiles = async function* (filenames, options) {
|
|
@@ -216,7 +214,6 @@ readFiles = async function* (filenames, options) {
|
|
|
216
214
|
for await (chunk of process.stdin) {
|
|
217
215
|
results2.push(chunk);
|
|
218
216
|
}
|
|
219
|
-
;
|
|
220
217
|
return results2;
|
|
221
218
|
})()).join("");
|
|
222
219
|
}
|
|
@@ -404,7 +401,6 @@ cli = async function() {
|
|
|
404
401
|
process.exit(1);
|
|
405
402
|
}
|
|
406
403
|
}
|
|
407
|
-
;
|
|
408
404
|
const { fork } = await import("child_process");
|
|
409
405
|
execArgv = ["--loader", "@danielx/civet/esm"];
|
|
410
406
|
debugRe = /--debug|--inspect/;
|
package/dist/esbuild.js
CHANGED
|
@@ -48,7 +48,8 @@ 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
|
+
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
52
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
53
54
|
if (options.dts && options.js) {
|
|
54
55
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -56,11 +57,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
56
57
|
if (options.typecheck && options.js) {
|
|
57
58
|
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
58
59
|
}
|
|
59
|
-
const transpileToJS = options.js ??
|
|
60
|
+
const transpileToJS = options.js ?? false;
|
|
60
61
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
61
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
62
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
63
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
64
66
|
return {
|
|
65
67
|
name: "unplugin-civet",
|
|
66
68
|
enforce: "pre",
|
|
@@ -158,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
158
160
|
resolveId(id, importer) {
|
|
159
161
|
if (/\0/.test(id))
|
|
160
162
|
return null;
|
|
161
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
162
164
|
return null;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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$/, "");
|
|
167
169
|
const relativePath = relativeId + outExt;
|
|
168
170
|
return relativePath;
|
|
169
171
|
},
|
|
@@ -194,8 +196,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
194
196
|
transformed = await options.transformOutput(transformed.code, id);
|
|
195
197
|
return transformed;
|
|
196
198
|
},
|
|
199
|
+
transformInclude(id) {
|
|
200
|
+
return isCivetTranspiledTS(id);
|
|
201
|
+
},
|
|
197
202
|
transform(code, id) {
|
|
198
|
-
if (
|
|
203
|
+
if (!isCivetTranspiledTS(id))
|
|
199
204
|
return null;
|
|
200
205
|
if (options.dts || options.typecheck) {
|
|
201
206
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
@@ -207,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
207
212
|
return null;
|
|
208
213
|
},
|
|
209
214
|
vite: {
|
|
210
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
211
217
|
if (command === "build") {
|
|
212
218
|
return {
|
|
213
219
|
esbuild: {
|
|
@@ -217,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
217
223
|
};
|
|
218
224
|
}
|
|
219
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
|
+
);
|
|
220
244
|
}
|
|
221
245
|
}
|
|
222
246
|
};
|
package/dist/main.js
CHANGED
|
@@ -812,7 +812,6 @@ var require_lib = __commonJS({
|
|
|
812
812
|
const part = strWithSubstitutions[i2];
|
|
813
813
|
results1.push(part.token ?? "s");
|
|
814
814
|
}
|
|
815
|
-
;
|
|
816
815
|
return results1;
|
|
817
816
|
})().join("");
|
|
818
817
|
const dedent = /^[ \t]*\r?\n/.test(stringPart) ? getIndentOfBlockString(stringPart, tab) : false;
|
|
@@ -2299,7 +2298,6 @@ var require_lib = __commonJS({
|
|
|
2299
2298
|
if (!condition?.expression) {
|
|
2300
2299
|
return;
|
|
2301
2300
|
}
|
|
2302
|
-
;
|
|
2303
2301
|
let { expression } = condition;
|
|
2304
2302
|
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && expression.children.length === 2 && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
|
|
2305
2303
|
const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
|
|
@@ -4712,12 +4710,13 @@ var require_parser = __commonJS({
|
|
|
4712
4710
|
var $R79 = $R(new RegExp("[+-]", "suy"));
|
|
4713
4711
|
var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
|
|
4714
4712
|
var $R81 = $R(new RegExp("[\\t ]*", "suy"));
|
|
4715
|
-
var $R82 = $R(new RegExp("[\\
|
|
4716
|
-
var $R83 = $R(new RegExp("\\
|
|
4717
|
-
var $R84 = $R(new RegExp("
|
|
4718
|
-
var $R85 = $R(new RegExp("(
|
|
4719
|
-
var $R86 = $R(new RegExp("
|
|
4720
|
-
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"));
|
|
4721
4720
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4722
4721
|
var statements = $4;
|
|
4723
4722
|
processProgram({
|
|
@@ -12424,19 +12423,21 @@ var require_parser = __commonJS({
|
|
|
12424
12423
|
function Shebang(ctx, state) {
|
|
12425
12424
|
return $EVENT(ctx, state, "Shebang", Shebang$0);
|
|
12426
12425
|
}
|
|
12427
|
-
var CivetPrologue$0 = $
|
|
12428
|
-
var content =
|
|
12429
|
-
|
|
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] };
|
|
12430
12430
|
});
|
|
12431
|
-
var CivetPrologue$1 = $
|
|
12432
|
-
var content =
|
|
12433
|
-
|
|
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] };
|
|
12434
12435
|
});
|
|
12435
12436
|
var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
|
|
12436
12437
|
function CivetPrologue(ctx, state) {
|
|
12437
12438
|
return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
|
|
12438
12439
|
}
|
|
12439
|
-
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) {
|
|
12440
12441
|
var options = $3;
|
|
12441
12442
|
return {
|
|
12442
12443
|
type: "CivetPrologue",
|
|
@@ -12447,7 +12448,7 @@ var require_parser = __commonJS({
|
|
|
12447
12448
|
function CivetPrologueContent(ctx, state) {
|
|
12448
12449
|
return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
|
|
12449
12450
|
}
|
|
12450
|
-
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) {
|
|
12451
12452
|
const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
|
|
12452
12453
|
if (l)
|
|
12453
12454
|
return l.toUpperCase();
|
|
@@ -12468,7 +12469,7 @@ var require_parser = __commonJS({
|
|
|
12468
12469
|
function UnknownPrologue(ctx, state) {
|
|
12469
12470
|
return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
|
|
12470
12471
|
}
|
|
12471
|
-
var TripleSlashDirective$0 = $S($R$0($EXPECT($
|
|
12472
|
+
var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
|
|
12472
12473
|
function TripleSlashDirective(ctx, state) {
|
|
12473
12474
|
return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
|
|
12474
12475
|
}
|
|
@@ -12482,13 +12483,13 @@ var require_parser = __commonJS({
|
|
|
12482
12483
|
function PrologueString(ctx, state) {
|
|
12483
12484
|
return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
|
|
12484
12485
|
}
|
|
12485
|
-
var EOS$0 = $T($S($EXPECT($
|
|
12486
|
+
var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
|
|
12486
12487
|
return value[1];
|
|
12487
12488
|
});
|
|
12488
12489
|
function EOS(ctx, state) {
|
|
12489
12490
|
return $EVENT(ctx, state, "EOS", EOS$0);
|
|
12490
12491
|
}
|
|
12491
|
-
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) {
|
|
12492
12493
|
return { $loc, token: $0 };
|
|
12493
12494
|
});
|
|
12494
12495
|
function EOL(ctx, state) {
|
|
@@ -12982,7 +12983,7 @@ var require_parser = __commonJS({
|
|
|
12982
12983
|
function Init(ctx, state) {
|
|
12983
12984
|
return $EVENT(ctx, state, "Init", Init$0);
|
|
12984
12985
|
}
|
|
12985
|
-
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) {
|
|
12986
12987
|
const level = getIndentLevel($0, module2.config.tab);
|
|
12987
12988
|
return {
|
|
12988
12989
|
$loc,
|
|
@@ -14349,7 +14350,6 @@ function compile(src, options) {
|
|
|
14349
14350
|
if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
|
|
14350
14351
|
options.parseOptions.coffeeCompat = true;
|
|
14351
14352
|
}
|
|
14352
|
-
;
|
|
14353
14353
|
const { hits, trace, noCache } = options;
|
|
14354
14354
|
let events;
|
|
14355
14355
|
if (!noCache) {
|
|
@@ -14444,7 +14444,6 @@ function makeCache({ hits, trace } = {}) {
|
|
|
14444
14444
|
if (uncacheable.has(ruleName)) {
|
|
14445
14445
|
return;
|
|
14446
14446
|
}
|
|
14447
|
-
;
|
|
14448
14447
|
const [stateKey, tagKey] = getStateKey();
|
|
14449
14448
|
const key = [tagKey, stateKey, state.pos, ruleName];
|
|
14450
14449
|
if (stateCache.has(key)) {
|
package/dist/main.mjs
CHANGED
|
@@ -810,7 +810,6 @@ var require_lib = __commonJS({
|
|
|
810
810
|
const part = strWithSubstitutions[i2];
|
|
811
811
|
results1.push(part.token ?? "s");
|
|
812
812
|
}
|
|
813
|
-
;
|
|
814
813
|
return results1;
|
|
815
814
|
})().join("");
|
|
816
815
|
const dedent = /^[ \t]*\r?\n/.test(stringPart) ? getIndentOfBlockString(stringPart, tab) : false;
|
|
@@ -2297,7 +2296,6 @@ var require_lib = __commonJS({
|
|
|
2297
2296
|
if (!condition?.expression) {
|
|
2298
2297
|
return;
|
|
2299
2298
|
}
|
|
2300
|
-
;
|
|
2301
2299
|
let { expression } = condition;
|
|
2302
2300
|
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "UnaryExpression" && "children" in expression && Array.isArray(expression.children) && expression.children.length === 2 && expression.children[0] === "!" && typeof expression.children[1] === "object" && expression.children[1] != null && "type" in expression.children[1] && expression.children[1].type === "ParenthesizedExpression" && "expression" in expression.children[1]) {
|
|
2303
2301
|
const { type: type1, children: [, { type: type2, expression: expression2 }] } = expression;
|
|
@@ -4710,12 +4708,13 @@ var require_parser = __commonJS({
|
|
|
4710
4708
|
var $R79 = $R(new RegExp("[+-]", "suy"));
|
|
4711
4709
|
var $R80 = $R(new RegExp("#![^\\r\\n]*", "suy"));
|
|
4712
4710
|
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]
|
|
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"));
|
|
4719
4718
|
var Program$0 = $TS($S(Reset, Init, $E(EOS), TopLevelStatements, __), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
4720
4719
|
var statements = $4;
|
|
4721
4720
|
processProgram({
|
|
@@ -12422,19 +12421,21 @@ var require_parser = __commonJS({
|
|
|
12422
12421
|
function Shebang(ctx, state) {
|
|
12423
12422
|
return $EVENT(ctx, state, "Shebang", Shebang$0);
|
|
12424
12423
|
}
|
|
12425
|
-
var CivetPrologue$0 = $
|
|
12426
|
-
var content =
|
|
12427
|
-
|
|
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] };
|
|
12428
12428
|
});
|
|
12429
|
-
var CivetPrologue$1 = $
|
|
12430
|
-
var content =
|
|
12431
|
-
|
|
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] };
|
|
12432
12433
|
});
|
|
12433
12434
|
var CivetPrologue$$ = [CivetPrologue$0, CivetPrologue$1];
|
|
12434
12435
|
function CivetPrologue(ctx, state) {
|
|
12435
12436
|
return $EVENT_C(ctx, state, "CivetPrologue", CivetPrologue$$);
|
|
12436
12437
|
}
|
|
12437
|
-
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) {
|
|
12438
12439
|
var options = $3;
|
|
12439
12440
|
return {
|
|
12440
12441
|
type: "CivetPrologue",
|
|
@@ -12445,7 +12446,7 @@ var require_parser = __commonJS({
|
|
|
12445
12446
|
function CivetPrologueContent(ctx, state) {
|
|
12446
12447
|
return $EVENT(ctx, state, "CivetPrologueContent", CivetPrologueContent$0);
|
|
12447
12448
|
}
|
|
12448
|
-
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) {
|
|
12449
12450
|
const optionName = $2.replace(/-+([a-z]?)/g, (_2, l) => {
|
|
12450
12451
|
if (l)
|
|
12451
12452
|
return l.toUpperCase();
|
|
@@ -12466,7 +12467,7 @@ var require_parser = __commonJS({
|
|
|
12466
12467
|
function UnknownPrologue(ctx, state) {
|
|
12467
12468
|
return $EVENT(ctx, state, "UnknownPrologue", UnknownPrologue$0);
|
|
12468
12469
|
}
|
|
12469
|
-
var TripleSlashDirective$0 = $S($R$0($EXPECT($
|
|
12470
|
+
var TripleSlashDirective$0 = $S($R$0($EXPECT($R86, "TripleSlashDirective /\\/\\/\\/[^\\r\\n]*/")), $E(EOS));
|
|
12470
12471
|
function TripleSlashDirective(ctx, state) {
|
|
12471
12472
|
return $EVENT(ctx, state, "TripleSlashDirective", TripleSlashDirective$0);
|
|
12472
12473
|
}
|
|
@@ -12480,13 +12481,13 @@ var require_parser = __commonJS({
|
|
|
12480
12481
|
function PrologueString(ctx, state) {
|
|
12481
12482
|
return $EVENT_C(ctx, state, "PrologueString", PrologueString$$);
|
|
12482
12483
|
}
|
|
12483
|
-
var EOS$0 = $T($S($EXPECT($
|
|
12484
|
+
var EOS$0 = $T($S($EXPECT($R87, "EOS /(?=[ \\t\\r\\n\\/#]|$)/"), $P(RestOfLine)), function(value) {
|
|
12484
12485
|
return value[1];
|
|
12485
12486
|
});
|
|
12486
12487
|
function EOS(ctx, state) {
|
|
12487
12488
|
return $EVENT(ctx, state, "EOS", EOS$0);
|
|
12488
12489
|
}
|
|
12489
|
-
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) {
|
|
12490
12491
|
return { $loc, token: $0 };
|
|
12491
12492
|
});
|
|
12492
12493
|
function EOL(ctx, state) {
|
|
@@ -12980,7 +12981,7 @@ var require_parser = __commonJS({
|
|
|
12980
12981
|
function Init(ctx, state) {
|
|
12981
12982
|
return $EVENT(ctx, state, "Init", Init$0);
|
|
12982
12983
|
}
|
|
12983
|
-
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) {
|
|
12984
12985
|
const level = getIndentLevel($0, module.config.tab);
|
|
12985
12986
|
return {
|
|
12986
12987
|
$loc,
|
|
@@ -14336,7 +14337,6 @@ function compile(src, options) {
|
|
|
14336
14337
|
if (filename.endsWith(".coffee") && !/^(#![^\r\n]*(\r\n|\n|\r))?\s*['"]civet/.test(src)) {
|
|
14337
14338
|
options.parseOptions.coffeeCompat = true;
|
|
14338
14339
|
}
|
|
14339
|
-
;
|
|
14340
14340
|
const { hits, trace, noCache } = options;
|
|
14341
14341
|
let events;
|
|
14342
14342
|
if (!noCache) {
|
|
@@ -14431,7 +14431,6 @@ function makeCache({ hits, trace } = {}) {
|
|
|
14431
14431
|
if (uncacheable.has(ruleName)) {
|
|
14432
14432
|
return;
|
|
14433
14433
|
}
|
|
14434
|
-
;
|
|
14435
14434
|
const [stateKey, tagKey] = getStateKey();
|
|
14436
14435
|
const key = [tagKey, stateKey, state.pos, ruleName];
|
|
14437
14436
|
if (stateCache.has(key)) {
|
package/dist/rollup.js
CHANGED
|
@@ -48,7 +48,8 @@ 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
|
+
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
52
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
53
54
|
if (options.dts && options.js) {
|
|
54
55
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -56,11 +57,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
56
57
|
if (options.typecheck && options.js) {
|
|
57
58
|
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
58
59
|
}
|
|
59
|
-
const transpileToJS = options.js ??
|
|
60
|
+
const transpileToJS = options.js ?? false;
|
|
60
61
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
61
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
62
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
63
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
64
66
|
return {
|
|
65
67
|
name: "unplugin-civet",
|
|
66
68
|
enforce: "pre",
|
|
@@ -158,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
158
160
|
resolveId(id, importer) {
|
|
159
161
|
if (/\0/.test(id))
|
|
160
162
|
return null;
|
|
161
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
162
164
|
return null;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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$/, "");
|
|
167
169
|
const relativePath = relativeId + outExt;
|
|
168
170
|
return relativePath;
|
|
169
171
|
},
|
|
@@ -194,8 +196,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
194
196
|
transformed = await options.transformOutput(transformed.code, id);
|
|
195
197
|
return transformed;
|
|
196
198
|
},
|
|
199
|
+
transformInclude(id) {
|
|
200
|
+
return isCivetTranspiledTS(id);
|
|
201
|
+
},
|
|
197
202
|
transform(code, id) {
|
|
198
|
-
if (
|
|
203
|
+
if (!isCivetTranspiledTS(id))
|
|
199
204
|
return null;
|
|
200
205
|
if (options.dts || options.typecheck) {
|
|
201
206
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
@@ -207,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
207
212
|
return null;
|
|
208
213
|
},
|
|
209
214
|
vite: {
|
|
210
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
211
217
|
if (command === "build") {
|
|
212
218
|
return {
|
|
213
219
|
esbuild: {
|
|
@@ -217,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
217
223
|
};
|
|
218
224
|
}
|
|
219
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
|
+
);
|
|
220
244
|
}
|
|
221
245
|
}
|
|
222
246
|
};
|
package/dist/unplugin-shared.mjs
CHANGED
|
@@ -17,7 +17,8 @@ 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
|
+
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
21
22
|
var civetUnplugin = createUnplugin((options = {}) => {
|
|
22
23
|
if (options.dts && options.js) {
|
|
23
24
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -25,11 +26,12 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
25
26
|
if (options.typecheck && options.js) {
|
|
26
27
|
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
27
28
|
}
|
|
28
|
-
const transpileToJS = options.js ??
|
|
29
|
+
const transpileToJS = options.js ?? false;
|
|
29
30
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
30
31
|
let fsMap = /* @__PURE__ */ new Map();
|
|
31
32
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
32
33
|
let compilerOptions;
|
|
34
|
+
let rootDir;
|
|
33
35
|
return {
|
|
34
36
|
name: "unplugin-civet",
|
|
35
37
|
enforce: "pre",
|
|
@@ -127,12 +129,12 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
127
129
|
resolveId(id, importer) {
|
|
128
130
|
if (/\0/.test(id))
|
|
129
131
|
return null;
|
|
130
|
-
if (!isCivet(id))
|
|
132
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
131
133
|
return null;
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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$/, "");
|
|
136
138
|
const relativePath = relativeId + outExt;
|
|
137
139
|
return relativePath;
|
|
138
140
|
},
|
|
@@ -163,8 +165,11 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
163
165
|
transformed = await options.transformOutput(transformed.code, id);
|
|
164
166
|
return transformed;
|
|
165
167
|
},
|
|
168
|
+
transformInclude(id) {
|
|
169
|
+
return isCivetTranspiledTS(id);
|
|
170
|
+
},
|
|
166
171
|
transform(code, id) {
|
|
167
|
-
if (
|
|
172
|
+
if (!isCivetTranspiledTS(id))
|
|
168
173
|
return null;
|
|
169
174
|
if (options.dts || options.typecheck) {
|
|
170
175
|
const resolved = path.resolve(process.cwd(), id);
|
|
@@ -176,7 +181,8 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
176
181
|
return null;
|
|
177
182
|
},
|
|
178
183
|
vite: {
|
|
179
|
-
config(
|
|
184
|
+
config(config, { command }) {
|
|
185
|
+
rootDir = path.resolve(process.cwd(), config.root ?? "");
|
|
180
186
|
if (command === "build") {
|
|
181
187
|
return {
|
|
182
188
|
esbuild: {
|
|
@@ -186,6 +192,24 @@ var civetUnplugin = createUnplugin((options = {}) => {
|
|
|
186
192
|
};
|
|
187
193
|
}
|
|
188
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
|
+
);
|
|
189
213
|
}
|
|
190
214
|
}
|
|
191
215
|
};
|
package/dist/unplugin.js
CHANGED
|
@@ -46,7 +46,8 @@ 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
|
+
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
50
51
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
51
52
|
if (options.dts && options.js) {
|
|
52
53
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -54,11 +55,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
54
55
|
if (options.typecheck && options.js) {
|
|
55
56
|
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
56
57
|
}
|
|
57
|
-
const transpileToJS = options.js ??
|
|
58
|
+
const transpileToJS = options.js ?? false;
|
|
58
59
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
59
60
|
let fsMap = /* @__PURE__ */ new Map();
|
|
60
61
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
61
62
|
let compilerOptions;
|
|
63
|
+
let rootDir;
|
|
62
64
|
return {
|
|
63
65
|
name: "unplugin-civet",
|
|
64
66
|
enforce: "pre",
|
|
@@ -156,12 +158,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
156
158
|
resolveId(id, importer) {
|
|
157
159
|
if (/\0/.test(id))
|
|
158
160
|
return null;
|
|
159
|
-
if (!isCivet(id))
|
|
161
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
160
162
|
return null;
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
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$/, "");
|
|
165
167
|
const relativePath = relativeId + outExt;
|
|
166
168
|
return relativePath;
|
|
167
169
|
},
|
|
@@ -192,8 +194,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
192
194
|
transformed = await options.transformOutput(transformed.code, id);
|
|
193
195
|
return transformed;
|
|
194
196
|
},
|
|
197
|
+
transformInclude(id) {
|
|
198
|
+
return isCivetTranspiledTS(id);
|
|
199
|
+
},
|
|
195
200
|
transform(code, id) {
|
|
196
|
-
if (
|
|
201
|
+
if (!isCivetTranspiledTS(id))
|
|
197
202
|
return null;
|
|
198
203
|
if (options.dts || options.typecheck) {
|
|
199
204
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
@@ -205,7 +210,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
205
210
|
return null;
|
|
206
211
|
},
|
|
207
212
|
vite: {
|
|
208
|
-
config(
|
|
213
|
+
config(config, { command }) {
|
|
214
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
209
215
|
if (command === "build") {
|
|
210
216
|
return {
|
|
211
217
|
esbuild: {
|
|
@@ -215,6 +221,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
215
221
|
};
|
|
216
222
|
}
|
|
217
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
|
+
);
|
|
218
242
|
}
|
|
219
243
|
}
|
|
220
244
|
};
|
package/dist/vite.js
CHANGED
|
@@ -48,7 +48,8 @@ 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
|
+
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
52
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
53
54
|
if (options.dts && options.js) {
|
|
54
55
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -56,11 +57,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
56
57
|
if (options.typecheck && options.js) {
|
|
57
58
|
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
58
59
|
}
|
|
59
|
-
const transpileToJS = options.js ??
|
|
60
|
+
const transpileToJS = options.js ?? false;
|
|
60
61
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
61
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
62
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
63
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
64
66
|
return {
|
|
65
67
|
name: "unplugin-civet",
|
|
66
68
|
enforce: "pre",
|
|
@@ -158,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
158
160
|
resolveId(id, importer) {
|
|
159
161
|
if (/\0/.test(id))
|
|
160
162
|
return null;
|
|
161
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
162
164
|
return null;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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$/, "");
|
|
167
169
|
const relativePath = relativeId + outExt;
|
|
168
170
|
return relativePath;
|
|
169
171
|
},
|
|
@@ -194,8 +196,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
194
196
|
transformed = await options.transformOutput(transformed.code, id);
|
|
195
197
|
return transformed;
|
|
196
198
|
},
|
|
199
|
+
transformInclude(id) {
|
|
200
|
+
return isCivetTranspiledTS(id);
|
|
201
|
+
},
|
|
197
202
|
transform(code, id) {
|
|
198
|
-
if (
|
|
203
|
+
if (!isCivetTranspiledTS(id))
|
|
199
204
|
return null;
|
|
200
205
|
if (options.dts || options.typecheck) {
|
|
201
206
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
@@ -207,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
207
212
|
return null;
|
|
208
213
|
},
|
|
209
214
|
vite: {
|
|
210
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
211
217
|
if (command === "build") {
|
|
212
218
|
return {
|
|
213
219
|
esbuild: {
|
|
@@ -217,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
217
223
|
};
|
|
218
224
|
}
|
|
219
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
|
+
);
|
|
220
244
|
}
|
|
221
245
|
}
|
|
222
246
|
};
|
package/dist/webpack.js
CHANGED
|
@@ -48,7 +48,8 @@ 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
|
+
var isCivetTranspiledTS = (id) => /\.civet\.(m?)ts(x?)$/.test(id);
|
|
52
53
|
var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
53
54
|
if (options.dts && options.js) {
|
|
54
55
|
throw new Error("Can't have both `dts` and `js` be set to `true`.");
|
|
@@ -56,11 +57,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
56
57
|
if (options.typecheck && options.js) {
|
|
57
58
|
throw new Error("Can't have both `typecheck` and `js` be set to `true`.");
|
|
58
59
|
}
|
|
59
|
-
const transpileToJS = options.js ??
|
|
60
|
+
const transpileToJS = options.js ?? false;
|
|
60
61
|
const outExt = options.outputExtension ?? (transpileToJS ? ".jsx" : ".tsx");
|
|
61
62
|
let fsMap = /* @__PURE__ */ new Map();
|
|
62
63
|
const sourceMaps = /* @__PURE__ */ new Map();
|
|
63
64
|
let compilerOptions;
|
|
65
|
+
let rootDir;
|
|
64
66
|
return {
|
|
65
67
|
name: "unplugin-civet",
|
|
66
68
|
enforce: "pre",
|
|
@@ -158,12 +160,12 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
158
160
|
resolveId(id, importer) {
|
|
159
161
|
if (/\0/.test(id))
|
|
160
162
|
return null;
|
|
161
|
-
if (!isCivet(id))
|
|
163
|
+
if (!isCivet(id) && !isCivetTranspiled(id))
|
|
162
164
|
return null;
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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$/, "");
|
|
167
169
|
const relativePath = relativeId + outExt;
|
|
168
170
|
return relativePath;
|
|
169
171
|
},
|
|
@@ -194,8 +196,11 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
194
196
|
transformed = await options.transformOutput(transformed.code, id);
|
|
195
197
|
return transformed;
|
|
196
198
|
},
|
|
199
|
+
transformInclude(id) {
|
|
200
|
+
return isCivetTranspiledTS(id);
|
|
201
|
+
},
|
|
197
202
|
transform(code, id) {
|
|
198
|
-
if (
|
|
203
|
+
if (!isCivetTranspiledTS(id))
|
|
199
204
|
return null;
|
|
200
205
|
if (options.dts || options.typecheck) {
|
|
201
206
|
const resolved = import_path.default.resolve(process.cwd(), id);
|
|
@@ -207,7 +212,8 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
207
212
|
return null;
|
|
208
213
|
},
|
|
209
214
|
vite: {
|
|
210
|
-
config(
|
|
215
|
+
config(config, { command }) {
|
|
216
|
+
rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
|
|
211
217
|
if (command === "build") {
|
|
212
218
|
return {
|
|
213
219
|
esbuild: {
|
|
@@ -217,6 +223,24 @@ var civetUnplugin = (0, import_unplugin.createUnplugin)((options = {}) => {
|
|
|
217
223
|
};
|
|
218
224
|
}
|
|
219
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
|
+
);
|
|
220
244
|
}
|
|
221
245
|
}
|
|
222
246
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielx/civet",
|
|
3
3
|
"type": "commonjs",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.47",
|
|
5
5
|
"description": "CoffeeScript style syntax for TypeScript",
|
|
6
6
|
"main": "dist/main.js",
|
|
7
7
|
"module": "dist/main.mjs",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"unplugin": "^1.4.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@danielx/civet": "0.6.
|
|
73
|
+
"@danielx/civet": "0.6.45",
|
|
74
74
|
"@danielx/hera": "^0.8.10",
|
|
75
75
|
"@types/assert": "^1.5.6",
|
|
76
76
|
"@types/mocha": "^9.1.1",
|