nitro-patcher 1.0.0 → 1.1.0
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/dist/browser.d.ts +12 -0
- package/dist/browser.js +978 -7
- package/dist/browser.js.LEGAL.txt +204 -0
- package/dist/browser.js.map +4 -4
- package/dist/{chunk-B7NTPBDX.js → chunk-ZQM3LT5L.js} +293 -1
- package/dist/chunk-ZQM3LT5L.js.map +1 -0
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -1
- package/dist/nitro-patch-helper.d.ts +13 -1
- package/dist/nitro-patch-helper.js +3 -1
- package/package.json +3 -2
- package/src/browser.ts +17 -0
- package/src/nitro-patch-helper.ts +2 -0
- package/src/patch/create.ts +341 -0
- package/src/patch/xdelta3-LICENSE +201 -0
- package/dist/chunk-B7NTPBDX.js.map +0 -1
|
@@ -263,5 +263,7 @@ export const PatchHelper = Object.freeze({
|
|
|
263
263
|
readPatchReadme,
|
|
264
264
|
readPatchReadmeFile,
|
|
265
265
|
});
|
|
266
|
+
export { createPatch } from "./patch/create";
|
|
267
|
+
export type { CreatePatchOptions, CreatePatchResult } from "./patch/create";
|
|
266
268
|
export { decodeXdelta } from "./patch/xdelta";
|
|
267
269
|
export type { XdeltaOptions } from "./patch/xdelta";
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { encode } from "@limrun/xdelta3-wasm";
|
|
2
|
+
import { zipSync } from "fflate";
|
|
3
|
+
|
|
4
|
+
import { hashDigest } from "#nitro-runtime";
|
|
5
|
+
|
|
6
|
+
import { decodeXdelta } from "./xdelta";
|
|
7
|
+
import { bytes } from "../nitro/binary";
|
|
8
|
+
import { crc16 } from "../nitro/crc";
|
|
9
|
+
import { decryptSecureArea, encryptSecureArea } from "../nitro/crypto";
|
|
10
|
+
import type { NitroFolder } from "../nitro/filesystem";
|
|
11
|
+
import { Header } from "../nitro/header";
|
|
12
|
+
import { NDSFile } from "../nitro/nds-file";
|
|
13
|
+
import { patchBuffer } from "../nitro-patch-helper";
|
|
14
|
+
import type { PatchMetadata, PatchOptions } from "../nitro-patch-helper";
|
|
15
|
+
|
|
16
|
+
export interface CreatePatchOptions extends PatchOptions {
|
|
17
|
+
metadata?: Omit<PatchMetadata, "formatVersion">;
|
|
18
|
+
readme?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CreatePatchResult {
|
|
22
|
+
buffer: Uint8Array<ArrayBuffer>;
|
|
23
|
+
changedFiles: number;
|
|
24
|
+
warnings: string[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const normalizePath = (path: string): string => path.replaceAll("\\", "/").toLowerCase();
|
|
28
|
+
const listFiles = (rom: NDSFile) => new Map(rom.listFiles().map((file) => [normalizePath(file.path), file]));
|
|
29
|
+
const listDirectories = (folder: NitroFolder, prefix = "data"): string[] =>
|
|
30
|
+
[prefix, ...folder.folders.flatMap((child) => listDirectories(child, `${prefix}/${child.name}`))].sort();
|
|
31
|
+
const getUnnamedFiles = (rom: NDSFile): Buffer[] => {
|
|
32
|
+
const namedIds = new Set(
|
|
33
|
+
rom
|
|
34
|
+
.listFiles()
|
|
35
|
+
.filter((file) => /^(data|overlay)\//i.test(file.path))
|
|
36
|
+
.map((file) => file.id),
|
|
37
|
+
);
|
|
38
|
+
return rom.fatTable.entries
|
|
39
|
+
.filter((entry) => !namedIds.has(entry.id))
|
|
40
|
+
.map((entry) => rom.original.subarray(entry.offset, entry.offset + entry.size));
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// Repacking assigns physical locations, capacities and derived checksums.
|
|
44
|
+
const normalizeHeader = (rom: NDSFile): Buffer => {
|
|
45
|
+
const header = new Header(rom.getFile("header.bin"));
|
|
46
|
+
header.size = 0x20000;
|
|
47
|
+
for (const field of [
|
|
48
|
+
"ARM9romOffset",
|
|
49
|
+
"ARM9size",
|
|
50
|
+
"ARM7romOffset",
|
|
51
|
+
"ARM7size",
|
|
52
|
+
"FNToffset",
|
|
53
|
+
"FNTsize",
|
|
54
|
+
"FAToffset",
|
|
55
|
+
"FATsize",
|
|
56
|
+
"ARM9overlayOffset",
|
|
57
|
+
"ARM9overlaySize",
|
|
58
|
+
"ARM7overlayOffset",
|
|
59
|
+
"ARM7overlaySize",
|
|
60
|
+
"bannerOffset",
|
|
61
|
+
"secureCRC16",
|
|
62
|
+
"ROMsize",
|
|
63
|
+
"logoCRC16",
|
|
64
|
+
"headerCRC16",
|
|
65
|
+
] as const)
|
|
66
|
+
header[field] = 0;
|
|
67
|
+
if (header.unitCode === 2) {
|
|
68
|
+
for (const field of [
|
|
69
|
+
"ntr_region_end",
|
|
70
|
+
"twl_region_start",
|
|
71
|
+
"dsi9_rom_offset",
|
|
72
|
+
"dsi7_rom_offset",
|
|
73
|
+
"digest_ntr_start",
|
|
74
|
+
"digest_ntr_size",
|
|
75
|
+
"digest_twl_start",
|
|
76
|
+
"digest_twl_size",
|
|
77
|
+
"sector_hashtable_start",
|
|
78
|
+
"sector_hashtable_size",
|
|
79
|
+
"block_hashtable_start",
|
|
80
|
+
"block_hashtable_size",
|
|
81
|
+
"total_rom_size",
|
|
82
|
+
"modcrypt1_start",
|
|
83
|
+
"modcrypt1_size",
|
|
84
|
+
"modcrypt2_start",
|
|
85
|
+
"modcrypt2_size",
|
|
86
|
+
] as const)
|
|
87
|
+
header[field] = 0;
|
|
88
|
+
for (const field of [
|
|
89
|
+
"hmac_arm9",
|
|
90
|
+
"hmac_arm7",
|
|
91
|
+
"hmac_digest_master",
|
|
92
|
+
"hmac_icon_title",
|
|
93
|
+
"hmac_arm9i",
|
|
94
|
+
"hmac_arm7i",
|
|
95
|
+
"hmac_arm9_no_secure",
|
|
96
|
+
"rsa_signature",
|
|
97
|
+
] as const)
|
|
98
|
+
header[field] = Buffer.alloc(header[field].length);
|
|
99
|
+
}
|
|
100
|
+
return header.raw;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const compareContent = (actual: Buffer, expected: Buffer, path: string, warnings: string[]): void => {
|
|
104
|
+
if (!actual.equals(expected)) warnings.push(`重建内容与修改后的 ROM 不同:${path}`);
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const errorMessage = (reason: unknown): string => (reason instanceof Error ? reason.message : String(reason));
|
|
108
|
+
|
|
109
|
+
const parseRom = (input: Buffer, label: string, warnings: string[]): NDSFile => {
|
|
110
|
+
try {
|
|
111
|
+
const rom = new NDSFile(input, { dsiMode: "complete" });
|
|
112
|
+
rom.listFiles();
|
|
113
|
+
return rom;
|
|
114
|
+
} catch (reason) {
|
|
115
|
+
try {
|
|
116
|
+
const rom = new NDSFile(input);
|
|
117
|
+
rom.listFiles();
|
|
118
|
+
warnings.push(`${label} 使用常规模式解析:${errorMessage(reason)}`);
|
|
119
|
+
return rom;
|
|
120
|
+
} catch (error) {
|
|
121
|
+
throw new Error(`无法解析${label}:${errorMessage(error)}`, { cause: error });
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const createDelta = async (before: Buffer, after: Buffer): Promise<Buffer> => {
|
|
127
|
+
const chunks: Buffer[] = [];
|
|
128
|
+
async function* targetChunks() {
|
|
129
|
+
yield after;
|
|
130
|
+
}
|
|
131
|
+
for await (const chunk of encode(targetChunks(), {
|
|
132
|
+
size: before.length,
|
|
133
|
+
read(offset, into) {
|
|
134
|
+
const part = before.subarray(offset, offset + into.length);
|
|
135
|
+
into.set(part);
|
|
136
|
+
return part.length;
|
|
137
|
+
},
|
|
138
|
+
}))
|
|
139
|
+
chunks.push(Buffer.from(chunk));
|
|
140
|
+
return Buffer.concat(chunks);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
const verifyContent = (actual: NDSFile, expected: NDSFile, arm9: Buffer, warnings: string[]): void => {
|
|
144
|
+
const actualFiles = listFiles(actual);
|
|
145
|
+
const expectedFiles = listFiles(expected);
|
|
146
|
+
if ([...actualFiles.keys()].sort().join("\n") !== [...expectedFiles.keys()].sort().join("\n"))
|
|
147
|
+
warnings.push("重建 ROM 的文件路径集合与修改后的 ROM 不同。");
|
|
148
|
+
const actualDirectories = new Set(listDirectories(actual.data));
|
|
149
|
+
const expectedDirectories = new Set(listDirectories(expected.data));
|
|
150
|
+
for (const path of expectedDirectories)
|
|
151
|
+
if (!actualDirectories.has(path)) {
|
|
152
|
+
if ([...expectedFiles.keys()].some((name) => name.startsWith(normalizePath(`${path}/`))))
|
|
153
|
+
warnings.push(`重建 ROM 缺少目录:${path}`);
|
|
154
|
+
else warnings.push(`新增空目录已忽略:${path}`);
|
|
155
|
+
}
|
|
156
|
+
for (const path of actualDirectories)
|
|
157
|
+
if (!expectedDirectories.has(path)) {
|
|
158
|
+
if ([...actualFiles.keys()].some((name) => name.startsWith(normalizePath(`${path}/`))))
|
|
159
|
+
warnings.push(`重建 ROM 保留了原始目录:${path}`);
|
|
160
|
+
else warnings.push(`已保留原始 ROM 的空目录:${path}`);
|
|
161
|
+
}
|
|
162
|
+
for (const [path, file] of expectedFiles) {
|
|
163
|
+
if (["header.bin", "fnt.bin", "fat.bin", "banner.bin", "overarm9.bin", "overarm7.bin"].includes(path)) continue;
|
|
164
|
+
if (!actualFiles.has(path)) continue;
|
|
165
|
+
let content = path === "arm9.bin" ? Buffer.from(arm9) : expected.getFile(file.path);
|
|
166
|
+
if (path === "arm9.bin" && expected.header.unitCode === 2) {
|
|
167
|
+
const plain = expected.header.decrypted ? content : decryptSecureArea(expected.header.gameCode, content);
|
|
168
|
+
plain.writeUInt16LE(crc16(plain.subarray(0x10, 0x800)), 0xe);
|
|
169
|
+
content = expected.header.decrypted ? plain : encryptSecureArea(expected.header.gameCode, plain);
|
|
170
|
+
}
|
|
171
|
+
compareContent(actual.getFile(file.path), content, file.path, warnings);
|
|
172
|
+
}
|
|
173
|
+
compareContent(actual.banner.toBuffer(), expected.banner.toBuffer(), "banner.bin", warnings);
|
|
174
|
+
compareContent(normalizeHeader(actual), normalizeHeader(expected), "header.bin", warnings);
|
|
175
|
+
compareContent(actual.header.dlp_signature, expected.header.dlp_signature, "Download Play 签名", warnings);
|
|
176
|
+
for (const [left, right] of [
|
|
177
|
+
[actual.overlay9Table, expected.overlay9Table],
|
|
178
|
+
[actual.overlay7Table, expected.overlay7Table],
|
|
179
|
+
]) {
|
|
180
|
+
if (left.entries.length !== right.entries.length) warnings.push("重建 ROM 的覆盖模块数量与修改后的 ROM 不同。");
|
|
181
|
+
for (const entry of right.entries) {
|
|
182
|
+
const other = left.entries.find((item) => item.overlayId === entry.overlayId);
|
|
183
|
+
if (!other) {
|
|
184
|
+
warnings.push(`重建 ROM 缺少覆盖模块:${entry.overlayId}`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
for (const field of [
|
|
188
|
+
"ramAddress",
|
|
189
|
+
"ramSize",
|
|
190
|
+
"bssSize",
|
|
191
|
+
"staticInitialiserStartAddress",
|
|
192
|
+
"staticInitialiserEndAddress",
|
|
193
|
+
"reserved",
|
|
194
|
+
] as const)
|
|
195
|
+
if (other[field] !== entry[field])
|
|
196
|
+
warnings.push(`重建覆盖模块 ${entry.overlayId} 的 ${field} 与修改后的 ROM 不同。`);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const actualUnnamed = getUnnamedFiles(actual);
|
|
200
|
+
const expectedUnnamed = getUnnamedFiles(expected);
|
|
201
|
+
if (actualUnnamed.length !== expectedUnnamed.length)
|
|
202
|
+
warnings.push("重建 ROM 的未命名 FAT 项数量与修改后的 ROM 不同。");
|
|
203
|
+
actualUnnamed.forEach((content, index) => {
|
|
204
|
+
if (expectedUnnamed[index]) compareContent(content, expectedUnnamed[index], `未命名 FAT 项 ${index}`, warnings);
|
|
205
|
+
});
|
|
206
|
+
if (actual.header.unitCode === 2)
|
|
207
|
+
for (const [name, check] of Object.entries(actual.verifyDsi()))
|
|
208
|
+
if (check.status === "invalid") warnings.push(`重建 ROM 的 DSi 校验结果为 invalid:${name}`);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
const verifyPatch = (
|
|
212
|
+
input: Buffer,
|
|
213
|
+
archive: Uint8Array,
|
|
214
|
+
target: NDSFile,
|
|
215
|
+
arm9: Buffer,
|
|
216
|
+
options: PatchOptions,
|
|
217
|
+
warnings: string[],
|
|
218
|
+
): boolean => {
|
|
219
|
+
let output: Buffer;
|
|
220
|
+
try {
|
|
221
|
+
output = patchBuffer(input, archive, options).buffer;
|
|
222
|
+
} catch (reason) {
|
|
223
|
+
warnings.push(`补丁应用检查未完成:${errorMessage(reason)}`);
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
try {
|
|
227
|
+
verifyContent(parseRom(output, "重建 ROM", warnings), target, arm9, warnings);
|
|
228
|
+
} catch (reason) {
|
|
229
|
+
warnings.push(`补丁数据核对未完成:${errorMessage(reason)}`);
|
|
230
|
+
}
|
|
231
|
+
return true;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
/** Create an XZP; differences and application checks are returned as warnings. */
|
|
235
|
+
export const createPatch = async (
|
|
236
|
+
original: Uint8Array,
|
|
237
|
+
modified: Uint8Array,
|
|
238
|
+
options: CreatePatchOptions = {},
|
|
239
|
+
): Promise<CreatePatchResult> => {
|
|
240
|
+
const input = bytes(original, "original ROM");
|
|
241
|
+
const targetBytes = bytes(modified, "modified ROM");
|
|
242
|
+
const warnings: string[] = [];
|
|
243
|
+
const source = parseRom(input, "原始 ROM", warnings);
|
|
244
|
+
const target = parseRom(targetBytes, "修改后的 ROM", warnings);
|
|
245
|
+
let preprocessing = false;
|
|
246
|
+
if (source.header.gameCode !== target.header.gameCode)
|
|
247
|
+
warnings.push(`两个 ROM 的游戏代码不同:${source.header.gameCode} / ${target.header.gameCode}`);
|
|
248
|
+
if (source.header.unitCode !== target.header.unitCode)
|
|
249
|
+
warnings.push(`两个 ROM 的 unitCode 不同:${source.header.unitCode} / ${target.header.unitCode}`);
|
|
250
|
+
if (source.header.ROMversion !== target.header.ROMversion)
|
|
251
|
+
warnings.push(`两个 ROM 的修订版本不同:${source.header.ROMversion} / ${target.header.ROMversion}`);
|
|
252
|
+
if (source.header.gameCode !== target.header.gameCode || source.header.unitCode !== target.header.unitCode)
|
|
253
|
+
preprocessing = true;
|
|
254
|
+
const sourceFiles = listFiles(source);
|
|
255
|
+
const targetFiles = listFiles(target);
|
|
256
|
+
const headerChanged = !normalizeHeader(source).equals(normalizeHeader(target));
|
|
257
|
+
const sourceArm9 = source.getFile("arm9.bin");
|
|
258
|
+
const targetArm9 = target.getFile("arm9.bin");
|
|
259
|
+
const sourcePostData = sourceArm9.subarray(source.header.ARM9size);
|
|
260
|
+
const targetPostData = targetArm9.subarray(target.header.ARM9size);
|
|
261
|
+
if (!sourcePostData.equals(targetPostData)) warnings.push("两个 ROM 的 ARM9 尾部记录不同。");
|
|
262
|
+
for (const [label, rom, entries] of [
|
|
263
|
+
["原始 ROM", source, sourceFiles],
|
|
264
|
+
["修改后的 ROM", target, targetFiles],
|
|
265
|
+
] as const) {
|
|
266
|
+
const file = entries.get("arm9.bin")!;
|
|
267
|
+
const end = file.offset + file.size;
|
|
268
|
+
if (rom.header.nitrocode && rom.original.subarray(end, end + 4).equals(Buffer.from("2106c0de", "hex")))
|
|
269
|
+
warnings.push(`${label} 的 ARM9 含有额外尾部记录。`);
|
|
270
|
+
}
|
|
271
|
+
const targetProgram = targetArm9.subarray(0, target.header.ARM9size);
|
|
272
|
+
const arm9 =
|
|
273
|
+
sourcePostData.length && targetProgram.subarray(-sourcePostData.length).equals(sourcePostData)
|
|
274
|
+
? targetProgram
|
|
275
|
+
: Buffer.concat([targetProgram, sourcePostData]);
|
|
276
|
+
const removed = [...sourceFiles.keys()].filter((path) => !targetFiles.has(path));
|
|
277
|
+
if (removed.length) {
|
|
278
|
+
warnings.push(`修改后的 ROM 缺少原始 ROM 中的 ${removed.length} 个文件。`);
|
|
279
|
+
preprocessing = true;
|
|
280
|
+
}
|
|
281
|
+
const sourceUnnamed = getUnnamedFiles(source);
|
|
282
|
+
const targetUnnamed = getUnnamedFiles(target);
|
|
283
|
+
if (
|
|
284
|
+
sourceUnnamed.length !== targetUnnamed.length ||
|
|
285
|
+
sourceUnnamed.some((content, index) => !content.equals(targetUnnamed[index] ?? Buffer.alloc(0)))
|
|
286
|
+
) {
|
|
287
|
+
warnings.push("两个 ROM 的未命名 FAT 数据不同。");
|
|
288
|
+
preprocessing = true;
|
|
289
|
+
}
|
|
290
|
+
const entries: Record<string, Uint8Array> = {};
|
|
291
|
+
let changedFiles = 0;
|
|
292
|
+
for (const [path, file] of targetFiles) {
|
|
293
|
+
if (path === "fnt.bin" || path === "fat.bin") continue;
|
|
294
|
+
if (path === "header.bin" && !headerChanged) continue;
|
|
295
|
+
const before = sourceFiles.has(path) ? source.getFile(file.path) : Buffer.alloc(0);
|
|
296
|
+
const after = path === "arm9.bin" ? arm9 : target.getFile(file.path);
|
|
297
|
+
if (sourceFiles.has(path) && before.equals(after)) continue;
|
|
298
|
+
if (!sourceFiles.has(path) && !/^(data|overlay)\//.test(path) && !/^overarm[97]\.bin$/.test(path))
|
|
299
|
+
warnings.push(`新增系统文件:${file.path}`);
|
|
300
|
+
try {
|
|
301
|
+
const delta = await createDelta(before, after);
|
|
302
|
+
if (decodeXdelta(before, delta, options).equals(after)) entries[`xdelta/${file.path}`] = delta;
|
|
303
|
+
else {
|
|
304
|
+
warnings.push(`文件差分解码内容不同,已保存完整替换内容:${file.path}`);
|
|
305
|
+
entries[file.path] = after;
|
|
306
|
+
}
|
|
307
|
+
} catch (reason) {
|
|
308
|
+
warnings.push(`文件差分检查未完成,已保存完整替换内容:${file.path}:${errorMessage(reason)}`);
|
|
309
|
+
entries[file.path] = after;
|
|
310
|
+
}
|
|
311
|
+
changedFiles++;
|
|
312
|
+
}
|
|
313
|
+
const metadata: PatchMetadata = { ...options.metadata, formatVersion: 2 };
|
|
314
|
+
const inputMd5 = hashDigest("md5", input).toString("hex");
|
|
315
|
+
entries["metadata.json"] = Buffer.from(JSON.stringify(metadata, null, 2));
|
|
316
|
+
entries["md5.txt"] = Buffer.from(inputMd5);
|
|
317
|
+
entries["readme.md"] = Buffer.from(options.readme ?? "");
|
|
318
|
+
let archive = zipSync(entries, { level: 9 });
|
|
319
|
+
if (!preprocessing) preprocessing = !verifyPatch(input, archive, target, arm9, options, warnings);
|
|
320
|
+
if (preprocessing) {
|
|
321
|
+
try {
|
|
322
|
+
const delta = await createDelta(input, targetBytes);
|
|
323
|
+
const formatVersion = target.header.unitCode & 2 && !target.twl?.complete ? 1 : 2;
|
|
324
|
+
archive = zipSync(
|
|
325
|
+
{
|
|
326
|
+
[`preprocessing/${inputMd5}.xdelta`]: delta,
|
|
327
|
+
"metadata.json": Buffer.from(JSON.stringify({ ...metadata, formatVersion }, null, 2)),
|
|
328
|
+
"md5.txt": entries["md5.txt"],
|
|
329
|
+
"readme.md": entries["readme.md"],
|
|
330
|
+
},
|
|
331
|
+
{ level: 9 },
|
|
332
|
+
);
|
|
333
|
+
changedFiles = 1;
|
|
334
|
+
warnings.push("补丁使用整份 ROM 的预处理差分保存修改。");
|
|
335
|
+
verifyPatch(input, archive, target, targetArm9, options, warnings);
|
|
336
|
+
} catch (reason) {
|
|
337
|
+
warnings.push(`预处理差分生成未完成,已保留按文件补丁包:${errorMessage(reason)}`);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
return { buffer: new Uint8Array(archive), changedFiles, warnings };
|
|
341
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Limrun
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|