@real-router/logger-plugin 0.3.3 → 0.3.4

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 CHANGED
@@ -1 +1 @@
1
- var t="logger-plugin",e=`[@real-router/${t}]`,o={level:"all",usePerformanceMarks:!1,showParamsDiff:!0,showTiming:!0,context:t},r=t=>t?.name??"(none)",n=(t,e)=>{if(null===t)return"";const o=e()-t;return!Number.isFinite(o)||o<0?" (?)":o<.1?` (${(1e3*o).toFixed(2)}μs)`:` (${o.toFixed(2)}ms)`},i=0,s=0,a="undefined"!=typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>{const t=Date.now();return t<i&&(s+=i-t),i=t,t+s},l=()=>a(),f=class{#t;#e;#o;#r;#n;#i;#s;#a;#l;#f;#h=null;#c="";#u="";constructor(t){this.#t="all"===t.level,this.#e="none"!==t.level&&"errors"!==t.level,this.#o="none"!==t.level,this.#r=this.#e&&t.showParamsDiff,this.#n=t.showTiming,this.#i=t.usePerformanceMarks,this.#s=`[${t.context}]`,this.#a=t.context,this.#l=(t=>{let e=!1;return{open(o){t&&!e&&(console.group(o),e=!0)},close(){t&&e&&(console.groupEnd(),e=!1)},isOpen:()=>e}})("undefined"!=typeof console&&"function"==typeof console.group&&"function"==typeof console.groupEnd),this.#f=((t,e)=>{const o=t&&"undefined"!=typeof performance&&"function"==typeof performance.mark&&"function"==typeof performance.measure;return{mark(t){o&&performance.mark(t)},measure(t,r,n){if(o)try{performance.measure(t,r,n)}catch(o){console.warn(`[${e}] Failed to create performance measure: ${t}`,o)}}}})(t.usePerformanceMarks,t.context)}getPlugin(){return{onStart:()=>{this.#f.mark("router:start"),this.#t&&console.log(`${this.#s} Router started`)},onStop:()=>{this.#l.close(),this.#f.mark("router:stop"),this.#f.measure("router:lifetime","router:start","router:stop"),this.#t&&console.log(`${this.#s} Router stopped`)},onTransitionStart:(t,e)=>{this.#l.open("Router transition"),this.#h=this.#n?l():null;const o=r(e),n=r(t);this.#i&&(this.#c=((t,e)=>`${t}→${e}`)(o,n),this.#u=`router:transition-start:${this.#c}`,this.#f.mark(this.#u)),this.#e&&(console.log(`${this.#s} Transition: ${o} → ${n}`,{from:e,to:t}),this.#m(t,e))},onTransitionSuccess:(t,e)=>{if(this.#i){const t=this.#c,e=`router:transition-end:${t}`;this.#f.mark(e),this.#f.measure(`router:transition:${t}`,this.#u,e)}if(this.#e){const o=this.#n?n(this.#h,l):"";console.log(`${this.#s} Transition success${o}`,{to:t,from:e})}this.#p()},onTransitionCancel:(t,e)=>{if(this.#i){const t=this.#c,e=`router:transition-cancel:${t}`;this.#f.mark(e),this.#f.measure(`router:transition-cancelled:${t}`,this.#u,e)}if(this.#e){const o=this.#n?n(this.#h,l):"";console.warn(`${this.#s} Transition cancelled${o}`,{to:t,from:e})}this.#p()},onTransitionError:(t,e,o)=>{if(this.#i){const t=this.#c,e=`router:transition-error:${t}`;this.#f.mark(e),this.#f.measure(`router:transition-failed:${t}`,this.#u,e)}if(this.#o){const r=this.#n?n(this.#h,l):"";console.error(`${this.#s} Transition error: ${o.code}${r}`,{error:o,stack:o.stack,to:t,from:e})}this.#p()},teardown:()=>{this.#p()}}}#m(t,e){if(!this.#r||!e)return;if(t.name!==e.name)return;const o=((t,e)=>{const o={},r={},n={};let i=!1;for(const r in t)r in e?t[r]!==e[r]&&(o[r]={from:t[r],to:e[r]},i=!0):(n[r]=t[r],i=!0);for(const o in e)o in t||(r[o]=e[o],i=!0);return i?{changed:o,added:r,removed:n}:null})(e.params,t.params);o&&((t,e)=>{const o=[],r=Object.entries(t.changed);if(r.length>0){const t=[];for(const[e,{from:o,to:n}]of r)t.push(`${e}: ${JSON.stringify(o)} → ${JSON.stringify(n)}`);o.push(`Changed: { ${t.join(", ")} }`)}Object.keys(t.added).length>0&&o.push(`Added: ${JSON.stringify(t.added)}`),Object.keys(t.removed).length>0&&o.push(`Removed: ${JSON.stringify(t.removed)}`),console.log(`[${e}] ${o.join(", ")}`)})(o,this.#a)}#p(){this.#l.close(),this.#c="",this.#u="",this.#h=null}},h=new Set(["all","transitions","errors","none"]);exports.loggerPluginFactory=function(t){!function(t){if(void 0!==t){if(null===t||"object"!=typeof t)throw new TypeError(`${e} Options must be an object`);if(void 0!==t.level&&!h.has(t.level))throw new TypeError(`${e} Invalid level: "${t.level}". Expected: ${[...h].join(", ")}`);if(void 0!==t.context&&("string"!=typeof t.context||0===t.context.length))throw new TypeError(`${e} Option "context" must be a non-empty string`);if(void 0!==t.showTiming&&"boolean"!=typeof t.showTiming)throw new TypeError(`${e} Option "showTiming" must be a boolean`);if(void 0!==t.showParamsDiff&&"boolean"!=typeof t.showParamsDiff)throw new TypeError(`${e} Option "showParamsDiff" must be a boolean`);if(void 0!==t.usePerformanceMarks&&"boolean"!=typeof t.usePerformanceMarks)throw new TypeError(`${e} Option "usePerformanceMarks" must be a boolean`)}}(t);const r={...o,...t};return()=>new f(r).getPlugin()};//# sourceMappingURL=index.js.map
1
+ "use strict";var t="logger-plugin",e=`[@real-router/${t}]`,r={level:"all",usePerformanceMarks:!1,showParamsDiff:!0,showTiming:!0,context:t},o=t=>t?.name??"(none)",n=(t,e)=>{if(null===t)return"";const r=e()-t;return!Number.isFinite(r)||r<0?" (?)":r<.1?` (${(1e3*r).toFixed(2)}μs)`:` (${r.toFixed(2)}ms)`},i=0,s=0,a="undefined"!=typeof performance&&"function"==typeof performance.now?()=>performance.now():()=>{const t=Date.now();return t<i&&(s+=i-t),i=t,t+s},l=()=>a(),f=class{#t;#e;#r;#o;#n;#i;#s;#a;#l;#f;#h=null;#c="";#u="";constructor(t){this.#t="all"===t.level,this.#e="none"!==t.level&&"errors"!==t.level,this.#r="none"!==t.level,this.#o=this.#e&&t.showParamsDiff,this.#n=t.showTiming,this.#i=t.usePerformanceMarks,this.#s=`[${t.context}]`,this.#a=t.context,this.#l=(t=>{let e=!1;return{open(r){t&&!e&&(console.group(r),e=!0)},close(){t&&e&&(console.groupEnd(),e=!1)},isOpen:()=>e}})("undefined"!=typeof console&&"function"==typeof console.group&&"function"==typeof console.groupEnd),this.#f=((t,e)=>{const r=t&&"undefined"!=typeof performance&&"function"==typeof performance.mark&&"function"==typeof performance.measure;return{mark(t){r&&performance.mark(t)},measure(t,o,n){if(r)try{performance.measure(t,o,n)}catch(r){console.warn(`[${e}] Failed to create performance measure: ${t}`,r)}}}})(t.usePerformanceMarks,t.context)}getPlugin(){return{onStart:()=>{this.#f.mark("router:start"),this.#t&&console.log(`${this.#s} Router started`)},onStop:()=>{this.#l.close(),this.#f.mark("router:stop"),this.#f.measure("router:lifetime","router:start","router:stop"),this.#t&&console.log(`${this.#s} Router stopped`)},onTransitionStart:(t,e)=>{this.#l.open("Router transition"),this.#h=this.#n?l():null;const r=o(e),n=o(t);this.#i&&(this.#c=((t,e)=>`${t}→${e}`)(r,n),this.#u=`router:transition-start:${this.#c}`,this.#f.mark(this.#u)),this.#e&&(console.log(`${this.#s} Transition: ${r} → ${n}`,{from:e,to:t}),this.#m(t,e))},onTransitionSuccess:(t,e)=>{if(this.#i){const t=this.#c,e=`router:transition-end:${t}`;this.#f.mark(e),this.#f.measure(`router:transition:${t}`,this.#u,e)}if(this.#e){const r=this.#n?n(this.#h,l):"";console.log(`${this.#s} Transition success${r}`,{to:t,from:e})}this.#p()},onTransitionCancel:(t,e)=>{if(this.#i){const t=this.#c,e=`router:transition-cancel:${t}`;this.#f.mark(e),this.#f.measure(`router:transition-cancelled:${t}`,this.#u,e)}if(this.#e){const r=this.#n?n(this.#h,l):"";console.warn(`${this.#s} Transition cancelled${r}`,{to:t,from:e})}this.#p()},onTransitionError:(t,e,r)=>{if(this.#i){const t=this.#c,e=`router:transition-error:${t}`;this.#f.mark(e),this.#f.measure(`router:transition-failed:${t}`,this.#u,e)}if(this.#r){const o=this.#n?n(this.#h,l):"";console.error(`${this.#s} Transition error: ${r.code}${o}`,{error:r,stack:r.stack,to:t,from:e})}this.#p()},teardown:()=>{this.#p()}}}#m(t,e){if(!this.#o||!e)return;if(t.name!==e.name)return;const r=((t,e)=>{const r={},o={},n={};let i=!1;for(const o in t)o in e?t[o]!==e[o]&&(r[o]={from:t[o],to:e[o]},i=!0):(n[o]=t[o],i=!0);for(const r in e)r in t||(o[r]=e[r],i=!0);return i?{changed:r,added:o,removed:n}:null})(e.params,t.params);r&&((t,e)=>{const r=[],o=Object.entries(t.changed);if(o.length>0){const t=[];for(const[e,{from:r,to:n}]of o)t.push(`${e}: ${JSON.stringify(r)} → ${JSON.stringify(n)}`);r.push(`Changed: { ${t.join(", ")} }`)}Object.keys(t.added).length>0&&r.push(`Added: ${JSON.stringify(t.added)}`),Object.keys(t.removed).length>0&&r.push(`Removed: ${JSON.stringify(t.removed)}`),console.log(`[${e}] ${r.join(", ")}`)})(r,this.#a)}#p(){this.#l.close(),this.#c="",this.#u="",this.#h=null}},h=new Set(["all","transitions","errors","none"]);exports.loggerPluginFactory=function(t){!function(t){if(void 0!==t){if(null===t||"object"!=typeof t)throw new TypeError(`${e} Options must be an object`);if(void 0!==t.level&&!h.has(t.level))throw new TypeError(`${e} Invalid level: "${t.level}". Expected: ${[...h].join(", ")}`);if(void 0!==t.context&&("string"!=typeof t.context||0===t.context.length))throw new TypeError(`${e} Option "context" must be a non-empty string`);if(void 0!==t.showTiming&&"boolean"!=typeof t.showTiming)throw new TypeError(`${e} Option "showTiming" must be a boolean`);if(void 0!==t.showParamsDiff&&"boolean"!=typeof t.showParamsDiff)throw new TypeError(`${e} Option "showParamsDiff" must be a boolean`);if(void 0!==t.usePerformanceMarks&&"boolean"!=typeof t.usePerformanceMarks)throw new TypeError(`${e} Option "usePerformanceMarks" must be a boolean`)}}(t);const o={...r,...t};return()=>new f(o).getPlugin()};//# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/constants.ts":{"bytes":391,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/console-groups.ts":{"bytes":1493,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/formatting.ts":{"bytes":1230,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/params-diff.ts":{"bytes":2530,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/performance-marks.ts":{"bytes":1723,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/timing.ts":{"bytes":1476,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugin.ts":{"bytes":6172,"imports":[{"path":"src/internal/console-groups.ts","kind":"import-statement","original":"./internal/console-groups"},{"path":"src/internal/formatting.ts","kind":"import-statement","original":"./internal/formatting"},{"path":"src/internal/params-diff.ts","kind":"import-statement","original":"./internal/params-diff"},{"path":"src/internal/performance-marks.ts","kind":"import-statement","original":"./internal/performance-marks"},{"path":"src/internal/timing.ts","kind":"import-statement","original":"./internal/timing"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/validation.ts":{"bytes":1714,"imports":[{"path":"src/constants.ts","kind":"import-statement","original":"./constants"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/factory.ts":{"bytes":561,"imports":[{"path":"src/constants.ts","kind":"import-statement","original":"./constants"},{"path":"src/plugin.ts","kind":"import-statement","original":"./plugin"},{"path":"src/validation.ts","kind":"import-statement","original":"./validation"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":151,"imports":[{"path":"src/factory.ts","kind":"import-statement","original":"./factory"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.19.4_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":25622},"dist/cjs/index.js":{"imports":[],"exports":["loggerPluginFactory"],"entryPoint":"src/index.ts","inputs":{"src/constants.ts":{"bytesInOutput":235},"src/internal/console-groups.ts":{"bytesInOutput":727},"src/internal/formatting.ts":{"bytesInOutput":592},"src/internal/params-diff.ts":{"bytesInOutput":1277},"src/internal/performance-marks.ts":{"bytesInOutput":941},"src/internal/timing.ts":{"bytesInOutput":450},"src/plugin.ts":{"bytesInOutput":4975},"src/validation.ts":{"bytesInOutput":1298},"src/factory.ts":{"bytesInOutput":185},"src/index.ts":{"bytesInOutput":0}},"bytes":10956}}}
1
+ {"inputs":{"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js":{"bytes":569,"imports":[],"format":"esm"},"src/constants.ts":{"bytes":391,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/console-groups.ts":{"bytes":1493,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/formatting.ts":{"bytes":1230,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/params-diff.ts":{"bytes":2530,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/performance-marks.ts":{"bytes":1723,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/internal/timing.ts":{"bytes":1476,"imports":[{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/plugin.ts":{"bytes":6172,"imports":[{"path":"src/internal/console-groups.ts","kind":"import-statement","original":"./internal/console-groups"},{"path":"src/internal/formatting.ts","kind":"import-statement","original":"./internal/formatting"},{"path":"src/internal/params-diff.ts","kind":"import-statement","original":"./internal/params-diff"},{"path":"src/internal/performance-marks.ts","kind":"import-statement","original":"./internal/performance-marks"},{"path":"src/internal/timing.ts","kind":"import-statement","original":"./internal/timing"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/validation.ts":{"bytes":1714,"imports":[{"path":"src/constants.ts","kind":"import-statement","original":"./constants"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/factory.ts":{"bytes":561,"imports":[{"path":"src/constants.ts","kind":"import-statement","original":"./constants"},{"path":"src/plugin.ts","kind":"import-statement","original":"./plugin"},{"path":"src/validation.ts","kind":"import-statement","original":"./validation"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":151,"imports":[{"path":"src/factory.ts","kind":"import-statement","original":"./factory"},{"path":"/home/runner/work/real-router/real-router/node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.8_tsx@4.21.0_typescript@5.9.3_yaml@2.8.2/node_modules/tsup/assets/cjs_shims.js","kind":"import-statement","external":true}],"format":"esm"}},"outputs":{"dist/cjs/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":25622},"dist/cjs/index.js":{"imports":[],"exports":["loggerPluginFactory"],"entryPoint":"src/index.ts","inputs":{"src/constants.ts":{"bytesInOutput":235},"src/internal/console-groups.ts":{"bytesInOutput":727},"src/internal/formatting.ts":{"bytesInOutput":592},"src/internal/params-diff.ts":{"bytesInOutput":1277},"src/internal/performance-marks.ts":{"bytesInOutput":941},"src/internal/timing.ts":{"bytesInOutput":450},"src/plugin.ts":{"bytesInOutput":4975},"src/validation.ts":{"bytesInOutput":1298},"src/factory.ts":{"bytesInOutput":185},"src/index.ts":{"bytesInOutput":0}},"bytes":10956}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@real-router/logger-plugin",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "type": "commonjs",
5
5
  "description": "Development logging plugin with transition tracking and performance metrics",
6
6
  "main": "./dist/cjs/index.js",
@@ -45,7 +45,7 @@
45
45
  "homepage": "https://github.com/greydragon888/real-router",
46
46
  "sideEffects": false,
47
47
  "dependencies": {
48
- "@real-router/core": "^0.38.0"
48
+ "@real-router/core": "^0.39.0"
49
49
  },
50
50
  "scripts": {
51
51
  "build": "tsup",