@gjsify/sab-native 0.23.0 → 0.24.1
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 +1 -1
- package/lib/esm/index.js +1 -1
- package/package.json +6 -6
- package/prebuilds/{linux-aarch64 → linux-arm64}/libgjsifysabnative.so +0 -0
- package/prebuilds/linux-ppc64/libgjsifysabnative.so +0 -0
- package/prebuilds/linux-riscv64/libgjsifysabnative.so +0 -0
- package/prebuilds/linux-s390x/GjsifySabNative-1.0.typelib +0 -0
- package/prebuilds/linux-s390x/libgjsifysabnative.so +0 -0
- package/prebuilds/{linux-x86_64 → linux-x64}/libgjsifysabnative.so +0 -0
- /package/prebuilds/{linux-aarch64 → linux-arm64}/GjsifySabNative-1.0.gir +0 -0
- /package/prebuilds/{linux-aarch64 → linux-arm64}/GjsifySabNative-1.0.typelib +0 -0
- /package/prebuilds/{linux-x86_64 → linux-x64}/GjsifySabNative-1.0.gir +0 -0
- /package/prebuilds/{linux-x86_64 → linux-x64}/GjsifySabNative-1.0.typelib +0 -0
package/README.md
CHANGED
package/lib/esm/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./_virtual/_rolldown/runtime.js";const e=globalThis;function resolveNativeSab(e){if(!e)return null;let t;try{t=e.GjsifySabNative}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;return typeof n.SharedBuffer?.create!=`function`||typeof n.FdChannel?.make_pair!=`function`?null:n}const t=resolveNativeSab(e.imports?.gi),n=t;function hasNativeSab(){return t!==null}const r="@gjsify/sab-native: the native backend is not available on this platform. Cross-process SharedBuffer is currently Linux-only (memfd_create + futex + SCM_RIGHTS); prebuilds ship for linux-{
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";const e=globalThis;function resolveNativeSab(e){if(!e)return null;let t;try{t=e.GjsifySabNative}catch{return null}if(!t||typeof t!=`object`)return null;let n=t;return typeof n.SharedBuffer?.create!=`function`||typeof n.FdChannel?.make_pair!=`function`?null:n}const t=resolveNativeSab(e.imports?.gi),n=t;function hasNativeSab(){return t!==null}const r="@gjsify/sab-native: the native backend is not available on this platform. Cross-process SharedBuffer is currently Linux-only (memfd_create + futex + SCM_RIGHTS); prebuilds ship for linux-{x64,arm64,ppc64,s390x,riscv64} only — macOS support is planned and Windows is unsupported (see docs/adr/0013-sab-native-platform-scope.md). Guard with hasNativeSab() before using SharedBuffer. On Linux, a missing prebuild can be built locally with `gjsify workspace @gjsify/sab-native build:prebuilds`.";var i=class SharedBuffer{_native;constructor(e){this._native=e}static create(e){if(!t)throw Error(r);if(!Number.isInteger(e)||e<=0)throw TypeError(`SharedBuffer.create: size must be a positive integer`);let n=t.SharedBuffer.create(e);if(!n)throw Error(`memfd_create or mmap failed`);return new SharedBuffer(n)}static fromFd(e,n){if(!t)throw Error(r);if(!Number.isInteger(e)||e<0)throw TypeError(`SharedBuffer.fromFd: fd must be a non-negative integer`);if(!Number.isInteger(n)||n<=0)throw TypeError(`SharedBuffer.fromFd: size must be a positive integer`);let i=t.SharedBuffer.from_fd(e,n);if(!i)throw Error(`mmap failed`);return new SharedBuffer(i)}get byteLength(){return this._assertOpen().byte_length}get fd(){return this._assertOpen().fd}get closed(){return this._native===null}close(){this._native=null}getUint8(e){return this._assertOpen().get_u8(e)}setUint8(e,t){this._assertOpen().set_u8(e,t&255)}getUint32LE(e){return this._assertOpen().get_u32_le(e)}setUint32LE(e,t){this._assertOpen().set_u32_le(e,t>>>0)}getInt32LE(e){return this._assertOpen().get_i32_le(e)}setInt32LE(e,t){this._assertOpen().set_i32_le(e,t|0)}getBigUint64LE(e){return this._assertOpen().get_u64_le(e)}setBigUint64LE(e,t){this._assertOpen().set_u64_le(e,t)}readBytes(t,n){let r=this._assertOpen().read_bytes(t,n),i=e.imports?.byteArray;if(i&&typeof i.fromGBytes==`function`){let e=i.fromGBytes(r);return new Uint8Array(e)}return new Uint8Array(r.toArray())}viewBytes(e,t){return this.readBytes(e,t)}toBuffer(t=0,n){let r=n??this.byteLength-t,i=this.viewBytes(t,r),a=e.Buffer;if(typeof a?.from!=`function`)throw Error(`SharedBuffer.toBuffer: globalThis.Buffer is not registered. Import "@gjsify/buffer/register" or rely on --globals auto.`);return a.from(i.buffer,i.byteOffset,i.byteLength)}writeBytes(t,n){let r=e.imports?.byteArray,i;if(r&&typeof r.toGBytes==`function`)i=r.toGBytes(n);else{let t=e.imports?.gi?.GLib;i=t?.Bytes?new t.Bytes(n):n}this._assertOpen().write_bytes(t,i)}get _nativeHandle(){return this._assertOpen()}_assertOpen(){if(!this._native)throw Error(`SharedBuffer has been closed`);return this._native}};const a={add32(e,t,n){return e._nativeHandle.atomic_add_i32(t,n|0)},sub32(e,t,n){return e._nativeHandle.atomic_sub_i32(t,n|0)},load32(e,t){return e._nativeHandle.atomic_load_i32(t)},store32(e,t,n){e._nativeHandle.atomic_store_i32(t,n|0)},exchange32(e,t,n){return e._nativeHandle.atomic_xchg_i32(t,n|0)},compareExchange32(e,t,n,r){return e._nativeHandle.atomic_cmpxchg_i32(t,n|0,r|0)},wait32(e,t,n,r){let i=e._nativeHandle.futex_wait(t,n|0,r|0);if(i===0)return`ok`;if(i===-1)return`not-equal`;if(i===-2)return`timed-out`;if(i===-3)return`interrupted`;throw Error(`futex_wait returned errno ${-i}`)},notify32(e,t,n){return e._nativeHandle.futex_wake(t,n|0)}},o=t?{makePair(){let[e,n,r]=t.FdChannel.make_pair();if(!e)throw Error(`socketpair() failed`);return{parentFd:n,childFd:r}},sendFd(e,n,r){return t.FdChannel.send_fd(e,n,r>>>0)},recvFd(e){let[n,r]=t.FdChannel.recv_fd(e);if(n===0)return null;if(n<0)throw Error(`recvmsg failed`);return{fd:n,tag:r>>>0}},closeFd(e){t.FdChannel.close_fd(e)}}:null;export{r as NATIVE_SAB_UNAVAILABLE,i as SharedBuffer,a as atomics,o as fdChannel,hasNativeSab,n as nativeSab,resolveNativeSab};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/sab-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "Optional Vala/GObject bridge providing cross-process shared memory + atomics for @gjsify/worker_threads. Wraps Linux memfd_create(2) + mmap(MAP_SHARED) to back JS-visible SharedBuffer regions whose fds can be passed to child workers via SCM_RIGHTS over a Unix-domain socket; exposes typed accessors (getInt32LE / setUint8 / etc.) plus atomics built on __atomic_* GCC builtins and SYS_futex for wait/notify. Workaround for the stock-GJS gap where SharedArrayBuffer is unavailable (Mozilla disables the SAB constructor without COOP/COEP opts) and SAB cannot share backing stores across Gio.Subprocess workers anyway.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/esm/index.js",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
],
|
|
21
21
|
"gjsify": {
|
|
22
22
|
"platforms": [
|
|
23
|
-
"linux-
|
|
24
|
-
"linux-
|
|
23
|
+
"linux-x64",
|
|
24
|
+
"linux-arm64",
|
|
25
25
|
"linux-ppc64",
|
|
26
26
|
"linux-s390x",
|
|
27
27
|
"linux-riscv64"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"build:meson": "gjsify run init:meson && meson compile -C build",
|
|
46
46
|
"build:types": "gjsify tsc",
|
|
47
47
|
"build:prebuilds": "gjsify run build:meson && node ../../../scripts/stage-prebuild.mjs .",
|
|
48
|
-
"build:gir-types": "ts-for-gir generate --externalDeps --allowMissingDeps --girDirectories=./prebuilds/linux-
|
|
48
|
+
"build:gir-types": "ts-for-gir generate --externalDeps --allowMissingDeps --girDirectories=./prebuilds/linux-x64 --girDirectories=/usr/share/gir-1.0 --modules=GjsifySabNative-1.0 --outdir=src/ts --npmScope=@girs --package=false --ignoreVersionConflicts=true",
|
|
49
49
|
"build:test": "gjsify run build:test:gjs",
|
|
50
50
|
"build:test:gjs": "gjsify build src/ts/test.mts --app gjs --outfile test.gjs.mjs",
|
|
51
51
|
"test": "gjsify run build:gjsify && gjsify run build:test && gjsify run test:gjs",
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
"@girs/gio-2.0": "^4.1.0"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@gjsify/cli": "^0.
|
|
74
|
-
"@gjsify/unit": "^0.
|
|
73
|
+
"@gjsify/cli": "^0.24.1",
|
|
74
|
+
"@gjsify/unit": "^0.24.1",
|
|
75
75
|
"@ts-for-gir/cli": "^4.1.0",
|
|
76
76
|
"@types/node": "^25.9.2",
|
|
77
77
|
"typescript": "^6.0.3"
|
|
index 66f2899..0c1cdce 100644
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
index d073cc5..61ee30b 100755
|
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|