@smapiot/pilet-template-angular 0.15.0-beta.4440

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/lib/index.js ADDED
@@ -0,0 +1,1385 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
22
+ var __commonJS = (cb, mod) => function __require() {
23
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
24
+ };
25
+ var __export = (target, all) => {
26
+ for (var name in all)
27
+ __defProp(target, name, { get: all[name], enumerable: true });
28
+ };
29
+ var __reExport = (target, module2, copyDefault, desc) => {
30
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
31
+ for (let key of __getOwnPropNames(module2))
32
+ if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
33
+ __defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
34
+ }
35
+ return target;
36
+ };
37
+ var __toESM = (module2, isNodeMode) => {
38
+ return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
39
+ };
40
+ var __toCommonJS = /* @__PURE__ */ ((cache) => {
41
+ return (module2, temp) => {
42
+ return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
43
+ };
44
+ })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
45
+
46
+ // ../../node_modules/ejs/lib/utils.js
47
+ var require_utils = __commonJS({
48
+ "../../node_modules/ejs/lib/utils.js"(exports) {
49
+ "use strict";
50
+ var regExpChars = /[|\\{}()[\]^$+*?.]/g;
51
+ exports.escapeRegExpChars = function(string) {
52
+ if (!string) {
53
+ return "";
54
+ }
55
+ return String(string).replace(regExpChars, "\\$&");
56
+ };
57
+ var _ENCODE_HTML_RULES = {
58
+ "&": "&",
59
+ "<": "&lt;",
60
+ ">": "&gt;",
61
+ '"': "&#34;",
62
+ "'": "&#39;"
63
+ };
64
+ var _MATCH_HTML = /[&<>'"]/g;
65
+ function encode_char(c) {
66
+ return _ENCODE_HTML_RULES[c] || c;
67
+ }
68
+ var escapeFuncStr = `var _ENCODE_HTML_RULES = {
69
+ "&": "&amp;"
70
+ , "<": "&lt;"
71
+ , ">": "&gt;"
72
+ , '"': "&#34;"
73
+ , "'": "&#39;"
74
+ }
75
+ , _MATCH_HTML = /[&<>'"]/g;
76
+ function encode_char(c) {
77
+ return _ENCODE_HTML_RULES[c] || c;
78
+ };
79
+ `;
80
+ exports.escapeXML = function(markup) {
81
+ return markup == void 0 ? "" : String(markup).replace(_MATCH_HTML, encode_char);
82
+ };
83
+ exports.escapeXML.toString = function() {
84
+ return Function.prototype.toString.call(this) + ";\n" + escapeFuncStr;
85
+ };
86
+ exports.shallowCopy = function(to, from) {
87
+ from = from || {};
88
+ for (var p in from) {
89
+ to[p] = from[p];
90
+ }
91
+ return to;
92
+ };
93
+ exports.shallowCopyFromList = function(to, from, list) {
94
+ for (var i = 0; i < list.length; i++) {
95
+ var p = list[i];
96
+ if (typeof from[p] != "undefined") {
97
+ to[p] = from[p];
98
+ }
99
+ }
100
+ return to;
101
+ };
102
+ exports.cache = {
103
+ _data: {},
104
+ set: function(key, val) {
105
+ this._data[key] = val;
106
+ },
107
+ get: function(key) {
108
+ return this._data[key];
109
+ },
110
+ remove: function(key) {
111
+ delete this._data[key];
112
+ },
113
+ reset: function() {
114
+ this._data = {};
115
+ }
116
+ };
117
+ }
118
+ });
119
+
120
+ // ../../node_modules/ejs/package.json
121
+ var require_package = __commonJS({
122
+ "../../node_modules/ejs/package.json"(exports, module2) {
123
+ module2.exports = {
124
+ name: "ejs",
125
+ description: "Embedded JavaScript templates",
126
+ keywords: [
127
+ "template",
128
+ "engine",
129
+ "ejs"
130
+ ],
131
+ version: "2.7.4",
132
+ author: "Matthew Eernisse <mde@fleegix.org> (http://fleegix.org)",
133
+ license: "Apache-2.0",
134
+ main: "./lib/ejs.js",
135
+ repository: {
136
+ type: "git",
137
+ url: "git://github.com/mde/ejs.git"
138
+ },
139
+ bugs: "https://github.com/mde/ejs/issues",
140
+ homepage: "https://github.com/mde/ejs",
141
+ dependencies: {},
142
+ devDependencies: {
143
+ browserify: "^13.1.1",
144
+ eslint: "^4.14.0",
145
+ "git-directory-deploy": "^1.5.1",
146
+ jake: "^10.3.1",
147
+ jsdoc: "^3.4.0",
148
+ "lru-cache": "^4.0.1",
149
+ mocha: "^5.0.5",
150
+ "uglify-js": "^3.3.16"
151
+ },
152
+ engines: {
153
+ node: ">=0.10.0"
154
+ },
155
+ scripts: {
156
+ test: "mocha",
157
+ postinstall: "node ./postinstall.js"
158
+ }
159
+ };
160
+ }
161
+ });
162
+
163
+ // ../../node_modules/ejs/lib/ejs.js
164
+ var require_ejs = __commonJS({
165
+ "../../node_modules/ejs/lib/ejs.js"(exports) {
166
+ "use strict";
167
+ var fs = require("fs");
168
+ var path = require("path");
169
+ var utils = require_utils();
170
+ var scopeOptionWarned = false;
171
+ var _VERSION_STRING = require_package().version;
172
+ var _DEFAULT_OPEN_DELIMITER = "<";
173
+ var _DEFAULT_CLOSE_DELIMITER = ">";
174
+ var _DEFAULT_DELIMITER = "%";
175
+ var _DEFAULT_LOCALS_NAME = "locals";
176
+ var _NAME = "ejs";
177
+ var _REGEX_STRING = "(<%%|%%>|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)";
178
+ var _OPTS_PASSABLE_WITH_DATA = [
179
+ "delimiter",
180
+ "scope",
181
+ "context",
182
+ "debug",
183
+ "compileDebug",
184
+ "client",
185
+ "_with",
186
+ "rmWhitespace",
187
+ "strict",
188
+ "filename",
189
+ "async"
190
+ ];
191
+ var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat("cache");
192
+ var _BOM = /^\uFEFF/;
193
+ exports.cache = utils.cache;
194
+ exports.fileLoader = fs.readFileSync;
195
+ exports.localsName = _DEFAULT_LOCALS_NAME;
196
+ exports.promiseImpl = new Function("return this;")().Promise;
197
+ exports.resolveInclude = function(name, filename, isDir) {
198
+ var dirname = path.dirname;
199
+ var extname = path.extname;
200
+ var resolve2 = path.resolve;
201
+ var includePath = resolve2(isDir ? filename : dirname(filename), name);
202
+ var ext = extname(name);
203
+ if (!ext) {
204
+ includePath += ".ejs";
205
+ }
206
+ return includePath;
207
+ };
208
+ function getIncludePath(path2, options) {
209
+ var includePath;
210
+ var filePath;
211
+ var views = options.views;
212
+ var match = /^[A-Za-z]+:\\|^\//.exec(path2);
213
+ if (match && match.length) {
214
+ includePath = exports.resolveInclude(path2.replace(/^\/*/, ""), options.root || "/", true);
215
+ } else {
216
+ if (options.filename) {
217
+ filePath = exports.resolveInclude(path2, options.filename);
218
+ if (fs.existsSync(filePath)) {
219
+ includePath = filePath;
220
+ }
221
+ }
222
+ if (!includePath) {
223
+ if (Array.isArray(views) && views.some(function(v) {
224
+ filePath = exports.resolveInclude(path2, v, true);
225
+ return fs.existsSync(filePath);
226
+ })) {
227
+ includePath = filePath;
228
+ }
229
+ }
230
+ if (!includePath) {
231
+ throw new Error('Could not find the include file "' + options.escapeFunction(path2) + '"');
232
+ }
233
+ }
234
+ return includePath;
235
+ }
236
+ function handleCache(options, template) {
237
+ var func;
238
+ var filename = options.filename;
239
+ var hasTemplate = arguments.length > 1;
240
+ if (options.cache) {
241
+ if (!filename) {
242
+ throw new Error("cache option requires a filename");
243
+ }
244
+ func = exports.cache.get(filename);
245
+ if (func) {
246
+ return func;
247
+ }
248
+ if (!hasTemplate) {
249
+ template = fileLoader(filename).toString().replace(_BOM, "");
250
+ }
251
+ } else if (!hasTemplate) {
252
+ if (!filename) {
253
+ throw new Error("Internal EJS error: no file name or template provided");
254
+ }
255
+ template = fileLoader(filename).toString().replace(_BOM, "");
256
+ }
257
+ func = exports.compile(template, options);
258
+ if (options.cache) {
259
+ exports.cache.set(filename, func);
260
+ }
261
+ return func;
262
+ }
263
+ function tryHandleCache(options, data, cb) {
264
+ var result;
265
+ if (!cb) {
266
+ if (typeof exports.promiseImpl == "function") {
267
+ return new exports.promiseImpl(function(resolve2, reject) {
268
+ try {
269
+ result = handleCache(options)(data);
270
+ resolve2(result);
271
+ } catch (err) {
272
+ reject(err);
273
+ }
274
+ });
275
+ } else {
276
+ throw new Error("Please provide a callback function");
277
+ }
278
+ } else {
279
+ try {
280
+ result = handleCache(options)(data);
281
+ } catch (err) {
282
+ return cb(err);
283
+ }
284
+ cb(null, result);
285
+ }
286
+ }
287
+ function fileLoader(filePath) {
288
+ return exports.fileLoader(filePath);
289
+ }
290
+ function includeFile(path2, options) {
291
+ var opts = utils.shallowCopy({}, options);
292
+ opts.filename = getIncludePath(path2, opts);
293
+ return handleCache(opts);
294
+ }
295
+ function includeSource(path2, options) {
296
+ var opts = utils.shallowCopy({}, options);
297
+ var includePath;
298
+ var template;
299
+ includePath = getIncludePath(path2, opts);
300
+ template = fileLoader(includePath).toString().replace(_BOM, "");
301
+ opts.filename = includePath;
302
+ var templ = new Template(template, opts);
303
+ templ.generateSource();
304
+ return {
305
+ source: templ.source,
306
+ filename: includePath,
307
+ template
308
+ };
309
+ }
310
+ function rethrow(err, str, flnm, lineno, esc) {
311
+ var lines = str.split("\n");
312
+ var start = Math.max(lineno - 3, 0);
313
+ var end = Math.min(lines.length, lineno + 3);
314
+ var filename = esc(flnm);
315
+ var context = lines.slice(start, end).map(function(line, i) {
316
+ var curr = i + start + 1;
317
+ return (curr == lineno ? " >> " : " ") + curr + "| " + line;
318
+ }).join("\n");
319
+ err.path = filename;
320
+ err.message = (filename || "ejs") + ":" + lineno + "\n" + context + "\n\n" + err.message;
321
+ throw err;
322
+ }
323
+ function stripSemi(str) {
324
+ return str.replace(/;(\s*$)/, "$1");
325
+ }
326
+ exports.compile = function compile(template, opts) {
327
+ var templ;
328
+ if (opts && opts.scope) {
329
+ if (!scopeOptionWarned) {
330
+ console.warn("`scope` option is deprecated and will be removed in EJS 3");
331
+ scopeOptionWarned = true;
332
+ }
333
+ if (!opts.context) {
334
+ opts.context = opts.scope;
335
+ }
336
+ delete opts.scope;
337
+ }
338
+ templ = new Template(template, opts);
339
+ return templ.compile();
340
+ };
341
+ exports.render = function(template, d, o) {
342
+ var data = d || {};
343
+ var opts = o || {};
344
+ if (arguments.length == 2) {
345
+ utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA);
346
+ }
347
+ return handleCache(opts, template)(data);
348
+ };
349
+ exports.renderFile = function() {
350
+ var args = Array.prototype.slice.call(arguments);
351
+ var filename = args.shift();
352
+ var cb;
353
+ var opts = { filename };
354
+ var data;
355
+ var viewOpts;
356
+ if (typeof arguments[arguments.length - 1] == "function") {
357
+ cb = args.pop();
358
+ }
359
+ if (args.length) {
360
+ data = args.shift();
361
+ if (args.length) {
362
+ utils.shallowCopy(opts, args.pop());
363
+ } else {
364
+ if (data.settings) {
365
+ if (data.settings.views) {
366
+ opts.views = data.settings.views;
367
+ }
368
+ if (data.settings["view cache"]) {
369
+ opts.cache = true;
370
+ }
371
+ viewOpts = data.settings["view options"];
372
+ if (viewOpts) {
373
+ utils.shallowCopy(opts, viewOpts);
374
+ }
375
+ }
376
+ utils.shallowCopyFromList(opts, data, _OPTS_PASSABLE_WITH_DATA_EXPRESS);
377
+ }
378
+ opts.filename = filename;
379
+ } else {
380
+ data = {};
381
+ }
382
+ return tryHandleCache(opts, data, cb);
383
+ };
384
+ exports.Template = Template;
385
+ exports.clearCache = function() {
386
+ exports.cache.reset();
387
+ };
388
+ function Template(text, opts) {
389
+ opts = opts || {};
390
+ var options = {};
391
+ this.templateText = text;
392
+ this.mode = null;
393
+ this.truncate = false;
394
+ this.currentLine = 1;
395
+ this.source = "";
396
+ this.dependencies = [];
397
+ options.client = opts.client || false;
398
+ options.escapeFunction = opts.escape || opts.escapeFunction || utils.escapeXML;
399
+ options.compileDebug = opts.compileDebug !== false;
400
+ options.debug = !!opts.debug;
401
+ options.filename = opts.filename;
402
+ options.openDelimiter = opts.openDelimiter || exports.openDelimiter || _DEFAULT_OPEN_DELIMITER;
403
+ options.closeDelimiter = opts.closeDelimiter || exports.closeDelimiter || _DEFAULT_CLOSE_DELIMITER;
404
+ options.delimiter = opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER;
405
+ options.strict = opts.strict || false;
406
+ options.context = opts.context;
407
+ options.cache = opts.cache || false;
408
+ options.rmWhitespace = opts.rmWhitespace;
409
+ options.root = opts.root;
410
+ options.outputFunctionName = opts.outputFunctionName;
411
+ options.localsName = opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME;
412
+ options.views = opts.views;
413
+ options.async = opts.async;
414
+ options.destructuredLocals = opts.destructuredLocals;
415
+ options.legacyInclude = typeof opts.legacyInclude != "undefined" ? !!opts.legacyInclude : true;
416
+ if (options.strict) {
417
+ options._with = false;
418
+ } else {
419
+ options._with = typeof opts._with != "undefined" ? opts._with : true;
420
+ }
421
+ this.opts = options;
422
+ this.regex = this.createRegex();
423
+ }
424
+ Template.modes = {
425
+ EVAL: "eval",
426
+ ESCAPED: "escaped",
427
+ RAW: "raw",
428
+ COMMENT: "comment",
429
+ LITERAL: "literal"
430
+ };
431
+ Template.prototype = {
432
+ createRegex: function() {
433
+ var str = _REGEX_STRING;
434
+ var delim = utils.escapeRegExpChars(this.opts.delimiter);
435
+ var open = utils.escapeRegExpChars(this.opts.openDelimiter);
436
+ var close = utils.escapeRegExpChars(this.opts.closeDelimiter);
437
+ str = str.replace(/%/g, delim).replace(/</g, open).replace(/>/g, close);
438
+ return new RegExp(str);
439
+ },
440
+ compile: function() {
441
+ var src;
442
+ var fn;
443
+ var opts = this.opts;
444
+ var prepended = "";
445
+ var appended = "";
446
+ var escapeFn = opts.escapeFunction;
447
+ var ctor;
448
+ if (!this.source) {
449
+ this.generateSource();
450
+ prepended += ' var __output = "";\n function __append(s) { if (s !== undefined && s !== null) __output += s }\n';
451
+ if (opts.outputFunctionName) {
452
+ prepended += " var " + opts.outputFunctionName + " = __append;\n";
453
+ }
454
+ if (opts.destructuredLocals && opts.destructuredLocals.length) {
455
+ var destructuring = " var __locals = (" + opts.localsName + " || {}),\n";
456
+ for (var i = 0; i < opts.destructuredLocals.length; i++) {
457
+ var name = opts.destructuredLocals[i];
458
+ if (i > 0) {
459
+ destructuring += ",\n ";
460
+ }
461
+ destructuring += name + " = __locals." + name;
462
+ }
463
+ prepended += destructuring + ";\n";
464
+ }
465
+ if (opts._with !== false) {
466
+ prepended += " with (" + opts.localsName + " || {}) {\n";
467
+ appended += " }\n";
468
+ }
469
+ appended += " return __output;\n";
470
+ this.source = prepended + this.source + appended;
471
+ }
472
+ if (opts.compileDebug) {
473
+ src = "var __line = 1\n , __lines = " + JSON.stringify(this.templateText) + "\n , __filename = " + (opts.filename ? JSON.stringify(opts.filename) : "undefined") + ";\ntry {\n" + this.source + "} catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n}\n";
474
+ } else {
475
+ src = this.source;
476
+ }
477
+ if (opts.client) {
478
+ src = "escapeFn = escapeFn || " + escapeFn.toString() + ";\n" + src;
479
+ if (opts.compileDebug) {
480
+ src = "rethrow = rethrow || " + rethrow.toString() + ";\n" + src;
481
+ }
482
+ }
483
+ if (opts.strict) {
484
+ src = '"use strict";\n' + src;
485
+ }
486
+ if (opts.debug) {
487
+ console.log(src);
488
+ }
489
+ if (opts.compileDebug && opts.filename) {
490
+ src = src + "\n//# sourceURL=" + opts.filename + "\n";
491
+ }
492
+ try {
493
+ if (opts.async) {
494
+ try {
495
+ ctor = new Function("return (async function(){}).constructor;")();
496
+ } catch (e) {
497
+ if (e instanceof SyntaxError) {
498
+ throw new Error("This environment does not support async/await");
499
+ } else {
500
+ throw e;
501
+ }
502
+ }
503
+ } else {
504
+ ctor = Function;
505
+ }
506
+ fn = new ctor(opts.localsName + ", escapeFn, include, rethrow", src);
507
+ } catch (e) {
508
+ if (e instanceof SyntaxError) {
509
+ if (opts.filename) {
510
+ e.message += " in " + opts.filename;
511
+ }
512
+ e.message += " while compiling ejs\n\n";
513
+ e.message += "If the above error is not helpful, you may want to try EJS-Lint:\n";
514
+ e.message += "https://github.com/RyanZim/EJS-Lint";
515
+ if (!opts.async) {
516
+ e.message += "\n";
517
+ e.message += "Or, if you meant to create an async function, pass `async: true` as an option.";
518
+ }
519
+ }
520
+ throw e;
521
+ }
522
+ var returnedFn = opts.client ? fn : function anonymous(data) {
523
+ var include = function(path2, includeData) {
524
+ var d = utils.shallowCopy({}, data);
525
+ if (includeData) {
526
+ d = utils.shallowCopy(d, includeData);
527
+ }
528
+ return includeFile(path2, opts)(d);
529
+ };
530
+ return fn.apply(opts.context, [data || {}, escapeFn, include, rethrow]);
531
+ };
532
+ returnedFn.dependencies = this.dependencies;
533
+ if (opts.filename && typeof Object.defineProperty === "function") {
534
+ var filename = opts.filename;
535
+ var basename = path.basename(filename, path.extname(filename));
536
+ try {
537
+ Object.defineProperty(returnedFn, "name", {
538
+ value: basename,
539
+ writable: false,
540
+ enumerable: false,
541
+ configurable: true
542
+ });
543
+ } catch (e) {
544
+ }
545
+ }
546
+ return returnedFn;
547
+ },
548
+ generateSource: function() {
549
+ var opts = this.opts;
550
+ if (opts.rmWhitespace) {
551
+ this.templateText = this.templateText.replace(/[\r\n]+/g, "\n").replace(/^\s+|\s+$/gm, "");
552
+ }
553
+ this.templateText = this.templateText.replace(/[ \t]*<%_/gm, "<%_").replace(/_%>[ \t]*/gm, "_%>");
554
+ var self = this;
555
+ var matches = this.parseTemplateText();
556
+ var d = this.opts.delimiter;
557
+ var o = this.opts.openDelimiter;
558
+ var c = this.opts.closeDelimiter;
559
+ if (matches && matches.length) {
560
+ matches.forEach(function(line, index) {
561
+ var opening;
562
+ var closing;
563
+ var include;
564
+ var includeOpts;
565
+ var includeObj;
566
+ var includeSrc;
567
+ if (line.indexOf(o + d) === 0 && line.indexOf(o + d + d) !== 0) {
568
+ closing = matches[index + 2];
569
+ if (!(closing == d + c || closing == "-" + d + c || closing == "_" + d + c)) {
570
+ throw new Error('Could not find matching close tag for "' + line + '".');
571
+ }
572
+ }
573
+ if (opts.legacyInclude && (include = line.match(/^\s*include\s+(\S+)/))) {
574
+ opening = matches[index - 1];
575
+ if (opening && (opening == o + d || opening == o + d + "-" || opening == o + d + "_")) {
576
+ includeOpts = utils.shallowCopy({}, self.opts);
577
+ includeObj = includeSource(include[1], includeOpts);
578
+ if (self.opts.compileDebug) {
579
+ includeSrc = " ; (function(){\n var __line = 1\n , __lines = " + JSON.stringify(includeObj.template) + "\n , __filename = " + JSON.stringify(includeObj.filename) + ";\n try {\n" + includeObj.source + " } catch (e) {\n rethrow(e, __lines, __filename, __line, escapeFn);\n }\n ; }).call(this)\n";
580
+ } else {
581
+ includeSrc = " ; (function(){\n" + includeObj.source + " ; }).call(this)\n";
582
+ }
583
+ self.source += includeSrc;
584
+ self.dependencies.push(exports.resolveInclude(include[1], includeOpts.filename));
585
+ return;
586
+ }
587
+ }
588
+ self.scanLine(line);
589
+ });
590
+ }
591
+ },
592
+ parseTemplateText: function() {
593
+ var str = this.templateText;
594
+ var pat = this.regex;
595
+ var result = pat.exec(str);
596
+ var arr = [];
597
+ var firstPos;
598
+ while (result) {
599
+ firstPos = result.index;
600
+ if (firstPos !== 0) {
601
+ arr.push(str.substring(0, firstPos));
602
+ str = str.slice(firstPos);
603
+ }
604
+ arr.push(result[0]);
605
+ str = str.slice(result[0].length);
606
+ result = pat.exec(str);
607
+ }
608
+ if (str) {
609
+ arr.push(str);
610
+ }
611
+ return arr;
612
+ },
613
+ _addOutput: function(line) {
614
+ if (this.truncate) {
615
+ line = line.replace(/^(?:\r\n|\r|\n)/, "");
616
+ this.truncate = false;
617
+ }
618
+ if (!line) {
619
+ return line;
620
+ }
621
+ line = line.replace(/\\/g, "\\\\");
622
+ line = line.replace(/\n/g, "\\n");
623
+ line = line.replace(/\r/g, "\\r");
624
+ line = line.replace(/"/g, '\\"');
625
+ this.source += ' ; __append("' + line + '")\n';
626
+ },
627
+ scanLine: function(line) {
628
+ var self = this;
629
+ var d = this.opts.delimiter;
630
+ var o = this.opts.openDelimiter;
631
+ var c = this.opts.closeDelimiter;
632
+ var newLineCount = 0;
633
+ newLineCount = line.split("\n").length - 1;
634
+ switch (line) {
635
+ case o + d:
636
+ case o + d + "_":
637
+ this.mode = Template.modes.EVAL;
638
+ break;
639
+ case o + d + "=":
640
+ this.mode = Template.modes.ESCAPED;
641
+ break;
642
+ case o + d + "-":
643
+ this.mode = Template.modes.RAW;
644
+ break;
645
+ case o + d + "#":
646
+ this.mode = Template.modes.COMMENT;
647
+ break;
648
+ case o + d + d:
649
+ this.mode = Template.modes.LITERAL;
650
+ this.source += ' ; __append("' + line.replace(o + d + d, o + d) + '")\n';
651
+ break;
652
+ case d + d + c:
653
+ this.mode = Template.modes.LITERAL;
654
+ this.source += ' ; __append("' + line.replace(d + d + c, d + c) + '")\n';
655
+ break;
656
+ case d + c:
657
+ case "-" + d + c:
658
+ case "_" + d + c:
659
+ if (this.mode == Template.modes.LITERAL) {
660
+ this._addOutput(line);
661
+ }
662
+ this.mode = null;
663
+ this.truncate = line.indexOf("-") === 0 || line.indexOf("_") === 0;
664
+ break;
665
+ default:
666
+ if (this.mode) {
667
+ switch (this.mode) {
668
+ case Template.modes.EVAL:
669
+ case Template.modes.ESCAPED:
670
+ case Template.modes.RAW:
671
+ if (line.lastIndexOf("//") > line.lastIndexOf("\n")) {
672
+ line += "\n";
673
+ }
674
+ }
675
+ switch (this.mode) {
676
+ case Template.modes.EVAL:
677
+ this.source += " ; " + line + "\n";
678
+ break;
679
+ case Template.modes.ESCAPED:
680
+ this.source += " ; __append(escapeFn(" + stripSemi(line) + "))\n";
681
+ break;
682
+ case Template.modes.RAW:
683
+ this.source += " ; __append(" + stripSemi(line) + ")\n";
684
+ break;
685
+ case Template.modes.COMMENT:
686
+ break;
687
+ case Template.modes.LITERAL:
688
+ this._addOutput(line);
689
+ break;
690
+ }
691
+ } else {
692
+ this._addOutput(line);
693
+ }
694
+ }
695
+ if (self.opts.compileDebug && newLineCount) {
696
+ this.currentLine += newLineCount;
697
+ this.source += " ; __line = " + this.currentLine + "\n";
698
+ }
699
+ }
700
+ };
701
+ exports.escapeXML = utils.escapeXML;
702
+ exports.__express = exports.renderFile;
703
+ if (require.extensions) {
704
+ require.extensions[".ejs"] = function(module3, flnm) {
705
+ console.log("Deprecated: this API will go away in EJS v2.8");
706
+ var filename = flnm || module3.filename;
707
+ var options = {
708
+ filename,
709
+ client: true
710
+ };
711
+ var template = fileLoader(filename).toString();
712
+ var fn = exports.compile(template, options);
713
+ module3._compile("module.exports = " + fn.toString() + ";", filename);
714
+ };
715
+ }
716
+ exports.VERSION = _VERSION_STRING;
717
+ exports.name = _NAME;
718
+ if (typeof window != "undefined") {
719
+ window.ejs = exports;
720
+ }
721
+ }
722
+ });
723
+
724
+ // ../../packages/template-utils/lib/log.js
725
+ var require_log = __commonJS({
726
+ "../../packages/template-utils/lib/log.js"(exports) {
727
+ "use strict";
728
+ Object.defineProperty(exports, "__esModule", { value: true });
729
+ exports.log = exports.setLogLevel = void 0;
730
+ var logLevel = "warn";
731
+ function setLogLevel(level) {
732
+ logLevel = level;
733
+ }
734
+ exports.setLogLevel = setLogLevel;
735
+ function log(level, message) {
736
+ if (level === "error") {
737
+ if (logLevel !== "disabled") {
738
+ console.error(`[template] ${message}`);
739
+ }
740
+ } else if (level === "warn") {
741
+ if (logLevel !== "error" && logLevel !== "disabled") {
742
+ console.warn(`[template] ${message}`);
743
+ }
744
+ } else if (level === "info") {
745
+ if (logLevel === "verbose" || logLevel === "info") {
746
+ console.info(`[template] ${message}`);
747
+ }
748
+ } else if (level === "verbose") {
749
+ if (logLevel === "verbose") {
750
+ console.log(`[template] ${message}`);
751
+ }
752
+ }
753
+ }
754
+ exports.log = log;
755
+ }
756
+ });
757
+
758
+ // ../../packages/template-utils/lib/template.js
759
+ var require_template = __commonJS({
760
+ "../../packages/template-utils/lib/template.js"(exports) {
761
+ "use strict";
762
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
763
+ function adopt(value) {
764
+ return value instanceof P ? value : new P(function(resolve2) {
765
+ resolve2(value);
766
+ });
767
+ }
768
+ return new (P || (P = Promise))(function(resolve2, reject) {
769
+ function fulfilled(value) {
770
+ try {
771
+ step(generator.next(value));
772
+ } catch (e) {
773
+ reject(e);
774
+ }
775
+ }
776
+ function rejected(value) {
777
+ try {
778
+ step(generator["throw"](value));
779
+ } catch (e) {
780
+ reject(e);
781
+ }
782
+ }
783
+ function step(result) {
784
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
785
+ }
786
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
787
+ });
788
+ };
789
+ Object.defineProperty(exports, "__esModule", { value: true });
790
+ exports.getFileFromTemplate = void 0;
791
+ var path_1 = require("path");
792
+ var ejs_1 = require_ejs();
793
+ var log_1 = require_log();
794
+ var findVariable = /<(\w+)>/g;
795
+ function replaceVariables(str, data) {
796
+ let match = findVariable.exec(str);
797
+ while (match) {
798
+ const [m, id] = match;
799
+ const val = data[id];
800
+ if (typeof val === "string") {
801
+ str = str.replace(m, val);
802
+ } else {
803
+ str = str.replace(m, ".");
804
+ }
805
+ findVariable.lastIndex = 0;
806
+ match = findVariable.exec(str);
807
+ }
808
+ return str;
809
+ }
810
+ function fillTemplate(sourceDir, name, data) {
811
+ const path = (0, path_1.resolve)(sourceDir, `${name}.ejs`);
812
+ (0, log_1.log)("verbose", `Filling template of "${path}" ...`);
813
+ return new Promise((resolve2, reject) => {
814
+ (0, ejs_1.renderFile)(path, data, (err, str) => {
815
+ if (err) {
816
+ (0, log_1.log)("error", `Could not fill template at "${path}": ${err}`);
817
+ reject(err);
818
+ } else {
819
+ (0, log_1.log)("verbose", `Filled template at "${path}" ...`);
820
+ resolve2(str);
821
+ }
822
+ });
823
+ });
824
+ }
825
+ function getFileFromTemplate(sourceDir, source, data) {
826
+ return __awaiter(this, void 0, void 0, function* () {
827
+ let { target, name, content } = source;
828
+ const absPath = replaceVariables(target, data);
829
+ const path = (0, path_1.isAbsolute)(absPath) ? (0, path_1.relative)(data.projectRoot, absPath) : absPath;
830
+ if (!content) {
831
+ (0, log_1.log)("verbose", `Return template "${name}" with path "${path}" (from "${target}")`);
832
+ content = yield fillTemplate(sourceDir, name, data);
833
+ } else {
834
+ (0, log_1.log)("verbose", `Return template "${name}" with content at path "${path}" (from "${target}")`);
835
+ }
836
+ return {
837
+ content: Buffer.from(content, "utf8"),
838
+ path
839
+ };
840
+ });
841
+ }
842
+ exports.getFileFromTemplate = getFileFromTemplate;
843
+ }
844
+ });
845
+
846
+ // ../../packages/template-utils/lib/version.js
847
+ var require_version = __commonJS({
848
+ "../../packages/template-utils/lib/version.js"(exports) {
849
+ "use strict";
850
+ Object.defineProperty(exports, "__esModule", { value: true });
851
+ exports.checkVersion = void 0;
852
+ var log_1 = require_log();
853
+ var semver = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i;
854
+ var acceptsAll = ["*", "x", ">=0"];
855
+ var operatorResMap = {
856
+ ">": [1],
857
+ ">=": [0, 1],
858
+ "=": [0],
859
+ "<=": [-1, 0],
860
+ "<": [-1]
861
+ };
862
+ function indexOrEnd(str, q) {
863
+ return str.indexOf(q) === -1 ? str.length : str.indexOf(q);
864
+ }
865
+ function splitVersion(v) {
866
+ var c = v.replace(/^v/, "").replace(/\+.*$/, "");
867
+ var patchIndex = indexOrEnd(c, "-");
868
+ var arr = c.substring(0, patchIndex).split(".");
869
+ arr.push(c.substring(patchIndex + 1));
870
+ return arr;
871
+ }
872
+ function parseSegment(v) {
873
+ var n = parseInt(v, 10);
874
+ return isNaN(n) ? v : n;
875
+ }
876
+ function validateAndParse(v) {
877
+ const match = v.match(semver);
878
+ match.shift();
879
+ return match;
880
+ }
881
+ function compareStrings(a, b) {
882
+ const ap = parseSegment(a);
883
+ const bp = parseSegment(b);
884
+ if (ap > bp) {
885
+ return 1;
886
+ } else if (ap < bp) {
887
+ return -1;
888
+ } else {
889
+ return 0;
890
+ }
891
+ }
892
+ function compareSegments(a, b) {
893
+ for (let i = 0; i < 2; i++) {
894
+ const r = compareStrings(a[i] || "0", b[i] || "0");
895
+ if (r !== 0) {
896
+ return r;
897
+ }
898
+ }
899
+ return 0;
900
+ }
901
+ function compareVersions(v1, v2) {
902
+ const s1 = splitVersion(v1);
903
+ const s2 = splitVersion(v2);
904
+ const len = Math.max(s1.length - 1, s2.length - 1);
905
+ for (let i = 0; i < len; i++) {
906
+ const n1 = parseInt(s1[i] || "0", 10);
907
+ const n2 = parseInt(s2[i] || "0", 10);
908
+ if (n1 > n2) {
909
+ return 1;
910
+ } else if (n2 > n1) {
911
+ return -1;
912
+ }
913
+ }
914
+ const sp1 = s1[s1.length - 1];
915
+ const sp2 = s2[s2.length - 1];
916
+ if (sp1 && sp2) {
917
+ const p1 = sp1.split(".").map(parseSegment);
918
+ const p2 = sp2.split(".").map(parseSegment);
919
+ const len2 = Math.max(p1.length, p2.length);
920
+ for (let i = 0; i < len2; i++) {
921
+ if (p1[i] === void 0 || typeof p2[i] === "string" && typeof p1[i] === "number") {
922
+ return -1;
923
+ } else if (p2[i] === void 0 || typeof p1[i] === "string" && typeof p2[i] === "number") {
924
+ return 1;
925
+ } else if (p1[i] > p2[i]) {
926
+ return 1;
927
+ } else if (p2[i] > p1[i]) {
928
+ return -1;
929
+ }
930
+ }
931
+ } else if (sp1 || sp2) {
932
+ return sp1 ? -1 : 1;
933
+ }
934
+ return 0;
935
+ }
936
+ function compare(v1, v2, operator) {
937
+ const res = compareVersions(v1, v2);
938
+ return operatorResMap[operator].indexOf(res) > -1;
939
+ }
940
+ function satisfies(v, r) {
941
+ if (!acceptsAll.includes(r)) {
942
+ const match = r.match(/^([<>=~^]+)/);
943
+ const op = match ? match[1] : "=";
944
+ if (op !== "^" && op !== "~") {
945
+ return compare(v, r, op);
946
+ }
947
+ const [v1, v2, v3] = validateAndParse(v);
948
+ const [m1, m2, m3] = validateAndParse(r);
949
+ if (compareStrings(v1, m1) !== 0) {
950
+ return false;
951
+ } else if (op === "^") {
952
+ return compareSegments([v2, v3], [m2, m3]) >= 0;
953
+ } else if (compareStrings(v2, m2) !== 0) {
954
+ return false;
955
+ }
956
+ return compareStrings(v3, m3) >= 0;
957
+ }
958
+ return true;
959
+ }
960
+ function checkVersion(desired, actual) {
961
+ if (!satisfies(actual, desired)) {
962
+ (0, log_1.log)("warn", `The template was made for "piral-cli" version "${desired}" but was used with "${actual}".`);
963
+ }
964
+ }
965
+ exports.checkVersion = checkVersion;
966
+ }
967
+ });
968
+
969
+ // ../../packages/template-utils/lib/parent.js
970
+ var require_parent = __commonJS({
971
+ "../../packages/template-utils/lib/parent.js"(exports) {
972
+ "use strict";
973
+ Object.defineProperty(exports, "__esModule", { value: true });
974
+ exports.configure = exports.LogLevels = exports.ForceOverwrite = void 0;
975
+ var path_1 = require("path");
976
+ var log_1 = require_log();
977
+ var version_1 = require_version();
978
+ var ForceOverwrite;
979
+ (function(ForceOverwrite2) {
980
+ ForceOverwrite2[ForceOverwrite2["no"] = 0] = "no";
981
+ ForceOverwrite2[ForceOverwrite2["prompt"] = 1] = "prompt";
982
+ ForceOverwrite2[ForceOverwrite2["yes"] = 2] = "yes";
983
+ })(ForceOverwrite = exports.ForceOverwrite || (exports.ForceOverwrite = {}));
984
+ var LogLevels;
985
+ (function(LogLevels2) {
986
+ LogLevels2[LogLevels2["disabled"] = 0] = "disabled";
987
+ LogLevels2[LogLevels2["error"] = 1] = "error";
988
+ LogLevels2[LogLevels2["warning"] = 2] = "warning";
989
+ LogLevels2[LogLevels2["info"] = 3] = "info";
990
+ LogLevels2[LogLevels2["verbose"] = 4] = "verbose";
991
+ LogLevels2[LogLevels2["debug"] = 5] = "debug";
992
+ })(LogLevels = exports.LogLevels || (exports.LogLevels = {}));
993
+ function configure(root2, details) {
994
+ var _a, _b;
995
+ if (details) {
996
+ const packageJsonPath = (0, path_1.resolve)(root2, "package.json");
997
+ const templateProject = require(packageJsonPath);
998
+ const desiredVersion = (_b = (_a = templateProject.engines) === null || _a === void 0 ? void 0 : _a.piral) !== null && _b !== void 0 ? _b : "*";
999
+ switch (details.logLevel) {
1000
+ case LogLevels.disabled:
1001
+ (0, log_1.setLogLevel)("disabled");
1002
+ break;
1003
+ case LogLevels.error:
1004
+ (0, log_1.setLogLevel)("error");
1005
+ break;
1006
+ case LogLevels.warning:
1007
+ (0, log_1.setLogLevel)("warn");
1008
+ break;
1009
+ case LogLevels.info:
1010
+ (0, log_1.setLogLevel)("info");
1011
+ break;
1012
+ case LogLevels.verbose:
1013
+ case LogLevels.debug:
1014
+ (0, log_1.setLogLevel)("verbose");
1015
+ break;
1016
+ }
1017
+ (0, version_1.checkVersion)(desiredVersion, details.cliVersion);
1018
+ } else {
1019
+ (0, log_1.log)("warn", `The used version of the "piral-cli" is outdated. The templating may still work - if not you should use a more recent version of the "piral-cli".`);
1020
+ }
1021
+ }
1022
+ exports.configure = configure;
1023
+ }
1024
+ });
1025
+
1026
+ // ../../packages/template-utils/lib/utils.js
1027
+ var require_utils2 = __commonJS({
1028
+ "../../packages/template-utils/lib/utils.js"(exports) {
1029
+ "use strict";
1030
+ Object.defineProperty(exports, "__esModule", { value: true });
1031
+ exports.getLanguageExtension = exports.getPlugins = exports.getPiralInstance = exports.getPackageJsonWithSource = void 0;
1032
+ var path_1 = require("path");
1033
+ var fs_1 = require("fs");
1034
+ var log_1 = require_log();
1035
+ function getPackageJsonWithSource(targetDir, fileName) {
1036
+ const path = path_1.posix.join(targetDir, fileName);
1037
+ (0, log_1.log)("verbose", `Adding 'source' to package.json "${path}" ...`);
1038
+ return Promise.resolve({
1039
+ content: Buffer.from(`{"source":${JSON.stringify(path)}}`, "utf8"),
1040
+ path: "package.json"
1041
+ });
1042
+ }
1043
+ exports.getPackageJsonWithSource = getPackageJsonWithSource;
1044
+ function getPiralInstance2(root2, sourceName) {
1045
+ try {
1046
+ const packageJsonPath = require.resolve(`${sourceName}/package.json`, {
1047
+ paths: [root2]
1048
+ });
1049
+ (0, log_1.log)("verbose", `Found package JSON in "${packageJsonPath}"`);
1050
+ const sourcePath = (0, path_1.dirname)(packageJsonPath);
1051
+ const details = require(packageJsonPath);
1052
+ const types = details.types || details.typings;
1053
+ (0, log_1.log)("verbose", `Looking for types in "${types}"`);
1054
+ const typingsPath = types !== void 0 ? (0, path_1.resolve)(sourcePath, types) : void 0;
1055
+ const app = details.app;
1056
+ (0, log_1.log)("verbose", `Looking for types in "${app}"`);
1057
+ const appPath = app !== void 0 ? (0, path_1.resolve)(sourcePath, app) : void 0;
1058
+ return {
1059
+ sourceName,
1060
+ sourcePath,
1061
+ details,
1062
+ appPath,
1063
+ typingsPath
1064
+ };
1065
+ } catch (ex) {
1066
+ (0, log_1.log)("error", `Error when getting Piral instance: ${ex}`);
1067
+ }
1068
+ return void 0;
1069
+ }
1070
+ exports.getPiralInstance = getPiralInstance2;
1071
+ function getPlugins(root2, sourceName) {
1072
+ const plugins = {};
1073
+ (0, log_1.log)("verbose", `Getting the plugins of "${sourceName}/package.json" ...`);
1074
+ const piralInstance = getPiralInstance2(root2, sourceName);
1075
+ const typingsPath = piralInstance === null || piralInstance === void 0 ? void 0 : piralInstance.typingsPath;
1076
+ if (typingsPath) {
1077
+ (0, log_1.log)("verbose", `Reading file in "${typingsPath}"`);
1078
+ const typing = (0, fs_1.readFileSync)(typingsPath, "utf8");
1079
+ const match = /export interface PiletCustomApi extends (.*?) \{/g.exec(typing);
1080
+ const apis = match[1].split(", ");
1081
+ (0, log_1.log)("info", `Found Piral instance plugins "${match[1]}"`);
1082
+ for (const api of apis) {
1083
+ const pluginMatch = /^Pilet(.*)Api$/.exec(api);
1084
+ if (pluginMatch) {
1085
+ const name = pluginMatch[1].toLowerCase();
1086
+ plugins[name] = true;
1087
+ } else {
1088
+ (0, log_1.log)("warn", `Could not find plugin for Pilet API "${api}"`);
1089
+ }
1090
+ }
1091
+ }
1092
+ return plugins;
1093
+ }
1094
+ exports.getPlugins = getPlugins;
1095
+ function getLanguageExtension(language, isJsx = true) {
1096
+ switch (language) {
1097
+ case "js":
1098
+ return isJsx ? ".jsx" : ".js";
1099
+ case "ts":
1100
+ default:
1101
+ return isJsx ? ".tsx" : ".ts";
1102
+ }
1103
+ }
1104
+ exports.getLanguageExtension = getLanguageExtension;
1105
+ }
1106
+ });
1107
+
1108
+ // ../../packages/template-utils/lib/factory.js
1109
+ var require_factory = __commonJS({
1110
+ "../../packages/template-utils/lib/factory.js"(exports) {
1111
+ "use strict";
1112
+ var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
1113
+ function adopt(value) {
1114
+ return value instanceof P ? value : new P(function(resolve2) {
1115
+ resolve2(value);
1116
+ });
1117
+ }
1118
+ return new (P || (P = Promise))(function(resolve2, reject) {
1119
+ function fulfilled(value) {
1120
+ try {
1121
+ step(generator.next(value));
1122
+ } catch (e) {
1123
+ reject(e);
1124
+ }
1125
+ }
1126
+ function rejected(value) {
1127
+ try {
1128
+ step(generator["throw"](value));
1129
+ } catch (e) {
1130
+ reject(e);
1131
+ }
1132
+ }
1133
+ function step(result) {
1134
+ result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
1135
+ }
1136
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
1137
+ });
1138
+ };
1139
+ Object.defineProperty(exports, "__esModule", { value: true });
1140
+ exports.createPiralTemplateFactory = exports.createPiletTemplateFactory = void 0;
1141
+ var path_1 = require("path");
1142
+ var template_1 = require_template();
1143
+ var parent_1 = require_parent();
1144
+ var utils_1 = require_utils2();
1145
+ function createPiletTemplateFactory2(templateRoot, getAllSources, defaultArgs = {}) {
1146
+ const sourceDir = (0, path_1.resolve)(templateRoot, "templates");
1147
+ return (projectRoot, args, details) => {
1148
+ (0, parent_1.configure)(templateRoot, details);
1149
+ const allArgs = Object.assign(Object.assign({}, defaultArgs), args);
1150
+ const { language = "ts", sourceName, src = "<root>/src", plugins = (0, utils_1.getPlugins)(projectRoot, sourceName), mocks = "<src>/mocks" } = allArgs;
1151
+ const allSources = getAllSources(projectRoot, allArgs, details);
1152
+ const sources = allSources.filter((m) => m.languages.includes(language));
1153
+ const data = Object.assign(Object.assign({}, allArgs), {
1154
+ language,
1155
+ plugins,
1156
+ projectRoot,
1157
+ root: ".",
1158
+ sourceName,
1159
+ extension: (0, utils_1.getLanguageExtension)(language),
1160
+ src,
1161
+ mocks
1162
+ });
1163
+ return Promise.all([
1164
+ ...sources.map((source) => (0, template_1.getFileFromTemplate)(sourceDir, source, data)),
1165
+ (0, utils_1.getPackageJsonWithSource)(data.src, `index${data.extension}`)
1166
+ ]);
1167
+ };
1168
+ }
1169
+ exports.createPiletTemplateFactory = createPiletTemplateFactory2;
1170
+ function createPiralTemplateFactory(templateRoot, getAllSources, defaultArgs = {}) {
1171
+ const sourceDir = (0, path_1.resolve)(templateRoot, "templates");
1172
+ return (projectRoot, args, details) => __awaiter(this, void 0, void 0, function* () {
1173
+ (0, parent_1.configure)(templateRoot, details);
1174
+ const allArgs = Object.assign(Object.assign({}, defaultArgs), args);
1175
+ const { language = "ts", packageName = "piral", mocks = "<src>/mocks", src = "<root>/src", title = "My Piral Instance", reactVersion = 17, plugins = [] } = allArgs;
1176
+ const allSources = getAllSources(projectRoot, allArgs, details);
1177
+ const sources = allSources.filter((m) => m.languages.includes(language) && m.frameworks.includes(packageName));
1178
+ const data = Object.assign(Object.assign({}, allArgs), {
1179
+ title,
1180
+ language,
1181
+ plugins,
1182
+ projectRoot,
1183
+ root: ".",
1184
+ reactVersion,
1185
+ packageName,
1186
+ extension: (0, utils_1.getLanguageExtension)(language, packageName !== "piral-base"),
1187
+ src,
1188
+ mocks
1189
+ });
1190
+ return Promise.all(sources.map((source) => (0, template_1.getFileFromTemplate)(sourceDir, source, data)));
1191
+ });
1192
+ }
1193
+ exports.createPiralTemplateFactory = createPiralTemplateFactory;
1194
+ }
1195
+ });
1196
+
1197
+ // ../../packages/template-utils/lib/types.js
1198
+ var require_types = __commonJS({
1199
+ "../../packages/template-utils/lib/types.js"(exports) {
1200
+ "use strict";
1201
+ Object.defineProperty(exports, "__esModule", { value: true });
1202
+ }
1203
+ });
1204
+
1205
+ // ../../packages/template-utils/lib/index.js
1206
+ var require_lib = __commonJS({
1207
+ "../../packages/template-utils/lib/index.js"(exports) {
1208
+ "use strict";
1209
+ var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
1210
+ if (k2 === void 0)
1211
+ k2 = k;
1212
+ Object.defineProperty(o, k2, { enumerable: true, get: function() {
1213
+ return m[k];
1214
+ } });
1215
+ } : function(o, m, k, k2) {
1216
+ if (k2 === void 0)
1217
+ k2 = k;
1218
+ o[k2] = m[k];
1219
+ });
1220
+ var __exportStar = exports && exports.__exportStar || function(m, exports2) {
1221
+ for (var p in m)
1222
+ if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
1223
+ __createBinding(exports2, m, p);
1224
+ };
1225
+ Object.defineProperty(exports, "__esModule", { value: true });
1226
+ __exportStar(require_factory(), exports);
1227
+ __exportStar(require_template(), exports);
1228
+ __exportStar(require_types(), exports);
1229
+ __exportStar(require_utils2(), exports);
1230
+ }
1231
+ });
1232
+
1233
+ // src/index.ts
1234
+ var src_exports = {};
1235
+ __export(src_exports, {
1236
+ default: () => src_default
1237
+ });
1238
+ var import_path = require("path");
1239
+ var import_template_utils = __toESM(require_lib());
1240
+
1241
+ // src/helpers.ts
1242
+ function detectMode(piralInstance) {
1243
+ var _a, _b;
1244
+ const dependencies = ((_a = piralInstance == null ? void 0 : piralInstance.details) == null ? void 0 : _a.dependencies) || {};
1245
+ const devDependencies = ((_b = piralInstance == null ? void 0 : piralInstance.details) == null ? void 0 : _b.devDependencies) || {};
1246
+ const allDependencies = __spreadValues(__spreadValues({}, devDependencies), dependencies);
1247
+ return allDependencies["piral-ng"] === void 0;
1248
+ }
1249
+ function detectNgVersion(piralInstance) {
1250
+ var _a, _b;
1251
+ const dependencies = ((_a = piralInstance == null ? void 0 : piralInstance.details) == null ? void 0 : _a.dependencies) || {};
1252
+ const devDependencies = ((_b = piralInstance == null ? void 0 : piralInstance.details) == null ? void 0 : _b.devDependencies) || {};
1253
+ const allDependencies = __spreadValues(__spreadValues({}, devDependencies), dependencies);
1254
+ const version = allDependencies["@angular/core"] || "14.0.0";
1255
+ if (typeof version === "string") {
1256
+ const result = /\d+/.exec(version);
1257
+ if (result) {
1258
+ return +result[0];
1259
+ }
1260
+ }
1261
+ return 14;
1262
+ }
1263
+ function getStandalonePackageJson(cliVersion, ngVersion) {
1264
+ return {
1265
+ importmap: {
1266
+ imports: {
1267
+ "@angular/animations": ".",
1268
+ "@angular/cli": ".",
1269
+ "@angular/common": ".",
1270
+ "@angular/compiler": ".",
1271
+ "@angular/core": ".",
1272
+ "@angular/forms": ".",
1273
+ "@angular/platform-browser": ".",
1274
+ "@angular/platform-browser-dynamic": ".",
1275
+ "@angular/router": "."
1276
+ }
1277
+ },
1278
+ dependencies: {
1279
+ "@angular/animations": ngVersion,
1280
+ "@angular/cli": ngVersion,
1281
+ "@angular/common": ngVersion,
1282
+ "@angular/compiler": ngVersion,
1283
+ "@angular/core": ngVersion,
1284
+ "@angular/forms": ngVersion,
1285
+ "@angular/platform-browser": ngVersion,
1286
+ "@angular/platform-browser-dynamic": ngVersion,
1287
+ "@angular/router": ngVersion,
1288
+ "piral-ng": cliVersion,
1289
+ rxjs: "~7.4",
1290
+ "zone.js": "~0.11"
1291
+ },
1292
+ devDependencies: {
1293
+ "@angular/compiler-cli": ngVersion,
1294
+ "@ngtools/webpack": ngVersion,
1295
+ "copy-webpack-plugin": "^10",
1296
+ "html-loader": "^3",
1297
+ "to-string-loader": "^1"
1298
+ }
1299
+ };
1300
+ }
1301
+ function getStandardPackageJson(cliVersion, ngVersion) {
1302
+ return {
1303
+ devDependencies: {
1304
+ "@angular/compiler-cli": ngVersion,
1305
+ "@ngtools/webpack": ngVersion,
1306
+ "copy-webpack-plugin": "^10",
1307
+ "html-loader": "^3",
1308
+ "to-string-loader": "^1",
1309
+ "piral-ng": cliVersion
1310
+ }
1311
+ };
1312
+ }
1313
+
1314
+ // src/index.ts
1315
+ var root = (0, import_path.resolve)(__dirname, "..");
1316
+ var src_default = (0, import_template_utils.createPiletTemplateFactory)(root, (projectRoot, args, details) => {
1317
+ const { sourceName } = args;
1318
+ const piralInstance = (0, import_template_utils.getPiralInstance)(projectRoot, sourceName);
1319
+ if (typeof args.standalone === "undefined") {
1320
+ args.standalone = detectMode(piralInstance);
1321
+ }
1322
+ if (typeof args.ngVersion !== "number") {
1323
+ args.ngVersion = detectNgVersion(piralInstance);
1324
+ }
1325
+ const ngVersion = `^${args.ngVersion}`;
1326
+ const packageJson = args.standalone ? getStandalonePackageJson(details.cliVersion, ngVersion) : getStandardPackageJson(details.cliVersion, ngVersion);
1327
+ return [
1328
+ {
1329
+ languages: ["ts", "js"],
1330
+ name: "package.json",
1331
+ content: JSON.stringify(packageJson),
1332
+ target: "<root>/package.json"
1333
+ },
1334
+ {
1335
+ languages: ["ts", "js"],
1336
+ name: "webpack.config.js",
1337
+ target: "<root>/webpack.config.js"
1338
+ },
1339
+ {
1340
+ languages: ["js"],
1341
+ name: "index.jsx",
1342
+ target: "<src>/index.jsx"
1343
+ },
1344
+ {
1345
+ languages: ["ts"],
1346
+ name: "app.module.ts",
1347
+ target: "<src>/app/app.module.ts"
1348
+ },
1349
+ {
1350
+ languages: ["ts"],
1351
+ name: "page.component.html",
1352
+ target: "<src>/app/page.component.html"
1353
+ },
1354
+ {
1355
+ languages: ["ts"],
1356
+ name: "page.component.css",
1357
+ target: "<src>/app/page.component.css"
1358
+ },
1359
+ {
1360
+ languages: ["ts"],
1361
+ name: "page.component.ts",
1362
+ target: "<src>/app/page.component.ts"
1363
+ },
1364
+ {
1365
+ languages: ["ts"],
1366
+ name: "index.tsx",
1367
+ target: "<src>/index.tsx"
1368
+ },
1369
+ {
1370
+ languages: ["ts"],
1371
+ name: "tsconfig.json",
1372
+ target: "<root>/tsconfig.json"
1373
+ }
1374
+ ];
1375
+ });
1376
+ module.exports = __toCommonJS(src_exports);
1377
+ // Annotate the CommonJS export names for ESM import in node:
1378
+ 0 && (module.exports = {});
1379
+ /**
1380
+ * @file Embedded JavaScript templating engine. {@link http://ejs.co}
1381
+ * @author Matthew Eernisse <mde@fleegix.org>
1382
+ * @author Tiancheng "Timothy" Gu <timothygu99@gmail.com>
1383
+ * @project EJS
1384
+ * @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
1385
+ */