@uniweb/runtime 0.5.16 → 0.5.18
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 +18 -2
package/package.json
CHANGED
package/src/index.jsx
CHANGED
|
@@ -107,7 +107,9 @@ async function loadFoundationCSS(url) {
|
|
|
107
107
|
*/
|
|
108
108
|
async function loadFoundation(source) {
|
|
109
109
|
const url = typeof source === 'string' ? source : source.url
|
|
110
|
-
|
|
110
|
+
// Auto-derive CSS URL from JS URL by convention: foundation.js → assets/foundation.css
|
|
111
|
+
const cssUrl = typeof source === 'object' ? source.cssUrl
|
|
112
|
+
: url.replace(/[^/]+\.js$/, 'assets/foundation.css')
|
|
111
113
|
|
|
112
114
|
console.log(`[Runtime] Loading foundation from: ${url}`)
|
|
113
115
|
|
|
@@ -138,8 +140,22 @@ async function loadFoundation(source) {
|
|
|
138
140
|
async function loadExtensions(urls, uniwebInstance) {
|
|
139
141
|
if (!urls?.length) return
|
|
140
142
|
|
|
143
|
+
// Resolve extension URLs against base path for subdirectory deployments
|
|
144
|
+
// e.g., /effects/foundation.js → /templates/extensions/effects/foundation.js
|
|
145
|
+
const basePath = import.meta.env?.BASE_URL || '/'
|
|
146
|
+
function resolveUrl(source) {
|
|
147
|
+
if (basePath === '/') return source
|
|
148
|
+
if (typeof source === 'string' && source.startsWith('/')) {
|
|
149
|
+
return basePath + source.slice(1)
|
|
150
|
+
}
|
|
151
|
+
if (typeof source === 'object' && source.url?.startsWith('/')) {
|
|
152
|
+
return { ...source, url: basePath + source.url.slice(1) }
|
|
153
|
+
}
|
|
154
|
+
return source
|
|
155
|
+
}
|
|
156
|
+
|
|
141
157
|
const results = await Promise.allSettled(
|
|
142
|
-
urls.map(url => loadFoundation(url))
|
|
158
|
+
urls.map(url => loadFoundation(resolveUrl(url)))
|
|
143
159
|
)
|
|
144
160
|
|
|
145
161
|
for (let i = 0; i < results.length; i++) {
|