rn-shiki 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/LICENCE +21 -0
  2. package/babel.cjs +150 -0
  3. package/babel.config.cjs +14 -0
  4. package/lib/commonjs/components/syntax/SyntaxHighlighter.js +73 -0
  5. package/lib/commonjs/components/syntax/SyntaxHighlighter.js.map +1 -0
  6. package/lib/commonjs/components/syntax/SyntaxLine.js +36 -0
  7. package/lib/commonjs/components/syntax/SyntaxLine.js.map +1 -0
  8. package/lib/commonjs/components/syntax/index.js +21 -0
  9. package/lib/commonjs/components/syntax/index.js.map +1 -0
  10. package/lib/commonjs/hooks/useSyntaxHighlighter.js +62 -0
  11. package/lib/commonjs/hooks/useSyntaxHighlighter.js.map +1 -0
  12. package/lib/commonjs/index.js +26 -0
  13. package/lib/commonjs/index.js.map +1 -0
  14. package/lib/commonjs/package.json +1 -0
  15. package/lib/commonjs/syntax/highlighter/index.js +128 -0
  16. package/lib/commonjs/syntax/highlighter/index.js.map +1 -0
  17. package/lib/commonjs/syntax/index.js +26 -0
  18. package/lib/commonjs/syntax/index.js.map +1 -0
  19. package/lib/commonjs/syntax/parser/index.js +26 -0
  20. package/lib/commonjs/syntax/parser/index.js.map +1 -0
  21. package/lib/commonjs/types/index.js +2 -0
  22. package/lib/commonjs/types/index.js.map +1 -0
  23. package/lib/commonjs/utils/index.js +17 -0
  24. package/lib/commonjs/utils/index.js.map +1 -0
  25. package/lib/commonjs/utils/string.js +28 -0
  26. package/lib/commonjs/utils/string.js.map +1 -0
  27. package/lib/module/components/syntax/SyntaxHighlighter.js +68 -0
  28. package/lib/module/components/syntax/SyntaxHighlighter.js.map +1 -0
  29. package/lib/module/components/syntax/SyntaxLine.js +31 -0
  30. package/lib/module/components/syntax/SyntaxLine.js.map +1 -0
  31. package/lib/module/components/syntax/index.js +5 -0
  32. package/lib/module/components/syntax/index.js.map +1 -0
  33. package/lib/module/hooks/useSyntaxHighlighter.js +58 -0
  34. package/lib/module/hooks/useSyntaxHighlighter.js.map +1 -0
  35. package/lib/module/index.js +5 -0
  36. package/lib/module/index.js.map +1 -0
  37. package/lib/module/package.json +1 -0
  38. package/lib/module/syntax/highlighter/index.js +121 -0
  39. package/lib/module/syntax/highlighter/index.js.map +1 -0
  40. package/lib/module/syntax/index.js +5 -0
  41. package/lib/module/syntax/index.js.map +1 -0
  42. package/lib/module/syntax/parser/index.js +22 -0
  43. package/lib/module/syntax/parser/index.js.map +1 -0
  44. package/lib/module/types/index.js +2 -0
  45. package/lib/module/types/index.js.map +1 -0
  46. package/lib/module/utils/index.js +4 -0
  47. package/lib/module/utils/index.js.map +1 -0
  48. package/lib/module/utils/string.js +22 -0
  49. package/lib/module/utils/string.js.map +1 -0
  50. package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts +11 -0
  51. package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts.map +1 -0
  52. package/lib/typescript/components/syntax/SyntaxLine.d.ts +9 -0
  53. package/lib/typescript/components/syntax/SyntaxLine.d.ts.map +1 -0
  54. package/lib/typescript/components/syntax/index.d.ts +3 -0
  55. package/lib/typescript/components/syntax/index.d.ts.map +1 -0
  56. package/lib/typescript/hooks/useSyntaxHighlighter.d.ts +11 -0
  57. package/lib/typescript/hooks/useSyntaxHighlighter.d.ts.map +1 -0
  58. package/lib/typescript/index.d.ts +4 -0
  59. package/lib/typescript/index.d.ts.map +1 -0
  60. package/lib/typescript/syntax/highlighter/index.d.ts +14 -0
  61. package/lib/typescript/syntax/highlighter/index.d.ts.map +1 -0
  62. package/lib/typescript/syntax/index.d.ts +4 -0
  63. package/lib/typescript/syntax/index.d.ts.map +1 -0
  64. package/lib/typescript/syntax/parser/index.d.ts +10 -0
  65. package/lib/typescript/syntax/parser/index.d.ts.map +1 -0
  66. package/lib/typescript/types/index.d.ts +7 -0
  67. package/lib/typescript/types/index.d.ts.map +1 -0
  68. package/lib/typescript/utils/index.d.ts +2 -0
  69. package/lib/typescript/utils/index.d.ts.map +1 -0
  70. package/lib/typescript/utils/string.d.ts +5 -0
  71. package/lib/typescript/utils/string.d.ts.map +1 -0
  72. package/package.json +78 -0
  73. package/src/components/syntax/SyntaxHighlighter.tsx +57 -0
  74. package/src/components/syntax/SyntaxLine.tsx +34 -0
  75. package/src/components/syntax/index.ts +2 -0
  76. package/src/hooks/useSyntaxHighlighter.ts +65 -0
  77. package/src/index.ts +3 -0
  78. package/src/syntax/highlighter/index.ts +139 -0
  79. package/src/syntax/index.ts +3 -0
  80. package/src/syntax/parser/index.ts +32 -0
  81. package/src/types/index.ts +6 -0
  82. package/src/utils/index.ts +1 -0
  83. package/src/utils/string.ts +37 -0
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createContentPreview = createContentPreview;
7
+ exports.createLineKey = createLineKey;
8
+ exports.removeExtraIndentation = removeExtraIndentation;
9
+ function createContentPreview(tokens, maxLength = 20) {
10
+ return tokens.slice(0, 3).map(token => token.content).join('').slice(0, maxLength);
11
+ }
12
+ function createLineKey(line, index) {
13
+ const contentPreview = createContentPreview(line);
14
+ return `line-${index}-${contentPreview}`;
15
+ }
16
+ function removeExtraIndentation(text) {
17
+ const preserved = text.replace(/\\n/g, '§NEWLINE§');
18
+ const lines = preserved.split('\n');
19
+ const minIndent = Math.min(...lines.filter(line => line.trim().length > 0).map(line => line.match(/^\s*/)?.[0].length ?? 0));
20
+ const normalized = lines.map(line => {
21
+ if (line.trim().length === 0) return '';
22
+ const indent = line.match(/^\s*/)?.[0] ?? '';
23
+ const relativeIndent = ' '.repeat(Math.max(0, indent.length - minIndent));
24
+ return relativeIndent + line.trim();
25
+ }).join('\n');
26
+ return normalized.replace(/§NEWLINE§/g, '\\n');
27
+ }
28
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentPreview","tokens","maxLength","slice","map","token","content","join","createLineKey","line","index","contentPreview","removeExtraIndentation","text","preserved","replace","lines","split","minIndent","Math","min","filter","trim","length","match","normalized","indent","relativeIndent","repeat","max"],"sourceRoot":"../../../src","sources":["utils/string.ts"],"mappings":";;;;;;;;AAEO,SAASA,oBAAoBA,CAACC,MAAmB,EAAEC,SAAiB,GAAG,EAAE,EAAU;EACxF,OAAOD,MAAM,CACVE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACXC,GAAG,CAACC,KAAK,IAAIA,KAAK,CAACC,OAAO,CAAC,CAC3BC,IAAI,CAAC,EAAE,CAAC,CACRJ,KAAK,CAAC,CAAC,EAAED,SAAS,CAAC;AACxB;AAEO,SAASM,aAAaA,CAACC,IAAiB,EAAEC,KAAa,EAAE;EAC9D,MAAMC,cAAc,GAAGX,oBAAoB,CAACS,IAAI,CAAC;EACjD,OAAO,QAAQC,KAAK,IAAIC,cAAc,EAAE;AAC1C;AAEO,SAASC,sBAAsBA,CAACC,IAAY,EAAU;EAC3D,MAAMC,SAAS,GAAGD,IAAI,CAACE,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC;EACnD,MAAMC,KAAK,GAAGF,SAAS,CAACG,KAAK,CAAC,IAAI,CAAC;EACnC,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CACxB,GAAGJ,KAAK,CACLK,MAAM,CAACZ,IAAI,IAAIA,IAAI,CAACa,IAAI,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC,CAAC,CACtCnB,GAAG,CAACK,IAAI,IAAIA,IAAI,CAACe,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAACD,MAAM,IAAI,CAAC,CACpD,CAAC;EAED,MAAME,UAAU,GAAGT,KAAK,CACrBZ,GAAG,CAAEK,IAAI,IAAK;IACb,IAAIA,IAAI,CAACa,IAAI,CAAC,CAAC,CAACC,MAAM,KAAK,CAAC,EAC1B,OAAO,EAAE;IAEX,MAAMG,MAAM,GAAGjB,IAAI,CAACe,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;IAC5C,MAAMG,cAAc,GAAG,GAAG,CAACC,MAAM,CAACT,IAAI,CAACU,GAAG,CAAC,CAAC,EAAEH,MAAM,CAACH,MAAM,GAAGL,SAAS,CAAC,CAAC;IACzE,OAAOS,cAAc,GAAGlB,IAAI,CAACa,IAAI,CAAC,CAAC;EACrC,CAAC,CAAC,CACDf,IAAI,CAAC,IAAI,CAAC;EAEb,OAAOkB,UAAU,CAACV,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC;AAChD","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { Text, View } from 'react-native';
5
+ import { useSyntaxHighlighter } from '../../hooks/useSyntaxHighlighter';
6
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
7
+ function SyntaxHighlighter({
8
+ text,
9
+ lang,
10
+ theme = 'github-dark',
11
+ fontSize
12
+ }) {
13
+ const {
14
+ tokens,
15
+ error,
16
+ isLoading
17
+ } = useSyntaxHighlighter({
18
+ text,
19
+ lang,
20
+ theme
21
+ });
22
+ if (error) {
23
+ return /*#__PURE__*/_jsxs(Text, {
24
+ style: {
25
+ color: '#ff6b6b',
26
+ fontFamily: 'monospace',
27
+ fontSize
28
+ },
29
+ children: ["Error:", error]
30
+ });
31
+ }
32
+ if (isLoading) {
33
+ return /*#__PURE__*/_jsx(Text, {
34
+ style: {
35
+ color: '#f8f8f2',
36
+ fontFamily: 'monospace',
37
+ fontSize
38
+ },
39
+ children: "Loading..."
40
+ });
41
+ }
42
+ return /*#__PURE__*/_jsx(View, {
43
+ children: tokens.map((line, lineIndex) => /*#__PURE__*/_jsxs(View, {
44
+ style: {
45
+ flexDirection: 'row',
46
+ flexWrap: 'wrap'
47
+ },
48
+ children: [line.map((token, tokenIndex) => /*#__PURE__*/_jsx(Text, {
49
+ style: {
50
+ color: token.color || '#FFFFFF',
51
+ fontFamily: 'monospace',
52
+ fontSize,
53
+ fontStyle: token.fontStyle
54
+ },
55
+ children: token.content.replace(/ /g, '\u00A0')
56
+ }, `${lineIndex}-${tokenIndex}`)), /*#__PURE__*/_jsx(Text, {
57
+ style: {
58
+ color: '#FFFFFF',
59
+ fontFamily: 'monospace',
60
+ fontSize
61
+ },
62
+ children: '\n'
63
+ })]
64
+ }, `line-${lineIndex}`))
65
+ });
66
+ }
67
+ export default SyntaxHighlighter;
68
+ //# sourceMappingURL=SyntaxHighlighter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Text","View","useSyntaxHighlighter","jsxs","_jsxs","jsx","_jsx","SyntaxHighlighter","text","lang","theme","fontSize","tokens","error","isLoading","style","color","fontFamily","children","map","line","lineIndex","flexDirection","flexWrap","token","tokenIndex","fontStyle","content","replace"],"sourceRoot":"../../../../src","sources":["components/syntax/SyntaxHighlighter.tsx"],"mappings":";;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AACzC,SAASC,oBAAoB,QAAQ,kCAAkC;AAAA,SAAAC,IAAA,IAAAC,KAAA,EAAAC,GAAA,IAAAC,IAAA;AASvE,SAASC,iBAAiBA,CAAC;EAAEC,IAAI;EAAEC,IAAI;EAAEC,KAAK,GAAG,aAAa;EAAEC;AAAiC,CAAC,EAAE;EAClG,MAAM;IAAEC,MAAM;IAAEC,KAAK;IAAEC;EAAU,CAAC,GAAGZ,oBAAoB,CAAC;IACxDM,IAAI;IACJC,IAAI;IACJC;EACF,CAAC,CAAC;EAEF,IAAIG,KAAK,EAAE;IACT,oBACET,KAAA,CAACJ,IAAI;MAACe,KAAK,EAAE;QAAEC,KAAK,EAAE,SAAS;QAAEC,UAAU,EAAE,WAAW;QAAEN;MAAS,CAAE;MAAAO,QAAA,GAAC,QAEpE,EAACL,KAAK;IAAA,CACF,CAAC;EAEX;EAEA,IAAIC,SAAS,EAAE;IACb,oBAAOR,IAAA,CAACN,IAAI;MAACe,KAAK,EAAE;QAAEC,KAAK,EAAE,SAAS;QAAEC,UAAU,EAAE,WAAW;QAAEN;MAAS,CAAE;MAAAO,QAAA,EAAC;IAAU,CAAM,CAAC;EAChG;EAEA,oBACEZ,IAAA,CAACL,IAAI;IAAAiB,QAAA,EACFN,MAAM,CAACO,GAAG,CAAC,CAACC,IAAI,EAAEC,SAAS,kBAC1BjB,KAAA,CAACH,IAAI;MAA2Bc,KAAK,EAAE;QAAEO,aAAa,EAAE,KAAK;QAAEC,QAAQ,EAAE;MAAO,CAAE;MAAAL,QAAA,GAC/EE,IAAI,CAACD,GAAG,CAAC,CAACK,KAAK,EAAEC,UAAU,kBAC1BnB,IAAA,CAACN,IAAI;QAEHe,KAAK,EAAE;UACLC,KAAK,EAAEQ,KAAK,CAACR,KAAK,IAAI,SAAS;UAC/BC,UAAU,EAAE,WAAW;UACvBN,QAAQ;UACRe,SAAS,EAAEF,KAAK,CAACE;QACnB,CAAE;QAAAR,QAAA,EAEDM,KAAK,CAACG,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,QAAQ;MAAC,GARjC,GAAGP,SAAS,IAAII,UAAU,EAS3B,CACP,CAAC,eACFnB,IAAA,CAACN,IAAI;QAACe,KAAK,EAAE;UAAEC,KAAK,EAAE,SAAS;UAAEC,UAAU,EAAE,WAAW;UAAEN;QAAS,CAAE;QAAAO,QAAA,EAAE;MAAI,CAAO,CAAC;IAAA,GAd1E,QAAQG,SAAS,EAetB,CACP;EAAC,CACE,CAAC;AAEX;AAEA,eAAed,iBAAiB","ignoreList":[]}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ import React from 'react';
4
+ import { Text, View } from 'react-native';
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ function SyntaxLine({
7
+ line,
8
+ fontSize
9
+ }) {
10
+ return /*#__PURE__*/_jsx(View, {
11
+ style: {
12
+ flexDirection: 'row',
13
+ flexWrap: 'wrap'
14
+ },
15
+ children: line.map((token, tokenIndex) => {
16
+ // Preserve whitespace
17
+ const content = token.content.replace(/ /g, '\u00A0');
18
+ return /*#__PURE__*/_jsx(Text, {
19
+ style: {
20
+ color: token.color,
21
+ fontFamily: 'monospace',
22
+ fontSize,
23
+ fontStyle: token.fontStyle
24
+ },
25
+ children: content
26
+ }, `${content}-${tokenIndex}`);
27
+ })
28
+ });
29
+ }
30
+ export default SyntaxLine;
31
+ //# sourceMappingURL=SyntaxLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Text","View","jsx","_jsx","SyntaxLine","line","fontSize","style","flexDirection","flexWrap","children","map","token","tokenIndex","content","replace","color","fontFamily","fontStyle"],"sourceRoot":"../../../../src","sources":["components/syntax/SyntaxLine.tsx"],"mappings":";;AACA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,EAAEC,IAAI,QAAQ,cAAc;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOzC,SAASC,UAAUA,CAAC;EAAEC,IAAI;EAAEC;AAA0B,CAAC,EAAE;EACvD,oBACEH,IAAA,CAACF,IAAI;IAACM,KAAK,EAAE;MAAEC,aAAa,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAO,CAAE;IAAAC,QAAA,EACrDL,IAAI,CAACM,GAAG,CAAC,CAACC,KAAK,EAAEC,UAAU,KAAK;MAC/B;MACA,MAAMC,OAAO,GAAGF,KAAK,CAACE,OAAO,CAACC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;MACrD,oBACEZ,IAAA,CAACH,IAAI;QAEHO,KAAK,EAAE;UACLS,KAAK,EAAEJ,KAAK,CAACI,KAAK;UAClBC,UAAU,EAAE,WAAW;UACvBX,QAAQ;UACRY,SAAS,EAAEN,KAAK,CAACM;QACnB,CAAE;QAAAR,QAAA,EAEDI;MAAO,GARH,GAAGA,OAAO,IAAID,UAAU,EASzB,CAAC;IAEX,CAAC;EAAC,CACE,CAAC;AAEX;AAEA,eAAeT,UAAU","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { default as SyntaxHighlighter } from './SyntaxHighlighter';
4
+ export { default as SyntaxLine } from './SyntaxLine';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["default","SyntaxHighlighter","SyntaxLine"],"sourceRoot":"../../../../src","sources":["components/syntax/index.ts"],"mappings":";;AAAA,SAASA,OAAO,IAAIC,iBAAiB,QAAQ,qBAAqB;AAClE,SAASD,OAAO,IAAIE,UAAU,QAAQ,cAAc","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ import { useEffect, useState } from 'react';
4
+ import { createHighlighter } from '../syntax';
5
+ export function useSyntaxHighlighter({
6
+ text,
7
+ lang,
8
+ theme
9
+ }) {
10
+ const [tokens, setTokens] = useState([]);
11
+ const [error, setError] = useState();
12
+ const [isLoading, setIsLoading] = useState(true);
13
+ useEffect(() => {
14
+ let mounted = true;
15
+ setIsLoading(true);
16
+ async function highlight() {
17
+ if (!text) {
18
+ setIsLoading(false);
19
+ setTokens([]);
20
+ return;
21
+ }
22
+ try {
23
+ const highlighter = await createHighlighter({
24
+ langs: [lang],
25
+ themes: [theme]
26
+ });
27
+ const result = highlighter.codeToTokens(text, {
28
+ lang,
29
+ theme
30
+ });
31
+ if (mounted && result.tokens) {
32
+ setTokens(result.tokens);
33
+ setError(undefined);
34
+ }
35
+ } catch (err) {
36
+ console.error('Highlighting error:', err);
37
+ if (mounted) {
38
+ setError(err instanceof Error ? err.message : 'Syntax highlighting failed');
39
+ setTokens([]);
40
+ }
41
+ } finally {
42
+ if (mounted) {
43
+ setIsLoading(false);
44
+ }
45
+ }
46
+ }
47
+ highlight();
48
+ return () => {
49
+ mounted = false;
50
+ };
51
+ }, [text, lang, theme]);
52
+ return {
53
+ tokens,
54
+ error,
55
+ isLoading
56
+ };
57
+ }
58
+ //# sourceMappingURL=useSyntaxHighlighter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useState","createHighlighter","useSyntaxHighlighter","text","lang","theme","tokens","setTokens","error","setError","isLoading","setIsLoading","mounted","highlight","highlighter","langs","themes","result","codeToTokens","undefined","err","console","Error","message"],"sourceRoot":"../../../src","sources":["hooks/useSyntaxHighlighter.ts"],"mappings":";;AAEA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,iBAAiB,QAAQ,WAAW;AAQ7C,OAAO,SAASC,oBAAoBA,CAAC;EAAEC,IAAI;EAAEC,IAAI;EAAEC;AAAoE,CAAC,EAAE;EACxH,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGP,QAAQ,CAAkB,EAAE,CAAC;EACzD,MAAM,CAACQ,KAAK,EAAEC,QAAQ,CAAC,GAAGT,QAAQ,CAAS,CAAC;EAC5C,MAAM,CAACU,SAAS,EAAEC,YAAY,CAAC,GAAGX,QAAQ,CAAC,IAAI,CAAC;EAEhDD,SAAS,CAAC,MAAM;IACd,IAAIa,OAAO,GAAG,IAAI;IAClBD,YAAY,CAAC,IAAI,CAAC;IAElB,eAAeE,SAASA,CAAA,EAAG;MACzB,IAAI,CAACV,IAAI,EAAE;QACTQ,YAAY,CAAC,KAAK,CAAC;QACnBJ,SAAS,CAAC,EAAE,CAAC;QACb;MACF;MAEA,IAAI;QACF,MAAMO,WAAW,GAAG,MAAMb,iBAAiB,CAAC;UAC1Cc,KAAK,EAAE,CAACX,IAAI,CAAsB;UAClCY,MAAM,EAAE,CAACX,KAAK;QAChB,CAAC,CAAC;QAEF,MAAMY,MAAM,GAAGH,WAAW,CAACI,YAAY,CAACf,IAAI,EAAE;UAC5CC,IAAI;UACJC;QACF,CAAC,CAAgB;QAEjB,IAAIO,OAAO,IAAIK,MAAM,CAACX,MAAM,EAAE;UAC5BC,SAAS,CAACU,MAAM,CAACX,MAAM,CAAC;UACxBG,QAAQ,CAACU,SAAS,CAAC;QACrB;MACF,CAAC,CACD,OAAOC,GAAG,EAAE;QACVC,OAAO,CAACb,KAAK,CAAC,qBAAqB,EAAEY,GAAG,CAAC;QACzC,IAAIR,OAAO,EAAE;UACXH,QAAQ,CAACW,GAAG,YAAYE,KAAK,GAAGF,GAAG,CAACG,OAAO,GAAG,4BAA4B,CAAC;UAC3EhB,SAAS,CAAC,EAAE,CAAC;QACf;MACF,CAAC,SACO;QACN,IAAIK,OAAO,EAAE;UACXD,YAAY,CAAC,KAAK,CAAC;QACrB;MACF;IACF;IAEAE,SAAS,CAAC,CAAC;IACX,OAAO,MAAM;MACXD,OAAO,GAAG,KAAK;IACjB,CAAC;EACH,CAAC,EAAE,CAACT,IAAI,EAAEC,IAAI,EAAEC,KAAK,CAAC,CAAC;EAEvB,OAAO;IAAEC,MAAM;IAAEE,KAAK;IAAEE;EAAU,CAAC;AACrC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { SyntaxHighlighter, SyntaxLine } from './components/syntax';
4
+ export { parseCodeFence } from './syntax';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["SyntaxHighlighter","SyntaxLine","parseCodeFence"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SAASA,iBAAiB,EAAEC,UAAU,QAAQ,qBAAqB;AACnE,SAASC,cAAc,QAAQ,UAAU","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ import { createHighlighterCore } from 'shiki/core';
4
+ import { createJavaScriptRegexEngine } from 'shiki/engine-javascript.mjs';
5
+
6
+ // Import languages
7
+ import css from 'shiki/langs/css.mjs';
8
+ import html from 'shiki/langs/html.mjs';
9
+ import javascript from 'shiki/langs/javascript.mjs';
10
+ import json from 'shiki/langs/json.mjs';
11
+ import php from 'shiki/langs/php.mjs';
12
+ import typescript from 'shiki/langs/typescript.mjs';
13
+
14
+ // Import themes
15
+ import githubDark from 'shiki/themes/github-dark.mjs';
16
+ import githubLight from 'shiki/themes/github-light.mjs';
17
+
18
+ // Define supported languages and themes explicitly
19
+
20
+ // Bundled languages mapping - using the imported grammars directly
21
+ const LANGUAGE_IMPORTS = {
22
+ css,
23
+ html,
24
+ javascript,
25
+ json,
26
+ php,
27
+ typescript
28
+ };
29
+
30
+ // Bundled themes mapping
31
+ const THEME_IMPORTS = {
32
+ 'github-dark': githubDark,
33
+ 'github-light': githubLight
34
+ };
35
+
36
+ // Singleton highlighter instance with tracking
37
+
38
+ let highlighterInstance = null;
39
+ export async function createHighlighter({
40
+ langs,
41
+ themes
42
+ }) {
43
+ if (!langs || !themes) {
44
+ throw new Error('Please provide both `langs` and `themes` when creating a highlighter.');
45
+ }
46
+
47
+ // Return existing instance if already initialized
48
+ if (highlighterInstance?.highlighter) {
49
+ // Load any new languages that weren't previously loaded
50
+ for (const lang of langs) {
51
+ if (!highlighterInstance.loadedLanguages.has(lang)) {
52
+ const langData = LANGUAGE_IMPORTS[lang];
53
+ await highlighterInstance.highlighter.loadLanguage(langData);
54
+ highlighterInstance.loadedLanguages.add(lang);
55
+ }
56
+ }
57
+
58
+ // Load any new themes that weren't previously loaded
59
+ for (const theme of themes) {
60
+ if (!highlighterInstance.loadedThemes.has(theme)) {
61
+ const themeData = THEME_IMPORTS[theme];
62
+ await highlighterInstance.highlighter.loadTheme(themeData);
63
+ highlighterInstance.loadedThemes.add(theme);
64
+ }
65
+ }
66
+ return highlighterInstance.highlighter;
67
+ }
68
+ try {
69
+ // Create highlighter with initial languages and themes
70
+ const highlighter = await createHighlighterCore({
71
+ engine: createJavaScriptRegexEngine(),
72
+ langs: langs.map(lang => LANGUAGE_IMPORTS[lang]),
73
+ themes: themes.map(theme => THEME_IMPORTS[theme])
74
+ });
75
+
76
+ // Store the instance with tracking sets
77
+ highlighterInstance = {
78
+ highlighter,
79
+ loadedLanguages: new Set(langs),
80
+ loadedThemes: new Set(themes)
81
+ };
82
+ return highlighter;
83
+ } catch (error) {
84
+ console.error('Failed to create highlighter:', error);
85
+ throw error;
86
+ }
87
+ }
88
+
89
+ // Function to ensure a theme is loaded
90
+ export async function loadTheme(theme) {
91
+ if (!highlighterInstance?.highlighter) {
92
+ throw new Error('Highlighter not initialized');
93
+ }
94
+ if (highlighterInstance.loadedThemes.has(theme)) {
95
+ return;
96
+ }
97
+ const themeData = THEME_IMPORTS[theme];
98
+ await highlighterInstance.highlighter.loadTheme(themeData);
99
+ highlighterInstance.loadedThemes.add(theme);
100
+ }
101
+
102
+ // Function to ensure a language is loaded
103
+ export async function loadLanguage(lang) {
104
+ if (!highlighterInstance?.highlighter) {
105
+ throw new Error('Highlighter not initialized');
106
+ }
107
+ if (highlighterInstance.loadedLanguages.has(lang)) {
108
+ return;
109
+ }
110
+ const langData = LANGUAGE_IMPORTS[lang];
111
+ await highlighterInstance.highlighter.loadLanguage(langData);
112
+ highlighterInstance.loadedLanguages.add(lang);
113
+ }
114
+ export function processTokens(tokens) {
115
+ return tokens.map(token => ({
116
+ content: token.content,
117
+ color: token.color || '#000000',
118
+ fontStyle: token.fontStyle?.toString()
119
+ }));
120
+ }
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createHighlighterCore","createJavaScriptRegexEngine","css","html","javascript","json","php","typescript","githubDark","githubLight","LANGUAGE_IMPORTS","THEME_IMPORTS","highlighterInstance","createHighlighter","langs","themes","Error","highlighter","lang","loadedLanguages","has","langData","loadLanguage","add","theme","loadedThemes","themeData","loadTheme","engine","map","Set","error","console","processTokens","tokens","token","content","color","fontStyle","toString"],"sourceRoot":"../../../../src","sources":["syntax/highlighter/index.ts"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { createHighlighter, processTokens } from './highlighter';
4
+ export { parseCodeFence } from './parser';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createHighlighter","processTokens","parseCodeFence"],"sourceRoot":"../../../src","sources":["syntax/index.ts"],"mappings":";;AAAA,SAASA,iBAAiB,EAAEC,aAAa,QAAQ,eAAe;AAChE,SAASC,cAAc,QAAQ,UAAU","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ import { removeExtraIndentation } from '../../utils';
4
+ const CODE_BLOCK_REGEX = /```([a-z0-9]+)?\n([\s\S]*?)\n```/gi;
5
+ export function parseCodeFence(text, defaultLang) {
6
+ const matches = [...text.matchAll(CODE_BLOCK_REGEX)];
7
+ if (matches.length === 0) {
8
+ return {
9
+ code: text
10
+ };
11
+ }
12
+ const code = matches[0]?.[2] || '';
13
+ const language = matches[0]?.[1] || defaultLang;
14
+ const outsideText = text.split(CODE_BLOCK_REGEX).filter(Boolean);
15
+ return {
16
+ code: removeExtraIndentation(code),
17
+ language,
18
+ valid: true,
19
+ outsideText
20
+ };
21
+ }
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["removeExtraIndentation","CODE_BLOCK_REGEX","parseCodeFence","text","defaultLang","matches","matchAll","length","code","language","outsideText","split","filter","Boolean","valid"],"sourceRoot":"../../../../src","sources":["syntax/parser/index.ts"],"mappings":";;AAEA,SAASA,sBAAsB,QAAQ,aAAa;AASpD,MAAMC,gBAAgB,GAAG,oCAAoC;AAE7D,OAAO,SAASC,cAAcA,CAACC,IAAY,EAAEC,WAA+B,EAAmB;EAC7F,MAAMC,OAAO,GAAG,CAAC,GAAGF,IAAI,CAACG,QAAQ,CAACL,gBAAgB,CAAC,CAAC;EACpD,IAAII,OAAO,CAACE,MAAM,KAAK,CAAC,EAAE;IACxB,OAAO;MACLC,IAAI,EAAEL;IACR,CAAC;EACH;EAEA,MAAMK,IAAI,GAAGH,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;EAClC,MAAMI,QAAQ,GAAIJ,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAqCD,WAAW;EACjF,MAAMM,WAAW,GAAGP,IAAI,CAACQ,KAAK,CAACV,gBAAgB,CAAC,CAACW,MAAM,CAACC,OAAO,CAAC;EAEhE,OAAO;IACLL,IAAI,EAAER,sBAAsB,CAACQ,IAAI,CAAC;IAClCC,QAAQ;IACRK,KAAK,EAAE,IAAI;IACXJ;EACF,CAAC;AACH","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export * from './string';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;AAAA,cAAc,UAAU","ignoreList":[]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+
3
+ export function createContentPreview(tokens, maxLength = 20) {
4
+ return tokens.slice(0, 3).map(token => token.content).join('').slice(0, maxLength);
5
+ }
6
+ export function createLineKey(line, index) {
7
+ const contentPreview = createContentPreview(line);
8
+ return `line-${index}-${contentPreview}`;
9
+ }
10
+ export function removeExtraIndentation(text) {
11
+ const preserved = text.replace(/\\n/g, '§NEWLINE§');
12
+ const lines = preserved.split('\n');
13
+ const minIndent = Math.min(...lines.filter(line => line.trim().length > 0).map(line => line.match(/^\s*/)?.[0].length ?? 0));
14
+ const normalized = lines.map(line => {
15
+ if (line.trim().length === 0) return '';
16
+ const indent = line.match(/^\s*/)?.[0] ?? '';
17
+ const relativeIndent = ' '.repeat(Math.max(0, indent.length - minIndent));
18
+ return relativeIndent + line.trim();
19
+ }).join('\n');
20
+ return normalized.replace(/§NEWLINE§/g, '\\n');
21
+ }
22
+ //# sourceMappingURL=string.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createContentPreview","tokens","maxLength","slice","map","token","content","join","createLineKey","line","index","contentPreview","removeExtraIndentation","text","preserved","replace","lines","split","minIndent","Math","min","filter","trim","length","match","normalized","indent","relativeIndent","repeat","max"],"sourceRoot":"../../../src","sources":["utils/string.ts"],"mappings":";;AAEA,OAAO,SAASA,oBAAoBA,CAACC,MAAmB,EAAEC,SAAiB,GAAG,EAAE,EAAU;EACxF,OAAOD,MAAM,CACVE,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACXC,GAAG,CAACC,KAAK,IAAIA,KAAK,CAACC,OAAO,CAAC,CAC3BC,IAAI,CAAC,EAAE,CAAC,CACRJ,KAAK,CAAC,CAAC,EAAED,SAAS,CAAC;AACxB;AAEA,OAAO,SAASM,aAAaA,CAACC,IAAiB,EAAEC,KAAa,EAAE;EAC9D,MAAMC,cAAc,GAAGX,oBAAoB,CAACS,IAAI,CAAC;EACjD,OAAO,QAAQC,KAAK,IAAIC,cAAc,EAAE;AAC1C;AAEA,OAAO,SAASC,sBAAsBA,CAACC,IAAY,EAAU;EAC3D,MAAMC,SAAS,GAAGD,IAAI,CAACE,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC;EACnD,MAAMC,KAAK,GAAGF,SAAS,CAACG,KAAK,CAAC,IAAI,CAAC;EACnC,MAAMC,SAAS,GAAGC,IAAI,CAACC,GAAG,CACxB,GAAGJ,KAAK,CACLK,MAAM,CAACZ,IAAI,IAAIA,IAAI,CAACa,IAAI,CAAC,CAAC,CAACC,MAAM,GAAG,CAAC,CAAC,CACtCnB,GAAG,CAACK,IAAI,IAAIA,IAAI,CAACe,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAACD,MAAM,IAAI,CAAC,CACpD,CAAC;EAED,MAAME,UAAU,GAAGT,KAAK,CACrBZ,GAAG,CAAEK,IAAI,IAAK;IACb,IAAIA,IAAI,CAACa,IAAI,CAAC,CAAC,CAACC,MAAM,KAAK,CAAC,EAC1B,OAAO,EAAE;IAEX,MAAMG,MAAM,GAAGjB,IAAI,CAACe,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE;IAC5C,MAAMG,cAAc,GAAG,GAAG,CAACC,MAAM,CAACT,IAAI,CAACU,GAAG,CAAC,CAAC,EAAEH,MAAM,CAACH,MAAM,GAAGL,SAAS,CAAC,CAAC;IACzE,OAAOS,cAAc,GAAGlB,IAAI,CAACa,IAAI,CAAC,CAAC;EACrC,CAAC,CAAC,CACDf,IAAI,CAAC,IAAI,CAAC;EAEb,OAAOkB,UAAU,CAACV,OAAO,CAAC,YAAY,EAAE,KAAK,CAAC;AAChD","ignoreList":[]}
@@ -0,0 +1,11 @@
1
+ import type { SupportedLanguage, SupportedTheme } from '../../syntax/highlighter';
2
+ import React from 'react';
3
+ interface SyntaxHighlighterProps {
4
+ text: string;
5
+ lang: SupportedLanguage;
6
+ theme?: SupportedTheme;
7
+ fontSize?: number;
8
+ }
9
+ declare function SyntaxHighlighter({ text, lang, theme, fontSize }: SyntaxHighlighterProps): React.JSX.Element;
10
+ export default SyntaxHighlighter;
11
+ //# sourceMappingURL=SyntaxHighlighter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyntaxHighlighter.d.ts","sourceRoot":"","sources":["../../../../src/components/syntax/SyntaxHighlighter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACjF,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,UAAU,sBAAsB;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,iBAAiB,CAAA;IACvB,KAAK,CAAC,EAAE,cAAc,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,iBAAS,iBAAiB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAqB,EAAE,QAAQ,EAAE,EAAE,sBAAsB,qBA0CjG;AAED,eAAe,iBAAiB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import type { TokenType } from '../../types';
2
+ import React from 'react';
3
+ interface SyntaxLineProps {
4
+ line: TokenType[];
5
+ fontSize?: number;
6
+ }
7
+ declare function SyntaxLine({ line, fontSize }: SyntaxLineProps): React.JSX.Element;
8
+ export default SyntaxLine;
9
+ //# sourceMappingURL=SyntaxLine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyntaxLine.d.ts","sourceRoot":"","sources":["../../../../src/components/syntax/SyntaxLine.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,UAAU,eAAe;IACvB,IAAI,EAAE,SAAS,EAAE,CAAA;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,iBAAS,UAAU,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,eAAe,qBAsBtD;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { default as SyntaxHighlighter } from './SyntaxHighlighter';
2
+ export { default as SyntaxLine } from './SyntaxLine';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/syntax/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { BundledLanguage, BundledTheme, ThemedToken } from 'shiki';
2
+ export declare function useSyntaxHighlighter({ text, lang, theme }: {
3
+ text: string;
4
+ lang: BundledLanguage;
5
+ theme: BundledTheme;
6
+ }): {
7
+ tokens: ThemedToken[][];
8
+ error: string | undefined;
9
+ isLoading: boolean;
10
+ };
11
+ //# sourceMappingURL=useSyntaxHighlighter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSyntaxHighlighter.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSyntaxHighlighter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAWvE,wBAAgB,oBAAoB,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,YAAY,CAAA;CAAE;;;;EAqDvH"}
@@ -0,0 +1,4 @@
1
+ export { SyntaxHighlighter, SyntaxLine } from './components/syntax';
2
+ export { parseCodeFence } from './syntax';
3
+ export type { ParsedCodeFence } from './syntax';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,14 @@
1
+ import type { ThemedToken } from 'shiki';
2
+ import type { TokenType } from '../../types';
3
+ export type SupportedLanguage = 'css' | 'html' | 'javascript' | 'json' | 'php' | 'typescript';
4
+ export type SupportedTheme = 'github-dark' | 'github-light';
5
+ interface HighlighterOptions {
6
+ langs: SupportedLanguage[];
7
+ themes: SupportedTheme[];
8
+ }
9
+ export declare function createHighlighter({ langs, themes }: HighlighterOptions): Promise<import("shiki").HighlighterCore>;
10
+ export declare function loadTheme(theme: SupportedTheme): Promise<void>;
11
+ export declare function loadLanguage(lang: SupportedLanguage): Promise<void>;
12
+ export declare function processTokens(tokens: ThemedToken[]): TokenType[];
13
+ export {};
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/syntax/highlighter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,WAAW,EAAc,MAAM,OAAO,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAiB5C,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,MAAM,GAAG,YAAY,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAA;AAC7F,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG,cAAc,CAAA;AA2B3D,UAAU,kBAAkB;IAC1B,KAAK,EAAE,iBAAiB,EAAE,CAAA;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAA;CACzB;AAED,wBAAsB,iBAAiB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,kBAAkB,4CAiD5E;AAGD,wBAAsB,SAAS,CAAC,KAAK,EAAE,cAAc,iBAYpD;AAGD,wBAAsB,YAAY,CAAC,IAAI,EAAE,iBAAiB,iBAYzD;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,CAMhE"}
@@ -0,0 +1,4 @@
1
+ export { createHighlighter, processTokens } from './highlighter';
2
+ export { parseCodeFence } from './parser';
3
+ export type { ParsedCodeFence } from './parser';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/syntax/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,10 @@
1
+ import type { BundledLanguage } from 'shiki/langs';
2
+ import type { SupportedLanguage } from '../../syntax/highlighter';
3
+ export interface ParsedCodeFence {
4
+ code: string;
5
+ language: BundledLanguage;
6
+ valid: boolean;
7
+ outsideText: string[];
8
+ }
9
+ export declare function parseCodeFence(text: string, defaultLang?: SupportedLanguage): ParsedCodeFence;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/syntax/parser/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAGjE,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,eAAe,CAAA;IACzB,KAAK,EAAE,OAAO,CAAA;IACd,WAAW,EAAE,MAAM,EAAE,CAAA;CACtB;AAID,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,iBAAiB,GAAG,eAAe,CAkB7F"}
@@ -0,0 +1,7 @@
1
+ export interface TokenType {
2
+ content: string;
3
+ color: string;
4
+ fontStyle?: string;
5
+ fontWeight?: string;
6
+ }
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
@@ -0,0 +1,2 @@
1
+ export * from './string';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { TokenType } from '../types';
2
+ export declare function createContentPreview(tokens: TokenType[], maxLength?: number): string;
3
+ export declare function createLineKey(line: TokenType[], index: number): string;
4
+ export declare function removeExtraIndentation(text: string): string;
5
+ //# sourceMappingURL=string.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/utils/string.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEzC,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAE,MAAW,GAAG,MAAM,CAMxF;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,MAAM,UAG7D;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAqB3D"}