@sonicjs-cms/core 2.0.9 → 2.0.10

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.
Files changed (39) hide show
  1. package/dist/{chunk-TMIRVVQ7.cjs → chunk-3PHG75W4.cjs} +3 -3
  2. package/dist/{chunk-TMIRVVQ7.cjs.map → chunk-3PHG75W4.cjs.map} +1 -1
  3. package/dist/{chunk-MABBKINE.cjs → chunk-CAP6QQR2.cjs} +5 -5
  4. package/dist/{chunk-MABBKINE.cjs.map → chunk-CAP6QQR2.cjs.map} +1 -1
  5. package/dist/{chunk-OPGDMS7L.js → chunk-FTMKKKNH.js} +3 -3
  6. package/dist/{chunk-OPGDMS7L.js.map → chunk-FTMKKKNH.js.map} +1 -1
  7. package/dist/{chunk-DYYAXDXI.cjs → chunk-HXA5QSI3.cjs} +12 -8
  8. package/dist/chunk-HXA5QSI3.cjs.map +1 -0
  9. package/dist/{chunk-VEC5MLT3.js → chunk-LW33AOBF.js} +6 -8
  10. package/dist/chunk-LW33AOBF.js.map +1 -0
  11. package/dist/{chunk-EYMHWJTW.cjs → chunk-MU3MR2QR.cjs} +6 -8
  12. package/dist/chunk-MU3MR2QR.cjs.map +1 -0
  13. package/dist/{chunk-WRRLB6KG.js → chunk-MXJJN4IA.js} +3 -3
  14. package/dist/{chunk-WRRLB6KG.js.map → chunk-MXJJN4IA.js.map} +1 -1
  15. package/dist/{chunk-4I25AGUR.cjs → chunk-Q7SL7U43.cjs} +199 -157
  16. package/dist/chunk-Q7SL7U43.cjs.map +1 -0
  17. package/dist/{chunk-OKPDQO2Y.js → chunk-YHG45LMU.js} +12 -8
  18. package/dist/chunk-YHG45LMU.js.map +1 -0
  19. package/dist/{chunk-ABYMIXRN.js → chunk-Z4H6DBVF.js} +53 -11
  20. package/dist/chunk-Z4H6DBVF.js.map +1 -0
  21. package/dist/index.cjs +83 -83
  22. package/dist/index.cjs.map +1 -1
  23. package/dist/index.js +10 -10
  24. package/dist/index.js.map +1 -1
  25. package/dist/middleware.cjs +22 -22
  26. package/dist/middleware.js +1 -1
  27. package/dist/routes.cjs +24 -24
  28. package/dist/routes.js +4 -4
  29. package/dist/templates.cjs +18 -18
  30. package/dist/templates.js +2 -2
  31. package/dist/utils.cjs +11 -11
  32. package/dist/utils.js +1 -1
  33. package/package.json +1 -1
  34. package/dist/chunk-4I25AGUR.cjs.map +0 -1
  35. package/dist/chunk-ABYMIXRN.js.map +0 -1
  36. package/dist/chunk-DYYAXDXI.cjs.map +0 -1
  37. package/dist/chunk-EYMHWJTW.cjs.map +0 -1
  38. package/dist/chunk-OKPDQO2Y.js.map +0 -1
  39. package/dist/chunk-VEC5MLT3.js.map +0 -1
@@ -5,7 +5,7 @@ import { getCookie } from 'hono/cookie';
5
5
 
6
6
  // src/middleware/bootstrap.ts
7
7
  var bootstrapComplete = false;
