@mercurjs/dashboard-sdk 2.0.0-canary.6 → 2.0.0-canary.60
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.cjs +23 -4
- package/dist/index.d.cts +4 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -136,6 +136,14 @@ function hasDefaultExport(filePath) {
|
|
|
136
136
|
return false;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
+
function hasConfigPublic(filePath) {
|
|
140
|
+
try {
|
|
141
|
+
const content = import_fs.default.readFileSync(filePath, "utf-8");
|
|
142
|
+
return /export\s+const\s+config\s*=\s*\{[^}]*public\s*:\s*true/.test(content);
|
|
143
|
+
} catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
139
147
|
function getNamedExports(filePath) {
|
|
140
148
|
try {
|
|
141
149
|
const content = import_fs.default.readFileSync(filePath, "utf-8");
|
|
@@ -170,12 +178,13 @@ function generateImports(file, index, hasHandle, hasLoader) {
|
|
|
170
178
|
}
|
|
171
179
|
return imports;
|
|
172
180
|
}
|
|
173
|
-
function generateRouteObject(routePath, index, hasHandle, hasLoader) {
|
|
181
|
+
function generateRouteObject(routePath, index, hasHandle, hasLoader, isPublic) {
|
|
174
182
|
return {
|
|
175
183
|
Component: generateRouteComponentName(index),
|
|
176
184
|
path: routePath,
|
|
177
185
|
handle: hasHandle ? generateHandleName(index) : void 0,
|
|
178
|
-
loader: hasLoader ? generateLoaderName(index) : void 0
|
|
186
|
+
loader: hasLoader ? generateLoaderName(index) : void 0,
|
|
187
|
+
isPublic
|
|
179
188
|
};
|
|
180
189
|
}
|
|
181
190
|
function formatRoute(route, indent = " ") {
|
|
@@ -191,6 +200,10 @@ ${indent} handle: ${route.handle}`;
|
|
|
191
200
|
if (route.loader) {
|
|
192
201
|
result += `,
|
|
193
202
|
${indent} loader: ${route.loader}`;
|
|
203
|
+
}
|
|
204
|
+
if (route.isPublic) {
|
|
205
|
+
result += `,
|
|
206
|
+
${indent} isPublic: true`;
|
|
194
207
|
}
|
|
195
208
|
if (route.children?.length) {
|
|
196
209
|
result += `,
|
|
@@ -209,9 +222,10 @@ function parseFile(file, pagesDir, index) {
|
|
|
209
222
|
return null;
|
|
210
223
|
}
|
|
211
224
|
const { hasHandle, hasLoader } = getNamedExports(file);
|
|
225
|
+
const isPublic = hasConfigPublic(file);
|
|
212
226
|
const routePath = getRoute(file, pagesDir);
|
|
213
227
|
const imports = generateImports(file, index, hasHandle, hasLoader);
|
|
214
|
-
const route = generateRouteObject(routePath, index, hasHandle, hasLoader);
|
|
228
|
+
const route = generateRouteObject(routePath, index, hasHandle, hasLoader, isPublic);
|
|
215
229
|
return {
|
|
216
230
|
imports,
|
|
217
231
|
route
|
|
@@ -528,8 +542,13 @@ function dashboardPlugin() {
|
|
|
528
542
|
root = viteConfig.root || process.cwd();
|
|
529
543
|
config = await loadMercurConfig(root);
|
|
530
544
|
return {
|
|
545
|
+
base: config.base,
|
|
531
546
|
define: {
|
|
532
|
-
"__BACKEND_URL__": JSON.stringify(config.backendUrl)
|
|
547
|
+
"__BACKEND_URL__": JSON.stringify(config.backendUrl),
|
|
548
|
+
"__BASE__": JSON.stringify(config.base || "/")
|
|
549
|
+
},
|
|
550
|
+
optimizeDeps: {
|
|
551
|
+
exclude: ["virtual:mercur/config", "virtual:mercur/routes", "virtual:mercur/components", "virtual:mercur/menu-items", "virtual:mercur/i18n"]
|
|
533
552
|
}
|
|
534
553
|
};
|
|
535
554
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -9,11 +9,14 @@ interface MercurConfig {
|
|
|
9
9
|
components?: {
|
|
10
10
|
MainSidebar?: string;
|
|
11
11
|
SettingsSidebar?: string;
|
|
12
|
+
TopbarActions?: string;
|
|
12
13
|
};
|
|
13
14
|
i18n?: {
|
|
14
15
|
defaultLanguage: string;
|
|
15
16
|
};
|
|
16
17
|
backendUrl?: string;
|
|
18
|
+
base?: string;
|
|
19
|
+
enableSellerRegistration?: boolean;
|
|
17
20
|
}
|
|
18
21
|
interface BuiltMercurConfig extends MercurConfig {
|
|
19
22
|
backendUrl: string;
|
|
@@ -27,6 +30,7 @@ type RouteConfig = {
|
|
|
27
30
|
rank?: number;
|
|
28
31
|
nested?: string;
|
|
29
32
|
translationNs?: string;
|
|
33
|
+
public?: boolean;
|
|
30
34
|
};
|
|
31
35
|
|
|
32
36
|
declare function defineConfig(config: MercurConfig): MercurConfig;
|