@swirly/renderer 0.17.1 → 0.18.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 -1686
- package/dist/arrow.js +4 -4
- package/dist/arrow.js.map +1 -1
- package/dist/decoration/barrier.js +3 -3
- package/dist/decoration/barrier.js.map +1 -1
- package/dist/decoration/index.js.map +1 -1
- package/dist/decoration/range.js +3 -3
- package/dist/decoration/range.js.map +1 -1
- package/dist/index.js +11 -11
- 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/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 +5 -5
- package/dist/message/stream.js.map +1 -1
- package/dist/operator.js +7 -7
- package/dist/operator.js.map +1 -1
- package/dist/stream-factory.js +10 -10
- package/dist/stream-factory.js.map +1 -1
- package/dist/stream.js +6 -6
- package/dist/stream.js.map +1 -1
- package/dist/util/create-element.d.ts +1 -1
- package/dist/util/create-element.js +2 -2
- package/dist/util/create-element.js.map +1 -1
- package/dist/util/geometry.js +8 -8
- package/dist/util/geometry.js.map +1 -1
- package/dist/util/merge-styles.js +1 -1
- 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 +2 -2
- package/dist/util/string-to-color.js.map +1 -1
- package/dist/util/transform.js +2 -2
- 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/decoration/range.ts +1 -5
- package/src/index.ts +6 -6
- package/src/message/non-stream.ts +1 -1
- package/src/message/scalar.ts +1 -1
- package/src/operator.ts +3 -3
- package/src/stream-factory.ts +76 -74
- package/src/util/create-element.ts +3 -3
- package/src/util/geometry.ts +4 -4
- package/src/util/merge-styles.ts +1 -1
|
@@ -3,7 +3,7 @@ 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;
|
|
@@ -1 +1 @@
|
|
|
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,GAAG,
|
|
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"}
|
|
@@ -5,8 +5,8 @@ exports.stringToColor = void 0;
|
|
|
5
5
|
const simple_sha1_1 = require("simple-sha1");
|
|
6
6
|
const hex_to_dec_1 = require("./hex-to-dec");
|
|
7
7
|
const stringToColor = (str, mode) => {
|
|
8
|
-
const hashHex = simple_sha1_1.sync(str);
|
|
9
|
-
const hash = hex_to_dec_1.hexToDec(hashHex.substr(4, 4));
|
|
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;
|
|
@@ -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;AAEhC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,IAAsB,EAAU,EAAE;IAC3E,MAAM,OAAO,GAAG,kBAAI,
|
|
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
|
@@ -11,14 +11,14 @@ const translate = ($element, x, y) => {
|
|
|
11
11
|
if (x === 0 && y === 0) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
exports.transform($element, `translate(${x} ${y})`);
|
|
14
|
+
(0, exports.transform)($element, `translate(${x} ${y})`);
|
|
15
15
|
};
|
|
16
16
|
exports.translate = translate;
|
|
17
17
|
const rotate = ($element, angle, x = 0, y = 0) => {
|
|
18
18
|
if (angle === 0) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
exports.transform($element, `rotate(${angle} ${x} ${y})`);
|
|
21
|
+
(0, exports.transform)($element, `rotate(${angle} ${x} ${y})`);
|
|
22
22
|
};
|
|
23
23
|
exports.rotate = rotate;
|
|
24
24
|
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +1 @@
|
|
|
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,iBAAS,
|
|
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.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.0",
|
|
37
|
+
"simple-sha1": "^3.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@swirly/types": "^0.
|
|
40
|
+
"@swirly/types": "^0.18.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": "1daf66f1412fda5d4ba48eb61e67be25d099b430"
|
|
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/decoration/range.ts
CHANGED
|
@@ -4,11 +4,7 @@ import {
|
|
|
4
4
|
RangeDecorationStyles
|
|
5
5
|
} from '@swirly/types'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
DecorationRenderer,
|
|
9
|
-
DecorationRendererContext,
|
|
10
|
-
DecorationRendererResult
|
|
11
|
-
} from '../types'
|
|
7
|
+
import { DecorationRendererContext, DecorationRendererResult } from '../types'
|
|
12
8
|
import { createElement } from '../util/create-element'
|
|
13
9
|
import { mergeStyles } from '../util/merge-styles'
|
|
14
10
|
import { translate } from '../util/transform'
|
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 = {
|
|
@@ -93,16 +93,16 @@ const renderMarbleDiagram = (
|
|
|
93
93
|
const height = styles.canvas_padding! + y + styles.canvas_padding!
|
|
94
94
|
|
|
95
95
|
$svg.setAttribute('viewBox', `0 0 ${width} ${height}`)
|
|
96
|
-
$svg.setAttribute('width',
|
|
97
|
-
$svg.setAttribute('height',
|
|
96
|
+
$svg.setAttribute('width', String(width))
|
|
97
|
+
$svg.setAttribute('height', String(height))
|
|
98
98
|
|
|
99
99
|
const bgColor = styles.background_color!
|
|
100
100
|
if (bgColor !== '' && bgColor !== 'transparent') {
|
|
101
101
|
const $bg = createElement(document, 'rect', {
|
|
102
102
|
x: 0,
|
|
103
103
|
y: 0,
|
|
104
|
-
width
|
|
105
|
-
height
|
|
104
|
+
width,
|
|
105
|
+
height,
|
|
106
106
|
fill: bgColor
|
|
107
107
|
})
|
|
108
108
|
$svg.insertBefore($bg, $svg.firstChild)
|
|
@@ -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/operator.ts
CHANGED
|
@@ -55,9 +55,9 @@ export const renderOperator = (
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
const update = ({ width }: PostRenderUpdateContext) => {
|
|
58
|
-
$rect.setAttribute('width',
|
|
59
|
-
$text.setAttribute('x',
|
|
60
|
-
$text.setAttribute('width',
|
|
58
|
+
$rect.setAttribute('width', String(width))
|
|
59
|
+
$text.setAttribute('x', String(width / 2))
|
|
60
|
+
$text.setAttribute('width', String(width))
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
return {
|
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,83 @@ 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
|
-
styles,
|
|
69
|
-
stream.styles,
|
|
70
|
-
'arrow_',
|
|
71
|
-
true
|
|
72
|
-
)
|
|
73
|
-
const scaledDuration = scaleTime(stream.duration)
|
|
74
|
-
add(renderArrow(ctx, arrowStyles, styles.arrowhead_angle!, scaledDuration))
|
|
75
|
-
|
|
76
|
-
for (let i = stream.messages.length - 1; i >= 0; --i) {
|
|
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
|
+
isHigherOrder: boolean,
|
|
53
|
+
stream: StreamSpecification
|
|
54
|
+
): RendererResult => {
|
|
55
|
+
const { document, styles } = ctx
|
|
56
|
+
|
|
57
|
+
const scaleTime = isHigherOrder
|
|
58
|
+
? createScaleTime(styles.higher_order_angle!)
|
|
59
|
+
: nullScaleTime
|
|
60
|
+
|
|
61
|
+
const $group = createElement(document, 'g')
|
|
62
|
+
const bboxes: Rectangle[] = []
|
|
63
|
+
|
|
64
|
+
const add = ({ element, bbox }: RendererResult) => {
|
|
65
|
+
$group.appendChild(element)
|
|
66
|
+
bboxes.push(bbox)
|
|
67
|
+
}
|
|
98
68
|
|
|
99
|
-
|
|
100
|
-
|
|
69
|
+
const arrowStyles: ArrowStyles = mergeStyles(
|
|
70
|
+
styles,
|
|
71
|
+
stream.styles,
|
|
72
|
+
'arrow_',
|
|
73
|
+
true
|
|
74
|
+
)
|
|
75
|
+
const scaledDuration = scaleTime(stream.duration)
|
|
76
|
+
add(renderArrow(ctx, arrowStyles, styles.arrowhead_angle!, scaledDuration))
|
|
77
|
+
|
|
78
|
+
for (let i = stream.messages.length - 1; i >= 0; --i) {
|
|
79
|
+
const message = stream.messages[i]
|
|
80
|
+
const scaledMessage = {
|
|
81
|
+
...message,
|
|
82
|
+
frame: scaleTime(message.frame)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const priorCount = isNotification(message)
|
|
86
|
+
? countPriors(message, i, stream.messages)
|
|
87
|
+
: 0
|
|
88
|
+
const dy = priorCount * styles.stacking_height!
|
|
89
|
+
|
|
90
|
+
const valueAngle = isHigherOrder
|
|
91
|
+
? styles.higher_order_event_value_angle!
|
|
92
|
+
: 0
|
|
93
|
+
|
|
94
|
+
const options = {
|
|
95
|
+
verticalOffset: dy,
|
|
96
|
+
valueAngle
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const { element, bbox } = renderMessage(ctx, scaledMessage, options)
|
|
100
|
+
|
|
101
|
+
translate(element, 0, dy)
|
|
102
|
+
bbox.y2 += dy
|
|
103
|
+
|
|
104
|
+
add({ element, bbox })
|
|
105
|
+
}
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
107
|
+
const innerCtx = {
|
|
108
|
+
...ctx,
|
|
109
|
+
scaleTime,
|
|
110
|
+
bbox: rectangleUnion(bboxes)
|
|
111
|
+
}
|
|
104
112
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
113
|
+
if (stream.decorations != null) {
|
|
114
|
+
for (const decoration of stream.decorations) {
|
|
115
|
+
const { element, bbox } = renderDecoration(innerCtx, decoration)
|
|
116
|
+
$group.appendChild(element)
|
|
117
|
+
if (bbox != null) {
|
|
118
|
+
innerCtx.bbox = rectangleUnion([innerCtx.bbox, bbox])
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
110
122
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
$group.appendChild(element)
|
|
115
|
-
if (bbox != null) {
|
|
116
|
-
innerCtx.bbox = rectangleUnion([innerCtx.bbox, bbox])
|
|
123
|
+
return {
|
|
124
|
+
element: $group,
|
|
125
|
+
bbox: innerCtx.bbox
|
|
117
126
|
}
|
|
118
127
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
return {
|
|
122
|
-
element: $group,
|
|
123
|
-
bbox: innerCtx.bbox
|
|
124
|
-
}
|
|
125
|
-
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
export const createElement = (
|
|
2
2
|
document: XMLDocument,
|
|
3
3
|
name: string,
|
|
4
|
-
attrs: any = {},
|
|
4
|
+
attrs: Record<string, any> = {},
|
|
5
5
|
text: string = ''
|
|
6
6
|
): SVGElement => {
|
|
7
7
|
const $el = document.createElementNS('http://www.w3.org/2000/svg', name)
|
|
8
8
|
|
|
9
9
|
for (const [name, value] of Object.entries(attrs)) {
|
|
10
|
-
$el.setAttribute(name,
|
|
10
|
+
$el.setAttribute(name, String(value))
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
if (text !== '') {
|
|
14
|
-
$el.textContent =
|
|
14
|
+
$el.textContent = text
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return $el
|
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) {
|