@snap/valdi 1.1.5 → 1.2.0

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 (82) hide show
  1. package/.metadata/.bazelrc.template +9 -3
  2. package/.metadata/MODULE.bazel.template +112 -3
  3. package/.metadata/bzl/patches/rules_python/1.9.0/BUILD.bazel.template +1 -0
  4. package/.metadata/bzl/patches/rules_python/1.9.0/remove_setuptools_spaces.patch.template +96 -0
  5. package/README.md +35 -1
  6. package/bundled-skills/registry.json +2 -1
  7. package/bundled-skills/skills/valdi-animations/skill.md +49 -0
  8. package/bundled-skills/skills/valdi-async/skill.md +3 -2
  9. package/bundled-skills/skills/valdi-bazel/skill.md +2 -6
  10. package/bundled-skills/skills/valdi-compiler/skill.md +4 -4
  11. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +18 -0
  12. package/bundled-skills/skills/valdi-error-handling/skill.md +1 -1
  13. package/bundled-skills/skills/valdi-gestures/skill.md +3 -3
  14. package/bundled-skills/skills/valdi-migrate/skill.md +2 -1
  15. package/bundled-skills/skills/valdi-mock-breakdown/skill.md +4 -4
  16. package/bundled-skills/skills/valdi-mock-to-module/skill.md +9 -6
  17. package/bundled-skills/skills/valdi-overview/skill.md +2 -1
  18. package/bundled-skills/skills/valdi-perf/skill.md +121 -5
  19. package/bundled-skills/skills/valdi-pr-review/skill.md +189 -0
  20. package/bundled-skills/skills/valdi-profile/skill.md +5 -3
  21. package/bundled-skills/skills/valdi-setup/skill.md +3 -6
  22. package/bundled-skills/skills/valdi-testing/skill.md +1 -1
  23. package/bundled-skills/skills/valdi-tsx/skill.md +47 -11
  24. package/debugger/README.md +356 -0
  25. package/debugger/debugger-actions.js +373 -0
  26. package/debugger/debugger-api.js +225 -0
  27. package/debugger/debugger-bootstrap.js +295 -0
  28. package/debugger/debugger-model.js +790 -0
  29. package/debugger/debugger-performance.js +573 -0
  30. package/debugger/debugger-preview-html.js +676 -0
  31. package/debugger/debugger-providers.js +389 -0
  32. package/debugger/debugger-render.js +529 -0
  33. package/debugger/debugger-runtime.js +387 -0
  34. package/debugger/debugger-session.js +188 -0
  35. package/debugger/debugger-settings.js +209 -0
  36. package/debugger/debugger-state.js +221 -0
  37. package/debugger/debugger-tree-model.js +539 -0
  38. package/debugger/debugger.css +1865 -0
  39. package/debugger/devtools-panel.css +1318 -0
  40. package/debugger/devtools-panel.html +273 -0
  41. package/debugger/devtools-panel.js +3329 -0
  42. package/debugger/index.html +279 -0
  43. package/dist/commands/bootstrap.js +6 -5
  44. package/dist/commands/build.js +6 -0
  45. package/dist/commands/debugger.js +163 -0
  46. package/dist/commands/doctor.js +5 -125
  47. package/dist/commands/inspect.js +5 -2
  48. package/dist/commands/inspect_commands/input.js +176 -0
  49. package/dist/commands/inspect_commands/snapshot.js +1 -1
  50. package/dist/commands/inspect_commands/tree.js +1 -1
  51. package/dist/commands/install.js +6 -0
  52. package/dist/commands/projectsync.js +15 -0
  53. package/dist/commands/webHotreload.js +31 -0
  54. package/dist/core/constants.js +26 -7
  55. package/dist/debugger/chromiumConsole.js +279 -0
  56. package/dist/debugger/inputClient.js +473 -0
  57. package/dist/debugger/server.js +3801 -0
  58. package/dist/debugger/targetRegistry.js +436 -0
  59. package/dist/debugger/webPreviewPerformance.js +864 -0
  60. package/dist/index.js +0 -0
  61. package/dist/setup/DevSetupHelper.js +0 -3
  62. package/dist/setup/linuxSetup.js +0 -14
  63. package/dist/setup/macOSSetup.js +1 -2
  64. package/dist/utils/BazelClient.js +34 -5
  65. package/dist/utils/applicationUtils.js +18 -0
  66. package/dist/utils/chromiumDevToolsClient.js +350 -0
  67. package/dist/utils/daemonClient.js +364 -44
  68. package/dist/utils/hermesClient.js +82 -176
  69. package/dist/utils/linuxDistro.js +0 -21
  70. package/dist/utils/loopbackHost.js +14 -0
  71. package/dist/utils/owlCdpClient.js +282 -0
  72. package/dist/utils/owlDevToolsExtension.js +142 -0
  73. package/dist/utils/skillsAdapters.js +40 -14
  74. package/dist/utils/stringUtils.js +13 -1
  75. package/package.json +4 -2
  76. package/dist/commands/inspect_commands/snapshot.spec.js +0 -105
  77. package/dist/core/packageFiles.spec.js +0 -29
  78. package/dist/preview/previewGenerator.spec.js +0 -203
  79. package/dist/preview/viewModelParser.spec.js +0 -171
  80. package/dist/utils/linuxDistro.spec.js +0 -170
  81. package/dist/utils/skillsAdapters.spec.js +0 -60
  82. package/dist/utils/stringUtils.spec.js +0 -81
