folderblog 0.0.1 → 0.0.2

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 (42) hide show
  1. package/README.md +109 -48
  2. package/dist/chunk-24MKFHML.cjs +143 -0
  3. package/dist/chunk-3RG5ZIWI.js +8 -0
  4. package/dist/chunk-4ZJGUMHS.cjs +78 -0
  5. package/dist/chunk-HMQIQUPB.cjs +387 -0
  6. package/dist/chunk-IXP35S24.js +1715 -0
  7. package/dist/chunk-OBGZSXTJ.cjs +10 -0
  8. package/dist/chunk-PARGDJNY.js +76 -0
  9. package/dist/chunk-QA4KPPTA.cjs +1787 -0
  10. package/dist/chunk-XP5J4LFJ.js +127 -0
  11. package/dist/chunk-ZRUBI3GH.js +370 -0
  12. package/dist/cli/bin.cjs +25 -0
  13. package/dist/cli/bin.d.cts +1 -0
  14. package/dist/cli/bin.d.ts +1 -0
  15. package/dist/cli/bin.js +23 -0
  16. package/dist/cli/index.cjs +22 -0
  17. package/dist/cli/index.d.cts +39 -0
  18. package/dist/cli/index.d.ts +39 -0
  19. package/dist/cli/index.js +15 -0
  20. package/dist/config-DFr-htlO.d.cts +887 -0
  21. package/dist/config-DFr-htlO.d.ts +887 -0
  22. package/dist/index.cjs +488 -1
  23. package/dist/index.d.cts +76 -8
  24. package/dist/index.d.ts +76 -8
  25. package/dist/index.js +153 -1
  26. package/dist/processor/index.cjs +337 -0
  27. package/dist/processor/index.d.cts +491 -0
  28. package/dist/processor/index.d.ts +491 -0
  29. package/dist/processor/index.js +4 -0
  30. package/dist/processor/plugins.cjs +51 -0
  31. package/dist/processor/plugins.d.cts +174 -0
  32. package/dist/processor/plugins.d.ts +174 -0
  33. package/dist/processor/plugins.js +2 -0
  34. package/dist/processor/types.cjs +67 -0
  35. package/dist/processor/types.d.cts +47 -0
  36. package/dist/processor/types.d.ts +47 -0
  37. package/dist/processor/types.js +2 -0
  38. package/dist/server/index.cjs +36 -0
  39. package/dist/server/index.d.cts +56 -0
  40. package/dist/server/index.d.ts +56 -0
  41. package/dist/server/index.js +34 -0
  42. package/package.json +63 -11
