@rollipop/core 0.0.0 → 0.1.0-alpha.1
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/CHANGELOG.md +20 -0
- package/README.md +1 -1
- package/dist/chunk-BYW8Mqxw.js +21 -0
- package/dist/hmr-client.cjs +212 -0
- package/dist/hmr-runtime.js +157 -0
- package/dist/index.cjs +1748 -0
- package/dist/index.d.cts +550 -0
- package/dist/index.d.ts +548 -0
- package/dist/index.js +1665 -0
- package/package.json +78 -2
- package/.editorconfig +0 -10
- package/.gitattributes +0 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,550 @@
|
|
|
1
|
+
import * as rolldown_experimental0 from "rolldown/experimental";
|
|
2
|
+
import { DevOptions, DevWatchOptions, TransformOptions } from "rolldown/experimental";
|
|
3
|
+
import * as rolldown from "rolldown";
|
|
4
|
+
import { FileStorage } from "@rollipop/common";
|
|
5
|
+
|
|
6
|
+
//#region rolldown:runtime
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/types.d.ts
|
|
9
|
+
interface Reporter {
|
|
10
|
+
update(event: ReportableEvent): void;
|
|
11
|
+
}
|
|
12
|
+
type ReportableEvent = {
|
|
13
|
+
type: 'bundle_build_started';
|
|
14
|
+
} | {
|
|
15
|
+
type: 'bundle_build_done';
|
|
16
|
+
} | {
|
|
17
|
+
type: 'bundle_build_failed';
|
|
18
|
+
error: Error;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'transform';
|
|
21
|
+
id: string;
|
|
22
|
+
totalModules: number | undefined;
|
|
23
|
+
transformedModules: number;
|
|
24
|
+
} | {
|
|
25
|
+
type: 'watch_change';
|
|
26
|
+
id: string;
|
|
27
|
+
} | MetroCompatibleClientLogEvent;
|
|
28
|
+
type MetroCompatibleClientLogEvent = {
|
|
29
|
+
type: 'client_log';
|
|
30
|
+
level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug'
|
|
31
|
+
/**
|
|
32
|
+
* In react-native, ReportableEvent['level'] does not defined `error` type.
|
|
33
|
+
* But, Flipper supports the `error` type.
|
|
34
|
+
*
|
|
35
|
+
* @see https://github.com/facebook/flipper/blob/v0.273.0/desktop/flipper-common/src/server-types.tsx#L74
|
|
36
|
+
*/ | 'error';
|
|
37
|
+
data: any[];
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/config/define-config.d.ts
|
|
41
|
+
interface DefineConfigContext {
|
|
42
|
+
command?: string;
|
|
43
|
+
defaultConfig: DefaultConfig;
|
|
44
|
+
}
|
|
45
|
+
type UserConfig = Config | DynamicConfig;
|
|
46
|
+
type DynamicConfig = ((context: DefineConfigContext) => Config) | ((context: DefineConfigContext) => Promise<Config>);
|
|
47
|
+
declare function defineConfig(userConfig: UserConfig): UserConfig;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/config/load-config.d.ts
|
|
50
|
+
interface LoadConfigOptions {
|
|
51
|
+
cwd?: string;
|
|
52
|
+
configFile?: string;
|
|
53
|
+
context?: Omit<DefineConfigContext, 'defaultConfig'>;
|
|
54
|
+
}
|
|
55
|
+
declare function loadConfig(options?: LoadConfigOptions): Promise<ResolvedConfig>;
|
|
56
|
+
declare function resolvePluginConfig(baseConfig: Config, plugins: Plugin[]): Promise<Config>;
|
|
57
|
+
declare function invokePluginConfigResolved(config: ResolvedConfig, plugins: Plugin[]): Promise<void>;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/config/merge-config.d.ts
|
|
60
|
+
declare function mergeConfig(baseConfig: Config, ...overrideConfigs: Config[]): Config;
|
|
61
|
+
declare function mergeConfig(baseConfig: DefaultConfig, ...overrideConfigs: Config[]): ResolvedConfig;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/core/plugins/types.d.ts
|
|
64
|
+
type PluginConfig = Omit<Config, 'plugins' | 'dangerously_overrideRolldownOptions'>;
|
|
65
|
+
type Plugin = rolldown.Plugin & {
|
|
66
|
+
config?: PluginConfig | ((config: PluginConfig) => PluginConfig | null | void) | ((config: PluginConfig) => Promise<PluginConfig | null | void>);
|
|
67
|
+
configResolved?: (config: ResolvedConfig) => void | Promise<void>;
|
|
68
|
+
};
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/config/types.d.ts
|
|
71
|
+
interface Config {
|
|
72
|
+
/**
|
|
73
|
+
* Defaults to current working directory.
|
|
74
|
+
*/
|
|
75
|
+
root?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Defaults to: `index.js`
|
|
78
|
+
*/
|
|
79
|
+
entry?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Resolver configuration.
|
|
82
|
+
*/
|
|
83
|
+
resolver?: ResolverConfig;
|
|
84
|
+
/**
|
|
85
|
+
* Transformer configuration.
|
|
86
|
+
*/
|
|
87
|
+
transformer?: TransformerConfig;
|
|
88
|
+
/**
|
|
89
|
+
* Serializer configuration.
|
|
90
|
+
*/
|
|
91
|
+
serializer?: SerializerConfig;
|
|
92
|
+
/**
|
|
93
|
+
* Watcher configuration.
|
|
94
|
+
*/
|
|
95
|
+
watcher?: WatcherConfig;
|
|
96
|
+
/**
|
|
97
|
+
* React Native specific configuration.
|
|
98
|
+
*/
|
|
99
|
+
reactNative?: ReactNativeConfig;
|
|
100
|
+
/**
|
|
101
|
+
* Terminal configuration.
|
|
102
|
+
*/
|
|
103
|
+
terminal?: TerminalConfig;
|
|
104
|
+
/**
|
|
105
|
+
* Reporter configuration.
|
|
106
|
+
*/
|
|
107
|
+
reporter?: Reporter;
|
|
108
|
+
/**
|
|
109
|
+
* Plugins.
|
|
110
|
+
*/
|
|
111
|
+
plugins?: Plugin[];
|
|
112
|
+
/**
|
|
113
|
+
* Rollipop provides default options for Rolldown, but you can override them by this option.
|
|
114
|
+
*
|
|
115
|
+
* **DANGEROUS**: This option is dangerous because it can break the build.
|
|
116
|
+
*/
|
|
117
|
+
dangerously_overrideRolldownOptions?: RolldownConfig | ((config: RolldownConfig) => RolldownConfig) | ((config: RolldownConfig) => Promise<RolldownConfig>);
|
|
118
|
+
}
|
|
119
|
+
type ResolverConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>, 'extensions'> & {
|
|
120
|
+
/**
|
|
121
|
+
* Defaults to: `['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json']`
|
|
122
|
+
*/
|
|
123
|
+
sourceExtensions?: string[];
|
|
124
|
+
/**
|
|
125
|
+
* Defaults to: `['bmp', 'gif', 'jpg', 'jpeg', 'png', 'webp', 'avif', 'ico', 'icns', 'icxl', 'webp']`
|
|
126
|
+
*/
|
|
127
|
+
assetExtensions?: string[];
|
|
128
|
+
/**
|
|
129
|
+
* If `true`, resolver will resolve `native` suffixed files.
|
|
130
|
+
*
|
|
131
|
+
* e.g.
|
|
132
|
+
* - **true**: `index.android` -> `index.native` -> `index`
|
|
133
|
+
* - **false**: `index.android` -> `index`
|
|
134
|
+
*
|
|
135
|
+
* Defaults to: `true`
|
|
136
|
+
*/
|
|
137
|
+
preferNativePlatform?: boolean;
|
|
138
|
+
};
|
|
139
|
+
type TransformerConfig = Omit<TransformOptions, 'cwd' | 'plugins'> & {
|
|
140
|
+
/**
|
|
141
|
+
* Transform SVG assets files to React components using `@svgr/core`.
|
|
142
|
+
*
|
|
143
|
+
* Defaults to: `true`
|
|
144
|
+
*/
|
|
145
|
+
svg?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Flow specific configuration.
|
|
148
|
+
*/
|
|
149
|
+
flow?: FlowConfig;
|
|
150
|
+
};
|
|
151
|
+
interface FlowConfig {
|
|
152
|
+
/**
|
|
153
|
+
* Filter for Flow transformation pipeline.
|
|
154
|
+
*/
|
|
155
|
+
filter?: rolldown.HookFilter;
|
|
156
|
+
}
|
|
157
|
+
interface SerializerConfig {
|
|
158
|
+
/**
|
|
159
|
+
* Paths to prelude files.
|
|
160
|
+
*
|
|
161
|
+
* Prelude files are imported in the top of the entry module.
|
|
162
|
+
*/
|
|
163
|
+
prelude?: string[];
|
|
164
|
+
/**
|
|
165
|
+
* Polyfills to include in the output bundle.
|
|
166
|
+
*
|
|
167
|
+
* Polyfills are injected in the top of the output bundle.
|
|
168
|
+
*/
|
|
169
|
+
polyfills?: Polyfill[];
|
|
170
|
+
}
|
|
171
|
+
type Polyfill = string | PolyfillWithCode | PolyfillWithPath;
|
|
172
|
+
type PolyfillWithCode = {
|
|
173
|
+
type: PolyfillType;
|
|
174
|
+
code: string;
|
|
175
|
+
};
|
|
176
|
+
type PolyfillWithPath = {
|
|
177
|
+
type: PolyfillType;
|
|
178
|
+
path: string;
|
|
179
|
+
};
|
|
180
|
+
type PolyfillType = 'plain' | 'iife';
|
|
181
|
+
type WatcherConfig = DevWatchOptions;
|
|
182
|
+
interface ReactNativeConfig {
|
|
183
|
+
/**
|
|
184
|
+
* Codegen specific configuration.
|
|
185
|
+
*/
|
|
186
|
+
codegen?: CodegenConfig;
|
|
187
|
+
/**
|
|
188
|
+
* Path to asset registry file.
|
|
189
|
+
*
|
|
190
|
+
* Defaults to: `react-native/Libraries/Image/AssetRegistry.js`
|
|
191
|
+
*/
|
|
192
|
+
assetRegistryPath?: string;
|
|
193
|
+
}
|
|
194
|
+
interface CodegenConfig {
|
|
195
|
+
/**
|
|
196
|
+
* Filter for codegen transformation pipeline.
|
|
197
|
+
*/
|
|
198
|
+
filter?: rolldown.HookFilter;
|
|
199
|
+
}
|
|
200
|
+
interface TerminalConfig {
|
|
201
|
+
/**
|
|
202
|
+
* Status of the terminal.
|
|
203
|
+
*
|
|
204
|
+
* Defaults to: `process.stderr.isTTY ? 'progress' : 'compat'`
|
|
205
|
+
*/
|
|
206
|
+
status?: 'compat' | 'progress';
|
|
207
|
+
}
|
|
208
|
+
interface RolldownConfig {
|
|
209
|
+
input?: rolldown.InputOptions;
|
|
210
|
+
output?: rolldown.OutputOptions;
|
|
211
|
+
}
|
|
212
|
+
//#endregion
|
|
213
|
+
//#region src/config/defaults.d.ts
|
|
214
|
+
declare function getDefaultConfig(basePath: string): {
|
|
215
|
+
root: string;
|
|
216
|
+
entry: string;
|
|
217
|
+
resolver: {
|
|
218
|
+
sourceExtensions: string[];
|
|
219
|
+
assetExtensions: string[];
|
|
220
|
+
mainFields: string[];
|
|
221
|
+
conditionNames: string[];
|
|
222
|
+
preferNativePlatform: true;
|
|
223
|
+
};
|
|
224
|
+
transformer: {
|
|
225
|
+
svg: true;
|
|
226
|
+
flow: {
|
|
227
|
+
filter: {
|
|
228
|
+
id: RegExp;
|
|
229
|
+
code: RegExp;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
};
|
|
233
|
+
serializer: {
|
|
234
|
+
prelude: string[];
|
|
235
|
+
polyfills: {
|
|
236
|
+
type: "iife";
|
|
237
|
+
code: string;
|
|
238
|
+
}[];
|
|
239
|
+
};
|
|
240
|
+
watcher: {
|
|
241
|
+
skipWrite: true;
|
|
242
|
+
useDebounce: true;
|
|
243
|
+
debounceDuration: number;
|
|
244
|
+
};
|
|
245
|
+
reactNative: {
|
|
246
|
+
codegen: {
|
|
247
|
+
filter: {
|
|
248
|
+
code: RegExp;
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
assetRegistryPath: string;
|
|
252
|
+
};
|
|
253
|
+
terminal: {
|
|
254
|
+
status: "progress" | "compat";
|
|
255
|
+
};
|
|
256
|
+
reporter: Reporter;
|
|
257
|
+
};
|
|
258
|
+
type DefaultConfig = ReturnType<typeof getDefaultConfig>;
|
|
259
|
+
type ResolvedConfig = Config & DefaultConfig;
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/core/cache/cache.d.ts
|
|
262
|
+
interface Cache<Key$1, Input, Output = Input> {
|
|
263
|
+
get(key: Key$1): Output | null | undefined;
|
|
264
|
+
set(key: Key$1, value: Input): void;
|
|
265
|
+
clear(): void;
|
|
266
|
+
}
|
|
267
|
+
//#endregion
|
|
268
|
+
//#region src/core/cache/file-system-cache.d.ts
|
|
269
|
+
type Key = string;
|
|
270
|
+
declare class FileSystemCache implements Cache<Key, string> {
|
|
271
|
+
private readonly cacheDirectory;
|
|
272
|
+
constructor(cacheDirectory: string);
|
|
273
|
+
private ensureCacheDirectory;
|
|
274
|
+
get(key: Key): string | undefined;
|
|
275
|
+
set(key: Key, value: string): void;
|
|
276
|
+
clear(): void;
|
|
277
|
+
}
|
|
278
|
+
//#endregion
|
|
279
|
+
//#region src/core/types.d.ts
|
|
280
|
+
interface BuildOptions {
|
|
281
|
+
/**
|
|
282
|
+
* The platform to build for.
|
|
283
|
+
*/
|
|
284
|
+
platform: string;
|
|
285
|
+
/**
|
|
286
|
+
* Whether to build in development mode.
|
|
287
|
+
*
|
|
288
|
+
* Defaults to `true`.
|
|
289
|
+
*/
|
|
290
|
+
dev?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Whether to minify the bundle.
|
|
293
|
+
*
|
|
294
|
+
* Defaults to `false`.
|
|
295
|
+
*/
|
|
296
|
+
minify?: boolean;
|
|
297
|
+
/**
|
|
298
|
+
* Enable or disable the cache.
|
|
299
|
+
*
|
|
300
|
+
* Defaults to `true`.
|
|
301
|
+
*/
|
|
302
|
+
cache?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* The output file.
|
|
305
|
+
*/
|
|
306
|
+
outfile?: string;
|
|
307
|
+
/**
|
|
308
|
+
* The sourcemap file.
|
|
309
|
+
*/
|
|
310
|
+
sourcemap?: string;
|
|
311
|
+
/**
|
|
312
|
+
* The assets directory.
|
|
313
|
+
*/
|
|
314
|
+
assetsDir?: string;
|
|
315
|
+
}
|
|
316
|
+
type DevEngineOptions = DevOptions & {
|
|
317
|
+
/**
|
|
318
|
+
* The host to run the dev server on.
|
|
319
|
+
*/
|
|
320
|
+
host: string;
|
|
321
|
+
/**
|
|
322
|
+
* The port to run the dev server on.
|
|
323
|
+
*/
|
|
324
|
+
port: number;
|
|
325
|
+
};
|
|
326
|
+
interface BundlerContext {
|
|
327
|
+
id: string;
|
|
328
|
+
cache: FileSystemCache;
|
|
329
|
+
storage: FileStorage;
|
|
330
|
+
mode: BuildMode;
|
|
331
|
+
}
|
|
332
|
+
type BuildMode = 'build' | 'serve';
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/core/bundler.d.ts
|
|
335
|
+
declare class Bundler {
|
|
336
|
+
private readonly config;
|
|
337
|
+
static devEngine(config: ResolvedConfig, buildOptions: Omit<BuildOptions, 'dev' | 'outfile'>, devEngineOptions: DevEngineOptions): Promise<rolldown_experimental0.DevEngine>;
|
|
338
|
+
static createId(config: ResolvedConfig, buildOptions: BuildOptions): string;
|
|
339
|
+
private static createContext;
|
|
340
|
+
constructor(config: ResolvedConfig);
|
|
341
|
+
build(buildOptions: BuildOptions): Promise<rolldown.OutputChunk>;
|
|
342
|
+
}
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/core/plugins/react-native-plugin.d.ts
|
|
345
|
+
interface ReactNativePluginOptions {
|
|
346
|
+
platform: string;
|
|
347
|
+
dev: boolean;
|
|
348
|
+
mode: BuildMode;
|
|
349
|
+
flowFilter: rolldown.HookFilter;
|
|
350
|
+
codegenFilter: rolldown.HookFilter;
|
|
351
|
+
assetsDir?: string;
|
|
352
|
+
assetExtensions: string[];
|
|
353
|
+
assetRegistryPath: string;
|
|
354
|
+
}
|
|
355
|
+
declare function reactNativePlugin(config: ResolvedConfig, options: ReactNativePluginOptions): rolldown.Plugin[];
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/core/plugins/react-refresh-plugin.d.ts
|
|
358
|
+
interface ReactRefreshPluginOptions {
|
|
359
|
+
include?: RegExp | string;
|
|
360
|
+
exclude?: RegExp | string;
|
|
361
|
+
}
|
|
362
|
+
declare function reactRefreshPlugin(options?: ReactRefreshPluginOptions): rolldown.Plugin[];
|
|
363
|
+
interface ApplyRefreshWrapperOptions {
|
|
364
|
+
id: string;
|
|
365
|
+
hasRefresh: boolean;
|
|
366
|
+
onlyReactComponent: boolean;
|
|
367
|
+
}
|
|
368
|
+
declare function applyRefreshWrapper(s: rolldown.BindingMagicString, options: ApplyRefreshWrapperOptions): void;
|
|
369
|
+
//#endregion
|
|
370
|
+
//#region src/core/plugins/prelude-plugin.d.ts
|
|
371
|
+
interface PreludePluginOptions {
|
|
372
|
+
modulePaths: string[];
|
|
373
|
+
}
|
|
374
|
+
declare function preludePlugin(options: PreludePluginOptions): rolldown.Plugin;
|
|
375
|
+
//#endregion
|
|
376
|
+
//#region src/core/plugins/status-plugin.d.ts
|
|
377
|
+
interface StatusPluginOptions {
|
|
378
|
+
initialTotalModules?: number;
|
|
379
|
+
onStart?: () => void;
|
|
380
|
+
onEnd?: (result: StatusPluginEndResult) => void;
|
|
381
|
+
onResolve?: (id: string) => void;
|
|
382
|
+
onTransform?: (result: StatusPluginTransformResult) => void;
|
|
383
|
+
onWatchChange?: (id: string) => void;
|
|
384
|
+
}
|
|
385
|
+
interface StatusPluginTransformResult {
|
|
386
|
+
id: string;
|
|
387
|
+
totalModules: number | undefined;
|
|
388
|
+
transformedModules: number;
|
|
389
|
+
}
|
|
390
|
+
interface StatusPluginEndResult {
|
|
391
|
+
totalModules: number;
|
|
392
|
+
duration: number;
|
|
393
|
+
error: Error | undefined;
|
|
394
|
+
}
|
|
395
|
+
declare function statusPlugin(options?: StatusPluginOptions): rolldown.Plugin;
|
|
396
|
+
//#endregion
|
|
397
|
+
//#region src/core/plugins/json-plugin.d.ts
|
|
398
|
+
declare function jsonPlugin(): rolldown.Plugin;
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/core/plugins/svg-plugin.d.ts
|
|
401
|
+
interface SvgPluginOptions {
|
|
402
|
+
enabled: boolean;
|
|
403
|
+
}
|
|
404
|
+
declare function svgPlugin(options: SvgPluginOptions): rolldown.Plugin;
|
|
405
|
+
declare namespace index_d_exports {
|
|
406
|
+
export { PreludePluginOptions, ReactNativePluginOptions, ReactRefreshPluginOptions, StatusPluginEndResult, StatusPluginOptions, StatusPluginTransformResult, SvgPluginOptions, applyRefreshWrapper, jsonPlugin as json, preludePlugin as prelude, reactNativePlugin as reactNative, reactRefreshPlugin as reactRefresh, statusPlugin as status, svgPlugin as svg };
|
|
407
|
+
}
|
|
408
|
+
//#endregion
|
|
409
|
+
//#region src/core/plugins/utils/index.d.ts
|
|
410
|
+
/**
|
|
411
|
+
* Enhance a plugin to cache the result. (transform hook only)
|
|
412
|
+
*/
|
|
413
|
+
declare function cacheable(plugin: rolldown.Plugin): rolldown.Plugin<any>;
|
|
414
|
+
declare const PluginUtils: Readonly<{
|
|
415
|
+
cacheable: typeof cacheable;
|
|
416
|
+
}>;
|
|
417
|
+
declare namespace assets_d_exports {
|
|
418
|
+
export { AssetContext, AssetData, AssetDataFiltered, AssetDataWithoutFiles, AssetInfo, AssetScale, copyAssetsToDestination, getAssetPriority, getSuffixedPath, platformSuffixPattern, resolveAssetPath, resolveScaledAssets, stripSuffix };
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* **NOTE**: Type definitions are ported from `metro` implementation.
|
|
422
|
+
*
|
|
423
|
+
* @see https://github.com/facebook/metro/blob/0.81.x/packages/metro/src/Assets.js
|
|
424
|
+
*/
|
|
425
|
+
interface AssetContext {
|
|
426
|
+
platform: string;
|
|
427
|
+
preferNativePlatform: boolean;
|
|
428
|
+
}
|
|
429
|
+
interface AssetInfo {
|
|
430
|
+
files: string[];
|
|
431
|
+
hash: string;
|
|
432
|
+
name: string;
|
|
433
|
+
scales: number[];
|
|
434
|
+
type: string;
|
|
435
|
+
}
|
|
436
|
+
interface AssetDataWithoutFiles {
|
|
437
|
+
__packager_asset: boolean;
|
|
438
|
+
fileSystemLocation: string;
|
|
439
|
+
hash: string;
|
|
440
|
+
httpServerLocation: string;
|
|
441
|
+
name: string;
|
|
442
|
+
scales: AssetScale[];
|
|
443
|
+
type: string;
|
|
444
|
+
width?: number;
|
|
445
|
+
height?: number;
|
|
446
|
+
}
|
|
447
|
+
interface AssetDataFiltered {
|
|
448
|
+
__packager_asset: boolean;
|
|
449
|
+
hash: string;
|
|
450
|
+
httpServerLocation: string;
|
|
451
|
+
name: string;
|
|
452
|
+
scales: AssetScale[];
|
|
453
|
+
type: string;
|
|
454
|
+
width?: number;
|
|
455
|
+
height?: number;
|
|
456
|
+
}
|
|
457
|
+
interface AssetData extends AssetDataWithoutFiles {
|
|
458
|
+
id: string;
|
|
459
|
+
files: string[];
|
|
460
|
+
}
|
|
461
|
+
type AssetScale = 0.75 | 1 | 1.5 | 2 | 3;
|
|
462
|
+
interface ResolveScaledAssetsOptions {
|
|
463
|
+
projectRoot: string;
|
|
464
|
+
assetPath: string;
|
|
465
|
+
platform: string;
|
|
466
|
+
preferNativePlatform: boolean;
|
|
467
|
+
}
|
|
468
|
+
declare function resolveScaledAssets(options: ResolveScaledAssetsOptions): Promise<AssetData>;
|
|
469
|
+
declare function platformSuffixPattern(context: AssetContext): string;
|
|
470
|
+
declare function stripSuffix(assetPath: string, context: AssetContext): string;
|
|
471
|
+
declare function getAssetPriority(assetPath: string, context: AssetContext): 0 | 3 | 2 | 1;
|
|
472
|
+
interface GetSuffixedPathOptions {
|
|
473
|
+
scale?: AssetScale;
|
|
474
|
+
platform?: string;
|
|
475
|
+
}
|
|
476
|
+
/**
|
|
477
|
+
* add suffix to asset path
|
|
478
|
+
*
|
|
479
|
+
* ```js
|
|
480
|
+
* // assetPath input
|
|
481
|
+
* '/path/to/assets/image.png'
|
|
482
|
+
*
|
|
483
|
+
* // `platform` suffixed
|
|
484
|
+
* '/path/to/assets/image.android.png'
|
|
485
|
+
*
|
|
486
|
+
* // `scale` suffixed
|
|
487
|
+
* '/path/to/assets/image@1x.png'
|
|
488
|
+
*
|
|
489
|
+
* // both `platform` and `scale` suffixed
|
|
490
|
+
* '/path/to/assets/image@1x.android.png'
|
|
491
|
+
* ```
|
|
492
|
+
*/
|
|
493
|
+
declare function getSuffixedPath(assetPath: string, context: AssetContext, options: GetSuffixedPathOptions): string;
|
|
494
|
+
declare function resolveAssetPath(assetPath: string, context: AssetContext, scale: AssetScale): string;
|
|
495
|
+
interface CopyAssetsToDestinationOptions {
|
|
496
|
+
assets: AssetData[];
|
|
497
|
+
assetsDir: string;
|
|
498
|
+
platform: string;
|
|
499
|
+
preferNativePlatform: boolean;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* @see https://github.com/facebook/react-native/blob/0.83-stable/packages/community-cli-plugin/src/commands/bundle/assetPathUtils.js
|
|
503
|
+
*/
|
|
504
|
+
declare function copyAssetsToDestination(options: CopyAssetsToDestinationOptions): Promise<undefined>;
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/types/hmr.d.ts
|
|
507
|
+
type HMRClientLogLevel = 'trace' | 'info' | 'warn' | 'error' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug';
|
|
508
|
+
type HMRClientMessage = {
|
|
509
|
+
type: 'hmr:connected';
|
|
510
|
+
bundleEntry: string;
|
|
511
|
+
platform: string;
|
|
512
|
+
} | {
|
|
513
|
+
type: 'hmr:module-registered';
|
|
514
|
+
modules: string[];
|
|
515
|
+
} | {
|
|
516
|
+
type: 'hmr:log';
|
|
517
|
+
level: HMRClientLogLevel;
|
|
518
|
+
data: any[];
|
|
519
|
+
} | {
|
|
520
|
+
type: 'hmr:invalidate';
|
|
521
|
+
moduleId: string;
|
|
522
|
+
};
|
|
523
|
+
type HMRServerMessage = {
|
|
524
|
+
type: 'hmr:update-start';
|
|
525
|
+
} | {
|
|
526
|
+
type: 'hmr:update-done';
|
|
527
|
+
} | {
|
|
528
|
+
type: 'hmr:update';
|
|
529
|
+
code: string;
|
|
530
|
+
} | {
|
|
531
|
+
type: 'hmr:reload';
|
|
532
|
+
} | {
|
|
533
|
+
type: 'hmr:error';
|
|
534
|
+
payload: HMRServerError;
|
|
535
|
+
};
|
|
536
|
+
interface HMRServerError {
|
|
537
|
+
type: string;
|
|
538
|
+
message: string;
|
|
539
|
+
errors: {
|
|
540
|
+
description: string;
|
|
541
|
+
}[];
|
|
542
|
+
}
|
|
543
|
+
//#endregion
|
|
544
|
+
//#region src/reporter.d.ts
|
|
545
|
+
declare class TerminalReporter implements Reporter {
|
|
546
|
+
private logger;
|
|
547
|
+
update(event: ReportableEvent): void;
|
|
548
|
+
}
|
|
549
|
+
//#endregion
|
|
550
|
+
export { assets_d_exports as AssetUtils, BuildMode, BuildOptions, Bundler, BundlerContext, CodegenConfig, Config, DefaultConfig, TerminalReporter as DefaultReporter, DefineConfigContext, DevEngineOptions, DynamicConfig, FlowConfig, HMRClientLogLevel, HMRClientMessage, HMRServerError, HMRServerMessage, LoadConfigOptions, type Plugin, type PluginConfig, PluginUtils, Polyfill, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ReportableEvent, Reporter, ResolvedConfig, ResolverConfig, RolldownConfig, SerializerConfig, TerminalConfig, TransformerConfig, UserConfig, WatcherConfig, defineConfig, getDefaultConfig, invokePluginConfigResolved, loadConfig, mergeConfig, index_d_exports as plugins, resolvePluginConfig, rolldown, rolldown_experimental0 as rolldownExperimental };
|