@danielx/civet 0.7.16 → 0.7.18

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.
Files changed (50) hide show
  1. package/README.md +2 -1
  2. package/dist/browser.js +28 -12
  3. package/dist/civet +139 -100
  4. package/dist/config.d.mts +1 -0
  5. package/dist/config.d.ts +1 -0
  6. package/dist/config.mjs +122 -0
  7. package/dist/esm.mjs +1 -1
  8. package/dist/main.js +28 -12
  9. package/dist/main.mjs +28 -12
  10. package/dist/unplugin/astro.d.ts +11 -0
  11. package/dist/unplugin/astro.js +49 -0
  12. package/dist/unplugin/astro.mjs +19 -0
  13. package/dist/unplugin/esbuild.d.ts +2 -0
  14. package/dist/unplugin/esbuild.js +36 -0
  15. package/dist/unplugin/esbuild.mjs +6 -0
  16. package/dist/unplugin/rollup.d.ts +2 -0
  17. package/dist/unplugin/rollup.js +36 -0
  18. package/dist/unplugin/rollup.mjs +6 -0
  19. package/dist/{unplugin.d.ts → unplugin/unplugin.d.ts} +7 -10
  20. package/dist/{unplugin.js → unplugin/unplugin.js} +81 -66
  21. package/dist/{unplugin-shared.mjs → unplugin/unplugin.mjs} +80 -65
  22. package/dist/unplugin/vite.d.ts +2 -0
  23. package/dist/unplugin/vite.js +36 -0
  24. package/dist/unplugin/vite.mjs +6 -0
  25. package/dist/unplugin/webpack.d.ts +2 -0
  26. package/dist/unplugin/webpack.js +36 -0
  27. package/dist/unplugin/webpack.mjs +6 -0
  28. package/package.json +27 -17
  29. package/dist/astro.d.mts +0 -16
  30. package/dist/astro.d.ts +0 -16
  31. package/dist/astro.js +0 -537
  32. package/dist/astro.mjs +0 -22
  33. package/dist/esbuild.d.mts +0 -8
  34. package/dist/esbuild.d.ts +0 -8
  35. package/dist/esbuild.js +0 -524
  36. package/dist/esbuild.mjs +0 -9
  37. package/dist/rollup.d.mts +0 -8
  38. package/dist/rollup.d.ts +0 -8
  39. package/dist/rollup.js +0 -524
  40. package/dist/rollup.mjs +0 -9
  41. package/dist/unplugin.d.mts +0 -26
  42. package/dist/unplugin.mjs +0 -10
  43. package/dist/vite.d.mts +0 -8
  44. package/dist/vite.d.ts +0 -8
  45. package/dist/vite.js +0 -524
  46. package/dist/vite.mjs +0 -9
  47. package/dist/webpack.d.mts +0 -7
  48. package/dist/webpack.d.ts +0 -7
  49. package/dist/webpack.js +0 -524
  50. package/dist/webpack.mjs +0 -9
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -27,14 +26,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
26
  ));
28
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
28
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- default: () => src_default,
29
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
30
+ var unplugin_civet_exports = {};
31
+ __export(unplugin_civet_exports, {
32
+ default: () => unplugin_civet_default,
34
33
  rawPlugin: () => rawPlugin,
35
34
  slash: () => slash
36
35
  });
37
- module.exports = __toCommonJS(src_exports);
36
+ module.exports = __toCommonJS(unplugin_civet_exports);
38
37
  var import_unplugin = require("unplugin");
39
38
  var import_civet = __toESM(require("@danielx/civet"));
40
39
  var import_config = require("@danielx/civet/config");
@@ -44,10 +43,15 @@ var import_path = __toESM(require("path"));
44
43
  var tsvfs = __toESM(require("@typescript/vfs"));
45
44
  var import_os = __toESM(require("os"));
46
45
 
47
- // src/constants.ts
46
+ // source/unplugin/constants.mjs
48
47
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
49
48
 
