weapp-vite 6.8.0 → 6.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto-import-components/resolvers.d.mts +2 -0
- package/dist/auto-import-components/resolvers.mjs +309 -350
- package/dist/auto-routes.d.mts +17 -0
- package/dist/auto-routes.mjs +48 -78
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +2171 -2398
- package/dist/config-IEj3IfSy.d.mts +3128 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +8 -31
- package/dist/createContext-CDgRHY26.mjs +19 -0
- package/dist/file-UprqcX9e.mjs +356 -0
- package/dist/getInstance-jl4yXdc0.mjs +31841 -0
- package/dist/index-B5wBsuYI.d.mts +56 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.mjs +9 -51
- package/dist/json.d.mts +2 -0
- package/dist/json.mjs +32 -14
- package/dist/logger-gutcwWKE.mjs +2 -0
- package/dist/mcp-pzGAH7ob.mjs +6415 -0
- package/dist/mcp.d.mts +30 -0
- package/dist/mcp.mjs +3 -18
- package/dist/pluginHost-SJdl15d3.mjs +24 -0
- package/dist/routes-o20IHwXa.d.mts +13 -0
- package/dist/{runtime.d.ts → runtime.d.mts} +12 -11
- package/dist/runtime.mjs +32 -11
- package/dist/types.d.mts +4 -0
- package/dist/types.mjs +1 -37
- package/dist/volar.d.mts +2 -0
- package/dist/volar.mjs +3 -9
- package/package.json +26 -31
- package/dist/auto-import-components/resolvers.d.ts +0 -10
- package/dist/auto-routes.d.ts +0 -16
- package/dist/chunk-3BOPS2AF.mjs +0 -34
- package/dist/chunk-6N2JYDJN.mjs +0 -13
- package/dist/chunk-BKU4KQJE.mjs +0 -430
- package/dist/chunk-EZOXN44U.mjs +0 -48
- package/dist/chunk-FXWNWYDN.mjs +0 -6
- package/dist/chunk-GJOF3MJY.mjs +0 -39428
- package/dist/chunk-JFV2DERD.mjs +0 -30
- package/dist/chunk-LDBSARE6.mjs +0 -9911
- package/dist/chunk-MIQZQK74.mjs +0 -14
- package/dist/chunk-OU5WM7WT.mjs +0 -41
- package/dist/chunk-X4YQFGKK.mjs +0 -29
- package/dist/cli.d.ts +0 -2
- package/dist/config-D8v221vL.d.ts +0 -1051
- package/dist/config.d.ts +0 -18
- package/dist/file-W4JJII65.mjs +0 -29
- package/dist/getInstance-W65F2IS7.mjs +0 -18
- package/dist/index.d.ts +0 -29
- package/dist/json.d.ts +0 -18
- package/dist/mcp.d.ts +0 -47
- package/dist/routes-74eLuiqj.d.ts +0 -12
- package/dist/types-B6irZnLM.d.ts +0 -46
- package/dist/types.d.ts +0 -29
- package/dist/volar.d.ts +0 -2
|
@@ -0,0 +1,3128 @@
|
|
|
1
|
+
import { c as Resolver, s as ResolvedValue } from "./index-B5wBsuYI.mjs";
|
|
2
|
+
import { t as AutoRoutes } from "./routes-o20IHwXa.mjs";
|
|
3
|
+
import { LoggerConfig } from "@weapp-core/logger";
|
|
4
|
+
import { WeappAstConfig } from "@weapp-vite/ast";
|
|
5
|
+
import { ConfigEnv, ConfigEnv as ConfigEnv$1, InlineConfig, InlineConfig as InlineConfig$1, Plugin as Plugin$1, PluginOption, ResolvedConfig, UserConfig, ViteDevServer, ViteDevServer as ViteDevServer$1, build } from "vite";
|
|
6
|
+
import { InputOption, RolldownBuild, RolldownOptions, RolldownOutput, RolldownOutput as RolldownOutput$1, RolldownPlugin, RolldownPluginOption, RolldownWatcher, RolldownWatcher as RolldownWatcher$1, WatchOptions as RolldownWatchOptions } from "rolldown";
|
|
7
|
+
import { Options } from "rolldown-plugin-dts";
|
|
8
|
+
import { Buffer } from "node:buffer";
|
|
9
|
+
import { PluginOptions } from "vite-tsconfig-paths";
|
|
10
|
+
import { WrapPluginOptions } from "vite-plugin-performance";
|
|
11
|
+
import { ComputedDefinitions as ComputedDefinitions$1, MethodDefinitions as MethodDefinitions$1, Ref, WevuDefaults } from "wevu";
|
|
12
|
+
import { App, App as App$1, Component, Component as Component$1, GenerateType, Page, Page as Page$1, Plugin, Sitemap, Sitemap as Sitemap$1, Theme, Theme as Theme$1 } from "@weapp-core/schematics";
|
|
13
|
+
import { CompilerOptions } from "typescript";
|
|
14
|
+
import { WeappWebPluginOptions } from "@weapp-vite/web/plugin";
|
|
15
|
+
|
|
16
|
+
//#region src/pluginHost.d.ts
|
|
17
|
+
declare const WEAPP_VITE_HOST_NAME = "weapp-vite";
|
|
18
|
+
type WeappViteRuntime = 'miniprogram' | 'web';
|
|
19
|
+
interface WeappViteHostMeta {
|
|
20
|
+
name: typeof WEAPP_VITE_HOST_NAME;
|
|
21
|
+
runtime: WeappViteRuntime;
|
|
22
|
+
}
|
|
23
|
+
declare function createWeappViteHostMeta(runtime: WeappViteRuntime): WeappViteHostMeta;
|
|
24
|
+
declare function applyWeappViteHostMeta(config: InlineConfig, runtime: WeappViteRuntime): InlineConfig;
|
|
25
|
+
declare function resolveWeappViteHostMeta(config: Pick<InlineConfig, 'weappVite'> | undefined): WeappViteHostMeta | undefined;
|
|
26
|
+
declare function isWeappViteHost(config: Pick<InlineConfig, 'weappVite'> | undefined): boolean;
|
|
27
|
+
declare module 'vite' {
|
|
28
|
+
interface UserConfig {
|
|
29
|
+
weappVite?: WeappViteHostMeta;
|
|
30
|
+
}
|
|
31
|
+
interface ResolvedConfig {
|
|
32
|
+
weappVite?: WeappViteHostMeta;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/types/config/foundation.d.ts
|
|
37
|
+
type NpmBuildOptions = InlineConfig;
|
|
38
|
+
/**
|
|
39
|
+
* @description 支付宝平台本地 npm 输出模式
|
|
40
|
+
*/
|
|
41
|
+
type AlipayNpmMode = 'miniprogram_npm' | 'node_modules';
|
|
42
|
+
interface Alias {
|
|
43
|
+
/**
|
|
44
|
+
* @description 被匹配的原始路径或正则
|
|
45
|
+
*/
|
|
46
|
+
find: string | RegExp;
|
|
47
|
+
/**
|
|
48
|
+
* @description 命中后的替换路径
|
|
49
|
+
*/
|
|
50
|
+
replacement: string;
|
|
51
|
+
}
|
|
52
|
+
interface ResolvedAlias {
|
|
53
|
+
/**
|
|
54
|
+
* @description 解析后的匹配条件
|
|
55
|
+
*/
|
|
56
|
+
find: string | RegExp;
|
|
57
|
+
/**
|
|
58
|
+
* @description 解析后的替换路径
|
|
59
|
+
*/
|
|
60
|
+
replacement: string;
|
|
61
|
+
}
|
|
62
|
+
interface AliasOptions {
|
|
63
|
+
/**
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* entries: [
|
|
67
|
+
* {
|
|
68
|
+
* find: '@',
|
|
69
|
+
* replacement: path.resolve(import.meta.dirname, 'components'),
|
|
70
|
+
* },
|
|
71
|
+
* ]
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
entries?: readonly Alias[] | {
|
|
75
|
+
[find: string]: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
type MpPlatform = 'weapp' | 'alipay' | 'tt' | 'swan' | 'jd' | 'xhs';
|
|
79
|
+
interface SubPackage {
|
|
80
|
+
/**
|
|
81
|
+
* @description 分包内页面列表,路径相对于分包 root
|
|
82
|
+
*/
|
|
83
|
+
pages: string[];
|
|
84
|
+
/**
|
|
85
|
+
* @description 分包根目录
|
|
86
|
+
*/
|
|
87
|
+
root: string;
|
|
88
|
+
/**
|
|
89
|
+
* @description 是否为独立分包
|
|
90
|
+
*/
|
|
91
|
+
independent?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* @description 分包入口文件,也基于 root 解析
|
|
94
|
+
*/
|
|
95
|
+
entry?: string;
|
|
96
|
+
/**
|
|
97
|
+
* @description 分包名称
|
|
98
|
+
*/
|
|
99
|
+
name?: string;
|
|
100
|
+
/**
|
|
101
|
+
* @description 分包依赖范围控制
|
|
102
|
+
*/
|
|
103
|
+
dependencies?: (string | RegExp)[];
|
|
104
|
+
/**
|
|
105
|
+
* @description 分包级额外 inline Vite 配置
|
|
106
|
+
*/
|
|
107
|
+
inlineConfig?: Partial<InlineConfig>;
|
|
108
|
+
}
|
|
109
|
+
type SubPackageStyleScope = 'all' | 'pages' | 'components';
|
|
110
|
+
interface SubPackageStyleConfigObject {
|
|
111
|
+
/** 样式文件路径,可以是相对分包 root、相对 `srcRoot` 或绝对路径 */
|
|
112
|
+
source: string;
|
|
113
|
+
/**
|
|
114
|
+
* @description 作用范围快捷配置
|
|
115
|
+
*/
|
|
116
|
+
scope?: SubPackageStyleScope;
|
|
117
|
+
/** 自定义包含路径,支持传入单个 glob 或数组,默认覆盖分包内所有文件 */
|
|
118
|
+
include?: string | string[];
|
|
119
|
+
/** 自定义排除路径,支持传入单个 glob 或数组 */
|
|
120
|
+
exclude?: string | string[];
|
|
121
|
+
}
|
|
122
|
+
type SubPackageStyleConfigEntry = string | SubPackageStyleConfigObject;
|
|
123
|
+
interface SubPackageStyleEntry {
|
|
124
|
+
source: string;
|
|
125
|
+
absolutePath: string;
|
|
126
|
+
outputRelativePath: string;
|
|
127
|
+
inputExtension: string;
|
|
128
|
+
scope: SubPackageStyleScope;
|
|
129
|
+
include: string[];
|
|
130
|
+
exclude: string[];
|
|
131
|
+
}
|
|
132
|
+
type GenerateExtensionsOptions = Partial<{
|
|
133
|
+
js: 'js' | 'ts' | (string & {});
|
|
134
|
+
json: 'js' | 'ts' | 'json' | (string & {});
|
|
135
|
+
wxml: 'wxml' | (string & {});
|
|
136
|
+
wxss: 'wxss' | 'scss' | 'less' | 'css' | (string & {});
|
|
137
|
+
}>;
|
|
138
|
+
type GenerateDirsOptions = Partial<{
|
|
139
|
+
app: string;
|
|
140
|
+
page: string;
|
|
141
|
+
component: string;
|
|
142
|
+
}>;
|
|
143
|
+
type GenerateFilenamesOptions = Partial<{
|
|
144
|
+
app: string;
|
|
145
|
+
page: string;
|
|
146
|
+
component: string;
|
|
147
|
+
}>;
|
|
148
|
+
type GenerateFileType = 'js' | 'json' | 'wxml' | 'wxss';
|
|
149
|
+
interface GenerateTemplateContext {
|
|
150
|
+
type: GenerateType;
|
|
151
|
+
fileType: GenerateFileType;
|
|
152
|
+
fileName: string;
|
|
153
|
+
outDir: string;
|
|
154
|
+
extension: string;
|
|
155
|
+
cwd: string;
|
|
156
|
+
defaultCode?: string;
|
|
157
|
+
}
|
|
158
|
+
interface GenerateTemplateFileSource {
|
|
159
|
+
path: string;
|
|
160
|
+
}
|
|
161
|
+
interface GenerateTemplateInlineSource {
|
|
162
|
+
content: string;
|
|
163
|
+
}
|
|
164
|
+
type GenerateTemplateFactory = (context: GenerateTemplateContext) => string | Promise<string> | undefined;
|
|
165
|
+
type GenerateTemplate = string | GenerateTemplateFileSource | GenerateTemplateInlineSource | GenerateTemplateFactory;
|
|
166
|
+
type GenerateTemplateEntry = Partial<Record<GenerateFileType, GenerateTemplate>>;
|
|
167
|
+
type GenerateTemplateScope = GenerateType | 'shared';
|
|
168
|
+
type GenerateTemplatesConfig = Partial<Record<GenerateTemplateScope, GenerateTemplateEntry>>;
|
|
169
|
+
interface GenerateOptions {
|
|
170
|
+
extensions?: GenerateExtensionsOptions;
|
|
171
|
+
dirs?: GenerateDirsOptions;
|
|
172
|
+
filenames?: GenerateFilenamesOptions;
|
|
173
|
+
templates?: GenerateTemplatesConfig;
|
|
174
|
+
}
|
|
175
|
+
interface CopyOptions {
|
|
176
|
+
include?: CopyGlobs;
|
|
177
|
+
exclude?: CopyGlobs;
|
|
178
|
+
filter?: (filePath: string, index: number, array: string[]) => boolean;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* @description 资源复制使用的 glob 列表
|
|
182
|
+
*/
|
|
183
|
+
type CopyGlobs = string[];
|
|
184
|
+
interface WeappWebConfig {
|
|
185
|
+
enable?: boolean;
|
|
186
|
+
root?: string;
|
|
187
|
+
srcDir?: string;
|
|
188
|
+
outDir?: string;
|
|
189
|
+
pluginOptions?: Partial<Omit<WeappWebPluginOptions, 'srcDir'>>;
|
|
190
|
+
vite?: InlineConfig;
|
|
191
|
+
}
|
|
192
|
+
interface WeappLibEntryContext {
|
|
193
|
+
name: string;
|
|
194
|
+
input: string;
|
|
195
|
+
}
|
|
196
|
+
type WeappLibFileName = string | ((context: WeappLibEntryContext) => string);
|
|
197
|
+
type WeappLibComponentJson = boolean | 'auto' | ((context: WeappLibEntryContext) => Record<string, any>);
|
|
198
|
+
interface WeappLibInternalDtsOptions {
|
|
199
|
+
tsconfig?: string | false;
|
|
200
|
+
compilerOptions?: CompilerOptions;
|
|
201
|
+
vueCompilerOptions?: Record<string, any>;
|
|
202
|
+
}
|
|
203
|
+
interface WeappLibVueTscOptions {
|
|
204
|
+
tsconfig?: Record<string, any>;
|
|
205
|
+
compilerOptions?: CompilerOptions;
|
|
206
|
+
vueCompilerOptions?: Record<string, any>;
|
|
207
|
+
}
|
|
208
|
+
interface WeappLibDtsOptions {
|
|
209
|
+
enabled?: boolean;
|
|
210
|
+
mode?: 'internal' | 'vue-tsc';
|
|
211
|
+
internal?: WeappLibInternalDtsOptions;
|
|
212
|
+
rolldown?: Options;
|
|
213
|
+
vueTsc?: WeappLibVueTscOptions;
|
|
214
|
+
}
|
|
215
|
+
interface WeappLibConfig {
|
|
216
|
+
entry: string | string[] | Record<string, string>;
|
|
217
|
+
root?: string;
|
|
218
|
+
outDir?: string;
|
|
219
|
+
preservePath?: boolean;
|
|
220
|
+
fileName?: WeappLibFileName;
|
|
221
|
+
componentJson?: WeappLibComponentJson;
|
|
222
|
+
dts?: boolean | WeappLibDtsOptions;
|
|
223
|
+
}
|
|
224
|
+
interface BuildNpmPackageMeta {
|
|
225
|
+
name: string;
|
|
226
|
+
entry: InputOption;
|
|
227
|
+
}
|
|
228
|
+
interface NpmSubPackageConfig {
|
|
229
|
+
dependencies?: (string | RegExp)[];
|
|
230
|
+
}
|
|
231
|
+
interface NpmMainPackageConfig {
|
|
232
|
+
dependencies?: false | (string | RegExp)[];
|
|
233
|
+
}
|
|
234
|
+
type JsFormat = 'cjs' | 'esm';
|
|
235
|
+
type SharedChunkStrategy = 'hoist' | 'duplicate';
|
|
236
|
+
type SharedChunkMode = 'common' | 'path' | 'inline';
|
|
237
|
+
type SharedChunkDynamicImports = 'preserve' | 'inline';
|
|
238
|
+
interface SharedChunkOverride {
|
|
239
|
+
test: string | RegExp;
|
|
240
|
+
mode: SharedChunkMode;
|
|
241
|
+
}
|
|
242
|
+
type JsonMergeStage = 'defaults' | 'json-block' | 'auto-using-components' | 'component-generics' | 'macro' | 'emit' | 'merge-existing';
|
|
243
|
+
interface JsonMergeContext {
|
|
244
|
+
filename?: string;
|
|
245
|
+
kind?: 'app' | 'page' | 'component' | 'unknown';
|
|
246
|
+
stage: JsonMergeStage;
|
|
247
|
+
}
|
|
248
|
+
type JsonMergeFunction = (target: Record<string, any>, source: Record<string, any>, context: JsonMergeContext) => Record<string, any> | void;
|
|
249
|
+
type JsonMergeStrategy = 'deep' | 'assign' | 'replace' | JsonMergeFunction;
|
|
250
|
+
interface JsonConfig {
|
|
251
|
+
defaults?: {
|
|
252
|
+
app?: Record<string, any>;
|
|
253
|
+
page?: Record<string, any>;
|
|
254
|
+
component?: Record<string, any>;
|
|
255
|
+
};
|
|
256
|
+
mergeStrategy?: JsonMergeStrategy;
|
|
257
|
+
}
|
|
258
|
+
interface ChunksConfig {
|
|
259
|
+
sharedStrategy?: SharedChunkStrategy;
|
|
260
|
+
sharedMode?: SharedChunkMode;
|
|
261
|
+
sharedOverrides?: SharedChunkOverride[];
|
|
262
|
+
sharedPathRoot?: string;
|
|
263
|
+
dynamicImports?: SharedChunkDynamicImports;
|
|
264
|
+
logOptimization?: boolean;
|
|
265
|
+
forceDuplicatePatterns?: (string | RegExp)[];
|
|
266
|
+
duplicateWarningBytes?: number;
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/types/config/features.d.ts
|
|
270
|
+
/**
|
|
271
|
+
* @description 自动导入组件配置
|
|
272
|
+
*/
|
|
273
|
+
interface AutoImportComponents {
|
|
274
|
+
/**
|
|
275
|
+
* @description 组件扫描范围
|
|
276
|
+
*/
|
|
277
|
+
globs?: string[];
|
|
278
|
+
/**
|
|
279
|
+
* @description 组件解析器列表
|
|
280
|
+
*/
|
|
281
|
+
resolvers?: Resolver[];
|
|
282
|
+
/**
|
|
283
|
+
* @description 组件清单输出路径
|
|
284
|
+
*/
|
|
285
|
+
output?: string | boolean;
|
|
286
|
+
/**
|
|
287
|
+
* @description WXML 组件 props 类型声明输出路径
|
|
288
|
+
*/
|
|
289
|
+
typedComponents?: boolean | string;
|
|
290
|
+
/**
|
|
291
|
+
* @description VS Code HTML customData 输出路径
|
|
292
|
+
*/
|
|
293
|
+
htmlCustomData?: boolean | string;
|
|
294
|
+
/**
|
|
295
|
+
* @description Vue SFC 组件声明输出路径
|
|
296
|
+
*/
|
|
297
|
+
vueComponents?: boolean | string;
|
|
298
|
+
/**
|
|
299
|
+
* @description 生成 `components.d.ts` 时使用的运行时模块名
|
|
300
|
+
*/
|
|
301
|
+
vueComponentsModule?: string;
|
|
302
|
+
}
|
|
303
|
+
type AutoImportComponentsOption = AutoImportComponents | boolean;
|
|
304
|
+
type EnhanceWxmlOptions = ScanWxmlOptions & HandleWxmlOptions;
|
|
305
|
+
/**
|
|
306
|
+
* @description WXML 扫描阶段配置
|
|
307
|
+
*/
|
|
308
|
+
interface ScanWxmlOptions {
|
|
309
|
+
excludeComponent?: (tagName: string) => boolean;
|
|
310
|
+
platform?: MpPlatform;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* @description WXML 处理阶段配置
|
|
314
|
+
*/
|
|
315
|
+
interface HandleWxmlOptions {
|
|
316
|
+
removeComment?: boolean;
|
|
317
|
+
transformEvent?: boolean;
|
|
318
|
+
scriptModuleExtension?: string;
|
|
319
|
+
scriptModuleTag?: string;
|
|
320
|
+
templateExtension?: string;
|
|
321
|
+
}
|
|
322
|
+
interface EnhanceOptions {
|
|
323
|
+
wxml?: boolean | Partial<Omit<EnhanceWxmlOptions, 'platform'>>;
|
|
324
|
+
wxs?: boolean;
|
|
325
|
+
autoImportComponents?: AutoImportComponentsOption;
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* @description 多平台 project.config 配置
|
|
329
|
+
*/
|
|
330
|
+
interface MultiPlatformConfig {
|
|
331
|
+
enabled?: boolean;
|
|
332
|
+
projectConfigRoot?: string;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* @description MCP 服务配置
|
|
336
|
+
*/
|
|
337
|
+
interface WeappMcpConfig {
|
|
338
|
+
enabled?: boolean;
|
|
339
|
+
autoStart?: boolean;
|
|
340
|
+
host?: string;
|
|
341
|
+
port?: number;
|
|
342
|
+
endpoint?: string;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* @description 自动路由配置
|
|
346
|
+
*/
|
|
347
|
+
type WeappAutoRoutesIncludePattern = string | RegExp;
|
|
348
|
+
/**
|
|
349
|
+
* @description 自动路由包含规则
|
|
350
|
+
*/
|
|
351
|
+
type WeappAutoRoutesInclude = WeappAutoRoutesIncludePattern | WeappAutoRoutesIncludePattern[];
|
|
352
|
+
/**
|
|
353
|
+
* @description 自动路由配置
|
|
354
|
+
*/
|
|
355
|
+
interface WeappAutoRoutesConfig {
|
|
356
|
+
enabled?: boolean;
|
|
357
|
+
typedRouter?: boolean;
|
|
358
|
+
/**
|
|
359
|
+
* @description 自动路由扫描规则,支持字符串 glob、正则以及它们的数组
|
|
360
|
+
* @remarks 默认会扫描主包 `pages/**`,以及已声明分包 root 下的 `pages/**`
|
|
361
|
+
*/
|
|
362
|
+
include?: WeappAutoRoutesInclude;
|
|
363
|
+
/**
|
|
364
|
+
* @description 是否启用自动路由持久化缓存,或指定自定义缓存文件路径
|
|
365
|
+
* @default false
|
|
366
|
+
*/
|
|
367
|
+
persistentCache?: boolean | string;
|
|
368
|
+
watch?: boolean;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* @description `@wevu/api` 注入配置
|
|
372
|
+
*/
|
|
373
|
+
interface WeappInjectWeapiConfig {
|
|
374
|
+
enabled?: boolean;
|
|
375
|
+
replaceWx?: boolean;
|
|
376
|
+
globalName?: string;
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* @description 本地 npm 构建配置
|
|
380
|
+
*/
|
|
381
|
+
interface WeappNpmConfig {
|
|
382
|
+
enable?: boolean;
|
|
383
|
+
cache?: boolean;
|
|
384
|
+
mainPackage?: NpmMainPackageConfig;
|
|
385
|
+
subPackages?: Record<string, NpmSubPackageConfig>;
|
|
386
|
+
buildOptions?: (options: NpmBuildOptions, pkgMeta: BuildNpmPackageMeta) => NpmBuildOptions | undefined;
|
|
387
|
+
alipayNpmMode?: AlipayNpmMode;
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* @description 分包级额外配置
|
|
391
|
+
*/
|
|
392
|
+
interface WeappSubPackageConfig {
|
|
393
|
+
independent?: boolean;
|
|
394
|
+
inlineConfig?: Partial<InlineConfig>;
|
|
395
|
+
autoImportComponents?: AutoImportComponentsOption;
|
|
396
|
+
watchSharedStyles?: boolean;
|
|
397
|
+
styles?: SubPackageStyleConfigEntry | SubPackageStyleConfigEntry[];
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* @description HMR 配置
|
|
401
|
+
*/
|
|
402
|
+
interface WeappHmrConfig {
|
|
403
|
+
sharedChunks?: 'full' | 'auto' | 'off';
|
|
404
|
+
touchAppWxss?: boolean | 'auto';
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* @description worker 构建配置
|
|
408
|
+
*/
|
|
409
|
+
interface WeappWorkerConfig {
|
|
410
|
+
entry?: string | string[];
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* @description Vue 模板编译配置
|
|
414
|
+
*/
|
|
415
|
+
interface WeappVueTemplateConfig {
|
|
416
|
+
removeComments?: boolean;
|
|
417
|
+
simplifyWhitespace?: boolean;
|
|
418
|
+
scopedSlotsCompiler?: 'auto' | 'augmented' | 'off';
|
|
419
|
+
scopedSlotsRequireProps?: boolean;
|
|
420
|
+
slotMultipleInstance?: boolean;
|
|
421
|
+
classStyleRuntime?: 'auto' | 'wxs' | 'js';
|
|
422
|
+
objectLiteralBindMode?: 'runtime' | 'inline';
|
|
423
|
+
mustacheInterpolation?: 'compact' | 'spaced';
|
|
424
|
+
classStyleWxsShared?: boolean;
|
|
425
|
+
}
|
|
426
|
+
/**
|
|
427
|
+
* @description Vue 支持配置
|
|
428
|
+
*/
|
|
429
|
+
interface WeappVueConfig {
|
|
430
|
+
enable?: boolean;
|
|
431
|
+
template?: WeappVueTemplateConfig;
|
|
432
|
+
autoImport?: boolean;
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* @description wevu 编译期默认值配置
|
|
436
|
+
*/
|
|
437
|
+
interface WeappWevuConfig {
|
|
438
|
+
preset?: 'performance';
|
|
439
|
+
defaults?: WevuDefaults;
|
|
440
|
+
autoSetDataPick?: boolean;
|
|
441
|
+
}
|
|
442
|
+
//#endregion
|
|
443
|
+
//#region src/types/config/main.d.ts
|
|
444
|
+
/**
|
|
445
|
+
* @description 分包元信息
|
|
446
|
+
*/
|
|
447
|
+
interface SubPackageMetaValue {
|
|
448
|
+
entries: string[];
|
|
449
|
+
subPackage: SubPackage;
|
|
450
|
+
autoImportComponents?: AutoImportComponentsOption;
|
|
451
|
+
styleEntries?: SubPackageStyleEntry[];
|
|
452
|
+
watchSharedStyles?: boolean;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* @description 调试输出配置
|
|
456
|
+
*/
|
|
457
|
+
interface WeappDebugConfig {
|
|
458
|
+
watchFiles?: (watchFiles: string[], subPackageMeta?: SubPackageMetaValue) => void;
|
|
459
|
+
resolveId?: (id: string, subPackageMeta?: SubPackageMetaValue) => void;
|
|
460
|
+
load?: (id: string, subPackageMeta?: SubPackageMetaValue) => void;
|
|
461
|
+
inspect?: WrapPluginOptions;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* @description weapp-vite 主配置
|
|
465
|
+
*/
|
|
466
|
+
interface WeappViteConfig {
|
|
467
|
+
/**
|
|
468
|
+
* 应用入口目录(`app.json` 所在目录)。
|
|
469
|
+
*/
|
|
470
|
+
srcRoot?: string;
|
|
471
|
+
/**
|
|
472
|
+
* 自动路由模块配置。
|
|
473
|
+
* - `undefined` / `false`: 默认关闭
|
|
474
|
+
* - `true`: 启用默认自动路由配置
|
|
475
|
+
* - `object`: 启用自动路由并允许细粒度控制
|
|
476
|
+
*/
|
|
477
|
+
autoRoutes?: boolean | WeappAutoRoutesConfig;
|
|
478
|
+
/**
|
|
479
|
+
* 插件入口目录(`plugin.json` 所在目录)。
|
|
480
|
+
*/
|
|
481
|
+
pluginRoot?: string;
|
|
482
|
+
/**
|
|
483
|
+
* 日志输出配置。
|
|
484
|
+
*/
|
|
485
|
+
logger?: LoggerConfig;
|
|
486
|
+
/**
|
|
487
|
+
* AST 引擎配置。
|
|
488
|
+
*/
|
|
489
|
+
ast?: WeappAstConfig;
|
|
490
|
+
/**
|
|
491
|
+
* 主包/分包体积告警阈值(字节)。
|
|
492
|
+
*/
|
|
493
|
+
packageSizeWarningBytes?: number;
|
|
494
|
+
jsonAlias?: AliasOptions;
|
|
495
|
+
npm?: WeappNpmConfig;
|
|
496
|
+
generate?: GenerateOptions;
|
|
497
|
+
tsconfigPaths?: PluginOptions | false;
|
|
498
|
+
subPackages?: Record<string, WeappSubPackageConfig>;
|
|
499
|
+
copy?: CopyOptions;
|
|
500
|
+
web?: WeappWebConfig;
|
|
501
|
+
lib?: WeappLibConfig;
|
|
502
|
+
isAdditionalWxml?: (wxmlFilePath: string) => boolean;
|
|
503
|
+
platform?: MpPlatform;
|
|
504
|
+
multiPlatform?: boolean | MultiPlatformConfig;
|
|
505
|
+
jsFormat?: JsFormat;
|
|
506
|
+
/**
|
|
507
|
+
* @deprecated 已废弃,不建议继续使用。请改为保持 `build.target >= es2020`,并在开发者工具中开启“将 JS 编译成 ES5”功能。
|
|
508
|
+
* 该选项依赖 `@swc/core` 做额外 ES5 降级,后续版本将移除。
|
|
509
|
+
*/
|
|
510
|
+
es5?: boolean;
|
|
511
|
+
wxml?: EnhanceOptions['wxml'];
|
|
512
|
+
wxs?: EnhanceOptions['wxs'];
|
|
513
|
+
autoImportComponents?: AutoImportComponentsOption;
|
|
514
|
+
enhance?: EnhanceOptions;
|
|
515
|
+
debug?: WeappDebugConfig;
|
|
516
|
+
hmr?: WeappHmrConfig;
|
|
517
|
+
worker?: WeappWorkerConfig;
|
|
518
|
+
vue?: WeappVueConfig;
|
|
519
|
+
wevu?: WeappWevuConfig;
|
|
520
|
+
injectWeapi?: boolean | WeappInjectWeapiConfig;
|
|
521
|
+
mcp?: boolean | WeappMcpConfig;
|
|
522
|
+
chunks?: ChunksConfig;
|
|
523
|
+
json?: JsonConfig;
|
|
524
|
+
}
|
|
525
|
+
type UserConfig$2 = UserConfig & {
|
|
526
|
+
weapp?: WeappViteConfig;
|
|
527
|
+
};
|
|
528
|
+
/**
|
|
529
|
+
* @description 小程序 project.config 结构
|
|
530
|
+
*/
|
|
531
|
+
interface ProjectConfig {
|
|
532
|
+
miniprogramRoot?: string;
|
|
533
|
+
srcMiniprogramRoot?: string;
|
|
534
|
+
smartProgramRoot?: string;
|
|
535
|
+
setting?: {
|
|
536
|
+
packNpmManually?: boolean;
|
|
537
|
+
packNpmRelationList?: {
|
|
538
|
+
packageJsonPath: string;
|
|
539
|
+
miniprogramNpmDistDir: string;
|
|
540
|
+
}[];
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/types/context.d.ts
|
|
545
|
+
interface WxmlDep {
|
|
546
|
+
tagName: string;
|
|
547
|
+
start: number;
|
|
548
|
+
end: number;
|
|
549
|
+
quote: string | null | undefined;
|
|
550
|
+
name: string;
|
|
551
|
+
value: string;
|
|
552
|
+
attrs: Record<string, string>;
|
|
553
|
+
}
|
|
554
|
+
interface ScanComponentItem {
|
|
555
|
+
start: number;
|
|
556
|
+
end: number;
|
|
557
|
+
}
|
|
558
|
+
type ComponentsMap = Record<string, ScanComponentItem[]>;
|
|
559
|
+
//#endregion
|
|
560
|
+
//#region src/types/entry.d.ts
|
|
561
|
+
interface BaseEntry {
|
|
562
|
+
path: string;
|
|
563
|
+
jsonPath?: string;
|
|
564
|
+
json?: object;
|
|
565
|
+
type: 'app' | 'page' | 'component' | (string & {});
|
|
566
|
+
}
|
|
567
|
+
type Entry = AppEntry | PageEntry | ComponentEntry;
|
|
568
|
+
/**
|
|
569
|
+
* 应用入口 js + json
|
|
570
|
+
*/
|
|
571
|
+
interface AppEntry extends BaseEntry {
|
|
572
|
+
type: 'app';
|
|
573
|
+
themeJsonPath?: string;
|
|
574
|
+
themeJson?: Theme;
|
|
575
|
+
sitemapJsonPath?: string;
|
|
576
|
+
sitemapJson?: Sitemap;
|
|
577
|
+
json: App;
|
|
578
|
+
jsonPath: string;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* 页面入口 js + wxml
|
|
582
|
+
*/
|
|
583
|
+
interface PageEntry extends BaseEntry {
|
|
584
|
+
type: 'page';
|
|
585
|
+
templatePath: string;
|
|
586
|
+
json?: Page;
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* 组件入口 js + wxml + json + json.component === true
|
|
590
|
+
*/
|
|
591
|
+
interface ComponentEntry extends BaseEntry {
|
|
592
|
+
type: 'component';
|
|
593
|
+
templatePath: string;
|
|
594
|
+
json: Component;
|
|
595
|
+
jsonPath: string;
|
|
596
|
+
}
|
|
597
|
+
type EntryJsonFragment = Omit<BaseEntry, 'path' | 'type'>;
|
|
598
|
+
//#endregion
|
|
599
|
+
//#region src/types/errors.d.ts
|
|
600
|
+
interface BindingErrorLike {
|
|
601
|
+
message?: string;
|
|
602
|
+
code?: string;
|
|
603
|
+
plugin?: string;
|
|
604
|
+
id?: string;
|
|
605
|
+
frame?: string;
|
|
606
|
+
stack?: string;
|
|
607
|
+
}
|
|
608
|
+
//#endregion
|
|
609
|
+
//#region ../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.d.ts
|
|
610
|
+
/**
|
|
611
|
+
* Minimal `EventEmitter` interface that is molded against the Node.js
|
|
612
|
+
* `EventEmitter` interface.
|
|
613
|
+
*/
|
|
614
|
+
declare class EventEmitter<EventTypes extends EventEmitter.ValidEventTypes = string | symbol, Context extends any = any> {
|
|
615
|
+
static prefixed: string | boolean;
|
|
616
|
+
/**
|
|
617
|
+
* Return an array listing the events for which the emitter has registered
|
|
618
|
+
* listeners.
|
|
619
|
+
*/
|
|
620
|
+
eventNames(): Array<EventEmitter.EventNames<EventTypes>>;
|
|
621
|
+
/**
|
|
622
|
+
* Return the listeners registered for a given event.
|
|
623
|
+
*/
|
|
624
|
+
listeners<T extends EventEmitter.EventNames<EventTypes>>(event: T): Array<EventEmitter.EventListener<EventTypes, T>>;
|
|
625
|
+
/**
|
|
626
|
+
* Return the number of listeners listening to a given event.
|
|
627
|
+
*/
|
|
628
|
+
listenerCount(event: EventEmitter.EventNames<EventTypes>): number;
|
|
629
|
+
/**
|
|
630
|
+
* Calls each of the listeners registered for a given event.
|
|
631
|
+
*/
|
|
632
|
+
emit<T extends EventEmitter.EventNames<EventTypes>>(event: T, ...args: EventEmitter.EventArgs<EventTypes, T>): boolean;
|
|
633
|
+
/**
|
|
634
|
+
* Add a listener for a given event.
|
|
635
|
+
*/
|
|
636
|
+
on<T extends EventEmitter.EventNames<EventTypes>>(event: T, fn: EventEmitter.EventListener<EventTypes, T>, context?: Context): this;
|
|
637
|
+
addListener<T extends EventEmitter.EventNames<EventTypes>>(event: T, fn: EventEmitter.EventListener<EventTypes, T>, context?: Context): this;
|
|
638
|
+
/**
|
|
639
|
+
* Add a one-time listener for a given event.
|
|
640
|
+
*/
|
|
641
|
+
once<T extends EventEmitter.EventNames<EventTypes>>(event: T, fn: EventEmitter.EventListener<EventTypes, T>, context?: Context): this;
|
|
642
|
+
/**
|
|
643
|
+
* Remove the listeners of a given event.
|
|
644
|
+
*/
|
|
645
|
+
removeListener<T extends EventEmitter.EventNames<EventTypes>>(event: T, fn?: EventEmitter.EventListener<EventTypes, T>, context?: Context, once?: boolean): this;
|
|
646
|
+
off<T extends EventEmitter.EventNames<EventTypes>>(event: T, fn?: EventEmitter.EventListener<EventTypes, T>, context?: Context, once?: boolean): this;
|
|
647
|
+
/**
|
|
648
|
+
* Remove all listeners, or those of the specified event.
|
|
649
|
+
*/
|
|
650
|
+
removeAllListeners(event?: EventEmitter.EventNames<EventTypes>): this;
|
|
651
|
+
}
|
|
652
|
+
declare namespace EventEmitter {
|
|
653
|
+
export interface ListenerFn<Args extends any[] = any[]> {
|
|
654
|
+
(...args: Args): void;
|
|
655
|
+
}
|
|
656
|
+
export interface EventEmitterStatic {
|
|
657
|
+
new <EventTypes extends ValidEventTypes = string | symbol, Context = any>(): EventEmitter<EventTypes, Context>;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* `object` should be in either of the following forms:
|
|
661
|
+
* ```
|
|
662
|
+
* interface EventTypes {
|
|
663
|
+
* 'event-with-parameters': any[]
|
|
664
|
+
* 'event-with-example-handler': (...args: any[]) => void
|
|
665
|
+
* }
|
|
666
|
+
* ```
|
|
667
|
+
*/
|
|
668
|
+
export type ValidEventTypes = string | symbol | object;
|
|
669
|
+
export type EventNames<T extends ValidEventTypes> = T extends string | symbol ? T : keyof T;
|
|
670
|
+
export type ArgumentMap<T extends object> = { [K in keyof T]: T[K] extends ((...args: any[]) => void) ? Parameters<T[K]> : T[K] extends any[] ? T[K] : any[] };
|
|
671
|
+
export type EventListener<T extends ValidEventTypes, K extends EventNames<T>> = T extends string | symbol ? (...args: any[]) => void : (...args: ArgumentMap<Exclude<T, string | symbol>>[Extract<K, keyof T>]) => void;
|
|
672
|
+
export type EventArgs<T extends ValidEventTypes, K extends EventNames<T>> = Parameters<EventListener<T, K>>;
|
|
673
|
+
export const EventEmitter: EventEmitterStatic;
|
|
674
|
+
}
|
|
675
|
+
//#endregion
|
|
676
|
+
//#region ../../node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/queue.d.ts
|
|
677
|
+
type RunFunction = () => Promise<unknown>;
|
|
678
|
+
type Queue<Element, Options> = {
|
|
679
|
+
size: number;
|
|
680
|
+
filter: (options: Readonly<Partial<Options>>) => Element[];
|
|
681
|
+
dequeue: () => Element | undefined;
|
|
682
|
+
enqueue: (run: Element, options?: Partial<Options>) => void;
|
|
683
|
+
setPriority: (id: string, priority: number) => void;
|
|
684
|
+
};
|
|
685
|
+
//#endregion
|
|
686
|
+
//#region ../../node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/options.d.ts
|
|
687
|
+
type TimeoutOptions = {
|
|
688
|
+
/**
|
|
689
|
+
Per-operation timeout in milliseconds. Operations will throw a `TimeoutError` if they don't complete within the specified time.
|
|
690
|
+
The timeout begins when the operation is dequeued and starts execution, not while it's waiting in the queue.
|
|
691
|
+
@default undefined
|
|
692
|
+
Can be overridden per task using the `timeout` option in `.add()`:
|
|
693
|
+
@example
|
|
694
|
+
```
|
|
695
|
+
const queue = new PQueue({timeout: 5000});
|
|
696
|
+
// This task uses the global 5s timeout
|
|
697
|
+
await queue.add(() => fetchData());
|
|
698
|
+
// This task has a 10s timeout
|
|
699
|
+
await queue.add(() => slowTask(), {timeout: 10000});
|
|
700
|
+
```
|
|
701
|
+
*/
|
|
702
|
+
timeout?: number;
|
|
703
|
+
};
|
|
704
|
+
type Options$1<QueueType extends Queue<RunFunction, QueueOptions>, QueueOptions extends QueueAddOptions> = {
|
|
705
|
+
/**
|
|
706
|
+
Concurrency limit.
|
|
707
|
+
Minimum: `1`.
|
|
708
|
+
@default Infinity
|
|
709
|
+
*/
|
|
710
|
+
readonly concurrency?: number;
|
|
711
|
+
/**
|
|
712
|
+
Whether queue tasks within concurrency limit, are auto-executed as soon as they're added.
|
|
713
|
+
@default true
|
|
714
|
+
*/
|
|
715
|
+
readonly autoStart?: boolean;
|
|
716
|
+
/**
|
|
717
|
+
Class with a `enqueue` and `dequeue` method, and a `size` getter. See the [Custom QueueClass](https://github.com/sindresorhus/p-queue#custom-queueclass) section.
|
|
718
|
+
*/
|
|
719
|
+
readonly queueClass?: new () => QueueType;
|
|
720
|
+
/**
|
|
721
|
+
The max number of runs in the given interval of time.
|
|
722
|
+
Minimum: `1`.
|
|
723
|
+
@default Infinity
|
|
724
|
+
*/
|
|
725
|
+
readonly intervalCap?: number;
|
|
726
|
+
/**
|
|
727
|
+
The length of time in milliseconds before the interval count resets. Must be finite.
|
|
728
|
+
Minimum: `0`.
|
|
729
|
+
@default 0
|
|
730
|
+
*/
|
|
731
|
+
readonly interval?: number;
|
|
732
|
+
/**
|
|
733
|
+
Whether the task must finish in the given interval or will be carried over into the next interval count.
|
|
734
|
+
@default false
|
|
735
|
+
*/
|
|
736
|
+
readonly carryoverIntervalCount?: boolean;
|
|
737
|
+
/**
|
|
738
|
+
@deprecated Renamed to `carryoverIntervalCount`.
|
|
739
|
+
*/
|
|
740
|
+
readonly carryoverConcurrencyCount?: boolean;
|
|
741
|
+
/**
|
|
742
|
+
Whether to use strict mode for rate limiting (sliding window algorithm).
|
|
743
|
+
When enabled, ensures that no more than `intervalCap` tasks execute in any rolling `interval` window, rather than resetting the count at fixed intervals. This provides more predictable and evenly distributed execution.
|
|
744
|
+
@default false
|
|
745
|
+
For example, with `intervalCap: 2` and `interval: 1000`:
|
|
746
|
+
- __Default mode (fixed window)__: Tasks can burst at window boundaries. You could execute 2 tasks at 999ms and 2 more at 1000ms, resulting in 4 tasks within 1ms.
|
|
747
|
+
- __Strict mode (sliding window)__: Enforces that no more than 2 tasks execute in any 1000ms rolling window, preventing bursts.
|
|
748
|
+
Strict mode is more resource-intensive as it tracks individual execution timestamps. Use it when you need guaranteed rate-limit compliance, such as when interacting with APIs that enforce strict rate limits.
|
|
749
|
+
The `carryoverIntervalCount` option has no effect when `strict` mode is enabled, as strict mode tracks actual execution timestamps rather than counting pending tasks.
|
|
750
|
+
*/
|
|
751
|
+
readonly strict?: boolean;
|
|
752
|
+
} & TimeoutOptions;
|
|
753
|
+
type QueueAddOptions = {
|
|
754
|
+
/**
|
|
755
|
+
Priority of operation. Operations with greater priority will be scheduled first.
|
|
756
|
+
@default 0
|
|
757
|
+
*/
|
|
758
|
+
readonly priority?: number;
|
|
759
|
+
/**
|
|
760
|
+
Unique identifier for the promise function, used to update its priority before execution. If not specified, it is auto-assigned an incrementing BigInt starting from `1n`.
|
|
761
|
+
*/
|
|
762
|
+
id?: string;
|
|
763
|
+
} & TaskOptions & TimeoutOptions;
|
|
764
|
+
type TaskOptions = {
|
|
765
|
+
/**
|
|
766
|
+
[`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) for cancellation of the operation. When aborted, it will be removed from the queue and the `queue.add()` call will reject with an `AbortError`. If the operation is already running, the signal will need to be handled by the operation itself.
|
|
767
|
+
@example
|
|
768
|
+
```
|
|
769
|
+
import PQueue, {AbortError} from 'p-queue';
|
|
770
|
+
import got, {CancelError} from 'got';
|
|
771
|
+
const queue = new PQueue();
|
|
772
|
+
const controller = new AbortController();
|
|
773
|
+
try {
|
|
774
|
+
await queue.add(({signal}) => {
|
|
775
|
+
const request = got('https://sindresorhus.com');
|
|
776
|
+
signal.addEventListener('abort', () => {
|
|
777
|
+
request.cancel();
|
|
778
|
+
});
|
|
779
|
+
try {
|
|
780
|
+
return await request;
|
|
781
|
+
} catch (error) {
|
|
782
|
+
if (!(error instanceof CancelError)) {
|
|
783
|
+
throw error;
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
}, {signal: controller.signal});
|
|
787
|
+
} catch (error) {
|
|
788
|
+
if (!(error instanceof AbortError)) {
|
|
789
|
+
throw error;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
```
|
|
793
|
+
*/
|
|
794
|
+
readonly signal?: AbortSignal | undefined;
|
|
795
|
+
};
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region ../../node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/priority-queue.d.ts
|
|
798
|
+
type PriorityQueueOptions = {
|
|
799
|
+
priority?: number;
|
|
800
|
+
} & QueueAddOptions;
|
|
801
|
+
declare class PriorityQueue implements Queue<RunFunction, PriorityQueueOptions> {
|
|
802
|
+
#private;
|
|
803
|
+
enqueue(run: RunFunction, options?: Partial<PriorityQueueOptions>): void;
|
|
804
|
+
setPriority(id: string, priority: number): void;
|
|
805
|
+
dequeue(): RunFunction | undefined;
|
|
806
|
+
filter(options: Readonly<Partial<PriorityQueueOptions>>): RunFunction[];
|
|
807
|
+
get size(): number;
|
|
808
|
+
}
|
|
809
|
+
//#endregion
|
|
810
|
+
//#region ../../node_modules/.pnpm/p-queue@9.1.0/node_modules/p-queue/dist/index.d.ts
|
|
811
|
+
type Task<TaskResultType> = ((options: TaskOptions) => PromiseLike<TaskResultType>) | ((options: TaskOptions) => TaskResultType);
|
|
812
|
+
type EventName = 'active' | 'idle' | 'empty' | 'add' | 'next' | 'completed' | 'error' | 'pendingZero' | 'rateLimit' | 'rateLimitCleared';
|
|
813
|
+
/**
|
|
814
|
+
Promise queue with concurrency control.
|
|
815
|
+
*/
|
|
816
|
+
declare class PQueue<QueueType extends Queue<RunFunction, EnqueueOptionsType> = PriorityQueue, EnqueueOptionsType extends QueueAddOptions = QueueAddOptions> extends EventEmitter<EventName> {
|
|
817
|
+
#private;
|
|
818
|
+
/**
|
|
819
|
+
Get or set the default timeout for all tasks. Can be changed at runtime.
|
|
820
|
+
Operations will throw a `TimeoutError` if they don't complete within the specified time.
|
|
821
|
+
The timeout begins when the operation is dequeued and starts execution, not while it's waiting in the queue.
|
|
822
|
+
@example
|
|
823
|
+
```
|
|
824
|
+
const queue = new PQueue({timeout: 5000});
|
|
825
|
+
// Change timeout for all future tasks
|
|
826
|
+
queue.timeout = 10000;
|
|
827
|
+
```
|
|
828
|
+
*/
|
|
829
|
+
timeout?: number;
|
|
830
|
+
constructor(options?: Options$1<QueueType, EnqueueOptionsType>);
|
|
831
|
+
get concurrency(): number;
|
|
832
|
+
set concurrency(newConcurrency: number);
|
|
833
|
+
/**
|
|
834
|
+
Updates the priority of a promise function by its id, affecting its execution order. Requires a defined concurrency limit to take effect.
|
|
835
|
+
For example, this can be used to prioritize a promise function to run earlier.
|
|
836
|
+
```js
|
|
837
|
+
import PQueue from 'p-queue';
|
|
838
|
+
const queue = new PQueue({concurrency: 1});
|
|
839
|
+
queue.add(async () => '🦄', {priority: 1});
|
|
840
|
+
queue.add(async () => '🦀', {priority: 0, id: '🦀'});
|
|
841
|
+
queue.add(async () => '🦄', {priority: 1});
|
|
842
|
+
queue.add(async () => '🦄', {priority: 1});
|
|
843
|
+
queue.setPriority('🦀', 2);
|
|
844
|
+
```
|
|
845
|
+
In this case, the promise function with `id: '🦀'` runs second.
|
|
846
|
+
You can also deprioritize a promise function to delay its execution:
|
|
847
|
+
```js
|
|
848
|
+
import PQueue from 'p-queue';
|
|
849
|
+
const queue = new PQueue({concurrency: 1});
|
|
850
|
+
queue.add(async () => '🦄', {priority: 1});
|
|
851
|
+
queue.add(async () => '🦀', {priority: 1, id: '🦀'});
|
|
852
|
+
queue.add(async () => '🦄');
|
|
853
|
+
queue.add(async () => '🦄', {priority: 0});
|
|
854
|
+
queue.setPriority('🦀', -1);
|
|
855
|
+
```
|
|
856
|
+
Here, the promise function with `id: '🦀'` executes last.
|
|
857
|
+
*/
|
|
858
|
+
setPriority(id: string, priority: number): void;
|
|
859
|
+
/**
|
|
860
|
+
Adds a sync or async task to the queue. Always returns a promise.
|
|
861
|
+
*/
|
|
862
|
+
add<TaskResultType>(function_: Task<TaskResultType>, options?: Partial<EnqueueOptionsType>): Promise<TaskResultType>;
|
|
863
|
+
/**
|
|
864
|
+
Same as `.add()`, but accepts an array of sync or async functions.
|
|
865
|
+
@returns A promise that resolves when all functions are resolved.
|
|
866
|
+
*/
|
|
867
|
+
addAll<TaskResultsType>(functions: ReadonlyArray<Task<TaskResultsType>>, options?: Partial<EnqueueOptionsType>): Promise<TaskResultsType[]>;
|
|
868
|
+
/**
|
|
869
|
+
Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
|
|
870
|
+
*/
|
|
871
|
+
start(): this;
|
|
872
|
+
/**
|
|
873
|
+
Put queue execution on hold.
|
|
874
|
+
*/
|
|
875
|
+
pause(): void;
|
|
876
|
+
/**
|
|
877
|
+
Clear the queue.
|
|
878
|
+
*/
|
|
879
|
+
clear(): void;
|
|
880
|
+
/**
|
|
881
|
+
Can be called multiple times. Useful if you for example add additional items at a later time.
|
|
882
|
+
@returns A promise that settles when the queue becomes empty.
|
|
883
|
+
*/
|
|
884
|
+
onEmpty(): Promise<void>;
|
|
885
|
+
/**
|
|
886
|
+
@returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
|
|
887
|
+
If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
|
|
888
|
+
Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
|
|
889
|
+
*/
|
|
890
|
+
onSizeLessThan(limit: number): Promise<void>;
|
|
891
|
+
/**
|
|
892
|
+
The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
|
|
893
|
+
@returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
|
|
894
|
+
*/
|
|
895
|
+
onIdle(): Promise<void>;
|
|
896
|
+
/**
|
|
897
|
+
The difference with `.onIdle` is that `.onPendingZero` only waits for currently running tasks to finish, ignoring queued tasks.
|
|
898
|
+
@returns A promise that settles when all currently running tasks have completed; `queue.pending === 0`.
|
|
899
|
+
*/
|
|
900
|
+
onPendingZero(): Promise<void>;
|
|
901
|
+
/**
|
|
902
|
+
@returns A promise that settles when the queue becomes rate-limited due to intervalCap.
|
|
903
|
+
*/
|
|
904
|
+
onRateLimit(): Promise<void>;
|
|
905
|
+
/**
|
|
906
|
+
@returns A promise that settles when the queue is no longer rate-limited.
|
|
907
|
+
*/
|
|
908
|
+
onRateLimitCleared(): Promise<void>;
|
|
909
|
+
/**
|
|
910
|
+
@returns A promise that rejects when any task in the queue errors.
|
|
911
|
+
Use with `Promise.race([queue.onError(), queue.onIdle()])` to fail fast on the first error while still resolving normally when the queue goes idle.
|
|
912
|
+
Important: The promise returned by `add()` still rejects. You must handle each `add()` promise (for example, `.catch(() => {})`) to avoid unhandled rejections.
|
|
913
|
+
@example
|
|
914
|
+
```
|
|
915
|
+
import PQueue from 'p-queue';
|
|
916
|
+
const queue = new PQueue({concurrency: 2});
|
|
917
|
+
queue.add(() => fetchData(1)).catch(() => {});
|
|
918
|
+
queue.add(() => fetchData(2)).catch(() => {});
|
|
919
|
+
queue.add(() => fetchData(3)).catch(() => {});
|
|
920
|
+
// Stop processing on first error
|
|
921
|
+
try {
|
|
922
|
+
await Promise.race([
|
|
923
|
+
queue.onError(),
|
|
924
|
+
queue.onIdle()
|
|
925
|
+
]);
|
|
926
|
+
} catch (error) {
|
|
927
|
+
queue.pause(); // Stop processing remaining tasks
|
|
928
|
+
console.error('Queue failed:', error);
|
|
929
|
+
}
|
|
930
|
+
```
|
|
931
|
+
*/
|
|
932
|
+
onError(): Promise<never>;
|
|
933
|
+
/**
|
|
934
|
+
Size of the queue, the number of queued items waiting to run.
|
|
935
|
+
*/
|
|
936
|
+
get size(): number;
|
|
937
|
+
/**
|
|
938
|
+
Size of the queue, filtered by the given options.
|
|
939
|
+
For example, this can be used to find the number of items remaining in the queue with a specific priority level.
|
|
940
|
+
*/
|
|
941
|
+
sizeBy(options: Readonly<Partial<EnqueueOptionsType>>): number;
|
|
942
|
+
/**
|
|
943
|
+
Number of running items (no longer in the queue).
|
|
944
|
+
*/
|
|
945
|
+
get pending(): number;
|
|
946
|
+
/**
|
|
947
|
+
Whether the queue is currently paused.
|
|
948
|
+
*/
|
|
949
|
+
get isPaused(): boolean;
|
|
950
|
+
/**
|
|
951
|
+
Whether the queue is currently rate-limited due to intervalCap.
|
|
952
|
+
*/
|
|
953
|
+
get isRateLimited(): boolean;
|
|
954
|
+
/**
|
|
955
|
+
Whether the queue is saturated. Returns `true` when:
|
|
956
|
+
- All concurrency slots are occupied and tasks are waiting, OR
|
|
957
|
+
- The queue is rate-limited and tasks are waiting
|
|
958
|
+
Useful for detecting backpressure and potential hanging tasks.
|
|
959
|
+
```js
|
|
960
|
+
import PQueue from 'p-queue';
|
|
961
|
+
const queue = new PQueue({concurrency: 2});
|
|
962
|
+
// Backpressure handling
|
|
963
|
+
if (queue.isSaturated) {
|
|
964
|
+
console.log('Queue is saturated, waiting for capacity...');
|
|
965
|
+
await queue.onSizeLessThan(queue.concurrency);
|
|
966
|
+
}
|
|
967
|
+
// Monitoring for stuck tasks
|
|
968
|
+
setInterval(() => {
|
|
969
|
+
if (queue.isSaturated) {
|
|
970
|
+
console.warn(`Queue saturated: ${queue.pending} running, ${queue.size} waiting`);
|
|
971
|
+
}
|
|
972
|
+
}, 60000);
|
|
973
|
+
```
|
|
974
|
+
*/
|
|
975
|
+
get isSaturated(): boolean;
|
|
976
|
+
/**
|
|
977
|
+
The tasks currently being executed. Each task includes its `id`, `priority`, `startTime`, and `timeout` (if set).
|
|
978
|
+
Returns an array of task info objects.
|
|
979
|
+
```js
|
|
980
|
+
import PQueue from 'p-queue';
|
|
981
|
+
const queue = new PQueue({concurrency: 2});
|
|
982
|
+
// Add tasks with IDs for better debugging
|
|
983
|
+
queue.add(() => fetchUser(123), {id: 'user-123'});
|
|
984
|
+
queue.add(() => fetchPosts(456), {id: 'posts-456', priority: 1});
|
|
985
|
+
// Check what's running
|
|
986
|
+
console.log(queue.runningTasks);
|
|
987
|
+
// => [{
|
|
988
|
+
// id: 'user-123',
|
|
989
|
+
// priority: 0,
|
|
990
|
+
// startTime: 1759253001716,
|
|
991
|
+
// timeout: undefined
|
|
992
|
+
// }, {
|
|
993
|
+
// id: 'posts-456',
|
|
994
|
+
// priority: 1,
|
|
995
|
+
// startTime: 1759253001916,
|
|
996
|
+
// timeout: undefined
|
|
997
|
+
// }]
|
|
998
|
+
```
|
|
999
|
+
*/
|
|
1000
|
+
get runningTasks(): ReadonlyArray<{
|
|
1001
|
+
readonly id?: string;
|
|
1002
|
+
readonly priority: number;
|
|
1003
|
+
readonly startTime: number;
|
|
1004
|
+
readonly timeout?: number;
|
|
1005
|
+
}>;
|
|
1006
|
+
}
|
|
1007
|
+
//#endregion
|
|
1008
|
+
//#region src/runtime/buildPlugin/service.d.ts
|
|
1009
|
+
interface BuildOptions {
|
|
1010
|
+
skipNpm?: boolean;
|
|
1011
|
+
}
|
|
1012
|
+
interface BuildService {
|
|
1013
|
+
queue: PQueue;
|
|
1014
|
+
build: (options?: BuildOptions) => Promise<RolldownOutput | RolldownOutput[] | RolldownWatcher>;
|
|
1015
|
+
buildIndependentBundle: (root: string, meta: SubPackageMetaValue) => Promise<RolldownOutput>;
|
|
1016
|
+
getIndependentOutput: (root: string) => RolldownOutput | undefined;
|
|
1017
|
+
invalidateIndependentOutput: (root: string) => void;
|
|
1018
|
+
}
|
|
1019
|
+
//#endregion
|
|
1020
|
+
//#region ../../node_modules/.pnpm/package-manager-detector@1.6.0/node_modules/package-manager-detector/dist/shared/package-manager-detector.DksAilYA.d.mts
|
|
1021
|
+
type Agent = 'npm' | 'yarn' | 'yarn@berry' | 'pnpm' | 'pnpm@6' | 'bun' | 'deno';
|
|
1022
|
+
type AgentName = 'npm' | 'yarn' | 'pnpm' | 'bun' | 'deno';
|
|
1023
|
+
interface DetectResult {
|
|
1024
|
+
/**
|
|
1025
|
+
* Agent name without the specifier.
|
|
1026
|
+
*
|
|
1027
|
+
* Can be `npm`, `yarn`, `pnpm`, `bun`, or `deno`.
|
|
1028
|
+
*/
|
|
1029
|
+
name: AgentName;
|
|
1030
|
+
/**
|
|
1031
|
+
* Agent specifier to resolve the command.
|
|
1032
|
+
*
|
|
1033
|
+
* May contain '@' to differentiate the version (e.g. 'yarn@berry').
|
|
1034
|
+
* Use `name` for the agent name without the specifier.
|
|
1035
|
+
*/
|
|
1036
|
+
agent: Agent;
|
|
1037
|
+
/**
|
|
1038
|
+
* Specific version of the agent, read from `packageManager` field in package.json.
|
|
1039
|
+
*/
|
|
1040
|
+
version?: string;
|
|
1041
|
+
}
|
|
1042
|
+
//#endregion
|
|
1043
|
+
//#region ../../node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.d.mts
|
|
1044
|
+
interface PackageJson {
|
|
1045
|
+
/**
|
|
1046
|
+
* The name is what your thing is called.
|
|
1047
|
+
* Some rules:
|
|
1048
|
+
* - The name must be less than or equal to 214 characters. This includes the scope for scoped packages.
|
|
1049
|
+
* - The name can’t start with a dot or an underscore.
|
|
1050
|
+
* - New packages must not have uppercase letters in the name.
|
|
1051
|
+
* - The name ends up being part of a URL, an argument on the command line, and a folder name. Therefore, the name can’t contain any non-URL-safe characters.
|
|
1052
|
+
*/
|
|
1053
|
+
name?: string;
|
|
1054
|
+
/**
|
|
1055
|
+
* Version must be parseable by `node-semver`, which is bundled with npm as a dependency. (`npm install semver` to use it yourself.)
|
|
1056
|
+
*/
|
|
1057
|
+
version?: string;
|
|
1058
|
+
/**
|
|
1059
|
+
* Put a description in it. It’s a string. This helps people discover your package, as it’s listed in `npm search`.
|
|
1060
|
+
*/
|
|
1061
|
+
description?: string;
|
|
1062
|
+
/**
|
|
1063
|
+
* Put keywords in it. It’s an array of strings. This helps people discover your package as it’s listed in `npm search`.
|
|
1064
|
+
*/
|
|
1065
|
+
keywords?: string[];
|
|
1066
|
+
/**
|
|
1067
|
+
* The url to the project homepage.
|
|
1068
|
+
*/
|
|
1069
|
+
homepage?: string;
|
|
1070
|
+
/**
|
|
1071
|
+
* The url to your project’s issue tracker and / or the email address to which issues should be reported. These are helpful for people who encounter issues with your package.
|
|
1072
|
+
*/
|
|
1073
|
+
bugs?: string | {
|
|
1074
|
+
url?: string;
|
|
1075
|
+
email?: string;
|
|
1076
|
+
};
|
|
1077
|
+
/**
|
|
1078
|
+
* You should specify a license for your package so that people know how they are permitted to use it, and any restrictions you’re placing on it.
|
|
1079
|
+
*/
|
|
1080
|
+
license?: string;
|
|
1081
|
+
/**
|
|
1082
|
+
* Specify the place where your code lives. This is helpful for people who want to contribute. If the git repo is on GitHub, then the `npm docs` command will be able to find you.
|
|
1083
|
+
* For GitHub, GitHub gist, Bitbucket, or GitLab repositories you can use the same shortcut syntax you use for npm install:
|
|
1084
|
+
*/
|
|
1085
|
+
repository?: string | {
|
|
1086
|
+
type: string;
|
|
1087
|
+
url: string;
|
|
1088
|
+
/**
|
|
1089
|
+
* If the `package.json` for your package is not in the root directory (for example if it is part of a monorepo), you can specify the directory in which it lives:
|
|
1090
|
+
*/
|
|
1091
|
+
directory?: string;
|
|
1092
|
+
};
|
|
1093
|
+
/**
|
|
1094
|
+
* The `scripts` field is a dictionary containing script commands that are run at various times in the lifecycle of your package.
|
|
1095
|
+
*/
|
|
1096
|
+
scripts?: PackageJsonScripts;
|
|
1097
|
+
/**
|
|
1098
|
+
* If you set `"private": true` in your package.json, then npm will refuse to publish it.
|
|
1099
|
+
*/
|
|
1100
|
+
private?: boolean;
|
|
1101
|
+
/**
|
|
1102
|
+
* The “author” is one person.
|
|
1103
|
+
*/
|
|
1104
|
+
author?: PackageJsonPerson;
|
|
1105
|
+
/**
|
|
1106
|
+
* “contributors” is an array of people.
|
|
1107
|
+
*/
|
|
1108
|
+
contributors?: PackageJsonPerson[];
|
|
1109
|
+
/**
|
|
1110
|
+
* An object containing a URL that provides up-to-date information
|
|
1111
|
+
* about ways to help fund development of your package,
|
|
1112
|
+
* a string URL, or an array of objects and string URLs
|
|
1113
|
+
*/
|
|
1114
|
+
funding?: PackageJsonFunding | PackageJsonFunding[];
|
|
1115
|
+
/**
|
|
1116
|
+
* The optional `files` field is an array of file patterns that describes the entries to be included when your package is installed as a dependency. File patterns follow a similar syntax to `.gitignore`, but reversed: including a file, directory, or glob pattern (`*`, `**\/*`, and such) will make it so that file is included in the tarball when it’s packed. Omitting the field will make it default to `["*"]`, which means it will include all files.
|
|
1117
|
+
*/
|
|
1118
|
+
files?: string[];
|
|
1119
|
+
/**
|
|
1120
|
+
* The main field is a module ID that is the primary entry point to your program. That is, if your package is named `foo`, and a user installs it, and then does `require("foo")`, then your main module’s exports object will be returned.
|
|
1121
|
+
* This should be a module ID relative to the root of your package folder.
|
|
1122
|
+
* For most modules, it makes the most sense to have a main script and often not much else.
|
|
1123
|
+
*/
|
|
1124
|
+
main?: string;
|
|
1125
|
+
/**
|
|
1126
|
+
* If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren’t available in Node.js modules. (e.g. window)
|
|
1127
|
+
*/
|
|
1128
|
+
browser?: string | Record<string, string | false>;
|
|
1129
|
+
/**
|
|
1130
|
+
* The `unpkg` field is used to specify the URL to a UMD module for your package. This is used by default in the unpkg.com CDN service.
|
|
1131
|
+
*/
|
|
1132
|
+
unpkg?: string;
|
|
1133
|
+
/**
|
|
1134
|
+
* A map of command name to local file name. On install, npm will symlink that file into `prefix/bin` for global installs, or `./node_modules/.bin/` for local installs.
|
|
1135
|
+
*/
|
|
1136
|
+
bin?: string | Record<string, string>;
|
|
1137
|
+
/**
|
|
1138
|
+
* Specify either a single file or an array of filenames to put in place for the `man` program to find.
|
|
1139
|
+
*/
|
|
1140
|
+
man?: string | string[];
|
|
1141
|
+
/**
|
|
1142
|
+
* Dependencies are specified in a simple object that maps a package name to a version range. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or git URL.
|
|
1143
|
+
*/
|
|
1144
|
+
dependencies?: Record<string, string>;
|
|
1145
|
+
/**
|
|
1146
|
+
* If someone is planning on downloading and using your module in their program, then they probably don’t want or need to download and build the external test or documentation framework that you use.
|
|
1147
|
+
* In this case, it’s best to map these additional items in a `devDependencies` object.
|
|
1148
|
+
*/
|
|
1149
|
+
devDependencies?: Record<string, string>;
|
|
1150
|
+
/**
|
|
1151
|
+
* If a dependency can be used, but you would like npm to proceed if it cannot be found or fails to install, then you may put it in the `optionalDependencies` object. This is a map of package name to version or url, just like the `dependencies` object. The difference is that build failures do not cause installation to fail.
|
|
1152
|
+
*/
|
|
1153
|
+
optionalDependencies?: Record<string, string>;
|
|
1154
|
+
/**
|
|
1155
|
+
* In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a `require` of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
|
|
1156
|
+
*/
|
|
1157
|
+
peerDependencies?: Record<string, string>;
|
|
1158
|
+
/**
|
|
1159
|
+
* TypeScript typings, typically ending by `.d.ts`.
|
|
1160
|
+
*/
|
|
1161
|
+
types?: string;
|
|
1162
|
+
/**
|
|
1163
|
+
* This field is synonymous with `types`.
|
|
1164
|
+
*/
|
|
1165
|
+
typings?: string;
|
|
1166
|
+
/**
|
|
1167
|
+
* Non-Standard Node.js alternate entry-point to main.
|
|
1168
|
+
* An initial implementation for supporting CJS packages (from main), and use module for ESM modules.
|
|
1169
|
+
*/
|
|
1170
|
+
module?: string;
|
|
1171
|
+
/**
|
|
1172
|
+
* Make main entry-point be loaded as an ESM module, support "export" syntax instead of "require"
|
|
1173
|
+
*
|
|
1174
|
+
* Docs:
|
|
1175
|
+
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_package_json_type_field
|
|
1176
|
+
*
|
|
1177
|
+
* @default 'commonjs'
|
|
1178
|
+
* @since Node.js v14
|
|
1179
|
+
*/
|
|
1180
|
+
type?: "module" | "commonjs";
|
|
1181
|
+
/**
|
|
1182
|
+
* Alternate and extensible alternative to "main" entry point.
|
|
1183
|
+
*
|
|
1184
|
+
* When using `{type: "module"}`, any ESM module file MUST end with `.mjs` extension.
|
|
1185
|
+
*
|
|
1186
|
+
* Docs:
|
|
1187
|
+
* - https://nodejs.org/docs/latest-v14.x/api/esm.html#esm_exports_sugar
|
|
1188
|
+
*
|
|
1189
|
+
* @since Node.js v12.7
|
|
1190
|
+
*/
|
|
1191
|
+
exports?: PackageJsonExports;
|
|
1192
|
+
/**
|
|
1193
|
+
* Docs:
|
|
1194
|
+
* - https://nodejs.org/api/packages.html#imports
|
|
1195
|
+
*/
|
|
1196
|
+
imports?: Record<string, string | Record<string, string>>;
|
|
1197
|
+
/**
|
|
1198
|
+
* The field is used to define a set of sub-packages (or workspaces) within a monorepo.
|
|
1199
|
+
*
|
|
1200
|
+
* This field is an array of glob patterns or an object with specific configurations for managing
|
|
1201
|
+
* multiple packages in a single repository.
|
|
1202
|
+
*/
|
|
1203
|
+
workspaces?: string[] | {
|
|
1204
|
+
/**
|
|
1205
|
+
* Workspace package paths. Glob patterns are supported.
|
|
1206
|
+
*/
|
|
1207
|
+
packages?: string[];
|
|
1208
|
+
/**
|
|
1209
|
+
* Packages to block from hoisting to the workspace root.
|
|
1210
|
+
* Uses glob patterns to match module paths in the dependency tree.
|
|
1211
|
+
*
|
|
1212
|
+
* Docs:
|
|
1213
|
+
* - https://classic.yarnpkg.com/blog/2018/02/15/nohoist/
|
|
1214
|
+
*/
|
|
1215
|
+
nohoist?: string[];
|
|
1216
|
+
};
|
|
1217
|
+
/**
|
|
1218
|
+
* The field is used to specify different TypeScript declaration files for
|
|
1219
|
+
* different versions of TypeScript, allowing for version-specific type definitions.
|
|
1220
|
+
*/
|
|
1221
|
+
typesVersions?: Record<string, Record<string, string[]>>;
|
|
1222
|
+
/**
|
|
1223
|
+
* You can specify which operating systems your module will run on:
|
|
1224
|
+
* ```json
|
|
1225
|
+
* {
|
|
1226
|
+
* "os": ["darwin", "linux"]
|
|
1227
|
+
* }
|
|
1228
|
+
* ```
|
|
1229
|
+
* You can also block instead of allowing operating systems, just prepend the blocked os with a '!':
|
|
1230
|
+
* ```json
|
|
1231
|
+
* {
|
|
1232
|
+
* "os": ["!win32"]
|
|
1233
|
+
* }
|
|
1234
|
+
* ```
|
|
1235
|
+
* The host operating system is determined by `process.platform`
|
|
1236
|
+
* It is allowed to both block and allow an item, although there isn't any good reason to do this.
|
|
1237
|
+
*/
|
|
1238
|
+
os?: string[];
|
|
1239
|
+
/**
|
|
1240
|
+
* If your code only runs on certain cpu architectures, you can specify which ones.
|
|
1241
|
+
* ```json
|
|
1242
|
+
* {
|
|
1243
|
+
* "cpu": ["x64", "ia32"]
|
|
1244
|
+
* }
|
|
1245
|
+
* ```
|
|
1246
|
+
* Like the `os` option, you can also block architectures:
|
|
1247
|
+
* ```json
|
|
1248
|
+
* {
|
|
1249
|
+
* "cpu": ["!arm", "!mips"]
|
|
1250
|
+
* }
|
|
1251
|
+
* ```
|
|
1252
|
+
* The host architecture is determined by `process.arch`
|
|
1253
|
+
*/
|
|
1254
|
+
cpu?: string[];
|
|
1255
|
+
/**
|
|
1256
|
+
* This is a set of config values that will be used at publish-time.
|
|
1257
|
+
*/
|
|
1258
|
+
publishConfig?: {
|
|
1259
|
+
/**
|
|
1260
|
+
* The registry that will be used if the package is published.
|
|
1261
|
+
*/
|
|
1262
|
+
registry?: string;
|
|
1263
|
+
/**
|
|
1264
|
+
* The tag that will be used if the package is published.
|
|
1265
|
+
*/
|
|
1266
|
+
tag?: string;
|
|
1267
|
+
/**
|
|
1268
|
+
* The access level that will be used if the package is published.
|
|
1269
|
+
*/
|
|
1270
|
+
access?: "public" | "restricted";
|
|
1271
|
+
/**
|
|
1272
|
+
* **pnpm-only**
|
|
1273
|
+
*
|
|
1274
|
+
* By default, for portability reasons, no files except those listed in
|
|
1275
|
+
* the bin field will be marked as executable in the resulting package
|
|
1276
|
+
* archive. The executableFiles field lets you declare additional fields
|
|
1277
|
+
* that must have the executable flag (+x) set even if
|
|
1278
|
+
* they aren't directly accessible through the bin field.
|
|
1279
|
+
*/
|
|
1280
|
+
executableFiles?: string[];
|
|
1281
|
+
/**
|
|
1282
|
+
* **pnpm-only**
|
|
1283
|
+
*
|
|
1284
|
+
* You also can use the field `publishConfig.directory` to customize
|
|
1285
|
+
* the published subdirectory relative to the current `package.json`.
|
|
1286
|
+
*
|
|
1287
|
+
* It is expected to have a modified version of the current package in
|
|
1288
|
+
* the specified directory (usually using third party build tools).
|
|
1289
|
+
*/
|
|
1290
|
+
directory?: string;
|
|
1291
|
+
/**
|
|
1292
|
+
* **pnpm-only**
|
|
1293
|
+
*
|
|
1294
|
+
* When set to `true`, the project will be symlinked from the
|
|
1295
|
+
* `publishConfig.directory` location during local development.
|
|
1296
|
+
* @default true
|
|
1297
|
+
*/
|
|
1298
|
+
linkDirectory?: boolean;
|
|
1299
|
+
} & Pick<PackageJson, "bin" | "main" | "exports" | "types" | "typings" | "module" | "browser" | "unpkg" | "typesVersions" | "os" | "cpu">;
|
|
1300
|
+
/**
|
|
1301
|
+
* See: https://nodejs.org/api/packages.html#packagemanager
|
|
1302
|
+
* This field defines which package manager is expected to be used when working on the current project.
|
|
1303
|
+
* Should be of the format: `<name>@<version>[#hash]`
|
|
1304
|
+
*/
|
|
1305
|
+
packageManager?: string;
|
|
1306
|
+
[key: string]: any;
|
|
1307
|
+
}
|
|
1308
|
+
/**
|
|
1309
|
+
* See: https://docs.npmjs.com/cli/v11/using-npm/scripts#pre--post-scripts
|
|
1310
|
+
*/
|
|
1311
|
+
type PackageJsonScriptWithPreAndPost<S extends string> = S | `${"pre" | "post"}${S}`;
|
|
1312
|
+
/**
|
|
1313
|
+
* See: https://docs.npmjs.com/cli/v11/using-npm/scripts#life-cycle-operation-order
|
|
1314
|
+
*/
|
|
1315
|
+
type PackageJsonNpmLifeCycleScripts = "dependencies" | "prepublishOnly" | PackageJsonScriptWithPreAndPost<"install" | "pack" | "prepare" | "publish" | "restart" | "start" | "stop" | "test" | "version">;
|
|
1316
|
+
/**
|
|
1317
|
+
* See: https://pnpm.io/scripts#lifecycle-scripts
|
|
1318
|
+
*/
|
|
1319
|
+
type PackageJsonPnpmLifeCycleScripts = "pnpm:devPreinstall";
|
|
1320
|
+
type PackageJsonCommonScripts = "build" | "coverage" | "deploy" | "dev" | "format" | "lint" | "preview" | "release" | "typecheck" | "watch";
|
|
1321
|
+
type PackageJsonScriptName = PackageJsonCommonScripts | PackageJsonNpmLifeCycleScripts | PackageJsonPnpmLifeCycleScripts | (string & {});
|
|
1322
|
+
type PackageJsonScripts = { [P in PackageJsonScriptName]?: string };
|
|
1323
|
+
/**
|
|
1324
|
+
* A “person” is an object with a “name” field and optionally “url” and “email”. Or you can shorten that all into a single string, and npm will parse it for you.
|
|
1325
|
+
*/
|
|
1326
|
+
type PackageJsonPerson = string | {
|
|
1327
|
+
name: string;
|
|
1328
|
+
email?: string;
|
|
1329
|
+
url?: string;
|
|
1330
|
+
};
|
|
1331
|
+
type PackageJsonFunding = string | {
|
|
1332
|
+
url: string;
|
|
1333
|
+
type?: string;
|
|
1334
|
+
};
|
|
1335
|
+
type PackageJsonExportKey = "." | "import" | "require" | "types" | "node" | "browser" | "default" | (string & {});
|
|
1336
|
+
type PackageJsonExportsObject = { [P in PackageJsonExportKey]?: string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject> };
|
|
1337
|
+
type PackageJsonExports = string | PackageJsonExportsObject | Array<string | PackageJsonExportsObject>;
|
|
1338
|
+
/**
|
|
1339
|
+
* Defines a PackageJson structure.
|
|
1340
|
+
* @param pkg - The `package.json` content as an object. See {@link PackageJson}.
|
|
1341
|
+
* @returns the same `package.json` object.
|
|
1342
|
+
*/
|
|
1343
|
+
//#endregion
|
|
1344
|
+
//#region src/platforms/types.d.ts
|
|
1345
|
+
interface OutputExtensions {
|
|
1346
|
+
js: string;
|
|
1347
|
+
json: string;
|
|
1348
|
+
wxml: string;
|
|
1349
|
+
wxss: string;
|
|
1350
|
+
wxs?: string;
|
|
1351
|
+
}
|
|
1352
|
+
//#endregion
|
|
1353
|
+
//#region src/runtime/config/types.d.ts
|
|
1354
|
+
interface LoadConfigOptions {
|
|
1355
|
+
cwd: string;
|
|
1356
|
+
isDev: boolean;
|
|
1357
|
+
mode: string;
|
|
1358
|
+
inlineConfig?: InlineConfig;
|
|
1359
|
+
configFile?: string;
|
|
1360
|
+
cliPlatform?: string;
|
|
1361
|
+
projectConfigPath?: string;
|
|
1362
|
+
}
|
|
1363
|
+
interface LoadConfigResult {
|
|
1364
|
+
config: InlineConfig;
|
|
1365
|
+
aliasEntries: ResolvedAlias[];
|
|
1366
|
+
outputExtensions: OutputExtensions;
|
|
1367
|
+
packageJson: PackageJson;
|
|
1368
|
+
relativeSrcRoot: (p: string) => string;
|
|
1369
|
+
cwd: string;
|
|
1370
|
+
isDev: boolean;
|
|
1371
|
+
mode: string;
|
|
1372
|
+
chunksConfigured?: boolean;
|
|
1373
|
+
projectConfig: Record<string, any>;
|
|
1374
|
+
projectConfigPath?: string;
|
|
1375
|
+
projectPrivateConfigPath?: string;
|
|
1376
|
+
mpDistRoot: string;
|
|
1377
|
+
weappLib?: ResolvedWeappLibConfig;
|
|
1378
|
+
weappLibOutputMap?: Map<string, string>;
|
|
1379
|
+
packageJsonPath: string;
|
|
1380
|
+
platform: MpPlatform;
|
|
1381
|
+
srcRoot: string;
|
|
1382
|
+
configFilePath?: string;
|
|
1383
|
+
currentSubPackageRoot?: string;
|
|
1384
|
+
weappWeb?: ResolvedWeappWebConfig;
|
|
1385
|
+
}
|
|
1386
|
+
interface ResolvedWeappLibConfig {
|
|
1387
|
+
enabled: boolean;
|
|
1388
|
+
entry: WeappLibConfig['entry'];
|
|
1389
|
+
root: string;
|
|
1390
|
+
outDir?: string;
|
|
1391
|
+
preservePath: boolean;
|
|
1392
|
+
fileName?: WeappLibFileName;
|
|
1393
|
+
componentJson: WeappLibComponentJson;
|
|
1394
|
+
dts: WeappLibDtsOptions;
|
|
1395
|
+
source?: WeappLibConfig;
|
|
1396
|
+
}
|
|
1397
|
+
interface PackageInfo {
|
|
1398
|
+
name: string;
|
|
1399
|
+
version: string | undefined;
|
|
1400
|
+
rootPath: string;
|
|
1401
|
+
packageJsonPath: string;
|
|
1402
|
+
packageJson: PackageJson;
|
|
1403
|
+
}
|
|
1404
|
+
interface ConfigService {
|
|
1405
|
+
options: LoadConfigResult;
|
|
1406
|
+
outputExtensions: OutputExtensions;
|
|
1407
|
+
defineEnv: Record<string, any>;
|
|
1408
|
+
packageManager: DetectResult;
|
|
1409
|
+
packageInfo: PackageInfo;
|
|
1410
|
+
setDefineEnv: (key: string, value: any) => void;
|
|
1411
|
+
load: (options?: Partial<LoadConfigOptions>) => Promise<LoadConfigResult>;
|
|
1412
|
+
mergeWorkers: (...configs: Partial<InlineConfig>[]) => InlineConfig;
|
|
1413
|
+
merge: (subPackageMeta?: SubPackageMetaValue, ...configs: Partial<InlineConfig | undefined>[]) => InlineConfig;
|
|
1414
|
+
mergeWeb: (...configs: Partial<InlineConfig | undefined>[]) => InlineConfig | undefined;
|
|
1415
|
+
mergeInlineConfig: (...configs: Partial<InlineConfig>[]) => InlineConfig;
|
|
1416
|
+
readonly defineImportMetaEnv: Record<string, any>;
|
|
1417
|
+
readonly cwd: string;
|
|
1418
|
+
readonly isDev: boolean;
|
|
1419
|
+
readonly mpDistRoot: string;
|
|
1420
|
+
readonly outDir: string;
|
|
1421
|
+
readonly inlineConfig: InlineConfig;
|
|
1422
|
+
readonly weappViteConfig: NonNullable<InlineConfig['weapp']>;
|
|
1423
|
+
readonly packageJson: PackageJson;
|
|
1424
|
+
readonly projectConfig: Record<string, any>;
|
|
1425
|
+
readonly projectConfigPath?: string;
|
|
1426
|
+
readonly projectPrivateConfigPath?: string;
|
|
1427
|
+
readonly srcRoot: string;
|
|
1428
|
+
readonly pluginRoot: string | undefined;
|
|
1429
|
+
readonly absolutePluginRoot: string | undefined;
|
|
1430
|
+
readonly absolutePluginOutputRoot: string | undefined;
|
|
1431
|
+
readonly absoluteSrcRoot: string;
|
|
1432
|
+
readonly mode: string;
|
|
1433
|
+
readonly aliasEntries: ResolvedAlias[];
|
|
1434
|
+
readonly platform: MpPlatform;
|
|
1435
|
+
readonly configFilePath?: string;
|
|
1436
|
+
readonly weappWebConfig?: ResolvedWeappWebConfig;
|
|
1437
|
+
readonly weappLibConfig?: ResolvedWeappLibConfig;
|
|
1438
|
+
readonly weappLibOutputMap?: Map<string, string>;
|
|
1439
|
+
relativeCwd: (p: string) => string;
|
|
1440
|
+
relativeSrcRoot: (p: string) => string;
|
|
1441
|
+
relativeAbsoluteSrcRoot: (p: string) => string;
|
|
1442
|
+
relativeOutputPath: (p: string) => string;
|
|
1443
|
+
readonly currentSubPackageRoot?: string;
|
|
1444
|
+
}
|
|
1445
|
+
interface ResolvedWeappWebConfig {
|
|
1446
|
+
enabled: boolean;
|
|
1447
|
+
root: string;
|
|
1448
|
+
srcDir: string;
|
|
1449
|
+
outDir: string;
|
|
1450
|
+
pluginOptions: Omit<WeappWebPluginOptions, 'srcDir'> & {
|
|
1451
|
+
srcDir: string;
|
|
1452
|
+
};
|
|
1453
|
+
userConfig?: InlineConfig;
|
|
1454
|
+
source?: WeappWebConfig;
|
|
1455
|
+
}
|
|
1456
|
+
//#endregion
|
|
1457
|
+
//#region src/utils/json.d.ts
|
|
1458
|
+
interface JsonResolvableEntry {
|
|
1459
|
+
json?: any;
|
|
1460
|
+
jsonPath?: string;
|
|
1461
|
+
type?: 'app' | 'page' | 'component' | 'plugin';
|
|
1462
|
+
}
|
|
1463
|
+
//#endregion
|
|
1464
|
+
//#region ../../node_modules/.pnpm/lru-cache@11.2.7/node_modules/lru-cache/dist/esm/index.d.ts
|
|
1465
|
+
/**
|
|
1466
|
+
* @module LRUCache
|
|
1467
|
+
*/
|
|
1468
|
+
type Perf = {
|
|
1469
|
+
now: () => number;
|
|
1470
|
+
};
|
|
1471
|
+
declare const TYPE: unique symbol;
|
|
1472
|
+
type Index = number & {
|
|
1473
|
+
[TYPE]: 'LRUCache Index';
|
|
1474
|
+
};
|
|
1475
|
+
type UintArray = Uint8Array | Uint16Array | Uint32Array;
|
|
1476
|
+
type NumberArray = UintArray | number[];
|
|
1477
|
+
declare class ZeroArray extends Array<number> {
|
|
1478
|
+
constructor(size: number);
|
|
1479
|
+
}
|
|
1480
|
+
type StackLike = Stack | Index[];
|
|
1481
|
+
declare class Stack {
|
|
1482
|
+
#private;
|
|
1483
|
+
heap: NumberArray;
|
|
1484
|
+
length: number;
|
|
1485
|
+
static create(max: number): StackLike;
|
|
1486
|
+
constructor(max: number, HeapCls: {
|
|
1487
|
+
new (n: number): NumberArray;
|
|
1488
|
+
});
|
|
1489
|
+
push(n: Index): void;
|
|
1490
|
+
pop(): Index;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Promise representing an in-progress {@link LRUCache#fetch} call
|
|
1494
|
+
*/
|
|
1495
|
+
type BackgroundFetch<V> = Promise<V | undefined> & {
|
|
1496
|
+
__returned: BackgroundFetch<V> | undefined;
|
|
1497
|
+
__abortController: AbortController;
|
|
1498
|
+
__staleWhileFetching: V | undefined;
|
|
1499
|
+
};
|
|
1500
|
+
declare namespace LRUCache {
|
|
1501
|
+
/**
|
|
1502
|
+
* An integer greater than 0, reflecting the calculated size of items
|
|
1503
|
+
*/
|
|
1504
|
+
type Size = number;
|
|
1505
|
+
/**
|
|
1506
|
+
* Integer greater than 0, representing some number of milliseconds, or the
|
|
1507
|
+
* time at which a TTL started counting from.
|
|
1508
|
+
*/
|
|
1509
|
+
type Milliseconds = number;
|
|
1510
|
+
/**
|
|
1511
|
+
* An integer greater than 0, reflecting a number of items
|
|
1512
|
+
*/
|
|
1513
|
+
type Count = number;
|
|
1514
|
+
/**
|
|
1515
|
+
* The reason why an item was removed from the cache, passed
|
|
1516
|
+
* to the {@link Disposer} methods.
|
|
1517
|
+
*
|
|
1518
|
+
* - `evict`: The item was evicted because it is the least recently used,
|
|
1519
|
+
* and the cache is full.
|
|
1520
|
+
* - `set`: A new value was set, overwriting the old value being disposed.
|
|
1521
|
+
* - `delete`: The item was explicitly deleted, either by calling
|
|
1522
|
+
* {@link LRUCache#delete}, {@link LRUCache#clear}, or
|
|
1523
|
+
* {@link LRUCache#set} with an undefined value.
|
|
1524
|
+
* - `expire`: The item was removed due to exceeding its TTL.
|
|
1525
|
+
* - `fetch`: A {@link OptionsBase#fetchMethod} operation returned
|
|
1526
|
+
* `undefined` or was aborted, causing the item to be deleted.
|
|
1527
|
+
*/
|
|
1528
|
+
type DisposeReason = 'evict' | 'set' | 'delete' | 'expire' | 'fetch';
|
|
1529
|
+
/**
|
|
1530
|
+
* A method called upon item removal, passed as the
|
|
1531
|
+
* {@link OptionsBase.dispose} and/or
|
|
1532
|
+
* {@link OptionsBase.disposeAfter} options.
|
|
1533
|
+
*/
|
|
1534
|
+
type Disposer<K, V> = (value: V, key: K, reason: DisposeReason) => void;
|
|
1535
|
+
/**
|
|
1536
|
+
* The reason why an item was added to the cache, passed
|
|
1537
|
+
* to the {@link Inserter} methods.
|
|
1538
|
+
*
|
|
1539
|
+
* - `add`: the item was not found in the cache, and was added
|
|
1540
|
+
* - `update`: the item was in the cache, with the same value provided
|
|
1541
|
+
* - `replace`: the item was in the cache, and replaced
|
|
1542
|
+
*/
|
|
1543
|
+
type InsertReason = 'add' | 'update' | 'replace';
|
|
1544
|
+
/**
|
|
1545
|
+
* A method called upon item insertion, passed as the
|
|
1546
|
+
* {@link OptionsBase.insert}
|
|
1547
|
+
*/
|
|
1548
|
+
type Inserter<K, V> = (value: V, key: K, reason: InsertReason) => void;
|
|
1549
|
+
/**
|
|
1550
|
+
* A function that returns the effective calculated size
|
|
1551
|
+
* of an entry in the cache.
|
|
1552
|
+
*/
|
|
1553
|
+
type SizeCalculator<K, V> = (value: V, key: K) => Size;
|
|
1554
|
+
/**
|
|
1555
|
+
* Options provided to the
|
|
1556
|
+
* {@link OptionsBase.fetchMethod} function.
|
|
1557
|
+
*/
|
|
1558
|
+
interface FetcherOptions<K, V, FC = unknown> {
|
|
1559
|
+
signal: AbortSignal;
|
|
1560
|
+
options: FetcherFetchOptions<K, V, FC>;
|
|
1561
|
+
/**
|
|
1562
|
+
* Object provided in the {@link FetchOptions.context} option to
|
|
1563
|
+
* {@link LRUCache#fetch}
|
|
1564
|
+
*/
|
|
1565
|
+
context: FC;
|
|
1566
|
+
}
|
|
1567
|
+
/**
|
|
1568
|
+
* Occasionally, it may be useful to track the internal behavior of the
|
|
1569
|
+
* cache, particularly for logging, debugging, or for behavior within the
|
|
1570
|
+
* `fetchMethod`. To do this, you can pass a `status` object to the
|
|
1571
|
+
* {@link LRUCache#fetch}, {@link LRUCache#get}, {@link LRUCache#set},
|
|
1572
|
+
* {@link LRUCache#memo}, and {@link LRUCache#has} methods.
|
|
1573
|
+
*
|
|
1574
|
+
* The `status` option should be a plain JavaScript object. The following
|
|
1575
|
+
* fields will be set on it appropriately, depending on the situation.
|
|
1576
|
+
*/
|
|
1577
|
+
interface Status<V> {
|
|
1578
|
+
/**
|
|
1579
|
+
* The status of a set() operation.
|
|
1580
|
+
*
|
|
1581
|
+
* - add: the item was not found in the cache, and was added
|
|
1582
|
+
* - update: the item was in the cache, with the same value provided
|
|
1583
|
+
* - replace: the item was in the cache, and replaced
|
|
1584
|
+
* - miss: the item was not added to the cache for some reason
|
|
1585
|
+
*/
|
|
1586
|
+
set?: 'add' | 'update' | 'replace' | 'miss';
|
|
1587
|
+
/**
|
|
1588
|
+
* the ttl stored for the item, or undefined if ttls are not used.
|
|
1589
|
+
*/
|
|
1590
|
+
ttl?: Milliseconds;
|
|
1591
|
+
/**
|
|
1592
|
+
* the start time for the item, or undefined if ttls are not used.
|
|
1593
|
+
*/
|
|
1594
|
+
start?: Milliseconds;
|
|
1595
|
+
/**
|
|
1596
|
+
* The timestamp used for TTL calculation
|
|
1597
|
+
*/
|
|
1598
|
+
now?: Milliseconds;
|
|
1599
|
+
/**
|
|
1600
|
+
* the remaining ttl for the item, or undefined if ttls are not used.
|
|
1601
|
+
*/
|
|
1602
|
+
remainingTTL?: Milliseconds;
|
|
1603
|
+
/**
|
|
1604
|
+
* The calculated size for the item, if sizes are used.
|
|
1605
|
+
*/
|
|
1606
|
+
entrySize?: Size;
|
|
1607
|
+
/**
|
|
1608
|
+
* The total calculated size of the cache, if sizes are used.
|
|
1609
|
+
*/
|
|
1610
|
+
totalCalculatedSize?: Size;
|
|
1611
|
+
/**
|
|
1612
|
+
* A flag indicating that the item was not stored, due to exceeding the
|
|
1613
|
+
* {@link OptionsBase.maxEntrySize}
|
|
1614
|
+
*/
|
|
1615
|
+
maxEntrySizeExceeded?: true;
|
|
1616
|
+
/**
|
|
1617
|
+
* The old value, specified in the case of `set:'update'` or
|
|
1618
|
+
* `set:'replace'`
|
|
1619
|
+
*/
|
|
1620
|
+
oldValue?: V;
|
|
1621
|
+
/**
|
|
1622
|
+
* The results of a {@link LRUCache#has} operation
|
|
1623
|
+
*
|
|
1624
|
+
* - hit: the item was found in the cache
|
|
1625
|
+
* - stale: the item was found in the cache, but is stale
|
|
1626
|
+
* - miss: the item was not found in the cache
|
|
1627
|
+
*/
|
|
1628
|
+
has?: 'hit' | 'stale' | 'miss';
|
|
1629
|
+
/**
|
|
1630
|
+
* The status of a {@link LRUCache#fetch} operation.
|
|
1631
|
+
* Note that this can change as the underlying fetch() moves through
|
|
1632
|
+
* various states.
|
|
1633
|
+
*
|
|
1634
|
+
* - inflight: there is another fetch() for this key which is in process
|
|
1635
|
+
* - get: there is no {@link OptionsBase.fetchMethod}, so
|
|
1636
|
+
* {@link LRUCache#get} was called.
|
|
1637
|
+
* - miss: the item is not in cache, and will be fetched.
|
|
1638
|
+
* - hit: the item is in the cache, and was resolved immediately.
|
|
1639
|
+
* - stale: the item is in the cache, but stale.
|
|
1640
|
+
* - refresh: the item is in the cache, and not stale, but
|
|
1641
|
+
* {@link FetchOptions.forceRefresh} was specified.
|
|
1642
|
+
*/
|
|
1643
|
+
fetch?: 'get' | 'inflight' | 'miss' | 'hit' | 'stale' | 'refresh';
|
|
1644
|
+
/**
|
|
1645
|
+
* The {@link OptionsBase.fetchMethod} was called
|
|
1646
|
+
*/
|
|
1647
|
+
fetchDispatched?: true;
|
|
1648
|
+
/**
|
|
1649
|
+
* The cached value was updated after a successful call to
|
|
1650
|
+
* {@link OptionsBase.fetchMethod}
|
|
1651
|
+
*/
|
|
1652
|
+
fetchUpdated?: true;
|
|
1653
|
+
/**
|
|
1654
|
+
* The reason for a fetch() rejection. Either the error raised by the
|
|
1655
|
+
* {@link OptionsBase.fetchMethod}, or the reason for an
|
|
1656
|
+
* AbortSignal.
|
|
1657
|
+
*/
|
|
1658
|
+
fetchError?: Error;
|
|
1659
|
+
/**
|
|
1660
|
+
* The fetch received an abort signal
|
|
1661
|
+
*/
|
|
1662
|
+
fetchAborted?: true;
|
|
1663
|
+
/**
|
|
1664
|
+
* The abort signal received was ignored, and the fetch was allowed to
|
|
1665
|
+
* continue.
|
|
1666
|
+
*/
|
|
1667
|
+
fetchAbortIgnored?: true;
|
|
1668
|
+
/**
|
|
1669
|
+
* The fetchMethod promise resolved successfully
|
|
1670
|
+
*/
|
|
1671
|
+
fetchResolved?: true;
|
|
1672
|
+
/**
|
|
1673
|
+
* The fetchMethod promise was rejected
|
|
1674
|
+
*/
|
|
1675
|
+
fetchRejected?: true;
|
|
1676
|
+
/**
|
|
1677
|
+
* The status of a {@link LRUCache#get} operation.
|
|
1678
|
+
*
|
|
1679
|
+
* - fetching: The item is currently being fetched. If a previous value
|
|
1680
|
+
* is present and allowed, that will be returned.
|
|
1681
|
+
* - stale: The item is in the cache, and is stale.
|
|
1682
|
+
* - hit: the item is in the cache
|
|
1683
|
+
* - miss: the item is not in the cache
|
|
1684
|
+
*/
|
|
1685
|
+
get?: 'stale' | 'hit' | 'miss';
|
|
1686
|
+
/**
|
|
1687
|
+
* A fetch or get operation returned a stale value.
|
|
1688
|
+
*/
|
|
1689
|
+
returnedStale?: true;
|
|
1690
|
+
}
|
|
1691
|
+
/**
|
|
1692
|
+
* options which override the options set in the LRUCache constructor
|
|
1693
|
+
* when calling {@link LRUCache#fetch}.
|
|
1694
|
+
*
|
|
1695
|
+
* This is the union of {@link GetOptions} and {@link SetOptions}, plus
|
|
1696
|
+
* {@link OptionsBase.noDeleteOnFetchRejection},
|
|
1697
|
+
* {@link OptionsBase.allowStaleOnFetchRejection},
|
|
1698
|
+
* {@link FetchOptions.forceRefresh}, and
|
|
1699
|
+
* {@link FetcherOptions.context}
|
|
1700
|
+
*
|
|
1701
|
+
* Any of these may be modified in the {@link OptionsBase.fetchMethod}
|
|
1702
|
+
* function, but the {@link GetOptions} fields will of course have no
|
|
1703
|
+
* effect, as the {@link LRUCache#get} call already happened by the time
|
|
1704
|
+
* the fetchMethod is called.
|
|
1705
|
+
*/
|
|
1706
|
+
interface FetcherFetchOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
|
|
1707
|
+
status?: Status<V>;
|
|
1708
|
+
size?: Size;
|
|
1709
|
+
}
|
|
1710
|
+
/**
|
|
1711
|
+
* Options that may be passed to the {@link LRUCache#fetch} method.
|
|
1712
|
+
*/
|
|
1713
|
+
interface FetchOptions<K, V, FC> extends FetcherFetchOptions<K, V, FC> {
|
|
1714
|
+
/**
|
|
1715
|
+
* Set to true to force a re-load of the existing data, even if it
|
|
1716
|
+
* is not yet stale.
|
|
1717
|
+
*/
|
|
1718
|
+
forceRefresh?: boolean;
|
|
1719
|
+
/**
|
|
1720
|
+
* Context provided to the {@link OptionsBase.fetchMethod} as
|
|
1721
|
+
* the {@link FetcherOptions.context} param.
|
|
1722
|
+
*
|
|
1723
|
+
* If the FC type is specified as unknown (the default),
|
|
1724
|
+
* undefined or void, then this is optional. Otherwise, it will
|
|
1725
|
+
* be required.
|
|
1726
|
+
*/
|
|
1727
|
+
context?: FC;
|
|
1728
|
+
signal?: AbortSignal;
|
|
1729
|
+
status?: Status<V>;
|
|
1730
|
+
}
|
|
1731
|
+
/**
|
|
1732
|
+
* Options provided to {@link LRUCache#fetch} when the FC type is something
|
|
1733
|
+
* other than `unknown`, `undefined`, or `void`
|
|
1734
|
+
*/
|
|
1735
|
+
interface FetchOptionsWithContext<K, V, FC> extends FetchOptions<K, V, FC> {
|
|
1736
|
+
context: FC;
|
|
1737
|
+
}
|
|
1738
|
+
/**
|
|
1739
|
+
* Options provided to {@link LRUCache#fetch} when the FC type is
|
|
1740
|
+
* `undefined` or `void`
|
|
1741
|
+
*/
|
|
1742
|
+
interface FetchOptionsNoContext<K, V> extends FetchOptions<K, V, undefined> {
|
|
1743
|
+
context?: undefined;
|
|
1744
|
+
}
|
|
1745
|
+
interface MemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL' | 'noDeleteOnFetchRejection' | 'allowStaleOnFetchRejection' | 'ignoreFetchAbort' | 'allowStaleOnFetchAbort'> {
|
|
1746
|
+
/**
|
|
1747
|
+
* Set to true to force a re-load of the existing data, even if it
|
|
1748
|
+
* is not yet stale.
|
|
1749
|
+
*/
|
|
1750
|
+
forceRefresh?: boolean;
|
|
1751
|
+
/**
|
|
1752
|
+
* Context provided to the {@link OptionsBase.memoMethod} as
|
|
1753
|
+
* the {@link MemoizerOptions.context} param.
|
|
1754
|
+
*
|
|
1755
|
+
* If the FC type is specified as unknown (the default),
|
|
1756
|
+
* undefined or void, then this is optional. Otherwise, it will
|
|
1757
|
+
* be required.
|
|
1758
|
+
*/
|
|
1759
|
+
context?: FC;
|
|
1760
|
+
status?: Status<V>;
|
|
1761
|
+
}
|
|
1762
|
+
/**
|
|
1763
|
+
* Options provided to {@link LRUCache#memo} when the FC type is something
|
|
1764
|
+
* other than `unknown`, `undefined`, or `void`
|
|
1765
|
+
*/
|
|
1766
|
+
interface MemoOptionsWithContext<K, V, FC> extends MemoOptions<K, V, FC> {
|
|
1767
|
+
context: FC;
|
|
1768
|
+
}
|
|
1769
|
+
/**
|
|
1770
|
+
* Options provided to {@link LRUCache#memo} when the FC type is
|
|
1771
|
+
* `undefined` or `void`
|
|
1772
|
+
*/
|
|
1773
|
+
interface MemoOptionsNoContext<K, V> extends MemoOptions<K, V, undefined> {
|
|
1774
|
+
context?: undefined;
|
|
1775
|
+
}
|
|
1776
|
+
/**
|
|
1777
|
+
* Options provided to the
|
|
1778
|
+
* {@link OptionsBase.memoMethod} function.
|
|
1779
|
+
*/
|
|
1780
|
+
interface MemoizerOptions<K, V, FC = unknown> {
|
|
1781
|
+
options: MemoizerMemoOptions<K, V, FC>;
|
|
1782
|
+
/**
|
|
1783
|
+
* Object provided in the {@link MemoOptions.context} option to
|
|
1784
|
+
* {@link LRUCache#memo}
|
|
1785
|
+
*/
|
|
1786
|
+
context: FC;
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* options which override the options set in the LRUCache constructor
|
|
1790
|
+
* when calling {@link LRUCache#memo}.
|
|
1791
|
+
*
|
|
1792
|
+
* This is the union of {@link GetOptions} and {@link SetOptions}, plus
|
|
1793
|
+
* {@link MemoOptions.forceRefresh}, and
|
|
1794
|
+
* {@link MemoOptions.context}
|
|
1795
|
+
*
|
|
1796
|
+
* Any of these may be modified in the {@link OptionsBase.memoMethod}
|
|
1797
|
+
* function, but the {@link GetOptions} fields will of course have no
|
|
1798
|
+
* effect, as the {@link LRUCache#get} call already happened by the time
|
|
1799
|
+
* the memoMethod is called.
|
|
1800
|
+
*/
|
|
1801
|
+
interface MemoizerMemoOptions<K, V, FC = unknown> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet' | 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL'> {
|
|
1802
|
+
status?: Status<V>;
|
|
1803
|
+
size?: Size;
|
|
1804
|
+
start?: Milliseconds;
|
|
1805
|
+
}
|
|
1806
|
+
/**
|
|
1807
|
+
* Options that may be passed to the {@link LRUCache#has} method.
|
|
1808
|
+
*/
|
|
1809
|
+
interface HasOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'updateAgeOnHas'> {
|
|
1810
|
+
status?: Status<V>;
|
|
1811
|
+
}
|
|
1812
|
+
/**
|
|
1813
|
+
* Options that may be passed to the {@link LRUCache#get} method.
|
|
1814
|
+
*/
|
|
1815
|
+
interface GetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale' | 'updateAgeOnGet' | 'noDeleteOnStaleGet'> {
|
|
1816
|
+
status?: Status<V>;
|
|
1817
|
+
}
|
|
1818
|
+
/**
|
|
1819
|
+
* Options that may be passed to the {@link LRUCache#peek} method.
|
|
1820
|
+
*/
|
|
1821
|
+
interface PeekOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'allowStale'> {}
|
|
1822
|
+
/**
|
|
1823
|
+
* Options that may be passed to the {@link LRUCache#set} method.
|
|
1824
|
+
*/
|
|
1825
|
+
interface SetOptions<K, V, FC> extends Pick<OptionsBase<K, V, FC>, 'sizeCalculation' | 'ttl' | 'noDisposeOnSet' | 'noUpdateTTL'> {
|
|
1826
|
+
/**
|
|
1827
|
+
* If size tracking is enabled, then setting an explicit size
|
|
1828
|
+
* in the {@link LRUCache#set} call will prevent calling the
|
|
1829
|
+
* {@link OptionsBase.sizeCalculation} function.
|
|
1830
|
+
*/
|
|
1831
|
+
size?: Size;
|
|
1832
|
+
/**
|
|
1833
|
+
* If TTL tracking is enabled, then setting an explicit start
|
|
1834
|
+
* time in the {@link LRUCache#set} call will override the
|
|
1835
|
+
* default time from `performance.now()` or `Date.now()`.
|
|
1836
|
+
*
|
|
1837
|
+
* Note that it must be a valid value for whichever time-tracking
|
|
1838
|
+
* method is in use.
|
|
1839
|
+
*/
|
|
1840
|
+
start?: Milliseconds;
|
|
1841
|
+
status?: Status<V>;
|
|
1842
|
+
}
|
|
1843
|
+
/**
|
|
1844
|
+
* The type signature for the {@link OptionsBase.fetchMethod} option.
|
|
1845
|
+
*/
|
|
1846
|
+
type Fetcher<K, V, FC = unknown> = (key: K, staleValue: V | undefined, options: FetcherOptions<K, V, FC>) => Promise<V | undefined | void> | V | undefined | void;
|
|
1847
|
+
/**
|
|
1848
|
+
* the type signature for the {@link OptionsBase.memoMethod} option.
|
|
1849
|
+
*/
|
|
1850
|
+
type Memoizer<K, V, FC = unknown> = (key: K, staleValue: V | undefined, options: MemoizerOptions<K, V, FC>) => V;
|
|
1851
|
+
/**
|
|
1852
|
+
* Options which may be passed to the {@link LRUCache} constructor.
|
|
1853
|
+
*
|
|
1854
|
+
* Most of these may be overridden in the various options that use
|
|
1855
|
+
* them.
|
|
1856
|
+
*
|
|
1857
|
+
* Despite all being technically optional, the constructor requires that
|
|
1858
|
+
* a cache is at minimum limited by one or more of {@link OptionsBase.max},
|
|
1859
|
+
* {@link OptionsBase.ttl}, or {@link OptionsBase.maxSize}.
|
|
1860
|
+
*
|
|
1861
|
+
* If {@link OptionsBase.ttl} is used alone, then it is strongly advised
|
|
1862
|
+
* (and in fact required by the type definitions here) that the cache
|
|
1863
|
+
* also set {@link OptionsBase.ttlAutopurge}, to prevent potentially
|
|
1864
|
+
* unbounded storage.
|
|
1865
|
+
*
|
|
1866
|
+
* All options are also available on the {@link LRUCache} instance, making
|
|
1867
|
+
* it safe to pass an LRUCache instance as the options argumemnt to
|
|
1868
|
+
* make another empty cache of the same type.
|
|
1869
|
+
*
|
|
1870
|
+
* Some options are marked as read-only, because changing them after
|
|
1871
|
+
* instantiation is not safe. Changing any of the other options will of
|
|
1872
|
+
* course only have an effect on subsequent method calls.
|
|
1873
|
+
*/
|
|
1874
|
+
interface OptionsBase<K, V, FC> {
|
|
1875
|
+
/**
|
|
1876
|
+
* The maximum number of items to store in the cache before evicting
|
|
1877
|
+
* old entries. This is read-only on the {@link LRUCache} instance,
|
|
1878
|
+
* and may not be overridden.
|
|
1879
|
+
*
|
|
1880
|
+
* If set, then storage space will be pre-allocated at construction
|
|
1881
|
+
* time, and the cache will perform significantly faster.
|
|
1882
|
+
*
|
|
1883
|
+
* Note that significantly fewer items may be stored, if
|
|
1884
|
+
* {@link OptionsBase.maxSize} and/or {@link OptionsBase.ttl} are also
|
|
1885
|
+
* set.
|
|
1886
|
+
*
|
|
1887
|
+
* **It is strongly recommended to set a `max` to prevent unbounded growth
|
|
1888
|
+
* of the cache.**
|
|
1889
|
+
*/
|
|
1890
|
+
max?: Count;
|
|
1891
|
+
/**
|
|
1892
|
+
* Max time in milliseconds for items to live in cache before they are
|
|
1893
|
+
* considered stale. Note that stale items are NOT preemptively removed by
|
|
1894
|
+
* default, and MAY live in the cache, contributing to its LRU max, long
|
|
1895
|
+
* after they have expired, unless {@link OptionsBase.ttlAutopurge} is
|
|
1896
|
+
* set.
|
|
1897
|
+
*
|
|
1898
|
+
* If set to `0` (the default value), then that means "do not track
|
|
1899
|
+
* TTL", not "expire immediately".
|
|
1900
|
+
*
|
|
1901
|
+
* Also, as this cache is optimized for LRU/MRU operations, some of
|
|
1902
|
+
* the staleness/TTL checks will reduce performance, as they will incur
|
|
1903
|
+
* overhead by deleting items.
|
|
1904
|
+
*
|
|
1905
|
+
* This is not primarily a TTL cache, and does not make strong TTL
|
|
1906
|
+
* guarantees. There is no pre-emptive pruning of expired items, but you
|
|
1907
|
+
* _may_ set a TTL on the cache, and it will treat expired items as missing
|
|
1908
|
+
* when they are fetched, and delete them.
|
|
1909
|
+
*
|
|
1910
|
+
* Optional, but must be a non-negative integer in ms if specified.
|
|
1911
|
+
*
|
|
1912
|
+
* This may be overridden by passing an options object to `cache.set()`.
|
|
1913
|
+
*
|
|
1914
|
+
* At least one of `max`, `maxSize`, or `TTL` is required. This must be a
|
|
1915
|
+
* positive integer if set.
|
|
1916
|
+
*
|
|
1917
|
+
* Even if ttl tracking is enabled, **it is strongly recommended to set a
|
|
1918
|
+
* `max` to prevent unbounded growth of the cache.**
|
|
1919
|
+
*
|
|
1920
|
+
* If ttl tracking is enabled, and `max` and `maxSize` are not set,
|
|
1921
|
+
* and `ttlAutopurge` is not set, then a warning will be emitted
|
|
1922
|
+
* cautioning about the potential for unbounded memory consumption.
|
|
1923
|
+
* (The TypeScript definitions will also discourage this.)
|
|
1924
|
+
*/
|
|
1925
|
+
ttl?: Milliseconds;
|
|
1926
|
+
/**
|
|
1927
|
+
* Minimum amount of time in ms in which to check for staleness.
|
|
1928
|
+
* Defaults to 1, which means that the current time is checked
|
|
1929
|
+
* at most once per millisecond.
|
|
1930
|
+
*
|
|
1931
|
+
* Set to 0 to check the current time every time staleness is tested.
|
|
1932
|
+
* (This reduces performance, and is theoretically unnecessary.)
|
|
1933
|
+
*
|
|
1934
|
+
* Setting this to a higher value will improve performance somewhat
|
|
1935
|
+
* while using ttl tracking, albeit at the expense of keeping stale
|
|
1936
|
+
* items around a bit longer than their TTLs would indicate.
|
|
1937
|
+
*
|
|
1938
|
+
* @default 1
|
|
1939
|
+
*/
|
|
1940
|
+
ttlResolution?: Milliseconds;
|
|
1941
|
+
/**
|
|
1942
|
+
* Preemptively remove stale items from the cache.
|
|
1943
|
+
*
|
|
1944
|
+
* Note that this may *significantly* degrade performance, especially if
|
|
1945
|
+
* the cache is storing a large number of items. It is almost always best
|
|
1946
|
+
* to just leave the stale items in the cache, and let them fall out as new
|
|
1947
|
+
* items are added.
|
|
1948
|
+
*
|
|
1949
|
+
* Note that this means that {@link OptionsBase.allowStale} is a bit
|
|
1950
|
+
* pointless, as stale items will be deleted almost as soon as they
|
|
1951
|
+
* expire.
|
|
1952
|
+
*
|
|
1953
|
+
* Use with caution!
|
|
1954
|
+
*/
|
|
1955
|
+
ttlAutopurge?: boolean;
|
|
1956
|
+
/**
|
|
1957
|
+
* When using time-expiring entries with `ttl`, setting this to `true` will
|
|
1958
|
+
* make each item's age reset to 0 whenever it is retrieved from cache with
|
|
1959
|
+
* {@link LRUCache#get}, causing it to not expire. (It can still fall out
|
|
1960
|
+
* of cache based on recency of use, of course.)
|
|
1961
|
+
*
|
|
1962
|
+
* Has no effect if {@link OptionsBase.ttl} is not set.
|
|
1963
|
+
*
|
|
1964
|
+
* This may be overridden by passing an options object to `cache.get()`.
|
|
1965
|
+
*/
|
|
1966
|
+
updateAgeOnGet?: boolean;
|
|
1967
|
+
/**
|
|
1968
|
+
* When using time-expiring entries with `ttl`, setting this to `true` will
|
|
1969
|
+
* make each item's age reset to 0 whenever its presence in the cache is
|
|
1970
|
+
* checked with {@link LRUCache#has}, causing it to not expire. (It can
|
|
1971
|
+
* still fall out of cache based on recency of use, of course.)
|
|
1972
|
+
*
|
|
1973
|
+
* Has no effect if {@link OptionsBase.ttl} is not set.
|
|
1974
|
+
*/
|
|
1975
|
+
updateAgeOnHas?: boolean;
|
|
1976
|
+
/**
|
|
1977
|
+
* Allow {@link LRUCache#get} and {@link LRUCache#fetch} calls to return
|
|
1978
|
+
* stale data, if available.
|
|
1979
|
+
*
|
|
1980
|
+
* By default, if you set `ttl`, stale items will only be deleted from the
|
|
1981
|
+
* cache when you `get(key)`. That is, it's not preemptively pruning items,
|
|
1982
|
+
* unless {@link OptionsBase.ttlAutopurge} is set.
|
|
1983
|
+
*
|
|
1984
|
+
* If you set `allowStale:true`, it'll return the stale value *as well as*
|
|
1985
|
+
* deleting it. If you don't set this, then it'll return `undefined` when
|
|
1986
|
+
* you try to get a stale entry.
|
|
1987
|
+
*
|
|
1988
|
+
* Note that when a stale entry is fetched, _even if it is returned due to
|
|
1989
|
+
* `allowStale` being set_, it is removed from the cache immediately. You
|
|
1990
|
+
* can suppress this behavior by setting
|
|
1991
|
+
* {@link OptionsBase.noDeleteOnStaleGet}, either in the constructor, or in
|
|
1992
|
+
* the options provided to {@link LRUCache#get}.
|
|
1993
|
+
*
|
|
1994
|
+
* This may be overridden by passing an options object to `cache.get()`.
|
|
1995
|
+
* The `cache.has()` method will always return `false` for stale items.
|
|
1996
|
+
*
|
|
1997
|
+
* Only relevant if a ttl is set.
|
|
1998
|
+
*/
|
|
1999
|
+
allowStale?: boolean;
|
|
2000
|
+
/**
|
|
2001
|
+
* Function that is called on items when they are dropped from the
|
|
2002
|
+
* cache, as `dispose(value, key, reason)`.
|
|
2003
|
+
*
|
|
2004
|
+
* This can be handy if you want to close file descriptors or do
|
|
2005
|
+
* other cleanup tasks when items are no longer stored in the cache.
|
|
2006
|
+
*
|
|
2007
|
+
* **NOTE**: It is called _before_ the item has been fully removed
|
|
2008
|
+
* from the cache, so if you want to put it right back in, you need
|
|
2009
|
+
* to wait until the next tick. If you try to add it back in during
|
|
2010
|
+
* the `dispose()` function call, it will break things in subtle and
|
|
2011
|
+
* weird ways.
|
|
2012
|
+
*
|
|
2013
|
+
* Unlike several other options, this may _not_ be overridden by
|
|
2014
|
+
* passing an option to `set()`, for performance reasons.
|
|
2015
|
+
*
|
|
2016
|
+
* The `reason` will be one of the following strings, corresponding
|
|
2017
|
+
* to the reason for the item's deletion:
|
|
2018
|
+
*
|
|
2019
|
+
* - `evict` Item was evicted to make space for a new addition
|
|
2020
|
+
* - `set` Item was overwritten by a new value
|
|
2021
|
+
* - `expire` Item expired its TTL
|
|
2022
|
+
* - `fetch` Item was deleted due to a failed or aborted fetch, or a
|
|
2023
|
+
* fetchMethod returning `undefined.
|
|
2024
|
+
* - `delete` Item was removed by explicit `cache.delete(key)`,
|
|
2025
|
+
* `cache.clear()`, or `cache.set(key, undefined)`.
|
|
2026
|
+
*/
|
|
2027
|
+
dispose?: Disposer<K, V>;
|
|
2028
|
+
/**
|
|
2029
|
+
* Function that is called when new items are inserted into the cache,
|
|
2030
|
+
* as `onInsert(value, key, reason)`.
|
|
2031
|
+
*
|
|
2032
|
+
* This can be useful if you need to perform actions when an item is
|
|
2033
|
+
* added, such as logging or tracking insertions.
|
|
2034
|
+
*
|
|
2035
|
+
* Unlike some other options, this may _not_ be overridden by passing
|
|
2036
|
+
* an option to `set()`, for performance and consistency reasons.
|
|
2037
|
+
*/
|
|
2038
|
+
onInsert?: Inserter<K, V>;
|
|
2039
|
+
/**
|
|
2040
|
+
* The same as {@link OptionsBase.dispose}, but called *after* the entry
|
|
2041
|
+
* is completely removed and the cache is once again in a clean state.
|
|
2042
|
+
*
|
|
2043
|
+
* It is safe to add an item right back into the cache at this point.
|
|
2044
|
+
* However, note that it is *very* easy to inadvertently create infinite
|
|
2045
|
+
* recursion this way.
|
|
2046
|
+
*/
|
|
2047
|
+
disposeAfter?: Disposer<K, V>;
|
|
2048
|
+
/**
|
|
2049
|
+
* Set to true to suppress calling the
|
|
2050
|
+
* {@link OptionsBase.dispose} function if the entry key is
|
|
2051
|
+
* still accessible within the cache.
|
|
2052
|
+
*
|
|
2053
|
+
* This may be overridden by passing an options object to
|
|
2054
|
+
* {@link LRUCache#set}.
|
|
2055
|
+
*
|
|
2056
|
+
* Only relevant if `dispose` or `disposeAfter` are set.
|
|
2057
|
+
*/
|
|
2058
|
+
noDisposeOnSet?: boolean;
|
|
2059
|
+
/**
|
|
2060
|
+
* Boolean flag to tell the cache to not update the TTL when setting a new
|
|
2061
|
+
* value for an existing key (ie, when updating a value rather than
|
|
2062
|
+
* inserting a new value). Note that the TTL value is _always_ set (if
|
|
2063
|
+
* provided) when adding a new entry into the cache.
|
|
2064
|
+
*
|
|
2065
|
+
* Has no effect if a {@link OptionsBase.ttl} is not set.
|
|
2066
|
+
*
|
|
2067
|
+
* May be passed as an option to {@link LRUCache#set}.
|
|
2068
|
+
*/
|
|
2069
|
+
noUpdateTTL?: boolean;
|
|
2070
|
+
/**
|
|
2071
|
+
* Set to a positive integer to track the sizes of items added to the
|
|
2072
|
+
* cache, and automatically evict items in order to stay below this size.
|
|
2073
|
+
* Note that this may result in fewer than `max` items being stored.
|
|
2074
|
+
*
|
|
2075
|
+
* Attempting to add an item to the cache whose calculated size is greater
|
|
2076
|
+
* that this amount will be a no-op. The item will not be cached, and no
|
|
2077
|
+
* other items will be evicted.
|
|
2078
|
+
*
|
|
2079
|
+
* Optional, must be a positive integer if provided.
|
|
2080
|
+
*
|
|
2081
|
+
* Sets `maxEntrySize` to the same value, unless a different value is
|
|
2082
|
+
* provided for `maxEntrySize`.
|
|
2083
|
+
*
|
|
2084
|
+
* At least one of `max`, `maxSize`, or `TTL` is required. This must be a
|
|
2085
|
+
* positive integer if set.
|
|
2086
|
+
*
|
|
2087
|
+
* Even if size tracking is enabled, **it is strongly recommended to set a
|
|
2088
|
+
* `max` to prevent unbounded growth of the cache.**
|
|
2089
|
+
*
|
|
2090
|
+
* Note also that size tracking can negatively impact performance,
|
|
2091
|
+
* though for most cases, only minimally.
|
|
2092
|
+
*/
|
|
2093
|
+
maxSize?: Size;
|
|
2094
|
+
/**
|
|
2095
|
+
* The maximum allowed size for any single item in the cache.
|
|
2096
|
+
*
|
|
2097
|
+
* If a larger item is passed to {@link LRUCache#set} or returned by a
|
|
2098
|
+
* {@link OptionsBase.fetchMethod} or {@link OptionsBase.memoMethod}, then
|
|
2099
|
+
* it will not be stored in the cache.
|
|
2100
|
+
*
|
|
2101
|
+
* Attempting to add an item whose calculated size is greater than
|
|
2102
|
+
* this amount will not cache the item or evict any old items, but
|
|
2103
|
+
* WILL delete an existing value if one is already present.
|
|
2104
|
+
*
|
|
2105
|
+
* Optional, must be a positive integer if provided. Defaults to
|
|
2106
|
+
* the value of `maxSize` if provided.
|
|
2107
|
+
*/
|
|
2108
|
+
maxEntrySize?: Size;
|
|
2109
|
+
/**
|
|
2110
|
+
* A function that returns a number indicating the item's size.
|
|
2111
|
+
*
|
|
2112
|
+
* Requires {@link OptionsBase.maxSize} to be set.
|
|
2113
|
+
*
|
|
2114
|
+
* If not provided, and {@link OptionsBase.maxSize} or
|
|
2115
|
+
* {@link OptionsBase.maxEntrySize} are set, then all
|
|
2116
|
+
* {@link LRUCache#set} calls **must** provide an explicit
|
|
2117
|
+
* {@link SetOptions.size} or sizeCalculation param.
|
|
2118
|
+
*/
|
|
2119
|
+
sizeCalculation?: SizeCalculator<K, V>;
|
|
2120
|
+
/**
|
|
2121
|
+
* Method that provides the implementation for {@link LRUCache#fetch}
|
|
2122
|
+
*
|
|
2123
|
+
* ```ts
|
|
2124
|
+
* fetchMethod(key, staleValue, { signal, options, context })
|
|
2125
|
+
* ```
|
|
2126
|
+
*
|
|
2127
|
+
* If `fetchMethod` is not provided, then `cache.fetch(key)` is equivalent
|
|
2128
|
+
* to `Promise.resolve(cache.get(key))`.
|
|
2129
|
+
*
|
|
2130
|
+
* If at any time, `signal.aborted` is set to `true`, or if the
|
|
2131
|
+
* `signal.onabort` method is called, or if it emits an `'abort'` event
|
|
2132
|
+
* which you can listen to with `addEventListener`, then that means that
|
|
2133
|
+
* the fetch should be abandoned. This may be passed along to async
|
|
2134
|
+
* functions aware of AbortController/AbortSignal behavior.
|
|
2135
|
+
*
|
|
2136
|
+
* The `fetchMethod` should **only** return `undefined` or a Promise
|
|
2137
|
+
* resolving to `undefined` if the AbortController signaled an `abort`
|
|
2138
|
+
* event. In all other cases, it should return or resolve to a value
|
|
2139
|
+
* suitable for adding to the cache.
|
|
2140
|
+
*
|
|
2141
|
+
* The `options` object is a union of the options that may be provided to
|
|
2142
|
+
* `set()` and `get()`. If they are modified, then that will result in
|
|
2143
|
+
* modifying the settings to `cache.set()` when the value is resolved, and
|
|
2144
|
+
* in the case of
|
|
2145
|
+
* {@link OptionsBase.noDeleteOnFetchRejection} and
|
|
2146
|
+
* {@link OptionsBase.allowStaleOnFetchRejection}, the handling of
|
|
2147
|
+
* `fetchMethod` failures.
|
|
2148
|
+
*
|
|
2149
|
+
* For example, a DNS cache may update the TTL based on the value returned
|
|
2150
|
+
* from a remote DNS server by changing `options.ttl` in the `fetchMethod`.
|
|
2151
|
+
*/
|
|
2152
|
+
fetchMethod?: Fetcher<K, V, FC>;
|
|
2153
|
+
/**
|
|
2154
|
+
* Method that provides the implementation for {@link LRUCache#memo}
|
|
2155
|
+
*/
|
|
2156
|
+
memoMethod?: Memoizer<K, V, FC>;
|
|
2157
|
+
/**
|
|
2158
|
+
* Set to true to suppress the deletion of stale data when a
|
|
2159
|
+
* {@link OptionsBase.fetchMethod} returns a rejected promise.
|
|
2160
|
+
*/
|
|
2161
|
+
noDeleteOnFetchRejection?: boolean;
|
|
2162
|
+
/**
|
|
2163
|
+
* Do not delete stale items when they are retrieved with
|
|
2164
|
+
* {@link LRUCache#get}.
|
|
2165
|
+
*
|
|
2166
|
+
* Note that the `get` return value will still be `undefined`
|
|
2167
|
+
* unless {@link OptionsBase.allowStale} is true.
|
|
2168
|
+
*
|
|
2169
|
+
* When using time-expiring entries with `ttl`, by default stale
|
|
2170
|
+
* items will be removed from the cache when the key is accessed
|
|
2171
|
+
* with `cache.get()`.
|
|
2172
|
+
*
|
|
2173
|
+
* Setting this option will cause stale items to remain in the cache, until
|
|
2174
|
+
* they are explicitly deleted with `cache.delete(key)`, or retrieved with
|
|
2175
|
+
* `noDeleteOnStaleGet` set to `false`.
|
|
2176
|
+
*
|
|
2177
|
+
* This may be overridden by passing an options object to `cache.get()`.
|
|
2178
|
+
*
|
|
2179
|
+
* Only relevant if a ttl is used.
|
|
2180
|
+
*/
|
|
2181
|
+
noDeleteOnStaleGet?: boolean;
|
|
2182
|
+
/**
|
|
2183
|
+
* Set to true to allow returning stale data when a
|
|
2184
|
+
* {@link OptionsBase.fetchMethod} throws an error or returns a rejected
|
|
2185
|
+
* promise.
|
|
2186
|
+
*
|
|
2187
|
+
* This differs from using {@link OptionsBase.allowStale} in that stale
|
|
2188
|
+
* data will ONLY be returned in the case that the {@link LRUCache#fetch}
|
|
2189
|
+
* fails, not any other times.
|
|
2190
|
+
*
|
|
2191
|
+
* If a `fetchMethod` fails, and there is no stale value available, the
|
|
2192
|
+
* `fetch()` will resolve to `undefined`. Ie, all `fetchMethod` errors are
|
|
2193
|
+
* suppressed.
|
|
2194
|
+
*
|
|
2195
|
+
* Implies `noDeleteOnFetchRejection`.
|
|
2196
|
+
*
|
|
2197
|
+
* This may be set in calls to `fetch()`, or defaulted on the constructor,
|
|
2198
|
+
* or overridden by modifying the options object in the `fetchMethod`.
|
|
2199
|
+
*/
|
|
2200
|
+
allowStaleOnFetchRejection?: boolean;
|
|
2201
|
+
/**
|
|
2202
|
+
* Set to true to return a stale value from the cache when the
|
|
2203
|
+
* `AbortSignal` passed to the {@link OptionsBase.fetchMethod} dispatches
|
|
2204
|
+
* an `'abort'` event, whether user-triggered, or due to internal cache
|
|
2205
|
+
* behavior.
|
|
2206
|
+
*
|
|
2207
|
+
* Unless {@link OptionsBase.ignoreFetchAbort} is also set, the underlying
|
|
2208
|
+
* {@link OptionsBase.fetchMethod} will still be considered canceled, and
|
|
2209
|
+
* any value it returns will be ignored and not cached.
|
|
2210
|
+
*
|
|
2211
|
+
* Caveat: since fetches are aborted when a new value is explicitly
|
|
2212
|
+
* set in the cache, this can lead to fetch returning a stale value,
|
|
2213
|
+
* since that was the fallback value _at the moment the `fetch()` was
|
|
2214
|
+
* initiated_, even though the new updated value is now present in
|
|
2215
|
+
* the cache.
|
|
2216
|
+
*
|
|
2217
|
+
* For example:
|
|
2218
|
+
*
|
|
2219
|
+
* ```ts
|
|
2220
|
+
* const cache = new LRUCache<string, any>({
|
|
2221
|
+
* ttl: 100,
|
|
2222
|
+
* fetchMethod: async (url, oldValue, { signal }) => {
|
|
2223
|
+
* const res = await fetch(url, { signal })
|
|
2224
|
+
* return await res.json()
|
|
2225
|
+
* }
|
|
2226
|
+
* })
|
|
2227
|
+
* cache.set('https://example.com/', { some: 'data' })
|
|
2228
|
+
* // 100ms go by...
|
|
2229
|
+
* const result = cache.fetch('https://example.com/')
|
|
2230
|
+
* cache.set('https://example.com/', { other: 'thing' })
|
|
2231
|
+
* console.log(await result) // { some: 'data' }
|
|
2232
|
+
* console.log(cache.get('https://example.com/')) // { other: 'thing' }
|
|
2233
|
+
* ```
|
|
2234
|
+
*/
|
|
2235
|
+
allowStaleOnFetchAbort?: boolean;
|
|
2236
|
+
/**
|
|
2237
|
+
* Set to true to ignore the `abort` event emitted by the `AbortSignal`
|
|
2238
|
+
* object passed to {@link OptionsBase.fetchMethod}, and still cache the
|
|
2239
|
+
* resulting resolution value, as long as it is not `undefined`.
|
|
2240
|
+
*
|
|
2241
|
+
* When used on its own, this means aborted {@link LRUCache#fetch} calls
|
|
2242
|
+
* are not immediately resolved or rejected when they are aborted, and
|
|
2243
|
+
* instead take the full time to await.
|
|
2244
|
+
*
|
|
2245
|
+
* When used with {@link OptionsBase.allowStaleOnFetchAbort}, aborted
|
|
2246
|
+
* {@link LRUCache#fetch} calls will resolve immediately to their stale
|
|
2247
|
+
* cached value or `undefined`, and will continue to process and eventually
|
|
2248
|
+
* update the cache when they resolve, as long as the resulting value is
|
|
2249
|
+
* not `undefined`, thus supporting a "return stale on timeout while
|
|
2250
|
+
* refreshing" mechanism by passing `AbortSignal.timeout(n)` as the signal.
|
|
2251
|
+
*
|
|
2252
|
+
* For example:
|
|
2253
|
+
*
|
|
2254
|
+
* ```ts
|
|
2255
|
+
* const c = new LRUCache({
|
|
2256
|
+
* ttl: 100,
|
|
2257
|
+
* ignoreFetchAbort: true,
|
|
2258
|
+
* allowStaleOnFetchAbort: true,
|
|
2259
|
+
* fetchMethod: async (key, oldValue, { signal }) => {
|
|
2260
|
+
* // note: do NOT pass the signal to fetch()!
|
|
2261
|
+
* // let's say this fetch can take a long time.
|
|
2262
|
+
* const res = await fetch(`https://slow-backend-server/${key}`)
|
|
2263
|
+
* return await res.json()
|
|
2264
|
+
* },
|
|
2265
|
+
* })
|
|
2266
|
+
*
|
|
2267
|
+
* // this will return the stale value after 100ms, while still
|
|
2268
|
+
* // updating in the background for next time.
|
|
2269
|
+
* const val = await c.fetch('key', { signal: AbortSignal.timeout(100) })
|
|
2270
|
+
* ```
|
|
2271
|
+
*
|
|
2272
|
+
* **Note**: regardless of this setting, an `abort` event _is still
|
|
2273
|
+
* emitted on the `AbortSignal` object_, so may result in invalid results
|
|
2274
|
+
* when passed to other underlying APIs that use AbortSignals.
|
|
2275
|
+
*
|
|
2276
|
+
* This may be overridden in the {@link OptionsBase.fetchMethod} or the
|
|
2277
|
+
* call to {@link LRUCache#fetch}.
|
|
2278
|
+
*/
|
|
2279
|
+
ignoreFetchAbort?: boolean;
|
|
2280
|
+
/**
|
|
2281
|
+
* In some cases, you may want to swap out the performance/Date object
|
|
2282
|
+
* used for TTL tracking. This should almost certainly NOT be done in
|
|
2283
|
+
* production environments!
|
|
2284
|
+
*
|
|
2285
|
+
* This value defaults to `global.performance` if it has a `now()` method,
|
|
2286
|
+
* or the `global.Date` object otherwise.
|
|
2287
|
+
*/
|
|
2288
|
+
perf?: Perf;
|
|
2289
|
+
}
|
|
2290
|
+
interface OptionsMaxLimit<K, V, FC> extends OptionsBase<K, V, FC> {
|
|
2291
|
+
max: Count;
|
|
2292
|
+
}
|
|
2293
|
+
interface OptionsTTLLimit<K, V, FC> extends OptionsBase<K, V, FC> {
|
|
2294
|
+
ttl: Milliseconds;
|
|
2295
|
+
ttlAutopurge: boolean;
|
|
2296
|
+
}
|
|
2297
|
+
interface OptionsSizeLimit<K, V, FC> extends OptionsBase<K, V, FC> {
|
|
2298
|
+
maxSize: Size;
|
|
2299
|
+
}
|
|
2300
|
+
/**
|
|
2301
|
+
* The valid safe options for the {@link LRUCache} constructor
|
|
2302
|
+
*/
|
|
2303
|
+
type Options<K, V, FC> = OptionsMaxLimit<K, V, FC> | OptionsSizeLimit<K, V, FC> | OptionsTTLLimit<K, V, FC>;
|
|
2304
|
+
/**
|
|
2305
|
+
* Entry objects used by {@link LRUCache#load} and {@link LRUCache#dump},
|
|
2306
|
+
* and returned by {@link LRUCache#info}.
|
|
2307
|
+
*/
|
|
2308
|
+
interface Entry<V> {
|
|
2309
|
+
value: V;
|
|
2310
|
+
ttl?: Milliseconds;
|
|
2311
|
+
size?: Size;
|
|
2312
|
+
start?: Milliseconds;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
/**
|
|
2316
|
+
* Default export, the thing you're using this module to get.
|
|
2317
|
+
*
|
|
2318
|
+
* The `K` and `V` types define the key and value types, respectively. The
|
|
2319
|
+
* optional `FC` type defines the type of the `context` object passed to
|
|
2320
|
+
* `cache.fetch()` and `cache.memo()`.
|
|
2321
|
+
*
|
|
2322
|
+
* Keys and values **must not** be `null` or `undefined`.
|
|
2323
|
+
*
|
|
2324
|
+
* All properties from the options object (with the exception of `max`,
|
|
2325
|
+
* `maxSize`, `fetchMethod`, `memoMethod`, `dispose` and `disposeAfter`) are
|
|
2326
|
+
* added as normal public members. (The listed options are read-only getters.)
|
|
2327
|
+
*
|
|
2328
|
+
* Changing any of these will alter the defaults for subsequent method calls.
|
|
2329
|
+
*/
|
|
2330
|
+
declare class LRUCache<K extends {}, V extends {}, FC = unknown> {
|
|
2331
|
+
#private;
|
|
2332
|
+
/**
|
|
2333
|
+
* {@link LRUCache.OptionsBase.perf}
|
|
2334
|
+
*/
|
|
2335
|
+
get perf(): Perf;
|
|
2336
|
+
/**
|
|
2337
|
+
* {@link LRUCache.OptionsBase.ttl}
|
|
2338
|
+
*/
|
|
2339
|
+
ttl: LRUCache.Milliseconds;
|
|
2340
|
+
/**
|
|
2341
|
+
* {@link LRUCache.OptionsBase.ttlResolution}
|
|
2342
|
+
*/
|
|
2343
|
+
ttlResolution: LRUCache.Milliseconds;
|
|
2344
|
+
/**
|
|
2345
|
+
* {@link LRUCache.OptionsBase.ttlAutopurge}
|
|
2346
|
+
*/
|
|
2347
|
+
ttlAutopurge: boolean;
|
|
2348
|
+
/**
|
|
2349
|
+
* {@link LRUCache.OptionsBase.updateAgeOnGet}
|
|
2350
|
+
*/
|
|
2351
|
+
updateAgeOnGet: boolean;
|
|
2352
|
+
/**
|
|
2353
|
+
* {@link LRUCache.OptionsBase.updateAgeOnHas}
|
|
2354
|
+
*/
|
|
2355
|
+
updateAgeOnHas: boolean;
|
|
2356
|
+
/**
|
|
2357
|
+
* {@link LRUCache.OptionsBase.allowStale}
|
|
2358
|
+
*/
|
|
2359
|
+
allowStale: boolean;
|
|
2360
|
+
/**
|
|
2361
|
+
* {@link LRUCache.OptionsBase.noDisposeOnSet}
|
|
2362
|
+
*/
|
|
2363
|
+
noDisposeOnSet: boolean;
|
|
2364
|
+
/**
|
|
2365
|
+
* {@link LRUCache.OptionsBase.noUpdateTTL}
|
|
2366
|
+
*/
|
|
2367
|
+
noUpdateTTL: boolean;
|
|
2368
|
+
/**
|
|
2369
|
+
* {@link LRUCache.OptionsBase.maxEntrySize}
|
|
2370
|
+
*/
|
|
2371
|
+
maxEntrySize: LRUCache.Size;
|
|
2372
|
+
/**
|
|
2373
|
+
* {@link LRUCache.OptionsBase.sizeCalculation}
|
|
2374
|
+
*/
|
|
2375
|
+
sizeCalculation?: LRUCache.SizeCalculator<K, V>;
|
|
2376
|
+
/**
|
|
2377
|
+
* {@link LRUCache.OptionsBase.noDeleteOnFetchRejection}
|
|
2378
|
+
*/
|
|
2379
|
+
noDeleteOnFetchRejection: boolean;
|
|
2380
|
+
/**
|
|
2381
|
+
* {@link LRUCache.OptionsBase.noDeleteOnStaleGet}
|
|
2382
|
+
*/
|
|
2383
|
+
noDeleteOnStaleGet: boolean;
|
|
2384
|
+
/**
|
|
2385
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort}
|
|
2386
|
+
*/
|
|
2387
|
+
allowStaleOnFetchAbort: boolean;
|
|
2388
|
+
/**
|
|
2389
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchRejection}
|
|
2390
|
+
*/
|
|
2391
|
+
allowStaleOnFetchRejection: boolean;
|
|
2392
|
+
/**
|
|
2393
|
+
* {@link LRUCache.OptionsBase.ignoreFetchAbort}
|
|
2394
|
+
*/
|
|
2395
|
+
ignoreFetchAbort: boolean;
|
|
2396
|
+
/**
|
|
2397
|
+
* Do not call this method unless you need to inspect the
|
|
2398
|
+
* inner workings of the cache. If anything returned by this
|
|
2399
|
+
* object is modified in any way, strange breakage may occur.
|
|
2400
|
+
*
|
|
2401
|
+
* These fields are private for a reason!
|
|
2402
|
+
*
|
|
2403
|
+
* @internal
|
|
2404
|
+
*/
|
|
2405
|
+
static unsafeExposeInternals<K extends {}, V extends {}, FC extends unknown = unknown>(c: LRUCache<K, V, FC>): {
|
|
2406
|
+
starts: ZeroArray | undefined;
|
|
2407
|
+
ttls: ZeroArray | undefined;
|
|
2408
|
+
autopurgeTimers: (NodeJS.Timeout | undefined)[] | undefined;
|
|
2409
|
+
sizes: ZeroArray | undefined;
|
|
2410
|
+
keyMap: Map<K, number>;
|
|
2411
|
+
keyList: (K | undefined)[];
|
|
2412
|
+
valList: (V | BackgroundFetch<V> | undefined)[];
|
|
2413
|
+
next: NumberArray;
|
|
2414
|
+
prev: NumberArray;
|
|
2415
|
+
readonly head: Index;
|
|
2416
|
+
readonly tail: Index;
|
|
2417
|
+
free: StackLike;
|
|
2418
|
+
isBackgroundFetch: (p: any) => p is BackgroundFetch<V>;
|
|
2419
|
+
backgroundFetch: (k: K, index: number | undefined, options: LRUCache.FetchOptions<K, V, FC>, context: any) => BackgroundFetch<V>;
|
|
2420
|
+
moveToTail: (index: number) => void;
|
|
2421
|
+
indexes: (options?: {
|
|
2422
|
+
allowStale: boolean;
|
|
2423
|
+
}) => Generator<Index, void, unknown>;
|
|
2424
|
+
rindexes: (options?: {
|
|
2425
|
+
allowStale: boolean;
|
|
2426
|
+
}) => Generator<Index, void, unknown>;
|
|
2427
|
+
isStale: (index: number | undefined) => boolean;
|
|
2428
|
+
};
|
|
2429
|
+
/**
|
|
2430
|
+
* {@link LRUCache.OptionsBase.max} (read-only)
|
|
2431
|
+
*/
|
|
2432
|
+
get max(): LRUCache.Count;
|
|
2433
|
+
/**
|
|
2434
|
+
* {@link LRUCache.OptionsBase.maxSize} (read-only)
|
|
2435
|
+
*/
|
|
2436
|
+
get maxSize(): LRUCache.Count;
|
|
2437
|
+
/**
|
|
2438
|
+
* The total computed size of items in the cache (read-only)
|
|
2439
|
+
*/
|
|
2440
|
+
get calculatedSize(): LRUCache.Size;
|
|
2441
|
+
/**
|
|
2442
|
+
* The number of items stored in the cache (read-only)
|
|
2443
|
+
*/
|
|
2444
|
+
get size(): LRUCache.Count;
|
|
2445
|
+
/**
|
|
2446
|
+
* {@link LRUCache.OptionsBase.fetchMethod} (read-only)
|
|
2447
|
+
*/
|
|
2448
|
+
get fetchMethod(): LRUCache.Fetcher<K, V, FC> | undefined;
|
|
2449
|
+
get memoMethod(): LRUCache.Memoizer<K, V, FC> | undefined;
|
|
2450
|
+
/**
|
|
2451
|
+
* {@link LRUCache.OptionsBase.dispose} (read-only)
|
|
2452
|
+
*/
|
|
2453
|
+
get dispose(): LRUCache.Disposer<K, V> | undefined;
|
|
2454
|
+
/**
|
|
2455
|
+
* {@link LRUCache.OptionsBase.onInsert} (read-only)
|
|
2456
|
+
*/
|
|
2457
|
+
get onInsert(): LRUCache.Inserter<K, V> | undefined;
|
|
2458
|
+
/**
|
|
2459
|
+
* {@link LRUCache.OptionsBase.disposeAfter} (read-only)
|
|
2460
|
+
*/
|
|
2461
|
+
get disposeAfter(): LRUCache.Disposer<K, V> | undefined;
|
|
2462
|
+
constructor(options: LRUCache.Options<K, V, FC> | LRUCache<K, V, FC>);
|
|
2463
|
+
/**
|
|
2464
|
+
* Return the number of ms left in the item's TTL. If item is not in cache,
|
|
2465
|
+
* returns `0`. Returns `Infinity` if item is in cache without a defined TTL.
|
|
2466
|
+
*/
|
|
2467
|
+
getRemainingTTL(key: K): number;
|
|
2468
|
+
/**
|
|
2469
|
+
* Return a generator yielding `[key, value]` pairs,
|
|
2470
|
+
* in order from most recently used to least recently used.
|
|
2471
|
+
*/
|
|
2472
|
+
entries(): Generator<[K, V], void, unknown>;
|
|
2473
|
+
/**
|
|
2474
|
+
* Inverse order version of {@link LRUCache.entries}
|
|
2475
|
+
*
|
|
2476
|
+
* Return a generator yielding `[key, value]` pairs,
|
|
2477
|
+
* in order from least recently used to most recently used.
|
|
2478
|
+
*/
|
|
2479
|
+
rentries(): Generator<(K | V)[], void, unknown>;
|
|
2480
|
+
/**
|
|
2481
|
+
* Return a generator yielding the keys in the cache,
|
|
2482
|
+
* in order from most recently used to least recently used.
|
|
2483
|
+
*/
|
|
2484
|
+
keys(): Generator<K, void, unknown>;
|
|
2485
|
+
/**
|
|
2486
|
+
* Inverse order version of {@link LRUCache.keys}
|
|
2487
|
+
*
|
|
2488
|
+
* Return a generator yielding the keys in the cache,
|
|
2489
|
+
* in order from least recently used to most recently used.
|
|
2490
|
+
*/
|
|
2491
|
+
rkeys(): Generator<K, void, unknown>;
|
|
2492
|
+
/**
|
|
2493
|
+
* Return a generator yielding the values in the cache,
|
|
2494
|
+
* in order from most recently used to least recently used.
|
|
2495
|
+
*/
|
|
2496
|
+
values(): Generator<V, void, unknown>;
|
|
2497
|
+
/**
|
|
2498
|
+
* Inverse order version of {@link LRUCache.values}
|
|
2499
|
+
*
|
|
2500
|
+
* Return a generator yielding the values in the cache,
|
|
2501
|
+
* in order from least recently used to most recently used.
|
|
2502
|
+
*/
|
|
2503
|
+
rvalues(): Generator<V | undefined, void, unknown>;
|
|
2504
|
+
/**
|
|
2505
|
+
* Iterating over the cache itself yields the same results as
|
|
2506
|
+
* {@link LRUCache.entries}
|
|
2507
|
+
*/
|
|
2508
|
+
[Symbol.iterator](): Generator<[K, V], void, unknown>;
|
|
2509
|
+
/**
|
|
2510
|
+
* A String value that is used in the creation of the default string
|
|
2511
|
+
* description of an object. Called by the built-in method
|
|
2512
|
+
* `Object.prototype.toString`.
|
|
2513
|
+
*/
|
|
2514
|
+
[Symbol.toStringTag]: string;
|
|
2515
|
+
/**
|
|
2516
|
+
* Find a value for which the supplied fn method returns a truthy value,
|
|
2517
|
+
* similar to `Array.find()`. fn is called as `fn(value, key, cache)`.
|
|
2518
|
+
*/
|
|
2519
|
+
find(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => boolean, getOptions?: LRUCache.GetOptions<K, V, FC>): V | undefined;
|
|
2520
|
+
/**
|
|
2521
|
+
* Call the supplied function on each item in the cache, in order from most
|
|
2522
|
+
* recently used to least recently used.
|
|
2523
|
+
*
|
|
2524
|
+
* `fn` is called as `fn(value, key, cache)`.
|
|
2525
|
+
*
|
|
2526
|
+
* If `thisp` is provided, function will be called in the `this`-context of
|
|
2527
|
+
* the provided object, or the cache if no `thisp` object is provided.
|
|
2528
|
+
*
|
|
2529
|
+
* Does not update age or recenty of use, or iterate over stale values.
|
|
2530
|
+
*/
|
|
2531
|
+
forEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
|
|
2532
|
+
/**
|
|
2533
|
+
* The same as {@link LRUCache.forEach} but items are iterated over in
|
|
2534
|
+
* reverse order. (ie, less recently used items are iterated over first.)
|
|
2535
|
+
*/
|
|
2536
|
+
rforEach(fn: (v: V, k: K, self: LRUCache<K, V, FC>) => any, thisp?: any): void;
|
|
2537
|
+
/**
|
|
2538
|
+
* Delete any stale entries. Returns true if anything was removed,
|
|
2539
|
+
* false otherwise.
|
|
2540
|
+
*/
|
|
2541
|
+
purgeStale(): boolean;
|
|
2542
|
+
/**
|
|
2543
|
+
* Get the extended info about a given entry, to get its value, size, and
|
|
2544
|
+
* TTL info simultaneously. Returns `undefined` if the key is not present.
|
|
2545
|
+
*
|
|
2546
|
+
* Unlike {@link LRUCache#dump}, which is designed to be portable and survive
|
|
2547
|
+
* serialization, the `start` value is always the current timestamp, and the
|
|
2548
|
+
* `ttl` is a calculated remaining time to live (negative if expired).
|
|
2549
|
+
*
|
|
2550
|
+
* Always returns stale values, if their info is found in the cache, so be
|
|
2551
|
+
* sure to check for expirations (ie, a negative {@link LRUCache.Entry#ttl})
|
|
2552
|
+
* if relevant.
|
|
2553
|
+
*/
|
|
2554
|
+
info(key: K): LRUCache.Entry<V> | undefined;
|
|
2555
|
+
/**
|
|
2556
|
+
* Return an array of [key, {@link LRUCache.Entry}] tuples which can be
|
|
2557
|
+
* passed to {@link LRUCache#load}.
|
|
2558
|
+
*
|
|
2559
|
+
* The `start` fields are calculated relative to a portable `Date.now()`
|
|
2560
|
+
* timestamp, even if `performance.now()` is available.
|
|
2561
|
+
*
|
|
2562
|
+
* Stale entries are always included in the `dump`, even if
|
|
2563
|
+
* {@link LRUCache.OptionsBase.allowStale} is false.
|
|
2564
|
+
*
|
|
2565
|
+
* Note: this returns an actual array, not a generator, so it can be more
|
|
2566
|
+
* easily passed around.
|
|
2567
|
+
*/
|
|
2568
|
+
dump(): [K, LRUCache.Entry<V>][];
|
|
2569
|
+
/**
|
|
2570
|
+
* Reset the cache and load in the items in entries in the order listed.
|
|
2571
|
+
*
|
|
2572
|
+
* The shape of the resulting cache may be different if the same options are
|
|
2573
|
+
* not used in both caches.
|
|
2574
|
+
*
|
|
2575
|
+
* The `start` fields are assumed to be calculated relative to a portable
|
|
2576
|
+
* `Date.now()` timestamp, even if `performance.now()` is available.
|
|
2577
|
+
*/
|
|
2578
|
+
load(arr: [K, LRUCache.Entry<V>][]): void;
|
|
2579
|
+
/**
|
|
2580
|
+
* Add a value to the cache.
|
|
2581
|
+
*
|
|
2582
|
+
* Note: if `undefined` is specified as a value, this is an alias for
|
|
2583
|
+
* {@link LRUCache#delete}
|
|
2584
|
+
*
|
|
2585
|
+
* Fields on the {@link LRUCache.SetOptions} options param will override
|
|
2586
|
+
* their corresponding values in the constructor options for the scope
|
|
2587
|
+
* of this single `set()` operation.
|
|
2588
|
+
*
|
|
2589
|
+
* If `start` is provided, then that will set the effective start
|
|
2590
|
+
* time for the TTL calculation. Note that this must be a previous
|
|
2591
|
+
* value of `performance.now()` if supported, or a previous value of
|
|
2592
|
+
* `Date.now()` if not.
|
|
2593
|
+
*
|
|
2594
|
+
* Options object may also include `size`, which will prevent
|
|
2595
|
+
* calling the `sizeCalculation` function and just use the specified
|
|
2596
|
+
* number if it is a positive integer, and `noDisposeOnSet` which
|
|
2597
|
+
* will prevent calling a `dispose` function in the case of
|
|
2598
|
+
* overwrites.
|
|
2599
|
+
*
|
|
2600
|
+
* If the `size` (or return value of `sizeCalculation`) for a given
|
|
2601
|
+
* entry is greater than `maxEntrySize`, then the item will not be
|
|
2602
|
+
* added to the cache.
|
|
2603
|
+
*
|
|
2604
|
+
* Will update the recency of the entry.
|
|
2605
|
+
*
|
|
2606
|
+
* If the value is `undefined`, then this is an alias for
|
|
2607
|
+
* `cache.delete(key)`. `undefined` is never stored in the cache.
|
|
2608
|
+
*/
|
|
2609
|
+
set(k: K, v: V | BackgroundFetch<V> | undefined, setOptions?: LRUCache.SetOptions<K, V, FC>): this;
|
|
2610
|
+
/**
|
|
2611
|
+
* Evict the least recently used item, returning its value or
|
|
2612
|
+
* `undefined` if cache is empty.
|
|
2613
|
+
*/
|
|
2614
|
+
pop(): V | undefined;
|
|
2615
|
+
/**
|
|
2616
|
+
* Check if a key is in the cache, without updating the recency of use.
|
|
2617
|
+
* Will return false if the item is stale, even though it is technically
|
|
2618
|
+
* in the cache.
|
|
2619
|
+
*
|
|
2620
|
+
* Check if a key is in the cache, without updating the recency of
|
|
2621
|
+
* use. Age is updated if {@link LRUCache.OptionsBase.updateAgeOnHas} is set
|
|
2622
|
+
* to `true` in either the options or the constructor.
|
|
2623
|
+
*
|
|
2624
|
+
* Will return `false` if the item is stale, even though it is technically in
|
|
2625
|
+
* the cache. The difference can be determined (if it matters) by using a
|
|
2626
|
+
* `status` argument, and inspecting the `has` field.
|
|
2627
|
+
*
|
|
2628
|
+
* Will not update item age unless
|
|
2629
|
+
* {@link LRUCache.OptionsBase.updateAgeOnHas} is set.
|
|
2630
|
+
*/
|
|
2631
|
+
has(k: K, hasOptions?: LRUCache.HasOptions<K, V, FC>): boolean;
|
|
2632
|
+
/**
|
|
2633
|
+
* Like {@link LRUCache#get} but doesn't update recency or delete stale
|
|
2634
|
+
* items.
|
|
2635
|
+
*
|
|
2636
|
+
* Returns `undefined` if the item is stale, unless
|
|
2637
|
+
* {@link LRUCache.OptionsBase.allowStale} is set.
|
|
2638
|
+
*/
|
|
2639
|
+
peek(k: K, peekOptions?: LRUCache.PeekOptions<K, V, FC>): V | undefined;
|
|
2640
|
+
/**
|
|
2641
|
+
* Make an asynchronous cached fetch using the
|
|
2642
|
+
* {@link LRUCache.OptionsBase.fetchMethod} function.
|
|
2643
|
+
*
|
|
2644
|
+
* If the value is in the cache and not stale, then the returned
|
|
2645
|
+
* Promise resolves to the value.
|
|
2646
|
+
*
|
|
2647
|
+
* If not in the cache, or beyond its TTL staleness, then
|
|
2648
|
+
* `fetchMethod(key, staleValue, { options, signal, context })` is
|
|
2649
|
+
* called, and the value returned will be added to the cache once
|
|
2650
|
+
* resolved.
|
|
2651
|
+
*
|
|
2652
|
+
* If called with `allowStale`, and an asynchronous fetch is
|
|
2653
|
+
* currently in progress to reload a stale value, then the former
|
|
2654
|
+
* stale value will be returned.
|
|
2655
|
+
*
|
|
2656
|
+
* If called with `forceRefresh`, then the cached item will be
|
|
2657
|
+
* re-fetched, even if it is not stale. However, if `allowStale` is also
|
|
2658
|
+
* set, then the old value will still be returned. This is useful
|
|
2659
|
+
* in cases where you want to force a reload of a cached value. If
|
|
2660
|
+
* a background fetch is already in progress, then `forceRefresh`
|
|
2661
|
+
* has no effect.
|
|
2662
|
+
*
|
|
2663
|
+
* If multiple fetches for the same key are issued, then they will all be
|
|
2664
|
+
* coalesced into a single call to fetchMethod.
|
|
2665
|
+
*
|
|
2666
|
+
* Note that this means that handling options such as
|
|
2667
|
+
* {@link LRUCache.OptionsBase.allowStaleOnFetchAbort},
|
|
2668
|
+
* {@link LRUCache.FetchOptions.signal},
|
|
2669
|
+
* and {@link LRUCache.OptionsBase.allowStaleOnFetchRejection} will be
|
|
2670
|
+
* determined by the FIRST fetch() call for a given key.
|
|
2671
|
+
*
|
|
2672
|
+
* This is a known (fixable) shortcoming which will be addresed on when
|
|
2673
|
+
* someone complains about it, as the fix would involve added complexity and
|
|
2674
|
+
* may not be worth the costs for this edge case.
|
|
2675
|
+
*
|
|
2676
|
+
* If {@link LRUCache.OptionsBase.fetchMethod} is not specified, then this is
|
|
2677
|
+
* effectively an alias for `Promise.resolve(cache.get(key))`.
|
|
2678
|
+
*
|
|
2679
|
+
* When the fetch method resolves to a value, if the fetch has not
|
|
2680
|
+
* been aborted due to deletion, eviction, or being overwritten,
|
|
2681
|
+
* then it is added to the cache using the options provided.
|
|
2682
|
+
*
|
|
2683
|
+
* If the key is evicted or deleted before the `fetchMethod`
|
|
2684
|
+
* resolves, then the AbortSignal passed to the `fetchMethod` will
|
|
2685
|
+
* receive an `abort` event, and the promise returned by `fetch()`
|
|
2686
|
+
* will reject with the reason for the abort.
|
|
2687
|
+
*
|
|
2688
|
+
* If a `signal` is passed to the `fetch()` call, then aborting the
|
|
2689
|
+
* signal will abort the fetch and cause the `fetch()` promise to
|
|
2690
|
+
* reject with the reason provided.
|
|
2691
|
+
*
|
|
2692
|
+
* **Setting `context`**
|
|
2693
|
+
*
|
|
2694
|
+
* If an `FC` type is set to a type other than `unknown`, `void`, or
|
|
2695
|
+
* `undefined` in the {@link LRUCache} constructor, then all
|
|
2696
|
+
* calls to `cache.fetch()` _must_ provide a `context` option. If
|
|
2697
|
+
* set to `undefined` or `void`, then calls to fetch _must not_
|
|
2698
|
+
* provide a `context` option.
|
|
2699
|
+
*
|
|
2700
|
+
* The `context` param allows you to provide arbitrary data that
|
|
2701
|
+
* might be relevant in the course of fetching the data. It is only
|
|
2702
|
+
* relevant for the course of a single `fetch()` operation, and
|
|
2703
|
+
* discarded afterwards.
|
|
2704
|
+
*
|
|
2705
|
+
* **Note: `fetch()` calls are inflight-unique**
|
|
2706
|
+
*
|
|
2707
|
+
* If you call `fetch()` multiple times with the same key value,
|
|
2708
|
+
* then every call after the first will resolve on the same
|
|
2709
|
+
* promise<sup>1</sup>,
|
|
2710
|
+
* _even if they have different settings that would otherwise change
|
|
2711
|
+
* the behavior of the fetch_, such as `noDeleteOnFetchRejection`
|
|
2712
|
+
* or `ignoreFetchAbort`.
|
|
2713
|
+
*
|
|
2714
|
+
* In most cases, this is not a problem (in fact, only fetching
|
|
2715
|
+
* something once is what you probably want, if you're caching in
|
|
2716
|
+
* the first place). If you are changing the fetch() options
|
|
2717
|
+
* dramatically between runs, there's a good chance that you might
|
|
2718
|
+
* be trying to fit divergent semantics into a single object, and
|
|
2719
|
+
* would be better off with multiple cache instances.
|
|
2720
|
+
*
|
|
2721
|
+
* **1**: Ie, they're not the "same Promise", but they resolve at
|
|
2722
|
+
* the same time, because they're both waiting on the same
|
|
2723
|
+
* underlying fetchMethod response.
|
|
2724
|
+
*/
|
|
2725
|
+
fetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<undefined | V>;
|
|
2726
|
+
fetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<undefined | V>;
|
|
2727
|
+
/**
|
|
2728
|
+
* In some cases, `cache.fetch()` may resolve to `undefined`, either because
|
|
2729
|
+
* a {@link LRUCache.OptionsBase#fetchMethod} was not provided (turning
|
|
2730
|
+
* `cache.fetch(k)` into just an async wrapper around `cache.get(k)`) or
|
|
2731
|
+
* because `ignoreFetchAbort` was specified (either to the constructor or
|
|
2732
|
+
* in the {@link LRUCache.FetchOptions}). Also, the
|
|
2733
|
+
* {@link LRUCache.OptionsBase.fetchMethod} may return `undefined` or `void`, making
|
|
2734
|
+
* the test even more complicated.
|
|
2735
|
+
*
|
|
2736
|
+
* Because inferring the cases where `undefined` might be returned are so
|
|
2737
|
+
* cumbersome, but testing for `undefined` can also be annoying, this method
|
|
2738
|
+
* can be used, which will reject if `this.fetch()` resolves to undefined.
|
|
2739
|
+
*/
|
|
2740
|
+
forceFetch(k: K, fetchOptions: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : LRUCache.FetchOptionsWithContext<K, V, FC>): Promise<V>;
|
|
2741
|
+
forceFetch(k: unknown extends FC ? K : FC extends undefined | void ? K : never, fetchOptions?: unknown extends FC ? LRUCache.FetchOptions<K, V, FC> : FC extends undefined | void ? LRUCache.FetchOptionsNoContext<K, V> : never): Promise<V>;
|
|
2742
|
+
/**
|
|
2743
|
+
* If the key is found in the cache, then this is equivalent to
|
|
2744
|
+
* {@link LRUCache#get}. If not, in the cache, then calculate the value using
|
|
2745
|
+
* the {@link LRUCache.OptionsBase.memoMethod}, and add it to the cache.
|
|
2746
|
+
*
|
|
2747
|
+
* If an `FC` type is set to a type other than `unknown`, `void`, or
|
|
2748
|
+
* `undefined` in the LRUCache constructor, then all calls to `cache.memo()`
|
|
2749
|
+
* _must_ provide a `context` option. If set to `undefined` or `void`, then
|
|
2750
|
+
* calls to memo _must not_ provide a `context` option.
|
|
2751
|
+
*
|
|
2752
|
+
* The `context` param allows you to provide arbitrary data that might be
|
|
2753
|
+
* relevant in the course of fetching the data. It is only relevant for the
|
|
2754
|
+
* course of a single `memo()` operation, and discarded afterwards.
|
|
2755
|
+
*/
|
|
2756
|
+
memo(k: K, memoOptions: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : LRUCache.MemoOptionsWithContext<K, V, FC>): V;
|
|
2757
|
+
memo(k: unknown extends FC ? K : FC extends undefined | void ? K : never, memoOptions?: unknown extends FC ? LRUCache.MemoOptions<K, V, FC> : FC extends undefined | void ? LRUCache.MemoOptionsNoContext<K, V> : never): V;
|
|
2758
|
+
/**
|
|
2759
|
+
* Return a value from the cache. Will update the recency of the cache
|
|
2760
|
+
* entry found.
|
|
2761
|
+
*
|
|
2762
|
+
* If the key is not found, get() will return `undefined`.
|
|
2763
|
+
*/
|
|
2764
|
+
get(k: K, getOptions?: LRUCache.GetOptions<K, V, FC>): V | undefined;
|
|
2765
|
+
/**
|
|
2766
|
+
* Deletes a key out of the cache.
|
|
2767
|
+
*
|
|
2768
|
+
* Returns true if the key was deleted, false otherwise.
|
|
2769
|
+
*/
|
|
2770
|
+
delete(k: K): boolean;
|
|
2771
|
+
/**
|
|
2772
|
+
* Clear the cache entirely, throwing away all values.
|
|
2773
|
+
*/
|
|
2774
|
+
clear(): void;
|
|
2775
|
+
}
|
|
2776
|
+
//#endregion
|
|
2777
|
+
//#region src/cache/file.d.ts
|
|
2778
|
+
type HashInput = string | Buffer;
|
|
2779
|
+
declare class FileCache<T extends object> {
|
|
2780
|
+
cache: LRUCache<string, T>;
|
|
2781
|
+
mtimeMap: Map<string, number>;
|
|
2782
|
+
signatureMap: Map<string, string>;
|
|
2783
|
+
constructor(max?: number);
|
|
2784
|
+
get(id: string): T | undefined;
|
|
2785
|
+
set(id: string, content: T): LRUCache<string, T, unknown>;
|
|
2786
|
+
delete(id: string): boolean;
|
|
2787
|
+
isInvalidate(id: string, options?: {
|
|
2788
|
+
content?: HashInput;
|
|
2789
|
+
checkMtime?: boolean;
|
|
2790
|
+
mtimeMs?: number;
|
|
2791
|
+
signature?: string;
|
|
2792
|
+
}): Promise<boolean>;
|
|
2793
|
+
}
|
|
2794
|
+
//#endregion
|
|
2795
|
+
//#region src/runtime/jsonPlugin.d.ts
|
|
2796
|
+
interface JsonService {
|
|
2797
|
+
read: (filepath: string) => Promise<any>;
|
|
2798
|
+
resolve: (entry: JsonResolvableEntry) => string | undefined;
|
|
2799
|
+
cache: FileCache<any>;
|
|
2800
|
+
}
|
|
2801
|
+
//#endregion
|
|
2802
|
+
//#region src/runtime/npmPlugin/service.d.ts
|
|
2803
|
+
interface NpmService {
|
|
2804
|
+
getDependenciesCacheFilePath: (key?: string) => string;
|
|
2805
|
+
readonly dependenciesCacheHash: string;
|
|
2806
|
+
isMiniprogramPackage: (pkg: PackageJson) => boolean;
|
|
2807
|
+
shouldSkipBuild: (outDir: string, isOutdated: boolean) => Promise<boolean>;
|
|
2808
|
+
writeDependenciesCache: (root?: string) => Promise<void>;
|
|
2809
|
+
readDependenciesCache: (root?: string) => Promise<any>;
|
|
2810
|
+
checkDependenciesCacheOutdate: (root?: string) => Promise<boolean>;
|
|
2811
|
+
bundleBuild: (args: {
|
|
2812
|
+
entry: InputOption;
|
|
2813
|
+
name: string;
|
|
2814
|
+
options?: NpmBuildOptions;
|
|
2815
|
+
outDir: string;
|
|
2816
|
+
}) => Promise<void>;
|
|
2817
|
+
copyBuild: (args: {
|
|
2818
|
+
from: string;
|
|
2819
|
+
to: string;
|
|
2820
|
+
name: string;
|
|
2821
|
+
}) => Promise<void>;
|
|
2822
|
+
buildPackage: (args: {
|
|
2823
|
+
dep: string;
|
|
2824
|
+
outDir: string;
|
|
2825
|
+
options?: NpmBuildOptions;
|
|
2826
|
+
isDependenciesCacheOutdate: boolean;
|
|
2827
|
+
}) => Promise<void>;
|
|
2828
|
+
getPackNpmRelationList: () => {
|
|
2829
|
+
packageJsonPath: string;
|
|
2830
|
+
miniprogramNpmDistDir: string;
|
|
2831
|
+
}[];
|
|
2832
|
+
build: (options?: NpmBuildOptions) => Promise<void>;
|
|
2833
|
+
}
|
|
2834
|
+
//#endregion
|
|
2835
|
+
//#region src/wxml/shared.d.ts
|
|
2836
|
+
interface Token {
|
|
2837
|
+
start: number;
|
|
2838
|
+
end: number;
|
|
2839
|
+
value: string;
|
|
2840
|
+
}
|
|
2841
|
+
//#endregion
|
|
2842
|
+
//#region src/wxml/scan/types.d.ts
|
|
2843
|
+
interface RemovalRange {
|
|
2844
|
+
start: number;
|
|
2845
|
+
end: number;
|
|
2846
|
+
}
|
|
2847
|
+
interface WxmlToken {
|
|
2848
|
+
components: ComponentsMap;
|
|
2849
|
+
deps: WxmlDep[];
|
|
2850
|
+
removalRanges: RemovalRange[];
|
|
2851
|
+
commentTokens: Token[];
|
|
2852
|
+
inlineWxsTokens: Token[];
|
|
2853
|
+
wxsImportNormalizeTokens: Token[];
|
|
2854
|
+
removeWxsLangAttrTokens: Token[];
|
|
2855
|
+
templateImportNormalizeTokens: Token[];
|
|
2856
|
+
scriptModuleTagTokens: Token[];
|
|
2857
|
+
eventTokens: Token[];
|
|
2858
|
+
directiveTokens?: Token[];
|
|
2859
|
+
tagNameTokens?: Token[];
|
|
2860
|
+
code: string;
|
|
2861
|
+
}
|
|
2862
|
+
//#endregion
|
|
2863
|
+
//#region src/wxml/scan/index.d.ts
|
|
2864
|
+
declare function scanWxml(wxml: string | Buffer, options?: ScanWxmlOptions): WxmlToken;
|
|
2865
|
+
type ScanWxmlResult = ReturnType<typeof scanWxml>;
|
|
2866
|
+
//#endregion
|
|
2867
|
+
//#region src/runtime/autoImport/types.d.ts
|
|
2868
|
+
interface LocalAutoImportMatch {
|
|
2869
|
+
kind: 'local';
|
|
2870
|
+
entry: ComponentEntry;
|
|
2871
|
+
value: ResolvedValue;
|
|
2872
|
+
}
|
|
2873
|
+
//#endregion
|
|
2874
|
+
//#region src/runtime/watcher/types.d.ts
|
|
2875
|
+
interface WatcherInstance {
|
|
2876
|
+
close: () => void | Promise<void>;
|
|
2877
|
+
}
|
|
2878
|
+
interface SidecarWatcher {
|
|
2879
|
+
close: () => void | Promise<void>;
|
|
2880
|
+
}
|
|
2881
|
+
//#endregion
|
|
2882
|
+
//#region src/runtime/runtimeState.d.ts
|
|
2883
|
+
interface AutoRoutesCandidateState {
|
|
2884
|
+
base: string;
|
|
2885
|
+
files: Set<string>;
|
|
2886
|
+
hasScript: boolean;
|
|
2887
|
+
hasTemplate: boolean;
|
|
2888
|
+
jsonPath?: string;
|
|
2889
|
+
}
|
|
2890
|
+
interface LibEntryState {
|
|
2891
|
+
name: string;
|
|
2892
|
+
input: string;
|
|
2893
|
+
outputBase: string;
|
|
2894
|
+
relativeBase: string;
|
|
2895
|
+
}
|
|
2896
|
+
interface RuntimeState {
|
|
2897
|
+
autoRoutes: {
|
|
2898
|
+
routes: AutoRoutes;
|
|
2899
|
+
serialized: string;
|
|
2900
|
+
moduleCode: string;
|
|
2901
|
+
typedDefinition: string;
|
|
2902
|
+
watchFiles: Set<string>;
|
|
2903
|
+
watchDirs: Set<string>;
|
|
2904
|
+
dirty: boolean;
|
|
2905
|
+
initialized: boolean;
|
|
2906
|
+
candidates: Map<string, AutoRoutesCandidateState>;
|
|
2907
|
+
needsFullRescan: boolean;
|
|
2908
|
+
loadingAppConfig: boolean;
|
|
2909
|
+
};
|
|
2910
|
+
autoImport: {
|
|
2911
|
+
registry: Map<string, LocalAutoImportMatch>;
|
|
2912
|
+
matcher?: (input: string) => boolean;
|
|
2913
|
+
matcherKey: string;
|
|
2914
|
+
};
|
|
2915
|
+
build: {
|
|
2916
|
+
queue: PQueue;
|
|
2917
|
+
npmBuilt: boolean;
|
|
2918
|
+
independent: {
|
|
2919
|
+
outputs: Map<string, RolldownOutput>;
|
|
2920
|
+
};
|
|
2921
|
+
};
|
|
2922
|
+
json: {
|
|
2923
|
+
cache: FileCache<any>;
|
|
2924
|
+
};
|
|
2925
|
+
css: {
|
|
2926
|
+
importerToDependencies: Map<string, Set<string>>;
|
|
2927
|
+
dependencyToImporters: Map<string, Set<string>>;
|
|
2928
|
+
};
|
|
2929
|
+
watcher: {
|
|
2930
|
+
rollupWatcherMap: Map<string, WatcherInstance>;
|
|
2931
|
+
sidecarWatcherMap: Map<string, SidecarWatcher>;
|
|
2932
|
+
};
|
|
2933
|
+
wxml: {
|
|
2934
|
+
depsMap: Map<string, Set<string>>;
|
|
2935
|
+
tokenMap: Map<string, ScanWxmlResult>;
|
|
2936
|
+
componentsMap: Map<string, ComponentsMap>;
|
|
2937
|
+
cache: FileCache<ScanWxmlResult>;
|
|
2938
|
+
emittedCode: Map<string, string>;
|
|
2939
|
+
};
|
|
2940
|
+
scan: {
|
|
2941
|
+
subPackageMap: Map<string, SubPackageMetaValue>;
|
|
2942
|
+
independentSubPackageMap: Map<string, SubPackageMetaValue>;
|
|
2943
|
+
appEntry?: AppEntry;
|
|
2944
|
+
pluginJson?: Plugin;
|
|
2945
|
+
pluginJsonPath?: string;
|
|
2946
|
+
isDirty: boolean;
|
|
2947
|
+
independentDirtyRoots: Set<string>;
|
|
2948
|
+
};
|
|
2949
|
+
lib: {
|
|
2950
|
+
enabled: boolean;
|
|
2951
|
+
entries: Map<string, LibEntryState>;
|
|
2952
|
+
};
|
|
2953
|
+
config: {
|
|
2954
|
+
packageInfo: PackageInfo;
|
|
2955
|
+
defineEnv: Record<string, any>;
|
|
2956
|
+
packageManager: DetectResult;
|
|
2957
|
+
options: LoadConfigResult;
|
|
2958
|
+
};
|
|
2959
|
+
}
|
|
2960
|
+
//#endregion
|
|
2961
|
+
//#region src/runtime/scanPlugin/service.d.ts
|
|
2962
|
+
interface ScanService {
|
|
2963
|
+
appEntry?: AppEntry;
|
|
2964
|
+
pluginJson?: Plugin;
|
|
2965
|
+
pluginJsonPath?: string;
|
|
2966
|
+
subPackageMap: Map<string, SubPackageMetaValue>;
|
|
2967
|
+
independentSubPackageMap: Map<string, SubPackageMetaValue>;
|
|
2968
|
+
loadAppEntry: () => Promise<AppEntry>;
|
|
2969
|
+
loadSubPackages: () => SubPackageMetaValue[];
|
|
2970
|
+
isMainPackageFileName: (fileName: string) => boolean;
|
|
2971
|
+
readonly workersOptions: App['workers'] | undefined;
|
|
2972
|
+
readonly workersDir: string | undefined;
|
|
2973
|
+
markDirty: () => void;
|
|
2974
|
+
markIndependentDirty: (root: string) => void;
|
|
2975
|
+
drainIndependentDirtyRoots: () => string[];
|
|
2976
|
+
}
|
|
2977
|
+
//#endregion
|
|
2978
|
+
//#region src/runtime/watcherPlugin.d.ts
|
|
2979
|
+
interface WatcherService {
|
|
2980
|
+
rollupWatcherMap: Map<string, WatcherInstance>;
|
|
2981
|
+
sidecarWatcherMap: Map<string, SidecarWatcher>;
|
|
2982
|
+
getRollupWatcher: (root?: string) => WatcherInstance | undefined;
|
|
2983
|
+
setRollupWatcher: (watcher: WatcherInstance, root?: string) => void;
|
|
2984
|
+
close: (root?: string) => void;
|
|
2985
|
+
closeAll: () => void;
|
|
2986
|
+
}
|
|
2987
|
+
//#endregion
|
|
2988
|
+
//#region src/runtime/webPlugin.d.ts
|
|
2989
|
+
interface WebService {
|
|
2990
|
+
readonly devServer?: ViteDevServer;
|
|
2991
|
+
isEnabled: () => boolean;
|
|
2992
|
+
startDevServer: () => Promise<ViteDevServer | undefined>;
|
|
2993
|
+
build: () => Promise<Awaited<ReturnType<typeof build>> | undefined>;
|
|
2994
|
+
close: () => Promise<void>;
|
|
2995
|
+
}
|
|
2996
|
+
//#endregion
|
|
2997
|
+
//#region src/runtime/wxmlPlugin.d.ts
|
|
2998
|
+
interface WxmlService {
|
|
2999
|
+
depsMap: Map<string, Set<string>>;
|
|
3000
|
+
tokenMap: Map<string, ScanWxmlResult>;
|
|
3001
|
+
wxmlComponentsMap: Map<string, ComponentsMap>;
|
|
3002
|
+
addDeps: (filepath: string, deps?: string[]) => Promise<void>;
|
|
3003
|
+
getAllDeps: () => Set<string>;
|
|
3004
|
+
clearAll: () => void;
|
|
3005
|
+
analyze: (wxml: string) => ScanWxmlResult;
|
|
3006
|
+
scan: (filepath: string) => Promise<ScanWxmlResult | undefined>;
|
|
3007
|
+
setWxmlComponentsMap: (absPath: string, components: ComponentsMap) => void;
|
|
3008
|
+
}
|
|
3009
|
+
//#endregion
|
|
3010
|
+
//#region src/runtime/autoImport/service/index.d.ts
|
|
3011
|
+
interface ResolverAutoImportMatch {
|
|
3012
|
+
kind: 'resolver';
|
|
3013
|
+
value: ResolvedValue;
|
|
3014
|
+
}
|
|
3015
|
+
type AutoImportMatch = LocalAutoImportMatch | ResolverAutoImportMatch;
|
|
3016
|
+
interface AutoImportService {
|
|
3017
|
+
reset: () => void;
|
|
3018
|
+
registerPotentialComponent: (filePath: string) => Promise<void>;
|
|
3019
|
+
removePotentialComponent: (filePath: string) => void;
|
|
3020
|
+
resolve: (componentName: string, importerBaseName?: string) => AutoImportMatch | undefined;
|
|
3021
|
+
filter: (id: string, meta?: SubPackageMetaValue) => boolean;
|
|
3022
|
+
getRegisteredLocalComponents: () => LocalAutoImportMatch[];
|
|
3023
|
+
awaitManifestWrites: () => Promise<void>;
|
|
3024
|
+
}
|
|
3025
|
+
//#endregion
|
|
3026
|
+
//#region src/runtime/autoRoutesPlugin/watch.d.ts
|
|
3027
|
+
type AutoRoutesFileEvent = ChangeEvent | 'rename';
|
|
3028
|
+
//#endregion
|
|
3029
|
+
//#region src/runtime/autoRoutesPlugin/service.d.ts
|
|
3030
|
+
interface AutoRoutesService {
|
|
3031
|
+
ensureFresh: () => Promise<void>;
|
|
3032
|
+
markDirty: () => void;
|
|
3033
|
+
getSnapshot: () => AutoRoutes;
|
|
3034
|
+
getReference: () => AutoRoutes;
|
|
3035
|
+
getSignature: () => string;
|
|
3036
|
+
getModuleCode: () => string;
|
|
3037
|
+
getWatchFiles: () => Iterable<string>;
|
|
3038
|
+
getWatchDirectories: () => Iterable<string>;
|
|
3039
|
+
isRouteFile: (filePath: string) => boolean;
|
|
3040
|
+
handleFileChange: (filePath: string, event?: AutoRoutesFileEvent) => Promise<void>;
|
|
3041
|
+
isInitialized: () => boolean;
|
|
3042
|
+
isEnabled: () => boolean;
|
|
3043
|
+
}
|
|
3044
|
+
//#endregion
|
|
3045
|
+
//#region src/context/CompilerContext.d.ts
|
|
3046
|
+
type BuildTarget = 'app' | 'plugin';
|
|
3047
|
+
interface CompilerContext {
|
|
3048
|
+
runtimeState: RuntimeState;
|
|
3049
|
+
configService: ConfigService;
|
|
3050
|
+
npmService: NpmService;
|
|
3051
|
+
wxmlService: WxmlService;
|
|
3052
|
+
jsonService: JsonService;
|
|
3053
|
+
watcherService: WatcherService;
|
|
3054
|
+
webService: WebService;
|
|
3055
|
+
autoImportService: AutoImportService;
|
|
3056
|
+
autoRoutesService: AutoRoutesService;
|
|
3057
|
+
buildService: BuildService;
|
|
3058
|
+
scanService: ScanService;
|
|
3059
|
+
currentBuildTarget?: BuildTarget;
|
|
3060
|
+
}
|
|
3061
|
+
//#endregion
|
|
3062
|
+
//#region src/types/plugin.d.ts
|
|
3063
|
+
interface WeappVitePluginApi {
|
|
3064
|
+
ctx: CompilerContext;
|
|
3065
|
+
}
|
|
3066
|
+
type ChangeEvent = 'create' | 'update' | 'delete';
|
|
3067
|
+
//#endregion
|
|
3068
|
+
//#region src/json.d.ts
|
|
3069
|
+
type ReturnSelf<T> = (config: T) => T;
|
|
3070
|
+
type ConfigFn<T> = T | ((ctx: CompilerContext) => T);
|
|
3071
|
+
type DefineJsonFn<T> = ReturnSelf<ConfigFn<T>>;
|
|
3072
|
+
/**
|
|
3073
|
+
* @description 定义 app.json(支持直接对象或函数形式)
|
|
3074
|
+
*/
|
|
3075
|
+
declare const defineAppJson: DefineJsonFn<App$1>;
|
|
3076
|
+
/**
|
|
3077
|
+
* @description 定义 page.json(支持直接对象或函数形式)
|
|
3078
|
+
*/
|
|
3079
|
+
declare const definePageJson: DefineJsonFn<Page$1>;
|
|
3080
|
+
/**
|
|
3081
|
+
* @description 定义 component.json(支持直接对象或函数形式)
|
|
3082
|
+
*/
|
|
3083
|
+
declare const defineComponentJson: DefineJsonFn<Component$1>;
|
|
3084
|
+
/**
|
|
3085
|
+
* @description 定义 sitemap.json(支持直接对象或函数形式)
|
|
3086
|
+
*/
|
|
3087
|
+
declare const defineSitemapJson: DefineJsonFn<Sitemap$1>;
|
|
3088
|
+
/**
|
|
3089
|
+
* @description 定义 theme.json(支持直接对象或函数形式)
|
|
3090
|
+
*/
|
|
3091
|
+
declare const defineThemeJson: DefineJsonFn<Theme$1>;
|
|
3092
|
+
//#endregion
|
|
3093
|
+
//#region src/config.d.ts
|
|
3094
|
+
/**
|
|
3095
|
+
* @description weapp-vite 的用户配置(扩展 Vite UserConfig)
|
|
3096
|
+
*/
|
|
3097
|
+
type UserConfig$1 = UserConfig & {
|
|
3098
|
+
weapp?: WeappViteConfig;
|
|
3099
|
+
};
|
|
3100
|
+
type UserConfigFnNoEnvPlain<T extends UserConfig$1 = UserConfig$1> = () => T;
|
|
3101
|
+
type UserConfigFnNoEnv<T extends UserConfig$1 = UserConfig$1> = () => T | Promise<T>;
|
|
3102
|
+
type UserConfigFnObjectPlain<T extends UserConfig$1 = UserConfig$1> = (env: ConfigEnv) => T;
|
|
3103
|
+
type UserConfigFnObject<T extends UserConfig$1 = UserConfig$1> = (env: ConfigEnv) => T;
|
|
3104
|
+
type UserConfigFnPromise<T extends UserConfig$1 = UserConfig$1> = (env: ConfigEnv) => Promise<T>;
|
|
3105
|
+
type UserConfigFn<T extends UserConfig$1 = UserConfig$1> = (env: ConfigEnv) => T | Promise<T>;
|
|
3106
|
+
type UserConfigLoose = UserConfig$1 & Record<string, any>;
|
|
3107
|
+
type UserConfigExport<T extends UserConfig$1 = UserConfig$1> = T | Promise<T> | UserConfigFnNoEnv<T> | UserConfigFnObject<T> | UserConfigFnPromise<T> | UserConfigFn<T>;
|
|
3108
|
+
declare module 'vite' {
|
|
3109
|
+
interface UserConfig {
|
|
3110
|
+
weapp?: WeappViteConfig;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
/**
|
|
3114
|
+
* @description 为 weapp-vite 配置提供类型提示与推断
|
|
3115
|
+
* @description 注意:同步回调重载需要放在 Promise/联合返回前面,
|
|
3116
|
+
* 这样 `vite.config.ts` 里对象字面量属性(如 `weapp.srcRoot`)才能保留上下文类型,
|
|
3117
|
+
* 才能在编辑器中正确显示 JSDoc 与支持跳转。
|
|
3118
|
+
*/
|
|
3119
|
+
declare function defineConfig(config: UserConfig$1): UserConfig$1;
|
|
3120
|
+
declare function defineConfig(config: Promise<UserConfig$1>): Promise<UserConfig$1>;
|
|
3121
|
+
declare function defineConfig(config: UserConfigFnNoEnvPlain): UserConfigFnNoEnvPlain;
|
|
3122
|
+
declare function defineConfig(config: UserConfigFnNoEnv): UserConfigFnNoEnv;
|
|
3123
|
+
declare function defineConfig(config: UserConfigFnObjectPlain): UserConfigFnObjectPlain;
|
|
3124
|
+
declare function defineConfig(config: UserConfigFnPromise): UserConfigFnPromise;
|
|
3125
|
+
declare function defineConfig(config: UserConfigFn): UserConfigFn;
|
|
3126
|
+
declare function defineConfig(config: UserConfigLoose): UserConfigLoose;
|
|
3127
|
+
//#endregion
|
|
3128
|
+
export { WeappDebugConfig as $, SharedChunkOverride as $t, type Ref as A, GenerateFilenamesOptions as At, BindingErrorLike as B, JsFormat as Bt, type LoadConfigOptions as C, BuildNpmPackageMeta as Ct, type MethodDefinitions$1 as D, GenerateDirsOptions as Dt, InlineConfig$1 as E, CopyOptions as Et, RolldownPlugin as F, GenerateTemplateFactory as Ft, EntryJsonFragment as G, JsonMergeStrategy as Gt, BaseEntry as H, JsonMergeContext as Ht, RolldownPluginOption as I, GenerateTemplateFileSource as It, ScanComponentItem as J, NpmMainPackageConfig as Jt, PageEntry as K, MpPlatform as Kt, RolldownWatchOptions as L, GenerateTemplateInlineSource as Lt, RolldownBuild as M, GenerateTemplate as Mt, RolldownOptions as N, GenerateTemplateContext as Nt, Plugin$1 as O, GenerateExtensionsOptions as Ot, RolldownOutput$1 as P, GenerateTemplateEntry as Pt, UserConfig$2 as Q, SharedChunkMode as Qt, type RolldownWatcher$1 as R, GenerateTemplateScope as Rt, CompilerContext as S, AlipayNpmMode as St, ConfigEnv$1 as T, CopyGlobs as Tt, ComponentEntry as U, JsonMergeFunction as Ut, AppEntry as V, JsonConfig as Vt, Entry as W, JsonMergeStage as Wt, ProjectConfig as X, ResolvedAlias as Xt, WxmlDep as Y, NpmSubPackageConfig as Yt, SubPackageMetaValue as Z, SharedChunkDynamicImports as Zt, definePageJson as _, applyWeappViteHostMeta as _n, WeappVueTemplateConfig as _t, type UserConfigFnNoEnvPlain as a, SubPackageStyleScope as an, HandleWxmlOptions as at, type ChangeEvent as b, resolveWeappViteHostMeta as bn, Alias as bt, type UserConfigFnPromise as c, WeappLibDtsOptions as cn, WeappAutoRoutesConfig as ct, type Component$1 as d, WeappLibInternalDtsOptions as dn, WeappHmrConfig as dt, SharedChunkStrategy as en, WeappViteConfig as et, Page$1 as f, WeappLibVueTscOptions as fn, WeappInjectWeapiConfig as ft, defineComponentJson as g, WeappViteRuntime as gn, WeappVueConfig as gt, defineAppJson as h, WeappViteHostMeta as hn, WeappSubPackageConfig as ht, UserConfigFnNoEnv as i, SubPackageStyleEntry as in, EnhanceWxmlOptions as it, ResolvedConfig as j, GenerateOptions as jt, PluginOption as k, GenerateFileType as kt, defineConfig as l, WeappLibEntryContext as ln, WeappAutoRoutesInclude as lt, Theme$1 as m, WEAPP_VITE_HOST_NAME as mn, WeappNpmConfig as mt, UserConfigExport as n, SubPackageStyleConfigEntry as nn, AutoImportComponentsOption as nt, UserConfigFnObject as o, WeappLibComponentJson as on, MultiPlatformConfig as ot, Sitemap$1 as p, WeappWebConfig as pn, WeappMcpConfig as pt, ComponentsMap as q, NpmBuildOptions as qt, UserConfigFn as r, SubPackageStyleConfigObject as rn, EnhanceOptions as rt, UserConfigFnObjectPlain as s, WeappLibConfig as sn, ScanWxmlOptions as st, UserConfig$1 as t, SubPackage as tn, AutoImportComponents as tt, App$1 as u, WeappLibFileName as un, WeappAutoRoutesIncludePattern as ut, defineSitemapJson as v, createWeappViteHostMeta as vn, WeappWevuConfig as vt, ComputedDefinitions$1 as w, ChunksConfig as wt, WeappVitePluginApi as x, AliasOptions as xt, defineThemeJson as y, isWeappViteHost as yn, WeappWorkerConfig as yt, ViteDevServer$1 as z, GenerateTemplatesConfig as zt };
|