vaderjs 1.3.3-alpha-38 → 1.3.3-alpha-40

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
@@ -191,168 +191,4 @@ Connect with the VaderJS community on [GitHub](https://github.com/Postr-Inc/Vade
191
191
 
192
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
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
194
+
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-38",
5
+ "version": "1.3.3-alpha-40",
6
6
  "bin": {
7
7
  "vader": "./vader.js"
8
8
  },
package/runtime/router.js CHANGED
@@ -269,40 +269,23 @@ class VaderRouter{
269
269
  // Allow pausing the route and run code before rendering
270
270
  await new Promise(async (resolve) => {
271
271
  await Component.router.use(req, res)
272
- if(!req.pause){
273
- resolve();
274
- }
272
+ if(req.pause){
273
+ let timer = setInterval(() => {
274
+ if(!req.pause){
275
+ resolve();
276
+ clearInterval(timer);
277
+ }
278
+ }, 1000);
279
+ }
275
280
  });
276
281
  } else if (Component.router.use && Component.isChild) {
277
282
  console.warn('Router.use() is not supported in child components');
278
- }
279
-
280
- // Check if the request is not paused
281
- if (!req.pause) {
282
- // Assuming Component.render() is an asynchronous function
283
+ }
283
284
  const renderedContent = await Component.render();
284
285
  document.querySelector('#root').innerHTML = renderedContent;
285
286
  Component.bindMount();
286
287
  Component.onMount();
287
- } else {
288
- console.log(`Request paused for ${req.path}`);
289
-
290
- // Continue rendering after a delay if the request is paused
291
- await new Promise((resolve) => {
292
- let i = setInterval(() => {
293
- if (!req.pause) {
294
- clearInterval(i);
295
- resolve();
296
- }
297
- }, 1000);
298
- });
299
-
300
- // Assuming Component.render() is an asynchronous function
301
- const renderedContent = await Component.render();
302
- document.querySelector('#root').innerHTML = renderedContent;
303
- Component.bindMount();
304
- Component.onMount();
305
- }
288
+
306
289
  } catch (error) {
307
290
  console.error(error);
308
291
  }