@tonyclaw/llm-inspector 1.9.9 → 1.11.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/.output/nitro.json +3 -3
- package/.output/public/assets/index-BIZeMR5N.js +105 -0
- package/.output/public/assets/index-SmtLx1lM.css +1 -0
- package/.output/public/assets/main-QfbQ5oBP.js +17 -0
- package/.output/server/_libs/@radix-ui/react-accessible-icon+[...].mjs +1 -1
- package/.output/server/_libs/@radix-ui/react-navigation-menu+[...].mjs +2 -1
- package/.output/server/_libs/@radix-ui/react-one-time-password-field+[...].mjs +2 -1
- package/.output/server/_libs/@radix-ui/react-password-toggle-field+[...].mjs +2 -1
- package/.output/server/_libs/@radix-ui/react-use-controllable-state+[...].mjs +1 -1
- package/.output/server/_libs/@radix-ui/react-use-effect-event+[...].mjs +1 -1
- package/.output/server/_libs/@radix-ui/react-use-is-hydrated+[...].mjs +1 -1
- package/.output/server/_libs/ajv-formats.mjs +21 -21
- package/.output/server/_libs/ajv.mjs +204 -204
- package/.output/server/_libs/cookie-es.mjs +21 -7
- package/.output/server/_libs/diff.mjs +320 -0
- package/.output/server/_libs/extend.mjs +1 -1
- package/.output/server/_libs/fast-uri.mjs +3 -3
- package/.output/server/_libs/h3-v2.mjs +9 -20
- package/.output/server/_libs/inherits.mjs +1 -1
- package/.output/server/_libs/jszip.mjs +131 -129
- package/.output/server/_libs/lie.mjs +1 -1
- package/.output/server/_libs/lucide-react.mjs +103 -80
- package/.output/server/_libs/pako.mjs +41 -41
- package/.output/server/_libs/radix-ui__react-accordion.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-alert-dialog.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-aspect-ratio.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-avatar.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-checkbox.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-collection.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-context-menu.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-dropdown-menu.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-form.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-hover-card.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-id.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-label.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-menu.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-menubar.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-popover.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-progress.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-radio-group.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-slider.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-switch.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-toast.mjs +2 -1
- package/.output/server/_libs/radix-ui__react-toggle-group.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-toggle.mjs +1 -1
- package/.output/server/_libs/radix-ui__react-toolbar.mjs +1 -1
- package/.output/server/_libs/react-dom.mjs +13 -13
- package/.output/server/_libs/react-remove-scroll.mjs +1 -1
- package/.output/server/_libs/react.mjs +45 -45
- package/.output/server/_libs/readable-stream.mjs +46 -46
- package/.output/server/_libs/rou3.mjs +7 -1
- package/.output/server/_libs/safe-buffer.mjs +3 -3
- package/.output/server/_libs/semver.mjs +148 -135
- package/.output/server/_libs/seroval-plugins.mjs +5 -5
- package/.output/server/_libs/seroval.mjs +596 -606
- package/.output/server/_libs/setimmediate.mjs +152 -1
- package/.output/server/_libs/srvx.mjs +245 -10
- package/.output/server/_libs/style-to-js.mjs +3 -3
- package/.output/server/_libs/style-to-object.mjs +1 -1
- package/.output/server/_libs/swr.mjs +2 -1
- package/.output/server/_libs/tanstack__history.mjs +44 -31
- package/.output/server/_libs/tanstack__react-router.mjs +1089 -780
- package/.output/server/_libs/tanstack__router-core.mjs +2331 -2226
- package/.output/server/_libs/tiny-invariant.mjs +12 -0
- package/.output/server/_libs/tiny-warning.mjs +5 -0
- package/.output/server/_libs/tslib.mjs +1 -576
- package/.output/server/_libs/use-sidecar.mjs +1 -1
- package/.output/server/_libs/use-sync-external-store.mjs +4 -4
- package/.output/server/_libs/zod.mjs +207 -505
- package/.output/server/_ssr/{index-BGk_7BAL.mjs → index-I_Nx8QEB.mjs} +730 -90
- package/.output/server/_ssr/index.mjs +778 -1100
- package/.output/server/_ssr/{router-DVhtTbPW.mjs → router-BVxfVFsb.mjs} +317 -74
- package/.output/server/_tanstack-start-manifest_v-Cm2Owszu.mjs +4 -0
- package/.output/server/index.mjs +114 -130
- package/.output/server/node_modules/tslib/modules/index.js +70 -0
- package/.output/server/node_modules/tslib/modules/package.json +3 -0
- package/.output/server/node_modules/tslib/package.json +47 -0
- package/.output/server/node_modules/tslib/tslib.js +484 -0
- package/.output/server/package.json +9 -0
- package/README.md +1 -1
- package/package.json +4 -3
- package/src/components/ProxyViewer.tsx +10 -3
- package/src/components/ProxyViewerContainer.tsx +6 -0
- package/src/components/providers/SettingsDialog.tsx +60 -0
- package/src/components/proxy-viewer/ConversationGroup.tsx +16 -2
- package/src/components/proxy-viewer/ConversationHeader.tsx +53 -0
- package/src/components/proxy-viewer/LogEntry.tsx +178 -9
- package/src/components/proxy-viewer/LogEntryHeader.tsx +21 -18
- package/src/components/proxy-viewer/ReplayDialog.tsx +3 -3
- package/src/components/proxy-viewer/diff/DiffView.tsx +319 -0
- package/src/components/proxy-viewer/diff/computeDiff.ts +178 -0
- package/src/components/proxy-viewer/diff/index.ts +3 -0
- package/src/components/ui/crab-logo.tsx +45 -0
- package/src/lib/runtimeConfig.ts +15 -0
- package/src/lib/useStripConfig.ts +86 -0
- package/src/proxy/claudeCodeStrip.ts +102 -0
- package/src/proxy/config.ts +162 -0
- package/src/proxy/constants.ts +11 -0
- package/src/proxy/dataDir.ts +56 -0
- package/src/proxy/formats/anthropic/stream.ts +5 -2
- package/src/proxy/formats/jsonSchema.ts +12 -0
- package/src/proxy/formats/openai/stream.ts +21 -16
- package/src/proxy/handler.ts +38 -6
- package/src/proxy/providers.ts +61 -1
- package/src/proxy/schemas.ts +42 -0
- package/src/proxy/store.ts +6 -23
- package/src/routes/api/config.ts +45 -0
- package/.output/public/assets/index-Cc1oV0hF.css +0 -1
- package/.output/public/assets/index-DZa_TXId.js +0 -122
- package/.output/public/assets/index-a_XE_Ksv.js +0 -11
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +0 -6
- package/.output/server/_tanstack-start-manifest_v-CrFsxDG4.mjs +0 -4
- /package/.output/server/_libs/{unctx.mjs → ocache.mjs} +0 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
function splitSetCookieString(cookiesString) {
|
|
2
|
-
if (Array.isArray(cookiesString))
|
|
3
|
-
|
|
2
|
+
if (Array.isArray(cookiesString)) {
|
|
3
|
+
return cookiesString.flatMap((c) => splitSetCookieString(c));
|
|
4
|
+
}
|
|
5
|
+
if (typeof cookiesString !== "string") {
|
|
6
|
+
return [];
|
|
7
|
+
}
|
|
4
8
|
const cookiesStrings = [];
|
|
5
9
|
let pos = 0;
|
|
6
10
|
let start;
|
|
@@ -9,7 +13,9 @@ function splitSetCookieString(cookiesString) {
|
|
|
9
13
|
let nextStart;
|
|
10
14
|
let cookiesSeparatorFound;
|
|
11
15
|
const skipWhitespace = () => {
|
|
12
|
-
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos)))
|
|
16
|
+
while (pos < cookiesString.length && /\s/.test(cookiesString.charAt(pos))) {
|
|
17
|
+
pos += 1;
|
|
18
|
+
}
|
|
13
19
|
return pos < cookiesString.length;
|
|
14
20
|
};
|
|
15
21
|
const notSpecialChar = () => {
|
|
@@ -26,16 +32,24 @@ function splitSetCookieString(cookiesString) {
|
|
|
26
32
|
pos += 1;
|
|
27
33
|
skipWhitespace();
|
|
28
34
|
nextStart = pos;
|
|
29
|
-
while (pos < cookiesString.length && notSpecialChar())
|
|
35
|
+
while (pos < cookiesString.length && notSpecialChar()) {
|
|
36
|
+
pos += 1;
|
|
37
|
+
}
|
|
30
38
|
if (pos < cookiesString.length && cookiesString.charAt(pos) === "=") {
|
|
31
39
|
cookiesSeparatorFound = true;
|
|
32
40
|
pos = nextStart;
|
|
33
41
|
cookiesStrings.push(cookiesString.slice(start, lastComma));
|
|
34
42
|
start = pos;
|
|
35
|
-
} else
|
|
36
|
-
|
|
43
|
+
} else {
|
|
44
|
+
pos = lastComma + 1;
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
pos += 1;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (!cookiesSeparatorFound || pos >= cookiesString.length) {
|
|
51
|
+
cookiesStrings.push(cookiesString.slice(start));
|
|
37
52
|
}
|
|
38
|
-
if (!cookiesSeparatorFound || pos >= cookiesString.length) cookiesStrings.push(cookiesString.slice(start));
|
|
39
53
|
}
|
|
40
54
|
return cookiesStrings;
|
|
41
55
|
}
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
class Diff {
|
|
2
|
+
diff(oldStr, newStr, options = {}) {
|
|
3
|
+
let callback;
|
|
4
|
+
if (typeof options === "function") {
|
|
5
|
+
callback = options;
|
|
6
|
+
options = {};
|
|
7
|
+
} else if ("callback" in options) {
|
|
8
|
+
callback = options.callback;
|
|
9
|
+
}
|
|
10
|
+
const oldString = this.castInput(oldStr, options);
|
|
11
|
+
const newString = this.castInput(newStr, options);
|
|
12
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
13
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
14
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
15
|
+
}
|
|
16
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
17
|
+
var _a;
|
|
18
|
+
const done = (value) => {
|
|
19
|
+
value = this.postProcess(value, options);
|
|
20
|
+
if (callback) {
|
|
21
|
+
setTimeout(function() {
|
|
22
|
+
callback(value);
|
|
23
|
+
}, 0);
|
|
24
|
+
return void 0;
|
|
25
|
+
} else {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
30
|
+
let editLength = 1;
|
|
31
|
+
let maxEditLength = newLen + oldLen;
|
|
32
|
+
if (options.maxEditLength != null) {
|
|
33
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
34
|
+
}
|
|
35
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
36
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
37
|
+
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
38
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
39
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
40
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
41
|
+
}
|
|
42
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
43
|
+
const execEditLength = () => {
|
|
44
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
45
|
+
let basePath;
|
|
46
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
47
|
+
if (removePath) {
|
|
48
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
49
|
+
}
|
|
50
|
+
let canAdd = false;
|
|
51
|
+
if (addPath) {
|
|
52
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
53
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
54
|
+
}
|
|
55
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
56
|
+
if (!canAdd && !canRemove) {
|
|
57
|
+
bestPath[diagonalPath] = void 0;
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
61
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
62
|
+
} else {
|
|
63
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
64
|
+
}
|
|
65
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
66
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
67
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
68
|
+
} else {
|
|
69
|
+
bestPath[diagonalPath] = basePath;
|
|
70
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
71
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
72
|
+
}
|
|
73
|
+
if (newPos + 1 >= newLen) {
|
|
74
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
editLength++;
|
|
79
|
+
};
|
|
80
|
+
if (callback) {
|
|
81
|
+
(function exec() {
|
|
82
|
+
setTimeout(function() {
|
|
83
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
84
|
+
return callback(void 0);
|
|
85
|
+
}
|
|
86
|
+
if (!execEditLength()) {
|
|
87
|
+
exec();
|
|
88
|
+
}
|
|
89
|
+
}, 0);
|
|
90
|
+
})();
|
|
91
|
+
} else {
|
|
92
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
93
|
+
const ret = execEditLength();
|
|
94
|
+
if (ret) {
|
|
95
|
+
return ret;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
101
|
+
const last = path.lastComponent;
|
|
102
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
103
|
+
return {
|
|
104
|
+
oldPos: path.oldPos + oldPosInc,
|
|
105
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
106
|
+
};
|
|
107
|
+
} else {
|
|
108
|
+
return {
|
|
109
|
+
oldPos: path.oldPos + oldPosInc,
|
|
110
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
115
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
116
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
117
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
118
|
+
newPos++;
|
|
119
|
+
oldPos++;
|
|
120
|
+
commonCount++;
|
|
121
|
+
if (options.oneChangePerToken) {
|
|
122
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
126
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
127
|
+
}
|
|
128
|
+
basePath.oldPos = oldPos;
|
|
129
|
+
return newPos;
|
|
130
|
+
}
|
|
131
|
+
equals(left, right, options) {
|
|
132
|
+
if (options.comparator) {
|
|
133
|
+
return options.comparator(left, right);
|
|
134
|
+
} else {
|
|
135
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
removeEmpty(array) {
|
|
139
|
+
const ret = [];
|
|
140
|
+
for (let i = 0; i < array.length; i++) {
|
|
141
|
+
if (array[i]) {
|
|
142
|
+
ret.push(array[i]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return ret;
|
|
146
|
+
}
|
|
147
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
148
|
+
castInput(value, options) {
|
|
149
|
+
return value;
|
|
150
|
+
}
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
152
|
+
tokenize(value, options) {
|
|
153
|
+
return Array.from(value);
|
|
154
|
+
}
|
|
155
|
+
join(chars) {
|
|
156
|
+
return chars.join("");
|
|
157
|
+
}
|
|
158
|
+
postProcess(changeObjects, options) {
|
|
159
|
+
return changeObjects;
|
|
160
|
+
}
|
|
161
|
+
get useLongestToken() {
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
165
|
+
const components = [];
|
|
166
|
+
let nextComponent;
|
|
167
|
+
while (lastComponent) {
|
|
168
|
+
components.push(lastComponent);
|
|
169
|
+
nextComponent = lastComponent.previousComponent;
|
|
170
|
+
delete lastComponent.previousComponent;
|
|
171
|
+
lastComponent = nextComponent;
|
|
172
|
+
}
|
|
173
|
+
components.reverse();
|
|
174
|
+
const componentLen = components.length;
|
|
175
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
176
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
177
|
+
const component = components[componentPos];
|
|
178
|
+
if (!component.removed) {
|
|
179
|
+
if (!component.added && this.useLongestToken) {
|
|
180
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
181
|
+
value = value.map(function(value2, i) {
|
|
182
|
+
const oldValue = oldTokens[oldPos + i];
|
|
183
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
184
|
+
});
|
|
185
|
+
component.value = this.join(value);
|
|
186
|
+
} else {
|
|
187
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
188
|
+
}
|
|
189
|
+
newPos += component.count;
|
|
190
|
+
if (!component.added) {
|
|
191
|
+
oldPos += component.count;
|
|
192
|
+
}
|
|
193
|
+
} else {
|
|
194
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
195
|
+
oldPos += component.count;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return components;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
class LineDiff extends Diff {
|
|
202
|
+
constructor() {
|
|
203
|
+
super(...arguments);
|
|
204
|
+
this.tokenize = tokenize;
|
|
205
|
+
}
|
|
206
|
+
equals(left, right, options) {
|
|
207
|
+
if (options.ignoreWhitespace) {
|
|
208
|
+
if (!options.newlineIsToken || !left.includes("\n")) {
|
|
209
|
+
left = left.trim();
|
|
210
|
+
}
|
|
211
|
+
if (!options.newlineIsToken || !right.includes("\n")) {
|
|
212
|
+
right = right.trim();
|
|
213
|
+
}
|
|
214
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
215
|
+
if (left.endsWith("\n")) {
|
|
216
|
+
left = left.slice(0, -1);
|
|
217
|
+
}
|
|
218
|
+
if (right.endsWith("\n")) {
|
|
219
|
+
right = right.slice(0, -1);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return super.equals(left, right, options);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const lineDiff = new LineDiff();
|
|
226
|
+
function diffLines(oldStr, newStr, options) {
|
|
227
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
228
|
+
}
|
|
229
|
+
function tokenize(value, options) {
|
|
230
|
+
if (options.stripTrailingCr) {
|
|
231
|
+
value = value.replace(/\r\n/g, "\n");
|
|
232
|
+
}
|
|
233
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
234
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
235
|
+
linesAndNewlines.pop();
|
|
236
|
+
}
|
|
237
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
238
|
+
const line = linesAndNewlines[i];
|
|
239
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
240
|
+
retLines[retLines.length - 1] += line;
|
|
241
|
+
} else {
|
|
242
|
+
retLines.push(line);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return retLines;
|
|
246
|
+
}
|
|
247
|
+
class JsonDiff extends Diff {
|
|
248
|
+
constructor() {
|
|
249
|
+
super(...arguments);
|
|
250
|
+
this.tokenize = tokenize;
|
|
251
|
+
}
|
|
252
|
+
get useLongestToken() {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
castInput(value, options) {
|
|
256
|
+
const { undefinedReplacement, stringifyReplacer = (k, v) => typeof v === "undefined" ? undefinedReplacement : v } = options;
|
|
257
|
+
return typeof value === "string" ? value : JSON.stringify(canonicalize(value, null, null, stringifyReplacer), null, " ");
|
|
258
|
+
}
|
|
259
|
+
equals(left, right, options) {
|
|
260
|
+
return super.equals(left.replace(/,([\r\n])/g, "$1"), right.replace(/,([\r\n])/g, "$1"), options);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const jsonDiff = new JsonDiff();
|
|
264
|
+
function diffJson(oldStr, newStr, options) {
|
|
265
|
+
return jsonDiff.diff(oldStr, newStr, options);
|
|
266
|
+
}
|
|
267
|
+
function canonicalize(obj, stack, replacementStack, replacer, key) {
|
|
268
|
+
stack = stack || [];
|
|
269
|
+
replacementStack = replacementStack || [];
|
|
270
|
+
if (replacer) {
|
|
271
|
+
obj = replacer(key === void 0 ? "" : key, obj);
|
|
272
|
+
}
|
|
273
|
+
let i;
|
|
274
|
+
for (i = 0; i < stack.length; i += 1) {
|
|
275
|
+
if (stack[i] === obj) {
|
|
276
|
+
return replacementStack[i];
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
let canonicalizedObj;
|
|
280
|
+
if ("[object Array]" === Object.prototype.toString.call(obj)) {
|
|
281
|
+
stack.push(obj);
|
|
282
|
+
canonicalizedObj = new Array(obj.length);
|
|
283
|
+
replacementStack.push(canonicalizedObj);
|
|
284
|
+
for (i = 0; i < obj.length; i += 1) {
|
|
285
|
+
canonicalizedObj[i] = canonicalize(obj[i], stack, replacementStack, replacer, String(i));
|
|
286
|
+
}
|
|
287
|
+
stack.pop();
|
|
288
|
+
replacementStack.pop();
|
|
289
|
+
return canonicalizedObj;
|
|
290
|
+
}
|
|
291
|
+
if (obj && obj.toJSON) {
|
|
292
|
+
obj = obj.toJSON();
|
|
293
|
+
}
|
|
294
|
+
if (typeof obj === "object" && obj !== null) {
|
|
295
|
+
stack.push(obj);
|
|
296
|
+
canonicalizedObj = {};
|
|
297
|
+
replacementStack.push(canonicalizedObj);
|
|
298
|
+
const sortedKeys = [];
|
|
299
|
+
let key2;
|
|
300
|
+
for (key2 in obj) {
|
|
301
|
+
if (Object.prototype.hasOwnProperty.call(obj, key2)) {
|
|
302
|
+
sortedKeys.push(key2);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
sortedKeys.sort();
|
|
306
|
+
for (i = 0; i < sortedKeys.length; i += 1) {
|
|
307
|
+
key2 = sortedKeys[i];
|
|
308
|
+
canonicalizedObj[key2] = canonicalize(obj[key2], stack, replacementStack, replacer, key2);
|
|
309
|
+
}
|
|
310
|
+
stack.pop();
|
|
311
|
+
replacementStack.pop();
|
|
312
|
+
} else {
|
|
313
|
+
canonicalizedObj = obj;
|
|
314
|
+
}
|
|
315
|
+
return canonicalizedObj;
|
|
316
|
+
}
|
|
317
|
+
export {
|
|
318
|
+
diffJson as a,
|
|
319
|
+
diffLines as d
|
|
320
|
+
};
|
|
@@ -317,7 +317,7 @@ var hasRequiredSchemes;
|
|
|
317
317
|
function requireSchemes() {
|
|
318
318
|
if (hasRequiredSchemes) return schemes;
|
|
319
319
|
hasRequiredSchemes = 1;
|
|
320
|
-
const { isUUID } =
|
|
320
|
+
const { isUUID } = requireUtils();
|
|
321
321
|
const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
|
|
322
322
|
const supportedSchemeNames = (
|
|
323
323
|
/** @type {const} */
|
|
@@ -526,8 +526,8 @@ var hasRequiredFastUri;
|
|
|
526
526
|
function requireFastUri() {
|
|
527
527
|
if (hasRequiredFastUri) return fastUri.exports;
|
|
528
528
|
hasRequiredFastUri = 1;
|
|
529
|
-
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } =
|
|
530
|
-
const { SCHEMES, getSchemeHandler } =
|
|
529
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = requireUtils();
|
|
530
|
+
const { SCHEMES, getSchemeHandler } = requireSchemes();
|
|
531
531
|
function normalize(uri, options) {
|
|
532
532
|
if (typeof uri === "string") {
|
|
533
533
|
uri = /** @type {T} */
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
function decodePathname(pathname) {
|
|
4
|
-
return decodeURI(pathname.includes("%25") ? pathname.replace(/%25/g, "%2525") : pathname);
|
|
5
|
-
}
|
|
1
|
+
import { a as NullProtoObj } from "./rou3.mjs";
|
|
2
|
+
import { a as FastURL, b as NodeResponse } from "./srvx.mjs";
|
|
6
3
|
const kEventNS = "h3.internal.event.";
|
|
7
4
|
const kEventRes = /* @__PURE__ */ Symbol.for(`${kEventNS}res`);
|
|
8
5
|
const kEventResHeaders = /* @__PURE__ */ Symbol.for(`${kEventNS}res.headers`);
|
|
9
|
-
const kEventResErrHeaders = /* @__PURE__ */ Symbol.for(`${kEventNS}res.err.headers`);
|
|
10
6
|
var H3Event = class {
|
|
11
7
|
app;
|
|
12
8
|
req;
|
|
@@ -18,9 +14,7 @@ var H3Event = class {
|
|
|
18
14
|
this.req = req;
|
|
19
15
|
this.app = app;
|
|
20
16
|
const _url = req._url;
|
|
21
|
-
|
|
22
|
-
if (url.pathname.includes("%")) url.pathname = decodePathname(url.pathname);
|
|
23
|
-
this.url = url;
|
|
17
|
+
this.url = _url && _url instanceof URL ? _url : new FastURL(req.url);
|
|
24
18
|
}
|
|
25
19
|
get res() {
|
|
26
20
|
return this[kEventRes] ||= new H3EventResponse();
|
|
@@ -56,9 +50,6 @@ var H3EventResponse = class {
|
|
|
56
50
|
get headers() {
|
|
57
51
|
return this[kEventResHeaders] ||= new Headers();
|
|
58
52
|
}
|
|
59
|
-
get errHeaders() {
|
|
60
|
-
return this[kEventResErrHeaders] ||= new Headers();
|
|
61
|
-
}
|
|
62
53
|
};
|
|
63
54
|
const DISALLOWED_STATUS_CHARS = /[^\u0009\u0020-\u007E]/g;
|
|
64
55
|
function sanitizeStatusMessage(statusMessage = "") {
|
|
@@ -98,8 +89,8 @@ var HTTPError = class HTTPError2 extends Error {
|
|
|
98
89
|
messageInput = arg1;
|
|
99
90
|
details = arg2;
|
|
100
91
|
} else details = arg1;
|
|
101
|
-
const status = sanitizeStatusCode(details?.status || details?.
|
|
102
|
-
const statusText = sanitizeStatusMessage(details?.statusText || details?.
|
|
92
|
+
const status = sanitizeStatusCode(details?.status || details?.cause?.status || details?.status || details?.statusCode, 500);
|
|
93
|
+
const statusText = sanitizeStatusMessage(details?.statusText || details?.cause?.statusText || details?.statusText || details?.statusMessage);
|
|
103
94
|
const message = messageInput || details?.message || details?.cause?.message || details?.statusText || details?.statusMessage || [
|
|
104
95
|
"HTTPError",
|
|
105
96
|
status,
|
|
@@ -185,8 +176,7 @@ function prepareResponse(val, event, config, nested) {
|
|
|
185
176
|
}
|
|
186
177
|
if (error.unhandled && !config.silent) console.error(error);
|
|
187
178
|
const { onError } = config;
|
|
188
|
-
|
|
189
|
-
return onError && !nested ? Promise.resolve(onError(error, event)).catch((error2) => error2).then((newVal) => prepareResponse(newVal ?? val, event, config, true)) : errorResponse(error, config.debug, errHeaders);
|
|
179
|
+
return onError && !nested ? Promise.resolve(onError(error, event)).catch((error2) => error2).then((newVal) => prepareResponse(newVal ?? val, event, config, true)) : errorResponse(error, config.debug);
|
|
190
180
|
}
|
|
191
181
|
const preparedRes = event[kEventRes];
|
|
192
182
|
const preparedHeaders = preparedRes?.[kEventResHeaders];
|
|
@@ -269,18 +259,17 @@ function prepareResponseBody(val, event, config) {
|
|
|
269
259
|
function nullBody(method, status) {
|
|
270
260
|
return method === "HEAD" || status === 100 || status === 101 || status === 102 || status === 204 || status === 205 || status === 304;
|
|
271
261
|
}
|
|
272
|
-
function errorResponse(error, debug
|
|
273
|
-
let headers = error.headers ? mergeHeaders$1(jsonHeaders, error.headers) : new Headers(jsonHeaders);
|
|
274
|
-
if (errHeaders) headers = mergeHeaders$1(headers, errHeaders);
|
|
262
|
+
function errorResponse(error, debug) {
|
|
275
263
|
return new NodeResponse(JSON.stringify({
|
|
276
264
|
...error.toJSON(),
|
|
277
265
|
stack: debug && error.stack ? error.stack.split("\n").map((l) => l.trim()) : void 0
|
|
278
266
|
}, void 0, debug ? 2 : void 0), {
|
|
279
267
|
status: error.status,
|
|
280
268
|
statusText: error.statusText,
|
|
281
|
-
headers
|
|
269
|
+
headers: error.headers ? mergeHeaders$1(jsonHeaders, error.headers) : new Headers(jsonHeaders)
|
|
282
270
|
});
|
|
283
271
|
}
|
|
272
|
+
new TextEncoder();
|
|
284
273
|
export {
|
|
285
274
|
H3Event as H,
|
|
286
275
|
toResponse as t
|
|
@@ -41,7 +41,7 @@ function requireInherits() {
|
|
|
41
41
|
if (typeof util.inherits !== "function") throw "";
|
|
42
42
|
inherits.exports = util.inherits;
|
|
43
43
|
} catch (e) {
|
|
44
|
-
inherits.exports =
|
|
44
|
+
inherits.exports = requireInherits_browser();
|
|
45
45
|
}
|
|
46
46
|
return inherits.exports;
|
|
47
47
|
}
|