@iwsdk/vite-plugin-dev 1.1.0-rc.0 → 1.1.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 +4 -3
- package/dist/bundle-feature-gates.d.ts +12 -0
- package/dist/editor/editor-workspace.d.ts +3 -0
- package/dist/editor/editor-workspace.js +55 -1
- package/dist/editor/editor-workspace.js.map +1 -1
- package/dist/editor/scene-editor-session.js +1 -1
- package/dist/index.js +1346 -140
- package/dist/index.js.map +1 -1
- package/dist/injection/chunks/{index-C3rlN7Lf.js → index-CMmj0avE.js} +1 -1
- package/dist/injection/chunks/{injection-template-9pnR-F15.js → injection-template-0HSd4CcE.js} +65 -65
- package/dist/injection/runtime.js +1 -1
- package/dist/managed-browser/session.d.ts +5 -1
- package/dist/managed-browser/tab-audio.d.ts +33 -0
- package/dist/mcp/ws-client.d.ts +16 -0
- package/dist/{patch-D24zp5ky.js → patch-4HakknH4.js} +14 -1
- package/dist/patch-4HakknH4.js.map +1 -0
- package/dist/runtime-session.d.ts +2 -0
- package/dist/types.d.ts +7 -0
- package/package.json +7 -7
- package/dist/patch-D24zp5ky.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash, randomUUID } from 'crypto';
|
|
1
|
+
import { createHash, randomUUID, randomBytes, timingSafeEqual } from 'crypto';
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import { existsSync, realpathSync, readFileSync, mkdirSync, writeFileSync, renameSync, unlinkSync, linkSync, rmdirSync, rmSync, readdirSync, statSync, lstatSync as lstatSync$1 } from 'fs';
|
|
4
4
|
import * as os from 'os';
|
|
@@ -10,7 +10,7 @@ import { mkdir, lstat, mkdtemp, writeFile, readdir, rename, unlink, rmdir, rm, r
|
|
|
10
10
|
import { createServer, createConnection } from 'net';
|
|
11
11
|
import { execFileSync, spawn } from 'child_process';
|
|
12
12
|
import { assertValidIwsdkProjectManifest, normalizeProjectSourcePath, resolveProjectEmulatorRoom, PROJECT_EMULATOR_ROOMS, normalizeProjectDevOptions } from '@iwsdk/core/project';
|
|
13
|
-
import { m as findNode, n as getNodeWorldBounds, o as getScenePatternRequestedCount, p as resolveScenePrefabRoot, q as getSceneNodeCollisionRadius, t as MAX_SCENE_PATTERN_INSTANCES, u as getScenePatternInstanceCount, s as sha256, c as canonicalizeJson, w as deepClone, a as assertValidSceneDocument, x as isPlainObject, y as SCENE_IMPORT_ID_PATTERN, z as validateSceneReview, v as validateSceneDocument, h as hashSceneDocument, b as hashRuntimeSceneDocument, A as getSceneCompositionSourceHashes, i as applyScenePatch, B as parseSceneDocument, j as serializeSceneDocument, D as serializeSceneReview, E as resolveSceneAuthoringTransforms, F as parseSceneReview } from './patch-
|
|
13
|
+
import { m as findNode, n as getNodeWorldBounds, o as getScenePatternRequestedCount, p as resolveScenePrefabRoot, q as getSceneNodeCollisionRadius, t as MAX_SCENE_PATTERN_INSTANCES, u as getScenePatternInstanceCount, s as sha256, c as canonicalizeJson, w as deepClone, a as assertValidSceneDocument, x as isPlainObject, y as SCENE_IMPORT_ID_PATTERN, z as validateSceneReview, v as validateSceneDocument, h as hashSceneDocument, b as hashRuntimeSceneDocument, A as getSceneCompositionSourceHashes, i as applyScenePatch, B as parseSceneDocument, j as serializeSceneDocument, D as serializeSceneReview, E as resolveSceneAuthoringTransforms, F as parseSceneReview } from './patch-4HakknH4.js';
|
|
14
14
|
import { getCertificate } from '@vitejs/plugin-basic-ssl';
|
|
15
15
|
import process$1 from 'node:process';
|
|
16
16
|
import { Buffer as Buffer$1 } from 'node:buffer';
|
|
@@ -23,7 +23,7 @@ import os$1 from 'node:os';
|
|
|
23
23
|
import fs$1, { readFileSync as readFileSync$1, existsSync as existsSync$1, realpathSync as realpathSync$1, lstatSync } from 'node:fs';
|
|
24
24
|
import { loadEnv, searchForWorkspaceRoot } from 'vite';
|
|
25
25
|
import { WebSocketServer, WebSocket } from 'ws';
|
|
26
|
-
import { parse, resolveKitComponentSets } from '@drawcall/uikitml';
|
|
26
|
+
import { lucideComponentSet, parse, resolveKitComponentSets } from '@drawcall/uikitml';
|
|
27
27
|
import { fileURLToPath as fileURLToPath$1 } from 'url';
|
|
28
28
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
29
29
|
import sharp from 'sharp';
|
|
@@ -1134,26 +1134,54 @@ const DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS = 30_000;
|
|
|
1134
1134
|
const UI_RENDER_PREVIEW_TIMEOUT_MS = 60_000;
|
|
1135
1135
|
const ASSET_RENDER_PREVIEW_TIMEOUT_MS = 120_000;
|
|
1136
1136
|
const BROWSER_RUNTIME_COMMAND_TIMEOUT_MS = 60_000;
|
|
1137
|
+
/**
|
|
1138
|
+
* IWER resolves a running hand sequence at most 28 s after dispatch, with a
|
|
1139
|
+
* partial result when it runs out of time. The default budget, less the
|
|
1140
|
+
* relay's margin, would give up first.
|
|
1141
|
+
*/
|
|
1142
|
+
const HAND_SEQUENCE_COMMAND_TIMEOUT_MS = 40_000;
|
|
1143
|
+
/** The longest `duration` (seconds) that extends a default command timeout. */
|
|
1144
|
+
const MAX_TIMED_COMMAND_DURATION_S = 3_600;
|
|
1145
|
+
/** IWER replies to these only once their `duration` (seconds) has elapsed. */
|
|
1146
|
+
const TIMED_RUNTIME_METHODS = new Set([
|
|
1147
|
+
'animate_to',
|
|
1148
|
+
'select',
|
|
1149
|
+
'set_hand_pose',
|
|
1150
|
+
'set_select_value',
|
|
1151
|
+
]);
|
|
1137
1152
|
const BROWSER_RUNTIME_METHODS = new Set([
|
|
1138
1153
|
'browser_interact',
|
|
1139
1154
|
'browser_profile',
|
|
1155
|
+
'browser_set_muted',
|
|
1140
1156
|
'browser_snapshot',
|
|
1141
1157
|
'get_console_logs',
|
|
1142
1158
|
'reload_page',
|
|
1143
1159
|
'screenshot',
|
|
1144
1160
|
]);
|
|
1145
|
-
function getDefaultRuntimeCommandTimeoutMs(method) {
|
|
1161
|
+
function getDefaultRuntimeCommandTimeoutMs(method, params) {
|
|
1146
1162
|
if (method === 'asset_render_preview') {
|
|
1147
1163
|
return ASSET_RENDER_PREVIEW_TIMEOUT_MS;
|
|
1148
1164
|
}
|
|
1149
1165
|
if (method === 'ui_render_preview') {
|
|
1150
1166
|
return UI_RENDER_PREVIEW_TIMEOUT_MS;
|
|
1151
1167
|
}
|
|
1168
|
+
if (method === 'run_sequence') {
|
|
1169
|
+
return HAND_SEQUENCE_COMMAND_TIMEOUT_MS;
|
|
1170
|
+
}
|
|
1171
|
+
if (TIMED_RUNTIME_METHODS.has(method)) {
|
|
1172
|
+
// A long fade or ramp gets the default budget on top of its duration.
|
|
1173
|
+
const duration = params?.duration;
|
|
1174
|
+
return typeof duration === 'number' && duration > 0
|
|
1175
|
+
? DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS +
|
|
1176
|
+
Math.ceil(Math.min(duration, MAX_TIMED_COMMAND_DURATION_S) * 1000)
|
|
1177
|
+
: DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS;
|
|
1178
|
+
}
|
|
1152
1179
|
return BROWSER_RUNTIME_METHODS.has(method)
|
|
1153
1180
|
? BROWSER_RUNTIME_COMMAND_TIMEOUT_MS
|
|
1154
1181
|
: DEFAULT_RUNTIME_COMMAND_TIMEOUT_MS;
|
|
1155
1182
|
}
|
|
1156
1183
|
const IWSDK_RUNTIME_SESSION_PATH = '.iwsdk/runtime/session.json';
|
|
1184
|
+
const IWSDK_RUNTIME_COMMAND_CREDENTIAL_PATH = '.iwsdk/runtime/command-credential.json';
|
|
1157
1185
|
const IWSDK_RUNTIME_STATE_SCHEMA_VERSION = 2;
|
|
1158
1186
|
const INTERNAL_BROWSER_PROBE_METHOD = '__iwsdk_browser_probe';
|
|
1159
1187
|
const INTERNAL_RUNTIME_SHUTDOWN_METHOD = '__iwsdk_runtime_shutdown';
|
|
@@ -1465,6 +1493,364 @@ const SCENE_OBJECT_INSPECTION_ASSESSMENT_SCHEMA = {
|
|
|
1465
1493
|
},
|
|
1466
1494
|
required: ['id', 'status', 'evidenceRefs', 'observation'],
|
|
1467
1495
|
};
|
|
1496
|
+
// =============================================================================
|
|
1497
|
+
// Emulated device shapes
|
|
1498
|
+
// =============================================================================
|
|
1499
|
+
// The xr_* schemas mirror IWER's extension-bridge contract and its JSON Schema
|
|
1500
|
+
// catalog (`iwer/lib/remote/catalog.js`): the same parameters, unions and
|
|
1501
|
+
// descriptions. vite-plugin-dev's tests compare them with the catalog of the
|
|
1502
|
+
// IWER it installs.
|
|
1503
|
+
const XR_POSITION_SCHEMA = {
|
|
1504
|
+
type: 'object',
|
|
1505
|
+
description: 'A 3D position in metres, XR-origin relative.',
|
|
1506
|
+
properties: {
|
|
1507
|
+
x: { type: 'number' },
|
|
1508
|
+
y: { type: 'number' },
|
|
1509
|
+
z: { type: 'number' },
|
|
1510
|
+
},
|
|
1511
|
+
required: ['x', 'y', 'z'],
|
|
1512
|
+
};
|
|
1513
|
+
const XR_STRICT_POSITION_SCHEMA = {
|
|
1514
|
+
...XR_POSITION_SCHEMA,
|
|
1515
|
+
additionalProperties: false,
|
|
1516
|
+
};
|
|
1517
|
+
const XR_TUPLE3_SCHEMA = {
|
|
1518
|
+
type: 'array',
|
|
1519
|
+
items: { type: 'number' },
|
|
1520
|
+
minItems: 3,
|
|
1521
|
+
maxItems: 3,
|
|
1522
|
+
};
|
|
1523
|
+
const XR_QUATERNION_SCHEMA = {
|
|
1524
|
+
type: 'object',
|
|
1525
|
+
additionalProperties: false,
|
|
1526
|
+
properties: {
|
|
1527
|
+
x: { type: 'number', description: 'Quaternion X component' },
|
|
1528
|
+
y: { type: 'number', description: 'Quaternion Y component' },
|
|
1529
|
+
z: { type: 'number', description: 'Quaternion Z component' },
|
|
1530
|
+
w: { type: 'number', description: 'Quaternion W component' },
|
|
1531
|
+
},
|
|
1532
|
+
required: ['x', 'y', 'z', 'w'],
|
|
1533
|
+
};
|
|
1534
|
+
const XR_EULER_SCHEMA = {
|
|
1535
|
+
type: 'object',
|
|
1536
|
+
additionalProperties: false,
|
|
1537
|
+
properties: {
|
|
1538
|
+
pitch: { type: 'number', description: 'Pitch in degrees (X rotation)' },
|
|
1539
|
+
yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
|
|
1540
|
+
roll: { type: 'number', description: 'Roll in degrees (Z rotation)' },
|
|
1541
|
+
},
|
|
1542
|
+
};
|
|
1543
|
+
const XR_ORIENTATION_SCHEMA = {
|
|
1544
|
+
anyOf: [XR_QUATERNION_SCHEMA, XR_EULER_SCHEMA],
|
|
1545
|
+
description: 'Orientation as a quaternion {x,y,z,w} or euler degrees {pitch,yaw,roll}.',
|
|
1546
|
+
};
|
|
1547
|
+
const XR_DIRECTION_SCHEMA = {
|
|
1548
|
+
anyOf: [
|
|
1549
|
+
{
|
|
1550
|
+
type: 'string',
|
|
1551
|
+
enum: [
|
|
1552
|
+
'up',
|
|
1553
|
+
'down',
|
|
1554
|
+
'forward',
|
|
1555
|
+
'back',
|
|
1556
|
+
'left',
|
|
1557
|
+
'right',
|
|
1558
|
+
'toward-head',
|
|
1559
|
+
'away-from-head',
|
|
1560
|
+
],
|
|
1561
|
+
},
|
|
1562
|
+
XR_STRICT_POSITION_SCHEMA,
|
|
1563
|
+
XR_TUPLE3_SCHEMA,
|
|
1564
|
+
],
|
|
1565
|
+
description: 'A direction: a name (up, down, forward, back, left, right, toward-head, away-from-head; forward/left/right follow where the headset faces) or an XR-origin vector (approximate is fine).',
|
|
1566
|
+
};
|
|
1567
|
+
// Hand directions come before quaternion/euler and every orientation object
|
|
1568
|
+
// is strict, so a misspelt hand direction is an error, not an empty euler.
|
|
1569
|
+
const XR_HAND_DIRECTIONS_SCHEMA = {
|
|
1570
|
+
type: 'object',
|
|
1571
|
+
additionalProperties: false,
|
|
1572
|
+
description: 'Hand orientation by direction: where the fingers point plus where the palm faces OR where the thumb side points. A thumbs up is {fingers:"forward", thumb:"up"}.',
|
|
1573
|
+
properties: {
|
|
1574
|
+
fingers: XR_DIRECTION_SCHEMA,
|
|
1575
|
+
palm: XR_DIRECTION_SCHEMA,
|
|
1576
|
+
thumb: XR_DIRECTION_SCHEMA,
|
|
1577
|
+
},
|
|
1578
|
+
required: ['fingers'],
|
|
1579
|
+
};
|
|
1580
|
+
const XR_PLACEMENT_ORIENTATION_SCHEMA = {
|
|
1581
|
+
anyOf: [
|
|
1582
|
+
{ type: 'string', enum: ['auto'] },
|
|
1583
|
+
XR_HAND_DIRECTIONS_SCHEMA,
|
|
1584
|
+
XR_QUATERNION_SCHEMA,
|
|
1585
|
+
XR_EULER_SCHEMA,
|
|
1586
|
+
],
|
|
1587
|
+
description: 'For hands: {fingers, palm|thumb} directions, or "auto" (a natural reach from the shoulder toward the position). A quaternion {x,y,z,w} or euler degrees {pitch,yaw,roll} sets the device (for hands, the target ray) as before.',
|
|
1588
|
+
};
|
|
1589
|
+
const XR_HAND_ANCHOR_SCHEMA = {
|
|
1590
|
+
type: 'string',
|
|
1591
|
+
description: 'Hands: the point of the hand `position` places and keeps there while the hand changes shape: index-tip (press), grasp (where thumb and index tips meet in a full pinch), wrist (gestures), grip, thumb-tip, target-ray (default), or a WebXR joint name.',
|
|
1592
|
+
};
|
|
1593
|
+
const XR_EASING_SCHEMA = {
|
|
1594
|
+
type: 'string',
|
|
1595
|
+
enum: ['linear', 'minimum-jerk'],
|
|
1596
|
+
description: 'Time curve; minimum-jerk starts and stops like a human reach.',
|
|
1597
|
+
};
|
|
1598
|
+
const XR_HAND_DEVICE_SCHEMA = {
|
|
1599
|
+
type: 'string',
|
|
1600
|
+
enum: ['hand-left', 'hand-right'],
|
|
1601
|
+
description: 'A hand-tracking device.',
|
|
1602
|
+
};
|
|
1603
|
+
// One short gloss per built-in IWER hand pose, for xr_set_hand_pose. Keep in
|
|
1604
|
+
// sync with IWER's BUILTIN_HAND_POSE_IDS (checked by vite-plugin-dev's tests).
|
|
1605
|
+
const XR_HAND_POSE_GLOSS = {
|
|
1606
|
+
default: 'relaxed',
|
|
1607
|
+
pinch: 'thumb and index touching',
|
|
1608
|
+
point: 'index extended',
|
|
1609
|
+
open: 'high five',
|
|
1610
|
+
flat: 'fingers together, blade',
|
|
1611
|
+
fist: 'closed fist',
|
|
1612
|
+
'thumbs-up': 'fist with thumb up',
|
|
1613
|
+
'finger-gun': 'index and thumb out',
|
|
1614
|
+
peace: 'V sign',
|
|
1615
|
+
three: 'index, middle, ring up',
|
|
1616
|
+
four: 'four fingers up, thumb folded',
|
|
1617
|
+
ok: 'thumb-index circle',
|
|
1618
|
+
rock: 'index and pinky out',
|
|
1619
|
+
call: 'thumb and pinky out',
|
|
1620
|
+
'pinch-middle': 'thumb to middle tip',
|
|
1621
|
+
'pinch-ring': 'thumb to ring tip',
|
|
1622
|
+
'pinch-pinky': 'thumb to pinky tip',
|
|
1623
|
+
tripod: 'thumb, index, middle tips together',
|
|
1624
|
+
'key-pinch': 'thumb against side of index',
|
|
1625
|
+
microgesture: 'loose curl, thumb by the side of the index',
|
|
1626
|
+
grip: 'wrapped around a handle',
|
|
1627
|
+
claw: 'holding a ball',
|
|
1628
|
+
hook: 'carrying a bag handle',
|
|
1629
|
+
cup: 'scooping water',
|
|
1630
|
+
};
|
|
1631
|
+
const XR_HAND_POSE_GLOSSES = Object.entries(XR_HAND_POSE_GLOSS)
|
|
1632
|
+
.map(([id, gloss]) => `${id} (${gloss})`)
|
|
1633
|
+
.join(', ');
|
|
1634
|
+
const XR_FINGER_POSE_SCHEMA = {
|
|
1635
|
+
anyOf: [
|
|
1636
|
+
{ type: 'string' },
|
|
1637
|
+
{
|
|
1638
|
+
type: 'object',
|
|
1639
|
+
additionalProperties: false,
|
|
1640
|
+
properties: {
|
|
1641
|
+
poseId: { type: 'string' },
|
|
1642
|
+
weight: { type: 'number', minimum: 0, maximum: 1 },
|
|
1643
|
+
},
|
|
1644
|
+
required: ['poseId'],
|
|
1645
|
+
},
|
|
1646
|
+
],
|
|
1647
|
+
description: 'A pose id, or {poseId, weight} where weight 0-1 blends from the base pose toward it.',
|
|
1648
|
+
};
|
|
1649
|
+
const XR_FINGER_POSES_SCHEMA = {
|
|
1650
|
+
type: 'object',
|
|
1651
|
+
additionalProperties: false,
|
|
1652
|
+
description: 'Fingers to take from other poses, on top of poseId.',
|
|
1653
|
+
properties: {
|
|
1654
|
+
thumb: XR_FINGER_POSE_SCHEMA,
|
|
1655
|
+
index: XR_FINGER_POSE_SCHEMA,
|
|
1656
|
+
middle: XR_FINGER_POSE_SCHEMA,
|
|
1657
|
+
ring: XR_FINGER_POSE_SCHEMA,
|
|
1658
|
+
pinky: XR_FINGER_POSE_SCHEMA,
|
|
1659
|
+
},
|
|
1660
|
+
};
|
|
1661
|
+
const XR_INPUT_STATE_SCHEMA = {
|
|
1662
|
+
type: 'object',
|
|
1663
|
+
additionalProperties: false,
|
|
1664
|
+
properties: {
|
|
1665
|
+
connected: { type: 'boolean' },
|
|
1666
|
+
position: XR_POSITION_SCHEMA,
|
|
1667
|
+
orientation: XR_ORIENTATION_SCHEMA,
|
|
1668
|
+
},
|
|
1669
|
+
};
|
|
1670
|
+
const XR_HAND_STATE_SCHEMA = {
|
|
1671
|
+
...XR_INPUT_STATE_SCHEMA,
|
|
1672
|
+
properties: {
|
|
1673
|
+
...XR_INPUT_STATE_SCHEMA.properties,
|
|
1674
|
+
poseId: { type: 'string' },
|
|
1675
|
+
pinchValue: { type: 'number', minimum: 0, maximum: 1 },
|
|
1676
|
+
},
|
|
1677
|
+
};
|
|
1678
|
+
const XR_MICROGESTURE_SCHEMA = {
|
|
1679
|
+
type: 'string',
|
|
1680
|
+
enum: ['swipe-left', 'swipe-right', 'swipe-forward', 'swipe-backward', 'tap'],
|
|
1681
|
+
description: "A thumb microgesture on the side of the curled index finger: swipe left / right (the user's), forward (over the finger), backward (toward the palm), or tap.",
|
|
1682
|
+
};
|
|
1683
|
+
// --- run_sequence ------------------------------------------------------------
|
|
1684
|
+
const XR_FRACTION_SCHEMA = {
|
|
1685
|
+
type: 'number',
|
|
1686
|
+
minimum: 0,
|
|
1687
|
+
maximum: 1,
|
|
1688
|
+
};
|
|
1689
|
+
const XR_TIMED_WINDOW_PROPERTIES = {
|
|
1690
|
+
start: XR_FRACTION_SCHEMA,
|
|
1691
|
+
end: XR_FRACTION_SCHEMA,
|
|
1692
|
+
easing: XR_EASING_SCHEMA,
|
|
1693
|
+
};
|
|
1694
|
+
const XR_SEQUENCE_TARGET_SCHEMA = {
|
|
1695
|
+
anyOf: [
|
|
1696
|
+
{ type: 'string' },
|
|
1697
|
+
{
|
|
1698
|
+
type: 'object',
|
|
1699
|
+
additionalProperties: false,
|
|
1700
|
+
properties: {
|
|
1701
|
+
name: { type: 'string' },
|
|
1702
|
+
face: {
|
|
1703
|
+
type: 'string',
|
|
1704
|
+
enum: ['front', 'back', 'top', 'bottom', 'left', 'right'],
|
|
1705
|
+
},
|
|
1706
|
+
},
|
|
1707
|
+
required: ['name'],
|
|
1708
|
+
},
|
|
1709
|
+
],
|
|
1710
|
+
description: 'A target name from xr_list_targets, or {name, face}; resolved again when the step starts.',
|
|
1711
|
+
};
|
|
1712
|
+
const XR_SEQUENCE_POSITION_SCHEMA = {
|
|
1713
|
+
anyOf: [
|
|
1714
|
+
XR_TUPLE3_SCHEMA,
|
|
1715
|
+
{
|
|
1716
|
+
type: 'object',
|
|
1717
|
+
additionalProperties: false,
|
|
1718
|
+
properties: {
|
|
1719
|
+
x: { type: 'number' },
|
|
1720
|
+
y: { type: 'number' },
|
|
1721
|
+
z: { type: 'number' },
|
|
1722
|
+
normal: XR_DIRECTION_SCHEMA,
|
|
1723
|
+
},
|
|
1724
|
+
required: ['x', 'y', 'z'],
|
|
1725
|
+
},
|
|
1726
|
+
{
|
|
1727
|
+
type: 'object',
|
|
1728
|
+
additionalProperties: false,
|
|
1729
|
+
properties: {
|
|
1730
|
+
relativeTo: { type: 'string', enum: ['head', 'body'] },
|
|
1731
|
+
x: { type: 'number' },
|
|
1732
|
+
y: { type: 'number' },
|
|
1733
|
+
z: { type: 'number' },
|
|
1734
|
+
},
|
|
1735
|
+
required: ['relativeTo', 'x', 'y', 'z'],
|
|
1736
|
+
},
|
|
1737
|
+
],
|
|
1738
|
+
description: 'XR-origin metres (optionally with the surface normal), or {relativeTo:"head"|"body", x right, y up, z back} turning with the body, never with head pitch; "body" measures y from the floor.',
|
|
1739
|
+
};
|
|
1740
|
+
const XR_STAND_OFF_SCHEMA = {
|
|
1741
|
+
type: 'object',
|
|
1742
|
+
additionalProperties: false,
|
|
1743
|
+
properties: {
|
|
1744
|
+
distance: { type: 'number', minimum: 0 },
|
|
1745
|
+
normal: XR_DIRECTION_SCHEMA,
|
|
1746
|
+
},
|
|
1747
|
+
required: ['distance'],
|
|
1748
|
+
};
|
|
1749
|
+
const XR_SEQUENCE_STEP_SCHEMA = {
|
|
1750
|
+
type: 'object',
|
|
1751
|
+
additionalProperties: false,
|
|
1752
|
+
properties: {
|
|
1753
|
+
label: { type: 'string' },
|
|
1754
|
+
duration: {
|
|
1755
|
+
anyOf: [
|
|
1756
|
+
{ type: 'number', minimum: 0 },
|
|
1757
|
+
{ type: 'string', enum: ['auto'] },
|
|
1758
|
+
],
|
|
1759
|
+
description: 'Seconds for the reach, or "auto" (the default for moves): scaled to distance, turn and pose change.',
|
|
1760
|
+
},
|
|
1761
|
+
target: XR_SEQUENCE_TARGET_SCHEMA,
|
|
1762
|
+
position: XR_SEQUENCE_POSITION_SCHEMA,
|
|
1763
|
+
offset: {
|
|
1764
|
+
anyOf: [
|
|
1765
|
+
XR_STRICT_POSITION_SCHEMA,
|
|
1766
|
+
{
|
|
1767
|
+
type: 'object',
|
|
1768
|
+
additionalProperties: false,
|
|
1769
|
+
properties: { normal: { type: 'number' } },
|
|
1770
|
+
required: ['normal'],
|
|
1771
|
+
},
|
|
1772
|
+
],
|
|
1773
|
+
description: 'Added to the target or position; {normal:d} moves d metres along the surface normal. Setting a held object down: its clearance above the surface.',
|
|
1774
|
+
},
|
|
1775
|
+
approach: {
|
|
1776
|
+
...XR_STAND_OFF_SCHEMA,
|
|
1777
|
+
description: 'Come straight in along the surface normal (straight down while holding) for the last `distance` metres.',
|
|
1778
|
+
},
|
|
1779
|
+
depart: {
|
|
1780
|
+
...XR_STAND_OFF_SCHEMA,
|
|
1781
|
+
description: 'Lift straight off first, along the last surface normal (straight up while holding).',
|
|
1782
|
+
},
|
|
1783
|
+
press: {
|
|
1784
|
+
type: 'object',
|
|
1785
|
+
additionalProperties: false,
|
|
1786
|
+
properties: {
|
|
1787
|
+
depth: { type: 'number', minimum: 0, maximum: 0.015 },
|
|
1788
|
+
hold: { type: 'number', minimum: 0, maximum: 0.2 },
|
|
1789
|
+
retract: { type: 'number', minimum: 0.05 },
|
|
1790
|
+
},
|
|
1791
|
+
description: 'Press the target with the index fingertip: reach, go `depth` m (default 0.008) past the surface, hold `hold` s, pull back `retract` m. Implies anchor index-tip and pose point. Use this for buttons, not a pinch.',
|
|
1792
|
+
},
|
|
1793
|
+
anchor: XR_HAND_ANCHOR_SCHEMA,
|
|
1794
|
+
orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
|
|
1795
|
+
poseId: {
|
|
1796
|
+
anyOf: [
|
|
1797
|
+
{ type: 'string' },
|
|
1798
|
+
{
|
|
1799
|
+
type: 'object',
|
|
1800
|
+
additionalProperties: false,
|
|
1801
|
+
properties: {
|
|
1802
|
+
value: { type: 'string' },
|
|
1803
|
+
...XR_TIMED_WINDOW_PROPERTIES,
|
|
1804
|
+
},
|
|
1805
|
+
required: ['value'],
|
|
1806
|
+
},
|
|
1807
|
+
],
|
|
1808
|
+
description: 'Pose to fade to during the step; {value, start, end} as fractions of the reach. Never "pinch": poses do not select.',
|
|
1809
|
+
},
|
|
1810
|
+
fingers: XR_FINGER_POSES_SCHEMA,
|
|
1811
|
+
pinch: {
|
|
1812
|
+
anyOf: [
|
|
1813
|
+
XR_FRACTION_SCHEMA,
|
|
1814
|
+
{
|
|
1815
|
+
type: 'object',
|
|
1816
|
+
additionalProperties: false,
|
|
1817
|
+
properties: {
|
|
1818
|
+
value: XR_FRACTION_SCHEMA,
|
|
1819
|
+
...XR_TIMED_WINDOW_PROPERTIES,
|
|
1820
|
+
},
|
|
1821
|
+
required: ['value'],
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
type: 'object',
|
|
1825
|
+
additionalProperties: false,
|
|
1826
|
+
properties: {
|
|
1827
|
+
value: XR_FRACTION_SCHEMA,
|
|
1828
|
+
at: { type: 'string', enum: ['arrival'] },
|
|
1829
|
+
},
|
|
1830
|
+
required: ['value', 'at'],
|
|
1831
|
+
},
|
|
1832
|
+
],
|
|
1833
|
+
description: 'Pinch 0..1 (selects at 0.9, lets go at 0.7). {value:1, at:"arrival"} opens to a grip and closes as the hand arrives; on a target it implies anchor grasp.',
|
|
1834
|
+
},
|
|
1835
|
+
body: {
|
|
1836
|
+
type: 'object',
|
|
1837
|
+
additionalProperties: false,
|
|
1838
|
+
properties: {
|
|
1839
|
+
position: XR_SEQUENCE_POSITION_SCHEMA,
|
|
1840
|
+
stepTo: XR_SEQUENCE_TARGET_SCHEMA,
|
|
1841
|
+
facing: XR_DIRECTION_SCHEMA,
|
|
1842
|
+
},
|
|
1843
|
+
description: 'Move the body first: to position, or a step closer to stepTo; facing turns it. The hand goes along.',
|
|
1844
|
+
},
|
|
1845
|
+
microgesture: {
|
|
1846
|
+
...XR_MICROGESTURE_SCHEMA,
|
|
1847
|
+
description: 'Make a microgesture where the hand is, as a step of its own (only label alongside); events report it by name.',
|
|
1848
|
+
},
|
|
1849
|
+
},
|
|
1850
|
+
};
|
|
1851
|
+
const XR_RUN_SEQUENCE_DESCRIPTION = "Run a whole hand interaction in one call with natural motion: one smooth arc per move, the head turning to each target first, the body leaning or stepping closer when needed, the other hand resting by the hip. Steps run in order and each step's properties animate together. Positions are XR-origin metres; -Z is forward, +Y up. Resolves when done with the select events the app saw, step times, press contact times, warnings and the final hand state. " +
|
|
1852
|
+
'Rules: press buttons with `press`, not a pinch. To pick something up, target it with `pinch:{value:1,at:"arrival"}` (the grasp point, between thumb and index, goes on the target). While holding, targeting a surface sets the object down on it; let go with pinch 0. The anchor carries over to later steps. A thumbs up is poseId "thumbs-up" with orientation {fingers:"forward",thumb:"up"} at a head-relative position. A microgesture is a step of its own, {"microgesture":"swipe-left"}, with the hand raised in view and the pinch open (see xr_microgesture). Get names from xr_list_targets and check a plan with dryRun:true first. ' +
|
|
1853
|
+
'Example: {"device":"hand-right","steps":[{"label":"reach","target":"button","press":{}},{"label":"grab","target":"piece","approach":{"distance":0.06},"pinch":{"value":1,"at":"arrival"}},{"label":"carry","target":"tray","depart":{"distance":0.08},"approach":{"distance":0.06}},{"label":"release","pinch":0,"duration":0.15},{"label":"thumbs up","position":{"relativeTo":"head","x":0.12,"y":-0.35,"z":-0.35},"anchor":"wrist","orientation":{"fingers":"forward","thumb":"up"},"poseId":"thumbs-up"},{"label":"hold","duration":1}]}';
|
|
1468
1854
|
const ALL_RUNTIME_MCP_TOOLS = [
|
|
1469
1855
|
// =============================================================================
|
|
1470
1856
|
// Session Management
|
|
@@ -1523,9 +1909,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1523
1909
|
},
|
|
1524
1910
|
{
|
|
1525
1911
|
name: 'xr_set_transform',
|
|
1526
|
-
description: 'Set position and/or orientation
|
|
1912
|
+
description: 'Set a device position and/or orientation immediately (XR-origin). Gaze accepts orientation only; move its origin with the headset. Hands: `anchor` puts that point of the hand at `position` and keeps it there while the hand changes shape (e.g. anchor "index-tip" on a button, "grasp" on an object before pinching); orientation may be hand directions or "auto". Requires an active session.',
|
|
1527
1913
|
inputSchema: {
|
|
1528
1914
|
type: 'object',
|
|
1915
|
+
additionalProperties: false,
|
|
1529
1916
|
properties: {
|
|
1530
1917
|
device: {
|
|
1531
1918
|
type: 'string',
|
|
@@ -1540,8 +1927,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1540
1927
|
description: 'The device to move',
|
|
1541
1928
|
},
|
|
1542
1929
|
position: {
|
|
1543
|
-
|
|
1544
|
-
description: 'World position in meters',
|
|
1930
|
+
...XR_POSITION_SCHEMA,
|
|
1545
1931
|
properties: {
|
|
1546
1932
|
x: { type: 'number', description: 'X position (left/right)' },
|
|
1547
1933
|
y: {
|
|
@@ -1554,25 +1940,8 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1554
1940
|
},
|
|
1555
1941
|
},
|
|
1556
1942
|
},
|
|
1557
|
-
orientation:
|
|
1558
|
-
|
|
1559
|
-
description: 'Rotation as quaternion {x,y,z,w} or euler angles {pitch,yaw,roll} in degrees',
|
|
1560
|
-
properties: {
|
|
1561
|
-
x: { type: 'number', description: 'Quaternion X component' },
|
|
1562
|
-
y: { type: 'number', description: 'Quaternion Y component' },
|
|
1563
|
-
z: { type: 'number', description: 'Quaternion Z component' },
|
|
1564
|
-
w: { type: 'number', description: 'Quaternion W component' },
|
|
1565
|
-
pitch: {
|
|
1566
|
-
type: 'number',
|
|
1567
|
-
description: 'Pitch in degrees (X rotation)',
|
|
1568
|
-
},
|
|
1569
|
-
yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
|
|
1570
|
-
roll: {
|
|
1571
|
-
type: 'number',
|
|
1572
|
-
description: 'Roll in degrees (Z rotation)',
|
|
1573
|
-
},
|
|
1574
|
-
},
|
|
1575
|
-
},
|
|
1943
|
+
orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
|
|
1944
|
+
anchor: XR_HAND_ANCHOR_SCHEMA,
|
|
1576
1945
|
},
|
|
1577
1946
|
required: ['device'],
|
|
1578
1947
|
},
|
|
@@ -1615,9 +1984,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1615
1984
|
},
|
|
1616
1985
|
{
|
|
1617
1986
|
name: 'xr_animate_to',
|
|
1618
|
-
description: '
|
|
1987
|
+
description: 'Animate a device to a target position and/or orientation (XR-origin) over `duration` seconds (default 0.5), from where it is when the animation starts. Gaze accepts orientation only. Hands take `anchor` and hand directions as in xr_set_transform. easing "minimum-jerk" moves like a person (default "linear"). For multi-step hand interactions (press, grab, carry, gestures) prefer xr_run_sequence. Requires an active, rendering session.',
|
|
1619
1988
|
inputSchema: {
|
|
1620
1989
|
type: 'object',
|
|
1990
|
+
additionalProperties: false,
|
|
1621
1991
|
properties: {
|
|
1622
1992
|
device: {
|
|
1623
1993
|
type: 'string',
|
|
@@ -1631,38 +2001,15 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1631
2001
|
],
|
|
1632
2002
|
description: 'The device to animate',
|
|
1633
2003
|
},
|
|
1634
|
-
position:
|
|
1635
|
-
|
|
1636
|
-
description: 'Target world position in meters',
|
|
1637
|
-
properties: {
|
|
1638
|
-
x: { type: 'number' },
|
|
1639
|
-
y: { type: 'number' },
|
|
1640
|
-
z: { type: 'number' },
|
|
1641
|
-
},
|
|
1642
|
-
},
|
|
1643
|
-
orientation: {
|
|
1644
|
-
type: 'object',
|
|
1645
|
-
description: 'Target rotation as quaternion {x,y,z,w} or euler angles {pitch,yaw,roll} in degrees',
|
|
1646
|
-
properties: {
|
|
1647
|
-
x: { type: 'number', description: 'Quaternion X component' },
|
|
1648
|
-
y: { type: 'number', description: 'Quaternion Y component' },
|
|
1649
|
-
z: { type: 'number', description: 'Quaternion Z component' },
|
|
1650
|
-
w: { type: 'number', description: 'Quaternion W component' },
|
|
1651
|
-
pitch: {
|
|
1652
|
-
type: 'number',
|
|
1653
|
-
description: 'Pitch in degrees (X rotation)',
|
|
1654
|
-
},
|
|
1655
|
-
yaw: { type: 'number', description: 'Yaw in degrees (Y rotation)' },
|
|
1656
|
-
roll: {
|
|
1657
|
-
type: 'number',
|
|
1658
|
-
description: 'Roll in degrees (Z rotation)',
|
|
1659
|
-
},
|
|
1660
|
-
},
|
|
1661
|
-
},
|
|
2004
|
+
position: XR_POSITION_SCHEMA,
|
|
2005
|
+
orientation: XR_PLACEMENT_ORIENTATION_SCHEMA,
|
|
1662
2006
|
duration: {
|
|
1663
2007
|
type: 'number',
|
|
2008
|
+
exclusiveMinimum: 0,
|
|
1664
2009
|
description: 'Animation duration in seconds (default: 0.5)',
|
|
1665
2010
|
},
|
|
2011
|
+
easing: XR_EASING_SCHEMA,
|
|
2012
|
+
anchor: XR_HAND_ANCHOR_SCHEMA,
|
|
1666
2013
|
},
|
|
1667
2014
|
required: ['device'],
|
|
1668
2015
|
},
|
|
@@ -1735,9 +2082,10 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1735
2082
|
},
|
|
1736
2083
|
{
|
|
1737
2084
|
name: 'xr_set_select_value',
|
|
1738
|
-
description: 'Set the select (trigger/pinch) value
|
|
2085
|
+
description: 'Set the select value (trigger/pinch), 0..1, optionally ramping from the current value over `duration` seconds (easing default minimum-jerk). A hand pinch selects at 0.9 and lets go at 0.7; a trigger selects above 0. Use xr_select for a full press+release.',
|
|
1739
2086
|
inputSchema: {
|
|
1740
2087
|
type: 'object',
|
|
2088
|
+
additionalProperties: false,
|
|
1741
2089
|
properties: {
|
|
1742
2090
|
device: {
|
|
1743
2091
|
type: 'string',
|
|
@@ -1755,13 +2103,19 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1755
2103
|
maximum: 1,
|
|
1756
2104
|
description: 'Select value (0=released, 1=fully pressed/pinched)',
|
|
1757
2105
|
},
|
|
2106
|
+
duration: {
|
|
2107
|
+
type: 'number',
|
|
2108
|
+
minimum: 0,
|
|
2109
|
+
description: 'Seconds to ramp from the current value (default: 0)',
|
|
2110
|
+
},
|
|
2111
|
+
easing: XR_EASING_SCHEMA,
|
|
1758
2112
|
},
|
|
1759
2113
|
required: ['device', 'value'],
|
|
1760
2114
|
},
|
|
1761
2115
|
},
|
|
1762
2116
|
{
|
|
1763
2117
|
name: 'xr_select',
|
|
1764
|
-
description: 'Perform a
|
|
2118
|
+
description: 'Perform a full select gesture: selectstart on press, then select and selectend on release, holding `duration` seconds (default 0.15). A hand closes its pinch over 0.1 s before the hold and opens it over 0.1 s after. Requires an active session.',
|
|
1765
2119
|
inputSchema: {
|
|
1766
2120
|
type: 'object',
|
|
1767
2121
|
properties: {
|
|
@@ -1777,6 +2131,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
1777
2131
|
},
|
|
1778
2132
|
duration: {
|
|
1779
2133
|
type: 'number',
|
|
2134
|
+
exclusiveMinimum: 0,
|
|
1780
2135
|
description: 'How long to hold in seconds (default: 0.15)',
|
|
1781
2136
|
},
|
|
1782
2137
|
},
|
|
@@ -2088,7 +2443,7 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
2088
2443
|
// =============================================================================
|
|
2089
2444
|
{
|
|
2090
2445
|
name: 'xr_get_device_state',
|
|
2091
|
-
description: 'Get
|
|
2446
|
+
description: 'Get a full snapshot: headset pose, input mode, controllers, hands (with poseId and pinchValue), gaze, stereo, and FOV. Positions are XR-origin relative.',
|
|
2092
2447
|
inputSchema: {
|
|
2093
2448
|
type: 'object',
|
|
2094
2449
|
properties: {},
|
|
@@ -2097,35 +2452,23 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
2097
2452
|
},
|
|
2098
2453
|
{
|
|
2099
2454
|
name: 'xr_set_device_state',
|
|
2100
|
-
description: '
|
|
2455
|
+
description: 'Apply a partial device state (positions XR-origin; hands also take poseId and pinchValue). Call with no `state` to reset everything to defaults.',
|
|
2101
2456
|
inputSchema: {
|
|
2102
2457
|
type: 'object',
|
|
2458
|
+
additionalProperties: false,
|
|
2103
2459
|
properties: {
|
|
2104
2460
|
state: {
|
|
2105
2461
|
type: 'object',
|
|
2462
|
+
additionalProperties: false,
|
|
2106
2463
|
description: 'Partial device state to apply. Omit to reset to defaults.',
|
|
2107
2464
|
properties: {
|
|
2108
2465
|
headset: {
|
|
2109
2466
|
type: 'object',
|
|
2467
|
+
additionalProperties: false,
|
|
2110
2468
|
description: 'Headset transform',
|
|
2111
2469
|
properties: {
|
|
2112
|
-
position:
|
|
2113
|
-
|
|
2114
|
-
properties: {
|
|
2115
|
-
x: { type: 'number' },
|
|
2116
|
-
y: { type: 'number' },
|
|
2117
|
-
z: { type: 'number' },
|
|
2118
|
-
},
|
|
2119
|
-
},
|
|
2120
|
-
orientation: {
|
|
2121
|
-
type: 'object',
|
|
2122
|
-
properties: {
|
|
2123
|
-
x: { type: 'number' },
|
|
2124
|
-
y: { type: 'number' },
|
|
2125
|
-
z: { type: 'number' },
|
|
2126
|
-
w: { type: 'number' },
|
|
2127
|
-
},
|
|
2128
|
-
},
|
|
2470
|
+
position: XR_POSITION_SCHEMA,
|
|
2471
|
+
orientation: XR_ORIENTATION_SCHEMA,
|
|
2129
2472
|
},
|
|
2130
2473
|
},
|
|
2131
2474
|
inputMode: {
|
|
@@ -2143,46 +2486,20 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
2143
2486
|
},
|
|
2144
2487
|
controllers: {
|
|
2145
2488
|
type: 'object',
|
|
2489
|
+
additionalProperties: false,
|
|
2146
2490
|
description: 'Controller states',
|
|
2147
2491
|
properties: {
|
|
2148
|
-
left:
|
|
2149
|
-
|
|
2150
|
-
properties: {
|
|
2151
|
-
position: { type: 'object' },
|
|
2152
|
-
orientation: { type: 'object' },
|
|
2153
|
-
connected: { type: 'boolean' },
|
|
2154
|
-
},
|
|
2155
|
-
},
|
|
2156
|
-
right: {
|
|
2157
|
-
type: 'object',
|
|
2158
|
-
properties: {
|
|
2159
|
-
position: { type: 'object' },
|
|
2160
|
-
orientation: { type: 'object' },
|
|
2161
|
-
connected: { type: 'boolean' },
|
|
2162
|
-
},
|
|
2163
|
-
},
|
|
2492
|
+
left: XR_INPUT_STATE_SCHEMA,
|
|
2493
|
+
right: XR_INPUT_STATE_SCHEMA,
|
|
2164
2494
|
},
|
|
2165
2495
|
},
|
|
2166
2496
|
hands: {
|
|
2167
2497
|
type: 'object',
|
|
2168
|
-
|
|
2498
|
+
additionalProperties: false,
|
|
2499
|
+
description: 'Hand states, including poseId and pinchValue',
|
|
2169
2500
|
properties: {
|
|
2170
|
-
left:
|
|
2171
|
-
|
|
2172
|
-
properties: {
|
|
2173
|
-
position: { type: 'object' },
|
|
2174
|
-
orientation: { type: 'object' },
|
|
2175
|
-
connected: { type: 'boolean' },
|
|
2176
|
-
},
|
|
2177
|
-
},
|
|
2178
|
-
right: {
|
|
2179
|
-
type: 'object',
|
|
2180
|
-
properties: {
|
|
2181
|
-
position: { type: 'object' },
|
|
2182
|
-
orientation: { type: 'object' },
|
|
2183
|
-
connected: { type: 'boolean' },
|
|
2184
|
-
},
|
|
2185
|
-
},
|
|
2501
|
+
left: XR_HAND_STATE_SCHEMA,
|
|
2502
|
+
right: XR_HAND_STATE_SCHEMA,
|
|
2186
2503
|
},
|
|
2187
2504
|
},
|
|
2188
2505
|
gaze: {
|
|
@@ -2190,16 +2507,8 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
2190
2507
|
additionalProperties: false,
|
|
2191
2508
|
description: 'Gaze state. Its origin is derived from the headset and cannot be set independently.',
|
|
2192
2509
|
properties: {
|
|
2193
|
-
orientation: {
|
|
2194
|
-
type: 'object',
|
|
2195
|
-
properties: {
|
|
2196
|
-
x: { type: 'number' },
|
|
2197
|
-
y: { type: 'number' },
|
|
2198
|
-
z: { type: 'number' },
|
|
2199
|
-
w: { type: 'number' },
|
|
2200
|
-
},
|
|
2201
|
-
},
|
|
2202
2510
|
connected: { type: 'boolean' },
|
|
2511
|
+
orientation: XR_ORIENTATION_SCHEMA,
|
|
2203
2512
|
},
|
|
2204
2513
|
},
|
|
2205
2514
|
},
|
|
@@ -2208,6 +2517,108 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
2208
2517
|
},
|
|
2209
2518
|
},
|
|
2210
2519
|
// =============================================================================
|
|
2520
|
+
// Hands
|
|
2521
|
+
// =============================================================================
|
|
2522
|
+
{
|
|
2523
|
+
name: 'xr_set_hand_pose',
|
|
2524
|
+
description: `Set a named hand pose on a hand device. Poses only shape the hand; to pinch (select), use the pinch value (xr_set_select_value). Poses: ${XR_HAND_POSE_GLOSSES}. ` +
|
|
2525
|
+
'Optionally take individual fingers from other poses, e.g. poseId "open" with fingers {"middle":"fist","ring":"fist","pinky":"fist"}, or blend partway with {"poseId":"fist","weight":0.5}. Setting a pose clears earlier finger overrides. `duration` fades from the hand as shown (easing default minimum-jerk); a hand placed by an anchor keeps the anchor in place.',
|
|
2526
|
+
inputSchema: {
|
|
2527
|
+
type: 'object',
|
|
2528
|
+
additionalProperties: false,
|
|
2529
|
+
properties: {
|
|
2530
|
+
device: XR_HAND_DEVICE_SCHEMA,
|
|
2531
|
+
poseId: { type: 'string' },
|
|
2532
|
+
fingers: XR_FINGER_POSES_SCHEMA,
|
|
2533
|
+
duration: { type: 'number', minimum: 0 },
|
|
2534
|
+
easing: XR_EASING_SCHEMA,
|
|
2535
|
+
},
|
|
2536
|
+
required: ['device', 'poseId'],
|
|
2537
|
+
},
|
|
2538
|
+
},
|
|
2539
|
+
{
|
|
2540
|
+
name: 'xr_microgesture',
|
|
2541
|
+
description: 'Swipe or tap the thumb on the side of the curled index finger, as on Quest. The app sees the hand gamepad (xr-standard) button pressed for 35 ms when the gesture completes: 5 swipe-left, 6 swipe-right, 7 swipe-forward, 8 swipe-backward, 9 tap; no select events. A hand not in the "microgesture" pose takes it first (0.25 s); a hand that is selecting must let go first. Raise the hand side-on in view first, e.g. xr_set_transform with anchor "wrist" and orientation {fingers:[0,-0.6,-0.8],palm:"left"} (right hand; "right" for the left). Requires an active session and hand input.',
|
|
2542
|
+
inputSchema: {
|
|
2543
|
+
type: 'object',
|
|
2544
|
+
additionalProperties: false,
|
|
2545
|
+
properties: {
|
|
2546
|
+
device: XR_HAND_DEVICE_SCHEMA,
|
|
2547
|
+
gesture: XR_MICROGESTURE_SCHEMA,
|
|
2548
|
+
},
|
|
2549
|
+
required: ['device', 'gesture'],
|
|
2550
|
+
},
|
|
2551
|
+
},
|
|
2552
|
+
{
|
|
2553
|
+
name: 'xr_get_hand_state',
|
|
2554
|
+
description: 'Read a hand: pose, finger blends, a pose fade in progress, pinch value, whether select is pressed, its anchor pin, and XR-origin positions of the wrist, grip, grasp point, index tip and thumb tip, plus its finger/palm/thumb directions (joints:"all" adds every joint).',
|
|
2555
|
+
inputSchema: {
|
|
2556
|
+
type: 'object',
|
|
2557
|
+
additionalProperties: false,
|
|
2558
|
+
properties: {
|
|
2559
|
+
device: XR_HAND_DEVICE_SCHEMA,
|
|
2560
|
+
joints: { type: 'string', enum: ['key', 'all'] },
|
|
2561
|
+
},
|
|
2562
|
+
required: ['device'],
|
|
2563
|
+
},
|
|
2564
|
+
},
|
|
2565
|
+
{
|
|
2566
|
+
name: 'xr_run_sequence',
|
|
2567
|
+
description: XR_RUN_SEQUENCE_DESCRIPTION,
|
|
2568
|
+
inputSchema: {
|
|
2569
|
+
type: 'object',
|
|
2570
|
+
additionalProperties: false,
|
|
2571
|
+
properties: {
|
|
2572
|
+
device: XR_HAND_DEVICE_SCHEMA,
|
|
2573
|
+
steps: {
|
|
2574
|
+
type: 'array',
|
|
2575
|
+
items: XR_SEQUENCE_STEP_SCHEMA,
|
|
2576
|
+
minItems: 1,
|
|
2577
|
+
},
|
|
2578
|
+
idleHand: {
|
|
2579
|
+
type: 'string',
|
|
2580
|
+
enum: ['keep', 'rest'],
|
|
2581
|
+
description: 'The other hand: rest it by the hip (the default unless it is pinching) or keep it where it is.',
|
|
2582
|
+
},
|
|
2583
|
+
body: {
|
|
2584
|
+
type: 'string',
|
|
2585
|
+
enum: ['auto', 'fixed'],
|
|
2586
|
+
description: 'auto (default): lean for low targets and step closer to ones out of reach. fixed: out of reach is an error.',
|
|
2587
|
+
},
|
|
2588
|
+
gaze: {
|
|
2589
|
+
type: 'string',
|
|
2590
|
+
enum: ['follow', 'fixed'],
|
|
2591
|
+
description: 'follow (default): the head turns to each target before the hand gets there.',
|
|
2592
|
+
},
|
|
2593
|
+
dryRun: {
|
|
2594
|
+
type: 'boolean',
|
|
2595
|
+
description: 'Validate and return the planned steps, walks, durations and warnings without moving anything.',
|
|
2596
|
+
},
|
|
2597
|
+
},
|
|
2598
|
+
required: ['device', 'steps'],
|
|
2599
|
+
},
|
|
2600
|
+
},
|
|
2601
|
+
{
|
|
2602
|
+
name: 'xr_cancel_sequence',
|
|
2603
|
+
description: 'Stop the running xr_run_sequence where it is; that call returns with cancelled: true and the steps done. The pinch is left as it is (no select events).',
|
|
2604
|
+
inputSchema: {
|
|
2605
|
+
type: 'object',
|
|
2606
|
+
additionalProperties: false,
|
|
2607
|
+
properties: {},
|
|
2608
|
+
required: [],
|
|
2609
|
+
},
|
|
2610
|
+
},
|
|
2611
|
+
{
|
|
2612
|
+
name: 'xr_list_targets',
|
|
2613
|
+
description: "List the named targets xr_run_sequence steps can use, from the page's target resolver: name, box centre and size (XR-origin). resolver:false means the page has none; use positions.",
|
|
2614
|
+
inputSchema: {
|
|
2615
|
+
type: 'object',
|
|
2616
|
+
additionalProperties: false,
|
|
2617
|
+
properties: {},
|
|
2618
|
+
required: [],
|
|
2619
|
+
},
|
|
2620
|
+
},
|
|
2621
|
+
// =============================================================================
|
|
2211
2622
|
// Console Logs (Plugin-specific, not in IWER)
|
|
2212
2623
|
// =============================================================================
|
|
2213
2624
|
{
|
|
@@ -2257,6 +2668,21 @@ const ALL_RUNTIME_MCP_TOOLS = [
|
|
|
2257
2668
|
properties: {},
|
|
2258
2669
|
},
|
|
2259
2670
|
},
|
|
2671
|
+
{
|
|
2672
|
+
name: 'browser_set_muted',
|
|
2673
|
+
description: 'Mute or unmute all audio in the managed browser tab, whose app-mode window hides the browser mute control. The state is shared with the workspace mute button and persists across reloads and browser relaunches for the dev session.',
|
|
2674
|
+
inputSchema: {
|
|
2675
|
+
type: 'object',
|
|
2676
|
+
additionalProperties: false,
|
|
2677
|
+
properties: {
|
|
2678
|
+
muted: {
|
|
2679
|
+
type: 'boolean',
|
|
2680
|
+
description: 'true mutes the tab; false unmutes it',
|
|
2681
|
+
},
|
|
2682
|
+
},
|
|
2683
|
+
required: ['muted'],
|
|
2684
|
+
},
|
|
2685
|
+
},
|
|
2260
2686
|
// =============================================================================
|
|
2261
2687
|
// Managed Workspace Tools
|
|
2262
2688
|
// =============================================================================
|
|
@@ -3829,6 +4255,12 @@ const RUNTIME_TOOL_TO_METHOD = {
|
|
|
3829
4255
|
xr_set_gamepad_state: 'set_gamepad_state',
|
|
3830
4256
|
xr_get_device_state: 'get_device_state',
|
|
3831
4257
|
xr_set_device_state: 'set_device_state',
|
|
4258
|
+
xr_set_hand_pose: 'set_hand_pose',
|
|
4259
|
+
xr_microgesture: 'microgesture',
|
|
4260
|
+
xr_get_hand_state: 'get_hand_state',
|
|
4261
|
+
xr_run_sequence: 'run_sequence',
|
|
4262
|
+
xr_cancel_sequence: 'cancel_sequence',
|
|
4263
|
+
xr_list_targets: 'list_targets',
|
|
3832
4264
|
browser_screenshot: 'screenshot',
|
|
3833
4265
|
browser_snapshot: 'browser_snapshot',
|
|
3834
4266
|
browser_interact: 'browser_interact',
|
|
@@ -3860,8 +4292,15 @@ const ALL_RUNTIME_CLI_PATHS = {
|
|
|
3860
4292
|
browser_profile: ['browser', 'profile'],
|
|
3861
4293
|
xr_get_device_state: ['xr', 'get-device-state'],
|
|
3862
4294
|
xr_set_device_state: ['xr', 'set-device-state'],
|
|
4295
|
+
xr_set_hand_pose: ['xr', 'set-hand-pose'],
|
|
4296
|
+
xr_microgesture: ['xr', 'microgesture'],
|
|
4297
|
+
xr_get_hand_state: ['xr', 'get-hand-state'],
|
|
4298
|
+
xr_run_sequence: ['xr', 'run-sequence'],
|
|
4299
|
+
xr_cancel_sequence: ['xr', 'cancel-sequence'],
|
|
4300
|
+
xr_list_targets: ['xr', 'list-targets'],
|
|
3863
4301
|
browser_get_console_logs: ['browser', 'logs'],
|
|
3864
4302
|
browser_reload_page: ['browser', 'reload'],
|
|
4303
|
+
browser_set_muted: ['browser', 'set-muted'],
|
|
3865
4304
|
workspace_get_state: ['workspace', 'state'],
|
|
3866
4305
|
workspace_set_view: ['workspace', 'set-view'],
|
|
3867
4306
|
workspace_open_scene: ['workspace', 'open-scene'],
|
|
@@ -3966,6 +4405,7 @@ const HOST_BROWSER_MCP_TOOL_NAME_SET = new Set([
|
|
|
3966
4405
|
'browser_profile',
|
|
3967
4406
|
'browser_get_console_logs',
|
|
3968
4407
|
'browser_reload_page',
|
|
4408
|
+
'browser_set_muted',
|
|
3969
4409
|
]);
|
|
3970
4410
|
const APP_TARGET_MCP_TOOL_NAME_SET = new Set([
|
|
3971
4411
|
...HOST_BROWSER_MCP_TOOL_NAME_SET,
|
|
@@ -5401,6 +5841,78 @@ async function resolveBundledFontNames(publicDirectory, configured) {
|
|
|
5401
5841
|
}
|
|
5402
5842
|
return result;
|
|
5403
5843
|
}
|
|
5844
|
+
const LUCIDE_ICON_NAMES = new Set(Object.keys(lucideComponentSet));
|
|
5845
|
+
function collectNodeIcons(node, result) {
|
|
5846
|
+
if (node.kind !== 'element') {
|
|
5847
|
+
return;
|
|
5848
|
+
}
|
|
5849
|
+
if (node.origin?.kit === 'lucide') {
|
|
5850
|
+
result.add(node.origin.name);
|
|
5851
|
+
}
|
|
5852
|
+
for (const child of node.children) {
|
|
5853
|
+
collectNodeIcons(child, result);
|
|
5854
|
+
}
|
|
5855
|
+
}
|
|
5856
|
+
/**
|
|
5857
|
+
* Lucide icons to keep in a production build: those used by static public
|
|
5858
|
+
* UIKitML plus `bundle.icons`, or `'all'` when that set cannot be known.
|
|
5859
|
+
*/
|
|
5860
|
+
async function resolveBundledLucideIcons(publicDirectory, configured) {
|
|
5861
|
+
if (configured === 'all') {
|
|
5862
|
+
return 'all';
|
|
5863
|
+
}
|
|
5864
|
+
const result = new Set();
|
|
5865
|
+
for (const icon of configured ?? []) {
|
|
5866
|
+
if (!LUCIDE_ICON_NAMES.has(icon)) {
|
|
5867
|
+
// Icons are UIKitML component names: 'Settings', not 'settings'.
|
|
5868
|
+
const normalized = icon.replace(/[-_\s]/g, '').toLowerCase();
|
|
5869
|
+
const suggestion = [...LUCIDE_ICON_NAMES].find((name) => name.toLowerCase() === normalized);
|
|
5870
|
+
throw new Error(`iwsdkDev().bundle.icons contains unknown Lucide icon "${icon}"` +
|
|
5871
|
+
(suggestion ? `; did you mean "${suggestion}"?` : ''));
|
|
5872
|
+
}
|
|
5873
|
+
result.add(icon);
|
|
5874
|
+
}
|
|
5875
|
+
if (!publicDirectory) {
|
|
5876
|
+
return result;
|
|
5877
|
+
}
|
|
5878
|
+
for (const file of await collectUIKitMLFiles$1(publicDirectory)) {
|
|
5879
|
+
const parsed = parse(await readFile$1(file, 'utf8'), {
|
|
5880
|
+
componentSets: resolveKitComponentSets('horizon'),
|
|
5881
|
+
});
|
|
5882
|
+
if (!parsed.success) {
|
|
5883
|
+
// As with fonts, keep every icon when this size pass cannot analyze a
|
|
5884
|
+
// document; UIKitML validation reports the actual syntax failure.
|
|
5885
|
+
return 'all';
|
|
5886
|
+
}
|
|
5887
|
+
collectNodeIcons(parsed.ast.root, result);
|
|
5888
|
+
}
|
|
5889
|
+
return result;
|
|
5890
|
+
}
|
|
5891
|
+
const UIKITML_KITS_MODULE = /[\\/]@drawcall[\\/]uikitml[\\/]dist[\\/]kits\.js$/;
|
|
5892
|
+
const LUCIDE_NAMESPACE_IMPORT = /import \* as Lucide from (['"])@pmndrs\/uikit-lucide\1;/;
|
|
5893
|
+
/**
|
|
5894
|
+
* UIKitML's kits module builds its Lucide component set by iterating
|
|
5895
|
+
* `import * as Lucide`, which keeps all ~1,600 icons in every production
|
|
5896
|
+
* bundle. Replace that namespace with just the retained icons. Returns null
|
|
5897
|
+
* for any other module.
|
|
5898
|
+
*/
|
|
5899
|
+
function rewriteUIKitMLLucideKit(code, id, icons) {
|
|
5900
|
+
if (icons === 'all' || !UIKITML_KITS_MODULE.test(id.split('?')[0])) {
|
|
5901
|
+
return null;
|
|
5902
|
+
}
|
|
5903
|
+
if (!LUCIDE_NAMESPACE_IMPORT.test(code)) {
|
|
5904
|
+
throw new Error('[IWSDK] @drawcall/uikitml no longer imports Lucide as a namespace; ' +
|
|
5905
|
+
"update rewriteUIKitMLLucideKit or set iwsdkDev({ bundle: { icons: 'all' } }).");
|
|
5906
|
+
}
|
|
5907
|
+
const names = [...icons].sort();
|
|
5908
|
+
const imports = names.map((name, index) => `import { ${name} as __iwsdkLucide${index} } from "@pmndrs/uikit-lucide/dist/${name}.js";`);
|
|
5909
|
+
const members = names.map((name, index) => `${name}: __iwsdkLucide${index}`);
|
|
5910
|
+
// The marker lets @iwsdk/core explain an unknown icon in dynamically loaded
|
|
5911
|
+
// UIKitML instead of reporting a bare unknown-component error.
|
|
5912
|
+
return code.replace(LUCIDE_NAMESPACE_IMPORT, () => `${imports.join('\n')}
|
|
5913
|
+
const Lucide = { ${members.join(', ')} };
|
|
5914
|
+
globalThis.__IWSDK_LUCIDE_ICONS_TRIMMED__ = true;`);
|
|
5915
|
+
}
|
|
5404
5916
|
function createDisabledBundledFontsModule() {
|
|
5405
5917
|
const exports = Object.entries(BUNDLED_FONT_MODULES).map(([font, definition]) => `export const ${definition.exportName} = unavailable(${JSON.stringify(font)});`);
|
|
5406
5918
|
return `const unavailable = (font) => new Proxy({}, {
|
|
@@ -5432,6 +5944,323 @@ function rewriteThreeDecoderDefaults(code, id) {
|
|
|
5432
5944
|
return rewritten === code ? null : rewritten;
|
|
5433
5945
|
}
|
|
5434
5946
|
|
|
5947
|
+
/**
|
|
5948
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5949
|
+
*
|
|
5950
|
+
* This source code is licensed under the MIT license found in the
|
|
5951
|
+
* LICENSE file in the root directory of this source tree.
|
|
5952
|
+
*/
|
|
5953
|
+
// Chromium's app-mode window hides the tab mute control, and the DevTools
|
|
5954
|
+
// Protocol has no tab-mute command. The managed browser therefore mutes each
|
|
5955
|
+
// frame itself: Web Audio output passes through a hidden gain per context, and
|
|
5956
|
+
// media elements are force-muted while page code still reads its own `muted`.
|
|
5957
|
+
/** Page-callable binding the workspace UI uses to change the host state. */
|
|
5958
|
+
const TAB_AUDIO_BINDING = '__IWSDK_SET_TAB_AUDIO_MUTED';
|
|
5959
|
+
/** Window event dispatched in every frame whose mute state changes. */
|
|
5960
|
+
const TAB_AUDIO_CHANGE_EVENT = 'iwsdk:tab-audio-change';
|
|
5961
|
+
// Lets a reloaded same-origin document start in the current state before the
|
|
5962
|
+
// host's framenavigated push reaches it. Written only once the state changes.
|
|
5963
|
+
const TAB_AUDIO_STORAGE_KEY = 'iwsdk:managed-tab-audio-muted';
|
|
5964
|
+
// A frame blocked in a dialog or long task must not hold the command past its
|
|
5965
|
+
// budget. A late evaluation still runs in order, so the frame converges.
|
|
5966
|
+
const FRAME_APPLY_TIMEOUT_MS = 2000;
|
|
5967
|
+
// Started media elements are remembered so detached players can be muted;
|
|
5968
|
+
// paused ones are pruned once the set grows past this size.
|
|
5969
|
+
const STARTED_MEDIA_PRUNE_SIZE = 64;
|
|
5970
|
+
// Playwright serializes this function into every frame before page scripts
|
|
5971
|
+
// run, so it must not reference anything outside its own body.
|
|
5972
|
+
function installTabAudioController({ eventName, initialMuted, pruneSize, storageKey, }) {
|
|
5973
|
+
if (Object.prototype.hasOwnProperty.call(window, '__IWSDK_TAB_AUDIO')) {
|
|
5974
|
+
return;
|
|
5975
|
+
}
|
|
5976
|
+
let muted = initialMuted;
|
|
5977
|
+
try {
|
|
5978
|
+
const stored = window.sessionStorage.getItem(storageKey);
|
|
5979
|
+
muted = stored == null ? initialMuted : stored === '1';
|
|
5980
|
+
}
|
|
5981
|
+
catch {
|
|
5982
|
+
// Opaque-origin and sandboxed frames have no storage; the host pushes.
|
|
5983
|
+
}
|
|
5984
|
+
const NativeAudioContext = window.AudioContext;
|
|
5985
|
+
const nodeProto = AudioNode.prototype;
|
|
5986
|
+
const nativeConnect = nodeProto.connect;
|
|
5987
|
+
const nativeDisconnect = nodeProto.disconnect;
|
|
5988
|
+
const nativeCreateGain = BaseAudioContext.prototype.createGain;
|
|
5989
|
+
// The weak lookup still finds a closed context's gain for disconnect();
|
|
5990
|
+
// only open contexts are retained for state changes.
|
|
5991
|
+
const masters = new WeakMap();
|
|
5992
|
+
const openContexts = new Set();
|
|
5993
|
+
const forEachOpenMaster = (callback) => {
|
|
5994
|
+
openContexts.forEach((context) => {
|
|
5995
|
+
if (context.state === 'closed') {
|
|
5996
|
+
openContexts.delete(context);
|
|
5997
|
+
}
|
|
5998
|
+
else {
|
|
5999
|
+
callback(masters.get(context));
|
|
6000
|
+
}
|
|
6001
|
+
});
|
|
6002
|
+
};
|
|
6003
|
+
const masterFor = (destination) => {
|
|
6004
|
+
const context = destination.context;
|
|
6005
|
+
// OfflineAudioContext renders into a buffer, not to the speakers.
|
|
6006
|
+
if (!(context instanceof NativeAudioContext)) {
|
|
6007
|
+
return null;
|
|
6008
|
+
}
|
|
6009
|
+
let master = masters.get(context);
|
|
6010
|
+
if (master == null) {
|
|
6011
|
+
forEachOpenMaster(() => { });
|
|
6012
|
+
master = nativeCreateGain.call(context);
|
|
6013
|
+
master.channelInterpretation = destination.channelInterpretation;
|
|
6014
|
+
master.gain.value = muted ? 0 : 1;
|
|
6015
|
+
nativeConnect.call(master, destination);
|
|
6016
|
+
masters.set(context, master);
|
|
6017
|
+
openContexts.add(context);
|
|
6018
|
+
}
|
|
6019
|
+
return master;
|
|
6020
|
+
};
|
|
6021
|
+
nodeProto.connect = function connect(destination, ...rest) {
|
|
6022
|
+
const master = destination instanceof AudioDestinationNode
|
|
6023
|
+
? masterFor(destination)
|
|
6024
|
+
: null;
|
|
6025
|
+
if (master == null) {
|
|
6026
|
+
return nativeConnect.call(this, destination, ...rest);
|
|
6027
|
+
}
|
|
6028
|
+
nativeConnect.call(this, master, ...rest);
|
|
6029
|
+
return destination;
|
|
6030
|
+
};
|
|
6031
|
+
nodeProto.disconnect = function disconnect(...args) {
|
|
6032
|
+
const [destination, ...rest] = args;
|
|
6033
|
+
const master = destination instanceof AudioDestinationNode
|
|
6034
|
+
? masters.get(destination.context)
|
|
6035
|
+
: undefined;
|
|
6036
|
+
return master == null
|
|
6037
|
+
? nativeDisconnect.apply(this, args)
|
|
6038
|
+
: nativeDisconnect.call(this, master, ...rest);
|
|
6039
|
+
};
|
|
6040
|
+
const mediaProto = HTMLMediaElement.prototype;
|
|
6041
|
+
const mutedDescriptor = Object.getOwnPropertyDescriptor(mediaProto, 'muted');
|
|
6042
|
+
const nativeGetMuted = mutedDescriptor.get;
|
|
6043
|
+
const nativeSetMuted = mutedDescriptor.set;
|
|
6044
|
+
const nativePlay = mediaProto.play;
|
|
6045
|
+
// The `muted` value page code expects while the tab mute overrides it.
|
|
6046
|
+
const pageMuted = new WeakMap();
|
|
6047
|
+
// Elements routed into Web Audio are silenced by the hidden gain instead;
|
|
6048
|
+
// muting the element would also starve analysers fed from it.
|
|
6049
|
+
const routed = new WeakSet();
|
|
6050
|
+
const started = new Set();
|
|
6051
|
+
const syncElement = (element) => {
|
|
6052
|
+
if (muted && !routed.has(element)) {
|
|
6053
|
+
if (!pageMuted.has(element)) {
|
|
6054
|
+
pageMuted.set(element, nativeGetMuted.call(element));
|
|
6055
|
+
}
|
|
6056
|
+
nativeSetMuted.call(element, true);
|
|
6057
|
+
}
|
|
6058
|
+
else if (pageMuted.has(element)) {
|
|
6059
|
+
// Elements outside the DOM and the started set are released lazily
|
|
6060
|
+
// here, the next time they play.
|
|
6061
|
+
nativeSetMuted.call(element, pageMuted.get(element));
|
|
6062
|
+
pageMuted.delete(element);
|
|
6063
|
+
}
|
|
6064
|
+
};
|
|
6065
|
+
const trackStarted = (element) => {
|
|
6066
|
+
syncElement(element);
|
|
6067
|
+
started.add(element);
|
|
6068
|
+
if (started.size > pruneSize) {
|
|
6069
|
+
started.forEach((candidate) => {
|
|
6070
|
+
if (candidate !== element && candidate.paused) {
|
|
6071
|
+
started.delete(candidate);
|
|
6072
|
+
}
|
|
6073
|
+
});
|
|
6074
|
+
}
|
|
6075
|
+
};
|
|
6076
|
+
const routeElement = (element) => {
|
|
6077
|
+
routed.add(element);
|
|
6078
|
+
syncElement(element);
|
|
6079
|
+
};
|
|
6080
|
+
Object.defineProperty(mediaProto, 'muted', {
|
|
6081
|
+
...mutedDescriptor,
|
|
6082
|
+
get() {
|
|
6083
|
+
return pageMuted.has(this)
|
|
6084
|
+
? pageMuted.get(this)
|
|
6085
|
+
: nativeGetMuted.call(this);
|
|
6086
|
+
},
|
|
6087
|
+
set(value) {
|
|
6088
|
+
if (muted && !routed.has(this)) {
|
|
6089
|
+
pageMuted.set(this, Boolean(value));
|
|
6090
|
+
nativeSetMuted.call(this, true);
|
|
6091
|
+
}
|
|
6092
|
+
else {
|
|
6093
|
+
pageMuted.delete(this);
|
|
6094
|
+
nativeSetMuted.call(this, value);
|
|
6095
|
+
}
|
|
6096
|
+
},
|
|
6097
|
+
});
|
|
6098
|
+
mediaProto.play = function play() {
|
|
6099
|
+
trackStarted(this);
|
|
6100
|
+
return nativePlay.call(this);
|
|
6101
|
+
};
|
|
6102
|
+
const nativeCreateMediaElementSource = NativeAudioContext.prototype.createMediaElementSource;
|
|
6103
|
+
NativeAudioContext.prototype.createMediaElementSource =
|
|
6104
|
+
function createMediaElementSource(element) {
|
|
6105
|
+
const source = nativeCreateMediaElementSource.call(this, element);
|
|
6106
|
+
routeElement(element);
|
|
6107
|
+
return source;
|
|
6108
|
+
};
|
|
6109
|
+
const NativeMediaElementSource = window.MediaElementAudioSourceNode;
|
|
6110
|
+
const MediaElementSource = new Proxy(NativeMediaElementSource, {
|
|
6111
|
+
construct(target, args, newTarget) {
|
|
6112
|
+
const source = Reflect.construct(target, args, newTarget);
|
|
6113
|
+
routeElement(source.mediaElement);
|
|
6114
|
+
return source;
|
|
6115
|
+
},
|
|
6116
|
+
});
|
|
6117
|
+
// Keep `node.constructor === MediaElementAudioSourceNode` true, and route
|
|
6118
|
+
// `new node.constructor(...)` through the hook as well.
|
|
6119
|
+
Object.defineProperty(NativeMediaElementSource.prototype, 'constructor', {
|
|
6120
|
+
...Object.getOwnPropertyDescriptor(NativeMediaElementSource.prototype, 'constructor'),
|
|
6121
|
+
value: MediaElementSource,
|
|
6122
|
+
});
|
|
6123
|
+
window.MediaElementAudioSourceNode = MediaElementSource;
|
|
6124
|
+
// Autoplay and native controls start playback without calling play(), and
|
|
6125
|
+
// native controls can unmute an element directly.
|
|
6126
|
+
const onPlay = (event) => {
|
|
6127
|
+
if (event.target instanceof HTMLMediaElement) {
|
|
6128
|
+
trackStarted(event.target);
|
|
6129
|
+
}
|
|
6130
|
+
};
|
|
6131
|
+
const onVolumeChange = (event) => {
|
|
6132
|
+
const element = event.target;
|
|
6133
|
+
if (muted &&
|
|
6134
|
+
element instanceof HTMLMediaElement &&
|
|
6135
|
+
!routed.has(element) &&
|
|
6136
|
+
nativeGetMuted.call(element) === false) {
|
|
6137
|
+
pageMuted.set(element, false);
|
|
6138
|
+
nativeSetMuted.call(element, true);
|
|
6139
|
+
}
|
|
6140
|
+
};
|
|
6141
|
+
// Media events do not cross shadow boundaries, so watch each shadow root.
|
|
6142
|
+
const watchMediaEvents = (target) => {
|
|
6143
|
+
target.addEventListener('play', onPlay, true);
|
|
6144
|
+
target.addEventListener('volumechange', onVolumeChange, true);
|
|
6145
|
+
};
|
|
6146
|
+
watchMediaEvents(window);
|
|
6147
|
+
const nativeAttachShadow = Element.prototype.attachShadow;
|
|
6148
|
+
Element.prototype.attachShadow = function attachShadow(init) {
|
|
6149
|
+
const root = nativeAttachShadow.call(this, init);
|
|
6150
|
+
watchMediaEvents(root);
|
|
6151
|
+
return root;
|
|
6152
|
+
};
|
|
6153
|
+
const apply = (next) => {
|
|
6154
|
+
if (next === muted) {
|
|
6155
|
+
return muted;
|
|
6156
|
+
}
|
|
6157
|
+
muted = next;
|
|
6158
|
+
try {
|
|
6159
|
+
window.sessionStorage.setItem(storageKey, muted ? '1' : '0');
|
|
6160
|
+
}
|
|
6161
|
+
catch {
|
|
6162
|
+
// See the read above.
|
|
6163
|
+
}
|
|
6164
|
+
forEachOpenMaster((master) => {
|
|
6165
|
+
master.gain.value = muted ? 0 : 1;
|
|
6166
|
+
});
|
|
6167
|
+
document
|
|
6168
|
+
.querySelectorAll('audio, video')
|
|
6169
|
+
.forEach(syncElement);
|
|
6170
|
+
started.forEach(syncElement);
|
|
6171
|
+
window.dispatchEvent(new CustomEvent(eventName, { detail: { muted } }));
|
|
6172
|
+
return muted;
|
|
6173
|
+
};
|
|
6174
|
+
const controller = {
|
|
6175
|
+
get muted() {
|
|
6176
|
+
return muted;
|
|
6177
|
+
},
|
|
6178
|
+
apply: (next) => apply(next === true),
|
|
6179
|
+
};
|
|
6180
|
+
Object.defineProperty(window, '__IWSDK_TAB_AUDIO', {
|
|
6181
|
+
value: Object.freeze(controller),
|
|
6182
|
+
});
|
|
6183
|
+
}
|
|
6184
|
+
/** Owns the managed browser's mute state and applies it to every frame. */
|
|
6185
|
+
class ManagedTabAudio {
|
|
6186
|
+
constructor(context, page, options) {
|
|
6187
|
+
this.context = context;
|
|
6188
|
+
this.page = page;
|
|
6189
|
+
this.applyQueue = Promise.resolve();
|
|
6190
|
+
this.muted = options.muted;
|
|
6191
|
+
this.onMutedChange = options.onMutedChange;
|
|
6192
|
+
}
|
|
6193
|
+
/** Install the frame controller and UI binding before the first navigation. */
|
|
6194
|
+
static async install(context, page, options) {
|
|
6195
|
+
const tabAudio = new ManagedTabAudio(context, page, options);
|
|
6196
|
+
await context.addInitScript(installTabAudioController, {
|
|
6197
|
+
eventName: TAB_AUDIO_CHANGE_EVENT,
|
|
6198
|
+
initialMuted: options.muted,
|
|
6199
|
+
pruneSize: STARTED_MEDIA_PRUNE_SIZE,
|
|
6200
|
+
storageKey: TAB_AUDIO_STORAGE_KEY,
|
|
6201
|
+
});
|
|
6202
|
+
await context.exposeBinding(TAB_AUDIO_BINDING, ({ frame }, muted) => {
|
|
6203
|
+
if (frame !== page.mainFrame()) {
|
|
6204
|
+
throw new Error('Only the managed page can change tab audio.');
|
|
6205
|
+
}
|
|
6206
|
+
return tabAudio.setMuted(muted);
|
|
6207
|
+
});
|
|
6208
|
+
// Covers frames that commit after a change in any page of the managed
|
|
6209
|
+
// browser, including cross-origin frames that cannot read the stored state.
|
|
6210
|
+
const pushOnNavigation = (target) => {
|
|
6211
|
+
target.on('framenavigated', (frame) => {
|
|
6212
|
+
void applyToFrame(frame, tabAudio.muted);
|
|
6213
|
+
});
|
|
6214
|
+
};
|
|
6215
|
+
context.pages().forEach(pushOnNavigation);
|
|
6216
|
+
context.on('page', pushOnNavigation);
|
|
6217
|
+
return tabAudio;
|
|
6218
|
+
}
|
|
6219
|
+
isMuted() {
|
|
6220
|
+
return this.muted;
|
|
6221
|
+
}
|
|
6222
|
+
setMuted(muted) {
|
|
6223
|
+
if (typeof muted !== 'boolean') {
|
|
6224
|
+
return Promise.reject(new TypeError('muted must be a boolean.'));
|
|
6225
|
+
}
|
|
6226
|
+
if (this.page.isClosed()) {
|
|
6227
|
+
return Promise.reject(new Error('The managed browser page is closed.'));
|
|
6228
|
+
}
|
|
6229
|
+
if (muted !== this.muted) {
|
|
6230
|
+
this.muted = muted;
|
|
6231
|
+
this.onMutedChange?.(muted);
|
|
6232
|
+
}
|
|
6233
|
+
// Queue fan-outs so overlapping requests reach each frame in call order.
|
|
6234
|
+
const operation = this.applyQueue.then(async () => {
|
|
6235
|
+
const frames = this.context.pages().flatMap((page) => page.frames());
|
|
6236
|
+
await Promise.all(frames.map((frame) => applyToFrame(frame, muted)));
|
|
6237
|
+
return muted;
|
|
6238
|
+
});
|
|
6239
|
+
this.applyQueue = operation.catch(() => { });
|
|
6240
|
+
return operation;
|
|
6241
|
+
}
|
|
6242
|
+
}
|
|
6243
|
+
async function applyToFrame(frame, muted) {
|
|
6244
|
+
let timer;
|
|
6245
|
+
try {
|
|
6246
|
+
await Promise.race([
|
|
6247
|
+
frame
|
|
6248
|
+
.evaluate((value) => {
|
|
6249
|
+
window.__IWSDK_TAB_AUDIO?.apply(value);
|
|
6250
|
+
}, muted)
|
|
6251
|
+
// Detached and navigating frames pick the state up on their next
|
|
6252
|
+
// commit from storage or the framenavigated push.
|
|
6253
|
+
.catch(() => { }),
|
|
6254
|
+
new Promise((resolve) => {
|
|
6255
|
+
timer = setTimeout(resolve, FRAME_APPLY_TIMEOUT_MS);
|
|
6256
|
+
}),
|
|
6257
|
+
]);
|
|
6258
|
+
}
|
|
6259
|
+
finally {
|
|
6260
|
+
clearTimeout(timer);
|
|
6261
|
+
}
|
|
6262
|
+
}
|
|
6263
|
+
|
|
5435
6264
|
/**
|
|
5436
6265
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
5437
6266
|
*
|
|
@@ -5837,14 +6666,20 @@ let ComponentRegistry;
|
|
|
5837
6666
|
let componentCatalogFromComponents;
|
|
5838
6667
|
let configureUIKitRenderer;
|
|
5839
6668
|
let disposeLoweredSceneNodes;
|
|
6669
|
+
let DomeFadeBinding;
|
|
6670
|
+
let domeFadeSpecFromComponentValue;
|
|
5840
6671
|
let ConeGeometry;
|
|
6672
|
+
let ContactShadowBinding;
|
|
6673
|
+
let createGroundShadowResources;
|
|
5841
6674
|
let CylinderGeometry;
|
|
5842
6675
|
let DirectionalLight;
|
|
6676
|
+
let EnvironmentSystem;
|
|
5843
6677
|
let Float32BufferAttribute;
|
|
5844
6678
|
let Frustum;
|
|
5845
6679
|
let FrontSide;
|
|
5846
6680
|
let finalizeSceneReviewDraft;
|
|
5847
6681
|
let Group;
|
|
6682
|
+
let groundShadowSpecFromComponentValue;
|
|
5848
6683
|
let hashSceneDocument;
|
|
5849
6684
|
let hashRuntimeSceneDocument;
|
|
5850
6685
|
let LevelComponentApplier;
|
|
@@ -5866,6 +6701,7 @@ let Raycaster;
|
|
|
5866
6701
|
let restoreSceneEnvironment;
|
|
5867
6702
|
let Scene;
|
|
5868
6703
|
let ShaderMaterial;
|
|
6704
|
+
let ShadowCatcherBinding;
|
|
5869
6705
|
let SphereGeometry;
|
|
5870
6706
|
let SRGBColorSpace;
|
|
5871
6707
|
let Types;
|
|
@@ -5901,6 +6737,8 @@ const EDITOR_TRANSFORM_SNAP_LIMITS = Object.freeze({
|
|
|
5901
6737
|
translation: { max: 10000, min: 0.001 },
|
|
5902
6738
|
});
|
|
5903
6739
|
const EDITOR_TRANSFORM_SNAP_STORAGE_KEY = 'iwsdk-editor-transform-snap';
|
|
6740
|
+
const TAB_AUDIO_BINDING = ${JSON.stringify(TAB_AUDIO_BINDING)};
|
|
6741
|
+
const TAB_AUDIO_CHANGE_EVENT = ${JSON.stringify(TAB_AUDIO_CHANGE_EVENT)};
|
|
5904
6742
|
|
|
5905
6743
|
async function loadEditorRuntimeDependencies() {
|
|
5906
6744
|
const [
|
|
@@ -5951,13 +6789,19 @@ async function loadEditorRuntimeDependencies() {
|
|
|
5951
6789
|
componentCatalogFromComponents,
|
|
5952
6790
|
configureUIKitRenderer,
|
|
5953
6791
|
disposeLoweredSceneNodes,
|
|
6792
|
+
DomeFadeBinding,
|
|
6793
|
+
domeFadeSpecFromComponentValue,
|
|
5954
6794
|
ConeGeometry,
|
|
6795
|
+
ContactShadowBinding,
|
|
6796
|
+
createGroundShadowResources,
|
|
5955
6797
|
CylinderGeometry,
|
|
5956
6798
|
DirectionalLight,
|
|
6799
|
+
EnvironmentSystem,
|
|
5957
6800
|
Float32BufferAttribute,
|
|
5958
6801
|
Frustum,
|
|
5959
6802
|
FrontSide,
|
|
5960
6803
|
Group,
|
|
6804
|
+
groundShadowSpecFromComponentValue,
|
|
5961
6805
|
LevelComponentApplier,
|
|
5962
6806
|
LineBasicMaterial,
|
|
5963
6807
|
LineSegments,
|
|
@@ -5977,6 +6821,7 @@ async function loadEditorRuntimeDependencies() {
|
|
|
5977
6821
|
restoreSceneEnvironment,
|
|
5978
6822
|
Scene,
|
|
5979
6823
|
ShaderMaterial,
|
|
6824
|
+
ShadowCatcherBinding,
|
|
5980
6825
|
SphereGeometry,
|
|
5981
6826
|
SRGBColorSpace,
|
|
5982
6827
|
Types,
|
|
@@ -6751,11 +7596,25 @@ function attachWorkspaceViewControls() {
|
|
|
6751
7596
|
}
|
|
6752
7597
|
window.addEventListener('hashchange', applyWorkspaceLocation);
|
|
6753
7598
|
window.addEventListener('popstate', applyWorkspaceLocation);
|
|
7599
|
+
window.addEventListener(TAB_AUDIO_CHANGE_EVENT, () => {
|
|
7600
|
+
workspaceUi?.update(workspaceTabAudioState());
|
|
7601
|
+
});
|
|
6754
7602
|
void setWorkspaceView(window.__IWSDK_WORKSPACE_VIEW || 'runtime', {
|
|
6755
7603
|
syncRoute: false,
|
|
6756
7604
|
});
|
|
6757
7605
|
}
|
|
6758
7606
|
|
|
7607
|
+
// The managed browser installs the tab audio controller and host binding;
|
|
7608
|
+
// the mute control stays hidden in any other browser.
|
|
7609
|
+
function workspaceTabAudioState() {
|
|
7610
|
+
const tabAudio = window.__IWSDK_TAB_AUDIO;
|
|
7611
|
+
return {
|
|
7612
|
+
tabAudioAvailable:
|
|
7613
|
+
tabAudio != null && typeof window[TAB_AUDIO_BINDING] === 'function',
|
|
7614
|
+
tabAudioMuted: tabAudio?.muted === true,
|
|
7615
|
+
};
|
|
7616
|
+
}
|
|
7617
|
+
|
|
6759
7618
|
async function waitForWorkspaceRuntimeFrame(timeoutMs = 10000) {
|
|
6760
7619
|
const startedAt = performance.now();
|
|
6761
7620
|
while (window.__IWSDK_WORKSPACE_RUNTIME_READY !== true) {
|
|
@@ -8267,6 +9126,15 @@ function editorWorkspaceController() {
|
|
|
8267
9126
|
reloadPage() {
|
|
8268
9127
|
window.location.reload();
|
|
8269
9128
|
},
|
|
9129
|
+
setTabAudioMuted(muted) {
|
|
9130
|
+
const setMuted = window[TAB_AUDIO_BINDING];
|
|
9131
|
+
if (typeof setMuted !== 'function') {
|
|
9132
|
+
return;
|
|
9133
|
+
}
|
|
9134
|
+
void setMuted(muted).catch((error) => {
|
|
9135
|
+
console.error('[IWSDK] Failed to change tab audio:', error);
|
|
9136
|
+
});
|
|
9137
|
+
},
|
|
8270
9138
|
openRuntimeInBrowser() {
|
|
8271
9139
|
void fetch('/__iwsdk/workspace/open-runtime', {
|
|
8272
9140
|
method: 'POST',
|
|
@@ -8374,6 +9242,7 @@ function createEditorFrame() {
|
|
|
8374
9242
|
workspaceUi?.unmount?.();
|
|
8375
9243
|
workspaceUi = mountEditorWorkspace(root, editorWorkspaceController(), {
|
|
8376
9244
|
...editorStartupState,
|
|
9245
|
+
...workspaceTabAudioState(),
|
|
8377
9246
|
view: window.__IWSDK_WORKSPACE_VIEW || 'runtime',
|
|
8378
9247
|
});
|
|
8379
9248
|
}
|
|
@@ -10119,7 +10988,7 @@ function runtimeSummaryForNode(node) {
|
|
|
10119
10988
|
if (entry.userData?.iwsdkEditorHelperType && summary.helperType == null) {
|
|
10120
10989
|
summary.helperType = entry.userData.iwsdkEditorHelperType;
|
|
10121
10990
|
}
|
|
10122
|
-
if (entry.isMesh === true) {
|
|
10991
|
+
if (entry.isMesh === true && entry.userData?.iwsdkRuntimeOnly !== true) {
|
|
10123
10992
|
summary.meshCount += 1;
|
|
10124
10993
|
summary.materialCount += Array.isArray(entry.material)
|
|
10125
10994
|
? entry.material.length
|
|
@@ -11038,7 +11907,7 @@ function applyEditorReviewLens(documentValue) {
|
|
|
11038
11907
|
if (child.isLight) {
|
|
11039
11908
|
maskObjectFromReviewLens(child);
|
|
11040
11909
|
}
|
|
11041
|
-
if (child.isMesh) {
|
|
11910
|
+
if (child.isMesh && child.userData?.iwsdkRuntimeOnly !== true) {
|
|
11042
11911
|
editorWorldState.lensMaterials.set(child, child.material);
|
|
11043
11912
|
child.material = neutral;
|
|
11044
11913
|
}
|
|
@@ -11061,7 +11930,9 @@ function indexLoweredNode(lowered) {
|
|
|
11061
11930
|
lowered.object.add(createComponentHelperDecoration(lowered.node, helperType));
|
|
11062
11931
|
}
|
|
11063
11932
|
editorWorldState.objectMap.set(lowered.id, lowered.object);
|
|
11933
|
+
attachEditorGroundShadowBindings(lowered);
|
|
11064
11934
|
attachEditorLightBindings(lowered);
|
|
11935
|
+
attachEditorEnvironmentBindings(lowered);
|
|
11065
11936
|
for (const virtual of lowered.virtualNodes || []) {
|
|
11066
11937
|
editorWorldState.objectMap.set(virtual.id, virtual.object);
|
|
11067
11938
|
}
|
|
@@ -11179,7 +12050,9 @@ function detachEditorSceneForSwap() {
|
|
|
11179
12050
|
editorWorldState.transformControls?.detach();
|
|
11180
12051
|
editorWorldState.hoverHelper = null;
|
|
11181
12052
|
editorWorldState.hoveredNodeId = null;
|
|
12053
|
+
disposeEditorGroundShadowBindings();
|
|
11182
12054
|
disposeEditorLightBindings();
|
|
12055
|
+
disposeEditorEnvironmentBindings();
|
|
11183
12056
|
for (const root of editorWorldState.loweredNodes || []) {
|
|
11184
12057
|
root.object.removeFromParent();
|
|
11185
12058
|
}
|
|
@@ -11192,6 +12065,38 @@ function detachEditorSceneForSwap() {
|
|
|
11192
12065
|
editorWorldState.objectMap.clear();
|
|
11193
12066
|
}
|
|
11194
12067
|
|
|
12068
|
+
function attachEditorGroundShadowBindings(lowered) {
|
|
12069
|
+
const bindings = [];
|
|
12070
|
+
for (const [componentName, value] of Object.entries(
|
|
12071
|
+
lowered.node?.components || {},
|
|
12072
|
+
)) {
|
|
12073
|
+
const groundShadow = groundShadowSpecFromComponentValue(componentName, value);
|
|
12074
|
+
if (!groundShadow) continue;
|
|
12075
|
+
const Binding =
|
|
12076
|
+
groundShadow.kind === 'contact-shadow'
|
|
12077
|
+
? ContactShadowBinding
|
|
12078
|
+
: ShadowCatcherBinding;
|
|
12079
|
+
bindings.push(
|
|
12080
|
+
new Binding(
|
|
12081
|
+
lowered.object,
|
|
12082
|
+
editorWorldState.groundShadowResources,
|
|
12083
|
+
groundShadow.spec,
|
|
12084
|
+
),
|
|
12085
|
+
);
|
|
12086
|
+
}
|
|
12087
|
+
if (bindings.length > 0) {
|
|
12088
|
+
editorWorldState.groundShadowBindings.set(lowered.id, bindings);
|
|
12089
|
+
}
|
|
12090
|
+
}
|
|
12091
|
+
|
|
12092
|
+
function disposeEditorGroundShadowBindings() {
|
|
12093
|
+
if (!editorWorldState?.groundShadowBindings) return;
|
|
12094
|
+
for (const bindings of editorWorldState.groundShadowBindings.values()) {
|
|
12095
|
+
for (const binding of bindings) binding.dispose();
|
|
12096
|
+
}
|
|
12097
|
+
editorWorldState.groundShadowBindings.clear();
|
|
12098
|
+
}
|
|
12099
|
+
|
|
11195
12100
|
function attachEditorLightBindings(lowered) {
|
|
11196
12101
|
const bindings = [];
|
|
11197
12102
|
for (const [componentName, value] of Object.entries(
|
|
@@ -11227,6 +12132,63 @@ function syncEditorLightBindings() {
|
|
|
11227
12132
|
}
|
|
11228
12133
|
}
|
|
11229
12134
|
|
|
12135
|
+
function editorDomeGradientUniforms() {
|
|
12136
|
+
return editorWorldState.world
|
|
12137
|
+
.getSystem(EnvironmentSystem)
|
|
12138
|
+
?.getDomeGradientUniforms();
|
|
12139
|
+
}
|
|
12140
|
+
|
|
12141
|
+
// Node components never become ECS components in the editor, so DomeFade
|
|
12142
|
+
// renders through the same binding EnvironmentSystem uses at runtime.
|
|
12143
|
+
function attachEditorEnvironmentBindings(lowered) {
|
|
12144
|
+
const uniforms = editorDomeGradientUniforms();
|
|
12145
|
+
if (!uniforms) return;
|
|
12146
|
+
const bindings = [];
|
|
12147
|
+
for (const [componentName, value] of Object.entries(
|
|
12148
|
+
lowered.node?.components || {},
|
|
12149
|
+
)) {
|
|
12150
|
+
const spec = domeFadeSpecFromComponentValue(componentName, value);
|
|
12151
|
+
if (!spec) continue;
|
|
12152
|
+
bindings.push(new DomeFadeBinding(lowered.object, uniforms, spec));
|
|
12153
|
+
}
|
|
12154
|
+
if (bindings.length > 0) {
|
|
12155
|
+
editorWorldState.environmentBindings.set(lowered.id, bindings);
|
|
12156
|
+
}
|
|
12157
|
+
}
|
|
12158
|
+
|
|
12159
|
+
function disposeEditorEnvironmentBindings() {
|
|
12160
|
+
if (!editorWorldState?.environmentBindings) return;
|
|
12161
|
+
for (const bindings of editorWorldState.environmentBindings.values()) {
|
|
12162
|
+
for (const binding of bindings) binding.dispose();
|
|
12163
|
+
}
|
|
12164
|
+
editorWorldState.environmentBindings.clear();
|
|
12165
|
+
}
|
|
12166
|
+
|
|
12167
|
+
function syncEditorEnvironmentBindings() {
|
|
12168
|
+
if (!editorWorldState?.environmentBindings?.size) return;
|
|
12169
|
+
const active = editorDomeGradientUniforms()?.active.value === 1;
|
|
12170
|
+
for (const bindings of editorWorldState.environmentBindings.values()) {
|
|
12171
|
+
for (const binding of bindings) {
|
|
12172
|
+
binding.refresh();
|
|
12173
|
+
binding.syncTransform();
|
|
12174
|
+
binding.writeMarker(active, active ? null : 'no-dome-gradient');
|
|
12175
|
+
}
|
|
12176
|
+
}
|
|
12177
|
+
}
|
|
12178
|
+
|
|
12179
|
+
function domeFadeStateProof() {
|
|
12180
|
+
const state = {};
|
|
12181
|
+
for (const [nodeId, bindings] of editorWorldState?.environmentBindings ||
|
|
12182
|
+
[]) {
|
|
12183
|
+
for (const binding of bindings) {
|
|
12184
|
+
if (binding instanceof DomeFadeBinding) {
|
|
12185
|
+
state[nodeId] = binding.root.userData.iwsdkDomeFade ?? null;
|
|
12186
|
+
}
|
|
12187
|
+
}
|
|
12188
|
+
}
|
|
12189
|
+
return state;
|
|
12190
|
+
}
|
|
12191
|
+
|
|
11230
12192
|
function syncEditorLightHelperTransforms() {
|
|
11231
12193
|
if (!editorWorldState?.objectMap) return;
|
|
11232
12194
|
for (const object of editorWorldState.objectMap.values()) {
|
|
@@ -11742,6 +12704,7 @@ function boundsForSceneFramingObjects() {
|
|
|
11742
12704
|
if (
|
|
11743
12705
|
!objectIsEffectivelyVisible(object) ||
|
|
11744
12706
|
object.userData?.iwsdkEditorHelper === true ||
|
|
12707
|
+
object.userData?.iwsdkRuntimeOnly === true ||
|
|
11745
12708
|
object.userData?.iwsdkSceneFramingRole === 'support'
|
|
11746
12709
|
) {
|
|
11747
12710
|
return;
|
|
@@ -11775,7 +12738,10 @@ function boundsForObjectWithoutEditorHelpers(object) {
|
|
|
11775
12738
|
const authoredBounds = new Box3();
|
|
11776
12739
|
authoredBounds.makeEmpty();
|
|
11777
12740
|
object.traverse((entry) => {
|
|
11778
|
-
if (
|
|
12741
|
+
if (
|
|
12742
|
+
entry.userData?.iwsdkEditorHelper === true ||
|
|
12743
|
+
entry.userData?.iwsdkRuntimeOnly === true
|
|
12744
|
+
) {
|
|
11779
12745
|
return;
|
|
11780
12746
|
}
|
|
11781
12747
|
expandBoundsByOwnGeometry(authoredBounds, entry);
|
|
@@ -12050,6 +13016,7 @@ function renderEditorWorld() {
|
|
|
12050
13016
|
}
|
|
12051
13017
|
hideCurrentEditorHelpersForRenderOnlyCapture();
|
|
12052
13018
|
syncEditorLightBindings();
|
|
13019
|
+
syncEditorEnvironmentBindings();
|
|
12053
13020
|
syncEditorLightHelperTransforms();
|
|
12054
13021
|
syncInfiniteEditorGrid();
|
|
12055
13022
|
const startedAt = performance.now();
|
|
@@ -12509,7 +13476,10 @@ function currentEditorRenderStats() {
|
|
|
12509
13476
|
if (typeof assetId === 'string') {
|
|
12510
13477
|
let assetMeshCount = 0;
|
|
12511
13478
|
object.traverse((entry) => {
|
|
12512
|
-
if (
|
|
13479
|
+
if (
|
|
13480
|
+
entry.isMesh === true &&
|
|
13481
|
+
entry.userData?.iwsdkRuntimeOnly !== true
|
|
13482
|
+
) {
|
|
12513
13483
|
assetMeshCount += 1;
|
|
12514
13484
|
}
|
|
12515
13485
|
});
|
|
@@ -13568,6 +14538,15 @@ async function createEditorWorld(session, camera) {
|
|
|
13568
14538
|
directional.position.set(4, 8, 5);
|
|
13569
14539
|
directional.userData.iwsdkEditorHelper = true;
|
|
13570
14540
|
world.scene.add(directional);
|
|
14541
|
+
const groundShadowResources = createGroundShadowResources();
|
|
14542
|
+
window.addEventListener(
|
|
14543
|
+
'pagehide',
|
|
14544
|
+
() => {
|
|
14545
|
+
disposeEditorGroundShadowBindings();
|
|
14546
|
+
groundShadowResources.dispose();
|
|
14547
|
+
},
|
|
14548
|
+
{ once: true },
|
|
14549
|
+
);
|
|
13571
14550
|
|
|
13572
14551
|
editorWorldState = {
|
|
13573
14552
|
appliedRootComponentNames: new Set(),
|
|
@@ -13580,8 +14559,11 @@ async function createEditorWorld(session, camera) {
|
|
|
13580
14559
|
editorAmbient: ambient,
|
|
13581
14560
|
editorDirectional: directional,
|
|
13582
14561
|
editorGrid: grid,
|
|
14562
|
+
environmentBindings: new Map(),
|
|
13583
14563
|
environmentPreviousState: null,
|
|
13584
14564
|
frameTimeSamples: [],
|
|
14565
|
+
groundShadowBindings: new Map(),
|
|
14566
|
+
groundShadowResources,
|
|
13585
14567
|
host,
|
|
13586
14568
|
hoveredNodeId: null,
|
|
13587
14569
|
hoverHelper: null,
|
|
@@ -13806,6 +14788,59 @@ function authoredRenderStateProof() {
|
|
|
13806
14788
|
};
|
|
13807
14789
|
}
|
|
13808
14790
|
|
|
14791
|
+
function groundShadowStateProof() {
|
|
14792
|
+
if (!editorWorldState) {
|
|
14793
|
+
return null;
|
|
14794
|
+
}
|
|
14795
|
+
const meshes = [];
|
|
14796
|
+
editorWorldState.world.scene.traverse((object) => {
|
|
14797
|
+
const kind =
|
|
14798
|
+
object.userData?.iwsdkContactShadow === true
|
|
14799
|
+
? 'contact-shadow'
|
|
14800
|
+
: object.userData?.iwsdkShadowCatcher === true
|
|
14801
|
+
? 'shadow-catcher'
|
|
14802
|
+
: null;
|
|
14803
|
+
if (!kind) {
|
|
14804
|
+
return;
|
|
14805
|
+
}
|
|
14806
|
+
meshes.push({
|
|
14807
|
+
castShadow: object.castShadow === true,
|
|
14808
|
+
color: '#' + object.material.color.getHexString(),
|
|
14809
|
+
kind,
|
|
14810
|
+
layerMask: object.layers.mask,
|
|
14811
|
+
materialType: object.material.type,
|
|
14812
|
+
materialUuid: object.material.uuid,
|
|
14813
|
+
nodeId: object.parent?.userData?.iwsdkSceneNodeId ?? null,
|
|
14814
|
+
opacity: object.material.opacity,
|
|
14815
|
+
positionY: Number(object.position.y.toFixed(4)),
|
|
14816
|
+
receiveShadow: object.receiveShadow === true,
|
|
14817
|
+
runtimeOnly: object.userData.iwsdkRuntimeOnly === true,
|
|
14818
|
+
scale: [
|
|
14819
|
+
Number(object.scale.x.toFixed(4)),
|
|
14820
|
+
Number(object.scale.y.toFixed(4)),
|
|
14821
|
+
],
|
|
14822
|
+
visible: objectIsEffectivelyVisible(object),
|
|
14823
|
+
});
|
|
14824
|
+
});
|
|
14825
|
+
meshes.sort((first, second) =>
|
|
14826
|
+
(first.nodeId + first.kind).localeCompare(second.nodeId + second.kind),
|
|
14827
|
+
);
|
|
14828
|
+
// Selection bounds of every node, with -0 reported as 0.
|
|
14829
|
+
const round = (vector) => roundVec3(vector.toArray()).map((value) => value || 0);
|
|
14830
|
+
const nodeBounds = {};
|
|
14831
|
+
for (const [nodeId, object] of editorWorldState.objectMap) {
|
|
14832
|
+
const bounds = boundsForObjectWithoutEditorHelpers(object);
|
|
14833
|
+
nodeBounds[nodeId] = bounds
|
|
14834
|
+
? { max: round(bounds.max), min: round(bounds.min) }
|
|
14835
|
+
: null;
|
|
14836
|
+
}
|
|
14837
|
+
return {
|
|
14838
|
+
bindingNodeIds: [...editorWorldState.groundShadowBindings.keys()].sort(),
|
|
14839
|
+
meshes,
|
|
14840
|
+
nodeBounds,
|
|
14841
|
+
};
|
|
14842
|
+
}
|
|
14843
|
+
|
|
13809
14844
|
function rendererGlobalsProof() {
|
|
13810
14845
|
if (!editorWorldState) {
|
|
13811
14846
|
return null;
|
|
@@ -14272,7 +15307,11 @@ function ghostObjectMaterials(object) {
|
|
|
14272
15307
|
return;
|
|
14273
15308
|
}
|
|
14274
15309
|
object.traverse((child) => {
|
|
14275
|
-
if (
|
|
15310
|
+
if (
|
|
15311
|
+
!child.isMesh ||
|
|
15312
|
+
child.userData?.iwsdkEditorHelper === true ||
|
|
15313
|
+
child.userData?.iwsdkRuntimeOnly === true
|
|
15314
|
+
) {
|
|
14276
15315
|
return;
|
|
14277
15316
|
}
|
|
14278
15317
|
const original = child.material;
|
|
@@ -18171,6 +19210,7 @@ async function init() {
|
|
|
18171
19210
|
},
|
|
18172
19211
|
getContributions: () => editorContributionProof(),
|
|
18173
19212
|
getAuthoredRenderState: () => authoredRenderStateProof(),
|
|
19213
|
+
getDomeFadeState: () => domeFadeStateProof(),
|
|
18174
19214
|
getEnvironmentDomeState: () => {
|
|
18175
19215
|
const camera = editorWorldState?.world?.camera;
|
|
18176
19216
|
let dome = null;
|
|
@@ -18190,6 +19230,7 @@ async function init() {
|
|
|
18190
19230
|
dome?.material?.vertexShader?.includes?.('mat3(viewMatrix)') ?? false,
|
|
18191
19231
|
};
|
|
18192
19232
|
},
|
|
19233
|
+
getGroundShadowState: () => groundShadowStateProof(),
|
|
18193
19234
|
getProof: () => createViewportProof(),
|
|
18194
19235
|
getResourceState: () => editorResourceStateProof(),
|
|
18195
19236
|
getRendererGlobals: () => rendererGlobalsProof(),
|
|
@@ -24325,7 +25366,7 @@ async function inspectPngCapture(bytes) {
|
|
|
24325
25366
|
async function launchManagedBrowser(url, headless, verbose, viewport = null, screenshotSize = {
|
|
24326
25367
|
width: 800,
|
|
24327
25368
|
height: 800,
|
|
24328
|
-
}, traceMcp = false, managedAccess = null, readiness = 'iwer', workspaceRoot = process.cwd(), browserAutomation = false, signal) {
|
|
25369
|
+
}, traceMcp = false, managedAccess = null, readiness = 'iwer', workspaceRoot = process.cwd(), browserAutomation = false, signal, tabAudioOptions = { muted: false }) {
|
|
24329
25370
|
const launchUrl = new URL(url);
|
|
24330
25371
|
if (launchUrl.protocol !== 'http:' && launchUrl.protocol !== 'https:') {
|
|
24331
25372
|
throw new Error('Managed browser URL must use HTTP or HTTPS');
|
|
@@ -24357,7 +25398,9 @@ async function launchManagedBrowser(url, headless, verbose, viewport = null, scr
|
|
|
24357
25398
|
const commandCoordinator = new ManagedBrowserCommandCoordinator(dispose, () => fireCloseCallback());
|
|
24358
25399
|
const profiler = new BrowserProfiler(page, context, workspaceRoot, commandCoordinator, (value) => browserConsole.sanitize(value));
|
|
24359
25400
|
browserConsole.attach(profiler);
|
|
25401
|
+
let tabAudio;
|
|
24360
25402
|
try {
|
|
25403
|
+
tabAudio = await ManagedTabAudio.install(context, page, tabAudioOptions);
|
|
24361
25404
|
browserAutomationTarget = await navigateAndVerifyManagedPage({
|
|
24362
25405
|
browserAutomationEndpoint,
|
|
24363
25406
|
context,
|
|
@@ -24443,6 +25486,10 @@ async function launchManagedBrowser(url, headless, verbose, viewport = null, scr
|
|
|
24443
25486
|
getAutomationEndpoint: () => browserAutomationTarget?.endpoint ?? null,
|
|
24444
25487
|
getAutomationTarget: () => browserAutomationTarget,
|
|
24445
25488
|
runCommandExclusive: (operation, options) => commandCoordinator.runExclusive(operation, options?.timeoutMs, options?.queueTimeoutMs),
|
|
25489
|
+
// Agent requests queue in the plugin's command runner for their tab
|
|
25490
|
+
// preconditions. The workspace button calls the page binding instead, so
|
|
25491
|
+
// it never waits behind a long browser command.
|
|
25492
|
+
setAudioMuted: (muted) => tabAudio.setMuted(muted),
|
|
24446
25493
|
reloadApplication: () => commandCoordinator.runExclusive(async () => {
|
|
24447
25494
|
await profiler.stopIfActive('reload');
|
|
24448
25495
|
return reloadApplicationFrame(page, getRemainingOperationTimeMs('browser_reload_page', 20000));
|
|
@@ -25203,10 +26250,11 @@ function createRelayHandler(options) {
|
|
|
25203
26250
|
replyError(request.source, request.sourceId, outcome.code, outcome.message, 'outcome_unknown');
|
|
25204
26251
|
}
|
|
25205
26252
|
/** Milliseconds this relay may wait, NaN when the deadline is malformed. */
|
|
25206
|
-
function relayWindowMs(method, deadline) {
|
|
26253
|
+
function relayWindowMs(method, deadline, params) {
|
|
25207
26254
|
// Only an omitted deadline is legacy; an explicit null is malformed.
|
|
25208
26255
|
if (deadline === undefined) {
|
|
25209
|
-
return (getDefaultRuntimeCommandTimeoutMs(method) -
|
|
26256
|
+
return (getDefaultRuntimeCommandTimeoutMs(method, params) -
|
|
26257
|
+
RELAY_DEADLINE_MARGIN_MS);
|
|
25210
26258
|
}
|
|
25211
26259
|
if (typeof deadline !== 'number' || !Number.isFinite(deadline)) {
|
|
25212
26260
|
return NaN;
|
|
@@ -25241,7 +26289,7 @@ function createRelayHandler(options) {
|
|
|
25241
26289
|
}
|
|
25242
26290
|
return;
|
|
25243
26291
|
}
|
|
25244
|
-
const windowMs = relayWindowMs(message.method, message.deadline);
|
|
26292
|
+
const windowMs = relayWindowMs(message.method, message.deadline, message.params);
|
|
25245
26293
|
if (Number.isNaN(windowMs)) {
|
|
25246
26294
|
return replyError(source, message.id, 'invalid_params', 'deadline must be an absolute epoch time in milliseconds within 24 days.');
|
|
25247
26295
|
}
|
|
@@ -25290,8 +26338,10 @@ function createRelayHandler(options) {
|
|
|
25290
26338
|
endpoint: metadata,
|
|
25291
26339
|
timer,
|
|
25292
26340
|
});
|
|
26341
|
+
// The caller's command credential is never forwarded to a page.
|
|
26342
|
+
const { commandToken: _commandToken, ...request } = message;
|
|
25293
26343
|
try {
|
|
25294
|
-
destination.send(JSON.stringify({ ...
|
|
26344
|
+
destination.send(JSON.stringify({ ...request, id: wireId, target }));
|
|
25295
26345
|
}
|
|
25296
26346
|
catch {
|
|
25297
26347
|
settleUnknown(wireId, DISPATCH_FAILED);
|
|
@@ -50003,6 +51053,11 @@ if ( typeof window !== 'undefined' ) {
|
|
|
50003
51053
|
* Copyright 2010-2026 Three.js Authors
|
|
50004
51054
|
* SPDX-License-Identifier: MIT
|
|
50005
51055
|
*/
|
|
51056
|
+
|
|
51057
|
+
var common = "#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n#ifndef saturate\n#define saturate( a ) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement( a ) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nvec3 pow2( const in vec3 x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); }\nfloat average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract( sin( sn ) * c );\n}\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n#ifdef USE_ALPHAHASH\n\tvarying vec3 vPosition;\n#endif\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\n#define inverseTransformDirection transformDirectionByInverseViewMatrix\nvec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz );\n}\nvec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz );\n}\nbool isPerspectiveMatrix( mat4 m ) {\n\treturn m[ 2 ][ 3 ] == - 1.0;\n}\nvec2 equirectUv( in vec3 dir ) {\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\treturn vec2( u, v );\n}\nvec3 BRDF_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n}\nfloat F_Schlick( const in float f0, const in float f90, const in float dotVH ) {\n\tfloat fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );\n\treturn f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );\n} // validated";
|
|
51058
|
+
|
|
51059
|
+
const ShaderChunk = {
|
|
51060
|
+
common: common};
|
|
50006
51061
|
const _m$1 = /*@__PURE__*/ new Matrix3();
|
|
50007
51062
|
|
|
50008
51063
|
_m$1.set( -1, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 );
|
|
@@ -56261,6 +57316,12 @@ Mesh.prototype.raycast = acceleratedRaycast;
|
|
|
56261
57316
|
BatchedMesh.prototype.computeBoundsTree = computeBatchedBoundsTree;
|
|
56262
57317
|
BatchedMesh.prototype.disposeBoundsTree = disposeBatchedBoundsTree;
|
|
56263
57318
|
BatchedMesh.prototype.raycast = acceleratedRaycast;
|
|
57319
|
+
// super-three's multiview mode (Quest in XR) `#define`s viewMatrix as
|
|
57320
|
+
// viewMatrices[VIEW_ID]. r185's transform*ByInverseViewMatrix helpers in the
|
|
57321
|
+
// common chunk take a parameter named viewMatrix, which that define turns into
|
|
57322
|
+
// an array of non-constant size, so every shader fails to compile in XR.
|
|
57323
|
+
// Rename the parameter; callers still pass viewMatrix.
|
|
57324
|
+
ShaderChunk.common = ShaderChunk.common.replace(/(vec3 transform(?:Normal|Direction)ByInverseViewMatrix\(\s*in vec3 \w+,\s*in mat4 )viewMatrix(\s*\)\s*\{[^}]*?)viewMatrix/g, '$1inverseView$2inverseView');
|
|
56264
57325
|
// export * as Addons from 'three/examples/jsm/Addons.js';
|
|
56265
57326
|
|
|
56266
57327
|
/**
|
|
@@ -57793,6 +58854,9 @@ function traceRuntimeSession(event, details = {}) {
|
|
|
57793
58854
|
function getRuntimeSessionFilePath(workspaceRoot) {
|
|
57794
58855
|
return getRuntimeFilePath(workspaceRoot, IWSDK_RUNTIME_SESSION_PATH);
|
|
57795
58856
|
}
|
|
58857
|
+
function getRuntimeCommandCredentialFilePath(workspaceRoot) {
|
|
58858
|
+
return getRuntimeFilePath(workspaceRoot, IWSDK_RUNTIME_COMMAND_CREDENTIAL_PATH);
|
|
58859
|
+
}
|
|
57796
58860
|
async function enqueueSessionMutation(workspaceRoot, mutate) {
|
|
57797
58861
|
const normalizedWorkspaceRoot = normalizeWorkspaceRoot(workspaceRoot);
|
|
57798
58862
|
return withRuntimeFileLock(getRuntimeSessionFilePath(normalizedWorkspaceRoot), () => mutate(normalizedWorkspaceRoot));
|
|
@@ -57816,6 +58880,14 @@ async function registerRuntimeSession(input) {
|
|
|
57816
58880
|
input.ownerSessionId === input.sessionId)) {
|
|
57817
58881
|
throw new RuntimeSessionOwnershipError(existing);
|
|
57818
58882
|
}
|
|
58883
|
+
// Under the session lock and before the session is published, so a
|
|
58884
|
+
// client that discovers this session always finds its credential.
|
|
58885
|
+
// writeRuntimeJson creates the file with mode 0600.
|
|
58886
|
+
await writeRuntimeJson(getRuntimeCommandCredentialFilePath(workspaceRoot), {
|
|
58887
|
+
schemaVersion: IWSDK_RUNTIME_STATE_SCHEMA_VERSION,
|
|
58888
|
+
sessionId: input.sessionId,
|
|
58889
|
+
commandToken: input.commandToken,
|
|
58890
|
+
});
|
|
57819
58891
|
const now = new Date().toISOString();
|
|
57820
58892
|
const hasBrowserInput = Object.prototype.hasOwnProperty.call(input, 'browser');
|
|
57821
58893
|
const session = {
|
|
@@ -57880,6 +58952,12 @@ async function setRuntimeSessionBrowserState(workspaceRoot, sessionId, browser)
|
|
|
57880
58952
|
}
|
|
57881
58953
|
async function unregisterRuntimeSession(workspaceRoot, sessionId) {
|
|
57882
58954
|
await enqueueSessionMutation(workspaceRoot, async (normalizedWorkspaceRoot) => {
|
|
58955
|
+
// Each record is removed only while it still names this session.
|
|
58956
|
+
const credentialPath = getRuntimeCommandCredentialFilePath(normalizedWorkspaceRoot);
|
|
58957
|
+
const credential = await readRuntimeJson(credentialPath);
|
|
58958
|
+
if (credential?.sessionId === sessionId) {
|
|
58959
|
+
await removeRuntimeFile(credentialPath);
|
|
58960
|
+
}
|
|
57883
58961
|
const filePath = getRuntimeSessionFilePath(normalizedWorkspaceRoot);
|
|
57884
58962
|
const existing = await readRuntimeSession(filePath);
|
|
57885
58963
|
if (existing?.sessionId !== sessionId) {
|
|
@@ -57901,13 +58979,18 @@ function unregisterRuntimeSessionSync(workspaceRoot, sessionId) {
|
|
|
57901
58979
|
return;
|
|
57902
58980
|
}
|
|
57903
58981
|
try {
|
|
57904
|
-
|
|
57905
|
-
|
|
57906
|
-
|
|
57907
|
-
|
|
57908
|
-
|
|
57909
|
-
|
|
57910
|
-
|
|
58982
|
+
for (const recordPath of [
|
|
58983
|
+
getRuntimeCommandCredentialFilePath(normalizedWorkspaceRoot),
|
|
58984
|
+
filePath,
|
|
58985
|
+
]) {
|
|
58986
|
+
let existing = null;
|
|
58987
|
+
try {
|
|
58988
|
+
existing = JSON.parse(readFileSync(recordPath, 'utf8'));
|
|
58989
|
+
}
|
|
58990
|
+
catch { }
|
|
58991
|
+
if (existing?.sessionId === sessionId) {
|
|
58992
|
+
rmSync(recordPath, { force: true });
|
|
58993
|
+
}
|
|
57911
58994
|
}
|
|
57912
58995
|
}
|
|
57913
58996
|
finally {
|
|
@@ -58468,6 +59551,7 @@ function iwsdkDev(options = {}) {
|
|
|
58468
59551
|
let loadedProject = null;
|
|
58469
59552
|
let bundlePhysics = true;
|
|
58470
59553
|
let bundledFonts = null;
|
|
59554
|
+
let bundledIcons = 'all';
|
|
58471
59555
|
let injectionBundle = null;
|
|
58472
59556
|
let config;
|
|
58473
59557
|
const hotClientRoles = new WeakMap();
|
|
@@ -58497,6 +59581,7 @@ function iwsdkDev(options = {}) {
|
|
|
58497
59581
|
? undefined
|
|
58498
59582
|
: path.resolve(projectRoot, configuredPublicDirectory ?? 'public');
|
|
58499
59583
|
bundledFonts = await resolveBundledFontNames(publicDirectory, options.bundle?.fonts);
|
|
59584
|
+
bundledIcons = await resolveBundledLucideIcons(publicDirectory, options.bundle?.icons);
|
|
58500
59585
|
}
|
|
58501
59586
|
}
|
|
58502
59587
|
// A local example-asset override is an explicit /@fs/ request. Vite's
|
|
@@ -58672,6 +59757,10 @@ function iwsdkDev(options = {}) {
|
|
|
58672
59757
|
let managedBrowser = null;
|
|
58673
59758
|
const httpServer = server.httpServer;
|
|
58674
59759
|
const sessionId = randomUUID();
|
|
59760
|
+
// Authorizes runtime commands for this server generation. It reaches
|
|
59761
|
+
// only clients that can read .iwsdk/runtime, never a browser page.
|
|
59762
|
+
const commandToken = randomBytes(32).toString('base64url');
|
|
59763
|
+
const expectedCommandToken = Buffer.from(commandToken, 'utf8');
|
|
58675
59764
|
const sessionStartTime = Date.now();
|
|
58676
59765
|
if (loadedProject != null) {
|
|
58677
59766
|
server.watcher.add(loadedProject.configPath);
|
|
@@ -58859,6 +59948,8 @@ function iwsdkDev(options = {}) {
|
|
|
58859
59948
|
const browserClientMetadata = new Map();
|
|
58860
59949
|
let serverShuttingDown = false;
|
|
58861
59950
|
let browserUrl = '';
|
|
59951
|
+
// Tab mute is a dev-session preference, so relaunches inherit it.
|
|
59952
|
+
let managedBrowserAudioMuted = false;
|
|
58862
59953
|
let currentBrowserState = null;
|
|
58863
59954
|
let lastBridgeConnectedAt;
|
|
58864
59955
|
let lastCommandReadyAt;
|
|
@@ -58937,6 +60028,7 @@ function iwsdkDev(options = {}) {
|
|
|
58937
60028
|
commandReady: lifecycle.state === 'running' && isBrowserCommandPathReady(),
|
|
58938
60029
|
connectedClientCount: managed.length,
|
|
58939
60030
|
lastTransitionAt: lifecycle.stateEnteredAt,
|
|
60031
|
+
audioMuted: managedBrowserAudioMuted,
|
|
58940
60032
|
...(lifecycle.issue
|
|
58941
60033
|
? {
|
|
58942
60034
|
lastError: createBrowserIssue(lifecycle.issueCause ??
|
|
@@ -59000,7 +60092,13 @@ function iwsdkDev(options = {}) {
|
|
|
59000
60092
|
topLevelPathnames: ['/'],
|
|
59001
60093
|
token: managedWorkspaceToken,
|
|
59002
60094
|
runtimeIdentity: { sessionId, browserEpoch },
|
|
59003
|
-
}, pluginOptions.ai ? 'iwer' : 'workspace', config.root, pluginOptions.workspace.browserAutomation, signal
|
|
60095
|
+
}, pluginOptions.ai ? 'iwer' : 'workspace', config.root, pluginOptions.workspace.browserAutomation, signal, {
|
|
60096
|
+
muted: managedBrowserAudioMuted,
|
|
60097
|
+
onMutedChange: (muted) => {
|
|
60098
|
+
managedBrowserAudioMuted = muted;
|
|
60099
|
+
publishBrowserState();
|
|
60100
|
+
},
|
|
60101
|
+
});
|
|
59004
60102
|
},
|
|
59005
60103
|
});
|
|
59006
60104
|
currentBrowserState = createBrowserState();
|
|
@@ -59268,7 +60366,9 @@ function iwsdkDev(options = {}) {
|
|
|
59268
60366
|
bytes: data.length,
|
|
59269
60367
|
});
|
|
59270
60368
|
if (pluginOptions.verbose) {
|
|
59271
|
-
console.log('[IWSDK-MCP] Message received:', message
|
|
60369
|
+
console.log('[IWSDK-MCP] Message received:', message
|
|
60370
|
+
.replace(/"commandToken":"[^"]*"/u, '"commandToken":"[redacted]"')
|
|
60371
|
+
.substring(0, 100));
|
|
59272
60372
|
}
|
|
59273
60373
|
let intercepted = false;
|
|
59274
60374
|
try {
|
|
@@ -59277,6 +60377,8 @@ function iwsdkDev(options = {}) {
|
|
|
59277
60377
|
parsed.expectedSessionId != null &&
|
|
59278
60378
|
parsed.expectedSessionId !== sessionId) {
|
|
59279
60379
|
intercepted = true;
|
|
60380
|
+
// Not authenticated yet, so the reply omits the current
|
|
60381
|
+
// sessionId: it is part of a managed bridge's identity.
|
|
59280
60382
|
sendWsJson(ws, {
|
|
59281
60383
|
id: parsed.id,
|
|
59282
60384
|
error: {
|
|
@@ -59285,12 +60387,38 @@ function iwsdkDev(options = {}) {
|
|
|
59285
60387
|
data: {
|
|
59286
60388
|
code: 'stale_runtime_owner',
|
|
59287
60389
|
outcome: 'not_executed',
|
|
59288
|
-
sessionId,
|
|
59289
60390
|
},
|
|
59290
60391
|
},
|
|
59291
60392
|
}, 'stale_owner');
|
|
59292
60393
|
return;
|
|
59293
60394
|
}
|
|
60395
|
+
// Every command must carry this session's credential. Browser
|
|
60396
|
+
// bridges never hold it: their hello, readiness and replies carry
|
|
60397
|
+
// no method and keep their own identity, pairing and loopback
|
|
60398
|
+
// rules. The credential is dropped before anything is relayed.
|
|
60399
|
+
if (parsed.method != null) {
|
|
60400
|
+
if (!hasRuntimeCommandCredential(parsed.commandToken, expectedCommandToken)) {
|
|
60401
|
+
intercepted = true;
|
|
60402
|
+
traceRuntime('command_unauthorized', {
|
|
60403
|
+
connectionId,
|
|
60404
|
+
kind: getConnectionKind(ws),
|
|
60405
|
+
});
|
|
60406
|
+
sendWsJson(ws, {
|
|
60407
|
+
id: parsed.id,
|
|
60408
|
+
error: {
|
|
60409
|
+
code: -32001,
|
|
60410
|
+
cause: 'permission_denied',
|
|
60411
|
+
message: 'Runtime command credential is missing or invalid. The iwsdk CLI and "iwsdk mcp stdio" send the one this dev server wrote to .iwsdk/runtime/command-credential.json: use them from the same IWSDK release as @iwsdk/vite-plugin-dev, or run "iwsdk dev restart" if that file is gone.',
|
|
60412
|
+
data: {
|
|
60413
|
+
code: 'runtime_unauthorized',
|
|
60414
|
+
outcome: 'not_executed',
|
|
60415
|
+
},
|
|
60416
|
+
},
|
|
60417
|
+
}, 'command_unauthorized');
|
|
60418
|
+
return;
|
|
60419
|
+
}
|
|
60420
|
+
delete parsed.commandToken;
|
|
60421
|
+
}
|
|
59294
60422
|
if (parsed.method === '__iwsdk_browser_lease_release') {
|
|
59295
60423
|
intercepted = true;
|
|
59296
60424
|
return;
|
|
@@ -59890,6 +61018,19 @@ function iwsdkDev(options = {}) {
|
|
|
59890
61018
|
});
|
|
59891
61019
|
return;
|
|
59892
61020
|
}
|
|
61021
|
+
if (parsed.method === 'browser_set_muted' &&
|
|
61022
|
+
typeof parsed.id === 'string') {
|
|
61023
|
+
intercepted = true;
|
|
61024
|
+
await handleManagedBrowserRequest(ws, parsed, {
|
|
61025
|
+
command: 'browser_set_muted',
|
|
61026
|
+
errorContext: 'set_muted_error',
|
|
61027
|
+
execute: (browser) => browser.setAudioMuted(parsed.params?.muted),
|
|
61028
|
+
resultContext: 'set_muted_result',
|
|
61029
|
+
serialize: (muted) => ({ muted }),
|
|
61030
|
+
unavailableContext: 'set_muted_unavailable',
|
|
61031
|
+
});
|
|
61032
|
+
return;
|
|
61033
|
+
}
|
|
59893
61034
|
if (parsed.method === 'browser_snapshot' &&
|
|
59894
61035
|
typeof parsed.id === 'string') {
|
|
59895
61036
|
intercepted = true;
|
|
@@ -60261,6 +61402,7 @@ function iwsdkDev(options = {}) {
|
|
|
60261
61402
|
try {
|
|
60262
61403
|
sessionRegistration = registerRuntimeSession({
|
|
60263
61404
|
sessionId,
|
|
61405
|
+
commandToken,
|
|
60264
61406
|
ownerSessionId: owner?.identity.sessionId,
|
|
60265
61407
|
workspaceRoot: config.root,
|
|
60266
61408
|
pid: process.pid,
|
|
@@ -60438,7 +61580,8 @@ function iwsdkDev(options = {}) {
|
|
|
60438
61580
|
},
|
|
60439
61581
|
transform(code, id) {
|
|
60440
61582
|
return config.command === 'build'
|
|
60441
|
-
? rewriteThreeDecoderDefaults(code, id)
|
|
61583
|
+
? (rewriteThreeDecoderDefaults(code, id) ??
|
|
61584
|
+
rewriteUIKitMLLucideKit(code, id, bundledIcons))
|
|
60442
61585
|
: null;
|
|
60443
61586
|
},
|
|
60444
61587
|
async load(id) {
|
|
@@ -60723,6 +61866,14 @@ function hasManagedWorkspaceAccess(request, token) {
|
|
|
60723
61866
|
return false;
|
|
60724
61867
|
}
|
|
60725
61868
|
}
|
|
61869
|
+
/** Compares a runtime command's credential in constant time. */
|
|
61870
|
+
function hasRuntimeCommandCredential(presented, expected) {
|
|
61871
|
+
if (typeof presented !== 'string') {
|
|
61872
|
+
return false;
|
|
61873
|
+
}
|
|
61874
|
+
const actual = Buffer.from(presented, 'utf8');
|
|
61875
|
+
return actual.length === expected.length && timingSafeEqual(actual, expected);
|
|
61876
|
+
}
|
|
60726
61877
|
function getHeaderValue(value) {
|
|
60727
61878
|
if (Array.isArray(value)) {
|
|
60728
61879
|
return value[0];
|
|
@@ -61067,7 +62218,9 @@ async function handleWorkspaceFilesRequest(request, response, workspaceRoot) {
|
|
|
61067
62218
|
.filter((entry) => /^\.[a-z0-9]+$/u.test(entry)));
|
|
61068
62219
|
const publicRoot = path.resolve(workspaceRoot, 'public');
|
|
61069
62220
|
const browseRoot = path.resolve(publicRoot, subfolder);
|
|
61070
|
-
|
|
62221
|
+
// The walk skips symbolic links; only the subfolder path can contain one.
|
|
62222
|
+
if (!isPathInside(publicRoot, browseRoot) ||
|
|
62223
|
+
!isRealPathInside(publicRoot, browseRoot)) {
|
|
61071
62224
|
throw new Error('File picker subfolder must stay inside public/.');
|
|
61072
62225
|
}
|
|
61073
62226
|
const files = [];
|
|
@@ -61105,6 +62258,44 @@ function isPathInside(parentPath, candidatePath) {
|
|
|
61105
62258
|
return (relative === '' ||
|
|
61106
62259
|
(!relative.startsWith('..') && !path.isAbsolute(relative)));
|
|
61107
62260
|
}
|
|
62261
|
+
/**
|
|
62262
|
+
* Resolves symbolic links in the existing part of a path and appends the
|
|
62263
|
+
* missing tail unchanged. Returns null when the path cannot be resolved, such
|
|
62264
|
+
* as through a dangling link that a write would follow.
|
|
62265
|
+
*/
|
|
62266
|
+
function resolveRealPath(targetPath) {
|
|
62267
|
+
const missing = [];
|
|
62268
|
+
let current = path.resolve(targetPath);
|
|
62269
|
+
while (true) {
|
|
62270
|
+
try {
|
|
62271
|
+
return path.join(realpathSync.native(current), ...missing);
|
|
62272
|
+
}
|
|
62273
|
+
catch (error) {
|
|
62274
|
+
if (error.code !== 'ENOENT') {
|
|
62275
|
+
return null;
|
|
62276
|
+
}
|
|
62277
|
+
}
|
|
62278
|
+
try {
|
|
62279
|
+
lstatSync$1(current);
|
|
62280
|
+
return null;
|
|
62281
|
+
}
|
|
62282
|
+
catch { }
|
|
62283
|
+
const parent = path.dirname(current);
|
|
62284
|
+
if (parent === current) {
|
|
62285
|
+
return null;
|
|
62286
|
+
}
|
|
62287
|
+
missing.unshift(path.basename(current));
|
|
62288
|
+
current = parent;
|
|
62289
|
+
}
|
|
62290
|
+
}
|
|
62291
|
+
/** Lexical checks cannot see symbolic links; this compares real paths. */
|
|
62292
|
+
function isRealPathInside(parentPath, candidatePath) {
|
|
62293
|
+
const realParent = resolveRealPath(parentPath);
|
|
62294
|
+
const realCandidate = resolveRealPath(candidatePath);
|
|
62295
|
+
return (realParent != null &&
|
|
62296
|
+
realCandidate != null &&
|
|
62297
|
+
isPathInside(realParent, realCandidate));
|
|
62298
|
+
}
|
|
61108
62299
|
function toPosixPath(value) {
|
|
61109
62300
|
return value.split(path.sep).join('/');
|
|
61110
62301
|
}
|
|
@@ -63531,6 +64722,14 @@ function resolveManagedScenePath(requestedScene, workspaceRoot, defaultScene) {
|
|
|
63531
64722
|
if (!resolved.endsWith(SCENE_FILE_SUFFIX)) {
|
|
63532
64723
|
throw new Error(`Scene path must end with ${SCENE_FILE_SUFFIX}`);
|
|
63533
64724
|
}
|
|
64725
|
+
// Every scene read and write goes through here, so a symbolic link at
|
|
64726
|
+
// public/scenes or inside it can never reach outside the project.
|
|
64727
|
+
if (!isRealPathInside(workspaceRoot, sceneRoot)) {
|
|
64728
|
+
throw new Error('public/scenes/ must resolve inside the Vite workspace root, including through symbolic links');
|
|
64729
|
+
}
|
|
64730
|
+
if (!isRealPathInside(sceneRoot, resolved)) {
|
|
64731
|
+
throw new Error('Scene path must stay inside public/scenes/, including through symbolic links');
|
|
64732
|
+
}
|
|
63534
64733
|
return resolved;
|
|
63535
64734
|
}
|
|
63536
64735
|
async function composeWorkspaceSceneDocument(document, scenePath, workspaceRoot) {
|
|
@@ -63560,6 +64759,9 @@ async function composeWorkspaceSceneDocument(document, scenePath, workspaceRoot)
|
|
|
63560
64759
|
if (!absolutePath.endsWith(SCENE_FILE_SUFFIX)) {
|
|
63561
64760
|
throw new Error(`Scene import "${src}" must end with ${SCENE_FILE_SUFFIX}`);
|
|
63562
64761
|
}
|
|
64762
|
+
if (!isRealPathInside(sceneRoot, absolutePath)) {
|
|
64763
|
+
throw new Error(`Scene import "${src}" must resolve inside public/scenes/, including through symbolic links`);
|
|
64764
|
+
}
|
|
63563
64765
|
if (!existsSync(absolutePath)) {
|
|
63564
64766
|
throw new Error(`Scene import file does not exist: ${src}`);
|
|
63565
64767
|
}
|
|
@@ -63584,6 +64786,10 @@ function listSceneFiles(workspaceRoot) {
|
|
|
63584
64786
|
if (!existsSync(sceneRoot)) {
|
|
63585
64787
|
return [];
|
|
63586
64788
|
}
|
|
64789
|
+
// The walk below skips symbolic links; only the root itself can be one.
|
|
64790
|
+
if (!isRealPathInside(workspaceRoot, sceneRoot)) {
|
|
64791
|
+
throw new Error('public/scenes/ must resolve inside the Vite workspace root, including through symbolic links');
|
|
64792
|
+
}
|
|
63587
64793
|
const files = [];
|
|
63588
64794
|
const visit = (directory) => {
|
|
63589
64795
|
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|