@snap/valdi 1.1.7 → 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 (74) hide show
  1. package/.metadata/.bazelrc.template +8 -2
  2. package/.metadata/MODULE.bazel.template +20 -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-cpp-runtime/skill.md +18 -0
  11. package/bundled-skills/skills/valdi-error-handling/skill.md +1 -1
  12. package/bundled-skills/skills/valdi-gestures/skill.md +3 -3
  13. package/bundled-skills/skills/valdi-migrate/skill.md +2 -1
  14. package/bundled-skills/skills/valdi-mock-breakdown/skill.md +4 -4
  15. package/bundled-skills/skills/valdi-mock-to-module/skill.md +9 -6
  16. package/bundled-skills/skills/valdi-overview/skill.md +2 -1
  17. package/bundled-skills/skills/valdi-perf/skill.md +121 -5
  18. package/bundled-skills/skills/valdi-pr-review/skill.md +189 -0
  19. package/bundled-skills/skills/valdi-profile/skill.md +5 -3
  20. package/bundled-skills/skills/valdi-setup/skill.md +3 -6
  21. package/bundled-skills/skills/valdi-testing/skill.md +1 -1
  22. package/bundled-skills/skills/valdi-tsx/skill.md +47 -11
  23. package/debugger/README.md +356 -0
  24. package/debugger/debugger-actions.js +373 -0
  25. package/debugger/debugger-api.js +225 -0
  26. package/debugger/debugger-bootstrap.js +295 -0
  27. package/debugger/debugger-model.js +790 -0
  28. package/debugger/debugger-performance.js +573 -0
  29. package/debugger/debugger-preview-html.js +676 -0
  30. package/debugger/debugger-providers.js +389 -0
  31. package/debugger/debugger-render.js +529 -0
  32. package/debugger/debugger-runtime.js +387 -0
  33. package/debugger/debugger-session.js +188 -0
  34. package/debugger/debugger-settings.js +209 -0
  35. package/debugger/debugger-state.js +221 -0
  36. package/debugger/debugger-tree-model.js +539 -0
  37. package/debugger/debugger.css +1865 -0
  38. package/debugger/devtools-panel.css +1318 -0
  39. package/debugger/devtools-panel.html +273 -0
  40. package/debugger/devtools-panel.js +3329 -0
  41. package/debugger/index.html +279 -0
  42. package/dist/commands/bootstrap.js +6 -5
  43. package/dist/commands/debugger.js +163 -0
  44. package/dist/commands/doctor.js +3 -62
  45. package/dist/commands/inspect.js +5 -2
  46. package/dist/commands/inspect_commands/input.js +176 -0
  47. package/dist/commands/inspect_commands/snapshot.js +1 -1
  48. package/dist/commands/inspect_commands/tree.js +1 -1
  49. package/dist/commands/projectsync.js +15 -0
  50. package/dist/commands/webHotreload.js +31 -0
  51. package/dist/core/constants.js +22 -6
  52. package/dist/debugger/chromiumConsole.js +279 -0
  53. package/dist/debugger/inputClient.js +473 -0
  54. package/dist/debugger/server.js +3801 -0
  55. package/dist/debugger/targetRegistry.js +436 -0
  56. package/dist/debugger/webPreviewPerformance.js +864 -0
  57. package/dist/index.js +0 -0
  58. package/dist/utils/BazelClient.js +34 -5
  59. package/dist/utils/applicationUtils.js +3 -0
  60. package/dist/utils/chromiumDevToolsClient.js +350 -0
  61. package/dist/utils/daemonClient.js +364 -44
  62. package/dist/utils/hermesClient.js +82 -176
  63. package/dist/utils/loopbackHost.js +14 -0
  64. package/dist/utils/owlCdpClient.js +282 -0
  65. package/dist/utils/owlDevToolsExtension.js +142 -0
  66. package/dist/utils/stringUtils.js +13 -1
  67. package/package.json +4 -2
  68. package/dist/commands/inspect_commands/snapshot.spec.js +0 -105
  69. package/dist/core/packageFiles.spec.js +0 -29
  70. package/dist/preview/previewGenerator.spec.js +0 -203
  71. package/dist/preview/viewModelParser.spec.js +0 -171
  72. package/dist/utils/linuxDistro.spec.js +0 -122
  73. package/dist/utils/skillsAdapters.spec.js +0 -141
  74. package/dist/utils/stringUtils.spec.js +0 -81
@@ -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
  }
@@ -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.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.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;
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'];
@@ -44,6 +45,8 @@ var TEMPLATE_BASE_PATHS;
44
45
  TEMPLATE_BASE_PATHS["GIT_IGNORE"] = ".gitignore.template";
