@staticbolt/core 1.0.0-beta.12 → 1.0.0-beta.14

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,16 +1,18 @@
1
- import { A as isStyleMetadata, C as filterScriptMetadata, D as isMarkdownMetadata, E as isHtmlMetadata, F as METADATA_TYPES, H as isValidRelativePath, I as Resolver, L as readJsonFile, M as isTextAssetMetadata, N as isWebManifestMetadata, O as isPackageMetadata, P as isScriptType, S as traverse, T as isBinaryAssetMetadata, U as splitHtmlLink, V as valueOrError, W as DependencyTracker, _ as mergeMaps, b as printFmtError, c as downloadContent, d as hashContent, f as humanReadableBytes, h as isURL, j as isSvgMetadata, k as isScriptMetadata, l as escapeHtml, n as bytesToKB, s as cloneObject, w as filterStyleMetadata, x as generator, y as PrintFormattedError, z as safeReadFileSync } from "../utilities-Bu5rdDC9.mjs";
2
- import { _ as resolve, a as basename, c as isAbsolute, d as matchPath, f as normalize, g as replaceExtension, h as relative, i as createLog, l as isSubpath, n as CUSTOM_ATTRIBUTES, o as dirname, p as parse$2, r as Log, s as extname, t as CONFIG_FILE_NAME, u as join } from "../common-Bkh8-tjA.mjs";
1
+ import { A as isTextAssetMetadata, C as isBinaryAssetMetadata, D as isScriptMetadata, E as isPackageMetadata, F as readJsonFile, H as splitHtmlLink, L as safeReadFileSync, M as isScriptType, N as METADATA_TYPES, O as isStyleMetadata, P as Resolver, S as filterStyleMetadata, T as isMarkdownMetadata, U as DependencyTracker, V as isValidRelativePath, _ as mergeMaps, b as printFmtError, c as downloadContent, d as hashContent, f as humanReadableBytes, h as isURL, j as isWebManifestMetadata, k as isSvgMetadata, l as escapeHtml, n as bytesToKB, s as cloneObject, w as isHtmlMetadata, x as filterScriptMetadata, y as PrintFormattedError, z as valueOrError } from "../utilities-ubLQ-AAc.mjs";
2
+ import { _ as resolve, a as basename, c as isAbsolute, d as join, f as normalize, g as replaceExtension, h as relative, i as createLog, l as isPathMatch, n as CUSTOM_ATTRIBUTES, o as dirname, p as parse$2, r as Log, s as extname, t as CONFIG_FILE_NAME, u as isSubpath } from "../common-CmCjfyAf.mjs";
3
3
  import { createRequire } from "node:module";
4
4
  import { copyFileSync, cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, rmdirSync, unlinkSync, writeFileSync } from "node:fs";
5
5
  import nodePath from "node:path";
6
- import c from "chalk";
6
+ import chalk from "chalk";
7
7
  import json5 from "json5";
8
+ import _generator from "@babel/generator";
8
9
  import { HTMLElement, NodeType, parse } from "@staticbolt/node-html-parser";
9
10
  import postcss from "postcss";
10
11
  import { common, createEmphasize } from "emphasize";
11
12
  import { globSync } from "glob";
12
13
  import { minify_sync } from "terser";
13
14
  import * as esbuild from "esbuild";
15
+ import _traverse from "@babel/traverse";
14
16
  import * as t from "@babel/types";
15
17
  import sharp from "sharp";
16
18
  import { generateSW } from "workbox-build";
@@ -28,7 +30,6 @@ import rehypeExternalLinks from "rehype-external-links";
28
30
  import rehypeSlug from "rehype-slug";
29
31
  import rehypeStringify from "rehype-stringify";
30
32
  import { remark } from "remark";
31
- import remarkBreaks from "remark-breaks";
32
33
  import remarkFrontmatter from "remark-frontmatter";
33
34
  import remarkGfm from "remark-gfm";
34
35
  import remarkRehype from "remark-rehype";
@@ -51,8 +52,8 @@ import ttf2woff2 from "ttf2woff2";
51
52
  import * as z from "zod";
52
53
  import * as fontKit from "fontkit";
53
54
 
