rn-shiki 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,10 +8,10 @@ exports.loadLanguage = loadLanguage;
8
8
  exports.loadTheme = loadTheme;
9
9
  exports.processTokens = processTokens;
10
10
  var _core = require("shiki/core");
11
- var _engineJavascript = require("shiki/engine-javascript.mjs");
11
+ var _javascript = require("shiki/engine/javascript");
12
12
  var _css = _interopRequireDefault(require("shiki/langs/css.mjs"));
13
13
  var _html = _interopRequireDefault(require("shiki/langs/html.mjs"));
14
- var _javascript = _interopRequireDefault(require("shiki/langs/javascript.mjs"));
14
+ var _javascript2 = _interopRequireDefault(require("shiki/langs/javascript.mjs"));
15
15
  var _json = _interopRequireDefault(require("shiki/langs/json.mjs"));
16
16
  var _php = _interopRequireDefault(require("shiki/langs/php.mjs"));
17
17
  var _typescript = _interopRequireDefault(require("shiki/langs/typescript.mjs"));
@@ -28,7 +28,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
28
28
  const LANGUAGE_IMPORTS = {
29
29
  css: _css.default,
30
30
  html: _html.default,
31
- javascript: _javascript.default,
31
+ javascript: _javascript2.default,
32
32
  json: _json.default,
33
33
  php: _php.default,
34
34
  typescript: _typescript.default
@@ -75,7 +75,7 @@ async function createHighlighter({
75
75
  try {
76
76
  // Create highlighter with initial languages and themes
77
77
  const highlighter = await (0, _core.createHighlighterCore)({
78
- engine: (0, _engineJavascript.createJavaScriptRegexEngine)(),
78
+ engine: (0, _javascript.createJavaScriptRegexEngine)(),
79
79
  langs: langs.map(lang => LANGUAGE_IMPORTS[lang]),
80
80
  themes: themes.map(theme => THEME_IMPORTS[theme])
81
81
  });
@@ -1 +1 @@
1
- {"version":3,"names":["_core","require","_engineJavascript","_css","_interopRequireDefault","_html","_javascript","_json","_php","_typescript","_githubDark","_githubLight","e","__esModule","default","LANGUAGE_IMPORTS","css","html","javascript","json","php","typescript","THEME_IMPORTS","githubDark","githubLight","highlighterInstance","createHighlighter","langs","themes","Error","highlighter","lang","loadedLanguages","has","langData","loadLanguage","add","theme","loadedThemes","themeData","loadTheme","createHighlighterCore","engine","createJavaScriptRegexEngine","map","Set","error","console","processTokens","tokens","token","content","color","fontStyle","toString"],"sourceRoot":"../../../../src","sources":["syntax/highlighter/index.ts"],"mappings":";;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGA,IAAAE,IAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,KAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,IAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,WAAA,GAAAL,sBAAA,CAAAH,OAAA;AAGA,IAAAS,WAAA,GAAAN,sBAAA,CAAAH,OAAA;AACA,IAAAU,YAAA,GAAAP,sBAAA,CAAAH,OAAA;AAAuD,SAAAG,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAVvD;;AAQA;;AAIA;;AAIA;AACA,MAAMG,gBAA0D,GAAG;EACjEC,GAAG,EAAHA,YAAG;EACHC,IAAI,EAAJA,aAAI;EACJC,UAAU,EAAVA,mBAAU;EACVC,IAAI,EAAJA,aAAI;EACJC,GAAG,EAAHA,YAAG;EACHC,UAAU,EAAVA;AACF,CAAC;;AAED;AACA,MAAMC,aAAiD,GAAG;EACxD,aAAa,EAAEC,mBAAU;EACzB,cAAc,EAAEC;AAClB,CAAC;;AAED;;AAOA,IAAIC,mBAA+C,GAAG,IAAI;AAOnD,eAAeC,iBAAiBA,CAAC;EAAEC,KAAK;EAAEC;AAA2B,CAAC,EAAE;EAC7E,IAAI,CAACD,KAAK,IAAI,CAACC,MAAM,EAAE;IACrB,MAAM,IAAIC,KAAK,CAAC,uEAAuE,CAAC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","_css","_interopRequireDefault","_html","_javascript2","_json","_php","_typescript","_githubDark","_githubLight","e","__esModule","default","LANGUAGE_IMPORTS","css","html","javascript","json","php","typescript","THEME_IMPORTS","githubDark","githubLight","highlighterInstance","createHighlighter","langs","themes","Error","highlighter","lang","loadedLanguages","has","langData","loadLanguage","add","theme","loadedThemes","themeData","loadTheme","createHighlighterCore","engine","createJavaScriptRegexEngine","map","Set","error","console","processTokens","tokens","token","content","color","fontStyle","toString"],"sourceRoot":"../../../../src","sources":["syntax/highlighter/index.ts"],"mappings":";;;;;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAGA,IAAAE,IAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,KAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,YAAA,GAAAF,sBAAA,CAAAH,OAAA;AACA,IAAAM,KAAA,GAAAH,sBAAA,CAAAH,OAAA;AACA,IAAAO,IAAA,GAAAJ,sBAAA,CAAAH,OAAA;AACA,IAAAQ,WAAA,GAAAL,sBAAA,CAAAH,OAAA;AAGA,IAAAS,WAAA,GAAAN,sBAAA,CAAAH,OAAA;AACA,IAAAU,YAAA,GAAAP,sBAAA,CAAAH,OAAA;AAAuD,SAAAG,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAVvD;;AAQA;;AAIA;;AAIA;AACA,MAAMG,gBAA0D,GAAG;EACjEC,GAAG,EAAHA,YAAG;EACHC,IAAI,EAAJA,aAAI;EACJC,UAAU,EAAVA,oBAAU;EACVC,IAAI,EAAJA,aAAI;EACJC,GAAG,EAAHA,YAAG;EACHC,UAAU,EAAVA;AACF,CAAC;;AAED;AACA,MAAMC,aAAiD,GAAG;EACxD,aAAa,EAAEC,mBAAU;EACzB,cAAc,EAAEC;AAClB,CAAC;;AAED;;AAOA,IAAIC,mBAA+C,GAAG,IA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,EAAEF,KAAK,CAACE,KAAK,IAAI,SAAS;IAC/BC,SAAS,EAAEH,KAAK,CAACG,SAAS,EAAEC,QAAQ,CAAC;EACvC,CAAC,CAAC,CAAC;AACL","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
 
3
3
  import { createHighlighterCore } from 'shiki/core';
4
- import { createJavaScriptRegexEngine } from 'shiki/engine-javascript.mjs';
4
+ import { createJavaScriptRegexEngine } from 'shiki/engine/javascript';
5
5
 
6
6
  // Import languages
7
7
  import css from 'shiki/langs/css.mjs';
@@ -1 +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":";;AAEA,SAASA,qBAAqB,QAAQ,YAAY;AAClD,SAASC,2BAA2B,QAAQ,6BAA6B;;AAEzE;AACA,OAAOC,GAAG,MAAM,qBAAqB;AACrC,OAAOC,IAAI,MAAM,sBAAsB;AACvC,OAAOC,UAAU,MAAM,4BAA4B;AACnD,OAAOC,IAAI,MAAM,sBAAsB;AACvC,OAAOC,GAAG,MAAM,qBAAqB;AACrC,OAAOC,UAAU,MAAM,4BAA4B;;AAEnD;AACA,OAAOC,UAAU,MAAM,8BAA8B;AACrD,OAAOC,WAAW,MAAM,+BAA+B;;AAEvD;;AAIA;AACA,MAAMC,gBAA0D,GAAG;EACjER,GAAG;EACHC,IAAI;EACJC,UAAU;EACVC,IAAI;EACJC,GAAG;EACHC;AACF,CAAC;;AAED;AACA,MAAMI,aAAiD,GAAG;EACxD,aAAa,EAAEH,UAAU;EACzB,cAAc,EAAEC;AAClB,CAAC;;AAED;;AAOA,IAAIG,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ACC,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
+ {"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":";;AAEA,SAASA,qBAAqB,QAAQ,YAAY;AAClD,SAASC,2BAA2B,QAAQ,yBAAyB;;AAErE;AACA,OAAOC,GAAG,MAAM,qBAAqB;AACrC,OAAOC,IAAI,MAAM,sBAAsB;AACvC,OAAOC,UAAU,MAAM,4BAA4B;AACnD,OAAOC,IAAI,MAAM,sBAAsB;AACvC,OAAOC,GAAG,MAAM,qBAAqB;AACrC,OAAOC,UAAU,MAAM,4BAA4B;;AAEnD;AACA,OAAOC,UAAU,MAAM,8BAA8B;AACrD,OAAOC,WAAW,MAAM,+BAA+B;;AAEvD;;AAIA;AACA,MAAMC,gBAA0D,GAAG;EACjER,GAAG;EACHC,IAAI;EACJC,UAAU;EACVC,IAAI;EACJC,GAAG;EACHC;AACF,CAAC;;AAED;AACA,MAAMI,aAAiD,GAAG;EACxD,aAAa,EAAEH,UAAU;EACzB,cAAc,EAAEC;AAClB,CAAC;;AAED;;AAOA,IAAIG,mBAA+C,GAAG,IAAI;AAO1D,OAAO,eAAeC,iBAAiBA,CAAC;EAAEC,KAAK;EAAEC;AAA2B,CAAC,EAAE;EAC7E,IAAI,CAACD,KAAK,IAAI,CAACC,MAAM,EAAE;IACrB,MAAM,IAAIC,KAAK,CAAC,uEAAuE,CAAC;EAC1F;;E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
2
2
  "name": "rn-shiki",
3
3
  "type": "module",
4
- "version": "0.0.5",
4
+ "version": "0.0.7",
5
5
  "description": "Shiki syntax highlighter for React Native.",
6
6
  "author": "Ryan Skinner <hello@ryanskinner.com>",
7
7
  "license": "MIT",
@@ -26,9 +26,11 @@
26
26
  "react-native": "src/index",
27
27
  "source": "src/index",
28
28
  "files": [
29
- "babel.cjs",
30
- "babel.config.cjs",
31
29
  "lib",
30
+ "node_modules/shiki/core",
31
+ "node_modules/shiki/engine/javascript",
32
+ "node_modules/shiki/langs",
33
+ "node_modules/shiki/themes",
32
34
  "src"
33
35
  ],
34
36
  "scripts": {
@@ -43,14 +45,11 @@
43
45
  "shiki": "^1.1.7"
44
46
  },
45
47
  "dependencies": {
46
- "shiki": "^1.1.7",
47
- "tm-grammars": "^1.18.6",
48
- "tm-themes": "^1.9.0"
48
+ "shiki": "^1.1.7"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@antfu/eslint-config": "^3.8.0",
52
52
  "@babel/core": "^7.24.0",
53
- "@babel/plugin-transform-modules-commonjs": "^7.25.9",
54
53
  "@babel/preset-env": "^7.26.0",
55
54
  "@eslint-react/eslint-plugin": "^1.15.0",
56
55
  "@types/react": "^18.2.0",
@@ -58,7 +57,6 @@
58
57
  "eslint": "^9.13.0",
59
58
  "eslint-plugin-react-hooks": "^5.0.0",
60
59
  "eslint-plugin-react-refresh": "^0.4.13",
61
- "metro-react-native-babel-preset": "^0.77.0",
62
60
  "react": "^18.2.0",
63
61
  "react-native": "^0.73.0",
64
62
  "react-native-builder-bob": "^0.30.2",
@@ -3,36 +3,36 @@ import type { TokenType } from '../../types'
3
3
  import { createHighlighterCore } from 'shiki/core'
4
4
  import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'
5
5
 
6
- // Import grammar JSON files using require
7
- const cssGrammar = require('tm-grammars/grammars/css.json')
8
- const htmlGrammar = require('tm-grammars/grammars/html.json')
9
- const javascriptGrammar = require('tm-grammars/grammars/javascript.json')
10
- const jsonGrammar = require('tm-grammars/grammars/json.json')
11
- const phpGrammar = require('tm-grammars/grammars/php.json')
12
- const typescriptGrammar = require('tm-grammars/grammars/typescript.json')
13
-
14
- // Import theme JSON files using require
15
- const githubDarkTheme = require('tm-themes/themes/github-dark.json')
16
- const githubLightTheme = require('tm-themes/themes/github-light.json')
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
17
 
18
18
  // Define supported languages and themes explicitly
19
19
  export type SupportedLanguage = 'css' | 'html' | 'javascript' | 'json' | 'php' | 'typescript'
20
20
  export type SupportedTheme = 'github-dark' | 'github-light'
21
21
 
22
- // Use full grammar definitions
22
+ // Bundled languages mapping - using the imported grammars directly
23
23
  const LANGUAGE_IMPORTS: Record<SupportedLanguage, LanguageInput> = {
24
- css: cssGrammar,
25
- html: htmlGrammar,
26
- javascript: javascriptGrammar,
27
- json: jsonGrammar,
28
- php: phpGrammar,
29
- typescript: typescriptGrammar,
24
+ css,
25
+ html,
26
+ javascript,
27
+ json,
28
+ php,
29
+ typescript,
30
30
  }
31
31
 
32
- // Use full theme definitions
32
+ // Bundled themes mapping
33
33
  const THEME_IMPORTS: Record<SupportedTheme, ThemeInput> = {
34
- 'github-dark': githubDarkTheme,
35
- 'github-light': githubLightTheme,
34
+ 'github-dark': githubDark,
35
+ 'github-light': githubLight,
36
36
  }
37
37
 
38
38
  // Singleton highlighter instance with tracking
package/babel.cjs DELETED
@@ -1,150 +0,0 @@
1
- const path = require('node:path')
2
- const process = require('node:process')
3
-
4
- const DEFAULT_CONFIG = {
5
- languages: ['typescript', 'javascript', 'json', 'html', 'css', 'php'],
6
- themes: ['github-light', 'github-dark'],
7
- }
8
-
9
- function validateConfig(config) {
10
- const errors = []
11
-
12
- if (!Array.isArray(config.languages)) {
13
- errors.push('languages must be an array')
14
- }
15
- if (!Array.isArray(config.themes)) {
16
- errors.push('themes must be an array')
17
- }
18
-
19
- if (config.languages?.length) {
20
- config.languages.forEach((lang) => {
21
- if (typeof lang !== 'string') {
22
- errors.push(`Invalid language: ${lang}. Must be a string.`)
23
- }
24
- })
25
- }
26
-
27
- if (config.themes?.length) {
28
- config.themes.forEach((theme) => {
29
- if (typeof theme !== 'string') {
30
- errors.push(`Invalid theme: ${theme}. Must be a string.`)
31
- }
32
- })
33
- }
34
-
35
- if (errors.length > 0) {
36
- throw new Error(`Invalid rn-shiki config:\n${errors.join('\n')}`)
37
- }
38
- }
39
-
40
- function mergeConfigs(userConfig = {}) {
41
- return {
42
- languages: [...new Set([...DEFAULT_CONFIG.languages, ...(userConfig.languages || [])])],
43
- themes: [...new Set([...DEFAULT_CONFIG.themes, ...(userConfig.themes || [])])],
44
- }
45
- }
46
-
47
- function loadProjectConfig() {
48
- try {
49
- const configPath = path.resolve(process.cwd(), 'rn-shiki.config.js')
50
- return require(configPath)
51
- }
52
- catch (error) {
53
- if (error.code !== 'MODULE_NOT_FOUND') {
54
- console.warn('Error loading rn-shiki.config.js:', error.message)
55
- }
56
- return {}
57
- }
58
- }
59
-
60
- function createResourceImport(t, type, name) {
61
- return t.objectProperty(
62
- t.stringLiteral(name),
63
- t.callExpression(
64
- t.identifier('require'),
65
- [t.stringLiteral(`shiki/${type}/${name}.mjs`)],
66
- ),
67
- )
68
- }
69
-
70
- module.exports = function (babel) {
71
- const { types: t } = babel
72
-
73
- return {
74
- name: 'rn-shiki-transform',
75
- visitor: {
76
- ImportDeclaration(path, state) {
77
- // Merge configurations with defaults
78
- const config = mergeConfigs({
79
- ...loadProjectConfig(),
80
- ...(state.opts?.shiki || state.opts || {}),
81
- })
82
-
83
- try {
84
- validateConfig(config)
85
- }
86
- catch (error) {
87
- throw path.buildCodeFrameError(error.message)
88
- }
89
-
90
- // Handle direct shiki resource imports
91
- if (path.node.source.value.startsWith('shiki/')) {
92
- const match = path.node.source.value.match(/shiki\/(langs|themes)\/(.+)\.mjs/)
93
- if (match) {
94
- const [, type, name] = match
95
- const configKey = type === 'langs' ? 'languages' : 'themes'
96
-
97
- if (!config[configKey].includes(name)) {
98
- throw path.buildCodeFrameError(
99
- `${type === 'langs' ? 'Language' : 'Theme'} "${name}" is not configured.\n`
100
- + `Configure it in rn-shiki.config.js or babel plugin options.\n`
101
- + `Available ${configKey}: ${config[configKey].join(', ')}`,
102
- )
103
- }
104
- }
105
- }
106
-
107
- // Handle shiki package imports
108
- if (path.node.source.value === 'shiki') {
109
- // Transform bundledLanguages
110
- const langSpec = path.node.specifiers.find(
111
- spec => spec.imported?.name === 'bundledLanguages'
112
- || spec.local?.name === 'bundledLanguages',
113
- )
114
-
115
- if (langSpec) {
116
- const languagesObject = t.objectExpression(
117
- config.languages.map(lang => createResourceImport(t, 'langs', lang)),
118
- )
119
-
120
- const binding = path.scope.getBinding(langSpec.local.name)
121
- if (binding) {
122
- binding.referencePaths.forEach((refPath) => {
123
- refPath.replaceWith(languagesObject)
124
- })
125
- }
126
- }
127
-
128
- // Transform bundledThemes
129
- const themeSpec = path.node.specifiers.find(
130
- spec => spec.imported?.name === 'bundledThemes'
131
- || spec.local?.name === 'bundledThemes',
132
- )
133
-
134
- if (themeSpec) {
135
- const themesObject = t.objectExpression(
136
- config.themes.map(theme => createResourceImport(t, 'themes', theme)),
137
- )
138
-
139
- const binding = path.scope.getBinding(themeSpec.local.name)
140
- if (binding) {
141
- binding.referencePaths.forEach((refPath) => {
142
- refPath.replaceWith(themesObject)
143
- })
144
- }
145
- }
146
- }
147
- },
148
- },
149
- }
150
- }
package/babel.config.cjs DELETED
@@ -1,14 +0,0 @@
1
- module.exports = {
2
- presets: [
3
- [
4
- '@babel/preset-env',
5
- {
6
- targets: {
7
- node: 'current',
8
- },
9
- },
10
- ],
11
- '@babel/preset-typescript',
12
- ],
13
- plugins: ['@babel/plugin-transform-modules-commonjs', '@babel/plugin-transform-runtime'],
14
- }