@arch-cadre/core 0.0.23 → 0.0.26

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 (98) hide show
  1. package/dist/_virtual/_rolldown/runtime.cjs +1 -29
  2. package/dist/_virtual/_rolldown/runtime.mjs +1 -18
  3. package/dist/core/auth/augment.cjs +1 -71
  4. package/dist/core/auth/augment.d.cts.map +1 -1
  5. package/dist/core/auth/augment.d.mts.map +1 -1
  6. package/dist/core/auth/augment.mjs +1 -65
  7. package/dist/core/auth/augment.mjs.map +1 -1
  8. package/dist/core/auth/email-verification.cjs +1 -99
  9. package/dist/core/auth/email-verification.d.cts +1 -1
  10. package/dist/core/auth/email-verification.d.mts +1 -1
  11. package/dist/core/auth/email-verification.mjs +1 -91
  12. package/dist/core/auth/email-verification.mjs.map +1 -1
  13. package/dist/core/auth/logic.cjs +1 -224
  14. package/dist/core/auth/logic.d.cts +6 -6
  15. package/dist/core/auth/logic.d.mts +6 -6
  16. package/dist/core/auth/logic.mjs +1 -212
  17. package/dist/core/auth/logic.mjs.map +1 -1
  18. package/dist/core/auth/password-reset.cjs +1 -118
  19. package/dist/core/auth/password-reset.mjs +1 -110
  20. package/dist/core/auth/password-reset.mjs.map +1 -1
  21. package/dist/core/auth/rbac.cjs +1 -118
  22. package/dist/core/auth/rbac.d.cts +2 -2
  23. package/dist/core/auth/rbac.d.mts +2 -2
  24. package/dist/core/auth/rbac.mjs +1 -103
  25. package/dist/core/auth/rbac.mjs.map +1 -1
  26. package/dist/core/auth/session.cjs +1 -154
  27. package/dist/core/auth/session.mjs +1 -142
  28. package/dist/core/auth/session.mjs.map +1 -1
  29. package/dist/core/auth/types.d.cts.map +1 -1
  30. package/dist/core/auth/types.d.mts.map +1 -1
  31. package/dist/core/auth/utils/encode.cjs +1 -27
  32. package/dist/core/auth/utils/encode.mjs +1 -25
  33. package/dist/core/auth/utils/encode.mjs.map +1 -1
  34. package/dist/core/auth/utils/encryption.cjs +1 -67
  35. package/dist/core/auth/utils/encryption.mjs +1 -63
  36. package/dist/core/auth/utils/encryption.mjs.map +1 -1
  37. package/dist/core/auth/validation.cjs +1 -39
  38. package/dist/core/auth/validation.mjs +1 -30
  39. package/dist/core/auth/validation.mjs.map +1 -1
  40. package/dist/core/bootstrap.cjs +1 -39
  41. package/dist/core/bootstrap.mjs +1 -39
  42. package/dist/core/bootstrap.mjs.map +1 -1
  43. package/dist/core/config.cjs +1 -6
  44. package/dist/core/config.mjs +1 -5
  45. package/dist/core/config.mjs.map +1 -1
  46. package/dist/core/config.server.cjs +1 -60
  47. package/dist/core/config.server.mjs +1 -56
  48. package/dist/core/config.server.mjs.map +1 -1
  49. package/dist/core/event-bus.cjs +1 -48
  50. package/dist/core/event-bus.d.cts.map +1 -1
  51. package/dist/core/event-bus.d.mts.map +1 -1
  52. package/dist/core/event-bus.mjs +1 -47
  53. package/dist/core/event-bus.mjs.map +1 -1
  54. package/dist/core/filesystem/index.cjs +1 -11
  55. package/dist/core/filesystem/index.mjs +1 -12
  56. package/dist/core/filesystem/index.mjs.map +1 -1
  57. package/dist/core/filesystem/providers/local.cjs +1 -43
  58. package/dist/core/filesystem/providers/local.mjs +1 -40
  59. package/dist/core/filesystem/providers/local.mjs.map +1 -1
  60. package/dist/core/filesystem/service.cjs +1 -43
  61. package/dist/core/filesystem/service.mjs +1 -42
  62. package/dist/core/filesystem/service.mjs.map +1 -1
  63. package/dist/core/notifications/actions.cjs +1 -36
  64. package/dist/core/notifications/actions.d.cts +1 -1
  65. package/dist/core/notifications/actions.d.mts +1 -1
  66. package/dist/core/notifications/actions.mjs +1 -32
  67. package/dist/core/notifications/actions.mjs.map +1 -1
  68. package/dist/core/notifications/index.cjs +1 -2
  69. package/dist/core/notifications/index.mjs +1 -4
  70. package/dist/core/notifications/service.cjs +1 -30
  71. package/dist/core/notifications/service.mjs +1 -30
  72. package/dist/core/notifications/service.mjs.map +1 -1
  73. package/dist/core/setup.cjs +1 -25
  74. package/dist/core/setup.mjs +1 -24
  75. package/dist/core/setup.mjs.map +1 -1
  76. package/dist/index.cjs +1 -30
  77. package/dist/index.mjs +1 -6
  78. package/dist/server/auth/email.cjs +1 -24
  79. package/dist/server/auth/email.mjs +1 -22
  80. package/dist/server/auth/email.mjs.map +1 -1
  81. package/dist/server/auth/password.cjs +1 -37
  82. package/dist/server/auth/password.mjs +1 -33
  83. package/dist/server/auth/password.mjs.map +1 -1
  84. package/dist/server/auth/user.cjs +1 -165
  85. package/dist/server/auth/user.mjs +1 -152
  86. package/dist/server/auth/user.mjs.map +1 -1
  87. package/dist/server/database/inject.cjs +1 -24
  88. package/dist/server/database/inject.mjs +1 -22
  89. package/dist/server/database/inject.mjs.map +1 -1
  90. package/dist/server/database/schema.cjs +1 -163
  91. package/dist/server/database/schema.mjs +1 -150
  92. package/dist/server/database/schema.mjs.map +1 -1
  93. package/dist/server/emails/index.cjs +1 -32
  94. package/dist/server/emails/index.mjs +1 -28
  95. package/dist/server/emails/index.mjs.map +1 -1
  96. package/dist/server.cjs +1 -145
  97. package/dist/server.mjs +1 -23
  98. package/package.json +1 -1
@@ -1,31 +1,2 @@
1
- import { z } from "zod";
2
-
3
- //#region src/core/auth/validation.ts
4
- const loginSchema = z.object({
5
- email: z.string().email("Invalid email address"),
6
- password: z.string().min(8),
7
- remember: z.boolean().optional()
8
- });
9
- const registerSchema = z.object({
10
- username: z.string().min(2, "Name must be at least 2 characters"),
11
- email: z.string().email("Invalid email address"),
12
- password: z.string().min(8, "Password must be at least 8 characters"),
13
- terms: z.boolean().refine((val) => val === true, "You must accept the terms")
14
- });
15
- const forgotPasswordSchema = z.object({ email: z.string().email("Invalid email address") });
16
- const resetPasswordSchema = z.object({
17
- password: z.string().min(8, "Password must be at least 8 characters"),
18
- confirm: z.string()
19
- }).refine((data) => data.password === data.confirm, {
20
- message: "Passwords do not match",
21
- path: ["confirm"]
22
- });
23
- const verifyEmailSchema = z.object({ code: z.string().min(6).max(6) });
24
- const totpSetupSchema = z.object({ code: z.string().regex(/^\d{6}$/, "Code must be 6 digits") });
25
- const totpVerifySchema = z.object({ code: z.string().regex(/^\d{6}$/, "Code must be 6 digits") });
26
- const passkeysSetupSchema = z.object({ name: z.string().min(1, "Passkey name is required") });
27
- const recoveryCodeVerifySchema = z.object({ code: z.string().min(16, "Recovery code is required").max(16) });
28
-
29
- //#endregion
30
- export { forgotPasswordSchema, loginSchema, passkeysSetupSchema, recoveryCodeVerifySchema, registerSchema, resetPasswordSchema, totpSetupSchema, totpVerifySchema, verifyEmailSchema };
1
+ import{z as e}from"zod";const t=e.object({email:e.string().email(`Invalid email address`),password:e.string().min(8),remember:e.boolean().optional()}),n=e.object({username:e.string().min(2,`Name must be at least 2 characters`),email:e.string().email(`Invalid email address`),password:e.string().min(8,`Password must be at least 8 characters`),terms:e.boolean().refine(e=>e===!0,`You must accept the terms`)}),r=e.object({email:e.string().email(`Invalid email address`)}),i=e.object({password:e.string().min(8,`Password must be at least 8 characters`),confirm:e.string()}).refine(e=>e.password===e.confirm,{message:`Passwords do not match`,path:[`confirm`]}),a=e.object({code:e.string().min(6).max(6)}),o=e.object({code:e.string().regex(/^\d{6}$/,`Code must be 6 digits`)}),s=e.object({code:e.string().regex(/^\d{6}$/,`Code must be 6 digits`)}),c=e.object({name:e.string().min(1,`Passkey name is required`)}),l=e.object({code:e.string().min(16,`Recovery code is required`).max(16)});export{r as forgotPasswordSchema,t as loginSchema,c as passkeysSetupSchema,l as recoveryCodeVerifySchema,n as registerSchema,i as resetPasswordSchema,o as totpSetupSchema,s as totpVerifySchema,a as verifyEmailSchema};
31
2
  //# sourceMappingURL=validation.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"validation.mjs","names":[],"sources":["../../../src/core/auth/validation.ts"],"sourcesContent":["import { z } from \"zod\";\n\n// Auth validation schemas - CLEAN (No DB dependencies for client-side)\nexport const loginSchema = z.object({\n email: z.string().email(\"Invalid email address\"),\n password: z.string().min(8),\n remember: z.boolean().optional(),\n});\n\nexport const registerSchema = z.object({\n username: z.string().min(2, \"Name must be at least 2 characters\"),\n email: z.string().email(\"Invalid email address\"),\n password: z.string().min(8, \"Password must be at least 8 characters\"),\n terms: z.boolean().refine((val) => val === true, \"You must accept the terms\"),\n});\n\nexport const forgotPasswordSchema = z.object({\n email: z.string().email(\"Invalid email address\"),\n});\n\nexport const resetPasswordSchema = z\n .object({\n password: z.string().min(8, \"Password must be at least 8 characters\"),\n confirm: z.string(),\n })\n .refine((data) => data.password === data.confirm, {\n message: \"Passwords do not match\",\n path: [\"confirm\"],\n });\n\nexport const verifyEmailSchema = z.object({\n code: z.string().min(6).max(6),\n});\n\n// mfa validation schemas\nexport const totpSetupSchema = z.object({\n code: z.string().regex(/^\\d{6}$/, \"Code must be 6 digits\"),\n});\n\nexport const totpVerifySchema = z.object({\n code: z.string().regex(/^\\d{6}$/, \"Code must be 6 digits\"),\n});\n\nexport const passkeysSetupSchema = z.object({\n name: z.string().min(1, \"Passkey name is required\"),\n});\n\nexport const recoveryCodeVerifySchema = z.object({\n code: z.string().min(16, \"Recovery code is required\").max(16),\n});\n\n// Type exports for use in components\nexport type LoginInput = z.infer<typeof loginSchema>;\nexport type RegisterInput = z.infer<typeof registerSchema>;\nexport type ForgotPasswordInput = z.infer<typeof forgotPasswordSchema>;\nexport type ResetPasswordInput = z.infer<typeof resetPasswordSchema>;\nexport type TOTPSetupInput = z.infer<typeof totpSetupSchema>;\nexport type TOTPVerifyInput = z.infer<typeof totpVerifySchema>;\nexport type PasskeysSetupInput = z.infer<typeof passkeysSetupSchema>;\nexport type VerifyEmailInput = z.infer<typeof verifyEmailSchema>;\nexport type RecoveryVerifyInput = z.infer<typeof recoveryCodeVerifySchema>;\n"],"mappings":";;;AAGA,MAAa,cAAc,EAAE,OAAO;CAClC,OAAO,EAAE,QAAQ,CAAC,MAAM,wBAAwB;CAChD,UAAU,EAAE,QAAQ,CAAC,IAAI,EAAE;CAC3B,UAAU,EAAE,SAAS,CAAC,UAAU;CACjC,CAAC;AAEF,MAAa,iBAAiB,EAAE,OAAO;CACrC,UAAU,EAAE,QAAQ,CAAC,IAAI,GAAG,qCAAqC;CACjE,OAAO,EAAE,QAAQ,CAAC,MAAM,wBAAwB;CAChD,UAAU,EAAE,QAAQ,CAAC,IAAI,GAAG,yCAAyC;CACrE,OAAO,EAAE,SAAS,CAAC,QAAQ,QAAQ,QAAQ,MAAM,4BAA4B;CAC9E,CAAC;AAEF,MAAa,uBAAuB,EAAE,OAAO,EAC3C,OAAO,EAAE,QAAQ,CAAC,MAAM,wBAAwB,EACjD,CAAC;AAEF,MAAa,sBAAsB,EAChC,OAAO;CACN,UAAU,EAAE,QAAQ,CAAC,IAAI,GAAG,yCAAyC;CACrE,SAAS,EAAE,QAAQ;CACpB,CAAC,CACD,QAAQ,SAAS,KAAK,aAAa,KAAK,SAAS;CAChD,SAAS;CACT,MAAM,CAAC,UAAU;CAClB,CAAC;AAEJ,MAAa,oBAAoB,EAAE,OAAO,EACxC,MAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,EAC/B,CAAC;AAGF,MAAa,kBAAkB,EAAE,OAAO,EACtC,MAAM,EAAE,QAAQ,CAAC,MAAM,WAAW,wBAAwB,EAC3D,CAAC;AAEF,MAAa,mBAAmB,EAAE,OAAO,EACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,WAAW,wBAAwB,EAC3D,CAAC;AAEF,MAAa,sBAAsB,EAAE,OAAO,EAC1C,MAAM,EAAE,QAAQ,CAAC,IAAI,GAAG,2BAA2B,EACpD,CAAC;AAEF,MAAa,2BAA2B,EAAE,OAAO,EAC/C,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAI,4BAA4B,CAAC,IAAI,GAAG,EAC9D,CAAC"}