50
- // src/index.ts
49
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
50
+ var DiagnosticCategory = {};
51
+ DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
52
+ DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
53
+ DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
54
+ DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
51
55
  var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
52
56
  var postfixRE = /[?#].*$/s;
53
57
  var isWindows = import_os.default.platform() === "win32";
@@ -102,7 +106,7 @@ var rawPlugin = (options = {}, meta) => {
102
106
  let esbuildOptions;
103
107
  let configErrors;
104
108
  let configFileNames;
105
- const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
109
+ const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then(($) => $.default) : null;
106
110
  const getFormatHost = (sys) => {
107
111
  return {
108
112
  getCurrentDirectory: () => sys.getCurrentDirectory(),
@@ -116,16 +120,17 @@ var rawPlugin = (options = {}, meta) => {
116
120
  enforce: "pre",
117
121
  async buildStart() {
118
122
  if (transformTS || options.ts === "tsc") {
119
- let mogrify2 = function(key) {
123
+ let mogrify = function(key) {
120
124
  if (key in config && Array.isArray(config[key])) {
121
- config[key] = config[key].map((item) => {
125
+ return config[key] = config[key].map((item) => {
122
126
  if (typeof item !== "string")
123
127
  return item;
124
128
  return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
125
129
  });
126
130
  }
131
+ ;
132
+ return;
127
133
  };
128
- var mogrify = mogrify2;
129
134
  const ts = await tsPromise;
130
135
  const civetConfigPath = "config" in options ? options.config : await (0, import_config.findInDir)(process.cwd());
131
136
  if (civetConfigPath) {
@@ -147,12 +152,12 @@ var rawPlugin = (options = {}, meta) => {
147
152
  console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
148
153
  throw error;
149
154
  }
150
- mogrify2("files");
155
+ mogrify("files");
151
156
  const system = { ...ts.sys };
152
157
  const { readDirectory: systemReadDirectory } = system;
153
158
  system.readDirectory = (path2, extensions, excludes, includes, depth) => {
154
159
  extensions = [...extensions ?? [], ".civet"];
155
- return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
160
+ return systemReadDirectory(path2, extensions, excludes, includes, depth).map(($1) => $1.endsWith(".civet") ? $1 + ".tsx" : $1);
156
161
  };
157
162
  const configContents = ts.parseJsonConfigFileContent(
158
163
  config,
@@ -166,7 +171,7 @@ var rawPlugin = (options = {}, meta) => {
166
171
  target: ts.ScriptTarget.ESNext,
167
172
  composite: false
168
173
  };
169
- compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
174
+ compilerOptions.jsx ??= ts.JsxEmit.Preserve;
170
175
  compilerOptionsWithSourceMap = {
171
176
  ...compilerOptions,
172
177
  sourceMap: true
@@ -190,10 +195,12 @@ var rawPlugin = (options = {}, meta) => {
190
195
  return true;
191
196
  return systemFileExists(filename.slice(0, -4));
192
197
  };
193
- system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
198
+ system.readDirectory = (path2) => {
199
+ return systemReadDirectory(path2).map(($2) => $2.endsWith(".civet") ? $2 + ".tsx" : $2);
200
+ };
194
201
  system.readFile = (filename, encoding = "utf-8") => {
195
202
  if (import_path.default.basename(filename) === "package.json") {
196
- let recurse2 = function(node) {
203
+ let recurse = function(node) {
197
204
  if (node && typeof node === "object") {
198
205
  for (const key in node) {
199
206
  const value = node[key];
@@ -203,18 +210,17 @@ var rawPlugin = (options = {}, meta) => {
203
210
  modified = true;
204
211
  }
205
212
  } else if (value) {
206
- recurse2(value);
213
+ recurse(value);
207
214
  }
208
215
  }
209
216
  }
210
217
  };
211
- var recurse = recurse2;
212
218
  const json = systemReadFile(filename, encoding);
213
219
  if (!json)
214
220
  return json;
215
221
  const parsed = JSON.parse(json);
216
222
  let modified = false;
217
- recurse2(parsed.imports);
223
+ recurse(parsed.imports);
218
224
  return modified ? JSON.stringify(parsed) : json;
219
225
  }
220
226
  if (!filename.endsWith(".civet.tsx"))
@@ -246,28 +252,30 @@ var rawPlugin = (options = {}, meta) => {
246
252
  options: compilerOptions,
247
253
  host: host.compilerHost
248
254
  });
249
- const diagnostics = ts.getPreEmitDiagnostics(program).map((diagnostic) => {
250
- const file = diagnostic.file;
251
- if (!file)
252
- return diagnostic;
253
- const sourceMap = sourceMaps.get(file.fileName);
254
- if (!sourceMap)
255
- return diagnostic;
256
- const sourcemapLines = sourceMap.data.lines;
257
- const range = (0, import_ts_diagnostic.remapRange)(
258
- {
259
- start: diagnostic.start || 0,
260
- end: (diagnostic.start || 0) + (diagnostic.length || 1)
261
- },
262
- sourcemapLines
263
- );
264
- return {
265
- ...diagnostic,
266
- messageText: (0, import_ts_diagnostic.flattenDiagnosticMessageText)(diagnostic.messageText),
267
- length: diagnostic.length,
268
- start: range.start
269
- };
270
- });
255
+ const diagnostics = ts.getPreEmitDiagnostics(program).map(
256
+ (diagnostic) => {
257
+ const file = diagnostic.file;
258
+ if (!file)
259
+ return diagnostic;
260
+ const sourceMap = sourceMaps.get(file.fileName);
261
+ if (!sourceMap)
262
+ return diagnostic;
263
+ const sourcemapLines = sourceMap.data.lines;
264
+ const range = (0, import_ts_diagnostic.remapRange)(
265
+ {
266
+ start: diagnostic.start || 0,
267
+ end: (diagnostic.start || 0) + (diagnostic.length || 1)
268
+ },
269
+ sourcemapLines
270
+ );
271
+ return {
272
+ ...diagnostic,
273
+ messageText: (0, import_ts_diagnostic.flattenDiagnosticMessageText)(diagnostic.messageText),
274
+ length: diagnostic.length,
275
+ start: range.start
276
+ };
277
+ }
278
+ );
271
279
  if (configErrors?.length) {
272
280
  diagnostics.unshift(...configErrors);
273
281
  }
@@ -282,18 +290,18 @@ var rawPlugin = (options = {}, meta) => {
282
290
  let failures = [];
283
291
  if (typeof options.typecheck === "string") {
284
292
  if (options.typecheck.includes("error"))
285
- failures.push(1 /* Error */);
293
+ failures.push(DiagnosticCategory.Error);
286
294
  if (options.typecheck.includes("warning"))
287
- failures.push(0 /* Warning */);
295
+ failures.push(DiagnosticCategory.Warning);
288
296
  if (options.typecheck.includes("suggestion"))
289
- failures.push(2 /* Suggestion */);
297
+ failures.push(DiagnosticCategory.Suggestion);
290
298
  if (options.typecheck.includes("message"))
291
- failures.push(3 /* Message */);
299
+ failures.push(DiagnosticCategory.Message);
292
300
  if (options.typecheck.includes("all")) {
293
301
  failures = { includes: () => true };
294
302
  }
295
303
  } else {
296
- failures.push(1 /* Error */);
304
+ failures.push(DiagnosticCategory.Error);
297
305
  }
298
306
  const count = diagnostics.filter((d) => failures.includes(d.category)).length;
299
307
  if (count) {
@@ -465,42 +473,49 @@ var rawPlugin = (options = {}, meta) => {
465
473
  code: compiled.code,
466
474
  map: jsonSourceMap
467
475
  };
468
- if (options.transformOutput)
476
+ if (options.transformOutput) {
469
477
  transformed = await options.transformOutput(transformed.code, id);
478
+ }
470
479
  cache?.set(filename, { mtime, result: transformed });
471
480
  return transformed;
472
481
  },
473
482
  esbuild: {
474
483
  config(options2) {
475
- esbuildOptions = options2;
484
+ return esbuildOptions = options2;
476
485
  }
477
486
  },
478
487
  vite: {
479
488
  config(config) {
480
- var _a;
481
489
  rootDir = import_path.default.resolve(process.cwd(), config.root ?? "");
482
490
  if (implicitExtension) {
483
- config.resolve ?? (config.resolve = {});
484
- (_a = config.resolve).extensions ?? (_a.extensions = DEFAULT_EXTENSIONS);
491
+ config.resolve ??= {};
492
+ config.resolve.extensions ??= DEFAULT_EXTENSIONS;
485
493
  config.resolve.extensions.push(".civet");
486
494
  }
495
+ ;
496
+ return;
487
497
  },
488
498
  async transformIndexHtml(html) {
489
499
  return html.replace(
490
500
  /<!--[^]*?-->|<[^<>]*>/g,
491
- (tag) => tag.replace(
492
- /<\s*script\b[^<>]*>/gi,
493
- (script) => (
494
- // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
495
- script.replace(
496
- /([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
497
- (attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
498
- /(\.civet)(['"]?)$/,
499
- (_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
500
- ) : attr
501
- )
502
- )
503
- )
501
+ (tag) => {
502
+ return tag.replace(
503
+ /<\s*script\b[^<>]*>/gi,
504
+ (script) => {
505
+ return script.replace(
506
+ /([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
507
+ (attr, name, value) => {
508
+ return name.toLowerCase() === "src" && value ? attr.replace(
509
+ /(\.civet)(['"]?)$/,
510
+ (_, extension, endQuote) => {
511
+ return `${extension}${outExt}?transform${endQuote}`;
512
+ }
513
+ ) : attr;
514
+ }
515
+ );
516
+ }
517
+ );
518
+ }
504
519
  );
505
520
  },
506
521
  handleHotUpdate({ file, server, modules }) {
@@ -518,7 +533,7 @@ var rawPlugin = (options = {}, meta) => {
518
533
  };
519
534
  };
520
535
  var unplugin = (0, import_unplugin.createUnplugin)(rawPlugin);
521
- var src_default = unplugin;
536
+ var unplugin_civet_default = unplugin;
522
537
  // Annotate the CommonJS export names for ESM import in node:
523
538
  0 && (module.exports = {
524
539
  rawPlugin,
@@ -1,6 +1,6 @@
1
- // src/index.ts
1
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
2
2
  import { createUnplugin } from "unplugin";
3
- import civet from "@danielx/civet";
3
+ import civet, { SourceMap } from "@danielx/civet";
4
4
  import { findInDir, loadConfig } from "@danielx/civet/config";
5
5
  import {
6
6
  remapRange,
@@ -11,10 +11,15 @@ import path from "path";
11
11
  import * as tsvfs from "@typescript/vfs";
12
12
  import os from "os";
13
13
 
14
- // src/constants.ts
14
+ // source/unplugin/constants.mjs
15
15
  var DEFAULT_EXTENSIONS = [".mjs", ".js", ".mts", ".ts", ".jsx", ".tsx", ".json"];
16
16
 
17
- // src/index.ts
17
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\unplugin.civet.jsx
18
+ var DiagnosticCategory = {};
19
+ DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
20
+ DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
21
+ DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
22
+ DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
18
23
  var isCivetTranspiled = /(\.civet)(\.[jt]sx)([?#].*)?$/;
19
24
  var postfixRE = /[?#].*$/s;
20
25
  var isWindows = os.platform() === "win32";
@@ -69,7 +74,7 @@ var rawPlugin = (options = {}, meta) => {
69
74
  let esbuildOptions;
70
75
  let configErrors;
71
76
  let configFileNames;
72
- const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then((m) => m.default) : null;
77
+ const tsPromise = transformTS || options.ts === "tsc" ? import("typescript").then(($) => $.default) : null;
73
78
  const getFormatHost = (sys) => {
74
79
  return {
75
80
  getCurrentDirectory: () => sys.getCurrentDirectory(),
@@ -83,16 +88,17 @@ var rawPlugin = (options = {}, meta) => {
83
88
  enforce: "pre",
84
89
  async buildStart() {
85
90
  if (transformTS || options.ts === "tsc") {
86
- let mogrify2 = function(key) {
91
+ let mogrify = function(key) {
87
92
  if (key in config && Array.isArray(config[key])) {
88
- config[key] = config[key].map((item) => {
93
+ return config[key] = config[key].map((item) => {
89
94
  if (typeof item !== "string")
90
95
  return item;
91
96
  return item.replace(/\.civet\b(?!\.)/g, ".civet.tsx");
92
97
  });
93
98
  }
99
+ ;
100
+ return;
94
101
  };
95
- var mogrify = mogrify2;
96
102
  const ts = await tsPromise;
97
103
  const civetConfigPath = "config" in options ? options.config : await findInDir(process.cwd());
98
104
  if (civetConfigPath) {
@@ -114,12 +120,12 @@ var rawPlugin = (options = {}, meta) => {
114
120
  console.error(ts.formatDiagnostic(error, getFormatHost(ts.sys)));
115
121
  throw error;
116
122
  }
117
- mogrify2("files");
123
+ mogrify("files");
118
124
  const system = { ...ts.sys };
119
125
  const { readDirectory: systemReadDirectory } = system;
120
126
  system.readDirectory = (path2, extensions, excludes, includes, depth) => {
121
127
  extensions = [...extensions ?? [], ".civet"];
122
- return systemReadDirectory(path2, extensions, excludes, includes, depth).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
128
+ return systemReadDirectory(path2, extensions, excludes, includes, depth).map(($1) => $1.endsWith(".civet") ? $1 + ".tsx" : $1);
123
129
  };
124
130
  const configContents = ts.parseJsonConfigFileContent(
125
131
  config,
@@ -133,7 +139,7 @@ var rawPlugin = (options = {}, meta) => {
133
139
  target: ts.ScriptTarget.ESNext,
134
140
  composite: false
135
141
  };
136
- compilerOptions.jsx ?? (compilerOptions.jsx = ts.JsxEmit.Preserve);
142
+ compilerOptions.jsx ??= ts.JsxEmit.Preserve;
137
143
  compilerOptionsWithSourceMap = {
138
144
  ...compilerOptions,
139
145
  sourceMap: true
@@ -157,10 +163,12 @@ var rawPlugin = (options = {}, meta) => {
157
163
  return true;
158
164
  return systemFileExists(filename.slice(0, -4));
159
165
  };
160
- system.readDirectory = (path2) => systemReadDirectory(path2).map((name) => name.endsWith(".civet") ? name + ".tsx" : name);
166
+ system.readDirectory = (path2) => {
167
+ return systemReadDirectory(path2).map(($2) => $2.endsWith(".civet") ? $2 + ".tsx" : $2);
168
+ };
161
169
  system.readFile = (filename, encoding = "utf-8") => {
162
170
  if (path.basename(filename) === "package.json") {
163
- let recurse2 = function(node) {
171
+ let recurse = function(node) {
164
172
  if (node && typeof node === "object") {
165
173
  for (const key in node) {
166
174
  const value = node[key];
@@ -170,18 +178,17 @@ var rawPlugin = (options = {}, meta) => {
170
178
  modified = true;
171
179
  }
172
180
  } else if (value) {
173
- recurse2(value);
181
+ recurse(value);
174
182
  }
175
183
  }
176
184
  }
177
185
  };
178
- var recurse = recurse2;
179
186
  const json = systemReadFile(filename, encoding);
180
187
  if (!json)
181
188
  return json;
182
189
  const parsed = JSON.parse(json);
183
190
  let modified = false;
184
- recurse2(parsed.imports);
191
+ recurse(parsed.imports);
185
192
  return modified ? JSON.stringify(parsed) : json;
186
193
  }
187
194
  if (!filename.endsWith(".civet.tsx"))
@@ -213,28 +220,30 @@ var rawPlugin = (options = {}, meta) => {
213
220
  options: compilerOptions,
214
221
  host: host.compilerHost
215
222
  });
216
- const diagnostics = ts.getPreEmitDiagnostics(program).map((diagnostic) => {
217
- const file = diagnostic.file;
218
- if (!file)
219
- return diagnostic;
220
- const sourceMap = sourceMaps.get(file.fileName);
221
- if (!sourceMap)
222
- return diagnostic;
223
- const sourcemapLines = sourceMap.data.lines;
224
- const range = remapRange(
225
- {
226
- start: diagnostic.start || 0,
227
- end: (diagnostic.start || 0) + (diagnostic.length || 1)
228
- },
229
- sourcemapLines
230
- );
231
- return {
232
- ...diagnostic,
233
- messageText: flattenDiagnosticMessageText(diagnostic.messageText),
234
- length: diagnostic.length,
235
- start: range.start
236
- };
237
- });
223
+ const diagnostics = ts.getPreEmitDiagnostics(program).map(
224
+ (diagnostic) => {
225
+ const file = diagnostic.file;
226
+ if (!file)
227
+ return diagnostic;
228
+ const sourceMap = sourceMaps.get(file.fileName);
229
+ if (!sourceMap)
230
+ return diagnostic;
231
+ const sourcemapLines = sourceMap.data.lines;
232
+ const range = remapRange(
233
+ {
234
+ start: diagnostic.start || 0,
235
+ end: (diagnostic.start || 0) + (diagnostic.length || 1)
236
+ },
237
+ sourcemapLines
238
+ );
239
+ return {
240
+ ...diagnostic,
241
+ messageText: flattenDiagnosticMessageText(diagnostic.messageText),
242
+ length: diagnostic.length,
243
+ start: range.start
244
+ };
245
+ }
246
+ );
238
247
  if (configErrors?.length) {
239
248
  diagnostics.unshift(...configErrors);
240
249
  }
@@ -249,18 +258,18 @@ var rawPlugin = (options = {}, meta) => {
249
258
  let failures = [];
250
259
  if (typeof options.typecheck === "string") {
251
260
  if (options.typecheck.includes("error"))
252
- failures.push(1 /* Error */);
261
+ failures.push(DiagnosticCategory.Error);
253
262
  if (options.typecheck.includes("warning"))
254
- failures.push(0 /* Warning */);
263
+ failures.push(DiagnosticCategory.Warning);
255
264
  if (options.typecheck.includes("suggestion"))
256
- failures.push(2 /* Suggestion */);
265
+ failures.push(DiagnosticCategory.Suggestion);
257
266
  if (options.typecheck.includes("message"))
258
- failures.push(3 /* Message */);
267
+ failures.push(DiagnosticCategory.Message);
259
268
  if (options.typecheck.includes("all")) {
260
269
  failures = { includes: () => true };
261
270
  }
262
271
  } else {
263
- failures.push(1 /* Error */);
272
+ failures.push(DiagnosticCategory.Error);
264
273
  }
265
274
  const count = diagnostics.filter((d) => failures.includes(d.category)).length;
266
275
  if (count) {
@@ -432,42 +441,49 @@ var rawPlugin = (options = {}, meta) => {
432
441
  code: compiled.code,
433
442
  map: jsonSourceMap
434
443
  };
435
- if (options.transformOutput)
444
+ if (options.transformOutput) {
436
445
  transformed = await options.transformOutput(transformed.code, id);
446
+ }
437
447
  cache?.set(filename, { mtime, result: transformed });
438
448
  return transformed;
439
449
  },
440
450
  esbuild: {
441
451
  config(options2) {
442
- esbuildOptions = options2;
452
+ return esbuildOptions = options2;
443
453
  }
444
454
  },
445
455
  vite: {
446
456
  config(config) {
447
- var _a;
448
457
  rootDir = path.resolve(process.cwd(), config.root ?? "");
449
458
  if (implicitExtension) {
450
- config.resolve ?? (config.resolve = {});
451
- (_a = config.resolve).extensions ?? (_a.extensions = DEFAULT_EXTENSIONS);
459
+ config.resolve ??= {};
460
+ config.resolve.extensions ??= DEFAULT_EXTENSIONS;
452
461
  config.resolve.extensions.push(".civet");
453
462
  }
463
+ ;
464
+ return;
454
465
  },
455
466
  async transformIndexHtml(html) {
456
467
  return html.replace(
457
468
  /<!--[^]*?-->|<[^<>]*>/g,
458
- (tag) => tag.replace(
459
- /<\s*script\b[^<>]*>/gi,
460
- (script) => (
461
- // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
462
- script.replace(
463
- /([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
464
- (attr, name, value) => name.toLowerCase() === "src" && value ? attr.replace(
465
- /(\.civet)(['"]?)$/,
466
- (_, extension, endQuote) => `${extension}${outExt}?transform${endQuote}`
467
- ) : attr
468
- )
469
- )
470
- )
469
+ (tag) => {
470
+ return tag.replace(
471
+ /<\s*script\b[^<>]*>/gi,
472
+ (script) => {
473
+ return script.replace(
474
+ /([:_\p{ID_Start}][:\p{ID_Continue}]*)(\s*=\s*("[^"]*"|'[^']*'|[^\s"'=<>`]*))?/gu,
475
+ (attr, name, value) => {
476
+ return name.toLowerCase() === "src" && value ? attr.replace(
477
+ /(\.civet)(['"]?)$/,
478
+ (_, extension, endQuote) => {
479
+ return `${extension}${outExt}?transform${endQuote}`;
480
+ }
481
+ ) : attr;
482
+ }
483
+ );
484
+ }
485
+ );
486
+ }
471
487
  );
472
488
  },
473
489
  handleHotUpdate({ file, server, modules }) {
@@ -485,10 +501,9 @@ var rawPlugin = (options = {}, meta) => {
485
501
  };
486
502
  };
487
503
  var unplugin = createUnplugin(rawPlugin);
488
- var src_default = unplugin;
489
-
504
+ var unplugin_civet_default = unplugin;
490
505
  export {
491
- slash,
506
+ unplugin_civet_default as default,
492
507
  rawPlugin,
493
- src_default
508
+ slash
494
509
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: (options: import("./unplugin.js").PluginOptions) => import("vite").Plugin | import("vite").Plugin[];
2
+ export default _default;
@@ -0,0 +1,36 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\vite.civet.jsx
30
+ var vite_civet_exports = {};
31
+ __export(vite_civet_exports, {
32
+ default: () => vite_civet_default
33
+ });
34
+ module.exports = __toCommonJS(vite_civet_exports);
35
+ var import_unplugin = __toESM(require("./unplugin.js"));
36
+ var vite_civet_default = import_unplugin.default.vite;
@@ -0,0 +1,6 @@
1
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\vite.civet.jsx
2
+ import civetUnplugin from "./unplugin.mjs";
3
+ var vite_civet_default = civetUnplugin.vite;
4
+ export {
5
+ vite_civet_default as default
6
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: (options: import("./unplugin.js").PluginOptions) => WebpackPluginInstance;
2
+ export default _default;
@@ -0,0 +1,36 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\webpack.civet.jsx
30
+ var webpack_civet_exports = {};
31
+ __export(webpack_civet_exports, {
32
+ default: () => webpack_civet_default
33
+ });
34
+ module.exports = __toCommonJS(webpack_civet_exports);
35
+ var import_unplugin = __toESM(require("./unplugin.js"));
36
+ var webpack_civet_default = import_unplugin.default.webpack;
@@ -0,0 +1,6 @@
1
+ // unplugin-civet:C:\Users\edemaine\Projects\Civet\source\unplugin\webpack.civet.jsx
2
+ import civetUnplugin from "./unplugin.mjs";
3
+ var webpack_civet_default = civetUnplugin.webpack;
4
+ export {
5
+ webpack_civet_default as default
6
+ };