@@ -0,0 +1,387 @@
1
+ 'use strict';
2
+
3
+ var fs = require('fs/promises');
4
+ var path = require('path');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var fs__default = /*#__PURE__*/_interopDefault(fs);
9
+ var path__default = /*#__PURE__*/_interopDefault(path);
10
+
11
+ // ../processor/src/plugins/manager.ts
12
+ var PluginManager = class {
13
+ plugins = /* @__PURE__ */ new Map();
14
+ config;
15
+ outputDir;
16
+ issues;
17
+ log;
18
+ initialized = false;
19
+ constructor(config) {
20
+ this.config = config.config;
21
+ this.outputDir = config.outputDir;
22
+ this.issues = config.issues;
23
+ this.log = config.log ?? defaultLogger;
24
+ }
25
+ // --------------------------------------------------------------------------
26
+ // Initialization
27
+ // --------------------------------------------------------------------------
28
+ /**
29
+ * Initialize all plugins in dependency order
30
+ */
31
+ async initialize() {
32
+ if (this.initialized) {
33
+ this.log("Plugin manager already initialized", "warn");
34
+ return;
35
+ }
36
+ const pluginConfigs = this.config.plugins ?? {};
37
+ const allPlugins = Object.values(pluginConfigs).filter(
38
+ (p) => p != null
39
+ );
40
+ if (allPlugins.length === 0) {
41
+ this.log("No plugins configured", "debug");
42
+ this.initialized = true;
43
+ return;
44
+ }
45
+ this.log(`Initializing ${allPlugins.length} plugin(s)...`, "info");
46
+ const sorted = topologicalSort(allPlugins);
47
+ const context = this.createContext();
48
+ for (const plugin of sorted) {
49
+ await this.initializePlugin(plugin, context);
50
+ }
51
+ this.initialized = true;
52
+ this.log(`All plugins initialized successfully`, "info");
53
+ }
54
+ /**
55
+ * Initialize a single plugin
56
+ */
57
+ async initializePlugin(plugin, context) {
58
+ const { name, requires } = plugin;
59
+ this.log(`Initializing plugin: ${name}`, "debug");
60
+ for (const dep of requires ?? []) {
61
+ if (!this.plugins.has(dep)) {
62
+ const error = `Plugin "${name}" requires "${dep}" which is not configured`;
63
+ this.issues.addPluginError({
64
+ pluginName: name,
65
+ operation: "initialize",
66
+ errorMessage: error
67
+ });
68
+ throw new Error(error);
69
+ }
70
+ }
71
+ try {
72
+ await plugin.initialize(context);
73
+ this.plugins.set(name, plugin);
74
+ this.log(`Plugin "${name}" initialized`, "debug");
75
+ } catch (error) {
76
+ const errorMessage = error instanceof Error ? error.message : String(error);
77
+ this.issues.addPluginError({
78
+ pluginName: name,
79
+ operation: "initialize",
80
+ errorMessage
81
+ });
82
+ throw new Error(`Failed to initialize plugin "${name}": ${errorMessage}`);
83
+ }
84
+ }
85
+ /**
86
+ * Create plugin context
87
+ */
88
+ createContext() {
89
+ return {
90
+ outputDir: this.outputDir,
91
+ issues: this.issues,
92
+ log: this.log,
93
+ config: this.config,
94
+ getPlugin: (name) => this.getPlugin(name)
95
+ };
96
+ }
97
+ // --------------------------------------------------------------------------
98
+ // Plugin Access
99
+ // --------------------------------------------------------------------------
100
+ /**
101
+ * Get a plugin by name
102
+ */
103
+ getPlugin(name) {
104
+ return this.plugins.get(name);
105
+ }
106
+ /**
107
+ * Get a typed plugin by its config key
108
+ */
109
+ getPluginByKey(key) {
110
+ return this.plugins.get(key);
111
+ }
112
+ /**
113
+ * Check if a plugin is available
114
+ */
115
+ hasPlugin(name) {
116
+ return this.plugins.has(name);
117
+ }
118
+ /**
119
+ * Get all initialized plugin names
120
+ */
121
+ getPluginNames() {
122
+ return [...this.plugins.keys()];
123
+ }
124
+ // --------------------------------------------------------------------------
125
+ // Cleanup
126
+ // --------------------------------------------------------------------------
127
+ /**
128
+ * Dispose all plugins
129
+ */
130
+ async dispose() {
131
+ const plugins = [...this.plugins.values()].reverse();
132
+ for (const plugin of plugins) {
133
+ if (plugin.dispose) {
134
+ try {
135
+ await plugin.dispose();
136
+ this.log(`Plugin "${plugin.name}" disposed`, "debug");
137
+ } catch (error) {
138
+ const errorMessage = error instanceof Error ? error.message : String(error);
139
+ this.issues.addPluginError({
140
+ pluginName: plugin.name,
141
+ operation: "dispose",
142
+ errorMessage
143
+ });
144
+ }
145
+ }
146
+ }
147
+ this.plugins.clear();
148
+ this.initialized = false;
149
+ }
150
+ };
151
+ var topologicalSort = (plugins) => {
152
+ const pluginMap = /* @__PURE__ */ new Map();
153
+ const adjacency = /* @__PURE__ */ new Map();
154
+ const inDegree = /* @__PURE__ */ new Map();
155
+ for (const plugin of plugins) {
156
+ pluginMap.set(plugin.name, plugin);
157
+ adjacency.set(plugin.name, []);
158
+ inDegree.set(plugin.name, 0);
159
+ }
160
+ for (const plugin of plugins) {
161
+ for (const dep of plugin.requires ?? []) {
162
+ if (adjacency.has(dep)) {
163
+ adjacency.get(dep).push(plugin.name);
164
+ inDegree.set(plugin.name, (inDegree.get(plugin.name) ?? 0) + 1);
165
+ }
166
+ }
167
+ }
168
+ const queue = [];
169
+ const result = [];
170
+ for (const [name, degree] of inDegree) {
171
+ if (degree === 0) {
172
+ queue.push(name);
173
+ }
174
+ }
175
+ while (queue.length > 0) {
176
+ const name = queue.shift();
177
+ const plugin = pluginMap.get(name);
178
+ if (plugin) {
179
+ result.push(plugin);
180
+ }
181
+ for (const neighbor of adjacency.get(name) ?? []) {
182
+ const newDegree = (inDegree.get(neighbor) ?? 0) - 1;
183
+ inDegree.set(neighbor, newDegree);
184
+ if (newDegree === 0) {
185
+ queue.push(neighbor);
186
+ }
187
+ }
188
+ }
189
+ if (result.length !== plugins.length) {
190
+ const unresolved = plugins.filter((p) => !result.includes(p)).map((p) => p.name);
191
+ throw new Error(
192
+ `Circular plugin dependency detected involving: ${unresolved.join(", ")}`
193
+ );
194
+ }
195
+ return result;
196
+ };
197
+ var defaultLogger = (message, level = "info") => {
198
+ const prefix = `[processor-core]`;
199
+ switch (level) {
200
+ case "error":
201
+ console.error(`${prefix} ERROR: ${message}`);
202
+ break;
203
+ case "warn":
204
+ console.warn(`${prefix} WARN: ${message}`);
205
+ break;
206
+ case "debug":
207
+ if (process.env.NODE_ENV === "development" || process.env.DEBUG) {
208
+ console.log(`${prefix} DEBUG: ${message}`);
209
+ }
210
+ break;
211
+ default:
212
+ console.log(`${prefix} ${message}`);
213
+ }
214
+ };
215
+ var createPluginManager = async (config) => {
216
+ const manager = new PluginManager(config);
217
+ await manager.initialize();
218
+ return manager;
219
+ };
220
+ var CopyOnlyImageProcessor = class {
221
+ name = "imageProcessor";
222
+ ready = false;
223
+ context = null;
224
+ async initialize(context) {
225
+ this.context = context;
226
+ this.ready = true;
227
+ context.log("CopyOnlyImageProcessor initialized (no optimization)", "debug");
228
+ }
229
+ isReady() {
230
+ return this.ready;
231
+ }
232
+ canProcess(filePath) {
233
+ const ext = path__default.default.extname(filePath).toLowerCase();
234
+ return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".avif", ".svg"].includes(ext);
235
+ }
236
+ async getMetadata(filePath) {
237
+ const ext = path__default.default.extname(filePath).toLowerCase().slice(1);
238
+ return {
239
+ width: 0,
240
+ height: 0,
241
+ format: ext || "unknown"
242
+ };
243
+ }
244
+ async process(inputPath, outputPath, _options) {
245
+ await this.copy(inputPath, outputPath);
246
+ const stats = await fs__default.default.stat(outputPath);
247
+ const ext = path__default.default.extname(inputPath).toLowerCase().slice(1);
248
+ return {
249
+ outputPath,
250
+ width: 0,
251
+ height: 0,
252
+ format: ext || "unknown",
253
+ size: stats.size
254
+ };
255
+ }
256
+ async copy(inputPath, outputPath) {
257
+ await fs__default.default.mkdir(path__default.default.dirname(outputPath), { recursive: true });
258
+ await fs__default.default.copyFile(inputPath, outputPath);
259
+ }
260
+ };
261
+ var PassthroughMermaidRenderer = class {
262
+ name = "mermaidRenderer";
263
+ ready = false;
264
+ async initialize(context) {
265
+ this.ready = true;
266
+ context.log("PassthroughMermaidRenderer initialized (client-side rendering)", "debug");
267
+ }
268
+ isReady() {
269
+ return this.ready;
270
+ }
271
+ async isAvailable() {
272
+ return true;
273
+ }
274
+ async render(code, _options) {
275
+ return {
276
+ output: code,
277
+ strategy: "pre-mermaid"
278
+ };
279
+ }
280
+ };
281
+ var NoOpTextEmbedder = class {
282
+ name = "textEmbedder";
283
+ model = "none";
284
+ dimensions = 0;
285
+ ready = false;
286
+ async initialize(context) {
287
+ this.ready = true;
288
+ context.log("NoOpTextEmbedder initialized (embeddings disabled)", "debug");
289
+ }
290
+ isReady() {
291
+ return this.ready;
292
+ }
293
+ async embed(_text) {
294
+ return [];
295
+ }
296
+ async batchEmbed(texts) {
297
+ return texts.map(() => []);
298
+ }
299
+ };
300
+ var NoOpImageEmbedder = class {
301
+ name = "imageEmbedder";
302
+ model = "none";
303
+ dimensions = 0;
304
+ ready = false;
305
+ async initialize(context) {
306
+ this.ready = true;
307
+ context.log("NoOpImageEmbedder initialized (image embeddings disabled)", "debug");
308
+ }
309
+ isReady() {
310
+ return this.ready;
311
+ }
312
+ async embedFile(_filePath) {
313
+ return [];
314
+ }
315
+ async embedBuffer(_buffer, _mimeType) {
316
+ return [];
317
+ }
318
+ };
319
+ var NoOpSimilarity = class {
320
+ name = "similarity";
321
+ requires = ["textEmbedder"];
322
+ ready = false;
323
+ async initialize(context) {
324
+ this.ready = true;
325
+ context.log("NoOpSimilarity initialized (similarity disabled)", "debug");
326
+ }
327
+ isReady() {
328
+ return this.ready;
329
+ }
330
+ computeSimilarity(_a, _b) {
331
+ return 0;
332
+ }
333
+ async generateSimilarityMap(posts) {
334
+ return {
335
+ pairwiseScores: /* @__PURE__ */ new Map(),
336
+ similarPosts: /* @__PURE__ */ new Map(),
337
+ metadata: {
338
+ computedAt: (/* @__PURE__ */ new Date()).toISOString(),
339
+ postCount: posts.length,
340
+ pairCount: 0
341
+ }
342
+ };
343
+ }
344
+ };
345
+ var NoOpDatabase = class {
346
+ name = "database";
347
+ ready = false;
348
+ async initialize(context) {
349
+ this.ready = true;
350
+ context.log("NoOpDatabase initialized (database generation disabled)", "debug");
351
+ }
352
+ isReady() {
353
+ return this.ready;
354
+ }
355
+ async build(_input) {
356
+ return {
357
+ databasePath: "",
358
+ tables: [],
359
+ rowCounts: {},
360
+ hasVectorSearch: false
361
+ };
362
+ }
363
+ };
364
+ var createDefaultPlugins = () => ({
365
+ imageProcessor: new CopyOnlyImageProcessor(),
366
+ mermaidRenderer: new PassthroughMermaidRenderer()
367
+ });
368
+ var createAllNoOpPlugins = () => ({
369
+ imageProcessor: new CopyOnlyImageProcessor(),
370
+ mermaidRenderer: new PassthroughMermaidRenderer(),
371
+ textEmbedder: new NoOpTextEmbedder(),
372
+ imageEmbedder: new NoOpImageEmbedder(),
373
+ similarity: new NoOpSimilarity(),
374
+ database: new NoOpDatabase()
375
+ });
376
+
377
+ exports.CopyOnlyImageProcessor = CopyOnlyImageProcessor;
378
+ exports.NoOpDatabase = NoOpDatabase;
379
+ exports.NoOpImageEmbedder = NoOpImageEmbedder;
380
+ exports.NoOpSimilarity = NoOpSimilarity;
381
+ exports.NoOpTextEmbedder = NoOpTextEmbedder;
382
+ exports.PassthroughMermaidRenderer = PassthroughMermaidRenderer;
383
+ exports.PluginManager = PluginManager;
384
+ exports.createAllNoOpPlugins = createAllNoOpPlugins;
385
+ exports.createDefaultPlugins = createDefaultPlugins;
386
+ exports.createPluginManager = createPluginManager;
387
+ exports.topologicalSort = topologicalSort;