@danielx/civet 0.6.77 → 0.6.79

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 CHANGED
@@ -1432,16 +1432,15 @@ var Civet = (() => {
1432
1432
  switch (node.type) {
1433
1433
  case "BlockStatement":
1434
1434
  if (node.expressions.length) {
1435
- const last = node.expressions[node.expressions.length - 1];
1436
- insertPush(last, ref);
1435
+ insertPush(node.expressions.at(-1), ref);
1437
1436
  } else {
1438
1437
  node.expressions.push([ref, ".push(void 0);"]);
1439
1438
  }
1440
1439
  return;
1441
1440
  case "CaseBlock":
1442
- node.clauses.forEach((clause) => ({
1443
- insertPush: insertPush(clause, ref)
1444
- }));
1441
+ node.clauses.forEach((clause) => {
1442
+ return insertPush(clause, ref);
1443
+ });
1445
1444
  return;
1446
1445
  case "WhenClause":
1447
1446
  insertPush(node.block, ref);
@@ -1490,8 +1489,8 @@ var Civet = (() => {
1490
1489
  return;
1491
1490
  case "IfStatement":
1492
1491
  insertPush(exp.then, ref);
1493
- if (exp.then.bare) {
1494
- exp.then.children.push(";");
1492
+ if (exp.then.bare && !exp.then.semicolon) {
1493
+ exp.then.children.push(exp.then.semicolon = ";");
1495
1494
  }
1496
1495
  if (exp.else)
1497
1496
  insertPush(exp.else[2], ref);
@@ -2468,11 +2467,10 @@ var Civet = (() => {
2468
2467
  const { else: e } = s;
2469
2468
  const block = blockWithPrefix(condition.expression.blockPrefix, s.then);
2470
2469
  s.then = block;
2471
- const toAdd = [block];
2472
- if (block.bare && e) {
2473
- toAdd.push(";");
2470
+ if (block.bare && e && !block.semicolon) {
2471
+ block.children.push(block.semicolon = ";");
2474
2472
  }
2475
- s.children.splice(2, 1, ...toAdd);
2473
+ s.children.splice(2, 1, block);
2476
2474
  updateParentPointers(block, s);
2477
2475
  break;
2478
2476
  }
package/dist/civet CHANGED
@@ -347,7 +347,7 @@ async function cli() {
347
347
  };
348
348
  (unpluginOptions.parseOptions ??= {}).rewriteCivetImports = ".civet.tsx";
349
349
  unplugin = (0, import_unplugin.rawPlugin)(unpluginOptions, { framework: "civet-cli" });
350
- unplugin.buildStart();
350
+ await unplugin.buildStart();
351
351
  }
352
352
  if (options.run) {
353
353
  options.js = true;
package/dist/esbuild.js CHANGED
@@ -239,20 +239,18 @@ var rawPlugin = (options = {}, meta) => {
239
239
  if (/\0/.test(id))
240
240
  return null;
241
241
  id = cleanCivetId(id);
242
- const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
- if (!absolutePath)
242
+ let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
+ if (!resolvedId)
244
244
  return null;
245
- let relativeId = import_path.default.relative(process.cwd(), absolutePath);
246
- if (!relativeId.endsWith(".civet")) {
245
+ if (!resolvedId.endsWith(".civet")) {
247
246
  if (!implicitExtension)
248
247
  return null;
249
- const implicitId = implicitCivet(relativeId);
248
+ const implicitId = implicitCivet(resolvedId);
250
249
  if (!implicitId)
251
250
  return null;
252
- relativeId = implicitId;
251
+ resolvedId = implicitId;
253
252
  }
254
- const relativePath = relativeId + outExt;
255
- return relativePath;
253
+ return resolvedId + outExt;
256
254
  },
257
255
  loadInclude(id) {
258
256
  return isCivetTranspiled(id);
@@ -260,7 +258,7 @@ var rawPlugin = (options = {}, meta) => {
260
258
  async load(id) {
261
259
  if (!isCivetTranspiled(id))
262
260
  return null;
263
- const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
261
+ const filename = import_path.default.resolve(rootDir, id.slice(0, -outExt.length));
264
262
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
265
263
  this.addWatchFile(filename);
266
264
  let compiled;
@@ -380,10 +378,10 @@ var rawPlugin = (options = {}, meta) => {
380
378
  handleHotUpdate({ file, server, modules }) {
381
379
  if (!file.endsWith(".civet"))
382
380
  return;
383
- const relativeId = slash(import_path.default.relative(process.cwd(), file) + outExt);
384
- const module2 = server.moduleGraph.getModuleById(relativeId);
381
+ const resolvedId = slash(import_path.default.resolve(file) + outExt);
382
+ const module2 = server.moduleGraph.getModuleById(resolvedId);
385
383
  if (module2) {
386
- server.moduleGraph.onFileChange(relativeId);
384
+ server.moduleGraph.onFileChange(resolvedId);
387
385
  return [...modules, module2];
388
386
  }
389
387
  return modules;
package/dist/main.js CHANGED
@@ -1424,16 +1424,15 @@ function insertPush(node, ref) {
1424
1424
  switch (node.type) {
1425
1425
  case "BlockStatement":
1426
1426
  if (node.expressions.length) {
1427
- const last = node.expressions[node.expressions.length - 1];
1428
- insertPush(last, ref);
1427
+ insertPush(node.expressions.at(-1), ref);
1429
1428
  } else {
1430
1429
  node.expressions.push([ref, ".push(void 0);"]);
1431
1430
  }
1432
1431
  return;
1433
1432
  case "CaseBlock":
1434
- node.clauses.forEach((clause) => ({
1435
- insertPush: insertPush(clause, ref)
1436
- }));
1433
+ node.clauses.forEach((clause) => {
1434
+ return insertPush(clause, ref);
1435
+ });
1437
1436
  return;
1438
1437
  case "WhenClause":
1439
1438
  insertPush(node.block, ref);
@@ -1482,8 +1481,8 @@ function insertPush(node, ref) {
1482
1481
  return;
1483
1482
  case "IfStatement":
1484
1483
  insertPush(exp.then, ref);
1485
- if (exp.then.bare) {
1486
- exp.then.children.push(";");
1484
+ if (exp.then.bare && !exp.then.semicolon) {
1485
+ exp.then.children.push(exp.then.semicolon = ";");
1487
1486
  }
1488
1487
  if (exp.else)
1489
1488
  insertPush(exp.else[2], ref);
@@ -2460,11 +2459,10 @@ function processDeclarationConditionStatement(s) {
2460
2459
  const { else: e } = s;
2461
2460
  const block = blockWithPrefix(condition.expression.blockPrefix, s.then);
2462
2461
  s.then = block;
2463
- const toAdd = [block];
2464
- if (block.bare && e) {
2465
- toAdd.push(";");
2462
+ if (block.bare && e && !block.semicolon) {
2463
+ block.children.push(block.semicolon = ";");
2466
2464
  }
2467
- s.children.splice(2, 1, ...toAdd);
2465
+ s.children.splice(2, 1, block);
2468
2466
  updateParentPointers(block, s);
2469
2467
  break;
2470
2468
  }
package/dist/main.mjs CHANGED
@@ -1422,16 +1422,15 @@ function insertPush(node, ref) {
1422
1422
  switch (node.type) {
1423
1423
  case "BlockStatement":
1424
1424
  if (node.expressions.length) {
1425
- const last = node.expressions[node.expressions.length - 1];
1426
- insertPush(last, ref);
1425
+ insertPush(node.expressions.at(-1), ref);
1427
1426
  } else {
1428
1427
  node.expressions.push([ref, ".push(void 0);"]);
1429
1428
  }
1430
1429
  return;
1431
1430
  case "CaseBlock":
1432
- node.clauses.forEach((clause) => ({
1433
- insertPush: insertPush(clause, ref)
1434
- }));
1431
+ node.clauses.forEach((clause) => {
1432
+ return insertPush(clause, ref);
1433
+ });
1435
1434
  return;
1436
1435
  case "WhenClause":
1437
1436
  insertPush(node.block, ref);
@@ -1480,8 +1479,8 @@ function insertPush(node, ref) {
1480
1479
  return;
1481
1480
  case "IfStatement":
1482
1481
  insertPush(exp.then, ref);
1483
- if (exp.then.bare) {
1484
- exp.then.children.push(";");
1482
+ if (exp.then.bare && !exp.then.semicolon) {
1483
+ exp.then.children.push(exp.then.semicolon = ";");
1485
1484
  }
1486
1485
  if (exp.else)
1487
1486
  insertPush(exp.else[2], ref);
@@ -2458,11 +2457,10 @@ function processDeclarationConditionStatement(s) {
2458
2457
  const { else: e } = s;
2459
2458
  const block = blockWithPrefix(condition.expression.blockPrefix, s.then);
2460
2459
  s.then = block;
2461
- const toAdd = [block];
2462
- if (block.bare && e) {
2463
- toAdd.push(";");
2460
+ if (block.bare && e && !block.semicolon) {
2461
+ block.children.push(block.semicolon = ";");
2464
2462
  }
2465
- s.children.splice(2, 1, ...toAdd);
2463
+ s.children.splice(2, 1, block);
2466
2464
  updateParentPointers(block, s);
2467
2465
  break;
2468
2466
  }
package/dist/rollup.js CHANGED
@@ -239,20 +239,18 @@ var rawPlugin = (options = {}, meta) => {
239
239
  if (/\0/.test(id))
240
240
  return null;
241
241
  id = cleanCivetId(id);
242
- const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
- if (!absolutePath)
242
+ let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
+ if (!resolvedId)
244
244
  return null;
245
- let relativeId = import_path.default.relative(process.cwd(), absolutePath);
246
- if (!relativeId.endsWith(".civet")) {
245
+ if (!resolvedId.endsWith(".civet")) {
247
246
  if (!implicitExtension)
248
247
  return null;
249
- const implicitId = implicitCivet(relativeId);
248
+ const implicitId = implicitCivet(resolvedId);
250
249
  if (!implicitId)
251
250
  return null;
252
- relativeId = implicitId;
251
+ resolvedId = implicitId;
253
252
  }
254
- const relativePath = relativeId + outExt;
255
- return relativePath;
253
+ return resolvedId + outExt;
256
254
  },
257
255
  loadInclude(id) {
258
256
  return isCivetTranspiled(id);
@@ -260,7 +258,7 @@ var rawPlugin = (options = {}, meta) => {
260
258
  async load(id) {
261
259
  if (!isCivetTranspiled(id))
262
260
  return null;
263
- const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
261
+ const filename = import_path.default.resolve(rootDir, id.slice(0, -outExt.length));
264
262
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
265
263
  this.addWatchFile(filename);
266
264
  let compiled;
@@ -380,10 +378,10 @@ var rawPlugin = (options = {}, meta) => {
380
378
  handleHotUpdate({ file, server, modules }) {
381
379
  if (!file.endsWith(".civet"))
382
380
  return;
383
- const relativeId = slash(import_path.default.relative(process.cwd(), file) + outExt);
384
- const module2 = server.moduleGraph.getModuleById(relativeId);
381
+ const resolvedId = slash(import_path.default.resolve(file) + outExt);
382
+ const module2 = server.moduleGraph.getModuleById(resolvedId);
385
383
  if (module2) {
386
- server.moduleGraph.onFileChange(relativeId);
384
+ server.moduleGraph.onFileChange(resolvedId);
387
385
  return [...modules, module2];
388
386
  }
389
387
  return modules;
@@ -206,20 +206,18 @@ var rawPlugin = (options = {}, meta) => {
206
206
  if (/\0/.test(id))
207
207
  return null;
208
208
  id = cleanCivetId(id);
209
- const absolutePath = path.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : path.resolve(path.dirname(importer ?? ""), id);
210
- if (!absolutePath)
209
+ let resolvedId = path.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : path.resolve(path.dirname(importer ?? ""), id);
210
+ if (!resolvedId)
211
211
  return null;
212
- let relativeId = path.relative(process.cwd(), absolutePath);
213
- if (!relativeId.endsWith(".civet")) {
212
+ if (!resolvedId.endsWith(".civet")) {
214
213
  if (!implicitExtension)
215
214
  return null;
216
- const implicitId = implicitCivet(relativeId);
215
+ const implicitId = implicitCivet(resolvedId);
217
216
  if (!implicitId)
218
217
  return null;
219
- relativeId = implicitId;
218
+ resolvedId = implicitId;
220
219
  }
221
- const relativePath = relativeId + outExt;
222
- return relativePath;
220
+ return resolvedId + outExt;
223
221
  },
224
222
  loadInclude(id) {
225
223
  return isCivetTranspiled(id);
@@ -227,7 +225,7 @@ var rawPlugin = (options = {}, meta) => {
227
225
  async load(id) {
228
226
  if (!isCivetTranspiled(id))
229
227
  return null;
230
- const filename = path.resolve(process.cwd(), id.slice(0, -outExt.length));
228
+ const filename = path.resolve(rootDir, id.slice(0, -outExt.length));
231
229
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
232
230
  this.addWatchFile(filename);
233
231
  let compiled;
@@ -347,10 +345,10 @@ var rawPlugin = (options = {}, meta) => {
347
345
  handleHotUpdate({ file, server, modules }) {
348
346
  if (!file.endsWith(".civet"))
349
347
  return;
350
- const relativeId = slash(path.relative(process.cwd(), file) + outExt);
351
- const module = server.moduleGraph.getModuleById(relativeId);
348
+ const resolvedId = slash(path.resolve(file) + outExt);
349
+ const module = server.moduleGraph.getModuleById(resolvedId);
352
350
  if (module) {
353
- server.moduleGraph.onFileChange(relativeId);
351
+ server.moduleGraph.onFileChange(resolvedId);
354
352
  return [...modules, module];
355
353
  }
356
354
  return modules;
package/dist/unplugin.js CHANGED
@@ -239,20 +239,18 @@ var rawPlugin = (options = {}, meta) => {
239
239
  if (/\0/.test(id))
240
240
  return null;
241
241
  id = cleanCivetId(id);
242
- const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
- if (!absolutePath)
242
+ let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
+ if (!resolvedId)
244
244
  return null;
245
- let relativeId = import_path.default.relative(process.cwd(), absolutePath);
246
- if (!relativeId.endsWith(".civet")) {
245
+ if (!resolvedId.endsWith(".civet")) {
247
246
  if (!implicitExtension)
248
247
  return null;
249
- const implicitId = implicitCivet(relativeId);
248
+ const implicitId = implicitCivet(resolvedId);
250
249
  if (!implicitId)
251
250
  return null;
252
- relativeId = implicitId;
251
+ resolvedId = implicitId;
253
252
  }
254
- const relativePath = relativeId + outExt;
255
- return relativePath;
253
+ return resolvedId + outExt;
256
254
  },
257
255
  loadInclude(id) {
258
256
  return isCivetTranspiled(id);
@@ -260,7 +258,7 @@ var rawPlugin = (options = {}, meta) => {
260
258
  async load(id) {
261
259
  if (!isCivetTranspiled(id))
262
260
  return null;
263
- const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
261
+ const filename = import_path.default.resolve(rootDir, id.slice(0, -outExt.length));
264
262
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
265
263
  this.addWatchFile(filename);
266
264
  let compiled;
@@ -380,10 +378,10 @@ var rawPlugin = (options = {}, meta) => {
380
378
  handleHotUpdate({ file, server, modules }) {
381
379
  if (!file.endsWith(".civet"))
382
380
  return;
383
- const relativeId = slash(import_path.default.relative(process.cwd(), file) + outExt);
384
- const module2 = server.moduleGraph.getModuleById(relativeId);
381
+ const resolvedId = slash(import_path.default.resolve(file) + outExt);
382
+ const module2 = server.moduleGraph.getModuleById(resolvedId);
385
383
  if (module2) {
386
- server.moduleGraph.onFileChange(relativeId);
384
+ server.moduleGraph.onFileChange(resolvedId);
387
385
  return [...modules, module2];
388
386
  }
389
387
  return modules;
package/dist/vite.js CHANGED
@@ -239,20 +239,18 @@ var rawPlugin = (options = {}, meta) => {
239
239
  if (/\0/.test(id))
240
240
  return null;
241
241
  id = cleanCivetId(id);
242
- const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
- if (!absolutePath)
242
+ let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
+ if (!resolvedId)
244
244
  return null;
245
- let relativeId = import_path.default.relative(process.cwd(), absolutePath);
246
- if (!relativeId.endsWith(".civet")) {
245
+ if (!resolvedId.endsWith(".civet")) {
247
246
  if (!implicitExtension)
248
247
  return null;
249
- const implicitId = implicitCivet(relativeId);
248
+ const implicitId = implicitCivet(resolvedId);
250
249
  if (!implicitId)
251
250
  return null;
252
- relativeId = implicitId;
251
+ resolvedId = implicitId;
253
252
  }
254
- const relativePath = relativeId + outExt;
255
- return relativePath;
253
+ return resolvedId + outExt;
256
254
  },
257
255
  loadInclude(id) {
258
256
  return isCivetTranspiled(id);
@@ -260,7 +258,7 @@ var rawPlugin = (options = {}, meta) => {
260
258
  async load(id) {
261
259
  if (!isCivetTranspiled(id))
262
260
  return null;
263
- const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
261
+ const filename = import_path.default.resolve(rootDir, id.slice(0, -outExt.length));
264
262
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
265
263
  this.addWatchFile(filename);
266
264
  let compiled;
@@ -380,10 +378,10 @@ var rawPlugin = (options = {}, meta) => {
380
378
  handleHotUpdate({ file, server, modules }) {
381
379
  if (!file.endsWith(".civet"))
382
380
  return;
383
- const relativeId = slash(import_path.default.relative(process.cwd(), file) + outExt);
384
- const module2 = server.moduleGraph.getModuleById(relativeId);
381
+ const resolvedId = slash(import_path.default.resolve(file) + outExt);
382
+ const module2 = server.moduleGraph.getModuleById(resolvedId);
385
383
  if (module2) {
386
- server.moduleGraph.onFileChange(relativeId);
384
+ server.moduleGraph.onFileChange(resolvedId);
387
385
  return [...modules, module2];
388
386
  }
389
387
  return modules;
package/dist/webpack.js CHANGED
@@ -239,20 +239,18 @@ var rawPlugin = (options = {}, meta) => {
239
239
  if (/\0/.test(id))
240
240
  return null;
241
241
  id = cleanCivetId(id);
242
- const absolutePath = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
- if (!absolutePath)
242
+ let resolvedId = import_path.default.isAbsolute(id) ? resolveAbsolutePath(rootDir, id, implicitExtension) : import_path.default.resolve(import_path.default.dirname(importer ?? ""), id);
243
+ if (!resolvedId)
244
244
  return null;
245
- let relativeId = import_path.default.relative(process.cwd(), absolutePath);
246
- if (!relativeId.endsWith(".civet")) {
245
+ if (!resolvedId.endsWith(".civet")) {
247
246
  if (!implicitExtension)
248
247
  return null;
249
- const implicitId = implicitCivet(relativeId);
248
+ const implicitId = implicitCivet(resolvedId);
250
249
  if (!implicitId)
251
250
  return null;
252
- relativeId = implicitId;
251
+ resolvedId = implicitId;
253
252
  }
254
- const relativePath = relativeId + outExt;
255
- return relativePath;
253
+ return resolvedId + outExt;
256
254
  },
257
255
  loadInclude(id) {
258
256
  return isCivetTranspiled(id);
@@ -260,7 +258,7 @@ var rawPlugin = (options = {}, meta) => {
260
258
  async load(id) {
261
259
  if (!isCivetTranspiled(id))
262
260
  return null;
263
- const filename = import_path.default.resolve(process.cwd(), id.slice(0, -outExt.length));
261
+ const filename = import_path.default.resolve(rootDir, id.slice(0, -outExt.length));
264
262
  const rawCivetSource = await fs.promises.readFile(filename, "utf-8");
265
263
  this.addWatchFile(filename);
266
264
  let compiled;
@@ -380,10 +378,10 @@ var rawPlugin = (options = {}, meta) => {
380
378
  handleHotUpdate({ file, server, modules }) {
381
379
  if (!file.endsWith(".civet"))
382
380
  return;
383
- const relativeId = slash(import_path.default.relative(process.cwd(), file) + outExt);
384
- const module2 = server.moduleGraph.getModuleById(relativeId);
381
+ const resolvedId = slash(import_path.default.resolve(file) + outExt);
382
+ const module2 = server.moduleGraph.getModuleById(resolvedId);
385
383
  if (module2) {
386
- server.moduleGraph.onFileChange(relativeId);
384
+ server.moduleGraph.onFileChange(resolvedId);
387
385
  return [...modules, module2];
388
386
  }
389
387
  return modules;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
3
  "type": "commonjs",
4
- "version": "0.6.77",
4
+ "version": "0.6.79",
5
5
  "description": "CoffeeScript style syntax for TypeScript",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/main.mjs",