mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-21 12:49:23 +08:00
This strategy allows us to synchronously init the wasm, without needing a patch on the npm package --------- Co-authored-by: Jarek Radosz <jarek@cvx.dev>
29 lines
704 B
JavaScript
Vendored
29 lines
704 B
JavaScript
Vendored
/* global rails */
|
|
|
|
import "core-js/actual/url";
|
|
import { TextDecoder, TextEncoder } from "fastestsmallesttextencoderdecoder";
|
|
import path from "path";
|
|
import getRandomValues from "polyfill-crypto.getrandomvalues";
|
|
|
|
const CONSOLE_PREFIX = "[DiscourseJsProcessor] ";
|
|
globalThis.window = {};
|
|
globalThis.console = {
|
|
log(...args) {
|
|
rails.logger.info(CONSOLE_PREFIX + args.join(" "));
|
|
},
|
|
warn(...args) {
|
|
rails.logger.warn(CONSOLE_PREFIX + args.join(" "));
|
|
},
|
|
error(...args) {
|
|
rails.logger.error(CONSOLE_PREFIX + args.join(" "));
|
|
},
|
|
};
|
|
|
|
globalThis.TextEncoder = TextEncoder;
|
|
globalThis.TextDecoder = TextDecoder;
|
|
|
|
path.win32 = {
|
|
sep: "/",
|
|
};
|
|
|
|
globalThis.crypto = { getRandomValues };
|