@neurodyn/react-model-viewer 0.1.0 → 0.2.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/index.d.ts +40 -2
- package/dist/index.js +90 -15
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,15 +3,50 @@ import { JSX } from 'react/jsx-runtime';
|
|
|
3
3
|
import type { default as React_2 } from 'react';
|
|
4
4
|
import * as React_3 from 'react';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* How long a tap may wait on a host's own AR before the native launch goes
|
|
8
|
+
* ahead instead.
|
|
9
|
+
*
|
|
10
|
+
* Chrome lets a page navigate on behalf of a tap for about five seconds, and
|
|
11
|
+
* the Scene Viewer intent is such a navigation: sent any later, the browser
|
|
12
|
+
* drops it as one nobody asked for. A host that loads its AR on the tap races
|
|
13
|
+
* the load against this, so a slow connection gets Scene Viewer for this tap
|
|
14
|
+
* and the host's AR for the next, the download having gone on meanwhile.
|
|
15
|
+
*/
|
|
16
|
+
export declare const AR_TAP_WINDOW_MS = 3000;
|
|
17
|
+
|
|
6
18
|
/** What the host needs to open its own AR experience for the shown model. */
|
|
7
19
|
export declare interface ArLaunchTarget {
|
|
20
|
+
/**
|
|
21
|
+
* The API the viewer's widget session was issued by, when the host set one.
|
|
22
|
+
* A host continuing that session has to refresh it there.
|
|
23
|
+
*/
|
|
24
|
+
apiBaseUrl?: string;
|
|
25
|
+
/**
|
|
26
|
+
* The public key the viewer runs on — including one a QR handoff code
|
|
27
|
+
* resolved, which the host page never saw.
|
|
28
|
+
*/
|
|
29
|
+
apiKey?: string;
|
|
8
30
|
/** Material collection currently shown, which may differ from the entry url. */
|
|
9
31
|
hid?: string;
|
|
32
|
+
/** The viewer's UI language, so the host's AR speaks the same one. */
|
|
33
|
+
lang?: 'en' | 'ru';
|
|
34
|
+
/** The object's display name, for the host AR's accessible label. */
|
|
35
|
+
name?: string;
|
|
10
36
|
tinuuid: string;
|
|
37
|
+
/**
|
|
38
|
+
* A live token of the viewer's widget session, so the host's AR continues
|
|
39
|
+
* that session instead of activating a second one.
|
|
40
|
+
*/
|
|
41
|
+
widgetSessionToken?: string;
|
|
11
42
|
}
|
|
12
43
|
|
|
13
44
|
declare type DialogProps = React_3.ComponentProps<typeof DialogPrimitive.Root>
|
|
14
45
|
|
|
46
|
+
export declare function isIOSDevice(): boolean;
|
|
47
|
+
|
|
48
|
+
export declare function isMobileArDevice(): boolean;
|
|
49
|
+
|
|
15
50
|
/**
|
|
16
51
|
* Lets the host open its own AR experience instead of the native one.
|
|
17
52
|
*
|
|
@@ -27,9 +62,9 @@ export declare type ModelViewerArExperience = 'advanced' | 'standard';
|
|
|
27
62
|
|
|
28
63
|
declare type ModelViewerBackground = 'default' | 'transparent';
|
|
29
64
|
|
|
30
|
-
export declare function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, appClipBundleId, initialWidgetSessionToken, handoffUrl, hid, lang, mode, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, ...props }: ModelViewerDialogProps): JSX.Element;
|
|
65
|
+
export declare function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, appClipBundleId, initialWidgetSessionToken, handoffUrl, hid, lang, launchAr, mode, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, ...props }: ModelViewerDialogProps): JSX.Element;
|
|
31
66
|
|
|
32
|
-
export declare interface ModelViewerDialogProps extends Pick<ModelViewerRootProps, 'apiBaseUrl' | 'apiKey' | 'appClipBundleId' | 'cameraOrbit' | 'dimensionAxes' | 'handoffUrl' | 'hid' | 'initialWidgetSessionToken' | 'lang' | 'maxCameraOrbit' | 'minCameraOrbit' | 'mode' | 'sizeType' | 'tinuuid'>, Omit<DialogProps, 'children' | 'open' | 'defaultOpen' | 'onOpenChange' | 'modal'> {
|
|
67
|
+
export declare interface ModelViewerDialogProps extends Pick<ModelViewerRootProps, 'apiBaseUrl' | 'apiKey' | 'appClipBundleId' | 'cameraOrbit' | 'dimensionAxes' | 'handoffUrl' | 'hid' | 'initialWidgetSessionToken' | 'lang' | 'launchAr' | 'maxCameraOrbit' | 'minCameraOrbit' | 'mode' | 'sizeType' | 'tinuuid'>, Omit<DialogProps, 'children' | 'open' | 'defaultOpen' | 'onOpenChange' | 'modal'> {
|
|
33
68
|
/** The controlled open state of the dialog. Use with `onOpenChange`. */
|
|
34
69
|
open?: DialogProps['open'];
|
|
35
70
|
/** The initial open state when the dialog is uncontrolled. */
|
|
@@ -99,4 +134,7 @@ export declare type SizeAxis = 'x' | 'y' | 'z';
|
|
|
99
134
|
|
|
100
135
|
export declare type SizeType = 'cm' | 'inch';
|
|
101
136
|
|
|
137
|
+
/** The value, or `null` once the tap's window has passed; a rejection still rejects. */
|
|
138
|
+
export declare function withinTapWindow<T>(promise: Promise<T>, windowMs?: number): Promise<T | null>;
|
|
139
|
+
|
|
102
140
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -478,6 +478,10 @@ var __webpack_modules__ = {
|
|
|
478
478
|
position: static;
|
|
479
479
|
}
|
|
480
480
|
|
|
481
|
+
.sticky {
|
|
482
|
+
position: sticky;
|
|
483
|
+
}
|
|
484
|
+
|
|
481
485
|
.inset-0 {
|
|
482
486
|
inset: calc(var(--spacing) * 0);
|
|
483
487
|
}
|
|
@@ -6365,12 +6369,18 @@ function shouldRetryViewerQuery(failureCount, error) {
|
|
|
6365
6369
|
return failureCount < 2;
|
|
6366
6370
|
}
|
|
6367
6371
|
const WIDGET_SESSION_TOKEN_HEADER = 'x-widget-session-token';
|
|
6372
|
+
const APP_TYPE_HEADER = 'x-app-type';
|
|
6368
6373
|
const DEFAULT_REFRESH_THRESHOLD_MS = 30000;
|
|
6369
6374
|
const ALLOWED_PRODUCT_TYPES = new Set([
|
|
6370
6375
|
'core-ar',
|
|
6371
6376
|
'core-ar-shopify'
|
|
6372
6377
|
]);
|
|
6373
6378
|
const ASSUMED_HANDOFF_SESSION_TTL_SECONDS = 900;
|
|
6379
|
+
function getAppTypeHeaders(appType) {
|
|
6380
|
+
return appType ? {
|
|
6381
|
+
[APP_TYPE_HEADER]: appType
|
|
6382
|
+
} : {};
|
|
6383
|
+
}
|
|
6374
6384
|
async function activateCoreArWidgetSession(mode, requestConfig) {
|
|
6375
6385
|
const activation = await publicApiControllerActivateCoreAR({
|
|
6376
6386
|
mode
|
|
@@ -6381,6 +6391,7 @@ async function activateCoreArWidgetSession(mode, requestConfig) {
|
|
|
6381
6391
|
class ModelViewerWidgetSession {
|
|
6382
6392
|
apiBaseUrl;
|
|
6383
6393
|
apiKey;
|
|
6394
|
+
appTypeHeaders;
|
|
6384
6395
|
issueWidgetToken;
|
|
6385
6396
|
mode;
|
|
6386
6397
|
now;
|
|
@@ -6390,6 +6401,7 @@ class ModelViewerWidgetSession {
|
|
|
6390
6401
|
constructor(activationData, options){
|
|
6391
6402
|
this.apiBaseUrl = options.apiBaseUrl;
|
|
6392
6403
|
this.apiKey = options.apiKey;
|
|
6404
|
+
this.appTypeHeaders = getAppTypeHeaders(options.appType);
|
|
6393
6405
|
this.issueWidgetToken = options.issueWidgetToken ?? publicApiControllerIssueWidgetToken;
|
|
6394
6406
|
this.mode = options.mode;
|
|
6395
6407
|
this.now = options.now ?? Date.now;
|
|
@@ -6415,6 +6427,7 @@ class ModelViewerWidgetSession {
|
|
|
6415
6427
|
return {
|
|
6416
6428
|
baseURL: this.apiBaseUrl,
|
|
6417
6429
|
headers: {
|
|
6430
|
+
...this.appTypeHeaders,
|
|
6418
6431
|
[WIDGET_SESSION_TOKEN_HEADER]: await this.getTokenForRequest()
|
|
6419
6432
|
},
|
|
6420
6433
|
signal
|
|
@@ -6427,6 +6440,7 @@ class ModelViewerWidgetSession {
|
|
|
6427
6440
|
this.session = this.toSnapshot(await activateCoreArWidgetSession(this.mode, {
|
|
6428
6441
|
baseURL: this.apiBaseUrl,
|
|
6429
6442
|
headers: {
|
|
6443
|
+
...this.appTypeHeaders,
|
|
6430
6444
|
'x-api-key': this.apiKey
|
|
6431
6445
|
},
|
|
6432
6446
|
signal
|
|
@@ -6441,6 +6455,7 @@ class ModelViewerWidgetSession {
|
|
|
6441
6455
|
}, {
|
|
6442
6456
|
baseURL: this.apiBaseUrl,
|
|
6443
6457
|
headers: {
|
|
6458
|
+
...this.appTypeHeaders,
|
|
6444
6459
|
'x-api-key': this.apiKey
|
|
6445
6460
|
}
|
|
6446
6461
|
}).then((data)=>this.toSnapshot(parseWidgetSession(data))).then((session)=>{
|
|
@@ -6458,7 +6473,7 @@ class ModelViewerWidgetSession {
|
|
|
6458
6473
|
};
|
|
6459
6474
|
}
|
|
6460
6475
|
}
|
|
6461
|
-
async function createModelViewerWidgetSession({ apiBaseUrl, apiKey, initialWidgetSessionToken, mode, signal }) {
|
|
6476
|
+
async function createModelViewerWidgetSession({ apiBaseUrl, apiKey, appType, initialWidgetSessionToken, mode, signal }) {
|
|
6462
6477
|
if (initialWidgetSessionToken) return new ModelViewerWidgetSession({
|
|
6463
6478
|
expiresIn: ASSUMED_HANDOFF_SESSION_TTL_SECONDS,
|
|
6464
6479
|
sid: initialWidgetSessionToken,
|
|
@@ -6466,11 +6481,13 @@ async function createModelViewerWidgetSession({ apiBaseUrl, apiKey, initialWidge
|
|
|
6466
6481
|
}, {
|
|
6467
6482
|
apiBaseUrl,
|
|
6468
6483
|
apiKey,
|
|
6484
|
+
appType,
|
|
6469
6485
|
mode
|
|
6470
6486
|
});
|
|
6471
6487
|
const activationData = await activateCoreArWidgetSession(mode, {
|
|
6472
6488
|
baseURL: apiBaseUrl,
|
|
6473
6489
|
headers: {
|
|
6490
|
+
...getAppTypeHeaders(appType),
|
|
6474
6491
|
'x-api-key': apiKey
|
|
6475
6492
|
},
|
|
6476
6493
|
signal
|
|
@@ -6478,6 +6495,7 @@ async function createModelViewerWidgetSession({ apiBaseUrl, apiKey, initialWidge
|
|
|
6478
6495
|
return new ModelViewerWidgetSession(activationData, {
|
|
6479
6496
|
apiBaseUrl,
|
|
6480
6497
|
apiKey,
|
|
6498
|
+
appType,
|
|
6481
6499
|
mode
|
|
6482
6500
|
});
|
|
6483
6501
|
}
|
|
@@ -6533,12 +6551,13 @@ async function issueWidgetHandoffCode(session, params) {
|
|
|
6533
6551
|
expiresIn: data.expiresIn
|
|
6534
6552
|
};
|
|
6535
6553
|
}
|
|
6536
|
-
async function resolveWidgetHandoffCode(apiBaseUrl, code) {
|
|
6554
|
+
async function resolveWidgetHandoffCode(apiBaseUrl, code, appType) {
|
|
6537
6555
|
try {
|
|
6538
6556
|
const data = await widgetHandoffControllerResolveHandoff({
|
|
6539
6557
|
code
|
|
6540
6558
|
}, {
|
|
6541
|
-
baseURL: apiBaseUrl
|
|
6559
|
+
baseURL: apiBaseUrl,
|
|
6560
|
+
headers: getAppTypeHeaders(appType)
|
|
6542
6561
|
});
|
|
6543
6562
|
if (!data?.apiKey || !data.token) return null;
|
|
6544
6563
|
return {
|
|
@@ -6593,6 +6612,7 @@ function useObjectData(tinuuid, initialHid, options) {
|
|
|
6593
6612
|
{
|
|
6594
6613
|
apiBaseUrl: options.apiBaseUrl ?? null,
|
|
6595
6614
|
apiKey: options.apiKey,
|
|
6615
|
+
appType: options.appType ?? null,
|
|
6596
6616
|
handoffCode: options.handoffCode ?? null,
|
|
6597
6617
|
initialHid: initialHid ?? null,
|
|
6598
6618
|
initialWidgetSessionToken: options.initialWidgetSessionToken ?? null,
|
|
@@ -6605,12 +6625,13 @@ function useObjectData(tinuuid, initialHid, options) {
|
|
|
6605
6625
|
refetchOnMount: 'always',
|
|
6606
6626
|
queryFn: async ({ signal })=>{
|
|
6607
6627
|
if (options.handoffCode) {
|
|
6608
|
-
const resolved = readHandoffResolution(options.handoffCode) ?? await resolveWidgetHandoffCode(options.apiBaseUrl ?? window.location.origin, options.handoffCode);
|
|
6628
|
+
const resolved = readHandoffResolution(options.handoffCode) ?? await resolveWidgetHandoffCode(options.apiBaseUrl ?? window.location.origin, options.handoffCode, options.appType);
|
|
6609
6629
|
if (!resolved) throw new WidgetHandoffExpiredError();
|
|
6610
6630
|
rememberHandoffResolution(options.handoffCode, resolved);
|
|
6611
6631
|
const widgetSession = await createModelViewerWidgetSession({
|
|
6612
6632
|
apiBaseUrl: options.apiBaseUrl,
|
|
6613
6633
|
apiKey: resolved.apiKey,
|
|
6634
|
+
appType: options.appType,
|
|
6614
6635
|
initialWidgetSessionToken: resolved.token,
|
|
6615
6636
|
mode: options.mode,
|
|
6616
6637
|
signal
|
|
@@ -6626,6 +6647,7 @@ function useObjectData(tinuuid, initialHid, options) {
|
|
|
6626
6647
|
tinuuid
|
|
6627
6648
|
}, {
|
|
6628
6649
|
baseURL: options.apiBaseUrl,
|
|
6650
|
+
headers: getAppTypeHeaders(options.appType),
|
|
6629
6651
|
signal
|
|
6630
6652
|
});
|
|
6631
6653
|
return {
|
|
@@ -6636,6 +6658,7 @@ function useObjectData(tinuuid, initialHid, options) {
|
|
|
6636
6658
|
const widgetSession = await createModelViewerWidgetSession({
|
|
6637
6659
|
apiBaseUrl: options.apiBaseUrl,
|
|
6638
6660
|
apiKey: options.apiKey,
|
|
6661
|
+
appType: options.appType,
|
|
6639
6662
|
initialWidgetSessionToken: options.initialWidgetSessionToken,
|
|
6640
6663
|
mode: options.mode,
|
|
6641
6664
|
signal
|
|
@@ -6712,6 +6735,7 @@ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExp
|
|
|
6712
6735
|
const { object, material, error, isLoading, setMaterialHid: setObjectMaterialHid, widgetSession } = useObjectData(tinuuid, hid, {
|
|
6713
6736
|
apiBaseUrl,
|
|
6714
6737
|
apiKey,
|
|
6738
|
+
appType: 'ru' === lang ? 'arizo' : 'vizbl',
|
|
6715
6739
|
handoffCode,
|
|
6716
6740
|
initialWidgetSessionToken,
|
|
6717
6741
|
mode
|
|
@@ -6830,6 +6854,7 @@ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExp
|
|
|
6830
6854
|
widgetSession
|
|
6831
6855
|
]);
|
|
6832
6856
|
const contextValue = external_react_useMemo(()=>({
|
|
6857
|
+
apiBaseUrl,
|
|
6833
6858
|
apiKey,
|
|
6834
6859
|
appClipBundleId,
|
|
6835
6860
|
arExperience,
|
|
@@ -6861,6 +6886,7 @@ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExp
|
|
|
6861
6886
|
setModelViewerEl,
|
|
6862
6887
|
trackEvent
|
|
6863
6888
|
}), [
|
|
6889
|
+
apiBaseUrl,
|
|
6864
6890
|
apiKey,
|
|
6865
6891
|
appClipBundleId,
|
|
6866
6892
|
arExperience,
|
|
@@ -6974,7 +7000,20 @@ async function launchArOverride(launchAr, target) {
|
|
|
6974
7000
|
return false;
|
|
6975
7001
|
}
|
|
6976
7002
|
}
|
|
6977
|
-
|
|
7003
|
+
const AR_TAP_WINDOW_MS = 3000;
|
|
7004
|
+
function withinTapWindow(promise, windowMs = AR_TAP_WINDOW_MS) {
|
|
7005
|
+
return new Promise((resolve, reject)=>{
|
|
7006
|
+
const timer = setTimeout(()=>resolve(null), windowMs);
|
|
7007
|
+
promise.then((value)=>{
|
|
7008
|
+
clearTimeout(timer);
|
|
7009
|
+
resolve(value);
|
|
7010
|
+
}, (error)=>{
|
|
7011
|
+
clearTimeout(timer);
|
|
7012
|
+
reject(error);
|
|
7013
|
+
});
|
|
7014
|
+
});
|
|
7015
|
+
}
|
|
7016
|
+
function buildModelViewerHandoffUrl({ apiKey, arExperience, baseUrl, hid, lang, mode, tinuuid, widgetSessionToken }) {
|
|
6978
7017
|
if (!baseUrl || !tinuuid) return null;
|
|
6979
7018
|
let url;
|
|
6980
7019
|
try {
|
|
@@ -6988,6 +7027,7 @@ function buildModelViewerHandoffUrl({ apiKey, arExperience, baseUrl, hid, mode,
|
|
|
6988
7027
|
else url.searchParams.delete('ar-experience');
|
|
6989
7028
|
if (hid) url.searchParams.set('hid', hid);
|
|
6990
7029
|
else url.searchParams.delete('hid');
|
|
7030
|
+
setLang(url, lang);
|
|
6991
7031
|
const fragment = new URLSearchParams(url.hash.slice(1));
|
|
6992
7032
|
if (apiKey) fragment.set('api-key', apiKey);
|
|
6993
7033
|
else fragment.delete('api-key');
|
|
@@ -6996,7 +7036,7 @@ function buildModelViewerHandoffUrl({ apiKey, arExperience, baseUrl, hid, mode,
|
|
|
6996
7036
|
url.hash = fragment.toString();
|
|
6997
7037
|
return url.toString();
|
|
6998
7038
|
}
|
|
6999
|
-
function buildModelViewerHandoffCodeUrl({ arExperience, baseUrl, code, hid, mode, tinuuid }) {
|
|
7039
|
+
function buildModelViewerHandoffCodeUrl({ arExperience, baseUrl, code, hid, lang, mode, tinuuid }) {
|
|
7000
7040
|
if (!baseUrl || !tinuuid) return null;
|
|
7001
7041
|
let url;
|
|
7002
7042
|
try {
|
|
@@ -7010,6 +7050,7 @@ function buildModelViewerHandoffCodeUrl({ arExperience, baseUrl, code, hid, mode
|
|
|
7010
7050
|
else url.searchParams.delete('ar-experience');
|
|
7011
7051
|
if (hid) url.searchParams.set('hid', hid);
|
|
7012
7052
|
else url.searchParams.delete('hid');
|
|
7053
|
+
setLang(url, lang);
|
|
7013
7054
|
const fragment = new URLSearchParams(url.hash.slice(1));
|
|
7014
7055
|
if (code) fragment.set('code', code);
|
|
7015
7056
|
else fragment.delete('code');
|
|
@@ -7019,9 +7060,14 @@ function buildModelViewerHandoffCodeUrl({ arExperience, baseUrl, code, hid, mode
|
|
|
7019
7060
|
function handoffCodeReissueDelayMs(expiresInSeconds) {
|
|
7020
7061
|
return Math.round(1000 * expiresInSeconds * 2 / 3);
|
|
7021
7062
|
}
|
|
7063
|
+
function setLang(url, lang) {
|
|
7064
|
+
if (lang) url.searchParams.set('lang', lang);
|
|
7065
|
+
else url.searchParams.delete('lang');
|
|
7066
|
+
}
|
|
7022
7067
|
const EVENT_FLUSH_TIMEOUT_MS = 300;
|
|
7068
|
+
const LAUNCH_TOKEN_TIMEOUT_MS = 800;
|
|
7023
7069
|
const HANDOFF_CODE_RETRY_MS = 15000;
|
|
7024
|
-
async function issueHandoffQrCode(widgetSession, { arExperience, baseUrl, hid, mode, tinuuid }) {
|
|
7070
|
+
async function issueHandoffQrCode(widgetSession, { arExperience, baseUrl, hid, lang, mode, tinuuid }) {
|
|
7025
7071
|
const { code, expiresIn } = await issueWidgetHandoffCode(widgetSession, {
|
|
7026
7072
|
arExperience,
|
|
7027
7073
|
hid,
|
|
@@ -7032,6 +7078,7 @@ async function issueHandoffQrCode(widgetSession, { arExperience, baseUrl, hid, m
|
|
|
7032
7078
|
baseUrl,
|
|
7033
7079
|
code,
|
|
7034
7080
|
hid,
|
|
7081
|
+
lang,
|
|
7035
7082
|
mode,
|
|
7036
7083
|
tinuuid
|
|
7037
7084
|
});
|
|
@@ -7050,7 +7097,7 @@ async function flushWidgetEvent(eventRequest) {
|
|
|
7050
7097
|
});
|
|
7051
7098
|
}
|
|
7052
7099
|
function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
7053
|
-
const { apiKey, appClipBundleId, arExperience, containerEl, handoffUrl, isLoading, isModelLoading, lang, launchAr, material, mode, modelViewerEl, object, tinuuid, trackEvent, widgetSession } = useModelViewer();
|
|
7100
|
+
const { apiBaseUrl, apiKey, appClipBundleId, arExperience, containerEl, handoffUrl, isLoading, isModelLoading, lang, launchAr, material, mode, modelViewerEl, object, tinuuid, trackEvent, widgetSession } = useModelViewer();
|
|
7054
7101
|
const [open, setOpen] = useState(false);
|
|
7055
7102
|
const [qrState, setQrState] = useState({
|
|
7056
7103
|
status: 'loading'
|
|
@@ -7059,12 +7106,33 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7059
7106
|
const widgetSessionSid = widgetSession?.sid;
|
|
7060
7107
|
const isDisabled = isLoading || isModelLoading || null === material;
|
|
7061
7108
|
const arTarget = external_react_useMemo(()=>({
|
|
7109
|
+
apiBaseUrl,
|
|
7110
|
+
apiKey: widgetSession?.apiKey || apiKey || void 0,
|
|
7062
7111
|
hid: material?.hid,
|
|
7112
|
+
lang,
|
|
7113
|
+
name: object?.name ?? void 0,
|
|
7063
7114
|
tinuuid: object?.tinuuid ?? tinuuid
|
|
7064
7115
|
}), [
|
|
7116
|
+
apiBaseUrl,
|
|
7117
|
+
apiKey,
|
|
7118
|
+
lang,
|
|
7065
7119
|
material?.hid,
|
|
7120
|
+
object?.name,
|
|
7066
7121
|
object?.tinuuid,
|
|
7067
|
-
tinuuid
|
|
7122
|
+
tinuuid,
|
|
7123
|
+
widgetSession
|
|
7124
|
+
]);
|
|
7125
|
+
const launchHostAr = useCallback(async ()=>{
|
|
7126
|
+
if (!launchAr) return false;
|
|
7127
|
+
const widgetSessionToken = widgetSession ? await withinTapWindow(widgetSession.getTokenForRequest(), LAUNCH_TOKEN_TIMEOUT_MS).catch(()=>null) ?? widgetSession.token : void 0;
|
|
7128
|
+
return launchArOverride(launchAr, {
|
|
7129
|
+
...arTarget,
|
|
7130
|
+
widgetSessionToken
|
|
7131
|
+
});
|
|
7132
|
+
}, [
|
|
7133
|
+
arTarget,
|
|
7134
|
+
launchAr,
|
|
7135
|
+
widgetSession
|
|
7068
7136
|
]);
|
|
7069
7137
|
const directArExperience = resolveDirectArExperience(mode, arExperience);
|
|
7070
7138
|
const directArLaunchOptions = external_react_useMemo(()=>{
|
|
@@ -7112,7 +7180,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7112
7180
|
const timer = window.setTimeout(()=>{
|
|
7113
7181
|
(async ()=>{
|
|
7114
7182
|
if (autoLaunchKeyRef.current !== launchKey) return;
|
|
7115
|
-
if (await
|
|
7183
|
+
if (await launchHostAr()) return;
|
|
7116
7184
|
await flushWidgetEvent(trackEvent('ar_launched'));
|
|
7117
7185
|
if (autoLaunchKeyRef.current === launchKey) launchDirectAr(directArLaunchOptions);
|
|
7118
7186
|
})();
|
|
@@ -7122,10 +7190,9 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7122
7190
|
if (autoLaunchKeyRef.current === launchKey) autoLaunchKeyRef.current = null;
|
|
7123
7191
|
};
|
|
7124
7192
|
}, [
|
|
7125
|
-
arTarget,
|
|
7126
7193
|
directArLaunchOptions,
|
|
7127
7194
|
isLoading,
|
|
7128
|
-
|
|
7195
|
+
launchHostAr,
|
|
7129
7196
|
material?.hid,
|
|
7130
7197
|
mode,
|
|
7131
7198
|
trackEvent,
|
|
@@ -7145,6 +7212,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7145
7212
|
arExperience,
|
|
7146
7213
|
baseUrl,
|
|
7147
7214
|
hid: material?.hid,
|
|
7215
|
+
lang,
|
|
7148
7216
|
mode,
|
|
7149
7217
|
tinuuid: resolvedTinuuid
|
|
7150
7218
|
});
|
|
@@ -7161,6 +7229,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7161
7229
|
arExperience,
|
|
7162
7230
|
baseUrl,
|
|
7163
7231
|
hid: material?.hid,
|
|
7232
|
+
lang,
|
|
7164
7233
|
mode,
|
|
7165
7234
|
tinuuid: resolvedTinuuid
|
|
7166
7235
|
});
|
|
@@ -7175,6 +7244,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7175
7244
|
arExperience,
|
|
7176
7245
|
baseUrl,
|
|
7177
7246
|
hid: material?.hid,
|
|
7247
|
+
lang,
|
|
7178
7248
|
mode,
|
|
7179
7249
|
tinuuid: resolvedTinuuid,
|
|
7180
7250
|
widgetSessionToken: sessionToken
|
|
@@ -7198,6 +7268,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7198
7268
|
arExperience,
|
|
7199
7269
|
baseUrl: handoffUrl || MODEL_VIEWER_URL,
|
|
7200
7270
|
hid: material?.hid,
|
|
7271
|
+
lang,
|
|
7201
7272
|
mode,
|
|
7202
7273
|
tinuuid: object?.tinuuid ?? tinuuid
|
|
7203
7274
|
});
|
|
@@ -7219,6 +7290,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7219
7290
|
}, [
|
|
7220
7291
|
arExperience,
|
|
7221
7292
|
handoffUrl,
|
|
7293
|
+
lang,
|
|
7222
7294
|
material?.hid,
|
|
7223
7295
|
mode,
|
|
7224
7296
|
object?.tinuuid,
|
|
@@ -7229,7 +7301,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7229
7301
|
]);
|
|
7230
7302
|
const handleClick = async ()=>{
|
|
7231
7303
|
if (!modelViewerEl || isDisabled) return;
|
|
7232
|
-
if (await
|
|
7304
|
+
if (await launchHostAr()) return void onBeforeActivateAr?.();
|
|
7233
7305
|
if (directArLaunchOptions && isMobileArDevice()) {
|
|
7234
7306
|
onBeforeActivateAr?.();
|
|
7235
7307
|
await flushWidgetEvent(trackEvent('ar_launched'));
|
|
@@ -8066,7 +8138,7 @@ function ModelViewerRoot({ tinuuid, apiKey, appClipBundleId = 'com.us.vizbl.Clip
|
|
|
8066
8138
|
})
|
|
8067
8139
|
});
|
|
8068
8140
|
}
|
|
8069
|
-
function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, appClipBundleId, initialWidgetSessionToken, handoffUrl, hid, lang = 'en', mode = 'ar-viewer', sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, ...props }) {
|
|
8141
|
+
function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, appClipBundleId, initialWidgetSessionToken, handoffUrl, hid, lang = 'en', launchAr, mode = 'ar-viewer', sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, ...props }) {
|
|
8070
8142
|
const [container, setContainer] = useState(null);
|
|
8071
8143
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
8072
8144
|
children: [
|
|
@@ -8107,6 +8179,7 @@ function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, appClipBundleId, initi
|
|
|
8107
8179
|
lang: lang,
|
|
8108
8180
|
handoffUrl: handoffUrl,
|
|
8109
8181
|
hid: hid,
|
|
8182
|
+
launchAr: launchAr,
|
|
8110
8183
|
sizeType: sizeType,
|
|
8111
8184
|
dimensionAxes: dimensionAxes,
|
|
8112
8185
|
cameraOrbit: cameraOrbit,
|
|
@@ -8123,6 +8196,7 @@ function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, appClipBundleId, initi
|
|
|
8123
8196
|
style: {
|
|
8124
8197
|
display: 'block',
|
|
8125
8198
|
letterSpacing: 'normal',
|
|
8199
|
+
position: 'relative',
|
|
8126
8200
|
zIndex: 2147483647
|
|
8127
8201
|
},
|
|
8128
8202
|
children: [
|
|
@@ -8197,4 +8271,5 @@ function ModelViewer({ tinuuid, apiKey, appClipBundleId, arExperience, hid, apiB
|
|
|
8197
8271
|
]
|
|
8198
8272
|
});
|
|
8199
8273
|
}
|
|
8200
|
-
|
|
8274
|
+
var __webpack_exports__AR_TAP_WINDOW_MS = 3000;
|
|
8275
|
+
export { ModelViewer, ModelViewerDialog, isIOSDevice, isMobileArDevice, withinTapWindow, __webpack_exports__AR_TAP_WINDOW_MS as AR_TAP_WINDOW_MS };
|