@danielx/civet 0.7.4 → 0.7.5
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/astro.js +6 -6
- package/dist/babel-plugin.mjs +4 -2
- package/dist/browser.js +214 -132
- package/dist/bun-civet.mjs +4 -4
- package/dist/civet +4 -4
- package/dist/config.js +4 -1
- package/dist/esbuild-plugin.js +1 -1
- package/dist/esbuild.js +6 -6
- package/dist/esm.mjs +1 -1
- package/dist/main.js +215 -132
- package/dist/main.mjs +214 -132
- package/dist/rollup.js +6 -6
- package/dist/types.d.ts +15 -5
- package/dist/unplugin-shared.mjs +6 -6
- package/dist/unplugin.js +6 -6
- package/dist/vite.js +6 -6
- package/dist/webpack.js +6 -6
- package/package.json +2 -2
package/dist/bun-civet.mjs
CHANGED
|
@@ -3,10 +3,10 @@ await plugin({
|
|
|
3
3
|
name: "Civet loader",
|
|
4
4
|
setup: async function(builder) {
|
|
5
5
|
const { compile } = await import("./main.mjs");
|
|
6
|
-
const {
|
|
7
|
-
return builder.onLoad({ filter: /\.civet$/ }, function({ path }) {
|
|
8
|
-
const source =
|
|
9
|
-
const contents = compile(source);
|
|
6
|
+
const { readFile } = await import("node:fs/promises");
|
|
7
|
+
return builder.onLoad({ filter: /\.civet$/ }, async function({ path }) {
|
|
8
|
+
const source = await readFile(path, "utf8");
|
|
9
|
+
const contents = await compile(source, { comptime: true });
|
|
10
10
|
return {
|
|
11
11
|
contents,
|
|
12
12
|
loader: "tsx"
|
package/dist/civet
CHANGED
|
@@ -346,20 +346,20 @@ async function repl(options) {
|
|
|
346
346
|
let output;
|
|
347
347
|
if (options.compile || options.ast) {
|
|
348
348
|
try {
|
|
349
|
-
output = (0, import_main.compile)(input, { ...options, filename });
|
|
349
|
+
output = await (0, import_main.compile)(input, { ...options, filename });
|
|
350
350
|
} catch (error) {
|
|
351
351
|
console.error(error);
|
|
352
352
|
return callback(null, void 0);
|
|
353
353
|
}
|
|
354
354
|
return callback(null, output);
|
|
355
355
|
}
|
|
356
|
-
let ast = (0, import_main.compile)(input, { ...options, filename, ast: true });
|
|
356
|
+
let ast = await (0, import_main.compile)(input, { ...options, filename, ast: true });
|
|
357
357
|
const topLevelAwait = import_main.lib.hasAwait(ast) || import_main.lib.hasImportDeclaration(ast);
|
|
358
358
|
if (topLevelAwait) {
|
|
359
359
|
const [prologue, rest] = (0, import_main.parse)(input, { startRule: "ProloguePrefix" });
|
|
360
360
|
const prefix = input.slice(0, -rest.length);
|
|
361
361
|
const coffee = prologue.some((p) => p.type === "CivetPrologue" && (p.config.coffeeCompat || p.config.coffeeDo));
|
|
362
|
-
ast = (0, import_main.compile)(
|
|
362
|
+
ast = await (0, import_main.compile)(
|
|
363
363
|
prefix + (coffee ? "(do ->\n" : "async do\n") + rest.replace(/^/gm, " ") + (coffee ? ")" : ""),
|
|
364
364
|
{ ...options, filename, ast: true }
|
|
365
365
|
);
|
|
@@ -493,7 +493,7 @@ async function cli() {
|
|
|
493
493
|
}
|
|
494
494
|
}, `${filename}.tsx`)).code;
|
|
495
495
|
} else {
|
|
496
|
-
output = (0, import_main.compile)(content, { ...options, filename });
|
|
496
|
+
output = await (0, import_main.compile)(content, { ...options, filename });
|
|
497
497
|
}
|
|
498
498
|
} catch (error2) {
|
|
499
499
|
console.error(error2);
|
package/dist/config.js
CHANGED
|
@@ -96,7 +96,10 @@ async function loadConfig(path2) {
|
|
|
96
96
|
} else {
|
|
97
97
|
let js;
|
|
98
98
|
try {
|
|
99
|
-
js = (0, import_main.compile)(config, {
|
|
99
|
+
js = (0, import_main.compile)(config, {
|
|
100
|
+
js: true,
|
|
101
|
+
sync: true
|
|
102
|
+
});
|
|
100
103
|
} catch (e) {
|
|
101
104
|
throw new Error(`Error compiling Civet config file ${path2}: ${e}`);
|
|
102
105
|
}
|
package/dist/esbuild-plugin.js
CHANGED
|
@@ -90,7 +90,7 @@ var civet = function(options = {}) {
|
|
|
90
90
|
try {
|
|
91
91
|
const source = await (0, import_promises.readFile)(args.path, "utf8");
|
|
92
92
|
const filename = import_path.default.relative(process.cwd(), args.path);
|
|
93
|
-
const compiled = (0, import_main.compile)(source, {
|
|
93
|
+
const compiled = await (0, import_main.compile)(source, {
|
|
94
94
|
filename,
|
|
95
95
|
inlineMap,
|
|
96
96
|
js
|
package/dist/esbuild.js
CHANGED
|
@@ -166,9 +166,9 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
166
166
|
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
167
167
|
filename,
|
|
168
168
|
js: false,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
comptime: Boolean(options.comptime),
|
|
170
|
+
sync: true
|
|
171
|
+
// TS readFile API seems to need to be synchronous
|
|
172
172
|
});
|
|
173
173
|
fsMap.set(filename, compiledTS);
|
|
174
174
|
return compiledTS;
|
|
@@ -321,12 +321,12 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
321
321
|
}
|
|
322
322
|
};
|
|
323
323
|
if (options.ts === "civet" && !transformTS) {
|
|
324
|
-
compiled = import_civet.default.compile(rawCivetSource, {
|
|
324
|
+
compiled = await import_civet.default.compile(rawCivetSource, {
|
|
325
325
|
...civetOptions,
|
|
326
326
|
js: true
|
|
327
327
|
});
|
|
328
328
|
} else {
|
|
329
|
-
const compiledTS = import_civet.default.compile(rawCivetSource, {
|
|
329
|
+
const compiledTS = await import_civet.default.compile(rawCivetSource, {
|
|
330
330
|
...civetOptions,
|
|
331
331
|
js: false
|
|
332
332
|
});
|
|
@@ -372,7 +372,7 @@ var rawPlugin = (options = {}, meta) => {
|
|
|
372
372
|
}
|
|
373
373
|
case "civet":
|
|
374
374
|
default: {
|
|
375
|
-
compiled = import_civet.default.compile(rawCivetSource, {
|
|
375
|
+
compiled = await import_civet.default.compile(rawCivetSource, {
|
|
376
376
|
...civetOptions,
|
|
377
377
|
js: true
|
|
378
378
|
});
|
package/dist/esm.mjs
CHANGED
|
@@ -50,7 +50,7 @@ async function load(url, context, next) {
|
|
|
50
50
|
if (context.format === "civet") {
|
|
51
51
|
const path = fileURLToPath(url);
|
|
52
52
|
const source = readFileSync(path, "utf8");
|
|
53
|
-
const { code: tsSource, sourceMap } = compile(source, {
|
|
53
|
+
const { code: tsSource, sourceMap } = await compile(source, {
|
|
54
54
|
filename: path,
|
|
55
55
|
sourceMap: true,
|
|
56
56
|
js: true
|