meticulous-ui 3.11.0 → 3.11.2
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/cjs/utils/getJsonContentAsQr.cjs +1 -1
- package/cjs/utils/getQrAsJsonContent.cjs +1 -0
- package/cjs/utils/randomValue.cjs +1 -1
- package/index.d.ts +84 -43
- package/package.json +1 -1
- package/utils/getJsonContentAsQr.js +22 -542
- package/utils/getQrAsJsonContent.d.ts +1 -0
- package/utils/getQrAsJsonContent.js +158 -0
- package/utils/randomValue.js +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";var m=Object.create;var c=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty;var R=(t,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of y(e))!L.call(t,r)&&r!==o&&c(t,r,{get:()=>e[r],enumerable:!(a=U(e,r))||a.enumerable});return t};var S=(t,e,o)=>(o=t!=null?m(C(t)):{},R(e||!t||!t.__esModule?c(o,"default",{value:t,enumerable:!0}):o,t));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let n=null;const b=()=>(n||(n=import("https://esm.sh/qrcode@1")),n),f=t=>/^#[0-9a-fA-F]{6}$/.test(t)?t+"ff":t,p=async(t,e={})=>{var o,a;try{const{width:r=256,errorCorrectionLevel:i="M",margin:u=2,darkColor:d="#000000ff",lightColor:g="#ffffffff"}=e,s=JSON.stringify(t);if(!s||s==="undefined")return{success:!1,error:"Input is not JSON-serialisable."};const l=await b();return{success:!0,dataUrl:await((a=(o=l.default)==null?void 0:o.toDataURL)!=null?a:l.toDataURL)(s,{width:r,margin:u,errorCorrectionLevel:i,color:{dark:f(d),light:f(g)}}),text:s,byteSize:new TextEncoder().encode(s).length}}catch(r){return{success:!1,error:r.message}}};exports.default=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.create;var N=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,Z=Object.prototype.hasOwnProperty;var G=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of V(t))!Z.call(e,a)&&a!==s&&N(e,a,{get:()=>t[a],enumerable:!(o=W(t,a))||o.enumerable});return e};var F=(e,t,s)=>(s=e!=null?P(Y(e)):{},G(t||!e||!e.__esModule?N(s,"default",{value:e,enumerable:!0}):s,e));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});let S=null;const K=()=>(S||(S=import("https://esm.sh/@zxing/library@0.21.3")),S);let b=null;const X=()=>(b||(b=import("https://esm.sh/jsqr@1")),b),ee=e=>new Promise((t,s)=>{if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement&&e.complete&&e.naturalWidth>0)return t({img:e,revoke:!1});let o,a;if(typeof e=="string")o=e,a=!1;else if(typeof Blob!="undefined"&&e instanceof Blob)o=URL.createObjectURL(e),a=!0;else if(typeof HTMLCanvasElement!="undefined"&&e instanceof HTMLCanvasElement)o=e.toDataURL(),a=!1;else if(typeof ImageData!="undefined"&&e instanceof ImageData){const p=document.createElement("canvas");p.width=e.width,p.height=e.height,p.getContext("2d").putImageData(e,0,0),o=p.toDataURL(),a=!1}else if(typeof HTMLImageElement!="undefined"&&e instanceof HTMLImageElement)o=e.src,a=!1;else return s(new TypeError("Unsupported source type."));const i=new Image;i.onload=()=>t({img:i,revoke:a,objectUrl:o}),i.onerror=()=>{a&&URL.revokeObjectURL(o),s(new Error("Image failed to load."))},i.src=o}),J=(e,t=1)=>{const s=(e.naturalWidth||e.width)*t,o=(e.naturalHeight||e.height)*t,a=document.createElement("canvas");a.width=s,a.height=o;const i=a.getContext("2d");return i.imageSmoothingEnabled=!1,i.fillStyle="#ffffff",i.fillRect(0,0,s,o),i.drawImage(e,0,0,s,o),{canvas:a,ctx:i,w:s,h:o}},te=async e=>{var s,o,a,i,p,T,H,U;const t=[];try{if(e==null)return{success:!1,error:"No source provided."};let f,I,M;try{({img:f,revoke:I,objectUrl:M}=await ee(e))}catch(n){return{success:!1,error:`Could not load image: ${n.message}`}}const O=f.naturalWidth||f.width,_=f.naturalHeight||f.height;if(t.push(`img ${O}×${_}`),O===0||_===0)return I&&URL.revokeObjectURL(M),{success:!1,error:"Image has zero dimensions."};const{canvas:A,ctx:z,w:m,h:R}=J(f,1),{canvas:L,ctx:q}=J(f,4);I&&URL.revokeObjectURL(M);const B=z.getImageData(0,0,m,R).data,Q=(n,u)=>{const r=(u*m+n)*4;return`(${B[r]},${B[r+1]},${B[r+2]})`};t.push(`pixels tl=${Q(0,0)} center=${Q(Math.floor(m/2),Math.floor(R/2))} m10%=${Q(Math.round(m*.1),Math.round(R*.1))}`);{const n=Math.floor(R/2);let u=0,r=B[n*m*4]>127;for(let c=1;c<m;c++){const h=B[(n*m+c)*4]>127;h!==r&&(u++,r=h)}t.push(`mid-row transitions: ${u}`)}let l=null,D=null;if(typeof BarcodeDetector=="undefined")t.push("BarcodeDetector: not available");else try{if(!(await BarcodeDetector.getSupportedFormats()).includes("qr_code"))t.push("BarcodeDetector: qr_code not in supported formats");else{const u=new BarcodeDetector({formats:["qr_code"]});let r=await u.detect(f);if(r.length)l=r[0].rawValue,D="BarcodeDetector",t.push("BarcodeDetector: found via img");else{t.push("BarcodeDetector (img): 0 results");try{const c=await createImageBitmap(f);r=await u.detect(c),r.length?(l=r[0].rawValue,D="BarcodeDetector",t.push("BarcodeDetector: found via ImageBitmap(img)")):t.push("BarcodeDetector (ImageBitmap): 0 results")}catch(c){t.push(`BarcodeDetector ImageBitmap: threw "${(s=c==null?void 0:c.message)!=null?s:c}"`)}}}}catch(n){t.push(`BarcodeDetector: threw "${(o=n==null?void 0:n.message)!=null?o:n}"`)}if(l===null)try{const n=await K(),{MultiFormatReader:u,BinaryBitmap:r,HybridBinarizer:c,HTMLCanvasElementLuminanceSource:h,DecodeHintType:g,BarcodeFormat:w}=n,v=(j,E)=>{var k;if(typeof h!="function")return null;const x=new u;try{const d=new Map;g&&w&&(d.set(g.POSSIBLE_FORMATS,[w.QR_CODE]),d.set(g.TRY_HARDER,!0)),d.size&&x.setHints(d)}catch(d){}try{const d=new h(j),y=new r(new c(d)),$=x.decode(y);if($)return t.push(`@zxing ${E}: found QR`),$.getText()}catch(d){const y=(k=d==null?void 0:d.message)!=null?k:String(d),$=y.includes("Not Found")||y.includes("NotFoundException")||y.includes("No Multi");t.push(`@zxing ${E}: ${$?"no QR found":`threw "${y}"`}`)}return null};l=(a=v(A,"1×"))!=null?a:v(L,"4×"),l!==null&&(D="@zxing/library")}catch(n){t.push(`@zxing/library: load failed — "${(i=n==null?void 0:n.message)!=null?i:n}"`)}if(l===null)try{const n=await X(),u=(p=n.default)!=null?p:n;if(typeof u!="function")t.push(`jsQR: not a function (got ${typeof((T=n.default)!=null?T:n)})`);else{const r=(c,h,g,w)=>{const v=c.getImageData(0,0,h,g),j=(Math.floor(g/2)*h+Math.floor(h/2))*4;if(v.data[j]>200)return t.push(`jsQR ${w}: canvas appears blank (center pixel white), skipping`),null;const x=u(v.data,h,g,{inversionAttempts:"attemptBoth"});return x?(t.push(`jsQR ${w}: found QR`),x.data):(t.push(`jsQR ${w}: null`),null)};l=(H=r(z,m,R,"1×"))!=null?H:r(q,L.width,L.height,"4×"),l!==null&&(D="jsQR")}}catch(n){t.push(`jsQR: threw "${(U=n==null?void 0:n.message)!=null?U:String(n)}"`)}if(l===null)return{success:!1,error:`No QR code detected. Details: ${t.join(" | ")}`};let C;try{C=JSON.parse(l)}catch(n){return{success:!1,error:`QR decoded, but content is not valid JSON: ${l.slice(0,120)}`}}return{success:!0,json:C,text:l,source:D}}catch(f){return{success:!1,error:f.message}}};exports.default=te;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=(e,t)=>Math.random()*(t-e
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=(e,t)=>Math.random()*(t-e)+e;exports.default=r;
|
package/index.d.ts
CHANGED
|
@@ -1332,16 +1332,15 @@ export declare function waitForTransitionEnd(
|
|
|
1332
1332
|
export declare function withTimeout<T>(promise: Promise<T>, ms: number): Promise<T>;
|
|
1333
1333
|
|
|
1334
1334
|
// ---------------------------------------------------------------------------
|
|
1335
|
-
// Utility — QR code
|
|
1335
|
+
// Utility — QR code encoder
|
|
1336
1336
|
// ---------------------------------------------------------------------------
|
|
1337
1337
|
|
|
1338
1338
|
/** Options accepted by {@link getJsonContentAsQr}. */
|
|
1339
1339
|
export interface JsonQrOptions {
|
|
1340
|
-
/** Output image width in pixels
|
|
1340
|
+
/** Output image width in pixels. Default: `256`. */
|
|
1341
1341
|
width?: number;
|
|
1342
1342
|
/**
|
|
1343
1343
|
* Reed-Solomon error correction level.
|
|
1344
|
-
* Higher levels survive more physical damage but produce denser codes.
|
|
1345
1344
|
* - `'L'` ≈ 7 % restored (smallest code)
|
|
1346
1345
|
* - `'M'` ≈ 15 % restored (default)
|
|
1347
1346
|
* - `'Q'` ≈ 25 % restored
|
|
@@ -1350,60 +1349,102 @@ export interface JsonQrOptions {
|
|
|
1350
1349
|
errorCorrectionLevel?: 'L' | 'M' | 'Q' | 'H';
|
|
1351
1350
|
/** Quiet-zone width in QR modules. Default: `2`. */
|
|
1352
1351
|
margin?: number;
|
|
1353
|
-
/**
|
|
1352
|
+
/** Dark module colour as 6- or 8-char hex. Default: `'#000000ff'`. */
|
|
1354
1353
|
darkColor?: string;
|
|
1355
|
-
/**
|
|
1354
|
+
/** Light module colour as 6- or 8-char hex. Default: `'#ffffffff'`. */
|
|
1356
1355
|
lightColor?: string;
|
|
1357
1356
|
}
|
|
1358
1357
|
|
|
1359
|
-
/**
|
|
1360
|
-
export interface
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
* UTF-8 byte length of the encoded string.
|
|
1375
|
-
* Present only when `success` is `true`.
|
|
1376
|
-
*/
|
|
1377
|
-
byteSize?: number;
|
|
1378
|
-
/**
|
|
1379
|
-
* QR version selected (1–40). Higher versions encode more data but produce
|
|
1380
|
-
* larger, denser codes.
|
|
1381
|
-
* Present only when `success` is `true`.
|
|
1382
|
-
*/
|
|
1383
|
-
version?: number;
|
|
1384
|
-
/** Human-readable error message. Present only when `success` is `false`. */
|
|
1385
|
-
error?: string;
|
|
1358
|
+
/** Successful result from {@link getJsonContentAsQr}. */
|
|
1359
|
+
export interface JsonQrSuccess {
|
|
1360
|
+
success: true;
|
|
1361
|
+
/** PNG data URL (`data:image/png;base64,…`) ready for `<img src>` or download. */
|
|
1362
|
+
dataUrl: string;
|
|
1363
|
+
/** The exact string encoded — `JSON.stringify(json)`. */
|
|
1364
|
+
text: string;
|
|
1365
|
+
/** UTF-8 byte length of the encoded string. */
|
|
1366
|
+
byteSize: number;
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
/** Failure result from {@link getJsonContentAsQr}. */
|
|
1370
|
+
export interface JsonQrFailure {
|
|
1371
|
+
success: false;
|
|
1372
|
+
error: string;
|
|
1386
1373
|
}
|
|
1387
1374
|
|
|
1375
|
+
/** Result returned by {@link getJsonContentAsQr}. */
|
|
1376
|
+
export type JsonQrResult = JsonQrSuccess | JsonQrFailure;
|
|
1377
|
+
|
|
1388
1378
|
/**
|
|
1389
|
-
* Encodes a JSON-serialisable value into a
|
|
1390
|
-
* Model 2, ISO/IEC 18004) and returns the result as a PNG data URL.
|
|
1379
|
+
* Encodes a JSON-serialisable value into a QR code and returns a PNG data URL.
|
|
1391
1380
|
*
|
|
1392
|
-
*
|
|
1393
|
-
*
|
|
1394
|
-
*
|
|
1395
|
-
*
|
|
1381
|
+
* Powered by the `qrcode` package loaded on demand from esm.sh.
|
|
1382
|
+
* Requires a browser Canvas API.
|
|
1383
|
+
*
|
|
1384
|
+
* @example
|
|
1385
|
+
* ```ts
|
|
1386
|
+
* const result = await getJsonContentAsQr({ userId: 42, role: 'admin' });
|
|
1387
|
+
* if (result.success) imgEl.src = result.dataUrl;
|
|
1388
|
+
* ```
|
|
1389
|
+
*/
|
|
1390
|
+
export declare function getJsonContentAsQr(
|
|
1391
|
+
json: unknown,
|
|
1392
|
+
options?: JsonQrOptions
|
|
1393
|
+
): Promise<JsonQrResult>;
|
|
1394
|
+
|
|
1395
|
+
// ---------------------------------------------------------------------------
|
|
1396
|
+
// Utility — QR code decoder
|
|
1397
|
+
// ---------------------------------------------------------------------------
|
|
1398
|
+
|
|
1399
|
+
/**
|
|
1400
|
+
* Source types accepted by {@link getQrAsJsonContent}.
|
|
1401
|
+
* - `string` — a data URL (`data:image/…`) or any URL fetchable by the browser
|
|
1402
|
+
* - `HTMLImageElement` — an already-loaded `<img>` element
|
|
1403
|
+
* - `HTMLCanvasElement` — a canvas whose pixels contain the QR image
|
|
1404
|
+
* - `ImageData` — raw RGBA pixel data
|
|
1405
|
+
* - `Blob` / `File` — image file (e.g. from `<input type="file">`)
|
|
1406
|
+
*/
|
|
1407
|
+
export type QrSource = string | HTMLImageElement | HTMLCanvasElement | ImageData | Blob | File;
|
|
1408
|
+
|
|
1409
|
+
/** Decoder backend that successfully read the QR code. */
|
|
1410
|
+
export type QrDecodeSource = 'BarcodeDetector' | '@zxing/library' | 'jsQR';
|
|
1411
|
+
|
|
1412
|
+
/** Successful result from {@link getQrAsJsonContent}. */
|
|
1413
|
+
export interface QrJsonSuccess {
|
|
1414
|
+
success: true;
|
|
1415
|
+
/** The parsed JavaScript object decoded from the QR. */
|
|
1416
|
+
json: unknown;
|
|
1417
|
+
/** Raw string decoded from the QR before JSON parsing. */
|
|
1418
|
+
text: string;
|
|
1419
|
+
/** Which decoder backend produced the result. */
|
|
1420
|
+
source: QrDecodeSource;
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/** Failure result from {@link getQrAsJsonContent}. */
|
|
1424
|
+
export interface QrJsonFailure {
|
|
1425
|
+
success: false;
|
|
1426
|
+
error: string;
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/** Result returned by {@link getQrAsJsonContent}. */
|
|
1430
|
+
export type QrJsonResult = QrJsonSuccess | QrJsonFailure;
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Decodes a QR code image back to the JSON object that was originally encoded.
|
|
1396
1434
|
*
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1435
|
+
* Tries three decoders in priority order:
|
|
1436
|
+
* 1. Native `BarcodeDetector` API (Chrome 83+, Edge 83+, Safari 17.4+)
|
|
1437
|
+
* 2. `@zxing/library` — pure-JS ZXing port, loaded on demand from esm.sh
|
|
1438
|
+
* 3. `jsQR` — pure-JS fallback, loaded on demand from esm.sh
|
|
1399
1439
|
*
|
|
1400
1440
|
* @example
|
|
1401
1441
|
* ```ts
|
|
1402
|
-
* const
|
|
1403
|
-
*
|
|
1442
|
+
* const [file] = event.target.files;
|
|
1443
|
+
* const result = await getQrAsJsonContent(file);
|
|
1444
|
+
* if (result.success) console.log(result.json);
|
|
1404
1445
|
* ```
|
|
1405
1446
|
*/
|
|
1406
|
-
export declare function
|
|
1447
|
+
export declare function getQrAsJsonContent(source: QrSource): Promise<QrJsonResult>;
|
|
1407
1448
|
|
|
1408
1449
|
// ---------------------------------------------------------------------------
|
|
1409
1450
|
// Utility — OCR
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "meticulous-ui",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.2",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"description": "A comprehensive React UI component library with a wide range of customizable components, icons, colors, and utilities for building modern web applications.",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -1,552 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
[53, 42, 32, 24],
|
|
5
|
-
[78, 62, 46, 34],
|
|
6
|
-
[106, 84, 60, 48],
|
|
7
|
-
[134, 106, 74, 57],
|
|
8
|
-
[154, 122, 86, 69],
|
|
9
|
-
[192, 152, 108, 79],
|
|
10
|
-
[230, 180, 130, 97],
|
|
11
|
-
[271, 213, 151, 116],
|
|
12
|
-
[321, 251, 177, 135],
|
|
13
|
-
[367, 287, 203, 157],
|
|
14
|
-
[425, 331, 241, 185],
|
|
15
|
-
[458, 362, 258, 193],
|
|
16
|
-
[520, 402, 292, 215],
|
|
17
|
-
[586, 450, 322, 253],
|
|
18
|
-
[644, 504, 364, 283],
|
|
19
|
-
[718, 560, 394, 313],
|
|
20
|
-
[792, 624, 442, 341],
|
|
21
|
-
[858, 666, 482, 385],
|
|
22
|
-
[929, 711, 509, 406],
|
|
23
|
-
[1003, 779, 565, 442],
|
|
24
|
-
[1091, 857, 611, 464],
|
|
25
|
-
[1171, 911, 661, 514],
|
|
26
|
-
[1273, 997, 715, 538],
|
|
27
|
-
[1367, 1059, 751, 596],
|
|
28
|
-
[1465, 1125, 805, 628],
|
|
29
|
-
[1528, 1190, 868, 661],
|
|
30
|
-
[1628, 1264, 908, 701],
|
|
31
|
-
[1732, 1370, 982, 745],
|
|
32
|
-
[1840, 1452, 1030, 793],
|
|
33
|
-
[1952, 1538, 1112, 845],
|
|
34
|
-
[2068, 1628, 1168, 901],
|
|
35
|
-
[2188, 1722, 1228, 961],
|
|
36
|
-
[2303, 1809, 1283, 986],
|
|
37
|
-
[2431, 1911, 1351, 1054],
|
|
38
|
-
[2563, 1989, 1423, 1096],
|
|
39
|
-
[2699, 2099, 1499, 1142],
|
|
40
|
-
[2809, 2213, 1579, 1222],
|
|
41
|
-
[2953, 2331, 1663, 1276]
|
|
42
|
-
], j = [
|
|
43
|
-
[
|
|
44
|
-
[7, 1, 19, 0, 0],
|
|
45
|
-
[10, 1, 16, 0, 0],
|
|
46
|
-
[13, 1, 13, 0, 0],
|
|
47
|
-
[17, 1, 9, 0, 0]
|
|
48
|
-
],
|
|
49
|
-
[
|
|
50
|
-
[10, 1, 34, 0, 0],
|
|
51
|
-
[16, 1, 28, 0, 0],
|
|
52
|
-
[22, 1, 22, 0, 0],
|
|
53
|
-
[28, 1, 16, 0, 0]
|
|
54
|
-
],
|
|
55
|
-
[
|
|
56
|
-
[15, 1, 55, 0, 0],
|
|
57
|
-
[26, 1, 44, 0, 0],
|
|
58
|
-
[18, 2, 17, 0, 0],
|
|
59
|
-
[22, 2, 13, 0, 0]
|
|
60
|
-
],
|
|
61
|
-
[
|
|
62
|
-
[20, 1, 80, 0, 0],
|
|
63
|
-
[18, 2, 32, 0, 0],
|
|
64
|
-
[26, 2, 24, 0, 0],
|
|
65
|
-
[16, 4, 9, 0, 0]
|
|
66
|
-
],
|
|
67
|
-
[
|
|
68
|
-
[26, 1, 108, 0, 0],
|
|
69
|
-
[24, 2, 43, 0, 0],
|
|
70
|
-
[18, 2, 15, 2, 16],
|
|
71
|
-
[22, 2, 11, 2, 12]
|
|
72
|
-
],
|
|
73
|
-
[
|
|
74
|
-
[18, 2, 68, 0, 0],
|
|
75
|
-
[16, 4, 27, 0, 0],
|
|
76
|
-
[24, 4, 19, 0, 0],
|
|
77
|
-
[28, 4, 15, 0, 0]
|
|
78
|
-
],
|
|
79
|
-
[
|
|
80
|
-
[20, 2, 78, 0, 0],
|
|
81
|
-
[18, 4, 31, 0, 0],
|
|
82
|
-
[18, 2, 14, 4, 15],
|
|
83
|
-
[26, 4, 13, 1, 14]
|
|
84
|
-
],
|
|
85
|
-
[
|
|
86
|
-
[24, 2, 97, 0, 0],
|
|
87
|
-
[22, 2, 38, 2, 39],
|
|
88
|
-
[22, 4, 18, 2, 19],
|
|
89
|
-
[26, 4, 14, 2, 15]
|
|
90
|
-
],
|
|
91
|
-
[
|
|
92
|
-
[30, 2, 116, 0, 0],
|
|
93
|
-
[22, 3, 36, 2, 37],
|
|
94
|
-
[20, 4, 16, 4, 17],
|
|
95
|
-
[24, 4, 12, 4, 13]
|
|
96
|
-
],
|
|
97
|
-
[
|
|
98
|
-
[18, 2, 68, 2, 69],
|
|
99
|
-
[26, 4, 43, 1, 44],
|
|
100
|
-
[24, 6, 19, 2, 20],
|
|
101
|
-
[28, 6, 15, 2, 16]
|
|
102
|
-
],
|
|
103
|
-
[
|
|
104
|
-
[20, 4, 81, 0, 0],
|
|
105
|
-
[30, 1, 50, 4, 51],
|
|
106
|
-
[28, 4, 22, 4, 23],
|
|
107
|
-
[24, 3, 12, 8, 13]
|
|
108
|
-
],
|
|
109
|
-
[
|
|
110
|
-
[24, 2, 92, 2, 93],
|
|
111
|
-
[22, 6, 36, 2, 37],
|
|
112
|
-
[26, 4, 20, 6, 21],
|
|
113
|
-
[28, 7, 14, 4, 15]
|
|
114
|
-
],
|
|
115
|
-
[
|
|
116
|
-
[26, 4, 107, 0, 0],
|
|
117
|
-
[22, 8, 37, 1, 38],
|
|
118
|
-
[24, 8, 20, 4, 21],
|
|
119
|
-
[22, 12, 11, 4, 12]
|
|
120
|
-
],
|
|
121
|
-
[
|
|
122
|
-
[30, 3, 115, 1, 116],
|
|
123
|
-
[24, 4, 40, 5, 41],
|
|
124
|
-
[20, 11, 16, 5, 17],
|
|
125
|
-
[24, 11, 12, 5, 13]
|
|
126
|
-
],
|
|
127
|
-
[
|
|
128
|
-
[22, 5, 87, 1, 88],
|
|
129
|
-
[24, 5, 41, 5, 42],
|
|
130
|
-
[30, 5, 24, 7, 25],
|
|
131
|
-
[24, 11, 12, 7, 13]
|
|
132
|
-
],
|
|
133
|
-
[
|
|
134
|
-
[24, 5, 98, 1, 99],
|
|
135
|
-
[28, 7, 45, 3, 46],
|
|
136
|
-
[24, 15, 19, 2, 20],
|
|
137
|
-
[30, 3, 15, 13, 16]
|
|
138
|
-
],
|
|
139
|
-
[
|
|
140
|
-
[28, 1, 107, 5, 108],
|
|
141
|
-
[28, 10, 46, 1, 47],
|
|
142
|
-
[28, 1, 22, 15, 23],
|
|
143
|
-
[28, 2, 14, 17, 15]
|
|
144
|
-
],
|
|
145
|
-
[
|
|
146
|
-
[30, 5, 120, 1, 121],
|
|
147
|
-
[26, 9, 43, 4, 44],
|
|
148
|
-
[28, 17, 22, 1, 23],
|
|
149
|
-
[28, 2, 14, 19, 15]
|
|
150
|
-
],
|
|
151
|
-
[
|
|
152
|
-
[28, 3, 113, 4, 114],
|
|
153
|
-
[26, 3, 44, 11, 45],
|
|
154
|
-
[26, 17, 21, 4, 22],
|
|
155
|
-
[26, 9, 13, 16, 14]
|
|
156
|
-
],
|
|
157
|
-
[
|
|
158
|
-
[28, 3, 107, 5, 108],
|
|
159
|
-
[26, 3, 41, 13, 42],
|
|
160
|
-
[30, 15, 24, 5, 25],
|
|
161
|
-
[28, 15, 15, 10, 16]
|
|
162
|
-
],
|
|
163
|
-
[
|
|
164
|
-
[28, 4, 116, 4, 117],
|
|
165
|
-
[26, 17, 42, 0, 0],
|
|
166
|
-
[28, 17, 22, 6, 23],
|
|
167
|
-
[30, 19, 16, 6, 17]
|
|
168
|
-
],
|
|
169
|
-
[
|
|
170
|
-
[28, 2, 111, 7, 112],
|
|
171
|
-
[28, 17, 46, 0, 0],
|
|
172
|
-
[30, 7, 24, 16, 25],
|
|
173
|
-
[24, 34, 13, 0, 0]
|
|
174
|
-
],
|
|
175
|
-
[
|
|
176
|
-
[30, 4, 121, 5, 122],
|
|
177
|
-
[28, 4, 47, 14, 48],
|
|
178
|
-
[30, 11, 24, 14, 25],
|
|
179
|
-
[30, 16, 15, 14, 16]
|
|
180
|
-
],
|
|
181
|
-
[
|
|
182
|
-
[30, 6, 117, 4, 118],
|
|
183
|
-
[28, 6, 45, 14, 46],
|
|
184
|
-
[30, 11, 24, 16, 25],
|
|
185
|
-
[30, 30, 16, 2, 17]
|
|
186
|
-
],
|
|
187
|
-
[
|
|
188
|
-
[26, 8, 106, 4, 107],
|
|
189
|
-
[28, 8, 47, 13, 48],
|
|
190
|
-
[30, 7, 24, 22, 25],
|
|
191
|
-
[30, 22, 15, 13, 16]
|
|
192
|
-
],
|
|
193
|
-
[
|
|
194
|
-
[28, 10, 114, 2, 115],
|
|
195
|
-
[28, 19, 46, 4, 47],
|
|
196
|
-
[28, 28, 22, 6, 23],
|
|
197
|
-
[30, 33, 16, 4, 17]
|
|
198
|
-
],
|
|
199
|
-
[
|
|
200
|
-
[30, 8, 122, 4, 123],
|
|
201
|
-
[28, 22, 45, 3, 46],
|
|
202
|
-
[30, 8, 23, 26, 24],
|
|
203
|
-
[30, 12, 15, 28, 16]
|
|
204
|
-
],
|
|
205
|
-
[
|
|
206
|
-
[30, 3, 117, 10, 118],
|
|
207
|
-
[28, 3, 45, 23, 46],
|
|
208
|
-
[30, 4, 24, 31, 25],
|
|
209
|
-
[30, 11, 15, 31, 16]
|
|
210
|
-
],
|
|
211
|
-
[
|
|
212
|
-
[30, 7, 116, 7, 117],
|
|
213
|
-
[28, 21, 45, 7, 46],
|
|
214
|
-
[30, 1, 23, 37, 24],
|
|
215
|
-
[30, 19, 15, 26, 16]
|
|
216
|
-
],
|
|
217
|
-
[
|
|
218
|
-
[30, 5, 115, 10, 116],
|
|
219
|
-
[28, 19, 45, 10, 46],
|
|
220
|
-
[30, 15, 24, 25, 25],
|
|
221
|
-
[30, 23, 15, 25, 16]
|
|
222
|
-
],
|
|
223
|
-
[
|
|
224
|
-
[30, 13, 115, 3, 116],
|
|
225
|
-
[28, 2, 45, 29, 46],
|
|
226
|
-
[30, 42, 24, 1, 25],
|
|
227
|
-
[30, 23, 15, 28, 16]
|
|
228
|
-
],
|
|
229
|
-
[
|
|
230
|
-
[30, 17, 115, 0, 0],
|
|
231
|
-
[28, 10, 45, 23, 46],
|
|
232
|
-
[30, 10, 24, 35, 25],
|
|
233
|
-
[30, 19, 15, 35, 16]
|
|
234
|
-
],
|
|
235
|
-
[
|
|
236
|
-
[30, 17, 115, 1, 116],
|
|
237
|
-
[28, 14, 45, 21, 46],
|
|
238
|
-
[30, 29, 24, 19, 25],
|
|
239
|
-
[30, 11, 15, 46, 16]
|
|
240
|
-
],
|
|
241
|
-
[
|
|
242
|
-
[30, 13, 115, 6, 116],
|
|
243
|
-
[28, 14, 45, 23, 46],
|
|
244
|
-
[30, 44, 24, 7, 25],
|
|
245
|
-
[30, 59, 16, 1, 17]
|
|
246
|
-
],
|
|
247
|
-
[
|
|
248
|
-
[30, 12, 121, 7, 122],
|
|
249
|
-
[28, 12, 45, 26, 46],
|
|
250
|
-
[30, 39, 24, 14, 25],
|
|
251
|
-
[30, 22, 15, 41, 16]
|
|
252
|
-
],
|
|
253
|
-
[
|
|
254
|
-
[30, 6, 121, 14, 122],
|
|
255
|
-
[28, 6, 45, 34, 46],
|
|
256
|
-
[30, 46, 24, 10, 25],
|
|
257
|
-
[30, 2, 15, 64, 16]
|
|
258
|
-
],
|
|
259
|
-
[
|
|
260
|
-
[30, 17, 122, 4, 123],
|
|
261
|
-
[28, 29, 45, 14, 46],
|
|
262
|
-
[30, 49, 24, 10, 25],
|
|
263
|
-
[30, 24, 15, 46, 16]
|
|
264
|
-
],
|
|
265
|
-
[
|
|
266
|
-
[30, 4, 122, 18, 123],
|
|
267
|
-
[28, 13, 45, 32, 46],
|
|
268
|
-
[30, 48, 24, 14, 25],
|
|
269
|
-
[30, 42, 15, 32, 16]
|
|
270
|
-
],
|
|
271
|
-
[
|
|
272
|
-
[30, 20, 117, 4, 118],
|
|
273
|
-
[28, 40, 45, 7, 46],
|
|
274
|
-
[30, 43, 24, 22, 25],
|
|
275
|
-
[30, 10, 15, 67, 16]
|
|
276
|
-
],
|
|
277
|
-
[
|
|
278
|
-
[30, 19, 118, 6, 119],
|
|
279
|
-
[28, 18, 45, 31, 46],
|
|
280
|
-
[30, 34, 24, 34, 25],
|
|
281
|
-
[30, 20, 15, 61, 16]
|
|
282
|
-
]
|
|
283
|
-
], B = [
|
|
284
|
-
[],
|
|
285
|
-
[6, 18],
|
|
286
|
-
[6, 22],
|
|
287
|
-
[6, 26],
|
|
288
|
-
[6, 30],
|
|
289
|
-
[6, 34],
|
|
290
|
-
[6, 22, 38],
|
|
291
|
-
[6, 24, 42],
|
|
292
|
-
[6, 26, 46],
|
|
293
|
-
[6, 28, 50],
|
|
294
|
-
[6, 30, 54],
|
|
295
|
-
[6, 32, 58],
|
|
296
|
-
[6, 34, 62],
|
|
297
|
-
[6, 26, 46, 66],
|
|
298
|
-
[6, 26, 48, 70],
|
|
299
|
-
[6, 26, 50, 74],
|
|
300
|
-
[6, 30, 54, 78],
|
|
301
|
-
[6, 30, 56, 82],
|
|
302
|
-
[6, 30, 58, 86],
|
|
303
|
-
[6, 34, 62, 90],
|
|
304
|
-
[6, 28, 50, 72, 94],
|
|
305
|
-
[6, 26, 50, 74, 98],
|
|
306
|
-
[6, 30, 54, 78, 102],
|
|
307
|
-
[6, 28, 54, 80, 106],
|
|
308
|
-
[6, 32, 58, 84, 110],
|
|
309
|
-
[6, 30, 58, 86, 114],
|
|
310
|
-
[6, 34, 62, 90, 118],
|
|
311
|
-
[6, 26, 50, 74, 98, 122],
|
|
312
|
-
[6, 30, 54, 78, 102, 126],
|
|
313
|
-
[6, 26, 52, 78, 104, 130],
|
|
314
|
-
[6, 30, 56, 82, 108, 134],
|
|
315
|
-
[6, 34, 60, 86, 112, 138],
|
|
316
|
-
[6, 30, 58, 86, 114, 142],
|
|
317
|
-
[6, 34, 62, 90, 118, 146],
|
|
318
|
-
[6, 30, 54, 78, 102, 126, 150],
|
|
319
|
-
[6, 24, 50, 76, 102, 128, 154],
|
|
320
|
-
[6, 28, 54, 80, 106, 132, 158],
|
|
321
|
-
[6, 32, 58, 84, 110, 136, 162],
|
|
322
|
-
[6, 26, 54, 82, 110, 138, 166],
|
|
323
|
-
[6, 30, 58, 86, 114, 142, 170]
|
|
324
|
-
], U = new Uint8Array(512), _ = new Uint8Array(256);
|
|
325
|
-
(() => {
|
|
326
|
-
let o = 1;
|
|
327
|
-
for (let t = 0; t < 255; t++)
|
|
328
|
-
U[t] = o, _[o] = t, o <<= 1, o & 256 && (o ^= 285);
|
|
329
|
-
for (let t = 255; t < 512; t++) U[t] = U[t - 255];
|
|
330
|
-
})();
|
|
331
|
-
const G = (o, t) => o === 0 || t === 0 ? 0 : U[_[o] + _[t]], O = (o, t) => {
|
|
332
|
-
const e = new Uint8Array(o.length + t.length - 1);
|
|
333
|
-
for (let r = 0; r < o.length; r++)
|
|
334
|
-
for (let c = 0; c < t.length; c++) e[r + c] ^= G(o[r], t[c]);
|
|
335
|
-
return e;
|
|
336
|
-
}, T = (o) => {
|
|
337
|
-
let t = new Uint8Array([1]);
|
|
338
|
-
for (let e = 0; e < o; e++) t = O(t, new Uint8Array([1, U[e]]));
|
|
339
|
-
return t;
|
|
340
|
-
}, J = (o, t) => {
|
|
341
|
-
const e = T(t), r = new Uint8Array(o.length + t);
|
|
342
|
-
r.set(o);
|
|
343
|
-
for (let c = 0; c < o.length; c++) {
|
|
344
|
-
const a = r[c];
|
|
345
|
-
if (a !== 0) for (let i = 1; i < e.length; i++) r[c + i] ^= G(e[i], a);
|
|
346
|
-
}
|
|
347
|
-
return r.slice(o.length);
|
|
348
|
-
}, Q = (o, t, e) => {
|
|
349
|
-
const [r, c, a, i, g] = j[t - 1][e], s = c * a + i * g, f = new TextEncoder().encode(o), h = [], l = (p, M) => {
|
|
350
|
-
for (let y = M - 1; y >= 0; y--) h.push(p >> y & 1);
|
|
351
|
-
};
|
|
352
|
-
l(4, 4), l(f.length, t <= 9 ? 8 : 16);
|
|
353
|
-
for (const p of f) l(p, 8);
|
|
354
|
-
const n = s * 8;
|
|
355
|
-
for (let p = 0; p < 4 && h.length < n; p++) h.push(0);
|
|
356
|
-
for (; h.length % 8 !== 0; ) h.push(0);
|
|
357
|
-
const b = [236, 17];
|
|
358
|
-
let u = 0;
|
|
359
|
-
for (; h.length < n; ) l(b[u++ % 2], 8);
|
|
360
|
-
const d = [];
|
|
361
|
-
for (let p = 0; p < h.length; p += 8) {
|
|
362
|
-
let M = 0;
|
|
363
|
-
for (let y = 0; y < 8; y++) M = M << 1 | h[p + y];
|
|
364
|
-
d.push(M);
|
|
365
|
-
}
|
|
366
|
-
return { codewords: d, ecPerBlock: r, nb1: c, db1: a, nb2: i, db2: g };
|
|
367
|
-
}, K = (o, t, e, r, c, a) => {
|
|
368
|
-
const i = [];
|
|
369
|
-
let g = 0;
|
|
370
|
-
for (let l = 0; l < e; l++)
|
|
371
|
-
i.push(o.slice(g, g + r)), g += r;
|
|
372
|
-
for (let l = 0; l < c; l++)
|
|
373
|
-
i.push(o.slice(g, g + a)), g += a;
|
|
374
|
-
const s = i.map((l) => J(new Uint8Array(l), t)), f = [], h = Math.max(r, a || 0);
|
|
375
|
-
for (let l = 0; l < h; l++) for (const n of i) l < n.length && f.push(n[l]);
|
|
376
|
-
for (let l = 0; l < t; l++) for (const n of s) f.push(n[l]);
|
|
377
|
-
return f;
|
|
378
|
-
}, H = (o, t) => {
|
|
379
|
-
const e = 4 * o + 17, r = new Uint8Array(e * e), c = new Uint8Array(e * e), a = (n, b, u) => {
|
|
380
|
-
r[n * e + b] = u ? 1 : 0, c[n * e + b] = 1;
|
|
381
|
-
}, i = (n, b) => {
|
|
382
|
-
c[n * e + b] = 1;
|
|
383
|
-
}, g = (n, b) => {
|
|
384
|
-
for (let u = -1; u <= 7; u++)
|
|
385
|
-
for (let d = -1; d <= 7; d++) {
|
|
386
|
-
const p = n + u, M = b + d;
|
|
387
|
-
if (p < 0 || p >= e || M < 0 || M >= e) continue;
|
|
388
|
-
const y = u >= 0 && u <= 6 && d >= 0 && d <= 6;
|
|
389
|
-
a(
|
|
390
|
-
p,
|
|
391
|
-
M,
|
|
392
|
-
y && (u === 0 || u === 6 || d === 0 || d === 6 || u >= 2 && u <= 4 && d >= 2 && d <= 4)
|
|
393
|
-
);
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
|
-
g(0, 0), g(0, e - 7), g(e - 7, 0);
|
|
397
|
-
for (let n = 8; n < e - 8; n++)
|
|
398
|
-
a(6, n, n % 2 === 0), a(n, 6, n % 2 === 0);
|
|
399
|
-
a(4 * o + 9, 8, !0);
|
|
400
|
-
const s = B[o - 1];
|
|
401
|
-
for (let n = 0; n < s.length; n++)
|
|
402
|
-
for (let b = 0; b < s.length; b++) {
|
|
403
|
-
const u = s[n], d = s[b];
|
|
404
|
-
if (!c[u * e + d])
|
|
405
|
-
for (let p = -2; p <= 2; p++)
|
|
406
|
-
for (let M = -2; M <= 2; M++)
|
|
407
|
-
a(u + p, d + M, Math.abs(p) === 2 || Math.abs(M) === 2 || p === 0 && M === 0);
|
|
408
|
-
}
|
|
409
|
-
for (let n = 0; n <= 8; n++)
|
|
410
|
-
i(n, 8), i(8, n);
|
|
411
|
-
for (let n = 0; n < 8; n++)
|
|
412
|
-
i(e - 1 - n, 8), i(8, e - 1 - n);
|
|
413
|
-
if (o >= 7)
|
|
414
|
-
for (let n = 0; n < 18; n++) {
|
|
415
|
-
const b = n % 6, u = Math.floor(n / 6);
|
|
416
|
-
i(b, e - 11 + u), i(e - 11 + u, b);
|
|
417
|
-
}
|
|
418
|
-
const f = [];
|
|
419
|
-
for (const n of t) for (let b = 7; b >= 0; b--) f.push(n >> b & 1);
|
|
420
|
-
let h = 0, l = !0;
|
|
421
|
-
for (let n = e - 1; n >= 1; n -= 2) {
|
|
422
|
-
n === 6 && n--;
|
|
423
|
-
for (let b = 0; b < e; b++) {
|
|
424
|
-
const u = l ? e - 1 - b : b;
|
|
425
|
-
for (let d = 0; d < 2; d++) {
|
|
426
|
-
const p = n - d;
|
|
427
|
-
c[u * e + p] || (r[u * e + p] = h < f.length ? f[h++] : 0);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
l = !l;
|
|
431
|
-
}
|
|
432
|
-
return { modules: r, reserved: c, size: e };
|
|
433
|
-
}, V = [
|
|
434
|
-
(o, t) => (o + t) % 2 === 0,
|
|
435
|
-
(o, t) => o % 2 === 0,
|
|
436
|
-
(o, t) => t % 3 === 0,
|
|
437
|
-
(o, t) => (o + t) % 3 === 0,
|
|
438
|
-
(o, t) => (Math.floor(o / 2) + Math.floor(t / 3)) % 2 === 0,
|
|
439
|
-
(o, t) => o * t % 2 + o * t % 3 === 0,
|
|
440
|
-
(o, t) => (o * t % 2 + o * t % 3) % 2 === 0,
|
|
441
|
-
(o, t) => ((o + t) % 2 + o * t % 3) % 2 === 0
|
|
442
|
-
], E = (o, t, e, r) => {
|
|
443
|
-
const c = V[r], a = new Uint8Array(o);
|
|
444
|
-
for (let i = 0; i < e; i++)
|
|
445
|
-
for (let g = 0; g < e; g++) !t[i * e + g] && c(i, g) && (a[i * e + g] ^= 1);
|
|
446
|
-
return a;
|
|
447
|
-
}, W = (o, t) => {
|
|
448
|
-
let e = 0;
|
|
449
|
-
for (let s = 0; s < t; s++)
|
|
450
|
-
for (const f of [!0, !1]) {
|
|
451
|
-
let h = 1, l = -1;
|
|
452
|
-
for (let n = 0; n < t; n++) {
|
|
453
|
-
const b = f ? o[s * t + n] : o[n * t + s];
|
|
454
|
-
b === l ? (h++, h === 5 ? e += 3 : h > 5 && e++) : (h = 1, l = b);
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
for (let s = 0; s < t - 1; s++)
|
|
458
|
-
for (let f = 0; f < t - 1; f++) {
|
|
459
|
-
const h = o[s * t + f];
|
|
460
|
-
h === o[s * t + f + 1] && h === o[(s + 1) * t + f] && h === o[(s + 1) * t + f + 1] && (e += 3);
|
|
461
|
-
}
|
|
462
|
-
const r = [1, 0, 1, 1, 1, 0, 1, 0, 0, 0, 0], c = [0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1];
|
|
463
|
-
for (let s = 0; s < t; s++)
|
|
464
|
-
for (let f = 0; f <= t - 11; f++) {
|
|
465
|
-
let h = !0, l = !0, n = !0, b = !0;
|
|
466
|
-
for (let u = 0; u < 11; u++)
|
|
467
|
-
o[s * t + f + u] !== r[u] && (h = !1), o[s * t + f + u] !== c[u] && (l = !1), o[(f + u) * t + s] !== r[u] && (n = !1), o[(f + u) * t + s] !== c[u] && (b = !1);
|
|
468
|
-
(h || l) && (e += 40), (n || b) && (e += 40);
|
|
469
|
-
}
|
|
470
|
-
const i = o.reduce((s, f) => s + f, 0) / (t * t) * 100, g = Math.floor(i / 5) * 5;
|
|
471
|
-
return e += Math.min(Math.abs(g - 50), Math.abs(g + 5 - 50)) * 2, e;
|
|
472
|
-
}, L = (o, t) => {
|
|
473
|
-
const e = N[o] << 3 | t;
|
|
474
|
-
let r = e << 10;
|
|
475
|
-
for (let c = 14; c >= 10; c--) r & 1 << c && (r ^= 1335 << c - 10);
|
|
476
|
-
return (e << 10 | r) ^ 21522;
|
|
477
|
-
}, X = [
|
|
478
|
-
[8, 0],
|
|
479
|
-
[8, 1],
|
|
480
|
-
[8, 2],
|
|
481
|
-
[8, 3],
|
|
482
|
-
[8, 4],
|
|
483
|
-
[8, 5],
|
|
484
|
-
[8, 7],
|
|
485
|
-
[8, 8],
|
|
486
|
-
[7, 8],
|
|
487
|
-
[5, 8],
|
|
488
|
-
[4, 8],
|
|
489
|
-
[3, 8],
|
|
490
|
-
[2, 8],
|
|
491
|
-
[1, 8],
|
|
492
|
-
[0, 8]
|
|
493
|
-
], D = (o, t, e) => {
|
|
494
|
-
for (let r = 0; r < 15; r++) {
|
|
495
|
-
const c = e >> r & 1, [a, i] = X[r];
|
|
496
|
-
o[a * t + i] = c, r < 7 ? o[(t - 1 - r) * t + 8] = c : o[8 * t + (t - 15 + r)] = c;
|
|
497
|
-
}
|
|
498
|
-
o[(t - 8) * t + 8] = 1;
|
|
499
|
-
}, P = (o, t, e) => {
|
|
500
|
-
let r = e << 12;
|
|
501
|
-
for (let a = 17; a >= 12; a--) r & 1 << a && (r ^= 7973 << a - 12);
|
|
502
|
-
const c = e << 12 | r;
|
|
503
|
-
for (let a = 0; a < 18; a++) {
|
|
504
|
-
const i = c >> a & 1, g = a % 6, s = Math.floor(a / 6);
|
|
505
|
-
o[g * t + (t - 11 + s)] = i, o[(t - 11 + s) * t + g] = i;
|
|
506
|
-
}
|
|
507
|
-
}, $ = (o, t, e) => {
|
|
508
|
-
const { width: r = 256, margin: c = 2, darkColor: a = "#000000", lightColor: i = "#ffffff" } = e, g = Math.max(1, Math.floor(r / (t + 2 * c))), s = g * (t + 2 * c), f = document.createElement("canvas");
|
|
509
|
-
f.width = f.height = s;
|
|
510
|
-
const h = f.getContext("2d");
|
|
511
|
-
h.fillStyle = i, h.fillRect(0, 0, s, s), h.fillStyle = a;
|
|
512
|
-
for (let l = 0; l < t; l++)
|
|
513
|
-
for (let n = 0; n < t; n++)
|
|
514
|
-
o[l * t + n] && h.fillRect((c + n) * g, (c + l) * g, g, g);
|
|
515
|
-
return f.toDataURL("image/png");
|
|
516
|
-
}, Z = (o, t = {}) => {
|
|
517
|
-
var e;
|
|
1
|
+
let o = null;
|
|
2
|
+
const g = () => (o || (o = import("https://esm.sh/qrcode@1")), o), c = (t) => /^#[0-9a-fA-F]{6}$/.test(t) ? t + "ff" : t, C = async (t, f = {}) => {
|
|
3
|
+
var a, s;
|
|
518
4
|
try {
|
|
519
5
|
const {
|
|
520
6
|
width: r = 256,
|
|
521
|
-
errorCorrectionLevel:
|
|
522
|
-
margin:
|
|
523
|
-
darkColor:
|
|
524
|
-
lightColor:
|
|
525
|
-
} =
|
|
526
|
-
if (!
|
|
7
|
+
errorCorrectionLevel: l = "M",
|
|
8
|
+
margin: i = 2,
|
|
9
|
+
darkColor: d = "#000000ff",
|
|
10
|
+
lightColor: u = "#ffffffff"
|
|
11
|
+
} = f, e = JSON.stringify(t);
|
|
12
|
+
if (!e || e === "undefined")
|
|
527
13
|
return { success: !1, error: "Input is not JSON-serialisable." };
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
D(C, x, L(f, w)), l >= 7 && P(C, x, l);
|
|
541
|
-
const m = W(C, x);
|
|
542
|
-
m < I && (I = m, A = w);
|
|
543
|
-
}
|
|
544
|
-
const k = E(S, F, x, A);
|
|
545
|
-
return D(k, x, L(f, A)), l >= 7 && P(k, x, l), { success: !0, dataUrl: $(k, x, { width: r, margin: a, darkColor: i, lightColor: g }), text: s, byteSize: h, version: l };
|
|
14
|
+
const n = await g();
|
|
15
|
+
return {
|
|
16
|
+
success: !0,
|
|
17
|
+
dataUrl: await ((s = (a = n.default) == null ? void 0 : a.toDataURL) != null ? s : n.toDataURL)(e, {
|
|
18
|
+
width: r,
|
|
19
|
+
margin: i,
|
|
20
|
+
errorCorrectionLevel: l,
|
|
21
|
+
color: { dark: c(d), light: c(u) }
|
|
22
|
+
}),
|
|
23
|
+
text: e,
|
|
24
|
+
byteSize: new TextEncoder().encode(e).length
|
|
25
|
+
};
|
|
546
26
|
} catch (r) {
|
|
547
27
|
return { success: !1, error: r.message };
|
|
548
28
|
}
|
|
549
29
|
};
|
|
550
30
|
export {
|
|
551
|
-
|
|
31
|
+
C as default
|
|
552
32
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getQrAsJsonContent as default } from '../index';
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
let H = null;
|
|
2
|
+
const A = () => (H || (H = import("https://esm.sh/@zxing/library@0.21.3")), H);
|
|
3
|
+
let S = null;
|
|
4
|
+
const q = () => (S || (S = import("https://esm.sh/jsqr@1")), S), W = (n) => new Promise((t, f) => {
|
|
5
|
+
if (typeof HTMLImageElement != "undefined" && n instanceof HTMLImageElement && n.complete && n.naturalWidth > 0)
|
|
6
|
+
return t({ img: n, revoke: !1 });
|
|
7
|
+
let o, r;
|
|
8
|
+
if (typeof n == "string")
|
|
9
|
+
o = n, r = !1;
|
|
10
|
+
else if (typeof Blob != "undefined" && n instanceof Blob)
|
|
11
|
+
o = URL.createObjectURL(n), r = !0;
|
|
12
|
+
else if (typeof HTMLCanvasElement != "undefined" && n instanceof HTMLCanvasElement)
|
|
13
|
+
o = n.toDataURL(), r = !1;
|
|
14
|
+
else if (typeof ImageData != "undefined" && n instanceof ImageData) {
|
|
15
|
+
const p = document.createElement("canvas");
|
|
16
|
+
p.width = n.width, p.height = n.height, p.getContext("2d").putImageData(n, 0, 0), o = p.toDataURL(), r = !1;
|
|
17
|
+
} else if (typeof HTMLImageElement != "undefined" && n instanceof HTMLImageElement)
|
|
18
|
+
o = n.src, r = !1;
|
|
19
|
+
else
|
|
20
|
+
return f(new TypeError("Unsupported source type."));
|
|
21
|
+
const c = new Image();
|
|
22
|
+
c.onload = () => t({ img: c, revoke: r, objectUrl: o }), c.onerror = () => {
|
|
23
|
+
r && URL.revokeObjectURL(o), f(new Error("Image failed to load."));
|
|
24
|
+
}, c.src = o;
|
|
25
|
+
}), _ = (n, t = 1) => {
|
|
26
|
+
const f = (n.naturalWidth || n.width) * t, o = (n.naturalHeight || n.height) * t, r = document.createElement("canvas");
|
|
27
|
+
r.width = f, r.height = o;
|
|
28
|
+
const c = r.getContext("2d");
|
|
29
|
+
return c.imageSmoothingEnabled = !1, c.fillStyle = "#ffffff", c.fillRect(0, 0, f, o), c.drawImage(n, 0, 0, f, o), { canvas: r, ctx: c, w: f, h: o };
|
|
30
|
+
}, V = async (n) => {
|
|
31
|
+
var f, o, r, c, p, T, U, b;
|
|
32
|
+
const t = [];
|
|
33
|
+
try {
|
|
34
|
+
if (n == null) return { success: !1, error: "No source provided." };
|
|
35
|
+
let u, I, L;
|
|
36
|
+
try {
|
|
37
|
+
({ img: u, revoke: I, objectUrl: L } = await W(n));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
return { success: !1, error: `Could not load image: ${e.message}` };
|
|
40
|
+
}
|
|
41
|
+
const z = u.naturalWidth || u.width, C = u.naturalHeight || u.height;
|
|
42
|
+
if (t.push(`img ${z}×${C}`), z === 0 || C === 0)
|
|
43
|
+
return I && URL.revokeObjectURL(L), { success: !1, error: "Image has zero dimensions." };
|
|
44
|
+
const { canvas: F, ctx: O, w: m, h: R } = _(u, 1), { canvas: M, ctx: J } = _(u, 4);
|
|
45
|
+
I && URL.revokeObjectURL(L);
|
|
46
|
+
const B = O.getImageData(0, 0, m, R).data, Q = (e, l) => {
|
|
47
|
+
const a = (l * m + e) * 4;
|
|
48
|
+
return `(${B[a]},${B[a + 1]},${B[a + 2]})`;
|
|
49
|
+
};
|
|
50
|
+
t.push(
|
|
51
|
+
`pixels tl=${Q(0, 0)} center=${Q(Math.floor(m / 2), Math.floor(R / 2))} m10%=${Q(Math.round(m * 0.1), Math.round(R * 0.1))}`
|
|
52
|
+
);
|
|
53
|
+
{
|
|
54
|
+
const e = Math.floor(R / 2);
|
|
55
|
+
let l = 0, a = B[e * m * 4] > 127;
|
|
56
|
+
for (let s = 1; s < m; s++) {
|
|
57
|
+
const h = B[(e * m + s) * 4] > 127;
|
|
58
|
+
h !== a && (l++, a = h);
|
|
59
|
+
}
|
|
60
|
+
t.push(`mid-row transitions: ${l}`);
|
|
61
|
+
}
|
|
62
|
+
let i = null, x = null;
|
|
63
|
+
if (typeof BarcodeDetector == "undefined")
|
|
64
|
+
t.push("BarcodeDetector: not available");
|
|
65
|
+
else
|
|
66
|
+
try {
|
|
67
|
+
if (!(await BarcodeDetector.getSupportedFormats()).includes("qr_code"))
|
|
68
|
+
t.push("BarcodeDetector: qr_code not in supported formats");
|
|
69
|
+
else {
|
|
70
|
+
const l = new BarcodeDetector({ formats: ["qr_code"] });
|
|
71
|
+
let a = await l.detect(u);
|
|
72
|
+
if (a.length)
|
|
73
|
+
i = a[0].rawValue, x = "BarcodeDetector", t.push("BarcodeDetector: found via img");
|
|
74
|
+
else {
|
|
75
|
+
t.push("BarcodeDetector (img): 0 results");
|
|
76
|
+
try {
|
|
77
|
+
const s = await createImageBitmap(u);
|
|
78
|
+
a = await l.detect(s), a.length ? (i = a[0].rawValue, x = "BarcodeDetector", t.push("BarcodeDetector: found via ImageBitmap(img)")) : t.push("BarcodeDetector (ImageBitmap): 0 results");
|
|
79
|
+
} catch (s) {
|
|
80
|
+
t.push(`BarcodeDetector ImageBitmap: threw "${(f = s == null ? void 0 : s.message) != null ? f : s}"`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} catch (e) {
|
|
85
|
+
t.push(`BarcodeDetector: threw "${(o = e == null ? void 0 : e.message) != null ? o : e}"`);
|
|
86
|
+
}
|
|
87
|
+
if (i === null)
|
|
88
|
+
try {
|
|
89
|
+
const e = await A(), {
|
|
90
|
+
MultiFormatReader: l,
|
|
91
|
+
BinaryBitmap: a,
|
|
92
|
+
HybridBinarizer: s,
|
|
93
|
+
HTMLCanvasElementLuminanceSource: h,
|
|
94
|
+
DecodeHintType: g,
|
|
95
|
+
BarcodeFormat: w
|
|
96
|
+
} = e, D = (j, E) => {
|
|
97
|
+
var N;
|
|
98
|
+
if (typeof h != "function") return null;
|
|
99
|
+
const $ = new l();
|
|
100
|
+
try {
|
|
101
|
+
const d = /* @__PURE__ */ new Map();
|
|
102
|
+
g && w && (d.set(g.POSSIBLE_FORMATS, [w.QR_CODE]), d.set(g.TRY_HARDER, !0)), d.size && $.setHints(d);
|
|
103
|
+
} catch (d) {
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const d = new h(j), y = new a(new s(d)), v = $.decode(y);
|
|
107
|
+
if (v)
|
|
108
|
+
return t.push(`@zxing ${E}: found QR`), v.getText();
|
|
109
|
+
} catch (d) {
|
|
110
|
+
const y = (N = d == null ? void 0 : d.message) != null ? N : String(d), v = y.includes("Not Found") || y.includes("NotFoundException") || y.includes("No Multi");
|
|
111
|
+
t.push(`@zxing ${E}: ${v ? "no QR found" : `threw "${y}"`}`);
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
115
|
+
i = (r = D(F, "1×")) != null ? r : D(M, "4×"), i !== null && (x = "@zxing/library");
|
|
116
|
+
} catch (e) {
|
|
117
|
+
t.push(`@zxing/library: load failed — "${(c = e == null ? void 0 : e.message) != null ? c : e}"`);
|
|
118
|
+
}
|
|
119
|
+
if (i === null)
|
|
120
|
+
try {
|
|
121
|
+
const e = await q(), l = (p = e.default) != null ? p : e;
|
|
122
|
+
if (typeof l != "function")
|
|
123
|
+
t.push(`jsQR: not a function (got ${typeof ((T = e.default) != null ? T : e)})`);
|
|
124
|
+
else {
|
|
125
|
+
const a = (s, h, g, w) => {
|
|
126
|
+
const D = s.getImageData(0, 0, h, g), j = (Math.floor(g / 2) * h + Math.floor(h / 2)) * 4;
|
|
127
|
+
if (D.data[j] > 200)
|
|
128
|
+
return t.push(`jsQR ${w}: canvas appears blank (center pixel white), skipping`), null;
|
|
129
|
+
const $ = l(D.data, h, g, { inversionAttempts: "attemptBoth" });
|
|
130
|
+
return $ ? (t.push(`jsQR ${w}: found QR`), $.data) : (t.push(`jsQR ${w}: null`), null);
|
|
131
|
+
};
|
|
132
|
+
i = (U = a(O, m, R, "1×")) != null ? U : a(J, M.width, M.height, "4×"), i !== null && (x = "jsQR");
|
|
133
|
+
}
|
|
134
|
+
} catch (e) {
|
|
135
|
+
t.push(`jsQR: threw "${(b = e == null ? void 0 : e.message) != null ? b : String(e)}"`);
|
|
136
|
+
}
|
|
137
|
+
if (i === null)
|
|
138
|
+
return {
|
|
139
|
+
success: !1,
|
|
140
|
+
error: `No QR code detected. Details: ${t.join(" | ")}`
|
|
141
|
+
};
|
|
142
|
+
let k;
|
|
143
|
+
try {
|
|
144
|
+
k = JSON.parse(i);
|
|
145
|
+
} catch (e) {
|
|
146
|
+
return {
|
|
147
|
+
success: !1,
|
|
148
|
+
error: `QR decoded, but content is not valid JSON: ${i.slice(0, 120)}`
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return { success: !0, json: k, text: i, source: x };
|
|
152
|
+
} catch (u) {
|
|
153
|
+
return { success: !1, error: u.message };
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
export {
|
|
157
|
+
V as default
|
|
158
|
+
};
|
package/utils/randomValue.js
CHANGED