refactor: migrate legacy wire namespace to wrn
This commit is contained in:
@@ -54,7 +54,7 @@ test("server actions validate, enforce CSRF, invalidate, and progressively enhan
|
||||
expect(html).toContain('name="wrnexus-csrf"');
|
||||
expect(html).toContain("/__wrnexus/actions.js");
|
||||
const cookie = page!.headers.get("set-cookie")!;
|
||||
const token = /wire-csrf=([^;]+)/.exec(cookie)?.[1];
|
||||
const token = /wrn-csrf=([^;]+)/.exec(cookie)?.[1];
|
||||
if (!token) throw new Error("expected CSRF cookie");
|
||||
|
||||
const invalid = await handlers.fetch(
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mkdtempSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "nod
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
compileWireArtifactsAsync,
|
||||
compileWrnArtifactsAsync,
|
||||
setCompileCacheDir,
|
||||
setCompileImportOptions,
|
||||
} from "../src/pipeline.ts";
|
||||
@@ -27,7 +27,7 @@ page Settings {
|
||||
|
||||
try {
|
||||
setCompileCacheDir(cache);
|
||||
const artifacts = await compileWireArtifactsAsync(page);
|
||||
const artifacts = await compileWrnArtifactsAsync(page);
|
||||
const browser = readFileSync(artifacts.browser, "utf8");
|
||||
expect(browser).toContain("wrnexus-client-bundled");
|
||||
expect(browser).not.toContain("file://");
|
||||
@@ -65,7 +65,7 @@ page Settings {
|
||||
aliases: { "~": "./app" },
|
||||
autoImport: false,
|
||||
});
|
||||
const artifacts = await compileWireArtifactsAsync(page);
|
||||
const artifacts = await compileWrnArtifactsAsync(page);
|
||||
const browser = readFileSync(artifacts.browser, "utf8");
|
||||
expect(browser).toContain("wrnexus-client-bundled");
|
||||
expect(browser).not.toContain("~/client/storage.ts");
|
||||
@@ -81,7 +81,7 @@ page Settings {
|
||||
aliases: { "~": "./alternate" },
|
||||
autoImport: false,
|
||||
});
|
||||
const changed = await compileWireArtifactsAsync(page);
|
||||
const changed = await compileWrnArtifactsAsync(page);
|
||||
expect(changed.browser).not.toBe(artifacts.browser);
|
||||
} finally {
|
||||
setCompileCacheDir(null);
|
||||
|
||||
@@ -3,7 +3,7 @@ import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
import {
|
||||
compileWireArtifacts,
|
||||
compileWrnArtifacts,
|
||||
setCompileCacheDir,
|
||||
setCompileImportOptions,
|
||||
} from "../src/pipeline.ts";
|
||||
@@ -31,24 +31,24 @@ function fixture(): { root: string; page: string } {
|
||||
test("legacy, compatible, and explicit import modes are enforced from app config", () => {
|
||||
const { root, page } = fixture();
|
||||
setCompileImportOptions(root, { mode: "legacy" });
|
||||
expect(() => compileWireArtifacts(page, 1)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 1)).not.toThrow();
|
||||
|
||||
const warnings: string[] = [];
|
||||
const originalWarn = console.warn;
|
||||
console.warn = (...args) => warnings.push(args.join(" "));
|
||||
try {
|
||||
setCompileImportOptions(root, { mode: "compatible" });
|
||||
expect(() => compileWireArtifacts(page, 2)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 2)).not.toThrow();
|
||||
expect(warnings.some((message) => message.includes("WRN-IMPORT-IMPLICIT"))).toBe(true);
|
||||
|
||||
setCompileImportOptions(root, { mode: "explicit" });
|
||||
expect(() => compileWireArtifacts(page, 3)).toThrow("WRN-IMPORT-IMPLICIT");
|
||||
expect(() => compileWrnArtifacts(page, 3)).toThrow("WRN-IMPORT-IMPLICIT");
|
||||
|
||||
writeFileSync(
|
||||
page,
|
||||
'import Card from "@/components/Card.wrn"\npage Home { view { <Card /> } }',
|
||||
);
|
||||
expect(() => compileWireArtifacts(page, 4)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 4)).not.toThrow();
|
||||
} finally {
|
||||
console.warn = originalWarn;
|
||||
}
|
||||
@@ -68,5 +68,5 @@ test("compiler-native reactive elements do not require application imports", ()
|
||||
}`,
|
||||
);
|
||||
setCompileImportOptions(root, { mode: "explicit" });
|
||||
expect(() => compileWireArtifacts(page, 5)).not.toThrow();
|
||||
expect(() => compileWrnArtifacts(page, 5)).not.toThrow();
|
||||
});
|
||||
|
||||
@@ -3,8 +3,8 @@ import { mkdtempSync, rmSync, utimesSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
compileWireArtifacts,
|
||||
compileWireArtifactsAsync,
|
||||
compileWrnArtifacts,
|
||||
compileWrnArtifactsAsync,
|
||||
getWrnCompileMetrics,
|
||||
invalidateModule,
|
||||
loadModule,
|
||||
@@ -32,7 +32,7 @@ test("development compilation awaits plugin AST and code transforms", async () =
|
||||
});
|
||||
try {
|
||||
writeFileSync(file, "page Home { view { <h1>Plugin</h1> } }\n");
|
||||
const artifact = await compileWireArtifactsAsync(file);
|
||||
const artifact = await compileWrnArtifactsAsync(file);
|
||||
expect(astTransformed).toBeTrue();
|
||||
expect((await import(artifact.main)).pluginTransformed).toBeTrue();
|
||||
} finally {
|
||||
@@ -48,10 +48,10 @@ test("WRN compilation exposes cache hit, miss, timing, and error metrics", () =>
|
||||
resetWrnCompileMetrics();
|
||||
try {
|
||||
writeFileSync(file, "page Home { view { <h1>Metrics</h1> } }\n");
|
||||
compileWireArtifacts(file);
|
||||
compileWireArtifacts(file);
|
||||
compileWrnArtifacts(file);
|
||||
compileWrnArtifacts(file);
|
||||
writeFileSync(file, "page Broken { view { <h1> } }\n");
|
||||
expect(() => compileWireArtifacts(file)).toThrow();
|
||||
expect(() => compileWrnArtifacts(file)).toThrow();
|
||||
expect(getWrnCompileMetrics()).toMatchObject({
|
||||
hits: 1,
|
||||
misses: 2,
|
||||
|
||||
@@ -2,13 +2,13 @@ import { expect, test } from "bun:test";
|
||||
import { HMR_CLIENT_JS, collectScripts } from "../src/runtime.ts";
|
||||
|
||||
test("accent controls load the shared theme runtime", () => {
|
||||
expect(collectScripts('<button data-wire-accent-set="rose">Rose</button>')).toContain(
|
||||
expect(collectScripts('<button data-wrn-accent-set="rose">Rose</button>')).toContain(
|
||||
"/__wrnexus/theme.js",
|
||||
);
|
||||
});
|
||||
|
||||
test("accent clear controls load the shared theme runtime", () => {
|
||||
expect(collectScripts("<button data-wire-accent-clear>Reset</button>")).toContain(
|
||||
expect(collectScripts("<button data-wrn-accent-clear>Reset</button>")).toContain(
|
||||
"/__wrnexus/theme.js",
|
||||
);
|
||||
});
|
||||
@@ -20,9 +20,9 @@ test("HMR preserves the active browser theme and accent", () => {
|
||||
|
||||
expect(HMR_CLIENT_JS).toMatch(/var nextLang\s*=\s*doc\.documentElement\.getAttribute\("lang"\)/);
|
||||
|
||||
expect(HMR_CLIENT_JS).toMatch(/typeof\s+window\.wireTheme\.bind\s*===\s*"function"/);
|
||||
expect(HMR_CLIENT_JS).toMatch(/typeof\s+window\.wrnTheme\.bind\s*===\s*"function"/);
|
||||
|
||||
expect(HMR_CLIENT_JS).toMatch(/window\.wireTheme\.bind\(document\)/);
|
||||
expect(HMR_CLIENT_JS).toMatch(/window\.wrnTheme\.bind\(document\)/);
|
||||
|
||||
expect(HMR_CLIENT_JS).toContain('new CustomEvent("wrnexus:hmr-updated"');
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import { expect, test } from "bun:test";
|
||||
import { createDevAssetServer } from "../src/assets.ts";
|
||||
|
||||
test("UI CSS is read from its live source after an HMR change", async () => {
|
||||
let css = ".wire-card { color: red; }";
|
||||
let css = ".wrn-card { color: red; }";
|
||||
const assets = createDevAssetServer(
|
||||
process.cwd(),
|
||||
"development",
|
||||
@@ -14,7 +14,7 @@ test("UI CSS is read from its live source after an HMR change", async () => {
|
||||
const first = await assets.serve("/__wrnexus/ui.css");
|
||||
expect(await first?.text()).toContain("color: red");
|
||||
|
||||
css = ".wire-card { color: blue; }";
|
||||
css = ".wrn-card { color: blue; }";
|
||||
assets.invalidateCss();
|
||||
|
||||
const second = await assets.serve("/__wrnexus/ui.css");
|
||||
|
||||
Reference in New Issue
Block a user