@wix/origami-site 1.1.0 → 1.2.0
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.
- package/package.json +5 -5
- package/src/browser/index.js +3 -1
- package/src/popups/controller.js +34 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/origami-site",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Runs an exported Wix origami site: file-based routing, Wix dynamic pages, popups and build checks. Use with @wix/origami-site-astro or @wix/origami-site-express.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@wix/origami-types": "^1.5.0",
|
|
50
50
|
"@wix/builder-error-pages": "^1.1.6",
|
|
51
|
-
"@wix/origami-transforms": "^0.1.
|
|
51
|
+
"@wix/origami-transforms": "^0.1.67",
|
|
52
52
|
"@babel/parser": "^7.25.0",
|
|
53
|
-
"@wix/origami-services": "^1.
|
|
53
|
+
"@wix/origami-services": "^1.4.0",
|
|
54
54
|
"@wix/services-manager-react": "^1.0.8",
|
|
55
|
-
"@wix/origami-bi": "^0.24.
|
|
55
|
+
"@wix/origami-bi": "^0.24.2"
|
|
56
56
|
},
|
|
57
57
|
"exports": {
|
|
58
58
|
"./server": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"optional": true
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
-
"falconPackageHash": "
|
|
96
|
+
"falconPackageHash": "6649a721555d393e583d946ebf521346e9b8cd1f61080ed1105ec9fa"
|
|
97
97
|
}
|
package/src/browser/index.js
CHANGED
|
@@ -65,6 +65,9 @@ export async function mountPage(element, { pages, popups = {}, seoUriByPageId =
|
|
|
65
65
|
userAgent: navigator.userAgent, reducedMotion: globalThis.matchMedia?.('(prefers-reduced-motion: reduce)').matches,
|
|
66
66
|
})
|
|
67
67
|
sealServicesConfigs()
|
|
68
|
+
// Before the page renders, so a reload's reset of the popups shown this visit and `?popup=`'s mark come before the
|
|
69
|
+
// page's auto-open reads them. PopupHost reads the controller when it mounts.
|
|
70
|
+
if (hasPopups) startPopups()
|
|
68
71
|
const root = createRoot(element)
|
|
69
72
|
// #main_MF is the container-query root: editor-components' `--one-unit: 1cqw` resolves against it.
|
|
70
73
|
// PopupHost sits inside it too, so popups share the page's services and container-query root.
|
|
@@ -72,7 +75,6 @@ export async function mountPage(element, { pages, popups = {}, seoUriByPageId =
|
|
|
72
75
|
createElement(Page), hasPopups ? createElement(PopupHost) : null)
|
|
73
76
|
root.render(createElement(StrictMode, null, createElement(WixServices, { servicesMap: map, children: main })))
|
|
74
77
|
if (!hasPopups) return () => root.unmount()
|
|
75
|
-
startPopups()
|
|
76
78
|
document.addEventListener('click', onPopupLinkClick)
|
|
77
79
|
return () => {
|
|
78
80
|
document.removeEventListener('click', onPopupLinkClick)
|
package/src/popups/controller.js
CHANGED
|
@@ -62,8 +62,40 @@ export const lightboxConfig = {
|
|
|
62
62
|
getPayload: () => current?.payload,
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* Opens the popup a `?popup=<seoUri>` URL names, right away and every time. Opening never changes the URL. It marks the
|
|
67
|
+
* popup shown for this visit so the page's auto-open doesn't open it again. mountPage calls it on every page load
|
|
68
|
+
* before the page renders, so it also resets shown markers on refresh before the page reads them.
|
|
69
|
+
*/
|
|
66
70
|
export function startPopups() {
|
|
71
|
+
forgetShownOnReload()
|
|
67
72
|
const seoUri = new URL(location.href).searchParams.get('popup')
|
|
68
|
-
if (seoUri)
|
|
73
|
+
if (!seoUri) return
|
|
74
|
+
const key = SHOWN_PREFIX + seoUri
|
|
75
|
+
markShown(key)
|
|
76
|
+
openPopup(seoUri).catch(error => {
|
|
77
|
+
forgetShown(key)
|
|
78
|
+
console.warn(`Cannot open ?popup=${seoUri}:`, error)
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const SHOWN_PREFIX = 'wix-auto-popup-shown-'
|
|
83
|
+
|
|
84
|
+
// Refresh starts a new popup visit across the site, so clear all popup shown markers.
|
|
85
|
+
// Normal navigation and Back preserve them. Run before the page checks whether to auto-open.
|
|
86
|
+
function forgetShownOnReload() {
|
|
87
|
+
try {
|
|
88
|
+
if (!performance.getEntriesByType?.('navigation').some(entry => /** @type {PerformanceNavigationTiming} */ (entry).type === 'reload')) return
|
|
89
|
+
for (const key of Object.keys(sessionStorage)) if (key.startsWith(SHOWN_PREFIX)) sessionStorage.removeItem(key)
|
|
90
|
+
} catch {}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** @param {string} key */
|
|
94
|
+
function markShown(key) {
|
|
95
|
+
try { sessionStorage.setItem(key, 'true') } catch {}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** @param {string} key */
|
|
99
|
+
function forgetShown(key) {
|
|
100
|
+
try { sessionStorage.removeItem(key) } catch {}
|
|
69
101
|
}
|