@covas-labs/electron-vr 0.8.0 → 0.8.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/dist/bridge.d.ts CHANGED
@@ -103,6 +103,15 @@ export interface NativeImageLike {
103
103
  export interface AttachWindowOptions {
104
104
  frameRate?: number;
105
105
  }
106
+ export interface NativeOpenXRApiLayerStatus {
107
+ installed: boolean;
108
+ enabled: boolean;
109
+ registered: boolean;
110
+ requiresUpdate: boolean;
111
+ manifestPath: string;
112
+ scope: string;
113
+ }
114
+ export declare function runNativeOpenXRApiLayerCommand(command: "status" | "install" | "enable" | "disable" | "uninstall", sourceDirectory: string): NativeOpenXRApiLayerStatus;
106
115
  export declare class VrBridge {
107
116
  private readonly addon;
108
117
  private attachedWindow;
package/dist/bridge.js CHANGED
@@ -105,6 +105,21 @@ function loadVrBridgeAddon() {
105
105
  }
106
106
  }
107
107
  }
108
+ export function runNativeOpenXRApiLayerCommand(command, sourceDirectory) {
109
+ const addon = loadVrBridgeAddon();
110
+ const method = command === "status"
111
+ ? addon.getOpenXRApiLayerStatus
112
+ : command === "install"
113
+ ? addon.installOpenXRApiLayer
114
+ : command === "enable"
115
+ ? addon.enableOpenXRApiLayer
116
+ : command === "disable"
117
+ ? addon.disableOpenXRApiLayer
118
+ : addon.uninstallOpenXRApiLayer;
119
+ if (!method)
120
+ throw new Error("The native OpenXR API-layer management API is unavailable.");
121
+ return method.call(addon, sourceDirectory);
122
+ }
108
123
  function sanitizeRuntimeInfo(runtimeInfo) {
109
124
  return {
110
125
  ...runtimeInfo,
@@ -3,6 +3,7 @@ import { createRequire } from "node:module";
3
3
  import { existsSync } from "node:fs";
4
4
  import { dirname, resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { runNativeOpenXRApiLayerCommand } from "./bridge.js";
6
7
  const PREBUILT_PACKAGES = {
7
8
  linux: "@covas-labs/electron-vr-prebuilt-linux-x64",
8
9
  win32: "@covas-labs/electron-vr-prebuilt-win32-x64"
@@ -33,6 +34,24 @@ function resolvePrebuiltCli() {
33
34
  }
34
35
  return null;
35
36
  }
37
+ function resolveWindowsLayerAssets() {
38
+ const currentDir = dirname(fileURLToPath(import.meta.url));
39
+ const repositoryAssets = resolve(currentDir, "..", "..", "native-addon", "build", "Release");
40
+ if (existsSync(resolve(repositoryAssets, "electron_vr_openxr_layer.dll")))
41
+ return repositoryAssets;
42
+ const requires = [createRequire(import.meta.url), createRequire(resolve(process.cwd(), "package.json"))];
43
+ for (const require of requires) {
44
+ try {
45
+ const directory = dirname(require.resolve(PREBUILT_PACKAGES.win32));
46
+ if (existsSync(resolve(directory, "electron_vr_openxr_layer.dll")))
47
+ return directory;
48
+ }
49
+ catch {
50
+ // Try the next package resolution context.
51
+ }
52
+ }
53
+ throw new Error("The Windows OpenXR API-layer assets are unavailable.");
54
+ }
36
55
  function resolveCli() {
37
56
  assertSupportedPlatform();
38
57
  const currentDir = dirname(fileURLToPath(import.meta.url));
@@ -91,9 +110,15 @@ export function parseOpenXRApiLayerStatus(output) {
91
110
  };
92
111
  }
93
112
  export async function getOpenXRApiLayerStatus() {
113
+ if (process.platform === "win32") {
114
+ return runNativeOpenXRApiLayerCommand("status", resolveWindowsLayerAssets());
115
+ }
94
116
  return parseOpenXRApiLayerStatus(await runCommand("status"));
95
117
  }
96
118
  async function runLifecycleCommand(command) {
119
+ if (process.platform === "win32") {
120
+ return runNativeOpenXRApiLayerCommand(command, resolveWindowsLayerAssets());
121
+ }
97
122
  await runCommand(command);
98
123
  return getOpenXRApiLayerStatus();
99
124
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@covas-labs/electron-vr",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "description": "Electron VR overlay bridge with OpenXR, OpenVR, and mock fallback backends.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,8 +22,8 @@
22
22
  "electron": ">=37"
23
23
  },
24
24
  "optionalDependencies": {
25
- "@covas-labs/electron-vr-prebuilt-linux-x64": "0.8.0",
26
- "@covas-labs/electron-vr-prebuilt-win32-x64": "0.8.0"
25
+ "@covas-labs/electron-vr-prebuilt-linux-x64": "0.8.1",
26
+ "@covas-labs/electron-vr-prebuilt-win32-x64": "0.8.1"
27
27
  },
28
28
  "publishConfig": {
29
29
  "registry": "https://registry.npmjs.org",