45
46
  TEMPLATE_BASE_PATHS["EDITOR_CONFIG"] = ".editorconfig.template";
46
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";
47
50
  })(TEMPLATE_BASE_PATHS || (exports.TEMPLATE_BASE_PATHS = TEMPLATE_BASE_PATHS = {}));
48
51
  exports.VALID_PLATFORMS = [PLATFORM.ANDROID, PLATFORM.IOS, PLATFORM.MACOS, PLATFORM.LINUX, PLATFORM.CLI];
49
52
  exports.IOS_BAZEL_APPLICATION_TAG = 'valdi_ios_application';
@@ -62,12 +65,25 @@ exports.MACOS_SETUP_SCRIPT_DIR_PATH = path_1.default.join(exports.SETUP_SCRIPT_D
62
65
  exports.LINUX_SETUP_SCRIPT_DIR_PATH = path_1.default.join(exports.SETUP_SCRIPT_DIR_PATH, 'linux');
63
66
  exports.COPY_CONFIG_PATH = path_1.default.join(exports.CONFIG_DIR_PATH, 'copyconfig.json');
64
67
  exports.ANDROID_BUILD_FLAGS = ['--copt=-DANDROID_WITH_JNI', '--repo_env=VALDI_PLATFORM_DEPENDENCIES=android'];
65
- function androidCpuFlags(cpu) {
66
- 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(',')}`;
67
78
  }
68
- exports.ANDROID_ARM64_BUILD_FLAGS = ['--define', 'client_repo_arm64=true', ...androidCpuFlags('arm64-v8a')];
69
- exports.ANDROID_ARMV7_BUILD_FLAGS = ['--define', 'client_repo_arm32=true', ...androidCpuFlags('armeabi-v7a')];
70
- 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
+ `;
71
87
  exports.ENABLE_RUNTIME_LOGS_BUILD_FLAGS = ['--@valdi//bzl/runtime_flags:enable_logging'];
72
88
  exports.ENABLE_RUNTIME_TRACES_BUILD_FLAGS = ['--@valdi//bzl/runtime_flags:enable_tracing'];
73
89
  exports.DEBUG_BUILD_FLAGS = ['--snap_flavor=platform_development'];
@@ -0,0 +1,279 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChromiumConsoleSource = exports.ChromiumConsoleLevel = exports.MAX_CHROMIUM_CONSOLE_MESSAGE_LENGTH = void 0;
4
+ exports.formatChromiumConsoleEvent = formatChromiumConsoleEvent;
5
+ exports.MAX_CHROMIUM_CONSOLE_MESSAGE_LENGTH = 16_384;
6
+ const MAX_CONSOLE_ARGUMENTS = 64;
7
+ const MAX_CONSOLE_FRAGMENT_LENGTH = exports.MAX_CHROMIUM_CONSOLE_MESSAGE_LENGTH * 2;
8
+ const MAX_PREVIEW_PROPERTIES = 12;
9
+ const MISSING_PROPERTY = Symbol('missing-property');
10
+ const UNAVAILABLE_PROPERTY = Symbol('unavailable-property');
11
+ const SENSITIVE_CONSOLE_KEY = /authorization|cookie|(?:access|refresh|id)[_-]?token|api[_-]?key|password|passwd|credential|secret|private[_-]?input/i;
12
+ const STANDALONE_JWT = /\beyJ[A-Za-z0-9_-]{2,1021}\.[A-Za-z0-9_-]{2,4096}\.[A-Za-z0-9_-]{2,1024}\b/g;
13
+ const STANDALONE_AWS_ACCESS_KEY = /\bA(?:KIA|SIA)[0-9A-Z]{16}\b/g;
14
+ const STANDALONE_GITHUB_TOKEN = /\b(?:gh[pousr]_[A-Za-z0-9]{20,255}|github_pat_[A-Za-z0-9_]{20,255})\b/g;
15
+ const STANDALONE_GOOGLE_API_KEY = /\bAIza[0-9A-Za-z_-]{35}\b/g;
16
+ const STANDALONE_SLACK_TOKEN = /\bxox[a-z]-[0-9A-Za-z-]{10,255}\b/g;
17
+ var ChromiumConsoleLevel;
18
+ (function (ChromiumConsoleLevel) {
19
+ ChromiumConsoleLevel["Debug"] = "debug";
20
+ ChromiumConsoleLevel["Error"] = "error";
21
+ ChromiumConsoleLevel["Info"] = "info";
22
+ ChromiumConsoleLevel["Log"] = "log";
23
+ ChromiumConsoleLevel["Warning"] = "warn";
24
+ })(ChromiumConsoleLevel || (exports.ChromiumConsoleLevel = ChromiumConsoleLevel = {}));
25
+ var ChromiumConsoleSource;
26
+ (function (ChromiumConsoleSource) {
27
+ ChromiumConsoleSource["Browser"] = "browser";
28
+ ChromiumConsoleSource["Console"] = "console";
29
+ ChromiumConsoleSource["Exception"] = "exception";
30
+ })(ChromiumConsoleSource || (exports.ChromiumConsoleSource = ChromiumConsoleSource = {}));
31
+ function readOwnDataProperty(value, key) {
32
+ try {
33
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
34
+ if (descriptor === undefined)
35
+ return MISSING_PROPERTY;
36
+ return Object.prototype.hasOwnProperty.call(descriptor, 'value') ? descriptor.value : UNAVAILABLE_PROPERTY;
37
+ }
38
+ catch {
39
+ return UNAVAILABLE_PROPERTY;
40
+ }
41
+ }
42
+ function readOwnString(value, key) {
43
+ const property = readOwnDataProperty(value, key);
44
+ return typeof property === 'string' ? property : undefined;
45
+ }
46
+ function safeArrayLength(value) {
47
+ try {
48
+ if (!Array.isArray(value))
49
+ return null;
50
+ }
51
+ catch {
52
+ return null;
53
+ }
54
+ const length = readOwnDataProperty(value, 'length');
55
+ return typeof length === 'number' && Number.isSafeInteger(length) && length >= 0 ? length : null;
56
+ }
57
+ function boundedFragment(value) {
58
+ const redacted = redactConsoleText(value);
59
+ return redacted.length > MAX_CONSOLE_FRAGMENT_LENGTH
60
+ ? `${redacted.slice(0, MAX_CONSOLE_FRAGMENT_LENGTH)}…`
61
+ : redacted;
62
+ }
63
+ function formatPrimitive(value) {
64
+ switch (typeof value) {
65
+ case 'string': {
66
+ return boundedFragment(value);
67
+ }
68
+ case 'number':
69
+ case 'bigint':
70
+ case 'boolean':
71
+ case 'undefined': {
72
+ return String(value);
73
+ }
74
+ case 'symbol': {
75
+ return value.description === undefined ? 'Symbol()' : `Symbol(${boundedFragment(value.description)})`;
76
+ }
77
+ default: {
78
+ return value === null ? 'null' : null;
79
+ }
80
+ }
81
+ }
82
+ function formatPreviewProperty(value, isArray) {
83
+ if (typeof value !== 'object' || value === null)
84
+ return '[Unavailable]';
85
+ const name = readOwnString(value, 'name') ?? '';
86
+ const rawValue = readOwnString(value, 'value') ?? readOwnString(value, 'type') ?? 'undefined';
87
+ const formattedValue = SENSITIVE_CONSOLE_KEY.test(name) ? '[REDACTED]' : boundedFragment(rawValue);
88
+ return isArray ? formattedValue : `${boundedFragment(name)}: ${formattedValue}`;
89
+ }
90
+ function formatRemotePreview(remoteObject) {
91
+ const previewValue = readOwnDataProperty(remoteObject, 'preview');
92
+ const preview = typeof previewValue === 'object' && previewValue !== null ? previewValue : null;
93
+ const propertiesValue = preview ? readOwnDataProperty(preview, 'properties') : MISSING_PROPERTY;
94
+ const propertyCount = safeArrayLength(propertiesValue);
95
+ const description = readOwnString(remoteObject, 'description') ??
96
+ (preview ? readOwnString(preview, 'description') : undefined) ??
97
+ readOwnString(remoteObject, 'type') ??
98
+ '[Unavailable]';
99
+ if (propertyCount === null || propertyCount === 0)
100
+ return boundedFragment(description);
101
+ const subtype = (preview ? readOwnString(preview, 'subtype') : undefined) ?? readOwnString(remoteObject, 'subtype');
102
+ const isArray = subtype === 'array';
103
+ const formatted = [];
104
+ const count = Math.min(propertyCount, MAX_PREVIEW_PROPERTIES);
105
+ for (let index = 0; index < count; index += 1) {
106
+ const property = readOwnDataProperty(propertiesValue, String(index));
107
+ formatted.push(formatPreviewProperty(property, isArray));
108
+ }
109
+ const overflow = preview ? readOwnDataProperty(preview, 'overflow') === true : false;
110
+ if (overflow || propertyCount > MAX_PREVIEW_PROPERTIES)
111
+ formatted.push('…');
112
+ return isArray ? `[${formatted.join(', ')}]` : `{${formatted.join(', ')}}`;
113
+ }
114
+ function formatRemoteObject(value) {
115
+ if (value === MISSING_PROPERTY || value === UNAVAILABLE_PROPERTY)
116
+ return '[Unavailable]';
117
+ const primitive = formatPrimitive(value);
118
+ if (primitive !== null)
119
+ return primitive;
120
+ if (typeof value !== 'object' || value === null)
121
+ return '[Unavailable]';
122
+ const type = readOwnString(value, 'type');
123
+ const subtype = readOwnString(value, 'subtype');
124
+ if (type === 'undefined')
125
+ return 'undefined';
126
+ if (subtype === 'null')
127
+ return 'null';
128
+ const unserializableValue = readOwnString(value, 'unserializableValue');
129
+ if (unserializableValue !== undefined)
130
+ return boundedFragment(unserializableValue);
131
+ const remoteValue = readOwnDataProperty(value, 'value');
132
+ if (remoteValue !== MISSING_PROPERTY && remoteValue !== UNAVAILABLE_PROPERTY) {
133
+ const formattedValue = formatPrimitive(remoteValue);
134
+ if (formattedValue !== null)
135
+ return formattedValue;
136
+ }
137
+ if (subtype === 'error') {
138
+ const errorDescription = readOwnString(value, 'description');
139
+ if (errorDescription !== undefined)
140
+ return boundedFragment(errorDescription);
141
+ }
142
+ return formatRemotePreview(value);
143
+ }
144
+ function formatConsoleArguments(value) {
145
+ const length = safeArrayLength(value);
146
+ if (length === null)
147
+ return null;
148
+ if (length === 0)
149
+ return '';
150
+ const count = Math.min(length, MAX_CONSOLE_ARGUMENTS);
151
+ const arguments_ = [];
152
+ const formatted = [];
153
+ let formattedLength = 0;
154
+ let inputTruncated = false;
155
+ for (let index = 0; index < count; index += 1) {
156
+ const argument = readOwnDataProperty(value, String(index));
157
+ const formattedArgument = formatRemoteObject(argument);
158
+ const separatorLength = formatted.length === 0 ? 0 : 1;
159
+ const remainingLength = MAX_CONSOLE_FRAGMENT_LENGTH - formattedLength - separatorLength;
160
+ if (remainingLength <= 0) {
161
+ formatted.push('…');
162
+ inputTruncated = true;
163
+ break;
164
+ }
165
+ arguments_.push(argument);
166
+ if (formattedArgument.length > remainingLength) {
167
+ formatted.push(`${formattedArgument.slice(0, Math.max(0, remainingLength - 1))}…`);
168
+ inputTruncated = true;
169
+ break;
170
+ }
171
+ formatted.push(formattedArgument);
172
+ formattedLength += separatorLength + formattedArgument.length;
173
+ }
174
+ if (!inputTruncated && length > arguments_.length && formattedLength < MAX_CONSOLE_FRAGMENT_LENGTH) {
175
+ formatted.push('…');
176
+ }
177
+ const firstValue = typeof arguments_[0] === 'object' && arguments_[0] !== null
178
+ ? readOwnDataProperty(arguments_[0], 'value')
179
+ : MISSING_PROPERTY;
180
+ if (typeof firstValue !== 'string' || !/%[%Ocdfios]/.test(formatted[0] ?? '')) {
181
+ return formatted.join(' ');
182
+ }
183
+ let nextArgument = 1;
184
+ const substituted = (formatted[0] ?? '').replaceAll(/%([%Ocdfios])/g, (match, specifier) => {
185
+ if (specifier === '%')
186
+ return '%';
187
+ if (nextArgument >= arguments_.length)
188
+ return match;
189
+ const argument = formatted[nextArgument++] ?? '';
190
+ if (specifier === 'c')
191
+ return '';
192
+ if (specifier === 'd' || specifier === 'i')
193
+ return String(Number.parseInt(argument, 10));
194
+ if (specifier === 'f')
195
+ return String(Number.parseFloat(argument));
196
+ return argument;
197
+ });
198
+ return [substituted, ...formatted.slice(nextArgument)].join(' ');
199
+ }
200
+ function redactConsoleText(text) {
201
+ return text
202
+ .replaceAll(STANDALONE_JWT, '[REDACTED]')
203
+ .replaceAll(STANDALONE_AWS_ACCESS_KEY, '[REDACTED]')
204
+ .replaceAll(STANDALONE_GITHUB_TOKEN, '[REDACTED]')
205
+ .replaceAll(STANDALONE_GOOGLE_API_KEY, '[REDACTED]')
206
+ .replaceAll(STANDALONE_SLACK_TOKEN, '[REDACTED]')
207
+ .replaceAll(/\b(?:sk-(?:proj-|svcacct-)?[\w-]{12,}|sess-[\w-]{12,})\b/g, '[REDACTED]')
208
+ .replaceAll(/\bbearer\s+[\w+./~-]+=*/gi, 'Bearer [REDACTED]')
209
+ .replaceAll(/(["']?\b(?:authorization|proxy-authorization|cookie|set-cookie)["']?\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\n\r,]+)/gi, '$1[REDACTED]')
210
+ .replaceAll(/(["']?\b(?:access[_-]?token|refresh[_-]?token|id[_-]?token|api[_-]?key|password|passwd|credential|secret|private[_-]?input)["']?\s*[:=]\s*)(?:"[^"]*"|'[^']*'|[^\n\r&,;}]+)/gi, '$1[REDACTED]')
211
+ .replaceAll(/([&?](?:access_token|refresh_token|id_token|api_key|token|code|password|key|session)=)[^\s#&]+/gi, '$1[REDACTED]');
212
+ }
213
+ function normalizeConsoleLevel(level) {
214
+ switch (level) {
215
+ case 'error':
216
+ case 'assert': {
217
+ return ChromiumConsoleLevel.Error;
218
+ }
219
+ case 'warn':
220
+ case 'warning': {
221
+ return ChromiumConsoleLevel.Warning;
222
+ }
223
+ case 'info': {
224
+ return ChromiumConsoleLevel.Info;
225
+ }
226
+ case 'debug':
227
+ case 'verbose':
228
+ case 'trace': {
229
+ return ChromiumConsoleLevel.Debug;
230
+ }
231
+ default: {
232
+ return ChromiumConsoleLevel.Log;
233
+ }
234
+ }
235
+ }
236
+ function makeConsoleEntry(level, message, source, timestamp) {
237
+ const redacted = boundedFragment(message);
238
+ return {
239
+ level: normalizeConsoleLevel(level),
240
+ message: redacted.length > exports.MAX_CHROMIUM_CONSOLE_MESSAGE_LENGTH
241
+ ? `${redacted.slice(0, exports.MAX_CHROMIUM_CONSOLE_MESSAGE_LENGTH)}…`
242
+ : redacted,
243
+ source,
244
+ timestamp: typeof timestamp === 'number' && Number.isFinite(timestamp) ? timestamp : Date.now(),
245
+ };
246
+ }
247
+ function formatChromiumConsoleEvent(event) {
248
+ if (typeof event !== 'object' || event === null)
249
+ return null;
250
+ const method = readOwnString(event, 'method');
251
+ const paramsValue = readOwnDataProperty(event, 'params');
252
+ if (typeof paramsValue !== 'object' || paramsValue === null)
253
+ return null;
254
+ if (method === 'Runtime.consoleAPICalled') {
255
+ const message = formatConsoleArguments(readOwnDataProperty(paramsValue, 'args'));
256
+ if (message === null)
257
+ return null;
258
+ return makeConsoleEntry(readOwnDataProperty(paramsValue, 'type'), message, ChromiumConsoleSource.Console, readOwnDataProperty(paramsValue, 'timestamp'));
259
+ }
260
+ if (method === 'Log.entryAdded') {
261
+ const entry = readOwnDataProperty(paramsValue, 'entry');
262
+ if (typeof entry !== 'object' || entry === null)
263
+ return null;
264
+ const message = readOwnString(entry, 'text');
265
+ if (message === undefined)
266
+ return null;
267
+ return makeConsoleEntry(readOwnDataProperty(entry, 'level'), message, ChromiumConsoleSource.Browser, readOwnDataProperty(entry, 'timestamp'));
268
+ }
269
+ if (method === 'Runtime.exceptionThrown') {
270
+ const details = readOwnDataProperty(paramsValue, 'exceptionDetails');
271
+ if (typeof details !== 'object' || details === null)
272
+ return null;
273
+ const exception = readOwnDataProperty(details, 'exception');
274
+ const description = typeof exception === 'object' && exception !== null ? readOwnString(exception, 'description') : undefined;
275
+ const message = description ?? readOwnString(details, 'text') ?? 'Uncaught exception';
276
+ return makeConsoleEntry(ChromiumConsoleLevel.Error, message, ChromiumConsoleSource.Exception, readOwnDataProperty(paramsValue, 'timestamp'));
277
+ }
278
+ return null;
279
+ }