Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(playground): update resvg-wasm #383

Merged
merged 5 commits into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.