@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,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const colors_1 = require("./colors");
|
|
8
|
+
const common_1 = require("./common");
|
|
9
|
+
const log_1 = require("./log");
|
|
10
|
+
const win32 = process.platform === 'win32';
|
|
11
|
+
function hasParent(file, records) {
|
|
12
|
+
const dirname = path_1.default.dirname(file);
|
|
13
|
+
// root directory
|
|
14
|
+
if (dirname === file) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return Boolean(records[dirname]);
|
|
18
|
+
}
|
|
19
|
+
function purgeTopDirectories(records) {
|
|
20
|
+
while (true) {
|
|
21
|
+
let found = false;
|
|
22
|
+
for (const file in records) {
|
|
23
|
+
if (records[file]) {
|
|
24
|
+
const record = records[file];
|
|
25
|
+
const links = record[common_1.STORE_LINKS];
|
|
26
|
+
if (links && links.length === 1) {
|
|
27
|
+
if (!hasParent(file, records)) {
|
|
28
|
+
const file2 = path_1.default.join(file, links[0]);
|
|
29
|
+
const record2 = records[file2];
|
|
30
|
+
const links2 = record2[common_1.STORE_LINKS];
|
|
31
|
+
if (links2 && links2.length === 1) {
|
|
32
|
+
const file3 = path_1.default.join(file2, links2[0]);
|
|
33
|
+
const record3 = records[file3];
|
|
34
|
+
const links3 = record3[common_1.STORE_LINKS];
|
|
35
|
+
if (links3) {
|
|
36
|
+
delete records[file];
|
|
37
|
+
log_1.log.debug(colors_1.pc.cyan(`Deleting record file: ${file}`));
|
|
38
|
+
found = true;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (!found)
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function denominate(records, entrypoint, denominator, symLinks) {
|
|
50
|
+
const newRecords = {};
|
|
51
|
+
const makeSnap = (file) => {
|
|
52
|
+
let snap = (0, common_1.substituteDenominator)(file, denominator);
|
|
53
|
+
if (win32) {
|
|
54
|
+
if (snap.slice(1) === ':')
|
|
55
|
+
snap += '\\';
|
|
56
|
+
}
|
|
57
|
+
else if (snap === '') {
|
|
58
|
+
snap = '/';
|
|
59
|
+
}
|
|
60
|
+
return snap;
|
|
61
|
+
};
|
|
62
|
+
for (const file in records) {
|
|
63
|
+
if (records[file]) {
|
|
64
|
+
const snap = makeSnap(file);
|
|
65
|
+
newRecords[snap] = records[file];
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const tmpSymLinks = symLinks;
|
|
69
|
+
symLinks = {};
|
|
70
|
+
for (const [key, value] of Object.entries(tmpSymLinks)) {
|
|
71
|
+
const key1 = makeSnap(key);
|
|
72
|
+
const value1 = makeSnap(value);
|
|
73
|
+
symLinks[key1] = value1;
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
records: newRecords,
|
|
77
|
+
entrypoint: (0, common_1.substituteDenominator)(entrypoint, denominator),
|
|
78
|
+
symLinks,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function refiner(records, entrypoint, symLinks) {
|
|
82
|
+
purgeTopDirectories(records);
|
|
83
|
+
const denominator = (0, common_1.retrieveDenominator)(Object.keys(records));
|
|
84
|
+
return denominate(records, entrypoint, denominator, symLinks);
|
|
85
|
+
}
|
|
86
|
+
exports.default = refiner;
|
|
87
|
+
//# sourceMappingURL=refiner.js.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveModule = void 0;
|
|
7
|
+
const resolve_1 = require("resolve");
|
|
8
|
+
const resolve_exports_1 = require("resolve.exports");
|
|
9
|
+
const fs_1 = __importDefault(require("fs"));
|
|
10
|
+
const path_1 = __importDefault(require("path"));
|
|
11
|
+
const common_1 = require("./common");
|
|
12
|
+
const log_1 = require("./log");
|
|
13
|
+
/**
|
|
14
|
+
* Resolve using package.json "exports" field (ESM-style)
|
|
15
|
+
* @param packageName - Package name (e.g., 'nanoid')
|
|
16
|
+
* @param subpath - Subpath within package (e.g., './url-alphabet')
|
|
17
|
+
* @param packageRoot - Absolute path to package root
|
|
18
|
+
* @returns Resolved path or null if not found
|
|
19
|
+
*/
|
|
20
|
+
function resolveWithExports(packageName, subpath, packageRoot) {
|
|
21
|
+
try {
|
|
22
|
+
const packageJsonPath = path_1.default.join(packageRoot, 'package.json');
|
|
23
|
+
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
const pkg = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
27
|
+
// Check if package has exports field
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
+
const pkgAny = pkg;
|
|
30
|
+
if (!pkgAny.exports) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
// Use resolve.exports to handle the exports field
|
|
34
|
+
// For pkg's context, we're bundling CJS code, so try 'require' condition first
|
|
35
|
+
// Then fallback to 'import' for ESM-only packages
|
|
36
|
+
let resolved = (0, resolve_exports_1.exports)(pkgAny, subpath, {
|
|
37
|
+
require: true, // Try require first
|
|
38
|
+
});
|
|
39
|
+
// Fallback to import condition for ESM-only packages
|
|
40
|
+
if (!resolved) {
|
|
41
|
+
resolved = (0, resolve_exports_1.exports)(pkgAny, subpath, {
|
|
42
|
+
require: false, // This enables import condition
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (resolved) {
|
|
46
|
+
// resolved can be a string or array
|
|
47
|
+
const resolvedPath = Array.isArray(resolved) ? resolved[0] : resolved;
|
|
48
|
+
const fullPath = path_1.default.join(packageRoot, resolvedPath);
|
|
49
|
+
if (fs_1.default.existsSync(fullPath)) {
|
|
50
|
+
return fullPath;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
catch (_error) {
|
|
56
|
+
log_1.log.debug(`Failed to resolve with exports field: ${packageName}${subpath}`);
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Try to resolve a module specifier as an ESM package
|
|
62
|
+
* @param specifier - Module specifier (e.g., 'nanoid', 'nanoid/url-alphabet')
|
|
63
|
+
* @param basedir - Base directory for resolution
|
|
64
|
+
* @returns Resolved path or null
|
|
65
|
+
*/
|
|
66
|
+
function tryResolveESM(specifier, basedir) {
|
|
67
|
+
try {
|
|
68
|
+
// Parse package name and subpath
|
|
69
|
+
let packageName;
|
|
70
|
+
let subpath;
|
|
71
|
+
if (specifier.startsWith('@')) {
|
|
72
|
+
// Scoped package: @org/pkg or @org/pkg/subpath
|
|
73
|
+
const parts = specifier.split('/');
|
|
74
|
+
packageName = `${parts[0]}/${parts[1]}`;
|
|
75
|
+
subpath = parts.length > 2 ? `./${parts.slice(2).join('/')}` : '.';
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Regular package: pkg or pkg/subpath
|
|
79
|
+
const slashIndex = specifier.indexOf('/');
|
|
80
|
+
if (slashIndex === -1) {
|
|
81
|
+
packageName = specifier;
|
|
82
|
+
subpath = '.';
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
packageName = specifier.substring(0, slashIndex);
|
|
86
|
+
subpath = `./${specifier.substring(slashIndex + 1)}`;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Use resolveSync to find the package root (works with pnpm and other layouts)
|
|
90
|
+
// Try to resolve the package.json to get the package root
|
|
91
|
+
try {
|
|
92
|
+
const pkgJsonPath = (0, resolve_1.sync)(path_1.default.join(packageName, 'package.json'), {
|
|
93
|
+
basedir,
|
|
94
|
+
preserveSymlinks: false,
|
|
95
|
+
});
|
|
96
|
+
const packageRoot = path_1.default.dirname(pkgJsonPath);
|
|
97
|
+
// Try to resolve with exports field
|
|
98
|
+
const resolved = resolveWithExports(packageName, subpath, packageRoot);
|
|
99
|
+
if (resolved) {
|
|
100
|
+
return resolved;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// If package.json resolution fails, fall through to return null
|
|
105
|
+
}
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Resolve a module specifier with ESM support
|
|
114
|
+
* Falls back to standard CommonJS resolution if ESM resolution fails
|
|
115
|
+
*
|
|
116
|
+
* @param specifier - Module specifier to resolve
|
|
117
|
+
* @param options - Resolution options
|
|
118
|
+
* @returns Resolved file path and ESM flag
|
|
119
|
+
*/
|
|
120
|
+
function resolveModule(specifier, options) {
|
|
121
|
+
const { basedir, extensions = ['.js', '.json', '.node'] } = options;
|
|
122
|
+
// First, try ESM-style resolution with exports field
|
|
123
|
+
const esmResolved = tryResolveESM(specifier, basedir);
|
|
124
|
+
if (esmResolved) {
|
|
125
|
+
// Use isESMFile which walks up to find the correct package.json
|
|
126
|
+
return {
|
|
127
|
+
resolved: esmResolved,
|
|
128
|
+
isESM: (0, common_1.isESMFile)(esmResolved),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
// Fallback to standard CommonJS resolution
|
|
132
|
+
const resolved = (0, resolve_1.sync)(specifier, {
|
|
133
|
+
basedir,
|
|
134
|
+
extensions,
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
resolved,
|
|
138
|
+
isESM: false, // CJS resolution
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
exports.resolveModule = resolveModule;
|
|
142
|
+
//# sourceMappingURL=resolver.js.map
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hakobu Runtime Diagnostics
|
|
4
|
+
*
|
|
5
|
+
* Structured error types for addon and external artifact failures.
|
|
6
|
+
* These wrap low-level errors with actionable context so users know
|
|
7
|
+
* what Hakobu was doing and how to fix the problem.
|
|
8
|
+
*
|
|
9
|
+
* Error types:
|
|
10
|
+
* HakobuAddonError — native .node addon failures
|
|
11
|
+
* HakobuExternalError — external artifact lookup failures
|
|
12
|
+
*
|
|
13
|
+
* All errors include:
|
|
14
|
+
* - what Hakobu was trying to do (operation)
|
|
15
|
+
* - the relevant path/name
|
|
16
|
+
* - the original cause (if wrapping a lower-level error)
|
|
17
|
+
* - remediation guidance
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.externalNotDeclared = exports.externalNotFound = exports.HakobuExternalError = exports.addonLoadFailed = exports.addonExtractionFailed = exports.addonNotInSnapshot = exports.HakobuAddonError = exports.HakobuRuntimeError = void 0;
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
22
|
+
// Base error
|
|
23
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
24
|
+
class HakobuRuntimeError extends Error {
|
|
25
|
+
/** Machine-readable error code. */
|
|
26
|
+
code;
|
|
27
|
+
/** What Hakobu was trying to do. */
|
|
28
|
+
operation;
|
|
29
|
+
/** The original error, if this wraps one. */
|
|
30
|
+
cause;
|
|
31
|
+
/** Remediation guidance. */
|
|
32
|
+
remediation;
|
|
33
|
+
constructor(opts) {
|
|
34
|
+
const fullMessage = [
|
|
35
|
+
`[${opts.code}] ${opts.message}`,
|
|
36
|
+
``,
|
|
37
|
+
`Operation: ${opts.operation}`,
|
|
38
|
+
`Remediation: ${opts.remediation}`,
|
|
39
|
+
opts.cause ? `Cause: ${opts.cause.message}` : null,
|
|
40
|
+
].filter(Boolean).join('\n');
|
|
41
|
+
super(fullMessage);
|
|
42
|
+
this.name = 'HakobuRuntimeError';
|
|
43
|
+
this.code = opts.code;
|
|
44
|
+
this.operation = opts.operation;
|
|
45
|
+
this.cause = opts.cause;
|
|
46
|
+
this.remediation = opts.remediation;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.HakobuRuntimeError = HakobuRuntimeError;
|
|
50
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
51
|
+
// Addon errors
|
|
52
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
53
|
+
class HakobuAddonError extends HakobuRuntimeError {
|
|
54
|
+
/** The snapshot path of the addon. */
|
|
55
|
+
addonPath;
|
|
56
|
+
/** The extraction target path, if applicable. */
|
|
57
|
+
extractionPath;
|
|
58
|
+
constructor(opts) {
|
|
59
|
+
super(opts);
|
|
60
|
+
this.name = 'HakobuAddonError';
|
|
61
|
+
this.addonPath = opts.addonPath;
|
|
62
|
+
this.extractionPath = opts.extractionPath;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.HakobuAddonError = HakobuAddonError;
|
|
66
|
+
/**
|
|
67
|
+
* Create a diagnostic error for a missing addon in the snapshot.
|
|
68
|
+
*/
|
|
69
|
+
function addonNotInSnapshot(snapshotPath) {
|
|
70
|
+
return new HakobuAddonError({
|
|
71
|
+
code: 'HAKOBU_ADDON_NOT_FOUND',
|
|
72
|
+
operation: `Loading native addon from snapshot: ${snapshotPath}`,
|
|
73
|
+
message: `Native addon '${snapshotPath}' is not in the packaged snapshot.`,
|
|
74
|
+
addonPath: snapshotPath,
|
|
75
|
+
remediation: `Ensure the .node addon is included in the packaging manifest.\n` +
|
|
76
|
+
`If it's a build-time artifact, run 'npm rebuild' before packaging.\n` +
|
|
77
|
+
`If it should be excluded, add it to the externals list.`,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
exports.addonNotInSnapshot = addonNotInSnapshot;
|
|
81
|
+
/**
|
|
82
|
+
* Create a diagnostic error for extraction failure.
|
|
83
|
+
*/
|
|
84
|
+
function addonExtractionFailed(snapshotPath, extractionPath, cause) {
|
|
85
|
+
return new HakobuAddonError({
|
|
86
|
+
code: 'HAKOBU_ADDON_EXTRACT_FAILED',
|
|
87
|
+
operation: `Extracting addon to: ${extractionPath}`,
|
|
88
|
+
message: `Failed to extract native addon '${snapshotPath}' to disk.`,
|
|
89
|
+
addonPath: snapshotPath,
|
|
90
|
+
extractionPath,
|
|
91
|
+
cause,
|
|
92
|
+
remediation: `Check filesystem permissions for the extraction directory.\n` +
|
|
93
|
+
`Override the cache location with HAKOBU_ADDON_CACHE=/path/to/cache.\n` +
|
|
94
|
+
`Ensure there is enough disk space.`,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
exports.addonExtractionFailed = addonExtractionFailed;
|
|
98
|
+
/**
|
|
99
|
+
* Create a diagnostic error for dlopen/load failure (likely platform mismatch).
|
|
100
|
+
*/
|
|
101
|
+
function addonLoadFailed(snapshotPath, extractedPath, cause) {
|
|
102
|
+
const isPlatformMismatch = cause.message.includes('wrong ELF class') ||
|
|
103
|
+
cause.message.includes('not a valid Win32') ||
|
|
104
|
+
cause.message.includes('Mach-O') ||
|
|
105
|
+
cause.message.includes('invalid ELF header') ||
|
|
106
|
+
cause.message.includes('GLIBC');
|
|
107
|
+
const code = isPlatformMismatch
|
|
108
|
+
? 'HAKOBU_ADDON_PLATFORM_MISMATCH'
|
|
109
|
+
: 'HAKOBU_ADDON_LOAD_FAILED';
|
|
110
|
+
const remediation = isPlatformMismatch
|
|
111
|
+
? `This addon was compiled for a different platform or architecture.\n` +
|
|
112
|
+
`The packaged binary targets a specific platform — ensure the addon\n` +
|
|
113
|
+
`was built for the same OS and architecture.\n` +
|
|
114
|
+
`Run 'npm rebuild' on the target platform before packaging.`
|
|
115
|
+
: `The addon was extracted successfully but failed to load.\n` +
|
|
116
|
+
`Check that all shared library dependencies are available.\n` +
|
|
117
|
+
`On Linux, use 'ldd ${extractedPath}' to check dependencies.`;
|
|
118
|
+
return new HakobuAddonError({
|
|
119
|
+
code,
|
|
120
|
+
operation: `Loading extracted addon: ${extractedPath}`,
|
|
121
|
+
message: `Failed to load native addon '${snapshotPath}'.`,
|
|
122
|
+
addonPath: snapshotPath,
|
|
123
|
+
extractionPath: extractedPath,
|
|
124
|
+
cause,
|
|
125
|
+
remediation,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
exports.addonLoadFailed = addonLoadFailed;
|
|
129
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
130
|
+
// External artifact errors
|
|
131
|
+
// ─────────────────────────────────────────────────────────────────────
|
|
132
|
+
class HakobuExternalError extends HakobuRuntimeError {
|
|
133
|
+
/** The declared artifact name. */
|
|
134
|
+
artifactName;
|
|
135
|
+
constructor(opts) {
|
|
136
|
+
super(opts);
|
|
137
|
+
this.name = 'HakobuExternalError';
|
|
138
|
+
this.artifactName = opts.artifactName;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.HakobuExternalError = HakobuExternalError;
|
|
142
|
+
/**
|
|
143
|
+
* Create a diagnostic error for a missing required external artifact.
|
|
144
|
+
*/
|
|
145
|
+
function externalNotFound(name, searchedPaths) {
|
|
146
|
+
return new HakobuExternalError({
|
|
147
|
+
code: 'HAKOBU_EXTERNAL_NOT_FOUND',
|
|
148
|
+
operation: `Locating required external artifact: ${name}`,
|
|
149
|
+
message: `Required external artifact '${name}' was not found.`,
|
|
150
|
+
artifactName: name,
|
|
151
|
+
remediation: `Searched locations:\n` +
|
|
152
|
+
searchedPaths.map(p => ` - ${p}`).join('\n') + '\n\n' +
|
|
153
|
+
`Set HAKOBU_EXTERNAL_${name.toUpperCase().replace(/[^A-Z0-9]/g, '_')} ` +
|
|
154
|
+
`to the artifact path, or place it at one of the search locations.`,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
exports.externalNotFound = externalNotFound;
|
|
158
|
+
/**
|
|
159
|
+
* Create a diagnostic error for an undeclared external artifact.
|
|
160
|
+
*/
|
|
161
|
+
function externalNotDeclared(name, declared) {
|
|
162
|
+
return new HakobuExternalError({
|
|
163
|
+
code: 'HAKOBU_EXTERNAL_NOT_DECLARED',
|
|
164
|
+
operation: `Looking up external artifact: ${name}`,
|
|
165
|
+
message: `External artifact '${name}' is not declared in the packaging manifest.`,
|
|
166
|
+
artifactName: name,
|
|
167
|
+
remediation: `Declared externals: ${declared.length ? declared.join(', ') : '(none)'}\n` +
|
|
168
|
+
`Add '${name}' to the externals list in your Hakobu config.`,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
exports.externalNotDeclared = externalNotDeclared;
|
|
172
|
+
//# sourceMappingURL=runtime-diagnostics.js.map
|