rn-shiki 0.0.37-20 → 0.0.37-22
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/commonjs/components/syntax/SyntaxHighlighter.js +69 -61
- package/lib/commonjs/components/syntax/SyntaxHighlighter.js.map +1 -1
- package/lib/commonjs/hooks/useSyntaxHighlighter.js +18 -10
- package/lib/commonjs/hooks/useSyntaxHighlighter.js.map +1 -1
- package/lib/commonjs/index.js +0 -23
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/syntax/{highlighter/index.js → highlighter.js} +20 -10
- package/lib/commonjs/syntax/highlighter.js.map +1 -0
- package/lib/commonjs/utils/style-transformer.js +97 -0
- package/lib/commonjs/utils/style-transformer.js.map +1 -0
- package/lib/module/components/syntax/SyntaxHighlighter.js +69 -62
- package/lib/module/components/syntax/SyntaxHighlighter.js.map +1 -1
- package/lib/module/hooks/useSyntaxHighlighter.js +17 -9
- package/lib/module/hooks/useSyntaxHighlighter.js.map +1 -1
- package/lib/module/index.js +1 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/syntax/highlighter.js +44 -0
- package/lib/module/syntax/highlighter.js.map +1 -0
- package/lib/module/utils/style-transformer.js +91 -0
- package/lib/module/utils/style-transformer.js.map +1 -0
- package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts +2 -10
- package/lib/typescript/components/syntax/SyntaxHighlighter.d.ts.map +1 -1
- package/lib/typescript/hooks/useSyntaxHighlighter.d.ts +3 -2
- package/lib/typescript/hooks/useSyntaxHighlighter.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -3
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/syntax/{highlighter/index.d.ts → highlighter.d.ts} +3 -4
- package/lib/typescript/syntax/highlighter.d.ts.map +1 -0
- package/lib/typescript/types/shiki.d.ts +10 -8
- package/lib/typescript/types/shiki.d.ts.map +1 -1
- package/lib/typescript/utils/string.d.ts +1 -1
- package/lib/typescript/utils/string.d.ts.map +1 -1
- package/lib/typescript/utils/style-transformer.d.ts +8 -0
- package/lib/typescript/utils/style-transformer.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/syntax/SyntaxHighlighter.tsx +62 -28
- package/src/utils/string.ts +1 -1
- package/lib/commonjs/components/syntax/SyntaxLine.js +0 -36
- package/lib/commonjs/components/syntax/SyntaxLine.js.map +0 -1
- package/lib/commonjs/components/syntax/index.js +0 -21
- package/lib/commonjs/components/syntax/index.js.map +0 -1
- package/lib/commonjs/syntax/highlighter/index.js.map +0 -1
- package/lib/commonjs/syntax/index.js +0 -19
- package/lib/commonjs/syntax/index.js.map +0 -1
- package/lib/commonjs/types/index.js +0 -2
- package/lib/commonjs/types/index.js.map +0 -1
- package/lib/commonjs/types/shiki.d.js +0 -6
- package/lib/commonjs/types/shiki.d.js.map +0 -1
- package/lib/commonjs/utils/index.js +0 -17
- package/lib/commonjs/utils/index.js.map +0 -1
- package/lib/module/components/syntax/SyntaxLine.js +0 -31
- package/lib/module/components/syntax/SyntaxLine.js.map +0 -1
- package/lib/module/components/syntax/index.js +0 -5
- package/lib/module/components/syntax/index.js.map +0 -1
- package/lib/module/syntax/highlighter/index.js +0 -34
- package/lib/module/syntax/highlighter/index.js.map +0 -1
- package/lib/module/syntax/index.js +0 -4
- package/lib/module/syntax/index.js.map +0 -1
- package/lib/module/types/index.js +0 -2
- package/lib/module/types/index.js.map +0 -1
- package/lib/module/types/shiki.d.js +0 -4
- package/lib/module/types/shiki.d.js.map +0 -1
- package/lib/module/utils/index.js +0 -4
- package/lib/module/utils/index.js.map +0 -1
- package/lib/typescript/components/syntax/SyntaxLine.d.ts +0 -9
- package/lib/typescript/components/syntax/SyntaxLine.d.ts.map +0 -1
- package/lib/typescript/components/syntax/index.d.ts +0 -3
- package/lib/typescript/components/syntax/index.d.ts.map +0 -1
- package/lib/typescript/syntax/highlighter/index.d.ts.map +0 -1
- package/lib/typescript/syntax/index.d.ts +0 -2
- package/lib/typescript/syntax/index.d.ts.map +0 -1
- package/lib/typescript/types/index.d.ts +0 -7
- package/lib/typescript/types/index.d.ts.map +0 -1
- package/lib/typescript/utils/index.d.ts +0 -2
- package/lib/typescript/utils/index.d.ts.map +0 -1
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
var _string = require("./string");
|
7
|
-
Object.keys(_string).forEach(function (key) {
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
9
|
-
if (key in exports && exports[key] === _string[key]) return;
|
10
|
-
Object.defineProperty(exports, key, {
|
11
|
-
enumerable: true,
|
12
|
-
get: function () {
|
13
|
-
return _string[key];
|
14
|
-
}
|
15
|
-
});
|
16
|
-
});
|
17
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["_string","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,OAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,OAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,OAAA,CAAAK,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
@@ -1,31 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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":[]}
|
@@ -1 +0,0 @@
|
|
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":[]}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
import { createHighlighterCore } from 'shiki/core';
|
4
|
-
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
|
5
|
-
async function initializeHighlighter(langs, themes) {
|
6
|
-
return createHighlighterCore({
|
7
|
-
engine: createJavaScriptRegexEngine(),
|
8
|
-
langs,
|
9
|
-
themes
|
10
|
-
});
|
11
|
-
}
|
12
|
-
export async function createHighlighter({
|
13
|
-
langs,
|
14
|
-
themes
|
15
|
-
}) {
|
16
|
-
if (!langs?.length || !themes?.length) {
|
17
|
-
throw new Error('Please provide both `langs` and `themes` when creating a highlighter.');
|
18
|
-
}
|
19
|
-
try {
|
20
|
-
const highlighter = await initializeHighlighter(langs, themes);
|
21
|
-
return highlighter;
|
22
|
-
} catch (error) {
|
23
|
-
console.error('Failed to create highlighter:', error);
|
24
|
-
throw error;
|
25
|
-
}
|
26
|
-
}
|
27
|
-
export function processTokens(tokens) {
|
28
|
-
return tokens.map(token => ({
|
29
|
-
content: token.content,
|
30
|
-
color: token.color || '#000000',
|
31
|
-
fontStyle: token.fontStyle?.toString()
|
32
|
-
}));
|
33
|
-
}
|
34
|
-
//# sourceMappingURL=index.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["createHighlighterCore","createJavaScriptRegexEngine","initializeHighlighter","langs","themes","engine","createHighlighter","length","Error","highlighter","error","console","processTokens","tokens","map","token","content","color","fontStyle","toString"],"sourceRoot":"../../../../src","sources":["syntax/highlighter/index.ts"],"mappings":";;AAEA,SAASA,qBAAqB,QAAQ,YAAY;AAClD,SAASC,2BAA2B,QAAQ,yBAAyB;AAErE,eAAeC,qBAAqBA,CAACC,KAAsB,EAAEC,MAAoB,EAA8D;EAC7I,OAAOJ,qBAAqB,CAAC;IAC3BK,MAAM,EAAEJ,2BAA2B,CAAC,CAAC;IACrCE,KAAK;IACLC;EACF,CAAC,CAAC;AACJ;AAEA,OAAO,eAAeE,iBAAiBA,CAAC;EAAEH,KAAK;EAAEC;AAAyD,CAAC,EAA8D;EACvK,IAAI,CAACD,KAAK,EAAEI,MAAM,IAAI,CAACH,MAAM,EAAEG,MAAM,EAAE;IACrC,MAAM,IAAIC,KAAK,CAAC,uEAAuE,CAAC;EAC1F;EAEA,IAAI;IACF,MAAMC,WAAW,GAAG,MAAMP,qBAAqB,CAACC,KAAK,EAAEC,MAAM,CAAC;IAC9D,OAAOK,WAAW;EACpB,CAAC,CACD,OAAOC,KAAK,EAAE;IACZC,OAAO,CAACD,KAAK,CAAC,+BAA+B,EAAEA,KAAK,CAAC;IACrD,MAAMA,KAAK;EACb;AACF;AAEA,OAAO,SAASE,aAAaA,CAACC,MAAqB,EAAe;EAChE,OAAOA,MAAM,CAACC,GAAG,CAACC,KAAK,KAAK;IAC1BC,OAAO,EAAED,KAAK,CAACC,OAAO;IACtBC,KAAK,EAAEF,KAAK,CAACE,KAAK,IAAI,SAAS;IAC/BC,SAAS,EAAEH,KAAK,CAACG,SAAS,EAAEC,QAAQ,CAAC;EACvC,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["createHighlighter","processTokens"],"sourceRoot":"../../../src","sources":["syntax/index.ts"],"mappings":";;AAAA,SAASA,iBAAiB,EAAEC,aAAa,QAAQ,eAAe","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/shiki.d.ts"],"mappings":"","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;AAAA,cAAc,UAAU","ignoreList":[]}
|
@@ -1,9 +0,0 @@
|
|
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
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/syntax/highlighter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACnE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAWlD,wBAAsB,iBAAiB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;IAAE,KAAK,EAAE,aAAa,EAAE,CAAC;IAAC,MAAM,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAavK;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,CAMhE"}
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1 +0,0 @@
|
|
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"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA"}
|