1
+ {"version":3,"file":"validation.mjs","names":[],"sources":["../../../src/core/auth/validation.ts"],"sourcesContent":["import { z } from \"zod\";\n\n// Auth validation schemas - CLEAN (No DB dependencies for client-side)\nexport const loginSchema = z.object({\n email: z.string().email(\"Invalid email address\"),\n password: z.string().min(8),\n remember: z.boolean().optional(),\n});\n\nexport const registerSchema = z.object({\n username: z.string().min(2, \"Name must be at least 2 characters\"),\n email: z.string().email(\"Invalid email address\"),\n password: z.string().min(8, \"Password must be at least 8 characters\"),\n terms: z.boolean().refine((val) => val === true, \"You must accept the terms\"),\n});\n\nexport const forgotPasswordSchema = z.object({\n email: z.string().email(\"Invalid email address\"),\n});\n\nexport const resetPasswordSchema = z\n .object({\n password: z.string().min(8, \"Password must be at least 8 characters\"),\n confirm: z.string(),\n })\n .refine((data) => data.password === data.confirm, {\n message: \"Passwords do not match\",\n path: [\"confirm\"],\n });\n\nexport const verifyEmailSchema = z.object({\n code: z.string().min(6).max(6),\n});\n\n// mfa validation schemas\nexport const totpSetupSchema = z.object({\n code: z.string().regex(/^\\d{6}$/, \"Code must be 6 digits\"),\n});\n\nexport const totpVerifySchema = z.object({\n code: z.string().regex(/^\\d{6}$/, \"Code must be 6 digits\"),\n});\n\nexport const passkeysSetupSchema = z.object({\n name: z.string().min(1, \"Passkey name is required\"),\n});\n\nexport const recoveryCodeVerifySchema = z.object({\n code: z.string().min(16, \"Recovery code is required\").max(16),\n});\n\n// Type exports for use in components\nexport type LoginInput = z.infer<typeof loginSchema>;\nexport type RegisterInput = z.infer<typeof registerSchema>;\nexport type ForgotPasswordInput = z.infer<typeof forgotPasswordSchema>;\nexport type ResetPasswordInput = z.infer<typeof resetPasswordSchema>;\nexport type TOTPSetupInput = z.infer<typeof totpSetupSchema>;\nexport type TOTPVerifyInput = z.infer<typeof totpVerifySchema>;\nexport type PasskeysSetupInput = z.infer<typeof passkeysSetupSchema>;\nexport type VerifyEmailInput = z.infer<typeof verifyEmailSchema>;\nexport type RecoveryVerifyInput = z.infer<typeof recoveryCodeVerifySchema>;\n"],"mappings":"wBAGA,MAAa,EAAc,EAAE,OAAO,CAClC,MAAO,EAAE,QAAQ,CAAC,MAAM,wBAAwB,CAChD,SAAU,EAAE,QAAQ,CAAC,IAAI,EAAE,CAC3B,SAAU,EAAE,SAAS,CAAC,UAAU,CACjC,CAAC,CAEW,EAAiB,EAAE,OAAO,CACrC,SAAU,EAAE,QAAQ,CAAC,IAAI,EAAG,qCAAqC,CACjE,MAAO,EAAE,QAAQ,CAAC,MAAM,wBAAwB,CAChD,SAAU,EAAE,QAAQ,CAAC,IAAI,EAAG,yCAAyC,CACrE,MAAO,EAAE,SAAS,CAAC,OAAQ,GAAQ,IAAQ,GAAM,4BAA4B,CAC9E,CAAC,CAEW,EAAuB,EAAE,OAAO,CAC3C,MAAO,EAAE,QAAQ,CAAC,MAAM,wBAAwB,CACjD,CAAC,CAEW,EAAsB,EAChC,OAAO,CACN,SAAU,EAAE,QAAQ,CAAC,IAAI,EAAG,yCAAyC,CACrE,QAAS,EAAE,QAAQ,CACpB,CAAC,CACD,OAAQ,GAAS,EAAK,WAAa,EAAK,QAAS,CAChD,QAAS,yBACT,KAAM,CAAC,UAAU,CAClB,CAAC,CAES,EAAoB,EAAE,OAAO,CACxC,KAAM,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAC/B,CAAC,CAGW,EAAkB,EAAE,OAAO,CACtC,KAAM,EAAE,QAAQ,CAAC,MAAM,UAAW,wBAAwB,CAC3D,CAAC,CAEW,EAAmB,EAAE,OAAO,CACvC,KAAM,EAAE,QAAQ,CAAC,MAAM,UAAW,wBAAwB,CAC3D,CAAC,CAEW,EAAsB,EAAE,OAAO,CAC1C,KAAM,EAAE,QAAQ,CAAC,IAAI,EAAG,2BAA2B,CACpD,CAAC,CAEW,EAA2B,EAAE,OAAO,CAC/C,KAAM,EAAE,QAAQ,CAAC,IAAI,GAAI,4BAA4B,CAAC,IAAI,GAAG,CAC9D,CAAC"}
@@ -1,39 +1 @@
1
- const require_event_bus = require('./event-bus.cjs');
2
- const require_inject = require('../server/database/inject.cjs');
3
- const require_email_verification = require('./auth/email-verification.cjs');
4
- const require_service = require('./notifications/service.cjs');
5
- const require_local = require('./filesystem/providers/local.cjs');
6
- const require_service$1 = require('./filesystem/service.cjs');
7
- require('./filesystem/index.cjs');
8
- const require_setup = require('./setup.cjs');
9
-
10
- //#region src/core/bootstrap.ts
11
- async function ensureSystemInitialized(providedDb) {
12
- if (typeof window !== "undefined") return;
13
- const g = globalThis;
14
- if (providedDb) require_inject.injectDb(providedDb);
15
- if (g.__KRYO_INITIALIZED__) return;
16
- if (g.__KRYO_INITIALIZING__) return;
17
- g.__KRYO_INITIALIZING__ = true;
18
- try {
19
- console.log("[Kryo:Bootstrap] Starting system initialization...");
20
- if (!g.__KRYO_DB__) console.warn("[Kryo:Bootstrap] DB not detected during bootstrap start. Trying to continue...");
21
- if (await require_setup.isSystemInstalled()) {
22
- require_service.notificationService.init();
23
- await require_email_verification.initEmailVerification();
24
- const local = new require_local.LocalFileProvider();
25
- require_service$1.filesystemService.registerProvider(local);
26
- require_service$1.filesystemService.setDefaultProvider(local.id);
27
- } else console.log("[Kryo:Bootstrap] System not installed. Skipping module initialization.");
28
- await require_event_bus.eventBus.publish("system:start", { runtime: "nodejs" });
29
- console.log("[Kryo:Bootstrap] System initialized successfully.");
30
- g.__KRYO_INITIALIZED__ = true;
31
- } catch (error) {
32
- console.error("[Kryo:Bootstrap] Initialization failed:", error);
33
- } finally {
34
- g.__KRYO_INITIALIZING__ = false;
35
- }
36
- }
37
-
38
- //#endregion
39
- exports.ensureSystemInitialized = ensureSystemInitialized;
1
+ const e=require(`./event-bus.cjs`),t=require(`../server/database/inject.cjs`),n=require(`./auth/email-verification.cjs`),r=require(`./notifications/service.cjs`),i=require(`./filesystem/providers/local.cjs`),a=require(`./filesystem/service.cjs`);require(`./filesystem/index.cjs`);const o=require(`./setup.cjs`);async function s(s){if(typeof window<`u`)return;let c=globalThis;if(s&&t.injectDb(s),!c.__KRYO_INITIALIZED__&&!c.__KRYO_INITIALIZING__){c.__KRYO_INITIALIZING__=!0;try{if(console.log(`[Kryo:Bootstrap] Starting system initialization...`),c.__KRYO_DB__||console.warn(`[Kryo:Bootstrap] DB not detected during bootstrap start. Trying to continue...`),await o.isSystemInstalled()){r.notificationService.init(),await n.initEmailVerification();let e=new i.LocalFileProvider;a.filesystemService.registerProvider(e),a.filesystemService.setDefaultProvider(e.id)}else console.log(`[Kryo:Bootstrap] System not installed. Skipping module initialization.`);await e.eventBus.publish(`system:start`,{runtime:`nodejs`}),console.log(`[Kryo:Bootstrap] System initialized successfully.`),c.__KRYO_INITIALIZED__=!0}catch(e){console.error(`[Kryo:Bootstrap] Initialization failed:`,e)}finally{c.__KRYO_INITIALIZING__=!1}}}exports.ensureSystemInitialized=s;
@@ -1,40 +1,2 @@
1
- import { eventBus } from "./event-bus.mjs";
2
- import { injectDb } from "../server/database/inject.mjs";
3
- import { initEmailVerification } from "./auth/email-verification.mjs";
4
- import { notificationService } from "./notifications/service.mjs";
5
- import { LocalFileProvider } from "./filesystem/providers/local.mjs";
6
- import { filesystemService } from "./filesystem/service.mjs";
7
- import "./filesystem/index.mjs";
8
- import { isSystemInstalled } from "./setup.mjs";
9
-
10
- //#region src/core/bootstrap.ts
11
- async function ensureSystemInitialized(providedDb) {
12
- if (typeof window !== "undefined") return;
13
- const g = globalThis;
14
- if (providedDb) injectDb(providedDb);
15
- if (g.__KRYO_INITIALIZED__) return;
16
- if (g.__KRYO_INITIALIZING__) return;
17
- g.__KRYO_INITIALIZING__ = true;
18
- try {
19
- console.log("[Kryo:Bootstrap] Starting system initialization...");
20
- if (!g.__KRYO_DB__) console.warn("[Kryo:Bootstrap] DB not detected during bootstrap start. Trying to continue...");
21
- if (await isSystemInstalled()) {
22
- notificationService.init();
23
- await initEmailVerification();
24
- const local = new LocalFileProvider();
25
- filesystemService.registerProvider(local);
26
- filesystemService.setDefaultProvider(local.id);
27
- } else console.log("[Kryo:Bootstrap] System not installed. Skipping module initialization.");
28
- await eventBus.publish("system:start", { runtime: "nodejs" });
29
- console.log("[Kryo:Bootstrap] System initialized successfully.");
30
- g.__KRYO_INITIALIZED__ = true;
31
- } catch (error) {
32
- console.error("[Kryo:Bootstrap] Initialization failed:", error);
33
- } finally {
34
- g.__KRYO_INITIALIZING__ = false;
35
- }
36
- }
37
-
38
- //#endregion
39
- export { ensureSystemInitialized };
1
+ import{eventBus as e}from"./event-bus.mjs";import{injectDb as t}from"../server/database/inject.mjs";import{initEmailVerification as n}from"./auth/email-verification.mjs";import{notificationService as r}from"./notifications/service.mjs";import{LocalFileProvider as i}from"./filesystem/providers/local.mjs";import{filesystemService as a}from"./filesystem/service.mjs";import"./filesystem/index.mjs";import{isSystemInstalled as o}from"./setup.mjs";async function s(s){if(typeof window<`u`)return;let c=globalThis;if(s&&t(s),!c.__KRYO_INITIALIZED__&&!c.__KRYO_INITIALIZING__){c.__KRYO_INITIALIZING__=!0;try{if(console.log(`[Kryo:Bootstrap] Starting system initialization...`),c.__KRYO_DB__||console.warn(`[Kryo:Bootstrap] DB not detected during bootstrap start. Trying to continue...`),await o()){r.init(),await n();let e=new i;a.registerProvider(e),a.setDefaultProvider(e.id)}else console.log(`[Kryo:Bootstrap] System not installed. Skipping module initialization.`);await e.publish(`system:start`,{runtime:`nodejs`}),console.log(`[Kryo:Bootstrap] System initialized successfully.`),c.__KRYO_INITIALIZED__=!0}catch(e){console.error(`[Kryo:Bootstrap] Initialization failed:`,e)}finally{c.__KRYO_INITIALIZING__=!1}}}export{s as ensureSystemInitialized};
40
2
  //# sourceMappingURL=bootstrap.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.mjs","names":[],"sources":["../../src/core/bootstrap.ts"],"sourcesContent":["import { injectDb } from \"../server/database/inject\";\nimport { initEmailVerification } from \"./auth/email-verification\";\nimport { eventBus } from \"./event-bus\";\nimport { filesystemService } from \"./filesystem\";\nimport { LocalFileProvider } from \"./filesystem/providers/local\";\nimport { notificationService } from \"./notifications/service\";\nimport { isSystemInstalled } from \"./setup\";\n\nexport async function ensureSystemInitialized(providedDb?: any) {\n if (typeof window !== \"undefined\") return;\n\n const g = globalThis as any;\n\n // 1. Immediate injection if provided\n if (providedDb) {\n injectDb(providedDb);\n }\n\n // 2. Prevent infinite recursion and double initialization\n if (g.__KRYO_INITIALIZED__) return;\n if (g.__KRYO_INITIALIZING__) return; // Already in progress, don't block/deadlock\n\n g.__KRYO_INITIALIZING__ = true;\n\n try {\n console.log(\"[Kryo:Bootstrap] Starting system initialization...\");\n\n // Check if we have DB after any possible injection\n if (!g.__KRYO_DB__) {\n console.warn(\n \"[Kryo:Bootstrap] DB not detected during bootstrap start. Trying to continue...\",\n );\n }\n\n // Check if system is installed before initializing modules\n if (await isSystemInstalled()) {\n // Order matters: services first, then modules (which use services)\n notificationService.init();\n await initEmailVerification();\n\n // Auto-register local filesystem provider as a fallback\n const local = new LocalFileProvider();\n\n filesystemService.registerProvider(local);\n filesystemService.setDefaultProvider(local.id);\n } else {\n console.log(\n \"[Kryo:Bootstrap] System not installed. Skipping module initialization.\",\n );\n }\n\n await eventBus.publish(\"system:start\", { runtime: \"nodejs\" });\n\n console.log(\"[Kryo:Bootstrap] System initialized successfully.\");\n g.__KRYO_INITIALIZED__ = true;\n } catch (error) {\n console.error(\"[Kryo:Bootstrap] Initialization failed:\", error);\n } finally {\n g.__KRYO_INITIALIZING__ = false;\n }\n}\n"],"mappings":";;;;;;;;;;AAQA,eAAsB,wBAAwB,YAAkB;AAC9D,KAAI,OAAO,WAAW,YAAa;CAEnC,MAAM,IAAI;AAGV,KAAI,WACF,UAAS,WAAW;AAItB,KAAI,EAAE,qBAAsB;AAC5B,KAAI,EAAE,sBAAuB;AAE7B,GAAE,wBAAwB;AAE1B,KAAI;AACF,UAAQ,IAAI,qDAAqD;AAGjE,MAAI,CAAC,EAAE,YACL,SAAQ,KACN,iFACD;AAIH,MAAI,MAAM,mBAAmB,EAAE;AAE7B,uBAAoB,MAAM;AAC1B,SAAM,uBAAuB;GAG7B,MAAM,QAAQ,IAAI,mBAAmB;AAErC,qBAAkB,iBAAiB,MAAM;AACzC,qBAAkB,mBAAmB,MAAM,GAAG;QAE9C,SAAQ,IACN,yEACD;AAGH,QAAM,SAAS,QAAQ,gBAAgB,EAAE,SAAS,UAAU,CAAC;AAE7D,UAAQ,IAAI,oDAAoD;AAChE,IAAE,uBAAuB;UAClB,OAAO;AACd,UAAQ,MAAM,2CAA2C,MAAM;WACvD;AACR,IAAE,wBAAwB"}
