@skafform/vite-plugin 0.1.5 → 0.1.7
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/dist/index.js +12 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -208,7 +208,9 @@ ${lightVars}
|
|
|
208
208
|
return `export default ${JSON.stringify({
|
|
209
209
|
...config,
|
|
210
210
|
customize: { ...themeJson.customize ?? {}, ...config.customize ?? {} },
|
|
211
|
-
fonts: themeJson.fonts ?? []
|
|
211
|
+
fonts: themeJson.fonts ?? [],
|
|
212
|
+
widget_areas: themeJson.widget_areas ?? {},
|
|
213
|
+
nav_locations: themeJson.nav_locations ?? {}
|
|
212
214
|
})}`;
|
|
213
215
|
}
|
|
214
216
|
if (id === RESOLVED_ADMIN_SECTIONS) {
|
|
@@ -245,7 +247,7 @@ ${lightVars}
|
|
|
245
247
|
const basename = absPath.split("/").pop().replace(/\.[^.]+$/, "");
|
|
246
248
|
const varName = `wr_${i++}`;
|
|
247
249
|
imports.push(`import * as ${varName} from ${JSON.stringify(absPath)}`);
|
|
248
|
-
items.push(` { brick: ${JSON.stringify(w.brick)}, basename: ${JSON.stringify(basename)}, Component: ${varName}.default }`);
|
|
250
|
+
items.push(` { brick: ${JSON.stringify(w.brick)}, basename: ${JSON.stringify(basename)}, Component: ${varName}.default, schema: ${varName}.schema ?? [] }`);
|
|
249
251
|
}
|
|
250
252
|
entries.push(` ${JSON.stringify(zone)}: [
|
|
251
253
|
${items.join(",\n")}
|
|
@@ -268,7 +270,7 @@ ${entries.join(",\n")}
|
|
|
268
270
|
const absPath = norm(resolve(root, widget.component));
|
|
269
271
|
const basename = absPath.split("/").pop().replace(/\.[^.]+$/, "");
|
|
270
272
|
const key = `${widget.zone}:${brickName}:${basename}`;
|
|
271
|
-
widgets.push({ key, absPath, varName: `wl_${i++}
|
|
273
|
+
widgets.push({ key, absPath, varName: `wl_${i++}`, brickName, basename });
|
|
272
274
|
}
|
|
273
275
|
}
|
|
274
276
|
if (widgets.length === 0) {
|
|
@@ -277,13 +279,16 @@ ${entries.join(",\n")}
|
|
|
277
279
|
return [
|
|
278
280
|
...widgets.map((w) => `import * as ${w.varName} from ${JSON.stringify(w.absPath)}`),
|
|
279
281
|
`const _loaders = [`,
|
|
280
|
-
...widgets.map((w) => ` { key: ${JSON.stringify(w.key)}, fn: ${w.varName}.loader ?? null },`),
|
|
282
|
+
...widgets.map((w) => ` { key: ${JSON.stringify(w.key)}, brick: ${JSON.stringify(w.brickName)}, basename: ${JSON.stringify(w.basename)}, fn: ${w.varName}.loader ?? null },`),
|
|
281
283
|
`]`,
|
|
282
|
-
`export async function runWidgetLoaders(request) {`,
|
|
284
|
+
`export async function runWidgetLoaders(request, dbWidgets) {`,
|
|
285
|
+
` const _all = Object.values(dbWidgets ?? {}).flat()`,
|
|
283
286
|
` const results = {}`,
|
|
284
287
|
` await Promise.all(`,
|
|
285
|
-
` _loaders.filter(w => w.fn !== null).map(async ({ key, fn }) => {`,
|
|
286
|
-
`
|
|
288
|
+
` _loaders.filter(w => w.fn !== null).map(async ({ key, fn, brick, basename }) => {`,
|
|
289
|
+
` const _inst = _all.find(w => w.brick === brick && w.component.split('/').pop()?.replace(/\\.[^.]+$/, '') === basename)`,
|
|
290
|
+
` const _config = _inst?.config ?? {}`,
|
|
291
|
+
` try { results[key] = await fn({ request, config: _config }) } catch { results[key] = null }`,
|
|
287
292
|
` })`,
|
|
288
293
|
` )`,
|
|
289
294
|
` return results`,
|