@wix/origami-site 0.1.9 → 0.1.11

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.9",
3
+ "version": "0.1.11",
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": [
@@ -43,12 +43,12 @@
43
43
  }
44
44
  },
45
45
  "dependencies": {
46
- "@wix/origami-types": "1.2.0",
46
+ "@wix/origami-types": "1.3.0",
47
47
  "react": "^18.3.1",
48
48
  "react-dom": "^18.3.1",
49
49
  "@wix/builder-error-pages": "^1.1.6",
50
50
  "@wix/builder-piler-components": "^1.6.7",
51
- "@wix/origami-transforms": "0.1.7",
51
+ "@wix/origami-transforms": "0.1.8",
52
52
  "@babel/parser": "^7.25.0"
53
53
  },
54
54
  "exports": {
@@ -79,5 +79,5 @@
79
79
  "peerDependencies": {
80
80
  "vite": "^8"
81
81
  },
82
- "falconPackageHash": "2972bc6c393f95c8d5a0dcd44a3e9afdd4fc110b3f45d9b6e0bdcc66"
82
+ "falconPackageHash": "24c3e9be28422eca894ae970057d12bb43ca7f2b2231d6a51421ada9"
83
83
  }
@@ -4,6 +4,8 @@ import { basename, resolve } from 'node:path'
4
4
  import { parse } from '@babel/parser'
5
5
  import { SiteTreeError } from '../requests/errors.js'
6
6
 
7
+
8
+
7
9
  /** @type {Map<string, { mtimeMs: number, metadata: { title?: string, pageId?: string } }>} */
8
10
  const metadataCache = new Map()
9
11
 
@@ -66,32 +68,38 @@ export const readSiteTree = async root => {
66
68
  const pages = []
67
69
  /** @type {import('@wix/origami-types').SiteNotFoundRoute} */
68
70
  let notFound = { key: '@wix/origami-site/default-error-404', title: 'Page not found' }
69
- const pathsByUrl = new Map()
70
71
  const walk = (folder, itemPath) => {
71
72
  const entries = readdirSync(folder, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))
72
73
  const path = `src/${itemPath}`
73
- if (/^\[.*\]$/.test(basename(folder)))
74
- throw new SiteTreeError('NOT_SUPPORTED_YET', [path], 'Router pages are not supported yet.')
75
- if (entries.some(entry => entry.name === 'route.json'))
76
- throw new SiteTreeError('NOT_SUPPORTED_YET', [`${path}/route.json`], 'Router pages are not supported yet.')
77
- const children = entries.filter(entry => entry.isDirectory() && !entry.name.startsWith('.') &&
78
- !['_generated', 'node_modules'].includes(entry.name))
79
- if (itemPath === 'pages/error404' && children.length)
80
- throw new SiteTreeError('NOT_FOUND_HAS_CHILDREN', [path, ...children.map(child => `${path}/${child.name}`)],
81
- 'The not-found page cannot have children.')
82
- if (entries.some(entry => entry.isFile() && !entry.name.startsWith('.'))) {
74
+ const isItem = entries.some(entry => entry.isFile() && entry.name === 'version')
75
+ if (isItem) {
83
76
  const metadata = pageMetadata(folder)
84
77
  if (itemPath === 'pages/error404') notFound = { key: itemPath, itemPath, title: metadata.title }
85
78
  else {
86
79
  const url = '/' + itemPath.split('/').slice(1).filter(segment => !/^\([^()]+\)$/.test(segment)).join('/')
87
- const previous = pathsByUrl.get(url)
88
- if (previous) throw new SiteTreeError('DUPLICATE_URL', [previous, path], `Both pages serve "${url}".`)
89
- pathsByUrl.set(url, path)
90
80
  pages.push({ key: itemPath, url, itemPath, ...metadata, access: [] })
91
81
  }
92
82
  }
93
- for (const child of children) walk(resolve(folder, child.name), `${itemPath}/${child.name}`)
83
+ const children = entries.filter(entry => entry.isDirectory() && !entry.name.startsWith('.') &&
84
+ !['_generated', 'node_modules', 'servicesConfigs'].includes(entry.name))
85
+ .filter(child => walk(resolve(folder, child.name), `${itemPath}/${child.name}`))
86
+ if (!isItem && !children.length) return false
87
+ if (/^\[.*\]$/.test(basename(folder)))
88
+ throw new SiteTreeError('NOT_SUPPORTED_YET', [path], 'Router pages are not supported yet.')
89
+ if (entries.some(entry => entry.name === 'route.json'))
90
+ throw new SiteTreeError('NOT_SUPPORTED_YET', [`${path}/route.json`], 'Router pages are not supported yet.')
91
+ if (itemPath === 'pages/error404' && children.length)
92
+ throw new SiteTreeError('NOT_FOUND_HAS_CHILDREN', [path, ...children.map(child => `${path}/${child.name}`)],
93
+ 'The not-found page cannot have children.')
94
+ return true
94
95
  }
95
96
  if (existsSync(pagesDir)) walk(pagesDir, 'pages')
97
+ const pathsByUrl = new Map()
98
+ for (const page of pages) {
99
+ const path = `src/${page.itemPath}`
100
+ const previous = pathsByUrl.get(page.url)
101
+ if (previous) throw new SiteTreeError('DUPLICATE_URL', [previous, path], `Both pages serve "${page.url}".`)
102
+ pathsByUrl.set(page.url, path)
103
+ }
96
104
  return { version: 2, pages, routers: [], notFound, popups: [] }
97
105
  }