linkque-cli-v2 1.6.16 → 1.6.18
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/dataTransformWorker.js +161 -89
- package/dev/worker.js +37 -11
- package/linkquejs.js +27708 -9430
- package/package.json +1 -1
- package/vendor/linkque-agent-appwrite-integrate/data-transform/dataTransformWorker.js +161 -89
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-2O5AZ546.js → chunk-3BH2PDL3.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-JMBJJF7P.js → chunk-KRE5FADB.js} +37 -11
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-ZQGBHENQ.js → chunk-L5WNKJ4W.js} +3147 -229
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-ZK7HXMMY.js → chunk-M6E4Y5HY.js} +40001 -20775
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{chunk-DNTEEBEH.js → chunk-SICWMO5Y.js} +1 -0
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-bsd-JGCLGHFY.js → getMachineId-bsd-NYGVHXGN.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-darwin-COHLFNXH.js → getMachineId-darwin-OPTJOAYC.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-linux-XV3Z5FQG.js → getMachineId-linux-5SQRYTUJ.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-unsupported-FCRKLIZL.js → getMachineId-unsupported-OJE7WPEH.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{getMachineId-win-A4WRNVV6.js → getMachineId-win-SLTTCNXU.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{google-generative-ai-KD7MXONK.js → google-generative-ai-YD5ZGNXC.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{google-vertex-TREYA472.js → google-vertex-M34UDW4J.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{mistral-conversations-OEOTQWE5.js → mistral-conversations-EIVAJAMW.js} +1 -1
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/{otel-WGS5CC2J.js → otel-LQR5KPZ3.js} +579 -267
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +2299 -339
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +3 -4
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +3 -4
- package/vendor/linkque-agent-appwrite-integrate/package.json +1 -1
- package/worker.js +46299 -26114
- package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-EAODRPW4.js +0 -518
package/dataTransformWorker.js
CHANGED
|
@@ -1743,6 +1743,9 @@ function smartUnwrap(val) {
|
|
|
1743
1743
|
return val && "default" in val && val.default ? val.default && "default" in val.default && val.default.default ? val.default.default : val.default : val;
|
|
1744
1744
|
}
|
|
1745
1745
|
|
|
1746
|
+
// ../linkque-agent-runtime/dist/esm/core/aiFilter.js
|
|
1747
|
+
var DEFAULT_AI_FILTER_PROMPT = "\u6309\u7167\u7528\u6237\u539F\u59CB\u95EE\u9898\uFF0C\u5BF9\u8FD9\u4E9B\u6570\u636E\u8FDB\u884C\u7B5B\u9009\u548C\u6392\u5E8F";
|
|
1748
|
+
|
|
1746
1749
|
// ../linkque-agent-runtime/dist/esm/core/dataTransformWorker.js
|
|
1747
1750
|
void initialize();
|
|
1748
1751
|
async function initialize() {
|
|
@@ -1752,129 +1755,198 @@ async function initialize() {
|
|
|
1752
1755
|
if (input?.type !== "execute")
|
|
1753
1756
|
return;
|
|
1754
1757
|
const startedAt = Date.now();
|
|
1755
|
-
void execute(quickJs, input).then((resultJson) => {
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
requestId: input.requestId,
|
|
1768
|
-
ok: false,
|
|
1769
|
-
code: classified.code,
|
|
1770
|
-
message: classified.message
|
|
1771
|
-
});
|
|
1772
|
-
});
|
|
1758
|
+
void execute(quickJs, input).then((resultJson) => import_node_worker_threads.parentPort?.postMessage({
|
|
1759
|
+
type: "result",
|
|
1760
|
+
requestId: input.requestId,
|
|
1761
|
+
ok: true,
|
|
1762
|
+
resultJson,
|
|
1763
|
+
durationMs: Date.now() - startedAt
|
|
1764
|
+
}), (error) => import_node_worker_threads.parentPort?.postMessage({
|
|
1765
|
+
type: "result",
|
|
1766
|
+
requestId: input.requestId,
|
|
1767
|
+
ok: false,
|
|
1768
|
+
...classifyError(error)
|
|
1769
|
+
}));
|
|
1773
1770
|
});
|
|
1774
1771
|
}
|
|
1775
1772
|
async function execute(module2, input) {
|
|
1776
1773
|
const runtime = module2.newRuntime();
|
|
1777
1774
|
runtime.setMemoryLimit(input.limits.memoryBytes);
|
|
1778
1775
|
runtime.setMaxStackSize(input.limits.stackBytes);
|
|
1779
|
-
|
|
1776
|
+
let remaining = input.limits.executionMs;
|
|
1777
|
+
let deadline = 0;
|
|
1780
1778
|
let interrupted = false;
|
|
1781
1779
|
runtime.setInterruptHandler(() => {
|
|
1782
1780
|
interrupted = Date.now() > deadline;
|
|
1783
1781
|
return interrupted;
|
|
1784
1782
|
});
|
|
1785
1783
|
const context = runtime.newContext();
|
|
1784
|
+
const pending = /* @__PURE__ */ new Map();
|
|
1785
|
+
let nextCallId = 1;
|
|
1786
|
+
let wake;
|
|
1787
|
+
const run = (callback) => {
|
|
1788
|
+
const started = Date.now();
|
|
1789
|
+
deadline = started + remaining;
|
|
1790
|
+
if (remaining <= 0)
|
|
1791
|
+
throw new Error("\u6570\u636E\u8F6C\u6362\u8D85\u8FC7\u6267\u884C\u65F6\u95F4\u9650\u5236");
|
|
1792
|
+
try {
|
|
1793
|
+
return callback();
|
|
1794
|
+
} finally {
|
|
1795
|
+
remaining -= Date.now() - started;
|
|
1796
|
+
}
|
|
1797
|
+
};
|
|
1798
|
+
const read = (handle) => {
|
|
1799
|
+
const value = context.dump(handle);
|
|
1800
|
+
if (typeof value !== "string")
|
|
1801
|
+
throw new TypeError("transform \u7ED3\u679C\u65E0\u6CD5\u5E8F\u5217\u5316");
|
|
1802
|
+
return value;
|
|
1803
|
+
};
|
|
1804
|
+
const onResponse = (message) => {
|
|
1805
|
+
if (message?.type !== "filter-result" || message.requestId !== input.requestId)
|
|
1806
|
+
return;
|
|
1807
|
+
const promise = pending.get(message.callId);
|
|
1808
|
+
if (!promise)
|
|
1809
|
+
return;
|
|
1810
|
+
pending.delete(message.callId);
|
|
1811
|
+
const handle = message.error ? context.newError(message.error) : context.newString(JSON.stringify(message.indices));
|
|
1812
|
+
if (message.error)
|
|
1813
|
+
promise.reject(handle);
|
|
1814
|
+
else
|
|
1815
|
+
promise.resolve(handle);
|
|
1816
|
+
handle.dispose();
|
|
1817
|
+
promise.dispose();
|
|
1818
|
+
wake?.();
|
|
1819
|
+
};
|
|
1820
|
+
import_node_worker_threads.parentPort?.on("message", onResponse);
|
|
1786
1821
|
try {
|
|
1787
1822
|
if (input.mode === "validate") {
|
|
1788
|
-
const
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
`);
|
|
1798
|
-
if (validated.error) {
|
|
1799
|
-
const dumped = context.dump(validated.error);
|
|
1800
|
-
validated.error.dispose();
|
|
1801
|
-
throw new Error(readQuickJsError(dumped));
|
|
1802
|
-
}
|
|
1803
|
-
const result2 = context.dump(validated.value);
|
|
1804
|
-
validated.value.dispose();
|
|
1805
|
-
if (typeof result2 !== "string")
|
|
1806
|
-
throw new TypeError("transform \u6E90\u7801\u6821\u9A8C\u5931\u8D25");
|
|
1807
|
-
return result2;
|
|
1823
|
+
const result = run(() => context.evalCode(`'use strict'; (() => { ${input.source}
|
|
1824
|
+
});`, void 0, { compileOnly: true }));
|
|
1825
|
+
if (result.error) {
|
|
1826
|
+
const error = context.dump(result.error);
|
|
1827
|
+
result.error.dispose();
|
|
1828
|
+
throw new Error(readQuickJsError(error));
|
|
1829
|
+
}
|
|
1830
|
+
result.value.dispose();
|
|
1831
|
+
return "{}";
|
|
1808
1832
|
}
|
|
1833
|
+
const host = context.newFunction("__hostFilter", (listHandle, promptHandle) => {
|
|
1834
|
+
const modelList = JSON.parse(context.getString(listHandle));
|
|
1835
|
+
const prompt = context.getString(promptHandle);
|
|
1836
|
+
const callId = nextCallId++;
|
|
1837
|
+
const promise = context.newPromise();
|
|
1838
|
+
pending.set(callId, promise);
|
|
1839
|
+
import_node_worker_threads.parentPort?.postMessage({
|
|
1840
|
+
type: "filter",
|
|
1841
|
+
requestId: input.requestId,
|
|
1842
|
+
callId,
|
|
1843
|
+
modelList,
|
|
1844
|
+
prompt
|
|
1845
|
+
});
|
|
1846
|
+
return promise.handle;
|
|
1847
|
+
});
|
|
1848
|
+
context.setProp(context.global, "__LINKQUE_FILTER__", host);
|
|
1849
|
+
host.dispose();
|
|
1809
1850
|
const inputHandle = context.newString(input.inputJson);
|
|
1810
1851
|
context.setProp(context.global, "__LINKQUE_INPUT_JSON__", inputHandle);
|
|
1811
1852
|
inputHandle.dispose();
|
|
1812
|
-
const
|
|
1853
|
+
const source = `
|
|
1813
1854
|
'use strict';
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1855
|
+
(() => {
|
|
1856
|
+
const hostFilter = globalThis.__LINKQUE_FILTER__;
|
|
1857
|
+
delete globalThis.__LINKQUE_FILTER__;
|
|
1858
|
+
const input = JSON.parse(globalThis.__LINKQUE_INPUT_JSON__);
|
|
1859
|
+
delete globalThis.__LINKQUE_INPUT_JSON__;
|
|
1860
|
+
const ctx = Object.freeze({ ai: Object.freeze({ filter: async (list, modelList = list, prompt = ${JSON.stringify(DEFAULT_AI_FILTER_PROMPT)}) => {
|
|
1861
|
+
if (!Array.isArray(list) || !Array.isArray(modelList)) throw new TypeError('AI \u7B5B\u9009\u8F93\u5165\u5FC5\u987B\u662F\u6570\u7EC4');
|
|
1862
|
+
if (list.length !== modelList.length) throw new TypeError('\u6A21\u578B\u6295\u5F71\u5FC5\u987B\u4E0E\u539F\u59CB\u6570\u7EC4\u7B49\u957F\u4E14\u987A\u5E8F\u4E00\u81F4');
|
|
1863
|
+
if (typeof prompt !== 'string') throw new TypeError('AI \u7B5B\u9009\u6307\u4EE4\u5FC5\u987B\u662F\u5B57\u7B26\u4E32');
|
|
1864
|
+
const original = list.slice();
|
|
1865
|
+
if (original.length === 0 || ${input.preview === true}) return original;
|
|
1866
|
+
const indices = JSON.parse(await hostFilter(JSON.stringify(modelList), prompt));
|
|
1867
|
+
return indices.map(index => original[index]);
|
|
1868
|
+
} }) });
|
|
1869
|
+
const transform = (() => { ${input.source}
|
|
1870
|
+
return transform; })();
|
|
1871
|
+
if (typeof transform !== 'function') throw new TypeError('transform \u5FC5\u987B\u662F\u51FD\u6570');
|
|
1872
|
+
return Promise.resolve(transform(input, ctx)).then(output => JSON.stringify(output));
|
|
1873
|
+
})()
|
|
1874
|
+
`;
|
|
1875
|
+
const evaluated = run(() => context.evalCode(source));
|
|
1831
1876
|
if (evaluated.error) {
|
|
1832
|
-
const
|
|
1877
|
+
const error = context.dump(evaluated.error);
|
|
1833
1878
|
evaluated.error.dispose();
|
|
1834
|
-
|
|
1835
|
-
throw new TransformWorkerError("timeout");
|
|
1836
|
-
throw new Error(readQuickJsError(dumped));
|
|
1879
|
+
throw new Error(readQuickJsError(error));
|
|
1837
1880
|
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1881
|
+
try {
|
|
1882
|
+
let done = false;
|
|
1883
|
+
const settled = context.resolvePromise(evaluated.value).then((result2) => {
|
|
1884
|
+
done = true;
|
|
1885
|
+
wake?.();
|
|
1886
|
+
return result2;
|
|
1887
|
+
});
|
|
1888
|
+
for (; ; ) {
|
|
1889
|
+
import_node_worker_threads.parentPort?.postMessage({
|
|
1890
|
+
type: "running",
|
|
1891
|
+
requestId: input.requestId
|
|
1892
|
+
});
|
|
1893
|
+
const jobs = run(() => runtime.executePendingJobs());
|
|
1894
|
+
if (jobs.error) {
|
|
1895
|
+
const error = context.dump(jobs.error);
|
|
1896
|
+
jobs.error.dispose();
|
|
1897
|
+
throw new Error(readQuickJsError(error));
|
|
1898
|
+
}
|
|
1899
|
+
await Promise.resolve();
|
|
1900
|
+
if (done)
|
|
1901
|
+
break;
|
|
1902
|
+
if (pending.size === 0)
|
|
1903
|
+
throw new Error("\u5F02\u6B65\u8F6C\u6362\u672A\u5B8C\u6210\u4E14\u6CA1\u6709\u53EF\u7B49\u5F85\u7684\u5BBF\u4E3B\u8BF7\u6C42");
|
|
1904
|
+
import_node_worker_threads.parentPort?.postMessage({
|
|
1905
|
+
type: "waiting",
|
|
1906
|
+
requestId: input.requestId
|
|
1907
|
+
});
|
|
1908
|
+
await new Promise((resolve) => {
|
|
1909
|
+
wake = resolve;
|
|
1910
|
+
});
|
|
1911
|
+
wake = void 0;
|
|
1912
|
+
}
|
|
1913
|
+
const result = await settled;
|
|
1914
|
+
if (result.error) {
|
|
1915
|
+
const error = context.dump(result.error);
|
|
1916
|
+
result.error.dispose();
|
|
1917
|
+
throw new Error(readQuickJsError(error));
|
|
1918
|
+
}
|
|
1919
|
+
try {
|
|
1920
|
+
return read(result.value);
|
|
1921
|
+
} finally {
|
|
1922
|
+
result.value.dispose();
|
|
1923
|
+
}
|
|
1924
|
+
} finally {
|
|
1925
|
+
evaluated.value.dispose();
|
|
1842
1926
|
}
|
|
1843
|
-
|
|
1927
|
+
} catch (error) {
|
|
1928
|
+
if (interrupted || remaining <= 0)
|
|
1929
|
+
throw new Error("\u6570\u636E\u8F6C\u6362\u8D85\u8FC7\u6267\u884C\u65F6\u95F4\u9650\u5236", { cause: error });
|
|
1930
|
+
throw error;
|
|
1844
1931
|
} finally {
|
|
1932
|
+
import_node_worker_threads.parentPort?.off("message", onResponse);
|
|
1933
|
+
for (const promise of pending.values())
|
|
1934
|
+
promise.dispose();
|
|
1845
1935
|
context.dispose();
|
|
1846
1936
|
runtime.dispose();
|
|
1847
1937
|
}
|
|
1848
1938
|
}
|
|
1849
|
-
var TransformWorkerError = class extends Error {
|
|
1850
|
-
kind;
|
|
1851
|
-
constructor(kind) {
|
|
1852
|
-
super(kind);
|
|
1853
|
-
this.kind = kind;
|
|
1854
|
-
}
|
|
1855
|
-
};
|
|
1856
1939
|
function classifyError(error) {
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
};
|
|
1862
|
-
}
|
|
1863
|
-
const message = sanitizeError(error);
|
|
1864
|
-
if (/out of memory|stack overflow|allocation failed/iu.test(message)) {
|
|
1940
|
+
const message = error instanceof Error ? error.message.slice(0, 500) : "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5931\u8D25";
|
|
1941
|
+
if (/超过执行时间限制/u.test(message))
|
|
1942
|
+
return { code: "CARD_TRANSFORM_TIMEOUT", message };
|
|
1943
|
+
if (/out of memory|stack overflow|allocation failed/iu.test(message))
|
|
1865
1944
|
return {
|
|
1866
1945
|
code: "CARD_TRANSFORM_RESOURCE_EXCEEDED",
|
|
1867
1946
|
message: "\u6570\u636E\u8F6C\u6362\u8D85\u8FC7\u5185\u5B58\u6216\u6808\u9650\u5236"
|
|
1868
1947
|
};
|
|
1869
|
-
}
|
|
1870
1948
|
return { code: "CARD_TRANSFORM_FAILED", message };
|
|
1871
1949
|
}
|
|
1872
1950
|
function readQuickJsError(value) {
|
|
1873
|
-
|
|
1874
|
-
return value.message;
|
|
1875
|
-
}
|
|
1876
|
-
return "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5931\u8D25";
|
|
1877
|
-
}
|
|
1878
|
-
function sanitizeError(error) {
|
|
1879
|
-
return error instanceof Error && error.message.trim() ? error.message.slice(0, 500) : "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5931\u8D25";
|
|
1951
|
+
return value && typeof value === "object" && "message" in value && typeof value.message === "string" ? value.message : "\u6570\u636E\u8F6C\u6362\u6267\u884C\u5931\u8D25";
|
|
1880
1952
|
}
|
package/dev/worker.js
CHANGED
|
@@ -53,6 +53,7 @@ var require_constants = __commonJS({
|
|
|
53
53
|
var require_buffer_util = __commonJS({
|
|
54
54
|
"../../node_modules/ws/lib/buffer-util.js"(exports2, module2) {
|
|
55
55
|
"use strict";
|
|
56
|
+
var { websocketMask, websocketUnmask } = require("http");
|
|
56
57
|
var { EMPTY_BUFFER } = require_constants();
|
|
57
58
|
var FastBuffer = Buffer[Symbol.species];
|
|
58
59
|
function concat(list, totalLength) {
|
|
@@ -107,7 +108,16 @@ var require_buffer_util = __commonJS({
|
|
|
107
108
|
toBuffer,
|
|
108
109
|
unmask: _unmask
|
|
109
110
|
};
|
|
110
|
-
if (
|
|
111
|
+
if (websocketMask) {
|
|
112
|
+
module2.exports.mask = function(source, mask, output, offset, length) {
|
|
113
|
+
if (length < 24) _mask(source, mask, output, offset, length);
|
|
114
|
+
else websocketMask(source, mask, output, offset, length);
|
|
115
|
+
};
|
|
116
|
+
module2.exports.unmask = function(buffer, mask) {
|
|
117
|
+
if (buffer.length < 24) _unmask(buffer, mask);
|
|
118
|
+
else websocketUnmask(buffer, mask);
|
|
119
|
+
};
|
|
120
|
+
} else if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
111
121
|
try {
|
|
112
122
|
const bufferUtil = require("bufferutil");
|
|
113
123
|
module2.exports.mask = function(source, mask, output, offset, length) {
|
|
@@ -1170,6 +1180,7 @@ var require_receiver = __commonJS({
|
|
|
1170
1180
|
unmask(data, this._mask);
|
|
1171
1181
|
}
|
|
1172
1182
|
}
|
|
1183
|
+
this._mask = void 0;
|
|
1173
1184
|
if (this._opcode > 7) {
|
|
1174
1185
|
this.controlMessage(data, cb);
|
|
1175
1186
|
return;
|
|
@@ -1502,12 +1513,15 @@ var require_sender = __commonJS({
|
|
|
1502
1513
|
target[2] = target[3] = 0;
|
|
1503
1514
|
target.writeUIntBE(dataLength, 4, 6);
|
|
1504
1515
|
}
|
|
1505
|
-
if (!options.mask)
|
|
1516
|
+
if (!options.mask) {
|
|
1517
|
+
return dataLength ? [target, data] : [target];
|
|
1518
|
+
}
|
|
1506
1519
|
target[1] |= 128;
|
|
1507
1520
|
target[offset - 4] = mask[0];
|
|
1508
1521
|
target[offset - 3] = mask[1];
|
|
1509
1522
|
target[offset - 2] = mask[2];
|
|
1510
1523
|
target[offset - 1] = mask[3];
|
|
1524
|
+
if (!dataLength) return [target];
|
|
1511
1525
|
if (skipMasking) return [target, data];
|
|
1512
1526
|
if (merge) {
|
|
1513
1527
|
applyMask(data, mask, target, offset, dataLength);
|
|
@@ -2264,6 +2278,7 @@ var require_websocket = __commonJS({
|
|
|
2264
2278
|
var https = require("https");
|
|
2265
2279
|
var http = require("http");
|
|
2266
2280
|
var net = require("net");
|
|
2281
|
+
var querystring = require("querystring");
|
|
2267
2282
|
var tls = require("tls");
|
|
2268
2283
|
var { randomBytes, createHash } = require("crypto");
|
|
2269
2284
|
var { Duplex, Readable } = require("stream");
|
|
@@ -2790,10 +2805,9 @@ var require_websocket = __commonJS({
|
|
|
2790
2805
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
2791
2806
|
}
|
|
2792
2807
|
}
|
|
2793
|
-
if (parsedUrl.protocol === "http:") {
|
|
2794
|
-
parsedUrl
|
|
2795
|
-
|
|
2796
|
-
parsedUrl.protocol = "wss:";
|
|
2808
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
2809
|
+
parsedUrl = new URL2(parsedUrl);
|
|
2810
|
+
parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
2797
2811
|
}
|
|
2798
2812
|
websocket._url = parsedUrl.href;
|
|
2799
2813
|
const isSecure = parsedUrl.protocol === "wss:";
|
|
@@ -2862,12 +2876,19 @@ var require_websocket = __commonJS({
|
|
|
2862
2876
|
}
|
|
2863
2877
|
}
|
|
2864
2878
|
if (parsedUrl.username || parsedUrl.password) {
|
|
2865
|
-
|
|
2879
|
+
const username = querystring.unescape(parsedUrl.username);
|
|
2880
|
+
const password = querystring.unescape(parsedUrl.password);
|
|
2881
|
+
opts.auth = `${username}:${password}`;
|
|
2866
2882
|
}
|
|
2867
2883
|
if (isIpcUrl) {
|
|
2868
|
-
const
|
|
2869
|
-
|
|
2870
|
-
|
|
2884
|
+
const i = opts.path.indexOf(":");
|
|
2885
|
+
if (i === -1) {
|
|
2886
|
+
opts.socketPath = opts.path;
|
|
2887
|
+
opts.path = "";
|
|
2888
|
+
} else {
|
|
2889
|
+
opts.socketPath = opts.path.slice(0, i);
|
|
2890
|
+
opts.path = opts.path.slice(i + 1);
|
|
2891
|
+
}
|
|
2871
2892
|
}
|
|
2872
2893
|
let req;
|
|
2873
2894
|
if (opts.followRedirects) {
|
|
@@ -3062,8 +3083,13 @@ var require_websocket = __commonJS({
|
|
|
3062
3083
|
function receiverOnConclude(code, reason) {
|
|
3063
3084
|
const websocket = this[kWebSocket];
|
|
3064
3085
|
websocket._closeFrameReceived = true;
|
|
3065
|
-
websocket._closeMessage = reason;
|
|
3066
3086
|
websocket._closeCode = code;
|
|
3087
|
+
if (reason.length === 0) {
|
|
3088
|
+
websocket._closeMessage = EMPTY_BUFFER;
|
|
3089
|
+
} else {
|
|
3090
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
3091
|
+
websocket._closeMessage.set(reason);
|
|
3092
|
+
}
|
|
3067
3093
|
if (websocket._socket[kWebSocket] === void 0) return;
|
|
3068
3094
|
websocket._socket.removeListener("data", socketOnData);
|
|
3069
3095
|
process.nextTick(resume, websocket._socket);
|