@kbach/core-engine 1.0.0-beta.0 → 1.0.0-beta.2

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,23 @@
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
+ > either of the two platforms it supports: on Android the same Rust source
12
+ > (`src/jni_bridge.rs`) is instead cross-compiled ahead of time to a native
13
+ > `.so` (JNI, not WASM) and shipped prebuilt inside `@kbach/react-native`'s
14
+ > own `android/` folder — see `scripts/build-android.mjs` in this package
15
+ > for how that binary gets (re)generated. On Expo Web / react-native-web,
16
+ > `@kbach/react-native` vendors a trimmed copy of this package's own
17
+ > web-target WASM glue directly into its own source (generated via
18
+ > `scripts/generate-web-glue.mjs` and `scripts/generate-wasm-base64.mjs`)
19
+ > rather than importing this package at runtime — see that script's own
20
+ > doc comment for why (short version: this package's unused async `init()`
21
+ > export references `import.meta.url`, which breaks under some bundler
22
+ > targets even when never called).
10
23
 
11
24
  ## What this is
12
25
 
package/dist/README.md CHANGED
@@ -3,10 +3,23 @@
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
+ > either of the two platforms it supports: on Android the same Rust source
12
+ > (`src/jni_bridge.rs`) is instead cross-compiled ahead of time to a native
13
+ > `.so` (JNI, not WASM) and shipped prebuilt inside `@kbach/react-native`'s
14
+ > own `android/` folder — see `scripts/build-android.mjs` in this package
15
+ > for how that binary gets (re)generated. On Expo Web / react-native-web,
16
+ > `@kbach/react-native` vendors a trimmed copy of this package's own
17
+ > web-target WASM glue directly into its own source (generated via
18
+ > `scripts/generate-web-glue.mjs` and `scripts/generate-wasm-base64.mjs`)
19
+ > rather than importing this package at runtime — see that script's own
20
+ > doc comment for why (short version: this package's unused async `init()`
21
+ > export references `import.meta.url`, which breaks under some bundler
22
+ > targets even when never called).
10
23
 
11
24
  ## What this is
12
25
 
@@ -14,12 +14,31 @@ export function default_colors_json(): string;
14
14
 
15
15
  export function generate_css(class_string: string, theme_json: string): string;
16
16
 
17
+ export function generate_css_attr(class_string: string, theme_json: string): string;
18
+
19
+ /**
20
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
21
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
22
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
23
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
24
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
25
+ * react-native-web itself converts to real DOM CSS internally) — the same
26
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
27
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
28
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
29
+ * bridge calls — zero duplicated resolution logic between the two
30
+ * style-object FFI entry points, only the argument marshaling differs.
31
+ */
32
+ export function resolve_style_json(class_string: string, theme_json: string, color_scheme: string, pressed: boolean, width: number): string;
33
+
17
34
  export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
18
35
 
