esp32tool 1.0.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/README.md +31 -0
- package/css/dark.css +156 -0
- package/css/light.css +156 -0
- package/css/style.css +870 -0
- package/dist/const.d.ts +277 -0
- package/dist/const.js +511 -0
- package/dist/esp_loader.d.ts +222 -0
- package/dist/esp_loader.js +1466 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +15 -0
- package/dist/lib/spiffs/index.d.ts +15 -0
- package/dist/lib/spiffs/index.js +16 -0
- package/dist/lib/spiffs/spiffs.d.ts +26 -0
- package/dist/lib/spiffs/spiffs.js +132 -0
- package/dist/lib/spiffs/spiffsBlock.d.ts +36 -0
- package/dist/lib/spiffs/spiffsBlock.js +140 -0
- package/dist/lib/spiffs/spiffsConfig.d.ts +63 -0
- package/dist/lib/spiffs/spiffsConfig.js +79 -0
- package/dist/lib/spiffs/spiffsPage.d.ts +45 -0
- package/dist/lib/spiffs/spiffsPage.js +260 -0
- package/dist/lib/spiffs/spiffsReader.d.ts +19 -0
- package/dist/lib/spiffs/spiffsReader.js +192 -0
- package/dist/partition.d.ts +26 -0
- package/dist/partition.js +129 -0
- package/dist/struct.d.ts +2 -0
- package/dist/struct.js +91 -0
- package/dist/stubs/esp32.json +8 -0
- package/dist/stubs/esp32c2.json +8 -0
- package/dist/stubs/esp32c3.json +8 -0
- package/dist/stubs/esp32c5.json +8 -0
- package/dist/stubs/esp32c6.json +8 -0
- package/dist/stubs/esp32c61.json +8 -0
- package/dist/stubs/esp32h2.json +8 -0
- package/dist/stubs/esp32p4.json +8 -0
- package/dist/stubs/esp32p4r3.json +8 -0
- package/dist/stubs/esp32s2.json +8 -0
- package/dist/stubs/esp32s3.json +8 -0
- package/dist/stubs/esp8266.json +8 -0
- package/dist/stubs/index.d.ts +10 -0
- package/dist/stubs/index.js +56 -0
- package/dist/util.d.ts +14 -0
- package/dist/util.js +46 -0
- package/dist/wasm/filesystems.d.ts +33 -0
- package/dist/wasm/filesystems.js +114 -0
- package/dist/web/esp32-D955RjN9.js +16 -0
- package/dist/web/esp32c2-CJkxHDQi.js +16 -0
- package/dist/web/esp32c3-BhUHzH0o.js +16 -0
- package/dist/web/esp32c5-Chs0HtmA.js +16 -0
- package/dist/web/esp32c6-D6mPN6ut.js +16 -0
- package/dist/web/esp32c61-CQiYCWAs.js +16 -0
- package/dist/web/esp32h2-LsKJE9AS.js +16 -0
- package/dist/web/esp32p4-7nWC-HiD.js +16 -0
- package/dist/web/esp32p4r3-CwiPecZW.js +16 -0
- package/dist/web/esp32s2-CtqVheSJ.js +16 -0
- package/dist/web/esp32s3-CRbtB0QR.js +16 -0
- package/dist/web/esp8266-nEkNAo8K.js +16 -0
- package/dist/web/index.js +7265 -0
- package/electron/main.js +333 -0
- package/electron/preload.js +37 -0
- package/eslint.config.js +22 -0
- package/index.html +408 -0
- package/js/modules/esp32-D955RjN9.js +16 -0
- package/js/modules/esp32c2-CJkxHDQi.js +16 -0
- package/js/modules/esp32c3-BhUHzH0o.js +16 -0
- package/js/modules/esp32c5-Chs0HtmA.js +16 -0
- package/js/modules/esp32c6-D6mPN6ut.js +16 -0
- package/js/modules/esp32c61-CQiYCWAs.js +16 -0
- package/js/modules/esp32h2-LsKJE9AS.js +16 -0
- package/js/modules/esp32p4-7nWC-HiD.js +16 -0
- package/js/modules/esp32p4r3-CwiPecZW.js +16 -0
- package/js/modules/esp32s2-CtqVheSJ.js +16 -0
- package/js/modules/esp32s3-CRbtB0QR.js +16 -0
- package/js/modules/esp8266-nEkNAo8K.js +16 -0
- package/js/modules/esptool.js +7265 -0
- package/js/script.js +2237 -0
- package/js/utilities.js +182 -0
- package/license.md +11 -0
- package/package.json +61 -0
- package/script/build +12 -0
- package/script/develop +17 -0
- package/src/const.ts +599 -0
- package/src/esp_loader.ts +1907 -0
- package/src/index.ts +63 -0
- package/src/lib/spiffs/index.ts +22 -0
- package/src/lib/spiffs/spiffs.ts +175 -0
- package/src/lib/spiffs/spiffsBlock.ts +204 -0
- package/src/lib/spiffs/spiffsConfig.ts +140 -0
- package/src/lib/spiffs/spiffsPage.ts +357 -0
- package/src/lib/spiffs/spiffsReader.ts +280 -0
- package/src/partition.ts +155 -0
- package/src/struct.ts +108 -0
- package/src/stubs/README.md +3 -0
- package/src/stubs/esp32.json +8 -0
- package/src/stubs/esp32c2.json +8 -0
- package/src/stubs/esp32c3.json +8 -0
- package/src/stubs/esp32c5.json +8 -0
- package/src/stubs/esp32c6.json +8 -0
- package/src/stubs/esp32c61.json +8 -0
- package/src/stubs/esp32h2.json +8 -0
- package/src/stubs/esp32p4.json +8 -0
- package/src/stubs/esp32p4r3.json +8 -0
- package/src/stubs/esp32s2.json +8 -0
- package/src/stubs/esp32s3.json +8 -0
- package/src/stubs/esp8266.json +8 -0
- package/src/stubs/index.ts +86 -0
- package/src/util.ts +49 -0
- package/src/wasm/fatfs/fatfs.wasm +0 -0
- package/src/wasm/fatfs/index.d.ts +26 -0
- package/src/wasm/fatfs/index.js +343 -0
- package/src/wasm/filesystems.ts +156 -0
- package/src/wasm/littlefs/index.d.ts +83 -0
- package/src/wasm/littlefs/index.js +529 -0
- package/src/wasm/littlefs/littlefs.js +2 -0
- package/src/wasm/littlefs/littlefs.wasm +0 -0
- package/src/wasm/shared/types.ts +13 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { FileSource, BinarySource } from "../shared/types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Maximum filename length (ESP-IDF default: 64)
|
|
5
|
+
*/
|
|
6
|
+
export declare const LFS_NAME_MAX: number;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* LittleFS disk version 2.0 (0x00020000)
|
|
10
|
+
* Use this for maximum compatibility with older implementations.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DISK_VERSION_2_0: number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* LittleFS disk version 2.1 (0x00020001)
|
|
16
|
+
* Latest version with additional features.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DISK_VERSION_2_1: number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Format disk version as human-readable string (e.g., "2.0", "2.1")
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatDiskVersion(version: number): string;
|
|
24
|
+
|
|
25
|
+
export interface LittleFSEntry {
|
|
26
|
+
path: string;
|
|
27
|
+
size: number;
|
|
28
|
+
type: "file" | "dir";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface LittleFSOptions {
|
|
32
|
+
blockSize?: number;
|
|
33
|
+
blockCount?: number;
|
|
34
|
+
lookaheadSize?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Optional override for the wasm asset location. Useful when bundlers move files.
|
|
37
|
+
*/
|
|
38
|
+
wasmURL?: string | URL;
|
|
39
|
+
/**
|
|
40
|
+
* Formats the filesystem immediately after initialization.
|
|
41
|
+
*/
|
|
42
|
+
formatOnInit?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Disk version to use when formatting new filesystems.
|
|
45
|
+
* Use DISK_VERSION_2_0 for compatibility with older ESP implementations.
|
|
46
|
+
* Use DISK_VERSION_2_1 for latest features.
|
|
47
|
+
*
|
|
48
|
+
* IMPORTANT: Setting this prevents automatic migration of older filesystems.
|
|
49
|
+
*/
|
|
50
|
+
diskVersion?: number;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface LittleFS {
|
|
54
|
+
format(): void;
|
|
55
|
+
list(path?: string): LittleFSEntry[];
|
|
56
|
+
addFile(path: string, data: FileSource): void;
|
|
57
|
+
writeFile(path: string, data: FileSource): void;
|
|
58
|
+
deleteFile(path: string): void;
|
|
59
|
+
delete(path: string, options?: {
|
|
60
|
+
recursive?: boolean;
|
|
61
|
+
}): void;
|
|
62
|
+
mkdir(path: string): void;
|
|
63
|
+
rename(oldPath: string, newPath: string): void;
|
|
64
|
+
toImage(): Uint8Array;
|
|
65
|
+
readFile(path: string): Uint8Array;
|
|
66
|
+
/**
|
|
67
|
+
* Get the disk version of the mounted filesystem.
|
|
68
|
+
* @returns Version as 32-bit number (e.g., 0x00020000 for v2.0)
|
|
69
|
+
*/
|
|
70
|
+
getDiskVersion(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Get filesystem usage statistics.
|
|
73
|
+
*/
|
|
74
|
+
getUsage(): { capacityBytes: number; usedBytes: number; freeBytes: number };
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export declare class LittleFSError extends Error {
|
|
78
|
+
readonly code: number;
|
|
79
|
+
constructor(message: string, code: number);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export declare function createLittleFS(options?: LittleFSOptions): Promise<LittleFS>;
|
|
83
|
+
export declare function createLittleFSFromImage(image: BinarySource, options?: LittleFSOptions): Promise<LittleFS>;
|
|
@@ -0,0 +1,529 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LittleFS WebAssembly Bindings for ESPConnect
|
|
3
|
+
*
|
|
4
|
+
* Provides TypeScript-first API for LittleFS with disk version control.
|
|
5
|
+
* Supports DISK_VERSION_2_0 to prevent automatic migration of older filesystems.
|
|
6
|
+
*
|
|
7
|
+
* ESP-IDF Compatible Configuration:
|
|
8
|
+
* - LFS_NAME_MAX=64 (filename length)
|
|
9
|
+
* - LFS_ATTR_MAX=4 (metadata for timestamps)
|
|
10
|
+
* - LFS_MULTIVERSION enabled
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
// Import Emscripten-generated module loader (converted to ES module)
|
|
14
|
+
import createLittleFSModule from './littlefs.js';
|
|
15
|
+
|
|
16
|
+
const DEFAULT_BLOCK_SIZE = 4096;
|
|
17
|
+
const DEFAULT_BLOCK_COUNT = 256;
|
|
18
|
+
const DEFAULT_LOOKAHEAD_SIZE = 32;
|
|
19
|
+
const LFS_ERR_NOSPC = -28;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Maximum filename length (ESP-IDF default)
|
|
23
|
+
*/
|
|
24
|
+
export const LFS_NAME_MAX = 64;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* LittleFS disk version 2.0 (0x00020000)
|
|
28
|
+
* Use this for maximum compatibility with older implementations.
|
|
29
|
+
*/
|
|
30
|
+
export const DISK_VERSION_2_0 = 0x00020000;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* LittleFS disk version 2.1 (0x00020001)
|
|
34
|
+
* Latest version with additional features.
|
|
35
|
+
*/
|
|
36
|
+
export const DISK_VERSION_2_1 = 0x00020001;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Format disk version as human-readable string (e.g., "2.0", "2.1")
|
|
40
|
+
*/
|
|
41
|
+
export function formatDiskVersion(version) {
|
|
42
|
+
const major = (version >> 16) & 0xffff;
|
|
43
|
+
const minor = version & 0xffff;
|
|
44
|
+
return `${major}.${minor}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export class LittleFSError extends Error {
|
|
48
|
+
constructor(message, code) {
|
|
49
|
+
super(message);
|
|
50
|
+
this.code = code;
|
|
51
|
+
this.name = "LittleFSError";
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function createModuleConfig(wasmURL) {
|
|
56
|
+
const wasmURLStr = wasmURL instanceof URL ? wasmURL.href : wasmURL;
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
locateFile: (path) => {
|
|
60
|
+
if (path.endsWith('.wasm')) {
|
|
61
|
+
console.info("[littlefs-wasm] locateFile:", path, "->", wasmURLStr);
|
|
62
|
+
return wasmURLStr;
|
|
63
|
+
}
|
|
64
|
+
return path;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create a new LittleFS instance
|
|
71
|
+
* @param {LittleFSOptions} options
|
|
72
|
+
* @returns {Promise<LittleFS>}
|
|
73
|
+
*/
|
|
74
|
+
export async function createLittleFS(options = {}) {
|
|
75
|
+
console.info("[littlefs-wasm] createLittleFS() starting", options);
|
|
76
|
+
|
|
77
|
+
const blockSize = options.blockSize ?? DEFAULT_BLOCK_SIZE;
|
|
78
|
+
const blockCount = options.blockCount ?? DEFAULT_BLOCK_COUNT;
|
|
79
|
+
const lookaheadSize = options.lookaheadSize ?? DEFAULT_LOOKAHEAD_SIZE;
|
|
80
|
+
const diskVersion = options.diskVersion ?? DISK_VERSION_2_0;
|
|
81
|
+
|
|
82
|
+
// Configure module with custom locateFile for WASM
|
|
83
|
+
// Always set locateFile to ensure correct WASM path resolution
|
|
84
|
+
const wasmURL = options.wasmURL ?? new URL('./littlefs.wasm', import.meta.url).href;
|
|
85
|
+
const moduleConfig = createModuleConfig(wasmURL);
|
|
86
|
+
|
|
87
|
+
// Initialize Emscripten module
|
|
88
|
+
const Module = await createLittleFSModule(moduleConfig);
|
|
89
|
+
console.info("[littlefs-wasm] Emscripten module loaded");
|
|
90
|
+
try {
|
|
91
|
+
// Set disk version before init to ensure new filesystems use the specified version
|
|
92
|
+
// and to prevent automatic migration from older versions
|
|
93
|
+
if (Module._lfs_wasm_set_disk_version) {
|
|
94
|
+
Module._lfs_wasm_set_disk_version(diskVersion);
|
|
95
|
+
console.info("[littlefs-wasm] Disk version set to:", formatDiskVersion(diskVersion));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Initialize LittleFS
|
|
99
|
+
const initResult = Module._lfs_wasm_init(blockSize, blockCount, lookaheadSize);
|
|
100
|
+
if (initResult !== 0) {
|
|
101
|
+
throw new LittleFSError(`Failed to initialize LittleFS: ${initResult}`, initResult);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Format if requested
|
|
105
|
+
if (options.formatOnInit) {
|
|
106
|
+
const formatResult = Module._lfs_wasm_format();
|
|
107
|
+
if (formatResult !== 0) {
|
|
108
|
+
throw new LittleFSError(`Failed to format LittleFS: ${formatResult}`, formatResult);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Mount (with optional auto-format on failure)
|
|
113
|
+
const mountResult = Module._lfs_wasm_mount();
|
|
114
|
+
if (mountResult !== 0) {
|
|
115
|
+
if (options.autoFormatOnMountFailure !== true) {
|
|
116
|
+
throw new LittleFSError(`Failed to mount LittleFS: ${mountResult}`, mountResult);
|
|
117
|
+
}
|
|
118
|
+
console.warn("[littlefs-wasm] Mount failed, attempting format and remount...");
|
|
119
|
+
const formatResult = Module._lfs_wasm_format();
|
|
120
|
+
if (formatResult !== 0) {
|
|
121
|
+
throw new LittleFSError(`Failed to format LittleFS: ${formatResult}`, formatResult);
|
|
122
|
+
}
|
|
123
|
+
const retryMount = Module._lfs_wasm_mount();
|
|
124
|
+
if (retryMount !== 0) {
|
|
125
|
+
throw new LittleFSError(`Failed to mount LittleFS: ${retryMount}`, retryMount);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
// Clean up Module resources before rethrowing
|
|
130
|
+
if (Module._lfs_wasm_cleanup) {
|
|
131
|
+
try {
|
|
132
|
+
Module._lfs_wasm_cleanup();
|
|
133
|
+
} catch (cleanupError) {
|
|
134
|
+
console.error("[littlefs-wasm] Cleanup during error handling failed:", cleanupError);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
console.info("[littlefs-wasm] LittleFS mounted successfully");
|
|
141
|
+
return createClient(Module, blockSize, blockCount);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Create a LittleFS instance from an existing image
|
|
146
|
+
* @param {Uint8Array|ArrayBuffer} image
|
|
147
|
+
* @param {LittleFSOptions} options
|
|
148
|
+
* @returns {Promise<LittleFS>}
|
|
149
|
+
*/
|
|
150
|
+
export async function createLittleFSFromImage(image, options = {}) {
|
|
151
|
+
console.info("[littlefs-wasm] createLittleFSFromImage() starting");
|
|
152
|
+
|
|
153
|
+
const imageData = image instanceof ArrayBuffer ? new Uint8Array(image) : image;
|
|
154
|
+
const blockSize = options.blockSize ?? DEFAULT_BLOCK_SIZE;
|
|
155
|
+
const blockCount = options.blockCount ?? Math.ceil(imageData.length / blockSize);
|
|
156
|
+
const lookaheadSize = options.lookaheadSize ?? DEFAULT_LOOKAHEAD_SIZE;
|
|
157
|
+
|
|
158
|
+
// Configure module with custom locateFile for WASM
|
|
159
|
+
// Always set locateFile to ensure correct WASM path resolution
|
|
160
|
+
const wasmURL = options.wasmURL ?? new URL('./littlefs.wasm', import.meta.url).href;
|
|
161
|
+
const moduleConfig = createModuleConfig(wasmURL);
|
|
162
|
+
|
|
163
|
+
// Initialize Emscripten module
|
|
164
|
+
const Module = await createLittleFSModule(moduleConfig);
|
|
165
|
+
console.info("[littlefs-wasm] Emscripten module loaded");
|
|
166
|
+
|
|
167
|
+
// When loading from image, don't set disk version (preserve existing)
|
|
168
|
+
// This is important to not trigger migration
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
// Allocate memory for image
|
|
172
|
+
const imagePtr = Module._malloc(imageData.length);
|
|
173
|
+
if (!imagePtr) {
|
|
174
|
+
throw new LittleFSError("Failed to allocate memory for image", -1);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
// Copy image to WASM memory (access HEAPU8 after malloc to ensure current buffer)
|
|
179
|
+
Module.HEAPU8.set(imageData, imagePtr);
|
|
180
|
+
|
|
181
|
+
// Initialize from image
|
|
182
|
+
const initResult = Module._lfs_wasm_init_from_image(
|
|
183
|
+
imagePtr,
|
|
184
|
+
imageData.length,
|
|
185
|
+
blockSize,
|
|
186
|
+
blockCount,
|
|
187
|
+
lookaheadSize
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
if (initResult !== 0) {
|
|
191
|
+
throw new LittleFSError(`Failed to initialize LittleFS from image: ${initResult}`, initResult);
|
|
192
|
+
}
|
|
193
|
+
} finally {
|
|
194
|
+
Module._free(imagePtr);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Mount
|
|
198
|
+
const mountResult = Module._lfs_wasm_mount();
|
|
199
|
+
if (mountResult !== 0) {
|
|
200
|
+
throw new LittleFSError(`Failed to mount LittleFS: ${mountResult}`, mountResult);
|
|
201
|
+
}
|
|
202
|
+
} catch (error) {
|
|
203
|
+
// Clean up Module resources before rethrowing
|
|
204
|
+
if (Module._lfs_wasm_cleanup) {
|
|
205
|
+
try {
|
|
206
|
+
Module._lfs_wasm_cleanup();
|
|
207
|
+
} catch (cleanupError) {
|
|
208
|
+
console.error("[littlefs-wasm] Cleanup during error handling failed:", cleanupError);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
throw error;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Get disk version after mounting
|
|
215
|
+
const version = Module._lfs_wasm_get_disk_version ? Module._lfs_wasm_get_disk_version() : 0;
|
|
216
|
+
console.info("[littlefs-wasm] LittleFS mounted from image, disk version:", formatDiskVersion(version));
|
|
217
|
+
|
|
218
|
+
return createClient(Module, blockSize, blockCount);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Create the client API wrapper
|
|
223
|
+
*/
|
|
224
|
+
function createClient(Module, blockSize, blockCount) {
|
|
225
|
+
const encoder = new TextEncoder();
|
|
226
|
+
const decoder = new TextDecoder();
|
|
227
|
+
|
|
228
|
+
function allocString(str) {
|
|
229
|
+
const bytes = encoder.encode(str + '\0');
|
|
230
|
+
const ptr = Module._malloc(bytes.length);
|
|
231
|
+
if (!ptr) throw new LittleFSError("Failed to allocate string", -1);
|
|
232
|
+
// Get HEAPU8 AFTER malloc to avoid stale reference if memory grows
|
|
233
|
+
Module.HEAPU8.set(bytes, ptr);
|
|
234
|
+
return ptr;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function readString(ptr, maxLength = 4096) {
|
|
238
|
+
if (!ptr) return "";
|
|
239
|
+
let end = ptr;
|
|
240
|
+
const limit = ptr + maxLength;
|
|
241
|
+
while (end < limit && Module.HEAPU8[end] !== 0) end++;
|
|
242
|
+
if (end >= limit) {
|
|
243
|
+
console.warn("[littlefs-wasm] String read truncated at maxLength");
|
|
244
|
+
}
|
|
245
|
+
return decoder.decode(Module.HEAPU8.subarray(ptr, end));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const client = {
|
|
249
|
+
format() {
|
|
250
|
+
const result = Module._lfs_wasm_format();
|
|
251
|
+
if (result !== 0) {
|
|
252
|
+
throw new LittleFSError(`Format failed: ${result}`, result);
|
|
253
|
+
}
|
|
254
|
+
// Remount after format
|
|
255
|
+
const mountResult = Module._lfs_wasm_mount();
|
|
256
|
+
if (mountResult !== 0) {
|
|
257
|
+
throw new LittleFSError(`Mount after format failed: ${mountResult}`, mountResult);
|
|
258
|
+
}
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
list(path = "/") {
|
|
262
|
+
const entries = [];
|
|
263
|
+
const pathPtr = allocString(path);
|
|
264
|
+
let dirHandle = -1;
|
|
265
|
+
|
|
266
|
+
try {
|
|
267
|
+
// dir_open returns handle >= 0 on success, negative on error
|
|
268
|
+
dirHandle = Module._lfs_wasm_dir_open(pathPtr);
|
|
269
|
+
if (dirHandle < 0) {
|
|
270
|
+
throw new LittleFSError(`Failed to open directory: ${dirHandle}`, dirHandle);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
const nameBuffer = Module._malloc(LFS_NAME_MAX + 1);
|
|
274
|
+
const typePtr = Module._malloc(4);
|
|
275
|
+
const sizePtr = Module._malloc(4);
|
|
276
|
+
|
|
277
|
+
try {
|
|
278
|
+
while (true) {
|
|
279
|
+
// dir_read takes handle as first parameter
|
|
280
|
+
const readResult = Module._lfs_wasm_dir_read(dirHandle, nameBuffer, LFS_NAME_MAX, typePtr, sizePtr);
|
|
281
|
+
if (readResult === 0) break; // No more entries
|
|
282
|
+
if (readResult < 0) {
|
|
283
|
+
throw new LittleFSError(`Failed to read directory: ${readResult}`, readResult);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
const name = readString(nameBuffer);
|
|
287
|
+
// . and .. are already filtered in C code, but double-check
|
|
288
|
+
if (name === "." || name === "..") continue;
|
|
289
|
+
|
|
290
|
+
const type = Module.HEAP32[typePtr >> 2];
|
|
291
|
+
const size = Module.HEAPU32[sizePtr >> 2];
|
|
292
|
+
|
|
293
|
+
const entryPath = path === "/" ? `/${name}` : `${path}/${name}`;
|
|
294
|
+
// type: 1 = file (LFS_TYPE_REG), 2 = directory (LFS_TYPE_DIR)
|
|
295
|
+
const isDir = type === 2;
|
|
296
|
+
entries.push({
|
|
297
|
+
path: entryPath,
|
|
298
|
+
name,
|
|
299
|
+
size: isDir ? 0 : size, // Files have size, directories don't
|
|
300
|
+
type: isDir ? "dir" : "file"
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
} finally {
|
|
304
|
+
Module._free(nameBuffer);
|
|
305
|
+
Module._free(typePtr);
|
|
306
|
+
Module._free(sizePtr);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// dir_close takes handle as parameter
|
|
310
|
+
Module._lfs_wasm_dir_close(dirHandle);
|
|
311
|
+
dirHandle = -1; // Mark as closed
|
|
312
|
+
} finally {
|
|
313
|
+
Module._free(pathPtr);
|
|
314
|
+
// Close handle if still open (in case of exception)
|
|
315
|
+
if (dirHandle >= 0) {
|
|
316
|
+
Module._lfs_wasm_dir_close(dirHandle);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
return entries;
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
readFile(path) {
|
|
324
|
+
const pathPtr = allocString(path);
|
|
325
|
+
try {
|
|
326
|
+
// Get file size first
|
|
327
|
+
const size = Module._lfs_wasm_file_size(pathPtr);
|
|
328
|
+
if (size < 0) {
|
|
329
|
+
throw new LittleFSError(`Failed to get file size: ${size}`, size);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const dataPtr = Module._malloc(size);
|
|
333
|
+
if (!dataPtr && size > 0) {
|
|
334
|
+
throw new LittleFSError("Failed to allocate read buffer", -1);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
try {
|
|
338
|
+
const readResult = Module._lfs_wasm_read_file(pathPtr, dataPtr, size);
|
|
339
|
+
if (readResult < 0) {
|
|
340
|
+
throw new LittleFSError(`Failed to read file: ${readResult}`, readResult);
|
|
341
|
+
}
|
|
342
|
+
return new Uint8Array(Module.HEAPU8.buffer, dataPtr, readResult).slice();
|
|
343
|
+
} finally {
|
|
344
|
+
Module._free(dataPtr);
|
|
345
|
+
}
|
|
346
|
+
} finally {
|
|
347
|
+
Module._free(pathPtr);
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
writeFile(path, data) {
|
|
352
|
+
const pathPtr = allocString(path);
|
|
353
|
+
const bytes = data instanceof Uint8Array ? data : new Uint8Array(data);
|
|
354
|
+
const dataPtr = Module._malloc(bytes.length);
|
|
355
|
+
|
|
356
|
+
if (!dataPtr && bytes.length > 0) {
|
|
357
|
+
Module._free(pathPtr);
|
|
358
|
+
throw new LittleFSError("Failed to allocate write buffer", -1);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
try {
|
|
362
|
+
// Access HEAPU8 after malloc to ensure we have current buffer
|
|
363
|
+
Module.HEAPU8.set(bytes, dataPtr);
|
|
364
|
+
const result = Module._lfs_wasm_write_file(pathPtr, dataPtr, bytes.length);
|
|
365
|
+
if (result < 0) {
|
|
366
|
+
if (result === LFS_ERR_NOSPC) {
|
|
367
|
+
throw new LittleFSError("No space left on device", result);
|
|
368
|
+
}
|
|
369
|
+
throw new LittleFSError(`Failed to write file: ${result}`, result);
|
|
370
|
+
}
|
|
371
|
+
} finally {
|
|
372
|
+
Module._free(pathPtr);
|
|
373
|
+
Module._free(dataPtr);
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
|
|
377
|
+
addFile(path, data) {
|
|
378
|
+
return this.writeFile(path, data);
|
|
379
|
+
},
|
|
380
|
+
|
|
381
|
+
deleteFile(path) {
|
|
382
|
+
const pathPtr = allocString(path);
|
|
383
|
+
try {
|
|
384
|
+
const result = Module._lfs_wasm_remove(pathPtr);
|
|
385
|
+
if (result !== 0) {
|
|
386
|
+
throw new LittleFSError(`Failed to delete: ${result}`, result);
|
|
387
|
+
}
|
|
388
|
+
} finally {
|
|
389
|
+
Module._free(pathPtr);
|
|
390
|
+
}
|
|
391
|
+
},
|
|
392
|
+
|
|
393
|
+
delete(path, options = {}) {
|
|
394
|
+
if (options.recursive) {
|
|
395
|
+
// List contents and delete recursively
|
|
396
|
+
try {
|
|
397
|
+
const entries = this.list(path);
|
|
398
|
+
for (const entry of entries) {
|
|
399
|
+
if (entry.type === "dir") {
|
|
400
|
+
this.delete(entry.path, { recursive: true });
|
|
401
|
+
} else {
|
|
402
|
+
this.deleteFile(entry.path);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
} catch (e) {
|
|
406
|
+
// Directory might be empty or not exist, log other errors
|
|
407
|
+
if (e.code !== -2) { // -2 is ENOENT
|
|
408
|
+
console.warn("[littlefs-wasm] Error during recursive delete:", e);
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
this.deleteFile(path);
|
|
413
|
+
},
|
|
414
|
+
|
|
415
|
+
mkdir(path) {
|
|
416
|
+
const pathPtr = allocString(path);
|
|
417
|
+
try {
|
|
418
|
+
const result = Module._lfs_wasm_mkdir(pathPtr);
|
|
419
|
+
// Ignore "already exists" error
|
|
420
|
+
if (result !== 0 && result !== -17) {
|
|
421
|
+
throw new LittleFSError(`Failed to create directory: ${result}`, result);
|
|
422
|
+
}
|
|
423
|
+
} finally {
|
|
424
|
+
Module._free(pathPtr);
|
|
425
|
+
}
|
|
426
|
+
},
|
|
427
|
+
|
|
428
|
+
rename(oldPath, newPath) {
|
|
429
|
+
const oldPtr = allocString(oldPath);
|
|
430
|
+
const newPtr = allocString(newPath);
|
|
431
|
+
try {
|
|
432
|
+
const result = Module._lfs_wasm_rename(oldPtr, newPtr);
|
|
433
|
+
if (result !== 0) {
|
|
434
|
+
throw new LittleFSError(`Failed to rename: ${result}`, result);
|
|
435
|
+
}
|
|
436
|
+
} finally {
|
|
437
|
+
Module._free(oldPtr);
|
|
438
|
+
Module._free(newPtr);
|
|
439
|
+
}
|
|
440
|
+
},
|
|
441
|
+
|
|
442
|
+
toImage() {
|
|
443
|
+
const size = Module._lfs_wasm_get_image_size();
|
|
444
|
+
if (size <= 0) {
|
|
445
|
+
throw new LittleFSError(`Invalid image size: ${size}`, size);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
const ptr = Module._lfs_wasm_get_image();
|
|
449
|
+
if (!ptr) {
|
|
450
|
+
throw new LittleFSError("Failed to get image pointer", -1);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Note: ptr points to internal ram_storage buffer, not allocated memory
|
|
454
|
+
// slice() already copies the data, so we must NOT free this pointer
|
|
455
|
+
return new Uint8Array(Module.HEAPU8.buffer, ptr, size).slice();
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
getDiskVersion() {
|
|
459
|
+
if (Module._lfs_wasm_get_fs_info) {
|
|
460
|
+
const versionPtr = Module._malloc(4);
|
|
461
|
+
try {
|
|
462
|
+
const result = Module._lfs_wasm_get_fs_info(versionPtr);
|
|
463
|
+
if (result === 0) {
|
|
464
|
+
return Module.HEAPU32[versionPtr >> 2];
|
|
465
|
+
}
|
|
466
|
+
} finally {
|
|
467
|
+
Module._free(versionPtr);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
console.warn("[littlefs-wasm] getDiskVersion not available or filesystem not mounted");
|
|
471
|
+
return 0;
|
|
472
|
+
},
|
|
473
|
+
|
|
474
|
+
setDiskVersion(version) {
|
|
475
|
+
if (Module._lfs_wasm_set_disk_version) {
|
|
476
|
+
Module._lfs_wasm_set_disk_version(version);
|
|
477
|
+
} else {
|
|
478
|
+
console.warn("[littlefs-wasm] setDiskVersion not available");
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
|
|
482
|
+
getUsage() {
|
|
483
|
+
const blockUsedPtr = Module._malloc(4);
|
|
484
|
+
const blockTotalPtr = Module._malloc(4);
|
|
485
|
+
|
|
486
|
+
try {
|
|
487
|
+
const result = Module._lfs_wasm_fs_stat(blockUsedPtr, blockTotalPtr);
|
|
488
|
+
if (result !== 0) {
|
|
489
|
+
// Fallback estimation
|
|
490
|
+
return {
|
|
491
|
+
capacityBytes: blockSize * blockCount,
|
|
492
|
+
usedBytes: 0,
|
|
493
|
+
freeBytes: blockSize * blockCount
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const blocksUsed = Module.HEAPU32[blockUsedPtr >> 2];
|
|
498
|
+
const blocksTotal = Module.HEAPU32[blockTotalPtr >> 2];
|
|
499
|
+
|
|
500
|
+
const capacityBytes = blocksTotal * blockSize;
|
|
501
|
+
const usedBytes = blocksUsed * blockSize;
|
|
502
|
+
|
|
503
|
+
return {
|
|
504
|
+
capacityBytes,
|
|
505
|
+
usedBytes,
|
|
506
|
+
freeBytes: Math.max(0, capacityBytes - usedBytes)
|
|
507
|
+
};
|
|
508
|
+
} finally {
|
|
509
|
+
Module._free(blockUsedPtr);
|
|
510
|
+
Module._free(blockTotalPtr);
|
|
511
|
+
}
|
|
512
|
+
},
|
|
513
|
+
|
|
514
|
+
canFit(path, size) {
|
|
515
|
+
const usage = this.getUsage();
|
|
516
|
+
return usage.freeBytes >= size;
|
|
517
|
+
},
|
|
518
|
+
|
|
519
|
+
cleanup() {
|
|
520
|
+
Module._lfs_wasm_unmount();
|
|
521
|
+
Module._lfs_wasm_cleanup();
|
|
522
|
+
}
|
|
523
|
+
};
|
|
524
|
+
|
|
525
|
+
return client;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Default export for CommonJS compatibility
|
|
529
|
+
export default { createLittleFS, createLittleFSFromImage, DISK_VERSION_2_0, DISK_VERSION_2_1, LFS_NAME_MAX, formatDiskVersion };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export default (()=>{var _scriptName=globalThis.document?.currentScript?.src;return async function(moduleArg={}){var moduleRtn;var Module=moduleArg;var ENVIRONMENT_IS_WEB=!!globalThis.window;var ENVIRONMENT_IS_WORKER=!!globalThis.WorkerGlobalScope;var ENVIRONMENT_IS_NODE=globalThis.process?.versions?.node&&globalThis.process?.type!="renderer";var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};if(ENVIRONMENT_IS_WORKER){_scriptName=self.location.href}var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}return scriptDirectory+path}var readAsync,readBinary;if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){try{scriptDirectory=new URL(".",_scriptName).href}catch{}{if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=async url=>{var response=await fetch(url,{credentials:"same-origin"});if(response.ok){return response.arrayBuffer()}throw new Error(response.status+" : "+response.url)}}}else{}var out=console.log.bind(console);var err=console.error.bind(console);var wasmBinary;var ABORT=false;var EXITSTATUS;var readyPromiseResolve,readyPromiseReject;var HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64;var HEAP64,HEAPU64;var runtimeInitialized=false;function updateMemoryViews(){var b=wasmMemory.buffer;HEAP8=new Int8Array(b);HEAP16=new Int16Array(b);Module["HEAPU8"]=HEAPU8=new Uint8Array(b);HEAPU16=new Uint16Array(b);Module["HEAP32"]=HEAP32=new Int32Array(b);Module["HEAPU32"]=HEAPU32=new Uint32Array(b);HEAPF32=new Float32Array(b);HEAPF64=new Float64Array(b);HEAP64=new BigInt64Array(b);HEAPU64=new BigUint64Array(b)}function preRun(){if(Module["preRun"]){if(typeof Module["preRun"]=="function")Module["preRun"]=[Module["preRun"]];while(Module["preRun"].length){addOnPreRun(Module["preRun"].shift())}}callRuntimeCallbacks(onPreRuns)}function initRuntime(){runtimeInitialized=true;wasmExports["i"]()}function postRun(){if(Module["postRun"]){if(typeof Module["postRun"]=="function")Module["postRun"]=[Module["postRun"]];while(Module["postRun"].length){addOnPostRun(Module["postRun"].shift())}}callRuntimeCallbacks(onPostRuns)}function abort(what){Module["onAbort"]?.(what);what="Aborted("+what+")";err(what);ABORT=true;what+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(what);readyPromiseReject?.(e);throw e}var wasmBinaryFile;function findWasmBinary(){return locateFile("littlefs.wasm")}function getBinarySync(file){if(file==wasmBinaryFile&&wasmBinary){return new Uint8Array(wasmBinary)}if(readBinary){return readBinary(file)}throw"both async and sync fetching of the wasm failed"}async function getWasmBinary(binaryFile){if(!wasmBinary){try{var response=await readAsync(binaryFile);return new Uint8Array(response)}catch{}}return getBinarySync(binaryFile)}async function instantiateArrayBuffer(binaryFile,imports){try{var binary=await getWasmBinary(binaryFile);var instance=await WebAssembly.instantiate(binary,imports);return instance}catch(reason){err(`failed to asynchronously prepare wasm: ${reason}`);abort(reason)}}async function instantiateAsync(binary,binaryFile,imports){if(!binary){try{var response=fetch(binaryFile,{credentials:"same-origin"});var instantiationResult=await WebAssembly.instantiateStreaming(response,imports);return instantiationResult}catch(reason){err(`wasm streaming compile failed: ${reason}`);err("falling back to ArrayBuffer instantiation")}}return instantiateArrayBuffer(binaryFile,imports)}function getWasmImports(){var imports={a:wasmImports};return imports}async function createWasm(){function receiveInstance(instance,module){wasmExports=instance.exports;assignWasmExports(wasmExports);updateMemoryViews();return wasmExports}function receiveInstantiationResult(result){return receiveInstance(result["instance"])}var info=getWasmImports();if(Module["instantiateWasm"]){return new Promise((resolve,reject)=>{Module["instantiateWasm"](info,(inst,mod)=>{resolve(receiveInstance(inst,mod))})})}wasmBinaryFile??=findWasmBinary();var result=await instantiateAsync(wasmBinary,wasmBinaryFile,info);var exports=receiveInstantiationResult(result);return exports}class ExitStatus{name="ExitStatus";constructor(status){this.message=`Program terminated with exit(${status})`;this.status=status}}var callRuntimeCallbacks=callbacks=>{while(callbacks.length>0){callbacks.shift()(Module)}};var onPostRuns=[];var addOnPostRun=cb=>onPostRuns.push(cb);var onPreRuns=[];var addOnPreRun=cb=>onPreRuns.push(cb);var noExitRuntime=true;var UTF8Decoder=globalThis.TextDecoder&&new TextDecoder;var findStringEnd=(heapOrArray,idx,maxBytesToRead,ignoreNul)=>{var maxIdx=idx+maxBytesToRead;if(ignoreNul)return maxIdx;while(heapOrArray[idx]&&!(idx>=maxIdx))++idx;return idx};var UTF8ArrayToString=(heapOrArray,idx=0,maxBytesToRead,ignoreNul)=>{var endPtr=findStringEnd(heapOrArray,idx,maxBytesToRead,ignoreNul);if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}return str};var UTF8ToString=(ptr,maxBytesToRead,ignoreNul)=>ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead,ignoreNul):"";var ___assert_fail=(condition,filename,line,func)=>abort(`Assertion failed: ${UTF8ToString(condition)}, at: `+[filename?UTF8ToString(filename):"unknown filename",line,func?UTF8ToString(func):"unknown function"]);var __abort_js=()=>abort("");var runtimeKeepaliveCounter=0;var __emscripten_runtime_keepalive_clear=()=>{noExitRuntime=false;runtimeKeepaliveCounter=0};var timers={};var handleException=e=>{if(e instanceof ExitStatus||e=="unwind"){return EXITSTATUS}quit_(1,e)};var keepRuntimeAlive=()=>noExitRuntime||runtimeKeepaliveCounter>0;var _proc_exit=code=>{EXITSTATUS=code;if(!keepRuntimeAlive()){Module["onExit"]?.(code);ABORT=true}quit_(code,new ExitStatus(code))};var exitJS=(status,implicit)=>{EXITSTATUS=status;_proc_exit(status)};var _exit=exitJS;var maybeExit=()=>{if(!keepRuntimeAlive()){try{_exit(EXITSTATUS)}catch(e){handleException(e)}}};var callUserCallback=func=>{if(ABORT){return}try{func();maybeExit()}catch(e){handleException(e)}};var _emscripten_get_now=()=>performance.now();var __setitimer_js=(which,timeout_ms)=>{if(timers[which]){clearTimeout(timers[which].id);delete timers[which]}if(!timeout_ms)return 0;var id=setTimeout(()=>{delete timers[which];callUserCallback(()=>__emscripten_timeout(which,_emscripten_get_now()))},timeout_ms);timers[which]={id,timeout_ms};return 0};var getHeapMax=()=>67108864;var alignMemory=(size,alignment)=>Math.ceil(size/alignment)*alignment;var growMemory=size=>{var oldHeapSize=wasmMemory.buffer.byteLength;var pages=(size-oldHeapSize+65535)/65536|0;try{wasmMemory.grow(pages);updateMemoryViews();return 1}catch(e){}};var _emscripten_resize_heap=requestedSize=>{var oldSize=HEAPU8.length;requestedSize>>>=0;var maxHeapSize=getHeapMax();if(requestedSize>maxHeapSize){return false}for(var cutDown=1;cutDown<=4;cutDown*=2){var overGrownHeapSize=oldSize*(1+.2/cutDown);overGrownHeapSize=Math.min(overGrownHeapSize,requestedSize+100663296);var newSize=Math.min(maxHeapSize,alignMemory(Math.max(requestedSize,overGrownHeapSize),65536));var replacement=growMemory(newSize);if(replacement){return true}}return false};var printCharBuffers=[null,[],[]];var printChar=(stream,curr)=>{var buffer=printCharBuffers[stream];if(curr===0||curr===10){(stream===1?out:err)(UTF8ArrayToString(buffer));buffer.length=0}else{buffer.push(curr)}};var _fd_write=(fd,iov,iovcnt,pnum)=>{var num=0;for(var i=0;i<iovcnt;i++){var ptr=HEAPU32[iov>>2];var len=HEAPU32[iov+4>>2];iov+=8;for(var j=0;j<len;j++){printChar(fd,HEAPU8[ptr+j])}num+=len}HEAPU32[pnum>>2]=num;return 0};{if(Module["noExitRuntime"])noExitRuntime=Module["noExitRuntime"];if(Module["print"])out=Module["print"];if(Module["printErr"])err=Module["printErr"];if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];if(Module["arguments"])arguments_=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["preInit"]){if(typeof Module["preInit"]=="function")Module["preInit"]=[Module["preInit"]];while(Module["preInit"].length>0){Module["preInit"].shift()()}}}var _lfs_wasm_set_disk_version,_lfs_wasm_get_disk_version,_lfs_wasm_init,_free,_malloc,_lfs_wasm_init_from_image,_lfs_wasm_get_fs_info,_lfs_wasm_mount,_lfs_wasm_unmount,_lfs_wasm_format,_lfs_wasm_mkdir,_lfs_wasm_remove,_lfs_wasm_rename,_lfs_wasm_stat,_lfs_wasm_dir_open,_lfs_wasm_dir_read,_lfs_wasm_dir_close,_lfs_wasm_write_file,_lfs_wasm_read_file,_lfs_wasm_file_size,_lfs_wasm_get_image,_lfs_wasm_get_image_size,_lfs_wasm_fs_stat,_lfs_wasm_cleanup,__emscripten_timeout,memory,__indirect_function_table,wasmMemory;function assignWasmExports(wasmExports){_lfs_wasm_set_disk_version=Module["_lfs_wasm_set_disk_version"]=wasmExports["j"];_lfs_wasm_get_disk_version=Module["_lfs_wasm_get_disk_version"]=wasmExports["k"];_lfs_wasm_init=Module["_lfs_wasm_init"]=wasmExports["l"];_free=Module["_free"]=wasmExports["m"];_malloc=Module["_malloc"]=wasmExports["n"];_lfs_wasm_init_from_image=Module["_lfs_wasm_init_from_image"]=wasmExports["o"];_lfs_wasm_get_fs_info=Module["_lfs_wasm_get_fs_info"]=wasmExports["p"];_lfs_wasm_mount=Module["_lfs_wasm_mount"]=wasmExports["q"];_lfs_wasm_unmount=Module["_lfs_wasm_unmount"]=wasmExports["r"];_lfs_wasm_format=Module["_lfs_wasm_format"]=wasmExports["s"];_lfs_wasm_mkdir=Module["_lfs_wasm_mkdir"]=wasmExports["t"];_lfs_wasm_remove=Module["_lfs_wasm_remove"]=wasmExports["u"];_lfs_wasm_rename=Module["_lfs_wasm_rename"]=wasmExports["v"];_lfs_wasm_stat=Module["_lfs_wasm_stat"]=wasmExports["w"];_lfs_wasm_dir_open=Module["_lfs_wasm_dir_open"]=wasmExports["x"];_lfs_wasm_dir_read=Module["_lfs_wasm_dir_read"]=wasmExports["y"];_lfs_wasm_dir_close=Module["_lfs_wasm_dir_close"]=wasmExports["z"];_lfs_wasm_write_file=Module["_lfs_wasm_write_file"]=wasmExports["A"];_lfs_wasm_read_file=Module["_lfs_wasm_read_file"]=wasmExports["B"];_lfs_wasm_file_size=Module["_lfs_wasm_file_size"]=wasmExports["C"];_lfs_wasm_get_image=Module["_lfs_wasm_get_image"]=wasmExports["D"];_lfs_wasm_get_image_size=Module["_lfs_wasm_get_image_size"]=wasmExports["E"];_lfs_wasm_fs_stat=Module["_lfs_wasm_fs_stat"]=wasmExports["F"];_lfs_wasm_cleanup=Module["_lfs_wasm_cleanup"]=wasmExports["G"];__emscripten_timeout=wasmExports["H"];memory=wasmMemory=wasmExports["h"];__indirect_function_table=wasmExports["__indirect_function_table"]}var wasmImports={a:___assert_fail,d:__abort_js,c:__emscripten_runtime_keepalive_clear,e:__setitimer_js,f:_emscripten_resize_heap,g:_fd_write,b:_proc_exit};function run(){preRun();function doRun(){Module["calledRun"]=true;if(ABORT)return;initRuntime();readyPromiseResolve?.(Module);Module["onRuntimeInitialized"]?.();postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setTimeout(()=>{setTimeout(()=>Module["setStatus"](""),1);doRun()},1)}else{doRun()}}var wasmExports;wasmExports=await (createWasm());run();if(runtimeInitialized){moduleRtn=Module}else{moduleRtn=new Promise((resolve,reject)=>{readyPromiseResolve=resolve;readyPromiseReject=reject})}
|
|
2
|
+
;return moduleRtn}})();if(typeof exports==="object"&&typeof module==="object"){module.exports=createLittleFS;module.exports.default=createLittleFS}else if(typeof define==="function"&&define["amd"])define([],()=>createLittleFS);
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for filesystem implementations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* File source can be a string, Uint8Array, or ArrayBuffer
|
|
7
|
+
*/
|
|
8
|
+
export type FileSource = string | Uint8Array | ArrayBuffer;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Binary source for filesystem images (Uint8Array or ArrayBuffer)
|
|
12
|
+
*/
|
|
13
|
+
export type BinarySource = Uint8Array | ArrayBuffer;
|