seabox 0.1.0-beta.3 → 0.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/README.md +177 -154
- package/bin/seabox-rebuild.mjs +88 -0
- package/bin/seabox.mjs +147 -0
- package/lib/{blob.js → blob.mjs} +14 -19
- package/lib/bootstrap.cjs +753 -0
- package/lib/build-cache.mjs +199 -0
- package/lib/build.mjs +77 -0
- package/lib/config.mjs +243 -0
- package/lib/{crypto-assets.js → crypto-assets.mjs} +12 -47
- package/lib/diagnostics.mjs +203 -0
- package/lib/entry-bundler.mjs +64 -0
- package/lib/{fetch-node.js → fetch-node.mjs} +15 -20
- package/lib/index.mjs +26 -0
- package/lib/inject.mjs +95 -0
- package/lib/{manifest.js → manifest.mjs} +5 -11
- package/lib/multi-target-builder.mjs +705 -0
- package/lib/native-scanner.mjs +203 -0
- package/lib/{obfuscate.js → obfuscate.mjs} +9 -31
- package/lib/require-shim.mjs +113 -0
- package/lib/rolldown-bundler.mjs +411 -0
- package/lib/{unsign.js → unsign.cjs} +31 -46
- package/package.json +10 -5
- package/bin/seabox-rebuild.js +0 -395
- package/bin/seabox.js +0 -81
- package/lib/bindings.js +0 -31
- package/lib/bootstrap.js +0 -697
- package/lib/build.js +0 -283
- package/lib/bytenode-hack.js +0 -56
- package/lib/config.js +0 -119
- package/lib/index.js +0 -27
- package/lib/inject.js +0 -114
- package/lib/scanner.js +0 -153
package/lib/scanner.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* scanner.js
|
|
3
|
-
* Resolve glob patterns, collect assets, and identify binary artifacts.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const fs = require('fs');
|
|
7
|
-
const path = require('path');
|
|
8
|
-
const { glob } = require('glob');
|
|
9
|
-
const crypto = require('crypto');
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @typedef {Object} AssetEntry
|
|
13
|
-
* @property {string} sourcePath - Absolute path to the asset on disk
|
|
14
|
-
* @property {string} assetKey - Logical key in the SEA blob
|
|
15
|
-
* @property {boolean} isBinary - True if this is a binary artifact requiring extraction
|
|
16
|
-
* @property {string} [hash] - SHA-256 hash of the file
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Scan and resolve all assets from configuration.
|
|
21
|
-
* Supports negative glob patterns (prefixed with '!') for exclusions.
|
|
22
|
-
* @param {string[]} assetPatterns - Glob patterns from config (supports '!' prefix for exclusions)
|
|
23
|
-
* @param {string[]} [binaryPatterns] - Patterns identifying binaries to extract
|
|
24
|
-
* @param {string[]} [excludePatterns] - Legacy: Additional patterns to exclude (optional)
|
|
25
|
-
* @param {string} projectRoot - Project root directory
|
|
26
|
-
* @returns {Promise<AssetEntry[]>}
|
|
27
|
-
*/
|
|
28
|
-
async function scanAssets(assetPatterns, binaryPatterns = [], excludePatterns = [], projectRoot = process.cwd()) {
|
|
29
|
-
const assets = [];
|
|
30
|
-
const seenKeys = new Set();
|
|
31
|
-
|
|
32
|
-
// Separate positive and negative patterns
|
|
33
|
-
const includePatterns = [];
|
|
34
|
-
const negativePatterns = [];
|
|
35
|
-
|
|
36
|
-
for (const pattern of assetPatterns) {
|
|
37
|
-
if (pattern.startsWith('!')) {
|
|
38
|
-
// Negative pattern - add to exclusions (remove the '!' prefix)
|
|
39
|
-
negativePatterns.push(pattern.slice(1));
|
|
40
|
-
} else {
|
|
41
|
-
includePatterns.push(pattern);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// Combine negative patterns with legacy excludePatterns
|
|
46
|
-
const allExclusions = [...negativePatterns, ...excludePatterns];
|
|
47
|
-
|
|
48
|
-
// Process each include pattern
|
|
49
|
-
for (const pattern of includePatterns) {
|
|
50
|
-
const matches = await glob(pattern, {
|
|
51
|
-
cwd: projectRoot,
|
|
52
|
-
nodir: true,
|
|
53
|
-
absolute: false,
|
|
54
|
-
ignore: allExclusions
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
for (const match of matches) {
|
|
58
|
-
const sourcePath = path.resolve(projectRoot, match);
|
|
59
|
-
const assetKey = normalizeAssetKey(match);
|
|
60
|
-
|
|
61
|
-
// Skip duplicates
|
|
62
|
-
if (seenKeys.has(assetKey)) {
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
seenKeys.add(assetKey);
|
|
66
|
-
|
|
67
|
-
const isBinary = isBinaryAsset(match, binaryPatterns);
|
|
68
|
-
const hash = isBinary ? await computeHash(sourcePath) : undefined;
|
|
69
|
-
|
|
70
|
-
assets.push({
|
|
71
|
-
sourcePath,
|
|
72
|
-
assetKey,
|
|
73
|
-
isBinary,
|
|
74
|
-
hash
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return assets;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Normalize a file path to a forward-slash asset key.
|
|
84
|
-
* @param {string} filePath
|
|
85
|
-
* @returns {string}
|
|
86
|
-
*/
|
|
87
|
-
function normalizeAssetKey(filePath) {
|
|
88
|
-
return filePath.replace(/\\/g, '/');
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Check if an asset matches binary patterns.
|
|
93
|
-
* @param {string} filePath
|
|
94
|
-
* @param {string[]} binaryPatterns
|
|
95
|
-
* @returns {boolean}
|
|
96
|
-
*/
|
|
97
|
-
function isBinaryAsset(filePath, binaryPatterns) {
|
|
98
|
-
const ext = path.extname(filePath).toLowerCase();
|
|
99
|
-
const binaryExtensions = ['.node', '.dll', '.so', '.dylib'];
|
|
100
|
-
|
|
101
|
-
// Check explicit patterns first
|
|
102
|
-
for (const pattern of binaryPatterns) {
|
|
103
|
-
if (filePath.includes(pattern) || filePath.endsWith(pattern)) {
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
// Fall back to extension check
|
|
109
|
-
return binaryExtensions.includes(ext);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Compute SHA-256 hash of a file.
|
|
114
|
-
* @param {string} filePath
|
|
115
|
-
* @returns {Promise<string>}
|
|
116
|
-
*/
|
|
117
|
-
function computeHash(filePath) {
|
|
118
|
-
return new Promise((resolve, reject) => {
|
|
119
|
-
const hash = crypto.createHash('sha256');
|
|
120
|
-
const stream = fs.createReadStream(filePath);
|
|
121
|
-
stream.on('data', chunk => hash.update(chunk));
|
|
122
|
-
stream.on('end', () => resolve(hash.digest('hex')));
|
|
123
|
-
stream.on('error', reject);
|
|
124
|
-
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Group assets by binary vs non-binary.
|
|
129
|
-
* @param {AssetEntry[]} assets
|
|
130
|
-
* @returns {{binaries: AssetEntry[], nonBinaries: AssetEntry[]}}
|
|
131
|
-
*/
|
|
132
|
-
function groupAssets(assets) {
|
|
133
|
-
const binaries = [];
|
|
134
|
-
const nonBinaries = [];
|
|
135
|
-
|
|
136
|
-
for (const asset of assets) {
|
|
137
|
-
if (asset.isBinary) {
|
|
138
|
-
binaries.push(asset);
|
|
139
|
-
} else {
|
|
140
|
-
nonBinaries.push(asset);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return { binaries, nonBinaries };
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
module.exports = {
|
|
148
|
-
scanAssets,
|
|
149
|
-
normalizeAssetKey,
|
|
150
|
-
isBinaryAsset,
|
|
151
|
-
computeHash,
|
|
152
|
-
groupAssets
|
|
153
|
-
};
|