@snap/valdi 1.0.7 → 1.0.11

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 (170) hide show
  1. package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/BUILD.bazel.template +16 -1
  2. package/.bootstrap/modules/polyglot_bridge_module/web/Calculator.ts +11 -0
  3. package/.bootstrap/modules/polyglot_bridge_module/web/tsconfig.json +16 -0
  4. package/.bootstrap/modules/polyglot_view_module/BUILD.bazel.template +75 -0
  5. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeView.kt.template +41 -0
  6. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeViewAttributesBinder.kt.template +17 -0
  7. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.h +8 -0
  8. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.m +23 -0
  9. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.h +8 -0
  10. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.m +23 -0
  11. package/.bootstrap/modules/polyglot_view_module/src/PolyglotCustomView.tsx.template +23 -0
  12. package/.bootstrap/modules/polyglot_view_module/web/PolyglotWeb.ts.template +30 -0
  13. package/.bootstrap/modules/polyglot_view_module/web/tsconfig.json +16 -0
  14. package/.metadata/AGENTS.md.template +8 -274
  15. package/.metadata/skill-reference.tsx.template +8 -0
  16. package/.metadata/skill-tests-BUILD.bazel.template +21 -0
  17. package/.metadata/skill-tests-README.md.template +17 -0
  18. package/.metadata/skill.md.template +27 -0
  19. package/README.md +12 -3
  20. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  21. package/bundled-skills/registry.json +21 -0
  22. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  23. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  24. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  25. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  26. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  27. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  28. package/bundled-skills/skills/valdi-bazel/skill.md +141 -0
  29. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  30. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  31. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  32. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  33. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  34. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  35. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  37. package/bundled-skills/skills/valdi-custom-view/skill.md +64 -0
  38. package/bundled-skills/skills/valdi-inspect/skill.md +199 -0
  39. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  40. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  41. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  42. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  43. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  44. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  45. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  46. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  47. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  48. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  49. package/bundled-skills/skills/valdi-overview/skill.md +63 -0
  50. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  51. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  52. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  53. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  54. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  55. package/bundled-skills/skills/valdi-polyglot-module/skill.md +124 -0
  56. package/bundled-skills/skills/valdi-profile/skill.md +126 -0
  57. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  58. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  59. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  60. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  61. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  62. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  63. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  64. package/dist/commands/bootstrap.js +0 -7
  65. package/dist/commands/inspect.js +16 -0
  66. package/dist/commands/inspect_commands/contexts.js +55 -0
  67. package/dist/commands/inspect_commands/devices.js +53 -0
  68. package/dist/commands/inspect_commands/heap.js +59 -0
  69. package/dist/commands/inspect_commands/select.js +43 -0
  70. package/dist/commands/inspect_commands/snapshot.js +64 -0
  71. package/dist/commands/inspect_commands/status.js +68 -0
  72. package/dist/commands/inspect_commands/tree.js +86 -0
  73. package/dist/commands/newModule.js +10 -14
  74. package/dist/commands/profile.js +16 -0
  75. package/dist/commands/profile_commands/capture.js +106 -0
  76. package/dist/commands/skills.js +16 -0
  77. package/dist/commands/skills_commands/create.js +125 -0
  78. package/dist/commands/skills_commands/install.js +96 -0
  79. package/dist/commands/skills_commands/list.js +83 -0
  80. package/dist/commands/skills_commands/remove.js +41 -0
  81. package/dist/commands/skills_commands/update.js +59 -0
  82. package/dist/core/constants.js +0 -1
  83. package/dist/core/packageFiles.spec.js +29 -0
  84. package/dist/setup/versions.js +1 -1
  85. package/dist/utils/daemonClient.js +342 -0
  86. package/dist/utils/hermesClient.js +252 -0
  87. package/dist/utils/skillsAdapters.js +140 -0
  88. package/dist/utils/skillsRegistry.js +40 -0
  89. package/dist/utils/stringUtils.spec.js +1 -1
  90. package/package.json +20 -5
  91. package/.bazelignore +0 -2
  92. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  93. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  94. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  95. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  96. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  97. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  98. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  99. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  100. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  101. package/.config/copyconfig.json +0 -10
  102. package/.editorconfig +0 -21
  103. package/.eslintignore +0 -1
  104. package/.eslintrc.js +0 -72
  105. package/.github/README.md +0 -164
  106. package/.metadata/.cursorrules.template +0 -60
  107. package/.prettierignore +0 -2
  108. package/.prettierrc.json +0 -7
  109. package/LINUX_COMPATIBILITY.md +0 -248
  110. package/prettier.config.js +0 -4
  111. package/scripts/sync-agents-md.sh +0 -44
  112. package/scripts/update-agents-templates.ts +0 -170
  113. package/spec/support/jasmine.json +0 -6
  114. package/src/commands/bootstrap.ts +0 -410
  115. package/src/commands/build.ts +0 -89
  116. package/src/commands/devSetup.ts +0 -17
  117. package/src/commands/doctor.ts +0 -1832
  118. package/src/commands/export.ts +0 -131
  119. package/src/commands/hotreload.ts +0 -108
  120. package/src/commands/install.ts +0 -93
  121. package/src/commands/lint.ts +0 -15
  122. package/src/commands/lint_commands/lintCheck.ts +0 -53
  123. package/src/commands/lint_commands/lintFormat.ts +0 -49
  124. package/src/commands/log.ts +0 -108
  125. package/src/commands/newModule.ts +0 -286
  126. package/src/commands/package.ts +0 -102
  127. package/src/commands/projectsync.ts +0 -488
  128. package/src/commands/test.ts +0 -68
  129. package/src/core/constants.ts +0 -98
  130. package/src/core/errors.ts +0 -10
  131. package/src/index.ts +0 -27
  132. package/src/setup/DevSetupHelper.ts +0 -290
  133. package/src/setup/linuxSetup.ts +0 -261
  134. package/src/setup/macOSSetup.ts +0 -156
  135. package/src/setup/setupEntryPoint.ts +0 -64
  136. package/src/setup/versions.ts +0 -8
  137. package/src/utils/ArgumentsResolver.ts +0 -23
  138. package/src/utils/BazelClient.ts +0 -285
  139. package/src/utils/Digraph.ts +0 -81
  140. package/src/utils/LoadingIndicator.ts +0 -43
  141. package/src/utils/applicationUtils.ts +0 -276
  142. package/src/utils/buildInfo.ts +0 -99
  143. package/src/utils/byString.ts +0 -3
  144. package/src/utils/cliUtils.ts +0 -112
  145. package/src/utils/copyBootstrapFiles.ts +0 -30
  146. package/src/utils/deviceUtils.ts +0 -76
  147. package/src/utils/errorUtils.ts +0 -63
  148. package/src/utils/fileUtils.ts +0 -257
  149. package/src/utils/githubUtils.ts +0 -102
  150. package/src/utils/jsonUtils.ts +0 -30
  151. package/src/utils/lintUtils.ts +0 -190
  152. package/src/utils/linuxDistro.spec.ts +0 -219
  153. package/src/utils/linuxDistro.ts +0 -326
  154. package/src/utils/logUtils.ts +0 -9
  155. package/src/utils/pathUtils.ts +0 -12
  156. package/src/utils/stringUtils.spec.ts +0 -95
  157. package/src/utils/stringUtils.ts +0 -103
  158. package/src/utils/tempDir.ts +0 -24
  159. package/src/utils/zipUtils.ts +0 -14
  160. package/test/ValdiSmokeTest.ts +0 -279
  161. package/test/helpers/AsyncHelpers.ts +0 -113
  162. package/test/helpers/CommandHelpers.ts +0 -37
  163. package/test/helpers/ProjectHelpers.ts +0 -153
  164. package/test/helpers/StreamHelpers.ts +0 -37
  165. package/test/helpers/TypeScriptClient.ts +0 -217
  166. package/tsconfig.dist.json +0 -8
  167. package/tsconfig.json +0 -42
  168. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/android/CalculatorModuleFactory.kt.template +0 -0
  169. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/ios/SCCCalculatorModuleFactory.m.template +0 -0
  170. /package/.bootstrap/modules/{cpp_bridge_module → polyglot_bridge_module}/src/Calculator.d.ts +0 -0
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const constants_1 = require("../../core/constants");
7
+ const logUtils_1 = require("../../utils/logUtils");
8
+ async function inspectContexts(argv) {
9
+ const port = argv.getArgument('port');
10
+ const clientOverride = argv.getArgument('client');
11
+ const pretty = argv.getArgument('pretty');
12
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
13
+ try {
14
+ await conn.configure();
15
+ const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
16
+ const contexts = await conn.listContexts(clientId);
17
+ if (pretty) {
18
+ if (contexts.length === 0) {
19
+ console.log((0, logUtils_1.wrapInColor)('No active contexts found.', constants_1.ANSI_COLORS.YELLOW_COLOR));
20
+ return;
21
+ }
22
+ console.log((0, logUtils_1.wrapInColor)(`${contexts.length} context(s) on device ${clientId}:\n`, constants_1.ANSI_COLORS.GRAY_COLOR));
23
+ for (const ctx of contexts) {
24
+ console.log(` ${(0, logUtils_1.wrapInColor)(ctx.id, constants_1.ANSI_COLORS.BLUE_COLOR)} ${ctx.rootComponentName}`);
25
+ }
26
+ }
27
+ else {
28
+ console.log(JSON.stringify(contexts));
29
+ }
30
+ }
31
+ finally {
32
+ conn.close();
33
+ }
34
+ }
35
+ exports.command = 'contexts';
36
+ exports.describe = 'List active Valdi root contexts (components) on the device';
37
+ const builder = (yargs) => {
38
+ yargs
39
+ .option('port', {
40
+ describe: 'Daemon TCP port',
41
+ type: 'number',
42
+ default: daemonClient_1.DEFAULT_PORT,
43
+ })
44
+ .option('client', {
45
+ describe: 'Client ID to target (from "valdi inspect devices")',
46
+ type: 'string',
47
+ })
48
+ .option('pretty', {
49
+ describe: 'Human-readable output instead of JSON',
50
+ type: 'boolean',
51
+ default: false,
52
+ });
53
+ };
54
+ exports.builder = builder;
55
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectContexts);
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const constants_1 = require("../../core/constants");
7
+ const logUtils_1 = require("../../utils/logUtils");
8
+ async function inspectDevices(argv) {
9
+ const port = argv.getArgument('port');
10
+ const pretty = argv.getArgument('pretty');
11
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
12
+ try {
13
+ await conn.configure();
14
+ const clients = await conn.listConnectedClients();
15
+ if (pretty) {
16
+ if (clients.length === 0) {
17
+ console.log((0, logUtils_1.wrapInColor)('No devices connected to the Valdi daemon.', constants_1.ANSI_COLORS.YELLOW_COLOR));
18
+ return;
19
+ }
20
+ const nameWidth = 30;
21
+ const platWidth = 12;
22
+ console.log((0, logUtils_1.wrapInColor)(['CLIENT ID'.padEnd(36), 'PLATFORM'.padEnd(platWidth), 'APPLICATION ID'.padEnd(nameWidth)].join(' '), constants_1.ANSI_COLORS.GRAY_COLOR));
23
+ console.log((0, logUtils_1.wrapInColor)('-'.repeat(36 + platWidth + nameWidth + 4), constants_1.ANSI_COLORS.GRAY_COLOR));
24
+ for (const c of clients) {
25
+ console.log([c.client_id.padEnd(36), c.platform.padEnd(platWidth), c.application_id.padEnd(nameWidth)].join(' '));
26
+ }
27
+ console.log((0, logUtils_1.wrapInColor)(`\n${clients.length} device(s) connected`, constants_1.ANSI_COLORS.GRAY_COLOR));
28
+ }
29
+ else {
30
+ console.log(JSON.stringify(clients));
31
+ }
32
+ }
33
+ finally {
34
+ conn.close();
35
+ }
36
+ }
37
+ exports.command = 'devices';
38
+ exports.describe = 'List devices connected to the Valdi daemon';
39
+ const builder = (yargs) => {
40
+ yargs
41
+ .option('port', {
42
+ describe: 'Daemon TCP port',
43
+ type: 'number',
44
+ default: daemonClient_1.DEFAULT_PORT,
45
+ })
46
+ .option('pretty', {
47
+ describe: 'Human-readable output instead of JSON',
48
+ type: 'boolean',
49
+ default: false,
50
+ });
51
+ };
52
+ exports.builder = builder;
53
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectDevices);
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const constants_1 = require("../../core/constants");
7
+ const logUtils_1 = require("../../utils/logUtils");
8
+ async function inspectHeap(argv) {
9
+ const gc = argv.getArgument('gc');
10
+ const port = argv.getArgument('port');
11
+ const clientOverride = argv.getArgument('client');
12
+ const pretty = argv.getArgument('pretty');
13
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
14
+ try {
15
+ await conn.configure();
16
+ const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
17
+ const result = await conn.dumpHeap(clientId, gc);
18
+ if (pretty) {
19
+ const heap = result;
20
+ if (heap?.memoryUsageBytes !== undefined) {
21
+ const mb = (heap.memoryUsageBytes / 1024 / 1024).toFixed(2);
22
+ console.log(`Memory usage: ${(0, logUtils_1.wrapInColor)(`${mb} MB`, constants_1.ANSI_COLORS.YELLOW_COLOR)} (${heap.memoryUsageBytes} bytes)`);
23
+ }
24
+ console.log(JSON.stringify(result, null, 2));
25
+ }
26
+ else {
27
+ console.log(JSON.stringify(result));
28
+ }
29
+ }
30
+ finally {
31
+ conn.close();
32
+ }
33
+ }
34
+ exports.command = 'heap';
35
+ exports.describe = 'Dump JS heap stats for the connected device';
36
+ const builder = (yargs) => {
37
+ yargs
38
+ .option('gc', {
39
+ describe: 'Run garbage collection before dumping heap',
40
+ type: 'boolean',
41
+ default: false,
42
+ })
43
+ .option('port', {
44
+ describe: 'Daemon TCP port',
45
+ type: 'number',
46
+ default: daemonClient_1.DEFAULT_PORT,
47
+ })
48
+ .option('client', {
49
+ describe: 'Client ID to target (from "valdi inspect devices")',
50
+ type: 'string',
51
+ })
52
+ .option('pretty', {
53
+ describe: 'Human-readable output instead of JSON',
54
+ type: 'boolean',
55
+ default: false,
56
+ });
57
+ };
58
+ exports.builder = builder;
59
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectHeap);
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const cliUtils_1 = require("../../utils/cliUtils");
7
+ const errors_1 = require("../../core/errors");
8
+ const constants_1 = require("../../core/constants");
9
+ const logUtils_1 = require("../../utils/logUtils");
10
+ async function inspectSelect(argv) {
11
+ const port = argv.getArgument('port');
12
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
13
+ try {
14
+ await conn.configure();
15
+ const clients = await conn.listConnectedClients();
16
+ if (clients.length === 0) {
17
+ throw new errors_1.CliError('No devices connected to the Valdi daemon.');
18
+ }
19
+ const clientId = await (0, cliUtils_1.getUserChoice)(clients.map((c) => ({
20
+ name: `${c.application_id} (${c.platform}) [${c.client_id}]`,
21
+ value: c.client_id,
22
+ })), 'Select a device to use for inspect commands:');
23
+ const config = (0, daemonClient_1.loadInspectConfig)();
24
+ (0, daemonClient_1.saveInspectConfig)({ ...config, selectedClientId: clientId });
25
+ const chosen = clients.find((c) => c.client_id === clientId);
26
+ console.log(`Selected: ${(0, logUtils_1.wrapInColor)(chosen.application_id, constants_1.ANSI_COLORS.GREEN_COLOR)} (${chosen.platform})`);
27
+ console.log((0, logUtils_1.wrapInColor)(`Saved to ~/.valdi-inspect.json`, constants_1.ANSI_COLORS.GRAY_COLOR));
28
+ }
29
+ finally {
30
+ conn.close();
31
+ }
32
+ }
33
+ exports.command = 'select';
34
+ exports.describe = 'Interactively select a device and save it for subsequent inspect commands';
35
+ const builder = (yargs) => {
36
+ yargs.option('port', {
37
+ describe: 'Daemon TCP port',
38
+ type: 'number',
39
+ default: daemonClient_1.DEFAULT_PORT,
40
+ });
41
+ };
42
+ exports.builder = builder;
43
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectSelect);
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const os = tslib_1.__importStar(require("os"));
8
+ const errorUtils_1 = require("../../utils/errorUtils");
9
+ const daemonClient_1 = require("../../utils/daemonClient");
10
+ const constants_1 = require("../../core/constants");
11
+ const logUtils_1 = require("../../utils/logUtils");
12
+ async function inspectSnapshot(argv) {
13
+ const elementId = argv.getArgument('elementId');
14
+ const contextIdArg = argv.getArgument('contextId');
15
+ const port = argv.getArgument('port');
16
+ const clientOverride = argv.getArgument('client');
17
+ const outputOverride = argv.getArgument('output');
18
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
19
+ try {
20
+ await conn.configure();
21
+ const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
22
+ const contextId = await (0, daemonClient_1.resolveContextId)(conn, clientId, contextIdArg);
23
+ const base64Data = await conn.takeSnapshot(clientId, elementId, contextId);
24
+ const outPath = outputOverride
25
+ ? path.resolve(outputOverride)
26
+ : path.join(os.tmpdir(), `valdi-snapshot-${elementId}.png`);
27
+ fs.writeFileSync(outPath, Buffer.from(base64Data, 'base64'));
28
+ console.log(JSON.stringify({ path: outPath }));
29
+ console.error((0, logUtils_1.wrapInColor)(`Screenshot saved: ${outPath}`, constants_1.ANSI_COLORS.GREEN_COLOR));
30
+ }
31
+ finally {
32
+ conn.close();
33
+ }
34
+ }
35
+ exports.command = 'snapshot <elementId> [contextId]';
36
+ exports.describe = 'Capture a screenshot of an element and write it to a PNG file';
37
+ const builder = (yargs) => {
38
+ yargs
39
+ .positional('elementId', {
40
+ describe: 'Element ID to screenshot',
41
+ type: 'string',
42
+ demandOption: true,
43
+ })
44
+ .positional('contextId', {
45
+ describe: 'Context ID containing the element (omit to auto-select or be prompted)',
46
+ type: 'string',
47
+ })
48
+ .option('port', {
49
+ describe: 'Daemon TCP port',
50
+ type: 'number',
51
+ default: daemonClient_1.DEFAULT_PORT,
52
+ })
53
+ .option('client', {
54
+ describe: 'Client ID to target (from "valdi inspect devices")',
55
+ type: 'string',
56
+ })
57
+ .option('output', {
58
+ describe: 'Output PNG file path (defaults to /tmp/valdi-snapshot-<elementId>.png)',
59
+ type: 'string',
60
+ alias: 'o',
61
+ });
62
+ };
63
+ exports.builder = builder;
64
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectSnapshot);
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ const constants_1 = require("../../core/constants");
7
+ const logUtils_1 = require("../../utils/logUtils");
8
+ async function inspectStatus(argv) {
9
+ const port = argv.getArgument('port');
10
+ const pretty = argv.getArgument('pretty');
11
+ let connected = false;
12
+ let clientCount = 0;
13
+ let error;
14
+ try {
15
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
16
+ try {
17
+ await conn.configure();
18
+ const clients = await conn.listConnectedClients();
19
+ connected = true;
20
+ clientCount = clients.length;
21
+ }
22
+ finally {
23
+ conn.close();
24
+ }
25
+ }
26
+ catch (err) {
27
+ error = err instanceof Error ? err.message : String(err);
28
+ }
29
+ const result = {
30
+ connected,
31
+ port,
32
+ connectedDevices: clientCount,
33
+ portName: port === daemonClient_1.MOBILE_PORT ? 'mobile' : port === daemonClient_1.STANDALONE_PORT ? 'standalone' : 'custom',
34
+ error: error ?? null,
35
+ };
36
+ if (pretty) {
37
+ const statusColor = connected ? constants_1.ANSI_COLORS.GREEN_COLOR : constants_1.ANSI_COLORS.RED_COLOR;
38
+ const statusLabel = connected ? '● connected' : '○ not connected';
39
+ console.log(`Daemon status: ${(0, logUtils_1.wrapInColor)(statusLabel, statusColor)}`);
40
+ console.log(`Port: ${(0, logUtils_1.wrapInColor)(String(port), constants_1.ANSI_COLORS.BLUE_COLOR)} (${result.portName})`);
41
+ if (connected) {
42
+ console.log(`Connected devices: ${(0, logUtils_1.wrapInColor)(String(clientCount), constants_1.ANSI_COLORS.GREEN_COLOR)}`);
43
+ }
44
+ if (error) {
45
+ console.log((0, logUtils_1.wrapInColor)(error, constants_1.ANSI_COLORS.RED_COLOR));
46
+ }
47
+ }
48
+ else {
49
+ console.log(JSON.stringify(result));
50
+ }
51
+ }
52
+ exports.command = 'status';
53
+ exports.describe = 'Check Valdi daemon connection status and connected device count';
54
+ const builder = (yargs) => {
55
+ yargs
56
+ .option('port', {
57
+ describe: 'Daemon TCP port',
58
+ type: 'number',
59
+ default: daemonClient_1.DEFAULT_PORT,
60
+ })
61
+ .option('pretty', {
62
+ describe: 'Human-readable output instead of JSON',
63
+ type: 'boolean',
64
+ default: false,
65
+ });
66
+ };
67
+ exports.builder = builder;
68
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectStatus);
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const errorUtils_1 = require("../../utils/errorUtils");
5
+ const daemonClient_1 = require("../../utils/daemonClient");
6
+ function trimDepth(node, depth) {
7
+ if (depth <= 0 || node === null || typeof node !== 'object')
8
+ return node;
9
+ const obj = node;
10
+ const result = {};
11
+ for (const key of Object.keys(obj)) {
12
+ if (key === 'children') {
13
+ const children = obj['children'];
14
+ if (depth === 1) {
15
+ const count = Array.isArray(children) ? children.length : 0;
16
+ if (count > 0)
17
+ result['_childrenTrimmed'] = count;
18
+ }
19
+ else if (Array.isArray(children)) {
20
+ result['children'] = children.map((c) => trimDepth(c, depth - 1));
21
+ }
22
+ else {
23
+ result['children'] = children;
24
+ }
25
+ }
26
+ else {
27
+ result[key] = obj[key];
28
+ }
29
+ }
30
+ return result;
31
+ }
32
+ async function inspectTree(argv) {
33
+ const contextIdArg = argv.getArgument('contextId');
34
+ const port = argv.getArgument('port');
35
+ const clientOverride = argv.getArgument('client');
36
+ const pretty = argv.getArgument('pretty');
37
+ const maxDepth = argv.getArgument('maxDepth');
38
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
39
+ try {
40
+ await conn.configure();
41
+ const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
42
+ const contextId = await (0, daemonClient_1.resolveContextId)(conn, clientId, contextIdArg);
43
+ let tree = await conn.getContextTree(clientId, contextId);
44
+ if (maxDepth !== undefined) {
45
+ tree = trimDepth(tree, maxDepth);
46
+ }
47
+ if (pretty) {
48
+ console.log(JSON.stringify(tree, null, 2));
49
+ }
50
+ else {
51
+ console.log(JSON.stringify(tree));
52
+ }
53
+ }
54
+ finally {
55
+ conn.close();
56
+ }
57
+ }
58
+ exports.command = 'tree [contextId]';
59
+ exports.describe = 'Get the full rendered virtual node tree for a context';
60
+ const builder = (yargs) => {
61
+ yargs
62
+ .positional('contextId', {
63
+ describe: 'Context ID (omit to auto-select or be prompted)',
64
+ type: 'string',
65
+ })
66
+ .option('port', {
67
+ describe: 'Daemon TCP port',
68
+ type: 'number',
69
+ default: daemonClient_1.DEFAULT_PORT,
70
+ })
71
+ .option('client', {
72
+ describe: 'Client ID to target (from "valdi inspect devices")',
73
+ type: 'string',
74
+ })
75
+ .option('pretty', {
76
+ describe: 'Pretty-print JSON output',
77
+ type: 'boolean',
78
+ default: false,
79
+ })
80
+ .option('max-depth', {
81
+ describe: 'Trim the tree to this many levels deep (children beyond the limit are replaced with _childrenTrimmed count)',
82
+ type: 'number',
83
+ });
84
+ };
85
+ exports.builder = builder;
86
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectTree);
@@ -30,9 +30,10 @@ my_application/ # Root directory of your application
30
30
  └── modules/
