@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,72 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
//#region src/design-memory/schema.ts
|
|
3
|
+
/** How many values, decisions and examples one document's memory keeps. */
|
|
4
|
+
const DESIGN_MEMORY_LIMITS = {
|
|
5
|
+
colors: 128,
|
|
6
|
+
fonts: 16,
|
|
7
|
+
numbers: 32,
|
|
8
|
+
decisions: 40,
|
|
9
|
+
decisionLength: 400,
|
|
10
|
+
examples: 12,
|
|
11
|
+
fontLength: 100
|
|
12
|
+
};
|
|
13
|
+
/** The kinds of value a memory allows, each with its own list and enforcement. */
|
|
14
|
+
const DESIGN_MEMORY_GROUPS = [
|
|
15
|
+
"colors",
|
|
16
|
+
"fonts",
|
|
17
|
+
"fontSizes",
|
|
18
|
+
"spacing",
|
|
19
|
+
"radius"
|
|
20
|
+
];
|
|
21
|
+
/**
|
|
22
|
+
* What happens to an agent's edit that uses a value the memory does not allow: it is undone and
|
|
23
|
+
* the agent told the allowed values, it goes through with a warning, or nothing is checked.
|
|
24
|
+
* People's own edits are never refused; lint lists them.
|
|
25
|
+
*/
|
|
26
|
+
const DESIGN_MEMORY_ENFORCEMENTS = [
|
|
27
|
+
"refuse",
|
|
28
|
+
"warn",
|
|
29
|
+
"off"
|
|
30
|
+
];
|
|
31
|
+
const DESIGN_DECISION_AUTHORS = ["person", "agent"];
|
|
32
|
+
const enforcementSchema = v.picklist(DESIGN_MEMORY_ENFORCEMENTS);
|
|
33
|
+
/** A color as a memory keeps it: `#RRGGBB`, since alpha is never compared. */
|
|
34
|
+
const hexColorSchema = v.pipe(v.string(), v.regex(/^#[0-9A-F]{6}$/));
|
|
35
|
+
const fontFamilySchema = v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(DESIGN_MEMORY_LIMITS.fontLength));
|
|
36
|
+
const fontSizeSchema = v.pipe(v.number(), v.finite(), v.gtValue(0));
|
|
37
|
+
const lengthSchema = v.pipe(v.number(), v.finite(), v.minValue(0));
|
|
38
|
+
/**
|
|
39
|
+
* One group: `fromSystem` allows what the document's variables and styles hold, and `values`
|
|
40
|
+
* adds values of the person's own.
|
|
41
|
+
*/
|
|
42
|
+
function valueGroup(value, max) {
|
|
43
|
+
return v.object({
|
|
44
|
+
fromSystem: v.boolean(),
|
|
45
|
+
values: v.pipe(v.array(value), v.maxLength(max)),
|
|
46
|
+
enforce: enforcementSchema
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const decisionSchema = v.object({
|
|
50
|
+
id: v.pipe(v.string(), v.nonEmpty()),
|
|
51
|
+
text: v.pipe(v.string(), v.trim(), v.nonEmpty(), v.maxLength(DESIGN_MEMORY_LIMITS.decisionLength)),
|
|
52
|
+
author: v.picklist(DESIGN_DECISION_AUTHORS)
|
|
53
|
+
});
|
|
54
|
+
const exampleSchema = v.object({ nodeId: v.pipe(v.string(), v.nonEmpty()) });
|
|
55
|
+
/**
|
|
56
|
+
* A document's design rules for agents: the values its designs may use, decisions written down
|
|
57
|
+
* about them, and frames pinned as examples to follow.
|
|
58
|
+
*/
|
|
59
|
+
const designMemorySchema = v.object({
|
|
60
|
+
version: v.literal(1),
|
|
61
|
+
colors: valueGroup(hexColorSchema, DESIGN_MEMORY_LIMITS.colors),
|
|
62
|
+
fonts: valueGroup(fontFamilySchema, DESIGN_MEMORY_LIMITS.fonts),
|
|
63
|
+
fontSizes: valueGroup(fontSizeSchema, DESIGN_MEMORY_LIMITS.numbers),
|
|
64
|
+
spacing: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),
|
|
65
|
+
radius: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),
|
|
66
|
+
decisions: v.pipe(v.array(decisionSchema), v.maxLength(DESIGN_MEMORY_LIMITS.decisions)),
|
|
67
|
+
examples: v.pipe(v.array(exampleSchema), v.maxLength(DESIGN_MEMORY_LIMITS.examples))
|
|
68
|
+
});
|
|
69
|
+
//#endregion
|
|
70
|
+
export { DESIGN_DECISION_AUTHORS, DESIGN_MEMORY_ENFORCEMENTS, DESIGN_MEMORY_GROUPS, DESIGN_MEMORY_LIMITS, designMemorySchema };
|
|
71
|
+
|
|
72
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.js","names":[],"sources":["../../src/design-memory/schema.ts"],"sourcesContent":["import * as v from 'valibot'\n\n/** How many values, decisions and examples one document's memory keeps. */\nexport const DESIGN_MEMORY_LIMITS = {\n colors: 128,\n fonts: 16,\n numbers: 32,\n decisions: 40,\n decisionLength: 400,\n examples: 12,\n fontLength: 100\n} as const\n\n/** The kinds of value a memory allows, each with its own list and enforcement. */\nexport const DESIGN_MEMORY_GROUPS = ['colors', 'fonts', 'fontSizes', 'spacing', 'radius'] as const\nexport type DesignMemoryGroup = (typeof DESIGN_MEMORY_GROUPS)[number]\n\n/**\n * What happens to an agent's edit that uses a value the memory does not allow: it is undone and\n * the agent told the allowed values, it goes through with a warning, or nothing is checked.\n * People's own edits are never refused; lint lists them.\n */\nexport const DESIGN_MEMORY_ENFORCEMENTS = ['refuse', 'warn', 'off'] as const\nexport type DesignMemoryEnforcement = (typeof DESIGN_MEMORY_ENFORCEMENTS)[number]\n\nexport const DESIGN_DECISION_AUTHORS = ['person', 'agent'] as const\nexport type DesignDecisionAuthor = (typeof DESIGN_DECISION_AUTHORS)[number]\n\nconst enforcementSchema = v.picklist(DESIGN_MEMORY_ENFORCEMENTS)\n\n/** A color as a memory keeps it: `#RRGGBB`, since alpha is never compared. */\nconst hexColorSchema = v.pipe(v.string(), v.regex(/^#[0-9A-F]{6}$/))\nconst fontFamilySchema = v.pipe(\n v.string(),\n v.trim(),\n v.nonEmpty(),\n v.maxLength(DESIGN_MEMORY_LIMITS.fontLength)\n)\nconst fontSizeSchema = v.pipe(v.number(), v.finite(), v.gtValue(0))\nconst lengthSchema = v.pipe(v.number(), v.finite(), v.minValue(0))\n\n/**\n * One group: `fromSystem` allows what the document's variables and styles hold, and `values`\n * adds values of the person's own.\n */\nfunction valueGroup<T>(value: v.GenericSchema<unknown, T>, max: number) {\n return v.object({\n fromSystem: v.boolean(),\n values: v.pipe(v.array(value), v.maxLength(max)),\n enforce: enforcementSchema\n })\n}\n\nconst decisionSchema = v.object({\n id: v.pipe(v.string(), v.nonEmpty()),\n text: v.pipe(\n v.string(),\n v.trim(),\n v.nonEmpty(),\n v.maxLength(DESIGN_MEMORY_LIMITS.decisionLength)\n ),\n author: v.picklist(DESIGN_DECISION_AUTHORS)\n})\n\nconst exampleSchema = v.object({ nodeId: v.pipe(v.string(), v.nonEmpty()) })\n\n/**\n * A document's design rules for agents: the values its designs may use, decisions written down\n * about them, and frames pinned as examples to follow.\n */\nexport const designMemorySchema = v.object({\n version: v.literal(1),\n colors: valueGroup(hexColorSchema, DESIGN_MEMORY_LIMITS.colors),\n fonts: valueGroup(fontFamilySchema, DESIGN_MEMORY_LIMITS.fonts),\n fontSizes: valueGroup(fontSizeSchema, DESIGN_MEMORY_LIMITS.numbers),\n spacing: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),\n radius: valueGroup(lengthSchema, DESIGN_MEMORY_LIMITS.numbers),\n decisions: v.pipe(v.array(decisionSchema), v.maxLength(DESIGN_MEMORY_LIMITS.decisions)),\n examples: v.pipe(v.array(exampleSchema), v.maxLength(DESIGN_MEMORY_LIMITS.examples))\n})\n\nexport type DesignMemory = v.InferOutput<typeof designMemorySchema>\nexport type DesignDecision = DesignMemory['decisions'][number]\nexport type DesignExample = DesignMemory['examples'][number]\n"],"mappings":";;;AAGA,MAAa,uBAAuB;CAClC,QAAQ;CACR,OAAO;CACP,SAAS;CACT,WAAW;CACX,gBAAgB;CAChB,UAAU;CACV,YAAY;AACd;;AAGA,MAAa,uBAAuB;CAAC;CAAU;CAAS;CAAa;CAAW;AAAQ;;;;;;AAQxF,MAAa,6BAA6B;CAAC;CAAU;CAAQ;AAAK;AAGlE,MAAa,0BAA0B,CAAC,UAAU,OAAO;AAGzD,MAAM,oBAAoB,EAAE,SAAS,0BAA0B;;AAG/D,MAAM,iBAAiB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACnE,MAAM,mBAAmB,EAAE,KACzB,EAAE,OAAO,GACT,EAAE,KAAK,GACP,EAAE,SAAS,GACX,EAAE,UAAU,qBAAqB,UAAU,CAC7C;AACA,MAAM,iBAAiB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC;AAClE,MAAM,eAAe,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,CAAC;;;;;AAMjE,SAAS,WAAc,OAAoC,KAAa;CACtE,OAAO,EAAE,OAAO;EACd,YAAY,EAAE,QAAQ;EACtB,QAAQ,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,EAAE,UAAU,GAAG,CAAC;EAC/C,SAAS;CACX,CAAC;AACH;AAEA,MAAM,iBAAiB,EAAE,OAAO;CAC9B,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC;CACnC,MAAM,EAAE,KACN,EAAE,OAAO,GACT,EAAE,KAAK,GACP,EAAE,SAAS,GACX,EAAE,UAAU,qBAAqB,cAAc,CACjD;CACA,QAAQ,EAAE,SAAS,uBAAuB;AAC5C,CAAC;AAED,MAAM,gBAAgB,EAAE,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,SAAS,CAAC,EAAE,CAAC;;;;;AAM3E,MAAa,qBAAqB,EAAE,OAAO;CACzC,SAAS,EAAE,QAAQ,CAAC;CACpB,QAAQ,WAAW,gBAAgB,qBAAqB,MAAM;CAC9D,OAAO,WAAW,kBAAkB,qBAAqB,KAAK;CAC9D,WAAW,WAAW,gBAAgB,qBAAqB,OAAO;CAClE,SAAS,WAAW,cAAc,qBAAqB,OAAO;CAC9D,QAAQ,WAAW,cAAc,qBAAqB,OAAO;CAC7D,WAAW,EAAE,KAAK,EAAE,MAAM,cAAc,GAAG,EAAE,UAAU,qBAAqB,SAAS,CAAC;CACtF,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,GAAG,EAAE,UAAU,qBAAqB,QAAQ,CAAC;AACrF,CAAC"}
|
package/dist/effects.d.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { Vector } from "./primitives/index.js";
|
|
2
|
-
import { Effect,
|
|
2
|
+
import { Effect, ShadowEffect } from "./types.js";
|
|
3
3
|
//#region src/effects.d.ts
|
|
4
4
|
/** A shadow or blur whose offset may still be missing or only partly present. */
|
|
5
5
|
type ShadowInput = Omit<ShadowEffect, 'offset'> & {
|
|
6
6
|
offset?: Partial<Vector> | null;
|
|
7
7
|
};
|
|
8
|
+
/** An effect as a caller may pass it, before its geometry is made finite. */
|
|
9
|
+
type EffectInput = Effect | ShadowInput;
|
|
8
10
|
/**
|
|
9
11
|
* Shadows and blurs keep a finite offset. A drop or inner shadow missing one uses `{x: 0, y: 4}`,
|
|
10
|
-
* the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader
|
|
11
|
-
* are left alone. An array that is already valid is
|
|
12
|
+
* the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader, noise,
|
|
13
|
+
* and texture effects carry no offset and are left alone. An array that is already valid is
|
|
14
|
+
* returned as itself.
|
|
12
15
|
*/
|
|
13
|
-
declare function normalizeEffects(effects:
|
|
16
|
+
declare function normalizeEffects(effects: EffectInput[]): Effect[];
|
|
14
17
|
//#endregion
|
|
15
18
|
export { normalizeEffects };
|
|
16
19
|
//# sourceMappingURL=effects.d.ts.map
|
package/dist/effects.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.d.ts","names":[],"sources":["../src/effects.ts"],"mappings":";;;;KAOK,cAAc,KAAK;EACtB,SAAS,QAAQ;;;;;;;
|
|
1
|
+
{"version":3,"file":"effects.d.ts","names":[],"sources":["../src/effects.ts"],"mappings":";;;;KAOK,cAAc,KAAK;EACtB,SAAS,QAAQ;;;KAId,cAAc,SAAS;;;;;;;iBA0DZ,iBAAiB,SAAS,gBAAgB"}
|
package/dist/effects.js
CHANGED
|
@@ -35,6 +35,10 @@ function isStoredShadow(effect) {
|
|
|
35
35
|
const offset = effect.offset;
|
|
36
36
|
return !!offset && typeof offset.x === "number" && Number.isFinite(offset.x) && typeof offset.y === "number" && Number.isFinite(offset.y);
|
|
37
37
|
}
|
|
38
|
+
/** An effect that carries geometry of its own, which has to be finite to render. */
|
|
39
|
+
function isOffsetEffect(effect) {
|
|
40
|
+
return effect.type !== "SHADER" && effect.type !== "NOISE" && effect.type !== "TEXTURE";
|
|
41
|
+
}
|
|
38
42
|
function withFiniteOffset(effect) {
|
|
39
43
|
const offset = finiteOffset(effect);
|
|
40
44
|
if (!offset) {
|
|
@@ -50,17 +54,18 @@ function withFiniteOffset(effect) {
|
|
|
50
54
|
};
|
|
51
55
|
}
|
|
52
56
|
function isStoredEffect(effect) {
|
|
53
|
-
return effect
|
|
57
|
+
return !isOffsetEffect(effect) || isStoredShadow(effect);
|
|
54
58
|
}
|
|
55
59
|
/**
|
|
56
60
|
* Shadows and blurs keep a finite offset. A drop or inner shadow missing one uses `{x: 0, y: 4}`,
|
|
57
|
-
* the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader
|
|
58
|
-
* are left alone. An array that is already valid is
|
|
61
|
+
* the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader, noise,
|
|
62
|
+
* and texture effects carry no offset and are left alone. An array that is already valid is
|
|
63
|
+
* returned as itself.
|
|
59
64
|
*/
|
|
60
65
|
function normalizeEffects(effects) {
|
|
61
66
|
let next = null;
|
|
62
67
|
for (const [index, effect] of effects.entries()) {
|
|
63
|
-
const normalized = effect
|
|
68
|
+
const normalized = isOffsetEffect(effect) ? withFiniteOffset(effect) : effect;
|
|
64
69
|
if (normalized === effect) {
|
|
65
70
|
if (next && isStoredEffect(effect)) next.push(effect);
|
|
66
71
|
continue;
|
package/dist/effects.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.js","names":[],"sources":["../src/effects.ts"],"sourcesContent":["import type { Vector } from './primitives'\nimport type { Effect,
|
|
1
|
+
{"version":3,"file":"effects.js","names":[],"sources":["../src/effects.ts"],"sourcesContent":["import type { Vector } from './primitives'\nimport type { Effect, ShadowEffect } from './types'\n\nconst SHADOW_OFFSET: Vector = { x: 0, y: 4 }\nconst BLUR_OFFSET: Vector = { x: 0, y: 0 }\n\n/** A shadow or blur whose offset may still be missing or only partly present. */\ntype ShadowInput = Omit<ShadowEffect, 'offset'> & {\n offset?: Partial<Vector> | null\n}\n\n/** An effect as a caller may pass it, before its geometry is made finite. */\ntype EffectInput = Effect | ShadowInput\n\nfunction fallbackOffset(type: ShadowEffect['type']): Vector {\n return type === 'DROP_SHADOW' || type === 'INNER_SHADOW' ? SHADOW_OFFSET : BLUR_OFFSET\n}\n\nfunction component(offset: object, key: 'x' | 'y', fallback: number): number {\n if (!(key in offset)) return fallback\n const value: unknown = Reflect.get(offset, key)\n return typeof value === 'number' && Number.isFinite(value) ? value : fallback\n}\n\n/** A new offset when `effect.offset` is missing or not finite; null when it can stay. */\nfunction finiteOffset(effect: ShadowInput): Vector | null {\n const fallback = fallbackOffset(effect.type)\n const offset: unknown = effect.offset\n if (offset === null || typeof offset !== 'object') return { x: fallback.x, y: fallback.y }\n const x = component(offset, 'x', fallback.x)\n const y = component(offset, 'y', fallback.y)\n if (Reflect.get(offset, 'x') === x && Reflect.get(offset, 'y') === y) return null\n return { x, y }\n}\n\nfunction isStoredShadow(effect: ShadowInput): effect is ShadowEffect {\n const offset = effect.offset\n return (\n !!offset &&\n typeof offset.x === 'number' &&\n Number.isFinite(offset.x) &&\n typeof offset.y === 'number' &&\n Number.isFinite(offset.y)\n )\n}\n\n/** An effect that carries geometry of its own, which has to be finite to render. */\nfunction isOffsetEffect(effect: EffectInput): effect is ShadowInput {\n return effect.type !== 'SHADER' && effect.type !== 'NOISE' && effect.type !== 'TEXTURE'\n}\n\nfunction withFiniteOffset(effect: ShadowInput): Effect {\n const offset = finiteOffset(effect)\n if (!offset) {\n if (isStoredShadow(effect)) return effect\n return { ...effect, offset: fallbackOffset(effect.type) }\n }\n return { ...effect, offset }\n}\n\nfunction isStoredEffect(effect: EffectInput): effect is Effect {\n return !isOffsetEffect(effect) || isStoredShadow(effect)\n}\n\n/**\n * Shadows and blurs keep a finite offset. A drop or inner shadow missing one uses `{x: 0, y: 4}`,\n * the same default as `dropShadow()` and `set_effects`; a blur uses `{x: 0, y: 0}`. Shader, noise,\n * and texture effects carry no offset and are left alone. An array that is already valid is\n * returned as itself.\n */\nexport function normalizeEffects(effects: EffectInput[]): Effect[] {\n let next: Effect[] | null = null\n for (const [index, effect] of effects.entries()) {\n const normalized = isOffsetEffect(effect) ? withFiniteOffset(effect) : effect\n if (normalized === effect) {\n if (next && isStoredEffect(effect)) next.push(effect)\n continue\n }\n next ??= effects.slice(0, index).filter(isStoredEffect)\n next.push(normalized)\n }\n if (next) return next\n if (effects.every(isStoredEffect)) return effects\n return effects.filter(isStoredEffect)\n}\n"],"mappings":";AAGA,MAAM,gBAAwB;CAAE,GAAG;CAAG,GAAG;AAAE;AAC3C,MAAM,cAAsB;CAAE,GAAG;CAAG,GAAG;AAAE;AAUzC,SAAS,eAAe,MAAoC;CAC1D,OAAO,SAAS,iBAAiB,SAAS,iBAAiB,gBAAgB;AAC7E;AAEA,SAAS,UAAU,QAAgB,KAAgB,UAA0B;CAC3E,IAAI,EAAE,OAAO,SAAS,OAAO;CAC7B,MAAM,QAAiB,QAAQ,IAAI,QAAQ,GAAG;CAC9C,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,IAAI,QAAQ;AACvE;;AAGA,SAAS,aAAa,QAAoC;CACxD,MAAM,WAAW,eAAe,OAAO,IAAI;CAC3C,MAAM,SAAkB,OAAO;CAC/B,IAAI,WAAW,QAAQ,OAAO,WAAW,UAAU,OAAO;EAAE,GAAG,SAAS;EAAG,GAAG,SAAS;CAAE;CACzF,MAAM,IAAI,UAAU,QAAQ,KAAK,SAAS,CAAC;CAC3C,MAAM,IAAI,UAAU,QAAQ,KAAK,SAAS,CAAC;CAC3C,IAAI,QAAQ,IAAI,QAAQ,GAAG,MAAM,KAAK,QAAQ,IAAI,QAAQ,GAAG,MAAM,GAAG,OAAO;CAC7E,OAAO;EAAE;EAAG;CAAE;AAChB;AAEA,SAAS,eAAe,QAA6C;CACnE,MAAM,SAAS,OAAO;CACtB,OACE,CAAC,CAAC,UACF,OAAO,OAAO,MAAM,YACpB,OAAO,SAAS,OAAO,CAAC,KACxB,OAAO,OAAO,MAAM,YACpB,OAAO,SAAS,OAAO,CAAC;AAE5B;;AAGA,SAAS,eAAe,QAA4C;CAClE,OAAO,OAAO,SAAS,YAAY,OAAO,SAAS,WAAW,OAAO,SAAS;AAChF;AAEA,SAAS,iBAAiB,QAA6B;CACrD,MAAM,SAAS,aAAa,MAAM;CAClC,IAAI,CAAC,QAAQ;EACX,IAAI,eAAe,MAAM,GAAG,OAAO;EACnC,OAAO;GAAE,GAAG;GAAQ,QAAQ,eAAe,OAAO,IAAI;EAAE;CAC1D;CACA,OAAO;EAAE,GAAG;EAAQ;CAAO;AAC7B;AAEA,SAAS,eAAe,QAAuC;CAC7D,OAAO,CAAC,eAAe,MAAM,KAAK,eAAe,MAAM;AACzD;;;;;;;AAQA,SAAgB,iBAAiB,SAAkC;CACjE,IAAI,OAAwB;CAC5B,KAAK,MAAM,CAAC,OAAO,WAAW,QAAQ,QAAQ,GAAG;EAC/C,MAAM,aAAa,eAAe,MAAM,IAAI,iBAAiB,MAAM,IAAI;EACvE,IAAI,eAAe,QAAQ;GACzB,IAAI,QAAQ,eAAe,MAAM,GAAG,KAAK,KAAK,MAAM;GACpD;EACF;EACA,SAAS,QAAQ,MAAM,GAAG,KAAK,CAAC,CAAC,OAAO,cAAc;EACtD,KAAK,KAAK,UAAU;CACtB;CACA,IAAI,MAAM,OAAO;CACjB,IAAI,QAAQ,MAAM,cAAc,GAAG,OAAO;CAC1C,OAAO,QAAQ,OAAO,cAAc;AACtC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { isEmptyObject, isPlainObject } from "es-toolkit";
|
|
2
|
+
//#region src/empty-values.ts
|
|
3
|
+
/**
|
|
4
|
+
* The empty list and record every layer holds until a field gets a value of its own. All layers
|
|
5
|
+
* share them, so they are frozen: a field is replaced, never written into, and a write into one
|
|
6
|
+
* throws instead of reaching every layer of every document.
|
|
7
|
+
*/
|
|
8
|
+
const EMPTY_LIST = Object.freeze([]);
|
|
9
|
+
const EMPTY_RECORD = Object.freeze({});
|
|
10
|
+
/** The child list is the graph's to grow in place, so every layer keeps its own. */
|
|
11
|
+
const OWN_LIST_FIELDS = /* @__PURE__ */ new Set(["childIds"]);
|
|
12
|
+
/** Fields keyed by name, such as bindings and property values, that start empty. */
|
|
13
|
+
const RECORD_FIELDS = /* @__PURE__ */ new Set([
|
|
14
|
+
"componentPropertyAssignments",
|
|
15
|
+
"componentPropertyValues",
|
|
16
|
+
"boundVariables",
|
|
17
|
+
"variableBindingScales",
|
|
18
|
+
"variableAssignmentScales",
|
|
19
|
+
"variableModes"
|
|
20
|
+
]);
|
|
21
|
+
const SOURCE_LIST_FIELDS = ["editedFields"];
|
|
22
|
+
const FIG_SOURCE_LIST_FIELDS = [
|
|
23
|
+
"symbolOverrides",
|
|
24
|
+
"componentPropAssignments",
|
|
25
|
+
"derivedSymbolData"
|
|
26
|
+
];
|
|
27
|
+
function sharedEmptyList(value) {
|
|
28
|
+
return Array.isArray(value) && value.length === 0 ? EMPTY_LIST : value;
|
|
29
|
+
}
|
|
30
|
+
function sharedEmptyRecord(value) {
|
|
31
|
+
return isPlainObject(value) && isEmptyObject(value) ? EMPTY_RECORD : value;
|
|
32
|
+
}
|
|
33
|
+
function sharedEmptyValue(field, value) {
|
|
34
|
+
if (Array.isArray(value)) return OWN_LIST_FIELDS.has(field) ? value : sharedEmptyList(value);
|
|
35
|
+
return RECORD_FIELDS.has(field) ? sharedEmptyRecord(value) : value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `record` with the empty lists among `lists` and the empty record at `recordField` swapped for
|
|
39
|
+
* the shared ones: a copy when anything changes, so the caller's object is never written into.
|
|
40
|
+
* A field the record lacks stays absent.
|
|
41
|
+
*/
|
|
42
|
+
function withSharedEmpties(record, lists, recordField) {
|
|
43
|
+
const fields = lists.map((field) => [field, sharedEmptyList]);
|
|
44
|
+
if (recordField !== void 0) fields.push([recordField, sharedEmptyRecord]);
|
|
45
|
+
let copy = null;
|
|
46
|
+
for (const [field, shared] of fields) {
|
|
47
|
+
if (!Object.hasOwn(record, field)) continue;
|
|
48
|
+
const value = Reflect.get(record, field);
|
|
49
|
+
const next = shared(value);
|
|
50
|
+
if (next === value) continue;
|
|
51
|
+
copy ??= { ...record };
|
|
52
|
+
Reflect.set(copy, field, next);
|
|
53
|
+
}
|
|
54
|
+
return copy ?? record;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Source metadata with its empty lists and raw fields swapped for the shared ones. The metadata
|
|
58
|
+
* object and its `fig` part stay the layer's own, since readers and edits write their scalars in
|
|
59
|
+
* place; metadata missing parts, as libraries and plugins may give, is kept as given.
|
|
60
|
+
*/
|
|
61
|
+
function withSharedEmptySource(source) {
|
|
62
|
+
const outer = withSharedEmpties(source, SOURCE_LIST_FIELDS);
|
|
63
|
+
const fig = Reflect.get(source, "fig");
|
|
64
|
+
if (!isPlainObject(fig)) return outer;
|
|
65
|
+
const sharedFig = withSharedEmpties(fig, FIG_SOURCE_LIST_FIELDS, "rawNodeFields");
|
|
66
|
+
if (sharedFig === fig) return outer;
|
|
67
|
+
return {
|
|
68
|
+
...outer,
|
|
69
|
+
fig: {
|
|
70
|
+
...source.fig,
|
|
71
|
+
...sharedFig
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Swap the `fields` of `node` that hold an empty list or record, its source metadata's included,
|
|
77
|
+
* for the shared ones. Writing known keys keeps the shape every layer shares.
|
|
78
|
+
*/
|
|
79
|
+
function shareEmptyNodeValues(node, fields) {
|
|
80
|
+
for (const field of fields) {
|
|
81
|
+
const value = Reflect.get(node, field);
|
|
82
|
+
if (field === "source") {
|
|
83
|
+
if (isPlainObject(value)) node.source = withSharedEmptySource(node.source);
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
const shared = sharedEmptyValue(field, value);
|
|
87
|
+
if (shared !== value) Reflect.set(node, field, shared);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { EMPTY_LIST, EMPTY_RECORD, shareEmptyNodeValues };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=empty-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty-values.js","names":[],"sources":["../src/empty-values.ts"],"sourcesContent":["import { isEmptyObject, isPlainObject } from 'es-toolkit'\n\nimport type { SceneNode, SourceMetadata } from './types'\n\n/**\n * The empty list and record every layer holds until a field gets a value of its own. All layers\n * share them, so they are frozen: a field is replaced, never written into, and a write into one\n * throws instead of reaching every layer of every document.\n */\nexport const EMPTY_LIST: never[] = Object.freeze<never[]>([]) as never[]\nexport const EMPTY_RECORD: Record<string, never> = Object.freeze({})\n\n/** The child list is the graph's to grow in place, so every layer keeps its own. */\nconst OWN_LIST_FIELDS: ReadonlySet<string> = new Set<keyof SceneNode>(['childIds'])\n\n/** Fields keyed by name, such as bindings and property values, that start empty. */\nconst RECORD_FIELDS: ReadonlySet<string> = new Set<keyof SceneNode>([\n 'componentPropertyAssignments',\n 'componentPropertyValues',\n 'boundVariables',\n 'variableBindingScales',\n 'variableAssignmentScales',\n 'variableModes'\n])\n\nconst SOURCE_LIST_FIELDS = ['editedFields'] as const\nconst FIG_SOURCE_LIST_FIELDS = [\n 'symbolOverrides',\n 'componentPropAssignments',\n 'derivedSymbolData'\n] as const\n\nfunction sharedEmptyList(value: unknown): unknown {\n return Array.isArray(value) && value.length === 0 ? EMPTY_LIST : value\n}\n\nfunction sharedEmptyRecord(value: unknown): unknown {\n return isPlainObject(value) && isEmptyObject(value) ? EMPTY_RECORD : value\n}\n\nfunction sharedEmptyValue(field: string, value: unknown): unknown {\n if (Array.isArray(value)) return OWN_LIST_FIELDS.has(field) ? value : sharedEmptyList(value)\n return RECORD_FIELDS.has(field) ? sharedEmptyRecord(value) : value\n}\n\n/**\n * `record` with the empty lists among `lists` and the empty record at `recordField` swapped for\n * the shared ones: a copy when anything changes, so the caller's object is never written into.\n * A field the record lacks stays absent.\n */\nfunction withSharedEmpties<T extends object>(\n record: T,\n lists: readonly string[],\n recordField?: string\n): T {\n const fields: [string, (value: unknown) => unknown][] = lists.map((field) => [\n field,\n sharedEmptyList\n ])\n if (recordField !== undefined) fields.push([recordField, sharedEmptyRecord])\n let copy: T | null = null\n for (const [field, shared] of fields) {\n if (!Object.hasOwn(record, field)) continue\n const value: unknown = Reflect.get(record, field)\n const next = shared(value)\n if (next === value) continue\n copy ??= { ...record }\n Reflect.set(copy, field, next)\n }\n return copy ?? record\n}\n\n/**\n * Source metadata with its empty lists and raw fields swapped for the shared ones. The metadata\n * object and its `fig` part stay the layer's own, since readers and edits write their scalars in\n * place; metadata missing parts, as libraries and plugins may give, is kept as given.\n */\nfunction withSharedEmptySource(source: SourceMetadata): SourceMetadata {\n const outer = withSharedEmpties(source, SOURCE_LIST_FIELDS)\n const fig: unknown = Reflect.get(source, 'fig')\n if (!isPlainObject(fig)) return outer\n const sharedFig = withSharedEmpties(fig, FIG_SOURCE_LIST_FIELDS, 'rawNodeFields')\n if (sharedFig === fig) return outer\n return { ...outer, fig: { ...source.fig, ...sharedFig } }\n}\n\n/**\n * Swap the `fields` of `node` that hold an empty list or record, its source metadata's included,\n * for the shared ones. Writing known keys keeps the shape every layer shares.\n */\nexport function shareEmptyNodeValues(node: SceneNode, fields: Iterable<string>): void {\n for (const field of fields) {\n const value: unknown = Reflect.get(node, field)\n if (field === 'source') {\n if (isPlainObject(value)) node.source = withSharedEmptySource(node.source)\n continue\n }\n const shared = sharedEmptyValue(field, value)\n if (shared !== value) Reflect.set(node, field, shared)\n }\n}\n"],"mappings":";;;;;;;AASA,MAAa,aAAsB,OAAO,OAAgB,CAAC,CAAC;AAC5D,MAAa,eAAsC,OAAO,OAAO,CAAC,CAAC;;AAGnE,MAAM,kCAAuC,IAAI,IAAqB,CAAC,UAAU,CAAC;;AAGlF,MAAM,gCAAqC,IAAI,IAAqB;CAClE;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAM,qBAAqB,CAAC,cAAc;AAC1C,MAAM,yBAAyB;CAC7B;CACA;CACA;AACF;AAEA,SAAS,gBAAgB,OAAyB;CAChD,OAAO,MAAM,QAAQ,KAAK,KAAK,MAAM,WAAW,IAAI,aAAa;AACnE;AAEA,SAAS,kBAAkB,OAAyB;CAClD,OAAO,cAAc,KAAK,KAAK,cAAc,KAAK,IAAI,eAAe;AACvE;AAEA,SAAS,iBAAiB,OAAe,OAAyB;CAChE,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,gBAAgB,IAAI,KAAK,IAAI,QAAQ,gBAAgB,KAAK;CAC3F,OAAO,cAAc,IAAI,KAAK,IAAI,kBAAkB,KAAK,IAAI;AAC/D;;;;;;AAOA,SAAS,kBACP,QACA,OACA,aACG;CACH,MAAM,SAAkD,MAAM,KAAK,UAAU,CAC3E,OACA,eACF,CAAC;CACD,IAAI,gBAAgB,KAAA,GAAW,OAAO,KAAK,CAAC,aAAa,iBAAiB,CAAC;CAC3E,IAAI,OAAiB;CACrB,KAAK,MAAM,CAAC,OAAO,WAAW,QAAQ;EACpC,IAAI,CAAC,OAAO,OAAO,QAAQ,KAAK,GAAG;EACnC,MAAM,QAAiB,QAAQ,IAAI,QAAQ,KAAK;EAChD,MAAM,OAAO,OAAO,KAAK;EACzB,IAAI,SAAS,OAAO;EACpB,SAAS,EAAE,GAAG,OAAO;EACrB,QAAQ,IAAI,MAAM,OAAO,IAAI;CAC/B;CACA,OAAO,QAAQ;AACjB;;;;;;AAOA,SAAS,sBAAsB,QAAwC;CACrE,MAAM,QAAQ,kBAAkB,QAAQ,kBAAkB;CAC1D,MAAM,MAAe,QAAQ,IAAI,QAAQ,KAAK;CAC9C,IAAI,CAAC,cAAc,GAAG,GAAG,OAAO;CAChC,MAAM,YAAY,kBAAkB,KAAK,wBAAwB,eAAe;CAChF,IAAI,cAAc,KAAK,OAAO;CAC9B,OAAO;EAAE,GAAG;EAAO,KAAK;GAAE,GAAG,OAAO;GAAK,GAAG;EAAU;CAAE;AAC1D;;;;;AAMA,SAAgB,qBAAqB,MAAiB,QAAgC;CACpF,KAAK,MAAM,SAAS,QAAQ;EAC1B,MAAM,QAAiB,QAAQ,IAAI,MAAM,KAAK;EAC9C,IAAI,UAAU,UAAU;GACtB,IAAI,cAAc,KAAK,GAAG,KAAK,SAAS,sBAAsB,KAAK,MAAM;GACzE;EACF;EACA,MAAM,SAAS,iBAAiB,OAAO,KAAK;EAC5C,IAAI,WAAW,OAAO,QAAQ,IAAI,MAAM,OAAO,MAAM;CACvD;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/fields/components.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* What makes a layer a main component beyond its type: its key, its properties and variant
|
|
4
|
+
* specs, and how it is published to libraries.
|
|
5
|
+
*/
|
|
6
|
+
declare const MAIN_COMPONENT_FIELDS: readonly ["componentKey", "componentPropertyDefinitions", "variantPropSpecs", "sourceLibraryKey", "publishId", "overrideKey", "sharedSymbolVersion", "publishedVersion", "librarySource", "isPublishable", "isSymbolPublishable", "symbolDescription", "symbolLinks"];
|
|
7
|
+
//#endregion
|
|
8
|
+
export { MAIN_COMPONENT_FIELDS };
|
|
9
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","names":[],"sources":["../../src/fields/components.ts"],"mappings":";;;;;cAMa"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/fields/components.ts
|
|
2
|
+
/**
|
|
3
|
+
* What makes a layer a main component beyond its type: its key, its properties and variant
|
|
4
|
+
* specs, and how it is published to libraries.
|
|
5
|
+
*/
|
|
6
|
+
const MAIN_COMPONENT_FIELDS = [
|
|
7
|
+
"componentKey",
|
|
8
|
+
"componentPropertyDefinitions",
|
|
9
|
+
"variantPropSpecs",
|
|
10
|
+
"sourceLibraryKey",
|
|
11
|
+
"publishId",
|
|
12
|
+
"overrideKey",
|
|
13
|
+
"sharedSymbolVersion",
|
|
14
|
+
"publishedVersion",
|
|
15
|
+
"librarySource",
|
|
16
|
+
"isPublishable",
|
|
17
|
+
"isSymbolPublishable",
|
|
18
|
+
"symbolDescription",
|
|
19
|
+
"symbolLinks"
|
|
20
|
+
];
|
|
21
|
+
//#endregion
|
|
22
|
+
export { MAIN_COMPONENT_FIELDS };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","names":[],"sources":["../../src/fields/components.ts"],"sourcesContent":["import type { SceneNode } from '../types'\n\n/**\n * What makes a layer a main component beyond its type: its key, its properties and variant\n * specs, and how it is published to libraries.\n */\nexport const MAIN_COMPONENT_FIELDS = [\n 'componentKey',\n 'componentPropertyDefinitions',\n 'variantPropSpecs',\n 'sourceLibraryKey',\n 'publishId',\n 'overrideKey',\n 'sharedSymbolVersion',\n 'publishedVersion',\n 'librarySource',\n 'isPublishable',\n 'isSymbolPublishable',\n 'symbolDescription',\n 'symbolLinks'\n] as const satisfies readonly (keyof SceneNode)[]\n"],"mappings":";;;;;AAMA,MAAa,wBAAwB;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
|
package/dist/fields/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CORNER_FIELDS, PAINT_FIELDS, STROKE_FIELDS } from "./appearance.js";
|
|
2
|
+
import { MAIN_COMPONENT_FIELDS } from "./components.js";
|
|
2
3
|
import { SIZE_FIELDS, TRANSFORM_FIELDS } from "./geometry.js";
|
|
3
|
-
import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
|
|
4
|
+
import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
|
|
4
5
|
import { TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS } from "./text.js";
|
|
5
|
-
export { AUTO_LAYOUT_FIELDS, CORNER_FIELDS, LAYOUT_AFFECTING_KEYS, PAINT_FIELDS, SIZE_CONSTRAINT_FIELDS, SIZE_FIELDS, STROKE_FIELDS, TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS, TRANSFORM_FIELDS };
|
|
6
|
+
export { AUTO_LAYOUT_FIELDS, CORNER_FIELDS, LAYOUT_AFFECTING_KEYS, MAIN_COMPONENT_FIELDS, PAINT_FIELDS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS, SIZE_FIELDS, STROKE_FIELDS, TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS, TRANSFORM_FIELDS };
|
package/dist/fields/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SIZE_FIELDS, TRANSFORM_FIELDS } from "./geometry.js";
|
|
2
|
-
import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
|
|
2
|
+
import { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS } from "./layout.js";
|
|
3
3
|
import { TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS } from "./text.js";
|
|
4
4
|
import { CORNER_FIELDS, PAINT_FIELDS, STROKE_FIELDS } from "./appearance.js";
|
|
5
|
-
|
|
5
|
+
import { MAIN_COMPONENT_FIELDS } from "./components.js";
|
|
6
|
+
export { AUTO_LAYOUT_FIELDS, CORNER_FIELDS, LAYOUT_AFFECTING_KEYS, MAIN_COMPONENT_FIELDS, PAINT_FIELDS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS, SIZE_FIELDS, STROKE_FIELDS, TEXT_DECORATION_FIELDS, TEXT_LAYOUT_FIELDS, TEXT_METRIC_FIELDS, TEXT_SHAPING_FIELDS, TEXT_STYLE_FIELDS, TRANSFORM_FIELDS };
|
package/dist/fields/layout.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
//#region src/fields/layout.d.ts
|
|
2
2
|
/** How a frame lays out its children: auto layout and its grid tracks. */
|
|
3
3
|
declare const AUTO_LAYOUT_FIELDS: readonly ["layoutMode", "layoutDirection", "layoutWrap", "primaryAxisAlign", "counterAxisAlign", "counterAxisAlignContent", "primaryAxisSizing", "counterAxisSizing", "itemSpacing", "counterAxisSpacing", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "strokesIncludedInLayout", "gridTemplateColumns", "gridTemplateRows", "gridColumnGap", "gridRowGap"];
|
|
4
|
+
/** How a layer sits in its parent: its constraints and its place in an auto layout or grid. */
|
|
5
|
+
declare const PARENT_LAYOUT_FIELDS: readonly ["horizontalConstraint", "verticalConstraint", "layoutPositioning", "layoutGrow", "layoutAlignSelf", "gridPosition"];
|
|
4
6
|
/** Size limits a layer keeps however it is resized. */
|
|
5
7
|
declare const SIZE_CONSTRAINT_FIELDS: readonly ["minWidth", "maxWidth", "minHeight", "maxHeight", "targetAspectRatio"];
|
|
6
8
|
/** Fields whose change moves a layer or its children, so cached absolute positions go stale. */
|
|
7
9
|
declare const LAYOUT_AFFECTING_KEYS: ReadonlySet<string>;
|
|
8
10
|
//#endregion
|
|
9
|
-
export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS };
|
|
11
|
+
export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS };
|
|
10
12
|
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.d.ts","names":[],"sources":["../../src/fields/layout.ts"],"mappings":";;cAIa;;cAuBA;;cASA,uBAAuB"}
|
|
1
|
+
{"version":3,"file":"layout.d.ts","names":[],"sources":["../../src/fields/layout.ts"],"mappings":";;cAIa;;cAuBA;;cAUA;;cASA,uBAAuB"}
|
package/dist/fields/layout.js
CHANGED
|
@@ -22,6 +22,15 @@ const AUTO_LAYOUT_FIELDS = [
|
|
|
22
22
|
"gridColumnGap",
|
|
23
23
|
"gridRowGap"
|
|
24
24
|
];
|
|
25
|
+
/** How a layer sits in its parent: its constraints and its place in an auto layout or grid. */
|
|
26
|
+
const PARENT_LAYOUT_FIELDS = [
|
|
27
|
+
"horizontalConstraint",
|
|
28
|
+
"verticalConstraint",
|
|
29
|
+
"layoutPositioning",
|
|
30
|
+
"layoutGrow",
|
|
31
|
+
"layoutAlignSelf",
|
|
32
|
+
"gridPosition"
|
|
33
|
+
];
|
|
25
34
|
/** Size limits a layer keeps however it is resized. */
|
|
26
35
|
const SIZE_CONSTRAINT_FIELDS = [
|
|
27
36
|
"minWidth",
|
|
@@ -44,6 +53,6 @@ const LAYOUT_AFFECTING_KEYS = /* @__PURE__ */ new Set([
|
|
|
44
53
|
...SIZE_CONSTRAINT_FIELDS
|
|
45
54
|
]);
|
|
46
55
|
//#endregion
|
|
47
|
-
export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, SIZE_CONSTRAINT_FIELDS };
|
|
56
|
+
export { AUTO_LAYOUT_FIELDS, LAYOUT_AFFECTING_KEYS, PARENT_LAYOUT_FIELDS, SIZE_CONSTRAINT_FIELDS };
|
|
48
57
|
|
|
49
58
|
//# sourceMappingURL=layout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","names":[],"sources":["../../src/fields/layout.ts"],"sourcesContent":["import type { SceneNode } from '../types'\nimport { SIZE_FIELDS, TRANSFORM_FIELDS } from './geometry'\n\n/** How a frame lays out its children: auto layout and its grid tracks. */\nexport const AUTO_LAYOUT_FIELDS = [\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisAlign',\n 'counterAxisAlign',\n 'counterAxisAlignContent',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'strokesIncludedInLayout',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'gridColumnGap',\n 'gridRowGap'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Size limits a layer keeps however it is resized. */\nexport const SIZE_CONSTRAINT_FIELDS = [\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'targetAspectRatio'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Fields whose change moves a layer or its children, so cached absolute positions go stale. */\nexport const LAYOUT_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n ...TRANSFORM_FIELDS,\n ...SIZE_FIELDS,\n ...AUTO_LAYOUT_FIELDS,\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'horizontalConstraint',\n 'verticalConstraint',\n 'gridPosition',\n ...SIZE_CONSTRAINT_FIELDS\n])\n"],"mappings":";;;AAIA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,wCAA6C,IAAI,IAAI;CAChE,GAAG;CACH,GAAG;CACH,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;AACL,CAAC"}
|
|
1
|
+
{"version":3,"file":"layout.js","names":[],"sources":["../../src/fields/layout.ts"],"sourcesContent":["import type { SceneNode } from '../types'\nimport { SIZE_FIELDS, TRANSFORM_FIELDS } from './geometry'\n\n/** How a frame lays out its children: auto layout and its grid tracks. */\nexport const AUTO_LAYOUT_FIELDS = [\n 'layoutMode',\n 'layoutDirection',\n 'layoutWrap',\n 'primaryAxisAlign',\n 'counterAxisAlign',\n 'counterAxisAlignContent',\n 'primaryAxisSizing',\n 'counterAxisSizing',\n 'itemSpacing',\n 'counterAxisSpacing',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'strokesIncludedInLayout',\n 'gridTemplateColumns',\n 'gridTemplateRows',\n 'gridColumnGap',\n 'gridRowGap'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** How a layer sits in its parent: its constraints and its place in an auto layout or grid. */\nexport const PARENT_LAYOUT_FIELDS = [\n 'horizontalConstraint',\n 'verticalConstraint',\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'gridPosition'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Size limits a layer keeps however it is resized. */\nexport const SIZE_CONSTRAINT_FIELDS = [\n 'minWidth',\n 'maxWidth',\n 'minHeight',\n 'maxHeight',\n 'targetAspectRatio'\n] as const satisfies readonly (keyof SceneNode)[]\n\n/** Fields whose change moves a layer or its children, so cached absolute positions go stale. */\nexport const LAYOUT_AFFECTING_KEYS: ReadonlySet<string> = new Set([\n ...TRANSFORM_FIELDS,\n ...SIZE_FIELDS,\n ...AUTO_LAYOUT_FIELDS,\n 'layoutPositioning',\n 'layoutGrow',\n 'layoutAlignSelf',\n 'horizontalConstraint',\n 'verticalConstraint',\n 'gridPosition',\n ...SIZE_CONSTRAINT_FIELDS\n])\n"],"mappings":";;;AAIA,MAAa,qBAAqB;CAChC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,uBAAuB;CAClC;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,yBAAyB;CACpC;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,wCAA6C,IAAI,IAAI;CAChE,GAAG;CACH,GAAG;CACH,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA,GAAG;AACL,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SceneGraph } from "../graph.js";
|
|
2
2
|
import { NodeType, SceneNode } from "../types.js";
|
|
3
3
|
import { GeneratedFrameKind } from "./kind.js";
|
|
4
|
-
import { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextLabel, shapeWithTextLabelFields } from "./shape-with-text.js";
|
|
4
|
+
import { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields } from "./shape-with-text.js";
|
|
5
5
|
import { DEFAULT_STICKY_COLOR, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, StickyContent, StickySublayers, StickyTextRole, buildStickySublayers, createSticky, isWideSticky, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth } from "./sticky.js";
|
|
6
6
|
//#region src/generated/index.d.ts
|
|
7
7
|
/**
|
|
@@ -42,5 +42,5 @@ declare function layerResizes(node: Pick<SceneNode, 'type'>): boolean;
|
|
|
42
42
|
/** Whether a layer takes strokes and effects: any layer but a sticky note. */
|
|
43
43
|
declare function layerStrokesAndEffects(node: Pick<SceneNode, 'type'>): boolean;
|
|
44
44
|
//#endregion
|
|
45
|
-
export { DEFAULT_STICKY_COLOR, GENERATED_FRAME_TYPES, type GeneratedFrameKind, GeneratedFrameType, SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, StickyContent, StickySublayers, StickyTextRole, buildShapeWithTextLabel, buildStickySublayers, createShapeWithText, createSticky, generatedFrameKind, generatedFrameOwner, generatedFrameText, isGeneratedFrame, isWideSticky, layerResizes, layerRotates, layerStrokesAndEffects, shapeWithTextFrameFields, shapeWithTextLabel, shapeWithTextLabelFields, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth, withGeneratedFrameSize };
|
|
45
|
+
export { DEFAULT_STICKY_COLOR, GENERATED_FRAME_TYPES, type GeneratedFrameKind, GeneratedFrameType, SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, StickyContent, StickySublayers, StickyTextRole, buildShapeWithTextLabel, buildStickySublayers, createShapeWithText, createSticky, generatedFrameKind, generatedFrameOwner, generatedFrameText, isGeneratedFrame, isWideSticky, layerResizes, layerRotates, layerStrokesAndEffects, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth, withGeneratedFrameSize };
|
|
46
46
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/generated/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CONNECTOR_KIND } from "../connectors/sublayers.js";
|
|
2
|
-
import { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextLabel, shapeWithTextLabelFields } from "./shape-with-text.js";
|
|
2
|
+
import { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields } from "./shape-with-text.js";
|
|
3
3
|
import { DEFAULT_STICKY_COLOR, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, buildStickySublayers, createSticky, isWideSticky, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth } from "./sticky.js";
|
|
4
4
|
//#region src/generated/index.ts
|
|
5
5
|
/**
|
|
@@ -57,6 +57,6 @@ function layerStrokesAndEffects(node) {
|
|
|
57
57
|
return generatedFrameKind(node)?.strokesAndEffects ?? true;
|
|
58
58
|
}
|
|
59
59
|
//#endregion
|
|
60
|
-
export { DEFAULT_STICKY_COLOR, GENERATED_FRAME_TYPES, SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, buildShapeWithTextLabel, buildStickySublayers, createShapeWithText, createSticky, generatedFrameKind, generatedFrameOwner, generatedFrameText, isGeneratedFrame, isWideSticky, layerResizes, layerRotates, layerStrokesAndEffects, shapeWithTextFrameFields, shapeWithTextLabel, shapeWithTextLabelFields, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth, withGeneratedFrameSize };
|
|
60
|
+
export { DEFAULT_STICKY_COLOR, GENERATED_FRAME_TYPES, SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, STICKY_AUTHOR_FONT_SIZE, STICKY_BODY_FONT_SIZE, STICKY_COLORS, STICKY_FONT_FAMILY, STICKY_FONT_WEIGHT, STICKY_KIND, STICKY_SIZE, STICKY_SUBLAYER_LAYOUT, STICKY_WIDE_WIDTH, buildShapeWithTextLabel, buildStickySublayers, createShapeWithText, createSticky, generatedFrameKind, generatedFrameOwner, generatedFrameText, isGeneratedFrame, isWideSticky, layerResizes, layerRotates, layerStrokesAndEffects, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields, stickyFrameFields, stickyScale, stickyShadows, stickySublayers, stickyTextFields, stickyWidth, withGeneratedFrameSize };
|
|
61
61
|
|
|
62
62
|
//# sourceMappingURL=index.js.map
|
|
@@ -5,7 +5,7 @@ import { GeneratedFrameKind } from "./kind.js";
|
|
|
5
5
|
//#region src/generated/shape-with-text.d.ts
|
|
6
6
|
/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */
|
|
7
7
|
declare const SHAPE_WITH_TEXT_SIZE = 176;
|
|
8
|
-
/** FigJam rounds every corner of a shape by 6 px. */
|
|
8
|
+
/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */
|
|
9
9
|
declare const SHAPE_WITH_TEXT_CORNER_RADIUS = 6;
|
|
10
10
|
/** How the label sits in its shape: as wide as the label box, as tall as its text. */
|
|
11
11
|
declare const SHAPE_WITH_TEXT_LABEL_LAYOUT: {
|
|
@@ -18,6 +18,11 @@ declare const SHAPE_WITH_TEXT_LABEL_LAYOUT: {
|
|
|
18
18
|
* whenever either changes.
|
|
19
19
|
*/
|
|
20
20
|
declare function shapeWithTextFrameFields(kind: ShapeWithTextType, width: number, height: number): Partial<SceneNode>;
|
|
21
|
+
/**
|
|
22
|
+
* What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the
|
|
23
|
+
* label area, and the corners a rounded rectangle leaves go back to FigJam's 6.
|
|
24
|
+
*/
|
|
25
|
+
declare function shapeWithTextKindFields(shape: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>, kind: ShapeWithTextType): Partial<SceneNode>;
|
|
21
26
|
/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */
|
|
22
27
|
declare function shapeWithTextLabelFields(): Partial<SceneNode>;
|
|
23
28
|
/** A shape's label: its one text sublayer. */
|
|
@@ -34,5 +39,5 @@ declare function buildShapeWithTextLabel(graph: SceneGraph, shape: SceneNode, pr
|
|
|
34
39
|
/** A new shape with text and its label; the caller lays it out to grow it to its text. */
|
|
35
40
|
declare function createShapeWithText(graph: SceneGraph, parentId: string, props?: Partial<SceneNode>, label?: Partial<SceneNode>): SceneNode;
|
|
36
41
|
//#endregion
|
|
37
|
-
export { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextLabel, shapeWithTextLabelFields };
|
|
42
|
+
export { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields };
|
|
38
43
|
//# sourceMappingURL=shape-with-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape-with-text.d.ts","names":[],"sources":["../../src/generated/shape-with-text.ts"],"mappings":";;;;;;cAUa;;cAEA;;
|
|
1
|
+
{"version":3,"file":"shape-with-text.d.ts","names":[],"sources":["../../src/generated/shape-with-text.ts"],"mappings":";;;;;;cAUa;;cAEA;;cAWA;WAAA;WAAA;;;;;;;iBAUG,yBACd,MAAM,mBACN,eACA,iBACC,QAAQ;;;;;iBAwBK,wBACd,OAAO,KAAK,sDACZ,MAAM,oBACL,QAAQ;;iBAWK,4BAA4B,QAAQ;;iBAcpC,mBAAmB,OAAO,YAAY,OAAO,YAAY;;;;;;;cAc5D,sBAAsB;;iBAcnB,wBACd,OAAO,YACP,OAAO,WACP,QAAO,QAAQ,aACd;;iBAea,oBACd,OAAO,YACP,kBACA,QAAO,QAAQ,YACf,QAAO,QAAQ,aACd"}
|
|
@@ -5,8 +5,13 @@ import { shapeWithTextLabelBox } from "../shape-with-text/fit.js";
|
|
|
5
5
|
//#region src/generated/shape-with-text.ts
|
|
6
6
|
/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */
|
|
7
7
|
const SHAPE_WITH_TEXT_SIZE = 176;
|
|
8
|
-
/** FigJam rounds every corner of a shape by 6 px. */
|
|
8
|
+
/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */
|
|
9
9
|
const SHAPE_WITH_TEXT_CORNER_RADIUS = 6;
|
|
10
|
+
/**
|
|
11
|
+
* FigJam keeps a rounded rectangle's corner radius at 0.4 of its shorter side, through resizes,
|
|
12
|
+
* measured in FigJam; Figma draws the shape from that radius.
|
|
13
|
+
*/
|
|
14
|
+
const ROUNDED_RECTANGLE_RADIUS = .4;
|
|
10
15
|
const LABEL_FILL = {
|
|
11
16
|
type: "SOLID",
|
|
12
17
|
color: { ...BLACK },
|
|
@@ -36,7 +41,19 @@ function shapeWithTextFrameFields(kind, width, height) {
|
|
|
36
41
|
paddingRight: Math.max(0, width - box.x - box.width),
|
|
37
42
|
paddingBottom: Math.max(0, height - box.y - box.height),
|
|
38
43
|
paddingLeft: box.x,
|
|
39
|
-
clipsContent: false
|
|
44
|
+
clipsContent: false,
|
|
45
|
+
...kind === "ROUNDED_RECTANGLE" ? { cornerRadius: ROUNDED_RECTANGLE_RADIUS * Math.min(width, height) } : {}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the
|
|
50
|
+
* label area, and the corners a rounded rectangle leaves go back to FigJam's 6.
|
|
51
|
+
*/
|
|
52
|
+
function shapeWithTextKindFields(shape, kind) {
|
|
53
|
+
return {
|
|
54
|
+
shapeWithTextType: kind,
|
|
55
|
+
...shape.shapeWithTextType === "ROUNDED_RECTANGLE" && kind !== shape.shapeWithTextType ? { cornerRadius: 6 } : {},
|
|
56
|
+
...shapeWithTextFrameFields(kind, shape.width, shape.height)
|
|
40
57
|
};
|
|
41
58
|
}
|
|
42
59
|
/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */
|
|
@@ -114,6 +131,6 @@ function createShapeWithText(graph, parentId, props = {}, label = {}) {
|
|
|
114
131
|
return shape;
|
|
115
132
|
}
|
|
116
133
|
//#endregion
|
|
117
|
-
export { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextLabel, shapeWithTextLabelFields };
|
|
134
|
+
export { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_KIND, SHAPE_WITH_TEXT_LABEL_LAYOUT, SHAPE_WITH_TEXT_SIZE, buildShapeWithTextLabel, createShapeWithText, shapeWithTextFrameFields, shapeWithTextKindFields, shapeWithTextLabel, shapeWithTextLabelFields };
|
|
118
135
|
|
|
119
136
|
//# sourceMappingURL=shape-with-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape-with-text.js","names":[],"sources":["../../src/generated/shape-with-text.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport { FIGJAM_TYPEFACES, figJamTextSizeFields } from '../figjam/text'\nimport type { SceneGraph } from '../index'\nimport { shapeWithTextLabelBox } from '../shape-with-text/fit'\nimport type { ShapeWithTextType } from '../shape-with-text/kinds'\nimport { lineHeightPixels } from '../text/lengths'\nimport type { Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */\nexport const SHAPE_WITH_TEXT_SIZE = 176\n/** FigJam rounds every corner of a shape by 6 px. */\nexport const SHAPE_WITH_TEXT_CORNER_RADIUS = 6\n\nconst LABEL_FILL: Fill = { type: 'SOLID', color: { ...BLACK }, opacity: 0.8, visible: true }\n\n/** How the label sits in its shape: as wide as the label box, as tall as its text. */\nexport const SHAPE_WITH_TEXT_LABEL_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/**\n * The shape's own layout: a vertical auto layout that centres the label in the label box of its\n * kind, which the padding leaves free. The padding follows the kind and size, so it is set again\n * whenever either changes.\n */\nexport function shapeWithTextFrameFields(\n kind: ShapeWithTextType,\n width: number,\n height: number\n): Partial<SceneNode> {\n const box = shapeWithTextLabelBox(kind, width, height)\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'CENTER',\n counterAxisAlign: 'CENTER',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n paddingTop: box.y,\n paddingRight: Math.max(0, width - box.x - box.width),\n paddingBottom: Math.max(0, height - box.y - box.height),\n paddingLeft: box.x,\n clipsContent: false\n }\n}\n\n/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */\nexport function shapeWithTextLabelFields(): Partial<SceneNode> {\n return {\n name: 'Text',\n fontFamily: FIGJAM_TYPEFACES.simple.fontFamily,\n fontWeight: FIGJAM_TYPEFACES.simple.fontWeight,\n ...figJamTextSizeFields('small'),\n textAlignHorizontal: 'CENTER',\n textAlignVertical: 'TOP',\n fills: [{ ...LABEL_FILL, color: { ...LABEL_FILL.color } }],\n ...SHAPE_WITH_TEXT_LABEL_LAYOUT\n }\n}\n\n/** A shape's label: its one text sublayer. */\nexport function shapeWithTextLabel(graph: SceneGraph, shape: SceneNode): SceneNode | null {\n if (shape.type !== 'SHAPE_WITH_TEXT') return null\n const children = graph.getChildren(shape.id)\n if (children.length !== 1) return null\n const [label] = children\n return label.type === 'TEXT' ? label : null\n}\n\n/**\n * A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes\n * its name from its label until it is named. A height set on it by a resize, a field or a script\n * is the height it was given, which layout grows it from when its label needs more room; once\n * that height changes, FigJam keeps it and truncates the label instead.\n */\nexport const SHAPE_WITH_TEXT_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => shapeWithTextLabel(graph, frame) !== null,\n text: (graph, frame) => shapeWithTextLabel(graph, frame) ?? undefined,\n rotates: true,\n resizes: true,\n strokesAndEffects: true,\n namedByText: true,\n sized: ({ height }, shape) =>\n height === undefined || height === shape.height\n ? {}\n : { shapeUserHeight: height, shapeTruncates: true }\n}\n\n/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */\nexport function buildShapeWithTextLabel(\n graph: SceneGraph,\n shape: SceneNode,\n props: Partial<SceneNode> = {}\n): SceneNode {\n const box = shapeWithTextLabelBox(shape.shapeWithTextType, shape.width, shape.height)\n const fields = shapeWithTextLabelFields()\n return graph.createNode('TEXT', shape.id, {\n ...fields,\n x: box.x,\n y: box.y,\n width: box.width,\n height: lineHeightPixels(fields.lineHeight ?? null, fields.fontSize ?? 0) ?? undefined,\n text: '',\n ...props\n })\n}\n\n/** A new shape with text and its label; the caller lays it out to grow it to its text. */\nexport function createShapeWithText(\n graph: SceneGraph,\n parentId: string,\n props: Partial<SceneNode> = {},\n label: Partial<SceneNode> = {}\n): SceneNode {\n const kind = props.shapeWithTextType ?? 'SQUARE'\n const width = props.width ?? SHAPE_WITH_TEXT_SIZE\n const height = props.height ?? SHAPE_WITH_TEXT_SIZE\n const shape = graph.createNode('SHAPE_WITH_TEXT', parentId, {\n name: 'Shape with text',\n cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS,\n ...props,\n shapeWithTextType: kind,\n width,\n height,\n shapeUserHeight: props.shapeUserHeight ?? height,\n ...shapeWithTextFrameFields(kind, width, height)\n })\n buildShapeWithTextLabel(graph, shape, label)\n return shape\n}\n"],"mappings":";;;;;;AAUA,MAAa,uBAAuB;;AAEpC,MAAa,gCAAgC;
|
|
1
|
+
{"version":3,"file":"shape-with-text.js","names":[],"sources":["../../src/generated/shape-with-text.ts"],"sourcesContent":["import { BLACK } from '../constants'\nimport { FIGJAM_TYPEFACES, figJamTextSizeFields } from '../figjam/text'\nimport type { SceneGraph } from '../index'\nimport { shapeWithTextLabelBox } from '../shape-with-text/fit'\nimport type { ShapeWithTextType } from '../shape-with-text/kinds'\nimport { lineHeightPixels } from '../text/lengths'\nimport type { Fill, SceneNode } from '../types'\nimport type { GeneratedFrameKind } from './kind'\n\n/** FigJam makes a shape with text 176 px square, from its tool and from its plugin API. */\nexport const SHAPE_WITH_TEXT_SIZE = 176\n/** FigJam rounds every corner of a shape by 6 px, but a rounded rectangle's. */\nexport const SHAPE_WITH_TEXT_CORNER_RADIUS = 6\n\n/**\n * FigJam keeps a rounded rectangle's corner radius at 0.4 of its shorter side, through resizes,\n * measured in FigJam; Figma draws the shape from that radius.\n */\nconst ROUNDED_RECTANGLE_RADIUS = 0.4\n\nconst LABEL_FILL: Fill = { type: 'SOLID', color: { ...BLACK }, opacity: 0.8, visible: true }\n\n/** How the label sits in its shape: as wide as the label box, as tall as its text. */\nexport const SHAPE_WITH_TEXT_LABEL_LAYOUT = {\n textAutoResize: 'HEIGHT',\n layoutAlignSelf: 'STRETCH'\n} as const satisfies Partial<SceneNode>\n\n/**\n * The shape's own layout: a vertical auto layout that centres the label in the label box of its\n * kind, which the padding leaves free. The padding follows the kind and size, so it is set again\n * whenever either changes.\n */\nexport function shapeWithTextFrameFields(\n kind: ShapeWithTextType,\n width: number,\n height: number\n): Partial<SceneNode> {\n const box = shapeWithTextLabelBox(kind, width, height)\n return {\n layoutMode: 'VERTICAL',\n primaryAxisAlign: 'CENTER',\n counterAxisAlign: 'CENTER',\n primaryAxisSizing: 'FIXED',\n counterAxisSizing: 'FIXED',\n itemSpacing: 0,\n paddingTop: box.y,\n paddingRight: Math.max(0, width - box.x - box.width),\n paddingBottom: Math.max(0, height - box.y - box.height),\n paddingLeft: box.x,\n clipsContent: false,\n ...(kind === 'ROUNDED_RECTANGLE'\n ? { cornerRadius: ROUNDED_RECTANGLE_RADIUS * Math.min(width, height) }\n : {})\n }\n}\n\n/**\n * What turning a shape into `kind` changes, keeping its size, as FigJam's shape switcher does: the\n * label area, and the corners a rounded rectangle leaves go back to FigJam's 6.\n */\nexport function shapeWithTextKindFields(\n shape: Pick<SceneNode, 'shapeWithTextType' | 'width' | 'height'>,\n kind: ShapeWithTextType\n): Partial<SceneNode> {\n const leavesRounded =\n shape.shapeWithTextType === 'ROUNDED_RECTANGLE' && kind !== shape.shapeWithTextType\n return {\n shapeWithTextType: kind,\n ...(leavesRounded ? { cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS } : {}),\n ...shapeWithTextFrameFields(kind, shape.width, shape.height)\n }\n}\n\n/** The label's text style as FigJam starts it: Inter Medium at its Small size, black at 80%. */\nexport function shapeWithTextLabelFields(): Partial<SceneNode> {\n return {\n name: 'Text',\n fontFamily: FIGJAM_TYPEFACES.simple.fontFamily,\n fontWeight: FIGJAM_TYPEFACES.simple.fontWeight,\n ...figJamTextSizeFields('small'),\n textAlignHorizontal: 'CENTER',\n textAlignVertical: 'TOP',\n fills: [{ ...LABEL_FILL, color: { ...LABEL_FILL.color } }],\n ...SHAPE_WITH_TEXT_LABEL_LAYOUT\n }\n}\n\n/** A shape's label: its one text sublayer. */\nexport function shapeWithTextLabel(graph: SceneGraph, shape: SceneNode): SceneNode | null {\n if (shape.type !== 'SHAPE_WITH_TEXT') return null\n const children = graph.getChildren(shape.id)\n if (children.length !== 1) return null\n const [label] = children\n return label.type === 'TEXT' ? label : null\n}\n\n/**\n * A shape with text edits its label in place, turns and resizes freely, and, as in FigJam, takes\n * its name from its label until it is named. A height set on it by a resize, a field or a script\n * is the height it was given, which layout grows it from when its label needs more room; once\n * that height changes, FigJam keeps it and truncates the label instead.\n */\nexport const SHAPE_WITH_TEXT_KIND: GeneratedFrameKind = {\n complete: (graph, frame) => shapeWithTextLabel(graph, frame) !== null,\n text: (graph, frame) => shapeWithTextLabel(graph, frame) ?? undefined,\n rotates: true,\n resizes: true,\n strokesAndEffects: true,\n namedByText: true,\n sized: ({ height }, shape) =>\n height === undefined || height === shape.height\n ? {}\n : { shapeUserHeight: height, shapeTruncates: true }\n}\n\n/** Adds the label to a SHAPE_WITH_TEXT the caller created, styled as FigJam generates it. */\nexport function buildShapeWithTextLabel(\n graph: SceneGraph,\n shape: SceneNode,\n props: Partial<SceneNode> = {}\n): SceneNode {\n const box = shapeWithTextLabelBox(shape.shapeWithTextType, shape.width, shape.height)\n const fields = shapeWithTextLabelFields()\n return graph.createNode('TEXT', shape.id, {\n ...fields,\n x: box.x,\n y: box.y,\n width: box.width,\n height: lineHeightPixels(fields.lineHeight ?? null, fields.fontSize ?? 0) ?? undefined,\n text: '',\n ...props\n })\n}\n\n/** A new shape with text and its label; the caller lays it out to grow it to its text. */\nexport function createShapeWithText(\n graph: SceneGraph,\n parentId: string,\n props: Partial<SceneNode> = {},\n label: Partial<SceneNode> = {}\n): SceneNode {\n const kind = props.shapeWithTextType ?? 'SQUARE'\n const width = props.width ?? SHAPE_WITH_TEXT_SIZE\n const height = props.height ?? SHAPE_WITH_TEXT_SIZE\n const shape = graph.createNode('SHAPE_WITH_TEXT', parentId, {\n name: 'Shape with text',\n cornerRadius: SHAPE_WITH_TEXT_CORNER_RADIUS,\n ...props,\n shapeWithTextType: kind,\n width,\n height,\n shapeUserHeight: props.shapeUserHeight ?? height,\n ...shapeWithTextFrameFields(kind, width, height)\n })\n buildShapeWithTextLabel(graph, shape, label)\n return shape\n}\n"],"mappings":"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"}
|
package/dist/graph.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BufferedSceneEmitter } from "./buffered-events.js";
|
|
2
2
|
import { NodeCloneMode } from "./copy.js";
|
|
3
3
|
import { Color, Rect, Vector } from "./primitives/index.js";
|
|
4
|
-
import { DropTargetOptions } from "./hit-test.js";
|
|
4
|
+
import { DropTargetOptions } from "./hit-test/drop.js";
|
|
5
5
|
import { SwapInstanceOptions } from "./instances/index.js";
|
|
6
6
|
import { NodePreviewObserver } from "./preview.js";
|
|
7
7
|
import { VariableModeFallback } from "./variables/resolution.js";
|
|
@@ -196,6 +196,13 @@ declare class SceneGraph {
|
|
|
196
196
|
*/
|
|
197
197
|
insertChildAt(childId: string, parentId: string, index: number): void;
|
|
198
198
|
deleteNode(id: string): void;
|
|
199
|
+
/**
|
|
200
|
+
* Deletes `node` and its layers, children first. Their parent goes with them, so its child
|
|
201
|
+
* list is emptied once instead of being filtered for each child, which kept deleting a frame
|
|
202
|
+
* of thousands of layers quadratic. The list is emptied before the children go, so a listener
|
|
203
|
+
* of a child's deletion never finds it still listed.
|
|
204
|
+
*/
|
|
205
|
+
private deleteSubtree;
|
|
199
206
|
hitTest(px: number, py: number, scopeId?: string): SceneNode | null;
|
|
200
207
|
/** `pad`, in canvas units, grows each shape's box, as Figma takes clicks just outside one. */
|
|
201
208
|
hitTestDeep(px: number, py: number, scopeId?: string, pad?: number): SceneNode | null;
|
package/dist/graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","names":[],"sources":["../src/graph.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","names":[],"sources":["../src/graph.ts"],"mappings":";;;;;;;;;cAgEa;mBAuCkB;EAtC7B,OAAK,YAAA;EACL,QAAM,YAAA,WAAA;EACN,WAAS,YAAA;EACT,qBAAmB,YAAA;EACnB,YAAU;EACV;EACA;;EAEA,mBAAmB;EACnB,oBAAoB;EACpB,cAAc;EACd,kBAAgB,YAAA;WACP,SAAO;UACR;mBACS;UAQT;;UAEA;mBACS;mBAGA;;mBAEA;UACT;UACA;EACR;EACA,eAAa,YAAA;;EAEb,cAAY;EAEiB,YAAA;EAW7B,QAAQ,eAAe;EAIvB,SAAS,4BAA0B;EAKnC,eAAe,SAAS;EAGxB,QAAQ,aAAa;EAGrB,aAAa,UAAU;;;;;;;EAUvB,mBAAmB,UAAU;;;;;;;EAW7B,gBAAgB,GAAG,aAAa,IAAI;;;;;;EAe9B,gBAAgB,GAAG,SAAS,QAAQ,KAAK,QAAQ;;EAyBvD,eAAe,MAAM;EAKrB,iBAAiB;EAkBjB,YAAY,UAAU;EAGtB,eAAe;EAGf,cAAc,YAAY;EAG1B,eACE,cACA,MAAM,cACN,sBACA,QAAQ,gBACP;EAWH,iBAAiB,eAAe;EAMhC,WAAW,sBAAsB,cAAc;;;;;EAc/C;EAKA,iBAAiB;EAIjB,gBAAgB;EAIhB,sBAAsB,gBAAgB;EAItC,cAAc,sBAAsB;EAIpC,QAAQ,sBAAsB,gBAAgB,cAAc;EAI5D,WAAW,sBAAsB;EAIjC,WAAW,sBAAsB,gBAAgB;EAIjD,eAAe,sBAAsB;EAIrC,gBACE,oBACA,iBACA,UAAU,cACT;EAIH,qBAAqB,qBAAqB;EAI1C,sBAAsB;EAItB,4BACE,gBACA,oBACA,WAAW,uBACV;EAIH,6BACE,gBACA,oBACA,WAAW;EAKb,uBACE,gBACA,oBACA,WAAW,uBACV;EAIH,6BACE,gBACA,oBACA,WAAW;EAKb,0BAA0B,uBAAuB;EAIjD,mBAAmB,MAAM,eAAe;EAIxC,aAAa,gBAAgB,eAAe;EAI5C,eAAe,gBAAgB;EAI/B,YAAY,aAAa;EAQzB,YAAY;EAKZ,aAAa,iBAAiB;;;;;EAQ9B,QAAQ,YAAY,QAAQ,MAAM,wBAAwB;;;;;EAa1D,OAAO;EAIP;EAIA,oBAAoB,aAAa;EAYjC,kBAAkB,aAAa;;;;;;UAevB;UAaA;;EAMR,gBAAgB;UAUR;UAQA;;;;;UAOA;UASA;;EAUR,mBAAmB,GAAG,cAAc,IAAI;EAIxC,WAAW,MAAM,UAAU,kBAAkB,YAAW,QAAQ,aAAkB;EAalF,iBACE,YACA,MAAM,UACN,yBACA,YAAW,QAAQ,aAClB;UAqBK;EASR,kBAAkB,gBAAgB,eAAe;EAQjD,6BAA6B,GAAG,UAAU,IAAI;MAG1C;;EAKJ,mBAAmB;;EAOnB,eAAe,YAAY;;EAM3B,kBAAkB,YAAY;EAQ9B,yBAAyB,GAAG,UAAU,GAAG,6BAA6B;MAUlE;;;;;EAQJ,yBAAyB;;;;;;EASzB,4BAA4B;MAIxB;MAIA;;;;;;EASJ,oBAAoB;UAeZ;MASJ;EAGJ,0BAA0B,YAAY,WAAW;EAGjD,kBAAkB,YAAY,SAAS,QAAQ;;;;;EAgB/C,WAAW,YAAY,SAAS,QAAQ;;;;;UAiBhC;;EAOR,sBACE,YACA,SAAS,QAAQ,YACjB,wBAAwB;UAMlB;;UA6CA;;UAOA;;UAKA;UAUA;EAgBR,aAAa,gBAAgB;;;;;;EA4D7B,cAAc,iBAAiB,kBAAkB;EAsBjD,WAAW;;;;;;;UAsBH;EAsBR,QAAQ,YAAY,YAAY,mBAAmB;;EAKnD,YAAY,YAAY,YAAY,kBAAkB,eAAU;;;;EAOhE,kBACE,YACA,YACA,iBACA,aAAa,qBACb,cACA,mBACC;EAIH,qBAAqB,YAAY,YAAY,kBAAkB;EAI/D,gBAAgB;EAIhB,cAAc,gBAAgB,YAAY;EAI1C,kBACE,YACA,YACA,YAAY,qBACZ,kBACA,UAAU,oBACT;EAIH,UACE,kBACA,kBACA,YAAW,QAAQ,aAClB;UAUK;EAkCR,eACE,qBACA,kBACA,YAAW,QAAQ,aAClB;EAIH,yBACE,oBACA,qBACA,OAAM;EAKR,sBACE,oBACA,qBACA,UAAU;EAKZ,cAAc;EAId,sBAAsB,cAAc;EAIpC,aAAa;EAIb,eAAe;EAIf,iBAAiB,qBAAqB;EAItC,aAAa,sBAAsB;;;;;EAQnC,YAAY,mBAAmB,iBAAY;IAAQ,MAAM;IAAW"}
|