@iwsdk/vite-plugin-dev 1.2.0-rc.1 → 1.2.0-rc.2

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 CHANGED
@@ -53,7 +53,9 @@ iwsdkDev({
53
53
  // RegExp - custom hostname pattern
54
54
  activation: 'localhost',
55
55
 
56
- // Inject during production build (not just dev)
56
+ // Inject during production build (not just dev). Never applies to native
57
+ // builds (`vite build --mode metavr` or IWSDK_BUILD_TARGET=metavr, used by
58
+ // the alpha `npm run build:metavr` with @iwer/native): those get no emulator.
57
59
  injectOnBuild: false, // default
58
60
 
59
61
  // User-Agent pattern to skip (avoids injection on real XR browsers)
package/dist/index.js CHANGED
@@ -27193,6 +27193,45 @@ function reportSessionEnd(sessionId, opts) {
27193
27193
  metaVrTelemetry(args, opts?.clientVersion, true);
27194
27194
  }
27195
27195
 
27196
+ /**
27197
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
27198
+ *
27199
+ * This source code is licensed under the MIT license found in the
27200
+ * LICENSE file in the root directory of this source tree.
27201
+ */
27202
+ /**
27203
+ * Vite mode of a native (metavr) build: `vite build --mode metavr`, which the
27204
+ * `build:metavr` script of projects created with `--metavr-native` runs before
27205
+ * `iwer-native pack`. Alpha: the @iwer/native runtime is an opt-in preview.
27206
+ */
27207
+ const METAVR_BUILD_MODE = 'metavr';
27208
+ /** Environment switch for wrappers that cannot pass a Vite mode (`iwsdk build --target metavr`). */
27209
+ const BUILD_TARGET_ENV = 'IWSDK_BUILD_TARGET';
27210
+ /**
27211
+ * True for a production build that @iwer/native packs into an APK. Such a build
27212
+ * must not carry the IWER emulator: the native runtime provides WebXR itself
27213
+ * (IWER host mode), and an injected emulator would take over navigator.xr.
27214
+ * `dev.emulator.injectOnBuild` keeps applying to browser builds.
27215
+ */
27216
+ function isNativeTargetBuild(command, mode, env = process.env) {
27217
+ if (command !== 'build') {
27218
+ return false;
27219
+ }
27220
+ return mode === METAVR_BUILD_MODE || env[BUILD_TARGET_ENV] === 'metavr';
27221
+ }
27222
+ /**
27223
+ * The manifest as the browser bundle sees it. The `native` section configures
27224
+ * packaging (package id, signing keystore path, env-var names) and is read by
27225
+ * @iwer/native at pack time, so it stays out of the shipped JavaScript.
27226
+ */
27227
+ function runtimeProjectManifest(manifest) {
27228
+ if (!('native' in manifest)) {
27229
+ return manifest;
27230
+ }
27231
+ const { native: _native, ...runtime } = manifest;
27232
+ return runtime;
27233
+ }
27234
+
27196
27235
  /**
27197
27236
  * Copyright (c) Meta Platforms, Inc. and affiliates.
27198
27237
  *
@@ -58102,6 +58141,10 @@ function applyShadow(light, spec) {
58102
58141
  * Owns one Three.js light and keeps runtime and managed-editor materialization identical.
58103
58142
  */
58104
58143
  class LightBinding {
58144
+ /**
58145
+ * @param targetRoot - No longer used: the target hangs from the light (see
58146
+ * {@link LightBinding.target}). Kept so existing callers still compile.
58147
+ */
58105
58148
  constructor(parent, targetRoot, spec) {
58106
58149
  this.parent = parent;
58107
58150
  this.targetRoot = targetRoot;
@@ -58110,7 +58153,6 @@ class LightBinding {
58110
58153
  this.localMatrix = new Matrix4();
58111
58154
  this.worldPosition = new Vector3();
58112
58155
  this.worldQuaternion = new Quaternion();
58113
- this.worldDirection = new Vector3();
58114
58156
  this.disposed = false;
58115
58157
  this.specSignature = '';
58116
58158
  this.light = createLight(spec);
@@ -58125,7 +58167,8 @@ class LightBinding {
58125
58167
  target.userData.iwsdkLightTarget = true;
58126
58168
  target.userData.iwsdkRuntimeOnly = true;
58127
58169
  copySceneIdentity(parent, target);
58128
- targetRoot.add(target);
58170
+ target.position.copy(LOCAL_FORWARD);
58171
+ this.light.add(target);
58129
58172
  this.target = target;
58130
58173
  this.light.target = target;
58131
58174
  }
@@ -58217,12 +58260,9 @@ class LightBinding {
58217
58260
  this.light.matrix.copy(this.localMatrix);
58218
58261
  this.light.matrixWorld.copy(this.desiredWorldMatrix);
58219
58262
  if (this.target != null) {
58220
- this.worldDirection
58221
- .copy(LOCAL_FORWARD)
58222
- .applyQuaternion(this.worldQuaternion);
58223
- this.target.position.copy(this.worldPosition).add(this.worldDirection);
58224
- if (this.target.parent !== this.targetRoot) {
58225
- this.targetRoot.add(this.target);
58263
+ this.target.position.copy(LOCAL_FORWARD);
58264
+ if (this.target.parent !== this.light) {
58265
+ this.light.add(this.target);
58226
58266
  }
58227
58267
  this.target.updateMatrixWorld(true);
58228
58268
  }
@@ -60182,13 +60222,18 @@ function createProjectVirtualModuleSource(manifest, nativeXRControl = false) {
60182
60222
  `export default projectOptions;`,
60183
60223
  ].join('\n');
60184
60224
  }
60185
- function shouldInjectRuntime(command, options) {
60225
+ function shouldInjectRuntime(command, options, nativeTarget = false) {
60186
60226
  if (command === 'build' && options.nativeXRControl) {
60187
60227
  throw new Error('[IWSDK] Native XR control is a development-session capability and cannot be injected into a production build.');
60188
60228
  }
60189
60229
  if (command === 'serve') {
60190
60230
  return options.iwer !== false || options.workspace != null;
60191
60231
  }
60232
+ // Native (metavr) builds are packed by @iwer/native, whose runtime provides
60233
+ // WebXR itself: never inject the emulator, whatever injectOnBuild says.
60234
+ if (nativeTarget) {
60235
+ return false;
60236
+ }
60192
60237
  // The managed editor is a development-server capability. Production builds
60193
60238
  // include only explicitly requested IWER emulation, never the workspace
60194
60239
  // bridge merely because a project manifest exists.
@@ -62384,7 +62429,7 @@ if (import.meta.hot) {
62384
62429
  if (loadedProject == null) {
62385
62430
  throw new Error('[IWSDK] virtual:iwsdk-project requires iwsdk.config.json at the Vite project root.');
62386
62431
  }
62387
- return createProjectVirtualModuleSource(loadedProject.manifest, pluginOptions.nativeXRControl);
62432
+ return createProjectVirtualModuleSource(runtimeProjectManifest(loadedProject.manifest), pluginOptions.nativeXRControl);
62388
62433
  }
62389
62434
  if (id === RESOLVED_EDITOR_STYLESHEET_ID) {
62390
62435
  return EDITOR_SHELL_CSS;
@@ -62469,10 +62514,14 @@ if (import.meta.hot) {
62469
62514
  // Development always builds the managed-workspace bridge, even when
62470
62515
  // IWER is disabled. Production builds include only explicitly enabled
62471
62516
  // IWER emulation; the editor bridge is never a production side effect.
62472
- const shouldInject = shouldInjectRuntime(config.command, pluginOptions);
62517
+ const shouldInject = shouldInjectRuntime(config.command, pluginOptions, isNativeTargetBuild(config.command, config.mode));
62473
62518
  if (!shouldInject) {
62474
62519
  if (pluginOptions.verbose) {
62475
- if (config.command === 'build' && pluginOptions.iwer === false) {
62520
+ if (isNativeTargetBuild(config.command, config.mode)) {
62521
+ console.log('⏭️ IWSDK Dev: Skipping build injection (metavr native build)');
62522
+ }
62523
+ else if (config.command === 'build' &&
62524
+ pluginOptions.iwer === false) {
62476
62525
  console.log('⏭️ IWSDK Dev: Skipping build injection (IWER disabled)');
62477
62526
  }
62478
62527
  else if (config.command === 'build') {
@@ -62499,7 +62548,7 @@ if (import.meta.hot) {
62499
62548
  order: 'pre', // Run before other HTML transformations
62500
62549
  handler(html) {
62501
62550
  // Check if the IWER runtime or managed-workspace bridge should load.
62502
- const shouldInject = shouldInjectRuntime(config.command, pluginOptions);
62551
+ const shouldInject = shouldInjectRuntime(config.command, pluginOptions, isNativeTargetBuild(config.command, config.mode));
62503
62552
  if (!shouldInject || !injectionBundle) {
62504
62553
  return html;
62505
62554
  }
@@ -62523,7 +62572,7 @@ if (import.meta.hot) {
62523
62572
  order: 'post',
62524
62573
  async handler() {
62525
62574
  // Only show summary when the runtime/workspace bundle actually loaded.
62526
- const shouldInject = shouldInjectRuntime(config.command, pluginOptions);
62575
+ const shouldInject = shouldInjectRuntime(config.command, pluginOptions, isNativeTargetBuild(config.command, config.mode));
62527
62576
  if (shouldInject && injectionBundle) {
62528
62577
  const mode = config.command === 'serve' ? 'Development' : 'Build';
62529
62578
  console.log(`\n🥽 IWSDK Dev Summary (${mode}):`);