Skip to content
Merged
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
15 changes: 12 additions & 3 deletions pcdeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,23 @@ class PCDEditor {
setupControls(this.pcdeditor)
resolve()
}
const go = new global.Go()
let go
if (typeof globalThis !== 'undefined' && typeof globalThis.Go !== 'undefined') {
go = new globalThis.Go()
} else if (typeof global !== 'undefined' && typeof global.Go !== 'undefined') {
go = new global.Go()
} else {
this.logger("'Go' could not be defined from neither globalThis nor global")
return
}
const { instance } = await WebAssembly.instantiateStreaming(
fetch(this.opts.wasmPath, { cache: 'no-cache' }),
go.importObject,
)
go.run(instance)
}
if (typeof global === 'undefined' || typeof global.Go === 'undefined') {
if ((typeof globalThis === 'undefined' || typeof globalThis.Go === 'undefined') &&
(typeof global === 'undefined' || typeof global.Go === 'undefined')) {
const script = document.createElement('script')
script.onload = loadWasm
script.src = this.opts.wasmExecPath
Expand Down Expand Up @@ -417,7 +426,7 @@ class PCDEditor {
return resp.blob()
})
.then((yamlBlob) => {
const img = new global.Image()
const img = new Image()
img.onload = async () => {
await this.pcdeditor.import2D(yamlBlob, img)
resolve()
Expand Down