@napolab/texture-bridge-core 0.2.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/dist/index.cjs +29 -0
- package/dist/index.d.cts +40 -0
- package/dist/index.d.mts +40 -0
- package/dist/index.mjs +26 -0
- package/package.json +42 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
let _napolab_texture_bridge = require("@napolab/texture-bridge");
|
|
3
|
+
|
|
4
|
+
//#region src/index.ts
|
|
5
|
+
/**
|
|
6
|
+
* Send a texture from an Electron paint event to Syphon/Spout.
|
|
7
|
+
*
|
|
8
|
+
* Handles platform detection and buffer extraction automatically.
|
|
9
|
+
*/
|
|
10
|
+
function sendTextureFromPaintEvent(sender, textureInfo) {
|
|
11
|
+
const { handle, codedSize } = textureInfo;
|
|
12
|
+
if (process.platform === "win32") {
|
|
13
|
+
const ntHandle = handle.ntHandle;
|
|
14
|
+
if (!ntHandle || !Buffer.isBuffer(ntHandle)) return;
|
|
15
|
+
const handleValue = Number(ntHandle.readBigInt64LE(0));
|
|
16
|
+
sender.send(handleValue, codedSize.width, codedSize.height);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (process.platform === "darwin") {
|
|
20
|
+
const ioSurface = handle.ioSurface;
|
|
21
|
+
if (!ioSurface) return;
|
|
22
|
+
sender.sendSurface(ioSurface, codedSize.width, codedSize.height);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//#endregion
|
|
27
|
+
exports.TextureSender = _napolab_texture_bridge.TextureSender;
|
|
28
|
+
exports.getPlatform = _napolab_texture_bridge.getPlatform;
|
|
29
|
+
exports.sendTextureFromPaintEvent = sendTextureFromPaintEvent;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TextureSender, getPlatform } from "@napolab/texture-bridge";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/** Supported pixel formats for shared textures */
|
|
5
|
+
type PixelFormat = "bgra" | "nv12" | "rgba" | "rgbaf16";
|
|
6
|
+
/** Electron paint event texture info */
|
|
7
|
+
interface TextureInfo {
|
|
8
|
+
pixelFormat: PixelFormat;
|
|
9
|
+
codedSize: {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
visibleRect: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
handle: {
|
|
20
|
+
ntHandle?: Buffer;
|
|
21
|
+
ioSurface?: Buffer;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Electron paint event texture with release callback */
|
|
25
|
+
interface PaintTexture {
|
|
26
|
+
textureInfo: TextureInfo;
|
|
27
|
+
release?: () => void;
|
|
28
|
+
}
|
|
29
|
+
/** Platform-specific texture sharing protocol */
|
|
30
|
+
type Platform = "spout" | "syphon-metal" | "unsupported";
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/index.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Send a texture from an Electron paint event to Syphon/Spout.
|
|
35
|
+
*
|
|
36
|
+
* Handles platform detection and buffer extraction automatically.
|
|
37
|
+
*/
|
|
38
|
+
declare function sendTextureFromPaintEvent(sender: InstanceType<typeof TextureSender>, textureInfo: TextureInfo): void;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { type PaintTexture, type PixelFormat, type Platform, type TextureInfo, TextureSender, getPlatform, sendTextureFromPaintEvent };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { TextureSender, getPlatform } from "@napolab/texture-bridge";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
/** Supported pixel formats for shared textures */
|
|
5
|
+
type PixelFormat = "bgra" | "nv12" | "rgba" | "rgbaf16";
|
|
6
|
+
/** Electron paint event texture info */
|
|
7
|
+
interface TextureInfo {
|
|
8
|
+
pixelFormat: PixelFormat;
|
|
9
|
+
codedSize: {
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
};
|
|
13
|
+
visibleRect: {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
width: number;
|
|
17
|
+
height: number;
|
|
18
|
+
};
|
|
19
|
+
handle: {
|
|
20
|
+
ntHandle?: Buffer;
|
|
21
|
+
ioSurface?: Buffer;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Electron paint event texture with release callback */
|
|
25
|
+
interface PaintTexture {
|
|
26
|
+
textureInfo: TextureInfo;
|
|
27
|
+
release?: () => void;
|
|
28
|
+
}
|
|
29
|
+
/** Platform-specific texture sharing protocol */
|
|
30
|
+
type Platform = "spout" | "syphon-metal" | "unsupported";
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region src/index.d.ts
|
|
33
|
+
/**
|
|
34
|
+
* Send a texture from an Electron paint event to Syphon/Spout.
|
|
35
|
+
*
|
|
36
|
+
* Handles platform detection and buffer extraction automatically.
|
|
37
|
+
*/
|
|
38
|
+
declare function sendTextureFromPaintEvent(sender: InstanceType<typeof TextureSender>, textureInfo: TextureInfo): void;
|
|
39
|
+
//#endregion
|
|
40
|
+
export { type PaintTexture, type PixelFormat, type Platform, type TextureInfo, TextureSender, getPlatform, sendTextureFromPaintEvent };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { TextureSender, getPlatform } from "@napolab/texture-bridge";
|
|
2
|
+
|
|
3
|
+
//#region src/index.ts
|
|
4
|
+
/**
|
|
5
|
+
* Send a texture from an Electron paint event to Syphon/Spout.
|
|
6
|
+
*
|
|
7
|
+
* Handles platform detection and buffer extraction automatically.
|
|
8
|
+
*/
|
|
9
|
+
function sendTextureFromPaintEvent(sender, textureInfo) {
|
|
10
|
+
const { handle, codedSize } = textureInfo;
|
|
11
|
+
if (process.platform === "win32") {
|
|
12
|
+
const ntHandle = handle.ntHandle;
|
|
13
|
+
if (!ntHandle || !Buffer.isBuffer(ntHandle)) return;
|
|
14
|
+
const handleValue = Number(ntHandle.readBigInt64LE(0));
|
|
15
|
+
sender.send(handleValue, codedSize.width, codedSize.height);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (process.platform === "darwin") {
|
|
19
|
+
const ioSurface = handle.ioSurface;
|
|
20
|
+
if (!ioSurface) return;
|
|
21
|
+
sender.sendSurface(ioSurface, codedSize.width, codedSize.height);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { TextureSender, getPlatform, sendTextureFromPaintEvent };
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@napolab/texture-bridge-core",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "High-level GPU texture sharing for Electron (Spout + Syphon Metal)",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.cts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.mjs",
|
|
11
|
+
"require": "./dist/index.cjs"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@napolab/texture-bridge": "0.2.0"
|
|
17
|
+
},
|
|
18
|
+
"peerDependencies": {
|
|
19
|
+
"electron": ">=40.0.0"
|
|
20
|
+
},
|
|
21
|
+
"peerDependenciesMeta": {
|
|
22
|
+
"electron": {
|
|
23
|
+
"optional": true
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/node": "^22.0.0",
|
|
28
|
+
"tsdown": "^0.20.3",
|
|
29
|
+
"typescript": "^5.7.0"
|
|
30
|
+
},
|
|
31
|
+
"license": "MIT",
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist"
|
|
37
|
+
],
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "tsdown src/index.ts --format cjs,esm --dts --exports",
|
|
40
|
+
"typecheck": "tsgo --noEmit"
|
|
41
|
+
}
|
|
42
|
+
}
|