@gjsify/perf_hooks 0.4.43 → 0.5.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 CHANGED
@@ -7,8 +7,10 @@ Part of the [gjsify](https://github.com/gjsify/gjsify) project — Node.js and W
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
+ gjsify install @gjsify/perf_hooks
11
+
12
+ # npm or yarn also work (e.g. adding it to an existing project):
10
13
  npm install @gjsify/perf_hooks
11
- # or
12
14
  yarn add @gjsify/perf_hooks
13
15
  ```
14
16
 
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import"./_virtual/_rolldown/runtime.js";let e;if(globalThis.performance)e=globalThis.performance;else{let t,_now;try{let e=globalThis.imports?.gi?.GLib;if(!e)throw Error(`GJS imports.gi.GLib not available`);t=e.get_monotonic_time(),_now=()=>(e.get_monotonic_time()-t)/1e3}catch{let e=Date.now();t=0,_now=()=>Date.now()-e}let n=[],r=Date.now()-_now();e={timeOrigin:r,now:_now,mark(e){let t={name:e,entryType:`mark`,startTime:_now(),duration:0};return n.push(t),t},measure(e,t,r){let i=0,a=_now();if(t){let e=n.find(e=>e.entryType===`mark`&&e.name===t);e&&(i=e.startTime)}if(r){let e=n.find(e=>e.entryType===`mark`&&e.name===r);e&&(a=e.startTime)}let o={name:e,entryType:`measure`,startTime:i,duration:a-i};return n.push(o),o},getEntries(){return[...n]},getEntriesByName(e){return n.filter(t=>t.name===e)},getEntriesByType(e){return n.filter(t=>t.entryType===e)},clearMarks(e){for(let t=n.length-1;t>=0;t--)n[t].entryType===`mark`&&(!e||n[t].name===e)&&n.splice(t,1)},clearMeasures(e){for(let t=n.length-1;t>=0;t--)n[t].entryType===`measure`&&(!e||n[t].name===e)&&n.splice(t,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:r}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}},PerformanceEntryStub=class{name=``;entryType=``;startTime=0;duration=0;toJSON(){return{name:this.name,entryType:this.entryType,startTime:this.startTime,duration:this.duration}}},PerformanceObserverEntryListStub=class{getEntries(){return[]}getEntriesByName(e){return[]}getEntriesByType(e){return[]}};const t=globalThis,n=t.PerformanceObserver||PerformanceObserverStub,r=t.PerformanceEntry||PerformanceEntryStub,i=t.PerformanceObserverEntryList||PerformanceObserverEntryListStub,a=t.PerformanceMark||class PerformanceMark extends PerformanceEntryStub{},o=t.PerformanceMeasure||class PerformanceMeasure extends PerformanceEntryStub{};function eventLoopUtilization(e,t){return{idle:0,active:0,utilization:0}}function timerify(t){let wrapped=function(...n){let r=e.now(),i=t.apply(this,n);return e.now()-r,i};return Object.defineProperty(wrapped,"name",{value:t.name}),wrapped}function monitorEventLoopDelay(e){let t=new Map;return{enable(){},disable(){},reset(){},percentile(e){return 0},get min(){return 0},get max(){return 0},get mean(){return 0},get stddev(){return 0},get percentiles(){return t}}}var s={performance:e,PerformanceObserver:n,PerformanceEntry:r,PerformanceObserverEntryList:i,PerformanceMark:a,PerformanceMeasure:o,eventLoopUtilization,timerify,monitorEventLoopDelay};export{r as PerformanceEntry,a as PerformanceMark,o as PerformanceMeasure,n as PerformanceObserver,i as PerformanceObserverEntryList,s as default,eventLoopUtilization,monitorEventLoopDelay,e as performance,timerify};
1
+ import"./_virtual/_rolldown/runtime.js";let e;if(globalThis.performance)e=globalThis.performance;else{let t,_now;try{let e=globalThis.imports?.gi?.GLib;if(!e)throw Error(`GJS imports.gi.GLib not available`);t=e.get_monotonic_time(),_now=()=>(e.get_monotonic_time()-t)/1e3}catch{let e=Date.now();t=0,_now=()=>Date.now()-e}let n=[],r=Date.now()-_now();e={timeOrigin:r,now:_now,mark(e){let t={name:e,entryType:`mark`,startTime:_now(),duration:0};return n.push(t),t},measure(e,t,r){let i=0,a=_now();if(t){let e=n.find(e=>e.entryType===`mark`&&e.name===t);e&&(i=e.startTime)}if(r){let e=n.find(e=>e.entryType===`mark`&&e.name===r);e&&(a=e.startTime)}let o={name:e,entryType:`measure`,startTime:i,duration:a-i};return n.push(o),o},getEntries(){return[...n]},getEntriesByName(e){return n.filter(t=>t.name===e)},getEntriesByType(e){return n.filter(t=>t.entryType===e)},clearMarks(e){for(let t=n.length-1;t>=0;t--)n[t].entryType===`mark`&&(!e||n[t].name===e)&&n.splice(t,1)},clearMeasures(e){for(let t=n.length-1;t>=0;t--)n[t].entryType===`measure`&&(!e||n[t].name===e)&&n.splice(t,1)},clearResourceTimings(){},setResourceTimingBufferSize(){},toJSON(){return{timeOrigin:r}}}}var PerformanceObserverStub=class{_callback;constructor(e){this._callback=e}observe(e){}disconnect(){}takeRecords(){return[]}},PerformanceEntryStub=class{name=``;entryType=``;startTime=0;duration=0;toJSON(){return{name:this.name,entryType:this.entryType,startTime:this.startTime,duration:this.duration}}},PerformanceObserverEntryListStub=class{getEntries(){return[]}getEntriesByName(e){return[]}getEntriesByType(e){return[]}};const t=globalThis,n=t.PerformanceObserver||PerformanceObserverStub,r=t.PerformanceEntry||PerformanceEntryStub,i=t.PerformanceObserverEntryList||PerformanceObserverEntryListStub,a=t.PerformanceMark||class PerformanceMark extends PerformanceEntryStub{},o=t.PerformanceMeasure||class PerformanceMeasure extends PerformanceEntryStub{};function eventLoopUtilization(e,t){return{idle:0,active:0,utilization:0}}function timerify(t){let wrapped=function(...n){let r=e.now(),i=t.apply(this,n);return e.now()-r,i};return Object.defineProperty(wrapped,`name`,{value:t.name}),wrapped}function monitorEventLoopDelay(e){let t=new Map;return{enable(){},disable(){},reset(){},percentile(e){return 0},get min(){return 0},get max(){return 0},get mean(){return 0},get stddev(){return 0},get percentiles(){return t}}}var s={performance:e,PerformanceObserver:n,PerformanceEntry:r,PerformanceObserverEntryList:i,PerformanceMark:a,PerformanceMeasure:o,eventLoopUtilization,timerify,monitorEventLoopDelay};export{r as PerformanceEntry,a as PerformanceMark,o as PerformanceMeasure,n as PerformanceObserver,i as PerformanceObserverEntryList,s as default,eventLoopUtilization,monitorEventLoopDelay,e as performance,timerify};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/perf_hooks",
3
- "version": "0.4.43",
3
+ "version": "0.5.0",
4
4
  "description": "Node.js perf_hooks module for Gjs",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -39,9 +39,9 @@
39
39
  "perf_hooks"
40
40
  ],
41
41
  "devDependencies": {
42
- "@gjsify/cli": "^0.4.43",
43
- "@gjsify/unit": "^0.4.43",
44
- "@types/node": "^25.9.1",
42
+ "@gjsify/cli": "^0.5.0",
43
+ "@gjsify/unit": "^0.5.0",
44
+ "@types/node": "^25.9.2",
45
45
  "typescript": "^6.0.3"
46
46
  },
47
47
  "gjsify": {