@rexeus/typeweaver-gen 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -148,4 +148,4 @@ output.
148
148
 
149
149
  ## 📄 License
150
150
 
151
- Apache 2.0 © Dennis Wentzien 2025
151
+ Apache 2.0 © Dennis Wentzien 2026
package/dist/LICENSE CHANGED
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright 2025 Dennis Wentzien
190
+ Copyright 2026 Dennis Wentzien
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
package/dist/NOTICE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2025 Dennis Wentzien
1
+ Copyright 2026 Dennis Wentzien
2
2
 
3
3
  This project is licensed under the Apache License, Version 2.0
4
4
  See LICENSE file for details.
package/dist/index.cjs CHANGED
@@ -1,228 +1,274 @@
1
- 'use strict';
2
-
3
- var fs = require('node:fs');
4
- var path3 = require('node:path');
5
- var ejs = require('ejs');
6
-
7
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ //#region \0rolldown/runtime.js
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
12
+ key = keys[i];
13
+ if (!__hasOwnProp.call(to, key) && key !== except) {
14
+ __defProp(to, key, {
15
+ get: ((k) => from[k]).bind(null, key),
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ }
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
26
+ }) : target, mod));
8
27
 
9
- var fs__default = /*#__PURE__*/_interopDefault(fs);
10
- var path3__default = /*#__PURE__*/_interopDefault(path3);
28
+ //#endregion
29
+ let node_fs = require("node:fs");
30
+ node_fs = __toESM(node_fs);
31
+ let node_path = require("node:path");
32
+ node_path = __toESM(node_path);
33
+ let ejs = require("ejs");
11
34
 
12
- // src/plugins/types.ts
35
+ //#region src/plugins/types.ts
36
+ /**
37
+ * Plugin loading error
38
+ */
13
39
  var PluginLoadError = class extends Error {
14
- constructor(pluginName, message) {
15
- super(`Failed to load plugin '${pluginName}': ${message}`);
16
- this.pluginName = pluginName;
17
- this.name = "PluginLoadError";
18
- }
40
+ constructor(pluginName, message) {
41
+ super(`Failed to load plugin '${pluginName}': ${message}`);
42
+ this.pluginName = pluginName;
43
+ this.name = "PluginLoadError";
44
+ }
19
45
  };
46
+ /**
47
+ * Plugin dependency error
48
+ */
20
49
  var PluginDependencyError = class extends Error {
21
- constructor(pluginName, missingDependency) {
22
- super(
23
- `Plugin '${pluginName}' depends on '${missingDependency}' which is not loaded`
24
- );
25
- this.pluginName = pluginName;
26
- this.missingDependency = missingDependency;
27
- this.name = "PluginDependencyError";
28
- }
50
+ constructor(pluginName, missingDependency) {
51
+ super(`Plugin '${pluginName}' depends on '${missingDependency}' which is not loaded`);
52
+ this.pluginName = pluginName;
53
+ this.missingDependency = missingDependency;
54
+ this.name = "PluginDependencyError";
55
+ }
29
56
  };
