@sendbird/actionbook-core 0.10.7 → 0.10.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.
package/dist/index.js CHANGED
@@ -2934,6 +2934,14 @@ var gfmNoAutolinkToMarkdown = () => ({
2934
2934
  function isEmptyParagraph(node) {
2935
2935
  return node.type === "paragraph" && (!("children" in node) || !node.children || node.children.length === 0);
2936
2936
  }
2937
+ var JINJA_TAG_RE = /^\{%\s*(if|elif|else|endif)\b/;
2938
+ function isJinjaTagParagraph(node) {
2939
+ if (node.type !== "paragraph") return false;
2940
+ const children = node.children;
2941
+ if (!children || children.length !== 1) return false;
2942
+ const child = children[0];
2943
+ return child.type === "text" && typeof child.value === "string" && JINJA_TAG_RE.test(child.value);
2944
+ }
2937
2945
  function textHandler(node, parent, state, info) {
2938
2946
  const originalUnsafe = state.unsafe;
2939
2947
  state.unsafe = originalUnsafe.filter((p) => !(p.character === "_" && !p.atBreak));
@@ -2976,7 +2984,10 @@ function serializeToMarkdown(doc2) {
2976
2984
  // Empty paragraphs represent blank-line spacers.
2977
2985
  // Reduce the separator after an empty paragraph from \n\n to \n
2978
2986
  // so that 1 empty paragraph = 1 extra blank line in the output.
2979
- (left) => isEmptyParagraph(left) ? 0 : null
2987
+ (left) => isEmptyParagraph(left) ? 0 : null,
2988
+ // Consecutive paragraphs: single newline instead of blank line
2989
+ // (skip jinja tag paragraphs — they need blank lines for proper roundtrip)
2990
+ (left, right) => left.type === "paragraph" && right.type === "paragraph" && !isJinjaTagParagraph(left) && !isJinjaTagParagraph(right) ? 0 : null
2980
2991
  ],
2981
2992
  handlers: {
2982
2993
  text: textHandler,
@@ -3737,6 +3748,11 @@ function tokenize(input) {
3737
3748
  i++;
3738
3749
  continue;
3739
3750
  }
3751
+ if (input[i] === ",") {
3752
+ tokens.push({ type: "COMMA", value: "," });
3753
+ i++;
3754
+ continue;
3755
+ }
3740
3756
  return { tokens: [], error: `Unexpected character: ${input[i]}` };
3741
3757
  }
3742
3758
  tokens.push({ type: "EOF", value: "" });
@@ -3867,6 +3883,17 @@ var Parser = class {
3867
3883
  return null;
3868
3884
  case "IDENT": {
3869
3885
  this.advance();
3886
+ if (this.peek().type === "LPAREN") {
3887
+ this.advance();
3888
+ while (this.peek().type !== "RPAREN" && this.peek().type !== "EOF") {
3889
+ this.orExpr();
3890
+ if (this.peek().type === "COMMA") {
3891
+ this.advance();
3892
+ }
3893
+ }
3894
+ this.expect("RPAREN");
3895
+ return null;
3896
+ }
3870
3897
  return this.resolveVariable(t.value);
3871
3898
  }
3872
3899
  case "LPAREN": {
@@ -4665,7 +4692,7 @@ var END_ACTION_TEXTS = /* @__PURE__ */ new Set([
4665
4692
  function isEndActionTag(tagType, resourceId, text2) {
4666
4693
  return tagType === "handoff" || END_ACTION_RESOURCE_IDS.has(resourceId) || END_ACTION_TEXTS.has(text2.toLowerCase());
4667
4694
  }
4668
- function extractInlineItems(content, blockIndex) {
4695
+ function extractInlineItems(content, blockIndex, listItemPath = []) {
4669
4696
  const items = [];
4670
4697
  for (const node of content) {
4671
4698
  if (node.type === "jumpPoint") {
@@ -4682,22 +4709,26 @@ function extractInlineItems(content, blockIndex) {
4682
4709
  label: endAction ? `End ${node.text}` : node.text,
4683
4710
  blockIndex,
4684
4711
  children: [],
4685
- meta: { tagType: node.tagType, resourceId: node.resourceId }
4712
+ meta: {
4713
+ tagType: node.tagType,
4714
+ resourceId: node.resourceId,
4715
+ ...listItemPath.length > 0 && { listItemPath: [...listItemPath] }
4716
+ }
4686
4717
  });
4687
4718
  }
4688
4719
  }
4689
4720
  return items;
4690
4721
  }
4691
- function extractBlockItems(blocks, startIndex, depth) {
4722
+ function extractBlockItems(blocks, startIndex, depth, listItemPath = [], fixedBlockIndex) {
4692
4723
  if (depth > MAX_DEPTH6) return [];
4693
4724
  const items = [];
4694
4725
  for (let i = 0; i < blocks.length; i++) {
4695
4726
  const block = blocks[i];
4696
- const blockIndex = startIndex + i;
4727
+ const blockIndex = fixedBlockIndex ?? startIndex + i;
4697
4728
  switch (block.type) {
4698
4729
  case "heading": {
4699
4730
  const label = textContent(block) || `Heading ${block.level}`;
4700
- const inlineItems = extractInlineItems(block.content, blockIndex);
4731
+ const inlineItems = extractInlineItems(block.content, blockIndex, listItemPath);
4701
4732
  items.push({
4702
4733
  type: "heading",
4703
4734
  label,
@@ -4708,7 +4739,7 @@ function extractBlockItems(blocks, startIndex, depth) {
4708
4739
  break;
4709
4740
  }
4710
4741
  case "paragraph": {
4711
- const inlineItems = extractInlineItems(block.content, blockIndex);
4742
+ const inlineItems = extractInlineItems(block.content, blockIndex, listItemPath);
4712
4743
  items.push(...inlineItems);
4713
4744
  break;
4714
4745
  }
@@ -4744,14 +4775,15 @@ function extractBlockItems(blocks, startIndex, depth) {
4744
4775
  }
4745
4776
  case "bulletList":
4746
4777
  case "orderedList": {
4747
- for (const li of block.content) {
4748
- const childItems = extractBlockItems(li.content, blockIndex, depth + 1);
4778
+ for (let liIdx = 0; liIdx < block.content.length; liIdx++) {
4779
+ const li = block.content[liIdx];
4780
+ const childItems = extractBlockItems(li.content, blockIndex, depth + 1, [...listItemPath, liIdx], blockIndex);
4749
4781
  items.push(...childItems);
4750
4782
  }
4751
4783
  break;
4752
4784
  }
4753
4785
  case "blockquote": {
4754
- const childItems = extractBlockItems(block.content, blockIndex, depth + 1);
4786
+ const childItems = extractBlockItems(block.content, blockIndex, depth + 1, listItemPath, blockIndex);
4755
4787
  items.push(...childItems);
4756
4788
  break;
4757
4789
  }