1
+ {"version":3,"file":"bootstrap.mjs","names":[],"sources":["../../src/core/bootstrap.ts"],"sourcesContent":["import { injectDb } from \"../server/database/inject.js\";\nimport { initEmailVerification } from \"./auth/email-verification.js\";\nimport { eventBus } from \"./event-bus.js\";\nimport { filesystemService } from \"./filesystem/index.js\";\nimport { LocalFileProvider } from \"./filesystem/providers/local.js\";\nimport { notificationService } from \"./notifications/service.js\";\nimport { isSystemInstalled } from \"./setup.js\";\n\nexport async function ensureSystemInitialized(providedDb?: any) {\n if (typeof window !== \"undefined\") return;\n\n const g = globalThis as any;\n\n // 1. Immediate injection if provided\n if (providedDb) {\n injectDb(providedDb);\n }\n\n // 2. Prevent infinite recursion and double initialization\n if (g.__KRYO_INITIALIZED__) return;\n if (g.__KRYO_INITIALIZING__) return; // Already in progress, don't block/deadlock\n\n g.__KRYO_INITIALIZING__ = true;\n\n try {\n console.log(\"[Kryo:Bootstrap] Starting system initialization...\");\n\n // Check if we have DB after any possible injection\n if (!g.__KRYO_DB__) {\n console.warn(\n \"[Kryo:Bootstrap] DB not detected during bootstrap start. Trying to continue...\",\n );\n }\n\n // Check if system is installed before initializing modules\n if (await isSystemInstalled()) {\n // Order matters: services first, then modules (which use services)\n notificationService.init();\n await initEmailVerification();\n\n // Auto-register local filesystem provider as a fallback\n const local = new LocalFileProvider();\n\n filesystemService.registerProvider(local);\n filesystemService.setDefaultProvider(local.id);\n } else {\n console.log(\n \"[Kryo:Bootstrap] System not installed. Skipping module initialization.\",\n );\n }\n\n await eventBus.publish(\"system:start\", { runtime: \"nodejs\" });\n\n console.log(\"[Kryo:Bootstrap] System initialized successfully.\");\n g.__KRYO_INITIALIZED__ = true;\n } catch (error) {\n console.error(\"[Kryo:Bootstrap] Initialization failed:\", error);\n } finally {\n g.__KRYO_INITIALIZING__ = false;\n }\n}\n"],"mappings":"6bAQA,eAAsB,EAAwB,EAAkB,CAC9D,GAAI,OAAO,OAAW,IAAa,OAEnC,IAAM,EAAI,WAGV,GAAI,GACF,EAAS,EAAW,CAIlB,GAAE,sBACF,GAAE,sBAEN,GAAE,sBAAwB,GAE1B,GAAI,CAWF,GAVA,QAAQ,IAAI,qDAAqD,CAG5D,EAAE,aACL,QAAQ,KACN,iFACD,CAIC,MAAM,GAAmB,CAAE,CAE7B,EAAoB,MAAM,CAC1B,MAAM,GAAuB,CAG7B,IAAM,EAAQ,IAAI,EAElB,EAAkB,iBAAiB,EAAM,CACzC,EAAkB,mBAAmB,EAAM,GAAG,MAE9C,QAAQ,IACN,yEACD,CAGH,MAAM,EAAS,QAAQ,eAAgB,CAAE,QAAS,SAAU,CAAC,CAE7D,QAAQ,IAAI,oDAAoD,CAChE,EAAE,qBAAuB,SAClB,EAAO,CACd,QAAQ,MAAM,0CAA2C,EAAM,QACvD,CACR,EAAE,sBAAwB"}
@@ -1,6 +1 @@
1
-
2
- //#region src/core/config.ts
3
- const DEFAULT_CONFIG = { modulesDirectory: "modules" };
4
-
5
- //#endregion
6
- exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
1
+ const e={modulesDirectory:`modules`};exports.DEFAULT_CONFIG=e;
@@ -1,6 +1,2 @@
1
- //#region src/core/config.ts
2
- const DEFAULT_CONFIG = { modulesDirectory: "modules" };
3
-
4
- //#endregion
5
- export { DEFAULT_CONFIG };
1
+ const e={modulesDirectory:`modules`};export{e as DEFAULT_CONFIG};
6
2
  //# sourceMappingURL=config.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.mjs","names":[],"sources":["../../src/core/config.ts"],"sourcesContent":["export interface KryoConfig {\n /**\n * Path to the directory with local modules.\n * Default: \"./modules\"\n */\n modulesDirectory?: string;\n}\n\nexport const DEFAULT_CONFIG: KryoConfig = {\n modulesDirectory: \"modules\",\n};\n"],"mappings":";AAQA,MAAa,iBAA6B,EACxC,kBAAkB,WACnB"}
