@salesforce/ui-bundle 1.117.2

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 (68) hide show
  1. package/LICENSE.txt +82 -0
  2. package/README.md +3 -0
  3. package/dist/api/clients.d.ts +22 -0
  4. package/dist/api/clients.d.ts.map +1 -0
  5. package/dist/api/clients.js +84 -0
  6. package/dist/api/graphql-operations-types.d.ts +225 -0
  7. package/dist/api/graphql-operations-types.d.ts.map +1 -0
  8. package/dist/api/index.d.ts +10 -0
  9. package/dist/api/index.d.ts.map +1 -0
  10. package/dist/api/index.js +13 -0
  11. package/dist/api/utils/accounts.d.ts +33 -0
  12. package/dist/api/utils/accounts.d.ts.map +1 -0
  13. package/dist/api/utils/accounts.js +47 -0
  14. package/dist/api/utils/records.d.ts +16 -0
  15. package/dist/api/utils/records.d.ts.map +1 -0
  16. package/dist/api/utils/records.js +26 -0
  17. package/dist/api/utils/user.d.ts +17 -0
  18. package/dist/api/utils/user.d.ts.map +1 -0
  19. package/dist/api/utils/user.js +25 -0
  20. package/dist/app/index.d.ts +10 -0
  21. package/dist/app/index.d.ts.map +1 -0
  22. package/dist/app/index.js +7 -0
  23. package/dist/app/manifest.d.ts +34 -0
  24. package/dist/app/manifest.d.ts.map +1 -0
  25. package/dist/app/manifest.js +28 -0
  26. package/dist/app/org.d.ts +28 -0
  27. package/dist/app/org.d.ts.map +1 -0
  28. package/dist/app/org.js +67 -0
  29. package/dist/design/design-mode-interactions.js +761 -0
  30. package/dist/design/index.d.ts +12 -0
  31. package/dist/design/index.d.ts.map +1 -0
  32. package/dist/design/index.js +14 -0
  33. package/dist/design/interactions/communicationManager.d.ts +25 -0
  34. package/dist/design/interactions/communicationManager.d.ts.map +1 -0
  35. package/dist/design/interactions/componentMatcher.d.ts +43 -0
  36. package/dist/design/interactions/componentMatcher.d.ts.map +1 -0
  37. package/dist/design/interactions/editableManager.d.ts +25 -0
  38. package/dist/design/interactions/editableManager.d.ts.map +1 -0
  39. package/dist/design/interactions/eventHandlers.d.ts +40 -0
  40. package/dist/design/interactions/eventHandlers.d.ts.map +1 -0
  41. package/dist/design/interactions/index.d.ts +7 -0
  42. package/dist/design/interactions/index.d.ts.map +1 -0
  43. package/dist/design/interactions/interactionsController.d.ts +36 -0
  44. package/dist/design/interactions/interactionsController.d.ts.map +1 -0
  45. package/dist/design/interactions/styleManager.d.ts +49 -0
  46. package/dist/design/interactions/styleManager.d.ts.map +1 -0
  47. package/dist/design/interactions/utils/cssUtils.d.ts +54 -0
  48. package/dist/design/interactions/utils/cssUtils.d.ts.map +1 -0
  49. package/dist/design/interactions/utils/sourceUtils.d.ts +36 -0
  50. package/dist/design/interactions/utils/sourceUtils.d.ts.map +1 -0
  51. package/dist/index.d.ts +10 -0
  52. package/dist/index.d.ts.map +1 -0
  53. package/dist/index.js +25 -0
  54. package/dist/package.json.js +4 -0
  55. package/dist/proxy/handler.d.ts +38 -0
  56. package/dist/proxy/handler.d.ts.map +1 -0
  57. package/dist/proxy/handler.js +530 -0
  58. package/dist/proxy/index.d.ts +8 -0
  59. package/dist/proxy/index.d.ts.map +1 -0
  60. package/dist/proxy/index.js +7 -0
  61. package/dist/proxy/livePreviewScript.d.ts +21 -0
  62. package/dist/proxy/livePreviewScript.d.ts.map +1 -0
  63. package/dist/proxy/livePreviewScript.js +16 -0
  64. package/dist/proxy/routing.d.ts +35 -0
  65. package/dist/proxy/routing.d.ts.map +1 -0
  66. package/dist/proxy/routing.js +83 -0
  67. package/dist/proxy/templates/livePreviewScript.js +553 -0
  68. package/package.json +65 -0
