@cloudflare/vite-plugin 1.37.3 → 1.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -3,28 +3,28 @@ import assert from "node:assert";
|
|
|
3
3
|
import { CoreHeaders, CorePaths, Log, LogLevel, Miniflare, Request as Request$1, Response as Response$1, buildPublicUrl, coupleWebSocket, getDefaultDevRegistryPath, getNodeCompat, getWorkerRegistry, kUnsafeEphemeralUniqueKey, parseModuleFallbackRequest } from "miniflare";
|
|
4
4
|
import * as wrangler from "wrangler";
|
|
5
5
|
import * as nodePath from "node:path";
|
|
6
|
-
import
|
|
6
|
+
import path3, { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
7
7
|
import * as util$1 from "node:util";
|
|
8
8
|
import { format, inspect, promisify } from "node:util";
|
|
9
9
|
import * as vite from "vite";
|
|
10
10
|
import { normalizePath, version } from "vite";
|
|
11
11
|
import { createHash, randomUUID } from "node:crypto";
|
|
12
|
-
import * as fs$
|
|
13
|
-
import
|
|
12
|
+
import * as fs$1 from "node:fs";
|
|
13
|
+
import fs2, { accessSync, chmodSync, constants, existsSync, mkdirSync, readFileSync, realpathSync, renameSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
14
14
|
import os, { arch } from "node:os";
|
|
15
15
|
import childProcess, { execFile, execFileSync, spawn } from "node:child_process";
|
|
16
16
|
import net from "node:net";
|
|
17
17
|
import { Buffer as Buffer$1 } from "node:buffer";
|
|
18
18
|
import { URL as URL$1, fileURLToPath, pathToFileURL } from "node:url";
|
|
19
19
|
import * as fsp from "node:fs/promises";
|
|
20
|
-
import fs
|
|
20
|
+
import fs, { constants as constants$1 } from "node:fs/promises";
|
|
21
21
|
import { getCloudflarePreset, nonPrefixedNodeModules } from "@cloudflare/unenv-preset";
|
|
22
22
|
import process$1 from "node:process";
|
|
23
23
|
import v8 from "node:v8";
|
|
24
24
|
import { defineEnv } from "unenv";
|
|
25
25
|
import * as nativeFs$1 from "fs";
|
|
26
26
|
import nativeFs from "fs";
|
|
27
|
-
import path
|
|
27
|
+
import path, { basename, dirname as dirname$1, normalize, posix, relative as relative$1, resolve as resolve$1, sep } from "path";
|
|
28
28
|
import { fileURLToPath as fileURLToPath$1 } from "url";
|
|
29
29
|
import { createRequire as createRequire$1 } from "module";
|
|
30
30
|
import { WebSocketServer } from "ws";
|
|
@@ -36,8 +36,8 @@ var __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor;
|
|
|
36
36
|
var __getOwnPropNames$1 = Object.getOwnPropertyNames;
|
|
37
37
|
var __getProtoOf$1 = Object.getPrototypeOf;
|
|
38
38
|
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
39
|
-
var __commonJS$1 = (cb, mod) => function() {
|
|
40
|
-
return mod || (0, cb[__getOwnPropNames$1(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
39
|
+
var __commonJS$1 = (cb, mod$1) => function() {
|
|
40
|
+
return mod$1 || (0, cb[__getOwnPropNames$1(cb)[0]])((mod$1 = { exports: {} }).exports, mod$1), mod$1.exports;
|
|
41
41
|
};
|
|
42
42
|
var __copyProps$1 = (to, from, except, desc) => {
|
|
43
43
|
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames$1(from), i$1 = 0, n$1 = keys.length, key; i$1 < n$1; i$1++) {
|
|
@@ -49,10 +49,10 @@ var __copyProps$1 = (to, from, except, desc) => {
|
|
|
49
49
|
}
|
|
50
50
|
return to;
|
|
51
51
|
};
|
|
52
|
-
var __toESM$1 = (mod, isNodeMode, target$1) => (target$1 = mod != null ? __create$1(__getProtoOf$1(mod)) : {}, __copyProps$1(isNodeMode || !mod || !mod.__esModule ? __defProp$1(target$1, "default", {
|
|
53
|
-
value: mod,
|
|
52
|
+
var __toESM$1 = (mod$1, isNodeMode, target$1) => (target$1 = mod$1 != null ? __create$1(__getProtoOf$1(mod$1)) : {}, __copyProps$1(isNodeMode || !mod$1 || !mod$1.__esModule ? __defProp$1(target$1, "default", {
|
|
53
|
+
value: mod$1,
|
|
54
54
|
enumerable: true
|
|
55
|
-
}) : target$1, mod));
|
|
55
|
+
}) : target$1, mod$1));
|
|
56
56
|
var __require$2 = /* @__PURE__ */ createRequire(import.meta.url);
|
|
57
57
|
|
|
58
58
|
//#endregion
|
|
@@ -1503,7 +1503,7 @@ async function assertWranglerVersion() {
|
|
|
1503
1503
|
* The default compatibility date to use when the user omits one.
|
|
1504
1504
|
* This value is injected at build time and remains fixed for each release.
|
|
1505
1505
|
*/
|
|
1506
|
-
const DEFAULT_COMPAT_DATE = "2026-05-
|
|
1506
|
+
const DEFAULT_COMPAT_DATE = "2026-05-26";
|
|
1507
1507
|
|
|
1508
1508
|
//#endregion
|
|
1509
1509
|
//#region ../../node_modules/.pnpm/@remix-run+node-fetch-server@0.8.0/node_modules/@remix-run/node-fetch-server/dist/node-fetch-server.js
|
|
@@ -1582,8 +1582,6 @@ const kRequestType = Symbol("kRequestType");
|
|
|
1582
1582
|
//#endregion
|
|
1583
1583
|
//#region ../workers-utils/dist/chunk-OZQVB3L3.mjs
|
|
1584
1584
|
var INHERIT_SYMBOL = Symbol.for("inherit_binding");
|
|
1585
|
-
var SERVICE_TAG_PREFIX = "cf:service=";
|
|
1586
|
-
var ENVIRONMENT_TAG_PREFIX = "cf:environment=";
|
|
1587
1585
|
var PATH_TO_DEPLOY_CONFIG = ".wrangler/deploy/config.json";
|
|
1588
1586
|
|
|
1589
1587
|
//#endregion
|
|
@@ -1602,8 +1600,8 @@ var __require$1 = /* @__PURE__ */ ((x) => typeof __require$2 !== "undefined" ? _
|
|
|
1602
1600
|
if (typeof __require$2 !== "undefined") return __require$2.apply(this, arguments);
|
|
1603
1601
|
throw Error("Dynamic require of \"" + x + "\" is not supported");
|
|
1604
1602
|
});
|
|
1605
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
1606
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
1603
|
+
var __commonJS = (cb, mod$1) => function __require2() {
|
|
1604
|
+
return mod$1 || (0, cb[__getOwnPropNames(cb)[0]])((mod$1 = { exports: {} }).exports, mod$1), mod$1.exports;
|
|
1607
1605
|
};
|
|
1608
1606
|
var __export = (target$1, all$1) => {
|
|
1609
1607
|
for (var name in all$1) __defProp(target$1, name, {
|
|
@@ -1620,381 +1618,11 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
1620
1618
|
}
|
|
1621
1619
|
return to;
|
|
1622
1620
|
};
|
|
1623
|
-
var __reExport = (target$1, mod, secondTarget) => (__copyProps(target$1, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
1624
|
-
var __toESM = (mod, isNodeMode, target$1) => (target$1 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target$1, "default", {
|
|
1625
|
-
value: mod,
|
|
1621
|
+
var __reExport = (target$1, mod$1, secondTarget) => (__copyProps(target$1, mod$1, "default"), secondTarget && __copyProps(secondTarget, mod$1, "default"));
|
|
1622
|
+
var __toESM = (mod$1, isNodeMode, target$1) => (target$1 = mod$1 != null ? __create(__getProtoOf(mod$1)) : {}, __copyProps(isNodeMode || !mod$1 || !mod$1.__esModule ? __defProp(target$1, "default", {
|
|
1623
|
+
value: mod$1,
|
|
1626
1624
|
enumerable: true
|
|
1627
|
-
}) : target$1, mod));
|
|
1628
|
-
|
|
1629
|
-
//#endregion
|
|
1630
|
-
//#region ../workers-utils/dist/chunk-BLWXWFJK.mjs
|
|
1631
|
-
function isCompatDate(str) {
|
|
1632
|
-
return /^\d{4}-\d{2}-\d{2}$/.test(str);
|
|
1633
|
-
}
|
|
1634
|
-
__name(isCompatDate, "isCompatDate");
|
|
1635
|
-
function formatCompatibilityDate(date) {
|
|
1636
|
-
const compatDate = date.toISOString().slice(0, 10);
|
|
1637
|
-
assert(isCompatDate(compatDate));
|
|
1638
|
-
return compatDate;
|
|
1639
|
-
}
|
|
1640
|
-
__name(formatCompatibilityDate, "formatCompatibilityDate");
|
|
1641
|
-
function getTodaysCompatDate() {
|
|
1642
|
-
return formatCompatibilityDate(/* @__PURE__ */ new Date());
|
|
1643
|
-
}
|
|
1644
|
-
__name(getTodaysCompatDate, "getTodaysCompatDate");
|
|
1645
|
-
function assertNever(_value) {}
|
|
1646
|
-
__name(assertNever, "assertNever");
|
|
1647
|
-
function mapWorkerMetadataBindings(bindings) {
|
|
1648
|
-
return bindings.filter((binding) => binding.type !== "secret_text").reduce((configObj, binding) => {
|
|
1649
|
-
switch (binding.type) {
|
|
1650
|
-
case "plain_text":
|
|
1651
|
-
configObj.vars = {
|
|
1652
|
-
...configObj.vars ?? {},
|
|
1653
|
-
[binding.name]: binding.text
|
|
1654
|
-
};
|
|
1655
|
-
break;
|
|
1656
|
-
case "json":
|
|
1657
|
-
configObj.vars = {
|
|
1658
|
-
...configObj.vars ?? {},
|
|
1659
|
-
name: binding.name,
|
|
1660
|
-
json: binding.json
|
|
1661
|
-
};
|
|
1662
|
-
break;
|
|
1663
|
-
case "kv_namespace":
|
|
1664
|
-
configObj.kv_namespaces = [...configObj.kv_namespaces ?? [], {
|
|
1665
|
-
id: binding.namespace_id,
|
|
1666
|
-
binding: binding.name
|
|
1667
|
-
}];
|
|
1668
|
-
break;
|
|
1669
|
-
case "durable_object_namespace":
|
|
1670
|
-
configObj.durable_objects = { bindings: [...configObj.durable_objects?.bindings ?? [], {
|
|
1671
|
-
name: binding.name,
|
|
1672
|
-
class_name: binding.class_name,
|
|
1673
|
-
script_name: binding.script_name,
|
|
1674
|
-
environment: binding.environment
|
|
1675
|
-
}] };
|
|
1676
|
-
break;
|
|
1677
|
-
case "d1":
|
|
1678
|
-
configObj.d1_databases = [...configObj.d1_databases ?? [], {
|
|
1679
|
-
binding: binding.name,
|
|
1680
|
-
database_id: binding.id
|
|
1681
|
-
}];
|
|
1682
|
-
break;
|
|
1683
|
-
case "browser":
|
|
1684
|
-
configObj.browser = { binding: binding.name };
|
|
1685
|
-
break;
|
|
1686
|
-
case "ai":
|
|
1687
|
-
configObj.ai = { binding: binding.name };
|
|
1688
|
-
break;
|
|
1689
|
-
case "images":
|
|
1690
|
-
configObj.images = { binding: binding.name };
|
|
1691
|
-
break;
|
|
1692
|
-
case "stream":
|
|
1693
|
-
configObj.stream = { binding: binding.name };
|
|
1694
|
-
break;
|
|
1695
|
-
case "media":
|
|
1696
|
-
configObj.media = { binding: binding.name };
|
|
1697
|
-
break;
|
|
1698
|
-
case "r2_bucket":
|
|
1699
|
-
configObj.r2_buckets = [...configObj.r2_buckets ?? [], {
|
|
1700
|
-
binding: binding.name,
|
|
1701
|
-
bucket_name: binding.bucket_name,
|
|
1702
|
-
jurisdiction: binding.jurisdiction
|
|
1703
|
-
}];
|
|
1704
|
-
break;
|
|
1705
|
-
case "secrets_store_secret":
|
|
1706
|
-
configObj.secrets_store_secrets = [...configObj.secrets_store_secrets ?? [], {
|
|
1707
|
-
binding: binding.name,
|
|
1708
|
-
store_id: binding.store_id,
|
|
1709
|
-
secret_name: binding.secret_name
|
|
1710
|
-
}];
|
|
1711
|
-
break;
|
|
1712
|
-
case "artifacts":
|
|
1713
|
-
configObj.artifacts = [...configObj.artifacts ?? [], {
|
|
1714
|
-
binding: binding.name,
|
|
1715
|
-
namespace: binding.namespace
|
|
1716
|
-
}];
|
|
1717
|
-
break;
|
|
1718
|
-
case "unsafe_hello_world":
|
|
1719
|
-
configObj.unsafe_hello_world = [...configObj.unsafe_hello_world ?? [], {
|
|
1720
|
-
binding: binding.name,
|
|
1721
|
-
enable_timer: binding.enable_timer
|
|
1722
|
-
}];
|
|
1723
|
-
break;
|
|
1724
|
-
case "flagship":
|
|
1725
|
-
configObj.flagship = [...configObj.flagship ?? [], {
|
|
1726
|
-
binding: binding.name,
|
|
1727
|
-
app_id: binding.app_id
|
|
1728
|
-
}];
|
|
1729
|
-
break;
|
|
1730
|
-
case "service":
|
|
1731
|
-
configObj.services = [...configObj.services ?? [], {
|
|
1732
|
-
binding: binding.name,
|
|
1733
|
-
service: binding.service,
|
|
1734
|
-
environment: binding.environment,
|
|
1735
|
-
entrypoint: binding.entrypoint
|
|
1736
|
-
}];
|
|
1737
|
-
break;
|
|
1738
|
-
case "analytics_engine":
|
|
1739
|
-
configObj.analytics_engine_datasets = [...configObj.analytics_engine_datasets ?? [], {
|
|
1740
|
-
binding: binding.name,
|
|
1741
|
-
dataset: binding.dataset
|
|
1742
|
-
}];
|
|
1743
|
-
break;
|
|
1744
|
-
case "dispatch_namespace":
|
|
1745
|
-
configObj.dispatch_namespaces = [...configObj.dispatch_namespaces ?? [], {
|
|
1746
|
-
binding: binding.name,
|
|
1747
|
-
namespace: binding.namespace,
|
|
1748
|
-
...binding.outbound && { outbound: {
|
|
1749
|
-
service: binding.outbound.worker.service,
|
|
1750
|
-
environment: binding.outbound.worker.environment,
|
|
1751
|
-
parameters: binding.outbound.params?.map((p$1) => p$1.name) ?? []
|
|
1752
|
-
} }
|
|
1753
|
-
}];
|
|
1754
|
-
break;
|
|
1755
|
-
case "logfwdr":
|
|
1756
|
-
configObj.logfwdr = { bindings: [...configObj.logfwdr?.bindings ?? [], {
|
|
1757
|
-
name: binding.name,
|
|
1758
|
-
destination: binding.destination
|
|
1759
|
-
}] };
|
|
1760
|
-
break;
|
|
1761
|
-
case "wasm_module":
|
|
1762
|
-
configObj.wasm_modules = {
|
|
1763
|
-
...configObj.wasm_modules ?? {},
|
|
1764
|
-
[binding.name]: binding.part
|
|
1765
|
-
};
|
|
1766
|
-
break;
|
|
1767
|
-
case "text_blob":
|
|
1768
|
-
configObj.text_blobs = {
|
|
1769
|
-
...configObj.text_blobs ?? {},
|
|
1770
|
-
[binding.name]: binding.part
|
|
1771
|
-
};
|
|
1772
|
-
break;
|
|
1773
|
-
case "data_blob":
|
|
1774
|
-
configObj.data_blobs = {
|
|
1775
|
-
...configObj.data_blobs ?? {},
|
|
1776
|
-
[binding.name]: binding.part
|
|
1777
|
-
};
|
|
1778
|
-
break;
|
|
1779
|
-
case "secret_text": break;
|
|
1780
|
-
case "version_metadata":
|
|
1781
|
-
configObj.version_metadata = { binding: binding.name };
|
|
1782
|
-
break;
|
|
1783
|
-
case "send_email":
|
|
1784
|
-
configObj.send_email = [...configObj.send_email ?? [], {
|
|
1785
|
-
name: binding.name,
|
|
1786
|
-
destination_address: binding.destination_address,
|
|
1787
|
-
allowed_destination_addresses: binding.allowed_destination_addresses,
|
|
1788
|
-
allowed_sender_addresses: binding.allowed_sender_addresses
|
|
1789
|
-
}];
|
|
1790
|
-
break;
|
|
1791
|
-
case "queue":
|
|
1792
|
-
configObj.queues ??= { producers: [] };
|
|
1793
|
-
configObj.queues.producers = [...configObj.queues.producers ?? [], {
|
|
1794
|
-
binding: binding.name,
|
|
1795
|
-
queue: binding.queue_name,
|
|
1796
|
-
delivery_delay: binding.delivery_delay
|
|
1797
|
-
}];
|
|
1798
|
-
break;
|
|
1799
|
-
case "vectorize":
|
|
1800
|
-
configObj.vectorize = [...configObj.vectorize ?? [], {
|
|
1801
|
-
binding: binding.name,
|
|
1802
|
-
index_name: binding.index_name
|
|
1803
|
-
}];
|
|
1804
|
-
break;
|
|
1805
|
-
case "ai_search_namespace":
|
|
1806
|
-
configObj.ai_search_namespaces = [...configObj.ai_search_namespaces ?? [], {
|
|
1807
|
-
binding: binding.name,
|
|
1808
|
-
namespace: binding.namespace
|
|
1809
|
-
}];
|
|
1810
|
-
break;
|
|
1811
|
-
case "ai_search":
|
|
1812
|
-
configObj.ai_search = [...configObj.ai_search ?? [], {
|
|
1813
|
-
binding: binding.name,
|
|
1814
|
-
instance_name: binding.instance_name
|
|
1815
|
-
}];
|
|
1816
|
-
break;
|
|
1817
|
-
case "hyperdrive":
|
|
1818
|
-
configObj.hyperdrive = [...configObj.hyperdrive ?? [], {
|
|
1819
|
-
binding: binding.name,
|
|
1820
|
-
id: binding.id
|
|
1821
|
-
}];
|
|
1822
|
-
break;
|
|
1823
|
-
case "mtls_certificate":
|
|
1824
|
-
configObj.mtls_certificates = [...configObj.mtls_certificates ?? [], {
|
|
1825
|
-
binding: binding.name,
|
|
1826
|
-
certificate_id: binding.certificate_id
|
|
1827
|
-
}];
|
|
1828
|
-
break;
|
|
1829
|
-
case "pipelines":
|
|
1830
|
-
configObj.pipelines = [...configObj.pipelines ?? [], {
|
|
1831
|
-
binding: binding.name,
|
|
1832
|
-
pipeline: binding.pipeline
|
|
1833
|
-
}];
|
|
1834
|
-
break;
|
|
1835
|
-
case "assets":
|
|
1836
|
-
configObj.assets = { binding: binding.name };
|
|
1837
|
-
break;
|
|
1838
|
-
case "inherit":
|
|
1839
|
-
configObj.unsafe = {
|
|
1840
|
-
bindings: [...configObj.unsafe?.bindings ?? [], binding],
|
|
1841
|
-
metadata: configObj.unsafe?.metadata ?? void 0
|
|
1842
|
-
};
|
|
1843
|
-
break;
|
|
1844
|
-
case "workflow":
|
|
1845
|
-
configObj.workflows = [...configObj.workflows ?? [], {
|
|
1846
|
-
binding: binding.name,
|
|
1847
|
-
name: binding.workflow_name,
|
|
1848
|
-
class_name: binding.class_name,
|
|
1849
|
-
script_name: binding.script_name
|
|
1850
|
-
}];
|
|
1851
|
-
break;
|
|
1852
|
-
case "worker_loader":
|
|
1853
|
-
configObj.worker_loaders = [...configObj.worker_loaders ?? [], { binding: binding.name }];
|
|
1854
|
-
break;
|
|
1855
|
-
case "ratelimit":
|
|
1856
|
-
configObj.ratelimits = [...configObj.ratelimits ?? [], {
|
|
1857
|
-
name: binding.name,
|
|
1858
|
-
namespace_id: binding.namespace_id,
|
|
1859
|
-
simple: {
|
|
1860
|
-
limit: binding.simple.limit,
|
|
1861
|
-
period: binding.simple.period
|
|
1862
|
-
}
|
|
1863
|
-
}];
|
|
1864
|
-
break;
|
|
1865
|
-
case "vpc_service":
|
|
1866
|
-
configObj.vpc_services = [...configObj.vpc_services ?? [], {
|
|
1867
|
-
binding: binding.name,
|
|
1868
|
-
service_id: binding.service_id
|
|
1869
|
-
}];
|
|
1870
|
-
break;
|
|
1871
|
-
case "vpc_network":
|
|
1872
|
-
if (binding.tunnel_id !== void 0) configObj.vpc_networks = [...configObj.vpc_networks ?? [], {
|
|
1873
|
-
binding: binding.name,
|
|
1874
|
-
tunnel_id: binding.tunnel_id
|
|
1875
|
-
}];
|
|
1876
|
-
else if (binding.network_id !== void 0) configObj.vpc_networks = [...configObj.vpc_networks ?? [], {
|
|
1877
|
-
binding: binding.name,
|
|
1878
|
-
network_id: binding.network_id
|
|
1879
|
-
}];
|
|
1880
|
-
break;
|
|
1881
|
-
default: configObj.unsafe = {
|
|
1882
|
-
bindings: [...configObj.unsafe?.bindings ?? [], binding],
|
|
1883
|
-
metadata: configObj.unsafe?.metadata ?? void 0
|
|
1884
|
-
};
|
|
1885
|
-
}
|
|
1886
|
-
return configObj;
|
|
1887
|
-
}, {});
|
|
1888
|
-
}
|
|
1889
|
-
__name(mapWorkerMetadataBindings, "mapWorkerMetadataBindings");
|
|
1890
|
-
function convertWorkerToWranglerConfig(config) {
|
|
1891
|
-
const mappedBindings = mapWorkerMetadataBindings(config.bindings);
|
|
1892
|
-
const durableObjectClassNames = config.bindings.filter((binding) => binding.type === "durable_object_namespace" && binding.script_name === config.name).map((durableObject) => durableObject.class_name);
|
|
1893
|
-
const allRoutes = [...config.routes.map((r$1) => ({
|
|
1894
|
-
pattern: r$1.pattern,
|
|
1895
|
-
zone_name: r$1.zone_name
|
|
1896
|
-
})), ...config.domains.map((c) => ({
|
|
1897
|
-
pattern: c.hostname,
|
|
1898
|
-
zone_name: c.zone_name,
|
|
1899
|
-
custom_domain: true,
|
|
1900
|
-
enabled: c.enabled,
|
|
1901
|
-
previews_enabled: c.previews_enabled
|
|
1902
|
-
}))];
|
|
1903
|
-
return {
|
|
1904
|
-
name: config.name,
|
|
1905
|
-
main: config.entrypoint,
|
|
1906
|
-
workers_dev: config.subdomain.enabled,
|
|
1907
|
-
preview_urls: config.subdomain.previews_enabled,
|
|
1908
|
-
compatibility_date: config.compatibility_date ?? getTodaysCompatDate(),
|
|
1909
|
-
compatibility_flags: config.compatibility_flags,
|
|
1910
|
-
...allRoutes.length ? { routes: allRoutes } : {},
|
|
1911
|
-
placement: config.placement?.mode === "smart" ? { mode: "smart" } : void 0,
|
|
1912
|
-
limits: config.limits,
|
|
1913
|
-
...durableObjectClassNames.length && config.migration_tag ? { migrations: [{
|
|
1914
|
-
tag: config.migration_tag,
|
|
1915
|
-
new_classes: durableObjectClassNames
|
|
1916
|
-
}] } : {},
|
|
1917
|
-
...config.schedules.length ? { triggers: { crons: config.schedules.map((scheduled) => scheduled.cron) } } : {},
|
|
1918
|
-
tail_consumers: config.tail_consumers ?? void 0,
|
|
1919
|
-
observability: config.observability,
|
|
1920
|
-
...mappedBindings
|
|
1921
|
-
};
|
|
1922
|
-
}
|
|
1923
|
-
__name(convertWorkerToWranglerConfig, "convertWorkerToWranglerConfig");
|
|
1924
|
-
function constructWranglerConfig(workerOrWorkers) {
|
|
1925
|
-
let workers;
|
|
1926
|
-
if (Array.isArray(workerOrWorkers)) workers = workerOrWorkers;
|
|
1927
|
-
else workers = [workerOrWorkers];
|
|
1928
|
-
const topLevelEnv = workers.find((w) => !w.tags?.some((t$5) => t$5.startsWith(ENVIRONMENT_TAG_PREFIX)));
|
|
1929
|
-
const workerName = topLevelEnv?.name ?? workers[0].name;
|
|
1930
|
-
const entrypoint = topLevelEnv?.entrypoint ?? workers[0].entrypoint;
|
|
1931
|
-
let combinedConfig;
|
|
1932
|
-
if (topLevelEnv) combinedConfig = convertWorkerToWranglerConfig(topLevelEnv);
|
|
1933
|
-
else combinedConfig = {
|
|
1934
|
-
name: workerName,
|
|
1935
|
-
main: entrypoint
|
|
1936
|
-
};
|
|
1937
|
-
for (const env$1 of workers) {
|
|
1938
|
-
const serviceTag = env$1.tags?.find((t$5) => t$5 === `${SERVICE_TAG_PREFIX}${workerName}`);
|
|
1939
|
-
const envTag = env$1.tags?.find((t$5) => t$5.startsWith(ENVIRONMENT_TAG_PREFIX));
|
|
1940
|
-
if (serviceTag !== `${SERVICE_TAG_PREFIX}${workerName}` || envTag === void 0) continue;
|
|
1941
|
-
const [_, envName] = envTag.split("=");
|
|
1942
|
-
combinedConfig.env ??= {};
|
|
1943
|
-
combinedConfig.env[envName] = convertWorkerToWranglerConfig(env$1);
|
|
1944
|
-
}
|
|
1945
|
-
return combinedConfig;
|
|
1946
|
-
}
|
|
1947
|
-
__name(constructWranglerConfig, "constructWranglerConfig");
|
|
1948
|
-
|
|
1949
|
-
//#endregion
|
|
1950
|
-
//#region ../workers-utils/dist/chunk-O4YGOZSW.mjs
|
|
1951
|
-
var MetricsRegistry = class {
|
|
1952
|
-
static {
|
|
1953
|
-
__name(this, "MetricsRegistry");
|
|
1954
|
-
}
|
|
1955
|
-
counters = [];
|
|
1956
|
-
/**
|
|
1957
|
-
* Create and register a new counter metric.
|
|
1958
|
-
*
|
|
1959
|
-
* @param name - The metric name (e.g. "service_request_total")
|
|
1960
|
-
* @param help - A human-readable description of the metric
|
|
1961
|
-
* @returns A Counter that can be incremented
|
|
1962
|
-
*/
|
|
1963
|
-
createCounter(name, help) {
|
|
1964
|
-
const entry = {
|
|
1965
|
-
name,
|
|
1966
|
-
help,
|
|
1967
|
-
value: 0
|
|
1968
|
-
};
|
|
1969
|
-
this.counters.push(entry);
|
|
1970
|
-
return {
|
|
1971
|
-
inc: /* @__PURE__ */ __name(() => {
|
|
1972
|
-
entry.value++;
|
|
1973
|
-
}, "inc"),
|
|
1974
|
-
add: /* @__PURE__ */ __name((amount) => {
|
|
1975
|
-
if (amount < 0) throw new Error("Counter value cannot decrease");
|
|
1976
|
-
entry.value += amount;
|
|
1977
|
-
}, "add")
|
|
1978
|
-
};
|
|
1979
|
-
}
|
|
1980
|
-
/**
|
|
1981
|
-
* Serialize all registered metrics in Prometheus text exposition format.
|
|
1982
|
-
*
|
|
1983
|
-
* @see https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format
|
|
1984
|
-
*/
|
|
1985
|
-
metrics() {
|
|
1986
|
-
return this.counters.map((c) => {
|
|
1987
|
-
let result = "";
|
|
1988
|
-
if (c.help.length > 0) result += `# HELP ${c.name} ${c.help}
|
|
1989
|
-
`;
|
|
1990
|
-
result += `# TYPE ${c.name} counter
|
|
1991
|
-
`;
|
|
1992
|
-
result += `${c.name} ${c.value}
|
|
1993
|
-
`;
|
|
1994
|
-
return result;
|
|
1995
|
-
}).join("");
|
|
1996
|
-
}
|
|
1997
|
-
};
|
|
1625
|
+
}) : target$1, mod$1));
|
|
1998
1626
|
|
|
1999
1627
|
//#endregion
|
|
2000
1628
|
//#region ../workers-utils/dist/chunk-GMTGAG26.mjs
|
|
@@ -4330,7 +3958,7 @@ function resolveWranglerConfigPath({ config, script }, options) {
|
|
|
4330
3958
|
deployConfigPath: void 0,
|
|
4331
3959
|
redirected: false
|
|
4332
3960
|
};
|
|
4333
|
-
return findWranglerConfig$1(script !== void 0 ?
|
|
3961
|
+
return findWranglerConfig$1(script !== void 0 ? path3.dirname(script) : process.cwd(), options);
|
|
4334
3962
|
}
|
|
4335
3963
|
__name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
|
|
4336
3964
|
function findWranglerConfig$1(referencePath = process.cwd(), { useRedirectIfAvailable = false } = {}) {
|
|
@@ -4361,15 +3989,15 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
4361
3989
|
const deployConfigFile = readFileSync$1(deployConfigPath);
|
|
4362
3990
|
try {
|
|
4363
3991
|
const deployConfig = parseJSONC(deployConfigFile, deployConfigPath);
|
|
4364
|
-
redirectedConfigPath = deployConfig.configPath &&
|
|
3992
|
+
redirectedConfigPath = deployConfig.configPath && path3.resolve(path3.dirname(deployConfigPath), deployConfig.configPath);
|
|
4365
3993
|
} catch (e) {
|
|
4366
|
-
throw new UserError(`Failed to parse the deploy configuration file at ${
|
|
3994
|
+
throw new UserError(`Failed to parse the deploy configuration file at ${path3.relative(".", deployConfigPath)}`, {
|
|
4367
3995
|
cause: e,
|
|
4368
3996
|
telemetryMessage: false
|
|
4369
3997
|
});
|
|
4370
3998
|
}
|
|
4371
3999
|
if (!redirectedConfigPath) throw new UserError(esm_default`
|
|
4372
|
-
A deploy configuration file was found at "${
|
|
4000
|
+
A deploy configuration file was found at "${path3.relative(".", deployConfigPath)}".
|
|
4373
4001
|
But this is not valid - the required "configPath" property was not found.
|
|
4374
4002
|
Instead this file contains:
|
|
4375
4003
|
\`\`\`
|
|
@@ -4377,13 +4005,13 @@ function findRedirectedWranglerConfig(cwd, userConfigPath) {
|
|
|
4377
4005
|
\`\`\`
|
|
4378
4006
|
`, { telemetryMessage: false });
|
|
4379
4007
|
if (!existsSync(redirectedConfigPath)) throw new UserError(esm_default`
|
|
4380
|
-
There is a deploy configuration at "${
|
|
4381
|
-
But the redirected configuration path it points to, "${
|
|
4008
|
+
There is a deploy configuration at "${path3.relative(".", deployConfigPath)}".
|
|
4009
|
+
But the redirected configuration path it points to, "${path3.relative(".", redirectedConfigPath)}", does not exist.
|
|
4382
4010
|
`, { telemetryMessage: false });
|
|
4383
4011
|
if (userConfigPath) {
|
|
4384
|
-
if (
|
|
4385
|
-
Found both a user configuration file at "${
|
|
4386
|
-
and a deploy configuration file at "${
|
|
4012
|
+
if (path3.join(path3.dirname(userConfigPath), PATH_TO_DEPLOY_CONFIG) !== deployConfigPath) throw new UserError(esm_default`
|
|
4013
|
+
Found both a user configuration file at "${path3.relative(".", userConfigPath)}"
|
|
4014
|
+
and a deploy configuration file at "${path3.relative(".", deployConfigPath)}".
|
|
4387
4015
|
But these do not share the same base path so it is not clear which should be used.
|
|
4388
4016
|
`, { telemetryMessage: false });
|
|
4389
4017
|
}
|
|
@@ -4427,11 +4055,11 @@ function formatConfigSnippet(snippet, configPath, formatted = true) {
|
|
|
4427
4055
|
}
|
|
4428
4056
|
__name(formatConfigSnippet, "formatConfigSnippet");
|
|
4429
4057
|
function isDirectory(path2) {
|
|
4430
|
-
return
|
|
4058
|
+
return fs2.statSync(path2, { throwIfNoEntry: false })?.isDirectory() ?? false;
|
|
4431
4059
|
}
|
|
4432
4060
|
__name(isDirectory, "isDirectory");
|
|
4433
4061
|
function removeDir(dirPath, { fireAndForget = false } = {}) {
|
|
4434
|
-
const result =
|
|
4062
|
+
const result = fs2.promises.rm(dirPath, {
|
|
4435
4063
|
recursive: true,
|
|
4436
4064
|
force: true,
|
|
4437
4065
|
maxRetries: 5,
|
|
@@ -4442,7 +4070,7 @@ function removeDir(dirPath, { fireAndForget = false } = {}) {
|
|
|
4442
4070
|
}
|
|
4443
4071
|
__name(removeDir, "removeDir");
|
|
4444
4072
|
function removeDirSync(dirPath) {
|
|
4445
|
-
|
|
4073
|
+
fs2.rmSync(dirPath, {
|
|
4446
4074
|
recursive: true,
|
|
4447
4075
|
force: true,
|
|
4448
4076
|
maxRetries: 5,
|
|
@@ -5599,10 +5227,10 @@ var require_util$5 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
5599
5227
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) throw new InvalidArgumentError$36("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
5600
5228
|
const port = url.port != null ? url.port : url.protocol === "https:" ? 443 : 80;
|
|
5601
5229
|
let origin = url.origin != null ? url.origin : `${url.protocol || ""}//${url.hostname || ""}:${port}`;
|
|
5602
|
-
let path$
|
|
5230
|
+
let path$1 = url.path != null ? url.path : `${url.pathname || ""}${url.search || ""}`;
|
|
5603
5231
|
if (origin[origin.length - 1] === "/") origin = origin.slice(0, origin.length - 1);
|
|
5604
|
-
if (path$
|
|
5605
|
-
return new URL(`${origin}${path$
|
|
5232
|
+
if (path$1 && path$1[0] !== "/") path$1 = `/${path$1}`;
|
|
5233
|
+
return new URL(`${origin}${path$1}`);
|
|
5606
5234
|
}
|
|
5607
5235
|
if (!isHttpOrHttpsPrefixed(url.origin || url.protocol)) throw new InvalidArgumentError$36("Invalid URL protocol: the URL must start with `http:` or `https:`.");
|
|
5608
5236
|
return url;
|
|
@@ -6477,8 +6105,8 @@ var require_diagnostics = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
6477
6105
|
debugLog("connection to %s%s using %s%s errored - %s", host, port ? `:${port}` : "", protocol, version$2, error.message);
|
|
6478
6106
|
});
|
|
6479
6107
|
diagnosticsChannel$1.subscribe("undici:client:sendHeaders", (evt) => {
|
|
6480
|
-
const { request: { method, path: path$
|
|
6481
|
-
debugLog("sending request to %s %s%s", method, origin, path$
|
|
6108
|
+
const { request: { method, path: path$1, origin } } = evt;
|
|
6109
|
+
debugLog("sending request to %s %s%s", method, origin, path$1);
|
|
6482
6110
|
});
|
|
6483
6111
|
}
|
|
6484
6112
|
let isTrackingRequestEvents = false;
|
|
@@ -6490,16 +6118,16 @@ var require_diagnostics = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
6490
6118
|
}
|
|
6491
6119
|
isTrackingRequestEvents = true;
|
|
6492
6120
|
diagnosticsChannel$1.subscribe("undici:request:headers", (evt) => {
|
|
6493
|
-
const { request: { method, path: path$
|
|
6494
|
-
debugLog("received response to %s %s%s - HTTP %d", method, origin, path$
|
|
6121
|
+
const { request: { method, path: path$1, origin }, response: { statusCode } } = evt;
|
|
6122
|
+
debugLog("received response to %s %s%s - HTTP %d", method, origin, path$1, statusCode);
|
|
6495
6123
|
});
|
|
6496
6124
|
diagnosticsChannel$1.subscribe("undici:request:trailers", (evt) => {
|
|
6497
|
-
const { request: { method, path: path$
|
|
6498
|
-
debugLog("trailers received from %s %s%s", method, origin, path$
|
|
6125
|
+
const { request: { method, path: path$1, origin } } = evt;
|
|
6126
|
+
debugLog("trailers received from %s %s%s", method, origin, path$1);
|
|
6499
6127
|
});
|
|
6500
6128
|
diagnosticsChannel$1.subscribe("undici:request:error", (evt) => {
|
|
6501
|
-
const { request: { method, path: path$
|
|
6502
|
-
debugLog("request to %s %s%s errored - %s", method, origin, path$
|
|
6129
|
+
const { request: { method, path: path$1, origin }, error } = evt;
|
|
6130
|
+
debugLog("request to %s %s%s errored - %s", method, origin, path$1, error.message);
|
|
6503
6131
|
});
|
|
6504
6132
|
}
|
|
6505
6133
|
let isTrackingWebSocketEvents = false;
|
|
@@ -6552,10 +6180,10 @@ var require_request$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
6552
6180
|
const invalidPathRegex = /[^\u0021-\u00ff]/;
|
|
6553
6181
|
const kHandler = Symbol("handler");
|
|
6554
6182
|
var Request$6 = class {
|
|
6555
|
-
constructor(origin, { path: path$
|
|
6556
|
-
if (typeof path$
|
|
6557
|
-
else if (path$
|
|
6558
|
-
else if (invalidPathRegex.test(path$
|
|
6183
|
+
constructor(origin, { path: path$1, method, body, headers, query, idempotent, blocking, upgrade: upgrade$1, headersTimeout, bodyTimeout, reset, expectContinue, servername, throwOnError, maxRedirections, typeOfService }, handler) {
|
|
6184
|
+
if (typeof path$1 !== "string") throw new InvalidArgumentError$35("path must be a string");
|
|
6185
|
+
else if (path$1[0] !== "/" && !(path$1.startsWith("http://") || path$1.startsWith("https://")) && method !== "CONNECT") throw new InvalidArgumentError$35("path must be an absolute URL or start with a slash");
|
|
6186
|
+
else if (invalidPathRegex.test(path$1)) throw new InvalidArgumentError$35("invalid request path");
|
|
6559
6187
|
if (typeof method !== "string") throw new InvalidArgumentError$35("method must be a string");
|
|
6560
6188
|
else if (normalizedMethodRecords$1[method] === void 0 && !isValidHTTPToken$2(method)) throw new InvalidArgumentError$35("invalid request method");
|
|
6561
6189
|
if (upgrade$1 && typeof upgrade$1 !== "string") throw new InvalidArgumentError$35("upgrade must be a string");
|
|
@@ -6596,7 +6224,7 @@ var require_request$1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
6596
6224
|
this.completed = false;
|
|
6597
6225
|
this.aborted = false;
|
|
6598
6226
|
this.upgrade = upgrade$1 || null;
|
|
6599
|
-
this.path = query ? serializePathWithQuery$3(path$
|
|
6227
|
+
this.path = query ? serializePathWithQuery$3(path$1, query) : path$1;
|
|
6600
6228
|
this.origin = origin;
|
|
6601
6229
|
this.protocol = getProtocolFromUrlString(origin);
|
|
6602
6230
|
this.idempotent = idempotent == null ? method === "HEAD" || method === "GET" : idempotent;
|
|
@@ -10524,15 +10152,15 @@ var require_client_h1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
10524
10152
|
let extractBody$4;
|
|
10525
10153
|
function lazyllhttp() {
|
|
10526
10154
|
const llhttpWasmData = process.env.JEST_WORKER_ID ? require_llhttp_wasm() : void 0;
|
|
10527
|
-
let mod;
|
|
10155
|
+
let mod$1;
|
|
10528
10156
|
let useWasmSIMD = process.arch !== "ppc64";
|
|
10529
10157
|
if (process.env.UNDICI_NO_WASM_SIMD === "1") useWasmSIMD = true;
|
|
10530
10158
|
else if (process.env.UNDICI_NO_WASM_SIMD === "0") useWasmSIMD = false;
|
|
10531
10159
|
if (useWasmSIMD) try {
|
|
10532
|
-
mod = new WebAssembly.Module(require_llhttp_simd_wasm());
|
|
10160
|
+
mod$1 = new WebAssembly.Module(require_llhttp_simd_wasm());
|
|
10533
10161
|
} catch {}
|
|
10534
|
-
if (!mod) mod = new WebAssembly.Module(llhttpWasmData || require_llhttp_wasm());
|
|
10535
|
-
return new WebAssembly.Instance(mod, { env: {
|
|
10162
|
+
if (!mod$1) mod$1 = new WebAssembly.Module(llhttpWasmData || require_llhttp_wasm());
|
|
10163
|
+
return new WebAssembly.Instance(mod$1, { env: {
|
|
10536
10164
|
wasm_on_url: (p$1, at, len) => {
|
|
10537
10165
|
return 0;
|
|
10538
10166
|
},
|
|
@@ -11079,7 +10707,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11079
10707
|
* @returns
|
|
11080
10708
|
*/
|
|
11081
10709
|
function writeH1(client, request$2) {
|
|
11082
|
-
const { method, path: path$
|
|
10710
|
+
const { method, path: path$1, host, upgrade: upgrade$1, blocking, reset } = request$2;
|
|
11083
10711
|
let { body, headers, contentLength } = request$2;
|
|
11084
10712
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH" || method === "QUERY" || method === "PROPFIND" || method === "PROPPATCH";
|
|
11085
10713
|
if (util$23.isFormDataLike(body)) {
|
|
@@ -11124,7 +10752,7 @@ var require_client_h1 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11124
10752
|
if (client[kMaxRequests$1] && socket[kCounter$1]++ >= client[kMaxRequests$1]) socket[kReset$1] = true;
|
|
11125
10753
|
if (blocking) socket[kBlocking] = true;
|
|
11126
10754
|
if (socket.setTypeOfService) socket.setTypeOfService(request$2.typeOfService);
|
|
11127
|
-
let header = `${method} ${path$
|
|
10755
|
+
let header = `${method} ${path$1} HTTP/1.1\r\n`;
|
|
11128
10756
|
if (typeof host === "string") header += `host: ${host}\r\n`;
|
|
11129
10757
|
else header += client[kHostHeader$1];
|
|
11130
10758
|
if (upgrade$1) header += `connection: upgrade\r\nupgrade: ${upgrade$1}\r\n`;
|
|
@@ -11660,7 +11288,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11660
11288
|
function writeH2(client, request$2) {
|
|
11661
11289
|
const requestTimeout = request$2.bodyTimeout ?? client[kBodyTimeout$1];
|
|
11662
11290
|
const session = client[kHTTP2Session];
|
|
11663
|
-
const { method, path: path$
|
|
11291
|
+
const { method, path: path$1, host, upgrade: upgrade$1, expectContinue, signal, protocol, headers: reqHeaders } = request$2;
|
|
11664
11292
|
let { body } = request$2;
|
|
11665
11293
|
if (upgrade$1 != null && upgrade$1 !== "websocket") {
|
|
11666
11294
|
util$22.errorRequest(client, request$2, new InvalidArgumentError$30(`Custom upgrade "${upgrade$1}" not supported over HTTP/2`));
|
|
@@ -11713,7 +11341,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11713
11341
|
}
|
|
11714
11342
|
headers[HTTP2_HEADER_METHOD] = "CONNECT";
|
|
11715
11343
|
headers[HTTP2_HEADER_PROTOCOL] = "websocket";
|
|
11716
|
-
headers[HTTP2_HEADER_PATH] = path$
|
|
11344
|
+
headers[HTTP2_HEADER_PATH] = path$1;
|
|
11717
11345
|
if (protocol === "ws:" || protocol === "wss:") headers[HTTP2_HEADER_SCHEME] = protocol === "ws:" ? "http" : "https";
|
|
11718
11346
|
else headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
11719
11347
|
stream$2 = session.request(headers, {
|
|
@@ -11755,7 +11383,7 @@ var require_client_h2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm
|
|
|
11755
11383
|
stream$2.setTimeout(requestTimeout);
|
|
11756
11384
|
return true;
|
|
11757
11385
|
}
|
|
11758
|
-
headers[HTTP2_HEADER_PATH] = path$
|
|
11386
|
+
headers[HTTP2_HEADER_PATH] = path$1;
|
|
11759
11387
|
headers[HTTP2_HEADER_SCHEME] = protocol === "http:" ? "http" : "https";
|
|
11760
11388
|
const expectsPayload = method === "PUT" || method === "POST" || method === "PATCH";
|
|
11761
11389
|
if (body && typeof body.read === "function") body.read(0);
|
|
@@ -13462,8 +13090,8 @@ var require_socks5_proxy_agent = /* @__PURE__ */ __commonJS$1({ "../../node_modu
|
|
|
13462
13090
|
const timeout$1 = setTimeout(() => {
|
|
13463
13091
|
reject(/* @__PURE__ */ new Error("SOCKS5 connection timeout"));
|
|
13464
13092
|
}, 5e3);
|
|
13465
|
-
const onConnected = (info) => {
|
|
13466
|
-
debug("SOCKS5 tunnel established to", targetHost, targetPort, "via", info);
|
|
13093
|
+
const onConnected = (info$1) => {
|
|
13094
|
+
debug("SOCKS5 tunnel established to", targetHost, targetPort, "via", info$1);
|
|
13467
13095
|
clearTimeout(timeout$1);
|
|
13468
13096
|
socks5Client.removeListener("error", onError$1);
|
|
13469
13097
|
resolve$4();
|
|
@@ -13581,8 +13209,8 @@ var require_proxy_agent = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pn
|
|
|
13581
13209
|
}
|
|
13582
13210
|
if (onHeaders) onHeaders.call(this, statusCode, data$1, resume$1);
|
|
13583
13211
|
};
|
|
13584
|
-
const { origin, path: path$
|
|
13585
|
-
opts.path = origin + path$
|
|
13212
|
+
const { origin, path: path$1 = "/", headers = {} } = opts;
|
|
13213
|
+
opts.path = origin + path$1;
|
|
13586
13214
|
if (!("host" in headers) && !("Host" in headers)) {
|
|
13587
13215
|
const { host } = new URL(origin);
|
|
13588
13216
|
headers.host = host;
|
|
@@ -15366,16 +14994,16 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15366
14994
|
}
|
|
15367
14995
|
return normalizedQp;
|
|
15368
14996
|
}
|
|
15369
|
-
function safeUrl(path$
|
|
15370
|
-
if (typeof path$
|
|
15371
|
-
const pathSegments = path$
|
|
15372
|
-
if (pathSegments.length !== 2) return path$
|
|
14997
|
+
function safeUrl(path$1) {
|
|
14998
|
+
if (typeof path$1 !== "string") return path$1;
|
|
14999
|
+
const pathSegments = path$1.split("?", 3);
|
|
15000
|
+
if (pathSegments.length !== 2) return path$1;
|
|
15373
15001
|
const qp = new URLSearchParams(pathSegments.pop());
|
|
15374
15002
|
qp.sort();
|
|
15375
15003
|
return [...pathSegments, qp.toString()].join("?");
|
|
15376
15004
|
}
|
|
15377
|
-
function matchKey(mockDispatch$1, { path: path$
|
|
15378
|
-
const pathMatch = matchValue$1(mockDispatch$1.path, path$
|
|
15005
|
+
function matchKey(mockDispatch$1, { path: path$1, method, body, headers }) {
|
|
15006
|
+
const pathMatch = matchValue$1(mockDispatch$1.path, path$1);
|
|
15379
15007
|
const methodMatch = matchValue$1(mockDispatch$1.method, method);
|
|
15380
15008
|
const bodyMatch = typeof mockDispatch$1.body !== "undefined" ? matchValue$1(mockDispatch$1.body, body) : true;
|
|
15381
15009
|
const headersMatch = matchHeaders(mockDispatch$1, headers);
|
|
@@ -15393,8 +15021,8 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15393
15021
|
const basePath = key.query ? serializePathWithQuery$2(key.path, key.query) : key.path;
|
|
15394
15022
|
const resolvedPath = typeof basePath === "string" ? safeUrl(basePath) : basePath;
|
|
15395
15023
|
const resolvedPathWithoutTrailingSlash = removeTrailingSlash(resolvedPath);
|
|
15396
|
-
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path$
|
|
15397
|
-
return ignoreTrailingSlash ? matchValue$1(removeTrailingSlash(safeUrl(path$
|
|
15024
|
+
let matchedMockDispatches = mockDispatches.filter(({ consumed }) => !consumed).filter(({ path: path$1, ignoreTrailingSlash }) => {
|
|
15025
|
+
return ignoreTrailingSlash ? matchValue$1(removeTrailingSlash(safeUrl(path$1)), resolvedPathWithoutTrailingSlash) : matchValue$1(safeUrl(path$1), resolvedPath);
|
|
15398
15026
|
});
|
|
15399
15027
|
if (matchedMockDispatches.length === 0) throw new MockNotMatchedError(`Mock dispatch not matched for path '${resolvedPath}'`);
|
|
15400
15028
|
matchedMockDispatches = matchedMockDispatches.filter(({ method }) => matchValue$1(method, key.method));
|
|
@@ -15437,15 +15065,15 @@ var require_mock_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
15437
15065
|
/**
|
|
15438
15066
|
* @param {string} path Path to remove trailing slash from
|
|
15439
15067
|
*/
|
|
15440
|
-
function removeTrailingSlash(path$
|
|
15441
|
-
while (path$
|
|
15442
|
-
if (path$
|
|
15443
|
-
return path$
|
|
15068
|
+
function removeTrailingSlash(path$1) {
|
|
15069
|
+
while (path$1.endsWith("/")) path$1 = path$1.slice(0, -1);
|
|
15070
|
+
if (path$1.length === 0) path$1 = "/";
|
|
15071
|
+
return path$1;
|
|
15444
15072
|
}
|
|
15445
15073
|
function buildKey$1(opts) {
|
|
15446
|
-
const { path: path$
|
|
15074
|
+
const { path: path$1, method, body, headers, query } = opts;
|
|
15447
15075
|
return {
|
|
15448
|
-
path: path$
|
|
15076
|
+
path: path$1,
|
|
15449
15077
|
method,
|
|
15450
15078
|
body,
|
|
15451
15079
|
headers,
|
|
@@ -16012,10 +15640,10 @@ var require_pending_interceptors_formatter = /* @__PURE__ */ __commonJS$1({ "../
|
|
|
16012
15640
|
});
|
|
16013
15641
|
}
|
|
16014
15642
|
format(pendingInterceptors) {
|
|
16015
|
-
const withPrettyHeaders = pendingInterceptors.map(({ method, path: path$
|
|
15643
|
+
const withPrettyHeaders = pendingInterceptors.map(({ method, path: path$1, data: { statusCode }, persist, times, timesInvoked, origin }) => ({
|
|
16016
15644
|
Method: method,
|
|
16017
15645
|
Origin: origin,
|
|
16018
|
-
Path: path$
|
|
15646
|
+
Path: path$1,
|
|
16019
15647
|
"Status code": statusCode,
|
|
16020
15648
|
Persistent: persist ? PERSISTENT : NOT_PERSISTENT,
|
|
16021
15649
|
Invocations: timesInvoked,
|
|
@@ -16073,8 +15701,8 @@ var require_mock_agent = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
16073
15701
|
const acceptNonStandardSearchParameters = this[kMockAgentAcceptsNonStandardSearchParameters];
|
|
16074
15702
|
const dispatchOpts = { ...opts };
|
|
16075
15703
|
if (acceptNonStandardSearchParameters && dispatchOpts.path) {
|
|
16076
|
-
const [path$
|
|
16077
|
-
dispatchOpts.path = `${path$
|
|
15704
|
+
const [path$1, searchParams] = dispatchOpts.path.split("?");
|
|
15705
|
+
dispatchOpts.path = `${path$1}?${normalizeSearchParams(searchParams, acceptNonStandardSearchParameters)}`;
|
|
16078
15706
|
}
|
|
16079
15707
|
return this[kAgent].dispatch(dispatchOpts, handler);
|
|
16080
15708
|
}
|
|
@@ -16551,10 +16179,10 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16551
16179
|
* @return {Promise<void>} - Resolves when snapshots are loaded
|
|
16552
16180
|
*/
|
|
16553
16181
|
async loadSnapshots(filePath) {
|
|
16554
|
-
const path$
|
|
16555
|
-
if (!path$
|
|
16182
|
+
const path$1 = filePath || this.#snapshotPath;
|
|
16183
|
+
if (!path$1) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16556
16184
|
try {
|
|
16557
|
-
const data$1 = await readFile(resolve$3(path$
|
|
16185
|
+
const data$1 = await readFile(resolve$3(path$1), "utf8");
|
|
16558
16186
|
const parsed = JSON.parse(data$1);
|
|
16559
16187
|
if (Array.isArray(parsed)) {
|
|
16560
16188
|
this.#snapshots.clear();
|
|
@@ -16562,7 +16190,7 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16562
16190
|
} else this.#snapshots = new Map(Object.entries(parsed));
|
|
16563
16191
|
} catch (error) {
|
|
16564
16192
|
if (error.code === "ENOENT") this.#snapshots.clear();
|
|
16565
|
-
else throw new UndiciError$1(`Failed to load snapshots from ${path$
|
|
16193
|
+
else throw new UndiciError$1(`Failed to load snapshots from ${path$1}`, { cause: error });
|
|
16566
16194
|
}
|
|
16567
16195
|
}
|
|
16568
16196
|
/**
|
|
@@ -16572,9 +16200,9 @@ var require_snapshot_recorder = /* @__PURE__ */ __commonJS$1({ "../../node_modul
|
|
|
16572
16200
|
* @returns {Promise<void>} - Resolves when snapshots are saved
|
|
16573
16201
|
*/
|
|
16574
16202
|
async saveSnapshots(filePath) {
|
|
16575
|
-
const path$
|
|
16576
|
-
if (!path$
|
|
16577
|
-
const resolvedPath = resolve$3(path$
|
|
16203
|
+
const path$1 = filePath || this.#snapshotPath;
|
|
16204
|
+
if (!path$1) throw new InvalidArgumentError$6("Snapshot path is required");
|
|
16205
|
+
const resolvedPath = resolve$3(path$1);
|
|
16578
16206
|
await mkdir(dirname$2(resolvedPath), { recursive: true });
|
|
16579
16207
|
const data$1 = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
16580
16208
|
hash,
|
|
@@ -17141,11 +16769,11 @@ var require_redirect_handler = /* @__PURE__ */ __commonJS$1({ "../../node_module
|
|
|
17141
16769
|
return;
|
|
17142
16770
|
}
|
|
17143
16771
|
const { origin, pathname, search } = util$10.parseURL(new URL(this.location, this.opts.origin && new URL(this.opts.path, this.opts.origin)));
|
|
17144
|
-
const path$
|
|
17145
|
-
const redirectUrlString = `${origin}${path$
|
|
16772
|
+
const path$1 = search ? `${pathname}${search}` : pathname;
|
|
16773
|
+
const redirectUrlString = `${origin}${path$1}`;
|
|
17146
16774
|
for (const historyUrl of this.history) if (historyUrl.toString() === redirectUrlString) throw new InvalidArgumentError$3(`Redirect loop detected. Cannot redirect to ${origin}. This typically happens when using a Client or Pool with cross-origin redirects. Use an Agent for cross-origin redirects.`);
|
|
17147
16775
|
this.opts.headers = cleanRequestHeaders(this.opts.headers, statusCode === 303, this.opts.origin !== origin);
|
|
17148
|
-
this.opts.path = path$
|
|
16776
|
+
this.opts.path = path$1;
|
|
17149
16777
|
this.opts.origin = origin;
|
|
17150
16778
|
this.opts.query = null;
|
|
17151
16779
|
}
|
|
@@ -22103,10 +21731,10 @@ var require_fetch = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/und
|
|
|
22103
21731
|
const url = requestCurrentURL(request$2);
|
|
22104
21732
|
/** @type {import('../../..').Agent} */
|
|
22105
21733
|
const agent = fetchParams.controller.dispatcher;
|
|
22106
|
-
const path$
|
|
21734
|
+
const path$1 = url.pathname + url.search;
|
|
22107
21735
|
const hasTrailingQuestionMark = url.search.length === 0 && url.href[url.href.length - url.hash.length - 1] === "?";
|
|
22108
21736
|
return new Promise((resolve$4, reject) => agent.dispatch({
|
|
22109
|
-
path: hasTrailingQuestionMark ? `${path$
|
|
21737
|
+
path: hasTrailingQuestionMark ? `${path$1}?` : path$1,
|
|
22110
21738
|
origin: url.origin,
|
|
22111
21739
|
method: request$2.method,
|
|
22112
21740
|
body: agent.isMockActive ? request$2.body && (request$2.body.source || request$2.body.stream) : body,
|
|
@@ -22888,9 +22516,9 @@ var require_util$2 = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
22888
22516
|
* path-value = <any CHAR except CTLs or ";">
|
|
22889
22517
|
* @param {string} path
|
|
22890
22518
|
*/
|
|
22891
|
-
function validateCookiePath(path$
|
|
22892
|
-
for (let i$1 = 0; i$1 < path$
|
|
22893
|
-
const code = path$
|
|
22519
|
+
function validateCookiePath(path$1) {
|
|
22520
|
+
for (let i$1 = 0; i$1 < path$1.length; ++i$1) {
|
|
22521
|
+
const code = path$1.charCodeAt(i$1);
|
|
22894
22522
|
if (code < 32 || code === 127 || code === 59) throw new Error("Invalid cookie path");
|
|
22895
22523
|
}
|
|
22896
22524
|
}
|
|
@@ -25998,9 +25626,9 @@ var require_undici = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/un
|
|
|
25998
25626
|
if (opts != null && typeof opts !== "object") throw new InvalidArgumentError("invalid opts");
|
|
25999
25627
|
if (opts && opts.path != null) {
|
|
26000
25628
|
if (typeof opts.path !== "string") throw new InvalidArgumentError("invalid opts.path");
|
|
26001
|
-
let path$
|
|
26002
|
-
if (!opts.path.startsWith("/")) path$
|
|
26003
|
-
url = new URL(util$3.parseOrigin(url).origin + path$
|
|
25629
|
+
let path$1 = opts.path;
|
|
25630
|
+
if (!opts.path.startsWith("/")) path$1 = `/${path$1}`;
|
|
25631
|
+
url = new URL(util$3.parseOrigin(url).origin + path$1);
|
|
26004
25632
|
} else {
|
|
26005
25633
|
if (!opts) opts = typeof url === "object" ? url : {};
|
|
26006
25634
|
url = util$3.parseURL(url);
|
|
@@ -26117,7 +25745,7 @@ var require_XDGAppPaths = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8
|
|
|
26117
25745
|
}
|
|
26118
25746
|
__name(typeOf, "typeOf");
|
|
26119
25747
|
function Adapt(adapter_) {
|
|
26120
|
-
var meta = adapter_.meta,
|
|
25748
|
+
var meta = adapter_.meta, path5 = adapter_.path, xdg = adapter_.xdg;
|
|
26121
25749
|
return { XDGAppPaths: new (/* @__PURE__ */ function() {
|
|
26122
25750
|
function XDGAppPaths_2(options_) {
|
|
26123
25751
|
if (options_ === void 0) options_ = {};
|
|
@@ -26135,7 +25763,7 @@ var require_XDGAppPaths = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8
|
|
|
26135
25763
|
meta.pkgMainFilename(),
|
|
26136
25764
|
meta.mainFilename()
|
|
26137
25765
|
];
|
|
26138
|
-
var name =
|
|
25766
|
+
var name = path5.parse(((_c = namePriorityList.find(function(e2) {
|
|
26139
25767
|
return isString2(e2);
|
|
26140
25768
|
})) !== null && _c !== void 0 ? _c : "$eval") + suffix).name;
|
|
26141
25769
|
XDGAppPaths.$name = /* @__PURE__ */ __name(function $name() {
|
|
@@ -26155,28 +25783,28 @@ var require_XDGAppPaths = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8
|
|
|
26155
25783
|
}
|
|
26156
25784
|
__name(finalPathSegment, "finalPathSegment");
|
|
26157
25785
|
XDGAppPaths.cache = /* @__PURE__ */ __name(function cache$2(dirOptions) {
|
|
26158
|
-
return
|
|
25786
|
+
return path5.join(xdg.cache(), finalPathSegment(dirOptions));
|
|
26159
25787
|
}, "cache");
|
|
26160
25788
|
XDGAppPaths.config = /* @__PURE__ */ __name(function config(dirOptions) {
|
|
26161
|
-
return
|
|
25789
|
+
return path5.join(xdg.config(), finalPathSegment(dirOptions));
|
|
26162
25790
|
}, "config");
|
|
26163
25791
|
XDGAppPaths.data = /* @__PURE__ */ __name(function data$1(dirOptions) {
|
|
26164
|
-
return
|
|
25792
|
+
return path5.join(xdg.data(), finalPathSegment(dirOptions));
|
|
26165
25793
|
}, "data");
|
|
26166
25794
|
XDGAppPaths.runtime = /* @__PURE__ */ __name(function runtime(dirOptions) {
|
|
26167
|
-
return xdg.runtime() ?
|
|
25795
|
+
return xdg.runtime() ? path5.join(xdg.runtime(), finalPathSegment(dirOptions)) : void 0;
|
|
26168
25796
|
}, "runtime");
|
|
26169
25797
|
XDGAppPaths.state = /* @__PURE__ */ __name(function state(dirOptions) {
|
|
26170
|
-
return
|
|
25798
|
+
return path5.join(xdg.state(), finalPathSegment(dirOptions));
|
|
26171
25799
|
}, "state");
|
|
26172
25800
|
XDGAppPaths.configDirs = /* @__PURE__ */ __name(function configDirs(dirOptions) {
|
|
26173
25801
|
return xdg.configDirs().map(function(s) {
|
|
26174
|
-
return
|
|
25802
|
+
return path5.join(s, finalPathSegment(dirOptions));
|
|
26175
25803
|
});
|
|
26176
25804
|
}, "configDirs");
|
|
26177
25805
|
XDGAppPaths.dataDirs = /* @__PURE__ */ __name(function dataDirs(dirOptions) {
|
|
26178
25806
|
return xdg.dataDirs().map(function(s) {
|
|
26179
|
-
return
|
|
25807
|
+
return path5.join(s, finalPathSegment(dirOptions));
|
|
26180
25808
|
});
|
|
26181
25809
|
}, "dataDirs");
|
|
26182
25810
|
return XDGAppPaths;
|
|
@@ -26196,7 +25824,7 @@ var require_XDG = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/nod
|
|
|
26196
25824
|
exports$1.__esModule = true;
|
|
26197
25825
|
exports$1.Adapt = void 0;
|
|
26198
25826
|
function Adapt(adapter_) {
|
|
26199
|
-
var env$1 = adapter_.env, osPaths = adapter_.osPaths,
|
|
25827
|
+
var env$1 = adapter_.env, osPaths = adapter_.osPaths, path5 = adapter_.path;
|
|
26200
25828
|
var isMacOS = /^darwin$/i.test(adapter_.process.platform);
|
|
26201
25829
|
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
26202
25830
|
function baseDir() {
|
|
@@ -26204,7 +25832,7 @@ var require_XDG = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/nod
|
|
|
26204
25832
|
}
|
|
26205
25833
|
__name(baseDir, "baseDir");
|
|
26206
25834
|
function valOrPath(val, pathSegments) {
|
|
26207
|
-
return val ||
|
|
25835
|
+
return val || path5.join.apply(path5, pathSegments);
|
|
26208
25836
|
}
|
|
26209
25837
|
__name(valOrPath, "valOrPath");
|
|
26210
25838
|
var linux = /* @__PURE__ */ __name(function() {
|
|
@@ -26318,11 +25946,11 @@ var require_XDG = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/nod
|
|
|
26318
25946
|
XDG.state = extension.state;
|
|
26319
25947
|
XDG.configDirs = /* @__PURE__ */ __name(function configDirs() {
|
|
26320
25948
|
var pathList = env$1.get("XDG_CONFIG_DIRS");
|
|
26321
|
-
return __spreadArray([extension.config()], pathList ? pathList.split(
|
|
25949
|
+
return __spreadArray([extension.config()], pathList ? pathList.split(path5.delimiter) : []);
|
|
26322
25950
|
}, "configDirs");
|
|
26323
25951
|
XDG.dataDirs = /* @__PURE__ */ __name(function dataDirs() {
|
|
26324
25952
|
var pathList = env$1.get("XDG_DATA_DIRS");
|
|
26325
|
-
return __spreadArray([extension.data()], pathList ? pathList.split(
|
|
25953
|
+
return __spreadArray([extension.data()], pathList ? pathList.split(path5.delimiter) : []);
|
|
26326
25954
|
}, "dataDirs");
|
|
26327
25955
|
return XDG;
|
|
26328
25956
|
}
|
|
@@ -26345,7 +25973,7 @@ var require_OSPaths = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node
|
|
|
26345
25973
|
}
|
|
26346
25974
|
__name(isEmpty, "isEmpty");
|
|
26347
25975
|
function Adapt(adapter_) {
|
|
26348
|
-
var env$1 = adapter_.env, os2 = adapter_.os,
|
|
25976
|
+
var env$1 = adapter_.env, os2 = adapter_.os, path5 = adapter_.path;
|
|
26349
25977
|
var isWinOS = /^win/i.test(adapter_.process.platform);
|
|
26350
25978
|
function normalizePath$2(path_) {
|
|
26351
25979
|
return path_ ? adapter_.path.normalize(adapter_.path.join(path_, ".")) : void 0;
|
|
@@ -26357,7 +25985,7 @@ var require_OSPaths = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node
|
|
|
26357
25985
|
typeof os2.homedir === "function" ? os2.homedir() : void 0,
|
|
26358
25986
|
env$1.get("USERPROFILE"),
|
|
26359
25987
|
env$1.get("HOME"),
|
|
26360
|
-
env$1.get("HOMEDRIVE") || env$1.get("HOMEPATH") ?
|
|
25988
|
+
env$1.get("HOMEDRIVE") || env$1.get("HOMEPATH") ? path5.join(env$1.get("HOMEDRIVE") || "", env$1.get("HOMEPATH") || "") : void 0
|
|
26361
25989
|
].find(function(v) {
|
|
26362
25990
|
return !isEmpty(v);
|
|
26363
25991
|
}));
|
|
@@ -26368,7 +25996,7 @@ var require_OSPaths = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node
|
|
|
26368
25996
|
__name(home, "home");
|
|
26369
25997
|
function temp() {
|
|
26370
25998
|
function joinPathToBase(base, segments) {
|
|
26371
|
-
return base ?
|
|
25999
|
+
return base ? path5.join.apply(path5, __spreadArray([base], segments)) : void 0;
|
|
26372
26000
|
}
|
|
26373
26001
|
__name(joinPathToBase, "joinPathToBase");
|
|
26374
26002
|
function posix$1() {
|
|
@@ -26461,26 +26089,26 @@ var require_node = __commonJS({ "../../node_modules/.pnpm/os-paths@7.4.0/node_mo
|
|
|
26461
26089
|
} : function(o, v) {
|
|
26462
26090
|
o["default"] = v;
|
|
26463
26091
|
});
|
|
26464
|
-
var __importStar = exports$1 && exports$1.__importStar || function(mod) {
|
|
26465
|
-
if (mod && mod.__esModule) return mod;
|
|
26092
|
+
var __importStar = exports$1 && exports$1.__importStar || function(mod$1) {
|
|
26093
|
+
if (mod$1 && mod$1.__esModule) return mod$1;
|
|
26466
26094
|
var result = {};
|
|
26467
|
-
if (mod != null) {
|
|
26468
|
-
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26095
|
+
if (mod$1 != null) {
|
|
26096
|
+
for (var k in mod$1) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod$1, k)) __createBinding(result, mod$1, k);
|
|
26469
26097
|
}
|
|
26470
|
-
__setModuleDefault(result, mod);
|
|
26098
|
+
__setModuleDefault(result, mod$1);
|
|
26471
26099
|
return result;
|
|
26472
26100
|
};
|
|
26473
26101
|
exports$1.__esModule = true;
|
|
26474
26102
|
exports$1.adapter = void 0;
|
|
26475
26103
|
var os2 = __importStar(__require$1("os"));
|
|
26476
|
-
var
|
|
26104
|
+
var path5 = __importStar(__require$1("path"));
|
|
26477
26105
|
exports$1.adapter = {
|
|
26478
26106
|
atImportPermissions: { env: true },
|
|
26479
26107
|
env: { get: /* @__PURE__ */ __name(function(s) {
|
|
26480
26108
|
return process.env[s];
|
|
26481
26109
|
}, "get") },
|
|
26482
26110
|
os: os2,
|
|
26483
|
-
path:
|
|
26111
|
+
path: path5,
|
|
26484
26112
|
process
|
|
26485
26113
|
};
|
|
26486
26114
|
} });
|
|
@@ -26510,21 +26138,21 @@ var require_node2 = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/n
|
|
|
26510
26138
|
} : function(o, v) {
|
|
26511
26139
|
o["default"] = v;
|
|
26512
26140
|
});
|
|
26513
|
-
var __importStar = exports$1 && exports$1.__importStar || function(mod) {
|
|
26514
|
-
if (mod && mod.__esModule) return mod;
|
|
26141
|
+
var __importStar = exports$1 && exports$1.__importStar || function(mod$1) {
|
|
26142
|
+
if (mod$1 && mod$1.__esModule) return mod$1;
|
|
26515
26143
|
var result = {};
|
|
26516
|
-
if (mod != null) {
|
|
26517
|
-
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26144
|
+
if (mod$1 != null) {
|
|
26145
|
+
for (var k in mod$1) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod$1, k)) __createBinding(result, mod$1, k);
|
|
26518
26146
|
}
|
|
26519
|
-
__setModuleDefault(result, mod);
|
|
26147
|
+
__setModuleDefault(result, mod$1);
|
|
26520
26148
|
return result;
|
|
26521
26149
|
};
|
|
26522
|
-
var __importDefault = exports$1 && exports$1.__importDefault || function(mod) {
|
|
26523
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
26150
|
+
var __importDefault = exports$1 && exports$1.__importDefault || function(mod$1) {
|
|
26151
|
+
return mod$1 && mod$1.__esModule ? mod$1 : { "default": mod$1 };
|
|
26524
26152
|
};
|
|
26525
26153
|
exports$1.__esModule = true;
|
|
26526
26154
|
exports$1.adapter = void 0;
|
|
26527
|
-
var
|
|
26155
|
+
var path5 = __importStar(__require$1("path"));
|
|
26528
26156
|
var os_paths_1 = __importDefault(require_mod_cjs());
|
|
26529
26157
|
exports$1.adapter = {
|
|
26530
26158
|
atImportPermissions: { env: true },
|
|
@@ -26532,7 +26160,7 @@ var require_node2 = __commonJS({ "../../node_modules/.pnpm/xdg-portable@10.6.0/n
|
|
|
26532
26160
|
return process.env[s];
|
|
26533
26161
|
}, "get") },
|
|
26534
26162
|
osPaths: os_paths_1["default"],
|
|
26535
|
-
path:
|
|
26163
|
+
path: path5,
|
|
26536
26164
|
process
|
|
26537
26165
|
};
|
|
26538
26166
|
} });
|
|
@@ -26562,21 +26190,21 @@ var require_node3 = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8.3.0/n
|
|
|
26562
26190
|
} : function(o, v) {
|
|
26563
26191
|
o["default"] = v;
|
|
26564
26192
|
});
|
|
26565
|
-
var __importStar = exports$1 && exports$1.__importStar || function(mod) {
|
|
26566
|
-
if (mod && mod.__esModule) return mod;
|
|
26193
|
+
var __importStar = exports$1 && exports$1.__importStar || function(mod$1) {
|
|
26194
|
+
if (mod$1 && mod$1.__esModule) return mod$1;
|
|
26567
26195
|
var result = {};
|
|
26568
|
-
if (mod != null) {
|
|
26569
|
-
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26196
|
+
if (mod$1 != null) {
|
|
26197
|
+
for (var k in mod$1) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod$1, k)) __createBinding(result, mod$1, k);
|
|
26570
26198
|
}
|
|
26571
|
-
__setModuleDefault(result, mod);
|
|
26199
|
+
__setModuleDefault(result, mod$1);
|
|
26572
26200
|
return result;
|
|
26573
26201
|
};
|
|
26574
|
-
var __importDefault = exports$1 && exports$1.__importDefault || function(mod) {
|
|
26575
|
-
return mod && mod.__esModule ? mod : { "default": mod };
|
|
26202
|
+
var __importDefault = exports$1 && exports$1.__importDefault || function(mod$1) {
|
|
26203
|
+
return mod$1 && mod$1.__esModule ? mod$1 : { "default": mod$1 };
|
|
26576
26204
|
};
|
|
26577
26205
|
exports$1.__esModule = true;
|
|
26578
26206
|
exports$1.adapter = void 0;
|
|
26579
|
-
var
|
|
26207
|
+
var path5 = __importStar(__require$1("path"));
|
|
26580
26208
|
var xdg_portable_1 = __importDefault(require_mod_cjs2());
|
|
26581
26209
|
exports$1.adapter = {
|
|
26582
26210
|
atImportPermissions: {
|
|
@@ -26592,7 +26220,7 @@ var require_node3 = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8.3.0/n
|
|
|
26592
26220
|
return process.pkg ? process.execPath : void 0;
|
|
26593
26221
|
}, "pkgMainFilename")
|
|
26594
26222
|
},
|
|
26595
|
-
path:
|
|
26223
|
+
path: path5,
|
|
26596
26224
|
process,
|
|
26597
26225
|
xdg: xdg_portable_1["default"]
|
|
26598
26226
|
};
|
|
@@ -26602,14 +26230,147 @@ var require_mod_cjs3 = __commonJS({ "../../node_modules/.pnpm/xdg-app-paths@8.3.
|
|
|
26602
26230
|
var node_js_1 = require_node3();
|
|
26603
26231
|
module$1.exports = XDGAppPaths_js_1.Adapt(node_js_1.adapter).XDGAppPaths;
|
|
26604
26232
|
} });
|
|
26233
|
+
var require_signals = __commonJS({ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/signals.js"(exports$1, module$1) {
|
|
26234
|
+
module$1.exports = [
|
|
26235
|
+
"SIGABRT",
|
|
26236
|
+
"SIGALRM",
|
|
26237
|
+
"SIGHUP",
|
|
26238
|
+
"SIGINT",
|
|
26239
|
+
"SIGTERM"
|
|
26240
|
+
];
|
|
26241
|
+
if (process.platform !== "win32") module$1.exports.push("SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
26242
|
+
if (process.platform === "linux") module$1.exports.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED");
|
|
26243
|
+
} });
|
|
26244
|
+
var require_signal_exit = __commonJS({ "../../node_modules/.pnpm/signal-exit@3.0.7/node_modules/signal-exit/index.js"(exports$1, module$1) {
|
|
26245
|
+
var process2 = global.process;
|
|
26246
|
+
var processOk = /* @__PURE__ */ __name(function(process3) {
|
|
26247
|
+
return process3 && typeof process3 === "object" && typeof process3.removeListener === "function" && typeof process3.emit === "function" && typeof process3.reallyExit === "function" && typeof process3.listeners === "function" && typeof process3.kill === "function" && typeof process3.pid === "number" && typeof process3.on === "function";
|
|
26248
|
+
}, "processOk");
|
|
26249
|
+
if (!processOk(process2)) module$1.exports = function() {
|
|
26250
|
+
return function() {};
|
|
26251
|
+
};
|
|
26252
|
+
else {
|
|
26253
|
+
assert2 = __require$1("assert");
|
|
26254
|
+
signals = require_signals();
|
|
26255
|
+
isWin$1 = /^win/i.test(process2.platform);
|
|
26256
|
+
EE$3 = __require$1("events");
|
|
26257
|
+
if (typeof EE$3 !== "function") EE$3 = EE$3.EventEmitter;
|
|
26258
|
+
if (process2.__signal_exit_emitter__) emitter = process2.__signal_exit_emitter__;
|
|
26259
|
+
else {
|
|
26260
|
+
emitter = process2.__signal_exit_emitter__ = new EE$3();
|
|
26261
|
+
emitter.count = 0;
|
|
26262
|
+
emitter.emitted = {};
|
|
26263
|
+
}
|
|
26264
|
+
if (!emitter.infinite) {
|
|
26265
|
+
emitter.setMaxListeners(Infinity);
|
|
26266
|
+
emitter.infinite = true;
|
|
26267
|
+
}
|
|
26268
|
+
module$1.exports = function(cb, opts) {
|
|
26269
|
+
if (!processOk(global.process)) return function() {};
|
|
26270
|
+
assert2.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
26271
|
+
if (loaded === false) load();
|
|
26272
|
+
var ev = "exit";
|
|
26273
|
+
if (opts && opts.alwaysLast) ev = "afterexit";
|
|
26274
|
+
var remove = /* @__PURE__ */ __name(function() {
|
|
26275
|
+
emitter.removeListener(ev, cb);
|
|
26276
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) unload();
|
|
26277
|
+
}, "remove");
|
|
26278
|
+
emitter.on(ev, cb);
|
|
26279
|
+
return remove;
|
|
26280
|
+
};
|
|
26281
|
+
unload = /* @__PURE__ */ __name(function unload2() {
|
|
26282
|
+
if (!loaded || !processOk(global.process)) return;
|
|
26283
|
+
loaded = false;
|
|
26284
|
+
signals.forEach(function(sig) {
|
|
26285
|
+
try {
|
|
26286
|
+
process2.removeListener(sig, sigListeners[sig]);
|
|
26287
|
+
} catch (er) {}
|
|
26288
|
+
});
|
|
26289
|
+
process2.emit = originalProcessEmit;
|
|
26290
|
+
process2.reallyExit = originalProcessReallyExit;
|
|
26291
|
+
emitter.count -= 1;
|
|
26292
|
+
}, "unload");
|
|
26293
|
+
module$1.exports.unload = unload;
|
|
26294
|
+
emit = /* @__PURE__ */ __name(function emit2(event, code, signal) {
|
|
26295
|
+
if (emitter.emitted[event]) return;
|
|
26296
|
+
emitter.emitted[event] = true;
|
|
26297
|
+
emitter.emit(event, code, signal);
|
|
26298
|
+
}, "emit");
|
|
26299
|
+
sigListeners = {};
|
|
26300
|
+
signals.forEach(function(sig) {
|
|
26301
|
+
sigListeners[sig] = /* @__PURE__ */ __name(function listener() {
|
|
26302
|
+
if (!processOk(global.process)) return;
|
|
26303
|
+
if (process2.listeners(sig).length === emitter.count) {
|
|
26304
|
+
unload();
|
|
26305
|
+
emit("exit", null, sig);
|
|
26306
|
+
emit("afterexit", null, sig);
|
|
26307
|
+
if (isWin$1 && sig === "SIGHUP") sig = "SIGINT";
|
|
26308
|
+
process2.kill(process2.pid, sig);
|
|
26309
|
+
}
|
|
26310
|
+
}, "listener");
|
|
26311
|
+
});
|
|
26312
|
+
module$1.exports.signals = function() {
|
|
26313
|
+
return signals;
|
|
26314
|
+
};
|
|
26315
|
+
loaded = false;
|
|
26316
|
+
load = /* @__PURE__ */ __name(function load2() {
|
|
26317
|
+
if (loaded || !processOk(global.process)) return;
|
|
26318
|
+
loaded = true;
|
|
26319
|
+
emitter.count += 1;
|
|
26320
|
+
signals = signals.filter(function(sig) {
|
|
26321
|
+
try {
|
|
26322
|
+
process2.on(sig, sigListeners[sig]);
|
|
26323
|
+
return true;
|
|
26324
|
+
} catch (er) {
|
|
26325
|
+
return false;
|
|
26326
|
+
}
|
|
26327
|
+
});
|
|
26328
|
+
process2.emit = processEmit;
|
|
26329
|
+
process2.reallyExit = processReallyExit;
|
|
26330
|
+
}, "load");
|
|
26331
|
+
module$1.exports.load = load;
|
|
26332
|
+
originalProcessReallyExit = process2.reallyExit;
|
|
26333
|
+
processReallyExit = /* @__PURE__ */ __name(function processReallyExit2(code) {
|
|
26334
|
+
if (!processOk(global.process)) return;
|
|
26335
|
+
process2.exitCode = code || 0;
|
|
26336
|
+
emit("exit", process2.exitCode, null);
|
|
26337
|
+
emit("afterexit", process2.exitCode, null);
|
|
26338
|
+
originalProcessReallyExit.call(process2, process2.exitCode);
|
|
26339
|
+
}, "processReallyExit");
|
|
26340
|
+
originalProcessEmit = process2.emit;
|
|
26341
|
+
processEmit = /* @__PURE__ */ __name(function processEmit2(ev, arg) {
|
|
26342
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
26343
|
+
if (arg !== void 0) process2.exitCode = arg;
|
|
26344
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
26345
|
+
emit("exit", process2.exitCode, null);
|
|
26346
|
+
emit("afterexit", process2.exitCode, null);
|
|
26347
|
+
return ret;
|
|
26348
|
+
} else return originalProcessEmit.apply(this, arguments);
|
|
26349
|
+
}, "processEmit");
|
|
26350
|
+
}
|
|
26351
|
+
var assert2;
|
|
26352
|
+
var signals;
|
|
26353
|
+
var isWin$1;
|
|
26354
|
+
var EE$3;
|
|
26355
|
+
var emitter;
|
|
26356
|
+
var unload;
|
|
26357
|
+
var emit;
|
|
26358
|
+
var sigListeners;
|
|
26359
|
+
var loaded;
|
|
26360
|
+
var load;
|
|
26361
|
+
var originalProcessReallyExit;
|
|
26362
|
+
var processReallyExit;
|
|
26363
|
+
var originalProcessEmit;
|
|
26364
|
+
var processEmit;
|
|
26365
|
+
} });
|
|
26605
26366
|
var require_command_exists = __commonJS({ "../../node_modules/.pnpm/command-exists@1.2.9/node_modules/command-exists/lib/command-exists.js"(exports$1, module$1) {
|
|
26606
26367
|
var exec = __require$1("child_process").exec;
|
|
26607
26368
|
var execSync = __require$1("child_process").execSync;
|
|
26608
|
-
var
|
|
26609
|
-
var
|
|
26610
|
-
var access =
|
|
26611
|
-
var accessSync2 =
|
|
26612
|
-
var constants2 =
|
|
26369
|
+
var fs3 = __require$1("fs");
|
|
26370
|
+
var path5 = __require$1("path");
|
|
26371
|
+
var access = fs3.access;
|
|
26372
|
+
var accessSync2 = fs3.accessSync;
|
|
26373
|
+
var constants2 = fs3.constants || fs3;
|
|
26613
26374
|
var isUsingWindows = process.platform == "win32";
|
|
26614
26375
|
var fileNotExists = /* @__PURE__ */ __name(function(commandName, callback$1) {
|
|
26615
26376
|
access(commandName, constants2.F_OK, function(err) {
|
|
@@ -26683,8 +26444,8 @@ var require_command_exists = __commonJS({ "../../node_modules/.pnpm/command-exis
|
|
|
26683
26444
|
}, "cleanInput");
|
|
26684
26445
|
if (isUsingWindows) cleanInput = /* @__PURE__ */ __name(function(s) {
|
|
26685
26446
|
if (/[\\]/.test(s)) {
|
|
26686
|
-
var dirname2 = "\"" +
|
|
26687
|
-
var basename$1 = "\"" +
|
|
26447
|
+
var dirname2 = "\"" + path5.dirname(s) + "\"";
|
|
26448
|
+
var basename$1 = "\"" + path5.basename(s) + "\"";
|
|
26688
26449
|
return dirname2 + ":" + basename$1;
|
|
26689
26450
|
}
|
|
26690
26451
|
return "\"" + s + "\"";
|
|
@@ -27100,8 +26861,8 @@ function getErrorMap$1() {
|
|
|
27100
26861
|
}
|
|
27101
26862
|
__name(getErrorMap$1, "getErrorMap");
|
|
27102
26863
|
var makeIssue$1 = /* @__PURE__ */ __name((params) => {
|
|
27103
|
-
const { data: data$1, path:
|
|
27104
|
-
const fullPath = [...
|
|
26864
|
+
const { data: data$1, path: path5, errorMaps, issueData } = params;
|
|
26865
|
+
const fullPath = [...path5, ...issueData.path || []];
|
|
27105
26866
|
const fullIssue = {
|
|
27106
26867
|
...issueData,
|
|
27107
26868
|
path: fullPath
|
|
@@ -27205,11 +26966,11 @@ var ParseInputLazyPath$1 = class {
|
|
|
27205
26966
|
static {
|
|
27206
26967
|
__name(this, "ParseInputLazyPath");
|
|
27207
26968
|
}
|
|
27208
|
-
constructor(parent, value,
|
|
26969
|
+
constructor(parent, value, path5, key) {
|
|
27209
26970
|
this._cachedPath = [];
|
|
27210
26971
|
this.parent = parent;
|
|
27211
26972
|
this.data = value;
|
|
27212
|
-
this._path =
|
|
26973
|
+
this._path = path5;
|
|
27213
26974
|
this._key = key;
|
|
27214
26975
|
}
|
|
27215
26976
|
get path() {
|
|
@@ -30376,7 +30137,7 @@ __reExport(mod_esm_exports, __toESM(require_mod_cjs3(), 1));
|
|
|
30376
30137
|
var mod_esm_default = import_mod_cjs.default;
|
|
30377
30138
|
function getGlobalWranglerConfigPath() {
|
|
30378
30139
|
const configDir = mod_esm_default(".wrangler").config();
|
|
30379
|
-
const legacyConfigDir =
|
|
30140
|
+
const legacyConfigDir = path3.join(os.homedir(), ".wrangler");
|
|
30380
30141
|
if (isDirectory(legacyConfigDir)) return legacyConfigDir;
|
|
30381
30142
|
else return configDir;
|
|
30382
30143
|
}
|
|
@@ -30472,7 +30233,7 @@ var getBuildPlatformFromEnv = getEnvironmentVariableFactory({ variableName: "WRA
|
|
|
30472
30233
|
var getRegistryPath = getEnvironmentVariableFactory({
|
|
30473
30234
|
variableName: "WRANGLER_REGISTRY_PATH",
|
|
30474
30235
|
defaultValue() {
|
|
30475
|
-
return
|
|
30236
|
+
return path3.join(getGlobalWranglerConfigPath(), "registry");
|
|
30476
30237
|
}
|
|
30477
30238
|
});
|
|
30478
30239
|
var getD1ExtraLocationChoices = getEnvironmentVariableFactory({ variableName: "WRANGLER_D1_EXTRA_LOCATION_CHOICES" });
|
|
@@ -30614,9 +30375,9 @@ Please add "${field}" to "env.${envName}".`);
|
|
|
30614
30375
|
return rawEnv[field] ?? defaultValue;
|
|
30615
30376
|
}
|
|
30616
30377
|
__name(notInheritable, "notInheritable");
|
|
30617
|
-
function unwindPropertyPath(root,
|
|
30378
|
+
function unwindPropertyPath(root, path5) {
|
|
30618
30379
|
let container = root;
|
|
30619
|
-
const parts =
|
|
30380
|
+
const parts = path5.split(".");
|
|
30620
30381
|
for (let i$1 = 0; i$1 < parts.length - 1; i$1++) {
|
|
30621
30382
|
if (!hasProperty(container, parts[i$1])) return;
|
|
30622
30383
|
container = container[parts[i$1]];
|
|
@@ -30884,7 +30645,7 @@ function isPagesConfig(rawConfig) {
|
|
|
30884
30645
|
}
|
|
30885
30646
|
__name(isPagesConfig, "isPagesConfig");
|
|
30886
30647
|
function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args, preserveOriginalMain = false) {
|
|
30887
|
-
const diagnostics = new Diagnostics(`Processing ${configPath ?
|
|
30648
|
+
const diagnostics = new Diagnostics(`Processing ${configPath ? path3.relative(process.cwd(), configPath) : "wrangler"} configuration:`);
|
|
30888
30649
|
validateOptionalProperty(diagnostics, "", "legacy_env", rawConfig.legacy_env, "boolean");
|
|
30889
30650
|
validateOptionalProperty(diagnostics, "", "send_metrics", rawConfig.send_metrics, "boolean");
|
|
30890
30651
|
validateOptionalProperty(diagnostics, "", "keep_vars", rawConfig.keep_vars, "boolean");
|
|
@@ -30988,34 +30749,34 @@ function normalizeAndValidateBuild(diagnostics, rawEnv, rawBuild, configPath) {
|
|
|
30988
30749
|
else validateOptionalProperty(diagnostics, "build", "watch_dir", watch_dir, "string");
|
|
30989
30750
|
return {
|
|
30990
30751
|
command,
|
|
30991
|
-
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) =>
|
|
30752
|
+
watch_dir: command && configPath ? Array.isArray(watch_dir) ? watch_dir.map((dir) => path3.relative(process.cwd(), path3.join(path3.dirname(configPath), `${dir}`))) : path3.relative(process.cwd(), path3.join(path3.dirname(configPath), `${watch_dir}`)) : watch_dir,
|
|
30992
30753
|
cwd
|
|
30993
30754
|
};
|
|
30994
30755
|
}
|
|
30995
30756
|
__name(normalizeAndValidateBuild, "normalizeAndValidateBuild");
|
|
30996
30757
|
function normalizeAndValidateMainField(configPath, rawMain) {
|
|
30997
|
-
const configDir =
|
|
30758
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
30998
30759
|
if (rawMain !== void 0) if (typeof rawMain === "string") {
|
|
30999
|
-
const directory =
|
|
31000
|
-
return
|
|
30760
|
+
const directory = path3.resolve(configDir);
|
|
30761
|
+
return path3.resolve(directory, rawMain);
|
|
31001
30762
|
} else return rawMain;
|
|
31002
30763
|
else return;
|
|
31003
30764
|
}
|
|
31004
30765
|
__name(normalizeAndValidateMainField, "normalizeAndValidateMainField");
|
|
31005
30766
|
function normalizeAndValidateBaseDirField(configPath, rawDir) {
|
|
31006
|
-
const configDir =
|
|
30767
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
31007
30768
|
if (rawDir !== void 0) if (typeof rawDir === "string") {
|
|
31008
|
-
const directory =
|
|
31009
|
-
return
|
|
30769
|
+
const directory = path3.resolve(configDir);
|
|
30770
|
+
return path3.resolve(directory, rawDir);
|
|
31010
30771
|
} else return rawDir;
|
|
31011
30772
|
else return;
|
|
31012
30773
|
}
|
|
31013
30774
|
__name(normalizeAndValidateBaseDirField, "normalizeAndValidateBaseDirField");
|
|
31014
30775
|
function normalizeAndValidatePagesBuildOutputDir(configPath, rawPagesDir) {
|
|
31015
|
-
const configDir =
|
|
30776
|
+
const configDir = path3.dirname(configPath ?? "wrangler.toml");
|
|
31016
30777
|
if (rawPagesDir !== void 0) if (typeof rawPagesDir === "string") {
|
|
31017
|
-
const directory =
|
|
31018
|
-
return
|
|
30778
|
+
const directory = path3.resolve(configDir);
|
|
30779
|
+
return path3.resolve(directory, rawPagesDir);
|
|
31019
30780
|
} else return rawPagesDir;
|
|
31020
30781
|
else return;
|
|
31021
30782
|
}
|
|
@@ -31068,7 +30829,7 @@ function normalizeAndValidateSite(diagnostics, configPath, rawConfig, mainEntryP
|
|
|
31068
30829
|
validateOptionalProperty(diagnostics, "site", "entry-point", rawConfig.site["entry-point"], "string");
|
|
31069
30830
|
deprecated(diagnostics, rawConfig, `site.entry-point`, `Delete the \`site.entry-point\` field, then add the top level \`main\` field to your configuration file:
|
|
31070
30831
|
\`\`\`
|
|
31071
|
-
main = "${
|
|
30832
|
+
main = "${path3.join(String(rawConfig.site["entry-point"]) || "workers-site", path3.extname(String(rawConfig.site["entry-point"]) || "workers-site") ? "" : "index.js")}"
|
|
31072
30833
|
\`\`\``, false, void 0, "warning");
|
|
31073
30834
|
let siteEntryPoint = rawConfig.site["entry-point"];
|
|
31074
30835
|
if (!mainEntryPoint && !siteEntryPoint) {
|
|
@@ -31081,7 +30842,7 @@ main = "workers-site/index.js"
|
|
|
31081
30842
|
} else if (mainEntryPoint && siteEntryPoint) diagnostics.errors.push(`Don't define both the \`main\` and \`site.entry-point\` fields in your configuration.
|
|
31082
30843
|
They serve the same purpose: to point to the entry-point of your worker.
|
|
31083
30844
|
Delete the deprecated \`site.entry-point\` field from your config.`);
|
|
31084
|
-
if (configPath && siteEntryPoint) siteEntryPoint =
|
|
30845
|
+
if (configPath && siteEntryPoint) siteEntryPoint = path3.relative(process.cwd(), path3.join(path3.dirname(configPath), siteEntryPoint));
|
|
31085
30846
|
return {
|
|
31086
30847
|
bucket,
|
|
31087
30848
|
"entry-point": siteEntryPoint,
|
|
@@ -31113,7 +30874,7 @@ function normalizeAndValidateModulePaths(diagnostics, configPath, field, rawMapp
|
|
|
31113
30874
|
if (rawMapping === void 0) return;
|
|
31114
30875
|
const mapping = {};
|
|
31115
30876
|
for (const [name, filePath] of Object.entries(rawMapping)) if (isString$2(diagnostics, `${field}['${name}']`, filePath, void 0)) {
|
|
31116
|
-
if (configPath) mapping[name] = configPath ?
|
|
30877
|
+
if (configPath) mapping[name] = configPath ? path3.relative(process.cwd(), path3.join(path3.dirname(configPath), filePath)) : filePath;
|
|
31117
30878
|
}
|
|
31118
30879
|
return mapping;
|
|
31119
30880
|
}
|
|
@@ -31361,7 +31122,7 @@ function normalizeAndValidateEnvironment(diagnostics, configPath, rawEnv, isDisp
|
|
|
31361
31122
|
__name(normalizeAndValidateEnvironment, "normalizeAndValidateEnvironment");
|
|
31362
31123
|
function validateAndNormalizeTsconfig(diagnostics, topLevelEnv, rawEnv, configPath) {
|
|
31363
31124
|
const tsconfig = inheritable(diagnostics, topLevelEnv, rawEnv, "tsconfig", isString$2, void 0);
|
|
31364
|
-
return configPath && tsconfig ?
|
|
31125
|
+
return configPath && tsconfig ? path3.relative(process.cwd(), path3.join(path3.dirname(configPath), tsconfig)) : tsconfig;
|
|
31365
31126
|
}
|
|
31366
31127
|
__name(validateAndNormalizeTsconfig, "validateAndNormalizeTsconfig");
|
|
31367
31128
|
var validateAndNormalizeRules = /* @__PURE__ */ __name((diagnostics, topLevelEnv, rawEnv, envName) => {
|
|
@@ -31617,6 +31378,26 @@ var validateWorkflowBinding = /* @__PURE__ */ __name((diagnostics, field, value)
|
|
|
31617
31378
|
diagnostics.errors.push(`"${field}" bindings should, optionally, have a boolean "remote" field but got ${JSON.stringify(value)}.`);
|
|
31618
31379
|
isValid2 = false;
|
|
31619
31380
|
}
|
|
31381
|
+
if (hasProperty(value, "schedules") && value.schedules !== void 0) if (typeof value.schedules === "string") {
|
|
31382
|
+
if (value.schedules.length === 0) {
|
|
31383
|
+
diagnostics.errors.push(`"${field}" bindings "schedules" field must not be an empty string.`);
|
|
31384
|
+
isValid2 = false;
|
|
31385
|
+
}
|
|
31386
|
+
} else if (Array.isArray(value.schedules)) {
|
|
31387
|
+
if (value.schedules.length === 0) {
|
|
31388
|
+
diagnostics.errors.push(`"${field}" bindings "schedules" field must not be an empty array.`);
|
|
31389
|
+
isValid2 = false;
|
|
31390
|
+
} else if (!value.schedules.every((s) => typeof s === "string")) {
|
|
31391
|
+
diagnostics.errors.push(`"${field}" bindings should, optionally, have a string or array of strings "schedules" field but got ${JSON.stringify(value)}.`);
|
|
31392
|
+
isValid2 = false;
|
|
31393
|
+
} else if (value.schedules.some((s) => s === "")) {
|
|
31394
|
+
diagnostics.errors.push(`"${field}" bindings "schedules" field must not contain empty strings.`);
|
|
31395
|
+
isValid2 = false;
|
|
31396
|
+
}
|
|
31397
|
+
} else {
|
|
31398
|
+
diagnostics.errors.push(`"${field}" bindings should, optionally, have a string or array of strings "schedules" field but got ${JSON.stringify(value)}.`);
|
|
31399
|
+
isValid2 = false;
|
|
31400
|
+
}
|
|
31620
31401
|
if (hasProperty(value, "limits") && value.limits !== void 0) if (typeof value.limits !== "object" || value.limits === null || Array.isArray(value.limits)) {
|
|
31621
31402
|
diagnostics.errors.push(`"${field}" bindings should, optionally, have an object "limits" field but got ${JSON.stringify(value)}.`);
|
|
31622
31403
|
isValid2 = false;
|
|
@@ -31636,7 +31417,8 @@ var validateWorkflowBinding = /* @__PURE__ */ __name((diagnostics, field, value)
|
|
|
31636
31417
|
"class_name",
|
|
31637
31418
|
"script_name",
|
|
31638
31419
|
"remote",
|
|
31639
|
-
"limits"
|
|
31420
|
+
"limits",
|
|
31421
|
+
"schedules"
|
|
31640
31422
|
]);
|
|
31641
31423
|
return isValid2;
|
|
31642
31424
|
}, "validateWorkflowBinding");
|
|
@@ -31838,9 +31620,9 @@ function validateContainerApp(envName, topLevelName, configPath) {
|
|
|
31838
31620
|
let resolvedBuildContextPath = void 0;
|
|
31839
31621
|
try {
|
|
31840
31622
|
if (isDockerfile(resolvedImage, configPath)) {
|
|
31841
|
-
const baseDir = configPath ?
|
|
31842
|
-
resolvedImage =
|
|
31843
|
-
resolvedBuildContextPath = containerAppOptional.image_build_context ?
|
|
31623
|
+
const baseDir = configPath ? path3.dirname(configPath) : process.cwd();
|
|
31624
|
+
resolvedImage = path3.resolve(baseDir, resolvedImage);
|
|
31625
|
+
resolvedBuildContextPath = containerAppOptional.image_build_context ? path3.resolve(baseDir, containerAppOptional.image_build_context) : path3.dirname(resolvedImage);
|
|
31844
31626
|
}
|
|
31845
31627
|
} catch (err) {
|
|
31846
31628
|
if (err instanceof Error && err.message) diagnostics.errors.push(err.message);
|
|
@@ -32979,9 +32761,9 @@ function isRemoteValid(targetObject, fieldPath, diagnostics) {
|
|
|
32979
32761
|
}
|
|
32980
32762
|
__name(isRemoteValid, "isRemoteValid");
|
|
32981
32763
|
function isDockerfile(imagePath, configPath) {
|
|
32982
|
-
const baseDir = configPath ?
|
|
32983
|
-
const maybeDockerfile =
|
|
32984
|
-
if (
|
|
32764
|
+
const baseDir = configPath ? path3.dirname(configPath) : process.cwd();
|
|
32765
|
+
const maybeDockerfile = path3.resolve(baseDir, imagePath);
|
|
32766
|
+
if (fs2.existsSync(maybeDockerfile)) {
|
|
32985
32767
|
if (isDirectory(maybeDockerfile)) throw new UserError(`${imagePath} is a directory, you should specify a path to the Dockerfile`, { telemetryMessage: false });
|
|
32986
32768
|
return true;
|
|
32987
32769
|
}
|
|
@@ -32999,6 +32781,53 @@ function isDockerfile(imagePath, configPath) {
|
|
|
32999
32781
|
return false;
|
|
33000
32782
|
}
|
|
33001
32783
|
__name(isDockerfile, "isDockerfile");
|
|
32784
|
+
var BINDING_LOCAL_SUPPORT = {
|
|
32785
|
+
plain_text: "local-only",
|
|
32786
|
+
secret_text: "local-only",
|
|
32787
|
+
json: "local-only",
|
|
32788
|
+
wasm_module: "local-only",
|
|
32789
|
+
text_blob: "local-only",
|
|
32790
|
+
data_blob: "local-only",
|
|
32791
|
+
version_metadata: "local-only",
|
|
32792
|
+
inherit: "local-only",
|
|
32793
|
+
logfwdr: "local-only",
|
|
32794
|
+
assets: "local-only",
|
|
32795
|
+
unsafe_hello_world: "local-only",
|
|
32796
|
+
durable_object_namespace: "local-only",
|
|
32797
|
+
hyperdrive: "local-only",
|
|
32798
|
+
fetcher: "local-only",
|
|
32799
|
+
analytics_engine: "local-only",
|
|
32800
|
+
secrets_store_secret: "local-only",
|
|
32801
|
+
ratelimit: "local-only",
|
|
32802
|
+
worker_loader: "local-only",
|
|
32803
|
+
kv_namespace: "local-and-remote",
|
|
32804
|
+
r2_bucket: "local-and-remote",
|
|
32805
|
+
d1: "local-and-remote",
|
|
32806
|
+
workflow: "local-and-remote",
|
|
32807
|
+
browser: "local-and-remote",
|
|
32808
|
+
images: "local-and-remote",
|
|
32809
|
+
stream: "local-and-remote",
|
|
32810
|
+
send_email: "local-and-remote",
|
|
32811
|
+
pipeline: "local-and-remote",
|
|
32812
|
+
service: "local-and-remote",
|
|
32813
|
+
queue: "local-and-remote",
|
|
32814
|
+
vectorize: "remote",
|
|
32815
|
+
mtls_certificate: "remote",
|
|
32816
|
+
dispatch_namespace: "remote",
|
|
32817
|
+
ai: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
32818
|
+
ai_search: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
32819
|
+
ai_search_namespace: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
32820
|
+
media: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
32821
|
+
artifacts: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
32822
|
+
flagship: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
32823
|
+
vpc_service: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator",
|
|
32824
|
+
vpc_network: "DO-NOT-USE-this-resource-will-never-have-a-local-simulator"
|
|
32825
|
+
};
|
|
32826
|
+
function getBindingLocalSupport(type) {
|
|
32827
|
+
if (type in BINDING_LOCAL_SUPPORT) return BINDING_LOCAL_SUPPORT[type];
|
|
32828
|
+
return "local-only";
|
|
32829
|
+
}
|
|
32830
|
+
__name(getBindingLocalSupport, "getBindingLocalSupport");
|
|
33002
32831
|
var supportedPagesConfigFields = [
|
|
33003
32832
|
"pages_build_output_dir",
|
|
33004
32833
|
"name",
|
|
@@ -33080,6 +32909,54 @@ Pages requires Durable Object bindings to specify the name of the Worker where t
|
|
|
33080
32909
|
}
|
|
33081
32910
|
}
|
|
33082
32911
|
__name(validateDurableObjectBinding2, "validateDurableObjectBinding");
|
|
32912
|
+
var import_signal_exit = __toESM(require_signal_exit());
|
|
32913
|
+
function getWranglerHiddenDirPath(projectRoot) {
|
|
32914
|
+
projectRoot ??= process.cwd();
|
|
32915
|
+
return path3.join(projectRoot, ".wrangler");
|
|
32916
|
+
}
|
|
32917
|
+
__name(getWranglerHiddenDirPath, "getWranglerHiddenDirPath");
|
|
32918
|
+
var STALE_WRANGLER_TMP_DIR_MS = 1440 * 60 * 1e3;
|
|
32919
|
+
var sweptTmpRoots = /* @__PURE__ */ new Set();
|
|
32920
|
+
function sweepStaleWranglerTmpDirs(tmpRoot) {
|
|
32921
|
+
if (sweptTmpRoots.has(tmpRoot)) return;
|
|
32922
|
+
sweptTmpRoots.add(tmpRoot);
|
|
32923
|
+
let entries;
|
|
32924
|
+
try {
|
|
32925
|
+
entries = fs2.readdirSync(tmpRoot, { withFileTypes: true });
|
|
32926
|
+
} catch {
|
|
32927
|
+
return;
|
|
32928
|
+
}
|
|
32929
|
+
const cutoff = Date.now() - STALE_WRANGLER_TMP_DIR_MS;
|
|
32930
|
+
for (const entry of entries) {
|
|
32931
|
+
if (!entry.isDirectory()) continue;
|
|
32932
|
+
const entryPath = path3.join(tmpRoot, entry.name);
|
|
32933
|
+
try {
|
|
32934
|
+
if (fs2.statSync(entryPath).mtimeMs < cutoff) removeDirSync(entryPath);
|
|
32935
|
+
} catch {}
|
|
32936
|
+
}
|
|
32937
|
+
}
|
|
32938
|
+
__name(sweepStaleWranglerTmpDirs, "sweepStaleWranglerTmpDirs");
|
|
32939
|
+
function getWranglerTmpDir(projectRoot, prefix, cleanup = true) {
|
|
32940
|
+
const tmpRoot = path3.join(getWranglerHiddenDirPath(projectRoot), "tmp");
|
|
32941
|
+
fs2.mkdirSync(tmpRoot, { recursive: true });
|
|
32942
|
+
sweepStaleWranglerTmpDirs(tmpRoot);
|
|
32943
|
+
const tmpPrefix = path3.join(tmpRoot, `${prefix}-`);
|
|
32944
|
+
const tmpDir = fs2.realpathSync(fs2.mkdtempSync(tmpPrefix));
|
|
32945
|
+
const cleanupDir = /* @__PURE__ */ __name(() => {
|
|
32946
|
+
if (cleanup) try {
|
|
32947
|
+
removeDirSync(tmpDir);
|
|
32948
|
+
} catch {}
|
|
32949
|
+
}, "cleanupDir");
|
|
32950
|
+
const removeExitListener = (0, import_signal_exit.default)(cleanupDir);
|
|
32951
|
+
return {
|
|
32952
|
+
path: tmpDir,
|
|
32953
|
+
remove() {
|
|
32954
|
+
removeExitListener();
|
|
32955
|
+
cleanupDir();
|
|
32956
|
+
}
|
|
32957
|
+
};
|
|
32958
|
+
}
|
|
32959
|
+
__name(getWranglerTmpDir, "getWranglerTmpDir");
|
|
33083
32960
|
var import_command_exists = __toESM(require_command_exists2());
|
|
33084
32961
|
var UPDATE_SERVICE_URL = "https://update.argotunnel.com";
|
|
33085
32962
|
var CLOUDFLARED_VERSION_PATTERN = /^\d{4}\.\d+\.\d+$/;
|
|
@@ -33830,8 +33707,1674 @@ var require_picocolors = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnp
|
|
|
33830
33707
|
}) });
|
|
33831
33708
|
|
|
33832
33709
|
//#endregion
|
|
33833
|
-
//#region
|
|
33710
|
+
//#region ../../node_modules/.pnpm/qr@0.6.0/node_modules/qr/index.js
|
|
33834
33711
|
var import_picocolors$5 = /* @__PURE__ */ __toESM$1(require_picocolors(), 1);
|
|
33712
|
+
/*!
|
|
33713
|
+
Copyright (c) 2023 Paul Miller (paulmillr.com)
|
|
33714
|
+
The library paulmillr-qr is dual-licensed under the Apache 2.0 OR MIT license.
|
|
33715
|
+
You can select a license of your choice.
|
|
33716
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
33717
|
+
you may not use this file except in compliance with the License.
|
|
33718
|
+
You may obtain a copy of the License at
|
|
33719
|
+
|
|
33720
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
33721
|
+
|
|
33722
|
+
Unless required by applicable law or agreed to in writing, software
|
|
33723
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
33724
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
33725
|
+
See the License for the specific language governing permissions and
|
|
33726
|
+
limitations under the License.
|
|
33727
|
+
*/
|
|
33728
|
+
const chCodes = {
|
|
33729
|
+
newline: 10,
|
|
33730
|
+
reset: 27
|
|
33731
|
+
};
|
|
33732
|
+
function assertNumber(n$1) {
|
|
33733
|
+
if (!Number.isSafeInteger(n$1)) throw new Error(`integer expected: ${n$1}`);
|
|
33734
|
+
}
|
|
33735
|
+
function validateVersion(ver) {
|
|
33736
|
+
if (!Number.isSafeInteger(ver) || ver < 1 || ver > 40) throw new Error(`Invalid version=${ver}. Expected number [1..40]`);
|
|
33737
|
+
}
|
|
33738
|
+
function bin(dec, pad) {
|
|
33739
|
+
return dec.toString(2).padStart(pad, "0");
|
|
33740
|
+
}
|
|
33741
|
+
function mod(a, b) {
|
|
33742
|
+
const result = a % b;
|
|
33743
|
+
return result >= 0 ? result : b + result;
|
|
33744
|
+
}
|
|
33745
|
+
function fillArr(length, val) {
|
|
33746
|
+
return new Array(length).fill(val);
|
|
33747
|
+
}
|
|
33748
|
+
function popcnt(n$1) {
|
|
33749
|
+
n$1 = n$1 - (n$1 >>> 1 & 1431655765);
|
|
33750
|
+
n$1 = (n$1 & 858993459) + (n$1 >>> 2 & 858993459);
|
|
33751
|
+
return (n$1 + (n$1 >>> 4) & 252645135) * 16843009 >>> 24;
|
|
33752
|
+
}
|
|
33753
|
+
/**
|
|
33754
|
+
* Interleaves byte blocks.
|
|
33755
|
+
* @param blocks [[1, 2, 3], [4, 5, 6]]
|
|
33756
|
+
* @returns [1, 4, 2, 5, 3, 6]
|
|
33757
|
+
*/
|
|
33758
|
+
function interleaveBytes(blocks) {
|
|
33759
|
+
let maxLen = 0;
|
|
33760
|
+
let totalLen = 0;
|
|
33761
|
+
for (const block of blocks) {
|
|
33762
|
+
maxLen = Math.max(maxLen, block.length);
|
|
33763
|
+
totalLen += block.length;
|
|
33764
|
+
}
|
|
33765
|
+
const result = new Uint8Array(totalLen);
|
|
33766
|
+
let idx = 0;
|
|
33767
|
+
for (let i$1 = 0; i$1 < maxLen; i$1++) for (const block of blocks) if (i$1 < block.length) result[idx++] = block[i$1];
|
|
33768
|
+
return result;
|
|
33769
|
+
}
|
|
33770
|
+
function best() {
|
|
33771
|
+
let best$1;
|
|
33772
|
+
let bestScore = Infinity;
|
|
33773
|
+
return {
|
|
33774
|
+
add(score, value) {
|
|
33775
|
+
if (score >= bestScore) return;
|
|
33776
|
+
best$1 = value;
|
|
33777
|
+
bestScore = score;
|
|
33778
|
+
},
|
|
33779
|
+
get: () => best$1,
|
|
33780
|
+
score: () => bestScore
|
|
33781
|
+
};
|
|
33782
|
+
}
|
|
33783
|
+
function alphabet(alphabet$1) {
|
|
33784
|
+
return Object.freeze({
|
|
33785
|
+
has: (char) => alphabet$1.includes(char),
|
|
33786
|
+
decode: (input) => {
|
|
33787
|
+
if (!Array.isArray(input) || input.length && typeof input[0] !== "string") throw new Error("alphabet.decode input should be array of strings");
|
|
33788
|
+
return input.map((letter) => {
|
|
33789
|
+
if (typeof letter !== "string") throw new Error(`alphabet.decode: not string element=${letter}`);
|
|
33790
|
+
const index = alphabet$1.indexOf(letter);
|
|
33791
|
+
if (index === -1) throw new Error(`Unknown letter: "${letter}". Allowed: ${alphabet$1}`);
|
|
33792
|
+
return index;
|
|
33793
|
+
});
|
|
33794
|
+
},
|
|
33795
|
+
encode: (digits) => {
|
|
33796
|
+
if (!Array.isArray(digits) || digits.length && typeof digits[0] !== "number") throw new Error("alphabet.encode input should be an array of numbers");
|
|
33797
|
+
return digits.map((i$1) => {
|
|
33798
|
+
assertNumber(i$1);
|
|
33799
|
+
if (i$1 < 0 || i$1 >= alphabet$1.length) throw new Error(`Digit index outside alphabet: ${i$1} (alphabet: ${alphabet$1.length})`);
|
|
33800
|
+
return alphabet$1[i$1];
|
|
33801
|
+
});
|
|
33802
|
+
}
|
|
33803
|
+
});
|
|
33804
|
+
}
|
|
33805
|
+
function transpose32(a) {
|
|
33806
|
+
if (a.length !== 32) throw new Error("expects 32 element matrix");
|
|
33807
|
+
const masks = [
|
|
33808
|
+
1431655765,
|
|
33809
|
+
858993459,
|
|
33810
|
+
252645135,
|
|
33811
|
+
16711935,
|
|
33812
|
+
65535
|
|
33813
|
+
];
|
|
33814
|
+
for (let stage = 0; stage < 5; stage++) {
|
|
33815
|
+
const m = masks[stage] >>> 0;
|
|
33816
|
+
const s = 1 << stage;
|
|
33817
|
+
const step = s << 1;
|
|
33818
|
+
for (let i$1 = 0; i$1 < 32; i$1 += step) for (let k = 0; k < s; k++) {
|
|
33819
|
+
const i0 = i$1 + k;
|
|
33820
|
+
const i1 = i0 + s;
|
|
33821
|
+
const x = a[i0] >>> 0;
|
|
33822
|
+
const y = a[i1] >>> 0;
|
|
33823
|
+
const t$5 = (x >>> s ^ y) & m;
|
|
33824
|
+
a[i0] = (x ^ t$5 << s) >>> 0;
|
|
33825
|
+
a[i1] = (y ^ t$5) >>> 0;
|
|
33826
|
+
}
|
|
33827
|
+
}
|
|
33828
|
+
}
|
|
33829
|
+
const bitMask = (x) => 1 << (x & 31) >>> 0;
|
|
33830
|
+
const rangeMask = (shift, len) => {
|
|
33831
|
+
if (len === 0) return 0;
|
|
33832
|
+
if (len === 32) return 4294967295;
|
|
33833
|
+
return (1 << len) - 1 << shift >>> 0;
|
|
33834
|
+
};
|
|
33835
|
+
/**
|
|
33836
|
+
* Mutable monochrome bitmap used as the internal QR representation.
|
|
33837
|
+
* @param size - Square edge length or explicit bitmap dimensions.
|
|
33838
|
+
* @param data - Optional row-major pixel matrix using `true`, `false`, or `undefined`.
|
|
33839
|
+
* @example
|
|
33840
|
+
* Create a bitmap, then scale it for display.
|
|
33841
|
+
* ```ts
|
|
33842
|
+
* import { Bitmap } from 'qr';
|
|
33843
|
+
* const bitmap = Bitmap.fromString('X \n X');
|
|
33844
|
+
* bitmap.scale(2);
|
|
33845
|
+
* ```
|
|
33846
|
+
*/
|
|
33847
|
+
var Bitmap = class Bitmap {
|
|
33848
|
+
static size(size, limit) {
|
|
33849
|
+
if (typeof size === "number") size = {
|
|
33850
|
+
height: size,
|
|
33851
|
+
width: size
|
|
33852
|
+
};
|
|
33853
|
+
if (!Number.isSafeInteger(size.height) && size.height !== Infinity) throw new Error(`Bitmap: invalid height=${size.height} (${typeof size.height})`);
|
|
33854
|
+
if (!Number.isSafeInteger(size.width) && size.width !== Infinity) throw new Error(`Bitmap: invalid width=${size.width} (${typeof size.width})`);
|
|
33855
|
+
if (limit !== void 0) size = {
|
|
33856
|
+
width: Math.min(size.width, limit.width),
|
|
33857
|
+
height: Math.min(size.height, limit.height)
|
|
33858
|
+
};
|
|
33859
|
+
return size;
|
|
33860
|
+
}
|
|
33861
|
+
static fromString(s) {
|
|
33862
|
+
s = s.replace(/^\n+/g, "").replace(/\n+$/g, "");
|
|
33863
|
+
const lines = s.split(String.fromCharCode(chCodes.newline));
|
|
33864
|
+
const height = lines.length;
|
|
33865
|
+
let width;
|
|
33866
|
+
const rows = [];
|
|
33867
|
+
for (const line of lines) {
|
|
33868
|
+
const row = line.split("").map((i$1) => {
|
|
33869
|
+
if (i$1 === "X") return true;
|
|
33870
|
+
if (i$1 === " ") return false;
|
|
33871
|
+
if (i$1 === "?") return void 0;
|
|
33872
|
+
throw new Error(`Bitmap.fromString: unknown symbol=${i$1}`);
|
|
33873
|
+
});
|
|
33874
|
+
if (width !== void 0 && row.length !== width) throw new Error(`Bitmap.fromString different row sizes: width=${width} cur=${row.length}`);
|
|
33875
|
+
width = row.length;
|
|
33876
|
+
rows.push(row);
|
|
33877
|
+
}
|
|
33878
|
+
if (width === void 0) width = 0;
|
|
33879
|
+
return new Bitmap({
|
|
33880
|
+
height,
|
|
33881
|
+
width
|
|
33882
|
+
}, rows);
|
|
33883
|
+
}
|
|
33884
|
+
defined;
|
|
33885
|
+
value;
|
|
33886
|
+
tailMask;
|
|
33887
|
+
words;
|
|
33888
|
+
fullWords;
|
|
33889
|
+
height;
|
|
33890
|
+
width;
|
|
33891
|
+
constructor(size, data$1) {
|
|
33892
|
+
const { height, width } = Bitmap.size(size);
|
|
33893
|
+
if (!Number.isSafeInteger(height) || height <= 0) throw new Error(`Bitmap: invalid height=${height}, expected positive safe integer dimension`);
|
|
33894
|
+
if (!Number.isSafeInteger(width) || width <= 0) throw new Error(`Bitmap: invalid width=${width}, expected positive safe integer dimension`);
|
|
33895
|
+
this.height = height;
|
|
33896
|
+
this.width = width;
|
|
33897
|
+
this.tailMask = rangeMask(0, width & 31 || 32);
|
|
33898
|
+
this.words = Math.ceil(width / 32) | 0;
|
|
33899
|
+
this.fullWords = Math.floor(width / 32) | 0;
|
|
33900
|
+
this.value = new Uint32Array(this.words * height);
|
|
33901
|
+
this.defined = new Uint32Array(this.value.length);
|
|
33902
|
+
if (data$1) {
|
|
33903
|
+
if (data$1.length !== height) throw new Error(`Bitmap: data height mismatch: exp=${height} got=${data$1.length}`);
|
|
33904
|
+
for (let y = 0; y < height; y++) {
|
|
33905
|
+
const row = data$1[y];
|
|
33906
|
+
if (!row || row.length !== width) throw new Error(`Bitmap: data width mismatch at y=${y}: exp=${width} got=${row?.length}`);
|
|
33907
|
+
for (let x = 0; x < width; x++) this.set(x, y, row[x]);
|
|
33908
|
+
}
|
|
33909
|
+
}
|
|
33910
|
+
}
|
|
33911
|
+
point(p$1) {
|
|
33912
|
+
return this.get(p$1.x, p$1.y);
|
|
33913
|
+
}
|
|
33914
|
+
isInside(p$1) {
|
|
33915
|
+
return 0 <= p$1.x && p$1.x < this.width && 0 <= p$1.y && p$1.y < this.height;
|
|
33916
|
+
}
|
|
33917
|
+
size(offset) {
|
|
33918
|
+
if (!offset) return {
|
|
33919
|
+
height: this.height,
|
|
33920
|
+
width: this.width
|
|
33921
|
+
};
|
|
33922
|
+
const { x, y } = this.xy(offset);
|
|
33923
|
+
return {
|
|
33924
|
+
height: this.height - y,
|
|
33925
|
+
width: this.width - x
|
|
33926
|
+
};
|
|
33927
|
+
}
|
|
33928
|
+
xy(c) {
|
|
33929
|
+
if (typeof c === "number") c = {
|
|
33930
|
+
x: c,
|
|
33931
|
+
y: c
|
|
33932
|
+
};
|
|
33933
|
+
if (!Number.isSafeInteger(c.x)) throw new Error(`Bitmap: invalid x=${c.x}`);
|
|
33934
|
+
if (!Number.isSafeInteger(c.y)) throw new Error(`Bitmap: invalid y=${c.y}`);
|
|
33935
|
+
c.x = mod(c.x, this.width);
|
|
33936
|
+
c.y = mod(c.y, this.height);
|
|
33937
|
+
return c;
|
|
33938
|
+
}
|
|
33939
|
+
/**
|
|
33940
|
+
* Return pixel bit index
|
|
33941
|
+
*/
|
|
33942
|
+
wordIndex(x, y) {
|
|
33943
|
+
return y * this.words + (x >>> 5);
|
|
33944
|
+
}
|
|
33945
|
+
bitIndex(x, y) {
|
|
33946
|
+
return {
|
|
33947
|
+
word: this.wordIndex(x, y),
|
|
33948
|
+
bit: x & 31
|
|
33949
|
+
};
|
|
33950
|
+
}
|
|
33951
|
+
isDefined(x, y) {
|
|
33952
|
+
const wi = this.wordIndex(x, y);
|
|
33953
|
+
const m = bitMask(x);
|
|
33954
|
+
return (this.defined[wi] & m) !== 0;
|
|
33955
|
+
}
|
|
33956
|
+
get(x, y) {
|
|
33957
|
+
const wi = this.wordIndex(x, y);
|
|
33958
|
+
const m = bitMask(x);
|
|
33959
|
+
return (this.value[wi] & m) !== 0;
|
|
33960
|
+
}
|
|
33961
|
+
maskWord(wi, mask, v) {
|
|
33962
|
+
const { defined, value } = this;
|
|
33963
|
+
defined[wi] |= mask;
|
|
33964
|
+
value[wi] = value[wi] & ~mask | -v & mask;
|
|
33965
|
+
}
|
|
33966
|
+
set(x, y, v) {
|
|
33967
|
+
if (v === void 0) return;
|
|
33968
|
+
this.maskWord(this.wordIndex(x, y), bitMask(x), v);
|
|
33969
|
+
}
|
|
33970
|
+
fillRectConst(x0, y0, w, h, v) {
|
|
33971
|
+
if (w <= 0 || h <= 0) return;
|
|
33972
|
+
if (v === void 0) return;
|
|
33973
|
+
const { value, defined, words } = this;
|
|
33974
|
+
const startWord = x0 >>> 5;
|
|
33975
|
+
const endWord = x0 + w - 1 >>> 5;
|
|
33976
|
+
const startBit = x0 & 31;
|
|
33977
|
+
const endBit = x0 + w - 1 & 31;
|
|
33978
|
+
for (let ry = 0; ry < h; ry++) {
|
|
33979
|
+
const rowBase = (y0 + ry) * words;
|
|
33980
|
+
if (startWord === endWord) {
|
|
33981
|
+
const mask = rangeMask(startBit, endBit - startBit + 1);
|
|
33982
|
+
this.maskWord(rowBase + startWord, mask, v);
|
|
33983
|
+
continue;
|
|
33984
|
+
}
|
|
33985
|
+
this.maskWord(rowBase + startWord, rangeMask(startBit, 32 - startBit), v);
|
|
33986
|
+
for (let i$1 = startWord + 1; i$1 < endWord; i$1++) {
|
|
33987
|
+
defined[rowBase + i$1] = 4294967295;
|
|
33988
|
+
value[rowBase + i$1] = v ? 4294967295 : 0;
|
|
33989
|
+
}
|
|
33990
|
+
this.maskWord(rowBase + endWord, rangeMask(0, endBit + 1), v);
|
|
33991
|
+
}
|
|
33992
|
+
}
|
|
33993
|
+
rectWords(x, y, width, height, cb) {
|
|
33994
|
+
for (let yPos = 0; yPos < height; yPos++) {
|
|
33995
|
+
const Py = y + yPos;
|
|
33996
|
+
for (let xPos = 0; xPos < width;) {
|
|
33997
|
+
const bitX = x + xPos;
|
|
33998
|
+
const { bit, word } = this.bitIndex(bitX, Py);
|
|
33999
|
+
const bitsPerWord = Math.min(32 - bit, width - xPos);
|
|
34000
|
+
cb(word, bitX, xPos, yPos, bitsPerWord);
|
|
34001
|
+
xPos += bitsPerWord;
|
|
34002
|
+
}
|
|
34003
|
+
}
|
|
34004
|
+
}
|
|
34005
|
+
rect(c, size, fn) {
|
|
34006
|
+
const { x, y } = this.xy(c);
|
|
34007
|
+
const { height, width } = Bitmap.size(size, this.size({
|
|
34008
|
+
x,
|
|
34009
|
+
y
|
|
34010
|
+
}));
|
|
34011
|
+
if (typeof fn !== "function") {
|
|
34012
|
+
this.fillRectConst(x, y, width, height, fn);
|
|
34013
|
+
return this;
|
|
34014
|
+
}
|
|
34015
|
+
const { defined, value } = this;
|
|
34016
|
+
this.rectWords(x, y, width, height, (wi, bitX, xPos, yPos, n$1) => {
|
|
34017
|
+
let defWord = 0;
|
|
34018
|
+
let valWord = value[wi];
|
|
34019
|
+
for (let b = 0; b < n$1; b++) {
|
|
34020
|
+
const mask = bitMask(bitX + b);
|
|
34021
|
+
const res = fn({
|
|
34022
|
+
x: xPos + b,
|
|
34023
|
+
y: yPos
|
|
34024
|
+
}, (valWord & mask) !== 0);
|
|
34025
|
+
if (res === void 0) continue;
|
|
34026
|
+
defWord |= mask;
|
|
34027
|
+
valWord = valWord & ~mask | -res & mask;
|
|
34028
|
+
}
|
|
34029
|
+
defined[wi] |= defWord;
|
|
34030
|
+
value[wi] = valWord;
|
|
34031
|
+
});
|
|
34032
|
+
return this;
|
|
34033
|
+
}
|
|
34034
|
+
rectRead(c, size, fn) {
|
|
34035
|
+
const { x, y } = this.xy(c);
|
|
34036
|
+
const { height, width } = Bitmap.size(size, this.size({
|
|
34037
|
+
x,
|
|
34038
|
+
y
|
|
34039
|
+
}));
|
|
34040
|
+
const { value } = this;
|
|
34041
|
+
this.rectWords(x, y, width, height, (wi, bitX, xPos, yPos, n$1) => {
|
|
34042
|
+
const valWord = value[wi];
|
|
34043
|
+
for (let b = 0; b < n$1; b++) {
|
|
34044
|
+
const mask = bitMask(bitX + b);
|
|
34045
|
+
fn({
|
|
34046
|
+
x: xPos + b,
|
|
34047
|
+
y: yPos
|
|
34048
|
+
}, (valWord & mask) !== 0);
|
|
34049
|
+
}
|
|
34050
|
+
});
|
|
34051
|
+
return this;
|
|
34052
|
+
}
|
|
34053
|
+
hLine(c, len, value) {
|
|
34054
|
+
return this.rect(c, {
|
|
34055
|
+
width: len,
|
|
34056
|
+
height: 1
|
|
34057
|
+
}, value);
|
|
34058
|
+
}
|
|
34059
|
+
vLine(c, len, value) {
|
|
34060
|
+
return this.rect(c, {
|
|
34061
|
+
width: 1,
|
|
34062
|
+
height: len
|
|
34063
|
+
}, value);
|
|
34064
|
+
}
|
|
34065
|
+
border(border = 2, value) {
|
|
34066
|
+
if (!Number.isSafeInteger(border) || border <= 0) throw new Error(`Bitmap.border: invalid size=${border}`);
|
|
34067
|
+
const out = new Bitmap({
|
|
34068
|
+
height: this.height + 2 * border,
|
|
34069
|
+
width: this.width + 2 * border
|
|
34070
|
+
});
|
|
34071
|
+
out.rect(0, Infinity, value);
|
|
34072
|
+
out.embed({
|
|
34073
|
+
x: border,
|
|
34074
|
+
y: border
|
|
34075
|
+
}, this);
|
|
34076
|
+
return out;
|
|
34077
|
+
}
|
|
34078
|
+
embed(c, src$1) {
|
|
34079
|
+
const { x, y } = this.xy(c);
|
|
34080
|
+
const { height, width } = Bitmap.size(src$1.size(), this.size({
|
|
34081
|
+
x,
|
|
34082
|
+
y
|
|
34083
|
+
}));
|
|
34084
|
+
if (width <= 0 || height <= 0) return this;
|
|
34085
|
+
const { value, defined } = this;
|
|
34086
|
+
const { words: srcStride, value: srcValue } = src$1;
|
|
34087
|
+
for (let yPos = 0; yPos < height; yPos++) {
|
|
34088
|
+
const srcRow = yPos * srcStride;
|
|
34089
|
+
for (let xPos = 0; xPos < width;) {
|
|
34090
|
+
const dstX = x + xPos;
|
|
34091
|
+
const { word: dstWord, bit: dstBit } = this.bitIndex(dstX, y + yPos);
|
|
34092
|
+
const { word: srcWord, bit: srcBit } = src$1.bitIndex(xPos, yPos);
|
|
34093
|
+
const len = Math.min(32 - dstBit, width - xPos);
|
|
34094
|
+
const w0 = srcValue[srcWord];
|
|
34095
|
+
const w1 = srcBit && srcWord + 1 < srcRow + srcStride ? srcValue[srcWord + 1] : 0;
|
|
34096
|
+
const sVal = srcBit ? (w0 >>> srcBit | w1 << 32 - srcBit) >>> 0 : w0;
|
|
34097
|
+
const dstMask = rangeMask(dstBit, len);
|
|
34098
|
+
const valBits = (sVal & rangeMask(0, len)) << dstBit >>> 0;
|
|
34099
|
+
defined[dstWord] |= dstMask;
|
|
34100
|
+
value[dstWord] = value[dstWord] & ~dstMask | valBits;
|
|
34101
|
+
xPos += len;
|
|
34102
|
+
}
|
|
34103
|
+
}
|
|
34104
|
+
return this;
|
|
34105
|
+
}
|
|
34106
|
+
rectSlice(c, size = this.size()) {
|
|
34107
|
+
const { x, y } = this.xy(c);
|
|
34108
|
+
const { height, width } = Bitmap.size(size, this.size({
|
|
34109
|
+
x,
|
|
34110
|
+
y
|
|
34111
|
+
}));
|
|
34112
|
+
const rect = new Bitmap({
|
|
34113
|
+
height,
|
|
34114
|
+
width
|
|
34115
|
+
});
|
|
34116
|
+
this.rectRead({
|
|
34117
|
+
x,
|
|
34118
|
+
y
|
|
34119
|
+
}, {
|
|
34120
|
+
height,
|
|
34121
|
+
width
|
|
34122
|
+
}, (p$1, cur) => {
|
|
34123
|
+
if (this.isDefined(x + p$1.x, y + p$1.y)) rect.set(p$1.x, p$1.y, cur);
|
|
34124
|
+
});
|
|
34125
|
+
return rect;
|
|
34126
|
+
}
|
|
34127
|
+
transpose() {
|
|
34128
|
+
const { height, width, value, defined, words } = this;
|
|
34129
|
+
const dst = new Bitmap({
|
|
34130
|
+
height: width,
|
|
34131
|
+
width: height
|
|
34132
|
+
});
|
|
34133
|
+
const { words: dstStride, value: dstValue, defined: dstDefined, tailMask: dstTail } = dst;
|
|
34134
|
+
const tmpV = new Uint32Array(32);
|
|
34135
|
+
const tmpD = new Uint32Array(32);
|
|
34136
|
+
for (let by = 0; by < height; by += 32) for (let bx = 0; bx < words; bx++) {
|
|
34137
|
+
const rows = Math.min(32, height - by);
|
|
34138
|
+
for (let r$1 = 0; r$1 < rows; r$1++) {
|
|
34139
|
+
const wi = this.wordIndex(32 * bx, by + r$1);
|
|
34140
|
+
tmpV[r$1] = value[wi];
|
|
34141
|
+
tmpD[r$1] = defined[wi];
|
|
34142
|
+
}
|
|
34143
|
+
tmpV.fill(0, rows);
|
|
34144
|
+
tmpD.fill(0, rows);
|
|
34145
|
+
transpose32(tmpV);
|
|
34146
|
+
transpose32(tmpD);
|
|
34147
|
+
for (let i$1 = 0; i$1 < 32; i$1++) {
|
|
34148
|
+
const dstY = bx * 32 + i$1;
|
|
34149
|
+
if (dstY >= width) break;
|
|
34150
|
+
const dstPos = dst.wordIndex(by, dstY);
|
|
34151
|
+
const curMask = by >>> 5 === dstStride - 1 ? dstTail : 4294967295;
|
|
34152
|
+
dstValue[dstPos] = tmpV[i$1] & curMask;
|
|
34153
|
+
dstDefined[dstPos] = tmpD[i$1] & curMask;
|
|
34154
|
+
}
|
|
34155
|
+
}
|
|
34156
|
+
return dst;
|
|
34157
|
+
}
|
|
34158
|
+
negate() {
|
|
34159
|
+
const n$1 = this.defined.length;
|
|
34160
|
+
for (let i$1 = 0; i$1 < n$1; i$1++) {
|
|
34161
|
+
this.value[i$1] = ~this.value[i$1];
|
|
34162
|
+
this.defined[i$1] = 4294967295;
|
|
34163
|
+
}
|
|
34164
|
+
return this;
|
|
34165
|
+
}
|
|
34166
|
+
scale(factor) {
|
|
34167
|
+
if (!Number.isSafeInteger(factor) || factor > 1024) throw new Error(`invalid scale factor: ${factor}`);
|
|
34168
|
+
const { height, width } = this;
|
|
34169
|
+
return new Bitmap({
|
|
34170
|
+
height: factor * height,
|
|
34171
|
+
width: factor * width
|
|
34172
|
+
}).rect({
|
|
34173
|
+
x: 0,
|
|
34174
|
+
y: 0
|
|
34175
|
+
}, Infinity, ({ x, y }) => this.get(x / factor | 0, y / factor | 0));
|
|
34176
|
+
}
|
|
34177
|
+
clone() {
|
|
34178
|
+
const res = new Bitmap(this.size());
|
|
34179
|
+
res.defined.set(this.defined);
|
|
34180
|
+
res.value.set(this.value);
|
|
34181
|
+
return res;
|
|
34182
|
+
}
|
|
34183
|
+
assertDrawn() {
|
|
34184
|
+
const { height, width, defined, tailMask, fullWords, words } = this;
|
|
34185
|
+
if (!height || !width) return;
|
|
34186
|
+
for (let y = 0; y < height; y++) {
|
|
34187
|
+
const rowBase = y * words;
|
|
34188
|
+
for (let wi = 0; wi < fullWords; wi++) if (defined[rowBase + wi] !== 4294967295) throw new Error(`Invalid color type=undefined`);
|
|
34189
|
+
if (words !== fullWords && (defined[rowBase + fullWords] & tailMask) !== tailMask) throw new Error(`Invalid color type=undefined`);
|
|
34190
|
+
}
|
|
34191
|
+
}
|
|
34192
|
+
countPatternInRow(y, patternLen, ...patterns) {
|
|
34193
|
+
if (!Number.isSafeInteger(patternLen) || patternLen <= 0 || patternLen >= 32) throw new Error("wrong patternLen");
|
|
34194
|
+
const mask = (1 << patternLen) - 1;
|
|
34195
|
+
const { height, width, value, words } = this;
|
|
34196
|
+
if (!Number.isSafeInteger(y) || y < 0 || y >= height) return 0;
|
|
34197
|
+
let count = 0;
|
|
34198
|
+
const rowBase = this.wordIndex(0, y);
|
|
34199
|
+
for (let i$1 = 0, window = 0; i$1 < words; i$1++) {
|
|
34200
|
+
const w = value[rowBase + i$1];
|
|
34201
|
+
const bitEnd = i$1 === words - 1 ? width & 31 || 32 : 32;
|
|
34202
|
+
for (let b = 0; b < bitEnd; b++) {
|
|
34203
|
+
window = (window << 1 | w >>> b & 1) & mask;
|
|
34204
|
+
if (i$1 * 32 + b + 1 < patternLen) continue;
|
|
34205
|
+
for (const p$1 of patterns) {
|
|
34206
|
+
if (window !== p$1) continue;
|
|
34207
|
+
count++;
|
|
34208
|
+
break;
|
|
34209
|
+
}
|
|
34210
|
+
}
|
|
34211
|
+
}
|
|
34212
|
+
return count;
|
|
34213
|
+
}
|
|
34214
|
+
getRuns(y, fn) {
|
|
34215
|
+
const { height, width, value, words } = this;
|
|
34216
|
+
if (width === 0) return;
|
|
34217
|
+
if (!Number.isSafeInteger(y) || y < 0 || y >= height) return;
|
|
34218
|
+
let runLen = 0;
|
|
34219
|
+
let runValue;
|
|
34220
|
+
const rowBase = this.wordIndex(0, y);
|
|
34221
|
+
for (let i$1 = 0; i$1 < words; i$1++) {
|
|
34222
|
+
const word = value[rowBase + i$1];
|
|
34223
|
+
const bitEnd = i$1 === words - 1 ? width & 31 || 32 : 32;
|
|
34224
|
+
for (let b = 0; b < bitEnd; b++) {
|
|
34225
|
+
const bit = (word & 1 << b) !== 0;
|
|
34226
|
+
if (bit === runValue) {
|
|
34227
|
+
runLen++;
|
|
34228
|
+
continue;
|
|
34229
|
+
}
|
|
34230
|
+
if (runValue !== void 0) fn(runLen, runValue);
|
|
34231
|
+
runValue = bit;
|
|
34232
|
+
runLen = 1;
|
|
34233
|
+
}
|
|
34234
|
+
}
|
|
34235
|
+
if (runValue !== void 0) fn(runLen, runValue);
|
|
34236
|
+
}
|
|
34237
|
+
popcnt() {
|
|
34238
|
+
const { height, width, words, fullWords, tailMask } = this;
|
|
34239
|
+
if (!height || !width) return 0;
|
|
34240
|
+
let count = 0;
|
|
34241
|
+
for (let y = 0; y < height; y++) {
|
|
34242
|
+
const rowBase = y * words;
|
|
34243
|
+
for (let wi = 0; wi < fullWords; wi++) count += popcnt(this.value[rowBase + wi]);
|
|
34244
|
+
if (words !== fullWords) count += popcnt(this.value[rowBase + fullWords] & tailMask);
|
|
34245
|
+
}
|
|
34246
|
+
return count;
|
|
34247
|
+
}
|
|
34248
|
+
countBoxes2x2(y) {
|
|
34249
|
+
const { height, width, words } = this;
|
|
34250
|
+
if (width < 2 || !Number.isSafeInteger(y) || y < 0 || y + 1 >= height) return 0;
|
|
34251
|
+
const base0 = this.wordIndex(0, y);
|
|
34252
|
+
const base1 = this.wordIndex(0, y + 1);
|
|
34253
|
+
const validLast = (width & 31) === 0 ? 2147483647 : rangeMask(0, width - 1 & 31);
|
|
34254
|
+
let boxes = 0;
|
|
34255
|
+
for (let wi = 0; wi < words; wi++) {
|
|
34256
|
+
const a0 = this.value[base0 + wi];
|
|
34257
|
+
const a1 = this.value[base1 + wi];
|
|
34258
|
+
const eqV = ~(a0 ^ a1) >>> 0;
|
|
34259
|
+
const n0 = wi + 1 < words ? this.value[base0 + wi + 1] >>> 0 : 0;
|
|
34260
|
+
const eqH0 = ~(a0 ^ (a0 >>> 1 | (n0 & 1) << 31) >>> 0) >>> 0;
|
|
34261
|
+
const n1 = wi + 1 < words ? this.value[base1 + wi + 1] >>> 0 : 0;
|
|
34262
|
+
const eqH1 = ~(a1 ^ (a1 >>> 1 | (n1 & 1) << 31) >>> 0) >>> 0;
|
|
34263
|
+
let m = (eqV & eqH0 & eqH1) >>> 0;
|
|
34264
|
+
if (wi === words - 1) m &= validLast;
|
|
34265
|
+
boxes += popcnt(m);
|
|
34266
|
+
}
|
|
34267
|
+
return boxes;
|
|
34268
|
+
}
|
|
34269
|
+
toString() {
|
|
34270
|
+
const nl = String.fromCharCode(chCodes.newline);
|
|
34271
|
+
let out = "";
|
|
34272
|
+
for (let y = 0; y < this.height; y++) {
|
|
34273
|
+
let line = "";
|
|
34274
|
+
for (let x = 0; x < this.width; x++) {
|
|
34275
|
+
const v = this.get(x, y);
|
|
34276
|
+
line += !this.isDefined(x, y) ? "?" : v ? "X" : " ";
|
|
34277
|
+
}
|
|
34278
|
+
out += line + (y + 1 === this.height ? "" : nl);
|
|
34279
|
+
}
|
|
34280
|
+
return out;
|
|
34281
|
+
}
|
|
34282
|
+
toRaw() {
|
|
34283
|
+
const out = Array.from({ length: this.height }, () => new Array(this.width));
|
|
34284
|
+
for (let y = 0; y < this.height; y++) {
|
|
34285
|
+
const row = out[y];
|
|
34286
|
+
for (let x = 0; x < this.width; x++) row[x] = this.get(x, y);
|
|
34287
|
+
}
|
|
34288
|
+
return out;
|
|
34289
|
+
}
|
|
34290
|
+
toASCII() {
|
|
34291
|
+
const { height, width } = this;
|
|
34292
|
+
let out = "";
|
|
34293
|
+
for (let y = 0; y < height; y += 2) {
|
|
34294
|
+
for (let x = 0; x < width; x++) {
|
|
34295
|
+
const first = this.get(x, y);
|
|
34296
|
+
const second = y + 1 >= height ? true : this.get(x, y + 1);
|
|
34297
|
+
if (!first && !second) out += "█";
|
|
34298
|
+
else if (!first && second) out += "▀";
|
|
34299
|
+
else if (first && !second) out += "▄";
|
|
34300
|
+
else if (first && second) out += " ";
|
|
34301
|
+
}
|
|
34302
|
+
out += String.fromCharCode(chCodes.newline);
|
|
34303
|
+
}
|
|
34304
|
+
return out;
|
|
34305
|
+
}
|
|
34306
|
+
toTerm() {
|
|
34307
|
+
const cc = String.fromCharCode(chCodes.reset);
|
|
34308
|
+
const reset = cc + "[0m";
|
|
34309
|
+
const whiteBG = cc + "[1;47m " + reset;
|
|
34310
|
+
const darkBG = cc + `[40m ` + reset;
|
|
34311
|
+
const nl = String.fromCharCode(chCodes.newline);
|
|
34312
|
+
let out = "";
|
|
34313
|
+
for (let y = 0; y < this.height; y++) {
|
|
34314
|
+
for (let x = 0; x < this.width; x++) {
|
|
34315
|
+
const v = this.get(x, y);
|
|
34316
|
+
out += v ? darkBG : whiteBG;
|
|
34317
|
+
}
|
|
34318
|
+
out += nl;
|
|
34319
|
+
}
|
|
34320
|
+
return out;
|
|
34321
|
+
}
|
|
34322
|
+
toSVG(optimize = true) {
|
|
34323
|
+
let out = `<svg viewBox="0 0 ${this.width} ${this.height}" xmlns="http://www.w3.org/2000/svg">`;
|
|
34324
|
+
let pathData = "";
|
|
34325
|
+
let prevPoint;
|
|
34326
|
+
this.rectRead(0, Infinity, (point, val) => {
|
|
34327
|
+
if (!val) return;
|
|
34328
|
+
const { x, y } = point;
|
|
34329
|
+
if (!optimize) {
|
|
34330
|
+
out += `<rect x="${x}" y="${y}" width="1" height="1" />`;
|
|
34331
|
+
return;
|
|
34332
|
+
}
|
|
34333
|
+
let m = `M${x} ${y}`;
|
|
34334
|
+
if (prevPoint) {
|
|
34335
|
+
const relM = `m${x - prevPoint.x} ${y - prevPoint.y}`;
|
|
34336
|
+
if (relM.length <= m.length) m = relM;
|
|
34337
|
+
}
|
|
34338
|
+
const bH = x < 10 ? `H${x}` : "h-1";
|
|
34339
|
+
pathData += `${m}h1v1${bH}Z`;
|
|
34340
|
+
prevPoint = point;
|
|
34341
|
+
});
|
|
34342
|
+
if (optimize) out += `<path d="${pathData}"/>`;
|
|
34343
|
+
out += `</svg>`;
|
|
34344
|
+
return out;
|
|
34345
|
+
}
|
|
34346
|
+
toGIF() {
|
|
34347
|
+
const u16le = (i$1) => [i$1 & 255, i$1 >>> 8 & 255];
|
|
34348
|
+
const dims = [...u16le(this.width), ...u16le(this.height)];
|
|
34349
|
+
const data$1 = [];
|
|
34350
|
+
this.rectRead(0, Infinity, (_, cur) => data$1.push(+(cur === true)));
|
|
34351
|
+
const N = 126;
|
|
34352
|
+
const bytes = [
|
|
34353
|
+
71,
|
|
34354
|
+
73,
|
|
34355
|
+
70,
|
|
34356
|
+
56,
|
|
34357
|
+
55,
|
|
34358
|
+
97,
|
|
34359
|
+
...dims,
|
|
34360
|
+
246,
|
|
34361
|
+
0,
|
|
34362
|
+
0,
|
|
34363
|
+
255,
|
|
34364
|
+
255,
|
|
34365
|
+
255,
|
|
34366
|
+
...fillArr(381, 0),
|
|
34367
|
+
44,
|
|
34368
|
+
0,
|
|
34369
|
+
0,
|
|
34370
|
+
0,
|
|
34371
|
+
0,
|
|
34372
|
+
...dims,
|
|
34373
|
+
0,
|
|
34374
|
+
7
|
|
34375
|
+
];
|
|
34376
|
+
const fullChunks = Math.floor(data$1.length / N);
|
|
34377
|
+
for (let i$1 = 0; i$1 < fullChunks; i$1++) bytes.push(N + 1, 128, ...data$1.slice(N * i$1, N * (i$1 + 1)).map((i$2) => +i$2));
|
|
34378
|
+
bytes.push(data$1.length % N + 1, 128, ...data$1.slice(fullChunks * N).map((i$1) => +i$1));
|
|
34379
|
+
bytes.push(1, 129, 0, 59);
|
|
34380
|
+
return new Uint8Array(bytes);
|
|
34381
|
+
}
|
|
34382
|
+
toImage(isRGB = false) {
|
|
34383
|
+
const { height, width } = this.size();
|
|
34384
|
+
const data$1 = new Uint8Array(height * width * (isRGB ? 3 : 4));
|
|
34385
|
+
let i$1 = 0;
|
|
34386
|
+
for (let y = 0; y < height; y++) for (let x = 0; x < width; x++) {
|
|
34387
|
+
const value = this.get(x, y) ? 0 : 255;
|
|
34388
|
+
data$1[i$1++] = value;
|
|
34389
|
+
data$1[i$1++] = value;
|
|
34390
|
+
data$1[i$1++] = value;
|
|
34391
|
+
if (!isRGB) data$1[i$1++] = 255;
|
|
34392
|
+
}
|
|
34393
|
+
return {
|
|
34394
|
+
height,
|
|
34395
|
+
width,
|
|
34396
|
+
data: data$1
|
|
34397
|
+
};
|
|
34398
|
+
}
|
|
34399
|
+
};
|
|
34400
|
+
/** Error correction mode. low: 7%, medium: 15%, quartile: 25%, high: 30%. */
|
|
34401
|
+
const ECMode = /* @__PURE__ */ Object.freeze([
|
|
34402
|
+
"low",
|
|
34403
|
+
"medium",
|
|
34404
|
+
"quartile",
|
|
34405
|
+
"high"
|
|
34406
|
+
]);
|
|
34407
|
+
/**
|
|
34408
|
+
* QR payload compaction mode names recognized by the type/validator.
|
|
34409
|
+
* `kanji` and `eci` are spec modes, but `encodeQR` currently rejects them until implemented.
|
|
34410
|
+
*/
|
|
34411
|
+
const Encoding = /* @__PURE__ */ Object.freeze([
|
|
34412
|
+
"numeric",
|
|
34413
|
+
"alphanumeric",
|
|
34414
|
+
"byte",
|
|
34415
|
+
"kanji",
|
|
34416
|
+
"eci"
|
|
34417
|
+
]);
|
|
34418
|
+
const BYTES = [
|
|
34419
|
+
26,
|
|
34420
|
+
44,
|
|
34421
|
+
70,
|
|
34422
|
+
100,
|
|
34423
|
+
134,
|
|
34424
|
+
172,
|
|
34425
|
+
196,
|
|
34426
|
+
242,
|
|
34427
|
+
292,
|
|
34428
|
+
346,
|
|
34429
|
+
404,
|
|
34430
|
+
466,
|
|
34431
|
+
532,
|
|
34432
|
+
581,
|
|
34433
|
+
655,
|
|
34434
|
+
733,
|
|
34435
|
+
815,
|
|
34436
|
+
901,
|
|
34437
|
+
991,
|
|
34438
|
+
1085,
|
|
34439
|
+
1156,
|
|
34440
|
+
1258,
|
|
34441
|
+
1364,
|
|
34442
|
+
1474,
|
|
34443
|
+
1588,
|
|
34444
|
+
1706,
|
|
34445
|
+
1828,
|
|
34446
|
+
1921,
|
|
34447
|
+
2051,
|
|
34448
|
+
2185,
|
|
34449
|
+
2323,
|
|
34450
|
+
2465,
|
|
34451
|
+
2611,
|
|
34452
|
+
2761,
|
|
34453
|
+
2876,
|
|
34454
|
+
3034,
|
|
34455
|
+
3196,
|
|
34456
|
+
3362,
|
|
34457
|
+
3532,
|
|
34458
|
+
3706
|
|
34459
|
+
];
|
|
34460
|
+
const WORDS_PER_BLOCK = {
|
|
34461
|
+
low: [
|
|
34462
|
+
7,
|
|
34463
|
+
10,
|
|
34464
|
+
15,
|
|
34465
|
+
20,
|
|
34466
|
+
26,
|
|
34467
|
+
18,
|
|
34468
|
+
20,
|
|
34469
|
+
24,
|
|
34470
|
+
30,
|
|
34471
|
+
18,
|
|
34472
|
+
20,
|
|
34473
|
+
24,
|
|
34474
|
+
26,
|
|
34475
|
+
30,
|
|
34476
|
+
22,
|
|
34477
|
+
24,
|
|
34478
|
+
28,
|
|
34479
|
+
30,
|
|
34480
|
+
28,
|
|
34481
|
+
28,
|
|
34482
|
+
28,
|
|
34483
|
+
28,
|
|
34484
|
+
30,
|
|
34485
|
+
30,
|
|
34486
|
+
26,
|
|
34487
|
+
28,
|
|
34488
|
+
30,
|
|
34489
|
+
30,
|
|
34490
|
+
30,
|
|
34491
|
+
30,
|
|
34492
|
+
30,
|
|
34493
|
+
30,
|
|
34494
|
+
30,
|
|
34495
|
+
30,
|
|
34496
|
+
30,
|
|
34497
|
+
30,
|
|
34498
|
+
30,
|
|
34499
|
+
30,
|
|
34500
|
+
30,
|
|
34501
|
+
30
|
|
34502
|
+
],
|
|
34503
|
+
medium: [
|
|
34504
|
+
10,
|
|
34505
|
+
16,
|
|
34506
|
+
26,
|
|
34507
|
+
18,
|
|
34508
|
+
24,
|
|
34509
|
+
16,
|
|
34510
|
+
18,
|
|
34511
|
+
22,
|
|
34512
|
+
22,
|
|
34513
|
+
26,
|
|
34514
|
+
30,
|
|
34515
|
+
22,
|
|
34516
|
+
22,
|
|
34517
|
+
24,
|
|
34518
|
+
24,
|
|
34519
|
+
28,
|
|
34520
|
+
28,
|
|
34521
|
+
26,
|
|
34522
|
+
26,
|
|
34523
|
+
26,
|
|
34524
|
+
26,
|
|
34525
|
+
28,
|
|
34526
|
+
28,
|
|
34527
|
+
28,
|
|
34528
|
+
28,
|
|
34529
|
+
28,
|
|
34530
|
+
28,
|
|
34531
|
+
28,
|
|
34532
|
+
28,
|
|
34533
|
+
28,
|
|
34534
|
+
28,
|
|
34535
|
+
28,
|
|
34536
|
+
28,
|
|
34537
|
+
28,
|
|
34538
|
+
28,
|
|
34539
|
+
28,
|
|
34540
|
+
28,
|
|
34541
|
+
28,
|
|
34542
|
+
28,
|
|
34543
|
+
28
|
|
34544
|
+
],
|
|
34545
|
+
quartile: [
|
|
34546
|
+
13,
|
|
34547
|
+
22,
|
|
34548
|
+
18,
|
|
34549
|
+
26,
|
|
34550
|
+
18,
|
|
34551
|
+
24,
|
|
34552
|
+
18,
|
|
34553
|
+
22,
|
|
34554
|
+
20,
|
|
34555
|
+
24,
|
|
34556
|
+
28,
|
|
34557
|
+
26,
|
|
34558
|
+
24,
|
|
34559
|
+
20,
|
|
34560
|
+
30,
|
|
34561
|
+
24,
|
|
34562
|
+
28,
|
|
34563
|
+
28,
|
|
34564
|
+
26,
|
|
34565
|
+
30,
|
|
34566
|
+
28,
|
|
34567
|
+
30,
|
|
34568
|
+
30,
|
|
34569
|
+
30,
|
|
34570
|
+
30,
|
|
34571
|
+
28,
|
|
34572
|
+
30,
|
|
34573
|
+
30,
|
|
34574
|
+
30,
|
|
34575
|
+
30,
|
|
34576
|
+
30,
|
|
34577
|
+
30,
|
|
34578
|
+
30,
|
|
34579
|
+
30,
|
|
34580
|
+
30,
|
|
34581
|
+
30,
|
|
34582
|
+
30,
|
|
34583
|
+
30,
|
|
34584
|
+
30,
|
|
34585
|
+
30
|
|
34586
|
+
],
|
|
34587
|
+
high: [
|
|
34588
|
+
17,
|
|
34589
|
+
28,
|
|
34590
|
+
22,
|
|
34591
|
+
16,
|
|
34592
|
+
22,
|
|
34593
|
+
28,
|
|
34594
|
+
26,
|
|
34595
|
+
26,
|
|
34596
|
+
24,
|
|
34597
|
+
28,
|
|
34598
|
+
24,
|
|
34599
|
+
28,
|
|
34600
|
+
22,
|
|
34601
|
+
24,
|
|
34602
|
+
24,
|
|
34603
|
+
30,
|
|
34604
|
+
28,
|
|
34605
|
+
28,
|
|
34606
|
+
26,
|
|
34607
|
+
28,
|
|
34608
|
+
30,
|
|
34609
|
+
24,
|
|
34610
|
+
30,
|
|
34611
|
+
30,
|
|
34612
|
+
30,
|
|
34613
|
+
30,
|
|
34614
|
+
30,
|
|
34615
|
+
30,
|
|
34616
|
+
30,
|
|
34617
|
+
30,
|
|
34618
|
+
30,
|
|
34619
|
+
30,
|
|
34620
|
+
30,
|
|
34621
|
+
30,
|
|
34622
|
+
30,
|
|
34623
|
+
30,
|
|
34624
|
+
30,
|
|
34625
|
+
30,
|
|
34626
|
+
30,
|
|
34627
|
+
30
|
|
34628
|
+
]
|
|
34629
|
+
};
|
|
34630
|
+
const ECC_BLOCKS = {
|
|
34631
|
+
low: [
|
|
34632
|
+
1,
|
|
34633
|
+
1,
|
|
34634
|
+
1,
|
|
34635
|
+
1,
|
|
34636
|
+
1,
|
|
34637
|
+
2,
|
|
34638
|
+
2,
|
|
34639
|
+
2,
|
|
34640
|
+
2,
|
|
34641
|
+
4,
|
|
34642
|
+
4,
|
|
34643
|
+
4,
|
|
34644
|
+
4,
|
|
34645
|
+
4,
|
|
34646
|
+
6,
|
|
34647
|
+
6,
|
|
34648
|
+
6,
|
|
34649
|
+
6,
|
|
34650
|
+
7,
|
|
34651
|
+
8,
|
|
34652
|
+
8,
|
|
34653
|
+
9,
|
|
34654
|
+
9,
|
|
34655
|
+
10,
|
|
34656
|
+
12,
|
|
34657
|
+
12,
|
|
34658
|
+
12,
|
|
34659
|
+
13,
|
|
34660
|
+
14,
|
|
34661
|
+
15,
|
|
34662
|
+
16,
|
|
34663
|
+
17,
|
|
34664
|
+
18,
|
|
34665
|
+
19,
|
|
34666
|
+
19,
|
|
34667
|
+
20,
|
|
34668
|
+
21,
|
|
34669
|
+
22,
|
|
34670
|
+
24,
|
|
34671
|
+
25
|
|
34672
|
+
],
|
|
34673
|
+
medium: [
|
|
34674
|
+
1,
|
|
34675
|
+
1,
|
|
34676
|
+
1,
|
|
34677
|
+
2,
|
|
34678
|
+
2,
|
|
34679
|
+
4,
|
|
34680
|
+
4,
|
|
34681
|
+
4,
|
|
34682
|
+
5,
|
|
34683
|
+
5,
|
|
34684
|
+
5,
|
|
34685
|
+
8,
|
|
34686
|
+
9,
|
|
34687
|
+
9,
|
|
34688
|
+
10,
|
|
34689
|
+
10,
|
|
34690
|
+
11,
|
|
34691
|
+
13,
|
|
34692
|
+
14,
|
|
34693
|
+
16,
|
|
34694
|
+
17,
|
|
34695
|
+
17,
|
|
34696
|
+
18,
|
|
34697
|
+
20,
|
|
34698
|
+
21,
|
|
34699
|
+
23,
|
|
34700
|
+
25,
|
|
34701
|
+
26,
|
|
34702
|
+
28,
|
|
34703
|
+
29,
|
|
34704
|
+
31,
|
|
34705
|
+
33,
|
|
34706
|
+
35,
|
|
34707
|
+
37,
|
|
34708
|
+
38,
|
|
34709
|
+
40,
|
|
34710
|
+
43,
|
|
34711
|
+
45,
|
|
34712
|
+
47,
|
|
34713
|
+
49
|
|
34714
|
+
],
|
|
34715
|
+
quartile: [
|
|
34716
|
+
1,
|
|
34717
|
+
1,
|
|
34718
|
+
2,
|
|
34719
|
+
2,
|
|
34720
|
+
4,
|
|
34721
|
+
4,
|
|
34722
|
+
6,
|
|
34723
|
+
6,
|
|
34724
|
+
8,
|
|
34725
|
+
8,
|
|
34726
|
+
8,
|
|
34727
|
+
10,
|
|
34728
|
+
12,
|
|
34729
|
+
16,
|
|
34730
|
+
12,
|
|
34731
|
+
17,
|
|
34732
|
+
16,
|
|
34733
|
+
18,
|
|
34734
|
+
21,
|
|
34735
|
+
20,
|
|
34736
|
+
23,
|
|
34737
|
+
23,
|
|
34738
|
+
25,
|
|
34739
|
+
27,
|
|
34740
|
+
29,
|
|
34741
|
+
34,
|
|
34742
|
+
34,
|
|
34743
|
+
35,
|
|
34744
|
+
38,
|
|
34745
|
+
40,
|
|
34746
|
+
43,
|
|
34747
|
+
45,
|
|
34748
|
+
48,
|
|
34749
|
+
51,
|
|
34750
|
+
53,
|
|
34751
|
+
56,
|
|
34752
|
+
59,
|
|
34753
|
+
62,
|
|
34754
|
+
65,
|
|
34755
|
+
68
|
|
34756
|
+
],
|
|
34757
|
+
high: [
|
|
34758
|
+
1,
|
|
34759
|
+
1,
|
|
34760
|
+
2,
|
|
34761
|
+
4,
|
|
34762
|
+
4,
|
|
34763
|
+
4,
|
|
34764
|
+
5,
|
|
34765
|
+
6,
|
|
34766
|
+
8,
|
|
34767
|
+
8,
|
|
34768
|
+
11,
|
|
34769
|
+
11,
|
|
34770
|
+
16,
|
|
34771
|
+
16,
|
|
34772
|
+
18,
|
|
34773
|
+
16,
|
|
34774
|
+
19,
|
|
34775
|
+
21,
|
|
34776
|
+
25,
|
|
34777
|
+
25,
|
|
34778
|
+
25,
|
|
34779
|
+
34,
|
|
34780
|
+
30,
|
|
34781
|
+
32,
|
|
34782
|
+
35,
|
|
34783
|
+
37,
|
|
34784
|
+
40,
|
|
34785
|
+
42,
|
|
34786
|
+
45,
|
|
34787
|
+
48,
|
|
34788
|
+
51,
|
|
34789
|
+
54,
|
|
34790
|
+
57,
|
|
34791
|
+
60,
|
|
34792
|
+
63,
|
|
34793
|
+
66,
|
|
34794
|
+
70,
|
|
34795
|
+
74,
|
|
34796
|
+
77,
|
|
34797
|
+
81
|
|
34798
|
+
]
|
|
34799
|
+
};
|
|
34800
|
+
const info = /* @__PURE__ */ Object.freeze({
|
|
34801
|
+
size: /* @__PURE__ */ Object.freeze({
|
|
34802
|
+
encode: (ver) => 21 + 4 * (ver - 1),
|
|
34803
|
+
decode: (size) => (size - 17) / 4
|
|
34804
|
+
}),
|
|
34805
|
+
sizeType: (ver) => Math.floor((ver + 7) / 17),
|
|
34806
|
+
alignmentPatterns(ver) {
|
|
34807
|
+
if (ver === 1) return [];
|
|
34808
|
+
const first = 6;
|
|
34809
|
+
const last = info.size.encode(ver) - first - 1;
|
|
34810
|
+
const distance = last - first;
|
|
34811
|
+
const count = Math.ceil(distance / 28);
|
|
34812
|
+
let interval = Math.floor(distance / count);
|
|
34813
|
+
if (interval % 2) interval += 1;
|
|
34814
|
+
else if (distance % count * 2 >= count) interval += 2;
|
|
34815
|
+
const res = [first];
|
|
34816
|
+
for (let m = 1; m < count; m++) res.push(last - (count - m) * interval);
|
|
34817
|
+
res.push(last);
|
|
34818
|
+
return res;
|
|
34819
|
+
},
|
|
34820
|
+
ECCode: /* @__PURE__ */ Object.freeze({
|
|
34821
|
+
low: 1,
|
|
34822
|
+
medium: 0,
|
|
34823
|
+
quartile: 3,
|
|
34824
|
+
high: 2
|
|
34825
|
+
}),
|
|
34826
|
+
formatMask: 21522,
|
|
34827
|
+
formatBits(ecc, maskIdx) {
|
|
34828
|
+
const data$1 = info.ECCode[ecc] << 3 | maskIdx;
|
|
34829
|
+
let d = data$1;
|
|
34830
|
+
for (let i$1 = 0; i$1 < 10; i$1++) d = d << 1 ^ (d >> 9) * 1335;
|
|
34831
|
+
return (data$1 << 10 | d) ^ info.formatMask;
|
|
34832
|
+
},
|
|
34833
|
+
versionBits(ver) {
|
|
34834
|
+
let d = ver;
|
|
34835
|
+
for (let i$1 = 0; i$1 < 12; i$1++) d = d << 1 ^ (d >> 11) * 7973;
|
|
34836
|
+
return ver << 12 | d;
|
|
34837
|
+
},
|
|
34838
|
+
alphabet: /* @__PURE__ */ Object.freeze({
|
|
34839
|
+
numeric: alphabet("0123456789"),
|
|
34840
|
+
alphanumerc: alphabet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:")
|
|
34841
|
+
}),
|
|
34842
|
+
lengthBits(ver, type) {
|
|
34843
|
+
return {
|
|
34844
|
+
numeric: [
|
|
34845
|
+
10,
|
|
34846
|
+
12,
|
|
34847
|
+
14
|
|
34848
|
+
],
|
|
34849
|
+
alphanumeric: [
|
|
34850
|
+
9,
|
|
34851
|
+
11,
|
|
34852
|
+
13
|
|
34853
|
+
],
|
|
34854
|
+
byte: [
|
|
34855
|
+
8,
|
|
34856
|
+
16,
|
|
34857
|
+
16
|
|
34858
|
+
],
|
|
34859
|
+
kanji: [
|
|
34860
|
+
8,
|
|
34861
|
+
10,
|
|
34862
|
+
12
|
|
34863
|
+
],
|
|
34864
|
+
eci: [
|
|
34865
|
+
0,
|
|
34866
|
+
0,
|
|
34867
|
+
0
|
|
34868
|
+
]
|
|
34869
|
+
}[type][info.sizeType(ver)];
|
|
34870
|
+
},
|
|
34871
|
+
modeBits: /* @__PURE__ */ Object.freeze({
|
|
34872
|
+
numeric: "0001",
|
|
34873
|
+
alphanumeric: "0010",
|
|
34874
|
+
byte: "0100",
|
|
34875
|
+
kanji: "1000",
|
|
34876
|
+
eci: "0111"
|
|
34877
|
+
}),
|
|
34878
|
+
capacity(ver, ecc) {
|
|
34879
|
+
const bytes = BYTES[ver - 1];
|
|
34880
|
+
const words = WORDS_PER_BLOCK[ecc][ver - 1];
|
|
34881
|
+
const numBlocks = ECC_BLOCKS[ecc][ver - 1];
|
|
34882
|
+
const blockLen = Math.floor(bytes / numBlocks) - words;
|
|
34883
|
+
const shortBlocks = numBlocks - bytes % numBlocks;
|
|
34884
|
+
return {
|
|
34885
|
+
words,
|
|
34886
|
+
numBlocks,
|
|
34887
|
+
shortBlocks,
|
|
34888
|
+
blockLen,
|
|
34889
|
+
capacity: (bytes - words * numBlocks) * 8,
|
|
34890
|
+
total: (words + blockLen) * numBlocks + numBlocks - shortBlocks
|
|
34891
|
+
};
|
|
34892
|
+
}
|
|
34893
|
+
});
|
|
34894
|
+
const PATTERNS = /* @__PURE__ */ Object.freeze([
|
|
34895
|
+
(x, y) => (x + y) % 2 == 0,
|
|
34896
|
+
(_x, y) => y % 2 == 0,
|
|
34897
|
+
(x, _y) => x % 3 == 0,
|
|
34898
|
+
(x, y) => (x + y) % 3 == 0,
|
|
34899
|
+
(x, y) => (Math.floor(y / 2) + Math.floor(x / 3)) % 2 == 0,
|
|
34900
|
+
(x, y) => x * y % 2 + x * y % 3 == 0,
|
|
34901
|
+
(x, y) => (x * y % 2 + x * y % 3) % 2 == 0,
|
|
34902
|
+
(x, y) => ((x + y) % 2 + x * y % 3) % 2 == 0
|
|
34903
|
+
]);
|
|
34904
|
+
const GF = {
|
|
34905
|
+
tables: ((p_poly) => {
|
|
34906
|
+
const exp = fillArr(256, 0);
|
|
34907
|
+
const log$1 = fillArr(256, 0);
|
|
34908
|
+
for (let i$1 = 0, x = 1; i$1 < 256; i$1++) {
|
|
34909
|
+
exp[i$1] = x;
|
|
34910
|
+
log$1[x] = i$1;
|
|
34911
|
+
x <<= 1;
|
|
34912
|
+
if (x & 256) x ^= p_poly;
|
|
34913
|
+
}
|
|
34914
|
+
return {
|
|
34915
|
+
exp,
|
|
34916
|
+
log: log$1
|
|
34917
|
+
};
|
|
34918
|
+
})(285),
|
|
34919
|
+
exp: (x) => GF.tables.exp[x],
|
|
34920
|
+
log(x) {
|
|
34921
|
+
if (x === 0) throw new Error(`GF.log: invalid arg=${x}`);
|
|
34922
|
+
return GF.tables.log[x] % 255;
|
|
34923
|
+
},
|
|
34924
|
+
mul(x, y) {
|
|
34925
|
+
if (x === 0 || y === 0) return 0;
|
|
34926
|
+
return GF.tables.exp[(GF.tables.log[x] + GF.tables.log[y]) % 255];
|
|
34927
|
+
},
|
|
34928
|
+
add: (x, y) => x ^ y,
|
|
34929
|
+
pow: (x, e) => GF.tables.exp[GF.tables.log[x] * e % 255],
|
|
34930
|
+
inv(x) {
|
|
34931
|
+
if (x === 0) throw new Error(`GF.inverse: invalid arg=${x}`);
|
|
34932
|
+
return GF.tables.exp[255 - GF.tables.log[x]];
|
|
34933
|
+
},
|
|
34934
|
+
polynomial(poly) {
|
|
34935
|
+
if (poly.length == 0) throw new Error("GF.polymomial: invalid length");
|
|
34936
|
+
if (poly[0] !== 0) return poly;
|
|
34937
|
+
let i$1 = 0;
|
|
34938
|
+
for (; i$1 < poly.length - 1 && poly[i$1] == 0; i$1++);
|
|
34939
|
+
return poly.slice(i$1);
|
|
34940
|
+
},
|
|
34941
|
+
monomial(degree, coefficient) {
|
|
34942
|
+
if (degree < 0) throw new Error(`GF.monomial: invalid degree=${degree}`);
|
|
34943
|
+
if (coefficient == 0) return [0];
|
|
34944
|
+
let coefficients = fillArr(degree + 1, 0);
|
|
34945
|
+
coefficients[0] = coefficient;
|
|
34946
|
+
return GF.polynomial(coefficients);
|
|
34947
|
+
},
|
|
34948
|
+
degree: (a) => a.length - 1,
|
|
34949
|
+
coefficient: (a, degree) => a[GF.degree(a) - degree],
|
|
34950
|
+
mulPoly(a, b) {
|
|
34951
|
+
if (a[0] === 0 || b[0] === 0) return [0];
|
|
34952
|
+
const res = fillArr(a.length + b.length - 1, 0);
|
|
34953
|
+
for (let i$1 = 0; i$1 < a.length; i$1++) for (let j = 0; j < b.length; j++) res[i$1 + j] = GF.add(res[i$1 + j], GF.mul(a[i$1], b[j]));
|
|
34954
|
+
return GF.polynomial(res);
|
|
34955
|
+
},
|
|
34956
|
+
mulPolyScalar(a, scalar) {
|
|
34957
|
+
if (scalar == 0) return [0];
|
|
34958
|
+
if (scalar == 1) return a;
|
|
34959
|
+
const res = fillArr(a.length, 0);
|
|
34960
|
+
for (let i$1 = 0; i$1 < a.length; i$1++) res[i$1] = GF.mul(a[i$1], scalar);
|
|
34961
|
+
return GF.polynomial(res);
|
|
34962
|
+
},
|
|
34963
|
+
mulPolyMonomial(a, degree, coefficient) {
|
|
34964
|
+
if (degree < 0) throw new Error("GF.mulPolyMonomial: invalid degree");
|
|
34965
|
+
if (coefficient == 0) return [0];
|
|
34966
|
+
const res = fillArr(a.length + degree, 0);
|
|
34967
|
+
for (let i$1 = 0; i$1 < a.length; i$1++) res[i$1] = GF.mul(a[i$1], coefficient);
|
|
34968
|
+
return GF.polynomial(res);
|
|
34969
|
+
},
|
|
34970
|
+
addPoly(a, b) {
|
|
34971
|
+
if (a[0] === 0) return b;
|
|
34972
|
+
if (b[0] === 0) return a;
|
|
34973
|
+
let smaller = a;
|
|
34974
|
+
let larger = b;
|
|
34975
|
+
if (smaller.length > larger.length) [smaller, larger] = [larger, smaller];
|
|
34976
|
+
let sumDiff = fillArr(larger.length, 0);
|
|
34977
|
+
let lengthDiff = larger.length - smaller.length;
|
|
34978
|
+
let s = larger.slice(0, lengthDiff);
|
|
34979
|
+
for (let i$1 = 0; i$1 < s.length; i$1++) sumDiff[i$1] = s[i$1];
|
|
34980
|
+
for (let i$1 = lengthDiff; i$1 < larger.length; i$1++) sumDiff[i$1] = GF.add(smaller[i$1 - lengthDiff], larger[i$1]);
|
|
34981
|
+
return GF.polynomial(sumDiff);
|
|
34982
|
+
},
|
|
34983
|
+
remainderPoly(data$1, divisor) {
|
|
34984
|
+
const out = Array.from(data$1);
|
|
34985
|
+
for (let i$1 = 0; i$1 < data$1.length - divisor.length + 1; i$1++) {
|
|
34986
|
+
const elm = out[i$1];
|
|
34987
|
+
if (elm === 0) continue;
|
|
34988
|
+
for (let j = 1; j < divisor.length; j++) if (divisor[j] !== 0) out[i$1 + j] = GF.add(out[i$1 + j], GF.mul(divisor[j], elm));
|
|
34989
|
+
}
|
|
34990
|
+
return out.slice(data$1.length - divisor.length + 1, out.length);
|
|
34991
|
+
},
|
|
34992
|
+
divisorPoly(degree) {
|
|
34993
|
+
let g = [1];
|
|
34994
|
+
for (let i$1 = 0; i$1 < degree; i$1++) g = GF.mulPoly(g, [1, GF.pow(2, i$1)]);
|
|
34995
|
+
return g;
|
|
34996
|
+
},
|
|
34997
|
+
evalPoly(poly, a) {
|
|
34998
|
+
if (a == 0) return GF.coefficient(poly, 0);
|
|
34999
|
+
let res = poly[0];
|
|
35000
|
+
for (let i$1 = 1; i$1 < poly.length; i$1++) res = GF.add(GF.mul(a, res), poly[i$1]);
|
|
35001
|
+
return res;
|
|
35002
|
+
},
|
|
35003
|
+
euclidian(a, b, R$1) {
|
|
35004
|
+
if (GF.degree(a) < GF.degree(b)) [a, b] = [b, a];
|
|
35005
|
+
let rLast = a;
|
|
35006
|
+
let r$1 = b;
|
|
35007
|
+
let tLast = [0];
|
|
35008
|
+
let t$5 = [1];
|
|
35009
|
+
while (2 * GF.degree(r$1) >= R$1) {
|
|
35010
|
+
let rLastLast = rLast;
|
|
35011
|
+
let tLastLast = tLast;
|
|
35012
|
+
rLast = r$1;
|
|
35013
|
+
tLast = t$5;
|
|
35014
|
+
if (rLast[0] === 0) throw new Error("rLast[0] === 0");
|
|
35015
|
+
r$1 = rLastLast;
|
|
35016
|
+
let q = [0];
|
|
35017
|
+
const dltInverse = GF.inv(rLast[0]);
|
|
35018
|
+
while (GF.degree(r$1) >= GF.degree(rLast) && r$1[0] !== 0) {
|
|
35019
|
+
const degreeDiff = GF.degree(r$1) - GF.degree(rLast);
|
|
35020
|
+
const scale = GF.mul(r$1[0], dltInverse);
|
|
35021
|
+
q = GF.addPoly(q, GF.monomial(degreeDiff, scale));
|
|
35022
|
+
r$1 = GF.addPoly(r$1, GF.mulPolyMonomial(rLast, degreeDiff, scale));
|
|
35023
|
+
}
|
|
35024
|
+
q = GF.mulPoly(q, tLast);
|
|
35025
|
+
t$5 = GF.addPoly(q, tLastLast);
|
|
35026
|
+
if (GF.degree(r$1) >= GF.degree(rLast)) throw new Error(`Division failed r: ${r$1}, rLast: ${rLast}`);
|
|
35027
|
+
}
|
|
35028
|
+
const sigmaTildeAtZero = GF.coefficient(t$5, 0);
|
|
35029
|
+
if (sigmaTildeAtZero == 0) throw new Error("sigmaTilde(0) was zero");
|
|
35030
|
+
const inverse = GF.inv(sigmaTildeAtZero);
|
|
35031
|
+
return [GF.mulPolyScalar(t$5, inverse), GF.mulPolyScalar(r$1, inverse)];
|
|
35032
|
+
}
|
|
35033
|
+
};
|
|
35034
|
+
function RS(eccWords) {
|
|
35035
|
+
return {
|
|
35036
|
+
encode(from) {
|
|
35037
|
+
const d = GF.divisorPoly(eccWords);
|
|
35038
|
+
const pol = Array.from(from);
|
|
35039
|
+
pol.push(...d.slice(0, -1).fill(0));
|
|
35040
|
+
return Uint8Array.from(GF.remainderPoly(pol, d));
|
|
35041
|
+
},
|
|
35042
|
+
decode(to) {
|
|
35043
|
+
const res = to.slice();
|
|
35044
|
+
const poly = GF.polynomial(Array.from(to));
|
|
35045
|
+
let syndrome = fillArr(eccWords, 0);
|
|
35046
|
+
let hasError = false;
|
|
35047
|
+
for (let i$1 = 0; i$1 < eccWords; i$1++) {
|
|
35048
|
+
const evl = GF.evalPoly(poly, GF.exp(i$1));
|
|
35049
|
+
syndrome[syndrome.length - 1 - i$1] = evl;
|
|
35050
|
+
if (evl !== 0) hasError = true;
|
|
35051
|
+
}
|
|
35052
|
+
if (!hasError) return res;
|
|
35053
|
+
syndrome = GF.polynomial(syndrome);
|
|
35054
|
+
const monomial = GF.monomial(eccWords, 1);
|
|
35055
|
+
const [errorLocator, errorEvaluator] = GF.euclidian(monomial, syndrome, eccWords);
|
|
35056
|
+
const locations = fillArr(GF.degree(errorLocator), 0);
|
|
35057
|
+
let e = 0;
|
|
35058
|
+
for (let i$1 = 1; i$1 < 256 && e < locations.length; i$1++) if (GF.evalPoly(errorLocator, i$1) === 0) locations[e++] = GF.inv(i$1);
|
|
35059
|
+
if (e !== locations.length) throw new Error("RS.decode: invalid errors number");
|
|
35060
|
+
for (let i$1 = 0; i$1 < locations.length; i$1++) {
|
|
35061
|
+
const pos = res.length - 1 - GF.log(locations[i$1]);
|
|
35062
|
+
if (pos < 0) throw new Error("RS.decode: invalid error location");
|
|
35063
|
+
const xiInverse = GF.inv(locations[i$1]);
|
|
35064
|
+
let denominator = 1;
|
|
35065
|
+
for (let j = 0; j < locations.length; j++) {
|
|
35066
|
+
if (i$1 === j) continue;
|
|
35067
|
+
denominator = GF.mul(denominator, GF.add(1, GF.mul(locations[j], xiInverse)));
|
|
35068
|
+
}
|
|
35069
|
+
res[pos] = GF.add(res[pos], GF.mul(GF.evalPoly(errorEvaluator, xiInverse), GF.inv(denominator)));
|
|
35070
|
+
}
|
|
35071
|
+
return res;
|
|
35072
|
+
}
|
|
35073
|
+
};
|
|
35074
|
+
}
|
|
35075
|
+
function interleave(ver, ecc) {
|
|
35076
|
+
const { words, shortBlocks, numBlocks, blockLen, total } = info.capacity(ver, ecc);
|
|
35077
|
+
const rs = RS(words);
|
|
35078
|
+
return {
|
|
35079
|
+
encode(bytes) {
|
|
35080
|
+
const blocks = [];
|
|
35081
|
+
const eccBlocks = [];
|
|
35082
|
+
for (let i$1 = 0; i$1 < numBlocks; i$1++) {
|
|
35083
|
+
const len = blockLen + (i$1 < shortBlocks ? 0 : 1);
|
|
35084
|
+
blocks.push(bytes.subarray(0, len));
|
|
35085
|
+
eccBlocks.push(rs.encode(bytes.subarray(0, len)));
|
|
35086
|
+
bytes = bytes.subarray(len);
|
|
35087
|
+
}
|
|
35088
|
+
const resBlocks = interleaveBytes(blocks);
|
|
35089
|
+
const resECC = interleaveBytes(eccBlocks);
|
|
35090
|
+
const res = new Uint8Array(resBlocks.length + resECC.length);
|
|
35091
|
+
res.set(resBlocks);
|
|
35092
|
+
res.set(resECC, resBlocks.length);
|
|
35093
|
+
return res;
|
|
35094
|
+
},
|
|
35095
|
+
decode(data$1) {
|
|
35096
|
+
if (data$1.length !== total) throw new Error(`interleave.decode: len(data)=${data$1.length}, total=${total}`);
|
|
35097
|
+
const blocks = [];
|
|
35098
|
+
for (let i$1 = 0; i$1 < numBlocks; i$1++) {
|
|
35099
|
+
const isShort = i$1 < shortBlocks;
|
|
35100
|
+
blocks.push(new Uint8Array(words + blockLen + (isShort ? 0 : 1)));
|
|
35101
|
+
}
|
|
35102
|
+
let pos = 0;
|
|
35103
|
+
for (let i$1 = 0; i$1 < blockLen; i$1++) for (let j = 0; j < numBlocks; j++) blocks[j][i$1] = data$1[pos++];
|
|
35104
|
+
for (let j = shortBlocks; j < numBlocks; j++) blocks[j][blockLen] = data$1[pos++];
|
|
35105
|
+
for (let i$1 = blockLen; i$1 < blockLen + words; i$1++) for (let j = 0; j < numBlocks; j++) {
|
|
35106
|
+
const isShort = j < shortBlocks;
|
|
35107
|
+
blocks[j][i$1 + (isShort ? 0 : 1)] = data$1[pos++];
|
|
35108
|
+
}
|
|
35109
|
+
const res = [];
|
|
35110
|
+
for (const block of blocks) res.push(...Array.from(rs.decode(block)).slice(0, -words));
|
|
35111
|
+
return Uint8Array.from(res);
|
|
35112
|
+
}
|
|
35113
|
+
};
|
|
35114
|
+
}
|
|
35115
|
+
function drawTemplate(ver, ecc, maskIdx, test = false) {
|
|
35116
|
+
const size = info.size.encode(ver);
|
|
35117
|
+
let b = new Bitmap(size + 2);
|
|
35118
|
+
const finder = new Bitmap(3).rect(0, 3, true).border(1, false).border(1, true).border(1, false);
|
|
35119
|
+
b = b.embed(0, finder).embed({
|
|
35120
|
+
x: -finder.width,
|
|
35121
|
+
y: 0
|
|
35122
|
+
}, finder).embed({
|
|
35123
|
+
x: 0,
|
|
35124
|
+
y: -finder.height
|
|
35125
|
+
}, finder);
|
|
35126
|
+
b = b.rectSlice(1, size);
|
|
35127
|
+
const align = new Bitmap(1).rect(0, 1, true).border(1, false).border(1, true);
|
|
35128
|
+
const alignPos = info.alignmentPatterns(ver);
|
|
35129
|
+
for (const y of alignPos) for (const x of alignPos) {
|
|
35130
|
+
if (b.isDefined(x, y)) continue;
|
|
35131
|
+
b.embed({
|
|
35132
|
+
x: x - 2,
|
|
35133
|
+
y: y - 2
|
|
35134
|
+
}, align);
|
|
35135
|
+
}
|
|
35136
|
+
b = b.hLine({
|
|
35137
|
+
x: 0,
|
|
35138
|
+
y: 6
|
|
35139
|
+
}, Infinity, ({ x }) => b.isDefined(x, 6) ? void 0 : x % 2 == 0).vLine({
|
|
35140
|
+
x: 6,
|
|
35141
|
+
y: 0
|
|
35142
|
+
}, Infinity, ({ y }) => b.isDefined(6, y) ? void 0 : y % 2 == 0);
|
|
35143
|
+
{
|
|
35144
|
+
const bits = info.formatBits(ecc, maskIdx);
|
|
35145
|
+
const getBit = (i$1) => !test && (bits >> i$1 & 1) == 1;
|
|
35146
|
+
for (let i$1 = 0; i$1 < 6; i$1++) b.set(8, i$1, getBit(i$1));
|
|
35147
|
+
for (let i$1 = 6; i$1 < 8; i$1++) b.set(8, i$1 + 1, getBit(i$1));
|
|
35148
|
+
for (let i$1 = 8; i$1 < 15; i$1++) b.set(8, size - 15 + i$1, getBit(i$1));
|
|
35149
|
+
for (let i$1 = 0; i$1 < 8; i$1++) b.set(size - i$1 - 1, 8, getBit(i$1));
|
|
35150
|
+
for (let i$1 = 8; i$1 < 9; i$1++) b.set(15 - i$1 - 1 + 1, 8, getBit(i$1));
|
|
35151
|
+
for (let i$1 = 9; i$1 < 15; i$1++) b.set(15 - i$1 - 1, 8, getBit(i$1));
|
|
35152
|
+
b.set(8, size - 8, !test);
|
|
35153
|
+
}
|
|
35154
|
+
if (ver >= 7) {
|
|
35155
|
+
const bits = info.versionBits(ver);
|
|
35156
|
+
for (let i$1 = 0; i$1 < 18; i$1 += 1) {
|
|
35157
|
+
const bit = !test && (bits >> i$1 & 1) == 1;
|
|
35158
|
+
const x = Math.floor(i$1 / 3);
|
|
35159
|
+
const y = i$1 % 3 + size - 8 - 3;
|
|
35160
|
+
b.set(y, x, bit);
|
|
35161
|
+
b.set(x, y, bit);
|
|
35162
|
+
}
|
|
35163
|
+
}
|
|
35164
|
+
return b;
|
|
35165
|
+
}
|
|
35166
|
+
function zigzag(tpl, maskIdx, fn) {
|
|
35167
|
+
const bm = tpl;
|
|
35168
|
+
const size = bm.height;
|
|
35169
|
+
const pattern = PATTERNS[maskIdx];
|
|
35170
|
+
let dir = -1;
|
|
35171
|
+
let y = size - 1;
|
|
35172
|
+
for (let xOffset = size - 1; xOffset > 0; xOffset -= 2) {
|
|
35173
|
+
if (xOffset == 6) xOffset = 5;
|
|
35174
|
+
for (;; y += dir) {
|
|
35175
|
+
for (let j = 0; j < 2; j += 1) {
|
|
35176
|
+
const x = xOffset - j;
|
|
35177
|
+
if (bm.isDefined(x, y)) continue;
|
|
35178
|
+
fn(x, y, pattern(x, y));
|
|
35179
|
+
}
|
|
35180
|
+
if (y + dir < 0 || y + dir >= size) break;
|
|
35181
|
+
}
|
|
35182
|
+
dir = -dir;
|
|
35183
|
+
}
|
|
35184
|
+
}
|
|
35185
|
+
function detectType(str) {
|
|
35186
|
+
let type = "numeric";
|
|
35187
|
+
for (let x of str) {
|
|
35188
|
+
if (info.alphabet.numeric.has(x)) continue;
|
|
35189
|
+
type = "alphanumeric";
|
|
35190
|
+
if (!info.alphabet.alphanumerc.has(x)) return "byte";
|
|
35191
|
+
}
|
|
35192
|
+
return type;
|
|
35193
|
+
}
|
|
35194
|
+
/**
|
|
35195
|
+
* Encode a string as UTF-8 bytes.
|
|
35196
|
+
* @param str - Text to encode into UTF-8.
|
|
35197
|
+
* @returns UTF-8 bytes for the provided string.
|
|
35198
|
+
* @throws If the input is not a string. {@link Error}
|
|
35199
|
+
* @example
|
|
35200
|
+
* Encode a string as UTF-8 bytes.
|
|
35201
|
+
* ```ts
|
|
35202
|
+
* const bytes = utf8ToBytes('abc'); // new Uint8Array([97, 98, 99])
|
|
35203
|
+
* ```
|
|
35204
|
+
*/
|
|
35205
|
+
function utf8ToBytes(str) {
|
|
35206
|
+
if (typeof str !== "string") throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
|
|
35207
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
|
35208
|
+
}
|
|
35209
|
+
function encode$1(ver, ecc, data$1, type, encoder$1 = utf8ToBytes) {
|
|
35210
|
+
let encoded = "";
|
|
35211
|
+
let dataLen = data$1.length;
|
|
35212
|
+
if (type === "numeric") {
|
|
35213
|
+
const t$5 = info.alphabet.numeric.decode(data$1.split(""));
|
|
35214
|
+
const n$1 = t$5.length;
|
|
35215
|
+
for (let i$1 = 0; i$1 < n$1 - 2; i$1 += 3) encoded += bin(t$5[i$1] * 100 + t$5[i$1 + 1] * 10 + t$5[i$1 + 2], 10);
|
|
35216
|
+
if (n$1 % 3 === 1) encoded += bin(t$5[n$1 - 1], 4);
|
|
35217
|
+
else if (n$1 % 3 === 2) encoded += bin(t$5[n$1 - 2] * 10 + t$5[n$1 - 1], 7);
|
|
35218
|
+
} else if (type === "alphanumeric") {
|
|
35219
|
+
const t$5 = info.alphabet.alphanumerc.decode(data$1.split(""));
|
|
35220
|
+
const n$1 = t$5.length;
|
|
35221
|
+
for (let i$1 = 0; i$1 < n$1 - 1; i$1 += 2) encoded += bin(t$5[i$1] * 45 + t$5[i$1 + 1], 11);
|
|
35222
|
+
if (n$1 % 2 == 1) encoded += bin(t$5[n$1 - 1], 6);
|
|
35223
|
+
} else if (type === "byte") {
|
|
35224
|
+
const utf8 = encoder$1(data$1);
|
|
35225
|
+
dataLen = utf8.length;
|
|
35226
|
+
encoded = Array.from(utf8).map((i$1) => bin(i$1, 8)).join("");
|
|
35227
|
+
} else throw new Error("encode: unsupported type");
|
|
35228
|
+
const { capacity } = info.capacity(ver, ecc);
|
|
35229
|
+
const len = bin(dataLen, info.lengthBits(ver, type));
|
|
35230
|
+
let bits = info.modeBits[type] + len + encoded;
|
|
35231
|
+
if (bits.length > capacity) throw new Error("Capacity overflow");
|
|
35232
|
+
bits += "0".repeat(Math.min(4, Math.max(0, capacity - bits.length)));
|
|
35233
|
+
if (bits.length % 8) bits += "0".repeat(8 - bits.length % 8);
|
|
35234
|
+
const padding = "1110110000010001";
|
|
35235
|
+
for (let idx = 0; bits.length !== capacity; idx++) bits += padding[idx % 16];
|
|
35236
|
+
const bytes = Uint8Array.from(bits.match(/(.{8})/g).map((i$1) => Number(`0b${i$1}`)));
|
|
35237
|
+
return interleave(ver, ecc).encode(bytes);
|
|
35238
|
+
}
|
|
35239
|
+
function drawQR(ver, ecc, data$1, maskIdx, test = false) {
|
|
35240
|
+
const b = drawTemplate(ver, ecc, maskIdx, test);
|
|
35241
|
+
let i$1 = 0;
|
|
35242
|
+
const need = 8 * data$1.length;
|
|
35243
|
+
zigzag(b, maskIdx, (x, y, mask) => {
|
|
35244
|
+
let value = false;
|
|
35245
|
+
if (i$1 < need) {
|
|
35246
|
+
value = (data$1[i$1 >>> 3] >> (7 - i$1 & 7) & 1) !== 0;
|
|
35247
|
+
i$1++;
|
|
35248
|
+
}
|
|
35249
|
+
b.set(x, y, value !== mask);
|
|
35250
|
+
});
|
|
35251
|
+
if (i$1 !== need) throw new Error("QR: bytes left after draw");
|
|
35252
|
+
return b;
|
|
35253
|
+
}
|
|
35254
|
+
const mkPattern = (pattern) => {
|
|
35255
|
+
const s = pattern.map((i$1) => i$1 ? "1" : "0").join("");
|
|
35256
|
+
return {
|
|
35257
|
+
len: s.length,
|
|
35258
|
+
n: Number(`0b${s}`)
|
|
35259
|
+
};
|
|
35260
|
+
};
|
|
35261
|
+
const finderPattern = [
|
|
35262
|
+
true,
|
|
35263
|
+
false,
|
|
35264
|
+
true,
|
|
35265
|
+
true,
|
|
35266
|
+
true,
|
|
35267
|
+
false,
|
|
35268
|
+
true
|
|
35269
|
+
];
|
|
35270
|
+
const lightPattern = [
|
|
35271
|
+
false,
|
|
35272
|
+
false,
|
|
35273
|
+
false,
|
|
35274
|
+
false
|
|
35275
|
+
];
|
|
35276
|
+
const P1 = /* @__PURE__ */ (() => mkPattern([...finderPattern, ...lightPattern]))();
|
|
35277
|
+
const P2 = /* @__PURE__ */ (() => mkPattern([...lightPattern, ...finderPattern]))();
|
|
35278
|
+
function penalty(bm) {
|
|
35279
|
+
const b = bm;
|
|
35280
|
+
const { width, height } = b;
|
|
35281
|
+
const transposed = b.transpose();
|
|
35282
|
+
let adjacent = 0;
|
|
35283
|
+
for (let y = 0; y < height; y++) b.getRuns(y, (len) => {
|
|
35284
|
+
if (len >= 5) adjacent += 3 + (len - 5);
|
|
35285
|
+
});
|
|
35286
|
+
for (let y = 0; y < width; y++) transposed.getRuns(y, (len) => {
|
|
35287
|
+
if (len >= 5) adjacent += 3 + (len - 5);
|
|
35288
|
+
});
|
|
35289
|
+
let box = 0;
|
|
35290
|
+
for (let y = 0; y < height - 1; y++) box += 3 * b.countBoxes2x2(y);
|
|
35291
|
+
let finder = 0;
|
|
35292
|
+
for (let y = 0; y < height; y++) finder += 40 * b.countPatternInRow(y, P1.len, P1.n, P2.n);
|
|
35293
|
+
for (let y = 0; y < width; y++) finder += 40 * transposed.countPatternInRow(y, P1.len, P1.n, P2.n);
|
|
35294
|
+
const total = height * width;
|
|
35295
|
+
const darkPixels = b.popcnt();
|
|
35296
|
+
const dark = 10 * Math.ceil(Math.max(0, Math.abs(darkPixels * 100 - total * 50) - total * 5) / (total * 5));
|
|
35297
|
+
return adjacent + box + finder + dark;
|
|
35298
|
+
}
|
|
35299
|
+
function drawQRBest(ver, ecc, data$1, maskIdx) {
|
|
35300
|
+
if (maskIdx === void 0) {
|
|
35301
|
+
const bestMask = best();
|
|
35302
|
+
for (let mask = 0; mask < PATTERNS.length; mask++) bestMask.add(penalty(drawQR(ver, ecc, data$1, mask, true)), mask);
|
|
35303
|
+
maskIdx = bestMask.get();
|
|
35304
|
+
}
|
|
35305
|
+
if (maskIdx === void 0) throw new Error("Cannot find mask");
|
|
35306
|
+
return drawQR(ver, ecc, data$1, maskIdx);
|
|
35307
|
+
}
|
|
35308
|
+
function validateECC(ec) {
|
|
35309
|
+
if (!ECMode.includes(ec)) throw new Error(`Invalid error correction mode=${ec}. Expected: ${ECMode}`);
|
|
35310
|
+
}
|
|
35311
|
+
function validateEncoding(enc) {
|
|
35312
|
+
if (!Encoding.includes(enc)) throw new Error(`Encoding: invalid mode=${enc}. Expected: ${Encoding}`);
|
|
35313
|
+
if (enc === "kanji" || enc === "eci") throw new Error(`Encoding: ${enc} is not supported (yet?).`);
|
|
35314
|
+
}
|
|
35315
|
+
function validateMask(mask) {
|
|
35316
|
+
if (![
|
|
35317
|
+
0,
|
|
35318
|
+
1,
|
|
35319
|
+
2,
|
|
35320
|
+
3,
|
|
35321
|
+
4,
|
|
35322
|
+
5,
|
|
35323
|
+
6,
|
|
35324
|
+
7
|
|
35325
|
+
].includes(mask) || !PATTERNS[mask]) throw new Error(`Invalid mask=${mask}. Expected number [0..7]`);
|
|
35326
|
+
}
|
|
35327
|
+
function encodeQR(text, output = "raw", opts = {}) {
|
|
35328
|
+
const _opts = opts;
|
|
35329
|
+
const ecc = _opts.ecc !== void 0 ? _opts.ecc : "medium";
|
|
35330
|
+
validateECC(ecc);
|
|
35331
|
+
const encoding = _opts.encoding !== void 0 ? _opts.encoding : detectType(text);
|
|
35332
|
+
validateEncoding(encoding);
|
|
35333
|
+
if (_opts.mask !== void 0) validateMask(_opts.mask);
|
|
35334
|
+
let ver = _opts.version;
|
|
35335
|
+
let data$1, err = /* @__PURE__ */ new Error("Unknown error");
|
|
35336
|
+
if (ver !== void 0) {
|
|
35337
|
+
validateVersion(ver);
|
|
35338
|
+
data$1 = encode$1(ver, ecc, text, encoding, _opts.textEncoder);
|
|
35339
|
+
} else for (let i$1 = 1; i$1 <= 40; i$1++) try {
|
|
35340
|
+
data$1 = encode$1(i$1, ecc, text, encoding, _opts.textEncoder);
|
|
35341
|
+
ver = i$1;
|
|
35342
|
+
break;
|
|
35343
|
+
} catch (e) {
|
|
35344
|
+
err = e;
|
|
35345
|
+
}
|
|
35346
|
+
if (!ver || !data$1) throw err;
|
|
35347
|
+
let res = drawQRBest(ver, ecc, data$1, _opts.mask);
|
|
35348
|
+
res.assertDrawn();
|
|
35349
|
+
const border = _opts.border === void 0 ? 2 : _opts.border;
|
|
35350
|
+
if (!Number.isSafeInteger(border) || border <= 0) throw new Error(`invalid border=${border}`);
|
|
35351
|
+
res = res.border(border, false);
|
|
35352
|
+
if (_opts.scale !== void 0) res = res.scale(_opts.scale);
|
|
35353
|
+
if (output === "raw") return res.toRaw();
|
|
35354
|
+
else if (output === "ascii") return res.toASCII();
|
|
35355
|
+
else if (output === "svg") return res.toSVG(_opts.optimize);
|
|
35356
|
+
else if (output === "gif") return res.toGIF();
|
|
35357
|
+
else if (output === "term") return res.toTerm();
|
|
35358
|
+
else throw new Error(`Unknown output: ${output}`);
|
|
35359
|
+
}
|
|
35360
|
+
/**
|
|
35361
|
+
* Default export alias for {@link encodeQR}.
|
|
35362
|
+
* @param text - Text payload that should be encoded into the QR symbol.
|
|
35363
|
+
* @param output - Output format to generate: raw matrix, ASCII, terminal ANSI, GIF, or SVG.
|
|
35364
|
+
* @param opts - Encoding and rendering options. See {@link QrOpts} and {@link SvgQrOpts}.
|
|
35365
|
+
* @returns Encoded QR data in the format selected by `output`.
|
|
35366
|
+
* @throws If the payload, options, QR capacity, or output format are invalid. {@link Error}
|
|
35367
|
+
* @example
|
|
35368
|
+
* Encode text into the default export from the package root.
|
|
35369
|
+
* ```ts
|
|
35370
|
+
* import encodeQR from 'qr';
|
|
35371
|
+
* encodeQR('Hello world', 'ascii');
|
|
35372
|
+
* ```
|
|
35373
|
+
*/
|
|
35374
|
+
var qr_default = encodeQR;
|
|
35375
|
+
|
|
35376
|
+
//#endregion
|
|
35377
|
+
//#region src/plugins/tunnel.ts
|
|
33835
35378
|
function createPublicExposureWarning(mode, name, shortcutPressed) {
|
|
33836
35379
|
const intro = name === void 0 ? import_picocolors$5.default.dim("Once connected, this tunnel will be ") + "publicly accessible" + import_picocolors$5.default.dim(". Anyone who can reach it can:") : import_picocolors$5.default.dim("Once connected, this tunnel may be reachable from the Internet. Anyone who can reach it can:");
|
|
33837
35380
|
const concerns = [
|
|
@@ -34115,6 +35658,11 @@ function patchPrintUrls(server) {
|
|
|
34115
35658
|
if (!publicUrls || publicUrls.length === 0) return;
|
|
34116
35659
|
for (let i$1 = 0; i$1 < publicUrls.length; i$1++) if (i$1 === 0) server.config.logger.info(`${import_picocolors$5.default.green(" ➜")} ${import_picocolors$5.default.bold("Tunnel:")} ${import_picocolors$5.default.cyan(publicUrls[i$1])}`);
|
|
34117
35660
|
else server.config.logger.info(` ${import_picocolors$5.default.cyan(publicUrls[i$1])}`);
|
|
35661
|
+
const primaryUrl = publicUrls[0];
|
|
35662
|
+
if (primaryUrl) try {
|
|
35663
|
+
const qrCode = qr_default(primaryUrl, "ascii", { border: 1 });
|
|
35664
|
+
server.config.logger.info(`\n${qrCode}`);
|
|
35665
|
+
} catch {}
|
|
34118
35666
|
server.config.logger.info("");
|
|
34119
35667
|
};
|
|
34120
35668
|
}
|
|
@@ -34213,8 +35761,8 @@ const postfixRE = /[?#].*$/;
|
|
|
34213
35761
|
function cleanUrl(url) {
|
|
34214
35762
|
return url.replace(postfixRE, "");
|
|
34215
35763
|
}
|
|
34216
|
-
function withTrailingSlash(path$
|
|
34217
|
-
return path$
|
|
35764
|
+
function withTrailingSlash(path$1) {
|
|
35765
|
+
return path$1.endsWith("/") ? path$1 : `${path$1}/`;
|
|
34218
35766
|
}
|
|
34219
35767
|
function createRequestHandler(handler) {
|
|
34220
35768
|
return async (req, res, next) => {
|
|
@@ -34590,53 +36138,34 @@ function getDeployConfigPath(root) {
|
|
|
34590
36138
|
}
|
|
34591
36139
|
function getWorkerConfigs(root, isPrerender) {
|
|
34592
36140
|
const deployConfigPath = getDeployConfigPath(root);
|
|
34593
|
-
const deployConfig = JSON.parse(fs$
|
|
34594
|
-
return [
|
|
34595
|
-
...isPrerender && deployConfig.prerenderWorkerConfigPath ? [{ configPath: deployConfig.prerenderWorkerConfigPath }] : [],
|
|
34596
|
-
{ configPath: deployConfig.configPath },
|
|
34597
|
-
...deployConfig.auxiliaryWorkers
|
|
34598
|
-
].map(({ configPath }) => {
|
|
36141
|
+
const deployConfig = JSON.parse(fs$1.readFileSync(deployConfigPath, "utf-8"));
|
|
36142
|
+
return [...isPrerender && deployConfig.prerenderWorkerConfigPath ? [{ configPath: deployConfig.prerenderWorkerConfigPath }] : [{ configPath: deployConfig.configPath }], ...deployConfig.auxiliaryWorkers].map(({ configPath }) => {
|
|
34599
36143
|
const resolvedConfigPath = nodePath.resolve(nodePath.dirname(deployConfigPath), configPath);
|
|
34600
36144
|
return wrangler.unstable_readConfig({ config: resolvedConfigPath });
|
|
34601
36145
|
});
|
|
34602
36146
|
}
|
|
34603
|
-
function
|
|
34604
|
-
return nodePath.relative(deployConfigDirectory, nodePath.resolve(root, outputDirectory, "wrangler.json"));
|
|
34605
|
-
}
|
|
34606
|
-
function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig) {
|
|
36147
|
+
function writeDeployConfig(resolvedPluginConfig, resolvedViteConfig, isAssetsOnly) {
|
|
34607
36148
|
const deployConfigPath = getDeployConfigPath(resolvedViteConfig.root);
|
|
34608
36149
|
const deployConfigDirectory = nodePath.dirname(deployConfigPath);
|
|
34609
|
-
fs$
|
|
34610
|
-
|
|
34611
|
-
const
|
|
34612
|
-
assert(
|
|
34613
|
-
|
|
34614
|
-
|
|
34615
|
-
|
|
34616
|
-
|
|
34617
|
-
|
|
34618
|
-
|
|
34619
|
-
|
|
34620
|
-
|
|
34621
|
-
let entryWorkerConfigPath;
|
|
34622
|
-
let prerenderWorkerConfigPath;
|
|
34623
|
-
const auxiliaryWorkers = [];
|
|
34624
|
-
for (const environmentName of resolvedPluginConfig.environmentNameToWorkerMap.keys()) {
|
|
34625
|
-
const outputDirectory = resolvedViteConfig.environments[environmentName]?.build.outDir;
|
|
34626
|
-
assert(outputDirectory, `Unexpected error: ${environmentName} environment output directory is undefined`);
|
|
34627
|
-
const configPath = getRelativePathToWorkerConfig(deployConfigDirectory, resolvedViteConfig.root, outputDirectory);
|
|
34628
|
-
if (environmentName === resolvedPluginConfig.entryWorkerEnvironmentName) entryWorkerConfigPath = configPath;
|
|
34629
|
-
else if (environmentName === resolvedPluginConfig.prerenderWorkerEnvironmentName) prerenderWorkerConfigPath = configPath;
|
|
34630
|
-
else auxiliaryWorkers.push({ configPath });
|
|
34631
|
-
}
|
|
34632
|
-
assert(entryWorkerConfigPath, `Unexpected error: entryWorkerConfigPath is undefined`);
|
|
34633
|
-
const deployConfig = {
|
|
34634
|
-
configPath: entryWorkerConfigPath,
|
|
34635
|
-
auxiliaryWorkers,
|
|
34636
|
-
prerenderWorkerConfigPath
|
|
34637
|
-
};
|
|
34638
|
-
fs$2.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
|
|
36150
|
+
fs$1.mkdirSync(deployConfigDirectory, { recursive: true });
|
|
36151
|
+
const resolveConfigPath = (environmentName) => {
|
|
36152
|
+
const outputDirectory = resolvedViteConfig.environments[environmentName]?.build.outDir;
|
|
36153
|
+
assert(outputDirectory, `Unexpected error: ${environmentName} environment output directory is undefined`);
|
|
36154
|
+
return nodePath.relative(deployConfigDirectory, nodePath.resolve(resolvedViteConfig.root, outputDirectory, "wrangler.json"));
|
|
36155
|
+
};
|
|
36156
|
+
const auxiliaryWorkerEnvironmentNames = resolvedPluginConfig.type === "workers" ? [...resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([name, worker]) => name !== resolvedPluginConfig.entryWorkerEnvironmentName && name !== resolvedPluginConfig.prerenderWorkerEnvironmentName && !resolveDevOnly(worker.devOnly)).map(([name]) => name) : [];
|
|
36157
|
+
let entryEnvironmentName;
|
|
36158
|
+
if (isAssetsOnly) entryEnvironmentName = "client";
|
|
36159
|
+
else {
|
|
36160
|
+
assert(resolvedPluginConfig.type === "workers", `Unexpected error: expected workers config but got ${resolvedPluginConfig.type}`);
|
|
36161
|
+
entryEnvironmentName = resolvedPluginConfig.entryWorkerEnvironmentName;
|
|
34639
36162
|
}
|
|
36163
|
+
const deployConfig = {
|
|
36164
|
+
configPath: resolveConfigPath(entryEnvironmentName),
|
|
36165
|
+
auxiliaryWorkers: auxiliaryWorkerEnvironmentNames.map((name) => ({ configPath: resolveConfigPath(name) })),
|
|
36166
|
+
prerenderWorkerConfigPath: resolvedPluginConfig.prerenderWorkerEnvironmentName ? resolveConfigPath(resolvedPluginConfig.prerenderWorkerEnvironmentName) : void 0
|
|
36167
|
+
};
|
|
36168
|
+
fs$1.writeFileSync(deployConfigPath, JSON.stringify(deployConfig));
|
|
34640
36169
|
}
|
|
34641
36170
|
|
|
34642
36171
|
//#endregion
|
|
@@ -39735,15 +41264,15 @@ function hasTrailingSlash(input = "", respectQueryAndFragment) {
|
|
|
39735
41264
|
function withTrailingSlash$1(input = "", respectQueryAndFragment) {
|
|
39736
41265
|
if (!respectQueryAndFragment) return input.endsWith("/") ? input : input + "/";
|
|
39737
41266
|
if (hasTrailingSlash(input, true)) return input || "/";
|
|
39738
|
-
let path$
|
|
41267
|
+
let path$1 = input;
|
|
39739
41268
|
let fragment = "";
|
|
39740
41269
|
const fragmentIndex = input.indexOf("#");
|
|
39741
41270
|
if (fragmentIndex >= 0) {
|
|
39742
|
-
path$
|
|
41271
|
+
path$1 = input.slice(0, fragmentIndex);
|
|
39743
41272
|
fragment = input.slice(fragmentIndex);
|
|
39744
|
-
if (!path$
|
|
41273
|
+
if (!path$1) return fragment;
|
|
39745
41274
|
}
|
|
39746
|
-
const [s0, ...s] = path$
|
|
41275
|
+
const [s0, ...s] = path$1.split("?");
|
|
39747
41276
|
return s0 + "/" + (s.length > 0 ? `?${s.join("?")}` : "") + fragment;
|
|
39748
41277
|
}
|
|
39749
41278
|
function isNonEmptyURL(url) {
|
|
@@ -39769,8 +41298,8 @@ const isAbsolute$1 = function(p$1) {
|
|
|
39769
41298
|
//#endregion
|
|
39770
41299
|
//#region ../../node_modules/.pnpm/mlly@1.7.4/node_modules/mlly/dist/index.mjs
|
|
39771
41300
|
const BUILTIN_MODULES = new Set(builtinModules);
|
|
39772
|
-
function normalizeSlash(path$
|
|
39773
|
-
return path$
|
|
41301
|
+
function normalizeSlash(path$1) {
|
|
41302
|
+
return path$1.replace(/\\/g, "/");
|
|
39774
41303
|
}
|
|
39775
41304
|
/**
|
|
39776
41305
|
* @typedef ErrnoExceptionFields
|
|
@@ -39890,8 +41419,8 @@ codes.ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
|
39890
41419
|
* @param {string} [base]
|
|
39891
41420
|
* @param {string} [message]
|
|
39892
41421
|
*/
|
|
39893
|
-
(path$
|
|
39894
|
-
return `Invalid package config ${path$
|
|
41422
|
+
(path$1, base, message) => {
|
|
41423
|
+
return `Invalid package config ${path$1}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
39895
41424
|
},
|
|
39896
41425
|
Error
|
|
39897
41426
|
);
|
|
@@ -39921,8 +41450,8 @@ codes.ERR_MODULE_NOT_FOUND = createError(
|
|
|
39921
41450
|
* @param {string} base
|
|
39922
41451
|
* @param {boolean} [exactUrl]
|
|
39923
41452
|
*/
|
|
39924
|
-
(path$
|
|
39925
|
-
return `Cannot find ${exactUrl ? "module" : "package"} '${path$
|
|
41453
|
+
(path$1, base, exactUrl = false) => {
|
|
41454
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path$1}' imported from ${base}`;
|
|
39926
41455
|
},
|
|
39927
41456
|
Error
|
|
39928
41457
|
);
|
|
@@ -39960,8 +41489,8 @@ codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
|
39960
41489
|
* @param {string} extension
|
|
39961
41490
|
* @param {string} path
|
|
39962
41491
|
*/
|
|
39963
|
-
(extension, path$
|
|
39964
|
-
return `Unknown file extension "${extension}" for ${path$
|
|
41492
|
+
(extension, path$1) => {
|
|
41493
|
+
return `Unknown file extension "${extension}" for ${path$1}`;
|
|
39965
41494
|
},
|
|
39966
41495
|
TypeError
|
|
39967
41496
|
);
|
|
@@ -40118,7 +41647,7 @@ function read(jsonPath, { base, specifier }) {
|
|
|
40118
41647
|
/** @type {string | undefined} */
|
|
40119
41648
|
let string;
|
|
40120
41649
|
try {
|
|
40121
|
-
string =
|
|
41650
|
+
string = fs2.readFileSync(path3.toNamespacedPath(jsonPath), "utf8");
|
|
40122
41651
|
} catch (error) {
|
|
40123
41652
|
const exception = error;
|
|
40124
41653
|
if (exception.code !== "ENOENT") throw exception;
|
|
@@ -40324,15 +41853,15 @@ function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
|
40324
41853
|
const packagePath = fileURLToPath(new URL$1(".", packageJsonUrl));
|
|
40325
41854
|
const basePath = fileURLToPath(base);
|
|
40326
41855
|
if (!main) process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
40327
|
-
else if (
|
|
41856
|
+
else if (path3.resolve(packagePath, main) !== urlPath) process$1.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
40328
41857
|
}
|
|
40329
41858
|
/**
|
|
40330
41859
|
* @param {string} path
|
|
40331
41860
|
* @returns {Stats | undefined}
|
|
40332
41861
|
*/
|
|
40333
|
-
function tryStatSync(path$
|
|
41862
|
+
function tryStatSync(path$1) {
|
|
40334
41863
|
try {
|
|
40335
|
-
return statSync(path$
|
|
41864
|
+
return statSync(path$1);
|
|
40336
41865
|
} catch {}
|
|
40337
41866
|
}
|
|
40338
41867
|
/**
|
|
@@ -40431,7 +41960,7 @@ function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
|
40431
41960
|
{
|
|
40432
41961
|
const real = realpathSync(filePath);
|
|
40433
41962
|
const { search, hash } = resolved;
|
|
40434
|
-
resolved = pathToFileURL(real + (filePath.endsWith(
|
|
41963
|
+
resolved = pathToFileURL(real + (filePath.endsWith(path3.sep) ? "/" : ""));
|
|
40435
41964
|
resolved.search = search;
|
|
40436
41965
|
resolved.hash = hash;
|
|
40437
41966
|
}
|
|
@@ -41425,7 +42954,7 @@ function maybeResolveMain(main, configPath, root) {
|
|
|
41425
42954
|
const baseDir = configPath ? nodePath.dirname(configPath) : root;
|
|
41426
42955
|
if (!baseDir) return main;
|
|
41427
42956
|
const resolvedMain = nodePath.resolve(baseDir, main);
|
|
41428
|
-
if (!fs$
|
|
42957
|
+
if (!fs$1.existsSync(resolvedMain)) throw new Error(`The provided Wrangler config main field (${resolvedMain}) doesn't point to an existing file`);
|
|
41429
42958
|
return resolvedMain;
|
|
41430
42959
|
}
|
|
41431
42960
|
/**
|
|
@@ -41446,7 +42975,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
|
|
|
41446
42975
|
const foundExtensionMessage = !fileExtension ? "no extension found" : `"${fileExtension}" found`;
|
|
41447
42976
|
throw new Error(`${errorMessagePrefix} doesn't point to a file with the correct file extension. It should point to a jsonc, json or toml file (${foundExtensionMessage} instead)`);
|
|
41448
42977
|
}
|
|
41449
|
-
const mainStat = fs$
|
|
42978
|
+
const mainStat = fs$1.statSync(configPath, { throwIfNoEntry: false });
|
|
41450
42979
|
if (!mainStat) throw new Error(`${errorMessagePrefix} doesn't point to an existing file`);
|
|
41451
42980
|
if (mainStat.isDirectory()) throw new Error(`${errorMessagePrefix} points to a directory. It should point to a file.`);
|
|
41452
42981
|
return configPath;
|
|
@@ -41457,7 +42986,7 @@ function getValidatedWranglerConfigPath(root, requestedConfigPath, isForAuxiliar
|
|
|
41457
42986
|
function findWranglerConfig(root) {
|
|
41458
42987
|
for (const extension of allowedWranglerConfigExtensions) {
|
|
41459
42988
|
const configPath = nodePath.join(root, `wrangler.${extension}`);
|
|
41460
|
-
if (fs$
|
|
42989
|
+
if (fs$1.existsSync(configPath)) return configPath;
|
|
41461
42990
|
}
|
|
41462
42991
|
}
|
|
41463
42992
|
const allowedWranglerConfigExtensions = [
|
|
@@ -41557,7 +43086,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
41557
43086
|
});
|
|
41558
43087
|
prerenderWorkerEnvironmentName = prerenderWorkerConfig.viteEnvironment?.name ?? workerNameToEnvironmentName(workerResolvedConfig.config.topLevelName);
|
|
41559
43088
|
validateAndAddEnvironmentName(prerenderWorkerEnvironmentName);
|
|
41560
|
-
environmentNameToWorkerMap.set(prerenderWorkerEnvironmentName, resolveWorker(workerResolvedConfig.config));
|
|
43089
|
+
environmentNameToWorkerMap.set(prerenderWorkerEnvironmentName, resolveWorker(workerResolvedConfig.config, void 0));
|
|
41561
43090
|
const prerenderWorkerChildEnvironments = prerenderWorkerConfig.viteEnvironment?.childEnvironments;
|
|
41562
43091
|
if (prerenderWorkerChildEnvironments) {
|
|
41563
43092
|
for (const childName of prerenderWorkerChildEnvironments) validateAndAddEnvironmentName(childName);
|
|
@@ -41580,7 +43109,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
41580
43109
|
if (Array.isArray(entryWorkerResolvedConfig.config.assets?.run_worker_first)) staticRouting = parseStaticRouting(entryWorkerResolvedConfig.config.assets.run_worker_first);
|
|
41581
43110
|
const entryWorkerEnvironmentName = pluginConfig.viteEnvironment?.name ?? workerNameToEnvironmentName(entryWorkerResolvedConfig.config.topLevelName);
|
|
41582
43111
|
validateAndAddEnvironmentName(entryWorkerEnvironmentName);
|
|
41583
|
-
environmentNameToWorkerMap.set(entryWorkerEnvironmentName, resolveWorker(entryWorkerResolvedConfig.config));
|
|
43112
|
+
environmentNameToWorkerMap.set(entryWorkerEnvironmentName, resolveWorker(entryWorkerResolvedConfig.config, pluginConfig.assetsOnly));
|
|
41584
43113
|
const entryWorkerChildEnvironments = pluginConfig.viteEnvironment?.childEnvironments;
|
|
41585
43114
|
if (entryWorkerChildEnvironments) {
|
|
41586
43115
|
for (const childName of entryWorkerChildEnvironments) validateAndAddEnvironmentName(childName);
|
|
@@ -41600,7 +43129,7 @@ function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
41600
43129
|
auxiliaryWorkersResolvedConfigs.push(workerResolvedConfig);
|
|
41601
43130
|
const workerEnvironmentName = auxiliaryWorker.viteEnvironment?.name ?? workerNameToEnvironmentName(workerResolvedConfig.config.topLevelName);
|
|
41602
43131
|
validateAndAddEnvironmentName(workerEnvironmentName);
|
|
41603
|
-
environmentNameToWorkerMap.set(workerEnvironmentName, resolveWorker(workerResolvedConfig.config));
|
|
43132
|
+
environmentNameToWorkerMap.set(workerEnvironmentName, resolveWorker(workerResolvedConfig.config, auxiliaryWorker.devOnly));
|
|
41604
43133
|
const auxiliaryWorkerChildEnvironments = auxiliaryWorker.viteEnvironment?.childEnvironments;
|
|
41605
43134
|
if (auxiliaryWorkerChildEnvironments) {
|
|
41606
43135
|
for (const childName of auxiliaryWorkerChildEnvironments) validateAndAddEnvironmentName(childName);
|
|
@@ -41635,10 +43164,19 @@ function createEnvironmentNameValidator() {
|
|
|
41635
43164
|
usedNames.add(name);
|
|
41636
43165
|
};
|
|
41637
43166
|
}
|
|
41638
|
-
|
|
43167
|
+
/**
|
|
43168
|
+
* Evaluates the `devOnly` value. Should be called lazily at build time
|
|
43169
|
+
* to allow frameworks to provide the value after initialization.
|
|
43170
|
+
*/
|
|
43171
|
+
function resolveDevOnly(devOnly) {
|
|
43172
|
+
if (typeof devOnly === "function") return devOnly();
|
|
43173
|
+
return devOnly ?? false;
|
|
43174
|
+
}
|
|
43175
|
+
function resolveWorker(workerConfig, devOnly) {
|
|
41639
43176
|
return {
|
|
41640
43177
|
config: workerConfig,
|
|
41641
|
-
nodeJsCompat: hasNodeJsCompat(workerConfig) ? new NodeJsCompat(workerConfig) : void 0
|
|
43178
|
+
nodeJsCompat: hasNodeJsCompat(workerConfig) ? new NodeJsCompat(workerConfig) : void 0,
|
|
43179
|
+
devOnly
|
|
41642
43180
|
};
|
|
41643
43181
|
}
|
|
41644
43182
|
|
|
@@ -42811,9 +44349,9 @@ function constructHeaders({ headers, headersFile, logger }) {
|
|
|
42811
44349
|
|
|
42812
44350
|
//#endregion
|
|
42813
44351
|
//#region ../workers-shared/utils/configuration/validateURL.ts
|
|
42814
|
-
const extractPathname = (path$
|
|
42815
|
-
if (!path$
|
|
42816
|
-
const url = new URL(`//${path$
|
|
44352
|
+
const extractPathname = (path$1 = "/", includeSearch, includeHash) => {
|
|
44353
|
+
if (!path$1.startsWith("/")) path$1 = `/${path$1}`;
|
|
44354
|
+
const url = new URL(`//${path$1}`, "relative://");
|
|
42817
44355
|
return `${url.pathname}${includeSearch ? url.search : ""}${includeHash ? url.hash : ""}`;
|
|
42818
44356
|
};
|
|
42819
44357
|
const URL_REGEX = /^https:\/\/+(?<host>[^/]+)\/?(?<path>.*)/;
|
|
@@ -42872,7 +44410,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
42872
44410
|
lineNumber: i$1 + 1,
|
|
42873
44411
|
message: "No headers specified"
|
|
42874
44412
|
});
|
|
42875
|
-
const [path$
|
|
44413
|
+
const [path$1, pathError] = validateUrl(line, false, true);
|
|
42876
44414
|
if (pathError) {
|
|
42877
44415
|
invalid.push({
|
|
42878
44416
|
line,
|
|
@@ -42883,7 +44421,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
42883
44421
|
skipUntilNextPath = true;
|
|
42884
44422
|
continue;
|
|
42885
44423
|
}
|
|
42886
|
-
const wildcardError = validateNoMultipleWildcards(path$
|
|
44424
|
+
const wildcardError = validateNoMultipleWildcards(path$1);
|
|
42887
44425
|
if (wildcardError) {
|
|
42888
44426
|
invalid.push({
|
|
42889
44427
|
line,
|
|
@@ -42895,7 +44433,7 @@ function parseHeaders(input, { maxRules = MAX_HEADER_RULES, maxLineLength = MAX_
|
|
|
42895
44433
|
continue;
|
|
42896
44434
|
}
|
|
42897
44435
|
rule = {
|
|
42898
|
-
path: path$
|
|
44436
|
+
path: path$1,
|
|
42899
44437
|
line,
|
|
42900
44438
|
headers: {},
|
|
42901
44439
|
unsetHeaders: []
|
|
@@ -42978,11 +44516,11 @@ function isValidRule(rule) {
|
|
|
42978
44516
|
* `:splat` placeholder, would result in duplicate `:splat` parameters which is
|
|
42979
44517
|
* unsupported.
|
|
42980
44518
|
*/
|
|
42981
|
-
function validateNoMultipleWildcards(path$
|
|
42982
|
-
const wildcardCount = (path$
|
|
42983
|
-
const hasSplatPlaceholder = /:splat(?!\w)/.test(path$
|
|
42984
|
-
if (wildcardCount > 1) return `Only one wildcard is allowed per rule. Use a named placeholder (e.g. :project) instead. Skipping ${path$
|
|
42985
|
-
if (wildcardCount > 0 && hasSplatPlaceholder) return `Cannot combine a wildcard * with a :splat placeholder because wildcards are converted to :splat at runtime. Skipping ${path$
|
|
44519
|
+
function validateNoMultipleWildcards(path$1) {
|
|
44520
|
+
const wildcardCount = (path$1.match(SPLAT_REGEX) ?? []).length;
|
|
44521
|
+
const hasSplatPlaceholder = /:splat(?!\w)/.test(path$1);
|
|
44522
|
+
if (wildcardCount > 1) return `Only one wildcard is allowed per rule. Use a named placeholder (e.g. :project) instead. Skipping ${path$1}.`;
|
|
44523
|
+
if (wildcardCount > 0 && hasSplatPlaceholder) return `Cannot combine a wildcard * with a :splat placeholder because wildcards are converted to :splat at runtime. Skipping ${path$1}.`;
|
|
42986
44524
|
}
|
|
42987
44525
|
|
|
42988
44526
|
//#endregion
|
|
@@ -43199,13 +44737,13 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
43199
44737
|
const throwError = (message, Ctor) => {
|
|
43200
44738
|
throw new Ctor(message);
|
|
43201
44739
|
};
|
|
43202
|
-
const checkPath = (path$
|
|
43203
|
-
if (!isString$1(path$
|
|
43204
|
-
if (!path$
|
|
43205
|
-
if (checkPath.isNotRelative(path$
|
|
44740
|
+
const checkPath = (path$1, originalPath, doThrow) => {
|
|
44741
|
+
if (!isString$1(path$1)) return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
44742
|
+
if (!path$1) return doThrow(`path must not be empty`, TypeError);
|
|
44743
|
+
if (checkPath.isNotRelative(path$1)) return doThrow(`path should be a \`path.relative()\`d string, but got "${originalPath}"`, RangeError);
|
|
43206
44744
|
return true;
|
|
43207
44745
|
};
|
|
43208
|
-
const isNotRelative = (path$
|
|
44746
|
+
const isNotRelative = (path$1) => REGEX_TEST_INVALID_PATH.test(path$1);
|
|
43209
44747
|
checkPath.isNotRelative = isNotRelative;
|
|
43210
44748
|
checkPath.convert = (p$1) => p$1;
|
|
43211
44749
|
var Ignore = class {
|
|
@@ -43241,13 +44779,13 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
43241
44779
|
addPattern(pattern) {
|
|
43242
44780
|
return this.add(pattern);
|
|
43243
44781
|
}
|
|
43244
|
-
_testOne(path$
|
|
44782
|
+
_testOne(path$1, checkUnignored) {
|
|
43245
44783
|
let ignored = false;
|
|
43246
44784
|
let unignored = false;
|
|
43247
44785
|
this._rules.forEach((rule) => {
|
|
43248
44786
|
const { negative } = rule;
|
|
43249
44787
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) return;
|
|
43250
|
-
if (rule.regex.test(path$
|
|
44788
|
+
if (rule.regex.test(path$1)) {
|
|
43251
44789
|
ignored = !negative;
|
|
43252
44790
|
unignored = negative;
|
|
43253
44791
|
}
|
|
@@ -43258,33 +44796,33 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
43258
44796
|
};
|
|
43259
44797
|
}
|
|
43260
44798
|
_test(originalPath, cache$2, checkUnignored, slices) {
|
|
43261
|
-
const path$
|
|
43262
|
-
checkPath(path$
|
|
43263
|
-
return this._t(path$
|
|
44799
|
+
const path$1 = originalPath && checkPath.convert(originalPath);
|
|
44800
|
+
checkPath(path$1, originalPath, this._allowRelativePaths ? RETURN_FALSE : throwError);
|
|
44801
|
+
return this._t(path$1, cache$2, checkUnignored, slices);
|
|
43264
44802
|
}
|
|
43265
|
-
_t(path$
|
|
43266
|
-
if (path$
|
|
43267
|
-
if (!slices) slices = path$
|
|
44803
|
+
_t(path$1, cache$2, checkUnignored, slices) {
|
|
44804
|
+
if (path$1 in cache$2) return cache$2[path$1];
|
|
44805
|
+
if (!slices) slices = path$1.split(SLASH);
|
|
43268
44806
|
slices.pop();
|
|
43269
|
-
if (!slices.length) return cache$2[path$
|
|
44807
|
+
if (!slices.length) return cache$2[path$1] = this._testOne(path$1, checkUnignored);
|
|
43270
44808
|
const parent = this._t(slices.join(SLASH) + SLASH, cache$2, checkUnignored, slices);
|
|
43271
|
-
return cache$2[path$
|
|
44809
|
+
return cache$2[path$1] = parent.ignored ? parent : this._testOne(path$1, checkUnignored);
|
|
43272
44810
|
}
|
|
43273
|
-
ignores(path$
|
|
43274
|
-
return this._test(path$
|
|
44811
|
+
ignores(path$1) {
|
|
44812
|
+
return this._test(path$1, this._ignoreCache, false).ignored;
|
|
43275
44813
|
}
|
|
43276
44814
|
createFilter() {
|
|
43277
|
-
return (path$
|
|
44815
|
+
return (path$1) => !this.ignores(path$1);
|
|
43278
44816
|
}
|
|
43279
44817
|
filter(paths) {
|
|
43280
44818
|
return makeArray(paths).filter(this.createFilter());
|
|
43281
44819
|
}
|
|
43282
|
-
test(path$
|
|
43283
|
-
return this._test(path$
|
|
44820
|
+
test(path$1) {
|
|
44821
|
+
return this._test(path$1, this._testCache, true);
|
|
43284
44822
|
}
|
|
43285
44823
|
};
|
|
43286
44824
|
const factory = (options) => new Ignore(options);
|
|
43287
|
-
const isPathValid = (path$
|
|
44825
|
+
const isPathValid = (path$1) => checkPath(path$1 && checkPath.convert(path$1), path$1, RETURN_FALSE);
|
|
43288
44826
|
factory.isPathValid = isPathValid;
|
|
43289
44827
|
factory.default = factory;
|
|
43290
44828
|
module.exports = factory;
|
|
@@ -43293,7 +44831,7 @@ var require_ignore = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ig
|
|
|
43293
44831
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
43294
44832
|
checkPath.convert = makePosix;
|
|
43295
44833
|
const REGIX_IS_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
43296
|
-
checkPath.isNotRelative = (path$
|
|
44834
|
+
checkPath.isNotRelative = (path$1) => REGIX_IS_WINDOWS_PATH_ABSOLUTE.test(path$1) || isNotRelative(path$1);
|
|
43297
44835
|
}
|
|
43298
44836
|
}) });
|
|
43299
44837
|
|
|
@@ -44648,11 +46186,11 @@ var Mime = class {
|
|
|
44648
46186
|
}
|
|
44649
46187
|
return this;
|
|
44650
46188
|
}
|
|
44651
|
-
getType(path$
|
|
44652
|
-
if (typeof path$
|
|
44653
|
-
const last = path$
|
|
46189
|
+
getType(path$1) {
|
|
46190
|
+
if (typeof path$1 !== "string") return null;
|
|
46191
|
+
const last = path$1.replace(/^.*[/\\]/s, "").toLowerCase();
|
|
44654
46192
|
const ext = last.replace(/^.*\./s, "").toLowerCase();
|
|
44655
|
-
const hasPath = last.length < path$
|
|
46193
|
+
const hasPath = last.length < path$1.length;
|
|
44656
46194
|
if (!(ext.length < last.length - 1) && hasPath) return null;
|
|
44657
46195
|
return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
|
|
44658
46196
|
}
|
|
@@ -44707,10 +46245,10 @@ var util;
|
|
|
44707
46245
|
util$27.assertEqual = (_) => {};
|
|
44708
46246
|
function assertIs(_arg) {}
|
|
44709
46247
|
util$27.assertIs = assertIs;
|
|
44710
|
-
function assertNever
|
|
46248
|
+
function assertNever(_x) {
|
|
44711
46249
|
throw new Error();
|
|
44712
46250
|
}
|
|
44713
|
-
util$27.assertNever = assertNever
|
|
46251
|
+
util$27.assertNever = assertNever;
|
|
44714
46252
|
util$27.arrayToEnum = (items) => {
|
|
44715
46253
|
const obj = {};
|
|
44716
46254
|
for (const item of items) obj[item] = item;
|
|
@@ -44986,8 +46524,8 @@ function getErrorMap() {
|
|
|
44986
46524
|
//#endregion
|
|
44987
46525
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
44988
46526
|
const makeIssue = (params) => {
|
|
44989
|
-
const { data: data$1, path: path$
|
|
44990
|
-
const fullPath = [...path$
|
|
46527
|
+
const { data: data$1, path: path$1, errorMaps, issueData } = params;
|
|
46528
|
+
const fullPath = [...path$1, ...issueData.path || []];
|
|
44991
46529
|
const fullIssue = {
|
|
44992
46530
|
...issueData,
|
|
44993
46531
|
path: fullPath
|
|
@@ -45099,11 +46637,11 @@ var errorUtil;
|
|
|
45099
46637
|
//#endregion
|
|
45100
46638
|
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
45101
46639
|
var ParseInputLazyPath = class {
|
|
45102
|
-
constructor(parent, value, path$
|
|
46640
|
+
constructor(parent, value, path$1, key) {
|
|
45103
46641
|
this._cachedPath = [];
|
|
45104
46642
|
this.parent = parent;
|
|
45105
46643
|
this.data = value;
|
|
45106
|
-
this._path = path$
|
|
46644
|
+
this._path = path$1;
|
|
45107
46645
|
this._key = key;
|
|
45108
46646
|
}
|
|
45109
46647
|
get path() {
|
|
@@ -48389,14 +49927,14 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
48389
49927
|
const clientEnvironment = builder.environments.client;
|
|
48390
49928
|
assert(clientEnvironment, `No "client" environment`);
|
|
48391
49929
|
const defaultHtmlPath = nodePath.resolve(builder.config.root, "index.html");
|
|
48392
|
-
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$
|
|
48393
|
-
const workerEnvironments = [...resolvedPluginConfig.environmentNameToWorkerMap.
|
|
49930
|
+
const hasClientEntry = clientEnvironment.config.build.rollupOptions.input || fs$1.existsSync(defaultHtmlPath);
|
|
49931
|
+
const workerEnvironments = [...resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([_, worker]) => !resolveDevOnly(worker.devOnly)).map(([environmentName]) => {
|
|
48394
49932
|
const environment = builder.environments[environmentName];
|
|
48395
49933
|
assert(environment, `"${environmentName}" environment not found`);
|
|
48396
49934
|
return environment;
|
|
48397
49935
|
});
|
|
48398
49936
|
await Promise.all(workerEnvironments.map((environment) => builder.build(environment)));
|
|
48399
|
-
if (resolvedPluginConfig.type === "assets-only") {
|
|
49937
|
+
if (resolvedPluginConfig.type === "assets-only" || !workerEnvironments.some((environment) => environment.name === resolvedPluginConfig.entryWorkerEnvironmentName)) {
|
|
48400
49938
|
if (hasClientEntry) await builder.build(clientEnvironment);
|
|
48401
49939
|
else if (getHasPublicAssets(builder.config) || resolvedPluginConfig.prerenderWorkerEnvironmentName) await fallbackBuild(builder, clientEnvironment);
|
|
48402
49940
|
return;
|
|
@@ -48417,12 +49955,12 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
48417
49955
|
for (const assetPath of importedAssetPaths) {
|
|
48418
49956
|
const src$1 = nodePath.join(entryWorkerBuildDirectory, assetPath);
|
|
48419
49957
|
const dest = nodePath.join(clientBuildDirectory, assetPath);
|
|
48420
|
-
if (!fs$
|
|
48421
|
-
if (fs$
|
|
49958
|
+
if (!fs$1.existsSync(src$1)) continue;
|
|
49959
|
+
if (fs$1.existsSync(dest)) fs$1.unlinkSync(src$1);
|
|
48422
49960
|
else {
|
|
48423
49961
|
const destDir = nodePath.dirname(dest);
|
|
48424
|
-
fs$
|
|
48425
|
-
fs$
|
|
49962
|
+
fs$1.mkdirSync(destDir, { recursive: true });
|
|
49963
|
+
fs$1.renameSync(src$1, dest);
|
|
48426
49964
|
movedAssetPaths.push(dest);
|
|
48427
49965
|
}
|
|
48428
49966
|
}
|
|
@@ -48432,7 +49970,7 @@ function createBuildApp(resolvedPluginConfig) {
|
|
|
48432
49970
|
function getHasPublicAssets({ publicDir }) {
|
|
48433
49971
|
let hasPublicAssets = false;
|
|
48434
49972
|
if (publicDir) try {
|
|
48435
|
-
if (fs$
|
|
49973
|
+
if (fs$1.readdirSync(publicDir).length) hasPublicAssets = true;
|
|
48436
49974
|
} catch {}
|
|
48437
49975
|
return hasPublicAssets;
|
|
48438
49976
|
}
|
|
@@ -48444,10 +49982,10 @@ async function fallbackBuild(builder, environment) {
|
|
|
48444
49982
|
};
|
|
48445
49983
|
await builder.build(environment);
|
|
48446
49984
|
const fallbackEntryPath = nodePath.resolve(builder.config.root, environment.config.build.outDir, CLIENT_FALLBACK_ENTRY_NAME);
|
|
48447
|
-
fs$
|
|
49985
|
+
fs$1.unlinkSync(fallbackEntryPath);
|
|
48448
49986
|
}
|
|
48449
49987
|
function loadViteManifest(directory) {
|
|
48450
|
-
const contents = fs$
|
|
49988
|
+
const contents = fs$1.readFileSync(nodePath.resolve(directory, ".vite", "manifest.json"), "utf-8");
|
|
48451
49989
|
return JSON.parse(contents);
|
|
48452
49990
|
}
|
|
48453
49991
|
function getImportedAssetPaths(viteManifest) {
|
|
@@ -48459,9 +49997,9 @@ function getImportedAssetPaths(viteManifest) {
|
|
|
48459
49997
|
*/
|
|
48460
49998
|
function removeAssetsField(entryWorkerBuildDirectory) {
|
|
48461
49999
|
const entryWorkerConfigPath = nodePath.join(entryWorkerBuildDirectory, "wrangler.json");
|
|
48462
|
-
const workerConfig = JSON.parse(fs$
|
|
50000
|
+
const workerConfig = JSON.parse(fs$1.readFileSync(entryWorkerConfigPath, "utf-8"));
|
|
48463
50001
|
workerConfig.assets = void 0;
|
|
48464
|
-
fs$
|
|
50002
|
+
fs$1.writeFileSync(entryWorkerConfigPath, JSON.stringify(workerConfig));
|
|
48465
50003
|
}
|
|
48466
50004
|
|
|
48467
50005
|
//#endregion
|
|
@@ -48816,7 +50354,7 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
48816
50354
|
order: "post",
|
|
48817
50355
|
async handler(builder) {
|
|
48818
50356
|
if (ctx.resolvedPluginConfig.type !== "workers") return;
|
|
48819
|
-
const workerEnvironments = [...ctx.resolvedPluginConfig.environmentNameToWorkerMap.
|
|
50357
|
+
const workerEnvironments = [...ctx.resolvedPluginConfig.environmentNameToWorkerMap.entries()].filter(([_, worker]) => !resolveDevOnly(worker.devOnly)).map(([environmentName]) => {
|
|
48820
50358
|
const environment = builder.environments[environmentName];
|
|
48821
50359
|
assert(environment, `"${environmentName}" environment not found`);
|
|
48822
50360
|
return environment;
|
|
@@ -48825,8 +50363,27 @@ const configPlugin = createPlugin("config", (ctx) => {
|
|
|
48825
50363
|
const { entryWorkerEnvironmentName } = ctx.resolvedPluginConfig;
|
|
48826
50364
|
const entryWorkerEnvironment = builder.environments[entryWorkerEnvironmentName];
|
|
48827
50365
|
assert(entryWorkerEnvironment, `No "${entryWorkerEnvironmentName}" environment`);
|
|
48828
|
-
|
|
48829
|
-
|
|
50366
|
+
if (entryWorkerEnvironment.isBuilt) {
|
|
50367
|
+
if (!builder.environments.client?.isBuilt) removeAssetsField(nodePath.resolve(builder.config.root, entryWorkerEnvironment.config.build.outDir));
|
|
50368
|
+
} else {
|
|
50369
|
+
const clientEnvironment = builder.environments.client;
|
|
50370
|
+
assert(clientEnvironment, "No \"client\" environment");
|
|
50371
|
+
if (!clientEnvironment.isBuilt) throw new Error("If `assetsOnly` is set to `true`, the client environment must be built");
|
|
50372
|
+
const entryWorkerConfig = ctx.getWorkerConfig(entryWorkerEnvironmentName);
|
|
50373
|
+
assert(entryWorkerConfig, `No config found for "${entryWorkerEnvironmentName}" environment`);
|
|
50374
|
+
const outputConfig = {
|
|
50375
|
+
...entryWorkerConfig,
|
|
50376
|
+
main: void 0,
|
|
50377
|
+
assets: {
|
|
50378
|
+
...entryWorkerConfig.assets,
|
|
50379
|
+
directory: ".",
|
|
50380
|
+
binding: void 0
|
|
50381
|
+
}
|
|
50382
|
+
};
|
|
50383
|
+
if (outputConfig.unsafe && Object.keys(outputConfig.unsafe).length === 0) outputConfig.unsafe = void 0;
|
|
50384
|
+
fs$1.writeFileSync(nodePath.resolve(builder.config.root, clientEnvironment.config.build.outDir, "wrangler.json"), JSON.stringify(outputConfig));
|
|
50385
|
+
writeDeployConfig(ctx.resolvedPluginConfig, ctx.resolvedViteConfig, true);
|
|
50386
|
+
}
|
|
48830
50387
|
}
|
|
48831
50388
|
}
|
|
48832
50389
|
};
|
|
@@ -49135,11 +50692,11 @@ const getQueryString = (params) => {
|
|
|
49135
50692
|
};
|
|
49136
50693
|
const getUrl = (config, options) => {
|
|
49137
50694
|
const encoder$1 = config.ENCODE_PATH || encodeURI;
|
|
49138
|
-
const path$
|
|
50695
|
+
const path$1 = options.url.replace("{api-version}", config.VERSION).replace(/{(.*?)}/g, (substring, group) => {
|
|
49139
50696
|
if (options.path?.hasOwnProperty(group)) return encoder$1(String(options.path[group]));
|
|
49140
50697
|
return substring;
|
|
49141
50698
|
});
|
|
49142
|
-
const url = `${config.BASE}${path$
|
|
50699
|
+
const url = `${config.BASE}${path$1}`;
|
|
49143
50700
|
if (options.query) return `${url}${getQueryString(options.query)}`;
|
|
49144
50701
|
return url;
|
|
49145
50702
|
};
|
|
@@ -50190,7 +51747,7 @@ function getContainerOptions(options) {
|
|
|
50190
51747
|
return containersConfig.map((container) => {
|
|
50191
51748
|
if (isDockerfile(container.image, configPath)) return {
|
|
50192
51749
|
dockerfile: container.image,
|
|
50193
|
-
image_build_context: container.image_build_context ??
|
|
51750
|
+
image_build_context: container.image_build_context ?? path3.dirname(container.image),
|
|
50194
51751
|
image_vars: container.image_vars,
|
|
50195
51752
|
class_name: container.class_name,
|
|
50196
51753
|
image_tag: getDevContainerImageName(container.class_name, containerBuildId)
|
|
@@ -50206,26 +51763,26 @@ function getContainerOptions(options) {
|
|
|
50206
51763
|
//#endregion
|
|
50207
51764
|
//#region ../../node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
|
|
50208
51765
|
var __require = /* @__PURE__ */ createRequire$1(import.meta.url);
|
|
50209
|
-
function cleanPath(path$
|
|
50210
|
-
let normalized = normalize(path$
|
|
51766
|
+
function cleanPath(path$1) {
|
|
51767
|
+
let normalized = normalize(path$1);
|
|
50211
51768
|
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
50212
51769
|
return normalized;
|
|
50213
51770
|
}
|
|
50214
51771
|
const SLASHES_REGEX = /[\\/]/g;
|
|
50215
|
-
function convertSlashes(path$
|
|
50216
|
-
return path$
|
|
51772
|
+
function convertSlashes(path$1, separator) {
|
|
51773
|
+
return path$1.replace(SLASHES_REGEX, separator);
|
|
50217
51774
|
}
|
|
50218
51775
|
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
50219
|
-
function isRootDirectory(path$
|
|
50220
|
-
return path$
|
|
51776
|
+
function isRootDirectory(path$1) {
|
|
51777
|
+
return path$1 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$1);
|
|
50221
51778
|
}
|
|
50222
|
-
function normalizePath$1(path$
|
|
51779
|
+
function normalizePath$1(path$1, options) {
|
|
50223
51780
|
const { resolvePaths, normalizePath: normalizePath$1$1, pathSeparator } = options;
|
|
50224
|
-
const pathNeedsCleaning = process.platform === "win32" && path$
|
|
50225
|
-
if (resolvePaths) path$
|
|
50226
|
-
if (normalizePath$1$1 || pathNeedsCleaning) path$
|
|
50227
|
-
if (path$
|
|
50228
|
-
return convertSlashes(path$
|
|
51781
|
+
const pathNeedsCleaning = process.platform === "win32" && path$1.includes("/") || path$1.startsWith(".");
|
|
51782
|
+
if (resolvePaths) path$1 = resolve$1(path$1);
|
|
51783
|
+
if (normalizePath$1$1 || pathNeedsCleaning) path$1 = cleanPath(path$1);
|
|
51784
|
+
if (path$1 === ".") return "";
|
|
51785
|
+
return convertSlashes(path$1[path$1.length - 1] !== pathSeparator ? path$1 + pathSeparator : path$1, pathSeparator);
|
|
50229
51786
|
}
|
|
50230
51787
|
function joinPathWithBasePath(filename, directoryPath) {
|
|
50231
51788
|
return directoryPath + filename;
|
|
@@ -50261,8 +51818,8 @@ const pushDirectory = (directoryPath, paths) => {
|
|
|
50261
51818
|
paths.push(directoryPath || ".");
|
|
50262
51819
|
};
|
|
50263
51820
|
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
50264
|
-
const path$
|
|
50265
|
-
if (filters.every((filter) => filter(path$
|
|
51821
|
+
const path$1 = directoryPath || ".";
|
|
51822
|
+
if (filters.every((filter) => filter(path$1, true))) paths.push(path$1);
|
|
50266
51823
|
};
|
|
50267
51824
|
const empty$2 = () => {};
|
|
50268
51825
|
function build$6(root, options) {
|
|
@@ -50311,26 +51868,26 @@ const empty = () => {};
|
|
|
50311
51868
|
function build$3(options) {
|
|
50312
51869
|
return options.group ? groupFiles : empty;
|
|
50313
51870
|
}
|
|
50314
|
-
const resolveSymlinksAsync = function(path$
|
|
50315
|
-
const { queue, fs: fs$
|
|
51871
|
+
const resolveSymlinksAsync = function(path$1, state, callback$1) {
|
|
51872
|
+
const { queue, fs: fs$2, options: { suppressErrors } } = state;
|
|
50316
51873
|
queue.enqueue();
|
|
50317
|
-
fs$
|
|
51874
|
+
fs$2.realpath(path$1, (error, resolvedPath) => {
|
|
50318
51875
|
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
50319
|
-
fs$
|
|
51876
|
+
fs$2.stat(resolvedPath, (error$1, stat) => {
|
|
50320
51877
|
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
50321
|
-
if (stat.isDirectory() && isRecursive(path$
|
|
51878
|
+
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
50322
51879
|
callback$1(stat, resolvedPath);
|
|
50323
51880
|
queue.dequeue(null, state);
|
|
50324
51881
|
});
|
|
50325
51882
|
});
|
|
50326
51883
|
};
|
|
50327
|
-
const resolveSymlinks = function(path$
|
|
50328
|
-
const { queue, fs: fs$
|
|
51884
|
+
const resolveSymlinks = function(path$1, state, callback$1) {
|
|
51885
|
+
const { queue, fs: fs$2, options: { suppressErrors } } = state;
|
|
50329
51886
|
queue.enqueue();
|
|
50330
51887
|
try {
|
|
50331
|
-
const resolvedPath = fs$
|
|
50332
|
-
const stat = fs$
|
|
50333
|
-
if (stat.isDirectory() && isRecursive(path$
|
|
51888
|
+
const resolvedPath = fs$2.realpathSync(path$1);
|
|
51889
|
+
const stat = fs$2.statSync(resolvedPath);
|
|
51890
|
+
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
50334
51891
|
callback$1(stat, resolvedPath);
|
|
50335
51892
|
} catch (e) {
|
|
50336
51893
|
if (!suppressErrors) throw e;
|
|
@@ -50340,16 +51897,16 @@ function build$2(options, isSynchronous) {
|
|
|
50340
51897
|
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
50341
51898
|
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
50342
51899
|
}
|
|
50343
|
-
function isRecursive(path$
|
|
51900
|
+
function isRecursive(path$1, resolved, state) {
|
|
50344
51901
|
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
50345
|
-
let parent = dirname$1(path$
|
|
51902
|
+
let parent = dirname$1(path$1);
|
|
50346
51903
|
let depth$1 = 1;
|
|
50347
51904
|
while (parent !== state.root && depth$1 < 2) {
|
|
50348
51905
|
const resolvedPath = state.symlinks.get(parent);
|
|
50349
51906
|
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth$1++;
|
|
50350
51907
|
else parent = dirname$1(parent);
|
|
50351
51908
|
}
|
|
50352
|
-
state.symlinks.set(path$
|
|
51909
|
+
state.symlinks.set(path$1, resolved);
|
|
50353
51910
|
return depth$1 > 1;
|
|
50354
51911
|
}
|
|
50355
51912
|
function isRecursiveUsingRealPaths(resolved, state) {
|
|
@@ -50398,22 +51955,22 @@ const readdirOpts = { withFileTypes: true };
|
|
|
50398
51955
|
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
50399
51956
|
state.queue.enqueue();
|
|
50400
51957
|
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
50401
|
-
const { fs: fs$
|
|
51958
|
+
const { fs: fs$2 } = state;
|
|
50402
51959
|
state.visited.push(crawlPath);
|
|
50403
51960
|
state.counts.directories++;
|
|
50404
|
-
fs$
|
|
51961
|
+
fs$2.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
50405
51962
|
callback$1(entries, directoryPath, currentDepth);
|
|
50406
51963
|
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
50407
51964
|
});
|
|
50408
51965
|
};
|
|
50409
51966
|
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
50410
|
-
const { fs: fs$
|
|
51967
|
+
const { fs: fs$2 } = state;
|
|
50411
51968
|
if (currentDepth < 0) return;
|
|
50412
51969
|
state.visited.push(crawlPath);
|
|
50413
51970
|
state.counts.directories++;
|
|
50414
51971
|
let entries = [];
|
|
50415
51972
|
try {
|
|
50416
|
-
entries = fs$
|
|
51973
|
+
entries = fs$2.readdirSync(crawlPath || ".", readdirOpts);
|
|
50417
51974
|
} catch (e) {
|
|
50418
51975
|
if (!state.options.suppressErrors) throw e;
|
|
50419
51976
|
}
|
|
@@ -50530,19 +52087,19 @@ var Walker = class {
|
|
|
50530
52087
|
const filename = this.joinPath(entry.name, directoryPath);
|
|
50531
52088
|
this.pushFile(filename, files, this.state.counts, filters);
|
|
50532
52089
|
} else if (entry.isDirectory()) {
|
|
50533
|
-
let path$
|
|
50534
|
-
if (exclude && exclude(entry.name, path$
|
|
50535
|
-
this.pushDirectory(path$
|
|
50536
|
-
this.walkDirectory(this.state, path$
|
|
52090
|
+
let path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
52091
|
+
if (exclude && exclude(entry.name, path$1)) continue;
|
|
52092
|
+
this.pushDirectory(path$1, paths, filters);
|
|
52093
|
+
this.walkDirectory(this.state, path$1, path$1, depth$1 - 1, this.walk);
|
|
50537
52094
|
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
50538
|
-
let path$
|
|
50539
|
-
this.resolveSymlink(path$
|
|
52095
|
+
let path$1 = joinPathWithBasePath(entry.name, directoryPath);
|
|
52096
|
+
this.resolveSymlink(path$1, this.state, (stat, resolvedPath) => {
|
|
50540
52097
|
if (stat.isDirectory()) {
|
|
50541
52098
|
resolvedPath = normalizePath$1(resolvedPath, this.state.options);
|
|
50542
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$
|
|
50543
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$
|
|
52099
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
|
|
52100
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth$1 - 1, this.walk);
|
|
50544
52101
|
} else {
|
|
50545
|
-
resolvedPath = useRealPaths ? resolvedPath : path$
|
|
52102
|
+
resolvedPath = useRealPaths ? resolvedPath : path$1;
|
|
50546
52103
|
const filename = basename(resolvedPath);
|
|
50547
52104
|
const directoryPath$1 = normalizePath$1(dirname$1(resolvedPath), this.state.options);
|
|
50548
52105
|
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
@@ -50707,7 +52264,7 @@ var Builder = class {
|
|
|
50707
52264
|
isMatch = globFn(patterns, ...options);
|
|
50708
52265
|
this.globCache[patterns.join("\0")] = isMatch;
|
|
50709
52266
|
}
|
|
50710
|
-
this.options.filters.push((path$
|
|
52267
|
+
this.options.filters.push((path$1) => isMatch(path$1));
|
|
50711
52268
|
return this;
|
|
50712
52269
|
}
|
|
50713
52270
|
};
|
|
@@ -50918,8 +52475,8 @@ var require_utils = /* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/pic
|
|
|
50918
52475
|
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
50919
52476
|
return output;
|
|
50920
52477
|
};
|
|
50921
|
-
exports.basename = (path$
|
|
50922
|
-
const segs = path$
|
|
52478
|
+
exports.basename = (path$1, { windows } = {}) => {
|
|
52479
|
+
const segs = path$1.split(windows ? /[\\/]/ : "/");
|
|
50923
52480
|
const last = segs[segs.length - 1];
|
|
50924
52481
|
if (last === "") return segs[segs.length - 2];
|
|
50925
52482
|
return last;
|
|
@@ -52454,15 +54011,15 @@ function buildRelative(cwd, root) {
|
|
|
52454
54011
|
};
|
|
52455
54012
|
}
|
|
52456
54013
|
const splitPatternOptions = { parts: true };
|
|
52457
|
-
function splitPattern(path$1
|
|
54014
|
+
function splitPattern(path$1) {
|
|
52458
54015
|
var _result$parts;
|
|
52459
|
-
const result = import_picomatch.default.scan(path$1
|
|
52460
|
-
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1
|
|
54016
|
+
const result = import_picomatch.default.scan(path$1, splitPatternOptions);
|
|
54017
|
+
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$1];
|
|
52461
54018
|
}
|
|
52462
54019
|
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
52463
54020
|
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
52464
|
-
const escapePosixPath = (path$1
|
|
52465
|
-
const escapeWin32Path = (path$1
|
|
54021
|
+
const escapePosixPath = (path$1) => path$1.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
54022
|
+
const escapeWin32Path = (path$1) => path$1.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
52466
54023
|
/**
|
|
52467
54024
|
* Escapes a path's special characters depending on the platform.
|
|
52468
54025
|
* @see {@link https://superchupu.dev/tinyglobby/documentation#escapePath}
|
|
@@ -52497,7 +54054,7 @@ function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
|
52497
54054
|
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
|
|
52498
54055
|
if (!result.endsWith("*") && expandDirectories) result += "/**";
|
|
52499
54056
|
const escapedCwd = escapePath(cwd);
|
|
52500
|
-
if (path
|
|
54057
|
+
if (path.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = posix.relative(escapedCwd, result);
|
|
52501
54058
|
else result = posix.normalize(result);
|
|
52502
54059
|
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
52503
54060
|
const parts = splitPattern(result);
|
|
@@ -52556,15 +54113,15 @@ function processPatterns({ patterns = ["**/*"], ignore: ignore$1 = [], expandDir
|
|
|
52556
54113
|
}
|
|
52557
54114
|
function formatPaths(paths, relative$2) {
|
|
52558
54115
|
for (let i$1 = paths.length - 1; i$1 >= 0; i$1--) {
|
|
52559
|
-
const path$1
|
|
52560
|
-
paths[i$1] = relative$2(path$1
|
|
54116
|
+
const path$1 = paths[i$1];
|
|
54117
|
+
paths[i$1] = relative$2(path$1);
|
|
52561
54118
|
}
|
|
52562
54119
|
return paths;
|
|
52563
54120
|
}
|
|
52564
54121
|
function normalizeCwd(cwd) {
|
|
52565
54122
|
if (!cwd) return process.cwd().replace(BACKSLASHES, "/");
|
|
52566
54123
|
if (cwd instanceof URL) return fileURLToPath$1(cwd).replace(BACKSLASHES, "/");
|
|
52567
|
-
return path
|
|
54124
|
+
return path.resolve(cwd).replace(BACKSLASHES, "/");
|
|
52568
54125
|
}
|
|
52569
54126
|
function getCrawler(patterns, inputOptions = {}) {
|
|
52570
54127
|
const options = process.env.TINYGLOBBY_DEBUG ? {
|
|
@@ -52609,9 +54166,9 @@ function getCrawler(patterns, inputOptions = {}) {
|
|
|
52609
54166
|
const formatExclude = options.absolute ? format$2 : buildFormat(cwd, props.root, true);
|
|
52610
54167
|
const fdirOptions = {
|
|
52611
54168
|
filters: [options.debug ? (p$1, isDirectory$1) => {
|
|
52612
|
-
const path$1
|
|
52613
|
-
const matches = matcher(path$1
|
|
52614
|
-
if (matches) log(`matched ${path$1
|
|
54169
|
+
const path$1 = format$2(p$1, isDirectory$1);
|
|
54170
|
+
const matches = matcher(path$1);
|
|
54171
|
+
if (matches) log(`matched ${path$1}`);
|
|
52615
54172
|
return matches;
|
|
52616
54173
|
} : (p$1, isDirectory$1) => matcher(format$2(p$1, isDirectory$1))],
|
|
52617
54174
|
exclude: options.debug ? (_, p$1) => {
|
|
@@ -52697,7 +54254,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
52697
54254
|
modules: [{
|
|
52698
54255
|
type: "ESModule",
|
|
52699
54256
|
path: nodePath.join(miniflareModulesRoot, ROUTER_WORKER_PATH),
|
|
52700
|
-
contents: fs$
|
|
54257
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(ROUTER_WORKER_PATH, import.meta.url)))
|
|
52701
54258
|
}],
|
|
52702
54259
|
bindings: { CONFIG: { has_user_worker: resolvedPluginConfig.type === "workers" } },
|
|
52703
54260
|
serviceBindings: {
|
|
@@ -52712,7 +54269,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
52712
54269
|
modules: [{
|
|
52713
54270
|
type: "ESModule",
|
|
52714
54271
|
path: nodePath.join(miniflareModulesRoot, ASSET_WORKER_PATH),
|
|
52715
|
-
contents: fs$
|
|
54272
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(ASSET_WORKER_PATH, import.meta.url)))
|
|
52716
54273
|
}],
|
|
52717
54274
|
bindings: {
|
|
52718
54275
|
CONFIG: assetsConfig,
|
|
@@ -52756,7 +54313,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
52756
54313
|
modules: [{
|
|
52757
54314
|
type: "ESModule",
|
|
52758
54315
|
path: nodePath.join(miniflareModulesRoot, VITE_PROXY_WORKER_PATH),
|
|
52759
|
-
contents: fs$
|
|
54316
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(VITE_PROXY_WORKER_PATH, import.meta.url)))
|
|
52760
54317
|
}],
|
|
52761
54318
|
serviceBindings: {
|
|
52762
54319
|
...entryWorkerConfig ? { ENTRY_USER_WORKER: entryWorkerConfig.name } : {},
|
|
@@ -52817,12 +54374,12 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
52817
54374
|
{
|
|
52818
54375
|
type: "ESModule",
|
|
52819
54376
|
path: nodePath.join(miniflareModulesRoot, RUNNER_PATH),
|
|
52820
|
-
contents: fs$
|
|
54377
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(RUNNER_PATH, import.meta.url)))
|
|
52821
54378
|
},
|
|
52822
54379
|
{
|
|
52823
54380
|
type: "ESModule",
|
|
52824
54381
|
path: nodePath.join(miniflareModulesRoot, "workers/runner-worker/vite/module-runner"),
|
|
52825
|
-
contents: fs$
|
|
54382
|
+
contents: fs$1.readFileSync(fileURLToPath(new URL(satisfiesMinimumViteVersion("7.2.0") ? MODULE_RUNNER_PATH : MODULE_RUNNER_LEGACY_PATH, import.meta.url)))
|
|
52826
54383
|
}
|
|
52827
54384
|
],
|
|
52828
54385
|
unsafeUseModuleFallbackService: true,
|
|
@@ -53384,12 +54941,12 @@ const outputConfigPlugin = createPlugin("output-config", (ctx) => {
|
|
|
53384
54941
|
},
|
|
53385
54942
|
writeBundle() {
|
|
53386
54943
|
assertIsNotPreview(ctx);
|
|
53387
|
-
if (this.environment.name === (ctx.resolvedPluginConfig.type === "workers" ? ctx.resolvedPluginConfig.entryWorkerEnvironmentName : "client")) writeDeployConfig(ctx.resolvedPluginConfig, ctx.resolvedViteConfig);
|
|
54944
|
+
if (this.environment.name === (ctx.resolvedPluginConfig.type === "workers" ? ctx.resolvedPluginConfig.entryWorkerEnvironmentName : "client")) writeDeployConfig(ctx.resolvedPluginConfig, ctx.resolvedViteConfig, ctx.resolvedPluginConfig.type === "assets-only");
|
|
53388
54945
|
}
|
|
53389
54946
|
};
|
|
53390
54947
|
});
|
|
53391
54948
|
function readAssetsIgnoreFile(assetsIgnorePath) {
|
|
53392
|
-
const content = existsSync(assetsIgnorePath) ? readFileSync(assetsIgnorePath, "utf-8") : "";
|
|
54949
|
+
const content = fs$1.existsSync(assetsIgnorePath) ? fs$1.readFileSync(assetsIgnorePath, "utf-8") : "";
|
|
53393
54950
|
if (content.length === 0) return "";
|
|
53394
54951
|
return content.at(-1) === "\n" ? content : `${content}\n`;
|
|
53395
54952
|
}
|
|
@@ -53477,7 +55034,7 @@ const rscPlugin = createPlugin("rsc", () => {
|
|
|
53477
55034
|
let isDockerCached;
|
|
53478
55035
|
function hasDockerEnv() {
|
|
53479
55036
|
try {
|
|
53480
|
-
|
|
55037
|
+
fs2.statSync("/.dockerenv");
|
|
53481
55038
|
return true;
|
|
53482
55039
|
} catch {
|
|
53483
55040
|
return false;
|
|
@@ -53485,7 +55042,7 @@ function hasDockerEnv() {
|
|
|
53485
55042
|
}
|
|
53486
55043
|
function hasDockerCGroup() {
|
|
53487
55044
|
try {
|
|
53488
|
-
return
|
|
55045
|
+
return fs2.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
53489
55046
|
} catch {
|
|
53490
55047
|
return false;
|
|
53491
55048
|
}
|
|
@@ -53500,7 +55057,7 @@ function isDocker() {
|
|
|
53500
55057
|
let cachedResult;
|
|
53501
55058
|
const hasContainerEnv = () => {
|
|
53502
55059
|
try {
|
|
53503
|
-
|
|
55060
|
+
fs2.statSync("/run/.containerenv");
|
|
53504
55061
|
return true;
|
|
53505
55062
|
} catch {
|
|
53506
55063
|
return false;
|
|
@@ -53520,7 +55077,7 @@ const isWsl = () => {
|
|
|
53520
55077
|
return true;
|
|
53521
55078
|
}
|
|
53522
55079
|
try {
|
|
53523
|
-
return
|
|
55080
|
+
return fs2.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
|
|
53524
55081
|
} catch {
|
|
53525
55082
|
return false;
|
|
53526
55083
|
}
|
|
@@ -53571,11 +55128,11 @@ const wslDrivesMountPoint = (() => {
|
|
|
53571
55128
|
const configFilePath = "/etc/wsl.conf";
|
|
53572
55129
|
let isConfigFileExists = false;
|
|
53573
55130
|
try {
|
|
53574
|
-
await fs
|
|
55131
|
+
await fs.access(configFilePath, constants$1.F_OK);
|
|
53575
55132
|
isConfigFileExists = true;
|
|
53576
55133
|
} catch {}
|
|
53577
55134
|
if (!isConfigFileExists) return defaultMountPoint;
|
|
53578
|
-
const parsedMountPoint = parseMountPointFromConfig(await fs
|
|
55135
|
+
const parsedMountPoint = parseMountPointFromConfig(await fs.readFile(configFilePath, { encoding: "utf8" }));
|
|
53579
55136
|
if (parsedMountPoint === void 0) return defaultMountPoint;
|
|
53580
55137
|
mountPoint = parsedMountPoint;
|
|
53581
55138
|
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
@@ -53591,7 +55148,7 @@ const canAccessPowerShell = async () => {
|
|
|
53591
55148
|
canAccessPowerShellPromise ??= (async () => {
|
|
53592
55149
|
try {
|
|
53593
55150
|
const psPath = await powerShellPath();
|
|
53594
|
-
await fs
|
|
55151
|
+
await fs.access(psPath, constants$1.X_OK);
|
|
53595
55152
|
return true;
|
|
53596
55153
|
} catch {
|
|
53597
55154
|
return false;
|
|
@@ -53604,13 +55161,13 @@ const wslDefaultBrowser = async () => {
|
|
|
53604
55161
|
const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
|
|
53605
55162
|
return stdout.trim();
|
|
53606
55163
|
};
|
|
53607
|
-
const convertWslPathToWindows = async (path$
|
|
53608
|
-
if (/^[a-z]+:\/\//i.test(path$
|
|
55164
|
+
const convertWslPathToWindows = async (path$1) => {
|
|
55165
|
+
if (/^[a-z]+:\/\//i.test(path$1)) return path$1;
|
|
53609
55166
|
try {
|
|
53610
|
-
const { stdout } = await execFile$1("wslpath", ["-aw", path$
|
|
55167
|
+
const { stdout } = await execFile$1("wslpath", ["-aw", path$1], { encoding: "utf8" });
|
|
53611
55168
|
return stdout.trim();
|
|
53612
55169
|
} catch {
|
|
53613
|
-
return path$
|
|
55170
|
+
return path$1;
|
|
53614
55171
|
}
|
|
53615
55172
|
};
|
|
53616
55173
|
|
|
@@ -53796,8 +55353,8 @@ var is_in_ssh_default = isInSsh;
|
|
|
53796
55353
|
//#endregion
|
|
53797
55354
|
//#region ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
53798
55355
|
const fallbackAttemptSymbol = Symbol("fallbackAttempt");
|
|
53799
|
-
const __dirname = import.meta.url ?
|
|
53800
|
-
const localXdgOpenPath =
|
|
55356
|
+
const __dirname = import.meta.url ? path3.dirname(fileURLToPath(import.meta.url)) : "";
|
|
55357
|
+
const localXdgOpenPath = path3.join(__dirname, "xdg-open");
|
|
53801
55358
|
const { platform, arch: arch$1 } = process$1;
|
|
53802
55359
|
const tryEachApp = async (apps$1, opener) => {
|
|
53803
55360
|
if (apps$1.length === 0) return;
|
|
@@ -53908,7 +55465,7 @@ const baseOpen = async (options) => {
|
|
|
53908
55465
|
const isBundled = !__dirname || __dirname === "/";
|
|
53909
55466
|
let exeLocalXdgOpen = false;
|
|
53910
55467
|
try {
|
|
53911
|
-
await fs
|
|
55468
|
+
await fs.access(localXdgOpenPath, constants$1.X_OK);
|
|
53912
55469
|
exeLocalXdgOpen = true;
|
|
53913
55470
|
} catch {}
|
|
53914
55471
|
command = process$1.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
|