@apollohg/react-native-rich-text-editor-code-highlighting 2.0.0

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.
Files changed (29) hide show
  1. package/LICENSE +160 -0
  2. package/NativeEditorCodeHighlighting.podspec +24 -0
  3. package/README.md +47 -0
  4. package/RUST-STANDARD-LIBRARY-NOTICES.html +8266 -0
  5. package/THIRD_PARTY_NOTICES.md +18451 -0
  6. package/android/build.gradle +25 -0
  7. package/android/consumer-rules.pro +1 -0
  8. package/android/src/main/AndroidManifest.xml +1 -0
  9. package/android/src/main/java/com/apollohg/editor/highlighting/NativeCodeHighlightingModule.kt +17 -0
  10. package/android/src/main/java/com/apollohg/editor/highlighting/SyntectHighlightingProvider.kt +23 -0
  11. package/android/src/main/java/uniffi/native_editor_highlighting/native_editor_highlighting.kt +1259 -0
  12. package/android/src/main/jniLibs/arm64-v8a/libnative_editor_highlighting.so +0 -0
  13. package/android/src/main/jniLibs/armeabi-v7a/libnative_editor_highlighting.so +0 -0
  14. package/android/src/main/jniLibs/x86/libnative_editor_highlighting.so +0 -0
  15. package/android/src/main/jniLibs/x86_64/libnative_editor_highlighting.so +0 -0
  16. package/dist/index.d.ts +7 -0
  17. package/dist/index.js +25 -0
  18. package/expo-module.config.json +10 -0
  19. package/ios/Generated_highlighting.swift +728 -0
  20. package/ios/NativeCodeHighlightingModule.swift +14 -0
  21. package/ios/NativeEditorHighlighting.xcframework/Info.plist +44 -0
  22. package/ios/NativeEditorHighlighting.xcframework/ios-arm64/libnative_editor_highlighting.a +0 -0
  23. package/ios/NativeEditorHighlighting.xcframework/ios-arm64_x86_64-simulator/libnative_editor_highlighting.a +0 -0
  24. package/ios/SyntectHighlightingProvider.swift +12 -0
  25. package/ios/native_editor_highlightingFFI/module.modulemap +7 -0
  26. package/ios/native_editor_highlightingFFI/native_editor_highlightingFFI.h +551 -0
  27. package/package.json +49 -0
  28. package/scripts/verify-package.mjs +19 -0
  29. package/src/index.ts +41 -0
@@ -0,0 +1,19 @@
1
+ import { existsSync } from 'node:fs';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ const root = fileURLToPath(new URL('..', import.meta.url));
5
+ const required = [
6
+ 'LICENSE', 'THIRD_PARTY_NOTICES.md', 'RUST-STANDARD-LIBRARY-NOTICES.html',
7
+ 'dist/index.js', 'dist/index.d.ts',
8
+ 'ios/Generated_highlighting.swift',
9
+ 'ios/native_editor_highlightingFFI/module.modulemap',
10
+ 'ios/NativeEditorHighlighting.xcframework/Info.plist',
11
+ 'ios/NativeEditorHighlighting.xcframework/ios-arm64/libnative_editor_highlighting.a',
12
+ 'ios/NativeEditorHighlighting.xcframework/ios-arm64_x86_64-simulator/libnative_editor_highlighting.a',
13
+ 'android/src/main/java/uniffi/native_editor_highlighting/native_editor_highlighting.kt',
14
+ ...['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'].map(
15
+ (abi) => `android/src/main/jniLibs/${abi}/libnative_editor_highlighting.so`
16
+ ),
17
+ ];
18
+ const missing = required.filter((path) => !existsSync(`${root}/${path}`));
19
+ if (missing.length) throw new Error(`Build the package before packing. Missing: ${missing.join(', ')}`);
package/src/index.ts ADDED
@@ -0,0 +1,41 @@
1
+ import { requireNativeModule } from 'expo-modules-core';
2
+ import type { CodeHighlightingAddon } from '@apollohg/react-native-rich-text-editor';
3
+
4
+ const nativeModule = requireNativeModule<{ initialize(): number }>('NativeCodeHighlighting');
5
+ if (nativeModule.initialize() !== 1) {
6
+ throw new Error(
7
+ 'Code highlighting requires native provider interface version 1. Rebuild the app.'
8
+ );
9
+ }
10
+
11
+ export const codeHighlightingThemes = Object.freeze([
12
+ 'base16-ocean.dark',
13
+ 'base16-eighties.dark',
14
+ 'base16-mocha.dark',
15
+ 'base16-ocean.light',
16
+ 'InspiredGitHub',
17
+ 'Solarized (dark)',
18
+ 'Solarized (light)',
19
+ ] as const);
20
+
21
+ export type CodeHighlightingTheme = (typeof codeHighlightingThemes)[number];
22
+
23
+ export interface CodeHighlightingOptions {
24
+ readonly theme: CodeHighlightingTheme;
25
+ }
26
+
27
+ export function createCodeHighlightingAddon(
28
+ options: CodeHighlightingOptions
29
+ ): CodeHighlightingAddon {
30
+ if (!options || !codeHighlightingThemes.includes(options.theme)) {
31
+ throw new Error(
32
+ 'Unsupported code-highlighting theme. Use a name from codeHighlightingThemes.'
33
+ );
34
+ }
35
+ return Object.freeze({
36
+ id: 'code-highlighting',
37
+ version: 1,
38
+ capability: 'code-highlighting',
39
+ options: Object.freeze({ provider: 'syntect', theme: options.theme }),
40
+ });
41
+ }