54
- //#region src/helpers/find-deps.ts
55
- var DepsFinder = class {
55
+ //#region src/helpers/find-dependencies.ts
56
+ var DependenciesFinder = class {
56
57
  #depsMap = /* @__PURE__ */ new Map();
57
58
  #visiting = /* @__PURE__ */ new Set();
58
59
  #app;
@@ -69,18 +70,22 @@ var DepsFinder = class {
69
70
  this.#visiting.add(metadataItem.filePath);
70
71
  const usedFiles = /* @__PURE__ */ new Set();
71
72
  if (isPackageMetadata(metadataItem)) await this.#collectPackageMetadataDeps(metadataItem, usedFiles);
72
- else for (const { source } of await this.#app.requestSources(metadataItem)) await this.#collect(source, metadataItem.filePath, usedFiles);
73
+ else {
74
+ const sources = await this.#app.requestSources(metadataItem);
75
+ for (const { source } of sources) await this.#collect(source, metadataItem.filePath, usedFiles);
76
+ }
73
77
  this.#visiting.delete(metadataItem.filePath);
74
78
  this.#depsMap.set(metadataItem.filePath, usedFiles);
75
79
  return usedFiles;
76
80
  }
77
81
  async #collectPackageMetadataDeps(metadataItem, usedFiles) {
78
- for (const dep of metadataItem.directDependencies) {
79
- const absPath = join(this.#root, dep);
82
+ for (const dependency of metadataItem.directDependencies) {
83
+ const absPath = join(this.#root, dependency);
80
84
  usedFiles.add(absPath);
81
- const depMetadata = this.#app.findMetadata({ filePath: dep });
82
- if (!depMetadata) continue;
83
- for (const subDep of await this.findDeps(depMetadata)) usedFiles.add(subDep);
85
+ const dependencyMetadata = this.#app.findMetadata({ filePath: dependency });
86
+ if (!dependencyMetadata) continue;
87
+ const subDependencies = await this.findDeps(dependencyMetadata);
88
+ for (const subDependency of subDependencies) usedFiles.add(subDependency);
84
89
  }
85
90
  }
86
91
  async #collect(source, fromFile, usedFiles) {
@@ -89,9 +94,10 @@ var DepsFinder = class {
89
94
  if (extname(absPath) === ".html") return;
90
95
  usedFiles.add(absPath);
91
96
  const relativePath = relative(this.#root, absPath);
92
- const depMetadata = this.#app.findMetadata({ filePath: relativePath });
93
- if (!depMetadata) return;
94
- for (const dep of await this.findDeps(depMetadata)) usedFiles.add(dep);
97
+ const dependencyMetadata = this.#app.findMetadata({ filePath: relativePath });
98
+ if (!dependencyMetadata) return;
99
+ const dependencies = await this.findDeps(dependencyMetadata);
100
+ for (const dependency of dependencies) usedFiles.add(dependency);
95
101
  }
96
102
  /** Resolves a source path relative to its containing file and the output directory. */
97
103
  #resolveSource(source, filePath) {
@@ -110,7 +116,7 @@ var DepsFinder = class {
110
116
  //#endregion
111
117
  //#region src/plugins/analyze-output/analyze-output-plugin.ts
112
118
  function analyzeOutputPlugin(options = {}) {
113
- const removeUnused = options.deleteUnused ?? false;
119
+ const isRemoveUnused = options.deleteUnused ?? false;
114
120
  const exclude = options.exclude ?? [
115
121
  "robots.txt",
116
122
  "sitemap.xml",
@@ -118,12 +124,12 @@ function analyzeOutputPlugin(options = {}) {
118
124
  "workbox-*.js"
119
125
  ];
120
126
  const maxFileSize = options.maxFileSize ?? { ".js": 150 };
121
- const logUnusedFiles = options.logUnusedFiles ?? true;
127
+ const isLogUnusedFiles = options.logUnusedFiles ?? true;
122
128
  return {
123
129
  name: "analyze-output",
124
130
  async postBuild() {
125
131
  if (!this.production) return;
126
- const depsFinder = new DepsFinder(this, this.outdir);
132
+ const dependenciesFinder = new DependenciesFinder(this, this.outdir);
127
133
  const availableFiles = new Set(globSync(this.outdir + "/**/*", {
128
134
  ignore: "**/*.html",
129
135
  nodir: true
@@ -131,29 +137,29 @@ function analyzeOutputPlugin(options = {}) {
131
137
  const htmlEntryPoints = this.metadataList.filter((meta) => isHtmlMetadata(meta));
132
138
  const usedFiles = /* @__PURE__ */ new Set();
133
139
  for (const metadataItem of htmlEntryPoints) {
134
- const deps = await depsFinder.findDeps(metadataItem);
135
- for (const dep of deps) usedFiles.add(dep);
140
+ const dependencies = await dependenciesFinder.findDeps(metadataItem);
141
+ for (const dependency of dependencies) usedFiles.add(dependency);
136
142
  }
137
143
  const missingFiles = usedFiles.difference(availableFiles);
138
- let missingFilesLog = c.bold("The following files are missing:");
139
- for (const missing of missingFiles) missingFilesLog += "\n" + c.red("File not found: ") + c.yellow(relative(this.root, missing));
144
+ let missingFilesLog = chalk.bold("The following files are missing:");
145
+ for (const missing of missingFiles) missingFilesLog += "\n" + chalk.red("File not found: ") + chalk.yellow(relative(this.root, missing));
140
146
  if (missingFiles.size > 0) this.log.error(missingFilesLog);
141
147
  const unusedFiles = availableFiles.difference(usedFiles);
142
148
  const unusedFilesLog = [];
143
149
  for (const unused of unusedFiles) {
144
150
  if (extname(unused) === ".html") continue;
145
151
  const relativePath = relative(this.outdir, unused);
146
- if (matchPath(relativePath, {
152
+ if (isPathMatch(relativePath, {
147
153
  include: exclude,
148
154
  root: this.outdir
149
155
  })) continue;
150
- if (removeUnused) unlinkSync(unused);
151
- unusedFilesLog.push(c.yellow(join(basename(this.outdir), relativePath)));
156
+ if (isRemoveUnused) unlinkSync(unused);
157
+ unusedFilesLog.push(chalk.yellow(join(basename(this.outdir), relativePath)));
152
158
  }
153
- const logTitle = removeUnused ? c.bold(c.red("Removed"), "(" + c.yellow(unusedFilesLog.length) + ")", "unused files from the output directory") : c.bold("Found", "(" + c.yellow(unusedFilesLog.length) + ")", "unused files");
154
- if (unusedFilesLog.length > 0) this.log.warn(logTitle + (logUnusedFiles ? "\n" + unusedFilesLog.join("\n") : ""));
155
- const directories = globSync(this.outdir + "/**/*/");
156
- for (const directory of directories.toSorted()) {
159
+ const logTitle = isRemoveUnused ? chalk.bold(chalk.red("Removed"), "(" + chalk.yellow(unusedFilesLog.length) + ")", "unused files from the output directory") : chalk.bold("Found", "(" + chalk.yellow(unusedFilesLog.length) + ")", "unused files");
160
+ if (unusedFilesLog.length > 0) this.log.warn(logTitle + (isLogUnusedFiles ? "\n" + unusedFilesLog.join("\n") : ""));
161
+ const sortedDirectories = globSync(this.outdir + "/**/*/").toSorted((a, b) => a.localeCompare(b));
162
+ for (const directory of sortedDirectories) {
157
163
  let currentPath = directory;
158
164
  while (currentPath !== this.outdir) {
159
165
  if (!(readdirSync(currentPath).length === 0)) break;
@@ -171,14 +177,15 @@ function analyzeOutputPlugin(options = {}) {
171
177
  stat: true
172
178
  });
173
179
  const largeFilesLogs = [];
174
- for (const file of filesStat.toSorted((a, b) => (b.size ?? 0) - (a.size ?? 0))) {
180
+ const sortedFiles = filesStat.toSorted((a, b) => (b.size ?? 0) - (a.size ?? 0));
181
+ for (const file of sortedFiles) {
175
182
  const maxSize = maxFileSize[extname(file.name)];
176
183
  if (typeof maxSize !== "number") continue;
177
184
  if (file.size === 0) continue;
178
185
  if (bytesToKB(file.size ?? 0) <= maxSize) continue;
179
- largeFilesLogs.push(c.yellow(file.relative()) + ` (${c.red.bold(humanReadableBytes(file.size ?? 0))} ${c.blue(">")} ${c.green(humanReadableBytes(maxSize * 1024))})`);
186
+ largeFilesLogs.push(chalk.yellow(file.relative()) + ` (${chalk.red.bold(humanReadableBytes(file.size ?? 0))} ${chalk.blue(">")} ${chalk.green(humanReadableBytes(maxSize * 1024))})`);
180
187
  }
181
- if (largeFilesLogs.length > 0) this.log.warn(c.bold("The following files may be large:\n") + largeFilesLogs.join("\n"));
188
+ if (largeFilesLogs.length > 0) this.log.warn(chalk.bold("The following files may be large:\n") + largeFilesLogs.join("\n"));
182
189
  }
183
190
  }
184
191
  };
@@ -235,9 +242,10 @@ async function bundlePackage(options) {
235
242
 
236
243
  //#endregion
237
244
  //#region src/plugins/bundle-packages/collect-specifiers.ts
245
+ const traverse$1 = typeof _traverse === "function" ? _traverse : _traverse.default;
238
246
  function collectSpecifiersFromAst(ast) {
239
247
  const result = [];
240
- traverse(ast, {
248
+ traverse$1(ast, {
241
249
  ImportDeclaration(path) {
242
250
  if (!t.isStringLiteral(path.node.source)) return;
243
251
  if ((path.node.importKind ?? "value") === "type") return;
@@ -312,21 +320,21 @@ function collectSpecifiersFromAst(ast) {
312
320
  function collectImportDeclarationSpecifiers(path, specifiers) {
313
321
  const node = path.node;
314
322
  if (!t.isStringLiteral(node.source) || node.importKind && node.importKind !== "value") return;
315
- let foundSpecifier = false;
323
+ let hasFoundSpecifier = false;
316
324
  for (let index = 0; index < node.specifiers.length; index++) {
317
325
  const specifier = node.specifiers[index];
318
326
  if (t.isImportDefaultSpecifier(specifier)) {
319
327
  const setDefaultName = (newName) => {
320
328
  const index = node.specifiers.indexOf(specifier);
321
329
  if (index === -1) return;
322
- node.specifiers.splice(index, 1, t.importSpecifier(t.identifier(specifier.local.name), t.identifier(newName)));
330
+ node.specifiers[index] = t.importSpecifier(t.identifier(specifier.local.name), t.identifier(newName));
323
331
  };
324
332
  specifiers.push({
325
333
  type: "default",
326
334
  name: specifier.local.name,
327
335
  setDefaultName
328
336
  });
329
- foundSpecifier = true;
337
+ hasFoundSpecifier = true;
330
338
  continue;
331
339
  }
332
340
  if (t.isImportSpecifier(specifier)) {
@@ -338,7 +346,7 @@ function collectImportDeclarationSpecifiers(path, specifiers) {
338
346
  name: imported,
339
347
  publicName: specifier.local.name
340
348
  });
341
- foundSpecifier = true;
349
+ hasFoundSpecifier = true;
342
350
  continue;
343
351
  }
344
352
  if (t.isImportNamespaceSpecifier(specifier)) {
@@ -360,7 +368,7 @@ function collectImportDeclarationSpecifiers(path, specifiers) {
360
368
  name: capturedLocalName,
361
369
  setDefaultName
362
370
  });
363
- foundSpecifier = true;
371
+ hasFoundSpecifier = true;
364
372
  continue;
365
373
  }
366
374
  specifiers.push({
@@ -369,11 +377,11 @@ function collectImportDeclarationSpecifiers(path, specifiers) {
369
377
  name,
370
378
  publicName: name
371
379
  });
372
- foundSpecifier = true;
380
+ hasFoundSpecifier = true;
373
381
  }
374
382
  }
375
383
  }
376
- if (!foundSpecifier) specifiers.push({ type: "side-effect" });
384
+ if (!hasFoundSpecifier) specifiers.push({ type: "side-effect" });
377
385
  }
378
386
  function collectExportAllDeclarationSpecifiers(path, specifiers) {
379
387
  if (!path.node.source.value || path.node.exportKind !== "value") return;
@@ -410,13 +418,10 @@ function collectExportNamedDeclarationSpecifiers(path, specifiers) {
410
418
  });
411
419
  continue;
412
420
  }
413
- if (t.isExportNamespaceSpecifier(specifier)) {
414
- specifiers.push({
415
- type: "namespace",
416
- name: specifier.exported.name
417
- });
418
- continue;
419
- }
421
+ if (t.isExportNamespaceSpecifier(specifier)) specifiers.push({
422
+ type: "namespace",
423
+ name: t.isIdentifier(specifier.exported) ? specifier.exported.name : specifier.exported.value
424
+ });
420
425
  }
421
426
  }
422
427
  function collectDynamicImportSpecifiers(path, specifiers) {
@@ -606,7 +611,7 @@ function generateStdinString(specifiers, packageName) {
606
611
  named.add(specifier.publicName);
607
612
  }
608
613
  if (specifier.type === "namespace") isNamespace = true;
609
- if (specifier.type === "side-effect") hasSideEffect = true;
614
+ else if (specifier.type === "side-effect") hasSideEffect = true;
610
615
  }
611
616
  let contents = "";
612
617
  if (hasSideEffect) contents += `import '${packageName}';`;
@@ -651,8 +656,8 @@ function getNodeModuleDirectory(packageName, root) {
651
656
  return null;
652
657
  }
653
658
  }
654
- function getCustomPackagePath(root, importPath, production, resolvePackage) {
655
- const environment = production ? "production" : "development";
659
+ function getCustomPackagePath(root, importPath, isProduction, resolvePackage) {
660
+ const environment = isProduction ? "production" : "development";
656
661
  for (const [packageName, exports] of Object.entries(resolvePackage)) for (const [entry, stringOrObject] of Object.entries(exports)) {
657
662
  if (packageJoin(packageName, entry) !== importPath) continue;
658
663
  const relativePath = typeof stringOrObject === "string" ? stringOrObject : stringOrObject[environment];
@@ -666,7 +671,7 @@ function getCustomPackagePath(root, importPath, production, resolvePackage) {
666
671
  }
667
672
  }
668
673
  function isNodeModulesPath(path, root) {
669
- return matchPath(path, {
674
+ return isPathMatch(path, {
670
675
  include: ["**/node_modules/**"],
671
676
  ignore: [],
672
677
  root
@@ -708,14 +713,14 @@ function normalizePackageName(packageName) {
708
713
  */
709
714
  function bundlePackagesPlugin(options = {}) {
710
715
  const packagesOutputDirection = options.packagesDir ?? "./packages";
711
- const minifyUsingTerser = options.minifyUsingTerser ?? false;
716
+ const shouldMinifyUsingTerser = options.minifyUsingTerser ?? false;
712
717
  const resolvePackage = options.resolvePackage ?? {};
713
718
  const chunks = options.chunks ?? {};
714
719
  /** Maps package names to a list of collected import specifiers (named, default, side-effect, etc.) from various source files. */
715
720
  const specifiersByPackage = /* @__PURE__ */ new Map();
716
721
  /** Maps the absolute path of a package entry point to its original source name */
717
722
  const pathPackageMap = /* @__PURE__ */ new Map();
718
- const JS_EXTENSIONS = new Set([
723
+ const JS_EXTENSIONS = /* @__PURE__ */ new Set([
719
724
  ".js",
720
725
  ".mjs",
721
726
  ".cjs",
@@ -836,7 +841,7 @@ function bundlePackagesPlugin(options = {}) {
836
841
  resolveDir: this.root,
837
842
  outfile: packageOutputPath,
838
843
  packageName: chunkName,
839
- minify: this.production && !minifyUsingTerser,
844
+ minify: this.production && !shouldMinifyUsingTerser,
840
845
  production: this.production,
841
846
  treeShaking: this.production,
842
847
  onPackageResolve: (importedPackageName) => {
@@ -887,19 +892,19 @@ function bundlePackagesPlugin(options = {}) {
887
892
  id: packageName,
888
893
  directDependencies: /* @__PURE__ */ new Set()
889
894
  };
890
- let loadAsIs = !this.production;
895
+ let isLoadAsIs = !this.production;
891
896
  for (const [index, specifier] of Array.from(specifiers).entries()) {
892
897
  if (specifier.type !== "unknown") continue;
893
- loadAsIs = true;
898
+ isLoadAsIs = true;
894
899
  specifiers.splice(index, 1);
895
900
  }
896
901
  const [bundledCode, bundleError] = await bundlePackage({
897
- contents: loadAsIs ? void 0 : generateStdinString(specifiers, packageName),
898
- entryPoint: loadAsIs ? packageName : void 0,
902
+ contents: isLoadAsIs ? void 0 : generateStdinString(specifiers, packageName),
903
+ entryPoint: isLoadAsIs ? packageName : void 0,
899
904
  resolveDir: this.root,
900
905
  outfile: packageOutputPath,
901
906
  packageName,
902
- minify: !minifyUsingTerser && this.production,
907
+ minify: !shouldMinifyUsingTerser && this.production,
903
908
  production: this.production,
904
909
  treeShaking: this.production,
905
910
  onPackageResolve: (importedPackageName) => {
@@ -974,7 +979,7 @@ function bundlePackagesPlugin(options = {}) {
974
979
  outfile: dependencyOutputPath,
975
980
  packageName: dependencyName,
976
981
  production: this.production,
977
- minify: !minifyUsingTerser,
982
+ minify: !shouldMinifyUsingTerser,
978
983
  treeShaking: true,
979
984
  onPackageResolve: (importedPackageName) => {
980
985
  const dependencyOutputPath = calcPackageOutPath(getChunkName(importedPackageName, chunks) ?? importedPackageName, packagesOutputDirection);
@@ -991,7 +996,7 @@ function bundlePackagesPlugin(options = {}) {
991
996
  }
992
997
  packageToBundle.code = reBundledCode;
993
998
  }
994
- if (!minifyUsingTerser) return;
999
+ if (!shouldMinifyUsingTerser) return;
995
1000
  const packages = this.filterMetadata({ type: METADATA_TYPES.Package });
996
1001
  for (const packageMetadata of packages) {
997
1002
  const result = minify_sync(packageMetadata.code);
@@ -1018,7 +1023,7 @@ function convertImagePlugin(options = {}) {
1018
1023
  if (!isValidRelativePath(source)) return;
1019
1024
  const [link, suffix] = splitHtmlLink(source);
1020
1025
  const relativeToRoot = join(dirname(filePath), link);
1021
- if (!matchPath(relativeToRoot, {
1026
+ if (!isPathMatch(relativeToRoot, {
1022
1027
  include,
1023
1028
  ignore,
1024
1029
  root: this.root
@@ -1028,7 +1033,7 @@ function convertImagePlugin(options = {}) {
1028
1033
  imgPath: join(this.root, relativeToRoot)
1029
1034
  };
1030
1035
  }
1031
- const supported = new Set([
1036
+ const supported = /* @__PURE__ */ new Set([
1032
1037
  "png",
1033
1038
  "jpg",
1034
1039
  "jpeg",
@@ -1044,7 +1049,7 @@ function convertImagePlugin(options = {}) {
1044
1049
  async transform(inputMetadata) {
1045
1050
  for (const { metadata } of filterScriptMetadata(inputMetadata)) {
1046
1051
  const log = this.log;
1047
- const production = this.production;
1052
+ const isProduction = this.production;
1048
1053
  t.traverse(metadata.ast, { enter(node, ancestors) {
1049
1054
  if (!t.isMemberExpression(node) || !t.isIdentifier(node.property)) return;
1050
1055
  if (!t.isIdentifier(node.object, { name: "_img" })) return;
@@ -1056,7 +1061,7 @@ function convertImagePlugin(options = {}) {
1056
1061
  return;
1057
1062
  }
1058
1063
  const parentNode = capturedAncestor.node;
1059
- const newNode = t.stringLiteral(production ? format : property);
1064
+ const newNode = t.stringLiteral(isProduction ? format : property);
1060
1065
  if (capturedAncestor.index === void 0) {
1061
1066
  parentNode[capturedAncestor.key] = newNode;
1062
1067
  return;
@@ -1134,7 +1139,8 @@ function copyAssetsPlugin(options = {}) {
1134
1139
  const publicFiles = globSync("**/*", {
1135
1140
  ignore,
1136
1141
  nodir: true,
1137
- cwd: join(this.root, publicDirectory)
1142
+ cwd: join(this.root, publicDirectory),
1143
+ dot: true
1138
1144
  });
1139
1145
  for (const file of publicFiles) {
1140
1146
  const inputFile = join(this.root, publicDirectory, file);
@@ -1159,7 +1165,7 @@ function getPointsFromPathString(path, viewBox) {
1159
1165
  const width = viewBox.width;
1160
1166
  const match = path.match(/-?[0-9.]+/g);
1161
1167
  if (!match) throw new Error("invalid path");
1162
- const pathData = match.map((v, index) => index % 2 === 0 ? Number.parseFloat(v) * width + x : Number.parseFloat(v) * height + y);
1168
+ const pathData = match.map((v, index) => index % 2 === 0 ? Number(v) * width + x : Number(v) * height + y);
1163
1169
  const points = [];
1164
1170
  if (pathData.length === 0) return points;
1165
1171
  points.push([pathData[0], pathData[1]]);
@@ -1277,7 +1283,7 @@ function convertEasingFunctionToLinearFN(easingFunction, samples) {
1277
1283
  const t = index / (samples - 1);
1278
1284
  values[count++] = easingFunction(t);
1279
1285
  }
1280
- return `linear(${Array.from(values).map((string) => +string.toFixed(2)).join(",")})`;
1286
+ return `linear(${Array.from(values, (string) => +string.toFixed(2)).join(",")})`;
1281
1287
  }
1282
1288
 
1283
1289
  //#endregion
@@ -1386,16 +1392,16 @@ function customEasePlugin(options = {}) {
1386
1392
  ...predefinedEasing,
1387
1393
  ...options.customEase
1388
1394
  };
1389
- const replaceInHtml = options.replaceInHtmlStyleAttribute ?? false;
1390
- const replaceInJS = options.replaceInJS ?? false;
1395
+ const shouldReplaceInHtml = options.replaceInHtmlStyleAttribute ?? false;
1396
+ const shouldReplaceInJS = options.replaceInJS ?? false;
1391
1397
  const jsFunctionName = options.jsFunctionName ?? "cssLinear";
1392
- const replaceInCSS = options.replaceInCSS ?? true;
1398
+ const shouldReplaceInCSS = options.replaceInCSS ?? true;
1393
1399
  const cssFunctionPrefix = options.cssFunctionPrefix ?? "--ease-";
1394
1400
  const samples = options.samples ?? 50;
1395
1401
  return {
1396
1402
  name: "custom-ease",
1397
1403
  transform(inputMetadata) {
1398
- if (replaceInHtml && isHtmlMetadata(inputMetadata)) {
1404
+ if (shouldReplaceInHtml && isHtmlMetadata(inputMetadata)) {
1399
1405
  const elements = inputMetadata.ast.querySelectorAll("[style]");
1400
1406
  for (const node of elements) {
1401
1407
  const style = node.getAttribute("style");
@@ -1403,7 +1409,7 @@ function customEasePlugin(options = {}) {
1403
1409
  const { name, matchStartIndex, matchEndIndex, args } = parseFunctionCall(style, `${cssFunctionPrefix}.+`);
1404
1410
  if (matchStartIndex < 0) return;
1405
1411
  const easeFunctionName = name.replace(cssFunctionPrefix, "");
1406
- if (!(easeFunctionName in customEasing)) return;
1412
+ if (!Object.hasOwn(customEasing, easeFunctionName)) return;
1407
1413
  const easeFunctionOrString = customEasing[easeFunctionName];
1408
1414
  if (typeof easeFunctionOrString === "string") {
1409
1415
  node.setAttribute("style", style.slice(0, Math.max(0, matchStartIndex)) + easeFunctionOrString + style.slice(Math.max(0, matchEndIndex)));
@@ -1420,13 +1426,13 @@ function customEasePlugin(options = {}) {
1420
1426
  }
1421
1427
  }
1422
1428
  }
1423
- if (replaceInJS) for (const { metadata } of filterScriptMetadata(inputMetadata)) t.traverse(metadata.ast, { enter(node, ancestors) {
1429
+ if (shouldReplaceInJS) for (const { metadata } of filterScriptMetadata(inputMetadata)) t.traverse(metadata.ast, { enter(node, ancestors) {
1424
1430
  if (!t.isCallExpression(node)) return;
1425
1431
  const callee = node.callee;
1426
1432
  if (!t.isMemberExpression(callee) || !t.isIdentifier(callee.object) || !t.isIdentifier(callee.property)) return;
1427
1433
  if (callee.object.name !== jsFunctionName) return;
1428
1434
  const functionName = callee.property.name.replace(/[A-Z]/g, (match) => "-" + match.toLowerCase());
1429
- if (!(functionName in customEasing)) return;
1435
+ if (!Object.hasOwn(customEasing, functionName)) return;
1430
1436
  const easeFunctionOrString = customEasing[functionName];
1431
1437
  const capturedAncestor = ancestors.at(-1);
1432
1438
  if (!capturedAncestor) {
@@ -1453,20 +1459,20 @@ function customEasePlugin(options = {}) {
1453
1459
  }
1454
1460
  replaceWith(convertEasingFunctionToLinearFN(easeFunctionOrString(...arguments_), samples));
1455
1461
  } });
1456
- if (replaceInCSS) for (const { metadata } of filterStyleMetadata(inputMetadata)) metadata.ast.walkDecls((decl) => {
1457
- const value = decl.value;
1462
+ if (shouldReplaceInCSS) for (const { metadata } of filterStyleMetadata(inputMetadata)) metadata.ast.walkDecls((declaration) => {
1463
+ const value = declaration.value;
1458
1464
  const { name, matchStartIndex, matchEndIndex, args } = parseFunctionCall(value, `${cssFunctionPrefix}.+`);
1459
1465
  if (matchStartIndex < 0) return;
1460
1466
  const easeFunctionName = name.replace(cssFunctionPrefix, "");
1461
- if (!(easeFunctionName in customEasing)) return;
1467
+ if (!Object.hasOwn(customEasing, easeFunctionName)) return;
1462
1468
  const easeFunctionOrString = customEasing[easeFunctionName];
1463
1469
  if (typeof easeFunctionOrString === "string") {
1464
- decl.value = value.slice(0, Math.max(0, matchStartIndex)) + easeFunctionOrString + value.slice(Math.max(0, matchEndIndex));
1470
+ declaration.value = value.slice(0, Math.max(0, matchStartIndex)) + easeFunctionOrString + value.slice(Math.max(0, matchEndIndex));
1465
1471
  return;
1466
1472
  }
1467
1473
  try {
1468
1474
  const linearFunction = convertEasingFunctionToLinearFN(easeFunctionOrString(...args), samples);
1469
- decl.value = value.slice(0, Math.max(0, matchStartIndex)) + linearFunction + value.slice(Math.max(0, matchEndIndex));
1475
+ declaration.value = value.slice(0, Math.max(0, matchStartIndex)) + linearFunction + value.slice(Math.max(0, matchEndIndex));
1470
1476
  } catch {
1471
1477
  printFmtError("Error generating easing function", {
1472
1478
  function: customEasePlugin,
@@ -1577,7 +1583,7 @@ getLocals.cache = null;
1577
1583
  function getAllPathsMap(object, prefix = "", result = /* @__PURE__ */ new Map()) {
1578
1584
  for (const key in object) {
1579
1585
  const path = prefix ? `${prefix}.${key}` : key;
1580
- if (object[key] && typeof object[key] === "object" && !Array.isArray(object[key])) {
1586
+ if (Object.hasOwn(object, key) && typeof object[key] === "object" && !Array.isArray(object[key])) {
1581
1587
  getAllPathsMap(object[key], path, result);
1582
1588
  continue;
1583
1589
  }
@@ -1653,7 +1659,7 @@ function processI18nInHTML(options) {
1653
1659
  const attributeValue = Object.entries(node.attrs);
1654
1660
  const i18nNameValuePair = Object.fromEntries(attributeValue.filter(([attribute]) => attribute.startsWith(placeholderPrefix)).map(([attribute, value]) => [attribute.replace(placeholderPrefix, ""), value]));
1655
1661
  const replacer = (_match, attribute, defaultValue) => {
1656
- if (attribute in i18nNameValuePair) {
1662
+ if (Object.hasOwn(i18nNameValuePair, attribute)) {
1657
1663
  const value = i18nNameValuePair[attribute];
1658
1664
  if (typeof value === "string") {
1659
1665
  if (!value.startsWith("@") || value.startsWith("@@")) return value.replace(/^@@/, "@");
@@ -1664,7 +1670,7 @@ function processI18nInHTML(options) {
1664
1670
  if (defaultValue !== void 0) return defaultValue;
1665
1671
  return "";
1666
1672
  };
1667
- if (i18nAttribute in node.attrs) {
1673
+ if (Object.hasOwn(node.attributes, i18nAttribute)) {
1668
1674
  const keysPath = node.getAttribute(i18nAttribute);
1669
1675
  node.removeAttribute(i18nAttribute);
1670
1676
  for (const attribute of Object.keys(i18nNameValuePair)) node.removeAttribute(placeholderPrefix + attribute);
@@ -1703,7 +1709,10 @@ function i18nCliPlugin(options) {
1703
1709
  });
1704
1710
  const keys = Array.from(localesData.localesMap[defaultLocale].keys());
1705
1711
  const placeholders = /* @__PURE__ */ new Set();
1706
- for (const locale in localesData.localesObj) for (const placeholder of collectPlaceholders(localesData.localesObj[locale])) placeholders.add(placeholder);
1712
+ for (const locale in localesData.localesObj) {
1713
+ const placeholders = collectPlaceholders(localesData.localesObj[locale]);
1714
+ for (const placeholder of placeholders) placeholders.add(placeholder);
1715
+ }
1707
1716
  const htmlDataSavePath = join(localesPath, "i18n.html-data.json");
1708
1717
  const attributeValues = keys.map((key) => ({ name: key }));
1709
1718
  const placeholderValues = keys.map((key) => ({ name: `@${key}` }));
@@ -1717,7 +1726,7 @@ function i18nCliPlugin(options) {
1717
1726
  values: placeholderValues
1718
1727
  }],
1719
1728
  globalAttributes: [
1720
- ...Array.from(placeholders).map((placeholder) => ({
1729
+ ...Array.from(placeholders, (placeholder) => ({
1721
1730
  name: placeholderPrefix + placeholder,
1722
1731
  description: `Replace the placeholder \`${placeholder}\` with a value.\n\nExample: \`"Hi {{ ${placeholder}=DefaultValue }}"\` -> \`<div ${placeholderPrefix + placeholder}="someValue"></div>\` \n\nOr use an existing i18n value:\n\n\`<div ${placeholderPrefix + placeholder}="@header.title"></div>\``,
1723
1732
  valueSet: "i18n-placeholder-keys"
@@ -1765,7 +1774,7 @@ function generateTypes(keys, placeholders, langs) {
1765
1774
  current[part] = "string";
1766
1775
  continue;
1767
1776
  }
1768
- if (!current[part]) current[part] = {};
1777
+ if (!Object.hasOwn(current, part)) current[part] = {};
1769
1778
  current = current[part];
1770
1779
  }
1771
1780
  }
@@ -1820,6 +1829,7 @@ function collectPlaceholders(data) {
1820
1829
 
1821
1830
  //#endregion
1822
1831
  //#region src/ast-utilities/babel-utils/resolve-static-value.ts
1832
+ const generator$1 = typeof _generator === "function" ? _generator : _generator.default;
1823
1833
  /** Get the value of an expression node */
1824
1834
  function resolveStaticValue$1(path) {
1825
1835
  if (!path) return;
@@ -1886,7 +1896,7 @@ function resolveStaticValue$1(path) {
1886
1896
  if (t.isArrowFunctionExpression(node) || t.isFunctionExpression(node) || t.isClassMethod(node) || t.isClassPrivateMethod(node)) {
1887
1897
  const parameters = node.params.map((parameter) => t.isIdentifier(parameter) ? parameter.name : "").filter(Boolean);
1888
1898
  const isBlock = t.isBlockStatement(node.body);
1889
- let bodyString = generator(node.body).code;
1899
+ let bodyString = generator$1(node.body).code;
1890
1900
  bodyString = isBlock ? bodyString.slice(1, -1).trim() : "return " + bodyString;
1891
1901
  let function_;
1892
1902
  try {
@@ -2018,6 +2028,7 @@ function getClassPropertyValue(classPath, propertyName) {
2018
2028
 
2019
2029
  //#endregion
2020
2030
  //#region src/plugins/i18n/i18n-script-plugin.ts
2031
+ const traverse = typeof _traverse === "function" ? _traverse : _traverse.default;
2021
2032
  function i18nScriptPlugin(options) {
2022
2033
  const { defaultLocale, localesDirectory, supportedLocales } = options;
2023
2034
  const printFmtError = PrintFormattedError.create({ function: i18nScriptPlugin });
@@ -2052,7 +2063,7 @@ function i18nScriptPlugin(options) {
2052
2063
  }
2053
2064
  const fillValues = secondArgumentValue?.value ?? {};
2054
2065
  const replacer = (_match, variableName, defaultValue) => {
2055
- if (variableName in fillValues) {
2066
+ if (Object.hasOwn(fillValues, variableName)) {
2056
2067
  const value_ = fillValues[variableName];
2057
2068
  if (typeof value_ === "string") return value_;
2058
2069
  }
@@ -2140,7 +2151,7 @@ function i18nScriptPlugin(options) {
2140
2151
  }
2141
2152
  const fillValues = thirdArgumentValue?.value ?? {};
2142
2153
  const replacer = (_match, variableName, defaultValue) => {
2143
- if (variableName in fillValues) {
2154
+ if (Object.hasOwn(fillValues, variableName)) {
2144
2155
  const value_ = fillValues[variableName];
2145
2156
  if (typeof value_ === "string") return value_;
2146
2157
  }
@@ -2220,13 +2231,13 @@ function parseImportAsString({ ast, filePath }) {
2220
2231
  if (isPlainObject(secondeArgumentValue)) {
2221
2232
  const entries = Object.entries(secondeArgumentValue);
2222
2233
  for (const [key, value] of entries) {
2223
- if (!(key in optionsObject)) {
2234
+ if (!Object.hasOwn(optionsObject, key)) {
2224
2235
  printFmtError("Unknown option of `import_as_string`", { node });
2225
2236
  continue;
2226
2237
  }
2227
2238
  const expectedType = typeof optionsObject[key];
2228
2239
  if (typeof value !== expectedType) {
2229
- printFmtError(`The '${String(key)}' option should be an optional`, expectedType, { node });
2240
+ printFmtError(`The '${key}' option should be an optional`, expectedType, { node });
2230
2241
  continue;
2231
2242
  }
2232
2243
  optionsObject[key] = value;
@@ -2309,7 +2320,7 @@ function isPlainObject(value) {
2309
2320
  //#endregion
2310
2321
  //#region src/plugins/import-as-string/import-as-string-plugin.ts
2311
2322
  function importAsStringPlugin() {
2312
- const deps = new DependencyTracker();
2323
+ const dependencies = new DependencyTracker();
2313
2324
  return {
2314
2325
  name: "import-as-string",
2315
2326
  sourcesProvider(metadata) {
@@ -2320,12 +2331,12 @@ function importAsStringPlugin() {
2320
2331
  });
2321
2332
  },
2322
2333
  onFileEvent(event, id) {
2323
- if (event === "unlink") deps.delete(id);
2334
+ if (event === "unlink") dependencies.delete(id);
2324
2335
  },
2325
2336
  resolveCompileList(compileSet, event) {
2326
2337
  if (event !== "change") return;
2327
2338
  for (const id of Array.from(compileSet)) {
2328
- const importers = deps.getImporters(id);
2339
+ const importers = dependencies.getImporters(id);
2329
2340
  for (const importer of importers) compileSet.add(importer);
2330
2341
  }
2331
2342
  },
@@ -2373,7 +2384,7 @@ function importAsStringPlugin() {
2373
2384
  if (!this.entryPoints.has(sourceMetadata.id)) this.emitExclude.add(sourceMetadata);
2374
2385
  replaceWith(metadataString);
2375
2386
  }
2376
- deps.update(metadata.id, currentSources);
2387
+ dependencies.update(metadata.id, currentSources);
2377
2388
  }
2378
2389
  }
2379
2390
  };
@@ -2403,7 +2414,7 @@ function loadSourcesPlugin(options) {
2403
2414
  },
2404
2415
  onFileEvent(event, id) {
2405
2416
  if (event === "change") return;
2406
- if (!matchPath(id, {
2417
+ if (!isPathMatch(id, {
2407
2418
  include: options.include,
2408
2419
  ignore,
2409
2420
  root: this.root
@@ -2471,8 +2482,8 @@ function serviceWorkerPlugin(options = {}) {
2471
2482
  babelPresetEnvTargets: this.browserslist,
2472
2483
  ...options
2473
2484
  });
2474
- if (warnings.length > 0) this.log.warn("Warnings encountered while generating a service worker:\n >", warnings.join(c.yellow("\n > ")), "\n");
2475
- this.log.info("Generated a service worker, which will precache", c.yellow(count), "files, totaling", c.yellow(humanReadableBytes(size)));
2485
+ if (warnings.length > 0) this.log.warn("Warnings encountered while generating a service worker:\n >", warnings.join(chalk.yellow("\n > ")), "\n");
2486
+ this.log.info("Generated a service worker, which will precache", chalk.yellow(count), "files, totaling", chalk.yellow(humanReadableBytes(size)));
2476
2487
  }
2477
2488
  };
2478
2489
  }
@@ -2608,7 +2619,7 @@ const processCss = valueOrError(processCssUnsafe);
2608
2619
  const loadPostcssConfig = valueOrError(postcssrc);
2609
2620
  function transformCssPlugin(options = {}) {
2610
2621
  const plugins = options.plugins ?? [];
2611
- const loadConfig = options.loadConfig ?? false;
2622
+ const isLoadConfig = options.loadConfig ?? false;
2612
2623
  let postcssConfig = {
2613
2624
  file: "",
2614
2625
  options: {},
@@ -2618,7 +2629,7 @@ function transformCssPlugin(options = {}) {
2618
2629
  return {
2619
2630
  name: "transform-css",
2620
2631
  async setup() {
2621
- if (!loadConfig) return;
2632
+ if (!isLoadConfig) return;
2622
2633
  const environment = this.production ? "production" : "development";
2623
2634
  const virtualCssFile = join(this.root, "virtual.css");
2624
2635
  const [loadedPlugins, loadPluginsError] = await loadPostcssConfig({
@@ -2753,14 +2764,14 @@ function writeFilesPlugin(options) {
2753
2764
  options.format.exclude ??= [];
2754
2765
  const format = options.format;
2755
2766
  function shouldMinifyFile(filePath, root) {
2756
- return minify.enabled && matchPath(filePath, {
2767
+ return minify.enabled && isPathMatch(filePath, {
2757
2768
  include: minify.include,
2758
2769
  ignore: minify.exclude,
2759
2770
  root
2760
2771
  });
2761
2772
  }
2762
2773
  function shouldFormatFile(filePath, root) {
2763
- return format.enabled && matchPath(filePath, {
2774
+ return format.enabled && isPathMatch(filePath, {
2764
2775
  include: format.include,
2765
2776
  ignore: format.exclude,
2766
2777
  root
@@ -2778,7 +2789,7 @@ function writeFilesPlugin(options) {
2778
2789
  async write(metadata) {
2779
2790
  if (!this.production) return;
2780
2791
  if (this.emitExclude.has(metadata)) return;
2781
- if (!matchPath(metadata.id, {
2792
+ if (!isPathMatch(metadata.id, {
2782
2793
  include,
2783
2794
  ignore,
2784
2795
  root: this.root
@@ -2787,16 +2798,16 @@ function writeFilesPlugin(options) {
2787
2798
  this.log.error(`file path "${metadata.filePath}" is outside of the output directory "${this.outdir}". Skipping...`);
2788
2799
  return;
2789
2800
  }
2790
- const minify = shouldMinifyFile(metadata.id, this.root);
2791
- const format = shouldFormatFile(metadata.id, this.root);
2792
- if (minify && format) this.log.warn(`"minify" and "format" are enabled for "${metadata.id}" but only one can be used.`);
2801
+ const shouldMinify = shouldMinifyFile(metadata.id, this.root);
2802
+ const shouldFormat = shouldFormatFile(metadata.id, this.root);
2803
+ if (shouldMinify && shouldFormat) this.log.warn(`"minify" and "format" are enabled for "${metadata.id}" but only one can be used.`);
2793
2804
  if (isBinaryAssetMetadata(metadata)) {
2794
2805
  cpSync(join(this.root, metadata.id), join(this.outdir, metadata.filePath), { recursive: true });
2795
2806
  return;
2796
2807
  }
2797
2808
  const code = await this.stringify(metadata, {
2798
- format,
2799
- minify
2809
+ format: shouldFormat,
2810
+ minify: shouldMinify
2800
2811
  });
2801
2812
  if (typeof code !== "string") {
2802
2813
  this.log.error(`Failed to stringify "${metadata.id}"`);
@@ -2866,7 +2877,7 @@ async function executeJsInVmUnsafe(options) {
2866
2877
  async function importModuleDynamically(specifier, referrer) {
2867
2878
  const m = await linker(specifier, referrer);
2868
2879
  if (m.status === "unlinked") await m.link(linker);
2869
- if (m.status === "linked") await m.evaluate();
2880
+ else if (m.status === "linked") await m.evaluate();
2870
2881
  return m;
2871
2882
  }
2872
2883
  async function linker(specifier, referencingModule) {
@@ -2884,7 +2895,7 @@ async function executeJsInVmUnsafe(options) {
2884
2895
  modules[resolveName] = module;
2885
2896
  return module;
2886
2897
  }
2887
- if (Boolean(modules[resolveName])) return modules[resolveName];
2898
+ if (Object.hasOwn(modules, resolveName)) return modules[resolveName];
2888
2899
  if (isNativeModule) {
2889
2900
  const builtIn = await import(specifier);
2890
2901
  const exportNames = Object.keys(builtIn);
@@ -2934,10 +2945,9 @@ function htmlBuildTimeScript(options = {}) {
2934
2945
  return {
2935
2946
  name: "html-build-time-script",
2936
2947
  setup() {
2937
- if (!vm.SourceTextModule) {
2938
- isVmEnabled = false;
2939
- printFmtError("Script execution requires the `node:vm` module, which is currently unavailable.", "\nStart Node.js with the `--experimental-vm-modules` flag to enable it.");
2940
- }
2948
+ if (vm.SourceTextModule) return;
2949
+ isVmEnabled = false;
2950
+ printFmtError("Script execution requires the `node:vm` module, which is currently unavailable.", "\nStart Node.js with the `--experimental-vm-modules` flag to enable it.");
2941
2951
  },
2942
2952
  async postTransform() {
2943
2953
  for (const metadata of this.metadataList) {
@@ -2950,9 +2960,9 @@ function htmlBuildTimeScript(options = {}) {
2950
2960
  const scripts = metadata.ast.querySelectorAll(query);
2951
2961
  if (scripts.length === 0) continue;
2952
2962
  for (const node of scripts) {
2953
- const useFullDom = node.hasAttribute(fullDomAttribute);
2963
+ const shouldUseFullDom = node.hasAttribute(fullDomAttribute);
2954
2964
  if (!isScriptType(node.getAttribute("type"))) continue;
2955
- if (useFullDom && !isReady) {
2965
+ if (shouldUseFullDom && !isReady) {
2956
2966
  printFmtError("Script cannot be executed until the page is fully constructed.", { node });
2957
2967
  continue;
2958
2968
  }
@@ -2995,9 +3005,9 @@ function htmlBuildTimeScript(options = {}) {
2995
3005
  const [executeResult, error] = await executeJsInVM({
2996
3006
  root: this.root,
2997
3007
  entryFile: scriptMetadata.filePath,
2998
- html: useFullDom ? await this.stringify(metadata) : void 0,
3008
+ html: shouldUseFullDom ? await this.stringify(metadata) : void 0,
2999
3009
  context: {
3000
- document: useFullDom ? void 0 : metadata.ast,
3010
+ document: shouldUseFullDom ? void 0 : metadata.ast,
3001
3011
  window: globalThis,
3002
3012
  StaticBolt: this,
3003
3013
  __filepath: metadata.filePath,
@@ -3010,7 +3020,7 @@ function htmlBuildTimeScript(options = {}) {
3010
3020
  printFmtError("Failed to execute script tag", error, { node });
3011
3021
  continue;
3012
3022
  }
3013
- if (useFullDom && executeResult.dom) {
3023
+ if (shouldUseFullDom && executeResult.dom) {
3014
3024
  const output = executeResult.dom.serialize();
3015
3025
  metadata.ast.root.set_content(output);
3016
3026
  }
@@ -3045,7 +3055,7 @@ function htmlBuildTimeScript(options = {}) {
3045
3055
 
3046
3056
  //#endregion
3047
3057
  //#region src/plugins/html-bundle-script/esbuild-plugin.ts
3048
- function loaderPlugin(outFile, checkExternal) {
3058
+ function loaderPlugin(outFile, isExternalCheck) {
3049
3059
  const root = this.root;
3050
3060
  const outFileAbs = join(root, outFile);
3051
3061
  const app = this;
@@ -3056,11 +3066,11 @@ function loaderPlugin(outFile, checkExternal) {
3056
3066
  if (!arguments_.path.startsWith(".")) return;
3057
3067
  const absSource = join(arguments_.resolveDir, arguments_.path);
3058
3068
  const source = relative(root, absSource);
3059
- if (checkExternal(source)) return {
3069
+ if (isExternalCheck(source)) return {
3060
3070
  path: relative(dirname(outFile), source),
3061
3071
  external: true
3062
3072
  };
3063
- if (matchPath(source, {
3073
+ if (isPathMatch(source, {
3064
3074
  include: ["**/node_modules/**"],
3065
3075
  ignore: [],
3066
3076
  root
@@ -3101,7 +3111,7 @@ function loaderPlugin(outFile, checkExternal) {
3101
3111
  //#region src/plugins/html-bundle-script/esbuild-bundle.ts
3102
3112
  const bundleFunction = valueOrError(esbuild.build);
3103
3113
  async function bundleScriptWithEsbuild(options) {
3104
- const { contents, entryPoint, outfile, checkExternal } = options;
3114
+ const { contents, entryPoint, outfile, isExternalCheck } = options;
3105
3115
  const root = this.root;
3106
3116
  const [bundleResult, error] = await bundleFunction({
3107
3117
  stdin: {
@@ -3122,7 +3132,7 @@ async function bundleScriptWithEsbuild(options) {
3122
3132
  legalComments: "none",
3123
3133
  logLevel: "silent",
3124
3134
  charset: "utf8",
3125
- plugins: [loaderPlugin.call(this, outfile, checkExternal)]
3135
+ plugins: [loaderPlugin.call(this, outfile, isExternalCheck)]
3126
3136
  });
3127
3137
  if (error) return [null, error];
3128
3138
  const outCode = bundleResult?.outputFiles?.[0].text;
@@ -3206,7 +3216,7 @@ function htmlBundleScriptPlugin(options = {}) {
3206
3216
  });
3207
3217
  continue;
3208
3218
  }
3209
- const inline = !bundleOut && hasContent;
3219
+ const isInlined = !bundleOut && hasContent;
3210
3220
  const externals = parsePatterns(externalsAttributeValue) ?? defaultExternal;
3211
3221
  const externalsIgnore = parsePatterns(externalsExcludeAttributeValue) ?? defaultExternalExclude;
3212
3222
  let entryPoint = "";
@@ -3214,7 +3224,7 @@ function htmlBundleScriptPlugin(options = {}) {
3214
3224
  let contents = "";
3215
3225
  if (hasContent) {
3216
3226
  outfile = bundleOut ?? filePath;
3217
- if (inline) {
3227
+ if (isInlined) {
3218
3228
  entryPoint = metadata.filePath;
3219
3229
  contents = await this.stringify(scriptMetadata);
3220
3230
  } else {
@@ -3249,8 +3259,8 @@ function htmlBundleScriptPlugin(options = {}) {
3249
3259
  await this.rebase(clone, join(this.root, outfile));
3250
3260
  contents = await this.stringify(clone);
3251
3261
  }
3252
- const checkExternal = (string) => {
3253
- return matchPath(string, {
3262
+ const isExternalCheck = (string) => {
3263
+ return isPathMatch(string, {
3254
3264
  include: externals,
3255
3265
  ignore: externalsIgnore,
3256
3266
  root: this.root
@@ -3260,7 +3270,7 @@ function htmlBundleScriptPlugin(options = {}) {
3260
3270
  contents,
3261
3271
  entryPoint,
3262
3272
  outfile,
3263
- checkExternal
3273
+ isExternalCheck
3264
3274
  });
3265
3275
  if (bundleError) {
3266
3276
  printFmtError(`Failed to bundle the entry point "${entryPoint}"`, bundleError, {
@@ -3269,7 +3279,7 @@ function htmlBundleScriptPlugin(options = {}) {
3269
3279
  });
3270
3280
  continue;
3271
3281
  }
3272
- const newMetadataPath = normalize(inline ? filePath : outfile);
3282
+ const newMetadataPath = normalize(isInlined ? filePath : outfile);
3273
3283
  const newScriptMetadata = await this.load(newMetadataPath, {
3274
3284
  code: bundleString,
3275
3285
  type: "js"
@@ -3281,7 +3291,7 @@ function htmlBundleScriptPlugin(options = {}) {
3281
3291
  });
3282
3292
  continue;
3283
3293
  }
3284
- if (inline) {
3294
+ if (isInlined) {
3285
3295
  if (!scriptMetadataID) {
3286
3296
  printFmtError("Missing script metadata ID", {
3287
3297
  node,
@@ -3384,14 +3394,11 @@ function htmlBundleStylePlugin(options = {}) {
3384
3394
  if (!metadata) return readFileSync(absoluteFilePath, "utf8");
3385
3395
  return await this.stringify(metadata);
3386
3396
  } })], { from: resolve(this.root, metadata.filePath) });
3387
- if (processError !== null) {
3388
- printFmtError(processError, {
3389
- function: htmlBundleStylePlugin,
3390
- node,
3391
- filePath: metadata.id
3392
- });
3393
- continue;
3394
- }
3397
+ if (processError !== null) printFmtError(processError, {
3398
+ function: htmlBundleStylePlugin,
3399
+ node,
3400
+ filePath: metadata.id
3401
+ });
3395
3402
  }
3396
3403
  },
3397
3404
  lspHtmlData() {
@@ -3444,11 +3451,11 @@ function htmlFragmentPlugin(options = {}) {
3444
3451
  function isTopLevelIIFE(ast) {
3445
3452
  const body = ast.program.body;
3446
3453
  if (body.length !== 1) return false;
3447
- const stmt = body[0];
3448
- if (stmt.type !== "ExpressionStatement") return false;
3449
- const expr = stmt.expression;
3450
- if (expr.type !== "CallExpression") return false;
3451
- const callee = expr.callee;
3454
+ const statement = body[0];
3455
+ if (statement.type !== "ExpressionStatement") return false;
3456
+ const expression = statement.expression;
3457
+ if (expression.type !== "CallExpression") return false;
3458
+ const callee = expression.callee;
3452
3459
  return callee.type === "ArrowFunctionExpression" || callee.type === "FunctionExpression";
3453
3460
  }
3454
3461
  /**
@@ -3525,10 +3532,7 @@ function htmlIifeScriptPlugin(options = {}) {
3525
3532
  continue;
3526
3533
  }
3527
3534
  const [, wrapError] = wrapWithIIFE(scriptMetadata.ast);
3528
- if (wrapError) {
3529
- printFmtError("Error wrapping script in IIFE", wrapError);
3530
- continue;
3531
- }
3535
+ if (wrapError) printFmtError("Error wrapping script in IIFE", wrapError);
3532
3536
  }
3533
3537
  },
3534
3538
  lspHtmlData() {
@@ -3606,7 +3610,7 @@ function htmlInlineScriptPlugin(options = {}) {
3606
3610
  async function loadScriptMetadata(source, filePath) {
3607
3611
  if (isURL(source)) {
3608
3612
  const urlHash = await crypto.subtle.digest("SHA-1", new TextEncoder().encode(source));
3609
- const hashHex = Array.from(new Uint8Array(urlHash)).map((b) => b.toString(16).padStart(2, "0")).join("");
3613
+ const hashHex = Array.from(new Uint8Array(urlHash), (b) => b.toString(16).padStart(2, "0")).join("");
3610
3614
  const downloadedFilePath = join(dirname(filePath), `downloaded/${hashHex}.css`);
3611
3615
  for (const metadata of this.metadataList) if (isScriptMetadata(metadata) && metadata.filePath === downloadedFilePath) return [metadata, null];
3612
3616
  const [downloaded, downloadError] = await downloadContent(source);
@@ -3683,7 +3687,7 @@ function htmlInlineStylePlugin(options = {}) {
3683
3687
  async function loadStyleMetadata(source, filePath) {
3684
3688
  if (isURL(source)) {
3685
3689
  const urlHash = await crypto.subtle.digest("SHA-1", new TextEncoder().encode(source));
3686
- const hashHex = Array.from(new Uint8Array(urlHash)).map((b) => b.toString(16).padStart(2, "0")).join("");
3690
+ const hashHex = Array.from(new Uint8Array(urlHash), (b) => b.toString(16).padStart(2, "0")).join("");
3687
3691
  const downloadedFilePath = join(dirname(filePath), `downloaded/${hashHex}.css`);
3688
3692
  for (const metadata of this.metadataList) if (isStyleMetadata(metadata) && metadata.filePath === downloadedFilePath) return [metadata, null];
3689
3693
  const [downloaded, downloadError] = await downloadContent(source);
@@ -3769,7 +3773,7 @@ function HtmlInlineSvgPlugin(options = {}) {
3769
3773
  async function loadSvgMetadata(source, filePath) {
3770
3774
  if (isURL(source)) {
3771
3775
  const urlHash = await crypto.subtle.digest("SHA-1", new TextEncoder().encode(source));
3772
- const hashHex = Array.from(new Uint8Array(urlHash)).map((b) => b.toString(16).padStart(2, "0")).join("");
3776
+ const hashHex = Array.from(new Uint8Array(urlHash), (b) => b.toString(16).padStart(2, "0")).join("");
3773
3777
  const downloadedFilePath = join(dirname(filePath), `downloaded/${hashHex}.css`);
3774
3778
  for (const metadata of this.metadataList) if (isSvgMetadata(metadata) && metadata.filePath === downloadedFilePath) return [metadata, null];
3775
3779
  const [downloaded, downloadError] = await downloadContent(source);
@@ -3797,7 +3801,7 @@ function htmlInlineTextPlugin(options = {}) {
3797
3801
  const sourceAttribute = options.sourceAttribute ?? "src";
3798
3802
  const noEscapeAttribute = options.noEscapeAttribute ?? "no-escape";
3799
3803
  const cache = /* @__PURE__ */ new Map();
3800
- const deps = new DependencyTracker();
3804
+ const dependencies = new DependencyTracker();
3801
3805
  return {
3802
3806
  name: "html-inline-text",
3803
3807
  sourcesProvider(metadata) {
@@ -3849,16 +3853,16 @@ function htmlInlineTextPlugin(options = {}) {
3849
3853
  currentSources.add(sourceRelative);
3850
3854
  inlineTag.replaceWith(contents);
3851
3855
  }
3852
- deps.update(metadata.id, currentSources);
3856
+ dependencies.update(metadata.id, currentSources);
3853
3857
  },
3854
3858
  onFileEvent(event, id) {
3855
3859
  if (event === "unlink" || event === "change") cache.delete(id);
3856
- if (event === "unlink") deps.delete(id);
3860
+ if (event === "unlink") dependencies.delete(id);
3857
3861
  },
3858
3862
  resolveCompileList(compileSet, event) {
3859
3863
  if (event !== "change") return;
3860
3864
  for (const id of Array.from(compileSet)) {
3861
- const importers = deps.getImporters(id);
3865
+ const importers = dependencies.getImporters(id);
3862
3866
  for (const importer of importers) compileSet.add(importer);
3863
3867
  }
3864
3868
  },
@@ -4099,7 +4103,8 @@ function htmlLayoutPlugin(options = {}) {
4099
4103
  const queue = [id];
4100
4104
  while (queue.length > 0) {
4101
4105
  const current = queue.shift();
4102
- for (const metadata of this.metadataList) if (metadata.directDependencies.has(current) && !compileSet.has(metadata.id)) {
4106
+ for (const metadata of this.metadataList) {
4107
+ if (!(metadata.directDependencies.has(current) && !compileSet.has(metadata.id))) continue;
4103
4108
  compileSet.add(metadata.id);
4104
4109
  if (isLayoutPath(metadata.id)) queue.push(metadata.id);
4105
4110
  }
@@ -4171,7 +4176,7 @@ function htmlLayoutPlugin(options = {}) {
4171
4176
  skip();
4172
4177
  continue;
4173
4178
  }
4174
- Object.assign(fillData, { ...node.attributes });
4179
+ Object.assign(fillData, node.attributes);
4175
4180
  const [layoutCode, fillError] = fillLayoutPlaceholders(layoutAssetMetadata.code, fillData);
4176
4181
  if (fillError) {
4177
4182
  printFmtError(fillError, {
@@ -4266,7 +4271,7 @@ function htmlLayoutPlugin(options = {}) {
4266
4271
  }
4267
4272
  for (const dependency of layoutHtmlMetadata.directDependencies) metadata.directDependencies.add(dependency);
4268
4273
  await this.rebase(layoutHtmlMetadata, join(this.root, metadata.filePath));
4269
- const children = node.querySelectorAll("> *");
4274
+ const children = node.querySelectorAll(":scope > *");
4270
4275
  for (const element of children) {
4271
4276
  if (element.nodeType !== NodeType.ELEMENT_NODE) continue;
4272
4277
  if (!element.hasAttribute("slot")) {
@@ -4380,7 +4385,7 @@ function htmlMarkdownPlugin(options = {}) {
4380
4385
  const mdAttribute = options.markdownAttribute ?? "markdown";
4381
4386
  const markdownTag = options.tag ?? "markdown";
4382
4387
  const sourceAttribute = options.sourceAttribute ?? "src";
4383
- const deps = new DependencyTracker();
4388
+ const dependencies = new DependencyTracker();
4384
4389
  const printFmtError = PrintFormattedError.create({ function: htmlMarkdownPlugin });
4385
4390
  return {
4386
4391
  name: "html-markdown",
@@ -4483,15 +4488,15 @@ function htmlMarkdownPlugin(options = {}) {
4483
4488
  await this.rebase(htmlMetadata, join(this.root, metadata.filePath));
4484
4489
  node.replaceWith(...htmlMetadata.ast.children);
4485
4490
  }
4486
- deps.update(metadata.id, currentSources);
4491
+ dependencies.update(metadata.id, currentSources);
4487
4492
  },
4488
4493
  onFileEvent(event, id) {
4489
- if (event === "unlink") deps.delete(id);
4494
+ if (event === "unlink") dependencies.delete(id);
4490
4495
  },
4491
4496
  resolveCompileList(compileSet, event) {
4492
4497
  if (event !== "change") return;
4493
4498
  for (const id of Array.from(compileSet)) {
4494
- const importers = deps.getImporters(id);
4499
+ const importers = dependencies.getImporters(id);
4495
4500
  for (const importer of importers) compileSet.add(importer);
4496
4501
  }
4497
4502
  },
@@ -4575,7 +4580,7 @@ function htmlMergeStylesPlugin() {
4575
4580
  //#endregion
4576
4581
  //#region src/plugins/core-plugins/base-plugin/base-plugin.ts
4577
4582
  function coreBasePlugin() {
4578
- const JS_EXTENSIONS = new Set([
4583
+ const JS_EXTENSIONS = /* @__PURE__ */ new Set([
4579
4584
  ".js",
4580
4585
  ".mjs",
4581
4586
  ".cjs",
@@ -4678,8 +4683,7 @@ function isSelfReference(sourceAbsolute, filePathAbsolute) {
4678
4683
  if (replaceExtension(sourceAbsolute, ".html") === filePathAbsolute) return true;
4679
4684
  if (replaceExtension(sourceAbsolute, ".md") === filePathAbsolute) return true;
4680
4685
  if (join(sourceAbsolute, "index.html") === filePathAbsolute) return true;
4681
- if (join(sourceAbsolute, "index.md") === filePathAbsolute) return true;
4682
- return false;
4686
+ return join(sourceAbsolute, "index.md") === filePathAbsolute;
4683
4687
  }
4684
4688
 
4685
4689
  //#endregion
@@ -4860,7 +4864,7 @@ function fillDynamicPath(path, parameters) {
4860
4864
  const key = dynamicMatch[1];
4861
4865
  const value = parameters[key] ?? dynamicMatch[0];
4862
4866
  if (value.includes("/")) throw new Error(`Dynamic param "${key}" contains slashes. Use "[...${key}]" for catch-all routes.`);
4863
- result.push(segment.replace(/\[([^\]]+)\]/, value));
4867
+ result.push(segment.replace(/\[([^\]]+)\]/, () => value));
4864
4868
  continue;
4865
4869
  }
4866
4870
  result.push(segment);
@@ -4959,10 +4963,10 @@ function htmlPagesPlugin(options = {}) {
4959
4963
  rebaseSource(source, filePath, newAbsolutePath) {
4960
4964
  if (!isValidRelativePath(source)) return;
4961
4965
  const relativeNewPath = relative(this.root, newAbsolutePath);
4962
- const rebasingFromPages = isPageDirectorySubpath(filePath, pagesDirectory);
4963
- const rebasingToPages = isPageDirectorySubpath(relativeNewPath, pagesDirectory);
4964
- if (rebasingFromPages && rebasingToPages) return;
4965
- if (!rebasingFromPages && !rebasingToPages) return;
4966
+ const isRebasingFromPages = isPageDirectorySubpath(filePath, pagesDirectory);
4967
+ const isRebasingToPages = isPageDirectorySubpath(relativeNewPath, pagesDirectory);
4968
+ if (isRebasingFromPages && isRebasingToPages) return;
4969
+ if (!isRebasingFromPages && !isRebasingToPages) return;
4966
4970
  const [link, suffix] = splitHtmlLink(source);
4967
4971
  if (["index.html", "index.md"].includes(basename(filePath)) && [
4968
4972
  "./",
@@ -5142,7 +5146,7 @@ function htmlPreloadPlugin(options = {}) {
5142
5146
  },
5143
5147
  async postTransform() {
5144
5148
  if (!this.production) return;
5145
- const depsFinder = new DepsFinder(this, this.root);
5149
+ const dependenciesFinder = new DependenciesFinder(this, this.root);
5146
5150
  for (const htmlMetadata of this.metadataList) {
5147
5151
  if (!isHtmlMetadata(htmlMetadata)) continue;
5148
5152
  const head = htmlMetadata.ast.querySelector("head");
@@ -5171,19 +5175,19 @@ function htmlPreloadPlugin(options = {}) {
5171
5175
  });
5172
5176
  continue;
5173
5177
  }
5174
- const deps = await depsFinder.findDeps(metadata);
5178
+ const dependencies = await dependenciesFinder.findDeps(metadata);
5175
5179
  const source = node.getAttribute("src") ?? node.getAttribute("href");
5176
5180
  if (isScript && source || isStyleSheetLink && source) {
5177
5181
  const [link] = splitHtmlLink(source);
5178
- deps.add(join(this.root, dirname(htmlMetadata.filePath), link));
5182
+ dependencies.add(join(this.root, dirname(htmlMetadata.filePath), link));
5179
5183
  }
5180
- for (const dep of deps) {
5181
- if (!matchPath(relative(this.root, dep), {
5184
+ for (const dependency of dependencies) {
5185
+ if (!isPathMatch(relative(this.root, dependency), {
5182
5186
  include,
5183
5187
  ignore,
5184
5188
  root: this.root
5185
5189
  })) continue;
5186
- preloadPaths.add(relative(dirname(htmlMetadata.filePath), dep));
5190
+ preloadPaths.add(relative(dirname(htmlMetadata.filePath), dependency));
5187
5191
  }
5188
5192
  }
5189
5193
  const linkTags = [];
@@ -5253,7 +5257,7 @@ function createLinkTag(info, href) {
5253
5257
  //#endregion
5254
5258
  //#region src/ast-utilities/html-utils/parse-html-sources.ts
5255
5259
  const attributeTagsMap = {
5256
- src: new Set([
5260
+ src: /* @__PURE__ */ new Set([
5257
5261
  "img",
5258
5262
  "video",
5259
5263
  "audio",
@@ -5264,24 +5268,24 @@ const attributeTagsMap = {
5264
5268
  "embed",
5265
5269
  "input"
5266
5270
  ]),
5267
- srcset: new Set(["img", "source"]),
5268
- href: new Set([
5271
+ srcset: /* @__PURE__ */ new Set(["img", "source"]),
5272
+ href: /* @__PURE__ */ new Set([
5269
5273
  "a",
5270
5274
  "area",
5271
5275
  "link",
5272
5276
  "base"
5273
5277
  ]),
5274
- data: new Set(["object"]),
5275
- action: new Set(["form"]),
5276
- formaction: new Set(["button", "input"]),
5277
- poster: new Set(["video"]),
5278
- cite: new Set([
5278
+ data: /* @__PURE__ */ new Set(["object"]),
5279
+ action: /* @__PURE__ */ new Set(["form"]),
5280
+ formaction: /* @__PURE__ */ new Set(["button", "input"]),
5281
+ poster: /* @__PURE__ */ new Set(["video"]),
5282
+ cite: /* @__PURE__ */ new Set([
5279
5283
  "blockquote",
5280
5284
  "del",
5281
5285
  "ins",
5282
5286
  "q"
5283
5287
  ]),
5284
- ping: new Set(["a", "area"])
5288
+ ping: /* @__PURE__ */ new Set(["a", "area"])
5285
5289
  };
5286
5290
  const tagAttributeMap = /* @__PURE__ */ new Map();
5287
5291
  const selectorParts = [];
@@ -5315,8 +5319,8 @@ function stringifySrcset(entries) {
5315
5319
  for (const entry of entries) srcset += entry.descriptor ? `, ${entry.url} ${entry.descriptor}` : `, ${entry.url}`;
5316
5320
  return srcset;
5317
5321
  }
5318
- /** Match placeholders [[ has $ ]] or {{ has $ }} */
5319
- const placeholderRe = /(?:\[\[([^\]]*\$[^\]]*?)\]\]|\{\{([^}]*\$[^}]*?)\}\})/;
5322
+ /** Match placeholders [[ ]] or {{ }} */
5323
+ const placeholderRe = /(?:\[\[([^\]]*[^\]]*?)\]\]|\{\{([^}]*[^}]*?)\}\})/;
5320
5324
  function parseHtmlSources(ast) {
5321
5325
  const links = [];
5322
5326
  for (const node of ast.querySelectorAll(combinedSelector)) {
@@ -5543,12 +5547,12 @@ function coreHtmlPlugin(options = {}) {
5543
5547
  //#endregion
5544
5548
  //#region src/plugins/core-plugins/markdown-metadata/markdown-metadata-plugin.ts
5545
5549
  function coreMarkdownPlugin(options = {}) {
5546
- const allowDangerousHtml = options.allowDangerousHtml ?? false;
5547
- const processor = remark().use(remarkFrontmatter, ["yaml"]).use(remarkGfm).use(remarkBreaks).use(remarkSmartypants).use(options.remarkPlugins ?? []);
5548
- const htmlProcessor = unified().use(remarkRehype, { allowDangerousHtml }).use(rehypeSlug).use(rehypeExternalLinks, {
5550
+ const shouldAllowDangerousHtml = options.allowDangerousHtml ?? false;
5551
+ const processor = remark().use(remarkFrontmatter, ["yaml"]).use(remarkGfm).use(remarkSmartypants).use(options.remarkPlugins ?? []);
5552
+ const htmlProcessor = unified().use(remarkRehype, { allowDangerousHtml: shouldAllowDangerousHtml }).use(rehypeSlug).use(rehypeExternalLinks, {
5549
5553
  target: "_blank",
5550
5554
  rel: ["noopener", "noreferrer"]
5551
- }).use(options.rehypePlugins ?? []).use(rehypeStringify, { allowDangerousHtml });
5555
+ }).use(options.rehypePlugins ?? []).use(rehypeStringify, { allowDangerousHtml: shouldAllowDangerousHtml });
5552
5556
  async function parseMarkdown(code) {
5553
5557
  try {
5554
5558
  const root = processor.parse(code);
@@ -5748,9 +5752,9 @@ function parseScriptSources({ ast }) {
5748
5752
 
5749
5753
  //#endregion
5750
5754
  //#region src/plugins/core-plugins/script-metadata/minify-script.ts
5751
- function minifyScriptSWC(code, module) {
5755
+ function minifyScriptSWC(code, isModule) {
5752
5756
  try {
5753
- const minified = minifySync(code, { module });
5757
+ const minified = minifySync(code, { module: isModule });
5754
5758
  if (!minified.code) return [null, /* @__PURE__ */ new Error("Failed to minify script: empty output")];
5755
5759
  return [minified.code, null];
5756
5760
  } catch (error) {
@@ -5798,8 +5802,9 @@ function scriptLoader(relativePath, code) {
5798
5802
 
5799
5803
  //#endregion
5800
5804
  //#region src/plugins/core-plugins/script-metadata/script-metadata-plugin.ts
5805
+ const generator = typeof _generator === "function" ? _generator : _generator.default;
5801
5806
  function coreScriptPlugin() {
5802
- const jsExtensions = new Set([
5807
+ const jsExtensions = /* @__PURE__ */ new Set([
5803
5808
  ".js",
5804
5809
  ".mjs",
5805
5810
  ".cjs",
@@ -5864,17 +5869,17 @@ function coreScriptPlugin() {
5864
5869
  const cssUrlRe = /url\((['"]?)(.+?)\1\)/gm;
5865
5870
  function parseStyleSources(ast) {
5866
5871
  const handles = [];
5867
- ast.walkDecls((decl) => {
5868
- for (const match of decl.value.matchAll(cssUrlRe)) {
5872
+ ast.walkDecls((declaration) => {
5873
+ for (const match of declaration.value.matchAll(cssUrlRe)) {
5869
5874
  const source = match[2];
5870
5875
  if (!source) continue;
5871
5876
  handles.push({
5872
- node: decl,
5877
+ node: declaration,
5873
5878
  get source() {
5874
5879
  return source;
5875
5880
  },
5876
5881
  set source(newSource) {
5877
- decl.value = decl.value.replace(source, newSource);
5882
+ declaration.value = declaration.value.replace(source, () => newSource);
5878
5883
  }
5879
5884
  });
5880
5885
  }
@@ -5890,7 +5895,7 @@ function parseStyleSources(ast) {
5890
5895
  return source;
5891
5896
  },
5892
5897
  set source(newSource) {
5893
- atRule.params = atRule.params.replace(source, newSource);
5898
+ atRule.params = atRule.params.replace(source, () => newSource);
5894
5899
  }
5895
5900
  });
5896
5901
  }
@@ -6281,8 +6286,8 @@ function orderByDependencyDepth(allMetadata, entryPoints, filePaths) {
6281
6286
  const metadata = metadataById.get(id);
6282
6287
  if (!metadata) continue;
6283
6288
  if (depth >= allMetadata.length) continue;
6284
- for (const depId of metadata.directDependencies) queue.push({
6285
- id: depId,
6289
+ for (const dependencyId of metadata.directDependencies) queue.push({
6290
+ id: dependencyId,
6286
6291
  depth: depth + 1
6287
6292
  });
6288
6293
  }
@@ -6347,7 +6352,7 @@ function developmentServerPlugin(options = {}) {
6347
6352
  this.log.error(error.message);
6348
6353
  throw new Error(error.message);
6349
6354
  }
6350
- this.log.info(c.bold("Server listening on"), c.green(address + entry));
6355
+ this.log.info(chalk.bold("Server listening on"), chalk.green(address + entry));
6351
6356
  });
6352
6357
  websocket.on("connection", () => {
6353
6358
  const sortedByAge = Array.from(entryPointAgeMap).toSorted((a, b) => a[1] - b[1]).map(([id]) => id);
@@ -6372,18 +6377,18 @@ function developmentServerPlugin(options = {}) {
6372
6377
  for (const id of ordered) {
6373
6378
  const oldMetadataList = this.filterMetadata({ id });
6374
6379
  if (oldMetadataList.length === 0) continue;
6375
- const oldDeps = new Set(oldMetadataList.flatMap((m) => Array.from(m.directDependencies)));
6380
+ const oldDependencies = new Set(oldMetadataList.flatMap((m) => Array.from(m.directDependencies)));
6376
6381
  this.removeMetadata(oldMetadataList);
6377
6382
  if (!await this.process(id)) {
6378
6383
  this.addMetadata(oldMetadataList);
6379
6384
  continue;
6380
6385
  }
6381
6386
  const newMetadataList = this.filterMetadata({ id });
6382
- const newDeps = new Set(newMetadataList.flatMap((m) => Array.from(m.directDependencies)));
6383
- const removedDeps = Array.from(oldDeps).filter((dep) => !newDeps.has(dep));
6384
- for (const dep of removedDeps) {
6385
- if (this.metadataList.some((m) => m.directDependencies && m.directDependencies.has(dep))) continue;
6386
- const orphans = this.filterMetadata({ id: dep });
6387
+ const newDependencies = new Set(newMetadataList.flatMap((m) => Array.from(m.directDependencies)));
6388
+ const removedDependencies = Array.from(oldDependencies).filter((dependency) => !newDependencies.has(dependency));
6389
+ for (const dependency of removedDependencies) {
6390
+ if (this.metadataList.some((m) => m.directDependencies && m.directDependencies.has(dependency))) continue;
6391
+ const orphans = this.filterMetadata({ id: dependency });
6387
6392
  if (orphans && orphans.length > 0) this.removeMetadata(orphans);
6388
6393
  }
6389
6394
  if (extname(id) !== ".css") isStyleOnly = false;
@@ -6391,7 +6396,10 @@ function developmentServerPlugin(options = {}) {
6391
6396
  }
6392
6397
  if (isStyleOnly) {
6393
6398
  const rootCssFiles = /* @__PURE__ */ new Set();
6394
- for (const htmlId of affected) for (const meta of this.filterMetadata({ id: htmlId })) for (const dep of meta.directDependencies) if (extname(dep) === ".css") rootCssFiles.add(dep);
6399
+ for (const htmlId of affected) {
6400
+ const metadataListWithId = this.filterMetadata({ id: htmlId });
6401
+ for (const meta of metadataListWithId) for (const dependency of meta.directDependencies) if (extname(dependency) === ".css") rootCssFiles.add(dependency);
6402
+ }
6395
6403
  sendMessageToClients(rootCssFiles.size > 0 ? Array.from(rootCssFiles) : [changedSource]);
6396
6404
  return;
6397
6405
  }
@@ -6431,9 +6439,9 @@ function isDependency(allMetadata, metadata, filePath) {
6431
6439
  visited.add(current);
6432
6440
  const currentMetadata = metadataByPath.get(current);
6433
6441
  if (!currentMetadata) continue;
6434
- for (const dep of currentMetadata.directDependencies) {
6435
- if (dep === filePath) return true;
6436
- if (!visited.has(dep)) queue.push(dep);
6442
+ for (const dependency of currentMetadata.directDependencies) {
6443
+ if (dependency === filePath) return true;
6444
+ if (!visited.has(dependency)) queue.push(dependency);
6437
6445
  }
6438
6446
  }
6439
6447
  return false;
@@ -6457,19 +6465,18 @@ function removeAndPruneOrphans(metadataList, targetId) {
6457
6465
  removed.add(currentId);
6458
6466
  const entries = metadataList.filter((m) => m.id === currentId);
6459
6467
  if (entries.length === 0) continue;
6460
- const deps = new Set(entries.flatMap((m) => [...m.directDependencies]));
6468
+ const dependencies = new Set(entries.flatMap((m) => [...m.directDependencies]));
6461
6469
  for (let index = metadataList.length - 1; index >= 0; index--) if (metadataList[index].id === currentId) metadataList.splice(index, 1);
6462
- for (const depId of deps) if (!metadataList.some((m) => m.directDependencies.has(depId))) queue.push(depId);
6470
+ for (const dependencyId of dependencies) if (!metadataList.some((m) => m.directDependencies.has(dependencyId))) queue.push(dependencyId);
6463
6471
  }
6464
6472
  }
6465
6473
 
6466
6474
  //#endregion
6467
6475
  //#region src/helpers/pirnt-debug.ts
6468
6476
  function formatDuration(ms) {
6469
- if (ms < 1) return c.gray(`${(ms * 1e3).toFixed(2)}μs`);
6470
- else if (ms < 1e3) return (ms < 100 ? c.green : ms < 500 ? c.yellow : c.red)(`${ms.toFixed(2)}ms`);
6471
- else if (ms < 6e4) return c.redBright(`${(ms / 1e3).toFixed(2)}s`);
6472
- else return c.magenta(`${(ms / 6e4).toFixed(2)}m`);
6477
+ if (ms < 1) return chalk.gray(`${(ms * 1e3).toFixed(2)}μs`);
6478
+ if (ms < 1e3) return (ms < 100 ? chalk.green : ms < 500 ? chalk.yellow : chalk.red)(`${ms.toFixed(2)}ms`);
6479
+ return ms < 6e4 ? chalk.redBright(`${(ms / 1e3).toFixed(2)}s`) : chalk.magenta(`${(ms / 6e4).toFixed(2)}m`);
6473
6480
  }
6474
6481
  function buildBar(value, total) {
6475
6482
  const BAR_WIDTH = 16;
@@ -6477,7 +6484,7 @@ function buildBar(value, total) {
6477
6484
  const filled = Math.round(ratio * BAR_WIDTH);
6478
6485
  const empty = BAR_WIDTH - filled;
6479
6486
  const pct = (ratio * 100).toFixed(0).padStart(3);
6480
- return (ratio < .2 ? c.green("█".repeat(filled)) : ratio < .5 ? c.yellow("█".repeat(filled)) : c.red("█".repeat(filled))) + c.dim("░".repeat(empty)) + c.dim(` ${pct}%`);
6487
+ return (ratio < .2 ? chalk.green("█".repeat(filled)) : ratio < .5 ? chalk.yellow("█".repeat(filled)) : chalk.red("█".repeat(filled))) + chalk.dim("░".repeat(empty)) + chalk.dim(` ${pct}%`);
6481
6488
  }
6482
6489
  function printExecutionTime(executionTime) {
6483
6490
  const sortedGroups = Object.entries(executionTime).toSorted(([, a], [, b]) => {
@@ -6489,13 +6496,13 @@ function printExecutionTime(executionTime) {
6489
6496
  const entries = Object.entries(metrics).filter(([, v]) => v >= 1).toSorted(([, a], [, b]) => b - a);
6490
6497
  console.log();
6491
6498
  if (entries.length === 0) {
6492
- console.log(c.bold.cyan("─ ") + c.bold.white(groupName) + c.dim(` total: ${formatDuration(total)}`));
6499
+ console.log(chalk.bold.cyan("─ ") + chalk.bold.white(groupName) + chalk.dim(` total: ${formatDuration(total)}`));
6493
6500
  continue;
6494
6501
  }
6495
6502
  const maxLabelLength = Math.max(...entries.map(([k]) => k.length));
6496
- console.log(c.bold.cyan("─ ") + c.bold.white(groupName) + c.dim(` total: ${formatDuration(total)}`));
6503
+ console.log(chalk.bold.cyan("─ ") + chalk.bold.white(groupName) + chalk.dim(` total: ${formatDuration(total)}`));
6497
6504
  for (const [key, value] of entries) {
6498
- const label = c.dim(key.padEnd(maxLabelLength));
6505
+ const label = chalk.dim(key.padEnd(maxLabelLength));
6499
6506
  const bar = buildBar(value, total);
6500
6507
  const time = formatDuration(value);
6501
6508
  console.log(` ${label} ${bar} ${time}`);
@@ -6541,7 +6548,8 @@ var App = class {
6541
6548
  this.outdir = isAbsolute(options.outdir) ? options.outdir : join(this.root, options.outdir);
6542
6549
  this.browserslist = browserslistFn(options.browserslist, { path: this.root });
6543
6550
  this.resolver = new Resolver(this.root);
6544
- for (const [index, pluginOrPlugins] of (options.plugins ?? []).entries()) {
6551
+ const pluginsEntries = (options.plugins ?? []).entries();
6552
+ for (const [index, pluginOrPlugins] of pluginsEntries) {
6545
6553
  const items = Array.isArray(pluginOrPlugins) ? pluginOrPlugins : [pluginOrPlugins];
6546
6554
  for (const [itemIndex, plugin] of items.entries()) this.plugins.push(this.bindPlugin(plugin, index + itemIndex));
6547
6555
  }
@@ -6718,7 +6726,7 @@ var App = class {
6718
6726
  this.log.error(`[transformAndSync] Plugin index is not set.`);
6719
6727
  return;
6720
6728
  }
6721
- if (!this.plugins[this.pluginIndex]) {
6729
+ if (!Object.hasOwn(this.plugins, this.pluginIndex)) {
6722
6730
  this.log.error(`[transformAndSync] Plugin with index "${this.pluginIndex}" does not exist.`);
6723
6731
  return;
6724
6732
  }
@@ -6787,7 +6795,7 @@ var App = class {
6787
6795
  }
6788
6796
  async getCompileList(event, filePath) {
6789
6797
  filePath = normalize(filePath);
6790
- const compileSet = new Set([filePath]);
6798
+ const compileSet = /* @__PURE__ */ new Set([filePath]);
6791
6799
  for (const plugin of this.plugins) await this.callPluginMethod(plugin, "resolveCompileList", compileSet, event, filePath);
6792
6800
  return compileSet;
6793
6801
  }
@@ -6832,12 +6840,12 @@ var App = class {
6832
6840
  findMetadata(metadataFilter) {
6833
6841
  for (const metadata of this.metadataList) {
6834
6842
  if (metadata === metadataFilter) return metadata;
6835
- let match = true;
6843
+ let isMatch = true;
6836
6844
  for (const [key, value] of Object.entries(metadataFilter)) if (metadata[key] !== value) {
6837
- match = false;
6845
+ isMatch = false;
6838
6846
  break;
6839
6847
  }
6840
- if (match) return metadata;
6848
+ if (isMatch) return metadata;
6841
6849
  }
6842
6850
  }
6843
6851
  filterMetadata(metadataFilter) {
@@ -6866,7 +6874,7 @@ function buildCliPlugin(options = {}) {
6866
6874
  const startTime = performance.now();
6867
6875
  config.production = true;
6868
6876
  await new App(config, configPath).run();
6869
- Log.info(`Built in ${c.bold.green(Math.round(performance.now() - startTime) / 1e3)} seconds.`);
6877
+ Log.info(`Built in ${chalk.bold.green(Math.round(performance.now() - startTime) / 1e3)} seconds.`);
6870
6878
  });
6871
6879
  this.addCommand(buildCommand);
6872
6880
  }
@@ -7137,7 +7145,7 @@ const MathUtilities = {
7137
7145
 
7138
7146
  //#endregion
7139
7147
  //#region src/plugins/cli-plugins/material-you/material-you/cam/hct-solver.ts
7140
- var HctSolver = class HctSolver {
7148
+ var HctSolver = class {
7141
7149
  /** Weights for transforming a set of linear RGB coordinates to Y in XYZ. */
7142
7150
  static Y_FROM_LINRGB = [
7143
7151
  .2126,
@@ -7447,8 +7455,8 @@ var HctSolver = class HctSolver {
7447
7455
  * @returns A degree measure between 0.0 (inclusive) and 360.0 (exclusive).
7448
7456
  */
7449
7457
  static sanitizeDegreesDouble(degrees) {
7450
- degrees = degrees % 360;
7451
- if (degrees < 0) degrees = degrees + 360;
7458
+ degrees %= 360;
7459
+ if (degrees < 0) degrees += 360;
7452
7460
  return degrees;
7453
7461
  }
7454
7462
  /** Equation used in CAM16 conversion that removes the effect of chromatic adaptation. */
@@ -7469,15 +7477,15 @@ var HctSolver = class HctSolver {
7469
7477
  let index = Math.sqrt(y) * 11;
7470
7478
  const viewingConditions = Frame.DEFAULT, tInnerCoeff = 1 / Math.pow(1.64 - Math.pow(.29, viewingConditions.getN()), .73), p1 = .25 * (Math.cos(hueRadians + 2) + 3.8) * (5e4 / 13) * viewingConditions.getNc() * viewingConditions.getNcb(), hSin = Math.sin(hueRadians), hCos = Math.cos(hueRadians);
7471
7479
  for (let iterationRound = 0; iterationRound < 5; iterationRound++) {
7472
- const indexNormalized = index / 100, alpha = chroma === 0 || index === 0 ? 0 : chroma / Math.sqrt(indexNormalized), t = Math.pow(alpha * tInnerCoeff, 1 / .9), acExponent = 1 / viewingConditions.getC() / viewingConditions.getZ(), p2 = viewingConditions.getAw() * Math.pow(indexNormalized, acExponent) / viewingConditions.getNbb(), gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, rCScaled = HctSolver.inverseChromaticAdaptation(rA), gCScaled = HctSolver.inverseChromaticAdaptation(gA), bCScaled = HctSolver.inverseChromaticAdaptation(bA), matrix = HctSolver.LINRGB_FROM_SCALED_DISCOUNT, linrgbR = rCScaled * matrix[0][0] + gCScaled * matrix[0][1] + bCScaled * matrix[0][2], linrgbG = rCScaled * matrix[1][0] + gCScaled * matrix[1][1] + bCScaled * matrix[1][2], linrgbB = rCScaled * matrix[2][0] + gCScaled * matrix[2][1] + bCScaled * matrix[2][2];
7480
+ const indexNormalized = index / 100, alpha = chroma === 0 || index === 0 ? 0 : chroma / Math.sqrt(indexNormalized), t = Math.pow(alpha * tInnerCoeff, 1 / .9), acExponent = 1 / viewingConditions.getC() / viewingConditions.getZ(), p2 = viewingConditions.getAw() * Math.pow(indexNormalized, acExponent) / viewingConditions.getNbb(), gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin), a = gamma * hCos, b = gamma * hSin, rA = (460 * p2 + 451 * a + 288 * b) / 1403, gA = (460 * p2 - 891 * a - 261 * b) / 1403, bA = (460 * p2 - 220 * a - 6300 * b) / 1403, rCScaled = this.inverseChromaticAdaptation(rA), gCScaled = this.inverseChromaticAdaptation(gA), bCScaled = this.inverseChromaticAdaptation(bA), matrix = this.LINRGB_FROM_SCALED_DISCOUNT, linrgbR = rCScaled * matrix[0][0] + gCScaled * matrix[0][1] + bCScaled * matrix[0][2], linrgbG = rCScaled * matrix[1][0] + gCScaled * matrix[1][1] + bCScaled * matrix[1][2], linrgbB = rCScaled * matrix[2][0] + gCScaled * matrix[2][1] + bCScaled * matrix[2][2];
7473
7481
  if (linrgbR < 0 || linrgbG < 0 || linrgbB < 0) return 0;
7474
- const kR = HctSolver.Y_FROM_LINRGB[0], kG = HctSolver.Y_FROM_LINRGB[1], kB = HctSolver.Y_FROM_LINRGB[2], fnj = kR * linrgbR + kG * linrgbG + kB * linrgbB;
7482
+ const kR = this.Y_FROM_LINRGB[0], kG = this.Y_FROM_LINRGB[1], kB = this.Y_FROM_LINRGB[2], fnj = kR * linrgbR + kG * linrgbG + kB * linrgbB;
7475
7483
  if (fnj <= 0) return 0;
7476
7484
  if (iterationRound === 4 || Math.abs(fnj - y) < .002) {
7477
7485
  if (linrgbR > 100.01 || linrgbG > 100.01 || linrgbB > 100.01) return 0;
7478
7486
  return CamUtilities.argbFromLinrgbComponents(linrgbR, linrgbG, linrgbB);
7479
7487
  }
7480
- index = index - (fnj - y) * index / (2 * fnj);
7488
+ index -= (fnj - y) * index / (2 * fnj);
7481
7489
  }
7482
7490
  return 0;
7483
7491
  }
@@ -7492,12 +7500,12 @@ var HctSolver = class HctSolver {
7492
7500
  */
7493
7501
  static solveToInt(hueDegrees, chroma, lstar) {
7494
7502
  if (chroma < 1e-4 || lstar < 1e-4 || lstar > 99.9999) return CamUtilities.argbFromLstar(lstar);
7495
- hueDegrees = HctSolver.sanitizeDegreesDouble(hueDegrees);
7503
+ hueDegrees = this.sanitizeDegreesDouble(hueDegrees);
7496
7504
  const hueRadians = MathUtilities.toRadians(hueDegrees);
7497
7505
  const y = CamUtilities.yFromLstar(lstar);
7498
- const exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);
7506
+ const exactAnswer = this.findResultByJ(hueRadians, chroma, y);
7499
7507
  if (exactAnswer !== 0) return exactAnswer;
7500
- return HctSolver.bisectToLimit(y, hueRadians);
7508
+ return this.bisectToLimit(y, hueRadians);
7501
7509
  }
7502
7510
  /** Ensure X is between 0 and 100. */
7503
7511
  static isBounded(x) {
@@ -7512,12 +7520,12 @@ var HctSolver = class HctSolver {
7512
7520
  * it exists. If the possible vertex lies outside of the cube, [-1.0, -1.0, -1.0] is returned.
7513
7521
  */
7514
7522
  static nthVertex(y, n) {
7515
- const kR = HctSolver.Y_FROM_LINRGB[0], kG = HctSolver.Y_FROM_LINRGB[1], kB = HctSolver.Y_FROM_LINRGB[2], coordA = n % 4 <= 1 ? 0 : 100, coordB = n % 2 === 0 ? 0 : 100;
7523
+ const kR = this.Y_FROM_LINRGB[0], kG = this.Y_FROM_LINRGB[1], kB = this.Y_FROM_LINRGB[2], coordA = n % 4 <= 1 ? 0 : 100, coordB = n % 2 === 0 ? 0 : 100;
7516
7524
  if (n < 4) {
7517
7525
  const g = coordA;
7518
7526
  const b = coordB;
7519
7527
  const r = (y - g * kG - b * kB) / kR;
7520
- return HctSolver.isBounded(r) ? [
7528
+ return this.isBounded(r) ? [
7521
7529
  r,
7522
7530
  g,
7523
7531
  b
@@ -7526,24 +7534,12 @@ var HctSolver = class HctSolver {
7526
7534
  -1,
7527
7535
  -1
7528
7536
  ];
7529
- } else if (n < 8) {
7537
+ }
7538
+ if (n < 8) {
7530
7539
  const b = coordA;
7531
7540
  const r = coordB;
7532
7541
  const g = (y - r * kR - b * kB) / kG;
7533
- return HctSolver.isBounded(g) ? [
7534
- r,
7535
- g,
7536
- b
7537
- ] : [
7538
- -1,
7539
- -1,
7540
- -1
7541
- ];
7542
- } else {
7543
- const r = coordA;
7544
- const g = coordB;
7545
- const b = (y - r * kR - g * kG) / kB;
7546
- return HctSolver.isBounded(b) ? [
7542
+ return this.isBounded(g) ? [
7547
7543
  r,
7548
7544
  g,
7549
7545
  b
@@ -7553,6 +7549,18 @@ var HctSolver = class HctSolver {
7553
7549
  -1
7554
7550
  ];
7555
7551
  }
7552
+ const r = coordA;
7553
+ const g = coordB;
7554
+ const b = (y - r * kR - g * kG) / kB;
7555
+ return this.isBounded(b) ? [
7556
+ r,
7557
+ g,
7558
+ b
7559
+ ] : [
7560
+ -1,
7561
+ -1,
7562
+ -1
7563
+ ];
7556
7564
  }
7557
7565
  static chromaticAdaptation(component) {
7558
7566
  const af = Math.pow(Math.abs(component), .42);
@@ -7565,8 +7573,8 @@ var HctSolver = class HctSolver {
7565
7573
  * @returns The hue of the color in CAM16, in radians.
7566
7574
  */
7567
7575
  static hueOf(linrgb) {
7568
- const matrix = HctSolver.SCALED_DISCOUNT_FROM_LINRGB, row = linrgb, rD = linrgb[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2], gD = linrgb[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2], bD = linrgb[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
7569
- const rA = HctSolver.chromaticAdaptation(rD), gA = HctSolver.chromaticAdaptation(gD), bA = HctSolver.chromaticAdaptation(bD);
7576
+ const matrix = this.SCALED_DISCOUNT_FROM_LINRGB, row = linrgb, rD = linrgb[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2], gD = linrgb[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2], bD = linrgb[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
7577
+ const rA = this.chromaticAdaptation(rD), gA = this.chromaticAdaptation(gD), bA = this.chromaticAdaptation(bD);
7570
7578
  const a = (11 * rA + -12 * gA + bA) / 11;
7571
7579
  const b = (rA + gA - 2 * bA) / 9;
7572
7580
  return Math.atan2(b, a);
@@ -7591,7 +7599,7 @@ var HctSolver = class HctSolver {
7591
7599
  * @returns True if B is between A and C
7592
7600
  */
7593
7601
  static areInCyclicOrder(a, b, c) {
7594
- return HctSolver.sanitizeRadians(b - a) < HctSolver.sanitizeRadians(c - a);
7602
+ return this.sanitizeRadians(b - a) < this.sanitizeRadians(c - a);
7595
7603
  }
7596
7604
  /**
7597
7605
  * Finds the segment containing the desired color.
@@ -7606,22 +7614,22 @@ var HctSolver = class HctSolver {
7606
7614
  -1,
7607
7615
  -1,
7608
7616
  -1
7609
- ], right = left, leftHue = 0, rightHue = 0, initialized = false, uncut = true;
7617
+ ], right = left, leftHue = 0, rightHue = 0, isInitialized = false, isUncut = true;
7610
7618
  for (let n = 0; n < 12; n++) {
7611
- const mid = HctSolver.nthVertex(y, n);
7619
+ const mid = this.nthVertex(y, n);
7612
7620
  if (mid[0] < 0) continue;
7613
- const midHue = HctSolver.hueOf(mid);
7614
- if (!initialized) {
7621
+ const midHue = this.hueOf(mid);
7622
+ if (!isInitialized) {
7615
7623
  left = mid;
7616
7624
  right = mid;
7617
7625
  leftHue = midHue;
7618
7626
  rightHue = midHue;
7619
- initialized = true;
7627
+ isInitialized = true;
7620
7628
  continue;
7621
7629
  }
7622
- if (uncut || HctSolver.areInCyclicOrder(leftHue, midHue, rightHue)) {
7623
- uncut = false;
7624
- if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
7630
+ if (isUncut || this.areInCyclicOrder(leftHue, midHue, rightHue)) {
7631
+ isUncut = false;
7632
+ if (this.areInCyclicOrder(leftHue, targetHue, midHue)) {
7625
7633
  right = mid;
7626
7634
  rightHue = midHue;
7627
7635
  } else {
@@ -7685,8 +7693,8 @@ var HctSolver = class HctSolver {
7685
7693
  * @returns The intersection point of the segment AB with the plane R=coordinate, G=coordinate, or B=coordinate
7686
7694
  */
7687
7695
  static setCoordinate(source, coordinate, target, axis) {
7688
- const t = HctSolver.intercept(source[axis], coordinate, target[axis]);
7689
- return HctSolver.lerpPoint(source, t, target);
7696
+ const t = this.intercept(source[axis], coordinate, target[axis]);
7697
+ return this.lerpPoint(source, t, target);
7690
7698
  }
7691
7699
  /**
7692
7700
  * Finds a color with the given Y and hue on the boundary of the cube.
@@ -7696,25 +7704,26 @@ var HctSolver = class HctSolver {
7696
7704
  * @returns The desired color, in linear RGB coordinates.
7697
7705
  */
7698
7706
  static bisectToLimit(y, targetHue) {
7699
- const segment = HctSolver.bisectToSegment(y, targetHue);
7700
- let left = segment[0], leftHue = HctSolver.hueOf(left), right = segment[1];
7701
- for (let axis = 0; axis < 3; axis++) if (left[axis] !== right[axis]) {
7707
+ const segment = this.bisectToSegment(y, targetHue);
7708
+ let left = segment[0], leftHue = this.hueOf(left), right = segment[1];
7709
+ for (let axis = 0; axis < 3; axis++) {
7710
+ if (left[axis] === right[axis]) continue;
7702
7711
  let lPlane;
7703
7712
  let rPlane;
7704
7713
  if (left[axis] < right[axis]) {
7705
- lPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(left[axis]));
7706
- rPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(right[axis]));
7714
+ lPlane = this.criticalPlaneBelow(this.trueDelinearized(left[axis]));
7715
+ rPlane = this.criticalPlaneAbove(this.trueDelinearized(right[axis]));
7707
7716
  } else {
7708
- lPlane = HctSolver.criticalPlaneAbove(HctSolver.trueDelinearized(left[axis]));
7709
- rPlane = HctSolver.criticalPlaneBelow(HctSolver.trueDelinearized(right[axis]));
7717
+ lPlane = this.criticalPlaneAbove(this.trueDelinearized(left[axis]));
7718
+ rPlane = this.criticalPlaneBelow(this.trueDelinearized(right[axis]));
7710
7719
  }
7711
- for (let index = 0; index < 8; index++) if (Math.abs(rPlane - lPlane) <= 1) break;
7712
- else {
7720
+ for (let index = 0; index < 8; index++) {
7721
+ if (Math.abs(rPlane - lPlane) <= 1) break;
7713
7722
  const mPlane = Math.floor((lPlane + rPlane) / 2);
7714
- const midPlaneCoordinate = HctSolver.CRITICAL_PLANES[mPlane] ?? 0;
7715
- const mid = HctSolver.setCoordinate(left, midPlaneCoordinate, right, axis);
7716
- const midHue = HctSolver.hueOf(mid);
7717
- if (HctSolver.areInCyclicOrder(leftHue, targetHue, midHue)) {
7723
+ const midPlaneCoordinate = this.CRITICAL_PLANES[mPlane] ?? 0;
7724
+ const mid = this.setCoordinate(left, midPlaneCoordinate, right, axis);
7725
+ const midHue = this.hueOf(mid);
7726
+ if (this.areInCyclicOrder(leftHue, targetHue, midHue)) {
7718
7727
  right = mid;
7719
7728
  rPlane = mPlane;
7720
7729
  } else {
@@ -7806,7 +7815,7 @@ var Cam = class Cam {
7806
7815
  * frame.
7807
7816
  */
7808
7817
  static fromJch(index, c, h) {
7809
- return Cam.fromJchInFrame(index, c, h);
7818
+ return this.fromJchInFrame(index, c, h);
7810
7819
  }
7811
7820
  /** Create a CAM from lightness, chroma, and hue coordinates, and also specify the frame in which the color is being viewed. */
7812
7821
  static fromJchInFrame(index, c, h) {
@@ -7851,15 +7860,15 @@ var Cam = class Cam {
7851
7860
  static findCamByJ(hue, chroma, lstar) {
7852
7861
  let low = 0, high = 100, mid, bestdL = 1e3, bestdE = 1e3;
7853
7862
  let bestCam = null;
7854
- while (Math.abs(low - high) > Cam.LIGHTNESS_SEARCH_ENDPOINT) {
7863
+ while (Math.abs(low - high) > this.LIGHTNESS_SEARCH_ENDPOINT) {
7855
7864
  mid = low + (high - low) / 2;
7856
- const clipped = Cam.fromJch(mid, chroma, hue).viewedInSrgb();
7865
+ const clipped = this.fromJch(mid, chroma, hue).viewedInSrgb();
7857
7866
  const clippedLstar = CamUtilities.lstarFromInt(clipped);
7858
7867
  const dL = Math.abs(lstar - clippedLstar);
7859
- if (dL < Cam.DL_MAX) {
7860
- const camClipped = Cam.fromInt(clipped);
7861
- const dE = camClipped.distance(Cam.fromJch(camClipped.getJ(), camClipped.getChroma(), hue));
7862
- if (dE <= Cam.DE_MAX) {
7868
+ if (dL < this.DL_MAX) {
7869
+ const camClipped = this.fromInt(clipped);
7870
+ const dE = camClipped.distance(this.fromJch(camClipped.getJ(), camClipped.getChroma(), hue));
7871
+ if (dE <= this.DE_MAX) {
7863
7872
  bestdL = dL;
7864
7873
  bestdE = dE;
7865
7874
  bestCam = camClipped;
@@ -7876,7 +7885,7 @@ var Cam = class Cam {
7876
7885
  * will, be lower than requested. Assumes the color is viewed in the frame defined by the sRGB standard.
7877
7886
  */
7878
7887
  static getInt(hue, chroma, lstar) {
7879
- return Cam.getInt_(hue, chroma, lstar, Frame.DEFAULT);
7888
+ return this.getInt_(hue, chroma, lstar, Frame.DEFAULT);
7880
7889
  }
7881
7890
  /**
7882
7891
  * Given a hue & chroma in CAM16, L* in L_a_b*, and the frame in which the color will be viewed, return an ARGB integer.
@@ -7894,13 +7903,16 @@ var Cam = class Cam {
7894
7903
  let low = 0;
7895
7904
  let isFirstLoop = true;
7896
7905
  let answer = null;
7897
- while (Math.abs(low - high) >= Cam.CHROMA_SEARCH_ENDPOINT) {
7898
- const possibleAnswer = Cam.findCamByJ(hue, mid, lstar);
7899
- if (isFirstLoop) if (possibleAnswer == void 0) {
7900
- isFirstLoop = false;
7901
- mid = low + (high - low) / 2;
7902
- continue;
7903
- } else return possibleAnswer.viewed(frame);
7906
+ while (Math.abs(low - high) >= this.CHROMA_SEARCH_ENDPOINT) {
7907
+ const possibleAnswer = this.findCamByJ(hue, mid, lstar);
7908
+ if (isFirstLoop) {
7909
+ if (possibleAnswer == void 0) {
7910
+ isFirstLoop = false;
7911
+ mid = low + (high - low) / 2;
7912
+ continue;
7913
+ }
7914
+ return possibleAnswer.viewed(frame);
7915
+ }
7904
7916
  if (possibleAnswer == void 0) high = mid;
7905
7917
  else {
7906
7918
  answer = possibleAnswer;
@@ -7913,10 +7925,10 @@ var Cam = class Cam {
7913
7925
  }
7914
7926
  static intFromLstar(lstar) {
7915
7927
  if (lstar < 1) return 4278190080;
7916
- else if (lstar > 99) return 4294967295;
7928
+ if (lstar > 99) return 4294967295;
7917
7929
  const fy = (lstar + 16) / 116;
7918
7930
  const fz = fy, fx = fy;
7919
- const kappa = 24389 / 27, epsilon = 216 / 24389, yT = lstar > 8 ? fy * fy * fy : lstar / kappa, cubeExceedEpsilon = fy * fy * fy > epsilon, xT = cubeExceedEpsilon ? fx * fx * fx : (116 * fx - 16) / kappa, zT = cubeExceedEpsilon ? fz * fz * fz : (116 * fx - 16) / kappa;
7931
+ const kappa = 24389 / 27, epsilon = 216 / 24389, yT = lstar > 8 ? fy * fy * fy : lstar / kappa, isCubeExceedEpsilon = fy * fy * fy > epsilon, xT = isCubeExceedEpsilon ? fx * fx * fx : (116 * fx - 16) / kappa, zT = isCubeExceedEpsilon ? fz * fz * fz : (116 * fx - 16) / kappa;
7920
7932
  return ColorUtilities.XYZToColor(xT * CamUtilities.WHITE_POINT_D65[0], yT * CamUtilities.WHITE_POINT_D65[1], zT * CamUtilities.WHITE_POINT_D65[2]);
7921
7933
  }
7922
7934
  static fromIntInFrame(argb, frame) {
@@ -7941,7 +7953,7 @@ var Cam = class Cam {
7941
7953
  * defined in the sRGB standard.
7942
7954
  */
7943
7955
  static fromInt(argb) {
7944
- return Cam.fromIntInFrame(argb, Frame.DEFAULT);
7956
+ return this.fromIntInFrame(argb, Frame.DEFAULT);
7945
7957
  }
7946
7958
  };
7947
7959
  /**
@@ -7964,7 +7976,7 @@ var Cam = class Cam {
7964
7976
  * results would be consistent, and reasonably good. It worked." - Fairchild, Color Models and Systems: Handbook of Color
7965
7977
  * Psychology, 2015
7966
7978
  */
7967
- var CamUtilities = class CamUtilities {
7979
+ var CamUtilities = class {
7968
7980
  /**
7969
7981
  * This is a more precise sRGB to XYZ transformation matrix than traditionally used. It was derived using Schlomer's technique
7970
7982
  * of transforming the xyY primaries to XYZ, then applying a correction to ensure mapping from sRGB 1, 1, 1 to the reference
@@ -8051,23 +8063,20 @@ var CamUtilities = class CamUtilities {
8051
8063
  ];
8052
8064
  /** Returns L* from L_a_b*, perceptual luminance, from an ARGB integer (ColorInt). */
8053
8065
  static lstarFromInt(argb) {
8054
- return CamUtilities.lstarFromY(CamUtilities.yFromInt(argb));
8066
+ return this.lstarFromY(this.yFromInt(argb));
8055
8067
  }
8056
8068
  static lstarFromY(y) {
8057
- y = y / 100;
8058
- const element = 216 / 24389;
8059
- let yIntermediate;
8060
- if (y <= element) return 24389 / 27 * y;
8061
- else yIntermediate = Math.cbrt(y);
8062
- return 116 * yIntermediate - 16;
8069
+ y /= 100;
8070
+ if (y <= 216 / 24389) return 24389 / 27 * y;
8071
+ return 116 * Math.cbrt(y) - 16;
8063
8072
  }
8064
8073
  static yFromInt(argb) {
8065
- const r = CamUtilities.linearized(Color.red(argb)), g = CamUtilities.linearized(Color.green(argb)), b = CamUtilities.linearized(Color.blue(argb)), matrix = CamUtilities.SRGB_TO_XYZ;
8074
+ const r = this.linearized(Color.red(argb)), g = this.linearized(Color.green(argb)), b = this.linearized(Color.blue(argb)), matrix = this.SRGB_TO_XYZ;
8066
8075
  return r * matrix[1][0] + g * matrix[1][1] + b * matrix[1][2];
8067
8076
  }
8068
8077
  static xyzFromInt(argb) {
8069
- const r = CamUtilities.linearized(Color.red(argb)), g = CamUtilities.linearized(Color.green(argb)), b = CamUtilities.linearized(Color.blue(argb));
8070
- const matrix = CamUtilities.SRGB_TO_XYZ;
8078
+ const r = this.linearized(Color.red(argb)), g = this.linearized(Color.green(argb)), b = this.linearized(Color.blue(argb));
8079
+ const matrix = this.SRGB_TO_XYZ;
8071
8080
  return [
8072
8081
  r * matrix[0][0] + g * matrix[0][1] + b * matrix[0][2],
8073
8082
  r * matrix[1][0] + g * matrix[1][1] + b * matrix[1][2],
@@ -8098,7 +8107,7 @@ var CamUtilities = class CamUtilities {
8098
8107
  */
8099
8108
  static clampInt(min, max, input) {
8100
8109
  if (input < min) return min;
8101
- else if (input > max) return max;
8110
+ if (input > max) return max;
8102
8111
  return input;
8103
8112
  }
8104
8113
  /**
@@ -8110,7 +8119,7 @@ var CamUtilities = class CamUtilities {
8110
8119
  static delinearized(rgbComponent) {
8111
8120
  const normalized = rgbComponent / 100;
8112
8121
  const delinearized = normalized <= .0031308 ? normalized * 12.92 : 1.055 * Math.pow(normalized, 1 / 2.4) - .055;
8113
- return CamUtilities.clampInt(0, 255, Math.round(delinearized * 255));
8122
+ return this.clampInt(0, 255, Math.round(delinearized * 255));
8114
8123
  }
8115
8124
  /** Converts a color from RGB components to ARGB format. */
8116
8125
  static argbFromRgb(red, green, blue) {
@@ -8118,8 +8127,8 @@ var CamUtilities = class CamUtilities {
8118
8127
  }
8119
8128
  /** Converts a color from ARGB to XYZ. */
8120
8129
  static argbFromXyz(x, y, z) {
8121
- const matrix = CamUtilities.XYZ_TO_SRGB, linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z, linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z, linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z, r = CamUtilities.delinearized(linearR), g = CamUtilities.delinearized(linearG), b = CamUtilities.delinearized(linearB);
8122
- return CamUtilities.argbFromRgb(r, g, b);
8130
+ const matrix = this.XYZ_TO_SRGB, linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z, linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z, linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z, r = this.delinearized(linearR), g = this.delinearized(linearG), b = this.delinearized(linearB);
8131
+ return this.argbFromRgb(r, g, b);
8123
8132
  }
8124
8133
  /**
8125
8134
  * Convert a color appearance model representation to an ARGB color.
@@ -8142,12 +8151,12 @@ var CamUtilities = class CamUtilities {
8142
8151
  * @returns ARGB representation of grayscale color with lightness matching L*
8143
8152
  */
8144
8153
  static argbFromLstar(lstar) {
8145
- const fy = (lstar + 16) / 116, fz = fy, fx = fy, kappa = 24389 / 27, epsilon = 216 / 24389, y = lstar > 8 ? fy * fy * fy : lstar / kappa, cubeExceedEpsilon = fy * fy * fy > epsilon, x = cubeExceedEpsilon ? fx * fx * fx : lstar / kappa, z = cubeExceedEpsilon ? fz * fz * fz : lstar / kappa, whitePoint = CamUtilities.WHITE_POINT_D65;
8146
- return CamUtilities.argbFromXyz(x * whitePoint[0], y * whitePoint[1], z * whitePoint[2]);
8154
+ const fy = (lstar + 16) / 116, fz = fy, fx = fy, kappa = 24389 / 27, epsilon = 216 / 24389, y = lstar > 8 ? fy * fy * fy : lstar / kappa, isCubeExceedEpsilon = fy * fy * fy > epsilon, x = isCubeExceedEpsilon ? fx * fx * fx : lstar / kappa, z = isCubeExceedEpsilon ? fz * fz * fz : lstar / kappa, whitePoint = this.WHITE_POINT_D65;
8155
+ return this.argbFromXyz(x * whitePoint[0], y * whitePoint[1], z * whitePoint[2]);
8147
8156
  }
8148
8157
  /** Converts a color from linear RGB components to ARGB format. */
8149
8158
  static argbFromLinrgbComponents(r, g, b) {
8150
- return CamUtilities.argbFromRgb(CamUtilities.delinearized(r), CamUtilities.delinearized(g), CamUtilities.delinearized(b));
8159
+ return this.argbFromRgb(this.delinearized(r), this.delinearized(g), this.delinearized(b));
8151
8160
  }
8152
8161
  /**
8153
8162
  * The signum function.
@@ -8156,22 +8165,21 @@ var CamUtilities = class CamUtilities {
8156
8165
  */
8157
8166
  static signum(number_) {
8158
8167
  if (number_ < 0) return -1;
8159
- else if (number_ === 0) return 0;
8160
- else return 1;
8168
+ return number_ === 0 ? 0 : 1;
8161
8169
  }
8162
8170
  static intFromLstar(lstar) {
8163
8171
  if (lstar < 1) return 4278190080;
8164
- else if (lstar > 99) return 4294967295;
8172
+ if (lstar > 99) return 4294967295;
8165
8173
  const fy = (lstar + 16) / 116;
8166
8174
  const fz = fy;
8167
8175
  const fx = fy;
8168
8176
  const kappa = 24389 / 27;
8169
8177
  const epsilon = 216 / 24389;
8170
8178
  const yT = lstar > 8 ? fy * fy * fy : lstar / kappa;
8171
- const cubeExceedEpsilon = fy * fy * fy > epsilon;
8172
- const xT = cubeExceedEpsilon ? fx * fx * fx : (116 * fx - 16) / kappa;
8173
- const zT = cubeExceedEpsilon ? fz * fz * fz : (116 * fx - 16) / kappa;
8174
- return ColorUtilities.XYZToColor(xT * CamUtilities.WHITE_POINT_D65[0], yT * CamUtilities.WHITE_POINT_D65[1], zT * CamUtilities.WHITE_POINT_D65[2]);
8179
+ const isCubeExceedEpsilon = fy * fy * fy > epsilon;
8180
+ const xT = isCubeExceedEpsilon ? fx * fx * fx : (116 * fx - 16) / kappa;
8181
+ const zT = isCubeExceedEpsilon ? fz * fz * fz : (116 * fx - 16) / kappa;
8182
+ return ColorUtilities.XYZToColor(xT * this.WHITE_POINT_D65[0], yT * this.WHITE_POINT_D65[1], zT * this.WHITE_POINT_D65[2]);
8175
8183
  }
8176
8184
  };
8177
8185
  /**
@@ -8238,11 +8246,11 @@ var Frame = class Frame {
8238
8246
  getN() {
8239
8247
  return this.mN;
8240
8248
  }
8241
- static make(whitepoint, adaptingLuminance, backgroundLstar, surround, discountingIlluminant) {
8249
+ static make(whitepoint, adaptingLuminance, backgroundLstar, surround, shouldDiscountingIlluminant) {
8242
8250
  const matrix = CamUtilities.XYZ_TO_CAM16RGB, xyz = whitepoint, rW = xyz[0] * matrix[0][0] + xyz[1] * matrix[0][1] + xyz[2] * matrix[0][2], gW = xyz[0] * matrix[1][0] + xyz[1] * matrix[1][1] + xyz[2] * matrix[1][2], bW = xyz[0] * matrix[2][0] + xyz[1] * matrix[2][1] + xyz[2] * matrix[2][2];
8243
8251
  const f = .8 + surround / 10;
8244
8252
  const c = f >= .9 ? MathUtilities.lerp(.59, .69, (f - .9) * 10) : MathUtilities.lerp(.525, .59, (f - .8) * 10);
8245
- let d = discountingIlluminant ? 1 : f * (1 - 1 / 3.6 * Math.exp((-adaptingLuminance - 42) / 92));
8253
+ let d = shouldDiscountingIlluminant ? 1 : f * (1 - 1 / 3.6 * Math.exp((-adaptingLuminance - 42) / 92));
8246
8254
  d = d > 1 ? 1 : Math.max(d, 0);
8247
8255
  const nc = f;
8248
8256
  const rgbD = [
@@ -8473,8 +8481,7 @@ const Palette = {
8473
8481
  },
8474
8482
  wrapDegreesDouble(degrees) {
8475
8483
  if (degrees < 0) return degrees % 360 + 360;
8476
- else if (degrees >= 360) return degrees % 360;
8477
- else return degrees;
8484
+ return degrees >= 360 ? degrees % 360 : degrees;
8478
8485
  },
8479
8486
  generate(seed, style = "TONAL_SPOT") {
8480
8487
  seed = seed.toUpperCase().slice(1, 7);
@@ -8553,8 +8560,7 @@ function materialYouCliPlugin(options = {}) {
8553
8560
  materialYouPaletteCommand.onExecute(async (result) => {
8554
8561
  const { color, style, format, raw } = result.options;
8555
8562
  if (!isHexColor(color)) {
8556
- console.error(`Invalid color: ${color}
8557
- Only HEX colors \`#RRGGBB\` are supported.`);
8563
+ console.error(`Invalid color: ${color}\nOnly HEX colors \`#RRGGBB\` are supported.`);
8558
8564
  return;
8559
8565
  }
8560
8566
  const palette = generateMaterialYouPalette(color, style);