sv 0.6.27 → 0.7.1

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/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { Element, __commonJS, __require, __toESM, addPnpmBuildDependendencies, box, cancel, confirm, create, detect, esm_exports, from, getUserAgent, group, installDependencies, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss, parseHtml, parseHtml$1, parseJson, parseScript, parseSvelte, resolveCommand, select, spinner, templates, text, up, walk_exports } from "./package-manager-BF1V21Xa.js";
3
- import { __commonJS$1, __export, __toESM$1, addFromString, applyAddons, array_exports, common_exports, createWorkspace, dedent_default, exports_exports, formatFiles, function_exports, getHighlighter, imports_exports, kit_exports, object_exports, require_picocolors, setupAddons, variables_exports } from "./install-D7XPOwHS.js";
2
+ import { Element, __commonJS, __require, __toESM, addPnpmBuildDependendencies, box, cancel, confirm, create, detect, esm_exports, from, getUserAgent, group, installDependencies, intro, isCancel, log, multiselect, note, outro, packageManagerPrompt, parseCss, parseHtml, parseHtml$1, parseJson, parseScript, parseSvelte, resolveCommand, select, spinner, templates, text, up, walk_exports } from "./package-manager-BusIB9Xp.js";
3
+ import { __commonJS$1, __export, __toESM$1, addFromString, applyAddons, array_exports, common_exports, createWorkspace, dedent_default, exports_exports, formatFiles, function_exports, getHighlighter, imports_exports, kit_exports, object_exports, require_picocolors, setupAddons, variables_exports } from "./install-DPLwqpud.js";
4
4
  import fs, { existsSync } from "node:fs";
5
5
  import path, { dirname, join } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -12,7 +12,7 @@ import { promisify } from "node:util";
12
12
 
13
13
  //#region packages/cli/package.json
14
14
  var name = "sv";
15
- var version = "0.6.27";
15
+ var version = "0.7.1";
16
16
  var type = "module";
17
17
  var description = "A CLI for creating and updating SvelteKit projects";
18
18
  var license = "MIT";
@@ -4218,11 +4218,11 @@ var drizzle_default = defineAddon({
4218
4218
  authToken
4219
4219
  }),
4220
4220
  verbose: {
4221
- type: "BooleanLiteral",
4221
+ type: "Literal",
4222
4222
  value: true
4223
4223
  },
4224
4224
  strict: {
4225
- type: "BooleanLiteral",
4225
+ type: "Literal",
4226
4226
  value: true
4227
4227
  }
4228
4228
  });
