@11ty/client 4.0.0-alpha.10 → 4.0.0-alpha.11
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/dist/core-fs.js +14008 -8550
- package/dist/core-minimal.js +7655 -5816
- package/dist/formats/liquid.js +626 -867
- package/dist/formats/markdown.js +4120 -4292
- package/dist/formats/nunjucks.js +209 -105
- package/dist/plugins/plugin-i18n.js +170 -14562
- package/package.json +5 -5
package/dist/formats/nunjucks.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Eleventy (Build Awesome) v4.0.0-alpha.
|
|
1
|
+
/*! Eleventy (Build Awesome) v4.0.0-alpha.11 (@11ty/client/njk Engine Bundle) */
|
|
2
2
|
var __create = Object.create;
|
|
3
3
|
var __defProp = Object.defineProperty;
|
|
4
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -1115,18 +1115,30 @@ var require_TemplatePath = __commonJS({
|
|
|
1115
1115
|
TemplatePath2.stripLeadingDotSlash = function(path2) {
|
|
1116
1116
|
return typeof path2 === "string" ? path2.replace(/^\.\//, "") : path2;
|
|
1117
1117
|
};
|
|
1118
|
+
function getSubPathRemainder(filePath, subPath) {
|
|
1119
|
+
if (filePath === subPath) {
|
|
1120
|
+
return "";
|
|
1121
|
+
}
|
|
1122
|
+
if (subPath === ".") {
|
|
1123
|
+
let isOutside = filePath === ".." || filePath.startsWith("../") || path.isAbsolute(filePath);
|
|
1124
|
+
return isOutside ? void 0 : filePath;
|
|
1125
|
+
}
|
|
1126
|
+
let prefix = subPath.endsWith("/") ? subPath : `${subPath}/`;
|
|
1127
|
+
return filePath.startsWith(prefix) ? filePath.slice(prefix.length) : void 0;
|
|
1128
|
+
}
|
|
1129
|
+
__name(getSubPathRemainder, "getSubPathRemainder");
|
|
1118
1130
|
TemplatePath2.startsWithSubPath = function(path2, subPath) {
|
|
1119
1131
|
path2 = TemplatePath2.normalize(path2);
|
|
1120
1132
|
subPath = TemplatePath2.normalize(subPath);
|
|
1121
|
-
return path2
|
|
1133
|
+
return getSubPathRemainder(path2, subPath) !== void 0;
|
|
1122
1134
|
};
|
|
1123
1135
|
TemplatePath2.stripLeadingSubPath = function(path2, subPath) {
|
|
1124
1136
|
path2 = TemplatePath2.normalize(path2);
|
|
1125
1137
|
subPath = TemplatePath2.normalize(subPath);
|
|
1126
|
-
if (subPath
|
|
1127
|
-
return path2
|
|
1138
|
+
if (subPath === ".") {
|
|
1139
|
+
return path2;
|
|
1128
1140
|
}
|
|
1129
|
-
return path2;
|
|
1141
|
+
return getSubPathRemainder(path2, subPath) ?? path2;
|
|
1130
1142
|
};
|
|
1131
1143
|
TemplatePath2.isDirectorySync = function(path2) {
|
|
1132
1144
|
return fs2.existsSync(path2) && fs2.statSync(path2).isDirectory();
|
|
@@ -1188,7 +1200,7 @@ var require_TemplatePath = __commonJS({
|
|
|
1188
1200
|
var require_IsPlainObject = __commonJS({
|
|
1189
1201
|
"../../node_modules/@11ty/eleventy-utils/src/IsPlainObject.js"(exports, module) {
|
|
1190
1202
|
module.exports = function(value) {
|
|
1191
|
-
if (value === null || typeof value !== "object") {
|
|
1203
|
+
if (value === null || typeof value !== "object" || value === Object.prototype) {
|
|
1192
1204
|
return false;
|
|
1193
1205
|
}
|
|
1194
1206
|
let proto = Object.getPrototypeOf(value);
|
|
@@ -1203,6 +1215,7 @@ var require_Merge = __commonJS({
|
|
|
1203
1215
|
"use strict";
|
|
1204
1216
|
var isPlainObject = require_IsPlainObject();
|
|
1205
1217
|
var OVERRIDE_PREFIX = "override:";
|
|
1218
|
+
var UNSAFE_KEY = "__proto__";
|
|
1206
1219
|
function cleanKey(key, prefix) {
|
|
1207
1220
|
if (prefix && key.startsWith(prefix)) {
|
|
1208
1221
|
return key.slice(prefix.length);
|
|
@@ -1212,21 +1225,29 @@ var require_Merge = __commonJS({
|
|
|
1212
1225
|
__name(cleanKey, "cleanKey");
|
|
1213
1226
|
function getMergedItem(target, source, prefixes = {}) {
|
|
1214
1227
|
let { override } = prefixes;
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
sourcePlainObjectShortcut
|
|
1228
|
+
let sourcePlainObjectShortcut = isPlainObject(source);
|
|
1229
|
+
let targetPlainObjectShortcut = false;
|
|
1230
|
+
if (!target) {
|
|
1231
|
+
if (Object.isFrozen(source)) {
|
|
1232
|
+
return source;
|
|
1233
|
+
}
|
|
1234
|
+
if (sourcePlainObjectShortcut) {
|
|
1235
|
+
targetPlainObjectShortcut = true;
|
|
1236
|
+
target = {};
|
|
1237
|
+
}
|
|
1222
1238
|
}
|
|
1223
1239
|
if (Array.isArray(target) && Array.isArray(source)) {
|
|
1224
1240
|
return target.concat(source);
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1241
|
+
}
|
|
1242
|
+
if (targetPlainObjectShortcut || isPlainObject(target)) {
|
|
1243
|
+
if (sourcePlainObjectShortcut) {
|
|
1227
1244
|
for (let key in source) {
|
|
1228
1245
|
let overrideKey = cleanKey(key, override);
|
|
1229
|
-
|
|
1246
|
+
if (overrideKey === UNSAFE_KEY) {
|
|
1247
|
+
continue;
|
|
1248
|
+
}
|
|
1249
|
+
let targetValue = Object.hasOwn(target, key) ? target[key] : void 0;
|
|
1250
|
+
target[overrideKey] = getMergedItem(targetValue, source[key], prefixes);
|
|
1230
1251
|
}
|
|
1231
1252
|
}
|
|
1232
1253
|
return target;
|
|
@@ -1248,7 +1269,10 @@ var require_Merge = __commonJS({
|
|
|
1248
1269
|
if (isPlainObject(target)) {
|
|
1249
1270
|
for (let key in target) {
|
|
1250
1271
|
if (key.indexOf(OVERRIDE_PREFIX) === 0) {
|
|
1251
|
-
|
|
1272
|
+
let cleanedKey = key.slice(OVERRIDE_PREFIX.length);
|
|
1273
|
+
if (cleanedKey !== UNSAFE_KEY) {
|
|
1274
|
+
target[cleanedKey] = target[key];
|
|
1275
|
+
}
|
|
1252
1276
|
delete target[key];
|
|
1253
1277
|
}
|
|
1254
1278
|
}
|
|
@@ -1329,22 +1353,6 @@ var require_Url = __commonJS({
|
|
|
1329
1353
|
}
|
|
1330
1354
|
});
|
|
1331
1355
|
|
|
1332
|
-
// ../../node_modules/@11ty/eleventy-utils/src/Buffer.js
|
|
1333
|
-
var require_Buffer = __commonJS({
|
|
1334
|
-
"../../node_modules/@11ty/eleventy-utils/src/Buffer.js"(exports, module) {
|
|
1335
|
-
function isBuffer(inst) {
|
|
1336
|
-
if (typeof Buffer !== "undefined") {
|
|
1337
|
-
return Buffer.isBuffer(inst);
|
|
1338
|
-
}
|
|
1339
|
-
return inst instanceof Uint8Array;
|
|
1340
|
-
}
|
|
1341
|
-
__name(isBuffer, "isBuffer");
|
|
1342
|
-
module.exports = {
|
|
1343
|
-
isBuffer
|
|
1344
|
-
};
|
|
1345
|
-
}
|
|
1346
|
-
});
|
|
1347
|
-
|
|
1348
1356
|
// ../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js
|
|
1349
1357
|
var require_lib_sha256 = __commonJS({
|
|
1350
1358
|
"../../node_modules/@11ty/eleventy-utils/src/lib-sha256.js"(exports, module) {
|
|
@@ -1521,7 +1529,6 @@ var require_lib_sha256 = __commonJS({
|
|
|
1521
1529
|
var require_HashTypes = __commonJS({
|
|
1522
1530
|
"../../node_modules/@11ty/eleventy-utils/src/HashTypes.js"(exports, module) {
|
|
1523
1531
|
var { base64UrlSafe } = require_Url();
|
|
1524
|
-
var { isBuffer } = require_Buffer();
|
|
1525
1532
|
var sha256 = require_lib_sha256();
|
|
1526
1533
|
function hasNodeCryptoModule() {
|
|
1527
1534
|
try {
|
|
@@ -1585,7 +1592,7 @@ var require_HashTypes = __commonJS({
|
|
|
1585
1592
|
static async toHash(...content) {
|
|
1586
1593
|
let encoder = new TextEncoder();
|
|
1587
1594
|
let input = this.mergeUint8Array(...content.map((c) => {
|
|
1588
|
-
if (
|
|
1595
|
+
if (c instanceof Uint8Array) {
|
|
1589
1596
|
return c;
|
|
1590
1597
|
}
|
|
1591
1598
|
return encoder.encode(c);
|
|
@@ -1688,6 +1695,22 @@ var require_CreateHash = __commonJS({
|
|
|
1688
1695
|
}
|
|
1689
1696
|
});
|
|
1690
1697
|
|
|
1698
|
+
// ../../node_modules/@11ty/eleventy-utils/src/Buffer.js
|
|
1699
|
+
var require_Buffer = __commonJS({
|
|
1700
|
+
"../../node_modules/@11ty/eleventy-utils/src/Buffer.js"(exports, module) {
|
|
1701
|
+
function isBuffer(inst) {
|
|
1702
|
+
if (typeof Buffer !== "undefined") {
|
|
1703
|
+
return Buffer.isBuffer(inst);
|
|
1704
|
+
}
|
|
1705
|
+
return inst instanceof Uint8Array;
|
|
1706
|
+
}
|
|
1707
|
+
__name(isBuffer, "isBuffer");
|
|
1708
|
+
module.exports = {
|
|
1709
|
+
isBuffer
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1712
|
+
});
|
|
1713
|
+
|
|
1691
1714
|
// ../../node_modules/@11ty/eleventy-utils/index.js
|
|
1692
1715
|
var require_eleventy_utils = __commonJS({
|
|
1693
1716
|
"../../node_modules/@11ty/eleventy-utils/index.js"(exports, module) {
|
|
@@ -1745,7 +1768,7 @@ var require_lib = __commonJS({
|
|
|
1745
1768
|
err.Update(path);
|
|
1746
1769
|
if (!withInternals) {
|
|
1747
1770
|
const old = err;
|
|
1748
|
-
err = new Error(old.message);
|
|
1771
|
+
err = old.cause ? new Error(old.message, { cause: old.cause }) : new Error(old.message);
|
|
1749
1772
|
err.name = old.name;
|
|
1750
1773
|
}
|
|
1751
1774
|
return err;
|
|
@@ -4309,11 +4332,11 @@ var require_parser = __commonJS({
|
|
|
4309
4332
|
const nextToken = this.peekToken();
|
|
4310
4333
|
const nextVal = nextToken && nextToken.value;
|
|
4311
4334
|
if (this.dropLeadingWhitespace) {
|
|
4312
|
-
data = data.
|
|
4335
|
+
data = data.trimStart();
|
|
4313
4336
|
this.dropLeadingWhitespace = false;
|
|
4314
4337
|
}
|
|
4315
4338
|
if (nextToken && (nextToken.type === lexer.TOKEN_BLOCK_START && nextVal.charAt(nextVal.length - 1) === "-" || nextToken.type === lexer.TOKEN_VARIABLE_START && nextVal.charAt(this.tokens.tags.VARIABLE_START.length) === "-" || nextToken.type === lexer.TOKEN_COMMENT && nextVal.charAt(this.tokens.tags.COMMENT_START.length) === "-")) {
|
|
4316
|
-
data = data.
|
|
4339
|
+
data = data.trimEnd();
|
|
4317
4340
|
}
|
|
4318
4341
|
buf.push(new nodes.Output(
|
|
4319
4342
|
tok.lineno,
|
|
@@ -7584,15 +7607,16 @@ function matchesTemplate(search, template) {
|
|
|
7584
7607
|
let templateIndex = 0;
|
|
7585
7608
|
let starIndex = -1;
|
|
7586
7609
|
let matchIndex = 0;
|
|
7587
|
-
while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*"))
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7610
|
+
while (searchIndex < search.length) if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === "*")) {
|
|
7611
|
+
if (template[templateIndex] === "*") {
|
|
7612
|
+
starIndex = templateIndex;
|
|
7613
|
+
matchIndex = searchIndex;
|
|
7614
|
+
templateIndex++;
|
|
7615
|
+
} else {
|
|
7616
|
+
searchIndex++;
|
|
7617
|
+
templateIndex++;
|
|
7618
|
+
}
|
|
7619
|
+
} else if (starIndex !== -1) {
|
|
7596
7620
|
templateIndex = starIndex + 1;
|
|
7597
7621
|
matchIndex++;
|
|
7598
7622
|
searchIndex = matchIndex;
|
|
@@ -7612,7 +7636,7 @@ function createDebug(namespace, options) {
|
|
|
7612
7636
|
let enableOverride;
|
|
7613
7637
|
let namespacesCache;
|
|
7614
7638
|
let enabledCache;
|
|
7615
|
-
const debug3 = /* @__PURE__ */ __name((...args) => {
|
|
7639
|
+
const debug3 = /* @__PURE__ */ __name(((...args) => {
|
|
7616
7640
|
if (!debug3.enabled) return;
|
|
7617
7641
|
const curr = Date.now();
|
|
7618
7642
|
const diff = curr - (prevTime || curr);
|
|
@@ -7634,7 +7658,7 @@ function createDebug(namespace, options) {
|
|
|
7634
7658
|
});
|
|
7635
7659
|
options.formatArgs.call(debug3, diff, args);
|
|
7636
7660
|
debug3.log(...args);
|
|
7637
|
-
}, "debug");
|
|
7661
|
+
}), "debug");
|
|
7638
7662
|
debug3.extend = function(namespace2, delimiter = ":") {
|
|
7639
7663
|
return createDebug(this.namespace + delimiter + namespace2, {
|
|
7640
7664
|
useColors: this.useColors,
|
|
@@ -7684,6 +7708,48 @@ function enabled(name) {
|
|
|
7684
7708
|
}
|
|
7685
7709
|
__name(enabled, "enabled");
|
|
7686
7710
|
|
|
7711
|
+
// ../../node_modules/obug/dist/plain.js
|
|
7712
|
+
function formatArgs(diff, args) {
|
|
7713
|
+
args[0] = `${this.namespace} ${args[0]} +${this.humanize(diff)}`;
|
|
7714
|
+
}
|
|
7715
|
+
__name(formatArgs, "formatArgs");
|
|
7716
|
+
var defaultOptions = {
|
|
7717
|
+
useColors: false,
|
|
7718
|
+
color: "",
|
|
7719
|
+
formatArgs,
|
|
7720
|
+
formatters: {
|
|
7721
|
+
/**
|
|
7722
|
+
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
7723
|
+
*/
|
|
7724
|
+
j(v) {
|
|
7725
|
+
try {
|
|
7726
|
+
return JSON.stringify(v);
|
|
7727
|
+
} catch (error) {
|
|
7728
|
+
return `[UnexpectedJSONParseError]: ${error.message}`;
|
|
7729
|
+
}
|
|
7730
|
+
}
|
|
7731
|
+
},
|
|
7732
|
+
inspectOpts: {},
|
|
7733
|
+
humanize,
|
|
7734
|
+
log: console.debug || console.log || (() => {
|
|
7735
|
+
})
|
|
7736
|
+
};
|
|
7737
|
+
function createDebug2(namespace, options) {
|
|
7738
|
+
return createDebug(namespace, Object.assign({}, defaultOptions, options));
|
|
7739
|
+
}
|
|
7740
|
+
__name(createDebug2, "createDebug");
|
|
7741
|
+
function load() {
|
|
7742
|
+
let r;
|
|
7743
|
+
try {
|
|
7744
|
+
r = localStorage.getItem("debug") || localStorage.getItem("DEBUG");
|
|
7745
|
+
} catch (_unused) {
|
|
7746
|
+
}
|
|
7747
|
+
if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
|
|
7748
|
+
return r || "";
|
|
7749
|
+
}
|
|
7750
|
+
__name(load, "load");
|
|
7751
|
+
enable(load());
|
|
7752
|
+
|
|
7687
7753
|
// ../../node_modules/obug/dist/browser.js
|
|
7688
7754
|
var colors = [
|
|
7689
7755
|
"#0000CC",
|
|
@@ -7763,7 +7829,7 @@ var colors = [
|
|
|
7763
7829
|
"#FFCC00",
|
|
7764
7830
|
"#FFCC33"
|
|
7765
7831
|
];
|
|
7766
|
-
function
|
|
7832
|
+
function formatArgs2(diff, args) {
|
|
7767
7833
|
const { useColors } = this;
|
|
7768
7834
|
args[0] = `${(useColors ? "%c" : "") + this.namespace + (useColors ? " %c" : " ") + args[0] + (useColors ? "%c " : " ")}+${this.humanize(diff)}`;
|
|
7769
7835
|
if (!useColors) return;
|
|
@@ -7778,53 +7844,17 @@ function formatArgs(diff, args) {
|
|
|
7778
7844
|
});
|
|
7779
7845
|
args.splice(lastC, 0, c);
|
|
7780
7846
|
}
|
|
7781
|
-
__name(
|
|
7782
|
-
|
|
7783
|
-
});
|
|
7784
|
-
var storage = localstorage();
|
|
7785
|
-
var defaultOptions = {
|
|
7786
|
-
useColors: true,
|
|
7787
|
-
formatArgs,
|
|
7788
|
-
formatters: {
|
|
7789
|
-
/**
|
|
7790
|
-
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
7791
|
-
*/
|
|
7792
|
-
j(v) {
|
|
7793
|
-
try {
|
|
7794
|
-
return JSON.stringify(v);
|
|
7795
|
-
} catch (error) {
|
|
7796
|
-
return `[UnexpectedJSONParseError]: ${error.message}`;
|
|
7797
|
-
}
|
|
7798
|
-
}
|
|
7799
|
-
},
|
|
7800
|
-
inspectOpts: {},
|
|
7801
|
-
humanize,
|
|
7802
|
-
log
|
|
7803
|
-
};
|
|
7804
|
-
function createDebug2(namespace, options) {
|
|
7847
|
+
__name(formatArgs2, "formatArgs");
|
|
7848
|
+
function createDebug3(namespace, options) {
|
|
7805
7849
|
var _ref;
|
|
7806
7850
|
const color = (_ref = options && options.color) !== null && _ref !== void 0 ? _ref : selectColor(colors, namespace);
|
|
7807
|
-
return
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
return localStorage;
|
|
7813
|
-
} catch (_unused) {
|
|
7814
|
-
}
|
|
7815
|
-
}
|
|
7816
|
-
__name(localstorage, "localstorage");
|
|
7817
|
-
function load() {
|
|
7818
|
-
let r;
|
|
7819
|
-
try {
|
|
7820
|
-
r = storage.getItem("debug") || storage.getItem("DEBUG");
|
|
7821
|
-
} catch (_unused2) {
|
|
7822
|
-
}
|
|
7823
|
-
if (!r && typeof process !== "undefined" && "env" in process) r = process.env.DEBUG;
|
|
7824
|
-
return r || "";
|
|
7851
|
+
return createDebug2(namespace, Object.assign({
|
|
7852
|
+
useColors: true,
|
|
7853
|
+
color,
|
|
7854
|
+
formatArgs: formatArgs2
|
|
7855
|
+
}, options));
|
|
7825
7856
|
}
|
|
7826
|
-
__name(
|
|
7827
|
-
enable(load());
|
|
7857
|
+
__name(createDebug3, "createDebug");
|
|
7828
7858
|
|
|
7829
7859
|
// ../../src/Util/IsBuildAwesome.js
|
|
7830
7860
|
function isUsingBuildAwesome() {
|
|
@@ -7834,10 +7864,10 @@ __name(isUsingBuildAwesome, "isUsingBuildAwesome");
|
|
|
7834
7864
|
|
|
7835
7865
|
// ../../src/Util/DebugLogUtil.js
|
|
7836
7866
|
var PREFIX = isUsingBuildAwesome() ? "BuildAwesome:" : "Eleventy:";
|
|
7837
|
-
function
|
|
7838
|
-
return
|
|
7867
|
+
function createDebug4(name) {
|
|
7868
|
+
return createDebug3(`${PREFIX}${name}`);
|
|
7839
7869
|
}
|
|
7840
|
-
__name(
|
|
7870
|
+
__name(createDebug4, "createDebug");
|
|
7841
7871
|
|
|
7842
7872
|
// ../../src/Errors/BaseError.js
|
|
7843
7873
|
var BaseError = class extends Error {
|
|
@@ -7862,6 +7892,14 @@ var BaseError = class extends Error {
|
|
|
7862
7892
|
this.originalError = originalError;
|
|
7863
7893
|
}
|
|
7864
7894
|
}
|
|
7895
|
+
/**
|
|
7896
|
+
* @param {string} filePath - The file that caused the error.
|
|
7897
|
+
* @returns {this}
|
|
7898
|
+
*/
|
|
7899
|
+
setFilePath(filePath) {
|
|
7900
|
+
this.filePath = filePath;
|
|
7901
|
+
return this;
|
|
7902
|
+
}
|
|
7865
7903
|
};
|
|
7866
7904
|
|
|
7867
7905
|
// ../../src/Engines/TemplateEngine.js
|
|
@@ -7870,7 +7908,7 @@ var TemplateEngineConfigError = class extends BaseError {
|
|
|
7870
7908
|
__name(this, "TemplateEngineConfigError");
|
|
7871
7909
|
}
|
|
7872
7910
|
};
|
|
7873
|
-
var debug =
|
|
7911
|
+
var debug = createDebug4("TemplateEngine");
|
|
7874
7912
|
var AMENDED_INSTANCES = /* @__PURE__ */ new Set();
|
|
7875
7913
|
var TemplateEngine = class {
|
|
7876
7914
|
static {
|
|
@@ -7879,6 +7917,7 @@ var TemplateEngine = class {
|
|
|
7879
7917
|
#extensionMap;
|
|
7880
7918
|
#engineManager;
|
|
7881
7919
|
#benchmarks;
|
|
7920
|
+
#configEventListeners = [];
|
|
7882
7921
|
constructor(name, eleventyConfig) {
|
|
7883
7922
|
this.name = name;
|
|
7884
7923
|
this.engineLib = null;
|
|
@@ -7890,6 +7929,18 @@ var TemplateEngine = class {
|
|
|
7890
7929
|
get cacheable() {
|
|
7891
7930
|
return false;
|
|
7892
7931
|
}
|
|
7932
|
+
// Engine instances are replaced on each build, so their listeners must not outlive them
|
|
7933
|
+
addConfigEventListener(eventName, fn) {
|
|
7934
|
+
let events = this.config.events;
|
|
7935
|
+
this.#configEventListeners.push([events, eventName, fn]);
|
|
7936
|
+
events.on(eventName, fn);
|
|
7937
|
+
}
|
|
7938
|
+
removeConfigEventListeners() {
|
|
7939
|
+
for (let [events, eventName, fn] of this.#configEventListeners) {
|
|
7940
|
+
events.off(eventName, fn);
|
|
7941
|
+
}
|
|
7942
|
+
this.#configEventListeners = [];
|
|
7943
|
+
}
|
|
7893
7944
|
get dirs() {
|
|
7894
7945
|
return this.eleventyConfig.directories;
|
|
7895
7946
|
}
|
|
@@ -8005,6 +8056,9 @@ var TemplateEngine = class {
|
|
|
8005
8056
|
needsCompilation(str) {
|
|
8006
8057
|
return true;
|
|
8007
8058
|
}
|
|
8059
|
+
// Runs at compile time for pipeline steps that compile later, during render
|
|
8060
|
+
async ready() {
|
|
8061
|
+
}
|
|
8008
8062
|
/**
|
|
8009
8063
|
* Make sure compile is implemented downstream.
|
|
8010
8064
|
* @abstract
|
|
@@ -8023,13 +8077,21 @@ var TemplateEngine = class {
|
|
|
8023
8077
|
}
|
|
8024
8078
|
return true;
|
|
8025
8079
|
}
|
|
8080
|
+
// e.g. a template’s include, import, extends, or layout file, recorded when it is used
|
|
8081
|
+
// `from` is the engine name for string templates (e.g. the Render plugin’s `renderTemplate`)
|
|
8082
|
+
addDependency(from, to) {
|
|
8083
|
+
if (!from || !to) {
|
|
8084
|
+
return;
|
|
8085
|
+
}
|
|
8086
|
+
this.config.uses.addDependency(from, [to]);
|
|
8087
|
+
}
|
|
8026
8088
|
isFileRelevantTo(inputPath, comparisonFile) {
|
|
8027
8089
|
return this.config.uses.isFileRelevantTo(inputPath, comparisonFile);
|
|
8028
8090
|
}
|
|
8029
8091
|
};
|
|
8030
8092
|
|
|
8031
8093
|
// ../../src/Engines/Util/ContextAugmenter.js
|
|
8032
|
-
var DATA_KEYS = ["page", "eleventy"];
|
|
8094
|
+
var DATA_KEYS = ["page", "eleventy", "buildawesome", "collections"];
|
|
8033
8095
|
function augmentObject(targetObject, options = {}) {
|
|
8034
8096
|
options = Object.assign(
|
|
8035
8097
|
{
|
|
@@ -8076,7 +8138,7 @@ function augmentObject(targetObject, options = {}) {
|
|
|
8076
8138
|
__name(augmentObject, "augmentObject");
|
|
8077
8139
|
|
|
8078
8140
|
// ../../src/Engines/Nunjucks.js
|
|
8079
|
-
var debug2 =
|
|
8141
|
+
var debug2 = createDebug4("Nunjucks");
|
|
8080
8142
|
var BuildAwesomeNunjucksError = class extends BaseError {
|
|
8081
8143
|
static {
|
|
8082
8144
|
__name(this, "BuildAwesomeNunjucksError");
|
|
@@ -8093,10 +8155,20 @@ var Nunjucks = class _Nunjucks extends TemplateEngine {
|
|
|
8093
8155
|
this._usingPrecompiled = Object.keys(this.nunjucksPrecompiledTemplates).length > 0;
|
|
8094
8156
|
this.setLibrary(this.config.libraryOverrides.njk);
|
|
8095
8157
|
}
|
|
8096
|
-
//
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8158
|
+
// Nunjucks’ internal cache only covers loader templates (includes, layouts), not compiled strings
|
|
8159
|
+
get cacheable() {
|
|
8160
|
+
return true;
|
|
8161
|
+
}
|
|
8162
|
+
#recompiledKeys = /* @__PURE__ */ new Set();
|
|
8163
|
+
// A cached template keeps the environment (and included templates) of the build that compiled it
|
|
8164
|
+
getCompileCacheKey(str, inputPath) {
|
|
8165
|
+
let entry = super.getCompileCacheKey(str, inputPath);
|
|
8166
|
+
if (!this.#recompiledKeys.has(entry.key) && this.config.uses.isChangedFileUsedBy(inputPath)) {
|
|
8167
|
+
this.#recompiledKeys.add(entry.key);
|
|
8168
|
+
entry.useCache = false;
|
|
8169
|
+
}
|
|
8170
|
+
return entry;
|
|
8171
|
+
}
|
|
8100
8172
|
#getFileSystemDirs() {
|
|
8101
8173
|
let paths = /* @__PURE__ */ new Set();
|
|
8102
8174
|
paths.add(super.getIncludesDir());
|
|
@@ -8105,6 +8177,11 @@ var Nunjucks = class _Nunjucks extends TemplateEngine {
|
|
|
8105
8177
|
}
|
|
8106
8178
|
#setEnv(override) {
|
|
8107
8179
|
if (override) {
|
|
8180
|
+
if (!(override instanceof import_nunjucks.Environment)) {
|
|
8181
|
+
debug2(
|
|
8182
|
+
"WARNING: the Nunjucks environment passed to `setLibrary` was not created by `@11ty/nunjucks`. Import from `@11ty/nunjucks` instead of `nunjucks` to avoid mixing library versions."
|
|
8183
|
+
);
|
|
8184
|
+
}
|
|
8108
8185
|
this.njkEnv = override;
|
|
8109
8186
|
} else if (this._usingPrecompiled) {
|
|
8110
8187
|
const NodePrecompiledLoader = /* @__PURE__ */ __name(function() {
|
|
@@ -8130,14 +8207,41 @@ var Nunjucks = class _Nunjucks extends TemplateEngine {
|
|
|
8130
8207
|
}
|
|
8131
8208
|
this.njkEnv = new import_nunjucks.Environment(loaders, this.nunjucksEnvironmentOptions);
|
|
8132
8209
|
}
|
|
8210
|
+
this.#trackTemplates();
|
|
8133
8211
|
this.config.events.emit("buildawesome.engine.njk", {
|
|
8134
8212
|
nunjucks: import_nunjucks.default,
|
|
8135
8213
|
environment: this.njkEnv
|
|
8136
8214
|
});
|
|
8137
8215
|
}
|
|
8216
|
+
// Records `include`, `import`, `from`, and `extends` files in the dependency graph for incremental builds
|
|
8217
|
+
#trackTemplates() {
|
|
8218
|
+
let env = this.njkEnv;
|
|
8219
|
+
let getTemplate = env.getTemplate;
|
|
8220
|
+
if (typeof getTemplate !== "function") {
|
|
8221
|
+
return;
|
|
8222
|
+
}
|
|
8223
|
+
let engine = this;
|
|
8224
|
+
env.getTemplate = function(name, ...args) {
|
|
8225
|
+
let parentName = typeof args[1] === "string" ? args[1] : args.length > 1 ? engine.name : void 0;
|
|
8226
|
+
let cbIndex = args.findIndex((arg) => typeof arg === "function");
|
|
8227
|
+
if (parentName && cbIndex > -1) {
|
|
8228
|
+
let cb = args[cbIndex];
|
|
8229
|
+
args[cbIndex] = (error, tmpl) => {
|
|
8230
|
+
engine.addDependency(parentName, tmpl?.path);
|
|
8231
|
+
cb(error, tmpl);
|
|
8232
|
+
};
|
|
8233
|
+
}
|
|
8234
|
+
let result = getTemplate.call(this, name, ...args);
|
|
8235
|
+
if (parentName && cbIndex === -1) {
|
|
8236
|
+
engine.addDependency(parentName, result?.path);
|
|
8237
|
+
}
|
|
8238
|
+
return result;
|
|
8239
|
+
};
|
|
8240
|
+
}
|
|
8138
8241
|
setLibrary(override) {
|
|
8139
8242
|
this.#setEnv(override);
|
|
8140
|
-
this.
|
|
8243
|
+
this.removeConfigEventListeners();
|
|
8244
|
+
this.addConfigEventListener("buildawesome#templatemodified", (templatePath) => {
|
|
8141
8245
|
let absTmplPath = import_eleventy_utils.TemplatePath.normalizeOperatingSystemFilePath(
|
|
8142
8246
|
import_eleventy_utils.TemplatePath.absolutePath(templatePath)
|
|
8143
8247
|
);
|