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.mjs
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
1
|
// index.ts
|
|
9
|
-
import { Buffer
|
|
2
|
+
import { Buffer } from "buffer";
|
|
10
3
|
|
|
11
4
|
// src/vendor/ocgcore-constants.ts
|
|
12
5
|
var OcgcoreCommonConstants = {
|
|
@@ -1231,50 +1224,40 @@ async function createOcgcoreWrapper(options = {}) {
|
|
|
1231
1224
|
// src/adapters/script-readers.ts
|
|
1232
1225
|
import JSZip from "jszip";
|
|
1233
1226
|
|
|
1234
|
-
// src/utility/node-
|
|
1235
|
-
function
|
|
1236
|
-
const req =
|
|
1227
|
+
// src/utility/load-node-module.ts
|
|
1228
|
+
function loadNodeModule(id, altId) {
|
|
1229
|
+
const req = new Function(
|
|
1230
|
+
'return typeof require !== "undefined" ? require : undefined'
|
|
1231
|
+
)();
|
|
1237
1232
|
if (!req) {
|
|
1238
|
-
|
|
1239
|
-
return null;
|
|
1240
|
-
}
|
|
1241
|
-
throw new Error("Node.js fs module is not available.");
|
|
1233
|
+
return null;
|
|
1242
1234
|
}
|
|
1243
1235
|
try {
|
|
1244
|
-
return req(
|
|
1236
|
+
return req(id);
|
|
1245
1237
|
} catch {
|
|
1238
|
+
if (!altId) return null;
|
|
1246
1239
|
try {
|
|
1247
|
-
return req(
|
|
1240
|
+
return req(altId);
|
|
1248
1241
|
} catch {
|
|
1249
|
-
|
|
1250
|
-
return null;
|
|
1251
|
-
}
|
|
1252
|
-
throw new Error("Node.js fs module is not available.");
|
|
1242
|
+
return null;
|
|
1253
1243
|
}
|
|
1254
1244
|
}
|
|
1255
1245
|
}
|
|
1256
1246
|
|
|
1247
|
+
// src/utility/node-fs.ts
|
|
1248
|
+
function getNodeFs(noThrow = false) {
|
|
1249
|
+
const mod = loadNodeModule("node:fs", "fs");
|
|
1250
|
+
if (mod) return mod;
|
|
1251
|
+
if (noThrow) return null;
|
|
1252
|
+
throw new Error("Node.js fs module is not available.");
|
|
1253
|
+
}
|
|
1254
|
+
|
|
1257
1255
|
// src/utility/node-path.ts
|
|
1258
1256
|
function getNodePath(noThrow = false) {
|
|
1259
|
-
const
|
|
1260
|
-
if (
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
}
|
|
1264
|
-
throw new Error("Node.js path module is not available.");
|
|
1265
|
-
}
|
|
1266
|
-
try {
|
|
1267
|
-
return req("node:path");
|
|
1268
|
-
} catch {
|
|
1269
|
-
try {
|
|
1270
|
-
return req("path");
|
|
1271
|
-
} catch {
|
|
1272
|
-
if (noThrow) {
|
|
1273
|
-
return null;
|
|
1274
|
-
}
|
|
1275
|
-
throw new Error("Node.js path module is not available.");
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1257
|
+
const mod = loadNodeModule("node:path", "path");
|
|
1258
|
+
if (mod) return mod;
|
|
1259
|
+
if (noThrow) return null;
|
|
1260
|
+
throw new Error("Node.js path module is not available.");
|
|
1278
1261
|
}
|
|
1279
1262
|
|
|
1280
1263
|
// src/adapters/script-readers.ts
|
|
@@ -2502,7 +2485,7 @@ function testCard(ocgcoreWrapper, ...ids) {
|
|
|
2502
2485
|
|
|
2503
2486
|
// index.ts
|
|
2504
2487
|
if (typeof globalThis !== "undefined" && !globalThis.Buffer) {
|
|
2505
|
-
globalThis.Buffer =
|
|
2488
|
+
globalThis.Buffer = Buffer;
|
|
2506
2489
|
}
|
|
2507
2490
|
export {
|
|
2508
2491
|
CardDataStruct,
|