8
- function bootstrapMiddleware() {
8
+ function bootstrapMiddleware(config = {}) {
9
9
  return async (c, next) => {
10
10
  if (bootstrapComplete) {
11
11
  return next();
@@ -25,11 +25,15 @@ function bootstrapMiddleware() {
25
25
  } catch (error) {
26
26
  console.error("[Bootstrap] Error syncing collections:", error);
27
27
  }
28
- console.log("[Bootstrap] Bootstrapping core plugins...");
29
- const bootstrapService = new PluginBootstrapService(c.env.DB);
30
- const needsBootstrap = await bootstrapService.isBootstrapNeeded();
31
- if (needsBootstrap) {
32
- await bootstrapService.bootstrapCorePlugins();
28
+ if (!config.plugins?.disableAll) {
29
+ console.log("[Bootstrap] Bootstrapping core plugins...");
30
+ const bootstrapService = new PluginBootstrapService(c.env.DB);
31
+ const needsBootstrap = await bootstrapService.isBootstrapNeeded();
32
+ if (needsBootstrap) {
33
+ await bootstrapService.bootstrapCorePlugins();
34
+ }
35
+ } else {
36
+ console.log("[Bootstrap] Plugin bootstrap skipped (disableAll is true)");
33
37
  }
34
38
  bootstrapComplete = true;
35
39
  console.log("[Bootstrap] System initialization completed");
@@ -197,5 +201,5 @@ var getActivePlugins = () => [];
197
201
  var isPluginActive = () => false;
198
202
 
199
203
  export { AuthManager, PermissionManager, bootstrapMiddleware, cacheHeaders, compressionMiddleware, detailedLoggingMiddleware, getActivePlugins, isPluginActive, logActivity, loggingMiddleware, metricsMiddleware, optionalAuth, performanceLoggingMiddleware, requireActivePlugin, requireActivePlugins, requireAnyPermission, requireAuth, requirePermission, requireRole, securityHeaders, securityLoggingMiddleware };
200
- //# sourceMappingURL=chunk-OKPDQO2Y.js.map
201
- //# sourceMappingURL=chunk-OKPDQO2Y.js.map
204
+ //# sourceMappingURL=chunk-YHG45LMU.js.map
205
+ //# sourceMappingURL=chunk-YHG45LMU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/middleware/bootstrap.ts","../src/middleware/auth.ts","../src/middleware/metrics.ts","../src/middleware/index.ts"],"names":[],"mappings":";;;;;;AAYA,IAAI,iBAAA,GAAoB,KAAA;AAMjB,SAAS,mBAAA,CAAoB,MAAA,GAAwB,EAAC,EAAG;AAC9D,EAAA,OAAO,OAAO,GAAoC,IAAA,KAAe;AAE/D,IAAA,IAAI,iBAAA,EAAmB;AACrB,MAAA,OAAO,IAAA,EAAK;AAAA,IACd;AAGA,IAAA,MAAM,IAAA,GAAO,EAAE,GAAA,CAAI,IAAA;AACnB,IAAA,IACE,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,IAC1B,IAAA,CAAK,UAAA,CAAW,UAAU,CAAA,IAC1B,IAAA,KAAS,SAAA,IACT,IAAA,CAAK,QAAA,CAAS,KAAK,CAAA,IACnB,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,IACpB,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,IACpB,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,IACpB,IAAA,CAAK,QAAA,CAAS,MAAM,CAAA,EACpB;AACA,MAAA,OAAO,IAAA,EAAK;AAAA,IACd;AAEA,IAAA,IAAI;AACF,MAAA,OAAA,CAAQ,IAAI,+CAA+C,CAAA;AAG3D,MAAA,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AAM,IAAA;AACvE,IAAM,kBAAuB,MAAM,OAAO,EAAA,EAAS,IAAA,KAAc,MAAM,IAAA;AAGvE,IAAM,oBAAyB;AAC/B,IAAM,oBAAyB,MAAM,OAAO,EAAA,EAAS,IAAA,KAAc,MAAM,IAAA;AACzE,IAAM,uBAA4B,MAAM,OAAO,EAAA,EAAS,IAAA,KAAc,MAAM,IAAA;AAC5E,IAAM,cAAmB,MAAM;AAAC;AAChC,IAAM,sBAA2B,MAAM,OAAO,EAAA,EAAS,IAAA,KAAc,MAAM,IAAA;AAC3E,IAAM,uBAA4B,MAAM,OAAO,EAAA,EAAS,IAAA,KAAc,MAAM,IAAA;AAC5E,IAAM,gBAAA,GAAwB,MAAM;AACpC,IAAM,iBAAsB,MAAM","file":"chunk-YHG45LMU.js","sourcesContent":["import { Context, Next } from \"hono\";\nimport { syncCollections } from \"../services/collection-sync\";\nimport { MigrationService } from \"../services/migrations\";\nimport { PluginBootstrapService } from \"../services/plugin-bootstrap\";\nimport type { SonicJSConfig } from \"../app\";\n\ntype Bindings = {\n DB: D1Database;\n KV: KVNamespace;\n};\n\n// Track if bootstrap has been run in this worker instance\nlet bootstrapComplete = false;\n\n/**\n * Bootstrap middleware that ensures system initialization\n * Runs once per worker instance\n */\nexport function bootstrapMiddleware(config: SonicJSConfig = {}) {\n return async (c: Context<{ Bindings: Bindings }>, next: Next) => {\n // Skip if already bootstrapped in this worker instance\n if (bootstrapComplete) {\n return next();\n }\n\n // Skip bootstrap for static assets and health checks\n const path = c.req.path;\n if (\n path.startsWith(\"/images/\") ||\n path.startsWith(\"/assets/\") ||\n path === \"/health\" ||\n path.endsWith(\".js\") ||\n path.endsWith(\".css\") ||\n path.endsWith(\".png\") ||\n path.endsWith(\".jpg\") ||\n path.endsWith(\".ico\")\n ) {\n return next();\n }\n\n try {\n console.log(\"[Bootstrap] Starting system initialization...\");\n\n // 1. Run database migrations first\n console.log(\"[Bootstrap] Running database migrations...\");\n const migrationService = new MigrationService(c.env.DB);\n await migrationService.runPendingMigrations();\n\n // 2. Sync collection configurations\n console.log(\"[Bootstrap] Syncing collection configurations...\");\n try {\n await syncCollections(c.env.DB);\n } catch (error) {\n console.error(\"[Bootstrap] Error syncing collections:\", error);\n // Continue bootstrap even if collection sync fails\n }\n\n // 3. Bootstrap core plugins (unless disableAll is set)\n if (!config.plugins?.disableAll) {\n console.log(\"[Bootstrap] Bootstrapping core plugins...\");\n const bootstrapService = new PluginBootstrapService(c.env.DB);\n\n // Check if bootstrap is needed\n const needsBootstrap = await bootstrapService.isBootstrapNeeded();\n if (needsBootstrap) {\n await bootstrapService.bootstrapCorePlugins();\n }\n } else {\n console.log(\"[Bootstrap] Plugin bootstrap skipped (disableAll is true)\");\n }\n\n // Mark bootstrap as complete for this worker instance\n bootstrapComplete = true;\n console.log(\"[Bootstrap] System initialization completed\");\n } catch (error) {\n console.error(\"[Bootstrap] Error during system initialization:\", error);\n // Don't prevent the app from starting, but log the error\n }\n\n return next();\n };\n}\n\n/**\n * Reset bootstrap flag (useful for testing)\n */\nexport function resetBootstrap() {\n bootstrapComplete = false;\n}\n","import { sign, verify } from 'hono/jwt'\nimport { Context, Next } from 'hono'\nimport { getCookie } from 'hono/cookie'\n\ntype JWTPayload = {\n userId: string\n email: string\n role: string\n exp: number\n iat: number\n}\n\n// JWT secret - in production this should come from environment variables\nconst JWT_SECRET = 'your-super-secret-jwt-key-change-in-production'\n\nexport class AuthManager {\n static async generateToken(userId: string, email: string, role: string): Promise<string> {\n const payload: JWTPayload = {\n userId,\n email,\n role,\n exp: Math.floor(Date.now() / 1000) + (60 * 60 * 24), // 24 hours\n iat: Math.floor(Date.now() / 1000)\n }\n \n return await sign(payload, JWT_SECRET)\n }\n\n static async verifyToken(token: string): Promise<JWTPayload | null> {\n try {\n const payload = await verify(token, JWT_SECRET) as JWTPayload\n \n // Check if token is expired\n if (payload.exp < Math.floor(Date.now() / 1000)) {\n return null\n }\n \n return payload\n } catch (error) {\n console.error('Token verification failed:', error)\n return null\n }\n }\n\n static async hashPassword(password: string): Promise<string> {\n // In Cloudflare Workers, we'll use Web Crypto API\n const encoder = new TextEncoder()\n const data = encoder.encode(password + 'salt-change-in-production')\n const hashBuffer = await crypto.subtle.digest('SHA-256', data)\n const hashArray = Array.from(new Uint8Array(hashBuffer))\n return hashArray.map(b => b.toString(16).padStart(2, '0')).join('')\n }\n\n static async verifyPassword(password: string, hash: string): Promise<boolean> {\n const passwordHash = await this.hashPassword(password)\n return passwordHash === hash\n }\n}\n\n// Middleware to require authentication\nexport const requireAuth = () => {\n return async (c: Context, next: Next) => {\n try {\n // Try to get token from Authorization header\n let token = c.req.header('Authorization')?.replace('Bearer ', '')\n\n // If no header token, try cookie\n if (!token) {\n token = getCookie(c, 'auth_token')\n }\n\n if (!token) {\n // Check if this is a browser request (HTML accept header)\n const acceptHeader = c.req.header('Accept') || ''\n if (acceptHeader.includes('text/html')) {\n return c.redirect('/auth/login?error=Please login to access the admin area')\n }\n return c.json({ error: 'Authentication required' }, 401)\n }\n\n // Try to get cached token verification from KV\n const kv = c.env?.KV\n let payload: JWTPayload | null = null\n\n if (kv) {\n const cacheKey = `auth:${token.substring(0, 20)}` // Use token prefix as key\n const cached = await kv.get(cacheKey, 'json')\n if (cached) {\n payload = cached as JWTPayload\n }\n }\n\n // If not cached, verify token\n if (!payload) {\n payload = await AuthManager.verifyToken(token)\n\n // Cache the verified payload for 5 minutes\n if (payload && kv) {\n const cacheKey = `auth:${token.substring(0, 20)}`\n await kv.put(cacheKey, JSON.stringify(payload), { expirationTtl: 300 })\n }\n }\n\n if (!payload) {\n // Check if this is a browser request (HTML accept header)\n const acceptHeader = c.req.header('Accept') || ''\n if (acceptHeader.includes('text/html')) {\n return c.redirect('/auth/login?error=Your session has expired, please login again')\n }\n return c.json({ error: 'Invalid or expired token' }, 401)\n }\n\n // Add user info to context\n c.set('user', payload)\n\n return await next()\n } catch (error) {\n console.error('Auth middleware error:', error)\n // Check if this is a browser request (HTML accept header)\n const acceptHeader = c.req.header('Accept') || ''\n if (acceptHeader.includes('text/html')) {\n return c.redirect('/auth/login?error=Authentication failed, please login again')\n }\n return c.json({ error: 'Authentication failed' }, 401)\n }\n }\n}\n\n// Middleware to require specific role\nexport const requireRole = (requiredRole: string | string[]) => {\n return async (c: Context, next: Next) => {\n const user = c.get('user') as JWTPayload\n \n if (!user) {\n // Check if this is a browser request (HTML accept header)\n const acceptHeader = c.req.header('Accept') || ''\n if (acceptHeader.includes('text/html')) {\n return c.redirect('/auth/login?error=Please login to access the admin area')\n }\n return c.json({ error: 'Authentication required' }, 401)\n }\n \n const roles = Array.isArray(requiredRole) ? requiredRole : [requiredRole]\n \n if (!roles.includes(user.role)) {\n // Check if this is a browser request (HTML accept header)\n const acceptHeader = c.req.header('Accept') || ''\n if (acceptHeader.includes('text/html')) {\n return c.redirect('/auth/login?error=You do not have permission to access this area')\n }\n return c.json({ error: 'Insufficient permissions' }, 403)\n }\n \n return await next()\n }\n}\n\n// Optional auth middleware (doesn't block if no token)\nexport const optionalAuth = () => {\n return async (c: Context, next: Next) => {\n try {\n let token = c.req.header('Authorization')?.replace('Bearer ', '')\n \n if (!token) {\n token = getCookie(c, 'auth_token')\n }\n \n if (token) {\n const payload = await AuthManager.verifyToken(token)\n if (payload) {\n c.set('user', payload)\n }\n }\n \n return await next()\n } catch (error) {\n // Don't block on auth errors in optional auth\n console.error('Optional auth error:', error)\n return await next()\n }\n }\n}","import { MiddlewareHandler } from 'hono'\nimport { metricsTracker } from '../utils/metrics'\n\n/**\n * Middleware to track all HTTP requests for real-time analytics\n * Excludes the metrics endpoint itself to avoid inflating the count\n */\nexport const metricsMiddleware = (): MiddlewareHandler => {\n return async (c, next) => {\n const path = new URL(c.req.url).pathname\n\n // Don't track the metrics endpoint itself to avoid self-inflating counts\n if (path !== '/admin/dashboard/api/metrics') {\n metricsTracker.recordRequest()\n }\n\n // Continue with the request\n await next()\n }\n}\n","/**\n * Middleware Module Exports\n *\n * Request processing middleware for SonicJS\n *\n * Note: Most middleware is currently in the monolith and will be migrated later.\n * For now, we only export the bootstrap middleware which is used for system initialization.\n */\n\n// Bootstrap middleware\nexport { bootstrapMiddleware } from './bootstrap'\n\n// Auth middleware\nexport { AuthManager, requireAuth, requireRole, optionalAuth } from './auth'\n\n// Metrics middleware\nexport { metricsMiddleware } from './metrics'\n\n// Re-export types and functions that are referenced but implemented in monolith\n// These are placeholder exports to maintain API compatibility\nexport type Permission = string\nexport type UserPermissions = {\n userId: string\n permissions: Permission[]\n}\n\n// Middleware stubs - these return pass-through middleware that call next()\nexport const loggingMiddleware: any = () => async (_c: any, next: any) => await next()\nexport const detailedLoggingMiddleware: any = () => async (_c: any, next: any) => await next()\nexport const securityLoggingMiddleware: any = () => async (_c: any, next: any) => await next()\nexport const performanceLoggingMiddleware: any = () => async (_c: any, next: any) => await next()\nexport const cacheHeaders: any = () => async (_c: any, next: any) => await next()\nexport const compressionMiddleware: any = async (_c: any, next: any) => await next()\nexport const securityHeaders: any = () => async (_c: any, next: any) => await next()\n\n// Other stubs\nexport const PermissionManager: any = {}\nexport const requirePermission: any = () => async (_c: any, next: any) => await next()\nexport const requireAnyPermission: any = () => async (_c: any, next: any) => await next()\nexport const logActivity: any = () => {}\nexport const requireActivePlugin: any = () => async (_c: any, next: any) => await next()\nexport const requireActivePlugins: any = () => async (_c: any, next: any) => await next()\nexport const getActivePlugins: any = () => []\nexport const isPluginActive: any = () => false\n"]}
@@ -1,8 +1,8 @@
1
1
  import { getCacheService, CACHE_CONFIGS, getLogger, SettingsService } from './chunk-6FR25MPC.js';
2
- import { requireAuth, isPluginActive, requireRole, AuthManager, logActivity } from './chunk-OKPDQO2Y.js';
2
+ import { requireAuth, isPluginActive, requireRole, AuthManager, logActivity } from './chunk-YHG45LMU.js';
3
3
  import { PluginService, MigrationService } from './chunk-COBUPOMD.js';
4
- import { init_admin_layout_catalyst_template, renderDesignPage, renderCheckboxPage, renderFAQList, renderTestimonialsList, renderCodeExamplesList, renderAlert, renderTable, renderPagination, renderConfirmationDialog, getConfirmationDialogScript, renderAdminLayoutCatalyst, renderAdminLayout, adminLayoutV2, renderForm } from './chunk-VEC5MLT3.js';
5
- import { QueryFilterBuilder, sanitizeInput, getCoreVersion, escapeHtml } from './chunk-WRRLB6KG.js';
4
+ import { init_admin_layout_catalyst_template, renderDesignPage, renderCheckboxPage, renderFAQList, renderTestimonialsList, renderCodeExamplesList, renderAlert, renderTable, renderPagination, renderConfirmationDialog, getConfirmationDialogScript, renderAdminLayoutCatalyst, renderAdminLayout, adminLayoutV2, renderForm } from './chunk-LW33AOBF.js';
5
+ import { QueryFilterBuilder, sanitizeInput, getCoreVersion, escapeHtml } from './chunk-MXJJN4IA.js';
6
6
  import { metricsTracker } from './chunk-FICTAGD4.js';
7
7
  import { Hono } from 'hono';
8
8
  import { cors } from 'hono/cors';
@@ -4760,6 +4760,28 @@ async function getCollectionFields(db, collectionId) {
4760
4760
  return cache.getOrSet(
4761
4761
  cache.generateKey("fields", collectionId),
4762
4762
  async () => {
4763
+ const collectionStmt = db.prepare("SELECT schema FROM collections WHERE id = ?");
4764
+ const collectionRow = await collectionStmt.bind(collectionId).first();
4765
+ if (collectionRow && collectionRow.schema) {
4766
+ try {
4767
+ const schema = typeof collectionRow.schema === "string" ? JSON.parse(collectionRow.schema) : collectionRow.schema;
4768
+ if (schema && schema.properties) {
4769
+ let fieldOrder = 0;
4770
+ return Object.entries(schema.properties).map(([fieldName, fieldConfig]) => ({
4771
+ id: `schema-${fieldName}`,
4772
+ field_name: fieldName,
4773
+ field_type: fieldConfig.type || "string",
4774
+ field_label: fieldConfig.title || fieldName,
4775
+ field_options: fieldConfig,
4776
+ field_order: fieldOrder++,
4777
+ is_required: fieldConfig.required === true || schema.required && schema.required.includes(fieldName),
4778
+ is_searchable: false
4779
+ }));
4780
+ }
4781
+ } catch (e) {
4782
+ console.error("Error parsing collection schema:", e);
4783
+ }
4784
+ }
4763
4785
  const stmt = db.prepare(`
4764
4786
  SELECT * FROM content_fields
4765
4787
  WHERE collection_id = ?
@@ -5207,9 +5229,9 @@ adminContentRoutes.post("/", async (c) => {
5207
5229
  INSERT INTO content (
5208
5230
  id, collection_id, slug, title, data, status,
5209
5231
  scheduled_publish_at, scheduled_unpublish_at,
5210
- meta_title, meta_description, author_id, created_by, created_at, updated_at
5232
+ meta_title, meta_description, author_id, created_at, updated_at
5211
5233
  )
5212
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
5234
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
5213
5235
  `);
5214
5236
  await insertStmt.bind(
5215
5237
  contentId,
@@ -5223,7 +5245,6 @@ adminContentRoutes.post("/", async (c) => {
5223
5245
  data.meta_title || null,
5224
5246
  data.meta_description || null,
5225
5247
  user?.userId || "unknown",
5226
- user?.userId || "unknown",
5227
5248
  now,
5228
5249
  now
5229
5250
  ).run();
@@ -5526,9 +5547,9 @@ adminContentRoutes.post("/duplicate", async (c) => {
5526
5547
  const insertStmt = db.prepare(`
5527
5548
  INSERT INTO content (
5528
5549
  id, collection_id, slug, title, data, status,
5529
- author_id, created_by, created_at, updated_at
5550
+ author_id, created_at, updated_at
5530
5551
  )
5531
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
5552
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
5532
5553
  `);
5533
5554
  await insertStmt.bind(
5534
5555
  newId,
@@ -5539,7 +5560,6 @@ adminContentRoutes.post("/duplicate", async (c) => {
5539
5560
  "draft",
5540
5561
  // Always start as draft
5541
5562
  user?.userId || "unknown",
5542
- user?.userId || "unknown",
5543
5563
  now,
5544
5564
  now
5545
5565
  ).run();
@@ -11090,6 +11110,28 @@ function renderPluginsListPage(data) {
11090
11110
  </div>
11091
11111
  </div>
11092
11112
 
11113
+ <!-- Experimental Notice -->
11114
+ <div class="mb-6 rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800/50 p-4">
11115
+ <div class="flex items-start">
11116
+ <div class="flex-shrink-0">
11117
+ <svg class="h-5 w-5 text-amber-600 dark:text-amber-400" viewBox="0 0 20 20" fill="currentColor">
11118
+ <path fill-rule="evenodd" d="M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd" />
11119
+ </svg>
11120
+ </div>
11121
+ <div class="ml-3 flex-1">
11122
+ <h3 class="text-sm font-semibold text-amber-800 dark:text-amber-200">
11123
+ Experimental Feature
11124
+ </h3>
11125
+ <div class="mt-2 text-sm text-amber-700 dark:text-amber-300">
11126
+ <p>
11127
+ Plugin management is currently under active development. While functional, some features may change or have limitations.
11128
+ Please report any issues you encounter on our <a href="https://discord.gg/8bMy6bv3sZ" target="_blank" class="font-medium underline hover:text-amber-900 dark:hover:text-amber-100">Discord community</a>.
11129
+ </p>
11130
+ </div>
11131
+ </div>
11132
+ </div>
11133
+ </div>
11134
+
11093
11135
  <!-- Stats -->
11094
11136
  <div class="mb-6">
11095
11137
  <h3 class="text-base font-semibold text-zinc-950 dark:text-white">Plugin Statistics</h3>
@@ -20252,5 +20294,5 @@ var ROUTES_INFO = {
20252
20294
  };
20253
20295
 
20254
20296
  export { ROUTES_INFO, adminCheckboxRoutes, adminCollectionsRoutes, adminDesignRoutes, adminLogsRoutes, adminMediaRoutes, adminPluginRoutes, adminSettingsRoutes, admin_api_default, admin_code_examples_default, admin_content_default, admin_faq_default, admin_testimonials_default, api_content_crud_default, api_default, api_media_default, api_system_default, auth_default, router, userRoutes };
20255
- //# sourceMappingURL=chunk-ABYMIXRN.js.map
20256
- //# sourceMappingURL=chunk-ABYMIXRN.js.map
20297
+ //# sourceMappingURL=chunk-Z4H6DBVF.js.map
20298
+ //# sourceMappingURL=chunk-Z4H6DBVF.js.map