@powerlines/plugin-automd 0.1.313 → 0.1.314

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.
@@ -1,6 +1,6 @@
1
1
  const require_rolldown_runtime = require('../../../../../../_virtual/rolldown_runtime.cjs');
2
2
  const require_pathe_M_eThtNZ = require('../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs');
3
- const require_index = require('../../../../mlly@1.8.0/node_modules/mlly/dist/index.cjs');
3
+ const require_index = require('../../../../mlly@1.8.1/node_modules/mlly/dist/index.cjs');
4
4
  const require_magic_string_es = require('../../../../magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs');
5
5
  const require_index$1 = require('../../../../scule@1.3.0/node_modules/scule/dist/index.cjs');
6
6
  const require_index$2 = require('../../../../pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs');
@@ -1,5 +1,5 @@
1
1
  import { basename, extname, join, resolve } from "../../../../pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs";
2
- import { fileURLToPath, findExportNames, resolvePath } from "../../../../mlly@1.8.0/node_modules/mlly/dist/index.mjs";
2
+ import { fileURLToPath, findExportNames, resolvePath } from "../../../../mlly@1.8.1/node_modules/mlly/dist/index.mjs";
3
3
  import { MagicString } from "../../../../magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs";
4
4
  import { camelCase, titleCase } from "../../../../scule@1.3.0/node_modules/scule/dist/index.mjs";
5
5
  import { readPackageJSON } from "../../../../pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs";
@@ -16,7 +16,7 @@ let node_v8 = require("node:v8");
16
16
  node_v8 = require_rolldown_runtime.__toESM(node_v8);
17
17
  let node_util = require("node:util");
18
18
 
19
- //#region ../../node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs
19
+ //#region ../../node_modules/.pnpm/mlly@1.8.1/node_modules/mlly/dist/index.mjs
20
20
  const BUILTIN_MODULES = new Set(node_module.builtinModules);
