rn-shiki 0.0.19 → 0.0.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/build.js +3 -42
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rn-shiki",
3
3
  "type": "module",
4
- "version": "0.0.19",
4
+ "version": "0.0.20",
5
5
  "description": "Shiki syntax highlighter for React Native.",
6
6
  "author": "Ryan Skinner <hello@ryanskinner.com>",
7
7
  "license": "MIT",
package/scripts/build.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from 'node:fs'
2
2
  import path from 'node:path'
3
3
  import { fileURLToPath } from 'node:url'
4
+
4
5
  import esbuild from 'esbuild'
5
6
 
6
7
  const __dirname = path.dirname(fileURLToPath(import.meta.url))
@@ -35,12 +36,7 @@ async function buildModule(inputPath, outputPath, name) {
35
36
 
36
37
  // Process themes
37
38
  if (inputPath.includes('/themes/')) {
38
- const themePatterns = [
39
- /export\s+default\s+(\{[\s\S]*?\});?\s*$/,
40
- /JSON\.parse\('(.+?)'\)/,
41
- /exports\.default\s*=\s*(\{[\s\S]*?\});?\s*$/,
42
- /module\.exports\s*=\s*(\{[\s\S]*?\});?\s*$/,
43
- ]
39
+ const themePatterns = [/export\s+default\s+(\{[\s\S]*?\});?\s*$/, /JSON\.parse\('(.+?)'\)/, /exports\.default\s*=\s*(\{[\s\S]*?\});?\s*$/, /module\.exports\s*=\s*(\{[\s\S]*?\});?\s*$/]
44
40
 
45
41
  let themeData = null
46
42
  for (const pattern of themePatterns) {
@@ -68,11 +64,7 @@ async function buildModule(inputPath, outputPath, name) {
68
64
  }
69
65
  else {
70
66
  // Fall back to processing the bundle
71
- const langPatterns = [
72
- /export\s+default\s+(\[[\s\S]*?\]);?\s*$/m,
73
- /exports\.default\s*=\s*(\[[\s\S]*?\]);?\s*$/m,
74
- /module\.exports\s*=\s*(\[[\s\S]*?\]);?\s*$/m,
75
- ]
67
+ const langPatterns = [/export\s+default\s+(\[[\s\S]*?\]);?\s*$/m, /exports\.default\s*=\s*(\[[\s\S]*?\]);?\s*$/m, /module\.exports\s*=\s*(\[[\s\S]*?\]);?\s*$/m]
76
68
 
77
69
  let langData = null
78
70
  for (const pattern of langPatterns) {
@@ -146,34 +138,6 @@ export default ${finalName}`
146
138
  fs.writeFileSync(dtsPath, dtsContent)
147
139
  }
148
140
 
149
- function createIndexTypes() {
150
- const indexDts = path.join(VENDOR_DIR, 'index.d.ts')
151
- const content = `\
152
- import type { ThemeInput, LanguageInput } from 'shiki'
153
-
154
- export * from './core/core'
155
- export * from './core/engine-javascript'
156
-
157
- export declare const themes: Record<string, ThemeInput>
158
- export declare const languages: Record<string, LanguageInput>
159
- `
160
- fs.writeFileSync(indexDts, content)
161
-
162
- // Create the actual index.js file
163
- const indexJs = path.join(VENDOR_DIR, 'index.js')
164
- const jsContent = `\
165
- "use strict";
166
- Object.defineProperty(exports, "__esModule", { value: true });
167
-
168
- export * from './core/core';
169
- export * from './core/engine-javascript';
170
-
171
- export const themes = {};
172
- export const languages = {};
173
- `
174
- fs.writeFileSync(indexJs, jsContent)
175
- }
176
-
177
141
  const shikiDir = path.join(__dirname, '../node_modules/shiki/dist')
178
142
  const langFiles = fs
179
143
  .readdirSync(path.join(shikiDir, 'langs'))
@@ -262,8 +226,5 @@ for (const module of modules) {
262
226
  }
263
227
  }
264
228
 
265
- // Create index types file
266
- createIndexTypes()
267
-
268
229
  // Write manifest
269
230
  fs.writeFileSync(path.join(VENDOR_DIR, 'manifest.json'), JSON.stringify(manifest, null, 2))