@pairdraw/scene-graph 0.19.1 → 0.20.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/behaviours/index.d.ts +2 -2
- package/dist/behaviours/index.js +2 -2
- package/dist/behaviours/spec.d.ts +6 -1
- package/dist/behaviours/spec.d.ts.map +1 -1
- package/dist/behaviours/spec.js +62 -5
- package/dist/behaviours/spec.js.map +1 -1
- package/dist/canvas-layout.js +66 -0
- package/dist/canvas-layout.js.map +1 -0
- package/dist/components/index.d.ts +2 -2
- package/dist/components/index.js +2 -2
- package/dist/components/variants.d.ts +12 -1
- package/dist/components/variants.d.ts.map +1 -1
- package/dist/components/variants.js +30 -1
- package/dist/components/variants.js.map +1 -1
- package/dist/constants.d.ts +25 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +94 -1
- package/dist/constants.js.map +1 -1
- package/dist/coordinate.js +1 -1
- package/dist/copy.d.ts.map +1 -1
- package/dist/copy.js +17 -1
- package/dist/copy.js.map +1 -1
- package/dist/css/index.d.ts +2 -2
- package/dist/css/index.js +2 -2
- package/dist/css/text.d.ts +22 -1
- package/dist/css/text.d.ts.map +1 -1
- package/dist/css/text.js +81 -1
- package/dist/css/text.js.map +1 -1
- package/dist/design-memory/index.d.ts +3 -0
- package/dist/design-memory/index.js +3 -0
- package/dist/design-memory/model.d.ts +33 -0
- package/dist/design-memory/model.d.ts.map +1 -0
- package/dist/design-memory/model.js +142 -0
- package/dist/design-memory/model.js.map +1 -0
- package/dist/design-memory/schema.d.ts +76 -0
- package/dist/design-memory/schema.d.ts.map +1 -0
- package/dist/design-memory/schema.js +72 -0
- package/dist/design-memory/schema.js.map +1 -0
- package/dist/effects.d.ts +7 -4
- package/dist/effects.d.ts.map +1 -1
- package/dist/effects.js +9 -4
- package/dist/effects.js.map +1 -1
- package/dist/empty-values.js +93 -0
- package/dist/empty-values.js.map +1 -0
- package/dist/fields/components.d.ts +9 -0
- package/dist/fields/components.d.ts.map +1 -0
- package/dist/fields/components.js +24 -0
- package/dist/fields/components.js.map +1 -0
- package/dist/fields/index.d.ts +3 -2
- package/dist/fields/index.js +3 -2
- package/dist/fields/layout.d.ts +3 -1
- package/dist/fields/layout.d.ts.map +1 -1
- package/dist/fields/layout.js +10 -1
- package/dist/fields/layout.js.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +2 -2
- package/dist/generated/shape-with-text.d.ts +7 -2
- package/dist/generated/shape-with-text.d.ts.map +1 -1
- package/dist/generated/shape-with-text.js +20 -3
- package/dist/generated/shape-with-text.js.map +1 -1
- package/dist/graph.d.ts +8 -1
- package/dist/graph.d.ts.map +1 -1
- package/dist/graph.js +36 -7
- package/dist/graph.js.map +1 -1
- package/dist/grid-values.d.ts +10 -0
- package/dist/grid-values.d.ts.map +1 -0
- package/dist/grid-values.js +53 -0
- package/dist/grid-values.js.map +1 -0
- package/dist/group-bounds.d.ts +4 -1
- package/dist/group-bounds.d.ts.map +1 -1
- package/dist/group-bounds.js +11 -1
- package/dist/group-bounds.js.map +1 -1
- package/dist/hit-test/drop.d.ts +20 -0
- package/dist/hit-test/drop.d.ts.map +1 -0
- package/dist/hit-test/drop.js +54 -0
- package/dist/hit-test/drop.js.map +1 -0
- package/dist/hit-test/geometry.js +86 -0
- package/dist/hit-test/geometry.js.map +1 -0
- package/dist/hit-test/masks.d.ts +14 -0
- package/dist/hit-test/masks.d.ts.map +1 -0
- package/dist/hit-test/masks.js +41 -0
- package/dist/hit-test/masks.js.map +1 -0
- package/dist/hit-test/paint.d.ts +6 -0
- package/dist/hit-test/paint.d.ts.map +1 -0
- package/dist/hit-test/paint.js +19 -0
- package/dist/hit-test/paint.js.map +1 -0
- package/dist/hit-test.d.ts +4 -15
- package/dist/hit-test.d.ts.map +1 -1
- package/dist/hit-test.js +33 -178
- package/dist/hit-test.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/instances/fields.d.ts.map +1 -1
- package/dist/instances/fields.js +2 -0
- package/dist/instances/fields.js.map +1 -1
- package/dist/instances/index.d.ts +2 -1
- package/dist/instances/index.d.ts.map +1 -1
- package/dist/instances/index.js +1 -1
- package/dist/instances/index.js.map +1 -1
- package/dist/instances/source-walk.d.ts +12 -0
- package/dist/instances/source-walk.d.ts.map +1 -0
- package/dist/node-defaults.d.ts +21 -1
- package/dist/node-defaults.d.ts.map +1 -1
- package/dist/node-defaults.js +63 -50
- package/dist/node-defaults.js.map +1 -1
- package/dist/plugin-data/fields.d.ts +75 -0
- package/dist/plugin-data/fields.d.ts.map +1 -1
- package/dist/plugin-data/fields.js +18 -1
- package/dist/plugin-data/fields.js.map +1 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +2 -0
- package/dist/preview.js.map +1 -1
- package/dist/resize.d.ts.map +1 -1
- package/dist/resize.js +3 -6
- package/dist/resize.js.map +1 -1
- package/dist/scaling/node.d.ts.map +1 -1
- package/dist/scaling/node.js +28 -4
- package/dist/scaling/node.js.map +1 -1
- package/dist/shared-styles.d.ts +3 -1
- package/dist/shared-styles.d.ts.map +1 -1
- package/dist/shared-styles.js +7 -1
- package/dist/shared-styles.js.map +1 -1
- package/dist/text/path.js +11 -0
- package/dist/text/path.js.map +1 -0
- package/dist/text/picture.d.ts.map +1 -1
- package/dist/text/picture.js +5 -5
- package/dist/text/picture.js.map +1 -1
- package/dist/token-sources/document.d.ts +26 -0
- package/dist/token-sources/document.d.ts.map +1 -0
- package/dist/token-sources/document.js +80 -0
- package/dist/token-sources/document.js.map +1 -0
- package/dist/token-sources/index.d.ts +3 -0
- package/dist/token-sources/index.js +3 -0
- package/dist/token-sources/schema.d.ts +43 -0
- package/dist/token-sources/schema.d.ts.map +1 -0
- package/dist/token-sources/schema.js +50 -0
- package/dist/token-sources/schema.js.map +1 -0
- package/dist/transfer/copied.d.ts +14 -0
- package/dist/transfer/copied.d.ts.map +1 -0
- package/dist/transfer/copied.js +52 -0
- package/dist/transfer/copied.js.map +1 -0
- package/dist/transfer/index.d.ts +2 -1
- package/dist/transfer/index.js +2 -1
- package/dist/transfer/nodes.js +7 -0
- package/dist/transfer/nodes.js.map +1 -1
- package/dist/types.d.ts +104 -15
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/undo.d.ts +6 -0
- package/dist/undo.d.ts.map +1 -1
- package/dist/undo.js +13 -0
- package/dist/undo.js.map +1 -1
- package/dist/variables/index.d.ts.map +1 -1
- package/dist/variables/index.js.map +1 -1
- package/dist/variations/copy.d.ts +16 -0
- package/dist/variations/copy.d.ts.map +1 -0
- package/dist/variations/copy.js +78 -0
- package/dist/variations/copy.js.map +1 -0
- package/dist/variations/index.d.ts +6 -0
- package/dist/variations/index.js +6 -0
- package/dist/variations/match.d.ts +23 -0
- package/dist/variations/match.d.ts.map +1 -0
- package/dist/variations/match.js +80 -0
- package/dist/variations/match.js.map +1 -0
- package/dist/variations/model.d.ts +39 -0
- package/dist/variations/model.d.ts.map +1 -0
- package/dist/variations/model.js +90 -0
- package/dist/variations/model.js.map +1 -0
- package/dist/variations/pick.d.ts +43 -0
- package/dist/variations/pick.d.ts.map +1 -0
- package/dist/variations/pick.js +211 -0
- package/dist/variations/pick.js.map +1 -0
- package/dist/variations/schema.d.ts +27 -0
- package/dist/variations/schema.d.ts.map +1 -0
- package/dist/variations/schema.js +27 -0
- package/dist/variations/schema.js.map +1 -0
- package/package.json +21 -1
- package/src/behaviours/spec.ts +94 -4
- package/src/canvas-layout.ts +76 -0
- package/src/components/variants.ts +39 -0
- package/src/constants.ts +75 -0
- package/src/copy.ts +20 -1
- package/src/css/index.ts +12 -1
- package/src/css/text.ts +86 -0
- package/src/design-memory/index.ts +2 -0
- package/src/design-memory/model.ts +143 -0
- package/src/design-memory/schema.ts +84 -0
- package/src/effects.ts +16 -7
- package/src/empty-values.ts +101 -0
- package/src/fields/components.ts +21 -0
- package/src/fields/index.ts +1 -0
- package/src/fields/layout.ts +10 -0
- package/src/generated/shape-with-text.ts +28 -2
- package/src/graph.ts +48 -6
- package/src/grid-values.ts +47 -0
- package/src/group-bounds.ts +13 -0
- package/src/hit-test/drop.ts +90 -0
- package/src/hit-test/geometry.ts +131 -0
- package/src/hit-test/masks.ts +57 -0
- package/src/hit-test/paint.ts +24 -0
- package/src/hit-test.ts +78 -291
- package/src/instances/fields.ts +2 -0
- package/src/instances/index.ts +1 -0
- package/src/node-defaults.ts +71 -52
- package/src/plugin-data/fields.ts +18 -1
- package/src/preview.ts +2 -0
- package/src/resize.ts +3 -14
- package/src/scaling/node.ts +34 -5
- package/src/shared-styles.ts +8 -0
- package/src/text/path.ts +14 -0
- package/src/text/picture.ts +5 -2
- package/src/token-sources/document.ts +104 -0
- package/src/token-sources/index.ts +2 -0
- package/src/token-sources/schema.ts +59 -0
- package/src/transfer/copied.ts +72 -0
- package/src/transfer/index.ts +1 -0
- package/src/transfer/nodes.ts +10 -0
- package/src/types.ts +117 -14
- package/src/undo.ts +11 -0
- package/src/variables/index.ts +1 -4
- package/src/variations/copy.ts +89 -0
- package/src/variations/index.ts +5 -0
- package/src/variations/match.ts +100 -0
- package/src/variations/model.ts +132 -0
- package/src/variations/pick.ts +293 -0
- package/src/variations/schema.ts +29 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { containsPoint } from "./geometry.js";
|
|
2
|
+
//#region src/hit-test/drop.ts
|
|
3
|
+
const LAYER_TARGETS = /* @__PURE__ */ new Set([
|
|
4
|
+
"FRAME",
|
|
5
|
+
"SECTION",
|
|
6
|
+
"COMPONENT",
|
|
7
|
+
"INSTANCE"
|
|
8
|
+
]);
|
|
9
|
+
const COMPONENT_TARGETS = /* @__PURE__ */ new Set([
|
|
10
|
+
"FRAME",
|
|
11
|
+
"SECTION",
|
|
12
|
+
"INSTANCE"
|
|
13
|
+
]);
|
|
14
|
+
function dropRules(options) {
|
|
15
|
+
const { componentSetIds } = options;
|
|
16
|
+
if (!componentSetIds) return {
|
|
17
|
+
takes: (node) => LAYER_TARGETS.has(node.type),
|
|
18
|
+
passThrough: /* @__PURE__ */ new Set(["GROUP", "COMPONENT_SET"])
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
takes: (node) => COMPONENT_TARGETS.has(node.type) || node.type === "COMPONENT_SET" && componentSetIds.has(node.id),
|
|
22
|
+
passThrough: /* @__PURE__ */ new Set(["GROUP"])
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function dropTargetIn(graph, px, py, parent, excludeIds, rules, transformCache) {
|
|
26
|
+
if (parent.type !== "CANVAS" && parent.clipsContent && !containsPoint(px, py, parent, graph, transformCache)) return null;
|
|
27
|
+
for (let i = parent.childIds.length - 1; i >= 0; i--) {
|
|
28
|
+
const childId = parent.childIds[i];
|
|
29
|
+
if (excludeIds.has(childId)) continue;
|
|
30
|
+
const child = graph.nodes.get(childId);
|
|
31
|
+
if (!child || child.internalOnly || !child.visible || child.locked) continue;
|
|
32
|
+
const target = rules.takes(child);
|
|
33
|
+
if (!target && !rules.passThrough.has(child.type)) continue;
|
|
34
|
+
const deeper = dropTargetIn(graph, px, py, child, excludeIds, rules, transformCache);
|
|
35
|
+
if (deeper) return deeper;
|
|
36
|
+
if (target && containsPoint(px, py, child, graph, transformCache)) return child;
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The topmost unlocked frame, section, component, or instance under the point, in its rotated
|
|
42
|
+
* shape and inside its clipping ancestors. Groups and component sets are looked through but never
|
|
43
|
+
* returned, except that a set takes dropped components; locked layers and their contents are
|
|
44
|
+
* skipped.
|
|
45
|
+
*/
|
|
46
|
+
function hitTestDropTarget(graph, px, py, excludeIds, scopeId, options = {}) {
|
|
47
|
+
const scope = graph.nodes.get(scopeId ?? graph.rootId);
|
|
48
|
+
if (!scope) return null;
|
|
49
|
+
return dropTargetIn(graph, px, py, scope, excludeIds, dropRules(options), /* @__PURE__ */ new Map());
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { hitTestDropTarget };
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=drop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop.js","names":[],"sources":["../../src/hit-test/drop.ts"],"sourcesContent":["// Where dragged layers land: the frame, section, component, or instance under the point.\nimport type { SceneGraph } from '../graph'\nimport type { NodeType, SceneNode } from '../types'\nimport { containsPoint } from './geometry'\n\n/** Which layers take a drop, and which are only looked through, as in Figma. */\ninterface DropRules {\n takes: (node: SceneNode) => boolean\n passThrough: ReadonlySet<NodeType>\n}\n\nconst LAYER_TARGETS = new Set<NodeType>(['FRAME', 'SECTION', 'COMPONENT', 'INSTANCE'])\nconst COMPONENT_TARGETS = new Set<NodeType>(['FRAME', 'SECTION', 'INSTANCE'])\n\nfunction dropRules(options: DropTargetOptions): DropRules {\n const { componentSetIds } = options\n if (!componentSetIds) {\n return {\n takes: (node) => LAYER_TARGETS.has(node.type),\n passThrough: new Set(['GROUP', 'COMPONENT_SET'])\n }\n }\n // Components never go into other components, and a set only takes back its own variants.\n return {\n takes: (node) =>\n COMPONENT_TARGETS.has(node.type) ||\n (node.type === 'COMPONENT_SET' && componentSetIds.has(node.id)),\n passThrough: new Set(['GROUP'])\n }\n}\n\nfunction dropTargetIn(\n graph: SceneGraph,\n px: number,\n py: number,\n parent: SceneNode,\n excludeIds: ReadonlySet<string>,\n rules: DropRules,\n transformCache: Map<string, boolean>\n): SceneNode | null {\n // A clipped-away part of a child is not under the cursor.\n if (\n parent.type !== 'CANVAS' &&\n parent.clipsContent &&\n !containsPoint(px, py, parent, graph, transformCache)\n )\n return null\n\n for (let i = parent.childIds.length - 1; i >= 0; i--) {\n const childId = parent.childIds[i]\n if (excludeIds.has(childId)) continue\n const child = graph.nodes.get(childId)\n if (!child || child.internalOnly || !child.visible || child.locked) continue\n const target = rules.takes(child)\n if (!target && !rules.passThrough.has(child.type)) continue\n\n const deeper = dropTargetIn(graph, px, py, child, excludeIds, rules, transformCache)\n if (deeper) return deeper\n if (target && containsPoint(px, py, child, graph, transformCache)) return child\n }\n\n return null\n}\n\nexport interface DropTargetOptions {\n /**\n * Set when the dropped layers are all main components: the component sets they come from.\n * Components then go only into frames, sections, instances, and those sets.\n */\n componentSetIds?: ReadonlySet<string>\n}\n\n/**\n * The topmost unlocked frame, section, component, or instance under the point, in its rotated\n * shape and inside its clipping ancestors. Groups and component sets are looked through but never\n * returned, except that a set takes dropped components; locked layers and their contents are\n * skipped.\n */\nexport function hitTestDropTarget(\n graph: SceneGraph,\n px: number,\n py: number,\n excludeIds: ReadonlySet<string>,\n scopeId?: string,\n options: DropTargetOptions = {}\n): SceneNode | null {\n const scope = graph.nodes.get(scopeId ?? graph.rootId)\n if (!scope) return null\n return dropTargetIn(graph, px, py, scope, excludeIds, dropRules(options), new Map())\n}\n"],"mappings":";;AAWA,MAAM,gCAAgB,IAAI,IAAc;CAAC;CAAS;CAAW;CAAa;AAAU,CAAC;AACrF,MAAM,oCAAoB,IAAI,IAAc;CAAC;CAAS;CAAW;AAAU,CAAC;AAE5E,SAAS,UAAU,SAAuC;CACxD,MAAM,EAAE,oBAAoB;CAC5B,IAAI,CAAC,iBACH,OAAO;EACL,QAAQ,SAAS,cAAc,IAAI,KAAK,IAAI;EAC5C,6BAAa,IAAI,IAAI,CAAC,SAAS,eAAe,CAAC;CACjD;CAGF,OAAO;EACL,QAAQ,SACN,kBAAkB,IAAI,KAAK,IAAI,KAC9B,KAAK,SAAS,mBAAmB,gBAAgB,IAAI,KAAK,EAAE;EAC/D,6BAAa,IAAI,IAAI,CAAC,OAAO,CAAC;CAChC;AACF;AAEA,SAAS,aACP,OACA,IACA,IACA,QACA,YACA,OACA,gBACkB;CAElB,IACE,OAAO,SAAS,YAChB,OAAO,gBACP,CAAC,cAAc,IAAI,IAAI,QAAQ,OAAO,cAAc,GAEpD,OAAO;CAET,KAAK,IAAI,IAAI,OAAO,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK;EACpD,MAAM,UAAU,OAAO,SAAS;EAChC,IAAI,WAAW,IAAI,OAAO,GAAG;EAC7B,MAAM,QAAQ,MAAM,MAAM,IAAI,OAAO;EACrC,IAAI,CAAC,SAAS,MAAM,gBAAgB,CAAC,MAAM,WAAW,MAAM,QAAQ;EACpE,MAAM,SAAS,MAAM,MAAM,KAAK;EAChC,IAAI,CAAC,UAAU,CAAC,MAAM,YAAY,IAAI,MAAM,IAAI,GAAG;EAEnD,MAAM,SAAS,aAAa,OAAO,IAAI,IAAI,OAAO,YAAY,OAAO,cAAc;EACnF,IAAI,QAAQ,OAAO;EACnB,IAAI,UAAU,cAAc,IAAI,IAAI,OAAO,OAAO,cAAc,GAAG,OAAO;CAC5E;CAEA,OAAO;AACT;;;;;;;AAgBA,SAAgB,kBACd,OACA,IACA,IACA,YACA,SACA,UAA6B,CAAC,GACZ;CAClB,MAAM,QAAQ,MAAM,MAAM,IAAI,WAAW,MAAM,MAAM;CACrD,IAAI,CAAC,OAAO,OAAO;CACnB,OAAO,aAAa,OAAO,IAAI,IAAI,OAAO,YAAY,UAAU,OAAO,mBAAG,IAAI,IAAI,CAAC;AACrF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import Matrix from "../matrix.js";
|
|
2
|
+
import { getWorldMatrix } from "../coordinate.js";
|
|
3
|
+
import { geometryBlobPolylines } from "../geometry.js";
|
|
4
|
+
//#region src/hit-test/geometry.ts
|
|
5
|
+
/**
|
|
6
|
+
* How far from a zero-width or zero-height layer, in canvas units, a point still lands on it, so
|
|
7
|
+
* a flat line or an empty box stays clickable; matches a connector line's slop (`connectors/hit.ts`).
|
|
8
|
+
*/
|
|
9
|
+
const DEGENERATE_AXIS_SLOP = 4;
|
|
10
|
+
function hasTransformedAncestor(node, graph, cache) {
|
|
11
|
+
const cached = cache.get(node.id);
|
|
12
|
+
if (cached !== void 0) return cached;
|
|
13
|
+
const parent = node.parentId ? graph.getNode(node.parentId) : void 0;
|
|
14
|
+
const transformed = node.rotation !== 0 || node.flipX || node.flipY || (parent ? hasTransformedAncestor(parent, graph, cache) : false);
|
|
15
|
+
cache.set(node.id, transformed);
|
|
16
|
+
return transformed;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Where the point lies in the node's own coordinates: its offset from the position when nothing
|
|
20
|
+
* above it is turned, else through the inverse world matrix. Null when that cannot be inverted.
|
|
21
|
+
*/
|
|
22
|
+
function localPoint(px, py, node, graph, transformCache) {
|
|
23
|
+
if (!hasTransformedAncestor(node, graph, transformCache)) {
|
|
24
|
+
const absolute = graph.getAbsolutePosition(node.id);
|
|
25
|
+
return {
|
|
26
|
+
x: px - absolute.x,
|
|
27
|
+
y: py - absolute.y
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const inv = Matrix.invert(getWorldMatrix(node, graph));
|
|
31
|
+
if (!inv) return null;
|
|
32
|
+
const [x, y] = Matrix.mapPoints(inv, [px, py]);
|
|
33
|
+
return {
|
|
34
|
+
x,
|
|
35
|
+
y
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Whether the point lies in the node's box, grown by `pad` canvas units on every side. */
|
|
39
|
+
function containsPoint(px, py, node, graph, transformCache, pad = 0) {
|
|
40
|
+
const local = localPoint(px, py, node, graph, transformCache);
|
|
41
|
+
if (!local) return false;
|
|
42
|
+
const padX = node.width > 0 ? pad : Math.max(pad, DEGENERATE_AXIS_SLOP);
|
|
43
|
+
const padY = node.height > 0 ? pad : Math.max(pad, DEGENERATE_AXIS_SLOP);
|
|
44
|
+
return local.x >= -padX && local.x <= node.width + padX && local.y >= -padY && local.y <= node.height + padY;
|
|
45
|
+
}
|
|
46
|
+
/** Whether a rounded rectangle of `width` × `height` holds the point. */
|
|
47
|
+
function roundedRectContains(point, width, height, radius) {
|
|
48
|
+
if (point.x < 0 || point.y < 0 || point.x > width || point.y > height) return false;
|
|
49
|
+
const r = Math.max(0, Math.min(radius, width / 2, height / 2));
|
|
50
|
+
const cx = Math.min(Math.max(point.x, r), width - r);
|
|
51
|
+
const cy = Math.min(Math.max(point.y, r), height - r);
|
|
52
|
+
return Math.hypot(point.x - cx, point.y - cy) <= r;
|
|
53
|
+
}
|
|
54
|
+
/** Whether the point is inside a closed polyline, by the even-odd rule. */
|
|
55
|
+
function insidePolyline(polyline, x, y) {
|
|
56
|
+
let inside = false;
|
|
57
|
+
for (let i = 0, j = polyline.length - 1; i < polyline.length; j = i++) {
|
|
58
|
+
const a = polyline[i];
|
|
59
|
+
const b = polyline[j];
|
|
60
|
+
if (a.y > y === b.y > y) continue;
|
|
61
|
+
if (x < (b.x - a.x) * (y - a.y) / (b.y - a.y) + a.x) inside = !inside;
|
|
62
|
+
}
|
|
63
|
+
return inside;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Whether a mask lets the point through, by the outline it draws: an ellipse's curve, a rounded
|
|
67
|
+
* rectangle's corners, or a vector's filled path. Other shapes clip by their box.
|
|
68
|
+
*/
|
|
69
|
+
function maskContainsPoint(px, py, mask, graph, transformCache) {
|
|
70
|
+
if (!(mask.type === "ELLIPSE" && mask.width > 0 && mask.height > 0 || mask.type === "RECTANGLE" && mask.cornerRadius > 0 || mask.type === "VECTOR" && mask.fillGeometry.length > 0)) return containsPoint(px, py, mask, graph, transformCache);
|
|
71
|
+
const local = localPoint(px, py, mask, graph, transformCache);
|
|
72
|
+
if (!local) return false;
|
|
73
|
+
if (mask.type === "ELLIPSE") {
|
|
74
|
+
const rx = mask.width / 2;
|
|
75
|
+
const ry = mask.height / 2;
|
|
76
|
+
const dx = (local.x - rx) / rx;
|
|
77
|
+
const dy = (local.y - ry) / ry;
|
|
78
|
+
return dx * dx + dy * dy <= 1;
|
|
79
|
+
}
|
|
80
|
+
if (mask.type === "RECTANGLE") return roundedRectContains(local, mask.width, mask.height, mask.cornerRadius);
|
|
81
|
+
return geometryBlobPolylines(mask.fillGeometry).some((points) => insidePolyline(points, local.x, local.y));
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { containsPoint, localPoint, maskContainsPoint };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=geometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"geometry.js","names":[],"sources":["../../src/hit-test/geometry.ts"],"sourcesContent":["// Where a point lies against a layer's box and a mask's outline, in the layer's own coordinates.\nimport { getWorldMatrix } from '../coordinate'\nimport { geometryBlobPolylines } from '../geometry'\nimport type { SceneGraph } from '../graph'\nimport Matrix from '../matrix'\nimport type { Vector } from '../primitives'\nimport type { SceneNode } from '../types'\n\n/**\n * How far from a zero-width or zero-height layer, in canvas units, a point still lands on it, so\n * a flat line or an empty box stays clickable; matches a connector line's slop (`connectors/hit.ts`).\n */\nconst DEGENERATE_AXIS_SLOP = 4\n\nfunction hasTransformedAncestor(\n node: SceneNode,\n graph: SceneGraph,\n cache: Map<string, boolean>\n): boolean {\n const cached = cache.get(node.id)\n if (cached !== undefined) return cached\n const parent = node.parentId ? graph.getNode(node.parentId) : undefined\n const transformed =\n node.rotation !== 0 ||\n node.flipX ||\n node.flipY ||\n (parent ? hasTransformedAncestor(parent, graph, cache) : false)\n cache.set(node.id, transformed)\n return transformed\n}\n\n/**\n * Where the point lies in the node's own coordinates: its offset from the position when nothing\n * above it is turned, else through the inverse world matrix. Null when that cannot be inverted.\n */\nexport function localPoint(\n px: number,\n py: number,\n node: SceneNode,\n graph: SceneGraph,\n transformCache: Map<string, boolean>\n): Vector | null {\n if (!hasTransformedAncestor(node, graph, transformCache)) {\n const absolute = graph.getAbsolutePosition(node.id)\n return { x: px - absolute.x, y: py - absolute.y }\n }\n const inv = Matrix.invert(getWorldMatrix(node, graph))\n if (!inv) return null\n const [x, y] = Matrix.mapPoints(inv, [px, py])\n return { x, y }\n}\n\n/** Whether the point lies in the node's box, grown by `pad` canvas units on every side. */\nexport function containsPoint(\n px: number,\n py: number,\n node: SceneNode,\n graph: SceneGraph,\n transformCache: Map<string, boolean>,\n pad = 0\n): boolean {\n const local = localPoint(px, py, node, graph, transformCache)\n if (!local) return false\n const padX = node.width > 0 ? pad : Math.max(pad, DEGENERATE_AXIS_SLOP)\n const padY = node.height > 0 ? pad : Math.max(pad, DEGENERATE_AXIS_SLOP)\n return (\n local.x >= -padX &&\n local.x <= node.width + padX &&\n local.y >= -padY &&\n local.y <= node.height + padY\n )\n}\n\n/** Whether a rounded rectangle of `width` × `height` holds the point. */\nfunction roundedRectContains(\n point: Vector,\n width: number,\n height: number,\n radius: number\n): boolean {\n if (point.x < 0 || point.y < 0 || point.x > width || point.y > height) return false\n const r = Math.max(0, Math.min(radius, width / 2, height / 2))\n const cx = Math.min(Math.max(point.x, r), width - r)\n const cy = Math.min(Math.max(point.y, r), height - r)\n return Math.hypot(point.x - cx, point.y - cy) <= r\n}\n\n/** Whether the point is inside a closed polyline, by the even-odd rule. */\nfunction insidePolyline(polyline: readonly Vector[], x: number, y: number): boolean {\n let inside = false\n for (let i = 0, j = polyline.length - 1; i < polyline.length; j = i++) {\n const a = polyline[i]\n const b = polyline[j]\n if (a.y > y === b.y > y) continue\n if (x < ((b.x - a.x) * (y - a.y)) / (b.y - a.y) + a.x) inside = !inside\n }\n return inside\n}\n\n/**\n * Whether a mask lets the point through, by the outline it draws: an ellipse's curve, a rounded\n * rectangle's corners, or a vector's filled path. Other shapes clip by their box.\n */\nexport function maskContainsPoint(\n px: number,\n py: number,\n mask: SceneNode,\n graph: SceneGraph,\n transformCache: Map<string, boolean>\n): boolean {\n const outlined =\n (mask.type === 'ELLIPSE' && mask.width > 0 && mask.height > 0) ||\n (mask.type === 'RECTANGLE' && mask.cornerRadius > 0) ||\n (mask.type === 'VECTOR' && mask.fillGeometry.length > 0)\n if (!outlined) return containsPoint(px, py, mask, graph, transformCache)\n const local = localPoint(px, py, mask, graph, transformCache)\n if (!local) return false\n if (mask.type === 'ELLIPSE') {\n const rx = mask.width / 2\n const ry = mask.height / 2\n const dx = (local.x - rx) / rx\n const dy = (local.y - ry) / ry\n return dx * dx + dy * dy <= 1\n }\n if (mask.type === 'RECTANGLE') {\n return roundedRectContains(local, mask.width, mask.height, mask.cornerRadius)\n }\n return geometryBlobPolylines(mask.fillGeometry).some((points) =>\n insidePolyline(points, local.x, local.y)\n )\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SceneGraph } from "../graph.js";
|
|
2
|
+
import { SceneNode } from "../types.js";
|
|
3
|
+
//#region src/hit-test/masks.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The masks that clip each child, by index, as the renderer groups them (`core/canvas/masks.ts`):
|
|
6
|
+
* a run of visible masks clips the layers after it up to the next visible mask. Empty when the
|
|
7
|
+
* container has no visible mask.
|
|
8
|
+
*/
|
|
9
|
+
declare function clippingMasks(graph: SceneGraph, childIds: readonly string[]): SceneNode[][];
|
|
10
|
+
/** Whether a point lies outside every mask of a run that clips a layer, so the layer hides it. */
|
|
11
|
+
declare function isPointMaskedOut(graph: SceneGraph, masks: readonly SceneNode[] | undefined, px: number, py: number): boolean;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { clippingMasks, isPointMaskedOut };
|
|
14
|
+
//# sourceMappingURL=masks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masks.d.ts","names":[],"sources":["../../src/hit-test/masks.ts"],"mappings":";;;;;;;;iBAcgB,cAAc,OAAO,YAAY,8BAA8B;;iBAmC/D,iBACd,OAAO,YACP,gBAAgB,yBAChB,YACA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { maskContainsPoint } from "./geometry.js";
|
|
2
|
+
//#region src/hit-test/masks.ts
|
|
3
|
+
function isVisibleMask(node) {
|
|
4
|
+
return node !== void 0 && node.visible && node.isMask;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The masks that clip each child, by index, as the renderer groups them (`core/canvas/masks.ts`):
|
|
8
|
+
* a run of visible masks clips the layers after it up to the next visible mask. Empty when the
|
|
9
|
+
* container has no visible mask.
|
|
10
|
+
*/
|
|
11
|
+
function clippingMasks(graph, childIds) {
|
|
12
|
+
const children = childIds.map((childId) => graph.nodes.get(childId));
|
|
13
|
+
if (!children.some(isVisibleMask)) return [];
|
|
14
|
+
const result = [];
|
|
15
|
+
let run = [];
|
|
16
|
+
let previousWasMask = false;
|
|
17
|
+
for (const child of children) {
|
|
18
|
+
if (isVisibleMask(child)) {
|
|
19
|
+
run = previousWasMask ? [...run, child] : [child];
|
|
20
|
+
previousWasMask = true;
|
|
21
|
+
result.push([]);
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
previousWasMask = false;
|
|
25
|
+
result.push(run);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
/** Whether the masks that clip a layer leave the point outside every one of their outlines. */
|
|
30
|
+
function isMaskedOut(px, py, masks, graph, transformCache) {
|
|
31
|
+
if (!masks) return false;
|
|
32
|
+
return masks.length > 0 && !masks.some((mask) => maskContainsPoint(px, py, mask, graph, transformCache));
|
|
33
|
+
}
|
|
34
|
+
/** Whether a point lies outside every mask of a run that clips a layer, so the layer hides it. */
|
|
35
|
+
function isPointMaskedOut(graph, masks, px, py) {
|
|
36
|
+
return isMaskedOut(px, py, masks, graph, /* @__PURE__ */ new Map());
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { clippingMasks, isMaskedOut, isPointMaskedOut };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=masks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masks.js","names":[],"sources":["../../src/hit-test/masks.ts"],"sourcesContent":["// The masks that clip a container's children, and whether they hide a point.\nimport type { SceneGraph } from '../graph'\nimport type { SceneNode } from '../types'\nimport { maskContainsPoint } from './geometry'\n\nfunction isVisibleMask(node: SceneNode | undefined): node is SceneNode {\n return node !== undefined && node.visible && node.isMask\n}\n\n/**\n * The masks that clip each child, by index, as the renderer groups them (`core/canvas/masks.ts`):\n * a run of visible masks clips the layers after it up to the next visible mask. Empty when the\n * container has no visible mask.\n */\nexport function clippingMasks(graph: SceneGraph, childIds: readonly string[]): SceneNode[][] {\n const children = childIds.map((childId) => graph.nodes.get(childId))\n if (!children.some(isVisibleMask)) return []\n const result: SceneNode[][] = []\n let run: SceneNode[] = []\n let previousWasMask = false\n for (const child of children) {\n if (isVisibleMask(child)) {\n run = previousWasMask ? [...run, child] : [child]\n previousWasMask = true\n result.push([])\n continue\n }\n previousWasMask = false\n result.push(run)\n }\n return result\n}\n\n/** Whether the masks that clip a layer leave the point outside every one of their outlines. */\nexport function isMaskedOut(\n px: number,\n py: number,\n masks: readonly SceneNode[] | undefined,\n graph: SceneGraph,\n transformCache: Map<string, boolean>\n): boolean {\n if (!masks) return false\n return (\n masks.length > 0 &&\n !masks.some((mask) => maskContainsPoint(px, py, mask, graph, transformCache))\n )\n}\n\n/** Whether a point lies outside every mask of a run that clips a layer, so the layer hides it. */\nexport function isPointMaskedOut(\n graph: SceneGraph,\n masks: readonly SceneNode[] | undefined,\n px: number,\n py: number\n): boolean {\n return isMaskedOut(px, py, masks, graph, new Map())\n}\n"],"mappings":";;AAKA,SAAS,cAAc,MAAgD;CACrE,OAAO,SAAS,KAAA,KAAa,KAAK,WAAW,KAAK;AACpD;;;;;;AAOA,SAAgB,cAAc,OAAmB,UAA4C;CAC3F,MAAM,WAAW,SAAS,KAAK,YAAY,MAAM,MAAM,IAAI,OAAO,CAAC;CACnE,IAAI,CAAC,SAAS,KAAK,aAAa,GAAG,OAAO,CAAC;CAC3C,MAAM,SAAwB,CAAC;CAC/B,IAAI,MAAmB,CAAC;CACxB,IAAI,kBAAkB;CACtB,KAAK,MAAM,SAAS,UAAU;EAC5B,IAAI,cAAc,KAAK,GAAG;GACxB,MAAM,kBAAkB,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,KAAK;GAChD,kBAAkB;GAClB,OAAO,KAAK,CAAC,CAAC;GACd;EACF;EACA,kBAAkB;EAClB,OAAO,KAAK,GAAG;CACjB;CACA,OAAO;AACT;;AAGA,SAAgB,YACd,IACA,IACA,OACA,OACA,gBACS;CACT,IAAI,CAAC,OAAO,OAAO;CACnB,OACE,MAAM,SAAS,KACf,CAAC,MAAM,MAAM,SAAS,kBAAkB,IAAI,IAAI,MAAM,OAAO,cAAc,CAAC;AAEhF;;AAGA,SAAgB,iBACd,OACA,OACA,IACA,IACS;CACT,OAAO,YAAY,IAAI,IAAI,OAAO,uBAAO,IAAI,IAAI,CAAC;AACpD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint.d.ts","names":[],"sources":["../../src/hit-test/paint.ts"],"mappings":";;iBAqBgB,WAAW,MAAM"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/hit-test/paint.ts
|
|
2
|
+
/**
|
|
3
|
+
* Whether a paint shows, so its container's empty area counts when a click reaches past
|
|
4
|
+
* containers: a paint at 0% opacity, or a gradient whose stops are all transparent, does not,
|
|
5
|
+
* while 1% does, and the layer's own opacity does not matter.
|
|
6
|
+
*/
|
|
7
|
+
function isHitPaint(paint) {
|
|
8
|
+
if (!paint.visible || !(paint.opacity > 0)) return false;
|
|
9
|
+
if (paint.type === "SOLID") return paint.color.a > 0;
|
|
10
|
+
if (paint.type === "GRADIENT_LINEAR" || paint.type === "GRADIENT_RADIAL" || paint.type === "GRADIENT_ANGULAR" || paint.type === "GRADIENT_DIAMOND") return (paint.gradientStops ?? []).some((stop) => stop.color.a > 0);
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
function showsPaint(node) {
|
|
14
|
+
return node.fills.some(isHitPaint) || node.strokes.some(isHitPaint);
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { showsPaint };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=paint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint.js","names":[],"sources":["../../src/hit-test/paint.ts"],"sourcesContent":["// Which layers show a paint where a pointer lands, so their area takes it.\nimport type { SceneNode } from '../types'\n\n/**\n * Whether a paint shows, so its container's empty area counts when a click reaches past\n * containers: a paint at 0% opacity, or a gradient whose stops are all transparent, does not,\n * while 1% does, and the layer's own opacity does not matter.\n */\nfunction isHitPaint(paint: SceneNode['fills'][number]): boolean {\n if (!paint.visible || !(paint.opacity > 0)) return false\n if (paint.type === 'SOLID') return paint.color.a > 0\n if (\n paint.type === 'GRADIENT_LINEAR' ||\n paint.type === 'GRADIENT_RADIAL' ||\n paint.type === 'GRADIENT_ANGULAR' ||\n paint.type === 'GRADIENT_DIAMOND'\n )\n return (paint.gradientStops ?? []).some((stop) => stop.color.a > 0)\n return true\n}\n\nexport function showsPaint(node: SceneNode): boolean {\n return node.fills.some(isHitPaint) || node.strokes.some(isHitPaint)\n}\n"],"mappings":";;;;;;AAQA,SAAS,WAAW,OAA4C;CAC9D,IAAI,CAAC,MAAM,WAAW,EAAE,MAAM,UAAU,IAAI,OAAO;CACnD,IAAI,MAAM,SAAS,SAAS,OAAO,MAAM,MAAM,IAAI;CACnD,IACE,MAAM,SAAS,qBACf,MAAM,SAAS,qBACf,MAAM,SAAS,sBACf,MAAM,SAAS,oBAEf,QAAQ,MAAM,iBAAiB,CAAC,EAAA,CAAG,MAAM,SAAS,KAAK,MAAM,IAAI,CAAC;CACpE,OAAO;AACT;AAEA,SAAgB,WAAW,MAA0B;CACnD,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,KAAK,QAAQ,KAAK,UAAU;AACpE"}
|
package/dist/hit-test.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { Rect } from "./primitives/index.js";
|
|
2
|
+
import { clippingMasks, isPointMaskedOut } from "./hit-test/masks.js";
|
|
3
|
+
import { DropTargetOptions, hitTestDropTarget } from "./hit-test/drop.js";
|
|
4
|
+
import { showsPaint } from "./hit-test/paint.js";
|
|
2
5
|
import { SceneGraph } from "./graph.js";
|
|
3
6
|
import { SceneNode } from "./types.js";
|
|
4
7
|
//#region src/hit-test.d.ts
|
|
@@ -32,20 +35,6 @@ declare function hitTestOpenContainer(graph: SceneGraph, px: number, py: number,
|
|
|
32
35
|
declare function hitTestDeepInRect(graph: SceneGraph, rect: Rect, scopeId: string): SceneNode[];
|
|
33
36
|
/** Whether the point lies inside the node's rotated and flipped bounds. */
|
|
34
37
|
declare function isPointInNode(graph: SceneGraph, nodeId: string, px: number, py: number): boolean;
|
|
35
|
-
interface DropTargetOptions {
|
|
36
|
-
/**
|
|
37
|
-
* Set when the dropped layers are all main components: the component sets they come from.
|
|
38
|
-
* Components then go only into frames, sections, instances, and those sets.
|
|
39
|
-
*/
|
|
40
|
-
componentSetIds?: ReadonlySet<string>;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* The topmost unlocked frame, section, component, or instance under the point, in its rotated
|
|
44
|
-
* shape and inside its clipping ancestors. Groups and component sets are looked through but never
|
|
45
|
-
* returned, except that a set takes dropped components; locked layers and their contents are
|
|
46
|
-
* skipped.
|
|
47
|
-
*/
|
|
48
|
-
declare function hitTestDropTarget(graph: SceneGraph, px: number, py: number, excludeIds: ReadonlySet<string>, scopeId?: string, options?: DropTargetOptions): SceneNode | null;
|
|
49
38
|
//#endregion
|
|
50
|
-
export { DropTargetOptions, hitTest, hitTestDeep, hitTestDeepInRect, hitTestDropTarget, hitTestOpenContainer, hitTestSelectable, isOpenContainer, isPointInNode };
|
|
39
|
+
export { type DropTargetOptions, clippingMasks, hitTest, hitTestDeep, hitTestDeepInRect, hitTestDropTarget, hitTestOpenContainer, hitTestSelectable, isOpenContainer, isPointInNode, isPointMaskedOut, showsPaint };
|
|
51
40
|
//# sourceMappingURL=hit-test.d.ts.map
|
package/dist/hit-test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hit-test.d.ts","names":[],"sources":["../src/hit-test.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"hit-test.d.ts","names":[],"sources":["../src/hit-test.ts"],"mappings":";;;;;;;iBA6NgB,QACd,OAAO,YACP,YACA,YACA,mBACC;iBAKa,YACd,OAAO,YACP,YACA,YACA,kBACA,eACC;;;;;;;;;iBA6Ea,kBACd,OAAO,YACP,YACA,YACA,iBACA,aAAa,qBACb,cAEA;;AAAA,mBACC;;iBA6Ba,gBAAgB,OAAO,YAAY;;;;;iBASnC,qBACd,OAAO,YACP,YACA,YACA,kBACC;;;;;;;;iBA0Ea,kBAAkB,OAAO,YAAY,MAAM,MAAM,kBAAkB;;iBASnE,cAAc,OAAO,YAAY,gBAAgB,YAAY"}
|
package/dist/hit-test.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import Matrix from "./matrix.js";
|
|
2
2
|
import { getAxisAlignedBoundsAt, getNodeLocalMatrix, getWorldMatrix } from "./coordinate.js";
|
|
3
|
-
import { geometryBlobPolylines } from "./geometry.js";
|
|
4
3
|
import { hitsConnectorLine } from "./connectors/hit.js";
|
|
4
|
+
import { containsPoint } from "./hit-test/geometry.js";
|
|
5
|
+
import { clippingMasks, isMaskedOut, isPointMaskedOut } from "./hit-test/masks.js";
|
|
6
|
+
import { showsPaint } from "./hit-test/paint.js";
|
|
5
7
|
import { drawnChildIds } from "./layout/draw-order.js";
|
|
8
|
+
import { hitTestDropTarget } from "./hit-test/drop.js";
|
|
6
9
|
//#region src/hit-test.ts
|
|
7
10
|
const CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
8
11
|
"CANVAS",
|
|
@@ -15,12 +18,12 @@ const CONTAINER_TYPES = /* @__PURE__ */ new Set([
|
|
|
15
18
|
]);
|
|
16
19
|
const OPAQUE_CONTAINER_TYPES = /* @__PURE__ */ new Set(["COMPONENT", "INSTANCE"]);
|
|
17
20
|
/**
|
|
18
|
-
*
|
|
19
|
-
* a
|
|
21
|
+
* Whether a container's empty area takes the click. Figma counts it only where a paint shows,
|
|
22
|
+
* except a main component's, which always counts, and an instance's when the click is a plain one.
|
|
20
23
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return
|
|
24
|
+
function takesEmptyArea(graph, node, instanceBodies) {
|
|
25
|
+
if (node.type === "COMPONENT" || showsPaint(node) || ownsItsEmptyArea(graph, node)) return true;
|
|
26
|
+
return instanceBodies && node.type === "INSTANCE";
|
|
24
27
|
}
|
|
25
28
|
function isTopLevel(graph, node) {
|
|
26
29
|
const parent = node.parentId ? graph.nodes.get(node.parentId) : void 0;
|
|
@@ -35,109 +38,26 @@ function isTopLevel(graph, node) {
|
|
|
35
38
|
function ownsItsEmptyArea(graph, node) {
|
|
36
39
|
return node.type === "FRAME" && node.layoutMode !== "NONE" && isTopLevel(graph, node);
|
|
37
40
|
}
|
|
38
|
-
function hasTransformedAncestor(node, graph, cache) {
|
|
39
|
-
const cached = cache.get(node.id);
|
|
40
|
-
if (cached !== void 0) return cached;
|
|
41
|
-
const parent = node.parentId ? graph.getNode(node.parentId) : void 0;
|
|
42
|
-
const transformed = node.rotation !== 0 || node.flipX || node.flipY || (parent ? hasTransformedAncestor(parent, graph, cache) : false);
|
|
43
|
-
cache.set(node.id, transformed);
|
|
44
|
-
return transformed;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Where the point lies in the node's own coordinates: its offset from the position when nothing
|
|
48
|
-
* above it is turned, else through the inverse world matrix. Null when that cannot be inverted.
|
|
49
|
-
*/
|
|
50
|
-
function localPoint(px, py, node, graph, transformCache) {
|
|
51
|
-
if (!hasTransformedAncestor(node, graph, transformCache)) {
|
|
52
|
-
const absolute = graph.getAbsolutePosition(node.id);
|
|
53
|
-
return {
|
|
54
|
-
x: px - absolute.x,
|
|
55
|
-
y: py - absolute.y
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
const inv = Matrix.invert(getWorldMatrix(node, graph));
|
|
59
|
-
if (!inv) return null;
|
|
60
|
-
const [x, y] = Matrix.mapPoints(inv, [px, py]);
|
|
61
|
-
return {
|
|
62
|
-
x,
|
|
63
|
-
y
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
/** Whether the point lies in the node's box, grown by `pad` canvas units on every side. */
|
|
67
|
-
function containsPoint(px, py, node, graph, transformCache, pad = 0) {
|
|
68
|
-
const local = localPoint(px, py, node, graph, transformCache);
|
|
69
|
-
if (!local) return false;
|
|
70
|
-
const padX = node.width > 0 ? pad : Math.max(pad, DEGENERATE_AXIS_SLOP);
|
|
71
|
-
const padY = node.height > 0 ? pad : Math.max(pad, DEGENERATE_AXIS_SLOP);
|
|
72
|
-
return local.x >= -padX && local.x <= node.width + padX && local.y >= -padY && local.y <= node.height + padY;
|
|
73
|
-
}
|
|
74
|
-
/** Whether a rounded rectangle of `width` × `height` holds the point. */
|
|
75
|
-
function roundedRectContains(point, width, height, radius) {
|
|
76
|
-
if (point.x < 0 || point.y < 0 || point.x > width || point.y > height) return false;
|
|
77
|
-
const r = Math.max(0, Math.min(radius, width / 2, height / 2));
|
|
78
|
-
const cx = Math.min(Math.max(point.x, r), width - r);
|
|
79
|
-
const cy = Math.min(Math.max(point.y, r), height - r);
|
|
80
|
-
return Math.hypot(point.x - cx, point.y - cy) <= r;
|
|
81
|
-
}
|
|
82
|
-
/** Whether the point is inside a closed polyline, by the even-odd rule. */
|
|
83
|
-
function insidePolyline(polyline, x, y) {
|
|
84
|
-
let inside = false;
|
|
85
|
-
for (let i = 0, j = polyline.length - 1; i < polyline.length; j = i++) {
|
|
86
|
-
const a = polyline[i];
|
|
87
|
-
const b = polyline[j];
|
|
88
|
-
if (a.y > y === b.y > y) continue;
|
|
89
|
-
if (x < (b.x - a.x) * (y - a.y) / (b.y - a.y) + a.x) inside = !inside;
|
|
90
|
-
}
|
|
91
|
-
return inside;
|
|
92
|
-
}
|
|
93
41
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
42
|
+
* What a click inside a container reports. `opaque` is an instance or component whose body takes
|
|
43
|
+
* the click without looking through it; every other container looks through to its children first.
|
|
96
44
|
*/
|
|
97
|
-
function
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const ry = mask.height / 2;
|
|
104
|
-
const dx = (local.x - rx) / rx;
|
|
105
|
-
const dy = (local.y - ry) / ry;
|
|
106
|
-
return dx * dx + dy * dy <= 1;
|
|
45
|
+
function hitTestContainer(graph, px, py, child, childId, deep, transformCache, pad, locked = false, instanceBodies = false, opaque = false) {
|
|
46
|
+
if (opaque) {
|
|
47
|
+
if (!containsPoint(px, py, child, graph, transformCache)) return null;
|
|
48
|
+
if (hitTestChildren(graph, px, py, childId, deep, transformCache, pad, locked, instanceBodies)) return child;
|
|
49
|
+
if (takesEmptyArea(graph, child, instanceBodies)) return child;
|
|
50
|
+
return null;
|
|
107
51
|
}
|
|
108
|
-
if (
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* The masks that clip each child, by index, as the renderer groups them (`core/canvas/masks.ts`):
|
|
116
|
-
* a run of visible masks clips the layers after it up to the next visible mask. Empty when the
|
|
117
|
-
* container has no visible mask.
|
|
118
|
-
*/
|
|
119
|
-
function clippingMasks(graph, childIds) {
|
|
120
|
-
const children = childIds.map((childId) => graph.nodes.get(childId));
|
|
121
|
-
if (!children.some(isVisibleMask)) return [];
|
|
122
|
-
const result = [];
|
|
123
|
-
let run = [];
|
|
124
|
-
let previousWasMask = false;
|
|
125
|
-
for (const child of children) {
|
|
126
|
-
if (isVisibleMask(child)) {
|
|
127
|
-
run = previousWasMask ? [...run, child] : [child];
|
|
128
|
-
previousWasMask = true;
|
|
129
|
-
result.push([]);
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
previousWasMask = false;
|
|
133
|
-
result.push(run);
|
|
52
|
+
if (child.type === "GROUP") {
|
|
53
|
+
if (!containsPoint(px, py, child, graph, transformCache, pad)) return null;
|
|
54
|
+
const childHit = hitTestChildren(graph, px, py, childId, deep, transformCache, pad, locked, instanceBodies);
|
|
55
|
+
if (childHit) return standIn(child, childHit, deep);
|
|
56
|
+
return containsPoint(px, py, child, graph, transformCache) ? child : null;
|
|
134
57
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (!containsPoint(px, py, child, graph, transformCache)) return null;
|
|
139
|
-
if (hitTestChildren(graph, px, py, childId, deep, transformCache, pad, locked)) return child;
|
|
140
|
-
if (hasVisibleFillOrStroke(child)) return child;
|
|
58
|
+
const childHit = hitTestChildren(graph, px, py, childId, deep, transformCache, pad, locked, instanceBodies);
|
|
59
|
+
if (childHit) return standIn(child, childHit, true);
|
|
60
|
+
if (containsPoint(px, py, child, graph, transformCache) && takesEmptyArea(graph, child, instanceBodies)) return child;
|
|
141
61
|
return null;
|
|
142
62
|
}
|
|
143
63
|
/**
|
|
@@ -147,23 +67,6 @@ function hitTestOpaqueContainer(graph, px, py, child, childId, deep, transformCa
|
|
|
147
67
|
function standIn(container, hit, deep) {
|
|
148
68
|
return container.locked || !deep ? container : hit;
|
|
149
69
|
}
|
|
150
|
-
function hitTestTransparentContainer(graph, px, py, child, childId, deep, transformCache, pad, locked = false) {
|
|
151
|
-
if (child.type === "GROUP") {
|
|
152
|
-
if (!containsPoint(px, py, child, graph, transformCache, pad)) return null;
|
|
153
|
-
const childHit = hitTestChildren(graph, px, py, childId, deep, transformCache, pad, locked);
|
|
154
|
-
if (childHit) return standIn(child, childHit, deep);
|
|
155
|
-
return containsPoint(px, py, child, graph, transformCache) ? child : null;
|
|
156
|
-
}
|
|
157
|
-
const childHit = hitTestChildren(graph, px, py, childId, deep, transformCache, pad, locked);
|
|
158
|
-
if (childHit) return standIn(child, childHit, true);
|
|
159
|
-
if (containsPoint(px, py, child, graph, transformCache) && (hasVisibleFillOrStroke(child) || ownsItsEmptyArea(graph, child))) return child;
|
|
160
|
-
return null;
|
|
161
|
-
}
|
|
162
|
-
/** Whether the masks that clip a layer leave the point outside every one of their outlines. */
|
|
163
|
-
function isMaskedOut(px, py, masks, graph, transformCache) {
|
|
164
|
-
if (!masks) return false;
|
|
165
|
-
return masks.length > 0 && !masks.some((mask) => maskContainsPoint(px, py, mask, graph, transformCache));
|
|
166
|
-
}
|
|
167
70
|
/**
|
|
168
71
|
* The topmost layer under the point among a container's children. `pad`, in canvas units, grows
|
|
169
72
|
* each leaf layer's box, as Figma takes a click a few screen pixels outside a shape.
|
|
@@ -177,7 +80,7 @@ function takesClick(graph, px, py, child, mask, locked, transformCache) {
|
|
|
177
80
|
if (!child || child.internalOnly || !child.visible || child.locked && !locked) return false;
|
|
178
81
|
return !isMaskedOut(px, py, mask, graph, transformCache);
|
|
179
82
|
}
|
|
180
|
-
function hitTestChildren(graph, px, py, parentId, deep = false, transformCache = /* @__PURE__ */ new Map(), pad = 0, locked = false) {
|
|
83
|
+
function hitTestChildren(graph, px, py, parentId, deep = false, transformCache = /* @__PURE__ */ new Map(), pad = 0, locked = false, instanceBodies = false) {
|
|
181
84
|
const parent = graph.nodes.get(parentId);
|
|
182
85
|
if (!parent) return null;
|
|
183
86
|
if (parent.clipsContent) {
|
|
@@ -191,11 +94,11 @@ function hitTestChildren(graph, px, py, parentId, deep = false, transformCache =
|
|
|
191
94
|
if (!takesClick(graph, px, py, child, masks[i], locked, transformCache)) continue;
|
|
192
95
|
if (CONTAINER_TYPES.has(child.type)) {
|
|
193
96
|
if (OPAQUE_CONTAINER_TYPES.has(child.type) && !deep) {
|
|
194
|
-
const hit =
|
|
97
|
+
const hit = hitTestContainer(graph, px, py, child, childId, deep, transformCache, pad, locked, instanceBodies, true);
|
|
195
98
|
if (hit) return hit;
|
|
196
99
|
continue;
|
|
197
100
|
}
|
|
198
|
-
const hit =
|
|
101
|
+
const hit = hitTestContainer(graph, px, py, child, childId, deep, transformCache, pad, locked, instanceBodies);
|
|
199
102
|
if (hit) return hit;
|
|
200
103
|
continue;
|
|
201
104
|
}
|
|
@@ -208,7 +111,7 @@ function hitTestChildren(graph, px, py, parentId, deep = false, transformCache =
|
|
|
208
111
|
return null;
|
|
209
112
|
}
|
|
210
113
|
function hitTest(graph, px, py, scopeId) {
|
|
211
|
-
return hitTestChildren(graph, px, py, scopeId ?? graph.rootId, false);
|
|
114
|
+
return hitTestChildren(graph, px, py, scopeId ?? graph.rootId, false, /* @__PURE__ */ new Map(), 0, false, true);
|
|
212
115
|
}
|
|
213
116
|
function hitTestDeep(graph, px, py, scopeId, pad = 0) {
|
|
214
117
|
return hitTestChildren(graph, px, py, scopeId ?? graph.rootId, true, /* @__PURE__ */ new Map(), pad);
|
|
@@ -266,7 +169,7 @@ function openedBySelection(graph, selectedIds, scopeId) {
|
|
|
266
169
|
* frame or a section is not.
|
|
267
170
|
*/
|
|
268
171
|
function hitTestSelectable(graph, px, py, scopeId, selectedIds, pad = 0, locked = false) {
|
|
269
|
-
const deepest = hitTestChildren(graph, px, py, scopeId, true, /* @__PURE__ */ new Map(), pad, locked);
|
|
172
|
+
const deepest = hitTestChildren(graph, px, py, scopeId, true, /* @__PURE__ */ new Map(), pad, locked, true);
|
|
270
173
|
if (!deepest) {
|
|
271
174
|
const scope = graph.nodes.get(scopeId);
|
|
272
175
|
return scope ? frameChildAt(graph, scope, px, py, locked) : null;
|
|
@@ -298,7 +201,7 @@ function isOpenContainer(graph, nodeId) {
|
|
|
298
201
|
* here selects that container's layers, as in Figma.
|
|
299
202
|
*/
|
|
300
203
|
function hitTestOpenContainer(graph, px, py, scopeId) {
|
|
301
|
-
const deepest = hitTestChildren(graph, px, py, scopeId, true);
|
|
204
|
+
const deepest = hitTestChildren(graph, px, py, scopeId, true, /* @__PURE__ */ new Map(), 0, false, false);
|
|
302
205
|
for (let node = deepest ?? void 0; node && node.id !== scopeId;) {
|
|
303
206
|
if (!opensByItself(graph, node) || ownsItsEmptyArea(graph, node)) return null;
|
|
304
207
|
node = node.parentId ? graph.nodes.get(node.parentId) : void 0;
|
|
@@ -326,7 +229,7 @@ function rectOverlap(a, b) {
|
|
|
326
229
|
*/
|
|
327
230
|
function selectsByOwnArea(graph, node) {
|
|
328
231
|
if (node.type === "GROUP" || ownsItsEmptyArea(graph, node)) return true;
|
|
329
|
-
return
|
|
232
|
+
return showsPaint(node) && !opensByItself(graph, node);
|
|
330
233
|
}
|
|
331
234
|
/**
|
|
332
235
|
* Collects the deepest layers among `parent`'s children that touch `rect`. Each child's world
|
|
@@ -368,55 +271,7 @@ function isPointInNode(graph, nodeId, px, py) {
|
|
|
368
271
|
const node = graph.nodes.get(nodeId);
|
|
369
272
|
return node !== void 0 && containsPoint(px, py, node, graph, /* @__PURE__ */ new Map());
|
|
370
273
|
}
|
|
371
|
-
const LAYER_TARGETS = /* @__PURE__ */ new Set([
|
|
372
|
-
"FRAME",
|
|
373
|
-
"SECTION",
|
|
374
|
-
"COMPONENT",
|
|
375
|
-
"INSTANCE"
|
|
376
|
-
]);
|
|
377
|
-
const COMPONENT_TARGETS = /* @__PURE__ */ new Set([
|
|
378
|
-
"FRAME",
|
|
379
|
-
"SECTION",
|
|
380
|
-
"INSTANCE"
|
|
381
|
-
]);
|
|
382
|
-
function dropRules(options) {
|
|
383
|
-
const { componentSetIds } = options;
|
|
384
|
-
if (!componentSetIds) return {
|
|
385
|
-
takes: (node) => LAYER_TARGETS.has(node.type),
|
|
386
|
-
passThrough: /* @__PURE__ */ new Set(["GROUP", "COMPONENT_SET"])
|
|
387
|
-
};
|
|
388
|
-
return {
|
|
389
|
-
takes: (node) => COMPONENT_TARGETS.has(node.type) || node.type === "COMPONENT_SET" && componentSetIds.has(node.id),
|
|
390
|
-
passThrough: /* @__PURE__ */ new Set(["GROUP"])
|
|
391
|
-
};
|
|
392
|
-
}
|
|
393
|
-
function dropTargetIn(graph, px, py, parent, excludeIds, rules, transformCache) {
|
|
394
|
-
if (parent.type !== "CANVAS" && parent.clipsContent && !containsPoint(px, py, parent, graph, transformCache)) return null;
|
|
395
|
-
for (let i = parent.childIds.length - 1; i >= 0; i--) {
|
|
396
|
-
const childId = parent.childIds[i];
|
|
397
|
-
if (excludeIds.has(childId)) continue;
|
|
398
|
-
const child = graph.nodes.get(childId);
|
|
399
|
-
if (!child || child.internalOnly || !child.visible || child.locked) continue;
|
|
400
|
-
const target = rules.takes(child);
|
|
401
|
-
if (!target && !rules.passThrough.has(child.type)) continue;
|
|
402
|
-
const deeper = dropTargetIn(graph, px, py, child, excludeIds, rules, transformCache);
|
|
403
|
-
if (deeper) return deeper;
|
|
404
|
-
if (target && containsPoint(px, py, child, graph, transformCache)) return child;
|
|
405
|
-
}
|
|
406
|
-
return null;
|
|
407
|
-
}
|
|
408
|
-
/**
|
|
409
|
-
* The topmost unlocked frame, section, component, or instance under the point, in its rotated
|
|
410
|
-
* shape and inside its clipping ancestors. Groups and component sets are looked through but never
|
|
411
|
-
* returned, except that a set takes dropped components; locked layers and their contents are
|
|
412
|
-
* skipped.
|
|
413
|
-
*/
|
|
414
|
-
function hitTestDropTarget(graph, px, py, excludeIds, scopeId, options = {}) {
|
|
415
|
-
const scope = graph.nodes.get(scopeId ?? graph.rootId);
|
|
416
|
-
if (!scope) return null;
|
|
417
|
-
return dropTargetIn(graph, px, py, scope, excludeIds, dropRules(options), /* @__PURE__ */ new Map());
|
|
418
|
-
}
|
|
419
274
|
//#endregion
|
|
420
|
-
export { hitTest, hitTestDeep, hitTestDeepInRect, hitTestDropTarget, hitTestOpenContainer, hitTestSelectable, isOpenContainer, isPointInNode };
|
|
275
|
+
export { clippingMasks, hitTest, hitTestDeep, hitTestDeepInRect, hitTestDropTarget, hitTestOpenContainer, hitTestSelectable, isOpenContainer, isPointInNode, isPointMaskedOut, showsPaint };
|
|
421
276
|
|
|
422
277
|
//# sourceMappingURL=hit-test.js.map
|