From 1acc8f67d0c80b44b40a7d8df407f57746f8c44e Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Wed, 1 Nov 2023 18:32:00 +0100 Subject: [PATCH 1/2] TASK: Use @private instead of nested components This will avoid the instantiation of a level of fusion objects and thus should improve performance --- .editorconfig | 22 +++++ .../Private/Fusion/Prototypes/Image.fusion | 56 +++++------ .../Private/Fusion/Prototypes/Picture.fusion | 99 ++++++++----------- .../Private/Fusion/Prototypes/Source.fusion | 67 +++++++------ composer.json | 4 +- 5 files changed, 125 insertions(+), 123 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e722f3d --- /dev/null +++ b/.editorconfig @@ -0,0 +1,22 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +# Composer uses 4 spaces itself +[composer.json] +indent_size = 4 + +# PHP should follow the PSR-2 standard +[*.php] +indent_size = 4 + +# fusion uses 4 spaces itself +[*.fusion] +indent_size = 4 diff --git a/Resources/Private/Fusion/Prototypes/Image.fusion b/Resources/Private/Fusion/Prototypes/Image.fusion index 76f5a48..cbcbd36 100644 --- a/Resources/Private/Fusion/Prototypes/Image.fusion +++ b/Resources/Private/Fusion/Prototypes/Image.fusion @@ -127,41 +127,35 @@ prototype(Sitegeist.Kaleidoscope:Image) < prototype(Neos.Fusion:Component) { attributes = Neos.Fusion:DataStructure renderDimensionAttributes = true - renderer = Neos.Fusion:Component { - @if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + @private { + # detect scalable sources isScalableSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} # apply format, width and height to the imageSource imageSource = ${props.imageSource} - imageSource.@process.applyWidth = ${props.width ? value.withWidth(props.width) : value} - imageSource.@process.applyHeight = ${props.height ? value.withHeight(props.height) : value} + imageSource.@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + imageSource.@process.applyDimensions = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} + imageSource.@process.applyWidth = ${(props.width && !props.height) ? value.withWidth(props.width) : value} + imageSource.@process.applyHeight = ${(props.height && !props.width) ? value.withHeight(props.height) : value} imageSource.@process.applyFormat = ${props.format ? value.withFormat(props.format) : value} - - srcset = ${props.srcset} - sizes = ${props.sizes} - loading = ${props.loading} - alt = ${props.alt} - title = ${props.title} - class = ${props.class} - attributes = ${props.attributes} - renderDimensionAttributes = ${props.renderDimensionAttributes} - - renderer = afx` - {props.alt - ` } + + renderer = afx` + {props.alt + ` } diff --git a/Resources/Private/Fusion/Prototypes/Picture.fusion b/Resources/Private/Fusion/Prototypes/Picture.fusion index e62892e..1bf606d 100644 --- a/Resources/Private/Fusion/Prototypes/Picture.fusion +++ b/Resources/Private/Fusion/Prototypes/Picture.fusion @@ -78,65 +78,52 @@ prototype(Sitegeist.Kaleidoscope:Picture) < prototype(Neos.Fusion:Component) { __format = ${this.format} } - renderer = Neos.Fusion:Component { - @if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} - + @private { # apply format, width and height to the imageSource imageSource = ${props.imageSource} - imageSource.@process.applyWidth = ${props.width ? value.setWidth(props.width) : value} - imageSource.@process.applyHeight = ${props.height ? value.setHeight(props.height) : value} - imageSource.@process.applyFormat = ${props.format ? value.setFormat(props.format) : value} - - srcset = ${props.srcset} - sizes = ${props.sizes} - loading = ${props.loading} - sources = ${props.sources} - formats = ${props.formats} - alt = ${props.alt} - title = ${props.title} - class = ${props.class} - attributes = ${props.attributes} - imgAttributes = ${props.imgAttributes} - content = ${props.content} - renderDimensionAttributes = ${props.renderDimensionAttributes} + imageSource.@if.has = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + imageSource.@process.applyDimensions = ${(props.width && props.height) ? value.withDimensions(props.width, props.height) : value} + imageSource.@process.applyWidth = ${(props.width && !props.height) ? value.withWidth(props.width) : value} + imageSource.@process.applyHeight = ${(props.height && !props.width) ? value.withHeight(props.height) : value} + imageSource.@process.applyFormat = ${props.format ? value.withFormat(props.format) : value} + } - renderer = afx` - - {props.content} - - - - - - - + {props.content} + + - - ` - } + + + + + + + ` } diff --git a/Resources/Private/Fusion/Prototypes/Source.fusion b/Resources/Private/Fusion/Prototypes/Source.fusion index 3939ed7..605f6e2 100644 --- a/Resources/Private/Fusion/Prototypes/Source.fusion +++ b/Resources/Private/Fusion/Prototypes/Source.fusion @@ -5,51 +5,50 @@ prototype(Sitegeist.Kaleidoscope:Source) < prototype(Neos.Fusion:Component) { } imageSource = null + imageSource.@process.contextFallback = ${value || __imageSource} + srcset = null + srcset.@process.contextFallback = ${value || __srcset} + sizes = null + sizes.@process.contextFallback = ${value || __sizes} + width = null + width.@process.contextFallback = ${value || __width} + height = null + height.@process.contextFallback = ${value || __height} + format = null + format.@process.contextFallback = ${value || __format} + type = null media = null renderDimensionAttributes = true - renderer = Neos.Fusion:Component { - - @context { - imageSource = ${props.imageSource || __imageSource} - format = ${props.format || __format} - width = ${props.width || __width} - height = ${props.height || __height} - srcset = ${props.srcset || __srcset} - sizes = ${props.sizes || __sizes} - } + @private { + isScalableSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} - @if.hasImageSource = ${imageSource && Type.instance(imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} - isScalableSource = ${imageSource && Type.instance(imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ScalableImageSourceInterface')} - - imageSource = ${imageSource} - imageSource.@process.applyWidth = ${width ? value.withWidth(width) : value} - imageSource.@process.applyHeight = ${height ? value.withHeight(height) : value} + imageSource = ${props.imageSource} + imageSource.@if.hasImageSource = ${props.imageSource && Type.instance(props.imageSource, '\\Sitegeist\\Kaleidoscope\\Domain\\ImageSourceInterface')} + imageSource.@process.applyDimensions = ${(width && height) ? value.withDimensions(width, height) : value} + imageSource.@process.applyWidth = ${(width && !height) ? value.withWidth(width) : value} + imageSource.@process.applyHeight = ${(height && !width) ? value.withHeight(height) : value} imageSource.@process.applyFormat = ${format ? value.withFormat(format) : value} - type = ${format ? 'image/' + format : props.type} - srcset = ${srcset} - sizes = ${sizes} - media = ${props.media} - renderDimensionAttributes = ${props.renderDimensionAttributes} - - renderer = afx` - - ` + type = ${props.format ? 'image/' + props.format : props.type} } + + renderer = afx` + + ` } diff --git a/composer.json b/composer.json index 09c223c..e30ef63 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,8 @@ "name": "sitegeist/kaleidoscope", "license": "GPL-3.0-or-later", "require": { - "neos/neos": "^7.0 || ^8.0 || ^9.0 || dev-master", - "neos/fusion-afx": "^7.0 || ^8.0 || ^9.0 || dev-master", + "neos/neos": "^8.3 || ^9.0 || dev-master", + "neos/fusion-afx": "^8.3 || ^9.0 || dev-master", "neos/media": "*", "neos/imagine": "*" }, From 781b7fba1f3ff8b22ac7a29d1606b8dcbc263536 Mon Sep 17 00:00:00 2001 From: Martin Ficzel Date: Fri, 27 Sep 2024 12:42:11 +0200 Subject: [PATCH 2/2] TASK: Adjust test matrix to Neos 8.3 and php 8.0 as minimal version --- .github/workflows/build.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f2e50bc..fa1e195 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,13 +13,9 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['8.0', '8.1'] + php-versions: ['8.0', '8.1', '8.2', '8.3'] neos-versions: ['8.3'] - include: - - php-versions: '7.4' - neos-versions: '7.3' - - php-versions: '8.0' - neos-versions: '8.0' + runs-on: ubuntu-latest steps: