zeed 0.7.152 → 0.7.157

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.
@@ -3,8 +3,10 @@ import {
3
3
  __name,
4
4
  __spreadProps,
5
5
  __spreadValues,
6
+ deepMerge,
6
7
  getGlobalContext,
7
8
  getTimestamp,
9
+ isArray,
8
10
  useLevelFilter,
9
11
  useNamespaceFilter
10
12
  } from "./chunk-LMZGFDSJ.js";
@@ -69,6 +71,22 @@ function toUint8Array(data) {
69
71
  return data;
70
72
  }
71
73
  __name(toUint8Array, "toUint8Array");
74
+ function joinToUint8Array(...args) {
75
+ let length = 0;
76
+ const bins = args.flat(1).map((d) => {
77
+ const b = toUint8Array(d);
78
+ length += b.length;
79
+ return b;
80
+ });
81
+ let bin = new Uint8Array(length);
82
+ let cursor = 0;
83
+ for (let b of bins) {
84
+ bin.set(b, cursor);
85
+ cursor += b.length;
86
+ }
87
+ return bin;
88
+ }
89
+ __name(joinToUint8Array, "joinToUint8Array");
72
90
  function toHex(bin) {
73
91
  if (typeof Buffer !== "undefined") {
74
92
  return Buffer.from(toUint8Array(bin)).toString("hex");
@@ -2374,7 +2392,7 @@ __name(debounce, "debounce");
2374
2392
 
2375
2393
  // src/common/localhost.ts
2376
2394
  function isLocalHost(hostname = ((_a) => (_a = globalThis == null ? void 0 : globalThis.location) == null ? void 0 : _a.hostname)() ?? "") {
2377
- return ["localhost", "127.0.0.1", "", "::1", "::"].includes(hostname) || hostname.startsWith("192.168.") || hostname.startsWith("10.0.") || hostname.endsWith(".local");
2395
+ return ["::ffff:127.0.0.1", "localhost", "127.0.0.1", "", "::1", "::"].includes(hostname) || hostname.startsWith("192.168.") || hostname.startsWith("10.0.") || hostname.endsWith(".local");
2378
2396
  }
2379
2397
  __name(isLocalHost, "isLocalHost");
2380
2398
 
@@ -2419,14 +2437,14 @@ var LocalChannel = class extends Channel {
2419
2437
  }
2420
2438
  };
2421
2439
  __name(LocalChannel, "LocalChannel");
2422
- function fakeWorkerPair() {
2440
+ function createLocalChannelPair() {
2423
2441
  let w1 = new LocalChannel();
2424
2442
  let w2 = new LocalChannel();
2425
2443
  w1.other = w2;
2426
2444
  w2.other = w1;
2427
2445
  return [w1, w2];
2428
2446
  }
2429
- __name(fakeWorkerPair, "fakeWorkerPair");
2447
+ __name(createLocalChannelPair, "createLocalChannelPair");
2430
2448
 
2431
2449
  // src/common/msg/encoder.ts
2432
2450
  var NoopEncoder = class {
@@ -2737,10 +2755,14 @@ __name(useRPC, "useRPC");
2737
2755
  var log8 = Logger("network");
2738
2756
  var defaultOptions = {
2739
2757
  cache: "no-cache",
2740
- redirect: "follow"
2758
+ redirect: "follow",
2759
+ headers: {}
2741
2760
  };
2742
2761
  async function fetchBasic(url, fetchOptions = {}, fetchFn = fetch) {
2743
2762
  try {
2763
+ if (isArray(fetchOptions)) {
2764
+ fetchOptions = deepMerge({}, ...arrayFlatten(fetchOptions));
2765
+ }
2744
2766
  const response = await fetchFn(String(url), fetchOptions);
2745
2767
  if (response.status < 400) {
2746
2768
  return response;
@@ -2756,13 +2778,17 @@ async function fetchBasic(url, fetchOptions = {}, fetchFn = fetch) {
2756
2778
  }
2757
2779
  }
2758
2780
  __name(fetchBasic, "fetchBasic");
2759
- async function fetchJson(url, opts = {}, fetchFn = fetch) {
2781
+ async function fetchJson(url, fetchOptions = {}, fetchFn = fetch) {
2760
2782
  try {
2761
- let res = await fetchBasic(url, __spreadValues(__spreadProps(__spreadValues({
2762
- method: "GET"
2763
- }, defaultOptions), {
2764
- headers: {}
2765
- }), opts), fetchFn);
2783
+ let res = await fetchBasic(url, [
2784
+ {
2785
+ method: "GET",
2786
+ headers: {
2787
+ Accept: "application/json"
2788
+ }
2789
+ },
2790
+ fetchOptions
2791
+ ], fetchFn);
2766
2792
  if (res) {
2767
2793
  return await res.json();
2768
2794
  }
@@ -2771,6 +2797,17 @@ async function fetchJson(url, opts = {}, fetchFn = fetch) {
2771
2797
  }
2772
2798
  }
2773
2799
  __name(fetchJson, "fetchJson");
2800
+ async function fetchText(url, fetchOptions = {}, fetchFn = fetch) {
2801
+ try {
2802
+ let res = await fetchBasic(url, [defaultOptions, { method: "GET" }, fetchOptions], fetchFn);
2803
+ if (res) {
2804
+ return await res.text();
2805
+ }
2806
+ } catch (err) {
2807
+ log8.error("fetchHTML error:", err);
2808
+ }
2809
+ }
2810
+ __name(fetchText, "fetchText");
2774
2811
  function fetchOptionsFormURLEncoded(data, method = "POST") {
2775
2812
  return __spreadProps(__spreadValues({
2776
2813
  method
@@ -2787,28 +2824,20 @@ function fetchOptionsJson(data, method = "POST") {
2787
2824
  method
2788
2825
  }, defaultOptions), {
2789
2826
  headers: {
2790
- "Content-Type": "application/json; charset=utf-8",
2791
- Accept: "application/json"
2827
+ "Content-Type": "application/json; charset=utf-8"
2792
2828
  },
2793
2829
  body: JSON.stringify(data)
2794
2830
  });
2795
2831
  }
2796
2832
  __name(fetchOptionsJson, "fetchOptionsJson");
2797
- async function fetchText(url, opts = {}, fetchFn = fetch) {
2798
- try {
2799
- let res = await fetchBasic(url, __spreadValues(__spreadProps(__spreadValues({
2800
- method: "GET"
2801
- }, defaultOptions), {
2802
- headers: {}
2803
- }), opts), fetchFn);
2804
- if (res) {
2805
- return await res.text();
2833
+ function fetchOptionsBasicAuth(username, password) {
2834
+ return {
2835
+ headers: {
2836
+ Authorization: "Basic " + toBase64(username + ":" + password)
2806
2837
  }
2807
- } catch (err) {
2808
- log8.error("fetchHTML error:", err);
2809
- }
2838
+ };
2810
2839
  }
2811
- __name(fetchText, "fetchText");
2840
+ __name(fetchOptionsBasicAuth, "fetchOptionsBasicAuth");
2812
2841
 
2813
2842
  // src/common/platform.ts
2814
2843
  function getWindow() {
@@ -2910,6 +2939,7 @@ export {
2910
2939
  stringToUInt8Array,
2911
2940
  Uint8ArrayToString,
2912
2941
  toUint8Array,
2942
+ joinToUint8Array,
2913
2943
  toHex,
2914
2944
  toBase64,
2915
2945
  toBase64Url,
@@ -3104,7 +3134,7 @@ export {
3104
3134
  LoggerMemoryHandler,
3105
3135
  Channel,
3106
3136
  LocalChannel,
3107
- fakeWorkerPair,
3137
+ createLocalChannelPair,
3108
3138
  NoopEncoder,
3109
3139
  JsonEncoder,
3110
3140
  CryptoEncoder,
@@ -3115,9 +3145,10 @@ export {
3115
3145
  useRPC,
3116
3146
  fetchBasic,
3117
3147
  fetchJson,
3148
+ fetchText,
3118
3149
  fetchOptionsFormURLEncoded,
3119
3150
  fetchOptionsJson,
3120
- fetchText,
3151
+ fetchOptionsBasicAuth,
3121
3152
  getWindow,
3122
3153
  getNavigator,
3123
3154
  getGlobal,
@@ -3127,4 +3158,4 @@ export {
3127
3158
  useExitHandler,
3128
3159
  MemStorage
3129
3160
  };
3130
- //# sourceMappingURL=chunk-NNGVZWI3.js.map
3161
+ //# sourceMappingURL=chunk-DPI2LOOM.js.map