@shopware-ag/dive 1.6.5 → 1.7.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/README.md +6 -8
- package/build/dive.cjs +102 -0
- package/build/dive.cjs.map +1 -1
- package/build/dive.d.cts +30 -0
- package/build/dive.d.ts +30 -0
- package/build/dive.js +102 -0
- package/build/dive.js.map +1 -1
- package/package.json +1 -1
- package/src/__test__/DIVE.test.ts +5 -0
- package/src/dive.ts +5 -0
- package/src/info/Info.ts +114 -0
- package/src/info/__test__/Info.test.ts +267 -0
package/build/dive.d.cts
CHANGED
|
@@ -676,6 +676,35 @@ declare const DIVEMath: {
|
|
|
676
676
|
signedAngleTo: typeof signedAngleTo;
|
|
677
677
|
};
|
|
678
678
|
|
|
679
|
+
declare class DIVEInfo {
|
|
680
|
+
private static _supportsWebXR;
|
|
681
|
+
/**
|
|
682
|
+
*
|
|
683
|
+
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
684
|
+
*/
|
|
685
|
+
static GetSystem(): string;
|
|
686
|
+
/**
|
|
687
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
688
|
+
*/
|
|
689
|
+
static GetSupportsWebXR(): Promise<boolean>;
|
|
690
|
+
/**
|
|
691
|
+
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
692
|
+
*/
|
|
693
|
+
static GetSupportsARQuickLook(): boolean;
|
|
694
|
+
/**
|
|
695
|
+
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
696
|
+
*/
|
|
697
|
+
static get isMobile(): boolean;
|
|
698
|
+
/**
|
|
699
|
+
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
700
|
+
*/
|
|
701
|
+
static get isDesktop(): boolean;
|
|
702
|
+
/**
|
|
703
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
704
|
+
*/
|
|
705
|
+
static GetIsARCapable(): Promise<boolean>;
|
|
706
|
+
}
|
|
707
|
+
|
|
679
708
|
type DIVESettings = {
|
|
680
709
|
autoResize: boolean;
|
|
681
710
|
displayAxes: boolean;
|
|
@@ -722,6 +751,7 @@ declare class DIVE {
|
|
|
722
751
|
private axisCamera;
|
|
723
752
|
get Communication(): DIVECommunication;
|
|
724
753
|
get Canvas(): HTMLCanvasElement;
|
|
754
|
+
get Info(): DIVEInfo;
|
|
725
755
|
set Settings(settings: Partial<DIVESettings>);
|
|
726
756
|
constructor(settings?: Partial<DIVESettings>);
|
|
727
757
|
Dispose(): void;
|
package/build/dive.d.ts
CHANGED
|
@@ -676,6 +676,35 @@ declare const DIVEMath: {
|
|
|
676
676
|
signedAngleTo: typeof signedAngleTo;
|
|
677
677
|
};
|
|
678
678
|
|
|
679
|
+
declare class DIVEInfo {
|
|
680
|
+
private static _supportsWebXR;
|
|
681
|
+
/**
|
|
682
|
+
*
|
|
683
|
+
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
684
|
+
*/
|
|
685
|
+
static GetSystem(): string;
|
|
686
|
+
/**
|
|
687
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
688
|
+
*/
|
|
689
|
+
static GetSupportsWebXR(): Promise<boolean>;
|
|
690
|
+
/**
|
|
691
|
+
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
692
|
+
*/
|
|
693
|
+
static GetSupportsARQuickLook(): boolean;
|
|
694
|
+
/**
|
|
695
|
+
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
696
|
+
*/
|
|
697
|
+
static get isMobile(): boolean;
|
|
698
|
+
/**
|
|
699
|
+
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
700
|
+
*/
|
|
701
|
+
static get isDesktop(): boolean;
|
|
702
|
+
/**
|
|
703
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
704
|
+
*/
|
|
705
|
+
static GetIsARCapable(): Promise<boolean>;
|
|
706
|
+
}
|
|
707
|
+
|
|
679
708
|
type DIVESettings = {
|
|
680
709
|
autoResize: boolean;
|
|
681
710
|
displayAxes: boolean;
|
|
@@ -722,6 +751,7 @@ declare class DIVE {
|
|
|
722
751
|
private axisCamera;
|
|
723
752
|
get Communication(): DIVECommunication;
|
|
724
753
|
get Canvas(): HTMLCanvasElement;
|
|
754
|
+
get Info(): DIVEInfo;
|
|
725
755
|
set Settings(settings: Partial<DIVESettings>);
|
|
726
756
|
constructor(settings?: Partial<DIVESettings>);
|
|
727
757
|
Dispose(): void;
|
package/build/dive.js
CHANGED
|
@@ -1939,6 +1939,105 @@ var DIVEMath = {
|
|
|
1939
1939
|
|
|
1940
1940
|
// src/dive.ts
|
|
1941
1941
|
import { generateUUID as generateUUID2 } from "three/src/math/MathUtils";
|
|
1942
|
+
|
|
1943
|
+
// src/info/Info.ts
|
|
1944
|
+
var DIVEInfo = class {
|
|
1945
|
+
/**
|
|
1946
|
+
*
|
|
1947
|
+
* @returns The system the user is using. Possible values are "Android", "iOS", "Windows", "MacOS", "Linux" or "Unknown".
|
|
1948
|
+
*/
|
|
1949
|
+
static GetSystem() {
|
|
1950
|
+
const platform = navigator.platform;
|
|
1951
|
+
if (/Android/.test(navigator.userAgent)) {
|
|
1952
|
+
return "Android";
|
|
1953
|
+
} else if (/iPhone|iPad|iPod/.test(navigator.userAgent)) {
|
|
1954
|
+
return "iOS";
|
|
1955
|
+
} else if (platform.startsWith("Win")) {
|
|
1956
|
+
return "Windows";
|
|
1957
|
+
} else if (platform.startsWith("Mac")) {
|
|
1958
|
+
return "MacOS";
|
|
1959
|
+
} else if (platform.startsWith("Linux")) {
|
|
1960
|
+
return "Linux";
|
|
1961
|
+
} else {
|
|
1962
|
+
return "Unknown";
|
|
1963
|
+
}
|
|
1964
|
+
}
|
|
1965
|
+
/**
|
|
1966
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device supports WebXR.
|
|
1967
|
+
*/
|
|
1968
|
+
static GetSupportsWebXR() {
|
|
1969
|
+
return __async(this, null, function* () {
|
|
1970
|
+
if (this._supportsWebXR !== null) {
|
|
1971
|
+
return this._supportsWebXR;
|
|
1972
|
+
}
|
|
1973
|
+
if (!navigator.xr) {
|
|
1974
|
+
this._supportsWebXR = false;
|
|
1975
|
+
return this._supportsWebXR;
|
|
1976
|
+
}
|
|
1977
|
+
try {
|
|
1978
|
+
const supported = yield navigator.xr.isSessionSupported("immersive-ar");
|
|
1979
|
+
this._supportsWebXR = supported;
|
|
1980
|
+
} catch (error) {
|
|
1981
|
+
this._supportsWebXR = false;
|
|
1982
|
+
}
|
|
1983
|
+
return this._supportsWebXR;
|
|
1984
|
+
});
|
|
1985
|
+
}
|
|
1986
|
+
/**
|
|
1987
|
+
* @returns A boolean indicating whether the user's device supports AR Quick Look.
|
|
1988
|
+
*/
|
|
1989
|
+
static GetSupportsARQuickLook() {
|
|
1990
|
+
const a = document.createElement("a");
|
|
1991
|
+
if (a.relList.supports("ar")) {
|
|
1992
|
+
return true;
|
|
1993
|
+
}
|
|
1994
|
+
const userAgent = navigator.userAgent;
|
|
1995
|
+
const isIOS = /iPad|iPhone|iPod/.test(userAgent) && !window.MSStream;
|
|
1996
|
+
if (!isIOS) {
|
|
1997
|
+
return false;
|
|
1998
|
+
}
|
|
1999
|
+
const match = userAgent.match(/OS (\d+)_/);
|
|
2000
|
+
if (!match || match.length < 2) {
|
|
2001
|
+
return false;
|
|
2002
|
+
}
|
|
2003
|
+
const iOSVersion = parseInt(match[1], 10);
|
|
2004
|
+
const minQuickLookVersion = 12;
|
|
2005
|
+
if (iOSVersion < minQuickLookVersion) {
|
|
2006
|
+
return false;
|
|
2007
|
+
}
|
|
2008
|
+
const isSupportedBrowser = /^((?!chrome|android).)*safari|CriOS|FxiOS/i.test(userAgent);
|
|
2009
|
+
if (isSupportedBrowser) {
|
|
2010
|
+
return true;
|
|
2011
|
+
}
|
|
2012
|
+
return false;
|
|
2013
|
+
}
|
|
2014
|
+
/**
|
|
2015
|
+
* @returns A boolean indicating whether the user's device is a mobile device.
|
|
2016
|
+
*/
|
|
2017
|
+
static get isMobile() {
|
|
2018
|
+
return this.GetSystem() === "Android" || this.GetSystem() === "iOS";
|
|
2019
|
+
}
|
|
2020
|
+
/**
|
|
2021
|
+
* @returns A boolean indicating whether the user's device is a desktop device.
|
|
2022
|
+
*/
|
|
2023
|
+
static get isDesktop() {
|
|
2024
|
+
return !this.isMobile;
|
|
2025
|
+
}
|
|
2026
|
+
/**
|
|
2027
|
+
* @returns A promise that resolves to a boolean indicating whether the user's device is capable of AR.
|
|
2028
|
+
*/
|
|
2029
|
+
static GetIsARCapable() {
|
|
2030
|
+
return __async(this, null, function* () {
|
|
2031
|
+
if (this.GetSupportsARQuickLook()) {
|
|
2032
|
+
return true;
|
|
2033
|
+
}
|
|
2034
|
+
return yield this.GetSupportsWebXR();
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
};
|
|
2038
|
+
DIVEInfo._supportsWebXR = null;
|
|
2039
|
+
|
|
2040
|
+
// src/dive.ts
|
|
1942
2041
|
var DIVEDefaultSettings = {
|
|
1943
2042
|
autoResize: true,
|
|
1944
2043
|
displayAxes: false,
|
|
@@ -2002,6 +2101,9 @@ var DIVE = class _DIVE {
|
|
|
2002
2101
|
get Canvas() {
|
|
2003
2102
|
return this.renderer.domElement;
|
|
2004
2103
|
}
|
|
2104
|
+
get Info() {
|
|
2105
|
+
return DIVEInfo;
|
|
2106
|
+
}
|
|
2005
2107
|
// setters
|
|
2006
2108
|
set Settings(settings) {
|
|
2007
2109
|
var _a;
|