Skip to content

Commit

Permalink
Revert thumbo import
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-leamon committed Apr 12, 2024
1 parent 5a83550 commit 629c621
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"version": "1.0.98",
"version": "1.0.99",
"description": "Formation is a comprehensive component library powered by React, Styled Components, and CSS variables for creating apps and websites that demand responsive, unified cross-platform experiences.",
"resolutions": {
"string-width": "^4",
Expand Down
20 changes: 6 additions & 14 deletions src/utils/generateThumbnail.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
import { resourceUrlToDataUrl } from '../internal';
import { resourceUrlToDataUrl } from '../internal'

let Thumbo: any
let Transfer: any
let isThumboInitialized = false // Flag to track whether Thumbo has been initialized

// Function to initialize Thumbo if it hasn't been already and if in a browser environment
const initializeThumbo = async () => {
if (typeof window !== 'undefined' && !isThumboInitialized) {
const ThumboLib = require('thumbo')
Thumbo = ThumboLib.default
Transfer = ThumboLib.Transfer
await Thumbo.init()
isThumboInitialized = true
}
if (typeof window !== 'undefined') {
const ThumboLib = require('thumbo')
Thumbo = ThumboLib.default
Transfer = ThumboLib.Transfer
Thumbo.init()
}

const generateImageThumbnail = async (file: File, callback: (image: string) => void, maxDimension = 256) => {
await initializeThumbo()

const ext = file.type.split('/')[1]

try {
Expand Down

0 comments on commit 629c621

Please sign in to comment.