@swirly/renderer 0.18.0 → 0.19.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/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/arrow.d.ts +1 -1
- package/dist/arrow.js +7 -11
- package/dist/arrow.js.map +1 -1
- package/dist/decoration/barrier.d.ts +1 -1
- package/dist/decoration/barrier.js +7 -11
- package/dist/decoration/barrier.js.map +1 -1
- package/dist/decoration/index.d.ts +1 -1
- package/dist/decoration/index.js +5 -9
- package/dist/decoration/index.js.map +1 -1
- package/dist/decoration/range.d.ts +1 -1
- package/dist/decoration/range.js +7 -11
- package/dist/decoration/range.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -26
- package/dist/index.js.map +1 -1
- package/dist/message/complete.d.ts +1 -1
- package/dist/message/complete.js +10 -13
- package/dist/message/complete.js.map +1 -1
- package/dist/message/error.d.ts +1 -1
- package/dist/message/error.js +11 -14
- package/dist/message/error.js.map +1 -1
- package/dist/message/index.d.ts +1 -1
- package/dist/message/index.js +6 -10
- package/dist/message/index.js.map +1 -1
- package/dist/message/non-stream.d.ts +1 -1
- package/dist/message/non-stream.js +7 -10
- package/dist/message/non-stream.js.map +1 -1
- package/dist/message/scalar.d.ts +1 -1
- package/dist/message/scalar.js +13 -16
- package/dist/message/scalar.js.map +1 -1
- package/dist/message/stream.d.ts +1 -1
- package/dist/message/stream.js +14 -17
- package/dist/message/stream.js.map +1 -1
- package/dist/operator.d.ts +1 -1
- package/dist/operator.js +96 -25
- package/dist/operator.js.map +1 -1
- package/dist/stream/core.d.ts +1 -0
- package/dist/stream/core.js +4 -0
- package/dist/stream/core.js.map +1 -0
- package/dist/{stream-factory.d.ts → stream/factory.d.ts} +2 -2
- package/dist/{stream-factory.js → stream/factory.js} +23 -23
- package/dist/stream/factory.js.map +1 -0
- package/dist/{stream.d.ts → stream/full.d.ts} +1 -1
- package/dist/stream/full.js +40 -0
- package/dist/stream/full.js.map +1 -0
- package/dist/types.d.ts +3 -2
- package/dist/types.js +1 -2
- package/dist/util/degrees-to-radians.js +1 -5
- package/dist/util/degrees-to-radians.js.map +1 -1
- package/dist/util/geometry.d.ts +1 -1
- package/dist/util/geometry.js +9 -17
- package/dist/util/geometry.js.map +1 -1
- package/dist/util/hex-to-dec.js +1 -5
- package/dist/util/hex-to-dec.js.map +1 -1
- package/dist/util/merge-styles.js +2 -6
- package/dist/util/merge-styles.js.map +1 -1
- package/dist/util/notification-kind.js +1 -5
- package/dist/util/notification-kind.js.map +1 -1
- package/dist/util/string-to-color.js +5 -9
- package/dist/util/string-to-color.js.map +1 -1
- package/dist/util/svg-xml.d.ts +7 -0
- package/dist/util/svg-xml.js +22 -0
- package/dist/util/svg-xml.js.map +1 -0
- package/dist/util/transform.js +5 -11
- package/dist/util/transform.js.map +1 -1
- package/package.json +7 -8
- package/src/arrow.ts +6 -6
- package/src/decoration/barrier.ts +8 -5
- package/src/decoration/index.ts +3 -3
- package/src/decoration/range.ts +8 -5
- package/src/index.ts +16 -20
- package/src/message/complete.ts +7 -7
- package/src/message/error.ts +8 -8
- package/src/message/index.ts +3 -3
- package/src/message/non-stream.ts +4 -4
- package/src/message/scalar.ts +8 -8
- package/src/message/stream.ts +8 -8
- package/src/operator.ts +152 -27
- package/src/stream/core.ts +4 -0
- package/src/{stream-factory.ts → stream/factory.ts} +20 -11
- package/src/{stream.ts → stream/full.ts} +8 -11
- package/src/types.ts +4 -2
- package/src/util/geometry.ts +1 -1
- package/src/util/merge-styles.ts +1 -1
- package/src/util/string-to-color.ts +2 -2
- package/src/util/svg-xml.ts +44 -0
- package/dist/stream-factory.js.map +0 -1
- package/dist/stream.js +0 -46
- package/dist/stream.js.map +0 -1
- package/dist/util/create-element.d.ts +0 -1
- package/dist/util/create-element.js +0 -15
- package/dist/util/create-element.js.map +0 -1
- package/src/util/create-element.ts +0 -18
package/dist/message/error.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const notification_kind_1 = require("../util/notification-kind");
|
|
7
|
-
const transform_1 = require("../util/transform");
|
|
8
|
-
const supports = ({ notification: { kind } }) => notification_kind_1.NotificationKind.ERROR.equals(kind);
|
|
1
|
+
import { mergeStyles } from '../util/merge-styles.js';
|
|
2
|
+
import { NotificationKind } from '../util/notification-kind.js';
|
|
3
|
+
import { createSvgElement } from '../util/svg-xml.js';
|
|
4
|
+
import { translate } from '../util/transform.js';
|
|
5
|
+
const supports = ({ notification: { kind } }) => NotificationKind.ERROR.equals(kind);
|
|
9
6
|
const render = ({ document, styles, streamHeight }, message) => {
|
|
10
|
-
const s =
|
|
7
|
+
const s = mergeStyles(styles, message.styles, 'error_');
|
|
11
8
|
const x = message.frame * styles.frame_width - s.size / 2;
|
|
12
9
|
const y = (streamHeight - s.size) / 2;
|
|
13
|
-
const $group = (
|
|
14
|
-
|
|
15
|
-
$group.appendChild((
|
|
10
|
+
const $group = createSvgElement(document, 'g');
|
|
11
|
+
translate($group, x, y);
|
|
12
|
+
$group.appendChild(createSvgElement(document, 'line', {
|
|
16
13
|
x1: 0,
|
|
17
14
|
y1: 0,
|
|
18
15
|
x2: s.size,
|
|
@@ -20,7 +17,7 @@ const render = ({ document, styles, streamHeight }, message) => {
|
|
|
20
17
|
stroke: s.color,
|
|
21
18
|
'stroke-width': s.stroke_width
|
|
22
19
|
}));
|
|
23
|
-
$group.appendChild((
|
|
20
|
+
$group.appendChild(createSvgElement(document, 'line', {
|
|
24
21
|
x1: s.size,
|
|
25
22
|
y1: 0,
|
|
26
23
|
x2: 0,
|
|
@@ -39,5 +36,5 @@ const render = ({ document, styles, streamHeight }, message) => {
|
|
|
39
36
|
bbox
|
|
40
37
|
};
|
|
41
38
|
};
|
|
42
|
-
|
|
39
|
+
export const errorMessageRenderer = { supports, render };
|
|
43
40
|
//# sourceMappingURL=error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/message/error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/message/error.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,MAAM,QAAQ,GAAG,CAAC,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,EAAwB,EAAE,EAAE,CACpE,gBAAgB,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;AAErC,MAAM,MAAM,GAAG,CACb,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAmB,EACnD,OAA6B,EACb,EAAE;IAClB,MAAM,CAAC,GAAuB,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAE3E,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,WAAY,GAAG,CAAC,CAAC,IAAK,GAAG,CAAC,CAAA;IAC3D,MAAM,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,CAAC,IAAK,CAAC,GAAG,CAAC,CAAA;IAEtC,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAC9C,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAEvB,MAAM,CAAC,WAAW,CAChB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE;QACjC,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC,CAAC,IAAK;QACX,EAAE,EAAE,CAAC,CAAC,IAAK;QACX,MAAM,EAAE,CAAC,CAAC,KAAM;QAChB,cAAc,EAAE,CAAC,CAAC,YAAa;KAChC,CAAC,CACH,CAAA;IAED,MAAM,CAAC,WAAW,CAChB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE;QACjC,EAAE,EAAE,CAAC,CAAC,IAAK;QACX,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC,CAAC,IAAK;QACX,MAAM,EAAE,CAAC,CAAC,KAAM;QAChB,cAAc,EAAE,CAAC,CAAC,YAAa;KAChC,CAAC,CACH,CAAA;IAED,MAAM,IAAI,GAAG;QACX,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAK;QACf,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,IAAK;KAChB,CAAA;IAED,OAAO;QACL,OAAO,EAAE,MAAM;QACf,IAAI;KACL,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA"}
|
package/dist/message/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MessageSpecification } from '@swirly/types';
|
|
2
|
-
import { MessageRendererOptions, RendererContext, RendererResult } from '../types';
|
|
2
|
+
import { MessageRendererOptions, RendererContext, RendererResult } from '../types.js';
|
|
3
3
|
export declare const renderMessage: (ctx: RendererContext, message: MessageSpecification, options: MessageRendererOptions) => RendererResult;
|
package/dist/message/index.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const renderer = stream_1.streamMessageRenderer.supports(message)
|
|
8
|
-
? stream_1.streamMessageRenderer
|
|
9
|
-
: non_stream_1.nonStreamMessageRenderer;
|
|
1
|
+
import { nonStreamMessageRenderer } from './non-stream.js';
|
|
2
|
+
import { streamMessageRenderer } from './stream.js';
|
|
3
|
+
export const renderMessage = (ctx, message, options) => {
|
|
4
|
+
const renderer = streamMessageRenderer.supports(message)
|
|
5
|
+
? streamMessageRenderer
|
|
6
|
+
: nonStreamMessageRenderer;
|
|
10
7
|
return renderer.render(ctx, message, options);
|
|
11
8
|
};
|
|
12
|
-
exports.renderMessage = renderMessage;
|
|
13
9
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/message/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/message/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,GAAoB,EACpB,OAA6B,EAC7B,OAA+B,EACf,EAAE;IAClB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,OAAO,CAAC;QACtD,CAAC,CAAC,qBAAqB;QACvB,CAAC,CAAC,wBAAwB,CAAA;IAC5B,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;AAC/C,CAAC,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageSpecification } from '@swirly/types';
|
|
2
|
-
import { MessageRendererOptions, RendererContext, RendererResult } from '../types';
|
|
2
|
+
import { MessageRendererOptions, RendererContext, RendererResult } from '../types.js';
|
|
3
3
|
export declare const nonStreamMessageRenderer: {
|
|
4
4
|
supports: ({ notification }: MessageSpecification) => boolean;
|
|
5
5
|
render: (ctx: RendererContext, message: MessageSpecification, options: MessageRendererOptions) => RendererResult;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const complete_1 = require("./complete");
|
|
5
|
-
const error_1 = require("./error");
|
|
6
|
-
const scalar_1 = require("./scalar");
|
|
1
|
+
import { completeMessageRenderer } from './complete.js';
|
|
2
|
+
import { errorMessageRenderer } from './error.js';
|
|
3
|
+
import { scalarMessageRenderer } from './scalar.js';
|
|
7
4
|
const strategies = [
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
completeMessageRenderer,
|
|
6
|
+
errorMessageRenderer,
|
|
7
|
+
scalarMessageRenderer
|
|
11
8
|
];
|
|
12
9
|
const supports = ({ notification }) => !('value' in notification) || typeof notification.value !== 'object';
|
|
13
10
|
const render = (ctx, message, options) => {
|
|
14
11
|
const renderer = strategies.find((renderer) => renderer.supports(message));
|
|
15
12
|
return renderer.render(ctx, message, options);
|
|
16
13
|
};
|
|
17
|
-
|
|
14
|
+
export const nonStreamMessageRenderer = { supports, render };
|
|
18
15
|
//# sourceMappingURL=non-stream.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"non-stream.js","sourceRoot":"","sources":["../../src/message/non-stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"non-stream.js","sourceRoot":"","sources":["../../src/message/non-stream.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AACjD,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AAEnD,MAAM,UAAU,GAAG;IACjB,uBAAuB;IACvB,oBAAoB;IACpB,qBAAqB;CACtB,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,EAAE,YAAY,EAAwB,EAAE,EAAE,CAC1D,CAAC,CAAC,OAAO,IAAI,YAAY,CAAC,IAAI,OAAO,YAAY,CAAC,KAAK,KAAK,QAAQ,CAAA;AAEtE,MAAM,MAAM,GAAG,CACb,GAAoB,EACpB,OAA6B,EAC7B,OAA+B,EACf,EAAE;IAClB,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAE,CAAA;IAC3E,OAAO,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAA;AAC/C,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAA"}
|
package/dist/message/scalar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageSpecification } from '@swirly/types';
|
|
2
|
-
import { MessageRendererOptions, RendererContext, RendererResult } from '../types';
|
|
2
|
+
import { MessageRendererOptions, RendererContext, RendererResult } from '../types.js';
|
|
3
3
|
export declare const scalarMessageRenderer: {
|
|
4
4
|
supports: () => boolean;
|
|
5
5
|
render: ({ document, styles, streamHeight }: RendererContext, message: MessageSpecification, { valueAngle }: MessageRendererOptions) => RendererResult;
|
package/dist/message/scalar.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const merge_styles_1 = require("../util/merge-styles");
|
|
6
|
-
const string_to_color_1 = require("../util/string-to-color");
|
|
7
|
-
const transform_1 = require("../util/transform");
|
|
1
|
+
import { mergeStyles } from '../util/merge-styles.js';
|
|
2
|
+
import { stringToColor } from '../util/string-to-color.js';
|
|
3
|
+
import { createSvgElement } from '../util/svg-xml.js';
|
|
4
|
+
import { rotate, translate } from '../util/transform.js';
|
|
8
5
|
const COLOR_TO_MODE = {
|
|
9
6
|
auto: 'light',
|
|
10
7
|
auto_light: 'light',
|
|
@@ -12,14 +9,14 @@ const COLOR_TO_MODE = {
|
|
|
12
9
|
};
|
|
13
10
|
const supports = () => true;
|
|
14
11
|
const render = ({ document, styles, streamHeight }, message, { valueAngle }) => {
|
|
15
|
-
const s =
|
|
12
|
+
const s = mergeStyles(styles, message.styles, 'event_');
|
|
16
13
|
const { value } = message.notification;
|
|
17
14
|
const x = message.frame * styles.frame_width - styles.event_radius;
|
|
18
|
-
const $group = (
|
|
19
|
-
|
|
15
|
+
const $group = createSvgElement(document, 'g');
|
|
16
|
+
translate($group, x, 0);
|
|
20
17
|
const fillColorMode = COLOR_TO_MODE[s.fill_color];
|
|
21
|
-
const finalFillColor = fillColorMode != null ?
|
|
22
|
-
$group.appendChild((
|
|
18
|
+
const finalFillColor = fillColorMode != null ? stringToColor(value, fillColorMode) : s.fill_color;
|
|
19
|
+
$group.appendChild(createSvgElement(document, 'ellipse', {
|
|
23
20
|
cx: styles.event_radius,
|
|
24
21
|
cy: streamHeight / 2,
|
|
25
22
|
rx: styles.event_radius - s.stroke_width / 2,
|
|
@@ -28,7 +25,7 @@ const render = ({ document, styles, streamHeight }, message, { valueAngle }) =>
|
|
|
28
25
|
stroke: s.stroke_color,
|
|
29
26
|
'stroke-width': s.stroke_width
|
|
30
27
|
}));
|
|
31
|
-
const $label = (
|
|
28
|
+
const $label = createSvgElement(document, 'text', {
|
|
32
29
|
x: 0,
|
|
33
30
|
y: 0,
|
|
34
31
|
fill: s.value_color,
|
|
@@ -39,8 +36,8 @@ const render = ({ document, styles, streamHeight }, message, { valueAngle }) =>
|
|
|
39
36
|
'dominant-baseline': 'middle',
|
|
40
37
|
'text-anchor': 'middle'
|
|
41
38
|
}, value);
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
translate($label, styles.event_radius, streamHeight / 2);
|
|
40
|
+
rotate($label, valueAngle, 0, 0);
|
|
44
41
|
$group.appendChild($label);
|
|
45
42
|
const bbox = {
|
|
46
43
|
x1: x,
|
|
@@ -53,7 +50,7 @@ const render = ({ document, styles, streamHeight }, message, { valueAngle }) =>
|
|
|
53
50
|
bbox
|
|
54
51
|
};
|
|
55
52
|
};
|
|
56
|
-
|
|
53
|
+
export const scalarMessageRenderer = {
|
|
57
54
|
supports,
|
|
58
55
|
render
|
|
59
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scalar.js","sourceRoot":"","sources":["../../src/message/scalar.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scalar.js","sourceRoot":"","sources":["../../src/message/scalar.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAExD,MAAM,aAAa,GAAqC;IACtD,IAAI,EAAE,OAAO;IACb,UAAU,EAAE,OAAO;IACnB,SAAS,EAAE,MAAM;CAClB,CAAA;AAED,MAAM,QAAQ,GAAG,GAAG,EAAE,CAAC,IAAI,CAAA;AAE3B,MAAM,MAAM,GAAG,CACb,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAmB,EACnD,OAA6B,EAC7B,EAAE,UAAU,EAA0B,EACtB,EAAE;IAClB,MAAM,CAAC,GAA4B,WAAW,CAC5C,MAAM,EACN,OAAO,CAAC,MAAM,EACd,QAAQ,CACT,CAAA;IACD,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC,YAAmD,CAAA;IAE7E,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,WAAY,GAAG,MAAM,CAAC,YAAa,CAAA;IAEpE,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAC9C,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAEvB,MAAM,aAAa,GAAG,aAAa,CAAC,CAAC,CAAC,UAAW,CAAC,CAAA;IAClD,MAAM,cAAc,GAClB,aAAa,IAAI,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,E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,OAAO;QACL,OAAO,EAAE,MAAM;QACf,IAAI;KACL,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ;IACR,MAAM;CACP,CAAA"}
|
package/dist/message/stream.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageSpecification } from '@swirly/types';
|
|
2
|
-
import { MessageRendererOptions, RendererContext, RendererResult } from '../types';
|
|
2
|
+
import { MessageRendererOptions, RendererContext, RendererResult } from '../types.js';
|
|
3
3
|
export declare const streamMessageRenderer: {
|
|
4
4
|
supports: (message: MessageSpecification) => boolean;
|
|
5
5
|
render: (ctx: RendererContext, { frame, notification }: MessageSpecification, { verticalOffset }: MessageRendererOptions) => RendererResult;
|
package/dist/message/stream.js
CHANGED
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const non_stream_1 = require("./non-stream");
|
|
9
|
-
const supports = (message) => !non_stream_1.nonStreamMessageRenderer.supports(message);
|
|
10
|
-
const renderStreamImpl = (0, stream_factory_1.createRenderStream)(non_stream_1.nonStreamMessageRenderer.render);
|
|
1
|
+
import { createRenderStream } from '../stream/factory.js';
|
|
2
|
+
import { degreesToRadians } from '../util/degrees-to-radians.js';
|
|
3
|
+
import { rotateRectangle, translateRectangle } from '../util/geometry.js';
|
|
4
|
+
import { rotate, translate } from '../util/transform.js';
|
|
5
|
+
import { nonStreamMessageRenderer } from './non-stream.js';
|
|
6
|
+
const supports = (message) => !nonStreamMessageRenderer.supports(message);
|
|
7
|
+
const renderStreamImpl = createRenderStream(nonStreamMessageRenderer.render);
|
|
11
8
|
const render = (ctx, { frame, notification }, { verticalOffset }) => {
|
|
12
9
|
const { styles, streamHeight } = ctx;
|
|
13
|
-
const { value } = notification;
|
|
10
|
+
const { value, isGhost } = notification;
|
|
14
11
|
const x = frame * styles.frame_width;
|
|
15
12
|
const y = streamHeight / 2 + verticalOffset;
|
|
16
|
-
const { element: $group, bbox } = renderStreamImpl(ctx, true,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const rotatedBBox =
|
|
20
|
-
const translatedBBox =
|
|
13
|
+
const { element: $group, bbox } = renderStreamImpl(ctx, value, true, isGhost);
|
|
14
|
+
rotate($group, styles.higher_order_angle, x, y);
|
|
15
|
+
translate($group, x, 0);
|
|
16
|
+
const rotatedBBox = rotateRectangle(bbox, degreesToRadians(styles.higher_order_angle), 0, y);
|
|
17
|
+
const translatedBBox = translateRectangle(rotatedBBox, x, 0);
|
|
21
18
|
return {
|
|
22
19
|
element: $group,
|
|
23
20
|
bbox: translatedBBox
|
|
24
21
|
};
|
|
25
22
|
};
|
|
26
|
-
|
|
23
|
+
export const streamMessageRenderer = {
|
|
27
24
|
supports,
|
|
28
25
|
render
|
|
29
26
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/message/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/message/stream.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAMzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAE1D,MAAM,QAAQ,GAAG,CAAC,OAA6B,EAAE,EAAE,CACjD,CAAC,wBAAwB,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;AAE7C,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,wBAAwB,CAAC,MAAM,CAAC,CAAA;AAE5E,MAAM,MAAM,GAAG,CACb,GAAoB,EACpB,EAAE,KAAK,EAAE,YAAY,EAAwB,EAC7C,EAAE,cAAc,EAA0B,EAC1B,EAAE;IAClB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,GAAG,CAAA;IACpC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,YAAmD,CAAA;IAE9E,MAAM,CAAC,GAAG,KAAK,GAAG,MAAM,CAAC,WAAY,CAAA;IACrC,MAAM,CAAC,GAAG,YAAY,GAAG,CAAC,GAAG,cAAc,CAAA;IAE3C,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;IAE7E,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,kBAAmB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAChD,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAEvB,MAAM,WAAW,GAAG,eAAe,CACjC,IAAI,EACJ,gBAAgB,CAAC,MAAM,CAAC,kBAAmB,CAAC,EAC5C,CAAC,EACD,CAAC,CACF,CAAA;IACD,MAAM,cAAc,GAAG,kBAAkB,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAE5D,OAAO;QACL,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,cAAc;KACrB,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,QAAQ;IACR,MAAM;CACP,CAAA"}
|
package/dist/operator.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { OperatorSpecification } from '@swirly/types';
|
|
2
|
-
import { RendererContext, UpdatableRendererResult } from './types';
|
|
2
|
+
import { RendererContext, UpdatableRendererResult } from './types.js';
|
|
3
3
|
export declare const renderOperator: (ctx: RendererContext, operator: OperatorSpecification) => UpdatableRendererResult;
|
package/dist/operator.js
CHANGED
|
@@ -1,13 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { streamParser } from '@swirly/parser';
|
|
2
|
+
import { renderStreamBase } from './stream/core.js';
|
|
3
|
+
import { mergeStyles } from './util/merge-styles.js';
|
|
4
|
+
import { createSvgDocument, createSvgElement, setSvgDimensions, XHTML_NS } from './util/svg-xml.js';
|
|
5
|
+
const NON_BREAKING_SPACE = '\xA0';
|
|
6
|
+
const reSpace = / /g;
|
|
7
|
+
const createRootDiv = (document, styles) => {
|
|
8
|
+
const $div = document.createElementNS(XHTML_NS, 'div');
|
|
9
|
+
$div.setAttribute('style', Object.entries(styles)
|
|
10
|
+
.map(([name, value]) => `${name}: ${value};`)
|
|
11
|
+
.join(' '));
|
|
12
|
+
return $div;
|
|
13
|
+
};
|
|
14
|
+
const renderStream = (text, ctx) => {
|
|
15
|
+
const content = [];
|
|
16
|
+
streamParser.run([text], {
|
|
17
|
+
content,
|
|
18
|
+
diagramStyles: {},
|
|
19
|
+
messageStyles: {},
|
|
20
|
+
allValues: {}
|
|
21
|
+
});
|
|
22
|
+
const [spec] = content;
|
|
23
|
+
const { element: $group, bbox: { x2: width, y2: height } } = renderStreamBase(ctx, spec, false, false);
|
|
24
|
+
return {
|
|
25
|
+
$group,
|
|
26
|
+
width,
|
|
27
|
+
height
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
const segmentRenderers = {
|
|
31
|
+
text: (value, ctx) => {
|
|
32
|
+
const $div = ctx.document.createElement('div');
|
|
33
|
+
$div.textContent = value.replace(reSpace, NON_BREAKING_SPACE);
|
|
34
|
+
return $div;
|
|
35
|
+
},
|
|
36
|
+
stream: (value, ctx, styles) => {
|
|
37
|
+
const { documentElement: $svg } = createSvgDocument(ctx.DOMParser);
|
|
38
|
+
const { $group, width, height } = renderStream(value, ctx);
|
|
39
|
+
setSvgDimensions($svg, width, height, (styles.stream_scale ?? 100) / 100);
|
|
40
|
+
$svg.appendChild($group);
|
|
41
|
+
return $svg;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const renderRichTitle = (segments, ctx, color, styles, fontStyles) => {
|
|
45
|
+
const $foreignObject = createSvgElement(ctx.document, 'foreignObject', {
|
|
46
|
+
y: styles.spacing,
|
|
47
|
+
height: styles.height
|
|
48
|
+
});
|
|
49
|
+
const $container = createRootDiv(ctx.document, {
|
|
50
|
+
width: '100%',
|
|
51
|
+
height: '100%',
|
|
52
|
+
display: 'flex',
|
|
53
|
+
'align-items': 'center',
|
|
54
|
+
'justify-content': 'center',
|
|
55
|
+
color,
|
|
56
|
+
...fontStyles
|
|
57
|
+
});
|
|
58
|
+
$foreignObject.appendChild($container);
|
|
59
|
+
for (const { type, value } of segments) {
|
|
60
|
+
const $element = segmentRenderers[type](value, ctx, styles);
|
|
61
|
+
$container.appendChild($element);
|
|
62
|
+
}
|
|
63
|
+
return $foreignObject;
|
|
64
|
+
};
|
|
65
|
+
const renderTextTitle = (text, ctx, color, styles, fontStyles) => createSvgElement(ctx.document, 'text', {
|
|
66
|
+
x: styles.spacing,
|
|
67
|
+
y: styles.spacing + styles.height / 2,
|
|
68
|
+
fill: color,
|
|
69
|
+
'dominant-baseline': 'middle',
|
|
70
|
+
'text-anchor': 'middle',
|
|
71
|
+
...fontStyles
|
|
72
|
+
}, text);
|
|
73
|
+
const renderTitle = (segments, ctx, styles) => {
|
|
74
|
+
const color = styles.title_color;
|
|
75
|
+
const fontStyles = {
|
|
76
|
+
'font-family': styles.title_font_family,
|
|
77
|
+
'font-size': styles.title_font_size + 'px',
|
|
78
|
+
'font-weight': styles.title_font_weight,
|
|
79
|
+
'font-style': styles.title_font_style
|
|
80
|
+
};
|
|
81
|
+
const isText = segments.length === 1 && segments[0].type === 'text';
|
|
82
|
+
const $title = isText
|
|
83
|
+
? renderTextTitle(segments[0].value, ctx, color, styles, fontStyles)
|
|
84
|
+
: renderRichTitle(segments, ctx, color, styles, fontStyles);
|
|
85
|
+
return { $title, shouldCenter: isText };
|
|
86
|
+
};
|
|
87
|
+
export const renderOperator = (ctx, operator) => {
|
|
88
|
+
const s = mergeStyles(ctx.styles, operator.styles, 'operator_');
|
|
89
|
+
const $group = createSvgElement(ctx.document, 'g');
|
|
90
|
+
const $rect = createSvgElement(ctx.document, 'rect', {
|
|
11
91
|
x: 0,
|
|
12
92
|
y: s.spacing,
|
|
13
93
|
width: 1,
|
|
@@ -18,18 +98,8 @@ const renderOperator = (ctx, operator) => {
|
|
|
18
98
|
rx: s.corner_radius
|
|
19
99
|
});
|
|
20
100
|
$group.appendChild($rect);
|
|
21
|
-
const $
|
|
22
|
-
|
|
23
|
-
y: s.spacing + s.height / 2,
|
|
24
|
-
fill: s.title_color,
|
|
25
|
-
'font-family': s.title_font_family,
|
|
26
|
-
'font-size': s.title_font_size + 'px',
|
|
27
|
-
'font-weight': s.title_font_weight,
|
|
28
|
-
'font-style': s.title_font_style,
|
|
29
|
-
'dominant-baseline': 'middle',
|
|
30
|
-
'text-anchor': 'middle'
|
|
31
|
-
}, operator.title);
|
|
32
|
-
$group.appendChild($text);
|
|
101
|
+
const { $title, shouldCenter } = renderTitle(operator.title, ctx, s);
|
|
102
|
+
$group.appendChild($title);
|
|
33
103
|
const bbox = {
|
|
34
104
|
x1: 0,
|
|
35
105
|
y1: 0,
|
|
@@ -38,8 +108,10 @@ const renderOperator = (ctx, operator) => {
|
|
|
38
108
|
};
|
|
39
109
|
const update = ({ width }) => {
|
|
40
110
|
$rect.setAttribute('width', String(width));
|
|
41
|
-
$
|
|
42
|
-
|
|
111
|
+
$title.setAttribute('width', String(width));
|
|
112
|
+
if (shouldCenter) {
|
|
113
|
+
$title.setAttribute('x', String(width / 2));
|
|
114
|
+
}
|
|
43
115
|
};
|
|
44
116
|
return {
|
|
45
117
|
element: $group,
|
|
@@ -47,5 +119,4 @@ const renderOperator = (ctx, operator) => {
|
|
|
47
119
|
update
|
|
48
120
|
};
|
|
49
121
|
};
|
|
50
|
-
exports.renderOperator = renderOperator;
|
|
51
122
|
//# sourceMappingURL=operator.js.map
|
package/dist/operator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operator.js","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operator.js","sourceRoot":"","sources":["../src/operator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAU7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAMnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACT,MAAM,mBAAmB,CAAA;AAE1B,MAAM,kBAAkB,GAAG,MAAM,CAAA;AAEjC,MAAM,OAAO,GAAG,IAAI,CAAA;AAEpB,MAAM,aAAa,GAAG,CAAC,QAAkB,EAAE,MAA2B,EAAE,EAAE;IACxE,MAAM,IAAI,GAAG,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;IACtD,IAAI,CAAC,YAAY,CACf,OAAO,EACP,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SACnB,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,KAAK,GAAG,CAAC;SAC5C,IAAI,CAAC,GAAG,CAAC,CACb,CAAA;IACD,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,GAAoB,EAAE,EAAE;IAC1D,MAAM,OAAO,GAAmB,EAAE,CAAA;IAClC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE;QACvB,OAAO;QACP,aAAa,EAA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QAC/B,EAAE,EAAE,CAAC,CAAC,aAAc;KACrB,CAAC,CAAA;IACF,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAEzB,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,CAAA;IACpE,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;IAE1B,MAAM,IAAI,GAAG;QACX,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC;QACL,EAAE,EAAE,CAAC,CAAC,MAAO,GAAG,CAAC,GAAG,CAAC,CAAC,OAAQ;KAC/B,CAAA;IAED,MAAM,MAAM,GAAG,CAAC,EAAE,KAAK,EAA2B,EAAE,EAAE;QACpD,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC1C,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAC3C,IAAI,YAAY,EAAE;YAChB,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;SAC5C;IACH,CAAC,CAAA;IAED,OAAO;QACL,OAAO,EAAE,MAAM;QACf,IAAI;QACJ,MAAM;KACP,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderStreamBase: (ctx: import("../types.js").RendererContext, stream: import("packages/swirly-types/src/stream.js").StreamSpecification, isHigherOrder: boolean, isGhost: boolean) => import("../types.js").RendererResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/stream/core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAEjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,aAAa,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StreamSpecification } from '@swirly/types';
|
|
2
|
-
import { MessageRenderer, RendererContext, RendererResult } from '
|
|
3
|
-
export declare const createRenderStream: (renderMessage: MessageRenderer) => (ctx: RendererContext, isHigherOrder: boolean,
|
|
2
|
+
import { MessageRenderer, RendererContext, RendererResult } from '../types.js';
|
|
3
|
+
export declare const createRenderStream: (renderMessage: MessageRenderer) => (ctx: RendererContext, stream: StreamSpecification, isHigherOrder: boolean, isGhost: boolean) => RendererResult;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const merge_styles_1 = require("./util/merge-styles");
|
|
10
|
-
const notification_kind_1 = require("./util/notification-kind");
|
|
11
|
-
const transform_1 = require("./util/transform");
|
|
1
|
+
import { renderArrow } from '../arrow.js';
|
|
2
|
+
import { renderDecoration } from '../decoration/index.js';
|
|
3
|
+
import { degreesToRadians } from '../util/degrees-to-radians.js';
|
|
4
|
+
import { rectangleUnion } from '../util/geometry.js';
|
|
5
|
+
import { mergeStyles } from '../util/merge-styles.js';
|
|
6
|
+
import { NotificationKind } from '../util/notification-kind.js';
|
|
7
|
+
import { createSvgElement } from '../util/svg-xml.js';
|
|
8
|
+
import { translate } from '../util/transform.js';
|
|
12
9
|
const nullScaleTime = (time) => time;
|
|
13
10
|
const createScaleTime = (higherOrderAngleDegrees) => {
|
|
14
|
-
const scale = 1 / Math.cos(
|
|
11
|
+
const scale = 1 / Math.cos(degreesToRadians(higherOrderAngleDegrees));
|
|
15
12
|
return (time) => time * scale;
|
|
16
13
|
};
|
|
17
|
-
const isNotification = ({ notification: { kind } }) =>
|
|
14
|
+
const isNotification = ({ notification: { kind } }) => NotificationKind.NEXT.equals(kind);
|
|
18
15
|
const countPriors = (message, index, messages) => {
|
|
19
16
|
let count = 0;
|
|
20
17
|
for (let i = 0; i < index; ++i) {
|
|
@@ -24,20 +21,24 @@ const countPriors = (message, index, messages) => {
|
|
|
24
21
|
}
|
|
25
22
|
return count;
|
|
26
23
|
};
|
|
27
|
-
const createRenderStream = (renderMessage) => (ctx, isHigherOrder,
|
|
24
|
+
export const createRenderStream = (renderMessage) => (ctx, stream, isHigherOrder, isGhost) => {
|
|
28
25
|
const { document, styles } = ctx;
|
|
29
26
|
const scaleTime = isHigherOrder
|
|
30
27
|
? createScaleTime(styles.higher_order_angle)
|
|
31
28
|
: nullScaleTime;
|
|
32
|
-
const $group = (
|
|
29
|
+
const $group = createSvgElement(document, 'g', isGhost
|
|
30
|
+
? {
|
|
31
|
+
style: `filter: opacity(${styles.ghost_opacity}%)`
|
|
32
|
+
}
|
|
33
|
+
: undefined);
|
|
33
34
|
const bboxes = [];
|
|
34
35
|
const add = ({ element, bbox }) => {
|
|
35
36
|
$group.appendChild(element);
|
|
36
37
|
bboxes.push(bbox);
|
|
37
38
|
};
|
|
38
|
-
const arrowStyles =
|
|
39
|
+
const arrowStyles = mergeStyles(styles, stream.styles, 'arrow_', true);
|
|
39
40
|
const scaledDuration = scaleTime(stream.duration);
|
|
40
|
-
add(
|
|
41
|
+
add(renderArrow(ctx, arrowStyles, styles.arrowhead_angle, scaledDuration));
|
|
41
42
|
for (let i = stream.messages.length - 1; i >= 0; --i) {
|
|
42
43
|
const message = stream.messages[i];
|
|
43
44
|
const scaledMessage = {
|
|
@@ -56,21 +57,21 @@ const createRenderStream = (renderMessage) => (ctx, isHigherOrder, stream) => {
|
|
|
56
57
|
valueAngle
|
|
57
58
|
};
|
|
58
59
|
const { element, bbox } = renderMessage(ctx, scaledMessage, options);
|
|
59
|
-
|
|
60
|
+
translate(element, 0, dy);
|
|
60
61
|
bbox.y2 += dy;
|
|
61
62
|
add({ element, bbox });
|
|
62
63
|
}
|
|
63
64
|
const innerCtx = {
|
|
64
65
|
...ctx,
|
|
65
66
|
scaleTime,
|
|
66
|
-
bbox:
|
|
67
|
+
bbox: rectangleUnion(bboxes)
|
|
67
68
|
};
|
|
68
69
|
if (stream.decorations != null) {
|
|
69
70
|
for (const decoration of stream.decorations) {
|
|
70
|
-
const { element, bbox } =
|
|
71
|
+
const { element, bbox } = renderDecoration(innerCtx, decoration);
|
|
71
72
|
$group.appendChild(element);
|
|
72
73
|
if (bbox != null) {
|
|
73
|
-
innerCtx.bbox =
|
|
74
|
+
innerCtx.bbox = rectangleUnion([innerCtx.bbox, bbox]);
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
77
|
}
|
|
@@ -79,5 +80,4 @@ const createRenderStream = (renderMessage) => (ctx, isHigherOrder, stream) => {
|
|
|
79
80
|
bbox: innerCtx.bbox
|
|
80
81
|
};
|
|
81
82
|
};
|
|
82
|
-
|
|
83
|
-
//# sourceMappingURL=stream-factory.js.map
|
|
83
|
+
//# sourceMappingURL=factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../../src/stream/factory.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAQzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,MAAM,aAAa,GAAe,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA;AAEhD,MAAM,eAAe,GAA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EAAE,GAAG,aAAa,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,CAAC,CAAA;QAEpE,SAAS,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,CAAA;QACzB,IAAI,CAAC,EAAE,IAAI,EAAE,CAAA;QAEb,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;KACvB;IAED,MAAM,QAAQ,GAAG;QACf,GAAG,GAAG;QACN,SAAS;QACT,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC;KAC7B,CAAA;IAED,IAAI,MAAM,CAAC,WAAW,IAAI,IAAI,EAAE;QAC9B,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,WAAW,EAAE;YAC3C,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAA;YAChE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YAC3B,IAAI,IAAI,IAAI,IAAI,EAAE;gBAChB,QAAQ,CAAC,IAAI,GAAG,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;aACtD;SACF;KACF;IAED,OAAO;QACL,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,QAAQ,CAAC,IAAI;KACpB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { StreamSpecification } from '@swirly/types';
|
|
2
|
-
import { RendererContext, RendererResult } from '
|
|
2
|
+
import { RendererContext, RendererResult } from '../types.js';
|
|
3
3
|
export declare const renderStream: (ctx: RendererContext, stream: StreamSpecification) => RendererResult;
|