57
+
58
+ //#endregion
59
+ //#region src/plugins/BasePlugin.ts
60
+ /**
61
+ * Base class for typeweaver plugins
62
+ * Provides default implementations and common utilities
63
+ */
30
64
  var BasePlugin = class {
31
- description;
32
- author;
33
- depends;
34
- config;
35
- constructor(config = {}) {
36
- this.config = config;
37
- }
38
- /**
39
- * Default implementation - override in subclasses if needed
40
- */
41
- async initialize(context) {
42
- }
43
- /**
44
- * Default implementation - override in subclasses if needed
45
- */
46
- collectResources(resources) {
47
- return resources;
48
- }
49
- /**
50
- * Default implementation - override in subclasses if needed
51
- */
52
- async finalize(context) {
53
- }
54
- /**
55
- * Copy lib files from plugin package to generated lib folder
56
- */
57
- copyLibFiles(context, libSourceDir, libNamespace) {
58
- const libDir = path3__default.default.join(context.outputDir, "lib", libNamespace);
59
- fs__default.default.mkdirSync(libDir, { recursive: true });
60
- if (fs__default.default.existsSync(libSourceDir)) {
61
- const files = fs__default.default.readdirSync(libSourceDir);
62
- for (const file of files) {
63
- const sourcePath = path3__default.default.join(libSourceDir, file);
64
- const targetPath = path3__default.default.join(libDir, file);
65
- if (fs__default.default.statSync(sourcePath).isFile()) {
66
- fs__default.default.copyFileSync(sourcePath, targetPath);
67
- }
68
- }
69
- }
70
- }
65
+ description;
66
+ author;
67
+ depends;
68
+ config;
69
+ constructor(config = {}) {
70
+ this.config = config;
71
+ }
72
+ /**
73
+ * Default implementation - override in subclasses if needed
74
+ */
75
+ async initialize(_context) {}
76
+ /**
77
+ * Default implementation - override in subclasses if needed
78
+ */
79
+ collectResources(resources) {
80
+ return resources;
81
+ }
82
+ /**
83
+ * Default implementation - override in subclasses if needed
84
+ */
85
+ async finalize(_context) {}
86
+ /**
87
+ * Copy lib files from plugin package to generated lib folder
88
+ */
89
+ copyLibFiles(context, libSourceDir, libNamespace) {
90
+ const libDir = node_path.default.join(context.outputDir, "lib", libNamespace);
91
+ node_fs.default.mkdirSync(libDir, { recursive: true });
92
+ if (node_fs.default.existsSync(libSourceDir)) {
93
+ const files = node_fs.default.readdirSync(libSourceDir);
94
+ for (const file of files) {
95
+ const sourcePath = node_path.default.join(libSourceDir, file);
96
+ const targetPath = node_path.default.join(libDir, file);
97
+ if (node_fs.default.statSync(sourcePath).isFile()) node_fs.default.copyFileSync(sourcePath, targetPath);
98
+ }
99
+ const libIndexPath = node_path.default.join("lib", libNamespace, "index.ts");
100
+ if (node_fs.default.existsSync(node_path.default.join(libDir, "index.ts"))) context.addGeneratedFile(libIndexPath);
101
+ }
102
+ }
71
103
  };
104
+
105
+ //#endregion
106
+ //#region src/plugins/BaseTemplatePlugin.ts
107
+ /**
108
+ * Base class for template-based generator plugins
109
+ * Provides utilities for working with EJS templates
110
+ */
72
111
  var BaseTemplatePlugin = class extends BasePlugin {
73
- /**
74
- * Render an EJS template with the given data
75
- */
76
- renderTemplate(templatePath, data) {
77
- const template = fs__default.default.readFileSync(templatePath, "utf8");
78
- return ejs.render(template, data);
79
- }
80
- /**
81
- * Write a file relative to the output directory
82
- */
83
- writeFile(context, relativePath, content) {
84
- context.writeFile(relativePath, content);
85
- }
86
- /**
87
- * Ensure a directory exists
88
- */
89
- ensureDir(context, relativePath) {
90
- const fullPath = path3__default.default.join(context.outputDir, relativePath);
91
- fs__default.default.mkdirSync(fullPath, { recursive: true });
92
- }
93
- /**
94
- * Get the template path for this plugin
95
- */
96
- getTemplatePath(context, templateName) {
97
- return path3__default.default.join(context.templateDir, templateName);
98
- }
112
+ /**
113
+ * Render an EJS template with the given data
114
+ */
115
+ renderTemplate(templatePath, data) {
116
+ return (0, ejs.render)(node_fs.default.readFileSync(templatePath, "utf8"), data);
117
+ }
118
+ /**
119
+ * Write a file relative to the output directory
120
+ */
121
+ writeFile(context, relativePath, content) {
122
+ context.writeFile(relativePath, content);
123
+ }
124
+ /**
125
+ * Ensure a directory exists
126
+ */
127
+ ensureDir(context, relativePath) {
128
+ const fullPath = node_path.default.join(context.outputDir, relativePath);
129
+ node_fs.default.mkdirSync(fullPath, { recursive: true });
130
+ }
131
+ /**
132
+ * Get the template path for this plugin
133
+ */
134
+ getTemplatePath(context, templateName) {
135
+ return node_path.default.join(context.templateDir, templateName);
136
+ }
99
137
  };
100
138
 
