@antv/g 5.0.23 → 5.0.24
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/index.umd.min.js +3 -2
- package/es/AbstractRenderer.d.ts +11 -0
- package/es/AbstractRenderer.js +17 -2
- package/es/Canvas.d.ts +1 -1
- package/es/components/Geometry.d.ts +0 -4
- package/es/css/CSS.d.ts +2 -1
- package/es/css/CSS.js +5 -1
- package/es/css/StyleValueRegistry.js +3 -16
- package/es/css/index.d.ts +1 -1
- package/es/css/index.js +1 -1
- package/es/css/layout/FragmentResult.d.ts +32 -0
- package/es/css/layout/FragmentResult.js +32 -0
- package/es/css/layout/LayoutChildren.d.ts +23 -0
- package/es/css/layout/LayoutChildren.js +55 -0
- package/es/css/layout/LayoutContext.d.ts +35 -0
- package/es/css/layout/LayoutContext.js +35 -0
- package/es/css/layout/LayoutDefinition.d.ts +20 -0
- package/es/css/layout/LayoutDefinition.js +9 -0
- package/es/css/layout/LayoutEdges.d.ts +24 -0
- package/es/css/layout/LayoutEdges.js +41 -0
- package/es/css/layout/LayoutEngine.d.ts +41 -0
- package/es/css/layout/LayoutEngine.js +332 -0
- package/es/css/layout/LayoutFragment.d.ts +26 -0
- package/es/css/layout/LayoutFragment.js +28 -0
- package/es/css/layout/LayoutObject.d.ts +46 -0
- package/es/css/layout/LayoutObject.js +172 -0
- package/es/css/layout/LayoutRegistry.d.ts +16 -0
- package/es/css/layout/LayoutRegistry.js +78 -0
- package/es/css/layout/LayoutWorkTask.d.ts +14 -0
- package/es/css/layout/LayoutWorkTask.js +1 -0
- package/es/css/layout/index.d.ts +11 -0
- package/es/css/layout/index.js +11 -0
- package/es/css/layout/types.d.ts +104 -0
- package/es/css/layout/types.js +66 -0
- package/es/global-module.js +87 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/services/OffscreenCanvasCreator.d.ts +1 -1
- package/es/services/OffscreenCanvasCreator.js +1 -1
- package/es/services/RenderingService.d.ts +1 -1
- package/es/services/RenderingService.js +1 -1
- package/es/types.d.ts +1 -4
- package/es/utils/deferred.d.ts +43 -0
- package/es/utils/deferred.js +117 -0
- package/es/utils/dom.d.ts +2 -0
- package/es/utils/dom.js +8 -0
- package/es/utils/index.d.ts +2 -0
- package/es/utils/index.js +3 -1
- package/lib/AbstractRenderer.d.ts +11 -0
- package/lib/AbstractRenderer.js +17 -2
- package/lib/Canvas.d.ts +1 -1
- package/lib/components/Geometry.d.ts +0 -4
- package/lib/css/CSS.d.ts +2 -1
- package/lib/css/CSS.js +7 -1
- package/lib/css/StyleValueRegistry.js +3 -17
- package/lib/css/index.d.ts +1 -1
- package/lib/css/index.js +12 -12
- package/lib/css/layout/FragmentResult.d.ts +32 -0
- package/lib/css/layout/FragmentResult.js +51 -0
- package/lib/css/layout/LayoutChildren.d.ts +23 -0
- package/lib/css/layout/LayoutChildren.js +72 -0
- package/lib/css/layout/LayoutContext.d.ts +35 -0
- package/lib/css/layout/LayoutContext.js +49 -0
- package/lib/css/layout/LayoutDefinition.d.ts +20 -0
- package/lib/css/layout/LayoutDefinition.js +16 -0
- package/lib/css/layout/LayoutEdges.d.ts +24 -0
- package/lib/css/layout/LayoutEdges.js +56 -0
- package/lib/css/layout/LayoutEngine.d.ts +41 -0
- package/lib/css/layout/LayoutEngine.js +345 -0
- package/lib/css/layout/LayoutFragment.d.ts +26 -0
- package/lib/css/layout/LayoutFragment.js +44 -0
- package/lib/css/layout/LayoutObject.d.ts +46 -0
- package/lib/css/layout/LayoutObject.js +182 -0
- package/lib/css/layout/LayoutRegistry.d.ts +16 -0
- package/lib/css/layout/LayoutRegistry.js +87 -0
- package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
- package/lib/css/layout/LayoutWorkTask.js +5 -0
- package/lib/css/layout/index.d.ts +11 -0
- package/lib/css/layout/index.js +148 -0
- package/lib/css/layout/types.d.ts +104 -0
- package/lib/css/layout/types.js +74 -0
- package/lib/global-module.js +89 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
- package/lib/services/OffscreenCanvasCreator.js +1 -1
- package/lib/services/RenderingService.d.ts +1 -1
- package/lib/services/RenderingService.js +1 -1
- package/lib/types.d.ts +1 -4
- package/lib/utils/deferred.d.ts +43 -0
- package/lib/utils/deferred.js +131 -0
- package/lib/utils/dom.d.ts +2 -0
- package/lib/utils/dom.js +17 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +26 -0
- package/package.json +3 -3
- package/es/css/LayoutRegistry.d.ts +0 -11
- package/es/css/LayoutRegistry.js +0 -22
- package/lib/css/LayoutRegistry.d.ts +0 -11
- package/lib/css/LayoutRegistry.js +0 -30
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface PromiseStatus<T> {
|
|
2
|
+
isPending: () => boolean;
|
|
3
|
+
isRejected: () => boolean;
|
|
4
|
+
isFulfilled: () => boolean;
|
|
5
|
+
getFullFilledValue: () => T;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* This function allow you to modify a JS Promise by adding some status properties.
|
|
9
|
+
* Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
|
|
10
|
+
* But modified according to the specs of promises : https://promisesaplus.com/
|
|
11
|
+
*/
|
|
12
|
+
export declare const makeQuerablePromise: <T>(promise: Promise<T>) => PromiseStatus<T>;
|
|
13
|
+
/**
|
|
14
|
+
* Simple implementation of the deferred pattern.
|
|
15
|
+
* An object that exposes a promise and functions to resolve and reject it.
|
|
16
|
+
*/
|
|
17
|
+
export declare class Deferred<T = void> {
|
|
18
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
19
|
+
reject: (err?: any) => void;
|
|
20
|
+
promise: Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
export declare const equalSet: (as: Set<any>, bs: Set<any>) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Nicely typed aliases for some `Object` Methods
|
|
25
|
+
* - PSA: Don't mutate `yourObject`s
|
|
26
|
+
* - Numerical keys are BAD, resolve that issue upstream
|
|
27
|
+
* - Discussion: https://stackoverflow.com/a/65117465/565877
|
|
28
|
+
*/
|
|
29
|
+
export declare const ObjectTyped: {
|
|
30
|
+
/**
|
|
31
|
+
* Object.keys, but with nice typing (`Array<keyof T>`)
|
|
32
|
+
*/
|
|
33
|
+
keys: <T extends {}>(yourObject: T) => (keyof T)[];
|
|
34
|
+
/**
|
|
35
|
+
* Object.values, but with nice typing
|
|
36
|
+
*/
|
|
37
|
+
values: <T_1 extends {}>(yourObject: T_1) => T_1[keyof T_1][];
|
|
38
|
+
/**
|
|
39
|
+
* Object.entries, but with nice typing
|
|
40
|
+
*/
|
|
41
|
+
entries: <T_2 extends {}>(yourObject: T_2) => [keyof T_2, T_2[keyof T_2]][];
|
|
42
|
+
};
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeQuerablePromise = exports.equalSet = exports.ObjectTyped = exports.Deferred = void 0;
|
|
7
|
+
|
|
8
|
+
var _tslib = require("tslib");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* This function allow you to modify a JS Promise by adding some status properties.
|
|
12
|
+
* Based on: http://stackoverflow.com/questions/21485545/is-there-a-way-to-tell-if-an-es6-promise-is-fulfilled-rejected-resolved
|
|
13
|
+
* But modified according to the specs of promises : https://promisesaplus.com/
|
|
14
|
+
*/
|
|
15
|
+
var makeQuerablePromise = function makeQuerablePromise(promise) {
|
|
16
|
+
// Don't modify any promise that has been already modified.
|
|
17
|
+
if (promise.isRejected || promise.isFulfilled) return promise; // Set initial state
|
|
18
|
+
|
|
19
|
+
var isPending = true;
|
|
20
|
+
var isRejected = false;
|
|
21
|
+
var isFulfilled = false;
|
|
22
|
+
var fullFilledValue; // Observe the promise, saving the fulfillment in a closure scope.
|
|
23
|
+
|
|
24
|
+
var result = promise.then(function (v) {
|
|
25
|
+
isFulfilled = true;
|
|
26
|
+
isPending = false;
|
|
27
|
+
fullFilledValue = v;
|
|
28
|
+
return v;
|
|
29
|
+
}, function (e) {
|
|
30
|
+
isRejected = true;
|
|
31
|
+
isPending = false;
|
|
32
|
+
throw e;
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
result.isFulfilled = function () {
|
|
36
|
+
return isFulfilled;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
result.isPending = function () {
|
|
40
|
+
return isPending;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
result.isRejected = function () {
|
|
44
|
+
return isRejected;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
result.getFullFilledValue = function () {
|
|
48
|
+
return fullFilledValue;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Simple implementation of the deferred pattern.
|
|
55
|
+
* An object that exposes a promise and functions to resolve and reject it.
|
|
56
|
+
*/
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
exports.makeQuerablePromise = makeQuerablePromise;
|
|
60
|
+
|
|
61
|
+
var Deferred =
|
|
62
|
+
/** @class */
|
|
63
|
+
function () {
|
|
64
|
+
function Deferred() {
|
|
65
|
+
var _this = this;
|
|
66
|
+
|
|
67
|
+
this.promise = new Promise(function (resolve, reject) {
|
|
68
|
+
_this.resolve = resolve;
|
|
69
|
+
_this.reject = reject;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return Deferred;
|
|
74
|
+
}();
|
|
75
|
+
|
|
76
|
+
exports.Deferred = Deferred;
|
|
77
|
+
|
|
78
|
+
var equalSet = function equalSet(as, bs) {
|
|
79
|
+
var e_1, _a;
|
|
80
|
+
|
|
81
|
+
if (as.size !== bs.size) return false;
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
// eslint-disable-next-line no-restricted-syntax
|
|
85
|
+
for (var as_1 = (0, _tslib.__values)(as), as_1_1 = as_1.next(); !as_1_1.done; as_1_1 = as_1.next()) {
|
|
86
|
+
var a = as_1_1.value;
|
|
87
|
+
|
|
88
|
+
if (!bs.has(a)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
} catch (e_1_1) {
|
|
93
|
+
e_1 = {
|
|
94
|
+
error: e_1_1
|
|
95
|
+
};
|
|
96
|
+
} finally {
|
|
97
|
+
try {
|
|
98
|
+
if (as_1_1 && !as_1_1.done && (_a = as_1.return)) _a.call(as_1);
|
|
99
|
+
} finally {
|
|
100
|
+
if (e_1) throw e_1.error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return true;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Nicely typed aliases for some `Object` Methods
|
|
108
|
+
* - PSA: Don't mutate `yourObject`s
|
|
109
|
+
* - Numerical keys are BAD, resolve that issue upstream
|
|
110
|
+
* - Discussion: https://stackoverflow.com/a/65117465/565877
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
exports.equalSet = equalSet;
|
|
115
|
+
var ObjectTyped = {
|
|
116
|
+
/**
|
|
117
|
+
* Object.keys, but with nice typing (`Array<keyof T>`)
|
|
118
|
+
*/
|
|
119
|
+
keys: Object.keys,
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Object.values, but with nice typing
|
|
123
|
+
*/
|
|
124
|
+
values: Object.values,
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Object.entries, but with nice typing
|
|
128
|
+
*/
|
|
129
|
+
entries: Object.entries
|
|
130
|
+
};
|
|
131
|
+
exports.ObjectTyped = ObjectTyped;
|
package/lib/utils/dom.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setDOMSize = setDOMSize;
|
|
7
|
+
|
|
8
|
+
var _canvas = require("./canvas");
|
|
9
|
+
|
|
10
|
+
var PX_SUFFIX = 'px';
|
|
11
|
+
|
|
12
|
+
function setDOMSize($el, width, height) {
|
|
13
|
+
if (_canvas.isBrowser && $el.style) {
|
|
14
|
+
$el.style.width = width + PX_SUFFIX;
|
|
15
|
+
$el.style.height = height + PX_SUFFIX;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -106,4 +106,30 @@ Object.keys(_canvas).forEach(function (key) {
|
|
|
106
106
|
return _canvas[key];
|
|
107
107
|
}
|
|
108
108
|
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
var _deferred = require("./deferred");
|
|
112
|
+
|
|
113
|
+
Object.keys(_deferred).forEach(function (key) {
|
|
114
|
+
if (key === "default" || key === "__esModule") return;
|
|
115
|
+
if (key in exports && exports[key] === _deferred[key]) return;
|
|
116
|
+
Object.defineProperty(exports, key, {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function get() {
|
|
119
|
+
return _deferred[key];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
var _dom = require("./dom");
|
|
125
|
+
|
|
126
|
+
Object.keys(_dom).forEach(function (key) {
|
|
127
|
+
if (key === "default" || key === "__esModule") return;
|
|
128
|
+
if (key in exports && exports[key] === _dom[key]) return;
|
|
129
|
+
Object.defineProperty(exports, key, {
|
|
130
|
+
enumerable: true,
|
|
131
|
+
get: function get() {
|
|
132
|
+
return _dom[key];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
109
135
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.24",
|
|
4
4
|
"description": "A core module including ECS and DI container.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/antvis/g#readme",
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@antv/g-math": "^1.0.
|
|
41
|
+
"@antv/g-math": "^1.0.21",
|
|
42
42
|
"@antv/util": "^3.0.0",
|
|
43
43
|
"@types/offscreencanvas": "^2019.6.4",
|
|
44
44
|
"d3-color": "^1.4.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"scripts": {
|
|
54
54
|
"umd": "webpack"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "98a28060c701e8c9c6c23fca672534677c4401b3"
|
|
57
57
|
}
|
package/es/css/LayoutRegistry.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
import { singleton } from 'mana-syringe';
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
*
|
|
7
|
-
* // register layout
|
|
8
|
-
* CSS.registerLayout('centering', class {});
|
|
9
|
-
* // use with `display` property
|
|
10
|
-
* group.style.display = 'layout(centering)';
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
var LayoutRegistry =
|
|
14
|
-
/** @class */
|
|
15
|
-
function () {
|
|
16
|
-
function LayoutRegistry() {}
|
|
17
|
-
|
|
18
|
-
LayoutRegistry = __decorate([singleton()], LayoutRegistry);
|
|
19
|
-
return LayoutRegistry;
|
|
20
|
-
}();
|
|
21
|
-
|
|
22
|
-
export { LayoutRegistry };
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.LayoutRegistry = void 0;
|
|
7
|
-
|
|
8
|
-
var _tslib = require("tslib");
|
|
9
|
-
|
|
10
|
-
var _manaSyringe = require("mana-syringe");
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
*
|
|
16
|
-
* // register layout
|
|
17
|
-
* CSS.registerLayout('centering', class {});
|
|
18
|
-
* // use with `display` property
|
|
19
|
-
* group.style.display = 'layout(centering)';
|
|
20
|
-
*/
|
|
21
|
-
var LayoutRegistry =
|
|
22
|
-
/** @class */
|
|
23
|
-
function () {
|
|
24
|
-
function LayoutRegistry() {}
|
|
25
|
-
|
|
26
|
-
LayoutRegistry = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], LayoutRegistry);
|
|
27
|
-
return LayoutRegistry;
|
|
28
|
-
}();
|
|
29
|
-
|
|
30
|
-
exports.LayoutRegistry = LayoutRegistry;
|