rollipop 1.0.0-beta.0 → 1.0.0-beta.2

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.
Files changed (38) hide show
  1. package/README.md +4 -0
  2. package/dist/config/defaults.js +6 -4
  3. package/dist/config/index.d.ts +2 -2
  4. package/dist/config/types.d.ts +24 -7
  5. package/dist/constants.js +1 -1
  6. package/dist/core/plugins/types.d.ts +2 -1
  7. package/dist/core/rolldown.js +28 -15
  8. package/dist/events/types.d.ts +2 -1
  9. package/dist/hmr-runtime.iife.js +89 -56
  10. package/dist/index.d.ts +3 -3
  11. package/dist/internal/react-native/legacy.js +14 -0
  12. package/dist/internal/react-native/polyfills.js +28 -0
  13. package/dist/internal/react-native/public-assets.js +14 -0
  14. package/dist/internal/react-native/public.js +14 -0
  15. package/dist/internal/react-native/runtime.js +25 -0
  16. package/dist/internal/react-native.js +2 -41
  17. package/dist/node/commands/agent/index.js +1 -2
  18. package/dist/node/commands/bundle/index.js +1 -2
  19. package/dist/node/commands/start/index.js +1 -2
  20. package/dist/package.js +1 -1
  21. package/dist/rolldown-runtime-DXE2a-Yu.js +27 -0
  22. package/dist/runtime.d.ts +1 -1
  23. package/dist/runtime.js +1 -1
  24. package/dist/server/bundle.d.ts +2 -1
  25. package/dist/server/create-dev-server.js +1 -1
  26. package/dist/server/devframe/events.js +4 -1
  27. package/dist/server/devframe/index.js +31 -8
  28. package/dist/server/devframe/setup.js +1 -1
  29. package/dist/server/hot-update-store.d.ts +7 -0
  30. package/dist/server/hot-update-store.js +24 -2
  31. package/dist/server/symbolicate.js +12 -6
  32. package/dist/server/types.d.ts +5 -0
  33. package/dist/storage/file-storage.js +1 -1
  34. package/dist/types.d.ts +1 -0
  35. package/package.json +26 -23
  36. package/skills/configuration.md +1 -1
  37. package/skills/plugins.md +1 -1
  38. package/dist/rolldown-runtime-BHXq-rbM.js +0 -24
package/README.md CHANGED
@@ -1 +1,5 @@
1
1
  # rollipop