@@ -4316,8 +4316,8 @@ var drizzle_default = defineAddon({
4316
4316
  common_exports.addStatement(ast, clientIdentifier);
4317
4317
  const drizzleCall = function_exports.callByIdentifier("drizzle", ["client"]);
4318
4318
  const paramObject = object_exports.create({ schema: variables_exports.identifier("schema") });
4319
- if (options$6.database == "mysql") {
4320
- const mode = options$6.mysql == "planetscale" ? "planetscale" : "default";
4319
+ if (options$6.database === "mysql") {
4320
+ const mode = options$6.mysql === "planetscale" ? "planetscale" : "default";
4321
4321
  object_exports.property(paramObject, "mode", common_exports.createLiteral(mode));
4322
4322
  }
4323
4323
  drizzleCall.arguments.push(paramObject);
@@ -4393,7 +4393,7 @@ function addEslintConfigPrettier(content) {
4393
4393
  const nodesToInsert = [];
4394
4394
  if (!common_exports.hasNode(eslintConfig, prettier)) nodesToInsert.push(prettier);
4395
4395
  if (!common_exports.hasNode(eslintConfig, configSpread)) nodesToInsert.push(configSpread);
4396
- const elements = eslintConfig.type == "ArrayExpression" ? eslintConfig.elements : eslintConfig.arguments;
4396
+ const elements = eslintConfig.type === "ArrayExpression" ? eslintConfig.elements : eslintConfig.arguments;
4397
4397
  const idx = elements.findIndex((el) => el?.type === "SpreadElement" && el.argument.type === "MemberExpression" && el.argument.object.type === "MemberExpression" && el.argument.object.property.type === "Identifier" && el.argument.object.property.name === "configs" && el.argument.object.object.type === "Identifier" && el.argument.object.object.name === svelteImportName);
4398
4398
  if (idx !== -1) elements.splice(idx + 1, 0, ...nodesToInsert);
4399
4399
  else elements.push(...nodesToInsert);
@@ -4443,7 +4443,7 @@ var eslint_default = defineAddon({
4443
4443
  const { ast, generateCode } = parseScript(content);
4444
4444
  const eslintConfigs = [];
4445
4445
  imports_exports.addDefault(ast, "./svelte.config.js", "svelteConfig");
4446
- const gitIgnorePathStatement = common_exports.statementFromString("\nconst gitignorePath = fileURLToPath(new URL(\"./.gitignore\", import.meta.url));");
4446
+ const gitIgnorePathStatement = common_exports.statementFromString("\nconst gitignorePath = fileURLToPath(new URL('./.gitignore', import.meta.url));");
4447
4447
  common_exports.addStatement(ast, gitIgnorePathStatement);
4448
4448
  const ignoresConfig = common_exports.expressionFromString("includeIgnoreFile(gitignorePath)");
4449
4449
  eslintConfigs.push(ignoresConfig);
@@ -4459,12 +4459,25 @@ var eslint_default = defineAddon({
4459
4459
  const globalsNode = common_exports.createSpreadElement(common_exports.expressionFromString("globals.node"));
4460
4460
  const globalsObjLiteral = object_exports.createEmpty();
4461
4461
  globalsObjLiteral.properties = [globalsBrowser, globalsNode];
4462
- const globalsConfig = object_exports.create({ languageOptions: object_exports.create({ globals: globalsObjLiteral }) });
4462
+ const off = common_exports.createLiteral("off");
4463
+ const rules = object_exports.create({ "\"no-undef\"": off });
4464
+ if (rules.properties[0].type !== "Property") throw new Error("rules.properties[0].type !== \"Property\"");
4465
+ rules.properties[0].key.leadingComments = [{
4466
+ type: "Line",
4467
+ value: " typescript-eslint strongly recommend that you do not use the no-undef lint rule on TypeScript projects."
4468
+ }, {
4469
+ type: "Line",
4470
+ value: " see: https://typescript-eslint.io/troubleshooting/faqs/eslint/#i-get-errors-from-the-no-undef-rule-about-global-variables-not-being-defined-even-though-there-are-no-typescript-errors"
4471
+ }];
4472
+ const globalsConfig = object_exports.create({
4473
+ languageOptions: object_exports.create({ globals: globalsObjLiteral }),
4474
+ rules: typescript ? rules : undefined
4475
+ });
4463
4476
  eslintConfigs.push(globalsConfig);
4464
4477
  if (typescript) {
4465
4478
  const svelteTSParserConfig = object_exports.create({
4466
- files: common_exports.expressionFromString("[\"**/*.svelte\", \"**/*.svelte.ts\", \"**/*.svelte.js\"]"),
4467
- ignores: common_exports.expressionFromString("[\"eslint.config.js\", \"svelte.config.js\"]"),
4479
+ files: common_exports.expressionFromString("['**/*.svelte', '**/*.svelte.ts', '**/*.svelte.js']"),
4480
+ ignores: common_exports.expressionFromString("['eslint.config.js', 'svelte.config.js']"),
4468
4481
  languageOptions: object_exports.create({ parserOptions: object_exports.create({
4469
4482
  projectService: common_exports.expressionFromString("true"),
4470
4483
  extraFileExtensions: common_exports.expressionFromString("['.svelte']"),
@@ -4475,7 +4488,7 @@ var eslint_default = defineAddon({
4475
4488
  eslintConfigs.push(svelteTSParserConfig);
4476
4489
  } else {
4477
4490
  const svelteTSParserConfig = object_exports.create({
4478
- files: common_exports.expressionFromString("[\"**/*.svelte\", \"**/*.svelte.js\"]"),
4491
+ files: common_exports.expressionFromString("['**/*.svelte', '**/*.svelte.js']"),
4479
4492
  languageOptions: object_exports.create({ parserOptions: object_exports.create({ svelteConfig: common_exports.expressionFromString("svelteConfig") }) })
4480
4493
  });
4481
4494
  eslintConfigs.push(svelteTSParserConfig);
@@ -4582,13 +4595,14 @@ var sveltekit_adapter_default = defineAddon({
4582
4595
  let adapterName = "adapter";
4583
4596
  if (adapterImportDecl) {
4584
4597
  adapterImportDecl.source.value = adapter.package;
4598
+ adapterImportDecl.source.raw = undefined;
4585
4599
  adapterName = adapterImportDecl.specifiers?.find((s$1) => s$1.type === "ImportDefaultSpecifier")?.local?.name;
4586
4600
  } else imports_exports.addDefault(ast, adapter.package, adapterName);
4587
4601
  const { value: config } = exports_exports.defaultExport(ast, object_exports.createEmpty());
4588
- const kitConfig = config.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "kit");
4602
+ const kitConfig = config.properties.find((p) => p.type === "Property" && p.key.type === "Identifier" && p.key.name === "kit");
4589
4603
  if (kitConfig && kitConfig.value.type === "ObjectExpression") {
4590
- const adapterProp = kitConfig.value.properties.find((p) => p.type === "ObjectProperty" && p.key.type === "Identifier" && p.key.name === "adapter");
4591
- if (adapterProp) adapterProp.comments = [];
4604
+ const adapterProp = kitConfig.value.properties.find((p) => p.type === "Property" && p.key.type === "Identifier" && p.key.name === "adapter");
4605
+ if (adapterProp) adapterProp.leadingComments = [];
4592
4606
  object_exports.overrideProperties(kitConfig.value, { adapter: function_exports.callByIdentifier(adapterName, []) });
4593
4607
  } else object_exports.properties(config, { kit: object_exports.create({ adapter: function_exports.callByIdentifier(adapterName, []) }) });
4594
4608
  return generateCode();
@@ -5641,9 +5655,9 @@ var lucia_default = defineAddon({
5641
5655
  sv.file(`drizzle.config.${ext}`, (content) => {
5642
5656
  const { ast, generateCode } = parseScript(content);
5643
5657
  const isProp = (name$1, node) => node.key.type === "Identifier" && node.key.name === name$1;
5644
- walk_exports.walk(ast, {}, { ObjectProperty(node) {
5645
- if (isProp("dialect", node) && node.value.type === "StringLiteral") drizzleDialect = node.value.value;
5646
- if (isProp("schema", node) && node.value.type === "StringLiteral") schemaPath = node.value.value;
5658
+ walk_exports.walk(ast, null, { Property(node) {
5659
+ if (isProp("dialect", node) && node.value.type === "Literal" && typeof node.value.value === "string") drizzleDialect = node.value.value;
5660
+ if (isProp("schema", node) && node.value.type === "Literal" && typeof node.value.value === "string") schemaPath = node.value.value;
5647
5661
  } });
5648
5662
  if (!drizzleDialect) throw new Error("Failed to detect DB dialect in your `drizzle.config.[js|ts]` file");
5649
5663
  if (!schemaPath) throw new Error("Failed to find schema path in your `drizzle.config.[js|ts]` file");
@@ -6082,6 +6096,7 @@ function createLuciaType(name$1) {
6082
6096
  type: "Identifier",
6083
6097
  name: name$1
6084
6098
  },
6099
+ computed: false,
6085
6100
  typeAnnotation: {
6086
6101
  type: "TSTypeAnnotation",
6087
6102
  typeAnnotation: {
@@ -6089,7 +6104,7 @@ function createLuciaType(name$1) {
6089
6104
  objectType: {
6090
6105
  type: "TSImportType",
6091
6106
  argument: {
6092
- type: "StringLiteral",
6107
+ type: "Literal",
6093
6108
  value: "$lib/server/auth"
6094
6109
  },
6095
6110
  qualifier: {
@@ -6100,7 +6115,7 @@ function createLuciaType(name$1) {
6100
6115
  indexType: {
6101
6116
  type: "TSLiteralType",
6102
6117
  literal: {
6103
- type: "StringLiteral",
6118
+ type: "Literal",
6104
6119
  value: name$1
6105
6120
  }
6106
6121
  }
@@ -6133,7 +6148,7 @@ function getAuthHandleContent() {
6133
6148
  }
6134
6149
  function getCallExpression(ast) {
6135
6150
  let callExpression;
6136
- walk_exports.walk(ast, {}, { CallExpression(node) {
6151
+ walk_exports.walk(ast, null, { CallExpression(node) {
6137
6152
  callExpression ??= node;
6138
6153
  } });
6139
6154
  return callExpression;
@@ -6836,7 +6851,7 @@ function getPadding(lines) {
6836
6851
  return Math.max(...lengths);
6837
6852
  }
6838
6853
  function forwardExitCode(error) {
6839
- if (error && typeof error === "object" && "status" in error && typeof error.status == "number") process$1.exit(error.status);
6854
+ if (error && typeof error === "object" && "status" in error && typeof error.status === "number") process$1.exit(error.status);
6840
6855
  else process$1.exit(1);
6841
6856
  }
6842
6857
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { create } from "./package-manager-BF1V21Xa.js";
2
- import { installAddon } from "./install-D7XPOwHS.js";
1
+ import { create } from "./package-manager-BusIB9Xp.js";
2
+ import { installAddon } from "./install-DPLwqpud.js";
3
3
 
4
4
  export { create, installAddon };
@@ -1,4 +1,4 @@
1
- import { __commonJS, __toESM, be, detect, getUserAgent, log, parseJson, parseScript, parseScript$1, resolveCommand, serializeScript, stripAst, up, walk_exports } from "./package-manager-BF1V21Xa.js";
1
+ import { __commonJS, __toESM, be, detect, getUserAgent, log, parseJson, parseScript as parseScript$1, parseScript$1 as parseScript, resolveCommand, serializeScript, stripAst, up, walk_exports } from "./package-manager-BusIB9Xp.js";
2
2
  import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import process$1 from "node:process";
@@ -188,7 +188,7 @@ else mindent = Math.min(mindent, indent);
188
188
  }
189
189
 
190
190
  //#endregion
191
- //#region packages/core/dist/common-DU6ydIJj.js
191
+ //#region packages/core/dist/common-Dee02diz.js
192
192
  function decircular(object) {
193
193
  const seenObjects = new WeakMap();
194
194
  function internalDecircular(value, path$1 = []) {
@@ -215,6 +215,7 @@ __export(common_exports, {
215
215
  createSpreadElement: () => createSpreadElement,
216
216
  expressionFromString: () => expressionFromString,
217
217
  expressionStatement: () => expressionStatement,
218
+ fromString: () => fromString,
218
219
  hasNode: () => hasNode,
219
220
  hasTypeProp: () => hasTypeProp,
220
221
  satisfiesExpression: () => satisfiesExpression,
@@ -223,9 +224,8 @@ __export(common_exports, {
223
224
  });
224
225
  function addJsDocTypeComment(node, type) {
225
226
  const comment = {
226
- type: "CommentBlock",
227
- value: `* @type {${type}} `,
228
- leading: true
227
+ type: "Block",
228
+ value: `* @type {${type}} `
229
229
  };
230
230
  addComment(node, comment);
231
231
  }
@@ -233,16 +233,15 @@ function addJsDocComment(node, params) {
233
233
  const commentLines = [];
234
234
  for (const [key, value] of Object.entries(params)) commentLines.push(`@param {${key}} ${value}`);
235
235
  const comment = {
236
- type: "CommentBlock",
237
- value: `*\n * ${commentLines.join("\n * ")}\n `,
238
- leading: true
236
+ type: "Block",
237
+ value: `*\n * ${commentLines.join("\n * ")}\n `
239
238
  };
240
239
  addComment(node, comment);
241
240
  }
242
241
  function addComment(node, comment) {
243
- node.comments ??= [];
244
- const found = node.comments.find((n) => n.type === "CommentBlock" && n.value === comment.value);
245
- if (!found) node.comments.push(comment);
242
+ node.leadingComments ??= [];
243
+ const found = node.leadingComments.find((n) => n.type === "Block" && n.value === comment.value);
244
+ if (!found) node.leadingComments.push(comment);
246
245
  }
247
246
  function typeAnnotateExpression(node, type) {
248
247
  const expression = {
@@ -286,8 +285,8 @@ function createLiteral(value = null) {
286
285
  return literal;
287
286
  }
288
287
  function areNodesEqual(ast1, ast2) {
289
- const ast1Clone = stripAst(decircular(ast1), "loc");
290
- const ast2Clone = stripAst(decircular(ast2), "loc");
288
+ const ast1Clone = stripAst(decircular(ast1), ["loc", "raw"]);
289
+ const ast2Clone = stripAst(decircular(ast2), ["loc", "raw"]);
291
290
  return serializeScript(ast1Clone) === serializeScript(ast2Clone);
292
291
  }
293
292
  function blockStatement() {
@@ -305,17 +304,20 @@ function expressionStatement(expression) {
305
304
  return statement;
306
305
  }
307
306
  function addFromString(ast, value) {
308
- const program = parseScript$1(dedent_default(value));
307
+ const program = parseScript(dedent_default(value));
309
308
  for (const childNode of program.body) ast.body.push(childNode);
310
309
  }
311
310
  function expressionFromString(value) {
312
- const program = parseScript$1(dedent_default(value));
311
+ const program = parseScript(dedent_default(value));
313
312
  const statement = program.body[0];
314
313
  if (statement.type !== "ExpressionStatement") throw new Error("value passed was not an expression");
315
314
  return statement.expression;
316
315
  }
317
316
  function statementFromString(value) {
318
- const program = parseScript$1(dedent_default(value));
317
+ return fromString(value);
318
+ }
319
+ function fromString(value) {
320
+ const program = parseScript(dedent_default(value));
319
321
  const statement = program.body[0];
320
322
  return statement;
321
323
  }
@@ -324,7 +326,7 @@ function addStatement(ast, statement) {
324
326
  }
325
327
  function hasNode(ast, nodeToMatch) {
326
328
  let found = false;
327
- walk_exports.walk(ast, {}, { _(node, { next, stop }) {
329
+ walk_exports.walk(ast, null, { _(node, { next, stop }) {
328
330
  if (node.type === nodeToMatch.type) {
329
331
  found = areNodesEqual(node, nodeToMatch);
330
332
  if (found) stop();
@@ -360,11 +362,11 @@ function unshift(ast, data) {
360
362
  }
361
363
  function insertElement(ast, data, insertEnd) {
362
364
  if (typeof data === "string") {
363
- const existingLiterals = ast.elements.filter((x) => x?.type === "StringLiteral");
365
+ const existingLiterals = ast.elements.filter((x) => x !== null && x.type === "Literal");
364
366
  let literal = existingLiterals.find((x) => x.value === data);
365
367
  if (!literal) {
366
368
  literal = {
367
- type: "StringLiteral",
369
+ type: "Literal",
368
370
  value: data
369
371
  };
370
372
  if (insertEnd) ast.elements.push(literal);
@@ -372,7 +374,7 @@ else ast.elements.unshift(literal);
372
374
  }
373
375
  } else {
374
376
  const elements = ast.elements;
375
- const anyNodeEquals = elements.some((node) => areNodesEqual(data, node));
377
+ const anyNodeEquals = elements.some((node) => node && areNodesEqual(data, node));
376
378
  if (!anyNodeEquals) if (insertEnd) ast.elements.push(data);
377
379
  else ast.elements.unshift(data);
378
380
  }
@@ -389,25 +391,28 @@ __export(object_exports, {
389
391
  });
390
392
  function property(ast, name, fallback) {
391
393
  const objectExpression = ast;
392
- const properties$1 = objectExpression.properties.filter((x) => x.type == "ObjectProperty");
393
- let property$1 = properties$1.find((x) => x.key.name == name);
394
+ const properties$1 = objectExpression.properties.filter((x) => x.type === "Property");
395
+ let property$1 = properties$1.find((x) => x.key.name === name);
394
396
  let propertyValue;
395
397
  if (property$1) propertyValue = property$1.value;
396
398
  else {
397
399
  let isShorthand = false;
398
- if (fallback.type == "Identifier") {
400
+ if (fallback.type === "Identifier") {
399
401
  const identifier$1 = fallback;
400
- isShorthand = identifier$1.name == name;
402
+ isShorthand = identifier$1.name === name;
401
403
  }
402
404
  propertyValue = fallback;
403
405
  property$1 = {
404
- type: "ObjectProperty",
406
+ type: "Property",
405
407
  shorthand: isShorthand,
406
408
  key: {
407
409
  type: "Identifier",
408
410
  name
409
411
  },
410
- value: propertyValue
412
+ value: propertyValue,
413
+ kind: "init",
414
+ computed: false,
415
+ method: false
411
416
  };
412
417
  objectExpression.properties.push(property$1);
413
418
  }
@@ -415,8 +420,8 @@ else {
415
420
  }
416
421
  function overrideProperty(ast, name, value) {
417
422
  const objectExpression = ast;
418
- const properties$1 = objectExpression.properties.filter((x) => x.type == "ObjectProperty");
419
- const prop = properties$1.find((x) => x.key.name == name);
423
+ const properties$1 = objectExpression.properties.filter((x) => x.type === "Property");
424
+ const prop = properties$1.find((x) => x.key.name === name);
420
425
  if (!prop) return property(ast, name, value);
421
426
  prop.value = value;
422
427
  return value;
@@ -434,7 +439,7 @@ function properties(ast, obj) {
434
439
  }
435
440
  }
436
441
  function removeProperty(ast, property$1) {
437
- const properties$1 = ast.properties.filter((x) => x.type === "ObjectProperty");
442
+ const properties$1 = ast.properties.filter((x) => x.type === "Property");
438
443
  const propIdx = properties$1.findIndex((x) => x.key.name === property$1);
439
444
  if (propIdx !== -1) ast.properties.splice(propIdx, 1);
440
445
  }
@@ -467,7 +472,8 @@ function call(name, args) {
467
472
  type: "Identifier",
468
473
  name
469
474
  },
470
- arguments: []
475
+ arguments: [],
476
+ optional: false
471
477
  };
472
478
  for (const argument of args) callExpression.arguments.push({
473
479
  type: "Literal",
@@ -482,7 +488,8 @@ function callByIdentifier(name, args) {
482
488
  type: "Identifier",
483
489
  name
484
490
  },
485
- arguments: []
491
+ arguments: [],
492
+ optional: false
486
493
  };
487
494
  for (const argument of args) {
488
495
  const identifier$1 = {
@@ -498,7 +505,8 @@ function arrowFunction(async, body) {
498
505
  type: "ArrowFunctionExpression",
499
506
  async,
500
507
  body,
501
- params: []
508
+ params: [],
509
+ expression: body.type !== "BlockStatement"
502
510
  };
503
511
  return arrowFunction$1;
504
512
  }
@@ -521,13 +529,15 @@ function addEmpty(ast, importFrom) {
521
529
  type: "Literal",
522
530
  value: importFrom
523
531
  },
524
- specifiers: []
532
+ specifiers: [],
533
+ importKind: "value"
525
534
  };
526
535
  addImportIfNecessary(ast, expectedImportDeclaration);
527
536
  }
528
537
  function addNamespace(ast, importFrom, importAs) {
529
538
  const expectedImportDeclaration = {
530
539
  type: "ImportDeclaration",
540
+ importKind: "value",
531
541
  source: {
532
542
  type: "Literal",
533
543
  value: importFrom
@@ -555,7 +565,8 @@ function addDefault(ast, importFrom, importAs) {
555
565
  type: "Identifier",
556
566
  name: importAs
557
567
  }
558
- }]
568
+ }],
569
+ importKind: "value"
559
570
  };
560
571
  addImportIfNecessary(ast, expectedImportDeclaration);
561
572
  }
@@ -575,12 +586,13 @@ function addNamed(ast, importFrom, exportedAsImportAs, isType = false) {
575
586
  return specifier;
576
587
  });
577
588
  let importDecl;
578
- walk_exports.walk(ast, {}, { ImportDeclaration(node) {
589
+ walk_exports.walk(ast, null, { ImportDeclaration(node) {
579
590
  if (node.source.value === importFrom && node.specifiers) importDecl = node;
580
591
  } });
581
592
  if (importDecl) {
582
593
  specifiers.forEach((specifierToAdd) => {
583
- if (importDecl?.specifiers?.every((existingSpecifier) => existingSpecifier.type === "ImportSpecifier" && existingSpecifier.local?.name !== specifierToAdd.local?.name && existingSpecifier.imported.name !== specifierToAdd.imported.name)) importDecl?.specifiers?.push(specifierToAdd);
594
+ const sourceExists = importDecl?.specifiers?.every((existingSpecifier) => existingSpecifier.type === "ImportSpecifier" && existingSpecifier.local?.name !== specifierToAdd.local?.name && existingSpecifier.imported.type === "Identifier" && specifierToAdd.imported.type === "Identifier" && existingSpecifier.imported.name !== specifierToAdd.imported.name);
595
+ if (sourceExists) importDecl?.specifiers?.push(specifierToAdd);
584
596
  });
585
597
  return;
586
598
  }
@@ -591,12 +603,12 @@ function addNamed(ast, importFrom, exportedAsImportAs, isType = false) {
591
603
  value: importFrom
592
604
  },
593
605
  specifiers,
594
- importKind: isType ? "type" : undefined
606
+ importKind: isType ? "type" : "value"
595
607
  };
596
608
  ast.body.unshift(expectedImportDeclaration);
597
609
  }
598
610
  function addImportIfNecessary(ast, expectedImportDeclaration) {
599
- const importDeclarations = ast.body.filter((x) => x.type == "ImportDeclaration");
611
+ const importDeclarations = ast.body.filter((x) => x.type === "ImportDeclaration");
600
612
  const importDeclaration = importDeclarations.find((x) => areNodesEqual(x, expectedImportDeclaration));
601
613
  if (!importDeclaration) ast.body.unshift(expectedImportDeclaration);
602
614
  }
@@ -607,11 +619,11 @@ __export(variables_exports, {
607
619
  typeAnnotateDeclarator: () => typeAnnotateDeclarator
608
620
  });
609
621
  function declaration(ast, kind, name, value) {
610
- const declarations = ast.type == "Program" ? ast.body.filter((x) => x.type == "VariableDeclaration") : [ast];
622
+ const declarations = ast.type === "Program" ? ast.body.filter((x) => x.type === "VariableDeclaration") : [ast];
611
623
  let declaration$1 = declarations.find((x) => {
612
624
  const declarator = x.declarations[0];
613
625
  const identifier$1 = declarator.id;
614
- return identifier$1.name == name;
626
+ return identifier$1.name === name;
615
627
  });
616
628
  if (declaration$1) return declaration$1;
617
629
  declaration$1 = {
@@ -691,17 +703,18 @@ function defaultExport(ast, fallbackDeclaration) {
691
703
  };
692
704
  }
693
705
  function namedExport(ast, name, fallback) {
694
- const namedExports = ast.body.filter((x) => x.type == "ExportNamedDeclaration");
706
+ const namedExports = ast.body.filter((x) => x.type === "ExportNamedDeclaration");
695
707
  let namedExport$1 = namedExports.find((x) => {
696
708
  const variableDeclaration = x.declaration;
697
709
  const variableDeclarator = variableDeclaration.declarations[0];
698
710
  const identifier$1 = variableDeclarator.id;
699
- return identifier$1.name == name;
711
+ return identifier$1.name === name;
700
712
  });
701
713
  if (namedExport$1) return namedExport$1;
702
714
  namedExport$1 = {
703
715
  type: "ExportNamedDeclaration",
704
- declaration: fallback
716
+ declaration: fallback,
717
+ specifiers: []
705
718
  };
706
719
  ast.body.push(namedExport$1);
707
720
  return namedExport$1;
@@ -714,13 +727,13 @@ __export(kit_exports, {
714
727
  function addGlobalAppInterface(ast, name) {
715
728
  let globalDecl = ast.body.filter((n) => n.type === "TSModuleDeclaration").find((m) => m.global && m.declare);
716
729
  if (!globalDecl) {
717
- globalDecl = statementFromString("declare global {}");
730
+ globalDecl = fromString("declare global {}");
718
731
  ast.body.push(globalDecl);
719
732
  }
720
733
  if (globalDecl.body?.type !== "TSModuleBlock") throw new Error("Unexpected body type of `declare global` in `src/app.d.ts`");
721
734
  let app;
722
735
  let interfaceNode;
723
- walk_exports.walk(globalDecl, {}, {
736
+ walk_exports.walk(globalDecl, null, {
724
737
  TSModuleDeclaration(node, { next }) {
725
738
  if (node.id.type === "Identifier" && node.id.name === "App") app = node;
726
739
  next();
@@ -730,12 +743,12 @@ function addGlobalAppInterface(ast, name) {
730
743
  }
731
744
  });
732
745
  if (!app) {
733
- app = statementFromString("namespace App {}");
746
+ app = fromString("namespace App {}");
734
747
  globalDecl.body.body.push(app);
735
748
  }
736
749
  if (app.body?.type !== "TSModuleBlock") throw new Error("Unexpected body type of `namespace App` in `src/app.d.ts`");
737
750
  if (!interfaceNode) {
738
- interfaceNode = statementFromString(`interface ${name} {}`);
751
+ interfaceNode = fromString(`interface ${name} {}`);
739
752
  app.body.body.push(interfaceNode);
740
753
  }
741
754
  return interfaceNode;
@@ -746,10 +759,10 @@ function addHooksHandle(ast, typescript, newHandleName, handleContent) {
746
759
  let handleName = "handle";
747
760
  let exportDecl;
748
761
  let originalHandleDecl;
749
- walk_exports.walk(ast, {}, { ExportNamedDeclaration(node) {
762
+ walk_exports.walk(ast, null, { ExportNamedDeclaration(node) {
750
763
  let maybeHandleDecl;
751
- const handleSpecifier = node.specifiers?.find((s) => s.exported.name === "handle");
752
- if (handleSpecifier) {
764
+ const handleSpecifier = node.specifiers?.find((s) => s.exported.type === "Identifier" && s.exported.name === "handle");
765
+ if (handleSpecifier && handleSpecifier.local.type === "Identifier" && handleSpecifier.exported.type === "Identifier") {
753
766
  isSpecifier = true;
754
767
  handleName = handleSpecifier.local?.name ?? handleSpecifier.exported.name;
755
768
  const handleFunc = ast.body.find((n) => isFunctionDeclaration(n, handleName));
@@ -978,7 +991,7 @@ function findRoot(cwd) {
978
991
  }
979
992
  function parseKitOptions(cwd) {
980
993
  const configSource = readFile(cwd, commonFilePaths.svelteConfig);
981
- const { ast } = parseScript(configSource);
994
+ const { ast } = parseScript$1(configSource);
982
995
  const defaultExport$1 = ast.body.find((s) => s.type === "ExportDefaultDeclaration");
983
996
  if (!defaultExport$1) throw Error("Missing default export in `svelte.config.js`");
984
997
  let objectExpression;