@wix/origami-site 1.3.0 → 1.3.1

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.3.0",
3
+ "version": "1.3.1",
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,13 +46,13 @@
46
46
  }
47
47
  },
48
48
  "dependencies": {
49
- "@wix/origami-types": "^1.6.0",
49
+ "@wix/origami-types": "^2.0.0",
50
50
  "@wix/builder-error-pages": "^1.1.6",
51
- "@wix/origami-transforms": "^0.1.68",
51
+ "@wix/origami-transforms": "^0.1.71",
52
52
  "@babel/parser": "^7.25.0",
53
- "@wix/origami-services": "^1.5.0",
53
+ "@wix/origami-services": "^1.5.2",
54
54
  "@wix/services-manager-react": "^1.0.8",
55
- "@wix/origami-bi": "^0.24.3"
55
+ "@wix/origami-bi": "^0.24.5"
56
56
  },
57
57
  "exports": {
58
58
  "./server": {
@@ -93,5 +93,5 @@
93
93
  "optional": true
94
94
  }
95
95
  },
96
- "falconPackageHash": "09ae6a964d9f9113b5dcb7e680c5cee48e6d1c06ef7877437be99a31"
96
+ "falconPackageHash": "a57028ec6abbc814695c28a1fbc23be9d145f49c32358f8f0fef93b0"
97
97
  }
@@ -11,7 +11,7 @@ export type MountPageOptions = {
11
11
  beforeMount: () => Promise<unknown>
12
12
  /** The site's meta site id, from `VITE_WIX_METASITE_ID`. Services get no site identity without it. */
13
13
  siteId?: string
14
- /** Renders around the page, once, at the root: the site passes the provider of src/global/allPages. Not around popups. */
14
+ /** Renders around the page, once, at the root: the site passes the provider of src/global/pagesContext. Not around popups. */
15
15
  wrapPage?: (page: ReactNode) => ReactNode
16
16
  }
17
17
  export function mountPage(element: Element | null, options: MountPageOptions): Promise<() => void>
@@ -15,7 +15,7 @@ function moduleSource(table) {
15
15
  ` [${JSON.stringify(popup.seoUri)}]: { title: ${JSON.stringify(popup.title)}, load: () => import(${JSON.stringify(`/src/${popup.itemPath}/_generated/index.jsx`)}) }`)
16
16
  // lightbox.open({ pageId }) names a popup by its Wix page id, as a Wix Forms form stores it.
17
17
  const seoUriByPageId = Object.fromEntries(table.popups.flatMap(popup => (popup.pageId ? [[popup.pageId, popup.seoUri]] : [])))
18
- return `export const pages = {\n${entries.join(',\n')}\n};\nexport const popups = {\n${popups.join(',\n')}\n};\nexport const seoUriByPageId = ${JSON.stringify(seoUriByPageId)};\nexport const allPages = ${JSON.stringify(table.allPages ?? {})};\n`
18
+ return `export const pages = {\n${entries.join(',\n')}\n};\nexport const popups = {\n${popups.join(',\n')}\n};\nexport const seoUriByPageId = ${JSON.stringify(seoUriByPageId)};\nexport const pagesContext = ${JSON.stringify(table.pagesContext ?? {})};\n`
19
19
  }
20
20
 
