@lingxiteam/assets 3.3.1-alpha.8 → 3.3.1-alpha.9

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/es/theme/index.js CHANGED
@@ -2,50 +2,38 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
2
2
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
3
3
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
4
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
5
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
9
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
10
5
  /* eslint-disable no-console */
11
- var https = require('https');
6
+ var fetch = require('node-fetch');
12
7
  var fs = require('fs');
13
8
  var path = require('path');
14
9
  var unzipper = require('unzipper');
15
10
  var localFilePath = path.resolve(__dirname, './bin/default.zip');
16
11
  var outputDirectory = path.resolve(__dirname, './bin');
17
- var options = {
18
- port: 443,
19
- path: '/npm/@lingxiteam/theme@latest/bin/default.zip',
20
- method: 'GET',
21
- timeout: 2000
22
- };
23
-
24
- // 下载远程zip文件到本地
25
- var downloadRemoteZipFile = function downloadRemoteZipFile(_ref) {
26
- var url = _ref.url,
27
- hostname = _ref.hostname;
28
- var file = fs.createWriteStream(localFilePath);
29
- var _options = _objectSpread({
30
- hostname: hostname
31
- }, options);
32
- return new Promise(function (resolve, reject) {
33
- https.get(url || _options, function (response) {
34
- response.pipe(file);
35
- file.on('finish', function () {
36
- file.close();
37
- resolve(true);
38
- });
39
- file.on('error', function (error) {
40
- fs.unlink(localFilePath, function () {
41
- reject(error);
42
- });
43
- });
44
- }).on('error', function (error) {
45
- reject(error);
46
- });
47
- });
48
- };
12
+ var downloadRemoteZipFile = /*#__PURE__*/function () {
13
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
14
+ var res, dest;
15
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
16
+ while (1) {
17
+ switch (_context.prev = _context.next) {
18
+ case 0:
19
+ _context.next = 2;
20
+ return fetch(url);
21
+ case 2:
22
+ res = _context.sent;
23
+ dest = fs.createWriteStream(localFilePath);
24
+ res.body.pipe(dest);
25
+ return _context.abrupt("return", true);
26
+ case 6:
27
+ case "end":
28
+ return _context.stop();
29
+ }
30
+ }
31
+ }, _callee);
32
+ }));
33
+ return function downloadRemoteZipFile(_x) {
34
+ return _ref.apply(this, arguments);
35
+ };
36
+ }();
49
37
 
50
38
  // 解压文件
51
39
  var extractZip = function extractZip() {
@@ -59,92 +47,82 @@ var extractZip = function extractZip() {
59
47
  };
60
48
 
61
49
  // 获取主题
62
- var getThemeImpl = /*#__PURE__*/function () {
63
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
50
+ var getThemeFromNpm = /*#__PURE__*/function () {
51
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
64
52
  var domains, downRes, i;
65
- return _regeneratorRuntime().wrap(function _callee$(_context) {
53
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
66
54
  while (1) {
67
- switch (_context.prev = _context.next) {
55
+ switch (_context2.prev = _context2.next) {
68
56
  case 0:
69
57
  domains = ['fastly.jsdelivr.net', 'cdn.jsdelivr.net', 'gcore.jsdelivr.net', 'jsdelivr.codeqihan.com'];
70
58
  downRes = false;
71
- if (!url) {
72
- _context.next = 9;
73
- break;
74
- }
75
- _context.next = 5;
76
- return downloadRemoteZipFile({
77
- url: url
78
- });
79
- case 5:
80
- downRes = _context.sent;
81
- console.log('remote zip file download success!from https://dev.iwhalecloud.com ......');
82
- _context.next = 18;
83
- break;
84
- case 9:
85
59
  i = 0;
86
- case 10:
60
+ case 3:
87
61
  if (!(!downRes && i < 4)) {
88
- _context.next = 18;
62
+ _context2.next = 11;
89
63
  break;
90
64
  }
91
- _context.next = 13;
92
- return downloadRemoteZipFile({
93
- hostname: domains[i]
94
- });
95
- case 13:
96
- downRes = _context.sent;
65
+ _context2.next = 6;
66
+ return downloadRemoteZipFile("https://".concat(domains[i], "/npm/@lingxiteam/theme@latest/bin/default.zip"));
67
+ case 6:
68
+ downRes = _context2.sent;
97
69
  console.log("remote zip file download success\uFF01from ".concat(domains[i], "....."));
98
70
  i += 1;
99
- _context.next = 10;
71
+ _context2.next = 3;
100
72
  break;
101
- case 18:
73
+ case 11:
102
74
  if (downRes) {
103
75
  extractZip();
104
76
  }
105
- return _context.abrupt("return", downRes);
106
- case 20:
77
+ return _context2.abrupt("return", downRes);
78
+ case 13:
107
79
  case "end":
108
- return _context.stop();
80
+ return _context2.stop();
109
81
  }
110
82
  }
111
- }, _callee);
83
+ }, _callee2);
112
84
  }));
