@wix/sdk
Advanced tools
Comparing version
@@ -34,4 +34,3 @@ import { Host, RESTFunctionDescriptor, BuildRESTFunction, HostModule, HostModuleAPI, AuthenticationStrategy, BoundAuthenticationStrategy } from '@wix/sdk-types'; | ||
}; | ||
type AmbassadorFactory<Request, Response> = { | ||
(payload: Request): (context: RequestContext) => AmbassadorRequestOptions<Response>; | ||
type AmbassadorFactory<Request, Response> = (payload: Request) => ((context: RequestContext) => AmbassadorRequestOptions<Response>) & { | ||
__isAmbassador: boolean; | ||
@@ -154,11 +153,28 @@ }; | ||
width: number; | ||
} | { | ||
altText: string; | ||
filename: string; | ||
altText?: string; | ||
filename?: string; | ||
}; | ||
declare function getVideoUrl(val: string, resolution?: VideoResolution): { | ||
id: string; | ||
url: string; | ||
height: number; | ||
width: number; | ||
thumbnail: string; | ||
}; | ||
declare function getAudioUrl(val: string): { | ||
id: string; | ||
url: string; | ||
duration: number; | ||
name?: string; | ||
}; | ||
declare function getDocumentUrl(val: string): { | ||
id: string; | ||
url: string; | ||
name?: string; | ||
}; | ||
declare function decodeText(s: string): string; | ||
declare enum VideoResolution { | ||
MOBILE = "360p", | ||
LOW = "480p", | ||
MID = "720p", | ||
HIGH = "1080p" | ||
} | ||
declare const media: { | ||
@@ -169,2 +185,5 @@ getCroppedImageUrl: typeof getCroppedImageUrl; | ||
getImageUrl: typeof getImageUrl; | ||
getVideoUrl: typeof getVideoUrl; | ||
getAudioUrl: typeof getAudioUrl; | ||
getDocumentUrl: typeof getDocumentUrl; | ||
}; | ||
@@ -372,2 +391,2 @@ | ||
export { API_URL, AccessToken, ApiKeyStrategy, AssertHostMatches, BuildDescriptors, CalculateNextState, Descriptors, IApiKeyStrategy, IOAuthStrategy, LoginParams, LoginState, OAuthStrategy, OauthData, OauthPKCE, ProcessableState, RefreshToken, RegisterParams, StateMachine, Token, TokenResponse, TokenRole, Tokens, WixAppOAuthStrategy, WixClient, createClient, decodeText, getDefaultDomain, media }; | ||
export { API_URL, type AccessToken, ApiKeyStrategy, type AssertHostMatches, type BuildDescriptors, type CalculateNextState, type Descriptors, type IApiKeyStrategy, type IOAuthStrategy, type LoginParams, LoginState, OAuthStrategy, type OauthData, type OauthPKCE, type ProcessableState, type RefreshToken, type RegisterParams, type StateMachine, type Token, type TokenResponse, TokenRole, type Tokens, VideoResolution, WixAppOAuthStrategy, type WixClient, createClient, decodeText, getDefaultDomain, media }; |
@@ -39,2 +39,3 @@ "use strict"; | ||
TokenRole: () => TokenRole, | ||
VideoResolution: () => VideoResolution, | ||
WixAppOAuthStrategy: () => WixAppOAuthStrategy, | ||
@@ -119,2 +120,9 @@ createClient: () => createClient, | ||
}); | ||
var isAmbassadorModule = (module2) => { | ||
if (module2.__isAmbassador) { | ||
return true; | ||
} | ||
const fn = module2(); | ||
return Boolean(fn.__isAmbassador); | ||
}; | ||
@@ -301,3 +309,3 @@ // src/common.ts | ||
} else if (typeof modules === "function") { | ||
const { module: module2, options } = modules.__isAmbassador ? { | ||
const { module: module2, options } = isAmbassadorModule(modules) ? { | ||
module: toHTTPModule(modules), | ||
@@ -372,3 +380,9 @@ options: ambassadorModuleOptions() | ||
var WIX_IMAGE = "image"; | ||
var WIX_VIDEO = "video"; | ||
var WIX_AUDIO = "audio"; | ||
var WIX_DOCUMENT = "document"; | ||
var WIX_IMAGE_URL = "https://static.wixstatic.com/media/"; | ||
var WIX_VIDEO_URL = "https://video.wixstatic.com/video/"; | ||
var WIX_AUDIO_URL = "https://static.wixstatic.com/mp3/"; | ||
var WIX_DOCUMENT_URL = "https://d945e594-8657-47e2-9cd9-e9033c3d8da0.usrfiles.com/ugd/"; | ||
function getScaledToFillImageUrl(wixMediaIdentifier, targetWidth, targetHeight, options) { | ||
@@ -442,2 +456,61 @@ const img = getImageUrl(wixMediaIdentifier); | ||
} | ||
function getVideoUrl(val, resolution) { | ||
let id, thumbnailId, thumbnailWidth, thumbnailHeight; | ||
if (val.startsWith(WIX_VIDEO_URL)) { | ||
id = val.split(WIX_VIDEO_URL).pop().split("/")[0]; | ||
thumbnailId = `${id}.jpg`; | ||
thumbnailWidth = "50"; | ||
thumbnailHeight = "50"; | ||
} else { | ||
const alignedVideo = alignIfLegacy(val, WIX_VIDEO); | ||
const { pathname, hash } = new URL(alignedVideo); | ||
const hashParams = new URLSearchParams(hash.replace("#", "")); | ||
[id] = pathname.replace(`${WIX_VIDEO}://v1/`, "").split("/"); | ||
thumbnailId = hashParams.get("posterUri") || `${id}.jpg`; | ||
thumbnailWidth = hashParams.get("posterWidth") || "50"; | ||
thumbnailHeight = hashParams.get("posterHeight") || "50"; | ||
} | ||
return { | ||
id, | ||
url: `${WIX_VIDEO_URL}${id}/${resolution ? `${resolution}/mp4/file.mp4` : "file"}`, | ||
thumbnail: `${WIX_PROTOCOL}${WIX_IMAGE}://v1/${thumbnailId}#originWidth=${thumbnailWidth}&originHeight=${thumbnailHeight}` | ||
}; | ||
} | ||
function getAudioUrl(val) { | ||
const alignedAudio = alignIfLegacy(val, WIX_AUDIO); | ||
const { pathname, hash } = new URL(alignedAudio); | ||
const [id, filename] = pathname.replace(`${WIX_AUDIO}://v1/`, "").split("/"); | ||
const decodedFilename = decodeText(filename); | ||
const hashParams = new URLSearchParams(hash.replace("#", "")); | ||
const res = { | ||
id, | ||
duration: Number(hashParams.get("duration") || ""), | ||
url: `${WIX_AUDIO_URL}${id}` | ||
}; | ||
if (!decodedFilename) { | ||
return res; | ||
} | ||
return { | ||
...res, | ||
name: decodedFilename | ||
}; | ||
} | ||
function getDocumentUrl(val) { | ||
const valWithoutUGD = val.replace("v1/ugd", "v1"); | ||
const alignedDocument = alignIfLegacy(valWithoutUGD, WIX_DOCUMENT); | ||
const { pathname } = new URL(alignedDocument); | ||
const [id, filename] = pathname.replace(`${WIX_DOCUMENT}://v1/`, "").split("/"); | ||
const decodedFilename = decodeText(filename); | ||
const res = { | ||
id, | ||
url: `${WIX_DOCUMENT_URL}${id}` | ||
}; | ||
if (!decodedFilename) { | ||
return res; | ||
} | ||
return { | ||
...res, | ||
name: decodedFilename | ||
}; | ||
} | ||
function decodeText(s) { | ||
@@ -453,2 +526,9 @@ if (!s) { | ||
} | ||
var VideoResolution = /* @__PURE__ */ ((VideoResolution2) => { | ||
VideoResolution2["MOBILE"] = "360p"; | ||
VideoResolution2["LOW"] = "480p"; | ||
VideoResolution2["MID"] = "720p"; | ||
VideoResolution2["HIGH"] = "1080p"; | ||
return VideoResolution2; | ||
})(VideoResolution || {}); | ||
var media = { | ||
@@ -458,3 +538,6 @@ getCroppedImageUrl, | ||
getScaledToFitImageUrl, | ||
getImageUrl | ||
getImageUrl, | ||
getVideoUrl, | ||
getAudioUrl, | ||
getDocumentUrl | ||
}; | ||
@@ -1023,2 +1106,3 @@ | ||
TokenRole, | ||
VideoResolution, | ||
WixAppOAuthStrategy, | ||
@@ -1025,0 +1109,0 @@ createClient, |
{ | ||
"name": "@wix/sdk", | ||
"version": "1.5.7", | ||
"version": "1.5.8", | ||
"license": "UNLICENSED", | ||
@@ -32,10 +32,10 @@ "author": { | ||
"dependencies": { | ||
"@babel/runtime": "^7.23.2", | ||
"@wix/identity": "^1.0.62", | ||
"@wix/image-kit": "^1.40.0", | ||
"@babel/runtime": "^7.23.5", | ||
"@wix/identity": "^1.0.63", | ||
"@wix/image-kit": "^1.42.0", | ||
"@wix/redirects": "^1.0.28", | ||
"@wix/sdk-types": "1.5.1", | ||
"@wix/sdk-types": "1.5.2", | ||
"pkce-challenge": "^3.1.0", | ||
"querystring": "^0.2.1", | ||
"type-fest": "^3.13.1" | ||
"type-fest": "^4.8.3" | ||
}, | ||
@@ -47,7 +47,7 @@ "optionalDependencies": { | ||
"@types/is-ci": "^3.0.4", | ||
"@types/node": "^20.9.0", | ||
"@wix/ecom": "^1.0.379", | ||
"@types/node": "^20.10.2", | ||
"@wix/ecom": "^1.0.385", | ||
"@wix/events": "^1.0.127", | ||
"@wix/metro": "^1.0.67", | ||
"@wix/metro-runtime": "^1.1547.0", | ||
"@wix/metro-runtime": "^1.1556.0", | ||
"eslint": "^7.32.0", | ||
@@ -58,7 +58,7 @@ "eslint-config-sdk": "0.0.0", | ||
"jsdom": "^22.1.0", | ||
"msw": "^2.0.5", | ||
"tsup": "^7.2.0", | ||
"typescript": "~4.9.5", | ||
"msw": "^2.0.9", | ||
"tsup": "^7.3.0", | ||
"typescript": "^5.3.2", | ||
"vitest": "^0.34.6", | ||
"vitest-teamcity-reporter": "^0.2.0" | ||
"vitest-teamcity-reporter": "^0.2.1" | ||
}, | ||
@@ -88,3 +88,3 @@ "yoshiFlowLibrary": { | ||
}, | ||
"falconPackageHash": "ef89c90113560669ac1e3eaddcf8cb682516f3c71c91e15d3dbf4821" | ||
"falconPackageHash": "abc3cbf2dfe41ba544a61d2a46cac253a1b083d01586f66bd062aba8" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected potential code anomaly
Supply chain riskAI has identified unusual behaviors that may pose a security risk.
Found 1 instance in 1 package
131774
8.17%3553
8.19%2
100%+ Added
+ Added
- Removed
- Removed
Updated
Updated
Updated
Updated
Updated