21
21
  function normalizeSlash(path$1) {
22
22
  return path$1.replace(/\\/g, "/");
@@ -83,7 +83,7 @@ codes.ERR_INVALID_ARG_TYPE = createError(
83
83
  * @param {unknown} actual
84
84
  */
85
85
  (name, expected, actual) => {
86
- (0, node_assert.default)(typeof name === "string", "'name' must be a string");
86
+ node_assert.default.ok(typeof name === "string", "'name' must be a string");
87
87
  if (!Array.isArray(expected)) expected = [expected];
88
88
  let message = "The ";
89
89
  if (name.endsWith(" argument")) message += `${name} `;
@@ -99,10 +99,10 @@ codes.ERR_INVALID_ARG_TYPE = createError(
99
99
  /** @type {Array<string>} */
100
100
  const other = [];
101
101
  for (const value of expected) {
102
- (0, node_assert.default)(typeof value === "string", "All expected entries have to be of type string");
102
+ node_assert.default.ok(typeof value === "string", "All expected entries have to be of type string");
103
103
  if (kTypes.has(value)) types.push(value.toLowerCase());
104
104
  else if (classRegExp.exec(value) === null) {
105
- (0, node_assert.default)(value !== "object", "The value \"object\" should be written as \"Object\"");
105
+ node_assert.default.ok(value !== "object", "The value \"object\" should be written as \"Object\"");
106
106
  other.push(value);
107
107
  } else instances.push(value);
108
108
  }
@@ -167,7 +167,7 @@ codes.ERR_INVALID_PACKAGE_TARGET = createError(
167
167
  (packagePath, key, target, isImport = false, base = void 0) => {
168
168
  const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
169
169
  if (key === ".") {
170
- (0, node_assert.default)(isImport === false);
170
+ node_assert.default.ok(isImport === false);
171
171
  return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
172
172
  }
173
173
  return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? "; targets must start with \"./\"" : ""}`;
@@ -334,15 +334,15 @@ const captureLargerStackTrace = hideStackFrames(
334
334
  */
335
335
  function getMessage(key, parameters, self) {
336
336
  const message = messages.get(key);
337
- (0, node_assert.default)(message !== void 0, "expected `message` to be found");
337
+ node_assert.default.ok(message !== void 0, "expected `message` to be found");
338
338
  if (typeof message === "function") {
339
- (0, node_assert.default)(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
339
+ node_assert.default.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`);
340
340
  return Reflect.apply(message, self, parameters);
341
341
  }
342
342
  const regex = /%[dfijoOs]/g;
343
343
  let expectedLength = 0;
344
344
  while (regex.exec(message) !== null) expectedLength++;
345
- (0, node_assert.default)(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
345
+ node_assert.default.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`);
346
346
  if (parameters.length === 0) return message;
347
347
  parameters.unshift(message);
348
348
  return Reflect.apply(node_util.format, null, parameters);
@@ -543,6 +543,21 @@ function defaultGetFormatWithoutErrors(url, context) {
543
543
  if (!hasOwnProperty.call(protocolHandlers, protocol)) return null;
544
544
  return protocolHandlers[protocol](url, context, true) || null;
545
545
  }
546
+ const DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
547
+ const DEFAULT_CONDITIONS_SET$1 = new Set(DEFAULT_CONDITIONS);
548
+ /**
549
+ * Returns the default conditions for ES module loading, as a Set.
550
+ */
551
+ function getDefaultConditionsSet() {
552
+ return DEFAULT_CONDITIONS_SET$1;
553
+ }
554
+ /**
555
+ * @param {Array<string>} [conditions]
556
+ * @returns {Set<string>}
557
+ */
558
+ function getConditionsSet(conditions) {
559
+ return getDefaultConditionsSet();
560
+ }
546
561
  const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
547
562
  const { ERR_INVALID_MODULE_SPECIFIER, ERR_INVALID_PACKAGE_CONFIG, ERR_INVALID_PACKAGE_TARGET, ERR_MODULE_NOT_FOUND, ERR_PACKAGE_IMPORT_NOT_DEFINED, ERR_PACKAGE_PATH_NOT_EXPORTED, ERR_UNSUPPORTED_DIR_IMPORT, ERR_UNSUPPORTED_RESOLVE_REQUEST } = codes;
548
563
  const own = {}.hasOwnProperty;
@@ -581,7 +596,7 @@ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
581
596
  if (node_process.default.noDeprecation) return;
582
597
  if (defaultGetFormatWithoutErrors(url, { parentURL: base.href }) !== "module") return;
583
598
  const urlPath = (0, node_url.fileURLToPath)(url.href);
584
- const packagePath = (0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl));
599
+ const packagePath = (0, node_url.fileURLToPath)(new URL(".", packageJsonUrl));
585
600
  const basePath = (0, node_url.fileURLToPath)(base);
586
601
  if (!main) node_process.default.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
587
602
  else if (node_path.default.resolve(packagePath, main) !== urlPath) node_process.default.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
@@ -621,7 +636,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
621
636
  /** @type {URL | undefined} */
622
637
  let guess;
623
638
  if (packageConfig.main !== void 0) {
624
- guess = new node_url.URL(packageConfig.main, packageJsonUrl);
639
+ guess = new URL(packageConfig.main, packageJsonUrl);
625
640
  if (fileExists(guess)) return guess;
626
641
  const tries$1 = [
627
642
  `./${packageConfig.main}.js`,
@@ -633,7 +648,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
633
648
  ];
634
649
  let i$1 = -1;
635
650
  while (++i$1 < tries$1.length) {
636
- guess = new node_url.URL(tries$1[i$1], packageJsonUrl);
651
+ guess = new URL(tries$1[i$1], packageJsonUrl);
637
652
  if (fileExists(guess)) break;
638
653
  guess = void 0;
639
654
  }
@@ -649,7 +664,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
649
664
  ];
650
665
  let i = -1;
651
666
  while (++i < tries.length) {
652
- guess = new node_url.URL(tries[i], packageJsonUrl);
667
+ guess = new URL(tries[i], packageJsonUrl);
653
668
  if (fileExists(guess)) break;
654
669
  guess = void 0;
655
670
  }
@@ -657,7 +672,7 @@ function legacyMainResolve(packageJsonUrl, packageConfig, base) {
657
672
  emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
658
673
  return guess;
659
674
  }
660
- throw new ERR_MODULE_NOT_FOUND((0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
675
+ throw new ERR_MODULE_NOT_FOUND((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
661
676
  }
662
677
  /**
663
678
  * @param {URL} resolved
@@ -704,7 +719,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
704
719
  * @returns {Error}
705
720
  */
706
721
  function importNotDefined(specifier, packageJsonUrl, base) {
707
- return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
722
+ return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && (0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), (0, node_url.fileURLToPath)(base));
708
723
  }
709
724
  /**
710
725
  * @param {string} subpath
@@ -713,7 +728,7 @@ function importNotDefined(specifier, packageJsonUrl, base) {
713
728
  * @returns {Error}
714
729
  */
715
730
  function exportsNotFound(subpath, packageJsonUrl, base) {
716
- return new ERR_PACKAGE_PATH_NOT_EXPORTED((0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), subpath, base && (0, node_url.fileURLToPath)(base));
731
+ return new ERR_PACKAGE_PATH_NOT_EXPORTED((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), subpath, base && (0, node_url.fileURLToPath)(base));
717
732
  }
718
733
  /**
719
734
  * @param {string} request
@@ -736,7 +751,7 @@ function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
736
751
  */
737
752
  function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
738
753
  target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
739
- return new ERR_INVALID_PACKAGE_TARGET((0, node_url.fileURLToPath)(new node_url.URL(".", packageJsonUrl)), subpath, target, internal, base && (0, node_url.fileURLToPath)(base));
754
+ return new ERR_INVALID_PACKAGE_TARGET((0, node_url.fileURLToPath)(new URL(".", packageJsonUrl)), subpath, target, internal, base && (0, node_url.fileURLToPath)(base));
740
755
  }
741
756
  /**
742
757
  * @param {string} target
@@ -756,7 +771,7 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
756
771
  if (internal && !target.startsWith("../") && !target.startsWith("/")) {
757
772
  let isURL = false;
758
773
  try {
759
- new node_url.URL(target);
774
+ new URL(target);
760
775
  isURL = true;
761
776
  } catch {}
762
777
  if (!isURL) return packageResolve(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath, packageJsonUrl, conditions);
@@ -769,9 +784,9 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
769
784
  emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, true);
770
785
  }
771
786
  } else throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
772
- const resolved = new node_url.URL(target, packageJsonUrl);
787
+ const resolved = new URL(target, packageJsonUrl);
773
788
  const resolvedPath = resolved.pathname;
774
- const packagePath = new node_url.URL(".", packageJsonUrl).pathname;
789
+ const packagePath = new URL(".", packageJsonUrl).pathname;
775
790
  if (!resolvedPath.startsWith(packagePath)) throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
776
791
  if (subpath === "") return resolved;
777
792
  if (invalidSegmentRegEx.exec(subpath) !== null) {
@@ -780,8 +795,8 @@ function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base
780
795
  if (!isPathMap) emitInvalidSegmentDeprecation(pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target, request, match, packageJsonUrl, internal, base, false);
781
796
  } else throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
782
797
  }
783
- if (pattern) return new node_url.URL(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
784
- return new node_url.URL(subpath, resolved);
798
+ if (pattern) return new URL(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
799
+ return new URL(subpath, resolved);
785
800
  }
786
801
  /**
787
802
  * @param {string} key
@@ -1019,7 +1034,7 @@ function parsePackageName(specifier, base) {
1019
1034
  * @returns {URL}
1020
1035
  */
1021
1036
  function packageResolve(specifier, base, conditions) {
1022
- if (node_module.builtinModules.includes(specifier)) return new node_url.URL("node:" + specifier);
1037
+ if (node_module.builtinModules.includes(specifier)) return new URL("node:" + specifier);
1023
1038
  const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
1024
1039
  const packageConfig = getPackageScopeConfig(base);
1025
1040
  /* c8 ignore next 16 */
@@ -1027,7 +1042,7 @@ function packageResolve(specifier, base, conditions) {
1027
1042
  const packageJsonUrl$1 = (0, node_url.pathToFileURL)(packageConfig.pjsonPath);
1028
1043
  if (packageConfig.name === packageName && packageConfig.exports !== void 0 && packageConfig.exports !== null) return packageExportsResolve(packageJsonUrl$1, packageSubpath, packageConfig, base, conditions);
1029
1044
  }
1030
- let packageJsonUrl = new node_url.URL("./node_modules/" + packageName + "/package.json", base);
1045
+ let packageJsonUrl = new URL("./node_modules/" + packageName + "/package.json", base);
1031
1046
  let packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1032
1047
  /** @type {string} */
1033
1048
  let lastPath;
@@ -1035,7 +1050,7 @@ function packageResolve(specifier, base, conditions) {
1035
1050
  const stat = tryStatSync(packageJsonPath.slice(0, -13));
1036
1051
  if (!stat || !stat.isDirectory()) {
1037
1052
  lastPath = packageJsonPath;
1038
- packageJsonUrl = new node_url.URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
1053
+ packageJsonUrl = new URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
1039
1054
  packageJsonPath = (0, node_url.fileURLToPath)(packageJsonUrl);
1040
1055
  continue;
1041
1056
  }
@@ -1045,7 +1060,7 @@ function packageResolve(specifier, base, conditions) {
1045
1060
  });
1046
1061
  if (packageConfig$1.exports !== void 0 && packageConfig$1.exports !== null) return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig$1, base, conditions);
1047
1062
  if (packageSubpath === ".") return legacyMainResolve(packageJsonUrl, packageConfig$1, base);
1048
- return new node_url.URL(packageSubpath, packageJsonUrl);
1063
+ return new URL(packageSubpath, packageJsonUrl);
1049
1064
  } while (packageJsonPath.length !== lastPath.length);
1050
1065
  throw new ERR_MODULE_NOT_FOUND(packageName, (0, node_url.fileURLToPath)(base), false);
1051
1066
  }
@@ -1085,12 +1100,13 @@ function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
1085
1100
  * A URL object to the found thing.
1086
1101
  */
1087
1102
  function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1103
+ if (conditions === void 0) conditions = getConditionsSet();
1088
1104
  const protocol = base.protocol;
1089
1105
  const isRemote = protocol === "data:" || protocol === "http:" || protocol === "https:";
1090
1106
  /** @type {URL | undefined} */
1091
1107
  let resolved;
1092
1108
  if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) try {
1093
- resolved = new node_url.URL(specifier, base);
1109
+ resolved = new URL(specifier, base);
1094
1110
  } catch (error_) {
1095
1111
  const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
1096
1112
  error.cause = error_;
@@ -1098,7 +1114,7 @@ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1098
1114
  }
1099
1115
  else if (protocol === "file:" && specifier[0] === "#") resolved = packageImportsResolve(specifier, base, conditions);
1100
1116
  else try {
1101
- resolved = new node_url.URL(specifier);
1117
+ resolved = new URL(specifier);
1102
1118
  } catch (error_) {
1103
1119
  if (isRemote && !node_module.builtinModules.includes(specifier)) {
1104
1120
  const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
@@ -1107,7 +1123,7 @@ function moduleResolve(specifier, base, conditions, preserveSymlinks) {
1107
1123
  }
1108
1124
  resolved = packageResolve(specifier, base, conditions);
1109
1125
  }
1110
- (0, node_assert.default)(resolved !== void 0, "expected to be defined");
1126
+ node_assert.default.ok(resolved !== void 0, "expected to be defined");
1111
1127
  if (resolved.protocol !== "file:") return resolved;
1112
1128
  return finalizeResolution(resolved, base);
1113
1129
  }
@@ -1200,14 +1216,56 @@ const EXPORT_STAR_RE = /\bexport\s*\*(?:\s*as\s+(?<name>[\w$]+)\s+)?\s*(?:\s*fro
1200
1216
  const EXPORT_DEFAULT_RE = /\bexport\s+default\s+(async function|function|class|true|false|\W|\d)|\bexport\s+default\s+(?<defaultName>.*)/g;
1201
1217
  const EXPORT_DEFAULT_CLASS_RE = /\bexport\s+default\s+(?<declaration>class)\s+(?<name>[\w$]+)/g;
1202
1218
  const TYPE_RE = /^\s*?type\s/;
1219
+ function _extractExtraNames(extraNamesStr) {
1220
+ const names = [];
1221
+ let depth = 0;
1222
+ let angleDepth = 0;
1223
+ let inString = false;
1224
+ let inTypeAnnotation = false;
1225
+ for (let i = 0; i < extraNamesStr.length; i++) {
1226
+ const char = extraNamesStr[i];
1227
+ if (inString) {
1228
+ if (char === inString) {
1229
+ let backslashCount = 0;
1230
+ for (let j = i - 1; j >= 0 && extraNamesStr[j] === "\\"; j--) backslashCount++;
1231
+ if (backslashCount % 2 === 0) inString = false;
1232
+ }
1233
+ continue;
1234
+ }
1235
+ if (char === "\"" || char === "'" || char === "`") {
1236
+ inString = char;
1237
+ continue;
1238
+ }
1239
+ if (char === ":" && depth === 0 && angleDepth === 0) {
1240
+ inTypeAnnotation = true;
1241
+ continue;
1242
+ }
1243
+ if (char === "=" && extraNamesStr[i + 1] !== ">" && depth === 0 && angleDepth === 0) inTypeAnnotation = false;
1244
+ if (inTypeAnnotation && char === "<") {
1245
+ angleDepth++;
1246
+ continue;
1247
+ }
1248
+ if (inTypeAnnotation && char === ">" && angleDepth > 0) {
1249
+ angleDepth--;
1250
+ continue;
1251
+ }
1252
+ if (char === "(" || char === "[" || char === "{") depth++;
1253
+ else if (char === ")" || char === "]" || char === "}") depth--;
1254
+ if (char === "," && depth === 0 && angleDepth === 0) {
1255
+ const match = extraNamesStr.slice(i + 1).match(/^\s*([\w$]+)/);
1256
+ if (match) names.push(match[1]);
1257
+ }
1258
+ }
1259
+ return names;
1260
+ }
1203
1261
  function findExports(code) {
1204
1262
  const declaredExports = matchAll(EXPORT_DECAL_RE, code, { type: "declaration" });
1205
1263
  for (const declaredExport of declaredExports) {
1206
1264
  if (/^export\s+(?:async\s+)?function/.test(declaredExport.code)) continue;
1207
1265
  const extraNamesStr = declaredExport.extraNames;
1208
1266
  if (extraNamesStr) {
1209
- const extraNames = matchAll(/({.*?})|(\[.*?])|(,\s*(?<name>\w+))/g, extraNamesStr, {}).map((m) => m.name).filter(Boolean);
1210
- declaredExport.names = [declaredExport.name, ...extraNames];
1267
+ const extraNames = _extractExtraNames(extraNamesStr);
1268
+ if (extraNames.length > 0) declaredExport.names = [declaredExport.name, ...extraNames];
1211
1269
  }
1212
1270
  delete declaredExport.extraNames;
1213
1271
  }