@perses-dev/core 0.8.1 → 0.10.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/cjs/index.js +18 -19
- package/dist/cjs/model/dashboard.js +5 -3
- package/dist/cjs/model/datasource.js +5 -3
- package/dist/cjs/model/definitions.js +7 -3
- package/dist/cjs/model/index.js +25 -26
- package/dist/cjs/model/layout.js +5 -3
- package/dist/cjs/model/panels.js +5 -3
- package/dist/cjs/model/resource.js +5 -3
- package/dist/cjs/model/{http.js → time-series-queries.js} +5 -8
- package/dist/cjs/model/time.js +41 -50
- package/dist/cjs/model/variables.js +5 -5
- package/dist/cjs/utils/event.js +12 -14
- package/dist/cjs/utils/fetch.js +17 -17
- package/dist/cjs/utils/index.js +19 -20
- package/dist/cjs/utils/memo.js +31 -25
- package/dist/cjs/utils/panel-refs.js +29 -11
- package/dist/index.js +16 -1
- package/dist/index.js.map +1 -0
- package/dist/model/dashboard.d.ts +2 -6
- package/dist/model/dashboard.d.ts.map +1 -1
- package/dist/model/dashboard.js +15 -1
- package/dist/model/dashboard.js.map +1 -0
- package/dist/model/datasource.d.ts +28 -10
- package/dist/model/datasource.d.ts.map +1 -1
- package/dist/model/datasource.js +15 -1
- package/dist/model/datasource.js.map +1 -0
- package/dist/model/definitions.d.ts +7 -12
- package/dist/model/definitions.d.ts.map +1 -1
- package/dist/model/definitions.js +17 -1
- package/dist/model/definitions.js.map +1 -0
- package/dist/model/index.d.ts +1 -1
- package/dist/model/index.d.ts.map +1 -1
- package/dist/model/index.js +23 -1
- package/dist/model/index.js.map +1 -0
- package/dist/model/layout.js +15 -1
- package/dist/model/layout.js.map +1 -0
- package/dist/model/panels.d.ts +6 -5
- package/dist/model/panels.d.ts.map +1 -1
- package/dist/model/panels.js +15 -1
- package/dist/model/panels.js.map +1 -0
- package/dist/model/resource.d.ts +4 -8
- package/dist/model/resource.d.ts.map +1 -1
- package/dist/model/resource.js +15 -1
- package/dist/model/resource.js.map +1 -0
- package/dist/model/time-series-queries.d.ts +8 -0
- package/dist/model/time-series-queries.d.ts.map +1 -0
- package/dist/model/time-series-queries.js +15 -0
- package/dist/model/time-series-queries.js.map +1 -0
- package/dist/model/time.js +88 -1
- package/dist/model/time.js.map +1 -0
- package/dist/model/variables.d.ts +17 -29
- package/dist/model/variables.d.ts.map +1 -1
- package/dist/model/variables.js +15 -1
- package/dist/model/variables.js.map +1 -0
- package/dist/utils/event.js +27 -1
- package/dist/utils/event.js.map +1 -0
- package/dist/utils/fetch.js +41 -1
- package/dist/utils/fetch.js.map +1 -0
- package/dist/utils/index.js +18 -1
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/memo.js +51 -1
- package/dist/utils/memo.js.map +1 -0
- package/dist/utils/panel-refs.d.ts +9 -4
- package/dist/utils/panel-refs.d.ts.map +1 -1
- package/dist/utils/panel-refs.js +40 -1
- package/dist/utils/panel-refs.js.map +1 -0
- package/package.json +6 -3
- package/dist/model/http.d.ts +0 -19
- package/dist/model/http.d.ts.map +0 -1
- package/dist/model/http.js +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,20 +10,20 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./model"), exports);
|
|
18
|
+
_exportStar(require("./utils"), exports);
|
|
19
|
+
function _exportStar(from, to) {
|
|
20
|
+
Object.keys(from).forEach(function(k) {
|
|
21
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function() {
|
|
24
|
+
return from[k];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
return from;
|
|
29
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,4 +10,7 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,4 +10,7 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,4 +10,9 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Base type for definitions in JSON config resources.
|
|
15
|
+
*/ "use strict";
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
package/dist/cjs/model/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,27 +10,27 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
Object.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./dashboard"), exports);
|
|
18
|
+
_exportStar(require("./datasource"), exports);
|
|
19
|
+
_exportStar(require("./definitions"), exports);
|
|
20
|
+
_exportStar(require("./layout"), exports);
|
|
21
|
+
_exportStar(require("./panels"), exports);
|
|
22
|
+
_exportStar(require("./resource"), exports);
|
|
23
|
+
_exportStar(require("./time"), exports);
|
|
24
|
+
_exportStar(require("./time-series-queries"), exports);
|
|
25
|
+
_exportStar(require("./variables"), exports);
|
|
26
|
+
function _exportStar(from, to) {
|
|
27
|
+
Object.keys(from).forEach(function(k) {
|
|
28
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function() {
|
|
31
|
+
return from[k];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
return from;
|
|
36
|
+
}
|
package/dist/cjs/model/layout.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,4 +10,7 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
package/dist/cjs/model/panels.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,4 +10,7 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,4 +10,7 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,9 +10,7 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
exports
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
exports.buildDatasourceURL = buildDatasourceURL;
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
package/dist/cjs/model/time.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,89 +10,81 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
isRelativeTimeRange: ()=>isRelativeTimeRange,
|
|
25
|
+
isAbsoluteTimeRange: ()=>isAbsoluteTimeRange,
|
|
26
|
+
toAbsoluteTimeRange: ()=>toAbsoluteTimeRange,
|
|
27
|
+
parseDurationString: ()=>parseDurationString,
|
|
28
|
+
isDurationString: ()=>isDurationString,
|
|
29
|
+
getSuggestedStepMs: ()=>getSuggestedStepMs,
|
|
30
|
+
getDefaultTimeRange: ()=>getDefaultTimeRange
|
|
31
|
+
});
|
|
32
|
+
const _dateFns = require("date-fns");
|
|
20
33
|
function isRelativeTimeRange(timeRange) {
|
|
21
34
|
return timeRange.pastDuration !== undefined;
|
|
22
35
|
}
|
|
23
|
-
exports.isRelativeTimeRange = isRelativeTimeRange;
|
|
24
|
-
/**
|
|
25
|
-
* Determine whether a given time range is absolute
|
|
26
|
-
*/
|
|
27
36
|
function isAbsoluteTimeRange(timeRange) {
|
|
28
37
|
return timeRange.start !== undefined && timeRange.end !== undefined;
|
|
29
38
|
}
|
|
30
|
-
exports.isAbsoluteTimeRange = isAbsoluteTimeRange;
|
|
31
|
-
/**
|
|
32
|
-
* Returns an absolute time range from a RelativeTimeRange.
|
|
33
|
-
*/
|
|
34
39
|
function toAbsoluteTimeRange(timeRange) {
|
|
35
|
-
var
|
|
36
|
-
const end = (
|
|
40
|
+
var _end;
|
|
41
|
+
const end = (_end = timeRange.end) !== null && _end !== void 0 ? _end : new Date();
|
|
37
42
|
return {
|
|
38
|
-
start: (0,
|
|
39
|
-
end
|
|
43
|
+
start: (0, _dateFns.sub)(end, parseDurationString(timeRange.pastDuration)),
|
|
44
|
+
end
|
|
40
45
|
};
|
|
41
46
|
}
|
|
42
|
-
exports.toAbsoluteTimeRange = toAbsoluteTimeRange;
|
|
43
47
|
const DURATION_REGEX = /^(?:(\d+)y)?(?:(\d+)w)?(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?(?:(\d+)ms)?$/;
|
|
44
|
-
/**
|
|
45
|
-
* Parses a DurationString into a Duration object with numeric values that can
|
|
46
|
-
* be used to do Date math. Throws if not a valid duration string.
|
|
47
|
-
*/
|
|
48
48
|
function parseDurationString(durationString) {
|
|
49
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
50
49
|
const matches = DURATION_REGEX.exec(durationString);
|
|
51
50
|
if (matches === null) {
|
|
52
51
|
throw new Error(`Invalid duration string '${durationString}'`);
|
|
53
52
|
}
|
|
53
|
+
var ref, ref1, ref2, ref3, ref4, ref5, ref6;
|
|
54
54
|
return {
|
|
55
|
-
years: parseInt((
|
|
55
|
+
years: parseInt((ref = matches[1]) !== null && ref !== void 0 ? ref : '0'),
|
|
56
56
|
months: 0,
|
|
57
|
-
weeks: parseInt((
|
|
58
|
-
days: parseInt((
|
|
59
|
-
hours: parseInt((
|
|
60
|
-
minutes: parseInt((
|
|
61
|
-
seconds: parseInt((
|
|
57
|
+
weeks: parseInt((ref1 = matches[2]) !== null && ref1 !== void 0 ? ref1 : '0'),
|
|
58
|
+
days: parseInt((ref2 = matches[3]) !== null && ref2 !== void 0 ? ref2 : '0'),
|
|
59
|
+
hours: parseInt((ref3 = matches[4]) !== null && ref3 !== void 0 ? ref3 : '0'),
|
|
60
|
+
minutes: parseInt((ref4 = matches[5]) !== null && ref4 !== void 0 ? ref4 : '0'),
|
|
61
|
+
seconds: parseInt((ref5 = matches[6]) !== null && ref5 !== void 0 ? ref5 : '0') + parseInt((ref6 = matches[7]) !== null && ref6 !== void 0 ? ref6 : '0') / 1000
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
exports.parseDurationString = parseDurationString;
|
|
65
|
-
/**
|
|
66
|
-
* Returns true if the given string is a valid DurationString.
|
|
67
|
-
*/
|
|
68
64
|
function isDurationString(maybeDuration) {
|
|
69
|
-
if (maybeDuration === '')
|
|
70
|
-
return false;
|
|
65
|
+
if (maybeDuration === '') return false;
|
|
71
66
|
return DURATION_REGEX.test(maybeDuration);
|
|
72
67
|
}
|
|
73
|
-
exports.isDurationString = isDurationString;
|
|
74
|
-
/**
|
|
75
|
-
* Gets a suggested step/interval size for a time range based on the width of a visual component.
|
|
76
|
-
*/
|
|
77
68
|
function getSuggestedStepMs(timeRange, width) {
|
|
78
69
|
// TODO: Should we try to suggest more "rounded" step values based around
|
|
79
70
|
// time increments that make sense (e.g. 15s, 30s, 1m, 5m, etc.)
|
|
80
71
|
const queryRangeMs = timeRange.end.valueOf() - timeRange.start.valueOf();
|
|
81
72
|
return Math.floor(queryRangeMs / width);
|
|
82
73
|
}
|
|
83
|
-
exports.getSuggestedStepMs = getSuggestedStepMs;
|
|
84
|
-
/**
|
|
85
|
-
* Gets the default time range taking into account URL params
|
|
86
|
-
*/
|
|
87
74
|
function getDefaultTimeRange(dashboardDuration, queryString) {
|
|
88
75
|
const startParam = queryString.get('start');
|
|
89
76
|
const endParam = queryString.get('end');
|
|
90
77
|
if (startParam === null) {
|
|
91
78
|
// use relative time range from dashboard definition if start param is empty
|
|
92
|
-
return {
|
|
79
|
+
return {
|
|
80
|
+
pastDuration: dashboardDuration
|
|
81
|
+
};
|
|
93
82
|
}
|
|
94
83
|
// convert query param format to RelativeTimeRange or AbsoluteTimeRange
|
|
95
|
-
return isDurationString(startParam)
|
|
96
|
-
|
|
97
|
-
|
|
84
|
+
return isDurationString(startParam) ? {
|
|
85
|
+
pastDuration: startParam
|
|
86
|
+
} : {
|
|
87
|
+
start: new Date(Number(startParam)),
|
|
88
|
+
end: new Date(Number(endParam))
|
|
89
|
+
};
|
|
98
90
|
}
|
|
99
|
-
exports.getDefaultTimeRange = getDefaultTimeRange;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,6 +10,7 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
exports
|
|
16
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
package/dist/cjs/utils/event.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,20 +10,19 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
exports
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "useEvent", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: ()=>useEvent
|
|
20
|
+
});
|
|
21
|
+
const _react = require("react");
|
|
23
22
|
function useEvent(handler) {
|
|
24
|
-
const handlerRef = (0,
|
|
25
|
-
(0,
|
|
23
|
+
const handlerRef = (0, _react.useRef)(handler);
|
|
24
|
+
(0, _react.useLayoutEffect)(()=>{
|
|
26
25
|
handlerRef.current = handler;
|
|
27
26
|
});
|
|
28
|
-
return (0,
|
|
27
|
+
return (0, _react.useCallback)((...args)=>handlerRef.current(...args), []);
|
|
29
28
|
}
|
|
30
|
-
exports.useEvent = useEvent;
|
package/dist/cjs/utils/fetch.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,11 +10,23 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.FetchError = exports.fetchJson = exports.fetch = void 0;
|
|
16
13
|
/**
|
|
17
14
|
* Calls `global.fetch`, but throws a `FetchError` for non-200 responses.
|
|
18
|
-
*/
|
|
15
|
+
*/ "use strict";
|
|
16
|
+
Object.defineProperty(exports, "__esModule", {
|
|
17
|
+
value: true
|
|
18
|
+
});
|
|
19
|
+
function _export(target, all) {
|
|
20
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: all[name]
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
_export(exports, {
|
|
26
|
+
fetch: ()=>fetch,
|
|
27
|
+
fetchJson: ()=>fetchJson,
|
|
28
|
+
FetchError: ()=>FetchError
|
|
29
|
+
});
|
|
19
30
|
async function fetch(...args) {
|
|
20
31
|
const response = await global.fetch(...args);
|
|
21
32
|
if (response.ok === false) {
|
|
@@ -23,26 +34,15 @@ async function fetch(...args) {
|
|
|
23
34
|
}
|
|
24
35
|
return response;
|
|
25
36
|
}
|
|
26
|
-
exports.fetch = fetch;
|
|
27
|
-
/**
|
|
28
|
-
* Calls `global.fetch` and throws a `FetchError` on non-200 responses, but also
|
|
29
|
-
* decodes the response body as JSON, casting it to type `T`. Returns the
|
|
30
|
-
* decoded body.
|
|
31
|
-
*/
|
|
32
37
|
async function fetchJson(...args) {
|
|
33
38
|
const response = await fetch(...args);
|
|
34
39
|
const json = await response.json();
|
|
35
40
|
return json;
|
|
36
41
|
}
|
|
37
|
-
exports.fetchJson = fetchJson;
|
|
38
|
-
/**
|
|
39
|
-
* Error thrown when fetch returns a non-200 response.
|
|
40
|
-
*/
|
|
41
42
|
class FetchError extends Error {
|
|
42
|
-
constructor(response)
|
|
43
|
+
constructor(response){
|
|
43
44
|
super(`${response.status} ${response.statusText}`);
|
|
44
45
|
this.response = response;
|
|
45
46
|
Object.setPrototypeOf(this, FetchError.prototype);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
|
-
exports.FetchError = FetchError;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,22 +10,22 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
_exportStar(require("./event"), exports);
|
|
18
|
+
_exportStar(require("./fetch"), exports);
|
|
19
|
+
_exportStar(require("./memo"), exports);
|
|
20
|
+
_exportStar(require("./panel-refs"), exports);
|
|
21
|
+
function _exportStar(from, to) {
|
|
22
|
+
Object.keys(from).forEach(function(k) {
|
|
23
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) Object.defineProperty(to, k, {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function() {
|
|
26
|
+
return from[k];
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
return from;
|
|
31
|
+
}
|
package/dist/cjs/utils/memo.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
// Copyright 2021 The Perses Authors
|
|
1
|
+
// Copyright 2022 The Perses Authors
|
|
3
2
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
3
|
// you may not use this file except in compliance with the License.
|
|
5
4
|
// You may obtain a copy of the License at
|
|
@@ -11,40 +10,47 @@
|
|
|
11
10
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
11
|
// See the License for the specific language governing permissions and
|
|
13
12
|
// limitations under the License.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
"use strict";
|
|
14
|
+
Object.defineProperty(exports, "__esModule", {
|
|
15
|
+
value: true
|
|
16
|
+
});
|
|
17
|
+
function _export(target, all) {
|
|
18
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: all[name]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
_export(exports, {
|
|
24
|
+
useMemoized: ()=>useMemoized,
|
|
25
|
+
useDeepMemo: ()=>useDeepMemo
|
|
26
|
+
});
|
|
27
|
+
const _react = require("react");
|
|
28
|
+
const _lodashEs = require("lodash-es");
|
|
23
29
|
function useMemoized(factory, deps) {
|
|
24
|
-
|
|
25
|
-
const ref = (0, react_1.useRef)();
|
|
30
|
+
const ref = (0, _react.useRef)();
|
|
26
31
|
let areEqual = true;
|
|
27
|
-
for
|
|
28
|
-
|
|
32
|
+
for(let i = 0; i < deps.length; i++){
|
|
33
|
+
var ref1;
|
|
34
|
+
if (((ref1 = ref.current) === null || ref1 === void 0 ? void 0 : ref1.deps[i]) !== deps[i]) {
|
|
29
35
|
areEqual = false;
|
|
30
36
|
break;
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
if (ref.current === undefined || areEqual === false) {
|
|
34
|
-
ref.current = {
|
|
40
|
+
ref.current = {
|
|
41
|
+
value: factory(),
|
|
42
|
+
deps: deps
|
|
43
|
+
};
|
|
35
44
|
}
|
|
36
45
|
return ref.current.value;
|
|
37
46
|
}
|
|
38
|
-
exports.useMemoized = useMemoized;
|
|
39
|
-
/**
|
|
40
|
-
* Like React's useMemo, except it does a deep equality comparison with lodash's
|
|
41
|
-
* isEqual on the dependency list.
|
|
42
|
-
*/
|
|
43
47
|
function useDeepMemo(factory, deps) {
|
|
44
|
-
const ref = (0,
|
|
45
|
-
if (ref.current === undefined || (0,
|
|
46
|
-
ref.current = {
|
|
48
|
+
const ref = (0, _react.useRef)();
|
|
49
|
+
if (ref.current === undefined || (0, _lodashEs.isEqual)(deps, ref.current.deps) === false) {
|
|
50
|
+
ref.current = {
|
|
51
|
+
value: factory(),
|
|
52
|
+
deps
|
|
53
|
+
};
|
|
47
54
|
}
|
|
48
55
|
return ref.current.value;
|
|
49
56
|
}
|
|
50
|
-
exports.useDeepMemo = useDeepMemo;
|