diff --git a/app/assets/javascripts/patches/content-tag+1.1.2.patch b/app/assets/javascripts/patches/content-tag+1.1.2.patch deleted file mode 100644 index 26f796d8115..00000000000 --- a/app/assets/javascripts/patches/content-tag+1.1.2.patch +++ /dev/null @@ -1,29 +0,0 @@ -diff --git a/node_modules/content-tag/content_tag.js b/node_modules/content-tag/content_tag.js -index e9be50d..9e20da2 100644 ---- a/node_modules/content-tag/content_tag.js -+++ b/node_modules/content-tag/content_tag.js -@@ -448,11 +448,17 @@ module.exports.__wbindgen_memory = function() { - return addHeapObject(ret); - }; - --const path = require('path').join(__dirname, 'content_tag_bg.wasm'); --const bytes = require('fs').readFileSync(path); -- --const wasmModule = new WebAssembly.Module(bytes); --const wasmInstance = new WebAssembly.Instance(wasmModule, imports); --wasm = wasmInstance.exports; --module.exports.__wasm = wasm; -+// Check for nodejs environment -+if (process.version) { -+ const path = require('path').join(__dirname, 'content_tag_bg.wasm'); -+ const bytes = require('fs').readFileSync(path); -+ -+ const wasmModule = new WebAssembly.Module(bytes); -+ const wasmInstance = new WebAssembly.Instance(wasmModule, imports); -+ wasm = wasmInstance.exports; -+} else { -+ const load = require('./content_tag_bg.wasm').default; -+ wasm = load(imports); -+ module.exports.__wasm = wasm; -+} - diff --git a/app/assets/javascripts/patches/content-tag+1.2.1.patch b/app/assets/javascripts/patches/content-tag+1.2.1.patch new file mode 100644 index 00000000000..825ecf06486 --- /dev/null +++ b/app/assets/javascripts/patches/content-tag+1.2.1.patch @@ -0,0 +1,25 @@ +diff --git a/node_modules/content-tag/pkg/standalone.js b/node_modules/content-tag/pkg/standalone.js +index 0df00d7..c19b607 100644 +--- a/node_modules/content-tag/pkg/standalone.js ++++ b/node_modules/content-tag/pkg/standalone.js +@@ -1,5 +1,6 @@ +-import init from "./standalone/content_tag.js"; ++import { initSync } from "./standalone/content_tag.js"; ++import module from "./standalone/content_tag_bg.wasm"; + +-await init(); ++initSync(module); + + export { Preprocessor } from "./standalone/content_tag.js"; +diff --git a/node_modules/content-tag/pkg/standalone/content_tag.js b/node_modules/content-tag/pkg/standalone/content_tag.js +index 70545cf..e6eb36b 100644 +--- a/node_modules/content-tag/pkg/standalone/content_tag.js ++++ b/node_modules/content-tag/pkg/standalone/content_tag.js +@@ -20,6 +20,7 @@ function takeObject(idx) { + return ret; + } + ++const { TextDecoder, TextEncoder } = require('util'); + const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); + + if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; diff --git a/app/assets/javascripts/theme-transpiler/build.js b/app/assets/javascripts/theme-transpiler/build.js index 57f649b5ac3..e2396061ca4 100644 --- a/app/assets/javascripts/theme-transpiler/build.js +++ b/app/assets/javascripts/theme-transpiler/build.js @@ -31,12 +31,7 @@ let wasmPlugin = { build.onLoad({ filter: /.*/, namespace: "wasm-stub" }, async (args) => { return { - contents: `import wasm from ${JSON.stringify(args.path)}; - export default (imports) => { - const wasmModule = new WebAssembly.Module(wasm); - const wasmInstance = new WebAssembly.Instance(wasmModule, imports); - return wasmInstance.exports; - };`, + contents: `export { default } from ${JSON.stringify(args.path)};`, }; }); diff --git a/app/assets/javascripts/theme-transpiler/package.json b/app/assets/javascripts/theme-transpiler/package.json index 68bd5dd591f..46e86f1f0b1 100644 --- a/app/assets/javascripts/theme-transpiler/package.json +++ b/app/assets/javascripts/theme-transpiler/package.json @@ -10,7 +10,7 @@ "@babel/standalone": "^7.23.6", "@zxing/text-encoding": "^0.9.0", "babel-plugin-ember-template-compilation": "^2.2.1", - "content-tag": "^1.1.2", + "content-tag": "^1.2.1", "discourse-common": "1.0.0", "discourse-widget-hbs": "1.0.0", "ember-cli-htmlbars": "^6.3.0", diff --git a/app/assets/javascripts/yarn-ember3.lock b/app/assets/javascripts/yarn-ember3.lock index 6cddb6ebbc4..f1f564d90ff 100644 --- a/app/assets/javascripts/yarn-ember3.lock +++ b/app/assets/javascripts/yarn-ember3.lock @@ -4325,6 +4325,11 @@ content-tag@^1.1.2: resolved "https://registry.yarnpkg.com/content-tag/-/content-tag-1.1.2.tgz#a7adddfdd2d44c9418b795c91ee04c55f570a997" integrity sha512-AZkfc6TUmW+/RbZJioPzOQPAHHXqyqK4B0GNckJDjBAPK3SyGrMfn21bfFky/qwi5uoLph5sjAHUkO3CL6/IgQ== +content-tag@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/content-tag/-/content-tag-1.2.1.tgz#5bb23443d2ddf316657994fb333fdc1d4a161be8" + integrity sha512-aKOsM+GojHMvRuqOa+qamATA3IEK9QksXcIX2NSGHpU5euNhrg6mZFT3Z7kDuNz55sH9NRPJKqeGhkhaq9ED2w== + content-type@~1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918" diff --git a/app/assets/javascripts/yarn-ember5.lock b/app/assets/javascripts/yarn-ember5.lock index 6cddb6ebbc4..f1f564d90ff 100644 --- a/app/assets/javascripts/yarn-ember5.lock +++ b/app/assets/javascripts/yarn-ember5.lock @@ -4325,6 +4325,11 @@ content-tag@^1.1.2: resolved "https://registry.yarnpkg.com/content-tag/-/content-tag-1.1.2.tgz#a7adddfdd2d44c9418b795c91ee04c55f570a997" integrity sha512-AZkfc6TUmW+/RbZJioPzOQPAHHXqyqK4B0GNckJDjBAPK3SyGrMfn21bfFky/qwi5uoLph5sjAHUkO3CL6/IgQ== +content-tag@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/content-tag/-/content-tag-1.2.1.tgz#5bb23443d2ddf316657994fb333fdc1d4a161be8" + integrity sha512-aKOsM+GojHMvRuqOa+qamATA3IEK9QksXcIX2NSGHpU5euNhrg6mZFT3Z7kDuNz55sH9NRPJKqeGhkhaq9ED2w== + content-type@~1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/content-type/-/content-type-1.0.5.tgz#8b773162656d1d1086784c8f23a54ce6d73d7918"