101
- // src/plugins/PluginRegistry.ts
139
+ //#endregion
140
+ //#region src/plugins/PluginRegistry.ts
141
+ /**
142
+ * Registry for managing typeweaver plugins
143
+ */
102
144
  var PluginRegistry = class {
103
- plugins;
104
- constructor() {
105
- this.plugins = /* @__PURE__ */ new Map();
106
- }
107
- /**
108
- * Register a plugin
109
- */
110
- register(plugin, config) {
111
- if (this.plugins.has(plugin.name)) {
112
- console.info(
113
- `Skipping duplicate registration of required plugin: ${plugin.name}`
114
- );
115
- return;
116
- }
117
- const registration = {
118
- name: plugin.name,
119
- plugin,
120
- config
121
- };
122
- this.plugins.set(plugin.name, registration);
123
- console.info(`Registered plugin: ${plugin.name}`);
124
- }
125
- /**
126
- * Get a registered plugin
127
- */
128
- get(name) {
129
- return this.plugins.get(name);
130
- }
131
- /**
132
- * Get all registered plugins
133
- */
134
- getAll() {
135
- return Array.from(this.plugins.values());
136
- }
137
- /**
138
- * Check if a plugin is registered
139
- */
140
- has(name) {
141
- return this.plugins.has(name);
142
- }
143
- /**
144
- * Clear all registered plugins (except required ones)
145
- */
146
- clear() {
147
- this.plugins.clear();
148
- }
145
+ plugins;
146
+ constructor() {
147
+ this.plugins = /* @__PURE__ */ new Map();
148
+ }
149
+ /**
150
+ * Register a plugin
151
+ */
152
+ register(plugin, config) {
153
+ if (this.plugins.has(plugin.name)) {
154
+ console.info(`Skipping duplicate registration of required plugin: ${plugin.name}`);
155
+ return;
156
+ }
157
+ const registration = {
158
+ name: plugin.name,
159
+ plugin,
160
+ config
161
+ };
162
+ this.plugins.set(plugin.name, registration);
163
+ console.info(`Registered plugin: ${plugin.name}`);
164
+ }
165
+ /**
166
+ * Get a registered plugin
167
+ */
168
+ get(name) {
169
+ return this.plugins.get(name);
170
+ }
171
+ /**
172
+ * Get all registered plugins
173
+ */
174
+ getAll() {
175
+ return Array.from(this.plugins.values());
176
+ }
177
+ /**
178
+ * Check if a plugin is registered
179
+ */
180
+ has(name) {
181
+ return this.plugins.has(name);
182
+ }
183
+ /**
184
+ * Clear all registered plugins (except required ones)
185
+ */
186
+ clear() {
187
+ this.plugins.clear();
188
+ }
149
189
  };