31
31
  ├── module_a/
32
32
  │ ├── BUILD.bazel
33
- │ ├── android/ # Native Android sources
34
- │ ├── ios/ # Native iOS sources
35
- │ ├── cpp/ # Native C++ sources
33
+ │ ├── android/ # Native Android sources (Kotlin)
34
+ │ ├── ios/ # Native iOS sources (Objective-C)
35
+ │ ├── macos/ # Native macOS sources (Objective-C)
36
+ │ ├── web/ # Web sources (TypeScript, compiled by tsc)
36
37
  │ └── src/ # Valdi sources
37
38
  │ └── ModuleAComponent.tsx
38
39
  ├── module_b/
@@ -54,19 +55,14 @@ const ALL_MODULE_TEMPLATES = [
54
55
  description: `Exports a Valdi component, which can render UI elements`,
55
56
  },
56
57
  {
57
- name: 'iOS/Android Bridge module',
58
- path: 'ios_android_bridge_module',
59
- description: `Bridge module with a TypeScript API backed by Objective-C and Kotlin implementation`,
58
+ name: 'Polyglot Bridge module',
59
+ path: 'polyglot_bridge_module',
60
+ description: `Bridge module with a TypeScript API backed by Kotlin (Android), Objective-C (iOS), and TypeScript (Web/macOS)`,
60
61
  },
