@hakobu/hakobu 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/LICENSE +21 -0
- package/README.md +673 -0
- package/dictionary/angular-bridge.js +3 -0
- package/dictionary/any-promise.js +3 -0
- package/dictionary/async.js +3 -0
- package/dictionary/aws-sdk.js +7 -0
- package/dictionary/babel-core.js +3 -0
- package/dictionary/batch.js +3 -0
- package/dictionary/bcrypt.js +3 -0
- package/dictionary/better-sqlite3.js +3 -0
- package/dictionary/bignum.js +3 -0
- package/dictionary/bindings.js +3 -0
- package/dictionary/blessed.js +8 -0
- package/dictionary/body-parser.js +9 -0
- package/dictionary/browserify.js +7 -0
- package/dictionary/bson.js +3 -0
- package/dictionary/buffermaker.js +7 -0
- package/dictionary/bunyan.js +9 -0
- package/dictionary/busboy.js +7 -0
- package/dictionary/bytes.js +3 -0
- package/dictionary/callsites.js +3 -0
- package/dictionary/chokidar.js +3 -0
- package/dictionary/coffee-script.js +7 -0
- package/dictionary/colors.js +3 -0
- package/dictionary/compression.js +3 -0
- package/dictionary/compressjs.js +7 -0
- package/dictionary/connect-mongo.js +3 -0
- package/dictionary/connect-mongodb.js +3 -0
- package/dictionary/connect-redis.js +3 -0
- package/dictionary/connect.js +10 -0
- package/dictionary/consolidate.js +3 -0
- package/dictionary/cookie-parser.js +3 -0
- package/dictionary/cookie.js +3 -0
- package/dictionary/cors.js +3 -0
- package/dictionary/cron.js +3 -0
- package/dictionary/cross-env.js +11 -0
- package/dictionary/cross-spawn-async.js +3 -0
- package/dictionary/curve25519.js +3 -0
- package/dictionary/data-preflight.js +7 -0
- package/dictionary/debug.js +3 -0
- package/dictionary/denymount.js +3 -0
- package/dictionary/diff.js +3 -0
- package/dictionary/drivelist.js +22 -0
- package/dictionary/ed25519.js +3 -0
- package/dictionary/ejs.js +3 -0
- package/dictionary/elasticsearch.js +3 -0
- package/dictionary/electron.js +17 -0
- package/dictionary/emailjs.js +3 -0
- package/dictionary/engine.io.js +3 -0
- package/dictionary/epoll.js +3 -0
- package/dictionary/errorhandler.js +7 -0
- package/dictionary/errors.js +7 -0
- package/dictionary/eslint.js +7 -0
- package/dictionary/etcher-image-write.js +3 -0
- package/dictionary/exceljs.js +21 -0
- package/dictionary/exiftool.exe.js +13 -0
- package/dictionary/exiftool.pl.js +13 -0
- package/dictionary/express-load.js +12 -0
- package/dictionary/express-session.js +3 -0
- package/dictionary/express.js +14 -0
- package/dictionary/extender.js +11 -0
- package/dictionary/extsprintf.js +3 -0
- package/dictionary/faye-websocket.js +3 -0
- package/dictionary/feathers.js +3 -0
- package/dictionary/findup-sync.js +3 -0
- package/dictionary/floordate.js +3 -0
- package/dictionary/fmt.js +3 -0
- package/dictionary/formidable.js +3 -0
- package/dictionary/fs-extra.js +3 -0
- package/dictionary/fsevents.js +3 -0
- package/dictionary/geoip-lite.js +7 -0
- package/dictionary/github.js +7 -0
- package/dictionary/gm.js +3 -0
- package/dictionary/google-closure-compiler-java.js +13 -0
- package/dictionary/google-closure-compiler.js +13 -0
- package/dictionary/googleapis.js +7 -0
- package/dictionary/got.js +3 -0
- package/dictionary/graceful-fs.js +19 -0
- package/dictionary/grpc.js +11 -0
- package/dictionary/gulp.js +3 -0
- package/dictionary/hap-nodejs.js +3 -0
- package/dictionary/heapdump.js +3 -0
- package/dictionary/hoek.js +3 -0
- package/dictionary/homebridge.js +3 -0
- package/dictionary/http-proxy.js +3 -0
- package/dictionary/http-server.js +3 -0
- package/dictionary/image-size.js +3 -0
- package/dictionary/indexof.js +3 -0
- package/dictionary/inquirer.js +3 -0
- package/dictionary/j.js +16 -0
- package/dictionary/jade.js +3 -0
- package/dictionary/jsdom.js +3 -0
- package/dictionary/json-stringify-date.js +3 -0
- package/dictionary/json-stringify-safe.js +3 -0
- package/dictionary/jsonwebtoken.js +3 -0
- package/dictionary/kerberos.js +3 -0
- package/dictionary/knex.js +7 -0
- package/dictionary/later.js +7 -0
- package/dictionary/level.js +3 -0
- package/dictionary/leveldown.js +10 -0
- package/dictionary/levelup.js +3 -0
- package/dictionary/liftoff.js +12 -0
- package/dictionary/lodash.js +3 -0
- package/dictionary/log4js.js +7 -0
- package/dictionary/logform.js +7 -0
- package/dictionary/machinepack-urls.js +7 -0
- package/dictionary/markdown.js +3 -0
- package/dictionary/mdns.js +6 -0
- package/dictionary/method-override.js +3 -0
- package/dictionary/microjob.js +16 -0
- package/dictionary/mime-types.js +3 -0
- package/dictionary/mime.js +3 -0
- package/dictionary/minimatch.js +3 -0
- package/dictionary/minstache.js +3 -0
- package/dictionary/module-deps.js +3 -0
- package/dictionary/moment-timezone.js +3 -0
- package/dictionary/moment.js +7 -0
- package/dictionary/mongodb-core.js +22 -0
- package/dictionary/mongodb.js +7 -0
- package/dictionary/mongoose.js +7 -0
- package/dictionary/mongoskin.js +7 -0
- package/dictionary/ms.js +3 -0
- package/dictionary/msgpack.js +3 -0
- package/dictionary/multer.js +3 -0
- package/dictionary/muri.js +3 -0
- package/dictionary/native-or-bluebird.js +3 -0
- package/dictionary/natives.js +3 -0
- package/dictionary/nconf.js +7 -0
- package/dictionary/nedb.js +3 -0
- package/dictionary/negotiator.js +7 -0
- package/dictionary/newrelic.js +3 -0
- package/dictionary/nib.js +3 -0
- package/dictionary/nightmare.js +18 -0
- package/dictionary/node-forge.js +7 -0
- package/dictionary/node-libcurl.js +3 -0
- package/dictionary/node-notifier.js +30 -0
- package/dictionary/node-pre-gyp.js +7 -0
- package/dictionary/node-redis-pubsub.js +3 -0
- package/dictionary/node-sass.js +3 -0
- package/dictionary/node-uuid.js +3 -0
- package/dictionary/node-xlsx.js +3 -0
- package/dictionary/node-zookeeper-client.js +7 -0
- package/dictionary/nodegit.js +7 -0
- package/dictionary/nodemailer-sendmail-transport.js +3 -0
- package/dictionary/nodemailer.js +3 -0
- package/dictionary/npm-registry-client.js +7 -0
- package/dictionary/npm.js +7 -0
- package/dictionary/nssocket.js +3 -0
- package/dictionary/oauth2orize.js +7 -0
- package/dictionary/octobat.js +3 -0
- package/dictionary/open.js +13 -0
- package/dictionary/opn.js +4 -0
- package/dictionary/optimist.js +3 -0
- package/dictionary/passport-local.js +3 -0
- package/dictionary/passport.js +3 -0
- package/dictionary/pg-cursor.js +3 -0
- package/dictionary/pg-query-stream.js +3 -0
- package/dictionary/pg-types.js +7 -0
- package/dictionary/pg.js +7 -0
- package/dictionary/pg.js.js +7 -0
- package/dictionary/pgpass.js +7 -0
- package/dictionary/phantom.js +19 -0
- package/dictionary/phantomjs-prebuilt.js +16 -0
- package/dictionary/pkginfo.js +3 -0
- package/dictionary/pm2.js +7 -0
- package/dictionary/pmx.js +3 -0
- package/dictionary/pouchdb.js +3 -0
- package/dictionary/primus-emitter.js +3 -0
- package/dictionary/primus-spark-latency.js +3 -0
- package/dictionary/primus.js +3 -0
- package/dictionary/publicsuffixlist.js +15 -0
- package/dictionary/pug.js +3 -0
- package/dictionary/punt.js +3 -0
- package/dictionary/puppeteer.js +13 -0
- package/dictionary/pwd.js +3 -0
- package/dictionary/q.js +3 -0
- package/dictionary/raven.js +3 -0
- package/dictionary/rc.js +12 -0
- package/dictionary/readable-stream.js +3 -0
- package/dictionary/rechoir.js +3 -0
- package/dictionary/redis-parser.js +3 -0
- package/dictionary/redis.js +3 -0
- package/dictionary/regression.js +3 -0
- package/dictionary/reload.js +7 -0
- package/dictionary/request.js +3 -0
- package/dictionary/require-uncached.js +3 -0
- package/dictionary/require_optional.js +3 -0
- package/dictionary/s3.js +3 -0
- package/dictionary/safe_datejs.js +3 -0
- package/dictionary/sails.js +33 -0
- package/dictionary/sax.js +3 -0
- package/dictionary/scrypt.js +3 -0
- package/dictionary/semver.js +3 -0
- package/dictionary/sequelize.js +7 -0
- package/dictionary/serialport.js +3 -0
- package/dictionary/sha3.js +3 -0
- package/dictionary/sharp.js +11 -0
- package/dictionary/shelljs.js +7 -0
- package/dictionary/sinon.js +3 -0
- package/dictionary/socket.io-client.js +13 -0
- package/dictionary/socket.io.js +12 -0
- package/dictionary/sqip.js +7 -0
- package/dictionary/sqlite3.js +7 -0
- package/dictionary/steam-crypto.js +7 -0
- package/dictionary/steam-resources.js +19 -0
- package/dictionary/steam.js +3 -0
- package/dictionary/stripe-webhook-middleware.js +3 -0
- package/dictionary/stripe.js +3 -0
- package/dictionary/strong-globalize.js +3 -0
- package/dictionary/stylus.js +14 -0
- package/dictionary/supervisor.js +3 -0
- package/dictionary/svgo.js +8 -0
- package/dictionary/tabtab.js +3 -0
- package/dictionary/tesseract.js.js +7 -0
- package/dictionary/thread-stream.js +7 -0
- package/dictionary/throng.js +3 -0
- package/dictionary/time.js +3 -0
- package/dictionary/tinify.js +7 -0
- package/dictionary/tiny-worker.js +7 -0
- package/dictionary/tmp.js +3 -0
- package/dictionary/transformers.js +3 -0
- package/dictionary/uglify-js.js +9 -0
- package/dictionary/umd.js +19 -0
- package/dictionary/underscore.js +3 -0
- package/dictionary/union.js +3 -0
- package/dictionary/update-notifier.js +3 -0
- package/dictionary/usage.js +7 -0
- package/dictionary/v8flags.js +13 -0
- package/dictionary/verror.js +3 -0
- package/dictionary/voc.js +3 -0
- package/dictionary/webdriverio.js +7 -0
- package/dictionary/winston-uber.js +7 -0
- package/dictionary/winston.js +7 -0
- package/dictionary/ws.js +3 -0
- package/dictionary/xlsx.js +16 -0
- package/dictionary/xml2js.js +3 -0
- package/dictionary/yargs.js +3 -0
- package/dictionary/zeromq.js +13 -0
- package/lib-es5/addon-extract.js +164 -0
- package/lib-es5/analyzer.js +687 -0
- package/lib-es5/app-bundle.js +133 -0
- package/lib-es5/appdir.js +265 -0
- package/lib-es5/bin.js +304 -0
- package/lib-es5/bootstrap.js +179 -0
- package/lib-es5/bundler.js +496 -0
- package/lib-es5/chmod.js +15 -0
- package/lib-es5/colors.js +12 -0
- package/lib-es5/commands.js +376 -0
- package/lib-es5/common.js +328 -0
- package/lib-es5/compress_type.js +10 -0
- package/lib-es5/config.js +291 -0
- package/lib-es5/detector.js +421 -0
- package/lib-es5/esm-hooks.js +366 -0
- package/lib-es5/esm-resolver.js +292 -0
- package/lib-es5/esm-transformer.js +378 -0
- package/lib-es5/exports-resolver.js +184 -0
- package/lib-es5/external-artifacts.js +170 -0
- package/lib-es5/fabricator.js +137 -0
- package/lib-es5/follow.js +190 -0
- package/lib-es5/help.js +52 -0
- package/lib-es5/index.d.ts +2 -0
- package/lib-es5/index.js +552 -0
- package/lib-es5/log.js +7 -0
- package/lib-es5/mach-o.js +262 -0
- package/lib-es5/manifest.js +21 -0
- package/lib-es5/options.js +19 -0
- package/lib-es5/packager.js +1036 -0
- package/lib-es5/packer.js +137 -0
- package/lib-es5/pe-metadata.js +130 -0
- package/lib-es5/producer.js +378 -0
- package/lib-es5/refiner.js +87 -0
- package/lib-es5/resolver.js +142 -0
- package/lib-es5/runtime-diagnostics.js +172 -0
- package/lib-es5/sea.js +307 -0
- package/lib-es5/snapshot-fs-patch.js +396 -0
- package/lib-es5/snapshot-fs.js +255 -0
- package/lib-es5/snapshot-index.js +135 -0
- package/lib-es5/snapshot-path.js +168 -0
- package/lib-es5/types.js +9 -0
- package/lib-es5/walker.js +1019 -0
- package/lib-es5/windows-sign.js +139 -0
- package/package.json +99 -0
- package/prelude/bootstrap.js +2263 -0
- package/prelude/diagnostic.js +147 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hakobu Native Addon Extraction
|
|
4
|
+
*
|
|
5
|
+
* Native .node addons cannot be loaded from an in-memory snapshot —
|
|
6
|
+
* they must exist as real files on the filesystem because dlopen()
|
|
7
|
+
* requires a real file path.
|
|
8
|
+
*
|
|
9
|
+
* This module extracts addons from the snapshot blob to a deterministic
|
|
10
|
+
* cache location on disk, keyed by content hash. This ensures:
|
|
11
|
+
*
|
|
12
|
+
* 1. Deterministic: same addon content → same extraction path
|
|
13
|
+
* 2. Idempotent: re-extraction is a no-op if the file already exists
|
|
14
|
+
* 3. Safe: permissions are narrowed appropriately
|
|
15
|
+
* 4. Cache-friendly: old versions can be garbage-collected
|
|
16
|
+
*
|
|
17
|
+
* Extraction path:
|
|
18
|
+
* {cacheDir}/{contentHash}/{addonFilename}
|
|
19
|
+
*
|
|
20
|
+
* e.g.: ~/.hakobu/addons/a1b2c3d4.../binding.node
|
|
21
|
+
*
|
|
22
|
+
* The extracted path replaces the snapshot path in require() resolution
|
|
23
|
+
* so that dlopen() can load the real file.
|
|
24
|
+
*/
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.cleanAddonCache = exports.extractAllAddons = exports.extractAddon = exports.getAddonCacheDir = void 0;
|
|
30
|
+
const fs_1 = __importDefault(require("fs"));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
33
|
+
const os_1 = __importDefault(require("os"));
|
|
34
|
+
const snapshot_path_1 = require("./snapshot-path");
|
|
35
|
+
const runtime_diagnostics_1 = require("./runtime-diagnostics");
|
|
36
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
37
|
+
// Cache directory
|
|
38
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
39
|
+
/**
|
|
40
|
+
* Get the addon extraction cache directory.
|
|
41
|
+
*
|
|
42
|
+
* Resolution order:
|
|
43
|
+
* 1. HAKOBU_ADDON_CACHE env var
|
|
44
|
+
* 2. $HOME/.hakobu/addons (default)
|
|
45
|
+
* 3. os.tmpdir()/hakobu-addons (fallback when home unavailable)
|
|
46
|
+
*/
|
|
47
|
+
function getAddonCacheDir() {
|
|
48
|
+
if (process.env.HAKOBU_ADDON_CACHE) {
|
|
49
|
+
return process.env.HAKOBU_ADDON_CACHE;
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
const home = os_1.default.homedir();
|
|
53
|
+
if (home) {
|
|
54
|
+
return path_1.default.join(home, '.hakobu', 'addons');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch { /* home unavailable */ }
|
|
58
|
+
return path_1.default.join(os_1.default.tmpdir(), 'hakobu-addons');
|
|
59
|
+
}
|
|
60
|
+
exports.getAddonCacheDir = getAddonCacheDir;
|
|
61
|
+
/**
|
|
62
|
+
* Extract a native addon from the snapshot to the real filesystem.
|
|
63
|
+
*
|
|
64
|
+
* If the addon is already cached (same content hash), returns the
|
|
65
|
+
* existing path without re-extracting. This makes extraction idempotent.
|
|
66
|
+
*
|
|
67
|
+
* @param snapshotPath - The addon's path in the snapshot
|
|
68
|
+
* @param sfs - The SnapshotFS instance
|
|
69
|
+
* @param cacheDir - Override cache directory (for testing)
|
|
70
|
+
* @returns ExtractedAddon with the real filesystem path
|
|
71
|
+
*/
|
|
72
|
+
function extractAddon(snapshotPath, sfs, cacheDir) {
|
|
73
|
+
const canonical = (0, snapshot_path_1.toCanonical)(snapshotPath);
|
|
74
|
+
const content = sfs.readFileSync(canonical);
|
|
75
|
+
// Compute content hash for deterministic path
|
|
76
|
+
const contentHash = crypto_1.default
|
|
77
|
+
.createHash('sha256')
|
|
78
|
+
.update(content)
|
|
79
|
+
.digest('hex');
|
|
80
|
+
// Build extraction path: {cacheDir}/{hash}/{filename}
|
|
81
|
+
const fileName = path_1.default.basename(canonical);
|
|
82
|
+
const dir = path_1.default.join(cacheDir || getAddonCacheDir(), contentHash);
|
|
83
|
+
const extractedPath = path_1.default.join(dir, fileName);
|
|
84
|
+
// Check cache: if file exists with correct size, skip extraction
|
|
85
|
+
if (fs_1.default.existsSync(extractedPath)) {
|
|
86
|
+
try {
|
|
87
|
+
const stat = fs_1.default.statSync(extractedPath);
|
|
88
|
+
if (stat.size === content.length) {
|
|
89
|
+
return {
|
|
90
|
+
snapshotPath: canonical,
|
|
91
|
+
extractedPath,
|
|
92
|
+
contentHash,
|
|
93
|
+
freshlyExtracted: false,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
// Fall through to extract
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// Extract: create directory and write the addon
|
|
102
|
+
try {
|
|
103
|
+
fs_1.default.mkdirSync(dir, { recursive: true });
|
|
104
|
+
fs_1.default.writeFileSync(extractedPath, content);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
throw (0, runtime_diagnostics_1.addonExtractionFailed)(canonical, extractedPath, err);
|
|
108
|
+
}
|
|
109
|
+
// Set executable permission (some addons need it)
|
|
110
|
+
try {
|
|
111
|
+
fs_1.default.chmodSync(extractedPath, 0o755);
|
|
112
|
+
}
|
|
113
|
+
catch {
|
|
114
|
+
// chmod may fail on some platforms — non-fatal
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
snapshotPath: canonical,
|
|
118
|
+
extractedPath,
|
|
119
|
+
contentHash,
|
|
120
|
+
freshlyExtracted: true,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
exports.extractAddon = extractAddon;
|
|
124
|
+
/**
|
|
125
|
+
* Extract all native addons from the snapshot.
|
|
126
|
+
* Returns a map from snapshot path → extracted filesystem path.
|
|
127
|
+
*/
|
|
128
|
+
function extractAllAddons(sfs, cacheDir) {
|
|
129
|
+
const index = sfs.index;
|
|
130
|
+
const results = new Map();
|
|
131
|
+
for (const entry of index.entries) {
|
|
132
|
+
if (entry.kind === 'native-addon') {
|
|
133
|
+
const result = extractAddon(entry.path, sfs, cacheDir);
|
|
134
|
+
results.set(entry.path, result);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return results;
|
|
138
|
+
}
|
|
139
|
+
exports.extractAllAddons = extractAllAddons;
|
|
140
|
+
/**
|
|
141
|
+
* Clean old addon cache entries that are no longer referenced.
|
|
142
|
+
* @param keepHashes - Set of content hashes to keep
|
|
143
|
+
* @param cacheDir - Cache directory to clean
|
|
144
|
+
*/
|
|
145
|
+
function cleanAddonCache(keepHashes, cacheDir) {
|
|
146
|
+
const dir = cacheDir || getAddonCacheDir();
|
|
147
|
+
if (!fs_1.default.existsSync(dir))
|
|
148
|
+
return 0;
|
|
149
|
+
let removed = 0;
|
|
150
|
+
for (const entry of fs_1.default.readdirSync(dir)) {
|
|
151
|
+
if (!keepHashes.has(entry)) {
|
|
152
|
+
try {
|
|
153
|
+
fs_1.default.rmSync(path_1.default.join(dir, entry), { recursive: true, force: true });
|
|
154
|
+
removed++;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
// Non-fatal
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return removed;
|
|
162
|
+
}
|
|
163
|
+
exports.cleanAddonCache = cleanAddonCache;
|
|
164
|
+
//# sourceMappingURL=addon-extract.js.map
|