UNPKG

@hsui/micro-app

Version:

Hundsun micro-app framework

102 lines 3.88 kB
import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime"; import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; import { concat, mergeWith } from 'lodash'; var rawPublicPath = window.__INJECTED_PUBLIC_PATH_BY_HUI_MICRO_APP__; export default function getAddOns(global) { var publicPath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '/'; var hasMountedOnce = false; return mergeWith({}, // engineFlag { beforeLoad: function beforeLoad() { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: global.__POWERED_BY_HUI_MICRO_APP__ = true; case 1: case "end": return _context.stop(); } }, _callee); }))(); }, beforeMount: function beforeMount() { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() { return _regeneratorRuntime().wrap(function _callee2$(_context2) { while (1) switch (_context2.prev = _context2.next) { case 0: global.__POWERED_BY_HUI_MICRO_APP__ = true; case 1: case "end": return _context2.stop(); } }, _callee2); }))(); }, beforeUnmount: function beforeUnmount() { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() { return _regeneratorRuntime().wrap(function _callee3$(_context3) { while (1) switch (_context3.prev = _context3.next) { case 0: delete global.__POWERED_BY_HUI_MICRO_APP__; case 1: case "end": return _context3.stop(); } }, _callee3); }))(); } }, // runtimePublicPath { beforeLoad: function beforeLoad() { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() { return _regeneratorRuntime().wrap(function _callee4$(_context4) { while (1) switch (_context4.prev = _context4.next) { case 0: global.__INJECTED_PUBLIC_PATH_BY_HUI_MICRO_APP__ = publicPath; case 1: case "end": return _context4.stop(); } }, _callee4); }))(); }, beforeMount: function beforeMount() { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() { return _regeneratorRuntime().wrap(function _callee5$(_context5) { while (1) switch (_context5.prev = _context5.next) { case 0: if (hasMountedOnce) { global.__INJECTED_PUBLIC_PATH_BY_HUI_MICRO_APP__ = publicPath; } case 1: case "end": return _context5.stop(); } }, _callee5); }))(); }, beforeUnmount: function beforeUnmount() { return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() { return _regeneratorRuntime().wrap(function _callee6$(_context6) { while (1) switch (_context6.prev = _context6.next) { case 0: if (rawPublicPath === undefined) { delete global.__INJECTED_PUBLIC_PATH_BY_HUI_MICRO_APP__; } else { global.__INJECTED_PUBLIC_PATH_BY_HUI_MICRO_APP__ = rawPublicPath; } hasMountedOnce = true; case 2: case "end": return _context6.stop(); } }, _callee6); }))(); } }, function (v1, v2) { return concat(v1 !== null && v1 !== void 0 ? v1 : [], v2 !== null && v2 !== void 0 ? v2 : []); }); }