vaderjs-native 1.0.0 → 1.0.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
@@ -21,17 +21,17 @@ A modern, reactive framework for building ultra-fast android applications — bu
21
21
  import * as Vader from "vader-native"
22
22
 
23
23
  export default function() {
24
- const [count, setCount] = useState(0)
24
+ const [count, setCount] = Vader.useState(0)
25
25
  return (
26
26
  <div>
27
- <Switch>
28
- <Match when={count > 10}>
27
+ <Vader.Switch>
28
+ <Vader.Match when={count > 10}>
29
29
  <h1>Count is greater than 10</h1>
30
- </Match>
31
- <Match when={count <= 10}>
30
+ </Vader.Match>
31
+ <Vader.Match when={count <= 10}>
32
32
  <h1>Count is less than or equal to 10</h1>
33
- </Match>
34
- </Switch>
33
+ </Vader.Match>
34
+ </Vader.Switch>
35
35
  </div>
36
36
  )
37
37
  }
package/cli.ts CHANGED
@@ -72,7 +72,7 @@ export async function init() {
72
72
 
73
73
  // Create example app/index.jsx with counter
74
74
  const counterCode = wantsTailwind
75
- ? `import * as Vader from "vader-native";
75
+ ? `import * as Vader from "vaderjs-native";
76
76
 
77
77
  function Counter() {
78
78
  let [count, setCount] = Vader.useState(0);
@@ -92,7 +92,7 @@ function Counter() {
92
92
 
93
93
  Vader.render(Vader.createElement(Counter, null), document.getElementById("app"));
94
94
  `
95
- : `import * as Vader from "vader-native";
95
+ : `import * as Vader from "vaderjs-native";
96
96
 
97
97
  function Counter() {
98
98
  let [count, setCount] = Vader.useState(0);
@@ -154,12 +154,12 @@ Vader.render(Vader.createElement(Counter, null), document.getElementById("app"))
154
154
  }
155
155
 
156
156
  // Create vaderjs.config.ts regardless, add Tailwind plugin if needed
157
- const vaderConfig = `import defineConfig from "vader-native/config";
158
- ${wantsTailwind ? 'import tailwind from "vader-native/plugins/tailwind";' : ''}
157
+ const vaderConfig = `import defineConfig from "vaderjs-native/config";
158
+ import tailwind from "vaderjs-native/plugins/tailwind";
159
159
 
160
160
  export default defineConfig({
161
161
  port: 3000,
162
- plugins: [${wantsTailwind ? "tailwind" : ""}],
162
+ plugins: [tailwind],
163
163
  });`;
164
164
 
165
165
  await fs.writeFile(path.join(projectDir, "vaderjs.config.ts"), vaderConfig);
package/main.js CHANGED
@@ -6,10 +6,47 @@ import fs from "fs/promises";
6
6
  import fsSync from "fs";
7
7
  import path from "path";
8
8
  import { init } from "./cli";
9
-
9
+ import os from "os";
10
+ import { execSync } from "child_process";
11
+ import { existsSync, writeFileSync } from "fs";
10
12
  // --- UTILITIES for a Sleek CLI ---
11
13
 
12
-
14
+ async function ensureLocalProperties() {
15
+ const ROOT = path.join(
16
+ PROJECT_ROOT,
17
+ "node_modules",
18
+ "vaderjs-native",
19
+ "app-template"
20
+ );
21
+
22
+ const localPropsPath = path.join(ROOT, "local.properties");
23
+ if (fsSync.existsSync(localPropsPath)) return;
24
+
25
+ // Determine SDK path
26
+ let sdkPath = process.env.ANDROID_HOME;
27
+
28
+ if (!sdkPath) {
29
+ const home = os.homedir();
30
+ if (process.platform === "win32") {
31
+ sdkPath = path.join(home, "AppData", "Local", "Android", "Sdk");
32
+ } else if (process.platform === "darwin") {
33
+ sdkPath = path.join(home, "Library", "Android", "sdk");
34
+ } else {
35
+ // Linux
36
+ sdkPath = path.join(home, "Android", "Sdk");
37
+ }
38
+ }
39
+
40
+ if (!existsSync(sdkPath)) {
41
+ throw new Error(
42
+ `Android SDK not found! Please set ANDROID_HOME or install the SDK at: ${sdkPath}`
43
+ );
44
+ }
45
+
46
+ const content = `sdk.dir=${sdkPath.replace(/\\/g, "\\\\")}\n`;
47
+ writeFileSync(localPropsPath, content);
48
+ logger.success(`Created local.properties with sdk.dir=${sdkPath}`);
49
+ }
13
50
 
14
51
  async function copyCompiledJavascriptToJava(isDev = false) {
15
52
  if (isDev) return;
@@ -40,6 +77,7 @@ async function copyCompiledJavascriptToJava(isDev = false) {
40
77
 
41
78
  import { spawnSync } from "child_process";
42
79
  async function buildAPK() {
80
+ await ensureLocalProperties();
43
81
  const ROOT = path.join(
44
82
  PROJECT_ROOT,
45
83
  "node_modules",
@@ -465,6 +503,11 @@ async function buildAppEntrypoints(isDev = false) {
465
503
  plugins: [
466
504
  publicAssetPlugin(),
467
505
  ],
506
+ loader: {
507
+ '.js': 'jsx',
508
+ '.ts': 'tsx',
509
+ '.css': 'text',
510
+ }
468
511
  });
469
512
 
470
513
  // --- FIX IMPORT PATHS IN JS ---
@@ -506,8 +549,10 @@ async function buildAll(isDev = false) {
506
549
  await timedStep("Building App Source (/src)", buildSrc);
507
550
  await timedStep("Copying Public Assets", copyPublicAssets);
508
551
  await timedStep("Building App Entrypoints (/app)", () => buildAppEntrypoints(isDev));
509
- await timedStep("Copy Compiled Javascript to Java", () => copyCompiledJavascriptToJava(isDev));
510
- await timedStep("Building APK", buildAPK);
552
+ if (!isDev) {
553
+ await timedStep("Copy Compiled Javascript to Java", () => copyCompiledJavascriptToJava(isDev));
554
+ await timedStep("Building APK", buildAPK);
555
+ }
511
556
 
512
557
  await runPluginHook("onBuildFinish");
513
558
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs-native",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Build Android Applications using Vaderjs framework.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"
@@ -15,6 +15,6 @@
15
15
  "ansi-colors": "latest",
16
16
  "autoprefixer": "^10.4.23",
17
17
  "postcss-cli": "^11.0.1",
18
- "tailwindcss": "4"
18
+ "tailwindcss": "latest"
19
19
  }
20
20
  }
@@ -40,7 +40,7 @@ export default {
40
40
  initTailwind()
41
41
  console.log('Building TailwindCSS...')
42
42
  await vader.runCommand(['bun', 'run', 'postcss', './public/styles.css', '-o', 'dist/public/tailwind.css'])
43
- vader.injectHTML(`<link rel="stylesheet" href="/public/tailwind.css">`)
43
+ vader.injectHTML(`<link rel="stylesheet" href="./styles.css">`)
44
44
 
45
45
  }
46
46
 
@@ -50,4 +50,4 @@ export default {
50
50
  console.log('TailwindCSS plugin finished building')
51
51
  },
52
52
 
53
- }
53
+ } as VaderPlugin;