@swirly/renderer 0.18.1-alpha.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/arrow.d.ts +1 -1
- package/dist/arrow.js +9 -13
- 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 +12 -15
- 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} +1 -1
- package/dist/{stream-factory.js → stream/factory.js} +19 -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 +4 -3
- 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 +8 -9
- package/src/arrow.ts +8 -8
- 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 +6 -6
- package/src/operator.ts +152 -27
- package/src/stream/core.ts +4 -0
- package/src/{stream-factory.ts → stream/factory.ts} +10 -10
- package/src/{stream.ts → stream/full.ts} +8 -11
- package/src/types.ts +5 -3
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"full.js","sourceRoot":"","sources":["../../src/stream/full.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAE5C,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,GAAoB,EACpB,MAA2B,EACX,EAAE;IAClB,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,GAAG,GAAG,CAAA;IAClE,MAAM,CAAC,GAAiB,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;IAErE,MAAM,kBAAkB,GAAG,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;IAEtE,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,kBAAkB,CAAA;IAE1D,IAAI,MAAM,CAAC,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,KAAK,GAAG,CAAC,EAAE;QAC5C,MAAM,EAAE,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,WAAY,CAAA;QAC7C,SAAS,CAAC,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QAC9B,IAAI,CAAC,EAAE,IAAI,EAAE,CAAA;QACb,IAAI,CAAC,EAAE,IAAI,EAAE,CAAA;KACd;IAED,IAAI,CAAC,kBAAkB,EAAE;QACvB,OAAO,kBAAkB,CAAA;KAC1B;IAED,MAAM,WAAW,GAAG,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAA;IAEnD,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAA;IAClE,WAAW,CAAC,WAAW,CACrB,gBAAgB,CACd,QAAQ,EACR,MAAM,EACN;QACE,CAAC,EAAE,CAAC;QACJ,CAAC,EAAE,YAAY,GAAG,CAAC;QACnB,IAAI,EAAE,CAAC,CAAC,WAAY;QACpB,aAAa,EAAE,CAAC,CAAC,iBAAkB;QACnC,WAAW,EAAE,CAAC,CAAC,eAAgB,GAAG,IAAI;QACtC,aAAa,EAAE,CAAC,CAAC,iBAAkB;QACnC,YAAY,EAAE,CAAC,CAAC,gBAAiB;QACjC,mBAAmB,EAAE,QAAQ;KAC9B,EACD,KAAK,CACN,CACF,CAAA;IAED,WAAW,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IACrC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC,WAAY,EAAE,CAAC,CAAC,CAAA;IAE1C,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IACX,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,WAAY,CAAA;IAEzB,OAAO;QACL,OAAO,EAAE,WAAW;QACpB,IAAI;KACL,CAAA;AACH,CAAC,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DecorationSpecification, DiagramStyles, MessageSpecification } from '@swirly/types';
|
|
1
|
+
import { DecorationSpecification, DiagramStyles, MessageSpecification, SVGDocument } from '@swirly/types';
|
|
2
2
|
export declare type Point = {
|
|
3
3
|
x: number;
|
|
4
4
|
y: number;
|
|
@@ -15,7 +15,8 @@ export declare type RendererOptions = {
|
|
|
15
15
|
styles?: DiagramStyles;
|
|
16
16
|
};
|
|
17
17
|
export declare type RendererContext = {
|
|
18
|
-
|
|
18
|
+
DOMParser?: typeof DOMParser;
|
|
19
|
+
document: SVGDocument;
|
|
19
20
|
styles: DiagramStyles;
|
|
20
21
|
streamHeight: number;
|
|
21
22
|
streamTitleEnabled: boolean;
|
|
@@ -29,7 +30,7 @@ export declare type PostRenderUpdateContext = {
|
|
|
29
30
|
height: number;
|
|
30
31
|
};
|
|
31
32
|
export declare type UpdatableRendererResult = RendererResult & {
|
|
32
|
-
update
|
|
33
|
+
update?: (ctx: PostRenderUpdateContext) => void;
|
|
33
34
|
};
|
|
34
35
|
export declare type MessageRendererOptions = {
|
|
35
36
|
verticalOffset: number;
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.degreesToRadians = void 0;
|
|
4
|
-
const degreesToRadians = (degrees) => (degrees / 180) * Math.PI;
|
|
5
|
-
exports.degreesToRadians = degreesToRadians;
|
|
1
|
+
export const degreesToRadians = (degrees) => (degrees / 180) * Math.PI;
|
|
6
2
|
//# 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":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,OAAe,EAAU,EAAE,CAC1D,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,CAAA"}
|
package/dist/util/geometry.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Point, Rectangle } from '../types';
|
|
1
|
+
import { Point, Rectangle } from '../types.js';
|
|
2
2
|
export declare const translatePoint: (x: number, y: number, dx: number, dy: number) => Point;
|
|
3
3
|
export declare const translateRectangle: ({ x1, y1, x2, y2 }: Rectangle, dx: number, dy: number) => Rectangle;
|
|
4
4
|
export declare const rotatePoint: (x: number, y: number, angle: number, x0: number, y0: number) => Point;
|
package/dist/util/geometry.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rectangleUnion = exports.rotateRectangle = exports.rotatePoint = exports.translateRectangle = exports.translatePoint = void 0;
|
|
4
|
-
const translatePoint = (x, y, dx, dy) => ({
|
|
1
|
+
export const translatePoint = (x, y, dx, dy) => ({
|
|
5
2
|
x: x + dx,
|
|
6
3
|
y: y + dy
|
|
7
4
|
});
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const p2 = (0, exports.translatePoint)(x2, y2, dx, dy);
|
|
5
|
+
export const translateRectangle = ({ x1, y1, x2, y2 }, dx, dy) => {
|
|
6
|
+
const p1 = translatePoint(x1, y1, dx, dy);
|
|
7
|
+
const p2 = translatePoint(x2, y2, dx, dy);
|
|
12
8
|
return {
|
|
13
9
|
x1: p1.x,
|
|
14
10
|
y1: p1.y,
|
|
@@ -16,8 +12,7 @@ const translateRectangle = ({ x1, y1, x2, y2 }, dx, dy) => {
|
|
|
16
12
|
y2: p2.y
|
|
17
13
|
};
|
|
18
14
|
};
|
|
19
|
-
|
|
20
|
-
const rotatePoint = (x, y, angle, x0, y0) => {
|
|
15
|
+
export const rotatePoint = (x, y, angle, x0, y0) => {
|
|
21
16
|
const s = Math.sin(angle);
|
|
22
17
|
const c = Math.cos(angle);
|
|
23
18
|
x -= x0;
|
|
@@ -27,10 +22,9 @@ const rotatePoint = (x, y, angle, x0, y0) => {
|
|
|
27
22
|
y: x * s + y * c + y0
|
|
28
23
|
};
|
|
29
24
|
};
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const p2 = (0, exports.rotatePoint)(x2, y2, angle, x0, y0);
|
|
25
|
+
export const rotateRectangle = ({ x1, y1, x2, y2 }, angle, x0, y0) => {
|
|
26
|
+
const p1 = rotatePoint(x1, y1, angle, x0, y0);
|
|
27
|
+
const p2 = rotatePoint(x2, y2, angle, x0, y0);
|
|
34
28
|
return {
|
|
35
29
|
x1: p1.x,
|
|
36
30
|
y1: p1.y,
|
|
@@ -38,8 +32,7 @@ const rotateRectangle = ({ x1, y1, x2, y2 }, angle, x0, y0) => {
|
|
|
38
32
|
y2: p2.y
|
|
39
33
|
};
|
|
40
34
|
};
|
|
41
|
-
|
|
42
|
-
const rectangleUnion = (rects) => {
|
|
35
|
+
export const rectangleUnion = (rects) => {
|
|
43
36
|
const nonEmptyRects = rects.filter(({ x1, y1, x2, y2 }) => x2 - x1 !== 0 && y2 - y1 !== 0);
|
|
44
37
|
if (nonEmptyRects.length === 0) {
|
|
45
38
|
throw new Error('All rectangles empty');
|
|
@@ -51,5 +44,4 @@ const rectangleUnion = (rects) => {
|
|
|
51
44
|
y2: Math.max(...nonEmptyRects.map((rect) => rect.y2))
|
|
52
45
|
};
|
|
53
46
|
};
|
|
54
|
-
exports.rectangleUnion = rectangleUnion;
|
|
55
47
|
//# 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
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hexToDec = void 0;
|
|
4
1
|
const A = 'A'.charCodeAt(0);
|
|
5
2
|
const ZERO = '0'.charCodeAt(0);
|
|
6
|
-
const hexToDec = (hex) => {
|
|
3
|
+
export const hexToDec = (hex) => {
|
|
7
4
|
let dec = 0;
|
|
8
5
|
hex = hex.toUpperCase();
|
|
9
6
|
for (let i = 0; i < hex.length; ++i) {
|
|
@@ -12,5 +9,4 @@ const hexToDec = (hex) => {
|
|
|
12
9
|
}
|
|
13
10
|
return dec;
|
|
14
11
|
};
|
|
15
|
-
exports.hexToDec = hexToDec;
|
|
16
12
|
//# 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":"
|
|
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;AAE9B,MAAM,CAAC,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"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mergeStyles = void 0;
|
|
4
|
-
const mergeStyles = (globalStyles, localStyles, globalPrefix, localStylesPrefixed = false) => {
|
|
1
|
+
export const mergeStyles = (globalStyles, localStyles, globalPrefix, localStylesPrefixed = false) => {
|
|
5
2
|
const result = {};
|
|
6
3
|
const globalKeys = Object.keys(globalStyles).filter((key) => key.startsWith(globalPrefix));
|
|
7
4
|
for (const globalKey of globalKeys) {
|
|
8
|
-
const simpleKey = globalKey.
|
|
5
|
+
const simpleKey = globalKey.substring(globalPrefix.length);
|
|
9
6
|
const localKey = localStylesPrefixed ? globalKey : simpleKey;
|
|
10
7
|
result[simpleKey] =
|
|
11
8
|
localStyles != null && localStyles[localKey] != null
|
|
@@ -14,5 +11,4 @@ const mergeStyles = (globalStyles, localStyles, globalPrefix, localStylesPrefixe
|
|
|
14
11
|
}
|
|
15
12
|
return result;
|
|
16
13
|
};
|
|
17
|
-
exports.mergeStyles = mergeStyles;
|
|
18
14
|
//# 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":"AAEA,MAAM,CAAC,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,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;QAC1D,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"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotificationKind = void 0;
|
|
4
|
-
class NotificationKind {
|
|
1
|
+
export class NotificationKind {
|
|
5
2
|
static NEXT = new NotificationKind('N');
|
|
6
3
|
static COMPLETE = new NotificationKind('C');
|
|
7
4
|
static ERROR = new NotificationKind('E');
|
|
@@ -13,5 +10,4 @@ class NotificationKind {
|
|
|
13
10
|
return typeof x === 'string' && x.charAt(0).toUpperCase() === this.char;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
exports.NotificationKind = NotificationKind;
|
|
17
13
|
//# sourceMappingURL=notification-kind.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification-kind.js","sourceRoot":"","sources":["../../src/util/notification-kind.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"notification-kind.js","sourceRoot":"","sources":["../../src/util/notification-kind.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,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"}
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringToColor = void 0;
|
|
4
1
|
// @ts-ignore
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const stringToColor = (str, mode) => {
|
|
8
|
-
const hashHex = (
|
|
9
|
-
const hash =
|
|
2
|
+
import { sync as sha1 } from 'simple-sha1';
|
|
3
|
+
import { hexToDec } from './hex-to-dec.js';
|
|
4
|
+
export const stringToColor = (str, mode) => {
|
|
5
|
+
const hashHex = sha1(str);
|
|
6
|
+
const hash = hexToDec(hashHex.substring(4, 8));
|
|
10
7
|
const hue = Math.round((hash / (1 << 16)) * 360);
|
|
11
8
|
const saturation = 60;
|
|
12
9
|
const lightness = mode === 'dark' ? 20 : 80;
|
|
13
10
|
return `hsl(${hue}, ${saturation}%, ${lightness}%)`;
|
|
14
11
|
};
|
|
15
|
-
exports.stringToColor = stringToColor;
|
|
16
12
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"string-to-color.js","sourceRoot":"","sources":["../../src/util/string-to-color.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,IAAI,IAAI,IAAI,EAAE,MAAM,aAAa,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,GAAW,EAAE,IAAsB,EAAU,EAAE;IAC3E,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAA;IACzB,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAC9C,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"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SVGDocument } from '@swirly/types';
|
|
2
|
+
export declare const SVG_NS = "http://www.w3.org/2000/svg";
|
|
3
|
+
export declare const SVG_MIME_TYPE = "image/svg+xml";
|
|
4
|
+
export declare const XHTML_NS = "http://www.w3.org/1999/xhtml";
|
|
5
|
+
export declare const createSvgDocument: (DOMParserImpl?: typeof DOMParser) => SVGDocument;
|
|
6
|
+
export declare const createSvgElement: (document: SVGDocument, name: string, attrs?: Record<string, any>, text?: string) => SVGElement;
|
|
7
|
+
export declare const setSvgDimensions: ($svg: SVGSVGElement, width: number, height: number, scale?: number) => void;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export const SVG_NS = 'http://www.w3.org/2000/svg';
|
|
2
|
+
export const SVG_MIME_TYPE = 'image/svg+xml';
|
|
3
|
+
export const XHTML_NS = 'http://www.w3.org/1999/xhtml';
|
|
4
|
+
const EMPTY_SVG_XML = `<svg xmlns="${SVG_NS}"/>`;
|
|
5
|
+
const parseXml = (xml, mimeType, DOMParserImpl = DOMParser) => new DOMParserImpl().parseFromString(xml, mimeType);
|
|
6
|
+
export const createSvgDocument = (DOMParserImpl) => parseXml(EMPTY_SVG_XML, SVG_MIME_TYPE, DOMParserImpl);
|
|
7
|
+
export const createSvgElement = (document, name, attrs = {}, text = '') => {
|
|
8
|
+
const $el = document.createElementNS(SVG_NS, name);
|
|
9
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
10
|
+
$el.setAttribute(name, String(value));
|
|
11
|
+
}
|
|
12
|
+
if (text !== '') {
|
|
13
|
+
$el.textContent = text;
|
|
14
|
+
}
|
|
15
|
+
return $el;
|
|
16
|
+
};
|
|
17
|
+
export const setSvgDimensions = ($svg, width, height, scale = 1) => {
|
|
18
|
+
$svg.setAttribute('viewBox', `0 0 ${width} ${height}`);
|
|
19
|
+
$svg.setAttribute('width', String(width * scale));
|
|
20
|
+
$svg.setAttribute('height', String(height * scale));
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=svg-xml.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-xml.js","sourceRoot":"","sources":["../../src/util/svg-xml.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,MAAM,GAAG,4BAA4B,CAAA;AAClD,MAAM,CAAC,MAAM,aAAa,GAAG,eAAe,CAAA;AAE5C,MAAM,CAAC,MAAM,QAAQ,GAAG,8BAA8B,CAAA;AAEtD,MAAM,aAAa,GAAG,eAAe,MAAM,KAAK,CAAA;AAEhD,MAAM,QAAQ,GAAG,CACf,GAAW,EACX,QAAgB,EAChB,gBAAkC,SAAS,EAC3C,EAAE,CAAC,IAAI,aAAa,EAAE,CAAC,eAAe,CAAC,GAAG,EAAE,QAAe,CAAgB,CAAA;AAE7E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,aAAgC,EAAE,EAAE,CACpE,QAAQ,CAAC,aAAa,EAAE,aAAa,EAAE,aAAa,CAAgB,CAAA;AAEtE,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAqB,EACrB,IAAY,EACZ,QAA6B,EAAE,EAC/B,OAAe,EAAE,EACL,EAAE;IACd,MAAM,GAAG,GAAG,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;IAClD,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;IACD,IAAI,IAAI,KAAK,EAAE,EAAE;QACf,GAAG,CAAC,WAAW,GAAG,IAAI,CAAA;KACvB;IACD,OAAO,GAAG,CAAA;AACZ,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAmB,EACnB,KAAa,EACb,MAAc,EACd,QAAgB,CAAC,EACjB,EAAE;IACF,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,MAAM,EAAE,CAAC,CAAA;IACtD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,CAAA;IACjD,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAA;AACrD,CAAC,CAAA"}
|
package/dist/util/transform.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.rotate = exports.translate = exports.transform = void 0;
|
|
4
|
-
const transform = ($element, value) => {
|
|
1
|
+
export const transform = ($element, value) => {
|
|
5
2
|
const existing = $element.getAttribute('transform');
|
|
6
3
|
const updated = (existing != null && existing !== '' ? existing + ' ' : '') + value;
|
|
7
4
|
$element.setAttribute('transform', updated);
|
|
8
5
|
};
|
|
9
|
-
|
|
10
|
-
const translate = ($element, x, y) => {
|
|
6
|
+
export const translate = ($element, x, y) => {
|
|
11
7
|
if (x === 0 && y === 0) {
|
|
12
8
|
return;
|
|
13
9
|
}
|
|
14
|
-
|
|
10
|
+
transform($element, `translate(${x} ${y})`);
|
|
15
11
|
};
|
|
16
|
-
|
|
17
|
-
const rotate = ($element, angle, x = 0, y = 0) => {
|
|
12
|
+
export const rotate = ($element, angle, x = 0, y = 0) => {
|
|
18
13
|
if (angle === 0) {
|
|
19
14
|
return;
|
|
20
15
|
}
|
|
21
|
-
|
|
16
|
+
transform($element, `rotate(${angle} ${x} ${y})`);
|
|
22
17
|
};
|
|
23
|
-
exports.rotate = rotate;
|
|
24
18
|
//# 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":"AAAA,MAAM,CAAC,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;AAED,MAAM,CAAC,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,SAAS,CAAC,QAAQ,EAAE,aAAa,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED,MAAM,CAAC,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,SAAS,CAAC,QAAQ,EAAE,UAAU,KAAK,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACnD,CAAC,CAAA"}
|
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.19.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -13,36 +13,35 @@
|
|
|
13
13
|
"name": "Tim De Pauw",
|
|
14
14
|
"url": "https://tmdpw.eu"
|
|
15
15
|
},
|
|
16
|
+
"type": "module",
|
|
16
17
|
"publishConfig": {
|
|
17
18
|
"access": "public"
|
|
18
19
|
},
|
|
19
20
|
"main": "dist/index.js",
|
|
20
|
-
"browser": "src/index.ts",
|
|
21
21
|
"files": [
|
|
22
22
|
"src/",
|
|
23
23
|
"dist/"
|
|
24
24
|
],
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "yarn run clean &&
|
|
27
|
-
"build:tsconfig": "node ../../scripts/build-tsconfig.js",
|
|
28
|
-
"build:js": "tsc",
|
|
26
|
+
"build": "yarn run clean && ../../scripts/build-ts.sh",
|
|
29
27
|
"clean": "shx rm -rf dist",
|
|
30
28
|
"prepare": "yarn run build"
|
|
31
29
|
},
|
|
32
30
|
"engines": {
|
|
33
|
-
"node": ">=14"
|
|
31
|
+
"node": ">=14.13.1"
|
|
34
32
|
},
|
|
35
33
|
"dependencies": {
|
|
36
|
-
"@swirly/
|
|
34
|
+
"@swirly/parser": "^0.19.1",
|
|
35
|
+
"@swirly/theme-default-light": "^0.19.1",
|
|
37
36
|
"simple-sha1": "^3.1.0"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|
|
40
|
-
"@swirly/types": "^0.
|
|
39
|
+
"@swirly/types": "^0.19.1",
|
|
41
40
|
"shx": "^0.3.3"
|
|
42
41
|
},
|
|
43
42
|
"funding": {
|
|
44
43
|
"type": "github",
|
|
45
44
|
"url": "https://github.com/sponsors/timdp"
|
|
46
45
|
},
|
|
47
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "8a6f346941ee49747adf65323992f03859471706"
|
|
48
47
|
}
|
package/src/arrow.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { RendererContext, RendererResult } from './types'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { RendererContext, RendererResult } from './types.js'
|
|
2
|
+
import { degreesToRadians } from './util/degrees-to-radians.js'
|
|
3
|
+
import { createSvgElement } from './util/svg-xml.js'
|
|
4
4
|
|
|
5
5
|
export const renderArrow = (
|
|
6
6
|
{ document, styles, streamHeight }: RendererContext,
|
|
@@ -19,10 +19,10 @@ export const renderArrow = (
|
|
|
19
19
|
const fillColor = arrowStyles.fill_color!
|
|
20
20
|
const filled = typeof fillColor === 'string' && fillColor !== ''
|
|
21
21
|
|
|
22
|
-
const $group =
|
|
22
|
+
const $group = createSvgElement(document, 'g')
|
|
23
23
|
|
|
24
24
|
$group.appendChild(
|
|
25
|
-
|
|
25
|
+
createSvgElement(document, 'line', {
|
|
26
26
|
x1: 0,
|
|
27
27
|
y1: y,
|
|
28
28
|
x2: width - (filled ? arrowheadWidth : 0),
|
|
@@ -39,7 +39,7 @@ export const renderArrow = (
|
|
|
39
39
|
]
|
|
40
40
|
|
|
41
41
|
$group.appendChild(
|
|
42
|
-
|
|
42
|
+
createSvgElement(document, filled ? 'polygon' : 'polyline', {
|
|
43
43
|
points: points.join(' '),
|
|
44
44
|
fill: filled ? fillColor : 'none',
|
|
45
45
|
stroke: arrowStyles.stroke_color!,
|
|
@@ -50,9 +50,9 @@ export const renderArrow = (
|
|
|
50
50
|
|
|
51
51
|
const bbox = {
|
|
52
52
|
x1: 0,
|
|
53
|
-
y1,
|
|
53
|
+
y1: 0,
|
|
54
54
|
x2: width,
|
|
55
|
-
y2
|
|
55
|
+
y2: streamHeight
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
return {
|
|
@@ -4,10 +4,13 @@ import {
|
|
|
4
4
|
DecorationSpecification
|
|
5
5
|
} from '@swirly/types'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {
|
|
8
|
+
DecorationRendererContext,
|
|
9
|
+
DecorationRendererResult
|
|
10
|
+
} from '../types.js'
|
|
11
|
+
import { mergeStyles } from '../util/merge-styles.js'
|
|
12
|
+
import { createSvgElement } from '../util/svg-xml.js'
|
|
13
|
+
import { translate } from '../util/transform.js'
|
|
11
14
|
|
|
12
15
|
export const renderBarrierDecoration = (
|
|
13
16
|
{ document, styles, bbox, scaleTime }: DecorationRendererContext,
|
|
@@ -22,7 +25,7 @@ export const renderBarrierDecoration = (
|
|
|
22
25
|
const y = bbox.y1
|
|
23
26
|
const height = bbox.y2 - bbox.y1
|
|
24
27
|
|
|
25
|
-
const $line =
|
|
28
|
+
const $line = createSvgElement(document, 'line', {
|
|
26
29
|
x1: 0,
|
|
27
30
|
y1: 0,
|
|
28
31
|
x2: 0,
|
package/src/decoration/index.ts
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
DecorationRenderer,
|
|
5
5
|
DecorationRendererContext,
|
|
6
6
|
DecorationRendererResult
|
|
7
|
-
} from '../types'
|
|
8
|
-
import { renderBarrierDecoration } from './barrier'
|
|
9
|
-
import { renderRangeDecoration } from './range'
|
|
7
|
+
} from '../types.js'
|
|
8
|
+
import { renderBarrierDecoration } from './barrier.js'
|
|
9
|
+
import { renderRangeDecoration } from './range.js'
|
|
10
10
|
|
|
11
11
|
const strategies: Record<string, DecorationRenderer> = {
|
|
12
12
|
barrier: renderBarrierDecoration,
|
package/src/decoration/range.ts
CHANGED
|
@@ -4,10 +4,13 @@ import {
|
|
|
4
4
|
RangeDecorationStyles
|
|
5
5
|
} from '@swirly/types'
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {
|
|
8
|
+
DecorationRendererContext,
|
|
9
|
+
DecorationRendererResult
|
|
10
|
+
} from '../types.js'
|
|
11
|
+
import { mergeStyles } from '../util/merge-styles.js'
|
|
12
|
+
import { createSvgElement } from '../util/svg-xml.js'
|
|
13
|
+
import { translate } from '../util/transform.js'
|
|
11
14
|
|
|
12
15
|
export const renderRangeDecoration = (
|
|
13
16
|
{ document, styles, streamHeight, scaleTime }: DecorationRendererContext,
|
|
@@ -26,7 +29,7 @@ export const renderRangeDecoration = (
|
|
|
26
29
|
const width = scaleTime(duration) * styles.frame_width!
|
|
27
30
|
const height = s.height!
|
|
28
31
|
|
|
29
|
-
const $rect =
|
|
32
|
+
const $rect = createSvgElement(document, 'rect', {
|
|
30
33
|
x: 0,
|
|
31
34
|
y: 0,
|
|
32
35
|
width,
|
package/src/index.ts
CHANGED
|
@@ -6,19 +6,20 @@ import {
|
|
|
6
6
|
StreamSpecification
|
|
7
7
|
} from '@swirly/types'
|
|
8
8
|
|
|
9
|
-
import { renderOperator } from './operator'
|
|
10
|
-
import { renderStream } from './stream'
|
|
9
|
+
import { renderOperator } from './operator.js'
|
|
10
|
+
import { renderStream } from './stream/full.js'
|
|
11
11
|
import {
|
|
12
12
|
RendererContext,
|
|
13
13
|
RendererOptions,
|
|
14
14
|
RendererResult,
|
|
15
15
|
UpdatableRendererResult
|
|
16
|
-
} from './types'
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
} from './types.js'
|
|
17
|
+
import {
|
|
18
|
+
createSvgDocument,
|
|
19
|
+
createSvgElement,
|
|
20
|
+
setSvgDimensions
|
|
21
|
+
} from './util/svg-xml.js'
|
|
22
|
+
import { translate } from './util/transform.js'
|
|
22
23
|
|
|
23
24
|
const isOperator = (item: StreamSpecification | OperatorSpecification) =>
|
|
24
25
|
item.kind === 'O'
|
|
@@ -30,20 +31,16 @@ const renderMarbleDiagram = (
|
|
|
30
31
|
spec: DiagramSpecification,
|
|
31
32
|
options: RendererOptions = {}
|
|
32
33
|
): DiagramRendering => {
|
|
33
|
-
const DOMParserImpl: typeof DOMParser =
|
|
34
|
-
options.DOMParser != null ? options.DOMParser : DOMParser
|
|
35
|
-
const parser: DOMParser = new DOMParserImpl()
|
|
36
|
-
const document: XMLDocument = parser.parseFromString(EMPTY_SVG, MIME_TYPE)
|
|
37
|
-
// XXX Typings for Document think it's HTML
|
|
38
|
-
const $svg = document.documentElement as unknown as SVGSVGElement
|
|
39
|
-
|
|
40
34
|
const styles = {
|
|
41
35
|
...lightStyles,
|
|
42
36
|
...options.styles,
|
|
43
37
|
...spec.styles
|
|
44
38
|
}
|
|
45
39
|
|
|
46
|
-
const
|
|
40
|
+
const document = createSvgDocument(options.DOMParser)
|
|
41
|
+
const $svg = document.documentElement
|
|
42
|
+
|
|
43
|
+
const $group = createSvgElement(document, 'g')
|
|
47
44
|
translate($group, styles.canvas_padding!, styles.canvas_padding!)
|
|
48
45
|
$svg.appendChild($group)
|
|
49
46
|
|
|
@@ -58,6 +55,7 @@ const renderMarbleDiagram = (
|
|
|
58
55
|
)
|
|
59
56
|
|
|
60
57
|
const ctx: RendererContext = {
|
|
58
|
+
DOMParser: options.DOMParser,
|
|
61
59
|
document,
|
|
62
60
|
styles,
|
|
63
61
|
streamHeight,
|
|
@@ -92,13 +90,11 @@ const renderMarbleDiagram = (
|
|
|
92
90
|
const width = styles.canvas_padding! + maxX + styles.canvas_padding!
|
|
93
91
|
const height = styles.canvas_padding! + y + styles.canvas_padding!
|
|
94
92
|
|
|
95
|
-
$svg
|
|
96
|
-
$svg.setAttribute('width', String(width))
|
|
97
|
-
$svg.setAttribute('height', String(height))
|
|
93
|
+
setSvgDimensions($svg, width, height)
|
|
98
94
|
|
|
99
95
|
const bgColor = styles.background_color!
|
|
100
96
|
if (bgColor !== '' && bgColor !== 'transparent') {
|
|
101
|
-
const $bg =
|
|
97
|
+
const $bg = createSvgElement(document, 'rect', {
|
|
102
98
|
x: 0,
|
|
103
99
|
y: 0,
|
|
104
100
|
width,
|
package/src/message/complete.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CompletionMessageStyles, MessageSpecification } from '@swirly/types'
|
|
2
2
|
|
|
3
|
-
import { RendererContext, RendererResult } from '../types'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { translate } from '../util/transform'
|
|
3
|
+
import { RendererContext, RendererResult } from '../types.js'
|
|
4
|
+
import { mergeStyles } from '../util/merge-styles.js'
|
|
5
|
+
import { NotificationKind } from '../util/notification-kind.js'
|
|
6
|
+
import { createSvgElement } from '../util/svg-xml.js'
|
|
7
|
+
import { translate } from '../util/transform.js'
|
|
8
8
|
|
|
9
9
|
const supports = ({ notification: { kind } }: MessageSpecification) =>
|
|
10
10
|
NotificationKind.COMPLETE.equals(kind)
|
|
@@ -23,11 +23,11 @@ const render = (
|
|
|
23
23
|
const y1 = (streamHeight - s.height!) / 2
|
|
24
24
|
const y2 = y1 + s.height!
|
|
25
25
|
|
|
26
|
-
const $group =
|
|
26
|
+
const $group = createSvgElement(document, 'g')
|
|
27
27
|
translate($group, x, 0)
|
|
28
28
|
|
|
29
29
|
$group.appendChild(
|
|
30
|
-
|
|
30
|
+
createSvgElement(document, 'line', {
|
|
31
31
|
x1: 0,
|
|
32
32
|
y1,
|
|
33
33
|
x2: 0,
|
package/src/message/error.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ErrorMessageStyles, MessageSpecification } from '@swirly/types'
|
|
2
2
|
|
|
3
|
-
import { RendererContext, RendererResult } from '../types'
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { translate } from '../util/transform'
|
|
3
|
+
import { RendererContext, RendererResult } from '../types.js'
|
|
4
|
+
import { mergeStyles } from '../util/merge-styles.js'
|
|
5
|
+
import { NotificationKind } from '../util/notification-kind.js'
|
|
6
|
+
import { createSvgElement } from '../util/svg-xml.js'
|
|
7
|
+
import { translate } from '../util/transform.js'
|
|
8
8
|
|
|
9
9
|
const supports = ({ notification: { kind } }: MessageSpecification) =>
|
|
10
10
|
NotificationKind.ERROR.equals(kind)
|
|
@@ -18,11 +18,11 @@ const render = (
|
|
|
18
18
|
const x = message.frame * styles.frame_width! - s.size! / 2
|
|
19
19
|
const y = (streamHeight - s.size!) / 2
|
|
20
20
|
|
|
21
|
-
const $group =
|
|
21
|
+
const $group = createSvgElement(document, 'g')
|
|
22
22
|
translate($group, x, y)
|
|
23
23
|
|
|
24
24
|
$group.appendChild(
|
|
25
|
-
|
|
25
|
+
createSvgElement(document, 'line', {
|
|
26
26
|
x1: 0,
|
|
27
27
|
y1: 0,
|
|
28
28
|
x2: s.size!,
|
|
@@ -33,7 +33,7 @@ const render = (
|
|
|
33
33
|
)
|
|
34
34
|
|
|
35
35
|
$group.appendChild(
|
|
36
|
-
|
|
36
|
+
createSvgElement(document, 'line', {
|
|
37
37
|
x1: s.size!,
|
|
38
38
|
y1: 0,
|
|
39
39
|
x2: 0,
|