Skip to content

Commit

Permalink
chore(playground): update resvg-wasm (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeetiss authored Feb 7, 2023
1 parent 9c5ad5f commit cf348f6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 138 deletions.
8 changes: 5 additions & 3 deletions playground/components/resvg_worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as resvg from '@resvg/resvg-wasm'

fetch('/resvg.wasm').then((res) => resvg.initWasm(res))
const wasmPath = new URL('@resvg/resvg-wasm/index_bg.wasm', import.meta.url)
fetch(wasmPath).then((res) => resvg.initWasm(res))

self.onmessage = (e) => {
const { svg, width, _id } = e.data
Expand All @@ -11,7 +12,8 @@ self.onmessage = (e) => {
value: width,
},
})
const pngData = renderer.render()
const url = URL.createObjectURL(new Blob([pngData], { type: 'image/png' }))
const image = renderer.render()
const pngBuffer = image.asPng()
const url = URL.createObjectURL(new Blob([pngBuffer], { type: 'image/png' }))
self.postMessage({ _id, url })
}
3 changes: 1 addition & 2 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"dependencies": {
"@babel/runtime": "^7.19.0",
"@monaco-editor/react": "^4.4.5",
"@resvg/resvg-js": "^1.4.0",
"@resvg/resvg-wasm": "2.0.0-alpha.4",
"@resvg/resvg-wasm": "^2.3.1",
"blob-stream": "^0.1.3",
"copy-to-clipboard": "^3.3.2",
"fflate": "^0.7.3",
Expand Down
9 changes: 8 additions & 1 deletion playground/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ async function init() {
res.arrayBuffer()
),
!globalThis.Intl || !globalThis.Intl.Segmenter
? createIntlSegmenterPolyfill(fetch('/break_iterator.wasm'))
? createIntlSegmenterPolyfill(
fetch(
new URL(
'intl-segmenter-polyfill/dist/break_iterator.wasm',
import.meta.url
)
)
)
: null,
]))

Expand Down
Binary file removed playground/public/break_iterator.wasm
Binary file not shown.
Binary file removed playground/public/resvg.wasm
Binary file not shown.
136 changes: 4 additions & 132 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit cf348f6

@vercel
Copy link

@vercel vercel bot commented on cf348f6 Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.