@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
@@ -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
+ }