malinajs 0.7.11 → 0.7.12
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 +36 -34
- package/package.json +1 -1
- package/runtime.js +5 -4
package/malina.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('acorn'), require('astring'), require('css-tree')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', 'acorn', 'astring', 'css-tree'], factory) :
|
|
4
|
-
(global = global || self, factory(global.malina = {}, global.acorn, global.astring, global[
|
|
5
|
-
}(this, (function (exports, acorn, astring, csstree) { 'use strict';
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.malina = {}, global.acorn, global.astring, global["css-tree"]));
|
|
5
|
+
})(this, (function (exports, acorn, astring, csstree) { 'use strict';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var acorn__default = /*#__PURE__*/_interopDefaultLegacy(acorn);
|
|
10
|
+
var astring__default = /*#__PURE__*/_interopDefaultLegacy(astring);
|
|
11
|
+
var csstree__default = /*#__PURE__*/_interopDefaultLegacy(csstree);
|
|
10
12
|
|
|
11
13
|
let current_context;
|
|
12
14
|
|
|
@@ -72,7 +74,7 @@
|
|
|
72
74
|
function detectExpressionType(name) {
|
|
73
75
|
if(isSimpleName(name)) return 'identifier';
|
|
74
76
|
|
|
75
|
-
let ast =
|
|
77
|
+
let ast = acorn__default["default"].parse(name, { allowReturnOutsideFunction: true, ecmaVersion: 'latest' });
|
|
76
78
|
|
|
77
79
|
function checkIdentificator(body) {
|
|
78
80
|
if(body.length != 1) return;
|
|
@@ -139,7 +141,7 @@
|
|
|
139
141
|
|
|
140
142
|
|
|
141
143
|
const extractKeywords = (exp) => {
|
|
142
|
-
let ast =
|
|
144
|
+
let ast = acorn__default["default"].parse(exp, { sourceType: 'module', ecmaVersion: 'latest' });
|
|
143
145
|
|
|
144
146
|
const keys = new Set();
|
|
145
147
|
const rec = (n) => {
|
|
@@ -197,8 +199,8 @@
|
|
|
197
199
|
|
|
198
200
|
const parseJS = (exp, option) => {
|
|
199
201
|
let self = {};
|
|
200
|
-
if(option === true) self.ast =
|
|
201
|
-
else self.ast =
|
|
202
|
+
if(option === true) self.ast = acorn__default["default"].parse(exp, { ecmaVersion: 'latest' });
|
|
203
|
+
else self.ast = acorn__default["default"].parseExpressionAt(exp, 0, { ecmaVersion: 'latest' });
|
|
202
204
|
|
|
203
205
|
self.transform = function(fn) {
|
|
204
206
|
const rec = (n, pk) => {
|
|
@@ -229,7 +231,7 @@
|
|
|
229
231
|
};
|
|
230
232
|
|
|
231
233
|
self.build = function(data) {
|
|
232
|
-
return
|
|
234
|
+
return astring__default["default"].generate(data || self.ast, { indent: '', lineEnd: '' });
|
|
233
235
|
};
|
|
234
236
|
return self;
|
|
235
237
|
};
|
|
@@ -963,17 +965,17 @@
|
|
|
963
965
|
const reader = new Reader(source);
|
|
964
966
|
|
|
965
967
|
const readScript = (reader) => {
|
|
966
|
-
class ScriptParser extends
|
|
968
|
+
class ScriptParser extends acorn__default["default"].Parser {
|
|
967
969
|
readToken_lt_gt(code) {
|
|
968
970
|
if (this.input.slice(this.pos, this.pos + 9) == '</script>') {
|
|
969
|
-
return this.finishToken(
|
|
971
|
+
return this.finishToken(acorn__default["default"].tokTypes.eof);
|
|
970
972
|
}
|
|
971
973
|
return super.readToken_lt_gt(code);
|
|
972
974
|
}
|
|
973
975
|
|
|
974
976
|
scan() {
|
|
975
977
|
this.nextToken();
|
|
976
|
-
while (this.type !==
|
|
978
|
+
while (this.type !== acorn__default["default"].tokTypes.eof) {
|
|
977
979
|
this.parseStatement(null, true, null);
|
|
978
980
|
}
|
|
979
981
|
return this.end;
|
|
@@ -1219,7 +1221,7 @@
|
|
|
1219
1221
|
elArg = reader.read(/^[^\s>/]+/);
|
|
1220
1222
|
}
|
|
1221
1223
|
|
|
1222
|
-
let attributes = parseAttibutes(reader, {closedByTag: true});
|
|
1224
|
+
let attributes = parseAttibutes$1(reader, {closedByTag: true});
|
|
1223
1225
|
|
|
1224
1226
|
let closedTag = false;
|
|
1225
1227
|
if(reader.readIf('/>')) closedTag = true;
|
|
@@ -1370,7 +1372,7 @@
|
|
|
1370
1372
|
};
|
|
1371
1373
|
|
|
1372
1374
|
|
|
1373
|
-
const parseAttibutes = (source, option={}) => {
|
|
1375
|
+
const parseAttibutes$1 = (source, option={}) => {
|
|
1374
1376
|
const r = new Reader(source);
|
|
1375
1377
|
let result = [];
|
|
1376
1378
|
|
|
@@ -1450,7 +1452,7 @@
|
|
|
1450
1452
|
if(isBlockComment) return;
|
|
1451
1453
|
this.script.comments.push({ start, end, value });
|
|
1452
1454
|
};
|
|
1453
|
-
this.script.ast =
|
|
1455
|
+
this.script.ast = acorn__default["default"].parse(source, { sourceType: 'module', ecmaVersion: 'latest', onComment });
|
|
1454
1456
|
|
|
1455
1457
|
if(source.includes('$props')) this.require('$props');
|
|
1456
1458
|
if(source.includes('$attributes')) this.require('$attributes');
|
|
@@ -1631,10 +1633,10 @@
|
|
|
1631
1633
|
target = ex.left.name;
|
|
1632
1634
|
if(!(target in rootVariables)) resultBody.push(makeVariable(target));
|
|
1633
1635
|
} else if(ex.left.type == 'MemberExpression') {
|
|
1634
|
-
target =
|
|
1636
|
+
target = astring__default["default"].generate(ex.left);
|
|
1635
1637
|
} else throw 'Error';
|
|
1636
1638
|
assertExpression(ex.right);
|
|
1637
|
-
const exp =
|
|
1639
|
+
const exp = astring__default["default"].generate(ex.right);
|
|
1638
1640
|
watchers.push(xNode('watch-assign', {
|
|
1639
1641
|
$wait: ['apply'],
|
|
1640
1642
|
target,
|
|
@@ -1646,7 +1648,7 @@
|
|
|
1646
1648
|
} else if(n.body.expression.type == 'SequenceExpression') {
|
|
1647
1649
|
const ex = n.body.expression.expressions;
|
|
1648
1650
|
const handler = last(ex);
|
|
1649
|
-
let callback =
|
|
1651
|
+
let callback = astring__default["default"].generate(handler);
|
|
1650
1652
|
if(handler.type == 'ArrowFunctionExpression' || handler.type == 'FunctionExpression') ; else if(detectExpressionType(callback) == 'identifier') {
|
|
1651
1653
|
callback = `(v) => { ${callback}(v); }`;
|
|
1652
1654
|
} else {
|
|
@@ -1657,7 +1659,7 @@
|
|
|
1657
1659
|
assertExpression(ex[0]);
|
|
1658
1660
|
watchers.push(xNode('watch-expression', {
|
|
1659
1661
|
$wait: ['apply'],
|
|
1660
|
-
exp:
|
|
1662
|
+
exp: astring__default["default"].generate(ex[0]),
|
|
1661
1663
|
callback
|
|
1662
1664
|
}, (ctx, n) => {
|
|
1663
1665
|
if(this.inuse.apply) {
|
|
@@ -1676,7 +1678,7 @@
|
|
|
1676
1678
|
|
|
1677
1679
|
watchers.push(xNode('watch-expression', {
|
|
1678
1680
|
$wait: ['apply'],
|
|
1679
|
-
exp:
|
|
1681
|
+
exp: astring__default["default"].generate(exp),
|
|
1680
1682
|
callback
|
|
1681
1683
|
}, (ctx, n) => {
|
|
1682
1684
|
if(this.inuse.apply) ctx.write(true, `$watch(() => ${n.exp}, ($args) => { (${n.callback}).apply(null, $args); }, {cmp: $runtime.deepComparator(1)});`);
|
|
@@ -1735,7 +1737,7 @@
|
|
|
1735
1737
|
if(d.init.type == 'Literal') {
|
|
1736
1738
|
p.value = d.init.raw;
|
|
1737
1739
|
} else {
|
|
1738
|
-
p.value =
|
|
1740
|
+
p.value = astring__default["default"].generate(d.init);
|
|
1739
1741
|
}
|
|
1740
1742
|
}
|
|
1741
1743
|
result.props.push(p);
|
|
@@ -1867,12 +1869,12 @@
|
|
|
1867
1869
|
if(statement.type != 'Raw') state.write(lineEnd);
|
|
1868
1870
|
}
|
|
1869
1871
|
}
|
|
1870
|
-
},
|
|
1872
|
+
}, astring__default["default"].baseGenerator);
|
|
1871
1873
|
|
|
1872
1874
|
|
|
1873
1875
|
xNode.init.ast = (ctx, node) => {
|
|
1874
1876
|
if(!node.body.length) return;
|
|
1875
|
-
let code =
|
|
1877
|
+
let code = astring__default["default"].generate({
|
|
1876
1878
|
type: 'CustomBlock',
|
|
1877
1879
|
body: node.body
|
|
1878
1880
|
}, { generator, startingIndentLevel: 0 });
|
|
@@ -4555,7 +4557,7 @@
|
|
|
4555
4557
|
|
|
4556
4558
|
const selector2str = (sel) => {
|
|
4557
4559
|
if(!sel.children) sel = { type: 'Selector', children: sel };
|
|
4558
|
-
return
|
|
4560
|
+
return csstree__default["default"].generate(sel);
|
|
4559
4561
|
};
|
|
4560
4562
|
|
|
4561
4563
|
const convertAst = (node, parent) => {
|
|
@@ -4570,7 +4572,7 @@
|
|
|
4570
4572
|
};
|
|
4571
4573
|
|
|
4572
4574
|
const parseCSS = (content, option) => {
|
|
4573
|
-
let ast =
|
|
4575
|
+
let ast = csstree__default["default"].parse(content, option);
|
|
4574
4576
|
return convertAst(ast, null);
|
|
4575
4577
|
};
|
|
4576
4578
|
|
|
@@ -4591,7 +4593,7 @@
|
|
|
4591
4593
|
let ast = parseCSS(styleNode.content);
|
|
4592
4594
|
astList.push(ast);
|
|
4593
4595
|
|
|
4594
|
-
|
|
4596
|
+
csstree__default["default"].walk(ast, function(node) {
|
|
4595
4597
|
if(node.type == 'Declaration') {
|
|
4596
4598
|
if(node.property == 'animation' || node.property == 'animation-name') {
|
|
4597
4599
|
let c = node.value.children[0];
|
|
@@ -4832,7 +4834,7 @@
|
|
|
4832
4834
|
});
|
|
4833
4835
|
resolveHashes();
|
|
4834
4836
|
|
|
4835
|
-
return astList.map(ast =>
|
|
4837
|
+
return astList.map(ast => csstree__default["default"].generate(ast)).join('');
|
|
4836
4838
|
};
|
|
4837
4839
|
}
|
|
4838
4840
|
|
|
@@ -6294,7 +6296,7 @@
|
|
|
6294
6296
|
}
|
|
6295
6297
|
|
|
6296
6298
|
|
|
6297
|
-
function parseAttibutes
|
|
6299
|
+
function parseAttibutes(attributes) {
|
|
6298
6300
|
let props = [];
|
|
6299
6301
|
let events = [];
|
|
6300
6302
|
let forwardAllEvents;
|
|
@@ -6339,7 +6341,7 @@
|
|
|
6339
6341
|
let slot = null;
|
|
6340
6342
|
if(node.body?.length) slot = this.buildBlock({ body: trimEmptyNodes(node.body) }, { inline: true });
|
|
6341
6343
|
|
|
6342
|
-
let { props, events, forwardAllEvents, staticProps } = parseAttibutes
|
|
6344
|
+
let { props, events, forwardAllEvents, staticProps } = parseAttibutes.call(this, node.attributes);
|
|
6343
6345
|
|
|
6344
6346
|
return xNode('call-fragment', {
|
|
6345
6347
|
$compile: [slot?.source],
|
|
@@ -6439,7 +6441,7 @@
|
|
|
6439
6441
|
// assert(!data.slot.template.svg, 'SVG is not supported for exported fragment');
|
|
6440
6442
|
}
|
|
6441
6443
|
|
|
6442
|
-
let pa = parseAttibutes
|
|
6444
|
+
let pa = parseAttibutes.call(this, node.attributes);
|
|
6443
6445
|
data = { ...pa, ...data };
|
|
6444
6446
|
|
|
6445
6447
|
return xNode('attach-exported-fragment', data, (ctx, n) => {
|
|
@@ -6829,7 +6831,7 @@
|
|
|
6829
6831
|
let key = null;
|
|
6830
6832
|
let args = node.value.substr(6);
|
|
6831
6833
|
if(args) {
|
|
6832
|
-
args = parseAttibutes(args);
|
|
6834
|
+
args = parseAttibutes$1(args);
|
|
6833
6835
|
const a = args.find(a => a.name == 'key');
|
|
6834
6836
|
if(a) {
|
|
6835
6837
|
let value = a.value;
|
|
@@ -6852,7 +6854,7 @@
|
|
|
6852
6854
|
});
|
|
6853
6855
|
}
|
|
6854
6856
|
|
|
6855
|
-
const version = '0.7.
|
|
6857
|
+
const version = '0.7.12';
|
|
6856
6858
|
|
|
6857
6859
|
|
|
6858
6860
|
async function compile(source, config = {}) {
|
|
@@ -7113,5 +7115,5 @@
|
|
|
7113
7115
|
|
|
7114
7116
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
7115
7117
|
|
|
7116
|
-
}))
|
|
7118
|
+
}));
|
|
7117
7119
|
//# sourceMappingURL=malina.js.map
|
package/package.json
CHANGED
package/runtime.js
CHANGED
|
@@ -178,11 +178,13 @@ const keyComparator = (w, value) => {
|
|
|
178
178
|
|
|
179
179
|
|
|
180
180
|
const fire = w => {
|
|
181
|
-
|
|
181
|
+
let value = w.fn();
|
|
182
|
+
if(w.cmp) w.cmp(w, value);
|
|
182
183
|
else {
|
|
183
|
-
w.value =
|
|
184
|
+
w.value = value;
|
|
184
185
|
w.cb(w.value);
|
|
185
186
|
}
|
|
187
|
+
return value;
|
|
186
188
|
};
|
|
187
189
|
|
|
188
190
|
function $digest($cd, flag) {
|
|
@@ -373,8 +375,7 @@ const callComponentDyn = (component, context, option = {}, propFn, cmp, setter,
|
|
|
373
375
|
$component.$push?.(value);
|
|
374
376
|
$component.$apply?.();
|
|
375
377
|
}, { value: {}, idle: true, cmp });
|
|
376
|
-
fire(parentWatch);
|
|
377
|
-
option.props = parentWatch.value;
|
|
378
|
+
option.props = fire(parentWatch);
|
|
378
379
|
}
|
|
379
380
|
|
|
380
381
|
if(classFn) {
|