malinajs 0.8.0-a1 → 0.8.0-a2

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/malina.js CHANGED
@@ -7498,7 +7498,21 @@
7498
7498
  function parseHTML(source) {
7499
7499
  const reader = new Reader(source);
7500
7500
 
7501
- const readScript = (reader) => {
7501
+ const readScript = (reader, tag) => {
7502
+ tag.type = 'script';
7503
+
7504
+ let isJS = true;
7505
+ for (let a of tag.attributes) {
7506
+ if (a.name == 'lang' || a.name == 'language' || a.name == 'type') {
7507
+ isJS = a.value.indexOf('javascript') >= 0 || a.value.indexOf('ecmascript') >= 0;
7508
+ tag.lang = a.value;
7509
+ break;
7510
+ }
7511
+ }
7512
+ tag.content = isJS ? readScriptJS(reader) : readScriptRaw();
7513
+ };
7514
+
7515
+ const readScriptJS = (reader) => {
7502
7516
  class ScriptParser extends Parser {
7503
7517
  readToken_lt_gt(code) {
7504
7518
  if (this.input.slice(this.pos, this.pos + 9) == '</script>') {
@@ -7523,6 +7537,10 @@
7523
7537
  return reader.sub(start, end);
7524
7538
  };
7525
7539
 
7540
+ const readScriptRaw = () => {
7541
+ return reader.read(/^(.*?)<\/script>/s);
7542
+ };
7543
+
7526
7544
  const readStyle = () => {
7527
7545
  return reader.read(/^(.*?)<\/style>/s);
7528
7546
  };
@@ -7580,8 +7598,7 @@
7580
7598
  let tag = readTag(reader);
7581
7599
  push(tag);
7582
7600
  if(tag.name === 'script') {
7583
- tag.type = 'script';
7584
- tag.content = readScript(reader);
7601
+ readScript(reader, tag);
7585
7602
  continue;
7586
7603
  } else if(tag.name === 'template') {
7587
7604
  tag.type = 'template';
@@ -22778,7 +22795,7 @@
22778
22795
  function(id, context) {
22779
22796
  var node = context, nodes = [ ], next = node.firstElementChild;
22780
22797
  while ((node = next)) {
22781
- node.id == id && (nodes[nodes.length] = node);
22798
+ (node.id == id || node.dynId) && (nodes[nodes.length] = node);
22782
22799
  if ((next = node.firstElementChild || node.nextElementSibling)) continue;
22783
22800
  while (!next && (node = node.parentElement) && node !== context) {
22784
22801
  next = node.nextElementSibling;
@@ -24582,8 +24599,10 @@
24582
24599
  else n.className += ' ' + a.value;
24583
24600
  }
24584
24601
  n.attributes[a.name] = a.value;
24585
- } else if(a.name == 'id') n.attributes.id = n.id = a.value;
24586
- else if(a.name.startsWith('class:')) {
24602
+ } else if(a.name == 'id') {
24603
+ if (a.value?.includes('{')) n.dynId = true;
24604
+ n.attributes.id = n.id = a.value;
24605
+ } else if(a.name.startsWith('class:')) {
24587
24606
  n.className += ' ' + a.name.substring(6);
24588
24607
  } else n.attributes[a.name] = a.value;
24589
24608
  });
@@ -24886,17 +24905,18 @@
24886
24905
  return;
24887
24906
  } else if(this.config.passClass && (name == 'class' || name.startsWith('class:'))) {
24888
24907
  let metaClass, args = name.split(':');
24889
- if(args.length == 1) {
24908
+ if (args.length == 1) {
24890
24909
  metaClass = '$$main';
24891
24910
  } else {
24892
24911
  assert(args.length == 2);
24893
24912
  metaClass = args[1];
24894
24913
  assert(metaClass);
24914
+ if (!value) value = metaClass;
24895
24915
  }
24896
24916
  assert(value);
24897
24917
  this.css.passingClass = true;
24898
24918
 
24899
- const parsed = this.parseText(prop.value);
24919
+ const parsed = this.parseText(value);
24900
24920
  this.detectDependency(parsed);
24901
24921
  let exp = parsed.result;
24902
24922
  $class.push(`${metaClass}: $$resolveClass(${exp})`);
@@ -26541,7 +26561,7 @@
26541
26561
  });
26542
26562
  }
26543
26563
 
26544
- const version = '0.8.0-a1';
26564
+ const version = '0.8.0-a2';
26545
26565
 
26546
26566
 
26547
26567
  async function compile(source, config = {}) {
package/malina.mjs CHANGED
@@ -7492,7 +7492,21 @@ class Reader {
7492
7492
  function parseHTML(source) {
7493
7493
  const reader = new Reader(source);
7494
7494
 
7495
- const readScript = (reader) => {
7495
+ const readScript = (reader, tag) => {
7496
+ tag.type = 'script';
7497
+
7498
+ let isJS = true;
7499
+ for (let a of tag.attributes) {
7500
+ if (a.name == 'lang' || a.name == 'language' || a.name == 'type') {
7501
+ isJS = a.value.indexOf('javascript') >= 0 || a.value.indexOf('ecmascript') >= 0;
7502
+ tag.lang = a.value;
7503
+ break;
7504
+ }
7505
+ }
7506
+ tag.content = isJS ? readScriptJS(reader) : readScriptRaw();
7507
+ };
7508
+
7509
+ const readScriptJS = (reader) => {
7496
7510
  class ScriptParser extends Parser {
7497
7511
  readToken_lt_gt(code) {
7498
7512
  if (this.input.slice(this.pos, this.pos + 9) == '</script>') {
@@ -7517,6 +7531,10 @@ function parseHTML(source) {
7517
7531
  return reader.sub(start, end);
7518
7532
  };
7519
7533
 
7534
+ const readScriptRaw = () => {
7535
+ return reader.read(/^(.*?)<\/script>/s);
7536
+ };
7537
+
7520
7538
  const readStyle = () => {
7521
7539
  return reader.read(/^(.*?)<\/style>/s);
7522
7540
  };
@@ -7574,8 +7592,7 @@ function parseHTML(source) {
7574
7592
  let tag = readTag(reader);
7575
7593
  push(tag);
7576
7594
  if(tag.name === 'script') {
7577
- tag.type = 'script';
7578
- tag.content = readScript(reader);
7595
+ readScript(reader, tag);
7579
7596
  continue;
7580
7597
  } else if(tag.name === 'template') {
7581
7598
  tag.type = 'template';
@@ -22772,7 +22789,7 @@ function Factory(global, Export) {
22772
22789
  function(id, context) {
22773
22790
  var node = context, nodes = [ ], next = node.firstElementChild;
22774
22791
  while ((node = next)) {
22775
- node.id == id && (nodes[nodes.length] = node);
22792
+ (node.id == id || node.dynId) && (nodes[nodes.length] = node);
22776
22793
  if ((next = node.firstElementChild || node.nextElementSibling)) continue;
22777
22794
  while (!next && (node = node.parentElement) && node !== context) {
22778
22795
  next = node.nextElementSibling;
@@ -24576,8 +24593,10 @@ function makeDom(data) {
24576
24593
  else n.className += ' ' + a.value;
24577
24594
  }
24578
24595
  n.attributes[a.name] = a.value;
24579
- } else if(a.name == 'id') n.attributes.id = n.id = a.value;
24580
- else if(a.name.startsWith('class:')) {
24596
+ } else if(a.name == 'id') {
24597
+ if (a.value?.includes('{')) n.dynId = true;
24598
+ n.attributes.id = n.id = a.value;
24599
+ } else if(a.name.startsWith('class:')) {
24581
24600
  n.className += ' ' + a.name.substring(6);
24582
24601
  } else n.attributes[a.name] = a.value;
24583
24602
  });
@@ -24880,17 +24899,18 @@ function makeComponent(node, option={}) {
24880
24899
  return;
24881
24900
  } else if(this.config.passClass && (name == 'class' || name.startsWith('class:'))) {
24882
24901
  let metaClass, args = name.split(':');
24883
- if(args.length == 1) {
24902
+ if (args.length == 1) {
24884
24903
  metaClass = '$$main';
24885
24904
  } else {
24886
24905
  assert(args.length == 2);
24887
24906
  metaClass = args[1];
24888
24907
  assert(metaClass);
24908
+ if (!value) value = metaClass;
24889
24909
  }
24890
24910
  assert(value);
24891
24911
  this.css.passingClass = true;
24892
24912
 
24893
- const parsed = this.parseText(prop.value);
24913
+ const parsed = this.parseText(value);
24894
24914
  this.detectDependency(parsed);
24895
24915
  let exp = parsed.result;
24896
24916
  $class.push(`${metaClass}: $$resolveClass(${exp})`);
@@ -26535,7 +26555,7 @@ function makeKeepAlive(node) {
26535
26555
  });
26536
26556
  }
26537
26557
 
26538
- const version = '0.8.0-a1';
26558
+ const version = '0.8.0-a2';
26539
26559
 
26540
26560
 
26541
26561
  async function compile(source, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.8.0-a1",
3
+ "version": "0.8.0-a2",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "build": "rollup -c",
package/readme.md CHANGED
@@ -3,24 +3,35 @@
3
3
 
4
4
  <img align="right" width="200" height="200" src="https://github.com/malinajs/malinajs/raw/master/malinajs2.png" />
5
5
 
6
- Malina.js builds your web-application to use it **without framework on frontend side**. Therefore your web-app becomes thinner and faster, and the application itself consists of **vanilla JavaScript**, look at [examples](https://malinajs.github.io/repl/). [TodoMVC example](https://malina-todomvc.surge.sh) **2.7kb** (gzipped) and [source code](https://github.com/malinajs/todomvc).
6
+ Malina.js helps you create a fast and thin web application that runs **without a front-end framework**
7
+ * High performance, [look at benchmark](#benchmark)
8
+ * One of the best in [startup metrics](#startupmetrics)
9
+ * Compact bundle size of an app (starts from 185 bytes), [TodoMVC example](https://malina-todomvc.surge.sh) **2.7kb** (gzipped) [source code](https://github.com/malinajs/todomvc)
10
+ * Familiar syntax based of standard HTML, CSS and JavaScript
7
11
 
8
- For documentation about Malinajs, please visit [our website](https://malinajs.github.io/docs/).
9
- Also, please join our community on [Discord](https://discord.gg/ScDhhNCk6N) or [Telegram](https://t.me/malinajs).
12
+ ### Links
10
13
 
11
- ### tools
12
-
13
- * [Syntax Highlighter for VS-Code](https://marketplace.visualstudio.com/items?itemName=AlexxNB.malina-js-highlight)
14
14
  * **[Try Malina.js online (REPL)](https://malinajs.github.io/repl/)**
15
+ * [Documentation](https://malinajs.github.io/docs/)
16
+ * [Telegram community](https://t.me/malinajs)
17
+ * [Syntax Highlighter for VS-Code](https://marketplace.visualstudio.com/items?itemName=AlexxNB.malina-js-highlight)
18
+
19
+ ### Benchmark
20
+ <a id="benchmark"></a>
21
+ ![Benchmark](files/benchmark.png)
15
22
 
16
- #### Articles
23
+ ### Startup metrics
24
+ <a id="startupmetrics"></a>
25
+ ![Benchmark](files/startup_metrics.png)
26
+
27
+ ### Articles
17
28
 
18
29
  * [Comparision with Svelte.js](https://medium.com/@lega911/svelte-js-and-malina-js-b33c55253271)
19
30
  * [Comparision with Vue 3](https://medium.com/@lega911/vue-3-vs-malina-js-abd97025ba81)
20
31
  * [Passing CSS classes to child components](https://medium.com/@lega911/how-a-popular-feature-declined-by-svelte-went-live-in-malina-js-1a08fdb9dbc4)
21
32
  * [Using fragments](https://medium.com/@lega911/how-fragments-can-help-in-your-web-development-5efc4d10f9da)
22
33
 
23
- ## The Gist
34
+ ## Example
24
35
 
25
36
  ```html
26
37
  <script>
@@ -39,26 +50,12 @@ Also, please join our community on [Discord](https://discord.gg/ScDhhNCk6N) or [
39
50
 
40
51
  You can get started with a simple app by running the following in your terminal:
41
52
  ```
42
- npx create-malina myapp
53
+ npm create malina myapp
43
54
  cd myapp
44
55
  npm run dev
45
56
  # open http://localhost:7000/
46
57
  ```
47
58
 
48
-
49
- Or via Docker:
50
- ```
51
- docker run --rm -it --user ${UID} -p 7000:7000 -v `pwd`:/app/src lega911/malina
52
- # open http://localhost:7000/
53
- ```
54
-
55
-
56
- Build compiler
57
- ```
58
- npm install
59
- npm run build
60
- ```
61
-
62
59
  ## License
63
60
 
64
61
  [MIT](LICENSE)