dsh-codex-subscription 2.5.9 → 3.0.0-beta.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/README.en.md +29 -6
- package/README.md +29 -6
- package/compatibility.json +2 -12
- package/lib/client.js +2447 -89
- package/lib/index.js +1651 -22
- package/package.json +23 -22
package/lib/client.js
CHANGED
|
@@ -11,6 +11,7 @@ window.__ModuleLoader__.load({
|
|
|
11
11
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
12
|
var __getProtoOf = Object.getPrototypeOf;
|
|
13
13
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
14
15
|
var __copyProps = (to, from, except, desc) => {
|
|
15
16
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
16
17
|
key = keys[i];
|
|
@@ -486,20 +487,20 @@ window.__ModuleLoader__.load({
|
|
|
486
487
|
//#endregion
|
|
487
488
|
//#region src/client-session-compat.js
|
|
488
489
|
async function withComposerSession(sessions, id, operation) {
|
|
489
|
-
|
|
490
|
+
if (typeof sessions?.retain !== "function") throw new Error("Image composer is unavailable");
|
|
491
|
+
const reference = sessions.retain(id, { source: "controllerOperation" });
|
|
490
492
|
try {
|
|
491
|
-
|
|
492
|
-
const context = reference
|
|
493
|
+
await reference.ready;
|
|
494
|
+
const context = reference.binding.ctx;
|
|
493
495
|
if (!context) throw new Error("Image composer is unavailable");
|
|
494
496
|
return await operation(context);
|
|
495
497
|
} finally {
|
|
496
|
-
reference
|
|
498
|
+
reference.release();
|
|
497
499
|
}
|
|
498
500
|
}
|
|
499
|
-
function openComposerSession(
|
|
500
|
-
if (typeof workspace?.openSession
|
|
501
|
-
|
|
502
|
-
else throw new Error("Session navigation is unavailable");
|
|
501
|
+
function openComposerSession(_sessions, workspace, id) {
|
|
502
|
+
if (typeof workspace?.openSession !== "function") throw new Error("Session navigation is unavailable");
|
|
503
|
+
workspace.openSession(id);
|
|
503
504
|
}
|
|
504
505
|
function createSessionOpeners() {
|
|
505
506
|
const entries = /* @__PURE__ */ new Map();
|
|
@@ -1086,6 +1087,10 @@ window.__ModuleLoader__.load({
|
|
|
1086
1087
|
"runtime/cancel",
|
|
1087
1088
|
"storage/status",
|
|
1088
1089
|
"storage/clear-forecast",
|
|
1090
|
+
"remote/status",
|
|
1091
|
+
"remote/enable",
|
|
1092
|
+
"remote/disable",
|
|
1093
|
+
"remote/pair",
|
|
1089
1094
|
"reset-credit/inspect",
|
|
1090
1095
|
"reset-credit/prepare",
|
|
1091
1096
|
"reset-credit/consume",
|
|
@@ -5464,17 +5469,16 @@ window.__ModuleLoader__.load({
|
|
|
5464
5469
|
const Switch = _deepseek_ai_dsh_client_ui_primitives.Switch;
|
|
5465
5470
|
const useAnchoredPosition = _deepseek_ai_dsh_client_ui_primitives.useAnchoredPosition;
|
|
5466
5471
|
const useDismissOnOutsidePointer = _deepseek_ai_dsh_client_ui_primitives.useDismissOnOutsidePointer;
|
|
5467
|
-
const IconCheckOutline16 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5468
|
-
const IconChevronDownOutline14 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5469
|
-
const IconChevronRightOutline14 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5472
|
+
const IconCheckOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular;
|
|
5473
|
+
const IconChevronDownOutline14 = _deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutlineRegular;
|
|
5474
|
+
const IconChevronRightOutline14 = _deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular;
|
|
5470
5475
|
const Menu = _deepseek_ai_dsh_client_ui_primitives.Menu;
|
|
5471
5476
|
const Tooltip = _deepseek_ai_dsh_client_ui_primitives.Tooltip;
|
|
5472
|
-
const IconChevronLeftOutline14 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5473
|
-
const IconCloseOutline16 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5474
|
-
const IconCopyOutline16 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5475
|
-
const IconDownloadOutline16 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5476
|
-
const IconEditOutline16 = _deepseek_ai_dsh_client_ui_primitives.
|
|
5477
|
-
_deepseek_ai_dsh_client_ui_primitives.IconFullscreenOutline16 ?? _deepseek_ai_dsh_client_ui_primitives.IconFullscreenOutlineRegular;
|
|
5477
|
+
const IconChevronLeftOutline14 = _deepseek_ai_dsh_client_ui_primitives.IconChevronLeftOutlineRegular;
|
|
5478
|
+
const IconCloseOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconCloseOutlineRegular;
|
|
5479
|
+
const IconCopyOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconCopyOutlineRegular;
|
|
5480
|
+
const IconDownloadOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconDownloadOutlineRegular;
|
|
5481
|
+
const IconEditOutline16 = _deepseek_ai_dsh_client_ui_primitives.IconEditOutlineRegular;
|
|
5478
5482
|
//#endregion
|
|
5479
5483
|
//#region src/image-workspace.jsx
|
|
5480
5484
|
function ImageWorkspace(props) {
|
|
@@ -5509,16 +5513,12 @@ window.__ModuleLoader__.load({
|
|
|
5509
5513
|
//#endregion
|
|
5510
5514
|
//#region src/image-composer.js
|
|
5511
5515
|
function attachImageFiles(conversation, input, files, sessionId) {
|
|
5512
|
-
|
|
5513
|
-
const
|
|
5514
|
-
const release = modern ? (items) => conversation.releaseDraftAttachments(items) : (items) => conversation.releaseDraftImages(items);
|
|
5515
|
-
const add = modern ? input.addAttachments : input.addImages;
|
|
5516
|
-
if (typeof add !== "function" || modern && !sessionId) throw new Error("Image composer is unavailable");
|
|
5517
|
-
const created = create();
|
|
5516
|
+
if (typeof conversation.createDrafts !== "function" || typeof input.addAttachments !== "function" || !sessionId) throw new Error("Image composer is unavailable");
|
|
5517
|
+
const created = conversation.createDrafts(sessionId, files);
|
|
5518
5518
|
try {
|
|
5519
|
-
if (!
|
|
5519
|
+
if (!input.addAttachments(created.map((item) => item.id))) throw new Error("The composer is busy");
|
|
5520
5520
|
} catch (error) {
|
|
5521
|
-
|
|
5521
|
+
conversation.releaseDraftAttachments(created);
|
|
5522
5522
|
throw error;
|
|
5523
5523
|
}
|
|
5524
5524
|
return created;
|
|
@@ -5680,6 +5680,24 @@ window.__ModuleLoader__.load({
|
|
|
5680
5680
|
subagentBackend_dsh: "DSH",
|
|
5681
5681
|
subagentBackend_codex: "Codex",
|
|
5682
5682
|
connectionTitle: "连接方式",
|
|
5683
|
+
remoteTitle: "手机远程控制",
|
|
5684
|
+
remote_off: "关闭",
|
|
5685
|
+
remote_on: "开启",
|
|
5686
|
+
remoteHint: "实验功能,默认关闭。开启后,这台电脑上的 DSH 会出现在 ChatGPT 手机 App 的 Codex 主机列表里,可用手机查看对话、发消息、切换模型和审批。需要订阅账号登录;电脑要保持开机和联网。",
|
|
5687
|
+
remoteConnected: "已连接",
|
|
5688
|
+
remoteConnecting: "正在连接",
|
|
5689
|
+
remoteError: "连接失败,会自动重试",
|
|
5690
|
+
remoteStopped: "已停止",
|
|
5691
|
+
remotePhones: "{count} 个手机连接",
|
|
5692
|
+
remotePair: "显示配对码",
|
|
5693
|
+
remotePairAgain: "重新生成配对码",
|
|
5694
|
+
remotePairFailed: "无法生成配对码,请确认已登录订阅账号。",
|
|
5695
|
+
remotePairSteps: "在手机 ChatGPT App 的 Codex 里扫码,或输入下面的手动码。",
|
|
5696
|
+
remoteManualCode: "手动配对码",
|
|
5697
|
+
remoteQrLabel: "配对二维码",
|
|
5698
|
+
remoteExpires: "约 {minutes} 分钟内有效",
|
|
5699
|
+
remoteExpired: "配对码已过期,请重新生成。",
|
|
5700
|
+
remoteLimits: "手机上可以查看和继续 DSH 里的对话、新建对话、切换模型、选择权限并审批。手机暂不能直接在电脑上执行命令。",
|
|
5683
5701
|
reviewModelTitle: "Auto review 审查模型",
|
|
5684
5702
|
reviewModel_session: "当前模型",
|
|
5685
5703
|
reviewModel_official: "Codex 官方审查模型",
|
|
@@ -6267,6 +6285,24 @@ window.__ModuleLoader__.load({
|
|
|
6267
6285
|
subagentBackend_dsh: "DSH",
|
|
6268
6286
|
subagentBackend_codex: "Codex",
|
|
6269
6287
|
connectionTitle: "Connection",
|
|
6288
|
+
remoteTitle: "Phone remote control",
|
|
6289
|
+
remote_off: "Off",
|
|
6290
|
+
remote_on: "On",
|
|
6291
|
+
remoteHint: "Experimental, off by default. When on, this computer's DSH appears as a host in the ChatGPT mobile app's Codex list, so you can follow conversations, send messages, switch models and approve actions from your phone. Needs a signed-in subscription account; the computer must stay on and online.",
|
|
6292
|
+
remoteConnected: "Connected",
|
|
6293
|
+
remoteConnecting: "Connecting",
|
|
6294
|
+
remoteError: "Connection failed, retrying",
|
|
6295
|
+
remoteStopped: "Stopped",
|
|
6296
|
+
remotePhones: "{count} phone(s) connected",
|
|
6297
|
+
remotePair: "Show pairing code",
|
|
6298
|
+
remotePairAgain: "New pairing code",
|
|
6299
|
+
remotePairFailed: "Could not create a pairing code. Check that the subscription account is signed in.",
|
|
6300
|
+
remotePairSteps: "Scan this in the ChatGPT app's Codex section, or type the manual code.",
|
|
6301
|
+
remoteManualCode: "Manual pairing code",
|
|
6302
|
+
remoteQrLabel: "Pairing QR code",
|
|
6303
|
+
remoteExpires: "Valid for about {minutes} minute(s)",
|
|
6304
|
+
remoteExpired: "The pairing code expired. Create a new one.",
|
|
6305
|
+
remoteLimits: "From the phone you can follow and continue DSH conversations, start new ones, switch models, choose permissions and approve actions. The phone cannot run commands on the computer directly.",
|
|
6270
6306
|
reviewModelTitle: "Auto review model",
|
|
6271
6307
|
reviewModel_session: "Current model",
|
|
6272
6308
|
reviewModel_official: "Codex reviewer",
|
|
@@ -6999,6 +7035,7 @@ window.__ModuleLoader__.load({
|
|
|
6999
7035
|
.codexSubscriptionSettingRows>.codexImagePreference+.codexImagePreference{border-top:1px solid var(--dsw-alias-border-l2)}
|
|
7000
7036
|
.codexSubscriptionDiagnostics .codexSubscriptionSectionHead{align-items:flex-start;flex-direction:column;gap:12px}
|
|
7001
7037
|
.codexSubscriptionDiagnostics .codexSubscriptionSectionTitle{display:flex;flex-direction:column;gap:5px}
|
|
7038
|
+
.codexSubscriptionRemotePair{display:flex;gap:16px;align-items:center;flex-wrap:wrap;margin-top:8px}.codexSubscriptionRemoteQr{width:168px;height:168px;flex:none;border-radius:12px;overflow:hidden;background:#fff}.codexSubscriptionRemoteQr svg{display:block;width:100%;height:100%}.codexSubscriptionRemoteCode{margin:6px 0;font:600 20px/28px ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;letter-spacing:.08em;user-select:all}
|
|
7002
7039
|
.codexSubscriptionStorageMeter{display:flex;flex-direction:column;gap:9px;padding:12px;border-radius:10px;background:var(--dsw-alias-bg-module-platform)}
|
|
7003
7040
|
.codexSubscriptionStorageMeter>div{display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;font-size:12px;line-height:18px}
|
|
7004
7041
|
.codexSubscriptionStorageMeter output{font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}
|
|
@@ -8350,6 +8387,8 @@ window.__ModuleLoader__.load({
|
|
|
8350
8387
|
limitId: limit.id
|
|
8351
8388
|
}))).filter((window) => Number.isFinite(window.remainingPercent) && window.remainingPercent >= 0 && window.remainingPercent <= (mode === "custom" ? readCapabilitySettings(thresholds)[window.windowSeconds > 0 && window.windowSeconds <= 6 * 3600 ? "quotaShortThreshold" : "quotaLongThreshold"] : mode === "early" && window.windowSeconds > 0 && window.windowSeconds <= 6 * 3600 ? 50 : 20) && (!Number.isFinite(window.resetsAt) || window.resetsAt * 1e3 > now)).sort((a, b) => a.remainingPercent - b.remainingPercent)[0];
|
|
8352
8389
|
}
|
|
8390
|
+
//#endregion
|
|
8391
|
+
//#region src/settings-contract.js
|
|
8353
8392
|
const DISABLED_MODELS_FIELD = "disabledModels";
|
|
8354
8393
|
const AUTO_QUOTA_RETRY_FIELD = "autoQuotaRetry";
|
|
8355
8394
|
const QUICK_QUOTA_MODE_FIELD = "quickQuotaMode";
|
|
@@ -8461,10 +8500,9 @@ window.__ModuleLoader__.load({
|
|
|
8461
8500
|
const supportsCodexFastMode = (modelId) => typeof modelId === "string" && (/^gpt-5\.(?:5|6)(?:$|-)/u.test(modelId) || modelId === "gpt-5.4" || modelId === "gpt-6-astra");
|
|
8462
8501
|
//#endregion
|
|
8463
8502
|
//#region src/preference-controller.js
|
|
8464
|
-
function createPreferenceController(
|
|
8503
|
+
function createPreferenceController(rpc) {
|
|
8465
8504
|
let updating = false;
|
|
8466
8505
|
let error = false;
|
|
8467
|
-
let fallbackStatus = "loading";
|
|
8468
8506
|
let fallback;
|
|
8469
8507
|
let pendingPatch;
|
|
8470
8508
|
let failedPatch;
|
|
@@ -8483,10 +8521,8 @@ window.__ModuleLoader__.load({
|
|
|
8483
8521
|
let subagentBackendAvailable = false;
|
|
8484
8522
|
let subagentRuntimeInstalled = false;
|
|
8485
8523
|
const sameModels = (left, right) => left.length === right.length && left.every((model, index) => JSON.stringify(model) === JSON.stringify(right[index]));
|
|
8486
|
-
const nativeSnapshot = () => scope.getSnapshot();
|
|
8487
8524
|
const read = () => {
|
|
8488
|
-
const
|
|
8489
|
-
const current = native.status === "ready" ? native : fallbackStatus === "ready" ? fallback : native;
|
|
8525
|
+
const current = fallback ?? { status: "unavailable" };
|
|
8490
8526
|
const value = pendingPatch === void 0 ? current.value : {
|
|
8491
8527
|
...current.value,
|
|
8492
8528
|
...pendingPatch
|
|
@@ -8498,6 +8534,7 @@ window.__ModuleLoader__.load({
|
|
|
8498
8534
|
autoQuotaRetry: normalizeAutoQuotaRetry(value?.[AUTO_QUOTA_RETRY_FIELD]),
|
|
8499
8535
|
connectionMode: value?.connectionMode === "websocket" ? "websocket" : "sse",
|
|
8500
8536
|
reviewModel: value?.reviewModel === "official" ? "official" : "session",
|
|
8537
|
+
remoteControl: value?.remoteControl === "on" ? "on" : "off",
|
|
8501
8538
|
compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
|
|
8502
8539
|
subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
|
|
8503
8540
|
subagentBackendAvailable,
|
|
@@ -8534,11 +8571,6 @@ window.__ModuleLoader__.load({
|
|
|
8534
8571
|
snapshot = read();
|
|
8535
8572
|
for (const listener of listeners) listener();
|
|
8536
8573
|
};
|
|
8537
|
-
const disposeScope = scope.subscribe(() => {
|
|
8538
|
-
error = false;
|
|
8539
|
-
if (!updating) failedPatch = void 0;
|
|
8540
|
-
publish();
|
|
8541
|
-
});
|
|
8542
8574
|
const acceptFallback = (value) => {
|
|
8543
8575
|
subagentBackendAvailable = value?.subagentBackendAvailable === true;
|
|
8544
8576
|
subagentRuntimeInstalled = value?.subagentRuntimeInstalled === true;
|
|
@@ -8550,7 +8582,6 @@ window.__ModuleLoader__.load({
|
|
|
8550
8582
|
ultrafastModels = Array.isArray(value?.ultrafastModels) ? value.ultrafastModels : [];
|
|
8551
8583
|
catalogStatus = value?.catalogStatus;
|
|
8552
8584
|
}
|
|
8553
|
-
fallbackStatus = "ready";
|
|
8554
8585
|
fallback = {
|
|
8555
8586
|
status: "ready",
|
|
8556
8587
|
value: {
|
|
@@ -8558,6 +8589,7 @@ window.__ModuleLoader__.load({
|
|
|
8558
8589
|
[AUTO_QUOTA_RETRY_FIELD]: normalizeAutoQuotaRetry(value?.[AUTO_QUOTA_RETRY_FIELD]),
|
|
8559
8590
|
connectionMode: value?.connectionMode === "websocket" ? "websocket" : "sse",
|
|
8560
8591
|
reviewModel: value?.reviewModel === "official" ? "official" : "session",
|
|
8592
|
+
remoteControl: value?.remoteControl === "on" ? "on" : "off",
|
|
8561
8593
|
compactionMode: value?.compactionMode === "cloud" ? "cloud" : "dsh",
|
|
8562
8594
|
subagentBackend: value?.subagentBackend === "codex" ? "codex" : "dsh",
|
|
8563
8595
|
...readCapabilitySettings(value),
|
|
@@ -8578,29 +8610,16 @@ window.__ModuleLoader__.load({
|
|
|
8578
8610
|
const current = ++generation;
|
|
8579
8611
|
updating = false;
|
|
8580
8612
|
pendingPatch = void 0;
|
|
8581
|
-
fallbackStatus = "loading";
|
|
8582
8613
|
fallback = void 0;
|
|
8583
8614
|
error = false;
|
|
8584
8615
|
publish();
|
|
8585
8616
|
try {
|
|
8586
8617
|
const value = unwrap(await rpc.call(CHANNEL, "preferences/status", {}));
|
|
8587
8618
|
if (current !== generation || disposed) return;
|
|
8588
|
-
|
|
8589
|
-
subagentRuntimeInstalled = value?.subagentRuntimeInstalled === true;
|
|
8590
|
-
if (nativeSnapshot().status === "ready") {
|
|
8591
|
-
if (!modelRefreshStarted) {
|
|
8592
|
-
contextModels = Array.isArray(value?.contextModels) ? value.contextModels : [];
|
|
8593
|
-
availableModels = Array.isArray(value?.availableModels) ? value.availableModels : [];
|
|
8594
|
-
verbosityModels = Array.isArray(value?.verbosityModels) ? value.verbosityModels : [];
|
|
8595
|
-
fastModels = Array.isArray(value?.fastModels) ? value.fastModels : void 0;
|
|
8596
|
-
ultrafastModels = Array.isArray(value?.ultrafastModels) ? value.ultrafastModels : [];
|
|
8597
|
-
catalogStatus = value?.catalogStatus;
|
|
8598
|
-
}
|
|
8599
|
-
} else acceptFallback(value);
|
|
8619
|
+
acceptFallback(value);
|
|
8600
8620
|
publish();
|
|
8601
8621
|
} catch {
|
|
8602
|
-
if (current !== generation || disposed
|
|
8603
|
-
fallbackStatus = "unavailable";
|
|
8622
|
+
if (current !== generation || disposed) return;
|
|
8604
8623
|
publish();
|
|
8605
8624
|
}
|
|
8606
8625
|
};
|
|
@@ -8643,46 +8662,19 @@ window.__ModuleLoader__.load({
|
|
|
8643
8662
|
}
|
|
8644
8663
|
}
|
|
8645
8664
|
};
|
|
8646
|
-
const accepted = (entries, wait = 1500) => new Promise((resolve) => {
|
|
8647
|
-
const matches = () => entries.every(([field, value]) => JSON.stringify(nativeSnapshot().value?.[field]) === JSON.stringify(value));
|
|
8648
|
-
if (matches()) return resolve(true);
|
|
8649
|
-
let timer;
|
|
8650
|
-
const stop = scope.subscribe(() => {
|
|
8651
|
-
if (!matches()) return;
|
|
8652
|
-
clearTimeout(timer);
|
|
8653
|
-
stop();
|
|
8654
|
-
resolve(true);
|
|
8655
|
-
});
|
|
8656
|
-
timer = setTimeout(() => {
|
|
8657
|
-
stop();
|
|
8658
|
-
resolve(matches());
|
|
8659
|
-
}, wait);
|
|
8660
|
-
});
|
|
8661
8665
|
const set = async (patch) => {
|
|
8662
8666
|
if (disposed || snapshot.status !== "ready" || snapshot.writable !== true) return;
|
|
8663
8667
|
const current = ++generation;
|
|
8664
|
-
const entries = Object.entries(patch);
|
|
8665
8668
|
updating = true;
|
|
8666
8669
|
pendingPatch = patch;
|
|
8667
8670
|
error = false;
|
|
8668
8671
|
failedPatch = void 0;
|
|
8669
8672
|
publish();
|
|
8670
8673
|
try {
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
|
-
|
|
8675
|
-
}
|
|
8676
|
-
if (current !== generation) return;
|
|
8677
|
-
error = !await accepted(entries);
|
|
8678
|
-
if (error) failedPatch = patch;
|
|
8679
|
-
pendingPatch = void 0;
|
|
8680
|
-
} else {
|
|
8681
|
-
const value = unwrap(await rpc.call(CHANNEL, "preferences/update", patch));
|
|
8682
|
-
if (current !== generation) return;
|
|
8683
|
-
acceptFallback(value);
|
|
8684
|
-
pendingPatch = void 0;
|
|
8685
|
-
}
|
|
8674
|
+
const value = unwrap(await rpc.call(CHANNEL, "preferences/update", patch));
|
|
8675
|
+
if (current !== generation) return;
|
|
8676
|
+
acceptFallback(value);
|
|
8677
|
+
pendingPatch = void 0;
|
|
8686
8678
|
} catch {
|
|
8687
8679
|
if (current === generation) {
|
|
8688
8680
|
pendingPatch = void 0;
|
|
@@ -8710,7 +8702,6 @@ window.__ModuleLoader__.load({
|
|
|
8710
8702
|
disposed = true;
|
|
8711
8703
|
generation += 1;
|
|
8712
8704
|
modelRefreshGeneration += 1;
|
|
8713
|
-
disposeScope();
|
|
8714
8705
|
}
|
|
8715
8706
|
};
|
|
8716
8707
|
}
|
|
@@ -9091,7 +9082,7 @@ window.__ModuleLoader__.load({
|
|
|
9091
9082
|
}
|
|
9092
9083
|
//#endregion
|
|
9093
9084
|
//#region src/version.js
|
|
9094
|
-
const PACKAGE_VERSION = "
|
|
9085
|
+
const PACKAGE_VERSION = "3.0.0-beta.2";
|
|
9095
9086
|
//#endregion
|
|
9096
9087
|
//#region src/client-recovery.js
|
|
9097
9088
|
async function recoveryCall(rpc, endpoint, payload = {}, timeoutMs = 1e4) {
|
|
@@ -10219,6 +10210,2371 @@ window.__ModuleLoader__.load({
|
|
|
10219
10210
|
});
|
|
10220
10211
|
}
|
|
10221
10212
|
//#endregion
|
|
10213
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/utils.js
|
|
10214
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10215
|
+
let toSJISFunction;
|
|
10216
|
+
const CODEWORDS_COUNT = [
|
|
10217
|
+
0,
|
|
10218
|
+
26,
|
|
10219
|
+
44,
|
|
10220
|
+
70,
|
|
10221
|
+
100,
|
|
10222
|
+
134,
|
|
10223
|
+
172,
|
|
10224
|
+
196,
|
|
10225
|
+
242,
|
|
10226
|
+
292,
|
|
10227
|
+
346,
|
|
10228
|
+
404,
|
|
10229
|
+
466,
|
|
10230
|
+
532,
|
|
10231
|
+
581,
|
|
10232
|
+
655,
|
|
10233
|
+
733,
|
|
10234
|
+
815,
|
|
10235
|
+
901,
|
|
10236
|
+
991,
|
|
10237
|
+
1085,
|
|
10238
|
+
1156,
|
|
10239
|
+
1258,
|
|
10240
|
+
1364,
|
|
10241
|
+
1474,
|
|
10242
|
+
1588,
|
|
10243
|
+
1706,
|
|
10244
|
+
1828,
|
|
10245
|
+
1921,
|
|
10246
|
+
2051,
|
|
10247
|
+
2185,
|
|
10248
|
+
2323,
|
|
10249
|
+
2465,
|
|
10250
|
+
2611,
|
|
10251
|
+
2761,
|
|
10252
|
+
2876,
|
|
10253
|
+
3034,
|
|
10254
|
+
3196,
|
|
10255
|
+
3362,
|
|
10256
|
+
3532,
|
|
10257
|
+
3706
|
|
10258
|
+
];
|
|
10259
|
+
/**
|
|
10260
|
+
* Returns the QR Code size for the specified version
|
|
10261
|
+
*
|
|
10262
|
+
* @param {Number} version QR Code version
|
|
10263
|
+
* @return {Number} size of QR code
|
|
10264
|
+
*/
|
|
10265
|
+
exports.getSymbolSize = function getSymbolSize(version) {
|
|
10266
|
+
if (!version) throw new Error("\"version\" cannot be null or undefined");
|
|
10267
|
+
if (version < 1 || version > 40) throw new Error("\"version\" should be in range from 1 to 40");
|
|
10268
|
+
return version * 4 + 17;
|
|
10269
|
+
};
|
|
10270
|
+
/**
|
|
10271
|
+
* Returns the total number of codewords used to store data and EC information.
|
|
10272
|
+
*
|
|
10273
|
+
* @param {Number} version QR Code version
|
|
10274
|
+
* @return {Number} Data length in bits
|
|
10275
|
+
*/
|
|
10276
|
+
exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
|
|
10277
|
+
return CODEWORDS_COUNT[version];
|
|
10278
|
+
};
|
|
10279
|
+
/**
|
|
10280
|
+
* Encode data with Bose-Chaudhuri-Hocquenghem
|
|
10281
|
+
*
|
|
10282
|
+
* @param {Number} data Value to encode
|
|
10283
|
+
* @return {Number} Encoded value
|
|
10284
|
+
*/
|
|
10285
|
+
exports.getBCHDigit = function(data) {
|
|
10286
|
+
let digit = 0;
|
|
10287
|
+
while (data !== 0) {
|
|
10288
|
+
digit++;
|
|
10289
|
+
data >>>= 1;
|
|
10290
|
+
}
|
|
10291
|
+
return digit;
|
|
10292
|
+
};
|
|
10293
|
+
exports.setToSJISFunction = function setToSJISFunction(f) {
|
|
10294
|
+
if (typeof f !== "function") throw new Error("\"toSJISFunc\" is not a valid function.");
|
|
10295
|
+
toSJISFunction = f;
|
|
10296
|
+
};
|
|
10297
|
+
exports.isKanjiModeEnabled = function() {
|
|
10298
|
+
return typeof toSJISFunction !== "undefined";
|
|
10299
|
+
};
|
|
10300
|
+
exports.toSJIS = function toSJIS(kanji) {
|
|
10301
|
+
return toSJISFunction(kanji);
|
|
10302
|
+
};
|
|
10303
|
+
}));
|
|
10304
|
+
//#endregion
|
|
10305
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-level.js
|
|
10306
|
+
var require_error_correction_level = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10307
|
+
exports.L = { bit: 1 };
|
|
10308
|
+
exports.M = { bit: 0 };
|
|
10309
|
+
exports.Q = { bit: 3 };
|
|
10310
|
+
exports.H = { bit: 2 };
|
|
10311
|
+
function fromString(string) {
|
|
10312
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
10313
|
+
switch (string.toLowerCase()) {
|
|
10314
|
+
case "l":
|
|
10315
|
+
case "low": return exports.L;
|
|
10316
|
+
case "m":
|
|
10317
|
+
case "medium": return exports.M;
|
|
10318
|
+
case "q":
|
|
10319
|
+
case "quartile": return exports.Q;
|
|
10320
|
+
case "h":
|
|
10321
|
+
case "high": return exports.H;
|
|
10322
|
+
default: throw new Error("Unknown EC Level: " + string);
|
|
10323
|
+
}
|
|
10324
|
+
}
|
|
10325
|
+
exports.isValid = function isValid(level) {
|
|
10326
|
+
return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
|
|
10327
|
+
};
|
|
10328
|
+
exports.from = function from(value, defaultValue) {
|
|
10329
|
+
if (exports.isValid(value)) return value;
|
|
10330
|
+
try {
|
|
10331
|
+
return fromString(value);
|
|
10332
|
+
} catch (e) {
|
|
10333
|
+
return defaultValue;
|
|
10334
|
+
}
|
|
10335
|
+
};
|
|
10336
|
+
}));
|
|
10337
|
+
//#endregion
|
|
10338
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-buffer.js
|
|
10339
|
+
var require_bit_buffer = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10340
|
+
function BitBuffer() {
|
|
10341
|
+
this.buffer = [];
|
|
10342
|
+
this.length = 0;
|
|
10343
|
+
}
|
|
10344
|
+
BitBuffer.prototype = {
|
|
10345
|
+
get: function(index) {
|
|
10346
|
+
const bufIndex = Math.floor(index / 8);
|
|
10347
|
+
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
|
|
10348
|
+
},
|
|
10349
|
+
put: function(num, length) {
|
|
10350
|
+
for (let i = 0; i < length; i++) this.putBit((num >>> length - i - 1 & 1) === 1);
|
|
10351
|
+
},
|
|
10352
|
+
getLengthInBits: function() {
|
|
10353
|
+
return this.length;
|
|
10354
|
+
},
|
|
10355
|
+
putBit: function(bit) {
|
|
10356
|
+
const bufIndex = Math.floor(this.length / 8);
|
|
10357
|
+
if (this.buffer.length <= bufIndex) this.buffer.push(0);
|
|
10358
|
+
if (bit) this.buffer[bufIndex] |= 128 >>> this.length % 8;
|
|
10359
|
+
this.length++;
|
|
10360
|
+
}
|
|
10361
|
+
};
|
|
10362
|
+
module.exports = BitBuffer;
|
|
10363
|
+
}));
|
|
10364
|
+
//#endregion
|
|
10365
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/bit-matrix.js
|
|
10366
|
+
var require_bit_matrix = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
10367
|
+
/**
|
|
10368
|
+
* Helper class to handle QR Code symbol modules
|
|
10369
|
+
*
|
|
10370
|
+
* @param {Number} size Symbol size
|
|
10371
|
+
*/
|
|
10372
|
+
function BitMatrix(size) {
|
|
10373
|
+
if (!size || size < 1) throw new Error("BitMatrix size must be defined and greater than 0");
|
|
10374
|
+
this.size = size;
|
|
10375
|
+
this.data = new Uint8Array(size * size);
|
|
10376
|
+
this.reservedBit = new Uint8Array(size * size);
|
|
10377
|
+
}
|
|
10378
|
+
/**
|
|
10379
|
+
* Set bit value at specified location
|
|
10380
|
+
* If reserved flag is set, this bit will be ignored during masking process
|
|
10381
|
+
*
|
|
10382
|
+
* @param {Number} row
|
|
10383
|
+
* @param {Number} col
|
|
10384
|
+
* @param {Boolean} value
|
|
10385
|
+
* @param {Boolean} reserved
|
|
10386
|
+
*/
|
|
10387
|
+
BitMatrix.prototype.set = function(row, col, value, reserved) {
|
|
10388
|
+
const index = row * this.size + col;
|
|
10389
|
+
this.data[index] = value;
|
|
10390
|
+
if (reserved) this.reservedBit[index] = true;
|
|
10391
|
+
};
|
|
10392
|
+
/**
|
|
10393
|
+
* Returns bit value at specified location
|
|
10394
|
+
*
|
|
10395
|
+
* @param {Number} row
|
|
10396
|
+
* @param {Number} col
|
|
10397
|
+
* @return {Boolean}
|
|
10398
|
+
*/
|
|
10399
|
+
BitMatrix.prototype.get = function(row, col) {
|
|
10400
|
+
return this.data[row * this.size + col];
|
|
10401
|
+
};
|
|
10402
|
+
/**
|
|
10403
|
+
* Applies xor operator at specified location
|
|
10404
|
+
* (used during masking process)
|
|
10405
|
+
*
|
|
10406
|
+
* @param {Number} row
|
|
10407
|
+
* @param {Number} col
|
|
10408
|
+
* @param {Boolean} value
|
|
10409
|
+
*/
|
|
10410
|
+
BitMatrix.prototype.xor = function(row, col, value) {
|
|
10411
|
+
this.data[row * this.size + col] ^= value;
|
|
10412
|
+
};
|
|
10413
|
+
/**
|
|
10414
|
+
* Check if bit at specified location is reserved
|
|
10415
|
+
*
|
|
10416
|
+
* @param {Number} row
|
|
10417
|
+
* @param {Number} col
|
|
10418
|
+
* @return {Boolean}
|
|
10419
|
+
*/
|
|
10420
|
+
BitMatrix.prototype.isReserved = function(row, col) {
|
|
10421
|
+
return this.reservedBit[row * this.size + col];
|
|
10422
|
+
};
|
|
10423
|
+
module.exports = BitMatrix;
|
|
10424
|
+
}));
|
|
10425
|
+
//#endregion
|
|
10426
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alignment-pattern.js
|
|
10427
|
+
var require_alignment_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10428
|
+
/**
|
|
10429
|
+
* Alignment pattern are fixed reference pattern in defined positions
|
|
10430
|
+
* in a matrix symbology, which enables the decode software to re-synchronise
|
|
10431
|
+
* the coordinate mapping of the image modules in the event of moderate amounts
|
|
10432
|
+
* of distortion of the image.
|
|
10433
|
+
*
|
|
10434
|
+
* Alignment patterns are present only in QR Code symbols of version 2 or larger
|
|
10435
|
+
* and their number depends on the symbol version.
|
|
10436
|
+
*/
|
|
10437
|
+
const getSymbolSize = require_utils().getSymbolSize;
|
|
10438
|
+
/**
|
|
10439
|
+
* Calculate the row/column coordinates of the center module of each alignment pattern
|
|
10440
|
+
* for the specified QR Code version.
|
|
10441
|
+
*
|
|
10442
|
+
* The alignment patterns are positioned symmetrically on either side of the diagonal
|
|
10443
|
+
* running from the top left corner of the symbol to the bottom right corner.
|
|
10444
|
+
*
|
|
10445
|
+
* Since positions are simmetrical only half of the coordinates are returned.
|
|
10446
|
+
* Each item of the array will represent in turn the x and y coordinate.
|
|
10447
|
+
* @see {@link getPositions}
|
|
10448
|
+
*
|
|
10449
|
+
* @param {Number} version QR Code version
|
|
10450
|
+
* @return {Array} Array of coordinate
|
|
10451
|
+
*/
|
|
10452
|
+
exports.getRowColCoords = function getRowColCoords(version) {
|
|
10453
|
+
if (version === 1) return [];
|
|
10454
|
+
const posCount = Math.floor(version / 7) + 2;
|
|
10455
|
+
const size = getSymbolSize(version);
|
|
10456
|
+
const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
|
|
10457
|
+
const positions = [size - 7];
|
|
10458
|
+
for (let i = 1; i < posCount - 1; i++) positions[i] = positions[i - 1] - intervals;
|
|
10459
|
+
positions.push(6);
|
|
10460
|
+
return positions.reverse();
|
|
10461
|
+
};
|
|
10462
|
+
/**
|
|
10463
|
+
* Returns an array containing the positions of each alignment pattern.
|
|
10464
|
+
* Each array's element represent the center point of the pattern as (x, y) coordinates
|
|
10465
|
+
*
|
|
10466
|
+
* Coordinates are calculated expanding the row/column coordinates returned by {@link getRowColCoords}
|
|
10467
|
+
* and filtering out the items that overlaps with finder pattern
|
|
10468
|
+
*
|
|
10469
|
+
* @example
|
|
10470
|
+
* For a Version 7 symbol {@link getRowColCoords} returns values 6, 22 and 38.
|
|
10471
|
+
* The alignment patterns, therefore, are to be centered on (row, column)
|
|
10472
|
+
* positions (6,22), (22,6), (22,22), (22,38), (38,22), (38,38).
|
|
10473
|
+
* Note that the coordinates (6,6), (6,38), (38,6) are occupied by finder patterns
|
|
10474
|
+
* and are not therefore used for alignment patterns.
|
|
10475
|
+
*
|
|
10476
|
+
* let pos = getPositions(7)
|
|
10477
|
+
* // [[6,22], [22,6], [22,22], [22,38], [38,22], [38,38]]
|
|
10478
|
+
*
|
|
10479
|
+
* @param {Number} version QR Code version
|
|
10480
|
+
* @return {Array} Array of coordinates
|
|
10481
|
+
*/
|
|
10482
|
+
exports.getPositions = function getPositions(version) {
|
|
10483
|
+
const coords = [];
|
|
10484
|
+
const pos = exports.getRowColCoords(version);
|
|
10485
|
+
const posLength = pos.length;
|
|
10486
|
+
for (let i = 0; i < posLength; i++) for (let j = 0; j < posLength; j++) {
|
|
10487
|
+
if (i === 0 && j === 0 || i === 0 && j === posLength - 1 || i === posLength - 1 && j === 0) continue;
|
|
10488
|
+
coords.push([pos[i], pos[j]]);
|
|
10489
|
+
}
|
|
10490
|
+
return coords;
|
|
10491
|
+
};
|
|
10492
|
+
}));
|
|
10493
|
+
//#endregion
|
|
10494
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/finder-pattern.js
|
|
10495
|
+
var require_finder_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10496
|
+
const getSymbolSize = require_utils().getSymbolSize;
|
|
10497
|
+
const FINDER_PATTERN_SIZE = 7;
|
|
10498
|
+
/**
|
|
10499
|
+
* Returns an array containing the positions of each finder pattern.
|
|
10500
|
+
* Each array's element represent the top-left point of the pattern as (x, y) coordinates
|
|
10501
|
+
*
|
|
10502
|
+
* @param {Number} version QR Code version
|
|
10503
|
+
* @return {Array} Array of coordinates
|
|
10504
|
+
*/
|
|
10505
|
+
exports.getPositions = function getPositions(version) {
|
|
10506
|
+
const size = getSymbolSize(version);
|
|
10507
|
+
return [
|
|
10508
|
+
[0, 0],
|
|
10509
|
+
[size - FINDER_PATTERN_SIZE, 0],
|
|
10510
|
+
[0, size - FINDER_PATTERN_SIZE]
|
|
10511
|
+
];
|
|
10512
|
+
};
|
|
10513
|
+
}));
|
|
10514
|
+
//#endregion
|
|
10515
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mask-pattern.js
|
|
10516
|
+
var require_mask_pattern = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10517
|
+
/**
|
|
10518
|
+
* Data mask pattern reference
|
|
10519
|
+
* @type {Object}
|
|
10520
|
+
*/
|
|
10521
|
+
exports.Patterns = {
|
|
10522
|
+
PATTERN000: 0,
|
|
10523
|
+
PATTERN001: 1,
|
|
10524
|
+
PATTERN010: 2,
|
|
10525
|
+
PATTERN011: 3,
|
|
10526
|
+
PATTERN100: 4,
|
|
10527
|
+
PATTERN101: 5,
|
|
10528
|
+
PATTERN110: 6,
|
|
10529
|
+
PATTERN111: 7
|
|
10530
|
+
};
|
|
10531
|
+
/**
|
|
10532
|
+
* Weighted penalty scores for the undesirable features
|
|
10533
|
+
* @type {Object}
|
|
10534
|
+
*/
|
|
10535
|
+
const PenaltyScores = {
|
|
10536
|
+
N1: 3,
|
|
10537
|
+
N2: 3,
|
|
10538
|
+
N3: 40,
|
|
10539
|
+
N4: 10
|
|
10540
|
+
};
|
|
10541
|
+
/**
|
|
10542
|
+
* Check if mask pattern value is valid
|
|
10543
|
+
*
|
|
10544
|
+
* @param {Number} mask Mask pattern
|
|
10545
|
+
* @return {Boolean} true if valid, false otherwise
|
|
10546
|
+
*/
|
|
10547
|
+
exports.isValid = function isValid(mask) {
|
|
10548
|
+
return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
|
|
10549
|
+
};
|
|
10550
|
+
/**
|
|
10551
|
+
* Returns mask pattern from a value.
|
|
10552
|
+
* If value is not valid, returns undefined
|
|
10553
|
+
*
|
|
10554
|
+
* @param {Number|String} value Mask pattern value
|
|
10555
|
+
* @return {Number} Valid mask pattern or undefined
|
|
10556
|
+
*/
|
|
10557
|
+
exports.from = function from(value) {
|
|
10558
|
+
return exports.isValid(value) ? parseInt(value, 10) : void 0;
|
|
10559
|
+
};
|
|
10560
|
+
/**
|
|
10561
|
+
* Find adjacent modules in row/column with the same color
|
|
10562
|
+
* and assign a penalty value.
|
|
10563
|
+
*
|
|
10564
|
+
* Points: N1 + i
|
|
10565
|
+
* i is the amount by which the number of adjacent modules of the same color exceeds 5
|
|
10566
|
+
*/
|
|
10567
|
+
exports.getPenaltyN1 = function getPenaltyN1(data) {
|
|
10568
|
+
const size = data.size;
|
|
10569
|
+
let points = 0;
|
|
10570
|
+
let sameCountCol = 0;
|
|
10571
|
+
let sameCountRow = 0;
|
|
10572
|
+
let lastCol = null;
|
|
10573
|
+
let lastRow = null;
|
|
10574
|
+
for (let row = 0; row < size; row++) {
|
|
10575
|
+
sameCountCol = sameCountRow = 0;
|
|
10576
|
+
lastCol = lastRow = null;
|
|
10577
|
+
for (let col = 0; col < size; col++) {
|
|
10578
|
+
let module$1 = data.get(row, col);
|
|
10579
|
+
if (module$1 === lastCol) sameCountCol++;
|
|
10580
|
+
else {
|
|
10581
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
10582
|
+
lastCol = module$1;
|
|
10583
|
+
sameCountCol = 1;
|
|
10584
|
+
}
|
|
10585
|
+
module$1 = data.get(col, row);
|
|
10586
|
+
if (module$1 === lastRow) sameCountRow++;
|
|
10587
|
+
else {
|
|
10588
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
10589
|
+
lastRow = module$1;
|
|
10590
|
+
sameCountRow = 1;
|
|
10591
|
+
}
|
|
10592
|
+
}
|
|
10593
|
+
if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
|
|
10594
|
+
if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
|
|
10595
|
+
}
|
|
10596
|
+
return points;
|
|
10597
|
+
};
|
|
10598
|
+
/**
|
|
10599
|
+
* Find 2x2 blocks with the same color and assign a penalty value
|
|
10600
|
+
*
|
|
10601
|
+
* Points: N2 * (m - 1) * (n - 1)
|
|
10602
|
+
*/
|
|
10603
|
+
exports.getPenaltyN2 = function getPenaltyN2(data) {
|
|
10604
|
+
const size = data.size;
|
|
10605
|
+
let points = 0;
|
|
10606
|
+
for (let row = 0; row < size - 1; row++) for (let col = 0; col < size - 1; col++) {
|
|
10607
|
+
const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
|
|
10608
|
+
if (last === 4 || last === 0) points++;
|
|
10609
|
+
}
|
|
10610
|
+
return points * PenaltyScores.N2;
|
|
10611
|
+
};
|
|
10612
|
+
/**
|
|
10613
|
+
* Find 1:1:3:1:1 ratio (dark:light:dark:light:dark) pattern in row/column,
|
|
10614
|
+
* preceded or followed by light area 4 modules wide
|
|
10615
|
+
*
|
|
10616
|
+
* Points: N3 * number of pattern found
|
|
10617
|
+
*/
|
|
10618
|
+
exports.getPenaltyN3 = function getPenaltyN3(data) {
|
|
10619
|
+
const size = data.size;
|
|
10620
|
+
let points = 0;
|
|
10621
|
+
let bitsCol = 0;
|
|
10622
|
+
let bitsRow = 0;
|
|
10623
|
+
for (let row = 0; row < size; row++) {
|
|
10624
|
+
bitsCol = bitsRow = 0;
|
|
10625
|
+
for (let col = 0; col < size; col++) {
|
|
10626
|
+
bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
|
|
10627
|
+
if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
|
|
10628
|
+
bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
|
|
10629
|
+
if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
|
|
10630
|
+
}
|
|
10631
|
+
}
|
|
10632
|
+
return points * PenaltyScores.N3;
|
|
10633
|
+
};
|
|
10634
|
+
/**
|
|
10635
|
+
* Calculate proportion of dark modules in entire symbol
|
|
10636
|
+
*
|
|
10637
|
+
* Points: N4 * k
|
|
10638
|
+
*
|
|
10639
|
+
* k is the rating of the deviation of the proportion of dark modules
|
|
10640
|
+
* in the symbol from 50% in steps of 5%
|
|
10641
|
+
*/
|
|
10642
|
+
exports.getPenaltyN4 = function getPenaltyN4(data) {
|
|
10643
|
+
let darkCount = 0;
|
|
10644
|
+
const modulesCount = data.data.length;
|
|
10645
|
+
for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
|
|
10646
|
+
return Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10) * PenaltyScores.N4;
|
|
10647
|
+
};
|
|
10648
|
+
/**
|
|
10649
|
+
* Return mask value at given position
|
|
10650
|
+
*
|
|
10651
|
+
* @param {Number} maskPattern Pattern reference value
|
|
10652
|
+
* @param {Number} i Row
|
|
10653
|
+
* @param {Number} j Column
|
|
10654
|
+
* @return {Boolean} Mask value
|
|
10655
|
+
*/
|
|
10656
|
+
function getMaskAt(maskPattern, i, j) {
|
|
10657
|
+
switch (maskPattern) {
|
|
10658
|
+
case exports.Patterns.PATTERN000: return (i + j) % 2 === 0;
|
|
10659
|
+
case exports.Patterns.PATTERN001: return i % 2 === 0;
|
|
10660
|
+
case exports.Patterns.PATTERN010: return j % 3 === 0;
|
|
10661
|
+
case exports.Patterns.PATTERN011: return (i + j) % 3 === 0;
|
|
10662
|
+
case exports.Patterns.PATTERN100: return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
|
|
10663
|
+
case exports.Patterns.PATTERN101: return i * j % 2 + i * j % 3 === 0;
|
|
10664
|
+
case exports.Patterns.PATTERN110: return (i * j % 2 + i * j % 3) % 2 === 0;
|
|
10665
|
+
case exports.Patterns.PATTERN111: return (i * j % 3 + (i + j) % 2) % 2 === 0;
|
|
10666
|
+
default: throw new Error("bad maskPattern:" + maskPattern);
|
|
10667
|
+
}
|
|
10668
|
+
}
|
|
10669
|
+
/**
|
|
10670
|
+
* Apply a mask pattern to a BitMatrix
|
|
10671
|
+
*
|
|
10672
|
+
* @param {Number} pattern Pattern reference number
|
|
10673
|
+
* @param {BitMatrix} data BitMatrix data
|
|
10674
|
+
*/
|
|
10675
|
+
exports.applyMask = function applyMask(pattern, data) {
|
|
10676
|
+
const size = data.size;
|
|
10677
|
+
for (let col = 0; col < size; col++) for (let row = 0; row < size; row++) {
|
|
10678
|
+
if (data.isReserved(row, col)) continue;
|
|
10679
|
+
data.xor(row, col, getMaskAt(pattern, row, col));
|
|
10680
|
+
}
|
|
10681
|
+
};
|
|
10682
|
+
/**
|
|
10683
|
+
* Returns the best mask pattern for data
|
|
10684
|
+
*
|
|
10685
|
+
* @param {BitMatrix} data
|
|
10686
|
+
* @return {Number} Mask pattern reference number
|
|
10687
|
+
*/
|
|
10688
|
+
exports.getBestMask = function getBestMask(data, setupFormatFunc) {
|
|
10689
|
+
const numPatterns = Object.keys(exports.Patterns).length;
|
|
10690
|
+
let bestPattern = 0;
|
|
10691
|
+
let lowerPenalty = Infinity;
|
|
10692
|
+
for (let p = 0; p < numPatterns; p++) {
|
|
10693
|
+
setupFormatFunc(p);
|
|
10694
|
+
exports.applyMask(p, data);
|
|
10695
|
+
const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
|
|
10696
|
+
exports.applyMask(p, data);
|
|
10697
|
+
if (penalty < lowerPenalty) {
|
|
10698
|
+
lowerPenalty = penalty;
|
|
10699
|
+
bestPattern = p;
|
|
10700
|
+
}
|
|
10701
|
+
}
|
|
10702
|
+
return bestPattern;
|
|
10703
|
+
};
|
|
10704
|
+
}));
|
|
10705
|
+
//#endregion
|
|
10706
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/error-correction-code.js
|
|
10707
|
+
var require_error_correction_code = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
10708
|
+
const ECLevel = require_error_correction_level();
|
|
10709
|
+
const EC_BLOCKS_TABLE = [
|
|
10710
|
+
1,
|
|
10711
|
+
1,
|
|
10712
|
+
1,
|
|
10713
|
+
1,
|
|
10714
|
+
1,
|
|
10715
|
+
1,
|
|
10716
|
+
1,
|
|
10717
|
+
1,
|
|
10718
|
+
1,
|
|
10719
|
+
1,
|
|
10720
|
+
2,
|
|
10721
|
+
2,
|
|
10722
|
+
1,
|
|
10723
|
+
2,
|
|
10724
|
+
2,
|
|
10725
|
+
4,
|
|
10726
|
+
1,
|
|
10727
|
+
2,
|
|
10728
|
+
4,
|
|
10729
|
+
4,
|
|
10730
|
+
2,
|
|
10731
|
+
4,
|
|
10732
|
+
4,
|
|
10733
|
+
4,
|
|
10734
|
+
2,
|
|
10735
|
+
4,
|
|
10736
|
+
6,
|
|
10737
|
+
5,
|
|
10738
|
+
2,
|
|
10739
|
+
4,
|
|
10740
|
+
6,
|
|
10741
|
+
6,
|
|
10742
|
+
2,
|
|
10743
|
+
5,
|
|
10744
|
+
8,
|
|
10745
|
+
8,
|
|
10746
|
+
4,
|
|
10747
|
+
5,
|
|
10748
|
+
8,
|
|
10749
|
+
8,
|
|
10750
|
+
4,
|
|
10751
|
+
5,
|
|
10752
|
+
8,
|
|
10753
|
+
11,
|
|
10754
|
+
4,
|
|
10755
|
+
8,
|
|
10756
|
+
10,
|
|
10757
|
+
11,
|
|
10758
|
+
4,
|
|
10759
|
+
9,
|
|
10760
|
+
12,
|
|
10761
|
+
16,
|
|
10762
|
+
4,
|
|
10763
|
+
9,
|
|
10764
|
+
16,
|
|
10765
|
+
16,
|
|
10766
|
+
6,
|
|
10767
|
+
10,
|
|
10768
|
+
12,
|
|
10769
|
+
18,
|
|
10770
|
+
6,
|
|
10771
|
+
10,
|
|
10772
|
+
17,
|
|
10773
|
+
16,
|
|
10774
|
+
6,
|
|
10775
|
+
11,
|
|
10776
|
+
16,
|
|
10777
|
+
19,
|
|
10778
|
+
6,
|
|
10779
|
+
13,
|
|
10780
|
+
18,
|
|
10781
|
+
21,
|
|
10782
|
+
7,
|
|
10783
|
+
14,
|
|
10784
|
+
21,
|
|
10785
|
+
25,
|
|
10786
|
+
8,
|
|
10787
|
+
16,
|
|
10788
|
+
20,
|
|
10789
|
+
25,
|
|
10790
|
+
8,
|
|
10791
|
+
17,
|
|
10792
|
+
23,
|
|
10793
|
+
25,
|
|
10794
|
+
9,
|
|
10795
|
+
17,
|
|
10796
|
+
23,
|
|
10797
|
+
34,
|
|
10798
|
+
9,
|
|
10799
|
+
18,
|
|
10800
|
+
25,
|
|
10801
|
+
30,
|
|
10802
|
+
10,
|
|
10803
|
+
20,
|
|
10804
|
+
27,
|
|
10805
|
+
32,
|
|
10806
|
+
12,
|
|
10807
|
+
21,
|
|
10808
|
+
29,
|
|
10809
|
+
35,
|
|
10810
|
+
12,
|
|
10811
|
+
23,
|
|
10812
|
+
34,
|
|
10813
|
+
37,
|
|
10814
|
+
12,
|
|
10815
|
+
25,
|
|
10816
|
+
34,
|
|
10817
|
+
40,
|
|
10818
|
+
13,
|
|
10819
|
+
26,
|
|
10820
|
+
35,
|
|
10821
|
+
42,
|
|
10822
|
+
14,
|
|
10823
|
+
28,
|
|
10824
|
+
38,
|
|
10825
|
+
45,
|
|
10826
|
+
15,
|
|
10827
|
+
29,
|
|
10828
|
+
40,
|
|
10829
|
+
48,
|
|
10830
|
+
16,
|
|
10831
|
+
31,
|
|
10832
|
+
43,
|
|
10833
|
+
51,
|
|
10834
|
+
17,
|
|
10835
|
+
33,
|
|
10836
|
+
45,
|
|
10837
|
+
54,
|
|
10838
|
+
18,
|
|
10839
|
+
35,
|
|
10840
|
+
48,
|
|
10841
|
+
57,
|
|
10842
|
+
19,
|
|
10843
|
+
37,
|
|
10844
|
+
51,
|
|
10845
|
+
60,
|
|
10846
|
+
19,
|
|
10847
|
+
38,
|
|
10848
|
+
53,
|
|
10849
|
+
63,
|
|
10850
|
+
20,
|
|
10851
|
+
40,
|
|
10852
|
+
56,
|
|
10853
|
+
66,
|
|
10854
|
+
21,
|
|
10855
|
+
43,
|
|
10856
|
+
59,
|
|
10857
|
+
70,
|
|
10858
|
+
22,
|
|
10859
|
+
45,
|
|
10860
|
+
62,
|
|
10861
|
+
74,
|
|
10862
|
+
24,
|
|
10863
|
+
47,
|
|
10864
|
+
65,
|
|
10865
|
+
77,
|
|
10866
|
+
25,
|
|
10867
|
+
49,
|
|
10868
|
+
68,
|
|
10869
|
+
81
|
|
10870
|
+
];
|
|
10871
|
+
const EC_CODEWORDS_TABLE = [
|
|
10872
|
+
7,
|
|
10873
|
+
10,
|
|
10874
|
+
13,
|
|
10875
|
+
17,
|
|
10876
|
+
10,
|
|
10877
|
+
16,
|
|
10878
|
+
22,
|
|
10879
|
+
28,
|
|
10880
|
+
15,
|
|
10881
|
+
26,
|
|
10882
|
+
36,
|
|
10883
|
+
44,
|
|
10884
|
+
20,
|
|
10885
|
+
36,
|
|
10886
|
+
52,
|
|
10887
|
+
64,
|
|
10888
|
+
26,
|
|
10889
|
+
48,
|
|
10890
|
+
72,
|
|
10891
|
+
88,
|
|
10892
|
+
36,
|
|
10893
|
+
64,
|
|
10894
|
+
96,
|
|
10895
|
+
112,
|
|
10896
|
+
40,
|
|
10897
|
+
72,
|
|
10898
|
+
108,
|
|
10899
|
+
130,
|
|
10900
|
+
48,
|
|
10901
|
+
88,
|
|
10902
|
+
132,
|
|
10903
|
+
156,
|
|
10904
|
+
60,
|
|
10905
|
+
110,
|
|
10906
|
+
160,
|
|
10907
|
+
192,
|
|
10908
|
+
72,
|
|
10909
|
+
130,
|
|
10910
|
+
192,
|
|
10911
|
+
224,
|
|
10912
|
+
80,
|
|
10913
|
+
150,
|
|
10914
|
+
224,
|
|
10915
|
+
264,
|
|
10916
|
+
96,
|
|
10917
|
+
176,
|
|
10918
|
+
260,
|
|
10919
|
+
308,
|
|
10920
|
+
104,
|
|
10921
|
+
198,
|
|
10922
|
+
288,
|
|
10923
|
+
352,
|
|
10924
|
+
120,
|
|
10925
|
+
216,
|
|
10926
|
+
320,
|
|
10927
|
+
384,
|
|
10928
|
+
132,
|
|
10929
|
+
240,
|
|
10930
|
+
360,
|
|
10931
|
+
432,
|
|
10932
|
+
144,
|
|
10933
|
+
280,
|
|
10934
|
+
408,
|
|
10935
|
+
480,
|
|
10936
|
+
168,
|
|
10937
|
+
308,
|
|
10938
|
+
448,
|
|
10939
|
+
532,
|
|
10940
|
+
180,
|
|
10941
|
+
338,
|
|
10942
|
+
504,
|
|
10943
|
+
588,
|
|
10944
|
+
196,
|
|
10945
|
+
364,
|
|
10946
|
+
546,
|
|
10947
|
+
650,
|
|
10948
|
+
224,
|
|
10949
|
+
416,
|
|
10950
|
+
600,
|
|
10951
|
+
700,
|
|
10952
|
+
224,
|
|
10953
|
+
442,
|
|
10954
|
+
644,
|
|
10955
|
+
750,
|
|
10956
|
+
252,
|
|
10957
|
+
476,
|
|
10958
|
+
690,
|
|
10959
|
+
816,
|
|
10960
|
+
270,
|
|
10961
|
+
504,
|
|
10962
|
+
750,
|
|
10963
|
+
900,
|
|
10964
|
+
300,
|
|
10965
|
+
560,
|
|
10966
|
+
810,
|
|
10967
|
+
960,
|
|
10968
|
+
312,
|
|
10969
|
+
588,
|
|
10970
|
+
870,
|
|
10971
|
+
1050,
|
|
10972
|
+
336,
|
|
10973
|
+
644,
|
|
10974
|
+
952,
|
|
10975
|
+
1110,
|
|
10976
|
+
360,
|
|
10977
|
+
700,
|
|
10978
|
+
1020,
|
|
10979
|
+
1200,
|
|
10980
|
+
390,
|
|
10981
|
+
728,
|
|
10982
|
+
1050,
|
|
10983
|
+
1260,
|
|
10984
|
+
420,
|
|
10985
|
+
784,
|
|
10986
|
+
1140,
|
|
10987
|
+
1350,
|
|
10988
|
+
450,
|
|
10989
|
+
812,
|
|
10990
|
+
1200,
|
|
10991
|
+
1440,
|
|
10992
|
+
480,
|
|
10993
|
+
868,
|
|
10994
|
+
1290,
|
|
10995
|
+
1530,
|
|
10996
|
+
510,
|
|
10997
|
+
924,
|
|
10998
|
+
1350,
|
|
10999
|
+
1620,
|
|
11000
|
+
540,
|
|
11001
|
+
980,
|
|
11002
|
+
1440,
|
|
11003
|
+
1710,
|
|
11004
|
+
570,
|
|
11005
|
+
1036,
|
|
11006
|
+
1530,
|
|
11007
|
+
1800,
|
|
11008
|
+
570,
|
|
11009
|
+
1064,
|
|
11010
|
+
1590,
|
|
11011
|
+
1890,
|
|
11012
|
+
600,
|
|
11013
|
+
1120,
|
|
11014
|
+
1680,
|
|
11015
|
+
1980,
|
|
11016
|
+
630,
|
|
11017
|
+
1204,
|
|
11018
|
+
1770,
|
|
11019
|
+
2100,
|
|
11020
|
+
660,
|
|
11021
|
+
1260,
|
|
11022
|
+
1860,
|
|
11023
|
+
2220,
|
|
11024
|
+
720,
|
|
11025
|
+
1316,
|
|
11026
|
+
1950,
|
|
11027
|
+
2310,
|
|
11028
|
+
750,
|
|
11029
|
+
1372,
|
|
11030
|
+
2040,
|
|
11031
|
+
2430
|
|
11032
|
+
];
|
|
11033
|
+
/**
|
|
11034
|
+
* Returns the number of error correction block that the QR Code should contain
|
|
11035
|
+
* for the specified version and error correction level.
|
|
11036
|
+
*
|
|
11037
|
+
* @param {Number} version QR Code version
|
|
11038
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11039
|
+
* @return {Number} Number of error correction blocks
|
|
11040
|
+
*/
|
|
11041
|
+
exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
|
|
11042
|
+
switch (errorCorrectionLevel) {
|
|
11043
|
+
case ECLevel.L: return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
|
|
11044
|
+
case ECLevel.M: return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
|
|
11045
|
+
case ECLevel.Q: return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
|
|
11046
|
+
case ECLevel.H: return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
|
|
11047
|
+
default: return;
|
|
11048
|
+
}
|
|
11049
|
+
};
|
|
11050
|
+
/**
|
|
11051
|
+
* Returns the number of error correction codewords to use for the specified
|
|
11052
|
+
* version and error correction level.
|
|
11053
|
+
*
|
|
11054
|
+
* @param {Number} version QR Code version
|
|
11055
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11056
|
+
* @return {Number} Number of error correction codewords
|
|
11057
|
+
*/
|
|
11058
|
+
exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
|
|
11059
|
+
switch (errorCorrectionLevel) {
|
|
11060
|
+
case ECLevel.L: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
|
|
11061
|
+
case ECLevel.M: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
|
|
11062
|
+
case ECLevel.Q: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
|
|
11063
|
+
case ECLevel.H: return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
|
|
11064
|
+
default: return;
|
|
11065
|
+
}
|
|
11066
|
+
};
|
|
11067
|
+
}));
|
|
11068
|
+
//#endregion
|
|
11069
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/galois-field.js
|
|
11070
|
+
var require_galois_field = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11071
|
+
const EXP_TABLE = /* @__PURE__ */ new Uint8Array(512);
|
|
11072
|
+
const LOG_TABLE = /* @__PURE__ */ new Uint8Array(256);
|
|
11073
|
+
(function initTables() {
|
|
11074
|
+
let x = 1;
|
|
11075
|
+
for (let i = 0; i < 255; i++) {
|
|
11076
|
+
EXP_TABLE[i] = x;
|
|
11077
|
+
LOG_TABLE[x] = i;
|
|
11078
|
+
x <<= 1;
|
|
11079
|
+
if (x & 256) x ^= 285;
|
|
11080
|
+
}
|
|
11081
|
+
for (let i = 255; i < 512; i++) EXP_TABLE[i] = EXP_TABLE[i - 255];
|
|
11082
|
+
})();
|
|
11083
|
+
/**
|
|
11084
|
+
* Returns log value of n inside Galois Field
|
|
11085
|
+
*
|
|
11086
|
+
* @param {Number} n
|
|
11087
|
+
* @return {Number}
|
|
11088
|
+
*/
|
|
11089
|
+
exports.log = function log(n) {
|
|
11090
|
+
if (n < 1) throw new Error("log(" + n + ")");
|
|
11091
|
+
return LOG_TABLE[n];
|
|
11092
|
+
};
|
|
11093
|
+
/**
|
|
11094
|
+
* Returns anti-log value of n inside Galois Field
|
|
11095
|
+
*
|
|
11096
|
+
* @param {Number} n
|
|
11097
|
+
* @return {Number}
|
|
11098
|
+
*/
|
|
11099
|
+
exports.exp = function exp(n) {
|
|
11100
|
+
return EXP_TABLE[n];
|
|
11101
|
+
};
|
|
11102
|
+
/**
|
|
11103
|
+
* Multiplies two number inside Galois Field
|
|
11104
|
+
*
|
|
11105
|
+
* @param {Number} x
|
|
11106
|
+
* @param {Number} y
|
|
11107
|
+
* @return {Number}
|
|
11108
|
+
*/
|
|
11109
|
+
exports.mul = function mul(x, y) {
|
|
11110
|
+
if (x === 0 || y === 0) return 0;
|
|
11111
|
+
return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
|
|
11112
|
+
};
|
|
11113
|
+
}));
|
|
11114
|
+
//#endregion
|
|
11115
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/polynomial.js
|
|
11116
|
+
var require_polynomial = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11117
|
+
const GF = require_galois_field();
|
|
11118
|
+
/**
|
|
11119
|
+
* Multiplies two polynomials inside Galois Field
|
|
11120
|
+
*
|
|
11121
|
+
* @param {Uint8Array} p1 Polynomial
|
|
11122
|
+
* @param {Uint8Array} p2 Polynomial
|
|
11123
|
+
* @return {Uint8Array} Product of p1 and p2
|
|
11124
|
+
*/
|
|
11125
|
+
exports.mul = function mul(p1, p2) {
|
|
11126
|
+
const coeff = new Uint8Array(p1.length + p2.length - 1);
|
|
11127
|
+
for (let i = 0; i < p1.length; i++) for (let j = 0; j < p2.length; j++) coeff[i + j] ^= GF.mul(p1[i], p2[j]);
|
|
11128
|
+
return coeff;
|
|
11129
|
+
};
|
|
11130
|
+
/**
|
|
11131
|
+
* Calculate the remainder of polynomials division
|
|
11132
|
+
*
|
|
11133
|
+
* @param {Uint8Array} divident Polynomial
|
|
11134
|
+
* @param {Uint8Array} divisor Polynomial
|
|
11135
|
+
* @return {Uint8Array} Remainder
|
|
11136
|
+
*/
|
|
11137
|
+
exports.mod = function mod(divident, divisor) {
|
|
11138
|
+
let result = new Uint8Array(divident);
|
|
11139
|
+
while (result.length - divisor.length >= 0) {
|
|
11140
|
+
const coeff = result[0];
|
|
11141
|
+
for (let i = 0; i < divisor.length; i++) result[i] ^= GF.mul(divisor[i], coeff);
|
|
11142
|
+
let offset = 0;
|
|
11143
|
+
while (offset < result.length && result[offset] === 0) offset++;
|
|
11144
|
+
result = result.slice(offset);
|
|
11145
|
+
}
|
|
11146
|
+
return result;
|
|
11147
|
+
};
|
|
11148
|
+
/**
|
|
11149
|
+
* Generate an irreducible generator polynomial of specified degree
|
|
11150
|
+
* (used by Reed-Solomon encoder)
|
|
11151
|
+
*
|
|
11152
|
+
* @param {Number} degree Degree of the generator polynomial
|
|
11153
|
+
* @return {Uint8Array} Buffer containing polynomial coefficients
|
|
11154
|
+
*/
|
|
11155
|
+
exports.generateECPolynomial = function generateECPolynomial(degree) {
|
|
11156
|
+
let poly = new Uint8Array([1]);
|
|
11157
|
+
for (let i = 0; i < degree; i++) poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
|
|
11158
|
+
return poly;
|
|
11159
|
+
};
|
|
11160
|
+
}));
|
|
11161
|
+
//#endregion
|
|
11162
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/reed-solomon-encoder.js
|
|
11163
|
+
var require_reed_solomon_encoder = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11164
|
+
const Polynomial = require_polynomial();
|
|
11165
|
+
function ReedSolomonEncoder(degree) {
|
|
11166
|
+
this.genPoly = void 0;
|
|
11167
|
+
this.degree = degree;
|
|
11168
|
+
if (this.degree) this.initialize(this.degree);
|
|
11169
|
+
}
|
|
11170
|
+
/**
|
|
11171
|
+
* Initialize the encoder.
|
|
11172
|
+
* The input param should correspond to the number of error correction codewords.
|
|
11173
|
+
*
|
|
11174
|
+
* @param {Number} degree
|
|
11175
|
+
*/
|
|
11176
|
+
ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
|
|
11177
|
+
this.degree = degree;
|
|
11178
|
+
this.genPoly = Polynomial.generateECPolynomial(this.degree);
|
|
11179
|
+
};
|
|
11180
|
+
/**
|
|
11181
|
+
* Encodes a chunk of data
|
|
11182
|
+
*
|
|
11183
|
+
* @param {Uint8Array} data Buffer containing input data
|
|
11184
|
+
* @return {Uint8Array} Buffer containing encoded data
|
|
11185
|
+
*/
|
|
11186
|
+
ReedSolomonEncoder.prototype.encode = function encode(data) {
|
|
11187
|
+
if (!this.genPoly) throw new Error("Encoder not initialized");
|
|
11188
|
+
const paddedData = new Uint8Array(data.length + this.degree);
|
|
11189
|
+
paddedData.set(data);
|
|
11190
|
+
const remainder = Polynomial.mod(paddedData, this.genPoly);
|
|
11191
|
+
const start = this.degree - remainder.length;
|
|
11192
|
+
if (start > 0) {
|
|
11193
|
+
const buff = new Uint8Array(this.degree);
|
|
11194
|
+
buff.set(remainder, start);
|
|
11195
|
+
return buff;
|
|
11196
|
+
}
|
|
11197
|
+
return remainder;
|
|
11198
|
+
};
|
|
11199
|
+
module.exports = ReedSolomonEncoder;
|
|
11200
|
+
}));
|
|
11201
|
+
//#endregion
|
|
11202
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version-check.js
|
|
11203
|
+
var require_version_check = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11204
|
+
/**
|
|
11205
|
+
* Check if QR Code version is valid
|
|
11206
|
+
*
|
|
11207
|
+
* @param {Number} version QR Code version
|
|
11208
|
+
* @return {Boolean} true if valid version, false otherwise
|
|
11209
|
+
*/
|
|
11210
|
+
exports.isValid = function isValid(version) {
|
|
11211
|
+
return !isNaN(version) && version >= 1 && version <= 40;
|
|
11212
|
+
};
|
|
11213
|
+
}));
|
|
11214
|
+
//#endregion
|
|
11215
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/regex.js
|
|
11216
|
+
var require_regex = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11217
|
+
const numeric = "[0-9]+";
|
|
11218
|
+
const alphanumeric = "[A-Z $%*+\\-./:]+";
|
|
11219
|
+
let kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
11220
|
+
kanji = kanji.replace(/u/g, "\\u");
|
|
11221
|
+
const byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
|
|
11222
|
+
exports.KANJI = new RegExp(kanji, "g");
|
|
11223
|
+
exports.BYTE_KANJI = /* @__PURE__ */ new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
11224
|
+
exports.BYTE = new RegExp(byte, "g");
|
|
11225
|
+
exports.NUMERIC = new RegExp(numeric, "g");
|
|
11226
|
+
exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
|
|
11227
|
+
const TEST_KANJI = new RegExp("^" + kanji + "$");
|
|
11228
|
+
const TEST_NUMERIC = /* @__PURE__ */ new RegExp("^[0-9]+$");
|
|
11229
|
+
const TEST_ALPHANUMERIC = /* @__PURE__ */ new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
11230
|
+
exports.testKanji = function testKanji(str) {
|
|
11231
|
+
return TEST_KANJI.test(str);
|
|
11232
|
+
};
|
|
11233
|
+
exports.testNumeric = function testNumeric(str) {
|
|
11234
|
+
return TEST_NUMERIC.test(str);
|
|
11235
|
+
};
|
|
11236
|
+
exports.testAlphanumeric = function testAlphanumeric(str) {
|
|
11237
|
+
return TEST_ALPHANUMERIC.test(str);
|
|
11238
|
+
};
|
|
11239
|
+
}));
|
|
11240
|
+
//#endregion
|
|
11241
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/mode.js
|
|
11242
|
+
var require_mode = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11243
|
+
const VersionCheck = require_version_check();
|
|
11244
|
+
const Regex = require_regex();
|
|
11245
|
+
/**
|
|
11246
|
+
* Numeric mode encodes data from the decimal digit set (0 - 9)
|
|
11247
|
+
* (byte values 30HEX to 39HEX).
|
|
11248
|
+
* Normally, 3 data characters are represented by 10 bits.
|
|
11249
|
+
*
|
|
11250
|
+
* @type {Object}
|
|
11251
|
+
*/
|
|
11252
|
+
exports.NUMERIC = {
|
|
11253
|
+
id: "Numeric",
|
|
11254
|
+
bit: 1,
|
|
11255
|
+
ccBits: [
|
|
11256
|
+
10,
|
|
11257
|
+
12,
|
|
11258
|
+
14
|
|
11259
|
+
]
|
|
11260
|
+
};
|
|
11261
|
+
/**
|
|
11262
|
+
* Alphanumeric mode encodes data from a set of 45 characters,
|
|
11263
|
+
* i.e. 10 numeric digits (0 - 9),
|
|
11264
|
+
* 26 alphabetic characters (A - Z),
|
|
11265
|
+
* and 9 symbols (SP, $, %, *, +, -, ., /, :).
|
|
11266
|
+
* Normally, two input characters are represented by 11 bits.
|
|
11267
|
+
*
|
|
11268
|
+
* @type {Object}
|
|
11269
|
+
*/
|
|
11270
|
+
exports.ALPHANUMERIC = {
|
|
11271
|
+
id: "Alphanumeric",
|
|
11272
|
+
bit: 2,
|
|
11273
|
+
ccBits: [
|
|
11274
|
+
9,
|
|
11275
|
+
11,
|
|
11276
|
+
13
|
|
11277
|
+
]
|
|
11278
|
+
};
|
|
11279
|
+
/**
|
|
11280
|
+
* In byte mode, data is encoded at 8 bits per character.
|
|
11281
|
+
*
|
|
11282
|
+
* @type {Object}
|
|
11283
|
+
*/
|
|
11284
|
+
exports.BYTE = {
|
|
11285
|
+
id: "Byte",
|
|
11286
|
+
bit: 4,
|
|
11287
|
+
ccBits: [
|
|
11288
|
+
8,
|
|
11289
|
+
16,
|
|
11290
|
+
16
|
|
11291
|
+
]
|
|
11292
|
+
};
|
|
11293
|
+
/**
|
|
11294
|
+
* The Kanji mode efficiently encodes Kanji characters in accordance with
|
|
11295
|
+
* the Shift JIS system based on JIS X 0208.
|
|
11296
|
+
* The Shift JIS values are shifted from the JIS X 0208 values.
|
|
11297
|
+
* JIS X 0208 gives details of the shift coded representation.
|
|
11298
|
+
* Each two-byte character value is compacted to a 13-bit binary codeword.
|
|
11299
|
+
*
|
|
11300
|
+
* @type {Object}
|
|
11301
|
+
*/
|
|
11302
|
+
exports.KANJI = {
|
|
11303
|
+
id: "Kanji",
|
|
11304
|
+
bit: 8,
|
|
11305
|
+
ccBits: [
|
|
11306
|
+
8,
|
|
11307
|
+
10,
|
|
11308
|
+
12
|
|
11309
|
+
]
|
|
11310
|
+
};
|
|
11311
|
+
/**
|
|
11312
|
+
* Mixed mode will contain a sequences of data in a combination of any of
|
|
11313
|
+
* the modes described above
|
|
11314
|
+
*
|
|
11315
|
+
* @type {Object}
|
|
11316
|
+
*/
|
|
11317
|
+
exports.MIXED = { bit: -1 };
|
|
11318
|
+
/**
|
|
11319
|
+
* Returns the number of bits needed to store the data length
|
|
11320
|
+
* according to QR Code specifications.
|
|
11321
|
+
*
|
|
11322
|
+
* @param {Mode} mode Data mode
|
|
11323
|
+
* @param {Number} version QR Code version
|
|
11324
|
+
* @return {Number} Number of bits
|
|
11325
|
+
*/
|
|
11326
|
+
exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
|
|
11327
|
+
if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
|
|
11328
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid version: " + version);
|
|
11329
|
+
if (version >= 1 && version < 10) return mode.ccBits[0];
|
|
11330
|
+
else if (version < 27) return mode.ccBits[1];
|
|
11331
|
+
return mode.ccBits[2];
|
|
11332
|
+
};
|
|
11333
|
+
/**
|
|
11334
|
+
* Returns the most efficient mode to store the specified data
|
|
11335
|
+
*
|
|
11336
|
+
* @param {String} dataStr Input data string
|
|
11337
|
+
* @return {Mode} Best mode
|
|
11338
|
+
*/
|
|
11339
|
+
exports.getBestModeForData = function getBestModeForData(dataStr) {
|
|
11340
|
+
if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
|
|
11341
|
+
else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
|
|
11342
|
+
else if (Regex.testKanji(dataStr)) return exports.KANJI;
|
|
11343
|
+
else return exports.BYTE;
|
|
11344
|
+
};
|
|
11345
|
+
/**
|
|
11346
|
+
* Return mode name as string
|
|
11347
|
+
*
|
|
11348
|
+
* @param {Mode} mode Mode object
|
|
11349
|
+
* @returns {String} Mode name
|
|
11350
|
+
*/
|
|
11351
|
+
exports.toString = function toString(mode) {
|
|
11352
|
+
if (mode && mode.id) return mode.id;
|
|
11353
|
+
throw new Error("Invalid mode");
|
|
11354
|
+
};
|
|
11355
|
+
/**
|
|
11356
|
+
* Check if input param is a valid mode object
|
|
11357
|
+
*
|
|
11358
|
+
* @param {Mode} mode Mode object
|
|
11359
|
+
* @returns {Boolean} True if valid mode, false otherwise
|
|
11360
|
+
*/
|
|
11361
|
+
exports.isValid = function isValid(mode) {
|
|
11362
|
+
return mode && mode.bit && mode.ccBits;
|
|
11363
|
+
};
|
|
11364
|
+
/**
|
|
11365
|
+
* Get mode object from its name
|
|
11366
|
+
*
|
|
11367
|
+
* @param {String} string Mode name
|
|
11368
|
+
* @returns {Mode} Mode object
|
|
11369
|
+
*/
|
|
11370
|
+
function fromString(string) {
|
|
11371
|
+
if (typeof string !== "string") throw new Error("Param is not a string");
|
|
11372
|
+
switch (string.toLowerCase()) {
|
|
11373
|
+
case "numeric": return exports.NUMERIC;
|
|
11374
|
+
case "alphanumeric": return exports.ALPHANUMERIC;
|
|
11375
|
+
case "kanji": return exports.KANJI;
|
|
11376
|
+
case "byte": return exports.BYTE;
|
|
11377
|
+
default: throw new Error("Unknown mode: " + string);
|
|
11378
|
+
}
|
|
11379
|
+
}
|
|
11380
|
+
/**
|
|
11381
|
+
* Returns mode from a value.
|
|
11382
|
+
* If value is not a valid mode, returns defaultValue
|
|
11383
|
+
*
|
|
11384
|
+
* @param {Mode|String} value Encoding mode
|
|
11385
|
+
* @param {Mode} defaultValue Fallback value
|
|
11386
|
+
* @return {Mode} Encoding mode
|
|
11387
|
+
*/
|
|
11388
|
+
exports.from = function from(value, defaultValue) {
|
|
11389
|
+
if (exports.isValid(value)) return value;
|
|
11390
|
+
try {
|
|
11391
|
+
return fromString(value);
|
|
11392
|
+
} catch (e) {
|
|
11393
|
+
return defaultValue;
|
|
11394
|
+
}
|
|
11395
|
+
};
|
|
11396
|
+
}));
|
|
11397
|
+
//#endregion
|
|
11398
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/version.js
|
|
11399
|
+
var require_version = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11400
|
+
const Utils = require_utils();
|
|
11401
|
+
const ECCode = require_error_correction_code();
|
|
11402
|
+
const ECLevel = require_error_correction_level();
|
|
11403
|
+
const Mode = require_mode();
|
|
11404
|
+
const VersionCheck = require_version_check();
|
|
11405
|
+
const G18 = 7973;
|
|
11406
|
+
const G18_BCH = Utils.getBCHDigit(G18);
|
|
11407
|
+
function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
|
|
11408
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) return currentVersion;
|
|
11409
|
+
}
|
|
11410
|
+
function getReservedBitsCount(mode, version) {
|
|
11411
|
+
return Mode.getCharCountIndicator(mode, version) + 4;
|
|
11412
|
+
}
|
|
11413
|
+
function getTotalBitsFromDataArray(segments, version) {
|
|
11414
|
+
let totalBits = 0;
|
|
11415
|
+
segments.forEach(function(data) {
|
|
11416
|
+
const reservedBits = getReservedBitsCount(data.mode, version);
|
|
11417
|
+
totalBits += reservedBits + data.getBitsLength();
|
|
11418
|
+
});
|
|
11419
|
+
return totalBits;
|
|
11420
|
+
}
|
|
11421
|
+
function getBestVersionForMixedData(segments, errorCorrectionLevel) {
|
|
11422
|
+
for (let currentVersion = 1; currentVersion <= 40; currentVersion++) if (getTotalBitsFromDataArray(segments, currentVersion) <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) return currentVersion;
|
|
11423
|
+
}
|
|
11424
|
+
/**
|
|
11425
|
+
* Returns version number from a value.
|
|
11426
|
+
* If value is not a valid version, returns defaultValue
|
|
11427
|
+
*
|
|
11428
|
+
* @param {Number|String} value QR Code version
|
|
11429
|
+
* @param {Number} defaultValue Fallback value
|
|
11430
|
+
* @return {Number} QR Code version number
|
|
11431
|
+
*/
|
|
11432
|
+
exports.from = function from(value, defaultValue) {
|
|
11433
|
+
if (VersionCheck.isValid(value)) return parseInt(value, 10);
|
|
11434
|
+
return defaultValue;
|
|
11435
|
+
};
|
|
11436
|
+
/**
|
|
11437
|
+
* Returns how much data can be stored with the specified QR code version
|
|
11438
|
+
* and error correction level
|
|
11439
|
+
*
|
|
11440
|
+
* @param {Number} version QR Code version (1-40)
|
|
11441
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11442
|
+
* @param {Mode} mode Data mode
|
|
11443
|
+
* @return {Number} Quantity of storable data
|
|
11444
|
+
*/
|
|
11445
|
+
exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
|
|
11446
|
+
if (!VersionCheck.isValid(version)) throw new Error("Invalid QR Code version");
|
|
11447
|
+
if (typeof mode === "undefined") mode = Mode.BYTE;
|
|
11448
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
11449
|
+
if (mode === Mode.MIXED) return dataTotalCodewordsBits;
|
|
11450
|
+
const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
|
|
11451
|
+
switch (mode) {
|
|
11452
|
+
case Mode.NUMERIC: return Math.floor(usableBits / 10 * 3);
|
|
11453
|
+
case Mode.ALPHANUMERIC: return Math.floor(usableBits / 11 * 2);
|
|
11454
|
+
case Mode.KANJI: return Math.floor(usableBits / 13);
|
|
11455
|
+
case Mode.BYTE:
|
|
11456
|
+
default: return Math.floor(usableBits / 8);
|
|
11457
|
+
}
|
|
11458
|
+
};
|
|
11459
|
+
/**
|
|
11460
|
+
* Returns the minimum version needed to contain the amount of data
|
|
11461
|
+
*
|
|
11462
|
+
* @param {Segment} data Segment of data
|
|
11463
|
+
* @param {Number} [errorCorrectionLevel=H] Error correction level
|
|
11464
|
+
* @param {Mode} mode Data mode
|
|
11465
|
+
* @return {Number} QR Code version
|
|
11466
|
+
*/
|
|
11467
|
+
exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
|
|
11468
|
+
let seg;
|
|
11469
|
+
const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
|
|
11470
|
+
if (Array.isArray(data)) {
|
|
11471
|
+
if (data.length > 1) return getBestVersionForMixedData(data, ecl);
|
|
11472
|
+
if (data.length === 0) return 1;
|
|
11473
|
+
seg = data[0];
|
|
11474
|
+
} else seg = data;
|
|
11475
|
+
return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
|
|
11476
|
+
};
|
|
11477
|
+
/**
|
|
11478
|
+
* Returns version information with relative error correction bits
|
|
11479
|
+
*
|
|
11480
|
+
* The version information is included in QR Code symbols of version 7 or larger.
|
|
11481
|
+
* It consists of an 18-bit sequence containing 6 data bits,
|
|
11482
|
+
* with 12 error correction bits calculated using the (18, 6) Golay code.
|
|
11483
|
+
*
|
|
11484
|
+
* @param {Number} version QR Code version
|
|
11485
|
+
* @return {Number} Encoded version info bits
|
|
11486
|
+
*/
|
|
11487
|
+
exports.getEncodedBits = function getEncodedBits(version) {
|
|
11488
|
+
if (!VersionCheck.isValid(version) || version < 7) throw new Error("Invalid QR Code version");
|
|
11489
|
+
let d = version << 12;
|
|
11490
|
+
while (Utils.getBCHDigit(d) - G18_BCH >= 0) d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
|
|
11491
|
+
return version << 12 | d;
|
|
11492
|
+
};
|
|
11493
|
+
}));
|
|
11494
|
+
//#endregion
|
|
11495
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/format-info.js
|
|
11496
|
+
var require_format_info = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11497
|
+
const Utils = require_utils();
|
|
11498
|
+
const G15 = 1335;
|
|
11499
|
+
const G15_MASK = 21522;
|
|
11500
|
+
const G15_BCH = Utils.getBCHDigit(G15);
|
|
11501
|
+
/**
|
|
11502
|
+
* Returns format information with relative error correction bits
|
|
11503
|
+
*
|
|
11504
|
+
* The format information is a 15-bit sequence containing 5 data bits,
|
|
11505
|
+
* with 10 error correction bits calculated using the (15, 5) BCH code.
|
|
11506
|
+
*
|
|
11507
|
+
* @param {Number} errorCorrectionLevel Error correction level
|
|
11508
|
+
* @param {Number} mask Mask pattern
|
|
11509
|
+
* @return {Number} Encoded format information bits
|
|
11510
|
+
*/
|
|
11511
|
+
exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
|
|
11512
|
+
const data = errorCorrectionLevel.bit << 3 | mask;
|
|
11513
|
+
let d = data << 10;
|
|
11514
|
+
while (Utils.getBCHDigit(d) - G15_BCH >= 0) d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
|
|
11515
|
+
return (data << 10 | d) ^ G15_MASK;
|
|
11516
|
+
};
|
|
11517
|
+
}));
|
|
11518
|
+
//#endregion
|
|
11519
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/numeric-data.js
|
|
11520
|
+
var require_numeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11521
|
+
const Mode = require_mode();
|
|
11522
|
+
function NumericData(data) {
|
|
11523
|
+
this.mode = Mode.NUMERIC;
|
|
11524
|
+
this.data = data.toString();
|
|
11525
|
+
}
|
|
11526
|
+
NumericData.getBitsLength = function getBitsLength(length) {
|
|
11527
|
+
return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
|
|
11528
|
+
};
|
|
11529
|
+
NumericData.prototype.getLength = function getLength() {
|
|
11530
|
+
return this.data.length;
|
|
11531
|
+
};
|
|
11532
|
+
NumericData.prototype.getBitsLength = function getBitsLength() {
|
|
11533
|
+
return NumericData.getBitsLength(this.data.length);
|
|
11534
|
+
};
|
|
11535
|
+
NumericData.prototype.write = function write(bitBuffer) {
|
|
11536
|
+
let i, group, value;
|
|
11537
|
+
for (i = 0; i + 3 <= this.data.length; i += 3) {
|
|
11538
|
+
group = this.data.substr(i, 3);
|
|
11539
|
+
value = parseInt(group, 10);
|
|
11540
|
+
bitBuffer.put(value, 10);
|
|
11541
|
+
}
|
|
11542
|
+
const remainingNum = this.data.length - i;
|
|
11543
|
+
if (remainingNum > 0) {
|
|
11544
|
+
group = this.data.substr(i);
|
|
11545
|
+
value = parseInt(group, 10);
|
|
11546
|
+
bitBuffer.put(value, remainingNum * 3 + 1);
|
|
11547
|
+
}
|
|
11548
|
+
};
|
|
11549
|
+
module.exports = NumericData;
|
|
11550
|
+
}));
|
|
11551
|
+
//#endregion
|
|
11552
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/alphanumeric-data.js
|
|
11553
|
+
var require_alphanumeric_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11554
|
+
const Mode = require_mode();
|
|
11555
|
+
/**
|
|
11556
|
+
* Array of characters available in alphanumeric mode
|
|
11557
|
+
*
|
|
11558
|
+
* As per QR Code specification, to each character
|
|
11559
|
+
* is assigned a value from 0 to 44 which in this case coincides
|
|
11560
|
+
* with the array index
|
|
11561
|
+
*
|
|
11562
|
+
* @type {Array}
|
|
11563
|
+
*/
|
|
11564
|
+
const ALPHA_NUM_CHARS = [
|
|
11565
|
+
"0",
|
|
11566
|
+
"1",
|
|
11567
|
+
"2",
|
|
11568
|
+
"3",
|
|
11569
|
+
"4",
|
|
11570
|
+
"5",
|
|
11571
|
+
"6",
|
|
11572
|
+
"7",
|
|
11573
|
+
"8",
|
|
11574
|
+
"9",
|
|
11575
|
+
"A",
|
|
11576
|
+
"B",
|
|
11577
|
+
"C",
|
|
11578
|
+
"D",
|
|
11579
|
+
"E",
|
|
11580
|
+
"F",
|
|
11581
|
+
"G",
|
|
11582
|
+
"H",
|
|
11583
|
+
"I",
|
|
11584
|
+
"J",
|
|
11585
|
+
"K",
|
|
11586
|
+
"L",
|
|
11587
|
+
"M",
|
|
11588
|
+
"N",
|
|
11589
|
+
"O",
|
|
11590
|
+
"P",
|
|
11591
|
+
"Q",
|
|
11592
|
+
"R",
|
|
11593
|
+
"S",
|
|
11594
|
+
"T",
|
|
11595
|
+
"U",
|
|
11596
|
+
"V",
|
|
11597
|
+
"W",
|
|
11598
|
+
"X",
|
|
11599
|
+
"Y",
|
|
11600
|
+
"Z",
|
|
11601
|
+
" ",
|
|
11602
|
+
"$",
|
|
11603
|
+
"%",
|
|
11604
|
+
"*",
|
|
11605
|
+
"+",
|
|
11606
|
+
"-",
|
|
11607
|
+
".",
|
|
11608
|
+
"/",
|
|
11609
|
+
":"
|
|
11610
|
+
];
|
|
11611
|
+
function AlphanumericData(data) {
|
|
11612
|
+
this.mode = Mode.ALPHANUMERIC;
|
|
11613
|
+
this.data = data;
|
|
11614
|
+
}
|
|
11615
|
+
AlphanumericData.getBitsLength = function getBitsLength(length) {
|
|
11616
|
+
return 11 * Math.floor(length / 2) + 6 * (length % 2);
|
|
11617
|
+
};
|
|
11618
|
+
AlphanumericData.prototype.getLength = function getLength() {
|
|
11619
|
+
return this.data.length;
|
|
11620
|
+
};
|
|
11621
|
+
AlphanumericData.prototype.getBitsLength = function getBitsLength() {
|
|
11622
|
+
return AlphanumericData.getBitsLength(this.data.length);
|
|
11623
|
+
};
|
|
11624
|
+
AlphanumericData.prototype.write = function write(bitBuffer) {
|
|
11625
|
+
let i;
|
|
11626
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
11627
|
+
let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
|
|
11628
|
+
value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
|
|
11629
|
+
bitBuffer.put(value, 11);
|
|
11630
|
+
}
|
|
11631
|
+
if (this.data.length % 2) bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
|
|
11632
|
+
};
|
|
11633
|
+
module.exports = AlphanumericData;
|
|
11634
|
+
}));
|
|
11635
|
+
//#endregion
|
|
11636
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/byte-data.js
|
|
11637
|
+
var require_byte_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11638
|
+
const Mode = require_mode();
|
|
11639
|
+
function ByteData(data) {
|
|
11640
|
+
this.mode = Mode.BYTE;
|
|
11641
|
+
if (typeof data === "string") this.data = new TextEncoder().encode(data);
|
|
11642
|
+
else this.data = new Uint8Array(data);
|
|
11643
|
+
}
|
|
11644
|
+
ByteData.getBitsLength = function getBitsLength(length) {
|
|
11645
|
+
return length * 8;
|
|
11646
|
+
};
|
|
11647
|
+
ByteData.prototype.getLength = function getLength() {
|
|
11648
|
+
return this.data.length;
|
|
11649
|
+
};
|
|
11650
|
+
ByteData.prototype.getBitsLength = function getBitsLength() {
|
|
11651
|
+
return ByteData.getBitsLength(this.data.length);
|
|
11652
|
+
};
|
|
11653
|
+
ByteData.prototype.write = function(bitBuffer) {
|
|
11654
|
+
for (let i = 0, l = this.data.length; i < l; i++) bitBuffer.put(this.data[i], 8);
|
|
11655
|
+
};
|
|
11656
|
+
module.exports = ByteData;
|
|
11657
|
+
}));
|
|
11658
|
+
//#endregion
|
|
11659
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/kanji-data.js
|
|
11660
|
+
var require_kanji_data = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11661
|
+
const Mode = require_mode();
|
|
11662
|
+
const Utils = require_utils();
|
|
11663
|
+
function KanjiData(data) {
|
|
11664
|
+
this.mode = Mode.KANJI;
|
|
11665
|
+
this.data = data;
|
|
11666
|
+
}
|
|
11667
|
+
KanjiData.getBitsLength = function getBitsLength(length) {
|
|
11668
|
+
return length * 13;
|
|
11669
|
+
};
|
|
11670
|
+
KanjiData.prototype.getLength = function getLength() {
|
|
11671
|
+
return this.data.length;
|
|
11672
|
+
};
|
|
11673
|
+
KanjiData.prototype.getBitsLength = function getBitsLength() {
|
|
11674
|
+
return KanjiData.getBitsLength(this.data.length);
|
|
11675
|
+
};
|
|
11676
|
+
KanjiData.prototype.write = function(bitBuffer) {
|
|
11677
|
+
let i;
|
|
11678
|
+
for (i = 0; i < this.data.length; i++) {
|
|
11679
|
+
let value = Utils.toSJIS(this.data[i]);
|
|
11680
|
+
if (value >= 33088 && value <= 40956) value -= 33088;
|
|
11681
|
+
else if (value >= 57408 && value <= 60351) value -= 49472;
|
|
11682
|
+
else throw new Error("Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8");
|
|
11683
|
+
value = (value >>> 8 & 255) * 192 + (value & 255);
|
|
11684
|
+
bitBuffer.put(value, 13);
|
|
11685
|
+
}
|
|
11686
|
+
};
|
|
11687
|
+
module.exports = KanjiData;
|
|
11688
|
+
}));
|
|
11689
|
+
//#endregion
|
|
11690
|
+
//#region node_modules/.pnpm/dijkstrajs@1.0.3/node_modules/dijkstrajs/dijkstra.js
|
|
11691
|
+
var require_dijkstra = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
11692
|
+
/******************************************************************************
|
|
11693
|
+
* Created 2008-08-19.
|
|
11694
|
+
*
|
|
11695
|
+
* Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
|
|
11696
|
+
*
|
|
11697
|
+
* Copyright (C) 2008
|
|
11698
|
+
* Wyatt Baldwin <self@wyattbaldwin.com>
|
|
11699
|
+
* All rights reserved
|
|
11700
|
+
*
|
|
11701
|
+
* Licensed under the MIT license.
|
|
11702
|
+
*
|
|
11703
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
11704
|
+
*
|
|
11705
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
11706
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
11707
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
11708
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
11709
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
11710
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
11711
|
+
* THE SOFTWARE.
|
|
11712
|
+
*****************************************************************************/
|
|
11713
|
+
var dijkstra = {
|
|
11714
|
+
single_source_shortest_paths: function(graph, s, d) {
|
|
11715
|
+
var predecessors = {};
|
|
11716
|
+
var costs = {};
|
|
11717
|
+
costs[s] = 0;
|
|
11718
|
+
var open = dijkstra.PriorityQueue.make();
|
|
11719
|
+
open.push(s, 0);
|
|
11720
|
+
var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
|
|
11721
|
+
while (!open.empty()) {
|
|
11722
|
+
closest = open.pop();
|
|
11723
|
+
u = closest.value;
|
|
11724
|
+
cost_of_s_to_u = closest.cost;
|
|
11725
|
+
adjacent_nodes = graph[u] || {};
|
|
11726
|
+
for (v in adjacent_nodes) if (adjacent_nodes.hasOwnProperty(v)) {
|
|
11727
|
+
cost_of_e = adjacent_nodes[v];
|
|
11728
|
+
cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
|
|
11729
|
+
cost_of_s_to_v = costs[v];
|
|
11730
|
+
first_visit = typeof costs[v] === "undefined";
|
|
11731
|
+
if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
|
|
11732
|
+
costs[v] = cost_of_s_to_u_plus_cost_of_e;
|
|
11733
|
+
open.push(v, cost_of_s_to_u_plus_cost_of_e);
|
|
11734
|
+
predecessors[v] = u;
|
|
11735
|
+
}
|
|
11736
|
+
}
|
|
11737
|
+
}
|
|
11738
|
+
if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
|
|
11739
|
+
var msg = [
|
|
11740
|
+
"Could not find a path from ",
|
|
11741
|
+
s,
|
|
11742
|
+
" to ",
|
|
11743
|
+
d,
|
|
11744
|
+
"."
|
|
11745
|
+
].join("");
|
|
11746
|
+
throw new Error(msg);
|
|
11747
|
+
}
|
|
11748
|
+
return predecessors;
|
|
11749
|
+
},
|
|
11750
|
+
extract_shortest_path_from_predecessor_list: function(predecessors, d) {
|
|
11751
|
+
var nodes = [];
|
|
11752
|
+
var u = d;
|
|
11753
|
+
while (u) {
|
|
11754
|
+
nodes.push(u);
|
|
11755
|
+
predecessors[u];
|
|
11756
|
+
u = predecessors[u];
|
|
11757
|
+
}
|
|
11758
|
+
nodes.reverse();
|
|
11759
|
+
return nodes;
|
|
11760
|
+
},
|
|
11761
|
+
find_path: function(graph, s, d) {
|
|
11762
|
+
var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
|
|
11763
|
+
return dijkstra.extract_shortest_path_from_predecessor_list(predecessors, d);
|
|
11764
|
+
},
|
|
11765
|
+
/**
|
|
11766
|
+
* A very naive priority queue implementation.
|
|
11767
|
+
*/
|
|
11768
|
+
PriorityQueue: {
|
|
11769
|
+
make: function(opts) {
|
|
11770
|
+
var T = dijkstra.PriorityQueue, t = {}, key;
|
|
11771
|
+
opts = opts || {};
|
|
11772
|
+
for (key in T) if (T.hasOwnProperty(key)) t[key] = T[key];
|
|
11773
|
+
t.queue = [];
|
|
11774
|
+
t.sorter = opts.sorter || T.default_sorter;
|
|
11775
|
+
return t;
|
|
11776
|
+
},
|
|
11777
|
+
default_sorter: function(a, b) {
|
|
11778
|
+
return a.cost - b.cost;
|
|
11779
|
+
},
|
|
11780
|
+
/**
|
|
11781
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
11782
|
+
* is at the front of the queue.
|
|
11783
|
+
*/
|
|
11784
|
+
push: function(value, cost) {
|
|
11785
|
+
var item = {
|
|
11786
|
+
value,
|
|
11787
|
+
cost
|
|
11788
|
+
};
|
|
11789
|
+
this.queue.push(item);
|
|
11790
|
+
this.queue.sort(this.sorter);
|
|
11791
|
+
},
|
|
11792
|
+
/**
|
|
11793
|
+
* Return the highest priority element in the queue.
|
|
11794
|
+
*/
|
|
11795
|
+
pop: function() {
|
|
11796
|
+
return this.queue.shift();
|
|
11797
|
+
},
|
|
11798
|
+
empty: function() {
|
|
11799
|
+
return this.queue.length === 0;
|
|
11800
|
+
}
|
|
11801
|
+
}
|
|
11802
|
+
};
|
|
11803
|
+
if (typeof module !== "undefined") module.exports = dijkstra;
|
|
11804
|
+
}));
|
|
11805
|
+
//#endregion
|
|
11806
|
+
//#region node_modules/.pnpm/qrcode@1.5.4/node_modules/qrcode/lib/core/segments.js
|
|
11807
|
+
var require_segments = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
11808
|
+
const Mode = require_mode();
|
|
11809
|
+
const NumericData = require_numeric_data();
|
|
11810
|
+
const AlphanumericData = require_alphanumeric_data();
|
|
11811
|
+
const ByteData = require_byte_data();
|
|
11812
|
+
const KanjiData = require_kanji_data();
|
|
11813
|
+
const Regex = require_regex();
|
|
11814
|
+
const Utils = require_utils();
|
|
11815
|
+
const dijkstra = require_dijkstra();
|
|
11816
|
+
/**
|
|
11817
|
+
* Returns UTF8 byte length
|
|
11818
|
+
*
|
|
11819
|
+
* @param {String} str Input string
|
|
11820
|
+
* @return {Number} Number of byte
|
|
11821
|
+
*/
|
|
11822
|
+
function getStringByteLength(str) {
|
|
11823
|
+
return unescape(encodeURIComponent(str)).length;
|
|
11824
|
+
}
|
|
11825
|
+
/**
|
|
11826
|
+
* Get a list of segments of the specified mode
|
|
11827
|
+
* from a string
|
|
11828
|
+
*
|
|
11829
|
+
* @param {Mode} mode Segment mode
|
|
11830
|
+
* @param {String} str String to process
|
|
11831
|
+
* @return {Array} Array of object with segments data
|
|
11832
|
+
*/
|
|
11833
|
+
function getSegments(regex, mode, str) {
|
|
11834
|
+
const segments = [];
|
|
11835
|
+
let result;
|
|
11836
|
+
while ((result = regex.exec(str)) !== null) segments.push({
|
|
11837
|
+
data: result[0],
|
|
11838
|
+
index: result.index,
|
|
11839
|
+
mode,
|
|
11840
|
+
length: result[0].length
|
|
11841
|
+
});
|
|
11842
|
+
return segments;
|
|
11843
|
+
}
|
|
11844
|
+
/**
|
|
11845
|
+
* Extracts a series of segments with the appropriate
|
|
11846
|
+
* modes from a string
|
|
11847
|
+
*
|
|
11848
|
+
* @param {String} dataStr Input string
|
|
11849
|
+
* @return {Array} Array of object with segments data
|
|
11850
|
+
*/
|
|
11851
|
+
function getSegmentsFromString(dataStr) {
|
|
11852
|
+
const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
|
|
11853
|
+
const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
|
|
11854
|
+
let byteSegs;
|
|
11855
|
+
let kanjiSegs;
|
|
11856
|
+
if (Utils.isKanjiModeEnabled()) {
|
|
11857
|
+
byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
|
|
11858
|
+
kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
|
|
11859
|
+
} else {
|
|
11860
|
+
byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
|
|
11861
|
+
kanjiSegs = [];
|
|
11862
|
+
}
|
|
11863
|
+
return numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs).sort(function(s1, s2) {
|
|
11864
|
+
return s1.index - s2.index;
|
|
11865
|
+
}).map(function(obj) {
|
|
11866
|
+
return {
|
|
11867
|
+
data: obj.data,
|
|
11868
|
+
mode: obj.mode,
|
|
11869
|
+
length: obj.length
|
|
11870
|
+
};
|
|
11871
|
+
});
|
|
11872
|
+
}
|
|
11873
|
+
/**
|
|
11874
|
+
* Returns how many bits are needed to encode a string of
|
|
11875
|
+
* specified length with the specified mode
|
|
11876
|
+
*
|
|
11877
|
+
* @param {Number} length String length
|
|
11878
|
+
* @param {Mode} mode Segment mode
|
|
11879
|
+
* @return {Number} Bit length
|
|
11880
|
+
*/
|
|
11881
|
+
function getSegmentBitsLength(length, mode) {
|
|
11882
|
+
switch (mode) {
|
|
11883
|
+
case Mode.NUMERIC: return NumericData.getBitsLength(length);
|
|
11884
|
+
case Mode.ALPHANUMERIC: return AlphanumericData.getBitsLength(length);
|
|
11885
|
+
case Mode.KANJI: return KanjiData.getBitsLength(length);
|
|
11886
|
+
case Mode.BYTE: return ByteData.getBitsLength(length);
|
|
11887
|
+
}
|
|
11888
|
+
}
|
|
11889
|
+
/**
|
|
11890
|
+
* Merges adjacent segments which have the same mode
|
|
11891
|
+
*
|
|
11892
|
+
* @param {Array} segs Array of object with segments data
|
|
11893
|
+
* @return {Array} Array of object with segments data
|
|
11894
|
+
*/
|
|
11895
|
+
function mergeSegments(segs) {
|
|
11896
|
+
return segs.reduce(function(acc, curr) {
|
|
11897
|
+
const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
|
|
11898
|
+
if (prevSeg && prevSeg.mode === curr.mode) {
|
|
11899
|
+
acc[acc.length - 1].data += curr.data;
|
|
11900
|
+
return acc;
|
|
11901
|
+
}
|
|
11902
|
+
acc.push(curr);
|
|
11903
|
+
return acc;
|
|
11904
|
+
}, []);
|
|
11905
|
+
}
|
|
11906
|
+
/**
|
|
11907
|
+
* Generates a list of all possible nodes combination which
|
|
11908
|
+
* will be used to build a segments graph.
|
|
11909
|
+
*
|
|
11910
|
+
* Nodes are divided by groups. Each group will contain a list of all the modes
|
|
11911
|
+
* in which is possible to encode the given text.
|
|
11912
|
+
*
|
|
11913
|
+
* For example the text '12345' can be encoded as Numeric, Alphanumeric or Byte.
|
|
11914
|
+
* The group for '12345' will contain then 3 objects, one for each
|
|
11915
|
+
* possible encoding mode.
|
|
11916
|
+
*
|
|
11917
|
+
* Each node represents a possible segment.
|
|
11918
|
+
*
|
|
11919
|
+
* @param {Array} segs Array of object with segments data
|
|
11920
|
+
* @return {Array} Array of object with segments data
|
|
11921
|
+
*/
|
|
11922
|
+
function buildNodes(segs) {
|
|
11923
|
+
const nodes = [];
|
|
11924
|
+
for (let i = 0; i < segs.length; i++) {
|
|
11925
|
+
const seg = segs[i];
|
|
11926
|
+
switch (seg.mode) {
|
|
11927
|
+
case Mode.NUMERIC:
|
|
11928
|
+
nodes.push([
|
|
11929
|
+
seg,
|
|
11930
|
+
{
|
|
11931
|
+
data: seg.data,
|
|
11932
|
+
mode: Mode.ALPHANUMERIC,
|
|
11933
|
+
length: seg.length
|
|
11934
|
+
},
|
|
11935
|
+
{
|
|
11936
|
+
data: seg.data,
|
|
11937
|
+
mode: Mode.BYTE,
|
|
11938
|
+
length: seg.length
|
|
11939
|
+
}
|
|
11940
|
+
]);
|
|
11941
|
+
break;
|
|
11942
|
+
case Mode.ALPHANUMERIC:
|
|
11943
|
+
nodes.push([seg, {
|
|
11944
|
+
data: seg.data,
|
|
11945
|
+
mode: Mode.BYTE,
|
|
11946
|
+
length: seg.length
|
|
11947
|
+
}]);
|
|
11948
|
+
break;
|
|
11949
|
+
case Mode.KANJI:
|
|
11950
|
+
nodes.push([seg, {
|
|
11951
|
+
data: seg.data,
|
|
11952
|
+
mode: Mode.BYTE,
|
|
11953
|
+
length: getStringByteLength(seg.data)
|
|
11954
|
+
}]);
|
|
11955
|
+
break;
|
|
11956
|
+
case Mode.BYTE: nodes.push([{
|
|
11957
|
+
data: seg.data,
|
|
11958
|
+
mode: Mode.BYTE,
|
|
11959
|
+
length: getStringByteLength(seg.data)
|
|
11960
|
+
}]);
|
|
11961
|
+
}
|
|
11962
|
+
}
|
|
11963
|
+
return nodes;
|
|
11964
|
+
}
|
|
11965
|
+
/**
|
|
11966
|
+
* Builds a graph from a list of nodes.
|
|
11967
|
+
* All segments in each node group will be connected with all the segments of
|
|
11968
|
+
* the next group and so on.
|
|
11969
|
+
*
|
|
11970
|
+
* At each connection will be assigned a weight depending on the
|
|
11971
|
+
* segment's byte length.
|
|
11972
|
+
*
|
|
11973
|
+
* @param {Array} nodes Array of object with segments data
|
|
11974
|
+
* @param {Number} version QR Code version
|
|
11975
|
+
* @return {Object} Graph of all possible segments
|
|
11976
|
+
*/
|
|
11977
|
+
function buildGraph(nodes, version) {
|
|
11978
|
+
const table = {};
|
|
11979
|
+
const graph = { start: {} };
|
|
11980
|
+
let prevNodeIds = ["start"];
|
|
11981
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
11982
|
+
const nodeGroup = nodes[i];
|
|
11983
|
+
const currentNodeIds = [];
|
|
11984
|
+
for (let j = 0; j < nodeGroup.length; j++) {
|
|
11985
|
+
const node = nodeGroup[j];
|
|
11986
|
+
const key = "" + i + j;
|
|
11987
|
+
currentNodeIds.push(key);
|
|
11988
|
+
table[key] = {
|
|
11989
|
+
node,
|
|
11990
|
+
lastCount: 0
|
|
11991
|
+
};
|
|
11992
|
+
graph[key] = {};
|
|
11993
|
+
for (let n = 0; n < prevNodeIds.length; n++) {
|
|
11994
|
+
const prevNodeId = prevNodeIds[n];
|
|
11995
|
+
if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
|
|
11996
|
+
graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
|
|
11997
|
+
table[prevNodeId].lastCount += node.length;
|
|
11998
|
+
} else {
|
|
11999
|
+
if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
|
|
12000
|
+
graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
|
|
12001
|
+
}
|
|
12002
|
+
}
|
|
12003
|
+
}
|
|
12004
|
+
prevNodeIds = currentNodeIds;
|
|
12005
|
+
}
|
|
12006
|
+
for (let n = 0; n < prevNodeIds.length; n++) graph[prevNodeIds[n]].end = 0;
|
|
12007
|
+
return {
|
|
12008
|
+
map: graph,
|
|
12009
|
+
table
|
|
12010
|
+
};
|
|
12011
|
+
}
|
|
12012
|
+
/**
|
|
12013
|
+
* Builds a segment from a specified data and mode.
|
|
12014
|
+
* If a mode is not specified, the more suitable will be used.
|
|
12015
|
+
*
|
|
12016
|
+
* @param {String} data Input data
|
|
12017
|
+
* @param {Mode | String} modesHint Data mode
|
|
12018
|
+
* @return {Segment} Segment
|
|
12019
|
+
*/
|
|
12020
|
+
function buildSingleSegment(data, modesHint) {
|
|
12021
|
+
let mode;
|
|
12022
|
+
const bestMode = Mode.getBestModeForData(data);
|
|
12023
|
+
mode = Mode.from(modesHint, bestMode);
|
|
12024
|
+
if (mode !== Mode.BYTE && mode.bit < bestMode.bit) throw new Error("\"" + data + "\" cannot be encoded with mode " + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
|
|
12025
|
+
if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) mode = Mode.BYTE;
|
|
12026
|
+
switch (mode) {
|
|
12027
|
+
case Mode.NUMERIC: return new NumericData(data);
|
|
12028
|
+
case Mode.ALPHANUMERIC: return new AlphanumericData(data);
|
|
12029
|
+
case Mode.KANJI: return new KanjiData(data);
|
|
12030
|
+
case Mode.BYTE: return new ByteData(data);
|
|
12031
|
+
}
|
|
12032
|
+
}
|
|
12033
|
+
/**
|
|
12034
|
+
* Builds a list of segments from an array.
|
|
12035
|
+
* Array can contain Strings or Objects with segment's info.
|
|
12036
|
+
*
|
|
12037
|
+
* For each item which is a string, will be generated a segment with the given
|
|
12038
|
+
* string and the more appropriate encoding mode.
|
|
12039
|
+
*
|
|
12040
|
+
* For each item which is an object, will be generated a segment with the given
|
|
12041
|
+
* data and mode.
|
|
12042
|
+
* Objects must contain at least the property "data".
|
|
12043
|
+
* If property "mode" is not present, the more suitable mode will be used.
|
|
12044
|
+
*
|
|
12045
|
+
* @param {Array} array Array of objects with segments data
|
|
12046
|
+
* @return {Array} Array of Segments
|
|
12047
|
+
*/
|
|
12048
|
+
exports.fromArray = function fromArray(array) {
|
|
12049
|
+
return array.reduce(function(acc, seg) {
|
|
12050
|
+
if (typeof seg === "string") acc.push(buildSingleSegment(seg, null));
|
|
12051
|
+
else if (seg.data) acc.push(buildSingleSegment(seg.data, seg.mode));
|
|
12052
|
+
return acc;
|
|
12053
|
+
}, []);
|
|
12054
|
+
};
|
|
12055
|
+
/**
|
|
12056
|
+
* Builds an optimized sequence of segments from a string,
|
|
12057
|
+
* which will produce the shortest possible bitstream.
|
|
12058
|
+
*
|
|
12059
|
+
* @param {String} data Input string
|
|
12060
|
+
* @param {Number} version QR Code version
|
|
12061
|
+
* @return {Array} Array of segments
|
|
12062
|
+
*/
|
|
12063
|
+
exports.fromString = function fromString(data, version) {
|
|
12064
|
+
const graph = buildGraph(buildNodes(getSegmentsFromString(data, Utils.isKanjiModeEnabled())), version);
|
|
12065
|
+
const path = dijkstra.find_path(graph.map, "start", "end");
|
|
12066
|
+
const optimizedSegs = [];
|
|
12067
|
+
for (let i = 1; i < path.length - 1; i++) optimizedSegs.push(graph.table[path[i]].node);
|
|
12068
|
+
return exports.fromArray(mergeSegments(optimizedSegs));
|
|
12069
|
+
};
|
|
12070
|
+
/**
|
|
12071
|
+
* Splits a string in various segments with the modes which
|
|
12072
|
+
* best represent their content.
|
|
12073
|
+
* The produced segments are far from being optimized.
|
|
12074
|
+
* The output of this function is only used to estimate a QR Code version
|
|
12075
|
+
* which may contain the data.
|
|
12076
|
+
*
|
|
12077
|
+
* @param {string} data Input string
|
|
12078
|
+
* @return {Array} Array of segments
|
|
12079
|
+
*/
|
|
12080
|
+
exports.rawSplit = function rawSplit(data) {
|
|
12081
|
+
return exports.fromArray(getSegmentsFromString(data, Utils.isKanjiModeEnabled()));
|
|
12082
|
+
};
|
|
12083
|
+
}));
|
|
12084
|
+
//#endregion
|
|
12085
|
+
//#region src/client-remote-control.jsx
|
|
12086
|
+
var import_qrcode = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
12087
|
+
const Utils = require_utils();
|
|
12088
|
+
const ECLevel = require_error_correction_level();
|
|
12089
|
+
const BitBuffer = require_bit_buffer();
|
|
12090
|
+
const BitMatrix = require_bit_matrix();
|
|
12091
|
+
const AlignmentPattern = require_alignment_pattern();
|
|
12092
|
+
const FinderPattern = require_finder_pattern();
|
|
12093
|
+
const MaskPattern = require_mask_pattern();
|
|
12094
|
+
const ECCode = require_error_correction_code();
|
|
12095
|
+
const ReedSolomonEncoder = require_reed_solomon_encoder();
|
|
12096
|
+
const Version = require_version();
|
|
12097
|
+
const FormatInfo = require_format_info();
|
|
12098
|
+
const Mode = require_mode();
|
|
12099
|
+
const Segments = require_segments();
|
|
12100
|
+
/**
|
|
12101
|
+
* QRCode for JavaScript
|
|
12102
|
+
*
|
|
12103
|
+
* modified by Ryan Day for nodejs support
|
|
12104
|
+
* Copyright (c) 2011 Ryan Day
|
|
12105
|
+
*
|
|
12106
|
+
* Licensed under the MIT license:
|
|
12107
|
+
* http://www.opensource.org/licenses/mit-license.php
|
|
12108
|
+
*
|
|
12109
|
+
//---------------------------------------------------------------------
|
|
12110
|
+
// QRCode for JavaScript
|
|
12111
|
+
//
|
|
12112
|
+
// Copyright (c) 2009 Kazuhiko Arase
|
|
12113
|
+
//
|
|
12114
|
+
// URL: http://www.d-project.com/
|
|
12115
|
+
//
|
|
12116
|
+
// Licensed under the MIT license:
|
|
12117
|
+
// http://www.opensource.org/licenses/mit-license.php
|
|
12118
|
+
//
|
|
12119
|
+
// The word "QR Code" is registered trademark of
|
|
12120
|
+
// DENSO WAVE INCORPORATED
|
|
12121
|
+
// http://www.denso-wave.com/qrcode/faqpatent-e.html
|
|
12122
|
+
//
|
|
12123
|
+
//---------------------------------------------------------------------
|
|
12124
|
+
*/
|
|
12125
|
+
/**
|
|
12126
|
+
* Add finder patterns bits to matrix
|
|
12127
|
+
*
|
|
12128
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12129
|
+
* @param {Number} version QR Code version
|
|
12130
|
+
*/
|
|
12131
|
+
function setupFinderPattern(matrix, version) {
|
|
12132
|
+
const size = matrix.size;
|
|
12133
|
+
const pos = FinderPattern.getPositions(version);
|
|
12134
|
+
for (let i = 0; i < pos.length; i++) {
|
|
12135
|
+
const row = pos[i][0];
|
|
12136
|
+
const col = pos[i][1];
|
|
12137
|
+
for (let r = -1; r <= 7; r++) {
|
|
12138
|
+
if (row + r <= -1 || size <= row + r) continue;
|
|
12139
|
+
for (let c = -1; c <= 7; c++) {
|
|
12140
|
+
if (col + c <= -1 || size <= col + c) continue;
|
|
12141
|
+
if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) matrix.set(row + r, col + c, true, true);
|
|
12142
|
+
else matrix.set(row + r, col + c, false, true);
|
|
12143
|
+
}
|
|
12144
|
+
}
|
|
12145
|
+
}
|
|
12146
|
+
}
|
|
12147
|
+
/**
|
|
12148
|
+
* Add timing pattern bits to matrix
|
|
12149
|
+
*
|
|
12150
|
+
* Note: this function must be called before {@link setupAlignmentPattern}
|
|
12151
|
+
*
|
|
12152
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12153
|
+
*/
|
|
12154
|
+
function setupTimingPattern(matrix) {
|
|
12155
|
+
const size = matrix.size;
|
|
12156
|
+
for (let r = 8; r < size - 8; r++) {
|
|
12157
|
+
const value = r % 2 === 0;
|
|
12158
|
+
matrix.set(r, 6, value, true);
|
|
12159
|
+
matrix.set(6, r, value, true);
|
|
12160
|
+
}
|
|
12161
|
+
}
|
|
12162
|
+
/**
|
|
12163
|
+
* Add alignment patterns bits to matrix
|
|
12164
|
+
*
|
|
12165
|
+
* Note: this function must be called after {@link setupTimingPattern}
|
|
12166
|
+
*
|
|
12167
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12168
|
+
* @param {Number} version QR Code version
|
|
12169
|
+
*/
|
|
12170
|
+
function setupAlignmentPattern(matrix, version) {
|
|
12171
|
+
const pos = AlignmentPattern.getPositions(version);
|
|
12172
|
+
for (let i = 0; i < pos.length; i++) {
|
|
12173
|
+
const row = pos[i][0];
|
|
12174
|
+
const col = pos[i][1];
|
|
12175
|
+
for (let r = -2; r <= 2; r++) for (let c = -2; c <= 2; c++) if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) matrix.set(row + r, col + c, true, true);
|
|
12176
|
+
else matrix.set(row + r, col + c, false, true);
|
|
12177
|
+
}
|
|
12178
|
+
}
|
|
12179
|
+
/**
|
|
12180
|
+
* Add version info bits to matrix
|
|
12181
|
+
*
|
|
12182
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12183
|
+
* @param {Number} version QR Code version
|
|
12184
|
+
*/
|
|
12185
|
+
function setupVersionInfo(matrix, version) {
|
|
12186
|
+
const size = matrix.size;
|
|
12187
|
+
const bits = Version.getEncodedBits(version);
|
|
12188
|
+
let row, col, mod;
|
|
12189
|
+
for (let i = 0; i < 18; i++) {
|
|
12190
|
+
row = Math.floor(i / 3);
|
|
12191
|
+
col = i % 3 + size - 8 - 3;
|
|
12192
|
+
mod = (bits >> i & 1) === 1;
|
|
12193
|
+
matrix.set(row, col, mod, true);
|
|
12194
|
+
matrix.set(col, row, mod, true);
|
|
12195
|
+
}
|
|
12196
|
+
}
|
|
12197
|
+
/**
|
|
12198
|
+
* Add format info bits to matrix
|
|
12199
|
+
*
|
|
12200
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12201
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
12202
|
+
* @param {Number} maskPattern Mask pattern reference value
|
|
12203
|
+
*/
|
|
12204
|
+
function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
|
|
12205
|
+
const size = matrix.size;
|
|
12206
|
+
const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
|
|
12207
|
+
let i, mod;
|
|
12208
|
+
for (i = 0; i < 15; i++) {
|
|
12209
|
+
mod = (bits >> i & 1) === 1;
|
|
12210
|
+
if (i < 6) matrix.set(i, 8, mod, true);
|
|
12211
|
+
else if (i < 8) matrix.set(i + 1, 8, mod, true);
|
|
12212
|
+
else matrix.set(size - 15 + i, 8, mod, true);
|
|
12213
|
+
if (i < 8) matrix.set(8, size - i - 1, mod, true);
|
|
12214
|
+
else if (i < 9) matrix.set(8, 15 - i - 1 + 1, mod, true);
|
|
12215
|
+
else matrix.set(8, 15 - i - 1, mod, true);
|
|
12216
|
+
}
|
|
12217
|
+
matrix.set(size - 8, 8, 1, true);
|
|
12218
|
+
}
|
|
12219
|
+
/**
|
|
12220
|
+
* Add encoded data bits to matrix
|
|
12221
|
+
*
|
|
12222
|
+
* @param {BitMatrix} matrix Modules matrix
|
|
12223
|
+
* @param {Uint8Array} data Data codewords
|
|
12224
|
+
*/
|
|
12225
|
+
function setupData(matrix, data) {
|
|
12226
|
+
const size = matrix.size;
|
|
12227
|
+
let inc = -1;
|
|
12228
|
+
let row = size - 1;
|
|
12229
|
+
let bitIndex = 7;
|
|
12230
|
+
let byteIndex = 0;
|
|
12231
|
+
for (let col = size - 1; col > 0; col -= 2) {
|
|
12232
|
+
if (col === 6) col--;
|
|
12233
|
+
while (true) {
|
|
12234
|
+
for (let c = 0; c < 2; c++) if (!matrix.isReserved(row, col - c)) {
|
|
12235
|
+
let dark = false;
|
|
12236
|
+
if (byteIndex < data.length) dark = (data[byteIndex] >>> bitIndex & 1) === 1;
|
|
12237
|
+
matrix.set(row, col - c, dark);
|
|
12238
|
+
bitIndex--;
|
|
12239
|
+
if (bitIndex === -1) {
|
|
12240
|
+
byteIndex++;
|
|
12241
|
+
bitIndex = 7;
|
|
12242
|
+
}
|
|
12243
|
+
}
|
|
12244
|
+
row += inc;
|
|
12245
|
+
if (row < 0 || size <= row) {
|
|
12246
|
+
row -= inc;
|
|
12247
|
+
inc = -inc;
|
|
12248
|
+
break;
|
|
12249
|
+
}
|
|
12250
|
+
}
|
|
12251
|
+
}
|
|
12252
|
+
}
|
|
12253
|
+
/**
|
|
12254
|
+
* Create encoded codewords from data input
|
|
12255
|
+
*
|
|
12256
|
+
* @param {Number} version QR Code version
|
|
12257
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
12258
|
+
* @param {ByteData} data Data input
|
|
12259
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
12260
|
+
*/
|
|
12261
|
+
function createData(version, errorCorrectionLevel, segments) {
|
|
12262
|
+
const buffer = new BitBuffer();
|
|
12263
|
+
segments.forEach(function(data) {
|
|
12264
|
+
buffer.put(data.mode.bit, 4);
|
|
12265
|
+
buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
|
|
12266
|
+
data.write(buffer);
|
|
12267
|
+
});
|
|
12268
|
+
const dataTotalCodewordsBits = (Utils.getSymbolTotalCodewords(version) - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel)) * 8;
|
|
12269
|
+
if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) buffer.put(0, 4);
|
|
12270
|
+
while (buffer.getLengthInBits() % 8 !== 0) buffer.putBit(0);
|
|
12271
|
+
const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
|
|
12272
|
+
for (let i = 0; i < remainingByte; i++) buffer.put(i % 2 ? 17 : 236, 8);
|
|
12273
|
+
return createCodewords(buffer, version, errorCorrectionLevel);
|
|
12274
|
+
}
|
|
12275
|
+
/**
|
|
12276
|
+
* Encode input data with Reed-Solomon and return codewords with
|
|
12277
|
+
* relative error correction bits
|
|
12278
|
+
*
|
|
12279
|
+
* @param {BitBuffer} bitBuffer Data to encode
|
|
12280
|
+
* @param {Number} version QR Code version
|
|
12281
|
+
* @param {ErrorCorrectionLevel} errorCorrectionLevel Error correction level
|
|
12282
|
+
* @return {Uint8Array} Buffer containing encoded codewords
|
|
12283
|
+
*/
|
|
12284
|
+
function createCodewords(bitBuffer, version, errorCorrectionLevel) {
|
|
12285
|
+
const totalCodewords = Utils.getSymbolTotalCodewords(version);
|
|
12286
|
+
const dataTotalCodewords = totalCodewords - ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
|
|
12287
|
+
const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
|
|
12288
|
+
const blocksInGroup1 = ecTotalBlocks - totalCodewords % ecTotalBlocks;
|
|
12289
|
+
const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
|
|
12290
|
+
const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
|
|
12291
|
+
const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
|
|
12292
|
+
const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
|
|
12293
|
+
const rs = new ReedSolomonEncoder(ecCount);
|
|
12294
|
+
let offset = 0;
|
|
12295
|
+
const dcData = new Array(ecTotalBlocks);
|
|
12296
|
+
const ecData = new Array(ecTotalBlocks);
|
|
12297
|
+
let maxDataSize = 0;
|
|
12298
|
+
const buffer = new Uint8Array(bitBuffer.buffer);
|
|
12299
|
+
for (let b = 0; b < ecTotalBlocks; b++) {
|
|
12300
|
+
const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
|
|
12301
|
+
dcData[b] = buffer.slice(offset, offset + dataSize);
|
|
12302
|
+
ecData[b] = rs.encode(dcData[b]);
|
|
12303
|
+
offset += dataSize;
|
|
12304
|
+
maxDataSize = Math.max(maxDataSize, dataSize);
|
|
12305
|
+
}
|
|
12306
|
+
const data = new Uint8Array(totalCodewords);
|
|
12307
|
+
let index = 0;
|
|
12308
|
+
let i, r;
|
|
12309
|
+
for (i = 0; i < maxDataSize; i++) for (r = 0; r < ecTotalBlocks; r++) if (i < dcData[r].length) data[index++] = dcData[r][i];
|
|
12310
|
+
for (i = 0; i < ecCount; i++) for (r = 0; r < ecTotalBlocks; r++) data[index++] = ecData[r][i];
|
|
12311
|
+
return data;
|
|
12312
|
+
}
|
|
12313
|
+
/**
|
|
12314
|
+
* Build QR Code symbol
|
|
12315
|
+
*
|
|
12316
|
+
* @param {String} data Input string
|
|
12317
|
+
* @param {Number} version QR Code version
|
|
12318
|
+
* @param {ErrorCorretionLevel} errorCorrectionLevel Error level
|
|
12319
|
+
* @param {MaskPattern} maskPattern Mask pattern
|
|
12320
|
+
* @return {Object} Object containing symbol data
|
|
12321
|
+
*/
|
|
12322
|
+
function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
|
|
12323
|
+
let segments;
|
|
12324
|
+
if (Array.isArray(data)) segments = Segments.fromArray(data);
|
|
12325
|
+
else if (typeof data === "string") {
|
|
12326
|
+
let estimatedVersion = version;
|
|
12327
|
+
if (!estimatedVersion) {
|
|
12328
|
+
const rawSegments = Segments.rawSplit(data);
|
|
12329
|
+
estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
|
|
12330
|
+
}
|
|
12331
|
+
segments = Segments.fromString(data, estimatedVersion || 40);
|
|
12332
|
+
} else throw new Error("Invalid data");
|
|
12333
|
+
const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
|
|
12334
|
+
if (!bestVersion) throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
12335
|
+
if (!version) version = bestVersion;
|
|
12336
|
+
else if (version < bestVersion) throw new Error("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n");
|
|
12337
|
+
const dataBits = createData(version, errorCorrectionLevel, segments);
|
|
12338
|
+
const moduleCount = Utils.getSymbolSize(version);
|
|
12339
|
+
const modules = new BitMatrix(moduleCount);
|
|
12340
|
+
setupFinderPattern(modules, version);
|
|
12341
|
+
setupTimingPattern(modules);
|
|
12342
|
+
setupAlignmentPattern(modules, version);
|
|
12343
|
+
setupFormatInfo(modules, errorCorrectionLevel, 0);
|
|
12344
|
+
if (version >= 7) setupVersionInfo(modules, version);
|
|
12345
|
+
setupData(modules, dataBits);
|
|
12346
|
+
if (isNaN(maskPattern)) maskPattern = MaskPattern.getBestMask(modules, setupFormatInfo.bind(null, modules, errorCorrectionLevel));
|
|
12347
|
+
MaskPattern.applyMask(maskPattern, modules);
|
|
12348
|
+
setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
|
|
12349
|
+
return {
|
|
12350
|
+
modules,
|
|
12351
|
+
version,
|
|
12352
|
+
errorCorrectionLevel,
|
|
12353
|
+
maskPattern,
|
|
12354
|
+
segments
|
|
12355
|
+
};
|
|
12356
|
+
}
|
|
12357
|
+
/**
|
|
12358
|
+
* QR Code
|
|
12359
|
+
*
|
|
12360
|
+
* @param {String | Array} data Input data
|
|
12361
|
+
* @param {Object} options Optional configurations
|
|
12362
|
+
* @param {Number} options.version QR Code version
|
|
12363
|
+
* @param {String} options.errorCorrectionLevel Error correction level
|
|
12364
|
+
* @param {Function} options.toSJISFunc Helper func to convert utf8 to sjis
|
|
12365
|
+
*/
|
|
12366
|
+
exports.create = function create(data, options) {
|
|
12367
|
+
if (typeof data === "undefined" || data === "") throw new Error("No input text");
|
|
12368
|
+
let errorCorrectionLevel = ECLevel.M;
|
|
12369
|
+
let version;
|
|
12370
|
+
let mask;
|
|
12371
|
+
if (typeof options !== "undefined") {
|
|
12372
|
+
errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
|
|
12373
|
+
version = Version.from(options.version);
|
|
12374
|
+
mask = MaskPattern.from(options.maskPattern);
|
|
12375
|
+
if (options.toSJISFunc) Utils.setToSJISFunction(options.toSJISFunc);
|
|
12376
|
+
}
|
|
12377
|
+
return createSymbol(data, version, errorCorrectionLevel, mask);
|
|
12378
|
+
};
|
|
12379
|
+
})))();
|
|
12380
|
+
const PAIR_URL = "https://chatgpt.com/codex/pair?pairing_code=";
|
|
12381
|
+
const STATUS_KEYS = {
|
|
12382
|
+
connected: "remoteConnected",
|
|
12383
|
+
connecting: "remoteConnecting",
|
|
12384
|
+
error: "remoteError",
|
|
12385
|
+
stopped: "remoteStopped"
|
|
12386
|
+
};
|
|
12387
|
+
const MARGIN = 2;
|
|
12388
|
+
function Qr({ value, label }) {
|
|
12389
|
+
let modules;
|
|
12390
|
+
try {
|
|
12391
|
+
modules = (0, import_qrcode.create)(value, { errorCorrectionLevel: "M" }).modules;
|
|
12392
|
+
} catch {
|
|
12393
|
+
return null;
|
|
12394
|
+
}
|
|
12395
|
+
const size = modules.size;
|
|
12396
|
+
let path = "";
|
|
12397
|
+
for (let row = 0; row < size; row++) for (let column = 0; column < size; column++) if (modules.get(row, column)) path += `M${column + MARGIN} ${row + MARGIN}h1v1h-1z`;
|
|
12398
|
+
const span = size + MARGIN * 2;
|
|
12399
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12400
|
+
className: "codexSubscriptionRemoteQr",
|
|
12401
|
+
role: "img",
|
|
12402
|
+
"aria-label": label,
|
|
12403
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("svg", {
|
|
12404
|
+
viewBox: `0 0 ${span} ${span}`,
|
|
12405
|
+
shapeRendering: "crispEdges",
|
|
12406
|
+
"aria-hidden": "true",
|
|
12407
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
|
|
12408
|
+
width: span,
|
|
12409
|
+
height: span,
|
|
12410
|
+
fill: "#fff"
|
|
12411
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
12412
|
+
d: path,
|
|
12413
|
+
fill: "#000"
|
|
12414
|
+
})]
|
|
12415
|
+
})
|
|
12416
|
+
});
|
|
12417
|
+
}
|
|
12418
|
+
/** Beta: show this DSH in the ChatGPT mobile app's Codex list (Remote Control). */
|
|
12419
|
+
function RemoteControlCard({ rpc, preference, snapshot, t }) {
|
|
12420
|
+
const [state, setState] = (0, react.useState)();
|
|
12421
|
+
const [pairing, setPairing] = (0, react.useState)();
|
|
12422
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
12423
|
+
const [failed, setFailed] = (0, react.useState)(false);
|
|
12424
|
+
const [now, setNow] = (0, react.useState)(Date.now());
|
|
12425
|
+
const alive = (0, react.useRef)(false);
|
|
12426
|
+
const on = snapshot.remoteControl === "on";
|
|
12427
|
+
const read = async () => {
|
|
12428
|
+
try {
|
|
12429
|
+
const result = await rpc.call(CHANNEL, "remote/status", {});
|
|
12430
|
+
if (alive.current && result.ok) setState(result.value);
|
|
12431
|
+
} catch {}
|
|
12432
|
+
};
|
|
12433
|
+
(0, react.useEffect)(() => {
|
|
12434
|
+
alive.current = true;
|
|
12435
|
+
return () => {
|
|
12436
|
+
alive.current = false;
|
|
12437
|
+
};
|
|
12438
|
+
}, []);
|
|
12439
|
+
(0, react.useEffect)(() => {
|
|
12440
|
+
if (!on) {
|
|
12441
|
+
setState(void 0);
|
|
12442
|
+
setPairing(void 0);
|
|
12443
|
+
return;
|
|
12444
|
+
}
|
|
12445
|
+
let stopped = false, timer;
|
|
12446
|
+
const poll = async () => {
|
|
12447
|
+
await read();
|
|
12448
|
+
if (!stopped) timer = setTimeout(poll, 4e3);
|
|
12449
|
+
};
|
|
12450
|
+
poll();
|
|
12451
|
+
return () => {
|
|
12452
|
+
stopped = true;
|
|
12453
|
+
clearTimeout(timer);
|
|
12454
|
+
};
|
|
12455
|
+
}, [on, rpc]);
|
|
12456
|
+
(0, react.useEffect)(() => {
|
|
12457
|
+
if (!pairing) return void 0;
|
|
12458
|
+
const timer = setInterval(() => setNow(Date.now()), 5e3);
|
|
12459
|
+
return () => clearInterval(timer);
|
|
12460
|
+
}, [pairing]);
|
|
12461
|
+
const pair = async () => {
|
|
12462
|
+
if (busy) return;
|
|
12463
|
+
setBusy(true);
|
|
12464
|
+
setFailed(false);
|
|
12465
|
+
try {
|
|
12466
|
+
const result = await rpc.call(CHANNEL, "remote/pair", {});
|
|
12467
|
+
if (!alive.current) return;
|
|
12468
|
+
if (!result.ok) {
|
|
12469
|
+
setFailed(true);
|
|
12470
|
+
return;
|
|
12471
|
+
}
|
|
12472
|
+
setPairing(result.value);
|
|
12473
|
+
setNow(Date.now());
|
|
12474
|
+
read();
|
|
12475
|
+
} catch {
|
|
12476
|
+
if (alive.current) setFailed(true);
|
|
12477
|
+
} finally {
|
|
12478
|
+
if (alive.current) setBusy(false);
|
|
12479
|
+
}
|
|
12480
|
+
};
|
|
12481
|
+
const expired = pairing && pairing.expiresAt <= now;
|
|
12482
|
+
const minutes = pairing ? Math.max(0, Math.ceil((pairing.expiresAt - now) / 6e4)) : 0;
|
|
12483
|
+
const status = state?.status ?? "connecting";
|
|
12484
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
12485
|
+
className: "codexSubscriptionCard codexSubscriptionPreferencesCard",
|
|
12486
|
+
"aria-label": t("remoteTitle"),
|
|
12487
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12488
|
+
className: "codexSubscriptionPreference",
|
|
12489
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12490
|
+
className: "codexSubscriptionPreferenceCopy",
|
|
12491
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
12492
|
+
className: "codexSubscriptionPreferenceLabel",
|
|
12493
|
+
children: [
|
|
12494
|
+
t("remoteTitle"),
|
|
12495
|
+
" ",
|
|
12496
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("small", { children: "Beta" })
|
|
12497
|
+
]
|
|
12498
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
12499
|
+
className: "codexSubscriptionPreferenceHint",
|
|
12500
|
+
children: t("remoteHint")
|
|
12501
|
+
})]
|
|
12502
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
12503
|
+
className: "codexSubscriptionQuotaModes",
|
|
12504
|
+
role: "radiogroup",
|
|
12505
|
+
"aria-label": t("remoteTitle"),
|
|
12506
|
+
"aria-busy": snapshot.saving || void 0,
|
|
12507
|
+
children: ["off", "on"].map((value) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
12508
|
+
className: "codexSubscriptionQuotaMode",
|
|
12509
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
12510
|
+
type: "radio",
|
|
12511
|
+
name: "codex-remote-control",
|
|
12512
|
+
checked: snapshot.remoteControl === value,
|
|
12513
|
+
disabled: !snapshot.writable,
|
|
12514
|
+
onChange: () => {
|
|
12515
|
+
preference.set({ remoteControl: value });
|
|
12516
|
+
}
|
|
12517
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t(`remote_${value}`) })]
|
|
12518
|
+
}, value))
|
|
12519
|
+
})]
|
|
12520
|
+
}), on ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
12521
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "codexSubscriptionDivider" }),
|
|
12522
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12523
|
+
className: "codexSubscriptionPreference",
|
|
12524
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
12525
|
+
role: "status",
|
|
12526
|
+
children: [
|
|
12527
|
+
t(STATUS_KEYS[status] ?? "remoteConnecting"),
|
|
12528
|
+
status === "error" && state?.lastError ? ` · ${state.lastError}` : "",
|
|
12529
|
+
state?.phones > 0 ? ` · ${t("remotePhones").replace("{count}", String(state.phones))}` : ""
|
|
12530
|
+
]
|
|
12531
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
12532
|
+
type: "button",
|
|
12533
|
+
variant: "outline",
|
|
12534
|
+
disabled: busy || status === "stopped",
|
|
12535
|
+
onClick: () => {
|
|
12536
|
+
pair();
|
|
12537
|
+
},
|
|
12538
|
+
children: t(pairing ? "remotePairAgain" : "remotePair")
|
|
12539
|
+
})]
|
|
12540
|
+
}),
|
|
12541
|
+
failed ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12542
|
+
role: "alert",
|
|
12543
|
+
className: "codexSubscriptionHelp",
|
|
12544
|
+
children: t("remotePairFailed")
|
|
12545
|
+
}) : null,
|
|
12546
|
+
pairing && !expired ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
12547
|
+
className: "codexSubscriptionRemotePair",
|
|
12548
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Qr, {
|
|
12549
|
+
value: `${PAIR_URL}${pairing.pairingCode}`,
|
|
12550
|
+
label: t("remoteQrLabel")
|
|
12551
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [
|
|
12552
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12553
|
+
className: "codexSubscriptionHelp",
|
|
12554
|
+
children: t("remotePairSteps")
|
|
12555
|
+
}),
|
|
12556
|
+
pairing.manualCode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12557
|
+
className: "codexSubscriptionRemoteCode",
|
|
12558
|
+
"aria-label": t("remoteManualCode"),
|
|
12559
|
+
children: pairing.manualCode
|
|
12560
|
+
}) : null,
|
|
12561
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12562
|
+
className: "codexSubscriptionHelp",
|
|
12563
|
+
children: t("remoteExpires").replace("{minutes}", String(minutes))
|
|
12564
|
+
})
|
|
12565
|
+
] })]
|
|
12566
|
+
}) : pairing ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12567
|
+
className: "codexSubscriptionHelp",
|
|
12568
|
+
children: t("remoteExpired")
|
|
12569
|
+
}) : null,
|
|
12570
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
12571
|
+
className: "codexSubscriptionHelp",
|
|
12572
|
+
children: t("remoteLimits")
|
|
12573
|
+
})
|
|
12574
|
+
] }) : null]
|
|
12575
|
+
});
|
|
12576
|
+
}
|
|
12577
|
+
//#endregion
|
|
10222
12578
|
//#region src/context-draft-state.js
|
|
10223
12579
|
const hasOwn = (value, key) => Object.prototype.hasOwnProperty.call(value ?? {}, key);
|
|
10224
12580
|
/**
|
|
@@ -10801,6 +13157,12 @@ window.__ModuleLoader__.load({
|
|
|
10801
13157
|
})]
|
|
10802
13158
|
})
|
|
10803
13159
|
}),
|
|
13160
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RemoteControlCard, {
|
|
13161
|
+
rpc,
|
|
13162
|
+
preference,
|
|
13163
|
+
snapshot,
|
|
13164
|
+
t
|
|
13165
|
+
}),
|
|
10804
13166
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
|
|
10805
13167
|
className: "codexSubscriptionCard codexSubscriptionPreferencesCard",
|
|
10806
13168
|
"aria-label": t("compactionTitle"),
|
|
@@ -12557,10 +14919,7 @@ window.__ModuleLoader__.load({
|
|
|
12557
14919
|
return () => tag.remove();
|
|
12558
14920
|
}, "codex-subscription: style");
|
|
12559
14921
|
const rpc = createSubscriptionRpcClient(ctx.get("connection").rpc);
|
|
12560
|
-
const preference = createPreferenceController(
|
|
12561
|
-
getSnapshot: () => ({ status: "unavailable" }),
|
|
12562
|
-
subscribe: () => () => {}
|
|
12563
|
-
}, rpc);
|
|
14922
|
+
const preference = createPreferenceController(rpc);
|
|
12564
14923
|
const defaultModel = createDefaultModelController(rpc);
|
|
12565
14924
|
ctx.effect(() => {
|
|
12566
14925
|
let previous = JSON.stringify(preference.getSnapshot(), (key, value) => key.startsWith("image") || key === "" ? value : void 0);
|
|
@@ -12708,7 +15067,6 @@ window.__ModuleLoader__.load({
|
|
|
12708
15067
|
const tool = Array.isArray(extraFiles);
|
|
12709
15068
|
if (!preference.getSnapshot().imageEditing) throw new Error("Image editing is disabled");
|
|
12710
15069
|
return withComposerSession(sessions, sessionId, async (actx) => {
|
|
12711
|
-
if (conversation.input?.for === void 0) throw new Error("This DSH version does not provide the image composer bridge");
|
|
12712
15070
|
const response = await fetch(src, { signal: lifetime.signal });
|
|
12713
15071
|
if (!response.ok) throw new Error("Could not read generated image");
|
|
12714
15072
|
const blob = await response.blob();
|