react-native-codepad-lang-javascript 0.0.0-stage → 0.1.1
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.
- package/CodepadLangJavascript.podspec +28 -0
- package/README.md +79 -2
- package/android/CMakeLists.txt +15 -0
- package/android/build.gradle +61 -0
- package/android/consumer-rules.pro +1 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/assets/codepad-languages/javascript +1 -0
- package/android/src/main/cpp/lang.c +10 -0
- package/android/src/main/java/me/sectiontn/codepad/lang/javascript/CodepadLangJavascriptPackage.kt +13 -0
- package/android/src/main/java/me/sectiontn/codepad/lang/javascript/JavascriptLanguage.kt +863 -0
- package/grammar/LICENSE +21 -0
- package/grammar/src/parser.c +94268 -0
- package/grammar/src/scanner.c +364 -0
- package/grammar/src/tree_sitter/alloc.h +54 -0
- package/grammar/src/tree_sitter/array.h +291 -0
- package/grammar/src/tree_sitter/parser.h +286 -0
- package/ios/CPLangJavascript.h +11 -0
- package/ios/CPLangJavascript.swift +856 -0
- package/package.json +40 -4
- package/queries/javascript/highlights.scm +608 -0
- package/queries/javascript/indents.scm +107 -0
- package/queries/javascript/injections.scm +234 -0
- package/queries/javascript/locals.scm +121 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "CodepadLangJavascript"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = package["author"]
|
|
12
|
+
s.platforms = { :ios => "17.0" }
|
|
13
|
+
s.source = { :git => "https://github.com/SectionTN/react-native-codepad.git", :tag => "v#{s.version}" }
|
|
14
|
+
|
|
15
|
+
s.source_files = ["ios/*.{h,swift}", "grammar/src/parser.c", "grammar/src/scanner.c"]
|
|
16
|
+
s.public_header_files = "ios/*.h"
|
|
17
|
+
s.preserve_paths = "grammar/**/*"
|
|
18
|
+
s.compiler_flags = "-w"
|
|
19
|
+
s.pod_target_xcconfig = {
|
|
20
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/grammar/src\"",
|
|
21
|
+
"GCC_OPTIMIZATION_LEVEL" => "1",
|
|
22
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
23
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
24
|
+
"DEFINES_MODULE" => "YES",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
s.dependency "Codepad"
|
|
28
|
+
end
|
package/README.md
CHANGED
|
@@ -1,3 +1,80 @@
|
|
|
1
|
-
#
|
|
1
|
+
# react-native-codepad-lang-javascript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Generated package. Do not edit by hand; run `yarn gen:languages` in the react-native-codepad repository.
|
|
4
|
+
|
|
5
|
+
Grammar: tree-sitter/tree-sitter-javascript at 58404d8cf191d69f2674a8fd507bd5776f46cb11. Queries: nvim-treesitter at e289100ff98969e118c702199d88b764ce9e7fdf.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
yarn add react-native-codepad react-native-codepad-lang-javascript
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Then pass `language="javascript"` to `CodeEditor`. Theme token keys this package produces:
|
|
14
|
+
|
|
15
|
+
### javascript
|
|
16
|
+
|
|
17
|
+
- `attribute`
|
|
18
|
+
- `boolean`
|
|
19
|
+
- `character.special`
|
|
20
|
+
- `comment`
|
|
21
|
+
- `comment.documentation`
|
|
22
|
+
- `constant`
|
|
23
|
+
- `constant.builtin`
|
|
24
|
+
- `constructor`
|
|
25
|
+
- `function`
|
|
26
|
+
- `function.builtin`
|
|
27
|
+
- `function.call`
|
|
28
|
+
- `function.method`
|
|
29
|
+
- `function.method.call`
|
|
30
|
+
- `keyword`
|
|
31
|
+
- `keyword.conditional`
|
|
32
|
+
- `keyword.conditional.ternary`
|
|
33
|
+
- `keyword.coroutine`
|
|
34
|
+
- `keyword.directive`
|
|
35
|
+
- `keyword.exception`
|
|
36
|
+
- `keyword.function`
|
|
37
|
+
- `keyword.import`
|
|
38
|
+
- `keyword.operator`
|
|
39
|
+
- `keyword.repeat`
|
|
40
|
+
- `keyword.return`
|
|
41
|
+
- `keyword.type`
|
|
42
|
+
- `label`
|
|
43
|
+
- `markup.heading`
|
|
44
|
+
- `markup.heading.1`
|
|
45
|
+
- `markup.heading.2`
|
|
46
|
+
- `markup.heading.3`
|
|
47
|
+
- `markup.heading.4`
|
|
48
|
+
- `markup.heading.5`
|
|
49
|
+
- `markup.heading.6`
|
|
50
|
+
- `markup.italic`
|
|
51
|
+
- `markup.link.label`
|
|
52
|
+
- `markup.raw`
|
|
53
|
+
- `markup.strikethrough`
|
|
54
|
+
- `markup.strong`
|
|
55
|
+
- `markup.underline`
|
|
56
|
+
- `module`
|
|
57
|
+
- `module.builtin`
|
|
58
|
+
- `none`
|
|
59
|
+
- `number`
|
|
60
|
+
- `operator`
|
|
61
|
+
- `punctuation.bracket`
|
|
62
|
+
- `punctuation.delimiter`
|
|
63
|
+
- `punctuation.special`
|
|
64
|
+
- `spell`
|
|
65
|
+
- `string`
|
|
66
|
+
- `string.escape`
|
|
67
|
+
- `string.regexp`
|
|
68
|
+
- `string.special.url`
|
|
69
|
+
- `tag`
|
|
70
|
+
- `tag.attribute`
|
|
71
|
+
- `tag.builtin`
|
|
72
|
+
- `tag.delimiter`
|
|
73
|
+
- `type`
|
|
74
|
+
- `type.builtin`
|
|
75
|
+
- `variable`
|
|
76
|
+
- `variable.builtin`
|
|
77
|
+
- `variable.member`
|
|
78
|
+
- `variable.parameter`
|
|
79
|
+
|
|
80
|
+
See the [languages guide](https://sectiontn.github.io/react-native-codepad/guides/languages/) for aliases, injections and themes.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.13)
|
|
2
|
+
project(codepad_lang_javascript C)
|
|
3
|
+
set(GRAMMAR ${CMAKE_SOURCE_DIR}/../grammar)
|
|
4
|
+
|
|
5
|
+
add_library(codepad_lang_javascript SHARED
|
|
6
|
+
src/main/cpp/lang.c
|
|
7
|
+
${GRAMMAR}/src/parser.c
|
|
8
|
+
${GRAMMAR}/src/scanner.c
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
target_include_directories(codepad_lang_javascript PRIVATE ${GRAMMAR}/src)
|
|
12
|
+
|
|
13
|
+
# Parser tables are data. -O1 keeps large grammars from taking minutes to compile.
|
|
14
|
+
set_source_files_properties(${GRAMMAR}/src/parser.c PROPERTIES COMPILE_OPTIONS "-O1")
|
|
15
|
+
target_compile_options(codepad_lang_javascript PRIVATE -std=c11 -O2 -fvisibility=hidden -w)
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
repositories {
|
|
3
|
+
google()
|
|
4
|
+
mavenCentral()
|
|
5
|
+
}
|
|
6
|
+
dependencies {
|
|
7
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
8
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.0.21"
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
apply plugin: "com.android.library"
|
|
13
|
+
if (project.extensions.findByName("kotlin") == null) {
|
|
14
|
+
apply plugin: "kotlin-android"
|
|
15
|
+
}
|
|
16
|
+
apply plugin: "com.facebook.react"
|
|
17
|
+
|
|
18
|
+
def safeExtGet(prop, fallback) {
|
|
19
|
+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
def reactNativeArchitectures() {
|
|
23
|
+
def value = rootProject.getProperties().get("reactNativeArchitectures")
|
|
24
|
+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
android {
|
|
28
|
+
namespace "me.sectiontn.codepad.lang.javascript"
|
|
29
|
+
compileSdkVersion safeExtGet("compileSdkVersion", 36)
|
|
30
|
+
|
|
31
|
+
defaultConfig {
|
|
32
|
+
minSdkVersion safeExtGet("minSdkVersion", 24)
|
|
33
|
+
consumerProguardFiles "consumer-rules.pro"
|
|
34
|
+
externalNativeBuild {
|
|
35
|
+
cmake {
|
|
36
|
+
arguments "-DANDROID_STL=none", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
|
|
37
|
+
abiFilters(*reactNativeArchitectures())
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (rootProject.ext.has("ndkVersion")) {
|
|
43
|
+
ndkVersion rootProject.ext.ndkVersion
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
externalNativeBuild {
|
|
47
|
+
cmake {
|
|
48
|
+
path "CMakeLists.txt"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
compileOptions {
|
|
53
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
54
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
dependencies {
|
|
59
|
+
implementation "com.facebook.react:react-android"
|
|
60
|
+
implementation project(":react-native-codepad")
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
-keep class me.sectiontn.codepad.lang.javascript.JavascriptLanguage { *; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.1.1
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#include <jni.h>
|
|
2
|
+
#include <stdint.h>
|
|
3
|
+
|
|
4
|
+
const void *tree_sitter_javascript(void);
|
|
5
|
+
|
|
6
|
+
JNIEXPORT jlong JNICALL Java_me_sectiontn_codepad_lang_javascript_JavascriptLanguage_nativeLanguage(JNIEnv *env, jobject thiz) {
|
|
7
|
+
(void) env;
|
|
8
|
+
(void) thiz;
|
|
9
|
+
return (jlong) (intptr_t) tree_sitter_javascript();
|
|
10
|
+
}
|
package/android/src/main/java/me/sectiontn/codepad/lang/javascript/CodepadLangJavascriptPackage.kt
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
package me.sectiontn.codepad.lang.javascript
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
7
|
+
|
|
8
|
+
// Empty package so React Native autolinking includes this Gradle module.
|
|
9
|
+
class CodepadLangJavascriptPackage : BaseReactPackage() {
|
|
10
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? = null
|
|
11
|
+
|
|
12
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider { HashMap() }
|
|
13
|
+
}
|