@rexeus/typeweaver 0.0.1 → 0.0.3

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.
@@ -12,6 +12,7 @@ import assert2 from 'assert';
12
12
  import v8 from 'v8';
13
13
  import { format, inspect } from 'util';
14
14
  import { PluginRegistry, PluginContextBuilder } from '@rexeus/typeweaver-gen';
15
+ import ejs from 'ejs';
15
16
  import TypesPlugin from '@rexeus/typeweaver-types';
16
17
  import { Command } from 'commander';
17
18
 
@@ -219,7 +220,7 @@ var public_exports$1 = {};
219
220
  __export$1(public_exports$1, {
220
221
  builders: () => builders,
221
222
  printer: () => printer,
222
- utils: () => utils$1
223
+ utils: () => utils
223
224
  });
224
225
  var DOC_TYPE_STRING$1 = "string";
225
226
  var DOC_TYPE_ARRAY$1 = "array";
@@ -1326,7 +1327,7 @@ var builders = {
1326
1327
  concat: (parts) => parts
1327
1328
  };
1328
1329
  var printer = { printDocToString: printDocToString$1 };
1329
- var utils$1 = {
1330
+ var utils = {
1330
1331
  willBreak,
1331
1332
  traverseDoc: traverse_doc_default$1,
1332
1333
  findInDoc,
@@ -1343,7 +1344,7 @@ var doc = /*#__PURE__*/Object.freeze({
1343
1344
  builders: builders,
1344
1345
  default: public_default,
1345
1346
  printer: printer,
1346
- utils: utils$1
1347
+ utils: utils
1347
1348
  });
1348
1349
 
1349
1350
  const require = createRequire(import.meta.url);
@@ -22471,7 +22472,7 @@ var { parsers, printers } = createParsersAndPrinters([
22471
22472
  printers: ["html"]
22472
22473
  },
22473
22474
  {
22474
- importPlugin: () => import('./markdown-BsYj_q7V.js'),
22475
+ importPlugin: () => import('./markdown-Xi16tYTk.js'),
22475
22476
  parsers: ["markdown", "mdx", "remark"],
22476
22477
  printers: ["mdast"]
22477
22478
  },
@@ -22835,718 +22836,6 @@ class Prettier {
22835
22836
  }
22836
22837
  }
22837
22838
 
22838
- function getDefaultExportFromCjs (x) {
22839
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
22840
- }
22841
-
22842
- var ejs$1 = {};
22843
-
22844
- var utils = {};
22845
-
22846
- var hasRequiredUtils;
22847
-
22848
- function requireUtils () {
22849
- if (hasRequiredUtils) return utils;
22850
- hasRequiredUtils = 1;
22851
- (function (exports) {
22852
- var regExpChars = /[|\\{}()[\]^$+*?.]/g;
22853
- var hasOwnProperty = Object.prototype.hasOwnProperty;
22854
- var hasOwn = function(obj, key) {
22855
- return hasOwnProperty.apply(obj, [key]);
22856
- };
22857
- exports.escapeRegExpChars = function(string) {
22858
- if (!string) {
22859
- return "";
22860
- }
22861
- return String(string).replace(regExpChars, "\\$&");
22862
- };
22863
- var _ENCODE_HTML_RULES = {
22864
- "&": "&",
22865
- "<": "&lt;",
22866
- ">": "&gt;",
22867
- '"': "&#34;",
22868
- "'": "&#39;"
22869
- };
22870
- var _MATCH_HTML = /[&<>'"]/g;
22871
- function encode_char(c) {
22872
- return _ENCODE_HTML_RULES[c] || c;
22873
- }
22874
- var escapeFuncStr = `var _ENCODE_HTML_RULES = {
22875
- "&": "&amp;"
22876
- , "<": "&lt;"
22877
- , ">": "&gt;"
22878
- , '"': "&#34;"
22879
- , "'": "&#39;"
22880
- }
22881
- , _MATCH_HTML = /[&<>'"]/g;
22882
- function encode_char(c) {
22883
- return _ENCODE_HTML_RULES[c] || c;
22884
- };
22885
- `;
22886
- exports.escapeXML = function(markup) {
22887
- return markup == void 0 ? "" : String(markup).replace(_MATCH_HTML, encode_char);
22888
- };
22889
- function escapeXMLToString() {
22890
- return Function.prototype.toString.call(this) + ";\n" + escapeFuncStr;
22891
- }
22892
- try {
22893
- if (typeof Object.defineProperty === "function") {
22894
- Object.defineProperty(exports.escapeXML, "toString", { value: escapeXMLToString });
22895
- } else {
22896
- exports.escapeXML.toString = escapeXMLToString;
22897
- }
22898
- } catch (err) {
22899
- console.warn("Unable to set escapeXML.toString (is the Function prototype frozen?)");
22900
- }
22901
- exports.shallowCopy = function(to, from) {
22902
- from = from || {};
22903
- if (to !== null && to !== void 0) {
22904
- for (var p in from) {
22905
- if (!hasOwn(from, p)) {
22906
- continue;
22907
- }
22908
- if (p === "__proto__" || p === "constructor") {
22909
- continue;
22910
- }
22911
- to[p] = from[p];
22912
- }
22913
- }
22914
- return to;
22915
- };
22916
- exports.shallowCopyFromList = function(to, from, list) {
22917
- list = list || [];
22918
- from = from || {};
22919
- if (to !== null && to !== void 0) {
22920
- for (var i = 0; i < list.length; i++) {
22921
- var p = list[i];
22922
- if (typeof from[p] != "undefined") {
22923
- if (!hasOwn(from, p)) {
22924
- continue;
22925
- }
22926
- if (p === "__proto__" || p === "constructor") {
22927
- continue;
22928
- }
22929
- to[p] = from[p];
22930
- }
22931
- }
22932
- }
22933
- return to;
22934
- };
22935
- exports.cache = {
22936
- _data: {},
22937
- set: function(key, val) {
22938
- this._data[key] = val;
22939
- },
22940
- get: function(key) {
22941
- return this._data[key];
22942
- },
22943
- remove: function(key) {
22944
- delete this._data[key];
22945
- },
22946
- reset: function() {
22947
- this._data = {};
22948
- }
22949
- };
22950
- exports.hyphenToCamel = function(str) {
22951
- return str.replace(/-[a-z]/g, function(match) {
22952
- return match[1].toUpperCase();
22953
- });
22954
- };
22955
- exports.createNullProtoObjWherePossible = function() {
22956
- if (typeof Object.create == "function") {
22957
- return function() {
22958
- return /* @__PURE__ */ Object.create(null);
22959
- };
22960
- }
22961
- if (!({ __proto__: null } instanceof Object)) {
22962
- return function() {
22963
- return { __proto__: null };
22964
- };
22965
- }
22966
- return function() {
22967
- return {};
22968
- };
22969
- }();
22970
- exports.hasOwnOnlyObject = function(obj) {
22971
- var o = exports.createNullProtoObjWherePossible();
22972
- for (var p in obj) {
22973
- if (hasOwn(obj, p)) {
22974
- o[p] = obj[p];
22975
- }
22976
- }
22977
- return o;
22978
- };
22979
- } (utils));
22980
- return utils;
22981
- }
22982
-
22983
- var version$1 = "3.1.10";
22984
- var require$$3 = {
22985
- version: version$1};
22986
-
22987
- var hasRequiredEjs;
22988
-
22989
- function requireEjs () {
22990
- if (hasRequiredEjs) return ejs$1;
22991
- hasRequiredEjs = 1;
22992
- (function (exports) {
22993
- /**
22994
- * @file Embedded JavaScript templating engine. {@link http://ejs.co}
22995
- * @author Matthew Eernisse <mde@fleegix.org>
22996
- * @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>
22997
- * @project EJS
22998
- * @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
22999
- */
23000
- var fs$1 = fs;
23001
- var path = path__default;
23002
- var utils = requireUtils();
23003
- var scopeOptionWarned = false;
23004
- var _VERSION_STRING = require$$3.version;
23005
- var _DEFAULT_OPEN_DELIMITER = "<";
23006
- var _DEFAULT_CLOSE_DELIMITER = ">";
23007
- var _DEFAULT_DELIMITER = "%";
23008
- var _DEFAULT_LOCALS_NAME = "locals";
23009
- var _NAME = "ejs";
23010
- var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
23011
- var _OPTS_PASSABLE_WITH_DATA = [
23012
- "delimiter",
23013
- "scope",
23014
- "context",
23015
- "debug",
23016
- "compileDebug",
23017
- "client",
23018
- "_with",
23019
- "rmWhitespace",
23020
- "strict",
23021
- "filename",
23022
- "async"
23023
- ];
23024
- var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
23025
- var _BOM = /^\uFEFF/;
23026
- var _JS_IDENTIFIER = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
23027
- exports.cache = utils.cache;
23028
- exports.fileLoader = fs$1.readFileSync;
23029
- exports.localsName = _DEFAULT_LOCALS_NAME;
23030
- exports.promiseImpl = new Function("return this;")().Promise;
23031
- exports.resolveInclude = function(name, filename, isDir) {
23032
- var dirname = path.dirname;
23033
- var extname = path.extname;
23034
- var resolve = path.resolve;
23035
- var includePath = resolve(isDir ? filename : dirname(filename), name);
23036
- var ext = extname(name);
23037
- if (!ext) {
23038
- includePath += ".ejs";
23039
- }
23040
- return includePath;
23041
- };
23042
- function resolvePaths(name, paths) {
23043
- var filePath;
23044
- if (paths.some(function(v) {
23045
- filePath = exports.resolveInclude(name, v, true);
23046
- return fs$1.existsSync(filePath);
23047
- })) {
23048
- return filePath;
23049
- }
23050
- }
23051
- function getIncludePath(path2, options) {
23052
- var includePath;
23053
- var filePath;
23054
- var views = options.views;
23055
- var match = /^[A-Za-z]+:\\|^\//.exec(path2);
23056
- if (match && match.length) {
23057
- path2 = path2.replace(/^\/*/, "");
23058
- if (Array.isArray(options.root)) {
23059
- includePath = resolvePaths(path2, options.root);
23060
- } else {
23061
- includePath = exports.resolveInclude(path2, options.root || "/", true);
23062
- }
23063
- } else {
23064
- if (options.filename) {
23065
- filePath = exports.resolveInclude(path2, options.filename);
23066
- if (fs$1.existsSync(filePath)) {
23067
- includePath = filePath;
23068
- }
23069
- }
23070
- if (!includePath && Array.isArray(views)) {
23071
- includePath = resolvePaths(path2, views);
23072
- }
23073
- if (!includePath && typeof options.includer !== "function") {
23074
- throw new Error('Could not find the include file "' + options.escapeFunction(path2) + '"');
23075
- }
23076
- }
23077
- return includePath;
23078
- }
23079
- function handleCache(options, template) {
23080
- var func;
23081
- var filename = options.filename;
23082
- var hasTemplate = arguments.length > 1;
23083
- if (options.cache) {
23084
- if (!filename) {
23085
- throw new Error("cache option requires a filename");
23086
- }
23087
- func = exports.cache.get(filename);
23088
- if (func) {
23089
- return func;
23090
- }
23091
- if (!hasTemplate) {
23092
- template = fileLoader(filename).toString().replace(_BOM, "");
23093
- }
23094
- } else if (!hasTemplate) {
23095
- if (!filename) {
23096
- throw new Error("Internal EJS error: no file name or template provided");
23097
- }
23098
- template = fileLoader(filename).toString().replace(_BOM, "");
23099
- }
23100
- func = exports.compile(template, options);
23101
- if (options.cache) {
23102
- exports.cache.set(filename, func);
23103
- }
23104
- return func;
23105
- }
23106
- function tryHandleCache(options, data, cb) {
23107
- var result;
23108
- if (!cb) {
23109
- if (typeof exports.promiseImpl == "function") {
23110
- return new exports.promiseImpl(function(resolve, reject) {
23111
- try {
23112
- result = handleCache(options)(data);
23113
- resolve(result);
23114
- } catch (err) {
23115
- reject(err);
23116
- }
23117
- });
23118
- } else {
23119
- throw new Error("Please provide a callback function");
23120
- }
23121
- } else {
23122
- try {
23123
- result = handleCache(options)(data);
23124
- } catch (err) {
23125
- return cb(err);
23126
- }
23127
- cb(null, result);
23128
- }
23129
- }
23130
- function fileLoader(filePath) {
23131
- return exports.fileLoader(filePath);
23132
- }
23133
- function includeFile(path2, options) {
23134
- var opts = utils.shallowCopy(utils.createNullProtoObjWherePossible(), options);
23135
- opts.filename = getIncludePath(path2, opts);
23136
- if (typeof options.includer === "function") {
23137
- var includerResult = options.includer(path2, opts.filename);
23138
- if (includerResult) {
23139
- if (includerResult.filename) {
23140
- opts.filename = includerResult.filename;
23141
- }
23142
- if (includerResult.template) {
23143
- return handleCache(opts, includerResult.template);
23144
- }
23145
- }
23146
- }
23147
- return handleCache(opts);
23148
- }
23149
- function rethrow(err, str, flnm, lineno, esc) {
23150
- var lines = str.split("\n");
23151
- var start = Math.max(lineno - 3, 0);
23152
- var end = Math.min(lines.length, lineno + 3);
23153
- var filename = esc(flnm);
23154
- var context = lines.slice(start, end).map(function(line, i) {
23155
- var curr = i + start + 1;
23156
- return (curr == lineno ? " >> " : " ") + curr + "| " + line;
23157
- }).join("\n");
23158
- err.path = filename;
23159
- err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
23160
- throw err;
23161
- }
23162
- function stripSemi(str) {
23163
- return str.replace(/;(\s*$)/, "$1");
23164
- }
23165
- exports.compile = function compile(template, opts) {
23166
- var templ;
23167
- if (opts && opts.scope) {
23168
- if (!scopeOptionWarned) {
23169
- console.warn("`scope` option is deprecated and will be removed in EJS 3");
23170
- scopeOptionWarned = true;
23171
- }
23172
- if (!opts.context) {
23173
- opts.context = opts.scope;
23174
- }
23175
- delete opts.scope;
23176
- }
23177
- templ = new Template(template, opts);
23178
- return templ.compile();
23179
- };
23180
- exports.render = function(template, d, o) {
23181
- var data = d || utils.createNullProtoObjWherePossible();
23182
- var opts = o || utils.createNullProtoObjWherePossible();
23183
- if (arguments.length == 2) {
23184
- utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
23185
- }
23186
- return handleCache(opts, template)(data);
23187
- };
23188
- exports.renderFile = function() {
23189
- var args = Array.prototype.slice.call(arguments);
23190
- var filename = args.shift();
23191
- var cb;
23192
- var opts = { filename };
23193
- var data;
23194
- var viewOpts;
23195
- if (typeof arguments[arguments.length - 1] == "function") {
23196
- cb = args.pop();
23197
- }
23198
- if (args.length) {
23199
- data = args.shift();
23200
- if (args.length) {
23201
- utils.shallowCopy(opts, args.pop());
23202
- } else {
23203
- if (data.settings) {
23204
- if (data.settings.views) {
23205
- opts.views = data.settings.views;
23206
- }
23207
- if (data.settings["view cache"]) {
23208
- opts.cache = true;
23209
- }
23210
- viewOpts = data.settings["view options"];
23211
- if (viewOpts) {
23212
- utils.shallowCopy(opts, viewOpts);
23213
- }
23214
- }
23215
- utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
23216
- }
23217
- opts.filename = filename;
23218
- } else {
23219
- data = utils.createNullProtoObjWherePossible();
23220
- }
23221
- return tryHandleCache(opts, data, cb);
23222
- };
23223
- exports.Template = Template;
23224
- exports.clearCache = function() {
23225
- exports.cache.reset();
23226
- };
23227
- function Template(text, optsParam) {
23228
- var opts = utils.hasOwnOnlyObject(optsParam);
23229
- var options = utils.createNullProtoObjWherePossible();
23230
- this.templateText = text;
23231
- this.mode = null;
23232
- this.truncate = false;
23233
- this.currentLine = 1;
23234
- this.source = "";
23235
- options.client = opts.client || false;
23236
- options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
23237
- options.compileDebug = opts.compileDebug !== false;
23238
- options.debug = !!opts.debug;
23239
- options.filename = opts.filename;
23240
- options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
23241
- options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
23242
- options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
23243
- options.strict = opts.strict || false;
23244
- options.context = opts.context;
23245
- options.cache = opts.cache || false;
23246
- options.rmWhitespace = opts.rmWhitespace;
23247
- options.root = opts.root;
23248
- options.includer = opts.includer;
23249
- options.outputFunctionName = opts.outputFunctionName;
23250
- options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
23251
- options.views = opts.views;
23252
- options.async = opts.async;
23253
- options.destructuredLocals = opts.destructuredLocals;
23254
- options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
23255
- if (options.strict) {
23256
- options._with = false;
23257
- } else {
23258
- options._with = typeof opts._with != "undefined" ? opts._with : true;
23259
- }
23260
- this.opts = options;
23261
- this.regex = this.createRegex();
23262
- }
23263
- Template.modes = {
23264
- EVAL: "eval",
23265
- ESCAPED: "escaped",
23266
- RAW: "raw",
23267
- COMMENT: "comment",
23268
- LITERAL: "literal"
23269
- };
23270
- Template.prototype = {
23271
- createRegex: function() {
23272
- var str = _REGEX_STRING;
23273
- var delim = utils.escapeRegExpChars(this.opts.delimiter);
23274
- var open = utils.escapeRegExpChars(this.opts.openDelimiter);
23275
- var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
23276
- str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
23277
- return new RegExp(str);
23278
- },
23279
- compile: function() {
23280
- var src;
23281
- var fn;
23282
- var opts = this.opts;
23283
- var prepended = "";
23284
- var appended = "";
23285
- var escapeFn = opts.escapeFunction;
23286
- var ctor;
23287
- var sanitizedFilename = opts.filename ? JSON.stringify(opts.filename) : "undefined";
23288
- if (!this.source) {
23289
- this.generateSource();
23290
- prepended += ' var __output = "";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
23291
- if (opts.outputFunctionName) {
23292
- if (!_JS_IDENTIFIER.test(opts.outputFunctionName)) {
23293
- throw new Error("outputFunctionName is not a valid JS identifier.");
23294
- }
23295
- prepended += " var " + opts.outputFunctionName + " = __append;\n";
23296
- }
23297
- if (opts.localsName && !_JS_IDENTIFIER.test(opts.localsName)) {
23298
- throw new Error("localsName is not a valid JS identifier.");
23299
- }
23300
- if (opts.destructuredLocals && opts.destructuredLocals.length) {
23301
- var destructuring = " var __locals = (" + opts.localsName + " || {}),\n";
23302
- for (var i = 0; i < opts.destructuredLocals.length; i++) {
23303
- var name = opts.destructuredLocals[i];
23304
- if (!_JS_IDENTIFIER.test(name)) {
23305
- throw new Error("destructuredLocals[" + i + "] is not a valid JS identifier.");
23306
- }
23307
- if (i > 0) {
23308
- destructuring += ",\n ";
23309
- }
23310
- destructuring += name + " = __locals." + name;
23311
- }
23312
- prepended += destructuring + ";\n";
23313
- }
23314
- if (opts._with !== false) {
23315
- prepended += " with (" + opts.localsName + " || {}) {\n";
23316
- appended += " }\n";
23317
- }
23318
- appended += " return __output;\n";
23319
- this.source = prepended + this.source + appended;
23320
- }
23321
- if (opts.compileDebug) {
23322
- src = "var __line = 1\n , __lines = " + JSON.stringify(this.templateText) + "\n , __filename = " + sanitizedFilename + ";\ntry {\n" + this.source + "} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n";
23323
- } else {
23324
- src = this.source;
23325
- }
23326
- if (opts.client) {
23327
- src = "escapeFn = escapeFn || " + escapeFn.toString() + ";\n" + src;
23328
- if (opts.compileDebug) {
23329
- src = "rethrow = rethrow || " + rethrow.toString() + ";\n" + src;
23330
- }
23331
- }
23332
- if (opts.strict) {
23333
- src = '"use strict";\n' + src;
23334
- }
23335
- if (opts.debug) {
23336
- console.log(src);
23337
- }
23338
- if (opts.compileDebug && opts.filename) {
23339
- src = src + "\n//# sourceURL=" + sanitizedFilename + "\n";
23340
- }
23341
- try {
23342
- if (opts.async) {
23343
- try {
23344
- ctor = new Function("return (async function(){}).constructor;")();
23345
- } catch (e) {
23346
- if (e instanceof SyntaxError) {
23347
- throw new Error("This environment does not support async/await");
23348
- } else {
23349
- throw e;
23350
- }
23351
- }
23352
- } else {
23353
- ctor = Function;
23354
- }
23355
- fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
23356
- } catch (e) {
23357
- if (e instanceof SyntaxError) {
23358
- if (opts.filename) {
23359
- e.message += " in " + opts.filename;
23360
- }
23361
- e.message += " while compiling ejs\n\n";
23362
- e.message += "If the above error is not helpful, you may want to try EJS-Lint:\n";
23363
- e.message += "https://github.com/RyanZim/EJS-Lint";
23364
- if (!opts.async) {
23365
- e.message += "\n";
23366
- e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
23367
- }
23368
- }
23369
- throw e;
23370
- }
23371
- var returnedFn = opts.client ? fn : function anonymous(data) {
23372
- var include = function(path2, includeData) {
23373
- var d = utils.shallowCopy(utils.createNullProtoObjWherePossible(), data);
23374
- if (includeData) {
23375
- d = utils.shallowCopy(d, includeData);
23376
- }
23377
- return includeFile(path2, opts)(d);
23378
- };
23379
- return fn.apply(
23380
- opts.context,
23381
- [data || utils.createNullProtoObjWherePossible(), escapeFn, include, rethrow]
23382
- );
23383
- };
23384
- if (opts.filename && typeof Object.defineProperty === "function") {
23385
- var filename = opts.filename;
23386
- var basename = path.basename(filename, path.extname(filename));
23387
- try {
23388
- Object.defineProperty(returnedFn, "name", {
23389
- value: basename,
23390
- writable: false,
23391
- enumerable: false,
23392
- configurable: true
23393
- });
23394
- } catch (e) {
23395
- }
23396
- }
23397
- return returnedFn;
23398
- },
23399
- generateSource: function() {
23400
- var opts = this.opts;
23401
- if (opts.rmWhitespace) {
23402
- this.templateText = this.templateText.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");
23403
- }
23404
- this.templateText = this.templateText.replace(/[ \t]*<%_/gm, "<%_").replace(/_%>[ \t]*/gm, "_%>");
23405
- var self = this;
23406
- var matches = this.parseTemplateText();
23407
- var d = this.opts.delimiter;
23408
- var o = this.opts.openDelimiter;
23409
- var c = this.opts.closeDelimiter;
23410
- if (matches && matches.length) {
23411
- matches.forEach(function(line, index) {
23412
- var closing;
23413
- if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
23414
- closing = matches[index + 2];
23415
- if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) {
23416
- throw new Error('Could not find matching close tag for "' + line + '".');
23417
- }
23418
- }
23419
- self.scanLine(line);
23420
- });
23421
- }
23422
- },
23423
- parseTemplateText: function() {
23424
- var str = this.templateText;
23425
- var pat = this.regex;
23426
- var result = pat.exec(str);
23427
- var arr = [];
23428
- var firstPos;
23429
- while (result) {
23430
- firstPos = result.index;
23431
- if (firstPos !== 0) {
23432
- arr.push(str.substring(0, firstPos));
23433
- str = str.slice(firstPos);
23434
- }
23435
- arr.push(result[0]);
23436
- str = str.slice(result[0].length);
23437
- result = pat.exec(str);
23438
- }
23439
- if (str) {
23440
- arr.push(str);
23441
- }
23442
- return arr;
23443
- },
23444
- _addOutput: function(line) {
23445
- if (this.truncate) {
23446
- line = line.replace(/^(?:\r\n|\r|\n)/, "");
23447
- this.truncate = false;
23448
- }
23449
- if (!line) {
23450
- return line;
23451
- }
23452
- line = line.replace(/\\/g, "\\\\");
23453
- line = line.replace(/\n/g, "\\n");
23454
- line = line.replace(/\r/g, "\\r");
23455
- line = line.replace(/"/g, '\\"');
23456
- this.source += ' ; __append("' + line + '")\n';
23457
- },
23458
- scanLine: function(line) {
23459
- var self = this;
23460
- var d = this.opts.delimiter;
23461
- var o = this.opts.openDelimiter;
23462
- var c = this.opts.closeDelimiter;
23463
- var newLineCount = 0;
23464
- newLineCount = line.split("\n").length - 1;
23465
- switch (line) {
23466
- case o + d:
23467
- case o + d + "_":
23468
- this.mode = Template.modes.EVAL;
23469
- break;
23470
- case o + d + "=":
23471
- this.mode = Template.modes.ESCAPED;
23472
- break;
23473
- case o + d + "-":
23474
- this.mode = Template.modes.RAW;
23475
- break;
23476
- case o + d + "#":
23477
- this.mode = Template.modes.COMMENT;
23478
- break;
23479
- case o + d + d:
23480
- this.mode = Template.modes.LITERAL;
23481
- this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")\n';
23482
- break;
23483
- case d + d + c:
23484
- this.mode = Template.modes.LITERAL;
23485
- this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")\n';
23486
- break;
23487
- case d + c:
23488
- case "-" + d + c:
23489
- case "_" + d + c:
23490
- if (this.mode == Template.modes.LITERAL) {
23491
- this._addOutput(line);
23492
- }
23493
- this.mode = null;
23494
- this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
23495
- break;
23496
- default:
23497
- if (this.mode) {
23498
- switch (this.mode) {
23499
- case Template.modes.EVAL:
23500
- case Template.modes.ESCAPED:
23501
- case Template.modes.RAW:
23502
- if (line.lastIndexOf("//") > line.lastIndexOf("\n")) {
23503
- line += "\n";
23504
- }
23505
- }
23506
- switch (this.mode) {
23507
- // Just executing code
23508
- case Template.modes.EVAL:
23509
- this.source += " ; " + line + "\n";
23510
- break;
23511
- // Exec, esc, and output
23512
- case Template.modes.ESCAPED:
23513
- this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
23514
- break;
23515
- // Exec and output
23516
- case Template.modes.RAW:
23517
- this.source += " ; __append(" + stripSemi(line) + ")\n";
23518
- break;
23519
- case Template.modes.COMMENT:
23520
- break;
23521
- // Literal <%% mode, append as raw output
23522
- case Template.modes.LITERAL:
23523
- this._addOutput(line);
23524
- break;
23525
- }
23526
- } else {
23527
- this._addOutput(line);
23528
- }
23529
- }
23530
- if (self.opts.compileDebug && newLineCount) {
23531
- this.currentLine += newLineCount;
23532
- this.source += " ; __line = " + this.currentLine + "\n";
23533
- }
23534
- }
23535
- };
23536
- exports.escapeXML = utils.escapeXML;
23537
- exports.__express = exports.renderFile;
23538
- exports.VERSION = _VERSION_STRING;
23539
- exports.name = _NAME;
23540
- if (typeof window != "undefined") {
23541
- window.ejs = exports;
23542
- }
23543
- } (ejs$1));
23544
- return ejs$1;
23545
- }
23546
-
23547
- var ejsExports = requireEjs();
23548
- var ejs = /*@__PURE__*/getDefaultExportFromCjs(ejsExports);
23549
-
23550
22839
  class IndexFileGenerator {
23551
22840
  constructor(templateDir) {
23552
22841
  this.templateDir = templateDir;
@@ -23774,7 +23063,7 @@ class Generator {
23774
23063
  }
23775
23064
  }
23776
23065
 
23777
- var version = "0.0.1";
23066
+ var version = "0.0.3";
23778
23067
  var packageJson = {
23779
23068
  version: version};
23780
23069
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import './cli-Ci6HB8FI.js';
1
+ import './cli-CteKWdCY.js';
2
2
  import 'path';
3
3
  import 'fs';
4
4
  import '@rexeus/typeweaver-core';
@@ -12,5 +12,6 @@ import 'assert';
12
12
  import 'v8';
13
13
  import 'util';
14
14
  import '@rexeus/typeweaver-gen';
15
+ import 'ejs';
15
16
  import '@rexeus/typeweaver-types';
16
17
  import 'commander';
@@ -2339,7 +2339,7 @@ function si(e, r, t) {
2339
2339
  }
2340
2340
  si.ignoredProperties = _l;
2341
2341
  var ci = si;
2342
- var li = /(?:[\u{2ea}-\u{2eb}\u{1100}-\u{11ff}\u{2e80}-\u{2e99}\u{2e9b}-\u{2ef3}\u{2f00}-\u{2fd5}\u{2ff0}-\u{303f}\u{3041}-\u{3096}\u{3099}-\u{30ff}\u{3105}-\u{312f}\u{3131}-\u{318e}\u{3190}-\u{4dbf}\u{4e00}-\u{9fff}\u{a700}-\u{a707}\u{a960}-\u{a97c}\u{ac00}-\u{d7a3}\u{d7b0}-\u{d7c6}\u{d7cb}-\u{d7fb}\u{f900}-\u{fa6d}\u{fa70}-\u{fad9}\u{fe10}-\u{fe1f}\u{fe30}-\u{fe6f}\u{ff00}-\u{ffef}\u{16fe3}\u{1aff0}-\u{1aff3}\u{1aff5}-\u{1affb}\u{1affd}-\u{1affe}\u{1b000}-\u{1b122}\u{1b132}\u{1b150}-\u{1b152}\u{1b155}\u{1b164}-\u{1b167}\u{1f200}\u{1f250}-\u{1f251}\u{20000}-\u{2a6df}\u{2a700}-\u{2b739}\u{2b740}-\u{2b81d}\u{2b820}-\u{2cea1}\u{2ceb0}-\u{2ebe0}\u{2f800}-\u{2fa1d}\u{30000}-\u{3134a}\u{31350}-\u{323af}])(?:[\u{fe00}-\u{fe0f}\u{e0100}-\u{e01ef}])?/u, Se = new RegExp("(?:[\\u{21}-\\u{2f}\\u{3a}-\\u{40}\\u{5b}-\\u{60}\\u{7b}-\\u{7e}]|\\p{General_Category=Connector_Punctuation}|\\p{General_Category=Dash_Punctuation}|\\p{General_Category=Close_Punctuation}|\\p{General_Category=Final_Punctuation}|\\p{General_Category=Initial_Punctuation}|\\p{General_Category=Other_Punctuation}|\\p{General_Category=Open_Punctuation})", "u");
2342
+ var li = /(?:[\u{2ea}-\u{2eb}\u{1100}-\u{11ff}\u{2e80}-\u{2e99}\u{2e9b}-\u{2ef3}\u{2f00}-\u{2fd5}\u{2ff0}-\u{303f}\u{3041}-\u{3096}\u{3099}-\u{30ff}\u{3105}-\u{312f}\u{3131}-\u{318e}\u{3190}-\u{4dbf}\u{4e00}-\u{9fff}\u{a700}-\u{a707}\u{a960}-\u{a97c}\u{ac00}-\u{d7a3}\u{d7b0}-\u{d7c6}\u{d7cb}-\u{d7fb}\u{f900}-\u{fa6d}\u{fa70}-\u{fad9}\u{fe10}-\u{fe1f}\u{fe30}-\u{fe6f}\u{ff00}-\u{ffef}\u{16fe3}\u{1aff0}-\u{1aff3}\u{1aff5}-\u{1affb}\u{1affd}-\u{1affe}\u{1b000}-\u{1b122}\u{1b132}\u{1b150}-\u{1b152}\u{1b155}\u{1b164}-\u{1b167}\u{1f200}\u{1f250}-\u{1f251}\u{20000}-\u{2a6df}\u{2a700}-\u{2b739}\u{2b740}-\u{2b81d}\u{2b820}-\u{2cea1}\u{2ceb0}-\u{2ebe0}\u{2f800}-\u{2fa1d}\u{30000}-\u{3134a}\u{31350}-\u{323af}])(?:[\u{fe00}-\u{fe0f}\u{e0100}-\u{e01ef}])?/u, Se = /(?:[\u{21}-\u{2f}\u{3a}-\u{40}\u{5b}-\u{60}\u{7b}-\u{7e}]|\p{General_Category=Connector_Punctuation}|\p{General_Category=Dash_Punctuation}|\p{General_Category=Close_Punctuation}|\p{General_Category=Final_Punctuation}|\p{General_Category=Initial_Punctuation}|\p{General_Category=Other_Punctuation}|\p{General_Category=Open_Punctuation})/u;
2343
2343
  async function Sl(e, r) {
2344
2344
  if (e.language === "yaml") {
2345
2345
  let t = e.value.trim(), n = t ? await r(t, { parser: "yaml" }) : "";
@@ -2369,7 +2369,7 @@ function Oe(e) {
2369
2369
  function Le(e) {
2370
2370
  return e.position.end.offset;
2371
2371
  }
2372
- var vt = /* @__PURE__ */ new Set(["liquidNode", "inlineCode", "emphasis", "esComment", "strong", "delete", "wikiLink", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"]), Lr = /* @__PURE__ */ new Set([...vt, "tableCell", "paragraph", "heading"]), Ge = "non-cjk", ie = "cj-letter", Pe = "k-letter", sr = "cjk-punctuation", Nl = new RegExp("\\p{Script_Extensions=Hangul}", "u");
2372
+ var vt = /* @__PURE__ */ new Set(["liquidNode", "inlineCode", "emphasis", "esComment", "strong", "delete", "wikiLink", "link", "linkReference", "image", "imageReference", "footnote", "footnoteReference", "sentence", "whitespace", "word", "break", "inlineMath"]), Lr = /* @__PURE__ */ new Set([...vt, "tableCell", "paragraph", "heading"]), Ge = "non-cjk", ie = "cj-letter", Pe = "k-letter", sr = "cjk-punctuation", Nl = /\p{Script_Extensions=Hangul}/u;
2373
2373
  function Pr(e) {
2374
2374
  let r = [], t = e.split(/([\t\n ]+)/u);
2375
2375
  for (let [a, u] of t.entries()) {
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import 'tsx';
3
- import './cli-Ci6HB8FI.js';
3
+ import './cli-CteKWdCY.js';
4
4
  import 'path';
5
5
  import 'fs';
6
6
  import '@rexeus/typeweaver-core';
@@ -14,5 +14,6 @@ import 'assert';
14
14
  import 'v8';
15
15
  import 'util';
16
16
  import '@rexeus/typeweaver-gen';
17
+ import 'ejs';
17
18
  import '@rexeus/typeweaver-types';
18
19
  import 'commander';
package/package.json CHANGED
@@ -1,18 +1,24 @@
1
1
  {
2
2
  "name": "@rexeus/typeweaver",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Command-line interface for the TypeWeaver API framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ }
13
+ },
14
+ "bin": {
15
+ "typeweaver": "./dist/run-cli-with-tsx.js"
16
+ },
8
17
  "files": [
9
18
  "dist",
10
19
  "package.json",
11
20
  "README.md"
12
21
  ],
13
- "bin": {
14
- "typeweaver": "dist/run-cli-with-tsx.js"
15
- },
16
22
  "keywords": [
17
23
  "api",
18
24
  "spec",
@@ -37,23 +43,27 @@
37
43
  "axios": "^1.9.0",
38
44
  "case": "^1.6.3",
39
45
  "hono": "^4.6.14",
40
- "@rexeus/typeweaver-core": "0.0.1",
41
- "@rexeus/typeweaver-types": "0.0.1",
42
- "@rexeus/typeweaver-hono": "0.0.1",
43
- "@rexeus/typeweaver-clients": "0.0.1",
44
- "@rexeus/typeweaver-gen": "0.0.1",
45
- "@rexeus/typeweaver-aws-cdk": "0.0.1"
46
+ "@rexeus/typeweaver-core": "^0.0.3",
47
+ "@rexeus/typeweaver-gen": "^0.0.3",
48
+ "@rexeus/typeweaver-types": "^0.0.3",
49
+ "@rexeus/typeweaver-clients": "^0.0.3",
50
+ "@rexeus/typeweaver-aws-cdk": "^0.0.3",
51
+ "@rexeus/typeweaver-hono": "^0.0.3"
46
52
  },
47
53
  "peerDependencies": {
48
- "@rexeus/typeweaver-core": "*",
49
- "@rexeus/typeweaver-gen": "*",
50
- "@rexeus/typeweaver-types": "*",
51
- "@rexeus/typeweaver-clients": "*",
52
- "@rexeus/typeweaver-aws-cdk": "*",
53
- "@rexeus/typeweaver-hono": "*"
54
+ "axios": "^1.9.0",
55
+ "case": "^1.6.3",
56
+ "hono": "^4.6.14",
57
+ "@rexeus/typeweaver-core": "^0.0.3",
58
+ "@rexeus/typeweaver-gen": "^0.0.3",
59
+ "@rexeus/typeweaver-types": "^0.0.3",
60
+ "@rexeus/typeweaver-clients": "^0.0.3",
61
+ "@rexeus/typeweaver-aws-cdk": "^0.0.3",
62
+ "@rexeus/typeweaver-hono": "^0.0.3"
54
63
  },
55
64
  "dependencies": {
56
65
  "commander": "^14.0.0",
66
+ "ejs": "^3.1.10",
57
67
  "tsx": "^4.19.4"
58
68
  },
59
69
  "scripts": {
@@ -63,6 +73,11 @@
63
73
  "build": "pkgroll --clean-dist && cp -r ./src/generators/templates ./dist/templates",
64
74
  "preversion": "npm run build",
65
75
  "test:bundle": "pnpm run build && node dist/run-cli-with-tsx.js generate --output test/output --input test/definition --plugins clients,aws-cdk,hono",
66
- "test:gen": "tsx src/cli.ts generate --output test/output --input test/definition --plugins clients,aws-cdk,hono"
76
+ "test:gen": "pnpm run test:gen:types && pnpm run test:gen:clients && pnpm run test:gen:aws-cdk && pnpm run test:gen:hono && pnpm run test:gen:all",
77
+ "test:gen:types": "tsx src/cli.ts generate --output test/outputs/types --input test/definition",
78
+ "test:gen:clients": "tsx src/cli.ts generate --output test/outputs/clients --input test/definition --plugins clients",
79
+ "test:gen:aws-cdk": "tsx src/cli.ts generate --output test/outputs/aws-cdk --input test/definition --plugins aws-cdk",
80
+ "test:gen:hono": "tsx src/cli.ts generate --output test/outputs/hono --input test/definition --plugins hono",
81
+ "test:gen:all": "tsx src/cli.ts generate --output test/outputs/all --input test/definition --plugins clients,aws-cdk,hono"
67
82
  }
68
83
  }