vaderjs-native 1.0.0
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/LICENSE +21 -0
- package/README.MD +99 -0
- package/app-template/.idea/.name +1 -0
- package/app-template/.idea/AndroidProjectSystem.xml +6 -0
- package/app-template/.idea/codeStyles/Project.xml +123 -0
- package/app-template/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/app-template/.idea/compiler.xml +6 -0
- package/app-template/.idea/deploymentTargetSelector.xml +10 -0
- package/app-template/.idea/gradle.xml +19 -0
- package/app-template/.idea/inspectionProfiles/Project_Default.xml +61 -0
- package/app-template/.idea/migrations.xml +10 -0
- package/app-template/.idea/misc.xml +9 -0
- package/app-template/.idea/runConfigurations.xml +17 -0
- package/app-template/app/build.gradle.kts +54 -0
- package/app-template/app/proguard-rules.pro +21 -0
- package/app-template/app/src/main/AndroidManifest.xml +31 -0
- package/app-template/app/src/main/java/com/example/myapplication/MainActivity.kt +74 -0
- package/app-template/app/src/main/java/com/example/myapplication/ui/theme/Color.kt +11 -0
- package/app-template/app/src/main/java/com/example/myapplication/ui/theme/Theme.kt +34 -0
- package/app-template/app/src/main/java/com/example/myapplication/ui/theme/Type.kt +36 -0
- package/app-template/app/src/main/res/mipmap-hdpi/ic_launcher.webp +0 -0
- package/app-template/app/src/main/res/mipmap-mdpi/ic_launcher.webp +0 -0
- package/app-template/app/src/main/res/mipmap-xhdpi/ic_launcher.webp +0 -0
- package/app-template/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp +0 -0
- package/app-template/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp +0 -0
- package/app-template/app/src/main/res/values/strings.xml +3 -0
- package/app-template/app/src/main/res/values/themes.xml +4 -0
- package/app-template/build.gradle.kts +5 -0
- package/app-template/gradle/libs.versions.toml +30 -0
- package/app-template/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/app-template/gradle/wrapper/gradle-wrapper.properties +9 -0
- package/app-template/gradle.properties +23 -0
- package/app-template/gradlew +251 -0
- package/app-template/gradlew.bat +94 -0
- package/app-template/settings.gradle.kts +23 -0
- package/cli.ts +232 -0
- package/config/index.ts +14 -0
- package/index.ts +1083 -0
- package/jsconfig.json +7 -0
- package/logo.png +0 -0
- package/main.js +643 -0
- package/package.json +20 -0
- package/plugins/index.ts +63 -0
- package/plugins/tailwind.ts +53 -0
package/plugins/index.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// vaderPlugin.d.ts
|
|
2
|
+
|
|
3
|
+
/** The API object passed to plugin hooks */
|
|
4
|
+
export interface VaderAPI {
|
|
5
|
+
/** Run a shell command (string or string[]) and wait for it to finish */
|
|
6
|
+
runCommand(cmd: string | string[]): Promise<void>;
|
|
7
|
+
|
|
8
|
+
/** Inject arbitrary HTML into the <head> of generated index.html files */
|
|
9
|
+
injectHTML(content: string): void;
|
|
10
|
+
|
|
11
|
+
/** Log a message prefixed with [Vader Plugin] */
|
|
12
|
+
log(msg: string): void;
|
|
13
|
+
|
|
14
|
+
/** Get absolute path to the project root */
|
|
15
|
+
getProjectRoot(): string;
|
|
16
|
+
|
|
17
|
+
/** Get absolute path to the dist output directory */
|
|
18
|
+
getDistDir(): string;
|
|
19
|
+
|
|
20
|
+
/** Get absolute path to the public assets directory */
|
|
21
|
+
getPublicDir(): string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Supported plugin hook names */
|
|
25
|
+
export type PluginHookName =
|
|
26
|
+
| "onBuildStart"
|
|
27
|
+
| "onBuildFinish"
|
|
28
|
+
| "onWatchStart"
|
|
29
|
+
| "onWatchStop"
|
|
30
|
+
| "onServeStart"
|
|
31
|
+
| "onServeStop"
|
|
32
|
+
| "onFileChange";
|
|
33
|
+
|
|
34
|
+
/** Interface for a single plugin */
|
|
35
|
+
export interface VaderPlugin {
|
|
36
|
+
/** Called before build starts */
|
|
37
|
+
onBuildStart?(api: VaderAPI): Promise<void> | void;
|
|
38
|
+
|
|
39
|
+
/** Called after build finishes */
|
|
40
|
+
onBuildFinish?(api: VaderAPI): Promise<void> | void;
|
|
41
|
+
|
|
42
|
+
/** Called when watcher starts (dev mode) */
|
|
43
|
+
onWatchStart?(api: VaderAPI): Promise<void> | void;
|
|
44
|
+
|
|
45
|
+
/** Called when watcher stops (dev mode) */
|
|
46
|
+
onWatchStop?(api: VaderAPI): Promise<void> | void;
|
|
47
|
+
|
|
48
|
+
/** Called when dev server starts */
|
|
49
|
+
onServeStart?(api: VaderAPI): Promise<void> | void;
|
|
50
|
+
|
|
51
|
+
/** Called when dev server stops */
|
|
52
|
+
onServeStop?(api: VaderAPI): Promise<void> | void;
|
|
53
|
+
|
|
54
|
+
/** Called on file change during watch, with changed file path */
|
|
55
|
+
onFileChange?(api: VaderAPI, filePath: string): Promise<void> | void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** User config type */
|
|
59
|
+
export interface VaderConfig {
|
|
60
|
+
port?: number;
|
|
61
|
+
host_provider?: string;
|
|
62
|
+
plugins?: VaderPlugin[];
|
|
63
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
//@ts-nocheck
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
|
|
5
|
+
import type { VaderPlugin, VaderAPI } from "vaderjs/plugins";
|
|
6
|
+
function checkIfTailwindInstalled() {
|
|
7
|
+
try {
|
|
8
|
+
//@ts-ignore
|
|
9
|
+
require.resolve('tailwindcss')
|
|
10
|
+
require.resolve('postcss')
|
|
11
|
+
return true
|
|
12
|
+
} catch (e) {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function initTailwind() {
|
|
18
|
+
const postcssConfig = path.resolve(process.cwd(), 'postcss.config.mjs')
|
|
19
|
+
const tailwindCssFile = path.join(process.cwd(), '/public/styles.css')
|
|
20
|
+
if(!fs.existsSync(tailwindCssFile)){
|
|
21
|
+
fs.writeFileSync(tailwindCssFile, `@import "tailwindcss"`)
|
|
22
|
+
}
|
|
23
|
+
if (!fs.existsSync(postcssConfig)) {
|
|
24
|
+
fs.writeFileSync(postcssConfig, `export default { plugins: { "@tailwindcss/postcss": {}, }}`)
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
name: 'tailwindcss',
|
|
33
|
+
description: 'TailwindCSS plugin for Vader.js',
|
|
34
|
+
version: '0.0.2',
|
|
35
|
+
onBuildStart: async (vader) => {
|
|
36
|
+
if (!checkIfTailwindInstalled()) {
|
|
37
|
+
console.error('TailwindCSS is not installed. Please install it using `bun install tailwindcss @tailwindcss/postcss postcss-cli`\n more info: https://tailwindcss.com/docs/installation/using-postcss`')
|
|
38
|
+
process.exit(1)
|
|
39
|
+
}else{
|
|
40
|
+
initTailwind()
|
|
41
|
+
console.log('Building TailwindCSS...')
|
|
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">`)
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return
|
|
48
|
+
},
|
|
49
|
+
onBuildFinish: async (vader) => {
|
|
50
|
+
console.log('TailwindCSS plugin finished building')
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
}
|