@pixui-dev/pxw 0.1.20 → 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/preact/css.d.ts +7476 -7476
- package/lib/types/preact/index.d.ts +340 -340
- package/lib/types/preact/internal.d.ts +94 -94
- package/lib/types/preact/jsx.d.ts +309 -309
- package/lib/types/preact-router/index.d.ts +84 -84
- 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,136 +1,136 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
var __extends =
|
|
3
|
-
(this && this.__extends) ||
|
|
4
|
-
(function () {
|
|
5
|
-
var extendStatics = function (d, b) {
|
|
6
|
-
extendStatics =
|
|
7
|
-
Object.setPrototypeOf ||
|
|
8
|
-
({ __proto__: [] } instanceof Array &&
|
|
9
|
-
function (d, b) {
|
|
10
|
-
d.__proto__ = b;
|
|
11
|
-
}) ||
|
|
12
|
-
function (d, b) {
|
|
13
|
-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
14
|
-
};
|
|
15
|
-
return extendStatics(d, b);
|
|
16
|
-
};
|
|
17
|
-
return function (d, b) {
|
|
18
|
-
extendStatics(d, b);
|
|
19
|
-
function __() {
|
|
20
|
-
this.constructor = d;
|
|
21
|
-
}
|
|
22
|
-
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
23
|
-
};
|
|
24
|
-
})();
|
|
25
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
26
|
-
var metadata_1 = require('../../metadata');
|
|
27
|
-
var debug_1 = require('../../debug');
|
|
28
|
-
var xhrUtil_1 = require('./xhrUtil');
|
|
29
|
-
function XhrTransport(init) {
|
|
30
|
-
return function (opts) {
|
|
31
|
-
if (xhrUtil_1.detectMozXHRSupport()) {
|
|
32
|
-
return new MozChunkedArrayBufferXHR(opts, init);
|
|
33
|
-
}
|
|
34
|
-
else if (xhrUtil_1.detectXHROverrideMimeTypeSupport()) {
|
|
35
|
-
return new XHR(opts, init);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
throw new Error('This environment\'s XHR implementation cannot support binary transfer.');
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.XhrTransport = XhrTransport;
|
|
43
|
-
var XHR = (function () {
|
|
44
|
-
function XHR(transportOptions, init) {
|
|
45
|
-
this.options = transportOptions;
|
|
46
|
-
this.init = init;
|
|
47
|
-
}
|
|
48
|
-
XHR.prototype.onProgressEvent = function () {
|
|
49
|
-
this.options.debug && debug_1.debug('XHR.onProgressEvent.length: ', this.xhr.response.length);
|
|
50
|
-
var rawText = this.xhr.response.substr(this.index);
|
|
51
|
-
this.index = this.xhr.response.length;
|
|
52
|
-
var asArrayBuffer = stringToArrayBuffer(rawText);
|
|
53
|
-
this.options.onChunk(asArrayBuffer);
|
|
54
|
-
};
|
|
55
|
-
XHR.prototype.onLoadEvent = function () {
|
|
56
|
-
this.options.debug && debug_1.debug('XHR.onLoadEvent');
|
|
57
|
-
this.options.onEnd();
|
|
58
|
-
};
|
|
59
|
-
XHR.prototype.onStateChange = function () {
|
|
60
|
-
this.options.debug && debug_1.debug('XHR.onStateChange', this.xhr.readyState);
|
|
61
|
-
if (this.xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
|
62
|
-
this.options.onHeaders(new metadata_1.Metadata(this.xhr.getAllResponseHeaders()), this.xhr.status);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
XHR.prototype.sendMessage = function (msgBytes) {
|
|
66
|
-
this.xhr.send(msgBytes);
|
|
67
|
-
};
|
|
68
|
-
XHR.prototype.finishSend = function () {};
|
|
69
|
-
XHR.prototype.start = function (metadata) {
|
|
70
|
-
var _this = this;
|
|
71
|
-
this.metadata = metadata;
|
|
72
|
-
var xhr = new XMLHttpRequest();
|
|
73
|
-
this.xhr = xhr;
|
|
74
|
-
xhr.open('POST', this.options.url);
|
|
75
|
-
this.configureXhr();
|
|
76
|
-
this.metadata.forEach(function (key, values) {
|
|
77
|
-
xhr.setRequestHeader(key, values.join(', '));
|
|
78
|
-
});
|
|
79
|
-
xhr.withCredentials = Boolean(this.init.withCredentials);
|
|
80
|
-
xhr.addEventListener('readystatechange', this.onStateChange.bind(this));
|
|
81
|
-
xhr.addEventListener('progress', this.onProgressEvent.bind(this));
|
|
82
|
-
xhr.addEventListener('loadend', this.onLoadEvent.bind(this));
|
|
83
|
-
xhr.addEventListener('error', function (err) {
|
|
84
|
-
_this.options.debug && debug_1.debug('XHR.error', err);
|
|
85
|
-
_this.options.onEnd(err.error);
|
|
86
|
-
});
|
|
87
|
-
};
|
|
88
|
-
XHR.prototype.configureXhr = function () {
|
|
89
|
-
this.xhr.responseType = 'text';
|
|
90
|
-
this.xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
|
91
|
-
};
|
|
92
|
-
XHR.prototype.cancel = function () {
|
|
93
|
-
this.options.debug && debug_1.debug('XHR.abort');
|
|
94
|
-
this.xhr.abort();
|
|
95
|
-
};
|
|
96
|
-
return XHR;
|
|
97
|
-
})();
|
|
98
|
-
exports.XHR = XHR;
|
|
99
|
-
var MozChunkedArrayBufferXHR = (function (_super) {
|
|
100
|
-
__extends(MozChunkedArrayBufferXHR, _super);
|
|
101
|
-
function MozChunkedArrayBufferXHR() {
|
|
102
|
-
return (_super !== null && _super.apply(this, arguments)) || this;
|
|
103
|
-
}
|
|
104
|
-
MozChunkedArrayBufferXHR.prototype.configureXhr = function () {
|
|
105
|
-
this.options.debug && debug_1.debug('MozXHR.configureXhr: setting responseType to \'moz-chunked-arraybuffer\'');
|
|
106
|
-
this.xhr.responseType = 'moz-chunked-arraybuffer';
|
|
107
|
-
};
|
|
108
|
-
MozChunkedArrayBufferXHR.prototype.onProgressEvent = function () {
|
|
109
|
-
var resp = this.xhr.response;
|
|
110
|
-
this.options.debug && debug_1.debug('MozXHR.onProgressEvent: ', new Uint8Array(resp));
|
|
111
|
-
this.options.onChunk(new Uint8Array(resp));
|
|
112
|
-
};
|
|
113
|
-
return MozChunkedArrayBufferXHR;
|
|
114
|
-
})(XHR);
|
|
115
|
-
exports.MozChunkedArrayBufferXHR = MozChunkedArrayBufferXHR;
|
|
116
|
-
function codePointAtPolyfill(str, index) {
|
|
117
|
-
var code = str.charCodeAt(index);
|
|
118
|
-
if (code >= 0xd800 && code <= 0xdbff) {
|
|
119
|
-
var surr = str.charCodeAt(index + 1);
|
|
120
|
-
if (surr >= 0xdc00 && surr <= 0xdfff) {
|
|
121
|
-
code = 0x10000 + ((code - 0xd800) << 10) + (surr - 0xdc00);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return code;
|
|
125
|
-
}
|
|
126
|
-
function stringToArrayBuffer(str) {
|
|
127
|
-
var asArray = new Uint8Array(str.length);
|
|
128
|
-
var arrayIndex = 0;
|
|
129
|
-
for (var i = 0; i < str.length; i++) {
|
|
130
|
-
var codePoint = String.prototype.codePointAt ? str.codePointAt(i) : codePointAtPolyfill(str, i);
|
|
131
|
-
asArray[arrayIndex++] = codePoint & 0xff;
|
|
132
|
-
}
|
|
133
|
-
return asArray;
|
|
134
|
-
}
|
|
135
|
-
exports.stringToArrayBuffer = stringToArrayBuffer;
|
|
136
|
-
//# sourceMappingURL=xhr.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
var __extends =
|
|
3
|
+
(this && this.__extends) ||
|
|
4
|
+
(function () {
|
|
5
|
+
var extendStatics = function (d, b) {
|
|
6
|
+
extendStatics =
|
|
7
|
+
Object.setPrototypeOf ||
|
|
8
|
+
({ __proto__: [] } instanceof Array &&
|
|
9
|
+
function (d, b) {
|
|
10
|
+
d.__proto__ = b;
|
|
11
|
+
}) ||
|
|
12
|
+
function (d, b) {
|
|
13
|
+
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
|
14
|
+
};
|
|
15
|
+
return extendStatics(d, b);
|
|
16
|
+
};
|
|
17
|
+
return function (d, b) {
|
|
18
|
+
extendStatics(d, b);
|
|
19
|
+
function __() {
|
|
20
|
+
this.constructor = d;
|
|
21
|
+
}
|
|
22
|
+
d.prototype = b === null ? Object.create(b) : ((__.prototype = b.prototype), new __());
|
|
23
|
+
};
|
|
24
|
+
})();
|
|
25
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
26
|
+
var metadata_1 = require('../../metadata');
|
|
27
|
+
var debug_1 = require('../../debug');
|
|
28
|
+
var xhrUtil_1 = require('./xhrUtil');
|
|
29
|
+
function XhrTransport(init) {
|
|
30
|
+
return function (opts) {
|
|
31
|
+
if (xhrUtil_1.detectMozXHRSupport()) {
|
|
32
|
+
return new MozChunkedArrayBufferXHR(opts, init);
|
|
33
|
+
}
|
|
34
|
+
else if (xhrUtil_1.detectXHROverrideMimeTypeSupport()) {
|
|
35
|
+
return new XHR(opts, init);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
throw new Error('This environment\'s XHR implementation cannot support binary transfer.');
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.XhrTransport = XhrTransport;
|
|
43
|
+
var XHR = (function () {
|
|
44
|
+
function XHR(transportOptions, init) {
|
|
45
|
+
this.options = transportOptions;
|
|
46
|
+
this.init = init;
|
|
47
|
+
}
|
|
48
|
+
XHR.prototype.onProgressEvent = function () {
|
|
49
|
+
this.options.debug && debug_1.debug('XHR.onProgressEvent.length: ', this.xhr.response.length);
|
|
50
|
+
var rawText = this.xhr.response.substr(this.index);
|
|
51
|
+
this.index = this.xhr.response.length;
|
|
52
|
+
var asArrayBuffer = stringToArrayBuffer(rawText);
|
|
53
|
+
this.options.onChunk(asArrayBuffer);
|
|
54
|
+
};
|
|
55
|
+
XHR.prototype.onLoadEvent = function () {
|
|
56
|
+
this.options.debug && debug_1.debug('XHR.onLoadEvent');
|
|
57
|
+
this.options.onEnd();
|
|
58
|
+
};
|
|
59
|
+
XHR.prototype.onStateChange = function () {
|
|
60
|
+
this.options.debug && debug_1.debug('XHR.onStateChange', this.xhr.readyState);
|
|
61
|
+
if (this.xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
|
|
62
|
+
this.options.onHeaders(new metadata_1.Metadata(this.xhr.getAllResponseHeaders()), this.xhr.status);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
XHR.prototype.sendMessage = function (msgBytes) {
|
|
66
|
+
this.xhr.send(msgBytes);
|
|
67
|
+
};
|
|
68
|
+
XHR.prototype.finishSend = function () {};
|
|
69
|
+
XHR.prototype.start = function (metadata) {
|
|
70
|
+
var _this = this;
|
|
71
|
+
this.metadata = metadata;
|
|
72
|
+
var xhr = new XMLHttpRequest();
|
|
73
|
+
this.xhr = xhr;
|
|
74
|
+
xhr.open('POST', this.options.url);
|
|
75
|
+
this.configureXhr();
|
|
76
|
+
this.metadata.forEach(function (key, values) {
|
|
77
|
+
xhr.setRequestHeader(key, values.join(', '));
|
|
78
|
+
});
|
|
79
|
+
xhr.withCredentials = Boolean(this.init.withCredentials);
|
|
80
|
+
xhr.addEventListener('readystatechange', this.onStateChange.bind(this));
|
|
81
|
+
xhr.addEventListener('progress', this.onProgressEvent.bind(this));
|
|
82
|
+
xhr.addEventListener('loadend', this.onLoadEvent.bind(this));
|
|
83
|
+
xhr.addEventListener('error', function (err) {
|
|
84
|
+
_this.options.debug && debug_1.debug('XHR.error', err);
|
|
85
|
+
_this.options.onEnd(err.error);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
XHR.prototype.configureXhr = function () {
|
|
89
|
+
this.xhr.responseType = 'text';
|
|
90
|
+
this.xhr.overrideMimeType('text/plain; charset=x-user-defined');
|
|
91
|
+
};
|
|
92
|
+
XHR.prototype.cancel = function () {
|
|
93
|
+
this.options.debug && debug_1.debug('XHR.abort');
|
|
94
|
+
this.xhr.abort();
|
|
95
|
+
};
|
|
96
|
+
return XHR;
|
|
97
|
+
})();
|
|
98
|
+
exports.XHR = XHR;
|
|
99
|
+
var MozChunkedArrayBufferXHR = (function (_super) {
|
|
100
|
+
__extends(MozChunkedArrayBufferXHR, _super);
|
|
101
|
+
function MozChunkedArrayBufferXHR() {
|
|
102
|
+
return (_super !== null && _super.apply(this, arguments)) || this;
|
|
103
|
+
}
|
|
104
|
+
MozChunkedArrayBufferXHR.prototype.configureXhr = function () {
|
|
105
|
+
this.options.debug && debug_1.debug('MozXHR.configureXhr: setting responseType to \'moz-chunked-arraybuffer\'');
|
|
106
|
+
this.xhr.responseType = 'moz-chunked-arraybuffer';
|
|
107
|
+
};
|
|
108
|
+
MozChunkedArrayBufferXHR.prototype.onProgressEvent = function () {
|
|
109
|
+
var resp = this.xhr.response;
|
|
110
|
+
this.options.debug && debug_1.debug('MozXHR.onProgressEvent: ', new Uint8Array(resp));
|
|
111
|
+
this.options.onChunk(new Uint8Array(resp));
|
|
112
|
+
};
|
|
113
|
+
return MozChunkedArrayBufferXHR;
|
|
114
|
+
})(XHR);
|
|
115
|
+
exports.MozChunkedArrayBufferXHR = MozChunkedArrayBufferXHR;
|
|
116
|
+
function codePointAtPolyfill(str, index) {
|
|
117
|
+
var code = str.charCodeAt(index);
|
|
118
|
+
if (code >= 0xd800 && code <= 0xdbff) {
|
|
119
|
+
var surr = str.charCodeAt(index + 1);
|
|
120
|
+
if (surr >= 0xdc00 && surr <= 0xdfff) {
|
|
121
|
+
code = 0x10000 + ((code - 0xd800) << 10) + (surr - 0xdc00);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return code;
|
|
125
|
+
}
|
|
126
|
+
function stringToArrayBuffer(str) {
|
|
127
|
+
var asArray = new Uint8Array(str.length);
|
|
128
|
+
var arrayIndex = 0;
|
|
129
|
+
for (var i = 0; i < str.length; i++) {
|
|
130
|
+
var codePoint = String.prototype.codePointAt ? str.codePointAt(i) : codePointAtPolyfill(str, i);
|
|
131
|
+
asArray[arrayIndex++] = codePoint & 0xff;
|
|
132
|
+
}
|
|
133
|
+
return asArray;
|
|
134
|
+
}
|
|
135
|
+
exports.stringToArrayBuffer = stringToArrayBuffer;
|
|
136
|
+
//# sourceMappingURL=xhr.js.map
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var xhr;
|
|
4
|
-
function getXHR() {
|
|
5
|
-
if (xhr !== undefined) return xhr;
|
|
6
|
-
if (XMLHttpRequest) {
|
|
7
|
-
xhr = new XMLHttpRequest();
|
|
8
|
-
try {
|
|
9
|
-
xhr.open('GET', 'https://localhost');
|
|
10
|
-
}
|
|
11
|
-
catch (e) {}
|
|
12
|
-
}
|
|
13
|
-
return xhr;
|
|
14
|
-
}
|
|
15
|
-
function xhrSupportsResponseType(type) {
|
|
16
|
-
var xhr = getXHR();
|
|
17
|
-
if (!xhr) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
try {
|
|
21
|
-
xhr.responseType = type;
|
|
22
|
-
return xhr.responseType === type;
|
|
23
|
-
}
|
|
24
|
-
catch (e) {}
|
|
25
|
-
return false;
|
|
26
|
-
}
|
|
27
|
-
exports.xhrSupportsResponseType = xhrSupportsResponseType;
|
|
28
|
-
function detectMozXHRSupport() {
|
|
29
|
-
return typeof XMLHttpRequest !== 'undefined' && xhrSupportsResponseType('moz-chunked-arraybuffer');
|
|
30
|
-
}
|
|
31
|
-
exports.detectMozXHRSupport = detectMozXHRSupport;
|
|
32
|
-
function detectXHROverrideMimeTypeSupport() {
|
|
33
|
-
return typeof XMLHttpRequest !== 'undefined' && XMLHttpRequest.prototype.hasOwnProperty('overrideMimeType');
|
|
34
|
-
}
|
|
35
|
-
exports.detectXHROverrideMimeTypeSupport = detectXHROverrideMimeTypeSupport;
|
|
36
|
-
//# sourceMappingURL=xhrUtil.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var xhr;
|
|
4
|
+
function getXHR() {
|
|
5
|
+
if (xhr !== undefined) return xhr;
|
|
6
|
+
if (XMLHttpRequest) {
|
|
7
|
+
xhr = new XMLHttpRequest();
|
|
8
|
+
try {
|
|
9
|
+
xhr.open('GET', 'https://localhost');
|
|
10
|
+
}
|
|
11
|
+
catch (e) {}
|
|
12
|
+
}
|
|
13
|
+
return xhr;
|
|
14
|
+
}
|
|
15
|
+
function xhrSupportsResponseType(type) {
|
|
16
|
+
var xhr = getXHR();
|
|
17
|
+
if (!xhr) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
xhr.responseType = type;
|
|
22
|
+
return xhr.responseType === type;
|
|
23
|
+
}
|
|
24
|
+
catch (e) {}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
exports.xhrSupportsResponseType = xhrSupportsResponseType;
|
|
28
|
+
function detectMozXHRSupport() {
|
|
29
|
+
return typeof XMLHttpRequest !== 'undefined' && xhrSupportsResponseType('moz-chunked-arraybuffer');
|
|
30
|
+
}
|
|
31
|
+
exports.detectMozXHRSupport = detectMozXHRSupport;
|
|
32
|
+
function detectXHROverrideMimeTypeSupport() {
|
|
33
|
+
return typeof XMLHttpRequest !== 'undefined' && XMLHttpRequest.prototype.hasOwnProperty('overrideMimeType');
|
|
34
|
+
}
|
|
35
|
+
exports.detectXHROverrideMimeTypeSupport = detectXHROverrideMimeTypeSupport;
|
|
36
|
+
//# sourceMappingURL=xhrUtil.js.map
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
-
var debug_1 = require('../../debug');
|
|
4
|
-
var ChunkParser_1 = require('../../ChunkParser');
|
|
5
|
-
var WebsocketSignal;
|
|
6
|
-
(function (WebsocketSignal) {
|
|
7
|
-
WebsocketSignal[(WebsocketSignal['FINISH_SEND'] = 1)] = 'FINISH_SEND';
|
|
8
|
-
})(WebsocketSignal || (WebsocketSignal = {}));
|
|
9
|
-
var finishSendFrame = new Uint8Array([1]);
|
|
10
|
-
function WebsocketTransport() {
|
|
11
|
-
return function (opts) {
|
|
12
|
-
return websocketRequest(opts);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
exports.WebsocketTransport = WebsocketTransport;
|
|
16
|
-
function websocketRequest(options) {
|
|
17
|
-
options.debug && debug_1.debug('websocketRequest', options);
|
|
18
|
-
var webSocketAddress = constructWebSocketAddress(options.url);
|
|
19
|
-
var sendQueue = [];
|
|
20
|
-
var ws;
|
|
21
|
-
function sendToWebsocket(toSend) {
|
|
22
|
-
if (toSend === WebsocketSignal.FINISH_SEND) {
|
|
23
|
-
ws.send(finishSendFrame);
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
options.debug && debug_1.debug('sendToWebsocket', toSend);
|
|
27
|
-
var byteArray = toSend;
|
|
28
|
-
var c = new Int8Array(byteArray.byteLength + 1);
|
|
29
|
-
c.set(new Uint8Array([0]));
|
|
30
|
-
c.set(byteArray, 1);
|
|
31
|
-
ws.send(c);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
sendMessage: function (msgBytes) {
|
|
36
|
-
if (!ws || ws.readyState === ws.CONNECTING) {
|
|
37
|
-
sendQueue.push(msgBytes);
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
sendToWebsocket(msgBytes);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
finishSend: function () {
|
|
44
|
-
if (!ws || ws.readyState === ws.CONNECTING) {
|
|
45
|
-
sendQueue.push(WebsocketSignal.FINISH_SEND);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
sendToWebsocket(WebsocketSignal.FINISH_SEND);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
start: function (metadata) {
|
|
52
|
-
ws = new WebSocket(webSocketAddress, ['grpc-websockets']);
|
|
53
|
-
ws.binaryType = 'arraybuffer';
|
|
54
|
-
ws.onopen = function () {
|
|
55
|
-
options.debug && debug_1.debug('websocketRequest.onopen');
|
|
56
|
-
ws.send(headersToBytes(metadata));
|
|
57
|
-
sendQueue.forEach(function (toSend) {
|
|
58
|
-
sendToWebsocket(toSend);
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
ws.onclose = function (closeEvent) {
|
|
62
|
-
options.debug && debug_1.debug('websocketRequest.onclose', closeEvent);
|
|
63
|
-
options.onEnd();
|
|
64
|
-
};
|
|
65
|
-
ws.onerror = function (error) {
|
|
66
|
-
options.debug && debug_1.debug('websocketRequest.onerror', error);
|
|
67
|
-
};
|
|
68
|
-
ws.onmessage = function (e) {
|
|
69
|
-
options.debug && debug_1.debug('ws.onmessage', e.data);
|
|
70
|
-
options.onChunk(new Uint8Array(e.data));
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
cancel: function () {
|
|
74
|
-
options.debug && debug_1.debug('websocket.abort');
|
|
75
|
-
ws.close();
|
|
76
|
-
},
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function constructWebSocketAddress(url) {
|
|
80
|
-
if (url.substr(0, 8) === 'https://') {
|
|
81
|
-
return 'wss://' + url.substr(8);
|
|
82
|
-
}
|
|
83
|
-
else if (url.substr(0, 7) === 'http://') {
|
|
84
|
-
return 'ws://' + url.substr(7);
|
|
85
|
-
}
|
|
86
|
-
throw new Error('Websocket transport constructed with non-https:// or http:// host.');
|
|
87
|
-
}
|
|
88
|
-
function headersToBytes(headers) {
|
|
89
|
-
var asString = '';
|
|
90
|
-
headers.forEach(function (key, values) {
|
|
91
|
-
asString += key + ': ' + values.join(', ') + '\r\n';
|
|
92
|
-
});
|
|
93
|
-
return ChunkParser_1.encodeASCII(asString);
|
|
94
|
-
}
|
|
95
|
-
//# sourceMappingURL=websocket.js.map
|
|
1
|
+
'use strict';
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
var debug_1 = require('../../debug');
|
|
4
|
+
var ChunkParser_1 = require('../../ChunkParser');
|
|
5
|
+
var WebsocketSignal;
|
|
6
|
+
(function (WebsocketSignal) {
|
|
7
|
+
WebsocketSignal[(WebsocketSignal['FINISH_SEND'] = 1)] = 'FINISH_SEND';
|
|
8
|
+
})(WebsocketSignal || (WebsocketSignal = {}));
|
|
9
|
+
var finishSendFrame = new Uint8Array([1]);
|
|
10
|
+
function WebsocketTransport() {
|
|
11
|
+
return function (opts) {
|
|
12
|
+
return websocketRequest(opts);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
exports.WebsocketTransport = WebsocketTransport;
|
|
16
|
+
function websocketRequest(options) {
|
|
17
|
+
options.debug && debug_1.debug('websocketRequest', options);
|
|
18
|
+
var webSocketAddress = constructWebSocketAddress(options.url);
|
|
19
|
+
var sendQueue = [];
|
|
20
|
+
var ws;
|
|
21
|
+
function sendToWebsocket(toSend) {
|
|
22
|
+
if (toSend === WebsocketSignal.FINISH_SEND) {
|
|
23
|
+
ws.send(finishSendFrame);
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
options.debug && debug_1.debug('sendToWebsocket', toSend);
|
|
27
|
+
var byteArray = toSend;
|
|
28
|
+
var c = new Int8Array(byteArray.byteLength + 1);
|
|
29
|
+
c.set(new Uint8Array([0]));
|
|
30
|
+
c.set(byteArray, 1);
|
|
31
|
+
ws.send(c);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
sendMessage: function (msgBytes) {
|
|
36
|
+
if (!ws || ws.readyState === ws.CONNECTING) {
|
|
37
|
+
sendQueue.push(msgBytes);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
sendToWebsocket(msgBytes);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
finishSend: function () {
|
|
44
|
+
if (!ws || ws.readyState === ws.CONNECTING) {
|
|
45
|
+
sendQueue.push(WebsocketSignal.FINISH_SEND);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
sendToWebsocket(WebsocketSignal.FINISH_SEND);
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
start: function (metadata) {
|
|
52
|
+
ws = new WebSocket(webSocketAddress, ['grpc-websockets']);
|
|
53
|
+
ws.binaryType = 'arraybuffer';
|
|
54
|
+
ws.onopen = function () {
|
|
55
|
+
options.debug && debug_1.debug('websocketRequest.onopen');
|
|
56
|
+
ws.send(headersToBytes(metadata));
|
|
57
|
+
sendQueue.forEach(function (toSend) {
|
|
58
|
+
sendToWebsocket(toSend);
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
ws.onclose = function (closeEvent) {
|
|
62
|
+
options.debug && debug_1.debug('websocketRequest.onclose', closeEvent);
|
|
63
|
+
options.onEnd();
|
|
64
|
+
};
|
|
65
|
+
ws.onerror = function (error) {
|
|
66
|
+
options.debug && debug_1.debug('websocketRequest.onerror', error);
|
|
67
|
+
};
|
|
68
|
+
ws.onmessage = function (e) {
|
|
69
|
+
options.debug && debug_1.debug('ws.onmessage', e.data);
|
|
70
|
+
options.onChunk(new Uint8Array(e.data));
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
cancel: function () {
|
|
74
|
+
options.debug && debug_1.debug('websocket.abort');
|
|
75
|
+
ws.close();
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function constructWebSocketAddress(url) {
|
|
80
|
+
if (url.substr(0, 8) === 'https://') {
|
|
81
|
+
return 'wss://' + url.substr(8);
|
|
82
|
+
}
|
|
83
|
+
else if (url.substr(0, 7) === 'http://') {
|
|
84
|
+
return 'ws://' + url.substr(7);
|
|
85
|
+
}
|
|
86
|
+
throw new Error('Websocket transport constructed with non-https:// or http:// host.');
|
|
87
|
+
}
|
|
88
|
+
function headersToBytes(headers) {
|
|
89
|
+
var asString = '';
|
|
90
|
+
headers.forEach(function (key, values) {
|
|
91
|
+
asString += key + ': ' + values.join(', ') + '\r\n';
|
|
92
|
+
});
|
|
93
|
+
return ChunkParser_1.encodeASCII(asString);
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=websocket.js.map
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Metadata } from './metadata';
|
|
2
|
-
export declare function decodeASCII(input: Uint8Array): string;
|
|
3
|
-
export declare function encodeASCII(input: string): Uint8Array;
|
|
4
|
-
export declare enum ChunkType {
|
|
5
|
-
MESSAGE = 1,
|
|
6
|
-
TRAILERS = 2,
|
|
7
|
-
}
|
|
8
|
-
export declare type Chunk = {
|
|
9
|
-
chunkType: ChunkType;
|
|
10
|
-
trailers?: Metadata;
|
|
11
|
-
data?: Uint8Array;
|
|
12
|
-
};
|
|
13
|
-
export declare class ChunkParser {
|
|
14
|
-
buffer: Uint8Array | null;
|
|
15
|
-
position: number;
|
|
16
|
-
parse(bytes: Uint8Array, flush?: boolean): Chunk[];
|
|
17
|
-
}
|
|
1
|
+
import { Metadata } from './metadata';
|
|
2
|
+
export declare function decodeASCII(input: Uint8Array): string;
|
|
3
|
+
export declare function encodeASCII(input: string): Uint8Array;
|
|
4
|
+
export declare enum ChunkType {
|
|
5
|
+
MESSAGE = 1,
|
|
6
|
+
TRAILERS = 2,
|
|
7
|
+
}
|
|
8
|
+
export declare type Chunk = {
|
|
9
|
+
chunkType: ChunkType;
|
|
10
|
+
trailers?: Metadata;
|
|
11
|
+
data?: Uint8Array;
|
|
12
|
+
};
|
|
13
|
+
export declare class ChunkParser {
|
|
14
|
+
buffer: Uint8Array | null;
|
|
15
|
+
position: number;
|
|
16
|
+
parse(bytes: Uint8Array, flush?: boolean): Chunk[];
|
|
17
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export declare enum Code {
|
|
2
|
-
OK = 0,
|
|
3
|
-
Canceled = 1,
|
|
4
|
-
Unknown = 2,
|
|
5
|
-
InvalidArgument = 3,
|
|
6
|
-
DeadlineExceeded = 4,
|
|
7
|
-
NotFound = 5,
|
|
8
|
-
AlreadyExists = 6,
|
|
9
|
-
PermissionDenied = 7,
|
|
10
|
-
ResourceExhausted = 8,
|
|
11
|
-
FailedPrecondition = 9,
|
|
12
|
-
Aborted = 10,
|
|
13
|
-
OutOfRange = 11,
|
|
14
|
-
Unimplemented = 12,
|
|
15
|
-
Internal = 13,
|
|
16
|
-
Unavailable = 14,
|
|
17
|
-
DataLoss = 15,
|
|
18
|
-
Unauthenticated = 16,
|
|
19
|
-
}
|
|
20
|
-
export declare function httpStatusToCode(httpStatus: number): Code;
|
|
1
|
+
export declare enum Code {
|
|
2
|
+
OK = 0,
|
|
3
|
+
Canceled = 1,
|
|
4
|
+
Unknown = 2,
|
|
5
|
+
InvalidArgument = 3,
|
|
6
|
+
DeadlineExceeded = 4,
|
|
7
|
+
NotFound = 5,
|
|
8
|
+
AlreadyExists = 6,
|
|
9
|
+
PermissionDenied = 7,
|
|
10
|
+
ResourceExhausted = 8,
|
|
11
|
+
FailedPrecondition = 9,
|
|
12
|
+
Aborted = 10,
|
|
13
|
+
OutOfRange = 11,
|
|
14
|
+
Unimplemented = 12,
|
|
15
|
+
Internal = 13,
|
|
16
|
+
Unavailable = 14,
|
|
17
|
+
DataLoss = 15,
|
|
18
|
+
Unauthenticated = 16,
|
|
19
|
+
}
|
|
20
|
+
export declare function httpStatusToCode(httpStatus: number): Code;
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Metadata } from './metadata';
|
|
2
|
-
import { Code } from './Code';
|
|
3
|
-
import { TransportFactory } from './transports/Transport';
|
|
4
|
-
import { MethodDefinition } from './service';
|
|
5
|
-
import { ProtobufMessage } from './message';
|
|
6
|
-
export interface RpcOptions {
|
|
7
|
-
transport?: TransportFactory;
|
|
8
|
-
debug?: boolean;
|
|
9
|
-
}
|
|
10
|
-
export interface ClientRpcOptions extends RpcOptions {
|
|
11
|
-
host: string;
|
|
12
|
-
}
|
|
13
|
-
export interface Client<TRequest extends ProtobufMessage, TResponse extends ProtobufMessage> {
|
|
14
|
-
start(metadata?: Metadata.ConstructorArg): void;
|
|
15
|
-
send(message: TRequest): void;
|
|
16
|
-
finishSend(): void;
|
|
17
|
-
close(): void;
|
|
18
|
-
onHeaders(callback: (headers: Metadata) => void): void;
|
|
19
|
-
onMessage(callback: (message: TResponse) => void): void;
|
|
20
|
-
onEnd(callback: (code: Code, message: string, trailers: Metadata) => void): void;
|
|
21
|
-
}
|
|
22
|
-
export declare function client<TRequest extends ProtobufMessage, TResponse extends ProtobufMessage, M extends MethodDefinition<TRequest, TResponse>>(
|
|
23
|
-
methodDescriptor: M,
|
|
24
|
-
props: ClientRpcOptions,
|
|
25
|
-
): Client<TRequest, TResponse>;
|
|
1
|
+
import { Metadata } from './metadata';
|
|
2
|
+
import { Code } from './Code';
|
|
3
|
+
import { TransportFactory } from './transports/Transport';
|
|
4
|
+
import { MethodDefinition } from './service';
|
|
5
|
+
import { ProtobufMessage } from './message';
|
|
6
|
+
export interface RpcOptions {
|
|
7
|
+
transport?: TransportFactory;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ClientRpcOptions extends RpcOptions {
|
|
11
|
+
host: string;
|
|
12
|
+
}
|
|
13
|
+
export interface Client<TRequest extends ProtobufMessage, TResponse extends ProtobufMessage> {
|
|
14
|
+
start(metadata?: Metadata.ConstructorArg): void;
|
|
15
|
+
send(message: TRequest): void;
|
|
16
|
+
finishSend(): void;
|
|
17
|
+
close(): void;
|
|
18
|
+
onHeaders(callback: (headers: Metadata) => void): void;
|
|
19
|
+
onMessage(callback: (message: TResponse) => void): void;
|
|
20
|
+
onEnd(callback: (code: Code, message: string, trailers: Metadata) => void): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function client<TRequest extends ProtobufMessage, TResponse extends ProtobufMessage, M extends MethodDefinition<TRequest, TResponse>>(
|
|
23
|
+
methodDescriptor: M,
|
|
24
|
+
props: ClientRpcOptions,
|
|
25
|
+
): Client<TRequest, TResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function debug(...args: any[]): void;
|
|
1
|
+
export declare function debug(...args: any[]): void;
|