@mikrojs/native 0.17.0 → 0.17.1-next.20260731001908
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.
|
@@ -36,6 +36,7 @@ typedef struct DynBuf {
|
|
|
36
36
|
|
|
37
37
|
/* Wrapper functions defined in cutils_compat.c */
|
|
38
38
|
int mik__dbuf_put(DynBuf *s, const void *data, size_t len);
|
|
39
|
+
int mik__dbuf_claim(DynBuf *s, size_t len);
|
|
39
40
|
int mik__dbuf_putc(DynBuf *s, uint8_t val);
|
|
40
41
|
int mik__dbuf_putstr(DynBuf *s, const char *str);
|
|
41
42
|
void mik__dbuf_free(DynBuf *s);
|
|
@@ -46,6 +47,7 @@ char *mik__js_pstrcat(char *buf, int buf_size, const char *s);
|
|
|
46
47
|
|
|
47
48
|
/* Map original names to wrapper names */
|
|
48
49
|
#define dbuf_put mik__dbuf_put
|
|
50
|
+
#define dbuf_claim mik__dbuf_claim
|
|
49
51
|
#define dbuf_putc mik__dbuf_putc
|
|
50
52
|
#define dbuf_putstr mik__dbuf_putstr
|
|
51
53
|
#define dbuf_free mik__dbuf_free
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikrojs/native",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1-next.20260731001908",
|
|
4
4
|
"description": "Mikro.js C++ runtime library and Node.js native addon",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"esp32",
|
|
@@ -86,14 +86,14 @@
|
|
|
86
86
|
"cmake-js": "^8.0.0",
|
|
87
87
|
"node-addon-api": "^8.7.0",
|
|
88
88
|
"node-gyp-build": "^4.8.4",
|
|
89
|
-
"@mikrojs/quickjs": "0.17.
|
|
89
|
+
"@mikrojs/quickjs": "0.17.1-next.20260731001908+ba9853e"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@swc/core": "^1.15.30",
|
|
93
93
|
"@types/node": "^24.12.2",
|
|
94
94
|
"esbuild": "^0.28.0",
|
|
95
95
|
"terser": "^5.46.2",
|
|
96
|
-
"@mikrojs/registry": "0.17.
|
|
96
|
+
"@mikrojs/registry": "0.17.1-next.20260731001908+ba9853e"
|
|
97
97
|
},
|
|
98
98
|
"engines": {
|
|
99
99
|
"node": ">=24.0.0"
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/cutils_compat.c
CHANGED
|
@@ -9,6 +9,10 @@ int mik__dbuf_put(DynBuf *s, const void *data, size_t len) {
|
|
|
9
9
|
return dbuf_put(s, data, len);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
int mik__dbuf_claim(DynBuf *s, size_t len) {
|
|
13
|
+
return dbuf_claim(s, len);
|
|
14
|
+
}
|
|
15
|
+
|
|
12
16
|
int mik__dbuf_putc(DynBuf *s, uint8_t val) {
|
|
13
17
|
return dbuf_putc(s, val);
|
|
14
18
|
}
|
package/src/mikrojs.cpp
CHANGED
|
@@ -850,6 +850,17 @@ int mik__load_file(JSContext* ctx, DynBuf* dbuf, const char* filename) {
|
|
|
850
850
|
return -1;
|
|
851
851
|
}
|
|
852
852
|
|
|
853
|
+
/* Reserve the exact file size up front: DynBuf grows 1.5x from zero, so
|
|
854
|
+
* letting it grow incrementally peaks at ~2.5x the file size mid-copy.
|
|
855
|
+
* +4 covers the NUL/wrapper suffix callers append after loading. */
|
|
856
|
+
struct stat st;
|
|
857
|
+
if (fstat(fd, &st) == 0 && st.st_size > 0) {
|
|
858
|
+
if (dbuf_claim(dbuf, (size_t)st.st_size + 4)) {
|
|
859
|
+
close(fd);
|
|
860
|
+
return -1;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
853
864
|
uint8_t buf[512];
|
|
854
865
|
ssize_t n;
|
|
855
866
|
while ((n = read(fd, buf, sizeof(buf))) > 0) {
|