@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.
Files changed (51) hide show
  1. package/dist/node/Plugin.d.ts +4 -0
  2. package/dist/node/Plugin.d.ts.map +1 -0
  3. package/dist/node/Witness/Config.d.ts +20 -0
  4. package/dist/node/Witness/Config.d.ts.map +1 -0
  5. package/dist/node/Witness/Params.d.ts +7 -0
  6. package/dist/node/Witness/Params.d.ts.map +1 -0
  7. package/dist/node/Witness/Witness.d.ts +37 -0
  8. package/dist/node/Witness/Witness.d.ts.map +1 -0
  9. package/dist/node/Witness/ffmpeg/fluent/getVideoFrameAsImageFluent.d.ts +7 -0
  10. package/dist/node/Witness/ffmpeg/fluent/getVideoFrameAsImageFluent.d.ts.map +1 -0
  11. package/dist/node/Witness/ffmpeg/fluent/index.d.ts +2 -0
  12. package/dist/node/Witness/ffmpeg/fluent/index.d.ts.map +1 -0
  13. package/dist/node/Witness/ffmpeg/index.d.ts +3 -0
  14. package/dist/node/Witness/ffmpeg/index.d.ts.map +1 -0
  15. package/dist/node/Witness/ffmpeg/spawn/executeFfmpeg.d.ts +8 -0
  16. package/dist/node/Witness/ffmpeg/spawn/executeFfmpeg.d.ts.map +1 -0
  17. package/dist/node/Witness/ffmpeg/spawn/getVideoFrameAsImage.d.ts +7 -0
  18. package/dist/node/Witness/ffmpeg/spawn/getVideoFrameAsImage.d.ts.map +1 -0
  19. package/dist/node/Witness/ffmpeg/spawn/index.d.ts +3 -0
  20. package/dist/node/Witness/ffmpeg/spawn/index.d.ts.map +1 -0
  21. package/dist/node/Witness/index.d.ts +4 -0
  22. package/dist/node/Witness/index.d.ts.map +1 -0
  23. package/dist/node/Witness/lib/checkIpfsUrl.d.ts +8 -0
  24. package/dist/node/Witness/lib/checkIpfsUrl.d.ts.map +1 -0
  25. package/dist/node/Witness/lib/createDataUrl.d.ts +2 -0
  26. package/dist/node/Witness/lib/createDataUrl.d.ts.map +1 -0
  27. package/dist/node/Witness/lib/index.d.ts +4 -0
  28. package/dist/node/Witness/lib/index.d.ts.map +1 -0
  29. package/dist/node/Witness/lib/resolveDynamicSvg.d.ts +2 -0
  30. package/dist/node/Witness/lib/resolveDynamicSvg.d.ts.map +1 -0
  31. package/dist/node/index.d.ts +4 -0
  32. package/dist/node/index.d.ts.map +1 -0
  33. package/dist/node/index.mjs +404 -0
  34. package/dist/node/index.mjs.map +1 -0
  35. package/package.json +26 -8
  36. package/src/Plugin.ts +0 -21
  37. package/src/Witness/Config.ts +0 -22
  38. package/src/Witness/Params.ts +0 -10
  39. package/src/Witness/Witness.ts +0 -320
  40. package/src/Witness/ffmpeg/fluent/getVideoFrameAsImageFluent.ts +0 -73
  41. package/src/Witness/ffmpeg/fluent/index.ts +0 -1
  42. package/src/Witness/ffmpeg/index.ts +0 -2
  43. package/src/Witness/ffmpeg/spawn/executeFfmpeg.ts +0 -27
  44. package/src/Witness/ffmpeg/spawn/getVideoFrameAsImage.ts +0 -11
  45. package/src/Witness/ffmpeg/spawn/index.ts +0 -2
  46. package/src/Witness/index.ts +0 -3
  47. package/src/Witness/lib/checkIpfsUrl.ts +0 -43
  48. package/src/Witness/lib/createDataUrl.ts +0 -5
  49. package/src/Witness/lib/index.ts +0 -3
  50. package/src/Witness/lib/resolveDynamicSvg.ts +0 -30
  51. 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
- }
@@ -1,5 +0,0 @@
1
- import { fromByteArray } from 'base64-js'
2
-
3
- export const createDataUrl = (data: ArrayBufferLike, contextType: string, encoding: 'base64' = 'base64') => {
4
- return `data:${contextType};${encoding},${fromByteArray(new Uint8Array(data))}`
5
- }
@@ -1,3 +0,0 @@
1
- export * from './checkIpfsUrl.ts'
2
- export * from './createDataUrl.ts'
3
- export * from './resolveDynamicSvg.ts'
@@ -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
@@ -1,3 +0,0 @@
1
- export { ImageThumbnailPlugin as default, ImageThumbnailPlugin } from './Plugin.ts'
2
- export * from './Witness/index.ts'
3
- export * from '@xyo-network/diviner-image-thumbnail'