metaowl 0.2.11 → 0.2.12
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/index.js +16 -1
- package/package.json +1 -1
- package/vite/plugin.js +1 -4
package/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { mountApp } from './modules/app-mounter.js'
|
|
2
2
|
import { buildRoutes } from './modules/file-router.js'
|
|
3
3
|
import { processRoutes } from './modules/router.js'
|
|
4
|
+
import { discoverLayouts } from './modules/layouts.js'
|
|
4
5
|
|
|
5
6
|
export { default as Fetch } from './modules/fetch.js'
|
|
6
7
|
export { default as Cache } from './modules/cache.js'
|
|
@@ -170,7 +171,21 @@ export {
|
|
|
170
171
|
*
|
|
171
172
|
* @param {Record<string, object>|object[]} [routesOrModules]
|
|
172
173
|
*/
|
|
173
|
-
export async function boot(routesOrModules = {}) {
|
|
174
|
+
export async function boot(routesOrModules = {}, layoutsOrModules = null) {
|
|
175
|
+
// Auto-discover layouts
|
|
176
|
+
try {
|
|
177
|
+
if (layoutsOrModules) {
|
|
178
|
+
// Use layouts provided by Vite plugin transformation
|
|
179
|
+
const { buildLayouts, setDefaultLayout } = await import('./modules/layouts.js')
|
|
180
|
+
buildLayouts(layoutsOrModules)
|
|
181
|
+
setDefaultLayout('default')
|
|
182
|
+
} else {
|
|
183
|
+
await discoverLayouts()
|
|
184
|
+
}
|
|
185
|
+
} catch (e) {
|
|
186
|
+
console.warn('[metaowl] Could not auto-discover layouts:', e.message)
|
|
187
|
+
}
|
|
188
|
+
|
|
174
189
|
const routes = Array.isArray(routesOrModules)
|
|
175
190
|
? routesOrModules
|
|
176
191
|
: buildRoutes(routesOrModules)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metaowl",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Lightweight meta-framework for Odoo OWL — file-based routing, app mounting, Fetch helper, Cache, Meta tags, SSG generator, and a Vite plugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
package/vite/plugin.js
CHANGED
|
@@ -191,10 +191,7 @@ export async function metaowlPlugin(options = {}) {
|
|
|
191
191
|
return {
|
|
192
192
|
code: code.replace(
|
|
193
193
|
/boot\(\s*\)/,
|
|
194
|
-
`boot(import.meta.glob('./${pagesRel}/**/*.js', { eager: true }))`
|
|
195
|
-
).replace(
|
|
196
|
-
/discoverLayouts\(\s*\)/,
|
|
197
|
-
`discoverLayouts(import.meta.glob('./${layoutsRel}/**/*.js', { eager: true }))`
|
|
194
|
+
`boot(import.meta.glob('./${pagesRel}/**/*.js', { eager: true }), import.meta.glob('./${layoutsRel}/**/*.js', { eager: true }))`
|
|
198
195
|
),
|
|
199
196
|
map: null
|
|
200
197
|
}
|