Loki_Base
This module is available free of charge as part of the Loki Checkout Open Source plan. Please note that support for this module is not to be taken for granted though. If you want our dedicated help, opt for a paid plan instead.
Core
module.plan-free
Professional
Standard
Trial
PHP
8.2 - 8.5
Magento
2.4.6 - 2.4.9
CSP
Yes
Unit Tests
15
Integration Tests
71
Functional Tests
37
PHPStan
1
Magento PHPCS
7
License
OSL-3.0
Latest Release
1.3.2
This Magento 2 module forms the base of various other Loki solutions: Loki Checkout, Loki Admin Components, Loki Theme for Luma. It adds Alpine.js to the page, adds container-blocks for other scripts to be added, it adds its own frontend messaging component and its adds an Alpine store for both localStorage and messaging.
Notice: Most likely you do not install this module on its own, but require it through other modules.
Installation
composer require loki/magento2-base bin/magento module:enable Loki_Base
Current status
Magento 2 Unit Tests
success
Magento 2 Integration Tests
success
Magento 2 DI compilation
success
Magento 2 Static Tests
success
Playwright test
success
Magento 2 Static Tests
success
Magento 2 DI compilation
success
Playwright test
success
Magento 2 Integration Tests
success
Magento 2 Unit Tests
success
Support
For getting support, create an Issue under the following project URL:
https://github.com/LokiExtensions/Loki_Base
Configuration Options
The following options of this module can be configured via the Store Configuration:
Messages > Timeout
loki_base/messages/timeout
Whenever messages are popping up, they are automatically removed after this timeout. This is by default 5000ms (5 seconds).
Module Dependencies
The following dependencies are declared in the module its `etc/module.xml` file:
Loki_CssUtils
Magento_Backend
Magento_Csp
Magento_Directory
Magento_Store
Magento_Theme
Composer details
Magento module name
Loki_BaseComposer name
loki/magento2-baseComposer version
1.3.2
Default branch
master
Requirements
loki/magento2-css-utils: ^1.0
magento/framework: ^103.0
magento/module-backend: ^102.0
magento/module-store: ^101.0
php: >=8.2 <8.6
Releases
| 1.3.2 | 12 November 2026 |
| 1.3.1 | 12 November 2026 |
| 1.3.0 | 12 November 2026 |
| 1.2.2 | 12 November 2026 |
| 1.2.1 | 12 November 2026 |
| 1.2.0 | 12 November 2026 |
| 1.1.29 | 12 November 2026 |
| 1.1.28 | 12 November 2026 |
| 1.1.27 | 12 November 2026 |
| 1.1.26 | 12 November 2026 |
| 1.1.25 | 12 November 2026 |
| 1.1.24 | 12 November 2026 |
| 1.1.23 | 12 November 2026 |
| 1.1.22 | 12 November 2026 |
| 1.1.21 | 12 November 2026 |
| 1.1.20 | 12 November 2026 |
| 1.1.19 | 12 November 2026 |
| 1.1.18 | 12 November 2026 |
| 1.1.17 | 12 November 2026 |
| 1.1.16 | 12 November 2026 |
| 1.1.15 | 12 November 2026 |
| 1.1.14 | 12 November 2026 |
| 1.1.13 | 12 November 2026 |
| 1.1.12 | 12 November 2026 |
| 1.1.11 | 12 November 2026 |
| 1.1.10 | 12 November 2026 |
| 1.1.9 | 12 November 2026 |
| 1.1.8 | 12 November 2026 |
| 1.1.7 | 12 November 2026 |
| 1.1.6 | 12 November 2026 |
| 1.1.5 | 12 November 2026 |
| 1.1.4 | 12 November 2026 |
| 1.1.3 | 12 November 2026 |
| 1.1.2 | 12 November 2026 |
| 1.1.1 | 12 November 2026 |
| 1.1.0 | 12 November 2026 |
| 1.0.4 | 12 November 2026 |
| 1.0.3 | 12 November 2026 |
| 1.0.2 | 12 November 2026 |
| 1.0.1 | 12 November 2026 |
| 1.0.0 | 12 November 2026 |
Changelog
[1.3.2] - 29 October 2026
Fixed
- Use own block name as uniq ID for non-child blocks
[1.3.1] - 24 October 2026
Added
- Add
$ancestorViewModelto block rendered viaBlockRenderer,ChildRendererorTemplateRenderer(if available)
Fixed
- Pressing Escape only removed the first of multiple messages, because the unkeyed
x-forof the messages component removed the Escape listeners of the remaining messages while re-rendering - ACL resource
Loki_Base::configis now a child ofMagento_Backend::admininstead of a top-level sibling of it, which broke integration ACL resolution and hid it from restricted admin roles MageCookies.getAll()no longer truncates cookie values containing=(e.g. CookiebotCookieConsent)- Playwright test no longer depends on a checkout or catalog product (fails in CI)
script-container.phtmlfatal "Undefined variable $childRenderer" whenLoki_Componentsis not installed:LokiScriptnow assigns its ownChildRenderer- Message store argument
skip_cookieswas ignored, becausefetchCookieswas based onskip_local_storage - Invalid (non-array)
mage-messagescookie was not ignored, due to a wronginstanceof Arraycheck MageCookies.remove()did not remove cookies set with a cookie domain (the default, when no domain is configured Magento uses the current host)- Loki Alpine.js was loaded a second time on Hyvä pages with only
Loki_Base, breaking the Alpine components of the theme AbstractRenderer::populateBlock()fatal when no ancestor block was setMageCookies.set()added thesecureflag based on the HttpOnly setting, so browsers silently dropped every cookie on non-HTTPS pages. Thesecureflag is now only added on secure connectionsChildRenderer::any()andChildRenderer::all()skipped group children and containers that have an alias (as), because the layout name was passed togetChildHtml()as aliasChildRenderer::get()did not transfer ancestor properties (likecss_classes) to the child blockAbstractRenderer::populateBlock()ignored the given ancestor block for the ancestor block, ancestor view model and uniq ID, and used a stale ancestor of a previous call instead- Messages in the
messageslocalStorage section (including those stored withsaveMessage()) were never shown, because theLocalStoragestore was initialized before theMessagestore listened to its init event - LocalStorage sections invalidated by the server via the
section_data_idscookie were not purged - LocalStorage store crashed on invalid stored JSON
- One malformed URI-encoded cookie broke all of
MageCookies MageCookies.set()deleted cookies immediately with a cookie lifetime of 0 (browser session)x-safe-htmlallowedjavascript:links with different casing or whitespace, as well asvbscript:anddata:linksdeferargument of the Loki Alpine.js block had no effect (the script is still deferred by default)- Messages data ID was set in the future, doubling the section lifetime
[1.3.0] - 28 August 2026
Fixed
- Render containers via
ChildRenderer::html()as well
Added
- Add new
ChildRenderer::any()to allow for bothasandgroupchild references
[1.2.2] - 12 August 2026
Fixed
- Rename
alpine-csp.jstoalpine-csp.min.jsto avoidjshrinkissue - Add Loki icon to store configuration
- Change
Textfactory to constructor method - Guard
MageCookies.getAll()against non-JSON cookies @Maksold
[1.2.1] - 08 August 2026
Security
- Rewrite
x-htmltox-textbecause of CSP
[1.2.0] - 06 August 2026
Fixed
- Add new container
loki.script.post - Add message CSS class that is compatible with admin panel
[1.1.29] - 21 May 2026
Fixed
- Make sure multiple calls to
refresh()do not trigger multiple AJAX calls
[1.1.28] - 08 May 2026
Fixed
- Fix bug in Alpine localStorage when it is out of sync
[1.1.27] - 06 May 2026
Fixed
- Move data-child-name attribute to
LokiCheckout_Coreobserver
[1.1.26] - 06 May 2026
Fixed
- Add
data-child-nameattribute to blocks rendered via ChildRenderer
[1.1.25] - 06 May 2026
Fixed
- Do not reset sortOrder because of other mechanisms using previous values
- Reset sortOrder of childRenderer to avoid negatives
[1.1.24] - 28 March 2026
- Move TransferableAncestorBlockProperties from components to base
[1.1.23] - 27 March 2026
Fixed
- Allow properties of ancestor block to populate child block
[1.1.22] - 02 March 2026
Fixed
- Fix infinite loop and page freeze caused by async Alpine.effect
- Messages with timeout 0 were removed right away, instead of kept forever
[1.1.21] - 25 February 2026
Fixed
- Make call to LocalStorage.get async
[1.1.20] - 19 February 2026
Fixed
- Better way of rendering containers via ChildRenderer::all()
- Remove trailing slash from
customer/section/loadURL
[1.1.19] - 16 February 2026
Fixed
- Make
Alpine.store('LocalStorage').get()andrefresh()asynchronous
[1.1.18] - 12 February 2026
Fixed
- Allow PHP Config to read from current store level
- Allow filtering of child blocks by prefix
- Add ancestor block to children
[1.1.17] - 23 January 2026
Fixed
- Prevent empty cookie from causing JS error
[1.1.16] - 12 January 2026
Fixed
- Remove debugging console log
- Add new GitHub Action workflows
- Copy generic CI/CD files
- Copy generic CI/CD files
[1.1.15] - 06 January 2026
Fixed
- Disable messages if
MageOS_AlpineMessagesis enabled
[1.1.14] - 19 December 2025
Fixed
- Upgrade tests
- Cleanup duplicates in CHANGELOG
[1.1.13] - 11 December 2025
Fixed
- Move dependency ComponentViewModelInterface from
Loki_BasetoLoki_Components
[1.1.12] - 11 December 2025
Fixed
- Rename
LOKI_BASE_URLtoBASE_URL
[1.1.11] - 21 November 2025
Fixed
- Add compatibility with
MageOS_AlpineLoader - Replace
$block->getChildHtml()with$childRenderer->all()including better sorting - Automatically sync localStorage.setItem to Alpine store
[1.1.10] - 12 November 2025
Fixed
- Make sure component scripts are loaded after all other scripts
[1.1.9] - 12 November 2025
Fixed
- Rename LokiMessageStore to Message
- Only load MageCookies if
MageOS_AlpineLocalStorageis not enabled - Fix wrong template variable
- Rename LokiLocalStorage to LocalStorage
- Check for duplicate
MageOS_AlpineLocalStorage - Move layout that is duplicate to Mage-OS Alpine to separate handles
- Remove temporarily Tailwind LESS attempt
[1.1.8] - 03 November 2025
Fixed
- Change z-index for messages from 100 to 5
- Update composer keywords
[1.1.7] - 22 October 2025
Fixed
- Do not escape
$css()withescapeHtmlAttr()butescapeHtml()
[1.1.6] - 09 October 2025
Fixed
- Adjust messages under Luma from z-index:300 to 100 to prevent clash with minicart
[1.1.5] - 08 October 2025
Fixed
- Remove cookies by stripping all non-relevant cookie parts
- Change messages to position:sticky in Luma
[1.1.4] - 07 October 2025
Fixed
- Allow for JS translations of dates
[1.1.3] - 30 September 2025
Fixed
- Use new LOKI_THEME_URL variable in JS
[1.1.2] - 30 September 2025
Fixed
- Remove block cache lifetime
[1.1.1] - 29 September 2025
Fixed
- When removing cookies, ignore the domain-value
[1.1.0] - 23 September 2025
Added
- Add Loki Component exception as complex message
- Move messages timeout configuration from
Loki_ComponentstoLoki_Base - Add custom Block class that adds layout-name to cache key info
- Move frontend assets to base to allow for admin features
- Add custom event "loki:init:localstorage-store"
Fixed
- Remove redundant CSS classes from icon containers
- Reset message timeout to 5000
- Rename
loki.scriptfrom container to block to allow caching - Skip handling messages via cookies and localStorage under Hyva
- Rewrite transfer of global messages from components to be a lot simpler
- Rename loki-directive to loki.script.directive
- Rename loki-store to loki.script.store
- Rename loki-components to loki.script.component
- Rename loki-component-types to loki.script.component-type
- Rename loki-component-partials to loki.script.component-partial
- Cleanup duplicate containers, move to
Loki_Base
[1.0.4] - 17 September 2025
Fixed
- Re-add styling of buttons
[1.0.3] - 17 September 2025
Fixed
- Really move all LESS away from CSS folder
[1.0.2] - 17 September 2025
Fixed
- Move experimental LESS sources away from compilation
- Remove console.log message
- Remove dep with
Loki_Components
[1.0.1] - 17 September 2025
Fixed
- Disable Tailwind for LESS for now (experimental)
[1.0.0] - 17 September 2025
Fixed
- Add LESS sources
- Prevent weird mage-messages cookie value from breaking things
- New ViewModel
- Properly implement section invalidation from Luma customerData JS
- Always use get('messages') when retrieving message section from store
- Remove expired sections in localStorage
- Remove messages with ESC
- Add box shadow to messages
- Sef long lifetime on
user_allowed_save_cookiecookie - Fix CSP compliance of message timeout
- Better notice colors under Luma
- Better API for cookies and messaging
- Fix mobile menu
- Correct padding of message close button under Luma
- Set timeout to 10000
- Move LokiComponents global messages to regular messages template
- Add to both Hyva and Luma
- Add SVG and click button to remove message
- Add close X
- Autoremove messages or double-click to remove
- Copy generic CI/CD files
- Adding all files to git via Yireo Command
[0.0.1] - 13 September 2025
Added
- Initial release
Last modified: June 1, 2026