@neurodyn/react-model-viewer 0.2.0 → 0.2.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/dist/index.js +122 -55
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -494,6 +494,18 @@ var __webpack_modules__ = {
|
|
|
494
494
|
inset-block: calc(var(--spacing) * 0);
|
|
495
495
|
}
|
|
496
496
|
|
|
497
|
+
.start-2 {
|
|
498
|
+
inset-inline-start: calc(var(--spacing) * 2);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.end-2 {
|
|
502
|
+
inset-inline-end: calc(var(--spacing) * 2);
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
.end-4 {
|
|
506
|
+
inset-inline-end: calc(var(--spacing) * 4);
|
|
507
|
+
}
|
|
508
|
+
|
|
497
509
|
.top-0 {
|
|
498
510
|
top: calc(var(--spacing) * 0);
|
|
499
511
|
}
|
|
@@ -542,10 +554,6 @@ var __webpack_modules__ = {
|
|
|
542
554
|
right: calc(var(--spacing) * 3);
|
|
543
555
|
}
|
|
544
556
|
|
|
545
|
-
.right-4 {
|
|
546
|
-
right: calc(var(--spacing) * 4);
|
|
547
|
-
}
|
|
548
|
-
|
|
549
557
|
.right-6 {
|
|
550
558
|
right: calc(var(--spacing) * 6);
|
|
551
559
|
}
|
|
@@ -558,15 +566,7 @@ var __webpack_modules__ = {
|
|
|
558
566
|
left: calc(var(--spacing) * 0);
|
|
559
567
|
}
|
|
560
568
|
|
|
561
|
-
.left-1\\/2 {
|
|
562
|
-
left: 50%;
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
.left-2 {
|
|
566
|
-
left: calc(var(--spacing) * 2);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
.left-\\[50\\%\\] {
|
|
569
|
+
.left-1\\/2, .left-\\[50\\%\\] {
|
|
570
570
|
left: 50%;
|
|
571
571
|
}
|
|
572
572
|
|
|
@@ -680,6 +680,14 @@ var __webpack_modules__ = {
|
|
|
680
680
|
margin-inline-start: -1px;
|
|
681
681
|
}
|
|
682
682
|
|
|
683
|
+
.ms-4 {
|
|
684
|
+
margin-inline-start: calc(var(--spacing) * 4);
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.ms-auto {
|
|
688
|
+
margin-inline-start: auto;
|
|
689
|
+
}
|
|
690
|
+
|
|
683
691
|
.mt-1\\.5 {
|
|
684
692
|
margin-top: calc(var(--spacing) * 1.5);
|
|
685
693
|
}
|
|
@@ -708,14 +716,6 @@ var __webpack_modules__ = {
|
|
|
708
716
|
margin-left: calc(var(--spacing) * 1);
|
|
709
717
|
}
|
|
710
718
|
|
|
711
|
-
.ml-4 {
|
|
712
|
-
margin-left: calc(var(--spacing) * 4);
|
|
713
|
-
}
|
|
714
|
-
|
|
715
|
-
.ml-auto {
|
|
716
|
-
margin-left: auto;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
719
|
.box-border {
|
|
720
720
|
box-sizing: border-box;
|
|
721
721
|
}
|
|
@@ -1854,6 +1854,26 @@ var __webpack_modules__ = {
|
|
|
1854
1854
|
padding-block: calc(var(--spacing) * 14);
|
|
1855
1855
|
}
|
|
1856
1856
|
|
|
1857
|
+
.ps-2 {
|
|
1858
|
+
padding-inline-start: calc(var(--spacing) * 2);
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
.ps-3 {
|
|
1862
|
+
padding-inline-start: calc(var(--spacing) * 3);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
.ps-8 {
|
|
1866
|
+
padding-inline-start: calc(var(--spacing) * 8);
|
|
1867
|
+
}
|
|
1868
|
+
|
|
1869
|
+
.pe-2 {
|
|
1870
|
+
padding-inline-end: calc(var(--spacing) * 2);
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
.pe-8 {
|
|
1874
|
+
padding-inline-end: calc(var(--spacing) * 8);
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1857
1877
|
.pt-1\\.5 {
|
|
1858
1878
|
padding-top: calc(var(--spacing) * 1.5);
|
|
1859
1879
|
}
|
|
@@ -1870,10 +1890,6 @@ var __webpack_modules__ = {
|
|
|
1870
1890
|
padding-right: calc(var(--spacing) * 1);
|
|
1871
1891
|
}
|
|
1872
1892
|
|
|
1873
|
-
.pr-2 {
|
|
1874
|
-
padding-right: calc(var(--spacing) * 2);
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
1893
|
.pr-2\\.5 {
|
|
1878
1894
|
padding-right: calc(var(--spacing) * 2.5);
|
|
1879
1895
|
}
|
|
@@ -1886,26 +1902,14 @@ var __webpack_modules__ = {
|
|
|
1886
1902
|
padding-right: calc(var(--spacing) * 5);
|
|
1887
1903
|
}
|
|
1888
1904
|
|
|
1889
|
-
.pr-8 {
|
|
1890
|
-
padding-right: calc(var(--spacing) * 8);
|
|
1891
|
-
}
|
|
1892
|
-
|
|
1893
1905
|
.pb-\\[0\\.3125rem\\] {
|
|
1894
1906
|
padding-bottom: 5px;
|
|
1895
1907
|
}
|
|
1896
1908
|
|
|
1897
|
-
.pl-2 {
|
|
1898
|
-
padding-left: calc(var(--spacing) * 2);
|
|
1899
|
-
}
|
|
1900
|
-
|
|
1901
1909
|
.pl-3 {
|
|
1902
1910
|
padding-left: calc(var(--spacing) * 3);
|
|
1903
1911
|
}
|
|
1904
1912
|
|
|
1905
|
-
.pl-8 {
|
|
1906
|
-
padding-left: calc(var(--spacing) * 8);
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
1913
|
.text-center {
|
|
1910
1914
|
text-align: center;
|
|
1911
1915
|
}
|
|
@@ -1914,6 +1918,10 @@ var __webpack_modules__ = {
|
|
|
1914
1918
|
text-align: left;
|
|
1915
1919
|
}
|
|
1916
1920
|
|
|
1921
|
+
.text-start {
|
|
1922
|
+
text-align: start;
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1917
1925
|
.align-middle {
|
|
1918
1926
|
vertical-align: middle;
|
|
1919
1927
|
}
|
|
@@ -4155,6 +4163,10 @@ var __webpack_modules__ = {
|
|
|
4155
4163
|
}
|
|
4156
4164
|
}
|
|
4157
4165
|
|
|
4166
|
+
.rtl\\:rotate-180:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *) {
|
|
4167
|
+
rotate: 180deg;
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4158
4170
|
.dark\\:bg-input\\/30:is(.dark *) {
|
|
4159
4171
|
background-color: var(--input);
|
|
4160
4172
|
}
|
|
@@ -4734,8 +4746,17 @@ var __webpack_modules__ = {
|
|
|
4734
4746
|
font-display: swap;
|
|
4735
4747
|
}
|
|
4736
4748
|
|
|
4749
|
+
@font-face {
|
|
4750
|
+
font-family: __tw4_shd_noto_arabic_7x4q2;
|
|
4751
|
+
src: url("https://fonts.gstatic.com/s/notosansarabic/v33/nwpCtLGrOAZMl5nJ_wfgRg3DrWFZWsnVBJ_sS6tlqHHFlj4wv4r4xA.woff2") format("woff2");
|
|
4752
|
+
font-weight: 100 900;
|
|
4753
|
+
font-style: normal;
|
|
4754
|
+
font-display: swap;
|
|
4755
|
+
unicode-range: U+6??, U+750-77F, U+870-891, U+897-8E1, U+8E3-8FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
|
|
4756
|
+
}
|
|
4757
|
+
|
|
4737
4758
|
:root {
|
|
4738
|
-
--v-font-family: "__tw4_shd_inter_7x4q2", sans-serif;
|
|
4759
|
+
--v-font-family: "__tw4_shd_inter_7x4q2", "__tw4_shd_noto_arabic_7x4q2", sans-serif;
|
|
4739
4760
|
font-family: var(--v-font-family);
|
|
4740
4761
|
font-feature-settings: "liga" 1, "calt" 1;
|
|
4741
4762
|
-webkit-font-smoothing: antialiased;
|
|
@@ -5374,6 +5395,15 @@ var __webpack_modules__ = {
|
|
|
5374
5395
|
font-style: normal;
|
|
5375
5396
|
font-display: swap;
|
|
5376
5397
|
}
|
|
5398
|
+
|
|
5399
|
+
@font-face {
|
|
5400
|
+
font-family: __tw4_shd_noto_arabic_7x4q2;
|
|
5401
|
+
src: url("https://fonts.gstatic.com/s/notosansarabic/v33/nwpCtLGrOAZMl5nJ_wfgRg3DrWFZWsnVBJ_sS6tlqHHFlj4wv4r4xA.woff2") format("woff2");
|
|
5402
|
+
font-weight: 100 900;
|
|
5403
|
+
font-style: normal;
|
|
5404
|
+
font-display: swap;
|
|
5405
|
+
unicode-range: U+6??, U+750-77F, U+870-891, U+897-8E1, U+8E3-8FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
|
|
5406
|
+
}
|
|
5377
5407
|
`,
|
|
5378
5408
|
""
|
|
5379
5409
|
]);
|
|
@@ -5831,7 +5861,7 @@ function DialogContent({ className, children, contentInsideOverlay = false, show
|
|
|
5831
5861
|
children,
|
|
5832
5862
|
showCloseButton && /*#__PURE__*/ jsxs(react_dialog_Close, {
|
|
5833
5863
|
"data-slot": "dialog-close",
|
|
5834
|
-
className: "focus-visible:ring-ring/30 absolute top-4
|
|
5864
|
+
className: "focus-visible:ring-ring/30 absolute top-4 end-4 inline-flex size-6 cursor-pointer items-center justify-center rounded-full text-icons-light transition-colors hover:text-icons-normal focus-visible:text-icons-dark focus-visible:ring-2 focus-visible:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
5835
5865
|
children: [
|
|
5836
5866
|
/*#__PURE__*/ jsx(XIcon, {
|
|
5837
5867
|
className: "size-6"
|
|
@@ -6436,7 +6466,8 @@ class ModelViewerWidgetSession {
|
|
|
6436
6466
|
async recoverFromExpiry(signal) {
|
|
6437
6467
|
try {
|
|
6438
6468
|
await this.refresh();
|
|
6439
|
-
} catch
|
|
6469
|
+
} catch (error) {
|
|
6470
|
+
if (!this.apiKey) throw error;
|
|
6440
6471
|
this.session = this.toSnapshot(await activateCoreArWidgetSession(this.mode, {
|
|
6441
6472
|
baseURL: this.apiBaseUrl,
|
|
6442
6473
|
headers: {
|
|
@@ -6456,7 +6487,11 @@ class ModelViewerWidgetSession {
|
|
|
6456
6487
|
baseURL: this.apiBaseUrl,
|
|
6457
6488
|
headers: {
|
|
6458
6489
|
...this.appTypeHeaders,
|
|
6459
|
-
|
|
6490
|
+
...this.apiKey ? {
|
|
6491
|
+
'x-api-key': this.apiKey
|
|
6492
|
+
} : {
|
|
6493
|
+
[WIDGET_SESSION_TOKEN_HEADER]: this.session.token
|
|
6494
|
+
}
|
|
6460
6495
|
}
|
|
6461
6496
|
}).then((data)=>this.toSnapshot(parseWidgetSession(data))).then((session)=>{
|
|
6462
6497
|
this.session = session;
|
|
@@ -6474,6 +6509,27 @@ class ModelViewerWidgetSession {
|
|
|
6474
6509
|
}
|
|
6475
6510
|
}
|
|
6476
6511
|
async function createModelViewerWidgetSession({ apiBaseUrl, apiKey, appType, initialWidgetSessionToken, mode, signal }) {
|
|
6512
|
+
if (initialWidgetSessionToken && !apiKey) try {
|
|
6513
|
+
const exchanged = await publicApiControllerIssueWidgetToken({
|
|
6514
|
+
mode,
|
|
6515
|
+
token: initialWidgetSessionToken
|
|
6516
|
+
}, {
|
|
6517
|
+
baseURL: apiBaseUrl,
|
|
6518
|
+
headers: {
|
|
6519
|
+
...getAppTypeHeaders(appType),
|
|
6520
|
+
[WIDGET_SESSION_TOKEN_HEADER]: initialWidgetSessionToken
|
|
6521
|
+
},
|
|
6522
|
+
signal
|
|
6523
|
+
});
|
|
6524
|
+
return new ModelViewerWidgetSession(parseWidgetSession(exchanged), {
|
|
6525
|
+
apiBaseUrl,
|
|
6526
|
+
apiKey,
|
|
6527
|
+
appType,
|
|
6528
|
+
mode
|
|
6529
|
+
});
|
|
6530
|
+
} catch (error) {
|
|
6531
|
+
if (signal?.aborted) throw error;
|
|
6532
|
+
}
|
|
6477
6533
|
if (initialWidgetSessionToken) return new ModelViewerWidgetSession({
|
|
6478
6534
|
expiresIn: ASSUMED_HANDOFF_SESSION_TTL_SECONDS,
|
|
6479
6535
|
sid: initialWidgetSessionToken,
|
|
@@ -6525,6 +6581,7 @@ async function sendModelViewerWidgetEvent(session, event, options = {}) {
|
|
|
6525
6581
|
body: JSON.stringify({
|
|
6526
6582
|
event,
|
|
6527
6583
|
objectId: options.objectId ?? void 0,
|
|
6584
|
+
page_path: currentPagePath(),
|
|
6528
6585
|
timestamp: new Date().toISOString(),
|
|
6529
6586
|
variantId: options.variantId ?? void 0
|
|
6530
6587
|
}),
|
|
@@ -6573,6 +6630,10 @@ function parseWidgetSession(value) {
|
|
|
6573
6630
|
if (!session || 'object' != typeof session || 'string' != typeof session.token || !session.token.trim() || 'string' != typeof session.sid || !session.sid.trim() || 'number' != typeof session.expiresIn || !Number.isFinite(session.expiresIn) || session.expiresIn <= 0) throw new TypeError('Invalid widget session response');
|
|
6574
6631
|
return session;
|
|
6575
6632
|
}
|
|
6633
|
+
function currentPagePath(locationRef = globalThis.location) {
|
|
6634
|
+
const path = locationRef?.pathname;
|
|
6635
|
+
return 'string' == typeof path && path.startsWith('/') ? path : void 0;
|
|
6636
|
+
}
|
|
6576
6637
|
const MODEL_VIEWER_URL = "https://integrations.vizbl.com/model-viewer";
|
|
6577
6638
|
const AR_DEVICE_REQUIREMENTS_DISCLAIMER = {
|
|
6578
6639
|
en: '*Requires AR-supported device and browser. We recommend iOS 18 or later with Safari, or Android 7.0 or later with Chrome.',
|
|
@@ -6642,7 +6703,7 @@ function useObjectData(tinuuid, initialHid, options) {
|
|
|
6642
6703
|
widgetSession
|
|
6643
6704
|
};
|
|
6644
6705
|
}
|
|
6645
|
-
|
|
6706
|
+
const readAnonymously = async ()=>{
|
|
6646
6707
|
const object = await readObject({
|
|
6647
6708
|
tinuuid
|
|
6648
6709
|
}, {
|
|
@@ -6654,20 +6715,26 @@ function useObjectData(tinuuid, initialHid, options) {
|
|
|
6654
6715
|
object,
|
|
6655
6716
|
widgetSession: null
|
|
6656
6717
|
};
|
|
6657
|
-
}
|
|
6658
|
-
const widgetSession = await createModelViewerWidgetSession({
|
|
6659
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
6660
|
-
apiKey: options.apiKey,
|
|
6661
|
-
appType: options.appType,
|
|
6662
|
-
initialWidgetSessionToken: options.initialWidgetSessionToken,
|
|
6663
|
-
mode: options.mode,
|
|
6664
|
-
signal
|
|
6665
|
-
});
|
|
6666
|
-
const object = await fetchModelViewerObject(tinuuid, initialHid, widgetSession, signal);
|
|
6667
|
-
return {
|
|
6668
|
-
object,
|
|
6669
|
-
widgetSession
|
|
6670
6718
|
};
|
|
6719
|
+
if (!options.apiKey && !options.initialWidgetSessionToken) return readAnonymously();
|
|
6720
|
+
try {
|
|
6721
|
+
const widgetSession = await createModelViewerWidgetSession({
|
|
6722
|
+
apiBaseUrl: options.apiBaseUrl,
|
|
6723
|
+
apiKey: options.apiKey,
|
|
6724
|
+
appType: options.appType,
|
|
6725
|
+
initialWidgetSessionToken: options.initialWidgetSessionToken,
|
|
6726
|
+
mode: options.mode,
|
|
6727
|
+
signal
|
|
6728
|
+
});
|
|
6729
|
+
const object = await fetchModelViewerObject(tinuuid, initialHid, widgetSession, signal);
|
|
6730
|
+
return {
|
|
6731
|
+
object,
|
|
6732
|
+
widgetSession
|
|
6733
|
+
};
|
|
6734
|
+
} catch (error) {
|
|
6735
|
+
if (options.apiKey || signal.aborted || 401 !== getErrorResponseStatus(error)) throw error;
|
|
6736
|
+
return readAnonymously();
|
|
6737
|
+
}
|
|
6671
6738
|
}
|
|
6672
6739
|
});
|
|
6673
6740
|
const object = data?.object ?? null;
|