@granite-js/plugin-core 0.1.7 → 0.1.9

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/index.d.cts CHANGED
@@ -1,84 +1,522 @@
1
- import * as _granite_js_mpack4 from "@granite-js/mpack";
2
- import { BabelConfig, BuildResult, EsbuildConfig, MetroConfig, ResolverConfig, SwcConfig } from "@granite-js/mpack";
1
+ import * as swc from "@swc/core";
2
+ import * as esbuild$1 from "esbuild";
3
+ import * as esbuild from "esbuild";
3
4
  import { HandleFunction } from "connect";
4
- import { z } from "zod";
5
+ import { FastifyPluginAsync, FastifyPluginCallback } from "fastify";
6
+ import * as babel from "@babel/core";
7
+ import * as z from "zod";
5
8
 
6
- //#region src/types/mpackConfig.d.ts
7
- declare const mpackConfigScheme: z.ZodOptional<z.ZodObject<{
8
- devServer: z.ZodDefault<z.ZodOptional<z.ZodObject<{
9
- middlewares: z.ZodDefault<z.ZodType<HandleFunction[], z.ZodTypeDef, HandleFunction[]>>;
10
- }, "strip", z.ZodTypeAny, {
11
- middlewares: HandleFunction[];
12
- }, {
13
- middlewares?: HandleFunction[] | undefined;
14
- }>>>;
15
- }, "strip", z.ZodTypeAny, {
16
- devServer: {
17
- middlewares: HandleFunction[];
9
+ //#region src/types/BuildConfig.d.ts
10
+ interface BuildConfig {
11
+ /**
12
+ * Build platform
13
+ */
14
+ platform: 'ios' | 'android';
15
+ /**
16
+ * Entry file path
17
+ */
18
+ entry: string;
19
+ /**
20
+ * Build output file path
21
+ */
22
+ outfile: string;
23
+ /**
24
+ * Source map output file path
25
+ *
26
+ * @default `${outfile}.map`
27
+ */
28
+ sourcemapOutfile?: string;
29
+ /**
30
+ * Module resolution configuration
31
+ */
32
+ resolver?: ResolverConfig;
33
+ /**
34
+ * Transformer configuration
35
+ */
36
+ transformer?: {
37
+ transformSync?: TransformSync;
38
+ transformAsync?: TransformAsync;
39
+ };
40
+ /**
41
+ * esbuild configuration
42
+ */
43
+ esbuild?: EsbuildConfig;
44
+ /**
45
+ * Custom babel configuration
46
+ */
47
+ babel?: BabelConfig;
48
+ /**
49
+ * Custom swc configuration
50
+ */
51
+ swc?: SwcConfig;
52
+ /**
53
+ * Additional data
54
+ *
55
+ * Included in the build result data, used for post-processing based on specific values
56
+ * (eg. add specific extra data in preset, and distinguish which preset the build result is from)
57
+ *
58
+ * ```js
59
+ * const result = new Bundler({
60
+ * bundlerConfig: {
61
+ * buildConfig: {
62
+ * extra: {
63
+ * reanimated: 3,
64
+ * },
65
+ * },
66
+ * },
67
+ * ...
68
+ * }).build();
69
+ *
70
+ * if (result.extra?.reanimated === 3) {
71
+ * // handle build result for reanimated v3
72
+ * }
73
+ * ```
74
+ */
75
+ extra?: any;
76
+ }
77
+ interface ResolverConfig {
78
+ /**
79
+ * Dependency alias configuration
80
+ */
81
+ alias?: AliasConfig[];
82
+ /**
83
+ * Custom module protocol configuration
84
+ */
85
+ protocols?: ProtocolConfig;
86
+ }
87
+ interface AliasConfig {
88
+ /**
89
+ * Replacement target module path
90
+ */
91
+ from: string;
92
+ /**
93
+ * Replacement module path or function that returns module path
94
+ */
95
+ to: string | ((context: {
96
+ args: esbuild$1.OnResolveArgs;
97
+ resolve: esbuild$1.PluginBuild['resolve'];
98
+ }) => string | Promise<string>);
99
+ /**
100
+ * - `false`: (default) replace even if subpath exists (`^name(?:$|/)`)
101
+ * - `true`: replace only if the target is exactly matched (`^name$`)
102
+ *
103
+ * ```js
104
+ * const config = {
105
+ * alias: [
106
+ * { from: 'react-native', to: 'react-native-0.68' },
107
+ * { from: 'react', to: 'react-17', exact: true },
108
+ * ],
109
+ * };
110
+ *
111
+ * // AS IS
112
+ * import * as RN from 'react-native';
113
+ * import 'react-native/Libraries/Core/InitializeCore';
114
+ * import React from 'react';
115
+ * import runtime from 'react/runtime';
116
+ *
117
+ * // TO BE
118
+ * import * as RN from 'react-native-0.68';
119
+ * import 'react-native-0.68/Libraries/Core/InitializeCore';
120
+ * import React from 'react-17';
121
+ * import runtime from 'react/runtime'; // exact
122
+ * ```
123
+ */
124
+ exact?: boolean;
125
+ }
126
+ /**
127
+ * Custom protocol resolve configuration
128
+ *
129
+ * This option configures to directly resolve and load modules referenced by the specified protocol
130
+ *
131
+ * ```ts
132
+ * // AS-IS
133
+ * import mod from 'custom-protocol:/path/to/module';
134
+ *
135
+ * // TO-BE
136
+ * // `custom-protocol:/path/to/module` module is handled as follows
137
+ * export default global.__import('/path/to/module');
138
+ * ```
139
+ *
140
+ * Configuration example
141
+ *
142
+ * ```ts
143
+ * {
144
+ * 'custom-protocol': {
145
+ * resolve: (args) => args.path,
146
+ * load: (args) => {
147
+ * return { loader: 'ts', contents: `export default global.__import('${args.path}')` };
148
+ * },
149
+ * },
150
+ * }
151
+ * ```
152
+ */
153
+ interface ProtocolConfig {
154
+ [name: string]: {
155
+ /**
156
+ * Module path to resolve
157
+ */
158
+ resolve?: (args: esbuild$1.OnResolveArgs) => string | Promise<string>;
159
+ /**
160
+ * Return module code based on the resolved path
161
+ */
162
+ load: (args: esbuild$1.OnLoadArgs) => esbuild$1.OnLoadResult | Promise<esbuild$1.OnLoadResult>;
163
+ };
164
+ }
165
+ interface TransformerConfig {
166
+ transformSync?: TransformSync;
167
+ transformAsync?: TransformAsync;
168
+ }
169
+ type TransformSync = (id: string, code: string) => string;
170
+ type TransformAsync = (id: string, code: string) => Promise<string>;
171
+ interface EsbuildConfig extends esbuild$1.BuildOptions {
172
+ /**
173
+ * Script path to inject at the entry point
174
+ *
175
+ * esbuild.inject option added script is not only injected into the entry-point module, but also into all modules.
176
+ * entry-point module's top level only inject code.
177
+ *
178
+ * - injected only once at the top level of the entry-point module
179
+ * - duplicate inject script is removed, reducing bundle size
180
+ *
181
+ * @see issue {@link https://github.com/evanw/esbuild/issues/475}
182
+ */
183
+ prelude?: string[];
184
+ }
185
+ interface SwcConfig {
186
+ /**
187
+ * Plugin binary(wasm) path, plugin configuration
188
+ */
189
+ plugins?: NonNullable<swc.JscConfig['experimental']>['plugins'];
190
+ }
191
+ interface BabelConfig {
192
+ /**
193
+ * List of rules for Babel transform processing
194
+ * (option to skip Babel transform only when certain conditions are met)
195
+ *
196
+ * If all rules return `false`, Babel transform is skipped
197
+ */
198
+ conditions?: Array<(code: string, path: string) => boolean>;
199
+ configFile?: string;
200
+ presets?: string[];
201
+ plugins?: (string | [string, any])[];
202
+ } //#endregion
203
+ //#region src/types/BuildResult.d.ts
204
+ interface BuildResult extends esbuild.BuildResult {
205
+ bundle: BundleData;
206
+ outfile: BuildConfig['outfile'];
207
+ sourcemapOutfile: NonNullable<BuildConfig['sourcemapOutfile']>;
208
+ platform: BuildConfig['platform'];
209
+ extra: BuildConfig['extra'];
210
+ totalModuleCount: number;
211
+ duration: number;
212
+ size: number;
213
+ }
214
+ interface BundleData {
215
+ source: esbuild.OutputFile;
216
+ sourcemap: esbuild.OutputFile;
217
+ }
218
+
219
+ //#endregion
220
+ //#region src/types/DevServerConfig.d.ts
221
+ type Middleware = FastifyPluginAsync | FastifyPluginCallback;
222
+ type MetroMiddleware = HandleFunction;
223
+ interface DevServerConfig {
224
+ middlewares?: Middleware[];
225
+ }
226
+ interface MetroDevServerConfig {
227
+ middlewares?: MetroMiddleware[];
228
+ }
229
+
230
+ //#endregion
231
+ //#region src/types/vendors/metro.d.ts
232
+ type Untyped = any;
233
+ interface PackageJson {
234
+ readonly name?: string;
235
+ readonly main?: string;
236
+ readonly exports?: string | Untyped;
237
+ }
238
+ interface PackageInfo {
239
+ readonly packageJson: PackageJson;
240
+ readonly rootPath: string;
241
+ }
242
+ type ResolveAsset = (dirPath: string, assetName: string, extension: string) => string[] | undefined;
243
+ interface ResolutionContext {
244
+ readonly assetExts: string[];
245
+ readonly allowHaste: boolean;
246
+ readonly customResolverOptions: Untyped;
247
+ readonly disableHierarchicalLookup: boolean;
248
+ readonly doesFileExist: Untyped;
249
+ readonly extraNodeModules?: {
250
+ [key: string]: string;
251
+ };
252
+ readonly getPackage: (packageJsonPath: string) => PackageJson | null;
253
+ readonly getPackageForModule: (modulePath: string) => PackageInfo | null;
254
+ readonly dependency?: any;
255
+ readonly mainFields: string[];
256
+ readonly originModulePath: string;
257
+ readonly nodeModulesPaths: string[];
258
+ readonly preferNativePlatform: boolean;
259
+ readonly resolveAsset: ResolveAsset;
260
+ readonly redirectModulePath: (modulePath: string) => string | false;
261
+ readonly resolveHasteModule: (name: string) => string | undefined;
262
+ readonly resolveHastePackage: (name: string) => string | undefined;
263
+ readonly resolveRequest?: CustomResolver;
264
+ readonly sourceExts: string[];
265
+ readonly unstable_conditionsByPlatform: {
266
+ [platform: string]: string[];
267
+ };
268
+ unstable_conditionNames: string[];
269
+ unstable_enablePackageExports: boolean;
270
+ unstable_getRealPath?: any;
271
+ unstable_logWarning: (message: string) => void;
272
+ }
273
+ interface CustomResolutionContext extends ResolutionContext {
274
+ readonly resolveRequest: CustomResolver;
275
+ }
276
+ type CustomResolver = (context: CustomResolutionContext, moduleName: string, platform: string | null) => any;
277
+ interface ResolverConfig$1 {
278
+ assetExts: string[];
279
+ assetResolutions: string[];
280
+ blacklistRE?: RegExp | RegExp[];
281
+ blockList: RegExp | RegExp[];
282
+ dependencyExtractor?: string;
283
+ disableHierarchicalLookup: boolean;
284
+ extraNodeModules: {
285
+ [name: string]: string;
286
+ };
287
+ emptyModulePath: string;
288
+ enableGlobalPackages: boolean;
289
+ hasteImplModulePath?: string;
290
+ nodeModulesPaths: string[];
291
+ platforms: string[];
292
+ resolveRequest?: CustomResolver;
293
+ resolverMainFields: string[];
294
+ sourceExts: string[];
295
+ unstable_enableSymlinks: boolean;
296
+ unstable_conditionNames: string[];
297
+ unstable_conditionsByPlatform: Readonly<{
298
+ [platform: string]: string[];
299
+ }>;
300
+ unstable_enablePackageExports: boolean;
301
+ useWatchman: boolean;
302
+ requireCycleIgnorePatterns: ReadonlyArray<RegExp>;
303
+ }
304
+ interface BundleDetails {
305
+ bundleType: string;
306
+ dev: boolean;
307
+ entryFile: string;
308
+ minify: boolean;
309
+ platform?: string;
310
+ runtimeBytecodeVersion?: number;
311
+ }
312
+ type WatcherStatus = {
313
+ type: 'watchman_slow_command';
314
+ timeElapsed: number;
315
+ command: 'watch-project' | 'query';
316
+ } | {
317
+ type: 'watchman_slow_command_complete';
318
+ timeElapsed: number;
319
+ command: 'watch-project' | 'query';
320
+ } | {
321
+ type: 'watchman_warning';
322
+ warning: unknown;
323
+ command: 'watch-project' | 'query';
324
+ };
325
+ type HealthCheckResult = {
326
+ type: 'error';
327
+ timeout: number;
328
+ error: Error;
329
+ watcher: string | null;
330
+ } | {
331
+ type: 'success';
332
+ timeout: number;
333
+ timeElapsed: number;
334
+ watcher: string | null;
335
+ } | {
336
+ type: 'timeout';
337
+ timeout: number;
338
+ watcher: string | null;
339
+ pauseReason: string | null;
340
+ };
341
+ type ReportableEvent = {
342
+ port: number;
343
+ hasReducedPerformance: boolean;
344
+ type: 'initialize_started';
345
+ } | {
346
+ type: 'initialize_failed';
347
+ port: number;
348
+ error: Error;
349
+ } | {
350
+ type: 'initialize_done';
351
+ port: number;
352
+ } | {
353
+ buildID: string;
354
+ type: 'bundle_build_done';
355
+ } | {
356
+ buildID: string;
357
+ type: 'bundle_build_failed';
358
+ } | {
359
+ type: 'bundle_save_log';
360
+ message: string;
361
+ } | {
362
+ buildID: string;
363
+ bundleDetails: BundleDetails;
364
+ isPrefetch?: boolean;
365
+ type: 'bundle_build_started';
366
+ } | {
367
+ error: Error;
368
+ type: 'bundling_error';
369
+ } | {
370
+ type: 'dep_graph_loading';
371
+ hasReducedPerformance: boolean;
372
+ } | {
373
+ type: 'dep_graph_loaded';
374
+ } | {
375
+ buildID: string;
376
+ type: 'bundle_transform_progressed';
377
+ transformedFileCount: number;
378
+ totalFileCount: number;
379
+ } | {
380
+ type: 'cache_read_error';
381
+ error: Error;
382
+ } | {
383
+ type: 'cache_write_error';
384
+ error: Error;
385
+ } | {
386
+ type: 'transform_cache_reset';
387
+ } | {
388
+ type: 'worker_stdout_chunk';
389
+ chunk: string;
390
+ } | {
391
+ type: 'worker_stderr_chunk';
392
+ chunk: string;
393
+ } | {
394
+ type: 'hmr_client_error';
395
+ error: Error;
396
+ } | {
397
+ type: 'client_log';
398
+ level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';
399
+ data: Array<unknown>;
400
+ mode: 'BRIDGE' | 'NOBRIDGE';
401
+ } | {
402
+ type: 'resolver_warning';
403
+ message: string;
404
+ } | {
405
+ type: 'server_listening';
406
+ port: number;
407
+ address: string;
408
+ family: string;
409
+ } | {
410
+ type: 'transformer_load_started';
411
+ } | {
412
+ type: 'transformer_load_done';
413
+ } | {
414
+ type: 'transformer_load_failed';
415
+ error: Error;
416
+ } | {
417
+ type: 'watcher_health_check_result';
418
+ result: HealthCheckResult;
419
+ } | {
420
+ type: 'watcher_status';
421
+ status: WatcherStatus;
422
+ };
423
+ interface MetroConfig {
424
+ readonly watchFolders?: string[];
425
+ readonly cacheStores?: any;
426
+ readonly resolver?: Partial<ResolverConfig$1>;
427
+ readonly server?: any;
428
+ readonly serializer?: object & {
429
+ getPolyfills?: () => string[];
18
430
  };
19
- }, {
20
- devServer?: {
21
- middlewares?: HandleFunction[] | undefined;
22
- } | undefined;
23
- }>>;
24
- type MpackConfig = z.infer<typeof mpackConfigScheme>;
431
+ readonly symbolicator?: any;
432
+ readonly transformer?: any;
433
+ readonly watcher?: any;
434
+ readonly reporter?: {
435
+ update: (event: ReportableEvent) => void;
436
+ };
437
+ } //#endregion
438
+ //#region src/types/MetroConfig.d.ts
439
+ interface AdditionalMetroConfig extends MetroConfig {
440
+ /**
441
+ * Partial support for some options only
442
+ *
443
+ * - `getPolyfills`
444
+ */
445
+ serializer?: MetroConfig['serializer'];
446
+ /**
447
+ * Partial support for some options only
448
+ *
449
+ * - `blockList`
450
+ */
451
+ resolver?: MetroConfig['resolver'];
452
+ reporter?: MetroConfig['reporter'];
453
+ babelConfig?: babel.TransformOptions;
454
+ transformSync?: (id: string, code: string) => string;
455
+ }
25
456
 
26
457
  //#endregion
27
- //#region src/core.d.ts
28
- type DeepPartial<T> = T extends ((...args: any[]) => any) ? T : T extends object ? { [P in keyof T]?: DeepPartial<T[P]> } : T;
458
+ //#region src/types/GranitePlugin.d.ts
29
459
  interface GranitePluginConfig {
30
460
  entryFile: string;
31
461
  cwd: string;
32
462
  appName: string;
33
463
  outdir: string;
34
464
  }
35
- interface GranitePluginDevConfig extends GranitePluginConfig {
465
+ interface GranitePluginDevHandlerArgs extends GranitePluginConfig {
36
466
  host: string;
37
467
  port: number;
38
468
  }
39
- interface GranitePluginBuildConfig extends GranitePluginConfig {
469
+ type GranitePluginPreHandlerArgs = GranitePluginConfig;
470
+ interface GranitePluginPostHandlerArgs extends GranitePluginConfig {
40
471
  buildResults: BuildResult[];
41
472
  }
42
473
  interface PluginContext {
43
474
  meta: any;
44
475
  }
476
+ type GranitePluginDevPreHandler = (this: PluginContext, args: GranitePluginDevHandlerArgs) => void | Promise<void>;
477
+ type GranitePluginDevPostHandler = (this: PluginContext, args: GranitePluginDevHandlerArgs) => void | Promise<void>;
478
+ type GranitePluginBuildPreHandler = (this: PluginContext, args: GranitePluginPreHandlerArgs) => void | Promise<void>;
479
+ type GranitePluginBuildPostHandler = (this: PluginContext, args: GranitePluginPostHandlerArgs) => void | Promise<void>;
45
480
  interface GranitePluginCore {
481
+ /**
482
+ * Plugin name
483
+ */
46
484
  name: string;
485
+ /**
486
+ * Dev handler
487
+ */
47
488
  dev?: {
48
- order: 'pre' | 'post';
49
- handler: (config: GranitePluginDevConfig) => void | Promise<void>;
489
+ order: 'pre';
490
+ handler: GranitePluginDevPreHandler;
491
+ } | {
492
+ order: 'post';
493
+ handler: GranitePluginDevPostHandler;
50
494
  };
495
+ /**
496
+ * Build handler
497
+ */
51
498
  build?: {
52
499
  order: 'pre';
53
- handler: (this: PluginContext, {
54
- appName,
55
- outdir,
56
- buildResults
57
- }: {
58
- entryFile: string;
59
- cwd: string;
60
- appName: string;
61
- outdir: string;
62
- buildResults: BuildResult[];
63
- }) => void | Promise<void>;
500
+ handler: GranitePluginBuildPreHandler;
64
501
  } | {
65
502
  order: 'post';
66
- handler: (this: PluginContext, config: GranitePluginBuildConfig) => void | Promise<void>;
67
- };
68
- transformSync?: (id: string, code: string) => string;
69
- transformAsync?: (id: string, code: string) => Promise<string>;
70
- config?: {
71
- mpack?: DeepPartial<MpackConfig>;
72
- metro?: DeepPartial<MetroConfig>;
73
- babel?: DeepPartial<BabelConfig>;
74
- esbuild?: DeepPartial<EsbuildConfig>;
75
- swc?: DeepPartial<SwcConfig>;
76
- resolver?: DeepPartial<ResolverConfig>;
503
+ handler: GranitePluginBuildPostHandler;
77
504
  };
505
+ config?: PluginConfig;
78
506
  }
79
- type GranitePlugin = GranitePluginCore | Promise<GranitePluginCore>;
507
+ type PluginConfig = Omit<PluginBuildConfig, 'platform' | 'outfile'> & {
508
+ devServer?: DevServerConfig;
509
+ metro?: PluginMetroConfig;
510
+ };
511
+ type PluginMetroConfig = Omit<AdditionalMetroConfig, 'babelConfig' | 'transformSync'> & MetroDevServerConfig;
80
512
  type PluginResolvable = GranitePlugin | GranitePluginCore | Promise<GranitePlugin> | Promise<GranitePluginCore>;
81
513
  type PluginInput = PluginResolvable | PluginInput[];
514
+ type PluginBuildConfig = Omit<BuildConfig, 'platform' | 'entry' | 'outfile'>;
515
+ type GranitePlugin = GranitePluginCore | Promise<GranitePluginCore>;
516
+
517
+ //#endregion
518
+ //#region src/createContext.d.ts
519
+ declare function createContext(): PluginContext;
82
520
 
83
521
  //#endregion
84
522
  //#region src/utils/flattenPlugins.d.ts
@@ -88,35 +526,70 @@ declare const flattenPlugins: (plugin: PluginInput) => Promise<GranitePluginCore
88
526
  //#region src/utils/resolvePlugins.d.ts
89
527
  declare function resolvePlugins(plugins: PluginInput): Promise<{
90
528
  plugins: GranitePluginCore[];
529
+ configs: PluginConfig[];
530
+ pluginHooks: {
531
+ devServer: {
532
+ preHandlers: GranitePluginDevPreHandler[];
533
+ postHandlers: GranitePluginDevPostHandler[];
534
+ };
535
+ build: {
536
+ preHandlers: GranitePluginBuildPreHandler[];
537
+ postHandlers: GranitePluginBuildPostHandler[];
538
+ };
539
+ };
540
+ }>;
541
+
542
+ //#endregion
543
+ //#region src/utils/mergeConfig.d.ts
544
+ declare function mergeConfig(base: PluginConfig, ...configs: PluginConfig[]): PluginConfig | undefined;
545
+
546
+ //#endregion
547
+ //#region src/utils/mergeBuildConfigs.d.ts
548
+ declare function mergeBuildConfigs(baseConfig: BuildConfig, ...otherConfigs: Partial<BuildConfig>[]): BuildConfig;
549
+
550
+ //#endregion
551
+ //#region src/schema/pluginConfig.d.ts
552
+ declare const pluginConfigSchema: z.ZodObject<{
553
+ cwd: z.ZodDefault<z.ZodString>;
554
+ appName: z.ZodString;
555
+ scheme: z.ZodString;
556
+ outdir: z.ZodDefault<z.ZodString>;
557
+ entryFile: z.ZodDefault<z.ZodString>;
558
+ build: z.ZodOptional<z.ZodCustom<PluginBuildConfig, PluginBuildConfig>>;
559
+ devServer: z.ZodOptional<z.ZodCustom<DevServerConfig, DevServerConfig>>;
560
+ metro: z.ZodOptional<z.ZodCustom<AdditionalMetroConfig & MetroDevServerConfig, AdditionalMetroConfig & MetroDevServerConfig>>;
561
+ plugins: z.ZodCustom<PluginInput, PluginInput>;
562
+ }, z.core.$strip>;
563
+ type GraniteConfig = z.input<typeof pluginConfigSchema>;
564
+ type ParsedGraniteConfig = z.output<typeof pluginConfigSchema>;
565
+ type CompleteGraniteConfig = Pick<ParsedGraniteConfig, 'cwd' | 'appName' | 'entryFile' | 'outdir' | 'devServer' | 'metro'> & {
566
+ build: Omit<BuildConfig, 'platform' | 'entry' | 'outfile'>;
567
+ pluginHooks: GranitePluginHooks;
568
+ };
569
+ interface GranitePluginHooks {
91
570
  devServer: {
92
- preHandlers: (((config: GranitePluginDevConfig) => void | Promise<void>) | undefined)[];
93
- postHandlers: (((config: GranitePluginDevConfig) => void | Promise<void>) | undefined)[];
571
+ preHandlers: GranitePluginDevPreHandler[];
572
+ postHandlers: GranitePluginDevPostHandler[];
94
573
  };
95
574
  build: {
96
- preHandlers: (((this: PluginContext, {
97
- appName,
98
- outdir,
99
- buildResults
100
- }: {
101
- entryFile: string;
102
- cwd: string;
103
- appName: string;
104
- outdir: string;
105
- buildResults: _granite_js_mpack4.BuildResult[];
106
- }) => void | Promise<void>) | ((this: PluginContext, config: GranitePluginBuildConfig) => void | Promise<void>) | undefined)[];
107
- postHandlers: (((this: PluginContext, {
108
- appName,
109
- outdir,
110
- buildResults
111
- }: {
112
- entryFile: string;
113
- cwd: string;
114
- appName: string;
115
- outdir: string;
116
- buildResults: _granite_js_mpack4.BuildResult[];
117
- }) => void | Promise<void>) | ((this: PluginContext, config: GranitePluginBuildConfig) => void | Promise<void>) | undefined)[];
575
+ preHandlers: GranitePluginBuildPreHandler[];
576
+ postHandlers: GranitePluginBuildPostHandler[];
118
577
  };
119
- }>;
578
+ }
579
+
580
+ //#endregion
581
+ //#region src/utils/createPluginHooksDriver.d.ts
582
+ declare function createPluginHooksDriver(config: CompleteGraniteConfig): {
583
+ devServer: {
584
+ pre: (args: Omit<GranitePluginDevHandlerArgs, keyof GranitePluginConfig>) => Promise<void>;
585
+ post: (args: Omit<GranitePluginDevHandlerArgs, keyof GranitePluginConfig>) => Promise<void>;
586
+ };
587
+ build: {
588
+ pre: () => Promise<void>;
589
+ post: (args: Omit<GranitePluginPostHandlerArgs, keyof GranitePluginConfig>) => Promise<void>;
590
+ };
591
+ };
592
+ declare function createPluginContext(): PluginContext;
120
593
 
121
594
  //#endregion
122
- export { BabelConfig, EsbuildConfig, GranitePlugin, GranitePluginBuildConfig, GranitePluginConfig, GranitePluginCore, GranitePluginDevConfig, MetroConfig, MpackConfig, PluginContext, PluginInput, PluginResolvable, ResolverConfig, SwcConfig, flattenPlugins, mpackConfigScheme, resolvePlugins };
595
+ export { AdditionalMetroConfig, AliasConfig, BabelConfig, BuildConfig, BuildResult, BundleData, CompleteGraniteConfig, DevServerConfig, EsbuildConfig, GraniteConfig, GranitePlugin, GranitePluginBuildPostHandler, GranitePluginBuildPreHandler, GranitePluginConfig, GranitePluginCore, GranitePluginDevHandlerArgs, GranitePluginDevPostHandler, GranitePluginDevPreHandler, GranitePluginHooks, GranitePluginPostHandlerArgs, GranitePluginPreHandlerArgs, MetroDevServerConfig, MetroMiddleware, Middleware, ParsedGraniteConfig, PluginBuildConfig, PluginConfig, PluginContext, PluginInput, PluginMetroConfig, PluginResolvable, ProtocolConfig, ResolverConfig, SwcConfig, TransformAsync, TransformSync, TransformerConfig, createContext, createPluginContext, createPluginHooksDriver, flattenPlugins, mergeBuildConfigs, mergeConfig, pluginConfigSchema, resolvePlugins };