@kbach/core-engine 1.0.0-beta.0 → 1.0.0-beta.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/README.md CHANGED
@@ -3,10 +3,16 @@
3
3
  The Rust/WASM utility-resolution engine that powers
4
4
  [`@kbach/react`](https://www.npmjs.com/package/@kbach/react).
5
5
 
6
- > **Beta.** This package is an internal dependency of `@kbach/react` and
7
- > `@kbach/react-native`. If you're building a React app, install
8
- > `@kbach/react` instead — it re-exports everything you need and pulls this
9
- > package in automatically.
6
+ > **Beta.** This package is an internal dependency of `@kbach/react` (the
7
+ > web package — this build is the browser/Node WASM target). If you're
8
+ > building a React web app, install `@kbach/react` instead — it re-exports
9
+ > everything you need and pulls this package in automatically.
10
+ > `@kbach/react-native` does NOT depend on this package directly: on
11
+ > Android the same Rust source (`src/jni_bridge.rs`) is instead
12
+ > cross-compiled ahead of time to a native `.so` (JNI, not WASM) and shipped
13
+ > prebuilt inside `@kbach/react-native`'s own `android/` folder — see
14
+ > `scripts/build-android.mjs` in this package for how that binary gets
15
+ > (re)generated.
10
16
 
11
17
  ## What this is
12
18
 
package/dist/README.md CHANGED
@@ -3,10 +3,16 @@
3
3
  The Rust/WASM utility-resolution engine that powers
4
4
  [`@kbach/react`](https://www.npmjs.com/package/@kbach/react).
5
5
 
6
- > **Beta.** This package is an internal dependency of `@kbach/react` and
7
- > `@kbach/react-native`. If you're building a React app, install
8
- > `@kbach/react` instead — it re-exports everything you need and pulls this
9
- > package in automatically.
6
+ > **Beta.** This package is an internal dependency of `@kbach/react` (the
7
+ > web package — this build is the browser/Node WASM target). If you're
8
+ > building a React web app, install `@kbach/react` instead — it re-exports
9
+ > everything you need and pulls this package in automatically.
10
+ > `@kbach/react-native` does NOT depend on this package directly: on
11
+ > Android the same Rust source (`src/jni_bridge.rs`) is instead
12
+ > cross-compiled ahead of time to a native `.so` (JNI, not WASM) and shipped
13
+ > prebuilt inside `@kbach/react-native`'s own `android/` folder — see
14
+ > `scripts/build-android.mjs` in this package for how that binary gets
15
+ > (re)generated.
10
16
 
11
17
  ## What this is
12
18
 
@@ -14,12 +14,28 @@ export function default_colors_json(): string;
14
14
 
15
15
  export function generate_css(class_string: string, theme_json: string): string;
16
16
 
17
+ /**
18
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
19
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
20
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
21
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
22
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
23
+ * react-native-web itself converts to real DOM CSS internally) — the same
24
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
25
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
26
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
27
+ * bridge calls — zero duplicated resolution logic between the two
28
+ * style-object FFI entry points, only the argument marshaling differs.
29
+ */
30
+ export function resolve_style_json(class_string: string, theme_json: string, color_scheme: string, pressed: boolean, width: number): string;
31
+
17
32
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
18
33
 
19
34
  export interface InitOutput {
20
35
  readonly memory: WebAssembly.Memory;
21
36
  readonly default_colors_json: () => [number, number];
22
37
  readonly generate_css: (a: number, b: number, c: number, d: number) => [number, number];
38
+ readonly resolve_style_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
23
39
  readonly __wbindgen_externrefs: WebAssembly.Table;
24
40
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
25
41
  readonly __wbindgen_malloc: (a: number, b: number) => number;
@@ -44,6 +44,44 @@ export function generate_css(class_string, theme_json) {
44
44
  wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
45
45
  }
46
46
  }
47
+
48
+ /**
49
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
50
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
51
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
52
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
53
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
54
+ * react-native-web itself converts to real DOM CSS internally) — the same
55
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
56
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
57
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
58
+ * bridge calls — zero duplicated resolution logic between the two
59
+ * style-object FFI entry points, only the argument marshaling differs.
60
+ * @param {string} class_string
61
+ * @param {string} theme_json
62
+ * @param {string} color_scheme
63
+ * @param {boolean} pressed
64
+ * @param {number} width
65
+ * @returns {string}
66
+ */
67
+ export function resolve_style_json(class_string, theme_json, color_scheme, pressed, width) {
68
+ let deferred4_0;
69
+ let deferred4_1;
70
+ try {
71
+ const ptr0 = passStringToWasm0(class_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
72
+ const len0 = WASM_VECTOR_LEN;
73
+ const ptr1 = passStringToWasm0(theme_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
74
+ const len1 = WASM_VECTOR_LEN;
75
+ const ptr2 = passStringToWasm0(color_scheme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
76
+ const len2 = WASM_VECTOR_LEN;
77
+ const ret = wasm.resolve_style_json(ptr0, len0, ptr1, len1, ptr2, len2, pressed, width);
78
+ deferred4_0 = ret[0];
79
+ deferred4_1 = ret[1];
80
+ return getStringFromWasm0(ret[0], ret[1]);
81
+ } finally {
82
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
83
+ }
84
+ }
47
85
  function __wbg_get_imports() {
48
86
  const import0 = {
49
87
  __proto__: null,
Binary file
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const default_colors_json: () => [number, number];
5
5
  export const generate_css: (a: number, b: number, c: number, d: number) => [number, number];
6
+ export const resolve_style_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
6
7
  export const __wbindgen_externrefs: WebAssembly.Table;
7
8
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
8
9
  export const __wbindgen_malloc: (a: number, b: number) => number;
@@ -3,10 +3,16 @@
3
3
  The Rust/WASM utility-resolution engine that powers
4
4
  [`@kbach/react`](https://www.npmjs.com/package/@kbach/react).
5
5
 
6
- > **Beta.** This package is an internal dependency of `@kbach/react` and
7
- > `@kbach/react-native`. If you're building a React app, install
8
- > `@kbach/react` instead — it re-exports everything you need and pulls this
9
- > package in automatically.
6
+ > **Beta.** This package is an internal dependency of `@kbach/react` (the
7
+ > web package — this build is the browser/Node WASM target). If you're
8
+ > building a React web app, install `@kbach/react` instead — it re-exports
9
+ > everything you need and pulls this package in automatically.
10
+ > `@kbach/react-native` does NOT depend on this package directly: on
11
+ > Android the same Rust source (`src/jni_bridge.rs`) is instead
12
+ > cross-compiled ahead of time to a native `.so` (JNI, not WASM) and shipped
13
+ > prebuilt inside `@kbach/react-native`'s own `android/` folder — see
14
+ > `scripts/build-android.mjs` in this package for how that binary gets
15
+ > (re)generated.
10
16
 
11
17
  ## What this is
12
18
 
@@ -13,3 +13,18 @@
13
13
  export function default_colors_json(): string;
14
14
 
15
15
  export function generate_css(class_string: string, theme_json: string): string;
16
+
17
+ /**
18
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
19
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
20
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
21
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
22
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
23
+ * react-native-web itself converts to real DOM CSS internally) — the same
24
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
25
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
26
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
27
+ * bridge calls — zero duplicated resolution logic between the two
28
+ * style-object FFI entry points, only the argument marshaling differs.
29
+ */
30
+ export function resolve_style_json(class_string: string, theme_json: string, color_scheme: string, pressed: boolean, width: number): string;
@@ -46,6 +46,45 @@ function generate_css(class_string, theme_json) {
46
46
  }
47
47
  }
48
48
  exports.generate_css = generate_css;
49
+
50
+ /**
51
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
52
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
53
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
54
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
55
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
56
+ * react-native-web itself converts to real DOM CSS internally) — the same
57
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
58
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
59
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
60
+ * bridge calls — zero duplicated resolution logic between the two
61
+ * style-object FFI entry points, only the argument marshaling differs.
62
+ * @param {string} class_string
63
+ * @param {string} theme_json
64
+ * @param {string} color_scheme
65
+ * @param {boolean} pressed
66
+ * @param {number} width
67
+ * @returns {string}
68
+ */
69
+ function resolve_style_json(class_string, theme_json, color_scheme, pressed, width) {
70
+ let deferred4_0;
71
+ let deferred4_1;
72
+ try {
73
+ const ptr0 = passStringToWasm0(class_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
74
+ const len0 = WASM_VECTOR_LEN;
75
+ const ptr1 = passStringToWasm0(theme_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
76
+ const len1 = WASM_VECTOR_LEN;
77
+ const ptr2 = passStringToWasm0(color_scheme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
78
+ const len2 = WASM_VECTOR_LEN;
79
+ const ret = wasm.resolve_style_json(ptr0, len0, ptr1, len1, ptr2, len2, pressed, width);
80
+ deferred4_0 = ret[0];
81
+ deferred4_1 = ret[1];
82
+ return getStringFromWasm0(ret[0], ret[1]);
83
+ } finally {
84
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
85
+ }
86
+ }
87
+ exports.resolve_style_json = resolve_style_json;
49
88
  function __wbg_get_imports() {
50
89
  const import0 = {
51
90
  __proto__: null,
Binary file
@@ -3,6 +3,7 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const default_colors_json: () => [number, number];
5
5
  export const generate_css: (a: number, b: number, c: number, d: number) => [number, number];
6
+ export const resolve_style_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
6
7
  export const __wbindgen_externrefs: WebAssembly.Table;
7
8
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
8
9
  export const __wbindgen_malloc: (a: number, b: number) => number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/core-engine",
3
- "version": "1.0.0-beta.0",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "Rust/WASM utility-class resolution engine powering @kbach/react and @kbach/react-native.",
5
5
  "keywords": ["css", "wasm", "rust", "tailwind", "utility-first", "styling"],
6
6
  "license": "MIT",
@@ -33,6 +33,7 @@
33
33
  "files": ["dist", "dist-node"],
34
34
  "scripts": {
35
35
  "build": "wasm-pack build --target web --out-dir dist && wasm-pack build --target nodejs --out-dir dist-node && node -e \"require('fs').rmSync('dist/.gitignore',{force:true});require('fs').rmSync('dist-node/.gitignore',{force:true})\"",
36
+ "build:android": "node scripts/build-android.mjs",
36
37
  "test": "cargo test",
37
38
  "lint": "cargo check",
38
39
  "clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true});require('fs').rmSync('dist-node',{recursive:true,force:true});require('fs').rmSync('target',{recursive:true,force:true})\""