@melandlabs/integrations-whatsapp 0.1.5 → 0.2.1
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/client-registry.js +0 -2
- package/dist/conversation-store.js +0 -2
- package/dist/index.js +0 -2
- package/dist/markdown.js +0 -2
- package/package.json +5 -5
- package/dist/client-registry.js.map +0 -1
- package/dist/conversation-store.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/markdown.js.map +0 -1
package/dist/markdown.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/markdown.ts"],"names":[],"mappings":";AAkBA,IAAM,iBAAA,GAAoB,SAAA;AAC1B,IAAM,uBAAA,GAA0B,QAAA;AAEhC,SAAS,aAAa,MAAA,EAAwB;AAC7C,EAAA,OAAO,MAAA,CAAO,OAAA,CAAQ,qBAAA,EAAuB,MAAM,CAAA;AACpD;AAeO,SAAS,mBAAmB,IAAA,EAAsB;AACxD,EAAA,IAAI,CAAC,IAAA,EAAM;AACV,IAAA,OAAO,IAAA;AAAA,EACR;AAGA,EAAA,MAAM,SAAmB,EAAC;AAC1B,EAAA,IAAI,MAAA,GAAS,IAAA,CAAK,OAAA,CAAQ,iBAAA,EAAmB,CAAC,KAAA,KAAU;AACvD,IAAA,MAAA,CAAO,KAAK,KAAK,CAAA;AACjB,IAAA,OAAO,CAAA,EAAG,iBAAiB,CAAA,EAAG,MAAA,CAAO,SAAS,CAAC,CAAA,CAAA;AAAA,EAChD,CAAC,CAAA;AAGD,EAAA,MAAM,cAAwB,EAAC;AAC/B,EAAA,MAAA,GAAS,MAAA,CAAO,OAAA,CAAQ,YAAA,EAAc,CAAC,KAAA,KAAU;AAChD,IAAA,WAAA,CAAY,KAAK,KAAK,CAAA;AACtB,IAAA,OAAO,CAAA,EAAG,uBAAuB,CAAA,EAAG,WAAA,CAAY,SAAS,CAAC,CAAA,CAAA;AAAA,EAC3D,CAAC,CAAA;AAGD,EAAA,MAAA,GAAS,MAAA,CAAO,OAAA,CAAQ,gBAAA,EAAkB,MAAM,CAAA;AAChD,EAAA,MAAA,GAAS,MAAA,CAAO,OAAA,CAAQ,YAAA,EAAc,MAAM,CAAA;AAG5C,EAAA,MAAA,GAAS,MAAA,CAAO,OAAA,CAAQ,YAAA,EAAc,MAAM,CAAA;AAG5C,EAAA,MAAA,GAAS,MAAA,CAAO,OAAA;AAAA,IACf,IAAI,MAAA,CAAO,CAAA,EAAG,aAAa,uBAAuB,CAAC,UAAU,GAAG,CAAA;AAAA,IAChE,CAAC,CAAA,EAAG,GAAA,KAAQ,YAAY,MAAA,CAAO,GAAG,CAAC,CAAA,IAAK;AAAA,GACzC;AAGA,EAAA,MAAA,GAAS,MAAA,CAAO,OAAA;AAAA,IACf,IAAI,MAAA,CAAO,CAAA,EAAG,aAAa,iBAAiB,CAAC,UAAU,GAAG,CAAA;AAAA,IAC1D,CAAC,CAAA,EAAG,GAAA,KAAQ,OAAO,MAAA,CAAO,GAAG,CAAC,CAAA,IAAK;AAAA,GACpC;AAEA,EAAA,OAAO,MAAA;AACR","file":"markdown.js","sourcesContent":["/**\n * Convert standard Markdown formatting to WhatsApp-compatible markup.\n *\n * WhatsApp uses its own formatting syntax:\n * - bold: *text*\n * - italic: _text_\n * - strikethrough: ~text~\n *\n * Standard Markdown uses:\n * - bold: **text** or __text__\n * - italic: *text* or _text_\n * - strikethrough: ~~text~~\n * - code: `text` (inline) or ```text``` (block)\n *\n * The conversion preserves fenced code blocks and inline code,\n * then converts bold and strikethrough markers.\n */\n\nconst FENCE_PLACEHOLDER = \"\\x00FENCE\";\nconst INLINE_CODE_PLACEHOLDER = \"\\x00CODE\";\n\nfunction escapeRegExp(string: string): string {\n\treturn string.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/**\n * Convert standard Markdown bold/italic/strikethrough to WhatsApp formatting.\n *\n * Order of operations matters:\n * 1. Protect fenced code blocks (```...```) — already WhatsApp-compatible\n * 2. Protect inline code (`...`) — leave as-is\n * 3. Convert **bold** → *bold* and __bold__ → *bold*\n * 4. Convert ~~strike~~ → ~strike~\n * 5. Restore protected spans\n *\n * Italic *text* and _text_ are left alone since WhatsApp uses _text_ for italic\n * and single * is already WhatsApp bold — no conversion needed for single markers.\n */\nexport function markdownToWhatsApp(text: string): string {\n\tif (!text) {\n\t\treturn text;\n\t}\n\n\t// 1. Extract and protect fenced code blocks\n\tconst fences: string[] = [];\n\tlet result = text.replace(/```[\\s\\S]*?```/g, (match) => {\n\t\tfences.push(match);\n\t\treturn `${FENCE_PLACEHOLDER}${fences.length - 1}`;\n\t});\n\n\t// 2. Extract and protect inline code\n\tconst inlineCodes: string[] = [];\n\tresult = result.replace(/`[^`\\n]+`/g, (match) => {\n\t\tinlineCodes.push(match);\n\t\treturn `${INLINE_CODE_PLACEHOLDER}${inlineCodes.length - 1}`;\n\t});\n\n\t// 3. Convert **bold** → *bold* and __bold__ → *bold*\n\tresult = result.replace(/\\*\\*(.+?)\\*\\*/g, \"*$1*\");\n\tresult = result.replace(/__(.+?)__/g, \"*$1*\");\n\n\t// 4. Convert ~~strikethrough~~ → ~strikethrough~\n\tresult = result.replace(/~~(.+?)~~/g, \"~$1~\");\n\n\t// 5. Restore inline code\n\tresult = result.replace(\n\t\tnew RegExp(`${escapeRegExp(INLINE_CODE_PLACEHOLDER)}(\\\\d+)`, \"g\"),\n\t\t(_, idx) => inlineCodes[Number(idx)] ?? \"\",\n\t);\n\n\t// 6. Restore fenced code blocks\n\tresult = result.replace(\n\t\tnew RegExp(`${escapeRegExp(FENCE_PLACEHOLDER)}(\\\\d+)`, \"g\"),\n\t\t(_, idx) => fences[Number(idx)] ?? \"\",\n\t);\n\n\treturn result;\n}\n"]}
|