@gjsify/module 0.52.0 → 0.53.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/lib/esm/index.js +1 -1
- package/lib/types/index.d.ts +24 -0
- package/package.json +4 -4
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";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 isDirectory(e){return r.File.new_for_path(e).query_file_type(r.FileQueryInfoFlags.NONE,null)===r.FileType.DIRECTORY}function resolvePackageEntry(e){let t=o(e,`package.json`);if(!t.query_exists(null))return null;let n=a(t.get_path());if(n.exports!==void 0){let t=resolveExportsMap(n.exports,`.`,c);if(t){let n=o(e,t);if(n.query_exists(null))return n.get_path()}}let 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 resolveExportsMap(e,t,n){if(typeof e==`string`)return t===`.`?e:void 0;if(typeof e!=`object`||!e)return;let r=e,i=Object.keys(r).some(e=>e===`.`||e.startsWith(`./`))?r[t]:t===`.`?r:void 0;if(i!=null)return pickConditionalValue(i,n)}function pickConditionalValue(e,t){if(typeof e==`string`)return e;if(typeof e!=`object`||!e)return;let n=e;for(let e of t)if(e in n){let r=pickConditionalValue(n[e],t);if(r!==void 0)return r}if(`default`in n&&!t.includes(`default`))return pickConditionalValue(n.default,t)}const c=[`node`,`import`,`default`];function splitBareSpecifier(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t===-1)return{pkg:e,subpath:`.`};let n=e.indexOf(`/`,t+1);return n===-1?{pkg:e,subpath:`.`}:{pkg:e.slice(0,n),subpath:`.`+e.slice(n)}}let t=e.indexOf(`/`);return t===-1?{pkg:e,subpath:`.`}:{pkg:e.slice(0,t),subpath:`.`+e.slice(t)}}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{pkg:n,subpath:i}=splitBareSpecifier(e),o=r.File.new_for_path(t);for(;o.has_parent(null);){let t=o.resolve_relative_path(`node_modules`);if(t.query_exists(null)){let r=t.resolve_relative_path(n);if(r.query_exists(null)){let e=r.resolve_relative_path(`package.json`);if(e.query_exists(null)){let t=a(e.get_path());if(t.exports!==void 0){let e=resolveExportsMap(t.exports,i,c);if(e!==void 0){let t=r.resolve_relative_path(e);if(t.query_exists(null))return t}}}let t=i===`.`?r:r.resolve_relative_path(i.slice(2));if(t.query_exists(null))return t;let n=t.get_basename();if(n&&!hasExtension(n)){let e=tryJsExtension(t.get_path());if(e)return e}}else{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}}}o=o.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 t=resolvePackageEntry(r);if(t)return t;if(isDirectory(r))throw Error(`Cannot find module "${e}" - ${r} exists but has no resolvable package entry (its package.json exports/main point at a file that does not exist)`)}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),o=function require(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 o.resolve=function resolve(e){return resolveModulePath(e,n)},o.resolve.paths=e=>null,o.cache=r,o.extensions=Object.create(null),o.main=void 0,o}var l={builtinModules:s,isBuiltin,createRequire};export{s as builtinModules,createRequire,l as default,isBuiltin};
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";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 isDirectory(e){return r.File.new_for_path(e).query_file_type(r.FileQueryInfoFlags.NONE,null)===r.FileType.DIRECTORY}function resolvePackageEntry(e){let t=o(e,`package.json`);if(!t.query_exists(null))return null;let n=a(t.get_path());if(n.exports!==void 0){let t=resolveExportsMap(n.exports,`.`,c);if(t){let n=o(e,t);if(n.query_exists(null))return n.get_path()}}let 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 resolveExportsMap(e,t,n){if(typeof e==`string`)return t===`.`?e:void 0;if(typeof e!=`object`||!e)return;let r=e,i=Object.keys(r).some(e=>e===`.`||e.startsWith(`./`))?r[t]:t===`.`?r:void 0;if(i!=null)return pickConditionalValue(i,n)}function pickConditionalValue(e,t){if(typeof e==`string`)return e;if(typeof e!=`object`||!e)return;let n=e;for(let e of t)if(e in n){let r=pickConditionalValue(n[e],t);if(r!==void 0)return r}if(`default`in n&&!t.includes(`default`))return pickConditionalValue(n.default,t)}const c=[`node`,`import`,`default`];function splitBareSpecifier(e){if(e.startsWith(`@`)){let t=e.indexOf(`/`);if(t===-1)return{pkg:e,subpath:`.`};let n=e.indexOf(`/`,t+1);return n===-1?{pkg:e,subpath:`.`}:{pkg:e.slice(0,n),subpath:`.`+e.slice(n)}}let t=e.indexOf(`/`);return t===-1?{pkg:e,subpath:`.`}:{pkg:e.slice(0,t),subpath:`.`+e.slice(t)}}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{pkg:n,subpath:i}=splitBareSpecifier(e),o=r.File.new_for_path(t);for(;o.has_parent(null);){let t=o.resolve_relative_path(`node_modules`);if(t.query_exists(null)){let r=t.resolve_relative_path(n);if(r.query_exists(null)){let e=r.resolve_relative_path(`package.json`);if(e.query_exists(null)){let t=a(e.get_path());if(t.exports!==void 0){let e=resolveExportsMap(t.exports,i,c);if(e!==void 0){let t=r.resolve_relative_path(e);if(t.query_exists(null))return t}}}let t=i===`.`?r:r.resolve_relative_path(i.slice(2));if(t.query_exists(null))return t;let n=t.get_basename();if(n&&!hasExtension(n)){let e=tryJsExtension(t.get_path());if(e)return e}}else{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}}}o=o.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 t=resolvePackageEntry(r);if(t)return t;if(isDirectory(r))throw Error(`Cannot find module "${e}" - ${r} exists but has no resolvable package entry (its package.json exports/main point at a file that does not exist)`)}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),o=function require(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 o.resolve=function resolve(e){return resolveModulePath(e,n)},o.resolve.paths=e=>null,o.cache=r,o.extensions=Object.create(null),o.main=void 0,o}var Module=class{static builtinModules=s;static isBuiltin=isBuiltin;static createRequire=createRequire;static Module;id;filename=null;loaded=!1;exports={};children=[];paths=[];parent;constructor(e=``,t){this.id=e,this.parent=t}};Module.Module=Module;var l={builtinModules:s,isBuiltin,createRequire,Module};export{Module,s as builtinModules,createRequire,l as default,isBuiltin};
|
package/lib/types/index.d.ts
CHANGED
|
@@ -2,9 +2,33 @@ import '@girs/gjs';
|
|
|
2
2
|
export declare const builtinModules: string[];
|
|
3
3
|
export declare function isBuiltin(name: string): boolean;
|
|
4
4
|
export declare function createRequire(filenameOrURL: string | URL): NodeRequire;
|
|
5
|
+
/**
|
|
6
|
+
* Node's CommonJS `Module` class — `require('module')` itself, and `Module.Module`.
|
|
7
|
+
*
|
|
8
|
+
* Packages mostly FEATURE-DETECT through it: vite picks its config loader by asking
|
|
9
|
+
* `Module.registerHooks` / `Module.register`, and a bare `import { Module }` failed its
|
|
10
|
+
* `--app gjs` build outright with MISSING_EXPORT. So the class carries the statics this
|
|
11
|
+
* package implements and none it does not — an absent `register` is the honest answer
|
|
12
|
+
* to "can I install a loader hook".
|
|
13
|
+
*/
|
|
14
|
+
export declare class Module {
|
|
15
|
+
static builtinModules: string[];
|
|
16
|
+
static isBuiltin: typeof isBuiltin;
|
|
17
|
+
static createRequire: typeof createRequire;
|
|
18
|
+
static Module: typeof Module;
|
|
19
|
+
id: string;
|
|
20
|
+
filename: string | null;
|
|
21
|
+
loaded: boolean;
|
|
22
|
+
exports: unknown;
|
|
23
|
+
children: Module[];
|
|
24
|
+
paths: string[];
|
|
25
|
+
parent: Module | null | undefined;
|
|
26
|
+
constructor(id?: string, parent?: Module | null);
|
|
27
|
+
}
|
|
5
28
|
declare const _default: {
|
|
6
29
|
builtinModules: string[];
|
|
7
30
|
isBuiltin: typeof isBuiltin;
|
|
8
31
|
createRequire: typeof createRequire;
|
|
32
|
+
Module: typeof Module;
|
|
9
33
|
};
|
|
10
34
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/module",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.53.0",
|
|
4
4
|
"description": "Node.js module module for Gjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "lib/esm/index.js",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"@girs/gio-2.0": "5.4.0",
|
|
42
42
|
"@girs/gjs": "5.4.0",
|
|
43
43
|
"@girs/glib-2.0": "5.4.0",
|
|
44
|
-
"@gjsify/utils": "^0.
|
|
44
|
+
"@gjsify/utils": "^0.53.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@gjsify/cli": "^0.
|
|
48
|
-
"@gjsify/unit": "^0.
|
|
47
|
+
"@gjsify/cli": "^0.53.0",
|
|
48
|
+
"@gjsify/unit": "^0.53.0",
|
|
49
49
|
"@types/node": "^25.9.2",
|
|
50
50
|
"typescript": "^6.0.3"
|
|
51
51
|
},
|