@salesforce/metadata-core-sdk 1.5.0 → 1.7.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.
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/dist/sdk/contracts/core/IMetadataParser.d.ts +39 -0
- package/dist/sdk/contracts/core/IMetadataParser.d.ts.map +1 -1
- package/dist/sdk/contracts/types/MetadataPluginInfo.d.ts +39 -9
- package/dist/sdk/contracts/types/MetadataPluginInfo.d.ts.map +1 -1
- package/dist/sdk/contracts/types/SelectableNode.d.ts +62 -0
- package/dist/sdk/contracts/types/SelectableNode.d.ts.map +1 -0
- package/dist/sdk/contracts/types/SelectableNode.js +8 -0
- package/dist/sdk/contracts/types/SelectableNode.js.map +1 -0
- package/dist/sdk/contracts/types/index.d.ts +1 -0
- package/dist/sdk/contracts/types/index.d.ts.map +1 -1
- package/dist/sdk/contracts/types/index.js +1 -0
- package/dist/sdk/contracts/types/index.js.map +1 -1
- package/dist/sdk/hooks/vibe-edit/index.d.ts +39 -0
- package/dist/sdk/hooks/vibe-edit/index.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/index.js +42 -0
- package/dist/sdk/hooks/vibe-edit/index.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.d.ts +56 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.js +138 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGeometry.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.d.ts +66 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.js +73 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraph.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.d.ts +64 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.js +161 -0
- package/dist/sdk/hooks/vibe-edit/selection/selectionGraphEngine.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.d.ts +47 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.js +40 -0
- package/dist/sdk/hooks/vibe-edit/selection/types.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.d.ts +30 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.js +50 -0
- package/dist/sdk/hooks/vibe-edit/selection/useMarqueeSelection.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.css +26 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.d.ts +84 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.js +256 -0
- package/dist/sdk/hooks/vibe-edit/ui/MarqueeSelection.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.css +207 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.d.ts +43 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.js +80 -0
- package/dist/sdk/hooks/vibe-edit/ui/VibeEditPanel.js.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.css +79 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.d.ts +116 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.d.ts.map +1 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.js +264 -0
- package/dist/sdk/hooks/vibe-edit/ui/useVibeEdit.js.map +1 -0
- package/dist/sdk/utils/HostCommunicationUtils.d.ts +2 -0
- package/dist/sdk/utils/HostCommunicationUtils.d.ts.map +1 -1
- package/dist/sdk/utils/HostCommunicationUtils.js +11 -2
- package/dist/sdk/utils/HostCommunicationUtils.js.map +1 -1
- package/dist/sdk/webviewMessageTypes.d.ts +103 -5
- package/dist/sdk/webviewMessageTypes.d.ts.map +1 -1
- package/dist/sdk/webviewMessageTypes.js +9 -4
- package/dist/sdk/webviewMessageTypes.js.map +1 -1
- package/package.json +11 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* SelectionGraph — the runtime helpers over the normalized node contract (C1 + C4).
|
|
9
|
+
*
|
|
10
|
+
* A plugin's parser emits `SelectableNode[]` as it walks its own tree (which it
|
|
11
|
+
* already does to render). The framework/host holds this flat, uniform array and
|
|
12
|
+
* the selection engine resolves a selected DOM element to its node by a single
|
|
13
|
+
* `Map.get(id)` — it never introspects the plugin's opaque parsed shape.
|
|
14
|
+
*
|
|
15
|
+
* This dissolves the consumption side of the shape-opacity blocker (B1) and, via
|
|
16
|
+
* deterministic ids (C4), the FlexiPage `Math.random()` render-time-id wall (B3):
|
|
17
|
+
* the DOM's `data-mv-id` is set to `node.id` at render time, so selection inverts
|
|
18
|
+
* by lookup, never by re-deriving a plugin-invented encoding.
|
|
19
|
+
*
|
|
20
|
+
* What remains plugin-authored (the irreducible, one-time, feature-agnostic
|
|
21
|
+
* residue): the parser must PROJECT its bespoke shape into these nodes (B1
|
|
22
|
+
* production side) and supply a few Salesforce convention primitives (B2) —
|
|
23
|
+
* `sfdxPath` below turns those primitives into the file path so the plugin never
|
|
24
|
+
* hand-writes path strings.
|
|
25
|
+
*
|
|
26
|
+
* The node TYPES ({@link SelectableNode}, {@link SfdxPathInput}) live in the
|
|
27
|
+
* contracts layer (`contracts/types/SelectableNode.ts`) because
|
|
28
|
+
* `IMetadataParser.getSelectableNodes()` returns them and contracts must not
|
|
29
|
+
* import from hooks/. They're re-exported here so the selection layer stays the
|
|
30
|
+
* one-stop import for both the types and the helpers that operate on them.
|
|
31
|
+
*/
|
|
32
|
+
import type { SelectableNode, SfdxPathInput } from '../../../contracts/types/SelectableNode.js';
|
|
33
|
+
export type { SelectableNode, SfdxPathInput };
|
|
34
|
+
/**
|
|
35
|
+
* Compute the SFDX metadata file path for a node from its convention primitives.
|
|
36
|
+
* Encapsulates the Salesforce source-format layout (`objects/<Api>/<Api>.object-meta.xml`,
|
|
37
|
+
* decomposed fields at `objects/<Obj>/fields/<Field>.field-meta.xml`, inline
|
|
38
|
+
* fields inheriting the object file) so no plugin hand-writes these strings.
|
|
39
|
+
*
|
|
40
|
+
* Returns undefined only when there isn't enough information to place the node;
|
|
41
|
+
* callers may leave `filePath` unset (the agent can still locate by name).
|
|
42
|
+
*/
|
|
43
|
+
export declare function sfdxPath(input: SfdxPathInput): string | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Deterministic 32-bit FNV-1a hash → zero-padded 8-char hex. Pure and
|
|
46
|
+
* environment-independent (no Web/Node crypto), so the parser (host) and any
|
|
47
|
+
* render-time consumer (iframe) compute identical ids.
|
|
48
|
+
*/
|
|
49
|
+
export declare function hashString(input: string): string;
|
|
50
|
+
/**
|
|
51
|
+
* Deterministic id from a node's position in the DATA tree — NOT the DOM. The
|
|
52
|
+
* host is DOM-less, so the id must be derivable from parsed-data structure alone
|
|
53
|
+
* (this is the C4 correction: the old DOM-based `inspectPath` could not be
|
|
54
|
+
* reproduced host-side). Same inputs → same id at parse time and render time.
|
|
55
|
+
*
|
|
56
|
+
* The path is `<parentId>/<type>:<apiName>#<index>` where `index` disambiguates
|
|
57
|
+
* same-(type,apiName) siblings under one parent. Callers pass a per-parent
|
|
58
|
+
* running index (0 when apiName is already unique among siblings).
|
|
59
|
+
*
|
|
60
|
+
* @param parentId parent node's id ('' for a root)
|
|
61
|
+
* @param type node kind
|
|
62
|
+
* @param apiName node api name
|
|
63
|
+
* @param index sibling index disambiguator (default 0)
|
|
64
|
+
*/
|
|
65
|
+
export declare function structuralId(parentId: string, type: string, apiName: string, index?: number): string;
|
|
66
|
+
//# sourceMappingURL=selectionGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionGraph.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/selectionGraph.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhG,YAAY,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAwBjE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,MAAM,CAE/F"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Compute the SFDX metadata file path for a node from its convention primitives.
|
|
9
|
+
* Encapsulates the Salesforce source-format layout (`objects/<Api>/<Api>.object-meta.xml`,
|
|
10
|
+
* decomposed fields at `objects/<Obj>/fields/<Field>.field-meta.xml`, inline
|
|
11
|
+
* fields inheriting the object file) so no plugin hand-writes these strings.
|
|
12
|
+
*
|
|
13
|
+
* Returns undefined only when there isn't enough information to place the node;
|
|
14
|
+
* callers may leave `filePath` unset (the agent can still locate by name).
|
|
15
|
+
*/
|
|
16
|
+
export function sfdxPath(input) {
|
|
17
|
+
const objectsRoot = input.objectsRoot ?? 'objects';
|
|
18
|
+
switch (input.type) {
|
|
19
|
+
case 'object': {
|
|
20
|
+
if (!input.apiName) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return `${objectsRoot}/${input.apiName}/${input.apiName}.object-meta.xml`;
|
|
24
|
+
}
|
|
25
|
+
case 'field': {
|
|
26
|
+
const obj = input.parentApiName;
|
|
27
|
+
if (!obj) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
// Decomposed field: its own file. Inline field: the object's file.
|
|
31
|
+
return input.decomposed && input.apiName
|
|
32
|
+
? `${objectsRoot}/${obj}/fields/${input.apiName}.field-meta.xml`
|
|
33
|
+
: `${objectsRoot}/${obj}/${obj}.object-meta.xml`;
|
|
34
|
+
}
|
|
35
|
+
default:
|
|
36
|
+
// Non-SFDX-object node kinds (flexipage regions/components, etc.) don't map
|
|
37
|
+
// through this resolver — the plugin sets node.filePath directly.
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Deterministic 32-bit FNV-1a hash → zero-padded 8-char hex. Pure and
|
|
43
|
+
* environment-independent (no Web/Node crypto), so the parser (host) and any
|
|
44
|
+
* render-time consumer (iframe) compute identical ids.
|
|
45
|
+
*/
|
|
46
|
+
export function hashString(input) {
|
|
47
|
+
let hash = 0x811c9dc5; // FNV offset basis
|
|
48
|
+
for (let i = 0; i < input.length; i++) {
|
|
49
|
+
hash ^= input.charCodeAt(i);
|
|
50
|
+
// FNV prime (16777619) via shifts; >>> 0 keeps it unsigned 32-bit.
|
|
51
|
+
hash = (hash + ((hash << 1) + (hash << 4) + (hash << 7) + (hash << 8) + (hash << 24))) >>> 0;
|
|
52
|
+
}
|
|
53
|
+
return hash.toString(16).padStart(8, '0');
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Deterministic id from a node's position in the DATA tree — NOT the DOM. The
|
|
57
|
+
* host is DOM-less, so the id must be derivable from parsed-data structure alone
|
|
58
|
+
* (this is the C4 correction: the old DOM-based `inspectPath` could not be
|
|
59
|
+
* reproduced host-side). Same inputs → same id at parse time and render time.
|
|
60
|
+
*
|
|
61
|
+
* The path is `<parentId>/<type>:<apiName>#<index>` where `index` disambiguates
|
|
62
|
+
* same-(type,apiName) siblings under one parent. Callers pass a per-parent
|
|
63
|
+
* running index (0 when apiName is already unique among siblings).
|
|
64
|
+
*
|
|
65
|
+
* @param parentId parent node's id ('' for a root)
|
|
66
|
+
* @param type node kind
|
|
67
|
+
* @param apiName node api name
|
|
68
|
+
* @param index sibling index disambiguator (default 0)
|
|
69
|
+
*/
|
|
70
|
+
export function structuralId(parentId, type, apiName, index = 0) {
|
|
71
|
+
return `${type}_${hashString(`${parentId}/${type}:${apiName}#${index}`)}`;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=selectionGraph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionGraph.js","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/selectionGraph.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAgCJ;;;;;;;;GAQG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,IAAI,SAAS,CAAC;IACnD,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AAC,CAAC;IAC/F,CAAC;IACD,OAAO,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,QAAgB,EAAE,IAAY,EAAE,OAAe,EAAE,KAAK,GAAG,CAAC;IACrF,OAAO,GAAG,IAAI,IAAI,UAAU,CAAC,GAAG,QAAQ,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,EAAE,CAAC,EAAE,CAAC;AAC5E,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* SelectionGraph engine (C1) — the GENERIC tagger + inverter that replaces the
|
|
9
|
+
* per-plugin `buildContext`/descriptor resolvers.
|
|
10
|
+
*
|
|
11
|
+
* Given the plugin's `SelectableNode[]` (emitted by its parser) and the plugin
|
|
12
|
+
* rendering each selectable element with `data-mv-id={node.id}`, this module:
|
|
13
|
+
* 1. TAGS: finds every `[data-mv-id]` element whose id is a known node and
|
|
14
|
+
* stamps the `data-mv-selectable` + `data-mv-type` hit-test contract onto it
|
|
15
|
+
* (kept live across re-renders via a childList/subtree MutationObserver).
|
|
16
|
+
* 2. INVERTS: turns a marquee/click SelectedItem into a SpatialContext by a
|
|
17
|
+
* single `Map.get(id)` over the node list — no plugin callback, no shape
|
|
18
|
+
* traversal. Because DOM id === graph id (the plugin rendered node.id), the
|
|
19
|
+
* inversion is a pure lookup; this is what dissolves FlexiPage's B3 wall.
|
|
20
|
+
*
|
|
21
|
+
* The engine never inspects the plugin's opaque parsed data — only the flat,
|
|
22
|
+
* uniform node array. All per-plugin knowledge was paid once, in the parser's
|
|
23
|
+
* getSelectableNodes() projection.
|
|
24
|
+
*/
|
|
25
|
+
import { type SelectedItem } from './types.js';
|
|
26
|
+
import type { SpatialContext } from '../../../webviewMessageTypes.js';
|
|
27
|
+
import type { SelectableNode } from './selectionGraph.js';
|
|
28
|
+
/** Build the `id -> node` lookup the inverter uses. First-wins on duplicate ids. */
|
|
29
|
+
export declare function indexNodes(nodes: ReadonlyArray<SelectableNode>): Map<string, SelectableNode>;
|
|
30
|
+
/**
|
|
31
|
+
* Keep the hit-test contract live across the plugin's DOM churn via a
|
|
32
|
+
* MutationObserver on childList+subtree ONLY (never attributes — that would
|
|
33
|
+
* observe our own setAttribute and loop).
|
|
34
|
+
*
|
|
35
|
+
* @param nodes the SelectableNode[] for the current data
|
|
36
|
+
* @param tagged caller-owned map of {id -> tagged element}, kept in sync
|
|
37
|
+
* @returns cleanup that disconnects the observer and removes the added tags
|
|
38
|
+
*/
|
|
39
|
+
export declare function tagSelectionGraphLive(nodes: ReadonlyArray<SelectableNode>, tagged: Map<string, HTMLElement>): () => void;
|
|
40
|
+
/**
|
|
41
|
+
* Project a SelectableNode to the canonical SpatialContext the host/agent
|
|
42
|
+
* consumes. Pure, generic — no plugin knowledge. `parent` is resolved to the
|
|
43
|
+
* parent node's apiName (human-readable) when the parent is known.
|
|
44
|
+
*
|
|
45
|
+
* `fileName` is the file-level name (from the plugin data context) used as the
|
|
46
|
+
* fallback so `SpatialContext.fileName` — documented as always-available — is
|
|
47
|
+
* populated even for nodes that carry no `filePath` (e.g. flexipage
|
|
48
|
+
* region/component nodes, where `sfdxPath` returns undefined). When a node DOES
|
|
49
|
+
* carry a `filePath`, its basename takes precedence so a decomposed field points
|
|
50
|
+
* at its own `.field-meta.xml` rather than the parent object file.
|
|
51
|
+
*/
|
|
52
|
+
export declare function nodeToSpatialContext(node: SelectableNode, byId: Map<string, SelectableNode>, fileName?: string): SpatialContext;
|
|
53
|
+
/**
|
|
54
|
+
* The generic inverter: SelectedItem[] (from the marquee/click) -> SpatialContext[]
|
|
55
|
+
* by pure `Map.get(id)` over the node list. Selection carries the node id in
|
|
56
|
+
* `item.id` (the DOM's data-mv-id === node.id), so no plugin resolver runs.
|
|
57
|
+
* Unknown ids are skipped.
|
|
58
|
+
*
|
|
59
|
+
* `fileName` is the file-level fallback (the current file's basename, from the
|
|
60
|
+
* plugin data context) stamped onto every context that has no more-specific
|
|
61
|
+
* per-node file path — see {@link nodeToSpatialContext}.
|
|
62
|
+
*/
|
|
63
|
+
export declare function buildContextsFromNodes(items: ReadonlyArray<SelectedItem>, nodes: ReadonlyArray<SelectableNode>, fileName?: string): SpatialContext[];
|
|
64
|
+
//# sourceMappingURL=selectionGraphEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionGraphEngine.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/selectionGraphEngine.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAuC,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAQ5F;AAgDD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,EACpC,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,GAC/B,MAAM,IAAI,CAiBZ;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,cAAc,EACpB,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EACjC,QAAQ,CAAC,EAAE,MAAM,GAChB,cAAc,CA0BhB;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,aAAa,CAAC,YAAY,CAAC,EAClC,KAAK,EAAE,aAAa,CAAC,cAAc,CAAC,EACpC,QAAQ,CAAC,EAAE,MAAM,GAChB,cAAc,EAAE,CAUlB"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* SelectionGraph engine (C1) — the GENERIC tagger + inverter that replaces the
|
|
9
|
+
* per-plugin `buildContext`/descriptor resolvers.
|
|
10
|
+
*
|
|
11
|
+
* Given the plugin's `SelectableNode[]` (emitted by its parser) and the plugin
|
|
12
|
+
* rendering each selectable element with `data-mv-id={node.id}`, this module:
|
|
13
|
+
* 1. TAGS: finds every `[data-mv-id]` element whose id is a known node and
|
|
14
|
+
* stamps the `data-mv-selectable` + `data-mv-type` hit-test contract onto it
|
|
15
|
+
* (kept live across re-renders via a childList/subtree MutationObserver).
|
|
16
|
+
* 2. INVERTS: turns a marquee/click SelectedItem into a SpatialContext by a
|
|
17
|
+
* single `Map.get(id)` over the node list — no plugin callback, no shape
|
|
18
|
+
* traversal. Because DOM id === graph id (the plugin rendered node.id), the
|
|
19
|
+
* inversion is a pure lookup; this is what dissolves FlexiPage's B3 wall.
|
|
20
|
+
*
|
|
21
|
+
* The engine never inspects the plugin's opaque parsed data — only the flat,
|
|
22
|
+
* uniform node array. All per-plugin knowledge was paid once, in the parser's
|
|
23
|
+
* getSelectableNodes() projection.
|
|
24
|
+
*/
|
|
25
|
+
import { SELECTABLE_ATTR, TYPE_ATTR, ID_ATTR } from './types.js';
|
|
26
|
+
/** Build the `id -> node` lookup the inverter uses. First-wins on duplicate ids. */
|
|
27
|
+
export function indexNodes(nodes) {
|
|
28
|
+
const byId = new Map();
|
|
29
|
+
for (const n of nodes) {
|
|
30
|
+
if (n.id && !byId.has(n.id)) {
|
|
31
|
+
byId.set(n.id, n);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return byId;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Stamp the hit-test contract (`data-mv-selectable`, `data-mv-type`) onto every
|
|
38
|
+
* live `[data-mv-id]` element whose id is a known node. `data-mv-id` is already
|
|
39
|
+
* present (the plugin rendered it) — we only add the two attributes the marquee
|
|
40
|
+
* hit-test needs, and record which elements we tagged so teardown can undo it.
|
|
41
|
+
*/
|
|
42
|
+
function tagKnownElements(byId, tagged) {
|
|
43
|
+
if (typeof document === 'undefined') {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const next = new Map();
|
|
47
|
+
const els = document.querySelectorAll(`[${ID_ATTR}]`);
|
|
48
|
+
for (let i = 0; i < els.length; i++) {
|
|
49
|
+
const el = els.item(i);
|
|
50
|
+
const id = el.getAttribute(ID_ATTR) ?? '';
|
|
51
|
+
const node = byId.get(id);
|
|
52
|
+
if (!node) {
|
|
53
|
+
continue; // an id we don't have a node for — leave it alone
|
|
54
|
+
}
|
|
55
|
+
el.setAttribute(SELECTABLE_ATTR, '');
|
|
56
|
+
el.setAttribute(TYPE_ATTR, node.type);
|
|
57
|
+
next.set(id, el);
|
|
58
|
+
}
|
|
59
|
+
// Untag elements that are no longer present/known so stale ids can't hit-test.
|
|
60
|
+
for (const [id, el] of tagged) {
|
|
61
|
+
if (next.get(id) !== el) {
|
|
62
|
+
el.removeAttribute(SELECTABLE_ATTR);
|
|
63
|
+
el.removeAttribute(TYPE_ATTR);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
tagged.clear();
|
|
67
|
+
next.forEach((el, id) => tagged.set(id, el));
|
|
68
|
+
}
|
|
69
|
+
/** Remove the tags this engine applied (leaves the plugin's own data-mv-id intact). */
|
|
70
|
+
function clearTags(tagged) {
|
|
71
|
+
for (const el of tagged.values()) {
|
|
72
|
+
el.removeAttribute(SELECTABLE_ATTR);
|
|
73
|
+
el.removeAttribute(TYPE_ATTR);
|
|
74
|
+
}
|
|
75
|
+
tagged.clear();
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Keep the hit-test contract live across the plugin's DOM churn via a
|
|
79
|
+
* MutationObserver on childList+subtree ONLY (never attributes — that would
|
|
80
|
+
* observe our own setAttribute and loop).
|
|
81
|
+
*
|
|
82
|
+
* @param nodes the SelectableNode[] for the current data
|
|
83
|
+
* @param tagged caller-owned map of {id -> tagged element}, kept in sync
|
|
84
|
+
* @returns cleanup that disconnects the observer and removes the added tags
|
|
85
|
+
*/
|
|
86
|
+
export function tagSelectionGraphLive(nodes, tagged) {
|
|
87
|
+
const byId = indexNodes(nodes);
|
|
88
|
+
const retag = () => tagKnownElements(byId, tagged);
|
|
89
|
+
if (typeof document === 'undefined' || typeof MutationObserver === 'undefined') {
|
|
90
|
+
retag();
|
|
91
|
+
return () => clearTags(tagged);
|
|
92
|
+
}
|
|
93
|
+
retag();
|
|
94
|
+
const observer = new MutationObserver(() => retag());
|
|
95
|
+
observer.observe(document.documentElement, { childList: true, subtree: true });
|
|
96
|
+
return () => {
|
|
97
|
+
observer.disconnect();
|
|
98
|
+
clearTags(tagged);
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Project a SelectableNode to the canonical SpatialContext the host/agent
|
|
103
|
+
* consumes. Pure, generic — no plugin knowledge. `parent` is resolved to the
|
|
104
|
+
* parent node's apiName (human-readable) when the parent is known.
|
|
105
|
+
*
|
|
106
|
+
* `fileName` is the file-level name (from the plugin data context) used as the
|
|
107
|
+
* fallback so `SpatialContext.fileName` — documented as always-available — is
|
|
108
|
+
* populated even for nodes that carry no `filePath` (e.g. flexipage
|
|
109
|
+
* region/component nodes, where `sfdxPath` returns undefined). When a node DOES
|
|
110
|
+
* carry a `filePath`, its basename takes precedence so a decomposed field points
|
|
111
|
+
* at its own `.field-meta.xml` rather than the parent object file.
|
|
112
|
+
*/
|
|
113
|
+
export function nodeToSpatialContext(node, byId, fileName) {
|
|
114
|
+
const parentApiName = node.parentId ? byId.get(node.parentId)?.apiName : undefined;
|
|
115
|
+
const ctx = {
|
|
116
|
+
elementType: node.type,
|
|
117
|
+
apiName: node.apiName,
|
|
118
|
+
};
|
|
119
|
+
if (parentApiName) {
|
|
120
|
+
ctx.parent = parentApiName;
|
|
121
|
+
}
|
|
122
|
+
if (node.attributes && Object.keys(node.attributes).length > 0) {
|
|
123
|
+
ctx.attributes = node.attributes;
|
|
124
|
+
}
|
|
125
|
+
if (node.filePath) {
|
|
126
|
+
// Nodes carry the SFDX path (via sfdxPath). Surface it as filePath; the
|
|
127
|
+
// host's KO-3 fix also falls back to fileName when a host lacks fs paths.
|
|
128
|
+
ctx.filePath = node.filePath;
|
|
129
|
+
}
|
|
130
|
+
// fileName (always-available contract): the node's own file basename when it
|
|
131
|
+
// has a path, otherwise the file-level fallback. Only omitted when neither is
|
|
132
|
+
// known (a node with no path and no file-level name supplied).
|
|
133
|
+
const nodeFileName = node.filePath ? node.filePath.split('/').pop() : undefined;
|
|
134
|
+
const resolvedFileName = nodeFileName || fileName;
|
|
135
|
+
if (resolvedFileName) {
|
|
136
|
+
ctx.fileName = resolvedFileName;
|
|
137
|
+
}
|
|
138
|
+
return ctx;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* The generic inverter: SelectedItem[] (from the marquee/click) -> SpatialContext[]
|
|
142
|
+
* by pure `Map.get(id)` over the node list. Selection carries the node id in
|
|
143
|
+
* `item.id` (the DOM's data-mv-id === node.id), so no plugin resolver runs.
|
|
144
|
+
* Unknown ids are skipped.
|
|
145
|
+
*
|
|
146
|
+
* `fileName` is the file-level fallback (the current file's basename, from the
|
|
147
|
+
* plugin data context) stamped onto every context that has no more-specific
|
|
148
|
+
* per-node file path — see {@link nodeToSpatialContext}.
|
|
149
|
+
*/
|
|
150
|
+
export function buildContextsFromNodes(items, nodes, fileName) {
|
|
151
|
+
const byId = indexNodes(nodes);
|
|
152
|
+
const contexts = [];
|
|
153
|
+
for (const item of items) {
|
|
154
|
+
const node = byId.get(item.id);
|
|
155
|
+
if (node) {
|
|
156
|
+
contexts.push(nodeToSpatialContext(node, byId, fileName));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return contexts;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=selectionGraphEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionGraphEngine.js","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/selectionGraphEngine.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,OAAO,EAAqB,MAAM,YAAY,CAAC;AAIpF,oFAAoF;AACpF,MAAM,UAAU,UAAU,CAAC,KAAoC;IAC7D,MAAM,IAAI,GAAG,IAAI,GAAG,EAA0B,CAAC;IAC/C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACtB,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;YAC5B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,SAAS,gBAAgB,CACvB,IAAiC,EACjC,MAAgC;IAEhC,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpC,OAAO;IACT,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,GAAG,EAA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,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Shared, renderer-agnostic marquee selection.
|
|
9
|
+
*
|
|
10
|
+
* Any visualization (ERD nodes, UEM tree, permission-set grid, flow diagram)
|
|
11
|
+
* gets consistent drag + click selection by tagging its selectable DOM elements
|
|
12
|
+
* with three data attributes — nothing else is required of the renderer:
|
|
13
|
+
*
|
|
14
|
+
* data-mv-selectable marks the element as a selection target
|
|
15
|
+
* data-mv-type="field" the element kind (plugin-defined)
|
|
16
|
+
* data-mv-id="Obj__c::Fld__c" a stable id unique within the visualization
|
|
17
|
+
*
|
|
18
|
+
* The overlay hit-tests purely by on-screen geometry (getBoundingClientRect),
|
|
19
|
+
* so it works identically across rendering technologies and transforms
|
|
20
|
+
* (React Flow zoom/pan included), since both the marquee and the elements are
|
|
21
|
+
* measured in the same client-coordinate space.
|
|
22
|
+
*/
|
|
23
|
+
/** Data attribute names — the contract every plugin opts into. */
|
|
24
|
+
export declare const SELECTABLE_ATTR = "data-mv-selectable";
|
|
25
|
+
export declare const TYPE_ATTR = "data-mv-type";
|
|
26
|
+
export declare const ID_ATTR = "data-mv-id";
|
|
27
|
+
/**
|
|
28
|
+
* DOM attributes reflected onto the matching `[data-mv-id]` element by
|
|
29
|
+
* useVibeEdit to drive the selected/hover outline. These are DOM-internal.
|
|
30
|
+
* IMPORTANT: the CSS attribute selectors in `useVibeEdit.css`
|
|
31
|
+
* (`[data-mv-selected]`, `[data-mv-hover]`) are string literals that must
|
|
32
|
+
* mirror these exact values — keep them in sync.
|
|
33
|
+
*/
|
|
34
|
+
export declare const SELECTED_ATTR = "data-mv-selected";
|
|
35
|
+
export declare const HOVER_ATTR = "data-mv-hover";
|
|
36
|
+
/** A single selected element resolved from the DOM. */
|
|
37
|
+
export interface SelectedItem {
|
|
38
|
+
/** Plugin-defined element kind, from data-mv-type (e.g. 'object', 'field'). */
|
|
39
|
+
type: string;
|
|
40
|
+
/** Stable id within the visualization, from data-mv-id. */
|
|
41
|
+
id: string;
|
|
42
|
+
}
|
|
43
|
+
/** Fraction of an element's area the marquee must cover to select it (drag). */
|
|
44
|
+
export declare const COVERAGE_THRESHOLD = 0.5;
|
|
45
|
+
/** Pointer travel (px) under which a gesture is treated as a click, not a drag. */
|
|
46
|
+
export declare const CLICK_THRESHOLD_PX = 5;
|
|
47
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/types.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;GAeG;AAEH,kEAAkE;AAClE,eAAO,MAAM,eAAe,uBAAuB,CAAC;AACpD,eAAO,MAAM,SAAS,iBAAiB,CAAC;AACxC,eAAO,MAAM,OAAO,eAAe,CAAC;AAEpC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAChD,eAAO,MAAM,UAAU,kBAAkB,CAAC;AAE1C,uDAAuD;AACvD,MAAM,WAAW,YAAY;IAC3B,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,gFAAgF;AAChF,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,mFAAmF;AACnF,eAAO,MAAM,kBAAkB,IAAI,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
/**
|
|
8
|
+
* Shared, renderer-agnostic marquee selection.
|
|
9
|
+
*
|
|
10
|
+
* Any visualization (ERD nodes, UEM tree, permission-set grid, flow diagram)
|
|
11
|
+
* gets consistent drag + click selection by tagging its selectable DOM elements
|
|
12
|
+
* with three data attributes — nothing else is required of the renderer:
|
|
13
|
+
*
|
|
14
|
+
* data-mv-selectable marks the element as a selection target
|
|
15
|
+
* data-mv-type="field" the element kind (plugin-defined)
|
|
16
|
+
* data-mv-id="Obj__c::Fld__c" a stable id unique within the visualization
|
|
17
|
+
*
|
|
18
|
+
* The overlay hit-tests purely by on-screen geometry (getBoundingClientRect),
|
|
19
|
+
* so it works identically across rendering technologies and transforms
|
|
20
|
+
* (React Flow zoom/pan included), since both the marquee and the elements are
|
|
21
|
+
* measured in the same client-coordinate space.
|
|
22
|
+
*/
|
|
23
|
+
/** Data attribute names — the contract every plugin opts into. */
|
|
24
|
+
export const SELECTABLE_ATTR = 'data-mv-selectable';
|
|
25
|
+
export const TYPE_ATTR = 'data-mv-type';
|
|
26
|
+
export const ID_ATTR = 'data-mv-id';
|
|
27
|
+
/**
|
|
28
|
+
* DOM attributes reflected onto the matching `[data-mv-id]` element by
|
|
29
|
+
* useVibeEdit to drive the selected/hover outline. These are DOM-internal.
|
|
30
|
+
* IMPORTANT: the CSS attribute selectors in `useVibeEdit.css`
|
|
31
|
+
* (`[data-mv-selected]`, `[data-mv-hover]`) are string literals that must
|
|
32
|
+
* mirror these exact values — keep them in sync.
|
|
33
|
+
*/
|
|
34
|
+
export const SELECTED_ATTR = 'data-mv-selected';
|
|
35
|
+
export const HOVER_ATTR = 'data-mv-hover';
|
|
36
|
+
/** Fraction of an element's area the marquee must cover to select it (drag). */
|
|
37
|
+
export const COVERAGE_THRESHOLD = 0.5;
|
|
38
|
+
/** Pointer travel (px) under which a gesture is treated as a click, not a drag. */
|
|
39
|
+
export const CLICK_THRESHOLD_PX = 5;
|
|
40
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/types.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ;;;;;;;;;;;;;;;GAeG;AAEH,kEAAkE;AAClE,MAAM,CAAC,MAAM,eAAe,GAAG,oBAAoB,CAAC;AACpD,MAAM,CAAC,MAAM,SAAS,GAAG,cAAc,CAAC;AACxC,MAAM,CAAC,MAAM,OAAO,GAAG,YAAY,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAChD,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAC;AAU1C,gFAAgF;AAChF,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,mFAAmF;AACnF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import type { SelectedItem } from './types.js';
|
|
8
|
+
export interface MarqueeSelectionApi {
|
|
9
|
+
/** Selected items keyed by `type::id`. */
|
|
10
|
+
selected: Map<string, SelectedItem>;
|
|
11
|
+
/** Ordered list of selected items (insertion order). */
|
|
12
|
+
items: SelectedItem[];
|
|
13
|
+
/** Replace the whole selection. */
|
|
14
|
+
replace: (items: SelectedItem[]) => void;
|
|
15
|
+
/** Add items (no removal). */
|
|
16
|
+
add: (items: SelectedItem[]) => void;
|
|
17
|
+
/** Toggle a single item. */
|
|
18
|
+
toggle: (item: SelectedItem) => void;
|
|
19
|
+
/** Clear everything. */
|
|
20
|
+
clear: () => void;
|
|
21
|
+
/** True if a given type::id is selected. */
|
|
22
|
+
isSelected: (type: string, id: string) => boolean;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Owns the marquee selection set and exposes the four mutators the overlay
|
|
26
|
+
* drives, plus an isSelected() helper plugins use to style elements. Pure
|
|
27
|
+
* state — no DOM access — so it's trivially testable and renderer-agnostic.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useMarqueeSelection(): MarqueeSelectionApi;
|
|
30
|
+
//# sourceMappingURL=useMarqueeSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarqueeSelection.d.ts","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/useMarqueeSelection.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAIJ,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,MAAM,WAAW,mBAAmB;IAClC,0CAA0C;IAC1C,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,wDAAwD;IACxD,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,mCAAmC;IACnC,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IACzC,8BAA8B;IAC9B,GAAG,EAAE,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IACrC,4BAA4B;IAC5B,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAC;IACrC,wBAAwB;IACxB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,4CAA4C;IAC5C,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;CACnD;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,mBAAmB,CA4CzD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
8
|
+
import { itemKey } from './selectionGeometry.js';
|
|
9
|
+
/**
|
|
10
|
+
* Owns the marquee selection set and exposes the four mutators the overlay
|
|
11
|
+
* drives, plus an isSelected() helper plugins use to style elements. Pure
|
|
12
|
+
* state — no DOM access — so it's trivially testable and renderer-agnostic.
|
|
13
|
+
*/
|
|
14
|
+
export function useMarqueeSelection() {
|
|
15
|
+
const [selected, setSelected] = useState(new Map());
|
|
16
|
+
const replace = useCallback((items) => {
|
|
17
|
+
const next = new Map();
|
|
18
|
+
for (const it of items) {
|
|
19
|
+
next.set(itemKey(it), it);
|
|
20
|
+
}
|
|
21
|
+
setSelected(next);
|
|
22
|
+
}, []);
|
|
23
|
+
const add = useCallback((items) => {
|
|
24
|
+
setSelected((prev) => {
|
|
25
|
+
const next = new Map(prev);
|
|
26
|
+
for (const it of items) {
|
|
27
|
+
next.set(itemKey(it), it);
|
|
28
|
+
}
|
|
29
|
+
return next;
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
const toggle = useCallback((item) => {
|
|
33
|
+
setSelected((prev) => {
|
|
34
|
+
const next = new Map(prev);
|
|
35
|
+
const key = itemKey(item);
|
|
36
|
+
if (next.has(key)) {
|
|
37
|
+
next.delete(key);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
next.set(key, item);
|
|
41
|
+
}
|
|
42
|
+
return next;
|
|
43
|
+
});
|
|
44
|
+
}, []);
|
|
45
|
+
const clear = useCallback(() => setSelected(new Map()), []);
|
|
46
|
+
const isSelected = useCallback((type, id) => selected.has(`${type}::${id}`), [selected]);
|
|
47
|
+
const items = useMemo(() => Array.from(selected.values()), [selected]);
|
|
48
|
+
return { selected, items, replace, add, toggle, clear, isSelected };
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=useMarqueeSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMarqueeSelection.js","sourceRoot":"","sources":["../../../../../src/sdk/hooks/vibe-edit/selection/useMarqueeSelection.ts"],"names":[],"mappings":"AAAA;;;;;IAKI;AAEJ,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAoBjD;;;;GAIG;AACH,MAAM,UAAU,mBAAmB;IACjC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAA4B,IAAI,GAAG,EAAE,CAAC,CAAC;IAE/E,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,KAAqB,EAAE,EAAE;QACpD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAwB,CAAC;QAC7C,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5B,CAAC;QACD,WAAW,CAAC,IAAI,CAAC,CAAC;IACpB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,GAAG,GAAG,WAAW,CAAC,CAAC,KAAqB,EAAE,EAAE;QAChD,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE;YACnB,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;YAC3B,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;gBACvB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE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|
+
/**
|
|
2
|
+
* Copyright (c) 2025, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* Licensed under the BSD 3-Clause license.
|
|
5
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
6
|
+
**/
|
|
7
|
+
|
|
8
|
+
.mv-marquee-overlay {
|
|
9
|
+
position: absolute;
|
|
10
|
+
inset: 0;
|
|
11
|
+
z-index: 15;
|
|
12
|
+
/* Crosshair cursor while select-mode is active — the marquee/rubber-band
|
|
13
|
+
draw affordance, signalling a drag-to-select gesture rather than a plain
|
|
14
|
+
click. */
|
|
15
|
+
cursor: crosshair;
|
|
16
|
+
/* Transparent catch-all for pointer gestures while select mode is active. */
|
|
17
|
+
background: transparent;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.mv-marquee-box {
|
|
21
|
+
position: absolute;
|
|
22
|
+
pointer-events: none;
|
|
23
|
+
background: color-mix(in srgb, var(--mv-interactive-primary) 14%, transparent);
|
|
24
|
+
border: 1px solid var(--mv-interactive-primary);
|
|
25
|
+
border-radius: var(--mv-radius-sm);
|
|
26
|
+
}
|