@@ -11,7 +11,7 @@ const cliUtils_1 = require("../utils/cliUtils");
11
11
  const errorUtils_1 = require("../utils/errorUtils");
12
12
  const linuxDistro_1 = require("../utils/linuxDistro");
13
13
  const logUtils_1 = require("../utils/logUtils");
14
- const DISCORD_SUPPORT_URL = 'https://discord.gg/uJyNEeYX2U';
14
+ const SUPPORT_URL = 'https://github.com/Snapchat/Valdi/discussions';
15
15
  class ValdiDoctor {
16
16
  results = [];
17
17
  verbose;
@@ -48,9 +48,7 @@ class ValdiDoctor {
48
48
  await this.checkEssentialPlatformTools();
49
49
  await this.checkJavaInstallation();
50
50
  await this.checkCoreDependencies();
51
- await this.checkGitLfsInitialization();
52
51
  this.checkShellAutoComplete();
53
- await this.checkEditorExtensions();
54
52
  if (this.frameworkMode) {
55
53
  this.checkFrameworkDependencies();
56
54
  this.checkAdvancedAndroidSDK();
@@ -541,60 +539,6 @@ class ValdiDoctor {
541
539
  await this.checkSingleDependency('ios_webkit_debug_proxy', 'fail');
542
540
  }
543
541
  }
544
- async checkGitLfsInitialization() {
545
- if (!(0, cliUtils_1.checkCommandExists)('git-lfs')) {
546
- const fixCommand = this.getFixCommandForDependency('git-lfs');
547
- this.addResult({
548
- name: 'Git LFS',
549
- status: 'warn',
550
- message: 'git-lfs not installed',
551
- details: 'Required for working with large files in the repository',
552
- fixable: true,
553
- fixCommand,
554
- category: 'Development tools',
555
- });
556
- return;
557
- }
558
- try {
559
- const { stdout, returnCode } = await (0, cliUtils_1.runCliCommand)('git config --global --get filter.lfs.process');
560
- if (returnCode === 0 && stdout.trim()) {
561
- this.addResult({
562
- name: 'Git LFS initialization',
563
- status: 'pass',
564
- message: 'git-lfs is initialized',
565
- category: 'Development tools',
566
- });
567
- }
568
- else {
569
- this.addResult({
570
- name: 'Git LFS initialization',
571
- status: 'warn',
572
- message: 'git-lfs is installed but not initialized',
573
- details: 'Run git lfs install to configure Git LFS hooks',
574
- fixable: true,
575
- fixCommand: 'git lfs install',
576
- category: 'Development tools',
577
- });
578
- if (this.autoFix) {
579
- await this.attemptAutoFix('git-lfs', 'git lfs install');
580
- }
581
- }
582
- }
583
- catch {
584
- this.addResult({
585
- name: 'Git LFS initialization',
586
- status: 'warn',
587
- message: 'git-lfs is installed but not initialized',
588
- details: 'Run git lfs install to configure Git LFS hooks',
589
- fixable: true,
590
- fixCommand: 'git lfs install',
591
- category: 'Development tools',
592
- });
593
- if (this.autoFix) {
594
- await this.attemptAutoFix('git-lfs', 'git lfs install');
595
- }
596
- }
597
- }
598
542
  checkShellAutoComplete() {
599
543
  const homeDir = process.env['HOME'] ?? '';
600
544
  const shell = process.env['SHELL'] ?? '';
@@ -668,64 +612,6 @@ class ValdiDoctor {
668
612
  });
669
613
  }
670
614
  }
