@neurodyn/react-model-viewer 0.0.8 → 0.0.10
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 +5 -1
- package/dist/index.js +50 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare type DialogProps = React_3.ComponentProps<typeof DialogPrimitive.Root>
|
|
|
21
21
|
*/
|
|
22
22
|
export declare type LaunchArOverride = (target: ArLaunchTarget) => boolean | Promise<boolean>;
|
|
23
23
|
|
|
24
|
-
export declare function ModelViewer({ tinuuid, apiKey, appClipBundleId, arExperience, hid, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, handoffUrl, launchAr, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, layout, background, viewerSurface, className, ...props }: ModelViewerProps & React_2.ComponentProps<'div'>): JSX.Element;
|
|
24
|
+
export declare function ModelViewer({ tinuuid, apiKey, appClipBundleId, arExperience, hid, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, lang, handoffUrl, launchAr, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, layout, background, viewerSurface, className, ...props }: ModelViewerProps & React_2.ComponentProps<'div'>): JSX.Element;
|
|
25
25
|
|
|
26
26
|
export declare type ModelViewerArExperience = 'advanced' | 'standard';
|
|
27
27
|
|
|
@@ -32,6 +32,8 @@ export declare function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, legacyA
|
|
|
32
32
|
declare interface ModelViewerDialogProps extends Pick<ModelViewerRootProps, 'apiBaseUrl' | 'apiKey' | 'dimensionAxes' | 'handoffUrl' | 'hid' | 'initialWidgetSessionToken' | 'legacyApiBaseUrl' | 'sizeType' | 'tinuuid'>, Omit<DialogProps, 'children'> {
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export declare type ModelViewerLanguage = 'en' | 'ru';
|
|
36
|
+
|
|
35
37
|
declare type ModelViewerLayout = 'default' | 'model';
|
|
36
38
|
|
|
37
39
|
export declare interface ModelViewerProps extends Omit<ModelViewerRootProps, 'showDialogCloseButton'> {
|
|
@@ -56,6 +58,8 @@ declare interface ModelViewerRootProps {
|
|
|
56
58
|
mode?: ModelViewerWidgetMode;
|
|
57
59
|
/** Existing token used to preserve the same widget session across a handoff. */
|
|
58
60
|
initialWidgetSessionToken?: string;
|
|
61
|
+
/** UI language. Defaults to English. */
|
|
62
|
+
lang?: ModelViewerLanguage;
|
|
59
63
|
/** Hosted viewer URL encoded into the desktop-to-mobile QR handoff. */
|
|
60
64
|
handoffUrl?: string;
|
|
61
65
|
/** Lets the host open its own AR experience instead of the native handoff. */
|
package/dist/index.js
CHANGED
|
@@ -1859,6 +1859,10 @@ button, input:where([type="button"], [type="reset"], [type="submit"]) {
|
|
|
1859
1859
|
padding-bottom: 5px;
|
|
1860
1860
|
}
|
|
1861
1861
|
|
|
1862
|
+
.pl-2 {
|
|
1863
|
+
padding-left: calc(var(--spacing) * 2);
|
|
1864
|
+
}
|
|
1865
|
+
|
|
1862
1866
|
.pl-3 {
|
|
1863
1867
|
padding-left: calc(var(--spacing) * 3);
|
|
1864
1868
|
}
|
|
@@ -4262,6 +4266,10 @@ button, input:where([type="button"], [type="reset"], [type="submit"]) {
|
|
|
4262
4266
|
color: var(--v-text-dark);
|
|
4263
4267
|
}
|
|
4264
4268
|
|
|
4269
|
+
.data-\\[variant\\=destructive\\]\\:\\[\\&_svg\\:not\\(\\[class\\*\\=text-\\]\\)\\]\\:text-inherit[data-variant="destructive"] svg:not([class*="text-"]) {
|
|
4270
|
+
color: inherit;
|
|
4271
|
+
}
|
|
4272
|
+
|
|
4265
4273
|
.\\[\\&_tr\\]\\:border-b tr {
|
|
4266
4274
|
border-bottom-style: var(--tw-border-style);
|
|
4267
4275
|
border-bottom-width: 1px;
|
|
@@ -5731,6 +5739,7 @@ const PROPERTY_BLOCK_RE = /@property\s+(--[^{\s]+)\s*\{([^}]*)\}/g;
|
|
|
5731
5739
|
const INITIAL_VALUE_RE = /initial-value:([^;}]+)/i;
|
|
5732
5740
|
const NON_INHERITING_RE = /inherits:\s*false(?:\s*;|\s*$)/i;
|
|
5733
5741
|
const ROOT_TO_HOST_SELECTOR_RE = /:root\s*,\s*:host|:root/g;
|
|
5742
|
+
const SHADOW_HOST_VISIBILITY_CSS = ':host{display:block!important;visibility:visible!important}';
|
|
5734
5743
|
function createShadowRootCssText(cssText) {
|
|
5735
5744
|
const cssForHost = cssText.replace(ROOT_TO_HOST_SELECTOR_RE, ':host');
|
|
5736
5745
|
const propertyBlocks = Array.from(cssText.matchAll(PROPERTY_BLOCK_RE));
|
|
@@ -6148,7 +6157,10 @@ function QRCode({ data, foreground, background, robustness = 'M', className, ...
|
|
|
6148
6157
|
});
|
|
6149
6158
|
}
|
|
6150
6159
|
const MODEL_VIEWER_URL = "https://integrations.vizbl.com/model-viewer";
|
|
6151
|
-
const AR_DEVICE_REQUIREMENTS_DISCLAIMER =
|
|
6160
|
+
const AR_DEVICE_REQUIREMENTS_DISCLAIMER = {
|
|
6161
|
+
en: '*Requires AR-supported device and browser. We recommend iOS 12 or later with Safari, or Android 7.0 or later with Chrome.',
|
|
6162
|
+
ru: '*Требуется устройство и браузер с поддержкой AR. Рекомендуем iOS 12 или новее с Safari либо Android 7.0 или новее с Chrome.'
|
|
6163
|
+
};
|
|
6152
6164
|
const DEFAULT_API_TIMEOUT = 30000;
|
|
6153
6165
|
function createDefaultClient(defaultBaseURL) {
|
|
6154
6166
|
return axios.create({
|
|
@@ -6842,7 +6854,7 @@ function isCanvasBlank(modelViewerEl) {
|
|
|
6842
6854
|
return true;
|
|
6843
6855
|
}
|
|
6844
6856
|
const ModelViewerContext = /*#__PURE__*/ createContext(null);
|
|
6845
|
-
function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExperience, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, handoffUrl, hid, launchAr, layout, background, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, viewerSurface }) {
|
|
6857
|
+
function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExperience, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, lang, handoffUrl, hid, launchAr, layout, background, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, viewerSurface }) {
|
|
6846
6858
|
const { object, material, error, isLoading, setMaterialHid: setObjectMaterialHid, widgetSession } = useObjectData(tinuuid, hid, {
|
|
6847
6859
|
apiBaseUrl,
|
|
6848
6860
|
apiKey,
|
|
@@ -6967,6 +6979,7 @@ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExp
|
|
|
6967
6979
|
layout,
|
|
6968
6980
|
background,
|
|
6969
6981
|
mode,
|
|
6982
|
+
lang,
|
|
6970
6983
|
sizeType,
|
|
6971
6984
|
dimensionAxes,
|
|
6972
6985
|
cameraOrbit,
|
|
@@ -6997,6 +7010,7 @@ function ModelViewerProvider({ children, tinuuid, apiKey, appClipBundleId, arExp
|
|
|
6997
7010
|
layout,
|
|
6998
7011
|
background,
|
|
6999
7012
|
mode,
|
|
7013
|
+
lang,
|
|
7000
7014
|
sizeType,
|
|
7001
7015
|
dimensionAxes,
|
|
7002
7016
|
cameraOrbit,
|
|
@@ -7120,7 +7134,7 @@ async function flushWidgetEvent(eventRequest) {
|
|
|
7120
7134
|
});
|
|
7121
7135
|
}
|
|
7122
7136
|
function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
7123
|
-
const { apiKey, appClipBundleId, arExperience, containerEl, handoffUrl, isLoading, isModelLoading, launchAr, material, mode, modelViewerEl, object, tinuuid, trackEvent, widgetSession } = useModelViewer();
|
|
7137
|
+
const { apiKey, appClipBundleId, arExperience, containerEl, handoffUrl, isLoading, isModelLoading, lang, launchAr, material, mode, modelViewerEl, object, tinuuid, trackEvent, widgetSession } = useModelViewer();
|
|
7124
7138
|
const [handoffSession, setHandoffSession] = useState(null);
|
|
7125
7139
|
const [open, setOpen] = useState(false);
|
|
7126
7140
|
const autoLaunchKeyRef = useRef(null);
|
|
@@ -7247,7 +7261,7 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7247
7261
|
size: size,
|
|
7248
7262
|
disabled: disabled || isDisabled,
|
|
7249
7263
|
onClick: handleButtonClick,
|
|
7250
|
-
children:
|
|
7264
|
+
children: 'ru' === lang ? 'Смотреть в интерьере' : 'View in place'
|
|
7251
7265
|
}),
|
|
7252
7266
|
url && /*#__PURE__*/ jsx(Dialog, {
|
|
7253
7267
|
open: open,
|
|
@@ -7266,17 +7280,17 @@ function AR({ disabled, onClick, onBeforeActivateAr, size = 'lg', ...props }) {
|
|
|
7266
7280
|
}),
|
|
7267
7281
|
/*#__PURE__*/ jsx("p", {
|
|
7268
7282
|
className: "text-center text-lg font-medium text-text-sub",
|
|
7269
|
-
children:
|
|
7283
|
+
children: 'ru' === lang ? 'Отсканируйте QR-код телефоном или планшетом, чтобы посмотреть объект в своём интерьере.' : 'Scan the QR code with your phone or tablet to view the object in your interior.'
|
|
7270
7284
|
}),
|
|
7271
7285
|
/*#__PURE__*/ jsx("p", {
|
|
7272
7286
|
className: "text-center text-xs text-text-light",
|
|
7273
|
-
children: AR_DEVICE_REQUIREMENTS_DISCLAIMER
|
|
7287
|
+
children: AR_DEVICE_REQUIREMENTS_DISCLAIMER[lang]
|
|
7274
7288
|
}),
|
|
7275
7289
|
/*#__PURE__*/ jsx(DialogClose, {
|
|
7276
7290
|
asChild: true,
|
|
7277
7291
|
children: /*#__PURE__*/ jsx(button_Button, {
|
|
7278
7292
|
size: "lg",
|
|
7279
|
-
children:
|
|
7293
|
+
children: 'ru' === lang ? 'Закрыть' : 'Close'
|
|
7280
7294
|
})
|
|
7281
7295
|
})
|
|
7282
7296
|
]
|
|
@@ -7478,6 +7492,7 @@ const Hotspots = /*#__PURE__*/ memo(({ hiddenHotspots, isVisible, labels })=>{
|
|
|
7478
7492
|
});
|
|
7479
7493
|
});
|
|
7480
7494
|
function LogoSign({ className, ...props }) {
|
|
7495
|
+
const { lang } = useModelViewer();
|
|
7481
7496
|
return /*#__PURE__*/ jsxs("div", {
|
|
7482
7497
|
className: utils_cn('group inline-flex gap-2 text-sm text-muted-foreground transition-colors duration-200 ease-in-out hover:text-text-dark', className),
|
|
7483
7498
|
...props,
|
|
@@ -7488,7 +7503,7 @@ function LogoSign({ className, ...props }) {
|
|
|
7488
7503
|
className: "size-4.25 text-icons-white"
|
|
7489
7504
|
})
|
|
7490
7505
|
}),
|
|
7491
|
-
|
|
7506
|
+
`Powered by ${'ru' === lang ? 'Arizo' : 'Vizbl'}`
|
|
7492
7507
|
]
|
|
7493
7508
|
});
|
|
7494
7509
|
}
|
|
@@ -7620,7 +7635,7 @@ function RadioGroupItem({ className, variant = 'default', ...props }) {
|
|
|
7620
7635
|
});
|
|
7621
7636
|
}
|
|
7622
7637
|
function MaterialVariants() {
|
|
7623
|
-
const { object, material, setMaterialHid } = useModelViewer();
|
|
7638
|
+
const { object, material, lang, setMaterialHid } = useModelViewer();
|
|
7624
7639
|
const materials = object?.materials ?? [];
|
|
7625
7640
|
if (!object || materials.length < 2) return null;
|
|
7626
7641
|
return /*#__PURE__*/ jsx(Card, {
|
|
@@ -7643,7 +7658,7 @@ function MaterialVariants() {
|
|
|
7643
7658
|
src: option.previews?.[0]?.subRes?.small ?? option.previews?.[0]?.url,
|
|
7644
7659
|
width: 80,
|
|
7645
7660
|
height: 80,
|
|
7646
|
-
alt: option.name ?? object.name ?? 'Material preview',
|
|
7661
|
+
alt: option.name ?? object.name ?? ('ru' === lang ? 'Превью материала' : 'Material preview'),
|
|
7647
7662
|
className: "size-20 object-cover @max-xl:size-12"
|
|
7648
7663
|
})
|
|
7649
7664
|
}),
|
|
@@ -7660,12 +7675,21 @@ function MaterialVariants() {
|
|
|
7660
7675
|
});
|
|
7661
7676
|
}
|
|
7662
7677
|
const viewerErrorTitle = {
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7678
|
+
en: {
|
|
7679
|
+
forbidden: 'Viewer unavailable for this domain',
|
|
7680
|
+
'not-found': 'Object not found',
|
|
7681
|
+
unauthorized: 'Invalid API key',
|
|
7682
|
+
'payment-required': 'Viewer temporarily unavailable'
|
|
7683
|
+
},
|
|
7684
|
+
ru: {
|
|
7685
|
+
forbidden: 'Просмотр недоступен для этого домена',
|
|
7686
|
+
'not-found': 'Объект не найден',
|
|
7687
|
+
unauthorized: 'Неверный API-ключ',
|
|
7688
|
+
'payment-required': 'Просмотр временно недоступен'
|
|
7689
|
+
}
|
|
7667
7690
|
};
|
|
7668
7691
|
function ViewerErrorState({ variant, showDialogCloseButton = false }) {
|
|
7692
|
+
const { lang } = useModelViewer();
|
|
7669
7693
|
return /*#__PURE__*/ jsxs("div", {
|
|
7670
7694
|
className: "relative z-30 flex size-full flex-col items-center justify-center gap-4 bg-radial from-background-containers to-background-base-2 p-4 text-center",
|
|
7671
7695
|
children: [
|
|
@@ -7674,13 +7698,13 @@ function ViewerErrorState({ variant, showDialogCloseButton = false }) {
|
|
|
7674
7698
|
}),
|
|
7675
7699
|
/*#__PURE__*/ jsx("h2", {
|
|
7676
7700
|
className: "typo-base-16 font-medium text-text-dark",
|
|
7677
|
-
children: viewerErrorTitle[variant]
|
|
7701
|
+
children: viewerErrorTitle[lang][variant]
|
|
7678
7702
|
}),
|
|
7679
7703
|
showDialogCloseButton && /*#__PURE__*/ jsx(DialogClose, {
|
|
7680
7704
|
asChild: true,
|
|
7681
7705
|
children: /*#__PURE__*/ jsx(button_Button, {
|
|
7682
7706
|
variant: "secondary",
|
|
7683
|
-
children:
|
|
7707
|
+
children: 'ru' === lang ? 'Закрыть' : 'Close'
|
|
7684
7708
|
})
|
|
7685
7709
|
})
|
|
7686
7710
|
]
|
|
@@ -7851,7 +7875,7 @@ function useDimensions({ isVisible, axes }) {
|
|
|
7851
7875
|
};
|
|
7852
7876
|
}
|
|
7853
7877
|
function ModelViewerContainer({ showDialogCloseButton = false }) {
|
|
7854
|
-
const { glbUrl, isModelLoading, object, previewUrl, state, setContainerEl, setModelViewerEl, usdzUrl, layout, background, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, trackEvent } = useModelViewer();
|
|
7878
|
+
const { glbUrl, isModelLoading, object, previewUrl, state, setContainerEl, setModelViewerEl, usdzUrl, layout, background, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, lang, trackEvent } = useModelViewer();
|
|
7855
7879
|
const [isDimensionsVisible, setDimensionsVisible] = useState(false);
|
|
7856
7880
|
const isModelLayout = 'model' === layout;
|
|
7857
7881
|
const showViewerLoader = 'loading' === state || 'ready' === state && isModelLoading;
|
|
@@ -7938,7 +7962,7 @@ function ModelViewerContainer({ showDialogCloseButton = false }) {
|
|
|
7938
7962
|
size: "lg",
|
|
7939
7963
|
variant: "secondary",
|
|
7940
7964
|
disabled: !canToggleDimensions,
|
|
7941
|
-
"aria-label":
|
|
7965
|
+
"aria-label": 'ru' === lang ? 'Показать размеры' : 'Toggle dimensions',
|
|
7942
7966
|
"aria-pressed": isDimensionsVisible,
|
|
7943
7967
|
onClick: ()=>{
|
|
7944
7968
|
setDimensionsVisible((current)=>!current);
|
|
@@ -7951,7 +7975,7 @@ function ModelViewerContainer({ showDialogCloseButton = false }) {
|
|
|
7951
7975
|
className: "size-6"
|
|
7952
7976
|
}),
|
|
7953
7977
|
/*#__PURE__*/ jsx("span", {
|
|
7954
|
-
children:
|
|
7978
|
+
children: 'ru' === lang ? 'Размеры' : 'Dimensions'
|
|
7955
7979
|
})
|
|
7956
7980
|
]
|
|
7957
7981
|
}),
|
|
@@ -7990,7 +8014,7 @@ const root_queryClient = new QueryClient({
|
|
|
7990
8014
|
}
|
|
7991
8015
|
}
|
|
7992
8016
|
});
|
|
7993
|
-
function ModelViewerRoot({ tinuuid, apiKey, appClipBundleId = 'com.us.vizbl.Clip', arExperience, hid, apiBaseUrl = "https://api.vizbl.com", legacyApiBaseUrl = "https://api.vizbl.com/v1", mode = 'embedded-3d-viewer', initialWidgetSessionToken, handoffUrl = "https://integrations.vizbl.com/model-viewer", launchAr, sizeType = 'cm', dimensionAxes = ALL_DIMENSION_AXES, cameraOrbit, minCameraOrbit, maxCameraOrbit, layout = 'default', background = 'default', showDialogCloseButton = false, viewerSurface = 'inline' }) {
|
|
8017
|
+
function ModelViewerRoot({ tinuuid, apiKey, appClipBundleId = 'com.us.vizbl.Clip', arExperience, hid, apiBaseUrl = "https://api.vizbl.com", legacyApiBaseUrl = "https://api.vizbl.com/v1", mode = 'embedded-3d-viewer', initialWidgetSessionToken, lang = 'en', handoffUrl = "https://integrations.vizbl.com/model-viewer", launchAr, sizeType = 'cm', dimensionAxes = ALL_DIMENSION_AXES, cameraOrbit, minCameraOrbit, maxCameraOrbit, layout = 'default', background = 'default', showDialogCloseButton = false, viewerSurface = 'inline' }) {
|
|
7994
8018
|
const normalizedApiKey = normalizeApiKey(apiKey);
|
|
7995
8019
|
return /*#__PURE__*/ jsx(QueryClientProvider, {
|
|
7996
8020
|
client: root_queryClient,
|
|
@@ -8003,6 +8027,7 @@ function ModelViewerRoot({ tinuuid, apiKey, appClipBundleId = 'com.us.vizbl.Clip
|
|
|
8003
8027
|
legacyApiBaseUrl: legacyApiBaseUrl,
|
|
8004
8028
|
mode: mode,
|
|
8005
8029
|
initialWidgetSessionToken: initialWidgetSessionToken,
|
|
8030
|
+
lang: lang,
|
|
8006
8031
|
handoffUrl: handoffUrl,
|
|
8007
8032
|
hid: hid,
|
|
8008
8033
|
launchAr: launchAr,
|
|
@@ -8076,6 +8101,9 @@ function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, legacyApiBaseUrl, init
|
|
|
8076
8101
|
zIndex: 2147483647
|
|
8077
8102
|
},
|
|
8078
8103
|
children: [
|
|
8104
|
+
/*#__PURE__*/ jsx("style", {
|
|
8105
|
+
children: SHADOW_HOST_VISIBILITY_CSS
|
|
8106
|
+
}),
|
|
8079
8107
|
/*#__PURE__*/ jsx("style", {
|
|
8080
8108
|
children: shadowRootCssText
|
|
8081
8109
|
}),
|
|
@@ -8087,7 +8115,7 @@ function ModelViewerDialog({ tinuuid, apiKey, apiBaseUrl, legacyApiBaseUrl, init
|
|
|
8087
8115
|
]
|
|
8088
8116
|
});
|
|
8089
8117
|
}
|
|
8090
|
-
function ModelViewer({ tinuuid, apiKey, appClipBundleId, arExperience, hid, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, handoffUrl, launchAr, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, layout, background, viewerSurface, className, ...props }) {
|
|
8118
|
+
function ModelViewer({ tinuuid, apiKey, appClipBundleId, arExperience, hid, apiBaseUrl, legacyApiBaseUrl, mode, initialWidgetSessionToken, lang, handoffUrl, launchAr, sizeType, dimensionAxes, cameraOrbit, minCameraOrbit, maxCameraOrbit, layout, background, viewerSurface, className, ...props }) {
|
|
8091
8119
|
const [container, setContainer] = useState(null);
|
|
8092
8120
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
8093
8121
|
children: [
|
|
@@ -8124,6 +8152,7 @@ function ModelViewer({ tinuuid, apiKey, appClipBundleId, arExperience, hid, apiB
|
|
|
8124
8152
|
legacyApiBaseUrl: legacyApiBaseUrl,
|
|
8125
8153
|
mode: mode,
|
|
8126
8154
|
initialWidgetSessionToken: initialWidgetSessionToken,
|
|
8155
|
+
lang: lang,
|
|
8127
8156
|
handoffUrl: handoffUrl,
|
|
8128
8157
|
hid: hid,
|
|
8129
8158
|
launchAr: launchAr,
|