@gjsify/utils 0.64.13 → 0.64.14
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/core.js +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/main-loop.js +1 -1
- package/lib/esm/next-tick.js +1 -1
- package/lib/types/main-loop.d.ts +6 -0
- package/package.json +2 -2
package/lib/esm/core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeCallable as e}from"./callable.js";import{deferEmit as t}from"./defer.js";import{initErrorV8Methods as n}from"./error.js";import{GIO_ERROR_TO_NODE as r,GLIB_FILE_ERROR_TO_NODE as i,createGLibFileError as a,createNodeError as o,isNotFoundError as s}from"./gio-errors.js";import{registerGlobal as c}from"./globals.js";import{TARGET_OSES as l,hostOs as u,hostPlatform as d,isDarwin as f,isLinux as p,isTargetOs as m,isWin32 as h}from"./host-os.js";import{notImplemented as g,warnNotImplemented as _}from"./message.js";import{queueMicrotask as v}from"./microtask.js";import{encodePathForFileUrl as y,isWindowsPath as b,lastPathSeparatorIndex as x,pathToFileUrlHref as S,splitPathComponents as C}from"./path-shape.js";import{PROBED_GI_LIBDIRS as w,TYPELIB_SUBDIR as T,dyldDefaultFallbackDirs as E,giLibraryDirsForTypelibDir as D,splitSearchPath as O,systemGiLibraryDirs as k}from"./system-gi-dirs.js";import{decodeXmlEntities as A,scanXml as j}from"./xml-scan.js";import{mapMachine as M,mapSysname as N}from"./platform-names.js";import{structuredClone as P}from"./structured-clone.js";import{hasProcfs as F,hostEnv as I,hostExecPath as L,hostPid as R,hostPpid as z,readProcessMemory as B}from"./host-process.js";import{acquireMainLoop as V,ensureMainLoop as H,holdMainLoop as U,quitMainLoop as W,releaseMainLoop as G,trackRequest as K,trackTimer as q,
|
|
1
|
+
import{makeCallable as e}from"./callable.js";import{deferEmit as t}from"./defer.js";import{initErrorV8Methods as n}from"./error.js";import{GIO_ERROR_TO_NODE as r,GLIB_FILE_ERROR_TO_NODE as i,createGLibFileError as a,createNodeError as o,isNotFoundError as s}from"./gio-errors.js";import{registerGlobal as c}from"./globals.js";import{TARGET_OSES as l,hostOs as u,hostPlatform as d,isDarwin as f,isLinux as p,isTargetOs as m,isWin32 as h}from"./host-os.js";import{notImplemented as g,warnNotImplemented as _}from"./message.js";import{queueMicrotask as v}from"./microtask.js";import{encodePathForFileUrl as y,isWindowsPath as b,lastPathSeparatorIndex as x,pathToFileUrlHref as S,splitPathComponents as C}from"./path-shape.js";import{PROBED_GI_LIBDIRS as w,TYPELIB_SUBDIR as T,dyldDefaultFallbackDirs as E,giLibraryDirsForTypelibDir as D,splitSearchPath as O,systemGiLibraryDirs as k}from"./system-gi-dirs.js";import{decodeXmlEntities as A,scanXml as j}from"./xml-scan.js";import{mapMachine as M,mapSysname as N}from"./platform-names.js";import{structuredClone as P}from"./structured-clone.js";import{hasProcfs as F,hostEnv as I,hostExecPath as L,hostPid as R,hostPpid as z,readProcessMemory as B}from"./host-process.js";import{acquireMainLoop as V,ensureMainLoop as H,holdMainLoop as U,quitMainLoop as W,releaseMainLoop as G,trackRequest as K,trackTimer as q,trackedCallback as J,untrackRequest as Y,untrackTimer as X}from"./main-loop.js";import{NativeLibraryLoadError as Z,colocateNativeLibrary as Q,loadOptionalNativeModule as $,missingLibraryDependency as ee,openNativeLibrary as te,probeNativeLibrary as ne}from"./native-library.js";import{__resetBurstStateForTests as re,nextTick as ie}from"./next-tick.js";export{r as GIO_ERROR_TO_NODE,i as GLIB_FILE_ERROR_TO_NODE,Z as NativeLibraryLoadError,w as PROBED_GI_LIBDIRS,l as TARGET_OSES,T as TYPELIB_SUBDIR,re as __resetBurstStateForTests,V as acquireMainLoop,Q as colocateNativeLibrary,a as createGLibFileError,o as createNodeError,A as decodeXmlEntities,t as deferEmit,E as dyldDefaultFallbackDirs,y as encodePathForFileUrl,H as ensureMainLoop,D as giLibraryDirsForTypelibDir,F as hasProcfs,U as holdMainLoop,I as hostEnv,L as hostExecPath,u as hostOs,R as hostPid,d as hostPlatform,z as hostPpid,n as initErrorV8Methods,f as isDarwin,p as isLinux,s as isNotFoundError,m as isTargetOs,h as isWin32,b as isWindowsPath,x as lastPathSeparatorIndex,$ as loadOptionalNativeModule,e as makeCallable,M as mapMachine,N as mapSysname,ee as missingLibraryDependency,ie as nextTick,g as notImplemented,te as openNativeLibrary,S as pathToFileUrlHref,ne as probeNativeLibrary,v as queueMicrotask,W as quitMainLoop,B as readProcessMemory,c as registerGlobal,G as releaseMainLoop,j as scanXml,C as splitPathComponents,O as splitSearchPath,P as structuredClone,k as systemGiLibraryDirs,K as trackRequest,q as trackTimer,J as trackedCallback,Y as untrackRequest,X as untrackTimer,_ as warnNotImplemented};
|
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{gbytesToUint8Array as e}from"./byte-array.js";import{makeCallable as t}from"./callable.js";import{cli as n}from"./cli.js";import{deferEmit as r}from"./defer.js";import{initErrorV8Methods as i}from"./error.js";import{GIO_ERROR_TO_NODE as a,GLIB_FILE_ERROR_TO_NODE as o,createGLibFileError as s,createNodeError as c,isNotFoundError as l}from"./gio-errors.js";import{registerGlobal as u}from"./globals.js";import{TARGET_OSES as d,hostOs as f,hostPlatform as p,isDarwin as m,isLinux as h,isTargetOs as g,isWin32 as _}from"./host-os.js";import{notImplemented as v,warnNotImplemented as y}from"./message.js";import{queueMicrotask as b}from"./microtask.js";import{encodePathForFileUrl as x,isWindowsPath as S,lastPathSeparatorIndex as C,pathToFileUrlHref as w,splitPathComponents as T}from"./path-shape.js";import{PROBED_GI_LIBDIRS as E,TYPELIB_SUBDIR as D,dyldDefaultFallbackDirs as O,giLibraryDirsForTypelibDir as k,splitSearchPath as A,systemGiLibraryDirs as j}from"./system-gi-dirs.js";import{decodeXmlEntities as M,scanXml as N}from"./xml-scan.js";import{mapMachine as P,mapSysname as F}from"./platform-names.js";import{structuredClone as I}from"./structured-clone.js";import{hasProcfs as L,hostEnv as R,hostExecPath as z,hostPid as B,hostPpid as V,readProcessMemory as H}from"./host-process.js";import{acquireMainLoop as U,ensureMainLoop as W,holdMainLoop as G,quitMainLoop as K,releaseMainLoop as q,trackRequest as J,trackTimer as Y,
|
|
1
|
+
import{gbytesToUint8Array as e}from"./byte-array.js";import{makeCallable as t}from"./callable.js";import{cli as n}from"./cli.js";import{deferEmit as r}from"./defer.js";import{initErrorV8Methods as i}from"./error.js";import{GIO_ERROR_TO_NODE as a,GLIB_FILE_ERROR_TO_NODE as o,createGLibFileError as s,createNodeError as c,isNotFoundError as l}from"./gio-errors.js";import{registerGlobal as u}from"./globals.js";import{TARGET_OSES as d,hostOs as f,hostPlatform as p,isDarwin as m,isLinux as h,isTargetOs as g,isWin32 as _}from"./host-os.js";import{notImplemented as v,warnNotImplemented as y}from"./message.js";import{queueMicrotask as b}from"./microtask.js";import{encodePathForFileUrl as x,isWindowsPath as S,lastPathSeparatorIndex as C,pathToFileUrlHref as w,splitPathComponents as T}from"./path-shape.js";import{PROBED_GI_LIBDIRS as E,TYPELIB_SUBDIR as D,dyldDefaultFallbackDirs as O,giLibraryDirsForTypelibDir as k,splitSearchPath as A,systemGiLibraryDirs as j}from"./system-gi-dirs.js";import{decodeXmlEntities as M,scanXml as N}from"./xml-scan.js";import{mapMachine as P,mapSysname as F}from"./platform-names.js";import{structuredClone as I}from"./structured-clone.js";import{hasProcfs as L,hostEnv as R,hostExecPath as z,hostPid as B,hostPpid as V,readProcessMemory as H}from"./host-process.js";import{acquireMainLoop as U,ensureMainLoop as W,holdMainLoop as G,quitMainLoop as K,releaseMainLoop as q,trackRequest as J,trackTimer as Y,trackedCallback as X,untrackRequest as Z,untrackTimer as Q}from"./main-loop.js";import{NativeLibraryLoadError as $,colocateNativeLibrary as ee,loadOptionalNativeModule as te,missingLibraryDependency as ne,openNativeLibrary as re,probeNativeLibrary as ie}from"./native-library.js";import{__resetBurstStateForTests as ae,nextTick as oe}from"./next-tick.js";import"./core.js";import{readJSON as se}from"./file.js";import{existsFD as ce,existsSync as le}from"./fs.js";import{gioAsync as ue,inputStreamAsyncIterator as de,readBytesAsync as fe}from"./gio.js";import{getNodeModulesPath as pe,getPathSeparator as me,getProgramDir as he,getProgramExe as ge,resolve as _e}from"./path.js";import{closeSocketService as ve,releaseListenPort as ye}from"./socket-service.js";export{a as GIO_ERROR_TO_NODE,o as GLIB_FILE_ERROR_TO_NODE,$ as NativeLibraryLoadError,E as PROBED_GI_LIBDIRS,d as TARGET_OSES,D as TYPELIB_SUBDIR,ae as __resetBurstStateForTests,U as acquireMainLoop,n as cli,ve as closeSocketService,ee as colocateNativeLibrary,s as createGLibFileError,c as createNodeError,M as decodeXmlEntities,r as deferEmit,O as dyldDefaultFallbackDirs,x as encodePathForFileUrl,W as ensureMainLoop,ce as existsFD,le as existsSync,e as gbytesToUint8Array,pe as getNodeModulesPath,me as getPathSeparator,he as getProgramDir,ge as getProgramExe,k as giLibraryDirsForTypelibDir,ue as gioAsync,L as hasProcfs,G as holdMainLoop,R as hostEnv,z as hostExecPath,f as hostOs,B as hostPid,p as hostPlatform,V as hostPpid,i as initErrorV8Methods,de as inputStreamAsyncIterator,m as isDarwin,h as isLinux,l as isNotFoundError,g as isTargetOs,_ as isWin32,S as isWindowsPath,C as lastPathSeparatorIndex,te as loadOptionalNativeModule,t as makeCallable,P as mapMachine,F as mapSysname,ne as missingLibraryDependency,oe as nextTick,v as notImplemented,re as openNativeLibrary,w as pathToFileUrlHref,ie as probeNativeLibrary,b as queueMicrotask,K as quitMainLoop,fe as readBytesAsync,se as readJSON,H as readProcessMemory,u as registerGlobal,ye as releaseListenPort,q as releaseMainLoop,_e as resolve,N as scanXml,T as splitPathComponents,A as splitSearchPath,I as structuredClone,j as systemGiLibraryDirs,J as trackRequest,Y as trackTimer,X as trackedCallback,Z as untrackRequest,Q as untrackTimer,y as warnNotImplemented};
|
package/lib/esm/main-loop.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";let e=null,t=!1,n=!1,r=0,i=!1,a=0,o=!1,s=!1,c=!1;function glib(){let e=globalThis;if(typeof e.process?.versions?.gjs==`string`||e.process===void 0)return e.imports?.gi?.GLib}function arm(e){n||(n=!0,e.runAsync().catch(()=>{}))}function ensureMainLoop(){return i=!1,createLoop()}function createLoop(){let n=glib();if(n)return t?e:(e=new n.MainLoop(null,!1),t=!0,n.main_depth()===0&&arm(e),e)}function holdMainLoop(){let e=ensureMainLoop();return e&&arm(e),e}function acquireMainLoop(){let e=t,n=createLoop();if(n)return r===0&&!s&&(i=!e),r+=1,n}function releaseMainLoop(){r===0||!e||(--r,drainIfIdle())}function trackTimer(){a+=1}function untrackTimer(){dropPending()}function trackRequest(){a+=1}function untrackRequest(){dropPending()}function dropPending(){a!==0&&(--a,a===0&&drainIfIdle())}function drainIfIdle(){if(r!==0||!e||!i)return;let t=e;if(!n){quitMainLoop();return}if(a!==0){s=!0;return}if(!t.is_running()){s=!0,awaitEntrySettle(t);return}exitParked()}function awaitEntrySettle(t){let n=glib();!n||c||(c=!0,n.timeout_add(n.PRIORITY_DEFAULT,20,()=>e!==t||r!==0||a!==0?(c=!1,n.SOURCE_REMOVE):t.is_running()?(c=!1,exitParked(),n.SOURCE_REMOVE):n.SOURCE_CONTINUE))}function exitParked(){let t=globalThis.process,n=glib();if(typeof t?.exit!=`function`||!n){quitMainLoop(),t?.exit?.(t.exitCode??0);return}if(o)return;o=!0;let i=e;n.timeout_add(n.PRIORITY_DEFAULT,0,()=>{if(o=!1,e!==i||r!==0)return n.SOURCE_REMOVE;if(a!==0)return s=!0,n.SOURCE_REMOVE;let c=t.exitCode??0;return quitMainLoop(),t.exit(c),n.SOURCE_REMOVE})}function quitMainLoop(){e&&(e.quit(),t=!1,n=!1,e=null,r=0,i=!1,s=!1)}export{acquireMainLoop,ensureMainLoop,holdMainLoop,quitMainLoop,releaseMainLoop,trackRequest,trackTimer,untrackRequest,untrackTimer};
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";let e=null,t=!1,n=!1,r=0,i=!1,a=0,o=!1,s=!1,c=!1;function glib(){let e=globalThis;if(typeof e.process?.versions?.gjs==`string`||e.process===void 0)return e.imports?.gi?.GLib}function arm(e){n||(n=!0,e.runAsync().catch(()=>{}))}function ensureMainLoop(){return i=!1,createLoop()}function createLoop(){let n=glib();if(n)return t?e:(e=new n.MainLoop(null,!1),t=!0,n.main_depth()===0&&arm(e),e)}function holdMainLoop(){let e=ensureMainLoop();return e&&arm(e),e}function acquireMainLoop(){let e=t,n=createLoop();if(n)return r===0&&!s&&(i=!e),r+=1,n}function releaseMainLoop(){r===0||!e||(--r,drainIfIdle())}function trackTimer(){a+=1}function untrackTimer(){dropPending()}function trackRequest(){a+=1}function untrackRequest(){dropPending()}function trackedCallback(e){return trackRequest(),(...t)=>{try{e(...t)}finally{untrackRequest()}}}function dropPending(){a!==0&&(--a,a===0&&drainIfIdle())}function drainIfIdle(){if(r!==0||!e||!i)return;let t=e;if(!n){quitMainLoop();return}if(a!==0){s=!0;return}if(!t.is_running()){s=!0,awaitEntrySettle(t);return}exitParked()}function awaitEntrySettle(t){let n=glib();!n||c||(c=!0,n.timeout_add(n.PRIORITY_DEFAULT,20,()=>e!==t||r!==0||a!==0?(c=!1,n.SOURCE_REMOVE):t.is_running()?(c=!1,exitParked(),n.SOURCE_REMOVE):n.SOURCE_CONTINUE))}function exitParked(){let t=globalThis.process,n=glib();if(typeof t?.exit!=`function`||!n){quitMainLoop(),t?.exit?.(t.exitCode??0);return}if(o)return;o=!0;let i=e;n.timeout_add(n.PRIORITY_DEFAULT,0,()=>{if(o=!1,e!==i||r!==0)return n.SOURCE_REMOVE;if(a!==0)return s=!0,n.SOURCE_REMOVE;let c=t.exitCode??0;return quitMainLoop(),t.exit(c),n.SOURCE_REMOVE})}function quitMainLoop(){e&&(e.quit(),t=!1,n=!1,e=null,r=0,i=!1,s=!1)}export{acquireMainLoop,ensureMainLoop,holdMainLoop,quitMainLoop,releaseMainLoop,trackRequest,trackTimer,trackedCallback,untrackRequest,untrackTimer};
|
package/lib/esm/next-tick.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";const
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{trackRequest as e,untrackRequest as t}from"./main-loop.js";const n=[];let r=!1;function setDrainerArmed(n){r!==n&&(r=n,n?e():t())}function drainOnce(e){let t=Math.min(64,n.length);for(let r=0;r<t;r++){let t=n.shift();try{t()}catch(t){try{e.log_default_handler(`gjsify-nextTick`,e.LogLevelFlags.LEVEL_WARNING,String(t?.stack||t),null)}catch{}}}n.length>0?e.timeout_add(e.PRIORITY_DEFAULT,1,()=>(drainOnce(e),!1)):setDrainerArmed(!1)}function tryGLibTimeout(e){let t=globalThis.imports?.gi?.GLib;return t?.timeout_add?(n.push(e),r||(setDrainerArmed(!0),t.timeout_add(t.PRIORITY_DEFAULT,0,()=>(drainOnce(t),!1))),!0):!1}function __resetBurstStateForTests(){n.length=0,setDrainerArmed(!1)}const nextTick=(e,...t)=>{let n=t.length>0?()=>e(...t):e;if(!tryGLibTimeout(n)){if(typeof globalThis.process?.nextTick==`function`){globalThis.process.nextTick(e,...t);return}if(typeof queueMicrotask==`function`){queueMicrotask(n);return}Promise.resolve().then(n)}};export{__resetBurstStateForTests,nextTick};
|
package/lib/types/main-loop.d.ts
CHANGED
|
@@ -94,6 +94,12 @@ export declare function untrackTimer(): void;
|
|
|
94
94
|
export declare function trackRequest(): void;
|
|
95
95
|
/** Drop one in-flight request after its completion has been delivered. */
|
|
96
96
|
export declare function untrackRequest(): void;
|
|
97
|
+
/**
|
|
98
|
+
* Count one request now and wrap its Gio completion callback so the count
|
|
99
|
+
* drops after the callback has run. Pass the wrapped callback straight to the
|
|
100
|
+
* `*_async` call: every Gio async call completes exactly once.
|
|
101
|
+
*/
|
|
102
|
+
export declare function trackedCallback<A extends unknown[]>(callback: (...args: A) => void): (...args: A) => void;
|
|
97
103
|
/**
|
|
98
104
|
* Quit the MainLoop created by `ensureMainLoop()`. Idempotent, no-op on Node.js.
|
|
99
105
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/utils",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.14",
|
|
4
4
|
"description": "Utils module for gjsify",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"fs"
|
|
50
50
|
],
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@gjsify/cli": "^0.64.
|
|
52
|
+
"@gjsify/cli": "^0.64.14",
|
|
53
53
|
"typescript": "^6.0.3"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|