@mercurjs/dashboard-sdk 2.0.0-canary.0

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 ADDED
@@ -0,0 +1,584 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ dashboardPlugin: () => dashboardPlugin,
34
+ defineConfig: () => defineConfig
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+
38
+ // src/plugin.ts
39
+ var import_path5 = __toESM(require("path"), 1);
40
+
41
+ // src/utils.ts
42
+ function resolveExports(moduleExports) {
43
+ if ("default" in moduleExports && moduleExports.default && "default" in moduleExports.default) {
44
+ return resolveExports(moduleExports.default);
45
+ }
46
+ return moduleExports;
47
+ }
48
+ async function getFileExports(path6) {
49
+ const { unregister } = await safeRegister();
50
+ const module2 = require(path6);
51
+ unregister();
52
+ return resolveExports(module2);
53
+ }
54
+ var safeRegister = async () => {
55
+ const { register } = await import("esbuild-register/dist/node");
56
+ let res;
57
+ try {
58
+ res = register({
59
+ format: "cjs",
60
+ loader: "ts"
61
+ });
62
+ } catch {
63
+ res = {
64
+ unregister: () => {
65
+ }
66
+ };
67
+ }
68
+ return res;
69
+ };
70
+ function normalizePath(filePath) {
71
+ return filePath.replace(/\\/g, "/");
72
+ }
73
+
74
+ // src/constants.ts
75
+ var VALID_FILE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js"];
76
+ var CONFIG_NAME = "mercur.config.ts";
77
+ var CONFIG_VIRTUAL_MODULE = "virtual:mercur/config";
78
+ var ROUTES_VIRTUAL_MODULE = "virtual:mercur/routes";
79
+ var COMPONENTS_VIRTUAL_MODULE = "virtual:mercur/components";
80
+ var MENU_ITEMS_VIRTUAL_MODULE = "virtual:mercur/menu-items";
81
+ var I18N_VIRTUAL_MODULE = "virtual:mercur/i18n";
82
+ var RESOLVED_CONFIG_MODULE = "\0" + CONFIG_VIRTUAL_MODULE;
83
+ var RESOLVED_ROUTES_MODULE = "\0" + ROUTES_VIRTUAL_MODULE;
84
+ var RESOLVED_COMPONENTS_MODULE = "\0" + COMPONENTS_VIRTUAL_MODULE;
85
+ var RESOLVED_MENU_ITEMS_MODULE = "\0" + MENU_ITEMS_VIRTUAL_MODULE;
86
+ var RESOLVED_I18N_MODULE = "\0" + I18N_VIRTUAL_MODULE;
87
+ var VIRTUAL_MODULES = [
88
+ CONFIG_VIRTUAL_MODULE,
89
+ ROUTES_VIRTUAL_MODULE,
90
+ COMPONENTS_VIRTUAL_MODULE,
91
+ MENU_ITEMS_VIRTUAL_MODULE,
92
+ I18N_VIRTUAL_MODULE
93
+ ];
94
+
95
+ // src/virtual-modules.ts
96
+ var import_path4 = __toESM(require("path"), 1);
97
+
98
+ // src/routes.ts
99
+ var import_fs = __toESM(require("fs"), 1);
100
+ var import_path = __toESM(require("path"), 1);
101
+ function getRoute(file, pagesDir) {
102
+ const importPath = normalizePath(file);
103
+ const normalizedPagesDir = normalizePath(pagesDir);
104
+ return importPath.replace(normalizedPagesDir, "").replace(/\[\[\*\]\]/g, "*?").replace(/\[\*\]/g, "*").replace(/\(([^\[\]\)]+)\)/g, "$1?").replace(/\[\[([^\]]+)\]\]/g, ":$1?").replace(/\[([^\]]+)\]/g, ":$1").replace(
105
+ new RegExp(
106
+ `/page\\.(${VALID_FILE_EXTENSIONS.map((ext) => ext.slice(1)).join("|")})$`
107
+ ),
108
+ ""
109
+ ) || "/";
110
+ }
111
+ function crawlPages(dir, pattern = "page") {
112
+ const files = [];
113
+ if (!import_fs.default.existsSync(dir)) {
114
+ return files;
115
+ }
116
+ const entries = import_fs.default.readdirSync(dir, { withFileTypes: true });
117
+ for (const entry of entries) {
118
+ const fullPath = import_path.default.join(dir, entry.name);
119
+ if (entry.isDirectory()) {
120
+ files.push(...crawlPages(fullPath, pattern));
121
+ } else if (entry.isFile()) {
122
+ const ext = import_path.default.extname(entry.name);
123
+ const baseName = import_path.default.basename(entry.name, ext);
124
+ if (baseName === pattern && VALID_FILE_EXTENSIONS.includes(ext)) {
125
+ files.push(fullPath);
126
+ }
127
+ }
128
+ }
129
+ return files;
130
+ }
131
+ function hasDefaultExport(filePath) {
132
+ try {
133
+ const content = import_fs.default.readFileSync(filePath, "utf-8");
134
+ return /export\s+default\s+/.test(content) || /export\s*\{\s*[^}]*\s+as\s+default\s*[,}]/.test(content);
135
+ } catch {
136
+ return false;
137
+ }
138
+ }
139
+ function getNamedExports(filePath) {
140
+ try {
141
+ const content = import_fs.default.readFileSync(filePath, "utf-8");
142
+ const hasHandle = /export\s+(const|function|async\s+function)\s+handle\b/.test(content) || /export\s*\{[^}]*\bhandle\b[^}]*\}/.test(content);
143
+ const hasLoader = /export\s+(const|function|async\s+function)\s+loader\b/.test(content) || /export\s*\{[^}]*\bloader\b[^}]*\}/.test(content);
144
+ return { hasHandle, hasLoader };
145
+ } catch {
146
+ return { hasHandle: false, hasLoader: false };
147
+ }
148
+ }
149
+ function generateRouteComponentName(index) {
150
+ return `RouteComponent${index}`;
151
+ }
152
+ function generateHandleName(index) {
153
+ return `RouteHandle${index}`;
154
+ }
155
+ function generateLoaderName(index) {
156
+ return `RouteLoader${index}`;
157
+ }
158
+ function generateImports(file, index, hasHandle, hasLoader) {
159
+ const imports = [];
160
+ const componentName = generateRouteComponentName(index);
161
+ const importPath = normalizePath(file);
162
+ if (!hasHandle && !hasLoader) {
163
+ imports.push(`import ${componentName} from "${importPath}"`);
164
+ } else {
165
+ const namedImports = [
166
+ hasHandle && `handle as ${generateHandleName(index)}`,
167
+ hasLoader && `loader as ${generateLoaderName(index)}`
168
+ ].filter(Boolean).join(", ");
169
+ imports.push(`import ${componentName}, { ${namedImports} } from "${importPath}"`);
170
+ }
171
+ return imports;
172
+ }
173
+ function generateRouteObject(routePath, index, hasHandle, hasLoader) {
174
+ return {
175
+ Component: generateRouteComponentName(index),
176
+ path: routePath,
177
+ handle: hasHandle ? generateHandleName(index) : void 0,
178
+ loader: hasLoader ? generateLoaderName(index) : void 0
179
+ };
180
+ }
181
+ function formatRoute(route, indent = " ") {
182
+ let result = `${indent}{
183
+ `;
184
+ result += `${indent} Component: ${route.Component},
185
+ `;
186
+ result += `${indent} path: "${route.path}"`;
187
+ if (route.handle) {
188
+ result += `,
189
+ ${indent} handle: ${route.handle}`;
190
+ }
191
+ if (route.loader) {
192
+ result += `,
193
+ ${indent} loader: ${route.loader}`;
194
+ }
195
+ if (route.children?.length) {
196
+ result += `,
197
+ ${indent} children: [
198
+ `;
199
+ result += route.children.map((child) => formatRoute(child, indent + " ")).join(",\n");
200
+ result += `
201
+ ${indent} ]`;
202
+ }
203
+ result += `
204
+ ${indent}}`;
205
+ return result;
206
+ }
207
+ function parseFile(file, pagesDir, index) {
208
+ if (!hasDefaultExport(file)) {
209
+ return null;
210
+ }
211
+ const { hasHandle, hasLoader } = getNamedExports(file);
212
+ const routePath = getRoute(file, pagesDir);
213
+ const imports = generateImports(file, index, hasHandle, hasLoader);
214
+ const route = generateRouteObject(routePath, index, hasHandle, hasLoader);
215
+ return {
216
+ imports,
217
+ route
218
+ };
219
+ }
220
+ function buildRouteTree(results) {
221
+ const routeMap = /* @__PURE__ */ new Map();
222
+ const sortedResults = [...results].sort(
223
+ (a, b) => a.route.path.split("/").length - b.route.path.split("/").length
224
+ );
225
+ for (const result of sortedResults) {
226
+ const routePath = result.route.path;
227
+ const isParallel = routePath.includes("/@");
228
+ if (isParallel) {
229
+ const parentPath = routePath.split("/@")[0];
230
+ const parent = routeMap.get(parentPath);
231
+ if (parent) {
232
+ parent.route.children = parent.route.children || [];
233
+ parent.route.children.push({
234
+ ...result.route,
235
+ path: result.route.path.replace("/@", "/")
236
+ });
237
+ parent.imports.push(...result.imports);
238
+ } else {
239
+ routeMap.set(routePath, result);
240
+ }
241
+ } else {
242
+ routeMap.set(routePath, result);
243
+ }
244
+ }
245
+ return Array.from(routeMap.values());
246
+ }
247
+ function generateRoutes({ srcDir }) {
248
+ const pagesDir = import_path.default.join(srcDir, "pages");
249
+ const files = crawlPages(pagesDir);
250
+ if (files.length === 0) {
251
+ return `export const customRoutes = []`;
252
+ }
253
+ let index = 0;
254
+ const results = [];
255
+ for (const file of files) {
256
+ const result = parseFile(file, pagesDir, index);
257
+ if (result) {
258
+ results.push(result);
259
+ index++;
260
+ }
261
+ }
262
+ if (results.length === 0) {
263
+ return `export const customRoutes = []`;
264
+ }
265
+ const routeTree = buildRouteTree(results);
266
+ const imports = routeTree.flatMap((result) => result.imports);
267
+ const routes = routeTree.map((result) => formatRoute(result.route));
268
+ return `${imports.join("\n")}
269
+
270
+ export const customRoutes = [
271
+ ${routes.join(",\n")}
272
+ ]`;
273
+ }
274
+
275
+ // src/menu-items.ts
276
+ var import_fs2 = __toESM(require("fs"), 1);
277
+ var import_path2 = __toESM(require("path"), 1);
278
+ function crawlPages2(dir, pattern = "page") {
279
+ const files = [];
280
+ if (!import_fs2.default.existsSync(dir)) {
281
+ return files;
282
+ }
283
+ const entries = import_fs2.default.readdirSync(dir, { withFileTypes: true });
284
+ for (const entry of entries) {
285
+ const fullPath = import_path2.default.join(dir, entry.name);
286
+ if (entry.isDirectory()) {
287
+ files.push(...crawlPages2(fullPath, pattern));
288
+ } else if (entry.isFile()) {
289
+ const ext = import_path2.default.extname(entry.name);
290
+ const baseName = import_path2.default.basename(entry.name, ext);
291
+ if (baseName === pattern && VALID_FILE_EXTENSIONS.includes(ext)) {
292
+ files.push(fullPath);
293
+ }
294
+ }
295
+ }
296
+ return files;
297
+ }
298
+ function getRoute2(file, pagesDir) {
299
+ const importPath = normalizePath(file);
300
+ const normalizedPagesDir = normalizePath(pagesDir);
301
+ return importPath.replace(normalizedPagesDir, "").replace(/\[\[\*\]\]/g, "*?").replace(/\[\*\]/g, "*").replace(/\(([^\[\]\)]+)\)/g, "$1?").replace(/\[\[([^\]]+)\]\]/g, ":$1?").replace(/\[([^\]]+)\]/g, ":$1").replace(
302
+ new RegExp(
303
+ `/page\\.(${VALID_FILE_EXTENSIONS.map((ext) => ext.slice(1)).join("|")})$`
304
+ ),
305
+ ""
306
+ ) || "/";
307
+ }
308
+ function hasConfigExport(filePath) {
309
+ try {
310
+ const content = import_fs2.default.readFileSync(filePath, "utf-8");
311
+ return /export\s+(const|let|var)\s+config\b/.test(content) || /export\s*\{[^}]*\bconfig\b[^}]*\}/.test(content);
312
+ } catch {
313
+ return false;
314
+ }
315
+ }
316
+ function getConfigProperties(filePath) {
317
+ try {
318
+ const content = import_fs2.default.readFileSync(filePath, "utf-8");
319
+ const hasLabel = /\blabel\s*[:=]/.test(content);
320
+ if (!hasLabel) {
321
+ return null;
322
+ }
323
+ const hasIcon = /\bicon\s*[:=]/.test(content);
324
+ const rankMatch = content.match(/\brank\s*:\s*(\d+)/);
325
+ const rank = rankMatch ? parseInt(rankMatch[1], 10) : void 0;
326
+ const nestedMatch = content.match(/\bnested\s*:\s*["']([^"']+)["']/);
327
+ const nested = nestedMatch ? nestedMatch[1] : void 0;
328
+ const translationNsMatch = content.match(/\btranslationNs\s*:\s*["']([^"']+)["']/);
329
+ const translationNs = translationNsMatch ? translationNsMatch[1] : void 0;
330
+ return { label: hasLabel, icon: hasIcon, rank, nested, translationNs };
331
+ } catch {
332
+ return null;
333
+ }
334
+ }
335
+ function generateRouteConfigName(index) {
336
+ return `RouteConfig${index}`;
337
+ }
338
+ function generateImport(file, index) {
339
+ const importPath = normalizePath(file);
340
+ return `import { config as ${generateRouteConfigName(index)} } from "${importPath}"`;
341
+ }
342
+ function generateMenuItem(config, file, pagesDir, index) {
343
+ const configName = generateRouteConfigName(index);
344
+ return {
345
+ label: `${configName}.label`,
346
+ icon: config.icon ? `${configName}.icon` : void 0,
347
+ path: getRoute2(file, pagesDir),
348
+ rank: config.rank,
349
+ nested: config.nested,
350
+ translationNs: config.translationNs ? `${configName}.translationNs` : void 0
351
+ };
352
+ }
353
+ function formatMenuItem(menuItem) {
354
+ const parts = [
355
+ ` label: ${menuItem.label}`,
356
+ ` icon: ${menuItem.icon || "undefined"}`,
357
+ ` path: "${menuItem.path}"`,
358
+ ` rank: ${menuItem.rank !== void 0 ? menuItem.rank : "undefined"}`,
359
+ ` nested: ${menuItem.nested ? `"${menuItem.nested}"` : "undefined"}`,
360
+ ` translationNs: ${menuItem.translationNs || "undefined"}`
361
+ ];
362
+ return ` {
363
+ ${parts.join(",\n")}
364
+ }`;
365
+ }
366
+ function parseFile2(file, pagesDir, index) {
367
+ if (!hasConfigExport(file)) {
368
+ return null;
369
+ }
370
+ const config = getConfigProperties(file);
371
+ if (!config) {
372
+ return null;
373
+ }
374
+ return {
375
+ import: generateImport(file, index),
376
+ menuItem: generateMenuItem(config, file, pagesDir, index)
377
+ };
378
+ }
379
+ function generateMenuItems({ srcDir }) {
380
+ const pagesDir = import_path2.default.join(srcDir, "pages");
381
+ const files = crawlPages2(pagesDir);
382
+ if (files.length === 0) {
383
+ return `export default { menuItems: [] }`;
384
+ }
385
+ let index = 0;
386
+ const results = [];
387
+ for (const file of files) {
388
+ const result = parseFile2(file, pagesDir, index);
389
+ if (result) {
390
+ results.push(result);
391
+ index++;
392
+ }
393
+ }
394
+ if (results.length === 0) {
395
+ return `export default { menuItems: [] }`;
396
+ }
397
+ const imports = results.map((r) => r.import);
398
+ const menuItems = results.map((r) => formatMenuItem(r.menuItem));
399
+ return `${imports.join("\n")}
400
+
401
+ export default {
402
+ menuItems: [
403
+ ${menuItems.join(",\n")}
404
+ ]
405
+ }`;
406
+ }
407
+
408
+ // src/i18n.ts
409
+ var import_fs3 = __toESM(require("fs"), 1);
410
+ var import_path3 = __toESM(require("path"), 1);
411
+ function findI18nIndex(srcDir) {
412
+ const i18nDir = import_path3.default.join(srcDir, "i18n");
413
+ if (!import_fs3.default.existsSync(i18nDir)) {
414
+ return null;
415
+ }
416
+ for (const ext of VALID_FILE_EXTENSIONS) {
417
+ const filePath = import_path3.default.join(i18nDir, `index${ext}`);
418
+ if (import_fs3.default.existsSync(filePath)) {
419
+ return filePath;
420
+ }
421
+ }
422
+ return null;
423
+ }
424
+ function generateI18n({ srcDir }) {
425
+ const indexFile = findI18nIndex(srcDir);
426
+ if (!indexFile) {
427
+ return `export default {}`;
428
+ }
429
+ const importPath = normalizePath(indexFile);
430
+ return `import i18nResources from "${importPath}"
431
+ export default i18nResources`;
432
+ }
433
+
434
+ // src/virtual-modules.ts
435
+ function isVirtualModule(id) {
436
+ return VIRTUAL_MODULES.includes(id);
437
+ }
438
+ function resolveVirtualModule(id) {
439
+ return "\0" + id;
440
+ }
441
+ function loadVirtualModule({
442
+ cwd,
443
+ id,
444
+ mercurConfig
445
+ }) {
446
+ if (id === RESOLVED_CONFIG_MODULE) {
447
+ return loadConfigModule(mercurConfig);
448
+ }
449
+ if (id === RESOLVED_COMPONENTS_MODULE) {
450
+ return loadComponentsModule(mercurConfig, cwd);
451
+ }
452
+ if (id === RESOLVED_ROUTES_MODULE) {
453
+ return loadRoutesModule(mercurConfig);
454
+ }
455
+ if (id === RESOLVED_MENU_ITEMS_MODULE) {
456
+ return loadMenuItemsModule(mercurConfig);
457
+ }
458
+ if (id === RESOLVED_I18N_MODULE) {
459
+ return loadI18nModule(mercurConfig);
460
+ }
461
+ return null;
462
+ }
463
+ function loadConfigModule(mercurConfig) {
464
+ const { components, ...configWithoutComponents } = mercurConfig;
465
+ return `export default ${JSON.stringify(configWithoutComponents)}`;
466
+ }
467
+ function loadComponentsModule(mercurConfig, cwd) {
468
+ const components = mercurConfig.components ?? {};
469
+ const imports = [];
470
+ const exports2 = [];
471
+ Object.entries(components).forEach(([name, componentPath]) => {
472
+ const resolvedPath = import_path4.default.resolve(cwd, "src", componentPath);
473
+ imports.push(`import _${name} from "${resolvedPath}"`);
474
+ exports2.push(`${name}: _${name}`);
475
+ });
476
+ return `
477
+ ${imports.join("\n")}
478
+
479
+ export default {
480
+ ${exports2.join(",\n ")}
481
+ }
482
+ `;
483
+ }
484
+ function loadRoutesModule(mercurConfig) {
485
+ return generateRoutes(mercurConfig);
486
+ }
487
+ function loadMenuItemsModule(mercurConfig) {
488
+ return generateMenuItems(mercurConfig);
489
+ }
490
+ function loadI18nModule(mercurConfig) {
491
+ return generateI18n(mercurConfig);
492
+ }
493
+
494
+ // src/plugin.ts
495
+ function buildConfig(config, root) {
496
+ const srcDir = import_path5.default.join(root, "src");
497
+ return {
498
+ ...config,
499
+ backendUrl: config.backendUrl ?? "http://localhost:9000",
500
+ root,
501
+ srcDir,
502
+ configPath: import_path5.default.resolve(root, CONFIG_NAME)
503
+ };
504
+ }
505
+ async function loadMercurConfig(root) {
506
+ const configPath = import_path5.default.resolve(root, CONFIG_NAME);
507
+ try {
508
+ const mod = await getFileExports(configPath);
509
+ const content = mod.default ?? mod;
510
+ return buildConfig(content, root);
511
+ } catch (error) {
512
+ console.error(error);
513
+ throw new Error(
514
+ `[@mercurjs/dashboard-sdk] Could not find or load ${CONFIG_NAME} in ${root}`
515
+ );
516
+ }
517
+ }
518
+ function isPageFile(file) {
519
+ const basename = import_path5.default.basename(file, import_path5.default.extname(file));
520
+ return basename === "page";
521
+ }
522
+ function dashboardPlugin() {
523
+ let root;
524
+ let config;
525
+ return {
526
+ name: "@mercurjs/dashboard-sdk",
527
+ async config(viteConfig) {
528
+ root = viteConfig.root || process.cwd();
529
+ config = await loadMercurConfig(root);
530
+ return {
531
+ define: {
532
+ "__BACKEND_URL__": JSON.stringify(config.backendUrl)
533
+ }
534
+ };
535
+ },
536
+ configResolved(resolvedConfig) {
537
+ root = resolvedConfig.root;
538
+ },
539
+ resolveId(id) {
540
+ if (isVirtualModule(id)) {
541
+ return resolveVirtualModule(id);
542
+ }
543
+ return null;
544
+ },
545
+ load(id) {
546
+ return loadVirtualModule({ cwd: root, id, mercurConfig: config });
547
+ },
548
+ configureServer(server) {
549
+ const handlePageChange = (file) => {
550
+ if (!isPageFile(file)) return;
551
+ const mod = server.moduleGraph.getModuleById(RESOLVED_ROUTES_MODULE);
552
+ if (mod) {
553
+ server.moduleGraph.invalidateModule(mod);
554
+ server.ws.send({ type: "full-reload" });
555
+ }
556
+ };
557
+ server.watcher.on("add", handlePageChange);
558
+ server.watcher.on("unlink", handlePageChange);
559
+ },
560
+ handleHotUpdate({ file, server }) {
561
+ const configPath = import_path5.default.resolve(root, CONFIG_NAME);
562
+ if (file === configPath) {
563
+ server.restart();
564
+ return;
565
+ }
566
+ if (isPageFile(file)) {
567
+ const mod = server.moduleGraph.getModuleById(RESOLVED_ROUTES_MODULE);
568
+ if (mod) {
569
+ server.moduleGraph.invalidateModule(mod);
570
+ }
571
+ }
572
+ }
573
+ };
574
+ }
575
+
576
+ // src/define-config.ts
577
+ function defineConfig(config) {
578
+ return config;
579
+ }
580
+ // Annotate the CommonJS export names for ESM import in node:
581
+ 0 && (module.exports = {
582
+ dashboardPlugin,
583
+ defineConfig
584
+ });
@@ -0,0 +1,34 @@
1
+ import * as Vite from 'vite';
2
+ import { ComponentType } from 'react';
3
+
4
+ declare function dashboardPlugin(): Vite.Plugin;
5
+
6
+ interface MercurConfig {
7
+ name?: string;
8
+ logo?: string;
9
+ components?: {
10
+ MainSidebar?: string;
11
+ SettingsSidebar?: string;
12
+ };
13
+ i18n?: {
14
+ defaultLanguage: string;
15
+ };
16
+ backendUrl?: string;
17
+ }
18
+ interface BuiltMercurConfig extends MercurConfig {
19
+ backendUrl: string;
20
+ root: string;
21
+ srcDir: string;
22
+ configPath: string;
23
+ }
24
+ type RouteConfig = {
25
+ label: string;
26
+ icon?: ComponentType;
27
+ rank?: number;
28
+ nested?: string;
29
+ translationNs?: string;
30
+ };
31
+
32
+ declare function defineConfig(config: MercurConfig): MercurConfig;
33
+
34
+ export { type BuiltMercurConfig, type MercurConfig, type RouteConfig, dashboardPlugin, defineConfig };
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@mercurjs/dashboard-sdk",
3
+ "version": "2.0.0-canary.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/mercurjs/mercur",
7
+ "directory": "packages/dashboard-sdk"
8
+ },
9
+ "type": "module",
10
+ "main": "./dist/index.cjs",
11
+ "types": "./dist/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "require": "./dist/index.cjs",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist"
21
+ ],
22
+ "scripts": {
23
+ "dev": "tsup --watch",
24
+ "build": "tsup",
25
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0"
26
+ },
27
+ "dependencies": {
28
+ "esbuild-register": "^3.6.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/node": "^22.0.0",
32
+ "tsup": "^8.0.2",
33
+ "typescript": "5.9.3",
34
+ "vite": "^5.4.21",
35
+ "@types/react": "^18.2.66"
36
+ }
37
+ }