@terrafirmagreg-team/dump 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/dump",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Game-dump readers and contracts",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
"src"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@terrafirmagreg-team/data": "1.2.
|
|
18
|
-
"@terrafirmagreg-team/sites": "1.2.
|
|
19
|
-
"@terrafirmagreg-team/translate": "1.2.
|
|
17
|
+
"@terrafirmagreg-team/data": "1.2.1",
|
|
18
|
+
"@terrafirmagreg-team/sites": "1.2.1",
|
|
19
|
+
"@terrafirmagreg-team/translate": "1.2.3",
|
|
20
20
|
"aws4fetch": "^1.0.20",
|
|
21
21
|
"fumadocs-core": "16.17.8"
|
|
22
22
|
},
|
|
@@ -118,13 +118,9 @@ export function createDumpAssetResolver(
|
|
|
118
118
|
const base =
|
|
119
119
|
typeof window === 'undefined' ? 'http://x.invalid' : location.origin;
|
|
120
120
|
prefix ??= new URL(dumpStorageUrl(''), base).href;
|
|
121
|
-
let resourcePath: string;
|
|
122
121
|
let modelAbs: URL;
|
|
123
122
|
try {
|
|
124
123
|
modelAbs = new URL(modelUrl, base);
|
|
125
|
-
const resource = new URL(resourceUrl, modelAbs);
|
|
126
|
-
if (resource.origin !== modelAbs.origin) return undefined;
|
|
127
|
-
resourcePath = resource.pathname;
|
|
128
124
|
} catch {
|
|
129
125
|
return undefined;
|
|
130
126
|
}
|
|
@@ -135,7 +131,19 @@ export function createDumpAssetResolver(
|
|
|
135
131
|
modelHref.slice(prefix.length),
|
|
136
132
|
);
|
|
137
133
|
if (!modelRel) return undefined;
|
|
138
|
-
const
|
|
134
|
+
const modelDirHref = pathDir(modelHref);
|
|
135
|
+
let rel: string | undefined;
|
|
136
|
+
if (resourceUrl.startsWith(modelDirHref)) {
|
|
137
|
+
rel = resourceUrl.slice(modelDirHref.length);
|
|
138
|
+
} else {
|
|
139
|
+
try {
|
|
140
|
+
const resource = new URL(resourceUrl, modelAbs);
|
|
141
|
+
if (resource.origin !== modelAbs.origin) return undefined;
|
|
142
|
+
rel = relativePath(pathDir(modelAbs.pathname), resource.pathname);
|
|
143
|
+
} catch {
|
|
144
|
+
return undefined;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
139
147
|
if (!rel || !rel.includes('/')) return undefined;
|
|
140
148
|
const dumpRel = resolveAssetRel(pathDir(modelRel), rel);
|
|
141
149
|
if (!dumpRel) return undefined;
|
|
@@ -107,16 +107,29 @@ export function dumpTextureUrl(
|
|
|
107
107
|
return texturePublicUrl(dataset, textureId);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
export async function multiblockModelIndex(
|
|
111
|
+
dataset: DatasetRef,
|
|
112
|
+
namespace: string,
|
|
113
|
+
): Promise<unknown | undefined> {
|
|
114
|
+
return (
|
|
115
|
+
(await clientDumpJson(
|
|
116
|
+
dataset,
|
|
117
|
+
`assets/${namespace}/models/multiblock.json`,
|
|
118
|
+
)) ??
|
|
119
|
+
(await clientDumpJson(
|
|
120
|
+
dataset,
|
|
121
|
+
`data/${namespace}/models/multiblock.json`,
|
|
122
|
+
))
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
110
126
|
export async function dumpModelUrl(
|
|
111
127
|
dataset: DatasetRef,
|
|
112
128
|
modelId: string,
|
|
113
129
|
): Promise<string | undefined> {
|
|
114
130
|
const parts = splitDumpId(modelId.trim());
|
|
115
131
|
if (!parts) return undefined;
|
|
116
|
-
const index = await
|
|
117
|
-
dataset,
|
|
118
|
-
`data/${parts.ns}/models/multiblock.json`,
|
|
119
|
-
);
|
|
132
|
+
const index = await multiblockModelIndex(dataset, parts.ns);
|
|
120
133
|
const rel =
|
|
121
134
|
index && typeof index === 'object' && !Array.isArray(index)
|
|
122
135
|
? (index as Record<string, unknown>)[modelId]
|
|
@@ -208,7 +208,12 @@ export class JsonDumpReader implements DumpReader {
|
|
|
208
208
|
private async objectsIndex(
|
|
209
209
|
root: string,
|
|
210
210
|
): Promise<Record<string, string> | undefined> {
|
|
211
|
-
const raw =
|
|
211
|
+
const raw =
|
|
212
|
+
(await fetchJsonGz(
|
|
213
|
+
dumpStorageUrl(`${root}/objects.json.gz`),
|
|
214
|
+
false,
|
|
215
|
+
)) ??
|
|
216
|
+
(await fetchJson(dumpStorageUrl(`${root}/objects.json`), false));
|
|
212
217
|
const files =
|
|
213
218
|
raw && typeof raw === 'object' && !Array.isArray(raw)
|
|
214
219
|
? (raw as Record<string, unknown>).files
|