vaderjs 1.4.0-90gbho234 → 1.4.1-h7iuy47
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/@integrations/ssg.js +189 -0
- package/LICENSE +21 -0
- package/README.md +26 -45
- package/binaries/IPC/index.js +277 -0
- package/binaries/main.js +1258 -479
- package/binaries/watcher.js +70 -66
- package/binaries/win32/check.ps1 +7 -0
- package/config/index.js +36 -0
- package/package.json +5 -6
- package/runtime/router.js +1 -1
- package/runtime/vader.js +1 -1
- package/vader.js +54 -89
- package/binaries/generator.js +0 -202
package/binaries/main.js
CHANGED
|
@@ -1,676 +1,1455 @@
|
|
|
1
1
|
import { Glob } from "bun";
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
|
|
5
|
+
import * as Bun from "bun";
|
|
6
|
+
|
|
7
|
+
import WebSocket from "ws";
|
|
8
|
+
|
|
5
9
|
let config = await import(process.cwd() + '/vader.config.js').then((m) => m ? m.default : {}).catch((e) => {
|
|
10
|
+
|
|
6
11
|
console.error(e)
|
|
12
|
+
|
|
7
13
|
return {}
|
|
14
|
+
|
|
8
15
|
})
|
|
16
|
+
|
|
17
|
+
import IPCServer from "vaderjs/binaries/IPC/index.js"
|
|
18
|
+
|
|
19
|
+
import { exec } from "child_process";
|
|
20
|
+
|
|
21
|
+
const IPC = IPCServer
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
globalThis.isVader = true
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
|
|
29
|
+
* @description - Call functions when the integration is triggered
|
|
30
|
+
|
|
31
|
+
* @param {function} fn
|
|
32
|
+
|
|
33
|
+
* @param {args} args
|
|
34
|
+
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
globalThis.call = async (fn, args) => {
|
|
38
|
+
|
|
39
|
+
return await fn(args) || void 0
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
9
43
|
/**@description - Used to store hmr websocket clients */
|
|
44
|
+
|
|
10
45
|
globalThis.clients = []
|
|
46
|
+
|
|
11
47
|
/**@description - Used to keep track of routes */
|
|
48
|
+
|
|
12
49
|
globalThis.routes = []
|
|
50
|
+
|
|
13
51
|
/**
|
|
52
|
+
|
|
14
53
|
* @description - Used to keep track of the mode
|
|
54
|
+
|
|
15
55
|
*/
|
|
16
|
-
|
|
56
|
+
|
|
57
|
+
globalThis.mode = ''
|
|
58
|
+
|
|
17
59
|
/**@usedby @transForm */
|
|
60
|
+
|
|
18
61
|
globalThis.isBuilding = false
|
|
62
|
+
|
|
19
63
|
globalThis.hasGenerated = []
|
|
64
|
+
|
|
65
|
+
let currentState = ''
|
|
66
|
+
|
|
20
67
|
/**
|
|
68
|
+
|
|
21
69
|
* @description - Used to keep track of the bundle size
|
|
70
|
+
|
|
22
71
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
PWD: process.cwd(),
|
|
31
|
-
onExit: (code) => {
|
|
32
|
-
globalThis.isBuilding = false
|
|
33
|
-
globalThis.oneAndDone = true
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
cmd: ['node', 'generator.js'],
|
|
37
|
-
})
|
|
38
|
-
globalThis.generatorWs = new WebSocket(`ws://localhost:${3436}`)
|
|
39
|
-
globalThis.generatorWs.on('message', (message) => {
|
|
40
|
-
let data = JSON.parse(message.toString())
|
|
41
|
-
switch(true){
|
|
42
|
-
case data.type === 'done':
|
|
43
|
-
let file = data.file
|
|
44
|
-
globalThis.hasGenerated.push(file)
|
|
45
|
-
console.log('Generated', file)
|
|
46
|
-
break;
|
|
47
|
-
case data.type === 'error':
|
|
48
|
-
console.error(data.message)
|
|
49
|
-
break;
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
globalThis.generatorWs.on('connection', (ws) => {
|
|
53
|
-
console.log('Connected to generator...')
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
if(!globalThis.generatorWs.readyState === 1){
|
|
57
|
-
console.log('Generator is not ready...')
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
72
|
+
|
|
73
|
+
let bundleSize = 0
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
61
79
|
/**
|
|
80
|
+
|
|
62
81
|
* @description - variables used to generate arrays of paths recursively
|
|
82
|
+
|
|
63
83
|
*/
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
84
|
+
|
|
85
|
+
const glob = new Glob("/pages/**/**/*.{,tsx,js,jsx}", { absolute: true });
|
|
86
|
+
|
|
87
|
+
const vaderGlob = new Glob("/node_modules/vaderjs/runtime/**/**/*.{,tsx,js}", { absolute: true });
|
|
88
|
+
|
|
89
|
+
const srcGlob = new Glob("/src/**/**/*.{jsx,ts,tsx,js}", { absolute: true });
|
|
90
|
+
|
|
91
|
+
const publicGlob = new Glob("/public/**/**/*.{css,js,html,jpg,png,gif,svg,ico,video,webm,mp4,jpeg}", { absolute: true });
|
|
92
|
+
|
|
93
|
+
const distPages = new Glob("/dist/pages/**/**/*.{tsx,js,jsx}", { absolute: true })
|
|
94
|
+
|
|
95
|
+
const distSrc = new Glob("/dist/src/**/**/*.{tsx,js,jsx}", { absolute: true })
|
|
96
|
+
|
|
97
|
+
const distPublic = new Glob("/dist/public/**/**/*.{css,js,html,jpg,png,gif,svg,ico,video,webm,mp4,jpeg}", { absolute: true });
|
|
98
|
+
|
|
99
|
+
|
|
71
100
|
|
|
72
101
|
const router = new Bun.FileSystemRouter({
|
|
102
|
+
|
|
73
103
|
style: "nextjs",
|
|
104
|
+
|
|
74
105
|
dir: process.cwd() + '/pages',
|
|
106
|
+
|
|
75
107
|
origin: process.env.ORIGIN || "http://localhost:3000",
|
|
108
|
+
|
|
76
109
|
assetPrefix: "_next/static/"
|
|
77
|
-
|
|
110
|
+
|
|
111
|
+
});
|
|
112
|
+
|
|
78
113
|
/**
|
|
114
|
+
|
|
79
115
|
* @function handleReplaceMents
|
|
116
|
+
|
|
80
117
|
* @description - replaces data to be compatible with Vader.js
|
|
118
|
+
|
|
81
119
|
* @param {*} data
|
|
120
|
+
|
|
82
121
|
* @returns
|
|
122
|
+
|
|
83
123
|
*/
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
124
|
+
|
|
125
|
+
function handleReplaceMents(data) {
|
|
126
|
+
|
|
127
|
+
data.split('\n').forEach((line, index) => {
|
|
128
|
+
|
|
129
|
+
switch (true) {
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
88
133
|
case line.includes('useReducer') && !line.includes('import'):
|
|
134
|
+
|
|
89
135
|
line = line.replaceAll(/\s+/g, " ");
|
|
90
136
|
|
|
137
|
+
|
|
138
|
+
|
|
91
139
|
let varTypereducer = line.split("=")[0].trim().split("[")[0].trim();
|
|
140
|
+
|
|
92
141
|
let keyreducer = line.split("=")[0].trim().split("[")[1].trim().split(",")[0].trim();
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
142
|
+
|
|
143
|
+
let setKeyreducer = line.split("=")[0].trim().split(",")[1].trim().replace("]", "");
|
|
144
|
+
|
|
145
|
+
let reducer = line.split("=")[1].split("useReducer(")[1];
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
let newStatereducer = `${varTypereducer} [${keyreducer}, ${setKeyreducer}] = this.useReducer('${keyreducer}', ${line.includes('=>') ? reducer + '=>{' : reducer}`;
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
data = data.replace(line, newStatereducer);
|
|
154
|
+
|
|
155
|
+
break
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
case line.includes('useState') && !line.includes('import'):
|
|
160
|
+
|
|
161
|
+
let varType = line.split("[")[0]
|
|
162
|
+
|
|
163
|
+
if (!line.split("=")[0].split(",")[1]) {
|
|
164
|
+
|
|
165
|
+
throw new Error('You forgot to value selector (useState) ' + ' at ' + `${file}:${string.split(line)[0].split('\n').length}`)
|
|
166
|
+
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
let key = line.split("=")[0].split(",")[0].trim().split('[')[1];
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
if (!line.split("=")[0].split(",")[1]) {
|
|
174
|
+
|
|
175
|
+
throw new Error('You forgot to add a setter (useState) ' + ' at ' + `${file}:${string.split(line)[0].split('\n').length}`)
|
|
176
|
+
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let setKey = line.split("=")[0].split(",")[1].trim().replace("]", "");
|
|
180
|
+
|
|
181
|
+
key = key.replace("[", "").replace(",", "");
|
|
182
|
+
|
|
183
|
+
let valuestate = line.split("=")[1].split("useState(")[1];
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
let regex = /useState\((.*)\)/gs;
|
|
188
|
+
|
|
189
|
+
valuestate = valuestate.match(regex) ? valuestate.match(regex)[0].split("useState(")[1].split(")")[0].trim() : valuestate
|
|
190
|
+
|
|
191
|
+
let newState = `${varType} [${key}, ${setKey}] = this.useState('${key}', ${valuestate}`;
|
|
192
|
+
|
|
193
|
+
data = data.replace(line, newState);
|
|
194
|
+
|
|
195
|
+
break;
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
case line.includes("useRef") && !line.includes("import"):
|
|
200
|
+
|
|
201
|
+
line = line.trim();
|
|
202
|
+
|
|
203
|
+
let typeref = line.split(" ")[0]
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
let keyref = line.split(typeref)[1].split("=")[0].trim().replace("[", "").replace(",", "");
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
let valueref = line.split("=")[1].split("useRef(")[1];
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
let newStateref = `${typeref} ${keyref} = this.useRef('${keyref}', ${valueref}`;
|
|
218
|
+
|
|
219
|
+
data = data.replace(line, newStateref);
|
|
220
|
+
|
|
221
|
+
case line.includes('.jsx') && line.includes('import') || line.includes('.tsx') && line.includes('import'):
|
|
222
|
+
|
|
133
223
|
let old = line
|
|
224
|
+
|
|
134
225
|
line = line.replace('.jsx', '.js')
|
|
226
|
+
|
|
135
227
|
line = line.replace('.tsx', '.js')
|
|
228
|
+
|
|
136
229
|
data = data.replace(old, line)
|
|
137
|
-
|
|
138
|
-
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
break;
|
|
234
|
+
|
|
139
235
|
}
|
|
140
|
-
|
|
141
|
-
|
|
236
|
+
|
|
237
|
+
})
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
142
241
|
data = data.replaceAll('jsxDEV', 'Vader.createElement')
|
|
242
|
+
|
|
143
243
|
data = data.replaceAll('jsx', 'Vader.createElement')
|
|
244
|
+
|
|
144
245
|
data = data.replaceAll('vaderjs/client', '/vader.js')
|
|
145
|
-
|
|
246
|
+
|
|
247
|
+
data = data.replaceAll('.tsx', '.js')
|
|
248
|
+
|
|
146
249
|
let reactImportMatch = data.match(/import React/g);
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
250
|
+
|
|
251
|
+
if (reactImportMatch) {
|
|
252
|
+
|
|
253
|
+
let fullmatch = data.match(/import React from "react"/g);
|
|
254
|
+
|
|
255
|
+
if (fullmatch) {
|
|
256
|
+
|
|
257
|
+
data = data.replaceAll('import React from "react"', '');
|
|
258
|
+
|
|
259
|
+
}
|
|
260
|
+
|
|
152
261
|
}
|
|
262
|
+
|
|
153
263
|
data = data.replaceAll('.ts', '.js')
|
|
154
264
|
|
|
265
|
+
|
|
266
|
+
|
|
155
267
|
// check if Vader is imported
|
|
268
|
+
|
|
156
269
|
let vaderImport = data.match(/import Vader/g);
|
|
157
|
-
|
|
270
|
+
|
|
271
|
+
if (!vaderImport) {
|
|
272
|
+
|
|
158
273
|
data = `import Vader from "/vader.js";\n` + data;
|
|
274
|
+
|
|
159
275
|
}
|
|
276
|
+
|
|
160
277
|
return data;
|
|
278
|
+
|
|
161
279
|
}
|
|
162
|
-
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
|
|
163
284
|
|
|
164
285
|
/**
|
|
286
|
+
|
|
165
287
|
* @function ContentType
|
|
288
|
+
|
|
166
289
|
* @description - returns the content type based on the file extension
|
|
290
|
+
|
|
167
291
|
* @param {*} url
|
|
292
|
+
|
|
168
293
|
* @returns
|
|
294
|
+
|
|
169
295
|
*/
|
|
170
|
-
|
|
171
|
-
|
|
296
|
+
|
|
297
|
+
const ContentType = (url) => {
|
|
298
|
+
|
|
299
|
+
switch (url.split('.').pop()) {
|
|
300
|
+
|
|
172
301
|
case 'css':
|
|
302
|
+
|
|
173
303
|
return 'text/css';
|
|
304
|
+
|
|
174
305
|
case 'js':
|
|
306
|
+
|
|
175
307
|
return 'text/javascript';
|
|
308
|
+
|
|
176
309
|
case 'json':
|
|
310
|
+
|
|
177
311
|
return 'application/json';
|
|
312
|
+
|
|
178
313
|
case 'html':
|
|
314
|
+
|
|
179
315
|
return 'text/html';
|
|
316
|
+
|
|
180
317
|
case 'jpg':
|
|
318
|
+
|
|
181
319
|
return 'image/jpg';
|
|
320
|
+
|
|
182
321
|
case 'png':
|
|
322
|
+
|
|
183
323
|
return 'image/png';
|
|
324
|
+
|
|
184
325
|
case 'gif':
|
|
326
|
+
|
|
185
327
|
return 'image/gif';
|
|
328
|
+
|
|
186
329
|
case 'svg':
|
|
330
|
+
|
|
187
331
|
return 'image/svg+xml';
|
|
332
|
+
|
|
188
333
|
case 'ico':
|
|
334
|
+
|
|
189
335
|
return 'image/x-icon';
|
|
336
|
+
|
|
190
337
|
default:
|
|
338
|
+
|
|
191
339
|
return 'text/html';
|
|
192
|
-
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
|
|
193
343
|
}
|
|
344
|
+
|
|
194
345
|
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
function Server
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
|
|
353
|
+
* @function Server
|
|
354
|
+
|
|
355
|
+
* @description - Creates a hmr development server
|
|
356
|
+
|
|
357
|
+
* @param {Number} port
|
|
358
|
+
|
|
359
|
+
*/
|
|
360
|
+
|
|
361
|
+
function Server(port) {
|
|
362
|
+
|
|
203
363
|
Bun.serve({
|
|
364
|
+
|
|
204
365
|
port: port,
|
|
205
|
-
|
|
366
|
+
|
|
367
|
+
async fetch(req, res) {
|
|
368
|
+
|
|
206
369
|
const url = new URL(req.url);
|
|
370
|
+
|
|
207
371
|
const success = res.upgrade(req);
|
|
208
|
-
|
|
372
|
+
|
|
373
|
+
if (success) {
|
|
374
|
+
|
|
209
375
|
return new Response('Connected', {
|
|
376
|
+
|
|
210
377
|
headers: {
|
|
378
|
+
|
|
211
379
|
"Content-Type": "text/html"
|
|
380
|
+
|
|
212
381
|
}
|
|
382
|
+
|
|
213
383
|
})
|
|
384
|
+
|
|
214
385
|
}
|
|
215
|
-
|
|
216
|
-
|
|
386
|
+
|
|
387
|
+
if (req.url.includes('.')) {
|
|
388
|
+
|
|
389
|
+
if (!fs.existsSync(process.cwd() + '/dist' + url.pathname)) {
|
|
390
|
+
|
|
391
|
+
return new Response('Not Found', {
|
|
392
|
+
|
|
393
|
+
status: 404,
|
|
394
|
+
|
|
395
|
+
headers: {
|
|
396
|
+
|
|
397
|
+
"Content-Type": "text/html"
|
|
398
|
+
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
console.log('Serving: ' + url.pathname)
|
|
406
|
+
|
|
407
|
+
return new Response(fs.readFileSync(process.cwd() + '/dist/' + url.pathname, 'utf-8'), {
|
|
408
|
+
|
|
217
409
|
headers: {
|
|
410
|
+
|
|
218
411
|
"Content-Type": ContentType(req.url)
|
|
412
|
+
|
|
219
413
|
}
|
|
414
|
+
|
|
220
415
|
})
|
|
416
|
+
|
|
221
417
|
}
|
|
418
|
+
|
|
222
419
|
let matchedRoute = router.match(url.pathname);
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
let
|
|
227
|
-
|
|
420
|
+
|
|
421
|
+
if (matchedRoute) {
|
|
422
|
+
|
|
423
|
+
let { filePath, kind, name, params, pathname, query, } = matchedRoute
|
|
424
|
+
|
|
425
|
+
let folder = url.pathname.split('/')[1]
|
|
426
|
+
|
|
427
|
+
let jsFile = filePath.split('pages/').pop().split('.').shift() + '.js'
|
|
428
|
+
|
|
429
|
+
let pageContent = fs.readFileSync(process.cwd() + '/dist/' + folder + '/index.html', 'utf8')
|
|
430
|
+
|
|
228
431
|
globalThis.mode === 'dev' ? pageContent += `
|
|
432
|
+
|
|
229
433
|
<script type="module">
|
|
434
|
+
|
|
230
435
|
let ws = new WebSocket('ws://localhost:${port}');
|
|
436
|
+
|
|
231
437
|
ws.onmessage = async (e) => {
|
|
438
|
+
|
|
232
439
|
if(e.data === 'reload'){
|
|
440
|
+
|
|
233
441
|
window.location.reload()
|
|
442
|
+
|
|
234
443
|
console.log('Reloading...')
|
|
444
|
+
|
|
235
445
|
}
|
|
446
|
+
|
|
236
447
|
}
|
|
448
|
+
|
|
237
449
|
</script>
|
|
450
|
+
|
|
238
451
|
` : void 0
|
|
239
|
-
|
|
452
|
+
|
|
453
|
+
return new Response(pageContent, {
|
|
454
|
+
|
|
240
455
|
headers: {
|
|
456
|
+
|
|
241
457
|
"Content-Type": "text/html",
|
|
458
|
+
|
|
242
459
|
"X-Powered-By": "Vader.js v1.3.3"
|
|
460
|
+
|
|
243
461
|
}
|
|
462
|
+
|
|
244
463
|
})
|
|
464
|
+
|
|
245
465
|
}
|
|
246
|
-
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
|
|
247
469
|
return new Response('Not Found', {
|
|
470
|
+
|
|
248
471
|
status: 404,
|
|
472
|
+
|
|
249
473
|
headers: {
|
|
474
|
+
|
|
250
475
|
"Content-Type": "text/html"
|
|
476
|
+
|
|
251
477
|
}
|
|
478
|
+
|
|
252
479
|
})
|
|
480
|
+
|
|
253
481
|
},
|
|
254
|
-
|
|
255
|
-
|
|
482
|
+
|
|
483
|
+
websocket: {
|
|
484
|
+
|
|
485
|
+
open(ws) {
|
|
486
|
+
|
|
256
487
|
clients.push(ws)
|
|
488
|
+
|
|
257
489
|
},
|
|
490
|
+
|
|
258
491
|
}
|
|
492
|
+
|
|
259
493
|
})
|
|
494
|
+
|
|
260
495
|
}
|
|
496
|
+
|
|
261
497
|
/**
|
|
498
|
+
|
|
262
499
|
* @function write
|
|
500
|
+
|
|
263
501
|
* @description - Writes data to a file
|
|
502
|
+
|
|
264
503
|
* @returns {void} 0
|
|
504
|
+
|
|
265
505
|
* @param {string} file
|
|
506
|
+
|
|
266
507
|
* @param {any} data
|
|
508
|
+
|
|
267
509
|
* @returns
|
|
510
|
+
|
|
268
511
|
*/
|
|
269
|
-
|
|
512
|
+
|
|
513
|
+
const write = (file, data) => {
|
|
514
|
+
|
|
270
515
|
try {
|
|
271
|
-
|
|
516
|
+
|
|
517
|
+
if (!fs.existsSync('./dist')) {
|
|
518
|
+
|
|
272
519
|
fs.mkdirSync('./dist')
|
|
273
|
-
|
|
520
|
+
|
|
521
|
+
}
|
|
522
|
+
|
|
274
523
|
Bun.write(file, data);
|
|
524
|
+
|
|
275
525
|
} catch (error) {
|
|
526
|
+
|
|
276
527
|
console.error(error)
|
|
528
|
+
|
|
277
529
|
}
|
|
278
|
-
|
|
530
|
+
|
|
531
|
+
|
|
532
|
+
|
|
279
533
|
}
|
|
534
|
+
|
|
280
535
|
/**
|
|
536
|
+
|
|
281
537
|
* @function read
|
|
538
|
+
|
|
282
539
|
* @param {path} file
|
|
540
|
+
|
|
283
541
|
* @returns {Promise<string>}
|
|
542
|
+
|
|
284
543
|
*/
|
|
544
|
+
|
|
285
545
|
const read = async (file) => {
|
|
546
|
+
|
|
286
547
|
return await Bun.file(file).text();
|
|
548
|
+
|
|
287
549
|
}
|
|
288
550
|
|
|
289
551
|
/**
|
|
290
|
-
|
|
291
|
-
* @
|
|
552
|
+
|
|
553
|
+
* @object integrationStates
|
|
554
|
+
|
|
555
|
+
* @description - Used to store integration states
|
|
556
|
+
|
|
557
|
+
*/
|
|
558
|
+
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
globalThis.integrationStates = []
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
|
|
565
|
+
* @description a boolean value that checks if vader is being used - useful for running toplevel code at integration start
|
|
566
|
+
|
|
567
|
+
*/
|
|
568
|
+
|
|
569
|
+
globalThis.context = {
|
|
570
|
+
|
|
571
|
+
vader: true
|
|
572
|
+
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
|
|
577
|
+
* @function handleIntegrations
|
|
578
|
+
|
|
579
|
+
* @description - Handles module integrations that add more functionality to Vader.js
|
|
580
|
+
|
|
292
581
|
* @returns {void} 0
|
|
582
|
+
|
|
293
583
|
*/
|
|
294
|
-
async function generateProviderRoutes(){
|
|
295
|
-
if(!config?.host?.provider){
|
|
296
|
-
console.warn('No provider found in vader.config.js ignoring route generation...')
|
|
297
|
-
return void 0;
|
|
298
|
-
}
|
|
299
|
-
let providerType = [{
|
|
300
|
-
provider: 'vercel',
|
|
301
|
-
file: 'vercel.json',
|
|
302
|
-
out: process.cwd() + '/vercel.json',
|
|
303
|
-
obj: {
|
|
304
|
-
rewrites:[]
|
|
305
|
-
}
|
|
306
|
-
},{
|
|
307
|
-
provider: 'cloudflare',
|
|
308
|
-
file:'_redirects',
|
|
309
|
-
out: 'dist/_redirects'
|
|
310
|
-
}]
|
|
311
|
-
|
|
312
|
-
let provider = providerType.find((p) => p.provider === config.host.provider)
|
|
313
|
-
if(provider){
|
|
314
|
-
let prev = null
|
|
315
|
-
|
|
316
|
-
switch(provider.provider){
|
|
317
|
-
case 'vercel':
|
|
318
|
-
prev = await read(provider.out);
|
|
319
|
-
if(!prev.includes('rewrites')){
|
|
320
|
-
prev = []
|
|
321
|
-
} else{
|
|
322
|
-
prev = JSON.parse(prev).rewrites
|
|
323
|
-
}
|
|
324
|
-
routes.forEach((r) => {
|
|
325
|
-
if(r.path === '/'
|
|
326
|
-
|| prev.find((p) => p.source === '/'+ r.path + '/index.html')
|
|
327
|
-
){
|
|
328
|
-
return void 0;
|
|
329
|
-
}
|
|
330
|
-
prev.push({
|
|
331
|
-
source: '/'+ r.path,
|
|
332
|
-
destination: '/'+ r.path + '/index.html'
|
|
333
|
-
})
|
|
334
584
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
585
|
+
function handleIntegrations() {
|
|
586
|
+
|
|
587
|
+
if (config?.integrations) {
|
|
588
|
+
|
|
589
|
+
config.integrations.forEach((integration) => {
|
|
590
|
+
|
|
591
|
+
let int = integration
|
|
592
|
+
|
|
593
|
+
globalThis.integrationStates.push(int)
|
|
594
|
+
|
|
595
|
+
})
|
|
347
596
|
|
|
348
|
-
fs.writeFileSync(provider.out, JSON.stringify({rewrites: prev}, null, 2))
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
})
|
|
352
|
-
provider.obj.rewrites = prev
|
|
353
|
-
write(provider.out, JSON.stringify(provider.obj, null, 2))
|
|
354
|
-
break;
|
|
355
|
-
case 'cloudflare':
|
|
356
|
-
console.warn('Cloudflare is not supported yet refer to their documentation for more information:https://developers.cloudflare.com/pages/configuration/redirects/')
|
|
357
|
-
break;
|
|
358
597
|
}
|
|
359
598
|
|
|
360
599
|
|
|
361
|
-
|
|
362
600
|
|
|
363
|
-
|
|
364
|
-
|
|
601
|
+
return void 0;
|
|
602
|
+
|
|
365
603
|
}
|
|
366
604
|
|
|
605
|
+
handleIntegrations()
|
|
606
|
+
|
|
367
607
|
/**
|
|
368
|
-
|
|
369
|
-
* @
|
|
608
|
+
|
|
609
|
+
* @function generateProviderRoutes
|
|
610
|
+
|
|
611
|
+
* @description - Generates routes for hosting provders ie: vercel, cloudflare
|
|
612
|
+
|
|
613
|
+
* @returns {void} 0
|
|
614
|
+
|
|
370
615
|
*/
|
|
371
|
-
|
|
372
|
-
async function
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
if(route){
|
|
381
|
-
let {filePath, kind, name, params, pathname, query,} = route
|
|
382
|
-
let data = await read(filePath);
|
|
383
|
-
try{
|
|
384
|
-
data = new Bun.Transpiler({loader: "tsx", target:"browser", }).transformSync(data);
|
|
385
|
-
}catch(e){
|
|
386
|
-
console.error(e)
|
|
387
|
-
}
|
|
388
|
-
let out = `./dist/pages/${isBasePath ? 'index.js' : folder + '/index.js'}`;
|
|
389
|
-
isBasePath ? folder = '/': null;
|
|
390
|
-
data = handleReplaceMents(data);
|
|
391
|
-
globalThis.routes.push({path: folder, file: out, isParam: kind === 'dynamic' ? true : false, params, query, pathname})
|
|
392
|
-
write(out, data);
|
|
393
|
-
bundleSize += data.length
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
616
|
+
|
|
617
|
+
async function generateProviderRoutes() {
|
|
618
|
+
|
|
619
|
+
if (!config?.host?.provider) {
|
|
620
|
+
|
|
621
|
+
console.warn('No provider found in vader.config.js ignoring route generation...')
|
|
622
|
+
|
|
623
|
+
return void 0;
|
|
624
|
+
|
|
398
625
|
}
|
|
399
626
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
627
|
+
let providerType = [{
|
|
628
|
+
|
|
629
|
+
provider: 'vercel',
|
|
630
|
+
|
|
631
|
+
file: 'vercel.json',
|
|
632
|
+
|
|
633
|
+
out: process.cwd() + '/vercel.json',
|
|
634
|
+
|
|
635
|
+
obj: {
|
|
636
|
+
|
|
637
|
+
rewrites: []
|
|
638
|
+
|
|
403
639
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
break;
|
|
436
|
-
case 'jsx':
|
|
437
|
-
let transpilerjx = new Bun.Transpiler({loader: "jsx", target:"browser", });
|
|
438
|
-
let datajx = await read(file);
|
|
439
|
-
try {
|
|
440
|
-
datajx = transpilerjx.transformSync(datajx);
|
|
441
|
-
} catch (error) {
|
|
442
|
-
console.error(error)
|
|
640
|
+
|
|
641
|
+
}, {
|
|
642
|
+
|
|
643
|
+
provider: 'cloudflare',
|
|
644
|
+
|
|
645
|
+
file: '_redirects',
|
|
646
|
+
|
|
647
|
+
out: 'dist/_redirects'
|
|
648
|
+
|
|
649
|
+
}]
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
let provider = providerType.find((p) => p.provider === config.host.provider)
|
|
654
|
+
|
|
655
|
+
if (provider) {
|
|
656
|
+
|
|
657
|
+
let prev = null
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
|
|
661
|
+
switch (provider.provider) {
|
|
662
|
+
|
|
663
|
+
case 'vercel':
|
|
664
|
+
|
|
665
|
+
if (!fs.existsSync(provider.out)) {
|
|
666
|
+
|
|
667
|
+
fs.writeFileSync(provider.out, JSON.stringify({ rewrites: [] }))
|
|
668
|
+
|
|
443
669
|
}
|
|
444
|
-
datajx = handleReplaceMents(datajx);
|
|
445
|
-
file = file.replace('.jsx', '.js')
|
|
446
|
-
let pathjx = process.cwd() +'/dist/src/' + file.split('src/').pop()
|
|
447
|
-
write(pathjx, datajx);
|
|
448
|
-
bundleSize += datajx.length
|
|
449
|
-
break;
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
|
|
453
670
|
|
|
454
|
-
|
|
455
|
-
let data = await read(file);
|
|
456
|
-
file = file.replace(/\\/g, '/');
|
|
457
|
-
write(process.cwd() +'/dist/public/' + file.split('public/').pop(), data);
|
|
458
|
-
bundleSize += fs.statSync(process.cwd() +'/dist/public/' + file.split('public/').pop()).size
|
|
459
|
-
}
|
|
460
|
-
for await (var file of vaderGlob.scan('.')) {
|
|
461
|
-
let data = await read(file);
|
|
462
|
-
file = file.replace(/\\/g, '/');
|
|
463
|
-
write(process.cwd() +'/dist/' + file.split('node_modules/vaderjs/runtime/').pop(), data);
|
|
464
|
-
bundleSize += fs.statSync(process.cwd() +'/dist/' + file.split('node_modules/vaderjs/runtime/').pop()).size
|
|
465
|
-
}
|
|
671
|
+
prev = await read(provider.out);
|
|
466
672
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
fs.unlinkSync(file)
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
}
|
|
673
|
+
if (!prev) {
|
|
674
|
+
|
|
675
|
+
prev = []
|
|
676
|
+
|
|
677
|
+
} else {
|
|
678
|
+
|
|
679
|
+
prev = JSON.parse(prev).rewrites
|
|
478
680
|
|
|
479
|
-
for await( var file of distSrc.scan('.')){
|
|
480
|
-
file = file.replace(/\\/g, '/');
|
|
481
|
-
let path = process.cwd() +'/src/' + file.split('dist/src/').pop()
|
|
482
|
-
// if the file is a js file see if theirs a matching ts file
|
|
483
|
-
if(file.split('.').pop() === 'js'){
|
|
484
|
-
let tsFile = path.replace('.js', '.ts')
|
|
485
|
-
// if the ts file exists then the js file is valid else if not the js file exists then remove
|
|
486
|
-
switch(true){
|
|
487
|
-
case !fs.existsSync(tsFile):
|
|
488
|
-
// check if a tsx or jsx file exists
|
|
489
|
-
let tsxFile = path.replace('.js', '.tsx')
|
|
490
|
-
let jsxFile = path.replace('.js', '.jsx')
|
|
491
|
-
let tsfile = path.replace('.js', '.ts')
|
|
492
|
-
switch(true){
|
|
493
|
-
case fs.existsSync(tsxFile):
|
|
494
|
-
break;
|
|
495
|
-
case fs.existsSync(jsxFile):
|
|
496
|
-
break;
|
|
497
|
-
case fs.existsSync(tsfile):
|
|
498
|
-
break
|
|
499
|
-
default:
|
|
500
|
-
fs.unlinkSync(file)
|
|
501
|
-
break;
|
|
502
681
|
}
|
|
682
|
+
|
|
683
|
+
routes.forEach((r) => {
|
|
684
|
+
|
|
685
|
+
let previous = prev.find((p) => p.source.includes(r.path))
|
|
686
|
+
|
|
687
|
+
if (previous) {
|
|
688
|
+
|
|
689
|
+
return void 0;
|
|
690
|
+
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
|
|
694
|
+
|
|
695
|
+
prev.push({
|
|
696
|
+
|
|
697
|
+
source: '/' + r.path,
|
|
698
|
+
|
|
699
|
+
destination: '/' + r.path + '/index.html'
|
|
700
|
+
|
|
701
|
+
})
|
|
702
|
+
|
|
703
|
+
|
|
704
|
+
|
|
705
|
+
if (r.params.length > 0) {
|
|
706
|
+
|
|
707
|
+
r.params.forEach((param) => {
|
|
708
|
+
|
|
709
|
+
if (!param.paramData) {
|
|
710
|
+
|
|
711
|
+
return void 0;
|
|
712
|
+
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
let parampath = Object.keys(param.paramData).map((p) => `:${p}`).join('/')
|
|
716
|
+
|
|
717
|
+
prev.push({
|
|
718
|
+
|
|
719
|
+
source: '/' + r.path + '/' + parampath,
|
|
720
|
+
|
|
721
|
+
destination: '/' + r.path + '/index.html'
|
|
722
|
+
|
|
723
|
+
})
|
|
724
|
+
|
|
725
|
+
})
|
|
726
|
+
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
fs.writeFileSync(provider.out, JSON.stringify({ rewrites: prev }, null, 2))
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
|
|
737
|
+
})
|
|
738
|
+
|
|
739
|
+
provider.obj.rewrites = prev
|
|
740
|
+
|
|
741
|
+
write(provider.out, JSON.stringify(provider.obj, null, 2))
|
|
742
|
+
|
|
503
743
|
break;
|
|
504
|
-
|
|
505
|
-
|
|
744
|
+
|
|
745
|
+
case 'cloudflare':
|
|
746
|
+
|
|
747
|
+
console.warn('Cloudflare is not supported yet refer to their documentation for more information:https://developers.cloudflare.com/pages/configuration/redirects/')
|
|
748
|
+
|
|
506
749
|
break;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
750
|
|
|
511
|
-
for await( var file of distPublic.scan('.')){
|
|
512
|
-
file = file.replace(/\\/g, '/');
|
|
513
|
-
let path = process.cwd() +'/public/' + file.split('dist/public/').pop()
|
|
514
|
-
if(!fs.existsSync(path)){
|
|
515
|
-
fs.unlinkSync(file)
|
|
516
|
-
}
|
|
517
751
|
}
|
|
518
752
|
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
/**
|
|
522
|
-
* @function organizeRoutes
|
|
523
|
-
* @description - Organizes routes that have param paths
|
|
524
|
-
*/
|
|
525
|
-
|
|
526
|
-
const organizeRoutes = () => {
|
|
527
|
-
// if path starts with the same path and is dynamic then they are the same route and push params to the same route
|
|
528
|
-
let newRoutes = []
|
|
529
|
-
routes.forEach((route) => {
|
|
530
|
-
let exists = routes.find((r) => r.path.startsWith(route.path) && r.isParam === true)
|
|
531
|
-
if(exists){
|
|
532
|
-
let b4Params = route.params
|
|
533
|
-
route.params = []
|
|
534
|
-
route.params.push(b4Params)
|
|
535
|
-
route.params.push( {
|
|
536
|
-
jsFile: '/pages/' + exists.path + '/index.js',
|
|
537
|
-
folder: '/pages/' + exists.path,
|
|
538
|
-
paramData:exists.params
|
|
539
|
-
}
|
|
540
|
-
)
|
|
541
|
-
route.query = exists.query
|
|
542
|
-
newRoutes.push(route)
|
|
543
|
-
}
|
|
544
|
-
else if(!exists && !route.isParam){
|
|
545
|
-
newRoutes.push(route)
|
|
546
|
-
|
|
547
|
-
}
|
|
548
|
-
//remove param route that matched
|
|
549
|
-
routes = routes.filter((r) => exists ? r.path !== exists.path : true)
|
|
550
|
-
|
|
551
|
-
})
|
|
552
|
-
globalThis.routes = newRoutes
|
|
553
|
-
}
|
|
554
|
-
organizeRoutes()
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
if(globalThis.mode === 'dev' && !globalThis.oneAndDone || globalThis.mode === 'build'){
|
|
558
|
-
|
|
559
|
-
/**
|
|
560
|
-
* @description - create an html file for each route
|
|
561
|
-
*/
|
|
562
|
-
routes.forEach((r)=>{
|
|
563
753
|
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
params: JSON.stringify(r.params),
|
|
572
|
-
}))
|
|
573
|
-
|
|
574
|
-
})
|
|
575
|
-
let i = setInterval(() => {
|
|
576
|
-
if(hasGenerated.length === routes.length){
|
|
577
|
-
globalThis.generatorWs.send(JSON.stringify({
|
|
578
|
-
type:'done'
|
|
579
|
-
}))
|
|
580
|
-
globalThis.oneAndDone = true
|
|
581
|
-
clearInterval(i)
|
|
582
|
-
}
|
|
583
|
-
}, 1000)
|
|
754
|
+
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
|
|
758
|
+
|
|
759
|
+
|
|
760
|
+
|
|
584
761
|
}
|
|
585
|
-
|
|
586
|
-
globalThis.isBuilding = false
|
|
587
|
-
console.log(`Finished building ${Math.round(bundleSize / 1000)}kb`)
|
|
588
|
-
bundleSize = 0
|
|
762
|
+
|
|
589
763
|
return void 0;
|
|
590
|
-
|
|
764
|
+
|
|
591
765
|
}
|
|
592
|
-
let port = 3000
|
|
593
|
-
switch (true) {
|
|
594
|
-
case process.argv.includes('dev') && !process.argv.includes('build') && !process.argv.includes('start'):
|
|
595
|
-
|
|
596
|
-
port = process.env.PORT || process.argv.includes('-p') ? process.argv[process.argv.indexOf('-p') + 1] : 3000
|
|
597
|
-
globalThis.oneAndDone = false
|
|
598
|
-
console.log(`
|
|
599
|
-
Vader.js v${fs.readFileSync(process.cwd() + '/node_modules/vaderjs/package.json', 'utf8').split('"version": "')[1].split('"')[0]}
|
|
600
|
-
- Watching for changes in ./pages
|
|
601
|
-
- Watching for changes in ./src
|
|
602
|
-
- Watching for changes in ./public
|
|
603
|
-
- Serving on port ${port}
|
|
604
|
-
`)
|
|
605
|
-
globalThis.mode = 'dev'
|
|
606
|
-
Server(port)
|
|
607
|
-
transForm()
|
|
608
766
|
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
767
|
+
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
|
|
771
|
+
* @function transform
|
|
772
|
+
|
|
773
|
+
* @description - Transforms the jsx files to js files based on file paths
|
|
774
|
+
|
|
775
|
+
*/
|
|
776
|
+
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
async function transForm() {
|
|
780
|
+
|
|
781
|
+
return new Promise(async (resolve, reject) => {
|
|
782
|
+
|
|
783
|
+
globalThis.isBuilding = true
|
|
784
|
+
|
|
785
|
+
router.reload()
|
|
786
|
+
|
|
787
|
+
for await (var file of glob.scan('.')) {
|
|
788
|
+
|
|
789
|
+
file = file.replace(/\\/g, '/');
|
|
790
|
+
|
|
791
|
+
let isBasePath = file.split('pages/')?.[1]?.split('/').length === 1;
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
let folder = file.split('pages/')?.[1]?.split('/').slice(0, -1).join('/') || null;
|
|
796
|
+
|
|
797
|
+
if (isBasePath) {
|
|
798
|
+
|
|
799
|
+
folder = '/'
|
|
800
|
+
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
let route = isBasePath ? router.match('/') : router.match('/' + folder)
|
|
804
|
+
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
if (route) {
|
|
808
|
+
|
|
809
|
+
let { filePath, kind, name, params, pathname, query, } = route
|
|
810
|
+
|
|
811
|
+
let data = await read(filePath);
|
|
812
|
+
|
|
813
|
+
try {
|
|
814
|
+
|
|
815
|
+
data = new Bun.Transpiler({ loader: "tsx", target: "browser", }).transformSync(data);
|
|
816
|
+
|
|
817
|
+
} catch (e) {
|
|
818
|
+
|
|
819
|
+
console.error(e)
|
|
820
|
+
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
let out = `./dist/${isBasePath ? 'index.js' : folder + '/index.js'}`;
|
|
824
|
+
|
|
825
|
+
isBasePath ? folder = '/' : null;
|
|
826
|
+
|
|
827
|
+
data = handleReplaceMents(data);
|
|
828
|
+
|
|
829
|
+
let isAparam = null
|
|
830
|
+
|
|
831
|
+
if (folder === "") {
|
|
832
|
+
|
|
833
|
+
return
|
|
834
|
+
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
switch (true) {
|
|
838
|
+
|
|
839
|
+
case kind === 'dynamic':
|
|
840
|
+
|
|
841
|
+
isAparam = true
|
|
842
|
+
|
|
843
|
+
break;
|
|
844
|
+
|
|
845
|
+
case kind === 'catch-all':
|
|
846
|
+
|
|
847
|
+
isAparam = true
|
|
848
|
+
|
|
849
|
+
break;
|
|
850
|
+
|
|
851
|
+
case kind === 'optional-catch-all':
|
|
852
|
+
|
|
853
|
+
isAparam = true
|
|
854
|
+
|
|
855
|
+
break;
|
|
856
|
+
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
routes.push({ path: folder, file: out, isParam: isAparam, params: params, query, pathname })
|
|
860
|
+
|
|
861
|
+
write(out, data);
|
|
862
|
+
|
|
863
|
+
bundleSize += data.length
|
|
864
|
+
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
|
|
872
|
+
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
for await (var file of srcGlob.scan('.')) {
|
|
878
|
+
|
|
879
|
+
if (!fs.existsSync(process.cwd() + '/dist/src/')) {
|
|
880
|
+
|
|
881
|
+
fs.mkdirSync(process.cwd() + '/dist/src/')
|
|
882
|
+
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
file = file.replace(/\\/g, '/');
|
|
886
|
+
|
|
887
|
+
switch (file.split('.').pop()) {
|
|
888
|
+
|
|
889
|
+
case 'ts':
|
|
890
|
+
|
|
891
|
+
let transpiler = new Bun.Transpiler({ loader: "ts", target: "browser", });
|
|
892
|
+
|
|
893
|
+
let data = await read(file);
|
|
894
|
+
|
|
895
|
+
try {
|
|
896
|
+
|
|
897
|
+
data = transpiler.transformSync(data);
|
|
898
|
+
|
|
899
|
+
} catch (error) {
|
|
900
|
+
|
|
901
|
+
console.error(error)
|
|
902
|
+
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
file = file.replace('.ts', '.js')
|
|
906
|
+
|
|
907
|
+
let path = process.cwd() + '/dist/src/' + file.split('src/').pop()
|
|
908
|
+
|
|
909
|
+
write(path, data);
|
|
910
|
+
|
|
911
|
+
bundleSize += data.length
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
break;
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
case 'tsx':
|
|
920
|
+
|
|
921
|
+
let transpilerx = new Bun.Transpiler({ loader: "tsx", target: "browser", });
|
|
922
|
+
|
|
923
|
+
let datax = await read(file);
|
|
924
|
+
|
|
925
|
+
try {
|
|
926
|
+
|
|
927
|
+
datax = transpilerx.transformSync(datax);
|
|
928
|
+
|
|
929
|
+
} catch (error) {
|
|
930
|
+
|
|
931
|
+
console.error(error)
|
|
932
|
+
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
datax = handleReplaceMents(datax);
|
|
936
|
+
|
|
937
|
+
file = file.replace('.tsx', '.js')
|
|
938
|
+
|
|
939
|
+
let pathx = process.cwd() + '/dist/src/' + file.split('src/').pop()
|
|
940
|
+
|
|
941
|
+
write(pathx, datax);
|
|
942
|
+
|
|
943
|
+
|
|
944
|
+
|
|
945
|
+
|
|
946
|
+
|
|
947
|
+
break;
|
|
948
|
+
|
|
949
|
+
case 'jsx':
|
|
950
|
+
|
|
951
|
+
let transpilerjx = new Bun.Transpiler({ loader: "jsx", target: "browser" });
|
|
952
|
+
|
|
953
|
+
let datajx = await read(file);
|
|
954
|
+
|
|
955
|
+
|
|
956
|
+
|
|
957
|
+
let source = transpilerjx.scan(datajx)
|
|
958
|
+
|
|
959
|
+
try {
|
|
960
|
+
|
|
961
|
+
datajx = transpilerjx.transformSync(datajx)
|
|
962
|
+
|
|
963
|
+
} catch (error) {
|
|
964
|
+
|
|
965
|
+
console.error(error)
|
|
966
|
+
|
|
967
|
+
}
|
|
968
|
+
|
|
969
|
+
datajx = handleReplaceMents(datajx);
|
|
970
|
+
|
|
971
|
+
file = file.replace('.jsx', '.js')
|
|
972
|
+
|
|
973
|
+
let pathjx = process.cwd() + '/dist/src/' + file.split('src/').pop()
|
|
974
|
+
|
|
975
|
+
write(pathjx, datajx);
|
|
976
|
+
|
|
977
|
+
bundleSize += datajx.length
|
|
978
|
+
|
|
979
|
+
break;
|
|
980
|
+
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
|
|
989
|
+
for await (var file of publicGlob.scan('.')) {
|
|
990
|
+
|
|
991
|
+
let data = await read(file);
|
|
992
|
+
|
|
993
|
+
file = file.replace(/\\/g, '/');
|
|
994
|
+
|
|
995
|
+
write(process.cwd() + '/dist/public/' + file.split('public/').pop(), data);
|
|
996
|
+
|
|
997
|
+
bundleSize += fs.statSync(process.cwd() + '/dist/public/' + file.split('public/').pop()).size
|
|
998
|
+
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
for await (var file of vaderGlob.scan('.')) {
|
|
1002
|
+
|
|
1003
|
+
let data = await read(file);
|
|
1004
|
+
|
|
1005
|
+
file = file.replace(/\\/g, '/');
|
|
1006
|
+
|
|
1007
|
+
write(process.cwd() + '/dist/' + file.split('node_modules/vaderjs/runtime/').pop(), data);
|
|
1008
|
+
|
|
1009
|
+
bundleSize += fs.statSync(process.cwd() + '/dist/' + file.split('node_modules/vaderjs/runtime/').pop()).size
|
|
1010
|
+
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
|
|
1015
|
+
// clean dist folder
|
|
1016
|
+
|
|
1017
|
+
for await (var file of distPages.scan('.')) {
|
|
1018
|
+
|
|
1019
|
+
file = file.replace(/\\/g, '/');
|
|
1020
|
+
|
|
1021
|
+
let path = process.cwd() + '/pages/' + file.split('dist/pages/').pop()
|
|
1022
|
+
|
|
1023
|
+
path = path.replace('.js', config?.files?.mimeType || '.jsx')
|
|
1024
|
+
|
|
1025
|
+
|
|
1026
|
+
|
|
1027
|
+
if (!fs.existsSync(path)) {
|
|
1028
|
+
|
|
1029
|
+
fs.unlinkSync(file)
|
|
1030
|
+
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
|
|
1039
|
+
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
|
|
1045
|
+
|
|
1046
|
+
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
|
|
1051
|
+
* @function organizeRoutes
|
|
1052
|
+
|
|
1053
|
+
* @description - Organizes routes that have param paths
|
|
1054
|
+
|
|
1055
|
+
*/
|
|
1056
|
+
|
|
1057
|
+
|
|
1058
|
+
|
|
1059
|
+
const organizeRoutes = () => {
|
|
1060
|
+
|
|
1061
|
+
// if path starts with the same path and is dynamic then they are the same route and push params to the same route
|
|
1062
|
+
|
|
1063
|
+
let newRoutes = []
|
|
1064
|
+
|
|
1065
|
+
routes.forEach((route) => {
|
|
1066
|
+
|
|
1067
|
+
let exists = routes.find((r) => {
|
|
1068
|
+
|
|
1069
|
+
if (r.path.includes('[')) {
|
|
1070
|
+
|
|
1071
|
+
r.path = r.path.split('[').shift()
|
|
1072
|
+
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
|
|
1076
|
+
|
|
1077
|
+
r.path = r.path.split('/').filter((p) => p !== '').join('/')
|
|
1078
|
+
|
|
1079
|
+
if (r.isParam) {
|
|
1080
|
+
|
|
1081
|
+
return r.path === route.path && r.isParam
|
|
1082
|
+
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
|
|
1086
|
+
|
|
1087
|
+
})
|
|
1088
|
+
|
|
1089
|
+
if (exists) {
|
|
1090
|
+
|
|
1091
|
+
let b4Params = route.params
|
|
1092
|
+
|
|
1093
|
+
route.params = []
|
|
1094
|
+
|
|
1095
|
+
route.params.push(b4Params)
|
|
1096
|
+
|
|
1097
|
+
route.params.push({
|
|
1098
|
+
|
|
1099
|
+
jsFile: '/' + exists.path + '/index.js',
|
|
1100
|
+
|
|
1101
|
+
folder: '/' + exists.path,
|
|
1102
|
+
|
|
1103
|
+
paramData: exists.params
|
|
1104
|
+
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
)
|
|
1108
|
+
|
|
1109
|
+
route.query = exists.query
|
|
1110
|
+
|
|
1111
|
+
newRoutes.push(route)
|
|
1112
|
+
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
else if (!exists && !route.isParam) {
|
|
1116
|
+
|
|
1117
|
+
newRoutes.push(route)
|
|
1118
|
+
|
|
1119
|
+
|
|
1120
|
+
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
//remove param route that matched
|
|
1124
|
+
|
|
1125
|
+
routes = routes.filter((r) => exists ? r.path !== exists.path : true)
|
|
1126
|
+
|
|
1127
|
+
|
|
1128
|
+
|
|
1129
|
+
})
|
|
1130
|
+
|
|
1131
|
+
globalThis.routes = newRoutes
|
|
1132
|
+
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
organizeRoutes()
|
|
1136
|
+
|
|
1137
|
+
|
|
1138
|
+
|
|
1139
|
+
|
|
1140
|
+
|
|
1141
|
+
generateProviderRoutes()
|
|
1142
|
+
|
|
1143
|
+
globalThis.isBuilding = false
|
|
1144
|
+
|
|
1145
|
+
if (!fs.existsSync(process.cwd() + '/_dev/meta')) {
|
|
1146
|
+
|
|
1147
|
+
fs.mkdirSync(process.cwd() + '/_dev/meta')
|
|
1148
|
+
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
fs.writeFileSync(process.cwd() + '/_dev/meta/routes.json', JSON.stringify(routes, null, 2))
|
|
1152
|
+
|
|
1153
|
+
console.log(`Finished building ${Math.round(bundleSize / 1000)}kb`)
|
|
1154
|
+
|
|
1155
|
+
|
|
1156
|
+
|
|
1157
|
+
bundleSize = 0
|
|
1158
|
+
|
|
1159
|
+
resolve()
|
|
1160
|
+
|
|
1161
|
+
});
|
|
1162
|
+
|
|
1163
|
+
|
|
1164
|
+
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
let port = 3000
|
|
1168
|
+
|
|
1169
|
+
switch (true) {
|
|
1170
|
+
|
|
1171
|
+
case process.argv.includes('dev') && !process.argv.includes('build') && !process.argv.includes('start'):
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
|
|
1175
|
+
port = process.argv.includes('-p') ? process.argv[process.argv.indexOf('-p') + 1] : config?.dev?.port || 3000
|
|
1176
|
+
|
|
1177
|
+
globalThis.oneAndDone = false
|
|
1178
|
+
|
|
1179
|
+
console.log(`
|
|
1180
|
+
|
|
1181
|
+
Vader.js v${fs.readFileSync(process.cwd() + '/node_modules/vaderjs/package.json', 'utf8').split('"version": "')[1].split('"')[0]}
|
|
1182
|
+
|
|
1183
|
+
- Watching for changes in ./pages
|
|
1184
|
+
|
|
1185
|
+
- Watching for changes in ./src
|
|
1186
|
+
|
|
1187
|
+
- Watching for changes in ./public
|
|
1188
|
+
|
|
1189
|
+
- Serving on port ${port}
|
|
1190
|
+
|
|
1191
|
+
`)
|
|
1192
|
+
|
|
1193
|
+
globalThis.mode = 'dev'
|
|
1194
|
+
|
|
1195
|
+
Server(port)
|
|
1196
|
+
|
|
1197
|
+
transForm()
|
|
1198
|
+
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
Bun.spawn({
|
|
1202
|
+
|
|
1203
|
+
cwd: process.cwd() + '/node_modules/vaderjs/binaries/',
|
|
1204
|
+
|
|
1205
|
+
env: {
|
|
1206
|
+
|
|
1207
|
+
PWD: process.cwd(),
|
|
1208
|
+
|
|
1209
|
+
IPC: IPC,
|
|
1210
|
+
|
|
1211
|
+
FOLDERS: 'pages,src,public',
|
|
1212
|
+
|
|
1213
|
+
onExit: (code) => {
|
|
1214
|
+
|
|
1215
|
+
globalThis.isBuilding = false
|
|
1216
|
+
|
|
1217
|
+
globalThis.oneAndDone = true
|
|
1218
|
+
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
},
|
|
1222
|
+
|
|
1223
|
+
cmd: ['node', 'watcher.js'],
|
|
1224
|
+
|
|
1225
|
+
})
|
|
1226
|
+
|
|
1227
|
+
async function runOnChange() {
|
|
1228
|
+
|
|
1229
|
+
for (var ints in integrationStates) {
|
|
1230
|
+
|
|
1231
|
+
if (integrationStates && integrationStates[ints].on.includes('dev:change')) {
|
|
1232
|
+
|
|
1233
|
+
console.log('Starting integration...')
|
|
1234
|
+
|
|
1235
|
+
let int = integrationStates[ints]
|
|
1236
|
+
|
|
1237
|
+
let { name, version, useRuntime, entryPoint, onAction, doOn } = int
|
|
1238
|
+
|
|
1239
|
+
if (globalThis.isBuilding) {
|
|
1240
|
+
|
|
1241
|
+
return
|
|
1242
|
+
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
globalThis.isBuilding = true
|
|
1246
|
+
|
|
1247
|
+
Bun.spawn({
|
|
1248
|
+
|
|
1249
|
+
cwd: process.cwd(),
|
|
1250
|
+
|
|
1251
|
+
isVader: true,
|
|
1252
|
+
|
|
1253
|
+
env: {
|
|
1254
|
+
|
|
1255
|
+
PWD: process.cwd(),
|
|
1256
|
+
|
|
1257
|
+
isVader: true,
|
|
1258
|
+
|
|
1259
|
+
FOLDERS: 'pages,src,public',
|
|
1260
|
+
|
|
1261
|
+
onExit: (code) => {
|
|
1262
|
+
|
|
1263
|
+
globalThis.isBuilding = false
|
|
1264
|
+
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
},
|
|
1268
|
+
|
|
1269
|
+
cmd: [useRuntime || 'node', entryPoint],
|
|
1270
|
+
|
|
1271
|
+
})
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
|
|
1275
|
+
console.log(`Using integration: ${name} v${version}`)
|
|
1276
|
+
|
|
1277
|
+
|
|
1278
|
+
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
|
|
1288
|
+
|
|
1289
|
+
IPC.client({
|
|
1290
|
+
|
|
1291
|
+
use: IPCServer.typeEnums.WATCHER,
|
|
1292
|
+
|
|
1293
|
+
port: 3434
|
|
1294
|
+
|
|
1295
|
+
}).Console.read((message) => {
|
|
1296
|
+
|
|
1297
|
+
message = message.msg
|
|
1298
|
+
|
|
1299
|
+
switch (true) {
|
|
1300
|
+
|
|
1301
|
+
case message.data?.type === 'change':
|
|
1302
|
+
|
|
1303
|
+
console.log('File changed:', message.data.filename)
|
|
1304
|
+
|
|
1305
|
+
transForm()
|
|
1306
|
+
|
|
1307
|
+
clients.forEach((client) => {
|
|
1308
|
+
|
|
1309
|
+
client.send('reload')
|
|
1310
|
+
|
|
1311
|
+
})
|
|
1312
|
+
|
|
1313
|
+
runOnChange()
|
|
1314
|
+
|
|
1315
|
+
|
|
1316
|
+
|
|
1317
|
+
break;
|
|
1318
|
+
|
|
1319
|
+
case message.data?.type === 'add':
|
|
1320
|
+
|
|
1321
|
+
console.log('File added:', message.data.filename)
|
|
1322
|
+
|
|
1323
|
+
transForm()
|
|
1324
|
+
|
|
1325
|
+
break;
|
|
1326
|
+
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
})
|
|
1330
|
+
|
|
1331
|
+
|
|
1332
|
+
|
|
1333
|
+
|
|
1334
|
+
|
|
1335
|
+
|
|
1336
|
+
|
|
1337
|
+
break;
|
|
1338
|
+
|
|
1339
|
+
case process.argv.includes('build') && !process.argv.includes('dev') && !process.argv.includes('start'):
|
|
1340
|
+
|
|
1341
|
+
globalThis.devMode = false
|
|
1342
|
+
|
|
1343
|
+
|
|
1344
|
+
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
|
|
1348
|
+
|
|
1349
|
+
globalThis.mode = 'prod'
|
|
1350
|
+
|
|
1351
|
+
globalThis.isProduction = true
|
|
1352
|
+
|
|
1353
|
+
globalThis.routeStates = []
|
|
1354
|
+
|
|
1355
|
+
console.log(`
|
|
1356
|
+
|
|
653
1357
|
Vader.js v1.3.3
|
|
1358
|
+
|
|
654
1359
|
Building to ./dist
|
|
1360
|
+
|
|
655
1361
|
`)
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
1362
|
+
|
|
1363
|
+
|
|
1364
|
+
|
|
1365
|
+
await transForm()
|
|
1366
|
+
|
|
1367
|
+
for (var ints in integrationStates) {
|
|
1368
|
+
|
|
1369
|
+
console.log(integrationStates[ints], 'integrationStates[ints]')
|
|
1370
|
+
|
|
1371
|
+
if (integrationStates && integrationStates[ints].on.includes('build')) {
|
|
1372
|
+
|
|
1373
|
+
console.log('Starting integration...')
|
|
1374
|
+
|
|
1375
|
+
let int = integrationStates[ints]
|
|
1376
|
+
|
|
1377
|
+
let { name, version, useRuntime, entryPoint, onAction, doOn } = int
|
|
1378
|
+
|
|
1379
|
+
console.log(`Using integration: ${name} v${version} from ${entryPoint}`)
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
Bun.spawn({
|
|
1384
|
+
|
|
1385
|
+
cwd: process.cwd(),
|
|
1386
|
+
|
|
1387
|
+
isVader: true,
|
|
1388
|
+
|
|
1389
|
+
env: {
|
|
1390
|
+
|
|
1391
|
+
PWD: process.cwd(),
|
|
1392
|
+
|
|
1393
|
+
isVader: true,
|
|
1394
|
+
|
|
1395
|
+
FOLDERS: 'pages,src,public',
|
|
1396
|
+
|
|
1397
|
+
onExit: (code) => {
|
|
1398
|
+
|
|
1399
|
+
globalThis.isBuilding = false
|
|
1400
|
+
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
},
|
|
1404
|
+
|
|
1405
|
+
cmd: ["node", entryPoint]
|
|
1406
|
+
|
|
1407
|
+
})
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
|
|
1411
|
+
|
|
1412
|
+
|
|
1413
|
+
|
|
1414
|
+
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
|
|
1420
|
+
|
|
1421
|
+
break;
|
|
1422
|
+
|
|
660
1423
|
case process.argv.includes('start') && !process.argv.includes('dev') && !process.argv.includes('build'):
|
|
661
|
-
|
|
1424
|
+
|
|
1425
|
+
port = process.argv.includes('-p') ? process.argv[process.argv.indexOf('-p') + 1] : config?.host?.prod?.port || 3000
|
|
1426
|
+
|
|
662
1427
|
console.log(`
|
|
1428
|
+
|
|
663
1429
|
Vader.js v1.3.3
|
|
1430
|
+
|
|
664
1431
|
Serving ./dist on port ${port}
|
|
1432
|
+
|
|
665
1433
|
url: http://localhost:${port}
|
|
1434
|
+
|
|
666
1435
|
`)
|
|
1436
|
+
|
|
667
1437
|
globalThis.devMode = false
|
|
1438
|
+
|
|
668
1439
|
globalThis.isProduction = true
|
|
669
|
-
|
|
670
|
-
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1443
|
+
Server(port)
|
|
1444
|
+
|
|
671
1445
|
break;
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
1446
|
+
|
|
1447
|
+
default:
|
|
1448
|
+
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
break;
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
|
|
1455
|
+
}
|