@plasmicapp/loader-edge
Advanced tools
Comparing version
@@ -24,3 +24,4 @@ 'use strict'; | ||
const expandVariation = variation => { | ||
return Object.keys(variation).map(key => `${DELIMITER}${key}=${variation[key]}`).join(''); | ||
return Object.keys(variation).filter(key => !key.startsWith('ext')) // remove external variations | ||
.sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map(key => `${DELIMITER}${key}=${variation[key]}`).join(''); | ||
}; | ||
@@ -54,3 +55,3 @@ | ||
const generateAllPaths = (path, splits) => { | ||
return generateAllSplitPaths(splits).map(meta => `${path}${path.endsWith('/') ? '' : '/'}${meta}`); | ||
return generateAllSplitPaths(splits.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0)).map(meta => `${path}${path.endsWith('/') ? '' : '/'}${meta}`); | ||
}; | ||
@@ -57,0 +58,0 @@ const getActiveSplits = async opts => { |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@plasmicapp/loader-fetcher"),t=require("@plasmicapp/loader-splits");const s=e=>Object.keys(e).map(t=>`__pm__${t}=${e[t]}`).join(""),i=(e,t)=>`${e}${e.endsWith("/")?"":"/"}${s(t)}`,r=e=>{if(0===e.length)return[""];const[i,...a]=e,p=r(a),l=["",...i.slices.map(e=>s({[t.getSplitKey(i)]:e.id}))],n=[];for(let e=0;e<l.length;e++)for(let t=0;t<p.length;t++)n.push(l[e]+p[t]);return n},a=async t=>{const s=new e.PlasmicModulesFetcher(t),i=await s.fetchAllData();return{splits:i.activeSplits,paths:i.components.filter(e=>e.isPage&&e.path).map(e=>e.path)}};exports.generateAllPaths=(e,t)=>r(t).map(t=>`${e}${e.endsWith("/")?"":"/"}${t}`),exports.getActiveSplits=a,exports.getMiddlewareResponse=async({opts:e,cookies:s,traits:r,url:p})=>{const{splits:l}=await a(e),n=[],o=t.getActiveVariation({splits:l,traits:r,getKnownValue:e=>s["plasmic:"+e],updateKnownValue:(e,t)=>{n.push({key:"plasmic:"+e,value:t})}});let c=p;return Object.keys(o).length&&(c=i(p,o)),{url:c,cookies:n}},exports.rewriteWithVariation=i,exports.rewriteWithoutVariation=e=>{const[t,...s]=e.split("__pm__");return{path:t,variation:s.reduce((e,t)=>{const[s,i]=t.split("=");return{...e,[s]:i}},{})}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@plasmicapp/loader-fetcher"),e=require("@plasmicapp/loader-splits");const s=t=>Object.keys(t).filter(t=>!t.startsWith("ext")).sort((t,e)=>t<e?-1:t>e?1:0).map(e=>`__pm__${e}=${t[e]}`).join(""),i=(t,e)=>`${t}${t.endsWith("/")?"":"/"}${s(e)}`,r=t=>{if(0===t.length)return[""];const[i,...a]=t,p=r(a),l=["",...i.slices.map(t=>s({[e.getSplitKey(i)]:t.id}))],o=[];for(let t=0;t<l.length;t++)for(let e=0;e<p.length;e++)o.push(l[t]+p[e]);return o},a=async e=>{const s=new t.PlasmicModulesFetcher(e),i=await s.fetchAllData();return{splits:i.activeSplits,paths:i.components.filter(t=>t.isPage&&t.path).map(t=>t.path)}};exports.generateAllPaths=(t,e)=>r(e.sort((t,e)=>t.id<e.id?-1:t.id>e.id?1:0)).map(e=>`${t}${t.endsWith("/")?"":"/"}${e}`),exports.getActiveSplits=a,exports.getMiddlewareResponse=async({opts:t,cookies:s,traits:r,url:p})=>{const{splits:l}=await a(t),o=[],n=e.getActiveVariation({splits:l,traits:r,getKnownValue:t=>s["plasmic:"+t],updateKnownValue:(t,e)=>{o.push({key:"plasmic:"+t,value:e})}});let c=p;return Object.keys(n).length&&(c=i(p,n)),{url:c,cookies:o}},exports.rewriteWithVariation=i,exports.rewriteWithoutVariation=t=>{const[e,...s]=t.split("__pm__");return{path:e,variation:s.reduce((t,e)=>{const[s,i]=e.split("=");return{...t,[s]:i}},{})}}; | ||
//# sourceMappingURL=loader-edge.cjs.production.min.js.map |
@@ -20,3 +20,4 @@ import { PlasmicModulesFetcher } from '@plasmicapp/loader-fetcher'; | ||
const expandVariation = variation => { | ||
return Object.keys(variation).map(key => `${DELIMITER}${key}=${variation[key]}`).join(''); | ||
return Object.keys(variation).filter(key => !key.startsWith('ext')) // remove external variations | ||
.sort((a, b) => a < b ? -1 : a > b ? 1 : 0).map(key => `${DELIMITER}${key}=${variation[key]}`).join(''); | ||
}; | ||
@@ -50,3 +51,3 @@ | ||
const generateAllPaths = (path, splits) => { | ||
return generateAllSplitPaths(splits).map(meta => `${path}${path.endsWith('/') ? '' : '/'}${meta}`); | ||
return generateAllSplitPaths(splits.sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0)).map(meta => `${path}${path.endsWith('/') ? '' : '/'}${meta}`); | ||
}; | ||
@@ -53,0 +54,0 @@ const getActiveSplits = async opts => { |
{ | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "MIT", | ||
@@ -56,3 +56,3 @@ "main": "dist/index.js", | ||
"@plasmicapp/loader-fetcher": "1.0.2", | ||
"@plasmicapp/loader-splits": "1.0.2" | ||
"@plasmicapp/loader-splits": "1.0.3" | ||
}, | ||
@@ -62,3 +62,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "67150233c7ade71ce1ff0f9d5a246821740a8e6f" | ||
"gitHead": "85308892b93b18d913f32ead0a92f7999741f245" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
29946
7.15%219
1.39%+ Added
+ Added
- Removed