Compare commits
2 Commits
main
...
codex/fix-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aebcedaf71 | ||
|
|
74801ae7d6 |
@ -17,6 +17,7 @@ location ^~ /vendor/zoo-modeling-app/fonts/ {
|
||||
location = /vendor/zoo-modeling-app/kcl_wasm_lib_bg.wasm {
|
||||
root /var/www/ai-chatbot/public;
|
||||
try_files $uri =404;
|
||||
gzip_static on;
|
||||
add_header Cache-Control "public, max-age=3600" always;
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@ export default defineConfig({
|
||||
/routes\/canvas-runtime-internal-endpoint\.test\.ts/,
|
||||
/routes\/model-classification\.test\.ts/,
|
||||
/routes\/clawd-request-lifecycle\.test\.ts/,
|
||||
/routes\/hicad-embedded-performance\.test\.ts/,
|
||||
],
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
|
||||
@ -140,6 +140,12 @@ function patchOfficialSource() {
|
||||
" <title>Zoo Design Studio</title>",
|
||||
" <title>HiCAD</title>"
|
||||
);
|
||||
replaceSource(
|
||||
"index.html",
|
||||
' <meta name="theme-color" content="#000000" />',
|
||||
` <meta name="theme-color" content="#000000" />
|
||||
<link rel="preload" href="./kcl_wasm_lib_bg.wasm" as="fetch" type="application/wasm" crossorigin="use-credentials" />`
|
||||
);
|
||||
replaceSource(
|
||||
"src/Router.tsx",
|
||||
" createBrowserRouter,\n createHashRouter,",
|
||||
@ -225,6 +231,19 @@ function patchOfficialSource() {
|
||||
` className="cursor-pointer"\n id="freeze-frame"`,
|
||||
` className="absolute inset-0 h-full w-full cursor-pointer"\n id="freeze-frame"`
|
||||
);
|
||||
replaceSource(
|
||||
"src/components/OpenedProject.tsx",
|
||||
"import { getMlEphantProjectReloadBehavior } from '@src/components/openedProjectUtils'\n",
|
||||
"import { getMlEphantProjectReloadBehavior } from '@src/components/openedProjectUtils'\nimport env from '@src/env'\n"
|
||||
);
|
||||
replaceSource(
|
||||
"src/components/OpenedProject.tsx",
|
||||
` const needsOnboarded =
|
||||
!window.electron &&`,
|
||||
` const needsOnboarded =
|
||||
env().VITE_ZOO_API_TOKEN !== '${proxyToken}' &&
|
||||
!window.electron &&`
|
||||
);
|
||||
replaceSource(
|
||||
"src/index.tsx",
|
||||
"import { markOnce } from '@src/lib/performance'\n",
|
||||
@ -250,6 +269,25 @@ function patchOfficialSource() {
|
||||
` // We need a padding of 0.1 for zoom_to_fit for all E2E tests since they were originally\n // written with zoom_to_fit with padding 0.1\n const padding = 0.1\n if (isPlaywright()) {`,
|
||||
` // Keep the official E2E framing stable while giving HiCAD users enough\n // breathing room to see the complete model after generation and file loads.\n const padding = isPlaywright() ? 0.1 : 0.35\n if (isPlaywright()) {`
|
||||
);
|
||||
replaceSource(
|
||||
"src/lib/resetCameraPosition.ts",
|
||||
` await engineViewIsometric({
|
||||
engineCommandManager,
|
||||
padding,
|
||||
})`,
|
||||
` await engineViewIsometric({
|
||||
engineCommandManager,
|
||||
padding,
|
||||
})
|
||||
|
||||
// view_isometric changes the direction but can preserve the previous
|
||||
// close-up distance. Refit against every generated entity so newly
|
||||
// completed models open fully framed instead of showing a local detail.
|
||||
await engineStreamZoomToFit({
|
||||
engineCommandManager,
|
||||
padding,
|
||||
})`
|
||||
);
|
||||
replaceSource(
|
||||
"src/lib/commandBarConfigs/standardViewsConfig.ts",
|
||||
"engineStreamZoomToFit({ engineCommandManager, padding: 0.1 })",
|
||||
@ -357,7 +395,7 @@ function ensureWasm() {
|
||||
|
||||
function precompressVersionedAssets(assetsDir) {
|
||||
for (const entry of readdirSync(assetsDir, { withFileTypes: true })) {
|
||||
if (!entry.isFile() || !/\.(?:css|js)$/.test(entry.name)) {
|
||||
if (!entry.isFile() || !/\.(?:css|js|wasm)$/.test(entry.name)) {
|
||||
continue;
|
||||
}
|
||||
const assetPath = path.join(assetsDir, entry.name);
|
||||
@ -365,6 +403,15 @@ function precompressVersionedAssets(assetsDir) {
|
||||
}
|
||||
}
|
||||
|
||||
function precompressRootWasm(buildDir) {
|
||||
const wasmPath = path.join(buildDir, "kcl_wasm_lib_bg.wasm");
|
||||
if (!existsSync(wasmPath)) return;
|
||||
writeFileSync(
|
||||
`${wasmPath}.gz`,
|
||||
gzipSync(readFileSync(wasmPath), { level: 9 })
|
||||
);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
ensureOfficialSource();
|
||||
ensureDependencies();
|
||||
@ -393,6 +440,7 @@ async function main() {
|
||||
throw new Error("Zoo Design Studio build did not produce index.html");
|
||||
}
|
||||
precompressVersionedAssets(path.join(buildDir, "assets"));
|
||||
precompressRootWasm(buildDir);
|
||||
cacheBustZooModelingAppAssets(buildDir);
|
||||
|
||||
rmSync(outputDir, { force: true, recursive: true });
|
||||
|
||||
57
tests/routes/hicad-embedded-performance.test.ts
Normal file
57
tests/routes/hicad-embedded-performance.test.ts
Normal file
@ -0,0 +1,57 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
const projectRoot = process.cwd();
|
||||
|
||||
test.describe("HiCAD embedded startup", () => {
|
||||
test("suppresses the upstream onboarding chooser in embedded mode", () => {
|
||||
const vendorScript = fs.readFileSync(
|
||||
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),
|
||||
"utf8"
|
||||
);
|
||||
const localization = fs.readFileSync(
|
||||
path.join(projectRoot, "vendor/zoo-modeling-app/localization.ts"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
expect(vendorScript).toMatch(
|
||||
/env\(\)\.VITE_ZOO_API_TOKEN !== '\$\{proxyToken\}'/
|
||||
);
|
||||
expect(localization).toContain("[data-testid='onboarding-toast']");
|
||||
});
|
||||
|
||||
test("preloads and serves the CAD wasm using a precompressed asset", () => {
|
||||
const vendorScript = fs.readFileSync(
|
||||
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),
|
||||
"utf8"
|
||||
);
|
||||
const nginxTemplate = fs.readFileSync(
|
||||
path.join(projectRoot, "deploy/nginx-hicad-zoo-ws.conf.template"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
expect(vendorScript).toContain(
|
||||
'rel="preload" href="./kcl_wasm_lib_bg.wasm"'
|
||||
);
|
||||
expect(vendorScript).toContain("/\\.(?:css|js|wasm)$/");
|
||||
expect(vendorScript).toContain("precompressRootWasm(buildDir)");
|
||||
expect(nginxTemplate).toMatch(
|
||||
/location = \/vendor\/zoo-modeling-app\/kcl_wasm_lib_bg\.wasm \{[\s\S]*?gzip_static on;/
|
||||
);
|
||||
});
|
||||
|
||||
test("fits the complete generated model after selecting the isometric view", () => {
|
||||
const vendorScript = fs.readFileSync(
|
||||
path.join(projectRoot, "scripts/vendor-zoo-modeling-app.mjs"),
|
||||
"utf8"
|
||||
);
|
||||
|
||||
expect(vendorScript).toMatch(
|
||||
/await engineViewIsometric\(\{[\s\S]*?await engineStreamZoomToFit\(\{\s*engineCommandManager,\s*padding,/
|
||||
);
|
||||
expect(vendorScript).toContain(
|
||||
"Refit against every generated entity so newly"
|
||||
);
|
||||
});
|
||||
});
|
||||
1
vendor/zoo-modeling-app/localization.ts
vendored
1
vendor/zoo-modeling-app/localization.ts
vendored
@ -199,6 +199,7 @@ export function installHiCadLocalization() {
|
||||
}
|
||||
html[data-hicad-embedded='true'] [data-testid='download-desktop-app'],
|
||||
html[data-hicad-embedded='true'] [data-testid='billing-remaining-bar'],
|
||||
html[data-hicad-embedded='true'] [data-testid='onboarding-toast'],
|
||||
html[data-hicad-embedded='true'] [data-hicad-official-account-link] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user