671
- async checkEditorExtensions() {
672
- const hasCode = (0, cliUtils_1.checkCommandExists)('code');
673
- const hasCursor = (0, cliUtils_1.checkCommandExists)('cursor');
674
- if (!hasCode && !hasCursor) {
675
- return;
676
- }
677
- let extensionsInstalled = false;
678
- if (hasCode) {
679
- try {
680
- const { stdout } = await (0, cliUtils_1.runCliCommand)('code --list-extensions');
681
- const installedExtensions = stdout.toLowerCase();
682
- const hasVivaldi = installedExtensions.includes('valdi-vivaldi');
683
- const hasDebug = installedExtensions.includes('valdi-debug');
684
- if (hasVivaldi && hasDebug) {
685
- extensionsInstalled = true;
686
- this.addResult({
687
- name: 'VSCode Extensions',
688
- status: 'pass',
689
- message: 'Valdi extensions installed in VSCode',
690
- category: 'Development tools',
691
- });
692
- }
693
- }
694
- catch {
695
- }
696
- }
697
- if (hasCursor) {
698
- try {
699
- const { stdout } = await (0, cliUtils_1.runCliCommand)('cursor --list-extensions');
700
- const installedExtensions = stdout.toLowerCase();
701
- const hasVivaldi = installedExtensions.includes('valdi-vivaldi');
702
- const hasDebug = installedExtensions.includes('valdi-debug');
703
- if (hasVivaldi && hasDebug) {
704
- extensionsInstalled = true;
705
- this.addResult({
706
- name: 'Cursor Extensions',
707
- status: 'pass',
708
- message: 'Valdi extensions installed in Cursor',
709
- category: 'Development tools',
710
- });
711
- }
712
- }
713
- catch {
714
- }
715
- }
716
- if (!extensionsInstalled && (hasCode || hasCursor)) {
717
- const editor = hasCode ? 'VSCode' : 'Cursor';
718
- this.addResult({
719
- name: `${editor} Extensions`,
720
- status: 'warn',
721
- message: 'Valdi editor extensions not installed',
722
- details: 'Extensions provide syntax highlighting, debugging, and device logs',
723
- fixable: true,
724
- fixCommand: 'See installation instructions: https://github.com/Snapchat/Valdi/blob/main/docs/INSTALL.md#vscodecursor-setup-optional-but-recommended',
725
- category: 'Development tools',
726
- });
727
- }
728
- }
729
615
  checkFrameworkDependencies() {
730
616
  if (os.platform() === 'darwin') {
731
617
  const temurinPath = '/opt/homebrew/opt/temurin';
@@ -764,7 +650,7 @@ class ValdiDoctor {
764
650
  if (['git', 'npm', 'watchman', 'ios_webkit_debug_proxy'].includes(dep)) {
765
651
  category = 'Development tools';
766
652
  }
767
- else if (['git-lfs', 'temurin'].includes(dep)) {
653
+ else if (['temurin'].includes(dep)) {
768
654
  category = 'Framework tools';
769
655
  }
770
656
  else {
@@ -854,9 +740,6 @@ class ValdiDoctor {
854
740
  case 'watchman': {
855
741
  return 'brew install watchman';
856
742
  }
857
- case 'git-lfs': {
858
- return 'brew install git-lfs';
859
- }
860
743
  case 'bazelisk': {
861
744
  return 'brew install bazelisk';
862
745
  }
@@ -888,9 +771,6 @@ class ValdiDoctor {
888
771
  }
889
772
  return cmd;
890
773
  }
891
- case 'git-lfs': {
892
- return (0, linuxDistro_1.buildInstallCommand)([(0, linuxDistro_1.getPackageName)(packageMappings['git-lfs'], this.linuxDistro)], this.linuxDistro);
893
- }
894
774
  case 'bazelisk': {
895
775
  return 'valdi dev_setup';
896
776
  }
@@ -970,8 +850,8 @@ class ValdiDoctor {
970
850
  console.log();
971
851
  console.log((0, logUtils_1.wrapInColor)('Some issues need to be resolved before Valdi can work properly.', constants_1.ANSI_COLORS.RED_COLOR));
972
852
  console.log();
973
- console.log((0, logUtils_1.wrapInColor)('Still having trouble? Come get help on Discord:', constants_1.ANSI_COLORS.BLUE_COLOR));
974
- console.log((0, logUtils_1.wrapInColor)(DISCORD_SUPPORT_URL, constants_1.ANSI_COLORS.BLUE_COLOR));
853
+ console.log((0, logUtils_1.wrapInColor)('Still having trouble? Ask for help in GitHub Discussions:', constants_1.ANSI_COLORS.BLUE_COLOR));
854
+ console.log((0, logUtils_1.wrapInColor)(SUPPORT_URL, constants_1.ANSI_COLORS.BLUE_COLOR));
975
855
  console.log((0, logUtils_1.wrapInColor)('Please paste the entire output of this command when asking for help.', constants_1.ANSI_COLORS.YELLOW_COLOR));
976
856
  }
977
857
  else if (totalWarnCount > 0) {
@@ -1020,7 +900,7 @@ const builder = (yargs) => {
1020
900
  alias: 'j',
1021
901
  })
1022
902
  .option('framework', {
1023
- describe: 'Include framework development checks (git-lfs, temurin, etc.)',
903
+ describe: 'Include framework development checks (temurin, etc.)',
1024
904
  type: 'boolean',
1025
905
  default: false,
1026
906
  alias: 'F',
@@ -5,8 +5,11 @@ exports.command = 'inspect <command>';
5
5
  exports.describe = 'Inspect a running Valdi app — component trees, contexts, screenshots, heap';
6
6
  const builder = (yargs) => {
7
7
  return yargs
8
- .commandDir('inspect_commands', { extensions: ['js', 'ts'] })
9
- .demandCommand(1, 'Use devices, select, status, contexts, tree, snapshot, or heap')
8
+ .commandDir('inspect_commands', {
9
+ extensions: ['js', 'ts'],
10
+ exclude: /\.spec\.(js|ts)$/,
11
+ })
12
+ .demandCommand(1, 'Use devices, select, status, contexts, tree, snapshot, input, or heap')
10
13
  .recommendCommands()
11
14
  .wrap(yargs.terminalWidth())
12
15
  .help();
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ exports.buildInputRequest = buildInputRequest;
5
+ const inputClient_1 = require("../../debugger/inputClient");
6
+ const daemonClient_1 = require("../../utils/daemonClient");
7
+ const errorUtils_1 = require("../../utils/errorUtils");
8
+ const INPUT_SELECTOR_FIELDS = new Set(['elementId', 'accessibilityId', 'tag']);
9
+ function parseSelector(selector) {
10
+ const trimmed = selector.trim();
11
+ if (!trimmed.startsWith('{')) {
12
+ return selector;
13
+ }
14
+ let parsed;
15
+ try {
16
+ parsed = JSON.parse(trimmed);
17
+ }
18
+ catch {
19
+ throw new Error('--selector must be a selector string or a JSON object.');
20
+ }
21
+ if (parsed === null || Array.isArray(parsed) || typeof parsed !== 'object') {
22
+ throw new Error('--selector JSON must be an object.');
23
+ }
24
+ const record = parsed;
25
+ const unknownKey = Object.keys(record)
26
+ .sort()
27
+ .find(key => !INPUT_SELECTOR_FIELDS.has(key));
28
+ if (unknownKey) {
29
+ throw new Error(`Unsupported selector field "${unknownKey}".`);
30
+ }
31
+ return record;
32
+ }
33
+ function addDefined(request, key, value) {
34
+ if (value !== undefined) {
35
+ request[key] = value;
36
+ }
37
+ }
38
+ function buildInputRequest(args) {
39
+ const selectorCount = [args.elementId, args.accessibilityId, args.selector].filter(value => value !== undefined).length;
40
+ if (selectorCount > 1) {
41
+ throw new Error('Use only one of --element-id, --accessibility-id, or --selector.');
42
+ }
43
+ if (args.action === inputClient_1.DebuggerInputType.Text && args.text === undefined) {
44
+ throw new Error('The text action requires --text.');
45
+ }
46
+ if (args.action === inputClient_1.DebuggerInputType.Key && args.key === undefined) {
47
+ throw new Error('The key action requires --key.');
48
+ }
49
+ const request = { type: args.action };
50
+ addDefined(request, 'elementId', args.elementId);
51
+ addDefined(request, 'accessibilityId', args.accessibilityId);
52
+ addDefined(request, 'selector', args.selector === undefined ? undefined : parseSelector(args.selector));
53
+ if (args.action === inputClient_1.DebuggerInputType.Focus) {
54
+ request['focused'] = args.focused;
55
+ }
56
+ addDefined(request, 'text', args.text);
57
+ addDefined(request, 'key', args.key);
58
+ addDefined(request, 'selectionStart', args.selectionStart);
59
+ addDefined(request, 'selectionEnd', args.selectionEnd);
60
+ addDefined(request, 'x', args.x);
61
+ addDefined(request, 'y', args.y);
62
+ addDefined(request, 'deltaX', args.deltaX);
63
+ addDefined(request, 'deltaY', args.deltaY);
64
+ const validationError = (0, inputClient_1.validateDebuggerInputRequest)(request);
65
+ if (validationError) {
66
+ throw new Error(validationError);
67
+ }
68
+ return request;
69
+ }
70
+ async function inspectInput(argv) {
71
+ const action = argv.getArgument('action');
72
+ const contextIdArg = argv.getArgument('contextId');
73
+ const port = argv.getArgument('port');
74
+ const clientOverride = argv.getArgument('client');
75
+ const request = buildInputRequest({
76
+ action,
77
+ elementId: argv.getArgument('elementId'),
78
+ accessibilityId: argv.getArgument('accessibilityId'),
79
+ selector: argv.getArgument('selector'),
80
+ focused: argv.getArgument('focused'),
81
+ text: argv.getArgument('text'),
82
+ key: argv.getArgument('key'),
83
+ selectionStart: argv.getArgument('selectionStart'),
84
+ selectionEnd: argv.getArgument('selectionEnd'),
85
+ x: argv.getArgument('x'),
86
+ y: argv.getArgument('y'),
87
+ deltaX: argv.getArgument('deltaX'),
88
+ deltaY: argv.getArgument('deltaY'),
89
+ });
90
+ const conn = await (0, daemonClient_1.connectToDaemon)(port);
91
+ try {
92
+ await conn.configure();
93
+ const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
94
+ const contextId = action === inputClient_1.DebuggerInputType.Capabilities ? undefined : await (0, daemonClient_1.resolveContextId)(conn, clientId, contextIdArg);
95
+ const requestWithContext = contextId === undefined ? request : { ...request, contextId };
96
+ const input = await (0, inputClient_1.sendDebuggerInput)(conn, clientId, requestWithContext);
97
+ console.log(JSON.stringify({ port, clientId, contextId, input }));
98
+ }
99
+ finally {
100
+ conn.close();
101
+ }
102
+ }
103
+ exports.command = 'input <action> [contextId]';
104
+ exports.describe = 'Query and control a live Valdi app through the default debugger input contract';
105
+ const builder = (yargs) => {
106
+ yargs
107
+ .positional('action', {
108
+ describe: 'Input operation',
109
+ choices: Object.values(inputClient_1.DebuggerInputType),
110
+ type: 'string',
111
+ })
112
+ .positional('contextId', {
113
+ describe: 'Context ID (omit to auto-select or be prompted)',
114
+ type: 'string',
115
+ })
116
+ .option('port', {
117
+ describe: 'Daemon TCP port (use 13591 for standalone macOS apps)',
118
+ type: 'number',
119
+ default: daemonClient_1.DEFAULT_PORT,
120
+ })
121
+ .option('client', {
122
+ describe: 'Client ID to target (from "valdi inspect devices")',
123
+ type: 'string',
124
+ })
125
+ .option('element-id', {
126
+ describe: 'Target a rendered element ID',
127
+ type: 'number',
128
+ })
129
+ .option('accessibility-id', {
130
+ describe: 'Target a stable accessibility ID',
131
+ type: 'string',
132
+ })
133
+ .option('selector', {
134
+ describe: 'Target #accessibilityId, [accessibilityId="..."], or a JSON selector object',
135
+ type: 'string',
136
+ })
137
+ .option('focused', {
138
+ describe: 'Focus state for the focus action; use --no-focused to blur',
139
+ type: 'boolean',
140
+ default: true,
141
+ })
142
+ .option('text', {
143
+ describe: 'Replacement text for the text action',
144
+ type: 'string',
145
+ })
146
+ .option('key', {
147
+ describe: 'Key for the key action (Enter, Return, Escape, Backspace, Delete, or one printable grapheme)',
148
+ type: 'string',
149
+ })
150
+ .option('selection-start', {
151
+ describe: 'Selection start for text and key actions',
152
+ type: 'number',
153
+ })
154
+ .option('selection-end', {
155
+ describe: 'Selection end for text and key actions',
156
+ type: 'number',
157
+ })
158
+ .option('x', {
159
+ describe: 'Absolute X coordinate for tap',
160
+ type: 'number',
161
+ })
162
+ .option('y', {
163
+ describe: 'Absolute Y coordinate for tap',
164
+ type: 'number',
165
+ })
166
+ .option('delta-x', {
167
+ describe: 'Horizontal content-offset delta for scroll',
168
+ type: 'number',
169
+ })
170
+ .option('delta-y', {
171
+ describe: 'Vertical content-offset delta for scroll',
172
+ type: 'number',
173
+ });
174
+ };
175
+ exports.builder = builder;
176
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(inspectInput);
@@ -71,7 +71,7 @@ async function inspectSnapshot(argv) {
71
71
  const contextId = await (0, daemonClient_1.resolveContextId)(conn, clientId, contextIdArg);
72
72
  let elementId = elementIdArg;
73
73
  if (keyOverride) {
74
- const tree = await conn.getContextTree(clientId, contextId);
74
+ const tree = await conn.getContextTree(clientId, contextId, false);
75
75
  const found = findElementByKey(tree, keyOverride);
76
76
  if (!found) {
77
77
  throw new Error(`No element found with key "${keyOverride}". Use "valdi inspect tree" to see available keys.`);
@@ -40,7 +40,7 @@ async function inspectTree(argv) {
40
40
  await conn.configure();
41
41
  const clientId = await (0, daemonClient_1.resolveClientId)(conn, clientOverride);
42
42
  const contextId = await (0, daemonClient_1.resolveContextId)(conn, clientId, contextIdArg);
43
- let tree = await conn.getContextTree(clientId, contextId);
43
+ let tree = await conn.getContextTree(clientId, contextId, false);
44
44
  if (maxDepth !== undefined) {
45
45
  tree = trimDepth(tree, maxDepth);
46
46
  }
@@ -36,6 +36,12 @@ async function valdiInstall(argv) {
36
36
  await bazel.runTarget(buildInfo.application, buildInfo.bazelArgs);
37
37
  break;
38
38
  }
39
+ case constants_1.PLATFORM.LINUX: {
40
+ (0, errorUtils_1.logReproduceThisCommandIfNeeded)(argv);
41
+ console.log('Running Linux application...');
42
+ await bazel.runTarget(buildInfo.application, buildInfo.bazelArgs);
43
+ break;
44
+ }
39
45
  case constants_1.PLATFORM.CLI: {
40
46
  (0, errorUtils_1.logReproduceThisCommandIfNeeded)(argv);
41
47
  console.log('Running CLI application...');
@@ -7,6 +7,7 @@ const tslib_1 = require("tslib");
7
7
  const fs_1 = tslib_1.__importDefault(require("fs"));
8
8
  const promises_1 = tslib_1.__importDefault(require("fs/promises"));
9
9
  const path_1 = tslib_1.__importDefault(require("path"));
10
+ const constants_1 = require("../core/constants");
10
11
  const errors_1 = require("../core/errors");
11
12
  const BazelClient_1 = require("../utils/BazelClient");
12
13
  const byString_1 = require("../utils/byString");
@@ -58,6 +59,19 @@ function bazelLabelToAbsolutePath(workspaceInfo, label) {
58
59
  return path_1.default.join(workspaceInfo.workspaceRoot, targetPath);
59
60
  }
60
61
  }
62
+ async function ensureStableExecConfig(workspaceRoot) {
63
+ const bazelrcPath = path_1.default.join(workspaceRoot, '.bazelrc');
64
+ if (!fs_1.default.existsSync(bazelrcPath)) {
65
+ return;
66
+ }
67
+ const content = await promises_1.default.readFile(bazelrcPath, 'utf8');
68
+ if (/(^|\n)[^\n#]*:stable_exec\b/.test(content)) {
69
+ return;
70
+ }
71
+ const separator = content.endsWith('\n') ? '\n' : '\n\n';
72
+ await promises_1.default.writeFile(bazelrcPath, content + separator + constants_1.STABLE_EXEC_BAZELRC_BLOCK);
73
+ console.log('Added the stable_exec config to .bazelrc so alternating builds and tests stop recompiling shared tools.');
74
+ }
61
75
  async function buildProjectSyncs(bazel, workspaceRoot, projectSyncTargets) {
62
76
  await bazel.buildTargets(projectSyncTargets);
63
77
  const buildOutputs = await bazel.queryBuildOutputs(projectSyncTargets);
@@ -272,6 +286,7 @@ async function runProjectSync(bazel, inputTargets, vscodeLaunchPath, generateLau
272
286
  console.log('Resolving dependencies of resolved Valdi targets...');
273
287
  const workspaceRoot = await bazel.getWorkspaceRoot();
274
288
  const executionRoot = await bazel.getExecutionRoot();
289
+ await ensureStableExecConfig(workspaceRoot);
275
290
  const allProjectSyncOutputs = await buildProjectSyncs(bazel, workspaceRoot, inputTargets);
276
291
  console.log('Generating tsconfig.json files...');
277
292
  const workspaceName = path_1.default.basename(executionRoot);
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.describe = exports.command = void 0;
4
+ const constants_1 = require("../core/constants");
5
+ const BazelClient_1 = require("../utils/BazelClient");
6
+ const errorUtils_1 = require("../utils/errorUtils");
7
+ const logUtils_1 = require("../utils/logUtils");
8
+ async function valdiWebHotreload(argv) {
9
+ const client = new BazelClient_1.BazelClient();
10
+ const target = argv.getArgument('target');
11
+ if (!target) {
12
+ throw new Error('--target is required (e.g. //apps/helloworld:dev)');
13
+ }
14
+ (0, errorUtils_1.logReproduceThisCommandIfNeeded)(argv);
15
+ console.log((0, logUtils_1.wrapInColor)(`Starting webpack-dev-server via ${target} ...`, constants_1.ANSI_COLORS.GREEN_COLOR));
16
+ await client.runTarget(target, '--define enable_web=true');
17
+ }
18
+ exports.command = 'web-hotreload --target <bazel-target>';
19
+ exports.describe = 'Start a Valdi web playground with hot module reload (webpack-dev-server). '
20
+ + 'Pass the Bazel label of the playground :dev target created by '
21
+ + 'valdi_web_playground(hmr_config = ...).';
22
+ const builder = (yargs) => {
23
+ yargs.option('target', {
24
+ describe: 'Bazel label of the playground :dev js_binary (e.g. //apps/helloworld:dev)',
25
+ type: 'string',
26
+ requiresArg: true,
27
+ demandOption: true,
28
+ });
29
+ };
30
+ exports.builder = builder;
31
+ exports.handler = (0, errorUtils_1.makeCommandHandler)(valdiWebHotreload);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEST_BUILD_FLAGS = exports.CLI_BUILD_FLAGS = exports.MACOS_BUILD_FLAGS = exports.IOS_BUILD_FLAGS = exports.IOS_DEVICE_BUILD_FLAGS = exports.RELEASE_BUILD_FLAGS = exports.DEBUG_BUILD_FLAGS = exports.ENABLE_RUNTIME_TRACES_BUILD_FLAGS = exports.ENABLE_RUNTIME_LOGS_BUILD_FLAGS = exports.ANDROID_X86_64_BUILD_FLAGS = exports.ANDROID_ARMV7_BUILD_FLAGS = exports.ANDROID_ARM64_BUILD_FLAGS = exports.ANDROID_BUILD_FLAGS = exports.COPY_CONFIG_PATH = exports.LINUX_SETUP_SCRIPT_DIR_PATH = exports.MACOS_SETUP_SCRIPT_DIR_PATH = exports.SETUP_SCRIPT_DIR_PATH = exports.BOOTSTRAP_DIR_PATH = exports.META_DIR_PATH = exports.CONFIG_DIR_PATH = exports.CLI_ROOT = exports.ANDROID_EXPORTED_LIBRARY_TAG = exports.IOS_EXPORTED_LIBRARY_TAG = exports.CLI_BAZEL_APPLICATION_TAG = exports.MACOS_BAZEL_APPLICATION_TAG = exports.ANDROID_BAZEL_APPLICATION_TAG = exports.IOS_BAZEL_APPLICATION_TAG = exports.VALID_PLATFORMS = exports.TEMPLATE_BASE_PATHS = exports.ALL_ARCHITECTURES = exports.Architecture = exports.PLATFORM = exports.ANSI_COLORS = exports.BAZEL_EXECUTABLES = exports.BAZEL_BIN_ENV = exports.VALDI_CONFIG_PATHS = void 0;
3
+ exports.TEST_BUILD_FLAGS = exports.CLI_BUILD_FLAGS = exports.LINUX_BUILD_FLAGS = exports.MACOS_BUILD_FLAGS = exports.IOS_BUILD_FLAGS = exports.IOS_DEVICE_BUILD_FLAGS = exports.RELEASE_BUILD_FLAGS = exports.DEBUG_BUILD_FLAGS = exports.ENABLE_RUNTIME_TRACES_BUILD_FLAGS = exports.ENABLE_RUNTIME_LOGS_BUILD_FLAGS = exports.STABLE_EXEC_BAZELRC_BLOCK = exports.STABLE_EXEC_BUILD_FLAGS = exports.ANDROID_X86_64_BUILD_FLAGS = exports.ANDROID_ARMV7_BUILD_FLAGS = exports.ANDROID_ARM64_BUILD_FLAGS = exports.ANDROID_BUILD_FLAGS = exports.COPY_CONFIG_PATH = exports.LINUX_SETUP_SCRIPT_DIR_PATH = exports.MACOS_SETUP_SCRIPT_DIR_PATH = exports.SETUP_SCRIPT_DIR_PATH = exports.BOOTSTRAP_DIR_PATH = exports.META_DIR_PATH = exports.CONFIG_DIR_PATH = exports.CLI_ROOT = exports.ANDROID_EXPORTED_LIBRARY_TAG = exports.IOS_EXPORTED_LIBRARY_TAG = exports.CLI_BAZEL_APPLICATION_TAG = exports.LINUX_BAZEL_APPLICATION_TAG = exports.MACOS_BAZEL_APPLICATION_TAG = exports.ANDROID_BAZEL_APPLICATION_TAG = exports.IOS_BAZEL_APPLICATION_TAG = exports.VALID_PLATFORMS = exports.TEMPLATE_BASE_PATHS = exports.ALL_ARCHITECTURES = exports.Architecture = exports.PLATFORM = exports.ANSI_COLORS = exports.BAZEL_EXECUTABLES = exports.BAZEL_BIN_ENV = exports.VALDI_CONFIG_PATHS = void 0;
4
+ exports.androidPlatformsFlag = androidPlatformsFlag;
4
5
  const tslib_1 = require("tslib");
5
6
  const path_1 = tslib_1.__importDefault(require("path"));
6
7
  exports.VALDI_CONFIG_PATHS = ['~/.valdi/config.yaml', '~/.valdi/config.yml'];
@@ -20,6 +21,7 @@ var PLATFORM;
20
21
  PLATFORM["IOS"] = "ios";
21
22
  PLATFORM["ANDROID"] = "android";
22
23
  PLATFORM["MACOS"] = "macos";
24
+ PLATFORM["LINUX"] = "linux";
23
25
  PLATFORM["CLI"] = "cli";
24
26
  })(PLATFORM || (exports.PLATFORM = PLATFORM = {}));
25
27
  var Architecture;
@@ -43,11 +45,14 @@ var TEMPLATE_BASE_PATHS;
43
45
  TEMPLATE_BASE_PATHS["GIT_IGNORE"] = ".gitignore.template";
44
46
  TEMPLATE_BASE_PATHS["EDITOR_CONFIG"] = ".editorconfig.template";
45
47
  TEMPLATE_BASE_PATHS["AGENTS"] = "AGENTS.md.template";
48
+ TEMPLATE_BASE_PATHS["RULES_PYTHON_PATCH"] = "bzl/patches/rules_python/1.9.0/remove_setuptools_spaces.patch.template";
49
+ TEMPLATE_BASE_PATHS["RULES_PYTHON_PATCH_BUILD"] = "bzl/patches/rules_python/1.9.0/BUILD.bazel.template";
46
50
  })(TEMPLATE_BASE_PATHS || (exports.TEMPLATE_BASE_PATHS = TEMPLATE_BASE_PATHS = {}));
47
- exports.VALID_PLATFORMS = [PLATFORM.ANDROID, PLATFORM.IOS, PLATFORM.MACOS, PLATFORM.CLI];
51
+ exports.VALID_PLATFORMS = [PLATFORM.ANDROID, PLATFORM.IOS, PLATFORM.MACOS, PLATFORM.LINUX, PLATFORM.CLI];
48
52
  exports.IOS_BAZEL_APPLICATION_TAG = 'valdi_ios_application';
49
53
  exports.ANDROID_BAZEL_APPLICATION_TAG = 'valdi_android_application';
50
54
  exports.MACOS_BAZEL_APPLICATION_TAG = 'valdi_macos_application';
55
+ exports.LINUX_BAZEL_APPLICATION_TAG = 'valdi_linux_application';
51
56
  exports.CLI_BAZEL_APPLICATION_TAG = 'valdi_cli_application';
52
57
  exports.IOS_EXPORTED_LIBRARY_TAG = 'valdi_ios_exported_library';
53
58
  exports.ANDROID_EXPORTED_LIBRARY_TAG = 'valdi_android_exported_library';
@@ -60,12 +65,25 @@ exports.MACOS_SETUP_SCRIPT_DIR_PATH = path_1.default.join(exports.SETUP_SCRIPT_D
60
65
  exports.LINUX_SETUP_SCRIPT_DIR_PATH = path_1.default.join(exports.SETUP_SCRIPT_DIR_PATH, 'linux');
61
66
  exports.COPY_CONFIG_PATH = path_1.default.join(exports.CONFIG_DIR_PATH, 'copyconfig.json');
62
67
  exports.ANDROID_BUILD_FLAGS = ['--copt=-DANDROID_WITH_JNI', '--repo_env=VALDI_PLATFORM_DEPENDENCIES=android'];
63
- function androidCpuFlags(cpu) {
64
- return [`--fat_apk_cpu=${cpu}`, `--android_cpu=${cpu}`];
68
+ exports.ANDROID_ARM64_BUILD_FLAGS = ['--define', 'client_repo_arm64=true'];
69
+ exports.ANDROID_ARMV7_BUILD_FLAGS = ['--define', 'client_repo_arm32=true'];
70
+ exports.ANDROID_X86_64_BUILD_FLAGS = ['--define', 'client_repo_x86_64=true'];
71
+ const ANDROID_PLATFORMS = {
72
+ [Architecture.ARM64]: '@snap_platforms//os:android_arm64',
73
+ [Architecture.ARMV7]: '@snap_platforms//os:android_arm32',
74
+ [Architecture.X86_64]: '@snap_platforms//os:android_x86_64',
75
+ };
76
+ function androidPlatformsFlag(architectures) {
77
+ return `--android_platforms=${architectures.map(architecture => ANDROID_PLATFORMS[architecture]).join(',')}`;
65
78
  }
66
- exports.ANDROID_ARM64_BUILD_FLAGS = ['--define', 'client_repo_arm64=true', ...androidCpuFlags('arm64-v8a')];
67
- exports.ANDROID_ARMV7_BUILD_FLAGS = ['--define', 'client_repo_arm32=true', ...androidCpuFlags('armeabi-v7a')];
68
- exports.ANDROID_X86_64_BUILD_FLAGS = ['--define', 'client_repo_x86_64=true', ...androidCpuFlags('x86_64')];
79
+ exports.STABLE_EXEC_BUILD_FLAGS = ['--config=stable_exec'];
80
+ exports.STABLE_EXEC_BAZELRC_BLOCK = `# Alternating a Valdi test target and a web/npm target trims test-only options
81
+ # differently, so their exec tool configs collide under one output path and
82
+ # recompile thousands of shared tool actions. Opt-in config that the \`valdi\`
83
+ # CLI passes to its build/test flows so they converge; raw \`bazel\` keeps the
84
+ # default. Changing test flags (e.g. --test_output) repopulates it once.
85
+ build:stable_exec --notrim_test_configuration
86
+ `;
69
87
  exports.ENABLE_RUNTIME_LOGS_BUILD_FLAGS = ['--@valdi//bzl/runtime_flags:enable_logging'];
70
88
  exports.ENABLE_RUNTIME_TRACES_BUILD_FLAGS = ['--@valdi//bzl/runtime_flags:enable_tracing'];
71
89
  exports.DEBUG_BUILD_FLAGS = ['--snap_flavor=platform_development'];
@@ -74,5 +92,6 @@ exports.IOS_DEVICE_BUILD_FLAGS = '--ios_multi_cpus=arm64';
74
92
  exports.IOS_BUILD_FLAGS = '--repo_env=VALDI_PLATFORM_DEPENDENCIES=ios';
75
93
  const INLINE_ASSETS_BUILD_FLAGS = ['--@valdi//bzl/valdi:assets_mode=inline'];
76
94
  exports.MACOS_BUILD_FLAGS = [...INLINE_ASSETS_BUILD_FLAGS, '--repo_env=VALDI_PLATFORM_DEPENDENCIES=macos'];
95
+ exports.LINUX_BUILD_FLAGS = [...INLINE_ASSETS_BUILD_FLAGS, '--repo_env=VALDI_PLATFORM_DEPENDENCIES=linux'];
77
96
  exports.CLI_BUILD_FLAGS = [...INLINE_ASSETS_BUILD_FLAGS, '--repo_env=VALDI_PLATFORM_DEPENDENCIES=cli'];
78
97
  exports.TEST_BUILD_FLAGS = INLINE_ASSETS_BUILD_FLAGS;