@11ty/client 4.0.0-alpha.8 → 4.0.0-alpha.9

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.
@@ -1,4 +1,4 @@
1
- /*! Eleventy (Build Awesome) v4.0.0-alpha.8 (@11ty/client/liquid Engine Bundle) */
1
+ /*! Eleventy (Build Awesome) v4.0.0-alpha.9 (@11ty/client/liquid Engine Bundle) */
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -2840,7 +2840,11 @@ var literalValues = {
2840
2840
  "empty": new EmptyDrop(),
2841
2841
  "blank": new BlankDrop()
2842
2842
  };
2843
+ var trieCache = /* @__PURE__ */ new WeakMap();
2843
2844
  function createTrie(input) {
2845
+ const cached = trieCache.get(input);
2846
+ if (cached)
2847
+ return cached;
2844
2848
  const trie = {};
2845
2849
  for (const [name, data] of Object.entries(input)) {
2846
2850
  let node = trie;
@@ -2855,6 +2859,7 @@ function createTrie(input) {
2855
2859
  node.data = data;
2856
2860
  node.end = true;
2857
2861
  }
2862
+ trieCache.set(input, trie);
2858
2863
  return trie;
2859
2864
  }
2860
2865
  __name(createTrie, "createTrie");
@@ -2916,7 +2921,7 @@ function toPromise(val) {
2916
2921
  let next = "next";
2917
2922
  do {
2918
2923
  const state = val[next](value);
2919
- done = state.done;
2924
+ done = !!state.done;
2920
2925
  value = state.value;
2921
2926
  next = "next";
2922
2927
  try {
@@ -2941,7 +2946,7 @@ function toValueSync(val) {
2941
2946
  let next = "next";
2942
2947
  do {
2943
2948
  const state = val[next](value);
2944
- done = state.done;
2949
+ done = !!state.done;
2945
2950
  value = state.value;
2946
2951
  next = "next";
2947
2952
  if (isIterator(value)) {
@@ -3091,7 +3096,7 @@ function format(d, match, memoryLimit) {
3091
3096
  flags[flag] = true;
3092
3097
  let ret = String(convert(d, { flags, width, modifier, memoryLimit }));
3093
3098
  let padChar = padSpaceChars.has(conversion) ? " " : "0";
3094
- let padWidth = width || padWidths[conversion] || 0;
3099
+ let padWidth = Number(width) || padWidths[conversion] || 0;
3095
3100
  if (flags["^"])
3096
3101
  ret = ret.toUpperCase();
3097
3102
  else if (flags["#"])
@@ -3424,8 +3429,7 @@ var OperatorToken = class extends Token {
3424
3429
  this.operator = this.getText();
3425
3430
  }
3426
3431
  getPrecedence() {
3427
- const key = this.getText();
3428
- return key in operatorPrecedences ? operatorPrecedences[key] : 1;
3432
+ return this.operator in operatorPrecedences ? operatorPrecedences[this.operator] : 1;
3429
3433
  }
3430
3434
  };
3431
3435
  var PropertyAccessToken = class extends Token {
@@ -4024,7 +4028,7 @@ function strip_html(v) {
4024
4028
  }
4025
4029
  blocks.delete(opener);
4026
4030
  }
4027
- if (i === lt)
4031
+ if (i <= lt)
4028
4032
  return out + str.slice(lt);
4029
4033
  }
4030
4034
  return out;
@@ -5532,8 +5536,8 @@ function round(v, arg = 0) {
5532
5536
  v = toNumber(v);
5533
5537
  arg = toNumber(arg);
5534
5538
  const amp = Math.pow(10, arg);
5535
- const scaled = v * amp;
5536
- return Math.sign(v) * Math.round(Math.abs(scaled)) / amp;
5539
+ const scaled = v * amp * (1 + Number.EPSILON);
5540
+ return Math.round(scaled) / amp;
5537
5541
  }
5538
5542
  __name(round, "round");
5539
5543
  var mathFilters = /* @__PURE__ */ Object.freeze({
@@ -5668,7 +5672,9 @@ function unshift(v, arg) {
5668
5672
  }
5669
5673
  __name(unshift, "unshift");
5670
5674
  function pop(v) {
5671
- const clone = [...toArray(v)];
5675
+ const array = toArray(v);
5676
+ this.context.memoryLimit.use(array.length);
5677
+ const clone = [...array];
5672
5678
  clone.pop();
5673
5679
  return clone;
5674
5680
  }
@@ -5840,7 +5846,7 @@ function sample(v, count = 1) {
5840
5846
  return [];
5841
5847
  if (!isArray(v))
5842
5848
  v = stringify(v);
5843
- this.context.memoryLimit.use(count);
5849
+ this.context.memoryLimit.use(v.length);
5844
5850
  const shuffled = [...v].sort(() => Math.random() - 0.5);
5845
5851
  if (count === 1)
5846
5852
  return shuffled[0];
@@ -6532,7 +6538,11 @@ var RenderTag = class extends Tag {
6532
6538
  alias = tokenizer.readIdentifier();
6533
6539
  else
6534
6540
  tokenizer.p = beforeAs;
6535
- this[keyword.content] = { value, alias: alias && alias.content };
6541
+ const binding = { value, alias: alias && alias.content };
6542
+ if (keyword.content === "with")
6543
+ this.with = binding;
6544
+ else
6545
+ this.forBinding = binding;
6536
6546
  tokenizer.skipBlank();
6537
6547
  if (tokenizer.peek() === ",")
6538
6548
  tokenizer.advance();
@@ -6547,56 +6557,56 @@ var RenderTag = class extends Tag {
6547
6557
  }
6548
6558
  *render(ctx, emitter) {
6549
6559
  const { liquid, hash } = this;
6550
- const filepath = yield renderFilePath(this["file"], ctx, liquid);
6560
+ const filepath = yield renderFilePath(this.file, ctx, liquid);
6551
6561
  assert(filepath, () => `illegal file path "${filepath}"`);
6552
6562
  const childCtx = ctx.spawn();
6553
6563
  const scope = childCtx.bottom();
6554
6564
  __assign(scope, yield hash.render(ctx));
6555
- if (this["with"]) {
6556
- const { value, alias } = this["with"];
6565
+ if (this.with) {
6566
+ const { value, alias } = this.with;
6557
6567
  scope[alias || filepath] = yield evalToken(value, ctx);
6558
6568
  }
6559
- if (this["for"]) {
6560
- const { value, alias } = this["for"];
6569
+ if (this.forBinding) {
6570
+ const { value, alias } = this.forBinding;
6561
6571
  const collection = toEnumerable(yield evalToken(value, ctx));
6562
6572
  scope["forloop"] = new ForloopDrop(collection.length, value.getText(), alias);
6563
6573
  for (const item of collection) {
6564
6574
  scope[alias] = item;
6565
- const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this["currentFile"]);
6575
+ const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
6566
6576
  yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
6567
6577
  scope["forloop"].next();
6568
6578
  }
6569
6579
  } else {
6570
- const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this["currentFile"]);
6580
+ const templates = yield liquid._parsePartialFile(filepath, childCtx.sync, this.currentFile);
6571
6581
  yield liquid.renderer.renderTemplates(templates, childCtx, emitter);
6572
6582
  }
6573
6583
  }
6574
6584
  *children(partials, sync) {
6575
- if (partials && isString(this["file"])) {
6576
- return yield this.liquid._parsePartialFile(this["file"], sync, this["currentFile"]);
6585
+ if (partials && isString(this.file)) {
6586
+ return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
6577
6587
  }
6578
6588
  return [];
6579
6589
  }
6580
6590
  partialScope() {
6581
- if (isString(this["file"])) {
6591
+ if (isString(this.file)) {
6582
6592
  const names2 = Object.keys(this.hash.hash);
6583
- if (this["with"]) {
6584
- const { value, alias } = this["with"];
6593
+ if (this.with) {
6594
+ const { value, alias } = this.with;
6585
6595
  if (isString(alias)) {
6586
6596
  names2.push([alias, value]);
6587
6597
  } else if (isString(this.file)) {
6588
6598
  names2.push([this.file, value]);
6589
6599
  }
6590
6600
  }
6591
- if (this["for"]) {
6592
- const { value, alias } = this["for"];
6601
+ if (this.forBinding) {
6602
+ const { value, alias } = this.forBinding;
6593
6603
  if (isString(alias)) {
6594
6604
  names2.push([alias, value]);
6595
6605
  } else if (isString(this.file)) {
6596
6606
  names2.push([this.file, value]);
6597
6607
  }
6598
6608
  }
6599
- return { name: this["file"], isolated: true, scope: names2 };
6609
+ return { name: this.file, isolated: true, scope: names2 };
6600
6610
  }
6601
6611
  }
6602
6612
  *arguments() {
@@ -6605,14 +6615,14 @@ var RenderTag = class extends Tag {
6605
6615
  yield v;
6606
6616
  }
6607
6617
  }
6608
- if (this["with"]) {
6609
- const { value } = this["with"];
6618
+ if (this.with) {
6619
+ const { value } = this.with;
6610
6620
  if (isValueToken(value)) {
6611
6621
  yield value;
6612
6622
  }
6613
6623
  }
6614
- if (this["for"]) {
6615
- const { value } = this["for"];
6624
+ if (this.forBinding) {
6625
+ const { value } = this.forBinding;
6616
6626
  if (isValueToken(value)) {
6617
6627
  yield value;
6618
6628
  }
@@ -6657,8 +6667,8 @@ var IncludeTag = class extends Tag {
6657
6667
  constructor(token, remainTokens, liquid, parser) {
6658
6668
  super(token, remainTokens, liquid);
6659
6669
  const { tokenizer } = token;
6660
- this["file"] = parseFilePath(tokenizer, this.liquid, parser);
6661
- this["currentFile"] = token.file;
6670
+ this.file = parseFilePath(tokenizer, this.liquid, parser);
6671
+ this.currentFile = token.file;
6662
6672
  const begin = tokenizer.p;
6663
6673
  const withStr = tokenizer.readIdentifier();
6664
6674
  if (withStr.content === "with") {
@@ -6674,7 +6684,7 @@ var IncludeTag = class extends Tag {
6674
6684
  *render(ctx, emitter) {
6675
6685
  const { liquid, hash, withVar } = this;
6676
6686
  const { renderer } = liquid;
6677
- const filepath = yield renderFilePath(this["file"], ctx, liquid);
6687
+ const filepath = yield renderFilePath(this.file, ctx, liquid);
6678
6688
  assert(filepath, () => `illegal file path "${filepath}"`);
6679
6689
  const saved = ctx.saveRegister("blocks", "blockMode");
6680
6690
  ctx.setRegister("blocks", {});
@@ -6682,36 +6692,36 @@ var IncludeTag = class extends Tag {
6682
6692
  const scope = createScope(yield hash.render(ctx));
6683
6693
  if (withVar)
6684
6694
  scope[filepath] = yield evalToken(withVar, ctx);
6685
- const templates = yield liquid._parsePartialFile(filepath, ctx.sync, this["currentFile"]);
6695
+ const templates = yield liquid._parsePartialFile(filepath, ctx.sync, this.currentFile);
6686
6696
  ctx.push(ctx.opts.jekyllInclude ? createScope({ include: scope }) : scope);
6687
6697
  yield renderer.renderTemplates(templates, ctx, emitter);
6688
6698
  ctx.pop();
6689
6699
  ctx.restoreRegister(saved);
6690
6700
  }
6691
6701
  *children(partials, sync) {
6692
- if (partials && isString(this["file"])) {
6693
- return yield this.liquid._parsePartialFile(this["file"], sync, this["currentFile"]);
6702
+ if (partials && isString(this.file)) {
6703
+ return yield this.liquid._parsePartialFile(this.file, sync, this.currentFile);
6694
6704
  }
6695
6705
  return [];
6696
6706
  }
6697
6707
  partialScope() {
6698
- if (isString(this["file"])) {
6708
+ if (isString(this.file)) {
6699
6709
  let names2;
6700
6710
  if (this.liquid.options.jekyllInclude) {
6701
6711
  names2 = ["include"];
6702
6712
  } else {
6703
6713
  names2 = Object.keys(this.hash.hash);
6704
6714
  if (this.withVar) {
6705
- names2.push([this["file"], this.withVar]);
6715
+ names2.push([this.file, this.withVar]);
6706
6716
  }
6707
6717
  }
6708
- return { name: this["file"], isolated: false, scope: names2 };
6718
+ return { name: this.file, isolated: false, scope: names2 };
6709
6719
  }
6710
6720
  }
6711
6721
  *arguments() {
6712
6722
  yield* Object.values(this.hash.hash).filter(isValueToken);
6713
- if (isValueToken(this["file"])) {
6714
- yield this["file"];
6723
+ if (isValueToken(this.file)) {
6724
+ yield this.file;
6715
6725
  }
6716
6726
  if (isValueToken(this.withVar)) {
6717
6727
  yield this.withVar;
@@ -6861,7 +6871,7 @@ var LayoutTag = class extends Tag {
6861
6871
  constructor(token, remainTokens, liquid, parser) {
6862
6872
  super(token, remainTokens, liquid);
6863
6873
  this.file = parseFilePath(this.tokenizer, this.liquid, parser);
6864
- this["currentFile"] = token.file;
6874
+ this.currentFile = token.file;
6865
6875
  this.args = new Hash(this.tokenizer, liquid.options.keyValueSeparator);
6866
6876
  this.templates = parser.parseTokens(remainTokens);
6867
6877
  }
@@ -6875,7 +6885,7 @@ var LayoutTag = class extends Tag {
6875
6885
  }
6876
6886
  const filepath = yield renderFilePath(this.file, ctx, liquid);
6877
6887
  assert(filepath, () => `illegal file path "${filepath}"`);
6878
- const templates = yield liquid._parseLayoutFile(filepath, ctx.sync, this["currentFile"]);
6888
+ const templates = yield liquid._parseLayoutFile(filepath, ctx.sync, this.currentFile);
6879
6889
  ctx.setRegister("blockMode", BlockMode.STORE);
6880
6890
  const html = yield renderer.renderTemplates(this.templates, ctx);
6881
6891
  const blocks = ctx.getRegister("blocks", {});
@@ -6889,7 +6899,7 @@ var LayoutTag = class extends Tag {
6889
6899
  *children(partials) {
6890
6900
  const templates = this.templates.slice();
6891
6901
  if (partials && isString(this.file)) {
6892
- templates.push(...yield this.liquid._parsePartialFile(this.file, true, this["currentFile"]));
6902
+ templates.push(...yield this.liquid._parsePartialFile(this.file, true, this.currentFile));
6893
6903
  }
6894
6904
  return templates;
6895
6905
  }
@@ -1,4 +1,4 @@
1
- /*! Eleventy (Build Awesome) v4.0.0-alpha.8 (@11ty/client/md Engine Bundle) */
1
+ /*! Eleventy (Build Awesome) v4.0.0-alpha.9 (@11ty/client/md Engine Bundle) */
2
2
  var __defProp = Object.defineProperty;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
4
  var __export = (target, all) => {