bun_plugins 1.2.5 → 1.2.6

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 (177) hide show
  1. package/README.md +3 -127
  2. package/dist/{src/PluginManager.d.ts → PluginManager.d.ts} +9 -20
  3. package/dist/PluginManager.d.ts.map +1 -0
  4. package/dist/{src/PluginManager.js → PluginManager.js} +189 -212
  5. package/dist/PluginManager.js.map +1 -0
  6. package/dist/{src/index.d.ts → index.d.ts} +1 -2
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/{src/index.js → index.js} +0 -2
  9. package/dist/index.js.map +1 -0
  10. package/dist/{src/managers → managers}/ContextFactory.d.ts +1 -1
  11. package/dist/managers/ContextFactory.d.ts.map +1 -0
  12. package/dist/{src/managers → managers}/ContextFactory.js +26 -51
  13. package/dist/managers/ContextFactory.js.map +1 -0
  14. package/dist/managers/DependencyManager.d.ts.map +1 -0
  15. package/dist/{src/managers → managers}/DependencyManager.js +5 -7
  16. package/dist/managers/DependencyManager.js.map +1 -0
  17. package/dist/{src/managers → managers}/HooksManager.d.ts +1 -4
  18. package/dist/managers/HooksManager.d.ts.map +1 -0
  19. package/dist/{src/managers → managers}/HooksManager.js +8 -36
  20. package/dist/managers/HooksManager.js.map +1 -0
  21. package/dist/managers/ResourceManager.d.ts.map +1 -0
  22. package/dist/{src/managers → managers}/ResourceManager.js +3 -3
  23. package/dist/managers/ResourceManager.js.map +1 -0
  24. package/dist/{src/storage → storage}/JsonPluginStorage.d.ts +1 -2
  25. package/dist/storage/JsonPluginStorage.d.ts.map +1 -0
  26. package/dist/storage/JsonPluginStorage.js +63 -0
  27. package/dist/storage/JsonPluginStorage.js.map +1 -0
  28. package/dist/{src/types.d.ts → types.d.ts} +19 -60
  29. package/dist/types.d.ts.map +1 -0
  30. package/dist/{src/types.js → types.js} +0 -6
  31. package/dist/types.js.map +1 -0
  32. package/dist/utils/errorParser.d.ts.map +1 -0
  33. package/dist/{src/utils → utils}/errorParser.js +5 -2
  34. package/dist/utils/errorParser.js.map +1 -0
  35. package/dist/utils/pluginValidator.d.ts +93 -0
  36. package/dist/utils/pluginValidator.d.ts.map +1 -0
  37. package/dist/{src/utils → utils}/pluginValidator.js +14 -11
  38. package/dist/utils/pluginValidator.js.map +1 -0
  39. package/dist/utils/security.d.ts.map +1 -0
  40. package/dist/utils/security.js.map +1 -0
  41. package/dist/worker/WorkerRunner.d.ts.map +1 -0
  42. package/dist/{src/worker → worker}/WorkerRunner.js +13 -38
  43. package/dist/worker/WorkerRunner.js.map +1 -0
  44. package/package.json +6 -9
  45. package/LICENSE +0 -9
  46. package/dist/examples/action-registry-declarative.d.ts +0 -14
  47. package/dist/examples/action-registry-declarative.d.ts.map +0 -1
  48. package/dist/examples/action-registry-declarative.js +0 -130
  49. package/dist/examples/action-registry-declarative.js.map +0 -1
  50. package/dist/examples/action-registry-example.d.ts +0 -31
  51. package/dist/examples/action-registry-example.d.ts.map +0 -1
  52. package/dist/examples/action-registry-example.js +0 -84
  53. package/dist/examples/action-registry-example.js.map +0 -1
  54. package/dist/examples/index-declarative.d.ts +0 -32
  55. package/dist/examples/index-declarative.d.ts.map +0 -1
  56. package/dist/examples/index-declarative.js +0 -206
  57. package/dist/examples/index-declarative.js.map +0 -1
  58. package/dist/examples/logger-declarative.d.ts +0 -109
  59. package/dist/examples/logger-declarative.d.ts.map +0 -1
  60. package/dist/examples/logger-declarative.js +0 -330
  61. package/dist/examples/logger-declarative.js.map +0 -1
  62. package/dist/examples/logger-simple.d.ts +0 -8
  63. package/dist/examples/logger-simple.d.ts.map +0 -1
  64. package/dist/examples/logger-simple.js +0 -165
  65. package/dist/examples/logger-simple.js.map +0 -1
  66. package/dist/examples/server-declarative.d.ts +0 -46
  67. package/dist/examples/server-declarative.d.ts.map +0 -1
  68. package/dist/examples/server-declarative.js +0 -205
  69. package/dist/examples/server-declarative.js.map +0 -1
  70. package/dist/examples/shared/action-registry.d.ts +0 -45
  71. package/dist/examples/shared/action-registry.d.ts.map +0 -1
  72. package/dist/examples/shared/action-registry.js +0 -65
  73. package/dist/examples/shared/action-registry.js.map +0 -1
  74. package/dist/examples/shared/plugin-builder.d.ts +0 -41
  75. package/dist/examples/shared/plugin-builder.d.ts.map +0 -1
  76. package/dist/examples/shared/plugin-builder.js +0 -85
  77. package/dist/examples/shared/plugin-builder.js.map +0 -1
  78. package/dist/examples/storage-declarative.d.ts +0 -13
  79. package/dist/examples/storage-declarative.d.ts.map +0 -1
  80. package/dist/examples/storage-declarative.js +0 -203
  81. package/dist/examples/storage-declarative.js.map +0 -1
  82. package/dist/plugins/ActionRegistryPlugin.d.ts +0 -14
  83. package/dist/plugins/ActionRegistryPlugin.d.ts.map +0 -1
  84. package/dist/plugins/ActionRegistryPlugin.js +0 -52
  85. package/dist/plugins/ActionRegistryPlugin.js.map +0 -1
  86. package/dist/plugins/DynamicJSActionsPlugin.d.ts +0 -21
  87. package/dist/plugins/DynamicJSActionsPlugin.d.ts.map +0 -1
  88. package/dist/plugins/DynamicJSActionsPlugin.js +0 -57
  89. package/dist/plugins/DynamicJSActionsPlugin.js.map +0 -1
  90. package/dist/plugins/DynamicMathActionsPlugin.d.ts +0 -22
  91. package/dist/plugins/DynamicMathActionsPlugin.d.ts.map +0 -1
  92. package/dist/plugins/DynamicMathActionsPlugin.js +0 -64
  93. package/dist/plugins/DynamicMathActionsPlugin.js.map +0 -1
  94. package/dist/plugins/DynamicTextActionsPlugin.d.ts +0 -22
  95. package/dist/plugins/DynamicTextActionsPlugin.d.ts.map +0 -1
  96. package/dist/plugins/DynamicTextActionsPlugin.js +0 -58
  97. package/dist/plugins/DynamicTextActionsPlugin.js.map +0 -1
  98. package/dist/plugins/DynamicUtilityActionsPlugin.d.ts +0 -22
  99. package/dist/plugins/DynamicUtilityActionsPlugin.d.ts.map +0 -1
  100. package/dist/plugins/DynamicUtilityActionsPlugin.js +0 -75
  101. package/dist/plugins/DynamicUtilityActionsPlugin.js.map +0 -1
  102. package/dist/plugins/ExamplePlugin.d.ts +0 -3
  103. package/dist/plugins/ExamplePlugin.d.ts.map +0 -1
  104. package/dist/plugins/ExamplePlugin.js +0 -24
  105. package/dist/plugins/ExamplePlugin.js.map +0 -1
  106. package/dist/plugins/LifecycleDemoPlugin.d.ts +0 -20
  107. package/dist/plugins/LifecycleDemoPlugin.d.ts.map +0 -1
  108. package/dist/plugins/LifecycleDemoPlugin.js +0 -34
  109. package/dist/plugins/LifecycleDemoPlugin.js.map +0 -1
  110. package/dist/plugins/MathPlugin.d.ts +0 -16
  111. package/dist/plugins/MathPlugin.d.ts.map +0 -1
  112. package/dist/plugins/MathPlugin.js +0 -30
  113. package/dist/plugins/MathPlugin.js.map +0 -1
  114. package/dist/plugins/MyJSPlugin.d.ts +0 -7
  115. package/dist/plugins/MyJSPlugin.d.ts.map +0 -1
  116. package/dist/plugins/MyJSPlugin.js +0 -12
  117. package/dist/plugins/MyJSPlugin.js.map +0 -1
  118. package/dist/plugins/TypedExamplePlugin.d.ts +0 -10
  119. package/dist/plugins/TypedExamplePlugin.d.ts.map +0 -1
  120. package/dist/plugins/TypedExamplePlugin.js +0 -61
  121. package/dist/plugins/TypedExamplePlugin.js.map +0 -1
  122. package/dist/plugins/arktype/index.d.ts +0 -8
  123. package/dist/plugins/arktype/index.d.ts.map +0 -1
  124. package/dist/plugins/arktype/index.js +0 -25
  125. package/dist/plugins/arktype/index.js.map +0 -1
  126. package/dist/src/Plugin.d.ts +0 -28
  127. package/dist/src/Plugin.d.ts.map +0 -1
  128. package/dist/src/Plugin.js +0 -36
  129. package/dist/src/Plugin.js.map +0 -1
  130. package/dist/src/PluginManager.d.ts.map +0 -1
  131. package/dist/src/PluginManager.js.map +0 -1
  132. package/dist/src/index.d.ts.map +0 -1
  133. package/dist/src/index.js.map +0 -1
  134. package/dist/src/logger/LoggerAdapter.d.ts +0 -77
  135. package/dist/src/logger/LoggerAdapter.d.ts.map +0 -1
  136. package/dist/src/logger/LoggerAdapter.js +0 -242
  137. package/dist/src/logger/LoggerAdapter.js.map +0 -1
  138. package/dist/src/logger/LoggerFactory.d.ts +0 -73
  139. package/dist/src/logger/LoggerFactory.d.ts.map +0 -1
  140. package/dist/src/logger/LoggerFactory.js +0 -99
  141. package/dist/src/logger/LoggerFactory.js.map +0 -1
  142. package/dist/src/logger/index.d.ts +0 -3
  143. package/dist/src/logger/index.d.ts.map +0 -1
  144. package/dist/src/logger/index.js +0 -3
  145. package/dist/src/logger/index.js.map +0 -1
  146. package/dist/src/managers/ContextFactory.d.ts.map +0 -1
  147. package/dist/src/managers/ContextFactory.js.map +0 -1
  148. package/dist/src/managers/DependencyManager.d.ts.map +0 -1
  149. package/dist/src/managers/DependencyManager.js.map +0 -1
  150. package/dist/src/managers/HooksManager.d.ts.map +0 -1
  151. package/dist/src/managers/HooksManager.js.map +0 -1
  152. package/dist/src/managers/ResourceManager.d.ts.map +0 -1
  153. package/dist/src/managers/ResourceManager.js.map +0 -1
  154. package/dist/src/storage/JsonPluginStorage.d.ts.map +0 -1
  155. package/dist/src/storage/JsonPluginStorage.js +0 -75
  156. package/dist/src/storage/JsonPluginStorage.js.map +0 -1
  157. package/dist/src/types/plugin-registry-base.d.ts +0 -80
  158. package/dist/src/types/plugin-registry-base.d.ts.map +0 -1
  159. package/dist/src/types/plugin-registry-base.js +0 -6
  160. package/dist/src/types/plugin-registry-base.js.map +0 -1
  161. package/dist/src/types.d.ts.map +0 -1
  162. package/dist/src/types.js.map +0 -1
  163. package/dist/src/utils/errorParser.d.ts.map +0 -1
  164. package/dist/src/utils/errorParser.js.map +0 -1
  165. package/dist/src/utils/pluginValidator.d.ts +0 -17
  166. package/dist/src/utils/pluginValidator.d.ts.map +0 -1
  167. package/dist/src/utils/pluginValidator.js.map +0 -1
  168. package/dist/src/utils/security.d.ts.map +0 -1
  169. package/dist/src/utils/security.js.map +0 -1
  170. package/dist/src/worker/WorkerRunner.d.ts.map +0 -1
  171. package/dist/src/worker/WorkerRunner.js.map +0 -1
  172. /package/dist/{src/managers → managers}/DependencyManager.d.ts +0 -0
  173. /package/dist/{src/managers → managers}/ResourceManager.d.ts +0 -0
  174. /package/dist/{src/utils → utils}/errorParser.d.ts +0 -0
  175. /package/dist/{src/utils → utils}/security.d.ts +0 -0
  176. /package/dist/{src/utils → utils}/security.js +0 -0
  177. /package/dist/{src/worker → worker}/WorkerRunner.d.ts +0 -0
