mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Master merge first attempt
This commit is contained in:
parent
1e819a2acf
commit
550c874c9b
419 changed files with 24252 additions and 3446 deletions
|
@ -34,12 +34,14 @@ Object.defineProperty(window, "FontFace", {
|
|||
private source: string;
|
||||
private descriptors: any;
|
||||
private status: string;
|
||||
private unicodeRange: string;
|
||||
|
||||
constructor(family, source, descriptors) {
|
||||
this.family = family;
|
||||
this.source = source;
|
||||
this.descriptors = descriptors;
|
||||
this.status = "unloaded";
|
||||
this.unicodeRange = "U+0000-00FF";
|
||||
}
|
||||
|
||||
load() {
|
||||
|
@ -61,27 +63,26 @@ Object.defineProperty(window, "EXCALIDRAW_ASSET_PATH", {
|
|||
value: `file://${__dirname}/`,
|
||||
});
|
||||
|
||||
// mock the font fetch only, so that everything else, as font subsetting, can run inside of the (snapshot) tests
|
||||
vi.mock(
|
||||
"./packages/excalidraw/fonts/ExcalidrawFont",
|
||||
"./packages/excalidraw/fonts/ExcalidrawFontFace",
|
||||
async (importOriginal) => {
|
||||
const mod = await importOriginal<
|
||||
typeof import("./packages/excalidraw/fonts/ExcalidrawFont")
|
||||
typeof import("./packages/excalidraw/fonts/ExcalidrawFontFace")
|
||||
>();
|
||||
const ExcalidrawFontImpl = mod.ExcalidrawFont;
|
||||
const ExcalidrawFontFaceImpl = mod.ExcalidrawFontFace;
|
||||
|
||||
return {
|
||||
...mod,
|
||||
ExcalidrawFont: class extends ExcalidrawFontImpl {
|
||||
public async getContent(): Promise<string> {
|
||||
const url = this.urls[0];
|
||||
|
||||
if (url.protocol !== "file:") {
|
||||
return super.getContent(new Set());
|
||||
ExcalidrawFontFace: class extends ExcalidrawFontFaceImpl {
|
||||
public async fetchFont(url: URL): Promise<ArrayBuffer> {
|
||||
if (!url.toString().startsWith("file://")) {
|
||||
return super.fetchFont(url);
|
||||
}
|
||||
|
||||
// read local assets directly, without running a server
|
||||
const content = await fs.promises.readFile(url);
|
||||
return `data:font/woff2;base64,${content.toString("base64")}`;
|
||||
return content.buffer;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -104,7 +105,7 @@ console.error = (...args) => {
|
|||
// the react's act() warning usually doesn't contain any useful stack trace
|
||||
// so we're catching the log and re-logging the message with the test name,
|
||||
// also stripping the actual component stack trace as it's not useful
|
||||
if (args[0]?.includes("act(")) {
|
||||
if (args[0]?.includes?.("act(")) {
|
||||
_consoleError(
|
||||
yellow(
|
||||
`<<< WARNING: test "${
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue