3
0

pinia-plugin-persistedstate.js.map 13 KB

1234567
  1. {
  2. "version": 3,
  3. "sources": ["../../../../../node_modules/destr/dist/index.mjs", "../../../../../node_modules/deep-pick-omit/dist/index.mjs", "../../../../../node_modules/pinia-plugin-persistedstate/dist/index.js"],
  4. "sourcesContent": ["const suspectProtoRx = /\"(?:_|\\\\u0{2}5[Ff]){2}(?:p|\\\\u0{2}70)(?:r|\\\\u0{2}72)(?:o|\\\\u0{2}6[Ff])(?:t|\\\\u0{2}74)(?:o|\\\\u0{2}6[Ff])(?:_|\\\\u0{2}5[Ff]){2}\"\\s*:/;\nconst suspectConstructorRx = /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\nconst JsonSigRx = /^\\s*[\"[{]|^\\s*-?\\d{1,16}(\\.\\d{1,17})?([Ee][+-]?\\d+)?\\s*$/;\nfunction jsonParseTransform(key, value) {\n if (key === \"__proto__\" || key === \"constructor\" && value && typeof value === \"object\" && \"prototype\" in value) {\n warnKeyDropped(key);\n return;\n }\n return value;\n}\nfunction warnKeyDropped(key) {\n console.warn(`[destr] Dropping \"${key}\" key to prevent prototype pollution.`);\n}\nfunction destr(value, options = {}) {\n if (typeof value !== \"string\") {\n return value;\n }\n const _value = value.trim();\n if (\n // eslint-disable-next-line unicorn/prefer-at\n value[0] === '\"' && value.endsWith('\"') && !value.includes(\"\\\\\")\n ) {\n return _value.slice(1, -1);\n }\n if (_value.length <= 9) {\n const _lval = _value.toLowerCase();\n if (_lval === \"true\") {\n return true;\n }\n if (_lval === \"false\") {\n return false;\n }\n if (_lval === \"undefined\") {\n return void 0;\n }\n if (_lval === \"null\") {\n return null;\n }\n if (_lval === \"nan\") {\n return Number.NaN;\n }\n if (_lval === \"infinity\") {\n return Number.POSITIVE_INFINITY;\n }\n if (_lval === \"-infinity\") {\n return Number.NEGATIVE_INFINITY;\n }\n }\n if (!JsonSigRx.test(value)) {\n if (options.strict) {\n throw new SyntaxError(\"[destr] Invalid JSON\");\n }\n return value;\n }\n try {\n if (suspectProtoRx.test(value) || suspectConstructorRx.test(value)) {\n if (options.strict) {\n throw new Error(\"[destr] Possible prototype pollution\");\n }\n return JSON.parse(value, jsonParseTransform);\n }\n return JSON.parse(value);\n } catch (error) {\n if (options.strict) {\n throw error;\n }\n return value;\n }\n}\nfunction safeDestr(value, options = {}) {\n return destr(value, { ...options, strict: true });\n}\n\nexport { destr as default, destr, safeDestr };\n", "function get(obj, path) {\n if (obj == null)\n return void 0;\n let value = obj;\n for (let i = 0; i < path.length; i++) {\n if (value == null || value[path[i]] == null)\n return void 0;\n value = value[path[i]];\n }\n return value;\n}\nfunction set(obj, value, path) {\n if (path.length === 0)\n return value;\n const idx = path[0];\n if (path.length > 1) {\n value = set(\n typeof obj !== \"object\" || obj === null || !Object.prototype.hasOwnProperty.call(obj, idx) ? Number.isInteger(Number(path[1])) ? [] : {} : obj[idx],\n value,\n Array.prototype.slice.call(path, 1)\n );\n }\n if (Number.isInteger(Number(idx)) && Array.isArray(obj))\n return obj.slice()[idx];\n return Object.assign({}, obj, { [idx]: value });\n}\nfunction unset(obj, path) {\n if (obj == null || path.length === 0)\n return obj;\n if (path.length === 1) {\n if (obj == null)\n return obj;\n if (Number.isInteger(path[0]) && Array.isArray(obj))\n return Array.prototype.slice.call(obj, 0).splice(path[0], 1);\n const result = {};\n for (const p in obj)\n result[p] = obj[p];\n delete result[path[0]];\n return result;\n }\n if (obj[path[0]] == null) {\n if (Number.isInteger(path[0]) && Array.isArray(obj))\n return Array.prototype.concat.call([], obj);\n const result = {};\n for (const p in obj)\n result[p] = obj[p];\n return result;\n }\n return set(\n obj,\n unset(\n obj[path[0]],\n Array.prototype.slice.call(path, 1)\n ),\n [path[0]]\n );\n}\n\nfunction deepPickUnsafe(obj, paths) {\n return paths.map((p) => p.split(\".\")).map((p) => [p, get(obj, p)]).filter((t) => t[1] !== void 0).reduce((acc, cur) => set(acc, cur[1], cur[0]), {});\n}\nfunction deepPick(obj, paths) {\n return deepPickUnsafe(obj, paths);\n}\nfunction deepOmitUnsafe(obj, paths) {\n return paths.map((p) => p.split(\".\")).reduce((acc, cur) => unset(acc, cur), obj);\n}\nfunction deepOmit(obj, paths) {\n return deepOmitUnsafe(obj, paths);\n}\n\nexport { deepOmit, deepOmitUnsafe, deepPick, deepPickUnsafe };\n", "// src/index.ts\nimport { destr } from \"destr\";\n\n// src/runtime/core.ts\nimport { deepOmitUnsafe, deepPickUnsafe } from \"deep-pick-omit\";\nfunction hydrateStore(store, {\n storage,\n serializer,\n key,\n debug,\n pick,\n omit,\n beforeHydrate,\n afterHydrate\n}, context, runHooks = true) {\n try {\n if (runHooks)\n beforeHydrate?.(context);\n const fromStorage = storage.getItem(key);\n if (fromStorage) {\n const deserialized = serializer.deserialize(fromStorage);\n const picked = pick ? deepPickUnsafe(deserialized, pick) : deserialized;\n const omitted = omit ? deepOmitUnsafe(picked, omit) : picked;\n store.$patch(omitted);\n }\n if (runHooks)\n afterHydrate?.(context);\n } catch (error) {\n if (debug)\n console.error(\"[pinia-plugin-persistedstate]\", error);\n }\n}\nfunction persistState(state, {\n storage,\n serializer,\n key,\n debug,\n pick,\n omit\n}) {\n try {\n const picked = pick ? deepPickUnsafe(state, pick) : state;\n const omitted = omit ? deepOmitUnsafe(picked, omit) : picked;\n const toStorage = serializer.serialize(omitted);\n storage.setItem(key, toStorage);\n } catch (error) {\n if (debug)\n console.error(\"[pinia-plugin-persistedstate]\", error);\n }\n}\nfunction createPersistence(context, optionsParser, auto) {\n const { pinia, store, options: { persist = auto } } = context;\n if (!persist)\n return;\n if (!(store.$id in pinia.state.value)) {\n const originalStore = pinia._s.get(store.$id.replace(\"__hot:\", \"\"));\n if (originalStore)\n Promise.resolve().then(() => originalStore.$persist());\n return;\n }\n const persistenceOptions = Array.isArray(persist) ? persist : persist === true ? [{}] : [persist];\n const persistences = persistenceOptions.map(optionsParser);\n store.$hydrate = ({ runHooks = true } = {}) => {\n persistences.forEach((p) => {\n hydrateStore(store, p, context, runHooks);\n });\n };\n store.$persist = () => {\n persistences.forEach((p) => {\n persistState(store.$state, p);\n });\n };\n persistences.forEach((p) => {\n hydrateStore(store, p, context);\n store.$subscribe(\n (_mutation, state) => persistState(state, p),\n { detached: true }\n );\n });\n}\n\n// src/index.ts\nfunction createPersistedState(options = {}) {\n return function(context) {\n createPersistence(\n context,\n (p) => ({\n key: (options.key ? options.key : (x) => x)(p.key ?? context.store.$id),\n debug: p.debug ?? options.debug ?? false,\n serializer: p.serializer ?? options.serializer ?? {\n serialize: (data) => JSON.stringify(data),\n deserialize: (data) => destr(data)\n },\n storage: p.storage ?? options.storage ?? window.localStorage,\n beforeHydrate: p.beforeHydrate,\n afterHydrate: p.afterHydrate,\n pick: p.pick,\n omit: p.omit\n }),\n options.auto ?? false\n );\n };\n}\nvar src_default = createPersistedState();\nexport {\n createPersistedState,\n src_default as default\n};\n"],
  5. "mappings": ";AAAA,IAAM,iBAAiB;AACvB,IAAM,uBAAuB;AAC7B,IAAM,YAAY;AAClB,SAAS,mBAAmB,KAAK,OAAO;AACtC,MAAI,QAAQ,eAAe,QAAQ,iBAAiB,SAAS,OAAO,UAAU,YAAY,eAAe,OAAO;AAC9G,mBAAe,GAAG;AAClB;AAAA,EACF;AACA,SAAO;AACT;AACA,SAAS,eAAe,KAAK;AAC3B,UAAQ,KAAK,qBAAqB,GAAG,uCAAuC;AAC9E;AACA,SAAS,MAAM,OAAO,UAAU,CAAC,GAAG;AAClC,MAAI,OAAO,UAAU,UAAU;AAC7B,WAAO;AAAA,EACT;AACA,QAAM,SAAS,MAAM,KAAK;AAC1B;AAAA;AAAA,IAEE,MAAM,CAAC,MAAM,OAAO,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,SAAS,IAAI;AAAA,IAC/D;AACA,W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