@wix/origami-site 0.1.19 → 0.1.21
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wix/origami-site",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
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,9 +48,11 @@
|
|
|
48
48
|
"@wix/origami-types": "1.4.0",
|
|
49
49
|
"@wix/builder-error-pages": "^1.1.6",
|
|
50
50
|
"@wix/builder-piler-components": "^1.6.7",
|
|
51
|
-
"@wix/origami-transforms": "0.1.
|
|
51
|
+
"@wix/origami-transforms": "0.1.12",
|
|
52
52
|
"@babel/parser": "^7.25.0",
|
|
53
|
-
"@wix/system-core-components": "^1.3.10"
|
|
53
|
+
"@wix/system-core-components": "^1.3.10",
|
|
54
|
+
"@wix/origami-services": "1.0.0",
|
|
55
|
+
"@wix/services-manager-react": "^1.0.8"
|
|
54
56
|
},
|
|
55
57
|
"exports": {
|
|
56
58
|
"./server": {
|
|
@@ -91,5 +93,5 @@
|
|
|
91
93
|
"optional": true
|
|
92
94
|
}
|
|
93
95
|
},
|
|
94
|
-
"falconPackageHash": "
|
|
96
|
+
"falconPackageHash": "e514bdb7045f0acc5bb6538bca6aa81fdd740d9a7d70429ebf1309b5"
|
|
95
97
|
}
|
package/src/browser/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createElement, StrictMode } from 'react'
|
|
2
2
|
import { createRoot } from 'react-dom/client'
|
|
3
|
+
import { registeredServicesConfigs, sealServicesConfigs } from '@wix/origami-services/internal'
|
|
4
|
+
import { servicesMap } from '@wix/origami-services'
|
|
5
|
+
import { WixServices } from '@wix/services-manager-react'
|
|
3
6
|
import { PilerPage } from '@wix/builder-piler-components'
|
|
4
7
|
|
|
5
8
|
let hasReadPageData = false
|
|
@@ -49,9 +52,13 @@ export async function mountPage(element, { pages, beforeMount }) {
|
|
|
49
52
|
} catch (error) {
|
|
50
53
|
console.error(error)
|
|
51
54
|
}
|
|
52
|
-
//
|
|
55
|
+
// Loading the page registers its globals and own DM configs before services are created.
|
|
53
56
|
const { default: Page } = await loadPage()
|
|
57
|
+
const map = servicesMap({ servicesConfigs: registeredServicesConfigs(), requestConfigs: data?.services ?? {}, url: location.href })
|
|
58
|
+
sealServicesConfigs()
|
|
54
59
|
const root = createRoot(element)
|
|
55
|
-
|
|
60
|
+
// Stage 3: PopupHost belongs inside WixServices so popups share page services.
|
|
61
|
+
root.render(createElement(StrictMode, null,
|
|
62
|
+
createElement(WixServices, { servicesMap: map, children: createElement(PilerPage, { Page }) })))
|
|
56
63
|
return () => root.unmount()
|
|
57
64
|
}
|
|
@@ -79,7 +79,9 @@ export async function createSite(options) {
|
|
|
79
79
|
* @param {import('../index.js').PageData['route']} routeData @param {Record<string, unknown>} services @param {HeadersInit} [headers] */
|
|
80
80
|
function pageResolution(route, status, routeData, services = {}, headers = {}) {
|
|
81
81
|
const page = { key: route.key, title: route.title, ...(route.itemPath === undefined ? {} : { itemPath: route.itemPath }) }
|
|
82
|
-
|
|
82
|
+
// Identity and dynamic-route configs use different services; merge per service if server layers ever overlap.
|
|
83
|
+
const identity = wix.siteId ? { '@wix/viewer-service-environment': { metaSiteId: wix.siteId } } : {}
|
|
84
|
+
return { kind: /** @type {const} */ ('page'), status, page, data: { page: page.key, route: routeData, services: { ...identity, ...services } }, headers: new Headers(headers) }
|
|
83
85
|
}
|
|
84
86
|
/** @param {Extract<import('../index.js').RouteMatch, { kind: 'router' }>} match @param {URL} url @param {string} path */
|
|
85
87
|
async function resolveRouter(match, url, path, current, request, context) {
|
|
@@ -109,11 +111,8 @@ export async function createSite(options) {
|
|
|
109
111
|
const { status, statusText, body } = denied.response
|
|
110
112
|
return { kind: /** @type {const} */ ('response'), response: new Response(body, { status, statusText, headers }) }
|
|
111
113
|
}
|
|
112
|
-
const externalBaseUrl = url.origin
|
|
113
114
|
return pageResolution(rolePage, 200, { kind: 'router', url: path, role: rolePage.role }, {
|
|
114
115
|
'@wix/viewer-service-dynamic-route': { dynamicRouteData: { pageData: answer.data, publicData: answer.publicData } },
|
|
115
|
-
'@wix/site-service-url': { externalBaseUrl },
|
|
116
|
-
'@wix/viewer-service-url': { externalBaseUrl },
|
|
117
116
|
}, noStore)
|
|
118
117
|
}
|
|
119
118
|
return {
|