@opentiny/next-sdk 0.3.2 → 0.3.3-alpha.1
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/WebMcp.ts +6 -0
- package/core.ts +1 -0
- package/dist/SimulatorMask-BHVXyogh-BFEGpD5S.js +1048 -0
- package/dist/SimulatorMask-BHVXyogh-CCYbrb84.js +801 -0
- package/dist/WebMcp.d.ts +3 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +16 -15
- package/dist/index.d.ts +2 -1
- package/dist/index.es.dev.js +8201 -2640
- package/dist/index.es.js +21518 -16896
- package/dist/index.js +4033 -1847
- package/dist/index.umd.dev.js +9557 -3051
- package/dist/index.umd.js +500 -66
- package/dist/initialize-builtin-WebMCP-HgObT902.js +6279 -0
- package/dist/mcpsdk@1.25.3.dev.js +253 -94
- package/dist/mcpsdk@1.25.3.es.dev.js +253 -94
- package/dist/mcpsdk@1.25.3.es.js +5689 -5531
- package/dist/mcpsdk@1.25.3.js +32 -27
- package/dist/page-tools/a11y-tree.d.ts +103 -0
- package/dist/page-tools/bridge.d.ts +0 -6
- package/dist/page-tools/initialize-builtin-WebMCP.d.ts +1 -0
- package/dist/page-tools/page-agent-tool.d.ts +9 -0
- package/dist/page-tools/page-state-cache.d.ts +36 -0
- package/dist/webagent.dev.js +3614 -1880
- package/dist/webagent.es.dev.js +3370 -1532
- package/dist/webagent.es.js +15958 -14259
- package/dist/webagent.js +74 -66
- package/dist/webmcp-full.dev.js +7625 -719
- package/dist/webmcp-full.es.dev.js +6437 -580
- package/dist/webmcp-full.es.js +12146 -7590
- package/dist/webmcp-full.js +631 -29
- package/dist/webmcp.dev.js +8002 -25
- package/dist/webmcp.es.dev.js +6932 -3
- package/dist/webmcp.es.js +6180 -859
- package/dist/webmcp.js +602 -1
- package/index.ts +2 -14
- package/package.json +11 -4
- package/page-tools/a11y-tree.ts +532 -0
- package/page-tools/bridge.ts +48 -14
- package/page-tools/initialize-builtin-WebMCP.ts +20 -0
- package/page-tools/page-agent-prompt.md +123 -0
- package/page-tools/page-agent-tool.ts +223 -0
- package/page-tools/page-state-cache.ts +78 -0
- package/remoter/createRemoter.ts +2 -1
- package/remoter/svgs/logo.svg +45 -0
- package/vite-env.d.ts +5 -0
- package/dist/AgentModelProvider-t6BqhAGn.js +0 -4194
|
@@ -3088,6 +3088,9 @@
|
|
|
3088
3088
|
hasRequiredUtils = 1;
|
|
3089
3089
|
const isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
3090
3090
|
const isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
3091
|
+
const isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
3092
|
+
const isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
3093
|
+
const isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
|
|
3091
3094
|
function stringArrayToHexStripped(input) {
|
|
3092
3095
|
let acc = "";
|
|
3093
3096
|
let code2 = 0;
|
|
@@ -3280,27 +3283,77 @@
|
|
|
3280
3283
|
}
|
|
3281
3284
|
return output.join("");
|
|
3282
3285
|
}
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3286
|
+
const HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
|
|
3287
|
+
const HOST_DELIM_RE = /[@/?#:]/g;
|
|
3288
|
+
const HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
|
|
3289
|
+
function reescapeHostDelimiters(host, isIP) {
|
|
3290
|
+
const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
|
|
3291
|
+
re.lastIndex = 0;
|
|
3292
|
+
return host.replace(re, (ch) => HOST_DELIMS[ch]);
|
|
3293
|
+
}
|
|
3294
|
+
function normalizePercentEncoding(input, decodeUnreserved = false) {
|
|
3295
|
+
if (input.indexOf("%") === -1) {
|
|
3296
|
+
return input;
|
|
3293
3297
|
}
|
|
3294
|
-
|
|
3295
|
-
|
|
3298
|
+
let output = "";
|
|
3299
|
+
for (let i = 0; i < input.length; i++) {
|
|
3300
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3301
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3302
|
+
if (isHexPair(hex)) {
|
|
3303
|
+
const normalizedHex = hex.toUpperCase();
|
|
3304
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3305
|
+
if (decodeUnreserved && isUnreserved(decoded)) {
|
|
3306
|
+
output += decoded;
|
|
3307
|
+
} else {
|
|
3308
|
+
output += "%" + normalizedHex;
|
|
3309
|
+
}
|
|
3310
|
+
i += 2;
|
|
3311
|
+
continue;
|
|
3312
|
+
}
|
|
3313
|
+
}
|
|
3314
|
+
output += input[i];
|
|
3296
3315
|
}
|
|
3297
|
-
|
|
3298
|
-
|
|
3316
|
+
return output;
|
|
3317
|
+
}
|
|
3318
|
+
function normalizePathEncoding(input) {
|
|
3319
|
+
let output = "";
|
|
3320
|
+
for (let i = 0; i < input.length; i++) {
|
|
3321
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3322
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3323
|
+
if (isHexPair(hex)) {
|
|
3324
|
+
const normalizedHex = hex.toUpperCase();
|
|
3325
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3326
|
+
if (decoded !== "." && isUnreserved(decoded)) {
|
|
3327
|
+
output += decoded;
|
|
3328
|
+
} else {
|
|
3329
|
+
output += "%" + normalizedHex;
|
|
3330
|
+
}
|
|
3331
|
+
i += 2;
|
|
3332
|
+
continue;
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
if (isPathCharacter(input[i])) {
|
|
3336
|
+
output += input[i];
|
|
3337
|
+
} else {
|
|
3338
|
+
output += escape(input[i]);
|
|
3339
|
+
}
|
|
3299
3340
|
}
|
|
3300
|
-
|
|
3301
|
-
|
|
3341
|
+
return output;
|
|
3342
|
+
}
|
|
3343
|
+
function escapePreservingEscapes(input) {
|
|
3344
|
+
let output = "";
|
|
3345
|
+
for (let i = 0; i < input.length; i++) {
|
|
3346
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3347
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3348
|
+
if (isHexPair(hex)) {
|
|
3349
|
+
output += "%" + hex.toUpperCase();
|
|
3350
|
+
i += 2;
|
|
3351
|
+
continue;
|
|
3352
|
+
}
|
|
3353
|
+
}
|
|
3354
|
+
output += escape(input[i]);
|
|
3302
3355
|
}
|
|
3303
|
-
return
|
|
3356
|
+
return output;
|
|
3304
3357
|
}
|
|
3305
3358
|
function recomposeAuthority(component) {
|
|
3306
3359
|
const uriTokens = [];
|
|
@@ -3315,7 +3368,7 @@
|
|
|
3315
3368
|
if (ipV6res.isIPV6 === true) {
|
|
3316
3369
|
host = `[${ipV6res.escapedHost}]`;
|
|
3317
3370
|
} else {
|
|
3318
|
-
host =
|
|
3371
|
+
host = reescapeHostDelimiters(host, false);
|
|
3319
3372
|
}
|
|
3320
3373
|
}
|
|
3321
3374
|
uriTokens.push(host);
|
|
@@ -3329,7 +3382,10 @@
|
|
|
3329
3382
|
utils = {
|
|
3330
3383
|
nonSimpleDomain,
|
|
3331
3384
|
recomposeAuthority,
|
|
3332
|
-
|
|
3385
|
+
reescapeHostDelimiters,
|
|
3386
|
+
normalizePercentEncoding,
|
|
3387
|
+
normalizePathEncoding,
|
|
3388
|
+
escapePreservingEscapes,
|
|
3333
3389
|
removeDotSegments,
|
|
3334
3390
|
isIPv4,
|
|
3335
3391
|
isUUID,
|
|
@@ -3552,12 +3608,12 @@
|
|
|
3552
3608
|
function requireFastUri() {
|
|
3553
3609
|
if (hasRequiredFastUri) return fastUri.exports;
|
|
3554
3610
|
hasRequiredFastUri = 1;
|
|
3555
|
-
const { normalizeIPv6, removeDotSegments, recomposeAuthority,
|
|
3611
|
+
const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = requireUtils();
|
|
3556
3612
|
const { SCHEMES, getSchemeHandler } = requireSchemes();
|
|
3557
3613
|
function normalize(uri2, options) {
|
|
3558
3614
|
if (typeof uri2 === "string") {
|
|
3559
3615
|
uri2 = /** @type {T} */
|
|
3560
|
-
|
|
3616
|
+
normalizeString(uri2, options);
|
|
3561
3617
|
} else if (typeof uri2 === "object") {
|
|
3562
3618
|
uri2 = /** @type {T} */
|
|
3563
3619
|
parse2(serialize(uri2, options), options);
|
|
@@ -3624,19 +3680,9 @@
|
|
|
3624
3680
|
return target;
|
|
3625
3681
|
}
|
|
3626
3682
|
function equal2(uriA, uriB, options) {
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
} else if (typeof uriA === "object") {
|
|
3631
|
-
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
|
|
3632
|
-
}
|
|
3633
|
-
if (typeof uriB === "string") {
|
|
3634
|
-
uriB = unescape(uriB);
|
|
3635
|
-
uriB = serialize(normalizeComponentEncoding(parse2(uriB, options), true), { ...options, skipEscape: true });
|
|
3636
|
-
} else if (typeof uriB === "object") {
|
|
3637
|
-
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
|
|
3638
|
-
}
|
|
3639
|
-
return uriA.toLowerCase() === uriB.toLowerCase();
|
|
3683
|
+
const normalizedA = normalizeComparableURI(uriA, options);
|
|
3684
|
+
const normalizedB = normalizeComparableURI(uriB, options);
|
|
3685
|
+
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
|
|
3640
3686
|
}
|
|
3641
3687
|
function serialize(cmpts, opts) {
|
|
3642
3688
|
const component = {
|
|
@@ -3661,12 +3707,12 @@
|
|
|
3661
3707
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
3662
3708
|
if (component.path !== void 0) {
|
|
3663
3709
|
if (!options.skipEscape) {
|
|
3664
|
-
component.path =
|
|
3710
|
+
component.path = escapePreservingEscapes(component.path);
|
|
3665
3711
|
if (component.scheme !== void 0) {
|
|
3666
3712
|
component.path = component.path.split("%3A").join(":");
|
|
3667
3713
|
}
|
|
3668
3714
|
} else {
|
|
3669
|
-
component.path =
|
|
3715
|
+
component.path = normalizePercentEncoding(component.path);
|
|
3670
3716
|
}
|
|
3671
3717
|
}
|
|
3672
3718
|
if (options.reference !== "suffix" && component.scheme) {
|
|
@@ -3701,7 +3747,16 @@
|
|
|
3701
3747
|
return uriTokens.join("");
|
|
3702
3748
|
}
|
|
3703
3749
|
const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
3704
|
-
function
|
|
3750
|
+
function getParseError(parsed, matches) {
|
|
3751
|
+
if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
|
|
3752
|
+
return 'URI path must start with "/" when authority is present.';
|
|
3753
|
+
}
|
|
3754
|
+
if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
|
|
3755
|
+
return "URI port is malformed.";
|
|
3756
|
+
}
|
|
3757
|
+
return void 0;
|
|
3758
|
+
}
|
|
3759
|
+
function parseWithStatus(uri2, opts) {
|
|
3705
3760
|
const options = Object.assign({}, opts);
|
|
3706
3761
|
const parsed = {
|
|
3707
3762
|
scheme: void 0,
|
|
@@ -3712,6 +3767,7 @@
|
|
|
3712
3767
|
query: void 0,
|
|
3713
3768
|
fragment: void 0
|
|
3714
3769
|
};
|
|
3770
|
+
let malformedAuthorityOrPort = false;
|
|
3715
3771
|
let isIP = false;
|
|
3716
3772
|
if (options.reference === "suffix") {
|
|
3717
3773
|
if (options.scheme) {
|
|
@@ -3732,6 +3788,11 @@
|
|
|
3732
3788
|
if (isNaN(parsed.port)) {
|
|
3733
3789
|
parsed.port = matches[5];
|
|
3734
3790
|
}
|
|
3791
|
+
const parseError = getParseError(parsed, matches);
|
|
3792
|
+
if (parseError !== void 0) {
|
|
3793
|
+
parsed.error = parsed.error || parseError;
|
|
3794
|
+
malformedAuthorityOrPort = true;
|
|
3795
|
+
}
|
|
3735
3796
|
if (parsed.host) {
|
|
3736
3797
|
const ipv4result = isIPv4(parsed.host);
|
|
3737
3798
|
if (ipv4result === false) {
|
|
@@ -3758,7 +3819,7 @@
|
|
|
3758
3819
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
3759
3820
|
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
3760
3821
|
try {
|
|
3761
|
-
parsed.host = URL
|
|
3822
|
+
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
3762
3823
|
} catch (e) {
|
|
3763
3824
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
3764
3825
|
}
|
|
@@ -3770,14 +3831,18 @@
|
|
|
3770
3831
|
parsed.scheme = unescape(parsed.scheme);
|
|
3771
3832
|
}
|
|
3772
3833
|
if (parsed.host !== void 0) {
|
|
3773
|
-
parsed.host = unescape(parsed.host);
|
|
3834
|
+
parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
|
|
3774
3835
|
}
|
|
3775
3836
|
}
|
|
3776
3837
|
if (parsed.path) {
|
|
3777
|
-
parsed.path =
|
|
3838
|
+
parsed.path = normalizePathEncoding(parsed.path);
|
|
3778
3839
|
}
|
|
3779
3840
|
if (parsed.fragment) {
|
|
3780
|
-
|
|
3841
|
+
try {
|
|
3842
|
+
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
|
|
3843
|
+
} catch {
|
|
3844
|
+
parsed.error = parsed.error || "URI malformed";
|
|
3845
|
+
}
|
|
3781
3846
|
}
|
|
3782
3847
|
}
|
|
3783
3848
|
if (schemeHandler && schemeHandler.parse) {
|
|
@@ -3786,7 +3851,29 @@
|
|
|
3786
3851
|
} else {
|
|
3787
3852
|
parsed.error = parsed.error || "URI can not be parsed.";
|
|
3788
3853
|
}
|
|
3789
|
-
return parsed;
|
|
3854
|
+
return { parsed, malformedAuthorityOrPort };
|
|
3855
|
+
}
|
|
3856
|
+
function parse2(uri2, opts) {
|
|
3857
|
+
return parseWithStatus(uri2, opts).parsed;
|
|
3858
|
+
}
|
|
3859
|
+
function normalizeString(uri2, opts) {
|
|
3860
|
+
return normalizeStringWithStatus(uri2, opts).normalized;
|
|
3861
|
+
}
|
|
3862
|
+
function normalizeStringWithStatus(uri2, opts) {
|
|
3863
|
+
const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri2, opts);
|
|
3864
|
+
return {
|
|
3865
|
+
normalized: malformedAuthorityOrPort ? uri2 : serialize(parsed, opts),
|
|
3866
|
+
malformedAuthorityOrPort
|
|
3867
|
+
};
|
|
3868
|
+
}
|
|
3869
|
+
function normalizeComparableURI(uri2, opts) {
|
|
3870
|
+
if (typeof uri2 === "string") {
|
|
3871
|
+
const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri2, opts);
|
|
3872
|
+
return malformedAuthorityOrPort ? void 0 : normalized;
|
|
3873
|
+
}
|
|
3874
|
+
if (typeof uri2 === "object") {
|
|
3875
|
+
return serialize(uri2, opts);
|
|
3876
|
+
}
|
|
3790
3877
|
}
|
|
3791
3878
|
const fastUri$1 = {
|
|
3792
3879
|
SCHEMES,
|
|
@@ -3925,7 +4012,7 @@
|
|
|
3925
4012
|
constructor(opts = {}) {
|
|
3926
4013
|
this.schemas = {};
|
|
3927
4014
|
this.refs = {};
|
|
3928
|
-
this.formats =
|
|
4015
|
+
this.formats = /* @__PURE__ */ Object.create(null);
|
|
3929
4016
|
this._compilations = /* @__PURE__ */ new Set();
|
|
3930
4017
|
this._loading = {};
|
|
3931
4018
|
this._cache = /* @__PURE__ */ new Map();
|
|
@@ -20099,46 +20186,128 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
20099
20186
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
20100
20187
|
}
|
|
20101
20188
|
}
|
|
20189
|
+
const LF = 10, CR = 13, SPACE = 32;
|
|
20102
20190
|
function noop(_arg) {
|
|
20103
20191
|
}
|
|
20104
|
-
function createParser(
|
|
20105
|
-
if (typeof
|
|
20192
|
+
function createParser(config2) {
|
|
20193
|
+
if (typeof config2 == "function")
|
|
20106
20194
|
throw new TypeError(
|
|
20107
|
-
"`
|
|
20195
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
20108
20196
|
);
|
|
20109
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } =
|
|
20110
|
-
let
|
|
20111
|
-
function feed(
|
|
20112
|
-
|
|
20113
|
-
|
|
20114
|
-
|
|
20115
|
-
|
|
20116
|
-
|
|
20117
|
-
|
|
20118
|
-
|
|
20197
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
20198
|
+
let pendingFragmentsLength = 0, isFirstChunk = true, id2, data = "", dataLines = 0, eventType, terminated = false;
|
|
20199
|
+
function feed(chunk) {
|
|
20200
|
+
if (terminated)
|
|
20201
|
+
throw new Error(
|
|
20202
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
20203
|
+
);
|
|
20204
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
20205
|
+
const trailing2 = processLines(chunk);
|
|
20206
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
20207
|
+
return;
|
|
20208
|
+
}
|
|
20209
|
+
if (chunk.indexOf(`
|
|
20210
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
20211
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
20212
|
+
return;
|
|
20213
|
+
}
|
|
20214
|
+
pendingFragments.push(chunk);
|
|
20215
|
+
const input = pendingFragments.join("");
|
|
20216
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
20217
|
+
const trailing = processLines(input);
|
|
20218
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
20219
|
+
}
|
|
20220
|
+
function checkBufferSize() {
|
|
20221
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id2 = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
20222
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
20223
|
+
type: "max-buffer-size-exceeded"
|
|
20224
|
+
})
|
|
20225
|
+
)));
|
|
20226
|
+
}
|
|
20227
|
+
function processLines(chunk) {
|
|
20228
|
+
let searchIndex = 0;
|
|
20229
|
+
if (chunk.indexOf("\r") === -1) {
|
|
20230
|
+
let lfIndex = chunk.indexOf(`
|
|
20231
|
+
`, searchIndex);
|
|
20232
|
+
for (; lfIndex !== -1; ) {
|
|
20233
|
+
if (searchIndex === lfIndex) {
|
|
20234
|
+
dataLines > 0 && onEvent({ id: id2, event: eventType, data }), id2 = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
20235
|
+
`, searchIndex);
|
|
20236
|
+
continue;
|
|
20237
|
+
}
|
|
20238
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
20239
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
20240
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
20241
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
20242
|
+
onEvent({ id: id2, event: eventType, data: value }), id2 = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
20243
|
+
`, searchIndex);
|
|
20244
|
+
continue;
|
|
20245
|
+
}
|
|
20246
|
+
data = dataLines === 0 ? value : `${data}
|
|
20247
|
+
${value}`, dataLines++;
|
|
20248
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
20249
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
20250
|
+
lfIndex
|
|
20251
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
20252
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
20253
|
+
`, searchIndex);
|
|
20254
|
+
}
|
|
20255
|
+
return chunk.slice(searchIndex);
|
|
20256
|
+
}
|
|
20257
|
+
for (; searchIndex < chunk.length; ) {
|
|
20258
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
20259
|
+
`, searchIndex);
|
|
20260
|
+
let lineEnd = -1;
|
|
20261
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
20262
|
+
break;
|
|
20263
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
20264
|
+
}
|
|
20265
|
+
return chunk.slice(searchIndex);
|
|
20266
|
+
}
|
|
20267
|
+
function parseLine(chunk, start, end) {
|
|
20268
|
+
if (start === end) {
|
|
20119
20269
|
dispatchEvent();
|
|
20120
20270
|
return;
|
|
20121
20271
|
}
|
|
20122
|
-
|
|
20123
|
-
|
|
20272
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
20273
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
20274
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
20275
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
20276
|
+
${value2}`, dataLines++;
|
|
20277
|
+
return;
|
|
20278
|
+
}
|
|
20279
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
20280
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
20124
20281
|
return;
|
|
20125
20282
|
}
|
|
20126
|
-
|
|
20127
|
-
|
|
20128
|
-
|
|
20129
|
-
processField(field, value, line);
|
|
20283
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
20284
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
20285
|
+
id2 = value2.includes("\0") ? void 0 : value2;
|
|
20130
20286
|
return;
|
|
20131
20287
|
}
|
|
20132
|
-
|
|
20288
|
+
if (firstCharCode === 58) {
|
|
20289
|
+
if (onComment) {
|
|
20290
|
+
const line2 = chunk.slice(start, end);
|
|
20291
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
20292
|
+
}
|
|
20293
|
+
return;
|
|
20294
|
+
}
|
|
20295
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
20296
|
+
if (fieldSeparatorIndex === -1) {
|
|
20297
|
+
processField(line, "", line);
|
|
20298
|
+
return;
|
|
20299
|
+
}
|
|
20300
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
20301
|
+
processField(field, value, line);
|
|
20133
20302
|
}
|
|
20134
20303
|
function processField(field, value, line) {
|
|
20135
20304
|
switch (field) {
|
|
20136
20305
|
case "event":
|
|
20137
|
-
eventType = value;
|
|
20306
|
+
eventType = value || void 0;
|
|
20138
20307
|
break;
|
|
20139
20308
|
case "data":
|
|
20140
|
-
data = `${data}
|
|
20141
|
-
|
|
20309
|
+
data = dataLines === 0 ? value : `${data}
|
|
20310
|
+
${value}`, dataLines++;
|
|
20142
20311
|
break;
|
|
20143
20312
|
case "id":
|
|
20144
20313
|
id2 = value.includes("\0") ? void 0 : value;
|
|
@@ -20163,37 +20332,26 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
20163
20332
|
}
|
|
20164
20333
|
}
|
|
20165
20334
|
function dispatchEvent() {
|
|
20166
|
-
|
|
20335
|
+
dataLines > 0 && onEvent({
|
|
20167
20336
|
id: id2,
|
|
20168
|
-
event: eventType
|
|
20169
|
-
|
|
20170
|
-
|
|
20171
|
-
data: data.endsWith(`
|
|
20172
|
-
`) ? data.slice(0, -1) : data
|
|
20173
|
-
}), id2 = void 0, data = "", eventType = "";
|
|
20337
|
+
event: eventType,
|
|
20338
|
+
data
|
|
20339
|
+
}), id2 = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
20174
20340
|
}
|
|
20175
20341
|
function reset(options = {}) {
|
|
20176
|
-
|
|
20342
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
20343
|
+
const incompleteLine = pendingFragments.join("");
|
|
20344
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
20345
|
+
}
|
|
20346
|
+
isFirstChunk = true, id2 = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
20177
20347
|
}
|
|
20178
20348
|
return { feed, reset };
|
|
20179
20349
|
}
|
|
20180
|
-
function
|
|
20181
|
-
|
|
20182
|
-
|
|
20183
|
-
|
|
20184
|
-
|
|
20185
|
-
`, searchIndex);
|
|
20186
|
-
let lineEnd = -1;
|
|
20187
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
20188
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
20189
|
-
break;
|
|
20190
|
-
} else {
|
|
20191
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
20192
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
20193
|
-
` && searchIndex++;
|
|
20194
|
-
}
|
|
20195
|
-
}
|
|
20196
|
-
return [lines, incompleteLine];
|
|
20350
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
20351
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
20352
|
+
}
|
|
20353
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
20354
|
+
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
20197
20355
|
}
|
|
20198
20356
|
class ErrorEvent extends Event {
|
|
20199
20357
|
/**
|
|
@@ -20677,7 +20835,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
20677
20835
|
}
|
|
20678
20836
|
}
|
|
20679
20837
|
class EventSourceParserStream extends TransformStream {
|
|
20680
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
20838
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
20681
20839
|
let parser;
|
|
20682
20840
|
super({
|
|
20683
20841
|
start(controller) {
|
|
@@ -20686,10 +20844,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
20686
20844
|
controller.enqueue(event);
|
|
20687
20845
|
},
|
|
20688
20846
|
onError(error) {
|
|
20689
|
-
onError
|
|
20847
|
+
typeof onError == "function" && onError(error), (onError === "terminate" || error.type === "max-buffer-size-exceeded") && controller.error(error);
|
|
20690
20848
|
},
|
|
20691
20849
|
onRetry,
|
|
20692
|
-
onComment
|
|
20850
|
+
onComment,
|
|
20851
|
+
maxBufferSize
|
|
20693
20852
|
});
|
|
20694
20853
|
},
|
|
20695
20854
|
transform(chunk) {
|