malinajs 0.6.59 → 0.6.62

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/compile.js CHANGED
@@ -53,7 +53,7 @@ const isNumber = (value) => {
53
53
  function detectExpressionType(name) {
54
54
  if(isSimpleName(name)) return 'identifier';
55
55
 
56
- let ast = acorn.parse(name, {allowReturnOutsideFunction: true});
56
+ let ast = acorn.parse(name, {allowReturnOutsideFunction: true, ecmaVersion: 'latest'});
57
57
 
58
58
  function checkIdentificator(body) {
59
59
  if(body.length != 1) return;
@@ -250,7 +250,7 @@ const genId = () => {
250
250
 
251
251
 
252
252
  const extractKeywords = (exp) => {
253
- let ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 12});
253
+ let ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 'latest'});
254
254
 
255
255
  const keys = new Set();
256
256
  const rec = (n) => {
@@ -305,7 +305,7 @@ const replaceElementKeyword = (exp, fn) => {
305
305
 
306
306
  const parseJS = (exp) => {
307
307
  let self = {};
308
- self.ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 12});
308
+ self.ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 'latest'});
309
309
 
310
310
  self.transform = function(fn) {
311
311
  const rec = (n, pk) => {
@@ -1126,7 +1126,7 @@ function parse$1() {
1126
1126
  if(isBlockComment) return;
1127
1127
  this.script.comments.push({start, end, value});
1128
1128
  };
1129
- this.script.ast = acorn.parse(source, {sourceType: 'module', ecmaVersion: 12, onComment});
1129
+ this.script.ast = acorn.parse(source, {sourceType: 'module', ecmaVersion: 'latest', onComment});
1130
1130
 
1131
1131
  if(source.includes('$props')) this.require('$props');
1132
1132
  if(source.includes('$attributes')) this.require('$attributes');
@@ -3870,6 +3870,7 @@ function processCSS() {
3870
3870
  }
3871
3871
  } else cleanSelectorItems.push(s);
3872
3872
  }
3873
+ while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(cleanSelectorItems[0].type)) cleanSelectorItems.shift();
3873
3874
  while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(last(cleanSelectorItems).type)) cleanSelectorItems.pop();
3874
3875
  if(!cleanSelectorItems.length || globalBlock) { // fully global?
3875
3876
  assert(origin.length);
@@ -5376,6 +5377,11 @@ function makeFragment(node) {
5376
5377
  });
5377
5378
  }
5378
5379
 
5380
+ if(external) {
5381
+ this.require('$component');
5382
+ if(props?.length) this.require('apply');
5383
+ }
5384
+
5379
5385
  return xNode('fragment', {
5380
5386
  name,
5381
5387
  props,
package/malina.js CHANGED
@@ -54,7 +54,7 @@
54
54
  function detectExpressionType(name) {
55
55
  if(isSimpleName(name)) return 'identifier';
56
56
 
57
- let ast = acorn.parse(name, {allowReturnOutsideFunction: true});
57
+ let ast = acorn.parse(name, {allowReturnOutsideFunction: true, ecmaVersion: 'latest'});
58
58
 
59
59
  function checkIdentificator(body) {
60
60
  if(body.length != 1) return;
@@ -251,7 +251,7 @@
251
251
 
252
252
 
253
253
  const extractKeywords = (exp) => {
254
- let ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 12});
254
+ let ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 'latest'});
255
255
 
256
256
  const keys = new Set();
257
257
  const rec = (n) => {
@@ -306,7 +306,7 @@
306
306
 
307
307
  const parseJS = (exp) => {
308
308
  let self = {};
309
- self.ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 12});
309
+ self.ast = acorn.parse(exp, {sourceType: 'module', ecmaVersion: 'latest'});
310
310
 
311
311
  self.transform = function(fn) {
312
312
  const rec = (n, pk) => {
@@ -1127,7 +1127,7 @@
1127
1127
  if(isBlockComment) return;
1128
1128
  this.script.comments.push({start, end, value});
1129
1129
  };
1130
- this.script.ast = acorn.parse(source, {sourceType: 'module', ecmaVersion: 12, onComment});
1130
+ this.script.ast = acorn.parse(source, {sourceType: 'module', ecmaVersion: 'latest', onComment});
1131
1131
 
1132
1132
  if(source.includes('$props')) this.require('$props');
1133
1133
  if(source.includes('$attributes')) this.require('$attributes');
@@ -3871,6 +3871,7 @@
3871
3871
  }
3872
3872
  } else cleanSelectorItems.push(s);
3873
3873
  }
3874
+ while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(cleanSelectorItems[0].type)) cleanSelectorItems.shift();
3874
3875
  while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(last(cleanSelectorItems).type)) cleanSelectorItems.pop();
3875
3876
  if(!cleanSelectorItems.length || globalBlock) { // fully global?
3876
3877
  assert(origin.length);
@@ -5377,6 +5378,11 @@
5377
5378
  });
5378
5379
  }
5379
5380
 
