chore: import upstream snapshot with attribution
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
import { version } from '@freecodecamp/browser-scripts/package.json';
|
||||
// work around for SASS error in Edge
|
||||
// https://github.com/medialize/sass.js/issues/96#issuecomment-424386171
|
||||
interface WorkerWithSass extends Worker {
|
||||
Sass: {
|
||||
compile(data: unknown, callback: unknown): void;
|
||||
};
|
||||
}
|
||||
|
||||
const ctx: WorkerWithSass & typeof globalThis =
|
||||
self as unknown as WorkerWithSass & typeof globalThis;
|
||||
|
||||
if (!ctx.crypto) {
|
||||
(ctx.crypto as unknown) = {
|
||||
getRandomValues: function (array: number[]) {
|
||||
for (let i = 0, l = array.length; i < l; i++) {
|
||||
array[i] = Math.floor(Math.random() * 256);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ctx.importScripts(`/js/workers/${version}/sass.sync.js`);
|
||||
|
||||
ctx.onmessage = e => {
|
||||
const data: unknown = e.data;
|
||||
ctx.Sass.compile(data, (result: Record<string, unknown>) => {
|
||||
if (result.status === 0) {
|
||||
ctx.postMessage(result.text);
|
||||
} else {
|
||||
ctx.postMessage({
|
||||
type: 'error',
|
||||
data: { message: result.formatted }
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ctx.postMessage({ type: 'contentLoaded' });
|
||||
Reference in New Issue
Block a user