@skafform/vite-plugin 0.1.0 → 0.1.2
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 +11 -24
- package/package.json +1 -1
- package/types.d.ts +11 -0
package/dist/index.js
CHANGED
|
@@ -7,8 +7,8 @@ var VIRTUAL_CONFIG = "virtual:skafform/config";
|
|
|
7
7
|
var RESOLVED_CONFIG = "\0virtual:skafform/config";
|
|
8
8
|
var VIRTUAL_SERVER_INIT = "virtual:skafform/server-init";
|
|
9
9
|
var RESOLVED_SERVER_INIT = "\0virtual:skafform/server-init";
|
|
10
|
-
var
|
|
11
|
-
var
|
|
10
|
+
var VIRTUAL_ADMIN_SECTIONS = "virtual:skafform/admin-sections";
|
|
11
|
+
var RESOLVED_ADMIN_SECTIONS = "\0virtual:skafform/admin-sections";
|
|
12
12
|
var norm = (p) => p.replace(/\\/g, "/");
|
|
13
13
|
function loadBrickIndex(root) {
|
|
14
14
|
const bricksDir = resolve(root, "bricks");
|
|
@@ -93,7 +93,7 @@ ${vars}
|
|
|
93
93
|
resolveId(id, importer) {
|
|
94
94
|
if (id === VIRTUAL_CONFIG) return RESOLVED_CONFIG;
|
|
95
95
|
if (id === VIRTUAL_SERVER_INIT) return RESOLVED_SERVER_INIT;
|
|
96
|
-
if (id ===
|
|
96
|
+
if (id === VIRTUAL_ADMIN_SECTIONS) return RESOLVED_ADMIN_SECTIONS;
|
|
97
97
|
if (id.startsWith(".") && importer) {
|
|
98
98
|
const themeDir = norm(resolve(root, `themes/${config.theme}`));
|
|
99
99
|
const componentsDir = themeDir + "/components";
|
|
@@ -120,30 +120,17 @@ ${vars}
|
|
|
120
120
|
customize: { ...themeJson.customize ?? {}, ...config.customize ?? {} }
|
|
121
121
|
})}`;
|
|
122
122
|
}
|
|
123
|
-
if (id ===
|
|
123
|
+
if (id === RESOLVED_ADMIN_SECTIONS) {
|
|
124
124
|
const bricksConfigPath = resolve(root, "skafform-bricks.json");
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
for (const [brickName, brick] of Object.entries(bricksConfig.bricks ?? {})) {
|
|
132
|
-
for (const item of brick.nav ?? []) {
|
|
133
|
-
if (registry[item.location] !== void 0) {
|
|
134
|
-
registry[item.location].push({ ...item, order: item.order ?? 0, brick: brickName });
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
for (const [loc, items] of Object.entries(customNav)) {
|
|
139
|
-
if (registry[loc] !== void 0) {
|
|
140
|
-
registry[loc].push(...items.map((i) => ({ ...i, order: i.order ?? 0, brick: "config" })));
|
|
125
|
+
if (!existsSync(bricksConfigPath)) return "export default []";
|
|
126
|
+
const bricksConfig = JSON.parse(readFileSync(bricksConfigPath, "utf-8"));
|
|
127
|
+
const sections = [];
|
|
128
|
+
for (const brick of Object.values(bricksConfig.bricks ?? {})) {
|
|
129
|
+
for (const section of brick.adminSections ?? []) {
|
|
130
|
+
sections.push(section);
|
|
141
131
|
}
|
|
142
132
|
}
|
|
143
|
-
|
|
144
|
-
registry[loc].sort((a, b) => a.order - b.order);
|
|
145
|
-
}
|
|
146
|
-
return `export default ${JSON.stringify(registry)}`;
|
|
133
|
+
return `export default ${JSON.stringify(sections)}`;
|
|
147
134
|
}
|
|
148
135
|
if (id === RESOLVED_SERVER_INIT) {
|
|
149
136
|
const bricksConfigPath = resolve(root, "skafform-bricks.json");
|
package/package.json
CHANGED
package/types.d.ts
CHANGED
|
@@ -18,3 +18,14 @@ declare module "virtual:skafform/config" {
|
|
|
18
18
|
export default config
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
interface SkafformAdminSection {
|
|
22
|
+
label: string
|
|
23
|
+
href: string
|
|
24
|
+
file: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module "virtual:skafform/admin-sections" {
|
|
28
|
+
const sections: SkafformAdminSection[]
|
|
29
|
+
export default sections
|
|
30
|
+
}
|
|
31
|
+
|