@real-router/persistent-params-plugin 0.1.20 → 0.1.21
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/dist/cjs/index.js +1 -1
- package/package.json +2 -2
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var r=Symbol("persistent-params-plugin");function e(r){return"number"==typeof r?Number.isFinite(r):"string"==typeof r||"boolean"==typeof r}var t=/[\s#%&/=?\\]/,n=String.raw`Cannot contain: = & ? # % / \ or whitespace`;function o(r){if(t.test(r))throw new TypeError(`[@real-router/persistent-params-plugin] Invalid parameter name "${r}". ${n}`)}function a(r,t){if(null===t)throw new TypeError(`[@real-router/persistent-params-plugin] Parameter "${r}" cannot be null. Use undefined to remove the parameter from persistence.`);if(void 0!==t&&!e(t)){const e=Array.isArray(t)?"array":typeof t;throw new TypeError(`[@real-router/persistent-params-plugin] Parameter "${r}" must be a primitive value (string, number, or boolean), got ${e}. Objects and arrays are not supported in URL parameters.`)}}function s(r){const e={};for(const t in r)Object.hasOwn(r,t)&&(e[t]=r[t]);return e}exports.persistentParamsPluginFactory=function(t={}){if(null==(n=t)||!(Array.isArray(n)?n.every(r=>{if("string"!=typeof r||0===r.length)return!1;try{return o(r),!0}catch{return!1}}):"object"==typeof n&&Object.getPrototypeOf(n)===Object.prototype&&Object.entries(n).every(([r,t])=>{if("string"!=typeof r||0===r.length)return!1;try{o(r)}catch{return!1}return e(t)}))){let r;throw r=null===t?"null":Array.isArray(t)?"array with invalid items":typeof t,new TypeError(`[@real-router/persistent-params-plugin] Invalid params configuration. Expected array of non-empty strings or object with primitive values, got ${r}.`)}var n;return Array.isArray(t)&&0===t.length?()=>({}):Array.isArray(t)||0!==Object.keys(t).length?e=>{if(r in e)throw new Error("[@real-router/persistent-params-plugin] Plugin already initialized on this router. To reconfigure, first unsubscribe the existing plugin using the returned unsubscribe function.");let n;if(e[r]=!0,Array.isArray(t)){const r={};for(const e of t)r[e]=void 0;n=Object.freeze(r)}else n=Object.freeze({...t});const o=new Set(Array.isArray(t)?[...t]:Object.keys(t)),i=e.buildPath.bind(e),c=e.forwardState.bind(e),u=e.getRootPath();try{const{basePath:r,queryString:t}=function(r){const e=r.indexOf("?");return-1===e?{basePath:r,queryString:""}:0===e?{basePath:"",queryString:r.slice(1)}:{basePath:r.slice(0,e),queryString:r.slice(e+1)}}(u),n=(p=t,0===(l=[...o]).length?p:p+(p?"&":"")+l.join("&"));e.setRootPath(`${r}?${n}`)}catch(t){throw delete e[r],new Error(`[@real-router/persistent-params-plugin] Failed to update root path: ${t instanceof Error?t.message:String(t)}`,{cause:t})}var p,l;function f(r){const e=s(r),t=[];for(const r of Object.keys(e)){const n=e[r];void 0===n&&o.has(r)?t.push(r):a(r,n)}if(t.length>0){for(const r of t)o.delete(r);const r={...n};for(const e of t)delete r[e];n=Object.freeze(r)}return function(r,e){const t=s(e),n={};for(const e in r)Object.hasOwn(r,e)&&void 0!==r[e]&&(n[e]=r[e]);for(const r of Object.keys(t)){const e=t[r];void 0===e?delete n[r]:n[r]=e}return n}(n,e)}return e.buildPath=(r,e={})=>i(r,f(e)),e.forwardState=(r,e)=>{const t=c(r,e);return{...t,params:f(t.params)}},{onTransitionSuccess(r){try{const e={},t=[];let s=!1;for(const i of o){const o=r.params[i];Object.hasOwn(r.params,i)&&void 0!==o?(a(i,o),n[i]!==o&&(e[i]=o,s=!0)):Object.hasOwn(n,i)&&void 0!==n[i]&&(t.push(i),s=!0)}if(s){const r={...n,...e};for(const e of t)delete r[e];n=Object.freeze(r)}}catch(r){console.error("persistent-params-plugin","Error updating persistent params:",r)}},teardown(){try{e.buildPath=i,e.forwardState=c,e.setRootPath(u),delete e[r]}catch(r){console.error("persistent-params-plugin","Error during teardown:",r)}}}}:()=>({})};//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@real-router/persistent-params-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "Persist query parameters across route transitions",
|
|
6
6
|
"main": "./dist/cjs/index.js",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"homepage": "https://github.com/greydragon888/real-router",
|
|
44
44
|
"sideEffects": false,
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@real-router/core": "^0.
|
|
46
|
+
"@real-router/core": "^0.18.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"type-guards": "^0.1.10"
|