mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-08 17:02:17 +00:00
Failures while the app loads left only the splash, with nothing to report. Handlers in public/boot.js now load before the module graph and replace the splash with an error page with copyable diagnostics and a report link, for module load errors, rejected startup, initial render errors and a 30-second timeout. A successful start cancels the timer. The production build also rejects selected newer startup APIs and unsupported regex and import syntax. The original macOS 11 trigger remains unconfirmed. Refs #2008
44 lines
1.7 KiB
TypeScript
44 lines
1.7 KiB
TypeScript
// @vitest-environment node
|
|
import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import { join } from "node:path";
|
|
import { expect, it } from "vitest";
|
|
import { checkBuild, checkSource } from "./check-webkit.ts";
|
|
|
|
it.each([
|
|
"Promise.withResolvers()",
|
|
"Object.groupBy(items, key)",
|
|
"Array.fromAsync(items)",
|
|
"text.toWellFormed()",
|
|
'new RegExp("[a-z]", "v")',
|
|
'RegExp("(?<=a)b")',
|
|
"/[a-z]/v",
|
|
"/(?<!a)b/",
|
|
'import data from "./data.json" with { type: "json" }',
|
|
])("rejects %s in the Safari 16 startup graph", (source) => {
|
|
expect(checkSource(source, true).length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it("does not mistake regex detection strings or named groups for newer syntax", () => {
|
|
expect(checkSource('const message = "(?<=a)"; const regex = /(?<name>a)/u;', true)).toEqual([]);
|
|
expect(checkSource("const regex = /(\\(\\?<=)|(\\(\\?<!)/;", true)).toEqual([]);
|
|
});
|
|
|
|
it("checks the entry's static imports and all lazy chunks for syntax", () => {
|
|
const dir = mkdtempSync(join(tmpdir(), "openidea-webkit-"));
|
|
try {
|
|
mkdirSync(join(dir, "assets"));
|
|
writeFileSync(join(dir, "index.html"), '<script type="module" src="/assets/entry.js"></script>');
|
|
writeFileSync(join(dir, "boot.js"), "");
|
|
writeFileSync(join(dir, "assets/entry.js"), 'import "./dependency.js"; import("./lazy.js");');
|
|
writeFileSync(join(dir, "assets/dependency.js"), "Promise.withResolvers();");
|
|
writeFileSync(join(dir, "assets/lazy.js"), "Object.groupBy(items, key); const re = /[a-z]/v;");
|
|
expect(checkBuild(dir)).toEqual([
|
|
"assets/dependency.js: Promise.withResolvers requires newer WebKit",
|
|
"assets/lazy.js: RegExp v flag requires Safari 17",
|
|
]);
|
|
} finally {
|
|
rmSync(dir, { recursive: true });
|
|
}
|
|
});
|