@danielx/civet 0.6.79 → 0.6.81
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 +15 -2
- package/dist/esbuild.js +51 -7
- package/dist/main.js +15 -2
- package/dist/main.mjs +15 -2
- package/dist/rollup.js +51 -7
- package/dist/unplugin-shared.mjs +51 -7
- package/dist/unplugin.d.mts +3 -3
- package/dist/unplugin.d.ts +3 -3
- package/dist/unplugin.js +51 -7
- package/dist/vite.js +51 -7
- package/dist/webpack.js +51 -7
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -2411,9 +2411,16 @@ var Civet = (() => {
|
|
|
2411
2411
|
const { decl, bindings } = condition.declaration;
|
|
2412
2412
|
const binding = bindings[0];
|
|
2413
2413
|
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2414
|
+
const grandparent = condition.parent?.parent;
|
|
2415
|
+
const children = (
|
|
2416
|
+
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2417
|
+
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2418
|
+
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2419
|
+
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2420
|
+
);
|
|
2414
2421
|
Object.assign(condition, {
|
|
2415
2422
|
type: "AssignmentExpression",
|
|
2416
|
-
children
|
|
2423
|
+
children,
|
|
2417
2424
|
hoistDec: {
|
|
2418
2425
|
type: "Declaration",
|
|
2419
2426
|
children: ["let ", ref, suffix],
|
|
@@ -2887,7 +2894,13 @@ var Civet = (() => {
|
|
|
2887
2894
|
};
|
|
2888
2895
|
}
|
|
2889
2896
|
function modifyString(str) {
|
|
2890
|
-
return str.replace(/(
|
|
2897
|
+
return str.replace(/((?:\\.|[^\r\n])*)(\r\n|\n|\r)?/gsu, function(_, chars, nl) {
|
|
2898
|
+
if (nl) {
|
|
2899
|
+
return chars + "\\n";
|
|
2900
|
+
} else {
|
|
2901
|
+
return chars;
|
|
2902
|
+
}
|
|
2903
|
+
});
|
|
2891
2904
|
}
|
|
2892
2905
|
function quoteString(str) {
|
|
2893
2906
|
str = str.replace(/\\/g, "\\\\");
|
package/dist/esbuild.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -222,6 +247,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
222
247
|
compilerOptions.outDir ?? process.cwd(),
|
|
223
248
|
filePath
|
|
224
249
|
);
|
|
250
|
+
if (meta.framework === "esbuild") {
|
|
251
|
+
fs.mkdirSync(
|
|
252
|
+
import_path.default.dirname(
|
|
253
|
+
import_path.default.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
254
|
+
),
|
|
255
|
+
{ recursive: true }
|
|
256
|
+
);
|
|
257
|
+
}
|
|
225
258
|
this.emitFile({
|
|
226
259
|
source: content,
|
|
227
260
|
fileName: pathFromDistDir,
|
|
@@ -229,13 +262,18 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
229
262
|
});
|
|
230
263
|
},
|
|
231
264
|
void 0,
|
|
265
|
+
true,
|
|
266
|
+
// emitDtsOnly
|
|
267
|
+
void 0,
|
|
268
|
+
// @ts-ignore @internal interface
|
|
232
269
|
true
|
|
270
|
+
// forceDtsEmit
|
|
233
271
|
);
|
|
234
272
|
}
|
|
235
273
|
}
|
|
236
274
|
}
|
|
237
275
|
},
|
|
238
|
-
resolveId(id, importer) {
|
|
276
|
+
resolveId(id, importer, options2) {
|
|
239
277
|
if (/\0/.test(id))
|
|
240
278
|
return null;
|
|
241
279
|
id = cleanCivetId(id);
|
|
@@ -250,15 +288,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
250
288
|
return null;
|
|
251
289
|
resolvedId = implicitId;
|
|
252
290
|
}
|
|
291
|
+
if (options2.scan && meta.framework === "vite") {
|
|
292
|
+
resolvedId = `\0${resolvedId}`;
|
|
293
|
+
}
|
|
253
294
|
return resolvedId + outExt;
|
|
254
295
|
},
|
|
255
296
|
loadInclude(id) {
|
|
256
|
-
return isCivetTranspiled(id);
|
|
297
|
+
return isCivetTranspiled.test(id);
|
|
257
298
|
},
|
|
258
299
|
async load(id) {
|
|
259
|
-
|
|
300
|
+
const match = isCivetTranspiled.exec(id);
|
|
301
|
+
if (!match)
|
|
260
302
|
return null;
|
|
261
|
-
const
|
|
303
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
304
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
262
305
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
263
306
|
this.addWatchFile(filename);
|
|
264
307
|
let compiled;
|
|
@@ -389,7 +432,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
389
432
|
}
|
|
390
433
|
};
|
|
391
434
|
};
|
|
392
|
-
var
|
|
435
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
436
|
+
var src_default = unplugin;
|
|
393
437
|
|
|
394
438
|
// src/esbuild.ts
|
|
395
439
|
var esbuild_default = src_default.esbuild;
|
package/dist/main.js
CHANGED
|
@@ -2403,9 +2403,16 @@ function processDeclarationCondition(condition, rootCondition, parent) {
|
|
|
2403
2403
|
const { decl, bindings } = condition.declaration;
|
|
2404
2404
|
const binding = bindings[0];
|
|
2405
2405
|
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2406
|
+
const grandparent = condition.parent?.parent;
|
|
2407
|
+
const children = (
|
|
2408
|
+
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2409
|
+
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2410
|
+
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2411
|
+
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2412
|
+
);
|
|
2406
2413
|
Object.assign(condition, {
|
|
2407
2414
|
type: "AssignmentExpression",
|
|
2408
|
-
children
|
|
2415
|
+
children,
|
|
2409
2416
|
hoistDec: {
|
|
2410
2417
|
type: "Declaration",
|
|
2411
2418
|
children: ["let ", ref, suffix],
|
|
@@ -2879,7 +2886,13 @@ function processCoffeeInterpolation(s, parts, e, $loc) {
|
|
|
2879
2886
|
};
|
|
2880
2887
|
}
|
|
2881
2888
|
function modifyString(str) {
|
|
2882
|
-
return str.replace(/(
|
|
2889
|
+
return str.replace(/((?:\\.|[^\r\n])*)(\r\n|\n|\r)?/gsu, function(_, chars, nl) {
|
|
2890
|
+
if (nl) {
|
|
2891
|
+
return chars + "\\n";
|
|
2892
|
+
} else {
|
|
2893
|
+
return chars;
|
|
2894
|
+
}
|
|
2895
|
+
});
|
|
2883
2896
|
}
|
|
2884
2897
|
function quoteString(str) {
|
|
2885
2898
|
str = str.replace(/\\/g, "\\\\");
|
package/dist/main.mjs
CHANGED
|
@@ -2401,9 +2401,16 @@ function processDeclarationCondition(condition, rootCondition, parent) {
|
|
|
2401
2401
|
const { decl, bindings } = condition.declaration;
|
|
2402
2402
|
const binding = bindings[0];
|
|
2403
2403
|
const { pattern, suffix, initializer, splices, thisAssignments } = binding;
|
|
2404
|
+
const grandparent = condition.parent?.parent;
|
|
2405
|
+
const children = (
|
|
2406
|
+
// Check that the declaration is a plain assignment (no pattern-matching) and the immediate grandchild of an `if` or `while`
|
|
2407
|
+
// More complex conditions (triggered by pattern matching or `until`/`unless`) don't need double parens
|
|
2408
|
+
// @ts-ignore Just because pattern might not have a type at runtime doesn't mean it's unsafe
|
|
2409
|
+
pattern.type === "Identifier" && (grandparent?.type === "IfStatement" || grandparent?.type === "WhileStatement") ? ["(", ref, initializer, ")"] : [ref, initializer]
|
|
2410
|
+
);
|
|
2404
2411
|
Object.assign(condition, {
|
|
2405
2412
|
type: "AssignmentExpression",
|
|
2406
|
-
children
|
|
2413
|
+
children,
|
|
2407
2414
|
hoistDec: {
|
|
2408
2415
|
type: "Declaration",
|
|
2409
2416
|
children: ["let ", ref, suffix],
|
|
@@ -2877,7 +2884,13 @@ function processCoffeeInterpolation(s, parts, e, $loc) {
|
|
|
2877
2884
|
};
|
|
2878
2885
|
}
|
|
2879
2886
|
function modifyString(str) {
|
|
2880
|
-
return str.replace(/(
|
|
2887
|
+
return str.replace(/((?:\\.|[^\r\n])*)(\r\n|\n|\r)?/gsu, function(_, chars, nl) {
|
|
2888
|
+
if (nl) {
|
|
2889
|
+
return chars + "\\n";
|
|
2890
|
+
} else {
|
|
2891
|
+
return chars;
|
|
2892
|
+
}
|
|
2893
|
+
});
|
|
2881
2894
|
}
|
|
2882
2895
|
function quoteString(str) {
|
|
2883
2896
|
str = str.replace(/\\/g, "\\\\");
|
package/dist/rollup.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -222,6 +247,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
222
247
|
compilerOptions.outDir ?? process.cwd(),
|
|
223
248
|
filePath
|
|
224
249
|
);
|
|
250
|
+
if (meta.framework === "esbuild") {
|
|
251
|
+
fs.mkdirSync(
|
|
252
|
+
import_path.default.dirname(
|
|
253
|
+
import_path.default.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
254
|
+
),
|
|
255
|
+
{ recursive: true }
|
|
256
|
+
);
|
|
257
|
+
}
|
|
225
258
|
this.emitFile({
|
|
226
259
|
source: content,
|
|
227
260
|
fileName: pathFromDistDir,
|
|
@@ -229,13 +262,18 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
229
262
|
});
|
|
230
263
|
},
|
|
231
264
|
void 0,
|
|
265
|
+
true,
|
|
266
|
+
// emitDtsOnly
|
|
267
|
+
void 0,
|
|
268
|
+
// @ts-ignore @internal interface
|
|
232
269
|
true
|
|
270
|
+
// forceDtsEmit
|
|
233
271
|
);
|
|
234
272
|
}
|
|
235
273
|
}
|
|
236
274
|
}
|
|
237
275
|
},
|
|
238
|
-
resolveId(id, importer) {
|
|
276
|
+
resolveId(id, importer, options2) {
|
|
239
277
|
if (/\0/.test(id))
|
|
240
278
|
return null;
|
|
241
279
|
id = cleanCivetId(id);
|
|
@@ -250,15 +288,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
250
288
|
return null;
|
|
251
289
|
resolvedId = implicitId;
|
|
252
290
|
}
|
|
291
|
+
if (options2.scan && meta.framework === "vite") {
|
|
292
|
+
resolvedId = `\0${resolvedId}`;
|
|
293
|
+
}
|
|
253
294
|
return resolvedId + outExt;
|
|
254
295
|
},
|
|
255
296
|
loadInclude(id) {
|
|
256
|
-
return isCivetTranspiled(id);
|
|
297
|
+
return isCivetTranspiled.test(id);
|
|
257
298
|
},
|
|
258
299
|
async load(id) {
|
|
259
|
-
|
|
300
|
+
const match = isCivetTranspiled.exec(id);
|
|
301
|
+
if (!match)
|
|
260
302
|
return null;
|
|
261
|
-
const
|
|
303
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
304
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
262
305
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
263
306
|
this.addWatchFile(filename);
|
|
264
307
|
let compiled;
|
|
@@ -389,7 +432,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
389
432
|
}
|
|
390
433
|
};
|
|
391
434
|
};
|
|
392
|
-
var
|
|
435
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
436
|
+
var src_default = unplugin;
|
|
393
437
|
|
|
394
438
|
// src/rollup.ts
|
|
395
439
|
var rollup_default = src_default.rollup;
|
package/dist/unplugin-shared.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import * as fs from "fs";
|
|
|
9
9
|
import path from "path";
|
|
10
10
|
import * as tsvfs from "@typescript/vfs";
|
|
11
11
|
import os from "os";
|
|
12
|
-
var isCivetTranspiled = (
|
|
12
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
13
13
|
var postfixRE = /[?#].*$/s;
|
|
14
14
|
var isWindows = os.platform() === "win32";
|
|
15
15
|
var windowsSlashRE = /\\/g;
|
|
@@ -93,7 +93,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
93
93
|
);
|
|
94
94
|
compilerOptions = {
|
|
95
95
|
...configContents.options,
|
|
96
|
-
target: ts.ScriptTarget.ESNext
|
|
96
|
+
target: ts.ScriptTarget.ESNext,
|
|
97
|
+
composite: false
|
|
97
98
|
};
|
|
98
99
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
99
100
|
compilerOptionsWithSourceMap = {
|
|
@@ -107,6 +108,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
107
108
|
if (transformTS) {
|
|
108
109
|
const ts = await tsPromise;
|
|
109
110
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
111
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
112
|
+
system.fileExists = (filename) => {
|
|
113
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
114
|
+
return systemFileExists(filename);
|
|
115
|
+
if (fsMap.has(filename))
|
|
116
|
+
return true;
|
|
117
|
+
return systemFileExists(filename.slice(0, -4));
|
|
118
|
+
};
|
|
119
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
120
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
121
|
+
return systemReadFile(filename);
|
|
122
|
+
if (fsMap.has(filename))
|
|
123
|
+
return fsMap.get(filename);
|
|
124
|
+
const civetFilename = filename.slice(0, -4);
|
|
125
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
126
|
+
encoding
|
|
127
|
+
});
|
|
128
|
+
const compiledTS = civet.compile(rawCivetSource, {
|
|
129
|
+
filename,
|
|
130
|
+
js: false
|
|
131
|
+
});
|
|
132
|
+
fsMap.set(filename, compiledTS);
|
|
133
|
+
return compiledTS;
|
|
134
|
+
};
|
|
110
135
|
const host = tsvfs.createVirtualCompilerHost(
|
|
111
136
|
system,
|
|
112
137
|
compilerOptions,
|
|
@@ -189,6 +214,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
189
214
|
compilerOptions.outDir ?? process.cwd(),
|
|
190
215
|
filePath
|
|
191
216
|
);
|
|
217
|
+
if (meta.framework === "esbuild") {
|
|
218
|
+
fs.mkdirSync(
|
|
219
|
+
path.dirname(
|
|
220
|
+
path.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
221
|
+
),
|
|
222
|
+
{ recursive: true }
|
|
223
|
+
);
|
|
224
|
+
}
|
|
192
225
|
this.emitFile({
|
|
193
226
|
source: content,
|
|
194
227
|
fileName: pathFromDistDir,
|
|
@@ -196,13 +229,18 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
196
229
|
});
|
|
197
230
|
},
|
|
198
231
|
void 0,
|
|
232
|
+
true,
|
|
233
|
+
// emitDtsOnly
|
|
234
|
+
void 0,
|
|
235
|
+
// @ts-ignore @internal interface
|
|
199
236
|
true
|
|
237
|
+
// forceDtsEmit
|
|
200
238
|
);
|
|
201
239
|
}
|
|
202
240
|
}
|
|
203
241
|
}
|
|
204
242
|
},
|
|
205
|
-
resolveId(id, importer) {
|
|
243
|
+
resolveId(id, importer, options2) {
|
|
206
244
|
if (/\0/.test(id))
|
|
207
245
|
return null;
|
|
208
246
|
id = cleanCivetId(id);
|
|
@@ -217,15 +255,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
217
255
|
return null;
|
|
218
256
|
resolvedId = implicitId;
|
|
219
257
|
}
|
|
258
|
+
if (options2.scan && meta.framework === "vite") {
|
|
259
|
+
resolvedId = `\0${resolvedId}`;
|
|
260
|
+
}
|
|
220
261
|
return resolvedId + outExt;
|
|
221
262
|
},
|
|
222
263
|
loadInclude(id) {
|
|
223
|
-
return isCivetTranspiled(id);
|
|
264
|
+
return isCivetTranspiled.test(id);
|
|
224
265
|
},
|
|
225
266
|
async load(id) {
|
|
226
|
-
|
|
267
|
+
const match = isCivetTranspiled.exec(id);
|
|
268
|
+
if (!match)
|
|
227
269
|
return null;
|
|
228
|
-
const
|
|
270
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
271
|
+
const filename = path.resolve(rootDir, basename);
|
|
229
272
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
230
273
|
this.addWatchFile(filename);
|
|
231
274
|
let compiled;
|
|
@@ -356,7 +399,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
356
399
|
}
|
|
357
400
|
};
|
|
358
401
|
};
|
|
359
|
-
var
|
|
402
|
+
var unplugin = createUnplugin(rawPlugin);
|
|
403
|
+
var src_default = unplugin;
|
|
360
404
|
|
|
361
405
|
export {
|
|
362
406
|
slash,
|
package/dist/unplugin.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
2
|
import { TransformResult, createUnplugin } from 'unplugin';
|
|
3
3
|
|
|
4
4
|
type PluginOptions = {
|
|
@@ -15,6 +15,6 @@ type PluginOptions = {
|
|
|
15
15
|
};
|
|
16
16
|
declare function slash(p: string): string;
|
|
17
17
|
declare const rawPlugin: Parameters<typeof createUnplugin<PluginOptions>>[0];
|
|
18
|
-
declare
|
|
18
|
+
declare var unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
|
|
19
19
|
|
|
20
|
-
export { PluginOptions,
|
|
20
|
+
export { PluginOptions, unplugin as default, rawPlugin, slash };
|
package/dist/unplugin.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _unplugin from 'unplugin';
|
|
2
2
|
import { TransformResult, createUnplugin } from 'unplugin';
|
|
3
3
|
|
|
4
4
|
type PluginOptions = {
|
|
@@ -15,6 +15,6 @@ type PluginOptions = {
|
|
|
15
15
|
};
|
|
16
16
|
declare function slash(p: string): string;
|
|
17
17
|
declare const rawPlugin: Parameters<typeof createUnplugin<PluginOptions>>[0];
|
|
18
|
-
declare
|
|
18
|
+
declare var unplugin: _unplugin.UnpluginInstance<PluginOptions, boolean>;
|
|
19
19
|
|
|
20
|
-
export { PluginOptions,
|
|
20
|
+
export { PluginOptions, unplugin as default, rawPlugin, slash };
|
package/dist/unplugin.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -222,6 +247,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
222
247
|
compilerOptions.outDir ?? process.cwd(),
|
|
223
248
|
filePath
|
|
224
249
|
);
|
|
250
|
+
if (meta.framework === "esbuild") {
|
|
251
|
+
fs.mkdirSync(
|
|
252
|
+
import_path.default.dirname(
|
|
253
|
+
import_path.default.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
254
|
+
),
|
|
255
|
+
{ recursive: true }
|
|
256
|
+
);
|
|
257
|
+
}
|
|
225
258
|
this.emitFile({
|
|
226
259
|
source: content,
|
|
227
260
|
fileName: pathFromDistDir,
|
|
@@ -229,13 +262,18 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
229
262
|
});
|
|
230
263
|
},
|
|
231
264
|
void 0,
|
|
265
|
+
true,
|
|
266
|
+
// emitDtsOnly
|
|
267
|
+
void 0,
|
|
268
|
+
// @ts-ignore @internal interface
|
|
232
269
|
true
|
|
270
|
+
// forceDtsEmit
|
|
233
271
|
);
|
|
234
272
|
}
|
|
235
273
|
}
|
|
236
274
|
}
|
|
237
275
|
},
|
|
238
|
-
resolveId(id, importer) {
|
|
276
|
+
resolveId(id, importer, options2) {
|
|
239
277
|
if (/\0/.test(id))
|
|
240
278
|
return null;
|
|
241
279
|
id = cleanCivetId(id);
|
|
@@ -250,15 +288,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
250
288
|
return null;
|
|
251
289
|
resolvedId = implicitId;
|
|
252
290
|
}
|
|
291
|
+
if (options2.scan && meta.framework === "vite") {
|
|
292
|
+
resolvedId = `\0${resolvedId}`;
|
|
293
|
+
}
|
|
253
294
|
return resolvedId + outExt;
|
|
254
295
|
},
|
|
255
296
|
loadInclude(id) {
|
|
256
|
-
return isCivetTranspiled(id);
|
|
297
|
+
return isCivetTranspiled.test(id);
|
|
257
298
|
},
|
|
258
299
|
async load(id) {
|
|
259
|
-
|
|
300
|
+
const match = isCivetTranspiled.exec(id);
|
|
301
|
+
if (!match)
|
|
260
302
|
return null;
|
|
261
|
-
const
|
|
303
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
304
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
262
305
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
263
306
|
this.addWatchFile(filename);
|
|
264
307
|
let compiled;
|
|
@@ -389,7 +432,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
389
432
|
}
|
|
390
433
|
};
|
|
391
434
|
};
|
|
392
|
-
var
|
|
435
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
436
|
+
var src_default = unplugin;
|
|
393
437
|
// Annotate the CommonJS export names for ESM import in node:
|
|
394
438
|
0 && (module.exports = {
|
|
395
439
|
rawPlugin,
|
package/dist/vite.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -222,6 +247,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
222
247
|
compilerOptions.outDir ?? process.cwd(),
|
|
223
248
|
filePath
|
|
224
249
|
);
|
|
250
|
+
if (meta.framework === "esbuild") {
|
|
251
|
+
fs.mkdirSync(
|
|
252
|
+
import_path.default.dirname(
|
|
253
|
+
import_path.default.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
254
|
+
),
|
|
255
|
+
{ recursive: true }
|
|
256
|
+
);
|
|
257
|
+
}
|
|
225
258
|
this.emitFile({
|
|
226
259
|
source: content,
|
|
227
260
|
fileName: pathFromDistDir,
|
|
@@ -229,13 +262,18 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
229
262
|
});
|
|
230
263
|
},
|
|
231
264
|
void 0,
|
|
265
|
+
true,
|
|
266
|
+
// emitDtsOnly
|
|
267
|
+
void 0,
|
|
268
|
+
// @ts-ignore @internal interface
|
|
232
269
|
true
|
|
270
|
+
// forceDtsEmit
|
|
233
271
|
);
|
|
234
272
|
}
|
|
235
273
|
}
|
|
236
274
|
}
|
|
237
275
|
},
|
|
238
|
-
resolveId(id, importer) {
|
|
276
|
+
resolveId(id, importer, options2) {
|
|
239
277
|
if (/\0/.test(id))
|
|
240
278
|
return null;
|
|
241
279
|
id = cleanCivetId(id);
|
|
@@ -250,15 +288,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
250
288
|
return null;
|
|
251
289
|
resolvedId = implicitId;
|
|
252
290
|
}
|
|
291
|
+
if (options2.scan && meta.framework === "vite") {
|
|
292
|
+
resolvedId = `\0${resolvedId}`;
|
|
293
|
+
}
|
|
253
294
|
return resolvedId + outExt;
|
|
254
295
|
},
|
|
255
296
|
loadInclude(id) {
|
|
256
|
-
return isCivetTranspiled(id);
|
|
297
|
+
return isCivetTranspiled.test(id);
|
|
257
298
|
},
|
|
258
299
|
async load(id) {
|
|
259
|
-
|
|
300
|
+
const match = isCivetTranspiled.exec(id);
|
|
301
|
+
if (!match)
|
|
260
302
|
return null;
|
|
261
|
-
const
|
|
303
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
304
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
262
305
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
263
306
|
this.addWatchFile(filename);
|
|
264
307
|
let compiled;
|
|
@@ -389,7 +432,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
389
432
|
}
|
|
390
433
|
};
|
|
391
434
|
};
|
|
392
|
-
var
|
|
435
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
436
|
+
var src_default = unplugin;
|
|
393
437
|
|
|
394
438
|
// src/vite.ts
|
|
395
439
|
var vite_default = src_default.vite;
|
package/dist/webpack.js
CHANGED
|
@@ -42,7 +42,7 @@ var fs = __toESM(require("fs"));
|
|
|
42
42
|
var import_path = __toESM(require("path"));
|
|
43
43
|
var tsvfs = __toESM(require("@typescript/vfs"));
|
|
44
44
|
var import_os = __toESM(require("os"));
|
|
45
|
-
var isCivetTranspiled = (
|
|
45
|
+
var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
|
|
46
46
|
var postfixRE = /[?#].*$/s;
|
|
47
47
|
var isWindows = import_os.default.platform() === "win32";
|
|
48
48
|
var windowsSlashRE = /\\/g;
|
|
@@ -126,7 +126,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
126
126
|
);
|
|
127
127
|
compilerOptions = {
|
|
128
128
|
...configContents.options,
|
|
129
|
-
target: ts.ScriptTarget.ESNext
|
|
129
|
+
target: ts.ScriptTarget.ESNext,
|
|
130
|
+
composite: false
|
|
130
131
|
};
|
|
131
132
|
compilerOptions.jsx ?? (compilerOptions.jsx = "preserve");
|
|
132
133
|
compilerOptionsWithSourceMap = {
|
|
@@ -140,6 +141,30 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
140
141
|
if (transformTS) {
|
|
141
142
|
const ts = await tsPromise;
|
|
142
143
|
const system = tsvfs.createFSBackedSystem(fsMap, process.cwd(), ts);
|
|
144
|
+
const { fileExists: systemFileExists, readFile: systemReadFile } = system;
|
|
145
|
+
system.fileExists = (filename) => {
|
|
146
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
147
|
+
return systemFileExists(filename);
|
|
148
|
+
if (fsMap.has(filename))
|
|
149
|
+
return true;
|
|
150
|
+
return systemFileExists(filename.slice(0, -4));
|
|
151
|
+
};
|
|
152
|
+
system.readFile = (filename, encoding = "utf-8") => {
|
|
153
|
+
if (!filename.endsWith(".civet.tsx"))
|
|
154
|
+
return systemReadFile(filename);
|
|
155
|
+
if (fsMap.has(filename))
|
|
156
|
+
return fsMap.get(filename);
|
|
157
|
+
const civetFilename = filename.slice(0, -4);
|
|
158
|
+
const rawCivetSource = fs.readFileSync(civetFilename, {
|
|
159
|
+
encoding
|
|
160
|
+
});
|
|
161
|
+
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
162
|
+
filename,
|
|
163
|
+
js: false
|
|
164
|
+
});
|
|
165
|
+
fsMap.set(filename, compiledTS);
|
|
166
|
+
return compiledTS;
|
|
167
|
+
};
|
|
143
168
|
const host = tsvfs.createVirtualCompilerHost(
|
|
144
169
|
system,
|
|
145
170
|
compilerOptions,
|
|
@@ -222,6 +247,14 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
222
247
|
compilerOptions.outDir ?? process.cwd(),
|
|
223
248
|
filePath
|
|
224
249
|
);
|
|
250
|
+
if (meta.framework === "esbuild") {
|
|
251
|
+
fs.mkdirSync(
|
|
252
|
+
import_path.default.dirname(
|
|
253
|
+
import_path.default.resolve(esbuildOptions.outdir, pathFromDistDir)
|
|
254
|
+
),
|
|
255
|
+
{ recursive: true }
|
|
256
|
+
);
|
|
257
|
+
}
|
|
225
258
|
this.emitFile({
|
|
226
259
|
source: content,
|
|
227
260
|
fileName: pathFromDistDir,
|
|
@@ -229,13 +262,18 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
229
262
|
});
|
|
230
263
|
},
|
|
231
264
|
void 0,
|
|
265
|
+
true,
|
|
266
|
+
// emitDtsOnly
|
|
267
|
+
void 0,
|
|
268
|
+
// @ts-ignore @internal interface
|
|
232
269
|
true
|
|
270
|
+
// forceDtsEmit
|
|
233
271
|
);
|
|
234
272
|
}
|
|
235
273
|
}
|
|
236
274
|
}
|
|
237
275
|
},
|
|
238
|
-
resolveId(id, importer) {
|
|
276
|
+
resolveId(id, importer, options2) {
|
|
239
277
|
if (/\0/.test(id))
|
|
240
278
|
return null;
|
|
241
279
|
id = cleanCivetId(id);
|
|
@@ -250,15 +288,20 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
250
288
|
return null;
|
|
251
289
|
resolvedId = implicitId;
|
|
252
290
|
}
|
|
291
|
+
if (options2.scan && meta.framework === "vite") {
|
|
292
|
+
resolvedId = `\0${resolvedId}`;
|
|
293
|
+
}
|
|
253
294
|
return resolvedId + outExt;
|
|
254
295
|
},
|
|
255
296
|
loadInclude(id) {
|
|
256
|
-
return isCivetTranspiled(id);
|
|
297
|
+
return isCivetTranspiled.test(id);
|
|
257
298
|
},
|
|
258
299
|
async load(id) {
|
|
259
|
-
|
|
300
|
+
const match = isCivetTranspiled.exec(id);
|
|
301
|
+
if (!match)
|
|
260
302
|
return null;
|
|
261
|
-
const
|
|
303
|
+
const basename = id.slice(0, match.index + match[1].length);
|
|
304
|
+
const filename = import_path.default.resolve(rootDir, basename);
|
|
262
305
|
const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
|
|
263
306
|
this.addWatchFile(filename);
|
|
264
307
|
let compiled;
|
|
@@ -389,7 +432,8 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
389
432
|
}
|
|
390
433
|
};
|
|
391
434
|
};
|
|
392
|
-
var
|
|
435
|
+
var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
|
|
436
|
+
var src_default = unplugin;
|
|
393
437
|
|
|
394
438
|
// src/webpack.ts
|
|
395
439
|
var webpack_default = src_default.webpack;
|