New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shapediver/viewer.shared.services

Package Overview
Dependencies
Maintainers
4
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shapediver/viewer.shared.services - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

6

dist/http-client/HttpClient.d.ts

@@ -7,7 +7,5 @@ import { AxiosRequestConfig } from 'axios';

constructor();
private loadingCriterion;
private getSessionId;
addDataLoading(sessionId: string, callbacks: {
getOutput: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>;
getTexture: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>;
getExport: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>;
getAsset: (url: string) => Promise<[ArrayBuffer, string, string]>;
downloadTexture: (sessionId: string, url: string) => Promise<[ArrayBuffer, string]>;

@@ -14,0 +12,0 @@ }): void;

@@ -48,3 +48,3 @@ "use strict";

// #region Public Methods (7)
loadingCriterion(href) {
getSessionId(href) {
// searching for "/session/SESSION_ID/{'output' | 'export' | 'texture'}/ASSET_DATA"

@@ -59,8 +59,3 @@ const parts = href.split('/');

return;
const type = parts[sessionPartIndex + 2];
// the type is not supported
if (type !== 'output' && type !== 'export' && type !== 'texture')
return;
const assetData = parts[sessionPartIndex + 3];
return { sessionId, assetData, type };
return sessionId;
}

@@ -77,75 +72,53 @@ return;

return yield this._dataCache[dataKey];
const loadingInfo = this.loadingCriterion(href);
if (loadingInfo) {
switch (loadingInfo.type) {
case 'output':
this._dataCache[dataKey] = new Promise(resolve => {
this._sessionLoading[loadingInfo.sessionId]
.getOutput(loadingInfo.sessionId, loadingInfo.assetData)
.then(result => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
});
// try to get sessionId from href
let sessionId = this.getSessionId(href);
// if href does not have sessionId, use the first sesison, if available
if (!sessionId && Object.keys(this._sessionLoading).length > 0)
sessionId = Object.keys(this._sessionLoading)[0];
// get the session loading functions, if available
let sessionLoading;
if (sessionId)
sessionLoading = this._sessionLoading[sessionId];
// separation texture vs everything else
if (textureLoading) {
// if we have a sessionId and the sessionLoading functions and the image is not a blob or data, we load it via the sdk
if (sessionLoading !== undefined && sessionId !== undefined && !href.startsWith('blob:') && !href.startsWith('data:')) {
// take first session to load a texture that is not session related
this._dataCache[dataKey] = new Promise(resolve => {
sessionLoading.downloadTexture(sessionId, href).then((result) => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
});
});
break;
case 'export':
this._dataCache[dataKey] = new Promise(resolve => {
this._sessionLoading[loadingInfo.sessionId]
.getExport(loadingInfo.sessionId, loadingInfo.assetData)
.then(result => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
});
});
});
break;
case 'texture':
this._dataCache[dataKey] = new Promise(resolve => {
this._sessionLoading[loadingInfo.sessionId]
.getTexture(loadingInfo.sessionId, loadingInfo.assetData)
.then(result => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
});
});
});
break;
default:
this._dataCache[dataKey] = (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));
});
}
else {
// we can load blobs and data urls directly
// or load it directly if we don't have a session
this._dataCache[dataKey] = (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));
}
}
else {
// separation texture vs something else...
if (textureLoading) {
// we can load blobs and data urls directly
// if no session is registered, we have to load the texture directly
if (href.startsWith('blob:') || href.startsWith('data:') || Object.values(this._sessionLoading).length === 0) {
this._dataCache[dataKey] = (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));
}
else {
// take first session to load a texture that is not session related
const sessionId = Object.keys(this._sessionLoading)[0];
this._dataCache[dataKey] = new Promise(resolve => {
this._sessionLoading[sessionId].downloadTexture(sessionId, href).then((result) => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
});
try {
// if there is no session to load from, we use the fallback option
if (!sessionLoading)
throw new Error();
// all data links where we could somehow find a session to load it with
this._dataCache[dataKey] = new Promise(resolve => {
sessionLoading.getAsset(href)
.then((result) => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
});
});
}
});
}
else {
catch (e) {
// if this fails, we just load it directly
this._dataCache[dataKey] = (0, axios_1.default)(href, Object.assign({ method: 'get' }, config));

@@ -152,0 +125,0 @@ }

{
"name": "@shapediver/viewer.shared.services",
"version": "2.0.4",
"version": "2.0.5",
"description": "",

@@ -45,5 +45,5 @@ "keywords": [],

"@sentry/tracing": "^6.7.2",
"@shapediver/sdk.geometry-api-sdk-v2": "^1.0.24",
"@shapediver/sdk.geometry-api-sdk-v2": "^1.0.25",
"@shapediver/viewer.settings": "0.1.36",
"@shapediver/viewer.shared.build-data": "2.0.4",
"@shapediver/viewer.shared.build-data": "2.0.5",
"@types/dompurify": "^2.3.1",

@@ -59,3 +59,3 @@ "@types/ua-parser-js": "^0.7.36",

},
"gitHead": "dad664eb2739bd688a887067e3300bcdb6c61f6c"
"gitHead": "35de65c2189ae1c5b797e0a0d255ef2db32d2fb1"
}

