rollipop 0.1.0-dev.20260424074146 → 1.0.0-alpha.21

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/plugins.d.ts DELETED
@@ -1,654 +0,0 @@
1
- import { DevWatchOptions } from "@rollipop/rolldown/experimental";
2
- import { ChalkInstance } from "chalk";
3
- import * as rolldown from "@rollipop/rolldown";
4
- import { RollupLogWithString } from "@rollipop/rolldown";
5
- import * as fastifyMiddie from "@fastify/middie";
6
- import { FastifyInstance } from "fastify";
7
- import { Emitter } from "mitt";
8
- import * as ws from "ws";
9
- import * as babel from "@babel/core";
10
- import { TopLevelFilterExpression } from "@rollipop/rolldown-pluginutils";
11
- import { TransformOptions } from "@rollipop/rolldown/utils";
12
- import * as swc from "@swc/core";
13
- //#region src/types.d.ts
14
- type MaybePromise<T> = T | Promise<T>;
15
- type NullValue<T = void> = T | undefined | null | void;
16
- interface Reporter {
17
- update(event: ReportableEvent): void;
18
- }
19
- type ReportableEvent = {
20
- type: 'bundle_build_started';
21
- } | {
22
- type: 'bundle_build_done';
23
- totalModules: number;
24
- duration: number;
25
- } | {
26
- type: 'bundle_build_failed';
27
- error: Error;
28
- } | {
29
- type: 'transform';
30
- id: string;
31
- totalModules: number | undefined;
32
- transformedModules: number;
33
- } | {
34
- type: 'watch_change';
35
- id: string;
36
- } | MetroCompatibleClientLogEvent;
37
- type MetroCompatibleClientLogEvent = {
38
- type: 'client_log';
39
- level: 'trace' | 'info' | 'warn' | 'log' | 'group' | 'groupCollapsed' | 'groupEnd' | 'debug'
40
- /**
41
- * In react-native, ReportableEvent['level'] does not defined `error` type.
42
- * But, Flipper supports the `error` type.
43
- *
44
- * @see https://github.com/facebook/flipper/blob/v0.273.0/desktop/flipper-common/src/server-types.tsx#L74
45
- */
46
- | 'error';
47
- data: any[];
48
- };
49
- //#endregion
50
- //#region src/core/types.d.ts
51
- type AsyncResult<T> = T | Promise<T>;
52
- //#endregion
53
- //#region src/common/logger.d.ts
54
- declare class Logger {
55
- private readonly scope?;
56
- private static blocked;
57
- private static queuedMessages;
58
- static Colors: {
59
- trace: ChalkInstance;
60
- debug: ChalkInstance;
61
- log: ChalkInstance;
62
- info: ChalkInstance;
63
- warn: ChalkInstance;
64
- error: ChalkInstance;
65
- };
66
- private format;
67
- private debugEnabled;
68
- static block(): void;
69
- static unblock(flush?: boolean): void;
70
- constructor(scope?: string | undefined);
71
- getFormat(): string;
72
- setFormat(format: string): void;
73
- private getTimestamp;
74
- private print;
75
- trace(...args: unknown[]): void;
76
- debug(...args: unknown[]): void;
77
- log(...args: unknown[]): void;
78
- info(...args: unknown[]): void;
79
- warn(...args: unknown[]): void;
80
- error(...args: unknown[]): void;
81
- child(scope: string): Logger;
82
- }
83
- //#endregion
84
- //#region src/server/wss/server.d.ts
85
- type WebSocketClient = ws.WebSocket & {
86
- id: number;
87
- };
88
- //#endregion
89
- //#region src/server/types.d.ts
90
- type FastifyInstance$1 = FastifyInstance & {
91
- use(fn: fastifyMiddie.Handler): FastifyInstance$1;
92
- use(route: string, fn: fastifyMiddie.Handler): FastifyInstance$1;
93
- use(routes: string[], fn: fastifyMiddie.Handler): FastifyInstance$1;
94
- };
95
- type DevServerEvents = {
96
- 'device.connected': {
97
- client: WebSocketClient;
98
- };
99
- 'device.message': {
100
- client: WebSocketClient;
101
- data: ws.RawData;
102
- };
103
- 'device.error': {
104
- client: WebSocketClient;
105
- error: Error;
106
- };
107
- 'device.disconnected': {
108
- client: WebSocketClient;
109
- };
110
- };
111
- interface Middlewares {
112
- /**
113
- * Register a middleware to the Fastify instance.
114
- *
115
- * **NOTE**: This is a wrapper of `instance.use`.
116
- */
117
- use: FastifyInstance$1['use'];
118
- }
119
- interface DevServer extends Emitter<DevServerEvents> {
120
- /**
121
- * Resolved Rollipop config.
122
- */
123
- config: ResolvedConfig;
124
- /**
125
- * The Fastify instance.
126
- */
127
- instance: FastifyInstance$1;
128
- /**
129
- * `express` and `connect` style middleware registration API.
130
- */
131
- middlewares: Middlewares;
132
- /**
133
- * The message websocket server API.
134
- */
135
- message: ws.Server & {
136
- /**
137
- * Broadcast a message to all connected devices.
138
- */
139
- broadcast: (method: string, params?: Record<string, any>) => void;
140
- };
141
- /**
142
- * The events websocket server API.
143
- */
144
- events: ws.Server & {
145
- /**
146
- * Report an event to the reporter.
147
- */
148
- reportEvent: (event: {
149
- type: string;
150
- [key: string]: unknown;
151
- }) => void;
152
- };
153
- /**
154
- * HMR websocket server API
155
- */
156
- hot: ws.Server & {
157
- send: (client: ws.WebSocket, eventName: string, payload?: unknown) => void;
158
- sendAll: (eventName: string, payload?: unknown) => void;
159
- };
160
- }
161
- //#endregion
162
- //#region src/core/plugins/context.d.ts
163
- interface PluginContext {
164
- debug: (log: RollupLogWithString) => void;
165
- info: (log: RollupLogWithString) => void;
166
- warn: (log: RollupLogWithString) => void;
167
- }
168
- //#endregion
169
- //#region src/core/plugins/types.d.ts
170
- type PluginConfig = Omit<Config, 'plugins' | 'dangerously_overrideRolldownOptions'>;
171
- type Plugin = rolldown.Plugin & {
172
- config?: PluginConfig | ((this: PluginContext, config: PluginConfig) => AsyncResult<PluginConfig | null | void>);
173
- configResolved?: (this: PluginContext, config: ResolvedConfig) => AsyncResult<void>;
174
- configureServer?: (this: PluginContext, server: DevServer) => AsyncResult<void | (() => AsyncResult<void>)>;
175
- };
176
- //#endregion
177
- //#region src/node/commands/start/setup-interactive-mode.d.ts
178
- interface InteractiveCommand {
179
- key: string;
180
- shift?: boolean;
181
- description: string | (() => string);
182
- handler: (this: InteractiveCommandContext) => void;
183
- }
184
- interface InteractiveCommandContext {
185
- server: DevServer;
186
- logger: Logger;
187
- }
188
- //#endregion
189
- //#region src/config/types.d.ts
190
- type ExperimentalConfig = NonNullable<rolldown.InputOptions['experimental']>;
191
- interface Config {
192
- /**
193
- * Defaults to current working directory.
194
- */
195
- root?: string;
196
- /**
197
- * Specifying this in config will override the default mode for both serve and build.
198
- *
199
- * Defaults to: `'development'` for serve, 'production' for build.
200
- */
201
- mode?: 'development' | 'production';
202
- /**
203
- * Defaults to: `index.js`
204
- */
205
- entry?: string;
206
- /**
207
- * Resolver configuration.
208
- */
209
- resolver?: ResolverConfig;
210
- /**
211
- * Transformer configuration.
212
- */
213
- transformer?: TransformerConfig;
214
- /**
215
- * Serializer configuration.
216
- */
217
- serializer?: SerializerConfig;
218
- /**
219
- * Watcher configuration.
220
- */
221
- watcher?: WatcherConfig;
222
- /**
223
- * Optimization configuration.
224
- */
225
- optimization?: OptimizationConfig;
226
- /**
227
- * React Native specific configuration.
228
- */
229
- reactNative?: ReactNativeConfig;
230
- /**
231
- * Terminal configuration.
232
- */
233
- terminal?: TerminalConfig;
234
- /**
235
- * Reporter configuration.
236
- */
237
- reporter?: Reporter;
238
- /**
239
- * Dev mode specific configuration. (for dev server)
240
- */
241
- devMode?: DevModeConfig;
242
- /**
243
- * Directory to load environment variables from.
244
- *
245
- * Defaults to: `root`
246
- */
247
- envDir?: string;
248
- /**
249
- * Environment variable prefix.
250
- *
251
- * Defaults to: `'ROLLIPOP_'`
252
- */
253
- envPrefix?: string;
254
- /**
255
- * Configures TypeScript configuration file resolution and usage.
256
- *
257
- * Defaults to: `true`
258
- */
259
- tsconfig?: rolldown.InputOptions['tsconfig'];
260
- /**
261
- * Whether to generate sourcemaps.
262
- *
263
- * - `false`: No sourcemap will be generated.
264
- * - `true`: A separate sourcemap file will be generated.
265
- * - `'inline'`: The sourcemap will be appended to the output file as a data URL.
266
- * - `'hidden'`: A separate sourcemap file will be generated, but the link to the sourcemap (//# sourceMappingURL comment) will not be included in the output file.
267
- *
268
- * Defaults to: `true` when in development mode, `false` otherwise.
269
- */
270
- sourcemap?: rolldown.OutputOptions['sourcemap'];
271
- /**
272
- * The base URL for the links to the sourcemap file in the output file.
273
- *
274
- * By default, relative URLs are generated. If this option is set, an absolute URL with that base URL will be generated.
275
- * This is useful when deploying source maps to a different location than your code, such as a CDN or separate debugging server.
276
- */
277
- sourcemapBaseUrl?: rolldown.OutputOptions['sourcemapBaseUrl'];
278
- /**
279
- * Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
280
- *
281
- * When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
282
- *
283
- * Defaults to: `false`
284
- */
285
- sourcemapDebugIds?: rolldown.OutputOptions['sourcemapDebugIds'];
286
- /**
287
- * Control which source files are included in the sourcemap ignore list.
288
- *
289
- * Files in the ignore list are excluded from debugger stepping and error stack traces.
290
- *
291
- * - `false`: Include no source files in the ignore list
292
- * - `true`: Include all source files in the ignore list
293
- * - `string`: Files containing this string in their path will be included in the ignore list
294
- * - `RegExp`: Files matching this regular expression will be included in the ignore list
295
- * - `function`: Custom function to determine if a source should be ignored
296
- *
297
- * :::tip Performance
298
- * Using static values (`boolean`, `string`, or `RegExp`) is significantly more performant than functions.
299
- * Calling JavaScript functions from Rust has extremely high overhead, so prefer static patterns when possible.
300
- * :::
301
- *
302
- * @example
303
- * ```js
304
- * // ✅ Preferred: Use RegExp for better performance
305
- * sourcemapIgnoreList: /node_modules/
306
- *
307
- * // ✅ Preferred: Use string pattern for better performance
308
- * sourcemapIgnoreList: "vendor"
309
- *
310
- * // ! Use sparingly: Function calls have high overhead
311
- * sourcemapIgnoreList: (source, sourcemapPath) => {
312
- * return source.includes('node_modules') || source.includes('.min.');
313
- * }
314
- * ```
315
- *
316
- * Defaults to: `/node_modules/`
317
- */
318
- sourcemapIgnoreList?: rolldown.OutputOptions['sourcemapIgnoreList'];
319
- /**
320
- * A transformation to apply to each path in a sourcemap.
321
- *
322
- * @example
323
- * ```js
324
- * export default defineConfig({
325
- * output: {
326
- * sourcemap: true,
327
- * sourcemapPathTransform: (source, sourcemapPath) => {
328
- * // Remove 'src/' prefix from all source paths
329
- * return source.replace(/^src\//, '');
330
- * },
331
- * },
332
- * });
333
- * ```
334
- */
335
- sourcemapPathTransform?: rolldown.OutputOptions['sourcemapPathTransform'];
336
- /**
337
- * Plugins to apply to the build.
338
- */
339
- plugins?: PluginOption;
340
- /**
341
- * Internal option to specify the runtime target.
342
- *
343
- * Defaults to 'hermes-v1'.
344
- */
345
- runtimeTarget?: 'hermes' | 'hermes-v1';
346
- /**
347
- * Rollipop provides default options for Rolldown, but you can override them by this option.
348
- *
349
- * **DANGEROUS**: This option is dangerous because it can break the build.
350
- */
351
- dangerously_overrideRolldownOptions?: RolldownConfig | ((config: RolldownConfig) => RolldownConfig) | ((config: RolldownConfig) => Promise<RolldownConfig>);
352
- }
353
- type PluginOption = MaybePromise<NullValue<Plugin> | {
354
- name: string;
355
- } | false | PluginOption[]>;
356
- type ResolverConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>, 'extensions'> & {
357
- /**
358
- * Defaults to: `['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json']`
359
- */
360
- sourceExtensions?: string[];
361
- /**
362
- * Defaults to: `['bmp', 'gif', 'jpg', 'jpeg', 'png', 'webp', 'avif', 'ico', 'icns', 'icxl']`
363
- */
364
- assetExtensions?: string[];
365
- /**
366
- * If `true`, resolver will resolve `native` suffixed files.
367
- *
368
- * e.g.
369
- * - **true**: `index.android` -> `index.native` -> `index`
370
- * - **false**: `index.android` -> `index`
371
- *
372
- * Defaults to: `true`
373
- */
374
- preferNativePlatform?: boolean;
375
- /**
376
- * Specifies which modules should be treated as external and not bundled.
377
- *
378
- * External modules will be left as import statements in the output.
379
- */
380
- external?: rolldown.InputOptions['external'];
381
- };
382
- type TransformerConfig = Omit<TransformOptions, 'cwd' | 'lang' | 'sourceType' | 'plugins'> & {
383
- /**
384
- * Transform SVG assets files to React components using `@svgr/core`.
385
- *
386
- * Defaults to: `true`
387
- */
388
- svg?: boolean;
389
- /**
390
- * Flow specific configuration.
391
- */
392
- flow?: FlowConfig;
393
- /**
394
- * Babel transformation configuration.
395
- */
396
- babel?: BabelTransformConfig;
397
- /**
398
- * SWC transformation configuration.
399
- */
400
- swc?: SwcTransformConfig;
401
- };
402
- type BabelTransformConfig = {
403
- rules?: TransformRule<babel.TransformOptions>[];
404
- };
405
- type SwcTransformConfig = {
406
- rules?: TransformRule<swc.Options>[];
407
- };
408
- interface TransformRule<T = unknown> {
409
- filter?: rolldown.HookFilter | TopLevelFilterExpression[];
410
- options: T | ((code: string, id: string) => T);
411
- }
412
- interface FlowConfig {
413
- /**
414
- * Filter for Flow transformation pipeline.
415
- */
416
- filter?: rolldown.HookFilter | TopLevelFilterExpression[];
417
- }
418
- interface SerializerConfig {
419
- /**
420
- * Paths to prelude files.
421
- *
422
- * Prelude files are imported in the top of the entry module.
423
- */
424
- prelude?: string[];
425
- /**
426
- * Polyfills to include in the output bundle.
427
- *
428
- * Polyfills are injected in the top of the output bundle.
429
- */
430
- polyfills?: Polyfill[];
431
- /**
432
- * A string to prepend to the bundle before `renderChunk` hook.
433
- */
434
- banner?: rolldown.OutputOptions['banner'];
435
- /**
436
- * A string to append to the bundle before `renderChunk` hook.
437
- */
438
- footer?: rolldown.OutputOptions['footer'];
439
- /**
440
- * A string to prepend to the bundle after `renderChunk` hook and minification.
441
- */
442
- postBanner?: rolldown.OutputOptions['postBanner'];
443
- /**
444
- * A string to append to the bundle after `renderChunk` hook and minification.
445
- */
446
- postFooter?: rolldown.OutputOptions['postFooter'];
447
- /**
448
- * A string to prepend inside any format-specific wrapper.
449
- */
450
- intro?: rolldown.OutputOptions['intro'];
451
- /**
452
- * A string to append inside any format-specific wrapper.
453
- */
454
- outro?: rolldown.OutputOptions['outro'];
455
- /**
456
- * When `true`, creates shim variables for missing exports instead of throwing an error.
457
- *
458
- * Defaults to: `false`
459
- */
460
- shimMissingExports?: rolldown.InputOptions['shimMissingExports'];
461
- }
462
- type Polyfill = string | PolyfillWithCode | PolyfillWithPath;
463
- type PolyfillWithCode = {
464
- type: PolyfillType;
465
- code: string;
466
- };
467
- type PolyfillWithPath = {
468
- type: PolyfillType;
469
- path: string;
470
- };
471
- type PolyfillType = 'plain' | 'iife';
472
- type OptimizationConfig = rolldown.OptimizationOptions & {
473
- /**
474
- * Controls tree-shaking (dead code elimination).
475
- *
476
- * When `false`, tree-shaking will be disabled. When `true`, it is equivalent to setting each options to the default value.
477
- *
478
- * Defaults to: `true`
479
- */
480
- treeshake?: rolldown.InputOptions['treeshake'];
481
- /**
482
- * Control code minification.
483
- *
484
- * - `true`: Enable full minification including code compression and dead code elimination
485
- * - `false`: Disable minification (default)
486
- * - `'dce-only'`: Only perform dead code elimination without code compression
487
- * - `MinifyOptions`: Fine-grained control over minification settings
488
- *
489
- * Defaults to: `false`
490
- */
491
- minify?: rolldown.OutputOptions['minify'];
492
- /**
493
- * Control whether to enable lazy barrel optimization.
494
- *
495
- * Lazy barrel optimization avoids compiling unused re-export modules in side-effect-free barrel modules,
496
- * significantly improving build performance for large codebases with many barrel modules.
497
- *
498
- * Defaults to: `false`
499
- *
500
- * @see {@link https://rolldown.rs/in-depth/lazy-barrel-optimization | Lazy Barrel Documentation}
501
- */
502
- lazyBarrel?: ExperimentalConfig['lazyBarrel'];
503
- };
504
- type WatcherConfig = DevWatchOptions;
505
- interface DevModeConfig {
506
- /**
507
- * Hot Module Replacement configurations.
508
- * This feature is only available in `development` mode.
509
- *
510
- * Defaults to `true`.
511
- */
512
- hmr?: boolean | HmrConfig;
513
- }
514
- interface HmrConfig {
515
- /**
516
- * Source code of the HMR runtime implementation.
517
- *
518
- * Defaults to: using `rollipop/hmr-runtime` as a default implementation.
519
- */
520
- runtimeImplement?: string;
521
- /**
522
- * Source code of the HMR client implementation.
523
- *
524
- * Defaults to: using `rollipop/hmr-client` as a default implementation.
525
- */
526
- clientImplement?: string;
527
- }
528
- interface ReactNativeConfig {
529
- /**
530
- * Path to React Native package.
531
- *
532
- * Defaults to: resolving `react-native` package from `projectRoot`.
533
- */
534
- reactNativePath?: string;
535
- /**
536
- * Codegen specific configuration.
537
- */
538
- codegen?: CodegenConfig;
539
- /**
540
- * Path to asset registry file.
541
- *
542
- * Defaults to: `react-native/Libraries/Image/AssetRegistry.js`
543
- */
544
- assetRegistryPath?: string | ((root: string) => MaybePromise<string>);
545
- /**
546
- * Path to HMR client file.
547
- *
548
- * Defaults to: `react-native/Libraries/Utilities/HMRClient.js`
549
- */
550
- hmrClientPath?: string | ((root: string) => MaybePromise<string>);
551
- /**
552
- * Reserved global identifiers of React Native.
553
- *
554
- * Defaults to: Global identifier list of React Native 0.83
555
- */
556
- globalIdentifiers?: string[];
557
- }
558
- interface CodegenConfig {
559
- /**
560
- * Filter for codegen transformation pipeline.
561
- */
562
- filter?: rolldown.HookFilter | TopLevelFilterExpression[];
563
- }
564
- interface TerminalConfig {
565
- /**
566
- * Status of the terminal.
567
- *
568
- * Defaults to: `process.stderr.isTTY ? 'progress' : 'compat'`
569
- */
570
- status?: 'none' | 'compat' | 'progress';
571
- /**
572
- * Extra commands to display in the interactive mode.
573
- */
574
- extraCommands?: InteractiveCommand[];
575
- }
576
- interface RolldownConfig {
577
- input?: rolldown.InputOptions;
578
- output?: rolldown.OutputOptions;
579
- }
580
- //#endregion
581
- //#region src/config/merge-config.d.ts
582
- type PluginFlattenConfig = Omit<Config, 'plugins'> & {
583
- plugins?: Plugin[];
584
- };
585
- //#endregion
586
- //#region src/config/defaults.d.ts
587
- declare function getDefaultConfig(projectRoot: string, mode?: Config['mode']): Promise<{
588
- root: string;
589
- mode: "development" | "production";
590
- entry: string;
591
- resolver: {
592
- sourceExtensions: string[];
593
- assetExtensions: string[];
594
- mainFields: string[];
595
- conditionNames: string[];
596
- preferNativePlatform: true;
597
- symlinks: true;
598
- };
599
- transformer: {
600
- svg: true;
601
- flow: {
602
- filter: {
603
- id: RegExp;
604
- code: RegExp;
605
- };
606
- };
607
- };
608
- serializer: {
609
- prelude: string[];
610
- polyfills: {
611
- type: "iife";
612
- code: string;
613
- }[];
614
- };
615
- watcher: {
616
- skipWrite: true;
617
- useDebounce: true;
618
- debounceDuration: number;
619
- };
620
- optimization: {
621
- treeshake: NonNullable<OptimizationConfig["treeshake"]>;
622
- };
623
- reactNative: {
624
- reactNativePath: string;
625
- codegen: {
626
- /**
627
- * @see {@link https://github.com/facebook/react-native/blob/v0.83.1/packages/react-native-babel-preset/src/configs/main.js#L78}
628
- */
629
- filter: {
630
- code: RegExp;
631
- };
632
- };
633
- assetRegistryPath: NonNullable<NonNullable<ReactNativeConfig>["assetRegistryPath"]>;
634
- hmrClientPath: NonNullable<NonNullable<ReactNativeConfig>["hmrClientPath"]>;
635
- globalIdentifiers: string[];
636
- };
637
- devMode: {
638
- hmr: NonNullable<DevModeConfig["hmr"]>;
639
- };
640
- reporter: Reporter;
641
- terminal: {
642
- status: "none" | "compat" | "progress" | undefined;
643
- };
644
- envDir: string;
645
- envPrefix: string;
646
- runtimeTarget: "hermes-v1";
647
- }>;
648
- type DefaultConfig = Awaited<ReturnType<typeof getDefaultConfig>>;
649
- type ResolvedConfig = DefaultConfig & PluginFlattenConfig;
650
- //#endregion
651
- //#region src/plugins/worklets.d.ts
652
- declare function worklets(): PluginOption;
653
- //#endregion
654
- export { worklets };