5381
+ if(external) {
5382
+ this.require('$component');
5383
+ if(props?.length) this.require('apply');
5384
+ }
5385
+
5380
5386
  return xNode('fragment', {
5381
5387
  name,
5382
5388
  props,
@@ -5925,7 +5931,7 @@
5925
5931
  return {event, fn};
5926
5932
  }
5927
5933
 
5928
- const version = '0.6.59';
5934
+ const version = '0.6.62';
5929
5935
 
5930
5936
 
5931
5937
  async function compile(source, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.6.59",
3
+ "version": "0.6.62",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "prepare": "npm run build",
@@ -15,7 +15,7 @@
15
15
  "brotli": "brotli --input /app/malinajs/example/public/app.min.js --output /app/malinajs/example/public/app.min.js.br; brotli --input /app/malinajs/example/public/app.min2.js --output /app/malinajs/example/public/app.min2.js.br"
16
16
  },
17
17
  "dependencies": {
18
- "acorn": "^7.3.1",
18
+ "acorn": "^8.7.1",
19
19
  "astring": "^1.4.3",
20
20
  "css-tree": "^1.0.0-alpha.39"
21
21
  },
package/readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  ## Malina.js
3
3
 
4
- <img align="right" width="200" height="200" src="malinajs2.png" />
4
+ <img align="right" width="200" height="200" src="https://github.com/malinajs/malinajs/raw/master/malinajs2.png" />
5
5
 
6
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 consist 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)
7
7
 
package/runtime.js CHANGED
@@ -718,7 +718,7 @@ const exportFragment = ($component, name, fn) => {
718
718
  let $cd = $childCD.new();
719
719
  cd_onDestroy($parentCD, () => $cd.destroy());
720
720
  fn($cd, label, props, events, slot);
721
- $component.apply();
721
+ $component.apply?.();
722
722
  };
723
723
  };
724
724
 
@@ -734,7 +734,7 @@ const observeProps = (cmp, fn) => {
734
734
  let result;
735
735
  fire($watch(cd, fn, value => {
736
736
  result = value;
737
- target.$$.apply();
737
+ target.$$.apply?.();
738
738
  }, {ro: true, value: {}, cmp}));
739
739
  return () => result;
740
740
  }
@@ -748,6 +748,18 @@ const unwrapProps = (cd, props, fn) => {
748
748
  }
749
749
  };
750
750
 
751
+
752
+ const mount = (label, component, option) => {
753
+ const app = component(label, option);
754
+ const destroy = () => label.textContent = '';
755
+
756
+ if(app?._d) {
757
+ app._d.push(destroy);
758
+ return app;
759
+ }
760
+ return {destroy};
761
+ };
762
+
751
763
  function $$htmlBlock($cd, tag, fn) {
752
764
  let lastElement;
753
765
  let create = (html) => {
@@ -947,4 +959,4 @@ function $$eachBlock($parentCD, label, onlyChild, fn, getKey, itemTemplate, bind
947
959
  }, {ro: true, cmp: $$compareArray});
948
960
  }
949
961
 
950
- export { $$addEventForComponent, $$awaitBlock, $$cloneDeep, $$compareArray, $$compareDeep, $$deepComparator, $$eachBlock, $$htmlBlock, $$htmlToFragment, $$htmlToFragmentClean, $$ifBlock, $$removeElements, $$removeItem, $ChangeDetector, $base, $context, $digest, $insertElementByOption, $makeEmitter, $onDestroy, $onMount, $readOnlyBase, $tick, $watch, $watchReadOnly, __app_onerror, __bindActionSubscribe, addClass, addEvent, addStyles, attachAnchor, attachSlot, attachSlotBase, attchExportedFragment, autoSubscribe, bindAction, bindAttribute, bindAttributeBase, bindClass, bindInput, bindStyle, bindText, callComponent, cd_onDestroy, childNodes, cloneDeep, configure, createTextNode, current_component, eachDefaultKey, exportFragment, fire, firstChild, getFinalLabel, insertAfter, isArray, isFunction, keyComparator, makeClassResolver, makeComponent, makeExternalProperty, makeSlot, makeSlotStatic, noop, observeProps, prefixPush, removeElementsBetween, setClassToElement, spreadAttributes, svgToFragment, unwrapProps };
962
+ export { $$addEventForComponent, $$awaitBlock, $$cloneDeep, $$compareArray, $$compareDeep, $$deepComparator, $$eachBlock, $$htmlBlock, $$htmlToFragment, $$htmlToFragmentClean, $$ifBlock, $$removeElements, $$removeItem, $ChangeDetector, $base, $context, $digest, $insertElementByOption, $makeEmitter, $onDestroy, $onMount, $readOnlyBase, $tick, $watch, $watchReadOnly, __app_onerror, __bindActionSubscribe, addClass, addEvent, addStyles, attachAnchor, attachSlot, attachSlotBase, attchExportedFragment, autoSubscribe, bindAction, bindAttribute, bindAttributeBase, bindClass, bindInput, bindStyle, bindText, callComponent, cd_onDestroy, childNodes, cloneDeep, configure, createTextNode, current_component, eachDefaultKey, exportFragment, fire, firstChild, getFinalLabel, insertAfter, isArray, isFunction, keyComparator, makeClassResolver, makeComponent, makeExternalProperty, makeSlot, makeSlotStatic, mount, noop, observeProps, prefixPush, removeElementsBetween, setClassToElement, spreadAttributes, svgToFragment, unwrapProps };