@uniweb/build 0.48.0 → 0.49.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/build",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "Build tooling for the Uniweb Component Web Platform",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -58,14 +58,14 @@
|
|
|
58
58
|
"sharp": "^0.35.3",
|
|
59
59
|
"yaml": "^2.5.0",
|
|
60
60
|
"@uniweb/content-reader": "^1.2.4",
|
|
61
|
-
"@uniweb/
|
|
62
|
-
"@uniweb/projections": "^0.7.0",
|
|
63
|
-
"@uniweb/theming": "^0.1.15",
|
|
61
|
+
"@uniweb/content-writer": "^0.3.4",
|
|
64
62
|
"@uniweb/semantic-parser": "^1.4.0",
|
|
65
|
-
"@uniweb/
|
|
63
|
+
"@uniweb/projections": "^0.7.1",
|
|
64
|
+
"@uniweb/schemas": "^0.2.13",
|
|
65
|
+
"@uniweb/theming": "^0.1.15"
|
|
66
66
|
},
|
|
67
67
|
"optionalDependencies": {
|
|
68
|
-
"@uniweb/runtime": "^0.
|
|
68
|
+
"@uniweb/runtime": "^0.24.0"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@tailwindcss/vite": "^4.0.0",
|
|
75
75
|
"@vitejs/plugin-react": "^4.0.0 || ^5.0.0",
|
|
76
76
|
"vite-plugin-svgr": "^4.0.0",
|
|
77
|
-
"@uniweb/core": "^0.
|
|
77
|
+
"@uniweb/core": "^0.28.0"
|
|
78
78
|
},
|
|
79
79
|
"peerDependenciesMeta": {
|
|
80
80
|
"vite": {
|
package/src/prerender.js
CHANGED
|
@@ -93,7 +93,9 @@ export function resolveExtensionPath(url, distDir, projectRoot, base) {
|
|
|
93
93
|
* baker for the views a concrete parametric page binds to its route
|
|
94
94
|
*/
|
|
95
95
|
export async function executeAllFetches(siteContent, siteDir, onProgress, localeInfo) {
|
|
96
|
-
|
|
96
|
+
// The locale this pass renders, which a `sort` collates texts in.
|
|
97
|
+
const locale = localeInfo?.locale ?? localeInfo?.defaultLocale ?? resolveDefaultLocale(siteContent.config) ?? null
|
|
98
|
+
const fetchOptions = { siteRoot: siteDir, publicDir: 'public', locale }
|
|
97
99
|
const fetchedData = [] // Collected for DataStore pre-population
|
|
98
100
|
|
|
99
101
|
// For non-default locales, translated collection data lives in dist/{locale}/data/
|
|
@@ -121,7 +123,7 @@ export async function executeAllFetches(siteContent, siteDir, onProgress, locale
|
|
|
121
123
|
|
|
122
124
|
// Fetch options pointing to dist/ for localized data
|
|
123
125
|
const localizedFetchOptions = isNonDefaultLocale
|
|
124
|
-
? { siteRoot: localeInfo.distDir, publicDir: '.' }
|
|
126
|
+
? { siteRoot: localeInfo.distDir, publicDir: '.', locale }
|
|
125
127
|
: fetchOptions
|
|
126
128
|
const optionsFor = (cfg, oneFetch) => (cfg.path !== oneFetch.path ? localizedFetchOptions : fetchOptions)
|
|
127
129
|
const entry = (cfg, data, scope) => ({ config: cfg, data, meta: { whole: cfg.whole }, _scope: scope })
|
|
@@ -143,7 +143,8 @@ export async function buildSiteData({
|
|
|
143
143
|
resolvedSiteRoot,
|
|
144
144
|
siteContent.config.queries,
|
|
145
145
|
siteContent.config?.paths?.entities,
|
|
146
|
-
basePath
|
|
146
|
+
basePath,
|
|
147
|
+
{ locale: resolveDefaultLocale(siteContent.config) ?? null }
|
|
147
148
|
)
|
|
148
149
|
await writeQueryFiles(resolvedSiteRoot, byQuery, siteContent.config.queries)
|
|
149
150
|
|
package/src/site/data-fetcher.js
CHANGED
|
@@ -52,13 +52,17 @@ function getNestedValue(obj, path) {
|
|
|
52
52
|
* records service refuses and the ruling dropped. A comma now THROWS here, at build
|
|
53
53
|
* time, which is where an authoring error on the file lane belongs.
|
|
54
54
|
*
|
|
55
|
+
* Texts are collated in `locale` — the page's (ruled 2026-09-14 [Diego]).
|
|
56
|
+
*
|
|
55
57
|
* @param {Array} items - Items to sort
|
|
56
58
|
* @param {string} sortExpr - Sort expression: `date`, `date desc`, `-date`
|
|
59
|
+
* @param {Object} [options]
|
|
60
|
+
* @param {string|null} [options.locale] - the page's locale
|
|
57
61
|
* @returns {Array} Sorted items (new array)
|
|
58
62
|
*/
|
|
59
|
-
export function applySort(items, sortExpr) {
|
|
63
|
+
export function applySort(items, sortExpr, { locale = null } = {}) {
|
|
60
64
|
if (!sortExpr || !Array.isArray(items)) return items
|
|
61
|
-
return sortRecords(items, sortExpr)
|
|
65
|
+
return sortRecords(items, sortExpr, { locale })
|
|
62
66
|
}
|
|
63
67
|
|
|
64
68
|
/**
|
|
@@ -88,9 +92,11 @@ export function applyWhere(items, where) {
|
|
|
88
92
|
*
|
|
89
93
|
* @param {any} data - Fetched data
|
|
90
94
|
* @param {object} config - Fetch config with optional where, sort, limit
|
|
95
|
+
* @param {object} [options]
|
|
96
|
+
* @param {string|null} [options.locale] - the page's locale, which texts sort in
|
|
91
97
|
* @returns {any} Processed data
|
|
92
98
|
*/
|
|
93
|
-
export function applyPostProcessing(data, config) {
|
|
99
|
+
export function applyPostProcessing(data, config, { locale = null } = {}) {
|
|
94
100
|
if (!data || !Array.isArray(data)) return data
|
|
95
101
|
if (!config.scope && !config.where && !config.sort && !config.limit) return data
|
|
96
102
|
|
|
@@ -109,7 +115,7 @@ export function applyPostProcessing(data, config) {
|
|
|
109
115
|
|
|
110
116
|
// Apply sort
|
|
111
117
|
if (config.sort) {
|
|
112
|
-
result = applySort(result, config.sort)
|
|
118
|
+
result = applySort(result, config.sort, { locale })
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
// Apply limit last
|
|
@@ -698,6 +704,7 @@ export function stripBuildOnlyFetchKeys(siteContent) {
|
|
|
698
704
|
* @param {object} options - Execution options
|
|
699
705
|
* @param {string} options.siteRoot - Site root directory
|
|
700
706
|
* @param {string} [options.publicDir='public'] - Public directory name
|
|
707
|
+
* @param {string|null} [options.locale] - the page's locale, which a `sort` collates texts in
|
|
701
708
|
* @returns {Promise<{ data: any, error?: string }>} Fetched data or error
|
|
702
709
|
*
|
|
703
710
|
* @example
|
|
@@ -773,7 +780,7 @@ export async function executeFetch(config, options = {}) {
|
|
|
773
780
|
}
|
|
774
781
|
|
|
775
782
|
// Apply post-processing (where, sort, limit)
|
|
776
|
-
data = applyPostProcessing(data, config)
|
|
783
|
+
data = applyPostProcessing(data, config, { locale: options.locale ?? null })
|
|
777
784
|
|
|
778
785
|
// Ensure we return an array or object, defaulting to empty array
|
|
779
786
|
return { data: data ?? [] }
|
package/src/site/plugin.js
CHANGED
|
@@ -136,7 +136,9 @@ export function shouldPrefetchInDev(cfg) {
|
|
|
136
136
|
* @param {string} siteDir - Path to site directory
|
|
137
137
|
*/
|
|
138
138
|
async function executeDevFetches(siteContent, siteDir) {
|
|
139
|
-
|
|
139
|
+
// The page's locale, which a `sort` collates texts in.
|
|
140
|
+
const locale = siteContent.config?.activeLocale ?? resolveDefaultLocale(siteContent.config) ?? null
|
|
141
|
+
const fetchOptions = { siteRoot: siteDir, publicDir: 'public', locale }
|
|
140
142
|
const fetchedData = []
|
|
141
143
|
// Resolved the way the runtime resolves it (see prerender.js::executeAllFetches
|
|
142
144
|
// for why): the SPA hydrates by the cache key of ITS resolved config.
|
|
@@ -825,7 +827,9 @@ export function siteContentPlugin(options = {}) {
|
|
|
825
827
|
|
|
826
828
|
if (queriesConfig) {
|
|
827
829
|
console.log('[site-content] Materializing queries...')
|
|
828
|
-
const byQuery = await processQueries(resolvedSitePath, queriesConfig, resolvedEntitiesDir, basePath
|
|
830
|
+
const byQuery = await processQueries(resolvedSitePath, queriesConfig, resolvedEntitiesDir, basePath, {
|
|
831
|
+
locale: resolveDefaultLocale(earlyContent.config) ?? null,
|
|
832
|
+
})
|
|
829
833
|
await writeQueryFiles(resolvedSitePath, byQuery, queriesConfig)
|
|
830
834
|
}
|
|
831
835
|
} catch (err) {
|
|
@@ -617,7 +617,7 @@ function warnDuplicateSlugs(items, queryName) {
|
|
|
617
617
|
* @param {Object} config - Parsed collection config
|
|
618
618
|
* @returns {Promise<Array>} Array of processed items
|
|
619
619
|
*/
|
|
620
|
-
async function collectItems(siteDir, config, entitiesDir, basePath) {
|
|
620
|
+
async function collectItems(siteDir, config, entitiesDir, basePath, locale = null) {
|
|
621
621
|
// ⭐ THE QUERY NAMES A SCHEMA AND THE POOL FOLLOWS — the same resolution the
|
|
622
622
|
// sync lane makes, from the same reader, so the two lanes cannot disagree
|
|
623
623
|
// about which files are a query's records. They used to: this one recursed
|
|
@@ -737,8 +737,9 @@ async function collectItems(siteDir, config, entitiesDir, basePath) {
|
|
|
737
737
|
|
|
738
738
|
// The query's `sort` orders the file; the runtime applies whichever sort wins —
|
|
739
739
|
// a binding's own, else this one — so the order here only spares it the work.
|
|
740
|
+
// Texts collate in the site's default language; each page re-sorts in its own.
|
|
740
741
|
if (config.sort) {
|
|
741
|
-
items = applySort(items, config.sort)
|
|
742
|
+
items = applySort(items, config.sort, { locale })
|
|
742
743
|
}
|
|
743
744
|
|
|
744
745
|
// ⛔ `limit` IS NEVER BAKED (ruled 2026-09-13 [Diego]): it is how many a list
|
|
@@ -757,6 +758,10 @@ async function collectItems(siteDir, config, entitiesDir, basePath) {
|
|
|
757
758
|
* @param {string} siteDir - Site root directory
|
|
758
759
|
* @param {Object} queriesConfig - the resolved QUERY declarations
|
|
759
760
|
* @param {string} [entitiesDir] - pool directory override (`site.yml::paths.entities`)
|
|
761
|
+
* @param {string} [basePath='/']
|
|
762
|
+
* @param {Object} [options]
|
|
763
|
+
* @param {string|null} [options.locale] - the site's default language, which a query's `sort`
|
|
764
|
+
* collates texts in when it orders the compiled file
|
|
760
765
|
* @returns {Promise<Object>} Map of collection name to items array
|
|
761
766
|
*
|
|
762
767
|
* @example
|
|
@@ -766,7 +771,7 @@ async function collectItems(siteDir, config, entitiesDir, basePath) {
|
|
|
766
771
|
* })
|
|
767
772
|
* // { articles: [...], products: [...] }
|
|
768
773
|
*/
|
|
769
|
-
export async function processQueries(siteDir, queriesConfig, entitiesDir, basePath = '/') {
|
|
774
|
+
export async function processQueries(siteDir, queriesConfig, entitiesDir, basePath = '/', { locale = null } = {}) {
|
|
770
775
|
if (!queriesConfig || typeof queriesConfig !== 'object') {
|
|
771
776
|
return {}
|
|
772
777
|
}
|
|
@@ -818,7 +823,7 @@ export async function processQueries(siteDir, queriesConfig, entitiesDir, basePa
|
|
|
818
823
|
(managed ? 'Check records.yml lists them.' : 'Check entities/.')
|
|
819
824
|
)
|
|
820
825
|
}
|
|
821
|
-
const items = await collectItems(siteDir, parsed, entitiesDir, basePath)
|
|
826
|
+
const items = await collectItems(siteDir, parsed, entitiesDir, basePath, locale)
|
|
822
827
|
results[name] = items
|
|
823
828
|
console.log(`[query-processor] Processed ${name}: ${items.length} items`)
|
|
824
829
|
}
|