diff --git a/src/Resources/app/storefront/build/webpack.config.js b/src/Resources/app/storefront/build/webpack.config.js deleted file mode 100644 index 950a0d439..000000000 --- a/src/Resources/app/storefront/build/webpack.config.js +++ /dev/null @@ -1,13 +0,0 @@ -const {resolve, join} = require("path"); - -module.exports = () => { - return { - resolve: { - alias: { - '@shopware-storefront-sdk': resolve( - join(__dirname, '..', 'src_vendor', 'shopware-storefront-sdk'), - ), - }, - }, - }; -}; \ No newline at end of file diff --git a/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js b/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js index 211fe6f47..dfcf13966 100644 --- a/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/core/creditcard-mandate.plugin.js @@ -1,10 +1,9 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; /** * This plugin manage the credit card mandate of the customer */ -export default class MollieCreditCardMandate extends Plugin { +export default class MollieCreditCardMandate extends window.PluginBaseClass { static options = { newCardMandateOption: null, mollieCreditCardFormClass: '.mollie-components-credit-card', diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js index b4853b5cf..0b2d667e4 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-direct.plugin.js @@ -1,7 +1,6 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; -export default class MollieApplePayDirect extends Plugin { +export default class MollieApplePayDirect extends window.PluginBaseClass { /** * diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js index 3d819c3e4..a79b06208 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/apple-pay-payment-method.plugin.js @@ -1,7 +1,6 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; -export default class MollieApplePayPaymentMethod extends Plugin { +export default class MollieApplePayPaymentMethod extends window.PluginBaseClass { /** * diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js index b08b04aed..29cef07fe 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/bancomat-plugin.js @@ -1,6 +1,4 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; - -export default class MollieBancomatPlugin extends Plugin { +export default class MollieBancomatPlugin extends window.PluginBaseClass { init() { diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js index 6413a5df4..6b8098b47 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/creditcard-mandate-manage.plugin.js @@ -1,10 +1,9 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient'; /** * This plugin manage the credit card mandate of customer */ -export default class MollieCreditCardMandateManage extends Plugin { +export default class MollieCreditCardMandateManage extends window.PluginBaseClass { static options = { shopUrl: null, customerId: null, diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js index fc4085199..eb0bf898f 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/ideal-issuer.plugin.js @@ -1,8 +1,7 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient' -export default class MollieIDealIssuer extends Plugin { +export default class MollieIDealIssuer extends window.PluginBaseClass { _shopUrl = ''; _customerId = ''; diff --git a/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js b/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js index 7aeadada5..a7f4fa2d1 100644 --- a/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js +++ b/src/Resources/app/storefront/src/mollie-payments/plugins/pos-terminal.plugin.js @@ -1,8 +1,7 @@ -import Plugin from '@shopware-storefront-sdk/plugin-system/plugin.class'; import HttpClient from '../services/HttpClient' -export default class MolliePosTerminalPlugin extends Plugin { +export default class MolliePosTerminalPlugin extends window.PluginBaseClass { _shopUrl = ''; _customerId = ''; diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/README.md b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/README.md deleted file mode 100644 index 22ae1747b..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# Shopware Storefront SDK - -## Description - -The Shopware Storefront SDK is a set of classes and methods to easily access the Shopware Storefront. -So in your plugins, you can add this package as dependency and use the classes from this package instead of default Shopware files. - -## Features - -- Build Shopware Version independent plugin -- Ability to build your plugin javascript without having the Shopware 6 code-base - -## Installation - -```bash -npm install shopware-storefront-sdk -``` diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/DeviceDetection.d.ts b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/DeviceDetection.d.ts deleted file mode 100644 index 5e35d30a1..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/DeviceDetection.d.ts +++ /dev/null @@ -1 +0,0 @@ -export declare function isTouchDevice(): boolean; diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/DeviceDetection.js b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/DeviceDetection.js deleted file mode 100644 index 5e808288e..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/DeviceDetection.js +++ /dev/null @@ -1,7 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.isTouchDevice = void 0; -function isTouchDevice() { - return ('ontouchstart' in document.documentElement); -} -exports.isTouchDevice = isTouchDevice; diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/String.d.ts b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/String.d.ts deleted file mode 100644 index 8819ee9df..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/String.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare function ucFirst(value: string): string; -export declare function lcFirst(value: string): string; -export declare function toLowerCamelCase(value: string, separator: string): string; -export declare function toUpperCamelCase(value: string, separator: string): string; diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/String.js b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/String.js deleted file mode 100644 index 5103b7436..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/helper/String.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.toUpperCamelCase = exports.toLowerCamelCase = exports.lcFirst = exports.ucFirst = void 0; -function ucFirst(value) { - return value.charAt(0).toUpperCase() + value.slice(1); -} -exports.ucFirst = ucFirst; -function lcFirst(value) { - return value.charAt(0).toLowerCase() + value.slice(1); -} -exports.lcFirst = lcFirst; -function toLowerCamelCase(value, separator) { - var upperCamelCase = toUpperCamelCase(value, separator); - return lcFirst(upperCamelCase); -} -exports.toLowerCamelCase = toLowerCamelCase; -function toUpperCamelCase(value, separator) { - if (!separator) { - return ucFirst(value.toLowerCase()); - } - var stringParts = value.split(separator); - return stringParts.map(function (string) { return ucFirst(string.toLowerCase()); }).join(''); -} -exports.toUpperCamelCase = toUpperCamelCase; diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/package.json b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/package.json deleted file mode 100644 index badc32db9..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/package.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "shopware-storefront-sdk", - "version": "0.0.2", - "description": "Provides Shopware Storefront Utilities as Typescript", - "main": "sdk.js", - "types": "sdk.d.ts", - "scripts": { - "publish-to-npm": "rm -rf dist; tsc --build && cp package.json dist && cat ./package.json | grep -v '\\\"private\\\":' > dist/package.json; cp README.md dist" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/FriendsOfShopware/shopware-storefront-sdk.git" - }, - "bugs": { - "url": "https://github.com/FriendsOfShopware/shopware-storefront-sdk/issues" - }, - "author": "FriendsOfShopware", - "license": "MIT", - "dependencies": { - "deepmerge": "^4.2.2" - }, - "devDependencies": { - "typescript": "^4.7.4" - } -} diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/NativeEventEmitter.d.ts b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/NativeEventEmitter.d.ts deleted file mode 100644 index 083a001e9..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/NativeEventEmitter.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -interface NativeEventEmitterPublish { - detail?: object; - cancelable?: boolean; -} -interface NativeEventEmitterSubscribeOpts { - once?: boolean; - scope?: Function; -} -export default class NativeEventEmitter { - private _listeners; - private _el; - constructor(el: HTMLElement); - publish(eventName: string, detail?: NativeEventEmitterPublish, cancelable?: boolean): CustomEvent; - subscribe(eventName: string, callback: Function, opts?: NativeEventEmitterSubscribeOpts): boolean; - unsubscribe(eventName: String): boolean; - reset(): boolean; - get el(): HTMLElement; - set el(value: HTMLElement); - get listeners(): any[]; - set listeners(value: any[]); -} -export {}; diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/NativeEventEmitter.js b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/NativeEventEmitter.js deleted file mode 100644 index 9aa92d954..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/NativeEventEmitter.js +++ /dev/null @@ -1,86 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -var NativeEventEmitter = /** @class */ (function () { - function NativeEventEmitter(el) { - this._el = el; - // @ts-ignore - el.$emitter = this; - this._listeners = []; - } - NativeEventEmitter.prototype.publish = function (eventName, detail, cancelable) { - if (detail === void 0) { detail = {}; } - if (cancelable === void 0) { cancelable = false; } - var event = new CustomEvent(eventName, { - detail: detail, - cancelable: cancelable, - }); - this.el.dispatchEvent(event); - return event; - }; - NativeEventEmitter.prototype.subscribe = function (eventName, callback, opts) { - if (opts === void 0) { opts = {}; } - var emitter = this; - var splitEventName = eventName.split('.'); - var cb = opts.scope ? callback.bind(opts.scope) : callback; - // Support for listeners which are fired once - if (opts.once && opts.once === true) { - var onceCallback_1 = cb; - cb = function onceListener(event) { - emitter.unsubscribe(eventName); - onceCallback_1(event); - }; - } - this.el.addEventListener(splitEventName[0], cb); - this.listeners.push({ - splitEventName: splitEventName, - opts: opts, - cb: cb, - }); - return true; - }; - NativeEventEmitter.prototype.unsubscribe = function (eventName) { - var _this = this; - var splitEventName = eventName.split('.'); - this.listeners = this.listeners.reduce(function (accumulator, listener) { - var foundEvent = listener.splitEventName.sort().toString() === splitEventName.sort().toString(); - if (foundEvent) { - _this.el.removeEventListener(listener.splitEventName[0], listener.cb); - return accumulator; - } - accumulator.push(listener); - return accumulator; - }, []); - return true; - }; - NativeEventEmitter.prototype.reset = function () { - var _this = this; - this.listeners.forEach(function (listener) { - _this.el.removeEventListener(listener.splitEventName[0], listener.cb); - }); - // Reset registry - this.listeners = []; - return true; - }; - Object.defineProperty(NativeEventEmitter.prototype, "el", { - get: function () { - return this._el; - }, - set: function (value) { - this._el = value; - }, - enumerable: false, - configurable: true - }); - Object.defineProperty(NativeEventEmitter.prototype, "listeners", { - get: function () { - return this._listeners; - }, - set: function (value) { - this._listeners = value; - }, - enumerable: false, - configurable: true - }); - return NativeEventEmitter; -}()); -exports.default = NativeEventEmitter; diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/plugin.class.d.ts b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/plugin.class.d.ts deleted file mode 100644 index 2f3f09c02..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/plugin.class.d.ts +++ /dev/null @@ -1,16 +0,0 @@ -export default abstract class PluginClass { - private readonly el; - private $emitter; - private readonly _pluginName; - private readonly options; - private _initialized; - constructor(el: HTMLElement, options?: any, pluginName?: boolean | string); - private _init; - _update(): void; - abstract init(): void; - update(): void; - _registerInstance(): void; - private _getPluginName; - private _mergeOptions; - private parseJsonOrFail; -} diff --git a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/plugin.class.js b/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/plugin.class.js deleted file mode 100644 index d3728aac0..000000000 --- a/src/Resources/app/storefront/src_vendor/shopware-storefront-sdk/plugin-system/plugin.class.js +++ /dev/null @@ -1,123 +0,0 @@ -"use strict"; - -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : {"default": mod}; -}; - -Object.defineProperty(exports, "__esModule", {value: true}); - -var NativeEventEmitter_1 = __importDefault(require("./NativeEventEmitter")); - -var deepmerge_1 = __importDefault(require("deepmerge")); - -var PluginClass = /** @class */ (function () { - - function PluginClass(el, options, pluginName) { - - if (options === void 0) { - options = {}; - } - if (pluginName === void 0) { - pluginName = false; - } - this.el = el; - this.$emitter = new NativeEventEmitter_1.default(this.el); - this._pluginName = this._getPluginName(pluginName); - this.options = this._mergeOptions(options); - this._initialized = false; - this._registerInstance(); - this._init(); - } - - PluginClass.prototype._init = function () { - if (this._initialized) - return; - this.init(); - this._initialized = true; - }; - - PluginClass.prototype._update = function () { - if (!this._initialized) - return; - this.update(); - }; - - PluginClass.prototype.update = function () { - }; - - PluginClass.prototype._registerInstance = function () { - var elementPluginInstances = window.PluginManager.getPluginInstancesFromElement(this.el); - elementPluginInstances.set(this._pluginName, this); - var plugin = window.PluginManager.getPlugin(this._pluginName, false); - plugin.get('instances').push(this); - }; - - PluginClass.prototype._getPluginName = function (pluginName) { - if (pluginName === false) { - // @ts-ignore - return this.constructor.name; - } - return pluginName; - }; - - PluginClass.prototype._mergeOptions = function (options) { - var dashedPluginName = this._pluginName.replace(/([A-Z])/g, '-$1').replace(/^-/, '').toLowerCase(); - var dataAttributeConfig = this.parseJsonOrFail(dashedPluginName); - - let dataAttributeOptions = ''; - - if (typeof this.el.getAttribute === 'function') { - dataAttributeOptions = this.el.getAttribute("data-".concat(dashedPluginName, "-options")) || ''; - } - - // static plugin options - // previously merged options - // explicit options when creating a plugin instance with 'new' - var merge = [ - // @ts-ignore - this.constructor.options, - this.options, - options, - ]; - - // options which are set via data-plugin-name-config="config name" - if (dataAttributeConfig) { - merge.push(window.PluginConfigManager.get(this._pluginName, dataAttributeConfig)); - } - - // options which are set via data-plugin-name-options="{json..}" - try { - if (dataAttributeOptions) - merge.push(JSON.parse(dataAttributeOptions)); - } catch (e) { - throw new Error("The data attribute \"data-".concat(dashedPluginName, "-options\" could not be parsed to json: ").concat(e.message || '')); - } - - return deepmerge_1.default.all(merge.filter(function (config) { - return config instanceof Object && !(config instanceof Array); - }) - .map(function (config) { - return config || {}; - })); - }; - - PluginClass.prototype.parseJsonOrFail = function (dashedPluginName) { - - if (typeof this.el.getAttribute !== 'function') { - return ''; - } - - const value = this.el.getAttribute("data-".concat(dashedPluginName, "-config")) || ''; - - try { - return JSON.parse(value); - } catch (e) { - return value; - } - }; - - return PluginClass; - -}()); - -exports.default = PluginClass; diff --git a/src/Resources/app/storefront/webpack.config.js b/src/Resources/app/storefront/webpack.config.js index e2f5a76a7..bbaaa627d 100644 --- a/src/Resources/app/storefront/webpack.config.js +++ b/src/Resources/app/storefront/webpack.config.js @@ -1,5 +1,4 @@ const path = require('path') -const {resolve, join} = require("path"); module.exports = { mode: 'production', @@ -8,12 +7,4 @@ module.exports = { path: path.resolve(__dirname, '..', '..', 'public'), filename: 'mollie-payments.js', }, - resolve: { - extensions: ['.js'], - alias: { - '@shopware-storefront-sdk': resolve( - join(__dirname, 'src_vendor', 'shopware-storefront-sdk'), - ), - }, - }, } diff --git a/src/Resources/views/mollie/head.html.twig b/src/Resources/views/mollie/head.html.twig index 28d382a6c..72fe6c2c9 100644 --- a/src/Resources/views/mollie/head.html.twig +++ b/src/Resources/views/mollie/head.html.twig @@ -31,7 +31,7 @@ window.mollie_javascript_use_shopware = '{{ mollie_javascript_use_shopware }}' - {% if mollie_javascript_already_exists == false and mollie_javascript_use_shopware != '1' and includeJsInHeader == true %} + {% if mollie_javascript_use_shopware != '1' and includeJsInHeader == true %} {% endif %} diff --git a/src/Subscriber/StorefrontBuildSubscriber.php b/src/Subscriber/StorefrontBuildSubscriber.php index f29d977e1..b7eb4e34f 100644 --- a/src/Subscriber/StorefrontBuildSubscriber.php +++ b/src/Subscriber/StorefrontBuildSubscriber.php @@ -59,11 +59,5 @@ public function onStorefrontRender(StorefrontRenderEvent $event): void $useJsValue = (int)$settings->isUseShopwareJavascript(); $event->setParameter('mollie_javascript_use_shopware', $useJsValue); - $mollieJavascriptAlreadyExists = false; - if ($this->versionCompare->gte('6.6')) { - $molliePayments = $this->pluginRegistry->getConfigurations()->getByTechnicalName('MolliePayments'); - $mollieJavascriptAlreadyExists = $molliePayments && ($molliePayments->getScriptFiles()->count() > 0); - } - $event->setParameter('mollie_javascript_already_exists', $mollieJavascriptAlreadyExists); } }