@webspatial/react-sdk 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/default/index.d.ts +60 -32
- package/dist/default/index.js +234 -169
- package/dist/default/index.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.d.ts +2 -1
- package/dist/jsx/jsx-dev-runtime.js +2 -1
- package/dist/jsx/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx/jsx-dev-runtime.web.js +1 -1
- package/dist/jsx/jsx-runtime.js +2 -1
- package/dist/jsx/jsx-runtime.js.map +1 -1
- package/dist/jsx/jsx-runtime.web.js +1 -1
- package/dist/web/index.d.ts +60 -32
- package/dist/web/index.js +247 -169
- package/dist/web/index.js.map +1 -1
- package/package.json +2 -2
package/dist/default/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as _webspatial_core_sdk from '@webspatial/core-sdk';
|
|
2
|
-
import { SpatialSceneCreationOptions, SpatialSceneType, SpatialTapEvent as SpatialTapEvent$1, SpatialDragStartEvent as SpatialDragStartEvent$1, SpatialDragEvent as SpatialDragEvent$1, SpatialDragEndEvent as SpatialDragEndEvent$1, SpatialRotateEvent as SpatialRotateEvent$1, SpatialRotateEndEvent as SpatialRotateEndEvent$1, SpatialMagnifyEvent as SpatialMagnifyEvent$1, SpatialMagnifyEndEvent as SpatialMagnifyEndEvent$1, SpatializedElement,
|
|
2
|
+
import { SpatialSceneCreationOptions, SpatialSceneType, SpatialTapEvent as SpatialTapEvent$1, SpatialDragStartEvent as SpatialDragStartEvent$1, SpatialDragEvent as SpatialDragEvent$1, SpatialDragEndEvent as SpatialDragEndEvent$1, SpatialRotateEvent as SpatialRotateEvent$1, SpatialRotateEndEvent as SpatialRotateEndEvent$1, SpatialMagnifyEvent as SpatialMagnifyEvent$1, SpatialMagnifyEndEvent as SpatialMagnifyEndEvent$1, SpatializedElement, Vec3, SpatialObject, SpatialSession, SpatializedDynamic3DElement, SpatialEntity, Quaternion, SpatialBoxGeometryOptions, SpatialUnlitMaterialOptions, SpatialSphereGeometryOptions, SpatialConeGeometryOptions, SpatialCylinderGeometryOptions, SpatialPlaneGeometryOptions, PhysicalMetrics } from '@webspatial/core-sdk';
|
|
3
3
|
export { Point3D, Vec3 } from '@webspatial/core-sdk';
|
|
4
4
|
import * as React$1 from 'react';
|
|
5
|
-
import React__default, { ElementType, ForwardedRef } from 'react';
|
|
5
|
+
import React__default, { ElementType, ForwardedRef, createElement as createElement$1 } from 'react';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
8
8
|
declare function enableDebugTool(): void;
|
|
@@ -13,6 +13,13 @@ declare function initScene(name: string, callback: (pre: SpatialSceneCreationOpt
|
|
|
13
13
|
|
|
14
14
|
declare const SpatialID = "data-spatial-id";
|
|
15
15
|
|
|
16
|
+
/** Options for spatial pointer/gesture behavior (not DOM attributes). */
|
|
17
|
+
type SpatialEventOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Direction vector for rotate gesture constraint. `[0, 0, 0]` or omit = unconstrained.
|
|
20
|
+
*/
|
|
21
|
+
constrainedToAxis?: Vec3 | readonly [number, number, number];
|
|
22
|
+
};
|
|
16
23
|
type SpatialEventProps<T extends SpatializedElementRef> = {
|
|
17
24
|
onSpatialTap?: (event: SpatialTapEvent<T>) => void;
|
|
18
25
|
onSpatialDragStart?: (event: SpatialDragStartEvent<T>) => void;
|
|
@@ -28,22 +35,12 @@ interface StandardSpatializedContainerProps extends React__default.ComponentProp
|
|
|
28
35
|
inStandardSpatializedContainer?: boolean;
|
|
29
36
|
[SpatialID]: string;
|
|
30
37
|
}
|
|
31
|
-
type RealityForbiddenSpatialEventProps = {
|
|
32
|
-
onSpatialTap?: never;
|
|
33
|
-
onSpatialDragStart?: never;
|
|
34
|
-
onSpatialDrag?: never;
|
|
35
|
-
onSpatialDragEnd?: never;
|
|
36
|
-
onSpatialRotate?: never;
|
|
37
|
-
onSpatialRotateEnd?: never;
|
|
38
|
-
onSpatialMagnify?: never;
|
|
39
|
-
onSpatialMagnifyEnd?: never;
|
|
40
|
-
};
|
|
41
|
-
type RealityProps = React__default.ComponentPropsWithRef<'div'> & RealityForbiddenSpatialEventProps;
|
|
42
38
|
type PortalSpatializedContainerProps<T extends SpatializedElementRef> = SpatialEventProps<T> & React__default.ComponentPropsWithoutRef<'div'> & {
|
|
43
39
|
component: ElementType;
|
|
44
40
|
spatializedContent: ElementType;
|
|
45
41
|
createSpatializedElement: () => Promise<SpatializedElement>;
|
|
46
42
|
getExtraSpatializedElementProperties?: (computedStyle: CSSStyleDeclaration) => Record<string, any>;
|
|
43
|
+
spatialEventOptions?: SpatialEventOptions;
|
|
47
44
|
[SpatialID]: string;
|
|
48
45
|
};
|
|
49
46
|
type SpatializedContainerProps<T extends SpatializedElementRef> = Omit<StandardSpatializedContainerProps & PortalSpatializedContainerProps<T>, typeof SpatialID | 'onLoad' | 'onError'> & {
|
|
@@ -51,11 +48,13 @@ type SpatializedContainerProps<T extends SpatializedElementRef> = Omit<StandardS
|
|
|
51
48
|
};
|
|
52
49
|
type Spatialized2DElementContainerProps<P extends ElementType> = SpatialEventProps<SpatializedElementRef> & React__default.ComponentPropsWithRef<'div'> & {
|
|
53
50
|
component: P;
|
|
51
|
+
spatialEventOptions?: SpatialEventOptions;
|
|
54
52
|
};
|
|
55
53
|
type SpatializedStatic3DContainerProps = SpatialEventProps<SpatializedStatic3DElementRef> & Omit<React__default.ComponentPropsWithoutRef<'div'>, 'onLoad' | 'onError'> & {
|
|
56
54
|
src?: string;
|
|
57
55
|
onLoad?: (event: ModelLoadEvent) => void;
|
|
58
56
|
onError?: (event: ModelLoadEvent) => void;
|
|
57
|
+
spatialEventOptions?: SpatialEventOptions;
|
|
59
58
|
};
|
|
60
59
|
type SpatializedElementRef<T extends HTMLElement = HTMLElement> = T;
|
|
61
60
|
type SpatializedDivElementRef = SpatializedElementRef<HTMLDivElement>;
|
|
@@ -130,13 +129,11 @@ declare const SpatializedStatic3DElementContainer: React$1.ForwardRefExoticCompo
|
|
|
130
129
|
src?: string;
|
|
131
130
|
onLoad?: (event: ModelLoadEvent) => void;
|
|
132
131
|
onError?: (event: ModelLoadEvent) => void;
|
|
132
|
+
spatialEventOptions?: SpatialEventOptions;
|
|
133
133
|
} & React$1.RefAttributes<SpatializedStatic3DElementRef>>;
|
|
134
134
|
|
|
135
135
|
declare function withSpatialized2DElementContainer<P extends ElementType>(Component: P): P | React$1.ForwardRefExoticComponent<Omit<Spatialized2DElementContainerProps<P>, "ref"> & React$1.RefAttributes<HTMLElement>>;
|
|
136
136
|
|
|
137
|
-
declare function toSceneSpatial(point: Point3D, spatializedElement: SpatializedElementRef): DOMPoint;
|
|
138
|
-
declare function toLocalSpace(point: Point3D, spatializedElement: SpatializedElementRef): DOMPoint;
|
|
139
|
-
|
|
140
137
|
declare function initPolyfill(): void;
|
|
141
138
|
|
|
142
139
|
declare function withSpatialMonitor(El: React__default.ElementType): any;
|
|
@@ -155,13 +152,17 @@ declare class ResourceRegistry {
|
|
|
155
152
|
destroy(): void;
|
|
156
153
|
}
|
|
157
154
|
|
|
158
|
-
type
|
|
155
|
+
type ContainerEntry = {
|
|
156
|
+
instanceId: string;
|
|
157
|
+
container: HTMLElement;
|
|
158
|
+
};
|
|
159
|
+
type ContainersChangeCallback = (containers: ContainerEntry[]) => void;
|
|
159
160
|
declare class AttachmentRegistry {
|
|
160
161
|
private containers;
|
|
161
162
|
private listeners;
|
|
162
163
|
addContainer(name: string, instanceId: string, container: HTMLElement): void;
|
|
163
164
|
removeContainer(name: string, instanceId: string): void;
|
|
164
|
-
getContainers(name: string):
|
|
165
|
+
getContainers(name: string): ContainerEntry[];
|
|
165
166
|
onContainersChange(name: string, cb: ContainersChangeCallback): () => void;
|
|
166
167
|
private notifyListeners;
|
|
167
168
|
destroy(): void;
|
|
@@ -203,6 +204,7 @@ type EntityProps = {
|
|
|
203
204
|
position?: Vec3;
|
|
204
205
|
rotation?: Vec3;
|
|
205
206
|
scale?: Vec3;
|
|
207
|
+
enableInput?: boolean;
|
|
206
208
|
};
|
|
207
209
|
type allTarget<T extends EntityRefShape> = {
|
|
208
210
|
target: T;
|
|
@@ -243,6 +245,7 @@ type EntityEventHandler = {
|
|
|
243
245
|
onSpatialDragStart?: (event: SpatialDragStartEntityEvent) => void;
|
|
244
246
|
onSpatialDrag?: (event: SpatialDragEntityEvent) => void;
|
|
245
247
|
onSpatialDragEnd?: (event: SpatialDragEndEntityEvent) => void;
|
|
248
|
+
spatialEventOptions?: SpatialEventOptions;
|
|
246
249
|
onSpatialRotate?: (event: SpatialRotateEntityEvent) => void;
|
|
247
250
|
onSpatialRotateEnd?: (event: SpatialRotateEndEntityEvent) => void;
|
|
248
251
|
onSpatialMagnify?: (event: SpatialMagnifyEntityEvent) => void;
|
|
@@ -253,45 +256,43 @@ declare const eventMap: {
|
|
|
253
256
|
readonly onSpatialDragStart: "spatialdragstart";
|
|
254
257
|
readonly onSpatialDrag: "spatialdrag";
|
|
255
258
|
readonly onSpatialDragEnd: "spatialdragend";
|
|
256
|
-
readonly onSpatialRotateStart: "spatialrotatestart";
|
|
257
259
|
readonly onSpatialRotate: "spatialrotate";
|
|
258
260
|
readonly onSpatialRotateEnd: "spatialrotateend";
|
|
259
|
-
readonly onSpatialMagnifyStart: "spatialmagnifystart";
|
|
260
261
|
readonly onSpatialMagnify: "spatialmagnify";
|
|
261
262
|
readonly onSpatialMagnifyEnd: "spatialmagnifyend";
|
|
262
263
|
};
|
|
263
264
|
|
|
264
|
-
declare const Entity: React__default.ForwardRefExoticComponent<EntityProps &
|
|
265
|
+
declare const Entity: React__default.ForwardRefExoticComponent<EntityProps & {
|
|
265
266
|
children?: React__default.ReactNode;
|
|
266
267
|
} & React__default.RefAttributes<EntityRefShape>>;
|
|
267
268
|
|
|
268
|
-
declare const BoxEntity: React__default.ForwardRefExoticComponent<EntityProps &
|
|
269
|
+
declare const BoxEntity: React__default.ForwardRefExoticComponent<EntityProps & {
|
|
269
270
|
children?: React__default.ReactNode;
|
|
270
271
|
materials?: string[];
|
|
271
272
|
} & SpatialBoxGeometryOptions & React__default.RefAttributes<EntityRefShape>>;
|
|
272
273
|
|
|
273
|
-
type
|
|
274
|
+
type UnlitMaterialProps = {
|
|
274
275
|
children?: React__default.ReactNode;
|
|
275
276
|
id: string;
|
|
276
277
|
} & SpatialUnlitMaterialOptions;
|
|
277
|
-
declare const UnlitMaterial: React__default.FC<
|
|
278
|
+
declare const UnlitMaterial: React__default.FC<UnlitMaterialProps>;
|
|
278
279
|
|
|
279
|
-
declare const SphereEntity: React__default.ForwardRefExoticComponent<EntityProps &
|
|
280
|
+
declare const SphereEntity: React__default.ForwardRefExoticComponent<EntityProps & {
|
|
280
281
|
children?: React__default.ReactNode;
|
|
281
282
|
materials?: string[];
|
|
282
283
|
} & SpatialSphereGeometryOptions & React__default.RefAttributes<EntityRefShape>>;
|
|
283
284
|
|
|
284
|
-
declare const ConeEntity: React__default.ForwardRefExoticComponent<EntityProps &
|
|
285
|
+
declare const ConeEntity: React__default.ForwardRefExoticComponent<EntityProps & {
|
|
285
286
|
children?: React__default.ReactNode;
|
|
286
287
|
materials?: string[];
|
|
287
288
|
} & SpatialConeGeometryOptions & React__default.RefAttributes<EntityRefShape>>;
|
|
288
289
|
|
|
289
|
-
declare const CylinderEntity: React__default.ForwardRefExoticComponent<EntityProps &
|
|
290
|
+
declare const CylinderEntity: React__default.ForwardRefExoticComponent<EntityProps & {
|
|
290
291
|
children?: React__default.ReactNode;
|
|
291
292
|
materials?: string[];
|
|
292
293
|
} & SpatialCylinderGeometryOptions & React__default.RefAttributes<EntityRefShape>>;
|
|
293
294
|
|
|
294
|
-
declare const PlaneEntity: React__default.ForwardRefExoticComponent<EntityProps &
|
|
295
|
+
declare const PlaneEntity: React__default.ForwardRefExoticComponent<EntityProps & {
|
|
295
296
|
children?: React__default.ReactNode;
|
|
296
297
|
materials?: string[];
|
|
297
298
|
} & SpatialPlaneGeometryOptions & React__default.RefAttributes<EntityRefShape>>;
|
|
@@ -312,10 +313,11 @@ declare const ModelAsset: React__default.FC<Props>;
|
|
|
312
313
|
|
|
313
314
|
declare const ModelEntity: React__default.ForwardRefExoticComponent<EntityProps & {
|
|
314
315
|
model: string;
|
|
315
|
-
} &
|
|
316
|
+
} & {
|
|
316
317
|
children?: React__default.ReactNode;
|
|
317
318
|
} & React__default.RefAttributes<EntityRefShape>>;
|
|
318
319
|
|
|
320
|
+
type RealityProps = React__default.ComponentPropsWithRef<'div'> & EntityEventHandler;
|
|
319
321
|
declare const Reality: React__default.ForwardRefExoticComponent<Omit<RealityProps, "ref"> & React__default.RefAttributes<HTMLElement>>;
|
|
320
322
|
|
|
321
323
|
type AttachmentAssetProps = {
|
|
@@ -324,16 +326,21 @@ type AttachmentAssetProps = {
|
|
|
324
326
|
};
|
|
325
327
|
declare const AttachmentAsset: React__default.FC<AttachmentAssetProps>;
|
|
326
328
|
|
|
327
|
-
|
|
329
|
+
type AttachmentEntityProps = {
|
|
328
330
|
attachment: string;
|
|
329
331
|
position?: [number, number, number];
|
|
330
332
|
size: {
|
|
331
333
|
width: number;
|
|
332
334
|
height: number;
|
|
333
335
|
};
|
|
334
|
-
}
|
|
336
|
+
};
|
|
335
337
|
declare const AttachmentEntity: React__default.FC<AttachmentEntityProps>;
|
|
336
338
|
|
|
339
|
+
type MaterialProps = {
|
|
340
|
+
type: 'unlit';
|
|
341
|
+
} & UnlitMaterialProps;
|
|
342
|
+
declare const Material: React__default.FC<MaterialProps>;
|
|
343
|
+
|
|
337
344
|
type ModelProps = SpatializedStatic3DContainerProps & {
|
|
338
345
|
'enable-xr'?: boolean;
|
|
339
346
|
};
|
|
@@ -351,6 +358,7 @@ declare const Model: React$1.ForwardRefExoticComponent<Omit<{
|
|
|
351
358
|
src?: string;
|
|
352
359
|
onLoad?: (event: ModelLoadEvent) => void;
|
|
353
360
|
onError?: (event: ModelLoadEvent) => void;
|
|
361
|
+
spatialEventOptions?: SpatialEventOptions;
|
|
354
362
|
} & {
|
|
355
363
|
'enable-xr'?: boolean;
|
|
356
364
|
} & React$1.RefAttributes<SpatializedStatic3DElementRef>, "ref"> & React$1.RefAttributes<any>>;
|
|
@@ -360,6 +368,26 @@ declare const SSRProvider: ({ isSSR: initialIsSSR, children, }: {
|
|
|
360
368
|
children: React__default.ReactNode;
|
|
361
369
|
}) => react_jsx_runtime.JSX.Element;
|
|
362
370
|
|
|
371
|
+
declare function useMetrics(): {
|
|
372
|
+
pointToPhysical: typeof PhysicalMetrics.pointToPhysical;
|
|
373
|
+
physicalToPoint: typeof PhysicalMetrics.physicalToPoint;
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
declare function createElement(...args: Parameters<typeof createElement$1>): React$1.DetailedReactHTMLElement<React$1.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
377
|
+
|
|
378
|
+
/**
|
|
379
|
+
* const e2e = await convertCoordinate(position, { from: elementOrEntity, to: elementOrEntity })
|
|
380
|
+
const e2w = await convertCoordinate(position, { from: elementOrEntity, to: window })
|
|
381
|
+
const w2e = await convertCoordinate(position, { from: window, to: elementOrEntity })
|
|
382
|
+
*
|
|
383
|
+
*/
|
|
384
|
+
|
|
385
|
+
type CoordinateConvertible = Window | SpatializedElementRef<any> | EntityRef | ModelRef;
|
|
386
|
+
declare function convertCoordinate(position: Vec3, { from, to }: {
|
|
387
|
+
from: CoordinateConvertible;
|
|
388
|
+
to: CoordinateConvertible;
|
|
389
|
+
}): Promise<Vec3>;
|
|
390
|
+
|
|
363
391
|
declare const version: string;
|
|
364
392
|
|
|
365
|
-
export { AttachmentAsset, AttachmentEntity, BoxEntity, ConeEntity, CylinderEntity, Entity, type EntityEventHandler, type EntityProps, EntityRef, Model, ModelAsset, ModelEntity, type ModelLoadEvent, type ModelProps, type ModelRef, type ModelSpatialDragEndEvent, type ModelSpatialDragEvent, type ModelSpatialDragStartEvent, type ModelSpatialMagnifyEndEvent, type ModelSpatialMagnifyEvent, type ModelSpatialRotateEndEvent, type ModelSpatialRotateEvent, type ModelSpatialTapEvent, PlaneEntity, Reality, SSRProvider, SceneGraph, type SpatialDragEndEntityEvent, type SpatialDragEndEvent, type SpatialDragEntityEvent, type SpatialDragEvent, type SpatialDragStartEntityEvent, type SpatialDragStartEvent, type SpatialMagnifyEndEntityEvent, type SpatialMagnifyEndEvent, type SpatialMagnifyEntityEvent, type SpatialMagnifyEvent, SpatialMonitor, type SpatialRotateEndEntityEvent, type SpatialRotateEndEvent, type SpatialRotateEntityEvent, type SpatialRotateEvent, type SpatialTapEntityEvent, type SpatialTapEvent, Spatialized2DElementContainer, type Spatialized2DElementContainerProps, SpatializedContainer, type SpatializedElementRef, type SpatializedStatic3DContainerProps, SpatializedStatic3DElementContainer, type SpatializedStatic3DElementRef, SphereEntity, UnlitMaterial, enableDebugTool, eventMap, initPolyfill, initScene,
|
|
393
|
+
export { AttachmentAsset, AttachmentEntity, BoxEntity as Box, BoxEntity, ConeEntity as Cone, ConeEntity, CylinderEntity as Cylinder, CylinderEntity, Entity, type EntityEventHandler, type EntityProps, EntityRef, Material, type MaterialProps, Model, ModelAsset, ModelEntity, type ModelLoadEvent, type ModelProps, type ModelRef, type ModelSpatialDragEndEvent, type ModelSpatialDragEvent, type ModelSpatialDragStartEvent, type ModelSpatialMagnifyEndEvent, type ModelSpatialMagnifyEvent, type ModelSpatialRotateEndEvent, type ModelSpatialRotateEvent, type ModelSpatialTapEvent, PlaneEntity as Plane, PlaneEntity, Reality, type RealityProps, SSRProvider, SceneGraph, type SpatialDragEndEntityEvent, type SpatialDragEndEvent, type SpatialDragEntityEvent, type SpatialDragEvent, type SpatialDragStartEntityEvent, type SpatialDragStartEvent, type SpatialEventOptions, type SpatialMagnifyEndEntityEvent, type SpatialMagnifyEndEvent, type SpatialMagnifyEntityEvent, type SpatialMagnifyEvent, SpatialMonitor, type SpatialRotateEndEntityEvent, type SpatialRotateEndEvent, type SpatialRotateEntityEvent, type SpatialRotateEvent, type SpatialTapEntityEvent, type SpatialTapEvent, Spatialized2DElementContainer, type Spatialized2DElementContainerProps, SpatializedContainer, type SpatializedElementRef, type SpatializedStatic3DContainerProps, SpatializedStatic3DElementContainer, type SpatializedStatic3DElementRef, SphereEntity as Sphere, SphereEntity, UnlitMaterial, type UnlitMaterialProps, SceneGraph as World, convertCoordinate, createElement, enableDebugTool, eventMap, initPolyfill, initScene, useMetrics, version, withSpatialMonitor, withSpatialized2DElementContainer };
|