@pixui-dev/pxw 0.1.19 → 0.1.21
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/bin/pxw.js +199 -199
- package/bin/wpbuild.js +10 -10
- package/config/default.conf +20 -20
- package/config/devops.js +372 -361
- package/config/h5es.js +10 -10
- package/config/index.html +183 -181
- package/config/pfbs.js +245 -245
- package/config/util.js +140 -140
- package/config/webpack.js +325 -309
- package/lib/assets/check.html +62 -62
- package/lib/assets/preact.js +4354 -4354
- package/lib/check/main.less +62 -62
- package/lib/check/main.tsx +41 -41
- package/lib/check/tool.js +3 -3
- package/lib/check/util.tsx +110 -110
- package/lib/grpc-web/dist/ChunkParser.js +117 -117
- package/lib/grpc-web/dist/Code.js +58 -58
- package/lib/grpc-web/dist/client.js +299 -299
- package/lib/grpc-web/dist/debug.js +16 -16
- package/lib/grpc-web/dist/detach.js +7 -7
- package/lib/grpc-web/dist/index.js +29 -29
- package/lib/grpc-web/dist/invoke.js +32 -32
- package/lib/grpc-web/dist/message.js +3 -3
- package/lib/grpc-web/dist/metadata.js +5 -5
- package/lib/grpc-web/dist/service.js +3 -3
- package/lib/grpc-web/dist/transports/Transport.js +15 -15
- package/lib/grpc-web/dist/transports/http/fetch.js +117 -117
- package/lib/grpc-web/dist/transports/http/http.js +15 -15
- package/lib/grpc-web/dist/transports/http/xhr.js +136 -136
- package/lib/grpc-web/dist/transports/http/xhrUtil.js +36 -36
- package/lib/grpc-web/dist/transports/websocket/websocket.js +95 -95
- package/lib/grpc-web/dist/typings/ChunkParser.d.ts +17 -17
- package/lib/grpc-web/dist/typings/Code.d.ts +20 -20
- package/lib/grpc-web/dist/typings/client.d.ts +25 -25
- package/lib/grpc-web/dist/typings/debug.d.ts +1 -1
- package/lib/grpc-web/dist/typings/detach.d.ts +1 -1
- package/lib/grpc-web/dist/typings/index.d.ts +45 -45
- package/lib/grpc-web/dist/typings/invoke.d.ts +20 -20
- package/lib/grpc-web/dist/typings/message.d.ts +8 -8
- package/lib/grpc-web/dist/typings/metadata.d.ts +2 -2
- package/lib/grpc-web/dist/typings/service.d.ts +16 -16
- package/lib/grpc-web/dist/typings/transports/Transport.d.ts +22 -22
- package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +6 -6
- package/lib/grpc-web/dist/typings/transports/http/http.d.ts +5 -5
- package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +27 -27
- package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +3 -3
- package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +2 -2
- package/lib/grpc-web/dist/typings/unary.d.ts +23 -23
- package/lib/grpc-web/dist/typings/util.d.ts +2 -2
- package/lib/grpc-web/dist/unary.js +44 -44
- package/lib/grpc-web/dist/util.js +11 -11
- package/lib/grpcTransport/PixHttp2Transport.ts +107 -107
- package/lib/grpcTransport/PixLuaTransport.ts +82 -82
- package/lib/h5es-types/v1.9.2/h5es.d.ts +1698 -1698
- package/lib/h5es-types/v3.5.0/h5es.d.ts +1788 -1788
- package/lib/pi_component/tinyList/tinyList.js +483 -483
- package/lib/pi_component/tinyList/tinyList.tsx +517 -517
- package/lib/preact-router.js +395 -395
- package/lib/preact.js +4355 -4355
- package/lib/preact.tq.js +4385 -4385
- package/lib/react-window/src/FixedSizeGrid.js +172 -172
- package/lib/react-window/src/FixedSizeList.js +91 -91
- package/lib/react-window/src/VariableSizeGrid.js +329 -329
- package/lib/react-window/src/VariableSizeList.js +231 -231
- package/lib/react-window/src/__tests__/FixedSizeGrid.js +942 -942
- package/lib/react-window/src/__tests__/FixedSizeList.js +749 -749
- package/lib/react-window/src/__tests__/VariableSizeGrid.js +598 -598
- package/lib/react-window/src/__tests__/VariableSizeList.js +345 -345
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +912 -912
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +568 -568
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +542 -542
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +331 -331
- package/lib/react-window/src/__tests__/areEqual.js +28 -28
- package/lib/react-window/src/__tests__/shouldComponentUpdate.js +32 -32
- package/lib/react-window/src/areEqual.js +13 -13
- package/lib/react-window/src/createGridComponent.js +657 -657
- package/lib/react-window/src/createListComponent.js +574 -574
- package/lib/react-window/src/domHelpers.js +69 -69
- package/lib/react-window/src/index.js +9 -9
- package/lib/react-window/src/shallowDiffers.js +17 -17
- package/lib/react-window/src/shouldComponentUpdate.js +11 -11
- package/lib/react-window/src/test.js.flow +382 -382
- package/lib/react-window/src/timer.js +36 -36
- package/lib/types/dom.ts +17 -17
- package/lib/types/ext.d.ts +81 -81
- package/lib/types/{css.d.ts → preact/css.d.ts} +7476 -7476
- package/lib/types/{preact.d.ts → preact/index.d.ts} +340 -340
- package/lib/types/{internal.d.ts → preact/internal.d.ts} +94 -94
- package/lib/types/{jsx.d.ts → preact/jsx.d.ts} +309 -309
- package/lib/types/preact-router/index.d.ts +85 -0
- package/package.json +113 -113
- package/scripts/pack.js +40 -40
- package/scripts/postinstall.js +11 -11
- package/scripts/run-pxw.js +12 -12
- package/tsconfig.json +30 -30
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var browser_headers_1 = require('browser-headers');
|
|
4
|
-
var impTransport = require('./transports/Transport');
|
|
5
|
-
var impTransportFetch = require('./transports/http/fetch');
|
|
6
|
-
var impTransportWebSocket = require('./transports/websocket/websocket');
|
|
7
|
-
var impTransportXhr = require('./transports/http/xhr');
|
|
8
|
-
var impTransportHttp = require('./transports/http/http');
|
|
9
|
-
var impCode = require('./Code');
|
|
10
|
-
var impInvoke = require('./invoke');
|
|
11
|
-
var impUnary = require('./unary');
|
|
12
|
-
var impClient = require('./client');
|
|
13
|
-
var grpc;
|
|
14
|
-
(function (grpc) {
|
|
15
|
-
grpc.setDefaultTransport = impTransport.setDefaultTransportFactory;
|
|
16
|
-
grpc.CrossBrowserHttpTransport = impTransportHttp.CrossBrowserHttpTransport;
|
|
17
|
-
grpc.FetchReadableStreamTransport = impTransportFetch.FetchReadableStreamTransport;
|
|
18
|
-
grpc.XhrTransport = impTransportXhr.XhrTransport;
|
|
19
|
-
grpc.WebsocketTransport = impTransportWebSocket.WebsocketTransport;
|
|
20
|
-
grpc.Code = impCode.Code;
|
|
21
|
-
grpc.Metadata = browser_headers_1.BrowserHeaders;
|
|
22
|
-
function client(methodDescriptor, props) {
|
|
23
|
-
return impClient.client(methodDescriptor, props);
|
|
24
|
-
}
|
|
25
|
-
grpc.client = client;
|
|
26
|
-
grpc.invoke = impInvoke.invoke;
|
|
27
|
-
grpc.unary = impUnary.unary;
|
|
28
|
-
})((grpc = exports.grpc || (exports.grpc = {})));
|
|
29
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var browser_headers_1 = require('browser-headers');
|
|
4
|
+
var impTransport = require('./transports/Transport');
|
|
5
|
+
var impTransportFetch = require('./transports/http/fetch');
|
|
6
|
+
var impTransportWebSocket = require('./transports/websocket/websocket');
|
|
7
|
+
var impTransportXhr = require('./transports/http/xhr');
|
|
8
|
+
var impTransportHttp = require('./transports/http/http');
|
|
9
|
+
var impCode = require('./Code');
|
|
10
|
+
var impInvoke = require('./invoke');
|
|
11
|
+
var impUnary = require('./unary');
|
|
12
|
+
var impClient = require('./client');
|
|
13
|
+
var grpc;
|
|
14
|
+
(function (grpc) {
|
|
15
|
+
grpc.setDefaultTransport = impTransport.setDefaultTransportFactory;
|
|
16
|
+
grpc.CrossBrowserHttpTransport = impTransportHttp.CrossBrowserHttpTransport;
|
|
17
|
+
grpc.FetchReadableStreamTransport = impTransportFetch.FetchReadableStreamTransport;
|
|
18
|
+
grpc.XhrTransport = impTransportXhr.XhrTransport;
|
|
19
|
+
grpc.WebsocketTransport = impTransportWebSocket.WebsocketTransport;
|
|
20
|
+
grpc.Code = impCode.Code;
|
|
21
|
+
grpc.Metadata = browser_headers_1.BrowserHeaders;
|
|
22
|
+
function client(methodDescriptor, props) {
|
|
23
|
+
return impClient.client(methodDescriptor, props);
|
|
24
|
+
}
|
|
25
|
+
grpc.client = client;
|
|
26
|
+
grpc.invoke = impInvoke.invoke;
|
|
27
|
+
grpc.unary = impUnary.unary;
|
|
28
|
+
})((grpc = exports.grpc || (exports.grpc = {})));
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var client_1 = require('./client');
|
|
4
|
-
function invoke(methodDescriptor, props) {
|
|
5
|
-
if (methodDescriptor.requestStream) {
|
|
6
|
-
throw new Error('.invoke cannot be used with client-streaming methods. Use .client instead.');
|
|
7
|
-
}
|
|
8
|
-
var grpcClient = client_1.client(methodDescriptor, {
|
|
9
|
-
host: props.host,
|
|
10
|
-
transport: props.transport,
|
|
11
|
-
debug: props.debug,
|
|
12
|
-
});
|
|
13
|
-
if (props.onHeaders) {
|
|
14
|
-
grpcClient.onHeaders(props.onHeaders);
|
|
15
|
-
}
|
|
16
|
-
if (props.onMessage) {
|
|
17
|
-
grpcClient.onMessage(props.onMessage);
|
|
18
|
-
}
|
|
19
|
-
if (props.onEnd) {
|
|
20
|
-
grpcClient.onEnd(props.onEnd);
|
|
21
|
-
}
|
|
22
|
-
grpcClient.start(props.metadata);
|
|
23
|
-
grpcClient.send(props.request);
|
|
24
|
-
grpcClient.finishSend();
|
|
25
|
-
return {
|
|
26
|
-
close: function () {
|
|
27
|
-
grpcClient.close();
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
exports.invoke = invoke;
|
|
32
|
-
//# sourceMappingURL=invoke.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var client_1 = require('./client');
|
|
4
|
+
function invoke(methodDescriptor, props) {
|
|
5
|
+
if (methodDescriptor.requestStream) {
|
|
6
|
+
throw new Error('.invoke cannot be used with client-streaming methods. Use .client instead.');
|
|
7
|
+
}
|
|
8
|
+
var grpcClient = client_1.client(methodDescriptor, {
|
|
9
|
+
host: props.host,
|
|
10
|
+
transport: props.transport,
|
|
11
|
+
debug: props.debug,
|
|
12
|
+
});
|
|
13
|
+
if (props.onHeaders) {
|
|
14
|
+
grpcClient.onHeaders(props.onHeaders);
|
|
15
|
+
}
|
|
16
|
+
if (props.onMessage) {
|
|
17
|
+
grpcClient.onMessage(props.onMessage);
|
|
18
|
+
}
|
|
19
|
+
if (props.onEnd) {
|
|
20
|
+
grpcClient.onEnd(props.onEnd);
|
|
21
|
+
}
|
|
22
|
+
grpcClient.start(props.metadata);
|
|
23
|
+
grpcClient.send(props.request);
|
|
24
|
+
grpcClient.finishSend();
|
|
25
|
+
return {
|
|
26
|
+
close: function () {
|
|
27
|
+
grpcClient.close();
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.invoke = invoke;
|
|
32
|
+
//# sourceMappingURL=invoke.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
//# sourceMappingURL=message.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var browser_headers_1 = require('browser-headers');
|
|
4
|
-
exports.Metadata = browser_headers_1.BrowserHeaders;
|
|
5
|
-
//# sourceMappingURL=metadata.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var browser_headers_1 = require('browser-headers');
|
|
4
|
+
exports.Metadata = browser_headers_1.BrowserHeaders;
|
|
5
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
//# sourceMappingURL=service.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var http_1 = require('./http/http');
|
|
4
|
-
var defaultTransportFactory = function (options) {
|
|
5
|
-
return http_1.CrossBrowserHttpTransport({ withCredentials: false })(options);
|
|
6
|
-
};
|
|
7
|
-
function setDefaultTransportFactory(t) {
|
|
8
|
-
defaultTransportFactory = t;
|
|
9
|
-
}
|
|
10
|
-
exports.setDefaultTransportFactory = setDefaultTransportFactory;
|
|
11
|
-
function makeDefaultTransport(options) {
|
|
12
|
-
return defaultTransportFactory(options);
|
|
13
|
-
}
|
|
14
|
-
exports.makeDefaultTransport = makeDefaultTransport;
|
|
15
|
-
//# sourceMappingURL=Transport.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var http_1 = require('./http/http');
|
|
4
|
+
var defaultTransportFactory = function (options) {
|
|
5
|
+
return http_1.CrossBrowserHttpTransport({ withCredentials: false })(options);
|
|
6
|
+
};
|
|
7
|
+
function setDefaultTransportFactory(t) {
|
|
8
|
+
defaultTransportFactory = t;
|
|
9
|
+
}
|
|
10
|
+
exports.setDefaultTransportFactory = setDefaultTransportFactory;
|
|
11
|
+
function makeDefaultTransport(options) {
|
|
12
|
+
return defaultTransportFactory(options);
|
|
13
|
+
}
|
|
14
|
+
exports.makeDefaultTransport = makeDefaultTransport;
|
|
15
|
+
//# sourceMappingURL=Transport.js.map
|
|
@@ -1,117 +1,117 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __assign =
|
|
3
|
-
(this && this.__assign) ||
|
|
4
|
-
function () {
|
|
5
|
-
__assign =
|
|
6
|
-
Object.assign ||
|
|
7
|
-
function (t) {
|
|
8
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
-
s = arguments[i];
|
|
10
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
17
|
-
var metadata_1 = require('../../metadata');
|
|
18
|
-
var debug_1 = require('../../debug');
|
|
19
|
-
function FetchReadableStreamTransport(init) {
|
|
20
|
-
return function (opts) {
|
|
21
|
-
return fetchRequest(opts, init);
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
exports.FetchReadableStreamTransport = FetchReadableStreamTransport;
|
|
25
|
-
function fetchRequest(options, init) {
|
|
26
|
-
options.debug && debug_1.debug('fetchRequest', options);
|
|
27
|
-
return new Fetch(options, init);
|
|
28
|
-
}
|
|
29
|
-
var Fetch = (function () {
|
|
30
|
-
function Fetch(transportOptions, init) {
|
|
31
|
-
this.cancelled = false;
|
|
32
|
-
this.controller = self.AbortController && new AbortController();
|
|
33
|
-
this.options = transportOptions;
|
|
34
|
-
this.init = init;
|
|
35
|
-
}
|
|
36
|
-
Fetch.prototype.pump = function (readerArg, res) {
|
|
37
|
-
var _this = this;
|
|
38
|
-
this.reader = readerArg;
|
|
39
|
-
if (this.cancelled) {
|
|
40
|
-
this.options.debug && debug_1.debug('Fetch.pump.cancel at first pump');
|
|
41
|
-
this.reader.cancel();
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.reader
|
|
45
|
-
.read()
|
|
46
|
-
.then(function (result) {
|
|
47
|
-
if (result.done) {
|
|
48
|
-
_this.options.onEnd();
|
|
49
|
-
return res;
|
|
50
|
-
}
|
|
51
|
-
_this.options.onChunk(result.value);
|
|
52
|
-
_this.pump(_this.reader, res);
|
|
53
|
-
return;
|
|
54
|
-
})
|
|
55
|
-
.catch(function (err) {
|
|
56
|
-
if (_this.cancelled) {
|
|
57
|
-
_this.options.debug && debug_1.debug('Fetch.catch - request cancelled');
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
_this.cancelled = true;
|
|
61
|
-
_this.options.debug && debug_1.debug('Fetch.catch', err.message);
|
|
62
|
-
_this.options.onEnd(err);
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
Fetch.prototype.send = function (msgBytes) {
|
|
66
|
-
var _this = this;
|
|
67
|
-
fetch(this.options.url, __assign({}, this.init, { headers: this.metadata.toHeaders(), method: 'POST', body: msgBytes, signal: this.controller && this.controller.signal }))
|
|
68
|
-
.then(function (res) {
|
|
69
|
-
_this.options.debug && debug_1.debug('Fetch.response', res);
|
|
70
|
-
_this.options.onHeaders(new metadata_1.Metadata(res.headers), res.status);
|
|
71
|
-
if (res.body) {
|
|
72
|
-
_this.pump(res.body.getReader(), res);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
return res;
|
|
76
|
-
})
|
|
77
|
-
.catch(function (err) {
|
|
78
|
-
if (_this.cancelled) {
|
|
79
|
-
_this.options.debug && debug_1.debug('Fetch.catch - request cancelled');
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
_this.cancelled = true;
|
|
83
|
-
_this.options.debug && debug_1.debug('Fetch.catch', err.message);
|
|
84
|
-
_this.options.onEnd(err);
|
|
85
|
-
});
|
|
86
|
-
};
|
|
87
|
-
Fetch.prototype.sendMessage = function (msgBytes) {
|
|
88
|
-
this.send(msgBytes);
|
|
89
|
-
};
|
|
90
|
-
Fetch.prototype.finishSend = function () {};
|
|
91
|
-
Fetch.prototype.start = function (metadata) {
|
|
92
|
-
this.metadata = metadata;
|
|
93
|
-
};
|
|
94
|
-
Fetch.prototype.cancel = function () {
|
|
95
|
-
if (this.cancelled) {
|
|
96
|
-
this.options.debug && debug_1.debug('Fetch.abort.cancel already cancelled');
|
|
97
|
-
return;
|
|
98
|
-
}
|
|
99
|
-
this.cancelled = true;
|
|
100
|
-
if (this.reader) {
|
|
101
|
-
this.options.debug && debug_1.debug('Fetch.abort.cancel');
|
|
102
|
-
this.reader.cancel();
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
this.options.debug && debug_1.debug('Fetch.abort.cancel before reader');
|
|
106
|
-
}
|
|
107
|
-
if (this.controller) {
|
|
108
|
-
this.controller.abort();
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
return Fetch;
|
|
112
|
-
})();
|
|
113
|
-
function detectFetchSupport() {
|
|
114
|
-
return typeof Response !== 'undefined' && Response.prototype.hasOwnProperty('body') && typeof Headers === 'function';
|
|
115
|
-
}
|
|
116
|
-
exports.detectFetchSupport = detectFetchSupport;
|
|
117
|
-
//# sourceMappingURL=fetch.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
var __assign =
|
|
3
|
+
(this && this.__assign) ||
|
|
4
|
+
function () {
|
|
5
|
+
__assign =
|
|
6
|
+
Object.assign ||
|
|
7
|
+
function (t) {
|
|
8
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
9
|
+
s = arguments[i];
|
|
10
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
17
|
+
var metadata_1 = require('../../metadata');
|
|
18
|
+
var debug_1 = require('../../debug');
|
|
19
|
+
function FetchReadableStreamTransport(init) {
|
|
20
|
+
return function (opts) {
|
|
21
|
+
return fetchRequest(opts, init);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.FetchReadableStreamTransport = FetchReadableStreamTransport;
|
|
25
|
+
function fetchRequest(options, init) {
|
|
26
|
+
options.debug && debug_1.debug('fetchRequest', options);
|
|
27
|
+
return new Fetch(options, init);
|
|
28
|
+
}
|
|
29
|
+
var Fetch = (function () {
|
|
30
|
+
function Fetch(transportOptions, init) {
|
|
31
|
+
this.cancelled = false;
|
|
32
|
+
this.controller = self.AbortController && new AbortController();
|
|
33
|
+
this.options = transportOptions;
|
|
34
|
+
this.init = init;
|
|
35
|
+
}
|
|
36
|
+
Fetch.prototype.pump = function (readerArg, res) {
|
|
37
|
+
var _this = this;
|
|
38
|
+
this.reader = readerArg;
|
|
39
|
+
if (this.cancelled) {
|
|
40
|
+
this.options.debug && debug_1.debug('Fetch.pump.cancel at first pump');
|
|
41
|
+
this.reader.cancel();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.reader
|
|
45
|
+
.read()
|
|
46
|
+
.then(function (result) {
|
|
47
|
+
if (result.done) {
|
|
48
|
+
_this.options.onEnd();
|
|
49
|
+
return res;
|
|
50
|
+
}
|
|
51
|
+
_this.options.onChunk(result.value);
|
|
52
|
+
_this.pump(_this.reader, res);
|
|
53
|
+
return;
|
|
54
|
+
})
|
|
55
|
+
.catch(function (err) {
|
|
56
|
+
if (_this.cancelled) {
|
|
57
|
+
_this.options.debug && debug_1.debug('Fetch.catch - request cancelled');
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
_this.cancelled = true;
|
|
61
|
+
_this.options.debug && debug_1.debug('Fetch.catch', err.message);
|
|
62
|
+
_this.options.onEnd(err);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
Fetch.prototype.send = function (msgBytes) {
|
|
66
|
+
var _this = this;
|
|
67
|
+
fetch(this.options.url, __assign({}, this.init, { headers: this.metadata.toHeaders(), method: 'POST', body: msgBytes, signal: this.controller && this.controller.signal }))
|
|
68
|
+
.then(function (res) {
|
|
69
|
+
_this.options.debug && debug_1.debug('Fetch.response', res);
|
|
70
|
+
_this.options.onHeaders(new metadata_1.Metadata(res.headers), res.status);
|
|
71
|
+
if (res.body) {
|
|
72
|
+
_this.pump(res.body.getReader(), res);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
return res;
|
|
76
|
+
})
|
|
77
|
+
.catch(function (err) {
|
|
78
|
+
if (_this.cancelled) {
|
|
79
|
+
_this.options.debug && debug_1.debug('Fetch.catch - request cancelled');
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
_this.cancelled = true;
|
|
83
|
+
_this.options.debug && debug_1.debug('Fetch.catch', err.message);
|
|
84
|
+
_this.options.onEnd(err);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
Fetch.prototype.sendMessage = function (msgBytes) {
|
|
88
|
+
this.send(msgBytes);
|
|
89
|
+
};
|
|
90
|
+
Fetch.prototype.finishSend = function () {};
|
|
91
|
+
Fetch.prototype.start = function (metadata) {
|
|
92
|
+
this.metadata = metadata;
|
|
93
|
+
};
|
|
94
|
+
Fetch.prototype.cancel = function () {
|
|
95
|
+
if (this.cancelled) {
|
|
96
|
+
this.options.debug && debug_1.debug('Fetch.abort.cancel already cancelled');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.cancelled = true;
|
|
100
|
+
if (this.reader) {
|
|
101
|
+
this.options.debug && debug_1.debug('Fetch.abort.cancel');
|
|
102
|
+
this.reader.cancel();
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
this.options.debug && debug_1.debug('Fetch.abort.cancel before reader');
|
|
106
|
+
}
|
|
107
|
+
if (this.controller) {
|
|
108
|
+
this.controller.abort();
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
return Fetch;
|
|
112
|
+
})();
|
|
113
|
+
function detectFetchSupport() {
|
|
114
|
+
return typeof Response !== 'undefined' && Response.prototype.hasOwnProperty('body') && typeof Headers === 'function';
|
|
115
|
+
}
|
|
116
|
+
exports.detectFetchSupport = detectFetchSupport;
|
|
117
|
+
//# sourceMappingURL=fetch.js.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var fetch_1 = require('./fetch');
|
|
4
|
-
var xhr_1 = require('./xhr');
|
|
5
|
-
function CrossBrowserHttpTransport(init) {
|
|
6
|
-
if (fetch_1.detectFetchSupport()) {
|
|
7
|
-
var fetchInit = {
|
|
8
|
-
credentials: init.withCredentials ? 'include' : 'same-origin',
|
|
9
|
-
};
|
|
10
|
-
return fetch_1.FetchReadableStreamTransport(fetchInit);
|
|
11
|
-
}
|
|
12
|
-
return xhr_1.XhrTransport({ withCredentials: init.withCredentials });
|
|
13
|
-
}
|
|
14
|
-
exports.CrossBrowserHttpTransport = CrossBrowserHttpTransport;
|
|
15
|
-
//# sourceMappingURL=http.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var fetch_1 = require('./fetch');
|
|
4
|
+
var xhr_1 = require('./xhr');
|
|
5
|
+
function CrossBrowserHttpTransport(init) {
|
|
6
|
+
if (fetch_1.detectFetchSupport()) {
|
|
7
|
+
var fetchInit = {
|
|
8
|
+
credentials: init.withCredentials ? 'include' : 'same-origin',
|
|
9
|
+
};
|
|
10
|
+
return fetch_1.FetchReadableStreamTransport(fetchInit);
|
|
11
|
+
}
|
|
12
|
+
return xhr_1.XhrTransport({ withCredentials: init.withCredentials });
|
|
13
|
+
}
|
|
14
|
+
exports.CrossBrowserHttpTransport = CrossBrowserHttpTransport;
|
|
15
|
+
//# sourceMappingURL=http.js.map
|