1234567 |
- {
- "version": 3,
- "sources": ["../../../../../node_modules/pinia-plugin-persist-uni/dist/pinia-persist-uni.es.js"],
- "sourcesContent": ["var _a, _b;\nconst isH5 = typeof uni !== \"undefined\" ? [\"web\", \"h5\", void 0].includes((_b = (_a = uni == null ? void 0 : uni.getSystemInfoSync()) == null ? void 0 : _a.uniPlatform) == null ? void 0 : _b.toLocaleLowerCase()) : true;\nconst updateStorage = (strategy, store, options) => {\n const storage = strategy.storage;\n const storeKey = strategy.key || store.$id;\n const isCustomStorage = isH5 || (options == null ? void 0 : options.enforceCustomStorage);\n if (strategy.paths) {\n const partialState = strategy.paths.reduce((finalObj, key) => {\n finalObj[key] = store.$state[key];\n return finalObj;\n }, {});\n if (isCustomStorage && storage) {\n storage.setItem(storeKey, JSON.stringify(partialState));\n } else {\n uni.setStorage({ key: storeKey, data: JSON.stringify(partialState) });\n }\n } else if (isCustomStorage && storage) {\n storage.setItem(storeKey, JSON.stringify(store.$state));\n } else {\n uni.setStorage({ key: storeKey, data: JSON.stringify(store.$state) });\n }\n};\nvar index = ({ options, store }) => {\n var _a2, _b2, _c, _d, _e, _f;\n if ((_a2 = options.persist) == null ? void 0 : _a2.enabled) {\n const defaultStrat = [\n {\n key: store.$id,\n storage: ((_b2 = options.persist) == null ? void 0 : _b2.H5Storage) || (window == null ? void 0 : window.sessionStorage)\n }\n ];\n const strategies = ((_d = (_c = options.persist) == null ? void 0 : _c.strategies) == null ? void 0 : _d.length) ? (_e = options.persist) == null ? void 0 : _e.strategies : defaultStrat;\n strategies.forEach((strategy) => {\n var _a3, _b3;\n const storage = strategy.storage || ((_a3 = options.persist) == null ? void 0 : _a3.H5Storage) || (window == null ? void 0 : window.sessionStorage);\n const storeKey = strategy.key || store.$id;\n let storageResult;\n if (isH5 || ((_b3 = options.persist) == null ? void 0 : _b3.enforceCustomStorage)) {\n storageResult = storage.getItem(storeKey);\n } else {\n storageResult = uni.getStorageSync(storeKey);\n }\n if (storageResult) {\n store.$patch(JSON.parse(storageResult));\n updateStorage(strategy, store, options.persist);\n }\n });\n store.$subscribe(() => {\n strategies.forEach((strategy) => {\n updateStorage(strategy, store, options.persist);\n });\n }, { detached: ((_f = options.persist) == null ? void 0 : _f.detached) ? true : false });\n }\n};\nexport { index as default };\n"],
- "mappings": ";;;AAAA,IAAI;AAAJ,IAAQ;AACR,IAAM,OAAO,OAAO,QAAQ,cAAc,CAAC,OAAO,MAAM,MAAM,EAAE,UAAU,MAAM,KAAK,OAAO,OAAO,SAAS,IAAI,kBAAkB,MAAM,OAAO,SAAS,GAAG,gBAAgB,OAAO,SAAS,GAAG,kBAAkB,CAAC,IAAI;AACrN,IAAM,gBAAgB,CAAC,UAAU,OAAO,YAAY;AAClD,QAAM,UAAU,SAAS;AACzB,QAAM,WAAW,SAAS,OAAO,MAAM;AACvC,QAAM,kBAAkB,SAAS,WAAW,OAAO,SAAS,QAAQ;AACpE,MAAI,SAAS,OAAO;AAClB,UAAM,eAAe,SAAS,MAAM,OAAO,CAAC,UAAU,QAAQ;AAC5D,eAAS,GAAG,IAAI,MAAM,OAAO,GAAG;AAChC,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AACL,QAAI,mBAAmB,SAAS;AAC9B,cAAQ,QAAQ,UAAU,KAAK,UAAU,YAAY,CAAC;AAAA,IACxD,OAAO;AACL,UAAI,WAAW,EAAE,KAAK,UAAU,MAAM,KAAK,UAAU,YAAY,EAAE,CAAC;AAAA,IACtE;AAAA,EACF,WAAW,mBAAmB,SAAS;AACrC,YAAQ,QAAQ,UAAU,KAAK,UAAU,MAAM,MAAM,CAAC;AAAA,EACxD,OAAO;AACL,QAAI,WAAW,EAAE,KAAK,UAAU,MAAM,KAAK,UAAU,MAAM,MAAM,EAAE,CAAC;AAAA,EACtE;AACF;AACA,IAAI,QAAQ,CAAC,EAAE,SAAS,MAAM,MAAM;AAClC,MAAI,KAAK,KAAK,IAAI,IAAI,IAAI;AAC1B,OAAK,MAAM,QAAQ,YAAY,OAAO,SAAS,IAA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