21
21
  /** @param {import('./index.js').OrigamiVitePluginsOptions['siteTree']} siteTree
@@ -13,10 +13,10 @@ export class SiteTreeError extends Error {
13
13
  | 'PREFIX_COLLIDES_WITH_PAGE' // pages/team is both a page and a prefix
14
14
  | 'NOT_FOUND_HAS_CHILDREN'
15
15
  | 'POPUP_NOT_TOP_LEVEL' // a popup folder not directly in src/popups
16
- | 'ALL_PAGES_INVALID' // src/global/allPages/index.ts isn't data only, or sets a key outside its Pick
17
- | 'AUTO_OPEN_POPUP_INVALID' // an autoOpenPopup that isn't one object with a string pageUriSEO
16
+ | 'PAGES_CONTEXT_INVALID' // src/global/pagesContext/index.ts isn't data only, or sets a key outside its Pick
17
+ | 'AUTO_OPEN_POPUP_INVALID' // an autoOpenPopup that isn't one object with a string pageUriSEO and a number delay
18
18
  | 'AUTO_OPEN_POPUP_UNKNOWN' // an autoOpenPopup of no popup in src/popups
19
- | 'AUTO_OPEN_POPUP_ON_PAGE_AND_ALL_PAGES' // a page sets autoOpenPopup while src/global/allPages/index.ts does
19
+ | 'AUTO_OPEN_POPUP_ON_PAGE_AND_PAGES_CONTEXT' // a page sets autoOpenPopup while src/global/pagesContext/index.ts does
20
20
  | 'UNSUPPORTED_ACCESS_RULE' // see section 4
21
21
  constructor(code: SiteTreeError['code'], paths: string[], message: string)
22
22
  paths: string[]
@@ -36,7 +36,7 @@ export const createSiteTree = (root, prepare = async table => table) => {
36
36
  fileChanged(path) {
37
37
  if (closed) return
38
38
  const changed = resolve(rootPath, path)
39
- for (const directory of ['pages', 'popups', 'global/allPages']) {
39
+ for (const directory of ['pages', 'popups', 'global/pagesContext']) {
40
40
  const suffix = relative(resolve(rootPath, 'src', directory), changed)
41
41
  if (suffix === '' || (suffix !== '..' && !suffix.startsWith(`..${sep}`) && !suffix.startsWith(sep))) dirty = true
42
42
  }
@@ -2,7 +2,7 @@
2
2
  import { existsSync, readFileSync, readdirSync, statSync } from 'node:fs'
3
3
  import { basename, dirname, resolve } from 'node:path'
4
4
  import { parse } from '@babel/parser'
5
- import { ALL_PAGES_FILE, allPagesProblems, attributeValue, findItems, pageUrl, readAllPages } from '@wix/origami-types'
5
+ import { PAGES_CONTEXT_FILE, pagesContextProblems, attributeValue, findItems, pageUrl, readPagesContext } from '@wix/origami-types'
6
6
  import { SiteTreeError } from '../requests/errors.js'
7
7
  import { readRouteJsons } from './routeJson.js'
8
8
 
@@ -196,31 +196,31 @@ export const readSiteTree = async root => {
196
196
  const hasPopups = process.env.ORIGAMI_EXPERIMENTAL_POPUPS === '1'
197
197
  const popups = hasPopups ? readPopups(src) : []
198
198
  const pageItemPaths = [...pages, ...routers.flatMap(router => Object.values(router.rolePages)), notFound].flatMap(page => page.itemPath ?? [])
199
- const allPages = hasPopups ? checkedAllPages(src, pageItemPaths, popups) : {}
200
- return { version: 2, pages, routers, ...(brokenRouters.length ? { brokenRouters } : {}), notFound, popups, allPages }
199
+ const pagesContext = hasPopups ? checkedPagesContext(src, pageItemPaths, popups) : {}
200
+ return { version: 2, pages, routers, ...(brokenRouters.length ? { brokenRouters } : {}), notFound, popups, pagesContext }
201
201
  }
202
202
 
203
- /** The props every page gets, read from src/global/allPages/index.ts without running it, after the checks of the
203
+ /** The props every page gets, read from src/global/pagesContext/index.ts without running it, after the checks of the
204
204
  * file and of the pages' own autoOpenPopup. {} without the file.
205
205
  * @param {string[]} pageItemPaths @param {import('@wix/origami-types').PopupRoute[]} popups
206
206
  * @returns {Record<string, unknown>} */
207
- function checkedAllPages(src, pageItemPaths, popups) {
208
- const file = resolve(src, '..', ALL_PAGES_FILE)
209
- let allPages
207
+ function checkedPagesContext(src, pageItemPaths, popups) {
208
+ const file = resolve(src, '..', PAGES_CONTEXT_FILE)
209
+ let pagesContext
210
210
  if (existsSync(file)) {
211
211
  try {
212
- allPages = readAllPages(ALL_PAGES_FILE, parse(readFileSync(file, 'utf8'), { sourceType: 'module', plugins: ['typescript'] }))
212
+ pagesContext = readPagesContext(PAGES_CONTEXT_FILE, parse(readFileSync(file, 'utf8'), { sourceType: 'module', plugins: ['typescript'] }))
213
213
  } catch (error) {
214
- throw new SiteTreeError('ALL_PAGES_INVALID', [ALL_PAGES_FILE], `Can't parse it: ${/** @type {Error} */ (error).message}`)
214
+ throw new SiteTreeError('PAGES_CONTEXT_INVALID', [PAGES_CONTEXT_FILE], `Can't parse it: ${/** @type {Error} */ (error).message}`)
215
215
  }
216
216
  }
217
217
  const pages = pageItemPaths.flatMap(itemPath => {
218
218
  const { autoOpenPopup } = pageMetadata(resolve(src, itemPath))
219
219
  return autoOpenPopup ? [{ file: `src/${itemPath}/structure.jsx`, value: autoOpenPopup.value }] : []
220
220
  })
221
- const [problem] = allPagesProblems({ allPages, pages, popups: popups.map(popup => popup.seoUri) })
221
+ const [problem] = pagesContextProblems({ pagesContext, pages, popups: popups.map(popup => popup.seoUri) })
222
222
  if (problem) throw new SiteTreeError(problem.code, [problem.file], problem.message)
223
- return allPages?.value ?? {}
223
+ return pagesContext?.value ?? {}
224
224
  }
225
225
 
226
226
  /** Popups sit directly in src/popups, so their folder names, which are their seoUris and their only name, can't repeat.