stickyflow 0.7.0 → 0.9.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/CHANGELOG.md +23 -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-OWNVXKXN.cjs → chunk-B3YRZVMR.cjs} +23 -23
- package/dist/chunk-B3YRZVMR.cjs.map +1 -0
- package/dist/{chunk-JCRPLPKV.js → chunk-BUVUJMWT.js} +5 -5
- package/dist/chunk-BUVUJMWT.js.map +1 -0
- package/dist/{chunk-ZNHYW47T.js → chunk-CM35H45Z.js} +3 -3
- package/dist/{chunk-ZNHYW47T.js.map → chunk-CM35H45Z.js.map} +1 -1
- package/dist/{chunk-JQK4IGXJ.js → chunk-D2266VBZ.js} +440 -8
- package/dist/chunk-D2266VBZ.js.map +1 -0
- package/dist/{chunk-SDMQRSRW.js → chunk-FS6L462E.js} +455 -136
- package/dist/chunk-FS6L462E.js.map +1 -0
- package/dist/{chunk-EKAWJFJQ.cjs → chunk-OUWGWDJ2.cjs} +15 -15
- package/dist/{chunk-EKAWJFJQ.cjs.map → chunk-OUWGWDJ2.cjs.map} +1 -1
- package/dist/{chunk-KXYSO6GC.cjs → chunk-QL7MNEMT.cjs} +444 -7
- package/dist/chunk-QL7MNEMT.cjs.map +1 -0
- package/dist/{chunk-BUOWM3LC.cjs → chunk-SQBF2BKT.cjs} +382 -73
- package/dist/chunk-SQBF2BKT.cjs.map +1 -0
- package/dist/{chunk-A73UJ5AQ.cjs → chunk-YSXD5IVZ.cjs} +1074 -755
- package/dist/chunk-YSXD5IVZ.cjs.map +1 -0
- package/dist/{chunk-MUKIGLR5.js → chunk-ZCGZJBAT.js} +353 -44
- package/dist/chunk-ZCGZJBAT.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 +268 -235
- 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 +44 -11
- package/dist/interaction/index.js.map +1 -1
- package/dist/{render-BU2uYzjG.d.cts → render-DU4lYbRl.d.cts} +29 -11
- package/dist/{render-BU2uYzjG.d.ts → render-DU4lYbRl.d.ts} +29 -11
- package/dist/{runtime-B7KiTmn8.d.cts → runtime-DG8X3Fwf.d.cts} +2 -2
- package/dist/{runtime-BPzyD-Nd.d.ts → runtime-kqD1RS17.d.ts} +2 -2
- package/dist/{runtimeTypes-DalvhScn.d.ts → runtimeTypes-CvjlBZds.d.cts} +7 -3
- package/dist/{runtimeTypes-BIP70z72.d.cts → runtimeTypes-vRaHOIHi.d.ts} +7 -3
- package/dist/stickyflow-diagram.global.js +294 -39
- package/dist/stickyflow-diagram.global.js.map +1 -1
- package/dist/{types-D_2NZ6lL.d.cts → types-B5jrEEcF.d.cts} +1 -1
- package/dist/{types-DMWs27Hn.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-A73UJ5AQ.cjs.map +0 -1
- package/dist/chunk-BUOWM3LC.cjs.map +0 -1
- package/dist/chunk-JCRPLPKV.js.map +0 -1
- package/dist/chunk-JQK4IGXJ.js.map +0 -1
- package/dist/chunk-KXYSO6GC.cjs.map +0 -1
- package/dist/chunk-MUKIGLR5.js.map +0 -1
- package/dist/chunk-OWNVXKXN.cjs.map +0 -1
- package/dist/chunk-SDMQRSRW.js.map +0 -1
|
@@ -1069,7 +1069,8 @@ var NAMED_BLOCK_KINDS = [
|
|
|
1069
1069
|
"Net",
|
|
1070
1070
|
"Symbol",
|
|
1071
1071
|
"Port",
|
|
1072
|
-
"DataSource"
|
|
1072
|
+
"DataSource",
|
|
1073
|
+
"Repeat"
|
|
1073
1074
|
];
|
|
1074
1075
|
var SIDES = ["top", "bottom", "left", "right"];
|
|
1075
1076
|
var isSide = (s) => SIDES.includes(s);
|
|
@@ -1128,7 +1129,43 @@ function parseList(cursor) {
|
|
|
1128
1129
|
cursor.expect("rbracket", "']'");
|
|
1129
1130
|
return { type: "list", values };
|
|
1130
1131
|
}
|
|
1132
|
+
var ARITHMETIC = /* @__PURE__ */ new Set(["+", "-", "*", "/", ">", "<", ">=", "<=", "==", "!=", "&&", "||"]);
|
|
1133
|
+
function startsComputed(cursor) {
|
|
1134
|
+
const first = cursor.peek();
|
|
1135
|
+
if (first.type === "op" && first.value === "-") {
|
|
1136
|
+
return true;
|
|
1137
|
+
}
|
|
1138
|
+
if (first.type !== "number" && first.type !== "ident" && first.type !== "lparen") {
|
|
1139
|
+
return false;
|
|
1140
|
+
}
|
|
1141
|
+
for (let offset = 0; ; offset++) {
|
|
1142
|
+
const token = cursor.peek(offset);
|
|
1143
|
+
if (token.type === "newline" || token.type === "semi" || token.type === "rbrace" || token.type === "eof") {
|
|
1144
|
+
return false;
|
|
1145
|
+
}
|
|
1146
|
+
if (token.type === "lparen" || token.type === "op" && ARITHMETIC.has(token.value)) {
|
|
1147
|
+
return true;
|
|
1148
|
+
}
|
|
1149
|
+
if (token.type === "ident" && cursor.peek(offset - 1).type === "comma") {
|
|
1150
|
+
return true;
|
|
1151
|
+
}
|
|
1152
|
+
if (offset === 0 && token.type === "ident" && cursor.peek(1).type === "comma") {
|
|
1153
|
+
return true;
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
function parseComputed(cursor) {
|
|
1158
|
+
const items = [parseExpression(cursor)];
|
|
1159
|
+
while (cursor.at("comma")) {
|
|
1160
|
+
cursor.next();
|
|
1161
|
+
items.push(parseExpression(cursor));
|
|
1162
|
+
}
|
|
1163
|
+
return { type: "expr", items };
|
|
1164
|
+
}
|
|
1131
1165
|
function parseValue(cursor, allowTuple = true) {
|
|
1166
|
+
if (allowTuple && startsComputed(cursor)) {
|
|
1167
|
+
return parseComputed(cursor);
|
|
1168
|
+
}
|
|
1132
1169
|
const token = cursor.peek();
|
|
1133
1170
|
switch (token.type) {
|
|
1134
1171
|
case "string":
|
|
@@ -1594,6 +1631,8 @@ function emitValue(value) {
|
|
|
1594
1631
|
return `[${value.values.map(emitValue).join(", ")}]`;
|
|
1595
1632
|
case "ident":
|
|
1596
1633
|
return value.segments.join(".");
|
|
1634
|
+
case "expr":
|
|
1635
|
+
return value.items.map((item) => emitExpression(item)).join(", ");
|
|
1597
1636
|
case "endpoint": {
|
|
1598
1637
|
let output = value.segments.join(".");
|
|
1599
1638
|
if (value.side) {
|
|
@@ -1673,6 +1712,8 @@ var STYLE_ORDER = [
|
|
|
1673
1712
|
"dash",
|
|
1674
1713
|
"shadow",
|
|
1675
1714
|
"opacity",
|
|
1715
|
+
"blur",
|
|
1716
|
+
"blend",
|
|
1676
1717
|
"icon",
|
|
1677
1718
|
"route",
|
|
1678
1719
|
"marker",
|
|
@@ -1851,6 +1892,353 @@ function isSwimlaneObject(canvasObject) {
|
|
|
1851
1892
|
return canvasObject.objectType === "swimlane" && canvasObject.swimlane !== void 0;
|
|
1852
1893
|
}
|
|
1853
1894
|
|
|
1895
|
+
// src/sflLanguage/expansion/repeat.ts
|
|
1896
|
+
var RESERVED = /* @__PURE__ */ new Set(["columns", "rows", "count", "step", "origin", "seed", "jitter", "chance", "order", "where"]);
|
|
1897
|
+
var MAX_CELLS = 2e4;
|
|
1898
|
+
var MAX_VALUES = 1e6;
|
|
1899
|
+
var Random = class {
|
|
1900
|
+
state;
|
|
1901
|
+
constructor(seed) {
|
|
1902
|
+
this.state = seed >>> 0;
|
|
1903
|
+
}
|
|
1904
|
+
// mulberry32: a small generator that gives the same numbers for the same seed, on every machine.
|
|
1905
|
+
next() {
|
|
1906
|
+
this.state = this.state + 1831565813 >>> 0;
|
|
1907
|
+
let t = this.state;
|
|
1908
|
+
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
1909
|
+
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
1910
|
+
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1911
|
+
}
|
|
1912
|
+
};
|
|
1913
|
+
function fail(scope, message) {
|
|
1914
|
+
throw new Error(`Repeat ${scope.repeat}: ${message}`);
|
|
1915
|
+
}
|
|
1916
|
+
function numberOf(scope, value, what) {
|
|
1917
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
1918
|
+
fail(scope, `${what} needs a number`);
|
|
1919
|
+
}
|
|
1920
|
+
return value;
|
|
1921
|
+
}
|
|
1922
|
+
function rgbOf(scope, value) {
|
|
1923
|
+
const match = typeof value === "string" ? /^#([0-9a-f]{6})$/i.exec(value) : null;
|
|
1924
|
+
if (!match) {
|
|
1925
|
+
fail(scope, 'a color has to be written as "#rrggbb"');
|
|
1926
|
+
}
|
|
1927
|
+
const n = Number.parseInt(match[1], 16);
|
|
1928
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1929
|
+
}
|
|
1930
|
+
var hexOf = (rgb) => `#${rgb.map(
|
|
1931
|
+
(channel) => Math.round(Math.max(0, Math.min(255, channel))).toString(16).padStart(2, "0")
|
|
1932
|
+
).join("")}`;
|
|
1933
|
+
function callFunction(scope, name, args) {
|
|
1934
|
+
const number = (index) => numberOf(scope, args[index], `${name}()`);
|
|
1935
|
+
switch (name) {
|
|
1936
|
+
case "random": {
|
|
1937
|
+
if (args.length === 0) {
|
|
1938
|
+
return scope.random.next();
|
|
1939
|
+
}
|
|
1940
|
+
const low = args.length === 1 ? 0 : number(0);
|
|
1941
|
+
const high = args.length === 1 ? number(0) : number(1);
|
|
1942
|
+
return low + scope.random.next() * (high - low);
|
|
1943
|
+
}
|
|
1944
|
+
case "pick": {
|
|
1945
|
+
if (args.length === 0) {
|
|
1946
|
+
fail(scope, "pick() needs at least one value");
|
|
1947
|
+
}
|
|
1948
|
+
return args[Math.floor(scope.random.next() * args.length)];
|
|
1949
|
+
}
|
|
1950
|
+
case "exp":
|
|
1951
|
+
return Math.exp(number(0));
|
|
1952
|
+
case "pow":
|
|
1953
|
+
return number(0) ** number(1);
|
|
1954
|
+
case "dist":
|
|
1955
|
+
return Math.hypot(number(0) - number(2), number(1) - number(3));
|
|
1956
|
+
case "mix": {
|
|
1957
|
+
const from = rgbOf(scope, args[0]);
|
|
1958
|
+
const to = rgbOf(scope, args[1]);
|
|
1959
|
+
const amount = Math.max(0, Math.min(1, number(2)));
|
|
1960
|
+
return hexOf(from.map((channel, index) => channel + (to[index] - channel) * amount));
|
|
1961
|
+
}
|
|
1962
|
+
case "shade": {
|
|
1963
|
+
const factor = number(1);
|
|
1964
|
+
return hexOf(rgbOf(scope, args[0]).map((channel) => channel * factor));
|
|
1965
|
+
}
|
|
1966
|
+
case "floor":
|
|
1967
|
+
return Math.floor(number(0));
|
|
1968
|
+
case "ceil":
|
|
1969
|
+
return Math.ceil(number(0));
|
|
1970
|
+
case "round":
|
|
1971
|
+
return Math.round(number(0));
|
|
1972
|
+
case "abs":
|
|
1973
|
+
return Math.abs(number(0));
|
|
1974
|
+
case "sqrt":
|
|
1975
|
+
return Math.sqrt(number(0));
|
|
1976
|
+
case "sin":
|
|
1977
|
+
return Math.sin(number(0));
|
|
1978
|
+
case "cos":
|
|
1979
|
+
return Math.cos(number(0));
|
|
1980
|
+
case "min":
|
|
1981
|
+
return Math.min(...args.map((_, index) => number(index)));
|
|
1982
|
+
case "max":
|
|
1983
|
+
return Math.max(...args.map((_, index) => number(index)));
|
|
1984
|
+
case "when":
|
|
1985
|
+
return args[0] ? args[1] : args[2];
|
|
1986
|
+
default:
|
|
1987
|
+
return fail(scope, `unknown function ${name}()`);
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
function evaluate(scope, expr) {
|
|
1991
|
+
switch (expr.kind) {
|
|
1992
|
+
case "number":
|
|
1993
|
+
case "string":
|
|
1994
|
+
case "boolean":
|
|
1995
|
+
return expr.value;
|
|
1996
|
+
case "ref": {
|
|
1997
|
+
const name = expr.path.join(".");
|
|
1998
|
+
const value = scope.vars.get(name);
|
|
1999
|
+
if (value === void 0) {
|
|
2000
|
+
fail(scope, `unknown name ${name}`);
|
|
2001
|
+
}
|
|
2002
|
+
return value;
|
|
2003
|
+
}
|
|
2004
|
+
case "unary": {
|
|
2005
|
+
const operand = evaluate(scope, expr.operand);
|
|
2006
|
+
return expr.operator === "-" ? -numberOf(scope, operand, "a minus") : !operand;
|
|
2007
|
+
}
|
|
2008
|
+
case "call":
|
|
2009
|
+
return callFunction(
|
|
2010
|
+
scope,
|
|
2011
|
+
expr.callee.join("."),
|
|
2012
|
+
expr.args.map((arg) => evaluate(scope, arg))
|
|
2013
|
+
);
|
|
2014
|
+
case "binary": {
|
|
2015
|
+
const left = evaluate(scope, expr.left);
|
|
2016
|
+
const right = evaluate(scope, expr.right);
|
|
2017
|
+
switch (expr.operator) {
|
|
2018
|
+
case "+":
|
|
2019
|
+
return typeof left === "string" || typeof right === "string" ? `${left}${right}` : 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 numberOf(scope, left, "<=") <= numberOf(scope, right, "<=");
|
|
2034
|
+
case "==":
|
|
2035
|
+
return left === right;
|
|
2036
|
+
case "!=":
|
|
2037
|
+
return left !== right;
|
|
2038
|
+
case "&&":
|
|
2039
|
+
return Boolean(left) && Boolean(right);
|
|
2040
|
+
case "||":
|
|
2041
|
+
return Boolean(left) || Boolean(right);
|
|
2042
|
+
}
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
}
|
|
2046
|
+
var round2 = (value) => Math.round(value * 1e3) / 1e3;
|
|
2047
|
+
function resolveValue(scope, value) {
|
|
2048
|
+
if (value.type !== "expr") {
|
|
2049
|
+
return value;
|
|
2050
|
+
}
|
|
2051
|
+
const results = value.items.map((item) => evaluate(scope, item));
|
|
2052
|
+
if (results.length === 1) {
|
|
2053
|
+
const [only] = results;
|
|
2054
|
+
if (typeof only === "number") {
|
|
2055
|
+
return { type: "number", value: round2(numberOf(scope, only, "a value")) };
|
|
2056
|
+
}
|
|
2057
|
+
if (typeof only === "string") {
|
|
2058
|
+
return { type: "string", value: only };
|
|
2059
|
+
}
|
|
2060
|
+
return { type: "ident", segments: [String(only)] };
|
|
2061
|
+
}
|
|
2062
|
+
return { type: "tuple", values: results.map((result) => round2(numberOf(scope, result, "a tuple"))) };
|
|
2063
|
+
}
|
|
2064
|
+
function propertiesOf(scope, properties) {
|
|
2065
|
+
return properties.map((property) => ({ key: property.key, value: resolveValue(scope, property.value) }));
|
|
2066
|
+
}
|
|
2067
|
+
function entryOf(scope, entry, suffix) {
|
|
2068
|
+
switch (entry.type) {
|
|
2069
|
+
case "property":
|
|
2070
|
+
return {
|
|
2071
|
+
type: "property",
|
|
2072
|
+
property: { key: entry.property.key, value: resolveValue(scope, entry.property.value) }
|
|
2073
|
+
};
|
|
2074
|
+
case "layout":
|
|
2075
|
+
return { type: "layout", layout: { properties: propertiesOf(scope, entry.layout.properties) } };
|
|
2076
|
+
case "style":
|
|
2077
|
+
return { type: "style", style: { ...entry.style, properties: propertiesOf(scope, entry.style.properties) } };
|
|
2078
|
+
case "block":
|
|
2079
|
+
return { type: "block", block: instance(scope, entry.block, suffix) };
|
|
2080
|
+
default:
|
|
2081
|
+
return entry;
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
2084
|
+
function instance(scope, block2, suffix) {
|
|
2085
|
+
return {
|
|
2086
|
+
...block2,
|
|
2087
|
+
name: `${block2.name}${suffix}`,
|
|
2088
|
+
entries: block2.entries.map((entry) => entryOf(scope, entry, suffix))
|
|
2089
|
+
};
|
|
2090
|
+
}
|
|
2091
|
+
function propertyOf(block2, key) {
|
|
2092
|
+
for (const entry of block2.entries) {
|
|
2093
|
+
if (entry.type === "property" && entry.property.key === key) {
|
|
2094
|
+
return entry.property.value;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
return void 0;
|
|
2098
|
+
}
|
|
2099
|
+
function numbersOf(block2, key) {
|
|
2100
|
+
for (const entry of block2.entries) {
|
|
2101
|
+
if (entry.type === "property" && entry.property.key === key) {
|
|
2102
|
+
const value = entry.property.value;
|
|
2103
|
+
if (value.type === "number") {
|
|
2104
|
+
return [value.value];
|
|
2105
|
+
}
|
|
2106
|
+
if (value.type === "tuple") {
|
|
2107
|
+
return value.values;
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
return void 0;
|
|
2112
|
+
}
|
|
2113
|
+
function expandRepeat(block2) {
|
|
2114
|
+
const scope = { vars: /* @__PURE__ */ new Map(), random: new Random(0), repeat: block2.name };
|
|
2115
|
+
const count = numbersOf(block2, "count")?.[0];
|
|
2116
|
+
const columns = Math.max(1, Math.floor(count ?? numbersOf(block2, "columns")?.[0] ?? 1));
|
|
2117
|
+
const rows = count === void 0 ? Math.max(1, Math.floor(numbersOf(block2, "rows")?.[0] ?? 1)) : 1;
|
|
2118
|
+
const total = columns * rows;
|
|
2119
|
+
if (total > MAX_CELLS) {
|
|
2120
|
+
fail(scope, `${total} cells are too many, the limit is ${MAX_CELLS}`);
|
|
2121
|
+
}
|
|
2122
|
+
const [stepX = 0, stepY = stepX] = numbersOf(block2, "step") ?? [];
|
|
2123
|
+
const [originX = 0, originY = 0] = numbersOf(block2, "origin") ?? [];
|
|
2124
|
+
const seed = numbersOf(block2, "seed")?.[0] ?? 0;
|
|
2125
|
+
const jitter = numbersOf(block2, "jitter")?.[0] ?? 0;
|
|
2126
|
+
const chance = numbersOf(block2, "chance")?.[0] ?? 1;
|
|
2127
|
+
const diagonal = propertyOf(block2, "order")?.type === "ident" && propertyOf(block2, "order").segments[0] === "diagonal";
|
|
2128
|
+
const condition = propertyOf(block2, "where");
|
|
2129
|
+
const helpers = block2.entries.flatMap(
|
|
2130
|
+
(entry) => entry.type === "property" && entry.property.value.type === "expr" && !RESERVED.has(entry.property.key) ? [entry.property] : []
|
|
2131
|
+
);
|
|
2132
|
+
const templates = block2.entries.flatMap((entry) => entry.type === "block" ? [entry.block] : []);
|
|
2133
|
+
if (templates.some((template) => template.kind === "Repeat")) {
|
|
2134
|
+
fail(scope, "a Repeat cannot hold another Repeat");
|
|
2135
|
+
}
|
|
2136
|
+
if (total * Math.max(1, templates.length) > MAX_VALUES) {
|
|
2137
|
+
fail(scope, "too many blocks");
|
|
2138
|
+
}
|
|
2139
|
+
const cells = [];
|
|
2140
|
+
for (let row = 0; row < rows; row++) {
|
|
2141
|
+
for (let col = 0; col < columns; col++) {
|
|
2142
|
+
cells.push([col, row]);
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
if (diagonal) {
|
|
2146
|
+
cells.sort((a, b) => a[0] + a[1] - (b[0] + b[1]) || a[0] - b[0]);
|
|
2147
|
+
}
|
|
2148
|
+
const out = [];
|
|
2149
|
+
for (const [col, row] of cells) {
|
|
2150
|
+
{
|
|
2151
|
+
const index = row * columns + col;
|
|
2152
|
+
scope.random = new Random(Math.imul(seed + 1, 2654435761) ^ Math.imul(index + 1, 2246822507));
|
|
2153
|
+
if (chance < 1 && scope.random.next() >= chance) {
|
|
2154
|
+
continue;
|
|
2155
|
+
}
|
|
2156
|
+
const spread = () => jitter > 0 ? (scope.random.next() * 2 - 1) * jitter : 0;
|
|
2157
|
+
scope.vars = /* @__PURE__ */ new Map([
|
|
2158
|
+
["col", col],
|
|
2159
|
+
["row", row],
|
|
2160
|
+
["index", index],
|
|
2161
|
+
["count", total],
|
|
2162
|
+
["columns", columns],
|
|
2163
|
+
["rows", rows],
|
|
2164
|
+
["x", round2(originX + col * stepX + spread())],
|
|
2165
|
+
["y", round2(originY + row * stepY + spread())]
|
|
2166
|
+
]);
|
|
2167
|
+
for (const helper of helpers) {
|
|
2168
|
+
const value = resolveValue(scope, helper.value);
|
|
2169
|
+
if (value.type === "number" || value.type === "string") {
|
|
2170
|
+
scope.vars.set(helper.key, value.value);
|
|
2171
|
+
} else if (value.type === "ident") {
|
|
2172
|
+
scope.vars.set(helper.key, value.segments[0] === "true" ? 1 : 0);
|
|
2173
|
+
} else {
|
|
2174
|
+
fail(scope, `${helper.key} needs a number`);
|
|
2175
|
+
}
|
|
2176
|
+
}
|
|
2177
|
+
if (condition && condition.type === "expr") {
|
|
2178
|
+
const result = condition.items.map((item) => evaluate(scope, item))[0];
|
|
2179
|
+
if (!result) {
|
|
2180
|
+
continue;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
const suffix = rows === 1 ? `_${col}` : `_${col}_${row}`;
|
|
2184
|
+
for (const template of templates) {
|
|
2185
|
+
out.push(instance(scope, template, suffix));
|
|
2186
|
+
}
|
|
2187
|
+
}
|
|
2188
|
+
}
|
|
2189
|
+
return out;
|
|
2190
|
+
}
|
|
2191
|
+
function expandBlocks(blocks) {
|
|
2192
|
+
return blocks.flatMap((block2) => {
|
|
2193
|
+
if (block2.kind === "Repeat") {
|
|
2194
|
+
return expandRepeat(block2);
|
|
2195
|
+
}
|
|
2196
|
+
if (!block2.entries.some((entry) => entry.type === "block")) {
|
|
2197
|
+
return [block2];
|
|
2198
|
+
}
|
|
2199
|
+
return [
|
|
2200
|
+
{
|
|
2201
|
+
...block2,
|
|
2202
|
+
entries: block2.entries.flatMap(
|
|
2203
|
+
(entry) => entry.type === "block" ? (entry.block.kind === "Repeat" ? expandRepeat(entry.block) : expandBlocks([entry.block])).map((child) => ({
|
|
2204
|
+
type: "block",
|
|
2205
|
+
block: child
|
|
2206
|
+
})) : [entry]
|
|
2207
|
+
)
|
|
2208
|
+
}
|
|
2209
|
+
];
|
|
2210
|
+
});
|
|
2211
|
+
}
|
|
2212
|
+
function checkNoComputed(blocks) {
|
|
2213
|
+
for (const block2 of blocks) {
|
|
2214
|
+
for (const entry of block2.entries) {
|
|
2215
|
+
const properties = entry.type === "property" ? [entry.property] : entry.type === "layout" ? entry.layout.properties : entry.type === "style" ? entry.style.properties : [];
|
|
2216
|
+
for (const property of properties) {
|
|
2217
|
+
if (property.value.type === "expr") {
|
|
2218
|
+
throw new Error(
|
|
2219
|
+
`${block2.kind} ${block2.name}: ${property.key} is computed, and only a Repeat can work out a computed value`
|
|
2220
|
+
);
|
|
2221
|
+
}
|
|
2222
|
+
}
|
|
2223
|
+
if (entry.type === "block") {
|
|
2224
|
+
checkNoComputed([entry.block]);
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
}
|
|
2229
|
+
function expandRepeats(doc) {
|
|
2230
|
+
const has = (blocks) => blocks.some(
|
|
2231
|
+
(block2) => block2.kind === "Repeat" || block2.entries.some((entry) => entry.type === "block" ? has([entry.block]) : false)
|
|
2232
|
+
);
|
|
2233
|
+
if (!has(doc.blocks)) {
|
|
2234
|
+
checkNoComputed(doc.blocks);
|
|
2235
|
+
return doc;
|
|
2236
|
+
}
|
|
2237
|
+
const expanded = { ...doc, blocks: expandBlocks(doc.blocks) };
|
|
2238
|
+
checkNoComputed(expanded.blocks);
|
|
2239
|
+
return expanded;
|
|
2240
|
+
}
|
|
2241
|
+
|
|
1854
2242
|
// src/sflSemantic/ast/valueAccess.ts
|
|
1855
2243
|
function asString(value) {
|
|
1856
2244
|
if (!value) {
|
|
@@ -3155,7 +3543,7 @@ function resolveCanvasState(document) {
|
|
|
3155
3543
|
|
|
3156
3544
|
// src/sflSemantic/sflToCanvasState.ts
|
|
3157
3545
|
function sflToCanvasState(source) {
|
|
3158
|
-
return resolveCanvasState(parseSource(source));
|
|
3546
|
+
return resolveCanvasState(expandRepeats(parseSource(source)));
|
|
3159
3547
|
}
|
|
3160
3548
|
|
|
3161
3549
|
// src/svg/domContract/version.ts
|
|
@@ -3164,9 +3552,9 @@ var DOM_CONTRACT_VERSION = 1;
|
|
|
3164
3552
|
// src/model/geometry/ports/rectangleCoordinates.ts
|
|
3165
3553
|
var DEGREES_TO_RADIANS = Math.PI / 180;
|
|
3166
3554
|
function rotatePoint(point, degrees) {
|
|
3167
|
-
const
|
|
3168
|
-
const cosine = Math.cos(
|
|
3169
|
-
const sine = Math.sin(
|
|
3555
|
+
const radians2 = degrees * DEGREES_TO_RADIANS;
|
|
3556
|
+
const cosine = Math.cos(radians2);
|
|
3557
|
+
const sine = Math.sin(radians2);
|
|
3170
3558
|
return { x: point.x * cosine - point.y * sine, y: point.x * sine + point.y * cosine };
|
|
3171
3559
|
}
|
|
3172
3560
|
function rectangleCenter(rectangle) {
|
|
@@ -4637,6 +5025,50 @@ function rowTop(rows, plot, index) {
|
|
|
4637
5025
|
return plot.y + index * rows.slotHeight + rows.groupGap / 2 + rows.offset;
|
|
4638
5026
|
}
|
|
4639
5027
|
|
|
5028
|
+
// src/renderScene/charts/primitives/labelTilt.ts
|
|
5029
|
+
function labelTilt(chart) {
|
|
5030
|
+
return Math.min(90, Math.max(0, finite(chart.axisLabelAngle, 0)));
|
|
5031
|
+
}
|
|
5032
|
+
var radians = (degrees) => degrees * Math.PI / 180;
|
|
5033
|
+
function labelFontSize(chart) {
|
|
5034
|
+
return Math.max(9, finite(chart.axisFontSize ?? chart.fontSize, 12));
|
|
5035
|
+
}
|
|
5036
|
+
function tiltedLabelRoom(chart, labels, tilt) {
|
|
5037
|
+
const fontSize = labelFontSize(chart);
|
|
5038
|
+
const widest = Math.max(0, ...labels.map((label) => estimateTextWidth(label, fontSize, false)));
|
|
5039
|
+
return Math.ceil(widest * Math.sin(radians(tilt)) + (fontSize + 2) * Math.cos(radians(tilt)));
|
|
5040
|
+
}
|
|
5041
|
+
function labelAboveFrame(chart, label, tilt, anchor) {
|
|
5042
|
+
const fontSize = labelFontSize(chart);
|
|
5043
|
+
const height = fontSize + 2;
|
|
5044
|
+
const width = Math.ceil(estimateTextWidth(label, fontSize, false)) + 4;
|
|
5045
|
+
const angle = radians(tilt);
|
|
5046
|
+
return {
|
|
5047
|
+
frame: {
|
|
5048
|
+
x: anchor.x - height / 2 * Math.sin(angle),
|
|
5049
|
+
y: anchor.y - height / 2 * Math.cos(angle),
|
|
5050
|
+
width,
|
|
5051
|
+
height
|
|
5052
|
+
},
|
|
5053
|
+
rotation: -tilt
|
|
5054
|
+
};
|
|
5055
|
+
}
|
|
5056
|
+
function labelBelowFrame(chart, label, tilt, anchor) {
|
|
5057
|
+
const fontSize = labelFontSize(chart);
|
|
5058
|
+
const height = fontSize + 2;
|
|
5059
|
+
const width = Math.ceil(estimateTextWidth(label, fontSize, false)) + 4;
|
|
5060
|
+
const angle = radians(tilt);
|
|
5061
|
+
return {
|
|
5062
|
+
frame: {
|
|
5063
|
+
x: anchor.x - (width * Math.cos(angle) + height / 2 * Math.sin(angle)),
|
|
5064
|
+
y: anchor.y + width * Math.sin(angle) - height / 2 * Math.cos(angle),
|
|
5065
|
+
width,
|
|
5066
|
+
height
|
|
5067
|
+
},
|
|
5068
|
+
rotation: -tilt
|
|
5069
|
+
};
|
|
5070
|
+
}
|
|
5071
|
+
|
|
4640
5072
|
// src/renderScene/charts/primitives/segments.ts
|
|
4641
5073
|
function segmentedBarPath(frame, orientation, count, gap, radius, fraction, snap) {
|
|
4642
5074
|
const horizontal = orientation === "horizontal";
|
|
@@ -5368,6 +5800,7 @@ exports.elementCenter = elementCenter;
|
|
|
5368
5800
|
exports.ellipsizeToWidth = ellipsizeToWidth;
|
|
5369
5801
|
exports.errorBarRange = errorBarRange;
|
|
5370
5802
|
exports.estimateTextWidth = estimateTextWidth;
|
|
5803
|
+
exports.expandRepeats = expandRepeats;
|
|
5371
5804
|
exports.extrudeFootprint = extrudeFootprint;
|
|
5372
5805
|
exports.finite = finite;
|
|
5373
5806
|
exports.flattenPath = flattenPath;
|
|
@@ -5394,7 +5827,10 @@ exports.isometricBounds = isometricBounds;
|
|
|
5394
5827
|
exports.isometricFaceCenter = isometricFaceCenter;
|
|
5395
5828
|
exports.isometricFaces = isometricFaces;
|
|
5396
5829
|
exports.isometricTopFaceCenter = isometricTopFaceCenter;
|
|
5830
|
+
exports.labelAboveFrame = labelAboveFrame;
|
|
5831
|
+
exports.labelBelowFrame = labelBelowFrame;
|
|
5397
5832
|
exports.labelGapDash = labelGapDash;
|
|
5833
|
+
exports.labelTilt = labelTilt;
|
|
5398
5834
|
exports.leftRoundedRectPath = leftRoundedRectPath;
|
|
5399
5835
|
exports.linePathData = linePathData;
|
|
5400
5836
|
exports.localShapePath = localShapePath;
|
|
@@ -5451,9 +5887,10 @@ exports.stackSequence = stackSequence;
|
|
|
5451
5887
|
exports.stackedSegment = stackedSegment;
|
|
5452
5888
|
exports.symbolToPath = symbolToPath;
|
|
5453
5889
|
exports.tag = tag;
|
|
5890
|
+
exports.tiltedLabelRoom = tiltedLabelRoom;
|
|
5454
5891
|
exports.tokenizeSource = tokenizeSource;
|
|
5455
5892
|
exports.topRoundedRectPath = topRoundedRectPath;
|
|
5456
5893
|
exports.wrapText = wrapText;
|
|
5457
5894
|
exports.zoneColorAtValue = zoneColorAtValue;
|
|
5458
|
-
//# sourceMappingURL=chunk-
|
|
5459
|
-
//# sourceMappingURL=chunk-
|
|
5895
|
+
//# sourceMappingURL=chunk-QL7MNEMT.cjs.map
|
|
5896
|
+
//# sourceMappingURL=chunk-QL7MNEMT.cjs.map
|