@staticbolt/core 1.0.0-beta.3 → 1.0.0-beta.31
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/README.md +2 -1
- package/lib/cli/index.d.mts +1 -1
- package/lib/cli/index.mjs +78 -44
- package/lib/cli/index.mjs.map +1 -1
- package/lib/{logger-BuxMGhij.mjs → common-D1QTZ8ra.mjs} +92 -33
- package/lib/common-D1QTZ8ra.mjs.map +1 -0
- package/lib/deferred-DTj91vEg.mjs +218 -0
- package/lib/deferred-DTj91vEg.mjs.map +1 -0
- package/lib/deferred.d.mts +79 -0
- package/lib/deferred.d.mts.map +1 -0
- package/lib/deferred.mjs +3 -0
- package/lib/index.d.mts +713 -340
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +9 -3
- package/lib/index.mjs.map +1 -1
- package/lib/load-config-CsbiJ01A.mjs +57 -0
- package/lib/load-config-CsbiJ01A.mjs.map +1 -0
- package/lib/plugins/index.d.mts +652 -39
- package/lib/plugins/index.d.mts.map +1 -1
- package/lib/plugins/index.mjs +3621 -1344
- package/lib/plugins/index.mjs.map +1 -1
- package/lib/plugins/write-files/deferred-worker.d.mts +15 -0
- package/lib/plugins/write-files/deferred-worker.d.mts.map +1 -0
- package/lib/plugins/write-files/deferred-worker.mjs +35 -0
- package/lib/plugins/write-files/deferred-worker.mjs.map +1 -0
- package/lib/rolldown-runtime-DXywRVcq.mjs +20 -0
- package/lib/{dependency-tracker-BuZfopIj.mjs → utilities-jK4uUZBV.mjs} +444 -125
- package/lib/utilities-jK4uUZBV.mjs.map +1 -0
- package/package.json +74 -65
- package/lib/dependency-tracker-BuZfopIj.mjs.map +0 -1
- package/lib/logger-BuxMGhij.mjs.map +0 -1
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";
|
|
1
|
+
import { basename, extname, isAbsolute, parse as parse$1, resolve } from "node:path";
|
|
5
2
|
import { ObjectEncodingOptions, OpenMode, PathLike, PathOrFileDescriptor } from "node:fs";
|
|
6
3
|
import { FileHandle } from "node:fs/promises";
|
|
7
|
-
import
|
|
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
|
|
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 */
|
|
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
|
|
1063
|
+
* The project root. Relative paths in the config are resolved against it.
|
|
1242
1064
|
*
|
|
1243
|
-
*
|
|
1244
|
-
* if the file is moved to a different location and its links are rebased).
|
|
1065
|
+
* @default process.cwd()
|
|
1245
1066
|
*/
|
|
1246
|
-
|
|
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
|
-
*
|
|
1071
|
+
* The output directory, either absolute or relative to {@link AppConfig.root}.
|
|
1249
1072
|
*
|
|
1250
|
-
*
|
|
1073
|
+
* @default "./dist"
|
|
1251
1074
|
*/
|
|
1252
|
-
|
|
1253
|
-
readonly directDependencies: Set<string>;
|
|
1254
|
-
}
|
|
1255
|
-
interface ScriptMetadata extends MetadataBase {
|
|
1256
|
-
readonly type: (typeof METADATA_TYPES)["Script"];
|
|
1075
|
+
outdir?: string;
|
|
1257
1076
|
/**
|
|
1258
|
-
*
|
|
1077
|
+
* Whether to build for production. In development the project is watched for file changes.
|
|
1259
1078
|
*
|
|
1260
|
-
*
|
|
1079
|
+
* @default false
|
|
1261
1080
|
*/
|
|
1262
|
-
|
|
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
|
-
*
|
|
1083
|
+
* Browsers to target, as [browserslist](https://github.com/browserslist/browserslist) queries. Defaults to the project's
|
|
1084
|
+
* browserslist configuration.
|
|
1270
1085
|
*
|
|
1271
|
-
*
|
|
1086
|
+
* @example
|
|
1087
|
+
* ["last 2 Chrome versions", "last 2 Safari versions"];
|
|
1272
1088
|
*/
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1275
|
-
interface HtmlMetadata extends MetadataBase {
|
|
1276
|
-
type: (typeof METADATA_TYPES)["HTML"];
|
|
1089
|
+
browserslist?: string[];
|
|
1277
1090
|
/**
|
|
1278
|
-
*
|
|
1091
|
+
* Whether to time each plugin hook and print a breakdown when the build finishes.
|
|
1279
1092
|
*
|
|
1280
|
-
*
|
|
1093
|
+
* @default false
|
|
1281
1094
|
*/
|
|
1282
|
-
|
|
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
|
-
*
|
|
1097
|
+
* Path aliases, merged on top of the ones resolved from `tsconfig.json` — entries defined here win on key conflicts.
|
|
1292
1098
|
*
|
|
1293
|
-
*
|
|
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
|
-
*
|
|
1102
|
+
* @example
|
|
1103
|
+
* { "~/": "./src/", "@config": "./src/config.ts" }
|
|
1305
1104
|
*/
|
|
1306
|
-
|
|
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
|
-
|
|
1374
|
-
|
|
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?:
|
|
1397
|
-
generateSubcommandHelpMessage?: ((subcommandName: string & {}, options?:
|
|
1398
|
-
run: (input: string | string[]) =>
|
|
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<
|
|
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
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
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[]):
|
|
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,596 @@ 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?:
|
|
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:
|
|
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<
|
|
1517
|
-
addArguments(newArguments: Record<string, Argument>): (Record<string, Argument<
|
|
1518
|
-
addOptionsToCommand(commandName: string, newOptions: Record<string, Option>): (Record<string, Option<
|
|
1519
|
-
addArgumentsToCommand(commandName: string, newArguments: Record<string, Argument>): (Record<string, Argument<
|
|
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
|
+
/** Whether a source that resolves to a missing file is logged, once. The result says so either way. */
|
|
1390
|
+
shouldWarnOnMissing: boolean;
|
|
1391
|
+
static JS_EXTENSIONS: Set<string>;
|
|
1392
|
+
static HTML_EXTENSIONS: Set<string>;
|
|
1393
|
+
constructor(root: string, isProduction?: boolean, configAliases?: Record<string, string>, shouldWarnOnMissing?: boolean);
|
|
1394
|
+
resolve(sourceOrLink: string, filePath: string): ResolveResult$1 | undefined;
|
|
1395
|
+
resolveAlias(source: string): string | undefined;
|
|
1396
|
+
normalize(filePath: string): string;
|
|
1397
|
+
static isFile(filePath: string): boolean;
|
|
1398
|
+
/** Aliased path to path */
|
|
1399
|
+
static resolvePathAlias(filePath: string, aliases: Record<string, string>): string | undefined;
|
|
1400
|
+
/** Path to aliased path */
|
|
1401
|
+
static resolveAliasPath(filePath: string, aliases: Record<string, string>): string;
|
|
1402
|
+
/** Path to aliased path */
|
|
1403
|
+
aliasPath(filePath: string): string;
|
|
1404
|
+
findFile(filePath: string, shouldCheckDirectory?: boolean): string | undefined;
|
|
1520
1405
|
}
|
|
1521
1406
|
//#endregion
|
|
1522
|
-
//#region src/
|
|
1407
|
+
//#region src/main.d.ts
|
|
1408
|
+
declare class App {
|
|
1409
|
+
readonly configPath: string;
|
|
1410
|
+
/** The absolute path to the project root. */
|
|
1411
|
+
readonly root: string;
|
|
1412
|
+
/** The absolute path to the output directory. */
|
|
1413
|
+
readonly outdir: string;
|
|
1414
|
+
/** Whether the application is running in production mode. */
|
|
1415
|
+
readonly production: boolean;
|
|
1416
|
+
/** A list of browsers to target. */
|
|
1417
|
+
readonly browserslist: string[];
|
|
1418
|
+
readonly metadataList: MetadataBase$1[];
|
|
1419
|
+
private readonly plugins;
|
|
1420
|
+
readonly resolver: Resolver;
|
|
1421
|
+
log: {
|
|
1422
|
+
(...messages: unknown[]): void;
|
|
1423
|
+
warn(...messages: string[]): void;
|
|
1424
|
+
success(...messages: string[]): void;
|
|
1425
|
+
error(...messages: string[]): void;
|
|
1426
|
+
fatal(...messages: string[]): never;
|
|
1427
|
+
info(...messages: string[]): void;
|
|
1428
|
+
tip(...messages: string[]): void;
|
|
1429
|
+
debug(...messages: string[]): void;
|
|
1430
|
+
enableVerbose(isEnabled: boolean): void;
|
|
1431
|
+
setVerboseFilter(filter: RegExp): void;
|
|
1432
|
+
};
|
|
1433
|
+
/** File paths to load as sources. */
|
|
1434
|
+
readonly entryPoints: Set<string>;
|
|
1435
|
+
/** Any type of data for plugins to use. */
|
|
1436
|
+
readonly pluginData: Record<string, unknown>;
|
|
1437
|
+
/** Exclude paths from being emitted. */
|
|
1438
|
+
readonly emitExclude: Set<MetadataBase$1>;
|
|
1439
|
+
/** Chokidar watcher. Development only, and gone once the app is closed. */
|
|
1440
|
+
watcher: FSWatcher | undefined;
|
|
1441
|
+
private isPluginInitialized;
|
|
1442
|
+
private isClosed;
|
|
1443
|
+
private measureExecutionTime;
|
|
1444
|
+
private executionTime;
|
|
1445
|
+
/** How long the hooks called from inside the hook currently being measured took. Held in an object so plugin contexts share it. */
|
|
1446
|
+
private readonly nestedTime;
|
|
1447
|
+
readonly pluginIndex: number;
|
|
1448
|
+
readonly pluginName: string;
|
|
1449
|
+
constructor(options: AppConfig$1 | undefined, configPath: string);
|
|
1450
|
+
/** Binds a copy of the plugin's hooks to this app, leaving the user's object untouched. */
|
|
1451
|
+
private bindPlugin;
|
|
1452
|
+
private callPluginMethod;
|
|
1453
|
+
private emitFileChange;
|
|
1454
|
+
run(): Promise<void>;
|
|
1455
|
+
/**
|
|
1456
|
+
* Stops watching and lets every plugin release what its `setup` took, in reverse order. A teardown that throws is reported and
|
|
1457
|
+
* the rest still run. Closing again does nothing.
|
|
1458
|
+
*/
|
|
1459
|
+
close(): Promise<void>;
|
|
1460
|
+
process(id: string): Promise<boolean>;
|
|
1461
|
+
resolve(metadata: MetadataBase$1): Promise<Set<string>>;
|
|
1462
|
+
/**
|
|
1463
|
+
* Resolve and load recursively
|
|
1464
|
+
*
|
|
1465
|
+
* 1. Resolves given metadata item or list
|
|
1466
|
+
* 2. Loads discovered dependencies if not already loaded skipping entry points
|
|
1467
|
+
* 3. Returns metadata list
|
|
1468
|
+
*/
|
|
1469
|
+
resolveAndLoad(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<MetadataBase$1[]>;
|
|
1470
|
+
transform(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<void>;
|
|
1471
|
+
transformAndSync(metadataItemOrList: MetadataBase$1 | MetadataBase$1[]): Promise<void>;
|
|
1472
|
+
rebase(metadata: MetadataBase$1, newAbsolutePath: string): Promise<void>;
|
|
1473
|
+
writeFiles(): Promise<void>;
|
|
1474
|
+
read(filePath: string): Promise<string | undefined>;
|
|
1475
|
+
load(relativePath: string, options?: {
|
|
1476
|
+
code?: string;
|
|
1477
|
+
type?: string;
|
|
1478
|
+
}): Promise<MetadataBase$1 | undefined>;
|
|
1479
|
+
requestSources(metadata: MetadataBase$1): Promise<MetadataSource$1[]>;
|
|
1480
|
+
stringify(metadata: MetadataBase$1, options?: StringifyOptions$1): Promise<string>;
|
|
1481
|
+
getCompileList(event: "change" | "add" | "unlink", filePath: string): Promise<Set<string>>;
|
|
1482
|
+
handleRequest(requestPath: string, reply: ServerReply$1, request: ServerRequest$1): Promise<true | undefined>;
|
|
1483
|
+
resolveRequestPath(requestPath: string): Promise<string>;
|
|
1484
|
+
clone<T extends MetadataBase$1>(metadata: T): T;
|
|
1485
|
+
addMetadata(itemOrList: MetadataBase$1 | MetadataBase$1[]): void;
|
|
1486
|
+
removeMetadata(metadataOrIndex: MetadataBase$1 | MetadataBase$1[] | number): void;
|
|
1487
|
+
findMetadata<T extends MetadataBase$1>(metadataFilter: Partial<T>): T | undefined;
|
|
1488
|
+
filterMetadata<T extends MetadataBase$1>(metadataFilter: Partial<T>): T[];
|
|
1489
|
+
}
|
|
1490
|
+
//#endregion
|
|
1491
|
+
//#region src/types/metadata.d.ts
|
|
1492
|
+
declare const METADATA_TYPES: Readonly<{
|
|
1493
|
+
Script: "Script";
|
|
1494
|
+
HTML: "Html";
|
|
1495
|
+
Markdown: "Markdown";
|
|
1496
|
+
CSS: "Style";
|
|
1497
|
+
SVG: "Svg";
|
|
1498
|
+
Package: "Package";
|
|
1499
|
+
TextAsset: "TextAsset";
|
|
1500
|
+
BinaryAsset: "BinaryAsset";
|
|
1501
|
+
WebAppManifest: "WebAppManifest";
|
|
1502
|
+
}>;
|
|
1503
|
+
type MetadataTypes = (typeof METADATA_TYPES)[keyof typeof METADATA_TYPES];
|
|
1504
|
+
interface MetadataBase {
|
|
1505
|
+
readonly type: `${Capitalize<string>}${string}`;
|
|
1506
|
+
/**
|
|
1507
|
+
* Relative path of the source file.
|
|
1508
|
+
*
|
|
1509
|
+
* Initially identical to `originalSource` when the metadata is created. During the build process, this value may change (e.g.,
|
|
1510
|
+
* if the file is moved to a different location and its links are rebased).
|
|
1511
|
+
*/
|
|
1512
|
+
filePath: string;
|
|
1513
|
+
/**
|
|
1514
|
+
* Original relative path of the source file.
|
|
1515
|
+
*
|
|
1516
|
+
* Set when the metadata is created and never modified.
|
|
1517
|
+
*/
|
|
1518
|
+
readonly id: string;
|
|
1519
|
+
readonly directDependencies: Set<string>;
|
|
1520
|
+
}
|
|
1521
|
+
interface ScriptMetadata extends MetadataBase {
|
|
1522
|
+
readonly type: (typeof METADATA_TYPES)["Script"];
|
|
1523
|
+
/**
|
|
1524
|
+
* The Babel AST for the script.
|
|
1525
|
+
*
|
|
1526
|
+
* Mutated during the build process and always represents the file's current transformed state.
|
|
1527
|
+
*/
|
|
1528
|
+
ast: BabelAst$1;
|
|
1529
|
+
/** Whether the script is a module or global */
|
|
1530
|
+
module: boolean;
|
|
1531
|
+
}
|
|
1532
|
+
interface StyleMetadata extends MetadataBase {
|
|
1533
|
+
readonly type: (typeof METADATA_TYPES)["CSS"];
|
|
1534
|
+
/**
|
|
1535
|
+
* The PostCSS root after transformation
|
|
1536
|
+
*
|
|
1537
|
+
* Mutated during the build process and always represents the file's current transformed state.
|
|
1538
|
+
*/
|
|
1539
|
+
ast: PostcssAst$1;
|
|
1540
|
+
}
|
|
1541
|
+
interface HtmlMetadata extends MetadataBase {
|
|
1542
|
+
type: (typeof METADATA_TYPES)["HTML"];
|
|
1543
|
+
/**
|
|
1544
|
+
* The HTML AST (root element).
|
|
1545
|
+
*
|
|
1546
|
+
* Mutated during the build process and always represents the file's current transformed state
|
|
1547
|
+
*/
|
|
1548
|
+
ast: Document$1;
|
|
1549
|
+
/** The transformed ASTs from script tags. The key is the UUID */
|
|
1550
|
+
scriptsMetadataList: Map<string, ScriptMetadata>;
|
|
1551
|
+
/** The transformed ASTs from script tags. The key is the UUID */
|
|
1552
|
+
stylesMetadataList: Map<string, StyleMetadata>;
|
|
1553
|
+
}
|
|
1554
|
+
interface SvgMetadata extends MetadataBase {
|
|
1555
|
+
type: (typeof METADATA_TYPES)["SVG"];
|
|
1556
|
+
/**
|
|
1557
|
+
* The HTML AST (root element).
|
|
1558
|
+
*
|
|
1559
|
+
* Mutated during the build process and always represents the file's current transformed state
|
|
1560
|
+
*/
|
|
1561
|
+
ast: Document$1;
|
|
1562
|
+
/** The transformed ASTs from script tags. The key is the UUID */
|
|
1563
|
+
stylesMetadataList: Map<string, StyleMetadata>;
|
|
1564
|
+
}
|
|
1565
|
+
interface MarkdownMetadata extends MetadataBase {
|
|
1566
|
+
type: (typeof METADATA_TYPES)["Markdown"];
|
|
1567
|
+
/**
|
|
1568
|
+
* Markdown tokens and frontmatter.
|
|
1569
|
+
*
|
|
1570
|
+
* Mutated during the build process and always represents the file's current transformed state
|
|
1571
|
+
*/
|
|
1572
|
+
ast: MarkdownAst$1;
|
|
1573
|
+
}
|
|
1574
|
+
interface WebManifestMetadata extends MetadataBase {
|
|
1575
|
+
type: (typeof METADATA_TYPES)["WebAppManifest"];
|
|
1576
|
+
ast: WebAppManifest;
|
|
1577
|
+
}
|
|
1578
|
+
interface PackageMetadata extends MetadataBase {
|
|
1579
|
+
type: (typeof METADATA_TYPES)["Package"];
|
|
1580
|
+
/** Metadata code */
|
|
1581
|
+
code: string;
|
|
1582
|
+
packageName: string;
|
|
1583
|
+
}
|
|
1584
|
+
interface TextAssetMetadata extends MetadataBase {
|
|
1585
|
+
type: (typeof METADATA_TYPES)["TextAsset"];
|
|
1586
|
+
/** Metadata code */
|
|
1587
|
+
code: string;
|
|
1588
|
+
}
|
|
1589
|
+
interface BinaryAssetMetadata extends MetadataBase {
|
|
1590
|
+
type: (typeof METADATA_TYPES)["BinaryAsset"];
|
|
1591
|
+
/** Raw binary content — images, fonts, wasm, etc. */
|
|
1592
|
+
data?: Uint8Array;
|
|
1593
|
+
}
|
|
1594
|
+
//#endregion
|
|
1595
|
+
//#region src/types/html-data.d.ts
|
|
1596
|
+
/**
|
|
1597
|
+
* The HTML custom data format, as an editor reads it for completions and hover.
|
|
1598
|
+
*
|
|
1599
|
+
* It is declared here rather than imported from the language service the language server runs on, so that a plugin written in a
|
|
1600
|
+
* user project is typed without that package having to be installed.
|
|
1601
|
+
*/
|
|
1602
|
+
type MarkupKind = "plaintext" | "markdown";
|
|
1603
|
+
interface MarkupContent {
|
|
1604
|
+
kind: MarkupKind;
|
|
1605
|
+
value: string;
|
|
1606
|
+
}
|
|
1607
|
+
type Baseline = false | "low" | "high";
|
|
1608
|
+
interface BaselineStatus {
|
|
1609
|
+
baseline: Baseline;
|
|
1610
|
+
baseline_low_date?: string;
|
|
1611
|
+
baseline_high_date?: string;
|
|
1612
|
+
}
|
|
1613
|
+
interface IReference {
|
|
1614
|
+
name: string;
|
|
1615
|
+
url: string;
|
|
1616
|
+
}
|
|
1617
|
+
interface IValueData {
|
|
1618
|
+
name: string;
|
|
1619
|
+
description?: string | MarkupContent;
|
|
1620
|
+
references?: IReference[];
|
|
1621
|
+
browsers?: string[];
|
|
1622
|
+
status?: BaselineStatus;
|
|
1623
|
+
}
|
|
1624
|
+
interface IValueSet {
|
|
1625
|
+
name: string;
|
|
1626
|
+
values: IValueData[];
|
|
1627
|
+
}
|
|
1628
|
+
interface IAttributeData {
|
|
1629
|
+
name: string;
|
|
1630
|
+
description?: string | MarkupContent;
|
|
1631
|
+
valueSet?: string;
|
|
1632
|
+
values?: IValueData[];
|
|
1633
|
+
references?: IReference[];
|
|
1634
|
+
browsers?: string[];
|
|
1635
|
+
status?: BaselineStatus;
|
|
1636
|
+
}
|
|
1637
|
+
interface ITagData {
|
|
1638
|
+
name: string;
|
|
1639
|
+
description?: string | MarkupContent;
|
|
1640
|
+
attributes: IAttributeData[];
|
|
1641
|
+
references?: IReference[];
|
|
1642
|
+
void?: boolean;
|
|
1643
|
+
browsers?: string[];
|
|
1644
|
+
status?: BaselineStatus;
|
|
1645
|
+
}
|
|
1646
|
+
interface HTMLDataV1 {
|
|
1647
|
+
version: 1 | 1.1;
|
|
1648
|
+
tags?: ITagData[];
|
|
1649
|
+
globalAttributes?: IAttributeData[];
|
|
1650
|
+
valueSets?: IValueSet[];
|
|
1651
|
+
}
|
|
1652
|
+
//#endregion
|
|
1653
|
+
//#region src/types/lsp.d.ts
|
|
1654
|
+
/**
|
|
1655
|
+
* JavaScript a plugin embeds in HTML, described for the language server: which files carry it, where it sits in their text, and
|
|
1656
|
+
* what the code can see. The server serves those regions through the project's TypeScript, as TypeScript.
|
|
1657
|
+
*/
|
|
1658
|
+
interface EmbeddedLanguage {
|
|
1659
|
+
/** Names the virtual document the regions are served from, so diagnostics say where they come from. */
|
|
1660
|
+
name: string;
|
|
1661
|
+
/** Whether a file carries this language, given its path relative to the project root. */
|
|
1662
|
+
filter: (file: string) => boolean;
|
|
1663
|
+
/**
|
|
1664
|
+
* The regions in a matching document, as offsets into its text, in order and not overlapping. A region a plugin earlier in the
|
|
1665
|
+
* config claimed already stays that plugin's: the core plugin, last in the config, only gets the scripts nobody else knows.
|
|
1666
|
+
*/
|
|
1667
|
+
findRegions: (document: DocumentInfo) => EmbeddedRegion[];
|
|
1668
|
+
/**
|
|
1669
|
+
* Whether the editor's own grammar colours the regions, a `<script type="application/x-typescript">` body say. The server then
|
|
1670
|
+
* colours only what TypeScript knows about the identifiers; otherwise it colours the keywords, literals and operators as well.
|
|
1671
|
+
*/
|
|
1672
|
+
isColouredByEditor?: boolean;
|
|
1673
|
+
/**
|
|
1674
|
+
* Appended to the virtual document: declarations for what the regions' code can see. In a module they shadow globals of the
|
|
1675
|
+
* same name; in a script, whose top level is the global scope, they are those globals.
|
|
1676
|
+
*/
|
|
1677
|
+
prelude?: string | ((document: DocumentInfo) => string);
|
|
1678
|
+
}
|
|
1679
|
+
/** A stretch of a document, as offsets into its text. */
|
|
1680
|
+
interface TextRange {
|
|
1681
|
+
start: number;
|
|
1682
|
+
end: number;
|
|
1683
|
+
}
|
|
1684
|
+
/** A stretch of a document in an embedded language. */
|
|
1685
|
+
interface EmbeddedRegion extends TextRange {
|
|
1686
|
+
/**
|
|
1687
|
+
* Whether the code is a module of its own, a `<script type="module">` say: served as its own file, so its top level is its
|
|
1688
|
+
* alone, rather than with the language's other regions, which share a scope like classic scripts do.
|
|
1689
|
+
*/
|
|
1690
|
+
isModule?: boolean;
|
|
1691
|
+
/**
|
|
1692
|
+
* The whole construct the code sits in, delimiters included, `{{ … }}` for a placeholder: what the languages around it see as a
|
|
1693
|
+
* hole. The region itself when left out.
|
|
1694
|
+
*/
|
|
1695
|
+
extent?: TextRange;
|
|
1696
|
+
}
|
|
1697
|
+
/**
|
|
1698
|
+
* A document as the language server parsed it, so a plugin never has to: the elements with their attributes and where everything
|
|
1699
|
+
* sits, and a resolver for the sources they point at.
|
|
1700
|
+
*/
|
|
1701
|
+
interface DocumentInfo {
|
|
1702
|
+
/** The document's path relative to the project root. */
|
|
1703
|
+
file: string;
|
|
1704
|
+
/** The document's HTML text. For a markdown document, the parts that can never be HTML are blanked out. */
|
|
1705
|
+
text: string;
|
|
1706
|
+
/** Every element in document order. */
|
|
1707
|
+
elements: ElementInfo[];
|
|
1708
|
+
/** The elements with one of the given tag names. */
|
|
1709
|
+
select: (...names: string[]) => ElementInfo[];
|
|
1710
|
+
/** The text of a range, an element's content say. */
|
|
1711
|
+
textOf: (range: TextRange) => string;
|
|
1712
|
+
/** Resolves a source the way the build does, relative to the document and through the project's aliases. */
|
|
1713
|
+
resolve: (source: string) => ResolvedSource | undefined;
|
|
1714
|
+
}
|
|
1715
|
+
/** Where a source lands once resolved. */
|
|
1716
|
+
interface ResolvedSource {
|
|
1717
|
+
/** The absolute path the source lands on. */
|
|
1718
|
+
path: string;
|
|
1719
|
+
/** Whether there is a file there. */
|
|
1720
|
+
exists: boolean;
|
|
1721
|
+
}
|
|
1722
|
+
/** An element of the document, with its attributes and where it sits. */
|
|
1723
|
+
interface ElementInfo {
|
|
1724
|
+
/** The tag name, lower case. */
|
|
1725
|
+
name: string;
|
|
1726
|
+
/** The attributes in the start tag, in order. */
|
|
1727
|
+
attributes: AttributeInfo[];
|
|
1728
|
+
/** The enclosing element, or nothing at the top level. */
|
|
1729
|
+
parent: ElementInfo | undefined;
|
|
1730
|
+
/** The elements directly inside. */
|
|
1731
|
+
children: ElementInfo[];
|
|
1732
|
+
/** The whole element, from its `<` to the end of its end tag, or of its start tag when it has none. */
|
|
1733
|
+
range: TextRange;
|
|
1734
|
+
/** The tag name in the start tag. */
|
|
1735
|
+
nameRange: TextRange;
|
|
1736
|
+
/** Between the start and the end tag, or up to where the element ends when it has no end tag; nothing for a void element. */
|
|
1737
|
+
contentRange: TextRange | undefined;
|
|
1738
|
+
/** The attribute with a name, matched regardless of case. */
|
|
1739
|
+
attribute: (name: string) => AttributeInfo | undefined;
|
|
1740
|
+
/** Whether an attribute with a name is there, regardless of case. */
|
|
1741
|
+
has: (name: string) => boolean;
|
|
1742
|
+
}
|
|
1743
|
+
/** An attribute of an element, with its value unquoted. */
|
|
1744
|
+
interface AttributeInfo {
|
|
1745
|
+
/** The attribute name as written. */
|
|
1746
|
+
name: string;
|
|
1747
|
+
/** The value without its quotes, or nothing for an attribute written without a value. */
|
|
1748
|
+
value: string | undefined;
|
|
1749
|
+
/** The element the attribute is on. */
|
|
1750
|
+
element: ElementInfo;
|
|
1751
|
+
/** The attribute name in the start tag. */
|
|
1752
|
+
nameRange: TextRange;
|
|
1753
|
+
/** The value without its quotes, when there is one. */
|
|
1754
|
+
valueRange: TextRange | undefined;
|
|
1755
|
+
}
|
|
1756
|
+
/** Where a problem is: an element underlines its tag name, an attribute its value or else its name, a range itself. */
|
|
1757
|
+
type ProblemTarget = ElementInfo | AttributeInfo | TextRange;
|
|
1758
|
+
/** Collects what a plugin finds wrong with a document, each problem shown at its target with the plugin's name. */
|
|
1759
|
+
interface ProblemReporter {
|
|
1760
|
+
/** Something the build would reject. */
|
|
1761
|
+
error: (target: ProblemTarget, message: string) => void;
|
|
1762
|
+
/** Something the build accepts but that is likely a mistake. */
|
|
1763
|
+
warn: (target: ProblemTarget, message: string) => void;
|
|
1764
|
+
/** Something worth knowing. */
|
|
1765
|
+
info: (target: ProblemTarget, message: string) => void;
|
|
1766
|
+
/** A suggestion, shown without underlining. */
|
|
1767
|
+
hint: (target: ProblemTarget, message: string) => void;
|
|
1768
|
+
}
|
|
1769
|
+
//#endregion
|
|
1770
|
+
//#region src/types/plugin.d.ts
|
|
1771
|
+
type FastifyHandlerParameters = Parameters<onRequestHookHandler>;
|
|
1772
|
+
type ServerReply = FastifyHandlerParameters[1];
|
|
1773
|
+
type ServerRequest = FastifyHandlerParameters[0];
|
|
1774
|
+
interface MetadataSource {
|
|
1775
|
+
get source(): string;
|
|
1776
|
+
set source(value: string);
|
|
1777
|
+
node?: HTMLElement$1 | NodePath$1 | Postcss["AtRule"] | Postcss["Declaration"] | ImageResource | object;
|
|
1778
|
+
}
|
|
1779
|
+
interface ResolveResult {
|
|
1780
|
+
source: string;
|
|
1781
|
+
dependencyID?: string;
|
|
1782
|
+
}
|
|
1783
|
+
/**
|
|
1784
|
+
* A format or minify pass handed over instead of run, described well enough for another thread to run it: the module that exports
|
|
1785
|
+
* the pass, the name it is exported under, and everything the pass needs besides the code itself.
|
|
1786
|
+
*/
|
|
1787
|
+
interface DeferredPass {
|
|
1788
|
+
/** Imported as written, from a context unrelated to the plugin, so it has to resolve on its own — an `import.meta.resolve` URL. */
|
|
1789
|
+
module: string;
|
|
1790
|
+
export: string;
|
|
1791
|
+
/** Crosses a thread boundary, so it has to survive a structured clone. */
|
|
1792
|
+
payload?: unknown;
|
|
1793
|
+
}
|
|
1794
|
+
/** What the module of a `DeferredPass` has to export under the name the pass gives. */
|
|
1795
|
+
type DeferredPassHandler<Payload = void> = (code: string, payload: Payload) => string | Promise<string>;
|
|
1796
|
+
interface StringifyOptions {
|
|
1797
|
+
minify?: boolean;
|
|
1798
|
+
format?: boolean;
|
|
1799
|
+
/**
|
|
1800
|
+
* Offered by callers that would rather run the final pass somewhere else. A plugin that takes it up describes its pass, returns
|
|
1801
|
+
* the code untouched and leaves the running to the caller. Ignoring it and doing the work is always correct.
|
|
1802
|
+
*/
|
|
1803
|
+
defer?: (pass: DeferredPass) => void;
|
|
1804
|
+
}
|
|
1805
|
+
interface Plugin {
|
|
1806
|
+
name: string;
|
|
1807
|
+
setup?: (this: App$1) => void | Promise<void>;
|
|
1808
|
+
/**
|
|
1809
|
+
* Runs when the app is closed, in reverse plugin order. Release whatever `setup` took hold of (servers, watchers, workers). May
|
|
1810
|
+
* run after a `setup` that never finished, so expect to find nothing to release.
|
|
1811
|
+
*/
|
|
1812
|
+
teardown?: (this: App$1) => void | Promise<void>;
|
|
1813
|
+
read?: (this: App$1, absolutePath: string) => string | void | Promise<string | void>;
|
|
1814
|
+
load?: (this: App$1, content: string, relativePath: string, options: {
|
|
1815
|
+
type?: string;
|
|
1816
|
+
}) => MetadataBase$1 | null | void | Promise<MetadataBase$1 | null | void>;
|
|
1817
|
+
resolveSource?: (this: App$1, source: string, filePath: string, parentMetadata: MetadataBase$1) => ResolveResult | void | Promise<ResolveResult | void>;
|
|
1818
|
+
transformSource?: (this: App$1, source: string, filePath: string, parentMetadata: MetadataBase$1, dependencyID?: string) => string | void | Promise<string | void>;
|
|
1819
|
+
preTransform?: (this: App$1) => void | Promise<void>;
|
|
1820
|
+
transform?: (this: App$1, metadata: MetadataBase$1) => void | Promise<void>;
|
|
1821
|
+
postTransform?: (this: App$1) => void | Promise<void>;
|
|
1822
|
+
/** Runs once, after every transform. Walk `metadataList` for the files to emit, and leave nothing outstanding on the way out. */
|
|
1823
|
+
write?: (this: App$1) => void | Promise<void>;
|
|
1824
|
+
postBuild?: (this: App$1) => void | Promise<void>;
|
|
1825
|
+
clone?: (this: App$1, metadata: MetadataBase$1) => void | MetadataBase$1;
|
|
1826
|
+
stringify?: (this: App$1, metadata: MetadataBase$1, options: StringifyOptions) => void | string | Promise<string | void>;
|
|
1827
|
+
sourcesProvider?: (this: App$1, metadata: MetadataBase$1) => MetadataSource[] | void | Promise<MetadataSource[] | void>;
|
|
1828
|
+
rebaseSource?: (this: App$1, source: string, filePath: string, newAbsolutePath: string) => string | void | Promise<string | void>;
|
|
1829
|
+
onMetadataRebase?: (this: App$1, metadata: MetadataBase$1, oldAbsolutePath: string, newAbsolutePath: string) => void | Promise<void>;
|
|
1830
|
+
handleRequest?: (this: App$1, requestPath: string, reply: ServerReply, request: ServerRequest) => boolean | void | Promise<boolean | void>;
|
|
1831
|
+
resolveRequestPath?: (this: App$1, requestPath: string) => string | void | Promise<string | void>;
|
|
1832
|
+
onFileEvent?: (this: App$1, event: "change" | "add" | "unlink", filePath: string) => void | Promise<void>;
|
|
1833
|
+
resolveCompileList?: (this: App$1, compileSet: Set<string>, event: "change" | "add" | "unlink", filePath: string) => void | Promise<void>;
|
|
1834
|
+
/**
|
|
1835
|
+
* Registers commands on the CLI. `config` has already been loaded from `configPath`, with its root made absolute against
|
|
1836
|
+
* `projectDirectory` — the directory the CLI was pointed at.
|
|
1837
|
+
*/
|
|
1838
|
+
cli?: (this: CliProgram$1, config: AppConfig$1, configPath: string, projectDirectory: string) => void | Promise<void>;
|
|
1839
|
+
/** The tags and attributes the plugin adds to HTML, for completion and hover in the editor. */
|
|
1840
|
+
lspHtmlData?: () => HTMLDataV1 | undefined | Promise<HTMLDataV1 | undefined>;
|
|
1841
|
+
/** Languages the plugin embeds in HTML, for the language server to serve their regions through the project's TypeScript. */
|
|
1842
|
+
lspEmbeddedLanguages?: () => EmbeddedLanguage[];
|
|
1843
|
+
/**
|
|
1844
|
+
* Checks a document for the language server, reporting what the plugin finds wrong: misused tags, attributes, values. Runs on
|
|
1845
|
+
* every edit, over the source as written, before any plugin has run: a value another plugin fills in later (see `isDynamic`) or
|
|
1846
|
+
* a tag another plugin rewrites first is not a mistake, so only report what no plugin order can make right. `checkFileExists`
|
|
1847
|
+
* and the other helpers exported by the package cover the common checks.
|
|
1848
|
+
*/
|
|
1849
|
+
lspValidate?: (document: DocumentInfo, report: ProblemReporter) => void | Promise<void>;
|
|
1850
|
+
}
|
|
1851
|
+
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]; }>;
|
|
1852
|
+
type BoundPlugin = RemoveThis<Plugin>;
|
|
1853
|
+
//#endregion
|
|
1854
|
+
//#region src/helpers/dependency-tracker.d.ts
|
|
1855
|
+
/**
|
|
1856
|
+
* Tracks bidirectional dependencies between importers and their sources.\
|
|
1857
|
+
* Handles reconciliation when dependencies change, so stale entries are automatically removed when an importer stops referencing
|
|
1858
|
+
* a source.
|
|
1859
|
+
*/
|
|
1860
|
+
declare class DependencyTracker {
|
|
1861
|
+
#private;
|
|
1862
|
+
/** Updates the full set of sources for a given importer, reconciling any stale entries from previous calls. */
|
|
1863
|
+
update(importer: string, sources: Iterable<string>): void;
|
|
1864
|
+
/** Deletes all dependency data for a given id, whether it's acting as an importer, a source, or both (e.g. on file unlink). */
|
|
1865
|
+
delete(id: string): void;
|
|
1866
|
+
/** Returns all importers that depend on a given source, or an empty set. */
|
|
1867
|
+
getImporters(source: string): ReadonlySet<string>;
|
|
1868
|
+
/** Returns all sources that a given importer depends on, or an empty set. */
|
|
1869
|
+
getSources(importer: string): ReadonlySet<string>;
|
|
1870
|
+
}
|
|
1871
|
+
//#endregion
|
|
1872
|
+
//#region src/helpers/lsp-checks.d.ts
|
|
1873
|
+
/** Whether an attribute value is only known later: it holds a placeholder something else fills in. */
|
|
1874
|
+
declare function isDynamic(value: string): boolean;
|
|
1875
|
+
/**
|
|
1876
|
+
* Reports an attribute whose value is a path to a file that is not there. A URL, an absolute link or a value with a placeholder
|
|
1877
|
+
* is left alone.
|
|
1878
|
+
*/
|
|
1879
|
+
declare function checkFileExists(attribute: AttributeInfo, document: DocumentInfo, report: ProblemReporter): void;
|
|
1880
|
+
/** Reports an attribute whose value is not the JSON of an object. A value with a placeholder is left alone. */
|
|
1881
|
+
declare function checkJsonObject(attribute: AttributeInfo, report: ProblemReporter): void;
|
|
1882
|
+
/** Whether a string is the JSON of an object. */
|
|
1883
|
+
declare function isJsonObject(text: string): boolean;
|
|
1884
|
+
/** Whether a script element holds JavaScript, going by its `type`: the build leaves any other kind of script alone. */
|
|
1885
|
+
declare function isJavaScript(script: ElementInfo): boolean;
|
|
1886
|
+
/** Whether a `<script>` is marked as TypeScript for the editor, which also keeps the editor's own script support out. */
|
|
1887
|
+
declare function isTypeScriptScript(script: ElementInfo): boolean;
|
|
1888
|
+
/** Whether an element has nothing but whitespace between its tags. */
|
|
1889
|
+
declare function isEmptyElement(element: ElementInfo, document: DocumentInfo): boolean;
|
|
1890
|
+
//#endregion
|
|
1891
|
+
//#region src/utilities/html-links.d.ts
|
|
1892
|
+
/**
|
|
1893
|
+
* Checks if the link is an HTML link (not a file link)
|
|
1894
|
+
*
|
|
1895
|
+
* @param source - The link
|
|
1896
|
+
* @returns
|
|
1897
|
+
*/
|
|
1898
|
+
declare function isHtmlLink(source: string): boolean;
|
|
1899
|
+
declare function isValidRelativePath(source: string): boolean;
|
|
1900
|
+
declare function splitHtmlLink(url: string): [string, string];
|
|
1901
|
+
//#endregion
|
|
1902
|
+
//#region src/utilities/metadata-utilities.d.ts
|
|
1903
|
+
declare function isScriptMetadata(metadata: MetadataBase$1 | undefined): metadata is ScriptMetadata$1;
|
|
1904
|
+
declare function isPackageMetadata(metadata: MetadataBase$1 | undefined): metadata is PackageMetadata$1;
|
|
1905
|
+
declare function isHtmlMetadata(metadata: MetadataBase$1 | undefined): metadata is HtmlMetadata$1;
|
|
1906
|
+
declare function isStyleMetadata(metadata: MetadataBase$1 | undefined): metadata is StyleMetadata$1;
|
|
1907
|
+
declare function isSvgMetadata(metadata: MetadataBase$1 | undefined): metadata is SvgMetadata$1;
|
|
1908
|
+
declare function isMarkdownMetadata(metadata: MetadataBase$1 | undefined): metadata is MarkdownMetadata$1;
|
|
1909
|
+
declare function isTextAssetMetadata(metadata: MetadataBase$1 | undefined): metadata is TextAssetMetadata$1;
|
|
1910
|
+
declare function isBinaryAssetMetadata(metadata: MetadataBase$1 | undefined): metadata is BinaryAssetMetadata$1;
|
|
1911
|
+
declare function isWebManifestMetadata(metadata: MetadataBase$1): metadata is WebManifestMetadata$1;
|
|
1912
|
+
/**
|
|
1913
|
+
* Returns script-related metadata entries.
|
|
1914
|
+
*
|
|
1915
|
+
* - If the input is ScriptMetadata, it returns it directly.
|
|
1916
|
+
* - If the input is HtmlMetadata, it scans <script> tags in the AST and resolves their associated ScriptMetadata using the metadata
|
|
1917
|
+
* ID attribute.
|
|
1918
|
+
*/
|
|
1919
|
+
declare function filterScriptMetadata(metadata: MetadataBase$1): {
|
|
1920
|
+
metadata: ScriptMetadata$1;
|
|
1921
|
+
tag?: HTMLElement$2;
|
|
1922
|
+
htmlMetadata?: HtmlMetadata$1;
|
|
1923
|
+
}[];
|
|
1924
|
+
/**
|
|
1925
|
+
* Returns style-related metadata entries.
|
|
1926
|
+
*
|
|
1927
|
+
* - If the input is StyleMetadata, it returns it directly.
|
|
1928
|
+
* - If the input is HtmlMetadata, it scans <style> tags in the AST and resolves their associated StyleMetadata using the metadata
|
|
1929
|
+
* ID attribute.
|
|
1930
|
+
*/
|
|
1931
|
+
declare function filterStyleMetadata(metadata: MetadataBase$1): {
|
|
1932
|
+
metadata: StyleMetadata$1;
|
|
1933
|
+
tag?: HTMLElement$2;
|
|
1934
|
+
htmlMetadata?: HtmlMetadata$1;
|
|
1935
|
+
}[];
|
|
1936
|
+
declare namespace path_d_exports {
|
|
1937
|
+
export { appendForwardSlash, basename, dirname, extname, firstPart, isAbsolute, isPathMatch, isSubpath, join, normalize, parse$1 as parse, parsePatterns, rebaseRelativePath, relative, replaceExtension, resolve, sourceRelativeToRoot, trimDotPrefix };
|
|
1938
|
+
}
|
|
1523
1939
|
declare const join: (...arguments_: string[]) => string;
|
|
1524
1940
|
declare const relative: (from: string, to: string) => string;
|
|
1525
1941
|
declare const dirname: (path: string) => string;
|
|
@@ -1551,11 +1967,7 @@ interface SourceRelativeToRootOptions {
|
|
|
1551
1967
|
sourcePath: string;
|
|
1552
1968
|
}
|
|
1553
1969
|
/** Calculates the relative path of a source path to the root. */
|
|
1554
|
-
declare function sourceRelativeToRoot({
|
|
1555
|
-
root,
|
|
1556
|
-
filePath,
|
|
1557
|
-
sourcePath
|
|
1558
|
-
}: SourceRelativeToRootOptions): string;
|
|
1970
|
+
declare function sourceRelativeToRoot({ root, filePath, sourcePath }: SourceRelativeToRootOptions): string;
|
|
1559
1971
|
/** Replaces the extension of a given path. */
|
|
1560
1972
|
declare function replaceExtension(filePath: string, extension: string): string;
|
|
1561
1973
|
/** Appends a forward slash to the end of a path if it doesn't already end with one. */
|
|
@@ -1564,52 +1976,19 @@ declare const appendForwardSlash: (path: string) => string;
|
|
|
1564
1976
|
declare const trimDotPrefix: (path: string) => string;
|
|
1565
1977
|
/** Returns the first segment of a path. */
|
|
1566
1978
|
declare function firstPart(path: string): string;
|
|
1979
|
+
/**
|
|
1980
|
+
* Splits a semicolon-separated attribute value into an array of trimmed glob patterns.
|
|
1981
|
+
*
|
|
1982
|
+
* Returns `undefined` when the input is not a string, and an empty array for an empty string.
|
|
1983
|
+
*/
|
|
1984
|
+
declare function parsePatterns(string: string | null | undefined): string[] | undefined;
|
|
1567
1985
|
interface MatchPathOptions {
|
|
1568
1986
|
include: string | string[];
|
|
1569
1987
|
ignore?: string | string[];
|
|
1570
1988
|
root: string;
|
|
1571
1989
|
}
|
|
1572
1990
|
/** Checks if a file path matches a set of patterns. */
|
|
1573
|
-
declare function
|
|
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
|
-
}[];
|
|
1991
|
+
declare function isPathMatch(filePath: string, { include, ignore, root }: MatchPathOptions): boolean;
|
|
1613
1992
|
//#endregion
|
|
1614
1993
|
//#region src/utilities/print-formatted-error.d.ts
|
|
1615
1994
|
type Node$3 = Node$2 | Node$1 | Node;
|
|
@@ -1639,6 +2018,12 @@ declare const printFmtError: (...messageAndErrorWithOptions: [...MessageAndError
|
|
|
1639
2018
|
//#endregion
|
|
1640
2019
|
//#region src/utilities/value-or-error.d.ts
|
|
1641
2020
|
type ValueOrError<T> = [T, null] | [null, Error];
|
|
2021
|
+
declare function handleError<T>(error: unknown, functionName?: string): ValueOrError<T>;
|
|
2022
|
+
interface goErrorsI {
|
|
2023
|
+
<T, A extends unknown[]>(function_: (...arguments_: A) => Promise<T>): (...arguments_: A) => Promise<ValueOrError<T>>;
|
|
2024
|
+
<T, A extends unknown[]>(function_: (...arguments_: A) => T): (...arguments_: A) => ValueOrError<T>;
|
|
2025
|
+
}
|
|
2026
|
+
declare const valueOrError: goErrorsI;
|
|
1642
2027
|
//#endregion
|
|
1643
2028
|
//#region src/utilities/read-file.d.ts
|
|
1644
2029
|
declare function safeReadFile(path: PathLike | FileHandle, options?: ({
|
|
@@ -1656,10 +2041,10 @@ declare function safeReadFileSync(path: PathOrFileDescriptor, options?: {
|
|
|
1656
2041
|
encoding?: null | undefined;
|
|
1657
2042
|
flag?: string | undefined;
|
|
1658
2043
|
} | null): ValueOrError<NonSharedBuffer>;
|
|
1659
|
-
declare function safeReadFileSync(path: PathOrFileDescriptor, options: {
|
|
2044
|
+
declare function safeReadFileSync(path: PathOrFileDescriptor, options: BufferEncoding | {
|
|
1660
2045
|
encoding: BufferEncoding;
|
|
1661
2046
|
flag?: string | undefined;
|
|
1662
|
-
}
|
|
2047
|
+
}): ValueOrError<string>;
|
|
1663
2048
|
declare function safeReadFileSync(path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & {
|
|
1664
2049
|
flag?: string | undefined;
|
|
1665
2050
|
}) | BufferEncoding | null): ValueOrError<string | NonSharedBuffer>;
|
|
@@ -1709,26 +2094,14 @@ declare function cloneObject<T extends object>(object: T): T;
|
|
|
1709
2094
|
declare function hashContent(content: string): string;
|
|
1710
2095
|
declare function escapeHtml(input: string): string;
|
|
1711
2096
|
//#endregion
|
|
1712
|
-
//#region src/
|
|
2097
|
+
//#region src/index.d.ts
|
|
1713
2098
|
/**
|
|
1714
|
-
*
|
|
1715
|
-
*
|
|
1716
|
-
*
|
|
2099
|
+
* Types the config file's default export.
|
|
2100
|
+
*
|
|
2101
|
+
* The config file runs as CommonJS, so it cannot use top-level `await`. Create plugins inside it rather than importing shared
|
|
2102
|
+
* instances: only the config file itself is evaluated again when the dev server reloads it.
|
|
1717
2103
|
*/
|
|
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
2104
|
declare function defineConfig(config: AppConfig): AppConfig;
|
|
1732
2105
|
//#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,
|
|
2106
|
+
export { type App, type AppConfig, type AttributeInfo, 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 DocumentInfo, type ElementInfo, type EmbeddedLanguage, type EmbeddedRegion, 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 ProblemReporter, type ProblemTarget, type ResolveResult, type ResolvedSource, Resolver, type ScriptMetadata, type ServerReply, type ServerRequest, type StringifyOptions, type StyleMetadata, type SvgMetadata, type TextAssetMetadata, type TextRange, ValueOrError, type WebManifestMetadata, assign, bytesToKB, camelCaseToKebabCase, capitalize, checkFileExists, checkJsonObject, clamp, clearLn, cloneObject, defineConfig, downloadContent, escapeHtml, filterScriptMetadata, filterStyleMetadata, getLineColumn, handleError, hashContent, humanReadableBytes, isBinaryAssetMetadata, isDefined, isDynamic, isEmptyElement, isHtmlLink, isHtmlMetadata, isJavaScript, isJsonObject, isMarkdownMetadata, isObject, isPackageMetadata, isScriptMetadata, isStyleMetadata, isSvgMetadata, isTextAssetMetadata, isTypeScriptScript, isURL, isValidRelativePath, isWebManifestMetadata, kebabToCamelCase, mergeMaps, path_d_exports as path, print, printFmtError, safeReadFile, safeReadFileSync, splitHtmlLink, valueOrError };
|
|
1734
2107
|
//# sourceMappingURL=index.d.mts.map
|