@wix/metro-runtime
Advanced tools
Comparing version
@@ -21,2 +21,20 @@ "use strict"; | ||
} | ||
// Inflate a params object to a nested object { field.text ='foo' } => { field: { text: 'foo' } } | ||
function inflateParams(data) { | ||
const params = {}; | ||
Object.entries(data).forEach(([key, value]) => { | ||
let pathParams = params; | ||
const pathArray = key.split('.'); | ||
const lastPath = pathArray.pop(); | ||
pathArray.forEach(path => { | ||
if (!pathParams[path]) { | ||
pathParams[path] = {}; | ||
} | ||
pathParams = pathParams[path]; | ||
}); | ||
pathParams[lastPath] = value; | ||
}); | ||
return params; | ||
} | ||
function resolvePath(path, key) { | ||
@@ -27,2 +45,3 @@ return `${path}${path ? '.' : ''}${key}`; | ||
const flatten = flattenParams(params); | ||
const complexParams = {}; | ||
const searchParams = Object.entries(flatten).reduce((urlSearchParams, [key, value]) => { | ||
@@ -32,5 +51,12 @@ // inorder to make `foo: [1,2]` turn into `foo=1&foo=2` and not `foo[]=1&foo[]=2` | ||
keyParams.forEach(param => { | ||
if (param === undefined || param === null || Array.isArray(value) && typeof param === 'object') { | ||
if (param === undefined || param === null) { | ||
return; | ||
} | ||
if (Array.isArray(value) && typeof param === 'object') { | ||
complexParams[key] = value; | ||
return; | ||
} | ||
if (!Array.isArray(value)) { | ||
complexParams[key] = value; | ||
} | ||
urlSearchParams.append(key, param); | ||
@@ -43,3 +69,3 @@ }); | ||
if (isComplexRequest) { | ||
searchParams.append('.r', (0, _jsBase.encode)(JSON.stringify(params), true)); | ||
searchParams.append('.r', (0, _jsBase.encode)(JSON.stringify(inflateParams(complexParams)), true)); | ||
} | ||
@@ -46,0 +72,0 @@ return searchParams; |
@@ -18,2 +18,19 @@ import { encode } from 'js-base64'; | ||
} | ||
// Inflate a params object to a nested object { field.text ='foo' } => { field: { text: 'foo' } } | ||
function inflateParams(data) { | ||
const params = {}; | ||
Object.entries(data).forEach(([key, value]) => { | ||
let pathParams = params; | ||
const pathArray = key.split('.'); | ||
const lastPath = pathArray.pop(); | ||
pathArray.forEach((path) => { | ||
if (!pathParams[path]) { | ||
pathParams[path] = {}; | ||
} | ||
pathParams = pathParams[path]; | ||
}); | ||
pathParams[lastPath] = value; | ||
}); | ||
return params; | ||
} | ||
function resolvePath(path, key) { | ||
@@ -24,2 +41,3 @@ return `${path}${path ? '.' : ''}${key}`; | ||
const flatten = flattenParams(params); | ||
const complexParams = {}; | ||
const searchParams = Object.entries(flatten).reduce((urlSearchParams, [key, value]) => { | ||
@@ -29,7 +47,12 @@ // inorder to make `foo: [1,2]` turn into `foo=1&foo=2` and not `foo[]=1&foo[]=2` | ||
keyParams.forEach((param) => { | ||
if (param === undefined || | ||
param === null || | ||
(Array.isArray(value) && typeof param === 'object')) { | ||
if (param === undefined || param === null) { | ||
return; | ||
} | ||
if (Array.isArray(value) && typeof param === 'object') { | ||
complexParams[key] = value; | ||
return; | ||
} | ||
if (!Array.isArray(value)) { | ||
complexParams[key] = value; | ||
} | ||
urlSearchParams.append(key, param); | ||
@@ -41,3 +64,3 @@ }); | ||
if (isComplexRequest) { | ||
searchParams.append('.r', encode(JSON.stringify(params), true)); | ||
searchParams.append('.r', encode(JSON.stringify(inflateParams(complexParams)), true)); | ||
} | ||
@@ -44,0 +67,0 @@ return searchParams; |
{ | ||
"metro-runtime.js": "https://static.parastorage.com/services/metro-runtime/d39a370902170448c2bfe96c8241551cd18afb0a8e1136f5d5770fa3/metro-runtime.umd.js" | ||
"metro-runtime.js": "https://static.parastorage.com/services/metro-runtime/aaee1d8b2e21d55f4ba1b32b545bcff96bfbe885f3012c7f19041dfc/metro-runtime.umd.js" | ||
} |
{ | ||
"metro-runtime.js": "https://static.parastorage.com/services/metro-runtime/d39a370902170448c2bfe96c8241551cd18afb0a8e1136f5d5770fa3/metro-runtime.umd.min.js" | ||
"metro-runtime.js": "https://static.parastorage.com/services/metro-runtime/aaee1d8b2e21d55f4ba1b32b545bcff96bfbe885f3012c7f19041dfc/metro-runtime.umd.min.js" | ||
} |
@@ -373,5 +373,6 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
// Flatten a nested object to params object { field: { text: 'foo' } } => { field.text ='foo' } | ||
function flattenParams(data,path){if(path===void 0){path='';}const params={};Object.entries(data).forEach(_ref=>{let[key,value]=_ref;const isObject=value!==null&&typeof value==='object'&&!Array.isArray(value);const fieldPath=flatten_params_resolvePath(path,key);if(isObject){const serializedObject=flattenParams(value,fieldPath);Object.assign(params,serializedObject);}else{params[fieldPath]=value;}});return params;}function flatten_params_resolvePath(path,key){return`${path}${path?'.':''}${key}`;}function toURLSearchParams(params,isComplexRequest){const flatten=flattenParams(params);const searchParams=Object.entries(flatten).reduce((urlSearchParams,_ref2)=>{let[key,value]=_ref2;// inorder to make `foo: [1,2]` turn into `foo=1&foo=2` and not `foo[]=1&foo[]=2` | ||
const keyParams=Array.isArray(value)?value:[value];keyParams.forEach(param=>{if(param===undefined||param===null||Array.isArray(value)&&typeof param==='object'){return;}urlSearchParams.append(key,param);});return urlSearchParams;},new URLSearchParams());// https://github.com/wix-private/server-infra/tree/master/framework/grpc/rest#complex-requests-messages-with-get-mappings | ||
if(isComplexRequest){searchParams.append('.r',encode(JSON.stringify(params),true));}return searchParams;} | ||
function flattenParams(data,path){if(path===void 0){path='';}const params={};Object.entries(data).forEach(_ref=>{let[key,value]=_ref;const isObject=value!==null&&typeof value==='object'&&!Array.isArray(value);const fieldPath=flatten_params_resolvePath(path,key);if(isObject){const serializedObject=flattenParams(value,fieldPath);Object.assign(params,serializedObject);}else{params[fieldPath]=value;}});return params;}// Inflate a params object to a nested object { field.text ='foo' } => { field: { text: 'foo' } } | ||
function inflateParams(data){const params={};Object.entries(data).forEach(_ref2=>{let[key,value]=_ref2;let pathParams=params;const pathArray=key.split('.');const lastPath=pathArray.pop();pathArray.forEach(path=>{if(!pathParams[path]){pathParams[path]={};}pathParams=pathParams[path];});pathParams[lastPath]=value;});return params;}function flatten_params_resolvePath(path,key){return`${path}${path?'.':''}${key}`;}function toURLSearchParams(params,isComplexRequest){const flatten=flattenParams(params);const complexParams={};const searchParams=Object.entries(flatten).reduce((urlSearchParams,_ref3)=>{let[key,value]=_ref3;// inorder to make `foo: [1,2]` turn into `foo=1&foo=2` and not `foo[]=1&foo[]=2` | ||
const keyParams=Array.isArray(value)?value:[value];keyParams.forEach(param=>{if(param===undefined||param===null){return;}if(Array.isArray(value)&&typeof param==='object'){complexParams[key]=value;return;}if(!Array.isArray(value)){complexParams[key]=value;}urlSearchParams.append(key,param);});return urlSearchParams;},new URLSearchParams());// https://github.com/wix-private/server-infra/tree/master/framework/grpc/rest#complex-requests-messages-with-get-mappings | ||
if(isComplexRequest){searchParams.append('.r',encode(JSON.stringify(inflateParams(complexParams)),true));}return searchParams;} | ||
;// CONCATENATED MODULE: ./index.ts | ||
@@ -378,0 +379,0 @@ |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("counter",[],t):"object"==typeof exports?exports.counter=t():e.counter=t()}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){void 0===e&&(e="");const[t,r]=o(e);return r?{schemaName:r,schemaType:t}:{schemaName:t}}e.r(t),e.d(t,{parseLeanSchemaRef:()=>r,resolveUrl:()=>u,toURLSearchParams:()=>T});const o=e=>e.split("#");const n="_",a=/{(.*)}/,c=new RegExp(`\\.(${["wix.com","editorx.com"].join("|")})$`),i=new RegExp(`\\.(${["42.wixprod.net","uw2-edt-1.wixprod.net"].join("|")})$`),f=new RegExp(".*\\.dev.wix-code.com$");function u(e){const t=function(e,t){const r=t[e]||t[n];if(!r&&function(e){return!!e.match(/\._base_domain_$/)}(e))return t[s];return r}(function(e){return e.replace("create.editorx.com","editor.editorx.com")}(e.host).replace(c,"._base_domain_").replace(i,"._api_base_domain_").replace(f,"*.dev.wix-code.com"),e.domainToMappings);var r,o;return function(e,t){const r=null==t?void 0:t.find((t=>e.startsWith(t.destPath)));if(!r)return e;return r.srcPath+e.slice(r.destPath.length)}((r=e.protoPath,o=e.data||{},r.split("/").map((e=>function(e,t){const r=e.match(a)||[],o=r[1];if(o){const n=e.replace(r[0],"");return function(e,t,r,o){let n=e;for(const e of t.split(".")){if(!n)return r;n=n[e]}return`${n}${o}`}(t,o,e,n)}return e}(e,o))).join("/")),t)}const s="www._base_domain_",d="function"==typeof Buffer,l=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder?new TextEncoder:void 0),p=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),h=(e=>{let t={};return e.forEach(((e,r)=>t[e]=r)),t})(p),y=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,m=String.fromCharCode.bind(String),b=("function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_"))),g=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),A=e=>{let t,r,o,n,a="";const c=e.length%3;for(let c=0;c<e.length;){if((r=e.charCodeAt(c++))>255||(o=e.charCodeAt(c++))>255||(n=e.charCodeAt(c++))>255)throw new TypeError("invalid character found");t=r<<16|o<<8|n,a+=p[t>>18&63]+p[t>>12&63]+p[t>>6&63]+p[63&t]}return c?a.slice(0,c-3)+"===".substring(c):a},x="function"==typeof btoa?e=>btoa(e):d?e=>Buffer.from(e,"binary").toString("base64"):A,w=d?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,o=e.length;r<o;r+=4096)t.push(m.apply(null,e.subarray(r,r+4096)));return x(t.join(""))},j=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?m(192|t>>>6)+m(128|63&t):m(224|t>>>12&15)+m(128|t>>>6&63)+m(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return m(240|t>>>18&7)+m(128|t>>>12&63)+m(128|t>>>6&63)+m(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,v=e=>e.replace(_,j),S=d?e=>Buffer.from(e,"utf8").toString("base64"):l?e=>w(l.encode(e)):e=>x(v(e)),$=(e,t=!1)=>t?b(S(e)):S(e),E=e=>{if(e=e.replace(/\s+/g,""),!y.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,r,o,n="";for(let a=0;a<e.length;)t=h[e.charAt(a++)]<<18|h[e.charAt(a++)]<<12|(r=h[e.charAt(a++)])<<6|(o=h[e.charAt(a++)]),n+=64===r?m(t>>16&255):64===o?m(t>>16&255,t>>8&255):m(t>>16&255,t>>8&255,255&t);return n};function P(e,t){void 0===t&&(t="");const r={};return Object.entries(e).forEach((e=>{let[o,n]=e;const a=null!==n&&"object"==typeof n&&!Array.isArray(n),c=function(e,t){return`${e}${e?".":""}${t}`}(t,o);if(a){const e=P(n,c);Object.assign(r,e)}else r[c]=n})),r}function T(e,t){const r=P(e),o=Object.entries(r).reduce(((e,t)=>{let[r,o]=t;return(Array.isArray(o)?o:[o]).forEach((t=>{null==t||Array.isArray(o)&&"object"==typeof t||e.append(r,t)})),e}),new URLSearchParams);return t&&o.append(".r",$(JSON.stringify(e),!0)),o}return t})())); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("counter",[],t):"object"==typeof exports?exports.counter=t():e.counter=t()}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e){void 0===e&&(e="");const[t,r]=o(e);return r?{schemaName:r,schemaType:t}:{schemaName:t}}e.r(t),e.d(t,{parseLeanSchemaRef:()=>r,resolveUrl:()=>s,toURLSearchParams:()=>P});const o=e=>e.split("#");const n="_",c=/{(.*)}/,a=new RegExp(`\\.(${["wix.com","editorx.com"].join("|")})$`),i=new RegExp(`\\.(${["42.wixprod.net","uw2-edt-1.wixprod.net"].join("|")})$`),f=new RegExp(".*\\.dev.wix-code.com$");function s(e){const t=function(e,t){const r=t[e]||t[n];if(!r&&function(e){return!!e.match(/\._base_domain_$/)}(e))return t[u];return r}(function(e){return e.replace("create.editorx.com","editor.editorx.com")}(e.host).replace(a,"._base_domain_").replace(i,"._api_base_domain_").replace(f,"*.dev.wix-code.com"),e.domainToMappings);var r,o;return function(e,t){const r=null==t?void 0:t.find((t=>e.startsWith(t.destPath)));if(!r)return e;return r.srcPath+e.slice(r.destPath.length)}((r=e.protoPath,o=e.data||{},r.split("/").map((e=>function(e,t){const r=e.match(c)||[],o=r[1];if(o){const n=e.replace(r[0],"");return function(e,t,r,o){let n=e;for(const e of t.split(".")){if(!n)return r;n=n[e]}return`${n}${o}`}(t,o,e,n)}return e}(e,o))).join("/")),t)}const u="www._base_domain_",l="function"==typeof Buffer,d=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder?new TextEncoder:void 0),p=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),h=(e=>{let t={};return e.forEach(((e,r)=>t[e]=r)),t})(p),y=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,m=String.fromCharCode.bind(String),b=("function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_"))),g=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),A=e=>{let t,r,o,n,c="";const a=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(o=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw new TypeError("invalid character found");t=r<<16|o<<8|n,c+=p[t>>18&63]+p[t>>12&63]+p[t>>6&63]+p[63&t]}return a?c.slice(0,a-3)+"===".substring(a):c},x="function"==typeof btoa?e=>btoa(e):l?e=>Buffer.from(e,"binary").toString("base64"):A,w=l?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,o=e.length;r<o;r+=4096)t.push(m.apply(null,e.subarray(r,r+4096)));return x(t.join(""))},j=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?m(192|t>>>6)+m(128|63&t):m(224|t>>>12&15)+m(128|t>>>6&63)+m(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return m(240|t>>>18&7)+m(128|t>>>12&63)+m(128|t>>>6&63)+m(128|63&t)},_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,v=e=>e.replace(_,j),S=l?e=>Buffer.from(e,"utf8").toString("base64"):d?e=>w(d.encode(e)):e=>x(v(e)),E=(e,t=!1)=>t?b(S(e)):S(e),$=e=>{if(e=e.replace(/\s+/g,""),!y.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,r,o,n="";for(let c=0;c<e.length;)t=h[e.charAt(c++)]<<18|h[e.charAt(c++)]<<12|(r=h[e.charAt(c++)])<<6|(o=h[e.charAt(c++)]),n+=64===r?m(t>>16&255):64===o?m(t>>16&255,t>>8&255):m(t>>16&255,t>>8&255,255&t);return n};function O(e,t){void 0===t&&(t="");const r={};return Object.entries(e).forEach((e=>{let[o,n]=e;const c=null!==n&&"object"==typeof n&&!Array.isArray(n),a=function(e,t){return`${e}${e?".":""}${t}`}(t,o);if(c){const e=O(n,a);Object.assign(r,e)}else r[a]=n})),r}function P(e,t){const r=O(e),o={},n=Object.entries(r).reduce(((e,t)=>{let[r,n]=t;return(Array.isArray(n)?n:[n]).forEach((t=>{null!=t&&(Array.isArray(n)&&"object"==typeof t?o[r]=n:(Array.isArray(n)||(o[r]=n),e.append(r,t)))})),e}),new URLSearchParams);return t&&n.append(".r",E(JSON.stringify(function(e){const t={};return Object.entries(e).forEach((e=>{let[r,o]=e,n=t;const c=r.split("."),a=c.pop();c.forEach((e=>{n[e]||(n[e]={}),n=n[e]})),n[a]=o})),t}(o)),!0)),n}return t})())); | ||
//# sourceMappingURL=metro-runtime.umd.min.js.map |
{ | ||
"name": "@wix/metro-runtime", | ||
"version": "1.1930.0", | ||
"version": "1.1931.0", | ||
"license": "UNLICENSED", | ||
@@ -117,3 +117,3 @@ "author": { | ||
}, | ||
"falconPackageHash": "f9dc58995e9c5c0b5903122c824e8945d70c7a9dfff8d37a5ba1237b" | ||
"falconPackageHash": "7761894eec8e0676763561a567f49504efdd95b101d46e77cb894658" | ||
} |
@@ -23,2 +23,20 @@ import { encode } from 'js-base64'; | ||
// Inflate a params object to a nested object { field.text ='foo' } => { field: { text: 'foo' } } | ||
function inflateParams(data: object) { | ||
const params: any = {}; | ||
Object.entries(data).forEach(([key, value]) => { | ||
let pathParams = params; | ||
const pathArray = key.split('.'); | ||
const lastPath = pathArray.pop()!; | ||
pathArray.forEach((path) => { | ||
if (!pathParams[path]) { | ||
pathParams[path] = {}; | ||
} | ||
pathParams = pathParams[path]; | ||
}); | ||
pathParams[lastPath] = value; | ||
}); | ||
return params; | ||
} | ||
function resolvePath(path: string, key: string) { | ||
@@ -30,2 +48,3 @@ return `${path}${path ? '.' : ''}${key}`; | ||
const flatten = flattenParams(params); | ||
const complexParams: { [key: string]: any } = {}; | ||
@@ -38,9 +57,12 @@ const searchParams = Object.entries(flatten).reduce( | ||
keyParams.forEach((param: any) => { | ||
if ( | ||
param === undefined || | ||
param === null || | ||
(Array.isArray(value) && typeof param === 'object') | ||
) { | ||
if (param === undefined || param === null) { | ||
return; | ||
} | ||
if (Array.isArray(value) && typeof param === 'object') { | ||
complexParams[key] = value; | ||
return; | ||
} | ||
if (!Array.isArray(value)) { | ||
complexParams[key] = value; | ||
} | ||
@@ -57,3 +79,6 @@ urlSearchParams.append(key, param); | ||
if (isComplexRequest) { | ||
searchParams.append('.r', encode(JSON.stringify(params), true)); | ||
searchParams.append( | ||
'.r', | ||
encode(JSON.stringify(inflateParams(complexParams)), true), | ||
); | ||
} | ||
@@ -60,0 +85,0 @@ |
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4856066
0.17%43151
0.17%