@aem-sdk/tracker-plugin-anim-fluency 0.1.0-beta.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/README.md +21 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.mjs +1 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# @aem-sdk/tracker-plugin-anim-fluency
|
|
2
|
+
|
|
3
|
+
Browser animation fluency 插件。保留旧 `@ali/aes-tracker-plugin-animFluency` 的核心采集能力。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @aem-sdk/tracker @aem-sdk/tracker-plugin-anim-fluency@next
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 用法
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import AES from "@aem-sdk/tracker";
|
|
15
|
+
import AnimFluencyPlugin from "@aem-sdk/tracker-plugin-anim-fluency";
|
|
16
|
+
|
|
17
|
+
const aes = new AES({ pid: "demo" });
|
|
18
|
+
aes.use(AnimFluencyPlugin);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
插件只在注册后监听 `transitionstart` 与 `animationstart`,不会在 import 时注册 listener、启动 RAF 或发送日志。上报字段直接使用新平台最终存储字段:`p1` 为动画节点 selector,`p2` 为动画名,`p3` 为掉帧率,`p4` 为平均 FPS,`p6` 为动画类型。
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){if(!e)return;if(Object.prototype.toString.call(e)===`[object Array]`)return t(e);let n=[],r=e;for(;r;)n.push(r),r=r.parentNode;return t(n)}function t(e){let t=[],n=typeof document<`u`?document.body:void 0;for(let r=0;r<e.length;r+=1){let i=e[r];if(i===n||typeof document<`u`&&i===document||typeof window<`u`&&i===window)break;let a=i;if(a.id){t.push(`#${String(a.id)}`);break}if(typeof a.className==`string`&&a.className){t.push(`.${a.className.split(/\s+/).filter(e=>!!e).join(`.`)}`);continue}a.nodeName&&t.push(String(a.nodeName))}return t.reverse().join(` `)||void 0}const n=e=>{if(typeof window>`u`||typeof document>`u`)return;let t={},n=Math.random(),i=`__aesTrans_${n}`,o=`__aesAnim_${n}`,c=(e,n)=>{let r=a();if(!r||t[e])return;let i,o=()=>{let a=s();if(!i){i=a,t[e]=r(o);return}n(a-i),i=a,t[e]=r(o)};t[e]=r(o)};try{document.addEventListener(`transitionstart`,n=>{r(e,n,{animName:n.propertyName,animType:`transition`,endEventName:`transitionend`,markerProperty:i,requestIds:t,startFps:c})}),document.addEventListener(`animationstart`,n=>{r(e,n,{animName:n.animationName,animType:`animation`,endEventName:`animationend`,markerProperty:o,requestIds:t,startFps:c})})}catch(e){return}};function r(t,n,r){if(!n||!n.target||!n.path)return;let a=n.target;if(a[r.markerProperty])return;a[r.markerProperty]=1;let s=String(Math.random()),l=new Date().getTime(),u=[],d;r.startFps(s,e=>{u.length>1e3&&u.shift(),u.push(e)});let f=(n={})=>{d&&a.removeEventListener&&a.removeEventListener(r.endEventName,d);let f=r.requestIds[s];if(f){var p;(p=o())==null||p(f)}delete r.requestIds[s],u.length&&c(()=>{let o=!Number.isNaN(n.elapsedTime)&&n.elapsedTime!==void 0?n.elapsedTime*1e3:new Date().getTime()-l,s=Math.floor(o/16.666666666666668),c=(s-u.length)/s,d=1e3/i(u);try{t.log(`animFluency`,{p1:e(n.path||a),p2:r.animName,p3:c,p4:d,p6:r.animType})}catch(e){return}})},p=setTimeout(()=>{f()},1100);a.addEventListener&&(d=e=>{clearTimeout(p),f(e)},a.addEventListener(r.endEventName,d))}function i(e){return e.reduce((e,t)=>e+t,0)/e.length}function a(){let e=window,t=e.requestAnimationFrame||e.webkitRequestAnimationFrame;return typeof t==`function`?t:void 0}function o(){let e=window,t=e.cancelAnimationFrame||e.webkitCancelAnimationFrame;return typeof t==`function`?t:void 0}function s(){return window.performance&&performance.now?performance.now():new Date().getTime()}function c(e){try{let t=globalThis.requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}module.exports=n;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AESPluginFactory } from "@aem-sdk/tracker";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
interface AnimFluencyPluginOptions {}
|
|
5
|
+
declare const AESPluginAnimFluency: AESPluginFactory<void, AnimFluencyPluginOptions>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { AnimFluencyPluginOptions, AESPluginAnimFluency as default };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e){if(!e)return;if(Object.prototype.toString.call(e)===`[object Array]`)return t(e);let n=[],r=e;for(;r;)n.push(r),r=r.parentNode;return t(n)}function t(e){let t=[],n=typeof document<`u`?document.body:void 0;for(let r=0;r<e.length;r+=1){let i=e[r];if(i===n||typeof document<`u`&&i===document||typeof window<`u`&&i===window)break;let a=i;if(a.id){t.push(`#${String(a.id)}`);break}if(typeof a.className==`string`&&a.className){t.push(`.${a.className.split(/\s+/).filter(e=>!!e).join(`.`)}`);continue}a.nodeName&&t.push(String(a.nodeName))}return t.reverse().join(` `)||void 0}const n=e=>{if(typeof window>`u`||typeof document>`u`)return;let t={},n=Math.random(),i=`__aesTrans_${n}`,o=`__aesAnim_${n}`,c=(e,n)=>{let r=a();if(!r||t[e])return;let i,o=()=>{let a=s();if(!i){i=a,t[e]=r(o);return}n(a-i),i=a,t[e]=r(o)};t[e]=r(o)};try{document.addEventListener(`transitionstart`,n=>{r(e,n,{animName:n.propertyName,animType:`transition`,endEventName:`transitionend`,markerProperty:i,requestIds:t,startFps:c})}),document.addEventListener(`animationstart`,n=>{r(e,n,{animName:n.animationName,animType:`animation`,endEventName:`animationend`,markerProperty:o,requestIds:t,startFps:c})})}catch(e){return}};function r(t,n,r){if(!n||!n.target||!n.path)return;let a=n.target;if(a[r.markerProperty])return;a[r.markerProperty]=1;let s=String(Math.random()),l=new Date().getTime(),u=[],d;r.startFps(s,e=>{u.length>1e3&&u.shift(),u.push(e)});let f=(n={})=>{d&&a.removeEventListener&&a.removeEventListener(r.endEventName,d);let f=r.requestIds[s];if(f){var p;(p=o())==null||p(f)}delete r.requestIds[s],u.length&&c(()=>{let o=!Number.isNaN(n.elapsedTime)&&n.elapsedTime!==void 0?n.elapsedTime*1e3:new Date().getTime()-l,s=Math.floor(o/16.666666666666668),c=(s-u.length)/s,d=1e3/i(u);try{t.log(`animFluency`,{p1:e(n.path||a),p2:r.animName,p3:c,p4:d,p6:r.animType})}catch(e){return}})},p=setTimeout(()=>{f()},1100);a.addEventListener&&(d=e=>{clearTimeout(p),f(e)},a.addEventListener(r.endEventName,d))}function i(e){return e.reduce((e,t)=>e+t,0)/e.length}function a(){let e=window,t=e.requestAnimationFrame||e.webkitRequestAnimationFrame;return typeof t==`function`?t:void 0}function o(){let e=window,t=e.cancelAnimationFrame||e.webkitCancelAnimationFrame;return typeof t==`function`?t:void 0}function s(){return window.performance&&performance.now?performance.now():new Date().getTime()}function c(e){try{let t=globalThis.requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}export{n as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aem-sdk/tracker-plugin-anim-fluency",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "AEM Web SDK browser animation fluency plugin",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"README.md"
|
|
9
|
+
],
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.mjs",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.mjs",
|
|
19
|
+
"require": "./dist/index.cjs"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"access": "public",
|
|
24
|
+
"registry": "https://registry.npmjs.org"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@aem-sdk/tracker": "0.1.0-beta.0"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@aem-sdk/tracker": "^0.1.0-beta.0"
|
|
31
|
+
},
|
|
32
|
+
"aemSizeBudget": {
|
|
33
|
+
"gzipBytes": 3072
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"build": "tsdown",
|
|
37
|
+
"clean": "rm -rf dist dist-types",
|
|
38
|
+
"typecheck": "tsc -b tsconfig.json"
|
|
39
|
+
}
|
|
40
|
+
}
|