mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
refactor(browser): map artifact failures at one boundary
This commit is contained in:
1 parent
73be86c39e
commit
5b0373db11
2 files changed
+34
-64
No files matched your search
@@ -60,39 +60,24 @@ export class LocalWebSourceLocationArtifacts implements WebSourceLocationArtifac
|
||||
async #load(input: WebSourceLocationInput, options?: ExecutionOptions) {
|
||||
const loaded = await this.scripts.load(input, options);
|
||||
if (!loaded.ok) return loaded;
|
||||
try {
|
||||
const data = await readStableArtifact(
|
||||
input.source_map.path,
|
||||
WEB_SOURCE_MAP_LIMITS.mapBytes,
|
||||
options?.signal,
|
||||
undefined,
|
||||
this.#resources,
|
||||
);
|
||||
return ok({
|
||||
...loaded.value,
|
||||
sourceMap: {
|
||||
file: {
|
||||
path: input.source_map.path,
|
||||
sha256: data.sha256,
|
||||
bytes: data.bytes.length,
|
||||
},
|
||||
url: input.source_map.url,
|
||||
text: decodeWebArtifact(data.bytes),
|
||||
const data = await readStableArtifact(
|
||||
input.source_map.path,
|
||||
WEB_SOURCE_MAP_LIMITS.mapBytes,
|
||||
options?.signal,
|
||||
undefined,
|
||||
this.#resources,
|
||||
);
|
||||
return ok({
|
||||
...loaded.value,
|
||||
sourceMap: {
|
||||
file: {
|
||||
path: input.source_map.path,
|
||||
sha256: data.sha256,
|
||||
bytes: data.bytes.length,
|
||||
},
|
||||
});
|
||||
} catch (cause: unknown) {
|
||||
return err(
|
||||
webArtifactReadError(
|
||||
cause,
|
||||
{
|
||||
operation: "trace_web_source_location",
|
||||
field: ["source_map", "path"],
|
||||
targetPath: input.source_map.path,
|
||||
callerSelected: true,
|
||||
},
|
||||
options?.signal,
|
||||
),
|
||||
);
|
||||
}
|
||||
url: input.source_map.url,
|
||||
text: decodeWebArtifact(data.bytes),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -69,36 +69,21 @@ export class LocalWebModuleArtifacts implements WebModuleArtifactPort {
|
||||
if (input.import_map === undefined)
|
||||
return ok({ ...loaded.value, importMap: null });
|
||||
const selected = input.import_map;
|
||||
try {
|
||||
const data = await readWebArtifactJson(
|
||||
selected.path,
|
||||
4 * 1024 * 1024,
|
||||
options?.signal,
|
||||
this.#resources,
|
||||
);
|
||||
const importMap: WebModuleArtifacts["importMap"] = {
|
||||
file: {
|
||||
path: selected.path,
|
||||
sha256: data.sha256,
|
||||
bytes: data.bytes.length,
|
||||
},
|
||||
baseUrl: selected.base_url,
|
||||
value: jsonObjectSchema.parse(data.value),
|
||||
};
|
||||
return ok({ ...loaded.value, importMap });
|
||||
} catch (cause: unknown) {
|
||||
return err(
|
||||
webArtifactReadError(
|
||||
cause,
|
||||
{
|
||||
operation: "trace_web_module_imports",
|
||||
field: ["import_map", "path"],
|
||||
targetPath: selected.path,
|
||||
callerSelected: true,
|
||||
},
|
||||
options?.signal,
|
||||
),
|
||||
);
|
||||
}
|
||||
const data = await readWebArtifactJson(
|
||||
selected.path,
|
||||
4 * 1024 * 1024,
|
||||
options?.signal,
|
||||
this.#resources,
|
||||
);
|
||||
const importMap: WebModuleArtifacts["importMap"] = {
|
||||
file: {
|
||||
path: selected.path,
|
||||
sha256: data.sha256,
|
||||
bytes: data.bytes.length,
|
||||
},
|
||||
baseUrl: selected.base_url,
|
||||
value: jsonObjectSchema.parse(data.value),
|
||||
};
|
||||
return ok({ ...loaded.value, importMap });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user