rollipop 1.0.0-alpha.21 → 1.0.0-alpha.23
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 +19 -0
- package/dist/{chunk-DEq-mXcV.js → _virtual/_rolldown/runtime.js} +1 -1
- package/dist/commands.d.ts +2 -4
- package/dist/commands.js +10 -3957
- package/dist/common/code.js +21 -0
- package/dist/common/constants.js +5 -0
- package/dist/common/env.js +33 -0
- package/dist/common/logger.d.ts +34 -0
- package/dist/common/logger.js +82 -0
- package/dist/common/logo.js +54 -0
- package/dist/common/progress-bar.js +167 -0
- package/dist/common/transformer.js +13 -0
- package/dist/common/types.d.ts +10 -0
- package/dist/config/compose-override.js +18 -0
- package/dist/config/defaults.d.ts +74 -0
- package/dist/config/defaults.js +74 -0
- package/dist/config/define-config.d.ts +13 -0
- package/dist/config/define-config.js +6 -0
- package/dist/config/index.d.ts +5 -0
- package/dist/config/index.js +5 -0
- package/dist/config/load-config.d.ts +19 -0
- package/dist/config/load-config.js +73 -0
- package/dist/config/merge-config.d.ts +12 -0
- package/dist/config/merge-config.js +20 -0
- package/dist/config/types.d.ts +452 -0
- package/dist/constants.d.ts +35 -0
- package/dist/constants.js +146 -0
- package/dist/core/assets.d.ts +91 -0
- package/dist/core/assets.js +244 -0
- package/dist/core/bundler.d.ts +15 -0
- package/dist/core/bundler.js +80 -0
- package/dist/core/env.d.ts +11 -0
- package/dist/core/env.js +36 -0
- package/dist/core/fs/data.js +9 -0
- package/dist/core/fs/storage.d.ts +15 -0
- package/dist/core/fs/storage.js +31 -0
- package/dist/core/plugins/babel-plugin.d.ts +22 -0
- package/dist/core/plugins/babel-plugin.js +74 -0
- package/dist/core/plugins/context.d.ts +10 -0
- package/dist/core/plugins/context.js +24 -0
- package/dist/core/plugins/dev-server-plugin.d.ts +13 -0
- package/dist/core/plugins/dev-server-plugin.js +27 -0
- package/dist/core/plugins/index.d.ts +13 -0
- package/dist/core/plugins/index.js +18 -0
- package/dist/core/plugins/prelude-plugin.d.ts +10 -0
- package/dist/core/plugins/prelude-plugin.js +23 -0
- package/dist/core/plugins/react-native-plugin.d.ts +36 -0
- package/dist/core/plugins/react-native-plugin.js +81 -0
- package/dist/core/plugins/reporter-plugin.d.ts +11 -0
- package/dist/core/plugins/reporter-plugin.js +87 -0
- package/dist/core/plugins/shared/filters.js +5 -0
- package/dist/core/plugins/swc-plugin.d.ts +26 -0
- package/dist/core/plugins/swc-plugin.js +108 -0
- package/dist/core/plugins/types.d.ts +18 -0
- package/dist/core/plugins/utils/source.js +10 -0
- package/dist/core/plugins/utils/transform-utils.js +56 -0
- package/dist/core/rolldown.js +313 -0
- package/dist/core/settings.js +19 -0
- package/dist/core/types.d.ts +83 -0
- package/dist/filter.d.ts +1 -0
- package/dist/filter.js +2 -0
- package/dist/hmr-runtime.iife.js +5 -5
- package/dist/index.d.ts +24 -1221
- package/dist/index.js +19 -4029
- package/dist/internal/react-native.js +24 -0
- package/dist/logger.js +5 -0
- package/dist/node/cli-utils.d.ts +10 -0
- package/dist/node/cli-utils.js +28 -0
- package/dist/node/cli.d.ts +6 -0
- package/dist/node/cli.js +23 -0
- package/dist/node/commands/agent/action.js +91 -0
- package/dist/node/commands/agent/command.js +10 -0
- package/dist/node/commands/agent/index.js +2 -0
- package/dist/node/commands/bundle/action.js +33 -0
- package/dist/node/commands/bundle/command.js +96 -0
- package/dist/node/commands/bundle/index.js +2 -0
- package/dist/node/commands/start/action.js +37 -0
- package/dist/node/commands/start/command.js +93 -0
- package/dist/node/commands/start/debugger.js +79 -0
- package/dist/node/commands/start/index.js +2 -0
- package/dist/node/commands/start/setup-interactive-mode.d.ts +20 -0
- package/dist/node/commands/start/setup-interactive-mode.js +107 -0
- package/dist/node/constants.js +4 -0
- package/dist/node/logger.js +5 -0
- package/dist/node/types.d.ts +23 -0
- package/dist/node/utils.js +23 -0
- package/dist/package.js +4 -0
- package/dist/runtime.js +1 -1
- package/dist/server/bundle.d.ts +12 -0
- package/dist/server/bundle.js +55 -0
- package/dist/server/bundler-pool.d.ts +51 -0
- package/dist/server/bundler-pool.js +197 -0
- package/dist/server/common/schema.js +19 -0
- package/dist/server/constants.d.ts +6 -0
- package/dist/server/constants.js +6 -0
- package/dist/server/create-dev-server.d.ts +6 -0
- package/dist/server/create-dev-server.js +185 -0
- package/dist/server/error.js +9 -0
- package/dist/server/events/event-bus.d.ts +12 -0
- package/dist/server/events/event-bus.js +16 -0
- package/dist/server/events/types.d.ts +37 -0
- package/dist/server/events/types.js +6 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +3 -0
- package/dist/server/logger.js +33 -0
- package/dist/server/mcp/context.js +14 -0
- package/dist/server/mcp/server.js +86 -0
- package/dist/server/mcp/tools/app-log-diagnostics.js +37 -0
- package/dist/server/mcp/tools/build-diagnostics.js +97 -0
- package/dist/server/mcp/tools/build-info.js +33 -0
- package/dist/server/mcp/tools/device-diagnostics.js +52 -0
- package/dist/server/mcp/tools/index.js +277 -0
- package/dist/server/middlewares/request-logger.js +15 -0
- package/dist/server/middlewares/serve-assets.js +49 -0
- package/dist/server/middlewares/serve-bundle.js +72 -0
- package/dist/server/middlewares/sse.js +34 -0
- package/dist/server/middlewares/symbolicate.js +71 -0
- package/dist/server/sse/adapter.js +74 -0
- package/dist/server/sse/event-bus.js +26 -0
- package/dist/server/symbolicate.js +93 -0
- package/dist/server/types.d.ts +125 -0
- package/dist/server/wss/hmr-server.js +209 -0
- package/dist/server/wss/server.d.ts +9 -0
- package/dist/server/wss/server.js +70 -0
- package/dist/{runtime.d.cts → types/hmr.d.ts} +1 -12
- package/dist/types.d.ts +78 -0
- package/dist/utils/babel.js +11 -0
- package/dist/utils/build-options.js +17 -0
- package/dist/utils/bundle.js +6 -0
- package/dist/utils/config.d.ts +5 -0
- package/dist/utils/config.js +32 -0
- package/dist/utils/dev-server.js +51 -0
- package/dist/utils/env.js +7 -0
- package/dist/utils/errors.js +9 -0
- package/dist/utils/hash.js +8 -0
- package/dist/utils/id.js +28 -0
- package/dist/utils/node-resolve.js +42 -0
- package/dist/utils/promise.js +15 -0
- package/dist/utils/reporters.js +120 -0
- package/dist/utils/reset-cache.d.ts +8 -0
- package/dist/utils/reset-cache.js +25 -0
- package/dist/utils/response.js +91 -0
- package/dist/utils/run-build.d.ts +8 -0
- package/dist/utils/run-build.js +7 -0
- package/dist/utils/run-server.d.ts +6 -0
- package/dist/utils/run-server.js +20 -0
- package/dist/utils/runtime-target.js +9 -0
- package/dist/utils/serialize.js +10 -0
- package/dist/utils/server.js +6 -0
- package/dist/utils/storage.js +6 -0
- package/dist/utils/string.js +6 -0
- package/dist/utils/swc.js +10 -0
- package/dist/utils/terminal.js +86 -0
- package/dist/utils/url.js +23 -0
- package/package.json +56 -68
- package/dist/commands.cjs +0 -4008
- package/dist/commands.d.cts +0 -5
- package/dist/pluginutils.d.ts +0 -1
- package/dist/pluginutils.js +0 -2
- package/dist/runtime.cjs +0 -34
- /package/dist/{chunk-DXpK5_cz.js → chunk-DJV587Yu.js} +0 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { __require } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { GLOBAL_IDENTIFIER } from "../constants.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { isNotNil } from "es-toolkit";
|
|
5
|
+
//#region src/internal/react-native.ts
|
|
6
|
+
function getInitializeCorePath(basePath) {
|
|
7
|
+
return __require.resolve("react-native/Libraries/Core/InitializeCore", { paths: [basePath] });
|
|
8
|
+
}
|
|
9
|
+
function getPolyfillScriptPaths(reactNativePath) {
|
|
10
|
+
return __require(path.join(reactNativePath, "rn-get-polyfills"))();
|
|
11
|
+
}
|
|
12
|
+
function getGlobalVariables(dev, buildType) {
|
|
13
|
+
const isDevServerMode = dev && buildType === "serve";
|
|
14
|
+
return [
|
|
15
|
+
`var __BUNDLE_START_TIME__=globalThis.nativePerformanceNow?nativePerformanceNow():Date.now();`,
|
|
16
|
+
`var __DEV__=${dev};`,
|
|
17
|
+
`var ${GLOBAL_IDENTIFIER}=typeof globalThis!=='undefined'?globalThis:typeof global !== 'undefined'?global:typeof window!=='undefined'?window:this;`,
|
|
18
|
+
`var process=globalThis.process||{};process.env=process.env||{};process.env.NODE_ENV=process.env.NODE_ENV||"${dev ? "development" : "production"}";`,
|
|
19
|
+
isDevServerMode ? `var $RefreshReg$ = () => {};` : null,
|
|
20
|
+
isDevServerMode ? `var $RefreshSig$ = () => (v) => v;` : null
|
|
21
|
+
].filter(isNotNil);
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { getGlobalVariables, getInitializeCorePath, getPolyfillScriptPaths };
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommandDefinition } from "./types.js";
|
|
2
|
+
import { InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, setupInteractiveMode } from "./commands/start/setup-interactive-mode.js";
|
|
3
|
+
import { Command } from "@commander-js/extra-typings";
|
|
4
|
+
import { Command as Command$1 } from "@react-native-community/cli-types";
|
|
5
|
+
|
|
6
|
+
//#region src/node/cli-utils.d.ts
|
|
7
|
+
declare function createCommand<T>(commandDefinition: CommandDefinition<T>): Command;
|
|
8
|
+
declare function createReactNativeCliCommand<T>(commandDefinition: CommandDefinition<T>): Command$1;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createCommand, createReactNativeCliCommand };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Logo } from "../common/logo.js";
|
|
2
|
+
import { withErrorHandler } from "./utils.js";
|
|
3
|
+
import "./commands/start/setup-interactive-mode.js";
|
|
4
|
+
import { omit } from "es-toolkit";
|
|
5
|
+
import { Command } from "@commander-js/extra-typings";
|
|
6
|
+
//#region src/node/cli-utils.ts
|
|
7
|
+
function createCommand(commandDefinition) {
|
|
8
|
+
const { name, description, helpText, options, action } = commandDefinition;
|
|
9
|
+
const command = new Command(name).description(description);
|
|
10
|
+
if (options != null) for (const option of options) (option.required ? command.requiredOption.bind(command) : command.option.bind(command))(option.name, option.description ?? "", (value) => option.parse != null ? option.parse(value) : value, option.default);
|
|
11
|
+
if (helpText != null) command.addHelpText("after", `\n${helpText}`);
|
|
12
|
+
return command.action(withErrorHandler(async function(args) {
|
|
13
|
+
await action.call({ platforms: ["android", "ios"] }, args);
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
function createReactNativeCliCommand(commandDefinition) {
|
|
17
|
+
return {
|
|
18
|
+
name: commandDefinition.name,
|
|
19
|
+
description: commandDefinition.description,
|
|
20
|
+
options: commandDefinition.options?.map((option) => omit(option, ["required"])),
|
|
21
|
+
func: (_argv, cliConfig, args) => {
|
|
22
|
+
Logo.printOnce();
|
|
23
|
+
return commandDefinition.action.call({ platforms: Object.keys(cliConfig.platforms) }, args);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { createCommand, createReactNativeCliCommand };
|
package/dist/node/cli.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Logo } from "../common/logo.js";
|
|
3
|
+
import { version } from "../package.js";
|
|
4
|
+
import { createCommand } from "./cli-utils.js";
|
|
5
|
+
import { command } from "./commands/agent/command.js";
|
|
6
|
+
import "./commands/agent/index.js";
|
|
7
|
+
import { command as command$1 } from "./commands/bundle/command.js";
|
|
8
|
+
import "./commands/bundle/index.js";
|
|
9
|
+
import { command as command$2 } from "./commands/start/command.js";
|
|
10
|
+
import "./commands/start/index.js";
|
|
11
|
+
import { program } from "@commander-js/extra-typings";
|
|
12
|
+
//#region src/node/cli.ts
|
|
13
|
+
var cli_exports = /* @__PURE__ */ __exportAll({ run: () => run });
|
|
14
|
+
function run(argv) {
|
|
15
|
+
Logo.printOnce();
|
|
16
|
+
const cli = program.name("rollipop").version(version);
|
|
17
|
+
cli.addCommand(createCommand(command));
|
|
18
|
+
cli.addCommand(createCommand(command$1));
|
|
19
|
+
cli.addCommand(createCommand(command$2));
|
|
20
|
+
cli.parse(argv);
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { cli_exports };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { DEFAULT_HOST, DEFAULT_PORT } from "../../../server/constants.js";
|
|
2
|
+
import "../../../server/index.js";
|
|
3
|
+
//#region src/node/commands/agent/action.ts
|
|
4
|
+
const defaultBaseUrl = `http://${DEFAULT_HOST}:${DEFAULT_PORT}`;
|
|
5
|
+
function getAgentGuide(baseUrl = defaultBaseUrl) {
|
|
6
|
+
return [
|
|
7
|
+
"Rollipop Agent Guide",
|
|
8
|
+
"",
|
|
9
|
+
"Rollipop exposes build events and client logs through SSE, with optional MCP tooling.",
|
|
10
|
+
"Keep the dev server running, then connect your agent to one of these endpoints.",
|
|
11
|
+
"",
|
|
12
|
+
"Start the dev server:",
|
|
13
|
+
"",
|
|
14
|
+
" rollipop start --mcp --reset-cache",
|
|
15
|
+
"",
|
|
16
|
+
"Default endpoints:",
|
|
17
|
+
"",
|
|
18
|
+
` SSE events: ${baseUrl}/sse/events`,
|
|
19
|
+
` SSE client logs: ${baseUrl}/sse/client-logs`,
|
|
20
|
+
` MCP server: ${baseUrl}/mcp (requires start --mcp)`,
|
|
21
|
+
"",
|
|
22
|
+
"If you start Rollipop with custom --host, --port, or --https options,",
|
|
23
|
+
"adjust these URLs to match the running dev server.",
|
|
24
|
+
"",
|
|
25
|
+
"SSE usage:",
|
|
26
|
+
"",
|
|
27
|
+
` curl -N ${baseUrl}/sse/events`,
|
|
28
|
+
` curl -N ${baseUrl}/sse/client-logs`,
|
|
29
|
+
"",
|
|
30
|
+
" Event format:",
|
|
31
|
+
" event: <event_type>",
|
|
32
|
+
" data: <json_payload>",
|
|
33
|
+
" bundler-scoped events include bundlerId",
|
|
34
|
+
"",
|
|
35
|
+
" Useful event types:",
|
|
36
|
+
" bundle_build_started, bundle_build_done, bundle_build_failed",
|
|
37
|
+
" watch_change, hmr_failed, device_connected, device_disconnected",
|
|
38
|
+
" server_ready, cache_reset",
|
|
39
|
+
" client_log is streamed separately from /sse/client-logs",
|
|
40
|
+
"",
|
|
41
|
+
" bundle_build_done includes bundleFilePath for the file-system bundle.",
|
|
42
|
+
" Rollipop serves that file when it has been edited after the build,",
|
|
43
|
+
" which lets agents inspect or patch the final bundle for debugging.",
|
|
44
|
+
"",
|
|
45
|
+
"MCP setup:",
|
|
46
|
+
"",
|
|
47
|
+
" Add this to your project .mcp.json:",
|
|
48
|
+
"",
|
|
49
|
+
" {",
|
|
50
|
+
" \"mcpServers\": {",
|
|
51
|
+
" \"rollipop\": {",
|
|
52
|
+
" \"type\": \"http\",",
|
|
53
|
+
` "url": "${baseUrl}/mcp"`,
|
|
54
|
+
" }",
|
|
55
|
+
" }",
|
|
56
|
+
" }",
|
|
57
|
+
"",
|
|
58
|
+
" Tool discovery:",
|
|
59
|
+
" MCP clients discover supported tools by calling tools/list.",
|
|
60
|
+
" The response includes tool names, descriptions, and input schemas.",
|
|
61
|
+
" For Streamable HTTP, initialize first, then call tools/list with",
|
|
62
|
+
" the returned mcp-session-id header.",
|
|
63
|
+
"",
|
|
64
|
+
"External debugging:",
|
|
65
|
+
"",
|
|
66
|
+
" CDP debugging, runtime evaluation, runtime errors, network inspection,",
|
|
67
|
+
" and profiling can be handled by agent-cdp:",
|
|
68
|
+
" https://github.com/callstackincubator/agent-cdp",
|
|
69
|
+
"",
|
|
70
|
+
" React component tree inspection and React DevTools profiling can be",
|
|
71
|
+
" handled by agent-react-devtools:",
|
|
72
|
+
" https://github.com/callstackincubator/agent-react-devtools",
|
|
73
|
+
"",
|
|
74
|
+
"Agent workflow:",
|
|
75
|
+
"",
|
|
76
|
+
" 1. Run rollipop start and keep it running; add --mcp when using MCP tools.",
|
|
77
|
+
" 2. Use get_build_events or /sse/events before and after edits.",
|
|
78
|
+
" 3. Wait for bundle_build_done or bundle_build_failed for bundle builds.",
|
|
79
|
+
" For HMR edits, watch for watch_change, hmr_failed, and HMR client messages.",
|
|
80
|
+
" 4. Use get_bundler_status when you need the latest state for a known bundlerId.",
|
|
81
|
+
" 5. Use clear_build_* and clear_console_logs before focused diagnostics when old buffered data may be noisy.",
|
|
82
|
+
" 6. Use bundleFilePath from bundle_build_done when bundle-level debugging is needed.",
|
|
83
|
+
" 7. If the build fails, inspect the error payload, fix the code, and repeat.",
|
|
84
|
+
" 8. Use reset_cache when stale cache is suspected."
|
|
85
|
+
].join("\n");
|
|
86
|
+
}
|
|
87
|
+
const action = async () => {
|
|
88
|
+
console.log(getAgentGuide());
|
|
89
|
+
};
|
|
90
|
+
//#endregion
|
|
91
|
+
export { action, getAgentGuide };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { action, getAgentGuide } from "./action.js";
|
|
2
|
+
//#region src/node/commands/agent/command.ts
|
|
3
|
+
const command = {
|
|
4
|
+
name: "agent",
|
|
5
|
+
description: "Print guidance for connecting LLM agents to Rollipop diagnostics.",
|
|
6
|
+
helpText: getAgentGuide(),
|
|
7
|
+
action
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { command };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { loadConfig } from "../../../config/load-config.js";
|
|
2
|
+
import { resetCache } from "../../../utils/reset-cache.js";
|
|
3
|
+
import { runBuild } from "../../../utils/run-build.js";
|
|
4
|
+
import { logger } from "../../logger.js";
|
|
5
|
+
import "../../../index.js";
|
|
6
|
+
//#region src/node/commands/bundle/action.ts
|
|
7
|
+
const action = async function(options) {
|
|
8
|
+
if (!this.platforms.includes(options.platform)) throw new Error(`Unrecognized platform: ${options.platform}`);
|
|
9
|
+
const cwd = process.cwd();
|
|
10
|
+
const config = await loadConfig({
|
|
11
|
+
cwd,
|
|
12
|
+
mode: "production",
|
|
13
|
+
configFile: options.config,
|
|
14
|
+
context: { command: "bundle" }
|
|
15
|
+
});
|
|
16
|
+
if (options.resetCache) {
|
|
17
|
+
resetCache(cwd);
|
|
18
|
+
logger.info("The transform cache was reset");
|
|
19
|
+
}
|
|
20
|
+
if (options.entryFile) config.entry = options.entryFile;
|
|
21
|
+
await runBuild(config, {
|
|
22
|
+
platform: options.platform,
|
|
23
|
+
dev: options.dev,
|
|
24
|
+
minify: options.minify,
|
|
25
|
+
cache: options.cache,
|
|
26
|
+
...options.sourcemapOutput ? { sourcemap: true } : {},
|
|
27
|
+
outfile: options.bundleOutput,
|
|
28
|
+
sourcemapOutfile: options.sourcemapOutput,
|
|
29
|
+
assetsDir: options.assetsDest
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
//#endregion
|
|
33
|
+
export { action };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { parseBoolean, resolvePath } from "../../utils.js";
|
|
2
|
+
import { UNSUPPORTED_OPTION_DESCRIPTION } from "../../constants.js";
|
|
3
|
+
import { action } from "./action.js";
|
|
4
|
+
//#region src/node/commands/bundle/command.ts
|
|
5
|
+
const command = {
|
|
6
|
+
name: "bundle",
|
|
7
|
+
description: "Build the bundle for the provided JavaScript entry file.",
|
|
8
|
+
action,
|
|
9
|
+
options: [
|
|
10
|
+
{
|
|
11
|
+
name: "--config <string>",
|
|
12
|
+
description: "Path to the CLI configuration file",
|
|
13
|
+
parse: resolvePath
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "--entry-file <path>",
|
|
17
|
+
description: "Path to the root JS file, either absolute or relative to JS root"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "--platform <string>",
|
|
21
|
+
description: "Either \"ios\" or \"android\"",
|
|
22
|
+
default: "ios"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: "--dev [boolean]",
|
|
26
|
+
description: "If false, warnings are disabled and the bundle is minified",
|
|
27
|
+
parse: parseBoolean
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "--minify [boolean]",
|
|
31
|
+
description: "Allows overriding whether bundle is minified. This defaults to false if dev is true, and true if dev is false. Disabling minification can be useful for speeding up production builds for testing purposes.",
|
|
32
|
+
parse: parseBoolean
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: "--cache [boolean]",
|
|
36
|
+
description: "If false, the bundler will not load or store any cache",
|
|
37
|
+
parse: parseBoolean
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "--bundle-output <string>",
|
|
41
|
+
description: "File name where to store the resulting bundle, ex. /tmp/groups.bundle",
|
|
42
|
+
required: true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "--sourcemap-output <string>",
|
|
46
|
+
description: "File name where to store the sourcemap file for resulting bundle, ex. /tmp/groups.map"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "--sourcemap-sources-root <string>",
|
|
50
|
+
description: `Path to make sourcemap's sources entries relative to, ex. /root/dir`
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "--sourcemap-use-absolute-path",
|
|
54
|
+
description: "Report SourceMapURL using its full path"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: "--assets-dest <string>",
|
|
58
|
+
description: "Directory name where to store assets referenced in the bundle"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "--reset-cache",
|
|
62
|
+
description: "Removes cached files",
|
|
63
|
+
default: false
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: "--transformer <string>",
|
|
67
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "--bundle-encoding <string>",
|
|
71
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: "--max-workers <number>",
|
|
75
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "--unstable-transform-profile <string>",
|
|
79
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: "--asset-catalog-dest [string]",
|
|
83
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "--read-global-cache",
|
|
87
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "--resolver-option <string...>",
|
|
91
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
};
|
|
95
|
+
//#endregion
|
|
96
|
+
export { command };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { loadConfig } from "../../../config/load-config.js";
|
|
2
|
+
import { resetCache } from "../../../utils/reset-cache.js";
|
|
3
|
+
import { runServer } from "../../../utils/run-server.js";
|
|
4
|
+
import { logger } from "../../logger.js";
|
|
5
|
+
import { setupInteractiveMode } from "./setup-interactive-mode.js";
|
|
6
|
+
import "../../../index.js";
|
|
7
|
+
import { noop } from "es-toolkit";
|
|
8
|
+
//#region src/node/commands/start/action.ts
|
|
9
|
+
const action = async function(options) {
|
|
10
|
+
const cwd = process.cwd();
|
|
11
|
+
const config = await loadConfig({
|
|
12
|
+
cwd,
|
|
13
|
+
mode: "development",
|
|
14
|
+
configFile: options.config,
|
|
15
|
+
context: { command: "start" }
|
|
16
|
+
});
|
|
17
|
+
if (options.resetCache) {
|
|
18
|
+
resetCache(cwd);
|
|
19
|
+
logger.info("The transform cache was reset");
|
|
20
|
+
}
|
|
21
|
+
if (options.clientLogs === false) config.reporter = { update: noop };
|
|
22
|
+
const devServer = await runServer(config, {
|
|
23
|
+
buildOptions: { cache: options.cache },
|
|
24
|
+
port: options.port,
|
|
25
|
+
host: options.host,
|
|
26
|
+
https: options.https,
|
|
27
|
+
key: options.key,
|
|
28
|
+
cert: options.cert,
|
|
29
|
+
mcp: options.mcp
|
|
30
|
+
});
|
|
31
|
+
if (options.interactive) setupInteractiveMode({
|
|
32
|
+
devServer,
|
|
33
|
+
extraCommands: config.terminal?.extraCommands
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { action };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { DEFAULT_HOST, DEFAULT_PORT } from "../../../server/constants.js";
|
|
2
|
+
import "../../../server/index.js";
|
|
3
|
+
import { parseBoolean, resolvePath } from "../../utils.js";
|
|
4
|
+
import { UNSUPPORTED_OPTION_DESCRIPTION } from "../../constants.js";
|
|
5
|
+
import { action } from "./action.js";
|
|
6
|
+
//#region src/node/commands/start/command.ts
|
|
7
|
+
const command = {
|
|
8
|
+
name: "start",
|
|
9
|
+
description: "Start the React Native development server.",
|
|
10
|
+
action,
|
|
11
|
+
options: [
|
|
12
|
+
{
|
|
13
|
+
name: "--config <string>",
|
|
14
|
+
description: "Path to the CLI configuration file",
|
|
15
|
+
parse: resolvePath
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "--host <string>",
|
|
19
|
+
description: "Host to start the development server on",
|
|
20
|
+
default: DEFAULT_HOST
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "--port <number>",
|
|
24
|
+
description: "Port to start the development server on",
|
|
25
|
+
default: DEFAULT_PORT,
|
|
26
|
+
parse: Number
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "--reset-cache, --resetCache",
|
|
30
|
+
description: "Removes cached files"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: "--https",
|
|
34
|
+
description: "Enables https connections to the server"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: "--key <path>",
|
|
38
|
+
description: "Path to custom SSL key"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "--cert <path>",
|
|
42
|
+
description: "Path to custom SSL cert"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: "--no-interactive",
|
|
46
|
+
description: "Disables interactive mode"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
name: "--client-logs",
|
|
50
|
+
description: "[Deprecated] Enable plain text JavaScript log streaming for all connected apps. This feature is deprecated and will be removed in future.",
|
|
51
|
+
default: false
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "--cache [boolean]",
|
|
55
|
+
description: "If false, the bundler will not load or store any cache",
|
|
56
|
+
parse: parseBoolean
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "--mcp",
|
|
60
|
+
description: "Enable the MCP server at /mcp"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "--projectRoot <path>",
|
|
64
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
name: "--watchFolders <list>",
|
|
68
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
name: "--assetPlugins <list>",
|
|
72
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "--sourceExts <list>",
|
|
76
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "--max-workers <number>",
|
|
80
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "--transformer <string>",
|
|
84
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: "--custom-log-reporter-path, --customLogReporterPath <string>",
|
|
88
|
+
description: UNSUPPORTED_OPTION_DESCRIPTION
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
};
|
|
92
|
+
//#endregion
|
|
93
|
+
export { command };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { Logger } from "../../../common/logger.js";
|
|
2
|
+
import { logger } from "../../logger.js";
|
|
3
|
+
import { loadSettings, saveSettings } from "../../../core/settings.js";
|
|
4
|
+
import { merge } from "es-toolkit";
|
|
5
|
+
import { select } from "@inquirer/prompts";
|
|
6
|
+
//#region src/node/commands/start/debugger.ts
|
|
7
|
+
var DebuggerOpener = class DebuggerOpener {
|
|
8
|
+
projectRoot;
|
|
9
|
+
serverUrl;
|
|
10
|
+
static MAX_TARGETS_SHOWN = 10;
|
|
11
|
+
_prompting = false;
|
|
12
|
+
settings;
|
|
13
|
+
autoOpened = false;
|
|
14
|
+
static setAutoOpenEnabled(projectRoot, enabled) {
|
|
15
|
+
saveSettings(projectRoot, { devtools: { autoOpen: enabled } });
|
|
16
|
+
}
|
|
17
|
+
constructor(projectRoot, serverUrl) {
|
|
18
|
+
this.projectRoot = projectRoot;
|
|
19
|
+
this.serverUrl = serverUrl;
|
|
20
|
+
this.settings = loadSettings(projectRoot);
|
|
21
|
+
}
|
|
22
|
+
async openDebuggerForTarget(target) {
|
|
23
|
+
logger.debug(`Opening debugger for target: ${target.id}`);
|
|
24
|
+
try {
|
|
25
|
+
await fetch(new URL("/open-debugger?target=" + encodeURIComponent(target.id), this.serverUrl), { method: "POST" });
|
|
26
|
+
} catch (error) {
|
|
27
|
+
logger.error(`Failed to open debugger for ${target.title}`);
|
|
28
|
+
logger.debug("Reason", error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
async autoOpen() {
|
|
32
|
+
if (this.autoOpened) return;
|
|
33
|
+
this.autoOpened = true;
|
|
34
|
+
if (this.isAutoOpenEnabled()) await this.open();
|
|
35
|
+
}
|
|
36
|
+
async open() {
|
|
37
|
+
logger.debug("Fetching available debugging targets...");
|
|
38
|
+
const response = await fetch(new URL("/json/list", this.serverUrl), { method: "POST" });
|
|
39
|
+
if (response.status !== 200) throw new Error(`Unexpected status code: ${response.status}`);
|
|
40
|
+
const targets = await response.json();
|
|
41
|
+
if (!Array.isArray(targets)) throw new Error("Unexpected response format");
|
|
42
|
+
logger.debug(`Found ${targets.length} debugging targets:`);
|
|
43
|
+
if (targets.length === 0) logger.warn("No connected targets");
|
|
44
|
+
else if (targets.length === 1) {
|
|
45
|
+
const target = targets[0];
|
|
46
|
+
await this.openDebuggerForTarget(target);
|
|
47
|
+
} else {
|
|
48
|
+
if (targets.length > DebuggerOpener.MAX_TARGETS_SHOWN) logger.warn(`More than ${DebuggerOpener.MAX_TARGETS_SHOWN} debug targets available, showing the first ${DebuggerOpener.MAX_TARGETS_SHOWN}.`);
|
|
49
|
+
const slicedTargets = targets.slice(0, DebuggerOpener.MAX_TARGETS_SHOWN);
|
|
50
|
+
Logger.block();
|
|
51
|
+
this._prompting = true;
|
|
52
|
+
try {
|
|
53
|
+
const targetIndex = await select({
|
|
54
|
+
message: "Multiple debug targets available, please select:",
|
|
55
|
+
choices: slicedTargets.map((target, index) => ({
|
|
56
|
+
value: index,
|
|
57
|
+
name: `${target.title} (${target.description})`
|
|
58
|
+
}))
|
|
59
|
+
});
|
|
60
|
+
await this.openDebuggerForTarget(slicedTargets[targetIndex]);
|
|
61
|
+
} catch {} finally {
|
|
62
|
+
Logger.unblock();
|
|
63
|
+
this._prompting = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
isPrompting() {
|
|
68
|
+
return this._prompting;
|
|
69
|
+
}
|
|
70
|
+
isAutoOpenEnabled() {
|
|
71
|
+
return this.settings.devtools?.autoOpen ?? false;
|
|
72
|
+
}
|
|
73
|
+
setAutoOpenEnabled(enabled) {
|
|
74
|
+
const newSettings = this.settings = merge(this.settings, { devtools: { autoOpen: enabled } });
|
|
75
|
+
saveSettings(this.projectRoot, newSettings);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { DebuggerOpener };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Logger } from "../../../common/logger.js";
|
|
2
|
+
import { DevServer } from "../../../server/types.js";
|
|
3
|
+
//#region src/node/commands/start/setup-interactive-mode.d.ts
|
|
4
|
+
interface InteractiveCommand {
|
|
5
|
+
key: string;
|
|
6
|
+
shift?: boolean;
|
|
7
|
+
description: string | (() => string);
|
|
8
|
+
handler: (this: InteractiveCommandContext) => void;
|
|
9
|
+
}
|
|
10
|
+
interface InteractiveCommandContext {
|
|
11
|
+
server: DevServer;
|
|
12
|
+
logger: Logger;
|
|
13
|
+
}
|
|
14
|
+
interface InteractiveModeOptions {
|
|
15
|
+
devServer: DevServer;
|
|
16
|
+
extraCommands?: InteractiveCommand[];
|
|
17
|
+
}
|
|
18
|
+
declare function setupInteractiveMode(options: InteractiveModeOptions): void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { InteractiveCommand, InteractiveCommandContext, InteractiveModeOptions, setupInteractiveMode };
|