@gjsify/module 0.3.20 → 0.3.21

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{findPnpManifest as e,loadPnpManifest as t,resolveBareViaPnp as n}from"./pnp.js";import"@girs/gjs";import r from"@girs/gio-2.0";import i from"@girs/glib-2.0";import{readJSON as a,resolve as o}from"@gjsify/utils";const s=`assert.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.domain.events.fs.http.http2.https.inspector.module.net.os.path.perf_hooks.process.punycode.querystring.readline.repl.stream.string_decoder.sys.timers.tls.tty.url.util.v8.vm.wasi.worker_threads.zlib`.split(`.`);function c(e){let t=e.startsWith(`node:`)?e.slice(5):e,n=t.split(`/`)[0];return s.includes(t)||s.includes(n)}function l(e){let t=e.query_info(`standard::`,r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(t.get_is_symlink()){let n=t.get_symlink_target(),r=e.get_parent();if(n&&r)return r.resolve_relative_path(n).get_path()}return e.get_path()}function u(e){let t=r.File.new_for_path(e+`.js`);return t.query_exists(null)?t:null}function d(e){return e.includes(`.`)}function f(e){let t=o(e,`package.json`);if(!t.query_exists(null))return null;let n=a(t.get_path()),r=n.main||n.module||`index.js`,i=o(e,r);if(i.query_exists(null))return i.get_path();if(!d(r)){let e=u(i.get_path());if(e)return e.get_path()}return null}function p(e){if(typeof e==`object`&&e&&`href`in e){let t=e;if(t.protocol&&t.protocol!==`file:`)throw TypeError(`The URL must use the file: protocol`);return i.filename_from_uri(t.href)[0]}return typeof e==`string`&&e.startsWith(`file:`)?i.filename_from_uri(e)[0]:String(e)}function m(i,a){let o=e(a);if(!o)return null;let s=t(o);if(!s)return null;let c=n(s,i,a);if(!c)return null;let l=r.File.new_for_path(c);return l.query_exists(null)?l:null}function h(e,t){let n=r.File.new_for_path(t);for(;n.has_parent(null);){let t=n.resolve_relative_path(`node_modules`);if(t.query_exists(null)){let n=t.resolve_relative_path(e);if(n.query_exists(null))return n;let r=n.get_basename();if(r&&!d(r)){let e=u(n.get_path());if(e)return e}}n=n.get_parent()}throw Error(`Cannot find module "${e}" - not found in any node_modules directory`)}function g(e,t){if(c(e))return e;let n;if(n=e.startsWith(`/`)?o(e):e.startsWith(`.`)?o(t,e):m(e,t)??h(e,t),e.startsWith(`/`)||e.startsWith(`.`)){if(!n.query_exists(null)){let e=n.get_basename();e&&!d(e)&&(n=u(n.get_path())??n)}if(!n.query_exists(null))throw Error(`Cannot find module "${e}"`)}let r=l(n),i=n.get_basename();if(i&&!d(i)){let e=f(r);if(e)return e}return r}function _(e,t){if(e in t)return t[e];let n=r.File.new_for_path(e),i=n.get_parent().get_path(),a=n.get_basename();if(a.endsWith(`.mjs`))throw Error(`Cannot require .mjs files. Use import instead. Path: "${e}"`);if(a.endsWith(`.cjs`)){let e=o(i,`__gjsify__`+a.replace(/\.cjs$/,`.js`));e.query_exists(null)&&e.delete(null),n.copy(e,r.FileCopyFlags.NONE,null,null),n=e,a=n.get_basename()}let s=globalThis.exports,c=globalThis.module,l={exports:{}};globalThis.exports=l.exports,globalThis.module=l;try{let{searchPath:n}=imports;n.unshift(i),imports[a.replace(/\.(js|cjs)$/,``)],n.shift();let r=l.exports;return t[e]=r,r}finally{globalThis.exports=s,globalThis.module=c}}function v(e){let t=p(e);if(!t.startsWith(`/`))throw TypeError(`The argument must be a file URL object, file URL string, or absolute path string. Received "${String(e)}"`);let n=i.path_get_dirname(t),r=Object.create(null),o=function(e){let t=g(e,n);if(t in r)return r[t];if(t.endsWith(`.json`)){let e=a(t);return r[t]=e,e}if(c(e))throw Error(`createRequire: Cannot require builtin module "${e}" synchronously in GJS. Use import instead.`);return _(t,r)};return o.resolve=function(e){return g(e,n)},o.resolve.paths=e=>null,o.cache=r,o.extensions=Object.create(null),o.main=void 0,o}var y={builtinModules:s,isBuiltin:c,createRequire:v};export{s as builtinModules,v as createRequire,y as default,c as isBuiltin};
1
+ import{findPnpManifest as e,loadPnpManifest as t,resolveBareViaPnp as n}from"./pnp.js";import"@girs/gjs";import r from"@girs/gio-2.0";import i from"@girs/glib-2.0";import{readJSON as a,resolve as o}from"@gjsify/utils";const s=`assert.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.domain.events.fs.http.http2.https.inspector.module.net.os.path.perf_hooks.process.punycode.querystring.readline.repl.stream.string_decoder.sys.timers.tls.tty.url.util.v8.vm.wasi.worker_threads.zlib`.split(`.`);function isBuiltin(e){let t=e.startsWith(`node:`)?e.slice(5):e,n=t.split(`/`)[0];return s.includes(t)||s.includes(n)}function resolveSymlink(e){let t=e.query_info(`standard::`,r.FileQueryInfoFlags.NOFOLLOW_SYMLINKS,null);if(t.get_is_symlink()){let n=t.get_symlink_target(),r=e.get_parent();if(n&&r)return r.resolve_relative_path(n).get_path()}return e.get_path()}function tryJsExtension(e){let t=r.File.new_for_path(e+`.js`);return t.query_exists(null)?t:null}function hasExtension(e){return e.includes(`.`)}function resolvePackageEntry(e){let t=o(e,`package.json`);if(!t.query_exists(null))return null;let n=a(t.get_path()),r=n.main||n.module||`index.js`,i=o(e,r);if(i.query_exists(null))return i.get_path();if(!hasExtension(r)){let e=tryJsExtension(i.get_path());if(e)return e.get_path()}return null}function fileUrlToPath(e){if(typeof e==`object`&&e&&`href`in e){let t=e;if(t.protocol&&t.protocol!==`file:`)throw TypeError(`The URL must use the file: protocol`);return i.filename_from_uri(t.href)[0]}return typeof e==`string`&&e.startsWith(`file:`)?i.filename_from_uri(e)[0]:String(e)}function resolveBareViaPnpFromCaller(i,a){let o=e(a);if(!o)return null;let s=t(o);if(!s)return null;let c=n(s,i,a);if(!c)return null;let l=r.File.new_for_path(c);return l.query_exists(null)?l:null}function resolveInNodeModules(e,t){let n=r.File.new_for_path(t);for(;n.has_parent(null);){let t=n.resolve_relative_path(`node_modules`);if(t.query_exists(null)){let n=t.resolve_relative_path(e);if(n.query_exists(null))return n;let r=n.get_basename();if(r&&!hasExtension(r)){let e=tryJsExtension(n.get_path());if(e)return e}}n=n.get_parent()}throw Error(`Cannot find module "${e}" - not found in any node_modules directory`)}function resolveModulePath(e,t){if(isBuiltin(e))return e;let n;if(n=e.startsWith(`/`)?o(e):e.startsWith(`.`)?o(t,e):resolveBareViaPnpFromCaller(e,t)??resolveInNodeModules(e,t),e.startsWith(`/`)||e.startsWith(`.`)){if(!n.query_exists(null)){let e=n.get_basename();e&&!hasExtension(e)&&(n=tryJsExtension(n.get_path())??n)}if(!n.query_exists(null))throw Error(`Cannot find module "${e}"`)}let r=resolveSymlink(n),i=n.get_basename();if(i&&!hasExtension(i)){let e=resolvePackageEntry(r);if(e)return e}return r}function requireJsFile(e,t){if(e in t)return t[e];let n=r.File.new_for_path(e),i=n.get_parent().get_path(),a=n.get_basename();if(a.endsWith(`.mjs`))throw Error(`Cannot require .mjs files. Use import instead. Path: "${e}"`);if(a.endsWith(`.cjs`)){let e=o(i,`__gjsify__`+a.replace(/\.cjs$/,`.js`));e.query_exists(null)&&e.delete(null),n.copy(e,r.FileCopyFlags.NONE,null,null),n=e,a=n.get_basename()}let s=globalThis.exports,c=globalThis.module,l={exports:{}};globalThis.exports=l.exports,globalThis.module=l;try{let{searchPath:n}=imports;n.unshift(i),imports[a.replace(/\.(js|cjs)$/,``)],n.shift();let r=l.exports;return t[e]=r,r}finally{globalThis.exports=s,globalThis.module=c}}function createRequire(e){let t=fileUrlToPath(e);if(!t.startsWith(`/`))throw TypeError(`The argument must be a file URL object, file URL string, or absolute path string. Received "${String(e)}"`);let n=i.path_get_dirname(t),r=Object.create(null),req=function(e){let t=resolveModulePath(e,n);if(t in r)return r[t];if(t.endsWith(`.json`)){let e=a(t);return r[t]=e,e}if(isBuiltin(e))throw Error(`createRequire: Cannot require builtin module "${e}" synchronously in GJS. Use import instead.`);return requireJsFile(t,r)};return req.resolve=function(e){return resolveModulePath(e,n)},req.resolve.paths=e=>null,req.cache=r,req.extensions=Object.create(null),req.main=void 0,req}var c={builtinModules:s,isBuiltin,createRequire};export{s as builtinModules,createRequire,c as default,isBuiltin};
package/lib/esm/pnp.js CHANGED
@@ -1 +1 @@
1
- import e from"@girs/gio-2.0";import t from"@girs/glib-2.0";const n=new Map;function r(t){let n=e.File.new_for_path(t);for(;n.has_parent(null);){let e=n.resolve_relative_path(`.pnp.cjs`);if(e.query_exists(null))return e.get_path();n=n.get_parent()}return null}function i(r){let i=n.get(r);if(i!==void 0)return i;let o=e.File.new_for_path(r),s;try{let[e,t]=o.load_contents(null);if(!e)return n.set(r,null),null;s=new TextDecoder().decode(t)}catch{return n.set(r,null),null}let c=a(s);if(!c)return n.set(r,null),null;let l=t.path_get_dirname(r),u=new Map,d=new Map;for(let[e,t]of c.packageRegistryData){let n=new Map;for(let[r,i]of t)n.set(r,i),i.discardFromLookup||d.set(i.packageLocation,{name:e,reference:r});u.set(e,n)}let f={rootDir:l,packages:u,locatorsByLocation:d};return n.set(r,f),f}function a(e){let t=e.indexOf(`const RAW_RUNTIME_STATE =`);if(t<0)return null;let n=e.indexOf(`'`,t);if(n<0)return null;let r=n+1;for(;r<e.length;){let t=e.charCodeAt(r);if(t===92){r+=2;continue}if(t===39)break;r++}if(r>=e.length)return null;let i=e.slice(n+1,r);i=i.replace(/\\\n/g,``);try{return JSON.parse(i)}catch{return null}}function o(e,t){let n=u(e.rootDir,t);if(n===null)return null;let r=null;for(let t of e.locatorsByLocation.keys())n.startsWith(t)&&(r===null||t.length>r.length)&&(r=t);if(r===null)return null;let i=e.locatorsByLocation.get(r),a=e.packages.get(i.name)?.get(i.reference);return a?{locator:i,info:a}:null}function s(t,n,r){let i=o(t,r);if(!i)return null;let{pkgName:a,subPath:s}=c(n),u=i.info.packageDependencies?.find(([e])=>e===a);if(!u)return null;let[,d]=u;if(d===null)return null;let f=t.packages.get(a)?.get(d);if(!f)return null;let p=f.packageLocation.startsWith(`/`)?e.File.new_for_path(f.packageLocation):e.File.new_for_path(t.rootDir).resolve_relative_path(l(f.packageLocation));return(s?p.resolve_relative_path(s):p).get_path()}function c(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t<0)return{pkgName:e,subPath:``};let n=e.indexOf(`/`,t+1);return n<0?{pkgName:e,subPath:``}:{pkgName:e.slice(0,n),subPath:e.slice(n+1)}}let t=e.indexOf(`/`);return t<0?{pkgName:e,subPath:``}:{pkgName:e.slice(0,t),subPath:e.slice(t+1)}}function l(e){return e.startsWith(`./`)?e.slice(2):e}function u(e,t){if(t===e)return`./`;let n=e.endsWith(`/`)?e:e+`/`;return t.startsWith(n)?`./`+t.slice(n.length):null}export{o as findPackageOwning,r as findPnpManifest,i as loadPnpManifest,s as resolveBareViaPnp};
1
+ import e from"@girs/gio-2.0";import t from"@girs/glib-2.0";const n=new Map;function findPnpManifest(t){let n=e.File.new_for_path(t);for(;n.has_parent(null);){let e=n.resolve_relative_path(`.pnp.cjs`);if(e.query_exists(null))return e.get_path();n=n.get_parent()}return null}function loadPnpManifest(r){let i=n.get(r);if(i!==void 0)return i;let a=e.File.new_for_path(r),o;try{let[e,t]=a.load_contents(null);if(!e)return n.set(r,null),null;o=new TextDecoder().decode(t)}catch{return n.set(r,null),null}let s=extractRawRuntimeState(o);if(!s)return n.set(r,null),null;let c=t.path_get_dirname(r),l=new Map,u=new Map;for(let[e,t]of s.packageRegistryData){let n=new Map;for(let[r,i]of t)n.set(r,i),i.discardFromLookup||u.set(i.packageLocation,{name:e,reference:r});l.set(e,n)}let d={rootDir:c,packages:l,locatorsByLocation:u};return n.set(r,d),d}function extractRawRuntimeState(e){let t=e.indexOf(`const RAW_RUNTIME_STATE =`);if(t<0)return null;let n=e.indexOf(`'`,t);if(n<0)return null;let r=n+1;for(;r<e.length;){let t=e.charCodeAt(r);if(t===92){r+=2;continue}if(t===39)break;r++}if(r>=e.length)return null;let i=e.slice(n+1,r);i=i.replace(/\\\n/g,``);try{return JSON.parse(i)}catch{return null}}function findPackageOwning(e,t){let n=relativeFromRoot(e.rootDir,t);if(n===null)return null;let r=null;for(let t of e.locatorsByLocation.keys())n.startsWith(t)&&(r===null||t.length>r.length)&&(r=t);if(r===null)return null;let i=e.locatorsByLocation.get(r),a=e.packages.get(i.name)?.get(i.reference);return a?{locator:i,info:a}:null}function resolveBareViaPnp(t,n,r){let i=findPackageOwning(t,r);if(!i)return null;let{pkgName:a,subPath:o}=splitSpecifier(n),s=i.info.packageDependencies?.find(([e])=>e===a);if(!s)return null;let[,c]=s;if(c===null)return null;let l=t.packages.get(a)?.get(c);if(!l)return null;let u=l.packageLocation.startsWith(`/`)?e.File.new_for_path(l.packageLocation):e.File.new_for_path(t.rootDir).resolve_relative_path(stripLeadingDotSlash(l.packageLocation));return(o?u.resolve_relative_path(o):u).get_path()}function splitSpecifier(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t<0)return{pkgName:e,subPath:``};let n=e.indexOf(`/`,t+1);return n<0?{pkgName:e,subPath:``}:{pkgName:e.slice(0,n),subPath:e.slice(n+1)}}let t=e.indexOf(`/`);return t<0?{pkgName:e,subPath:``}:{pkgName:e.slice(0,t),subPath:e.slice(t+1)}}function stripLeadingDotSlash(e){return e.startsWith(`./`)?e.slice(2):e}function relativeFromRoot(e,t){if(t===e)return`./`;let n=e.endsWith(`/`)?e:e+`/`;return t.startsWith(n)?`./`+t.slice(n.length):null}export{findPackageOwning,findPnpManifest,loadPnpManifest,resolveBareViaPnp};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/module",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "description": "Node.js module module for Gjs",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -33,11 +33,11 @@
33
33
  "@girs/gio-2.0": "2.88.0-4.0.0-rc.14",
34
34
  "@girs/gjs": "4.0.0-rc.14",
35
35
  "@girs/glib-2.0": "2.88.0-4.0.0-rc.14",
36
- "@gjsify/utils": "^0.3.20"
36
+ "@gjsify/utils": "^0.3.21"
37
37
  },
38
38
  "devDependencies": {
39
- "@gjsify/cli": "^0.3.20",
40
- "@gjsify/unit": "^0.3.20",
39
+ "@gjsify/cli": "^0.3.21",
40
+ "@gjsify/unit": "^0.3.21",
41
41
  "@types/node": "^25.6.2",
42
42
  "typescript": "^6.0.3"
43
43
  }