feat: integrate Pi backend and Pi Web

This commit is contained in:
luckyyzh
2026-07-30 19:37:53 +08:00
commit 7392ab9dd7
1390 changed files with 337197 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
// In-memory roots that should be browsable in addition to roots derived from
// persisted sessions. Stored on globalThis so Next.js hot-reload keeps them.
declare global {
var __piAllowedRootsCache: { roots: Set<string>; expiresAt: number } | undefined;
var __piAdditionalAllowedRoots: Set<string> | undefined;
}
export function normalizeSlashes(filePath: string): string {
return filePath.replace(/\\/g, "/");
}
export function getAdditionalAllowedRoots(): Set<string> {
if (!globalThis.__piAdditionalAllowedRoots) {
globalThis.__piAdditionalAllowedRoots = new Set();
}
return globalThis.__piAdditionalAllowedRoots;
}
export function allowFileRoot(root: string): void {
if (!root) return;
const normalizedRoot = normalizeSlashes(root);
getAdditionalAllowedRoots().add(normalizedRoot);
globalThis.__piAllowedRootsCache?.roots.add(normalizedRoot);
}