@cilix/lightjs 0.0.17 → 0.0.19

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/cli.js +15 -2
  2. package/core.js +20 -4
  3. package/package.json +1 -1
package/cli.js CHANGED
@@ -118,6 +118,9 @@ for (let i = 0; i < process.argv.length; i++) {
118
118
  case 'create':
119
119
  config.create = process.argv[++i];
120
120
  break
121
+ case 'serve':
122
+ config.serve = true;
123
+ break;
121
124
  case 'dev':
122
125
  config.dev = true;
123
126
  break;
@@ -125,7 +128,7 @@ for (let i = 0; i < process.argv.length; i++) {
125
128
  config.publicDir = process.argv[++i];
126
129
  break;
127
130
  case '-p':
128
- config.port= process.argv[++i];
131
+ config.port = process.argv[++i];
129
132
  break;
130
133
  case '-r':
131
134
  const r = process.argv[++i];
@@ -150,7 +153,17 @@ for (let i = 0; i < process.argv.length; i++) {
150
153
  break
151
154
  }
152
155
  }
153
- if (config.dev) {
156
+
157
+ if (config.serve) {
158
+ http.createServer(light.router({
159
+ publicDir: config.publicDir || '.',
160
+ minify: true,
161
+ cache: true,
162
+ routes: config.routes
163
+ })).listen(4477, () => {
164
+ console.log('Listening on port 4477');
165
+ });
166
+ } else if (config.dev) {
154
167
  http.createServer(light.router({
155
168
  publicDir: config.publicDir || '.',
156
169
  routes: config.routes
package/core.js CHANGED
@@ -392,7 +392,8 @@ module.exports = (config, fs, path) => {
392
392
  "as",
393
393
  "global",
394
394
  "when",
395
- "catch"
395
+ "catch",
396
+ "state"
396
397
  ];
397
398
 
398
399
  const symbols = [
@@ -700,6 +701,12 @@ module.exports = (config, fs, path) => {
700
701
  tok.type = c;
701
702
  tok.data = c;
702
703
  cursor++;
704
+ if (c === ':') {
705
+ if (prog[cursor] === '=') {
706
+ tok.type = tok.data = ':=';
707
+ cursor++;
708
+ }
709
+ }
703
710
  } else {
704
711
  tok.type = tok.data = c;
705
712
  cursor++;
@@ -1240,8 +1247,16 @@ module.exports = (config, fs, path) => {
1240
1247
  parent = current;
1241
1248
  }
1242
1249
 
1250
+ function assignmentTok(ahead = 0) {
1251
+ return peek(':', ahead) || peek(':=', ahead) || peek('=', ahead);
1252
+ }
1253
+
1254
+ function assignmentStart() {
1255
+ return peek('let') || peek('state');
1256
+ }
1257
+
1243
1258
  function isAssignment() {
1244
- return peek('let') || (peek('ident') && peek(':', 1));
1259
+ return assignmentStart() || (peek('ident') && assignmentTok(1));
1245
1260
  }
1246
1261
 
1247
1262
  function parse_tag_list() {
@@ -1360,18 +1375,19 @@ module.exports = (config, fs, path) => {
1360
1375
 
1361
1376
  function parse_assignment () {
1362
1377
  const global = tok.data === 'global';
1363
- if (peek('global') || peek('let')) {
1378
+ if (peek('global') || assignmentStart()) {
1364
1379
  next();
1365
1380
  }
1366
1381
  let dst = { data: tok.data, pos: tok.pos, file: tok.file };
1367
1382
  expect('ident');
1368
- if (!accept("=") && !accept(':')) {
1383
+ if (!assignmentTok()) {
1369
1384
  throw_error({
1370
1385
  msg: 'expected assignment',
1371
1386
  pos: tok.pos,
1372
1387
  file: tok.file
1373
1388
  });
1374
1389
  }
1390
+ next();
1375
1391
  let val = parse_rhs();
1376
1392
  ast_node('set', {
1377
1393
  global,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cilix/lightjs",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "A new kind of JavaScript framework",
5
5
  "main": "index.js",
6
6
  "scripts": {