@gjsify/perf_hooks 0.4.21 → 0.4.23

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/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;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.PerformanceObserver||PerformanceObserverStub,n=globalThis.PerformanceEntry||PerformanceEntryStub,r=globalThis.PerformanceObserverEntryList||PerformanceObserverEntryListStub,i=globalThis.PerformanceMark||class PerformanceMark extends PerformanceEntryStub{},a=globalThis.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 o={performance:e,PerformanceObserver:t,PerformanceEntry:n,PerformanceObserverEntryList:r,PerformanceMark:i,PerformanceMeasure:a,eventLoopUtilization,timerify,monitorEventLoopDelay};export{n as PerformanceEntry,i as PerformanceMark,a as PerformanceMeasure,t as PerformanceObserver,r as PerformanceObserverEntryList,o 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};
@@ -1,9 +1,36 @@
1
1
  declare let performance: Performance;
2
- declare const PerformanceObserver: any;
3
- declare const PerformanceEntry: any;
4
- declare const PerformanceObserverEntryList: any;
5
- declare const PerformanceMark: any;
6
- declare const PerformanceMeasure: any;
2
+ declare class PerformanceObserverStub {
3
+ private _callback;
4
+ constructor(callback: (list: any, observer: any) => void);
5
+ observe(_options?: {
6
+ entryTypes?: string[];
7
+ type?: string;
8
+ }): void;
9
+ disconnect(): void;
10
+ takeRecords(): any[];
11
+ }
12
+ declare class PerformanceEntryStub {
13
+ readonly name: string;
14
+ readonly entryType: string;
15
+ readonly startTime: number;
16
+ readonly duration: number;
17
+ toJSON(): {
18
+ name: string;
19
+ entryType: string;
20
+ startTime: number;
21
+ duration: number;
22
+ };
23
+ }
24
+ declare class PerformanceObserverEntryListStub {
25
+ getEntries(): any[];
26
+ getEntriesByName(_name: string): any[];
27
+ getEntriesByType(_type: string): any[];
28
+ }
29
+ declare const PerformanceObserver: typeof PerformanceObserverStub;
30
+ declare const PerformanceEntry: typeof PerformanceEntryStub;
31
+ declare const PerformanceObserverEntryList: typeof PerformanceObserverEntryListStub;
32
+ declare const PerformanceMark: typeof PerformanceEntryStub;
33
+ declare const PerformanceMeasure: typeof PerformanceEntryStub;
7
34
  /** Stub: event loop utilization metrics (not available in GJS). */
8
35
  declare function eventLoopUtilization(_utilization1?: any, _utilization2?: any): {
9
36
  idle: number;
@@ -29,11 +56,11 @@ declare function monitorEventLoopDelay(_options?: {
29
56
  export { performance, PerformanceObserver, PerformanceEntry, PerformanceObserverEntryList, PerformanceMark, PerformanceMeasure, eventLoopUtilization, timerify, monitorEventLoopDelay, };
30
57
  declare const _default: {
31
58
  performance: Performance;
32
- PerformanceObserver: any;
33
- PerformanceEntry: any;
34
- PerformanceObserverEntryList: any;
35
- PerformanceMark: any;
36
- PerformanceMeasure: any;
59
+ PerformanceObserver: typeof PerformanceObserverStub;
60
+ PerformanceEntry: typeof PerformanceEntryStub;
61
+ PerformanceObserverEntryList: typeof PerformanceObserverEntryListStub;
62
+ PerformanceMark: typeof PerformanceEntryStub;
63
+ PerformanceMeasure: typeof PerformanceEntryStub;
37
64
  eventLoopUtilization: typeof eventLoopUtilization;
38
65
  timerify: typeof timerify;
39
66
  monitorEventLoopDelay: typeof monitorEventLoopDelay;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/perf_hooks",
3
- "version": "0.4.21",
3
+ "version": "0.4.23",
4
4
  "description": "Node.js perf_hooks module for Gjs",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -33,9 +33,9 @@
33
33
  "perf_hooks"
34
34
  ],
35
35
  "devDependencies": {
36
- "@gjsify/cli": "^0.4.21",
37
- "@gjsify/unit": "^0.4.21",
38
- "@types/node": "^25.6.2",
36
+ "@gjsify/cli": "^0.4.23",
37
+ "@gjsify/unit": "^0.4.23",
38
+ "@types/node": "^25.9.1",
39
39
  "typescript": "^6.0.3"
40
40
  }
41
41
  }