stickyflow 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/README.md +1 -1
- package/dist/binding/index.cjs +9 -9
- package/dist/binding/index.d.cts +4 -4
- package/dist/binding/index.d.ts +4 -4
- package/dist/binding/index.js +3 -3
- package/dist/{chunk-VOYX6JMW.cjs → chunk-5EY7EK5V.cjs} +797 -669
- package/dist/chunk-5EY7EK5V.cjs.map +1 -0
- package/dist/{chunk-EDOPENSE.js → chunk-7ZEC7AB4.js} +228 -46
- package/dist/chunk-7ZEC7AB4.js.map +1 -0
- package/dist/{chunk-XPM3E7NV.cjs → chunk-BL5NCXS4.cjs} +23 -23
- package/dist/chunk-BL5NCXS4.cjs.map +1 -0
- package/dist/{chunk-LFEGZJWC.js → chunk-CM35H45Z.js} +3 -3
- package/dist/{chunk-LFEGZJWC.js.map → chunk-CM35H45Z.js.map} +1 -1
- package/dist/{chunk-GLZVHUSW.js → chunk-D2266VBZ.js} +393 -5
- package/dist/chunk-D2266VBZ.js.map +1 -0
- package/dist/{chunk-CZW3ARXQ.js → chunk-IKTSCLIK.js} +5 -5
- package/dist/chunk-IKTSCLIK.js.map +1 -0
- package/dist/{chunk-FQ7GMLCM.cjs → chunk-OUWGWDJ2.cjs} +15 -15
- package/dist/{chunk-FQ7GMLCM.cjs.map → chunk-OUWGWDJ2.cjs.map} +1 -1
- package/dist/{chunk-LNW5VIEA.cjs → chunk-QL7MNEMT.cjs} +393 -4
- package/dist/chunk-QL7MNEMT.cjs.map +1 -0
- package/dist/{chunk-IR2T47NW.cjs → chunk-RUSNRDLI.cjs} +257 -75
- package/dist/chunk-RUSNRDLI.cjs.map +1 -0
- package/dist/{chunk-MAPNY7MJ.js → chunk-TH2HFMEL.js} +147 -19
- package/dist/chunk-TH2HFMEL.js.map +1 -0
- package/dist/index.cjs +36 -36
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +5 -5
- package/dist/interaction/index.cjs +232 -230
- package/dist/interaction/index.cjs.map +1 -1
- package/dist/interaction/index.d.cts +2 -2
- package/dist/interaction/index.d.ts +2 -2
- package/dist/interaction/index.js +4 -2
- package/dist/interaction/index.js.map +1 -1
- package/dist/{render-Bp2FLEzv.d.cts → render-DU4lYbRl.d.cts} +19 -11
- package/dist/{render-Bp2FLEzv.d.ts → render-DU4lYbRl.d.ts} +19 -11
- package/dist/{runtime-DIag-XBa.d.cts → runtime-DG8X3Fwf.d.cts} +2 -2
- package/dist/{runtime-CWIGxRcL.d.ts → runtime-kqD1RS17.d.ts} +2 -2
- package/dist/{runtimeTypes-C7sSLfOK.d.ts → runtimeTypes-CvjlBZds.d.cts} +7 -3
- package/dist/{runtimeTypes-BYODuxHk.d.cts → runtimeTypes-vRaHOIHi.d.ts} +7 -3
- package/dist/stickyflow-diagram.global.js +192 -40
- package/dist/stickyflow-diagram.global.js.map +1 -1
- package/dist/{types-D2w6D_wG.d.cts → types-B5jrEEcF.d.cts} +1 -1
- package/dist/{types-B9QM_H3R.d.ts → types-B7IkZ0w4.d.ts} +1 -1
- package/dist/viewer/index.cjs +9 -9
- package/dist/viewer/index.d.cts +4 -4
- package/dist/viewer/index.d.ts +4 -4
- package/dist/viewer/index.js +4 -4
- package/dist/web-component/index.cjs +6 -6
- package/dist/web-component/index.d.cts +2 -2
- package/dist/web-component/index.d.ts +2 -2
- package/dist/web-component/index.js +4 -4
- package/package.json +1 -1
- package/dist/chunk-CZW3ARXQ.js.map +0 -1
- package/dist/chunk-EDOPENSE.js.map +0 -1
- package/dist/chunk-GLZVHUSW.js.map +0 -1
- package/dist/chunk-IR2T47NW.cjs.map +0 -1
- package/dist/chunk-LNW5VIEA.cjs.map +0 -1
- package/dist/chunk-MAPNY7MJ.js.map +0 -1
- package/dist/chunk-VOYX6JMW.cjs.map +0 -1
- package/dist/chunk-XPM3E7NV.cjs.map +0 -1
|
@@ -1067,7 +1067,8 @@ var NAMED_BLOCK_KINDS = [
|
|
|
1067
1067
|
"Net",
|
|
1068
1068
|
"Symbol",
|
|
1069
1069
|
"Port",
|
|
1070
|
-
"DataSource"
|
|
1070
|
+
"DataSource",
|
|
1071
|
+
"Repeat"
|
|
1071
1072
|
];
|
|
1072
1073
|
var SIDES = ["top", "bottom", "left", "right"];
|
|
1073
1074
|
var isSide = (s) => SIDES.includes(s);
|
|
@@ -1126,7 +1127,43 @@ function parseList(cursor) {
|
|
|
1126
1127
|
cursor.expect("rbracket", "']'");
|
|
1127
1128
|
return { type: "list", values };
|
|
1128
1129
|
}
|
|
1130
|
+
var ARITHMETIC = /* @__PURE__ */ new Set(["+", "-", "*", "/", ">", "<", ">=", "<=", "==", "!=", "&&", "||"]);
|
|
1131
|
+
function startsComputed(cursor) {
|
|
1132
|
+
const first = cursor.peek();
|
|
1133
|
+
if (first.type === "op" && first.value === "-") {
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
1136
|
+
if (first.type !== "number" && first.type !== "ident" && first.type !== "lparen") {
|
|
1137
|
+
return false;
|
|
1138
|
+
}
|
|
1139
|
+
for (let offset = 0; ; offset++) {
|
|
1140
|
+
const token = cursor.peek(offset);
|
|
1141
|
+
if (token.type === "newline" || token.type === "semi" || token.type === "rbrace" || token.type === "eof") {
|
|
1142
|
+
return false;
|
|
1143
|
+
}
|
|
1144
|
+
if (token.type === "lparen" || token.type === "op" && ARITHMETIC.has(token.value)) {
|
|
1145
|
+
return true;
|
|
1146
|
+
}
|
|
1147
|
+
if (token.type === "ident" && cursor.peek(offset - 1).type === "comma") {
|
|
1148
|
+
return true;
|
|
1149
|
+
}
|
|
1150
|
+
if (offset === 0 && token.type === "ident" && cursor.peek(1).type === "comma") {
|
|
1151
|
+
return true;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
function parseComputed(cursor) {
|
|
1156
|
+
const items = [parseExpression(cursor)];
|
|
1157
|
+
while (cursor.at("comma")) {
|
|
1158
|
+
cursor.next();
|
|
1159
|
+
items.push(parseExpression(cursor));
|
|
1160
|
+
}
|
|
1161
|
+
return { type: "expr", items };
|
|
1162
|
+
}
|
|
1129
1163
|
function parseValue(cursor, allowTuple = true) {
|
|
1164
|
+
if (allowTuple && startsComputed(cursor)) {
|
|
1165
|
+
return parseComputed(cursor);
|
|
1166
|
+
}
|
|
1130
1167
|
const token = cursor.peek();
|
|
1131
1168
|
switch (token.type) {
|
|
1132
1169
|
case "string":
|
|
@@ -1592,6 +1629,8 @@ function emitValue(value) {
|
|
|
1592
1629
|
return `[${value.values.map(emitValue).join(", ")}]`;
|
|
1593
1630
|
case "ident":
|
|
1594
1631
|
return value.segments.join(".");
|
|
1632
|
+
case "expr":
|
|
1633
|
+
return value.items.map((item) => emitExpression(item)).join(", ");
|
|
1595
1634
|
case "endpoint": {
|
|
1596
1635
|
let output = value.segments.join(".");
|
|
1597
1636
|
if (value.side) {
|
|
@@ -1671,6 +1710,8 @@ var STYLE_ORDER = [
|
|
|
1671
1710
|
"dash",
|
|
1672
1711
|
"shadow",
|
|
1673
1712
|
"opacity",
|
|
1713
|
+
"blur",
|
|
1714
|
+
"blend",
|
|
1674
1715
|
"icon",
|
|
1675
1716
|
"route",
|
|
1676
1717
|
"marker",
|
|
@@ -1849,6 +1890,353 @@ function isSwimlaneObject(canvasObject) {
|
|
|
1849
1890
|
return canvasObject.objectType === "swimlane" && canvasObject.swimlane !== void 0;
|
|
1850
1891
|
}
|
|
1851
1892
|
|
|
1893
|
+
// src/sflLanguage/expansion/repeat.ts
|
|
1894
|
+
var RESERVED = /* @__PURE__ */ new Set(["columns", "rows", "count", "step", "origin", "seed", "jitter", "chance", "order", "where"]);
|
|
1895
|
+
var MAX_CELLS = 2e4;
|
|
1896
|
+
var MAX_VALUES = 1e6;
|
|
1897
|
+
var Random = class {
|
|
1898
|
+
state;
|
|
1899
|
+
constructor(seed) {
|
|
1900
|
+
this.state = seed >>> 0;
|
|
1901
|
+
}
|
|
1902
|
+
// mulberry32: a small generator that gives the same numbers for the same seed, on every machine.
|
|
1903
|
+
next() {
|
|
1904
|
+
this.state = this.state + 1831565813 >>> 0;
|
|
1905
|
+
let t = this.state;
|
|
1906
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
1907
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
1908
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
function fail(scope, message) {
|
|
1912
|
+
throw new Error(`Repeat ${scope.repeat}: ${message}`);
|
|
1913
|
+
}
|
|
1914
|
+
function numberOf(scope, value, what) {
|
|
1915
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1916
|
+
fail(scope, `${what} needs a number`);
|
|
1917
|
+
}
|
|
1918
|
+
return value;
|
|
1919
|
+
}
|
|
1920
|
+
function rgbOf(scope, value) {
|
|
1921
|
+
const match = typeof value === "string" ? /^#([0-9a-f]{6})$/i.exec(value) : null;
|
|
1922
|
+
if (!match) {
|
|
1923
|
+
fail(scope, 'a color has to be written as "#rrggbb"');
|
|
1924
|
+
}
|
|
1925
|
+
const n = Number.parseInt(match[1], 16);
|
|
1926
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1927
|
+
}
|
|
1928
|
+
var hexOf = (rgb) => `#${rgb.map(
|
|
1929
|
+
(channel) => Math.round(Math.max(0, Math.min(255, channel))).toString(16).padStart(2, "0")
|
|
1930
|
+
).join("")}`;
|
|
1931
|
+
function callFunction(scope, name, args) {
|
|
1932
|
+
const number = (index) => numberOf(scope, args[index], `${name}()`);
|
|
1933
|
+
switch (name) {
|
|
1934
|
+
case "random": {
|
|
1935
|
+
if (args.length === 0) {
|
|
1936
|
+
return scope.random.next();
|
|
1937
|
+
}
|
|
1938
|
+
const low = args.length === 1 ? 0 : number(0);
|
|
1939
|
+
const high = args.length === 1 ? number(0) : number(1);
|
|
1940
|
+
return low + scope.random.next() * (high - low);
|
|
1941
|
+
}
|
|
1942
|
+
case "pick": {
|
|
1943
|
+
if (args.length === 0) {
|
|
1944
|
+
fail(scope, "pick() needs at least one value");
|
|
1945
|
+
}
|
|
1946
|
+
return args[Math.floor(scope.random.next() * args.length)];
|
|
1947
|
+
}
|
|
1948
|
+
case "exp":
|
|
1949
|
+
return Math.exp(number(0));
|
|
1950
|
+
case "pow":
|
|
1951
|
+
return number(0) ** number(1);
|
|
1952
|
+
case "dist":
|
|
1953
|
+
return Math.hypot(number(0) - number(2), number(1) - number(3));
|
|
1954
|
+
case "mix": {
|
|
1955
|
+
const from = rgbOf(scope, args[0]);
|
|
1956
|
+
const to = rgbOf(scope, args[1]);
|
|
1957
|
+
const amount = Math.max(0, Math.min(1, number(2)));
|
|
1958
|
+
return hexOf(from.map((channel, index) => channel + (to[index] - channel) * amount));
|
|
1959
|
+
}
|
|
1960
|
+
case "shade": {
|
|
1961
|
+
const factor = number(1);
|
|
1962
|
+
return hexOf(rgbOf(scope, args[0]).map((channel) => channel * factor));
|
|
1963
|
+
}
|
|
1964
|
+
case "floor":
|
|
1965
|
+
return Math.floor(number(0));
|
|
1966
|
+
case "ceil":
|
|
1967
|
+
return Math.ceil(number(0));
|
|
1968
|
+
case "round":
|
|
1969
|
+
return Math.round(number(0));
|
|
1970
|
+
case "abs":
|
|
1971
|
+
return Math.abs(number(0));
|
|
1972
|
+
case "sqrt":
|
|
1973
|
+
return Math.sqrt(number(0));
|
|
1974
|
+
case "sin":
|
|
1975
|
+
return Math.sin(number(0));
|
|
1976
|
+
case "cos":
|
|
1977
|
+
return Math.cos(number(0));
|
|
1978
|
+
case "min":
|
|
1979
|
+
return Math.min(...args.map((_, index) => number(index)));
|
|
1980
|
+
case "max":
|
|
1981
|
+
return Math.max(...args.map((_, index) => number(index)));
|
|
1982
|
+
case "when":
|
|
1983
|
+
return args[0] ? args[1] : args[2];
|
|
1984
|
+
default:
|
|
1985
|
+
return fail(scope, `unknown function ${name}()`);
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
function evaluate(scope, expr) {
|
|
1989
|
+
switch (expr.kind) {
|
|
1990
|
+
case "number":
|
|
1991
|
+
case "string":
|
|
1992
|
+
case "boolean":
|
|
1993
|
+
return expr.value;
|
|
1994
|
+
case "ref": {
|
|
1995
|
+
const name = expr.path.join(".");
|
|
1996
|
+
const value = scope.vars.get(name);
|
|
1997
|
+
if (value === void 0) {
|
|
1998
|
+
fail(scope, `unknown name ${name}`);
|
|
1999
|
+
}
|
|
2000
|
+
return value;
|
|
2001
|
+
}
|
|
2002
|
+
case "unary": {
|
|
2003
|
+
const operand = evaluate(scope, expr.operand);
|
|
2004
|
+
return expr.operator === "-" ? -numberOf(scope, operand, "a minus") : !operand;
|
|
2005
|
+
}
|
|
2006
|
+
case "call":
|
|
2007
|
+
return callFunction(
|
|
2008
|
+
scope,
|
|
2009
|
+
expr.callee.join("."),
|
|
2010
|
+
expr.args.map((arg) => evaluate(scope, arg))
|
|
2011
|
+
);
|
|
2012
|
+
case "binary": {
|
|
2013
|
+
const left = evaluate(scope, expr.left);
|
|
2014
|
+
const right = evaluate(scope, expr.right);
|
|
2015
|
+
switch (expr.operator) {
|
|
2016
|
+
case "+":
|
|
2017
|
+
return typeof left === "string" || typeof right === "string" ? `${left}${right}` : numberOf(scope, left, "+") + numberOf(scope, right, "+");
|
|
2018
|
+
case "-":
|
|
2019
|
+
return numberOf(scope, left, "-") - numberOf(scope, right, "-");
|
|
2020
|
+
case "*":
|
|
2021
|
+
return numberOf(scope, left, "*") * numberOf(scope, right, "*");
|
|
2022
|
+
case "/":
|
|
2023
|
+
return numberOf(scope, left, "/") / numberOf(scope, right, "/");
|
|
2024
|
+
case ">":
|
|
2025
|
+
return numberOf(scope, left, ">") > numberOf(scope, right, ">");
|
|
2026
|
+
case "<":
|
|
2027
|
+
return numberOf(scope, left, "<") < numberOf(scope, right, "<");
|
|
2028
|
+
case ">=":
|
|
2029
|
+
return numberOf(scope, left, ">=") >= numberOf(scope, right, ">=");
|
|
2030
|
+
case "<=":
|
|
2031
|
+
return numberOf(scope, left, "<=") <= numberOf(scope, right, "<=");
|
|
2032
|
+
case "==":
|
|
2033
|
+
return left === right;
|
|
2034
|
+
case "!=":
|
|
2035
|
+
return left !== right;
|
|
2036
|
+
case "&&":
|
|
2037
|
+
return Boolean(left) && Boolean(right);
|
|
2038
|
+
case "||":
|
|
2039
|
+
return Boolean(left) || Boolean(right);
|
|
2040
|
+
}
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
var round2 = (value) => Math.round(value * 1e3) / 1e3;
|
|
2045
|
+
function resolveValue(scope, value) {
|
|
2046
|
+
if (value.type !== "expr") {
|
|
2047
|
+
return value;
|
|
2048
|
+
}
|
|
2049
|
+
const results = value.items.map((item) => evaluate(scope, item));
|
|
2050
|
+
if (results.length === 1) {
|
|
2051
|
+
const [only] = results;
|
|
2052
|
+
if (typeof only === "number") {
|
|
2053
|
+
return { type: "number", value: round2(numberOf(scope, only, "a value")) };
|
|
2054
|
+
}
|
|
2055
|
+
if (typeof only === "string") {
|
|
2056
|
+
return { type: "string", value: only };
|
|
2057
|
+
}
|
|
2058
|
+
return { type: "ident", segments: [String(only)] };
|
|
2059
|
+
}
|
|
2060
|
+
return { type: "tuple", values: results.map((result) => round2(numberOf(scope, result, "a tuple"))) };
|
|
2061
|
+
}
|
|
2062
|
+
function propertiesOf(scope, properties) {
|
|
2063
|
+
return properties.map((property) => ({ key: property.key, value: resolveValue(scope, property.value) }));
|
|
2064
|
+
}
|
|
2065
|
+
function entryOf(scope, entry, suffix) {
|
|
2066
|
+
switch (entry.type) {
|
|
2067
|
+
case "property":
|
|
2068
|
+
return {
|
|
2069
|
+
type: "property",
|
|
2070
|
+
property: { key: entry.property.key, value: resolveValue(scope, entry.property.value) }
|
|
2071
|
+
};
|
|
2072
|
+
case "layout":
|
|
2073
|
+
return { type: "layout", layout: { properties: propertiesOf(scope, entry.layout.properties) } };
|
|
2074
|
+
case "style":
|
|
2075
|
+
return { type: "style", style: { ...entry.style, properties: propertiesOf(scope, entry.style.properties) } };
|
|
2076
|
+
case "block":
|
|
2077
|
+
return { type: "block", block: instance(scope, entry.block, suffix) };
|
|
2078
|
+
default:
|
|
2079
|
+
return entry;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
function instance(scope, block2, suffix) {
|
|
2083
|
+
return {
|
|
2084
|
+
...block2,
|
|
2085
|
+
name: `${block2.name}${suffix}`,
|
|
2086
|
+
entries: block2.entries.map((entry) => entryOf(scope, entry, suffix))
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
function propertyOf(block2, key) {
|
|
2090
|
+
for (const entry of block2.entries) {
|
|
2091
|
+
if (entry.type === "property" && entry.property.key === key) {
|
|
2092
|
+
return entry.property.value;
|
|
2093
|
+
}
|
|
2094
|
+
}
|
|
2095
|
+
return void 0;
|
|
2096
|
+
}
|
|
2097
|
+
function numbersOf(block2, key) {
|
|
2098
|
+
for (const entry of block2.entries) {
|
|
2099
|
+
if (entry.type === "property" && entry.property.key === key) {
|
|
2100
|
+
const value = entry.property.value;
|
|
2101
|
+
if (value.type === "number") {
|
|
2102
|
+
return [value.value];
|
|
2103
|
+
}
|
|
2104
|
+
if (value.type === "tuple") {
|
|
2105
|
+
return value.values;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
return void 0;
|
|
2110
|
+
}
|
|
2111
|
+
function expandRepeat(block2) {
|
|
2112
|
+
const scope = { vars: /* @__PURE__ */ new Map(), random: new Random(0), repeat: block2.name };
|
|
2113
|
+
const count = numbersOf(block2, "count")?.[0];
|
|
2114
|
+
const columns = Math.max(1, Math.floor(count ?? numbersOf(block2, "columns")?.[0] ?? 1));
|
|
2115
|
+
const rows = count === void 0 ? Math.max(1, Math.floor(numbersOf(block2, "rows")?.[0] ?? 1)) : 1;
|
|
2116
|
+
const total = columns * rows;
|
|
2117
|
+
if (total > MAX_CELLS) {
|
|
2118
|
+
fail(scope, `${total} cells are too many, the limit is ${MAX_CELLS}`);
|
|
2119
|
+
}
|
|
2120
|
+
const [stepX = 0, stepY = stepX] = numbersOf(block2, "step") ?? [];
|
|
2121
|
+
const [originX = 0, originY = 0] = numbersOf(block2, "origin") ?? [];
|
|
2122
|
+
const seed = numbersOf(block2, "seed")?.[0] ?? 0;
|
|
2123
|
+
const jitter = numbersOf(block2, "jitter")?.[0] ?? 0;
|
|
2124
|
+
const chance = numbersOf(block2, "chance")?.[0] ?? 1;
|
|
2125
|
+
const diagonal = propertyOf(block2, "order")?.type === "ident" && propertyOf(block2, "order").segments[0] === "diagonal";
|
|
2126
|
+
const condition = propertyOf(block2, "where");
|
|
2127
|
+
const helpers = block2.entries.flatMap(
|
|
2128
|
+
(entry) => entry.type === "property" && entry.property.value.type === "expr" && !RESERVED.has(entry.property.key) ? [entry.property] : []
|
|
2129
|
+
);
|
|
2130
|
+
const templates = block2.entries.flatMap((entry) => entry.type === "block" ? [entry.block] : []);
|
|
2131
|
+
if (templates.some((template) => template.kind === "Repeat")) {
|
|
2132
|
+
fail(scope, "a Repeat cannot hold another Repeat");
|
|
2133
|
+
}
|
|
2134
|
+
if (total * Math.max(1, templates.length) > MAX_VALUES) {
|
|
2135
|
+
fail(scope, "too many blocks");
|
|
2136
|
+
}
|
|
2137
|
+
const cells = [];
|
|
2138
|
+
for (let row = 0; row < rows; row++) {
|
|
2139
|
+
for (let col = 0; col < columns; col++) {
|
|
2140
|
+
cells.push([col, row]);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
if (diagonal) {
|
|
2144
|
+
cells.sort((a, b) => a[0] + a[1] - (b[0] + b[1]) || a[0] - b[0]);
|
|
2145
|
+
}
|
|
2146
|
+
const out = [];
|
|
2147
|
+
for (const [col, row] of cells) {
|
|
2148
|
+
{
|
|
2149
|
+
const index = row * columns + col;
|
|
2150
|
+
scope.random = new Random(Math.imul(seed + 1, 2654435761) ^ Math.imul(index + 1, 2246822507));
|
|
2151
|
+
if (chance < 1 && scope.random.next() >= chance) {
|
|
2152
|
+
continue;
|
|
2153
|
+
}
|
|
2154
|
+
const spread = () => jitter > 0 ? (scope.random.next() * 2 - 1) * jitter : 0;
|
|
2155
|
+
scope.vars = /* @__PURE__ */ new Map([
|
|
2156
|
+
["col", col],
|
|
2157
|
+
["row", row],
|
|
2158
|
+
["index", index],
|
|
2159
|
+
["count", total],
|
|
2160
|
+
["columns", columns],
|
|
2161
|
+
["rows", rows],
|
|
2162
|
+
["x", round2(originX + col * stepX + spread())],
|
|
2163
|
+
["y", round2(originY + row * stepY + spread())]
|
|
2164
|
+
]);
|
|
2165
|
+
for (const helper of helpers) {
|
|
2166
|
+
const value = resolveValue(scope, helper.value);
|
|
2167
|
+
if (value.type === "number" || value.type === "string") {
|
|
2168
|
+
scope.vars.set(helper.key, value.value);
|
|
2169
|
+
} else if (value.type === "ident") {
|
|
2170
|
+
scope.vars.set(helper.key, value.segments[0] === "true" ? 1 : 0);
|
|
2171
|
+
} else {
|
|
2172
|
+
fail(scope, `${helper.key} needs a number`);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
if (condition && condition.type === "expr") {
|
|
2176
|
+
const result = condition.items.map((item) => evaluate(scope, item))[0];
|
|
2177
|
+
if (!result) {
|
|
2178
|
+
continue;
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
const suffix = rows === 1 ? `_${col}` : `_${col}_${row}`;
|
|
2182
|
+
for (const template of templates) {
|
|
2183
|
+
out.push(instance(scope, template, suffix));
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
return out;
|
|
2188
|
+
}
|
|
2189
|
+
function expandBlocks(blocks) {
|
|
2190
|
+
return blocks.flatMap((block2) => {
|
|
2191
|
+
if (block2.kind === "Repeat") {
|
|
2192
|
+
return expandRepeat(block2);
|
|
2193
|
+
}
|
|
2194
|
+
if (!block2.entries.some((entry) => entry.type === "block")) {
|
|
2195
|
+
return [block2];
|
|
2196
|
+
}
|
|
2197
|
+
return [
|
|
2198
|
+
{
|
|
2199
|
+
...block2,
|
|
2200
|
+
entries: block2.entries.flatMap(
|
|
2201
|
+
(entry) => entry.type === "block" ? (entry.block.kind === "Repeat" ? expandRepeat(entry.block) : expandBlocks([entry.block])).map((child) => ({
|
|
2202
|
+
type: "block",
|
|
2203
|
+
block: child
|
|
2204
|
+
})) : [entry]
|
|
2205
|
+
)
|
|
2206
|
+
}
|
|
2207
|
+
];
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
function checkNoComputed(blocks) {
|
|
2211
|
+
for (const block2 of blocks) {
|
|
2212
|
+
for (const entry of block2.entries) {
|
|
2213
|
+
const properties = entry.type === "property" ? [entry.property] : entry.type === "layout" ? entry.layout.properties : entry.type === "style" ? entry.style.properties : [];
|
|
2214
|
+
for (const property of properties) {
|
|
2215
|
+
if (property.value.type === "expr") {
|
|
2216
|
+
throw new Error(
|
|
2217
|
+
`${block2.kind} ${block2.name}: ${property.key} is computed, and only a Repeat can work out a computed value`
|
|
2218
|
+
);
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
if (entry.type === "block") {
|
|
2222
|
+
checkNoComputed([entry.block]);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
function expandRepeats(doc) {
|
|
2228
|
+
const has = (blocks) => blocks.some(
|
|
2229
|
+
(block2) => block2.kind === "Repeat" || block2.entries.some((entry) => entry.type === "block" ? has([entry.block]) : false)
|
|
2230
|
+
);
|
|
2231
|
+
if (!has(doc.blocks)) {
|
|
2232
|
+
checkNoComputed(doc.blocks);
|
|
2233
|
+
return doc;
|
|
2234
|
+
}
|
|
2235
|
+
const expanded = { ...doc, blocks: expandBlocks(doc.blocks) };
|
|
2236
|
+
checkNoComputed(expanded.blocks);
|
|
2237
|
+
return expanded;
|
|
2238
|
+
}
|
|
2239
|
+
|
|
1852
2240
|
// src/sflSemantic/ast/valueAccess.ts
|
|
1853
2241
|
function asString(value) {
|
|
1854
2242
|
if (!value) {
|
|
@@ -3153,7 +3541,7 @@ function resolveCanvasState(document) {
|
|
|
3153
3541
|
|
|
3154
3542
|
// src/sflSemantic/sflToCanvasState.ts
|
|
3155
3543
|
function sflToCanvasState(source) {
|
|
3156
|
-
return resolveCanvasState(parseSource(source));
|
|
3544
|
+
return resolveCanvasState(expandRepeats(parseSource(source)));
|
|
3157
3545
|
}
|
|
3158
3546
|
|
|
3159
3547
|
// src/svg/domContract/version.ts
|
|
@@ -5350,6 +5738,6 @@ function localShapePath(type, x, y, width, height) {
|
|
|
5350
5738
|
}
|
|
5351
5739
|
}
|
|
5352
5740
|
|
|
5353
|
-
export { AXIS_COS, AXIS_SIN, BAR_LABEL, CATEGORY_LABEL_ROW, CHART_COLORS, CHART_TITLE_PROP, CHART_TYPES, COMPONENT_CATEGORIES, CORNER_RADIUS_ATTR, DEFAULT_FONT, DEFAULT_HEATMAP_ZONES, DEFAULT_HEX_RADIUS, DEFAULT_ROLLING_NUMBER_STYLE, DEFAULT_ZONE_FILL, DOM_CONTRACT_VERSION, EMPTY_BOUNDS, ISOMETRIC_LABEL_OFFSET_ATTR, ISOMETRIC_SIZE_ATTR, LABEL_WIDTH, LEADER_INSET, PATH_CLOSED_ATTR, PATH_POINTS_ATTR, PATH_POINT_INDEX_ATTR, PATH_TENSION_ATTR, SQUARE_CORNER_ATTR, SYMBOL_BOUNDS_ATTR, SYMBOL_POINTS_ATTR, SYMBOL_TENSION_ATTR, VISIBLE_ISOMETRIC_FACES, angleForAxisValue, axisBands, axisLabelProp, barCategoryCount, barLabelSize, barPath, barShapePath, bottomRoundedRectPath, boxBounds, calculateLinkRoute, canonicalizeSource, categoryProp, chartText, chartTicks, cleanFootprint, clipSegmentToRect, colorWithAlpha, componentRegistryVersion, componentTypes, computeBoxplotStats, contrastTextColor, cornersRoundedRectPath, createPieGeometry, createPieSlicePath, createVerticalErrorWhiskerNode, deriveFaceFills, edgePointToward, elementCenter, ellipsizeToWidth, errorBarRange, estimateTextWidth, extrudeFootprint, finite, flattenPath, formatBarLabel, formatFieldValue, formatRollingNumber, freeformPathData, gapInsetAngle, getComponentDescriptor, getLineMidpoint, heuristicRichMeasure, horizontalRows, interpolateHexColorStops, isBuiltInComponentType, isChartObject, isDimensionObject, isGenericComponent, isHorizontalBar, isIsometricObject, isLightColor, isPathObject, isSwimlaneObject, isometricBounds, isometricFaceCenter, isometricFaces, isometricTopFaceCenter, labelAboveFrame, labelBelowFrame, labelGapDash, labelTilt, leftRoundedRectPath, linePathData, localShapePath, mapChartValue, maxApexCornerRadius, maxPieCornerRadius, paint, parseSource, pathBounds, pathToSymbol, personLabelArea, pieApexRadius, pieArcPoint, pieUsesInnerArc, pillCornerRadius, pillPath, pointAtNormalizedPort, pointAtPort, radarCategoryCount, radarPointAt, radarRadius, radarRadiusForValue, radarSeriesPath, radarValueAtPoint, radarVertexPoint, registerComponentDescriptor, relativeOffsetOnRectangleSide, renderPieLabels, representativeColor, resolveChartShadow, resolvePieRadii, resolveRollingNumberStyle, rightRoundedRectPath, rotatedBounds, roundedBarPath, roundedOrthogonalPathData, roundedPolygonPath, rowTop, ruleAtProp, ruleTextProp, sameHueContrastColor, sameHueTint, segmentedBarPath, seriesColorProp, seriesLabelOffsetXProp, seriesLabelOffsetYProp, seriesLabelProp, seriesValueColorProp, seriesValueProp, sflToCanvasState, shadeFill, stackRank, stackSequence, stackedSegment, symbolToPath, tag, tiltedLabelRoom, tokenizeSource, topRoundedRectPath, wrapText, zoneColorAtValue };
|
|
5354
|
-
//# sourceMappingURL=chunk-
|
|
5355
|
-
//# sourceMappingURL=chunk-
|
|
5741
|
+
export { AXIS_COS, AXIS_SIN, BAR_LABEL, CATEGORY_LABEL_ROW, CHART_COLORS, CHART_TITLE_PROP, CHART_TYPES, COMPONENT_CATEGORIES, CORNER_RADIUS_ATTR, DEFAULT_FONT, DEFAULT_HEATMAP_ZONES, DEFAULT_HEX_RADIUS, DEFAULT_ROLLING_NUMBER_STYLE, DEFAULT_ZONE_FILL, DOM_CONTRACT_VERSION, EMPTY_BOUNDS, ISOMETRIC_LABEL_OFFSET_ATTR, ISOMETRIC_SIZE_ATTR, LABEL_WIDTH, LEADER_INSET, PATH_CLOSED_ATTR, PATH_POINTS_ATTR, PATH_POINT_INDEX_ATTR, PATH_TENSION_ATTR, SQUARE_CORNER_ATTR, SYMBOL_BOUNDS_ATTR, SYMBOL_POINTS_ATTR, SYMBOL_TENSION_ATTR, VISIBLE_ISOMETRIC_FACES, angleForAxisValue, axisBands, axisLabelProp, barCategoryCount, barLabelSize, barPath, barShapePath, bottomRoundedRectPath, boxBounds, calculateLinkRoute, canonicalizeSource, categoryProp, chartText, chartTicks, cleanFootprint, clipSegmentToRect, colorWithAlpha, componentRegistryVersion, componentTypes, computeBoxplotStats, contrastTextColor, cornersRoundedRectPath, createPieGeometry, createPieSlicePath, createVerticalErrorWhiskerNode, deriveFaceFills, edgePointToward, elementCenter, ellipsizeToWidth, errorBarRange, estimateTextWidth, expandRepeats, extrudeFootprint, finite, flattenPath, formatBarLabel, formatFieldValue, formatRollingNumber, freeformPathData, gapInsetAngle, getComponentDescriptor, getLineMidpoint, heuristicRichMeasure, horizontalRows, interpolateHexColorStops, isBuiltInComponentType, isChartObject, isDimensionObject, isGenericComponent, isHorizontalBar, isIsometricObject, isLightColor, isPathObject, isSwimlaneObject, isometricBounds, isometricFaceCenter, isometricFaces, isometricTopFaceCenter, labelAboveFrame, labelBelowFrame, labelGapDash, labelTilt, leftRoundedRectPath, linePathData, localShapePath, mapChartValue, maxApexCornerRadius, maxPieCornerRadius, paint, parseSource, pathBounds, pathToSymbol, personLabelArea, pieApexRadius, pieArcPoint, pieUsesInnerArc, pillCornerRadius, pillPath, pointAtNormalizedPort, pointAtPort, radarCategoryCount, radarPointAt, radarRadius, radarRadiusForValue, radarSeriesPath, radarValueAtPoint, radarVertexPoint, registerComponentDescriptor, relativeOffsetOnRectangleSide, renderPieLabels, representativeColor, resolveChartShadow, resolvePieRadii, resolveRollingNumberStyle, rightRoundedRectPath, rotatedBounds, roundedBarPath, roundedOrthogonalPathData, roundedPolygonPath, rowTop, ruleAtProp, ruleTextProp, sameHueContrastColor, sameHueTint, segmentedBarPath, seriesColorProp, seriesLabelOffsetXProp, seriesLabelOffsetYProp, seriesLabelProp, seriesValueColorProp, seriesValueProp, sflToCanvasState, shadeFill, stackRank, stackSequence, stackedSegment, symbolToPath, tag, tiltedLabelRoom, tokenizeSource, topRoundedRectPath, wrapText, zoneColorAtValue };
|
|
5742
|
+
//# sourceMappingURL=chunk-D2266VBZ.js.map
|
|
5743
|
+
//# sourceMappingURL=chunk-D2266VBZ.js.map
|