190
+
191
+ //#endregion
192
+ //#region src/plugins/PluginContext.ts
193
+ /**
194
+ * Builder for plugin contexts
195
+ */
150
196
  var PluginContextBuilder = class {
151
- generatedFiles = /* @__PURE__ */ new Set();
152
- /**
153
- * Create a basic plugin context
154
- */
155
- createPluginContext(params) {
156
- return {
157
- outputDir: params.outputDir,
158
- inputDir: params.inputDir,
159
- config: params.config
160
- };
161
- }
162
- /**
163
- * Create a generator context with utilities
164
- */
165
- createGeneratorContext(params) {
166
- const pluginContext = this.createPluginContext(params);
167
- return {
168
- ...pluginContext,
169
- resources: params.resources,
170
- templateDir: params.templateDir,
171
- coreDir: params.coreDir,
172
- // Utility functions
173
- writeFile: (relativePath, content) => {
174
- const fullPath = path3__default.default.join(params.outputDir, relativePath);
175
- const dir = path3__default.default.dirname(fullPath);
176
- fs__default.default.mkdirSync(dir, { recursive: true });
177
- fs__default.default.writeFileSync(fullPath, content);
178
- this.generatedFiles.add(relativePath);
179
- console.info(`Generated: ${relativePath}`);
180
- },
181
- renderTemplate: (templatePath, data) => {
182
- const fullTemplatePath = path3__default.default.isAbsolute(templatePath) ? templatePath : path3__default.default.join(params.templateDir, templatePath);
183
- const template = fs__default.default.readFileSync(fullTemplatePath, "utf8");
184
- return ejs.render(template, data);
185
- },
186
- addGeneratedFile: (relativePath) => {
187
- this.generatedFiles.add(relativePath);
188
- },
189
- getGeneratedFiles: () => {
190
- return Array.from(this.generatedFiles);
191
- }
192
- };
193
- }
194
- /**
195
- * Get all generated files
196
- */
197
- getGeneratedFiles() {
198
- return Array.from(this.generatedFiles);
199
- }
200
- /**
201
- * Clear generated files tracking
202
- */
203
- clearGeneratedFiles() {
204
- this.generatedFiles.clear();
205
- }
197
+ generatedFiles = /* @__PURE__ */ new Set();
198
+ /**
199
+ * Create a basic plugin context
200
+ */
201
+ createPluginContext(params) {
202
+ return {
203
+ outputDir: params.outputDir,
204
+ inputDir: params.inputDir,
205
+ config: params.config
206
+ };
207
+ }
208
+ /**
209
+ * Create a generator context with utilities
210
+ */
211
+ createGeneratorContext(params) {
212
+ return {
213
+ ...this.createPluginContext(params),
214
+ resources: params.resources,
215
+ templateDir: params.templateDir,
216
+ coreDir: params.coreDir,
217
+ writeFile: (relativePath, content) => {
218
+ const fullPath = node_path.default.join(params.outputDir, relativePath);
219
+ const dir = node_path.default.dirname(fullPath);
220
+ node_fs.default.mkdirSync(dir, { recursive: true });
221
+ node_fs.default.writeFileSync(fullPath, content);
222
+ this.generatedFiles.add(relativePath);
223
+ console.info(`Generated: ${relativePath}`);
224
+ },
225
+ renderTemplate: (templatePath, data) => {
226
+ const fullTemplatePath = node_path.default.isAbsolute(templatePath) ? templatePath : node_path.default.join(params.templateDir, templatePath);
227
+ return (0, ejs.render)(node_fs.default.readFileSync(fullTemplatePath, "utf8"), data);
228
+ },
229
+ addGeneratedFile: (relativePath) => {
230
+ this.generatedFiles.add(relativePath);
231
+ },
232
+ getGeneratedFiles: () => {
233
+ return Array.from(this.generatedFiles);
234
+ }
235
+ };
236
+ }
237
+ /**
238
+ * Get all generated files
239
+ */
240
+ getGeneratedFiles() {
241
+ return Array.from(this.generatedFiles);
242
+ }
243
+ /**
244
+ * Clear generated files tracking
245
+ */
246
+ clearGeneratedFiles() {
247
+ this.generatedFiles.clear();
248
+ }
206
249
  };
250
+
251
+ //#endregion
252
+ //#region src/helpers/Path.ts
207
253
  var Path = class {
208
- static relative(from, to) {
209
- const relativePath = path3__default.default.relative(from, to);
210
- if (relativePath.includes("node_modules")) {
211
- const parts = relativePath.split(path3__default.default.sep);
212
- const index = parts.indexOf("node_modules");
213
- return parts.slice(index + 1).join(path3__default.default.sep);
214
- }
215
- if (!relativePath.startsWith("./") && !relativePath.startsWith("../")) {
216
- return `./${relativePath}`;
217
- }
218
- return relativePath;
219
- }
254
+ static relative(from, to) {
255
+ const relativePath = node_path.default.relative(from, to);
256
+ if (relativePath.includes("node_modules")) {
257
+ const parts = relativePath.split(node_path.default.sep);
258
+ const index = parts.indexOf("node_modules");
259
+ return parts.slice(index + 1).join("/");
260
+ }
261
+ const posixPath = relativePath.split(node_path.default.sep).join("/");
262
+ if (!posixPath.startsWith("./") && !posixPath.startsWith("../")) return `./${posixPath}`;
263
+ return posixPath;
264
+ }
220
265
  };
221
266
 
267
+ //#endregion
222
268
  exports.BasePlugin = BasePlugin;
223
269
  exports.BaseTemplatePlugin = BaseTemplatePlugin;
224
270
  exports.Path = Path;
225
271
  exports.PluginContextBuilder = PluginContextBuilder;
226
272
  exports.PluginDependencyError = PluginDependencyError;
227
273
  exports.PluginLoadError = PluginLoadError;
228
- exports.PluginRegistry = PluginRegistry;
274
+ exports.PluginRegistry = PluginRegistry;