1
+ {"version":3,"file":"config.mjs","names":[],"sources":["../../src/core/config.ts"],"sourcesContent":["export interface KryoConfig {\n /**\n * Path to the directory with local modules.\n * Default: \"./modules\"\n */\n modulesDirectory?: string;\n}\n\nexport const DEFAULT_CONFIG: KryoConfig = {\n modulesDirectory: \"modules\",\n};\n"],"mappings":"AAQA,MAAa,EAA6B,CACxC,iBAAkB,UACnB"}
@@ -1,60 +1 @@
1
- const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
2
- const require_config = require('./config.cjs');
3
- let node_fs = require("node:fs");
4
- node_fs = require_runtime.__toESM(node_fs);
5
- let node_path = require("node:path");
6
- node_path = require_runtime.__toESM(node_path);
7
-
8
- //#region src/core/config.server.ts
9
- let cachedConfig = null;
10
- /**
11
- * Loads the Kryo configuration from kryo.config.ts or kryo.config.js in the current working directory.
12
- * SERVER ONLY.
13
- */
14
- async function getKryoConfig() {
15
- if (typeof window !== "undefined") throw new Error("getKryoConfig can only be called on the server.");
16
- if (process.env.NODE_ENV === "production" && cachedConfig) return cachedConfig;
17
- const cwd = process.cwd();
18
- const configPathTS = node_path.default.join(cwd, "kryo.config.ts");
19
- const configPathJS = node_path.default.join(cwd, "kryo.config.js");
20
- const configPathMJS = node_path.default.join(cwd, "kryo.config.mjs");
21
- let loadedConfig = {};
22
- try {
23
- const { createJiti } = await import("jiti");
24
- const jiti = createJiti(cwd, {
25
- fsCache: false,
26
- moduleCache: false
27
- });
28
- if (node_fs.default.existsSync(configPathTS)) {
29
- const cacheBuster = `?t=${Date.now()}`;
30
- const imported = await jiti.import(`file://${configPathTS}${cacheBuster}`, { default: true });
31
- loadedConfig = imported.default || imported;
32
- } else if (node_fs.default.existsSync(configPathMJS)) {
33
- const imported = await jiti.import(configPathMJS, { default: true });
34
- loadedConfig = imported.default || imported;
35
- } else if (node_fs.default.existsSync(configPathJS)) {
36
- const imported = await jiti.import(configPathJS, { default: true });
37
- loadedConfig = imported.default || imported;
38
- }
39
- } catch (error) {
40
- console.warn("[Kryo:Config] Could not load kryo.config.ts, using defaults.", error);
41
- }
42
- const finalConfig = {
43
- ...require_config.DEFAULT_CONFIG,
44
- ...loadedConfig
45
- };
46
- if (process.env.NODE_ENV === "production") cachedConfig = finalConfig;
47
- return finalConfig;
48
- }
49
- /**
50
- * Helper returning the absolute path to the modules directory.
51
- * SERVER ONLY.
52
- */
53
- async function getModulesDir() {
54
- const dir = (await getKryoConfig()).modulesDirectory || "modules";
55
- return node_path.default.isAbsolute(dir) ? dir : node_path.default.join(process.cwd(), dir);
56
- }
57
-
58
- //#endregion
59
- exports.getKryoConfig = getKryoConfig;
60
- exports.getModulesDir = getModulesDir;
1
+ const e=require(`../_virtual/_rolldown/runtime.cjs`),t=require(`./config.cjs`);let n=require(`node:fs`);n=e.__toESM(n);let r=require(`node:path`);r=e.__toESM(r);let i=null;async function a(){if(typeof window<`u`)throw Error(`getKryoConfig can only be called on the server.`);if(process.env.NODE_ENV===`production`&&i)return i;let e=process.cwd(),a=r.default.join(e,`kryo.config.ts`),o=r.default.join(e,`kryo.config.js`),s=r.default.join(e,`kryo.config.mjs`),c={};try{let{createJiti:t}=await import(`jiti`),r=t(e,{fsCache:!1,moduleCache:!1});if(n.default.existsSync(a)){let e=`?t=${Date.now()}`,t=await r.import(`file://${a}${e}`,{default:!0});c=t.default||t}else if(n.default.existsSync(s)){let e=await r.import(s,{default:!0});c=e.default||e}else if(n.default.existsSync(o)){let e=await r.import(o,{default:!0});c=e.default||e}}catch(e){console.warn(`[Kryo:Config] Could not load kryo.config.ts, using defaults.`,e)}let l={...t.DEFAULT_CONFIG,...c};return process.env.NODE_ENV===`production`&&(i=l),l}async function o(){let e=(await a()).modulesDirectory||`modules`;return r.default.isAbsolute(e)?e:r.default.join(process.cwd(),e)}exports.getKryoConfig=a,exports.getModulesDir=o;
@@ -1,57 +1,2 @@
1
- import { DEFAULT_CONFIG } from "./config.mjs";
2
- import fs from "node:fs";
3
- import path from "node:path";
4
-
5
- //#region src/core/config.server.ts
6
- let cachedConfig = null;
7
- /**
8
- * Loads the Kryo configuration from kryo.config.ts or kryo.config.js in the current working directory.
9
- * SERVER ONLY.
10
- */
11
- async function getKryoConfig() {
12
- if (typeof window !== "undefined") throw new Error("getKryoConfig can only be called on the server.");
13
- if (process.env.NODE_ENV === "production" && cachedConfig) return cachedConfig;
14
- const cwd = process.cwd();
15
- const configPathTS = path.join(cwd, "kryo.config.ts");
16
- const configPathJS = path.join(cwd, "kryo.config.js");
17
- const configPathMJS = path.join(cwd, "kryo.config.mjs");
18
- let loadedConfig = {};
19
- try {
20
- const { createJiti } = await import("jiti");
21
- const jiti = createJiti(cwd, {
22
- fsCache: false,
23
- moduleCache: false
24
- });
25
- if (fs.existsSync(configPathTS)) {
26
- const cacheBuster = `?t=${Date.now()}`;
27
- const imported = await jiti.import(`file://${configPathTS}${cacheBuster}`, { default: true });
28
- loadedConfig = imported.default || imported;
29
- } else if (fs.existsSync(configPathMJS)) {
30
- const imported = await jiti.import(configPathMJS, { default: true });
31
- loadedConfig = imported.default || imported;
32
- } else if (fs.existsSync(configPathJS)) {
33
- const imported = await jiti.import(configPathJS, { default: true });
34
- loadedConfig = imported.default || imported;
35
- }
36
- } catch (error) {
37
- console.warn("[Kryo:Config] Could not load kryo.config.ts, using defaults.", error);
38
- }
39
- const finalConfig = {
40
- ...DEFAULT_CONFIG,
41
- ...loadedConfig
42
- };
43
- if (process.env.NODE_ENV === "production") cachedConfig = finalConfig;
44
- return finalConfig;
45
- }
46
- /**
47
- * Helper returning the absolute path to the modules directory.
48
- * SERVER ONLY.
49
- */
50
- async function getModulesDir() {
51
- const dir = (await getKryoConfig()).modulesDirectory || "modules";
52
- return path.isAbsolute(dir) ? dir : path.join(process.cwd(), dir);
53
- }
54
-
55
- //#endregion
56
- export { getKryoConfig, getModulesDir };
1
+ import{DEFAULT_CONFIG as e}from"./config.mjs";import t from"node:fs";import n from"node:path";let r=null;async function i(){if(typeof window<`u`)throw Error(`getKryoConfig can only be called on the server.`);if(process.env.NODE_ENV===`production`&&r)return r;let i=process.cwd(),a=n.join(i,`kryo.config.ts`),o=n.join(i,`kryo.config.js`),s=n.join(i,`kryo.config.mjs`),c={};try{let{createJiti:e}=await import(`jiti`),n=e(i,{fsCache:!1,moduleCache:!1});if(t.existsSync(a)){let e=`?t=${Date.now()}`,t=await n.import(`file://${a}${e}`,{default:!0});c=t.default||t}else if(t.existsSync(s)){let e=await n.import(s,{default:!0});c=e.default||e}else if(t.existsSync(o)){let e=await n.import(o,{default:!0});c=e.default||e}}catch(e){console.warn(`[Kryo:Config] Could not load kryo.config.ts, using defaults.`,e)}let l={...e,...c};return process.env.NODE_ENV===`production`&&(r=l),l}async function a(){let e=(await i()).modulesDirectory||`modules`;return n.isAbsolute(e)?e:n.join(process.cwd(),e)}export{i as getKryoConfig,a as getModulesDir};
57
2
  //# sourceMappingURL=config.server.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.server.mjs","names":[],"sources":["../../src/core/config.server.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { DEFAULT_CONFIG, type KryoConfig } from \"./config\";\n\nlet cachedConfig: KryoConfig | null = null;\n\n/**\n * Loads the Kryo configuration from kryo.config.ts or kryo.config.js in the current working directory.\n * SERVER ONLY.\n */\nexport async function getKryoConfig(): Promise<KryoConfig> {\n // Prevent this from ever running on the client even if imported\n if (typeof window !== \"undefined\") {\n throw new Error(\"getKryoConfig can only be called on the server.\");\n }\n\n // Use memory cache in production\n if (process.env.NODE_ENV === \"production\" && cachedConfig) {\n return cachedConfig;\n }\n\n const cwd = process.cwd();\n const configPathTS = path.join(cwd, \"kryo.config.ts\");\n const configPathJS = path.join(cwd, \"kryo.config.js\");\n const configPathMJS = path.join(cwd, \"kryo.config.mjs\");\n\n let loadedConfig: Partial<KryoConfig> = {};\n\n try {\n // Dynamic import jiti only on server to avoid bundling issues\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(cwd, {\n fsCache: false,\n moduleCache: false,\n });\n\n if (fs.existsSync(configPathTS)) {\n const cacheBuster = `?t=${Date.now()}`;\n const imported: any = await jiti.import(\n `file://${configPathTS}${cacheBuster}`,\n { default: true },\n );\n loadedConfig = imported.default || imported;\n } else if (fs.existsSync(configPathMJS)) {\n const imported: any = await jiti.import(configPathMJS, { default: true });\n loadedConfig = imported.default || imported;\n } else if (fs.existsSync(configPathJS)) {\n const imported: any = await jiti.import(configPathJS, { default: true });\n loadedConfig = imported.default || imported;\n }\n } catch (error) {\n console.warn(\n \"[Kryo:Config] Could not load kryo.config.ts, using defaults.\",\n error,\n );\n }\n\n const finalConfig = { ...DEFAULT_CONFIG, ...loadedConfig };\n\n if (process.env.NODE_ENV === \"production\") {\n cachedConfig = finalConfig;\n }\n\n return finalConfig;\n}\n\n/**\n * Helper returning the absolute path to the modules directory.\n * SERVER ONLY.\n */\nexport async function getModulesDir(): Promise<string> {\n const config = await getKryoConfig();\n\n const dir = config.modulesDirectory || \"modules\";\n return path.isAbsolute(dir) ? dir : path.join(process.cwd(), dir);\n}\n"],"mappings":";;;;;AAIA,IAAI,eAAkC;;;;;AAMtC,eAAsB,gBAAqC;AAEzD,KAAI,OAAO,WAAW,YACpB,OAAM,IAAI,MAAM,kDAAkD;AAIpE,KAAI,QAAQ,IAAI,aAAa,gBAAgB,aAC3C,QAAO;CAGT,MAAM,MAAM,QAAQ,KAAK;CACzB,MAAM,eAAe,KAAK,KAAK,KAAK,iBAAiB;CACrD,MAAM,eAAe,KAAK,KAAK,KAAK,iBAAiB;CACrD,MAAM,gBAAgB,KAAK,KAAK,KAAK,kBAAkB;CAEvD,IAAI,eAAoC,EAAE;AAE1C,KAAI;EAEF,MAAM,EAAE,eAAe,MAAM,OAAO;EACpC,MAAM,OAAO,WAAW,KAAK;GAC3B,SAAS;GACT,aAAa;GACd,CAAC;AAEF,MAAI,GAAG,WAAW,aAAa,EAAE;GAC/B,MAAM,cAAc,MAAM,KAAK,KAAK;GACpC,MAAM,WAAgB,MAAM,KAAK,OAC/B,UAAU,eAAe,eACzB,EAAE,SAAS,MAAM,CAClB;AACD,kBAAe,SAAS,WAAW;aAC1B,GAAG,WAAW,cAAc,EAAE;GACvC,MAAM,WAAgB,MAAM,KAAK,OAAO,eAAe,EAAE,SAAS,MAAM,CAAC;AACzE,kBAAe,SAAS,WAAW;aAC1B,GAAG,WAAW,aAAa,EAAE;GACtC,MAAM,WAAgB,MAAM,KAAK,OAAO,cAAc,EAAE,SAAS,MAAM,CAAC;AACxE,kBAAe,SAAS,WAAW;;UAE9B,OAAO;AACd,UAAQ,KACN,gEACA,MACD;;CAGH,MAAM,cAAc;EAAE,GAAG;EAAgB,GAAG;EAAc;AAE1D,KAAI,QAAQ,IAAI,aAAa,aAC3B,gBAAe;AAGjB,QAAO;;;;;;AAOT,eAAsB,gBAAiC;CAGrD,MAAM,OAFS,MAAM,eAAe,EAEjB,oBAAoB;AACvC,QAAO,KAAK,WAAW,IAAI,GAAG,MAAM,KAAK,KAAK,QAAQ,KAAK,EAAE,IAAI"}
