cabinetsbay / site

cabinetsbay.com (Magento 2)
https://upwork.com/fl/mage2pro
0 stars 1 forks source link

«Mismatched anonymous define() module» on loading `cdn1.affirm.com/products/affirmjs/master/dist/ldclient.min.js` #128

Closed dmitrii-fediuk closed 5 months ago

dmitrii-fediuk commented 5 months ago

2024-04-05--15-55-16

dmitrii-fediuk commented 5 months ago

function(e){"use strict";function t(e){function t(e,t){Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor),this.message=e,this.code=t}return t.prototype=new Error,t.prototype.name=e,t.prototype.constructor=t,t}const n=t("LaunchDarklyUnexpectedResponseError"),r=t("LaunchDarklyInvalidEnvironmentIdError"),o=t("LaunchDarklyInvalidUserError"),i=t("LaunchDarklyInvalidEventKeyError"),a=t("LaunchDarklyInvalidArgumentError"),s=t("LaunchDarklyFlagFetchError");for(var c={LDUnexpectedResponseError:n,LDInvalidEnvironmentIdError:r,LDInvalidUserError:o,LDInvalidEventKeyError:i,LDInvalidArgumentError:a,LDInvalidDataError:t("LaunchDarklyInvalidDataError"),LDFlagFetchError:s,isHttpErrorRecoverable:function(e){return!(e>=400&&e<500)||(400===e||408===e||429===e)}},u=function(e){var t=h(e),n=t[0],r=t[1];return 3(n+r)/4-r},l=function(e){var t,n,r=h(e),o=r[0],i=r[1],a=new v(function(e,t,n){return 3(t+n)/4-n}(0,o,i)),s=0,c=i>0?o-4:o;for(n=0;n<c;n+=4)t=g[e.charCodeAt(n)]<<18|g[e.charCodeAt(n+1)]<<12|g[e.charCodeAt(n+2)]<<6|g[e.charCodeAt(n+3)],a[s++]=t>>16&255,a[s++]=t>>8&255,a[s++]=255&t;2===i&&(t=g[e.charCodeAt(n)]<<2|g[e.charCodeAt(n+1)]>>4,a[s++]=255&t);1===i&&(t=g[e.charCodeAt(n)]<<10|g[e.charCodeAt(n+1)]<<4|g[e.charCodeAt(n+2)]>>2,a[s++]=t>>8&255,a[s++]=255&t);return a},d=function(e){for(var t,n=e.length,r=n%3,o=[],i=16383,a=0,s=n-r;a<s;a+=i)o.push(y(e,a,a+i>s?s:a+i));1===r?(t=e[n-1],o.push(f[t>>2]+f[t<<4&63]+"==")):2===r&&(t=(e[n-2]<<8)+e[n-1],o.push(f[t>>10]+f[t>>4&63]+f[t<<2&63]+"="));return o.join("")},f=[],g=[],v="undefined"!=typeof Uint8Array?Uint8Array:Array,p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",m=0;m<64;++m)f[m]=p[m],g[p.charCodeAt(m)]=m;function h(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function y(e,t,n){for(var r,o,i=[],a=t;a<n;a+=3)r=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(f[(o=r)>>18&63]+f[o>>12&63]+f[o>>6&63]+f[63&o]);return i.join("")}g["-".charCodeAt(0)]=62,g["".charCodeAt(0)]=63;var w={byteLength:u,toByteArray:l,fromByteArray:d},b=Array.isArray,k=Object.keys,E=Object.prototype.hasOwnProperty,D=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var r,o,i,a=b(t),s=b(n);if(a&&s){if((o=t.length)!=n.length)return!1;for(r=o;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(a!=s)return!1;var c=t instanceof Date,u=n instanceof Date;if(c!=u)return!1;if(c&&u)return t.getTime()==n.getTime();var l=t instanceof RegExp,d=n instanceof RegExp;if(l!=d)return!1;if(l&&d)return t.toString()==n.toString();var f=k(t);if((o=f.length)!==k(n).length)return!1;for(r=o;0!=r--;)if(!E.call(n,f[r]))return!1;for(r=o;0!=r--;)if(!e(t[i=f[r]],n[i]))return!1;return!0}return t!=t&&n!=n};const C=["key","ip","country","email","firstName","lastName","avatar","name"];function x(e){const t=unescape(encodeURIComponent(e));return w.fromByteArray(function(e){const t=[];for(let n=0;n<e.length;n++)t.push(e.charCodeAt(n));return t}(t))}function P(e){return x(e).replace(/=/g,"").replace(/+/g,"-").replace(/\//g,"")}function S(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var I,O={appendUrlPath:function(e,t){return(e.endsWith("/")?e.substring(0,e.length-1):e)+(t.startsWith("/")?"":"/")+t},base64URLEncode:P,btoa:x,chunkEventsForUrl:function(e,t){const n=t.slice(0),r=[];let o,i=e;for(;n.length>0;){for(o=[];i>0;){const e=n.shift();if(!e)break;i-=P(JSON.stringify(e)).length,i<0&&o.length>0?n.unshift(e):o.push(e)}i=e,r.push(o)}return r},clone:function(e){return JSON.parse(JSON.stringify(e))},deepEquals:function(e,t){return D(e,t)},extend:function(...e){return e.reduce(((e,t)=>({...e,...t})),{})},getLDUserAgentString:function(e){const t=e.version||"?";return e.userAgent+"/"+t},objectHasOwnProperty:S,onNextTick:function(e){setTimeout(e,0)},sanitizeContext:function(e){if(!e)return e;let t;return null!==e.kind&&void 0!==e.kind||C.forEach((n=>{const r=e[n];void 0!==r&&"string"!=typeof r&&(t=t||{...e},t[n]=String(r))})),t||e},transformValuesToVersionedValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]={value:e[n],version:0});return t},transformVersionedValuesToValues:function(e){const t={};for(const n in e)S(e,n)&&(t[n]=e[n].value);return t},wrapPromiseCallback:function(e,t){const n=e.then((e=>(t&&setTimeout((()=>{t(null,e)}),0),e)),(e=>{if(!t)return Promise.reject(e);setTimeout((()=>{t(e,null)}),0)}));return t?void 0:n}},L=new Uint8Array(16);function T(){if(!I&&!(I="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return I(L)}var U=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function R(e){return"string"==typeof e&&U.test(e)}for(var A,j,F=[],N=0;N<256;++N)F.push((N+256).toString(16).substr(1));function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(F[e[t+0]]+F[e[t+1]]+F[e[t+2]]+F[e[t+3]]+"-"+F[e[t+4]]+F[e[t+5]]+"-"+F[e[t+6]]+F[e[t+7]]+"-"+F[e[t+8]]+F[e[t+9]]+"-"+F[e[t+10]]+F[e[t+11]]+F[e[t+12]]+F[e[t+13]]+F[e[t+14]]+F[e[t+15]]).toLowerCase();if(!R(n))throw TypeError("Stringified UUID is invalid");return n}var V=0,H=0;function M(e){if(!R(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n}function q(e,t,n){function r(e,r,o,i){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof r&&(r=M(r)),16!==r.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(r),a.set(e,r.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,o){i=i||0;for(var s=0;s<16;++s)o[i+s]=a[s];return o}return $(a)}try{r.name=e}catch(e){}return r.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",r.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",r}function K(e){return 14+(e+64>>>9<<4)+1}function (e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function z(e,t,n,r,o,i){return ((a=((t,e),(r,i)))<<(s=o)|a>>>32-s,n);var a,s}function J(e,t,n,r,o,i,a){return z(t&n|~t&r,e,t,o,i,a)}function B(e,t,n,r,o,i,a){return z(t&r|n&~r,e,t,o,i,a)}function G(e,t,n,r,o,i,a){return z(t^n^r,e,t,o,i,a)}function W(e,t,n,r,o,i,a){return z(n^(t|~r),e,t,o,i,a)}var X=q("v3",48,(function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,r="0123456789abcdef",o=0;o<n;o+=8){var i=e[o>>5]>>>o%32&255,a=parseInt(r.charAt(i>>>4&15)+r.charAt(15&i),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[K(t)-1]=t;for(var n=1732584193,r=-271733879,o=-1732584194,i=271733878,a=0;a<e.length;a+=16){var s=n,c=r,u=o,l=i;n=J(n,r,o,i,e[a],7,-680876936),i=J(i,n,r,o,e[a+1],12,-389564586),o=J(o,i,n,r,e[a+2],17,606105819),r=J(r,o,i,n,e[a+3],22,-1044525330),n=J(n,r,o,i,e[a+4],7,-176418897),i=J(i,n,r,o,e[a+5],12,1200080426),o=J(o,i,n,r,e[a+6],17,-1473231341),r=J(r,o,i,n,e[a+7],22,-45705983),n=J(n,r,o,i,e[a+8],7,1770035416),i=J(i,n,r,o,e[a+9],12,-1958414417),o=J(o,i,n,r,e[a+10],17,-42063),r=J(r,o,i,n,e[a+11],22,-1990404162),n=J(n,r,o,i,e[a+12],7,1804603682),i=J(i,n,r,o,e[a+13],12,-40341101),o=J(o,i,n,r,e[a+14],17,-1502002290),n=B(n,r=J(r,o,i,n,e[a+15],22,1236535329),o,i,e[a+1],5,-165796510),i=B(i,n,r,o,e[a+6],9,-1069501632),o=B(o,i,n,r,e[a+11],14,643717713),r=B(r,o,i,n,e[a],20,-373897302),n=B(n,r,o,i,e[a+5],5,-701558691),i=B(i,n,r,o,e[a+10],9,38016083),o=B(o,i,n,r,e[a+15],14,-660478335),r=B(r,o,i,n,e[a+4],20,-405537848),n=B(n,r,o,i,e[a+9],5,568446438),i=B(i,n,r,o,e[a+14],9,-1019803690),o=B(o,i,n,r,e[a+3],14,-187363961),r=B(r,o,i,n,e[a+8],20,1163531501),n=B(n,r,o,i,e[a+13],5,-1444681467),i=B(i,n,r,o,e[a+2],9,-51403784),o=B(o,i,n,r,e[a+7],14,1735328473),n=G(n,r=B(r,o,i,n,e[a+12],20,-1926607734),o,i,e[a+5],4,-378558),i=G(i,n,r,o,e[a+8],11,-2022574463),o=G(o,i,n,r,e[a+11],16,1839030562),r=G(r,o,i,n,e[a+14],23,-35309556),n=G(n,r,o,i,e[a+1],4,-1530992060),i=G(i,n,r,o,e[a+4],11,1272893353),o=G(o,i,n,r,e[a+7],16,-155497632),r=G(r,o,i,n,e[a+10],23,-1094730640),n=G(n,r,o,i,e[a+13],4,681279174),i=G(i,n,r,o,e[a],11,-358537222),o=G(o,i,n,r,e[a+3],16,-722521979),r=G(r,o,i,n,e[a+6],23,76029189),n=G(n,r,o,i,e[a+9],4,-640364487),i=G(i,n,r,o,e[a+12],11,-421815835),o=G(o,i,n,r,e[a+15],16,530742520),n=W(n,r=G(r,o,i,n,e[a+2],23,-995338651),o,i,e[a],6,-198630844),i=W(i,n,r,o,e[a+7],10,1126891415),o=W(o,i,n,r,e[a+14],15,-1416354905),r=W(r,o,i,n,e[a+5],21,-57434055),n=W(n,r,o,i,e[a+12],6,1700485571),i=W(i,n,r,o,e[a+3],10,-1894986606),o=W(o,i,n,r,e[a+10],15,-1051523),r=W(r,o,i,n,e[a+1],21,-2054922799),n=W(n,r,o,i,e[a+8],6,1873313359),i=W(i,n,r,o,e[a+15],10,-30611744),o=W(o,i,n,r,e[a+6],15,-1560198380),r=W(r,o,i,n,e[a+13],21,1309151649),n=W(n,r,o,i,e[a+4],6,-145523070),i=W(i,n,r,o,e[a+11],10,-1120210379),o=W(o,i,n,r,e[a+2],15,718787259),r=W(r,o,i,n,e[a+9],21,-343485551),n=(n,s),r=(r,c),o=(o,u),i=_(i,l)}return[n,r,o,i]}(function(e){if(0===e.length)return[];for(var t=8e.length,n=new Uint32Array(K(t)),r=0;r<t;r+=8)n[r>>5]|=(255&e[r/8])<<r%32;return n}(e),8e.length))})),Q=X;function Y(e,t,n,r){switch(e){case 0:return t&n^~t&r;case 1:case 3:return t^n^r;case 2:return t&n^t&r^n&r}}function Z(e,t){return e<<t|e>>>32-t}var ee=q("v5",80,(funct…"

dmitrii-fediuk commented 5 months ago

cdn1.affirm.com/products/affirmjs/master/dist/ldclient.min.js

dmitrii-fediuk commented 5 months ago
vendor/magento/module-page-builder/view/base/web/js/widget-initializer.js

2024-04-05--16-26-54

function (_, $, mage, domObserver) {
    'use strict';

    /**
     * Initializes components assigned to HTML elements.
     *
     *
     * @param {HTMLElement} el
     * @param {Array} data
     * @param {Object} breakpoints
     * @param {Object} currentViewport
     */
    function initializeWidget(el, data, breakpoints, currentViewport) {
        _.each(data, function (config, component) {
            config = config || {};
            config.breakpoints = breakpoints;
            config.currentViewport = currentViewport;
            mage.applyFor(el, config, component);
        });
    }

    return function (data, contextElement) {
        _.each(data.config, function (componentConfiguration, elementPath) {
            domObserver.get(
                elementPath,
                function (element) {
                    var $element = $(element);

                    if (contextElement) {
                        $element = $(contextElement).find(element);
                    }

                    if ($element.length) {
                        initializeWidget($element, componentConfiguration, data.breakpoints, data.currentViewport);
                    }
                }
            );
        });
    };
}
dmitrii-fediuk commented 5 months ago

Устранил проблему. Она вызывалась модулем Affirm. Сайт загружает много подпрограмм на JavaScript с серверов сторонних (используемых сайтом) сервисов, в том числе и с серверов Affirm: https://docs.affirm.com/payments/docs/afjs-reference#including-and-initializing-affirmjs Эти подпрограммы разрабатываются сторонними разработчиками, которые могут их менять в любой день. Раньше проблема не проявлялась, потому что эти сторонние подпрограммы работали по-другому. В частности, проблему «Mismatched anonymous define() module» вызывала подпрограмма https://cdn1.affirm.com/products/affirmjs/master/dist/ldclient.min.js Причём, может быть, она вне контекста сайта работает правильно, но, как я писал раньше: «Если программные дефекты не устранять, то программа начинает работать непредсказуемым образом. Много маленьких дефектов взаимно влияют друг на друга и на другие части системы, сложность поведения системы быстро растёт и система становится непонятной.» В контексте сайта эта подпрограмма работала неправильно. Я в Magento добавил специальную обработку этой подпрограммы, чтобы она заработала правильно.