@pixui-dev/pxw 0.1.32 → 0.1.33

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.
Files changed (2) hide show
  1. package/config/pfbs.js +9 -4
  2. package/package.json +1 -1
package/config/pfbs.js CHANGED
@@ -57,11 +57,16 @@ let pfbsConvert = async (ver, isJS, input, fn) => {
57
57
  xhr.onerror = () => reject(new Error('Network Error'));
58
58
  xhr.send();
59
59
  });
60
- } else if (typeof require !== 'undefined' && require('http')) {
61
- const http = require('http');
62
- console.log('http: ', url);
60
+ } else if (typeof require !== 'undefined') {
61
+ let protocol;
62
+ try {
63
+ console.log('require http/https: ', url);
64
+ protocol = url.startsWith('https') ? require('https') : require('http');
65
+ } catch (e) {
66
+ throw new Error('No supported HTTP client available');
67
+ }
63
68
  buffer = await new Promise((resolve, reject) => {
64
- http.get(url, (res) => {
69
+ protocol.get(url, (res) => {
65
70
  if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
66
71
  return resolve(this._fetchBuffer(res.headers.location));
67
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pixui-dev/pxw",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "private": false,
5
5
  "directories": {
6
6
  "lib": "lib"