@@ -0,0 +1,83 @@
1
+ import "micromatch";
2
+ import { match } from "path-to-regexp";
3
+ function normalizeRoute(route) {
4
+ let wildcardIndex = 0;
5
+ return route.replace(/\*/g, () => {
6
+ return `{*wildcard${wildcardIndex++}}`;
7
+ });
8
+ }
9
+ function matchRoute(pathname, basePath, rewrites, redirects) {
10
+ const servicesRegex = new RegExp(
11
+ `^${basePath || ""}/services/data/v\\d{2}\\.\\d/(graphql|ui-api|connect/file/upload/config)`
12
+ );
13
+ if (servicesRegex.test(pathname) || pathname.startsWith(`${basePath || ""}/lwr/apex/v`)) {
14
+ return { type: "api" };
15
+ }
16
+ if (pathname.startsWith(`${basePath || ""}/gql/endpoint`)) {
17
+ return { type: "gql" };
18
+ }
19
+ if (pathname.startsWith(`${basePath || ""}/chatter/handlers/file/body`)) {
20
+ return { type: "file-upload" };
21
+ }
22
+ if (redirects) {
23
+ for (const redirect of redirects) {
24
+ const normalizedRoute = normalizeRoute(redirect.route);
25
+ const matcher = match(normalizedRoute, { decode: decodeURIComponent });
26
+ const result = matcher(pathname);
27
+ if (result) {
28
+ let target = redirect.target;
29
+ const params = result.params;
30
+ for (const [key, value] of Object.entries(params)) {
31
+ if (!key.startsWith("wildcard")) {
32
+ target = target.replace(`:${key}`, value);
33
+ }
34
+ }
35
+ return {
36
+ type: "redirect",
37
+ target,
38
+ statusCode: redirect.statusCode
39
+ };
40
+ }
41
+ }
42
+ }
43
+ if (rewrites) {
44
+ for (const rewrite of rewrites) {
45
+ const normalizedRoute = normalizeRoute(rewrite.route);
46
+ const matcher = match(normalizedRoute, { decode: decodeURIComponent });
47
+ const result = matcher(pathname);
48
+ if (result) {
49
+ const params = {};
50
+ const matchParams = result.params;
51
+ for (const [key, value] of Object.entries(matchParams)) {
52
+ if (!key.startsWith("wildcard")) {
53
+ params[key] = value;
54
+ }
55
+ }
56
+ return {
57
+ type: "rewrite",
58
+ target: rewrite.target,
59
+ params
60
+ };
61
+ }
62
+ }
63
+ }
64
+ return null;
65
+ }
66
+ function applyTrailingSlash(pathname, trailingSlash) {
67
+ if (!trailingSlash || trailingSlash === "auto") {
68
+ return pathname;
69
+ }
70
+ const hasTrailingSlash = pathname.endsWith("/");
71
+ const isRoot = pathname === "/";
72
+ if (trailingSlash === "always" && !hasTrailingSlash && !isRoot) {
73
+ return `${pathname}/`;
74
+ }
75
+ if (trailingSlash === "never" && hasTrailingSlash && !isRoot) {
76
+ return pathname.slice(0, -1);
77
+ }
78
+ return pathname;
79
+ }
80
+ export {
81
+ applyTrailingSlash,
82
+ matchRoute
83
+ };
@@ -0,0 +1,553 @@
1
+ /**
2
+ * Copyright (c) 2026, Salesforce, Inc.,
3
+ * All rights reserved.
4
+ * For full license text, see the LICENSE.txt file
5
+ */
6
+
7
+ /* eslint-disable */
8
+ // Live Preview injected script — loaded at runtime by livePreviewScript.ts via readFileSync.
9
+ // This file runs in the browser (injected into <script> tags), NOT in Node.js.
10
+ // Live Preview postMessage contract (match extension TypeScript type):
11
+ // type: 'runtime' | 'compile' | 'network' | 'hmr' - extension uses for Fix Code vs Refresh Panel vs Re-authenticate
12
+ // For network: always send status (401/403 = auth, 0 = connection/socket failure)
13
+ // CRITICAL: Set up fetch interceptor IMMEDIATELY (synchronously, before defer)
14
+ // This ensures we catch all network errors, even those that happen during page load
15
+ (function setupFetchInterceptorImmediate() {
16
+ if (window.fetch && !window.fetch._vscodeIntercepted) {
17
+ const originalFetch = window.fetch;
18
+ window.fetch = function () {
19
+ const args = Array.prototype.slice.call(arguments);
20
+ const url = typeof args[0] === "string" ? args[0] : args[0] && args[0].url ? args[0].url : "";
21
+ const method = (args[1] && args[1].method ? args[1].method : "GET").toUpperCase();
22
+ const startTime = Date.now();
23
+
24
+ return originalFetch
25
+ .apply(window, args)
26
+ .then(function (response) {
27
+ const duration = Date.now() - startTime;
28
+
29
+ if (response.status >= 400) {
30
+ const errorData = {
31
+ type: "network",
32
+ method: method,
33
+ url: url,
34
+ status: response.status,
35
+ duration: duration,
36
+ message: "Network error: " + response.status + " " + (response.statusText || ""),
37
+ };
38
+ // Use sendErrorToParent (via window.__vscodeLivePreviewSendError) so dedup applies.
39
+ // Do NOT use console.error here — it would trigger the override and double-send.
40
+ if (typeof window.__vscodeLivePreviewSendError === "function") {
41
+ try {
42
+ window.__vscodeLivePreviewSendError(errorData);
43
+ } catch (err) {}
44
+ } else if (window.parent && window.parent !== window) {
45
+ // Fallback before init: send directly (no dedup yet)
46
+ try {
47
+ window.parent.postMessage(
48
+ {
49
+ type: errorData.type,
50
+ message: errorData.message,
51
+ metadata: {
52
+ method: errorData.method,
53
+ url: errorData.url,
54
+ status: errorData.status,
55
+ duration: errorData.duration,
56
+ },
57
+ _source: "ui-bundle-proxy-injected-script",
58
+ },
59
+ "*",
60
+ );
61
+ } catch (e) {}
62
+ }
63
+ }
64
+
65
+ return response;
66
+ })
67
+ .catch(function (error) {
68
+ const duration = Date.now() - startTime;
69
+ const status =
70
+ (error && error.status) || (error && error.response && error.response.status) || 0;
71
+ const errorData = {
72
+ type: "network",
73
+ method: method,
74
+ url: url,
75
+ status: status,
76
+ duration: duration,
77
+ message:
78
+ error && error.message
79
+ ? error.message
80
+ : status > 0
81
+ ? "Network error: " + status
82
+ : "Network request failed",
83
+ stack: error && error.stack ? error.stack : "",
84
+ };
85
+ // Use sendErrorToParent (via window.__vscodeLivePreviewSendError) so dedup applies.
86
+ // Do NOT use console.error — it would trigger the override and double-send.
87
+ if (typeof window.__vscodeLivePreviewSendError === "function") {
88
+ try {
89
+ window.__vscodeLivePreviewSendError(errorData);
90
+ } catch (err) {}
91
+ } else if (window.parent && window.parent !== window) {
92
+ try {
93
+ window.parent.postMessage(
94
+ {
95
+ type: errorData.type,
96
+ message: errorData.message,
97
+ stack: errorData.stack,
98
+ metadata: {
99
+ method: errorData.method,
100
+ url: errorData.url,
101
+ status: errorData.status,
102
+ duration: errorData.duration,
103
+ },
104
+ _source: "ui-bundle-proxy-injected-script",
105
+ },
106
+ "*",
107
+ );
108
+ } catch (e) {}
109
+ }
110
+ throw error;
111
+ });
112
+ };
113
+ window.fetch._vscodeIntercepted = true;
114
+ }
115
+ })();
116
+ (function () {
117
+ // Defer script execution to avoid blocking initial page render
118
+ // Use requestIdleCallback if available, otherwise setTimeout
119
+ function deferInit(callback) {
120
+ if (window.requestIdleCallback) {
121
+ window.requestIdleCallback(callback, { timeout: 100 });
122
+ } else {
123
+ setTimeout(callback, 0);
124
+ }
125
+ }
126
+ function initVSCodeLivePreview() {
127
+ const recentErrors = {};
128
+ const ERROR_DEDUP_WINDOW_MS = 2000;
129
+
130
+ function safeStr(val, maxLen) {
131
+ if (val == null) return "";
132
+ const s = typeof val === "string" ? val : String(val);
133
+ return s.substring(0, maxLen == null ? s.length : maxLen);
134
+ }
135
+
136
+ function getErrorHash(errorData) {
137
+ if (errorData.type === "network") {
138
+ return (
139
+ (errorData.type || "unknown") +
140
+ "|" +
141
+ (errorData.status || "0") +
142
+ "|" +
143
+ safeStr(errorData.url, 100) +
144
+ "|" +
145
+ (errorData.method || "GET")
146
+ );
147
+ }
148
+ return (
149
+ (errorData.type || "unknown") +
150
+ "|" +
151
+ safeStr(errorData.message, 100) +
152
+ "|" +
153
+ safeStr(errorData.source, 50)
154
+ );
155
+ }
156
+
157
+ function sendErrorToParent(errorData) {
158
+ const errorHash = getErrorHash(errorData);
159
+ const now = Date.now();
160
+
161
+ if (recentErrors[errorHash]) {
162
+ const timeSinceLastSend = now - recentErrors[errorHash];
163
+ if (timeSinceLastSend < ERROR_DEDUP_WINDOW_MS) {
164
+ return;
165
+ }
166
+ }
167
+
168
+ recentErrors[errorHash] = now;
169
+
170
+ const errorKeys = Object.keys(recentErrors);
171
+ if (errorKeys.length > 50) {
172
+ const sortedKeys = errorKeys.sort(function (a, b) {
173
+ return recentErrors[a] - recentErrors[b];
174
+ });
175
+ for (let i = 0; i < sortedKeys.length - 50; i++) {
176
+ delete recentErrors[sortedKeys[i]];
177
+ }
178
+ }
179
+
180
+ if (window.parent && window.parent !== window) {
181
+ try {
182
+ const msg = {
183
+ type: errorData.type,
184
+ message: errorData.message,
185
+ stack: errorData.stack,
186
+ metadata: {
187
+ source: errorData.source || window.location.href,
188
+ level: errorData.level,
189
+ method: errorData.method,
190
+ url: errorData.url,
191
+ status: errorData.status,
192
+ duration: errorData.duration,
193
+ },
194
+ _source: "ui-bundle-proxy-injected-script",
195
+ };
196
+ window.parent.postMessage(msg, "*");
197
+ } catch (err) {
198
+ console.error("[ui-bundle-proxy] Failed to send error to parent:", err);
199
+ }
200
+ }
201
+ }
202
+ // Expose for fetch interceptor: once init runs, network errors use sendErrorToParent (dedup)
203
+ try {
204
+ window.__vscodeLivePreviewSendError = sendErrorToParent;
205
+ } catch (e) {}
206
+
207
+ const initTime = new Date().toISOString();
208
+ if (window.parent && window.parent !== window) {
209
+ try {
210
+ window.parent.postMessage(
211
+ {
212
+ command: "iframeAlive",
213
+ version: "2026-01-19-v5",
214
+ timestamp: initTime,
215
+ source: "ui-bundle-proxy-injected-script",
216
+ },
217
+ "*",
218
+ );
219
+ } catch (e) {
220
+ console.error("[ui-bundle-proxy] Failed to send iframeAlive message:", e);
221
+ }
222
+ }
223
+ if (
224
+ window.parent &&
225
+ window.parent !== window &&
226
+ !document.getElementById("vscode-text-selection-style")
227
+ ) {
228
+ const style = document.createElement("style");
229
+ style.id = "vscode-text-selection-style";
230
+ style.textContent =
231
+ "* { -webkit-user-select: text !important; user-select: text !important; }";
232
+ document.head.appendChild(style);
233
+ }
234
+
235
+ let lastSelection = "";
236
+ let lastCopyTime = 0;
237
+ const COPY_THROTTLE_MS = 100;
238
+
239
+ // Function to get current selection and send copy message
240
+ function sendCopyMessage(forceCopy) {
241
+ if (forceCopy === undefined) forceCopy = false;
242
+ const timestamp = new Date().toISOString();
243
+ const now = Date.now();
244
+ const timeSinceLastCopy = now - lastCopyTime;
245
+ let selection = window.getSelection();
246
+ let text = "";
247
+
248
+ if (selection && selection.toString().trim()) {
249
+ text = selection.toString();
250
+ } else {
251
+ try {
252
+ const docSelection = document.getSelection();
253
+ if (docSelection && docSelection.toString().trim()) {
254
+ text = docSelection.toString();
255
+ }
256
+ } catch (e) {}
257
+ }
258
+ if (!text || text.length === 0) {
259
+ try {
260
+ const activeElement = document.activeElement;
261
+ if (
262
+ activeElement &&
263
+ (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA")
264
+ ) {
265
+ const input = activeElement;
266
+ if (input.selectionStart !== undefined && input.selectionEnd !== undefined) {
267
+ text = input.value.substring(input.selectionStart, input.selectionEnd);
268
+ }
269
+ }
270
+ } catch (e) {}
271
+ }
272
+ if (!text || text.trim().length === 0) {
273
+ return;
274
+ }
275
+
276
+ const selectionChanged = text !== lastSelection;
277
+ const shouldThrottle = !forceCopy && timeSinceLastCopy < COPY_THROTTLE_MS;
278
+
279
+ if (forceCopy || (selectionChanged && !shouldThrottle)) {
280
+ lastSelection = text;
281
+ lastCopyTime = now;
282
+
283
+ if (window.parent && window.parent !== window) {
284
+ try {
285
+ const message = {
286
+ command: "copy",
287
+ text: text,
288
+ timestamp: timestamp,
289
+ };
290
+ window.parent.postMessage(message, "*");
291
+ } catch (err) {
292
+ console.error("[ui-bundle-proxy] Copy: Error sending postMessage:", err);
293
+ }
294
+ }
295
+ }
296
+ }
297
+
298
+ if (window.parent && window.parent !== window) {
299
+ document.addEventListener(
300
+ "keydown",
301
+ function (e) {
302
+ if ((e.metaKey || e.ctrlKey) && (e.key === "c" || e.key === "C" || e.keyCode === 67)) {
303
+ setTimeout(function () {
304
+ sendCopyMessage(true);
305
+ }, 0);
306
+ }
307
+ },
308
+ true,
309
+ );
310
+
311
+ document.addEventListener(
312
+ "copy",
313
+ function (e) {
314
+ setTimeout(function () {
315
+ sendCopyMessage(true);
316
+ }, 0);
317
+ },
318
+ true,
319
+ );
320
+ }
321
+
322
+ if (window.parent && window.parent !== window) {
323
+ document.addEventListener(
324
+ "contextmenu",
325
+ function (e) {
326
+ e.preventDefault();
327
+ const selection = window.getSelection();
328
+ const selectedText = selection && selection.toString().trim() ? selection.toString() : "";
329
+ try {
330
+ window.parent.postMessage(
331
+ {
332
+ command: "rightClick",
333
+ x: e.clientX,
334
+ y: e.clientY,
335
+ selectedText: selectedText,
336
+ },
337
+ "*",
338
+ );
339
+ } catch (err) {
340
+ console.error("[ui-bundle-proxy] Right-click: Error sending postMessage:", err);
341
+ }
342
+ },
343
+ true,
344
+ );
345
+ }
346
+
347
+ window.addEventListener("message", function (e) {
348
+ if (e.data && e.data.command === "getSelection") {
349
+ const selection = window.getSelection();
350
+ const text = selection && selection.toString() ? selection.toString() : "";
351
+ if (window.parent && window.parent !== window) {
352
+ window.parent.postMessage({ command: "selectionText", text: text }, "*");
353
+ }
354
+ } else if (e.data && e.data.command === "selectAll") {
355
+ document.execCommand("selectAll", false, null);
356
+ } else if (e.data && e.data.command === "paste") {
357
+ // Paste text into active element or document
358
+ if (e.data.text) {
359
+ try {
360
+ const activeElement = document.activeElement;
361
+ if (
362
+ activeElement &&
363
+ (activeElement.tagName === "INPUT" ||
364
+ activeElement.tagName === "TEXTAREA" ||
365
+ activeElement.isContentEditable)
366
+ ) {
367
+ if (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA") {
368
+ const input = activeElement;
369
+ const start = input.selectionStart || 0;
370
+ const end = input.selectionEnd || 0;
371
+ const value = input.value || "";
372
+ input.value = value.substring(0, start) + e.data.text + value.substring(end);
373
+ input.selectionStart = input.selectionEnd = start + e.data.text.length;
374
+ input.dispatchEvent(new Event("input", { bubbles: true }));
375
+ } else if (activeElement.isContentEditable) {
376
+ document.execCommand("insertText", false, e.data.text);
377
+ }
378
+ } else {
379
+ // Fallback: try to paste into body
380
+ document.execCommand("insertText", false, e.data.text);
381
+ }
382
+ } catch (err) {
383
+ console.error("[ui-bundle-proxy] paste: Failed to paste text:", err);
384
+ }
385
+ }
386
+ }
387
+ });
388
+
389
+ // Send click events to parent to hide context menu when clicking elsewhere
390
+ document.addEventListener(
391
+ "click",
392
+ function (e) {
393
+ if (window.parent && window.parent !== window) {
394
+ try {
395
+ window.parent.postMessage(
396
+ {
397
+ command: "iframeClick",
398
+ x: e.clientX,
399
+ y: e.clientY,
400
+ },
401
+ "*",
402
+ );
403
+ } catch (err) {
404
+ // Silently fail if postMessage fails
405
+ }
406
+ }
407
+ },
408
+ true,
409
+ );
410
+
411
+ // 1. Handle unhandled JavaScript errors (runtime - extension shows Refresh Panel)
412
+ window.addEventListener(
413
+ "error",
414
+ function (event) {
415
+ const errorData = {
416
+ type: "runtime",
417
+ message: event.message || "Unknown error",
418
+ stack: event.error ? event.error.stack : "",
419
+ source: event.filename || window.location.href,
420
+ };
421
+ console.error("[ui-bundle-proxy] Unhandled error detected:", errorData);
422
+ sendErrorToParent(errorData);
423
+ },
424
+ true,
425
+ );
426
+
427
+ // 2. Handle unhandled promise rejections (runtime or network - extension shows appropriate actions)
428
+ window.addEventListener("unhandledrejection", function (event) {
429
+ const reason = event.reason;
430
+ const msg =
431
+ reason && reason.message ? reason.message : String(reason) || "Unhandled promise rejection";
432
+ // "Failed to fetch" and similar come from fetch() rejections (DNS, CORS, connection) — classify as network
433
+ const isNetworkFailure =
434
+ /failed to fetch|network request failed|load failed|networkerror/i.test(msg);
435
+ const errorData = {
436
+ type: isNetworkFailure ? "network" : "runtime",
437
+ message: msg,
438
+ stack: reason && reason.stack ? reason.stack : "",
439
+ source: window.location.href,
440
+ };
441
+ console.error("[ui-bundle-proxy] Unhandled promise rejection detected:", errorData);
442
+ sendErrorToParent(errorData);
443
+ });
444
+
445
+ // 3. Override console.error to catch errors surfaced by frameworks (React, Vite).
446
+ // Trade-off: this catches all console.error calls (including third-party noise).
447
+ // The ignore list below filters known framework messages. A re-entrancy guard
448
+ // prevents infinite loops if sendErrorToParent itself triggers console.error.
449
+ const originalConsoleError = console.error;
450
+ let _inConsoleErrorOverride = false;
451
+ console.error = function () {
452
+ const args = Array.prototype.slice.call(arguments);
453
+ originalConsoleError.apply(console, args);
454
+ if (_inConsoleErrorOverride) return;
455
+ _inConsoleErrorOverride = true;
456
+ try {
457
+ let message = "";
458
+ let stack = "";
459
+
460
+ for (let i = 0; i < args.length; i++) {
461
+ const arg = args[i];
462
+ if (arg instanceof Error) {
463
+ message = arg.message;
464
+ stack = arg.stack || "";
465
+ break;
466
+ } else if (typeof arg === "string") {
467
+ message = arg;
468
+ } else if (arg && typeof arg === "object") {
469
+ message =
470
+ arg.message && typeof arg.message === "string" ? arg.message : JSON.stringify(arg);
471
+ } else {
472
+ message = String(arg);
473
+ }
474
+ }
475
+
476
+ // If no message extracted, stringify all args (avoid [object Object])
477
+ if (!message && args.length > 0) {
478
+ message = args
479
+ .map(function (arg) {
480
+ if (arg && typeof arg === "object" && !(arg instanceof Error)) {
481
+ return arg.message && typeof arg.message === "string"
482
+ ? arg.message
483
+ : JSON.stringify(arg);
484
+ }
485
+ return String(arg);
486
+ })
487
+ .join(" ");
488
+ }
489
+ // Skip sending noise: [object Object] with no useful content
490
+ if (message === "[object Object]") {
491
+ return;
492
+ }
493
+
494
+ const messageLower = (
495
+ typeof message === "string" ? message : String(message)
496
+ ).toLowerCase();
497
+ if (messageLower.includes("failed to reload")) {
498
+ const errorData = {
499
+ type: "compile",
500
+ level: "error",
501
+ message: (typeof message === "string" ? message : String(message)) || "Console error",
502
+ stack: stack,
503
+ };
504
+ sendErrorToParent(errorData);
505
+ return;
506
+ }
507
+ // Filter out other noisy/expected errors that shouldn't trigger notifications
508
+ const shouldIgnore =
509
+ messageLower.includes("hmr update") ||
510
+ messageLower.includes("fast refresh") ||
511
+ messageLower.includes("could not fast refresh") ||
512
+ (messageLower.includes("[vite]") && messageLower.includes("hmr")) ||
513
+ messageLower.includes("reactdomclient.createroot");
514
+
515
+ if (shouldIgnore) {
516
+ return; // Don't send these to VS Code
517
+ }
518
+
519
+ // Skip network errors: fetch interceptor already sends them (avoids double postMessage)
520
+ for (let i = 0; i < args.length; i++) {
521
+ if (args[i] && typeof args[i] === "object" && args[i].type === "network") {
522
+ return;
523
+ }
524
+ }
525
+
526
+ const errorData = {
527
+ type: "runtime",
528
+ level: "error",
529
+ message: message || "Console error",
530
+ stack: stack,
531
+ };
532
+
533
+ sendErrorToParent(errorData);
534
+ } finally {
535
+ _inConsoleErrorOverride = false;
536
+ }
537
+ };
538
+ }
539
+
540
+ // Defer execution to avoid blocking initial page render
541
+ // Wait for page to be interactive before initializing
542
+ if (document.readyState === "loading") {
543
+ document.addEventListener("DOMContentLoaded", function () {
544
+ deferInit(initVSCodeLivePreview);
545
+ });
546
+ } else if (document.readyState === "interactive") {
547
+ // DOM is interactive, defer to next idle period
548
+ deferInit(initVSCodeLivePreview);
549
+ } else {
550
+ // DOM is complete, run immediately but asynchronously
551
+ deferInit(initVSCodeLivePreview);
552
+ }
553
+ })();
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@salesforce/ui-bundle",
3
+ "description": "Core package for Salesforce UI Bundles",
4
+ "version": "1.117.2",
5
+ "license": "SEE LICENSE IN LICENSE.txt",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "./api": {
16
+ "types": "./dist/api/index.d.ts",
17
+ "import": "./dist/api/index.js"
18
+ },
19
+ "./app": {
20
+ "types": "./dist/app/index.d.ts",
21
+ "import": "./dist/app/index.js"
22
+ },
23
+ "./proxy": {
24
+ "types": "./dist/proxy/index.d.ts",
25
+ "import": "./dist/proxy/index.js"
26
+ },
27
+ "./design": {
28
+ "types": "./dist/design/index.d.ts",
29
+ "import": "./dist/design/index.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "files": [
34
+ "dist"
35
+ ],
36
+ "scripts": {
37
+ "build": "npm run build:design && vite build && node scripts/copy-templates.cjs",
38
+ "build:design": "node src/design/bundle-interactions.mjs",
39
+ "clean": "rm -rf dist",
40
+ "dev": "vite build --watch",
41
+ "test": "vitest run",
42
+ "test:watch": "vitest",
43
+ "test:coverage": "vitest run --coverage"
44
+ },
45
+ "dependencies": {
46
+ "@salesforce/core": "^8.23.4",
47
+ "@salesforce/sdk-data": "^1.117.2",
48
+ "axios": "^1.7.7",
49
+ "micromatch": "^4.0.8",
50
+ "path-to-regexp": "^8.3.0"
51
+ },
52
+ "devDependencies": {
53
+ "@types/micromatch": "^4.0.10",
54
+ "esbuild": "^0.24.0",
55
+ "vite": "^7.3.1",
56
+ "vite-plugin-dts": "^4.5.4",
57
+ "vitest": "^4.0.6"
58
+ },
59
+ "engines": {
60
+ "node": ">=20.0.0"
61
+ },
62
+ "publishConfig": {
63
+ "access": "public"
64
+ }
65
+ }