113
- return function getThemeImpl(_x) {
85
+ return function getThemeFromNpm() {
114
86
  return _ref2.apply(this, arguments);
115
87
  };
116
88
  }();
117
- var getTheme = /*#__PURE__*/function () {
118
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
119
- var url, res;
120
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
89
+ var getThemeFromPlat = /*#__PURE__*/function () {
90
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
91
+ var downRes;
92
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
121
93
  while (1) {
122
- switch (_context2.prev = _context2.next) {
94
+ switch (_context3.prev = _context3.next) {
123
95
  case 0:
124
- url = 'https://dev.iwhalecloud.com/portal/zcm-doc/file/download?filePath=document/book-275/doc/uploads/63433/ad4b0668-59d1-4535-8ab9-9633517f95b0/default.zip';
125
- _context2.prev = 1;
126
- _context2.next = 4;
127
- return getThemeImpl(url);
128
- case 4:
129
- res = _context2.sent;
130
- if (!res) {
131
- getThemeImpl();
132
- }
133
- _context2.next = 11;
96
+ _context3.prev = 0;
97
+ _context3.next = 3;
98
+ return downloadRemoteZipFile('http://172.21.72.205:18008/api/getLastPackageTheme?PROJECT_ID=lingxi');
99
+ case 3:
100
+ downRes = _context3.sent;
101
+ _context3.next = 11;
134
102
  break;
135
- case 8:
136
- _context2.prev = 8;
137
- _context2.t0 = _context2["catch"](1);
138
- console.error(_context2.t0);
103
+ case 6:
104
+ _context3.prev = 6;
105
+ _context3.t0 = _context3["catch"](0);
106
+ _context3.next = 10;
107
+ return getThemeFromNpm();
108
+ case 10:
109
+ downRes = _context3.sent;
139
110
  case 11:
111
+ if (downRes) {
112
+ extractZip();
113
+ }
114
+ case 12:
140
115
  case "end":
141
- return _context2.stop();
116
+ return _context3.stop();
142
117
  }
143
118
  }
144
- }, _callee2, null, [[1, 8]]);
119
+ }, _callee3, null, [[0, 6]]);
145
120
  }));
146
- return function getTheme() {
121
+ return function getThemeFromPlat() {
147
122
  return _ref3.apply(this, arguments);
148
123
  };
149
124
  }();
125
+ var getTheme = function getTheme() {
126
+ getThemeFromPlat();
127
+ };
150
128
  export default getTheme;
@@ -1,57 +1,45 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.default = void 0;
7
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
8
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
9
9
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
10
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
13
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
- function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
11
  /* eslint-disable no-console */
17
- var https = require('https');
12
+ var fetch = require('node-fetch');
18
13
  var fs = require('fs');
19
14
  var path = require('path');
20
15
  var unzipper = require('unzipper');
21
16
  var localFilePath = path.resolve(__dirname, './bin/default.zip');
22
17
  var outputDirectory = path.resolve(__dirname, './bin');
23
- var options = {
24
- port: 443,
25
- path: '/npm/@lingxiteam/theme@latest/bin/default.zip',
26
- method: 'GET',
27
- timeout: 2000
28
- };
29
-
30
- // 下载远程zip文件到本地
31
- var downloadRemoteZipFile = function downloadRemoteZipFile(_ref) {
32
- var url = _ref.url,
33
- hostname = _ref.hostname;
34
- var file = fs.createWriteStream(localFilePath);
35
- var _options = _objectSpread({
36
- hostname: hostname
37
- }, options);
38
- return new Promise(function (resolve, reject) {
39
- https.get(url || _options, function (response) {
40
- response.pipe(file);
41
- file.on('finish', function () {
42
- file.close();
43
- resolve(true);
44
- });
45
- file.on('error', function (error) {
46
- fs.unlink(localFilePath, function () {
47
- reject(error);
48
- });
49
- });
50
- }).on('error', function (error) {
51
- reject(error);
52
- });
53
- });
54
- };
18
+ var downloadRemoteZipFile = /*#__PURE__*/function () {
19
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
20
+ var res, dest;
21
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
22
+ while (1) {
23
+ switch (_context.prev = _context.next) {
24
+ case 0:
25
+ _context.next = 2;
26
+ return fetch(url);
27
+ case 2:
28
+ res = _context.sent;
29
+ dest = fs.createWriteStream(localFilePath);
30
+ res.body.pipe(dest);
31
+ return _context.abrupt("return", true);
32
+ case 6:
33
+ case "end":
34
+ return _context.stop();
35
+ }
36
+ }
37
+ }, _callee);
38
+ }));
39
+ return function downloadRemoteZipFile(_x) {
40
+ return _ref.apply(this, arguments);
41
+ };
42
+ }();
55
43
 
56
44
  // 解压文件