@@ -1,330 +0,0 @@
1
- /**
2
- * Declarative Logger Example
3
- *
4
- * This example demonstrates a clean, declarative approach to configuring
5
- * and using different logging adapters.
6
- */
7
- import { logger, ConsoleLogger, NoopLogger, SimpleLoggerAdapter, ColorfulConsoleLogger } from "../src";
8
- // Declarative logger factory
9
- const createLogger = (config) => {
10
- switch (config.type) {
11
- case 'console':
12
- const consoleLogger = new ConsoleLogger({
13
- useColors: config.useColors ?? false,
14
- timestampFormat: config.timestampFormat ?? 'none'
15
- });
16
- if (config.context) {
17
- return new SimpleLoggerAdapter(consoleLogger, config.context);
18
- }
19
- return consoleLogger;
20
- case 'colorful':
21
- const colorfulLogger = new ColorfulConsoleLogger({
22
- useColors: config.useColors ?? true,
23
- timestampFormat: config.timestampFormat ?? 'none',
24
- levelColors: config.levelColors,
25
- contextColor: config.contextColor,
26
- showEmoji: config.showEmoji ?? true
27
- });
28
- if (config.context) {
29
- return colorfulLogger.child(config.context);
30
- }
31
- return colorfulLogger;
32
- case 'pino':
33
- // Simulated Pino logger for demonstration
34
- const pinoLogger = {
35
- info: (msg, ...args) => {
36
- console.log(`[PINO] INFO: ${msg}`, ...args);
37
- },
38
- warn: (msg, ...args) => {
39
- console.log(`[PINO] WARN: ${msg}`, ...args);
40
- },
41
- error: (msg, ...args) => {
42
- console.log(`[PINO] ERROR: ${msg}`, ...args);
43
- },
44
- child: (context) => pinoLogger
45
- };
46
- return config.context ?
47
- new SimpleLoggerAdapter(pinoLogger, config.context) :
48
- pinoLogger;
49
- case 'noop':
50
- return new NoopLogger();
51
- default:
52
- throw new Error(`Unknown logger type: ${config.type}`);
53
- }
54
- };
55
- // Logger scenarios
56
- const loggerScenarios = [
57
- {
58
- name: "Basic Console Logger",
59
- config: { type: 'console', context: 'MyApp' },
60
- demo: (log) => {
61
- log.info("Application started");
62
- log.warn("Low memory warning");
63
- log.error("Connection failed");
64
- }
65
- },
66
- {
67
- name: "Colorful Console Logger",
68
- config: {
69
- type: 'colorful',
70
- context: 'ColorfulApp',
71
- timestampFormat: 'time',
72
- showEmoji: true
73
- },
74
- demo: (log) => {
75
- log.info("System initialized with colors");
76
- log.warn("Performance degradation detected");
77
- log.error("Critical system failure");
78
- log.debug("Debug information available");
79
- }
80
- },
81
- {
82
- name: "Custom Color Theme Logger",
83
- config: {
84
- type: 'colorful',
85
- levelColors: {
86
- info: '#00FF00', // Bright green
87
- warn: '#FFA500', // Orange
88
- error: '#FF1493', // Deep pink
89
- debug: '#00CED1' // Dark turquoise
90
- },
91
- contextColor: '#FFD700', // Gold
92
- showEmoji: true
93
- },
94
- demo: (log) => {
95
- log.info("Custom themed info message");
96
- log.warn("Custom themed warning");
97
- log.error("Custom themed error");
98
- }
99
- },
100
- {
101
- name: "Pino-style Logger",
102
- config: { type: 'pino' },
103
- demo: (log) => {
104
- log.info({ userId: 123 }, "User logged in");
105
- log.warn({ memory: '85%' }, "High memory usage");
106
- log.error({ error: 'ECONNREFUSED' }, "Database connection failed");
107
- }
108
- },
109
- {
110
- name: "No-op Logger (disabled)",
111
- config: { type: 'noop' },
112
- demo: (log) => {
113
- log.info("This won't be shown");
114
- log.error("Neither will this");
115
- console.log("But this console.log will still appear");
116
- }
117
- }
118
- ];
119
- // Plugin-specific logger configuration
120
- const pluginLoggerConfigs = {
121
- 'database-plugin': {
122
- type: 'colorful',
123
- context: 'Database',
124
- timestampFormat: 'time',
125
- showEmoji: true,
126
- levelColors: {
127
- info: '#4ECDC4',
128
- warn: '#FFA07A',
129
- error: '#FF6B6B'
130
- }
131
- },
132
- 'api-plugin': {
133
- type: 'colorful',
134
- context: 'API',
135
- showEmoji: true
136
- },
137
- 'cache-plugin': { type: 'noop' }, // Disable cache logging
138
- 'auth-plugin': {
139
- type: 'colorful',
140
- context: 'Auth',
141
- contextColor: '#FF69B4',
142
- showEmoji: true
143
- }
144
- };
145
- // Declarative plugin logger setup
146
- const setupPluginLoggers = () => {
147
- Object.entries(pluginLoggerConfigs).forEach(([pluginName, config]) => {
148
- const log = createLogger(config);
149
- logger.setPluginLogger(pluginName, log);
150
- console.log(`✅ Configured logger for ${pluginName}`);
151
- });
152
- };
153
- // Hierarchical logger demonstration
154
- const demonstrateHierarchicalLoggers = () => {
155
- console.log("\n🏗️ Hierarchical Loggers:");
156
- // Parent logger
157
- const parentLogger = createLogger({ type: 'console', context: 'Parent' });
158
- logger.setDefaultLogger(parentLogger);
159
- parentLogger.info("Message from parent logger");
160
- // Child logger (using factory method)
161
- const childLogger = logger.createLogger('Child');
162
- childLogger.info("Message from child logger");
163
- // Grandchild logger
164
- const grandchildLogger = childLogger.child?.('Grandchild') || childLogger;
165
- grandchildLogger.info("Message from grandchild logger");
166
- };
167
- // Color palette demonstration
168
- const demonstrateColorPalette = () => {
169
- console.log("\n🎨 Bun.color Palette Demo:");
170
- const colors = [
171
- { name: 'CSS Colors', colors: ['red', 'green', 'blue', 'yellow', 'magenta', 'cyan'] },
172
- { name: 'Hex Colors', colors: ['#FF6B6B', '#4ECDC4', '#45B7D1', '#FFA07A', '#98D8C8'] },
173
- { name: 'RGB/HSL', colors: ['rgb(255, 99, 71)', 'hsl(120, 50%, 50%)'] }
174
- ];
175
- colors.forEach(category => {
176
- console.log(`\n${category.name}:`);
177
- category.colors.forEach(color => {
178
- const ansiColor = Bun.color(color, 'ansi');
179
- if (ansiColor) {
180
- console.log(`${ansiColor}This text is ${color}${Bun.color('reset', 'ansi')}`);
181
- }
182
- });
183
- });
184
- };
185
- // Structured logging demonstration
186
- const demonstrateStructuredLogging = () => {
187
- console.log("\n📊 Structured Logging:");
188
- const structuredLogger = createLogger({
189
- type: 'colorful',
190
- context: 'Structured',
191
- timestampFormat: 'iso',
192
- showEmoji: true
193
- });
194
- // Log with metadata
195
- structuredLogger.info("User completed purchase", {
196
- event: 'user_action',
197
- userId: 456,
198
- action: 'purchase',
199
- amount: 99.99,
200
- timestamp: new Date().toISOString()
201
- });
202
- // Log with error context
203
- structuredLogger.error("Input validation failed", {
204
- error: 'ValidationError',
205
- field: 'email',
206
- value: 'invalid-email',
207
- userId: 789
208
- });
209
- };
210
- // Performance logging demonstration
211
- const demonstratePerformanceLogging = () => {
212
- console.log("\n⚡ Performance Logging:");
213
- const perfLogger = createLogger({
214
- type: 'colorful',
215
- context: 'Performance',
216
- timestampFormat: 'time',
217
- showEmoji: true,
218
- levelColors: {
219
- info: '#00FF7F', // Spring green
220
- warn: '#FFD700', // Gold
221
- error: '#FF4500' // Orange red
222
- }
223
- });
224
- // Simulate some operations with timing
225
- const operations = [
226
- { name: 'database_query', duration: 150 },
227
- { name: 'api_call', duration: 300 },
228
- { name: 'file_processing', duration: 75 }
229
- ];
230
- operations.forEach(op => {
231
- perfLogger.info(`Operation ${op.name} completed`, {
232
- operation: op.name,
233
- duration: op.duration,
234
- status: op.duration < 200 ? 'fast' : 'slow',
235
- timestamp: new Date().toISOString()
236
- });
237
- });
238
- };
239
- // Advanced color configuration demonstration
240
- const demonstrateAdvancedColors = () => {
241
- console.log("\n🔬 Advanced Color Configuration:");
242
- // Create loggers with different color schemes
243
- const neonLogger = createLogger({
244
- type: 'colorful',
245
- context: 'Neon',
246
- levelColors: {
247
- info: '#00FFFF', // Cyan
248
- warn: '#FF00FF', // Magenta
249
- error: '#FFFF00', // Yellow
250
- debug: '#00FF00' // Lime
251
- },
252
- contextColor: '#FF1493', // Deep pink
253
- showEmoji: true
254
- });
255
- const pastelLogger = createLogger({
256
- type: 'colorful',
257
- context: 'Pastel',
258
- levelColors: {
259
- info: '#B19CD9', // Light purple
260
- warn: '#FFB6C1', // Light pink
261
- error: '#FFA07A', // Light salmon
262
- debug: '#87CEEB' // Sky blue
263
- },
264
- contextColor: '#DDA0DD', // Plum
265
- showEmoji: false
266
- });
267
- const darkThemeLogger = createLogger({
268
- type: 'colorful',
269
- context: 'DarkTheme',
270
- levelColors: {
271
- info: '#00FF00', // Green
272
- warn: '#FFA500', // Orange
273
- error: '#FF0000', // Red
274
- debug: '#808080' // Gray
275
- },
276
- contextColor: '#FFFFFF', // White
277
- showEmoji: true
278
- });
279
- // Test each themed logger
280
- const loggers = [
281
- { name: 'Neon Theme', logger: neonLogger },
282
- { name: 'Pastel Theme', logger: pastelLogger },
283
- { name: 'Dark Theme', logger: darkThemeLogger }
284
- ];
285
- loggers.forEach(({ name, logger: log }) => {
286
- console.log(`\n${name}:`);
287
- log.info("Information message");
288
- log.warn("Warning message");
289
- log.error("Error message");
290
- log.debug?.("Debug message");
291
- });
292
- };
293
- // Main demonstration
294
- const demonstrateDeclarativeLogging = async () => {
295
- console.log("🚀 Enhanced Declarative Logger Demo\n");
296
- // Scenario 1: Different logger types
297
- console.log("=== Logger Types ===");
298
- for (const scenario of loggerScenarios) {
299
- console.log(`\n${scenario.name}:`);
300
- const log = createLogger(scenario.config);
301
- scenario.demo(log);
302
- }
303
- // Scenario 2: Plugin-specific loggers
304
- console.log("\n=== Plugin-specific Loggers ===");
305
- setupPluginLoggers();
306
- // Test plugin loggers
307
- const plugins = ['database-plugin', 'api-plugin', 'cache-plugin', 'auth-plugin'];
308
- plugins.forEach(pluginName => {
309
- const log = logger.getLogger(pluginName);
310
- log.info(`Test message from ${pluginName}`);
311
- });
312
- // Scenario 3: Hierarchical loggers
313
- demonstrateHierarchicalLoggers();
314
- // Scenario 4: Color palette
315
- demonstrateColorPalette();
316
- // Scenario 5: Structured logging
317
- demonstrateStructuredLogging();
318
- // Scenario 6: Performance logging
319
- demonstratePerformanceLogging();
320
- // Scenario 7: Advanced colors
321
- demonstrateAdvancedColors();
322
- console.log("\n✅ Enhanced declarative logger demo completed!");
323
- };
324
- // Export for use
325
- export { createLogger, loggerScenarios, pluginLoggerConfigs, demonstrateDeclarativeLogging };
326
- // Run if called directly
327
- if (import.meta.main) {
328
- demonstrateDeclarativeLogging().catch(console.error);
329
- }
330
- //# sourceMappingURL=logger-declarative.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger-declarative.js","sourceRoot":"","sources":["../../examples/logger-declarative.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,MAAM,EACN,aAAa,EACb,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,QAAQ,CAAC;AAehB,6BAA6B;AAC7B,MAAM,YAAY,GAAG,CAAC,MAAoB,EAAE,EAAE;IAC5C,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,SAAS;YACZ,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC;gBACtC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK;gBACpC,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,MAAM;aAClD,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,IAAI,mBAAmB,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YAChE,CAAC;YACD,OAAO,aAAa,CAAC;QAEvB,KAAK,UAAU;YACb,MAAM,cAAc,GAAG,IAAI,qBAAqB,CAAC;gBAC/C,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;gBACnC,eAAe,EAAE,MAAM,CAAC,eAAe,IAAI,MAAM;gBACjD,WAAW,EAAE,MAAM,CAAC,WAAW;gBAC/B,YAAY,EAAE,MAAM,CAAC,YAAY;gBACjC,SAAS,EAAE,MAAM,CAAC,SAAS,IAAI,IAAI;aACpC,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;gBACnB,OAAO,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC9C,CAAC;YACD,OAAO,cAAc,CAAC;QAExB,KAAK,MAAM;YACT,0CAA0C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AC;IAEhC,8BAA8B;IAC9B,yBAAyB,EAAE,CAAC;IAE5B,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;AACjE,CAAC,CAAC;AAEF,iBAAiB;AACjB,OAAO,EACL,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,6BAA6B,EAC9B,CAAC;AAEF,yBAAyB;AACzB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,6BAA6B,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvD,CAAC"}
@@ -1,8 +0,0 @@
1
- /**
2
- * Simple Logger Example
3
- *
4
- * This example demonstrates how to use custom loggers with the simplified system
5
- */
6
- declare const runLoggerDemo: () => Promise<void>;
7
- export { runLoggerDemo };
8
- //# sourceMappingURL=logger-simple.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger-simple.d.ts","sourceRoot":"","sources":["../../examples/logger-simple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAgLH,QAAA,MAAM,aAAa,qBAalB,CAAC;AAGF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -1,165 +0,0 @@
1
- /**
2
- * Simple Logger Example
3
- *
4
- * This example demonstrates how to use custom loggers with the simplified system
5
- */
6
- import { logger, NoopLogger, ColorfulConsoleLogger } from "../src";
7
- // Example 1: Using the default colorful console logger
8
- const demoDefaultLogger = () => {
9
- console.log("\n=== Default Colorful Console Logger ===");
10
- const log = logger.getDefaultLogger();
11
- log.info("This is an info message");
12
- log.warn("This is a warning message");
13
- log.error("This is an error message");
14
- log.debug?.("This is a debug message"); // Optional debug method
15
- };
16
- // Example 1b: Using basic console logger without colors
17
- const demoBasicConsoleLogger = () => {
18
- console.log("\n=== Basic Console Logger (No Colors) ===");
19
- // Create a basic console logger without colors
20
- const basicLogger = logger.createConsoleLogger({ useColors: false });
21
- logger.setDefaultLogger(basicLogger);
22
- const log = logger.getDefaultLogger();
23
- log.info("This is a basic info message");
24
- log.warn("This is a basic warning message");
25
- log.error("This is a basic error message");
26
- log.debug?.("This is a basic debug message");
27
- };
28
- // Example 2: Using a custom logger (simulating Winston/Pino style)
29
- const demoCustomLogger = () => {
30
- console.log("\n=== Custom Logger (Winston/Pino style) ===");
31
- // Create a custom logger that follows the Logger interface
32
- const customLogger = {
33
- info: (msg, ...args) => {
34
- console.log(`[CUSTOM] ${new Date().toISOString()} INFO: ${msg}`, ...args);
35
- },
36
- warn: (msg, ...args) => {
37
- console.log(`[CUSTOM] ${new Date().toISOString()} WARN: ${msg}`, ...args);
38
- },
39
- error: (msg, ...args) => {
40
- console.log(`[CUSTOM] ${new Date().toISOString()} ERROR: ${msg}`, ...args);
41
- },
42
- debug: (msg, ...args) => {
43
- console.log(`[CUSTOM] ${new Date().toISOString()} DEBUG: ${msg}`, ...args);
44
- }
45
- };
46
- // Set it as the default logger
47
- logger.setDefaultLogger(customLogger);
48
- // Use it
49
- const log = logger.getDefaultLogger();
50
- log.info("Custom logger info message");
51
- log.warn("Custom logger warning message");
52
- log.error("Custom logger error message");
53
- log.debug?.("Custom logger debug message");
54
- };
55
- // Example 3: Plugin-specific loggers with context and colors
56
- const demoPluginLoggers = () => {
57
- console.log("\n=== Plugin-specific Colorful Loggers ===");
58
- // Reset to colorful console logger
59
- logger.setDefaultLogger(new ColorfulConsoleLogger());
60
- // Create loggers for different plugins
61
- const dbLogger = logger.createLogger("database");
62
- const apiLogger = logger.createLogger("api");
63
- const authLogger = logger.createLogger("auth");
64
- dbLogger.info("Connected to database");
65
- dbLogger.debug?.("Query executed in 150ms");
66
- apiLogger.info("API server started on port 3000");
67
- apiLogger.warn("High response time detected");
68
- authLogger.info("User authentication successful");
69
- authLogger.error("Invalid credentials provided");
70
- };
71
- // Example 4: Using no-op logger to disable logging
72
- const demoNoopLogger = () => {
73
- console.log("\n=== No-op Logger (disabled logging) ===");
74
- const noopLog = new NoopLogger();
75
- logger.setDefaultLogger(noopLog);
76
- const log = logger.getDefaultLogger();
77
- log.info("This won't be shown");
78
- log.error("Neither will this error");
79
- log.warn("This warning is also ignored");
80
- console.log("But regular console.log still works");
81
- };
82
- // Example 5: Wrapping existing loggers
83
- const demoWrapLogger = () => {
84
- console.log("\n=== Wrapping Existing Loggers ===");
85
- // Simulate an existing logger from another library
86
- const existingLogger = {
87
- log: (level, message) => {
88
- console.log(`[EXTERNAL] ${level.toUpperCase()}: ${message}`);
89
- }
90
- };
91
- // Create a wrapper that implements our Logger interface
92
- const wrappedLogger = {
93
- info: (msg) => existingLogger.log('info', msg),
94
- warn: (msg) => existingLogger.log('warn', msg),
95
- error: (msg) => existingLogger.log('error', msg),
96
- child: (context) => wrappedLogger // Simple child implementation
97
- };
98
- // Wrap it with our adapter for context support
99
- const adaptedLogger = logger.wrapLogger(wrappedLogger, "wrapped-context");
100
- adaptedLogger.info("Message from wrapped logger");
101
- adaptedLogger.warn("Warning from wrapped logger");
102
- adaptedLogger.error("Error from wrapped logger");
103
- };
104
- // Example 6: Advanced colorful logger with custom colors
105
- const demoAdvancedColorfulLogger = () => {
106
- console.log("\n=== Advanced Colorful Logger ===");
107
- // Create a colorful logger with custom configuration
108
- const colorfulLogger = logger.createColorfulConsoleLogger({
109
- useColors: true,
110
- timestampFormat: 'time',
111
- levelColors: {
112
- info: '#00FF00', // Bright green
113
- warn: '#FFD700', // Gold
114
- error: '#FF0000', // Red
115
- debug: '#00CED1' // Dark turquoise
116
- },
117
- contextColor: '#FF69B4', // Hot pink
118
- showEmoji: true
119
- });
120
- logger.setDefaultLogger(colorfulLogger);
121
- const log = logger.getDefaultLogger();
122
- log.info("System initialized successfully");
123
- log.warn("Cache miss detected");
124
- log.error("Failed to connect to external service");
125
- log.debug?.("Processing request with ID: abc123");
126
- // Test hierarchical logging with colors
127
- const childLogger = log.child?.('submodule') || log;
128
- childLogger.info("Child logger with colorful context");
129
- childLogger.error("Error from child logger");
130
- };
131
- // Example 7: Color palette demonstration
132
- const demoColorPalette = () => {
133
- console.log("\n=== Bun.color Palette Demo ===");
134
- const colors = [
135
- 'red', 'green', 'blue', 'yellow', 'magenta', 'cyan',
136
- '#FF6B6B', '#4ECDC4', '#45B7D1', '#FFA07A', '#98D8C8',
137
- 'rgb(255, 99, 71)', 'hsl(120, 50%, 50%)'
138
- ];
139
- colors.forEach(color => {
140
- const ansiColor = Bun.color(color, 'ansi');
141
- if (ansiColor) {
142
- console.log(`${ansiColor}This text is ${color}${Bun.color('reset', 'ansi')}`);
143
- }
144
- });
145
- };
146
- // Main demonstration
147
- const runLoggerDemo = async () => {
148
- console.log("🚀 Enhanced Colorful Logger Demo\n");
149
- demoDefaultLogger();
150
- demoBasicConsoleLogger();
151
- demoCustomLogger();
152
- demoPluginLoggers();
153
- demoNoopLogger();
154
- demoWrapLogger();
155
- demoAdvancedColorfulLogger();
156
- demoColorPalette();
157
- console.log("\n✅ Enhanced logger demo completed!");
158
- };
159
- // Export for use
160
- export { runLoggerDemo };
161
- // Run if called directly
162
- if (import.meta.main) {
163
- runLoggerDemo().catch(console.error);
164
- }
165
- //# sourceMappingURL=logger-simple.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"logger-simple.js","sourceRoot":"","sources":["../../examples/logger-simple.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAiB,UAAU,EAAuB,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAEvG,uDAAuD;AACvD,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;IACzD,MAAM,GAAG,GAAG,MAAM,CAAC,gBAAgB,EAAE,CAAC;IAEtC,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;IACpC,GAAG,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IACtC,GAAG,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACtC,GAAG,CAAC,KAAK,EAAE,CAAC,yBAAyB,CAAC,CAAC,CAAC,wBA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B;AACzB,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;IACrB,aAAa,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AACvC,CAAC"}
@@ -1,46 +0,0 @@
1
- /**
2
- * Declarative Server Example
3
- *
4
- * A clean, declarative approach to building a plugin-powered server
5
- * with minimal boilerplate and maximum clarity.
6
- */
7
- import { PluginManager } from "../src/PluginManager";
8
- interface ServerConfig {
9
- port: number;
10
- host: string;
11
- routes: RouteDefinition[];
12
- middleware: MiddlewareDefinition[];
13
- }
14
- interface RouteDefinition {
15
- method: 'GET' | 'POST' | 'PUT' | 'DELETE';
16
- path: string;
17
- handler: string;
18
- description?: string;
19
- }
20
- interface MiddlewareDefinition {
21
- name: string;
22
- priority: number;
23
- handler: string;
24
- }
25
- declare const routes: RouteDefinition[];
26
- declare const createServerPlugin: () => {
27
- name: string;
28
- version: string;
29
- description: string;
30
- onLoad(context: any): Promise<void>;
31
- onUnload(): Promise<void>;
32
- };
33
- declare const createDeclarativeServer: (config: ServerConfig) => {
34
- pluginManager: PluginManager;
35
- start(): Promise<Bun.Server<undefined>>;
36
- };
37
- declare const createActionRegistryPlugin: () => {
38
- name: string;
39
- version: string;
40
- description: string;
41
- onLoad(context: any): Promise<void>;
42
- onUnload(): Promise<void>;
43
- };
44
- declare const demonstrateDeclarativeServer: () => Promise<Bun.Server<undefined>>;
45
- export { createDeclarativeServer, createServerPlugin, createActionRegistryPlugin, routes, demonstrateDeclarativeServer };
46
- //# sourceMappingURL=server-declarative.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server-declarative.d.ts","sourceRoot":"","sources":["../../examples/server-declarative.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACpC;AAED,UAAU,eAAe;IACvB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,QAAA,MAAM,MAAM,EAAE,eAAe,EAqC5B,CAAC;AAGF,QAAA,MAAM,kBAAkB;;;;oBAKA,GAAG;;CAmCzB,CAAC;AAGH,QAAA,MAAM,uBAAuB,GAAI,QAAQ,YAAY;;;CAyEpD,CAAC;AAGF,QAAA,MAAM,0BAA0B;;;;oBAKR,GAAG;;CA8BzB,CAAC;AAGH,QAAA,MAAM,4BAA4B,sCAwBjC,CAAC;AAGF,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,0BAA0B,EAC1B,MAAM,EACN,4BAA4B,EAC7B,CAAC"}