@kbach/react-native 1.0.0-beta.2 → 1.0.0-beta.4
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/README.md +59 -26
- package/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +14 -0
- package/android/src/main/java/com/kbachnative/KbachModule.kt +83 -0
- package/android/src/main/java/com/kbachnative/KbachPackage.kt +54 -0
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-4KCCEMEN.mjs +66 -0
- package/dist/{chunk-YHF3QLRL.mjs → chunk-AEVOM2NB.mjs} +9 -12
- package/dist/{chunk-SVMYVXY6.mjs → chunk-DLIXI5OW.mjs} +23 -14
- package/dist/chunk-FG5E4NLJ.mjs +18 -0
- package/dist/chunk-KSDFO34H.mjs +32 -0
- package/dist/chunk-OJQAJLYT.mjs +14 -0
- package/dist/chunk-ZUE6SCTE.mjs +14 -0
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +9 -2
- package/dist/index.mjs +9 -57
- package/dist/index.web.d.mts +7 -0
- package/dist/index.web.d.ts +7 -0
- package/dist/index.web.js +488 -0
- package/dist/index.web.mjs +32 -0
- package/dist/jsx-dev-runtime.d.mts +3 -12
- package/dist/jsx-dev-runtime.d.ts +3 -12
- package/dist/jsx-dev-runtime.js +61 -47
- package/dist/jsx-dev-runtime.mjs +8 -11
- package/dist/jsx-dev-runtime.web.d.mts +10 -0
- package/dist/jsx-dev-runtime.web.d.ts +10 -0
- package/dist/jsx-dev-runtime.web.js +437 -0
- package/dist/jsx-dev-runtime.web.mjs +17 -0
- package/dist/jsx-runtime.d.mts +3 -23
- package/dist/jsx-runtime.d.ts +3 -23
- package/dist/jsx-runtime.js +51 -38
- package/dist/jsx-runtime.mjs +6 -3
- package/dist/jsx-runtime.web.d.mts +7 -0
- package/dist/jsx-runtime.web.d.ts +7 -0
- package/dist/jsx-runtime.web.js +426 -0
- package/dist/jsx-runtime.web.mjs +14 -0
- package/package.json +27 -6
- package/react-native.config.js +29 -0
- package/specs/NativeKbachModule.ts +31 -0
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbach/react-native",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
4
|
-
"description": "Kbach's utility-class styling engine for React Native — the same class names as @kbach/react, resolved to a StyleSheet-ready style object via a Kotlin/JNI TurboModule.
|
|
5
|
-
"keywords": ["css", "react-native", "expo", "tailwind", "utility-first", "styling", "android"],
|
|
3
|
+
"version": "1.0.0-beta.4",
|
|
4
|
+
"description": "Kbach's utility-class styling engine for React Native — the same class names as @kbach/react, resolved to a StyleSheet-ready style object via a Kotlin/JNI TurboModule (native) or the same WASM engine @kbach/react uses (Expo Web / react-native-web). Ships its own native Android module — one npm install, no separate native package. Beta. Native is Android-only (no iOS bridge yet); works with the React Native CLI or an Expo dev client (not Expo Go, which cannot load any custom native module).",
|
|
5
|
+
"keywords": ["css", "react-native", "expo", "tailwind", "utility-first", "styling", "android", "web", "wasm"],
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"author": "semsakadanupol",
|
|
8
8
|
"repository": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|
|
19
19
|
},
|
|
20
|
-
"files": ["dist", "src/babel-plugin.js"],
|
|
20
|
+
"files": ["dist", "src/babel-plugin.js", "android/build.gradle", "android/src", "specs", "react-native.config.js"],
|
|
21
21
|
"source": "./src/index.ts",
|
|
22
22
|
"main": "./dist/index.js",
|
|
23
23
|
"module": "./dist/index.mjs",
|
|
@@ -26,18 +26,30 @@
|
|
|
26
26
|
".": {
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
28
|
"source": "./src/index.ts",
|
|
29
|
+
"browser": {
|
|
30
|
+
"import": "./dist/index.web.mjs",
|
|
31
|
+
"require": "./dist/index.web.js"
|
|
32
|
+
},
|
|
29
33
|
"import": "./dist/index.mjs",
|
|
30
34
|
"require": "./dist/index.js"
|
|
31
35
|
},
|
|
32
36
|
"./jsx-runtime": {
|
|
33
37
|
"types": "./dist/jsx-runtime.d.ts",
|
|
34
38
|
"source": "./src/jsx-runtime.tsx",
|
|
39
|
+
"browser": {
|
|
40
|
+
"import": "./dist/jsx-runtime.web.mjs",
|
|
41
|
+
"require": "./dist/jsx-runtime.web.js"
|
|
42
|
+
},
|
|
35
43
|
"import": "./dist/jsx-runtime.mjs",
|
|
36
44
|
"require": "./dist/jsx-runtime.js"
|
|
37
45
|
},
|
|
38
46
|
"./jsx-dev-runtime": {
|
|
39
47
|
"types": "./dist/jsx-dev-runtime.d.ts",
|
|
40
48
|
"source": "./src/jsx-dev-runtime.tsx",
|
|
49
|
+
"browser": {
|
|
50
|
+
"import": "./dist/jsx-dev-runtime.web.mjs",
|
|
51
|
+
"require": "./dist/jsx-dev-runtime.web.js"
|
|
52
|
+
},
|
|
41
53
|
"import": "./dist/jsx-dev-runtime.mjs",
|
|
42
54
|
"require": "./dist/jsx-dev-runtime.js"
|
|
43
55
|
},
|
|
@@ -48,10 +60,11 @@
|
|
|
48
60
|
"dev": "tsup --watch",
|
|
49
61
|
"test": "vitest run --passWithNoTests",
|
|
50
62
|
"lint": "tsc --noEmit",
|
|
51
|
-
"generate:colors": "node ../core-engine/scripts/generate-palette.mjs src/generatedPalette.ts"
|
|
63
|
+
"generate:colors": "node ../core-engine/scripts/generate-palette.mjs src/generatedPalette.ts",
|
|
64
|
+
"generate:wasm-base64": "node ../core-engine/scripts/generate-wasm-base64.mjs src/wasmBinary.generated.ts"
|
|
52
65
|
},
|
|
53
66
|
"dependencies": {
|
|
54
|
-
"@kbach/
|
|
67
|
+
"@kbach/core-engine": "1.0.0-beta.0"
|
|
55
68
|
},
|
|
56
69
|
"devDependencies": {
|
|
57
70
|
"@types/react": "^19.2.0",
|
|
@@ -65,5 +78,13 @@
|
|
|
65
78
|
"peerDependencies": {
|
|
66
79
|
"react": ">=18.0.0",
|
|
67
80
|
"react-native": ">=0.70.0"
|
|
81
|
+
},
|
|
82
|
+
"codegenConfig": {
|
|
83
|
+
"name": "KbachSpec",
|
|
84
|
+
"type": "modules",
|
|
85
|
+
"jsSrcsDir": "specs",
|
|
86
|
+
"android": {
|
|
87
|
+
"javaPackageName": "com.kbachnative"
|
|
88
|
+
}
|
|
68
89
|
}
|
|
69
90
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Explicit override for React Native autolinking's Android package
|
|
3
|
+
* detection, which otherwise guesses `<packageName>.<PackageClassName>`
|
|
4
|
+
* from either AndroidManifest.xml's `package` attribute or (when absent,
|
|
5
|
+
* our case) build.gradle's `namespace` — see cli-config-android's
|
|
6
|
+
* getPackageName. That guess is wrong here on purpose: KbachModule.kt/
|
|
7
|
+
* KbachPackage.kt declare `package com.kbachnative` (chosen to match the
|
|
8
|
+
* JNI extern symbol names in packages/core-engine/src/jni_bridge.rs), but
|
|
9
|
+
* this module's Gradle `namespace` has to be a DIFFERENT value
|
|
10
|
+
* (com.kbachnative.nativemodule, see android/build.gradle's own comment)
|
|
11
|
+
* since AGP requires unique namespaces per module and the consuming app
|
|
12
|
+
* itself already claims "com.kbachnative" as its own. Without this
|
|
13
|
+
* override, the generated PackageList.java imports the non-existent
|
|
14
|
+
* `com.kbachnative.nativemodule.KbachPackage` and the app fails to
|
|
15
|
+
* compile. (A `package="com.kbachnative"` attribute in AndroidManifest.xml
|
|
16
|
+
* was tried first instead — simpler on paper — but AGP 9+ hard-errors on a
|
|
17
|
+
* manifest package that doesn't match the namespace, so this explicit
|
|
18
|
+
* config override is the only working fix.)
|
|
19
|
+
*/
|
|
20
|
+
module.exports = {
|
|
21
|
+
dependency: {
|
|
22
|
+
platforms: {
|
|
23
|
+
android: {
|
|
24
|
+
packageImportPath: 'import com.kbachnative.KbachPackage;',
|
|
25
|
+
packageInstance: 'new KbachPackage()',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TurboModule spec for KbachModule — RN's Codegen convention requires this
|
|
3
|
+
* exact `Native<Name>.ts` filename and a default-exported
|
|
4
|
+
* `TurboModuleRegistry.getEnforcing<Spec>(...)`. Read by Codegen (see this
|
|
5
|
+
* package's own `codegenConfig` in package.json) to generate the native
|
|
6
|
+
* glue that ../android/src/main/java/com/kbachnative/KbachModule.kt
|
|
7
|
+
* implements. Lives in this same package (not the consuming app) alongside
|
|
8
|
+
* the native Android code it describes — Android autolinking only
|
|
9
|
+
* discovers native modules from npm dependencies with their own `android/`
|
|
10
|
+
* folder, not from native code declared directly inside an app, which is
|
|
11
|
+
* why `@kbach/react-native` ships its own `android/` + `specs/` at all
|
|
12
|
+
* (see Phase 13) rather than relying on the consuming app to provide one.
|
|
13
|
+
*
|
|
14
|
+
* Method names have no `Sync` suffix (unlike the pre-Phase-13 bridge's
|
|
15
|
+
* `generateCssSync`/`resolveStyleSync`) — every TurboModule call is
|
|
16
|
+
* synchronous by nature via JSI, so the suffix's whole point (flagging
|
|
17
|
+
* "this one blocks, unlike normal bridge methods") no longer applies.
|
|
18
|
+
*/
|
|
19
|
+
import type { TurboModule } from 'react-native';
|
|
20
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
21
|
+
|
|
22
|
+
export interface Spec extends TurboModule {
|
|
23
|
+
generateCss(classString: string, themeJson: string): string;
|
|
24
|
+
// `width`: a plain `number` (not the `Int32`/`Float` CodegenTypes
|
|
25
|
+
// aliases) is Codegen's own default float-numeric mapping — it already
|
|
26
|
+
// compiles to Kotlin's `Double` on the native side, matching
|
|
27
|
+
// KbachModule.kt's `width: Double` parameter with no extra type alias.
|
|
28
|
+
resolveStyle(classString: string, themeJson: string, colorScheme: string, pressed: boolean, width: number): string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('KbachModule');
|