@uniweb/runtime 0.2.5 → 0.2.6
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 +1 -1
- package/src/index.jsx +29 -1
package/package.json
CHANGED
package/src/index.jsx
CHANGED
|
@@ -226,5 +226,33 @@ async function initRuntime(foundationSource, options = {}) {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Simplified entry point for sites
|
|
231
|
+
*
|
|
232
|
+
* Reads foundation configuration from __FOUNDATION_CONFIG__ which is injected
|
|
233
|
+
* by the Vite config based on site.yml settings.
|
|
234
|
+
*
|
|
235
|
+
* @param {Object} options
|
|
236
|
+
* @param {Promise} options.foundation - Promise from import('#foundation')
|
|
237
|
+
* @param {Promise} options.styles - Promise from import('#foundation/styles')
|
|
238
|
+
*/
|
|
239
|
+
async function start({ foundation, styles } = {}) {
|
|
240
|
+
// Read config injected by Vite's define option (from site.yml)
|
|
241
|
+
const config =
|
|
242
|
+
typeof __FOUNDATION_CONFIG__ !== 'undefined' ? __FOUNDATION_CONFIG__ : { mode: 'bundled' }
|
|
243
|
+
|
|
244
|
+
if (config.mode === 'runtime') {
|
|
245
|
+
// Runtime mode: load foundation dynamically from URL
|
|
246
|
+
return initRuntime({
|
|
247
|
+
url: config.url,
|
|
248
|
+
cssUrl: config.cssUrl
|
|
249
|
+
})
|
|
250
|
+
} else {
|
|
251
|
+
// Bundled mode: await the foundation and styles imports
|
|
252
|
+
const [foundationModule] = await Promise.all([foundation, styles])
|
|
253
|
+
return initRuntime(foundationModule)
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export { initRuntime, start }
|
|
230
258
|
export default initRuntime
|