vaderjs 1.4.2 → 1.4.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.
@@ -26,8 +26,7 @@ Create a pages folder - which allows you to have nextjs page like routing via bu
26
26
 
27
27
  Tip: Each folder can be deep nested up to 4 levels!
28
28
 
29
- ```md
30
-
29
+ ```md
31
30
  /pages/index.jsx = /
32
31
  /pages/home/[page].jsx = /home/:page
33
32
  /pages/path/index.jsx = /path/
@@ -38,29 +37,20 @@ Tip: Each folder can be deep nested up to 4 levels!
38
37
  Keyword folders - all files are passed from these folders to the build folder
39
38
 
40
39
  ```md
41
- 1. pages - used for jsx route files
42
- 2. src - used for your jsx components / javascript files
43
- 3. public - used for anything
40
+ 1. app - used for jsx route files
41
+ 2. public - used for anything / css / json etc
44
42
  ```
45
43
 
46
44
 
47
45
  # Define your config
48
46
 
49
47
  ```ts
50
- import { defineConfig } from "vaderjs/config";
51
- import cloudflare from "vaderjs/plugins/cloudflare/functions"
48
+ import defineConfig from "../config";
49
+
52
50
  export default defineConfig({
53
- target: "web",
54
- host: {
55
- hostname: "localhost",
56
- provider:'cloudflare'
57
- },
58
- env: {
59
- PORT: 3000,
60
- SSR: true,
61
- apiRoute: "https://api.example.com"
62
- },
63
- plugins: [cloudflare],
64
- });
51
+ port: 3000,
52
+ host: 'localhost',
53
+ hot_reload: true,
54
+ })
65
55
 
66
56
  ```
package/config/index.ts CHANGED
@@ -1,68 +1,14 @@
1
- /**
2
- * @description Instruct the compiler to use the provided configuration
3
- * @typedef {Object} Config
4
- * @property {string} target - The target environment
5
- * @property {Object} host - The host object
6
- * @property {string} host.hostname - The hostname of the application
7
- * @property {string} host.provider - The provider of the application
8
- * @property {Object} compilerOptions - The compiler options
9
- * @property {string} compilerOptions.outDir - The output directory
10
- * @property {string} compilerOptions.target - The target of the compiler
11
- * @property {any[]} plugins - The plugins to be used in the application
12
- * @property {string} mode - The mode of the application
13
- * @param config - The configuration object
14
- * @returns
15
- */
16
- /**
17
- * Defines the configuration options for VaderJS.
18
- * @param {Object} config - The configuration object.
19
- * @param {string} config.target - The target platform for the code ('web' or 'bun').
20
- * @param {Object} [config.host] - The host configuration.
21
- * @param {string} [config.host.hostname] - The hostname for the host.
22
- * @param {('vercel','netlify')} [config.host.provider] - The provider for the host ('vercel', 'netlify', 'aws', 'azure', 'gcp').
23
- * @param {number} [config.host.port] - The port number for the host.
24
- * @param {Object} [config.compilerOptions] - The compiler options.
25
- * @param {string} [config.compilerOptions.outDir] - The output directory for the compiled code.
26
- * @param {string} [config.mode] - The mode for the configuration.
27
- * @param {Array} [config.plugins] - The plugins for the configuration.
28
- * @param {Object} [config.env] - The environment variables for the configuration.
29
- * @returns {Object} The configured object.
30
- */
31
- export const defineConfig = (config: {
32
- /**
33
- * @type {string}
34
- * @param {('web'|'bun')} target
35
- */
36
- target:string,
37
- host?: {
38
- hostname?: string,
39
- /**
40
- * @param {('vercel', 'netlify', 'aws', 'azure', 'gcp')} provider
41
- */
42
- provider?: string,
43
- port?: number
44
- },
45
- compilerOptions?: {
46
- outDir?: string,
47
- },
48
- mode?: string,
49
- plugins?: any[]
50
- env?: {
51
- [key: string]: any
52
- }
53
- }) => {
54
- // add config.env to globalThis.env
55
- let env = {}
56
- if(config.env){
57
- for(let key in config.env){
58
- env[key] = config.env[key]
59
- }
60
- for(let key in globalThis.env){
61
- env[key] = globalThis.env[key]
62
- }
63
- }
1
+ type Config = {
2
+ port: number,
3
+ host?: string,
4
+ plugins?: any[],
5
+ generateTypes?: boolean,
6
+ host_provider?: 'vercel' | 'netlify' | 'aws' | 'gcp' | 'azure' | 'heroku' | 'custom' | 'none',
7
+ host_provider_options?: {
8
+ [key: string]: any
9
+ },
10
+ }
64
11
 
65
- //@ts-ignore
66
- globalThis.env = env
67
- return config
12
+ export default function defineConfig(config: Config) {
13
+ return config
68
14
  }
@@ -0,0 +1,49 @@
1
+ export const document = (element: any) => {
2
+ let type = element.type;
3
+ let el = `<${type}`;
4
+ let attributes = element.props;
5
+ let children = element.children;
6
+ for (let key in attributes) {
7
+ if(key === "key"){
8
+ el += ` key="${attributes[key]}"`;
9
+ continue;
10
+ }
11
+ if (key === "className") {
12
+ el += ` class="${attributes[key]}"`;
13
+ continue;
14
+ }
15
+ if (key === "style") {
16
+ let style = "";
17
+ for (let styleKey in attributes[key]) {
18
+ style += `${styleKey}:${attributes[key][styleKey]};`;
19
+ }
20
+ el += ` style="${style}"`;
21
+ continue;
22
+ }
23
+ //@ts-ignore
24
+ if (key.includes("on")) {
25
+ continue;
26
+ }
27
+ el += ` ${key}="${attributes[key]}"`;
28
+
29
+ }
30
+ el += ">";
31
+ for (let i = 0;i < children.length; i++) {
32
+ let child = children[i];
33
+ if (Array.isArray(child)) {
34
+ child.forEach((c) => {
35
+ el += document(c);
36
+ });
37
+ }
38
+ if(typeof child === "function"){
39
+ el += document(child());
40
+ }else
41
+ if (typeof child === "object") {
42
+ el += document(child);
43
+ }else{
44
+ el += child;
45
+ }
46
+ }
47
+ el += `</${type}>`;
48
+ return el;
49
+ }