Files
orca/config/scripts/orcad-distribution/server-bundle/orcad-mobile-web-bundle.mjs
Kelvin Amoaba 64a2a6f779 perf(mobile): let newer phones fetch their language catalog from the desktop instead of downloading all of them (#40519)
* perf(mobile): let newer phone shells fetch the language catalog from the desktop instead of downloading all of them

* fix(mobile): hash only the buildId fields so phone readers can recompute it

* fix(mobile): use the catalog chunk when the generation still has it

* fix(desktop): give catalog reads their own read-slot budget
2026-11-10 03:52:19 +00:00

31 lines
1.3 KiB
JavaScript

import { cpSync, readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join } from 'node:path'
import {
ORCAD_MOBILE_WEB_DIR,
ORCAD_MOBILE_WEB_MANIFEST,
orcadMobileWebAssetFilenames
} from '../../../../src/shared/orcad-artifacts.ts'
const { MOBILE_WEB_BUNDLE_DIR, assertMobileWebBundleBuilt } = createRequire(import.meta.url)(
'../../desktop-distribution/runtime-verification/verify-packaged-mobile-web-bundle.cjs'
)
const { assertNoDarkOutputOfOffSwitches } = createRequire(import.meta.url)(
'../../../dark-build-switches.cjs'
)
// Require a fresh built page as beforePack does: an orcad package without it cannot serve phones.
export function stageOrcadMobileWebBundle(outputDir, bundleDir = MOBILE_WEB_BUNDLE_DIR) {
// The release template refuses the variable itself.
assertNoDarkOutputOfOffSwitches([bundleDir])
assertMobileWebBundleBuilt(bundleDir)
// The guard refuses unlisted files, so the tree is the manifest, its assets and catalogs, and a dark marker.
cpSync(bundleDir, join(outputDir, ...ORCAD_MOBILE_WEB_DIR.split('/')), { recursive: true })
}
export function readOrcadMobileWebAssetFilenames(packageDir) {
return orcadMobileWebAssetFilenames(
readFileSync(join(packageDir, ...ORCAD_MOBILE_WEB_MANIFEST.split('/')), 'utf8')
)
}