@staticbolt/core 1.0.0-beta.3 → 1.0.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.mts CHANGED
@@ -1,21 +1,18 @@
1
- import { basename, extname, isAbsolute, parse, resolve } from "node:path";
2
- import { Document, HTMLElement, HTMLElement as HTMLElement$1, Node } from "@staticbolt/node-html-parser";
3
- import postcss, { Node as Node$1, Postcss } from "postcss";
4
- import { NodePath as NodePath$1 } from "@babel/traverse";
5
1
  import { ObjectEncodingOptions, OpenMode, PathLike, PathOrFileDescriptor } from "node:fs";
2
+ import { basename, extname, isAbsolute, parse as parse$1, resolve } from "node:path";
6
3
  import { FileHandle } from "node:fs/promises";
7
- import * as t from "@babel/types";
4
+ import { Document, HTMLElement, HTMLElement as HTMLElement$1, Node } from "@staticbolt/node-html-parser";
5
+ import postcss, { Node as Node$1, Postcss } from "postcss";
6
+ import { NodePath, NodePath as NodePath$1 } from "@babel/traverse";
8
7
  import { Node as Node$2 } from "@babel/types";
9
8
  import { ParseResult } from "@babel/parser";
10
9
  import { onRequestHookHandler } from "fastify";
11
- import { FSWatcher } from "chokidar";
12
10
  import * as z from "zod";
13
- import * as _$_staticbolt_args_parser0 from "@staticbolt/args-parser";
11
+ import { FSWatcher } from "chokidar";
14
12
  import { Argument, Option, Subcommand, defineArguments, defineOptions, defineSubcommand } from "@staticbolt/args-parser";
15
- import { App as App$1, AppConfig as AppConfig$1, BabelAst as BabelAst$1, BinaryAssetMetadata as BinaryAssetMetadata$1, CliProgram as CliProgram$1, Document as Document$1, HTMLElement as HTMLElement$2, HtmlMetadata as HtmlMetadata$1, MarkdownAst as MarkdownAst$1, MarkdownMetadata as MarkdownMetadata$1, MetadataBase as MetadataBase$1, MetadataSource as MetadataSource$1, PackageMetadata as PackageMetadata$1, Plugin as Plugin$1, PostcssAst as PostcssAst$1, ScriptMetadata as ScriptMetadata$1, ServerReply as ServerReply$1, ServerRequest as ServerRequest$1, StyleMetadata as StyleMetadata$1, SvgMetadata as SvgMetadata$1, TextAssetMetadata as TextAssetMetadata$1, WebManifestMetadata as WebManifestMetadata$1 } from "@staticbolt/core";
13
+ import { App as App$1, AppConfig as AppConfig$1, BabelAst as BabelAst$1, BinaryAssetMetadata as BinaryAssetMetadata$1, CliProgram as CliProgram$1, Document as Document$1, HTMLElement as HTMLElement$2, HtmlMetadata as HtmlMetadata$1, MarkdownAst as MarkdownAst$1, MarkdownMetadata as MarkdownMetadata$1, MetadataBase as MetadataBase$1, MetadataSource as MetadataSource$1, PackageMetadata as PackageMetadata$1, Plugin as Plugin$1, PostcssAst as PostcssAst$1, ScriptMetadata as ScriptMetadata$1, ServerReply as ServerReply$1, ServerRequest as ServerRequest$1, StringifyOptions as StringifyOptions$1, StyleMetadata as StyleMetadata$1, SvgMetadata as SvgMetadata$1, TextAssetMetadata as TextAssetMetadata$1, WebManifestMetadata as WebManifestMetadata$1 } from "@staticbolt/core";
16
14
  import { ImageResource, WebAppManifest } from "web-app-manifest";
17
15
  import { Abortable } from "node:events";
18
-
19
16
  //#region ../../node_modules/@types/unist/index.d.ts
20
17
  // ## Interfaces
21
18
  /**
@@ -1049,7 +1046,6 @@ interface Yaml extends Literal {
1049
1046
  interface YamlData extends Data {}
1050
1047
  //#endregion
1051
1048
  //#region src/types/common.d.ts
1052
- type NodePath<T = t.Node | null | undefined> = NodePath$1<T>;
1053
1049
  type BabelAst = ParseResult;
1054
1050
  type PostcssAst = postcss.Root;
1055
1051
  interface MarkdownAst {
@@ -1058,272 +1054,55 @@ interface MarkdownAst {
1058
1054
  render(): Promise<string>;
1059
1055
  }
1060
1056
  declare const CUSTOM_ATTRIBUTES: Readonly<{
1061
- /** For script and style tags to grab the metadata */MetadataID: "data-metadata-id";
1057
+ /** For script and style tags to grab the metadata */
1058
+ MetadataID: "data-metadata-id";
1062
1059
  }>;
1063
1060
  declare const CONFIG_FILE_NAME = ".staticbolt.ts";
