vaderjs 1.4.1-ui7iuy47 → 1.4.2-jpbvml56

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.
Files changed (39) hide show
  1. package/.editorconfig +11 -0
  2. package/.vscode/c_cpp_properties.json +21 -0
  3. package/.vscode/settings.json +12 -0
  4. package/README.md +44 -197
  5. package/binaries/Kalix/index.js +677 -0
  6. package/binaries/compiler/main.js +502 -0
  7. package/binaries/vader.js +74 -0
  8. package/binaries/watcher/hmr.js +41 -0
  9. package/client/index.d.ts +226 -0
  10. package/client/runtime/index.js +1 -0
  11. package/client/runtime/router.js +1 -0
  12. package/config/index.ts +87 -0
  13. package/index.ts +344 -0
  14. package/package.json +13 -25
  15. package/plugins/cloudflare/functions/index.js +102 -0
  16. package/plugins/cloudflare/toCopy/@server/Kalix/index.js +673 -0
  17. package/plugins/cloudflare/toCopy/@server/cloudflare_ssr/index.js +85 -0
  18. package/plugins/cloudflare/toCopy/node_modules/vaderjs/server/index.js +99 -0
  19. package/plugins/cloudflare/toCopy/src/client.js +1 -0
  20. package/plugins/cloudflare/toCopy/src/router.js +1 -0
  21. package/plugins/ssg/index.js +197 -0
  22. package/plugins/tailwind/index.ts +102 -0
  23. package/plugins/vercel/functions/index.ts +8 -0
  24. package/router/index.ts +208 -0
  25. package/server/index.js +143 -0
  26. package/vader_dev.js +177 -0
  27. package/@integrations/ssg.js +0 -189
  28. package/LICENSE +0 -21
  29. package/binaries/IPC/index.js +0 -277
  30. package/binaries/main.js +0 -1464
  31. package/binaries/readme.md +0 -4
  32. package/binaries/watcher.js +0 -74
  33. package/binaries/win32/check.ps1 +0 -7
  34. package/client/index.js +0 -426
  35. package/config/index.js +0 -36
  36. package/logo.png +0 -0
  37. package/runtime/router.js +0 -1
  38. package/runtime/vader.js +0 -1
  39. package/vader.js +0 -230
