Node-Red configuration
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

vuex.esm-browser.js 42KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484
  1. /*!
  2. * vuex v4.1.0
  3. * (c) 2022 Evan You
  4. * @license MIT
  5. */
  6. import { inject, effectScope, reactive, watch, computed } from 'vue';
  7. import { setupDevtoolsPlugin } from '@vue/devtools-api';
  8. var storeKey = 'store';
  9. function useStore (key) {
  10. if ( key === void 0 ) key = null;
  11. return inject(key !== null ? key : storeKey)
  12. }
  13. /**
  14. * Get the first item that pass the test
  15. * by second argument function
  16. *
  17. * @param {Array} list
  18. * @param {Function} f
  19. * @return {*}
  20. */
  21. function find (list, f) {
  22. return list.filter(f)[0]
  23. }
  24. /**
  25. * Deep copy the given object considering circular structure.
  26. * This function caches all nested objects and its copies.
  27. * If it detects circular structure, use cached copy to avoid infinite loop.
  28. *
  29. * @param {*} obj
  30. * @param {Array<Object>} cache
  31. * @return {*}
  32. */
  33. function deepCopy (obj, cache) {
  34. if ( cache === void 0 ) cache = [];
  35. // just return if obj is immutable value
  36. if (obj === null || typeof obj !== 'object') {
  37. return obj
  38. }
  39. // if obj is hit, it is in circular structure
  40. var hit = find(cache, function (c) { return c.original === obj; });
  41. if (hit) {
  42. return hit.copy
  43. }
  44. var copy = Array.isArray(obj) ? [] : {};
  45. // put the copy into cache at first
  46. // because we want to refer it in recursive deepCopy
  47. cache.push({
  48. original: obj,
  49. copy: copy
  50. });
  51. Object.keys(obj).forEach(function (key) {
  52. copy[key] = deepCopy(obj[key], cache);
  53. });
  54. return copy
  55. }
  56. /**
  57. * forEach for object
  58. */
  59. function forEachValue (obj, fn) {
  60. Object.keys(obj).forEach(function (key) { return fn(obj[key], key); });
  61. }
  62. function isObject (obj) {
  63. return obj !== null && typeof obj === 'object'
  64. }
  65. function isPromise (val) {
  66. return val && typeof val.then === 'function'
  67. }
  68. function assert (condition, msg) {
  69. if (!condition) { throw new Error(("[vuex] " + msg)) }
  70. }
  71. function partial (fn, arg) {
  72. return function () {
  73. return fn(arg)
  74. }
  75. }
  76. function genericSubscribe (fn, subs, options) {
  77. if (subs.indexOf(fn) < 0) {
  78. options && options.prepend
  79. ? subs.unshift(fn)
  80. : subs.push(fn);
  81. }
  82. return function () {
  83. var i = subs.indexOf(fn);
  84. if (i > -1) {
  85. subs.splice(i, 1);
  86. }
  87. }
  88. }
  89. function resetStore (store, hot) {
  90. store._actions = Object.create(null);
  91. store._mutations = Object.create(null);
  92. store._wrappedGetters = Object.create(null);
  93. store._modulesNamespaceMap = Object.create(null);
  94. var state = store.state;
  95. // init all modules
  96. installModule(store, state, [], store._modules.root, true);
  97. // reset state
  98. resetStoreState(store, state, hot);
  99. }
  100. function resetStoreState (store, state, hot) {
  101. var oldState = store._state;
  102. var oldScope = store._scope;
  103. // bind store public getters
  104. store.getters = {};
  105. // reset local getters cache
  106. store._makeLocalGettersCache = Object.create(null);
  107. var wrappedGetters = store._wrappedGetters;
  108. var computedObj = {};
  109. var computedCache = {};
  110. // create a new effect scope and create computed object inside it to avoid
  111. // getters (computed) getting destroyed on component unmount.
  112. var scope = effectScope(true);
  113. scope.run(function () {
  114. forEachValue(wrappedGetters, function (fn, key) {
  115. // use computed to leverage its lazy-caching mechanism
  116. // direct inline function use will lead to closure preserving oldState.
  117. // using partial to return function with only arguments preserved in closure environment.
  118. computedObj[key] = partial(fn, store);
  119. computedCache[key] = computed(function () { return computedObj[key](); });
  120. Object.defineProperty(store.getters, key, {
  121. get: function () { return computedCache[key].value; },
  122. enumerable: true // for local getters
  123. });
  124. });
  125. });
  126. store._state = reactive({
  127. data: state
  128. });
  129. // register the newly created effect scope to the store so that we can
  130. // dispose the effects when this method runs again in the future.
  131. store._scope = scope;
  132. // enable strict mode for new state
  133. if (store.strict) {
  134. enableStrictMode(store);
  135. }
  136. if (oldState) {
  137. if (hot) {
  138. // dispatch changes in all subscribed watchers
  139. // to force getter re-evaluation for hot reloading.
  140. store._withCommit(function () {
  141. oldState.data = null;
  142. });
  143. }
  144. }
  145. // dispose previously registered effect scope if there is one.
  146. if (oldScope) {
  147. oldScope.stop();
  148. }
  149. }
  150. function installModule (store, rootState, path, module, hot) {
  151. var isRoot = !path.length;
  152. var namespace = store._modules.getNamespace(path);
  153. // register in namespace map
  154. if (module.namespaced) {
  155. if (store._modulesNamespaceMap[namespace] && true) {
  156. console.error(("[vuex] duplicate namespace " + namespace + " for the namespaced module " + (path.join('/'))));
  157. }
  158. store._modulesNamespaceMap[namespace] = module;
  159. }
  160. // set state
  161. if (!isRoot && !hot) {
  162. var parentState = getNestedState(rootState, path.slice(0, -1));
  163. var moduleName = path[path.length - 1];
  164. store._withCommit(function () {
  165. {
  166. if (moduleName in parentState) {
  167. console.warn(
  168. ("[vuex] state field \"" + moduleName + "\" was overridden by a module with the same name at \"" + (path.join('.')) + "\"")
  169. );
  170. }
  171. }
  172. parentState[moduleName] = module.state;
  173. });
  174. }
  175. var local = module.context = makeLocalContext(store, namespace, path);
  176. module.forEachMutation(function (mutation, key) {
  177. var namespacedType = namespace + key;
  178. registerMutation(store, namespacedType, mutation, local);
  179. });
  180. module.forEachAction(function (action, key) {
  181. var type = action.root ? key : namespace + key;
  182. var handler = action.handler || action;
  183. registerAction(store, type, handler, local);
  184. });
  185. module.forEachGetter(function (getter, key) {
  186. var namespacedType = namespace + key;
  187. registerGetter(store, namespacedType, getter, local);
  188. });
  189. module.forEachChild(function (child, key) {
  190. installModule(store, rootState, path.concat(key), child, hot);
  191. });
  192. }
  193. /**
  194. * make localized dispatch, commit, getters and state
  195. * if there is no namespace, just use root ones
  196. */
  197. function makeLocalContext (store, namespace, path) {
  198. var noNamespace = namespace === '';
  199. var local = {
  200. dispatch: noNamespace ? store.dispatch : function (_type, _payload, _options) {
  201. var args = unifyObjectStyle(_type, _payload, _options);
  202. var payload = args.payload;
  203. var options = args.options;
  204. var type = args.type;
  205. if (!options || !options.root) {
  206. type = namespace + type;
  207. if (!store._actions[type]) {
  208. console.error(("[vuex] unknown local action type: " + (args.type) + ", global type: " + type));
  209. return
  210. }
  211. }
  212. return store.dispatch(type, payload)
  213. },
  214. commit: noNamespace ? store.commit : function (_type, _payload, _options) {
  215. var args = unifyObjectStyle(_type, _payload, _options);
  216. var payload = args.payload;
  217. var options = args.options;
  218. var type = args.type;
  219. if (!options || !options.root) {
  220. type = namespace + type;
  221. if (!store._mutations[type]) {
  222. console.error(("[vuex] unknown local mutation type: " + (args.type) + ", global type: " + type));
  223. return
  224. }
  225. }
  226. store.commit(type, payload, options);
  227. }
  228. };
  229. // getters and state object must be gotten lazily
  230. // because they will be changed by state update
  231. Object.defineProperties(local, {
  232. getters: {
  233. get: noNamespace
  234. ? function () { return store.getters; }
  235. : function () { return makeLocalGetters(store, namespace); }
  236. },
  237. state: {
  238. get: function () { return getNestedState(store.state, path); }
  239. }
  240. });
  241. return local
  242. }
  243. function makeLocalGetters (store, namespace) {
  244. if (!store._makeLocalGettersCache[namespace]) {
  245. var gettersProxy = {};
  246. var splitPos = namespace.length;
  247. Object.keys(store.getters).forEach(function (type) {
  248. // skip if the target getter is not match this namespace
  249. if (type.slice(0, splitPos) !== namespace) { return }
  250. // extract local getter type
  251. var localType = type.slice(splitPos);
  252. // Add a port to the getters proxy.
  253. // Define as getter property because
  254. // we do not want to evaluate the getters in this time.
  255. Object.defineProperty(gettersProxy, localType, {
  256. get: function () { return store.getters[type]; },
  257. enumerable: true
  258. });
  259. });
  260. store._makeLocalGettersCache[namespace] = gettersProxy;
  261. }
  262. return store._makeLocalGettersCache[namespace]
  263. }
  264. function registerMutation (store, type, handler, local) {
  265. var entry = store._mutations[type] || (store._mutations[type] = []);
  266. entry.push(function wrappedMutationHandler (payload) {
  267. handler.call(store, local.state, payload);
  268. });
  269. }
  270. function registerAction (store, type, handler, local) {
  271. var entry = store._actions[type] || (store._actions[type] = []);
  272. entry.push(function wrappedActionHandler (payload) {
  273. var res = handler.call(store, {
  274. dispatch: local.dispatch,
  275. commit: local.commit,
  276. getters: local.getters,
  277. state: local.state,
  278. rootGetters: store.getters,
  279. rootState: store.state
  280. }, payload);
  281. if (!isPromise(res)) {
  282. res = Promise.resolve(res);
  283. }
  284. if (store._devtoolHook) {
  285. return res.catch(function (err) {
  286. store._devtoolHook.emit('vuex:error', err);
  287. throw err
  288. })
  289. } else {
  290. return res
  291. }
  292. });
  293. }
  294. function registerGetter (store, type, rawGetter, local) {
  295. if (store._wrappedGetters[type]) {
  296. {
  297. console.error(("[vuex] duplicate getter key: " + type));
  298. }
  299. return
  300. }
  301. store._wrappedGetters[type] = function wrappedGetter (store) {
  302. return rawGetter(
  303. local.state, // local state
  304. local.getters, // local getters
  305. store.state, // root state
  306. store.getters // root getters
  307. )
  308. };
  309. }
  310. function enableStrictMode (store) {
  311. watch(function () { return store._state.data; }, function () {
  312. {
  313. assert(store._committing, "do not mutate vuex store state outside mutation handlers.");
  314. }
  315. }, { deep: true, flush: 'sync' });
  316. }
  317. function getNestedState (state, path) {
  318. return path.reduce(function (state, key) { return state[key]; }, state)
  319. }
  320. function unifyObjectStyle (type, payload, options) {
  321. if (isObject(type) && type.type) {
  322. options = payload;
  323. payload = type;
  324. type = type.type;
  325. }
  326. {
  327. assert(typeof type === 'string', ("expects string as the type, but found " + (typeof type) + "."));
  328. }
  329. return { type: type, payload: payload, options: options }
  330. }
  331. var LABEL_VUEX_BINDINGS = 'vuex bindings';
  332. var MUTATIONS_LAYER_ID = 'vuex:mutations';
  333. var ACTIONS_LAYER_ID = 'vuex:actions';
  334. var INSPECTOR_ID = 'vuex';
  335. var actionId = 0;
  336. function addDevtools (app, store) {
  337. setupDevtoolsPlugin(
  338. {
  339. id: 'org.vuejs.vuex',
  340. app: app,
  341. label: 'Vuex',
  342. homepage: 'https://next.vuex.vuejs.org/',
  343. logo: 'https://vuejs.org/images/icons/favicon-96x96.png',
  344. packageName: 'vuex',
  345. componentStateTypes: [LABEL_VUEX_BINDINGS]
  346. },
  347. function (api) {
  348. api.addTimelineLayer({
  349. id: MUTATIONS_LAYER_ID,
  350. label: 'Vuex Mutations',
  351. color: COLOR_LIME_500
  352. });
  353. api.addTimelineLayer({
  354. id: ACTIONS_LAYER_ID,
  355. label: 'Vuex Actions',
  356. color: COLOR_LIME_500
  357. });
  358. api.addInspector({
  359. id: INSPECTOR_ID,
  360. label: 'Vuex',
  361. icon: 'storage',
  362. treeFilterPlaceholder: 'Filter stores...'
  363. });
  364. api.on.getInspectorTree(function (payload) {
  365. if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
  366. if (payload.filter) {
  367. var nodes = [];
  368. flattenStoreForInspectorTree(nodes, store._modules.root, payload.filter, '');
  369. payload.rootNodes = nodes;
  370. } else {
  371. payload.rootNodes = [
  372. formatStoreForInspectorTree(store._modules.root, '')
  373. ];
  374. }
  375. }
  376. });
  377. api.on.getInspectorState(function (payload) {
  378. if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
  379. var modulePath = payload.nodeId;
  380. makeLocalGetters(store, modulePath);
  381. payload.state = formatStoreForInspectorState(
  382. getStoreModule(store._modules, modulePath),
  383. modulePath === 'root' ? store.getters : store._makeLocalGettersCache,
  384. modulePath
  385. );
  386. }
  387. });
  388. api.on.editInspectorState(function (payload) {
  389. if (payload.app === app && payload.inspectorId === INSPECTOR_ID) {
  390. var modulePath = payload.nodeId;
  391. var path = payload.path;
  392. if (modulePath !== 'root') {
  393. path = modulePath.split('/').filter(Boolean).concat( path);
  394. }
  395. store._withCommit(function () {
  396. payload.set(store._state.data, path, payload.state.value);
  397. });
  398. }
  399. });
  400. store.subscribe(function (mutation, state) {
  401. var data = {};
  402. if (mutation.payload) {
  403. data.payload = mutation.payload;
  404. }
  405. data.state = state;
  406. api.notifyComponentUpdate();
  407. api.sendInspectorTree(INSPECTOR_ID);
  408. api.sendInspectorState(INSPECTOR_ID);
  409. api.addTimelineEvent({
  410. layerId: MUTATIONS_LAYER_ID,
  411. event: {
  412. time: Date.now(),
  413. title: mutation.type,
  414. data: data
  415. }
  416. });
  417. });
  418. store.subscribeAction({
  419. before: function (action, state) {
  420. var data = {};
  421. if (action.payload) {
  422. data.payload = action.payload;
  423. }
  424. action._id = actionId++;
  425. action._time = Date.now();
  426. data.state = state;
  427. api.addTimelineEvent({
  428. layerId: ACTIONS_LAYER_ID,
  429. event: {
  430. time: action._time,
  431. title: action.type,
  432. groupId: action._id,
  433. subtitle: 'start',
  434. data: data
  435. }
  436. });
  437. },
  438. after: function (action, state) {
  439. var data = {};
  440. var duration = Date.now() - action._time;
  441. data.duration = {
  442. _custom: {
  443. type: 'duration',
  444. display: (duration + "ms"),
  445. tooltip: 'Action duration',
  446. value: duration
  447. }
  448. };
  449. if (action.payload) {
  450. data.payload = action.payload;
  451. }
  452. data.state = state;
  453. api.addTimelineEvent({
  454. layerId: ACTIONS_LAYER_ID,
  455. event: {
  456. time: Date.now(),
  457. title: action.type,
  458. groupId: action._id,
  459. subtitle: 'end',
  460. data: data
  461. }
  462. });
  463. }
  464. });
  465. }
  466. );
  467. }
  468. // extracted from tailwind palette
  469. var COLOR_LIME_500 = 0x84cc16;
  470. var COLOR_DARK = 0x666666;
  471. var COLOR_WHITE = 0xffffff;
  472. var TAG_NAMESPACED = {
  473. label: 'namespaced',
  474. textColor: COLOR_WHITE,
  475. backgroundColor: COLOR_DARK
  476. };
  477. /**
  478. * @param {string} path
  479. */
  480. function extractNameFromPath (path) {
  481. return path && path !== 'root' ? path.split('/').slice(-2, -1)[0] : 'Root'
  482. }
  483. /**
  484. * @param {*} module
  485. * @return {import('@vue/devtools-api').CustomInspectorNode}
  486. */
  487. function formatStoreForInspectorTree (module, path) {
  488. return {
  489. id: path || 'root',
  490. // all modules end with a `/`, we want the last segment only
  491. // cart/ -> cart
  492. // nested/cart/ -> cart
  493. label: extractNameFromPath(path),
  494. tags: module.namespaced ? [TAG_NAMESPACED] : [],
  495. children: Object.keys(module._children).map(function (moduleName) { return formatStoreForInspectorTree(
  496. module._children[moduleName],
  497. path + moduleName + '/'
  498. ); }
  499. )
  500. }
  501. }
  502. /**
  503. * @param {import('@vue/devtools-api').CustomInspectorNode[]} result
  504. * @param {*} module
  505. * @param {string} filter
  506. * @param {string} path
  507. */
  508. function flattenStoreForInspectorTree (result, module, filter, path) {
  509. if (path.includes(filter)) {
  510. result.push({
  511. id: path || 'root',
  512. label: path.endsWith('/') ? path.slice(0, path.length - 1) : path || 'Root',
  513. tags: module.namespaced ? [TAG_NAMESPACED] : []
  514. });
  515. }
  516. Object.keys(module._children).forEach(function (moduleName) {
  517. flattenStoreForInspectorTree(result, module._children[moduleName], filter, path + moduleName + '/');
  518. });
  519. }
  520. /**
  521. * @param {*} module
  522. * @return {import('@vue/devtools-api').CustomInspectorState}
  523. */
  524. function formatStoreForInspectorState (module, getters, path) {
  525. getters = path === 'root' ? getters : getters[path];
  526. var gettersKeys = Object.keys(getters);
  527. var storeState = {
  528. state: Object.keys(module.state).map(function (key) { return ({
  529. key: key,
  530. editable: true,
  531. value: module.state[key]
  532. }); })
  533. };
  534. if (gettersKeys.length) {
  535. var tree = transformPathsToObjectTree(getters);
  536. storeState.getters = Object.keys(tree).map(function (key) { return ({
  537. key: key.endsWith('/') ? extractNameFromPath(key) : key,
  538. editable: false,
  539. value: canThrow(function () { return tree[key]; })
  540. }); });
  541. }
  542. return storeState
  543. }
  544. function transformPathsToObjectTree (getters) {
  545. var result = {};
  546. Object.keys(getters).forEach(function (key) {
  547. var path = key.split('/');
  548. if (path.length > 1) {
  549. var target = result;
  550. var leafKey = path.pop();
  551. path.forEach(function (p) {
  552. if (!target[p]) {
  553. target[p] = {
  554. _custom: {
  555. value: {},
  556. display: p,
  557. tooltip: 'Module',
  558. abstract: true
  559. }
  560. };
  561. }
  562. target = target[p]._custom.value;
  563. });
  564. target[leafKey] = canThrow(function () { return getters[key]; });
  565. } else {
  566. result[key] = canThrow(function () { return getters[key]; });
  567. }
  568. });
  569. return result
  570. }
  571. function getStoreModule (moduleMap, path) {
  572. var names = path.split('/').filter(function (n) { return n; });
  573. return names.reduce(
  574. function (module, moduleName, i) {
  575. var child = module[moduleName];
  576. if (!child) {
  577. throw new Error(("Missing module \"" + moduleName + "\" for path \"" + path + "\"."))
  578. }
  579. return i === names.length - 1 ? child : child._children
  580. },
  581. path === 'root' ? moduleMap : moduleMap.root._children
  582. )
  583. }
  584. function canThrow (cb) {
  585. try {
  586. return cb()
  587. } catch (e) {
  588. return e
  589. }
  590. }
  591. // Base data struct for store's module, package with some attribute and method
  592. var Module = function Module (rawModule, runtime) {
  593. this.runtime = runtime;
  594. // Store some children item
  595. this._children = Object.create(null);
  596. // Store the origin module object which passed by programmer
  597. this._rawModule = rawModule;
  598. var rawState = rawModule.state;
  599. // Store the origin module's state
  600. this.state = (typeof rawState === 'function' ? rawState() : rawState) || {};
  601. };
  602. var prototypeAccessors$1 = { namespaced: { configurable: true } };
  603. prototypeAccessors$1.namespaced.get = function () {
  604. return !!this._rawModule.namespaced
  605. };
  606. Module.prototype.addChild = function addChild (key, module) {
  607. this._children[key] = module;
  608. };
  609. Module.prototype.removeChild = function removeChild (key) {
  610. delete this._children[key];
  611. };
  612. Module.prototype.getChild = function getChild (key) {
  613. return this._children[key]
  614. };
  615. Module.prototype.hasChild = function hasChild (key) {
  616. return key in this._children
  617. };
  618. Module.prototype.update = function update (rawModule) {
  619. this._rawModule.namespaced = rawModule.namespaced;
  620. if (rawModule.actions) {
  621. this._rawModule.actions = rawModule.actions;
  622. }
  623. if (rawModule.mutations) {
  624. this._rawModule.mutations = rawModule.mutations;
  625. }
  626. if (rawModule.getters) {
  627. this._rawModule.getters = rawModule.getters;
  628. }
  629. };
  630. Module.prototype.forEachChild = function forEachChild (fn) {
  631. forEachValue(this._children, fn);
  632. };
  633. Module.prototype.forEachGetter = function forEachGetter (fn) {
  634. if (this._rawModule.getters) {
  635. forEachValue(this._rawModule.getters, fn);
  636. }
  637. };
  638. Module.prototype.forEachAction = function forEachAction (fn) {
  639. if (this._rawModule.actions) {
  640. forEachValue(this._rawModule.actions, fn);
  641. }
  642. };
  643. Module.prototype.forEachMutation = function forEachMutation (fn) {
  644. if (this._rawModule.mutations) {
  645. forEachValue(this._rawModule.mutations, fn);
  646. }
  647. };
  648. Object.defineProperties( Module.prototype, prototypeAccessors$1 );
  649. var ModuleCollection = function ModuleCollection (rawRootModule) {
  650. // register root module (Vuex.Store options)
  651. this.register([], rawRootModule, false);
  652. };
  653. ModuleCollection.prototype.get = function get (path) {
  654. return path.reduce(function (module, key) {
  655. return module.getChild(key)
  656. }, this.root)
  657. };
  658. ModuleCollection.prototype.getNamespace = function getNamespace (path) {
  659. var module = this.root;
  660. return path.reduce(function (namespace, key) {
  661. module = module.getChild(key);
  662. return namespace + (module.namespaced ? key + '/' : '')
  663. }, '')
  664. };
  665. ModuleCollection.prototype.update = function update$1 (rawRootModule) {
  666. update([], this.root, rawRootModule);
  667. };
  668. ModuleCollection.prototype.register = function register (path, rawModule, runtime) {
  669. var this$1$1 = this;
  670. if ( runtime === void 0 ) runtime = true;
  671. {
  672. assertRawModule(path, rawModule);
  673. }
  674. var newModule = new Module(rawModule, runtime);
  675. if (path.length === 0) {
  676. this.root = newModule;
  677. } else {
  678. var parent = this.get(path.slice(0, -1));
  679. parent.addChild(path[path.length - 1], newModule);
  680. }
  681. // register nested modules
  682. if (rawModule.modules) {
  683. forEachValue(rawModule.modules, function (rawChildModule, key) {
  684. this$1$1.register(path.concat(key), rawChildModule, runtime);
  685. });
  686. }
  687. };
  688. ModuleCollection.prototype.unregister = function unregister (path) {
  689. var parent = this.get(path.slice(0, -1));
  690. var key = path[path.length - 1];
  691. var child = parent.getChild(key);
  692. if (!child) {
  693. {
  694. console.warn(
  695. "[vuex] trying to unregister module '" + key + "', which is " +
  696. "not registered"
  697. );
  698. }
  699. return
  700. }
  701. if (!child.runtime) {
  702. return
  703. }
  704. parent.removeChild(key);
  705. };
  706. ModuleCollection.prototype.isRegistered = function isRegistered (path) {
  707. var parent = this.get(path.slice(0, -1));
  708. var key = path[path.length - 1];
  709. if (parent) {
  710. return parent.hasChild(key)
  711. }
  712. return false
  713. };
  714. function update (path, targetModule, newModule) {
  715. {
  716. assertRawModule(path, newModule);
  717. }
  718. // update target module
  719. targetModule.update(newModule);
  720. // update nested modules
  721. if (newModule.modules) {
  722. for (var key in newModule.modules) {
  723. if (!targetModule.getChild(key)) {
  724. {
  725. console.warn(
  726. "[vuex] trying to add a new module '" + key + "' on hot reloading, " +
  727. 'manual reload is needed'
  728. );
  729. }
  730. return
  731. }
  732. update(
  733. path.concat(key),
  734. targetModule.getChild(key),
  735. newModule.modules[key]
  736. );
  737. }
  738. }
  739. }
  740. var functionAssert = {
  741. assert: function (value) { return typeof value === 'function'; },
  742. expected: 'function'
  743. };
  744. var objectAssert = {
  745. assert: function (value) { return typeof value === 'function' ||
  746. (typeof value === 'object' && typeof value.handler === 'function'); },
  747. expected: 'function or object with "handler" function'
  748. };
  749. var assertTypes = {
  750. getters: functionAssert,
  751. mutations: functionAssert,
  752. actions: objectAssert
  753. };
  754. function assertRawModule (path, rawModule) {
  755. Object.keys(assertTypes).forEach(function (key) {
  756. if (!rawModule[key]) { return }
  757. var assertOptions = assertTypes[key];
  758. forEachValue(rawModule[key], function (value, type) {
  759. assert(
  760. assertOptions.assert(value),
  761. makeAssertionMessage(path, key, type, value, assertOptions.expected)
  762. );
  763. });
  764. });
  765. }
  766. function makeAssertionMessage (path, key, type, value, expected) {
  767. var buf = key + " should be " + expected + " but \"" + key + "." + type + "\"";
  768. if (path.length > 0) {
  769. buf += " in module \"" + (path.join('.')) + "\"";
  770. }
  771. buf += " is " + (JSON.stringify(value)) + ".";
  772. return buf
  773. }
  774. function createStore (options) {
  775. return new Store(options)
  776. }
  777. var Store = function Store (options) {
  778. var this$1$1 = this;
  779. if ( options === void 0 ) options = {};
  780. {
  781. assert(typeof Promise !== 'undefined', "vuex requires a Promise polyfill in this browser.");
  782. assert(this instanceof Store, "store must be called with the new operator.");
  783. }
  784. var plugins = options.plugins; if ( plugins === void 0 ) plugins = [];
  785. var strict = options.strict; if ( strict === void 0 ) strict = false;
  786. var devtools = options.devtools;
  787. // store internal state
  788. this._committing = false;
  789. this._actions = Object.create(null);
  790. this._actionSubscribers = [];
  791. this._mutations = Object.create(null);
  792. this._wrappedGetters = Object.create(null);
  793. this._modules = new ModuleCollection(options);
  794. this._modulesNamespaceMap = Object.create(null);
  795. this._subscribers = [];
  796. this._makeLocalGettersCache = Object.create(null);
  797. // EffectScope instance. when registering new getters, we wrap them inside
  798. // EffectScope so that getters (computed) would not be destroyed on
  799. // component unmount.
  800. this._scope = null;
  801. this._devtools = devtools;
  802. // bind commit and dispatch to self
  803. var store = this;
  804. var ref = this;
  805. var dispatch = ref.dispatch;
  806. var commit = ref.commit;
  807. this.dispatch = function boundDispatch (type, payload) {
  808. return dispatch.call(store, type, payload)
  809. };
  810. this.commit = function boundCommit (type, payload, options) {
  811. return commit.call(store, type, payload, options)
  812. };
  813. // strict mode
  814. this.strict = strict;
  815. var state = this._modules.root.state;
  816. // init root module.
  817. // this also recursively registers all sub-modules
  818. // and collects all module getters inside this._wrappedGetters
  819. installModule(this, state, [], this._modules.root);
  820. // initialize the store state, which is responsible for the reactivity
  821. // (also registers _wrappedGetters as computed properties)
  822. resetStoreState(this, state);
  823. // apply plugins
  824. plugins.forEach(function (plugin) { return plugin(this$1$1); });
  825. };
  826. var prototypeAccessors = { state: { configurable: true } };
  827. Store.prototype.install = function install (app, injectKey) {
  828. app.provide(injectKey || storeKey, this);
  829. app.config.globalProperties.$store = this;
  830. var useDevtools = this._devtools !== undefined
  831. ? this._devtools
  832. : true ;
  833. if (useDevtools) {
  834. addDevtools(app, this);
  835. }
  836. };
  837. prototypeAccessors.state.get = function () {
  838. return this._state.data
  839. };
  840. prototypeAccessors.state.set = function (v) {
  841. {
  842. assert(false, "use store.replaceState() to explicit replace store state.");
  843. }
  844. };
  845. Store.prototype.commit = function commit (_type, _payload, _options) {
  846. var this$1$1 = this;
  847. // check object-style commit
  848. var ref = unifyObjectStyle(_type, _payload, _options);
  849. var type = ref.type;
  850. var payload = ref.payload;
  851. var options = ref.options;
  852. var mutation = { type: type, payload: payload };
  853. var entry = this._mutations[type];
  854. if (!entry) {
  855. {
  856. console.error(("[vuex] unknown mutation type: " + type));
  857. }
  858. return
  859. }
  860. this._withCommit(function () {
  861. entry.forEach(function commitIterator (handler) {
  862. handler(payload);
  863. });
  864. });
  865. this._subscribers
  866. .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe
  867. .forEach(function (sub) { return sub(mutation, this$1$1.state); });
  868. if (
  869. options && options.silent
  870. ) {
  871. console.warn(
  872. "[vuex] mutation type: " + type + ". Silent option has been removed. " +
  873. 'Use the filter functionality in the vue-devtools'
  874. );
  875. }
  876. };
  877. Store.prototype.dispatch = function dispatch (_type, _payload) {
  878. var this$1$1 = this;
  879. // check object-style dispatch
  880. var ref = unifyObjectStyle(_type, _payload);
  881. var type = ref.type;
  882. var payload = ref.payload;
  883. var action = { type: type, payload: payload };
  884. var entry = this._actions[type];
  885. if (!entry) {
  886. {
  887. console.error(("[vuex] unknown action type: " + type));
  888. }
  889. return
  890. }
  891. try {
  892. this._actionSubscribers
  893. .slice() // shallow copy to prevent iterator invalidation if subscriber synchronously calls unsubscribe
  894. .filter(function (sub) { return sub.before; })
  895. .forEach(function (sub) { return sub.before(action, this$1$1.state); });
  896. } catch (e) {
  897. {
  898. console.warn("[vuex] error in before action subscribers: ");
  899. console.error(e);
  900. }
  901. }
  902. var result = entry.length > 1
  903. ? Promise.all(entry.map(function (handler) { return handler(payload); }))
  904. : entry[0](payload);
  905. return new Promise(function (resolve, reject) {
  906. result.then(function (res) {
  907. try {
  908. this$1$1._actionSubscribers
  909. .filter(function (sub) { return sub.after; })
  910. .forEach(function (sub) { return sub.after(action, this$1$1.state); });
  911. } catch (e) {
  912. {
  913. console.warn("[vuex] error in after action subscribers: ");
  914. console.error(e);
  915. }
  916. }
  917. resolve(res);
  918. }, function (error) {
  919. try {
  920. this$1$1._actionSubscribers
  921. .filter(function (sub) { return sub.error; })
  922. .forEach(function (sub) { return sub.error(action, this$1$1.state, error); });
  923. } catch (e) {
  924. {
  925. console.warn("[vuex] error in error action subscribers: ");
  926. console.error(e);
  927. }
  928. }
  929. reject(error);
  930. });
  931. })
  932. };
  933. Store.prototype.subscribe = function subscribe (fn, options) {
  934. return genericSubscribe(fn, this._subscribers, options)
  935. };
  936. Store.prototype.subscribeAction = function subscribeAction (fn, options) {
  937. var subs = typeof fn === 'function' ? { before: fn } : fn;
  938. return genericSubscribe(subs, this._actionSubscribers, options)
  939. };
  940. Store.prototype.watch = function watch$1 (getter, cb, options) {
  941. var this$1$1 = this;
  942. {
  943. assert(typeof getter === 'function', "store.watch only accepts a function.");
  944. }
  945. return watch(function () { return getter(this$1$1.state, this$1$1.getters); }, cb, Object.assign({}, options))
  946. };
  947. Store.prototype.replaceState = function replaceState (state) {
  948. var this$1$1 = this;
  949. this._withCommit(function () {
  950. this$1$1._state.data = state;
  951. });
  952. };
  953. Store.prototype.registerModule = function registerModule (path, rawModule, options) {
  954. if ( options === void 0 ) options = {};
  955. if (typeof path === 'string') { path = [path]; }
  956. {
  957. assert(Array.isArray(path), "module path must be a string or an Array.");
  958. assert(path.length > 0, 'cannot register the root module by using registerModule.');
  959. }
  960. this._modules.register(path, rawModule);
  961. installModule(this, this.state, path, this._modules.get(path), options.preserveState);
  962. // reset store to update getters...
  963. resetStoreState(this, this.state);
  964. };
  965. Store.prototype.unregisterModule = function unregisterModule (path) {
  966. var this$1$1 = this;
  967. if (typeof path === 'string') { path = [path]; }
  968. {
  969. assert(Array.isArray(path), "module path must be a string or an Array.");
  970. }
  971. this._modules.unregister(path);
  972. this._withCommit(function () {
  973. var parentState = getNestedState(this$1$1.state, path.slice(0, -1));
  974. delete parentState[path[path.length - 1]];
  975. });
  976. resetStore(this);
  977. };
  978. Store.prototype.hasModule = function hasModule (path) {
  979. if (typeof path === 'string') { path = [path]; }
  980. {
  981. assert(Array.isArray(path), "module path must be a string or an Array.");
  982. }
  983. return this._modules.isRegistered(path)
  984. };
  985. Store.prototype.hotUpdate = function hotUpdate (newOptions) {
  986. this._modules.update(newOptions);
  987. resetStore(this, true);
  988. };
  989. Store.prototype._withCommit = function _withCommit (fn) {
  990. var committing = this._committing;
  991. this._committing = true;
  992. fn();
  993. this._committing = committing;
  994. };
  995. Object.defineProperties( Store.prototype, prototypeAccessors );
  996. /**
  997. * Reduce the code which written in Vue.js for getting the state.
  998. * @param {String} [namespace] - Module's namespace
  999. * @param {Object|Array} states # Object's item can be a function which accept state and getters for param, you can do something for state and getters in it.
  1000. * @param {Object}
  1001. */
  1002. var mapState = normalizeNamespace(function (namespace, states) {
  1003. var res = {};
  1004. if (!isValidMap(states)) {
  1005. console.error('[vuex] mapState: mapper parameter must be either an Array or an Object');
  1006. }
  1007. normalizeMap(states).forEach(function (ref) {
  1008. var key = ref.key;
  1009. var val = ref.val;
  1010. res[key] = function mappedState () {
  1011. var state = this.$store.state;
  1012. var getters = this.$store.getters;
  1013. if (namespace) {
  1014. var module = getModuleByNamespace(this.$store, 'mapState', namespace);
  1015. if (!module) {
  1016. return
  1017. }
  1018. state = module.context.state;
  1019. getters = module.context.getters;
  1020. }
  1021. return typeof val === 'function'
  1022. ? val.call(this, state, getters)
  1023. : state[val]
  1024. };
  1025. // mark vuex getter for devtools
  1026. res[key].vuex = true;
  1027. });
  1028. return res
  1029. });
  1030. /**
  1031. * Reduce the code which written in Vue.js for committing the mutation
  1032. * @param {String} [namespace] - Module's namespace
  1033. * @param {Object|Array} mutations # Object's item can be a function which accept `commit` function as the first param, it can accept another params. You can commit mutation and do any other things in this function. specially, You need to pass anthor params from the mapped function.
  1034. * @return {Object}
  1035. */
  1036. var mapMutations = normalizeNamespace(function (namespace, mutations) {
  1037. var res = {};
  1038. if (!isValidMap(mutations)) {
  1039. console.error('[vuex] mapMutations: mapper parameter must be either an Array or an Object');
  1040. }
  1041. normalizeMap(mutations).forEach(function (ref) {
  1042. var key = ref.key;
  1043. var val = ref.val;
  1044. res[key] = function mappedMutation () {
  1045. var args = [], len = arguments.length;
  1046. while ( len-- ) args[ len ] = arguments[ len ];
  1047. // Get the commit method from store
  1048. var commit = this.$store.commit;
  1049. if (namespace) {
  1050. var module = getModuleByNamespace(this.$store, 'mapMutations', namespace);
  1051. if (!module) {
  1052. return
  1053. }
  1054. commit = module.context.commit;
  1055. }
  1056. return typeof val === 'function'
  1057. ? val.apply(this, [commit].concat(args))
  1058. : commit.apply(this.$store, [val].concat(args))
  1059. };
  1060. });
  1061. return res
  1062. });
  1063. /**
  1064. * Reduce the code which written in Vue.js for getting the getters
  1065. * @param {String} [namespace] - Module's namespace
  1066. * @param {Object|Array} getters
  1067. * @return {Object}
  1068. */
  1069. var mapGetters = normalizeNamespace(function (namespace, getters) {
  1070. var res = {};
  1071. if (!isValidMap(getters)) {
  1072. console.error('[vuex] mapGetters: mapper parameter must be either an Array or an Object');
  1073. }
  1074. normalizeMap(getters).forEach(function (ref) {
  1075. var key = ref.key;
  1076. var val = ref.val;
  1077. // The namespace has been mutated by normalizeNamespace
  1078. val = namespace + val;
  1079. res[key] = function mappedGetter () {
  1080. if (namespace && !getModuleByNamespace(this.$store, 'mapGetters', namespace)) {
  1081. return
  1082. }
  1083. if (!(val in this.$store.getters)) {
  1084. console.error(("[vuex] unknown getter: " + val));
  1085. return
  1086. }
  1087. return this.$store.getters[val]
  1088. };
  1089. // mark vuex getter for devtools
  1090. res[key].vuex = true;
  1091. });
  1092. return res
  1093. });
  1094. /**
  1095. * Reduce the code which written in Vue.js for dispatch the action
  1096. * @param {String} [namespace] - Module's namespace
  1097. * @param {Object|Array} actions # Object's item can be a function which accept `dispatch` function as the first param, it can accept anthor params. You can dispatch action and do any other things in this function. specially, You need to pass anthor params from the mapped function.
  1098. * @return {Object}
  1099. */
  1100. var mapActions = normalizeNamespace(function (namespace, actions) {
  1101. var res = {};
  1102. if (!isValidMap(actions)) {
  1103. console.error('[vuex] mapActions: mapper parameter must be either an Array or an Object');
  1104. }
  1105. normalizeMap(actions).forEach(function (ref) {
  1106. var key = ref.key;
  1107. var val = ref.val;
  1108. res[key] = function mappedAction () {
  1109. var args = [], len = arguments.length;
  1110. while ( len-- ) args[ len ] = arguments[ len ];
  1111. // get dispatch function from store
  1112. var dispatch = this.$store.dispatch;
  1113. if (namespace) {
  1114. var module = getModuleByNamespace(this.$store, 'mapActions', namespace);
  1115. if (!module) {
  1116. return
  1117. }
  1118. dispatch = module.context.dispatch;
  1119. }
  1120. return typeof val === 'function'
  1121. ? val.apply(this, [dispatch].concat(args))
  1122. : dispatch.apply(this.$store, [val].concat(args))
  1123. };
  1124. });
  1125. return res
  1126. });
  1127. /**
  1128. * Rebinding namespace param for mapXXX function in special scoped, and return them by simple object
  1129. * @param {String} namespace
  1130. * @return {Object}
  1131. */
  1132. var createNamespacedHelpers = function (namespace) { return ({
  1133. mapState: mapState.bind(null, namespace),
  1134. mapGetters: mapGetters.bind(null, namespace),
  1135. mapMutations: mapMutations.bind(null, namespace),
  1136. mapActions: mapActions.bind(null, namespace)
  1137. }); };
  1138. /**
  1139. * Normalize the map
  1140. * normalizeMap([1, 2, 3]) => [ { key: 1, val: 1 }, { key: 2, val: 2 }, { key: 3, val: 3 } ]
  1141. * normalizeMap({a: 1, b: 2, c: 3}) => [ { key: 'a', val: 1 }, { key: 'b', val: 2 }, { key: 'c', val: 3 } ]
  1142. * @param {Array|Object} map
  1143. * @return {Object}
  1144. */
  1145. function normalizeMap (map) {
  1146. if (!isValidMap(map)) {
  1147. return []
  1148. }
  1149. return Array.isArray(map)
  1150. ? map.map(function (key) { return ({ key: key, val: key }); })
  1151. : Object.keys(map).map(function (key) { return ({ key: key, val: map[key] }); })
  1152. }
  1153. /**
  1154. * Validate whether given map is valid or not
  1155. * @param {*} map
  1156. * @return {Boolean}
  1157. */
  1158. function isValidMap (map) {
  1159. return Array.isArray(map) || isObject(map)
  1160. }
  1161. /**
  1162. * Return a function expect two param contains namespace and map. it will normalize the namespace and then the param's function will handle the new namespace and the map.
  1163. * @param {Function} fn
  1164. * @return {Function}
  1165. */
  1166. function normalizeNamespace (fn) {
  1167. return function (namespace, map) {
  1168. if (typeof namespace !== 'string') {
  1169. map = namespace;
  1170. namespace = '';
  1171. } else if (namespace.charAt(namespace.length - 1) !== '/') {
  1172. namespace += '/';
  1173. }
  1174. return fn(namespace, map)
  1175. }
  1176. }
  1177. /**
  1178. * Search a special module from store by namespace. if module not exist, print error message.
  1179. * @param {Object} store
  1180. * @param {String} helper
  1181. * @param {String} namespace
  1182. * @return {Object}
  1183. */
  1184. function getModuleByNamespace (store, helper, namespace) {
  1185. var module = store._modulesNamespaceMap[namespace];
  1186. if (!module) {
  1187. console.error(("[vuex] module namespace not found in " + helper + "(): " + namespace));
  1188. }
  1189. return module
  1190. }
  1191. // Credits: borrowed code from fcomb/redux-logger
  1192. function createLogger (ref) {
  1193. if ( ref === void 0 ) ref = {};
  1194. var collapsed = ref.collapsed; if ( collapsed === void 0 ) collapsed = true;
  1195. var filter = ref.filter; if ( filter === void 0 ) filter = function (mutation, stateBefore, stateAfter) { return true; };
  1196. var transformer = ref.transformer; if ( transformer === void 0 ) transformer = function (state) { return state; };
  1197. var mutationTransformer = ref.mutationTransformer; if ( mutationTransformer === void 0 ) mutationTransformer = function (mut) { return mut; };
  1198. var actionFilter = ref.actionFilter; if ( actionFilter === void 0 ) actionFilter = function (action, state) { return true; };
  1199. var actionTransformer = ref.actionTransformer; if ( actionTransformer === void 0 ) actionTransformer = function (act) { return act; };
  1200. var logMutations = ref.logMutations; if ( logMutations === void 0 ) logMutations = true;
  1201. var logActions = ref.logActions; if ( logActions === void 0 ) logActions = true;
  1202. var logger = ref.logger; if ( logger === void 0 ) logger = console;
  1203. return function (store) {
  1204. var prevState = deepCopy(store.state);
  1205. if (typeof logger === 'undefined') {
  1206. return
  1207. }
  1208. if (logMutations) {
  1209. store.subscribe(function (mutation, state) {
  1210. var nextState = deepCopy(state);
  1211. if (filter(mutation, prevState, nextState)) {
  1212. var formattedTime = getFormattedTime();
  1213. var formattedMutation = mutationTransformer(mutation);
  1214. var message = "mutation " + (mutation.type) + formattedTime;
  1215. startMessage(logger, message, collapsed);
  1216. logger.log('%c prev state', 'color: #9E9E9E; font-weight: bold', transformer(prevState));
  1217. logger.log('%c mutation', 'color: #03A9F4; font-weight: bold', formattedMutation);
  1218. logger.log('%c next state', 'color: #4CAF50; font-weight: bold', transformer(nextState));
  1219. endMessage(logger);
  1220. }
  1221. prevState = nextState;
  1222. });
  1223. }
  1224. if (logActions) {
  1225. store.subscribeAction(function (action, state) {
  1226. if (actionFilter(action, state)) {
  1227. var formattedTime = getFormattedTime();
  1228. var formattedAction = actionTransformer(action);
  1229. var message = "action " + (action.type) + formattedTime;
  1230. startMessage(logger, message, collapsed);
  1231. logger.log('%c action', 'color: #03A9F4; font-weight: bold', formattedAction);
  1232. endMessage(logger);
  1233. }
  1234. });
  1235. }
  1236. }
  1237. }
  1238. function startMessage (logger, message, collapsed) {
  1239. var startMessage = collapsed
  1240. ? logger.groupCollapsed
  1241. : logger.group;
  1242. // render
  1243. try {
  1244. startMessage.call(logger, message);
  1245. } catch (e) {
  1246. logger.log(message);
  1247. }
  1248. }
  1249. function endMessage (logger) {
  1250. try {
  1251. logger.groupEnd();
  1252. } catch (e) {
  1253. logger.log('—— log end ——');
  1254. }
  1255. }
  1256. function getFormattedTime () {
  1257. var time = new Date();
  1258. return (" @ " + (pad(time.getHours(), 2)) + ":" + (pad(time.getMinutes(), 2)) + ":" + (pad(time.getSeconds(), 2)) + "." + (pad(time.getMilliseconds(), 3)))
  1259. }
  1260. function repeat (str, times) {
  1261. return (new Array(times + 1)).join(str)
  1262. }
  1263. function pad (num, maxLength) {
  1264. return repeat('0', maxLength - num.toString().length) + num
  1265. }
  1266. var index = {
  1267. version: '4.1.0',
  1268. Store: Store,
  1269. storeKey: storeKey,
  1270. createStore: createStore,
  1271. useStore: useStore,
  1272. mapState: mapState,
  1273. mapMutations: mapMutations,
  1274. mapGetters: mapGetters,
  1275. mapActions: mapActions,
  1276. createNamespacedHelpers: createNamespacedHelpers,
  1277. createLogger: createLogger
  1278. };
  1279. export default index;
  1280. export { Store, createLogger, createNamespacedHelpers, createStore, mapActions, mapGetters, mapMutations, mapState, storeKey, useStore };