feat(web): finish RE 5000PBR lesson video and fix non-ASCII GLB import
- Add 11:07 Chinese-narrated lesson video, VTT, poster and 13 chapter screenshots. - Regenerate 20-render WebGL2 matrix and 15 operation captures on RTX 4060. - Fix WASM staging for non-ASCII import filenames (猴头.glb); rebuild web_engine. - Harden lesson video recording pipeline; fix stale lesson-link E2E selector. - Add RE PBR derived libraries, lesson page, evidence and status report. Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -148,7 +148,11 @@ export class StorageClient {
|
||||
}
|
||||
|
||||
getAssetCatalog(): Promise<StorageAssetCatalogResult> {
|
||||
return this.request({ type: "getAssetCatalog" }) as Promise<StorageAssetCatalogResult>;
|
||||
return this.request({ type: "getAssetCatalog" }, [], undefined, 30_000) as Promise<StorageAssetCatalogResult>;
|
||||
}
|
||||
|
||||
mergeAssetCatalogManifest(manifest: unknown, projectId = "asset-library"): Promise<StorageAssetCatalogResult> {
|
||||
return this.request({ type: "mergeAssetCatalogManifest", projectId, manifest }, [], undefined, 30_000) as Promise<StorageAssetCatalogResult>;
|
||||
}
|
||||
|
||||
seedAssetCatalog(
|
||||
@@ -162,11 +166,13 @@ export class StorageClient {
|
||||
return this.request(
|
||||
{ type: "seedAssetCatalog", projectId, manifest, library, previews: [...previews], seedId, repair },
|
||||
[library, ...previews.map((entry) => entry.data)],
|
||||
undefined,
|
||||
60_000,
|
||||
) as Promise<StorageAssetCatalogResult>;
|
||||
}
|
||||
|
||||
readAssetCatalogPreview(projectId: string, sha256: string): Promise<StorageAssetCatalogPreviewReadResult> {
|
||||
return this.request({ type: "readAssetCatalogPreview", projectId, sha256 }) as Promise<StorageAssetCatalogPreviewReadResult>;
|
||||
return this.request({ type: "readAssetCatalogPreview", projectId, sha256 }, [], undefined, 30_000) as Promise<StorageAssetCatalogPreviewReadResult>;
|
||||
}
|
||||
|
||||
commitAssetCatalogPreview(projectId: string, expectedRevision: number, identity: unknown, data: ArrayBuffer): Promise<StorageAssetCatalogCommitResult> {
|
||||
@@ -241,7 +247,7 @@ export class StorageClient {
|
||||
return this.pending.size;
|
||||
}
|
||||
|
||||
private request(command: StorageRequest["command"], transfer: Transferable[] = [], signal?: AbortSignal): Promise<NonNullable<StorageResponse["result"]>> {
|
||||
private request(command: StorageRequest["command"], transfer: Transferable[] = [], signal?: AbortSignal, timeoutMs = 10_000): Promise<NonNullable<StorageResponse["result"]>> {
|
||||
if (signal?.aborted) return Promise.reject(new DOMException("Storage request aborted", "AbortError"));
|
||||
let worker: Worker;
|
||||
try {
|
||||
@@ -260,7 +266,7 @@ export class StorageClient {
|
||||
pending.cleanupAbort?.();
|
||||
worker.postMessage({ requestId: `storage-cancel-${++this.counter}`, command: { type: "cancelRequest", targetRequestId: requestId } } satisfies StorageRequest);
|
||||
reject(new Error("StorageWorker timeout"));
|
||||
}, 10_000);
|
||||
}, timeoutMs);
|
||||
const abort = () => {
|
||||
const pending = this.pending.get(requestId);
|
||||
if (!pending) return;
|
||||
|
||||
@@ -4,14 +4,18 @@ import {
|
||||
readAssetCatalogIndexedDBIndex,
|
||||
type AssetCatalogIndexRowV2,
|
||||
} from "./asset-catalog-indexeddb";
|
||||
import { parseAssetCatalogManifestV2, type AssetCatalogManifestV2IR } from "../../../protocol/asset-catalog-v2";
|
||||
import {
|
||||
mergeAssetCatalogManifests,
|
||||
parseAssetCatalogManifestV2,
|
||||
type AssetCatalogManifestV2IR,
|
||||
} from "../../../protocol/asset-catalog-v2";
|
||||
import type {
|
||||
StorageAssetCatalogCommitResult,
|
||||
StorageAssetCatalogPreviewReadResult,
|
||||
StorageAssetCatalogResult,
|
||||
StorageAssetCatalogSeedIR,
|
||||
} from "../../../protocol/storage";
|
||||
import { commitAssetPreviewToOPFS } from "./asset-preview-opfs-commit";
|
||||
import { ASSET_PREVIEW_CATALOG_HEAD_ID, commitAssetPreviewToOPFS } from "./asset-preview-opfs-commit";
|
||||
import { readContentAsset, writeContentAsset } from "./opfs-files";
|
||||
|
||||
export const ASSET_CATALOG_SEED_ID = "asset-catalog:seed:v1" as const;
|
||||
@@ -25,6 +29,15 @@ async function sha256(data: ArrayBuffer): Promise<string> {
|
||||
return hex(await crypto.subtle.digest("SHA-256", data));
|
||||
}
|
||||
|
||||
function stableJSON(value: unknown): string {
|
||||
if (Array.isArray(value)) return `[${value.map(stableJSON).join(",")}]`;
|
||||
if (value && typeof value === "object") {
|
||||
const record = value as Record<string, unknown>;
|
||||
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableJSON(record[key])}`).join(",")}}`;
|
||||
}
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
|
||||
function readStored<T>(store: IDBObjectStore, id: string): Promise<T | undefined> {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = store.get(id);
|
||||
@@ -180,4 +193,47 @@ export async function commitAssetCatalogPreview(
|
||||
};
|
||||
}
|
||||
|
||||
export async function mergeAssetCatalogManifest(
|
||||
database: IDBDatabase,
|
||||
options: { manifest: unknown; projectId?: string },
|
||||
): Promise<StorageAssetCatalogResult> {
|
||||
const incoming = await parseAssetCatalogManifestV2(options.manifest);
|
||||
const readTransaction = database.transaction("setting", "readonly");
|
||||
const row = await readStored<{ id: string; value: unknown }>(
|
||||
readTransaction.objectStore("setting"),
|
||||
ASSET_CATALOG_INDEX_V2_ID,
|
||||
);
|
||||
await complete(readTransaction);
|
||||
if (!row) throw new Error("Asset catalog v2 index is missing");
|
||||
const existing = await parseAssetCatalogManifestV2(row.value);
|
||||
const merged = await mergeAssetCatalogManifests(existing, incoming);
|
||||
|
||||
const transaction = database.transaction("setting", "readwrite");
|
||||
const store = transaction.objectStore("setting");
|
||||
let failure: Error | undefined;
|
||||
const completion = complete(transaction);
|
||||
const request = store.get(ASSET_CATALOG_INDEX_V2_ID);
|
||||
request.onerror = () => {
|
||||
failure = request.error ?? new Error("Asset catalog merge recheck failed");
|
||||
};
|
||||
request.onsuccess = () => {
|
||||
const current = request.result as { id: string; value: unknown } | undefined;
|
||||
if (!current || stableJSON(current.value) !== stableJSON(row.value)) {
|
||||
failure = new Error("Asset catalog revision changed while merging");
|
||||
transaction.abort();
|
||||
return;
|
||||
}
|
||||
store.put({ id: ASSET_CATALOG_INDEX_V2_ID, value: merged.manifest } satisfies AssetCatalogIndexRowV2);
|
||||
// A merge bumps the manifest revision; the preview head receipt would be stale.
|
||||
store.delete(ASSET_PREVIEW_CATALOG_HEAD_ID);
|
||||
};
|
||||
try {
|
||||
await completion;
|
||||
} catch (error) {
|
||||
throw failure ?? error;
|
||||
}
|
||||
if (failure) throw failure;
|
||||
return { manifest: merged.manifest, seed: await readSeed(database) };
|
||||
}
|
||||
|
||||
export type { AssetCatalogManifestV2IR };
|
||||
|
||||
Reference in New Issue
Block a user