1
+ {"version":3,"file":"config.server.mjs","names":[],"sources":["../../src/core/config.server.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport { DEFAULT_CONFIG, type KryoConfig } from \"./config.js\";\n\nlet cachedConfig: KryoConfig | null = null;\n\n/**\n * Loads the Kryo configuration from kryo.config.ts or kryo.config.js in the current working directory.\n * SERVER ONLY.\n */\nexport async function getKryoConfig(): Promise<KryoConfig> {\n // Prevent this from ever running on the client even if imported\n if (typeof window !== \"undefined\") {\n throw new Error(\"getKryoConfig can only be called on the server.\");\n }\n\n // Use memory cache in production\n if (process.env.NODE_ENV === \"production\" && cachedConfig) {\n return cachedConfig;\n }\n\n const cwd = process.cwd();\n const configPathTS = path.join(cwd, \"kryo.config.ts\");\n const configPathJS = path.join(cwd, \"kryo.config.js\");\n const configPathMJS = path.join(cwd, \"kryo.config.mjs\");\n\n let loadedConfig: Partial<KryoConfig> = {};\n\n try {\n // Dynamic import jiti only on server to avoid bundling issues\n const { createJiti } = await import(\"jiti\");\n const jiti = createJiti(cwd, {\n fsCache: false,\n moduleCache: false,\n });\n\n if (fs.existsSync(configPathTS)) {\n const cacheBuster = `?t=${Date.now()}`;\n const imported: any = await jiti.import(\n `file://${configPathTS}${cacheBuster}`,\n { default: true },\n );\n loadedConfig = imported.default || imported;\n } else if (fs.existsSync(configPathMJS)) {\n const imported: any = await jiti.import(configPathMJS, { default: true });\n loadedConfig = imported.default || imported;\n } else if (fs.existsSync(configPathJS)) {\n const imported: any = await jiti.import(configPathJS, { default: true });\n loadedConfig = imported.default || imported;\n }\n } catch (error) {\n console.warn(\n \"[Kryo:Config] Could not load kryo.config.ts, using defaults.\",\n error,\n );\n }\n\n const finalConfig = { ...DEFAULT_CONFIG, ...loadedConfig };\n\n if (process.env.NODE_ENV === \"production\") {\n cachedConfig = finalConfig;\n }\n\n return finalConfig;\n}\n\n/**\n * Helper returning the absolute path to the modules directory.\n * SERVER ONLY.\n */\nexport async function getModulesDir(): Promise<string> {\n const config = await getKryoConfig();\n\n const dir = config.modulesDirectory || \"modules\";\n return path.isAbsolute(dir) ? dir : path.join(process.cwd(), dir);\n}\n"],"mappings":"8FAIA,IAAI,EAAkC,KAMtC,eAAsB,GAAqC,CAEzD,GAAI,OAAO,OAAW,IACpB,MAAU,MAAM,kDAAkD,CAIpE,GAAI,QAAQ,IAAI,WAAa,cAAgB,EAC3C,OAAO,EAGT,IAAM,EAAM,QAAQ,KAAK,CACnB,EAAe,EAAK,KAAK,EAAK,iBAAiB,CAC/C,EAAe,EAAK,KAAK,EAAK,iBAAiB,CAC/C,EAAgB,EAAK,KAAK,EAAK,kBAAkB,CAEnD,EAAoC,EAAE,CAE1C,GAAI,CAEF,GAAM,CAAE,cAAe,MAAM,OAAO,QAC9B,EAAO,EAAW,EAAK,CAC3B,QAAS,GACT,YAAa,GACd,CAAC,CAEF,GAAI,EAAG,WAAW,EAAa,CAAE,CAC/B,IAAM,EAAc,MAAM,KAAK,KAAK,GAC9B,EAAgB,MAAM,EAAK,OAC/B,UAAU,IAAe,IACzB,CAAE,QAAS,GAAM,CAClB,CACD,EAAe,EAAS,SAAW,UAC1B,EAAG,WAAW,EAAc,CAAE,CACvC,IAAM,EAAgB,MAAM,EAAK,OAAO,EAAe,CAAE,QAAS,GAAM,CAAC,CACzE,EAAe,EAAS,SAAW,UAC1B,EAAG,WAAW,EAAa,CAAE,CACtC,IAAM,EAAgB,MAAM,EAAK,OAAO,EAAc,CAAE,QAAS,GAAM,CAAC,CACxE,EAAe,EAAS,SAAW,SAE9B,EAAO,CACd,QAAQ,KACN,+DACA,EACD,CAGH,IAAM,EAAc,CAAE,GAAG,EAAgB,GAAG,EAAc,CAM1D,OAJI,QAAQ,IAAI,WAAa,eAC3B,EAAe,GAGV,EAOT,eAAsB,GAAiC,CAGrD,IAAM,GAFS,MAAM,GAAe,EAEjB,kBAAoB,UACvC,OAAO,EAAK,WAAW,EAAI,CAAG,EAAM,EAAK,KAAK,QAAQ,KAAK,CAAE,EAAI"}
@@ -1,48 +1 @@
1
-
2
- //#region src/core/event-bus.ts
3
- /**
4
- * EventBus (Pub/Sub) - Global Singleton Pattern.
5
- */
6
- var EventBus = class {
7
- constructor() {
8
- this.handlers = /* @__PURE__ */ new Map();
9
- }
10
- subscribe(eventType, subscriberId, handler) {
11
- if (!this.handlers.has(eventType)) this.handlers.set(eventType, /* @__PURE__ */ new Map());
12
- this.handlers.get(eventType)?.set(subscriberId, handler);
13
- console.log(`[Event Bus] Subscriber "${subscriberId}" added for "${eventType}"`);
14
- }
15
- unsubscribe(eventType, subscriberId) {
16
- this.handlers.get(eventType)?.delete(subscriberId);
17
- console.log(`[Event Bus] Subscriber "${subscriberId}" removed from "${eventType}"`);
18
- }
19
- clearAll() {
20
- console.log("[Event Bus] Resetting all listeners...");
21
- this.handlers.clear();
22
- }
23
- async publish(eventType, payload, source = "system") {
24
- const eventHandlers = this.handlers.get(eventType);
25
- if (!eventHandlers) return;
26
- const handlers = Array.from(eventHandlers.values());
27
- console.log(`[Event Bus] Publishing "${eventType}" to ${handlers.length} subscribers`);
28
- const event = {
29
- type: eventType,
30
- payload,
31
- timestamp: Date.now(),
32
- source
33
- };
34
- await Promise.all(handlers.map(async (handler) => {
35
- try {
36
- await handler(event);
37
- } catch (error) {
38
- console.error(`[Event Bus] Handler Error for ${eventType}:`, error);
39
- }
40
- }));
41
- }
42
- };
43
- const globalForEventBus = globalThis;
44
- const eventBus = globalForEventBus.__KRYO_EVENT_BUS__ ?? new EventBus();
45
- globalForEventBus.__KRYO_EVENT_BUS__ = eventBus;
46
-
47
- //#endregion
48
- exports.eventBus = eventBus;
1
+ var e=class{constructor(){this.handlers=new Map}subscribe(e,t,n){this.handlers.has(e)||this.handlers.set(e,new Map),this.handlers.get(e)?.set(t,n),console.log(`[Event Bus] Subscriber "${t}" added for "${e}"`)}unsubscribe(e,t){this.handlers.get(e)?.delete(t),console.log(`[Event Bus] Subscriber "${t}" removed from "${e}"`)}clearAll(){console.log(`[Event Bus] Resetting all listeners...`),this.handlers.clear()}async publish(e,t,n=`system`){let r=this.handlers.get(e);if(!r)return;let i=Array.from(r.values());console.log(`[Event Bus] Publishing "${e}" to ${i.length} subscribers`);let a={type:e,payload:t,timestamp:Date.now(),source:n};await Promise.all(i.map(async t=>{try{await t(a)}catch(t){console.error(`[Event Bus] Handler Error for ${e}:`,t)}}))}};const t=globalThis,n=t.__KRYO_EVENT_BUS__??new e;t.__KRYO_EVENT_BUS__=n,exports.eventBus=n;
@@ -1 +1 @@
1
- {"version":3,"file":"event-bus.d.cts","names":[],"sources":["../../src/core/event-bus.ts"],"mappings":";;;;;AAAyD;cAKnD,QAAA;EAAA,QACI,QAAA;EAED,SAAA,GAAA,CACL,SAAA,UACA,YAAA,UACA,OAAA,EAAS,YAAA,CAAa,CAAA;EAYjB,WAAA,CAAY,SAAA,UAAmB,YAAA;EAO/B,QAAA,CAAA;EAKM,OAAA,GAAA,CACX,SAAA,UACA,OAAA,EAAS,CAAA,EACT,MAAA,YACC,OAAA;AAAA;AAAA,cAkCQ,QAAA,EAAQ,QAAA"}
1
+ {"version":3,"file":"event-bus.d.cts","names":[],"sources":["../../src/core/event-bus.ts"],"mappings":";;;;;AAA4D;cAKtD,QAAA;EAAA,QACI,QAAA;EAED,SAAA,GAAA,CACL,SAAA,UACA,YAAA,UACA,OAAA,EAAS,YAAA,CAAa,CAAA;EAYjB,WAAA,CAAY,SAAA,UAAmB,YAAA;EAO/B,QAAA,CAAA;EAKM,OAAA,GAAA,CACX,SAAA,UACA,OAAA,EAAS,CAAA,EACT,MAAA,YACC,OAAA;AAAA;AAAA,cAkCQ,QAAA,EAAQ,QAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"event-bus.d.mts","names":[],"sources":["../../src/core/event-bus.ts"],"mappings":";;;;;AAAyD;cAKnD,QAAA;EAAA,QACI,QAAA;EAED,SAAA,GAAA,CACL,SAAA,UACA,YAAA,UACA,OAAA,EAAS,YAAA,CAAa,CAAA;EAYjB,WAAA,CAAY,SAAA,UAAmB,YAAA;EAO/B,QAAA,CAAA;EAKM,OAAA,GAAA,CACX,SAAA,UACA,OAAA,EAAS,CAAA,EACT,MAAA,YACC,OAAA;AAAA;AAAA,cAkCQ,QAAA,EAAQ,QAAA"}
1
+ {"version":3,"file":"event-bus.d.mts","names":[],"sources":["../../src/core/event-bus.ts"],"mappings":";;;;;AAA4D;cAKtD,QAAA;EAAA,QACI,QAAA;EAED,SAAA,GAAA,CACL,SAAA,UACA,YAAA,UACA,OAAA,EAAS,YAAA,CAAa,CAAA;EAYjB,WAAA,CAAY,SAAA,UAAmB,YAAA;EAO/B,QAAA,CAAA;EAKM,OAAA,GAAA,CACX,SAAA,UACA,OAAA,EAAS,CAAA,EACT,MAAA,YACC,OAAA;AAAA;AAAA,cAkCQ,QAAA,EAAQ,QAAA"}
@@ -1,48 +1,2 @@
1
- //#region src/core/event-bus.ts
2
- /**
3
- * EventBus (Pub/Sub) - Global Singleton Pattern.
4
- */
5
- var EventBus = class {
6
- constructor() {
7
- this.handlers = /* @__PURE__ */ new Map();
8
- }
9
- subscribe(eventType, subscriberId, handler) {
10
- if (!this.handlers.has(eventType)) this.handlers.set(eventType, /* @__PURE__ */ new Map());
11
- this.handlers.get(eventType)?.set(subscriberId, handler);
12
- console.log(`[Event Bus] Subscriber "${subscriberId}" added for "${eventType}"`);
13
- }
14
- unsubscribe(eventType, subscriberId) {
15
- this.handlers.get(eventType)?.delete(subscriberId);
16
- console.log(`[Event Bus] Subscriber "${subscriberId}" removed from "${eventType}"`);
17
- }
18
- clearAll() {
19
- console.log("[Event Bus] Resetting all listeners...");
20
- this.handlers.clear();
21
- }
22
- async publish(eventType, payload, source = "system") {
23
- const eventHandlers = this.handlers.get(eventType);
24
- if (!eventHandlers) return;
25
- const handlers = Array.from(eventHandlers.values());
26
- console.log(`[Event Bus] Publishing "${eventType}" to ${handlers.length} subscribers`);
27
- const event = {
28
- type: eventType,
29
- payload,
30
- timestamp: Date.now(),
31
- source
32
- };
33
- await Promise.all(handlers.map(async (handler) => {
34
- try {
35
- await handler(event);
36
- } catch (error) {
37
- console.error(`[Event Bus] Handler Error for ${eventType}:`, error);
38
- }
39
- }));
40
- }
41
- };
42
- const globalForEventBus = globalThis;
43
- const eventBus = globalForEventBus.__KRYO_EVENT_BUS__ ?? new EventBus();
44
- globalForEventBus.__KRYO_EVENT_BUS__ = eventBus;
45
-
46
- //#endregion
47
- export { eventBus };
1
+ var e=class{constructor(){this.handlers=new Map}subscribe(e,t,n){this.handlers.has(e)||this.handlers.set(e,new Map),this.handlers.get(e)?.set(t,n),console.log(`[Event Bus] Subscriber "${t}" added for "${e}"`)}unsubscribe(e,t){this.handlers.get(e)?.delete(t),console.log(`[Event Bus] Subscriber "${t}" removed from "${e}"`)}clearAll(){console.log(`[Event Bus] Resetting all listeners...`),this.handlers.clear()}async publish(e,t,n=`system`){let r=this.handlers.get(e);if(!r)return;let i=Array.from(r.values());console.log(`[Event Bus] Publishing "${e}" to ${i.length} subscribers`);let a={type:e,payload:t,timestamp:Date.now(),source:n};await Promise.all(i.map(async t=>{try{await t(a)}catch(t){console.error(`[Event Bus] Handler Error for ${e}:`,t)}}))}};const t=globalThis,n=t.__KRYO_EVENT_BUS__??new e;t.__KRYO_EVENT_BUS__=n;export{n as eventBus};
48
2
  //# sourceMappingURL=event-bus.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"event-bus.mjs","names":[],"sources":["../../src/core/event-bus.ts"],"sourcesContent":["import type { EventHandler, SystemEvent } from \"./types\";\n\n/**\n * EventBus (Pub/Sub) - Global Singleton Pattern.\n */\nclass EventBus {\n private handlers: Map<string, Map<string, EventHandler>> = new Map();\n\n public subscribe<T>(\n eventType: string,\n subscriberId: string,\n handler: EventHandler<T>,\n ): void {\n if (!this.handlers.has(eventType)) {\n this.handlers.set(eventType, new Map());\n }\n const eventHandlers = this.handlers.get(eventType);\n eventHandlers?.set(subscriberId, handler);\n console.log(\n `[Event Bus] Subscriber \"${subscriberId}\" added for \"${eventType}\"`,\n );\n }\n\n public unsubscribe(eventType: string, subscriberId: string): void {\n this.handlers.get(eventType)?.delete(subscriberId);\n console.log(\n `[Event Bus] Subscriber \"${subscriberId}\" removed from \"${eventType}\"`,\n );\n }\n\n public clearAll(): void {\n console.log(\"[Event Bus] Resetting all listeners...\");\n this.handlers.clear();\n }\n\n public async publish<T>(\n eventType: string,\n payload: T,\n source: string = \"system\",\n ): Promise<void> {\n const eventHandlers = this.handlers.get(eventType);\n if (!eventHandlers) return;\n\n const handlers = Array.from(eventHandlers.values());\n\n console.log(\n `[Event Bus] Publishing \"${eventType}\" to ${handlers.length} subscribers`,\n );\n\n const event: SystemEvent<T> = {\n type: eventType,\n payload,\n timestamp: Date.now(),\n source,\n };\n\n await Promise.all(\n handlers.map(async (handler) => {\n try {\n await handler(event);\n } catch (error) {\n console.error(`[Event Bus] Handler Error for ${eventType}:`, error);\n }\n }),\n );\n }\n}\n\n// Ensure global singleton\nconst globalForEventBus = globalThis as unknown as {\n __KRYO_EVENT_BUS__: EventBus | undefined;\n};\n\nexport const eventBus = globalForEventBus.__KRYO_EVENT_BUS__ ?? new EventBus();\n\nglobalForEventBus.__KRYO_EVENT_BUS__ = eventBus;\n"],"mappings":";;;;AAKA,IAAM,WAAN,MAAe;;kCAC8C,IAAI,KAAK;;CAEpE,AAAO,UACL,WACA,cACA,SACM;AACN,MAAI,CAAC,KAAK,SAAS,IAAI,UAAU,CAC/B,MAAK,SAAS,IAAI,2BAAW,IAAI,KAAK,CAAC;AAGzC,EADsB,KAAK,SAAS,IAAI,UAAU,EACnC,IAAI,cAAc,QAAQ;AACzC,UAAQ,IACN,2BAA2B,aAAa,eAAe,UAAU,GAClE;;CAGH,AAAO,YAAY,WAAmB,cAA4B;AAChE,OAAK,SAAS,IAAI,UAAU,EAAE,OAAO,aAAa;AAClD,UAAQ,IACN,2BAA2B,aAAa,kBAAkB,UAAU,GACrE;;CAGH,AAAO,WAAiB;AACtB,UAAQ,IAAI,yCAAyC;AACrD,OAAK,SAAS,OAAO;;CAGvB,MAAa,QACX,WACA,SACA,SAAiB,UACF;EACf,MAAM,gBAAgB,KAAK,SAAS,IAAI,UAAU;AAClD,MAAI,CAAC,cAAe;EAEpB,MAAM,WAAW,MAAM,KAAK,cAAc,QAAQ,CAAC;AAEnD,UAAQ,IACN,2BAA2B,UAAU,OAAO,SAAS,OAAO,cAC7D;EAED,MAAM,QAAwB;GAC5B,MAAM;GACN;GACA,WAAW,KAAK,KAAK;GACrB;GACD;AAED,QAAM,QAAQ,IACZ,SAAS,IAAI,OAAO,YAAY;AAC9B,OAAI;AACF,UAAM,QAAQ,MAAM;YACb,OAAO;AACd,YAAQ,MAAM,iCAAiC,UAAU,IAAI,MAAM;;IAErE,CACH;;;AAKL,MAAM,oBAAoB;AAI1B,MAAa,WAAW,kBAAkB,sBAAsB,IAAI,UAAU;AAE9E,kBAAkB,qBAAqB"}
1
+ {"version":3,"file":"event-bus.mjs","names":[],"sources":["../../src/core/event-bus.ts"],"sourcesContent":["import type { EventHandler, SystemEvent } from \"./types.js\";\n\n/**\n * EventBus (Pub/Sub) - Global Singleton Pattern.\n */\nclass EventBus {\n private handlers: Map<string, Map<string, EventHandler>> = new Map();\n\n public subscribe<T>(\n eventType: string,\n subscriberId: string,\n handler: EventHandler<T>,\n ): void {\n if (!this.handlers.has(eventType)) {\n this.handlers.set(eventType, new Map());\n }\n const eventHandlers = this.handlers.get(eventType);\n eventHandlers?.set(subscriberId, handler);\n console.log(\n `[Event Bus] Subscriber \"${subscriberId}\" added for \"${eventType}\"`,\n );\n }\n\n public unsubscribe(eventType: string, subscriberId: string): void {\n this.handlers.get(eventType)?.delete(subscriberId);\n console.log(\n `[Event Bus] Subscriber \"${subscriberId}\" removed from \"${eventType}\"`,\n );\n }\n\n public clearAll(): void {\n console.log(\"[Event Bus] Resetting all listeners...\");\n this.handlers.clear();\n }\n\n public async publish<T>(\n eventType: string,\n payload: T,\n source: string = \"system\",\n ): Promise<void> {\n const eventHandlers = this.handlers.get(eventType);\n if (!eventHandlers) return;\n\n const handlers = Array.from(eventHandlers.values());\n\n console.log(\n `[Event Bus] Publishing \"${eventType}\" to ${handlers.length} subscribers`,\n );\n\n const event: SystemEvent<T> = {\n type: eventType,\n payload,\n timestamp: Date.now(),\n source,\n };\n\n await Promise.all(\n handlers.map(async (handler) => {\n try {\n await handler(event);\n } catch (error) {\n console.error(`[Event Bus] Handler Error for ${eventType}:`, error);\n }\n }),\n );\n }\n}\n\n// Ensure global singleton\nconst globalForEventBus = globalThis as unknown as {\n __KRYO_EVENT_BUS__: EventBus | undefined;\n};\n\nexport const eventBus = globalForEventBus.__KRYO_EVENT_BUS__ ?? new EventBus();\n\nglobalForEventBus.__KRYO_EVENT_BUS__ = eventBus;\n"],"mappings":"AAKA,IAAM,EAAN,KAAe,6BAC8C,IAAI,IAE/D,UACE,EACA,EACA,EACM,CACD,KAAK,SAAS,IAAI,EAAU,EAC/B,KAAK,SAAS,IAAI,EAAW,IAAI,IAAM,CAEnB,KAAK,SAAS,IAAI,EAAU,EACnC,IAAI,EAAc,EAAQ,CACzC,QAAQ,IACN,2BAA2B,EAAa,eAAe,EAAU,GAClE,CAGH,YAAmB,EAAmB,EAA4B,CAChE,KAAK,SAAS,IAAI,EAAU,EAAE,OAAO,EAAa,CAClD,QAAQ,IACN,2BAA2B,EAAa,kBAAkB,EAAU,GACrE,CAGH,UAAwB,CACtB,QAAQ,IAAI,yCAAyC,CACrD,KAAK,SAAS,OAAO,CAGvB,MAAa,QACX,EACA,EACA,EAAiB,SACF,CACf,IAAM,EAAgB,KAAK,SAAS,IAAI,EAAU,CAClD,GAAI,CAAC,EAAe,OAEpB,IAAM,EAAW,MAAM,KAAK,EAAc,QAAQ,CAAC,CAEnD,QAAQ,IACN,2BAA2B,EAAU,OAAO,EAAS,OAAO,cAC7D,CAED,IAAM,EAAwB,CAC5B,KAAM,EACN,UACA,UAAW,KAAK,KAAK,CACrB,SACD,CAED,MAAM,QAAQ,IACZ,EAAS,IAAI,KAAO,IAAY,CAC9B,GAAI,CACF,MAAM,EAAQ,EAAM,OACb,EAAO,CACd,QAAQ,MAAM,iCAAiC,EAAU,GAAI,EAAM,GAErE,CACH,GAKL,MAAM,EAAoB,WAIb,EAAW,EAAkB,oBAAsB,IAAI,EAEpE,EAAkB,mBAAqB"}
@@ -1,11 +1 @@
1
- const require_local = require('./providers/local.cjs');
2
- const require_service = require('./service.cjs');
3
-
4
- //#region src/core/filesystem/index.ts
5
- if (typeof window === "undefined") {
6
- const local = new require_local.LocalFileProvider();
7
- require_service.filesystemService.registerProvider(local);
8
- require_service.filesystemService.setDefaultProvider(local.id);
9
- }
10
-
11
- //#endregion
1
+ const e=require(`./providers/local.cjs`),t=require(`./service.cjs`);if(typeof window>`u`){let n=new e.LocalFileProvider;t.filesystemService.registerProvider(n),t.filesystemService.setDefaultProvider(n.id)}
@@ -1,13 +1,2 @@
1
- import { LocalFileProvider } from "./providers/local.mjs";
2
- import { filesystemService } from "./service.mjs";
3
-
4
- //#region src/core/filesystem/index.ts
5
- if (typeof window === "undefined") {
6
- const local = new LocalFileProvider();
7
- filesystemService.registerProvider(local);
8
- filesystemService.setDefaultProvider(local.id);
9
- }
10
-
11
- //#endregion
12
- export { };
1
+ import{LocalFileProvider as e}from"./providers/local.mjs";import{filesystemService as t}from"./service.mjs";if(typeof window>`u`){let n=new e;t.registerProvider(n),t.setDefaultProvider(n.id)}export{};
13
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/filesystem/index.ts"],"sourcesContent":["import { LocalFileProvider } from \"./providers/local\";\nimport { filesystemService } from \"./service\";\n\nexport * from \"./types\";\nexport { filesystemService };\n\n// Auto-register local provider\nif (typeof window === \"undefined\") {\n const local = new LocalFileProvider();\n\n filesystemService.registerProvider(local);\n filesystemService.setDefaultProvider(local.id);\n}\n"],"mappings":";;;;AAOA,IAAI,OAAO,WAAW,aAAa;CACjC,MAAM,QAAQ,IAAI,mBAAmB;AAErC,mBAAkB,iBAAiB,MAAM;AACzC,mBAAkB,mBAAmB,MAAM,GAAG"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/core/filesystem/index.ts"],"sourcesContent":["import { LocalFileProvider } from \"./providers/local.js\";\nimport { filesystemService } from \"./service.js\";\n\nexport * from \"./types.js\";\nexport { filesystemService };\n\n// Auto-register local provider\nif (typeof window === \"undefined\") {\n const local = new LocalFileProvider();\n\n filesystemService.registerProvider(local);\n filesystemService.setDefaultProvider(local.id);\n}\n"],"mappings":"4GAOA,GAAI,OAAO,OAAW,IAAa,CACjC,IAAM,EAAQ,IAAI,EAElB,EAAkB,iBAAiB,EAAM,CACzC,EAAkB,mBAAmB,EAAM,GAAG"}
@@ -1,43 +1 @@
1
- const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
2
- let node_fs = require("node:fs");
3
- node_fs = require_runtime.__toESM(node_fs);
4
- let node_path = require("node:path");
5
- node_path = require_runtime.__toESM(node_path);
6
-
7
- //#region src/core/filesystem/providers/local.ts
8
- var LocalFileProvider = class {
9
- constructor() {
10
- this.id = "local";
11
- this.name = "Local Filesystem";
12
- }
13
- generateUniqueImageName(name) {
14
- const cleanName = name.replace(/\s+/g, "-").toLowerCase();
15
- const suffix = Math.floor(Math.random() * Date.now()).toString(36);
16
- const index = cleanName.lastIndexOf(".");
17
- return index < 0 ? `${cleanName}-${suffix}` : `${cleanName.slice(0, index)}-${suffix}${cleanName.slice(index)}`;
18
- }
19
- async upload(file) {
20
- try {
21
- const storageFolder = process.env.FILE_STORAGE_FOLDER ?? "public/storage";
22
- if (!node_fs.default.existsSync(storageFolder)) node_fs.default.mkdirSync(storageFolder, { recursive: true });
23
- const name = this.generateUniqueImageName(file.name);
24
- const filePath = node_path.default.join(storageFolder, name);
25
- const buffer = await file.arrayBuffer();
26
- node_fs.default.writeFileSync(filePath, Buffer.from(buffer));
27
- return {
28
- name,
29
- url: `${storageFolder}/${name}`.replace("public", ""),
30
- type: file.type,
31
- size: file.size,
32
- service: "local",
33
- serviceId: filePath
34
- };
35
- } catch (error) {
36
- console.error("Error uploading file", error);
37
- return { error: "Error uploading file" };
38
- }
39
- }
40
- };
41
-
42
- //#endregion
43
- exports.LocalFileProvider = LocalFileProvider;
1
+ const e=require(`../../../_virtual/_rolldown/runtime.cjs`);let t=require(`node:fs`);t=e.__toESM(t);let n=require(`node:path`);n=e.__toESM(n);var r=class{constructor(){this.id=`local`,this.name=`Local Filesystem`}generateUniqueImageName(e){let t=e.replace(/\s+/g,`-`).toLowerCase(),n=Math.floor(Math.random()*Date.now()).toString(36),r=t.lastIndexOf(`.`);return r<0?`${t}-${n}`:`${t.slice(0,r)}-${n}${t.slice(r)}`}async upload(e){try{let r=process.env.FILE_STORAGE_FOLDER??`public/storage`;t.default.existsSync(r)||t.default.mkdirSync(r,{recursive:!0});let i=this.generateUniqueImageName(e.name),a=n.default.join(r,i),o=await e.arrayBuffer();return t.default.writeFileSync(a,Buffer.from(o)),{name:i,url:`${r}/${i}`.replace(`public`,``),type:e.type,size:e.size,service:`local`,serviceId:a}}catch(e){return console.error(`Error uploading file`,e),{error:`Error uploading file`}}}};exports.LocalFileProvider=r;
@@ -1,41 +1,2 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
-
4
- //#region src/core/filesystem/providers/local.ts
5
- var LocalFileProvider = class {
6
- constructor() {
7
- this.id = "local";
8
- this.name = "Local Filesystem";
9
- }
10
- generateUniqueImageName(name) {
11
- const cleanName = name.replace(/\s+/g, "-").toLowerCase();
12
- const suffix = Math.floor(Math.random() * Date.now()).toString(36);
13
- const index = cleanName.lastIndexOf(".");
14
- return index < 0 ? `${cleanName}-${suffix}` : `${cleanName.slice(0, index)}-${suffix}${cleanName.slice(index)}`;
15
- }
16
- async upload(file) {
17
- try {
18
- const storageFolder = process.env.FILE_STORAGE_FOLDER ?? "public/storage";
19
- if (!fs.existsSync(storageFolder)) fs.mkdirSync(storageFolder, { recursive: true });
20
- const name = this.generateUniqueImageName(file.name);
21
- const filePath = path.join(storageFolder, name);
22
- const buffer = await file.arrayBuffer();
23
- fs.writeFileSync(filePath, Buffer.from(buffer));
24
- return {
25
- name,
26
- url: `${storageFolder}/${name}`.replace("public", ""),
27
- type: file.type,
28
- size: file.size,
29
- service: "local",
30
- serviceId: filePath
31
- };
32
- } catch (error) {
33
- console.error("Error uploading file", error);
34
- return { error: "Error uploading file" };
35
- }
36
- }
37
- };
38
-
39
- //#endregion
40
- export { LocalFileProvider };
1
+ import e from"node:fs";import t from"node:path";var n=class{constructor(){this.id=`local`,this.name=`Local Filesystem`}generateUniqueImageName(e){let t=e.replace(/\s+/g,`-`).toLowerCase(),n=Math.floor(Math.random()*Date.now()).toString(36),r=t.lastIndexOf(`.`);return r<0?`${t}-${n}`:`${t.slice(0,r)}-${n}${t.slice(r)}`}async upload(n){try{let r=process.env.FILE_STORAGE_FOLDER??`public/storage`;e.existsSync(r)||e.mkdirSync(r,{recursive:!0});let i=this.generateUniqueImageName(n.name),a=t.join(r,i),o=await n.arrayBuffer();return e.writeFileSync(a,Buffer.from(o)),{name:i,url:`${r}/${i}`.replace(`public`,``),type:n.type,size:n.size,service:`local`,serviceId:a}}catch(e){return console.error(`Error uploading file`,e),{error:`Error uploading file`}}}};export{n as LocalFileProvider};
41
2
  //# sourceMappingURL=local.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"local.mjs","names":[],"sources":["../../../../src/core/filesystem/providers/local.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { IStorageProvider, StorageResult } from \"../types\";\n\nexport class LocalFileProvider implements IStorageProvider {\n public id = \"local\";\n public name = \"Local Filesystem\";\n\n private generateUniqueImageName(name: string) {\n const cleanName = name.replace(/\\s+/g, \"-\").toLowerCase();\n const suffix = Math.floor(Math.random() * Date.now()).toString(36);\n const index = cleanName.lastIndexOf(\".\");\n\n return index < 0\n ? `${cleanName}-${suffix}`\n : `${cleanName.slice(0, index)}-${suffix}${cleanName.slice(index)}`;\n }\n\n public async upload(file: File): Promise<StorageResult> {\n try {\n const storageFolder = process.env.FILE_STORAGE_FOLDER ?? \"public/storage\";\n\n if (!fs.existsSync(storageFolder)) {\n fs.mkdirSync(storageFolder, { recursive: true });\n }\n\n const name = this.generateUniqueImageName(file.name);\n const filePath = path.join(storageFolder, name);\n const buffer = await file.arrayBuffer();\n fs.writeFileSync(filePath, Buffer.from(buffer));\n\n const url = `${storageFolder}/${name}`.replace(\"public\", \"\");\n\n return {\n name: name,\n url,\n type: file.type,\n size: file.size,\n service: \"local\",\n serviceId: filePath,\n };\n } catch (error) {\n console.error(\"Error uploading file\", error);\n return { error: \"Error uploading file\" };\n }\n }\n}\n"],"mappings":";;;;AAIA,IAAa,oBAAb,MAA2D;;YAC7C;cACE;;CAEd,AAAQ,wBAAwB,MAAc;EAC5C,MAAM,YAAY,KAAK,QAAQ,QAAQ,IAAI,CAAC,aAAa;EACzD,MAAM,SAAS,KAAK,MAAM,KAAK,QAAQ,GAAG,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG;EAClE,MAAM,QAAQ,UAAU,YAAY,IAAI;AAExC,SAAO,QAAQ,IACX,GAAG,UAAU,GAAG,WAChB,GAAG,UAAU,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,UAAU,MAAM,MAAM;;CAGrE,MAAa,OAAO,MAAoC;AACtD,MAAI;GACF,MAAM,gBAAgB,QAAQ,IAAI,uBAAuB;AAEzD,OAAI,CAAC,GAAG,WAAW,cAAc,CAC/B,IAAG,UAAU,eAAe,EAAE,WAAW,MAAM,CAAC;GAGlD,MAAM,OAAO,KAAK,wBAAwB,KAAK,KAAK;GACpD,MAAM,WAAW,KAAK,KAAK,eAAe,KAAK;GAC/C,MAAM,SAAS,MAAM,KAAK,aAAa;AACvC,MAAG,cAAc,UAAU,OAAO,KAAK,OAAO,CAAC;AAI/C,UAAO;IACC;IACN,KAJU,GAAG,cAAc,GAAG,OAAO,QAAQ,UAAU,GAAG;IAK1D,MAAM,KAAK;IACX,MAAM,KAAK;IACX,SAAS;IACT,WAAW;IACZ;WACM,OAAO;AACd,WAAQ,MAAM,wBAAwB,MAAM;AAC5C,UAAO,EAAE,OAAO,wBAAwB"}
