@iwsdk/vite-plugin-dev 0.5.3 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -78,6 +78,10 @@ iwsdkDev({
78
78
  // Wait for the managed browser command bridge after launch or recovery.
79
79
  bridgeReadyTimeoutMs: 5000, // default
80
80
 
81
+ // Public UIKitML is scanned automatically. Retain bundled families needed
82
+ // only by remote or otherwise dynamic UIKitML (or use 'all').
83
+ bundle: { fonts: ['roboto'] },
84
+
81
85
  // Enable verbose logging
82
86
  verbose: false, // default
83
87
  });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { RuntimeBrowserClient, RuntimeDeviceClass, RuntimePageRole, RuntimePageTarget } from '@iwsdk/cli/contract';
8
+ /** Longest page, tab, scene or owner identity accepted from a browser. */
9
+ export declare const MAX_BROWSER_IDENTITY_LENGTH = 256;
10
+ /** Absent is a legacy managed page; any other unknown class is malformed. */
11
+ export declare function normalizeDeviceClass(deviceClass: unknown): RuntimeDeviceClass | null;
12
+ /** Absent is a legacy app page; any other unknown role is malformed. */
13
+ export declare function normalizePageRole(role: unknown): RuntimePageRole | null;
14
+ /**
15
+ * True only for endpoint metadata that is safe to route, sort and publish:
16
+ * bounded string identities and a positive safe-integer generation.
17
+ */
18
+ export declare function isValidBrowserEndpoint(endpoint: RuntimePageTarget): boolean;
19
+ /** Compares everything except readiness, the one field a socket may update. */
20
+ export declare function isSameBrowserEndpoint(left: RuntimePageTarget, right: RuntimePageTarget): boolean;
21
+ export interface BrowserHelloOwner {
22
+ sessionId: string;
23
+ browserEpoch: number;
24
+ /** Resolved from the hello's pairing token; required for physical pages. */
25
+ headsetId?: string;
26
+ /** Used only when a legacy page announces neither pageId nor tabId. */
27
+ fallbackPageId: string;
28
+ }
29
+ /**
30
+ * Converts a raw iwsdk_browser_hello into endpoint metadata before any
31
+ * registry sees it. Absent legacy fields take defaults, but present malformed
32
+ * values are rejected (null) instead of coerced, and a managed page must carry
33
+ * exactly the owned session and browser epoch.
34
+ */
35
+ export declare function normalizeBrowserHello(hello: Record<string, unknown>, owner: BrowserHelloOwner): RuntimeBrowserClient | null;
36
+ export declare function isBrowserBridgeConnectionAllowed(address: string | undefined): boolean;
37
+ /** True while both managed roles the command path needs have a bridge. */
38
+ export declare function hasManagedCommandRoles(clients: readonly RuntimeBrowserClient[]): boolean;
39
+ export declare function hasReadyBrowserCommandPath(clients: readonly RuntimeBrowserClient[]): boolean;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import type { ProductionBundleOptions, UIKitMLBundledFontName } from './types.js';
8
+ export declare const BUNDLED_FONT_MODULES: Record<UIKitMLBundledFontName, {
9
+ module: string;
10
+ exportName: string;
11
+ }>;
12
+ export declare function resolveBundledFontNames(publicDirectory: string | undefined, configured: ProductionBundleOptions['fonts']): Promise<ReadonlySet<UIKitMLBundledFontName>>;
13
+ export declare function createDisabledBundledFontsModule(): string;
@@ -5,7 +5,7 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import { type SceneComponentCatalog, type SceneBounds, type SceneDocument, type ScenePatch, type Sha256, type ValidationIssue, type Vec3, type Vec4 } from '@iwsdk/scene-composition';
8
- export declare const SCENE_EDITOR_TOOL_METHODS: readonly ["scene_get_capabilities", "scene_select", "scene_set_camera", "scene_screenshot", "ui_list_assets", "ui_render_preview"];
8
+ export declare const SCENE_EDITOR_TOOL_METHODS: readonly ["scene_get_capabilities", "scene_select", "scene_set_camera", "scene_screenshot", "asset_render_preview", "ui_list_assets", "ui_render_preview"];
9
9
  export type SceneEditorToolMethod = (typeof SCENE_EDITOR_TOOL_METHODS)[number];
