@sanity/client 6.22.2 → 6.22.3-canary.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/README.md +43 -1
- package/dist/_chunks-cjs/resolveEditInfo.cjs.map +1 -1
- package/dist/_chunks-cjs/stegaEncodeSourceMap.cjs.map +1 -1
- package/dist/_chunks-es/resolveEditInfo.js.map +1 -1
- package/dist/_chunks-es/stegaEncodeSourceMap.js.map +1 -1
- package/dist/csm.cjs.map +1 -1
- package/dist/csm.js.map +1 -1
- package/dist/index.browser.cjs +26 -0
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.d.cts +12 -0
- package/dist/index.browser.d.ts +12 -0
- package/dist/index.browser.js +26 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +27 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +27 -1
- package/dist/index.js.map +1 -1
- package/package.json +20 -19
- package/src/data/live.ts +18 -0
- package/src/defineCreateClient.ts +1 -1
- package/src/http/errors.ts +28 -0
- package/src/stega/types.ts +1 -0
- package/src/types.ts +1 -0
- package/umd/sanityClient.js +1091 -1052
- package/umd/sanityClient.min.js +2 -2
package/umd/sanityClient.js
CHANGED
|
@@ -1133,6 +1133,19 @@
|
|
|
1133
1133
|
function stringifyBody(body, res) {
|
|
1134
1134
|
return (res.headers["content-type"] || "").toLowerCase().indexOf("application/json") !== -1 ? JSON.stringify(body, null, 2) : body;
|
|
1135
1135
|
}
|
|
1136
|
+
class CorsOriginError extends Error {
|
|
1137
|
+
projectId;
|
|
1138
|
+
addOriginUrl;
|
|
1139
|
+
constructor({ projectId: projectId2 }) {
|
|
1140
|
+
super("CorsOriginError"), this.name = "CorsOriginError", this.projectId = projectId2;
|
|
1141
|
+
const url = new URL(`https://sanity.io/manage/project/${projectId2}/api`);
|
|
1142
|
+
if (typeof location < "u") {
|
|
1143
|
+
const { origin } = location;
|
|
1144
|
+
url.searchParams.set("cors", "add"), url.searchParams.set("origin", origin), this.addOriginUrl = url, this.message = `The current origin is not allowed to connect to the Live Content API. Add it here: ${url}`;
|
|
1145
|
+
} else
|
|
1146
|
+
this.message = `The current origin is not allowed to connect to the Live Content API. Change your configuration here: ${url}`;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1136
1149
|
const httpError = {
|
|
1137
1150
|
onResponse: (res) => {
|
|
1138
1151
|
if (res.statusCode >= 500)
|
|
@@ -1954,7 +1967,7 @@ ${selectionOpts}`);
|
|
|
1954
1967
|
shouldEmitReconnect && observer.next({ type: "reconnect" });
|
|
1955
1968
|
}
|
|
1956
1969
|
async function getEventSource() {
|
|
1957
|
-
const { default: EventSource2 } = await Promise.resolve().then(function () { return browser$
|
|
1970
|
+
const { default: EventSource2 } = await Promise.resolve().then(function () { return browser$1; });
|
|
1958
1971
|
if (unsubscribed)
|
|
1959
1972
|
return;
|
|
1960
1973
|
const evs = new EventSource2(uri, esOptions);
|
|
@@ -2004,6 +2017,7 @@ ${selectionOpts}`);
|
|
|
2004
2017
|
tag: _tag
|
|
2005
2018
|
} = {}) {
|
|
2006
2019
|
const {
|
|
2020
|
+
projectId: projectId2,
|
|
2007
2021
|
apiVersion: _apiVersion,
|
|
2008
2022
|
token,
|
|
2009
2023
|
withCredentials,
|
|
@@ -2051,9 +2065,20 @@ ${selectionOpts}`);
|
|
|
2051
2065
|
}
|
|
2052
2066
|
}
|
|
2053
2067
|
async function getEventSource() {
|
|
2054
|
-
const EventSourceImplementation = typeof EventSource > "u" || esOptions.headers || esOptions.withCredentials ? (await Promise.resolve().then(function () { return browser$
|
|
2068
|
+
const EventSourceImplementation = typeof EventSource > "u" || esOptions.headers || esOptions.withCredentials ? (await Promise.resolve().then(function () { return browser$1; })).default : EventSource;
|
|
2055
2069
|
if (unsubscribed)
|
|
2056
2070
|
return;
|
|
2071
|
+
try {
|
|
2072
|
+
if (await fetch(url, {
|
|
2073
|
+
method: "OPTIONS",
|
|
2074
|
+
mode: "cors",
|
|
2075
|
+
credentials: esOptions.withCredentials ? "include" : "omit",
|
|
2076
|
+
headers: esOptions.headers
|
|
2077
|
+
}), unsubscribed)
|
|
2078
|
+
return;
|
|
2079
|
+
} catch {
|
|
2080
|
+
throw new CorsOriginError({ projectId: projectId2 });
|
|
2081
|
+
}
|
|
2057
2082
|
const evs = new EventSourceImplementation(url.toString(), esOptions);
|
|
2058
2083
|
evs.addEventListener("error", onError);
|
|
2059
2084
|
for (const type of listenFor)
|
|
@@ -2933,1072 +2958,1086 @@ ${selectionOpts}`);
|
|
|
2933
2958
|
stegaEncodeSourceMap$1: stegaEncodeSourceMap$1
|
|
2934
2959
|
});
|
|
2935
2960
|
|
|
2936
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
2937
|
-
|
|
2938
2961
|
function getDefaultExportFromCjs (x) {
|
|
2939
2962
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
2940
2963
|
}
|
|
2941
2964
|
|
|
2942
|
-
var eventsource = {exports: {}};
|
|
2965
|
+
var eventsource$1 = {exports: {}};
|
|
2943
2966
|
|
|
2944
2967
|
/** @license
|
|
2945
2968
|
* eventsource.js
|
|
2946
2969
|
* Available under MIT License (MIT)
|
|
2947
2970
|
* https://github.com/Yaffle/EventSource/
|
|
2948
2971
|
*/
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3217
|
-
|
|
3218
|
-
|
|
3219
|
-
|
|
3220
|
-
|
|
3221
|
-
|
|
3222
|
-
|
|
3223
|
-
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3328
|
-
|
|
3329
|
-
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
|
|
3934
|
-
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
2972
|
+
var eventsource = eventsource$1.exports;
|
|
2973
|
+
|
|
2974
|
+
var hasRequiredEventsource;
|
|
2975
|
+
|
|
2976
|
+
function requireEventsource () {
|
|
2977
|
+
if (hasRequiredEventsource) return eventsource$1.exports;
|
|
2978
|
+
hasRequiredEventsource = 1;
|
|
2979
|
+
(function (module, exports) {
|
|
2980
|
+
/*jslint indent: 2, vars: true, plusplus: true */
|
|
2981
|
+
/*global setTimeout, clearTimeout */
|
|
2982
|
+
|
|
2983
|
+
(function (global) {
|
|
2984
|
+
|
|
2985
|
+
var setTimeout = global.setTimeout;
|
|
2986
|
+
var clearTimeout = global.clearTimeout;
|
|
2987
|
+
var XMLHttpRequest = global.XMLHttpRequest;
|
|
2988
|
+
var XDomainRequest = global.XDomainRequest;
|
|
2989
|
+
var ActiveXObject = global.ActiveXObject;
|
|
2990
|
+
var NativeEventSource = global.EventSource;
|
|
2991
|
+
|
|
2992
|
+
var document = global.document;
|
|
2993
|
+
var Promise = global.Promise;
|
|
2994
|
+
var fetch = global.fetch;
|
|
2995
|
+
var Response = global.Response;
|
|
2996
|
+
var TextDecoder = global.TextDecoder;
|
|
2997
|
+
var TextEncoder = global.TextEncoder;
|
|
2998
|
+
var AbortController = global.AbortController;
|
|
2999
|
+
|
|
3000
|
+
if (typeof window !== "undefined" && typeof document !== "undefined" && !("readyState" in document) && document.body == null) { // Firefox 2
|
|
3001
|
+
document.readyState = "loading";
|
|
3002
|
+
window.addEventListener("load", function (event) {
|
|
3003
|
+
document.readyState = "complete";
|
|
3004
|
+
}, false);
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
if (XMLHttpRequest == null && ActiveXObject != null) { // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Using_XMLHttpRequest_in_IE6
|
|
3008
|
+
XMLHttpRequest = function () {
|
|
3009
|
+
return new ActiveXObject("Microsoft.XMLHTTP");
|
|
3010
|
+
};
|
|
3011
|
+
}
|
|
3012
|
+
|
|
3013
|
+
if (Object.create == undefined) {
|
|
3014
|
+
Object.create = function (C) {
|
|
3015
|
+
function F(){}
|
|
3016
|
+
F.prototype = C;
|
|
3017
|
+
return new F();
|
|
3018
|
+
};
|
|
3019
|
+
}
|
|
3020
|
+
|
|
3021
|
+
if (!Date.now) {
|
|
3022
|
+
Date.now = function now() {
|
|
3023
|
+
return new Date().getTime();
|
|
3024
|
+
};
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
// see #118 (Promise#finally with polyfilled Promise)
|
|
3028
|
+
// see #123 (data URLs crash Edge)
|
|
3029
|
+
// see #125 (CSP violations)
|
|
3030
|
+
// see pull/#138
|
|
3031
|
+
// => No way to polyfill Promise#finally
|
|
3032
|
+
|
|
3033
|
+
if (AbortController == undefined) {
|
|
3034
|
+
var originalFetch2 = fetch;
|
|
3035
|
+
fetch = function (url, options) {
|
|
3036
|
+
var signal = options.signal;
|
|
3037
|
+
return originalFetch2(url, {headers: options.headers, credentials: options.credentials, cache: options.cache}).then(function (response) {
|
|
3038
|
+
var reader = response.body.getReader();
|
|
3039
|
+
signal._reader = reader;
|
|
3040
|
+
if (signal._aborted) {
|
|
3041
|
+
signal._reader.cancel();
|
|
3042
|
+
}
|
|
3043
|
+
return {
|
|
3044
|
+
status: response.status,
|
|
3045
|
+
statusText: response.statusText,
|
|
3046
|
+
headers: response.headers,
|
|
3047
|
+
body: {
|
|
3048
|
+
getReader: function () {
|
|
3049
|
+
return reader;
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
};
|
|
3053
|
+
});
|
|
3054
|
+
};
|
|
3055
|
+
AbortController = function () {
|
|
3056
|
+
this.signal = {
|
|
3057
|
+
_reader: null,
|
|
3058
|
+
_aborted: false
|
|
3059
|
+
};
|
|
3060
|
+
this.abort = function () {
|
|
3061
|
+
if (this.signal._reader != null) {
|
|
3062
|
+
this.signal._reader.cancel();
|
|
3063
|
+
}
|
|
3064
|
+
this.signal._aborted = true;
|
|
3065
|
+
};
|
|
3066
|
+
};
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
function TextDecoderPolyfill() {
|
|
3070
|
+
this.bitsNeeded = 0;
|
|
3071
|
+
this.codePoint = 0;
|
|
3072
|
+
}
|
|
3073
|
+
|
|
3074
|
+
TextDecoderPolyfill.prototype.decode = function (octets) {
|
|
3075
|
+
function valid(codePoint, shift, octetsCount) {
|
|
3076
|
+
if (octetsCount === 1) {
|
|
3077
|
+
return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
|
|
3078
|
+
}
|
|
3079
|
+
if (octetsCount === 2) {
|
|
3080
|
+
return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
|
|
3081
|
+
}
|
|
3082
|
+
if (octetsCount === 3) {
|
|
3083
|
+
return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
|
|
3084
|
+
}
|
|
3085
|
+
throw new Error();
|
|
3086
|
+
}
|
|
3087
|
+
function octetsCount(bitsNeeded, codePoint) {
|
|
3088
|
+
if (bitsNeeded === 6 * 1) {
|
|
3089
|
+
return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;
|
|
3090
|
+
}
|
|
3091
|
+
if (bitsNeeded === 6 * 2) {
|
|
3092
|
+
return codePoint > 15 ? 3 : 2;
|
|
3093
|
+
}
|
|
3094
|
+
if (bitsNeeded === 6 * 3) {
|
|
3095
|
+
return 3;
|
|
3096
|
+
}
|
|
3097
|
+
throw new Error();
|
|
3098
|
+
}
|
|
3099
|
+
var REPLACER = 0xFFFD;
|
|
3100
|
+
var string = "";
|
|
3101
|
+
var bitsNeeded = this.bitsNeeded;
|
|
3102
|
+
var codePoint = this.codePoint;
|
|
3103
|
+
for (var i = 0; i < octets.length; i += 1) {
|
|
3104
|
+
var octet = octets[i];
|
|
3105
|
+
if (bitsNeeded !== 0) {
|
|
3106
|
+
if (octet < 128 || octet > 191 || !valid(codePoint << 6 | octet & 63, bitsNeeded - 6, octetsCount(bitsNeeded, codePoint))) {
|
|
3107
|
+
bitsNeeded = 0;
|
|
3108
|
+
codePoint = REPLACER;
|
|
3109
|
+
string += String.fromCharCode(codePoint);
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
if (bitsNeeded === 0) {
|
|
3113
|
+
if (octet >= 0 && octet <= 127) {
|
|
3114
|
+
bitsNeeded = 0;
|
|
3115
|
+
codePoint = octet;
|
|
3116
|
+
} else if (octet >= 192 && octet <= 223) {
|
|
3117
|
+
bitsNeeded = 6 * 1;
|
|
3118
|
+
codePoint = octet & 31;
|
|
3119
|
+
} else if (octet >= 224 && octet <= 239) {
|
|
3120
|
+
bitsNeeded = 6 * 2;
|
|
3121
|
+
codePoint = octet & 15;
|
|
3122
|
+
} else if (octet >= 240 && octet <= 247) {
|
|
3123
|
+
bitsNeeded = 6 * 3;
|
|
3124
|
+
codePoint = octet & 7;
|
|
3125
|
+
} else {
|
|
3126
|
+
bitsNeeded = 0;
|
|
3127
|
+
codePoint = REPLACER;
|
|
3128
|
+
}
|
|
3129
|
+
if (bitsNeeded !== 0 && !valid(codePoint, bitsNeeded, octetsCount(bitsNeeded, codePoint))) {
|
|
3130
|
+
bitsNeeded = 0;
|
|
3131
|
+
codePoint = REPLACER;
|
|
3132
|
+
}
|
|
3133
|
+
} else {
|
|
3134
|
+
bitsNeeded -= 6;
|
|
3135
|
+
codePoint = codePoint << 6 | octet & 63;
|
|
3136
|
+
}
|
|
3137
|
+
if (bitsNeeded === 0) {
|
|
3138
|
+
if (codePoint <= 0xFFFF) {
|
|
3139
|
+
string += String.fromCharCode(codePoint);
|
|
3140
|
+
} else {
|
|
3141
|
+
string += String.fromCharCode(0xD800 + (codePoint - 0xFFFF - 1 >> 10));
|
|
3142
|
+
string += String.fromCharCode(0xDC00 + (codePoint - 0xFFFF - 1 & 0x3FF));
|
|
3143
|
+
}
|
|
3144
|
+
}
|
|
3145
|
+
}
|
|
3146
|
+
this.bitsNeeded = bitsNeeded;
|
|
3147
|
+
this.codePoint = codePoint;
|
|
3148
|
+
return string;
|
|
3149
|
+
};
|
|
3150
|
+
|
|
3151
|
+
// Firefox < 38 throws an error with stream option
|
|
3152
|
+
var supportsStreamOption = function () {
|
|
3153
|
+
try {
|
|
3154
|
+
return new TextDecoder().decode(new TextEncoder().encode("test"), {stream: true}) === "test";
|
|
3155
|
+
} catch (error) {
|
|
3156
|
+
console.debug("TextDecoder does not support streaming option. Using polyfill instead: " + error);
|
|
3157
|
+
}
|
|
3158
|
+
return false;
|
|
3159
|
+
};
|
|
3160
|
+
|
|
3161
|
+
// IE, Edge
|
|
3162
|
+
if (TextDecoder == undefined || TextEncoder == undefined || !supportsStreamOption()) {
|
|
3163
|
+
TextDecoder = TextDecoderPolyfill;
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3166
|
+
var k = function () {
|
|
3167
|
+
};
|
|
3168
|
+
|
|
3169
|
+
function XHRWrapper(xhr) {
|
|
3170
|
+
this.withCredentials = false;
|
|
3171
|
+
this.readyState = 0;
|
|
3172
|
+
this.status = 0;
|
|
3173
|
+
this.statusText = "";
|
|
3174
|
+
this.responseText = "";
|
|
3175
|
+
this.onprogress = k;
|
|
3176
|
+
this.onload = k;
|
|
3177
|
+
this.onerror = k;
|
|
3178
|
+
this.onreadystatechange = k;
|
|
3179
|
+
this._contentType = "";
|
|
3180
|
+
this._xhr = xhr;
|
|
3181
|
+
this._sendTimeout = 0;
|
|
3182
|
+
this._abort = k;
|
|
3183
|
+
}
|
|
3184
|
+
|
|
3185
|
+
XHRWrapper.prototype.open = function (method, url) {
|
|
3186
|
+
this._abort(true);
|
|
3187
|
+
|
|
3188
|
+
var that = this;
|
|
3189
|
+
var xhr = this._xhr;
|
|
3190
|
+
var state = 1;
|
|
3191
|
+
var timeout = 0;
|
|
3192
|
+
|
|
3193
|
+
this._abort = function (silent) {
|
|
3194
|
+
if (that._sendTimeout !== 0) {
|
|
3195
|
+
clearTimeout(that._sendTimeout);
|
|
3196
|
+
that._sendTimeout = 0;
|
|
3197
|
+
}
|
|
3198
|
+
if (state === 1 || state === 2 || state === 3) {
|
|
3199
|
+
state = 4;
|
|
3200
|
+
xhr.onload = k;
|
|
3201
|
+
xhr.onerror = k;
|
|
3202
|
+
xhr.onabort = k;
|
|
3203
|
+
xhr.onprogress = k;
|
|
3204
|
+
xhr.onreadystatechange = k;
|
|
3205
|
+
// IE 8 - 9: XDomainRequest#abort() does not fire any event
|
|
3206
|
+
// Opera < 10: XMLHttpRequest#abort() does not fire any event
|
|
3207
|
+
xhr.abort();
|
|
3208
|
+
if (timeout !== 0) {
|
|
3209
|
+
clearTimeout(timeout);
|
|
3210
|
+
timeout = 0;
|
|
3211
|
+
}
|
|
3212
|
+
if (!silent) {
|
|
3213
|
+
that.readyState = 4;
|
|
3214
|
+
that.onabort(null);
|
|
3215
|
+
that.onreadystatechange();
|
|
3216
|
+
}
|
|
3217
|
+
}
|
|
3218
|
+
state = 0;
|
|
3219
|
+
};
|
|
3220
|
+
|
|
3221
|
+
var onStart = function () {
|
|
3222
|
+
if (state === 1) {
|
|
3223
|
+
//state = 2;
|
|
3224
|
+
var status = 0;
|
|
3225
|
+
var statusText = "";
|
|
3226
|
+
var contentType = undefined;
|
|
3227
|
+
if (!("contentType" in xhr)) {
|
|
3228
|
+
try {
|
|
3229
|
+
status = xhr.status;
|
|
3230
|
+
statusText = xhr.statusText;
|
|
3231
|
+
contentType = xhr.getResponseHeader("Content-Type");
|
|
3232
|
+
} catch (error) {
|
|
3233
|
+
// IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
|
|
3234
|
+
// Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
|
|
3235
|
+
// https://bugs.webkit.org/show_bug.cgi?id=29121
|
|
3236
|
+
status = 0;
|
|
3237
|
+
statusText = "";
|
|
3238
|
+
contentType = undefined;
|
|
3239
|
+
// Firefox < 14, Chrome ?, Safari ?
|
|
3240
|
+
// https://bugs.webkit.org/show_bug.cgi?id=29658
|
|
3241
|
+
// https://bugs.webkit.org/show_bug.cgi?id=77854
|
|
3242
|
+
}
|
|
3243
|
+
} else {
|
|
3244
|
+
status = 200;
|
|
3245
|
+
statusText = "OK";
|
|
3246
|
+
contentType = xhr.contentType;
|
|
3247
|
+
}
|
|
3248
|
+
if (status !== 0) {
|
|
3249
|
+
state = 2;
|
|
3250
|
+
that.readyState = 2;
|
|
3251
|
+
that.status = status;
|
|
3252
|
+
that.statusText = statusText;
|
|
3253
|
+
that._contentType = contentType;
|
|
3254
|
+
that.onreadystatechange();
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
};
|
|
3258
|
+
var onProgress = function () {
|
|
3259
|
+
onStart();
|
|
3260
|
+
if (state === 2 || state === 3) {
|
|
3261
|
+
state = 3;
|
|
3262
|
+
var responseText = "";
|
|
3263
|
+
try {
|
|
3264
|
+
responseText = xhr.responseText;
|
|
3265
|
+
} catch (error) {
|
|
3266
|
+
// IE 8 - 9 with XMLHttpRequest
|
|
3267
|
+
}
|
|
3268
|
+
that.readyState = 3;
|
|
3269
|
+
that.responseText = responseText;
|
|
3270
|
+
that.onprogress();
|
|
3271
|
+
}
|
|
3272
|
+
};
|
|
3273
|
+
var onFinish = function (type, event) {
|
|
3274
|
+
if (event == null || event.preventDefault == null) {
|
|
3275
|
+
event = {
|
|
3276
|
+
preventDefault: k
|
|
3277
|
+
};
|
|
3278
|
+
}
|
|
3279
|
+
// Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
|
|
3280
|
+
// IE 8 fires "onload" without "onprogress"
|
|
3281
|
+
onProgress();
|
|
3282
|
+
if (state === 1 || state === 2 || state === 3) {
|
|
3283
|
+
state = 4;
|
|
3284
|
+
if (timeout !== 0) {
|
|
3285
|
+
clearTimeout(timeout);
|
|
3286
|
+
timeout = 0;
|
|
3287
|
+
}
|
|
3288
|
+
that.readyState = 4;
|
|
3289
|
+
if (type === "load") {
|
|
3290
|
+
that.onload(event);
|
|
3291
|
+
} else if (type === "error") {
|
|
3292
|
+
that.onerror(event);
|
|
3293
|
+
} else if (type === "abort") {
|
|
3294
|
+
that.onabort(event);
|
|
3295
|
+
} else {
|
|
3296
|
+
throw new TypeError();
|
|
3297
|
+
}
|
|
3298
|
+
that.onreadystatechange();
|
|
3299
|
+
}
|
|
3300
|
+
};
|
|
3301
|
+
var onReadyStateChange = function (event) {
|
|
3302
|
+
if (xhr != undefined) { // Opera 12
|
|
3303
|
+
if (xhr.readyState === 4) {
|
|
3304
|
+
if (!("onload" in xhr) || !("onerror" in xhr) || !("onabort" in xhr)) {
|
|
3305
|
+
onFinish(xhr.responseText === "" ? "error" : "load", event);
|
|
3306
|
+
}
|
|
3307
|
+
} else if (xhr.readyState === 3) {
|
|
3308
|
+
if (!("onprogress" in xhr)) { // testing XMLHttpRequest#responseText too many times is too slow in IE 11
|
|
3309
|
+
// and in Firefox 3.6
|
|
3310
|
+
onProgress();
|
|
3311
|
+
}
|
|
3312
|
+
} else if (xhr.readyState === 2) {
|
|
3313
|
+
onStart();
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
};
|
|
3317
|
+
var onTimeout = function () {
|
|
3318
|
+
timeout = setTimeout(function () {
|
|
3319
|
+
onTimeout();
|
|
3320
|
+
}, 500);
|
|
3321
|
+
if (xhr.readyState === 3) {
|
|
3322
|
+
onProgress();
|
|
3323
|
+
}
|
|
3324
|
+
};
|
|
3325
|
+
|
|
3326
|
+
// XDomainRequest#abort removes onprogress, onerror, onload
|
|
3327
|
+
if ("onload" in xhr) {
|
|
3328
|
+
xhr.onload = function (event) {
|
|
3329
|
+
onFinish("load", event);
|
|
3330
|
+
};
|
|
3331
|
+
}
|
|
3332
|
+
if ("onerror" in xhr) {
|
|
3333
|
+
xhr.onerror = function (event) {
|
|
3334
|
+
onFinish("error", event);
|
|
3335
|
+
};
|
|
3336
|
+
}
|
|
3337
|
+
// improper fix to match Firefox behaviour, but it is better than just ignore abort
|
|
3338
|
+
// see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
|
|
3339
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=880200
|
|
3340
|
+
// https://code.google.com/p/chromium/issues/detail?id=153570
|
|
3341
|
+
// IE 8 fires "onload" without "onprogress
|
|
3342
|
+
if ("onabort" in xhr) {
|
|
3343
|
+
xhr.onabort = function (event) {
|
|
3344
|
+
onFinish("abort", event);
|
|
3345
|
+
};
|
|
3346
|
+
}
|
|
3347
|
+
|
|
3348
|
+
if ("onprogress" in xhr) {
|
|
3349
|
+
xhr.onprogress = onProgress;
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
// IE 8 - 9 (XMLHTTPRequest)
|
|
3353
|
+
// Opera < 12
|
|
3354
|
+
// Firefox < 3.5
|
|
3355
|
+
// Firefox 3.5 - 3.6 - ? < 9.0
|
|
3356
|
+
// onprogress is not fired sometimes or delayed
|
|
3357
|
+
// see also #64 (significant lag in IE 11)
|
|
3358
|
+
if ("onreadystatechange" in xhr) {
|
|
3359
|
+
xhr.onreadystatechange = function (event) {
|
|
3360
|
+
onReadyStateChange(event);
|
|
3361
|
+
};
|
|
3362
|
+
}
|
|
3363
|
+
|
|
3364
|
+
if ("contentType" in xhr || !("ontimeout" in XMLHttpRequest.prototype)) {
|
|
3365
|
+
url += (url.indexOf("?") === -1 ? "?" : "&") + "padding=true";
|
|
3366
|
+
}
|
|
3367
|
+
xhr.open(method, url, true);
|
|
3368
|
+
|
|
3369
|
+
if ("readyState" in xhr) {
|
|
3370
|
+
// workaround for Opera 12 issue with "progress" events
|
|
3371
|
+
// #91 (XMLHttpRequest onprogress not fired for streaming response in Edge 14-15-?)
|
|
3372
|
+
timeout = setTimeout(function () {
|
|
3373
|
+
onTimeout();
|
|
3374
|
+
}, 0);
|
|
3375
|
+
}
|
|
3376
|
+
};
|
|
3377
|
+
XHRWrapper.prototype.abort = function () {
|
|
3378
|
+
this._abort(false);
|
|
3379
|
+
};
|
|
3380
|
+
XHRWrapper.prototype.getResponseHeader = function (name) {
|
|
3381
|
+
return this._contentType;
|
|
3382
|
+
};
|
|
3383
|
+
XHRWrapper.prototype.setRequestHeader = function (name, value) {
|
|
3384
|
+
var xhr = this._xhr;
|
|
3385
|
+
if ("setRequestHeader" in xhr) {
|
|
3386
|
+
xhr.setRequestHeader(name, value);
|
|
3387
|
+
}
|
|
3388
|
+
};
|
|
3389
|
+
XHRWrapper.prototype.getAllResponseHeaders = function () {
|
|
3390
|
+
// XMLHttpRequest#getAllResponseHeaders returns null for CORS requests in Firefox 3.6.28
|
|
3391
|
+
return this._xhr.getAllResponseHeaders != undefined ? this._xhr.getAllResponseHeaders() || "" : "";
|
|
3392
|
+
};
|
|
3393
|
+
XHRWrapper.prototype.send = function () {
|
|
3394
|
+
// loading indicator in Safari < ? (6), Chrome < 14, Firefox
|
|
3395
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=736723
|
|
3396
|
+
if ((!("ontimeout" in XMLHttpRequest.prototype) || (!("sendAsBinary" in XMLHttpRequest.prototype) && !("mozAnon" in XMLHttpRequest.prototype))) &&
|
|
3397
|
+
document != undefined &&
|
|
3398
|
+
document.readyState != undefined &&
|
|
3399
|
+
document.readyState !== "complete") {
|
|
3400
|
+
var that = this;
|
|
3401
|
+
that._sendTimeout = setTimeout(function () {
|
|
3402
|
+
that._sendTimeout = 0;
|
|
3403
|
+
that.send();
|
|
3404
|
+
}, 4);
|
|
3405
|
+
return;
|
|
3406
|
+
}
|
|
3407
|
+
|
|
3408
|
+
var xhr = this._xhr;
|
|
3409
|
+
// withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
|
|
3410
|
+
if ("withCredentials" in xhr) {
|
|
3411
|
+
xhr.withCredentials = this.withCredentials;
|
|
3412
|
+
}
|
|
3413
|
+
try {
|
|
3414
|
+
// xhr.send(); throws "Not enough arguments" in Firefox 3.0
|
|
3415
|
+
xhr.send(undefined);
|
|
3416
|
+
} catch (error1) {
|
|
3417
|
+
// Safari 5.1.7, Opera 12
|
|
3418
|
+
throw error1;
|
|
3419
|
+
}
|
|
3420
|
+
};
|
|
3421
|
+
|
|
3422
|
+
function toLowerCase(name) {
|
|
3423
|
+
return name.replace(/[A-Z]/g, function (c) {
|
|
3424
|
+
return String.fromCharCode(c.charCodeAt(0) + 0x20);
|
|
3425
|
+
});
|
|
3426
|
+
}
|
|
3427
|
+
|
|
3428
|
+
function HeadersPolyfill(all) {
|
|
3429
|
+
// Get headers: implemented according to mozilla's example code: https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getAllResponseHeaders#Example
|
|
3430
|
+
var map = Object.create(null);
|
|
3431
|
+
var array = all.split("\r\n");
|
|
3432
|
+
for (var i = 0; i < array.length; i += 1) {
|
|
3433
|
+
var line = array[i];
|
|
3434
|
+
var parts = line.split(": ");
|
|
3435
|
+
var name = parts.shift();
|
|
3436
|
+
var value = parts.join(": ");
|
|
3437
|
+
map[toLowerCase(name)] = value;
|
|
3438
|
+
}
|
|
3439
|
+
this._map = map;
|
|
3440
|
+
}
|
|
3441
|
+
HeadersPolyfill.prototype.get = function (name) {
|
|
3442
|
+
return this._map[toLowerCase(name)];
|
|
3443
|
+
};
|
|
3444
|
+
|
|
3445
|
+
if (XMLHttpRequest != null && XMLHttpRequest.HEADERS_RECEIVED == null) { // IE < 9, Firefox 3.6
|
|
3446
|
+
XMLHttpRequest.HEADERS_RECEIVED = 2;
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
function XHRTransport() {
|
|
3450
|
+
}
|
|
3451
|
+
|
|
3452
|
+
XHRTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
3453
|
+
xhr.open("GET", url);
|
|
3454
|
+
var offset = 0;
|
|
3455
|
+
xhr.onprogress = function () {
|
|
3456
|
+
var responseText = xhr.responseText;
|
|
3457
|
+
var chunk = responseText.slice(offset);
|
|
3458
|
+
offset += chunk.length;
|
|
3459
|
+
onProgressCallback(chunk);
|
|
3460
|
+
};
|
|
3461
|
+
xhr.onerror = function (event) {
|
|
3462
|
+
event.preventDefault();
|
|
3463
|
+
onFinishCallback(new Error("NetworkError"));
|
|
3464
|
+
};
|
|
3465
|
+
xhr.onload = function () {
|
|
3466
|
+
onFinishCallback(null);
|
|
3467
|
+
};
|
|
3468
|
+
xhr.onabort = function () {
|
|
3469
|
+
onFinishCallback(null);
|
|
3470
|
+
};
|
|
3471
|
+
xhr.onreadystatechange = function () {
|
|
3472
|
+
if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
|
3473
|
+
var status = xhr.status;
|
|
3474
|
+
var statusText = xhr.statusText;
|
|
3475
|
+
var contentType = xhr.getResponseHeader("Content-Type");
|
|
3476
|
+
var headers = xhr.getAllResponseHeaders();
|
|
3477
|
+
onStartCallback(status, statusText, contentType, new HeadersPolyfill(headers));
|
|
3478
|
+
}
|
|
3479
|
+
};
|
|
3480
|
+
xhr.withCredentials = withCredentials;
|
|
3481
|
+
for (var name in headers) {
|
|
3482
|
+
if (Object.prototype.hasOwnProperty.call(headers, name)) {
|
|
3483
|
+
xhr.setRequestHeader(name, headers[name]);
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
xhr.send();
|
|
3487
|
+
return xhr;
|
|
3488
|
+
};
|
|
3489
|
+
|
|
3490
|
+
function HeadersWrapper(headers) {
|
|
3491
|
+
this._headers = headers;
|
|
3492
|
+
}
|
|
3493
|
+
HeadersWrapper.prototype.get = function (name) {
|
|
3494
|
+
return this._headers.get(name);
|
|
3495
|
+
};
|
|
3496
|
+
|
|
3497
|
+
function FetchTransport() {
|
|
3498
|
+
}
|
|
3499
|
+
|
|
3500
|
+
FetchTransport.prototype.open = function (xhr, onStartCallback, onProgressCallback, onFinishCallback, url, withCredentials, headers) {
|
|
3501
|
+
var reader = null;
|
|
3502
|
+
var controller = new AbortController();
|
|
3503
|
+
var signal = controller.signal;
|
|
3504
|
+
var textDecoder = new TextDecoder();
|
|
3505
|
+
fetch(url, {
|
|
3506
|
+
headers: headers,
|
|
3507
|
+
credentials: withCredentials ? "include" : "same-origin",
|
|
3508
|
+
signal: signal,
|
|
3509
|
+
cache: "no-store"
|
|
3510
|
+
}).then(function (response) {
|
|
3511
|
+
reader = response.body.getReader();
|
|
3512
|
+
onStartCallback(response.status, response.statusText, response.headers.get("Content-Type"), new HeadersWrapper(response.headers));
|
|
3513
|
+
// see https://github.com/promises-aplus/promises-spec/issues/179
|
|
3514
|
+
return new Promise(function (resolve, reject) {
|
|
3515
|
+
var readNextChunk = function () {
|
|
3516
|
+
reader.read().then(function (result) {
|
|
3517
|
+
if (result.done) {
|
|
3518
|
+
//Note: bytes in textDecoder are ignored
|
|
3519
|
+
resolve(undefined);
|
|
3520
|
+
} else {
|
|
3521
|
+
var chunk = textDecoder.decode(result.value, {stream: true});
|
|
3522
|
+
onProgressCallback(chunk);
|
|
3523
|
+
readNextChunk();
|
|
3524
|
+
}
|
|
3525
|
+
})["catch"](function (error) {
|
|
3526
|
+
reject(error);
|
|
3527
|
+
});
|
|
3528
|
+
};
|
|
3529
|
+
readNextChunk();
|
|
3530
|
+
});
|
|
3531
|
+
})["catch"](function (error) {
|
|
3532
|
+
if (error.name === "AbortError") {
|
|
3533
|
+
return undefined;
|
|
3534
|
+
} else {
|
|
3535
|
+
return error;
|
|
3536
|
+
}
|
|
3537
|
+
}).then(function (error) {
|
|
3538
|
+
onFinishCallback(error);
|
|
3539
|
+
});
|
|
3540
|
+
return {
|
|
3541
|
+
abort: function () {
|
|
3542
|
+
if (reader != null) {
|
|
3543
|
+
reader.cancel(); // https://bugzilla.mozilla.org/show_bug.cgi?id=1583815
|
|
3544
|
+
}
|
|
3545
|
+
controller.abort();
|
|
3546
|
+
}
|
|
3547
|
+
};
|
|
3548
|
+
};
|
|
3549
|
+
|
|
3550
|
+
function EventTarget() {
|
|
3551
|
+
this._listeners = Object.create(null);
|
|
3552
|
+
}
|
|
3553
|
+
|
|
3554
|
+
function throwError(e) {
|
|
3555
|
+
setTimeout(function () {
|
|
3556
|
+
throw e;
|
|
3557
|
+
}, 0);
|
|
3558
|
+
}
|
|
3559
|
+
|
|
3560
|
+
EventTarget.prototype.dispatchEvent = function (event) {
|
|
3561
|
+
event.target = this;
|
|
3562
|
+
var typeListeners = this._listeners[event.type];
|
|
3563
|
+
if (typeListeners != undefined) {
|
|
3564
|
+
var length = typeListeners.length;
|
|
3565
|
+
for (var i = 0; i < length; i += 1) {
|
|
3566
|
+
var listener = typeListeners[i];
|
|
3567
|
+
try {
|
|
3568
|
+
if (typeof listener.handleEvent === "function") {
|
|
3569
|
+
listener.handleEvent(event);
|
|
3570
|
+
} else {
|
|
3571
|
+
listener.call(this, event);
|
|
3572
|
+
}
|
|
3573
|
+
} catch (e) {
|
|
3574
|
+
throwError(e);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
};
|
|
3579
|
+
EventTarget.prototype.addEventListener = function (type, listener) {
|
|
3580
|
+
type = String(type);
|
|
3581
|
+
var listeners = this._listeners;
|
|
3582
|
+
var typeListeners = listeners[type];
|
|
3583
|
+
if (typeListeners == undefined) {
|
|
3584
|
+
typeListeners = [];
|
|
3585
|
+
listeners[type] = typeListeners;
|
|
3586
|
+
}
|
|
3587
|
+
var found = false;
|
|
3588
|
+
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
3589
|
+
if (typeListeners[i] === listener) {
|
|
3590
|
+
found = true;
|
|
3591
|
+
}
|
|
3592
|
+
}
|
|
3593
|
+
if (!found) {
|
|
3594
|
+
typeListeners.push(listener);
|
|
3595
|
+
}
|
|
3596
|
+
};
|
|
3597
|
+
EventTarget.prototype.removeEventListener = function (type, listener) {
|
|
3598
|
+
type = String(type);
|
|
3599
|
+
var listeners = this._listeners;
|
|
3600
|
+
var typeListeners = listeners[type];
|
|
3601
|
+
if (typeListeners != undefined) {
|
|
3602
|
+
var filtered = [];
|
|
3603
|
+
for (var i = 0; i < typeListeners.length; i += 1) {
|
|
3604
|
+
if (typeListeners[i] !== listener) {
|
|
3605
|
+
filtered.push(typeListeners[i]);
|
|
3606
|
+
}
|
|
3607
|
+
}
|
|
3608
|
+
if (filtered.length === 0) {
|
|
3609
|
+
delete listeners[type];
|
|
3610
|
+
} else {
|
|
3611
|
+
listeners[type] = filtered;
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
};
|
|
3615
|
+
|
|
3616
|
+
function Event(type) {
|
|
3617
|
+
this.type = type;
|
|
3618
|
+
this.target = undefined;
|
|
3619
|
+
}
|
|
3620
|
+
|
|
3621
|
+
function MessageEvent(type, options) {
|
|
3622
|
+
Event.call(this, type);
|
|
3623
|
+
this.data = options.data;
|
|
3624
|
+
this.lastEventId = options.lastEventId;
|
|
3625
|
+
}
|
|
3626
|
+
|
|
3627
|
+
MessageEvent.prototype = Object.create(Event.prototype);
|
|
3628
|
+
|
|
3629
|
+
function ConnectionEvent(type, options) {
|
|
3630
|
+
Event.call(this, type);
|
|
3631
|
+
this.status = options.status;
|
|
3632
|
+
this.statusText = options.statusText;
|
|
3633
|
+
this.headers = options.headers;
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
ConnectionEvent.prototype = Object.create(Event.prototype);
|
|
3637
|
+
|
|
3638
|
+
function ErrorEvent(type, options) {
|
|
3639
|
+
Event.call(this, type);
|
|
3640
|
+
this.error = options.error;
|
|
3641
|
+
}
|
|
3642
|
+
|
|
3643
|
+
ErrorEvent.prototype = Object.create(Event.prototype);
|
|
3644
|
+
|
|
3645
|
+
var WAITING = -1;
|
|
3646
|
+
var CONNECTING = 0;
|
|
3647
|
+
var OPEN = 1;
|
|
3648
|
+
var CLOSED = 2;
|
|
3649
|
+
|
|
3650
|
+
var AFTER_CR = -1;
|
|
3651
|
+
var FIELD_START = 0;
|
|
3652
|
+
var FIELD = 1;
|
|
3653
|
+
var VALUE_START = 2;
|
|
3654
|
+
var VALUE = 3;
|
|
3655
|
+
|
|
3656
|
+
var contentTypeRegExp = /^text\/event\-stream(;.*)?$/i;
|
|
3657
|
+
|
|
3658
|
+
var MINIMUM_DURATION = 1000;
|
|
3659
|
+
var MAXIMUM_DURATION = 18000000;
|
|
3660
|
+
|
|
3661
|
+
var parseDuration = function (value, def) {
|
|
3662
|
+
var n = value == null ? def : parseInt(value, 10);
|
|
3663
|
+
if (n !== n) {
|
|
3664
|
+
n = def;
|
|
3665
|
+
}
|
|
3666
|
+
return clampDuration(n);
|
|
3667
|
+
};
|
|
3668
|
+
var clampDuration = function (n) {
|
|
3669
|
+
return Math.min(Math.max(n, MINIMUM_DURATION), MAXIMUM_DURATION);
|
|
3670
|
+
};
|
|
3671
|
+
|
|
3672
|
+
var fire = function (that, f, event) {
|
|
3673
|
+
try {
|
|
3674
|
+
if (typeof f === "function") {
|
|
3675
|
+
f.call(that, event);
|
|
3676
|
+
}
|
|
3677
|
+
} catch (e) {
|
|
3678
|
+
throwError(e);
|
|
3679
|
+
}
|
|
3680
|
+
};
|
|
3681
|
+
|
|
3682
|
+
function EventSourcePolyfill(url, options) {
|
|
3683
|
+
EventTarget.call(this);
|
|
3684
|
+
options = options || {};
|
|
3685
|
+
|
|
3686
|
+
this.onopen = undefined;
|
|
3687
|
+
this.onmessage = undefined;
|
|
3688
|
+
this.onerror = undefined;
|
|
3689
|
+
|
|
3690
|
+
this.url = undefined;
|
|
3691
|
+
this.readyState = undefined;
|
|
3692
|
+
this.withCredentials = undefined;
|
|
3693
|
+
this.headers = undefined;
|
|
3694
|
+
|
|
3695
|
+
this._close = undefined;
|
|
3696
|
+
|
|
3697
|
+
start(this, url, options);
|
|
3698
|
+
}
|
|
3699
|
+
|
|
3700
|
+
function getBestXHRTransport() {
|
|
3701
|
+
return (XMLHttpRequest != undefined && ("withCredentials" in XMLHttpRequest.prototype)) || XDomainRequest == undefined
|
|
3702
|
+
? new XMLHttpRequest()
|
|
3703
|
+
: new XDomainRequest();
|
|
3704
|
+
}
|
|
3705
|
+
|
|
3706
|
+
var isFetchSupported = fetch != undefined && Response != undefined && "body" in Response.prototype;
|
|
3707
|
+
|
|
3708
|
+
function start(es, url, options) {
|
|
3709
|
+
url = String(url);
|
|
3710
|
+
var withCredentials = Boolean(options.withCredentials);
|
|
3711
|
+
var lastEventIdQueryParameterName = options.lastEventIdQueryParameterName || "lastEventId";
|
|
3712
|
+
|
|
3713
|
+
var initialRetry = clampDuration(1000);
|
|
3714
|
+
var heartbeatTimeout = parseDuration(options.heartbeatTimeout, 45000);
|
|
3715
|
+
|
|
3716
|
+
var lastEventId = "";
|
|
3717
|
+
var retry = initialRetry;
|
|
3718
|
+
var wasActivity = false;
|
|
3719
|
+
var textLength = 0;
|
|
3720
|
+
var headers = options.headers || {};
|
|
3721
|
+
var TransportOption = options.Transport;
|
|
3722
|
+
var xhr = isFetchSupported && TransportOption == undefined ? undefined : new XHRWrapper(TransportOption != undefined ? new TransportOption() : getBestXHRTransport());
|
|
3723
|
+
var transport = TransportOption != null && typeof TransportOption !== "string" ? new TransportOption() : (xhr == undefined ? new FetchTransport() : new XHRTransport());
|
|
3724
|
+
var abortController = undefined;
|
|
3725
|
+
var timeout = 0;
|
|
3726
|
+
var currentState = WAITING;
|
|
3727
|
+
var dataBuffer = "";
|
|
3728
|
+
var lastEventIdBuffer = "";
|
|
3729
|
+
var eventTypeBuffer = "";
|
|
3730
|
+
|
|
3731
|
+
var textBuffer = "";
|
|
3732
|
+
var state = FIELD_START;
|
|
3733
|
+
var fieldStart = 0;
|
|
3734
|
+
var valueStart = 0;
|
|
3735
|
+
|
|
3736
|
+
var onStart = function (status, statusText, contentType, headers) {
|
|
3737
|
+
if (currentState === CONNECTING) {
|
|
3738
|
+
if (status === 200 && contentType != undefined && contentTypeRegExp.test(contentType)) {
|
|
3739
|
+
currentState = OPEN;
|
|
3740
|
+
wasActivity = Date.now();
|
|
3741
|
+
retry = initialRetry;
|
|
3742
|
+
es.readyState = OPEN;
|
|
3743
|
+
var event = new ConnectionEvent("open", {
|
|
3744
|
+
status: status,
|
|
3745
|
+
statusText: statusText,
|
|
3746
|
+
headers: headers
|
|
3747
|
+
});
|
|
3748
|
+
es.dispatchEvent(event);
|
|
3749
|
+
fire(es, es.onopen, event);
|
|
3750
|
+
} else {
|
|
3751
|
+
var message = "";
|
|
3752
|
+
if (status !== 200) {
|
|
3753
|
+
if (statusText) {
|
|
3754
|
+
statusText = statusText.replace(/\s+/g, " ");
|
|
3755
|
+
}
|
|
3756
|
+
message = "EventSource's response has a status " + status + " " + statusText + " that is not 200. Aborting the connection.";
|
|
3757
|
+
} else {
|
|
3758
|
+
message = "EventSource's response has a Content-Type specifying an unsupported type: " + (contentType == undefined ? "-" : contentType.replace(/\s+/g, " ")) + ". Aborting the connection.";
|
|
3759
|
+
}
|
|
3760
|
+
close();
|
|
3761
|
+
var event = new ConnectionEvent("error", {
|
|
3762
|
+
status: status,
|
|
3763
|
+
statusText: statusText,
|
|
3764
|
+
headers: headers
|
|
3765
|
+
});
|
|
3766
|
+
es.dispatchEvent(event);
|
|
3767
|
+
fire(es, es.onerror, event);
|
|
3768
|
+
console.error(message);
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
};
|
|
3772
|
+
|
|
3773
|
+
var onProgress = function (textChunk) {
|
|
3774
|
+
if (currentState === OPEN) {
|
|
3775
|
+
var n = -1;
|
|
3776
|
+
for (var i = 0; i < textChunk.length; i += 1) {
|
|
3777
|
+
var c = textChunk.charCodeAt(i);
|
|
3778
|
+
if (c === "\n".charCodeAt(0) || c === "\r".charCodeAt(0)) {
|
|
3779
|
+
n = i;
|
|
3780
|
+
}
|
|
3781
|
+
}
|
|
3782
|
+
var chunk = (n !== -1 ? textBuffer : "") + textChunk.slice(0, n + 1);
|
|
3783
|
+
textBuffer = (n === -1 ? textBuffer : "") + textChunk.slice(n + 1);
|
|
3784
|
+
if (textChunk !== "") {
|
|
3785
|
+
wasActivity = Date.now();
|
|
3786
|
+
textLength += textChunk.length;
|
|
3787
|
+
}
|
|
3788
|
+
for (var position = 0; position < chunk.length; position += 1) {
|
|
3789
|
+
var c = chunk.charCodeAt(position);
|
|
3790
|
+
if (state === AFTER_CR && c === "\n".charCodeAt(0)) {
|
|
3791
|
+
state = FIELD_START;
|
|
3792
|
+
} else {
|
|
3793
|
+
if (state === AFTER_CR) {
|
|
3794
|
+
state = FIELD_START;
|
|
3795
|
+
}
|
|
3796
|
+
if (c === "\r".charCodeAt(0) || c === "\n".charCodeAt(0)) {
|
|
3797
|
+
if (state !== FIELD_START) {
|
|
3798
|
+
if (state === FIELD) {
|
|
3799
|
+
valueStart = position + 1;
|
|
3800
|
+
}
|
|
3801
|
+
var field = chunk.slice(fieldStart, valueStart - 1);
|
|
3802
|
+
var value = chunk.slice(valueStart + (valueStart < position && chunk.charCodeAt(valueStart) === " ".charCodeAt(0) ? 1 : 0), position);
|
|
3803
|
+
if (field === "data") {
|
|
3804
|
+
dataBuffer += "\n";
|
|
3805
|
+
dataBuffer += value;
|
|
3806
|
+
} else if (field === "id") {
|
|
3807
|
+
lastEventIdBuffer = value;
|
|
3808
|
+
} else if (field === "event") {
|
|
3809
|
+
eventTypeBuffer = value;
|
|
3810
|
+
} else if (field === "retry") {
|
|
3811
|
+
initialRetry = parseDuration(value, initialRetry);
|
|
3812
|
+
retry = initialRetry;
|
|
3813
|
+
} else if (field === "heartbeatTimeout") {
|
|
3814
|
+
heartbeatTimeout = parseDuration(value, heartbeatTimeout);
|
|
3815
|
+
if (timeout !== 0) {
|
|
3816
|
+
clearTimeout(timeout);
|
|
3817
|
+
timeout = setTimeout(function () {
|
|
3818
|
+
onTimeout();
|
|
3819
|
+
}, heartbeatTimeout);
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
if (state === FIELD_START) {
|
|
3824
|
+
if (dataBuffer !== "") {
|
|
3825
|
+
lastEventId = lastEventIdBuffer;
|
|
3826
|
+
if (eventTypeBuffer === "") {
|
|
3827
|
+
eventTypeBuffer = "message";
|
|
3828
|
+
}
|
|
3829
|
+
var event = new MessageEvent(eventTypeBuffer, {
|
|
3830
|
+
data: dataBuffer.slice(1),
|
|
3831
|
+
lastEventId: lastEventIdBuffer
|
|
3832
|
+
});
|
|
3833
|
+
es.dispatchEvent(event);
|
|
3834
|
+
if (eventTypeBuffer === "open") {
|
|
3835
|
+
fire(es, es.onopen, event);
|
|
3836
|
+
} else if (eventTypeBuffer === "message") {
|
|
3837
|
+
fire(es, es.onmessage, event);
|
|
3838
|
+
} else if (eventTypeBuffer === "error") {
|
|
3839
|
+
fire(es, es.onerror, event);
|
|
3840
|
+
}
|
|
3841
|
+
if (currentState === CLOSED) {
|
|
3842
|
+
return;
|
|
3843
|
+
}
|
|
3844
|
+
}
|
|
3845
|
+
dataBuffer = "";
|
|
3846
|
+
eventTypeBuffer = "";
|
|
3847
|
+
}
|
|
3848
|
+
state = c === "\r".charCodeAt(0) ? AFTER_CR : FIELD_START;
|
|
3849
|
+
} else {
|
|
3850
|
+
if (state === FIELD_START) {
|
|
3851
|
+
fieldStart = position;
|
|
3852
|
+
state = FIELD;
|
|
3853
|
+
}
|
|
3854
|
+
if (state === FIELD) {
|
|
3855
|
+
if (c === ":".charCodeAt(0)) {
|
|
3856
|
+
valueStart = position + 1;
|
|
3857
|
+
state = VALUE_START;
|
|
3858
|
+
}
|
|
3859
|
+
} else if (state === VALUE_START) {
|
|
3860
|
+
state = VALUE;
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
}
|
|
3864
|
+
}
|
|
3865
|
+
}
|
|
3866
|
+
};
|
|
3867
|
+
|
|
3868
|
+
var onFinish = function (error) {
|
|
3869
|
+
if (currentState === OPEN || currentState === CONNECTING) {
|
|
3870
|
+
currentState = WAITING;
|
|
3871
|
+
if (timeout !== 0) {
|
|
3872
|
+
clearTimeout(timeout);
|
|
3873
|
+
timeout = 0;
|
|
3874
|
+
}
|
|
3875
|
+
timeout = setTimeout(function () {
|
|
3876
|
+
onTimeout();
|
|
3877
|
+
}, retry);
|
|
3878
|
+
retry = clampDuration(Math.min(initialRetry * 16, retry * 2));
|
|
3879
|
+
|
|
3880
|
+
es.readyState = CONNECTING;
|
|
3881
|
+
var event = new ErrorEvent("error", {error: error});
|
|
3882
|
+
es.dispatchEvent(event);
|
|
3883
|
+
fire(es, es.onerror, event);
|
|
3884
|
+
if (error != undefined) {
|
|
3885
|
+
console.error(error);
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
};
|
|
3889
|
+
|
|
3890
|
+
var close = function () {
|
|
3891
|
+
currentState = CLOSED;
|
|
3892
|
+
if (abortController != undefined) {
|
|
3893
|
+
abortController.abort();
|
|
3894
|
+
abortController = undefined;
|
|
3895
|
+
}
|
|
3896
|
+
if (timeout !== 0) {
|
|
3897
|
+
clearTimeout(timeout);
|
|
3898
|
+
timeout = 0;
|
|
3899
|
+
}
|
|
3900
|
+
es.readyState = CLOSED;
|
|
3901
|
+
};
|
|
3902
|
+
|
|
3903
|
+
var onTimeout = function () {
|
|
3904
|
+
timeout = 0;
|
|
3905
|
+
|
|
3906
|
+
if (currentState !== WAITING) {
|
|
3907
|
+
if (!wasActivity && abortController != undefined) {
|
|
3908
|
+
onFinish(new Error("No activity within " + heartbeatTimeout + " milliseconds." + " " + (currentState === CONNECTING ? "No response received." : textLength + " chars received.") + " " + "Reconnecting."));
|
|
3909
|
+
if (abortController != undefined) {
|
|
3910
|
+
abortController.abort();
|
|
3911
|
+
abortController = undefined;
|
|
3912
|
+
}
|
|
3913
|
+
} else {
|
|
3914
|
+
var nextHeartbeat = Math.max((wasActivity || Date.now()) + heartbeatTimeout - Date.now(), 1);
|
|
3915
|
+
wasActivity = false;
|
|
3916
|
+
timeout = setTimeout(function () {
|
|
3917
|
+
onTimeout();
|
|
3918
|
+
}, nextHeartbeat);
|
|
3919
|
+
}
|
|
3920
|
+
return;
|
|
3921
|
+
}
|
|
3922
|
+
|
|
3923
|
+
wasActivity = false;
|
|
3924
|
+
textLength = 0;
|
|
3925
|
+
timeout = setTimeout(function () {
|
|
3926
|
+
onTimeout();
|
|
3927
|
+
}, heartbeatTimeout);
|
|
3928
|
+
|
|
3929
|
+
currentState = CONNECTING;
|
|
3930
|
+
dataBuffer = "";
|
|
3931
|
+
eventTypeBuffer = "";
|
|
3932
|
+
lastEventIdBuffer = lastEventId;
|
|
3933
|
+
textBuffer = "";
|
|
3934
|
+
fieldStart = 0;
|
|
3935
|
+
valueStart = 0;
|
|
3936
|
+
state = FIELD_START;
|
|
3937
|
+
|
|
3938
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=428916
|
|
3939
|
+
// Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
|
|
3940
|
+
var requestURL = url;
|
|
3941
|
+
if (url.slice(0, 5) !== "data:" && url.slice(0, 5) !== "blob:") {
|
|
3942
|
+
if (lastEventId !== "") {
|
|
3943
|
+
// Remove the lastEventId parameter if it's already part of the request URL.
|
|
3944
|
+
var i = url.indexOf("?");
|
|
3945
|
+
requestURL = i === -1 ? url : url.slice(0, i + 1) + url.slice(i + 1).replace(/(?:^|&)([^=&]*)(?:=[^&]*)?/g, function (p, paramName) {
|
|
3946
|
+
return paramName === lastEventIdQueryParameterName ? '' : p;
|
|
3947
|
+
});
|
|
3948
|
+
// Append the current lastEventId to the request URL.
|
|
3949
|
+
requestURL += (url.indexOf("?") === -1 ? "?" : "&") + lastEventIdQueryParameterName +"=" + encodeURIComponent(lastEventId);
|
|
3950
|
+
}
|
|
3951
|
+
}
|
|
3952
|
+
var withCredentials = es.withCredentials;
|
|
3953
|
+
var requestHeaders = {};
|
|
3954
|
+
requestHeaders["Accept"] = "text/event-stream";
|
|
3955
|
+
var headers = es.headers;
|
|
3956
|
+
if (headers != undefined) {
|
|
3957
|
+
for (var name in headers) {
|
|
3958
|
+
if (Object.prototype.hasOwnProperty.call(headers, name)) {
|
|
3959
|
+
requestHeaders[name] = headers[name];
|
|
3960
|
+
}
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
try {
|
|
3964
|
+
abortController = transport.open(xhr, onStart, onProgress, onFinish, requestURL, withCredentials, requestHeaders);
|
|
3965
|
+
} catch (error) {
|
|
3966
|
+
close();
|
|
3967
|
+
throw error;
|
|
3968
|
+
}
|
|
3969
|
+
};
|
|
3970
|
+
|
|
3971
|
+
es.url = url;
|
|
3972
|
+
es.readyState = CONNECTING;
|
|
3973
|
+
es.withCredentials = withCredentials;
|
|
3974
|
+
es.headers = headers;
|
|
3975
|
+
es._close = close;
|
|
3976
|
+
|
|
3977
|
+
onTimeout();
|
|
3978
|
+
}
|
|
3979
|
+
|
|
3980
|
+
EventSourcePolyfill.prototype = Object.create(EventTarget.prototype);
|
|
3981
|
+
EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
|
|
3982
|
+
EventSourcePolyfill.prototype.OPEN = OPEN;
|
|
3983
|
+
EventSourcePolyfill.prototype.CLOSED = CLOSED;
|
|
3984
|
+
EventSourcePolyfill.prototype.close = function () {
|
|
3985
|
+
this._close();
|
|
3986
|
+
};
|
|
3987
|
+
|
|
3988
|
+
EventSourcePolyfill.CONNECTING = CONNECTING;
|
|
3989
|
+
EventSourcePolyfill.OPEN = OPEN;
|
|
3990
|
+
EventSourcePolyfill.CLOSED = CLOSED;
|
|
3991
|
+
EventSourcePolyfill.prototype.withCredentials = undefined;
|
|
3992
|
+
|
|
3993
|
+
var R = NativeEventSource;
|
|
3994
|
+
if (XMLHttpRequest != undefined && (NativeEventSource == undefined || !("withCredentials" in NativeEventSource.prototype))) {
|
|
3995
|
+
// Why replace a native EventSource ?
|
|
3996
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=444328
|
|
3997
|
+
// https://bugzilla.mozilla.org/show_bug.cgi?id=831392
|
|
3998
|
+
// https://code.google.com/p/chromium/issues/detail?id=260144
|
|
3999
|
+
// https://code.google.com/p/chromium/issues/detail?id=225654
|
|
4000
|
+
// ...
|
|
4001
|
+
R = EventSourcePolyfill;
|
|
4002
|
+
}
|
|
4003
|
+
|
|
4004
|
+
(function (factory) {
|
|
4005
|
+
{
|
|
4006
|
+
var v = factory(exports);
|
|
4007
|
+
if (v !== undefined) module.exports = v;
|
|
4008
|
+
}
|
|
4009
|
+
})(function (exports) {
|
|
4010
|
+
exports.EventSourcePolyfill = EventSourcePolyfill;
|
|
4011
|
+
exports.NativeEventSource = NativeEventSource;
|
|
4012
|
+
exports.EventSource = R;
|
|
4013
|
+
});
|
|
4014
|
+
}(typeof globalThis === 'undefined' ? (typeof window !== 'undefined' ? window : typeof self !== 'undefined' ? self : eventsource) : globalThis));
|
|
4015
|
+
} (eventsource$1, eventsource$1.exports));
|
|
4016
|
+
return eventsource$1.exports;
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
var browser$2;
|
|
4020
|
+
var hasRequiredBrowser;
|
|
4021
|
+
|
|
4022
|
+
function requireBrowser () {
|
|
4023
|
+
if (hasRequiredBrowser) return browser$2;
|
|
4024
|
+
hasRequiredBrowser = 1;
|
|
4025
|
+
browser$2 = requireEventsource().EventSourcePolyfill;
|
|
4026
|
+
return browser$2;
|
|
4027
|
+
}
|
|
4028
|
+
|
|
4029
|
+
var browserExports = /*@__PURE__*/ requireBrowser();
|
|
4030
|
+
var browser = /*@__PURE__*/getDefaultExportFromCjs(browserExports);
|
|
4031
|
+
|
|
4032
|
+
var browser$1 = /*#__PURE__*/Object.freeze({
|
|
3995
4033
|
__proto__: null,
|
|
3996
|
-
default: browser
|
|
4034
|
+
default: browser
|
|
3997
4035
|
});
|
|
3998
4036
|
|
|
3999
4037
|
exports.BasePatch = BasePatch;
|
|
4000
4038
|
exports.BaseTransaction = BaseTransaction;
|
|
4001
4039
|
exports.ClientError = ClientError;
|
|
4040
|
+
exports.CorsOriginError = CorsOriginError;
|
|
4002
4041
|
exports.ObservablePatch = ObservablePatch;
|
|
4003
4042
|
exports.ObservableSanityClient = ObservableSanityClient;
|
|
4004
4043
|
exports.ObservableTransaction = ObservableTransaction;
|