@rhinostone/swig 2.1.0 → 2.3.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/HISTORY.md +14 -0
- package/ROADMAP.md +11 -0
- package/bin/swig.js +272 -87
- package/dist/swig.js +120 -41
- package/dist/swig.min.js +2 -2
- package/dist/swig.min.js.map +1 -1
- package/lib/filters.js +23 -20
- package/lib/swig.js +13 -2
- package/lib/tags/import.js +42 -21
- package/lib/tags/include.js +4 -0
- package/package.json +3 -4
- package/.changes/unreleased/.gitkeep +0 -0
- package/.changes/v0.1.2.md +0 -6
- package/.changes/v0.1.3.md +0 -6
- package/.changes/v0.1.5.md +0 -11
- package/.changes/v0.1.6.md +0 -6
- package/.changes/v0.1.7.md +0 -7
- package/.changes/v0.1.8.md +0 -7
- package/.changes/v0.1.9.md +0 -7
- package/.changes/v0.10.0.md +0 -11
- package/.changes/v0.11.0.md +0 -15
- package/.changes/v0.11.1.md +0 -6
- package/.changes/v0.11.2.md +0 -6
- package/.changes/v0.12.0.md +0 -7
- package/.changes/v0.12.1.md +0 -11
- package/.changes/v0.13.0.md +0 -8
- package/.changes/v0.13.1.md +0 -8
- package/.changes/v0.13.2.md +0 -9
- package/.changes/v0.13.3.md +0 -5
- package/.changes/v0.13.4.md +0 -5
- package/.changes/v0.13.5.md +0 -4
- package/.changes/v0.14.0.md +0 -6
- package/.changes/v0.2.0.md +0 -7
- package/.changes/v0.2.1.md +0 -6
- package/.changes/v0.2.2.md +0 -6
- package/.changes/v0.2.3.md +0 -10
- package/.changes/v0.3.0.md +0 -6
- package/.changes/v0.4.0.md +0 -11
- package/.changes/v0.5.0.md +0 -11
- package/.changes/v0.6.0.md +0 -12
- package/.changes/v0.6.1.md +0 -6
- package/.changes/v0.7.0.md +0 -7
- package/.changes/v0.8.0.md +0 -18
- package/.changes/v0.9.0.md +0 -13
- package/.changes/v0.9.1.md +0 -6
- package/.changes/v0.9.2.md +0 -6
- package/.changes/v0.9.3.md +0 -6
- package/.changes/v0.9.4.md +0 -10
- package/.changes/v1.0.0-pre1.md +0 -22
- package/.changes/v1.0.0-pre2.md +0 -18
- package/.changes/v1.0.0-pre3.md +0 -7
- package/.changes/v1.0.0-rc1.md +0 -12
- package/.changes/v1.0.0-rc2.md +0 -10
- package/.changes/v1.0.0-rc3.md +0 -7
- package/.changes/v1.0.0.md +0 -7
- package/.changes/v1.1.0.md +0 -6
- package/.changes/v1.2.0.md +0 -10
- package/.changes/v1.2.1.md +0 -4
- package/.changes/v1.2.2.md +0 -4
- package/.changes/v1.3.0.md +0 -14
- package/.changes/v1.3.2.md +0 -6
- package/.changes/v1.4.0.md +0 -13
- package/.changes/v1.4.1.md +0 -5
- package/.changes/v1.4.2.md +0 -10
- package/.changes/v1.4.3.md +0 -4
- package/.changes/v1.4.4.md +0 -6
- package/.changes/v1.4.5.md +0 -10
- package/.changes/v1.4.6.md +0 -6
- package/.changes/v1.4.7.md +0 -8
- package/.changes/v1.5.0.md +0 -4
- package/.changes/v1.6.0.md +0 -4
- package/.changes/v2.0.0-alpha.1.md +0 -4
- package/.changes/v2.0.0-alpha.2.md +0 -4
- package/.changes/v2.0.0-alpha.4.md +0 -10
- package/.changes/v2.0.0-alpha.5.md +0 -16
- package/.changes/v2.0.0-alpha.6.md +0 -4
- package/.changes/v2.0.0-alpha.7.md +0 -4
- package/.changes/v2.0.0-alpha.8.md +0 -4
- package/.changes/v2.0.0.md +0 -6
- package/.changes/v2.0.1.md +0 -8
- package/.changes/v2.1.0.md +0 -8
- package/.playwright-mcp/console-2026-04-22T15-34-20-480Z.log +0 -2
- package/.playwright-mcp/console-2026-04-22T15-35-04-265Z.log +0 -11
- package/.playwright-mcp/console-2026-04-22T15-37-26-953Z.log +0 -1
- package/.playwright-mcp/console-2026-04-22T15-51-15-160Z.log +0 -148
- package/.playwright-mcp/console-2026-04-22T15-51-33-405Z.log +0 -74
- package/.playwright-mcp/console-2026-04-22T15-51-53-922Z.log +0 -74
- package/.playwright-mcp/console-2026-04-22T15-53-10-736Z.log +0 -74
- package/.playwright-mcp/console-2026-04-22T15-53-40-091Z.log +0 -883
- package/.playwright-mcp/console-2026-04-22T16-12-02-541Z.log +0 -74
- package/.playwright-mcp/console-2026-04-22T16-33-44-982Z.log +0 -13973
- package/.playwright-mcp/page-2026-04-22T15-34-24-524Z.yml +0 -1
- package/.playwright-mcp/page-2026-04-22T15-35-04-346Z.yml +0 -0
- package/.playwright-mcp/page-2026-04-22T15-37-27-039Z.yml +0 -5
- package/.playwright-mcp/page-2026-04-22T15-51-15-600Z.yml +0 -76
- package/.playwright-mcp/page-2026-04-22T15-51-33-605Z.yml +0 -0
- package/.playwright-mcp/page-2026-04-22T15-51-54-206Z.yml +0 -676
- package/.playwright-mcp/page-2026-04-22T15-53-11-277Z.yml +0 -632
- package/.playwright-mcp/page-2026-04-22T15-53-40-297Z.yml +0 -0
- package/.playwright-mcp/page-2026-04-22T16-12-02-855Z.yml +0 -0
- package/.playwright-mcp/page-2026-04-22T16-33-45-281Z.yml +0 -0
package/dist/swig.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Swig v2.
|
|
1
|
+
/*! Swig v2.3.0 | https://github.com/gina-io/swig | @license https://github.com/gina-io/swig/blob/master/LICENSE */
|
|
2
2
|
/*! DateZ (c) 2011 Tomo Universalis | @license https://github.com/ocrybit/DateZ/blob/master/LISENCE */
|
|
3
3
|
(() => {
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -844,32 +844,40 @@
|
|
|
844
844
|
exports["default"] = function(input, def) {
|
|
845
845
|
return typeof input !== "undefined" && (input || typeof input === "number") ? input : def;
|
|
846
846
|
};
|
|
847
|
+
function escapeHtmlRest(ch) {
|
|
848
|
+
return ch === "<" ? "<" : ch === ">" ? ">" : ch === '"' ? """ : "'";
|
|
849
|
+
}
|
|
847
850
|
exports.escape = function(input, type) {
|
|
848
|
-
var
|
|
849
|
-
if (
|
|
850
|
-
return
|
|
851
|
+
var t, inp, out, i, code;
|
|
852
|
+
if (input === null || input === void 0) {
|
|
853
|
+
return input;
|
|
851
854
|
}
|
|
852
|
-
|
|
855
|
+
t = typeof input;
|
|
856
|
+
if (t !== "string") {
|
|
857
|
+
if (t === "object") {
|
|
858
|
+
out = iterateFilter.apply(exports.escape, arguments);
|
|
859
|
+
if (out !== void 0) {
|
|
860
|
+
return out;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
853
863
|
return input;
|
|
854
864
|
}
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
out += inp[i];
|
|
867
|
-
}
|
|
865
|
+
if (type === "js") {
|
|
866
|
+
inp = input.replace(/\\/g, "\\u005C");
|
|
867
|
+
out = "";
|
|
868
|
+
for (i = 0; i < inp.length; i += 1) {
|
|
869
|
+
code = inp.charCodeAt(i);
|
|
870
|
+
if (code < 32) {
|
|
871
|
+
code = code.toString(16).toUpperCase();
|
|
872
|
+
code = code.length < 2 ? "0" + code : code;
|
|
873
|
+
out += "\\u00" + code;
|
|
874
|
+
} else {
|
|
875
|
+
out += inp[i];
|
|
868
876
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
return inp.replace(/&(?!amp;|lt;|gt;|quot;|#39;)/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
877
|
+
}
|
|
878
|
+
return out.replace(/&/g, "\\u0026").replace(/</g, "\\u003C").replace(/>/g, "\\u003E").replace(/\'/g, "\\u0027").replace(/"/g, "\\u0022").replace(/\=/g, "\\u003D").replace(/-/g, "\\u002D").replace(/;/g, "\\u003B");
|
|
872
879
|
}
|
|
880
|
+
return input.replace(/&(?!amp;|lt;|gt;|quot;|#39;)/g, "&").replace(/[<>"']/g, escapeHtmlRest);
|
|
873
881
|
};
|
|
874
882
|
exports.e = exports.escape;
|
|
875
883
|
exports.first = function(input) {
|
|
@@ -2993,9 +3001,19 @@
|
|
|
2993
3001
|
var require_import = __commonJS({
|
|
2994
3002
|
"lib/tags/import.js"(exports) {
|
|
2995
3003
|
var utils = require_utils2();
|
|
3004
|
+
var ir = require_ir();
|
|
2996
3005
|
var backend = require_backend();
|
|
2997
3006
|
var _dangerousProps = require_security().dangerousProps;
|
|
2998
|
-
exports.compile = function(compiler, args) {
|
|
3007
|
+
exports.compile = function(compiler, args, content, parents, options) {
|
|
3008
|
+
if (options && options.codegenMode === "async") {
|
|
3009
|
+
var asyncAlias = args[args.length - 1];
|
|
3010
|
+
var asyncPath = args[0].path;
|
|
3011
|
+
return ir.importDeferred(
|
|
3012
|
+
ir.literal("string", asyncPath),
|
|
3013
|
+
asyncAlias,
|
|
3014
|
+
options.filename || ""
|
|
3015
|
+
);
|
|
3016
|
+
}
|
|
2999
3017
|
var ctx = args.pop(), allMacros = utils.map(args, function(arg) {
|
|
3000
3018
|
return arg.name;
|
|
3001
3019
|
}).join("|"), out = "_ctx." + ctx + ' = {};\n var _output = "";\n', replacements = utils.map(args, function(arg) {
|
|
@@ -3014,27 +3032,31 @@
|
|
|
3014
3032
|
return out;
|
|
3015
3033
|
};
|
|
3016
3034
|
exports.parse = function(str, line, parser, types, stack, opts, swig2) {
|
|
3017
|
-
var compiler = require_parser().compile, parseOpts = { resolveFrom: opts.filename }, compileOpts = utils.extend({}, opts, parseOpts),
|
|
3035
|
+
var compiler = require_parser().compile, parseOpts = { resolveFrom: opts.filename }, compileOpts = utils.extend({}, opts, parseOpts), isAsync = !!(opts && opts.codegenMode === "async"), importPath, ctx;
|
|
3018
3036
|
parser.on(types.STRING, function(token) {
|
|
3019
3037
|
var self = this;
|
|
3020
|
-
if (
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
}
|
|
3027
|
-
macroName = token2.args[0];
|
|
3028
|
-
out += backend.compile([token2.compile(compiler, token2.args, token2.content, [], compileOpts)], [], compileOpts) + "\n";
|
|
3029
|
-
self.out.push({ compiled: out, name: macroName });
|
|
3030
|
-
});
|
|
3038
|
+
if (importPath !== void 0) {
|
|
3039
|
+
throw new Error("Unexpected string " + token.match + " on line " + line + ".");
|
|
3040
|
+
}
|
|
3041
|
+
importPath = token.match.replace(/^("|')|("|')$/g, "");
|
|
3042
|
+
if (isAsync) {
|
|
3043
|
+
self.out.push({ path: importPath });
|
|
3031
3044
|
return;
|
|
3032
3045
|
}
|
|
3033
|
-
|
|
3046
|
+
var tokens = swig2.parseFile(importPath, parseOpts).tokens;
|
|
3047
|
+
utils.each(tokens, function(token2) {
|
|
3048
|
+
var out = "", macroName;
|
|
3049
|
+
if (!token2 || token2.name !== "macro" || !token2.compile) {
|
|
3050
|
+
return;
|
|
3051
|
+
}
|
|
3052
|
+
macroName = token2.args[0];
|
|
3053
|
+
out += backend.compile([token2.compile(compiler, token2.args, token2.content, [], compileOpts)], [], compileOpts) + "\n";
|
|
3054
|
+
self.out.push({ compiled: out, name: macroName });
|
|
3055
|
+
});
|
|
3034
3056
|
});
|
|
3035
3057
|
parser.on(types.VAR, function(token) {
|
|
3036
3058
|
var self = this;
|
|
3037
|
-
if (
|
|
3059
|
+
if (importPath === void 0 || ctx) {
|
|
3038
3060
|
throw new Error('Unexpected variable "' + token.match + '" on line ' + line + ".");
|
|
3039
3061
|
}
|
|
3040
3062
|
if (token.match === "as") {
|
|
@@ -3071,6 +3093,9 @@
|
|
|
3071
3093
|
w = void 0;
|
|
3072
3094
|
}
|
|
3073
3095
|
}
|
|
3096
|
+
if (options && options.codegenMode === "async") {
|
|
3097
|
+
return ir.includeDeferred(file, w || void 0, !!onlyCtx, !!ignoreMissing, parentFile);
|
|
3098
|
+
}
|
|
3074
3099
|
return ir.include(file, w || void 0, !!onlyCtx, !!ignoreMissing, parentFile);
|
|
3075
3100
|
};
|
|
3076
3101
|
exports.lowerExpr = function(parser, tokens) {
|
|
@@ -4130,6 +4155,7 @@
|
|
|
4130
4155
|
var require_engine = __commonJS({
|
|
4131
4156
|
"packages/swig-core/lib/engine.js"(exports) {
|
|
4132
4157
|
var utils = require_utils();
|
|
4158
|
+
var ir = require_ir();
|
|
4133
4159
|
var backend = require_backend();
|
|
4134
4160
|
var cache = require_cache();
|
|
4135
4161
|
var AsyncFunction = Object.getPrototypeOf(async function() {
|
|
@@ -4160,6 +4186,45 @@
|
|
|
4160
4186
|
}
|
|
4161
4187
|
});
|
|
4162
4188
|
};
|
|
4189
|
+
function buildExtendsDeferred(tokens, options) {
|
|
4190
|
+
var childBlocks = {};
|
|
4191
|
+
var childIRs = [];
|
|
4192
|
+
utils.each(tokens.blocks, function(blockToken) {
|
|
4193
|
+
var args = blockToken.args ? blockToken.args.slice(0) : [];
|
|
4194
|
+
var content = blockToken.content ? blockToken.content.slice(0) : [];
|
|
4195
|
+
if (blockToken.name === "block") {
|
|
4196
|
+
var blockName = args.join("");
|
|
4197
|
+
var blockIR = blockToken.compile(backend.compile, args, content, [], options, blockName, blockToken);
|
|
4198
|
+
if (blockIR && typeof blockIR === "object" && typeof blockIR.type === "string") {
|
|
4199
|
+
childBlocks[blockName] = blockIR;
|
|
4200
|
+
}
|
|
4201
|
+
return;
|
|
4202
|
+
}
|
|
4203
|
+
var result = blockToken.compile(backend.compile, args, content, [], options, void 0, blockToken);
|
|
4204
|
+
if (result === void 0 || result === null || result === "") {
|
|
4205
|
+
return;
|
|
4206
|
+
}
|
|
4207
|
+
if (typeof result === "string") {
|
|
4208
|
+
childIRs.push(ir.legacyJS(result));
|
|
4209
|
+
return;
|
|
4210
|
+
}
|
|
4211
|
+
if (utils.isArray(result)) {
|
|
4212
|
+
utils.each(result, function(n) {
|
|
4213
|
+
childIRs.push(n);
|
|
4214
|
+
});
|
|
4215
|
+
return;
|
|
4216
|
+
}
|
|
4217
|
+
if (typeof result === "object" && typeof result.type === "string") {
|
|
4218
|
+
childIRs.push(result);
|
|
4219
|
+
}
|
|
4220
|
+
});
|
|
4221
|
+
return ir.extendsDeferred(
|
|
4222
|
+
ir.literal("string", tokens.parent),
|
|
4223
|
+
childBlocks,
|
|
4224
|
+
childIRs,
|
|
4225
|
+
options.filename || ""
|
|
4226
|
+
);
|
|
4227
|
+
}
|
|
4163
4228
|
exports.getParents = function(tokens, options, deps) {
|
|
4164
4229
|
var parentName = tokens.parent, parentFiles = [], parents = [], parentFile, parent, l;
|
|
4165
4230
|
while (parentName) {
|
|
@@ -4267,10 +4332,16 @@
|
|
|
4267
4332
|
return self.parse(src, options);
|
|
4268
4333
|
};
|
|
4269
4334
|
self.precompile = function(source, options) {
|
|
4270
|
-
var tokens = self.parse(source, options), parents
|
|
4271
|
-
if (
|
|
4272
|
-
|
|
4273
|
-
|
|
4335
|
+
var tokens = self.parse(source, options), parents, tpl;
|
|
4336
|
+
if (options && options.codegenMode === "async" && tokens.parent) {
|
|
4337
|
+
parents = [];
|
|
4338
|
+
tokens.tokens = [buildExtendsDeferred(tokens, options)];
|
|
4339
|
+
} else {
|
|
4340
|
+
parents = getParentsInternal(tokens, options);
|
|
4341
|
+
if (parents.length) {
|
|
4342
|
+
tokens.tokens = exports.remapBlocks(tokens.blocks, parents[0].tokens);
|
|
4343
|
+
exports.importNonBlocks(tokens.blocks, tokens.tokens);
|
|
4344
|
+
}
|
|
4274
4345
|
}
|
|
4275
4346
|
try {
|
|
4276
4347
|
tpl = exports.buildTemplateFunction(tokens, parents, options);
|
|
@@ -4394,6 +4465,14 @@
|
|
|
4394
4465
|
};
|
|
4395
4466
|
self.renderFile = function(pathName, locals, cb) {
|
|
4396
4467
|
if (cb) {
|
|
4468
|
+
if (self.options.loader && self.options.loader.async === true) {
|
|
4469
|
+
self.getTemplate(pathName).then(function(fn) {
|
|
4470
|
+
return fn(locals);
|
|
4471
|
+
}).then(function(result) {
|
|
4472
|
+
cb(null, result.output);
|
|
4473
|
+
}).catch(cb);
|
|
4474
|
+
return;
|
|
4475
|
+
}
|
|
4397
4476
|
self.compileFile(pathName, {}, function(err, fn) {
|
|
4398
4477
|
var result;
|
|
4399
4478
|
if (err) {
|
|
@@ -4434,7 +4513,7 @@
|
|
|
4434
4513
|
var loaders = require_loaders2();
|
|
4435
4514
|
var preWalker = require_pre_walker();
|
|
4436
4515
|
var engine = require_engine();
|
|
4437
|
-
exports.version = "2.
|
|
4516
|
+
exports.version = "2.3.0";
|
|
4438
4517
|
var defaultOptions = {
|
|
4439
4518
|
autoescape: true,
|
|
4440
4519
|
varControls: ["{{", "}}"],
|