10
10
  export type SceneEditorCameraView = 'current' | 'top' | 'front' | 'back' | 'left' | 'right' | 'quarter' | 'orbit';
11
11
  export type SceneEditorResolvedCameraView = Exclude<SceneEditorCameraView, 'current'>;
@@ -50,6 +50,50 @@ export interface SceneEditorUIPreviewResult {
50
50
  mimeType: 'image/png';
51
51
  width: number;
52
52
  }
53
+ export type SceneEditorAssetPreviewMode = 'material' | 'clay';
54
+ export type SceneEditorAssetPreviewView = 'front' | 'back' | 'left' | 'right' | 'top' | 'quarter';
55
+ export interface SceneEditorAssetPreviewOptions {
56
+ background?: string;
57
+ focus?: string;
58
+ height?: number;
59
+ mode?: SceneEditorAssetPreviewMode;
60
+ views?: SceneEditorAssetPreviewView[];
61
+ width?: number;
62
+ }
63
+ export interface SceneEditorAssetPreviewResult {
64
+ assetId: string;
65
+ background: string;
66
+ diagnostics: {
67
+ bounds: SceneBounds | null;
68
+ focusBounds: SceneBounds | null;
69
+ framingBounds: SceneBounds | null;
70
+ geometryCount: number;
71
+ materialCount: number;
72
+ meshCount: number;
73
+ namedPartCount: number;
74
+ namedParts: Array<{
75
+ bounds: SceneBounds | null;
76
+ name: string;
77
+ path: string;
78
+ type: string;
79
+ }>;
80
+ namedPartsTruncated: boolean;
81
+ objectCount: number;
82
+ renderedTriangles: number;
83
+ warnings: Array<{
84
+ code: string;
85
+ message: string;
86
+ path?: string;
87
+ }>;
88
+ };
89
+ focus?: string;
90
+ height: number;
91
+ imageData: string;
92
+ mimeType: 'image/png';
93
+ mode: SceneEditorAssetPreviewMode;
94
+ views: SceneEditorAssetPreviewView[];
95
+ width: number;
96
+ }
53
97
  export interface SceneEditorScreenshotComparisonResult {
54
98
  matches: boolean;
55
99
  first: SceneEditorScreenshotResult;
@@ -129,6 +173,7 @@ export interface SceneEditorSessionOptions {
129
173
  saveDocument?: (serializedDocument: string, document: SceneDocument) => Promise<SceneEditorSaveResult> | SceneEditorSaveResult;
130
174
  screenshot?: (camera: SceneEditorCameraState, options: SceneEditorScreenshotOptions) => Promise<SceneEditorScreenshotResult> | SceneEditorScreenshotResult;
131
175
  renderUIPreview?: (assetId: string, options: SceneEditorUIPreviewOptions) => Promise<SceneEditorUIPreviewResult> | SceneEditorUIPreviewResult;
176
+ renderAssetPreview?: (assetId: string, options: SceneEditorAssetPreviewOptions) => Promise<SceneEditorAssetPreviewResult> | SceneEditorAssetPreviewResult;
132
177
  registerReviewCapture?: (capture: Record<string, unknown>) => Promise<{
133
178
  captureToken: Sha256;
134
179
  }> | {
@@ -213,6 +258,7 @@ export declare class SceneEditorSession implements FrameworkMCPRuntime {
213
258
  private getLogs;
214
259
  private setCamera;
215
260
  private screenshot;
261
+ private renderAssetPreview;
216
262
  private renderUIPreview;
217
263
  private compareScreenshots;
218
264
  private setReviewLens;
@@ -1,4 +1,4 @@
1
- import { s as sha256, c as canonicalizeJson, a as assertValidSceneDocument, S as SceneCommandHistory, h as hashSceneDocument, b as hashRuntimeSceneDocument, C as CURRENT_SCENE_VERSION, M as MAX_SCENE_RESOURCES, d as MAX_SCENE_PATTERN_EXPANSION, e as MAX_SCENE_NODES, f as MAX_SCENE_COORDINATE, g as CURRENT_SCENE_REVIEW_VERSION, i as applyScenePatch, r as resolveLookAtTransformInDocument, v as validateSceneDocument, j as serializeSceneDocument, k as SCENE_REVIEW_JSON_SCHEMA, l as SCENE_DOCUMENT_JSON_SCHEMA } from '../patch-BVc5fBs4.js';
1
+ import { s as sha256, c as canonicalizeJson, a as assertValidSceneDocument, S as SceneCommandHistory, h as hashSceneDocument, b as hashRuntimeSceneDocument, C as CURRENT_SCENE_VERSION, M as MAX_SCENE_RESOURCES, d as MAX_SCENE_PATTERN_EXPANSION, e as MAX_SCENE_NODES, f as MAX_SCENE_COORDINATE, g as CURRENT_SCENE_REVIEW_VERSION, i as applyScenePatch, r as resolveLookAtTransformInDocument, v as validateSceneDocument, j as serializeSceneDocument, k as SCENE_REVIEW_JSON_SCHEMA, l as SCENE_DOCUMENT_JSON_SCHEMA } from '../patch-D24zp5ky.js';
2
2
 
3
3
  /** Stable structural fingerprint shared by editor and runtime capabilities. */
4
4
  function hashSceneComponentSchema(schema) {
@@ -155,6 +155,7 @@ const SCENE_EDITOR_TOOL_METHODS = [
155
155
  'scene_select',
156
156
  'scene_set_camera',
157
157
  'scene_screenshot',
158
+ 'asset_render_preview',
158
159
  'ui_list_assets',
159
160
  'ui_render_preview',
160
161
  ];
@@ -287,6 +288,8 @@ class SceneEditorSession {
287
288
  return this.screenshot(params);
288
289
  case 'scene_compare_screenshots':
289
290
  return this.compareScreenshots(params);
291
+ case 'asset_render_preview':
292
+ return this.renderAssetPreview(params);
290
293
  case 'ui_list_assets':
291
294
  return this.listUIAssets(params);
292
295
  case 'ui_render_preview':
@@ -873,6 +876,19 @@ class SceneEditorSession {
873
876
  width: getOptionalNumber(params.width),
874
877
  });
875
878
  }
879
+ async renderAssetPreview(params) {
880
+ if (this.options.renderAssetPreview == null) {
881
+ throw new Error('The editor runtime cannot render model previews');
882
+ }
883
+ return this.options.renderAssetPreview(getRequiredString(params.assetId, 'assetId'), {
884
+ background: getOptionalString(params.background),
885
+ focus: getOptionalString(params.focus),
886
+ height: getOptionalNumber(params.height),
887
+ mode: getOptionalAssetPreviewMode(params.mode),
888
+ views: getOptionalAssetPreviewViews(params.views),
889
+ width: getOptionalNumber(params.width),
890
+ });
891
+ }
876
892
  async renderUIPreview(params) {
877
893
  if (this.options.renderUIPreview == null) {
878
894
  throw new Error('The editor runtime cannot render UIKitML previews');
@@ -1513,6 +1529,33 @@ function getReviewLens(value) {
1513
1529
  }
1514
1530
  throw new Error('lens must be one of layout, geometry, final');
1515
1531
  }
1532
+ function getOptionalAssetPreviewMode(value) {
1533
+ if (value == null) {
1534
+ return undefined;
1535
+ }
1536
+ if (value === 'material' || value === 'clay') {
1537
+ return value;
1538
+ }
1539
+ throw new Error('mode must be one of material, clay');
1540
+ }
1541
+ function getOptionalAssetPreviewViews(value) {
1542
+ if (value == null) {
1543
+ return undefined;
1544
+ }
1545
+ const views = getStringArray(value, 'views');
1546
+ if (views.length < 1 || views.length > 6) {
1547
+ throw new Error('views must contain between 1 and 6 entries');
1548
+ }
1549
+ if (!views.every((view) => view === 'front' ||
1550
+ view === 'back' ||
1551
+ view === 'left' ||
1552
+ view === 'right' ||
1553
+ view === 'top' ||
1554
+ view === 'quarter')) {
1555
+ throw new Error('views entries must be front, back, left, right, top, or quarter');
1556
+ }
1557
+ return views;
1558
+ }
1516
1559
  function getCaptureMode(value) {
1517
1560
  if (value == null || value === 'render') {
1518
1561
  return 'render';