1064
1061
  interface AppConfig {
1065
- root?: string;
1066
- plugins?: (Plugin$1[] | Plugin$1)[];
1067
- outdir?: string;
1068
- production?: boolean;
1069
- browserslist?: string[];
1070
- }
1071
- //#endregion
1072
- //#region src/resolver/resolver.d.ts
1073
- type ResolveResult$1 = {
1074
- path: string;
1075
- suffix: string;
1076
- isDirAlias?: boolean;
1077
- isFileAlias?: boolean;
1078
- isPackage?: boolean;
1079
- exists: boolean;
1080
- };
1081
- declare class Resolver {
1082
- root: string;
1083
- aliases: Record<string, string>;
1084
- notFound: Set<string>;
1085
- files: Set<string>;
1086
- directories: Set<string>;
1087
- static JS_EXTENSIONS: Set<string>;
1088
- static HTML_EXTENSIONS: Set<string>;
1089
- constructor(root: string);
1090
- resolve(sourceOrLink: string, filePath: string): ResolveResult$1 | undefined;
1091
- resolveAlias(source: string): string | undefined;
1092
- normalize(filePath: string): string;
1093
- static isFile(filePath: string): boolean;
1094
- /** Aliased path to path */
1095
- static resolvePathAlias(filePath: string, aliases: Record<string, string>): string | undefined;
1096
- /** Path to aliased path */
1097
- static resolveAliasPath(filePath: string, aliases: Record<string, string>): string;
1098
- /** Path to aliased path */
1099
- aliasPath(filePath: string): string;
1100
- findFile(filePath: string, checkDirectory?: boolean): string | undefined;
1101
- }
1102
- //#endregion
1103
- //#region src/main.d.ts
1104
- declare class App {
1105
- readonly configPath: string;
1106
- /** The absolute path to the project root. */
1107
- readonly root: string;
1108
- /** The absolute path to the output directory. */
1109
- readonly outdir: string;
1110
- /** Whether the application is running in production mode. */
1111
- readonly production: boolean;
1112
- /** A list of browsers to target. */
1113
- readonly browserslist: string[];
1114
- readonly metadataList: MetadataBase$1[];
1115
- private readonly plugins;
1116
- readonly resolver: Resolver;
1117
- log: {
1118
- (...messages: unknown[]): void;
1119
- warn(...messages: string[]): void;
1120
- success(...messages: string[]): void;
1121
- error(...messages: string[]): void;
1122
- fatal(...messages: string[]): never;
1123
- info(...messages: string[]): void;
1124
- tip(...messages: string[]): void;
1125
- debug(...messages: string[]): void;
1126
- enableVerbose(enabled: boolean): void;
1127
- setVerboseFilter(filter: RegExp): void;
1128
- };
1129
- /** File paths to load as sources. */
1130
- readonly entryPoints: Set<string>;
1131
- /** Any type of data for plugins to use. */
1132
- readonly pluginData: Record<string, unknown>;
1133
- /** Exclude paths from being emitted. */
1134
- readonly emitExclude: Set<MetadataBase$1>;
1135
- /** Chokidar watcher. */
1136
- readonly watcher: FSWatcher | undefined;
1137
- private isPluginInitialized;
1138
- private measureExecutionTime;
1139
- private executionTime;
1140
- readonly pluginIndex: number;
1141
- readonly pluginName: string;
1142
- constructor(options: AppConfig$1 | undefined, configPath: string);
1143
- private bindPlugin;
1144
- private callPluginMethod;
1145
- private emitFileChange;
1146
- run(): Promise<void>;
1147
- process(id: string): Promise<void>;
1148
- resolve(metadata: MetadataBase$1): Promise<Set<string>>;
1149
- /**
1150
- * Resolve and load recursively
1151
- *
1152
- * 1. Resolves given metadata item or list
1153
- * 2. Loads discovered dependencies if not already loaded skipping entry points
1154
- * 3. Returns metadata list
1155
- */
1156
- resolveAndLoad(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<MetadataBase$1[]>;
1157
- transform(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<void>;
1158
- transformAndSync(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<void>;
1159
- rebase(metadata: MetadataBase$1, newAbsolutePath: string): Promise<void>;
1160
- writeFiles(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<void>;
1161
- read(filePath: string): Promise<string | undefined>;
1162
- load(relativePath: string, options?: {
1163
- code?: string;
1164
- type?: string;
1165
- }): Promise<MetadataBase$1 | undefined>;
1166
- requestSources(metadata: MetadataBase$1): Promise<MetadataSource$1[]>;
1167
- stringify(metadata: MetadataBase$1, options?: {
1168
- minify?: boolean;
1169
- format?: boolean;
1170
- }): Promise<string>;
1171
- getCompileList(event: "change" | "add" | "unlink", filePath: string): Promise<Set<string>>;
1172
- handleRequest(requestPath: string, reply: ServerReply$1, request: ServerRequest$1): Promise<true | undefined>;
1173
- resolveRequestPath(requestPath: string): Promise<string>;
1174
- clone<T extends MetadataBase$1>(metadata: T): T;
1175
- addMetadata(itemOrList: MetadataBase$1 | MetadataBase$1[]): void;
1176
- removeMetadata(metadataOrIndex: MetadataBase$1 | MetadataBase$1[] | number): void;
1177
- findMetadata<T extends MetadataBase$1>(metadataFilter: Partial<T>): T | undefined;
1178
- filterMetadata<T extends MetadataBase$1>(metadataFilter: Partial<T>): T[];
1179
- }
1180
- //#endregion
1181
- //#region src/types/plugin.d.ts
1182
- type FastifyHandlerParameters = Parameters<onRequestHookHandler>;
1183
- type ServerReply = FastifyHandlerParameters[1];
1184
- type ServerRequest = FastifyHandlerParameters[0];
1185
- interface MetadataSource {
1186
- get source(): string;
1187
- set source(value: string);
1188
- node?: HTMLElement$1 | NodePath$1 | Postcss["AtRule"] | Postcss["Declaration"] | ImageResource | object;
1189
- }
1190
- interface ResolveResult {
1191
- source: string;
1192
- dependencyID?: string;
1193
- }
1194
- interface Plugin {
1195
- name: string;
1196
- setup?: (this: App$1) => void | Promise<void>;
1197
- read?: (this: App$1, absolutePath: string) => string | void | Promise<string | void>;
1198
- load?: (this: App$1, content: string, relativePath: string, options: {
1199
- type?: string;
1200
- }) => MetadataBase$1 | null | void | Promise<MetadataBase$1 | null | void>;
1201
- resolveSource?: (this: App$1, source: string, filePath: string, parentMetadata: MetadataBase$1) => ResolveResult | void | Promise<ResolveResult | void>;
1202
- transformSource?: (this: App$1, source: string, filePath: string, parentMetadata: MetadataBase$1) => string | void | Promise<string | void>;
1203
- preTransform?: (this: App$1) => void | Promise<void>;
1204
- transform?: (this: App$1, metadata: MetadataBase$1) => void | Promise<void>;
1205
- postTransform?: (this: App$1) => void | Promise<void>;
1206
- write?: (this: App$1, metadata: MetadataBase$1) => void | Promise<void>;
1207
- postBuild?: (this: App$1) => void | Promise<void>;
1208
- clone?: (this: App$1, metadata: MetadataBase$1) => void | MetadataBase$1;
1209
- stringify?: (this: App$1, metadata: MetadataBase$1, options: {
1210
- minify?: boolean;
1211
- format?: boolean;
1212
- }) => void | string | Promise<string | void>;
1213
- sourcesProvider?: (this: App$1, metadata: MetadataBase$1) => MetadataSource[] | void | Promise<MetadataSource[] | void>;
1214
- rebaseSource?: (this: App$1, source: string, filePath: string, newAbsolutePath: string) => string | void | Promise<string | void>;
1215
- onMetadataRebase?: (this: App$1, metadata: MetadataBase$1, oldAbsolutePath: string, newAbsolutePath: string) => void | Promise<void>;
1216
- handleRequest?: (this: App$1, requestPath: string, reply: ServerReply, request: ServerRequest) => boolean | void | Promise<boolean | void>;
1217
- resolveRequestPath?: (this: App$1, requestPath: string) => string | void | Promise<string | void>;
1218
- onFileEvent?: (this: App$1, event: "change" | "add" | "unlink", filePath: string) => void | Promise<void>;
1219
- resolveCompileList?: (this: App$1, compileSet: Set<string>, event: "change" | "add" | "unlink", filePath: string) => void | Promise<void>;
1220
- cli?: (this: CliProgram$1, config: AppConfig$1, configPath: string) => void | Promise<void>;
1221
- }
1222
- type RemoveThis<T> = Required<{ [K in keyof T]: T[K] extends ((this: App$1, ...arguments_: infer A) => infer R) | undefined ? (...arguments_: A) => R : T[K] }>;
1223
- type BoundPlugin = RemoveThis<Plugin>;
1224
- //#endregion
1225
- //#region src/types/metadata.d.ts
1226
- declare const METADATA_TYPES: Readonly<{
1227
- Script: "Script";
1228
- HTML: "Html";
1229
- Markdown: "Markdown";
1230
- CSS: "Style";
1231
- SVG: "Svg";
1232
- Package: "Package";
1233
- TextAsset: "TextAsset";
1234
- BinaryAsset: "BinaryAsset";
1235
- WebAppManifest: "WebAppManifest";
1236
- }>;
1237
- type MetadataTypes = (typeof METADATA_TYPES)[keyof typeof METADATA_TYPES];
1238
- interface MetadataBase {
1239
- readonly type: `${Capitalize<string>}${string}`;
1240
1062
  /**
1241
- * Relative path of the source file.
1063
+ * The project root. Relative paths in the config are resolved against it.
1242
1064
  *
1243
- * Initially identical to `originalSource` when the metadata is created. During the build process, this value may change (e.g.,
1244
- * if the file is moved to a different location and its links are rebased).
1065
+ * @default process.cwd()
1245
1066
  */
1246
- filePath: string;
1067
+ root?: string;
1068
+ /** Plugins to run, in order. Nested arrays are flattened, so a plugin preset can be spread in as a single entry. */
1069
+ plugins?: (Plugin$1[] | Plugin$1)[];
1247
1070
  /**
1248
- * Original relative path of the source file.
1071
+ * The output directory, either absolute or relative to {@link AppConfig.root}.
1249
1072
  *
1250
- * Set when the metadata is created and never modified.
1073
+ * @default "./dist"
1251
1074
  */
1252
- readonly id: string;
1253
- readonly directDependencies: Set<string>;
1254
- }
1255
- interface ScriptMetadata extends MetadataBase {
1256
- readonly type: (typeof METADATA_TYPES)["Script"];
1075
+ outdir?: string;
1257
1076
  /**
1258
- * The Babel AST for the script.
1077
+ * Whether to build for production. In development the project is watched for file changes.
1259
1078
  *
1260
- * Mutated during the build process and always represents the file's current transformed state.
1079
+ * @default false
1261
1080
  */
1262
- ast: BabelAst$1;
1263
- /** Whether the script is a module or global */
1264
- module: boolean;
1265
- }
1266
- interface StyleMetadata extends MetadataBase {
1267
- readonly type: (typeof METADATA_TYPES)["CSS"];
1081
+ production?: boolean;
1268
1082
  /**
1269
- * The PostCSS root after transformation
1083
+ * Browsers to target, as [browserslist](https://github.com/browserslist/browserslist) queries. Defaults to the project's
1084
+ * browserslist configuration.
1270
1085
  *
1271
- * Mutated during the build process and always represents the file's current transformed state.
1086
+ * @example
1087
+ * ["last 2 Chrome versions", "last 2 Safari versions"];
1272
1088
  */
1273
- ast: PostcssAst$1;
1274
- }
1275
- interface HtmlMetadata extends MetadataBase {
1276
- type: (typeof METADATA_TYPES)["HTML"];
1089
+ browserslist?: string[];
1277
1090
  /**
1278
- * The HTML AST (root element).
1091
+ * Whether to time each plugin hook and print a breakdown when the build finishes.
1279
1092
  *
1280
- * Mutated during the build process and always represents the file's current transformed state
1093
+ * @default false
1281
1094
  */
1282
- ast: Document$1;
1283
- /** The transformed ASTs from script tags. The key is the UUID */
1284
- scriptsMetadataList: Map<string, ScriptMetadata>;
1285
- /** The transformed ASTs from script tags. The key is the UUID */
1286
- stylesMetadataList: Map<string, StyleMetadata>;
1287
- }
1288
- interface SvgMetadata extends MetadataBase {
1289
- type: (typeof METADATA_TYPES)["SVG"];
1095
+ measureExecutionTime?: boolean;
1290
1096
  /**
1291
- * The HTML AST (root element).
1097
+ * Path aliases, merged on top of the ones resolved from `tsconfig.json` — entries defined here win on key conflicts.
1292
1098
  *
1293
- * Mutated during the build process and always represents the file's current transformed state
1294
- */
1295
- ast: Document$1;
1296
- /** The transformed ASTs from script tags. The key is the UUID */
1297
- stylesMetadataList: Map<string, StyleMetadata>;
1298
- }
1299
- interface MarkdownMetadata extends MetadataBase {
1300
- type: (typeof METADATA_TYPES)["Markdown"];
1301
- /**
1302
- * Markdown tokens and frontmatter.
1099
+ * Keys ending with `/` are directory aliases, otherwise the key is matched as a whole. Values are resolved relative to the
1100
+ * project root.
1303
1101
  *
1304
- * Mutated during the build process and always represents the file's current transformed state
1102
+ * @example
1103
+ * { "~/": "./src/", "@config": "./src/config.ts" }
1305
1104
  */
1306
- ast: MarkdownAst$1;
1307
- }
1308
- interface WebManifestMetadata extends MetadataBase {
1309
- type: (typeof METADATA_TYPES)["WebAppManifest"];
1310
- ast: WebAppManifest;
1311
- }
1312
- interface PackageMetadata extends MetadataBase {
1313
- type: (typeof METADATA_TYPES)["Package"];
1314
- /** Metadata code */
1315
- code: string;
1316
- packageName: string;
1317
- }
1318
- interface TextAssetMetadata extends MetadataBase {
1319
- type: (typeof METADATA_TYPES)["TextAsset"];
1320
- /** Metadata code */
1321
- code: string;
1322
- }
1323
- interface BinaryAssetMetadata extends MetadataBase {
1324
- type: (typeof METADATA_TYPES)["BinaryAsset"];
1325
- /** Raw binary content — images, fonts, wasm, etc. */
1326
- data?: Uint8Array;
1105
+ aliases?: Record<string, string>;
1327
1106
  }
1328
1107
  //#endregion
1329
1108
  //#region src/cli/cli.d.ts
@@ -1336,6 +1115,20 @@ declare class CliProgram {
1336
1115
  example: string;
1337
1116
  };
1338
1117
  options: {
1118
+ cwd: {
1119
+ schema: z.ZodOptional<z.ZodString>;
1120
+ meta: {
1121
+ placeholder: string;
1122
+ description: string;
1123
+ };
1124
+ };
1125
+ config: {
1126
+ schema: z.ZodOptional<z.ZodString>;
1127
+ meta: {
1128
+ placeholder: string;
1129
+ description: string;
1130
+ };
1131
+ };
1339
1132
  help: {
1340
1133
  aliases: string[];
1341
1134
  schema: z.ZodOptional<z.ZodBoolean>;
@@ -1362,6 +1155,8 @@ declare class CliProgram {
1362
1155
  onExecute: (handler: (data: {
1363
1156
  subcommand: undefined;
1364
1157
  options: {
1158
+ cwd?: string | undefined;
1159
+ config?: string | undefined;
1365
1160
  help?: boolean | undefined;
1366
1161
  version?: boolean | undefined;
1367
1162
  };
@@ -1370,8 +1165,10 @@ declare class CliProgram {
1370
1165
  context: {
1371
1166
  subcommand: undefined;
1372
1167
  options: {
1373
- help: _$_staticbolt_args_parser0.OptionContext<z.ZodOptional<z.ZodBoolean>>;
1374
- version: _$_staticbolt_args_parser0.OptionContext<z.ZodOptional<z.ZodBoolean>>;
1168
+ cwd: import("@staticbolt/args-parser").OptionContext<z.ZodOptional<z.ZodString>>;
1169
+ config: import("@staticbolt/args-parser").OptionContext<z.ZodOptional<z.ZodString>>;
1170
+ help: import("@staticbolt/args-parser").OptionContext<z.ZodOptional<z.ZodBoolean>>;
1171
+ version: import("@staticbolt/args-parser").OptionContext<z.ZodOptional<z.ZodBoolean>>;
1375
1172
  };
1376
1173
  arguments: never;
1377
1174
  positionals: never;
@@ -1379,6 +1176,8 @@ declare class CliProgram {
1379
1176
  }) => void) => () => void;
1380
1177
  execute: (input?: {
1381
1178
  options?: {
1179
+ cwd?: string | undefined;
1180
+ config?: string | undefined;
1382
1181
  help?: boolean | undefined;
1383
1182
  version?: boolean | undefined;
1384
1183
  } | undefined;
@@ -1387,21 +1186,37 @@ declare class CliProgram {
1387
1186
  } | undefined) => void;
1388
1187
  executeAsync: (input?: {
1389
1188
  options?: {
1189
+ cwd?: string | undefined;
1190
+ config?: string | undefined;
1390
1191
  help?: boolean | undefined;
1391
1192
  version?: boolean | undefined;
1392
1193
  } | undefined;
1393
1194
  arguments?: undefined;
1394
1195
  positionals?: undefined;
1395
1196
  } | undefined) => Promise<void>;
1396
- generateCliHelpMessage?: ((options?: _$_staticbolt_args_parser0.PrintHelpOptions) => string) | undefined;
1397
- generateSubcommandHelpMessage?: ((subcommandName: string & {}, options?: _$_staticbolt_args_parser0.PrintHelpOptions) => string) | undefined;
1398
- run: (input: string | string[]) => _$_staticbolt_args_parser0.CliParseResult<{
1197
+ generateCliHelpMessage?: ((options?: import("@staticbolt/args-parser").PrintHelpOptions) => string) | undefined;
1198
+ generateSubcommandHelpMessage?: ((subcommandName: string & {}, options?: import("@staticbolt/args-parser").PrintHelpOptions) => string) | undefined;
1199
+ run: (input: string | string[]) => import("@staticbolt/args-parser").CliParseResult<{
1399
1200
  cliName: "staticbolt";
1400
1201
  meta: {
1401
1202
  description: string;
1402
1203
  example: string;
1403
1204
  };
1404
1205
  options: {
1206
+ cwd: {
1207
+ schema: z.ZodOptional<z.ZodString>;
1208
+ meta: {
1209
+ placeholder: string;
1210
+ description: string;
1211
+ };
1212
+ };
1213
+ config: {
1214
+ schema: z.ZodOptional<z.ZodString>;
1215
+ meta: {
1216
+ placeholder: string;
1217
+ description: string;
1218
+ };
1219
+ };
1405
1220
  help: {
1406
1221
  aliases: string[];
1407
1222
  schema: z.ZodOptional<z.ZodBoolean>;
@@ -1426,18 +1241,32 @@ declare class CliProgram {
1426
1241
  };
1427
1242
  };
1428
1243
  }>;
1429
- runAsync: (input: string | string[]) => Promise<_$_staticbolt_args_parser0.CliParseResult<{
1244
+ runAsync: (input: string | string[]) => Promise<import("@staticbolt/args-parser").CliParseResult<{
1430
1245
  cliName: "staticbolt";
1431
1246
  meta: {
1432
1247
  description: string;
1433
1248
  example: string;
1434
1249
  };
1435
1250
  options: {
1436
- help: {
1437
- aliases: string[];
1438
- schema: z.ZodOptional<z.ZodBoolean>;
1439
- coerce: {
1440
- <T extends boolean | undefined>(terminalInput: string): T;
1251
+ cwd: {
1252
+ schema: z.ZodOptional<z.ZodString>;
1253
+ meta: {
1254
+ placeholder: string;
1255
+ description: string;
1256
+ };
1257
+ };
1258
+ config: {
1259
+ schema: z.ZodOptional<z.ZodString>;
1260
+ meta: {
1261
+ placeholder: string;
1262
+ description: string;
1263
+ };
1264
+ };
1265
+ help: {
1266
+ aliases: string[];
1267
+ schema: z.ZodOptional<z.ZodBoolean>;
1268
+ coerce: {
1269
+ <T extends boolean | undefined>(terminalInput: string): T;
1441
1270
  type: string;
1442
1271
  };
1443
1272
  meta: {
@@ -1459,15 +1288,29 @@ declare class CliProgram {
1459
1288
  }>>;
1460
1289
  };
1461
1290
  constructor();
1462
- initializePlugins(config: AppConfig$1, configPath: string): Promise<void>;
1463
- static init(config: AppConfig$1, configPath: string): Promise<CliProgram>;
1464
- run(cliArguments: string[]): _$_staticbolt_args_parser0.CliParseResult<{
1291
+ initializePlugins(config: AppConfig$1, configPath: string, projectDirectory: string): Promise<void>;
1292
+ static init(config: AppConfig$1, configPath: string, projectDirectory: string): Promise<CliProgram>;
1293
+ run(cliArguments: string[]): import("@staticbolt/args-parser").CliParseResult<{
1465
1294
  cliName: "staticbolt";
1466
1295
  meta: {
1467
1296
  description: string;
1468
1297
  example: string;
1469
1298
  };
1470
1299
  options: {
1300
+ cwd: {
1301
+ schema: z.ZodOptional<z.ZodString>;
1302
+ meta: {
1303
+ placeholder: string;
1304
+ description: string;
1305
+ };
1306
+ };
1307
+ config: {
1308
+ schema: z.ZodOptional<z.ZodString>;
1309
+ meta: {
1310
+ placeholder: string;
1311
+ description: string;
1312
+ };
1313
+ };
1471
1314
  help: {
1472
1315
  aliases: string[];
1473
1316
  schema: z.ZodOptional<z.ZodBoolean>;
@@ -1503,23 +1346,448 @@ declare class CliProgram {
1503
1346
  };
1504
1347
  number: <T extends number | undefined>(terminalInput: string) => T;
1505
1348
  bigint: <T extends bigint | undefined>(terminalInput: string) => T;
1506
- object: (options?: _$_staticbolt_args_parser0.ObjectCoerceMethodOptions) => <T extends Record<string, unknown> | undefined>(terminalInput: string) => T;
1349
+ object: (options?: import("@staticbolt/args-parser").ObjectCoerceMethodOptions) => {
1350
+ <T extends Record<string, unknown> | undefined>(terminalInput: string): T;
1351
+ type: string;
1352
+ };
1507
1353
  stringArray: (separator: string) => <T extends string[] | undefined>(terminalInput: string) => T;
1508
1354
  numberArray: (separator: string) => <T extends number[] | undefined>(terminalInput: string) => T;
1509
1355
  booleanArray: (separator: string) => <T extends boolean[] | undefined>(terminalInput: string) => T;
1510
1356
  stringSet: (separator: string) => <T extends Set<string> | undefined>(terminalInput: string) => T;
1511
1357
  numberSet: (separator: string) => <T extends Set<number> | undefined>(terminalInput: string) => T;
1512
1358
  booleanSet: (separator: string) => <T extends Set<boolean> | undefined>(terminalInput: string) => T;
1513
- json: <T>(terminalInput: string) => T;
1359
+ json: {
1360
+ <T>(terminalInput: string): T;
1361
+ type: string;
1362
+ };
1514
1363
  };
1515
1364
  addCommand(newSubcommand: Subcommand): number | undefined;
1516
- addOptions(newOptions: Record<string, Option>): (Record<string, Option<_$_staticbolt_args_parser0.SchemaType<unknown>>> & Record<string, Option>) | undefined;
1517
- addArguments(newArguments: Record<string, Argument>): (Record<string, Argument<_$_staticbolt_args_parser0.SchemaType<unknown>>> & Record<string, Argument>) | undefined;
1518
- addOptionsToCommand(commandName: string, newOptions: Record<string, Option>): (Record<string, Option<_$_staticbolt_args_parser0.SchemaType<unknown>>> & Record<string, Option>) | undefined;
1519
- addArgumentsToCommand(commandName: string, newArguments: Record<string, Argument>): (Record<string, Argument<_$_staticbolt_args_parser0.SchemaType<unknown>>> & Record<string, Argument>) | undefined;
1365
+ addOptions(newOptions: Record<string, Option>): (Record<string, Option<import("@staticbolt/args-parser").SchemaType<unknown>>> & Record<string, Option>) | undefined;
1366
+ addArguments(newArguments: Record<string, Argument>): (Record<string, Argument<import("@staticbolt/args-parser").SchemaType<unknown>>> & Record<string, Argument>) | undefined;
1367
+ addOptionsToCommand(commandName: string, newOptions: Record<string, Option>): (Record<string, Option<import("@staticbolt/args-parser").SchemaType<unknown>>> & Record<string, Option>) | undefined;
1368
+ addArgumentsToCommand(commandName: string, newArguments: Record<string, Argument>): (Record<string, Argument<import("@staticbolt/args-parser").SchemaType<unknown>>> & Record<string, Argument>) | undefined;
1369
+ }
1370
+ //#endregion
1371
+ //#region src/resolver/resolver.d.ts
1372
+ type ResolveResult$1 = {
1373
+ path: string;
1374
+ suffix: string;
1375
+ isDirAlias?: boolean;
1376
+ isFileAlias?: boolean;
1377
+ isPackage?: boolean;
1378
+ exists: boolean;
1379
+ };
1380
+ declare class Resolver {
1381
+ #private;
1382
+ root: string;
1383
+ isProduction: boolean;
1384
+ aliases: Record<string, string>;
1385
+ notFound: Set<string>;
1386
+ files: Set<string>;
1387
+ directories: Set<string>;
1388
+ misses: Set<string>;
1389
+ static JS_EXTENSIONS: Set<string>;
1390
+ static HTML_EXTENSIONS: Set<string>;
1391
+ constructor(root: string, isProduction?: boolean, configAliases?: Record<string, string>);
1392
+ resolve(sourceOrLink: string, filePath: string): ResolveResult$1 | undefined;
1393
+ resolveAlias(source: string): string | undefined;
1394
+ normalize(filePath: string): string;
1395
+ static isFile(filePath: string): boolean;
1396
+ /** Aliased path to path */
1397
+ static resolvePathAlias(filePath: string, aliases: Record<string, string>): string | undefined;
1398
+ /** Path to aliased path */
1399
+ static resolveAliasPath(filePath: string, aliases: Record<string, string>): string;
1400
+ /** Path to aliased path */
1401
+ aliasPath(filePath: string): string;
1402
+ findFile(filePath: string, shouldCheckDirectory?: boolean): string | undefined;
1403
+ }
1404
+ //#endregion
1405
+ //#region src/main.d.ts
1406
+ declare class App {
1407
+ readonly configPath: string;
1408
+ /** The absolute path to the project root. */
1409
+ readonly root: string;
1410
+ /** The absolute path to the output directory. */
1411
+ readonly outdir: string;
1412
+ /** Whether the application is running in production mode. */
1413
+ readonly production: boolean;
1414
+ /** A list of browsers to target. */
1415
+ readonly browserslist: string[];
1416
+ readonly metadataList: MetadataBase$1[];
1417
+ private readonly plugins;
1418
+ readonly resolver: Resolver;
1419
+ log: {
1420
+ (...messages: unknown[]): void;
1421
+ warn(...messages: string[]): void;
1422
+ success(...messages: string[]): void;
1423
+ error(...messages: string[]): void;
1424
+ fatal(...messages: string[]): never;
1425
+ info(...messages: string[]): void;
1426
+ tip(...messages: string[]): void;
1427
+ debug(...messages: string[]): void;
1428
+ enableVerbose(isEnabled: boolean): void;
1429
+ setVerboseFilter(filter: RegExp): void;
1430
+ };
1431
+ /** File paths to load as sources. */
1432
+ readonly entryPoints: Set<string>;
1433
+ /** Any type of data for plugins to use. */
1434
+ readonly pluginData: Record<string, unknown>;
1435
+ /** Exclude paths from being emitted. */
1436
+ readonly emitExclude: Set<MetadataBase$1>;
1437
+ /** Chokidar watcher. Development only, and gone once the app is closed. */
1438
+ watcher: FSWatcher | undefined;
1439
+ private isPluginInitialized;
1440
+ private isClosed;
1441
+ private measureExecutionTime;
1442
+ private executionTime;
1443
+ /** How long the hooks called from inside the hook currently being measured took. Held in an object so plugin contexts share it. */
1444
+ private readonly nestedTime;
1445
+ readonly pluginIndex: number;
1446
+ readonly pluginName: string;
1447
+ constructor(options: AppConfig$1 | undefined, configPath: string);
1448
+ /** Binds a copy of the plugin's hooks to this app, leaving the user's object untouched. */
1449
+ private bindPlugin;
1450
+ private callPluginMethod;
1451
+ private emitFileChange;
1452
+ run(): Promise<void>;
1453
+ /**
1454
+ * Stops watching and lets every plugin release what its `setup` took, in reverse order. A teardown that throws is reported and
1455
+ * the rest still run. Closing again does nothing.
1456
+ */
1457
+ close(): Promise<void>;
1458
+ process(id: string): Promise<boolean>;
1459
+ resolve(metadata: MetadataBase$1): Promise<Set<string>>;
1460
+ /**
1461
+ * Resolve and load recursively
1462
+ *
1463
+ * 1. Resolves given metadata item or list
1464
+ * 2. Loads discovered dependencies if not already loaded skipping entry points
1465
+ * 3. Returns metadata list
1466
+ */
1467
+ resolveAndLoad(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<MetadataBase$1[]>;
1468
+ transform(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<void>;
1469
+ transformAndSync(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<void>;
1470
+ rebase(metadata: MetadataBase$1, newAbsolutePath: string): Promise<void>;
1471
+ writeFiles(): Promise<void>;
1472
+ read(filePath: string): Promise<string | undefined>;
1473
+ load(relativePath: string, options?: {
1474
+ code?: string;
1475
+ type?: string;
1476
+ }): Promise<MetadataBase$1 | undefined>;
1477
+ requestSources(metadata: MetadataBase$1): Promise<MetadataSource$1[]>;
1478
+ stringify(metadata: MetadataBase$1, options?: StringifyOptions$1): Promise<string>;
1479
+ getCompileList(event: "change" | "add" | "unlink", filePath: string): Promise<Set<string>>;
1480
+ handleRequest(requestPath: string, reply: ServerReply$1, request: ServerRequest$1): Promise<true | undefined>;
1481
+ resolveRequestPath(requestPath: string): Promise<string>;
1482
+ clone<T extends MetadataBase$1>(metadata: T): T;
1483
+ addMetadata(itemOrList: MetadataBase$1 | MetadataBase$1[]): void;
1484
+ removeMetadata(metadataOrIndex: MetadataBase$1 | MetadataBase$1[] | number): void;
1485
+ findMetadata<T extends MetadataBase$1>(metadataFilter: Partial<T>): T | undefined;
1486
+ filterMetadata<T extends MetadataBase$1>(metadataFilter: Partial<T>): T[];
1487
+ }
1488
+ //#endregion
1489
+ //#region src/types/metadata.d.ts
1490
+ declare const METADATA_TYPES: Readonly<{
1491
+ Script: "Script";
1492
+ HTML: "Html";
1493
+ Markdown: "Markdown";
1494
+ CSS: "Style";
1495
+ SVG: "Svg";
1496
+ Package: "Package";
1497
+ TextAsset: "TextAsset";
1498
+ BinaryAsset: "BinaryAsset";
1499
+ WebAppManifest: "WebAppManifest";
1500
+ }>;
1501
+ type MetadataTypes = (typeof METADATA_TYPES)[keyof typeof METADATA_TYPES];
1502
+ interface MetadataBase {
1503
+ readonly type: `${Capitalize<string>}${string}`;
1504
+ /**
1505
+ * Relative path of the source file.
1506
+ *
1507
+ * Initially identical to `originalSource` when the metadata is created. During the build process, this value may change (e.g.,
1508
+ * if the file is moved to a different location and its links are rebased).
1509
+ */
1510
+ filePath: string;
1511
+ /**
1512
+ * Original relative path of the source file.
1513
+ *
1514
+ * Set when the metadata is created and never modified.
1515
+ */
1516
+ readonly id: string;
1517
+ readonly directDependencies: Set<string>;
1518
+ }
1519
+ interface ScriptMetadata extends MetadataBase {
1520
+ readonly type: (typeof METADATA_TYPES)["Script"];
1521
+ /**
1522
+ * The Babel AST for the script.
1523
+ *
1524
+ * Mutated during the build process and always represents the file's current transformed state.
1525
+ */
1526
+ ast: BabelAst$1;
1527
+ /** Whether the script is a module or global */
1528
+ module: boolean;
1529
+ }
1530
+ interface StyleMetadata extends MetadataBase {
1531
+ readonly type: (typeof METADATA_TYPES)["CSS"];
1532
+ /**
1533
+ * The PostCSS root after transformation
1534
+ *
1535
+ * Mutated during the build process and always represents the file's current transformed state.
1536
+ */
1537
+ ast: PostcssAst$1;
1538
+ }
1539
+ interface HtmlMetadata extends MetadataBase {
1540
+ type: (typeof METADATA_TYPES)["HTML"];
1541
+ /**
1542
+ * The HTML AST (root element).
1543
+ *
1544
+ * Mutated during the build process and always represents the file's current transformed state
1545
+ */
1546
+ ast: Document$1;
1547
+ /** The transformed ASTs from script tags. The key is the UUID */
1548
+ scriptsMetadataList: Map<string, ScriptMetadata>;
1549
+ /** The transformed ASTs from script tags. The key is the UUID */
1550
+ stylesMetadataList: Map<string, StyleMetadata>;
1551
+ }
1552
+ interface SvgMetadata extends MetadataBase {
1553
+ type: (typeof METADATA_TYPES)["SVG"];
1554
+ /**
1555
+ * The HTML AST (root element).
1556
+ *
1557
+ * Mutated during the build process and always represents the file's current transformed state
1558
+ */
1559
+ ast: Document$1;
1560
+ /** The transformed ASTs from script tags. The key is the UUID */
1561
+ stylesMetadataList: Map<string, StyleMetadata>;
1562
+ }
1563
+ interface MarkdownMetadata extends MetadataBase {
1564
+ type: (typeof METADATA_TYPES)["Markdown"];
1565
+ /**
1566
+ * Markdown tokens and frontmatter.
1567
+ *
1568
+ * Mutated during the build process and always represents the file's current transformed state
1569
+ */
1570
+ ast: MarkdownAst$1;
1571
+ }
1572
+ interface WebManifestMetadata extends MetadataBase {
1573
+ type: (typeof METADATA_TYPES)["WebAppManifest"];
1574
+ ast: WebAppManifest;
1575
+ }
1576
+ interface PackageMetadata extends MetadataBase {
1577
+ type: (typeof METADATA_TYPES)["Package"];
1578
+ /** Metadata code */
1579
+ code: string;
1580
+ packageName: string;
1581
+ }
1582
+ interface TextAssetMetadata extends MetadataBase {
1583
+ type: (typeof METADATA_TYPES)["TextAsset"];
1584
+ /** Metadata code */
1585
+ code: string;
1586
+ }
1587
+ interface BinaryAssetMetadata extends MetadataBase {
1588
+ type: (typeof METADATA_TYPES)["BinaryAsset"];
1589
+ /** Raw binary content — images, fonts, wasm, etc. */
1590
+ data?: Uint8Array;
1591
+ }
1592
+ //#endregion
1593
+ //#region src/types/html-data.d.ts
1594
+ /**
1595
+ * The HTML custom data format, as an editor reads it for completions and hover.
1596
+ *
1597
+ * It is declared here rather than imported from the language service the language server runs on, so that a plugin written in a
1598
+ * user project is typed without that package having to be installed.
1599
+ */
1600
+ type MarkupKind = "plaintext" | "markdown";
1601
+ interface MarkupContent {
1602
+ kind: MarkupKind;
1603
+ value: string;
1604
+ }
1605
+ type Baseline = false | "low" | "high";
1606
+ interface BaselineStatus {
1607
+ baseline: Baseline;
1608
+ baseline_low_date?: string;
1609
+ baseline_high_date?: string;
1610
+ }
1611
+ interface IReference {
1612
+ name: string;
1613
+ url: string;
1614
+ }
1615
+ interface IValueData {
1616
+ name: string;
1617
+ description?: string | MarkupContent;
1618
+ references?: IReference[];
1619
+ browsers?: string[];
1620
+ status?: BaselineStatus;
1621
+ }
1622
+ interface IValueSet {
1623
+ name: string;
1624
+ values: IValueData[];
1625
+ }
1626
+ interface IAttributeData {
1627
+ name: string;
1628
+ description?: string | MarkupContent;
1629
+ valueSet?: string;
1630
+ values?: IValueData[];
1631
+ references?: IReference[];
1632
+ browsers?: string[];
1633
+ status?: BaselineStatus;
1634
+ }
1635
+ interface ITagData {
1636
+ name: string;
1637
+ description?: string | MarkupContent;
1638
+ attributes: IAttributeData[];
1639
+ references?: IReference[];
1640
+ void?: boolean;
1641
+ browsers?: string[];
1642
+ status?: BaselineStatus;
1643
+ }
1644
+ interface HTMLDataV1 {
1645
+ version: 1 | 1.1;
1646
+ tags?: ITagData[];
1647
+ globalAttributes?: IAttributeData[];
1648
+ valueSets?: IValueSet[];
1649
+ }
1650
+ //#endregion
1651
+ //#region src/types/plugin.d.ts
1652
+ type FastifyHandlerParameters = Parameters<onRequestHookHandler>;
1653
+ type ServerReply = FastifyHandlerParameters[1];
1654
+ type ServerRequest = FastifyHandlerParameters[0];
1655
+ interface MetadataSource {
1656
+ get source(): string;
1657
+ set source(value: string);
1658
+ node?: HTMLElement$1 | NodePath$1 | Postcss["AtRule"] | Postcss["Declaration"] | ImageResource | object;
1659
+ }
1660
+ interface ResolveResult {
1661
+ source: string;
1662
+ dependencyID?: string;
1663
+ }
1664
+ /**
1665
+ * A format or minify pass handed over instead of run, described well enough for another thread to run it: the module that exports
1666
+ * the pass, the name it is exported under, and everything the pass needs besides the code itself.
1667
+ */
1668
+ interface DeferredPass {
1669
+ /** Imported as written, from a context unrelated to the plugin, so it has to resolve on its own — an `import.meta.resolve` URL. */
1670
+ module: string;
1671
+ export: string;
1672
+ /** Crosses a thread boundary, so it has to survive a structured clone. */
1673
+ payload?: unknown;
1674
+ }
1675
+ /** What the module of a `DeferredPass` has to export under the name the pass gives. */
1676
+ type DeferredPassHandler<Payload = void> = (code: string, payload: Payload) => string | Promise<string>;
1677
+ interface StringifyOptions {
1678
+ minify?: boolean;
1679
+ format?: boolean;
1680
+ /**
1681
+ * Offered by callers that would rather run the final pass somewhere else. A plugin that takes it up describes its pass, returns
1682
+ * the code untouched and leaves the running to the caller. Ignoring it and doing the work is always correct.
1683
+ */
1684
+ defer?: (pass: DeferredPass) => void;
1685
+ }
1686
+ interface Plugin {
1687
+ name: string;
1688
+ setup?: (this: App$1) => void | Promise<void>;
1689
+ /**
1690
+ * Runs when the app is closed, in reverse plugin order. Release whatever `setup` took hold of (servers, watchers, workers). May
1691
+ * run after a `setup` that never finished, so expect to find nothing to release.
1692
+ */
1693
+ teardown?: (this: App$1) => void | Promise<void>;
1694
+ read?: (this: App$1, absolutePath: string) => string | void | Promise<string | void>;
1695
+ load?: (this: App$1, content: string, relativePath: string, options: {
1696
+ type?: string;
1697
+ }) => MetadataBase$1 | null | void | Promise<MetadataBase$1 | null | void>;
1698
+ resolveSource?: (this: App$1, source: string, filePath: string, parentMetadata: MetadataBase$1) => ResolveResult | void | Promise<ResolveResult | void>;
1699
+ transformSource?: (this: App$1, source: string, filePath: string, parentMetadata: MetadataBase$1, dependencyID?: string) => string | void | Promise<string | void>;
1700
+ preTransform?: (this: App$1) => void | Promise<void>;
1701
+ transform?: (this: App$1, metadata: MetadataBase$1) => void | Promise<void>;
1702
+ postTransform?: (this: App$1) => void | Promise<void>;
1703
+ /** Runs once, after every transform. Walk `metadataList` for the files to emit, and leave nothing outstanding on the way out. */
1704
+ write?: (this: App$1) => void | Promise<void>;
1705
+ postBuild?: (this: App$1) => void | Promise<void>;
1706
+ clone?: (this: App$1, metadata: MetadataBase$1) => void | MetadataBase$1;
1707
+ stringify?: (this: App$1, metadata: MetadataBase$1, options: StringifyOptions) => void | string | Promise<string | void>;
1708
+ sourcesProvider?: (this: App$1, metadata: MetadataBase$1) => MetadataSource[] | void | Promise<MetadataSource[] | void>;
1709
+ rebaseSource?: (this: App$1, source: string, filePath: string, newAbsolutePath: string) => string | void | Promise<string | void>;
1710
+ onMetadataRebase?: (this: App$1, metadata: MetadataBase$1, oldAbsolutePath: string, newAbsolutePath: string) => void | Promise<void>;
1711
+ handleRequest?: (this: App$1, requestPath: string, reply: ServerReply, request: ServerRequest) => boolean | void | Promise<boolean | void>;
1712
+ resolveRequestPath?: (this: App$1, requestPath: string) => string | void | Promise<string | void>;
1713
+ onFileEvent?: (this: App$1, event: "change" | "add" | "unlink", filePath: string) => void | Promise<void>;
1714
+ resolveCompileList?: (this: App$1, compileSet: Set<string>, event: "change" | "add" | "unlink", filePath: string) => void | Promise<void>;
1715
+ /**
1716
+ * Registers commands on the CLI. `config` has already been loaded from `configPath`, with its root made absolute against
1717
+ * `projectDirectory` — the directory the CLI was pointed at.
1718
+ */
1719
+ cli?: (this: CliProgram$1, config: AppConfig$1, configPath: string, projectDirectory: string) => void | Promise<void>;
1720
+ lspHtmlData?: () => HTMLDataV1 | undefined | Promise<HTMLDataV1 | undefined>;
1721
+ }
1722
+ type RemoveThis<T> = Required<{ [K in keyof T]: T[K] extends ((this: App$1, ...arguments_: infer A) => infer R) | undefined ? (...arguments_: A) => R : T[K]; }>;
1723
+ type BoundPlugin = RemoveThis<Plugin>;
1724
+ //#endregion
1725
+ //#region src/helpers/dependency-tracker.d.ts
1726
+ /**
1727
+ * Tracks bidirectional dependencies between importers and their sources.\
1728
+ * Handles reconciliation when dependencies change, so stale entries are automatically removed when an importer stops referencing
1729
+ * a source.
1730
+ */
1731
+ declare class DependencyTracker {
1732
+ #private;
1733
+ /** Updates the full set of sources for a given importer, reconciling any stale entries from previous calls. */
1734
+ update(importer: string, sources: Iterable<string>): void;
1735
+ /** Deletes all dependency data for a given id, whether it's acting as an importer, a source, or both (e.g. on file unlink). */
1736
+ delete(id: string): void;
1737
+ /** Returns all importers that depend on a given source, or an empty set. */
1738
+ getImporters(source: string): ReadonlySet<string>;
1739
+ /** Returns all sources that a given importer depends on, or an empty set. */
1740
+ getSources(importer: string): ReadonlySet<string>;
1520
1741
  }
1521
1742
  //#endregion
1522
- //#region src/utilities/path.d.ts
1743
+ //#region src/utilities/html-links.d.ts
1744
+ /**
1745
+ * Checks if the link is an HTML link (not a file link)
1746
+ *
1747
+ * @param source - The link
1748
+ * @returns
1749
+ */
1750
+ declare function isHtmlLink(source: string): boolean;
1751
+ declare function isValidRelativePath(source: string): boolean;
1752
+ declare function splitHtmlLink(url: string): [string, string];
1753
+ //#endregion
1754
+ //#region src/utilities/metadata-utilities.d.ts
1755
+ declare function isScriptMetadata(metadata: MetadataBase$1 | undefined): metadata is ScriptMetadata$1;
1756
+ declare function isPackageMetadata(metadata: MetadataBase$1 | undefined): metadata is PackageMetadata$1;
1757
+ declare function isHtmlMetadata(metadata: MetadataBase$1 | undefined): metadata is HtmlMetadata$1;
1758
+ declare function isStyleMetadata(metadata: MetadataBase$1 | undefined): metadata is StyleMetadata$1;
1759
+ declare function isSvgMetadata(metadata: MetadataBase$1 | undefined): metadata is SvgMetadata$1;
1760
+ declare function isMarkdownMetadata(metadata: MetadataBase$1 | undefined): metadata is MarkdownMetadata$1;
1761
+ declare function isTextAssetMetadata(metadata: MetadataBase$1 | undefined): metadata is TextAssetMetadata$1;
1762
+ declare function isBinaryAssetMetadata(metadata: MetadataBase$1 | undefined): metadata is BinaryAssetMetadata$1;
1763
+ declare function isWebManifestMetadata(metadata: MetadataBase$1): metadata is WebManifestMetadata$1;
1764
+ /**
1765
+ * Returns script-related metadata entries.
1766
+ *
1767
+ * - If the input is ScriptMetadata, it returns it directly.
1768
+ * - If the input is HtmlMetadata, it scans <script> tags in the AST and resolves their associated ScriptMetadata using the metadata
1769
+ * ID attribute.
1770
+ */
1771
+ declare function filterScriptMetadata(metadata: MetadataBase$1): {
1772
+ metadata: ScriptMetadata$1;
1773
+ tag?: HTMLElement$2;
1774
+ htmlMetadata?: HtmlMetadata$1;
1775
+ }[];
1776
+ /**
1777
+ * Returns style-related metadata entries.
1778
+ *
1779
+ * - If the input is StyleMetadata, it returns it directly.
1780
+ * - If the input is HtmlMetadata, it scans <style> tags in the AST and resolves their associated StyleMetadata using the metadata
1781
+ * ID attribute.
1782
+ */
1783
+ declare function filterStyleMetadata(metadata: MetadataBase$1): {
1784
+ metadata: StyleMetadata$1;
1785
+ tag?: HTMLElement$2;
1786
+ htmlMetadata?: HtmlMetadata$1;
1787
+ }[];
1788
+ declare namespace path_d_exports {
1789
+ export { appendForwardSlash, basename, dirname, extname, firstPart, isAbsolute, isPathMatch, isSubpath, join, normalize, parse$1 as parse, parsePatterns, rebaseRelativePath, relative, replaceExtension, resolve, sourceRelativeToRoot, trimDotPrefix };
1790
+ }
1523
1791
  declare const join: (...arguments_: string[]) => string;
1524
1792
  declare const relative: (from: string, to: string) => string;
1525
1793
  declare const dirname: (path: string) => string;
@@ -1551,11 +1819,7 @@ interface SourceRelativeToRootOptions {
1551
1819
  sourcePath: string;
1552
1820
  }
1553
1821
  /** Calculates the relative path of a source path to the root. */
1554
- declare function sourceRelativeToRoot({
1555
- root,
1556
- filePath,
1557
- sourcePath
1558
- }: SourceRelativeToRootOptions): string;
1822
+ declare function sourceRelativeToRoot({ root, filePath, sourcePath }: SourceRelativeToRootOptions): string;
1559
1823
  /** Replaces the extension of a given path. */
1560
1824
  declare function replaceExtension(filePath: string, extension: string): string;
1561
1825
  /** Appends a forward slash to the end of a path if it doesn't already end with one. */
@@ -1564,52 +1828,19 @@ declare const appendForwardSlash: (path: string) => string;
1564
1828
  declare const trimDotPrefix: (path: string) => string;
1565
1829
  /** Returns the first segment of a path. */
1566
1830
  declare function firstPart(path: string): string;
1831
+ /**
1832
+ * Splits a semicolon-separated attribute value into an array of trimmed glob patterns.
1833
+ *
1834
+ * Returns `undefined` when the input is not a string, and an empty array for an empty string.
1835
+ */
1836
+ declare function parsePatterns(string: string | null | undefined): string[] | undefined;
1567
1837
  interface MatchPathOptions {
1568
1838
  include: string | string[];
1569
1839
  ignore?: string | string[];
1570
1840
  root: string;
1571
1841
  }
1572
1842
  /** Checks if a file path matches a set of patterns. */
1573
- declare function matchPath(filePath: string, {
1574
- include,
1575
- ignore,
1576
- root
1577
- }: MatchPathOptions): boolean;
1578
- //#endregion
1579
- //#region src/utilities/metadata-utilities.d.ts
1580
- declare function isScriptMetadata(metadata: MetadataBase$1 | undefined): metadata is ScriptMetadata$1;
1581
- declare function isPackageMetadata(metadata: MetadataBase$1 | undefined): metadata is PackageMetadata$1;
1582
- declare function isHtmlMetadata(metadata: MetadataBase$1 | undefined): metadata is HtmlMetadata$1;
1583
- declare function isStyleMetadata(metadata: MetadataBase$1 | undefined): metadata is StyleMetadata$1;
1584
- declare function isSvgMetadata(metadata: MetadataBase$1 | undefined): metadata is SvgMetadata$1;
1585
- declare function isMarkdownMetadata(metadata: MetadataBase$1 | undefined): metadata is MarkdownMetadata$1;
1586
- declare function isTextAssetMetadata(metadata: MetadataBase$1 | undefined): metadata is TextAssetMetadata$1;
1587
- declare function isBinaryAssetMetadata(metadata: MetadataBase$1 | undefined): metadata is BinaryAssetMetadata$1;
1588
- declare function isWebManifestMetadata(metadata: MetadataBase$1): metadata is WebManifestMetadata$1;
1589
- /**
1590
- * Returns script-related metadata entries.
1591
- *
1592
- * - If the input is ScriptMetadata, it returns it directly.
1593
- * - If the input is HtmlMetadata, it scans <script> tags in the AST and resolves their associated ScriptMetadata using the metadata
1594
- * ID attribute.
1595
- */
1596
- declare function filterScriptMetadata(metadata: MetadataBase$1): {
1597
- metadata: ScriptMetadata$1;
1598
- tag?: HTMLElement$2;
1599
- htmlMetadata?: HtmlMetadata$1;
1600
- }[];
1601
- /**
1602
- * Returns style-related metadata entries.
1603
- *
1604
- * - If the input is StyleMetadata, it returns it directly.
1605
- * - If the input is HtmlMetadata, it scans <style> tags in the AST and resolves their associated StyleMetadata using the metadata
1606
- * ID attribute.
1607
- */
1608
- declare function filterStyleMetadata(metadata: MetadataBase$1): {
1609
- metadata: StyleMetadata$1;
1610
- tag?: HTMLElement$2;
1611
- htmlMetadata?: HtmlMetadata$1;
1612
- }[];
1843
+ declare function isPathMatch(filePath: string, { include, ignore, root }: MatchPathOptions): boolean;
1613
1844
  //#endregion
1614
1845
  //#region src/utilities/print-formatted-error.d.ts
1615
1846
  type Node$3 = Node$2 | Node$1 | Node;
@@ -1639,6 +1870,12 @@ declare const printFmtError: (...messageAndErrorWithOptions: [...MessageAndError
1639
1870
  //#endregion
1640
1871
  //#region src/utilities/value-or-error.d.ts
1641
1872
  type ValueOrError<T> = [T, null] | [null, Error];
1873
+ declare function handleError<T>(error: unknown, functionName?: string): ValueOrError<T>;
1874
+ interface goErrorsI {
1875
+ <T, A extends unknown[]>(function_: (...arguments_: A) => Promise<T>): (...arguments_: A) => Promise<ValueOrError<T>>;
1876
+ <T, A extends unknown[]>(function_: (...arguments_: A) => T): (...arguments_: A) => ValueOrError<T>;
1877
+ }
1878
+ declare const valueOrError: goErrorsI;
1642
1879
  //#endregion
1643
1880
  //#region src/utilities/read-file.d.ts
1644
1881
  declare function safeReadFile(path: PathLike | FileHandle, options?: ({
@@ -1656,10 +1893,10 @@ declare function safeReadFileSync(path: PathOrFileDescriptor, options?: {
1656
1893
  encoding?: null | undefined;
1657
1894
  flag?: string | undefined;
1658
1895
  } | null): ValueOrError<NonSharedBuffer>;
1659
- declare function safeReadFileSync(path: PathOrFileDescriptor, options: {
1896
+ declare function safeReadFileSync(path: PathOrFileDescriptor, options: BufferEncoding | {
1660
1897
  encoding: BufferEncoding;
1661
1898
  flag?: string | undefined;
1662
- } | BufferEncoding): ValueOrError<string>;
1899
+ }): ValueOrError<string>;
1663
1900
  declare function safeReadFileSync(path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & {
1664
1901
  flag?: string | undefined;
1665
1902
  }) | BufferEncoding | null): ValueOrError<string | NonSharedBuffer>;
@@ -1709,26 +1946,14 @@ declare function cloneObject<T extends object>(object: T): T;
1709
1946
  declare function hashContent(content: string): string;
1710
1947
  declare function escapeHtml(input: string): string;
1711
1948
  //#endregion
1712
- //#region src/helpers/dependency-tracker.d.ts
1949
+ //#region src/index.d.ts
1713
1950
  /**
1714
- * Tracks bidirectional dependencies between importers and their sources.\
1715
- * Handles reconciliation when dependencies change, so stale entries are automatically removed when an importer stops referencing
1716
- * a source.
1951
+ * Types the config file's default export.
1952
+ *
1953
+ * The config file runs as CommonJS, so it cannot use top-level `await`. Create plugins inside it rather than importing shared
1954
+ * instances: only the config file itself is evaluated again when the dev server reloads it.
1717
1955
  */
1718
- declare class DependencyTracker {
1719
- #private;
1720
- /** Updates the full set of sources for a given importer, reconciling any stale entries from previous calls. */
1721
- update(importer: string, sources: Iterable<string>): void;
1722
- /** Deletes all dependency data for a given id, whether it's acting as an importer, a source, or both (e.g. on file unlink). */
1723
- delete(id: string): void;
1724
- /** Returns all importers that depend on a given source, or an empty set. */
1725
- getImporters(source: string): ReadonlySet<string>;
1726
- /** Returns all sources that a given importer depends on, or an empty set. */
1727
- getSources(importer: string): ReadonlySet<string>;
1728
- }
1729
- //#endregion
1730
- //#region src/index.d.ts
1731
1956
  declare function defineConfig(config: AppConfig): AppConfig;
1732
1957
  //#endregion
1733
- export { type App, AppConfig, BabelAst, BinaryAssetMetadata, BoundPlugin, CONFIG_FILE_NAME, CUSTOM_ATTRIBUTES, CliProgram, DependencyTracker, type Document, type HTMLElement, HtmlMetadata, METADATA_TYPES, MarkdownAst, MarkdownMetadata, MetadataBase, MetadataSource, MetadataTypes, NodePath, PackageMetadata, Plugin, PostcssAst, PrintFormattedError, ResolveResult, ScriptMetadata, ServerReply, ServerRequest, StyleMetadata, SvgMetadata, TextAssetMetadata, WebManifestMetadata, appendForwardSlash, assign, basename, bytesToKB, camelCaseToKebabCase, capitalize, clamp, clearLn, cloneObject, defineConfig, dirname, downloadContent, escapeHtml, extname, filterScriptMetadata, filterStyleMetadata, firstPart, getLineColumn, hashContent, humanReadableBytes, isAbsolute, isBinaryAssetMetadata, isDefined, isHtmlMetadata, isMarkdownMetadata, isObject, isPackageMetadata, isScriptMetadata, isStyleMetadata, isSubpath, isSvgMetadata, isTextAssetMetadata, isURL, isWebManifestMetadata, join, kebabToCamelCase, matchPath, mergeMaps, normalize, parse, print, printFmtError, rebaseRelativePath, relative, replaceExtension, resolve, safeReadFile, safeReadFileSync, sourceRelativeToRoot, trimDotPrefix };
1958
+ export { type App, type AppConfig, type BabelAst, type Baseline, type BaselineStatus, type BinaryAssetMetadata, type BoundPlugin, type CONFIG_FILE_NAME, type CUSTOM_ATTRIBUTES, type CliProgram, type DeferredPass, type DeferredPassHandler, DependencyTracker, type Document, type HTMLDataV1, type HTMLElement, type HtmlMetadata, type IAttributeData, type IReference, type ITagData, type IValueData, type IValueSet, METADATA_TYPES, type MarkdownAst, type MarkdownMetadata, type MarkupContent, type MarkupKind, type MetadataBase, type MetadataSource, type MetadataTypes, type NodePath, type PackageMetadata, type Plugin, type PostcssAst, PrintFormattedError, type ResolveResult, Resolver, type ScriptMetadata, type ServerReply, type ServerRequest, type StringifyOptions, type StyleMetadata, type SvgMetadata, type TextAssetMetadata, ValueOrError, type WebManifestMetadata, assign, bytesToKB, camelCaseToKebabCase, capitalize, clamp, clearLn, cloneObject, defineConfig, downloadContent, escapeHtml, filterScriptMetadata, filterStyleMetadata, getLineColumn, handleError, hashContent, humanReadableBytes, isBinaryAssetMetadata, isDefined, isHtmlLink, isHtmlMetadata, isMarkdownMetadata, isObject, isPackageMetadata, isScriptMetadata, isStyleMetadata, isSvgMetadata, isTextAssetMetadata, isURL, isValidRelativePath, isWebManifestMetadata, kebabToCamelCase, mergeMaps, path_d_exports as path, print, printFmtError, safeReadFile, safeReadFileSync, splitHtmlLink, valueOrError };
1734
1959
  //# sourceMappingURL=index.d.mts.map