miqro 1.8.3 → 1.8.6
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/dist/cli.js +31 -31
- package/dist/cmds/wc-compile-sfc.d.ts +2 -0
- package/dist/cmds/wc-compile-sfc.js +195 -0
- package/dist/utils/index.js +2 -2
- package/dist/utils/xml.js +15 -17
- package/package.json +4 -2
package/dist/cli.js
CHANGED
|
@@ -25,100 +25,100 @@ const db_createmodel_1 = require("./cmds/db-createmodel");
|
|
|
25
25
|
const db_push_data_1 = require("./cmds/db-push-data");
|
|
26
26
|
const db_dump_data_1 = require("./cmds/db-dump-data");
|
|
27
27
|
const db_migrate_1 = require("./cmds/db-migrate");
|
|
28
|
-
|
|
28
|
+
const wc_compile_sfc_1 = require("./cmds/wc-compile-sfc");
|
|
29
29
|
const wc_cache_templates_1 = require("./cmds/wc-cache-templates");
|
|
30
30
|
// noinspection SpellCheckingInspection
|
|
31
31
|
(0, utils_1.mainCMD)({
|
|
32
|
-
["new"]: { section: "api development", cb: new_1.mainJS, tabs: 5, description: `create a new project
|
|
33
|
-
["new:typescript"]: { cb: new_1.mainTS, tabs: 4, description: `create a new typescript project
|
|
32
|
+
["new"]: { section: "api development", cb: new_1.mainJS, tabs: 5, description: `create a new project.` },
|
|
33
|
+
["new:typescript"]: { cb: new_1.mainTS, tabs: 4, description: `create a new typescript project.` },
|
|
34
34
|
["new:main"]: {
|
|
35
35
|
//section: "http scafolding",
|
|
36
36
|
cb: handler_main_new_1.main,
|
|
37
37
|
tabs: 4,
|
|
38
|
-
description: `creates a new main file
|
|
38
|
+
description: `creates a new main file.`
|
|
39
39
|
},
|
|
40
|
-
["new:route"]: { cb: handler_apiroute_new_1.main, tabs: 4, description: `creates a new route
|
|
40
|
+
["new:route"]: { cb: handler_apiroute_new_1.main, tabs: 4, description: `creates a new route.` },
|
|
41
41
|
["config"]: {
|
|
42
42
|
//section: "config managment",
|
|
43
43
|
cb: config_1.main,
|
|
44
44
|
tabs: 5,
|
|
45
|
-
description: `
|
|
45
|
+
description: `print config as a json.`
|
|
46
46
|
},
|
|
47
47
|
["config:bash"]: {
|
|
48
48
|
cb: config_bash_1.main,
|
|
49
49
|
tabs: 4,
|
|
50
|
-
description: `
|
|
50
|
+
description: `print config as a bash script.`
|
|
51
51
|
},
|
|
52
52
|
["config:env"]: {
|
|
53
53
|
cb: config_env_1.main,
|
|
54
54
|
tabs: 4,
|
|
55
|
-
description: `
|
|
55
|
+
description: `print config as a env file.`
|
|
56
56
|
},
|
|
57
|
-
["config:init"]: { cb: config_init_1.main, tabs: 4, description: `inits your config folder
|
|
57
|
+
["config:init"]: { cb: config_init_1.main, tabs: 4, description: `inits your config folder.` },
|
|
58
58
|
["doc"]: {
|
|
59
59
|
//section: "api documentation",
|
|
60
60
|
tabs: 5,
|
|
61
61
|
cb: doc_json_1.main,
|
|
62
|
-
description: `
|
|
62
|
+
description: `api folder auto doc as a json.`
|
|
63
63
|
},
|
|
64
64
|
["doc:md"]: {
|
|
65
65
|
cb: doc_md_1.main,
|
|
66
66
|
tabs: 5,
|
|
67
|
-
description: `
|
|
67
|
+
description: `api folder auto doc as a markdown.`
|
|
68
68
|
},
|
|
69
|
-
["new:front"]: { section: "front development", cb: wc_new_1.mainJS, tabs: 4, description: `create a new project
|
|
70
|
-
["new:front:typescript"]: { cb: wc_new_1.mainTS, tabs: 3, description: `create a new typescript project
|
|
69
|
+
["new:front"]: { section: "front development", cb: wc_new_1.mainJS, tabs: 4, description: `create a new project.` },
|
|
70
|
+
["new:front:typescript"]: { cb: wc_new_1.mainTS, tabs: 3, description: `create a new typescript project.` },
|
|
71
71
|
["generate:template:cache"]: {
|
|
72
72
|
//section: "web components",
|
|
73
73
|
tabs: 3,
|
|
74
|
-
cb: wc_cache_templates_1.main, description: `generate
|
|
74
|
+
cb: wc_cache_templates_1.main, description: `generate cache.json for webcomponents.`
|
|
75
|
+
},
|
|
76
|
+
["sfc"]: {
|
|
77
|
+
tabs: 5,
|
|
78
|
+
cb: wc_compile_sfc_1.main, description: `transform sfc files to javascript.`
|
|
75
79
|
},
|
|
76
|
-
/*["sfc"]: {
|
|
77
|
-
tabs: 6,
|
|
78
|
-
cb: wcCompileSFC, description: `transpiles a single file webcomponent to commonjs file for packing. ${wcCompileSFCUsage}`
|
|
79
|
-
},*/
|
|
80
80
|
["start"]: {
|
|
81
81
|
section: "start helpers",
|
|
82
82
|
tabs: 5,
|
|
83
83
|
cb: start_1.main,
|
|
84
|
-
description: `start
|
|
84
|
+
description: `start script in cluster mode.`
|
|
85
85
|
},
|
|
86
86
|
["watch"]: {
|
|
87
87
|
//section: "watch",
|
|
88
88
|
cb: watch_1.main,
|
|
89
89
|
tabs: 5,
|
|
90
|
-
description: `watch
|
|
90
|
+
description: `watch folder for changes.`
|
|
91
91
|
},
|
|
92
92
|
["serve"]: {
|
|
93
93
|
//section: "serve static files",
|
|
94
94
|
tabs: 5,
|
|
95
|
-
cb: serve_1.main, description: `serve static files
|
|
95
|
+
cb: serve_1.main, description: `serve static files.`
|
|
96
96
|
},
|
|
97
|
-
["test"]: { section: "testing", cb: test_1.main, tabs: 5, description: `run test files
|
|
98
|
-
["new:test"]: { cb: new_test_1.main, tabs: 4, description: `create new test.js file
|
|
97
|
+
["test"]: { section: "testing", cb: test_1.main, tabs: 5, description: `run test files.` },
|
|
98
|
+
["new:test"]: { cb: new_test_1.main, tabs: 4, description: `create new test.js file.` },
|
|
99
99
|
["db:console"]: {
|
|
100
100
|
section: "sequelize helpers",
|
|
101
101
|
cb: db_console_1.main,
|
|
102
102
|
tabs: 4,
|
|
103
|
-
description: `
|
|
103
|
+
description: `a query console for sequelize.`
|
|
104
104
|
},
|
|
105
105
|
["db:dump:data"]: {
|
|
106
106
|
cb: db_dump_data_1.main,
|
|
107
107
|
tabs: 4,
|
|
108
|
-
description: `dump the data of the database
|
|
108
|
+
description: `dump the data of the database.`
|
|
109
109
|
},
|
|
110
|
-
["db:push:data"]: { cb: db_push_data_1.main, tabs: 4, description: `push a dump to the database
|
|
110
|
+
["db:push:data"]: { cb: db_push_data_1.main, tabs: 4, description: `push a dump to the database.` },
|
|
111
111
|
["db:make:migration"]: {
|
|
112
112
|
cb: db_makemigrations_1.main,
|
|
113
113
|
tabs: 3,
|
|
114
|
-
description: `
|
|
114
|
+
description: `generate migrations from model changes.`
|
|
115
115
|
},
|
|
116
116
|
["db:make:migration:force:clean:state"]: {
|
|
117
117
|
cb: db_sync_makemigrations_1.main,
|
|
118
118
|
tabs: 1,
|
|
119
|
-
description: `
|
|
119
|
+
description: `force 'local' model state.`
|
|
120
120
|
},
|
|
121
|
-
["db:migrate"]: { cb: db_migrate_1.main, tabs: 4, description: `loads config
|
|
122
|
-
["db:init"]: { cb: db_init_1.main, tabs: 5, description: `init sequelize configuration
|
|
123
|
-
["db:create:model"]: { cb: db_createmodel_1.main, tabs: 4, description: `creates an example model
|
|
121
|
+
["db:migrate"]: { cb: db_migrate_1.main, tabs: 4, description: `loads config and run migrations.` },
|
|
122
|
+
["db:init"]: { cb: db_init_1.main, tabs: 5, description: `init sequelize configuration.` },
|
|
123
|
+
["db:create:model"]: { cb: db_createmodel_1.main, tabs: 4, description: `creates an example model.` }
|
|
124
124
|
}, "npx miqro <command> [args]", console);
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.main = exports.usage = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const fs_1 = require("fs");
|
|
6
|
+
const xml_js_1 = require("../utils/xml.js");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
exports.usage = "npx miqro sfc <sfcDir> <outDir> [-m @miqro/web-components] [-e \".js\"]";
|
|
9
|
+
const DATA_SHADOW_ROOT_MODE = "data-shadow-root-mode";
|
|
10
|
+
const main = async () => {
|
|
11
|
+
const flags = (0, utils_1.extractFlags)(process.argv.slice(3), {
|
|
12
|
+
flags: {
|
|
13
|
+
"m": {
|
|
14
|
+
description: "module to require defineFunction",
|
|
15
|
+
hasValue: true
|
|
16
|
+
},
|
|
17
|
+
"o": {
|
|
18
|
+
description: "extension of output",
|
|
19
|
+
hasValue: true
|
|
20
|
+
},
|
|
21
|
+
"i": {
|
|
22
|
+
description: "extension of input",
|
|
23
|
+
hasValue: true
|
|
24
|
+
},
|
|
25
|
+
"c": {
|
|
26
|
+
description: "remove output files",
|
|
27
|
+
hasValue: false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
if (flags.files.length !== 2) {
|
|
32
|
+
throw new Error(exports.usage);
|
|
33
|
+
}
|
|
34
|
+
const extension = flags.flags.o ? flags.flags.o : ".js";
|
|
35
|
+
const inputExtension = flags.flags.i ? flags.flags.i : ".sfc";
|
|
36
|
+
const webComponentsModule = flags.flags.m ? flags.flags.m : "@miqro/web-components";
|
|
37
|
+
const defineRequireString = extension === ".ts" ?
|
|
38
|
+
`import {define} from "${webComponentsModule}"` :
|
|
39
|
+
`import {define} from "${webComponentsModule}";`;
|
|
40
|
+
const componentRequireString = extension === ".ts" ?
|
|
41
|
+
`import {FunctionComponentThis} from "${webComponentsModule}"` : "";
|
|
42
|
+
const sfcDir = (0, path_1.resolve)(process.cwd(), flags.files[0]);
|
|
43
|
+
const outDir = (0, path_1.resolve)(process.cwd(), flags.files[1]);
|
|
44
|
+
if (!(0, fs_1.statSync)(sfcDir).isDirectory() || !(0, fs_1.statSync)(outDir).isDirectory()) {
|
|
45
|
+
throw new Error(exports.usage);
|
|
46
|
+
}
|
|
47
|
+
const tE = [];
|
|
48
|
+
function recursiveDir(folder) {
|
|
49
|
+
const files = (0, fs_1.readdirSync)(folder);
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
const filePath = (0, path_1.resolve)(folder, file);
|
|
52
|
+
if ((0, fs_1.statSync)(filePath).isDirectory()) {
|
|
53
|
+
recursiveDir(filePath);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if ((0, path_1.extname)(filePath) === inputExtension) {
|
|
57
|
+
tE.push(async function () {
|
|
58
|
+
try {
|
|
59
|
+
const outMainFileName = (0, path_1.basename)(filePath.substring(0, filePath.length - inputExtension.length) + extension);
|
|
60
|
+
const outFileName = (0, path_1.basename)(filePath.substring(0, filePath.length - inputExtension.length) + "-component" + extension);
|
|
61
|
+
const realOutFileDirname = (0, path_1.resolve)(outDir, (0, path_1.relative)(sfcDir, (0, path_1.dirname)(filePath)));
|
|
62
|
+
const realOutFilePath = (0, path_1.resolve)(realOutFileDirname, outFileName);
|
|
63
|
+
const realMainOutFilePath = (0, path_1.resolve)(realOutFileDirname, outMainFileName);
|
|
64
|
+
if (flags.flags.c !== undefined) {
|
|
65
|
+
console.log("%s\n\tremoving %s\n\tremoving %s", filePath, realOutFilePath, realMainOutFilePath);
|
|
66
|
+
(0, fs_1.unlinkSync)(realOutFilePath);
|
|
67
|
+
(0, fs_1.unlinkSync)(realMainOutFilePath);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.log("%s ->\n\t%s\n\t%s", filePath, realOutFilePath, realMainOutFilePath);
|
|
71
|
+
if (!(0, fs_1.existsSync)(realOutFileDirname)) {
|
|
72
|
+
(0, fs_1.mkdirSync)(realOutFileDirname, {
|
|
73
|
+
recursive: true
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const [jsContent, mainJS] = await compileSFC(filePath, {
|
|
77
|
+
defineRequireString,
|
|
78
|
+
componentRequireString
|
|
79
|
+
});
|
|
80
|
+
(0, fs_1.writeFileSync)(realOutFilePath, jsContent);
|
|
81
|
+
const requireInput = "./" + (0, path_1.relative)((0, path_1.dirname)(realMainOutFilePath), realOutFilePath);
|
|
82
|
+
const commonJSANDESM = requireInput.substring(0, requireInput.length - extension.length) + ".js";
|
|
83
|
+
(0, fs_1.writeFileSync)(realMainOutFilePath, mainJS(commonJSANDESM));
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
catch (e) {
|
|
87
|
+
console.error(e);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
recursiveDir(sfcDir);
|
|
95
|
+
await Promise.allSettled(tE.map(t => t()));
|
|
96
|
+
};
|
|
97
|
+
exports.main = main;
|
|
98
|
+
async function compileSFC(sfcPath, requireStrings, extension = ".js") {
|
|
99
|
+
const json = await (0, xml_js_1.parseXML2JSON)((0, fs_1.readFileSync)(sfcPath).toString());
|
|
100
|
+
json.children = json.children.filter((c) => c.name !== "TEXT");
|
|
101
|
+
if (json.children.length !== 1) {
|
|
102
|
+
throw new Error("bad sfc structure(0) for " + sfcPath);
|
|
103
|
+
}
|
|
104
|
+
json.children[0].children = json.children[0].children.filter((c) => c.name !== "TEXT");
|
|
105
|
+
if (json.children[0].children.length !== 2) {
|
|
106
|
+
throw new Error("bad sfc structure(1) for " + sfcPath);
|
|
107
|
+
}
|
|
108
|
+
const componentName = json.children[0].name;
|
|
109
|
+
const componentTemplateTag = json.children[0].children[0];
|
|
110
|
+
const componentScriptTag = json.children[0].children[1];
|
|
111
|
+
const dataShadowRootMode = json.children[0].attributes[DATA_SHADOW_ROOT_MODE] ? json.children[0].attributes[DATA_SHADOW_ROOT_MODE] : undefined;
|
|
112
|
+
let modeArg;
|
|
113
|
+
switch (dataShadowRootMode) {
|
|
114
|
+
case "false":
|
|
115
|
+
modeArg = false;
|
|
116
|
+
break;
|
|
117
|
+
case "true":
|
|
118
|
+
case "close":
|
|
119
|
+
modeArg = { mode: "closed" };
|
|
120
|
+
break;
|
|
121
|
+
case "open":
|
|
122
|
+
modeArg = { mode: "open" };
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
if (componentTemplateTag.name !== "template" || componentScriptTag.name !== "script") {
|
|
126
|
+
throw new Error("bad sfc structure(2) for " + sfcPath);
|
|
127
|
+
}
|
|
128
|
+
/*console.dir(json, {
|
|
129
|
+
depth: 10
|
|
130
|
+
});*/
|
|
131
|
+
if (componentScriptTag.children.length !== 1 || componentScriptTag.children[0].type !== "text") {
|
|
132
|
+
throw new Error("bad sfc structure(3) for " + sfcPath);
|
|
133
|
+
}
|
|
134
|
+
const scriptText = componentScriptTag.children[0].text;
|
|
135
|
+
let baseTabulation = null;
|
|
136
|
+
let startTabulationIndex = 0;
|
|
137
|
+
const jsContent = scriptText.split("\n").map((l, i) => {
|
|
138
|
+
const trimmed = l.trim();
|
|
139
|
+
if (baseTabulation === null && trimmed !== "") {
|
|
140
|
+
baseTabulation = l.indexOf(trimmed);
|
|
141
|
+
startTabulationIndex = i;
|
|
142
|
+
const tabulationSubstring = l.substring(baseTabulation);
|
|
143
|
+
return tabulationSubstring.trim() !== "" ? tabulationSubstring : l;
|
|
144
|
+
}
|
|
145
|
+
else if (baseTabulation !== null) {
|
|
146
|
+
const tabulationSubstring = l.substring(baseTabulation);
|
|
147
|
+
return tabulationSubstring.trim() !== "" ? tabulationSubstring : l;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return "";
|
|
151
|
+
}
|
|
152
|
+
}).join("\n").slice(startTabulationIndex);
|
|
153
|
+
const template = componentTemplateTag.children.map((tag) => tagToString(tag)).join("");
|
|
154
|
+
const outFileContent = `${requireStrings.componentRequireString ? `${requireStrings.componentRequireString}\n\n` : ""}${jsContent}`;
|
|
155
|
+
return [
|
|
156
|
+
outFileContent,
|
|
157
|
+
(jsContentPath) => `${requireStrings.defineRequireString ? `${requireStrings.defineRequireString}\n` : ""}` +
|
|
158
|
+
`import render from "${jsContentPath}";\n\n` +
|
|
159
|
+
`define("${componentName}", render, ${JSON.stringify({
|
|
160
|
+
template,
|
|
161
|
+
...(dataShadowRootMode === undefined ? {} : {
|
|
162
|
+
shadowInit: modeArg
|
|
163
|
+
})
|
|
164
|
+
})});`
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
function getAttributes(tag) {
|
|
168
|
+
const attributes = Object.keys(tag.attributes);
|
|
169
|
+
let ret = "";
|
|
170
|
+
for (const attribute of attributes) {
|
|
171
|
+
if (ret === "") {
|
|
172
|
+
ret = `${attribute}="${tag.attributes[attribute]}"`;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
ret += ` ${attribute}="${tag.attributes[attribute]}"`;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return ret;
|
|
179
|
+
}
|
|
180
|
+
function tagToString(tag) {
|
|
181
|
+
if (tag.type === "text") {
|
|
182
|
+
return tag.text ? tag.text : "";
|
|
183
|
+
}
|
|
184
|
+
else if (tag.type === "comment") {
|
|
185
|
+
return `<!--${tag.text}-->`;
|
|
186
|
+
}
|
|
187
|
+
else if (tag.isSelfClosing) {
|
|
188
|
+
const attrs = getAttributes(tag);
|
|
189
|
+
return `<${tag.name}${attrs ? ` ${attrs}` : ""}/>`;
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
const attrs = getAttributes(tag);
|
|
193
|
+
return `<${tag.name}${attrs ? ` ${attrs}` : ""}>${tag.children.map((c) => tagToString(c)).join("\n")}</${tag.name}>`;
|
|
194
|
+
}
|
|
195
|
+
}
|
package/dist/utils/index.js
CHANGED
|
@@ -82,12 +82,12 @@ const mainCMD = (cmds, usage, logger, cmdArg = process.argv[2], exit = true) =>
|
|
|
82
82
|
logger.info(`Available commands:\n`);
|
|
83
83
|
for (const cmd of Object.keys(cmds)) {
|
|
84
84
|
if (cmds[cmd].section) {
|
|
85
|
-
logger.info(`\n
|
|
85
|
+
logger.info(`\n==${cmds[cmd].section}==\n`);
|
|
86
86
|
}
|
|
87
87
|
//const description = cmds[cmd].description.split("\n").map(s => `${getTabs(/*cmds[cmd].tabs*/2)}${s}`).join("\n");
|
|
88
88
|
//const description = cmds[cmd].description.split("\n").map(s => `${getTabs(/*cmds[cmd].tabs*/1)}${s}`).join("\n");
|
|
89
89
|
const description = cmds[cmd].description.split("\n").map(s => `${getTabs(cmds[cmd].tabs)}${s}`).join("\n");
|
|
90
|
-
logger.info(
|
|
90
|
+
logger.info(`${cmd}${description}`);
|
|
91
91
|
//logger.info(`${cmd}\n${description}`);
|
|
92
92
|
}
|
|
93
93
|
logger.info("");
|
package/dist/utils/xml.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseXML2JSON = void 0;
|
|
4
|
-
const
|
|
4
|
+
const sax_1 = require("sax");
|
|
5
5
|
const parseXML2JSON = async (val) => {
|
|
6
6
|
return new Promise((resolve, reject) => {
|
|
7
7
|
const ret = {
|
|
@@ -15,13 +15,13 @@ const parseXML2JSON = async (val) => {
|
|
|
15
15
|
let current = {
|
|
16
16
|
ref: ret
|
|
17
17
|
};
|
|
18
|
-
const p = parser(
|
|
18
|
+
const p = (0, sax_1.parser)(false, {
|
|
19
19
|
noscript: true,
|
|
20
|
-
|
|
20
|
+
lowercase: true
|
|
21
21
|
});
|
|
22
22
|
p.onerror = (e) => {
|
|
23
|
-
// an error happened.
|
|
24
23
|
console.error(e);
|
|
24
|
+
reject(e);
|
|
25
25
|
};
|
|
26
26
|
p.oncomment = (c) => {
|
|
27
27
|
if (!current) {
|
|
@@ -53,15 +53,17 @@ const parseXML2JSON = async (val) => {
|
|
|
53
53
|
};
|
|
54
54
|
current.ref.children.push(node);
|
|
55
55
|
};
|
|
56
|
-
p.onopentag = (
|
|
57
|
-
// opened a tag. node has "name" and "attributes"
|
|
58
|
-
/*if (node.name.toLocaleLowerCase() === "bpmn:sequenceflow") {
|
|
59
|
-
console.log("open %o", node);
|
|
60
|
-
}*/
|
|
56
|
+
p.onopentag = (t) => {
|
|
61
57
|
if (!current) {
|
|
62
58
|
console.error("current null");
|
|
63
59
|
process.exit(1);
|
|
64
60
|
}
|
|
61
|
+
const node = {
|
|
62
|
+
...t,
|
|
63
|
+
type: "node",
|
|
64
|
+
text: "",
|
|
65
|
+
children: []
|
|
66
|
+
};
|
|
65
67
|
node.type = "node";
|
|
66
68
|
node.text = "";
|
|
67
69
|
node.children = [];
|
|
@@ -71,12 +73,10 @@ const parseXML2JSON = async (val) => {
|
|
|
71
73
|
ref: node
|
|
72
74
|
};
|
|
73
75
|
};
|
|
74
|
-
p.onattribute = (attr) => {
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
p.onclosetag = (
|
|
78
|
-
// opened a tag. node has "name" and "attributes"
|
|
79
|
-
// console.log("close %s", node);
|
|
76
|
+
/*p.onattribute = (attr: XMLAttr) => {
|
|
77
|
+
|
|
78
|
+
};*/
|
|
79
|
+
p.onclosetag = () => {
|
|
80
80
|
if (!current) {
|
|
81
81
|
console.error("current null");
|
|
82
82
|
process.exit(1);
|
|
@@ -86,8 +86,6 @@ const parseXML2JSON = async (val) => {
|
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
88
|
p.onend = () => {
|
|
89
|
-
// console.log("end");
|
|
90
|
-
// parser stream is done, and ready to have more stuff written to it.
|
|
91
89
|
resolve(ret);
|
|
92
90
|
};
|
|
93
91
|
p.write(val).close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "miqro",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
"@miqro/parser": "^0.1.5",
|
|
22
22
|
"@miqro/runner": "^1.2.8",
|
|
23
23
|
"@miqro/test": "^0.2.4",
|
|
24
|
-
"
|
|
24
|
+
"@types/sax": "^1.2.4",
|
|
25
|
+
"deep-diff": "1.0.2",
|
|
26
|
+
"sax": "^1.2.4"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@types/cookie": "0.4.1",
|