57
45
  var extractZip = function extractZip() {
@@ -65,93 +53,83 @@ var extractZip = function extractZip() {
65
53
  };
66
54
 
67
55
  // 获取主题
68
- var getThemeImpl = /*#__PURE__*/function () {
69
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(url) {
56
+ var getThemeFromNpm = /*#__PURE__*/function () {
57
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
70
58
  var domains, downRes, i;
71
- return _regeneratorRuntime().wrap(function _callee$(_context) {
59
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
72
60
  while (1) {
73
- switch (_context.prev = _context.next) {
61
+ switch (_context2.prev = _context2.next) {
74
62
  case 0:
75
63
  domains = ['fastly.jsdelivr.net', 'cdn.jsdelivr.net', 'gcore.jsdelivr.net', 'jsdelivr.codeqihan.com'];
76
64
  downRes = false;
77
- if (!url) {
78
- _context.next = 9;
79
- break;
80
- }
81
- _context.next = 5;
82
- return downloadRemoteZipFile({
83
- url: url
84
- });
85
- case 5:
86
- downRes = _context.sent;
87
- console.log('remote zip file download success!from https://dev.iwhalecloud.com ......');
88
- _context.next = 18;
89
- break;
90
- case 9:
91
65
  i = 0;
92
- case 10:
66
+ case 3:
93
67
  if (!(!downRes && i < 4)) {
94
- _context.next = 18;
68
+ _context2.next = 11;
95
69
  break;
96
70
  }
97
- _context.next = 13;
98
- return downloadRemoteZipFile({
99
- hostname: domains[i]
100
- });
101
- case 13:
102
- downRes = _context.sent;
71
+ _context2.next = 6;
72
+ return downloadRemoteZipFile("https://".concat(domains[i], "/npm/@lingxiteam/theme@latest/bin/default.zip"));
73
+ case 6:
74
+ downRes = _context2.sent;
103
75
  console.log("remote zip file download success\uFF01from ".concat(domains[i], "....."));
104
76
  i += 1;
105
- _context.next = 10;
77
+ _context2.next = 3;
106
78
  break;
107
- case 18:
79
+ case 11:
108
80
  if (downRes) {
109
81
  extractZip();
110
82
  }
111
- return _context.abrupt("return", downRes);
112
- case 20:
83
+ return _context2.abrupt("return", downRes);
84
+ case 13:
113
85
  case "end":
114
- return _context.stop();
86
+ return _context2.stop();
115
87
  }
116
88
  }
117
- }, _callee);
89
+ }, _callee2);
118
90
  }));
119
- return function getThemeImpl(_x) {
91
+ return function getThemeFromNpm() {
120
92
  return _ref2.apply(this, arguments);
121
93
  };
122
94
  }();
123
- var getTheme = /*#__PURE__*/function () {
124
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
125
- var url, res;
126
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
95
+ var getThemeFromPlat = /*#__PURE__*/function () {
96
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
97
+ var downRes;
98
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
127
99
  while (1) {
128
- switch (_context2.prev = _context2.next) {
100
+ switch (_context3.prev = _context3.next) {
129
101
  case 0:
130
- url = 'https://dev.iwhalecloud.com/portal/zcm-doc/file/download?filePath=document/book-275/doc/uploads/63433/ad4b0668-59d1-4535-8ab9-9633517f95b0/default.zip';
131
- _context2.prev = 1;
132
- _context2.next = 4;
133
- return getThemeImpl(url);
134
- case 4:
135
- res = _context2.sent;
136
- if (!res) {
137
- getThemeImpl();
138
- }
139
- _context2.next = 11;
102
+ _context3.prev = 0;
103
+ _context3.next = 3;
104
+ return downloadRemoteZipFile('http://172.21.72.205:18008/api/getLastPackageTheme?PROJECT_ID=lingxi');
105
+ case 3:
106
+ downRes = _context3.sent;
107
+ _context3.next = 11;
140
108
  break;
141
- case 8:
142
- _context2.prev = 8;
143
- _context2.t0 = _context2["catch"](1);
144
- console.error(_context2.t0);
109
+ case 6:
110
+ _context3.prev = 6;
111
+ _context3.t0 = _context3["catch"](0);
112
+ _context3.next = 10;
113
+ return getThemeFromNpm();
114
+ case 10:
115
+ downRes = _context3.sent;
145
116
  case 11:
117
+ if (downRes) {
118
+ extractZip();
119
+ }
120
+ case 12:
146
121
  case "end":
147
- return _context2.stop();
122
+ return _context3.stop();
148
123
  }
149
124
  }
150
- }, _callee2, null, [[1, 8]]);
125
+ }, _callee3, null, [[0, 6]]);
151
126
  }));
152
- return function getTheme() {
127
+ return function getThemeFromPlat() {
153
128
  return _ref3.apply(this, arguments);
154
129
  };
155
130
  }();
131
+ var getTheme = function getTheme() {
132
+ getThemeFromPlat();
133
+ };
156
134
  var _default = getTheme;
157
135
  exports.default = _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/assets",
3
- "version": "3.3.1-alpha.8",
3
+ "version": "3.3.1-alpha.9",
4
4
  "description": "灵犀低代码平台移动端 - 工具类",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",