@pairdraw/design-jsx 0.19.2 → 0.21.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/chunks/component-properties.js +6 -6
- package/dist/chunks/component-properties.js.map +1 -1
- package/dist/chunks/effects.js +54 -2
- package/dist/chunks/effects.js.map +1 -1
- package/dist/chunks/elements.js +72 -35
- package/dist/chunks/elements.js.map +1 -1
- package/dist/chunks/export/decoration.js +4 -4
- package/dist/chunks/export/decoration.js.map +1 -1
- package/dist/chunks/export/index.js +42 -22
- package/dist/chunks/export/index.js.map +1 -1
- package/dist/chunks/fields.js +27 -27
- package/dist/chunks/fields.js.map +1 -1
- package/dist/chunks/index.js +1 -1
- package/dist/chunks/index.js.map +1 -1
- package/dist/index.d.ts +29 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/package.json +3 -3
- package/src/effects.ts +81 -2
- package/src/elements.ts +1 -1
- package/src/export/decoration.ts +4 -3
- package/src/export/helpers.ts +8 -6
- package/src/export/index.ts +4 -2
- package/src/export/paint.ts +91 -29
- package/src/export/props.ts +10 -10
- package/src/export/text.ts +14 -8
- package/src/export/variables.ts +1 -1
- package/src/helpers.ts +26 -1
- package/src/index.ts +6 -1
- package/src/overrides/effects.ts +7 -3
- package/src/overrides/fills.ts +6 -3
- package/src/overrides/strokes.ts +9 -5
- package/src/overrides/text.ts +4 -3
- package/src/props-overrides.ts +37 -19
- package/src/reference/authoring.md +1 -1
- package/src/renderer.ts +20 -7
- package/src/shapes-with-text.ts +2 -2
- package/src/variables/graph.ts +1 -1
package/dist/chunks/elements.js
CHANGED
|
@@ -2,19 +2,24 @@ import { REKA_ELEMENTS, plainTextOf, rekaRole } from "./behaviours/elements.js";
|
|
|
2
2
|
import { FIGJAM_TEXT_SIZE, FIGJAM_TYPEFACE, SHAPE_KIND, STROKE_ALIGN, STROKE_CAP, STROKE_JOIN, connectorPropsSchema, ownLayerPropsSchema, placedOwnLayerPropsSchema, readElementProps, shapeLayerPropsSchema, shapePropsSchema, stickyPropsSchema } from "./component-properties.js";
|
|
3
3
|
import { DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES, DESIGN_JSX_SPAN_PROPERTY_NAMES, DESIGN_JSX_SUPPORTED_PROPERTY_NAMES, DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES } from "./behaviours/render.js";
|
|
4
4
|
import { connectorBindingTarget, helperCall, plainValue, renderConnectorNode } from "./connectors.js";
|
|
5
|
-
import { colorToHex, colorToHex8 } from "@pairdraw/scene-graph/color";
|
|
5
|
+
import { colorToDocumentCSS, colorToHex, colorToHex8 } from "@pairdraw/scene-graph/color";
|
|
6
6
|
import { gradientTransformRows, isIdentityGradientTransform } from "@pairdraw/scene-graph/gradient";
|
|
7
7
|
import { isShaderPresetPaint, shaderOfPaint } from "@pairdraw/scene-graph/shaders";
|
|
8
8
|
import { SHAPE_WITH_TEXT_CORNER_RADIUS, SHAPE_WITH_TEXT_SIZE, STICKY_COLORS, createShapeWithText, createSticky, isWideSticky, shapeWithTextLabel, stickyScale, stickySublayers } from "@pairdraw/scene-graph/generated";
|
|
9
9
|
import { difference } from "es-toolkit/array";
|
|
10
10
|
import { figJamTextSize, figJamTextSizeFields, figJamTypeface, figJamTypefaceFields } from "@pairdraw/scene-graph/figjam";
|
|
11
11
|
//#region src/export/helpers.ts
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
/** A color as the JSX runtime reads it, in the document's profile, so a P3 color keeps its gamut. */
|
|
13
|
+
function formatColor(color, opacity = 1, profile = "srgb") {
|
|
14
|
+
if (profile === "srgb") return colorToHex8(color, opacity);
|
|
15
|
+
return colorToDocumentCSS({
|
|
16
|
+
...color,
|
|
17
|
+
a: opacity
|
|
18
|
+
}, profile);
|
|
19
|
+
}
|
|
20
|
+
function formatShadow(e, profile = "srgb") {
|
|
16
21
|
if (e.type !== "DROP_SHADOW" && e.type !== "INNER_SHADOW") return null;
|
|
17
|
-
return `${e.offset.x} ${e.offset.y} ${e.radius} ${formatColor(e.color, e.color.a)}`;
|
|
22
|
+
return `${e.offset.x} ${e.offset.y} ${e.radius} ${formatColor(e.color, e.color.a, profile)}`;
|
|
18
23
|
}
|
|
19
24
|
function getNodeContext(node, graph) {
|
|
20
25
|
const parent = node.parentId ? graph.getNode(node.parentId) : null;
|
|
@@ -92,7 +97,7 @@ function blendMode(mode) {
|
|
|
92
97
|
function options(entries) {
|
|
93
98
|
return Object.values(entries).some((value) => value !== void 0) ? entries : void 0;
|
|
94
99
|
}
|
|
95
|
-
function fillValue(fill, node) {
|
|
100
|
+
function fillValue(fill, node, profile) {
|
|
96
101
|
const visible = fill.visible ? void 0 : false;
|
|
97
102
|
const shader = shaderOfPaint(node, fill);
|
|
98
103
|
if (shader && isShaderPresetPaint(shader)) {
|
|
@@ -113,7 +118,7 @@ function fillValue(fill, node) {
|
|
|
113
118
|
}));
|
|
114
119
|
}
|
|
115
120
|
if (fill.type === "SOLID") {
|
|
116
|
-
const color = formatColor(fill.color, fill.color.a);
|
|
121
|
+
const color = formatColor(fill.color, fill.color.a, profile);
|
|
117
122
|
const opacity = fill.opacity === fill.color.a ? void 0 : fill.opacity;
|
|
118
123
|
return helperCall("solid", color, options({
|
|
119
124
|
opacity,
|
|
@@ -123,7 +128,7 @@ function fillValue(fill, node) {
|
|
|
123
128
|
}
|
|
124
129
|
const helper = GRADIENT_HELPERS[fill.type];
|
|
125
130
|
if (helper && fill.gradientStops) {
|
|
126
|
-
const stops = fill.gradientStops.map((stop) => [formatColor(stop.color, stop.color.a), stop.position]);
|
|
131
|
+
const stops = fill.gradientStops.map((stop) => [formatColor(stop.color, stop.color.a, profile), stop.position]);
|
|
127
132
|
return helperCall(helper, stops, options({
|
|
128
133
|
opacity: fill.opacity === 1 ? void 0 : fill.opacity,
|
|
129
134
|
visible,
|
|
@@ -138,29 +143,29 @@ function fillValue(fill, node) {
|
|
|
138
143
|
});
|
|
139
144
|
}
|
|
140
145
|
/** A single visible solid paint fits the `bg` or text `color` shorthand. */
|
|
141
|
-
function solidShorthand(fills) {
|
|
146
|
+
function solidShorthand(fills, profile) {
|
|
142
147
|
if (fills.length !== 1) return null;
|
|
143
148
|
const [fill] = fills;
|
|
144
149
|
if (fill.type !== "SOLID" || !fill.visible || blendMode(fill.blendMode)) return null;
|
|
145
150
|
if (fill.opacity !== fill.color.a) return null;
|
|
146
|
-
return formatColor(fill.color, fill.color.a);
|
|
151
|
+
return formatColor(fill.color, fill.color.a, profile);
|
|
147
152
|
}
|
|
148
153
|
/** One paint as a colour prop takes it: a colour string when it is plain, its helper otherwise. */
|
|
149
|
-
function paintPropValue(fill, node) {
|
|
150
|
-
return solidShorthand([fill]) ?? fillValue(fill, node);
|
|
154
|
+
function paintPropValue(fill, node, profile = "srgb") {
|
|
155
|
+
return solidShorthand([fill], profile) ?? fillValue(fill, node, profile);
|
|
151
156
|
}
|
|
152
|
-
function collectFillProps(node, props) {
|
|
157
|
+
function collectFillProps(node, props, profile = "srgb") {
|
|
153
158
|
if (node.fills.length === 0) {
|
|
154
159
|
if (node.type === "TEXT") props.push(["fills", []]);
|
|
155
160
|
return;
|
|
156
161
|
}
|
|
157
|
-
const shorthand = solidShorthand(node.fills);
|
|
162
|
+
const shorthand = solidShorthand(node.fills, profile);
|
|
158
163
|
if (shorthand) props.push([node.type === "TEXT" ? "color" : "bg", shorthand]);
|
|
159
|
-
else props.push(["fills", node.fills.map((fill) => fillValue(fill, node))]);
|
|
164
|
+
else props.push(["fills", node.fills.map((fill) => fillValue(fill, node, profile))]);
|
|
160
165
|
}
|
|
161
|
-
function strokeValue(stroke) {
|
|
166
|
+
function strokeValue(stroke, profile) {
|
|
162
167
|
return {
|
|
163
|
-
color: formatColor(stroke.color, stroke.color.a),
|
|
168
|
+
color: formatColor(stroke.color, stroke.color.a, profile),
|
|
164
169
|
opacity: stroke.opacity === stroke.color.a ? void 0 : stroke.opacity,
|
|
165
170
|
weight: stroke.weight === 1 ? void 0 : stroke.weight,
|
|
166
171
|
align: stroke.align === "INSIDE" ? void 0 : STROKE_ALIGN.print(stroke.align),
|
|
@@ -189,8 +194,8 @@ function fitsStrokeShorthand(node, stroke) {
|
|
|
189
194
|
const nodeJoin = STROKE_JOIN.print(node.strokeJoin);
|
|
190
195
|
return (stroke.cap ?? nodeCap) === nodeCap && (stroke.join ?? nodeJoin) === nodeJoin;
|
|
191
196
|
}
|
|
192
|
-
function collectStrokeProps(node, props) {
|
|
193
|
-
const strokes = node.strokes.map(strokeValue);
|
|
197
|
+
function collectStrokeProps(node, props, profile = "srgb") {
|
|
198
|
+
const strokes = node.strokes.map((stroke) => strokeValue(stroke, profile));
|
|
194
199
|
const [only] = strokes;
|
|
195
200
|
if (strokes.length === 1 && fitsStrokeShorthand(node, only)) {
|
|
196
201
|
for (const [key, value] of Object.entries(only)) if (value !== void 0 && key !== "cap" && key !== "join") props.push([STROKE_SHORTHAND[key], value]);
|
|
@@ -210,50 +215,82 @@ const EFFECT_HELPERS = {
|
|
|
210
215
|
INNER_SHADOW: "innerShadow",
|
|
211
216
|
LAYER_BLUR: "layerBlur",
|
|
212
217
|
BACKGROUND_BLUR: "backgroundBlur",
|
|
213
|
-
FOREGROUND_BLUR: "foregroundBlur"
|
|
218
|
+
FOREGROUND_BLUR: "foregroundBlur",
|
|
219
|
+
NOISE: "noise",
|
|
220
|
+
TEXTURE: "texture"
|
|
214
221
|
};
|
|
215
|
-
|
|
222
|
+
/** A grain size as one number when both axes match, as Figma's plugin API writes it. */
|
|
223
|
+
function noiseSizeValue(size) {
|
|
224
|
+
return size.x === size.y ? size.x : {
|
|
225
|
+
x: size.x,
|
|
226
|
+
y: size.y
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
function effectValue(effect, profile) {
|
|
216
230
|
const visible = effect.visible ? void 0 : false;
|
|
217
231
|
if (effect.type === "DROP_SHADOW" || effect.type === "INNER_SHADOW") return helperCall(EFFECT_HELPERS[effect.type], options({
|
|
218
232
|
x: effect.offset.x,
|
|
219
233
|
y: effect.offset.y,
|
|
220
234
|
radius: effect.radius,
|
|
221
235
|
spread: effect.spread === 0 ? void 0 : effect.spread,
|
|
222
|
-
color: formatColor(effect.color, effect.color.a),
|
|
236
|
+
color: formatColor(effect.color, effect.color.a, profile),
|
|
223
237
|
visible,
|
|
224
238
|
blendMode: blendMode(effect.blendMode),
|
|
225
239
|
showShadowBehindNode: effect.showShadowBehindNode
|
|
226
240
|
}));
|
|
241
|
+
if (effect.type === "NOISE") {
|
|
242
|
+
const grain = effect.noise;
|
|
243
|
+
return helperCall(EFFECT_HELPERS.NOISE, options({
|
|
244
|
+
noiseType: grain.noiseType,
|
|
245
|
+
noiseSize: noiseSizeValue(grain.noiseSize),
|
|
246
|
+
density: grain.density,
|
|
247
|
+
color: formatColor(effect.color, effect.color.a, profile),
|
|
248
|
+
secondaryColor: grain.secondaryColor ? formatColor(grain.secondaryColor, grain.secondaryColor.a, profile) : void 0,
|
|
249
|
+
opacity: grain.opacity,
|
|
250
|
+
seed: grain.seed,
|
|
251
|
+
visible
|
|
252
|
+
}));
|
|
253
|
+
}
|
|
254
|
+
if (effect.type === "TEXTURE") {
|
|
255
|
+
const grain = effect.texture;
|
|
256
|
+
return helperCall(EFFECT_HELPERS.TEXTURE, options({
|
|
257
|
+
noiseSize: noiseSizeValue(grain.noiseSize),
|
|
258
|
+
radius: effect.radius,
|
|
259
|
+
clipToShape: grain.clipToShape,
|
|
260
|
+
seed: grain.seed,
|
|
261
|
+
visible
|
|
262
|
+
}));
|
|
263
|
+
}
|
|
227
264
|
return helperCall(EFFECT_HELPERS[effect.type], visible === void 0 ? effect.radius : {
|
|
228
265
|
radius: effect.radius,
|
|
229
266
|
visible
|
|
230
267
|
});
|
|
231
268
|
}
|
|
232
|
-
function plainDropShadow(effect) {
|
|
233
|
-
return effect.type === "DROP_SHADOW" && effect.spread === 0 && !blendMode(effect.blendMode) && effect.showShadowBehindNode === void 0 ? formatShadow(effect) : null;
|
|
269
|
+
function plainDropShadow(effect, profile) {
|
|
270
|
+
return effect.type === "DROP_SHADOW" && effect.spread === 0 && !blendMode(effect.blendMode) && effect.showShadowBehindNode === void 0 ? formatShadow(effect, profile) : null;
|
|
234
271
|
}
|
|
235
272
|
/**
|
|
236
273
|
* `shadow` and `blur` describe a plain drop shadow followed by a layer blur, each optional,
|
|
237
274
|
* in the order the renderer appends them; anything else needs `effects`.
|
|
238
275
|
*/
|
|
239
|
-
function effectShorthand(effects) {
|
|
276
|
+
function effectShorthand(effects, profile) {
|
|
240
277
|
if (effects.some((effect) => !effect.visible)) return null;
|
|
241
|
-
const shadow = effects.length > 0 ? plainDropShadow(effects[0]) : null;
|
|
278
|
+
const shadow = effects.length > 0 ? plainDropShadow(effects[0], profile) : null;
|
|
242
279
|
const rest = shadow ? effects.slice(1) : effects;
|
|
243
280
|
if (rest.length > 1 || rest.some((effect) => effect.type !== "LAYER_BLUR")) return null;
|
|
244
281
|
const props = [];
|
|
245
282
|
if (shadow) props.push(["shadow", shadow]);
|
|
246
|
-
for (const blur of rest) props.push(["blur", blur.radius]);
|
|
283
|
+
for (const blur of rest) if (blur.type === "LAYER_BLUR") props.push(["blur", blur.radius]);
|
|
247
284
|
return props;
|
|
248
285
|
}
|
|
249
|
-
/** An effect JSX has a helper for;
|
|
286
|
+
/** An effect JSX has a helper for; a shader effect is not written back as JSX source. */
|
|
250
287
|
function hasJSXHelper(effect) {
|
|
251
|
-
return Object.hasOwn(EFFECT_HELPERS, effect.type);
|
|
288
|
+
return effect.type !== "SHADER" && Object.hasOwn(EFFECT_HELPERS, effect.type);
|
|
252
289
|
}
|
|
253
|
-
function collectEffectProps(node, props) {
|
|
290
|
+
function collectEffectProps(node, props, profile = "srgb") {
|
|
254
291
|
const effects = node.effects.filter(hasJSXHelper);
|
|
255
292
|
if (effects.length === 0) return;
|
|
256
|
-
props.push(...effectShorthand(effects) ?? [["effects", effects.map(effectValue)]]);
|
|
293
|
+
props.push(...effectShorthand(effects, profile) ?? [["effects", effects.map((effect) => effectValue(effect, profile))]]);
|
|
257
294
|
}
|
|
258
295
|
//#endregion
|
|
259
296
|
//#region src/figjam-text.ts
|
|
@@ -309,8 +346,8 @@ function shapeWithTextProps(graph, node) {
|
|
|
309
346
|
if (height !== SHAPE_WITH_TEXT_SIZE) props.push(["h", height]);
|
|
310
347
|
if (node.shapeTruncates) props.push(["truncate", true]);
|
|
311
348
|
if (node.rotation !== 0) props.push(["rotate", Math.round(node.rotation * 100) / 100]);
|
|
312
|
-
collectFillProps(node, props);
|
|
313
|
-
collectStrokeProps(node, props);
|
|
349
|
+
collectFillProps(node, props, graph.documentColorSpace);
|
|
350
|
+
collectStrokeProps(node, props, graph.documentColorSpace);
|
|
314
351
|
if (node.cornerRadius !== SHAPE_WITH_TEXT_CORNER_RADIUS) props.push(["rounded", node.cornerRadius]);
|
|
315
352
|
return props;
|
|
316
353
|
}
|
|
@@ -458,7 +495,7 @@ const DESIGN_JSX_ELEMENTS = [
|
|
|
458
495
|
runtimeType: "vector",
|
|
459
496
|
description: "A vector layer.",
|
|
460
497
|
nodeType: "VECTOR",
|
|
461
|
-
writes: ["VECTOR"]
|
|
498
|
+
writes: ["VECTOR", "BOOLEAN_OPERATION"]
|
|
462
499
|
},
|
|
463
500
|
{
|
|
464
501
|
name: "Group",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"elements.js","names":[],"sources":["../../src/export/helpers.ts","../../src/export/paint.ts","../../src/figjam-text.ts","../../src/shapes-with-text.ts","../../src/stickies.ts","../../src/elements.ts"],"sourcesContent":["import type { SceneGraph, SceneNode, Effect, GridTrack } from '@pairdraw/scene-graph'\nimport { colorToHex8 } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nexport function formatColor(color: Color, opacity = 1): string {\n return colorToHex8(color, opacity)\n}\n\nexport function formatShadow(e: Effect): string | null {\n if (e.type !== 'DROP_SHADOW' && e.type !== 'INNER_SHADOW') return null\n return `${e.offset.x} ${e.offset.y} ${e.radius} ${formatColor(e.color, e.color.a)}`\n}\n\nexport function getNodeContext(node: SceneNode, graph: SceneGraph) {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n return {\n isAutoLayout: node.layoutMode !== 'NONE',\n isGrid: node.layoutMode === 'GRID',\n isFlex: node.layoutMode === 'HORIZONTAL' || node.layoutMode === 'VERTICAL',\n parentIsAutoLayout: parent ? parent.layoutMode !== 'NONE' : false,\n parentIsGrid: parent ? parent.layoutMode === 'GRID' : false\n }\n}\n\nexport type PaddingEdges = { pt: number; pr: number; pb: number; pl: number }\n\nexport function collectPadding(node: SceneNode): PaddingEdges | null {\n const { paddingTop: pt, paddingRight: pr, paddingBottom: pb, paddingLeft: pl } = node\n if (pt === 0 && pr === 0 && pb === 0 && pl === 0) return null\n return { pt, pr, pb, pl }\n}\n\nexport function emitPadding<T>(\n edges: PaddingEdges,\n uniform: (v: number) => T,\n symmetric: (y: number, x: number) => T[],\n individual: (edges: PaddingEdges) => T[]\n): T[] {\n const { pt, pr, pb, pl } = edges\n if (pt === pr && pr === pb && pb === pl) return [uniform(pt)]\n if (pt === pb && pl === pr) return symmetric(pt, pl)\n return individual(edges)\n}\n\nexport interface CornerRadii {\n tl: number\n tr: number\n br: number\n bl: number\n}\n\nexport function collectCornerRadii(node: SceneNode): CornerRadii | null {\n if (node.independentCorners) {\n const corners = {\n tl: node.topLeftRadius,\n tr: node.topRightRadius,\n br: node.bottomRightRadius,\n bl: node.bottomLeftRadius\n }\n return Object.values(corners).some((radius) => radius > 0) ? corners : null\n }\n if (node.cornerRadius <= 0) return null\n const r = node.cornerRadius\n return { tl: r, tr: r, br: r, bl: r }\n}\n\nfunction formatTrack(t: GridTrack): string {\n if (t.sizing === 'FR') return `${t.value}fr`\n if (t.sizing === 'FIXED') return `${t.value}px`\n return 'auto'\n}\n\nexport function formatTracks(tracks: GridTrack[]): string {\n return tracks.map(formatTrack).join(' ')\n}\n","import type {\n Effect,\n Fill,\n GradientTransform,\n SceneNode,\n ShadowEffect,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { gradientTransformRows, isIdentityGradientTransform } from '@pairdraw/scene-graph/gradient'\nimport { isShaderPresetPaint, shaderOfPaint } from '@pairdraw/scene-graph/shaders'\n\nimport { STROKE_ALIGN, STROKE_CAP, STROKE_JOIN } from '../enums'\nimport { formatColor, formatShadow } from './helpers'\nimport { helperCall, plainValue, type HelperCall, type JSXProp, type JSXValue } from './value'\n\nconst GRADIENT_HELPERS: Partial<Record<Fill['type'], string>> = {\n GRADIENT_LINEAR: 'linearGradient',\n GRADIENT_RADIAL: 'radialGradient',\n GRADIENT_ANGULAR: 'angularGradient',\n GRADIENT_DIAMOND: 'diamondGradient'\n}\n\nfunction isIdentity(transform: GradientTransform | undefined): boolean {\n return !transform || isIdentityGradientTransform(transform)\n}\n\n/** A paint transform as authors write it, in Figma's rows. */\nfunction rows(transform: GradientTransform | undefined) {\n return transform && gradientTransformRows(transform)\n}\n\n/** Paints and effects imported from Figma often spell out the default blend mode. */\nfunction blendMode(mode: Fill['blendMode']): Fill['blendMode'] {\n return mode === 'NORMAL' || mode === 'PASS_THROUGH' ? undefined : mode\n}\n\ntype Options = Record<string, JSXValue | undefined>\n\n/** Helper options with defaults left out, or `undefined` when none differ. */\nfunction options(entries: Options): Options | undefined {\n return Object.values(entries).some((value) => value !== undefined) ? entries : undefined\n}\n\nfunction fillValue(fill: Fill, node: SceneNode): JSXValue {\n const visible = fill.visible ? undefined : false\n const shader = shaderOfPaint(node, fill)\n if (shader && isShaderPresetPaint(shader)) {\n // A preset with nothing but effects is written as just its effects.\n const { components, ...rest } = shader.preset\n return helperCall(\n 'shader',\n plainValue(Object.keys(rest).length === 0 ? components : shader.preset),\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n // Code the user wrote comes back as the same paint only through its own helper.\n if (shader) {\n const uniforms = shader.uniforms ?? {}\n return helperCall(\n 'shaderSource',\n shader.source,\n options({\n uniforms: Object.keys(uniforms).length === 0 ? undefined : plainValue(uniforms),\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n if (fill.type === 'SOLID') {\n const color = formatColor(fill.color, fill.color.a)\n const opacity = fill.opacity === fill.color.a ? undefined : fill.opacity\n return helperCall(\n 'solid',\n color,\n options({ opacity, visible, blendMode: blendMode(fill.blendMode) })\n )\n }\n const helper = GRADIENT_HELPERS[fill.type]\n if (helper && fill.gradientStops) {\n const stops = fill.gradientStops.map((stop) => [\n formatColor(stop.color, stop.color.a),\n stop.position\n ])\n return helperCall(\n helper,\n stops,\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode),\n transform: isIdentity(fill.gradientTransform)\n ? undefined\n : plainValue(rows(fill.gradientTransform))\n })\n )\n }\n // Image, pattern, and other paints have no helper; they render back from their fields.\n return plainValue({\n ...fill,\n gradientTransform: rows(fill.gradientTransform),\n imageTransform: rows(fill.imageTransform)\n })\n}\n\n/** A single visible solid paint fits the `bg` or text `color` shorthand. */\nfunction solidShorthand(fills: Fill[]): string | null {\n if (fills.length !== 1) return null\n const [fill] = fills\n if (fill.type !== 'SOLID' || !fill.visible || blendMode(fill.blendMode)) return null\n // The shorthand has one alpha; a fill whose opacity differs from its colour's needs `solid`.\n if (fill.opacity !== fill.color.a) return null\n return formatColor(fill.color, fill.color.a)\n}\n\n/** One paint as a colour prop takes it: a colour string when it is plain, its helper otherwise. */\nexport function paintPropValue(fill: Fill, node: SceneNode): JSXValue {\n return solidShorthand([fill]) ?? fillValue(fill, node)\n}\n\nexport function collectFillProps(node: SceneNode, props: JSXProp[]): void {\n if (node.fills.length === 0) {\n // A text is painted black unless it says it is not painted.\n if (node.type === 'TEXT') props.push(['fills', []])\n return\n }\n const shorthand = solidShorthand(node.fills)\n if (shorthand) props.push([node.type === 'TEXT' ? 'color' : 'bg', shorthand])\n else props.push(['fills', node.fills.map((fill) => fillValue(fill, node))])\n}\n\ninterface StrokeValue {\n [key: string]: JSXValue | undefined\n color: string\n /** Only when it differs from the colour's alpha, which the colour already carries. */\n opacity?: number\n weight?: number\n align?: string\n dash?: number[]\n cap?: string\n join?: string\n visible?: false\n}\n\nfunction strokeValue(stroke: Stroke): StrokeValue {\n return {\n color: formatColor(stroke.color, stroke.color.a),\n opacity: stroke.opacity === stroke.color.a ? undefined : stroke.opacity,\n weight: stroke.weight === 1 ? undefined : stroke.weight,\n align: stroke.align === 'INSIDE' ? undefined : STROKE_ALIGN.print(stroke.align),\n dash: stroke.dashPattern && stroke.dashPattern.length > 0 ? [...stroke.dashPattern] : undefined,\n cap: stroke.cap && STROKE_CAP.print(stroke.cap),\n join: stroke.join && STROKE_JOIN.print(stroke.join),\n visible: stroke.visible ? undefined : false\n }\n}\n\nconst STROKE_SHORTHAND: Record<string, string> = {\n color: 'stroke',\n weight: 'strokeWidth',\n align: 'strokeAlign',\n dash: 'strokeDash'\n}\n\n/** Node-level cap and join apply to strokes that do not set their own. */\nconst DEFAULT_STROKE_CAP = 'NONE'\nconst DEFAULT_STROKE_JOIN = 'MITER'\n\n/**\n * The shorthand props describe one stroke, and `strokeCap`/`strokeJoin` also set the node's\n * cap and join; they fit only when the stroke agrees with the node on both.\n */\nfunction fitsStrokeShorthand(node: SceneNode, stroke: StrokeValue): boolean {\n if (stroke.visible !== undefined || stroke.opacity !== undefined) return false\n const nodeCap = STROKE_CAP.print(node.strokeCap)\n const nodeJoin = STROKE_JOIN.print(node.strokeJoin)\n return (stroke.cap ?? nodeCap) === nodeCap && (stroke.join ?? nodeJoin) === nodeJoin\n}\n\nexport function collectStrokeProps(node: SceneNode, props: JSXProp[]): void {\n const strokes = node.strokes.map(strokeValue)\n const [only] = strokes\n const shorthand = strokes.length === 1 && fitsStrokeShorthand(node, only)\n if (shorthand) {\n for (const [key, value] of Object.entries(only)) {\n if (value !== undefined && key !== 'cap' && key !== 'join') {\n props.push([STROKE_SHORTHAND[key], value])\n }\n }\n } else if (strokes.length > 0) {\n props.push(['strokes', strokes])\n }\n if (node.strokeCap !== DEFAULT_STROKE_CAP)\n props.push(['strokeCap', STROKE_CAP.print(node.strokeCap)])\n if (node.strokeJoin !== DEFAULT_STROKE_JOIN) {\n props.push(['strokeJoin', STROKE_JOIN.print(node.strokeJoin)])\n }\n // With strokes, each stroke's own dash says it; the layer's follows the first.\n if (node.strokes.length === 0 && node.dashPattern.length > 0)\n props.push(['dashPattern', [...node.dashPattern]])\n if (node.independentStrokeWeights) {\n props.push([\n 'strokeWeights',\n {\n top: node.borderTopWeight,\n right: node.borderRightWeight,\n bottom: node.borderBottomWeight,\n left: node.borderLeftWeight\n }\n ])\n }\n}\n\nconst EFFECT_HELPERS: Record<ShadowEffect['type'], string> = {\n DROP_SHADOW: 'dropShadow',\n INNER_SHADOW: 'innerShadow',\n LAYER_BLUR: 'layerBlur',\n BACKGROUND_BLUR: 'backgroundBlur',\n FOREGROUND_BLUR: 'foregroundBlur'\n}\n\nfunction effectValue(effect: ShadowEffect): HelperCall {\n const visible = effect.visible ? undefined : false\n if (effect.type === 'DROP_SHADOW' || effect.type === 'INNER_SHADOW') {\n return helperCall(\n EFFECT_HELPERS[effect.type],\n options({\n x: effect.offset.x,\n y: effect.offset.y,\n radius: effect.radius,\n spread: effect.spread === 0 ? undefined : effect.spread,\n color: formatColor(effect.color, effect.color.a),\n visible,\n blendMode: blendMode(effect.blendMode),\n showShadowBehindNode: effect.showShadowBehindNode\n })\n )\n }\n return helperCall(\n EFFECT_HELPERS[effect.type],\n visible === undefined ? effect.radius : { radius: effect.radius, visible }\n )\n}\n\nfunction plainDropShadow(effect: Effect): string | null {\n const plain =\n effect.type === 'DROP_SHADOW' &&\n effect.spread === 0 &&\n !blendMode(effect.blendMode) &&\n effect.showShadowBehindNode === undefined\n return plain ? formatShadow(effect) : null\n}\n\n/**\n * `shadow` and `blur` describe a plain drop shadow followed by a layer blur, each optional,\n * in the order the renderer appends them; anything else needs `effects`.\n */\nfunction effectShorthand(effects: ShadowEffect[]): JSXProp[] | null {\n if (effects.some((effect) => !effect.visible)) return null\n const shadow = effects.length > 0 ? plainDropShadow(effects[0]) : null\n const rest = shadow ? effects.slice(1) : effects\n if (rest.length > 1 || rest.some((effect) => effect.type !== 'LAYER_BLUR')) return null\n const props: JSXProp[] = []\n if (shadow) props.push(['shadow', shadow])\n for (const blur of rest) props.push(['blur', blur.radius])\n return props\n}\n\n/** An effect JSX has a helper for; an imported one the modeller lacks, such as noise, has none. */\nfunction hasJSXHelper(effect: Effect): effect is ShadowEffect {\n return Object.hasOwn(EFFECT_HELPERS, effect.type)\n}\n\nexport function collectEffectProps(node: SceneNode, props: JSXProp[]): void {\n // An effect without a helper cannot be written as JSX; leaving it out keeps the source importable.\n const effects = node.effects.filter(hasJSXHelper)\n if (effects.length === 0) return\n props.push(...(effectShorthand(effects) ?? [['effects', effects.map(effectValue)]]))\n}\n","import type { SceneNode } from '@pairdraw/scene-graph'\nimport {\n figJamTextSize,\n figJamTextSizeFields,\n figJamTypeface,\n figJamTypefaceFields,\n type FigJamTextSize,\n type FigJamTypeface\n} from '@pairdraw/scene-graph/figjam'\n\nimport { FIGJAM_TEXT_SIZE, FIGJAM_TYPEFACE } from './enums'\n\n/**\n * The fields a sticky note's body or a shape's label takes from `textSize` and `typeface`, as\n * FigJam's text menus set them; the typeface keeps the size the text ends up at.\n */\nexport function figJamTextFields(\n text: Pick<SceneNode, 'fontSize'>,\n textSize: FigJamTextSize | undefined,\n typeface: FigJamTypeface | undefined\n): Partial<SceneNode> {\n const sized = textSize ? figJamTextSizeFields(textSize, typeface) : {}\n if (!typeface) return sized\n return figJamTypefaceFields(typeface, { fontSize: sized.fontSize ?? text.fontSize })\n}\n\n/** `textSize` and `typeface` as an element writes them, each left out at FigJam's default. */\nexport function figJamTextProps(\n text: Pick<SceneNode, 'fontSize' | 'fontFamily'>\n): Array<[string, string]> {\n const props: Array<[string, string]> = []\n const size = figJamTextSize(text)\n if (size !== 'small') props.push(['textSize', FIGJAM_TEXT_SIZE.print(size)])\n const typeface = figJamTypeface(text)\n if (typeface && typeface !== 'simple') props.push(['typeface', FIGJAM_TYPEFACE.print(typeface)])\n return props\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n createShapeWithText,\n SHAPE_WITH_TEXT_CORNER_RADIUS,\n SHAPE_WITH_TEXT_SIZE,\n shapeWithTextLabel\n} from '@pairdraw/scene-graph/generated'\n\nimport { SHAPE_KIND } from './enums'\nimport { collectFillProps, collectStrokeProps } from './export/paint'\nimport type { JSXProp } from './export/value'\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, shapePropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The shape an element describes, with `layer`'s fields; it is named by its label, as FigJam\n * names a shape, until given a name.\n */\nexport function renderShapeNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(shapePropsSchema, tree.props)\n const text = plainTextOf(tree)\n const shape = createShapeWithText(\n graph,\n parentId,\n {\n ...layer,\n name: layer.name ?? (text.trim() || 'Shape with text'),\n autoRename: !layer.name,\n shapeWithTextType: props.kind ?? 'SQUARE',\n shapeTruncates: props.truncate ?? false\n },\n { text }\n )\n const label = shapeWithTextLabel(graph, shape)\n if (label) graph.updateNode(label.id, figJamTextFields(label, props.textSize, props.typeface))\n return shape\n}\n\n/**\n * A shape's own props as `<Shape>` writes them, after its name and position: the height it was\n * given rather than the height its label grew it to, so it grows the same way when read back.\n */\nexport function shapeWithTextProps(graph: SceneGraph, node: SceneNode): JSXProp[] {\n const props: JSXProp[] = []\n if (node.shapeWithTextType !== 'SQUARE') {\n props.push(['kind', SHAPE_KIND.print(node.shapeWithTextType)])\n }\n const label = shapeWithTextLabel(graph, node)\n if (label) props.push(...figJamTextProps(label))\n // A truncating shape keeps the height it has; any other grows from the height it was given.\n const height =\n !node.shapeTruncates && node.shapeUserHeight > 0 ? node.shapeUserHeight : node.height\n if (node.width !== SHAPE_WITH_TEXT_SIZE) props.push(['w', node.width])\n if (height !== SHAPE_WITH_TEXT_SIZE) props.push(['h', height])\n if (node.shapeTruncates) props.push(['truncate', true])\n if (node.rotation !== 0) props.push(['rotate', Math.round(node.rotation * 100) / 100])\n collectFillProps(node, props)\n collectStrokeProps(node, props)\n if (node.cornerRadius !== SHAPE_WITH_TEXT_CORNER_RADIUS)\n props.push(['rounded', node.cornerRadius])\n return props\n}\n\n/** The label a shape writes as its children. */\nexport function shapeWithTextLabelText(graph: SceneGraph, node: SceneNode): string {\n return shapeWithTextLabel(graph, node)?.text ?? ''\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport {\n createSticky,\n isWideSticky,\n STICKY_COLORS,\n stickyScale,\n stickySublayers\n} from '@pairdraw/scene-graph/generated'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, stickyPropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The note an element describes, with `layer`'s fields; it is named by its body, as FigJam names\n * a note, until given a name.\n */\nexport function renderStickyNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(stickyPropsSchema, tree.props)\n const text = plainTextOf(tree)\n const author = props.author ?? ''\n const sticky = createSticky(\n graph,\n parentId,\n {\n text,\n author,\n authorVisible: props.authorVisible !== false && author !== '',\n color: props.color,\n wide: props.wide === true,\n scale: props.scale ?? 1\n },\n { ...layer, name: layer.name ?? (text.trim() || 'Sticky'), autoRename: !layer.name }\n )\n const body = stickySublayers(graph, sticky)?.body\n if (body) graph.updateNode(body.id, figJamTextFields(body, props.textSize, props.typeface))\n return sticky\n}\n\n/** The colour as `<Sticky>` writes it: its palette name, or a hex colour off the palette. */\nfunction colorName(color: Color): string {\n const hex = colorToHex(color)\n const named = Object.entries(STICKY_COLORS).find(([, value]) => colorToHex(value) === hex)\n return named ? named[0] : hex\n}\n\n/** A note's own props as `<Sticky>` writes them, after its name and position. */\nexport function stickyProps(graph: SceneGraph, node: SceneNode): Array<[string, unknown]> {\n const layers = stickySublayers(graph, node)\n const color = node.fills.at(0)?.color\n const props: Array<[string, unknown]> = []\n if (color) props.push(['color', colorName(color)])\n if (layers?.author.text) props.push(['author', layers.author.text])\n if (layers?.author.text && !layers.author.visible) props.push(['authorVisible', false])\n if (isWideSticky(graph, node)) props.push(['wide', true])\n if (layers) props.push(...figJamTextProps(layers.body))\n const scale = layers ? stickyScale(layers.author) : 1\n if (scale !== 1) props.push(['scale', scale])\n return props\n}\n\n/** The body a note writes as its children. */\nexport function stickyBody(graph: SceneGraph, node: SceneNode): string {\n return stickySublayers(graph, node)?.body.text ?? ''\n}\n","import { difference } from 'es-toolkit/array'\n\nimport type { NodeType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { REKA_ELEMENTS, rekaRole } from './behaviours'\nimport { connectorBindingTarget, renderConnectorNode } from './connectors'\nimport {\n DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES,\n DESIGN_JSX_SPAN_PROPERTY_NAMES,\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES\n} from './definitions'\nimport {\n connectorPropsSchema,\n ownLayerPropsSchema,\n placedOwnLayerPropsSchema,\n shapeLayerPropsSchema,\n shapePropsSchema,\n stickyPropsSchema,\n type ElementPropsSchema\n} from './schema'\nimport { renderShapeNode } from './shapes-with-text'\nimport { renderStickyNode } from './stickies'\nimport type { TreeNode } from './tree'\n\n/** How an element that draws a layer of its own, such as a sticky note, renders it. */\nexport interface OwnLayerRenderer {\n /** The layer props it takes, made into fields as any layer's are. */\n layer: ElementPropsSchema\n render(graph: SceneGraph, tree: TreeNode, parentId: string, layer: Partial<SceneNode>): SceneNode\n /** The layer a variable binding of `field` goes on, when not the element's own. */\n bindingTarget?(graph: SceneGraph, node: SceneNode, field: string): string\n}\n\n/**\n * One design JSX element: what JSX names it, what it makes, the props it takes, and which layers\n * export writes as it. The renderer, the export, the prop checks, the streaming preview, and the\n * authoring reference all read this list rather than keeping their own.\n */\nexport type DesignJSXElementDefinition = {\n name: string\n /** The type its tree nodes carry, such as `frame`. */\n runtimeType: string\n description: string\n /** The layer a plain element makes; an element rendered its own way, such as `Icon`, has none. */\n nodeType?: NodeType\n /** The props it takes; every layer prop when left out. */\n props?: readonly string[]\n /** The props it takes and what each holds, for an element that reads them by this schema. */\n schema?: ElementPropsSchema\n /** How it draws its own layer, for an element that does. */\n ownLayer?: OwnLayerRenderer\n /** The layers export writes as this element. */\n writes?: readonly NodeType[]\n}\n\nfunction rekaDescription(namespace: string, part: string): string {\n const role = rekaRole(`${namespace}.${part}`)\n if (role?.role === 'root')\n return `A main component that behaves as Reka UI's ${namespace} ${part}.`\n if (role?.role === 'input') return `The text layer of a ${namespace}'s text property.`\n return `The ${namespace} ${part}, drawn by a slot of its component.`\n}\n\n/** A Reka UI element as the element list describes it. */\nfunction rekaElementDefinitions(): DesignJSXElementDefinition[] {\n return Object.entries(REKA_ELEMENTS).flatMap(([namespace, parts]) =>\n Object.keys(parts).map((part) => {\n const type = `${namespace}.${part}`\n return { name: type, runtimeType: type, description: rekaDescription(namespace, part) }\n })\n )\n}\n\nexport const DESIGN_JSX_ELEMENTS: DesignJSXElementDefinition[] = [\n {\n name: 'Frame',\n runtimeType: 'frame',\n description: 'A frame or auto-layout container.',\n nodeType: 'FRAME',\n // A set and an instance read back as frames: JSX cannot name what they come from.\n writes: ['FRAME', 'COMPONENT_SET', 'INSTANCE']\n },\n {\n name: 'Text',\n runtimeType: 'text',\n description: 'A text layer.',\n nodeType: 'TEXT',\n writes: ['TEXT']\n },\n {\n name: 'Span',\n runtimeType: 'text-span',\n description: 'Characters inside a Text, styled apart from the rest.',\n props: ['key', ...DESIGN_JSX_SPAN_PROPERTY_NAMES]\n },\n {\n name: 'Paragraph',\n runtimeType: 'text-paragraph',\n description: 'One paragraph of a Text, plain or a list item.',\n props: ['key', ...DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES]\n },\n {\n name: 'Rectangle',\n runtimeType: 'rectangle',\n description: 'A rectangle layer.',\n nodeType: 'RECTANGLE',\n writes: ['RECTANGLE', 'ROUNDED_RECTANGLE']\n },\n {\n name: 'Ellipse',\n runtimeType: 'ellipse',\n description: 'An ellipse layer.',\n nodeType: 'ELLIPSE',\n writes: ['ELLIPSE']\n },\n {\n name: 'Line',\n runtimeType: 'line',\n description: 'A line layer.',\n nodeType: 'LINE',\n writes: ['LINE']\n },\n {\n name: 'Star',\n runtimeType: 'star',\n description: 'A star layer.',\n nodeType: 'STAR',\n writes: ['STAR']\n },\n {\n name: 'Polygon',\n runtimeType: 'polygon',\n description: 'A polygon layer.',\n nodeType: 'POLYGON',\n writes: ['POLYGON']\n },\n {\n name: 'Vector',\n runtimeType: 'vector',\n description: 'A vector layer.',\n nodeType: 'VECTOR',\n writes: ['VECTOR']\n },\n {\n name: 'Group',\n runtimeType: 'group',\n description: 'A group of layers.',\n nodeType: 'GROUP',\n writes: ['GROUP']\n },\n {\n name: 'Section',\n runtimeType: 'section',\n description: 'A canvas section.',\n nodeType: 'SECTION',\n writes: ['SECTION']\n },\n {\n name: 'Component',\n runtimeType: 'component',\n description: 'A reusable component.',\n nodeType: 'COMPONENT',\n writes: ['COMPONENT']\n },\n {\n name: 'ComponentSet',\n runtimeType: 'component-set',\n description: 'A component variant set.',\n nodeType: 'COMPONENT_SET'\n },\n { name: 'Instance', runtimeType: 'instance', description: 'An instance of a component.' },\n { name: 'View', runtimeType: 'frame', description: 'An alias for Frame.', nodeType: 'FRAME' },\n {\n name: 'Rect',\n runtimeType: 'rectangle',\n description: 'An alias for Rectangle.',\n nodeType: 'RECTANGLE'\n },\n { name: 'Icon', runtimeType: 'icon', description: 'An Iconify icon.' },\n {\n name: 'Sticky',\n runtimeType: 'sticky',\n description: 'A FigJam sticky note; its text is the body.',\n schema: stickyPropsSchema,\n ownLayer: { layer: placedOwnLayerPropsSchema, render: renderStickyNode },\n writes: ['STICKY']\n },\n {\n name: 'Shape',\n runtimeType: 'shape',\n description: 'A FigJam shape with text; its text is the label.',\n schema: shapePropsSchema,\n ownLayer: { layer: shapeLayerPropsSchema, render: renderShapeNode },\n writes: ['SHAPE_WITH_TEXT']\n },\n {\n name: 'Connector',\n runtimeType: 'connector',\n description:\n 'A FigJam connector between two layers of the same JSX, named by `from` and `to`, or points.',\n schema: connectorPropsSchema,\n ownLayer: {\n layer: ownLayerPropsSchema,\n render: renderConnectorNode,\n bindingTarget: connectorBindingTarget\n },\n writes: ['CONNECTOR']\n },\n ...rekaElementDefinitions()\n]\n\n/** Props an inline `<svg>` takes besides a layer's: its markup's view box and body. */\nconst SVG_PROPERTY_NAMES = ['viewBox', 'body'] as const\n\n/**\n * Lowercase tags JSX also accepts, as HTML names them, with the layer each makes; they are\n * not written back.\n */\nconst INTRINSIC_ELEMENTS: Readonly<Record<string, NodeType | null>> = {\n componentset: 'COMPONENT_SET',\n div: 'FRAME',\n main: 'FRAME',\n header: 'FRAME',\n footer: 'FRAME',\n nav: 'FRAME',\n article: 'FRAME',\n aside: 'FRAME',\n span: 'TEXT',\n p: 'TEXT',\n h1: 'TEXT',\n h2: 'TEXT',\n h3: 'TEXT',\n h4: 'TEXT',\n h5: 'TEXT',\n h6: 'TEXT',\n // Inline SVG markup, which the artwork service draws.\n svg: null\n}\n\n/** Paragraph props describe a paragraph of a text, never a layer, unless a text sets them too. */\nconst LAYER_PROPS: ReadonlySet<string> = new Set<string>(\n difference(\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n difference(DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES, DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES)\n )\n)\n\nconst BY_RUNTIME_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.runtimeType,\n element\n ]).reverse()\n)\n\nconst PROPS_BY_RUNTIME_TYPE = new Map<string, ReadonlySet<string>>([\n ['svg', new Set([...LAYER_PROPS, ...SVG_PROPERTY_NAMES])],\n ...DESIGN_JSX_ELEMENTS.flatMap((element): [string, ReadonlySet<string>][] => {\n const props = element.schema ? Object.keys(element.schema.entries) : element.props\n return props ? [[element.runtimeType, new Set(props)]] : []\n })\n])\n\nconst TAG_BY_NODE_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.flatMap((element) =>\n (element.writes ?? []).map((type): [NodeType, string] => [type, element.name])\n )\n)\n\n/** The layer an element of `runtimeType` makes, for an element without its own renderer. */\nexport function elementNodeType(runtimeType: string): NodeType | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.nodeType ?? INTRINSIC_ELEMENTS[runtimeType] ?? undefined\n}\n\n/** The props an element of `runtimeType` takes. */\nexport function elementProps(runtimeType: string): ReadonlySet<string> {\n return PROPS_BY_RUNTIME_TYPE.get(runtimeType) ?? LAYER_PROPS\n}\n\nconst BY_NAME = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.name,\n element\n ])\n)\n\n/**\n * The props an element written `<name>` takes, as the renderer checks them, for an editor that\n * checks them as they are typed; null for a name that is no element, and for an instance, which\n * also takes its component's properties by name.\n */\nexport function elementPropsByName(name: string): ReadonlySet<string> | null {\n const element = BY_NAME.get(name)\n if (!element) return Object.hasOwn(INTRINSIC_ELEMENTS, name) ? elementProps(name) : null\n return element.runtimeType === 'instance' ? null : elementProps(element.runtimeType)\n}\n\n/** The schema an element of `runtimeType` reads its props by, if it has one. */\nexport function elementSchema(runtimeType: string): ElementPropsSchema | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.schema\n}\n\n/** How an element of `runtimeType` draws its own layer, if it does. */\nexport function elementOwnLayer(runtimeType: string): OwnLayerRenderer | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.ownLayer\n}\n\n/** The element export writes a layer of `type` as, if any. */\nexport function elementTag(type: NodeType): string | undefined {\n return TAG_BY_NODE_TYPE.get(type)\n}\n\n/**\n * `const Frame = 'frame', …`: the element names a JSX string's code can use, bound to their\n * runtime types. Reka UI elements, named `Switch.Root`, are bound by their namespaces.\n */\nexport function elementBindings(): string {\n return DESIGN_JSX_ELEMENTS.filter((element) => !element.name.includes('.'))\n .map((element) => `const ${element.name} = '${element.runtimeType}'`)\n .join('\\n')\n}\n"],"mappings":";;;;;;;;;;;AAIA,SAAgB,YAAY,OAAc,UAAU,GAAW;CAC7D,OAAO,YAAY,OAAO,OAAO;AACnC;AAEA,SAAgB,aAAa,GAA0B;CACrD,IAAI,EAAE,SAAS,iBAAiB,EAAE,SAAS,gBAAgB,OAAO;CAClE,OAAO,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC;AAClF;AAEA,SAAgB,eAAe,MAAiB,OAAmB;CACjE,MAAM,SAAS,KAAK,WAAW,MAAM,QAAQ,KAAK,QAAQ,IAAI;CAC9D,OAAO;EACL,cAAc,KAAK,eAAe;EAClC,QAAQ,KAAK,eAAe;EAC5B,QAAQ,KAAK,eAAe,gBAAgB,KAAK,eAAe;EAChE,oBAAoB,SAAS,OAAO,eAAe,SAAS;EAC5D,cAAc,SAAS,OAAO,eAAe,SAAS;CACxD;AACF;AAIA,SAAgB,eAAe,MAAsC;CACnE,MAAM,EAAE,YAAY,IAAI,cAAc,IAAI,eAAe,IAAI,aAAa,OAAO;CACjF,IAAI,OAAO,KAAK,OAAO,KAAK,OAAO,KAAK,OAAO,GAAG,OAAO;CACzD,OAAO;EAAE;EAAI;EAAI;EAAI;CAAG;AAC1B;AAEA,SAAgB,YACd,OACA,SACA,WACA,YACK;CACL,MAAM,EAAE,IAAI,IAAI,IAAI,OAAO;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oB,IAAI,IAAI,aAAa,IAAI,IAAI;CACpF,OAAO,QAAQ,gBAAgB,aAAa,OAAO,aAAa,QAAQ,WAAW;AACrF;;AAGA,SAAgB,cAAc,aAAqD;CACjF,OAAO,gBAAgB,IAAI,WAAW,CAAC,EAAE;AAC3C;;AAGA,SAAgB,gBAAgB,aAAmD;CACjF,OAAO,gBAAgB,IAAI,WAAW,CAAC,EAAE;AAC3C;;AAGA,SAAgB,WAAW,MAAoC;CAC7D,OAAO,iBAAiB,IAAI,IAAI;AAClC;;;;;AAMA,SAAgB,kBAA0B;CACxC,OAAO,oBAAoB,QAAQ,YAAY,CAAC,QAAQ,KAAK,SAAS,GAAG,CAAC,CAAC,CACxE,KAAK,YAAY,SAAS,QAAQ,KAAK,MAAM,QAAQ,YAAY,EAAE,CAAC,CACpE,KAAK,IAAI;AACd"}
|
|
1
|
+
{"version":3,"file":"elements.js","names":[],"sources":["../../src/export/helpers.ts","../../src/export/paint.ts","../../src/figjam-text.ts","../../src/shapes-with-text.ts","../../src/stickies.ts","../../src/elements.ts"],"sourcesContent":["import type { ColorProfile, SceneGraph, SceneNode, Effect, GridTrack } from '@pairdraw/scene-graph'\nimport { colorToDocumentCSS, colorToHex8 } from '@pairdraw/scene-graph/color'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\n/** A color as the JSX runtime reads it, in the document's profile, so a P3 color keeps its gamut. */\nexport function formatColor(color: Color, opacity = 1, profile: ColorProfile = 'srgb'): string {\n if (profile === 'srgb') return colorToHex8(color, opacity)\n return colorToDocumentCSS({ ...color, a: opacity }, profile)\n}\n\nexport function formatShadow(e: Effect, profile: ColorProfile = 'srgb'): string | null {\n if (e.type !== 'DROP_SHADOW' && e.type !== 'INNER_SHADOW') return null\n return `${e.offset.x} ${e.offset.y} ${e.radius} ${formatColor(e.color, e.color.a, profile)}`\n}\n\nexport function getNodeContext(node: SceneNode, graph: SceneGraph) {\n const parent = node.parentId ? graph.getNode(node.parentId) : null\n return {\n isAutoLayout: node.layoutMode !== 'NONE',\n isGrid: node.layoutMode === 'GRID',\n isFlex: node.layoutMode === 'HORIZONTAL' || node.layoutMode === 'VERTICAL',\n parentIsAutoLayout: parent ? parent.layoutMode !== 'NONE' : false,\n parentIsGrid: parent ? parent.layoutMode === 'GRID' : false\n }\n}\n\nexport type PaddingEdges = { pt: number; pr: number; pb: number; pl: number }\n\nexport function collectPadding(node: SceneNode): PaddingEdges | null {\n const { paddingTop: pt, paddingRight: pr, paddingBottom: pb, paddingLeft: pl } = node\n if (pt === 0 && pr === 0 && pb === 0 && pl === 0) return null\n return { pt, pr, pb, pl }\n}\n\nexport function emitPadding<T>(\n edges: PaddingEdges,\n uniform: (v: number) => T,\n symmetric: (y: number, x: number) => T[],\n individual: (edges: PaddingEdges) => T[]\n): T[] {\n const { pt, pr, pb, pl } = edges\n if (pt === pr && pr === pb && pb === pl) return [uniform(pt)]\n if (pt === pb && pl === pr) return symmetric(pt, pl)\n return individual(edges)\n}\n\nexport interface CornerRadii {\n tl: number\n tr: number\n br: number\n bl: number\n}\n\nexport function collectCornerRadii(node: SceneNode): CornerRadii | null {\n if (node.independentCorners) {\n const corners = {\n tl: node.topLeftRadius,\n tr: node.topRightRadius,\n br: node.bottomRightRadius,\n bl: node.bottomLeftRadius\n }\n return Object.values(corners).some((radius) => radius > 0) ? corners : null\n }\n if (node.cornerRadius <= 0) return null\n const r = node.cornerRadius\n return { tl: r, tr: r, br: r, bl: r }\n}\n\nfunction formatTrack(t: GridTrack): string {\n if (t.sizing === 'FR') return `${t.value}fr`\n if (t.sizing === 'FIXED') return `${t.value}px`\n return 'auto'\n}\n\nexport function formatTracks(tracks: GridTrack[]): string {\n return tracks.map(formatTrack).join(' ')\n}\n","import type {\n ColorProfile,\n Effect,\n Fill,\n GradientTransform,\n SceneNode,\n ShaderEffect,\n Stroke\n} from '@pairdraw/scene-graph'\nimport { gradientTransformRows, isIdentityGradientTransform } from '@pairdraw/scene-graph/gradient'\nimport type { Vector } from '@pairdraw/scene-graph/primitives'\nimport { isShaderPresetPaint, shaderOfPaint } from '@pairdraw/scene-graph/shaders'\n\nimport { STROKE_ALIGN, STROKE_CAP, STROKE_JOIN } from '../enums'\nimport { formatColor, formatShadow } from './helpers'\nimport { helperCall, plainValue, type HelperCall, type JSXProp, type JSXValue } from './value'\n\nconst GRADIENT_HELPERS: Partial<Record<Fill['type'], string>> = {\n GRADIENT_LINEAR: 'linearGradient',\n GRADIENT_RADIAL: 'radialGradient',\n GRADIENT_ANGULAR: 'angularGradient',\n GRADIENT_DIAMOND: 'diamondGradient'\n}\n\nfunction isIdentity(transform: GradientTransform | undefined): boolean {\n return !transform || isIdentityGradientTransform(transform)\n}\n\n/** A paint transform as authors write it, in Figma's rows. */\nfunction rows(transform: GradientTransform | undefined) {\n return transform && gradientTransformRows(transform)\n}\n\n/** Paints and effects imported from Figma often spell out the default blend mode. */\nfunction blendMode(mode: Fill['blendMode']): Fill['blendMode'] {\n return mode === 'NORMAL' || mode === 'PASS_THROUGH' ? undefined : mode\n}\n\ntype Options = Record<string, JSXValue | undefined>\n\n/** Helper options with defaults left out, or `undefined` when none differ. */\nfunction options(entries: Options): Options | undefined {\n return Object.values(entries).some((value) => value !== undefined) ? entries : undefined\n}\n\nfunction fillValue(fill: Fill, node: SceneNode, profile: ColorProfile): JSXValue {\n const visible = fill.visible ? undefined : false\n const shader = shaderOfPaint(node, fill)\n if (shader && isShaderPresetPaint(shader)) {\n // A preset with nothing but effects is written as just its effects.\n const { components, ...rest } = shader.preset\n return helperCall(\n 'shader',\n plainValue(Object.keys(rest).length === 0 ? components : shader.preset),\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n // Code the user wrote comes back as the same paint only through its own helper.\n if (shader) {\n const uniforms = shader.uniforms ?? {}\n return helperCall(\n 'shaderSource',\n shader.source,\n options({\n uniforms: Object.keys(uniforms).length === 0 ? undefined : plainValue(uniforms),\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode)\n })\n )\n }\n if (fill.type === 'SOLID') {\n const color = formatColor(fill.color, fill.color.a, profile)\n const opacity = fill.opacity === fill.color.a ? undefined : fill.opacity\n return helperCall(\n 'solid',\n color,\n options({ opacity, visible, blendMode: blendMode(fill.blendMode) })\n )\n }\n const helper = GRADIENT_HELPERS[fill.type]\n if (helper && fill.gradientStops) {\n const stops = fill.gradientStops.map((stop) => [\n formatColor(stop.color, stop.color.a, profile),\n stop.position\n ])\n return helperCall(\n helper,\n stops,\n options({\n opacity: fill.opacity === 1 ? undefined : fill.opacity,\n visible,\n blendMode: blendMode(fill.blendMode),\n transform: isIdentity(fill.gradientTransform)\n ? undefined\n : plainValue(rows(fill.gradientTransform))\n })\n )\n }\n // Image, pattern, and other paints have no helper; they render back from their fields.\n return plainValue({\n ...fill,\n gradientTransform: rows(fill.gradientTransform),\n imageTransform: rows(fill.imageTransform)\n })\n}\n\n/** A single visible solid paint fits the `bg` or text `color` shorthand. */\nfunction solidShorthand(fills: Fill[], profile: ColorProfile): string | null {\n if (fills.length !== 1) return null\n const [fill] = fills\n if (fill.type !== 'SOLID' || !fill.visible || blendMode(fill.blendMode)) return null\n // The shorthand has one alpha; a fill whose opacity differs from its colour's needs `solid`.\n if (fill.opacity !== fill.color.a) return null\n return formatColor(fill.color, fill.color.a, profile)\n}\n\n/** One paint as a colour prop takes it: a colour string when it is plain, its helper otherwise. */\nexport function paintPropValue(\n fill: Fill,\n node: SceneNode,\n profile: ColorProfile = 'srgb'\n): JSXValue {\n return solidShorthand([fill], profile) ?? fillValue(fill, node, profile)\n}\n\nexport function collectFillProps(\n node: SceneNode,\n props: JSXProp[],\n profile: ColorProfile = 'srgb'\n): void {\n if (node.fills.length === 0) {\n // A text is painted black unless it says it is not painted.\n if (node.type === 'TEXT') props.push(['fills', []])\n return\n }\n const shorthand = solidShorthand(node.fills, profile)\n if (shorthand) props.push([node.type === 'TEXT' ? 'color' : 'bg', shorthand])\n else props.push(['fills', node.fills.map((fill) => fillValue(fill, node, profile))])\n}\n\ninterface StrokeValue {\n [key: string]: JSXValue | undefined\n color: string\n /** Only when it differs from the colour's alpha, which the colour already carries. */\n opacity?: number\n weight?: number\n align?: string\n dash?: number[]\n cap?: string\n join?: string\n visible?: false\n}\n\nfunction strokeValue(stroke: Stroke, profile: ColorProfile): StrokeValue {\n return {\n color: formatColor(stroke.color, stroke.color.a, profile),\n opacity: stroke.opacity === stroke.color.a ? undefined : stroke.opacity,\n weight: stroke.weight === 1 ? undefined : stroke.weight,\n align: stroke.align === 'INSIDE' ? undefined : STROKE_ALIGN.print(stroke.align),\n dash: stroke.dashPattern && stroke.dashPattern.length > 0 ? [...stroke.dashPattern] : undefined,\n cap: stroke.cap && STROKE_CAP.print(stroke.cap),\n join: stroke.join && STROKE_JOIN.print(stroke.join),\n visible: stroke.visible ? undefined : false\n }\n}\n\nconst STROKE_SHORTHAND: Record<string, string> = {\n color: 'stroke',\n weight: 'strokeWidth',\n align: 'strokeAlign',\n dash: 'strokeDash'\n}\n\n/** Node-level cap and join apply to strokes that do not set their own. */\nconst DEFAULT_STROKE_CAP = 'NONE'\nconst DEFAULT_STROKE_JOIN = 'MITER'\n\n/**\n * The shorthand props describe one stroke, and `strokeCap`/`strokeJoin` also set the node's\n * cap and join; they fit only when the stroke agrees with the node on both.\n */\nfunction fitsStrokeShorthand(node: SceneNode, stroke: StrokeValue): boolean {\n if (stroke.visible !== undefined || stroke.opacity !== undefined) return false\n const nodeCap = STROKE_CAP.print(node.strokeCap)\n const nodeJoin = STROKE_JOIN.print(node.strokeJoin)\n return (stroke.cap ?? nodeCap) === nodeCap && (stroke.join ?? nodeJoin) === nodeJoin\n}\n\nexport function collectStrokeProps(\n node: SceneNode,\n props: JSXProp[],\n profile: ColorProfile = 'srgb'\n): void {\n const strokes = node.strokes.map((stroke) => strokeValue(stroke, profile))\n const [only] = strokes\n const shorthand = strokes.length === 1 && fitsStrokeShorthand(node, only)\n if (shorthand) {\n for (const [key, value] of Object.entries(only)) {\n if (value !== undefined && key !== 'cap' && key !== 'join') {\n props.push([STROKE_SHORTHAND[key], value])\n }\n }\n } else if (strokes.length > 0) {\n props.push(['strokes', strokes])\n }\n if (node.strokeCap !== DEFAULT_STROKE_CAP)\n props.push(['strokeCap', STROKE_CAP.print(node.strokeCap)])\n if (node.strokeJoin !== DEFAULT_STROKE_JOIN) {\n props.push(['strokeJoin', STROKE_JOIN.print(node.strokeJoin)])\n }\n // With strokes, each stroke's own dash says it; the layer's follows the first.\n if (node.strokes.length === 0 && node.dashPattern.length > 0)\n props.push(['dashPattern', [...node.dashPattern]])\n if (node.independentStrokeWeights) {\n props.push([\n 'strokeWeights',\n {\n top: node.borderTopWeight,\n right: node.borderRightWeight,\n bottom: node.borderBottomWeight,\n left: node.borderLeftWeight\n }\n ])\n }\n}\n\nconst EFFECT_HELPERS: Record<Exclude<Effect['type'], 'SHADER'>, string> = {\n DROP_SHADOW: 'dropShadow',\n INNER_SHADOW: 'innerShadow',\n LAYER_BLUR: 'layerBlur',\n BACKGROUND_BLUR: 'backgroundBlur',\n FOREGROUND_BLUR: 'foregroundBlur',\n NOISE: 'noise',\n TEXTURE: 'texture'\n}\n\n/** A grain size as one number when both axes match, as Figma's plugin API writes it. */\nfunction noiseSizeValue(size: Vector): JSXValue {\n return size.x === size.y ? size.x : { x: size.x, y: size.y }\n}\n\nfunction effectValue(effect: Exclude<Effect, ShaderEffect>, profile: ColorProfile): HelperCall {\n const visible = effect.visible ? undefined : false\n if (effect.type === 'DROP_SHADOW' || effect.type === 'INNER_SHADOW') {\n return helperCall(\n EFFECT_HELPERS[effect.type],\n options({\n x: effect.offset.x,\n y: effect.offset.y,\n radius: effect.radius,\n spread: effect.spread === 0 ? undefined : effect.spread,\n color: formatColor(effect.color, effect.color.a, profile),\n visible,\n blendMode: blendMode(effect.blendMode),\n showShadowBehindNode: effect.showShadowBehindNode\n })\n )\n }\n if (effect.type === 'NOISE') {\n const grain = effect.noise\n return helperCall(\n EFFECT_HELPERS.NOISE,\n options({\n noiseType: grain.noiseType,\n noiseSize: noiseSizeValue(grain.noiseSize),\n density: grain.density,\n color: formatColor(effect.color, effect.color.a, profile),\n secondaryColor: grain.secondaryColor\n ? formatColor(grain.secondaryColor, grain.secondaryColor.a, profile)\n : undefined,\n opacity: grain.opacity,\n seed: grain.seed,\n visible\n })\n )\n }\n if (effect.type === 'TEXTURE') {\n const grain = effect.texture\n return helperCall(\n EFFECT_HELPERS.TEXTURE,\n options({\n noiseSize: noiseSizeValue(grain.noiseSize),\n radius: effect.radius,\n clipToShape: grain.clipToShape,\n seed: grain.seed,\n visible\n })\n )\n }\n return helperCall(\n EFFECT_HELPERS[effect.type],\n visible === undefined ? effect.radius : { radius: effect.radius, visible }\n )\n}\n\nfunction plainDropShadow(effect: Effect, profile: ColorProfile): string | null {\n const plain =\n effect.type === 'DROP_SHADOW' &&\n effect.spread === 0 &&\n !blendMode(effect.blendMode) &&\n effect.showShadowBehindNode === undefined\n return plain ? formatShadow(effect, profile) : null\n}\n\n/**\n * `shadow` and `blur` describe a plain drop shadow followed by a layer blur, each optional,\n * in the order the renderer appends them; anything else needs `effects`.\n */\nfunction effectShorthand(effects: Effect[], profile: ColorProfile): JSXProp[] | null {\n if (effects.some((effect) => !effect.visible)) return null\n const shadow = effects.length > 0 ? plainDropShadow(effects[0], profile) : null\n const rest = shadow ? effects.slice(1) : effects\n if (rest.length > 1 || rest.some((effect) => effect.type !== 'LAYER_BLUR')) return null\n const props: JSXProp[] = []\n if (shadow) props.push(['shadow', shadow])\n for (const blur of rest) {\n if (blur.type === 'LAYER_BLUR') props.push(['blur', blur.radius])\n }\n return props\n}\n\n/** An effect JSX has a helper for; a shader effect is not written back as JSX source. */\nfunction hasJSXHelper(effect: Effect): effect is Exclude<Effect, ShaderEffect> {\n return effect.type !== 'SHADER' && Object.hasOwn(EFFECT_HELPERS, effect.type)\n}\n\nexport function collectEffectProps(\n node: SceneNode,\n props: JSXProp[],\n profile: ColorProfile = 'srgb'\n): void {\n // An effect without a helper cannot be written as JSX; leaving it out keeps the source importable.\n const effects = node.effects.filter(hasJSXHelper)\n if (effects.length === 0) return\n props.push(\n ...(effectShorthand(effects, profile) ?? [\n ['effects', effects.map((effect) => effectValue(effect, profile))]\n ])\n )\n}\n","import type { SceneNode } from '@pairdraw/scene-graph'\nimport {\n figJamTextSize,\n figJamTextSizeFields,\n figJamTypeface,\n figJamTypefaceFields,\n type FigJamTextSize,\n type FigJamTypeface\n} from '@pairdraw/scene-graph/figjam'\n\nimport { FIGJAM_TEXT_SIZE, FIGJAM_TYPEFACE } from './enums'\n\n/**\n * The fields a sticky note's body or a shape's label takes from `textSize` and `typeface`, as\n * FigJam's text menus set them; the typeface keeps the size the text ends up at.\n */\nexport function figJamTextFields(\n text: Pick<SceneNode, 'fontSize'>,\n textSize: FigJamTextSize | undefined,\n typeface: FigJamTypeface | undefined\n): Partial<SceneNode> {\n const sized = textSize ? figJamTextSizeFields(textSize, typeface) : {}\n if (!typeface) return sized\n return figJamTypefaceFields(typeface, { fontSize: sized.fontSize ?? text.fontSize })\n}\n\n/** `textSize` and `typeface` as an element writes them, each left out at FigJam's default. */\nexport function figJamTextProps(\n text: Pick<SceneNode, 'fontSize' | 'fontFamily'>\n): Array<[string, string]> {\n const props: Array<[string, string]> = []\n const size = figJamTextSize(text)\n if (size !== 'small') props.push(['textSize', FIGJAM_TEXT_SIZE.print(size)])\n const typeface = figJamTypeface(text)\n if (typeface && typeface !== 'simple') props.push(['typeface', FIGJAM_TYPEFACE.print(typeface)])\n return props\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport {\n createShapeWithText,\n SHAPE_WITH_TEXT_CORNER_RADIUS,\n SHAPE_WITH_TEXT_SIZE,\n shapeWithTextLabel\n} from '@pairdraw/scene-graph/generated'\n\nimport { SHAPE_KIND } from './enums'\nimport { collectFillProps, collectStrokeProps } from './export/paint'\nimport type { JSXProp } from './export/value'\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, shapePropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The shape an element describes, with `layer`'s fields; it is named by its label, as FigJam\n * names a shape, until given a name.\n */\nexport function renderShapeNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(shapePropsSchema, tree.props)\n const text = plainTextOf(tree)\n const shape = createShapeWithText(\n graph,\n parentId,\n {\n ...layer,\n name: layer.name ?? (text.trim() || 'Shape with text'),\n autoRename: !layer.name,\n shapeWithTextType: props.kind ?? 'SQUARE',\n shapeTruncates: props.truncate ?? false\n },\n { text }\n )\n const label = shapeWithTextLabel(graph, shape)\n if (label) graph.updateNode(label.id, figJamTextFields(label, props.textSize, props.typeface))\n return shape\n}\n\n/**\n * A shape's own props as `<Shape>` writes them, after its name and position: the height it was\n * given rather than the height its label grew it to, so it grows the same way when read back.\n */\nexport function shapeWithTextProps(graph: SceneGraph, node: SceneNode): JSXProp[] {\n const props: JSXProp[] = []\n if (node.shapeWithTextType !== 'SQUARE') {\n props.push(['kind', SHAPE_KIND.print(node.shapeWithTextType)])\n }\n const label = shapeWithTextLabel(graph, node)\n if (label) props.push(...figJamTextProps(label))\n // A truncating shape keeps the height it has; any other grows from the height it was given.\n const height =\n !node.shapeTruncates && node.shapeUserHeight > 0 ? node.shapeUserHeight : node.height\n if (node.width !== SHAPE_WITH_TEXT_SIZE) props.push(['w', node.width])\n if (height !== SHAPE_WITH_TEXT_SIZE) props.push(['h', height])\n if (node.shapeTruncates) props.push(['truncate', true])\n if (node.rotation !== 0) props.push(['rotate', Math.round(node.rotation * 100) / 100])\n collectFillProps(node, props, graph.documentColorSpace)\n collectStrokeProps(node, props, graph.documentColorSpace)\n if (node.cornerRadius !== SHAPE_WITH_TEXT_CORNER_RADIUS)\n props.push(['rounded', node.cornerRadius])\n return props\n}\n\n/** The label a shape writes as its children. */\nexport function shapeWithTextLabelText(graph: SceneGraph, node: SceneNode): string {\n return shapeWithTextLabel(graph, node)?.text ?? ''\n}\n","import type { SceneGraph, SceneNode } from '@pairdraw/scene-graph'\nimport { colorToHex } from '@pairdraw/scene-graph/color'\nimport {\n createSticky,\n isWideSticky,\n STICKY_COLORS,\n stickyScale,\n stickySublayers\n} from '@pairdraw/scene-graph/generated'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\n\nimport { figJamTextFields, figJamTextProps } from './figjam-text'\nimport { readElementProps, stickyPropsSchema } from './schema'\nimport { plainTextOf, type TreeNode } from './tree'\n\n/**\n * The note an element describes, with `layer`'s fields; it is named by its body, as FigJam names\n * a note, until given a name.\n */\nexport function renderStickyNode(\n graph: SceneGraph,\n tree: TreeNode,\n parentId: string,\n layer: Partial<SceneNode>\n) {\n const props = readElementProps(stickyPropsSchema, tree.props)\n const text = plainTextOf(tree)\n const author = props.author ?? ''\n const sticky = createSticky(\n graph,\n parentId,\n {\n text,\n author,\n authorVisible: props.authorVisible !== false && author !== '',\n color: props.color,\n wide: props.wide === true,\n scale: props.scale ?? 1\n },\n { ...layer, name: layer.name ?? (text.trim() || 'Sticky'), autoRename: !layer.name }\n )\n const body = stickySublayers(graph, sticky)?.body\n if (body) graph.updateNode(body.id, figJamTextFields(body, props.textSize, props.typeface))\n return sticky\n}\n\n/** The colour as `<Sticky>` writes it: its palette name, or a hex colour off the palette. */\nfunction colorName(color: Color): string {\n const hex = colorToHex(color)\n const named = Object.entries(STICKY_COLORS).find(([, value]) => colorToHex(value) === hex)\n return named ? named[0] : hex\n}\n\n/** A note's own props as `<Sticky>` writes them, after its name and position. */\nexport function stickyProps(graph: SceneGraph, node: SceneNode): Array<[string, unknown]> {\n const layers = stickySublayers(graph, node)\n const color = node.fills.at(0)?.color\n const props: Array<[string, unknown]> = []\n if (color) props.push(['color', colorName(color)])\n if (layers?.author.text) props.push(['author', layers.author.text])\n if (layers?.author.text && !layers.author.visible) props.push(['authorVisible', false])\n if (isWideSticky(graph, node)) props.push(['wide', true])\n if (layers) props.push(...figJamTextProps(layers.body))\n const scale = layers ? stickyScale(layers.author) : 1\n if (scale !== 1) props.push(['scale', scale])\n return props\n}\n\n/** The body a note writes as its children. */\nexport function stickyBody(graph: SceneGraph, node: SceneNode): string {\n return stickySublayers(graph, node)?.body.text ?? ''\n}\n","import { difference } from 'es-toolkit/array'\n\nimport type { NodeType, SceneGraph, SceneNode } from '@pairdraw/scene-graph'\n\nimport { REKA_ELEMENTS, rekaRole } from './behaviours'\nimport { connectorBindingTarget, renderConnectorNode } from './connectors'\nimport {\n DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES,\n DESIGN_JSX_SPAN_PROPERTY_NAMES,\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES\n} from './definitions'\nimport {\n connectorPropsSchema,\n ownLayerPropsSchema,\n placedOwnLayerPropsSchema,\n shapeLayerPropsSchema,\n shapePropsSchema,\n stickyPropsSchema,\n type ElementPropsSchema\n} from './schema'\nimport { renderShapeNode } from './shapes-with-text'\nimport { renderStickyNode } from './stickies'\nimport type { TreeNode } from './tree'\n\n/** How an element that draws a layer of its own, such as a sticky note, renders it. */\nexport interface OwnLayerRenderer {\n /** The layer props it takes, made into fields as any layer's are. */\n layer: ElementPropsSchema\n render(graph: SceneGraph, tree: TreeNode, parentId: string, layer: Partial<SceneNode>): SceneNode\n /** The layer a variable binding of `field` goes on, when not the element's own. */\n bindingTarget?(graph: SceneGraph, node: SceneNode, field: string): string\n}\n\n/**\n * One design JSX element: what JSX names it, what it makes, the props it takes, and which layers\n * export writes as it. The renderer, the export, the prop checks, the streaming preview, and the\n * authoring reference all read this list rather than keeping their own.\n */\nexport type DesignJSXElementDefinition = {\n name: string\n /** The type its tree nodes carry, such as `frame`. */\n runtimeType: string\n description: string\n /** The layer a plain element makes; an element rendered its own way, such as `Icon`, has none. */\n nodeType?: NodeType\n /** The props it takes; every layer prop when left out. */\n props?: readonly string[]\n /** The props it takes and what each holds, for an element that reads them by this schema. */\n schema?: ElementPropsSchema\n /** How it draws its own layer, for an element that does. */\n ownLayer?: OwnLayerRenderer\n /** The layers export writes as this element. */\n writes?: readonly NodeType[]\n}\n\nfunction rekaDescription(namespace: string, part: string): string {\n const role = rekaRole(`${namespace}.${part}`)\n if (role?.role === 'root')\n return `A main component that behaves as Reka UI's ${namespace} ${part}.`\n if (role?.role === 'input') return `The text layer of a ${namespace}'s text property.`\n return `The ${namespace} ${part}, drawn by a slot of its component.`\n}\n\n/** A Reka UI element as the element list describes it. */\nfunction rekaElementDefinitions(): DesignJSXElementDefinition[] {\n return Object.entries(REKA_ELEMENTS).flatMap(([namespace, parts]) =>\n Object.keys(parts).map((part) => {\n const type = `${namespace}.${part}`\n return { name: type, runtimeType: type, description: rekaDescription(namespace, part) }\n })\n )\n}\n\nexport const DESIGN_JSX_ELEMENTS: DesignJSXElementDefinition[] = [\n {\n name: 'Frame',\n runtimeType: 'frame',\n description: 'A frame or auto-layout container.',\n nodeType: 'FRAME',\n // A set and an instance read back as frames: JSX cannot name what they come from.\n writes: ['FRAME', 'COMPONENT_SET', 'INSTANCE']\n },\n {\n name: 'Text',\n runtimeType: 'text',\n description: 'A text layer.',\n nodeType: 'TEXT',\n writes: ['TEXT']\n },\n {\n name: 'Span',\n runtimeType: 'text-span',\n description: 'Characters inside a Text, styled apart from the rest.',\n props: ['key', ...DESIGN_JSX_SPAN_PROPERTY_NAMES]\n },\n {\n name: 'Paragraph',\n runtimeType: 'text-paragraph',\n description: 'One paragraph of a Text, plain or a list item.',\n props: ['key', ...DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES]\n },\n {\n name: 'Rectangle',\n runtimeType: 'rectangle',\n description: 'A rectangle layer.',\n nodeType: 'RECTANGLE',\n writes: ['RECTANGLE', 'ROUNDED_RECTANGLE']\n },\n {\n name: 'Ellipse',\n runtimeType: 'ellipse',\n description: 'An ellipse layer.',\n nodeType: 'ELLIPSE',\n writes: ['ELLIPSE']\n },\n {\n name: 'Line',\n runtimeType: 'line',\n description: 'A line layer.',\n nodeType: 'LINE',\n writes: ['LINE']\n },\n {\n name: 'Star',\n runtimeType: 'star',\n description: 'A star layer.',\n nodeType: 'STAR',\n writes: ['STAR']\n },\n {\n name: 'Polygon',\n runtimeType: 'polygon',\n description: 'A polygon layer.',\n nodeType: 'POLYGON',\n writes: ['POLYGON']\n },\n {\n name: 'Vector',\n runtimeType: 'vector',\n description: 'A vector layer.',\n nodeType: 'VECTOR',\n writes: ['VECTOR', 'BOOLEAN_OPERATION']\n },\n {\n name: 'Group',\n runtimeType: 'group',\n description: 'A group of layers.',\n nodeType: 'GROUP',\n writes: ['GROUP']\n },\n {\n name: 'Section',\n runtimeType: 'section',\n description: 'A canvas section.',\n nodeType: 'SECTION',\n writes: ['SECTION']\n },\n {\n name: 'Component',\n runtimeType: 'component',\n description: 'A reusable component.',\n nodeType: 'COMPONENT',\n writes: ['COMPONENT']\n },\n {\n name: 'ComponentSet',\n runtimeType: 'component-set',\n description: 'A component variant set.',\n nodeType: 'COMPONENT_SET'\n },\n { name: 'Instance', runtimeType: 'instance', description: 'An instance of a component.' },\n { name: 'View', runtimeType: 'frame', description: 'An alias for Frame.', nodeType: 'FRAME' },\n {\n name: 'Rect',\n runtimeType: 'rectangle',\n description: 'An alias for Rectangle.',\n nodeType: 'RECTANGLE'\n },\n { name: 'Icon', runtimeType: 'icon', description: 'An Iconify icon.' },\n {\n name: 'Sticky',\n runtimeType: 'sticky',\n description: 'A FigJam sticky note; its text is the body.',\n schema: stickyPropsSchema,\n ownLayer: { layer: placedOwnLayerPropsSchema, render: renderStickyNode },\n writes: ['STICKY']\n },\n {\n name: 'Shape',\n runtimeType: 'shape',\n description: 'A FigJam shape with text; its text is the label.',\n schema: shapePropsSchema,\n ownLayer: { layer: shapeLayerPropsSchema, render: renderShapeNode },\n writes: ['SHAPE_WITH_TEXT']\n },\n {\n name: 'Connector',\n runtimeType: 'connector',\n description:\n 'A FigJam connector between two layers of the same JSX, named by `from` and `to`, or points.',\n schema: connectorPropsSchema,\n ownLayer: {\n layer: ownLayerPropsSchema,\n render: renderConnectorNode,\n bindingTarget: connectorBindingTarget\n },\n writes: ['CONNECTOR']\n },\n ...rekaElementDefinitions()\n]\n\n/** Props an inline `<svg>` takes besides a layer's: its markup's view box and body. */\nconst SVG_PROPERTY_NAMES = ['viewBox', 'body'] as const\n\n/**\n * Lowercase tags JSX also accepts, as HTML names them, with the layer each makes; they are\n * not written back.\n */\nconst INTRINSIC_ELEMENTS: Readonly<Record<string, NodeType | null>> = {\n componentset: 'COMPONENT_SET',\n div: 'FRAME',\n main: 'FRAME',\n header: 'FRAME',\n footer: 'FRAME',\n nav: 'FRAME',\n article: 'FRAME',\n aside: 'FRAME',\n span: 'TEXT',\n p: 'TEXT',\n h1: 'TEXT',\n h2: 'TEXT',\n h3: 'TEXT',\n h4: 'TEXT',\n h5: 'TEXT',\n h6: 'TEXT',\n // Inline SVG markup, which the artwork service draws.\n svg: null\n}\n\n/** Paragraph props describe a paragraph of a text, never a layer, unless a text sets them too. */\nconst LAYER_PROPS: ReadonlySet<string> = new Set<string>(\n difference(\n DESIGN_JSX_SUPPORTED_PROPERTY_NAMES,\n difference(DESIGN_JSX_PARAGRAPH_PROPERTY_NAMES, DESIGN_JSX_TEXT_PARAGRAPH_PROPERTY_NAMES)\n )\n)\n\nconst BY_RUNTIME_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.runtimeType,\n element\n ]).reverse()\n)\n\nconst PROPS_BY_RUNTIME_TYPE = new Map<string, ReadonlySet<string>>([\n ['svg', new Set([...LAYER_PROPS, ...SVG_PROPERTY_NAMES])],\n ...DESIGN_JSX_ELEMENTS.flatMap((element): [string, ReadonlySet<string>][] => {\n const props = element.schema ? Object.keys(element.schema.entries) : element.props\n return props ? [[element.runtimeType, new Set(props)]] : []\n })\n])\n\nconst TAG_BY_NODE_TYPE = new Map(\n DESIGN_JSX_ELEMENTS.flatMap((element) =>\n (element.writes ?? []).map((type): [NodeType, string] => [type, element.name])\n )\n)\n\n/** The layer an element of `runtimeType` makes, for an element without its own renderer. */\nexport function elementNodeType(runtimeType: string): NodeType | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.nodeType ?? INTRINSIC_ELEMENTS[runtimeType] ?? undefined\n}\n\n/** The props an element of `runtimeType` takes. */\nexport function elementProps(runtimeType: string): ReadonlySet<string> {\n return PROPS_BY_RUNTIME_TYPE.get(runtimeType) ?? LAYER_PROPS\n}\n\nconst BY_NAME = new Map(\n DESIGN_JSX_ELEMENTS.map((element): [string, DesignJSXElementDefinition] => [\n element.name,\n element\n ])\n)\n\n/**\n * The props an element written `<name>` takes, as the renderer checks them, for an editor that\n * checks them as they are typed; null for a name that is no element, and for an instance, which\n * also takes its component's properties by name.\n */\nexport function elementPropsByName(name: string): ReadonlySet<string> | null {\n const element = BY_NAME.get(name)\n if (!element) return Object.hasOwn(INTRINSIC_ELEMENTS, name) ? elementProps(name) : null\n return element.runtimeType === 'instance' ? null : elementProps(element.runtimeType)\n}\n\n/** The schema an element of `runtimeType` reads its props by, if it has one. */\nexport function elementSchema(runtimeType: string): ElementPropsSchema | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.schema\n}\n\n/** How an element of `runtimeType` draws its own layer, if it does. */\nexport function elementOwnLayer(runtimeType: string): OwnLayerRenderer | undefined {\n return BY_RUNTIME_TYPE.get(runtimeType)?.ownLayer\n}\n\n/** The element export writes a layer of `type` as, if any. */\nexport function elementTag(type: NodeType): string | undefined {\n return TAG_BY_NODE_TYPE.get(type)\n}\n\n/**\n * `const Frame = 'frame', …`: the element names a JSX string's code can use, bound to their\n * runtime types. Reka UI elements, named `Switch.Root`, are bound by their namespaces.\n */\nexport function elementBindings(): string {\n return DESIGN_JSX_ELEMENTS.filter((element) => !element.name.includes('.'))\n .map((element) => `const ${element.name} = '${element.runtimeType}'`)\n .join('\\n')\n}\n"],"mappings":";;;;;;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I;AACd"}
|
|
@@ -49,12 +49,12 @@ function autoLength(value) {
|
|
|
49
49
|
* The decoration details, font settings, and text-wide paragraph spacing a `<Text>` or `<Span>`
|
|
50
50
|
* sets. Font settings replace the ones around them as a whole, as CSS's do.
|
|
51
51
|
*/
|
|
52
|
-
function applyTextDetailOverrides(props, o) {
|
|
52
|
+
function applyTextDetailOverrides(props, o, profile) {
|
|
53
53
|
const parsed = parseScriptInput("Invalid <Text> props", textPropsSchema, props);
|
|
54
54
|
const color = parsed.textDecorationColor;
|
|
55
55
|
const style = TEXT_DECORATION_STYLE.parse(parsed.textDecorationStyle);
|
|
56
56
|
if (style) o.textDecorationStyle = style;
|
|
57
|
-
if (color !== void 0) o.textDecorationFills = typeof color === "string" && color.toLowerCase() === "currentColor".toLowerCase() ? [] : [fillFromValue(color)];
|
|
57
|
+
if (color !== void 0) o.textDecorationFills = typeof color === "string" && color.toLowerCase() === "currentColor".toLowerCase() ? [] : [fillFromValue(color, profile)];
|
|
58
58
|
if (parsed.textDecorationThickness !== void 0) o.textDecorationThickness = autoLength(parsed.textDecorationThickness);
|
|
59
59
|
if (parsed.textUnderlineOffset !== void 0) o.textUnderlineOffset = autoLength(parsed.textUnderlineOffset);
|
|
60
60
|
if (parsed.textDecorationSkipInk !== void 0) o.textDecorationSkipInk = parsed.textDecorationSkipInk;
|
|
@@ -79,12 +79,12 @@ function applyTextDetailOverrides(props, o) {
|
|
|
79
79
|
* The decoration details set in `style`, as `<Text>` and `<Span>` write them. A decoration
|
|
80
80
|
* painted with more than one paint keeps only its first, the one `textDecorationColor` holds.
|
|
81
81
|
*/
|
|
82
|
-
function collectDecorationProps(style, node, props) {
|
|
82
|
+
function collectDecorationProps(style, node, props, profile = "srgb") {
|
|
83
83
|
const { textDecorationFills: fills } = style;
|
|
84
84
|
if (style.textDecorationStyle !== void 0) props.push(["textDecorationStyle", TEXT_DECORATION_STYLE.print(style.textDecorationStyle)]);
|
|
85
85
|
if (fills) {
|
|
86
86
|
const fill = fills.at(0);
|
|
87
|
-
props.push(["textDecorationColor", fill ? paintPropValue(fill, node) : CURRENT_COLOR]);
|
|
87
|
+
props.push(["textDecorationColor", fill ? paintPropValue(fill, node, profile) : CURRENT_COLOR]);
|
|
88
88
|
}
|
|
89
89
|
if (style.textDecorationThickness !== void 0) props.push(["textDecorationThickness", style.textDecorationThickness ?? "auto"]);
|
|
90
90
|
if (style.textUnderlineOffset !== void 0) props.push(["textUnderlineOffset", style.textUnderlineOffset ?? "auto"]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decoration.js","names":[],"sources":["../../../src/overrides/text.ts","../../../src/export/decoration.ts"],"sourcesContent":["import { uniqBy } from 'es-toolkit'\nimport * as v from 'valibot'\n\nimport type { Fill, SceneNode, TextLength } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\nimport { percentLength, pixelLength } from '@pairdraw/scene-graph/text'\n\nimport { TEXT_DECORATION_STYLE } from '../enums'\nimport { parseScriptInput } from '../schema'\nimport { fillFromValue, isFillValue } from './fills'\n\n/** Lengths that follow the font unless set take `'auto'`, as in CSS. */\nexport const AUTO = 'auto'\n/** The decoration colour that follows the text's, as in CSS. */\nexport const CURRENT_COLOR = 'currentColor'\n\n/** A percent of the font size, such as `'150%'`, which follows the size as in Figma. */\nconst PERCENT_LENGTH = /^(-?\\d+(?:\\.\\d+)?)%$/\n\n/** A line height or letter spacing a prop gives: pixels as a number, or a percent string. */\nexport function textLengthProp(value: unknown): TextLength | undefined {\n if (typeof value === 'number' && Number.isFinite(value)) return pixelLength(value)\n const match = typeof value === 'string' ? PERCENT_LENGTH.exec(value.trim()) : null\n return match ? percentLength(Number(match[1])) : undefined\n}\n\n/** A line height or letter spacing as a prop writes it. */\nexport function textLengthJSX(length: TextLength): number | `${number}%` {\n return length.unit === 'PIXELS' ? length.value : `${length.value}%`\n}\n\nconst lengthSchema = v.pipe(v.number(), v.finite())\nconst autoLengthSchema = v.union([lengthSchema, v.literal(AUTO)])\n/** An OpenType feature or axis tag: four printable ASCII characters, such as `tnum` or `wght`. */\nconst openTypeTagSchema = v.pipe(\n v.string(),\n v.regex(/^[\\x20-\\x7E]{4}$/, 'Expected a four-character tag')\n)\n\nconst textPropsSchema = v.object({\n // Read by TEXT_DECORATION_STYLE, so an unknown style warns rather than failing the render.\n textDecorationStyle: v.optional(v.string()),\n textDecorationColor: v.optional(\n v.custom<string | Color | Fill>(isFillValue, 'Expected a colour or a paint')\n ),\n textDecorationThickness: v.optional(autoLengthSchema),\n textUnderlineOffset: v.optional(autoLengthSchema),\n textDecorationSkipInk: v.optional(v.boolean()),\n fontFeatures: v.optional(\n v.pipe(\n v.record(openTypeTagSchema, v.boolean()),\n // Tags are stored in capitals, so `liga` and `LIGA` are the same feature.\n v.check((features) => {\n const tags = Object.keys(features)\n return uniqBy(tags, (tag) => tag.toUpperCase()).length === tags.length\n }, 'Expected each feature tag once, in any case')\n )\n ),\n fontVariations: v.optional(v.record(openTypeTagSchema, lengthSchema)),\n lang: v.optional(v.nullable(v.pipe(v.string(), v.trim(), v.nonEmpty()))),\n fontOpticalSizing: v.optional(v.picklist([AUTO, 'none'])),\n paragraphSpacing: v.optional(lengthSchema),\n listSpacing: v.optional(lengthSchema),\n paragraphIndent: v.optional(lengthSchema),\n hangingList: v.optional(v.boolean())\n})\n\nfunction autoLength(value: number | typeof AUTO): number | null {\n return value === AUTO ? null : value\n}\n\n/**\n * The decoration details, font settings, and text-wide paragraph spacing a `<Text>` or `<Span>`\n * sets. Font settings replace the ones around them as a whole, as CSS's do.\n */\nexport function applyTextDetailOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode
|
|
1
|
+
{"version":3,"file":"decoration.js","names":[],"sources":["../../../src/overrides/text.ts","../../../src/export/decoration.ts"],"sourcesContent":["import { uniqBy } from 'es-toolkit'\nimport * as v from 'valibot'\n\nimport type { DocumentColorSpace, Fill, SceneNode, TextLength } from '@pairdraw/scene-graph'\nimport type { Color } from '@pairdraw/scene-graph/primitives'\nimport { percentLength, pixelLength } from '@pairdraw/scene-graph/text'\n\nimport { TEXT_DECORATION_STYLE } from '../enums'\nimport { parseScriptInput } from '../schema'\nimport { fillFromValue, isFillValue } from './fills'\n\n/** Lengths that follow the font unless set take `'auto'`, as in CSS. */\nexport const AUTO = 'auto'\n/** The decoration colour that follows the text's, as in CSS. */\nexport const CURRENT_COLOR = 'currentColor'\n\n/** A percent of the font size, such as `'150%'`, which follows the size as in Figma. */\nconst PERCENT_LENGTH = /^(-?\\d+(?:\\.\\d+)?)%$/\n\n/** A line height or letter spacing a prop gives: pixels as a number, or a percent string. */\nexport function textLengthProp(value: unknown): TextLength | undefined {\n if (typeof value === 'number' && Number.isFinite(value)) return pixelLength(value)\n const match = typeof value === 'string' ? PERCENT_LENGTH.exec(value.trim()) : null\n return match ? percentLength(Number(match[1])) : undefined\n}\n\n/** A line height or letter spacing as a prop writes it. */\nexport function textLengthJSX(length: TextLength): number | `${number}%` {\n return length.unit === 'PIXELS' ? length.value : `${length.value}%`\n}\n\nconst lengthSchema = v.pipe(v.number(), v.finite())\nconst autoLengthSchema = v.union([lengthSchema, v.literal(AUTO)])\n/** An OpenType feature or axis tag: four printable ASCII characters, such as `tnum` or `wght`. */\nconst openTypeTagSchema = v.pipe(\n v.string(),\n v.regex(/^[\\x20-\\x7E]{4}$/, 'Expected a four-character tag')\n)\n\nconst textPropsSchema = v.object({\n // Read by TEXT_DECORATION_STYLE, so an unknown style warns rather than failing the render.\n textDecorationStyle: v.optional(v.string()),\n textDecorationColor: v.optional(\n v.custom<string | Color | Fill>(isFillValue, 'Expected a colour or a paint')\n ),\n textDecorationThickness: v.optional(autoLengthSchema),\n textUnderlineOffset: v.optional(autoLengthSchema),\n textDecorationSkipInk: v.optional(v.boolean()),\n fontFeatures: v.optional(\n v.pipe(\n v.record(openTypeTagSchema, v.boolean()),\n // Tags are stored in capitals, so `liga` and `LIGA` are the same feature.\n v.check((features) => {\n const tags = Object.keys(features)\n return uniqBy(tags, (tag) => tag.toUpperCase()).length === tags.length\n }, 'Expected each feature tag once, in any case')\n )\n ),\n fontVariations: v.optional(v.record(openTypeTagSchema, lengthSchema)),\n lang: v.optional(v.nullable(v.pipe(v.string(), v.trim(), v.nonEmpty()))),\n fontOpticalSizing: v.optional(v.picklist([AUTO, 'none'])),\n paragraphSpacing: v.optional(lengthSchema),\n listSpacing: v.optional(lengthSchema),\n paragraphIndent: v.optional(lengthSchema),\n hangingList: v.optional(v.boolean())\n})\n\nfunction autoLength(value: number | typeof AUTO): number | null {\n return value === AUTO ? null : value\n}\n\n/**\n * The decoration details, font settings, and text-wide paragraph spacing a `<Text>` or `<Span>`\n * sets. Font settings replace the ones around them as a whole, as CSS's do.\n */\nexport function applyTextDetailOverrides(\n props: Record<string, unknown>,\n o: Partial<SceneNode>,\n profile: DocumentColorSpace\n): void {\n const parsed = parseScriptInput('Invalid <Text> props', textPropsSchema, props)\n const color = parsed.textDecorationColor\n const style = TEXT_DECORATION_STYLE.parse(parsed.textDecorationStyle)\n if (style) o.textDecorationStyle = style\n if (color !== undefined) {\n o.textDecorationFills =\n typeof color === 'string' && color.toLowerCase() === CURRENT_COLOR.toLowerCase()\n ? []\n : [fillFromValue(color, profile)]\n }\n if (parsed.textDecorationThickness !== undefined)\n o.textDecorationThickness = autoLength(parsed.textDecorationThickness)\n if (parsed.textUnderlineOffset !== undefined)\n o.textUnderlineOffset = autoLength(parsed.textUnderlineOffset)\n if (parsed.textDecorationSkipInk !== undefined)\n o.textDecorationSkipInk = parsed.textDecorationSkipInk\n if (parsed.fontFeatures) {\n // The scene keeps feature tags as Figma does, in capitals.\n o.fontFeatures = Object.entries(parsed.fontFeatures).map(([tag, enabled]) => ({\n tag: tag.toUpperCase(),\n enabled\n }))\n }\n if (parsed.fontVariations) {\n o.fontVariations = Object.entries(parsed.fontVariations).map(([axis, value]) => ({\n axis,\n value\n }))\n }\n if (parsed.lang !== undefined) o.textLanguage = parsed.lang\n if (parsed.fontOpticalSizing !== undefined)\n o.opticalSizeFromFontSize = parsed.fontOpticalSizing === AUTO\n if (parsed.paragraphSpacing !== undefined) o.paragraphSpacing = parsed.paragraphSpacing\n if (parsed.listSpacing !== undefined) o.listSpacing = parsed.listSpacing\n if (parsed.paragraphIndent !== undefined) o.paragraphIndent = parsed.paragraphIndent\n if (parsed.hangingList !== undefined) o.hangingList = parsed.hangingList\n}\n","import type { CharacterStyleOverride, ColorProfile, SceneNode } from '@pairdraw/scene-graph'\n\nimport { TEXT_DECORATION_STYLE } from '../enums'\nimport { AUTO, CURRENT_COLOR } from '../overrides/text'\nimport { paintPropValue } from './paint'\nimport type { JSXProp } from './value'\n\ntype DecorationStyle = Pick<\n CharacterStyleOverride,\n | 'textDecorationStyle'\n | 'textDecorationFills'\n | 'textDecorationThickness'\n | 'textUnderlineOffset'\n | 'textDecorationSkipInk'\n>\n\n/**\n * The decoration details set in `style`, as `<Text>` and `<Span>` write them. A decoration\n * painted with more than one paint keeps only its first, the one `textDecorationColor` holds.\n */\nexport function collectDecorationProps(\n style: DecorationStyle,\n node: SceneNode,\n props: JSXProp[],\n profile: ColorProfile = 'srgb'\n): void {\n const { textDecorationFills: fills } = style\n if (style.textDecorationStyle !== undefined)\n props.push(['textDecorationStyle', TEXT_DECORATION_STYLE.print(style.textDecorationStyle)])\n if (fills) {\n const fill = fills.at(0)\n props.push(['textDecorationColor', fill ? paintPropValue(fill, node, profile) : CURRENT_COLOR])\n }\n if (style.textDecorationThickness !== undefined)\n props.push(['textDecorationThickness', style.textDecorationThickness ?? AUTO])\n if (style.textUnderlineOffset !== undefined)\n props.push(['textUnderlineOffset', style.textUnderlineOffset ?? AUTO])\n if (style.textDecorationSkipInk !== undefined)\n props.push(['textDecorationSkipInk', style.textDecorationSkipInk])\n}\n"],"mappings":";;;;;;;AAYA,MAAa,OAAO;;AAEpB,MAAa,gBAAgB;;AAG7B,MAAM,iBAAiB;;AAGvB,SAAgB,eAAe,OAAwC;CACrE,IAAI,OAAO,UAAU,YAAY,OAA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