@player-ui/metrics-plugin-react 0.0.1-next.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/dist/index.cjs.js +59 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.esm.js +46 -0
- package/package.json +19 -0
- package/src/index.tsx +40 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var metricsPlugin = require('@player-ui/metrics-plugin');
|
|
7
|
+
|
|
8
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
9
|
+
|
|
10
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
11
|
+
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
14
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
15
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
16
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
17
|
+
var __spreadValues = (a, b) => {
|
|
18
|
+
for (var prop in b || (b = {}))
|
|
19
|
+
if (__hasOwnProp.call(b, prop))
|
|
20
|
+
__defNormalProp(a, prop, b[prop]);
|
|
21
|
+
if (__getOwnPropSymbols)
|
|
22
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
23
|
+
if (__propIsEnum.call(b, prop))
|
|
24
|
+
__defNormalProp(a, prop, b[prop]);
|
|
25
|
+
}
|
|
26
|
+
return a;
|
|
27
|
+
};
|
|
28
|
+
class MetricsPlugin extends metricsPlugin.MetricsCorePlugin {
|
|
29
|
+
constructor(options) {
|
|
30
|
+
super(__spreadValues({
|
|
31
|
+
trackRenderTime: (_a = options == null ? void 0 : options.trackRenderTime) != null ? _a : true,
|
|
32
|
+
trackUpdateTime: (_b = options == null ? void 0 : options.trackUpdateTime) != null ? _b : true
|
|
33
|
+
}, options != null ? options : {}));
|
|
34
|
+
var _a, _b;
|
|
35
|
+
}
|
|
36
|
+
applyWeb(webPlayer) {
|
|
37
|
+
if (!this.trackRender) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const endRender = () => {
|
|
41
|
+
this.renderEnd();
|
|
42
|
+
};
|
|
43
|
+
webPlayer.hooks.playerComponent.tap(this.name, (Comp) => {
|
|
44
|
+
return (props) => {
|
|
45
|
+
React__default["default"].useEffect(endRender);
|
|
46
|
+
return /* @__PURE__ */ React__default["default"].createElement(Comp, __spreadValues({}, props));
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
exports.MetricsPlugin = MetricsPlugin;
|
|
53
|
+
Object.keys(metricsPlugin).forEach(function (k) {
|
|
54
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return metricsPlugin[k]; }
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { WebPlayerPlugin, WebPlayer } from '@player-ui/react';
|
|
2
|
+
import { MetricsCorePlugin, MetricsWebPluginOptions } from '@player-ui/metrics-plugin';
|
|
3
|
+
export * from '@player-ui/metrics-plugin';
|
|
4
|
+
|
|
5
|
+
/** A plugin to add render metrics to Player */
|
|
6
|
+
declare class MetricsPlugin extends MetricsCorePlugin implements WebPlayerPlugin {
|
|
7
|
+
constructor(options?: MetricsWebPluginOptions);
|
|
8
|
+
applyWeb(webPlayer: WebPlayer): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { MetricsPlugin };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MetricsCorePlugin } from '@player-ui/metrics-plugin';
|
|
3
|
+
export * from '@player-ui/metrics-plugin';
|
|
4
|
+
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
class MetricsPlugin extends MetricsCorePlugin {
|
|
22
|
+
constructor(options) {
|
|
23
|
+
super(__spreadValues({
|
|
24
|
+
trackRenderTime: (_a = options == null ? void 0 : options.trackRenderTime) != null ? _a : true,
|
|
25
|
+
trackUpdateTime: (_b = options == null ? void 0 : options.trackUpdateTime) != null ? _b : true
|
|
26
|
+
}, options != null ? options : {}));
|
|
27
|
+
var _a, _b;
|
|
28
|
+
}
|
|
29
|
+
applyWeb(webPlayer) {
|
|
30
|
+
if (!this.trackRender) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const endRender = () => {
|
|
34
|
+
this.renderEnd();
|
|
35
|
+
};
|
|
36
|
+
webPlayer.hooks.playerComponent.tap(this.name, (Comp) => {
|
|
37
|
+
return (props) => {
|
|
38
|
+
React.useEffect(endRender);
|
|
39
|
+
return /* @__PURE__ */ React.createElement(Comp, __spreadValues({}, props));
|
|
40
|
+
};
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { MetricsPlugin };
|
|
46
|
+
//# sourceMappingURL=index.esm.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@player-ui/metrics-plugin-react",
|
|
3
|
+
"version": "0.0.1-next.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"registry": "https://registry.npmjs.org"
|
|
7
|
+
},
|
|
8
|
+
"peerDependencies": {
|
|
9
|
+
"react": "^17.0.2",
|
|
10
|
+
"@player-ui/binding-grammar": "0.0.1-next.1"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@player-ui/binding-grammar": "0.0.1-next.1",
|
|
14
|
+
"@babel/runtime": "7.15.4"
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/index.cjs.js",
|
|
17
|
+
"module": "dist/index.esm.js",
|
|
18
|
+
"typings": "dist/index.d.ts"
|
|
19
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WebPlayer, WebPlayerPlugin } from '@player-ui/react';
|
|
3
|
+
import type { MetricsWebPluginOptions } from '@player-ui/metrics-plugin';
|
|
4
|
+
import { MetricsCorePlugin } from '@player-ui/metrics-plugin';
|
|
5
|
+
|
|
6
|
+
export * from '@player-ui/metrics-plugin';
|
|
7
|
+
|
|
8
|
+
/** A plugin to add render metrics to Player */
|
|
9
|
+
export class MetricsPlugin
|
|
10
|
+
extends MetricsCorePlugin
|
|
11
|
+
implements WebPlayerPlugin
|
|
12
|
+
{
|
|
13
|
+
constructor(options?: MetricsWebPluginOptions) {
|
|
14
|
+
// Default to `true` for tracking metrics
|
|
15
|
+
super({
|
|
16
|
+
trackRenderTime: options?.trackRenderTime ?? true,
|
|
17
|
+
trackUpdateTime: options?.trackUpdateTime ?? true,
|
|
18
|
+
...(options ?? {}),
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
applyWeb(webPlayer: WebPlayer) {
|
|
23
|
+
if (!this.trackRender) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Callback to complete the render lifecycle */
|
|
28
|
+
const endRender = () => {
|
|
29
|
+
this.renderEnd();
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
webPlayer.hooks.playerComponent.tap(this.name, (Comp) => {
|
|
33
|
+
return (props) => {
|
|
34
|
+
React.useEffect(endRender);
|
|
35
|
+
|
|
36
|
+
return <Comp {...props} />;
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|