malinajs 0.6.58 → 0.6.61

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
@@ -18,9 +18,10 @@ function assert(x, info) {
18
18
  }
19
19
 
20
20
  function toCamelCase(name) {
21
- assert(name[name.length - 1] !== '-', 'Wrong name');
22
- return name.replace(/(?<!-)(\-\w)/g, function(part) {
23
- return part[1].toUpperCase();
21
+ assert(last(name) !== '-', 'Wrong name');
22
+ return name.replace(/(.\-\w)/g, function(part) {
23
+ if(part[0] == '-') return part;
24
+ return part[0] + part[2].toUpperCase();
24
25
  });
25
26
  }
26
27
  function Q(s) {
@@ -3869,6 +3870,7 @@ function processCSS() {
3869
3870
  }
3870
3871
  } else cleanSelectorItems.push(s);
3871
3872
  }
3873
+ while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(cleanSelectorItems[0].type)) cleanSelectorItems.shift();
3872
3874
  while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(last(cleanSelectorItems).type)) cleanSelectorItems.pop();
3873
3875
  if(!cleanSelectorItems.length || globalBlock) { // fully global?
3874
3876
  assert(origin.length);
@@ -5375,6 +5377,11 @@ function makeFragment(node) {
5375
5377
  });
5376
5378
  }
5377
5379
 
5380
+ if(external) {
5381
+ this.require('$component');
5382
+ if(props?.length) this.require('apply');
5383
+ }
5384
+
5378
5385
  return xNode('fragment', {
5379
5386
  name,
5380
5387
  props,
package/malina.js CHANGED
@@ -19,9 +19,10 @@
19
19
  }
20
20
 
21
21
  function toCamelCase(name) {
22
- assert(name[name.length - 1] !== '-', 'Wrong name');
23
- return name.replace(/(?<!-)(\-\w)/g, function(part) {
24
- return part[1].toUpperCase();
22
+ assert(last(name) !== '-', 'Wrong name');
23
+ return name.replace(/(.\-\w)/g, function(part) {
24
+ if(part[0] == '-') return part;
25
+ return part[0] + part[2].toUpperCase();
25
26
  });
26
27
  }
27
28
  function Q(s) {
@@ -3870,6 +3871,7 @@
3870
3871
  }
3871
3872
  } else cleanSelectorItems.push(s);
3872
3873
  }
3874
+ while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(cleanSelectorItems[0].type)) cleanSelectorItems.shift();
3873
3875
  while(cleanSelectorItems.length && ['WhiteSpace', 'Combinator'].includes(last(cleanSelectorItems).type)) cleanSelectorItems.pop();
3874
3876
  if(!cleanSelectorItems.length || globalBlock) { // fully global?
3875
3877
  assert(origin.length);
@@ -5376,6 +5378,11 @@
5376
5378
  });
5377
5379
  }
5378
5380
 
5381
+ if(external) {
5382
+ this.require('$component');
5383
+ if(props?.length) this.require('apply');
5384
+ }
5385
+
5379
5386
  return xNode('fragment', {
5380
5387
  name,
5381
5388
  props,
@@ -5924,7 +5931,7 @@
5924
5931
  return {event, fn};
5925
5932
  }
5926
5933
 
5927
- const version = '0.6.58';
5934
+ const version = '0.6.61';
5928
5935
 
5929
5936
 
5930
5937
  async function compile(source, config = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "malinajs",
3
- "version": "0.6.58",
3
+ "version": "0.6.61",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "prepare": "npm run build",
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 };