mkfashion-sdk 2.3.3 → 2.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mkfashion-sdk",
3
- "version": "2.3.3",
3
+ "version": "2.3.4",
4
4
  "description": "SDK para integrar o provador virtual mKFashion com suporte a Wake Commerce",
5
5
  "main": "src/mkfashion.js",
6
6
  "scripts": {
package/src/mkfashion.js CHANGED
@@ -661,4 +661,27 @@ const mkfashion = {
661
661
 
662
662
  if (typeof window !== 'undefined') {
663
663
  window.mkfashion = mkfashion
664
+
665
+ // Auto-init: abre automaticamente se a URL do site pai tiver startInit=true
666
+ const _mkAutoInit = () => {
667
+ const params = new URLSearchParams(window.location.search)
668
+ if (params.get('startInit') !== 'true') return
669
+
670
+ const projectId = params.get('projectId') || params.get('projectid')
671
+ const identifier = params.get('identifier') || params.get('sku')
672
+
673
+ if (!projectId || !identifier) {
674
+ console.error('[mKFashion] Auto-init requer projectId e identifier na URL')
675
+ return
676
+ }
677
+
678
+ mkfashion._log('Auto-init detectado', { projectId, identifier })
679
+ mkfashion.open({ projectId, identifier })
680
+ }
681
+
682
+ if (document.readyState === 'loading') {
683
+ document.addEventListener('DOMContentLoaded', _mkAutoInit)
684
+ } else {
685
+ _mkAutoInit()
686
+ }
664
687
  }