@swirly/renderer 0.17.2 → 0.18.1-alpha.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/.tsbuildinfo +1 -1667
- package/dist/arrow.js +6 -5
- package/dist/arrow.js.map +1 -1
- package/dist/decoration/barrier.js +5 -4
- package/dist/decoration/barrier.js.map +1 -1
- package/dist/decoration/index.js +2 -1
- package/dist/decoration/index.js.map +1 -1
- package/dist/decoration/range.js +5 -4
- package/dist/decoration/range.js.map +1 -1
- package/dist/index.js +7 -7
- package/dist/index.js.map +1 -1
- package/dist/message/complete.js +4 -4
- package/dist/message/complete.js.map +1 -1
- package/dist/message/error.js +5 -5
- package/dist/message/error.js.map +1 -1
- package/dist/message/index.js +2 -1
- package/dist/message/index.js.map +1 -1
- package/dist/message/non-stream.js +1 -1
- package/dist/message/non-stream.js.map +1 -1
- package/dist/message/scalar.js +8 -8
- package/dist/message/scalar.js.map +1 -1
- package/dist/message/stream.js +7 -7
- package/dist/message/stream.js.map +1 -1
- package/dist/operator.js +6 -5
- package/dist/operator.js.map +1 -1
- package/dist/stream-factory.d.ts +1 -1
- package/dist/stream-factory.js +16 -11
- package/dist/stream-factory.js.map +1 -1
- package/dist/stream.js +9 -8
- package/dist/stream.js.map +1 -1
- package/dist/util/create-element.d.ts +1 -3
- package/dist/util/create-element.js +2 -1
- package/dist/util/create-element.js.map +1 -1
- package/dist/util/degrees-to-radians.js +2 -1
- package/dist/util/degrees-to-radians.js.map +1 -1
- package/dist/util/geometry.js +18 -13
- package/dist/util/geometry.js.map +1 -1
- package/dist/util/hex-to-dec.js +2 -1
- package/dist/util/hex-to-dec.js.map +1 -1
- package/dist/util/merge-styles.js +3 -2
- package/dist/util/merge-styles.js.map +1 -1
- package/dist/util/notification-kind.js +4 -3
- package/dist/util/notification-kind.js.map +1 -1
- package/dist/util/string-to-color.js +4 -3
- package/dist/util/string-to-color.js.map +1 -1
- package/dist/util/transform.js +8 -5
- package/dist/util/transform.js.map +1 -1
- package/package.json +6 -6
- package/src/decoration/barrier.ts +2 -4
- package/src/decoration/index.ts +1 -1
- package/src/index.ts +2 -2
- package/src/message/non-stream.ts +1 -1
- package/src/message/scalar.ts +1 -1
- package/src/message/stream.ts +2 -2
- package/src/stream-factory.ts +85 -74
- package/src/stream.ts +1 -1
- package/src/util/create-element.ts +1 -1
- package/src/util/geometry.ts +4 -4
- package/src/util/merge-styles.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createElement = void 0;
|
|
4
|
-
|
|
4
|
+
const createElement = (document, name, attrs = {}, text = '') => {
|
|
5
5
|
const $el = document.createElementNS('http://www.w3.org/2000/svg', name);
|
|
6
6
|
for (const [name, value] of Object.entries(attrs)) {
|
|
7
7
|
$el.setAttribute(name, String(value));
|
|
@@ -11,4 +11,5 @@ exports.createElement = (document, name, attrs = {}, text = '') => {
|
|
|
11
11
|
}
|
|
12
12
|
return $el;
|
|
13
13
|
};
|
|
14
|
+
exports.createElement = createElement;
|
|
14
15
|
//# sourceMappingURL=create-element.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-element.js","sourceRoot":"","sources":["../../src/util/create-element.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"create-element.js","sourceRoot":"","sources":["../../src/util/create-element.ts"],"names":[],"mappings":";;;AAAO,MAAM,aAAa,GAAG,CAC3B,QAAqB,EACrB,IAAY,EACZ,QAA6B,EAAE,EAC/B,OAAe,EAAE,EACL,EAAE;IACd,MAAM,GAAG,GAAG,QAAQ,CAAC,eAAe,CAAC,4BAA4B,EAAE,IAAI,CAAC,CAAA;IAExE,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;QACjD,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;KACtC;IAED,IAAI,IAAI,KAAK,EAAE,EAAE;QACf,GAAG,CAAC,WAAW,GAAG,IAAI,CAAA;KACvB;IAED,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAjBY,QAAA,aAAa,iBAiBzB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.degreesToRadians = void 0;
|
|
4
|
-
|
|
4
|
+
const degreesToRadians = (degrees) => (degrees / 180) * Math.PI;
|
|
5
|
+
exports.degreesToRadians = degreesToRadians;
|
|
5
6
|
//# sourceMappingURL=degrees-to-radians.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"degrees-to-radians.js","sourceRoot":"","sources":["../../src/util/degrees-to-radians.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"degrees-to-radians.js","sourceRoot":"","sources":["../../src/util/degrees-to-radians.ts"],"names":[],"mappings":";;;AAAO,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE,CAC1D,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA;AADd,QAAA,gBAAgB,oBACF"}
|
package/dist/util/geometry.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rectangleUnion = exports.rotateRectangle = exports.rotatePoint = exports.translateRectangle = exports.translatePoint = void 0;
|
|
4
|
-
|
|
4
|
+
const translatePoint = (x, y, dx, dy) => ({
|
|
5
5
|
x: x + dx,
|
|
6
6
|
y: y + dy
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
9
|
-
|
|
10
|
-
const
|
|
8
|
+
exports.translatePoint = translatePoint;
|
|
9
|
+
const translateRectangle = ({ x1, y1, x2, y2 }, dx, dy) => {
|
|
10
|
+
const p1 = (0, exports.translatePoint)(x1, y1, dx, dy);
|
|
11
|
+
const p2 = (0, exports.translatePoint)(x2, y2, dx, dy);
|
|
11
12
|
return {
|
|
12
13
|
x1: p1.x,
|
|
13
14
|
y1: p1.y,
|
|
@@ -15,7 +16,8 @@ exports.translateRectangle = ({ x1, y1, x2, y2 }, dx, dy) => {
|
|
|
15
16
|
y2: p2.y
|
|
16
17
|
};
|
|
17
18
|
};
|
|
18
|
-
exports.
|
|
19
|
+
exports.translateRectangle = translateRectangle;
|
|
20
|
+
const rotatePoint = (x, y, angle, x0, y0) => {
|
|
19
21
|
const s = Math.sin(angle);
|
|
20
22
|
const c = Math.cos(angle);
|
|
21
23
|
x -= x0;
|
|
@@ -25,9 +27,10 @@ exports.rotatePoint = (x, y, angle, x0, y0) => {
|
|
|
25
27
|
y: x * s + y * c + y0
|
|
26
28
|
};
|
|
27
29
|
};
|
|
28
|
-
exports.
|
|
29
|
-
|
|
30
|
-
const
|
|
30
|
+
exports.rotatePoint = rotatePoint;
|
|
31
|
+
const rotateRectangle = ({ x1, y1, x2, y2 }, angle, x0, y0) => {
|
|
32
|
+
const p1 = (0, exports.rotatePoint)(x1, y1, angle, x0, y0);
|
|
33
|
+
const p2 = (0, exports.rotatePoint)(x2, y2, angle, x0, y0);
|
|
31
34
|
return {
|
|
32
35
|
x1: p1.x,
|
|
33
36
|
y1: p1.y,
|
|
@@ -35,16 +38,18 @@ exports.rotateRectangle = ({ x1, y1, x2, y2 }, angle, x0, y0) => {
|
|
|
35
38
|
y2: p2.y
|
|
36
39
|
};
|
|
37
40
|
};
|
|
38
|
-
exports.
|
|
41
|
+
exports.rotateRectangle = rotateRectangle;
|
|
42
|
+
const rectangleUnion = (rects) => {
|
|
39
43
|
const nonEmptyRects = rects.filter(({ x1, y1, x2, y2 }) => x2 - x1 !== 0 && y2 - y1 !== 0);
|
|
40
44
|
if (nonEmptyRects.length === 0) {
|
|
41
45
|
throw new Error('All rectangles empty');
|
|
42
46
|
}
|
|
43
47
|
return {
|
|
44
|
-
x1: Math.min(...nonEmptyRects.map(rect => rect.x1)),
|
|
45
|
-
y1: Math.min(...nonEmptyRects.map(rect => rect.y1)),
|
|
46
|
-
x2: Math.max(...nonEmptyRects.map(rect => rect.x2)),
|
|
47
|
-
y2: Math.max(...nonEmptyRects.map(rect => rect.y2))
|
|
48
|
+
x1: Math.min(...nonEmptyRects.map((rect) => rect.x1)),
|
|
49
|
+
y1: Math.min(...nonEmptyRects.map((rect) => rect.y1)),
|
|
50
|
+
x2: Math.max(...nonEmptyRects.map((rect) => rect.x2)),
|
|
51
|
+
y2: Math.max(...nonEmptyRects.map((rect) => rect.y2))
|
|
48
52
|
};
|
|
49
53
|
};
|
|
54
|
+
exports.rectangleUnion = rectangleUnion;
|
|
50
55
|
//# sourceMappingURL=geometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/util/geometry.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"geometry.js","sourceRoot":"","sources":["../../src/util/geometry.ts"],"names":[],"mappings":"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"}
|
package/dist/util/hex-to-dec.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.hexToDec = void 0;
|
|
4
4
|
const A = 'A'.charCodeAt(0);
|
|
5
5
|
const ZERO = '0'.charCodeAt(0);
|
|
6
|
-
|
|
6
|
+
const hexToDec = (hex) => {
|
|
7
7
|
let dec = 0;
|
|
8
8
|
hex = hex.toUpperCase();
|
|
9
9
|
for (let i = 0; i < hex.length; ++i) {
|
|
@@ -12,4 +12,5 @@ exports.hexToDec = (hex) => {
|
|
|
12
12
|
}
|
|
13
13
|
return dec;
|
|
14
14
|
};
|
|
15
|
+
exports.hexToDec = hexToDec;
|
|
15
16
|
//# sourceMappingURL=hex-to-dec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hex-to-dec.js","sourceRoot":"","sources":["../../src/util/hex-to-dec.ts"],"names":[],"mappings":";;;AAAA,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;AAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"hex-to-dec.js","sourceRoot":"","sources":["../../src/util/hex-to-dec.ts"],"names":[],"mappings":";;;AAAA,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;AAC3B,MAAM,IAAI,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;AAEvB,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE;IAC9C,IAAI,GAAG,GAAG,CAAC,CAAA;IACX,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAA;IACvB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;QACnC,MAAM,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;QAC3B,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;KACpD;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AARY,QAAA,QAAQ,YAQpB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeStyles = void 0;
|
|
4
|
-
|
|
4
|
+
const mergeStyles = (globalStyles, localStyles, globalPrefix, localStylesPrefixed = false) => {
|
|
5
5
|
const result = {};
|
|
6
|
-
const globalKeys = Object.keys(globalStyles).filter(key => key.startsWith(globalPrefix));
|
|
6
|
+
const globalKeys = Object.keys(globalStyles).filter((key) => key.startsWith(globalPrefix));
|
|
7
7
|
for (const globalKey of globalKeys) {
|
|
8
8
|
const simpleKey = globalKey.substr(globalPrefix.length);
|
|
9
9
|
const localKey = localStylesPrefixed ? globalKey : simpleKey;
|
|
@@ -14,4 +14,5 @@ exports.mergeStyles = (globalStyles, localStyles, globalPrefix, localStylesPrefi
|
|
|
14
14
|
}
|
|
15
15
|
return result;
|
|
16
16
|
};
|
|
17
|
+
exports.mergeStyles = mergeStyles;
|
|
17
18
|
//# sourceMappingURL=merge-styles.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge-styles.js","sourceRoot":"","sources":["../../src/util/merge-styles.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"merge-styles.js","sourceRoot":"","sources":["../../src/util/merge-styles.ts"],"names":[],"mappings":";;;AAEO,MAAM,WAAW,GAAG,CACzB,YAA4B,EAC5B,WAA8C,EAC9C,YAAoB,EACpB,sBAA+B,KAAK,EACpB,EAAE;IAClB,MAAM,MAAM,GAAmB,EAAE,CAAA;IAEjC,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAC1D,GAAG,CAAC,UAAU,CAAC,YAAY,CAAC,CAC7B,CAAA;IACD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;QAClC,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;QACvD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAA;QAC5D,MAAM,CAAC,SAAS,CAAC;YACf,WAAW,IAAI,IAAI,IAAI,WAAW,CAAC,QAAQ,CAAC,IAAI,IAAI;gBAClD,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC;gBACvB,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;KAC9B;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AArBY,QAAA,WAAW,eAqBvB"}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotificationKind = void 0;
|
|
4
4
|
class NotificationKind {
|
|
5
|
+
static NEXT = new NotificationKind('N');
|
|
6
|
+
static COMPLETE = new NotificationKind('C');
|
|
7
|
+
static ERROR = new NotificationKind('E');
|
|
8
|
+
char;
|
|
5
9
|
constructor(char) {
|
|
6
10
|
this.char = char;
|
|
7
11
|
}
|
|
@@ -10,7 +14,4 @@ class NotificationKind {
|
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
exports.NotificationKind = NotificationKind;
|
|
13
|
-
NotificationKind.NEXT = new NotificationKind('N');
|
|
14
|
-
NotificationKind.COMPLETE = new NotificationKind('C');
|
|
15
|
-
NotificationKind.ERROR = new NotificationKind('E');
|
|
16
17
|
//# sourceMappingURL=notification-kind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-kind.js","sourceRoot":"","sources":["../../src/util/notification-kind.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;
|
|
1
|
+
{"version":3,"file":"notification-kind.js","sourceRoot":"","sources":["../../src/util/notification-kind.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAgB;IAC3B,MAAM,CAAC,IAAI,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAA;IACvC,MAAM,CAAC,QAAQ,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAA;IAC3C,MAAM,CAAC,KAAK,GAAG,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAA;IAEhC,IAAI,CAAQ;IAEpB,YAAqB,IAAY;QAC/B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAED,MAAM,CAAE,CAAM;QACZ,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,IAAI,CAAA;IACzE,CAAC;;AAbH,4CAcC"}
|
|
@@ -4,12 +4,13 @@ exports.stringToColor = void 0;
|
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
const simple_sha1_1 = require("simple-sha1");
|
|
6
6
|
const hex_to_dec_1 = require("./hex-to-dec");
|
|
7
|
-
|
|
8
|
-
const hashHex = simple_sha1_1.sync(str);
|
|
9
|
-
const hash = hex_to_dec_1.hexToDec(hashHex.substr(4, 4));
|
|
7
|
+
const stringToColor = (str, mode) => {
|
|
8
|
+
const hashHex = (0, simple_sha1_1.sync)(str);
|
|
9
|
+
const hash = (0, hex_to_dec_1.hexToDec)(hashHex.substr(4, 4));
|
|
10
10
|
const hue = Math.round((hash / (1 << 16)) * 360);
|
|
11
11
|
const saturation = 60;
|
|
12
12
|
const lightness = mode === 'dark' ? 20 : 80;
|
|
13
13
|
return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
|
|
14
14
|
};
|
|
15
|
+
exports.stringToColor = stringToColor;
|
|
15
16
|
//# sourceMappingURL=string-to-color.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-to-color.js","sourceRoot":"","sources":["../../src/util/string-to-color.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,6CAA0C;AAE1C,6CAAuC;
|
|
1
|
+
{"version":3,"file":"string-to-color.js","sourceRoot":"","sources":["../../src/util/string-to-color.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,6CAA0C;AAE1C,6CAAuC;AAEhC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,IAAsB,EAAU,EAAE;IAC3E,MAAM,OAAO,GAAG,IAAA,kBAAI,EAAC,GAAG,CAAC,CAAA;IACzB,MAAM,IAAI,GAAG,IAAA,qBAAQ,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC3C,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;IAChD,MAAM,UAAU,GAAG,EAAE,CAAA;IACrB,MAAM,SAAS,GAAG,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAA;IAC3C,OAAO,OAAO,GAAG,KAAK,UAAU,MAAM,SAAS,IAAI,CAAA;AACrD,CAAC,CAAA;AAPY,QAAA,aAAa,iBAOzB"}
|
package/dist/util/transform.js
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rotate = exports.translate = exports.transform = void 0;
|
|
4
|
-
|
|
4
|
+
const transform = ($element, value) => {
|
|
5
5
|
const existing = $element.getAttribute('transform');
|
|
6
6
|
const updated = (existing != null && existing !== '' ? existing + ' ' : '') + value;
|
|
7
7
|
$element.setAttribute('transform', updated);
|
|
8
8
|
};
|
|
9
|
-
exports.
|
|
9
|
+
exports.transform = transform;
|
|
10
|
+
const translate = ($element, x, y) => {
|
|
10
11
|
if (x === 0 && y === 0) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
13
|
-
exports.transform($element, `translate(${x} ${y})`);
|
|
14
|
+
(0, exports.transform)($element, `translate(${x} ${y})`);
|
|
14
15
|
};
|
|
15
|
-
exports.
|
|
16
|
+
exports.translate = translate;
|
|
17
|
+
const rotate = ($element, angle, x = 0, y = 0) => {
|
|
16
18
|
if (angle === 0) {
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
19
|
-
exports.transform($element, `rotate(${angle} ${x} ${y})`);
|
|
21
|
+
(0, exports.transform)($element, `rotate(${angle} ${x} ${y})`);
|
|
20
22
|
};
|
|
23
|
+
exports.rotate = rotate;
|
|
21
24
|
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/util/transform.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/util/transform.ts"],"names":[],"mappings":";;;AAAO,MAAM,SAAS,GAAG,CAAC,QAAoB,EAAE,KAAa,EAAE,EAAE;IAC/D,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,CAAA;IACnD,MAAM,OAAO,GACX,CAAC,QAAQ,IAAI,IAAI,IAAI,QAAQ,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,KAAK,CAAA;IACrE,QAAQ,CAAC,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;AAC7C,CAAC,CAAA;AALY,QAAA,SAAS,aAKrB;AAEM,MAAM,SAAS,GAAG,CAAC,QAAoB,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;IACtE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;QACtB,OAAM;KACP;IACD,IAAA,iBAAS,EAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC7C,CAAC,CAAA;AALY,QAAA,SAAS,aAKrB;AAEM,MAAM,MAAM,GAAG,CACpB,QAAoB,EACpB,KAAa,EACb,IAAY,CAAC,EACb,IAAY,CAAC,EACb,EAAE;IACF,IAAI,KAAK,KAAK,CAAC,EAAE;QACf,OAAM;KACP;IACD,IAAA,iBAAS,EAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACnD,CAAC,CAAA;AAVY,QAAA,MAAM,UAUlB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swirly/renderer",
|
|
3
3
|
"description": "Renderer for Swirly marble diagrams.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.18.1-alpha.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -30,19 +30,19 @@
|
|
|
30
30
|
"prepare": "yarn run build"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=
|
|
33
|
+
"node": ">=14"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@swirly/theme-default-light": "^0.
|
|
37
|
-
"simple-sha1": "^3.0
|
|
36
|
+
"@swirly/theme-default-light": "^0.18.1-alpha.0",
|
|
37
|
+
"simple-sha1": "^3.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@swirly/types": "^0.
|
|
40
|
+
"@swirly/types": "^0.18.1-alpha.0",
|
|
41
41
|
"shx": "^0.3.3"
|
|
42
42
|
},
|
|
43
43
|
"funding": {
|
|
44
44
|
"type": "github",
|
|
45
45
|
"url": "https://github.com/sponsors/timdp"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "10b1d6ab3b11a4a2a565206127d57a5a0b43bd36"
|
|
48
48
|
}
|
|
@@ -13,10 +13,8 @@ export const renderBarrierDecoration = (
|
|
|
13
13
|
{ document, styles, bbox, scaleTime }: DecorationRendererContext,
|
|
14
14
|
decoration: DecorationSpecification
|
|
15
15
|
): DecorationRendererResult => {
|
|
16
|
-
const {
|
|
17
|
-
|
|
18
|
-
styles: ownStyles
|
|
19
|
-
} = decoration as BarrierDecorationSpecification
|
|
16
|
+
const { frame, styles: ownStyles } =
|
|
17
|
+
decoration as BarrierDecorationSpecification
|
|
20
18
|
|
|
21
19
|
const s: BarrierDecorationStyles = mergeStyles(styles, ownStyles, 'barrier_')
|
|
22
20
|
|
package/src/decoration/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { renderBarrierDecoration } from './barrier'
|
|
9
9
|
import { renderRangeDecoration } from './range'
|
|
10
10
|
|
|
11
|
-
const strategies:
|
|
11
|
+
const strategies: Record<string, DecorationRenderer> = {
|
|
12
12
|
barrier: renderBarrierDecoration,
|
|
13
13
|
range: renderRangeDecoration
|
|
14
14
|
}
|
package/src/index.ts
CHANGED
|
@@ -35,7 +35,7 @@ const renderMarbleDiagram = (
|
|
|
35
35
|
const parser: DOMParser = new DOMParserImpl()
|
|
36
36
|
const document: XMLDocument = parser.parseFromString(EMPTY_SVG, MIME_TYPE)
|
|
37
37
|
// XXX Typings for Document think it's HTML
|
|
38
|
-
const $svg =
|
|
38
|
+
const $svg = document.documentElement as unknown as SVGSVGElement
|
|
39
39
|
|
|
40
40
|
const styles = {
|
|
41
41
|
...lightStyles,
|
|
@@ -54,7 +54,7 @@ const renderMarbleDiagram = (
|
|
|
54
54
|
)
|
|
55
55
|
|
|
56
56
|
const streamTitleEnabled = spec.content.some(
|
|
57
|
-
item => isStream(item) && item.title != null && item.title !== ''
|
|
57
|
+
(item) => isStream(item) && item.title != null && item.title !== ''
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
const ctx: RendererContext = {
|
|
@@ -23,7 +23,7 @@ const render = (
|
|
|
23
23
|
message: MessageSpecification,
|
|
24
24
|
options: MessageRendererOptions
|
|
25
25
|
): RendererResult => {
|
|
26
|
-
const renderer = strategies.find(renderer => renderer.supports(message))!
|
|
26
|
+
const renderer = strategies.find((renderer) => renderer.supports(message))!
|
|
27
27
|
return renderer.render(ctx, message, options)
|
|
28
28
|
}
|
|
29
29
|
|
package/src/message/scalar.ts
CHANGED
|
@@ -14,7 +14,7 @@ import { mergeStyles } from '../util/merge-styles'
|
|
|
14
14
|
import { stringToColor } from '../util/string-to-color'
|
|
15
15
|
import { rotate, translate } from '../util/transform'
|
|
16
16
|
|
|
17
|
-
const COLOR_TO_MODE:
|
|
17
|
+
const COLOR_TO_MODE: Record<string, 'light' | 'dark'> = {
|
|
18
18
|
auto: 'light',
|
|
19
19
|
auto_light: 'light',
|
|
20
20
|
auto_dark: 'dark'
|
package/src/message/stream.ts
CHANGED
|
@@ -25,12 +25,12 @@ const render = (
|
|
|
25
25
|
{ verticalOffset }: MessageRendererOptions
|
|
26
26
|
): RendererResult => {
|
|
27
27
|
const { styles, streamHeight } = ctx
|
|
28
|
-
const { value } = notification as StreamNextNotificationSpecification
|
|
28
|
+
const { value, isGhost } = notification as StreamNextNotificationSpecification
|
|
29
29
|
|
|
30
30
|
const x = frame * styles.frame_width!
|
|
31
31
|
const y = streamHeight / 2 + verticalOffset
|
|
32
32
|
|
|
33
|
-
const { element: $group, bbox } = renderStreamImpl(ctx, true,
|
|
33
|
+
const { element: $group, bbox } = renderStreamImpl(ctx, value, true, isGhost)
|
|
34
34
|
|
|
35
35
|
rotate($group, styles.higher_order_angle!, x, y)
|
|
36
36
|
translate($group, x, 0)
|
package/src/stream-factory.ts
CHANGED
|
@@ -20,11 +20,11 @@ import { mergeStyles } from './util/merge-styles'
|
|
|
20
20
|
import { NotificationKind } from './util/notification-kind'
|
|
21
21
|
import { translate } from './util/transform'
|
|
22
22
|
|
|
23
|
-
const nullScaleTime: TimeScaler = time => time
|
|
23
|
+
const nullScaleTime: TimeScaler = (time) => time
|
|
24
24
|
|
|
25
25
|
const createScaleTime = (higherOrderAngleDegrees: number): TimeScaler => {
|
|
26
26
|
const scale = 1 / Math.cos(degreesToRadians(higherOrderAngleDegrees))
|
|
27
|
-
return time => time * scale
|
|
27
|
+
return (time) => time * scale
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const isNotification = ({
|
|
@@ -45,81 +45,92 @@ const countPriors = (
|
|
|
45
45
|
return count
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export const createRenderStream =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const message = stream.messages[i]
|
|
78
|
-
const scaledMessage = {
|
|
79
|
-
...message,
|
|
80
|
-
frame: scaleTime(message.frame)
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const priorCount = isNotification(message)
|
|
84
|
-
? countPriors(message, i, stream.messages)
|
|
85
|
-
: 0
|
|
86
|
-
const dy = priorCount * styles.stacking_height!
|
|
87
|
-
|
|
88
|
-
const valueAngle = isHigherOrder
|
|
89
|
-
? styles.higher_order_event_value_angle!
|
|
90
|
-
: 0
|
|
91
|
-
|
|
92
|
-
const options = {
|
|
93
|
-
verticalOffset: dy,
|
|
94
|
-
valueAngle
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const { element, bbox } = renderMessage(ctx, scaledMessage, options)
|
|
48
|
+
export const createRenderStream =
|
|
49
|
+
(renderMessage: MessageRenderer) =>
|
|
50
|
+
(
|
|
51
|
+
ctx: RendererContext,
|
|
52
|
+
stream: StreamSpecification,
|
|
53
|
+
isHigherOrder: boolean,
|
|
54
|
+
isGhost: boolean
|
|
55
|
+
): RendererResult => {
|
|
56
|
+
const { document, styles } = ctx
|
|
57
|
+
|
|
58
|
+
const scaleTime = isHigherOrder
|
|
59
|
+
? createScaleTime(styles.higher_order_angle!)
|
|
60
|
+
: nullScaleTime
|
|
61
|
+
|
|
62
|
+
const $group = createElement(
|
|
63
|
+
document,
|
|
64
|
+
'g',
|
|
65
|
+
isGhost
|
|
66
|
+
? {
|
|
67
|
+
style: `filter: opacity(${styles.ghost_opacity}%)`
|
|
68
|
+
}
|
|
69
|
+
: undefined
|
|
70
|
+
)
|
|
71
|
+
const bboxes: Rectangle[] = []
|
|
72
|
+
|
|
73
|
+
const add = ({ element, bbox }: RendererResult) => {
|
|
74
|
+
$group.appendChild(element)
|
|
75
|
+
bboxes.push(bbox)
|
|
76
|
+
}
|
|
98
77
|
|
|
99
|
-
|
|
100
|
-
|
|
78
|
+
const arrowStyles: ArrowStyles = mergeStyles(
|
|
79
|
+
styles,
|
|
80
|
+
stream.styles,
|
|
81
|
+
'arrow_',
|
|
82
|
+
true
|
|
83
|
+
)
|
|
84
|
+
const scaledDuration = scaleTime(stream.duration)
|
|
85
|
+
add(renderArrow(ctx, arrowStyles, styles.arrowhead_angle!, scaledDuration))
|
|
86
|
+
|
|
87
|
+
for (let i = stream.messages.length - 1; i >= 0; --i) {
|
|
88
|
+
const message = stream.messages[i]
|
|
89
|
+
const scaledMessage = {
|
|
90
|
+
...message,
|
|
91
|
+
frame: scaleTime(message.frame)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const priorCount = isNotification(message)
|
|
95
|
+
? countPriors(message, i, stream.messages)
|
|
96
|
+
: 0
|
|
97
|
+
const dy = priorCount * styles.stacking_height!
|
|
98
|
+
|
|
99
|
+
const valueAngle = isHigherOrder
|
|
100
|
+
? styles.higher_order_event_value_angle!
|
|
101
|
+
: 0
|
|
102
|
+
|
|
103
|
+
const options = {
|
|
104
|
+
verticalOffset: dy,
|
|
105
|
+
valueAngle
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const { element, bbox } = renderMessage(ctx, scaledMessage, options)
|
|
109
|
+
|
|
110
|
+
translate(element, 0, dy)
|
|
111
|
+
bbox.y2 += dy
|
|
112
|
+
|
|
113
|
+
add({ element, bbox })
|
|
114
|
+
}
|
|
101
115
|
|
|
102
|
-
|
|
103
|
-
|
|
116
|
+
const innerCtx = {
|
|
117
|
+
...ctx,
|
|
118
|
+
scaleTime,
|
|
119
|
+
bbox: rectangleUnion(bboxes)
|
|
120
|
+
}
|
|
104
121
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
122
|
+
if (stream.decorations != null) {
|
|
123
|
+
for (const decoration of stream.decorations) {
|
|
124
|
+
const { element, bbox } = renderDecoration(innerCtx, decoration)
|
|
125
|
+
$group.appendChild(element)
|
|
126
|
+
if (bbox != null) {
|
|
127
|
+
innerCtx.bbox = rectangleUnion([innerCtx.bbox, bbox])
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
110
131
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
$group.appendChild(element)
|
|
115
|
-
if (bbox != null) {
|
|
116
|
-
innerCtx.bbox = rectangleUnion([innerCtx.bbox, bbox])
|
|
132
|
+
return {
|
|
133
|
+
element: $group,
|
|
134
|
+
bbox: innerCtx.bbox
|
|
117
135
|
}
|
|
118
136
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
element: $group,
|
|
123
|
-
bbox: innerCtx.bbox
|
|
124
|
-
}
|
|
125
|
-
}
|
package/src/stream.ts
CHANGED
|
@@ -16,7 +16,7 @@ export const renderStream = (
|
|
|
16
16
|
const { document, styles, streamHeight, streamTitleEnabled } = ctx
|
|
17
17
|
const s: StreamStyles = mergeStyles(styles, stream.styles, 'stream_')
|
|
18
18
|
|
|
19
|
-
const renderStreamResult = renderStreamImpl(ctx, false,
|
|
19
|
+
const renderStreamResult = renderStreamImpl(ctx, stream, false, false)
|
|
20
20
|
|
|
21
21
|
const { element: $streamGroup, bbox } = renderStreamResult
|
|
22
22
|
|
package/src/util/geometry.ts
CHANGED
|
@@ -66,9 +66,9 @@ export const rectangleUnion = (rects: readonly Rectangle[]): Rectangle => {
|
|
|
66
66
|
throw new Error('All rectangles empty')
|
|
67
67
|
}
|
|
68
68
|
return {
|
|
69
|
-
x1: Math.min(...nonEmptyRects.map(rect => rect.x1)),
|
|
70
|
-
y1: Math.min(...nonEmptyRects.map(rect => rect.y1)),
|
|
71
|
-
x2: Math.max(...nonEmptyRects.map(rect => rect.x2)),
|
|
72
|
-
y2: Math.max(...nonEmptyRects.map(rect => rect.y2))
|
|
69
|
+
x1: Math.min(...nonEmptyRects.map((rect) => rect.x1)),
|
|
70
|
+
y1: Math.min(...nonEmptyRects.map((rect) => rect.y1)),
|
|
71
|
+
x2: Math.max(...nonEmptyRects.map((rect) => rect.x2)),
|
|
72
|
+
y2: Math.max(...nonEmptyRects.map((rect) => rect.y2))
|
|
73
73
|
}
|
|
74
74
|
}
|
package/src/util/merge-styles.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const mergeStyles = (
|
|
|
8
8
|
): FreeformStyles => {
|
|
9
9
|
const result: FreeformStyles = {}
|
|
10
10
|
|
|
11
|
-
const globalKeys = Object.keys(globalStyles).filter(key =>
|
|
11
|
+
const globalKeys = Object.keys(globalStyles).filter((key) =>
|
|
12
12
|
key.startsWith(globalPrefix)
|
|
13
13
|
)
|
|
14
14
|
for (const globalKey of globalKeys) {
|