@eve-online-tools/eve-resfile 0.0.1
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/README.md +109 -0
- package/dist/chunk-D665R74X.js +63 -0
- package/dist/chunk-IX5WVBZL.js +65 -0
- package/dist/chunk-RP7V25VC.js +229 -0
- package/dist/chunk-YCJ3SYSF.js +203 -0
- package/dist/index.cjs +256 -0
- package/dist/index.d.cts +23 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +34 -0
- package/dist/rollup/index.cjs +322 -0
- package/dist/rollup/index.d.cts +6 -0
- package/dist/rollup/index.d.ts +6 -0
- package/dist/rollup/index.js +64 -0
- package/dist/types-DUuyxUdh.d.cts +28 -0
- package/dist/types-DUuyxUdh.d.ts +28 -0
- package/dist/vite/client.d.ts +4 -0
- package/dist/vite/index.cjs +416 -0
- package/dist/vite/index.d.cts +6 -0
- package/dist/vite/index.d.ts +6 -0
- package/dist/vite/index.js +154 -0
- package/package.json +80 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __async = (__this, __arguments, generator) => {
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
var fulfilled = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
step(generator.next(value));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
reject(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var rejected = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.throw(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/index.ts
|
|
41
|
+
var index_exports = {};
|
|
42
|
+
__export(index_exports, {
|
|
43
|
+
DEFAULT_ASSET_ORIGIN: () => DEFAULT_ASSET_ORIGIN,
|
|
44
|
+
DEFAULT_CACHE_DIR: () => DEFAULT_CACHE_DIR,
|
|
45
|
+
DEFAULT_INDEX_ORIGIN: () => DEFAULT_INDEX_ORIGIN,
|
|
46
|
+
DEV_PROXY_PREFIX: () => DEV_PROXY_PREFIX,
|
|
47
|
+
EVE_CLIENT_MANIFEST: () => EVE_CLIENT_MANIFEST,
|
|
48
|
+
RESFILE_INDEX_PATH: () => RESFILE_INDEX_PATH,
|
|
49
|
+
RES_IMPORT_PREFIX: () => RES_IMPORT_PREFIX,
|
|
50
|
+
devProxyUrl: () => devProxyUrl,
|
|
51
|
+
findResfileIndexCdnPath: () => findResfileIndexCdnPath,
|
|
52
|
+
loadResfileIndexData: () => loadResfileIndexData,
|
|
53
|
+
lookupCdnPath: () => lookupCdnPath,
|
|
54
|
+
normalizeResPath: () => normalizeResPath,
|
|
55
|
+
parseFirstTwoColumns: () => parseFirstTwoColumns,
|
|
56
|
+
parseResfileIndex: () => parseResfileIndex,
|
|
57
|
+
resPathFromDevProxyUrl: () => resPathFromDevProxyUrl
|
|
58
|
+
});
|
|
59
|
+
module.exports = __toCommonJS(index_exports);
|
|
60
|
+
|
|
61
|
+
// src/constants.ts
|
|
62
|
+
var DEFAULT_INDEX_ORIGIN = "https://binaries.eveonline.com";
|
|
63
|
+
var DEFAULT_ASSET_ORIGIN = "https://resources.eveonline.com";
|
|
64
|
+
var DEFAULT_CACHE_DIR = ".cache/eve-resfile";
|
|
65
|
+
var EVE_CLIENT_MANIFEST = "eveclient_TQ.json";
|
|
66
|
+
var RESFILE_INDEX_PATH = "app:/resfileindex.txt";
|
|
67
|
+
var DEV_PROXY_PREFIX = "/__eve_res__/";
|
|
68
|
+
var RES_IMPORT_PREFIX = "res:/";
|
|
69
|
+
|
|
70
|
+
// src/index-loader.ts
|
|
71
|
+
var import_promises2 = require("fs/promises");
|
|
72
|
+
|
|
73
|
+
// src/cache.ts
|
|
74
|
+
var import_node_fs = require("fs");
|
|
75
|
+
var import_promises = require("fs/promises");
|
|
76
|
+
var import_node_path = require("path");
|
|
77
|
+
var buildCacheDir = (cacheDir, buildNumber) => (0, import_node_path.join)(cacheDir, buildNumber);
|
|
78
|
+
var buildIndexPath = (cacheDir, buildNumber) => (0, import_node_path.join)(buildCacheDir(cacheDir, buildNumber), "build-index.txt");
|
|
79
|
+
var resfileIndexPath = (cacheDir, buildNumber) => (0, import_node_path.join)(buildCacheDir(cacheDir, buildNumber), "resfileindex.txt");
|
|
80
|
+
var resfileMapPath = (cacheDir, buildNumber) => (0, import_node_path.join)(buildCacheDir(cacheDir, buildNumber), "resfile-map.json");
|
|
81
|
+
var readCachedText = (path) => __async(null, null, function* () {
|
|
82
|
+
if (!(0, import_node_fs.existsSync)(path)) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
return (0, import_promises.readFile)(path, "utf8");
|
|
86
|
+
});
|
|
87
|
+
var writeCachedText = (path, content) => __async(null, null, function* () {
|
|
88
|
+
yield (0, import_promises.mkdir)((0, import_node_path.join)(path, ".."), { recursive: true });
|
|
89
|
+
yield (0, import_promises.writeFile)(path, content);
|
|
90
|
+
});
|
|
91
|
+
var readCachedMap = (path) => __async(null, null, function* () {
|
|
92
|
+
if (!(0, import_node_fs.existsSync)(path)) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
const parsed = JSON.parse(yield (0, import_promises.readFile)(path, "utf8"));
|
|
96
|
+
return new Map(Object.entries(parsed));
|
|
97
|
+
});
|
|
98
|
+
var writeCachedMap = (path, map) => __async(null, null, function* () {
|
|
99
|
+
yield (0, import_promises.mkdir)((0, import_node_path.join)(path, ".."), { recursive: true });
|
|
100
|
+
yield (0, import_promises.writeFile)(path, JSON.stringify(Object.fromEntries(map)));
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
// src/fetch.ts
|
|
104
|
+
var fetchText = (url) => __async(null, null, function* () {
|
|
105
|
+
const response = yield fetch(url);
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
throw new Error(`Failed to fetch ${url} (${response.status}).`);
|
|
108
|
+
}
|
|
109
|
+
return response.text();
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// src/parse.ts
|
|
113
|
+
var parseFirstTwoColumns = (line) => {
|
|
114
|
+
const commaIndex = line.indexOf(",");
|
|
115
|
+
if (commaIndex === -1) {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
const path = line.slice(0, commaIndex);
|
|
119
|
+
const remainder = line.slice(commaIndex + 1);
|
|
120
|
+
const secondComma = remainder.indexOf(",");
|
|
121
|
+
const cdnPath = secondComma === -1 ? remainder : remainder.slice(0, secondComma);
|
|
122
|
+
if (!path || !cdnPath) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return [path, cdnPath];
|
|
126
|
+
};
|
|
127
|
+
var parseResfileIndex = (content) => {
|
|
128
|
+
const map = /* @__PURE__ */ new Map();
|
|
129
|
+
for (const line of content.split("\n")) {
|
|
130
|
+
const trimmed = line.trim();
|
|
131
|
+
if (!trimmed) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
const parsed = parseFirstTwoColumns(trimmed);
|
|
135
|
+
if (!parsed) {
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const [resPath, cdnPath] = parsed;
|
|
139
|
+
map.set(resPath, cdnPath);
|
|
140
|
+
}
|
|
141
|
+
return map;
|
|
142
|
+
};
|
|
143
|
+
var findResfileIndexCdnPath = (buildIndex) => {
|
|
144
|
+
for (const line of buildIndex.split("\n")) {
|
|
145
|
+
const trimmed = line.trim();
|
|
146
|
+
if (!trimmed) {
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const parsed = parseFirstTwoColumns(trimmed);
|
|
150
|
+
if (!parsed) {
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
const [path, cdnPath] = parsed;
|
|
154
|
+
if (path === RESFILE_INDEX_PATH) {
|
|
155
|
+
return cdnPath;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
throw new Error(`${RESFILE_INDEX_PATH} not found in build index.`);
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
// src/index-loader.ts
|
|
162
|
+
var resolveBuildNumber = (options) => __async(null, null, function* () {
|
|
163
|
+
if (options.buildNumber !== void 0) {
|
|
164
|
+
return String(options.buildNumber);
|
|
165
|
+
}
|
|
166
|
+
const manifestUrl = `${options.indexOrigin}/${EVE_CLIENT_MANIFEST}`;
|
|
167
|
+
const manifest = JSON.parse(yield fetchText(manifestUrl));
|
|
168
|
+
if (!manifest.buildNumber) {
|
|
169
|
+
throw new Error(`Missing buildNumber in ${manifestUrl}.`);
|
|
170
|
+
}
|
|
171
|
+
return manifest.buildNumber;
|
|
172
|
+
});
|
|
173
|
+
var loadBuildIndex = (options, buildNumber) => __async(null, null, function* () {
|
|
174
|
+
const cachedPath = buildIndexPath(options.cacheDir, buildNumber);
|
|
175
|
+
const cached = yield readCachedText(cachedPath);
|
|
176
|
+
if (cached) {
|
|
177
|
+
return cached;
|
|
178
|
+
}
|
|
179
|
+
const buildIndexUrl = `${options.indexOrigin}/eveonline_${buildNumber}.txt`;
|
|
180
|
+
const content = yield fetchText(buildIndexUrl);
|
|
181
|
+
yield writeCachedText(cachedPath, content);
|
|
182
|
+
return content;
|
|
183
|
+
});
|
|
184
|
+
var loadResfileIndex = (options, buildNumber, cdnPath) => __async(null, null, function* () {
|
|
185
|
+
const cachedPath = resfileIndexPath(options.cacheDir, buildNumber);
|
|
186
|
+
const cached = yield readCachedText(cachedPath);
|
|
187
|
+
if (cached) {
|
|
188
|
+
return cached;
|
|
189
|
+
}
|
|
190
|
+
const resfileIndexUrl = `${options.indexOrigin}/${cdnPath}`;
|
|
191
|
+
const content = yield fetchText(resfileIndexUrl);
|
|
192
|
+
yield writeCachedText(cachedPath, content);
|
|
193
|
+
return content;
|
|
194
|
+
});
|
|
195
|
+
var loadResfileIndexData = (options) => __async(null, null, function* () {
|
|
196
|
+
const { cacheDir } = options;
|
|
197
|
+
const buildNumber = yield resolveBuildNumber(options);
|
|
198
|
+
yield (0, import_promises2.mkdir)(buildCacheDir(cacheDir, buildNumber), { recursive: true });
|
|
199
|
+
const cachedMap = yield readCachedMap(resfileMapPath(cacheDir, buildNumber));
|
|
200
|
+
if (cachedMap) {
|
|
201
|
+
return { buildNumber, resPathToCdnPath: cachedMap };
|
|
202
|
+
}
|
|
203
|
+
const buildIndex = yield loadBuildIndex(options, buildNumber);
|
|
204
|
+
const resfileIndexCdnPath = findResfileIndexCdnPath(buildIndex);
|
|
205
|
+
const resfileIndex = yield loadResfileIndex(options, buildNumber, resfileIndexCdnPath);
|
|
206
|
+
const resPathToCdnPath = parseResfileIndex(resfileIndex);
|
|
207
|
+
yield writeCachedMap(resfileMapPath(cacheDir, buildNumber), resPathToCdnPath);
|
|
208
|
+
return { buildNumber, resPathToCdnPath };
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// src/lookup.ts
|
|
212
|
+
var normalizeResPath = (source) => {
|
|
213
|
+
var _a;
|
|
214
|
+
const withoutQuery = (_a = source.split(/[?#]/)[0]) != null ? _a : source;
|
|
215
|
+
if (withoutQuery.startsWith(RES_IMPORT_PREFIX)) {
|
|
216
|
+
return withoutQuery;
|
|
217
|
+
}
|
|
218
|
+
if (withoutQuery.startsWith("res:")) {
|
|
219
|
+
const path = withoutQuery.slice("res:".length);
|
|
220
|
+
return path.startsWith("/") ? `res:${path}` : `res:/${path}`;
|
|
221
|
+
}
|
|
222
|
+
throw new Error(`Invalid res import "${source}". Expected a path starting with "res:/".`);
|
|
223
|
+
};
|
|
224
|
+
var lookupCdnPath = (index, resPath) => index.get(resPath);
|
|
225
|
+
var devProxyUrl = (resPath) => {
|
|
226
|
+
const encoded = encodeURIComponent(resPath.slice(RES_IMPORT_PREFIX.length));
|
|
227
|
+
return `/__eve_res__/${encoded}`;
|
|
228
|
+
};
|
|
229
|
+
var resPathFromDevProxyUrl = (pathname) => {
|
|
230
|
+
if (!pathname.startsWith("/__eve_res__/")) {
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
const encoded = pathname.slice("/__eve_res__/".length);
|
|
234
|
+
if (!encoded) {
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
return `${RES_IMPORT_PREFIX}${decodeURIComponent(encoded)}`;
|
|
238
|
+
};
|
|
239
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
240
|
+
0 && (module.exports = {
|
|
241
|
+
DEFAULT_ASSET_ORIGIN,
|
|
242
|
+
DEFAULT_CACHE_DIR,
|
|
243
|
+
DEFAULT_INDEX_ORIGIN,
|
|
244
|
+
DEV_PROXY_PREFIX,
|
|
245
|
+
EVE_CLIENT_MANIFEST,
|
|
246
|
+
RESFILE_INDEX_PATH,
|
|
247
|
+
RES_IMPORT_PREFIX,
|
|
248
|
+
devProxyUrl,
|
|
249
|
+
findResfileIndexCdnPath,
|
|
250
|
+
loadResfileIndexData,
|
|
251
|
+
lookupCdnPath,
|
|
252
|
+
normalizeResPath,
|
|
253
|
+
parseFirstTwoColumns,
|
|
254
|
+
parseResfileIndex,
|
|
255
|
+
resPathFromDevProxyUrl
|
|
256
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { R as ResolvedEveResfileOptions, a as ResfileIndex } from './types-DUuyxUdh.cjs';
|
|
2
|
+
export { E as EveClientManifest, b as EveResfileOptions } from './types-DUuyxUdh.cjs';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_INDEX_ORIGIN = "https://binaries.eveonline.com";
|
|
5
|
+
declare const DEFAULT_ASSET_ORIGIN = "https://resources.eveonline.com";
|
|
6
|
+
declare const DEFAULT_CACHE_DIR = ".cache/eve-resfile";
|
|
7
|
+
declare const EVE_CLIENT_MANIFEST = "eveclient_TQ.json";
|
|
8
|
+
declare const RESFILE_INDEX_PATH = "app:/resfileindex.txt";
|
|
9
|
+
declare const DEV_PROXY_PREFIX = "/__eve_res__/";
|
|
10
|
+
declare const RES_IMPORT_PREFIX = "res:/";
|
|
11
|
+
|
|
12
|
+
declare const loadResfileIndexData: (options: ResolvedEveResfileOptions) => Promise<ResfileIndex>;
|
|
13
|
+
|
|
14
|
+
declare const normalizeResPath: (source: string) => string;
|
|
15
|
+
declare const lookupCdnPath: (index: Map<string, string>, resPath: string) => string | undefined;
|
|
16
|
+
declare const devProxyUrl: (resPath: string) => string;
|
|
17
|
+
declare const resPathFromDevProxyUrl: (pathname: string) => string | null;
|
|
18
|
+
|
|
19
|
+
declare const parseFirstTwoColumns: (line: string) => [string, string] | null;
|
|
20
|
+
declare const parseResfileIndex: (content: string) => Map<string, string>;
|
|
21
|
+
declare const findResfileIndexCdnPath: (buildIndex: string) => string;
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_ASSET_ORIGIN, DEFAULT_CACHE_DIR, DEFAULT_INDEX_ORIGIN, DEV_PROXY_PREFIX, EVE_CLIENT_MANIFEST, RESFILE_INDEX_PATH, RES_IMPORT_PREFIX, ResfileIndex, ResolvedEveResfileOptions, devProxyUrl, findResfileIndexCdnPath, loadResfileIndexData, lookupCdnPath, normalizeResPath, parseFirstTwoColumns, parseResfileIndex, resPathFromDevProxyUrl };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { R as ResolvedEveResfileOptions, a as ResfileIndex } from './types-DUuyxUdh.js';
|
|
2
|
+
export { E as EveClientManifest, b as EveResfileOptions } from './types-DUuyxUdh.js';
|
|
3
|
+
|
|
4
|
+
declare const DEFAULT_INDEX_ORIGIN = "https://binaries.eveonline.com";
|
|
5
|
+
declare const DEFAULT_ASSET_ORIGIN = "https://resources.eveonline.com";
|
|
6
|
+
declare const DEFAULT_CACHE_DIR = ".cache/eve-resfile";
|
|
7
|
+
declare const EVE_CLIENT_MANIFEST = "eveclient_TQ.json";
|
|
8
|
+
declare const RESFILE_INDEX_PATH = "app:/resfileindex.txt";
|
|
9
|
+
declare const DEV_PROXY_PREFIX = "/__eve_res__/";
|
|
10
|
+
declare const RES_IMPORT_PREFIX = "res:/";
|
|
11
|
+
|
|
12
|
+
declare const loadResfileIndexData: (options: ResolvedEveResfileOptions) => Promise<ResfileIndex>;
|
|
13
|
+
|
|
14
|
+
declare const normalizeResPath: (source: string) => string;
|
|
15
|
+
declare const lookupCdnPath: (index: Map<string, string>, resPath: string) => string | undefined;
|
|
16
|
+
declare const devProxyUrl: (resPath: string) => string;
|
|
17
|
+
declare const resPathFromDevProxyUrl: (pathname: string) => string | null;
|
|
18
|
+
|
|
19
|
+
declare const parseFirstTwoColumns: (line: string) => [string, string] | null;
|
|
20
|
+
declare const parseResfileIndex: (content: string) => Map<string, string>;
|
|
21
|
+
declare const findResfileIndexCdnPath: (buildIndex: string) => string;
|
|
22
|
+
|
|
23
|
+
export { DEFAULT_ASSET_ORIGIN, DEFAULT_CACHE_DIR, DEFAULT_INDEX_ORIGIN, DEV_PROXY_PREFIX, EVE_CLIENT_MANIFEST, RESFILE_INDEX_PATH, RES_IMPORT_PREFIX, ResfileIndex, ResolvedEveResfileOptions, devProxyUrl, findResfileIndexCdnPath, loadResfileIndexData, lookupCdnPath, normalizeResPath, parseFirstTwoColumns, parseResfileIndex, resPathFromDevProxyUrl };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_ASSET_ORIGIN,
|
|
3
|
+
DEFAULT_CACHE_DIR,
|
|
4
|
+
DEFAULT_INDEX_ORIGIN,
|
|
5
|
+
DEV_PROXY_PREFIX,
|
|
6
|
+
EVE_CLIENT_MANIFEST,
|
|
7
|
+
RESFILE_INDEX_PATH,
|
|
8
|
+
RES_IMPORT_PREFIX,
|
|
9
|
+
devProxyUrl,
|
|
10
|
+
findResfileIndexCdnPath,
|
|
11
|
+
loadResfileIndexData,
|
|
12
|
+
lookupCdnPath,
|
|
13
|
+
normalizeResPath,
|
|
14
|
+
parseFirstTwoColumns,
|
|
15
|
+
parseResfileIndex,
|
|
16
|
+
resPathFromDevProxyUrl
|
|
17
|
+
} from "./chunk-RP7V25VC.js";
|
|
18
|
+
export {
|
|
19
|
+
DEFAULT_ASSET_ORIGIN,
|
|
20
|
+
DEFAULT_CACHE_DIR,
|
|
21
|
+
DEFAULT_INDEX_ORIGIN,
|
|
22
|
+
DEV_PROXY_PREFIX,
|
|
23
|
+
EVE_CLIENT_MANIFEST,
|
|
24
|
+
RESFILE_INDEX_PATH,
|
|
25
|
+
RES_IMPORT_PREFIX,
|
|
26
|
+
devProxyUrl,
|
|
27
|
+
findResfileIndexCdnPath,
|
|
28
|
+
loadResfileIndexData,
|
|
29
|
+
lookupCdnPath,
|
|
30
|
+
normalizeResPath,
|
|
31
|
+
parseFirstTwoColumns,
|
|
32
|
+
parseResfileIndex,
|
|
33
|
+
resPathFromDevProxyUrl
|
|
34
|
+
};
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var __async = (__this, __arguments, generator) => {
|
|
20
|
+
return new Promise((resolve2, reject) => {
|
|
21
|
+
var fulfilled = (value) => {
|
|
22
|
+
try {
|
|
23
|
+
step(generator.next(value));
|
|
24
|
+
} catch (e) {
|
|
25
|
+
reject(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var rejected = (value) => {
|
|
29
|
+
try {
|
|
30
|
+
step(generator.throw(value));
|
|
31
|
+
} catch (e) {
|
|
32
|
+
reject(e);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
var step = (x) => x.done ? resolve2(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/rollup/index.ts
|
|
41
|
+
var rollup_exports = {};
|
|
42
|
+
__export(rollup_exports, {
|
|
43
|
+
eveResfile: () => eveResfile
|
|
44
|
+
});
|
|
45
|
+
module.exports = __toCommonJS(rollup_exports);
|
|
46
|
+
|
|
47
|
+
// src/index-loader.ts
|
|
48
|
+
var import_promises2 = require("fs/promises");
|
|
49
|
+
|
|
50
|
+
// src/cache.ts
|
|
51
|
+
var import_node_fs = require("fs");
|
|
52
|
+
var import_promises = require("fs/promises");
|
|
53
|
+
var import_node_path = require("path");
|
|
54
|
+
var buildCacheDir = (cacheDir, buildNumber) => (0, import_node_path.join)(cacheDir, buildNumber);
|
|
55
|
+
var buildIndexPath = (cacheDir, buildNumber) => (0, import_node_path.join)(buildCacheDir(cacheDir, buildNumber), "build-index.txt");
|
|
56
|
+
var resfileIndexPath = (cacheDir, buildNumber) => (0, import_node_path.join)(buildCacheDir(cacheDir, buildNumber), "resfileindex.txt");
|
|
57
|
+
var resfileMapPath = (cacheDir, buildNumber) => (0, import_node_path.join)(buildCacheDir(cacheDir, buildNumber), "resfile-map.json");
|
|
58
|
+
var readCachedText = (path) => __async(null, null, function* () {
|
|
59
|
+
if (!(0, import_node_fs.existsSync)(path)) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
return (0, import_promises.readFile)(path, "utf8");
|
|
63
|
+
});
|
|
64
|
+
var writeCachedText = (path, content) => __async(null, null, function* () {
|
|
65
|
+
yield (0, import_promises.mkdir)((0, import_node_path.join)(path, ".."), { recursive: true });
|
|
66
|
+
yield (0, import_promises.writeFile)(path, content);
|
|
67
|
+
});
|
|
68
|
+
var readCachedMap = (path) => __async(null, null, function* () {
|
|
69
|
+
if (!(0, import_node_fs.existsSync)(path)) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
const parsed = JSON.parse(yield (0, import_promises.readFile)(path, "utf8"));
|
|
73
|
+
return new Map(Object.entries(parsed));
|
|
74
|
+
});
|
|
75
|
+
var writeCachedMap = (path, map) => __async(null, null, function* () {
|
|
76
|
+
yield (0, import_promises.mkdir)((0, import_node_path.join)(path, ".."), { recursive: true });
|
|
77
|
+
yield (0, import_promises.writeFile)(path, JSON.stringify(Object.fromEntries(map)));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// src/constants.ts
|
|
81
|
+
var DEFAULT_INDEX_ORIGIN = "https://binaries.eveonline.com";
|
|
82
|
+
var DEFAULT_ASSET_ORIGIN = "https://resources.eveonline.com";
|
|
83
|
+
var DEFAULT_CACHE_DIR = ".cache/eve-resfile";
|
|
84
|
+
var EVE_CLIENT_MANIFEST = "eveclient_TQ.json";
|
|
85
|
+
var RESFILE_INDEX_PATH = "app:/resfileindex.txt";
|
|
86
|
+
var VIRTUAL_PREFIX = "\0res:";
|
|
87
|
+
var RES_IMPORT_PREFIX = "res:/";
|
|
88
|
+
|
|
89
|
+
// src/fetch.ts
|
|
90
|
+
var fetchText = (url) => __async(null, null, function* () {
|
|
91
|
+
const response = yield fetch(url);
|
|
92
|
+
if (!response.ok) {
|
|
93
|
+
throw new Error(`Failed to fetch ${url} (${response.status}).`);
|
|
94
|
+
}
|
|
95
|
+
return response.text();
|
|
96
|
+
});
|
|
97
|
+
var fetchBuffer = (url) => __async(null, null, function* () {
|
|
98
|
+
const response = yield fetch(url);
|
|
99
|
+
if (!response.ok) {
|
|
100
|
+
throw new Error(`Failed to fetch ${url} (${response.status}).`);
|
|
101
|
+
}
|
|
102
|
+
const arrayBuffer = yield response.arrayBuffer();
|
|
103
|
+
return Buffer.from(arrayBuffer);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// src/parse.ts
|
|
107
|
+
var parseFirstTwoColumns = (line) => {
|
|
108
|
+
const commaIndex = line.indexOf(",");
|
|
109
|
+
if (commaIndex === -1) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
const path = line.slice(0, commaIndex);
|
|
113
|
+
const remainder = line.slice(commaIndex + 1);
|
|
114
|
+
const secondComma = remainder.indexOf(",");
|
|
115
|
+
const cdnPath = secondComma === -1 ? remainder : remainder.slice(0, secondComma);
|
|
116
|
+
if (!path || !cdnPath) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
return [path, cdnPath];
|
|
120
|
+
};
|
|
121
|
+
var parseResfileIndex = (content) => {
|
|
122
|
+
const map = /* @__PURE__ */ new Map();
|
|
123
|
+
for (const line of content.split("\n")) {
|
|
124
|
+
const trimmed = line.trim();
|
|
125
|
+
if (!trimmed) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const parsed = parseFirstTwoColumns(trimmed);
|
|
129
|
+
if (!parsed) {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const [resPath, cdnPath] = parsed;
|
|
133
|
+
map.set(resPath, cdnPath);
|
|
134
|
+
}
|
|
135
|
+
return map;
|
|
136
|
+
};
|
|
137
|
+
var findResfileIndexCdnPath = (buildIndex) => {
|
|
138
|
+
for (const line of buildIndex.split("\n")) {
|
|
139
|
+
const trimmed = line.trim();
|
|
140
|
+
if (!trimmed) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
const parsed = parseFirstTwoColumns(trimmed);
|
|
144
|
+
if (!parsed) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const [path, cdnPath] = parsed;
|
|
148
|
+
if (path === RESFILE_INDEX_PATH) {
|
|
149
|
+
return cdnPath;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
throw new Error(`${RESFILE_INDEX_PATH} not found in build index.`);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/index-loader.ts
|
|
156
|
+
var resolveBuildNumber = (options) => __async(null, null, function* () {
|
|
157
|
+
if (options.buildNumber !== void 0) {
|
|
158
|
+
return String(options.buildNumber);
|
|
159
|
+
}
|
|
160
|
+
const manifestUrl = `${options.indexOrigin}/${EVE_CLIENT_MANIFEST}`;
|
|
161
|
+
const manifest = JSON.parse(yield fetchText(manifestUrl));
|
|
162
|
+
if (!manifest.buildNumber) {
|
|
163
|
+
throw new Error(`Missing buildNumber in ${manifestUrl}.`);
|
|
164
|
+
}
|
|
165
|
+
return manifest.buildNumber;
|
|
166
|
+
});
|
|
167
|
+
var loadBuildIndex = (options, buildNumber) => __async(null, null, function* () {
|
|
168
|
+
const cachedPath = buildIndexPath(options.cacheDir, buildNumber);
|
|
169
|
+
const cached = yield readCachedText(cachedPath);
|
|
170
|
+
if (cached) {
|
|
171
|
+
return cached;
|
|
172
|
+
}
|
|
173
|
+
const buildIndexUrl = `${options.indexOrigin}/eveonline_${buildNumber}.txt`;
|
|
174
|
+
const content = yield fetchText(buildIndexUrl);
|
|
175
|
+
yield writeCachedText(cachedPath, content);
|
|
176
|
+
return content;
|
|
177
|
+
});
|
|
178
|
+
var loadResfileIndex = (options, buildNumber, cdnPath) => __async(null, null, function* () {
|
|
179
|
+
const cachedPath = resfileIndexPath(options.cacheDir, buildNumber);
|
|
180
|
+
const cached = yield readCachedText(cachedPath);
|
|
181
|
+
if (cached) {
|
|
182
|
+
return cached;
|
|
183
|
+
}
|
|
184
|
+
const resfileIndexUrl = `${options.indexOrigin}/${cdnPath}`;
|
|
185
|
+
const content = yield fetchText(resfileIndexUrl);
|
|
186
|
+
yield writeCachedText(cachedPath, content);
|
|
187
|
+
return content;
|
|
188
|
+
});
|
|
189
|
+
var loadResfileIndexData = (options) => __async(null, null, function* () {
|
|
190
|
+
const { cacheDir } = options;
|
|
191
|
+
const buildNumber = yield resolveBuildNumber(options);
|
|
192
|
+
yield (0, import_promises2.mkdir)(buildCacheDir(cacheDir, buildNumber), { recursive: true });
|
|
193
|
+
const cachedMap = yield readCachedMap(resfileMapPath(cacheDir, buildNumber));
|
|
194
|
+
if (cachedMap) {
|
|
195
|
+
return { buildNumber, resPathToCdnPath: cachedMap };
|
|
196
|
+
}
|
|
197
|
+
const buildIndex = yield loadBuildIndex(options, buildNumber);
|
|
198
|
+
const resfileIndexCdnPath = findResfileIndexCdnPath(buildIndex);
|
|
199
|
+
const resfileIndex = yield loadResfileIndex(options, buildNumber, resfileIndexCdnPath);
|
|
200
|
+
const resPathToCdnPath = parseResfileIndex(resfileIndex);
|
|
201
|
+
yield writeCachedMap(resfileMapPath(cacheDir, buildNumber), resPathToCdnPath);
|
|
202
|
+
return { buildNumber, resPathToCdnPath };
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// src/plugin-core.ts
|
|
206
|
+
var import_node_path2 = require("path");
|
|
207
|
+
|
|
208
|
+
// src/lookup.ts
|
|
209
|
+
var normalizeResPath = (source) => {
|
|
210
|
+
var _a;
|
|
211
|
+
const withoutQuery = (_a = source.split(/[?#]/)[0]) != null ? _a : source;
|
|
212
|
+
if (withoutQuery.startsWith(RES_IMPORT_PREFIX)) {
|
|
213
|
+
return withoutQuery;
|
|
214
|
+
}
|
|
215
|
+
if (withoutQuery.startsWith("res:")) {
|
|
216
|
+
const path = withoutQuery.slice("res:".length);
|
|
217
|
+
return path.startsWith("/") ? `res:${path}` : `res:/${path}`;
|
|
218
|
+
}
|
|
219
|
+
throw new Error(`Invalid res import "${source}". Expected a path starting with "res:/".`);
|
|
220
|
+
};
|
|
221
|
+
var lookupCdnPath = (index, resPath) => index.get(resPath);
|
|
222
|
+
var devProxyUrl = (resPath) => {
|
|
223
|
+
const encoded = encodeURIComponent(resPath.slice(RES_IMPORT_PREFIX.length));
|
|
224
|
+
return `/__eve_res__/${encoded}`;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/plugin-core.ts
|
|
228
|
+
var resolveEveResfileOptions = (options = {}, root) => {
|
|
229
|
+
var _a, _b, _c;
|
|
230
|
+
const cacheDir = (_a = options.cacheDir) != null ? _a : DEFAULT_CACHE_DIR;
|
|
231
|
+
return {
|
|
232
|
+
buildNumber: options.buildNumber,
|
|
233
|
+
indexOrigin: (_b = options.indexOrigin) != null ? _b : DEFAULT_INDEX_ORIGIN,
|
|
234
|
+
assetOrigin: (_c = options.assetOrigin) != null ? _c : DEFAULT_ASSET_ORIGIN,
|
|
235
|
+
cacheDir: (0, import_node_path2.isAbsolute)(cacheDir) ? cacheDir : (0, import_node_path2.resolve)(root, cacheDir)
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
var isVirtualResId = (id) => id.startsWith(VIRTUAL_PREFIX);
|
|
239
|
+
var virtualIdForResPath = (resPath) => `${VIRTUAL_PREFIX}${resPath}`;
|
|
240
|
+
var resPathFromVirtualId = (id) => id.slice(VIRTUAL_PREFIX.length);
|
|
241
|
+
var lookupOrThrow = (index, resPath) => {
|
|
242
|
+
const cdnPath = lookupCdnPath(index.resPathToCdnPath, resPath);
|
|
243
|
+
if (!cdnPath) {
|
|
244
|
+
throw new Error(`${resPath} not found in resfileindex (build ${index.buildNumber}).`);
|
|
245
|
+
}
|
|
246
|
+
return cdnPath;
|
|
247
|
+
};
|
|
248
|
+
var resolveResfileId = (source) => {
|
|
249
|
+
if (!source.startsWith(RES_IMPORT_PREFIX)) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
return virtualIdForResPath(normalizeResPath(source));
|
|
253
|
+
};
|
|
254
|
+
var loadResfileAssetModule = (_0) => __async(null, [_0], function* ({
|
|
255
|
+
watchMode,
|
|
256
|
+
assetOrigin,
|
|
257
|
+
index,
|
|
258
|
+
resPath,
|
|
259
|
+
emitAsset
|
|
260
|
+
}) {
|
|
261
|
+
const cdnPath = lookupOrThrow(index, resPath);
|
|
262
|
+
if (watchMode) {
|
|
263
|
+
return `export default ${JSON.stringify(devProxyUrl(resPath))}`;
|
|
264
|
+
}
|
|
265
|
+
const buffer = yield fetchBuffer(`${assetOrigin}/${cdnPath}`);
|
|
266
|
+
const referenceId = emitAsset((0, import_node_path2.basename)(resPath), buffer);
|
|
267
|
+
return `export default import.meta.ROLLUP_FILE_URL_${referenceId}`;
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// src/rollup/plugin.ts
|
|
271
|
+
var eveResfile = (options = {}) => {
|
|
272
|
+
var _a;
|
|
273
|
+
const userOptions = resolveEveResfileOptions(options, (_a = options.root) != null ? _a : process.cwd());
|
|
274
|
+
const indexOptions = userOptions;
|
|
275
|
+
let indexPromise = null;
|
|
276
|
+
let loadedIndex = null;
|
|
277
|
+
const ensureIndex = () => {
|
|
278
|
+
indexPromise != null ? indexPromise : indexPromise = loadResfileIndexData(indexOptions).then((index) => {
|
|
279
|
+
loadedIndex = index;
|
|
280
|
+
return index;
|
|
281
|
+
});
|
|
282
|
+
return indexPromise;
|
|
283
|
+
};
|
|
284
|
+
return {
|
|
285
|
+
name: "eve-resfile-rollup",
|
|
286
|
+
buildStart() {
|
|
287
|
+
return __async(this, null, function* () {
|
|
288
|
+
const index = yield ensureIndex();
|
|
289
|
+
this.info(
|
|
290
|
+
`Loaded EVE resfileindex (build ${index.buildNumber}, ${index.resPathToCdnPath.size} entries).`
|
|
291
|
+
);
|
|
292
|
+
});
|
|
293
|
+
},
|
|
294
|
+
resolveId(source) {
|
|
295
|
+
return resolveResfileId(source);
|
|
296
|
+
},
|
|
297
|
+
load(id) {
|
|
298
|
+
return __async(this, null, function* () {
|
|
299
|
+
if (!isVirtualResId(id)) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
const resPath = resPathFromVirtualId(id);
|
|
303
|
+
const index = loadedIndex != null ? loadedIndex : yield ensureIndex();
|
|
304
|
+
return loadResfileAssetModule({
|
|
305
|
+
watchMode: this.meta.watchMode,
|
|
306
|
+
assetOrigin: userOptions.assetOrigin,
|
|
307
|
+
index,
|
|
308
|
+
resPath,
|
|
309
|
+
emitAsset: (name, source) => this.emitFile({
|
|
310
|
+
type: "asset",
|
|
311
|
+
name,
|
|
312
|
+
source
|
|
313
|
+
})
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
320
|
+
0 && (module.exports = {
|
|
321
|
+
eveResfile
|
|
322
|
+
});
|