@xyo-network/image-thumbnail-plugin 5.3.2 → 5.3.3
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/node/Plugin.d.ts +4 -0
- package/dist/node/Plugin.d.ts.map +1 -0
- package/dist/node/Witness/Config.d.ts +20 -0
- package/dist/node/Witness/Config.d.ts.map +1 -0
- package/dist/node/Witness/Params.d.ts +7 -0
- package/dist/node/Witness/Params.d.ts.map +1 -0
- package/dist/node/Witness/Witness.d.ts +37 -0
- package/dist/node/Witness/Witness.d.ts.map +1 -0
- package/dist/node/Witness/ffmpeg/fluent/getVideoFrameAsImageFluent.d.ts +7 -0
- package/dist/node/Witness/ffmpeg/fluent/getVideoFrameAsImageFluent.d.ts.map +1 -0
- package/dist/node/Witness/ffmpeg/fluent/index.d.ts +2 -0
- package/dist/node/Witness/ffmpeg/fluent/index.d.ts.map +1 -0
- package/dist/node/Witness/ffmpeg/index.d.ts +3 -0
- package/dist/node/Witness/ffmpeg/index.d.ts.map +1 -0
- package/dist/node/Witness/ffmpeg/spawn/executeFfmpeg.d.ts +8 -0
- package/dist/node/Witness/ffmpeg/spawn/executeFfmpeg.d.ts.map +1 -0
- package/dist/node/Witness/ffmpeg/spawn/getVideoFrameAsImage.d.ts +7 -0
- package/dist/node/Witness/ffmpeg/spawn/getVideoFrameAsImage.d.ts.map +1 -0
- package/dist/node/Witness/ffmpeg/spawn/index.d.ts +3 -0
- package/dist/node/Witness/ffmpeg/spawn/index.d.ts.map +1 -0
- package/dist/node/Witness/index.d.ts +4 -0
- package/dist/node/Witness/index.d.ts.map +1 -0
- package/dist/node/Witness/lib/checkIpfsUrl.d.ts +8 -0
- package/dist/node/Witness/lib/checkIpfsUrl.d.ts.map +1 -0
- package/dist/node/Witness/lib/createDataUrl.d.ts +2 -0
- package/dist/node/Witness/lib/createDataUrl.d.ts.map +1 -0
- package/dist/node/Witness/lib/index.d.ts +4 -0
- package/dist/node/Witness/lib/index.d.ts.map +1 -0
- package/dist/node/Witness/lib/resolveDynamicSvg.d.ts +2 -0
- package/dist/node/Witness/lib/resolveDynamicSvg.d.ts.map +1 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.mjs +404 -0
- package/dist/node/index.mjs.map +1 -0
- package/package.json +26 -8
- package/src/Plugin.ts +0 -21
- package/src/Witness/Config.ts +0 -22
- package/src/Witness/Params.ts +0 -10
- package/src/Witness/Witness.ts +0 -320
- package/src/Witness/ffmpeg/fluent/getVideoFrameAsImageFluent.ts +0 -73
- package/src/Witness/ffmpeg/fluent/index.ts +0 -1
- package/src/Witness/ffmpeg/index.ts +0 -2
- package/src/Witness/ffmpeg/spawn/executeFfmpeg.ts +0 -27
- package/src/Witness/ffmpeg/spawn/getVideoFrameAsImage.ts +0 -11
- package/src/Witness/ffmpeg/spawn/index.ts +0 -2
- package/src/Witness/index.ts +0 -3
- package/src/Witness/lib/checkIpfsUrl.ts +0 -43
- package/src/Witness/lib/createDataUrl.ts +0 -5
- package/src/Witness/lib/index.ts +0 -3
- package/src/Witness/lib/resolveDynamicSvg.ts +0 -30
- package/src/index.ts +0 -3
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { assertEx } from '@xylabs/sdk-js'
|
|
2
|
-
|
|
3
|
-
const allowIpfsIoRepair = true
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Returns the equivalent IPFS gateway URL for the supplied URL.
|
|
7
|
-
* @param urlToCheck The URL to check
|
|
8
|
-
* @returns If the supplied URL is an IPFS URL, it converts the URL to the
|
|
9
|
-
* equivalent IPFS gateway URL. Otherwise, returns the original URL.
|
|
10
|
-
*/
|
|
11
|
-
export const checkIpfsUrl = (urlToCheck: string, ipfsGateway?: string): string => {
|
|
12
|
-
try {
|
|
13
|
-
const url = new URL(urlToCheck)
|
|
14
|
-
let protocol = url.protocol
|
|
15
|
-
let host = url.host
|
|
16
|
-
let path = url.pathname
|
|
17
|
-
const query = url.search
|
|
18
|
-
if (protocol === 'ipfs:') {
|
|
19
|
-
protocol = 'https:'
|
|
20
|
-
host = assertEx(ipfsGateway, () => 'No ipfsGateway provided')
|
|
21
|
-
path = url.host === 'ipfs' ? `ipfs${path}` : `ipfs/${url.host}${path}`
|
|
22
|
-
const root = `${protocol}//${host}/${path}`
|
|
23
|
-
return query?.length > 0 ? `${root}?${query}` : root
|
|
24
|
-
} else if (allowIpfsIoRepair && protocol === 'https' && host === 'ipfs.io') {
|
|
25
|
-
protocol = 'https:'
|
|
26
|
-
host = assertEx(ipfsGateway, () => 'No ipfsGateway provided')
|
|
27
|
-
const pathParts = path.split('/')
|
|
28
|
-
if (pathParts[0] === 'ipfs') {
|
|
29
|
-
pathParts.shift()
|
|
30
|
-
}
|
|
31
|
-
path = pathParts.join('/')
|
|
32
|
-
const root = `${protocol}//${host}/${path}`
|
|
33
|
-
return query?.length > 0 ? `${root}?${query}` : root
|
|
34
|
-
} else {
|
|
35
|
-
return urlToCheck
|
|
36
|
-
}
|
|
37
|
-
} catch {
|
|
38
|
-
// const error = ex as Error
|
|
39
|
-
// console.error(`${error.name}:${error.message} [${urlToCheck}]`)
|
|
40
|
-
// console.log(error.stack)
|
|
41
|
-
return urlToCheck
|
|
42
|
-
}
|
|
43
|
-
}
|
package/src/Witness/lib/index.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { AxiosResponse } from 'axios'
|
|
2
|
-
import axios from 'axios'
|
|
3
|
-
import { toByteArray } from 'base64-js'
|
|
4
|
-
import { Builder, parseStringPromise } from 'xml2js'
|
|
5
|
-
|
|
6
|
-
export const resolveDynamicSvg = async (base64Bytes: string) => {
|
|
7
|
-
const decoder = new TextDecoder()
|
|
8
|
-
const bytes = toByteArray(base64Bytes)
|
|
9
|
-
const svg = decoder.decode(bytes)
|
|
10
|
-
const svgObj = await parseStringPromise(svg)
|
|
11
|
-
const svgNode = svgObj['svg']
|
|
12
|
-
const imageResults = (await Promise.all(
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
svgNode['image'].map(async (img: any) => [
|
|
15
|
-
img.$,
|
|
16
|
-
await axios.get(img.$.href, { responseType: 'arraybuffer' }),
|
|
17
|
-
]),
|
|
18
|
-
)) as [string, AxiosResponse][]
|
|
19
|
-
const image = imageResults.map(([href, response]) => {
|
|
20
|
-
if (response.data) {
|
|
21
|
-
const sourceBuffer = Buffer.from(response.data, 'binary')
|
|
22
|
-
return { $: { href: `data:${response.headers['content-type']?.toString()};base64,${sourceBuffer.toString('base64')}` } }
|
|
23
|
-
} else {
|
|
24
|
-
return { $: { href } }
|
|
25
|
-
}
|
|
26
|
-
})
|
|
27
|
-
const updatedSVG = { ...svgObj, svg: { ...svgNode, image } }
|
|
28
|
-
const builder = new Builder()
|
|
29
|
-
return builder.buildObject(updatedSVG)
|
|
30
|
-
}
|
package/src/index.ts
DELETED