@salesforce/webapp-experimental 1.47.0 → 1.48.1
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.
- package/dist/design/design-mode-interactions.js +649 -0
- package/dist/design/index.d.ts +12 -0
- package/dist/design/index.d.ts.map +1 -0
- package/dist/design/index.js +21 -0
- package/dist/design/interactions/communicationManager.d.ts +25 -0
- package/dist/design/interactions/communicationManager.d.ts.map +1 -0
- package/dist/design/interactions/communicationManager.js +112 -0
- package/dist/design/interactions/componentMatcher.d.ts +37 -0
- package/dist/design/interactions/componentMatcher.d.ts.map +1 -0
- package/dist/design/interactions/componentMatcher.js +68 -0
- package/dist/design/interactions/editableManager.d.ts +51 -0
- package/dist/design/interactions/editableManager.d.ts.map +1 -0
- package/dist/design/interactions/editableManager.js +90 -0
- package/dist/design/interactions/eventHandlers.d.ts +66 -0
- package/dist/design/interactions/eventHandlers.d.ts.map +1 -0
- package/dist/design/interactions/eventHandlers.js +136 -0
- package/dist/design/interactions/index.d.ts +7 -0
- package/dist/design/interactions/index.d.ts.map +1 -0
- package/dist/design/interactions/index.js +45 -0
- package/dist/design/interactions/interactionsController.d.ts +38 -0
- package/dist/design/interactions/interactionsController.d.ts.map +1 -0
- package/dist/design/interactions/interactionsController.js +86 -0
- package/dist/design/interactions/styleManager.d.ts +49 -0
- package/dist/design/interactions/styleManager.d.ts.map +1 -0
- package/dist/design/interactions/styleManager.js +89 -0
- package/dist/design/interactions/utils/cssUtils.d.ts +22 -0
- package/dist/design/interactions/utils/cssUtils.d.ts.map +1 -0
- package/dist/design/interactions/utils/cssUtils.js +46 -0
- package/dist/design/interactions/utils/sourceUtils.d.ts +23 -0
- package/dist/design/interactions/utils/sourceUtils.d.ts.map +1 -0
- package/dist/design/interactions/utils/sourceUtils.js +64 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +10 -4
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export declare class InteractionsController {
|
|
7
|
+
private enabled;
|
|
8
|
+
private isActive;
|
|
9
|
+
private componentMatcher;
|
|
10
|
+
private styleManager;
|
|
11
|
+
private communicationManager;
|
|
12
|
+
private editableManager;
|
|
13
|
+
private eventHandlers;
|
|
14
|
+
constructor(enabled?: boolean);
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the design mode interactions
|
|
17
|
+
*/
|
|
18
|
+
initialize(): void;
|
|
19
|
+
/**
|
|
20
|
+
* Enable the design mode interactions
|
|
21
|
+
*/
|
|
22
|
+
enable(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Disable the design mode interactions
|
|
25
|
+
*/
|
|
26
|
+
disable(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Apply style changes to the selected element
|
|
29
|
+
* @param property - CSS property name
|
|
30
|
+
* @param value - CSS property value
|
|
31
|
+
*/
|
|
32
|
+
applyStyleChange(property: string, value: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Cleanup and remove event listeners
|
|
35
|
+
*/
|
|
36
|
+
destroy(): void;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=interactionsController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactionsController.d.ts","sourceRoot":"","sources":["../../../src/design/interactions/interactionsController.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAaH,qBAAa,sBAAsB;IAClC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,QAAQ,CAAU;IAE1B,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,oBAAoB,CAAuB;IACnD,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,OAAO,UAAO;IAmB1B;;OAEG;IACH,UAAU,IAAI,IAAI;IAiBlB;;OAEG;IACH,MAAM,IAAI,IAAI;IAKd;;OAEG;IACH,OAAO,IAAI,IAAI;IAMf;;;;OAIG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAOvD;;OAEG;IACH,OAAO,IAAI,IAAI;CAOf"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Interactions Controller Module
|
|
8
|
+
* Main controller that orchestrates all interaction modules
|
|
9
|
+
*/
|
|
10
|
+
import { CommunicationManager } from "./communicationManager.js";
|
|
11
|
+
import { ComponentMatcher } from "./componentMatcher.js";
|
|
12
|
+
import { EditableManager } from "./editableManager.js";
|
|
13
|
+
import { EventHandlers } from "./eventHandlers.js";
|
|
14
|
+
import { StyleManager } from "./styleManager.js";
|
|
15
|
+
export class InteractionsController {
|
|
16
|
+
enabled;
|
|
17
|
+
isActive;
|
|
18
|
+
componentMatcher;
|
|
19
|
+
styleManager;
|
|
20
|
+
communicationManager;
|
|
21
|
+
editableManager;
|
|
22
|
+
eventHandlers;
|
|
23
|
+
constructor(enabled = true) {
|
|
24
|
+
this.enabled = enabled;
|
|
25
|
+
this.isActive = false;
|
|
26
|
+
// Initialize modules
|
|
27
|
+
this.componentMatcher = new ComponentMatcher();
|
|
28
|
+
this.styleManager = new StyleManager();
|
|
29
|
+
this.communicationManager = new CommunicationManager();
|
|
30
|
+
this.editableManager = new EditableManager(this.communicationManager);
|
|
31
|
+
this.eventHandlers = new EventHandlers(() => this.isActive, this.componentMatcher, this.styleManager, this.editableManager, this.communicationManager);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Initialize the design mode interactions
|
|
35
|
+
*/
|
|
36
|
+
initialize() {
|
|
37
|
+
if (!this.enabled) {
|
|
38
|
+
console.log("Design Mode Interactions disabled");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
console.log("Initializing Design Mode Interactions...");
|
|
42
|
+
this.styleManager.addHighlightStyles();
|
|
43
|
+
document.addEventListener("mouseover", this.eventHandlers.handleMouseOver);
|
|
44
|
+
document.addEventListener("mouseleave", this.eventHandlers.handleMouseLeave);
|
|
45
|
+
// Use capture phase so we run before links/buttons/dropdowns and can preventDefault/stopPropagation
|
|
46
|
+
document.addEventListener("click", this.eventHandlers.handleClick, true);
|
|
47
|
+
console.log("Design Mode Interactions initialized!");
|
|
48
|
+
this.communicationManager.notifyInitializationComplete();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Enable the design mode interactions
|
|
52
|
+
*/
|
|
53
|
+
enable() {
|
|
54
|
+
this.isActive = true;
|
|
55
|
+
console.log("Design Mode Interactions enabled");
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Disable the design mode interactions
|
|
59
|
+
*/
|
|
60
|
+
disable() {
|
|
61
|
+
this.isActive = false;
|
|
62
|
+
this.eventHandlers.clearAll();
|
|
63
|
+
console.log("Design Mode Interactions disabled");
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Apply style changes to the selected element
|
|
67
|
+
* @param property - CSS property name
|
|
68
|
+
* @param value - CSS property value
|
|
69
|
+
*/
|
|
70
|
+
applyStyleChange(property, value) {
|
|
71
|
+
const selectedElement = this.eventHandlers.getSelectedElement();
|
|
72
|
+
if (selectedElement) {
|
|
73
|
+
selectedElement.style[property] = value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Cleanup and remove event listeners
|
|
78
|
+
*/
|
|
79
|
+
destroy() {
|
|
80
|
+
document.removeEventListener("mouseover", this.eventHandlers.handleMouseOver);
|
|
81
|
+
document.removeEventListener("mouseleave", this.eventHandlers.handleMouseLeave);
|
|
82
|
+
document.removeEventListener("click", this.eventHandlers.handleClick, true);
|
|
83
|
+
this.styleManager.removeHighlightStyles();
|
|
84
|
+
this.eventHandlers.clearAll();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Style Manager Module
|
|
8
|
+
* Handles CSS injection and style management for highlighting
|
|
9
|
+
*/
|
|
10
|
+
export declare class StyleManager {
|
|
11
|
+
private styleId;
|
|
12
|
+
private stylesAdded;
|
|
13
|
+
constructor();
|
|
14
|
+
/**
|
|
15
|
+
* Add CSS styles for highlighting to the document
|
|
16
|
+
*/
|
|
17
|
+
addHighlightStyles(): void;
|
|
18
|
+
/**
|
|
19
|
+
* Remove highlight styles from the document
|
|
20
|
+
*/
|
|
21
|
+
removeHighlightStyles(): void;
|
|
22
|
+
/**
|
|
23
|
+
* Get the CSS styles for highlighting
|
|
24
|
+
* @private
|
|
25
|
+
* @returns CSS styles
|
|
26
|
+
*/
|
|
27
|
+
private _getStyles;
|
|
28
|
+
/**
|
|
29
|
+
* Apply highlight class to an element
|
|
30
|
+
* @param element - The element to highlight
|
|
31
|
+
*/
|
|
32
|
+
highlightElement(element: HTMLElement): void;
|
|
33
|
+
/**
|
|
34
|
+
* Remove highlight class from an element
|
|
35
|
+
* @param element - The element to unhighlight
|
|
36
|
+
*/
|
|
37
|
+
unhighlightElement(element: HTMLElement): void;
|
|
38
|
+
/**
|
|
39
|
+
* Apply selected class to an element
|
|
40
|
+
* @param element - The element to select
|
|
41
|
+
*/
|
|
42
|
+
selectElement(element: HTMLElement): void;
|
|
43
|
+
/**
|
|
44
|
+
* Remove selected class from an element
|
|
45
|
+
* @param element - The element to deselect
|
|
46
|
+
*/
|
|
47
|
+
deselectElement(element: HTMLElement): void;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=styleManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styleManager.d.ts","sourceRoot":"","sources":["../../../src/design/interactions/styleManager.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AAEH,qBAAa,YAAY;IACxB,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,WAAW,CAAU;;IAO7B;;OAEG;IACH,kBAAkB,IAAI,IAAI;IAY1B;;OAEG;IACH,qBAAqB,IAAI,IAAI;IAQ7B;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAiBlB;;;OAGG;IACH,gBAAgB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAI5C;;;OAGG;IACH,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAI9C;;;OAGG;IACH,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;IAIzC;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI;CAG3C"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Style Manager Module
|
|
8
|
+
* Handles CSS injection and style management for highlighting
|
|
9
|
+
*/
|
|
10
|
+
export class StyleManager {
|
|
11
|
+
styleId;
|
|
12
|
+
stylesAdded;
|
|
13
|
+
constructor() {
|
|
14
|
+
this.styleId = "design-mode-styles";
|
|
15
|
+
this.stylesAdded = false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Add CSS styles for highlighting to the document
|
|
19
|
+
*/
|
|
20
|
+
addHighlightStyles() {
|
|
21
|
+
if (this.stylesAdded) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const style = document.createElement("style");
|
|
25
|
+
style.id = this.styleId;
|
|
26
|
+
style.textContent = this._getStyles();
|
|
27
|
+
document.head.appendChild(style);
|
|
28
|
+
this.stylesAdded = true;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Remove highlight styles from the document
|
|
32
|
+
*/
|
|
33
|
+
removeHighlightStyles() {
|
|
34
|
+
const style = document.getElementById(this.styleId);
|
|
35
|
+
if (style) {
|
|
36
|
+
style.remove();
|
|
37
|
+
this.stylesAdded = false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Get the CSS styles for highlighting
|
|
42
|
+
* @private
|
|
43
|
+
* @returns CSS styles
|
|
44
|
+
*/
|
|
45
|
+
_getStyles() {
|
|
46
|
+
return `
|
|
47
|
+
.design-mode-highlight {
|
|
48
|
+
outline: 4px dashed #007acc !important;
|
|
49
|
+
outline-offset: -4px !important;
|
|
50
|
+
transition: all 0.2s ease !important;
|
|
51
|
+
position: relative !important;
|
|
52
|
+
cursor: pointer !important;
|
|
53
|
+
}
|
|
54
|
+
.design-mode-selected {
|
|
55
|
+
outline: 5px dashed #ff6b35 !important;
|
|
56
|
+
outline-offset: -5px !important;
|
|
57
|
+
position: relative !important;
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Apply highlight class to an element
|
|
63
|
+
* @param element - The element to highlight
|
|
64
|
+
*/
|
|
65
|
+
highlightElement(element) {
|
|
66
|
+
element.classList.add("design-mode-highlight");
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Remove highlight class from an element
|
|
70
|
+
* @param element - The element to unhighlight
|
|
71
|
+
*/
|
|
72
|
+
unhighlightElement(element) {
|
|
73
|
+
element.classList.remove("design-mode-highlight");
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Apply selected class to an element
|
|
77
|
+
* @param element - The element to select
|
|
78
|
+
*/
|
|
79
|
+
selectElement(element) {
|
|
80
|
+
element.classList.add("design-mode-selected");
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Remove selected class from an element
|
|
84
|
+
* @param element - The element to deselect
|
|
85
|
+
*/
|
|
86
|
+
deselectElement(element) {
|
|
87
|
+
element.classList.remove("design-mode-selected");
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* CSS Utility Functions
|
|
8
|
+
* Helper functions for CSS value parsing and conversion
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Parse pixel value from CSS string (e.g., "10px" -> 10)
|
|
12
|
+
* @param value - CSS value string
|
|
13
|
+
* @returns Numeric value in pixels
|
|
14
|
+
*/
|
|
15
|
+
export declare function parsePixelValue(value: string): number;
|
|
16
|
+
/**
|
|
17
|
+
* Get all style values relevant to UI controls for an element
|
|
18
|
+
* @param element - The element
|
|
19
|
+
* @returns Object with style values (plain values safe for postMessage)
|
|
20
|
+
*/
|
|
21
|
+
export declare function getElementStyles(element: HTMLElement | null | undefined): Record<string, number | string>;
|
|
22
|
+
//# sourceMappingURL=cssUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cssUtils.d.ts","sourceRoot":"","sources":["../../../../src/design/interactions/utils/cssUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AAEH;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOrD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACrC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CA+BjC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* CSS Utility Functions
|
|
8
|
+
* Helper functions for CSS value parsing and conversion
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Parse pixel value from CSS string (e.g., "10px" -> 10)
|
|
12
|
+
* @param value - CSS value string
|
|
13
|
+
* @returns Numeric value in pixels
|
|
14
|
+
*/
|
|
15
|
+
export function parsePixelValue(value) {
|
|
16
|
+
if (!value || typeof value !== "string") {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
const match = value.match(/^(\d+(?:\.\d+)?)px$/);
|
|
20
|
+
const numberPart = match?.[1];
|
|
21
|
+
return numberPart ? Number.parseFloat(numberPart) : 0;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Get all style values relevant to UI controls for an element
|
|
25
|
+
* @param element - The element
|
|
26
|
+
* @returns Object with style values (plain values safe for postMessage)
|
|
27
|
+
*/
|
|
28
|
+
export function getElementStyles(element) {
|
|
29
|
+
if (!element) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
const computed = window.getComputedStyle(element);
|
|
33
|
+
const px = (prop) => parsePixelValue(computed[prop] || "");
|
|
34
|
+
return {
|
|
35
|
+
paddingTop: px("paddingTop"),
|
|
36
|
+
paddingRight: px("paddingRight"),
|
|
37
|
+
paddingBottom: px("paddingBottom"),
|
|
38
|
+
paddingLeft: px("paddingLeft"),
|
|
39
|
+
marginTop: px("marginTop"),
|
|
40
|
+
marginRight: px("marginRight"),
|
|
41
|
+
marginBottom: px("marginBottom"),
|
|
42
|
+
marginLeft: px("marginLeft"),
|
|
43
|
+
backgroundColor: computed.backgroundColor,
|
|
44
|
+
fontFamily: computed.fontFamily,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
export interface SourceLocation {
|
|
7
|
+
fileName: string;
|
|
8
|
+
lineNumber: number | null;
|
|
9
|
+
columnNumber: number | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extract source location information from data attributes.
|
|
13
|
+
* @param element - The DOM element
|
|
14
|
+
* @returns Source location information, or null if missing.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getSourceFromDataAttributes(element: HTMLElement | null | undefined): SourceLocation | null;
|
|
17
|
+
/**
|
|
18
|
+
* Derive a human-readable label from the injected source file name, if present.
|
|
19
|
+
* @param element - The DOM element
|
|
20
|
+
* @returns A label suitable for UI display
|
|
21
|
+
*/
|
|
22
|
+
export declare function getLabelFromSource(element: HTMLElement | null | undefined): string;
|
|
23
|
+
//# sourceMappingURL=sourceUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sourceUtils.d.ts","sourceRoot":"","sources":["../../../../src/design/interactions/utils/sourceUtils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAkCH,MAAM,WAAW,cAAc;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GACrC,cAAc,GAAG,IAAI,CAWvB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAiBlF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.,
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Source/Label Utility Functions
|
|
8
|
+
* Helper functions for extracting source metadata injected into DOM elements.
|
|
9
|
+
*/
|
|
10
|
+
function parseOptionalInt(value) {
|
|
11
|
+
if (value === null || value === undefined || value === "") {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
const parsed = Number.parseInt(String(value), 10);
|
|
15
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
16
|
+
}
|
|
17
|
+
function parseSourceFileAttribute(value) {
|
|
18
|
+
// Current injection format: "<file>:<line>:<col>".
|
|
19
|
+
// Use a greedy file capture so Windows paths like "C:\foo\bar.tsx:12:34" work.
|
|
20
|
+
const match = /^(.*):(\d+):(\d+)$/.exec(value);
|
|
21
|
+
if (!match) {
|
|
22
|
+
return { fileName: value, lineNumber: null, columnNumber: null };
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
fileName: match[1] ?? value,
|
|
26
|
+
lineNumber: parseOptionalInt(match[2]),
|
|
27
|
+
columnNumber: parseOptionalInt(match[3]),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Extract source location information from data attributes.
|
|
32
|
+
* @param element - The DOM element
|
|
33
|
+
* @returns Source location information, or null if missing.
|
|
34
|
+
*/
|
|
35
|
+
export function getSourceFromDataAttributes(element) {
|
|
36
|
+
if (!element) {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const source = element.getAttribute("data-source-file") || null;
|
|
40
|
+
if (!source) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return parseSourceFileAttribute(source);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Derive a human-readable label from the injected source file name, if present.
|
|
47
|
+
* @param element - The DOM element
|
|
48
|
+
* @returns A label suitable for UI display
|
|
49
|
+
*/
|
|
50
|
+
export function getLabelFromSource(element) {
|
|
51
|
+
if (!element) {
|
|
52
|
+
return "";
|
|
53
|
+
}
|
|
54
|
+
const source = element.getAttribute("data-source-file");
|
|
55
|
+
if (!source) {
|
|
56
|
+
return element.tagName ? element.tagName.toLowerCase() : "";
|
|
57
|
+
}
|
|
58
|
+
const { fileName } = parseSourceFileAttribute(source);
|
|
59
|
+
// Support both POSIX and Windows-style separators.
|
|
60
|
+
const parts = fileName.split(/[/\\]/);
|
|
61
|
+
const baseName = parts[parts.length - 1] || fileName;
|
|
62
|
+
console.log("baseName", baseName);
|
|
63
|
+
return baseName;
|
|
64
|
+
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/webapp-experimental",
|
|
3
3
|
"description": "[experimental] Core package for Salesforce Web Applications",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.48.1",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -24,13 +24,18 @@
|
|
|
24
24
|
"types": "./dist/proxy/index.d.ts",
|
|
25
25
|
"import": "./dist/proxy/index.js"
|
|
26
26
|
},
|
|
27
|
+
"./design": {
|
|
28
|
+
"types": "./dist/design/index.d.ts",
|
|
29
|
+
"import": "./dist/design/index.js"
|
|
30
|
+
},
|
|
27
31
|
"./package.json": "./package.json"
|
|
28
32
|
},
|
|
29
33
|
"files": [
|
|
30
34
|
"dist"
|
|
31
35
|
],
|
|
32
36
|
"scripts": {
|
|
33
|
-
"build": "tsc --build",
|
|
37
|
+
"build": "npm run build:design && tsc --build",
|
|
38
|
+
"build:design": "node src/design/bundle-interactions.mjs",
|
|
34
39
|
"postbuild": "node scripts/copy-templates.cjs",
|
|
35
40
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
36
41
|
"dev": "tsc --build --watch",
|
|
@@ -40,13 +45,14 @@
|
|
|
40
45
|
},
|
|
41
46
|
"dependencies": {
|
|
42
47
|
"@salesforce/core": "^8.23.4",
|
|
43
|
-
"@salesforce/sdk-data": "^1.
|
|
48
|
+
"@salesforce/sdk-data": "^1.48.1",
|
|
44
49
|
"axios": "^1.7.7",
|
|
45
50
|
"micromatch": "^4.0.8",
|
|
46
51
|
"path-to-regexp": "^8.3.0"
|
|
47
52
|
},
|
|
48
53
|
"devDependencies": {
|
|
49
54
|
"@types/micromatch": "^4.0.10",
|
|
55
|
+
"esbuild": "^0.24.0",
|
|
50
56
|
"vitest": "^4.0.6"
|
|
51
57
|
},
|
|
52
58
|
"engines": {
|
|
@@ -55,5 +61,5 @@
|
|
|
55
61
|
"publishConfig": {
|
|
56
62
|
"access": "public"
|
|
57
63
|
},
|
|
58
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "3a6ed78f0171a5106e8716c8154ef20e2962bf59"
|
|
59
65
|
}
|