vaderjs 1.7.0 → 1.7.1

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 (3) hide show
  1. package/index.ts +1 -1
  2. package/main.js +41 -43
  3. package/package.json +1 -1
package/index.ts CHANGED
@@ -188,7 +188,7 @@ export const useState = <T>(initialState: T, persist: false) => {
188
188
  }
189
189
 
190
190
 
191
- return [initialState, setState];
191
+ return [() => initialState, setState];
192
192
  }
193
193
 
194
194
  if (!isServer) {
package/main.js CHANGED
@@ -110,9 +110,7 @@ const vader = {
110
110
  const handleReplacements = (code) => {
111
111
  let lines = code.split('\n')
112
112
  let newLines = []
113
- let isDefault
114
113
  for (let line of lines) {
115
-
116
114
  let hasImport = line.includes('import')
117
115
 
118
116
  if (hasImport && line.includes('.css')) {
@@ -206,8 +204,8 @@ async function generateApp() {
206
204
  code = handleReplacements(code)
207
205
  let size = code.length / 1024
208
206
  r = r.replace(process.cwd().replace(/\\/g, '/') + '/app', '')
209
- r = r.replace('.jsx', '.js').replace('.tsx', '.js')
210
- fs.mkdirSync(path.dirname(process.cwd() + '/dist/' + r), { recursive: true })
207
+ r = r.replace('.jsx', '.js').replace('.tsx', '.js')
208
+ fs.mkdirSync(path.join(process.cwd() + '/dist', path.dirname(r)), { recursive: true })
211
209
  fs.writeFileSync(process.cwd() + '/dist/' + path.dirname(r) + '/' + path.basename(r), `
212
210
  let route = window.location.pathname.split('/').filter(v => v !== '')
213
211
  let params = {
@@ -302,6 +300,7 @@ async function generateApp() {
302
300
  function handleFiles() {
303
301
  return new Promise(async (resolve, reject) => {
304
302
  try {
303
+ console.log(Glob)
305
304
  let glob = new Glob('public/**/*')
306
305
  for await (var i of glob.scan()) {
307
306
  let file = i
@@ -312,42 +311,42 @@ function handleFiles() {
312
311
  fs.copyFileSync(file, path.join(process.cwd() + '/dist', file))
313
312
  }
314
313
  let glob2 = new Glob('src/**/*')
315
- for await (var i of glob2.scan()) {
316
- var file = i
317
- fs.mkdirSync(path.join(process.cwd() + '/dist', path.dirname(file)), { recursive: true })
318
- // turn jsx to js
319
- if (file.includes('.jsx') || file.includes('.tsx')) {
320
- let code = await Bun.file(file).text()
321
-
322
- code = handleReplacements(code)
323
-
324
- file = file.replace('.jsx', '.js').replace('.tsx', '.js')
325
- fs.writeFileSync(path.join(process.cwd() + '/dist', file.replace('.jsx', '.js').replace('.tsx', '.js')), code)
326
- await Bun.spawn({
327
- cmd: ['bun', 'run', './dev/bundler.js'],
328
- cwd: process.cwd(),
329
- stdout: 'inherit',
330
- env: {
331
- ENTRYPOINT: path.join(process.cwd() + '/dist/' + file.replace('.jsx', '.js').replace('.tsx', '.js')),
332
- ROOT: process.cwd() + '/app/',
333
- OUT: path.dirname(file),
334
- shouldReplace: true,
335
- file: process.cwd() + '/dist/' + file.replace('.jsx', '.js').replace('.tsx', '.js'),
336
- DEV: mode === 'development',
337
- size: code.length / 1024,
338
- filePath: file.replace('.jsx', '.js'),
339
- isTs: false,
340
- INPUT: path.join(process.cwd(), file.replace('.js', '.jsx').replace('.tsx', '.js')),
341
- },
342
- onExit({ exitCode: code }) {
343
- if (code === 0) {
344
- resolve()
345
- } else {
346
- reject()
347
- }
348
- }
349
- })
350
- } else if (file.includes('.ts') || file.includes('.js')) {
314
+ for await (var i of glob2.scan()) {
315
+ var file = i
316
+ fs.mkdirSync(path.join(process.cwd() + '/dist', path.dirname(file)), { recursive: true })
317
+ // turn jsx to js
318
+ if (file.includes('.jsx') || file.includes('.tsx')) {
319
+ let code = await Bun.file(file).text()
320
+
321
+ code = handleReplacements(code)
322
+
323
+ file = file.replace('.jsx', '.js').replace('.tsx', '.js')
324
+ fs.writeFileSync(path.join(process.cwd() + '/dist', file.replace('.jsx', '.js').replace('.tsx', '.js')), code)
325
+ await Bun.spawn({
326
+ cmd: ['bun', 'run', './dev/bundler.js'],
327
+ cwd: process.cwd(),
328
+ stdout: 'inherit',
329
+ env: {
330
+ ENTRYPOINT: path.join(process.cwd() + '/dist/' + file.replace('.jsx', '.js').replace('.tsx', '.js')),
331
+ ROOT: process.cwd() + '/app/',
332
+ OUT: path.dirname(file),
333
+ shouldReplace: true,
334
+ file: process.cwd() + '/dist/' + file.replace('.jsx', '.js').replace('.tsx', '.js'),
335
+ DEV: mode === 'development',
336
+ size: code.length / 1024,
337
+ filePath: file.replace('.jsx', '.js'),
338
+ isTs: file.includes('.tsx'),
339
+ INPUT: path.join(process.cwd(), file.replace('.js', '.jsx').replace('.tsx', '.js')),
340
+ },
341
+ onExit({ exitCode: code }) {
342
+ if (code === 0) {
343
+ resolve()
344
+ } else {
345
+ reject()
346
+ }
347
+ }
348
+ })
349
+ } else if (file.includes('.ts')) {
351
350
  let code = await Bun.file(file).text()
352
351
  code = handleReplacements(code)
353
352
  file = file.replace('.ts', '.js')
@@ -362,10 +361,10 @@ function handleFiles() {
362
361
  OUT: path.dirname(file),
363
362
  file: process.cwd() + '/dist/' + file.replace('.ts', '.js'),
364
363
  DEV: mode === 'development',
365
- isTs: true,
364
+ isTS: true,
366
365
  size: code.length / 1024,
367
366
  filePath: file.replace('.ts', '.js'),
368
- INPUT: path.join(process.cwd(), file.replace('.ts', '.js')),
367
+ INPUT: path.join(process.cwd(), file.replace('.js', '.jsx')),
369
368
  },
370
369
  onExit({ exitCode: code }) {
371
370
  if (code === 0) {
@@ -400,7 +399,6 @@ if (mode === 'development') {
400
399
  const handleFileChangeDebounced = async (change, file) => {
401
400
  if (file.endsWith('.tsx') || file.endsWith('.jsx') || file.endsWith('.css') || file.endsWith('.ts')
402
401
  && !file.includes('node_module')
403
- || file.endsWith('.js') && !file.includes('dist')
404
402
  ) {
405
403
  // delete files cache
406
404
  if (file.endsWith('vader.config.ts')){
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"