UNPKG

@shopify/cli

Version:

A CLI tool to build for the Shopify platform

3 lines (2 loc) 5 kB
import{g as W}from"./chunk-VPRTJUIN.js";W();function v(){}v.prototype={diff:function(e,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},t=o.callback;typeof o=="function"&&(t=o,o={}),this.options=o;var l=this;function f(u){return t?(setTimeout(function(){t(void 0,u)},0),!0):u}e=this.castInput(e),r=this.castInput(r),e=this.removeEmpty(this.tokenize(e)),r=this.removeEmpty(this.tokenize(r));var s=r.length,d=e.length,p=1,a=s+d;o.maxEditLength&&(a=Math.min(a,o.maxEditLength));var m=(i=o.timeout)!==null&&i!==void 0?i:1/0,N=Date.now()+m,c=[{oldPos:-1,lastComponent:void 0}],w=this.extractCommon(c[0],r,e,0);if(c[0].oldPos+1>=d&&w+1>=s)return f([{value:this.join(r),count:r.length}]);var L=-1/0,g=1/0;function E(){for(var u=Math.max(L,-p);u<=Math.min(g,p);u+=2){var h=void 0,y=c[u-1],x=c[u+1];y&&(c[u-1]=void 0);var O=!1;if(x){var A=x.oldPos-u;O=x&&0<=A&&A<s}var z=y&&y.oldPos+1<d;if(!O&&!z){c[u]=void 0;continue}if(!z||O&&y.oldPos+1<x.oldPos?h=l.addToPath(x,!0,void 0,0):h=l.addToPath(y,void 0,!0,1),w=l.extractCommon(h,r,e,u),h.oldPos+1>=d&&w+1>=s)return f(D(l,h.lastComponent,r,e,l.useLongestToken));c[u]=h,h.oldPos+1>=d&&(g=Math.min(g,u-1)),w+1>=s&&(L=Math.max(L,u+1))}p++}if(t)(function u(){setTimeout(function(){if(p>a||Date.now()>N)return t();E()||u()},0)})();else for(;p<=a&&Date.now()<=N;){var T=E();if(T)return T}},addToPath:function(e,r,i,o){var t=e.lastComponent;return t&&t.added===r&&t.removed===i?{oldPos:e.oldPos+o,lastComponent:{count:t.count+1,added:r,removed:i,previousComponent:t.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:r,removed:i,previousComponent:t}}},extractCommon:function(e,r,i,o){for(var t=r.length,l=i.length,f=e.oldPos,s=f-o,d=0;s+1<t&&f+1<l&&this.equals(r[s+1],i[f+1]);)s++,f++,d++;return d&&(e.lastComponent={count:d,previousComponent:e.lastComponent}),e.oldPos=f,s},equals:function(e,r){return this.options.comparator?this.options.comparator(e,r):e===r||this.options.ignoreCase&&e.toLowerCase()===r.toLowerCase()},removeEmpty:function(e){for(var r=[],i=0;i<e.length;i++)e[i]&&r.push(e[i]);return r},castInput:function(e){return e},tokenize:function(e){return e.split("")},join:function(e){return e.join("")}};function D(n,e,r,i,o){for(var t=[],l;e;)t.push(e),l=e.previousComponent,delete e.previousComponent,e=l;t.reverse();for(var f=0,s=t.length,d=0,p=0;f<s;f++){var a=t[f];if(a.removed){if(a.value=n.join(i.slice(p,p+a.count)),p+=a.count,f&&t[f-1].added){var N=t[f-1];t[f-1]=t[f],t[f]=N}}else{if(!a.added&&o){var m=r.slice(d,d+a.count);m=m.map(function(w,L){var g=i[p+L];return g.length>w.length?g:w}),a.value=n.join(m)}else a.value=n.join(r.slice(d,d+a.count));d+=a.count,a.added||(p+=a.count)}}var c=t[s-1];return s>1&&typeof c.value=="string"&&(c.added||c.removed)&&n.equals("",c.value)&&(t[s-2].value+=c.value,t.pop()),t}var P=new v;var C=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,M=/\S/,q=new v;q.equals=function(n,e){return this.options.ignoreCase&&(n=n.toLowerCase(),e=e.toLowerCase()),n===e||this.options.ignoreWhitespace&&!M.test(n)&&!M.test(e)};q.tokenize=function(n){for(var e=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),r=0;r<e.length-1;r++)!e[r+1]&&e[r+2]&&C.test(e[r])&&C.test(e[r+2])&&(e[r]+=e[r+2],e.splice(r+1,2),r--);return e};var I=new v;I.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,` `));var e=[],r=n.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(var i=0;i<r.length;i++){var o=r[i];i%2&&!this.options.newlineIsToken?e[e.length-1]+=o:(this.options.ignoreWhitespace&&(o=o.trim()),e.push(o))}return e};function j(n,e,r){return I.diff(n,e,r)}var R=new v;R.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var $=new v;$.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function H(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?H=function(e){return typeof e}:H=function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},H(n)}var J=Object.prototype.toString,F=new v;F.useLongestToken=!0;F.tokenize=I.tokenize;F.castInput=function(n){var e=this.options,r=e.undefinedReplacement,i=e.stringifyReplacer,o=i===void 0?function(t,l){return typeof l>"u"?r:l}:i;return typeof n=="string"?n:JSON.stringify(b(n,null,null,o),o," ")};F.equals=function(n,e){return v.prototype.equals.call(F,n.replace(/,([\r\n])/g,"$1"),e.replace(/,([\r\n])/g,"$1"))};function b(n,e,r,i,o){e=e||[],r=r||[],i&&(n=i(o,n));var t;for(t=0;t<e.length;t+=1)if(e[t]===n)return r[t];var l;if(J.call(n)==="[object Array]"){for(e.push(n),l=new Array(n.length),r.push(l),t=0;t<n.length;t+=1)l[t]=b(n[t],e,r,i,o);return e.pop(),r.pop(),l}if(n&&n.toJSON&&(n=n.toJSON()),H(n)==="object"&&n!==null){e.push(n),l={},r.push(l);var f=[],s;for(s in n)n.hasOwnProperty(s)&&f.push(s);for(f.sort(),t=0;t<f.length;t+=1)s=f[t],l[s]=b(n[s],e,r,i,s);e.pop(),r.pop()}else l=n;return l}var S=new v;S.tokenize=function(n){return n.slice()};S.join=S.removeEmpty=function(n){return n};export{j as a};