61
62
  {
62
- name: 'C++ Bridge module',
63
- path: 'cpp_bridge_module',
64
- description: `Bridge module with a TypeScript API backed by a cross-platform C++ implementation`,
65
- },
66
- {
67
- name: 'iOS/Android View module',
68
- path: 'ios_android_view_module',
69
- description: `iOS and Android view exported to TypeScript, rendered through a Valdi component`,
63
+ name: 'Polyglot View module',
64
+ path: 'polyglot_view_module',
65
+ description: `Native view with <custom-view> implementations for all platforms: Android, iOS, macOS, and Web`,
70
66
  },
71
67
  ];
72
68
  async function promptChecks() {
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ exports.command = 'profile <command>';
5
+ exports.describe = 'Capture a CPU profile from the Hermes JS runtime';
6
+ const builder = (yargs) => {
7
+ return yargs
8
+ .commandDir('profile_commands', { extensions: ['js', 'ts'] })
9
+ .demandCommand(1, 'Use: capture')
10
+ .recommendCommands()
11
+ .wrap(yargs.terminalWidth())
12
+ .help();
13
+ };
14
+ exports.builder = builder;
15
+ const handler = () => { };
16
+ exports.handler = handler;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const os = tslib_1.__importStar(require("os"));
8
+ const ora_1 = tslib_1.__importDefault(require("ora"));
9
+ const errorUtils_1 = require("../../utils/errorUtils");
10
+ const hermesClient_1 = require("../../utils/hermesClient");
11
+ const errors_1 = require("../../core/errors");
12
+ const cliUtils_1 = require("../../utils/cliUtils");
13
+ const constants_1 = require("../../core/constants");
14
+ const logUtils_1 = require("../../utils/logUtils");
15
+ async function profileCapture(argv) {
16
+ const duration = argv.getArgument('duration');
17
+ const outputOverride = argv.getArgument('output');
18
+ const port = argv.getArgument('port');
19
+ const contextOverride = argv.getArgument('context');
20
+ const devices = await (0, hermesClient_1.listHermesDevices)(port);
21
+ if (devices.length === 0) {
22
+ throw new errors_1.CliError('No debuggable JS contexts found. Make sure the Valdi app is running.');
23
+ }
24
+ let targetId;
25
+ if (contextOverride) {
26
+ if (!devices.some((d) => d.id === contextOverride)) {
27
+ throw new errors_1.CliError(`Context "${contextOverride}" not found.\n` +
28
+ `Available: ${devices.map((d) => d.id).join(', ')}`);
29
+ }
30
+ targetId = contextOverride;
31
+ }
32
+ else if (devices.length === 1) {
33
+ targetId = devices[0].id;
34
+ }
35
+ else {
36
+ targetId = await (0, cliUtils_1.getUserChoice)(devices.map((d) => ({ name: `${d.id} ${d.title}`, value: d.id })), 'Multiple JS contexts found. Select one:');
37
+ }
38
+ const conn = await hermesClient_1.HermesConnection.connect(port, targetId);
39
+ try {
40
+ await conn.startProfiling();
41
+ const startMs = Date.now();
42
+ const spinner = (0, ora_1.default)({ stream: process.stderr });
43
+ await new Promise((resolve) => {
44
+ let timer;
45
+ const stop = () => {
46
+ if (timer)
47
+ clearTimeout(timer);
48
+ process.off('SIGINT', stop);
49
+ process.exitCode = 0;
50
+ resolve();
51
+ };
52
+ if (duration !== undefined) {
53
+ spinner.start(`Profiling context "${targetId}"… (${duration}s)`);
54
+ timer = setTimeout(stop, duration * 1000);
55
+ }
56
+ else {
57
+ spinner.start(`Profiling context "${targetId}"… (Ctrl+C to stop)`);
58
+ }
59
+ process.once('SIGINT', stop);
60
+ });
61
+ spinner.text = 'Stopping profiler…';
62
+ const profile = await conn.stopProfiling();
63
+ spinner.stop();
64
+ const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
65
+ const outPath = outputOverride
66
+ ? path.resolve(outputOverride)
67
+ : path.join(os.tmpdir(), `valdi-profile-${timestamp}.cpuprofile`);
68
+ fs.writeFileSync(outPath, JSON.stringify(profile), 'utf8');
69
+ const elapsedS = ((Date.now() - startMs) / 1000).toFixed(1);
70
+ const sampleCount = profile.samples?.length ?? 0;
71
+ const sizeKb = Math.round(fs.statSync(outPath).size / 1024);
72
+ console.log(JSON.stringify({ path: outPath }));
73
+ console.error((0, logUtils_1.wrapInColor)(`Profile saved: ${outPath}`, constants_1.ANSI_COLORS.GREEN_COLOR) + '\n' +
74
+ ` Duration: ${elapsedS}s | Samples: ${sampleCount} | Size: ${sizeKb} KB\n` +
75
+ ` Open in: Chrome DevTools → Performance → Load | speedscope.app`);
76
+ }
77
+ finally {
78
+ conn.close();
79
+ }
80
+ }
81
+ exports.command = 'capture';
82
+ exports.describe = 'Capture a CPU profile from the Hermes JS runtime';
83
+ const builder = (yargs) => {
84
+ yargs
85
+ .option('duration', {
86
+ describe: 'Profile for N seconds then stop automatically (omit to stop with Ctrl+C)',
87
+ type: 'number',
88
+ alias: 'd',
89
+ })
90
+ .option('output', {
91
+ describe: 'Output .cpuprofile file path (default: /tmp/valdi-profile-<timestamp>.cpuprofile)',
92
+ type: 'string',
93
+ alias: 'o',
94
+ })
95
+ .option('port', {
96
+ describe: 'Hermes debug socket port',
97
+ type: 'number',
98
+ default: hermesClient_1.HERMES_PORT,
99
+ })
100
+ .option('context', {
101
+ describe: 'JS context ID to profile (from /json/list); auto-selected if only one',
102
+ type: 'string',
103
+ });
104
+ };
105
+ exports.builder = builder;
106
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(profileCapture);
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ exports.command = 'skills <command>';
5
+ exports.describe = 'Manage AI assistant skills for Valdi development';
6
+ const builder = (yargs) => {
7
+ return yargs
8
+ .commandDir('skills_commands', { extensions: ['js', 'ts'] })
9
+ .demandCommand(1, 'Use list, install, update, remove, or add')
10
+ .recommendCommands()
11
+ .wrap(yargs.terminalWidth())
12
+ .help();
13
+ };
14
+ exports.builder = builder;
15
+ const handler = () => { };
16
+ exports.handler = handler;