@wix/origami-site 1.0.56 → 1.0.58
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": "1.0.
|
|
3
|
+
"version": "1.0.58",
|
|
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": [
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@wix/origami-types": "1.4.
|
|
49
|
+
"@wix/origami-types": "1.4.5",
|
|
50
50
|
"@wix/builder-error-pages": "^1.1.6",
|
|
51
51
|
"@wix/origami-transforms": "0.1.61",
|
|
52
52
|
"@babel/parser": "^7.25.0",
|
|
53
|
-
"@wix/origami-services": "1.2.
|
|
53
|
+
"@wix/origami-services": "1.2.9",
|
|
54
54
|
"@wix/services-manager-react": "^1.0.8",
|
|
55
55
|
"@wix/origami-bi": "0.24.0"
|
|
56
56
|
},
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"optional": true
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
|
-
"falconPackageHash": "
|
|
96
|
+
"falconPackageHash": "586bb54b6049b1338cedc323f4094dec6062cef5af337338d39d78fc"
|
|
97
97
|
}
|
|
@@ -41,6 +41,12 @@ export function pageServicesConfigs(table, served) {
|
|
|
41
41
|
const home = pages[HOME]
|
|
42
42
|
const appDefinitionIdBySlug = new Map(table.routers.flatMap(router =>
|
|
43
43
|
Object.values(router.rolePages).map(rolePage => [rolePage.slug, router.config.appDefinitionId])))
|
|
44
|
+
// An app's page, by the id its app knows it by: appSectionRelativeUrl() finds it by this and appDefinitionId.
|
|
45
|
+
/** @type {Map<string, string>} */
|
|
46
|
+
const tpaPageIdBySlug = new Map()
|
|
47
|
+
for (const route of table.pages) if (route.tpaPageId) tpaPageIdBySlug.set(pageSlug(route), route.tpaPageId)
|
|
48
|
+
for (const router of table.routers)
|
|
49
|
+
for (const rolePage of Object.values(router.rolePages)) if (rolePage.tpaPageId) tpaPageIdBySlug.set(rolePage.slug, rolePage.tpaPageId)
|
|
44
50
|
return {
|
|
45
51
|
'@wix/site-service-pages': {
|
|
46
52
|
pages,
|
|
@@ -56,7 +62,9 @@ export function pageServicesConfigs(table, served) {
|
|
|
56
62
|
'@wix/site-service-url': {
|
|
57
63
|
// As thunderbolt: popups aren't app sections, and a section's URL is `/` and its slug.
|
|
58
64
|
pages: Object.entries(pages).filter(([, page]) => !page.popup).map(([id]) => ({
|
|
59
|
-
id, url: `/${id}`,
|
|
65
|
+
id, url: `/${id}`,
|
|
66
|
+
...(tpaPageIdBySlug.has(id) ? { tpaPageId: tpaPageIdBySlug.get(id) } : {}),
|
|
67
|
+
...(appDefinitionIdBySlug.has(id) ? { appDefinitionId: appDefinitionIdBySlug.get(id) } : {}),
|
|
60
68
|
})),
|
|
61
69
|
pageIdToPrefix: Object.fromEntries(table.routers.flatMap(router =>
|
|
62
70
|
Object.values(router.rolePages).map(rolePage => [rolePage.slug, router.prefix]))),
|
|
@@ -6,12 +6,21 @@ import { findItems, pageUrl } from '@wix/origami-types'
|
|
|
6
6
|
import { SiteTreeError } from '../requests/errors.js'
|
|
7
7
|
import { readRouteJsons } from './routeJson.js'
|
|
8
8
|
|
|
9
|
-
/** @type {Map<string, { mtimeMs: number, metadata: { title?: string, pageId?: string } }>} */
|
|
9
|
+
/** @type {Map<string, { mtimeMs: number, metadata: { title?: string, pageId?: string, tpaPageId?: string } }>} */
|
|
10
10
|
const metadataCache = new Map()
|
|
11
11
|
|
|
12
|
+
/** The string value of an object literal's `key`, or undefined when it has none or the value isn't a string literal. */
|
|
13
|
+
const stringProperty = (properties, key) => {
|
|
14
|
+
const property = properties.find(candidate =>
|
|
15
|
+
candidate.type === 'ObjectProperty' && !candidate.computed &&
|
|
16
|
+
((candidate.key.type === 'Identifier' && candidate.key.name === key) ||
|
|
17
|
+
(candidate.key.type === 'StringLiteral' && candidate.key.value === key)))
|
|
18
|
+
return property?.value.type === 'StringLiteral' ? property.value.value : undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
const readMetadata = structure => {
|
|
13
22
|
const ast = parse(readFileSync(structure, 'utf8'), { sourceType: 'module', plugins: ['jsx'] })
|
|
14
|
-
/** @type {{ title?: string, pageId?: string }} */
|
|
23
|
+
/** @type {{ title?: string, pageId?: string, tpaPageId?: string }} */
|
|
15
24
|
const metadata = {}
|
|
16
25
|
// Walk Babel's AST without a runtime dependency on @babel/types.
|
|
17
26
|
const visit = node => {
|
|
@@ -24,11 +33,12 @@ const readMetadata = structure => {
|
|
|
24
33
|
if (metadata.title !== undefined || attribute.name.name !== 'data' ||
|
|
25
34
|
attribute.value?.type !== 'JSXExpressionContainer' ||
|
|
26
35
|
attribute.value.expression.type !== 'ObjectExpression') continue
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
const { properties } = attribute.value.expression
|
|
37
|
+
const title = stringProperty(properties, 'title')
|
|
38
|
+
if (title !== undefined) metadata.title = title
|
|
39
|
+
// An app's page names itself to the URL service by it; a page that isn't an app's has none, or ''.
|
|
40
|
+
const tpaPageId = stringProperty(properties, 'tpaPageId')
|
|
41
|
+
if (tpaPageId && metadata.tpaPageId === undefined) metadata.tpaPageId = tpaPageId
|
|
32
42
|
}
|
|
33
43
|
}
|
|
34
44
|
for (const value of Object.values(node)) {
|
|
@@ -82,7 +92,7 @@ function readRouter(folder, itemPath, entries, items) {
|
|
|
82
92
|
const others = children.filter(child => !isBracket(child.name))
|
|
83
93
|
if (others.length)
|
|
84
94
|
throw new SiteTreeError('PREFIX_COLLIDES_WITH_PAGE', others.map(child => `${path}/${child.name}`), `Every URL under /${prefix} goes to the Wix router, so it can't hold other pages.`)
|
|
85
|
-
/** @type {{ slug: string, itemPath: string, path: string, file: string, title: string }[]} */
|
|
95
|
+
/** @type {{ slug: string, itemPath: string, path: string, file: string, title: string, tpaPageId?: string }[]} */
|
|
86
96
|
const roleFolders = []
|
|
87
97
|
for (const child of children) {
|
|
88
98
|
const childPath = `${path}/${child.name}`
|
|
@@ -96,10 +106,10 @@ function readRouter(folder, itemPath, entries, items) {
|
|
|
96
106
|
// Without them the browser would import a page entry that doesn't exist, once the router picks this page.
|
|
97
107
|
if (!hasPageFiles(childEntries.filter(entry => entry.name !== 'route.json')))
|
|
98
108
|
throw new SiteTreeError('ROLE_PAGE_HAS_NO_FILES', [childPath], 'This [page] folder has a route.json but no page files.')
|
|
109
|
+
const { title, tpaPageId } = pageMetadata(childFolder)
|
|
99
110
|
roleFolders.push({
|
|
100
111
|
slug: child.name.slice(1, -1), itemPath: `${itemPath}/${child.name}`, path: childPath,
|
|
101
|
-
file: resolve(childFolder, 'route.json'),
|
|
102
|
-
title: pageMetadata(childFolder).title,
|
|
112
|
+
file: resolve(childFolder, 'route.json'), title, ...(tpaPageId ? { tpaPageId } : {}),
|
|
103
113
|
})
|
|
104
114
|
}
|
|
105
115
|
const config = readRouteJsons(roleFolders.map(({ slug, file, path }) => ({ slug, file, path: `${path}/route.json` })))
|
|
@@ -111,7 +121,10 @@ function readRouter(folder, itemPath, entries, items) {
|
|
|
111
121
|
const folder = roleFolders.find(candidate => candidate.slug === slug)
|
|
112
122
|
if (!folder) throw new SiteTreeError('ROLE_FOLDER_MISSING', [`${path}/[${slug}]`], `route.json names the "${role}" page "${slug}", but there is no [${slug}] folder.`)
|
|
113
123
|
const pageId = config.pageIds?.[role]
|
|
114
|
-
rolePages[role] = {
|
|
124
|
+
rolePages[role] = {
|
|
125
|
+
key: folder.itemPath, role, slug, itemPath: folder.itemPath, title: folder.title, access: [],
|
|
126
|
+
...(pageId ? { pageId } : {}), ...(folder.tpaPageId ? { tpaPageId: folder.tpaPageId } : {}),
|
|
127
|
+
}
|
|
115
128
|
}
|
|
116
129
|
return { key: itemPath, prefix, config, rolePages }
|
|
117
130
|
}
|
|
@@ -154,8 +167,11 @@ export const readSiteTree = async root => {
|
|
|
154
167
|
if (inBrokenRouter(itemPath) || routers.some(router => Object.values(router.rolePages).some(page => page.itemPath === itemPath))) continue
|
|
155
168
|
const path = `src/${itemPath}`
|
|
156
169
|
const metadata = pageMetadata(resolve(src, itemPath))
|
|
157
|
-
if (itemPath === 'pages/error404')
|
|
158
|
-
|
|
170
|
+
if (itemPath === 'pages/error404') {
|
|
171
|
+
// The 404 page isn't an app section.
|
|
172
|
+
const { tpaPageId: _, ...notFoundMetadata } = metadata
|
|
173
|
+
notFound = { key: itemPath, itemPath, ...notFoundMetadata }
|
|
174
|
+
} else {
|
|
159
175
|
const url = pageUrl(itemPath)
|
|
160
176
|
const previous = pathsByUrl.get(url)
|
|
161
177
|
if (previous) throw new SiteTreeError('DUPLICATE_URL', [previous, path], `Both pages serve "${url}".`)
|