Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Fix lodash dependency in the spree admin (#12525)
Damian Kaczmarczyk25be0ee89d86
diff --git a/admin/config/importmap.rb b/admin/config/importmap.rbindex b0ca189340..26e94e1f53 100644--- a/admin/config/importmap.rb+++ b/admin/config/importmap.rb@@ -30,8 +30,15 @@ pin 'stimulus-checkbox-select-all', preload: ['application-spree-admin'] # @5.3.pin 'stimulus-clipboard', preload: ['application-spree-admin'] # @4.0.1#+# We can't vendor some of the javascript libraries+# because they have relative imports in the code,+# and importmaps don't handle them, leaving us with broken imports.++# All the pins that are pinning to `ga.jspm.io`+# can be replaced with vendored versions+# after this PR: https://github.com/rails/importmap-rails/pull/235 is merged+# Uppy-# Uppy can't be downloaded, it has many relative imports in the code, and importmaps don't handle them, leaving us with broken imports.pin '@uppy/core', to: 'https://ga.jspm.io/npm:@uppy/[email protected]/lib/index.js', preload: ['application-spree-admin']pin '@uppy/dashboard', to: 'https://ga.jspm.io/npm:@uppy/[email protected]/lib/index.js', preload: ['application-spree-admin']pin '@uppy/image-editor', to: 'https://ga.jspm.io/npm:@uppy/[email protected]/lib/index.js', preload: ['application-spree-admin']@@ -80,7 +87,9 @@ pin 'classnames', to: 'https://ga.jspm.io/npm:[email protected]/index.js', preloapin 'cropperjs', to: 'https://ga.jspm.io/npm:[email protected]/dist/cropper.js', preload: ['application-spree-admin']pin 'eventemitter3', to: 'https://ga.jspm.io/npm:[email protected]/index.mjs', preload: ['application-spree-admin']pin 'exifr/dist/mini.esm.mjs', to: 'https://ga.jspm.io/npm:[email protected]/dist/mini.esm.mjs', preload: ['application-spree-admin']-pin 'lodash/', to: 'https://ga.jspm.io/npm:[email protected]/', preload: ['application-spree-admin']+pin 'lodash/throttle.js', to: 'https://ga.jspm.io/npm:[email protected]/throttle.js', preload: ['application-spree-admin']+pin 'lodash/debounce.js', to: 'https://ga.jspm.io/npm:[email protected]/debounce.js', preload: ['application-spree-admin']+pin 'lodash/merge.js', to: 'https://ga.jspm.io/npm:[email protected]/merge.js', preload: ['application-spree-admin']pin 'memoize-one', to: 'https://ga.jspm.io/npm:[email protected]/dist/memoize-one.esm.js', preload: ['application-spree-admin']pin 'mime-match', to: 'https://ga.jspm.io/npm:[email protected]/index.js', preload: ['application-spree-admin']pin 'namespace-emitter', to: 'https://ga.jspm.io/npm:[email protected]/index.js', preload: ['application-spree-admin']@@ -98,7 +107,6 @@ pin '@noble/hashes/crypto', to: 'https://ga.jspm.io/npm:@noble/[email protected]/cryppin '@noble/hashes/sha3', to: 'https://ga.jspm.io/npm:@noble/[email protected]/sha3.js', preload: ['application-spree-admin']# Tom Select-# Same as Uppy, Tom Select can't be downloaded, it has many relative imports in the code, and importmaps don't handle them, leaving us with broken imports.pin 'tom-select/dist/esm/tom-select.complete.js',to: 'https://ga.jspm.io/npm:[email protected]/dist/esm/tom-select.complete.js',preload: ['application-spree-admin']diff --git a/admin/vendor/javascript/lodash--debounce.js.js b/admin/vendor/javascript/lodash--debounce.js.jsdeleted file mode 100644index af1bb7f828..0000000000--- a/admin/vendor/javascript/lodash--debounce.js.js+++ /dev/null@@ -1,58 +0,0 @@-// lodash/[email protected] downloaded from https://ga.jspm.io/npm:[email protected]/debounce.js--import e from"./isObject.js";import i from"./now.js";import n from"./toNumber.js";import"./_/b15bba73.js";import"./_/83742462.js";import"./_/69d56582.js";import"./isSymbol.js";import"./_/052e9e66.js";import"./_/e65ed236.js";import"./isObjectLike.js";var r="undefined"!==typeof globalThis?globalThis:"undefined"!==typeof self?self:global;var t={};var o=e,u=i,a=n;var d="Expected a function";var f=Math.max,c=Math.min;-/**- * Creates a debounced function that delays invoking `func` until after `wait`- * milliseconds have elapsed since the last time the debounced function was- * invoked. The debounced function comes with a `cancel` method to cancel- * delayed `func` invocations and a `flush` method to immediately invoke them.- * Provide `options` to indicate whether `func` should be invoked on the- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked- * with the last arguments provided to the debounced function. Subsequent- * calls to the debounced function return the result of the last `func`- * invocation.- *- * **Note:** If `leading` and `trailing` options are `true`, `func` is- * invoked on the trailing edge of the timeout only if the debounced function- * is invoked more than once during the `wait` timeout.- *- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred- * until to the next tick, similar to `setTimeout` with a timeout of `0`.- *- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)- * for details over the differences between `_.debounce` and `_.throttle`.- *- * @static- * @memberOf _- * @since 0.1.0- * @category Function- * @param {Function} func The function to debounce.- * @param {number} [wait=0] The number of milliseconds to delay.- * @param {Object} [options={}] The options object.- * @param {boolean} [options.leading=false]- * Specify invoking on the leading edge of the timeout.- * @param {number} [options.maxWait]- * The maximum time `func` is allowed to be delayed before it's invoked.- * @param {boolean} [options.trailing=true]- * Specify invoking on the trailing edge of the timeout.- * @returns {Function} Returns the new debounced function.- * @example- *- * // Avoid costly calculations while the window size is in flux.- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));- *- * // Invoke `sendMail` when clicked, debouncing subsequent calls.- * jQuery(element).on('click', _.debounce(sendMail, 300, {- * 'leading': true,- * 'trailing': false- * }));- *- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });- * var source = new EventSource('/stream');- * jQuery(source).on('message', debounced);- *- * // Cancel the trailing debounced invocation.- * jQuery(window).on('popstate', debounced.cancel);- */function debounce(e,i,n){var t,l,m,s,v,p,g=0,b=false,h=false,j=true;if("function"!=typeof e)throw new TypeError(d);i=a(i)||0;if(o(n)){b=!!n.leading;h="maxWait"in n;m=h?f(a(n.maxWait)||0,i):m;j="trailing"in n?!!n.trailing:j}function invokeFunc(i){var n=t,r=l;t=l=void 0;g=i;s=e.apply(r,n);return s}function leadingEdge(e){g=e;v=setTimeout(timerExpired,i);return b?invokeFunc(e):s}function remainingWait(e){var n=e-p,r=e-g,t=i-n;return h?c(t,m-r):t}function shouldInvoke(e){var n=e-p,r=e-g;return void 0===p||n>=i||n<0||h&&r>=m}function timerExpired(){var e=u();if(shouldInvoke(e))return trailingEdge(e);v=setTimeout(timerExpired,remainingWait(e))}function trailingEdge(e){v=void 0;if(j&&t)return invokeFunc(e);t=l=void 0;return s}function cancel(){void 0!==v&&clearTimeout(v);g=0;t=p=l=v=void 0}function flush(){return void 0===v?s:trailingEdge(u())}function debounced(){var e=u(),n=shouldInvoke(e);t=arguments;l=this||r;p=e;if(n){if(void 0===v)return leadingEdge(p);if(h){clearTimeout(v);v=setTimeout(timerExpired,i);return invokeFunc(p)}}void 0===v&&(v=setTimeout(timerExpired,i));return s}debounced.cancel=cancel;debounced.flush=flush;return debounced}t=debounce;var l=t;export{l as default};-diff --git a/admin/vendor/javascript/lodash--merge.js b/admin/vendor/javascript/lodash--merge.jsdeleted file mode 100644index 34df99ccea..0000000000--- a/admin/vendor/javascript/lodash--merge.js+++ /dev/null@@ -1,35 +0,0 @@-// lodash/[email protected] downloaded from https://ga.jspm.io/npm:[email protected]/merge.js--import{_ as s}from"./_/3a21c86a.js";import{_ as i}from"./_/d7952e2b.js";import"./_Stack.js";import"./_/9e9ce10f.js";import"./_/70a2d34d.js";import"./_/58273e1c.js";import"./isFunction.js";import"./_/052e9e66.js";import"./_/e65ed236.js";import"./_/b15bba73.js";import"./isObject.js";import"./eq.js";import"./_/38d0670d.js";import"./_/762679ff.js";import"./_/d35a7fd6.js";import"./_/d603d993.js";import"./_/ae1a03d5.js";import"./_cloneBuffer.js";import"./_/38f90d17.js";import"./_/8ae180c0.js";import"./_copyArray.js";import"./_initCloneObject.js";import"./_/79ae4a01.js";import"./_/ca1e037e.js";import"./_/d2b8ecf6.js";import"./_/1d469fdd.js";import"./isArguments.js";import"./isObjectLike.js";import"./isArray.js";import"./isArrayLikeObject.js";import"./isArrayLike.js";import"./isLength.js";import"./isBuffer.js";import"./stubFalse.js";import"./isPlainObject.js";import"./isTypedArray.js";import"./_/dcdb9fca.js";import"./_/9f64fdae.js";import"./toPlainObject.js";import"./_/b1449f65.js";import"./_assignValue.js";import"./keysIn.js";import"./_/d533f765.js";import"./_/c8441f51.js";import"./_isIndex.js";import"./_baseRest.js";import"./identity.js";import"./_overRest.js";import"./_apply.js";import"./_/ead8ed36.js";import"./constant.js";import"./_/7781ca7a.js";var t={};var r=s,o=i;-/**- * This method is like `_.assign` except that it recursively merges own and- * inherited enumerable string keyed properties of source objects into the- * destination object. Source properties that resolve to `undefined` are- * skipped if a destination value exists. Array and plain object properties- * are merged recursively. Other objects and value types are overridden by- * assignment. Source objects are applied from left to right. Subsequent- * sources overwrite property assignments of previous sources.- *- * **Note:** This method mutates `object`.- *- * @static- * @memberOf _- * @since 0.5.0- * @category Object- * @param {Object} object The destination object.- * @param {...Object} [sources] The source objects.- * @returns {Object} Returns `object`.- * @example- *- * var object = {- * 'a': [{ 'b': 2 }, { 'd': 4 }]- * };- *- * var other = {- * 'a': [{ 'c': 3 }, { 'e': 5 }]- * };- *- * _.merge(object, other);- * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }- */var j=o((function(s,i,t){r(s,i,t)}));t=j;var p=t;export{p as default};-diff --git a/admin/vendor/javascript/lodash--throttle.js b/admin/vendor/javascript/lodash--throttle.jsdeleted file mode 100644index 12350ebec7..0000000000--- a/admin/vendor/javascript/lodash--throttle.js+++ /dev/null@@ -1,48 +0,0 @@-// lodash/[email protected] downloaded from https://ga.jspm.io/npm:[email protected]/throttle.js--import t from"./debounce.js";import r from"./isObject.js";import"./now.js";import"./_/b15bba73.js";import"./toNumber.js";import"./_/83742462.js";import"./_/69d56582.js";import"./isSymbol.js";import"./_/052e9e66.js";import"./_/e65ed236.js";import"./isObjectLike.js";var i={};var o=t,e=r;var n="Expected a function";-/**- * Creates a throttled function that only invokes `func` at most once per- * every `wait` milliseconds. The throttled function comes with a `cancel`- * method to cancel delayed `func` invocations and a `flush` method to- * immediately invoke them. Provide `options` to indicate whether `func`- * should be invoked on the leading and/or trailing edge of the `wait`- * timeout. The `func` is invoked with the last arguments provided to the- * throttled function. Subsequent calls to the throttled function return the- * result of the last `func` invocation.- *- * **Note:** If `leading` and `trailing` options are `true`, `func` is- * invoked on the trailing edge of the timeout only if the throttled function- * is invoked more than once during the `wait` timeout.- *- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred- * until to the next tick, similar to `setTimeout` with a timeout of `0`.- *- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)- * for details over the differences between `_.throttle` and `_.debounce`.- *- * @static- * @memberOf _- * @since 0.1.0- * @category Function- * @param {Function} func The function to throttle.- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.- * @param {Object} [options={}] The options object.- * @param {boolean} [options.leading=true]- * Specify invoking on the leading edge of the timeout.- * @param {boolean} [options.trailing=true]- * Specify invoking on the trailing edge of the timeout.- * @returns {Function} Returns the new throttled function.- * @example- *- * // Avoid excessively updating the position while scrolling.- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));- *- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });- * jQuery(element).on('click', throttled);- *- * // Cancel the trailing throttled invocation.- * jQuery(window).on('popstate', throttled.cancel);- */function throttle(t,r,i){var a=true,m=true;if("function"!=typeof t)throw new TypeError(n);if(e(i)){a="leading"in i?!!i.leading:a;m="trailing"in i?!!i.trailing:m}return o(t,r,{leading:a,maxWait:r,trailing:m})}i=throttle;var a=i;export{a as default};-