package/package.json CHANGED
@@ -1,36 +1,24 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "description": "A Reactive library aimed to helping you build reactive applications inspired by react.js",
4
- "module": "vader.js",
5
- "version": "1.4.1-ui7iuy47",
6
- "bin": {
7
- "vader": "./vader.js"
3
+ "description": "A reactive framework for building fast and scalable web applications",
4
+ "version": "1.4.2-jpbvml56",
5
+ "author": {
6
+ "name": "Malikwhitten67",
7
+ "email": "malikwhitterb@gmail.com"
8
8
  },
9
- "keywords": [
10
- "react",
11
- "reactive",
12
- "nextjs",
13
- "pages router",
14
- "bun.js",
15
- "severside generation",
16
- "spa",
17
- "vanillajs",
18
- "vanilla js"
19
- ],
20
- "type": "module",
21
9
  "license": "MIT",
22
- "homepage": "https://vader-js.pages.dev",
23
10
  "repository": {
24
11
  "type": "git",
25
12
  "url": "https://github.com/Postr-Inc/Vader.js"
26
13
  },
27
- "author": {
28
- "name": "Malik Whitten",
29
- "email": "malikwhitterb@gmail.com"
14
+ "type": "module",
15
+ "bin":{
16
+ "vader":"./vader_dev.js"
17
+ },
18
+ "dependencies": {
19
+ "ws": "latest"
30
20
  },
31
- "dependencies": {
32
- "playwright": "latest",
33
- "source-map": "latest",
21
+ "devDependencies": {
34
22
  "ws": "latest"
35
23
  }
36
- }
24
+ }
@@ -0,0 +1,102 @@
1
+ import { Glob } from 'bun'
2
+ import fs from 'fs'
3
+ const glob = new Glob("/**/*.{ts,tsx,js,jsx}", {
4
+ absolute: true,
5
+ });
6
+ /**
7
+ * @description This function generates cloudflare functions from the routes folder
8
+ */
9
+ async function generate(){
10
+ let config = await import(process.cwd() + '/vader.config.js').then((config) => { return config.default })
11
+ if(!config?.env || !config?.env.SSR){
12
+ console.error('\x1b[31m[CloudFlare Functions] \x1b[0m - Please add an SSR environment variable to your vader.config.js file')
13
+ return
14
+ }
15
+ let start = Date.now()
16
+ for(var i of glob.scanSync({cwd: process.cwd() + '/routes', absolute: true})){
17
+ let data = await Bun.file(i).text()
18
+ let method = ''
19
+ i = i.replaceAll('\\', '/').replace(process.cwd(), '')
20
+ if(!data.includes(data.match(new RegExp('export\\s+default')))){
21
+ throw new Error('File must have a default export')
22
+ }
23
+ data.split('\n').forEach((line, index) => {
24
+ if(line.includes('GET') || line.includes('POST') || line.includes('PUT') || line.includes('DELETE') && line.includes('function')){
25
+ line = line.replace(/export\s+default\s+async\s+function/g, line.includes('async') ? 'async function' : 'function')
26
+ method = line.split('function')[1].split('(')[0].trim()
27
+ data = data.replace(data.split('\n')[index], line)
28
+ data = data + `\nexport async function onRequest${method.toLowerCase().charAt(0).toUpperCase() + method.toLowerCase().slice(1)}(request){
29
+ let req = {
30
+ url: request.request.url,
31
+ method: request.request.method,
32
+ headers: request.request.headers,
33
+ }
34
+ let res = {
35
+ params: (param) => {
36
+ return request.params[param]
37
+ },
38
+ query: (param) => {
39
+ let url = new URL(request.request.url)
40
+ return url.searchParams.get(param)
41
+ }
42
+ }
43
+ let response = await ${method}({req, res})
44
+ return response
45
+ }
46
+ `
47
+ }
48
+ });
49
+
50
+ let env = `globalThis.env = {
51
+
52
+ ${
53
+ Object.keys(config?.env).map((key) => {
54
+ return `${key}:"${config.env[key]}",`
55
+ } ).join('\n')
56
+ }
57
+ ${Object.keys(process.env).map((key) => {
58
+ let value = process.env[key].replace(/"/g, '\\"')
59
+ value = value.replace(/\\n/g, '\\n') // remove new lines
60
+ value = value.replace(/\\r/g, '\\r') // remove carriage returns
61
+ value = value.replace(/\\t/g, '\\t') // remove tabs
62
+ value = value.replace('/\/g', '\\\\') // remove octal escape sequences
63
+ // remove octal escape sequences
64
+ value = value.replace(/\\[0-7]{1,3}/g, '');
65
+ return `${key}:"${value}"`
66
+ } ).join(',\n')
67
+ }
68
+ };
69
+ `
70
+ // make env all on one line
71
+ env = env.replace(/\n/g, '')
72
+ data = env + data
73
+
74
+
75
+ fs.mkdirSync(process.cwd() + '/build/functions' + i.split('/routes')[1].split('/').slice(0, -1).join('/'), { recursive: true })
76
+ fs.writeFileSync(process.cwd() + '/build/functions/' + i.split('/routes')[1].replace('.ts', '.js').replace('.tsx', '.js').replace('.jsx', '.js'), data)
77
+
78
+ let nodeModules = process.cwd() + '/node_modules/vaderjs/plugins/cloudflare/toCopy'
79
+ let glb = new Glob('**/*', {
80
+ absolute: true,
81
+ cwd: nodeModules
82
+ })
83
+ for(var file of glb.scanSync({cwd: nodeModules, absolute: true})){
84
+ file = file.replaceAll('\\', '/').replace(nodeModules, '')
85
+ if(fs.existsSync('build/' + file.split('/toCopy')[1])) continue
86
+ let data = await Bun.file(file).text()
87
+ let path = file.split('/toCopy')[1]
88
+ Bun.write(process.cwd() + '/build/' + path, data)
89
+ }
90
+ }
91
+ console.log(`\x1b[32msuccess \x1b[0m - Cloudflare Functions Compiled in: ${Date.now() - start}ms`)
92
+ }
93
+ export default {
94
+ name: 'Cloudflare Functions Plugin',
95
+ description: 'This plugin utilizes cloudflare functios for server side rendering',
96
+ version: '0.0.1',
97
+ type: "SSR",
98
+ init: async (path, options) => {
99
+ console.log(`\x1b[32mevent \x1b[0m - Cloudflare Functions Plugin Initialized`)
100
+ await generate()
101
+ }
102
+ }