19
36
  export interface InitOutput {
20
37
  readonly memory: WebAssembly.Memory;
21
38
  readonly default_colors_json: () => [number, number];
22
39
  readonly generate_css: (a: number, b: number, c: number, d: number) => [number, number];
40
+ readonly generate_css_attr: (a: number, b: number, c: number, d: number) => [number, number];
41
+ readonly resolve_style_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
23
42
  readonly __wbindgen_externrefs: WebAssembly.Table;
24
43
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
25
44
  readonly __wbindgen_malloc: (a: number, b: number) => number;
@@ -44,6 +44,66 @@ 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
+ * @param {string} class_string
50
+ * @param {string} theme_json
51
+ * @returns {string}
52
+ */
53
+ export function generate_css_attr(class_string, theme_json) {
54
+ let deferred3_0;
55
+ let deferred3_1;
56
+ try {
57
+ const ptr0 = passStringToWasm0(class_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
58
+ const len0 = WASM_VECTOR_LEN;
59
+ const ptr1 = passStringToWasm0(theme_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len1 = WASM_VECTOR_LEN;
61
+ const ret = wasm.generate_css_attr(ptr0, len0, ptr1, len1);
62
+ deferred3_0 = ret[0];
63
+ deferred3_1 = ret[1];
64
+ return getStringFromWasm0(ret[0], ret[1]);
65
+ } finally {
66
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
67
+ }
68
+ }
69
+
70
+ /**
71
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
72
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
73
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
74
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
75
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
76
+ * react-native-web itself converts to real DOM CSS internally) — the same
77
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
78
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
79
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
80
+ * bridge calls — zero duplicated resolution logic between the two
81
+ * style-object FFI entry points, only the argument marshaling differs.
82
+ * @param {string} class_string
83
+ * @param {string} theme_json
84
+ * @param {string} color_scheme
85
+ * @param {boolean} pressed
86
+ * @param {number} width
87
+ * @returns {string}
88
+ */
89
+ export function resolve_style_json(class_string, theme_json, color_scheme, pressed, width) {
90
+ let deferred4_0;
91
+ let deferred4_1;
92
+ try {
93
+ const ptr0 = passStringToWasm0(class_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
94
+ const len0 = WASM_VECTOR_LEN;
95
+ const ptr1 = passStringToWasm0(theme_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
96
+ const len1 = WASM_VECTOR_LEN;
97
+ const ptr2 = passStringToWasm0(color_scheme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
98
+ const len2 = WASM_VECTOR_LEN;
99
+ const ret = wasm.resolve_style_json(ptr0, len0, ptr1, len1, ptr2, len2, pressed, width);
100
+ deferred4_0 = ret[0];
101
+ deferred4_1 = ret[1];
102
+ return getStringFromWasm0(ret[0], ret[1]);
103
+ } finally {
104
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
105
+ }
106
+ }
47
107
  function __wbg_get_imports() {
48
108
  const import0 = {
49
109
  __proto__: null,
Binary file
@@ -3,6 +3,8 @@
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 generate_css_attr: (a: number, b: number, c: number, d: number) => [number, number];
7
+ export const resolve_style_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
6
8
  export const __wbindgen_externrefs: WebAssembly.Table;
7
9
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
8
10
  export const __wbindgen_malloc: (a: number, b: number) => number;
@@ -3,10 +3,23 @@
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
+ > either of the two platforms it supports: on Android the same Rust source
12
+ > (`src/jni_bridge.rs`) is instead cross-compiled ahead of time to a native
13
+ > `.so` (JNI, not WASM) and shipped prebuilt inside `@kbach/react-native`'s
14
+ > own `android/` folder — see `scripts/build-android.mjs` in this package
15
+ > for how that binary gets (re)generated. On Expo Web / react-native-web,
16
+ > `@kbach/react-native` vendors a trimmed copy of this package's own
17
+ > web-target WASM glue directly into its own source (generated via
18
+ > `scripts/generate-web-glue.mjs` and `scripts/generate-wasm-base64.mjs`)
19
+ > rather than importing this package at runtime — see that script's own
20
+ > doc comment for why (short version: this package's unused async `init()`
21
+ > export references `import.meta.url`, which breaks under some bundler
22
+ > targets even when never called).
10
23
 
11
24
  ## What this is
12
25
 
@@ -13,3 +13,20 @@
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
+ export function generate_css_attr(class_string: string, theme_json: string): string;
18
+
19
+ /**
20
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
21
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
22
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
23
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
24
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
25
+ * react-native-web itself converts to real DOM CSS internally) — the same
26
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
27
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
28
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
29
+ * bridge calls — zero duplicated resolution logic between the two
30
+ * style-object FFI entry points, only the argument marshaling differs.
31
+ */
32
+ export function resolve_style_json(class_string: string, theme_json: string, color_scheme: string, pressed: boolean, width: number): string;
@@ -46,6 +46,68 @@ function generate_css(class_string, theme_json) {
46
46
  }
47
47
  }
48
48
  exports.generate_css = generate_css;
49
+
50
+ /**
51
+ * @param {string} class_string
52
+ * @param {string} theme_json
53
+ * @returns {string}
54
+ */
55
+ function generate_css_attr(class_string, theme_json) {
56
+ let deferred3_0;
57
+ let deferred3_1;
58
+ try {
59
+ const ptr0 = passStringToWasm0(class_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
60
+ const len0 = WASM_VECTOR_LEN;
61
+ const ptr1 = passStringToWasm0(theme_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
62
+ const len1 = WASM_VECTOR_LEN;
63
+ const ret = wasm.generate_css_attr(ptr0, len0, ptr1, len1);
64
+ deferred3_0 = ret[0];
65
+ deferred3_1 = ret[1];
66
+ return getStringFromWasm0(ret[0], ret[1]);
67
+ } finally {
68
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
69
+ }
70
+ }
71
+ exports.generate_css_attr = generate_css_attr;
72
+
73
+ /**
74
+ * WASM counterpart to the Android JNI bridge's `resolveStyle` — resolves
75
+ * `class_string` to a flat, RN-`StyleSheet`-shaped JSON style object
76
+ * instead of CSS rule text, for @kbach/react-native's Expo Web /
77
+ * react-native-web fallback path (see packages/react-native/src/webBridge.ts).
78
+ * react-native-web's `View`/`Text` accept an RN-style `style` OBJECT (which
79
+ * react-native-web itself converts to real DOM CSS internally) — the same
80
+ * shape the JNI bridge already produces for real native, NOT the CSS-text
81
+ * shape `generate_css` above produces for plain DOM `@kbach/react`.
82
+ * Delegates to the exact same `resolve_style::resolve_style_json` the JNI
83
+ * bridge calls — zero duplicated resolution logic between the two
84
+ * style-object FFI entry points, only the argument marshaling differs.
85
+ * @param {string} class_string
86
+ * @param {string} theme_json
87
+ * @param {string} color_scheme
88
+ * @param {boolean} pressed
89
+ * @param {number} width
90
+ * @returns {string}
91
+ */
92
+ function resolve_style_json(class_string, theme_json, color_scheme, pressed, width) {
93
+ let deferred4_0;
94
+ let deferred4_1;
95
+ try {
96
+ const ptr0 = passStringToWasm0(class_string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
97
+ const len0 = WASM_VECTOR_LEN;
98
+ const ptr1 = passStringToWasm0(theme_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
99
+ const len1 = WASM_VECTOR_LEN;
100
+ const ptr2 = passStringToWasm0(color_scheme, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
101
+ const len2 = WASM_VECTOR_LEN;
102
+ const ret = wasm.resolve_style_json(ptr0, len0, ptr1, len1, ptr2, len2, pressed, width);
103
+ deferred4_0 = ret[0];
104
+ deferred4_1 = ret[1];
105
+ return getStringFromWasm0(ret[0], ret[1]);
106
+ } finally {
107
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
108
+ }
109
+ }
110
+ exports.resolve_style_json = resolve_style_json;
49
111
  function __wbg_get_imports() {
50
112
  const import0 = {
51
113
  __proto__: null,
Binary file
@@ -3,6 +3,8 @@
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 generate_css_attr: (a: number, b: number, c: number, d: number) => [number, number];
7
+ export const resolve_style_json: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number];
6
8
  export const __wbindgen_externrefs: WebAssembly.Table;
7
9
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
8
10
  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.2",
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})\""