koishipro-core.js 1.0.8 → 1.0.9
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/dist/index.cjs +22 -32
- package/dist/index.cjs.map +3 -3
- package/dist/index.mjs +24 -41
- package/dist/index.mjs.map +4 -4
- package/dist/src/utility/load-node-module.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1256,50 +1256,40 @@ function normalizeOcgcoreFactory(mod) {
|
|
|
1256
1256
|
throw new Error("Invalid ocgcore factory module");
|
|
1257
1257
|
}
|
|
1258
1258
|
|
|
1259
|
-
// src/utility/node-
|
|
1260
|
-
function
|
|
1261
|
-
const req =
|
|
1259
|
+
// src/utility/load-node-module.ts
|
|
1260
|
+
function loadNodeModule(id, altId) {
|
|
1261
|
+
const req = new Function(
|
|
1262
|
+
'return typeof require !== "undefined" ? require : undefined'
|
|
1263
|
+
)();
|
|
1262
1264
|
if (!req) {
|
|
1263
|
-
|
|
1264
|
-
return null;
|
|
1265
|
-
}
|
|
1266
|
-
throw new Error("Node.js fs module is not available.");
|
|
1265
|
+
return null;
|
|
1267
1266
|
}
|
|
1268
1267
|
try {
|
|
1269
|
-
return req(
|
|
1268
|
+
return req(id);
|
|
1270
1269
|
} catch {
|
|
1270
|
+
if (!altId) return null;
|
|
1271
1271
|
try {
|
|
1272
|
-
return req(
|
|
1272
|
+
return req(altId);
|
|
1273
1273
|
} catch {
|
|
1274
|
-
|
|
1275
|
-
return null;
|
|
1276
|
-
}
|
|
1277
|
-
throw new Error("Node.js fs module is not available.");
|
|
1274
|
+
return null;
|
|
1278
1275
|
}
|
|
1279
1276
|
}
|
|
1280
1277
|
}
|
|
1281
1278
|
|
|
1279
|
+
// src/utility/node-fs.ts
|
|
1280
|
+
function getNodeFs(noThrow = false) {
|
|
1281
|
+
const mod = loadNodeModule("node:fs", "fs");
|
|
1282
|
+
if (mod) return mod;
|
|
1283
|
+
if (noThrow) return null;
|
|
1284
|
+
throw new Error("Node.js fs module is not available.");
|
|
1285
|
+
}
|
|
1286
|
+
|
|
1282
1287
|
// src/utility/node-path.ts
|
|
1283
1288
|
function getNodePath(noThrow = false) {
|
|
1284
|
-
const
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
}
|
|
1289
|
-
throw new Error("Node.js path module is not available.");
|
|
1290
|
-
}
|
|
1291
|
-
try {
|
|
1292
|
-
return req("node:path");
|
|
1293
|
-
} catch {
|
|
1294
|
-
try {
|
|
1295
|
-
return req("path");
|
|
1296
|
-
} catch {
|
|
1297
|
-
if (noThrow) {
|
|
1298
|
-
return null;
|
|
1299
|
-
}
|
|
1300
|
-
throw new Error("Node.js path module is not available.");
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1289
|
+
const mod = loadNodeModule("node:path", "path");
|
|
1290
|
+
if (mod) return mod;
|
|
1291
|
+
if (noThrow) return null;
|
|
1292
|
+
throw new Error("Node.js path module is not available.");
|
|
1303
1293
|
}
|
|
1304
1294
|
|
|
1305
1295
|
// src/load-ocgcore-factory.cjs.ts
|