@mikrojs/quickjs 0.17.1-pr-300.20260731010039 → 0.18.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/apply-patches.js +13 -100
- package/deps/quickjs/api-test.c +765 -0
- package/deps/quickjs/builtin-array-fromasync.h +37 -36
- package/deps/quickjs/builtin-iterator-zip-keyed.h +1 -1
- package/deps/quickjs/builtin-iterator-zip.h +1 -1
- package/deps/quickjs/cutils.h +1 -0
- package/deps/quickjs/libregexp-opcode.h +26 -11
- package/deps/quickjs/libregexp.c +1640 -745
- package/deps/quickjs/libregexp.h +6 -1
- package/deps/quickjs/libunicode-table.h +466 -0
- package/deps/quickjs/libunicode.c +331 -8
- package/deps/quickjs/libunicode.h +48 -2
- package/deps/quickjs/lre-test.c +64 -4
- package/deps/quickjs/qjs.c +39 -25
- package/deps/quickjs/qjsc.c +0 -72
- package/deps/quickjs/quickjs-libc.c +44 -24
- package/deps/quickjs/quickjs.c +2214 -1253
- package/deps/quickjs/quickjs.h +49 -23
- package/deps/quickjs/run-test262.c +1 -1
- package/deps/quickjs/unicode_gen.c +15 -2
- package/package.json +1 -1
- package/postinstall.js +42 -17
- package/quickjs.cmake +22 -12
package/apply-patches.js
CHANGED
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
* @mikrojs/native (which calls the patched module-management symbols).
|
|
15
15
|
*/
|
|
16
16
|
import {execFileSync} from 'node:child_process'
|
|
17
|
-
import {
|
|
18
|
-
import {existsSync, readdirSync, readFileSync, writeFileSync} from 'node:fs'
|
|
19
|
-
import {tmpdir} from 'node:os'
|
|
17
|
+
import {existsSync, readdirSync} from 'node:fs'
|
|
20
18
|
import {dirname, join} from 'node:path'
|
|
21
19
|
import {fileURLToPath} from 'node:url'
|
|
22
20
|
|
|
@@ -24,116 +22,31 @@ const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
|
24
22
|
const qjsDir = join(__dirname, 'deps', 'quickjs')
|
|
25
23
|
const patchesDir = join(__dirname, 'patches')
|
|
26
24
|
|
|
27
|
-
function seriesHash(files) {
|
|
28
|
-
const hash = createHash('sha256')
|
|
29
|
-
for (const f of files) hash.update(readFileSync(join(patchesDir, f)))
|
|
30
|
-
return hash.digest('hex')
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function applyAll(files) {
|
|
34
|
-
for (const f of files) {
|
|
35
|
-
try {
|
|
36
|
-
execFileSync('git', ['apply', join(patchesDir, f)], {cwd: qjsDir, stdio: 'inherit'})
|
|
37
|
-
console.log(`@mikrojs/quickjs: applied patch ${f}`)
|
|
38
|
-
} catch (err) {
|
|
39
|
-
console.error(`@mikrojs/quickjs: failed to apply ${f}`, err.message)
|
|
40
|
-
process.exit(1)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
25
|
export function applyPatches() {
|
|
46
|
-
// Published tarballs ship pre-patched sources and exclude patches/ from
|
|
47
|
-
// the package files, so consumers return here and never need git.
|
|
48
26
|
if (!existsSync(patchesDir)) return
|
|
49
27
|
const files = readdirSync(patchesDir)
|
|
50
28
|
.filter((f) => f.endsWith('.patch'))
|
|
51
29
|
.sort()
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
// so they are only meaningful as a whole series applied in order to a
|
|
56
|
-
// pristine tree. A stamp records which series the tree currently carries.
|
|
57
|
-
const stampFile = join(qjsDir, '.patches-stamp')
|
|
58
|
-
const hash = seriesHash(files)
|
|
59
|
-
if (existsSync(stampFile) && readFileSync(stampFile, 'utf8').trim() === hash) {
|
|
60
|
-
// The stamp can outlive the tree it describes (e.g. `git submodule
|
|
61
|
-
// update` resets sources but leaves untracked files); trust it only if
|
|
62
|
-
// the series bounds are actually present. First and last together catch
|
|
63
|
-
// both a reset tree and a partially reverted one.
|
|
64
|
-
try {
|
|
65
|
-
for (const probe of [files[0], files[files.length - 1]]) {
|
|
66
|
-
execFileSync('git', ['apply', '--reverse', '--check', join(patchesDir, probe)], {
|
|
67
|
-
cwd: qjsDir,
|
|
68
|
-
stdio: 'pipe',
|
|
69
|
-
})
|
|
70
|
-
}
|
|
71
|
-
return // series already applied
|
|
72
|
-
} catch {
|
|
73
|
-
// stale stamp — fall through and re-apply
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
let inRepo = true
|
|
78
|
-
try {
|
|
79
|
-
execFileSync('git', ['-C', qjsDir, 'rev-parse', 'HEAD'], {stdio: 'pipe'})
|
|
80
|
-
} catch {
|
|
81
|
-
inRepo = false
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (!inRepo) {
|
|
85
|
-
// Sources without git metadata (should not happen: tarballs exclude
|
|
86
|
-
// patches/ and return above). Refuse rather than guess.
|
|
87
|
-
console.error('@mikrojs/quickjs: patches/ present but deps/quickjs is not a git checkout')
|
|
88
|
-
process.exit(1)
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// In-repo: reset to the pinned commit, then apply the whole series.
|
|
92
|
-
// Only reset when the tree state is accounted for (a previous series
|
|
93
|
-
// stamp, a clean tree, or a tree matching the pre-stamp-era series);
|
|
94
|
-
// otherwise refuse rather than discard unknown local edits. Untracked
|
|
95
|
-
// files (editor droppings, agent scratch dirs) are ignored: they cannot
|
|
96
|
-
// conflict with `git apply` of tracked-file patches, and `checkout -- .`
|
|
97
|
-
// could not remove them anyway.
|
|
98
|
-
const dirty =
|
|
99
|
-
execFileSync('git', ['-C', qjsDir, 'status', '--porcelain', '--untracked-files=no'], {
|
|
100
|
-
encoding: 'utf8',
|
|
101
|
-
})
|
|
102
|
-
.split('\n')
|
|
103
|
-
.filter((l) => l.trim()).length > 0
|
|
104
|
-
if (dirty && !existsSync(stampFile)) {
|
|
105
|
-
// Pre-stamp checkouts have some prefix of the series applied; the
|
|
106
|
-
// first patch reverse-checking is strong evidence of that state.
|
|
30
|
+
for (const f of files) {
|
|
31
|
+
const patch = join(patchesDir, f)
|
|
32
|
+
// Probe: is the patch already applied?
|
|
107
33
|
try {
|
|
108
|
-
execFileSync('git', ['apply', '--reverse', '--check',
|
|
34
|
+
execFileSync('git', ['apply', '--reverse', '--check', patch], {
|
|
109
35
|
cwd: qjsDir,
|
|
110
36
|
stdio: 'pipe',
|
|
111
37
|
})
|
|
38
|
+
continue // already applied
|
|
112
39
|
} catch {
|
|
113
|
-
|
|
114
|
-
'@mikrojs/quickjs: submodule tree has local changes that do not match the patch series.\n' +
|
|
115
|
-
`Commit them as a patch or discard them: git -C ${qjsDir} checkout -- .`,
|
|
116
|
-
)
|
|
117
|
-
process.exit(1)
|
|
40
|
+
// not applied — fall through
|
|
118
41
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
// recoverable instead of silently gone.
|
|
126
|
-
const diff = execFileSync('git', ['-C', qjsDir, 'diff'], {encoding: 'utf8'})
|
|
127
|
-
if (diff.length > 0) {
|
|
128
|
-
const backup = join(tmpdir(), `quickjs-discarded-${Date.now()}.patch`)
|
|
129
|
-
writeFileSync(backup, diff)
|
|
130
|
-
console.log(`@mikrojs/quickjs: re-deriving submodule tree from the patch series`)
|
|
131
|
-
console.log(`@mikrojs/quickjs: previous tracked changes saved to ${backup}`)
|
|
42
|
+
try {
|
|
43
|
+
execFileSync('git', ['apply', patch], {cwd: qjsDir, stdio: 'inherit'})
|
|
44
|
+
console.log(`@mikrojs/quickjs: applied patch ${f}`)
|
|
45
|
+
} catch (err) {
|
|
46
|
+
console.error(`@mikrojs/quickjs: failed to apply ${f}`, err.message)
|
|
47
|
+
process.exit(1)
|
|
132
48
|
}
|
|
133
|
-
execFileSync('git', ['-C', qjsDir, 'checkout', '--', '.'], {stdio: 'inherit'})
|
|
134
49
|
}
|
|
135
|
-
applyAll(files)
|
|
136
|
-
writeFileSync(stampFile, hash + '\n')
|
|
137
50
|
}
|
|
138
51
|
|
|
139
52
|
// Run directly: sync the submodule, then apply patches.
|