1
+ {"version":3,"file":"local.mjs","names":[],"sources":["../../../../src/core/filesystem/providers/local.ts"],"sourcesContent":["import fs from \"node:fs\";\nimport path from \"node:path\";\nimport type { IStorageProvider, StorageResult } from \"../types.js\";\n\nexport class LocalFileProvider implements IStorageProvider {\n public id = \"local\";\n public name = \"Local Filesystem\";\n\n private generateUniqueImageName(name: string) {\n const cleanName = name.replace(/\\s+/g, \"-\").toLowerCase();\n const suffix = Math.floor(Math.random() * Date.now()).toString(36);\n const index = cleanName.lastIndexOf(\".\");\n\n return index < 0\n ? `${cleanName}-${suffix}`\n : `${cleanName.slice(0, index)}-${suffix}${cleanName.slice(index)}`;\n }\n\n public async upload(file: File): Promise<StorageResult> {\n try {\n const storageFolder = process.env.FILE_STORAGE_FOLDER ?? \"public/storage\";\n\n if (!fs.existsSync(storageFolder)) {\n fs.mkdirSync(storageFolder, { recursive: true });\n }\n\n const name = this.generateUniqueImageName(file.name);\n const filePath = path.join(storageFolder, name);\n const buffer = await file.arrayBuffer();\n fs.writeFileSync(filePath, Buffer.from(buffer));\n\n const url = `${storageFolder}/${name}`.replace(\"public\", \"\");\n\n return {\n name: name,\n url,\n type: file.type,\n size: file.size,\n service: \"local\",\n serviceId: filePath,\n };\n } catch (error) {\n console.error(\"Error uploading file\", error);\n return { error: \"Error uploading file\" };\n }\n }\n}\n"],"mappings":"gDAIA,IAAa,EAAb,KAA2D,uBAC7C,kBACE,mBAEd,wBAAgC,EAAc,CAC5C,IAAM,EAAY,EAAK,QAAQ,OAAQ,IAAI,CAAC,aAAa,CACnD,EAAS,KAAK,MAAM,KAAK,QAAQ,CAAG,KAAK,KAAK,CAAC,CAAC,SAAS,GAAG,CAC5D,EAAQ,EAAU,YAAY,IAAI,CAExC,OAAO,EAAQ,EACX,GAAG,EAAU,GAAG,IAChB,GAAG,EAAU,MAAM,EAAG,EAAM,CAAC,GAAG,IAAS,EAAU,MAAM,EAAM,GAGrE,MAAa,OAAO,EAAoC,CACtD,GAAI,CACF,IAAM,EAAgB,QAAQ,IAAI,qBAAuB,iBAEpD,EAAG,WAAW,EAAc,EAC/B,EAAG,UAAU,EAAe,CAAE,UAAW,GAAM,CAAC,CAGlD,IAAM,EAAO,KAAK,wBAAwB,EAAK,KAAK,CAC9C,EAAW,EAAK,KAAK,EAAe,EAAK,CACzC,EAAS,MAAM,EAAK,aAAa,CAKvC,OAJA,EAAG,cAAc,EAAU,OAAO,KAAK,EAAO,CAAC,CAIxC,CACC,OACN,IAJU,GAAG,EAAc,GAAG,IAAO,QAAQ,SAAU,GAAG,CAK1D,KAAM,EAAK,KACX,KAAM,EAAK,KACX,QAAS,QACT,UAAW,EACZ,OACM,EAAO,CAEd,OADA,QAAQ,MAAM,uBAAwB,EAAM,CACrC,CAAE,MAAO,uBAAwB"}