idmission-web-sdk 2.3.92 → 2.3.94
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/components/submission/SubmissionProvider.d.ts +3 -2
- package/dist/components/submission/SubmissionProvider.d.ts.map +1 -1
- package/dist/components/submission/types.d.ts +2 -2
- package/dist/components/submission/types.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts +2 -2
- package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +18 -3
- package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
- package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts +4 -3
- package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
- package/dist/lib/camera/useVideoRecorder.d.ts +1 -0
- package/dist/lib/camera/useVideoRecorder.d.ts.map +1 -1
- package/dist/sdk2.cjs.development.js +575 -386
- package/dist/sdk2.cjs.development.js.map +1 -1
- package/dist/sdk2.cjs.production.js +1 -1
- package/dist/sdk2.cjs.production.js.map +1 -1
- package/dist/sdk2.esm.js +574 -386
- package/dist/sdk2.esm.js.map +1 -1
- package/dist/sdk2.umd.development.js +3299 -412
- package/dist/sdk2.umd.development.js.map +1 -1
- package/dist/sdk2.umd.production.js +1 -1
- package/dist/sdk2.umd.production.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +4 -3
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Sdk2 = {}, global.React, global.ReactDOM, global.platform, global.styled, global.ReactDOM, global.tusJsClient, global.PropTypes, global.server));
|
|
5
5
|
})(this, (function (exports, React, ReactDOM, platform, styled, reactDom, tusJsClient, require$$0, server) { 'use strict';
|
|
6
6
|
|
|
7
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
8
|
function _interopNamespaceDefault(e) {
|
|
8
9
|
var n = Object.create(null);
|
|
9
10
|
if (e) {
|
|
@@ -211,7 +212,7 @@
|
|
|
211
212
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
212
213
|
};
|
|
213
214
|
|
|
214
|
-
var webSdkVersion = '2.3.
|
|
215
|
+
var webSdkVersion = '2.3.94';
|
|
215
216
|
|
|
216
217
|
function getPlatform() {
|
|
217
218
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
@@ -2133,10 +2134,7 @@
|
|
|
2133
2134
|
setIdCaptureVideoUrl: function setIdCaptureVideoUrl() {
|
|
2134
2135
|
return null;
|
|
2135
2136
|
},
|
|
2136
|
-
|
|
2137
|
-
return null;
|
|
2138
|
-
},
|
|
2139
|
-
setSignatureEndTimestamp: function setSignatureEndTimestamp() {
|
|
2137
|
+
setSignatureVideoMetadata: function setSignatureVideoMetadata() {
|
|
2140
2138
|
return null;
|
|
2141
2139
|
},
|
|
2142
2140
|
setIdCaptureVideoIdFrontImage: function setIdCaptureVideoIdFrontImage() {
|
|
@@ -2306,50 +2304,47 @@
|
|
|
2306
2304
|
signatureVideoUrl = _17[0],
|
|
2307
2305
|
setSignatureVideoUrl = _17[1];
|
|
2308
2306
|
var _18 = React.useState(null),
|
|
2309
|
-
|
|
2310
|
-
|
|
2307
|
+
signatureVideoMetadata = _18[0],
|
|
2308
|
+
setSignatureVideoMetadata = _18[1];
|
|
2311
2309
|
var _19 = React.useState(null),
|
|
2312
|
-
|
|
2313
|
-
|
|
2310
|
+
idCaptureVideoUrl = _19[0],
|
|
2311
|
+
setIdCaptureVideoUrl = _19[1];
|
|
2314
2312
|
var _20 = React.useState(null),
|
|
2315
|
-
|
|
2316
|
-
|
|
2313
|
+
idCaptureVideoIdFrontImage = _20[0],
|
|
2314
|
+
setIdCaptureVideoIdFrontImage = _20[1];
|
|
2317
2315
|
var _21 = React.useState(null),
|
|
2318
|
-
|
|
2319
|
-
|
|
2316
|
+
idCaptureVideoIdBackImage = _21[0],
|
|
2317
|
+
setIdCaptureVideoIdBackImage = _21[1];
|
|
2320
2318
|
var _22 = React.useState(null),
|
|
2321
|
-
|
|
2322
|
-
|
|
2319
|
+
idCaptureVideoAudioUrl = _22[0],
|
|
2320
|
+
setIdCaptureVideoAudioUrl = _22[1];
|
|
2323
2321
|
var _23 = React.useState(null),
|
|
2324
|
-
|
|
2325
|
-
|
|
2322
|
+
idCaptureVideoAudioStartsAt = _23[0],
|
|
2323
|
+
setIdCaptureVideoAudioStartsAt = _23[1];
|
|
2326
2324
|
var _24 = React.useState(null),
|
|
2327
|
-
|
|
2328
|
-
|
|
2325
|
+
expectedAudioText = _24[0],
|
|
2326
|
+
setExpectedAudioText = _24[1];
|
|
2329
2327
|
var _25 = React.useState(null),
|
|
2330
|
-
|
|
2331
|
-
|
|
2328
|
+
additionalDocuments = _25[0],
|
|
2329
|
+
setAdditionalDocuments = _25[1];
|
|
2332
2330
|
var _26 = React.useState(null),
|
|
2333
|
-
|
|
2334
|
-
|
|
2335
|
-
var _27 = React.useState(
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
var _28 = React.useState(
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
var _29 = React.useState(
|
|
2342
|
-
|
|
2343
|
-
|
|
2331
|
+
geolocationResult = _26[0],
|
|
2332
|
+
setGeolocationResult = _26[1];
|
|
2333
|
+
var _27 = React.useState(0),
|
|
2334
|
+
geolocationAttempts = _27[0],
|
|
2335
|
+
setGeolocationAttempts = _27[1];
|
|
2336
|
+
var _28 = React.useState(false),
|
|
2337
|
+
geolocationBlocked = _28[0],
|
|
2338
|
+
setGeolocationBlocked = _28[1];
|
|
2339
|
+
var _29 = React.useState([]),
|
|
2340
|
+
idFrontCaptureAttempts = _29[0],
|
|
2341
|
+
setIdFrontCaptureAttempts = _29[1];
|
|
2344
2342
|
var _30 = React.useState([]),
|
|
2345
|
-
|
|
2346
|
-
|
|
2343
|
+
idBackCaptureAttempts = _30[0],
|
|
2344
|
+
setIdBackCaptureAttempts = _30[1];
|
|
2347
2345
|
var _31 = React.useState([]),
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
var _32 = React.useState([]),
|
|
2351
|
-
selfieCaptureAttempts = _32[0],
|
|
2352
|
-
setSelfieCaptureAttempts = _32[1];
|
|
2346
|
+
selfieCaptureAttempts = _31[0],
|
|
2347
|
+
setSelfieCaptureAttempts = _31[1];
|
|
2353
2348
|
var logIdFrontCaptureAttempt = React.useCallback(function (attempt) {
|
|
2354
2349
|
setIdFrontCaptureAttempts(function (attempts) {
|
|
2355
2350
|
return __spreadArray(__spreadArray([], attempts, true), [attempt], false);
|
|
@@ -2446,19 +2441,22 @@
|
|
|
2446
2441
|
var buildSubmissionPayload = React.useCallback(function () {
|
|
2447
2442
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
2448
2443
|
function uploadIfPossible(src_1, filename_1) {
|
|
2449
|
-
return __awaiter(this, arguments, void 0, function (src, filename, filetype) {
|
|
2444
|
+
return __awaiter(this, arguments, void 0, function (src, filename, filetype, metadata) {
|
|
2450
2445
|
if (filetype === void 0) {
|
|
2451
2446
|
filetype = 'image/jpeg';
|
|
2452
2447
|
}
|
|
2448
|
+
if (metadata === void 0) {
|
|
2449
|
+
metadata = {};
|
|
2450
|
+
}
|
|
2453
2451
|
return __generator(this, function (_a) {
|
|
2454
2452
|
switch (_a.label) {
|
|
2455
2453
|
case 0:
|
|
2456
2454
|
if (!documentServiceUrl) return [2 /*return*/, src];
|
|
2457
2455
|
if (!src.startsWith('data:')) src = "data:".concat(filetype, ";base64,").concat(src);
|
|
2458
|
-
return [4 /*yield*/, uploadDocument(src, {
|
|
2456
|
+
return [4 /*yield*/, uploadDocument(src, _assign({
|
|
2459
2457
|
filename: filename,
|
|
2460
2458
|
filetype: filetype
|
|
2461
|
-
})];
|
|
2459
|
+
}, metadata))];
|
|
2462
2460
|
case 1:
|
|
2463
2461
|
return [2 /*return*/, _a.sent()];
|
|
2464
2462
|
}
|
|
@@ -2467,9 +2465,9 @@
|
|
|
2467
2465
|
}
|
|
2468
2466
|
var documents, _a, _b, _c, submissionRequest, onBeforeSubmitResult;
|
|
2469
2467
|
var _d;
|
|
2470
|
-
var _e, _f, _g, _h;
|
|
2471
|
-
return __generator(this, function (
|
|
2472
|
-
switch (
|
|
2468
|
+
var _e, _f, _g, _h, _j;
|
|
2469
|
+
return __generator(this, function (_k) {
|
|
2470
|
+
switch (_k.label) {
|
|
2473
2471
|
case 0:
|
|
2474
2472
|
_d = {
|
|
2475
2473
|
idFrontImage: idFrontImage,
|
|
@@ -2482,24 +2480,24 @@
|
|
|
2482
2480
|
if (!_a) return [3 /*break*/, 2];
|
|
2483
2481
|
return [4 /*yield*/, videoDataUrlToB64(signatureVideoUrl)];
|
|
2484
2482
|
case 1:
|
|
2485
|
-
_a =
|
|
2486
|
-
|
|
2483
|
+
_a = _k.sent();
|
|
2484
|
+
_k.label = 2;
|
|
2487
2485
|
case 2:
|
|
2488
2486
|
_d.signatureVideo = _a;
|
|
2489
2487
|
_b = idCaptureVideoUrl;
|
|
2490
2488
|
if (!_b) return [3 /*break*/, 4];
|
|
2491
2489
|
return [4 /*yield*/, videoDataUrlToB64(idCaptureVideoUrl)];
|
|
2492
2490
|
case 3:
|
|
2493
|
-
_b =
|
|
2494
|
-
|
|
2491
|
+
_b = _k.sent();
|
|
2492
|
+
_k.label = 4;
|
|
2495
2493
|
case 4:
|
|
2496
2494
|
_d.idCaptureVideo = _b;
|
|
2497
2495
|
_c = idCaptureVideoAudioUrl;
|
|
2498
2496
|
if (!_c) return [3 /*break*/, 6];
|
|
2499
2497
|
return [4 /*yield*/, videoDataUrlToB64(idCaptureVideoAudioUrl)];
|
|
2500
2498
|
case 5:
|
|
2501
|
-
_c =
|
|
2502
|
-
|
|
2499
|
+
_c = _k.sent();
|
|
2500
|
+
_k.label = 6;
|
|
2503
2501
|
case 6:
|
|
2504
2502
|
documents = (_d.idCaptureVideoAudio = _c, _d.idCaptureVideoIdFrontImage = idCaptureVideoIdFrontImage, _d.idCaptureVideoIdBackImage = idCaptureVideoIdBackImage, _d.idFrontIrImage = idFrontIrImage, _d.idBackIrImage = idBackIrImage, _d.idFrontUvImage = idFrontUvImage, _d.idBackUvImage = idBackUvImage, _d);
|
|
2505
2503
|
if (signatureData) {
|
|
@@ -2508,15 +2506,18 @@
|
|
|
2508
2506
|
if (!documentServiceUrl) return [3 /*break*/, 8];
|
|
2509
2507
|
return [4 /*yield*/, Promise.all(Object.keys(documents).map(function (k) {
|
|
2510
2508
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
2511
|
-
var filetype, _a, _b;
|
|
2509
|
+
var filetype, metadata, _a, _b;
|
|
2512
2510
|
return __generator(this, function (_c) {
|
|
2513
2511
|
switch (_c.label) {
|
|
2514
2512
|
case 0:
|
|
2515
2513
|
if (!documents[k]) return [3 /*break*/, 2];
|
|
2516
2514
|
filetype = k.endsWith('Video') ? 'video/mp4' : k.endsWith('Audio') ? 'audio/mp4' : 'image/jpeg';
|
|
2515
|
+
metadata = k === 'signatureVideo' ? {
|
|
2516
|
+
filemetadata: JSON.stringify(signatureVideoMetadata)
|
|
2517
|
+
} : {};
|
|
2517
2518
|
_a = documents;
|
|
2518
2519
|
_b = k;
|
|
2519
|
-
return [4 /*yield*/, uploadIfPossible(documents[k], k, filetype)];
|
|
2520
|
+
return [4 /*yield*/, uploadIfPossible(documents[k], k, filetype, metadata)];
|
|
2520
2521
|
case 1:
|
|
2521
2522
|
_a[_b] = _c.sent();
|
|
2522
2523
|
_c.label = 2;
|
|
@@ -2529,8 +2530,8 @@
|
|
|
2529
2530
|
throw new NetworkError(e.message);
|
|
2530
2531
|
})];
|
|
2531
2532
|
case 7:
|
|
2532
|
-
|
|
2533
|
-
|
|
2533
|
+
_k.sent();
|
|
2534
|
+
_k.label = 8;
|
|
2534
2535
|
case 8:
|
|
2535
2536
|
submissionRequest = {
|
|
2536
2537
|
securityData: {
|
|
@@ -2630,11 +2631,9 @@
|
|
|
2630
2631
|
submissionRequest.customerData.signatureData.signatureVideo = documents.signatureVideo;
|
|
2631
2632
|
}
|
|
2632
2633
|
}
|
|
2633
|
-
if (
|
|
2634
|
-
submissionRequest.customerData.
|
|
2635
|
-
|
|
2636
|
-
if (signatureEndTimestamp) {
|
|
2637
|
-
submissionRequest.customerData.signatureEndTimestamp = signatureEndTimestamp;
|
|
2634
|
+
if (signatureVideoMetadata) {
|
|
2635
|
+
(_g = submissionRequest.customerData).signatureData || (_g.signatureData = {});
|
|
2636
|
+
submissionRequest.customerData.signatureData.signatureVideoMetadata = signatureVideoMetadata;
|
|
2638
2637
|
}
|
|
2639
2638
|
if (additionalDocuments) {
|
|
2640
2639
|
submissionRequest.customerData.additionalDocuments = additionalDocuments.map(function (d) {
|
|
@@ -2646,11 +2645,11 @@
|
|
|
2646
2645
|
});
|
|
2647
2646
|
}
|
|
2648
2647
|
if (documents.idCaptureVideo) {
|
|
2649
|
-
(
|
|
2648
|
+
(_h = submissionRequest.customerData).biometricData || (_h.biometricData = {});
|
|
2650
2649
|
submissionRequest.customerData.biometricData.videoData = documents.idCaptureVideo;
|
|
2651
2650
|
}
|
|
2652
2651
|
if (documents.idCaptureVideoAudio) {
|
|
2653
|
-
(
|
|
2652
|
+
(_j = submissionRequest.customerData).biometricData || (_j.biometricData = {});
|
|
2654
2653
|
submissionRequest.customerData.biometricData.voiceData = documents.idCaptureVideoAudio;
|
|
2655
2654
|
submissionRequest.customerData.biometricData.voiceStartTime = idCaptureVideoAudioStartsAt !== null && idCaptureVideoAudioStartsAt !== void 0 ? idCaptureVideoAudioStartsAt : undefined;
|
|
2656
2655
|
submissionRequest.customerData.biometricData.expectedAudioText = expectedAudioText !== null && expectedAudioText !== void 0 ? expectedAudioText : undefined;
|
|
@@ -2670,15 +2669,15 @@
|
|
|
2670
2669
|
if (!onBeforeSubmit.current) return [3 /*break*/, 10];
|
|
2671
2670
|
return [4 /*yield*/, onBeforeSubmit.current(submissionRequest)];
|
|
2672
2671
|
case 9:
|
|
2673
|
-
onBeforeSubmitResult =
|
|
2672
|
+
onBeforeSubmitResult = _k.sent();
|
|
2674
2673
|
if (onBeforeSubmitResult) submissionRequest = onBeforeSubmitResult;
|
|
2675
|
-
|
|
2674
|
+
_k.label = 10;
|
|
2676
2675
|
case 10:
|
|
2677
2676
|
return [2 /*return*/, submissionRequest];
|
|
2678
2677
|
}
|
|
2679
2678
|
});
|
|
2680
2679
|
});
|
|
2681
|
-
}, [additionalDocuments, bypassAgeValidation, bypassNameMatching, cardData, clientRequestID, companyId, customerDataMatchConfig, deduplicationEnabled, deduplicationSynchronous, documentServiceUrl, enrollmentId, expectedAudioText, geolocationResult, idBackCaptureAttempts, idBackImage, idBackImageRequired, idBackIrImage, idBackUvImage, idBarcodeImage, idCaptureVideoAudioStartsAt, idCaptureVideoAudioUrl, idCaptureVideoIdBackImage, idCaptureVideoIdFrontImage, idCaptureVideoUrl, idCardForFaceMatch, idData, idFrontCaptureAttempts, idFrontImage, idFrontIrImage, idFrontUvImage, idImageResolutionCheck, jobId, manualReviewRequired, needImmediateResponse, passportImage, personalData, selfieCaptureAttempts, selfieImage, signatureData,
|
|
2680
|
+
}, [additionalDocuments, bypassAgeValidation, bypassNameMatching, cardData, clientRequestID, companyId, customerDataMatchConfig, deduplicationEnabled, deduplicationSynchronous, documentServiceUrl, enrollmentId, expectedAudioText, geolocationResult, idBackCaptureAttempts, idBackImage, idBackImageRequired, idBackIrImage, idBackUvImage, idBarcodeImage, idCaptureVideoAudioStartsAt, idCaptureVideoAudioUrl, idCaptureVideoIdBackImage, idCaptureVideoIdFrontImage, idCaptureVideoUrl, idCardForFaceMatch, idData, idFrontCaptureAttempts, idFrontImage, idFrontIrImage, idFrontUvImage, idImageResolutionCheck, jobId, manualReviewRequired, needImmediateResponse, passportImage, personalData, selfieCaptureAttempts, selfieImage, signatureData, signatureVideoUrl, signatureVideoMetadata, uploadDocument, verifyIdWithExternalDatabases, webhooksClientTraceId, webhooksEnabled, webhooksFireOnReview, webhooksFireOnReviewURL, webhooksSendInputImages, webhooksSendProcessedImages, webhooksStripSpecialCharacters, webhooksURL]);
|
|
2682
2681
|
var defaultOnSubmit = React.useCallback(function () {
|
|
2683
2682
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
2684
2683
|
var submissionResponse_1, payload, host, endpoint, response, statusMessage, submissionResponse_2, e_1, err;
|
|
@@ -2977,8 +2976,7 @@
|
|
|
2977
2976
|
setSelfieImage: setSelfieImage,
|
|
2978
2977
|
setSignatureData: setSignatureData,
|
|
2979
2978
|
setSignatureVideoUrl: setSignatureVideoUrl,
|
|
2980
|
-
|
|
2981
|
-
setSignatureEndTimestamp: setSignatureEndTimestamp,
|
|
2979
|
+
setSignatureVideoMetadata: setSignatureVideoMetadata,
|
|
2982
2980
|
setIdCaptureVideoUrl: setIdCaptureVideoUrl,
|
|
2983
2981
|
setIdCaptureVideoIdFrontImage: setIdCaptureVideoIdFrontImage,
|
|
2984
2982
|
setIdCaptureVideoIdBackImage: setIdCaptureVideoIdBackImage,
|
|
@@ -3618,9 +3616,9 @@
|
|
|
3618
3616
|
}
|
|
3619
3617
|
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
3620
3618
|
|
|
3621
|
-
function _createForOfIteratorHelperLoose$
|
|
3622
|
-
function _unsupportedIterableToArray$
|
|
3623
|
-
function _arrayLikeToArray$
|
|
3619
|
+
function _createForOfIteratorHelperLoose$3(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$3(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3620
|
+
function _unsupportedIterableToArray$3(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$3(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$3(r, a) : void 0; } }
|
|
3621
|
+
function _arrayLikeToArray$3(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
3624
3622
|
var t = self;
|
|
3625
3623
|
function e() {
|
|
3626
3624
|
throw Error("Invalid UTF8");
|
|
@@ -5847,7 +5845,7 @@
|
|
|
5847
5845
|
height: (_hn4 = hn(e, 4)) != null ? _hn4 : 0,
|
|
5848
5846
|
angle: 0
|
|
5849
5847
|
}), (_en2 = en$1(t, ws, 4)) != null && _en2.g().length) {
|
|
5850
|
-
for (var _iterator = _createForOfIteratorHelperLoose$
|
|
5848
|
+
for (var _iterator = _createForOfIteratorHelperLoose$3(en$1(t, ws, 4).g()), _step; !(_step = _iterator()).done;) {
|
|
5851
5849
|
var _We, _We2, _We3, _un3;
|
|
5852
5850
|
var _e16 = _step.value;
|
|
5853
5851
|
i.keypoints.push({
|
|
@@ -5862,7 +5860,7 @@
|
|
|
5862
5860
|
}
|
|
5863
5861
|
function Qi(t) {
|
|
5864
5862
|
var e = [];
|
|
5865
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose$
|
|
5863
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose$3(rn(t, Fs, 1)), _step2; !(_step2 = _iterator2()).done;) {
|
|
5866
5864
|
var _fn2, _fn3, _fn4;
|
|
5867
5865
|
var _n14 = _step2.value;
|
|
5868
5866
|
e.push({
|
|
@@ -5875,7 +5873,7 @@
|
|
|
5875
5873
|
}
|
|
5876
5874
|
function to(t) {
|
|
5877
5875
|
var e = [];
|
|
5878
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose$
|
|
5876
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose$3(rn(t, Ts, 1)), _step3; !(_step3 = _iterator3()).done;) {
|
|
5879
5877
|
var _fn5, _fn6, _fn7;
|
|
5880
5878
|
var _n15 = _step3.value;
|
|
5881
5879
|
e.push({
|
|
@@ -6023,7 +6021,7 @@
|
|
|
6023
6021
|
var r = new Uint32Array(e.length);
|
|
6024
6022
|
for (var _n16 = 0; _n16 < e.length; _n16++) r[_n16] = t.i.stringToNewUTF8(e[_n16]);
|
|
6025
6023
|
e = t.i._malloc(4 * r.length), t.i.HEAPU32.set(r, e >> 2), n(e);
|
|
6026
|
-
for (var _iterator4 = _createForOfIteratorHelperLoose$
|
|
6024
|
+
for (var _iterator4 = _createForOfIteratorHelperLoose$3(r), _step4; !(_step4 = _iterator4()).done;) {
|
|
6027
6025
|
var _e17 = _step4.value;
|
|
6028
6026
|
t.i._free(_e17);
|
|
6029
6027
|
}
|
|
@@ -6389,7 +6387,7 @@
|
|
|
6389
6387
|
}
|
|
6390
6388
|
t.push(n);
|
|
6391
6389
|
};
|
|
6392
|
-
for (var _iterator7 = _createForOfIteratorHelperLoose$
|
|
6390
|
+
for (var _iterator7 = _createForOfIteratorHelperLoose$3(this.g), _step7; !(_step7 = _iterator7()).done;) {
|
|
6393
6391
|
_loop();
|
|
6394
6392
|
}
|
|
6395
6393
|
return new _Yo(t, this.ba(), this.K(), this.canvas, this.l, this.width, this.height);
|
|
@@ -6521,7 +6519,7 @@
|
|
|
6521
6519
|
}
|
|
6522
6520
|
t.push(n);
|
|
6523
6521
|
};
|
|
6524
|
-
for (var _iterator8 = _createForOfIteratorHelperLoose$
|
|
6522
|
+
for (var _iterator8 = _createForOfIteratorHelperLoose$3(this.g), _step8; !(_step8 = _iterator8()).done;) {
|
|
6525
6523
|
_loop2();
|
|
6526
6524
|
}
|
|
6527
6525
|
return new _ia(t, this.K(), this.canvas, this.l, this.width, this.height);
|
|
@@ -7001,7 +6999,7 @@
|
|
|
7001
6999
|
yn(e, si, this.h);
|
|
7002
7000
|
var n = new qr();
|
|
7003
7001
|
Hr(n, "mediapipe.tasks.vision.face_detector.FaceDetectorGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect_in"), $r(n, "DETECTIONS:detections"), n.o(e), es$1(t, n), this.g.attachProtoVectorListener("detections", function (t, e) {
|
|
7004
|
-
for (var _iterator9 = _createForOfIteratorHelperLoose$
|
|
7002
|
+
for (var _iterator9 = _createForOfIteratorHelperLoose$3(t), _step9; !(_step9 = _iterator9()).done;) {
|
|
7005
7003
|
var _e23 = _step9.value;
|
|
7006
7004
|
t = Es(_e23), _this43.j.detections.push(Zi(t));
|
|
7007
7005
|
}
|
|
@@ -7095,7 +7093,7 @@
|
|
|
7095
7093
|
yn(e, di, this.h);
|
|
7096
7094
|
var n = new qr();
|
|
7097
7095
|
Hr(n, "mediapipe.tasks.vision.face_landmarker.FaceLandmarkerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "NORM_LANDMARKS:face_landmarks"), n.o(e), es$1(t, n), this.g.attachProtoVectorListener("face_landmarks", function (t, e) {
|
|
7098
|
-
for (var _iterator10 = _createForOfIteratorHelperLoose$
|
|
7096
|
+
for (var _iterator10 = _createForOfIteratorHelperLoose$3(t), _step10; !(_step10 = _iterator10()).done;) {
|
|
7099
7097
|
var _e24 = _step10.value;
|
|
7100
7098
|
t = Ms(_e24), _this45.j.faceLandmarks.push(Qi(t));
|
|
7101
7099
|
}
|
|
@@ -7104,7 +7102,7 @@
|
|
|
7104
7102
|
_o(_this45, t);
|
|
7105
7103
|
}), this.outputFaceBlendshapes && (rs(t, "blendshapes"), $r(n, "BLENDSHAPES:blendshapes"), this.g.attachProtoVectorListener("blendshapes", function (t, e) {
|
|
7106
7104
|
if (_this45.outputFaceBlendshapes) {
|
|
7107
|
-
for (var _iterator11 = _createForOfIteratorHelperLoose$
|
|
7105
|
+
for (var _iterator11 = _createForOfIteratorHelperLoose$3(t), _step11; !(_step11 = _iterator11()).done;) {
|
|
7108
7106
|
var _t$g;
|
|
7109
7107
|
var _e25 = _step11.value;
|
|
7110
7108
|
t = fs(_e25), _this45.j.faceBlendshapes.push(Ji((_t$g = t.g()) != null ? _t$g : []));
|
|
@@ -7115,7 +7113,7 @@
|
|
|
7115
7113
|
_o(_this45, t);
|
|
7116
7114
|
})), this.outputFacialTransformationMatrixes && (rs(t, "face_geometry"), $r(n, "FACE_GEOMETRY:face_geometry"), this.g.attachProtoVectorListener("face_geometry", function (t, e) {
|
|
7117
7115
|
if (_this45.outputFacialTransformationMatrixes) {
|
|
7118
|
-
for (var _iterator12 = _createForOfIteratorHelperLoose$
|
|
7116
|
+
for (var _iterator12 = _createForOfIteratorHelperLoose$3(t), _step12; !(_step12 = _iterator12()).done;) {
|
|
7119
7117
|
var _ln2, _ln3, _He;
|
|
7120
7118
|
var _e26 = _step12.value;
|
|
7121
7119
|
(t = en$1(ai(_e26), Ps, 2)) && _this45.j.facialTransformationMatrixes.push({
|
|
@@ -7246,11 +7244,11 @@
|
|
|
7246
7244
|
e = !0;
|
|
7247
7245
|
}
|
|
7248
7246
|
var n = [];
|
|
7249
|
-
for (var _iterator13 = _createForOfIteratorHelperLoose$
|
|
7247
|
+
for (var _iterator13 = _createForOfIteratorHelperLoose$3(t), _step13; !(_step13 = _iterator13()).done;) {
|
|
7250
7248
|
var _s9 = _step13.value;
|
|
7251
7249
|
var r = fs(_s9);
|
|
7252
7250
|
t = [];
|
|
7253
|
-
for (var _iterator14 = _createForOfIteratorHelperLoose$
|
|
7251
|
+
for (var _iterator14 = _createForOfIteratorHelperLoose$3(r.g()), _step14; !(_step14 = _iterator14()).done;) {
|
|
7254
7252
|
var _fn8, _ref9, _un4, _ref10, _un5;
|
|
7255
7253
|
var _n24 = _step14.value;
|
|
7256
7254
|
r = e && null != hn(_n24, 1) ? ln(hn(_n24, 1)) : -1, t.push({
|
|
@@ -7296,11 +7294,11 @@
|
|
|
7296
7294
|
yn(e, Oi, this.v);
|
|
7297
7295
|
var n = new qr();
|
|
7298
7296
|
Hr(n, "mediapipe.tasks.vision.gesture_recognizer.GestureRecognizerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "HAND_GESTURES:hand_gestures"), $r(n, "LANDMARKS:hand_landmarks"), $r(n, "WORLD_LANDMARKS:world_hand_landmarks"), $r(n, "HANDEDNESS:handedness"), n.o(e), es$1(t, n), this.g.attachProtoVectorListener("hand_landmarks", function (t, e) {
|
|
7299
|
-
for (var _iterator15 = _createForOfIteratorHelperLoose$
|
|
7297
|
+
for (var _iterator15 = _createForOfIteratorHelperLoose$3(t), _step15; !(_step15 = _iterator15()).done;) {
|
|
7300
7298
|
var _e28 = _step15.value;
|
|
7301
7299
|
t = Ms(_e28);
|
|
7302
7300
|
var _n25 = [];
|
|
7303
|
-
for (var _iterator16 = _createForOfIteratorHelperLoose$
|
|
7301
|
+
for (var _iterator16 = _createForOfIteratorHelperLoose$3(rn(t, Fs, 1)), _step16; !(_step16 = _iterator16()).done;) {
|
|
7304
7302
|
var _fn9, _fn10, _fn11;
|
|
7305
7303
|
var _e29 = _step16.value;
|
|
7306
7304
|
_n25.push({
|
|
@@ -7315,11 +7313,11 @@
|
|
|
7315
7313
|
}), this.g.attachEmptyPacketListener("hand_landmarks", function (t) {
|
|
7316
7314
|
_o(_this49, t);
|
|
7317
7315
|
}), this.g.attachProtoVectorListener("world_hand_landmarks", function (t, e) {
|
|
7318
|
-
for (var _iterator17 = _createForOfIteratorHelperLoose$
|
|
7316
|
+
for (var _iterator17 = _createForOfIteratorHelperLoose$3(t), _step17; !(_step17 = _iterator17()).done;) {
|
|
7319
7317
|
var _e30 = _step17.value;
|
|
7320
7318
|
t = Ls(_e30);
|
|
7321
7319
|
var _n26 = [];
|
|
7322
|
-
for (var _iterator18 = _createForOfIteratorHelperLoose$
|
|
7320
|
+
for (var _iterator18 = _createForOfIteratorHelperLoose$3(rn(t, Ts, 1)), _step18; !(_step18 = _iterator18()).done;) {
|
|
7323
7321
|
var _fn12, _fn13, _fn14;
|
|
7324
7322
|
var _e31 = _step18.value;
|
|
7325
7323
|
_n26.push({
|
|
@@ -7404,7 +7402,7 @@
|
|
|
7404
7402
|
yn(e, Si, this.j);
|
|
7405
7403
|
var n = new qr();
|
|
7406
7404
|
Hr(n, "mediapipe.tasks.vision.hand_landmarker.HandLandmarkerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "LANDMARKS:hand_landmarks"), $r(n, "WORLD_LANDMARKS:world_hand_landmarks"), $r(n, "HANDEDNESS:handedness"), n.o(e), es$1(t, n), this.g.attachProtoVectorListener("hand_landmarks", function (t, e) {
|
|
7407
|
-
for (var _iterator19 = _createForOfIteratorHelperLoose$
|
|
7405
|
+
for (var _iterator19 = _createForOfIteratorHelperLoose$3(t), _step19; !(_step19 = _iterator19()).done;) {
|
|
7408
7406
|
var _e32 = _step19.value;
|
|
7409
7407
|
t = Ms(_e32), _this51.landmarks.push(Qi(t));
|
|
7410
7408
|
}
|
|
@@ -7412,7 +7410,7 @@
|
|
|
7412
7410
|
}), this.g.attachEmptyPacketListener("hand_landmarks", function (t) {
|
|
7413
7411
|
_o(_this51, t);
|
|
7414
7412
|
}), this.g.attachProtoVectorListener("world_hand_landmarks", function (t, e) {
|
|
7415
|
-
for (var _iterator20 = _createForOfIteratorHelperLoose$
|
|
7413
|
+
for (var _iterator20 = _createForOfIteratorHelperLoose$3(t), _step20; !(_step20 = _iterator20()).done;) {
|
|
7416
7414
|
var _e33 = _step20.value;
|
|
7417
7415
|
t = Ls(_e33), _this51.worldLandmarks.push(to(t));
|
|
7418
7416
|
}
|
|
@@ -7423,11 +7421,11 @@
|
|
|
7423
7421
|
var n = _this51.handedness,
|
|
7424
7422
|
r = n.push;
|
|
7425
7423
|
var s = [];
|
|
7426
|
-
for (var _iterator21 = _createForOfIteratorHelperLoose$
|
|
7424
|
+
for (var _iterator21 = _createForOfIteratorHelperLoose$3(t), _step21; !(_step21 = _iterator21()).done;) {
|
|
7427
7425
|
var _e34 = _step21.value;
|
|
7428
7426
|
t = fs(_e34);
|
|
7429
7427
|
var _n27 = [];
|
|
7430
|
-
for (var _iterator22 = _createForOfIteratorHelperLoose$
|
|
7428
|
+
for (var _iterator22 = _createForOfIteratorHelperLoose$3(t.g()), _step22; !(_step22 = _iterator22()).done;) {
|
|
7431
7429
|
var _fn15, _ln4, _ref11, _un6, _ref12, _un7;
|
|
7432
7430
|
var _e35 = _step22.value;
|
|
7433
7431
|
_n27.push({
|
|
@@ -7819,7 +7817,7 @@
|
|
|
7819
7817
|
dn(a, 3, !0), gn(a, 1, e.keypoint.x), gn(a, 2, e.keypoint.y), on(i, 5, oh, a);
|
|
7820
7818
|
} else {
|
|
7821
7819
|
if (!e.scribble) throw Error("Must provide either a keypoint or a scribble.");
|
|
7822
|
-
for (var _iterator23 = _createForOfIteratorHelperLoose$
|
|
7820
|
+
for (var _iterator23 = _createForOfIteratorHelperLoose$3((o = new sh(), e.scribble)), _step23; !(_step23 = _iterator23()).done;) {
|
|
7823
7821
|
a = _step23.value;
|
|
7824
7822
|
dn(e = new nh(), 3, !0), gn(e, 1, a.x), gn(e, 2, a.y), an(o, nh, e);
|
|
7825
7823
|
}
|
|
@@ -7920,7 +7918,7 @@
|
|
|
7920
7918
|
yn(e, Vi, this.h);
|
|
7921
7919
|
var n = new qr();
|
|
7922
7920
|
Hr(n, "mediapipe.tasks.vision.ObjectDetectorGraph"), Yr(n, "IMAGE:input_frame_gpu"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "DETECTIONS:detections"), n.o(e), es$1(t, n), this.g.attachProtoVectorListener("detections", function (t, e) {
|
|
7923
|
-
for (var _iterator24 = _createForOfIteratorHelperLoose$
|
|
7921
|
+
for (var _iterator24 = _createForOfIteratorHelperLoose$3(t), _step24; !(_step24 = _iterator24()).done;) {
|
|
7924
7922
|
var _e37 = _step24.value;
|
|
7925
7923
|
t = Es(_e37), _this61.j.detections.push(Zi(t));
|
|
7926
7924
|
}
|
|
@@ -8020,7 +8018,7 @@
|
|
|
8020
8018
|
var n = new qr();
|
|
8021
8019
|
Hr(n, "mediapipe.tasks.vision.pose_landmarker.PoseLandmarkerGraph"), Yr(n, "IMAGE:image_in"), Yr(n, "NORM_RECT:norm_rect"), $r(n, "NORM_LANDMARKS:normalized_landmarks"), $r(n, "WORLD_LANDMARKS:world_landmarks"), n.o(e), es$1(t, n), wo(this, t), this.g.attachProtoVectorListener("normalized_landmarks", function (t, e) {
|
|
8022
8020
|
_this63.landmarks = [];
|
|
8023
|
-
for (var _iterator25 = _createForOfIteratorHelperLoose$
|
|
8021
|
+
for (var _iterator25 = _createForOfIteratorHelperLoose$3(t), _step25; !(_step25 = _iterator25()).done;) {
|
|
8024
8022
|
var _e39 = _step25.value;
|
|
8025
8023
|
t = Ms(_e39), _this63.landmarks.push(Qi(t));
|
|
8026
8024
|
}
|
|
@@ -8029,7 +8027,7 @@
|
|
|
8029
8027
|
_this63.landmarks = [], _o(_this63, t);
|
|
8030
8028
|
}), this.g.attachProtoVectorListener("world_landmarks", function (t, e) {
|
|
8031
8029
|
_this63.worldLandmarks = [];
|
|
8032
|
-
for (var _iterator26 = _createForOfIteratorHelperLoose$
|
|
8030
|
+
for (var _iterator26 = _createForOfIteratorHelperLoose$3(t), _step26; !(_step26 = _iterator26()).done;) {
|
|
8033
8031
|
var _e40 = _step26.value;
|
|
8034
8032
|
t = Ls(_e40), _this63.worldLandmarks.push(to(t));
|
|
8035
8033
|
}
|
|
@@ -9507,9 +9505,9 @@
|
|
|
9507
9505
|
return e;
|
|
9508
9506
|
}
|
|
9509
9507
|
|
|
9510
|
-
function _createForOfIteratorHelperLoose$
|
|
9511
|
-
function _unsupportedIterableToArray$
|
|
9512
|
-
function _arrayLikeToArray$
|
|
9508
|
+
function _createForOfIteratorHelperLoose$2(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$2(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9509
|
+
function _unsupportedIterableToArray$2(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$2(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$2(r, a) : void 0; } }
|
|
9510
|
+
function _arrayLikeToArray$2(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
9513
9511
|
var consoleLogger = {
|
|
9514
9512
|
type: 'logger',
|
|
9515
9513
|
log: function log(args) {
|
|
@@ -10356,7 +10354,7 @@
|
|
|
10356
10354
|
}
|
|
10357
10355
|
if (!useOptionsReplaceForData) {
|
|
10358
10356
|
data = _extends({}, data);
|
|
10359
|
-
for (var _iterator = _createForOfIteratorHelperLoose$
|
|
10357
|
+
for (var _iterator = _createForOfIteratorHelperLoose$2(optionsKeys), _step; !(_step = _iterator()).done;) {
|
|
10360
10358
|
var key = _step.value;
|
|
10361
10359
|
delete data[key];
|
|
10362
10360
|
}
|
|
@@ -14948,7 +14946,7 @@
|
|
|
14948
14946
|
});
|
|
14949
14947
|
}
|
|
14950
14948
|
|
|
14951
|
-
var _excluded = ["enabled", "anonymousActionType", "store"],
|
|
14949
|
+
var _excluded$1 = ["enabled", "anonymousActionType", "store"],
|
|
14952
14950
|
_excluded2 = ["connection"];
|
|
14953
14951
|
var trackedConnections = /* @__PURE__ */new Map();
|
|
14954
14952
|
var getTrackedConnectionState = function getTrackedConnectionState(name) {
|
|
@@ -14993,7 +14991,7 @@
|
|
|
14993
14991
|
enabled = _devtoolsOptions.enabled,
|
|
14994
14992
|
anonymousActionType = _devtoolsOptions.anonymousActionType,
|
|
14995
14993
|
store = _devtoolsOptions.store,
|
|
14996
|
-
options = _objectWithoutPropertiesLoose(_devtoolsOptions, _excluded);
|
|
14994
|
+
options = _objectWithoutPropertiesLoose(_devtoolsOptions, _excluded$1);
|
|
14997
14995
|
var extensionConnector;
|
|
14998
14996
|
try {
|
|
14999
14997
|
extensionConnector = (enabled != null ? enabled : (undefined ? undefined.MODE : void 0) !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__;
|
|
@@ -15154,9 +15152,9 @@
|
|
|
15154
15152
|
if (parsed !== void 0) f(parsed);
|
|
15155
15153
|
};
|
|
15156
15154
|
|
|
15157
|
-
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15158
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
15159
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15155
|
+
function _createForOfIteratorHelperLoose$1(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray$1(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15156
|
+
function _unsupportedIterableToArray$1(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$1(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$1(r, a) : void 0; } }
|
|
15157
|
+
function _arrayLikeToArray$1(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
15160
15158
|
var isIterable = function isIterable(obj) {
|
|
15161
15159
|
return Symbol.iterator in obj;
|
|
15162
15160
|
};
|
|
@@ -15172,7 +15170,7 @@
|
|
|
15172
15170
|
if (mapA.size !== mapB.size) {
|
|
15173
15171
|
return false;
|
|
15174
15172
|
}
|
|
15175
|
-
for (var _iterator = _createForOfIteratorHelperLoose(mapA), _step; !(_step = _iterator()).done;) {
|
|
15173
|
+
for (var _iterator = _createForOfIteratorHelperLoose$1(mapA), _step; !(_step = _iterator()).done;) {
|
|
15176
15174
|
var _step$value = _step.value,
|
|
15177
15175
|
key = _step$value[0],
|
|
15178
15176
|
value = _step$value[1];
|
|
@@ -24203,194 +24201,2722 @@
|
|
|
24203
24201
|
return t.length > 0 ? t : undefined;
|
|
24204
24202
|
}
|
|
24205
24203
|
|
|
24206
|
-
var
|
|
24207
|
-
var
|
|
24208
|
-
var
|
|
24209
|
-
var
|
|
24210
|
-
function
|
|
24211
|
-
|
|
24212
|
-
}
|
|
24213
|
-
function setAudioRecorder(recorder) {
|
|
24214
|
-
audioRecorder = recorder;
|
|
24215
|
-
}
|
|
24216
|
-
function clearVideoChunks() {
|
|
24217
|
-
videoChunks = [];
|
|
24204
|
+
var _excluded = ["locateFile"];
|
|
24205
|
+
function _createForOfIteratorHelperLoose(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (t) return (t = t.call(r)).next.bind(t); if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) { t && (r = t); var o = 0; return function () { return o >= r.length ? { done: !0 } : { done: !1, value: r[o++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
24206
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
24207
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
24208
|
+
function isError(error) {
|
|
24209
|
+
return error !== null && typeof error === 'object' && Object.prototype.hasOwnProperty.call(error, 'message');
|
|
24218
24210
|
}
|
|
24219
|
-
function
|
|
24220
|
-
|
|
24211
|
+
function unknownToError(error) {
|
|
24212
|
+
if (isError(error)) {
|
|
24213
|
+
return error;
|
|
24214
|
+
}
|
|
24215
|
+
return new Error(typeof error === 'string' ? error : 'Unknown error');
|
|
24221
24216
|
}
|
|
24222
|
-
|
|
24223
|
-
|
|
24224
|
-
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
|
|
24228
|
-
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
|
|
24217
|
+
|
|
24218
|
+
// DO NOT EDIT! File generated using `generate-types` script.
|
|
24219
|
+
|
|
24220
|
+
var INT_FIELDS = ['Active_Height', 'Active_Width', 'AudioCount', 'Audio_Channels_Total', 'BitDepth_Detected', 'BitDepth', 'BitDepth_Stored', 'Channels', 'Channels_Original', 'Chapters_Pos_Begin', 'Chapters_Pos_End', 'Comic_Position_Total', 'Count', 'DataSize', 'ElementCount', 'EPG_Positions_Begin', 'EPG_Positions_End', 'FirstPacketOrder', 'FooterSize', 'Format_Settings_GMC', 'Format_Settings_RefFrames', 'Format_Settings_SliceCount', 'FrameCount', 'FrameRate_Den', 'FrameRate_Num', 'GeneralCount', 'HeaderSize', 'Height_CleanAperture', 'Height', 'Height_Offset', 'Height_Original', 'ImageCount', 'Lines_MaxCharacterCount', 'Lines_MaxCountPerEvent', 'Matrix_Channels', 'MenuCount', 'OtherCount', 'Part_Position', 'Part_Position_Total', 'Played_Count', 'Reel_Position', 'Reel_Position_Total', 'Resolution', 'Sampled_Height', 'Sampled_Width', 'SamplingCount', 'Season_Position', 'Season_Position_Total', 'Source_FrameCount', 'Source_SamplingCount', 'Source_StreamSize_Encoded', 'Source_StreamSize', 'Status', 'Stored_Height', 'Stored_Width', 'StreamCount', 'StreamKindID', 'StreamKindPos', 'StreamSize_Demuxed', 'StreamSize_Encoded', 'StreamSize', 'TextCount', 'Track_Position', 'Track_Position_Total', 'Video0_Delay', 'VideoCount', 'Width_CleanAperture', 'Width', 'Width_Offset', 'Width_Original'];
|
|
24221
|
+
var FLOAT_FIELDS = ['Active_DisplayAspectRatio', 'BitRate_Encoded', 'BitRate_Maximum', 'BitRate_Minimum', 'BitRate', 'BitRate_Nominal', 'Bits-Pixel_Frame', 'BitsPixel_Frame', 'Compression_Ratio', 'Delay', 'Delay_Original', 'DisplayAspectRatio_CleanAperture', 'DisplayAspectRatio', 'DisplayAspectRatio_Original', 'Duration_End_Command', 'Duration_End', 'Duration_FirstFrame', 'Duration_LastFrame', 'Duration', 'Duration_Start2End', 'Duration_Start_Command', 'Duration_Start', 'Events_MinDuration', 'FrameRate_Maximum', 'FrameRate_Minimum', 'FrameRate', 'FrameRate_Nominal', 'FrameRate_Original_Den', 'FrameRate_Original', 'FrameRate_Original_Num', 'FrameRate_Real', 'Interleave_Duration', 'Interleave_Preload', 'Interleave_VideoFrames', 'OverallBitRate_Maximum', 'OverallBitRate_Minimum', 'OverallBitRate', 'OverallBitRate_Nominal', 'PixelAspectRatio_CleanAperture', 'PixelAspectRatio', 'PixelAspectRatio_Original', 'SamplesPerFrame', 'SamplingRate', 'Source_Duration_FirstFrame', 'Source_Duration_LastFrame', 'Source_Duration', 'TimeStamp_FirstFrame', 'Video_Delay'];
|
|
24222
|
+
var MAX_UINT32_PLUS_ONE = Math.pow(2, 32);
|
|
24223
|
+
var DEFAULT_OPTIONS = {
|
|
24224
|
+
coverData: false,
|
|
24225
|
+
chunkSize: 256 * 1024,
|
|
24226
|
+
format: 'object',
|
|
24227
|
+
full: false
|
|
24232
24228
|
};
|
|
24233
|
-
|
|
24234
|
-
|
|
24235
|
-
|
|
24236
|
-
|
|
24237
|
-
|
|
24238
|
-
|
|
24239
|
-
|
|
24240
|
-
|
|
24241
|
-
|
|
24242
|
-
|
|
24243
|
-
|
|
24244
|
-
|
|
24245
|
-
|
|
24246
|
-
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
|
|
24250
|
-
|
|
24251
|
-
|
|
24252
|
-
|
|
24253
|
-
|
|
24254
|
-
|
|
24255
|
-
|
|
24229
|
+
/**
|
|
24230
|
+
* Wrapper for the MediaInfoLib WASM module.
|
|
24231
|
+
*
|
|
24232
|
+
* This class should not be instantiated directly. Use the {@link mediaInfoFactory} function
|
|
24233
|
+
* to create instances of `MediaInfo`.
|
|
24234
|
+
*
|
|
24235
|
+
* @typeParam TFormat - The format type, defaults to `object`.
|
|
24236
|
+
*/
|
|
24237
|
+
var MediaInfo = /*#__PURE__*/function () {
|
|
24238
|
+
/** @group General Use */
|
|
24239
|
+
|
|
24240
|
+
/**
|
|
24241
|
+
* The constructor should not be called directly, instead use {@link mediaInfoFactory}.
|
|
24242
|
+
*
|
|
24243
|
+
* @hidden
|
|
24244
|
+
* @param mediainfoModule WASM module
|
|
24245
|
+
* @param options User options
|
|
24246
|
+
*/
|
|
24247
|
+
function MediaInfo(mediainfoModule, options) {
|
|
24248
|
+
this.isAnalyzing = false;
|
|
24249
|
+
this.mediainfoModule = mediainfoModule;
|
|
24250
|
+
this.options = options;
|
|
24251
|
+
this.mediainfoModuleInstance = this.instantiateModuleInstance();
|
|
24252
|
+
}
|
|
24253
|
+
|
|
24254
|
+
/**
|
|
24255
|
+
* Convenience method for analyzing a buffer chunk by chunk.
|
|
24256
|
+
*
|
|
24257
|
+
* @param size Return total buffer size in bytes.
|
|
24258
|
+
* @param readChunk Read chunk of data and return an {@link Uint8Array}.
|
|
24259
|
+
* @group General Use
|
|
24260
|
+
*/
|
|
24261
|
+
|
|
24262
|
+
/**
|
|
24263
|
+
* Convenience method for analyzing a buffer chunk by chunk.
|
|
24264
|
+
*
|
|
24265
|
+
* @param size Return total buffer size in bytes.
|
|
24266
|
+
* @param readChunk Read chunk of data and return an {@link Uint8Array}.
|
|
24267
|
+
* @param callback Function that is called once the processing is done
|
|
24268
|
+
* @group General Use
|
|
24269
|
+
*/
|
|
24270
|
+
var _proto = MediaInfo.prototype;
|
|
24271
|
+
_proto.analyzeData = function analyzeData(size, readChunk, callback) {
|
|
24272
|
+
var _this = this;
|
|
24273
|
+
// Support promise signature
|
|
24274
|
+
if (callback === undefined) {
|
|
24275
|
+
return new Promise(function (resolve, reject) {
|
|
24276
|
+
var resultCb = function resultCb(result, error) {
|
|
24277
|
+
_this.isAnalyzing = false;
|
|
24278
|
+
if (error || !result) {
|
|
24279
|
+
reject(unknownToError(error));
|
|
24280
|
+
} else {
|
|
24281
|
+
resolve(result);
|
|
24282
|
+
}
|
|
24283
|
+
};
|
|
24284
|
+
_this.analyzeData(size, readChunk, resultCb);
|
|
24256
24285
|
});
|
|
24257
|
-
|
|
24258
|
-
|
|
24259
|
-
|
|
24260
|
-
|
|
24261
|
-
|
|
24262
|
-
|
|
24263
|
-
|
|
24264
|
-
|
|
24265
|
-
|
|
24266
|
-
|
|
24267
|
-
|
|
24268
|
-
|
|
24269
|
-
|
|
24286
|
+
}
|
|
24287
|
+
if (this.isAnalyzing) {
|
|
24288
|
+
callback('', new Error('cannot start a new analysis while another is in progress'));
|
|
24289
|
+
return;
|
|
24290
|
+
}
|
|
24291
|
+
this.reset();
|
|
24292
|
+
this.isAnalyzing = true;
|
|
24293
|
+
var finalize = function finalize() {
|
|
24294
|
+
try {
|
|
24295
|
+
_this.openBufferFinalize();
|
|
24296
|
+
var result = _this.inform();
|
|
24297
|
+
if (_this.options.format === 'object') {
|
|
24298
|
+
callback(_this.parseResultJson(result));
|
|
24299
|
+
} else {
|
|
24300
|
+
callback(result);
|
|
24270
24301
|
}
|
|
24271
|
-
}
|
|
24272
|
-
|
|
24273
|
-
startRecordingAudio();
|
|
24274
|
-
}
|
|
24275
|
-
},
|
|
24276
|
-
stopRecordingVideo: function stopRecordingVideo() {
|
|
24277
|
-
set({
|
|
24278
|
-
videoRecordingIntentionallyStopped: true
|
|
24279
|
-
});
|
|
24280
|
-
if ((videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.state) !== 'inactive') {
|
|
24281
|
-
videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
|
|
24302
|
+
} finally {
|
|
24303
|
+
_this.isAnalyzing = false;
|
|
24282
24304
|
}
|
|
24283
|
-
}
|
|
24284
|
-
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
|
|
24288
|
-
|
|
24289
|
-
|
|
24290
|
-
|
|
24291
|
-
|
|
24292
|
-
});
|
|
24293
|
-
var audioRecorder = new MediaRecorder(audioStream, {
|
|
24294
|
-
audioBitsPerSecond: 32000
|
|
24295
|
-
});
|
|
24296
|
-
setAudioRecorder(audioRecorder);
|
|
24297
|
-
audioRecorder.ondataavailable = function (e) {
|
|
24298
|
-
audioChunks.push(e.data);
|
|
24305
|
+
};
|
|
24306
|
+
var offset = 0;
|
|
24307
|
+
var runReadDataLoop = function runReadDataLoop(fileSize) {
|
|
24308
|
+
var readNextChunk = function readNextChunk(data) {
|
|
24309
|
+
if (continueBuffer(data)) {
|
|
24310
|
+
getChunk();
|
|
24311
|
+
} else {
|
|
24312
|
+
finalize();
|
|
24313
|
+
}
|
|
24299
24314
|
};
|
|
24300
|
-
|
|
24301
|
-
|
|
24302
|
-
|
|
24303
|
-
|
|
24315
|
+
var getChunk = function getChunk() {
|
|
24316
|
+
var dataValue;
|
|
24317
|
+
try {
|
|
24318
|
+
var safeSize = Math.min(_this.options.chunkSize, fileSize - offset);
|
|
24319
|
+
dataValue = readChunk(safeSize, offset);
|
|
24320
|
+
} catch (error) {
|
|
24321
|
+
_this.isAnalyzing = false;
|
|
24322
|
+
callback('', unknownToError(error));
|
|
24323
|
+
return;
|
|
24324
|
+
}
|
|
24325
|
+
if (dataValue instanceof Promise) {
|
|
24326
|
+
dataValue.then(readNextChunk)["catch"](function (error) {
|
|
24327
|
+
_this.isAnalyzing = false;
|
|
24328
|
+
callback('', unknownToError(error));
|
|
24329
|
+
});
|
|
24330
|
+
} else {
|
|
24331
|
+
readNextChunk(dataValue);
|
|
24332
|
+
}
|
|
24304
24333
|
};
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
|
|
24309
|
-
|
|
24334
|
+
var continueBuffer = function continueBuffer(data) {
|
|
24335
|
+
if (data.length === 0 || _this.openBufferContinue(data, data.length)) {
|
|
24336
|
+
return false;
|
|
24337
|
+
}
|
|
24338
|
+
var seekTo = _this.openBufferContinueGotoGet();
|
|
24339
|
+
if (seekTo === -1) {
|
|
24340
|
+
offset += data.length;
|
|
24341
|
+
} else {
|
|
24342
|
+
offset = seekTo;
|
|
24343
|
+
_this.openBufferInit(fileSize, seekTo);
|
|
24344
|
+
}
|
|
24345
|
+
return true;
|
|
24346
|
+
};
|
|
24347
|
+
_this.openBufferInit(fileSize, offset);
|
|
24348
|
+
getChunk();
|
|
24349
|
+
};
|
|
24350
|
+
var fileSizeValue = typeof size === 'function' ? size() : size;
|
|
24351
|
+
if (fileSizeValue instanceof Promise) {
|
|
24352
|
+
fileSizeValue.then(runReadDataLoop)["catch"](function (error) {
|
|
24353
|
+
callback(null, unknownToError(error));
|
|
24310
24354
|
});
|
|
24311
|
-
|
|
24312
|
-
|
|
24313
|
-
}
|
|
24314
|
-
},
|
|
24315
|
-
stopRecording: function stopRecording() {
|
|
24316
|
-
get().stopRecordingVideo();
|
|
24317
|
-
get().stopRecordingAudio();
|
|
24318
|
-
},
|
|
24319
|
-
clearRecordedData: function clearRecordedData() {
|
|
24320
|
-
clearVideoChunks();
|
|
24321
|
-
clearAudioChunks();
|
|
24355
|
+
} else {
|
|
24356
|
+
runReadDataLoop(fileSizeValue);
|
|
24322
24357
|
}
|
|
24323
|
-
});
|
|
24324
|
-
}));
|
|
24325
|
-
var useVideoRecorder = function useVideoRecorder(mergeAVStreams) {
|
|
24326
|
-
if (mergeAVStreams === void 0) {
|
|
24327
|
-
mergeAVStreams = false;
|
|
24328
24358
|
}
|
|
24329
|
-
|
|
24330
|
-
|
|
24331
|
-
|
|
24332
|
-
|
|
24333
|
-
|
|
24334
|
-
|
|
24335
|
-
|
|
24336
|
-
|
|
24337
|
-
|
|
24338
|
-
var processVideo = React.useCallback(function () {
|
|
24339
|
-
var inferredType = inferBlobType(videoChunks[0]) || (videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.mimeType) || 'video/mp4';
|
|
24340
|
-
var videoBlob = new Blob(videoChunks, {
|
|
24341
|
-
type: inferredType
|
|
24342
|
-
});
|
|
24343
|
-
useVideoRecorderStore.setState({
|
|
24344
|
-
videoUrl: URL.createObjectURL(videoBlob),
|
|
24345
|
-
isRecordingVideo: false
|
|
24346
|
-
});
|
|
24347
|
-
clearVideoChunks();
|
|
24348
|
-
setVideoRecorder(null);
|
|
24349
|
-
}, []);
|
|
24350
|
-
var processAudio = React.useCallback(function () {
|
|
24351
|
-
var inferredType = inferBlobType(audioChunks[0]) || (audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.mimeType) || 'audio/mp4';
|
|
24352
|
-
var audioBlob = new Blob(audioChunks, {
|
|
24353
|
-
type: inferredType
|
|
24354
|
-
});
|
|
24355
|
-
useVideoRecorderStore.setState({
|
|
24356
|
-
audioUrl: URL.createObjectURL(audioBlob),
|
|
24357
|
-
isRecordingAudio: false
|
|
24358
|
-
});
|
|
24359
|
-
clearAudioChunks();
|
|
24360
|
-
setAudioRecorder(null);
|
|
24361
|
-
}, []);
|
|
24362
|
-
var _a = useVideoRecorderStore(),
|
|
24363
|
-
videoUrl = _a.videoUrl,
|
|
24364
|
-
audioUrl = _a.audioUrl,
|
|
24365
|
-
isRecordingVideo = _a.isRecordingVideo,
|
|
24366
|
-
isRecordingAudio = _a.isRecordingAudio,
|
|
24367
|
-
videoRecordingStopped = _a.videoRecordingStopped,
|
|
24368
|
-
videoRecordingIntentionallyStopped = _a.videoRecordingIntentionallyStopped,
|
|
24369
|
-
audioRecordingStopped = _a.audioRecordingStopped,
|
|
24370
|
-
audioRecordingIntentionallyStopped = _a.audioRecordingIntentionallyStopped;
|
|
24371
|
-
React.useEffect(function () {
|
|
24372
|
-
if (videoRecordingStopped && videoRecordingIntentionallyStopped) {
|
|
24373
|
-
processVideo();
|
|
24359
|
+
|
|
24360
|
+
/**
|
|
24361
|
+
* Close the MediaInfoLib WASM instance.
|
|
24362
|
+
*
|
|
24363
|
+
* @group General Use
|
|
24364
|
+
*/;
|
|
24365
|
+
_proto.close = function close() {
|
|
24366
|
+
if (typeof this.mediainfoModuleInstance.close === 'function') {
|
|
24367
|
+
this.mediainfoModuleInstance.close();
|
|
24374
24368
|
}
|
|
24375
|
-
}
|
|
24376
|
-
|
|
24377
|
-
|
|
24378
|
-
|
|
24369
|
+
}
|
|
24370
|
+
|
|
24371
|
+
/**
|
|
24372
|
+
* Reset the MediaInfoLib WASM instance to its initial state.
|
|
24373
|
+
*
|
|
24374
|
+
* This method ensures that the instance is ready for a new parse.
|
|
24375
|
+
* @group General Use
|
|
24376
|
+
*/;
|
|
24377
|
+
_proto.reset = function reset() {
|
|
24378
|
+
this.mediainfoModuleInstance["delete"]();
|
|
24379
|
+
this.mediainfoModuleInstance = this.instantiateModuleInstance();
|
|
24380
|
+
}
|
|
24381
|
+
|
|
24382
|
+
/**
|
|
24383
|
+
* Receive result data from the WASM instance.
|
|
24384
|
+
*
|
|
24385
|
+
* (This is a low-level MediaInfoLib function.)
|
|
24386
|
+
*
|
|
24387
|
+
* @returns Result data (format can be configured in options)
|
|
24388
|
+
* @group Low-level
|
|
24389
|
+
*/;
|
|
24390
|
+
_proto.inform = function inform() {
|
|
24391
|
+
return this.mediainfoModuleInstance.inform();
|
|
24392
|
+
}
|
|
24393
|
+
|
|
24394
|
+
/**
|
|
24395
|
+
* Send more data to the WASM instance.
|
|
24396
|
+
*
|
|
24397
|
+
* (This is a low-level MediaInfoLib function.)
|
|
24398
|
+
*
|
|
24399
|
+
* @param data Data buffer
|
|
24400
|
+
* @param size Buffer size
|
|
24401
|
+
* @returns Processing state: `0` (no bits set) = not finished, Bit `0` set = enough data read for providing information
|
|
24402
|
+
* @group Low-level
|
|
24403
|
+
*/;
|
|
24404
|
+
_proto.openBufferContinue = function openBufferContinue(data, size) {
|
|
24405
|
+
// bit 3 set -> done
|
|
24406
|
+
return !!(this.mediainfoModuleInstance.open_buffer_continue(data, size) & 0x08);
|
|
24407
|
+
}
|
|
24408
|
+
|
|
24409
|
+
/**
|
|
24410
|
+
* Retrieve seek position from WASM instance.
|
|
24411
|
+
* The MediaInfoLib function `Open_Buffer_GoTo` returns an integer with 64 bit precision.
|
|
24412
|
+
* It would be cut at 32 bit due to the JavaScript bindings. Here we transport the low and high
|
|
24413
|
+
* parts separately and put them together.
|
|
24414
|
+
*
|
|
24415
|
+
* (This is a low-level MediaInfoLib function.)
|
|
24416
|
+
*
|
|
24417
|
+
* @returns Seek position (where MediaInfoLib wants go in the data buffer)
|
|
24418
|
+
* @group Low-level
|
|
24419
|
+
*/;
|
|
24420
|
+
_proto.openBufferContinueGotoGet = function openBufferContinueGotoGet() {
|
|
24421
|
+
// JS bindings don't support 64 bit int
|
|
24422
|
+
// https://github.com/buzz/mediainfo.js/issues/11
|
|
24423
|
+
var seekTo = -1;
|
|
24424
|
+
var seekToLow = this.mediainfoModuleInstance.open_buffer_continue_goto_get_lower();
|
|
24425
|
+
var seekToHigh = this.mediainfoModuleInstance.open_buffer_continue_goto_get_upper();
|
|
24426
|
+
if (seekToLow == -1 && seekToHigh == -1) {
|
|
24427
|
+
seekTo = -1;
|
|
24428
|
+
} else if (seekToLow < 0) {
|
|
24429
|
+
seekTo = seekToLow + MAX_UINT32_PLUS_ONE + seekToHigh * MAX_UINT32_PLUS_ONE;
|
|
24430
|
+
} else {
|
|
24431
|
+
seekTo = seekToLow + seekToHigh * MAX_UINT32_PLUS_ONE;
|
|
24379
24432
|
}
|
|
24380
|
-
|
|
24381
|
-
|
|
24382
|
-
return {
|
|
24383
|
-
isRecordingVideo: isRecordingVideo,
|
|
24384
|
-
isRecordingAudio: isRecordingAudio,
|
|
24385
|
-
videoRecordingUnintentionallyStopped: videoRecordingStopped && !videoRecordingIntentionallyStopped,
|
|
24386
|
-
audioRecordingUnintentionallyStopped: audioRecordingStopped && !audioRecordingIntentionallyStopped,
|
|
24387
|
-
videoUrl: videoUrl,
|
|
24388
|
-
audioUrl: audioUrl
|
|
24389
|
-
};
|
|
24390
|
-
}, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, isRecordingAudio, isRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
|
|
24391
|
-
};
|
|
24433
|
+
return seekTo;
|
|
24434
|
+
}
|
|
24392
24435
|
|
|
24393
|
-
|
|
24436
|
+
/**
|
|
24437
|
+
* Inform MediaInfoLib that no more data is being read.
|
|
24438
|
+
*
|
|
24439
|
+
* (This is a low-level MediaInfoLib function.)
|
|
24440
|
+
*
|
|
24441
|
+
* @group Low-level
|
|
24442
|
+
*/;
|
|
24443
|
+
_proto.openBufferFinalize = function openBufferFinalize() {
|
|
24444
|
+
this.mediainfoModuleInstance.open_buffer_finalize();
|
|
24445
|
+
}
|
|
24446
|
+
|
|
24447
|
+
/**
|
|
24448
|
+
* Prepare MediaInfoLib to process a data buffer.
|
|
24449
|
+
*
|
|
24450
|
+
* (This is a low-level MediaInfoLib function.)
|
|
24451
|
+
*
|
|
24452
|
+
* @param size Expected buffer size
|
|
24453
|
+
* @param offset Buffer offset
|
|
24454
|
+
* @group Low-level
|
|
24455
|
+
*/;
|
|
24456
|
+
_proto.openBufferInit = function openBufferInit(size, offset) {
|
|
24457
|
+
this.mediainfoModuleInstance.open_buffer_init(size, offset);
|
|
24458
|
+
}
|
|
24459
|
+
|
|
24460
|
+
/**
|
|
24461
|
+
* Parse result JSON. Convert integer/float fields.
|
|
24462
|
+
*
|
|
24463
|
+
* @param result Serialized JSON from MediaInfo
|
|
24464
|
+
* @returns Parsed JSON object
|
|
24465
|
+
*/;
|
|
24466
|
+
_proto.parseResultJson = function parseResultJson(resultString) {
|
|
24467
|
+
var intFields = INT_FIELDS;
|
|
24468
|
+
var floatFields = FLOAT_FIELDS;
|
|
24469
|
+
|
|
24470
|
+
// Parse JSON
|
|
24471
|
+
var result = JSON.parse(resultString);
|
|
24472
|
+
if (result.media) {
|
|
24473
|
+
var newMedia = _extends({}, result.media, {
|
|
24474
|
+
track: []
|
|
24475
|
+
});
|
|
24476
|
+
if (Array.isArray(result.media.track)) {
|
|
24477
|
+
for (var _iterator = _createForOfIteratorHelperLoose(result.media.track), _step; !(_step = _iterator()).done;) {
|
|
24478
|
+
var track = _step.value;
|
|
24479
|
+
var newTrack = {
|
|
24480
|
+
'@type': track['@type']
|
|
24481
|
+
};
|
|
24482
|
+
for (var _i = 0, _Object$entries = Object.entries(track); _i < _Object$entries.length; _i++) {
|
|
24483
|
+
var _Object$entries$_i = _Object$entries[_i],
|
|
24484
|
+
key = _Object$entries$_i[0],
|
|
24485
|
+
val = _Object$entries$_i[1];
|
|
24486
|
+
if (key === '@type') {
|
|
24487
|
+
continue;
|
|
24488
|
+
}
|
|
24489
|
+
if (typeof val === 'string' && intFields.includes(key)) {
|
|
24490
|
+
var _extends2;
|
|
24491
|
+
newTrack = _extends({}, newTrack, (_extends2 = {}, _extends2[key] = Number.parseInt(val, 10), _extends2));
|
|
24492
|
+
} else if (typeof val === 'string' && floatFields.includes(key)) {
|
|
24493
|
+
var _extends3;
|
|
24494
|
+
newTrack = _extends({}, newTrack, (_extends3 = {}, _extends3[key] = Number.parseFloat(val), _extends3));
|
|
24495
|
+
} else {
|
|
24496
|
+
var _extends4;
|
|
24497
|
+
newTrack = _extends({}, newTrack, (_extends4 = {}, _extends4[key] = val, _extends4));
|
|
24498
|
+
}
|
|
24499
|
+
}
|
|
24500
|
+
newMedia.track.push(newTrack);
|
|
24501
|
+
}
|
|
24502
|
+
}
|
|
24503
|
+
return _extends({}, result, {
|
|
24504
|
+
media: newMedia
|
|
24505
|
+
});
|
|
24506
|
+
}
|
|
24507
|
+
return result;
|
|
24508
|
+
}
|
|
24509
|
+
|
|
24510
|
+
/**
|
|
24511
|
+
* Instantiate a new WASM module instance.
|
|
24512
|
+
*
|
|
24513
|
+
* @returns MediaInfo module instance
|
|
24514
|
+
*/;
|
|
24515
|
+
_proto.instantiateModuleInstance = function instantiateModuleInstance() {
|
|
24516
|
+
return new this.mediainfoModule.MediaInfo(this.options.format === 'object' ? 'JSON' : this.options.format, this.options.coverData, this.options.full);
|
|
24517
|
+
};
|
|
24518
|
+
return MediaInfo;
|
|
24519
|
+
}(); // This code implements the `-sMODULARIZE` settings by taking the generated
|
|
24520
|
+
// JS program code (INNER_JS_CODE) and wrapping it in a factory function.
|
|
24521
|
+
// When targetting node and ES6 we use `await import ..` in the generated code
|
|
24522
|
+
// so the outer function needs to be marked as async.
|
|
24523
|
+
function Module(_x) {
|
|
24524
|
+
return _Module.apply(this, arguments);
|
|
24525
|
+
}
|
|
24526
|
+
function _Module() {
|
|
24527
|
+
_Module = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(moduleArg) {
|
|
24528
|
+
var moduleRtn, Module, thisProgram, _scriptName, scriptDirectory, locateFile, readAsync, out, err, wasmBinary, ABORT, readyPromiseResolve, readyPromiseReject, wasmMemory, HEAP8, HEAPU8, HEAP16, HEAPU16, HEAP32, HEAPU32, HEAPF32, HEAPF64, HEAP64, HEAPU64, runtimeInitialized, updateMemoryViews, initRuntime, runDependencies, dependenciesFulfilled, addRunDependency, removeRunDependency, abort, wasmBinaryFile, findWasmBinary, getBinarySync, getWasmBinary, _getWasmBinary, instantiateArrayBuffer, _instantiateArrayBuffer, instantiateAsync, _instantiateAsync, getWasmImports, createWasm, _createWasm, __abort_js, AsciiToString, awaitingDependencies, registeredTypes, typeDependencies, BindingError, throwBindingError, sharedRegisterType, registerType, integerReadValueFromPointer, __embind_register_bigint, __embind_register_bool, shallowCopyInternalPointer, throwInstanceAlreadyDeleted, finalizationRegistry, detachFinalizer, runDestructor, releaseClassHandle, _attachFinalizer, init_ClassHandle, ClassHandle, createNamedFunction, registeredPointers, ensureOverloadTable, exposePublicSymbol, char_0, char_9, makeLegalFunctionName, RegisteredClass, upcastPointer, embindRepr, constNoSmartPtrRawPointerToWireType, genericPointerToWireType, nonConstNoSmartPtrRawPointerToWireType, readPointer, _downcastPointer, registeredInstances, getBasestPointer, getInheritedInstance, InternalError, throwInternalError, makeClassHandle, RegisteredPointer_fromWireType, init_RegisteredPointer, RegisteredPointer, replacePublicSymbol, wasmTableMirror, wasmTable, getWasmTableEntry, embind__requireFunction, UnboundTypeError, getTypeName, throwUnboundTypeError, whenDependentTypesAreResolved, __embind_register_class, heap32VectorToArray, runDestructors, usesDestructorStack, createJsInvoker, craftInvokerFunction, __embind_register_class_constructor, getFunctionName, __embind_register_class_function, emval_freelist, emval_handles, __emval_decref, Emval, EmValType, __embind_register_emval, floatReadValueFromPointer, __embind_register_float, __embind_register_integer, __embind_register_memory_view, __embind_register_smart_ptr, stringToUTF8Array, stringToUTF8, lengthBytesUTF8, UTF8Decoder, findStringEnd, UTF8ArrayToString, UTF8ToString, __embind_register_std_string, UTF16Decoder, UTF16ToString, stringToUTF16, lengthBytesUTF16, UTF32ToString, stringToUTF32, lengthBytesUTF32, __embind_register_std_wstring, __embind_register_void, emval_methodCallers, emval_addMethodCaller, requireRegisteredType, emval_lookupTypes, emval_returnValue, emval_symbols, getStringOrSymbol, __emval_create_invoker, __emval_incref, __emval_invoke, __emval_run_destructors, INT53_MAX, INT53_MIN, bigintToI53Checked, __gmtime_js, __tzset_js, _emscripten_date_now, getHeapMax, alignMemory, growMemory, _emscripten_resize_heap, ENV, getExecutableName, _getEnvStrings, _environ_get, _environ_sizes_get, _fd_close, _fd_seek, printCharBuffers, printChar, _fd_write, ___getTypeName, _malloc, _free, assignWasmExports, wasmImports, wasmExports, run;
|
|
24529
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
24530
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
24531
|
+
case 0:
|
|
24532
|
+
run = function _run() {
|
|
24533
|
+
if (runDependencies > 0) {
|
|
24534
|
+
dependenciesFulfilled = run;
|
|
24535
|
+
return;
|
|
24536
|
+
}
|
|
24537
|
+
|
|
24538
|
+
// a preRun added a dependency, run will be called later
|
|
24539
|
+
if (runDependencies > 0) {
|
|
24540
|
+
dependenciesFulfilled = run;
|
|
24541
|
+
return;
|
|
24542
|
+
}
|
|
24543
|
+
function doRun() {
|
|
24544
|
+
// run may have just been called through dependencies being fulfilled just in this very frame,
|
|
24545
|
+
// or while the async setStatus time below was happening
|
|
24546
|
+
Module['calledRun'] = true;
|
|
24547
|
+
if (ABORT) return;
|
|
24548
|
+
initRuntime();
|
|
24549
|
+
readyPromiseResolve == null || readyPromiseResolve(Module);
|
|
24550
|
+
}
|
|
24551
|
+
{
|
|
24552
|
+
doRun();
|
|
24553
|
+
}
|
|
24554
|
+
};
|
|
24555
|
+
assignWasmExports = function _assignWasmExports(wasmExports) {
|
|
24556
|
+
___getTypeName = wasmExports['__getTypeName'];
|
|
24557
|
+
_malloc = wasmExports['malloc'];
|
|
24558
|
+
_free = wasmExports['free'];
|
|
24559
|
+
wasmExports['_emscripten_stack_restore'];
|
|
24560
|
+
wasmExports['_emscripten_stack_alloc'];
|
|
24561
|
+
wasmExports['emscripten_stack_get_current'];
|
|
24562
|
+
};
|
|
24563
|
+
_fd_seek = function _fd_seek2(fd, offset, whence, newOffset) {
|
|
24564
|
+
return 70;
|
|
24565
|
+
};
|
|
24566
|
+
__gmtime_js = function _gmtime_js(time, tmPtr) {
|
|
24567
|
+
time = bigintToI53Checked(time);
|
|
24568
|
+
var date = new Date(time * 1000);
|
|
24569
|
+
HEAP32[tmPtr >> 2] = date.getUTCSeconds();
|
|
24570
|
+
HEAP32[tmPtr + 4 >> 2] = date.getUTCMinutes();
|
|
24571
|
+
HEAP32[tmPtr + 8 >> 2] = date.getUTCHours();
|
|
24572
|
+
HEAP32[tmPtr + 12 >> 2] = date.getUTCDate();
|
|
24573
|
+
HEAP32[tmPtr + 16 >> 2] = date.getUTCMonth();
|
|
24574
|
+
HEAP32[tmPtr + 20 >> 2] = date.getUTCFullYear() - 1900;
|
|
24575
|
+
HEAP32[tmPtr + 24 >> 2] = date.getUTCDay();
|
|
24576
|
+
var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0);
|
|
24577
|
+
var yday = (date.getTime() - start) / (1000 * 60 * 60 * 24) | 0;
|
|
24578
|
+
HEAP32[tmPtr + 28 >> 2] = yday;
|
|
24579
|
+
};
|
|
24580
|
+
craftInvokerFunction = function _craftInvokerFunction(humanName, argTypes, classType, cppInvokerFunc, cppTargetFunc, /** boolean= */isAsync) {
|
|
24581
|
+
// humanName: a human-readable string name for the function to be generated.
|
|
24582
|
+
// argTypes: An array that contains the embind type objects for all types in the function signature.
|
|
24583
|
+
// argTypes[0] is the type object for the function return value.
|
|
24584
|
+
// argTypes[1] is the type object for function this object/class type, or null if not crafting an invoker for a class method.
|
|
24585
|
+
// argTypes[2...] are the actual function parameters.
|
|
24586
|
+
// classType: The embind type object for the class to be bound, or null if this is not a method of a class.
|
|
24587
|
+
// cppInvokerFunc: JS Function object to the C++-side function that interops into C++ code.
|
|
24588
|
+
// cppTargetFunc: Function pointer (an integer to FUNCTION_TABLE) to the target C++ function the cppInvokerFunc will end up calling.
|
|
24589
|
+
// isAsync: Optional. If true, returns an async function. Async bindings are only supported with JSPI.
|
|
24590
|
+
var argCount = argTypes.length;
|
|
24591
|
+
if (argCount < 2) {
|
|
24592
|
+
throwBindingError("argTypes array size mismatch! Must at least get return value and 'this' types!");
|
|
24593
|
+
}
|
|
24594
|
+
var isClassMethodFunc = argTypes[1] !== null && classType !== null;
|
|
24595
|
+
|
|
24596
|
+
// Free functions with signature "void function()" do not need an invoker that marshalls between wire types.
|
|
24597
|
+
// TODO: This omits argument count check - enable only at -O3 or similar.
|
|
24598
|
+
// if (ENABLE_UNSAFE_OPTS && argCount == 2 && argTypes[0].name == "void" && !isClassMethodFunc) {
|
|
24599
|
+
// return FUNCTION_TABLE[fn];
|
|
24600
|
+
// }
|
|
24601
|
+
|
|
24602
|
+
// Determine if we need to use a dynamic stack to store the destructors for the function parameters.
|
|
24603
|
+
// TODO: Remove this completely once all function invokers are being dynamically generated.
|
|
24604
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
24605
|
+
var returns = !argTypes[0].isVoid;
|
|
24606
|
+
// Builld the arguments that will be passed into the closure around the invoker
|
|
24607
|
+
// function.
|
|
24608
|
+
var retType = argTypes[0];
|
|
24609
|
+
var instType = argTypes[1];
|
|
24610
|
+
var closureArgs = [humanName, throwBindingError, cppInvokerFunc, cppTargetFunc, runDestructors, retType.fromWireType.bind(retType), instType == null ? void 0 : instType.toWireType.bind(instType)];
|
|
24611
|
+
for (var i = 2; i < argCount; ++i) {
|
|
24612
|
+
var argType = argTypes[i];
|
|
24613
|
+
closureArgs.push(argType.toWireType.bind(argType));
|
|
24614
|
+
}
|
|
24615
|
+
if (!needsDestructorStack) {
|
|
24616
|
+
// Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
|
|
24617
|
+
for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) {
|
|
24618
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
24619
|
+
closureArgs.push(argTypes[i].destructorFunction);
|
|
24620
|
+
}
|
|
24621
|
+
}
|
|
24622
|
+
}
|
|
24623
|
+
var invokerFactory = createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync);
|
|
24624
|
+
var invokerFn = invokerFactory.apply(void 0, closureArgs);
|
|
24625
|
+
return createNamedFunction(humanName, invokerFn);
|
|
24626
|
+
};
|
|
24627
|
+
createJsInvoker = function _createJsInvoker(argTypes, isClassMethodFunc, returns, isAsync) {
|
|
24628
|
+
var needsDestructorStack = usesDestructorStack(argTypes);
|
|
24629
|
+
var argCount = argTypes.length - 2;
|
|
24630
|
+
var argsList = [];
|
|
24631
|
+
var argsListWired = ['fn'];
|
|
24632
|
+
if (isClassMethodFunc) {
|
|
24633
|
+
argsListWired.push('thisWired');
|
|
24634
|
+
}
|
|
24635
|
+
for (var i = 0; i < argCount; ++i) {
|
|
24636
|
+
argsList.push("arg" + i);
|
|
24637
|
+
argsListWired.push("arg" + i + "Wired");
|
|
24638
|
+
}
|
|
24639
|
+
argsList = argsList.join(',');
|
|
24640
|
+
argsListWired = argsListWired.join(',');
|
|
24641
|
+
var invokerFnBody = "return function (" + argsList + ") {\n";
|
|
24642
|
+
if (needsDestructorStack) {
|
|
24643
|
+
invokerFnBody += 'var destructors = [];\n';
|
|
24644
|
+
}
|
|
24645
|
+
var dtorStack = needsDestructorStack ? 'destructors' : 'null';
|
|
24646
|
+
var args1 = ['humanName', 'throwBindingError', 'invoker', 'fn', 'runDestructors', 'fromRetWire', 'toClassParamWire'];
|
|
24647
|
+
if (isClassMethodFunc) {
|
|
24648
|
+
invokerFnBody += "var thisWired = toClassParamWire(" + dtorStack + ", this);\n";
|
|
24649
|
+
}
|
|
24650
|
+
for (var i = 0; i < argCount; ++i) {
|
|
24651
|
+
var argName = "toArg" + i + "Wire";
|
|
24652
|
+
invokerFnBody += "var arg" + i + "Wired = " + argName + "(" + dtorStack + ", arg" + i + ");\n";
|
|
24653
|
+
args1.push(argName);
|
|
24654
|
+
}
|
|
24655
|
+
invokerFnBody += (returns || isAsync ? 'var rv = ' : '') + ("invoker(" + argsListWired + ");\n");
|
|
24656
|
+
if (needsDestructorStack) {
|
|
24657
|
+
invokerFnBody += 'runDestructors(destructors);\n';
|
|
24658
|
+
} else {
|
|
24659
|
+
for (var i = isClassMethodFunc ? 1 : 2; i < argTypes.length; ++i) {
|
|
24660
|
+
// Skip return value at index 0 - it's not deleted here. Also skip class type if not a method.
|
|
24661
|
+
var paramName = i === 1 ? 'thisWired' : 'arg' + (i - 2) + 'Wired';
|
|
24662
|
+
if (argTypes[i].destructorFunction !== null) {
|
|
24663
|
+
invokerFnBody += paramName + "_dtor(" + paramName + ");\n";
|
|
24664
|
+
args1.push(paramName + "_dtor");
|
|
24665
|
+
}
|
|
24666
|
+
}
|
|
24667
|
+
}
|
|
24668
|
+
if (returns) {
|
|
24669
|
+
invokerFnBody += 'var ret = fromRetWire(rv);\n' + 'return ret;\n';
|
|
24670
|
+
}
|
|
24671
|
+
invokerFnBody += '}\n';
|
|
24672
|
+
return new Function(args1, invokerFnBody);
|
|
24673
|
+
};
|
|
24674
|
+
usesDestructorStack = function _usesDestructorStack(argTypes) {
|
|
24675
|
+
// Skip return value at index 0 - it's not deleted here.
|
|
24676
|
+
for (var i = 1; i < argTypes.length; ++i) {
|
|
24677
|
+
// The type does not define a destructor function - must use dynamic stack
|
|
24678
|
+
if (argTypes[i] !== null && argTypes[i].destructorFunction === undefined) {
|
|
24679
|
+
return true;
|
|
24680
|
+
}
|
|
24681
|
+
}
|
|
24682
|
+
return false;
|
|
24683
|
+
};
|
|
24684
|
+
RegisteredPointer = function _RegisteredPointer(name, registeredClass, isReference, isConst,
|
|
24685
|
+
// smart pointer properties
|
|
24686
|
+
isSmartPointer, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor) {
|
|
24687
|
+
this.name = name;
|
|
24688
|
+
this.registeredClass = registeredClass;
|
|
24689
|
+
this.isReference = isReference;
|
|
24690
|
+
this.isConst = isConst;
|
|
24691
|
+
|
|
24692
|
+
// smart pointer properties
|
|
24693
|
+
this.isSmartPointer = isSmartPointer;
|
|
24694
|
+
this.pointeeType = pointeeType;
|
|
24695
|
+
this.sharingPolicy = sharingPolicy;
|
|
24696
|
+
this.rawGetPointee = rawGetPointee;
|
|
24697
|
+
this.rawConstructor = rawConstructor;
|
|
24698
|
+
this.rawShare = rawShare;
|
|
24699
|
+
this.rawDestructor = rawDestructor;
|
|
24700
|
+
if (!isSmartPointer && registeredClass.baseClass === undefined) {
|
|
24701
|
+
if (isConst) {
|
|
24702
|
+
this.toWireType = constNoSmartPtrRawPointerToWireType;
|
|
24703
|
+
this.destructorFunction = null;
|
|
24704
|
+
} else {
|
|
24705
|
+
this.toWireType = nonConstNoSmartPtrRawPointerToWireType;
|
|
24706
|
+
this.destructorFunction = null;
|
|
24707
|
+
}
|
|
24708
|
+
} else {
|
|
24709
|
+
this.toWireType = genericPointerToWireType;
|
|
24710
|
+
// Here we must leave this.destructorFunction undefined, since whether genericPointerToWireType returns
|
|
24711
|
+
// a pointer that needs to be freed up is runtime-dependent, and cannot be evaluated at registration time.
|
|
24712
|
+
// TODO: Create an alternative mechanism that allows removing the use of var destructors = []; array in
|
|
24713
|
+
// craftInvokerFunction altogether.
|
|
24714
|
+
}
|
|
24715
|
+
};
|
|
24716
|
+
RegisteredPointer_fromWireType = function _RegisteredPointer_fr(ptr) {
|
|
24717
|
+
// ptr is a raw pointer (or a raw smartpointer)
|
|
24718
|
+
|
|
24719
|
+
// rawPointer is a maybe-null raw pointer
|
|
24720
|
+
var rawPointer = this.getPointee(ptr);
|
|
24721
|
+
if (!rawPointer) {
|
|
24722
|
+
this.destructor(ptr);
|
|
24723
|
+
return null;
|
|
24724
|
+
}
|
|
24725
|
+
var registeredInstance = getInheritedInstance(this.registeredClass, rawPointer);
|
|
24726
|
+
if (undefined !== registeredInstance) {
|
|
24727
|
+
// JS object has been neutered, time to repopulate it
|
|
24728
|
+
if (0 === registeredInstance.$$.count.value) {
|
|
24729
|
+
registeredInstance.$$.ptr = rawPointer;
|
|
24730
|
+
registeredInstance.$$.smartPtr = ptr;
|
|
24731
|
+
return registeredInstance['clone']();
|
|
24732
|
+
} else {
|
|
24733
|
+
// else, just increment reference count on existing object
|
|
24734
|
+
// it already has a reference to the smart pointer
|
|
24735
|
+
var rv = registeredInstance['clone']();
|
|
24736
|
+
this.destructor(ptr);
|
|
24737
|
+
return rv;
|
|
24738
|
+
}
|
|
24739
|
+
}
|
|
24740
|
+
function makeDefaultHandle() {
|
|
24741
|
+
if (this.isSmartPointer) {
|
|
24742
|
+
return makeClassHandle(this.registeredClass.instancePrototype, {
|
|
24743
|
+
ptrType: this.pointeeType,
|
|
24744
|
+
ptr: rawPointer,
|
|
24745
|
+
smartPtrType: this,
|
|
24746
|
+
smartPtr: ptr
|
|
24747
|
+
});
|
|
24748
|
+
} else {
|
|
24749
|
+
return makeClassHandle(this.registeredClass.instancePrototype, {
|
|
24750
|
+
ptrType: this,
|
|
24751
|
+
ptr: ptr
|
|
24752
|
+
});
|
|
24753
|
+
}
|
|
24754
|
+
}
|
|
24755
|
+
var actualType = this.registeredClass.getActualType(rawPointer);
|
|
24756
|
+
var registeredPointerRecord = registeredPointers[actualType];
|
|
24757
|
+
if (!registeredPointerRecord) {
|
|
24758
|
+
return makeDefaultHandle.call(this);
|
|
24759
|
+
}
|
|
24760
|
+
var toType;
|
|
24761
|
+
if (this.isConst) {
|
|
24762
|
+
toType = registeredPointerRecord.constPointerType;
|
|
24763
|
+
} else {
|
|
24764
|
+
toType = registeredPointerRecord.pointerType;
|
|
24765
|
+
}
|
|
24766
|
+
var dp = _downcastPointer(rawPointer, this.registeredClass, toType.registeredClass);
|
|
24767
|
+
if (dp === null) {
|
|
24768
|
+
return makeDefaultHandle.call(this);
|
|
24769
|
+
}
|
|
24770
|
+
if (this.isSmartPointer) {
|
|
24771
|
+
return makeClassHandle(toType.registeredClass.instancePrototype, {
|
|
24772
|
+
ptrType: toType,
|
|
24773
|
+
ptr: dp,
|
|
24774
|
+
smartPtrType: this,
|
|
24775
|
+
smartPtr: ptr
|
|
24776
|
+
});
|
|
24777
|
+
} else {
|
|
24778
|
+
return makeClassHandle(toType.registeredClass.instancePrototype, {
|
|
24779
|
+
ptrType: toType,
|
|
24780
|
+
ptr: dp
|
|
24781
|
+
});
|
|
24782
|
+
}
|
|
24783
|
+
};
|
|
24784
|
+
readPointer = function _readPointer(pointer) {
|
|
24785
|
+
return this.fromWireType(HEAPU32[pointer >> 2]);
|
|
24786
|
+
};
|
|
24787
|
+
nonConstNoSmartPtrRawPointerToWireType = function _nonConstNoSmartPtrRa(destructors, handle) {
|
|
24788
|
+
if (handle === null) {
|
|
24789
|
+
if (this.isReference) {
|
|
24790
|
+
throwBindingError("null is not a valid " + this.name);
|
|
24791
|
+
}
|
|
24792
|
+
return 0;
|
|
24793
|
+
}
|
|
24794
|
+
if (!handle.$$) {
|
|
24795
|
+
throwBindingError("Cannot pass \"" + embindRepr(handle) + "\" as a " + this.name);
|
|
24796
|
+
}
|
|
24797
|
+
if (!handle.$$.ptr) {
|
|
24798
|
+
throwBindingError("Cannot pass deleted object as a pointer of type " + this.name);
|
|
24799
|
+
}
|
|
24800
|
+
if (handle.$$.ptrType.isConst) {
|
|
24801
|
+
throwBindingError("Cannot convert argument of type " + handle.$$.ptrType.name + " to parameter type " + this.name);
|
|
24802
|
+
}
|
|
24803
|
+
var handleClass = handle.$$.ptrType.registeredClass;
|
|
24804
|
+
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
24805
|
+
return ptr;
|
|
24806
|
+
};
|
|
24807
|
+
genericPointerToWireType = function _genericPointerToWire(destructors, handle) {
|
|
24808
|
+
var ptr;
|
|
24809
|
+
if (handle === null) {
|
|
24810
|
+
if (this.isReference) {
|
|
24811
|
+
throwBindingError("null is not a valid " + this.name);
|
|
24812
|
+
}
|
|
24813
|
+
if (this.isSmartPointer) {
|
|
24814
|
+
ptr = this.rawConstructor();
|
|
24815
|
+
if (destructors !== null) {
|
|
24816
|
+
destructors.push(this.rawDestructor, ptr);
|
|
24817
|
+
}
|
|
24818
|
+
return ptr;
|
|
24819
|
+
} else {
|
|
24820
|
+
return 0;
|
|
24821
|
+
}
|
|
24822
|
+
}
|
|
24823
|
+
if (!handle || !handle.$$) {
|
|
24824
|
+
throwBindingError("Cannot pass \"" + embindRepr(handle) + "\" as a " + this.name);
|
|
24825
|
+
}
|
|
24826
|
+
if (!handle.$$.ptr) {
|
|
24827
|
+
throwBindingError("Cannot pass deleted object as a pointer of type " + this.name);
|
|
24828
|
+
}
|
|
24829
|
+
if (!this.isConst && handle.$$.ptrType.isConst) {
|
|
24830
|
+
throwBindingError("Cannot convert argument of type " + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + " to parameter type " + this.name);
|
|
24831
|
+
}
|
|
24832
|
+
var handleClass = handle.$$.ptrType.registeredClass;
|
|
24833
|
+
ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
24834
|
+
if (this.isSmartPointer) {
|
|
24835
|
+
// TODO: this is not strictly true
|
|
24836
|
+
// We could support BY_EMVAL conversions from raw pointers to smart pointers
|
|
24837
|
+
// because the smart pointer can hold a reference to the handle
|
|
24838
|
+
if (undefined === handle.$$.smartPtr) {
|
|
24839
|
+
throwBindingError('Passing raw pointer to smart pointer is illegal');
|
|
24840
|
+
}
|
|
24841
|
+
switch (this.sharingPolicy) {
|
|
24842
|
+
case 0:
|
|
24843
|
+
// NONE
|
|
24844
|
+
// no upcasting
|
|
24845
|
+
if (handle.$$.smartPtrType === this) {
|
|
24846
|
+
ptr = handle.$$.smartPtr;
|
|
24847
|
+
} else {
|
|
24848
|
+
throwBindingError("Cannot convert argument of type " + (handle.$$.smartPtrType ? handle.$$.smartPtrType.name : handle.$$.ptrType.name) + " to parameter type " + this.name);
|
|
24849
|
+
}
|
|
24850
|
+
break;
|
|
24851
|
+
case 1:
|
|
24852
|
+
// INTRUSIVE
|
|
24853
|
+
ptr = handle.$$.smartPtr;
|
|
24854
|
+
break;
|
|
24855
|
+
case 2:
|
|
24856
|
+
// BY_EMVAL
|
|
24857
|
+
if (handle.$$.smartPtrType === this) {
|
|
24858
|
+
ptr = handle.$$.smartPtr;
|
|
24859
|
+
} else {
|
|
24860
|
+
var clonedHandle = handle['clone']();
|
|
24861
|
+
ptr = this.rawShare(ptr, Emval.toHandle(function () {
|
|
24862
|
+
return clonedHandle['delete']();
|
|
24863
|
+
}));
|
|
24864
|
+
if (destructors !== null) {
|
|
24865
|
+
destructors.push(this.rawDestructor, ptr);
|
|
24866
|
+
}
|
|
24867
|
+
}
|
|
24868
|
+
break;
|
|
24869
|
+
default:
|
|
24870
|
+
throwBindingError('Unsupporting sharing policy');
|
|
24871
|
+
}
|
|
24872
|
+
}
|
|
24873
|
+
return ptr;
|
|
24874
|
+
};
|
|
24875
|
+
constNoSmartPtrRawPointerToWireType = function _constNoSmartPtrRawPo(destructors, handle) {
|
|
24876
|
+
if (handle === null) {
|
|
24877
|
+
if (this.isReference) {
|
|
24878
|
+
throwBindingError("null is not a valid " + this.name);
|
|
24879
|
+
}
|
|
24880
|
+
return 0;
|
|
24881
|
+
}
|
|
24882
|
+
if (!handle.$$) {
|
|
24883
|
+
throwBindingError("Cannot pass \"" + embindRepr(handle) + "\" as a " + this.name);
|
|
24884
|
+
}
|
|
24885
|
+
if (!handle.$$.ptr) {
|
|
24886
|
+
throwBindingError("Cannot pass deleted object as a pointer of type " + this.name);
|
|
24887
|
+
}
|
|
24888
|
+
var handleClass = handle.$$.ptrType.registeredClass;
|
|
24889
|
+
var ptr = upcastPointer(handle.$$.ptr, handleClass, this.registeredClass);
|
|
24890
|
+
return ptr;
|
|
24891
|
+
};
|
|
24892
|
+
RegisteredClass = function _RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast) {
|
|
24893
|
+
this.name = name;
|
|
24894
|
+
this.constructor = constructor;
|
|
24895
|
+
this.instancePrototype = instancePrototype;
|
|
24896
|
+
this.rawDestructor = rawDestructor;
|
|
24897
|
+
this.baseClass = baseClass;
|
|
24898
|
+
this.getActualType = getActualType;
|
|
24899
|
+
this.upcast = upcast;
|
|
24900
|
+
this.downcast = downcast;
|
|
24901
|
+
this.pureVirtualFunctions = [];
|
|
24902
|
+
};
|
|
24903
|
+
ClassHandle = function _ClassHandle() {};
|
|
24904
|
+
registerType = function _registerType(rawType, registeredInstance, options) {
|
|
24905
|
+
if (options === void 0) {
|
|
24906
|
+
options = {};
|
|
24907
|
+
}
|
|
24908
|
+
return sharedRegisterType(rawType, registeredInstance, options);
|
|
24909
|
+
};
|
|
24910
|
+
sharedRegisterType = function _sharedRegisterType(rawType, registeredInstance, options) {
|
|
24911
|
+
if (options === void 0) {
|
|
24912
|
+
options = {};
|
|
24913
|
+
}
|
|
24914
|
+
var name = registeredInstance.name;
|
|
24915
|
+
if (!rawType) {
|
|
24916
|
+
throwBindingError("type \"" + name + "\" must have a positive integer typeid pointer");
|
|
24917
|
+
}
|
|
24918
|
+
if (registeredTypes.hasOwnProperty(rawType)) {
|
|
24919
|
+
if (options.ignoreDuplicateRegistrations) {
|
|
24920
|
+
return;
|
|
24921
|
+
} else {
|
|
24922
|
+
throwBindingError("Cannot register type '" + name + "' twice");
|
|
24923
|
+
}
|
|
24924
|
+
}
|
|
24925
|
+
registeredTypes[rawType] = registeredInstance;
|
|
24926
|
+
delete typeDependencies[rawType];
|
|
24927
|
+
if (awaitingDependencies.hasOwnProperty(rawType)) {
|
|
24928
|
+
var callbacks = awaitingDependencies[rawType];
|
|
24929
|
+
delete awaitingDependencies[rawType];
|
|
24930
|
+
callbacks.forEach(function (cb) {
|
|
24931
|
+
return cb();
|
|
24932
|
+
});
|
|
24933
|
+
}
|
|
24934
|
+
};
|
|
24935
|
+
_createWasm = function _createWasm3() {
|
|
24936
|
+
_createWasm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
24937
|
+
var _wasmBinaryFile;
|
|
24938
|
+
var receiveInstance, receiveInstantiationResult, info, result, exports;
|
|
24939
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
24940
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
24941
|
+
case 0:
|
|
24942
|
+
receiveInstantiationResult = function _receiveInstantiation(result) {
|
|
24943
|
+
// 'result' is a ResultObject object which has both the module and instance.
|
|
24944
|
+
// receiveInstance() will swap in the exports (to Module.asm) so they can be called
|
|
24945
|
+
// TODO: Due to Closure regression https://github.com/google/closure-compiler/issues/3193, the above line no longer optimizes out down to the following line.
|
|
24946
|
+
// When the regression is fixed, can restore the above PTHREADS-enabled path.
|
|
24947
|
+
return receiveInstance(result['instance']);
|
|
24948
|
+
};
|
|
24949
|
+
receiveInstance = function _receiveInstance(instance, module) {
|
|
24950
|
+
wasmExports = instance.exports;
|
|
24951
|
+
wasmMemory = wasmExports['memory'];
|
|
24952
|
+
updateMemoryViews();
|
|
24953
|
+
wasmTable = wasmExports['__indirect_function_table'];
|
|
24954
|
+
assignWasmExports(wasmExports);
|
|
24955
|
+
removeRunDependency();
|
|
24956
|
+
return wasmExports;
|
|
24957
|
+
}; // Load the wasm module and create an instance of using native support in the JS engine.
|
|
24958
|
+
// handle a generated wasm instance, receiving its exports and
|
|
24959
|
+
// performing other necessary setup
|
|
24960
|
+
/** @param {WebAssembly.Module=} module*/
|
|
24961
|
+
// wait for the pthread pool (if any)
|
|
24962
|
+
addRunDependency();
|
|
24963
|
+
|
|
24964
|
+
// Prefer streaming instantiation if available.
|
|
24965
|
+
info = getWasmImports();
|
|
24966
|
+
(_wasmBinaryFile = wasmBinaryFile) != null ? _wasmBinaryFile : wasmBinaryFile = findWasmBinary();
|
|
24967
|
+
_context5.next = 7;
|
|
24968
|
+
return instantiateAsync(wasmBinary, wasmBinaryFile, info);
|
|
24969
|
+
case 7:
|
|
24970
|
+
result = _context5.sent;
|
|
24971
|
+
exports = receiveInstantiationResult(result);
|
|
24972
|
+
return _context5.abrupt("return", exports);
|
|
24973
|
+
case 10:
|
|
24974
|
+
case "end":
|
|
24975
|
+
return _context5.stop();
|
|
24976
|
+
}
|
|
24977
|
+
}, _callee5);
|
|
24978
|
+
}));
|
|
24979
|
+
return _createWasm.apply(this, arguments);
|
|
24980
|
+
};
|
|
24981
|
+
createWasm = function _createWasm2() {
|
|
24982
|
+
return _createWasm.apply(this, arguments);
|
|
24983
|
+
};
|
|
24984
|
+
getWasmImports = function _getWasmImports() {
|
|
24985
|
+
// prepare imports
|
|
24986
|
+
return {
|
|
24987
|
+
env: wasmImports,
|
|
24988
|
+
wasi_snapshot_preview1: wasmImports
|
|
24989
|
+
};
|
|
24990
|
+
};
|
|
24991
|
+
_instantiateAsync = function _instantiateAsync3() {
|
|
24992
|
+
_instantiateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(binary, binaryFile, imports) {
|
|
24993
|
+
var response, instantiationResult;
|
|
24994
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
24995
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
24996
|
+
case 0:
|
|
24997
|
+
_context4.prev = 0;
|
|
24998
|
+
response = fetch(binaryFile, {
|
|
24999
|
+
credentials: 'same-origin'
|
|
25000
|
+
});
|
|
25001
|
+
_context4.next = 4;
|
|
25002
|
+
return WebAssembly.instantiateStreaming(response, imports);
|
|
25003
|
+
case 4:
|
|
25004
|
+
instantiationResult = _context4.sent;
|
|
25005
|
+
return _context4.abrupt("return", instantiationResult);
|
|
25006
|
+
case 8:
|
|
25007
|
+
_context4.prev = 8;
|
|
25008
|
+
_context4.t0 = _context4["catch"](0);
|
|
25009
|
+
// We expect the most common failure cause to be a bad MIME type for the binary,
|
|
25010
|
+
// in which case falling back to ArrayBuffer instantiation should work.
|
|
25011
|
+
err("wasm streaming compile failed: " + _context4.t0);
|
|
25012
|
+
err('falling back to ArrayBuffer instantiation');
|
|
25013
|
+
// fall back of instantiateArrayBuffer below
|
|
25014
|
+
case 12:
|
|
25015
|
+
return _context4.abrupt("return", instantiateArrayBuffer(binaryFile, imports));
|
|
25016
|
+
case 13:
|
|
25017
|
+
case "end":
|
|
25018
|
+
return _context4.stop();
|
|
25019
|
+
}
|
|
25020
|
+
}, _callee4, null, [[0, 8]]);
|
|
25021
|
+
}));
|
|
25022
|
+
return _instantiateAsync.apply(this, arguments);
|
|
25023
|
+
};
|
|
25024
|
+
instantiateAsync = function _instantiateAsync2(_x6, _x7, _x8) {
|
|
25025
|
+
return _instantiateAsync.apply(this, arguments);
|
|
25026
|
+
};
|
|
25027
|
+
_instantiateArrayBuffer = function _instantiateArrayBuff2() {
|
|
25028
|
+
_instantiateArrayBuffer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(binaryFile, imports) {
|
|
25029
|
+
var binary, instance;
|
|
25030
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
25031
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
25032
|
+
case 0:
|
|
25033
|
+
_context3.prev = 0;
|
|
25034
|
+
_context3.next = 3;
|
|
25035
|
+
return getWasmBinary(binaryFile);
|
|
25036
|
+
case 3:
|
|
25037
|
+
binary = _context3.sent;
|
|
25038
|
+
_context3.next = 6;
|
|
25039
|
+
return WebAssembly.instantiate(binary, imports);
|
|
25040
|
+
case 6:
|
|
25041
|
+
instance = _context3.sent;
|
|
25042
|
+
return _context3.abrupt("return", instance);
|
|
25043
|
+
case 10:
|
|
25044
|
+
_context3.prev = 10;
|
|
25045
|
+
_context3.t0 = _context3["catch"](0);
|
|
25046
|
+
err("failed to asynchronously prepare wasm: " + _context3.t0);
|
|
25047
|
+
abort(_context3.t0);
|
|
25048
|
+
case 14:
|
|
25049
|
+
case "end":
|
|
25050
|
+
return _context3.stop();
|
|
25051
|
+
}
|
|
25052
|
+
}, _callee3, null, [[0, 10]]);
|
|
25053
|
+
}));
|
|
25054
|
+
return _instantiateArrayBuffer.apply(this, arguments);
|
|
25055
|
+
};
|
|
25056
|
+
instantiateArrayBuffer = function _instantiateArrayBuff(_x4, _x5) {
|
|
25057
|
+
return _instantiateArrayBuffer.apply(this, arguments);
|
|
25058
|
+
};
|
|
25059
|
+
_getWasmBinary = function _getWasmBinary3() {
|
|
25060
|
+
_getWasmBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(binaryFile) {
|
|
25061
|
+
var response;
|
|
25062
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
25063
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
25064
|
+
case 0:
|
|
25065
|
+
_context2.prev = 0;
|
|
25066
|
+
_context2.next = 3;
|
|
25067
|
+
return readAsync(binaryFile);
|
|
25068
|
+
case 3:
|
|
25069
|
+
response = _context2.sent;
|
|
25070
|
+
return _context2.abrupt("return", new Uint8Array(response));
|
|
25071
|
+
case 7:
|
|
25072
|
+
_context2.prev = 7;
|
|
25073
|
+
_context2.t0 = _context2["catch"](0);
|
|
25074
|
+
case 9:
|
|
25075
|
+
return _context2.abrupt("return", getBinarySync());
|
|
25076
|
+
case 10:
|
|
25077
|
+
case "end":
|
|
25078
|
+
return _context2.stop();
|
|
25079
|
+
}
|
|
25080
|
+
}, _callee2, null, [[0, 7]]);
|
|
25081
|
+
}));
|
|
25082
|
+
return _getWasmBinary.apply(this, arguments);
|
|
25083
|
+
};
|
|
25084
|
+
getWasmBinary = function _getWasmBinary2(_x3) {
|
|
25085
|
+
return _getWasmBinary.apply(this, arguments);
|
|
25086
|
+
};
|
|
25087
|
+
getBinarySync = function _getBinarySync(file) {
|
|
25088
|
+
throw 'both async and sync fetching of the wasm failed';
|
|
25089
|
+
};
|
|
25090
|
+
findWasmBinary = function _findWasmBinary() {
|
|
25091
|
+
if (Module['locateFile']) {
|
|
25092
|
+
return locateFile('MediaInfoModule.wasm');
|
|
25093
|
+
}
|
|
25094
|
+
// Use bundler-friendly `new URL(..., import.meta.url)` pattern; works in browsers too.
|
|
25095
|
+
return new URL('MediaInfoModule.wasm', (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('sdk2.umd.development.js', document.baseURI).href))).href;
|
|
25096
|
+
};
|
|
25097
|
+
abort = function _abort(what) {
|
|
25098
|
+
what = 'Aborted(' + what + ')';
|
|
25099
|
+
// TODO(sbc): Should we remove printing and leave it up to whoever
|
|
25100
|
+
// catches the exception?
|
|
25101
|
+
err(what);
|
|
25102
|
+
ABORT = true;
|
|
25103
|
+
what += '. Build with -sASSERTIONS for more info.';
|
|
25104
|
+
|
|
25105
|
+
// Use a wasm runtime error, because a JS error might be seen as a foreign
|
|
25106
|
+
// exception, which means we'd run destructors on it. We need the error to
|
|
25107
|
+
// simply make the program stop.
|
|
25108
|
+
// FIXME This approach does not work in Wasm EH because it currently does not assume
|
|
25109
|
+
// all RuntimeErrors are from traps; it decides whether a RuntimeError is from
|
|
25110
|
+
// a trap or not based on a hidden field within the object. So at the moment
|
|
25111
|
+
// we don't have a way of throwing a wasm trap from JS. TODO Make a JS API that
|
|
25112
|
+
// allows this in the wasm spec.
|
|
25113
|
+
|
|
25114
|
+
// Suppress closure compiler warning here. Closure compiler's builtin extern
|
|
25115
|
+
// definition for WebAssembly.RuntimeError claims it takes no arguments even
|
|
25116
|
+
// though it can.
|
|
25117
|
+
// TODO(https://github.com/google/closure-compiler/pull/3913): Remove if/when upstream closure gets fixed.
|
|
25118
|
+
/** @suppress {checkTypes} */
|
|
25119
|
+
var e = new WebAssembly.RuntimeError(what);
|
|
25120
|
+
readyPromiseReject == null || readyPromiseReject(e);
|
|
25121
|
+
// Throw the error whether or not MODULARIZE is set because abort is used
|
|
25122
|
+
// in code paths apart from instantiation where an exception is expected
|
|
25123
|
+
// to be thrown when abort is called.
|
|
25124
|
+
throw e;
|
|
25125
|
+
};
|
|
25126
|
+
removeRunDependency = function _removeRunDependency(id) {
|
|
25127
|
+
runDependencies--;
|
|
25128
|
+
if (runDependencies == 0) {
|
|
25129
|
+
if (dependenciesFulfilled) {
|
|
25130
|
+
var callback = dependenciesFulfilled;
|
|
25131
|
+
dependenciesFulfilled = null;
|
|
25132
|
+
callback(); // can add another dependenciesFulfilled
|
|
25133
|
+
}
|
|
25134
|
+
}
|
|
25135
|
+
};
|
|
25136
|
+
addRunDependency = function _addRunDependency(id) {
|
|
25137
|
+
runDependencies++;
|
|
25138
|
+
};
|
|
25139
|
+
initRuntime = function _initRuntime() {
|
|
25140
|
+
runtimeInitialized = true;
|
|
25141
|
+
|
|
25142
|
+
// No ATINITS hooks
|
|
25143
|
+
|
|
25144
|
+
wasmExports['__wasm_call_ctors']();
|
|
25145
|
+
|
|
25146
|
+
// No ATPOSTCTORS hooks
|
|
25147
|
+
};
|
|
25148
|
+
updateMemoryViews = function _updateMemoryViews() {
|
|
25149
|
+
var b = wasmMemory.buffer;
|
|
25150
|
+
HEAP8 = new Int8Array(b);
|
|
25151
|
+
HEAP16 = new Int16Array(b);
|
|
25152
|
+
HEAPU8 = new Uint8Array(b);
|
|
25153
|
+
HEAPU16 = new Uint16Array(b);
|
|
25154
|
+
HEAP32 = new Int32Array(b);
|
|
25155
|
+
HEAPU32 = new Uint32Array(b);
|
|
25156
|
+
HEAPF32 = new Float32Array(b);
|
|
25157
|
+
HEAPF64 = new Float64Array(b);
|
|
25158
|
+
HEAP64 = new BigInt64Array(b);
|
|
25159
|
+
HEAPU64 = new BigUint64Array(b);
|
|
25160
|
+
};
|
|
25161
|
+
locateFile = function _locateFile(path) {
|
|
25162
|
+
if (Module['locateFile']) {
|
|
25163
|
+
return Module['locateFile'](path, scriptDirectory);
|
|
25164
|
+
}
|
|
25165
|
+
return scriptDirectory + path;
|
|
25166
|
+
};
|
|
25167
|
+
if (moduleArg === void 0) {
|
|
25168
|
+
moduleArg = {};
|
|
25169
|
+
}
|
|
25170
|
+
// include: shell.js
|
|
25171
|
+
// The Module object: Our interface to the outside world. We import
|
|
25172
|
+
// and export values on it. There are various ways Module can be used:
|
|
25173
|
+
// 1. Not defined. We create it here
|
|
25174
|
+
// 2. A function parameter, function(moduleArg) => Promise<Module>
|
|
25175
|
+
// 3. pre-run appended it, var Module = {}; ..generated code..
|
|
25176
|
+
// 4. External script tag defines var Module.
|
|
25177
|
+
// We need to check if Module already exists (e.g. case 3 above).
|
|
25178
|
+
// Substitution will be replaced with actual code on later stage of the build,
|
|
25179
|
+
// this way Closure Compiler will not mangle it (e.g. case 4. above).
|
|
25180
|
+
// Note that if you want to run closure, and also to use Module
|
|
25181
|
+
// after the generated code, you will need to define var Module = {};
|
|
25182
|
+
// before the code. Then that object will be used in the code, and you
|
|
25183
|
+
// can continue to use Module afterwards as well.
|
|
25184
|
+
Module = moduleArg;
|
|
25185
|
+
thisProgram = './this.program';
|
|
25186
|
+
_scriptName = (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('sdk2.umd.development.js', document.baseURI).href)); // `/` should be present at the end if `scriptDirectory` is not empty
|
|
25187
|
+
scriptDirectory = ''; // Hooks that are implemented differently in different runtime environments.
|
|
25188
|
+
try {
|
|
25189
|
+
scriptDirectory = new URL('.', _scriptName).href; // includes trailing slash
|
|
25190
|
+
} catch (_unused2) {
|
|
25191
|
+
// Must be a `blob:` or `data:` URL (e.g. `blob:http://site.com/etc/etc`), we cannot
|
|
25192
|
+
// infer anything from them.
|
|
25193
|
+
}
|
|
25194
|
+
// include: web_or_worker_shell_read.js
|
|
25195
|
+
readAsync = /*#__PURE__*/function () {
|
|
25196
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(url) {
|
|
25197
|
+
var response;
|
|
25198
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
25199
|
+
while (1) switch (_context.prev = _context.next) {
|
|
25200
|
+
case 0:
|
|
25201
|
+
_context.next = 2;
|
|
25202
|
+
return fetch(url, {
|
|
25203
|
+
credentials: 'same-origin'
|
|
25204
|
+
});
|
|
25205
|
+
case 2:
|
|
25206
|
+
response = _context.sent;
|
|
25207
|
+
if (!response.ok) {
|
|
25208
|
+
_context.next = 5;
|
|
25209
|
+
break;
|
|
25210
|
+
}
|
|
25211
|
+
return _context.abrupt("return", response.arrayBuffer());
|
|
25212
|
+
case 5:
|
|
25213
|
+
throw new Error(response.status + ' : ' + response.url);
|
|
25214
|
+
case 6:
|
|
25215
|
+
case "end":
|
|
25216
|
+
return _context.stop();
|
|
25217
|
+
}
|
|
25218
|
+
}, _callee);
|
|
25219
|
+
}));
|
|
25220
|
+
return function readAsync(_x2) {
|
|
25221
|
+
return _ref.apply(this, arguments);
|
|
25222
|
+
};
|
|
25223
|
+
}();
|
|
25224
|
+
// end include: web_or_worker_shell_read.js
|
|
25225
|
+
out = console.log.bind(console);
|
|
25226
|
+
err = console.error.bind(console); // end include: shell.js
|
|
25227
|
+
// include: preamble.js
|
|
25228
|
+
// === Preamble library stuff ===
|
|
25229
|
+
// Documentation for the public APIs defined in this file must be updated in:
|
|
25230
|
+
// site/source/docs/api_reference/preamble.js.rst
|
|
25231
|
+
// A prebuilt local version of the documentation is available at:
|
|
25232
|
+
// site/build/text/docs/api_reference/preamble.js.txt
|
|
25233
|
+
// You can also build docs locally as HTML or other formats in site/
|
|
25234
|
+
// An online HTML version (which may be of a different version of Emscripten)
|
|
25235
|
+
// is up at http://kripken.github.io/emscripten-site/docs/api_reference/preamble.js.html
|
|
25236
|
+
// Wasm globals
|
|
25237
|
+
//========================================
|
|
25238
|
+
// Runtime essentials
|
|
25239
|
+
//========================================
|
|
25240
|
+
// whether we are quitting the application. no code should run after this.
|
|
25241
|
+
// set in exit() and abort()
|
|
25242
|
+
ABORT = false; // include: runtime_common.js
|
|
25243
|
+
// include: runtime_stack_check.js
|
|
25244
|
+
// end include: runtime_stack_check.js
|
|
25245
|
+
// include: runtime_exceptions.js
|
|
25246
|
+
// end include: runtime_exceptions.js
|
|
25247
|
+
// include: runtime_debug.js
|
|
25248
|
+
// end include: runtime_debug.js
|
|
25249
|
+
// Memory management
|
|
25250
|
+
// BigInt64Array type is not correctly defined in closure
|
|
25251
|
+
runtimeInitialized = false;
|
|
25252
|
+
// A counter of dependencies for calling run(). If we need to
|
|
25253
|
+
// do asynchronous work before running, increment this and
|
|
25254
|
+
// decrement it. Incrementing must happen in a place like
|
|
25255
|
+
// Module.preRun (used by emcc to add file preloading).
|
|
25256
|
+
// Note that you can add dependencies in preRun, even though
|
|
25257
|
+
// it happens right before run - run will be postponed until
|
|
25258
|
+
// the dependencies are met.
|
|
25259
|
+
runDependencies = 0;
|
|
25260
|
+
dependenciesFulfilled = null; // overridden to take different actions when all run dependencies are fulfilled
|
|
25261
|
+
/** @param {string|number=} what */
|
|
25262
|
+
// Create the wasm instance.
|
|
25263
|
+
// Receives the wasm imports, returns the exports.
|
|
25264
|
+
__abort_js = function __abort_js() {
|
|
25265
|
+
return abort('');
|
|
25266
|
+
};
|
|
25267
|
+
AsciiToString = function AsciiToString(ptr) {
|
|
25268
|
+
var str = '';
|
|
25269
|
+
while (1) {
|
|
25270
|
+
var ch = HEAPU8[ptr++];
|
|
25271
|
+
if (!ch) return str;
|
|
25272
|
+
str += String.fromCharCode(ch);
|
|
25273
|
+
}
|
|
25274
|
+
};
|
|
25275
|
+
awaitingDependencies = {};
|
|
25276
|
+
registeredTypes = {};
|
|
25277
|
+
typeDependencies = {};
|
|
25278
|
+
BindingError = /*#__PURE__*/function (_Error) {
|
|
25279
|
+
function BindingError(message) {
|
|
25280
|
+
var _this2;
|
|
25281
|
+
_this2 = _Error.call(this, message) || this;
|
|
25282
|
+
_this2.name = 'BindingError';
|
|
25283
|
+
return _this2;
|
|
25284
|
+
}
|
|
25285
|
+
_inheritsLoose(BindingError, _Error);
|
|
25286
|
+
return BindingError;
|
|
25287
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
25288
|
+
throwBindingError = function throwBindingError(message) {
|
|
25289
|
+
throw new BindingError(message);
|
|
25290
|
+
};
|
|
25291
|
+
/** @param {Object=} options */
|
|
25292
|
+
/** @param {Object=} options */
|
|
25293
|
+
integerReadValueFromPointer = function integerReadValueFromPointer(name, width, signed) {
|
|
25294
|
+
// integers are quite common, so generate very specialized functions
|
|
25295
|
+
switch (width) {
|
|
25296
|
+
case 1:
|
|
25297
|
+
return signed ? function (pointer) {
|
|
25298
|
+
return HEAP8[pointer];
|
|
25299
|
+
} : function (pointer) {
|
|
25300
|
+
return HEAPU8[pointer];
|
|
25301
|
+
};
|
|
25302
|
+
case 2:
|
|
25303
|
+
return signed ? function (pointer) {
|
|
25304
|
+
return HEAP16[pointer >> 1];
|
|
25305
|
+
} : function (pointer) {
|
|
25306
|
+
return HEAPU16[pointer >> 1];
|
|
25307
|
+
};
|
|
25308
|
+
case 4:
|
|
25309
|
+
return signed ? function (pointer) {
|
|
25310
|
+
return HEAP32[pointer >> 2];
|
|
25311
|
+
} : function (pointer) {
|
|
25312
|
+
return HEAPU32[pointer >> 2];
|
|
25313
|
+
};
|
|
25314
|
+
case 8:
|
|
25315
|
+
return signed ? function (pointer) {
|
|
25316
|
+
return HEAP64[pointer >> 3];
|
|
25317
|
+
} : function (pointer) {
|
|
25318
|
+
return HEAPU64[pointer >> 3];
|
|
25319
|
+
};
|
|
25320
|
+
default:
|
|
25321
|
+
throw new TypeError("invalid integer width (" + width + "): " + name);
|
|
25322
|
+
}
|
|
25323
|
+
};
|
|
25324
|
+
/** @suppress {globalThis} */
|
|
25325
|
+
__embind_register_bigint = function __embind_register_bigint(primitiveType, name, size, minRange, maxRange) {
|
|
25326
|
+
name = AsciiToString(name);
|
|
25327
|
+
var isUnsignedType = minRange === 0n;
|
|
25328
|
+
var fromWireType = function fromWireType(value) {
|
|
25329
|
+
return value;
|
|
25330
|
+
};
|
|
25331
|
+
if (isUnsignedType) {
|
|
25332
|
+
// uint64 get converted to int64 in ABI, fix them up like we do for 32-bit integers.
|
|
25333
|
+
var bitSize = size * 8;
|
|
25334
|
+
fromWireType = function fromWireType(value) {
|
|
25335
|
+
return BigInt.asUintN(bitSize, value);
|
|
25336
|
+
};
|
|
25337
|
+
maxRange = fromWireType(maxRange);
|
|
25338
|
+
}
|
|
25339
|
+
registerType(primitiveType, {
|
|
25340
|
+
name: name,
|
|
25341
|
+
fromWireType: fromWireType,
|
|
25342
|
+
toWireType: function toWireType(destructors, value) {
|
|
25343
|
+
if (typeof value == 'number') {
|
|
25344
|
+
value = BigInt(value);
|
|
25345
|
+
}
|
|
25346
|
+
return value;
|
|
25347
|
+
},
|
|
25348
|
+
readValueFromPointer: integerReadValueFromPointer(name, size, !isUnsignedType),
|
|
25349
|
+
destructorFunction: null // This type does not need a destructor
|
|
25350
|
+
});
|
|
25351
|
+
};
|
|
25352
|
+
/** @suppress {globalThis} */
|
|
25353
|
+
__embind_register_bool = function __embind_register_bool(rawType, name, trueValue, falseValue) {
|
|
25354
|
+
name = AsciiToString(name);
|
|
25355
|
+
registerType(rawType, {
|
|
25356
|
+
name: name,
|
|
25357
|
+
fromWireType: function fromWireType(wt) {
|
|
25358
|
+
// ambiguous emscripten ABI: sometimes return values are
|
|
25359
|
+
// true or false, and sometimes integers (0 or 1)
|
|
25360
|
+
return !!wt;
|
|
25361
|
+
},
|
|
25362
|
+
toWireType: function toWireType(destructors, o) {
|
|
25363
|
+
return o ? trueValue : falseValue;
|
|
25364
|
+
},
|
|
25365
|
+
readValueFromPointer: function readValueFromPointer(pointer) {
|
|
25366
|
+
return this.fromWireType(HEAPU8[pointer]);
|
|
25367
|
+
},
|
|
25368
|
+
destructorFunction: null // This type does not need a destructor
|
|
25369
|
+
});
|
|
25370
|
+
};
|
|
25371
|
+
shallowCopyInternalPointer = function shallowCopyInternalPointer(o) {
|
|
25372
|
+
return {
|
|
25373
|
+
count: o.count,
|
|
25374
|
+
deleteScheduled: o.deleteScheduled,
|
|
25375
|
+
preservePointerOnDelete: o.preservePointerOnDelete,
|
|
25376
|
+
ptr: o.ptr,
|
|
25377
|
+
ptrType: o.ptrType,
|
|
25378
|
+
smartPtr: o.smartPtr,
|
|
25379
|
+
smartPtrType: o.smartPtrType
|
|
25380
|
+
};
|
|
25381
|
+
};
|
|
25382
|
+
throwInstanceAlreadyDeleted = function throwInstanceAlreadyDeleted(obj) {
|
|
25383
|
+
function getInstanceTypeName(handle) {
|
|
25384
|
+
return handle.$$.ptrType.registeredClass.name;
|
|
25385
|
+
}
|
|
25386
|
+
throwBindingError(getInstanceTypeName(obj) + ' instance already deleted');
|
|
25387
|
+
};
|
|
25388
|
+
finalizationRegistry = false;
|
|
25389
|
+
detachFinalizer = function detachFinalizer(handle) {};
|
|
25390
|
+
runDestructor = function runDestructor($$) {
|
|
25391
|
+
if ($$.smartPtr) {
|
|
25392
|
+
$$.smartPtrType.rawDestructor($$.smartPtr);
|
|
25393
|
+
} else {
|
|
25394
|
+
$$.ptrType.registeredClass.rawDestructor($$.ptr);
|
|
25395
|
+
}
|
|
25396
|
+
};
|
|
25397
|
+
releaseClassHandle = function releaseClassHandle($$) {
|
|
25398
|
+
$$.count.value -= 1;
|
|
25399
|
+
var toDelete = 0 === $$.count.value;
|
|
25400
|
+
if (toDelete) {
|
|
25401
|
+
runDestructor($$);
|
|
25402
|
+
}
|
|
25403
|
+
};
|
|
25404
|
+
_attachFinalizer = function attachFinalizer(handle) {
|
|
25405
|
+
if ('undefined' === typeof FinalizationRegistry) {
|
|
25406
|
+
_attachFinalizer = function attachFinalizer(handle) {
|
|
25407
|
+
return handle;
|
|
25408
|
+
};
|
|
25409
|
+
return handle;
|
|
25410
|
+
}
|
|
25411
|
+
// If the running environment has a FinalizationRegistry (see
|
|
25412
|
+
// https://github.com/tc39/proposal-weakrefs), then attach finalizers
|
|
25413
|
+
// for class handles. We check for the presence of FinalizationRegistry
|
|
25414
|
+
// at run-time, not build-time.
|
|
25415
|
+
finalizationRegistry = new FinalizationRegistry(function (info) {
|
|
25416
|
+
releaseClassHandle(info.$$);
|
|
25417
|
+
});
|
|
25418
|
+
_attachFinalizer = function attachFinalizer(handle) {
|
|
25419
|
+
var $$ = handle.$$;
|
|
25420
|
+
var hasSmartPtr = !!$$.smartPtr;
|
|
25421
|
+
if (hasSmartPtr) {
|
|
25422
|
+
// We should not call the destructor on raw pointers in case other code expects the pointee to live
|
|
25423
|
+
var info = {
|
|
25424
|
+
$$: $$
|
|
25425
|
+
};
|
|
25426
|
+
finalizationRegistry.register(handle, info, handle);
|
|
25427
|
+
}
|
|
25428
|
+
return handle;
|
|
25429
|
+
};
|
|
25430
|
+
detachFinalizer = function detachFinalizer(handle) {
|
|
25431
|
+
return finalizationRegistry.unregister(handle);
|
|
25432
|
+
};
|
|
25433
|
+
return _attachFinalizer(handle);
|
|
25434
|
+
};
|
|
25435
|
+
init_ClassHandle = function init_ClassHandle() {
|
|
25436
|
+
var proto = ClassHandle.prototype;
|
|
25437
|
+
Object.assign(proto, {
|
|
25438
|
+
isAliasOf: function isAliasOf(other) {
|
|
25439
|
+
if (!(this instanceof ClassHandle)) {
|
|
25440
|
+
return false;
|
|
25441
|
+
}
|
|
25442
|
+
if (!(other instanceof ClassHandle)) {
|
|
25443
|
+
return false;
|
|
25444
|
+
}
|
|
25445
|
+
var leftClass = this.$$.ptrType.registeredClass;
|
|
25446
|
+
var left = this.$$.ptr;
|
|
25447
|
+
other.$$ = /** @type {Object} */other.$$;
|
|
25448
|
+
var rightClass = other.$$.ptrType.registeredClass;
|
|
25449
|
+
var right = other.$$.ptr;
|
|
25450
|
+
while (leftClass.baseClass) {
|
|
25451
|
+
left = leftClass.upcast(left);
|
|
25452
|
+
leftClass = leftClass.baseClass;
|
|
25453
|
+
}
|
|
25454
|
+
while (rightClass.baseClass) {
|
|
25455
|
+
right = rightClass.upcast(right);
|
|
25456
|
+
rightClass = rightClass.baseClass;
|
|
25457
|
+
}
|
|
25458
|
+
return leftClass === rightClass && left === right;
|
|
25459
|
+
},
|
|
25460
|
+
clone: function clone() {
|
|
25461
|
+
if (!this.$$.ptr) {
|
|
25462
|
+
throwInstanceAlreadyDeleted(this);
|
|
25463
|
+
}
|
|
25464
|
+
if (this.$$.preservePointerOnDelete) {
|
|
25465
|
+
this.$$.count.value += 1;
|
|
25466
|
+
return this;
|
|
25467
|
+
} else {
|
|
25468
|
+
var clone = _attachFinalizer(Object.create(Object.getPrototypeOf(this), {
|
|
25469
|
+
$$: {
|
|
25470
|
+
value: shallowCopyInternalPointer(this.$$)
|
|
25471
|
+
}
|
|
25472
|
+
}));
|
|
25473
|
+
clone.$$.count.value += 1;
|
|
25474
|
+
clone.$$.deleteScheduled = false;
|
|
25475
|
+
return clone;
|
|
25476
|
+
}
|
|
25477
|
+
},
|
|
25478
|
+
"delete": function _delete() {
|
|
25479
|
+
if (!this.$$.ptr) {
|
|
25480
|
+
throwInstanceAlreadyDeleted(this);
|
|
25481
|
+
}
|
|
25482
|
+
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
|
25483
|
+
throwBindingError('Object already scheduled for deletion');
|
|
25484
|
+
}
|
|
25485
|
+
detachFinalizer(this);
|
|
25486
|
+
releaseClassHandle(this.$$);
|
|
25487
|
+
if (!this.$$.preservePointerOnDelete) {
|
|
25488
|
+
this.$$.smartPtr = undefined;
|
|
25489
|
+
this.$$.ptr = undefined;
|
|
25490
|
+
}
|
|
25491
|
+
},
|
|
25492
|
+
isDeleted: function isDeleted() {
|
|
25493
|
+
return !this.$$.ptr;
|
|
25494
|
+
},
|
|
25495
|
+
deleteLater: function deleteLater() {
|
|
25496
|
+
if (!this.$$.ptr) {
|
|
25497
|
+
throwInstanceAlreadyDeleted(this);
|
|
25498
|
+
}
|
|
25499
|
+
if (this.$$.deleteScheduled && !this.$$.preservePointerOnDelete) {
|
|
25500
|
+
throwBindingError('Object already scheduled for deletion');
|
|
25501
|
+
}
|
|
25502
|
+
this.$$.deleteScheduled = true;
|
|
25503
|
+
return this;
|
|
25504
|
+
}
|
|
25505
|
+
});
|
|
25506
|
+
|
|
25507
|
+
// Support `using ...` from https://github.com/tc39/proposal-explicit-resource-management.
|
|
25508
|
+
var symbolDispose = Symbol.dispose;
|
|
25509
|
+
if (symbolDispose) {
|
|
25510
|
+
proto[symbolDispose] = proto['delete'];
|
|
25511
|
+
}
|
|
25512
|
+
};
|
|
25513
|
+
/** @constructor */
|
|
25514
|
+
createNamedFunction = function createNamedFunction(name, func) {
|
|
25515
|
+
return Object.defineProperty(func, 'name', {
|
|
25516
|
+
value: name
|
|
25517
|
+
});
|
|
25518
|
+
};
|
|
25519
|
+
registeredPointers = {};
|
|
25520
|
+
ensureOverloadTable = function ensureOverloadTable(proto, methodName, humanName) {
|
|
25521
|
+
if (undefined === proto[methodName].overloadTable) {
|
|
25522
|
+
var prevFunc = proto[methodName];
|
|
25523
|
+
// Inject an overload resolver function that routes to the appropriate overload based on the number of arguments.
|
|
25524
|
+
proto[methodName] = function () {
|
|
25525
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25526
|
+
args[_key] = arguments[_key];
|
|
25527
|
+
}
|
|
25528
|
+
// TODO This check can be removed in -O3 level "unsafe" optimizations.
|
|
25529
|
+
if (!proto[methodName].overloadTable.hasOwnProperty(args.length)) {
|
|
25530
|
+
throwBindingError("Function '" + humanName + "' called with an invalid number of arguments (" + args.length + ") - expects one of (" + proto[methodName].overloadTable + ")!");
|
|
25531
|
+
}
|
|
25532
|
+
return proto[methodName].overloadTable[args.length].apply(this, args);
|
|
25533
|
+
};
|
|
25534
|
+
// Move the previous function into the overload table.
|
|
25535
|
+
proto[methodName].overloadTable = [];
|
|
25536
|
+
proto[methodName].overloadTable[prevFunc.argCount] = prevFunc;
|
|
25537
|
+
}
|
|
25538
|
+
};
|
|
25539
|
+
/** @param {number=} numArguments */
|
|
25540
|
+
exposePublicSymbol = function exposePublicSymbol(name, value, numArguments) {
|
|
25541
|
+
if (Module.hasOwnProperty(name)) {
|
|
25542
|
+
{
|
|
25543
|
+
throwBindingError("Cannot register public name '" + name + "' twice");
|
|
25544
|
+
}
|
|
25545
|
+
|
|
25546
|
+
// We are exposing a function with the same name as an existing function. Create an overload table and a function selector
|
|
25547
|
+
// that routes between the two.
|
|
25548
|
+
ensureOverloadTable(Module, name, name);
|
|
25549
|
+
if (Module[name].overloadTable.hasOwnProperty(numArguments)) {
|
|
25550
|
+
throwBindingError("Cannot register multiple overloads of a function with the same number of arguments (" + numArguments + ")!");
|
|
25551
|
+
}
|
|
25552
|
+
// Add the new function into the overload table.
|
|
25553
|
+
Module[name].overloadTable[numArguments] = value;
|
|
25554
|
+
} else {
|
|
25555
|
+
Module[name] = value;
|
|
25556
|
+
Module[name].argCount = numArguments;
|
|
25557
|
+
}
|
|
25558
|
+
};
|
|
25559
|
+
char_0 = 48;
|
|
25560
|
+
char_9 = 57;
|
|
25561
|
+
makeLegalFunctionName = function makeLegalFunctionName(name) {
|
|
25562
|
+
name = name.replace(/[^a-zA-Z0-9_]/g, '$');
|
|
25563
|
+
var f = name.charCodeAt(0);
|
|
25564
|
+
if (f >= char_0 && f <= char_9) {
|
|
25565
|
+
return "_" + name;
|
|
25566
|
+
}
|
|
25567
|
+
return name;
|
|
25568
|
+
};
|
|
25569
|
+
/** @constructor */
|
|
25570
|
+
upcastPointer = function upcastPointer(ptr, ptrClass, desiredClass) {
|
|
25571
|
+
while (ptrClass !== desiredClass) {
|
|
25572
|
+
if (!ptrClass.upcast) {
|
|
25573
|
+
throwBindingError("Expected null or instance of " + desiredClass.name + ", got an instance of " + ptrClass.name);
|
|
25574
|
+
}
|
|
25575
|
+
ptr = ptrClass.upcast(ptr);
|
|
25576
|
+
ptrClass = ptrClass.baseClass;
|
|
25577
|
+
}
|
|
25578
|
+
return ptr;
|
|
25579
|
+
};
|
|
25580
|
+
embindRepr = function embindRepr(v) {
|
|
25581
|
+
if (v === null) {
|
|
25582
|
+
return 'null';
|
|
25583
|
+
}
|
|
25584
|
+
var t = typeof v;
|
|
25585
|
+
if (t === 'object' || t === 'array' || t === 'function') {
|
|
25586
|
+
return v.toString();
|
|
25587
|
+
} else {
|
|
25588
|
+
return '' + v;
|
|
25589
|
+
}
|
|
25590
|
+
};
|
|
25591
|
+
/** @suppress {globalThis} */
|
|
25592
|
+
/** @suppress {globalThis} */
|
|
25593
|
+
/** @suppress {globalThis} */
|
|
25594
|
+
/** @suppress {globalThis} */
|
|
25595
|
+
_downcastPointer = function downcastPointer(ptr, ptrClass, desiredClass) {
|
|
25596
|
+
if (ptrClass === desiredClass) {
|
|
25597
|
+
return ptr;
|
|
25598
|
+
}
|
|
25599
|
+
if (undefined === desiredClass.baseClass) {
|
|
25600
|
+
return null; // no conversion
|
|
25601
|
+
}
|
|
25602
|
+
var rv = _downcastPointer(ptr, ptrClass, desiredClass.baseClass);
|
|
25603
|
+
if (rv === null) {
|
|
25604
|
+
return null;
|
|
25605
|
+
}
|
|
25606
|
+
return desiredClass.downcast(rv);
|
|
25607
|
+
};
|
|
25608
|
+
registeredInstances = {};
|
|
25609
|
+
getBasestPointer = function getBasestPointer(class_, ptr) {
|
|
25610
|
+
if (ptr === undefined) {
|
|
25611
|
+
throwBindingError('ptr should not be undefined');
|
|
25612
|
+
}
|
|
25613
|
+
while (class_.baseClass) {
|
|
25614
|
+
ptr = class_.upcast(ptr);
|
|
25615
|
+
class_ = class_.baseClass;
|
|
25616
|
+
}
|
|
25617
|
+
return ptr;
|
|
25618
|
+
};
|
|
25619
|
+
getInheritedInstance = function getInheritedInstance(class_, ptr) {
|
|
25620
|
+
ptr = getBasestPointer(class_, ptr);
|
|
25621
|
+
return registeredInstances[ptr];
|
|
25622
|
+
};
|
|
25623
|
+
InternalError = /*#__PURE__*/function (_Error2) {
|
|
25624
|
+
function InternalError(message) {
|
|
25625
|
+
var _this3;
|
|
25626
|
+
_this3 = _Error2.call(this, message) || this;
|
|
25627
|
+
_this3.name = 'InternalError';
|
|
25628
|
+
return _this3;
|
|
25629
|
+
}
|
|
25630
|
+
_inheritsLoose(InternalError, _Error2);
|
|
25631
|
+
return InternalError;
|
|
25632
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
25633
|
+
throwInternalError = function throwInternalError(message) {
|
|
25634
|
+
throw new InternalError(message);
|
|
25635
|
+
};
|
|
25636
|
+
makeClassHandle = function makeClassHandle(prototype, record) {
|
|
25637
|
+
if (!record.ptrType || !record.ptr) {
|
|
25638
|
+
throwInternalError('makeClassHandle requires ptr and ptrType');
|
|
25639
|
+
}
|
|
25640
|
+
var hasSmartPtrType = !!record.smartPtrType;
|
|
25641
|
+
var hasSmartPtr = !!record.smartPtr;
|
|
25642
|
+
if (hasSmartPtrType !== hasSmartPtr) {
|
|
25643
|
+
throwInternalError('Both smartPtrType and smartPtr must be specified');
|
|
25644
|
+
}
|
|
25645
|
+
record.count = {
|
|
25646
|
+
value: 1
|
|
25647
|
+
};
|
|
25648
|
+
return _attachFinalizer(Object.create(prototype, {
|
|
25649
|
+
$$: {
|
|
25650
|
+
value: record,
|
|
25651
|
+
writable: true
|
|
25652
|
+
}
|
|
25653
|
+
}));
|
|
25654
|
+
};
|
|
25655
|
+
/** @suppress {globalThis} */
|
|
25656
|
+
init_RegisteredPointer = function init_RegisteredPointer() {
|
|
25657
|
+
Object.assign(RegisteredPointer.prototype, {
|
|
25658
|
+
getPointee: function getPointee(ptr) {
|
|
25659
|
+
if (this.rawGetPointee) {
|
|
25660
|
+
ptr = this.rawGetPointee(ptr);
|
|
25661
|
+
}
|
|
25662
|
+
return ptr;
|
|
25663
|
+
},
|
|
25664
|
+
destructor: function destructor(ptr) {
|
|
25665
|
+
var _this$rawDestructor;
|
|
25666
|
+
(_this$rawDestructor = this.rawDestructor) == null || _this$rawDestructor.call(this, ptr);
|
|
25667
|
+
},
|
|
25668
|
+
readValueFromPointer: readPointer,
|
|
25669
|
+
fromWireType: RegisteredPointer_fromWireType
|
|
25670
|
+
});
|
|
25671
|
+
};
|
|
25672
|
+
/** @constructor
|
|
25673
|
+
@param {*=} pointeeType,
|
|
25674
|
+
@param {*=} sharingPolicy,
|
|
25675
|
+
@param {*=} rawGetPointee,
|
|
25676
|
+
@param {*=} rawConstructor,
|
|
25677
|
+
@param {*=} rawShare,
|
|
25678
|
+
@param {*=} rawDestructor,
|
|
25679
|
+
*/
|
|
25680
|
+
/** @param {number=} numArguments */
|
|
25681
|
+
replacePublicSymbol = function replacePublicSymbol(name, value, numArguments) {
|
|
25682
|
+
if (!Module.hasOwnProperty(name)) {
|
|
25683
|
+
throwInternalError('Replacing nonexistent public symbol');
|
|
25684
|
+
}
|
|
25685
|
+
// If there's an overload table for this symbol, replace the symbol in the overload table instead.
|
|
25686
|
+
if (undefined !== Module[name].overloadTable && undefined !== numArguments) ;else {
|
|
25687
|
+
Module[name] = value;
|
|
25688
|
+
Module[name].argCount = numArguments;
|
|
25689
|
+
}
|
|
25690
|
+
};
|
|
25691
|
+
wasmTableMirror = [];
|
|
25692
|
+
/** @type {WebAssembly.Table} */
|
|
25693
|
+
getWasmTableEntry = function getWasmTableEntry(funcPtr) {
|
|
25694
|
+
var func = wasmTableMirror[funcPtr];
|
|
25695
|
+
if (!func) {
|
|
25696
|
+
/** @suppress {checkTypes} */
|
|
25697
|
+
wasmTableMirror[funcPtr] = func = wasmTable.get(funcPtr);
|
|
25698
|
+
}
|
|
25699
|
+
return func;
|
|
25700
|
+
};
|
|
25701
|
+
embind__requireFunction = function embind__requireFunction(signature, rawFunction, isAsync) {
|
|
25702
|
+
signature = AsciiToString(signature);
|
|
25703
|
+
function makeDynCaller() {
|
|
25704
|
+
var rtn = getWasmTableEntry(rawFunction);
|
|
25705
|
+
return rtn;
|
|
25706
|
+
}
|
|
25707
|
+
var fp = makeDynCaller();
|
|
25708
|
+
if (typeof fp != 'function') {
|
|
25709
|
+
throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
|
|
25710
|
+
}
|
|
25711
|
+
return fp;
|
|
25712
|
+
};
|
|
25713
|
+
UnboundTypeError = /*#__PURE__*/function (_Error3) {
|
|
25714
|
+
function UnboundTypeError() {
|
|
25715
|
+
return _Error3.apply(this, arguments) || this;
|
|
25716
|
+
}
|
|
25717
|
+
_inheritsLoose(UnboundTypeError, _Error3);
|
|
25718
|
+
return UnboundTypeError;
|
|
25719
|
+
}( /*#__PURE__*/_wrapNativeSuper(Error));
|
|
25720
|
+
getTypeName = function getTypeName(type) {
|
|
25721
|
+
var ptr = ___getTypeName(type);
|
|
25722
|
+
var rv = AsciiToString(ptr);
|
|
25723
|
+
_free(ptr);
|
|
25724
|
+
return rv;
|
|
25725
|
+
};
|
|
25726
|
+
throwUnboundTypeError = function throwUnboundTypeError(message, types) {
|
|
25727
|
+
var unboundTypes = [];
|
|
25728
|
+
var seen = {};
|
|
25729
|
+
function visit(type) {
|
|
25730
|
+
if (seen[type]) {
|
|
25731
|
+
return;
|
|
25732
|
+
}
|
|
25733
|
+
if (registeredTypes[type]) {
|
|
25734
|
+
return;
|
|
25735
|
+
}
|
|
25736
|
+
if (typeDependencies[type]) {
|
|
25737
|
+
typeDependencies[type].forEach(visit);
|
|
25738
|
+
return;
|
|
25739
|
+
}
|
|
25740
|
+
unboundTypes.push(type);
|
|
25741
|
+
seen[type] = true;
|
|
25742
|
+
}
|
|
25743
|
+
types.forEach(visit);
|
|
25744
|
+
throw new UnboundTypeError(message + ": " + unboundTypes.map(getTypeName).join([', ']));
|
|
25745
|
+
};
|
|
25746
|
+
whenDependentTypesAreResolved = function whenDependentTypesAreResolved(myTypes, dependentTypes, getTypeConverters) {
|
|
25747
|
+
myTypes.forEach(function (type) {
|
|
25748
|
+
return typeDependencies[type] = dependentTypes;
|
|
25749
|
+
});
|
|
25750
|
+
function onComplete(typeConverters) {
|
|
25751
|
+
var myTypeConverters = getTypeConverters(typeConverters);
|
|
25752
|
+
if (myTypeConverters.length !== myTypes.length) {
|
|
25753
|
+
throwInternalError('Mismatched type converter count');
|
|
25754
|
+
}
|
|
25755
|
+
for (var i = 0; i < myTypes.length; ++i) {
|
|
25756
|
+
registerType(myTypes[i], myTypeConverters[i]);
|
|
25757
|
+
}
|
|
25758
|
+
}
|
|
25759
|
+
var typeConverters = new Array(dependentTypes.length);
|
|
25760
|
+
var unregisteredTypes = [];
|
|
25761
|
+
var registered = 0;
|
|
25762
|
+
dependentTypes.forEach(function (dt, i) {
|
|
25763
|
+
if (registeredTypes.hasOwnProperty(dt)) {
|
|
25764
|
+
typeConverters[i] = registeredTypes[dt];
|
|
25765
|
+
} else {
|
|
25766
|
+
unregisteredTypes.push(dt);
|
|
25767
|
+
if (!awaitingDependencies.hasOwnProperty(dt)) {
|
|
25768
|
+
awaitingDependencies[dt] = [];
|
|
25769
|
+
}
|
|
25770
|
+
awaitingDependencies[dt].push(function () {
|
|
25771
|
+
typeConverters[i] = registeredTypes[dt];
|
|
25772
|
+
++registered;
|
|
25773
|
+
if (registered === unregisteredTypes.length) {
|
|
25774
|
+
onComplete(typeConverters);
|
|
25775
|
+
}
|
|
25776
|
+
});
|
|
25777
|
+
}
|
|
25778
|
+
});
|
|
25779
|
+
if (0 === unregisteredTypes.length) {
|
|
25780
|
+
onComplete(typeConverters);
|
|
25781
|
+
}
|
|
25782
|
+
};
|
|
25783
|
+
__embind_register_class = function __embind_register_class(rawType, rawPointerType, rawConstPointerType, baseClassRawType, getActualTypeSignature, getActualType, upcastSignature, upcast, downcastSignature, downcast, name, destructorSignature, rawDestructor) {
|
|
25784
|
+
name = AsciiToString(name);
|
|
25785
|
+
getActualType = embind__requireFunction(getActualTypeSignature, getActualType);
|
|
25786
|
+
upcast && (upcast = embind__requireFunction(upcastSignature, upcast));
|
|
25787
|
+
downcast && (downcast = embind__requireFunction(downcastSignature, downcast));
|
|
25788
|
+
rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
|
|
25789
|
+
var legalFunctionName = makeLegalFunctionName(name);
|
|
25790
|
+
exposePublicSymbol(legalFunctionName, function () {
|
|
25791
|
+
// this code cannot run if baseClassRawType is zero
|
|
25792
|
+
throwUnboundTypeError("Cannot construct " + name + " due to unbound types", [baseClassRawType]);
|
|
25793
|
+
});
|
|
25794
|
+
whenDependentTypesAreResolved([rawType, rawPointerType, rawConstPointerType], baseClassRawType ? [baseClassRawType] : [], function (base) {
|
|
25795
|
+
base = base[0];
|
|
25796
|
+
var baseClass;
|
|
25797
|
+
var basePrototype;
|
|
25798
|
+
if (baseClassRawType) {
|
|
25799
|
+
baseClass = base.registeredClass;
|
|
25800
|
+
basePrototype = baseClass.instancePrototype;
|
|
25801
|
+
} else {
|
|
25802
|
+
basePrototype = ClassHandle.prototype;
|
|
25803
|
+
}
|
|
25804
|
+
var constructor = createNamedFunction(name, function () {
|
|
25805
|
+
if (Object.getPrototypeOf(this) !== instancePrototype) {
|
|
25806
|
+
throw new BindingError("Use 'new' to construct " + name);
|
|
25807
|
+
}
|
|
25808
|
+
if (undefined === registeredClass.constructor_body) {
|
|
25809
|
+
throw new BindingError(name + " has no accessible constructor");
|
|
25810
|
+
}
|
|
25811
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
25812
|
+
args[_key2] = arguments[_key2];
|
|
25813
|
+
}
|
|
25814
|
+
var body = registeredClass.constructor_body[args.length];
|
|
25815
|
+
if (undefined === body) {
|
|
25816
|
+
throw new BindingError("Tried to invoke ctor of " + name + " with invalid number of parameters (" + args.length + ") - expected (" + Object.keys(registeredClass.constructor_body).toString() + ") parameters instead!");
|
|
25817
|
+
}
|
|
25818
|
+
return body.apply(this, args);
|
|
25819
|
+
});
|
|
25820
|
+
var instancePrototype = Object.create(basePrototype, {
|
|
25821
|
+
constructor: {
|
|
25822
|
+
value: constructor
|
|
25823
|
+
}
|
|
25824
|
+
});
|
|
25825
|
+
constructor.prototype = instancePrototype;
|
|
25826
|
+
var registeredClass = new RegisteredClass(name, constructor, instancePrototype, rawDestructor, baseClass, getActualType, upcast, downcast);
|
|
25827
|
+
if (registeredClass.baseClass) {
|
|
25828
|
+
var _registeredClass$base, _registeredClass$base2;
|
|
25829
|
+
// Keep track of class hierarchy. Used to allow sub-classes to inherit class functions.
|
|
25830
|
+
(_registeredClass$base2 = (_registeredClass$base = registeredClass.baseClass).__derivedClasses) != null ? _registeredClass$base2 : _registeredClass$base.__derivedClasses = [];
|
|
25831
|
+
registeredClass.baseClass.__derivedClasses.push(registeredClass);
|
|
25832
|
+
}
|
|
25833
|
+
var referenceConverter = new RegisteredPointer(name, registeredClass, true, false, false);
|
|
25834
|
+
var pointerConverter = new RegisteredPointer(name + '*', registeredClass, false, false, false);
|
|
25835
|
+
var constPointerConverter = new RegisteredPointer(name + ' const*', registeredClass, false, true, false);
|
|
25836
|
+
registeredPointers[rawType] = {
|
|
25837
|
+
pointerType: pointerConverter,
|
|
25838
|
+
constPointerType: constPointerConverter
|
|
25839
|
+
};
|
|
25840
|
+
replacePublicSymbol(legalFunctionName, constructor);
|
|
25841
|
+
return [referenceConverter, pointerConverter, constPointerConverter];
|
|
25842
|
+
});
|
|
25843
|
+
};
|
|
25844
|
+
heap32VectorToArray = function heap32VectorToArray(count, firstElement) {
|
|
25845
|
+
var array = [];
|
|
25846
|
+
for (var i = 0; i < count; i++) {
|
|
25847
|
+
// TODO(https://github.com/emscripten-core/emscripten/issues/17310):
|
|
25848
|
+
// Find a way to hoist the `>> 2` or `>> 3` out of this loop.
|
|
25849
|
+
array.push(HEAPU32[firstElement + i * 4 >> 2]);
|
|
25850
|
+
}
|
|
25851
|
+
return array;
|
|
25852
|
+
};
|
|
25853
|
+
runDestructors = function runDestructors(destructors) {
|
|
25854
|
+
while (destructors.length) {
|
|
25855
|
+
var ptr = destructors.pop();
|
|
25856
|
+
var del = destructors.pop();
|
|
25857
|
+
del(ptr);
|
|
25858
|
+
}
|
|
25859
|
+
};
|
|
25860
|
+
__embind_register_class_constructor = function __embind_register_class_constructor(rawClassType, argCount, rawArgTypesAddr, invokerSignature, invoker, rawConstructor) {
|
|
25861
|
+
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
25862
|
+
invoker = embind__requireFunction(invokerSignature, invoker);
|
|
25863
|
+
whenDependentTypesAreResolved([], [rawClassType], function (classType) {
|
|
25864
|
+
classType = classType[0];
|
|
25865
|
+
var humanName = "constructor " + classType.name;
|
|
25866
|
+
if (undefined === classType.registeredClass.constructor_body) {
|
|
25867
|
+
classType.registeredClass.constructor_body = [];
|
|
25868
|
+
}
|
|
25869
|
+
if (undefined !== classType.registeredClass.constructor_body[argCount - 1]) {
|
|
25870
|
+
throw new BindingError("Cannot register multiple constructors with identical number of parameters (" + (argCount - 1) + ") for class '" + classType.name + "'! Overload resolution is currently only performed using the parameter count, not actual type info!");
|
|
25871
|
+
}
|
|
25872
|
+
classType.registeredClass.constructor_body[argCount - 1] = function () {
|
|
25873
|
+
throwUnboundTypeError("Cannot construct " + classType.name + " due to unbound types", rawArgTypes);
|
|
25874
|
+
};
|
|
25875
|
+
whenDependentTypesAreResolved([], rawArgTypes, function (argTypes) {
|
|
25876
|
+
// Insert empty slot for context type (argTypes[1]).
|
|
25877
|
+
argTypes.splice(1, 0, null);
|
|
25878
|
+
classType.registeredClass.constructor_body[argCount - 1] = craftInvokerFunction(humanName, argTypes, null, invoker, rawConstructor);
|
|
25879
|
+
return [];
|
|
25880
|
+
});
|
|
25881
|
+
return [];
|
|
25882
|
+
});
|
|
25883
|
+
};
|
|
25884
|
+
getFunctionName = function getFunctionName(signature) {
|
|
25885
|
+
signature = signature.trim();
|
|
25886
|
+
var argsIndex = signature.indexOf('(');
|
|
25887
|
+
if (argsIndex === -1) return signature;
|
|
25888
|
+
return signature.slice(0, argsIndex);
|
|
25889
|
+
};
|
|
25890
|
+
__embind_register_class_function = function __embind_register_class_function(rawClassType, methodName, argCount, rawArgTypesAddr,
|
|
25891
|
+
// [ReturnType, ThisType, Args...]
|
|
25892
|
+
invokerSignature, rawInvoker, context, isPureVirtual, isAsync, isNonnullReturn) {
|
|
25893
|
+
var rawArgTypes = heap32VectorToArray(argCount, rawArgTypesAddr);
|
|
25894
|
+
methodName = AsciiToString(methodName);
|
|
25895
|
+
methodName = getFunctionName(methodName);
|
|
25896
|
+
rawInvoker = embind__requireFunction(invokerSignature, rawInvoker, isAsync);
|
|
25897
|
+
whenDependentTypesAreResolved([], [rawClassType], function (classType) {
|
|
25898
|
+
classType = classType[0];
|
|
25899
|
+
var humanName = classType.name + "." + methodName;
|
|
25900
|
+
if (methodName.startsWith('@@')) {
|
|
25901
|
+
methodName = Symbol[methodName.substring(2)];
|
|
25902
|
+
}
|
|
25903
|
+
if (isPureVirtual) {
|
|
25904
|
+
classType.registeredClass.pureVirtualFunctions.push(methodName);
|
|
25905
|
+
}
|
|
25906
|
+
function unboundTypesHandler() {
|
|
25907
|
+
throwUnboundTypeError("Cannot call " + humanName + " due to unbound types", rawArgTypes);
|
|
25908
|
+
}
|
|
25909
|
+
var proto = classType.registeredClass.instancePrototype;
|
|
25910
|
+
var method = proto[methodName];
|
|
25911
|
+
if (undefined === method || undefined === method.overloadTable && method.className !== classType.name && method.argCount === argCount - 2) {
|
|
25912
|
+
// This is the first overload to be registered, OR we are replacing a
|
|
25913
|
+
// function in the base class with a function in the derived class.
|
|
25914
|
+
unboundTypesHandler.argCount = argCount - 2;
|
|
25915
|
+
unboundTypesHandler.className = classType.name;
|
|
25916
|
+
proto[methodName] = unboundTypesHandler;
|
|
25917
|
+
} else {
|
|
25918
|
+
// There was an existing function with the same name registered. Set up
|
|
25919
|
+
// a function overload routing table.
|
|
25920
|
+
ensureOverloadTable(proto, methodName, humanName);
|
|
25921
|
+
proto[methodName].overloadTable[argCount - 2] = unboundTypesHandler;
|
|
25922
|
+
}
|
|
25923
|
+
whenDependentTypesAreResolved([], rawArgTypes, function (argTypes) {
|
|
25924
|
+
var memberFunction = craftInvokerFunction(humanName, argTypes, classType, rawInvoker, context, isAsync);
|
|
25925
|
+
|
|
25926
|
+
// Replace the initial unbound-handler-stub function with the
|
|
25927
|
+
// appropriate member function, now that all types are resolved. If
|
|
25928
|
+
// multiple overloads are registered for this function, the function
|
|
25929
|
+
// goes into an overload table.
|
|
25930
|
+
if (undefined === proto[methodName].overloadTable) {
|
|
25931
|
+
// Set argCount in case an overload is registered later
|
|
25932
|
+
memberFunction.argCount = argCount - 2;
|
|
25933
|
+
proto[methodName] = memberFunction;
|
|
25934
|
+
} else {
|
|
25935
|
+
proto[methodName].overloadTable[argCount - 2] = memberFunction;
|
|
25936
|
+
}
|
|
25937
|
+
return [];
|
|
25938
|
+
});
|
|
25939
|
+
return [];
|
|
25940
|
+
});
|
|
25941
|
+
};
|
|
25942
|
+
emval_freelist = [];
|
|
25943
|
+
emval_handles = [0, 1,, 1, null, 1, true, 1, false, 1];
|
|
25944
|
+
__emval_decref = function __emval_decref(handle) {
|
|
25945
|
+
if (handle > 9 && 0 === --emval_handles[handle + 1]) {
|
|
25946
|
+
emval_handles[handle] = undefined;
|
|
25947
|
+
emval_freelist.push(handle);
|
|
25948
|
+
}
|
|
25949
|
+
};
|
|
25950
|
+
Emval = {
|
|
25951
|
+
toValue: function toValue(handle) {
|
|
25952
|
+
if (!handle) {
|
|
25953
|
+
throwBindingError("Cannot use deleted val. handle = " + handle);
|
|
25954
|
+
}
|
|
25955
|
+
return emval_handles[handle];
|
|
25956
|
+
},
|
|
25957
|
+
toHandle: function toHandle(value) {
|
|
25958
|
+
switch (value) {
|
|
25959
|
+
case undefined:
|
|
25960
|
+
return 2;
|
|
25961
|
+
case null:
|
|
25962
|
+
return 4;
|
|
25963
|
+
case true:
|
|
25964
|
+
return 6;
|
|
25965
|
+
case false:
|
|
25966
|
+
return 8;
|
|
25967
|
+
default:
|
|
25968
|
+
{
|
|
25969
|
+
var handle = emval_freelist.pop() || emval_handles.length;
|
|
25970
|
+
emval_handles[handle] = value;
|
|
25971
|
+
emval_handles[handle + 1] = 1;
|
|
25972
|
+
return handle;
|
|
25973
|
+
}
|
|
25974
|
+
}
|
|
25975
|
+
}
|
|
25976
|
+
};
|
|
25977
|
+
EmValType = {
|
|
25978
|
+
name: 'emscripten::val',
|
|
25979
|
+
fromWireType: function fromWireType(handle) {
|
|
25980
|
+
var rv = Emval.toValue(handle);
|
|
25981
|
+
__emval_decref(handle);
|
|
25982
|
+
return rv;
|
|
25983
|
+
},
|
|
25984
|
+
toWireType: function toWireType(destructors, value) {
|
|
25985
|
+
return Emval.toHandle(value);
|
|
25986
|
+
},
|
|
25987
|
+
readValueFromPointer: readPointer,
|
|
25988
|
+
destructorFunction: null // This type does not need a destructor
|
|
25989
|
+
|
|
25990
|
+
// TODO: do we need a deleteObject here? write a test where
|
|
25991
|
+
// emval is passed into JS via an interface
|
|
25992
|
+
};
|
|
25993
|
+
__embind_register_emval = function __embind_register_emval(rawType) {
|
|
25994
|
+
return registerType(rawType, EmValType);
|
|
25995
|
+
};
|
|
25996
|
+
floatReadValueFromPointer = function floatReadValueFromPointer(name, width) {
|
|
25997
|
+
switch (width) {
|
|
25998
|
+
case 4:
|
|
25999
|
+
return function (pointer) {
|
|
26000
|
+
return this.fromWireType(HEAPF32[pointer >> 2]);
|
|
26001
|
+
};
|
|
26002
|
+
case 8:
|
|
26003
|
+
return function (pointer) {
|
|
26004
|
+
return this.fromWireType(HEAPF64[pointer >> 3]);
|
|
26005
|
+
};
|
|
26006
|
+
default:
|
|
26007
|
+
throw new TypeError("invalid float width (" + width + "): " + name);
|
|
26008
|
+
}
|
|
26009
|
+
};
|
|
26010
|
+
__embind_register_float = function __embind_register_float(rawType, name, size) {
|
|
26011
|
+
name = AsciiToString(name);
|
|
26012
|
+
registerType(rawType, {
|
|
26013
|
+
name: name,
|
|
26014
|
+
fromWireType: function fromWireType(value) {
|
|
26015
|
+
return value;
|
|
26016
|
+
},
|
|
26017
|
+
toWireType: function toWireType(destructors, value) {
|
|
26018
|
+
// The VM will perform JS to Wasm value conversion, according to the spec:
|
|
26019
|
+
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
|
|
26020
|
+
return value;
|
|
26021
|
+
},
|
|
26022
|
+
readValueFromPointer: floatReadValueFromPointer(name, size),
|
|
26023
|
+
destructorFunction: null // This type does not need a destructor
|
|
26024
|
+
});
|
|
26025
|
+
};
|
|
26026
|
+
/** @suppress {globalThis} */
|
|
26027
|
+
__embind_register_integer = function __embind_register_integer(primitiveType, name, size, minRange, maxRange) {
|
|
26028
|
+
name = AsciiToString(name);
|
|
26029
|
+
var isUnsignedType = minRange === 0;
|
|
26030
|
+
var fromWireType = function fromWireType(value) {
|
|
26031
|
+
return value;
|
|
26032
|
+
};
|
|
26033
|
+
if (isUnsignedType) {
|
|
26034
|
+
var bitshift = 32 - 8 * size;
|
|
26035
|
+
fromWireType = function fromWireType(value) {
|
|
26036
|
+
return value << bitshift >>> bitshift;
|
|
26037
|
+
};
|
|
26038
|
+
maxRange = fromWireType(maxRange);
|
|
26039
|
+
}
|
|
26040
|
+
registerType(primitiveType, {
|
|
26041
|
+
name: name,
|
|
26042
|
+
fromWireType: fromWireType,
|
|
26043
|
+
toWireType: function toWireType(destructors, value) {
|
|
26044
|
+
// The VM will perform JS to Wasm value conversion, according to the spec:
|
|
26045
|
+
// https://www.w3.org/TR/wasm-js-api-1/#towebassemblyvalue
|
|
26046
|
+
return value;
|
|
26047
|
+
},
|
|
26048
|
+
readValueFromPointer: integerReadValueFromPointer(name, size, minRange !== 0),
|
|
26049
|
+
destructorFunction: null // This type does not need a destructor
|
|
26050
|
+
});
|
|
26051
|
+
};
|
|
26052
|
+
__embind_register_memory_view = function __embind_register_memory_view(rawType, dataTypeIndex, name) {
|
|
26053
|
+
var typeMapping = [Int8Array, Uint8Array, Int16Array, Uint16Array, Int32Array, Uint32Array, Float32Array, Float64Array, BigInt64Array, BigUint64Array];
|
|
26054
|
+
var TA = typeMapping[dataTypeIndex];
|
|
26055
|
+
function decodeMemoryView(handle) {
|
|
26056
|
+
var size = HEAPU32[handle >> 2];
|
|
26057
|
+
var data = HEAPU32[handle + 4 >> 2];
|
|
26058
|
+
return new TA(HEAP8.buffer, data, size);
|
|
26059
|
+
}
|
|
26060
|
+
name = AsciiToString(name);
|
|
26061
|
+
registerType(rawType, {
|
|
26062
|
+
name: name,
|
|
26063
|
+
fromWireType: decodeMemoryView,
|
|
26064
|
+
readValueFromPointer: decodeMemoryView
|
|
26065
|
+
}, {
|
|
26066
|
+
ignoreDuplicateRegistrations: true
|
|
26067
|
+
});
|
|
26068
|
+
};
|
|
26069
|
+
__embind_register_smart_ptr = function __embind_register_smart_ptr(rawType, rawPointeeType, name, sharingPolicy, getPointeeSignature, rawGetPointee, constructorSignature, rawConstructor, shareSignature, rawShare, destructorSignature, rawDestructor) {
|
|
26070
|
+
name = AsciiToString(name);
|
|
26071
|
+
rawGetPointee = embind__requireFunction(getPointeeSignature, rawGetPointee);
|
|
26072
|
+
rawConstructor = embind__requireFunction(constructorSignature, rawConstructor);
|
|
26073
|
+
rawShare = embind__requireFunction(shareSignature, rawShare);
|
|
26074
|
+
rawDestructor = embind__requireFunction(destructorSignature, rawDestructor);
|
|
26075
|
+
whenDependentTypesAreResolved([rawType], [rawPointeeType], function (pointeeType) {
|
|
26076
|
+
pointeeType = pointeeType[0];
|
|
26077
|
+
var registeredPointer = new RegisteredPointer(name, pointeeType.registeredClass, false, false,
|
|
26078
|
+
// smart pointer properties
|
|
26079
|
+
true, pointeeType, sharingPolicy, rawGetPointee, rawConstructor, rawShare, rawDestructor);
|
|
26080
|
+
return [registeredPointer];
|
|
26081
|
+
});
|
|
26082
|
+
};
|
|
26083
|
+
stringToUTF8Array = function stringToUTF8Array(str, heap, outIdx, maxBytesToWrite) {
|
|
26084
|
+
// Parameter maxBytesToWrite is not optional. Negative values, 0, null,
|
|
26085
|
+
// undefined and false each don't write out any bytes.
|
|
26086
|
+
if (!(maxBytesToWrite > 0)) return 0;
|
|
26087
|
+
var startIdx = outIdx;
|
|
26088
|
+
var endIdx = outIdx + maxBytesToWrite - 1; // -1 for string null terminator.
|
|
26089
|
+
for (var i = 0; i < str.length; ++i) {
|
|
26090
|
+
// For UTF8 byte structure, see http://en.wikipedia.org/wiki/UTF-8#Description
|
|
26091
|
+
// and https://www.ietf.org/rfc/rfc2279.txt
|
|
26092
|
+
// and https://tools.ietf.org/html/rfc3629
|
|
26093
|
+
var u = str.codePointAt(i);
|
|
26094
|
+
if (u <= 0x7f) {
|
|
26095
|
+
if (outIdx >= endIdx) break;
|
|
26096
|
+
heap[outIdx++] = u;
|
|
26097
|
+
} else if (u <= 0x7ff) {
|
|
26098
|
+
if (outIdx + 1 >= endIdx) break;
|
|
26099
|
+
heap[outIdx++] = 0xc0 | u >> 6;
|
|
26100
|
+
heap[outIdx++] = 0x80 | u & 63;
|
|
26101
|
+
} else if (u <= 0xffff) {
|
|
26102
|
+
if (outIdx + 2 >= endIdx) break;
|
|
26103
|
+
heap[outIdx++] = 0xe0 | u >> 12;
|
|
26104
|
+
heap[outIdx++] = 0x80 | u >> 6 & 63;
|
|
26105
|
+
heap[outIdx++] = 0x80 | u & 63;
|
|
26106
|
+
} else {
|
|
26107
|
+
if (outIdx + 3 >= endIdx) break;
|
|
26108
|
+
heap[outIdx++] = 0xf0 | u >> 18;
|
|
26109
|
+
heap[outIdx++] = 0x80 | u >> 12 & 63;
|
|
26110
|
+
heap[outIdx++] = 0x80 | u >> 6 & 63;
|
|
26111
|
+
heap[outIdx++] = 0x80 | u & 63;
|
|
26112
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
26113
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
26114
|
+
i++;
|
|
26115
|
+
}
|
|
26116
|
+
}
|
|
26117
|
+
// Null-terminate the pointer to the buffer.
|
|
26118
|
+
heap[outIdx] = 0;
|
|
26119
|
+
return outIdx - startIdx;
|
|
26120
|
+
};
|
|
26121
|
+
stringToUTF8 = function stringToUTF8(str, outPtr, maxBytesToWrite) {
|
|
26122
|
+
return stringToUTF8Array(str, HEAPU8, outPtr, maxBytesToWrite);
|
|
26123
|
+
};
|
|
26124
|
+
lengthBytesUTF8 = function lengthBytesUTF8(str) {
|
|
26125
|
+
var len = 0;
|
|
26126
|
+
for (var i = 0; i < str.length; ++i) {
|
|
26127
|
+
// Gotcha: charCodeAt returns a 16-bit word that is a UTF-16 encoded code
|
|
26128
|
+
// unit, not a Unicode code point of the character! So decode
|
|
26129
|
+
// UTF16->UTF32->UTF8.
|
|
26130
|
+
// See http://unicode.org/faq/utf_bom.html#utf16-3
|
|
26131
|
+
var c = str.charCodeAt(i); // possibly a lead surrogate
|
|
26132
|
+
if (c <= 0x7f) {
|
|
26133
|
+
len++;
|
|
26134
|
+
} else if (c <= 0x7ff) {
|
|
26135
|
+
len += 2;
|
|
26136
|
+
} else if (c >= 0xd800 && c <= 0xdfff) {
|
|
26137
|
+
len += 4;
|
|
26138
|
+
++i;
|
|
26139
|
+
} else {
|
|
26140
|
+
len += 3;
|
|
26141
|
+
}
|
|
26142
|
+
}
|
|
26143
|
+
return len;
|
|
26144
|
+
};
|
|
26145
|
+
UTF8Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder() : undefined;
|
|
26146
|
+
findStringEnd = function findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul) {
|
|
26147
|
+
var maxIdx = idx + maxBytesToRead;
|
|
26148
|
+
if (ignoreNul) return maxIdx;
|
|
26149
|
+
// TextDecoder needs to know the byte length in advance, it doesn't stop on
|
|
26150
|
+
// null terminator by itself.
|
|
26151
|
+
// As a tiny code save trick, compare idx against maxIdx using a negation,
|
|
26152
|
+
// so that maxBytesToRead=undefined/NaN means Infinity.
|
|
26153
|
+
while (heapOrArray[idx] && !(idx >= maxIdx)) ++idx;
|
|
26154
|
+
return idx;
|
|
26155
|
+
};
|
|
26156
|
+
/**
|
|
26157
|
+
* Given a pointer 'idx' to a null-terminated UTF8-encoded string in the given
|
|
26158
|
+
* array that contains uint8 values, returns a copy of that string as a
|
|
26159
|
+
* Javascript String object.
|
|
26160
|
+
* heapOrArray is either a regular array, or a JavaScript typed array view.
|
|
26161
|
+
* @param {number=} idx
|
|
26162
|
+
* @param {number=} maxBytesToRead
|
|
26163
|
+
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
26164
|
+
* @return {string}
|
|
26165
|
+
*/
|
|
26166
|
+
UTF8ArrayToString = function UTF8ArrayToString(heapOrArray, idx, maxBytesToRead, ignoreNul) {
|
|
26167
|
+
if (idx === void 0) {
|
|
26168
|
+
idx = 0;
|
|
26169
|
+
}
|
|
26170
|
+
var endPtr = findStringEnd(heapOrArray, idx, maxBytesToRead, ignoreNul);
|
|
26171
|
+
|
|
26172
|
+
// When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
|
|
26173
|
+
if (endPtr - idx > 16 && heapOrArray.buffer && UTF8Decoder) {
|
|
26174
|
+
return UTF8Decoder.decode(heapOrArray.subarray(idx, endPtr));
|
|
26175
|
+
}
|
|
26176
|
+
var str = '';
|
|
26177
|
+
while (idx < endPtr) {
|
|
26178
|
+
// For UTF8 byte structure, see:
|
|
26179
|
+
// http://en.wikipedia.org/wiki/UTF-8#Description
|
|
26180
|
+
// https://www.ietf.org/rfc/rfc2279.txt
|
|
26181
|
+
// https://tools.ietf.org/html/rfc3629
|
|
26182
|
+
var u0 = heapOrArray[idx++];
|
|
26183
|
+
if (!(u0 & 0x80)) {
|
|
26184
|
+
str += String.fromCharCode(u0);
|
|
26185
|
+
continue;
|
|
26186
|
+
}
|
|
26187
|
+
var u1 = heapOrArray[idx++] & 63;
|
|
26188
|
+
if ((u0 & 0xe0) == 0xc0) {
|
|
26189
|
+
str += String.fromCharCode((u0 & 31) << 6 | u1);
|
|
26190
|
+
continue;
|
|
26191
|
+
}
|
|
26192
|
+
var u2 = heapOrArray[idx++] & 63;
|
|
26193
|
+
if ((u0 & 0xf0) == 0xe0) {
|
|
26194
|
+
u0 = (u0 & 15) << 12 | u1 << 6 | u2;
|
|
26195
|
+
} else {
|
|
26196
|
+
u0 = (u0 & 7) << 18 | u1 << 12 | u2 << 6 | heapOrArray[idx++] & 63;
|
|
26197
|
+
}
|
|
26198
|
+
if (u0 < 0x10000) {
|
|
26199
|
+
str += String.fromCharCode(u0);
|
|
26200
|
+
} else {
|
|
26201
|
+
var ch = u0 - 0x10000;
|
|
26202
|
+
str += String.fromCharCode(0xd800 | ch >> 10, 0xdc00 | ch & 0x3ff);
|
|
26203
|
+
}
|
|
26204
|
+
}
|
|
26205
|
+
return str;
|
|
26206
|
+
};
|
|
26207
|
+
/**
|
|
26208
|
+
* Given a pointer 'ptr' to a null-terminated UTF8-encoded string in the
|
|
26209
|
+
* emscripten HEAP, returns a copy of that string as a Javascript String object.
|
|
26210
|
+
*
|
|
26211
|
+
* @param {number} ptr
|
|
26212
|
+
* @param {number=} maxBytesToRead - An optional length that specifies the
|
|
26213
|
+
* maximum number of bytes to read. You can omit this parameter to scan the
|
|
26214
|
+
* string until the first 0 byte. If maxBytesToRead is passed, and the string
|
|
26215
|
+
* at [ptr, ptr+maxBytesToReadr[ contains a null byte in the middle, then the
|
|
26216
|
+
* string will cut short at that byte index.
|
|
26217
|
+
* @param {boolean=} ignoreNul - If true, the function will not stop on a NUL character.
|
|
26218
|
+
* @return {string}
|
|
26219
|
+
*/
|
|
26220
|
+
UTF8ToString = function UTF8ToString(ptr, maxBytesToRead, ignoreNul) {
|
|
26221
|
+
return ptr ? UTF8ArrayToString(HEAPU8, ptr, maxBytesToRead, ignoreNul) : '';
|
|
26222
|
+
};
|
|
26223
|
+
__embind_register_std_string = function __embind_register_std_string(rawType, name) {
|
|
26224
|
+
name = AsciiToString(name);
|
|
26225
|
+
registerType(rawType, {
|
|
26226
|
+
name: name,
|
|
26227
|
+
// For some method names we use string keys here since they are part of
|
|
26228
|
+
// the public/external API and/or used by the runtime-generated code.
|
|
26229
|
+
fromWireType: function fromWireType(value) {
|
|
26230
|
+
var length = HEAPU32[value >> 2];
|
|
26231
|
+
var payload = value + 4;
|
|
26232
|
+
var str;
|
|
26233
|
+
{
|
|
26234
|
+
str = UTF8ToString(payload, length, true);
|
|
26235
|
+
}
|
|
26236
|
+
_free(value);
|
|
26237
|
+
return str;
|
|
26238
|
+
},
|
|
26239
|
+
toWireType: function toWireType(destructors, value) {
|
|
26240
|
+
if (value instanceof ArrayBuffer) {
|
|
26241
|
+
value = new Uint8Array(value);
|
|
26242
|
+
}
|
|
26243
|
+
var length;
|
|
26244
|
+
var valueIsOfTypeString = typeof value == 'string';
|
|
26245
|
+
|
|
26246
|
+
// We accept `string` or array views with single byte elements
|
|
26247
|
+
if (!(valueIsOfTypeString || ArrayBuffer.isView(value) && value.BYTES_PER_ELEMENT == 1)) {
|
|
26248
|
+
throwBindingError('Cannot pass non-string to std::string');
|
|
26249
|
+
}
|
|
26250
|
+
if (valueIsOfTypeString) {
|
|
26251
|
+
length = lengthBytesUTF8(value);
|
|
26252
|
+
} else {
|
|
26253
|
+
length = value.length;
|
|
26254
|
+
}
|
|
26255
|
+
|
|
26256
|
+
// assumes POINTER_SIZE alignment
|
|
26257
|
+
var base = _malloc(4 + length + 1);
|
|
26258
|
+
var ptr = base + 4;
|
|
26259
|
+
HEAPU32[base >> 2] = length;
|
|
26260
|
+
if (valueIsOfTypeString) {
|
|
26261
|
+
{
|
|
26262
|
+
stringToUTF8(value, ptr, length + 1);
|
|
26263
|
+
}
|
|
26264
|
+
} else {
|
|
26265
|
+
HEAPU8.set(value, ptr);
|
|
26266
|
+
}
|
|
26267
|
+
if (destructors !== null) {
|
|
26268
|
+
destructors.push(_free, base);
|
|
26269
|
+
}
|
|
26270
|
+
return base;
|
|
26271
|
+
},
|
|
26272
|
+
readValueFromPointer: readPointer,
|
|
26273
|
+
destructorFunction: function destructorFunction(ptr) {
|
|
26274
|
+
_free(ptr);
|
|
26275
|
+
}
|
|
26276
|
+
});
|
|
26277
|
+
};
|
|
26278
|
+
UTF16Decoder = typeof TextDecoder != 'undefined' ? new TextDecoder('utf-16le') : undefined;
|
|
26279
|
+
UTF16ToString = function UTF16ToString(ptr, maxBytesToRead, ignoreNul) {
|
|
26280
|
+
var idx = ptr >> 1;
|
|
26281
|
+
var endIdx = findStringEnd(HEAPU16, idx, maxBytesToRead / 2, ignoreNul);
|
|
26282
|
+
|
|
26283
|
+
// When using conditional TextDecoder, skip it for short strings as the overhead of the native call is not worth it.
|
|
26284
|
+
if (endIdx - idx > 16 && UTF16Decoder) return UTF16Decoder.decode(HEAPU16.subarray(idx, endIdx));
|
|
26285
|
+
|
|
26286
|
+
// Fallback: decode without UTF16Decoder
|
|
26287
|
+
var str = '';
|
|
26288
|
+
|
|
26289
|
+
// If maxBytesToRead is not passed explicitly, it will be undefined, and the
|
|
26290
|
+
// for-loop's condition will always evaluate to true. The loop is then
|
|
26291
|
+
// terminated on the first null char.
|
|
26292
|
+
for (var i = idx; i < endIdx; ++i) {
|
|
26293
|
+
var codeUnit = HEAPU16[i];
|
|
26294
|
+
// fromCharCode constructs a character from a UTF-16 code unit, so we can
|
|
26295
|
+
// pass the UTF16 string right through.
|
|
26296
|
+
str += String.fromCharCode(codeUnit);
|
|
26297
|
+
}
|
|
26298
|
+
return str;
|
|
26299
|
+
};
|
|
26300
|
+
stringToUTF16 = function stringToUTF16(str, outPtr, maxBytesToWrite) {
|
|
26301
|
+
var _maxBytesToWrite;
|
|
26302
|
+
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
26303
|
+
(_maxBytesToWrite = maxBytesToWrite) != null ? _maxBytesToWrite : maxBytesToWrite = 0x7fffffff;
|
|
26304
|
+
if (maxBytesToWrite < 2) return 0;
|
|
26305
|
+
maxBytesToWrite -= 2; // Null terminator.
|
|
26306
|
+
var startPtr = outPtr;
|
|
26307
|
+
var numCharsToWrite = maxBytesToWrite < str.length * 2 ? maxBytesToWrite / 2 : str.length;
|
|
26308
|
+
for (var i = 0; i < numCharsToWrite; ++i) {
|
|
26309
|
+
// charCodeAt returns a UTF-16 encoded code unit, so it can be directly written to the HEAP.
|
|
26310
|
+
var codeUnit = str.charCodeAt(i); // possibly a lead surrogate
|
|
26311
|
+
HEAP16[outPtr >> 1] = codeUnit;
|
|
26312
|
+
outPtr += 2;
|
|
26313
|
+
}
|
|
26314
|
+
// Null-terminate the pointer to the HEAP.
|
|
26315
|
+
HEAP16[outPtr >> 1] = 0;
|
|
26316
|
+
return outPtr - startPtr;
|
|
26317
|
+
};
|
|
26318
|
+
lengthBytesUTF16 = function lengthBytesUTF16(str) {
|
|
26319
|
+
return str.length * 2;
|
|
26320
|
+
};
|
|
26321
|
+
UTF32ToString = function UTF32ToString(ptr, maxBytesToRead, ignoreNul) {
|
|
26322
|
+
var str = '';
|
|
26323
|
+
var startIdx = ptr >> 2;
|
|
26324
|
+
// If maxBytesToRead is not passed explicitly, it will be undefined, and this
|
|
26325
|
+
// will always evaluate to true. This saves on code size.
|
|
26326
|
+
for (var i = 0; !(i >= maxBytesToRead / 4); i++) {
|
|
26327
|
+
var utf32 = HEAPU32[startIdx + i];
|
|
26328
|
+
if (!utf32 && !ignoreNul) break;
|
|
26329
|
+
str += String.fromCodePoint(utf32);
|
|
26330
|
+
}
|
|
26331
|
+
return str;
|
|
26332
|
+
};
|
|
26333
|
+
stringToUTF32 = function stringToUTF32(str, outPtr, maxBytesToWrite) {
|
|
26334
|
+
var _maxBytesToWrite2;
|
|
26335
|
+
// Backwards compatibility: if max bytes is not specified, assume unsafe unbounded write is allowed.
|
|
26336
|
+
(_maxBytesToWrite2 = maxBytesToWrite) != null ? _maxBytesToWrite2 : maxBytesToWrite = 0x7fffffff;
|
|
26337
|
+
if (maxBytesToWrite < 4) return 0;
|
|
26338
|
+
var startPtr = outPtr;
|
|
26339
|
+
var endPtr = startPtr + maxBytesToWrite - 4;
|
|
26340
|
+
for (var i = 0; i < str.length; ++i) {
|
|
26341
|
+
var codePoint = str.codePointAt(i);
|
|
26342
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
26343
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
26344
|
+
if (codePoint > 0xffff) {
|
|
26345
|
+
i++;
|
|
26346
|
+
}
|
|
26347
|
+
HEAP32[outPtr >> 2] = codePoint;
|
|
26348
|
+
outPtr += 4;
|
|
26349
|
+
if (outPtr + 4 > endPtr) break;
|
|
26350
|
+
}
|
|
26351
|
+
// Null-terminate the pointer to the HEAP.
|
|
26352
|
+
HEAP32[outPtr >> 2] = 0;
|
|
26353
|
+
return outPtr - startPtr;
|
|
26354
|
+
};
|
|
26355
|
+
lengthBytesUTF32 = function lengthBytesUTF32(str) {
|
|
26356
|
+
var len = 0;
|
|
26357
|
+
for (var i = 0; i < str.length; ++i) {
|
|
26358
|
+
var codePoint = str.codePointAt(i);
|
|
26359
|
+
// Gotcha: if codePoint is over 0xFFFF, it is represented as a surrogate pair in UTF-16.
|
|
26360
|
+
// We need to manually skip over the second code unit for correct iteration.
|
|
26361
|
+
if (codePoint > 0xffff) {
|
|
26362
|
+
i++;
|
|
26363
|
+
}
|
|
26364
|
+
len += 4;
|
|
26365
|
+
}
|
|
26366
|
+
return len;
|
|
26367
|
+
};
|
|
26368
|
+
__embind_register_std_wstring = function __embind_register_std_wstring(rawType, charSize, name) {
|
|
26369
|
+
name = AsciiToString(name);
|
|
26370
|
+
var decodeString, encodeString, lengthBytesUTF;
|
|
26371
|
+
if (charSize === 2) {
|
|
26372
|
+
decodeString = UTF16ToString;
|
|
26373
|
+
encodeString = stringToUTF16;
|
|
26374
|
+
lengthBytesUTF = lengthBytesUTF16;
|
|
26375
|
+
} else {
|
|
26376
|
+
decodeString = UTF32ToString;
|
|
26377
|
+
encodeString = stringToUTF32;
|
|
26378
|
+
lengthBytesUTF = lengthBytesUTF32;
|
|
26379
|
+
}
|
|
26380
|
+
registerType(rawType, {
|
|
26381
|
+
name: name,
|
|
26382
|
+
fromWireType: function fromWireType(value) {
|
|
26383
|
+
// Code mostly taken from _embind_register_std_string fromWireType
|
|
26384
|
+
var length = HEAPU32[value >> 2];
|
|
26385
|
+
var str = decodeString(value + 4, length * charSize, true);
|
|
26386
|
+
_free(value);
|
|
26387
|
+
return str;
|
|
26388
|
+
},
|
|
26389
|
+
toWireType: function toWireType(destructors, value) {
|
|
26390
|
+
if (!(typeof value == 'string')) {
|
|
26391
|
+
throwBindingError("Cannot pass non-string to C++ string type " + name);
|
|
26392
|
+
}
|
|
26393
|
+
|
|
26394
|
+
// assumes POINTER_SIZE alignment
|
|
26395
|
+
var length = lengthBytesUTF(value);
|
|
26396
|
+
var ptr = _malloc(4 + length + charSize);
|
|
26397
|
+
HEAPU32[ptr >> 2] = length / charSize;
|
|
26398
|
+
encodeString(value, ptr + 4, length + charSize);
|
|
26399
|
+
if (destructors !== null) {
|
|
26400
|
+
destructors.push(_free, ptr);
|
|
26401
|
+
}
|
|
26402
|
+
return ptr;
|
|
26403
|
+
},
|
|
26404
|
+
readValueFromPointer: readPointer,
|
|
26405
|
+
destructorFunction: function destructorFunction(ptr) {
|
|
26406
|
+
_free(ptr);
|
|
26407
|
+
}
|
|
26408
|
+
});
|
|
26409
|
+
};
|
|
26410
|
+
__embind_register_void = function __embind_register_void(rawType, name) {
|
|
26411
|
+
name = AsciiToString(name);
|
|
26412
|
+
registerType(rawType, {
|
|
26413
|
+
isVoid: true,
|
|
26414
|
+
// void return values can be optimized out sometimes
|
|
26415
|
+
name: name,
|
|
26416
|
+
fromWireType: function fromWireType() {
|
|
26417
|
+
return undefined;
|
|
26418
|
+
},
|
|
26419
|
+
// TODO: assert if anything else is given?
|
|
26420
|
+
toWireType: function toWireType(destructors, o) {
|
|
26421
|
+
return undefined;
|
|
26422
|
+
}
|
|
26423
|
+
});
|
|
26424
|
+
};
|
|
26425
|
+
emval_methodCallers = [];
|
|
26426
|
+
emval_addMethodCaller = function emval_addMethodCaller(caller) {
|
|
26427
|
+
var id = emval_methodCallers.length;
|
|
26428
|
+
emval_methodCallers.push(caller);
|
|
26429
|
+
return id;
|
|
26430
|
+
};
|
|
26431
|
+
requireRegisteredType = function requireRegisteredType(rawType, humanName) {
|
|
26432
|
+
var impl = registeredTypes[rawType];
|
|
26433
|
+
if (undefined === impl) {
|
|
26434
|
+
throwBindingError(humanName + " has unknown type " + getTypeName(rawType));
|
|
26435
|
+
}
|
|
26436
|
+
return impl;
|
|
26437
|
+
};
|
|
26438
|
+
emval_lookupTypes = function emval_lookupTypes(argCount, argTypes) {
|
|
26439
|
+
var a = new Array(argCount);
|
|
26440
|
+
for (var i = 0; i < argCount; ++i) {
|
|
26441
|
+
a[i] = requireRegisteredType(HEAPU32[argTypes + i * 4 >> 2], "parameter " + i);
|
|
26442
|
+
}
|
|
26443
|
+
return a;
|
|
26444
|
+
};
|
|
26445
|
+
emval_returnValue = function emval_returnValue(toReturnWire, destructorsRef, handle) {
|
|
26446
|
+
var destructors = [];
|
|
26447
|
+
var result = toReturnWire(destructors, handle);
|
|
26448
|
+
if (destructors.length) {
|
|
26449
|
+
// void, primitives and any other types w/o destructors don't need to allocate a handle
|
|
26450
|
+
HEAPU32[destructorsRef >> 2] = Emval.toHandle(destructors);
|
|
26451
|
+
}
|
|
26452
|
+
return result;
|
|
26453
|
+
};
|
|
26454
|
+
emval_symbols = {};
|
|
26455
|
+
getStringOrSymbol = function getStringOrSymbol(address) {
|
|
26456
|
+
var symbol = emval_symbols[address];
|
|
26457
|
+
if (symbol === undefined) {
|
|
26458
|
+
return AsciiToString(address);
|
|
26459
|
+
}
|
|
26460
|
+
return symbol;
|
|
26461
|
+
};
|
|
26462
|
+
__emval_create_invoker = function __emval_create_invoker(argCount, argTypesPtr, kind) {
|
|
26463
|
+
var GenericWireTypeSize = 8;
|
|
26464
|
+
var _emval_lookupTypes = emval_lookupTypes(argCount, argTypesPtr),
|
|
26465
|
+
retType = _emval_lookupTypes[0],
|
|
26466
|
+
argTypes = _emval_lookupTypes.slice(1);
|
|
26467
|
+
var toReturnWire = retType.toWireType.bind(retType);
|
|
26468
|
+
var argFromPtr = argTypes.map(function (type) {
|
|
26469
|
+
return type.readValueFromPointer.bind(type);
|
|
26470
|
+
});
|
|
26471
|
+
argCount--; // remove the extracted return type
|
|
26472
|
+
|
|
26473
|
+
var captures = {
|
|
26474
|
+
toValue: Emval.toValue
|
|
26475
|
+
};
|
|
26476
|
+
var args = argFromPtr.map(function (argFromPtr, i) {
|
|
26477
|
+
var captureName = "argFromPtr" + i;
|
|
26478
|
+
captures[captureName] = argFromPtr;
|
|
26479
|
+
return captureName + "(args" + (i ? '+' + i * GenericWireTypeSize : '') + ")";
|
|
26480
|
+
});
|
|
26481
|
+
var functionBody;
|
|
26482
|
+
switch (kind) {
|
|
26483
|
+
case 0:
|
|
26484
|
+
functionBody = 'toValue(handle)';
|
|
26485
|
+
break;
|
|
26486
|
+
case 2:
|
|
26487
|
+
functionBody = 'new (toValue(handle))';
|
|
26488
|
+
break;
|
|
26489
|
+
case 3:
|
|
26490
|
+
functionBody = '';
|
|
26491
|
+
break;
|
|
26492
|
+
case 1:
|
|
26493
|
+
captures['getStringOrSymbol'] = getStringOrSymbol;
|
|
26494
|
+
functionBody = 'toValue(handle)[getStringOrSymbol(methodName)]';
|
|
26495
|
+
break;
|
|
26496
|
+
}
|
|
26497
|
+
functionBody += "(" + args + ")";
|
|
26498
|
+
if (!retType.isVoid) {
|
|
26499
|
+
captures['toReturnWire'] = toReturnWire;
|
|
26500
|
+
captures['emval_returnValue'] = emval_returnValue;
|
|
26501
|
+
functionBody = "return emval_returnValue(toReturnWire, destructorsRef, " + functionBody + ")";
|
|
26502
|
+
}
|
|
26503
|
+
functionBody = "return function (handle, methodName, destructorsRef, args) {\n " + functionBody + "\n }";
|
|
26504
|
+
var invokerFunction = new Function(Object.keys(captures), functionBody).apply(void 0, Object.values(captures));
|
|
26505
|
+
var functionName = "methodCaller<(" + argTypes.map(function (t) {
|
|
26506
|
+
return t.name;
|
|
26507
|
+
}) + ") => " + retType.name + ">";
|
|
26508
|
+
return emval_addMethodCaller(createNamedFunction(functionName, invokerFunction));
|
|
26509
|
+
};
|
|
26510
|
+
__emval_incref = function __emval_incref(handle) {
|
|
26511
|
+
if (handle > 9) {
|
|
26512
|
+
emval_handles[handle + 1] += 1;
|
|
26513
|
+
}
|
|
26514
|
+
};
|
|
26515
|
+
__emval_invoke = function __emval_invoke(caller, handle, methodName, destructorsRef, args) {
|
|
26516
|
+
return emval_methodCallers[caller](handle, methodName, destructorsRef, args);
|
|
26517
|
+
};
|
|
26518
|
+
__emval_run_destructors = function __emval_run_destructors(handle) {
|
|
26519
|
+
var destructors = Emval.toValue(handle);
|
|
26520
|
+
runDestructors(destructors);
|
|
26521
|
+
__emval_decref(handle);
|
|
26522
|
+
};
|
|
26523
|
+
INT53_MAX = 9007199254740992;
|
|
26524
|
+
INT53_MIN = -9007199254740992;
|
|
26525
|
+
bigintToI53Checked = function bigintToI53Checked(num) {
|
|
26526
|
+
return num < INT53_MIN || num > INT53_MAX ? NaN : Number(num);
|
|
26527
|
+
};
|
|
26528
|
+
__tzset_js = function __tzset_js(timezone, daylight, std_name, dst_name) {
|
|
26529
|
+
// TODO: Use (malleable) environment variables instead of system settings.
|
|
26530
|
+
var currentYear = new Date().getFullYear();
|
|
26531
|
+
var winter = new Date(currentYear, 0, 1);
|
|
26532
|
+
var summer = new Date(currentYear, 6, 1);
|
|
26533
|
+
var winterOffset = winter.getTimezoneOffset();
|
|
26534
|
+
var summerOffset = summer.getTimezoneOffset();
|
|
26535
|
+
|
|
26536
|
+
// Local standard timezone offset. Local standard time is not adjusted for
|
|
26537
|
+
// daylight savings. This code uses the fact that getTimezoneOffset returns
|
|
26538
|
+
// a greater value during Standard Time versus Daylight Saving Time (DST).
|
|
26539
|
+
// Thus it determines the expected output during Standard Time, and it
|
|
26540
|
+
// compares whether the output of the given date the same (Standard) or less
|
|
26541
|
+
// (DST).
|
|
26542
|
+
var stdTimezoneOffset = Math.max(winterOffset, summerOffset);
|
|
26543
|
+
|
|
26544
|
+
// timezone is specified as seconds west of UTC ("The external variable
|
|
26545
|
+
// `timezone` shall be set to the difference, in seconds, between
|
|
26546
|
+
// Coordinated Universal Time (UTC) and local standard time."), the same
|
|
26547
|
+
// as returned by stdTimezoneOffset.
|
|
26548
|
+
// See http://pubs.opengroup.org/onlinepubs/009695399/functions/tzset.html
|
|
26549
|
+
HEAPU32[timezone >> 2] = stdTimezoneOffset * 60;
|
|
26550
|
+
HEAP32[daylight >> 2] = Number(winterOffset != summerOffset);
|
|
26551
|
+
var extractZone = function extractZone(timezoneOffset) {
|
|
26552
|
+
// Why inverse sign?
|
|
26553
|
+
// Read here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset
|
|
26554
|
+
var sign = timezoneOffset >= 0 ? '-' : '+';
|
|
26555
|
+
var absOffset = Math.abs(timezoneOffset);
|
|
26556
|
+
var hours = String(Math.floor(absOffset / 60)).padStart(2, '0');
|
|
26557
|
+
var minutes = String(absOffset % 60).padStart(2, '0');
|
|
26558
|
+
return "UTC" + sign + hours + minutes;
|
|
26559
|
+
};
|
|
26560
|
+
var winterName = extractZone(winterOffset);
|
|
26561
|
+
var summerName = extractZone(summerOffset);
|
|
26562
|
+
if (summerOffset < winterOffset) {
|
|
26563
|
+
// Northern hemisphere
|
|
26564
|
+
stringToUTF8(winterName, std_name, 17);
|
|
26565
|
+
stringToUTF8(summerName, dst_name, 17);
|
|
26566
|
+
} else {
|
|
26567
|
+
stringToUTF8(winterName, dst_name, 17);
|
|
26568
|
+
stringToUTF8(summerName, std_name, 17);
|
|
26569
|
+
}
|
|
26570
|
+
};
|
|
26571
|
+
_emscripten_date_now = function _emscripten_date_now() {
|
|
26572
|
+
return Date.now();
|
|
26573
|
+
};
|
|
26574
|
+
getHeapMax = function getHeapMax() {
|
|
26575
|
+
return (
|
|
26576
|
+
// Stay one Wasm page short of 4GB: while e.g. Chrome is able to allocate
|
|
26577
|
+
// full 4GB Wasm memories, the size will wrap back to 0 bytes in Wasm side
|
|
26578
|
+
// for any code that deals with heap sizes, which would require special
|
|
26579
|
+
// casing all heap size related code to treat 0 specially.
|
|
26580
|
+
2147483648
|
|
26581
|
+
);
|
|
26582
|
+
};
|
|
26583
|
+
alignMemory = function alignMemory(size, alignment) {
|
|
26584
|
+
return Math.ceil(size / alignment) * alignment;
|
|
26585
|
+
};
|
|
26586
|
+
growMemory = function growMemory(size) {
|
|
26587
|
+
var oldHeapSize = wasmMemory.buffer.byteLength;
|
|
26588
|
+
var pages = (size - oldHeapSize + 65535) / 65536 | 0;
|
|
26589
|
+
try {
|
|
26590
|
+
// round size grow request up to wasm page size (fixed 64KB per spec)
|
|
26591
|
+
wasmMemory.grow(pages); // .grow() takes a delta compared to the previous size
|
|
26592
|
+
updateMemoryViews();
|
|
26593
|
+
return 1; /*success*/
|
|
26594
|
+
} catch (e) {}
|
|
26595
|
+
// implicit 0 return to save code size (caller will cast "undefined" into 0
|
|
26596
|
+
// anyhow)
|
|
26597
|
+
};
|
|
26598
|
+
_emscripten_resize_heap = function _emscripten_resize_heap(requestedSize) {
|
|
26599
|
+
var oldSize = HEAPU8.length;
|
|
26600
|
+
// With CAN_ADDRESS_2GB or MEMORY64, pointers are already unsigned.
|
|
26601
|
+
requestedSize >>>= 0;
|
|
26602
|
+
// With multithreaded builds, races can happen (another thread might increase the size
|
|
26603
|
+
// in between), so return a failure, and let the caller retry.
|
|
26604
|
+
|
|
26605
|
+
// Memory resize rules:
|
|
26606
|
+
// 1. Always increase heap size to at least the requested size, rounded up
|
|
26607
|
+
// to next page multiple.
|
|
26608
|
+
// 2a. If MEMORY_GROWTH_LINEAR_STEP == -1, excessively resize the heap
|
|
26609
|
+
// geometrically: increase the heap size according to
|
|
26610
|
+
// MEMORY_GROWTH_GEOMETRIC_STEP factor (default +20%), At most
|
|
26611
|
+
// overreserve by MEMORY_GROWTH_GEOMETRIC_CAP bytes (default 96MB).
|
|
26612
|
+
// 2b. If MEMORY_GROWTH_LINEAR_STEP != -1, excessively resize the heap
|
|
26613
|
+
// linearly: increase the heap size by at least
|
|
26614
|
+
// MEMORY_GROWTH_LINEAR_STEP bytes.
|
|
26615
|
+
// 3. Max size for the heap is capped at 2048MB-WASM_PAGE_SIZE, or by
|
|
26616
|
+
// MAXIMUM_MEMORY, or by ASAN limit, depending on which is smallest
|
|
26617
|
+
// 4. If we were unable to allocate as much memory, it may be due to
|
|
26618
|
+
// over-eager decision to excessively reserve due to (3) above.
|
|
26619
|
+
// Hence if an allocation fails, cut down on the amount of excess
|
|
26620
|
+
// growth, in an attempt to succeed to perform a smaller allocation.
|
|
26621
|
+
|
|
26622
|
+
// A limit is set for how much we can grow. We should not exceed that
|
|
26623
|
+
// (the wasm binary specifies it, so if we tried, we'd fail anyhow).
|
|
26624
|
+
var maxHeapSize = getHeapMax();
|
|
26625
|
+
if (requestedSize > maxHeapSize) {
|
|
26626
|
+
return false;
|
|
26627
|
+
}
|
|
26628
|
+
|
|
26629
|
+
// Loop through potential heap size increases. If we attempt a too eager
|
|
26630
|
+
// reservation that fails, cut down on the attempted size and reserve a
|
|
26631
|
+
// smaller bump instead. (max 3 times, chosen somewhat arbitrarily)
|
|
26632
|
+
for (var cutDown = 1; cutDown <= 4; cutDown *= 2) {
|
|
26633
|
+
var overGrownHeapSize = oldSize * (1 + 0.2 / cutDown); // ensure geometric growth
|
|
26634
|
+
// but limit overreserving (default to capping at +96MB overgrowth at most)
|
|
26635
|
+
overGrownHeapSize = Math.min(overGrownHeapSize, requestedSize + 100663296);
|
|
26636
|
+
var newSize = Math.min(maxHeapSize, alignMemory(Math.max(requestedSize, overGrownHeapSize), 65536));
|
|
26637
|
+
var replacement = growMemory(newSize);
|
|
26638
|
+
if (replacement) {
|
|
26639
|
+
return true;
|
|
26640
|
+
}
|
|
26641
|
+
}
|
|
26642
|
+
return false;
|
|
26643
|
+
};
|
|
26644
|
+
ENV = {};
|
|
26645
|
+
getExecutableName = function getExecutableName() {
|
|
26646
|
+
return thisProgram;
|
|
26647
|
+
};
|
|
26648
|
+
_getEnvStrings = function getEnvStrings() {
|
|
26649
|
+
if (!_getEnvStrings.strings) {
|
|
26650
|
+
// Default values.
|
|
26651
|
+
// Browser language detection #8751
|
|
26652
|
+
var lang = (typeof navigator == 'object' && navigator.language || 'C').replace('-', '_') + '.UTF-8';
|
|
26653
|
+
var env = {
|
|
26654
|
+
USER: 'web_user',
|
|
26655
|
+
LOGNAME: 'web_user',
|
|
26656
|
+
PATH: '/',
|
|
26657
|
+
PWD: '/',
|
|
26658
|
+
HOME: '/home/web_user',
|
|
26659
|
+
LANG: lang,
|
|
26660
|
+
_: getExecutableName()
|
|
26661
|
+
};
|
|
26662
|
+
// Apply the user-provided values, if any.
|
|
26663
|
+
for (var x in ENV) {
|
|
26664
|
+
// x is a key in ENV; if ENV[x] is undefined, that means it was
|
|
26665
|
+
// explicitly set to be so. We allow user code to do that to
|
|
26666
|
+
// force variables with default values to remain unset.
|
|
26667
|
+
if (ENV[x] === undefined) delete env[x];else env[x] = ENV[x];
|
|
26668
|
+
}
|
|
26669
|
+
var strings = [];
|
|
26670
|
+
for (var x in env) {
|
|
26671
|
+
strings.push(x + "=" + env[x]);
|
|
26672
|
+
}
|
|
26673
|
+
_getEnvStrings.strings = strings;
|
|
26674
|
+
}
|
|
26675
|
+
return _getEnvStrings.strings;
|
|
26676
|
+
};
|
|
26677
|
+
_environ_get = function _environ_get(__environ, environ_buf) {
|
|
26678
|
+
var bufSize = 0;
|
|
26679
|
+
var envp = 0;
|
|
26680
|
+
for (var _iterator2 = _createForOfIteratorHelperLoose(_getEnvStrings()), _step2; !(_step2 = _iterator2()).done;) {
|
|
26681
|
+
var string = _step2.value;
|
|
26682
|
+
var ptr = environ_buf + bufSize;
|
|
26683
|
+
HEAPU32[__environ + envp >> 2] = ptr;
|
|
26684
|
+
bufSize += stringToUTF8(string, ptr, Infinity) + 1;
|
|
26685
|
+
envp += 4;
|
|
26686
|
+
}
|
|
26687
|
+
return 0;
|
|
26688
|
+
};
|
|
26689
|
+
_environ_sizes_get = function _environ_sizes_get(penviron_count, penviron_buf_size) {
|
|
26690
|
+
var strings = _getEnvStrings();
|
|
26691
|
+
HEAPU32[penviron_count >> 2] = strings.length;
|
|
26692
|
+
var bufSize = 0;
|
|
26693
|
+
for (var _iterator3 = _createForOfIteratorHelperLoose(strings), _step3; !(_step3 = _iterator3()).done;) {
|
|
26694
|
+
var string = _step3.value;
|
|
26695
|
+
bufSize += lengthBytesUTF8(string) + 1;
|
|
26696
|
+
}
|
|
26697
|
+
HEAPU32[penviron_buf_size >> 2] = bufSize;
|
|
26698
|
+
return 0;
|
|
26699
|
+
};
|
|
26700
|
+
_fd_close = function _fd_close(fd) {
|
|
26701
|
+
return 52;
|
|
26702
|
+
};
|
|
26703
|
+
printCharBuffers = [null, [], []];
|
|
26704
|
+
printChar = function printChar(stream, curr) {
|
|
26705
|
+
var buffer = printCharBuffers[stream];
|
|
26706
|
+
if (curr === 0 || curr === 10) {
|
|
26707
|
+
(stream === 1 ? out : err)(UTF8ArrayToString(buffer));
|
|
26708
|
+
buffer.length = 0;
|
|
26709
|
+
} else {
|
|
26710
|
+
buffer.push(curr);
|
|
26711
|
+
}
|
|
26712
|
+
};
|
|
26713
|
+
_fd_write = function _fd_write(fd, iov, iovcnt, pnum) {
|
|
26714
|
+
// hack to support printf in SYSCALLS_REQUIRE_FILESYSTEM=0
|
|
26715
|
+
var num = 0;
|
|
26716
|
+
for (var i = 0; i < iovcnt; i++) {
|
|
26717
|
+
var ptr = HEAPU32[iov >> 2];
|
|
26718
|
+
var len = HEAPU32[iov + 4 >> 2];
|
|
26719
|
+
iov += 8;
|
|
26720
|
+
for (var j = 0; j < len; j++) {
|
|
26721
|
+
printChar(fd, HEAPU8[ptr + j]);
|
|
26722
|
+
}
|
|
26723
|
+
num += len;
|
|
26724
|
+
}
|
|
26725
|
+
HEAPU32[pnum >> 2] = num;
|
|
26726
|
+
return 0;
|
|
26727
|
+
};
|
|
26728
|
+
init_ClassHandle();
|
|
26729
|
+
init_RegisteredPointer();
|
|
26730
|
+
|
|
26731
|
+
// Begin runtime exports
|
|
26732
|
+
// End runtime exports
|
|
26733
|
+
// Begin JS library exports
|
|
26734
|
+
// End JS library exports
|
|
26735
|
+
|
|
26736
|
+
// end include: postlibrary.js
|
|
26737
|
+
|
|
26738
|
+
// Imports from the Wasm binary.
|
|
26739
|
+
wasmImports = {
|
|
26740
|
+
/** @export */
|
|
26741
|
+
_abort_js: __abort_js,
|
|
26742
|
+
/** @export */
|
|
26743
|
+
_embind_register_bigint: __embind_register_bigint,
|
|
26744
|
+
/** @export */
|
|
26745
|
+
_embind_register_bool: __embind_register_bool,
|
|
26746
|
+
/** @export */
|
|
26747
|
+
_embind_register_class: __embind_register_class,
|
|
26748
|
+
/** @export */
|
|
26749
|
+
_embind_register_class_constructor: __embind_register_class_constructor,
|
|
26750
|
+
/** @export */
|
|
26751
|
+
_embind_register_class_function: __embind_register_class_function,
|
|
26752
|
+
/** @export */
|
|
26753
|
+
_embind_register_emval: __embind_register_emval,
|
|
26754
|
+
/** @export */
|
|
26755
|
+
_embind_register_float: __embind_register_float,
|
|
26756
|
+
/** @export */
|
|
26757
|
+
_embind_register_integer: __embind_register_integer,
|
|
26758
|
+
/** @export */
|
|
26759
|
+
_embind_register_memory_view: __embind_register_memory_view,
|
|
26760
|
+
/** @export */
|
|
26761
|
+
_embind_register_smart_ptr: __embind_register_smart_ptr,
|
|
26762
|
+
/** @export */
|
|
26763
|
+
_embind_register_std_string: __embind_register_std_string,
|
|
26764
|
+
/** @export */
|
|
26765
|
+
_embind_register_std_wstring: __embind_register_std_wstring,
|
|
26766
|
+
/** @export */
|
|
26767
|
+
_embind_register_void: __embind_register_void,
|
|
26768
|
+
/** @export */
|
|
26769
|
+
_emval_create_invoker: __emval_create_invoker,
|
|
26770
|
+
/** @export */
|
|
26771
|
+
_emval_decref: __emval_decref,
|
|
26772
|
+
/** @export */
|
|
26773
|
+
_emval_incref: __emval_incref,
|
|
26774
|
+
/** @export */
|
|
26775
|
+
_emval_invoke: __emval_invoke,
|
|
26776
|
+
/** @export */
|
|
26777
|
+
_emval_run_destructors: __emval_run_destructors,
|
|
26778
|
+
/** @export */
|
|
26779
|
+
_gmtime_js: __gmtime_js,
|
|
26780
|
+
/** @export */
|
|
26781
|
+
_tzset_js: __tzset_js,
|
|
26782
|
+
/** @export */
|
|
26783
|
+
emscripten_date_now: _emscripten_date_now,
|
|
26784
|
+
/** @export */
|
|
26785
|
+
emscripten_resize_heap: _emscripten_resize_heap,
|
|
26786
|
+
/** @export */
|
|
26787
|
+
environ_get: _environ_get,
|
|
26788
|
+
/** @export */
|
|
26789
|
+
environ_sizes_get: _environ_sizes_get,
|
|
26790
|
+
/** @export */
|
|
26791
|
+
fd_close: _fd_close,
|
|
26792
|
+
/** @export */
|
|
26793
|
+
fd_seek: _fd_seek,
|
|
26794
|
+
/** @export */
|
|
26795
|
+
fd_write: _fd_write
|
|
26796
|
+
};
|
|
26797
|
+
_context6.next = 158;
|
|
26798
|
+
return createWasm();
|
|
26799
|
+
case 158:
|
|
26800
|
+
wasmExports = _context6.sent;
|
|
26801
|
+
run();
|
|
26802
|
+
|
|
26803
|
+
// end include: postamble.js
|
|
26804
|
+
|
|
26805
|
+
// include: postamble_modularize.js
|
|
26806
|
+
// In MODULARIZE mode we wrap the generated code in a factory function
|
|
26807
|
+
// and return either the Module itself, or a promise of the module.
|
|
26808
|
+
//
|
|
26809
|
+
// We assign to the `moduleRtn` global here and configure closure to see
|
|
26810
|
+
// this as and extern so it won't get minified.
|
|
26811
|
+
|
|
26812
|
+
if (runtimeInitialized) {
|
|
26813
|
+
moduleRtn = Module;
|
|
26814
|
+
} else {
|
|
26815
|
+
// Set up the promise that indicates the Module is initialized
|
|
26816
|
+
moduleRtn = new Promise(function (resolve, reject) {
|
|
26817
|
+
readyPromiseResolve = resolve;
|
|
26818
|
+
readyPromiseReject = reject;
|
|
26819
|
+
});
|
|
26820
|
+
}
|
|
26821
|
+
|
|
26822
|
+
// end include: postamble_modularize.js
|
|
26823
|
+
return _context6.abrupt("return", moduleRtn);
|
|
26824
|
+
case 162:
|
|
26825
|
+
case "end":
|
|
26826
|
+
return _context6.stop();
|
|
26827
|
+
}
|
|
26828
|
+
}, _callee6);
|
|
26829
|
+
}));
|
|
26830
|
+
return _Module.apply(this, arguments);
|
|
26831
|
+
}
|
|
26832
|
+
var noopPrint = function noopPrint() {
|
|
26833
|
+
// No-op
|
|
26834
|
+
};
|
|
26835
|
+
function defaultLocateFile(path, prefix) {
|
|
26836
|
+
try {
|
|
26837
|
+
var url = new URL(prefix);
|
|
26838
|
+
if (url.pathname === '/') {
|
|
26839
|
+
return prefix + "mediainfo.js/dist/" + path;
|
|
26840
|
+
}
|
|
26841
|
+
} catch (_unused) {
|
|
26842
|
+
// empty
|
|
26843
|
+
}
|
|
26844
|
+
return prefix + "../" + path;
|
|
26845
|
+
}
|
|
26846
|
+
|
|
26847
|
+
// TODO pass through more emscripten module options?
|
|
26848
|
+
|
|
26849
|
+
/**
|
|
26850
|
+
* Creates a {@link MediaInfo} instance with the specified options.
|
|
26851
|
+
*
|
|
26852
|
+
* @typeParam TFormat - The format type, defaults to `object`.
|
|
26853
|
+
* @param options - Configuration options for creating the {@link MediaInfo} instance.
|
|
26854
|
+
* @returns A promise that resolves to a {@link MediaInfo} instance when no callback is provided.
|
|
26855
|
+
*/
|
|
26856
|
+
|
|
26857
|
+
/**
|
|
26858
|
+
* Creates a {@link MediaInfo} instance with the specified options and executes the callback.
|
|
26859
|
+
*
|
|
26860
|
+
* @typeParam TFormat - The format type, defaults to `object`.
|
|
26861
|
+
* @param options - Configuration options for creating the {@link MediaInfo} instance.
|
|
26862
|
+
* @param callback - Function to call with the {@link MediaInfo} instance.
|
|
26863
|
+
* @param errCallback - Optional function to call on error.
|
|
26864
|
+
*/
|
|
26865
|
+
|
|
26866
|
+
function mediaInfoFactory() {
|
|
26867
|
+
var _options$format;
|
|
26868
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
26869
|
+
var callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
26870
|
+
var errCallback = arguments.length > 2 ? arguments[2] : undefined;
|
|
26871
|
+
if (callback === undefined) {
|
|
26872
|
+
return new Promise(function (resolve, reject) {
|
|
26873
|
+
mediaInfoFactory(options, resolve, reject);
|
|
26874
|
+
});
|
|
26875
|
+
}
|
|
26876
|
+
var _DEFAULT_OPTIONS$opti = _extends({}, DEFAULT_OPTIONS, options, {
|
|
26877
|
+
format: (_options$format = options.format) != null ? _options$format : DEFAULT_OPTIONS.format
|
|
26878
|
+
}),
|
|
26879
|
+
locateFile = _DEFAULT_OPTIONS$opti.locateFile,
|
|
26880
|
+
mergedOptions = _objectWithoutPropertiesLoose(_DEFAULT_OPTIONS$opti, _excluded);
|
|
26881
|
+
var mediaInfoModuleFactoryOpts = {
|
|
26882
|
+
// Silence all print in module
|
|
26883
|
+
print: noopPrint,
|
|
26884
|
+
printErr: noopPrint,
|
|
26885
|
+
locateFile: locateFile != null ? locateFile : defaultLocateFile,
|
|
26886
|
+
onAbort: function onAbort(err) {
|
|
26887
|
+
if (errCallback) {
|
|
26888
|
+
errCallback(err);
|
|
26889
|
+
}
|
|
26890
|
+
}
|
|
26891
|
+
};
|
|
26892
|
+
|
|
26893
|
+
// Fetch and load WASM module
|
|
26894
|
+
Module(mediaInfoModuleFactoryOpts).then(function (wasmModule) {
|
|
26895
|
+
callback(new MediaInfo(wasmModule, mergedOptions));
|
|
26896
|
+
})["catch"](function (error) {
|
|
26897
|
+
if (errCallback) {
|
|
26898
|
+
errCallback(error);
|
|
26899
|
+
}
|
|
26900
|
+
});
|
|
26901
|
+
}
|
|
26902
|
+
|
|
26903
|
+
function makeReadChunk(file) {
|
|
26904
|
+
var _this = this;
|
|
26905
|
+
return function (chunkSize, offset) {
|
|
26906
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
26907
|
+
var _a;
|
|
26908
|
+
return __generator(this, function (_b) {
|
|
26909
|
+
switch (_b.label) {
|
|
26910
|
+
case 0:
|
|
26911
|
+
_a = Uint8Array.bind;
|
|
26912
|
+
return [4 /*yield*/, file.slice(offset, offset + chunkSize).arrayBuffer()];
|
|
26913
|
+
case 1:
|
|
26914
|
+
return [2 /*return*/, new (_a.apply(Uint8Array, [void 0, _b.sent()]))()];
|
|
26915
|
+
}
|
|
26916
|
+
});
|
|
26917
|
+
});
|
|
26918
|
+
};
|
|
26919
|
+
}
|
|
24394
26920
|
var signatureRecorder = null;
|
|
24395
26921
|
var signatureChunks = [];
|
|
24396
26922
|
var videoSignatureInitialState = {
|
|
@@ -24418,27 +26944,31 @@
|
|
|
24418
26944
|
var useVideoSignatureStore = create$1()(devtools(function (set, get) {
|
|
24419
26945
|
return _assign(_assign({}, videoSignatureInitialState), {
|
|
24420
26946
|
startRecording: function startRecording(captureAudio) {
|
|
24421
|
-
var _a;
|
|
26947
|
+
var _a, _b;
|
|
24422
26948
|
if (captureAudio === void 0) {
|
|
24423
26949
|
captureAudio = false;
|
|
24424
26950
|
}
|
|
24425
26951
|
if (!camera) throw new Error('Camera not found');
|
|
24426
26952
|
// set our flag and clear whatever we have recorded so far.
|
|
24427
|
-
set({
|
|
24428
|
-
recordingStartedAt: performance.now()
|
|
24429
|
-
});
|
|
24430
26953
|
signatureChunks = [];
|
|
24431
|
-
|
|
24432
|
-
useVideoRecorderStore.getState().startRecordingVideo(captureAudio);
|
|
26954
|
+
var outputCanvas = get().outputCanvas;
|
|
24433
26955
|
// start recording from the output canvas to capture the signature
|
|
24434
|
-
var
|
|
24435
|
-
|
|
24436
|
-
var
|
|
24437
|
-
if (
|
|
26956
|
+
var outputStream = (_a = outputCanvas.current) === null || _a === void 0 ? void 0 : _a.captureStream(24);
|
|
26957
|
+
if (!outputStream) throw new Error('outputStream not found');
|
|
26958
|
+
var tracks = [outputStream.getVideoTracks()[0]];
|
|
26959
|
+
if (captureAudio) {
|
|
26960
|
+
var audioTrack = (_b = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getAudioTracks()) === null || _b === void 0 ? void 0 : _b[0];
|
|
26961
|
+
if (audioTrack) tracks.push(audioTrack);
|
|
26962
|
+
}
|
|
24438
26963
|
signatureRecorder = new MediaRecorder(new MediaStream(tracks), {
|
|
24439
|
-
videoBitsPerSecond:
|
|
26964
|
+
videoBitsPerSecond: 650000,
|
|
24440
26965
|
audioBitsPerSecond: 32000
|
|
24441
26966
|
});
|
|
26967
|
+
signatureRecorder.onstart = function () {
|
|
26968
|
+
set({
|
|
26969
|
+
recordingStartedAt: performance.now()
|
|
26970
|
+
});
|
|
26971
|
+
};
|
|
24442
26972
|
var hasFirstChunk = false;
|
|
24443
26973
|
signatureRecorder.ondataavailable = function (event) {
|
|
24444
26974
|
signatureChunks.push(event.data);
|
|
@@ -24457,39 +26987,101 @@
|
|
|
24457
26987
|
signatureRecorder.start(100);
|
|
24458
26988
|
},
|
|
24459
26989
|
stopRecording: function stopRecording(signatureData, imageUrl) {
|
|
24460
|
-
set({
|
|
24461
|
-
firstChunkReceivedAt: undefined,
|
|
24462
|
-
recordingStoppedAt: performance.now()
|
|
24463
|
-
});
|
|
24464
26990
|
waitForOneMoreChunk().then(function () {
|
|
24465
26991
|
if (!signatureRecorder) return;
|
|
24466
26992
|
signatureRecorder.stop();
|
|
24467
26993
|
signatureRecorder.onstop = function () {
|
|
24468
|
-
|
|
24469
|
-
|
|
24470
|
-
|
|
26994
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
|
26995
|
+
var recordingStoppedAt, inferredType, blob, _a, onSignatureVideoCaptured, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, lastChunkReceivedAt, mediaInfo;
|
|
26996
|
+
var _b;
|
|
26997
|
+
return __generator(this, function (_c) {
|
|
26998
|
+
switch (_c.label) {
|
|
26999
|
+
case 0:
|
|
27000
|
+
recordingStoppedAt = performance.now();
|
|
27001
|
+
set({
|
|
27002
|
+
recordingStoppedAt: recordingStoppedAt
|
|
27003
|
+
});
|
|
27004
|
+
inferredType = inferBlobType(signatureChunks[0]) || (signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.mimeType) || 'video/mp4';
|
|
27005
|
+
blob = new Blob(signatureChunks, {
|
|
27006
|
+
type: inferredType
|
|
27007
|
+
});
|
|
27008
|
+
signatureChunks = [];
|
|
27009
|
+
signatureRecorder = null;
|
|
27010
|
+
if (!signatureData) return [2 /*return*/];
|
|
27011
|
+
_a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt;
|
|
27012
|
+
return [4 /*yield*/, (_b = get().mediaInfo) === null || _b === void 0 ? void 0 : _b.analyzeData(blob.size, makeReadChunk(blob))
|
|
27013
|
+
// const endMs = Math.min(
|
|
27014
|
+
// signatureEndedAt ?? Infinity,
|
|
27015
|
+
// lastChunkReceivedAt ?? Infinity,
|
|
27016
|
+
// )
|
|
27017
|
+
// const signatureStartTimestamp =
|
|
27018
|
+
// signatureStartedAt && recordingStartedAt
|
|
27019
|
+
// ? formatTimestamp(
|
|
27020
|
+
// Math.max(
|
|
27021
|
+
// 0,
|
|
27022
|
+
// signatureStartedAt -
|
|
27023
|
+
// recordingStartedAt -
|
|
27024
|
+
// RECORDING_TIMESTAMP_PADDING_MS,
|
|
27025
|
+
// ),
|
|
27026
|
+
// )
|
|
27027
|
+
// : undefined
|
|
27028
|
+
// const signatureEndTimestamp =
|
|
27029
|
+
// endMs !== Infinity && recordingStartedAt
|
|
27030
|
+
// ? formatTimestamp(
|
|
27031
|
+
// Math.min(
|
|
27032
|
+
// endMs - recordingStartedAt + RECORDING_TIMESTAMP_PADDING_MS,
|
|
27033
|
+
// lastChunkReceivedAt ?? Infinity,
|
|
27034
|
+
// ),
|
|
27035
|
+
// )
|
|
27036
|
+
// : undefined
|
|
27037
|
+
];
|
|
27038
|
+
case 1:
|
|
27039
|
+
mediaInfo = _c.sent();
|
|
27040
|
+
// const endMs = Math.min(
|
|
27041
|
+
// signatureEndedAt ?? Infinity,
|
|
27042
|
+
// lastChunkReceivedAt ?? Infinity,
|
|
27043
|
+
// )
|
|
27044
|
+
// const signatureStartTimestamp =
|
|
27045
|
+
// signatureStartedAt && recordingStartedAt
|
|
27046
|
+
// ? formatTimestamp(
|
|
27047
|
+
// Math.max(
|
|
27048
|
+
// 0,
|
|
27049
|
+
// signatureStartedAt -
|
|
27050
|
+
// recordingStartedAt -
|
|
27051
|
+
// RECORDING_TIMESTAMP_PADDING_MS,
|
|
27052
|
+
// ),
|
|
27053
|
+
// )
|
|
27054
|
+
// : undefined
|
|
27055
|
+
// const signatureEndTimestamp =
|
|
27056
|
+
// endMs !== Infinity && recordingStartedAt
|
|
27057
|
+
// ? formatTimestamp(
|
|
27058
|
+
// Math.min(
|
|
27059
|
+
// endMs - recordingStartedAt + RECORDING_TIMESTAMP_PADDING_MS,
|
|
27060
|
+
// lastChunkReceivedAt ?? Infinity,
|
|
27061
|
+
// ),
|
|
27062
|
+
// )
|
|
27063
|
+
// : undefined
|
|
27064
|
+
onSignatureVideoCaptured(blob, signatureData, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
|
|
27065
|
+
mediaInfo: mediaInfo,
|
|
27066
|
+
mimeType: inferredType,
|
|
27067
|
+
timingData: {
|
|
27068
|
+
recordingStartedAt: recordingStartedAt,
|
|
27069
|
+
firstChunkReceivedAt: firstChunkReceivedAt,
|
|
27070
|
+
signatureStartedAt: signatureStartedAt,
|
|
27071
|
+
signatureEndedAt: signatureEndedAt,
|
|
27072
|
+
recordingStoppedAt: recordingStoppedAt,
|
|
27073
|
+
lastChunkReceivedAt: lastChunkReceivedAt
|
|
27074
|
+
}
|
|
27075
|
+
});
|
|
27076
|
+
return [2 /*return*/];
|
|
27077
|
+
}
|
|
27078
|
+
});
|
|
24471
27079
|
});
|
|
24472
|
-
signatureChunks = [];
|
|
24473
|
-
signatureRecorder = null;
|
|
24474
|
-
if (!signatureData) return;
|
|
24475
|
-
var _a = get(),
|
|
24476
|
-
onSignatureVideoCaptured = _a.onSignatureVideoCaptured,
|
|
24477
|
-
recordingStartedAt = _a.recordingStartedAt,
|
|
24478
|
-
signatureStartedAt = _a.signatureStartedAt,
|
|
24479
|
-
signatureEndedAt = _a.signatureEndedAt,
|
|
24480
|
-
lastChunkReceivedAt = _a.lastChunkReceivedAt;
|
|
24481
|
-
var endMs = Math.min(signatureEndedAt !== null && signatureEndedAt !== void 0 ? signatureEndedAt : Infinity, lastChunkReceivedAt !== null && lastChunkReceivedAt !== void 0 ? lastChunkReceivedAt : Infinity);
|
|
24482
|
-
var signatureStartTimestamp = signatureStartedAt && recordingStartedAt ? formatTimestamp(Math.max(0, signatureStartedAt - recordingStartedAt - RECORDING_TIMESTAMP_PADDING_MS)) : undefined;
|
|
24483
|
-
var signatureEndTimestamp = endMs !== Infinity && recordingStartedAt ? formatTimestamp(Math.min(endMs - recordingStartedAt + RECORDING_TIMESTAMP_PADDING_MS, lastChunkReceivedAt !== null && lastChunkReceivedAt !== void 0 ? lastChunkReceivedAt : Infinity)) : undefined;
|
|
24484
|
-
onSignatureVideoCaptured(blob, signatureData, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, signatureStartTimestamp, signatureEndTimestamp);
|
|
24485
27080
|
};
|
|
24486
|
-
useVideoRecorderStore.getState().stopRecording();
|
|
24487
27081
|
});
|
|
24488
27082
|
},
|
|
24489
27083
|
clearRecordedData: function clearRecordedData() {
|
|
24490
27084
|
signatureChunks = [];
|
|
24491
|
-
useVideoRecorderStore.getState().stopRecordingVideo();
|
|
24492
|
-
useVideoRecorderStore.getState().clearRecordedData();
|
|
24493
27085
|
signatureRecorder === null || signatureRecorder === void 0 ? void 0 : signatureRecorder.stop();
|
|
24494
27086
|
signatureRecorder = null;
|
|
24495
27087
|
set({
|
|
@@ -24531,75 +27123,180 @@
|
|
|
24531
27123
|
}
|
|
24532
27124
|
function VideoSignatureContextProvider(_a) {
|
|
24533
27125
|
var _this = this;
|
|
24534
|
-
var _b, _c;
|
|
27126
|
+
var _b, _c, _d, _e;
|
|
24535
27127
|
var children = _a.children,
|
|
24536
|
-
|
|
24537
|
-
|
|
27128
|
+
_f = _a.captureMediaInfo,
|
|
27129
|
+
captureMediaInfo = _f === void 0 ? false : _f;
|
|
24538
27130
|
var videoRef = useCameraStore().videoRef;
|
|
24539
|
-
useVideoRecorder(captureAudio);
|
|
24540
27131
|
var outputCanvas = React.useRef(null);
|
|
24541
27132
|
React.useEffect(function () {
|
|
24542
27133
|
return useVideoSignatureStore.setState({
|
|
24543
27134
|
outputCanvas: outputCanvas
|
|
24544
27135
|
});
|
|
24545
27136
|
}, []);
|
|
27137
|
+
var signatureVideoRef = React.useRef(null);
|
|
27138
|
+
var frameCheckCanvas = React.useRef(null);
|
|
24546
27139
|
React.useEffect(function () {
|
|
24547
|
-
|
|
24548
|
-
|
|
24549
|
-
|
|
24550
|
-
|
|
24551
|
-
|
|
24552
|
-
|
|
24553
|
-
|
|
24554
|
-
|
|
24555
|
-
|
|
24556
|
-
|
|
24557
|
-
|
|
24558
|
-
|
|
27140
|
+
if (!captureMediaInfo) return;
|
|
27141
|
+
mediaInfoFactory({
|
|
27142
|
+
format: 'object',
|
|
27143
|
+
full: true,
|
|
27144
|
+
locateFile: function locateFile(filename) {
|
|
27145
|
+
return "".concat(DEFAULT_CDN_URL, "/").concat(filename);
|
|
27146
|
+
}
|
|
27147
|
+
}).then(function (mediaInfo) {
|
|
27148
|
+
useVideoSignatureStore.setState({
|
|
27149
|
+
mediaInfo: mediaInfo
|
|
27150
|
+
});
|
|
27151
|
+
})["catch"](function (e) {
|
|
27152
|
+
warn('error loading mediaInfo', e);
|
|
27153
|
+
});
|
|
27154
|
+
return function () {
|
|
27155
|
+
var mediaInfo = useVideoSignatureStore.getState().mediaInfo;
|
|
27156
|
+
if (mediaInfo) {
|
|
27157
|
+
mediaInfo.close();
|
|
27158
|
+
useVideoSignatureStore.setState({
|
|
27159
|
+
mediaInfo: undefined
|
|
27160
|
+
});
|
|
27161
|
+
}
|
|
27162
|
+
};
|
|
27163
|
+
}, [captureMediaInfo]);
|
|
27164
|
+
var signaturePadEmpty = useVideoSignatureStore().signaturePadEmpty;
|
|
27165
|
+
var blankCheckPassed = React.useRef(false);
|
|
27166
|
+
React.useEffect(function () {
|
|
27167
|
+
if (signaturePadEmpty) blankCheckPassed.current = false;
|
|
27168
|
+
}, [signaturePadEmpty]);
|
|
27169
|
+
var drawOutputFrame = React.useCallback(function () {
|
|
24559
27170
|
return __awaiter(_this, void 0, void 0, function () {
|
|
24560
|
-
var
|
|
27171
|
+
var ctx, _a, w, h, isPortrait, rect;
|
|
24561
27172
|
return __generator(this, function (_b) {
|
|
24562
|
-
|
|
24563
|
-
if (!outputCanvas.current || !signaturePad.current || !videoRef.current) return [2 /*return*/];
|
|
27173
|
+
if (!outputCanvas.current || !signatureVideoRef.current || !videoRef.current) return [2 /*return*/];
|
|
24564
27174
|
ctx = outputCanvas.current.getContext('2d');
|
|
24565
27175
|
if (!ctx) return [2 /*return*/];
|
|
24566
27176
|
_a = [videoRef.current.videoWidth, videoRef.current.videoHeight], w = _a[0], h = _a[1];
|
|
24567
27177
|
isPortrait = w < h;
|
|
24568
27178
|
outputCanvas.current.width = w;
|
|
24569
27179
|
outputCanvas.current.height = h;
|
|
24570
|
-
rect = [w * (isPortrait ? 0.02 : 0.15),
|
|
24571
|
-
//
|
|
27180
|
+
rect = [w * (isPortrait ? 0.02 : 0.15),
|
|
27181
|
+
// x
|
|
27182
|
+
h * (isPortrait ? 0.15 : 0.25),
|
|
27183
|
+
// y
|
|
27184
|
+
w * (isPortrait ? 0.96 : 0.7),
|
|
27185
|
+
// width
|
|
27186
|
+
h * (isPortrait ? 0.7 : 0.5) // height
|
|
27187
|
+
];
|
|
24572
27188
|
ctx.drawImage(videoRef.current, 0, 0, w, h);
|
|
24573
|
-
// draw a semi-transparent white rectangle over the video to simulate a signature pad
|
|
24574
27189
|
ctx.beginPath();
|
|
24575
27190
|
ctx.fillStyle = 'rgba(255,255,255,0.5)';
|
|
24576
|
-
ctx.roundRect
|
|
27191
|
+
if (typeof ctx.roundRect === 'function') {
|
|
27192
|
+
ctx.roundRect.apply(ctx, __spreadArray(__spreadArray([], rect, false), [16], false));
|
|
27193
|
+
} else if (typeof ctx.rect === 'function') {
|
|
27194
|
+
ctx.rect.apply(ctx, rect);
|
|
27195
|
+
}
|
|
24577
27196
|
ctx.fill();
|
|
24578
|
-
|
|
24579
|
-
|
|
27197
|
+
if (signatureVideoRef.current && blankCheckPassed.current) {
|
|
27198
|
+
ctx.drawImage.apply(ctx, __spreadArray([signatureVideoRef.current], rect, false));
|
|
27199
|
+
}
|
|
24580
27200
|
return [2 /*return*/];
|
|
24581
27201
|
});
|
|
24582
27202
|
});
|
|
24583
|
-
}, [videoRef])
|
|
24584
|
-
|
|
24585
|
-
|
|
24586
|
-
|
|
24587
|
-
|
|
24588
|
-
|
|
27203
|
+
}, [videoRef, outputCanvas]);
|
|
27204
|
+
React.useEffect(function () {
|
|
27205
|
+
if (!signatureVideoRef.current) return;
|
|
27206
|
+
var video = signatureVideoRef.current;
|
|
27207
|
+
function onFrame() {
|
|
27208
|
+
blankCheckPassed.current || (blankCheckPassed.current = !isVideoBlank(signatureVideoRef.current, frameCheckCanvas.current));
|
|
27209
|
+
drawOutputFrame();
|
|
27210
|
+
video.requestVideoFrameCallback(onFrame);
|
|
27211
|
+
}
|
|
27212
|
+
function onPlay() {
|
|
27213
|
+
video.requestVideoFrameCallback(onFrame);
|
|
27214
|
+
}
|
|
27215
|
+
video.addEventListener('play', onPlay);
|
|
27216
|
+
return function () {
|
|
27217
|
+
video.removeEventListener('play', onPlay);
|
|
27218
|
+
};
|
|
27219
|
+
}, [drawOutputFrame]);
|
|
27220
|
+
React.useEffect(function () {
|
|
27221
|
+
if (!videoRef.current) return;
|
|
27222
|
+
var video = videoRef.current;
|
|
27223
|
+
function onFrame() {
|
|
27224
|
+
drawOutputFrame();
|
|
27225
|
+
video.requestVideoFrameCallback(onFrame);
|
|
27226
|
+
}
|
|
27227
|
+
function onPlay() {
|
|
27228
|
+
video.requestVideoFrameCallback(onFrame);
|
|
27229
|
+
}
|
|
27230
|
+
video.addEventListener('play', onPlay);
|
|
27231
|
+
return function () {
|
|
27232
|
+
video.removeEventListener('play', onPlay);
|
|
27233
|
+
};
|
|
27234
|
+
}, [drawOutputFrame, videoRef]);
|
|
27235
|
+
var _g = useVideoSignatureStore(),
|
|
27236
|
+
signaturePad = _g.signaturePad,
|
|
27237
|
+
recordingStartedAt = _g.recordingStartedAt;
|
|
27238
|
+
React.useEffect(function () {
|
|
27239
|
+
var _a;
|
|
27240
|
+
if (!signaturePad.current || !recordingStartedAt) return;
|
|
27241
|
+
(_a = signatureVideoRef.current).srcObject || (_a.srcObject = signaturePad.current.getCanvas().captureStream(24));
|
|
27242
|
+
}, [recordingStartedAt, signaturePad]);
|
|
27243
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, children, /*#__PURE__*/React.createElement("video", {
|
|
27244
|
+
ref: signatureVideoRef,
|
|
27245
|
+
autoPlay: true,
|
|
27246
|
+
playsInline: true,
|
|
27247
|
+
muted: true,
|
|
27248
|
+
style: {
|
|
27249
|
+
display: 'none'
|
|
27250
|
+
// position: 'absolute',
|
|
27251
|
+
// top: 0,
|
|
27252
|
+
// left: 0,
|
|
27253
|
+
// width: '100%',
|
|
27254
|
+
// height: '100%',
|
|
27255
|
+
// zIndex: 1000,
|
|
27256
|
+
// pointerEvents: 'none',
|
|
27257
|
+
// opacity: 0.5,
|
|
27258
|
+
}
|
|
27259
|
+
}), /*#__PURE__*/React.createElement(InvisibleCanvas, {
|
|
27260
|
+
ref: frameCheckCanvas,
|
|
24589
27261
|
width: (_b = videoRef.current) === null || _b === void 0 ? void 0 : _b.videoWidth,
|
|
24590
27262
|
height: (_c = videoRef.current) === null || _c === void 0 ? void 0 : _c.videoHeight
|
|
27263
|
+
}), /*#__PURE__*/React.createElement(InvisibleCanvas, {
|
|
27264
|
+
ref: outputCanvas,
|
|
27265
|
+
width: (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoWidth,
|
|
27266
|
+
height: (_e = videoRef.current) === null || _e === void 0 ? void 0 : _e.videoHeight
|
|
24591
27267
|
}));
|
|
24592
27268
|
}
|
|
24593
|
-
function formatTimestamp(durationMs) {
|
|
24594
|
-
|
|
24595
|
-
|
|
24596
|
-
|
|
24597
|
-
|
|
24598
|
-
|
|
24599
|
-
|
|
24600
|
-
|
|
24601
|
-
|
|
24602
|
-
|
|
27269
|
+
// function formatTimestamp(durationMs: number): string {
|
|
27270
|
+
// // should be in the format of 00:00:00:00 (hh:mm:ss:cs)
|
|
27271
|
+
// const hours = Math.floor(durationMs / 3600000)
|
|
27272
|
+
// const minutes = Math.floor((durationMs % 3600000) / 60000)
|
|
27273
|
+
// const seconds = Math.floor((durationMs % 60000) / 1000)
|
|
27274
|
+
// const milliseconds = durationMs % 1000
|
|
27275
|
+
// // Convert milliseconds to centiseconds (1/100th of a second)
|
|
27276
|
+
// const centiseconds = Math.floor(milliseconds / 10)
|
|
27277
|
+
// const csString = centiseconds.toString().padStart(2, '0')
|
|
27278
|
+
// return (
|
|
27279
|
+
// `${hours.toString().padStart(2, '0')}:` +
|
|
27280
|
+
// `${minutes.toString().padStart(2, '0')}:` +
|
|
27281
|
+
// `${seconds.toString().padStart(2, '0')}:` +
|
|
27282
|
+
// `${csString}`
|
|
27283
|
+
// )
|
|
27284
|
+
// }
|
|
27285
|
+
function isVideoBlank(video, canvas) {
|
|
27286
|
+
if (!video || !canvas) return true;
|
|
27287
|
+
var ctx2 = canvas.getContext('2d');
|
|
27288
|
+
if (!ctx2) return true;
|
|
27289
|
+
ctx2.drawImage(video, 0, 0, canvas.width, canvas.height);
|
|
27290
|
+
return isCanvasBlank(canvas);
|
|
27291
|
+
}
|
|
27292
|
+
function isCanvasBlank(canvas) {
|
|
27293
|
+
var context = canvas.getContext('2d');
|
|
27294
|
+
if (!context) return true;
|
|
27295
|
+
var pixelBuffer = new Uint32Array(context.getImageData(0, 0, canvas.width, canvas.height).data.buffer);
|
|
27296
|
+
var result = !pixelBuffer.some(function (color) {
|
|
27297
|
+
return color !== 0;
|
|
27298
|
+
});
|
|
27299
|
+
return result;
|
|
24603
27300
|
}
|
|
24604
27301
|
|
|
24605
27302
|
function VideoSignaturePad(_a) {
|
|
@@ -24939,8 +27636,8 @@
|
|
|
24939
27636
|
var templateObject_1$8, templateObject_2$8, templateObject_3$7, templateObject_4$3;
|
|
24940
27637
|
|
|
24941
27638
|
var assetSelectorOpts$1 = [{
|
|
24942
|
-
value: '
|
|
24943
|
-
label: 'Video'
|
|
27639
|
+
value: 'signatureVideo',
|
|
27640
|
+
label: 'Signature Video'
|
|
24944
27641
|
}, {
|
|
24945
27642
|
value: 'selfieImage',
|
|
24946
27643
|
label: 'Selfie Image'
|
|
@@ -24955,7 +27652,7 @@
|
|
|
24955
27652
|
_d = _a.verbiage,
|
|
24956
27653
|
rawVerbiage = _d === void 0 ? {} : _d;
|
|
24957
27654
|
var ctx = useSubmissionContext();
|
|
24958
|
-
var _e = React.useState('
|
|
27655
|
+
var _e = React.useState('signatureVideo'),
|
|
24959
27656
|
displayedAsset = _e[0],
|
|
24960
27657
|
setDisplayedAsset = _e[1];
|
|
24961
27658
|
var verbiage = useTranslations(rawVerbiage, {
|
|
@@ -24993,7 +27690,7 @@
|
|
|
24993
27690
|
}, option.label));
|
|
24994
27691
|
})), /*#__PURE__*/React.createElement(OverlayImageContainer, {
|
|
24995
27692
|
className: classNames.videoContainer
|
|
24996
|
-
}, displayedAsset === '
|
|
27693
|
+
}, displayedAsset === 'signatureVideo' && ctx.signatureVideoUrl && ( /*#__PURE__*/React.createElement(StyledVideo, {
|
|
24997
27694
|
className: classNames.video,
|
|
24998
27695
|
src: ctx.signatureVideoUrl,
|
|
24999
27696
|
poster: ctx.signatureVideoUrl + '#t=0.1',
|
|
@@ -25220,59 +27917,60 @@
|
|
|
25220
27917
|
skipSuccessScreen = _c === void 0 ? false : _c,
|
|
25221
27918
|
_d = _a.captureAudio,
|
|
25222
27919
|
captureAudio = _d === void 0 ? false : _d,
|
|
25223
|
-
_e = _a.
|
|
25224
|
-
|
|
25225
|
-
_f = _a.
|
|
25226
|
-
|
|
25227
|
-
_g = _a.
|
|
25228
|
-
|
|
25229
|
-
_h = _a.
|
|
25230
|
-
|
|
25231
|
-
_j = _a.
|
|
25232
|
-
|
|
25233
|
-
_k = _a.
|
|
25234
|
-
|
|
25235
|
-
_l = _a.
|
|
25236
|
-
|
|
25237
|
-
_m = _a.
|
|
25238
|
-
|
|
27920
|
+
_e = _a.captureMediaInfo,
|
|
27921
|
+
captureMediaInfo = _e === void 0 ? false : _e,
|
|
27922
|
+
_f = _a.minSignaturePadPoints,
|
|
27923
|
+
minSignaturePadPoints = _f === void 0 ? DEFAULT_MIN_SIGNATURE_PAD_POINTS : _f,
|
|
27924
|
+
_g = _a.headTrackingDisabled,
|
|
27925
|
+
headTrackingDisabled = _g === void 0 ? false : _g,
|
|
27926
|
+
_h = _a.headTrackingBoundaryPercentage,
|
|
27927
|
+
headTrackingBoundaryPercentage = _h === void 0 ? DEFAULT_HEAD_TRACKING_BOUNDARY_PERCENTAGE : _h,
|
|
27928
|
+
_j = _a.headTrackingBoundaryType,
|
|
27929
|
+
headTrackingBoundaryType = _j === void 0 ? DEFAULT_HEAD_TRACKING_BOUNDARY_TYPE : _j,
|
|
27930
|
+
_k = _a.allowSignatureAfterLivenessCheckFailure,
|
|
27931
|
+
allowSignatureAfterLivenessCheckFailure = _k === void 0 ? false : _k,
|
|
27932
|
+
_l = _a.restartVideoOnSignaturePadCleared,
|
|
27933
|
+
restartVideoOnSignaturePadCleared = _l === void 0 ? true : _l,
|
|
27934
|
+
_m = _a.skipLivenessValidation,
|
|
27935
|
+
skipLivenessValidation = _m === void 0 ? false : _m,
|
|
27936
|
+
_o = _a.allowManualSelfieCaptureOnLoadingError,
|
|
27937
|
+
allowManualSelfieCaptureOnLoadingError = _o === void 0 ? false : _o,
|
|
25239
27938
|
faceLivenessProps = _a.faceLivenessProps,
|
|
25240
27939
|
guidesComponent = _a.guidesComponent,
|
|
25241
|
-
|
|
25242
|
-
showFaceGuideThenSignaturePad =
|
|
25243
|
-
|
|
25244
|
-
assets =
|
|
25245
|
-
|
|
25246
|
-
classNames =
|
|
25247
|
-
|
|
25248
|
-
colors =
|
|
25249
|
-
|
|
25250
|
-
verbiage =
|
|
25251
|
-
|
|
25252
|
-
debugMode =
|
|
25253
|
-
var
|
|
25254
|
-
selfieImage =
|
|
25255
|
-
setSelfieImage =
|
|
25256
|
-
setSignatureData =
|
|
25257
|
-
setSignatureVideoUrl =
|
|
25258
|
-
|
|
25259
|
-
|
|
25260
|
-
|
|
25261
|
-
uploadDocument = _u.uploadDocument;
|
|
27940
|
+
_p = _a.showFaceGuideThenSignaturePad,
|
|
27941
|
+
showFaceGuideThenSignaturePad = _p === void 0 ? false : _p,
|
|
27942
|
+
_q = _a.assets,
|
|
27943
|
+
assets = _q === void 0 ? {} : _q,
|
|
27944
|
+
_r = _a.classNames,
|
|
27945
|
+
classNames = _r === void 0 ? {} : _r,
|
|
27946
|
+
_s = _a.colors,
|
|
27947
|
+
colors = _s === void 0 ? {} : _s,
|
|
27948
|
+
_t = _a.verbiage,
|
|
27949
|
+
verbiage = _t === void 0 ? {} : _t,
|
|
27950
|
+
_u = _a.debugMode,
|
|
27951
|
+
debugMode = _u === void 0 ? false : _u;
|
|
27952
|
+
var _v = useSubmissionContext(),
|
|
27953
|
+
selfieImage = _v.selfieImage,
|
|
27954
|
+
setSelfieImage = _v.setSelfieImage,
|
|
27955
|
+
setSignatureData = _v.setSignatureData,
|
|
27956
|
+
setSignatureVideoUrl = _v.setSignatureVideoUrl,
|
|
27957
|
+
setSignatureVideoMetadata = _v.setSignatureVideoMetadata,
|
|
27958
|
+
logSelfieCaptureAttempt = _v.logSelfieCaptureAttempt,
|
|
27959
|
+
uploadDocument = _v.uploadDocument;
|
|
25262
27960
|
var cameraAccessDenied = useCameraStore(useShallow(function (state) {
|
|
25263
27961
|
return {
|
|
25264
27962
|
cameraAccessDenied: state.cameraAccessDenied
|
|
25265
27963
|
};
|
|
25266
27964
|
})).cameraAccessDenied;
|
|
25267
|
-
var
|
|
25268
|
-
captureState =
|
|
25269
|
-
setCaptureState =
|
|
27965
|
+
var _w = React.useState(skipLivenessValidation ? 'CAPTURING_SELFIE' : 'CHECKING_LIVENESS'),
|
|
27966
|
+
captureState = _w[0],
|
|
27967
|
+
setCaptureState = _w[1];
|
|
25270
27968
|
var operationStartedAt = React.useRef();
|
|
25271
27969
|
var captureStartedAt = React.useRef();
|
|
25272
27970
|
var captureEndedAt = React.useRef();
|
|
25273
|
-
var
|
|
25274
|
-
start =
|
|
25275
|
-
stop =
|
|
27971
|
+
var _x = useSelfieGuidanceModelsContext(),
|
|
27972
|
+
start = _x.start,
|
|
27973
|
+
stop = _x.stop;
|
|
25276
27974
|
React.useEffect(function () {
|
|
25277
27975
|
operationStartedAt.current = new Date();
|
|
25278
27976
|
}, []);
|
|
@@ -25316,25 +28014,24 @@
|
|
|
25316
28014
|
filetype: 'image/jpeg'
|
|
25317
28015
|
}).then(onSelfieCaptured);
|
|
25318
28016
|
}, [logCaptureMetadata, onSelfieCaptured, setSelfieImage, uploadDocument]);
|
|
25319
|
-
var onSignatureCaptureCompleted = React.useCallback(function (videoData, signatureData, signatureImageData,
|
|
28017
|
+
var onSignatureCaptureCompleted = React.useCallback(function (videoData, signatureData, signatureImageData, metadata) {
|
|
25320
28018
|
setSignatureData(signatureData);
|
|
25321
28019
|
setSignatureVideoUrl(URL.createObjectURL(videoData));
|
|
25322
|
-
|
|
25323
|
-
if (signatureEndTimestamp) setSignatureEndTimestamp(signatureEndTimestamp);
|
|
28020
|
+
setSignatureVideoMetadata(metadata);
|
|
25324
28021
|
setCaptureState('SUCCESS');
|
|
25325
|
-
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(videoData, signatureData, signatureImageData,
|
|
25326
|
-
}, [onVideoCaptured, setSignatureData,
|
|
25327
|
-
var
|
|
25328
|
-
showLoadingOverlay =
|
|
25329
|
-
setShowLoadingOverlay =
|
|
28022
|
+
onVideoCaptured === null || onVideoCaptured === void 0 ? void 0 : onVideoCaptured(videoData, signatureData, signatureImageData, metadata);
|
|
28023
|
+
}, [onVideoCaptured, setSignatureData, setSignatureVideoMetadata, setSignatureVideoUrl]);
|
|
28024
|
+
var _y = React.useState(true),
|
|
28025
|
+
showLoadingOverlay = _y[0],
|
|
28026
|
+
setShowLoadingOverlay = _y[1];
|
|
25330
28027
|
var onSignatureCaptureFacesNotDetected = React.useCallback(function () {
|
|
25331
28028
|
setShowLoadingOverlay(false);
|
|
25332
28029
|
setCaptureState(skipLivenessValidation ? 'CAPTURING_SELFIE' : 'CHECKING_LIVENESS');
|
|
25333
28030
|
useVideoSignatureStore.getState().clearRecordedData();
|
|
25334
28031
|
}, [skipLivenessValidation]);
|
|
25335
|
-
var
|
|
25336
|
-
attempt =
|
|
25337
|
-
setAttempt =
|
|
28032
|
+
var _z = React.useState(0),
|
|
28033
|
+
attempt = _z[0],
|
|
28034
|
+
setAttempt = _z[1];
|
|
25338
28035
|
var onRetry = React.useCallback(function () {
|
|
25339
28036
|
onRetryClicked === null || onRetryClicked === void 0 ? void 0 : onRetryClicked();
|
|
25340
28037
|
setAttempt(function (n) {
|
|
@@ -25383,7 +28080,7 @@
|
|
|
25383
28080
|
}, [faceLivenessOnLoadingOverlayDismissed, onLoadingOverlayDismissed]);
|
|
25384
28081
|
return /*#__PURE__*/React.createElement(VideoSignatureContextProvider, {
|
|
25385
28082
|
key: "video-signature-context-".concat(attempt),
|
|
25386
|
-
|
|
28083
|
+
captureMediaInfo: captureMediaInfo
|
|
25387
28084
|
}, /*#__PURE__*/React.createElement(CameraVideoTag, {
|
|
25388
28085
|
className: classNames.cameraFeed
|
|
25389
28086
|
}), function () {
|
|
@@ -25680,6 +28377,196 @@
|
|
|
25680
28377
|
var IdCardGuideInstructions = styled(GuidanceMessage)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n align-content: center;\n padding: 8px 12px;\n font-weight: bold;\n font-size: 18px;\n"], ["\n align-content: center;\n padding: 8px 12px;\n font-weight: bold;\n font-size: 18px;\n"])));
|
|
25681
28378
|
var templateObject_1$7, templateObject_2$7, templateObject_3$6, templateObject_4$2, templateObject_5$2, templateObject_6$1, templateObject_7, templateObject_8;
|
|
25682
28379
|
|
|
28380
|
+
var videoRecorder = null;
|
|
28381
|
+
var audioRecorder = null;
|
|
28382
|
+
var videoChunks = [];
|
|
28383
|
+
var audioChunks = [];
|
|
28384
|
+
function setVideoRecorder(recorder) {
|
|
28385
|
+
videoRecorder = recorder;
|
|
28386
|
+
}
|
|
28387
|
+
function setAudioRecorder(recorder) {
|
|
28388
|
+
audioRecorder = recorder;
|
|
28389
|
+
}
|
|
28390
|
+
function clearVideoChunks() {
|
|
28391
|
+
videoChunks = [];
|
|
28392
|
+
}
|
|
28393
|
+
function clearAudioChunks() {
|
|
28394
|
+
audioChunks = [];
|
|
28395
|
+
}
|
|
28396
|
+
var initialState$2 = {
|
|
28397
|
+
videoUrl: null,
|
|
28398
|
+
audioUrl: null,
|
|
28399
|
+
isRecordingVideo: false,
|
|
28400
|
+
isRecordingAudio: false,
|
|
28401
|
+
videoRecordingStopped: false,
|
|
28402
|
+
audioRecordingStopped: false,
|
|
28403
|
+
videoRecordingIntentionallyStopped: false,
|
|
28404
|
+
audioRecordingIntentionallyStopped: false,
|
|
28405
|
+
mergeAVStreams: false,
|
|
28406
|
+
onVideoCaptured: function onVideoCaptured() {}
|
|
28407
|
+
};
|
|
28408
|
+
var useVideoRecorderStore = create$1()(devtools(function (set, get) {
|
|
28409
|
+
return _assign(_assign({}, initialState$2), {
|
|
28410
|
+
startRecordingVideo: function startRecordingVideo(captureAudio) {
|
|
28411
|
+
var _a, _b, _c;
|
|
28412
|
+
if (captureAudio === void 0) {
|
|
28413
|
+
captureAudio = false;
|
|
28414
|
+
}
|
|
28415
|
+
if (!camera) throw new Error('Camera not found');
|
|
28416
|
+
var _d = get(),
|
|
28417
|
+
mergeAVStreams = _d.mergeAVStreams,
|
|
28418
|
+
startRecordingAudio = _d.startRecordingAudio;
|
|
28419
|
+
var videoStream = mergeAVStreams ? new MediaStream(__spreadArray(__spreadArray([], (_b = (_a = camera === null || camera === void 0 ? void 0 : camera.stream) === null || _a === void 0 ? void 0 : _a.getTracks()) !== null && _b !== void 0 ? _b : [], true), captureAudio ? (_c = audioStream === null || audioStream === void 0 ? void 0 : audioStream.getTracks()) !== null && _c !== void 0 ? _c : [] : [], true)) : camera.stream;
|
|
28420
|
+
if (!videoStream) return;
|
|
28421
|
+
clearVideoChunks();
|
|
28422
|
+
videoRecorder = null;
|
|
28423
|
+
set({
|
|
28424
|
+
isRecordingVideo: true,
|
|
28425
|
+
videoRecordingStopped: false,
|
|
28426
|
+
videoRecordingIntentionallyStopped: false
|
|
28427
|
+
});
|
|
28428
|
+
videoRecorder = new MediaRecorder(videoStream, {
|
|
28429
|
+
videoBitsPerSecond: 270000,
|
|
28430
|
+
audioBitsPerSecond: 32000
|
|
28431
|
+
});
|
|
28432
|
+
videoRecorder.ondataavailable = function (e) {
|
|
28433
|
+
videoChunks.push(e.data);
|
|
28434
|
+
};
|
|
28435
|
+
videoRecorder.onstop = function () {
|
|
28436
|
+
set({
|
|
28437
|
+
videoRecordingStopped: true
|
|
28438
|
+
});
|
|
28439
|
+
};
|
|
28440
|
+
videoRecorder.start(100);
|
|
28441
|
+
setTimeout(function () {
|
|
28442
|
+
if (!videoRecorder || videoRecorder.state === 'inactive') {
|
|
28443
|
+
log('media recorder is inactive!');
|
|
28444
|
+
// TODO: figure out what to do here
|
|
28445
|
+
}
|
|
28446
|
+
}, 100);
|
|
28447
|
+
if (captureAudio && !mergeAVStreams) {
|
|
28448
|
+
startRecordingAudio();
|
|
28449
|
+
}
|
|
28450
|
+
},
|
|
28451
|
+
stopRecordingVideo: function stopRecordingVideo() {
|
|
28452
|
+
set({
|
|
28453
|
+
videoRecordingIntentionallyStopped: true
|
|
28454
|
+
});
|
|
28455
|
+
if (videoRecorder && videoRecorder.state !== 'inactive') {
|
|
28456
|
+
videoRecorder.stop();
|
|
28457
|
+
}
|
|
28458
|
+
},
|
|
28459
|
+
startRecordingAudio: function startRecordingAudio() {
|
|
28460
|
+
if (get().mergeAVStreams) return;
|
|
28461
|
+
if (!audioStream) return;
|
|
28462
|
+
clearAudioChunks();
|
|
28463
|
+
set({
|
|
28464
|
+
isRecordingAudio: true,
|
|
28465
|
+
audioRecordingStopped: false,
|
|
28466
|
+
audioRecordingIntentionallyStopped: false
|
|
28467
|
+
});
|
|
28468
|
+
var audioRecorder = new MediaRecorder(audioStream, {
|
|
28469
|
+
audioBitsPerSecond: 32000
|
|
28470
|
+
});
|
|
28471
|
+
setAudioRecorder(audioRecorder);
|
|
28472
|
+
audioRecorder.ondataavailable = function (e) {
|
|
28473
|
+
audioChunks.push(e.data);
|
|
28474
|
+
};
|
|
28475
|
+
audioRecorder.onstop = function () {
|
|
28476
|
+
set({
|
|
28477
|
+
audioRecordingStopped: true
|
|
28478
|
+
});
|
|
28479
|
+
};
|
|
28480
|
+
audioRecorder.start(100);
|
|
28481
|
+
},
|
|
28482
|
+
stopRecordingAudio: function stopRecordingAudio() {
|
|
28483
|
+
set({
|
|
28484
|
+
audioRecordingIntentionallyStopped: true
|
|
28485
|
+
});
|
|
28486
|
+
if ((audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.state) !== 'inactive') {
|
|
28487
|
+
audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.stop(); // if you call this while state === 'inactive', an exception is thrown.
|
|
28488
|
+
}
|
|
28489
|
+
},
|
|
28490
|
+
stopRecording: function stopRecording() {
|
|
28491
|
+
get().stopRecordingVideo();
|
|
28492
|
+
get().stopRecordingAudio();
|
|
28493
|
+
},
|
|
28494
|
+
clearRecordedData: function clearRecordedData() {
|
|
28495
|
+
clearVideoChunks();
|
|
28496
|
+
clearAudioChunks();
|
|
28497
|
+
}
|
|
28498
|
+
});
|
|
28499
|
+
}));
|
|
28500
|
+
var useVideoRecorder = function useVideoRecorder(mergeAVStreams) {
|
|
28501
|
+
if (mergeAVStreams === void 0) {
|
|
28502
|
+
mergeAVStreams = false;
|
|
28503
|
+
}
|
|
28504
|
+
React.useEffect(function () {
|
|
28505
|
+
return useVideoRecorderStore.setState({
|
|
28506
|
+
mergeAVStreams: mergeAVStreams
|
|
28507
|
+
});
|
|
28508
|
+
}, [mergeAVStreams]);
|
|
28509
|
+
React.useEffect(function () {
|
|
28510
|
+
// clear recorded data when the component is mounted
|
|
28511
|
+
useVideoRecorderStore.getState().clearRecordedData();
|
|
28512
|
+
}, []);
|
|
28513
|
+
var processVideo = React.useCallback(function () {
|
|
28514
|
+
var inferredType = inferBlobType(videoChunks[0]) || (videoRecorder === null || videoRecorder === void 0 ? void 0 : videoRecorder.mimeType) || 'video/mp4';
|
|
28515
|
+
var videoBlob = new Blob(videoChunks, {
|
|
28516
|
+
type: inferredType
|
|
28517
|
+
});
|
|
28518
|
+
var videoUrl = URL.createObjectURL(videoBlob);
|
|
28519
|
+
useVideoRecorderStore.setState({
|
|
28520
|
+
videoUrl: videoUrl,
|
|
28521
|
+
isRecordingVideo: false
|
|
28522
|
+
});
|
|
28523
|
+
clearVideoChunks();
|
|
28524
|
+
setVideoRecorder(null);
|
|
28525
|
+
useVideoRecorderStore.getState().onVideoCaptured(videoUrl);
|
|
28526
|
+
}, []);
|
|
28527
|
+
var processAudio = React.useCallback(function () {
|
|
28528
|
+
var inferredType = inferBlobType(audioChunks[0]) || (audioRecorder === null || audioRecorder === void 0 ? void 0 : audioRecorder.mimeType) || 'audio/mp4';
|
|
28529
|
+
var audioBlob = new Blob(audioChunks, {
|
|
28530
|
+
type: inferredType
|
|
28531
|
+
});
|
|
28532
|
+
useVideoRecorderStore.setState({
|
|
28533
|
+
audioUrl: URL.createObjectURL(audioBlob),
|
|
28534
|
+
isRecordingAudio: false
|
|
28535
|
+
});
|
|
28536
|
+
clearAudioChunks();
|
|
28537
|
+
setAudioRecorder(null);
|
|
28538
|
+
}, []);
|
|
28539
|
+
var _a = useVideoRecorderStore(),
|
|
28540
|
+
videoUrl = _a.videoUrl,
|
|
28541
|
+
audioUrl = _a.audioUrl,
|
|
28542
|
+
isRecordingVideo = _a.isRecordingVideo,
|
|
28543
|
+
isRecordingAudio = _a.isRecordingAudio,
|
|
28544
|
+
videoRecordingStopped = _a.videoRecordingStopped,
|
|
28545
|
+
videoRecordingIntentionallyStopped = _a.videoRecordingIntentionallyStopped,
|
|
28546
|
+
audioRecordingStopped = _a.audioRecordingStopped,
|
|
28547
|
+
audioRecordingIntentionallyStopped = _a.audioRecordingIntentionallyStopped;
|
|
28548
|
+
React.useEffect(function () {
|
|
28549
|
+
if (videoRecordingStopped && videoRecordingIntentionallyStopped) {
|
|
28550
|
+
processVideo();
|
|
28551
|
+
}
|
|
28552
|
+
}, [processVideo, videoRecordingIntentionallyStopped, videoRecordingStopped]);
|
|
28553
|
+
React.useEffect(function () {
|
|
28554
|
+
if (audioRecordingStopped && audioRecordingIntentionallyStopped) {
|
|
28555
|
+
processAudio();
|
|
28556
|
+
}
|
|
28557
|
+
}, [audioRecordingIntentionallyStopped, audioRecordingStopped, processAudio]);
|
|
28558
|
+
return React.useMemo(function () {
|
|
28559
|
+
return {
|
|
28560
|
+
isRecordingVideo: isRecordingVideo,
|
|
28561
|
+
isRecordingAudio: isRecordingAudio,
|
|
28562
|
+
videoRecordingUnintentionallyStopped: videoRecordingStopped && !videoRecordingIntentionallyStopped,
|
|
28563
|
+
audioRecordingUnintentionallyStopped: audioRecordingStopped && !audioRecordingIntentionallyStopped,
|
|
28564
|
+
videoUrl: videoUrl,
|
|
28565
|
+
audioUrl: audioUrl
|
|
28566
|
+
};
|
|
28567
|
+
}, [audioRecordingIntentionallyStopped, audioRecordingStopped, audioUrl, isRecordingAudio, isRecordingVideo, videoRecordingIntentionallyStopped, videoRecordingStopped, videoUrl]);
|
|
28568
|
+
};
|
|
28569
|
+
|
|
25683
28570
|
var ReadTextPrompt = function ReadTextPrompt(_a) {
|
|
25684
28571
|
var onComplete = _a.onComplete,
|
|
25685
28572
|
_b = _a.durationMs,
|