nowebcli 0.2.11 → 0.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/scripts/noweb.mjs
CHANGED
|
@@ -162,12 +162,15 @@ async function createCover() {
|
|
|
162
162
|
server.once("error", reject);
|
|
163
163
|
server.listen(0, "127.0.0.1", resolve);
|
|
164
164
|
});
|
|
165
|
-
browser = await chromium.launch({ headless: true, args: ["--enable-unsafe-swiftshader", "--use-angle=swiftshader"] });
|
|
165
|
+
browser = await chromium.launch({ headless: true, args: ["--enable-unsafe-swiftshader", "--enable-unsafe-webgpu", "--use-angle=swiftshader"] });
|
|
166
166
|
const page = await browser.newPage({ viewport: { width: 1920, height: 1080 }, deviceScaleFactor: 1 });
|
|
167
167
|
const errors = [];
|
|
168
168
|
page.on("pageerror", (error) => errors.push(error.message));
|
|
169
169
|
page.on("console", (message) => { if (message.type() === "error") errors.push(message.text()); });
|
|
170
170
|
await page.goto(`http://127.0.0.1:${server.address().port}`, { waitUntil: "load" });
|
|
171
|
+
if (template.source.includes("shaders/react") && !await page.evaluate(async () => Boolean(await navigator.gpu?.requestAdapter()))) {
|
|
172
|
+
throw new Error("Cannot create shader cover: Chromium has no WebGPU adapter. Update Chromium with `npx playwright install chromium`.");
|
|
173
|
+
}
|
|
171
174
|
await page.waitForFunction(() => document.getElementById("root")?.childElementCount, undefined, { timeout: 15_000 }).catch(() => {
|
|
172
175
|
throw new Error(`Template did not render: ${errors.slice(0, 3).join("; ") || "empty preview"}`);
|
|
173
176
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { execFile } from "node:child_process";
|
|
2
2
|
import { existsSync } from "node:fs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
3
4
|
import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
4
5
|
import { tmpdir } from "node:os";
|
|
5
6
|
import path from "node:path";
|
|
@@ -17,6 +18,8 @@ const modulesPath = existsSync(path.join(packageModulesPath, ".bin", "esbuild"))
|
|
|
17
18
|
? packageModulesPath
|
|
18
19
|
: path.join(process.cwd(), "node_modules");
|
|
19
20
|
|
|
21
|
+
const require = createRequire(import.meta.url);
|
|
22
|
+
|
|
20
23
|
const TEMPLATE_COMPILE_TIMEOUT_MS = 10_000;
|
|
21
24
|
const TEMPLATE_COMPILE_MAX_BUFFER = 8 * 1024 * 1024;
|
|
22
25
|
const TEMPLATE_RUNTIME_IMPORT = "noweb";
|
|
@@ -165,6 +168,10 @@ function customizationDefaults(
|
|
|
165
168
|
|
|
166
169
|
function runtimeAliases() {
|
|
167
170
|
return [
|
|
171
|
+
// npx and project dependencies must share the renderer's React instance.
|
|
172
|
+
...["react", "react-dom"].map((name) =>
|
|
173
|
+
`--alias:${name}=${path.dirname(require.resolve(`${name}/package.json`, { paths: [modulesPath] }))}`,
|
|
174
|
+
),
|
|
168
175
|
...TEMPLATE_RUNTIME_IMPORTS.map(
|
|
169
176
|
(moduleName) => `--alias:${moduleName}=${templateRuntimePath()}`,
|
|
170
177
|
),
|