vaderjs 1.3.3-alpha-34 → 1.3.3-alpha-36

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
@@ -1,3 +1,4 @@
1
+
1
2
  <p align="center">
2
3
  <a href="https://vader-js.pages.dev">
3
4
  <picture>
@@ -73,8 +74,9 @@ For pages that have [params] you can derive it using this.request
73
74
 
74
75
  ```jsx
75
76
  // pages/home.jsx
76
- let {Component, useState} = await import('vaderjs/client') // this will be automatically handled by vader in compile time
77
- let Mycomponent = await require('./pages/mycomponent')
77
+ import {Component, useState, useRef} = from 'vaderjs/client'
78
+ import Mycomponent from './src/mycomponent.jsx'
79
+
78
80
  class Home extends Vader {
79
81
  constructor() {
80
82
  super();
@@ -90,7 +92,7 @@ class Home extends Vader {
90
92
  }
91
93
  }
92
94
 
93
- return {default:Home}
95
+ export default Home
94
96
  ```
95
97
 
96
98
 
@@ -174,3 +176,183 @@ VaderJS is released under the MIT License. See the [LICENSE](https://github.com/
174
176
  ## Join the Community
175
177
 
176
178
  Connect with the VaderJS community on [GitHub](https://github.com/Postr-Inc/Vader.js). Contribute, share feedback, and improve VaderJS for SPA development.
179
+ =======
180
+ <p align="center">
181
+ <a href="https://vader-js.pages.dev">
182
+ <picture>
183
+ <source media="(prefers-color-scheme: dark)" srcset="/icon.jpeg">
184
+ <img src="./logo.png" height="128">
185
+ </picture>
186
+ <h1 align="center">Vader.js</h1>
187
+ </a>
188
+ </p>
189
+
190
+ # VaderJS: A Powerful Reactive Framework for SPAs inspired by react.js!
191
+
192
+ [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Postr-Inc/Vader.js/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/vaderjs.svg?style=flat)](https://www.npmjs.com/package/vaderjs)
193
+
194
+
195
+
196
+ ## Get Started
197
+
198
+ 2. Install vaderjs
199
+
200
+ ```bash
201
+ npm i vaderjs@latest
202
+ ```
203
+
204
+ 3. Install five server - recommended to watch the index.html file as you edit your code
205
+
206
+ [Vscode 5 Server](https://marketplace.visualstudio.com/items?itemName=yandeu.five-server)
207
+
208
+ 4. Create Proper Folders
209
+
210
+ Create a pages folder - which allows you to have nextjs page like routing via buns file based router
211
+
212
+ Tip: Each folder can be deep nested up to 4 levels!
213
+
214
+ ```bash
215
+ /pages/index.jsx = /
216
+ /pages/home/[page].jsx = /home/:page
217
+ /pages/path/index.jsx = /path/
218
+ /pages/test/[...]/index.jsx = /path/test/*
219
+ /pages/route/[param1]/[param2].jsx = /path/route/:param1/:param2
220
+ ```
221
+ Keyword folders - all files are passed from these folders to the `dist` folder
222
+
223
+ ```bash
224
+
225
+ pages - used for jsx route files
226
+ src - used for your jsx components / javascript files
227
+ public - used for anything
228
+
229
+ ```
230
+
231
+
232
+
233
+ 5. And your done - Run `npx vaderjs` and the compiled output is visible inside of the `/dist/` folder!
234
+
235
+
236
+ ## Key Features & Examples
237
+
238
+ ### File based routing
239
+ vader's compiler automatically handles routing so you wont need to! - it uses a similar page routing to nextjs
240
+
241
+ ```bash
242
+ /pages/index.jsx = /
243
+ /pages/home/[page].jsx = /home/:page
244
+ /pages/path/index.jsx = /path/
245
+ /pages/path/[...].jsx = /path/*
246
+
247
+ ```
248
+ For pages that have [params] you can derive it using this.request
249
+
250
+
251
+ ### Simplified Component Creation
252
+
253
+ ```jsx
254
+ // pages/home.jsx
255
+ let {Component, useState} = await import('vaderjs/client') // this will be automatically handled by vader in compile time
256
+ let Mycomponent = await require('./pages/mycomponent')
257
+ class Home extends Vader {
258
+ constructor() {
259
+ super();
260
+ this.key = '2'
261
+ }
262
+ render() {
263
+ return <>
264
+ <div key={this.key}>
265
+ <p>Hello World</p>
266
+ </div>
267
+ <Mycomponent ..props />
268
+ </>
269
+ }
270
+ }
271
+
272
+ return {default:Home}
273
+ ```
274
+
275
+
276
+
277
+ ### State Management
278
+ Vaderjs uses partial hydration & full reflection
279
+
280
+ You can pass a reference to the dom target like an id for the element u want to change - or you can just swap the value and the entire component will rerender
281
+
282
+ ```jsx
283
+ let {Component, useState, useRef} = await import('vaderjs/client')
284
+
285
+ class MyApp extends Component{
286
+ contructor(){
287
+ super()
288
+ this.key = 'static key for state changes'
289
+ }
290
+
291
+ render(){
292
+ let [count, setCount] = useState(0)
293
+ let ref = useRef('')
294
+
295
+ return <>
296
+ <p ref={ref.bind}>Count is ${count}</p>
297
+ ${/**
298
+ pass anything used from the toplevel render to the lowerlevel function params to be able to invoke!
299
+ **/}
300
+ <button onclick={(setCount, count, ref)=>{
301
+ setCount(count + 1, ref.bind)
302
+ }}>Increment</button>
303
+ </>
304
+
305
+ }
306
+ }
307
+
308
+ return {default:MyApp}
309
+ ```
310
+
311
+
312
+ ### Function Binding
313
+
314
+ Vaderjs allows you to bind functions directly to html elements just like react
315
+ there are two ways - top level invokes like below
316
+
317
+ ```javascript
318
+ // vader uses params[0] as the event target object and other parameters resolve after
319
+
320
+ function click(event, otherparams){
321
+ console.log(event.target, otherparams)
322
+ }
323
+
324
+ const hello = function(event, otherparams){
325
+
326
+ }
327
+
328
+ return <>
329
+ <button onclick={()=>click()}>Click Me</button>
330
+ </>
331
+ ```
332
+
333
+ and lower level invokes - these operate the same just allow you to pass items from top level to lower level: ex - I have a variable named car and i want the button to log it i can pass it as a parameter to allow it to be added to the buttons function scope
334
+
335
+ ```jsx
336
+ let car = {
337
+ model: 'tesla',
338
+ price: 'toomiuch'
339
+ }
340
+ return <>
341
+ <button onclick={(car)=>{
342
+ console.log(car.model)
343
+ }}>Log</button>
344
+ ```
345
+
346
+
347
+
348
+
349
+
350
+
351
+ ## License
352
+
353
+ VaderJS is released under the MIT License. See the [LICENSE](https://github.com/Postr-Inc/Vader.js/blob/main/LICENSE) file for details.
354
+
355
+ ## Join the Community
356
+
357
+ Connect with the VaderJS community on [GitHub](https://github.com/Postr-Inc/Vader.js). Contribute, share feedback, and improve VaderJS for SPA development.
358
+ >>>>>>> 2a55d1782fcc399a8d0a72467bc88dfcfe49db88
package/client/index.js CHANGED
File without changes
package/logo.png CHANGED
File without changes
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "vaderjs",
3
3
  "description": "A Reactive library aimed to helping you build reactive applications inspired by react.js",
4
4
  "module": "vader.js",
5
- "version": "1.3.3-alpha-34",
5
+ "version": "1.3.3-alpha-36",
6
6
  "bin": {
7
7
  "vader": "./vader.js"
8
8
  },
File without changes
package/runtime/router.js CHANGED
File without changes
package/vader.js CHANGED
@@ -659,6 +659,7 @@ function Compiler(func) {
659
659
  string += `\n\n //wascompiled`;
660
660
 
661
661
  string = string.replaceAll("undefined", "");
662
+ let exportss = {}
662
663
  string.split('\n').forEach(line => {
663
664
  if(line.includes('import')){
664
665
  let asyncimportMatch = line.match(/import\((.*)\)/gs)
@@ -721,10 +722,12 @@ function Compiler(func) {
721
722
  let b4line = line;
722
723
  let exports = line.split('export')[1].trim();
723
724
  let isDefault = exports.includes('default');
724
- let newExport = '';
725
+
725
726
  let name = ''
726
727
  switch (true) {
727
- case exports && isDefault:
728
+ case exports && isDefault:
729
+ console.log('default')
730
+
728
731
  let expt = exports.split('default')[1].trim();
729
732
  // Check if it's a class definition
730
733
  if (expt.includes('class')) {
@@ -733,14 +736,15 @@ function Compiler(func) {
733
736
  let className = match ? match[0].split('class')[1].split('extends')[0].trim() : expt.split('class')[1].split('{')[0].trim();
734
737
  name = className
735
738
 
736
- newExport = isDefault ? `return {default: ${className}}` : `return ${className}`;
739
+ exportss['default'] = className
737
740
  } else if (expt.includes('function')) {
738
741
  let funcName = expt.split('function')[1].split('(')[0].trim();
739
742
  name = funcName
740
- newExport = isDefault ? `return {default: ${funcName}}` : `return ${funcName}`;
743
+ exportss[isDefault ? 'default' : funcName] = funcName
741
744
  }else{
742
745
  name = expt
743
- newExport = isDefault ? `return {default: ${expt}}` : `return ${expt}`;
746
+ exportss[isDefault ? 'default' : expt] = expt
747
+
744
748
  }
745
749
  break;
746
750
 
@@ -748,23 +752,24 @@ function Compiler(func) {
748
752
  let expt2 = exports
749
753
  if(expt2.includes('function')){
750
754
  let funcName = expt2.split('function')[1].split('(')[0].trim();
751
- newExport = `return ${funcName}`;
755
+ exportss[funcName] = funcName
752
756
  }else if(expt2.includes('class')){
753
757
  let match = expt2.match(/class\s*([a-zA-Z0-9_-]+)\s*extends\s*([a-zA-Z0-9_-]+)/gs)
754
758
  let className = match ? match[0].split('class')[1].split('extends')[0].trim() : expt2.split('class')[1].split('{')[0].trim();
755
759
  name = className
756
- newExport = `return ${className}`;
760
+ exportss[className] = className
757
761
  }
758
762
  break;
759
763
  }
760
764
 
761
- if (newExport) {
762
- string = string.replace(b4line, b4line.replaceAll(/\s+/g, " ").trim().split('export').join('').split('default').join('').trim());
763
- string = `${string}\n${newExport}`;
764
- }
765
+ string = string.replace(b4line, b4line.replaceAll(/\s+/g, " ").trim().split('export').join('').split('default').join('').trim());
765
766
  }
766
767
 
768
+
767
769
  })
770
+ if(exportss){
771
+ string = string + `\n return ${Object.keys(exportss).length > 0 ? `{${Object.keys(exportss).map(key => key + ':' + exportss[key]).join(',')}}` : Object.keys(exportss)[0]}`
772
+ }
768
773
 
769
774
  return string;
770
775
  }