2
+
3
+ React Native build toolkit powered by Rolldown.
4
+
5
+ [Installation](https://rollipop.dev/docs/get-started/quick-start) · [Configuration](https://rollipop.dev/docs/get-started/configuration) · [CLI](https://rollipop.dev/docs/get-started/cli-commands)
@@ -2,7 +2,8 @@ import { stripFlowTypes } from "../common/transformer.js";
2
2
  import { DEFAULT_ANALYZE_FILE, DEFAULT_ANALYZE_REPORT_FILE, DEFAULT_ASSET_EXTENSIONS, DEFAULT_ENV_FILE, DEFAULT_ENV_PREFIX, DEFAULT_HMR_CLIENT_PATH, DEFAULT_RESOLVER_ALIAS_FIELDS, DEFAULT_RESOLVER_CONDITION_NAMES, DEFAULT_RESOLVER_MAIN_FIELDS, DEFAULT_RUNTIME_TARGET, DEFAULT_SOURCE_EXTENSIONS } from "../constants.js";
3
3
  import { ClientLogReporter } from "../events/builtin-reporters.js";
4
4
  import { resolvePackagePath } from "../utils/node-resolve.js";
5
- import { resolveAssetRegistryPath, resolveInitializeCorePath, resolvePolyfillScriptPaths } from "../internal/react-native.js";
5
+ import { resolveReactNativeRuntime } from "../internal/react-native/runtime.js";
6
+ import "../internal/react-native.js";
6
7
  import fs from "node:fs";
7
8
  //#region src/config/defaults.ts
8
9
  async function getDefaultConfig(projectRoot, mode) {
@@ -12,6 +13,7 @@ async function getDefaultConfig(projectRoot, mode) {
12
13
  } catch {
13
14
  throw new Error(`Could not resolve 'react-native' package path. Please check your project path.`);
14
15
  }
16
+ const runtime = resolveReactNativeRuntime(projectRoot, reactNativePath);
15
17
  return {
16
18
  root: projectRoot,
17
19
  mode: mode ?? "development",
@@ -26,8 +28,8 @@ async function getDefaultConfig(projectRoot, mode) {
26
28
  symlinks: true
27
29
  },
28
30
  transform: { swc: { native: { externalHelpers: true } } },
29
- prelude: [resolveInitializeCorePath(projectRoot)],
30
- polyfills: await Promise.all(resolvePolyfillScriptPaths(projectRoot, reactNativePath).map(async (path) => {
31
+ prelude: runtime.prelude,
32
+ polyfills: await Promise.all(runtime.polyfills.map(async (path) => {
31
33
  const code = fs.readFileSync(path, "utf-8");
32
34
  return {
33
35
  type: "iife",
@@ -38,7 +40,7 @@ async function getDefaultConfig(projectRoot, mode) {
38
40
  treeshake: true,
39
41
  reactNative: {
40
42
  reactNativePath,
41
- assetRegistryPath: resolveAssetRegistryPath(projectRoot),
43
+ assetRegistryPath: runtime.assetRegistryPath,
42
44
  hmrClientPath: DEFAULT_HMR_CLIENT_PATH
43
45
  },
44
46
  dev: {
@@ -1,7 +1,7 @@
1
1
  import { RolldownOptions, RolldownOptionsConfig, RolldownOptionsContext, RolldownOptionsFunction } from "../core/rolldown.js";
2
- import { AliasConfig, AnalyzerConfig, BabelTransformConfig, Config, DevConfig, ExperimentalConfig, HmrConfig, OptimizationConfig, OutputConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolveConfig, RollipopReactNativeFlowConfig, RollipopReactNativeSwcConfig, RollipopReactNativeWorkletsConfig, SwcTransformConfig, TransformConfig, TransformRule, WatcherConfig } from "./types.js";
2
+ import { AliasConfig, AnalyzerConfig, BabelTransformConfig, Config, DevConfig, ExperimentalConfig, FlowConfig, HmrConfig, JsxOptions, OptimizationConfig, OutputConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolveConfig, RollipopReactNativeSwcConfig as SwcConfig, RollipopReactNativeWorkletsConfig as WorkletsConfig, SwcTransformConfig, TransformConfig, TransformRule, WatcherConfig } from "./types.js";
3
3
  import { DefineConfigContext, DynamicUserConfig, UserConfig, defineConfig } from "./define-config.js";
4
4
  import { LoadConfigOptions, flattenPluginOption, invokeConfigResolved, loadConfig, resolvePluginConfig } from "./load-config.js";
5
5
  import { PluginFlattenConfig, mergeConfig } from "./merge-config.js";
6
6
  import { DefaultConfig, InternalConfig, ResolvedConfig, getDefaultConfig } from "./defaults.js";
7
- export { type AliasConfig, type AnalyzerConfig, type BabelTransformConfig, type Config, DefaultConfig, DefineConfigContext, type DevConfig, DynamicUserConfig, type ExperimentalConfig, type HmrConfig, InternalConfig, LoadConfigOptions, type OptimizationConfig, type OutputConfig, PluginFlattenConfig, type PluginOption, type Polyfill, type PolyfillOptions, type PolyfillType, type PolyfillWithCode, type PolyfillWithPath, type ReactNativeConfig, type ResolveConfig, ResolvedConfig, type RolldownOptions, type RolldownOptionsConfig, type RolldownOptionsContext, type RolldownOptionsFunction, type RollipopReactNativeFlowConfig, type RollipopReactNativeSwcConfig, type RollipopReactNativeWorkletsConfig, type SwcTransformConfig, type TransformConfig, type TransformRule, UserConfig, type WatcherConfig, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, mergeConfig, resolvePluginConfig };
7
+ export { type AliasConfig, type AnalyzerConfig, type BabelTransformConfig, type Config, DefaultConfig, DefineConfigContext, type DevConfig, DynamicUserConfig, type ExperimentalConfig, type FlowConfig, type FlowConfig as RollipopReactNativeFlowConfig, type HmrConfig, InternalConfig, type JsxOptions, LoadConfigOptions, type OptimizationConfig, type OutputConfig, PluginFlattenConfig, type PluginOption, type Polyfill, type PolyfillOptions, type PolyfillType, type PolyfillWithCode, type PolyfillWithPath, type ReactNativeConfig, type ResolveConfig, ResolvedConfig, type RolldownOptions, type RolldownOptionsConfig, type RolldownOptionsContext, type RolldownOptionsFunction, type SwcConfig as RollipopReactNativeSwcConfig, type SwcConfig, type WorkletsConfig as RollipopReactNativeWorkletsConfig, type WorkletsConfig, type SwcTransformConfig, type TransformConfig, type TransformRule, UserConfig, type WatcherConfig, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, mergeConfig, resolvePluginConfig };
@@ -1,4 +1,4 @@
1
- import { MaybePromise, NullValue, Reporter } from "../types.js";
1
+ import { ExtractObject, MaybePromise, NullValue, Reporter } from "../types.js";
2
2
  import { RolldownOptions, RolldownOptionsConfig, RolldownOptionsContext, RolldownOptionsFunction } from "../core/rolldown.js";
3
3
  import { AliasEntry } from "../core/plugins/alias-plugin.js";
4
4
  import "../core/plugins/index.js";
@@ -6,13 +6,14 @@ import { InteractiveCommand } from "../node/commands/start/setup-interactive-mod
6
6
  import "../node/cli-utils.js";
7
7
  import { Plugin } from "../core/plugins/types.js";
8
8
  import * as swc from "@swc/core";
9
- import { DevWatchOptions, RollipopReactNativeFlowConfig, RollipopReactNativeSwcConfig, RollipopReactNativeWorkletsConfig } from "@rollipop/rolldown/experimental";
9
+ import { DevWatchOptions, RollipopReactNativeFlowConfig as FlowConfig, RollipopReactNativeReactConfig, RollipopReactNativeSwcConfig as SwcConfig, RollipopReactNativeWorkletsConfig as WorkletsConfig } from "@rollipop/rolldown/experimental";
10
10
  import * as rolldown from "@rollipop/rolldown";
11
11
  import { TopLevelFilterExpression } from "@rollipop/rolldown/filter";
12
12
  import * as babel from "@babel/core";
13
13
  //#region src/config/types.d.ts
14
14
  type RolldownExperimentalOptions = NonNullable<rolldown.InputOptions['experimental']>;
15
15
  type RolldownTransformOptions = NonNullable<rolldown.InputOptions['transform']>;
16
+ type RolldownJsxOptions = ExtractObject<NonNullable<RolldownTransformOptions['jsx']>>;
16
17
  type RollipopManagedInputOption = 'input' | 'plugins' | 'cwd' | 'platform' | 'checks' | 'logLevel' | 'onLog' | 'onwarn' | 'resolve' | 'transform' | 'watch' | 'experimental' | 'id';
17
18
  type RollipopManagedOutputOption = 'dir' | 'file' | 'format' | 'codeSplitting' | 'persistentCache';
18
19
  export interface Config extends Omit<rolldown.InputOptions, RollipopManagedInputOption> {
@@ -177,11 +178,20 @@ export type ResolveConfig = Omit<NonNullable<rolldown.InputOptions['resolve']>,
177
178
  preferNativePlatform?: boolean;
178
179
  };
179
180
  export type AliasConfig = NonNullable<rolldown.InputOptions['resolve']>['alias'] | AliasEntry[];
180
- export type TransformConfig = Omit<RolldownTransformOptions, 'cwd' | 'lang' | 'sourceType' | 'plugins'> & {
181
+ export type TransformConfig = Omit<RolldownTransformOptions, 'cwd' | 'lang' | 'sourceType' | 'jsx' | 'plugins'> & {
182
+ /**
183
+ * Controls how JSX syntax is transformed.
184
+ *
185
+ * - If set to `false`, an error will be thrown if JSX syntax is encountered.
186
+ * - If set to `'react'`, JSX syntax will be transformed to classic runtime React code.
187
+ * - If set to `'react-jsx'`, JSX syntax will be transformed to automatic runtime React code.
188
+ * - If set to `'preserve'`, JSX syntax will be preserved as-is.
189
+ */
190
+ jsx?: false | 'react' | 'react-jsx' | 'preserve' | JsxOptions;
181
191
  /**
182
192
  * Flow handling configuration for the built-in transform pipeline.
183
193
  */
184
- flow?: RollipopReactNativeFlowConfig;
194
+ flow?: FlowConfig;
185
195
  /**
186
196
  * Babel transformation configuration.
187
197
  */
@@ -191,11 +201,18 @@ export type TransformConfig = Omit<RolldownTransformOptions, 'cwd' | 'lang' | 's
191
201
  */
192
202
  swc?: SwcTransformConfig;
193
203
  };
204
+ export type JsxOptions = RolldownJsxOptions & {
205
+ /**
206
+ * React Compiler options forwarded to the native SWC pipeline.
207
+ * Explicit `transform.swc.native.react.compiler` options take precedence.
208
+ */
209
+ compiler?: RollipopReactNativeReactConfig['compiler'];
210
+ };
194
211
  export type BabelTransformConfig = {
195
212
  rules?: TransformRule<babel.InputOptions>[];
196
213
  };
197
214
  export type SwcTransformConfig = {
198
- native?: RollipopReactNativeSwcConfig;
215
+ native?: SwcConfig;
199
216
  rules?: TransformRule<swc.Options>[];
200
217
  };
201
218
  export interface TransformRule<T = unknown> {
@@ -212,7 +229,7 @@ export interface ExperimentalConfig extends RolldownExperimentalOptions {
212
229
  /**
213
230
  * `react-native-worklets` transformation configuration.
214
231
  */
215
- worklets?: RollipopReactNativeWorkletsConfig;
232
+ worklets?: WorkletsConfig;
216
233
  }
217
234
  export interface OutputConfig extends Omit<rolldown.OutputOptions, RollipopManagedOutputOption> {}
218
235
  export type Polyfill = string | PolyfillWithCode | PolyfillWithPath;
@@ -306,4 +323,4 @@ export interface AnalyzerConfig {
306
323
  autoOpen?: boolean;
307
324
  }
308
325
  //#endregion
309
- export type { RolldownOptions, RolldownOptionsConfig, RolldownOptionsContext, RolldownOptionsFunction, RollipopReactNativeFlowConfig, RollipopReactNativeSwcConfig, RollipopReactNativeWorkletsConfig };
326
+ export type { FlowConfig, FlowConfig as RollipopReactNativeFlowConfig, RolldownOptions, RolldownOptionsConfig, RolldownOptionsContext, RolldownOptionsFunction, SwcConfig as RollipopReactNativeSwcConfig, SwcConfig, WorkletsConfig as RollipopReactNativeWorkletsConfig, WorkletsConfig };
package/dist/constants.js CHANGED
@@ -20,7 +20,7 @@ var constants_exports = /* @__PURE__ */ __exportAll({
20
20
  ROLLIPOP_VIRTUAL_ENTRY_ID: () => ROLLIPOP_VIRTUAL_ENTRY_ID,
21
21
  ROLLIPOP_VIRTUAL_PREFIX: () => ROLLIPOP_VIRTUAL_PREFIX
22
22
  });
23
- const ROLLIPOP_VERSION = "1.0.0-beta.0";
23
+ const ROLLIPOP_VERSION = "1.0.0-beta.2";
24
24
  const ROLLIPOP_VIRTUAL_PREFIX = "\0rollipop/";
25
25
  const ROLLIPOP_VIRTUAL_BOOTSTRAP_ID = `${ROLLIPOP_VIRTUAL_PREFIX}bootstrap`;
26
26
  const ROLLIPOP_VIRTUAL_ENTRY_ID = `${ROLLIPOP_VIRTUAL_PREFIX}entry`;
@@ -28,4 +28,5 @@ export type Plugin = Omit<rolldown.Plugin, InternalRolldownHook> & {
28
28
  configureServer?: (this: PluginContext, server: DevServer) => AsyncResult<void | (() => AsyncResult<void>)>;
29
29
  devtools?: DevToolsPluginOptions;
30
30
  };
31
- //#endregion
31
+ //#endregion
32
+ export {};
@@ -28,7 +28,7 @@ import { resolutionTopology as resolutionTopologyPlugin } from "./plugins/resolu
28
28
  import "./plugins/index.js";
29
29
  import fs from "node:fs";
30
30
  import path from "node:path";
31
- import { invariant, isNotNil, toMerged } from "es-toolkit";
31
+ import { invariant, isNotNil, mergeWith, toMerged } from "es-toolkit";
32
32
  //#region src/core/rolldown.ts
33
33
  async function resolveRolldownOptions(context, config, buildOptions, devEngineOptions) {
34
34
  const { platform, dev, cache } = buildOptions;
@@ -45,7 +45,7 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
45
45
  const { sourceExtensions, assetExtensions, preferNativePlatform, ...rolldownResolve } = config.resolve;
46
46
  const { intro: rolldownIntro, ...rolldownOutput } = config.output;
47
47
  const { worklets: _experimentalWorklets, ...rolldownExperimental } = config.experimental;
48
- const { flow: _flow, babel: _babel, swc: _swc, ...rolldownTransform } = config.transform;
48
+ const rolldownTransform = resolveRolldownTransformConfig(config.transform);
49
49
  const userPlugins = config.plugins;
50
50
  const { rolldownAlias, aliasPluginOptions } = resolveAliasPluginOptions(config);
51
51
  const mergedResolveOptions = toMerged({ extensions: getResolveExtensions({
@@ -58,12 +58,10 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
58
58
  alias: rolldownAlias
59
59
  });
60
60
  const defaultTransformOptions = {
61
- cwd: config.root,
62
61
  target: "esnext",
63
62
  jsx: {
64
63
  runtime: "automatic",
65
- development: dev,
66
- compiler: void 0
64
+ development: dev
67
65
  },
68
66
  define: {
69
67
  __DEV__: asLiteral(dev),
@@ -76,7 +74,6 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
76
74
  helpers: { mode: "Runtime" }
77
75
  };
78
76
  const mergedTransformOptions = toMerged(defaultTransformOptions, rolldownTransform);
79
- applyReactCompilerDefaults(mergedTransformOptions);
80
77
  const reactRefreshFilter = resolveReactRefreshFilter(mergedTransformOptions);
81
78
  const entryPluginOptions = resolveEntryPluginOptions(config, context);
82
79
  const importGlobPluginOptions = resolveImportGlobPluginOptions(config);
@@ -220,7 +217,7 @@ function resolveReactNativeBuiltinPluginConfig(config) {
220
217
  envName: config.mode,
221
218
  runtimeTarget: config.runtimeTarget,
222
219
  flow: config.transform.flow,
223
- swc: config.transform.swc?.native,
220
+ swc: resolveNativeSwcConfig(config.transform),
224
221
  worklets: resolveWorkletsConfig(config)
225
222
  };
226
223
  }
@@ -232,14 +229,30 @@ function resolveWorkletsConfig(config) {
232
229
  pluginVersion: resolvePackageJson(config.root, "react-native-worklets")?.version
233
230
  }, worklets);
234
231
  }
235
- function applyReactCompilerDefaults(transform) {
236
- const jsx = transform.jsx;
237
- if (jsx == null || typeof jsx !== "object") return;
238
- const jsxOptions = jsx;
239
- if (jsxOptions.compiler == null) return;
240
- jsxOptions.compiler = {
241
- ...jsxOptions.compiler,
242
- exclude: jsxOptions.compiler.exclude ?? [/node_modules/]
232
+ function resolveRolldownTransformConfig(config) {
233
+ const { flow: _flow, babel: _babel, swc: _swc, ...transform } = config;
234
+ if (transform.jsx != null && typeof transform.jsx === "object") {
235
+ const { compiler: _compiler, ...jsx } = transform.jsx;
236
+ return {
237
+ ...transform,
238
+ jsx
239
+ };
240
+ }
241
+ return transform;
242
+ }
243
+ function resolveNativeSwcConfig({ jsx, swc }) {
244
+ const jsxCompiler = jsx != null && typeof jsx === "object" ? jsx.compiler : void 0;
245
+ const native = swc?.native;
246
+ const nativeCompiler = native?.react?.compiler;
247
+ if (jsxCompiler == null && nativeCompiler == null) return native;
248
+ const compiler = mergeWith(toMerged({}, jsxCompiler ?? {}), nativeCompiler ?? {}, (_target, source) => Array.isArray(source) ? [...source] : void 0);
249
+ compiler.exclude ??= [/node_modules/];
250
+ return {
251
+ ...native,
252
+ react: {
253
+ ...native?.react,
254
+ compiler
255
+ }
243
256
  };
244
257
  }
245
258
  function resolveBabelPluginOptions(config, context) {
@@ -90,4 +90,5 @@ type MetroCompatibleEvent = {
90
90
  bundlerId?: string;
91
91
  };
92
92
  export type ReportableEvent = InternalEvent | MetroCompatibleEvent;
93
- //#endregion
93
+ //#endregion
94
+ export {};
@@ -1,14 +1,14 @@
1
1
  var __rolldown_runtime__ = (function() {
2
2
  //#region \0rolldown/runtime.js
3
- function e$1(e) {
3
+ function r$1(r) {
4
4
  "@swc/helpers - typeof";
5
- return e && typeof Symbol !== "undefined" && e.constructor === Symbol ? "symbol" : typeof e;
5
+ return r && typeof Symbol !== "undefined" && r.constructor === Symbol ? "symbol" : typeof r;
6
6
  }
7
7
  var __create = Object.create;
8
8
  var __defProp = Object.defineProperty;
9
- var __name = function e(e, r) {
10
- return __defProp(e, "name", {
11
- value: r,
9
+ var __name = function r(r, e) {
10
+ return __defProp(r, "name", {
11
+ value: e,
12
12
  configurable: true
13
13
  });
14
14
  };
@@ -16,94 +16,127 @@ var __rolldown_runtime__ = (function() {
16
16
  var __getOwnPropNames = Object.getOwnPropertyNames;
17
17
  var __getProtoOf = Object.getPrototypeOf;
18
18
  var __hasOwnProp = Object.prototype.hasOwnProperty;
19
- var __esm = function e(e, r, t) {
19
+ var __esm = function r(r, e, t) {
20
20
  return function() {
21
21
  if (t) throw t[0];
22
22
  try {
23
- return e && (r = (0, e[__getOwnPropNames(e)[0]])(e = 0)), r;
24
- } catch (e) {
25
- throw t = [e], e;
23
+ return r && (e = (0, r[__getOwnPropNames(r)[0]])(r = 0)), e;
24
+ } catch (r) {
25
+ throw t = [r], r;
26
26
  }
27
27
  };
28
28
  };
29
- var __esmMin = function e(e, r, t) {
29
+ var __esmMin = function r(r, e, t) {
30
30
  return function() {
31
31
  if (t) throw t[0];
32
32
  try {
33
- return e && (r = e(e = 0)), r;
34
- } catch (e) {
35
- throw t = [e], e;
33
+ return r && (e = r(r = 0)), e;
34
+ } catch (r) {
35
+ throw t = [r], r;
36
36
  }
37
37
  };
38
38
  };
39
- var __commonJS = function e(e, r) {
39
+ var __commonJS = function r(r, e) {
40
40
  return function() {
41
- return r || ((0, e[__getOwnPropNames(e)[0]])((r = { exports: {} }).exports, r), e = null), r.exports;
41
+ return e || ((0, r[__getOwnPropNames(r)[0]])((e = { exports: {} }).exports, e, e.exports), r = null), e.exports;
42
42
  };
43
43
  };
44
- var __commonJSMin = function e(e, r) {
44
+ var __commonJSMin = function r(r, e) {
45
45
  return function() {
46
- return r || (e((r = { exports: {} }).exports, r), e = null), r.exports;
46
+ return e || (r((e = { exports: {} }).exports, e, e.exports), r = null), e.exports;
47
47
  };
48
48
  };
49
- var __exportAll = function e(e, r) {
49
+ var __exportAll = function r(r, e) {
50
50
  var t = {};
51
- for (var o in e) __defProp(t, o, {
52
- get: e[o],
51
+ for (var o in r) __defProp(t, o, {
52
+ get: r[o],
53
53
  enumerable: true
54
54
  });
55
- if (!r) __defProp(t, Symbol.toStringTag, { value: "Module" });
55
+ if (!e) __defProp(t, Symbol.toStringTag, { value: "Module" });
56
56
  return t;
57
57
  };
58
- var __copyProps = function r(r, t, o, n) {
59
- if (t && (typeof t === "undefined" ? "undefined" : e$1(t)) === "object" || typeof t === "function") for (var u = __getOwnPropNames(t), _ = 0, p = u.length, a; _ < p; _++) {
60
- a = u[_];
61
- if (!__hasOwnProp.call(r, a) && a !== o) __defProp(r, a, {
62
- get: (function(e) {
63
- return t[e];
64
- }).bind(null, a),
65
- enumerable: !(n = __getOwnPropDesc(t, a)) || n.enumerable
58
+ var __copyProps = function e(e, t, o, n) {
59
+ if (t && (typeof t === "undefined" ? "undefined" : r$1(t)) === "object" || typeof t === "function") for (var _ = __getOwnPropNames(t), a = 0, u = _.length, p; a < u; a++) {
60
+ p = _[a];
61
+ if (!__hasOwnProp.call(e, p) && p !== o) __defProp(e, p, {
62
+ get: (function(r) {
63
+ return t[r];
64
+ }).bind(null, p),
65
+ enumerable: !(n = __getOwnPropDesc(t, p)) || n.enumerable
66
66
  });
67
67
  }
68
- return r;
68
+ return e;
69
69
  };
70
- var __reExport = function e(e, r, t) {
71
- return __copyProps(e, r, "default"), t && __copyProps(t, r, "default");
70
+ var __reExport = function r(r, e, t) {
71
+ return __copyProps(r, e, "default"), t && __copyProps(t, e, "default");
72
72
  };
73
- var __toESM = function e(e, r, t) {
74
- return t = e != null ? __create(__getProtoOf(e)) : {}, __copyProps(r || !e || !e.__esModule || !__hasOwnProp.call(e, "default") ? __defProp(t, "default", {
75
- value: e,
73
+ var __toESM = function r(r, e, t) {
74
+ return t = r != null ? __create(__getProtoOf(r)) : {}, __copyProps(e || !r || !r.__esModule || !__hasOwnProp.call(r, "default") ? __defProp(t, "default", {
75
+ value: r,
76
76
  enumerable: true
77
- }) : t, e);
77
+ }) : t, r);
78
+ };
79
+ var __toCommonJS = function r(r) {
80
+ return __hasOwnProp.call(r, "module.exports") ? r["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), r);
78
81
  };
79
- var __toCommonJS = function e(e) {
80
- return __hasOwnProp.call(e, "module.exports") ? e["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), e);
82
+ var __share_factories = __create(null);
83
+ var __share_records = __create(null);
84
+ var __share = function r(r, e) {
85
+ if (!(r in __share_factories)) __share_factories[r] = e;
86
+ };
87
+ var __share_require = function r(r) {
88
+ var e = __share_records[r];
89
+ if (e) {
90
+ if (e.failed) throw e.error;
91
+ return e.exports;
92
+ }
93
+ var t = __share_factories[r];
94
+ if (!t) throw new Error("Shared chunk \"" + r + "\" was not registered before it was required.");
95
+ e = __share_records[r] = {
96
+ exports: {},
97
+ failed: false,
98
+ error: void 0
99
+ };
100
+ try {
101
+ t(e.exports);
102
+ } catch (r) {
103
+ e.failed = true;
104
+ e.error = r;
105
+ throw r;
106
+ }
107
+ return e.exports;
108
+ };
109
+ var __share_export = function r(r, e) {
110
+ for (var t in e) __defProp(r, t, {
111
+ get: e[t],
112
+ enumerable: true
113
+ });
81
114
  };
82
- var __toBinaryNode = function e(e) {
83
- return new Uint8Array(Buffer.from(e, "base64"));
115
+ var __toBinaryNode = function r(r) {
116
+ return new Uint8Array(Buffer.from(r, "base64"));
84
117
  };
85
118
  var __toBinary = function() {
86
- var e = /* @__PURE__ */ new Uint8Array(128);
87
- for (var r = 0; r < 64; r++) e[r < 26 ? r + 65 : r < 52 ? r + 71 : r < 62 ? r - 4 : r * 4 - 205] = r;
88
- return function(r) {
89
- var t = r.length, o = new Uint8Array((t - (r[t - 1] == "=") - (r[t - 2] == "=")) * 3 / 4 | 0);
90
- for (var n = 0, u = 0; n < t;) {
91
- var _ = e[r.charCodeAt(n++)], p = e[r.charCodeAt(n++)];
92
- var a = e[r.charCodeAt(n++)], f = e[r.charCodeAt(n++)];
93
- o[u++] = _ << 2 | p >> 4;
94
- o[u++] = p << 4 | a >> 2;
95
- o[u++] = a << 6 | f;
119
+ var r = /* @__PURE__ */ new Uint8Array(128);
120
+ for (var e = 0; e < 64; e++) r[e < 26 ? e + 65 : e < 52 ? e + 71 : e < 62 ? e - 4 : e * 4 - 205] = e;
121
+ return function(e) {
122
+ var t = e.length, o = new Uint8Array((t - (e[t - 1] == "=") - (e[t - 2] == "=")) * 3 / 4 | 0);
123
+ for (var n = 0, _ = 0; n < t;) {
124
+ var a = r[e.charCodeAt(n++)], u = r[e.charCodeAt(n++)];
125
+ var p = r[e.charCodeAt(n++)], f = r[e.charCodeAt(n++)];
126
+ o[_++] = a << 2 | u >> 4;
127
+ o[_++] = u << 4 | p >> 2;
128
+ o[_++] = p << 6 | f;
96
129
  }
97
130
  return o;
98
131
  };
99
132
  }();
100
- var __require = function(e) {
101
- return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(e, { get: function e(e, r) {
102
- return (typeof require !== "undefined" ? require : e)[r];
103
- } }) : e;
104
- }(function(e) {
133
+ var __require = function(r) {
134
+ return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(r, { get: function r(r, e) {
135
+ return (typeof require !== "undefined" ? require : r)[e];
136
+ } }) : r;
137
+ }(function(r) {
105
138
  if (typeof require !== "undefined") return require.apply(this, arguments);
106
- throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
139
+ throw Error("Calling `require` for \"" + r + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
107
140
  });
108
141
  //#endregion
109
142
  //#region ../../node_modules/mitt/dist/mitt.mjs
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { BuildDiagnosticLog, ReportableEvent } from "./events/types.js";
2
- import { ChangeEvent, DeepRequired, HotUpdateOptions, MaybePromise, NullValue, PackageJson, PluginWithHotUpdate, Reporter } from "./types.js";
2
+ import { ChangeEvent, DeepRequired, ExtractObject, HotUpdateOptions, MaybePromise, NullValue, PackageJson, PluginWithHotUpdate, Reporter } from "./types.js";
3
3
  import { RolldownOptions, RolldownOptionsConfig, RolldownOptionsContext, RolldownOptionsFunction } from "./core/rolldown.js";
4
4
  import { AsyncResult, BuildOptions, BuildType, BundlerContext, BundlerState, DevEngine, DevEngineOptions } from "./core/types.js";
5
5
  import { index_d_exports } from "./core/plugins/index.js";
@@ -8,7 +8,7 @@ import { DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH } from "./server/cons
8
8
  import { createDevServer } from "./server/index.js";
9
9
  import { InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, setupInteractiveMode } from "./node/commands/start/setup-interactive-mode.js";
10
10
  import { createCommand, createReactNativeCliCommand } from "./node/cli-utils.js";
11
- import { AliasConfig, AnalyzerConfig, BabelTransformConfig, Config, DevConfig, ExperimentalConfig, HmrConfig, OptimizationConfig, OutputConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolveConfig, RollipopReactNativeFlowConfig, RollipopReactNativeSwcConfig, RollipopReactNativeWorkletsConfig, SwcTransformConfig, TransformConfig, TransformRule, WatcherConfig } from "./config/types.js";
11
+ import { AliasConfig, AnalyzerConfig, BabelTransformConfig, Config, DevConfig, ExperimentalConfig, FlowConfig, HmrConfig, JsxOptions, OptimizationConfig, OutputConfig, PluginOption, Polyfill, PolyfillOptions, PolyfillType, PolyfillWithCode, PolyfillWithPath, ReactNativeConfig, ResolveConfig, RollipopReactNativeSwcConfig as SwcConfig, RollipopReactNativeWorkletsConfig as WorkletsConfig, SwcTransformConfig, TransformConfig, TransformRule, WatcherConfig } from "./config/types.js";
12
12
  import { DefineConfigContext, DynamicUserConfig, UserConfig, defineConfig } from "./config/define-config.js";
13
13
  import { LoadConfigOptions, flattenPluginOption, invokeConfigResolved, loadConfig, resolvePluginConfig } from "./config/load-config.js";
14
14
  import "./config/index.js";
@@ -29,4 +29,4 @@ import { OutputChunk } from "@rollipop/rolldown";
29
29
  export declare function runBuild(config: ResolvedConfig, options: BuildOptions): Promise<OutputChunk>;
30
30
  export declare function runServer(config: ResolvedConfig, options: ServerOptions): Promise<DevServer>;
31
31
  //#endregion
32
- export { type AliasConfig, type AnalyzerConfig, assets_d_exports as AssetUtils, type AsyncResult, type BabelTransformConfig, type BuildDiagnosticLog, type BuildOptions, type BuildType, type BundleDetails, Bundler, type BundlerContext, type BundlerState, type ChangeEvent, type Config, constants_d_exports as Constants, DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH, type DeepRequired, DefaultConfig, DefineConfigContext, type DevConfig, type DevEngine, type DevEngineOptions, type DevServer, type DevServerContext, type DevServerEvents, type DevToolsPluginOptions, DynamicUserConfig, type ExperimentalConfig, type FastifyInstance, type FormattedError, type HMRClientLogLevel, type HMRClientMessage, type HMRContext, type HMRCustomHandler, type HMRCustomMessage, type HMRServerError, type HMRServerMessage, type HmrConfig, type HotUpdateOptions, InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, InternalConfig, LoadConfigOptions, LoadEnvOptions, type MaybePromise, type Middlewares, type NullValue, type OptimizationConfig, type OutputConfig, type PackageJson, type Plugin, type PluginConfig, PluginFlattenConfig, type PluginOption, type PluginWithHotUpdate, type Polyfill, type PolyfillOptions, type PolyfillType, type PolyfillWithCode, type PolyfillWithPath, type ReactNativeConfig, type ReportableEvent, type Reporter, type ResolveConfig, ResolvedConfig, type RolldownOptions, type RolldownOptionsConfig, type RolldownOptionsContext, type RolldownOptionsFunction, type RollipopDevToolsNodeContext, type RollipopReactNativeFlowConfig, type RollipopReactNativeSwcConfig, type RollipopReactNativeWorkletsConfig, type ServerOptions, type SwcTransformConfig, type TransformConfig, type TransformRule, UserConfig, type WatcherConfig, cli_d_exports as cli, createCommand, createDevServer, createReactNativeCliCommand, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, loadEnv, mergeConfig, index_d_exports as plugins, resetCache, resolvePluginConfig, rolldown, rolldownExperimental, setupInteractiveMode };
32
+ export { type AliasConfig, type AnalyzerConfig, assets_d_exports as AssetUtils, type AsyncResult, type BabelTransformConfig, type BuildDiagnosticLog, type BuildOptions, type BuildType, type BundleDetails, Bundler, type BundlerContext, type BundlerState, type ChangeEvent, type Config, constants_d_exports as Constants, DEFAULT_HOST, DEFAULT_PORT, DEV_SERVER_ASSET_PATH, type DeepRequired, DefaultConfig, DefineConfigContext, type DevConfig, type DevEngine, type DevEngineOptions, type DevServer, type DevServerContext, type DevServerEvents, type DevToolsPluginOptions, DynamicUserConfig, type ExperimentalConfig, type ExtractObject, type FastifyInstance, type FlowConfig, type FlowConfig as RollipopReactNativeFlowConfig, type FormattedError, type HMRClientLogLevel, type HMRClientMessage, type HMRContext, type HMRCustomHandler, type HMRCustomMessage, type HMRServerError, type HMRServerMessage, type HmrConfig, type HotUpdateOptions, InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, InternalConfig, type JsxOptions, LoadConfigOptions, LoadEnvOptions, type MaybePromise, type Middlewares, type NullValue, type OptimizationConfig, type OutputConfig, type PackageJson, type Plugin, type PluginConfig, PluginFlattenConfig, type PluginOption, type PluginWithHotUpdate, type Polyfill, type PolyfillOptions, type PolyfillType, type PolyfillWithCode, type PolyfillWithPath, type ReactNativeConfig, type ReportableEvent, type Reporter, type ResolveConfig, ResolvedConfig, type RolldownOptions, type RolldownOptionsConfig, type RolldownOptionsContext, type RolldownOptionsFunction, type RollipopDevToolsNodeContext, type SwcConfig as RollipopReactNativeSwcConfig, type SwcConfig, type WorkletsConfig as RollipopReactNativeWorkletsConfig, type WorkletsConfig, type ServerOptions, type SwcTransformConfig, type TransformConfig, type TransformRule, UserConfig, type WatcherConfig, cli_d_exports as cli, createCommand, createDevServer, createReactNativeCliCommand, defineConfig, flattenPluginOption, getDefaultConfig, invokeConfigResolved, loadConfig, loadEnv, mergeConfig, index_d_exports as plugins, resetCache, resolvePluginConfig, rolldown, rolldownExperimental, setupInteractiveMode };
@@ -0,0 +1,14 @@
1
+ import { resolvePolyfillScriptPaths } from "./polyfills.js";
2
+ //#region src/internal/react-native/legacy.ts
3
+ const legacyRuntime = {
4
+ range: "<0.87.0-0",
5
+ resolve(context) {
6
+ return {
7
+ prelude: [context.require.resolve("./Libraries/Core/InitializeCore")],
8
+ polyfills: resolvePolyfillScriptPaths(context),
9
+ assetRegistryPath: "react-native/Libraries/Image/AssetRegistry.js"
10
+ };
11
+ }
12
+ };
13
+ //#endregion
14
+ export { legacyRuntime };
@@ -0,0 +1,28 @@
1
+ import { resolvePackagePath } from "../../utils/node-resolve.js";
2
+ import { createRequire } from "node:module";
3
+ import path from "node:path";
4
+ //#region src/internal/react-native/polyfills.ts
5
+ function resolvePolyfillScriptPaths({ projectRoot, reactNativePath, require }) {
6
+ const polyfillPath = resolveOptional(() => require.resolve("@react-native/js-polyfills", { paths: [reactNativePath, projectRoot] }));
7
+ if (polyfillPath) return require(polyfillPath)();
8
+ let metroConfigPath;
9
+ try {
10
+ metroConfigPath = resolvePackagePath(projectRoot, "@react-native/metro-config");
11
+ } catch {}
12
+ if (metroConfigPath) {
13
+ const requireFromMetroConfig = createRequire(path.join(metroConfigPath, "package.json"));
14
+ const metroPolyfillPath = resolveOptional(() => requireFromMetroConfig.resolve("@react-native/js-polyfills"));
15
+ if (metroPolyfillPath) return requireFromMetroConfig(metroPolyfillPath)();
16
+ }
17
+ return require("./rn-get-polyfills")();
18
+ }
19
+ function resolveOptional(resolve) {
20
+ try {
21
+ return resolve();
22
+ } catch (error) {
23
+ if (error instanceof Error && "code" in error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) return;
24
+ throw error;
25
+ }
26
+ }
27
+ //#endregion
28
+ export { resolvePolyfillScriptPaths };
@@ -0,0 +1,14 @@
1
+ import { resolvePolyfillScriptPaths } from "./polyfills.js";
2
+ //#region src/internal/react-native/public-assets.ts
3
+ const publicAssetsRuntime = {
4
+ range: ">=0.87.0-0 <0.88.0-0",
5
+ resolve(context) {
6
+ return {
7
+ prelude: [context.require.resolve("./Libraries/Core/InitializeCore")],
8
+ polyfills: resolvePolyfillScriptPaths(context),
9
+ assetRegistryPath: "react-native/asset-registry"
10
+ };
11
+ }
12
+ };
13
+ //#endregion
14
+ export { publicAssetsRuntime };
@@ -0,0 +1,14 @@
1
+ import { resolvePolyfillScriptPaths } from "./polyfills.js";
2
+ //#region src/internal/react-native/public.ts
3
+ const publicRuntime = {
4
+ range: ">=0.88.0-0",
5
+ resolve(context) {
6
+ return {
7
+ prelude: [context.require.resolve("react-native/setup-env")],
8
+ polyfills: resolvePolyfillScriptPaths(context),
9
+ assetRegistryPath: "react-native/asset-registry"
10
+ };
11
+ }
12
+ };
13
+ //#endregion
14
+ export { publicRuntime };
@@ -0,0 +1,25 @@
1
+ import { legacyRuntime } from "./legacy.js";
2
+ import { publicRuntime } from "./public.js";
3
+ import { publicAssetsRuntime } from "./public-assets.js";
4
+ import { createRequire } from "node:module";
5
+ import path from "node:path";
6
+ import { satisfies } from "semver";
7
+ //#region src/internal/react-native/runtime.ts
8
+ const strategies = [
9
+ publicRuntime,
10
+ publicAssetsRuntime,
11
+ legacyRuntime
12
+ ];
13
+ function resolveReactNativeRuntime(projectRoot, reactNativePath) {
14
+ const require = createRequire(path.join(reactNativePath, "package.json"));
15
+ const { version } = require("./package.json");
16
+ const strategy = strategies.find(({ range }) => satisfies(version, range, { includePrerelease: true }));
17
+ if (!strategy) throw new Error(`Unsupported React Native version: ${version}`);
18
+ return strategy.resolve({
19
+ projectRoot,
20
+ reactNativePath,
21
+ require
22
+ });
23
+ }
24
+ //#endregion
25
+ export { resolveReactNativeRuntime };
@@ -1,46 +1,7 @@
1
1
  import { asLiteral } from "../common/code.js";
2
- import { resolvePackagePath } from "../utils/node-resolve.js";
3
- import { createRequire } from "node:module";
4
- import path from "node:path";
2
+ import { resolveReactNativeRuntime } from "./react-native/runtime.js";
5
3
  import { isNotNil } from "es-toolkit";
6
4
  //#region src/internal/react-native.ts
7
- const ASSET_REGISTRY_PATH = "react-native/asset-registry";
8
- const LEGACY_ASSET_REGISTRY_PATH = "react-native/Libraries/Image/AssetRegistry.js";
9
- const require = createRequire(import.meta.url);
10
- function resolveInitializeCorePath(basePath) {
11
- return resolveOptional("react-native/setup-env", [basePath]) ?? require.resolve("react-native/Libraries/Core/InitializeCore", { paths: [basePath] });
12
- }
13
- function resolveAssetRegistryPath(basePath) {
14
- return resolveOptional(ASSET_REGISTRY_PATH, [basePath]) ? ASSET_REGISTRY_PATH : LEGACY_ASSET_REGISTRY_PATH;
15
- }
16
- function resolvePolyfillScriptPaths(basePath, reactNativePath) {
17
- const polyfillPath = resolveOptional("@react-native/js-polyfills", [reactNativePath, basePath]);
18
- if (polyfillPath) return loadPolyfillScriptPaths(polyfillPath);
19
- let metroConfigPath;
20
- try {
21
- metroConfigPath = resolvePackagePath(basePath, "@react-native/metro-config");
22
- } catch {}
23
- if (metroConfigPath) {
24
- const requireFromMetroConfig = createRequire(path.join(metroConfigPath, "package.json"));
25
- const metroPolyfillPath = resolveOptionalWith(() => requireFromMetroConfig.resolve("@react-native/js-polyfills"));
26
- if (metroPolyfillPath) return loadPolyfillScriptPaths(metroPolyfillPath, requireFromMetroConfig);
27
- }
28
- return loadPolyfillScriptPaths(require.resolve(path.join(reactNativePath, "rn-get-polyfills")));
29
- }
30
- function loadPolyfillScriptPaths(modulePath, load = require) {
31
- return load(modulePath)();
32
- }
33
- function resolveOptional(moduleId, paths) {
34
- return resolveOptionalWith(() => require.resolve(moduleId, { paths }));
35
- }
36
- function resolveOptionalWith(resolve) {
37
- try {
38
- return resolve();
39
- } catch (error) {
40
- if (error instanceof Error && "code" in error && (error.code === "MODULE_NOT_FOUND" || error.code === "ERR_PACKAGE_PATH_NOT_EXPORTED")) return;
41
- throw error;
42
- }
43
- }
44
5
  function getGlobalVariables(dev) {
45
6
  return [
46
7
  `var __BUNDLE_START_TIME__ = globalThis.nativePerformanceNow ? nativePerformanceNow() : Date.now();`,
@@ -51,4 +12,4 @@ function getGlobalVariables(dev) {
51
12
  ].filter(isNotNil);
52
13
  }
53
14
  //#endregion
54
- export { getGlobalVariables, resolveAssetRegistryPath, resolveInitializeCorePath, resolvePolyfillScriptPaths };
15
+ export { getGlobalVariables, resolveReactNativeRuntime };
@@ -1,2 +1 @@
1
- import { command } from "./command.js";
2
- export { command };
1
+ export { command } from "./command.js";
@@ -1,2 +1 @@
1
- import { command } from "./command.js";
2
- export { command };
1
+ export { command } from "./command.js";
@@ -1,2 +1 @@
1
- import { command } from "./command.js";
2
- export { command };
1
+ export { command } from "./command.js";
package/dist/package.js CHANGED
@@ -1,4 +1,4 @@
1
1
  //#region package.json
2
- var version = "1.0.0-beta.0";
2
+ var version = "1.0.0-beta.2";
3
3
  //#endregion
4
4
  export { version };
@@ -0,0 +1,27 @@
1
+ var __create = Object.create;
2
+ __create(null);
3
+ __create(null);
4
+ (function() {
5
+ var r = /* @__PURE__ */ new Uint8Array(128);
6
+ for (var e = 0; e < 64; e++) r[e < 26 ? e + 65 : e < 52 ? e + 71 : e < 62 ? e - 4 : e * 4 - 205] = e;
7
+ return function(e) {
8
+ var t = e.length, o = new Uint8Array((t - (e[t - 1] == "=") - (e[t - 2] == "=")) * 3 / 4 | 0);
9
+ for (var n = 0, _ = 0; n < t;) {
10
+ var a = r[e.charCodeAt(n++)], u = r[e.charCodeAt(n++)];
11
+ var p = r[e.charCodeAt(n++)], f = r[e.charCodeAt(n++)];
12
+ o[_++] = a << 2 | u >> 4;
13
+ o[_++] = u << 4 | p >> 2;
14
+ o[_++] = p << 6 | f;
15
+ }
16
+ return o;
17
+ };
18
+ })();
19
+ (function(r) {
20
+ return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(r, { get: function r(r, e) {
21
+ return (typeof require !== "undefined" ? require : r)[e];
22
+ } }) : r;
23
+ })(function(r) {
24
+ if (typeof require !== "undefined") return require.apply(this, arguments);
25
+ throw Error("Calling `require` for \"" + r + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
26
+ });
27
+ //#endregion
package/dist/runtime.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import "./rolldown-runtime-BHXq-rbM.js";
1
+ import "./rolldown-runtime-DXE2a-Yu.js";
2
2
  import { createSignatureFunctionForTransform, getFamilyByType, isLikelyComponentType, performReactRefresh, register } from "react-refresh";
3
3
  //#endregion
4
4
  export { setCustomHMRHandler };
package/dist/runtime.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./rolldown-runtime-BHXq-rbM.js";
1
+ import "./rolldown-runtime-DXE2a-Yu.js";
2
2
  //#region src/runtime.ts
3
3
  function setCustomHMRHandler(l) {
4
4
  if (__DEV__ && globalThis.__rollipop_runtime__ != null) {
@@ -7,4 +7,5 @@ export interface BundleStore {
7
7
  sourceMap: string | undefined;
8
8
  sourceMapConsumer: Promise<SourceMapConsumerType> | undefined;
9
9
  }
10
- //#endregion
10
+ //#endregion
11
+ export {};
@@ -57,7 +57,7 @@ async function createDevServer(config, options) {
57
57
  eventBus.subscribe(createReporterEventListener(config.reporter));
58
58
  eventBus.subscribe(createReactNativeEventListener(reportEvent));
59
59
  eventBus.subscribe(createDevServerEventListener(emitter));
60
- const { middleware: devMiddleware, websocketEndpoints } = createDevMiddleware({
60
+ const { middleware: devMiddleware, websocketEndpoints } = options?.inspector ?? createDevMiddleware({
61
61
  serverBaseUrl,
62
62
  logger: {
63
63
  info(...args) {
@@ -18,7 +18,10 @@ function toDevframeEvent(event) {
18
18
  case "bundle_build_failed":
19
19
  case "hmr_failed":
20
20
  case "watch_change": return bundlerEventToDevframeEvent(event);
21
- case "hmr_updates":
21
+ case "hmr_updates": return {
22
+ type: "hmr_updates",
23
+ bundlerId: event.bundlerId
24
+ };
22
25
  case "client_message":
23
26
  case "client_error":
24
27
  case "transform":
@@ -1,5 +1,6 @@
1
1
  import { resetCache } from "../../utils/reset-cache.js";
2
2
  import { getBaseBundleName } from "../../utils/bundle.js";
3
+ import { getHotUpdatePath, parseHotUpdatePath } from "../hot-update-store.js";
3
4
  import { parseUrl } from "../../utils/url.js";
4
5
  import { symbolicate } from "../symbolicate.js";
5
6
  import { toDevframeEvent } from "./events.js";
@@ -20,7 +21,7 @@ var RollipopDevframeController = class {
20
21
  this.definition = defineDevframe({
21
22
  id: "rollipop",
22
23
  name: "Rollipop",
23
- version: "1.0.0-beta.0",
24
+ version: "1.0.0-beta.2",
24
25
  packageName: "rollipop",
25
26
  homepage: "https://github.com/rollipop-dev/rollipop",
26
27
  description: "React Native development dashboard powered by Rollipop.",
@@ -58,6 +59,14 @@ var RollipopDevframeController = class {
58
59
  getBuilds() {
59
60
  return this.context.state.getBuilds();
60
61
  }
62
+ getHmrChunks(bundlerId) {
63
+ return this.context.bundlerPool.hotUpdateStore.list(bundlerId).map((chunk) => ({
64
+ filename: chunk.filename,
65
+ bundleUrl: new URL(getHotUpdatePath(bundlerId, chunk.filename), this.context.serverBaseUrl).href,
66
+ sourceMapUrl: chunk.sourcemapFilename == null ? null : new URL(getHotUpdatePath(bundlerId, chunk.sourcemapFilename), this.context.serverBaseUrl).href,
67
+ updatedAt: chunk.updatedAt
68
+ }));
69
+ }
61
70
  getBuildLogs(bundlerId) {
62
71
  const logs = this.context.state.getBuildLogs(bundlerId);
63
72
  if (logs != null) return logs;
@@ -80,17 +89,26 @@ var RollipopDevframeController = class {
80
89
  }
81
90
  async symbolicateBundlePosition(bundleUrl, line, column) {
82
91
  const { pathname, query } = parseUrl(bundleUrl);
83
- if (pathname == null || query.platform == null || query.dev == null) throw new Error("Bundle URL must include pathname, platform, and dev query parameters");
84
- const bundle = await this.context.bundlerPool.get(getBaseBundleName(pathname), {
85
- platform: String(query.platform),
86
- dev: query.dev === "true",
87
- ...query.minify == null ? {} : { minify: query.minify === "true" }
88
- }).getBundle();
92
+ let bundle;
93
+ if (pathname?.startsWith(`/hot/`)) {
94
+ const hotUpdate = parseHotUpdatePath(pathname);
95
+ if (hotUpdate == null) throw new Error("Invalid HMR chunk URL");
96
+ const stored = this.context.bundlerPool.hotUpdateStore.resolve(hotUpdate.id, hotUpdate.filename);
97
+ if (stored == null) throw new Error(`HMR chunk not found: ${hotUpdate.id}/${hotUpdate.filename}`);
98
+ bundle = stored;
99
+ } else {
100
+ if (pathname == null || query.platform == null || query.dev == null) throw new Error("Bundle URL must include pathname, platform, and dev query parameters");
101
+ bundle = await this.context.bundlerPool.get(getBaseBundleName(pathname), {
102
+ platform: String(query.platform),
103
+ dev: query.dev === "true",
104
+ ...query.minify == null ? {} : { minify: query.minify === "true" }
105
+ }).getBundle();
106
+ }
89
107
  return symbolicate(bundle, [{
90
108
  file: bundleUrl,
91
109
  lineNumber: line + 1,
92
110
  column
93
- }]);
111
+ }], { fallbackToNextMapping: true });
94
112
  }
95
113
  async triggerFullBuild(bundlerId) {
96
114
  const bundler = this.context.bundlerPool.getInstanceById(bundlerId);
@@ -124,6 +142,11 @@ function registerDashboardRpcFunctions(rpc, controller) {
124
142
  type: "query",
125
143
  handler: () => controller.getBuilds()
126
144
  }));
145
+ rpc.register(defineRpcFunction({
146
+ name: "get-hmr-chunks",
147
+ type: "query",
148
+ handler: (bundlerId) => controller.getHmrChunks(bundlerId)
149
+ }));
127
150
  rpc.register(defineRpcFunction({
128
151
  name: "get-build-logs",
129
152
  type: "query",
@@ -16,7 +16,7 @@ async function setupDevframe(context, server, inspectorDeviceServer) {
16
16
  const controller = new RollipopDevframeController(context, createAgentToolContext(context));
17
17
  const devtools = initHub({
18
18
  name: DEVFRAME_NAME,
19
- version: "1.0.0-beta.0",
19
+ version: "1.0.0-beta.2",
20
20
  base: ROLLIPOP_DEVFRAME_BASE,
21
21
  cwd: context.config.root,
22
22
  ui: createUi({
@@ -8,11 +8,18 @@ export interface HotUpdatePatch {
8
8
  }
9
9
  export declare class HotUpdateStore {
10
10
  private readonly hotPath;
11
+ private readonly patches;
11
12
  constructor(projectRoot: string);
12
13
  clear(): void;
13
14
  write(id: string, patch: HotUpdatePatch): void;
15
+ list(id: string): {
16
+ filename: string;
17
+ sourcemapFilename: string | null;
18
+ updatedAt: number;
19
+ }[];
14
20
  resolve(id: string, filename: string): BundleStore | undefined;
15
21
  readAsset(id: string, filename: string): Buffer | undefined;
22
+ private getSourcemapFilename;
16
23
  private getDirectoryPath;
17
24
  private getFilePath;
18
25
  }
@@ -27,10 +27,12 @@ function parseHotUpdatePath(pathname) {
27
27
  }
28
28
  var HotUpdateStore = class {
29
29
  hotPath;
30
+ patches = /* @__PURE__ */ new Map();
30
31
  constructor(projectRoot) {
31
32
  this.hotPath = path.join(FileStorage.getPath(projectRoot), "hot");
32
33
  }
33
34
  clear() {
35
+ this.patches.clear();
34
36
  try {
35
37
  fs.rmSync(this.hotPath, {
36
38
  recursive: true,
@@ -47,14 +49,29 @@ var HotUpdateStore = class {
47
49
  fs.mkdirSync(directoryPath, { recursive: true });
48
50
  if (patch.sourcemap != null && patch.sourcemapFilename != null) fs.writeFileSync(this.getFilePath(id, patch.sourcemapFilename), patch.sourcemap, "utf-8");
49
51
  fs.writeFileSync(this.getFilePath(id, patch.filename), patch.code, "utf-8");
52
+ const patches = this.patches.get(id) ?? /* @__PURE__ */ new Map();
53
+ patches.set(patch.filename, patch.sourcemapFilename ?? null);
54
+ this.patches.set(id, patches);
55
+ }
56
+ list(id) {
57
+ assertPathSegment(id, "id");
58
+ return Array.from(this.patches.get(id)?.keys() ?? []).flatMap((filename) => {
59
+ const stats = fs.statSync(this.getFilePath(id, filename), { throwIfNoEntry: false });
60
+ if (!stats?.isFile()) return [];
61
+ return [{
62
+ filename,
63
+ sourcemapFilename: this.getSourcemapFilename(id, filename),
64
+ updatedAt: stats.mtimeMs
65
+ }];
66
+ }).sort((a, b) => b.updatedAt - a.updatedAt);
50
67
  }
51
68
  resolve(id, filename) {
52
69
  assertPathSegment(id, "id");
53
70
  assertPathSegment(filename, "filename");
54
71
  const bundleFilePath = this.getFilePath(id, filename);
55
72
  if (!isFile(bundleFilePath)) return;
56
- const sourcemapFilePath = this.getFilePath(id, `${filename}.map`);
57
- return new HotUpdateBundleStore(bundleFilePath, isFile(sourcemapFilePath) ? sourcemapFilePath : void 0);
73
+ const sourcemapFilename = this.getSourcemapFilename(id, filename);
74
+ return new HotUpdateBundleStore(bundleFilePath, sourcemapFilename == null ? void 0 : this.getFilePath(id, sourcemapFilename));
58
75
  }
59
76
  readAsset(id, filename) {
60
77
  assertPathSegment(id, "id");
@@ -62,6 +79,11 @@ var HotUpdateStore = class {
62
79
  const filePath = this.getFilePath(id, filename);
63
80
  return isFile(filePath) ? fs.readFileSync(filePath) : void 0;
64
81
  }
82
+ getSourcemapFilename(id, filename) {
83
+ const storedFilename = this.patches.get(id)?.get(filename);
84
+ const sourcemapFilename = storedFilename === void 0 ? `${filename}.map` : storedFilename;
85
+ return sourcemapFilename != null && isFile(this.getFilePath(id, sourcemapFilename)) ? sourcemapFilename : null;
86
+ }
65
87
  getDirectoryPath(id) {
66
88
  return path.join(this.hotPath, id);
67
89
  }
@@ -1,4 +1,5 @@
1
1
  import { parseUrl } from "../utils/url.js";
2
+ import { SourceMapConsumer } from "source-map";
2
3
  import { codeFrameColumns } from "@babel/code-frame";
3
4
  //#region src/server/symbolicate.ts
4
5
  /**
@@ -25,16 +26,16 @@ const INTERNAL_CALLSITES_REGEX = new RegExp([
25
26
  "/node_modules/scheduler/.+\\.js$",
26
27
  "^\\[native code\\]$"
27
28
  ].map((pathPattern) => pathPattern.replaceAll("/", "[/\\\\]")).join("|"));
28
- async function symbolicate(bundleStore, stack) {
29
- return symbolicateWithBundleResolver(stack, (frame) => frame.file?.startsWith("http") ? bundleStore : void 0);
29
+ async function symbolicate(bundleStore, stack, options) {
30
+ return symbolicateWithBundleResolver(stack, (frame) => frame.file?.startsWith("http") ? bundleStore : void 0, options);
30
31
  }
31
- async function symbolicateWithBundleResolver(stack, resolveBundleStore) {
32
+ async function symbolicateWithBundleResolver(stack, resolveBundleStore, options) {
32
33
  const symbolicatedStack = await Promise.all(stack.map(async (frame) => {
33
34
  const bundleStore = frame.file?.startsWith("http") ? await resolveBundleStore(frame) : void 0;
34
35
  const sourceMapConsumer = await bundleStore?.sourceMapConsumer;
35
36
  return {
36
37
  bundleStore,
37
- frame: collapseFrame(sourceMapConsumer ? originalPositionFor(sourceMapConsumer, frame) : frame),
38
+ frame: collapseFrame(sourceMapConsumer ? originalPositionFor(sourceMapConsumer, frame, options) : frame),
38
39
  sourceMapConsumer
39
40
  };
40
41
  }));
@@ -43,12 +44,17 @@ async function symbolicateWithBundleResolver(stack, resolveBundleStore) {
43
44
  codeFrame: getCodeFrame(symbolicatedStack)
44
45
  };
45
46
  }
46
- function originalPositionFor(sourceMapConsumer, frame) {
47
+ function originalPositionFor(sourceMapConsumer, frame, options) {
47
48
  if (frame.column == null || frame.lineNumber == null) return frame;
48
- const originalPosition = sourceMapConsumer.originalPositionFor({
49
+ let originalPosition = sourceMapConsumer.originalPositionFor({
49
50
  column: frame.column,
50
51
  line: frame.lineNumber
51
52
  });
53
+ if (originalPosition.source == null && options?.fallbackToNextMapping) originalPosition = sourceMapConsumer.originalPositionFor({
54
+ column: frame.column,
55
+ line: frame.lineNumber,
56
+ bias: SourceMapConsumer.LEAST_UPPER_BOUND
57
+ });
52
58
  return Object.entries(originalPosition).reduce((frame, [key, value]) => {
53
59
  const targetKey = convertFrameKey(key);
54
60
  return {
@@ -22,6 +22,11 @@ export interface ServerOptions {
22
22
  key?: string;
23
23
  cert?: string;
24
24
  buildOptions?: Pick<BuildOptions, 'cache'>;
25
+ /** Override the inspector middleware and WebSocket endpoints for a host's debugging protocol. */
26
+ inspector?: {
27
+ middleware: fastifyMiddie.Handler;
28
+ websocketEndpoints: Record<string, ws.Server>;
29
+ };
25
30
  }
26
31
  export interface DevServerContext {
27
32
  /**
@@ -28,7 +28,7 @@ var FileStorage = class FileStorage {
28
28
  this.dataFilePath = path.join(FileStorage.getPath(basePath, { prepare: true }), DATA_FILENAME);
29
29
  if (fs.existsSync(this.dataFilePath)) {
30
30
  const loadedData = JSON.parse(fs.readFileSync(this.dataFilePath, "utf-8"));
31
- if ("version" in loadedData && loadedData.version === "1.0.0-beta.0") this.data = loadedData;
31
+ if ("version" in loadedData && loadedData.version === "1.0.0-beta.2") this.data = loadedData;
32
32
  else {
33
33
  this.data = createDefaultData();
34
34
  this.flush();
package/dist/types.d.ts CHANGED
@@ -2,6 +2,7 @@ import { BuildDiagnosticLog, ReportableEvent } from "./events/types.js";
2
2
  import * as rolldown from "@rollipop/rolldown";
3
3
  //#region src/types.d.ts
4
4
  export type MaybePromise<T> = T | Promise<T>;
5
+ export type ExtractObject<T> = T extends object ? T : never;
5
6
  export type NullValue<T = void> = T | undefined | null | void;
6
7
  export type DeepRequired<T> = { [K in keyof T]-?: T[K] extends object ? DeepRequired<T[K]> : T[K]; };
7
8
  export interface Reporter {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollipop",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.2",
4
4
  "homepage": "https://github.com/rollipop-dev/rollipop#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/rollipop-dev/rollipop/issues"
@@ -59,57 +59,60 @@
59
59
  "@babel/code-frame": "8.0.6",
60
60
  "@babel/core": "8.0.6",
61
61
  "@commander-js/extra-typings": "15.0.0",
62
- "@devframes/hub": "1.0.0",
63
- "@devframes/hub-ui": "1.0.0",
64
- "@fastify/middie": "9.3.4",
65
- "@fastify/static": "10.1.4",
66
- "@inquirer/prompts": "8.7.2",
62
+ "@devframes/hub": "1.2.6",
63
+ "@devframes/hub-ui": "1.2.6",
64
+ "@fastify/middie": "9.3.5",
65
+ "@fastify/static": "10.1.6",
66
+ "@inquirer/prompts": "8.7.4",
67
67
  "@react-native-community/cli-server-api": "20.2.0",
68
68
  "@react-native-community/cli-types": "20.2.0",
69
- "@react-native/dev-middleware": "0.87.1",
70
- "@rollipop/dashboard": "1.0.0-beta.0",
71
- "@rollipop/rolldown": "1.0.34",
69
+ "@react-native/dev-middleware": "0.88.0",
70
+ "@rollipop/dashboard": "1.0.0-beta.2",
71
+ "@rollipop/rolldown": "1.1.1",
72
72
  "@swc/core": "1.16.13",
73
73
  "@swc/helpers": "0.5.23",
74
- "@types/ws": "8.18.1",
75
- "arktype": "2.2.3",
74
+ "@types/ws": "8.18.2",
75
+ "arktype": "2.2.8",
76
76
  "c12": "3.3.4",
77
- "chalk": "6.0.0",
77
+ "chalk": "6.0.1",
78
78
  "commander": "15.0.0",
79
79
  "dayjs": "1.11.23",
80
80
  "dedent": "1.7.2",
81
- "devframe": "1.0.0",
82
- "dotenv": "17.4.2",
81
+ "devframe": "1.2.6",
82
+ "dotenv": "18.0.8",
83
83
  "dotenv-expand": "13.0.0",
84
84
  "es-toolkit": "1.52.0",
85
85
  "fast-flow-transform": "0.0.3",
86
- "fastify": "5.12.5",
87
- "fastify-plugin": "6.0.0",
86
+ "fastify": "5.12.7",
87
+ "fastify-plugin": "6.0.1",
88
88
  "gradient-string": "3.0.0",
89
89
  "image-size": "2.0.4",
90
90
  "json-schema-to-ts": "3.1.1",
91
- "mime": "4.1.0",
91
+ "mime": "4.1.1",
92
92
  "mitt": "3.0.1",
93
93
  "open": "11.0.4",
94
94
  "pretty-format": "30.5.1",
95
95
  "rolldown-analyzer": "0.3.1",
96
+ "semver": "7.8.5",
96
97
  "source-map": "0.8.0",
97
98
  "strip-ansi": "7.2.0",
98
99
  "wrap-ansi": "10.0.2",
99
- "ws": "8.21.3"
100
+ "ws": "8.22.0"
100
101
  },
101
102
  "devDependencies": {
102
- "@devframes/agentic": "1.0.0",
103
+ "@devframes/agentic": "1.2.6",
103
104
  "@swc/plugin-remove-console": "15.0.0",
104
105
  "@types/react-refresh": "0.14.7",
105
- "@vitest/coverage-v8": "4.1.11",
106
+ "@types/semver": "7.8.0",
107
+ "@vitest/coverage-v8": "5.0.5",
106
108
  "react-refresh": "0.19.0",
107
109
  "typescript": "7.0.2",
108
- "vite-plus": "0.3.3",
109
- "vitest": "4.1.11"
110
+ "vite": "@voidzero-dev/vite-plus-core@1.3.0",
111
+ "vite-plus": "1.3.0",
112
+ "vitest": "5.0.5"
110
113
  },
111
114
  "peerDependencies": {
112
- "@devframes/agentic": "1.0.0"
115
+ "@devframes/agentic": "^1"
113
116
  },
114
117
  "peerDependenciesMeta": {
115
118
  "@devframes/agentic": {
@@ -18,7 +18,7 @@ Use https://rollipop.dev/docs/features/env.md when changing env file loading, pr
18
18
 
19
19
  ## Experimental Features
20
20
 
21
- Use https://rollipop.dev/docs/experimental/overview.md before enabling experimental options. Keep the change explicit and mention stability/version risk. For worklets specifically, read https://rollipop.dev/docs/experimental/reanimated-worklets.md.
21
+ Use https://rollipop.dev/docs/get-started/configuration.md#experimental before enabling experimental options. Keep the change explicit and mention stability/version risk. For worklets specifically, read https://rollipop.dev/docs/experimental/reanimated-worklets.md.
22
22
 
23
23
  ## Resolve Changes
24
24
 
package/skills/plugins.md CHANGED
@@ -28,7 +28,7 @@ Use the built-in analyzer config when the task is to inspect bundle size or modu
28
28
 
29
29
  ### Rozenite
30
30
 
31
- Use the Rozenite plugin when the app needs Rozenite DevTools middleware integrated into the Rollipop dev server. Keep it development-focused and follow Rozenite's app-side setup guidance for companion plugins. Read https://www.rozenite.dev.
31
+ Use the Rozenite plugin when the app needs Rozenite DevTools middleware integrated into the Rollipop dev server. Keep it development-focused and follow Rozenite's app-side setup guidance for companion plugins. Read https://rollipop.dev/docs/features/rozenite.md.
32
32
 
33
33
  ## Watchpoints
34
34
 
@@ -1,24 +0,0 @@
1
- (function() {
2
- var e = /* @__PURE__ */ new Uint8Array(128);
3
- for (var r = 0; r < 64; r++) e[r < 26 ? r + 65 : r < 52 ? r + 71 : r < 62 ? r - 4 : r * 4 - 205] = r;
4
- return function(r) {
5
- var t = r.length, o = new Uint8Array((t - (r[t - 1] == "=") - (r[t - 2] == "=")) * 3 / 4 | 0);
6
- for (var n = 0, u = 0; n < t;) {
7
- var _ = e[r.charCodeAt(n++)], p = e[r.charCodeAt(n++)];
8
- var a = e[r.charCodeAt(n++)], f = e[r.charCodeAt(n++)];
9
- o[u++] = _ << 2 | p >> 4;
10
- o[u++] = p << 4 | a >> 2;
11
- o[u++] = a << 6 | f;
12
- }
13
- return o;
14
- };
15
- })();
16
- (function(e) {
17
- return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(e, { get: function e(e, r) {
18
- return (typeof require !== "undefined" ? require : e)[r];
19
- } }) : e;
20
- })(function(e) {
21
- if (typeof require !== "undefined") return require.apply(this, arguments);
22
- throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
23
- });
24
- //#endregion