@@ -16,5 +16,3 @@ import axios, { AxiosRequestConfig } from 'axios'

[key: string]: {
getOutput: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>,
getTexture: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>,
getExport: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>,
getAsset: (url: string) => Promise<[ArrayBuffer, string, string]>,
downloadTexture: (sessionId: string, url: string) => Promise<[ArrayBuffer, string]>,

@@ -49,3 +47,3 @@ }

private loadingCriterion(href: string): { sessionId: string, assetData: string, type: 'output' | 'export' | 'texture' } | undefined {
private getSessionId(href: string): string | undefined {
// searching for "/session/SESSION_ID/{'output' | 'export' | 'texture'}/ASSET_DATA"

@@ -60,12 +58,4 @@ const parts = href.split('/');

if (!this._sessionLoading[sessionId]) return;
const type = parts[sessionPartIndex + 2];
// the type is not supported
if (type !== 'output' && type !== 'export' && type !== 'texture') return;
const assetData = parts[sessionPartIndex + 3];
return { sessionId, assetData, type };
return sessionId;
}
return;

@@ -75,5 +65,3 @@ }

public addDataLoading(sessionId: string, callbacks: {
getOutput: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>,
getTexture: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>,
getExport: (sessionId: string, assetData: string) => Promise<[ArrayBuffer, string]>,
getAsset: (url: string) => Promise<[ArrayBuffer, string, string]>,
downloadTexture: (sessionId: string, url: string) => Promise<[ArrayBuffer, string]>,

@@ -87,70 +75,47 @@ }) {

if (dataKey in this._dataCache) return await this._dataCache[dataKey];
// try to get sessionId from href
let sessionId = this.getSessionId(href);
const loadingInfo = this.loadingCriterion(href);
if (loadingInfo) {
switch (loadingInfo.type) {
case 'output':
this._dataCache[dataKey] = new Promise<HttpResponse<ArrayBuffer>>(resolve => {
this._sessionLoading[loadingInfo.sessionId]
.getOutput(loadingInfo.sessionId, loadingInfo.assetData)
.then(result => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
})
})
// if href does not have sessionId, use the first sesison, if available
if(!sessionId && Object.keys(this._sessionLoading).length > 0)
sessionId = Object.keys(this._sessionLoading)[0];
// get the session loading functions, if available
let sessionLoading: {
getAsset: (url: string) => Promise<[ArrayBuffer, string, string]>,
downloadTexture: (sessionId: string, url: string) => Promise<[ArrayBuffer, string]>,
} | undefined;
if(sessionId)
sessionLoading = this._sessionLoading[sessionId];
// separation texture vs everything else
if(textureLoading) {
// if we have a sessionId and the sessionLoading functions and the image is not a blob or data, we load it via the sdk
if(sessionLoading !== undefined && sessionId !== undefined && !href.startsWith('blob:') && !href.startsWith('data:')) {
// take first session to load a texture that is not session related
this._dataCache[dataKey] = new Promise<HttpResponse<any>>(resolve => {
sessionLoading!.downloadTexture(sessionId!, href).then((result) => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
})
});
break;
case 'export':
this._dataCache[dataKey] = new Promise<HttpResponse<ArrayBuffer>>(resolve => {
this._sessionLoading[loadingInfo.sessionId]
.getExport(loadingInfo.sessionId, loadingInfo.assetData)
.then(result => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
})
})
});
break;
case 'texture':
this._dataCache[dataKey] = new Promise<HttpResponse<ArrayBuffer>>(resolve => {
this._sessionLoading[loadingInfo.sessionId]
.getTexture(loadingInfo.sessionId, loadingInfo.assetData)
.then(result => {
resolve({
data: result[0],
headers: {
'content-type': result[1]
}
})
})
});
break;
default:
this._dataCache[dataKey] = axios(href, Object.assign({ method: 'get' }, config));
});
} else {
// we can load blobs and data urls directly
// or load it directly if we don't have a session
this._dataCache[dataKey] = axios(href, Object.assign({ method: 'get' }, config));
}
} else {
// separation texture vs something else...
if(textureLoading) {
// we can load blobs and data urls directly
// if no session is registered, we have to load the texture directly
if(href.startsWith('blob:') || href.startsWith('data:') || Object.values(this._sessionLoading).length === 0) {
this._dataCache[dataKey] = axios(href, Object.assign({ method: 'get' }, config));
} else {
// take first session to load a texture that is not session related
const sessionId = Object.keys(this._sessionLoading)[0];
try{
// if there is no session to load from, we use the fallback option
if(!sessionLoading) throw new Error();
this._dataCache[dataKey] = new Promise<HttpResponse<any>>(resolve => {
this._sessionLoading[sessionId].downloadTexture(sessionId, href).then((result) => {
// all data links where we could somehow find a session to load it with
this._dataCache[dataKey] = new Promise<HttpResponse<ArrayBuffer>>(resolve => {
sessionLoading!.getAsset(href)
.then((result) => {
resolve({

@@ -162,10 +127,10 @@ data: result[0],

})
});
});
}
} else {
})
});
} catch(e) {
// if this fails, we just load it directly
this._dataCache[dataKey] = axios(href, Object.assign({ method: 'get' }, config));
}
}
return this._dataCache[dataKey];

@@ -172,0 +137,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc