@yr-lang/yr 0.3.8 → 0.3.11
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/lib/%build.yr +1 -0
- package/lib/%serve.yr +0 -1
- package/node.js +18 -13
- package/package.json +1 -1
- package/yr.js +16 -9
package/lib/%build.yr
CHANGED
package/lib/%serve.yr
CHANGED
package/node.js
CHANGED
|
@@ -430,8 +430,13 @@ const window = {
|
|
|
430
430
|
__api: '',
|
|
431
431
|
};
|
|
432
432
|
const fs = require('fs');
|
|
433
|
-
let _PROJECT_PATH = '${parsePaths(projectPath)}';
|
|
434
433
|
const _globals = [];
|
|
434
|
+
function setGlobal(name, item, subscribe=false) {
|
|
435
|
+
if (!_globals.includes(name) || subscribe) {
|
|
436
|
+
global[name] = item;
|
|
437
|
+
_globals.push(name);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
435
440
|
function parsePaths(newPaths) {
|
|
436
441
|
let newStrPath = [];
|
|
437
442
|
for (let item of newPaths.split(',')) {
|
|
@@ -442,15 +447,17 @@ function parsePaths(newPaths) {
|
|
|
442
447
|
|
|
443
448
|
return newStrPath.join(',');
|
|
444
449
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
const _config =
|
|
453
|
-
|
|
450
|
+
//let _PROJECT_PATH = '${parsePaths(projectPath)}';
|
|
451
|
+
//_PROJECT_PATH = parsePaths(_PROJECT_PATH);
|
|
452
|
+
//const _config = require(\`\${_PROJECT_PATH}/yrconfig.json\`);
|
|
453
|
+
//const env = require(\`\${_PROJECT_PATH}/.env.json\`);
|
|
454
|
+
setGlobal('path', require('path'));
|
|
455
|
+
const _PROJECT_PATH = path.resolve(process.cwd(), '..');
|
|
456
|
+
const PROJECT_PATH = _PROJECT_PATH;
|
|
457
|
+
const _config = JSON.parse(
|
|
458
|
+
fs.readFileSync(path.join(PROJECT_PATH, 'yrconfig.json'), 'utf8'));
|
|
459
|
+
const env = JSON.parse(
|
|
460
|
+
fs.readFileSync(path.join(PROJECT_PATH, '.env.json'), 'utf8'));
|
|
454
461
|
for (let item of ['HOME', 'LIBS', 'BUILDS', 'TREE', 'CONFIG']) {
|
|
455
462
|
if (typeof env[item] === 'object') {
|
|
456
463
|
env[item] = parsePaths(env[item].join(',')).split(',');
|
|
@@ -503,10 +510,8 @@ for (let item of ['HOME', 'LIBS', 'BUILDS', 'TREE', 'CONFIG']) {
|
|
|
503
510
|
*\:Zone.Identifier
|
|
504
511
|
node_modules/
|
|
505
512
|
__pycache__/
|
|
506
|
-
dist/
|
|
507
|
-
.yrkitconf
|
|
508
513
|
package*.json
|
|
509
|
-
|
|
514
|
+
.yrkitconf`);
|
|
510
515
|
|
|
511
516
|
fs.writeFileSync(projectPath + '/yrconfig.json', JSON.stringify(result.config, null, 2));
|
|
512
517
|
fs.writeFileSync(projectPath + '/app/app.js', result.app);
|
package/package.json
CHANGED
package/yr.js
CHANGED
|
@@ -344,7 +344,7 @@ const parserFns = {
|
|
|
344
344
|
},
|
|
345
345
|
nosection(line, sections, section, state, lineNumber, config={}) {
|
|
346
346
|
if (line.startsWith('--')) sections.modules =
|
|
347
|
-
[...sections.modules, ...line.slice(2).trim().split(',')];
|
|
347
|
+
[...sections.modules, ...line.slice(2).trim().split(',').map(item => item.trim())];
|
|
348
348
|
},
|
|
349
349
|
string(line, sections, section, state, lineNumber, config={}) {
|
|
350
350
|
sections[section] += line + '\n';
|
|
@@ -1546,18 +1546,25 @@ const core = {
|
|
|
1546
1546
|
parsedItem.attributes = sections
|
|
1547
1547
|
.wrappers[`${parsedItem.category}/${parsedItem.option}`].vars.attributes;
|
|
1548
1548
|
|
|
1549
|
-
|
|
1549
|
+
// maybe add await here
|
|
1550
|
+
newWrapperJs += ` __${parsedItem.category}_${parsedItem.option}(${
|
|
1550
1551
|
JSON.stringify(parsedItem)
|
|
1551
|
-
})
|
|
1552
|
-
|
|
1553
|
-
sections.parsedjs += newItem + '\n';
|
|
1554
|
-
newWrapperJs += newItem + '\n';
|
|
1555
|
-
break;
|
|
1552
|
+
});\n`;
|
|
1556
1553
|
}
|
|
1557
1554
|
}
|
|
1558
1555
|
}
|
|
1559
|
-
|
|
1560
|
-
|
|
1556
|
+
|
|
1557
|
+
if (newWrapperJs) {
|
|
1558
|
+
if (!sections.parsedyr) sections.parsedyr = sections.parsedyr = {};
|
|
1559
|
+
|
|
1560
|
+
if (!sections.parsedyr.body)
|
|
1561
|
+
sections.parsedyr.body = sections.parsedyr.body = '';
|
|
1562
|
+
|
|
1563
|
+
sections.parsedjs += `(async () => {\n${
|
|
1564
|
+
(!/\n\s*_![^\s/]+\/[^\s/]+/.test(code)) ? newWrapperJs
|
|
1565
|
+
: newWrapperJs.split('\n').reverse().join('\n')
|
|
1566
|
+
}})();`;
|
|
1567
|
+
}
|
|
1561
1568
|
|
|
1562
1569
|
if (config.preview) {
|
|
1563
1570
|
function countCharacterOccurrences(str, char) {
|