tkeron 0.0.5 → 0.0.7
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/README.md +8 -6
- package/changelog.md +12 -1
- package/dist/build.js +48 -12
- package/dist/cmdBuild.d.ts +2 -1
- package/dist/cmdBuild.js +4 -3
- package/dist/cmdDev.d.ts +3 -2
- package/dist/cmdDev.js +7 -2
- package/dist/cmdGenerate.d.ts +2 -1
- package/dist/cmdGenerate.js +1 -1
- package/dist/cmdInit.d.ts +2 -1
- package/dist/cmdInit.js +3 -3
- package/dist/copyDir.js +1 -1
- package/dist/eventEmitter.js +1 -1
- package/dist/fileExist.js +1 -1
- package/dist/generateItems.js +2 -2
- package/dist/getDocument.js +12 -11
- package/dist/getFilesRecursive.js +11 -6
- package/dist/getOptions.js +1 -2
- package/dist/injectTsFile.js +1 -1
- package/dist/jsDom/crypto.js +24 -4
- package/dist/jsDom/fetch.d.ts +2 -0
- package/dist/jsDom/fetch.js +13 -0
- package/dist/jsDom/writeLogElement.js +2 -1
- package/dist/libFiles.ts.js +1 -1
- package/dist/main.js +29 -29
- package/dist/mod.d.ts +3 -3
- package/dist/range.js +1 -1
- package/dist/rnda.js +2 -2
- package/dist/simpleHotRestart.js +3 -2
- package/dist/tkeron.js +10 -13
- package/distFiles/eventEmitter.ts +23 -24
- package/distFiles/getType.ts +2 -2
- package/distFiles/random.ts +17 -18
- package/distFiles/range.ts +2 -2
- package/distFiles/rectReady.ts +29 -26
- package/distFiles/rnda.ts +4 -4
- package/distFiles/runOncePerTime.ts +12 -11
- package/distFiles/simpleHotRestart.ts +14 -16
- package/distFiles/tkeron.ts +25 -23
- package/package.json +50 -45
- package/tkeron.json +3 -3
- package/tsconfig.json +10 -28
- package/tkeron.tsconfig.json +0 -12
package/README.md
CHANGED
|
@@ -7,13 +7,12 @@ Micro framework for developing web user interfaces with typescript.
|
|
|
7
7
|
- Start your project faster, compile faster than other frameworks (thanks to esbuild).
|
|
8
8
|
- Create pre-rendered components or pages.
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|

|
|
12
11
|
|
|
13
12
|
**How to use**
|
|
14
13
|
|
|
15
|
-
|
|
16
14
|
---
|
|
15
|
+
|
|
17
16
|
- Install tkeron globally
|
|
18
17
|
|
|
19
18
|
```bash
|
|
@@ -21,6 +20,7 @@ npm i -g tkeron
|
|
|
21
20
|
```
|
|
22
21
|
|
|
23
22
|
---
|
|
23
|
+
|
|
24
24
|
- Enter in your project directory and run:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
@@ -30,6 +30,7 @@ tkeron init
|
|
|
30
30
|
This will create a blank project in the "front" directory.
|
|
31
31
|
|
|
32
32
|
---
|
|
33
|
+
|
|
33
34
|
- To build the html file run this:
|
|
34
35
|
|
|
35
36
|
```bash
|
|
@@ -39,6 +40,7 @@ tkeron build
|
|
|
39
40
|
This will transpile the project in the directory "web"
|
|
40
41
|
|
|
41
42
|
---
|
|
43
|
+
|
|
42
44
|
- To run in your browser:
|
|
43
45
|
|
|
44
46
|
```bash
|
|
@@ -48,29 +50,29 @@ tkeron dev
|
|
|
48
50
|
This command will create a server on port 5000 for the "web" directory and will observe the file change in the "front" directory.
|
|
49
51
|
|
|
50
52
|
---
|
|
53
|
+
|
|
51
54
|
- to create a page use this:
|
|
52
55
|
|
|
53
56
|
```bash
|
|
54
57
|
tkeron generate page index
|
|
55
58
|
```
|
|
56
59
|
|
|
57
|
-
or its short version:
|
|
60
|
+
or its short version:
|
|
58
61
|
|
|
59
62
|
```bash
|
|
60
63
|
tk g p index
|
|
61
64
|
```
|
|
62
65
|
|
|
63
66
|
---
|
|
67
|
+
|
|
64
68
|
- to create a component use this:
|
|
65
69
|
|
|
66
70
|
```bash
|
|
67
71
|
tkeron generate component my/button
|
|
68
72
|
```
|
|
69
73
|
|
|
70
|
-
or its short version:
|
|
74
|
+
or its short version:
|
|
71
75
|
|
|
72
76
|
```bash
|
|
73
77
|
tk g c my/button
|
|
74
78
|
```
|
|
75
|
-
|
|
76
|
-
|
package/changelog.md
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
# v0.0.7
|
|
2
|
+
|
|
3
|
+
- replace commander for @tkeron/commands.
|
|
4
|
+
|
|
5
|
+
# v0.0.6
|
|
6
|
+
|
|
7
|
+
- fixed fetch error.
|
|
8
|
+
|
|
9
|
+
# v0.0.5
|
|
10
|
+
|
|
11
|
+
- move to cli directory, action runs on directory changes.
|
|
12
|
+
|
|
1
13
|
# v0.0.4
|
|
2
14
|
|
|
3
15
|
- update bundleTs function to allow delete outfile.
|
|
@@ -5,4 +17,3 @@
|
|
|
5
17
|
# v0.0.3
|
|
6
18
|
|
|
7
19
|
- fix error in simpleHotRestart script due to undefined "exports" variable.
|
|
8
|
-
|
package/dist/build.js
CHANGED
|
@@ -16,8 +16,11 @@ const backRegex = /\.back\.ts$/;
|
|
|
16
16
|
const htmlPageRegex = /\.page\.html$/;
|
|
17
17
|
const build = async (args, minify = true) => {
|
|
18
18
|
const { hotRestart, ignoreConsoleLogs, ignoreErrors } = args;
|
|
19
|
-
const { outputDir, sourceDir } = (0, getOptions_1.getOptions)({
|
|
20
|
-
|
|
19
|
+
const { outputDir, sourceDir } = (0, getOptions_1.getOptions)({
|
|
20
|
+
sourceDir: args.sourceDir,
|
|
21
|
+
outputDir: args.outputDir,
|
|
22
|
+
});
|
|
23
|
+
if (!(await (0, fileExist_1.fileExists)(sourceDir)))
|
|
21
24
|
throw "directory does not exist";
|
|
22
25
|
await (0, promises_1.mkdir)(outputDir, { recursive: true });
|
|
23
26
|
const pagesReady = [];
|
|
@@ -28,10 +31,21 @@ const build = async (args, minify = true) => {
|
|
|
28
31
|
const htmlFile = file.replace(backRegex, ".page.html");
|
|
29
32
|
pagesReady.push(htmlFile);
|
|
30
33
|
const htmlExist = await (0, fileExist_1.fileExists)(htmlFile);
|
|
31
|
-
let html = htmlExist
|
|
34
|
+
let html = htmlExist
|
|
35
|
+
? await (0, promises_1.readFile)(htmlFile, { encoding: "utf-8" })
|
|
36
|
+
: (0, generateItems_1.pageItem)(name).html;
|
|
32
37
|
const scriptId = "tmp" + (0, rnd_1.rnds)(25);
|
|
33
|
-
html = await (0, injectTsFile_1.injectTsFile)({
|
|
34
|
-
|
|
38
|
+
html = await (0, injectTsFile_1.injectTsFile)({
|
|
39
|
+
html,
|
|
40
|
+
outputDir,
|
|
41
|
+
sourceDir,
|
|
42
|
+
tsFile: file,
|
|
43
|
+
scriptId,
|
|
44
|
+
});
|
|
45
|
+
const { document, jsDomErrors, window } = (0, getDocument_1.getDocument)(html, {
|
|
46
|
+
ignoreConsoleLogs,
|
|
47
|
+
ignoreErrors,
|
|
48
|
+
});
|
|
35
49
|
if (ignoreErrors && jsDomErrors.length)
|
|
36
50
|
jsDomErrors.forEach((_) => console["log"](`page ${name} error: `, _.detail || _));
|
|
37
51
|
await new Promise((ok) => {
|
|
@@ -50,20 +64,30 @@ const build = async (args, minify = true) => {
|
|
|
50
64
|
html = (0, serializeDocument_1.serializeDocument)(document);
|
|
51
65
|
window.close();
|
|
52
66
|
const tsFile = htmlFile.replace(htmlPageRegex, ".page.ts");
|
|
53
|
-
const outHtmlFile = file
|
|
54
|
-
|
|
67
|
+
const outHtmlFile = file
|
|
68
|
+
.replace(sourceDir, outputDir)
|
|
69
|
+
.replace(backRegex, ".html");
|
|
70
|
+
const outTsFile = file
|
|
71
|
+
.replace(sourceDir, outputDir)
|
|
72
|
+
.replace(backRegex, ".js");
|
|
55
73
|
html = html.replace(/\/\*tkeron\-front\-script/g, "");
|
|
56
74
|
html = html.replace(/tkeron\-front\-script\*\//g, "");
|
|
57
75
|
buildFrontPromises.push((0, exports.tryBuildFront)(name, html, outHtmlFile, hotRestart, outTsFile, "tkeron_page_js", tsFile, minify));
|
|
58
76
|
}
|
|
59
|
-
const htmlFiles = [
|
|
77
|
+
const htmlFiles = [
|
|
78
|
+
...(0, getFilesRecursive_1.getFilesRecursive)(sourceDir, { pattern: htmlPageRegex }),
|
|
79
|
+
];
|
|
60
80
|
for (const file of htmlFiles) {
|
|
61
81
|
const name = (0, path_1.basename)(file).replace(htmlPageRegex, "");
|
|
62
82
|
if (pagesReady.includes(file))
|
|
63
83
|
continue;
|
|
64
84
|
let html = await (0, promises_1.readFile)(file, { encoding: "utf-8" });
|
|
65
|
-
const outHtmlFile = file
|
|
66
|
-
|
|
85
|
+
const outHtmlFile = file
|
|
86
|
+
.replace(sourceDir, outputDir)
|
|
87
|
+
.replace(htmlPageRegex, ".html");
|
|
88
|
+
const outTsFile = file
|
|
89
|
+
.replace(sourceDir, outputDir)
|
|
90
|
+
.replace(htmlPageRegex, ".html");
|
|
67
91
|
const tsFile = file.replace(htmlPageRegex, ".page.ts");
|
|
68
92
|
html = html.replace(/\/\*tkeron\-front\-script/g, "");
|
|
69
93
|
html = html.replace(/tkeron\-front\-script\*\//g, "");
|
|
@@ -89,13 +113,25 @@ exports.build = build;
|
|
|
89
113
|
const tryBuildFront = async (name, html, outHtmlFile, hotRestart, outTsFile, scriptId, tsFile, minify = true) => {
|
|
90
114
|
return new Promise(async (ok) => {
|
|
91
115
|
try {
|
|
92
|
-
await (0, buildFront_1.buildFront)({
|
|
116
|
+
await (0, buildFront_1.buildFront)({
|
|
117
|
+
html,
|
|
118
|
+
outHtmlFile,
|
|
119
|
+
hotRestart,
|
|
120
|
+
outTsFile,
|
|
121
|
+
scriptId: "tkeron_page_js",
|
|
122
|
+
tsFile,
|
|
123
|
+
minify,
|
|
124
|
+
});
|
|
93
125
|
console["log"](`site ${name} built`);
|
|
94
126
|
ok([true, name, async () => { }]);
|
|
95
127
|
}
|
|
96
128
|
catch (_) {
|
|
97
129
|
console["log"](`error building site ${name}: `, _);
|
|
98
|
-
ok([
|
|
130
|
+
ok([
|
|
131
|
+
false,
|
|
132
|
+
name,
|
|
133
|
+
() => (0, exports.tryBuildFront)(name, html, outHtmlFile, hotRestart, outTsFile, scriptId, tsFile),
|
|
134
|
+
]);
|
|
99
135
|
}
|
|
100
136
|
});
|
|
101
137
|
};
|
package/dist/cmdBuild.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Callback } from "@tkeron/commands";
|
|
2
|
+
export declare const cmdBuild: Callback;
|
package/dist/cmdBuild.js
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cmdBuild = void 0;
|
|
4
4
|
const build_1 = require("./build");
|
|
5
|
-
const cmdBuild = (sourceDir, outputDir) => (0, build_1.build)({
|
|
6
|
-
sourceDir,
|
|
5
|
+
const cmdBuild = ({ sourceDir, outputDir } = { sourceDir: "", outputDir: "" }) => (0, build_1.build)({
|
|
6
|
+
sourceDir,
|
|
7
|
+
outputDir,
|
|
7
8
|
hotRestart: false,
|
|
8
9
|
ignoreConsoleLogs: true,
|
|
9
|
-
ignoreErrors: true
|
|
10
|
+
ignoreErrors: true,
|
|
10
11
|
});
|
|
11
12
|
exports.cmdBuild = cmdBuild;
|
package/dist/cmdDev.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Server } from "http";
|
|
3
|
+
import { Callback } from "@tkeron/commands";
|
|
3
4
|
export declare const dev: (sourceDir: string, outputDir: string, port?: number, addr?: string) => Promise<{
|
|
4
5
|
closeWatcher: () => void;
|
|
5
|
-
closeServer: () => Server<typeof import("
|
|
6
|
+
closeServer: () => Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
6
7
|
}>;
|
|
7
|
-
export declare const cmdDev:
|
|
8
|
+
export declare const cmdDev: Callback;
|
package/dist/cmdDev.js
CHANGED
|
@@ -57,7 +57,12 @@ const dev = async (sourceDir, outputDir, port = 5000, addr = "127.0.0.1") => {
|
|
|
57
57
|
};
|
|
58
58
|
};
|
|
59
59
|
exports.dev = dev;
|
|
60
|
-
const cmdDev =
|
|
61
|
-
|
|
60
|
+
const cmdDev = ({ sourceDir, outputDir, port, addr } = {
|
|
61
|
+
sourceDir: "",
|
|
62
|
+
outputDir: "",
|
|
63
|
+
port: "5000",
|
|
64
|
+
addr: "127.0.0.1",
|
|
65
|
+
}) => {
|
|
66
|
+
(0, exports.dev)(sourceDir, outputDir, Number(port), addr);
|
|
62
67
|
};
|
|
63
68
|
exports.cmdDev = cmdDev;
|
package/dist/cmdGenerate.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Callback } from "@tkeron/commands";
|
|
2
|
+
export declare const cmdGenerate: Callback;
|
package/dist/cmdGenerate.js
CHANGED
|
@@ -6,7 +6,7 @@ const promises_1 = require("fs/promises");
|
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const generateItems_1 = require("./generateItems");
|
|
8
8
|
const getOptions_1 = require("./getOptions");
|
|
9
|
-
const cmdGenerate = async (item, path) => {
|
|
9
|
+
const cmdGenerate = async ({ item, path } = { item: "", path: "" }) => {
|
|
10
10
|
const { sourceDir } = (0, getOptions_1.getOptions)();
|
|
11
11
|
const name = (0, path_1.basename)(path);
|
|
12
12
|
if (!generateItems_1.validItems.includes(item)) {
|
package/dist/cmdInit.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { Callback } from "@tkeron/commands";
|
|
2
|
+
export declare const cmdInit: Callback;
|
package/dist/cmdInit.js
CHANGED
|
@@ -10,15 +10,15 @@ const createTsConfigFile_1 = require("./createTsConfigFile");
|
|
|
10
10
|
const fileExist_1 = require("./fileExist");
|
|
11
11
|
const getOptions_1 = require("./getOptions");
|
|
12
12
|
const libFiles_ts_1 = require("./libFiles.ts");
|
|
13
|
-
const cmdInit = async (sourceDir, outputDir) => {
|
|
13
|
+
const cmdInit = async ({ sourceDir, outputDir } = { sourceDir: "", outputDir: "" }) => {
|
|
14
14
|
const options = (0, getOptions_1.getOptions)({ sourceDir, outputDir });
|
|
15
15
|
sourceDir = options.sourceDir;
|
|
16
16
|
await (0, promises_1.writeFile)("tkeron.json", JSON.stringify(options, null, 4));
|
|
17
17
|
await (0, createTsConfigFile_1.createTsConfigFile)();
|
|
18
|
-
if (!await (0, fileExist_1.fileExists)(sourceDir))
|
|
18
|
+
if (!(await (0, fileExist_1.fileExists)(sourceDir)))
|
|
19
19
|
await (0, promises_1.mkdir)(sourceDir, { recursive: true });
|
|
20
20
|
const tklibs = (0, path_1.join)(sourceDir, "tklibs");
|
|
21
|
-
if (!await (0, fileExist_1.fileExists)(tklibs))
|
|
21
|
+
if (!(await (0, fileExist_1.fileExists)(tklibs)))
|
|
22
22
|
await (0, promises_1.mkdir)(tklibs, { recursive: true });
|
|
23
23
|
for (const file of libFiles_ts_1.libFiles) {
|
|
24
24
|
const dest = (0, path_1.join)(tklibs, file);
|
package/dist/copyDir.js
CHANGED
|
@@ -10,7 +10,7 @@ const copyDir = async (sourceDir, outputDir) => {
|
|
|
10
10
|
const sourcePath = (0, path_1.join)(sourceDir, file);
|
|
11
11
|
const outPath = (0, path_1.join)(outputDir, file);
|
|
12
12
|
const dir = (0, path_1.dirname)(outPath);
|
|
13
|
-
if (!await (0, fileExist_1.fileExists)(dir))
|
|
13
|
+
if (!(await (0, fileExist_1.fileExists)(dir)))
|
|
14
14
|
await (0, promises_1.mkdir)(dir, { recursive: true });
|
|
15
15
|
await (0, promises_1.copyFile)(sourcePath, outPath);
|
|
16
16
|
}
|
package/dist/eventEmitter.js
CHANGED
package/dist/fileExist.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fileExistsSync = exports.fileExists = void 0;
|
|
4
4
|
const promises_1 = require("fs/promises");
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
|
-
const fileExists = async (path) => !!(await (0, promises_1.stat)(path).catch(_ => false));
|
|
6
|
+
const fileExists = async (path) => !!(await (0, promises_1.stat)(path).catch((_) => false));
|
|
7
7
|
exports.fileExists = fileExists;
|
|
8
8
|
const fileExistsSync = (path) => {
|
|
9
9
|
try {
|
package/dist/generateItems.js
CHANGED
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validItems = exports.pageItem = exports.componentItem = void 0;
|
|
4
4
|
const componentItem = (name) => ({
|
|
5
5
|
ts: `import { tkeron, Component } from "@tkeron";\nimport css from "./${name}.css";\n\nexport interface ${name} extends Component {\n \n}\n\nexport const ${name} = () => {\n const com = tkeron("${name}") as ${name};\n \n return com;\n};\ntkeron.css("${name}",css);\n`,
|
|
6
|
-
css: `.${name} {\n \n}\n
|
|
6
|
+
css: `.${name} {\n \n}\n`,
|
|
7
7
|
});
|
|
8
8
|
exports.componentItem = componentItem;
|
|
9
9
|
const pageItem = (name) => ({
|
|
10
10
|
html: `<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>${name}</title>\n </head>\n <body></body>\n</html>\n`,
|
|
11
11
|
ts: `import { tkeron } from "@tkeron";\n\ntkeron({type:"h1",value:"${name} page front works"}).appendIn("body");`,
|
|
12
12
|
back: `import { tkeron } from "@tkeron";\n\ntkeron({type:"h1",value:"${name} page back works"}).appendIn("body");`,
|
|
13
|
-
css: `html, body {\n margin: 0;\n padding: 0;\n}\n
|
|
13
|
+
css: `html, body {\n margin: 0;\n padding: 0;\n}\n`,
|
|
14
14
|
});
|
|
15
15
|
exports.pageItem = pageItem;
|
|
16
16
|
exports.validItems = ["component", "c", "page", "p"];
|
package/dist/getDocument.js
CHANGED
|
@@ -5,6 +5,7 @@ const jsdom_1 = require("jsdom");
|
|
|
5
5
|
const crypto_1 = require("./jsDom/crypto");
|
|
6
6
|
const errors_1 = require("./jsDom/errors");
|
|
7
7
|
const logs_1 = require("./jsDom/logs");
|
|
8
|
+
const fetch_1 = require("./jsDom/fetch");
|
|
8
9
|
const getDocument = (html, options) => {
|
|
9
10
|
if (!options)
|
|
10
11
|
options = {};
|
|
@@ -13,20 +14,20 @@ const getDocument = (html, options) => {
|
|
|
13
14
|
const virtualConsole = new jsdom_1.VirtualConsole({ captureRejections: true });
|
|
14
15
|
const jsDomErrors = [];
|
|
15
16
|
const logs = [];
|
|
16
|
-
virtualConsole.on("jsdomError", e => jsDomErrors.push(e));
|
|
17
|
+
virtualConsole.on("jsdomError", (e) => jsDomErrors.push(e));
|
|
17
18
|
virtualConsole.on("log", (e) => logs.push(e));
|
|
18
19
|
if (html.trim() === "")
|
|
19
20
|
html = `<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="UTF-8" />\n <meta http-equiv="X-UA-Compatible" content="IE=edge" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <title>Document</title>\n </head>\n <body></body>\n</html>\n`;
|
|
20
|
-
const { window } = new jsdom_1.JSDOM(html, constructorOptions ||
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
const { window } = new jsdom_1.JSDOM(html, constructorOptions || {
|
|
22
|
+
resources: "usable",
|
|
23
|
+
runScripts: "dangerously",
|
|
24
|
+
virtualConsole,
|
|
25
|
+
beforeParse: (window) => {
|
|
26
|
+
(0, errors_1.ext_errors)(window);
|
|
27
|
+
(0, crypto_1.ext_crypto)(window);
|
|
28
|
+
(0, fetch_1.ext_fetch)(window);
|
|
29
|
+
},
|
|
30
|
+
});
|
|
30
31
|
const document = window.document;
|
|
31
32
|
if (!ignoreErrors)
|
|
32
33
|
(0, errors_1.handleJsDomError)(jsDomErrors, document);
|
|
@@ -7,7 +7,7 @@ const pathToUrlResource_1 = require("./pathToUrlResource");
|
|
|
7
7
|
function* getFilesRecursive(directory, options) {
|
|
8
8
|
if (!options)
|
|
9
9
|
options = {};
|
|
10
|
-
const { pattern, returnNamesOnly, excludePattern, returnOnlyDirs, useDirectoryBase } = options;
|
|
10
|
+
const { pattern, returnNamesOnly, excludePattern, returnOnlyDirs, useDirectoryBase, } = options;
|
|
11
11
|
let files = [];
|
|
12
12
|
try {
|
|
13
13
|
files = (0, fs_1.readdirSync)(directory, { withFileTypes: true });
|
|
@@ -16,7 +16,7 @@ function* getFilesRecursive(directory, options) {
|
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const topDirectory = directory;
|
|
19
|
-
const pending = files.map(file => ({ file, directory }));
|
|
19
|
+
const pending = files.map((file) => ({ file, directory }));
|
|
20
20
|
while (pending.length) {
|
|
21
21
|
const { file, directory } = pending.pop();
|
|
22
22
|
if (file.isDirectory()) {
|
|
@@ -32,7 +32,9 @@ function* getFilesRecursive(directory, options) {
|
|
|
32
32
|
catch (e) {
|
|
33
33
|
continue;
|
|
34
34
|
}
|
|
35
|
-
files
|
|
35
|
+
files
|
|
36
|
+
.map((file) => ({ file, directory: path }))
|
|
37
|
+
.forEach((item) => pending.push(item));
|
|
36
38
|
continue;
|
|
37
39
|
}
|
|
38
40
|
if (!file.isFile())
|
|
@@ -40,9 +42,13 @@ function* getFilesRecursive(directory, options) {
|
|
|
40
42
|
if (excludePattern && file.name.match(excludePattern))
|
|
41
43
|
continue;
|
|
42
44
|
if (useDirectoryBase && !pattern)
|
|
43
|
-
yield returnNamesOnly
|
|
45
|
+
yield returnNamesOnly
|
|
46
|
+
? file.name
|
|
47
|
+
: (0, pathToUrlResource_1.pathToUrlResource)((0, path_1.join)(directory, file.name), topDirectory).url;
|
|
44
48
|
if (useDirectoryBase && pattern && file.name.match(pattern))
|
|
45
|
-
yield returnNamesOnly
|
|
49
|
+
yield returnNamesOnly
|
|
50
|
+
? file.name
|
|
51
|
+
: (0, pathToUrlResource_1.pathToUrlResource)((0, path_1.join)(directory, file.name), topDirectory).url;
|
|
46
52
|
if (!useDirectoryBase && !pattern)
|
|
47
53
|
yield returnNamesOnly ? file.name : (0, path_1.join)(directory, file.name);
|
|
48
54
|
if (!useDirectoryBase && pattern && file.name.match(pattern))
|
|
@@ -50,4 +56,3 @@ function* getFilesRecursive(directory, options) {
|
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
exports.getFilesRecursive = getFilesRecursive;
|
|
53
|
-
;
|
package/dist/getOptions.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOptions = void 0;
|
|
4
4
|
const readJsonFile_1 = require("./readJsonFile");
|
|
5
|
-
;
|
|
6
5
|
const getOptions = (opts) => {
|
|
7
6
|
const jsonOpt = (0, readJsonFile_1.readJsonFile)("tkeron.json");
|
|
8
7
|
if (!opts)
|
|
@@ -15,7 +14,7 @@ const getOptions = (opts) => {
|
|
|
15
14
|
if (!jsonOpt) {
|
|
16
15
|
return defaultOpt;
|
|
17
16
|
}
|
|
18
|
-
Object.keys(defaultOpt).forEach(key => {
|
|
17
|
+
Object.keys(defaultOpt).forEach((key) => {
|
|
19
18
|
if (key in jsonOpt)
|
|
20
19
|
defaultOpt[key] = jsonOpt[key];
|
|
21
20
|
});
|
package/dist/injectTsFile.js
CHANGED
|
@@ -9,7 +9,7 @@ const injectCode_1 = require("./injectCode");
|
|
|
9
9
|
const pathToUrlResource_1 = require("./pathToUrlResource");
|
|
10
10
|
const injectTsFile = async (options) => {
|
|
11
11
|
const { tsFile, sourceDir, outputDir, scriptId } = options;
|
|
12
|
-
if (!await (0, fileExist_1.fileExists)(tsFile))
|
|
12
|
+
if (!(await (0, fileExist_1.fileExists)(tsFile)))
|
|
13
13
|
throw `file ${tsFile} does not exist`;
|
|
14
14
|
let { html } = options;
|
|
15
15
|
const { resource } = (0, pathToUrlResource_1.pathToUrlResource)(tsFile, sourceDir);
|
package/dist/jsDom/crypto.js
CHANGED
|
@@ -2,14 +2,34 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ext_crypto = exports.getRandomValues = void 0;
|
|
4
4
|
const getType_1 = require("../getType");
|
|
5
|
-
const allowed = [
|
|
6
|
-
|
|
5
|
+
const allowed = [
|
|
6
|
+
"Int8Array",
|
|
7
|
+
"Int16Array",
|
|
8
|
+
"Int32Array",
|
|
9
|
+
"Uint8Array",
|
|
10
|
+
"Uint16Array",
|
|
11
|
+
"Uint32Array",
|
|
12
|
+
"Float32Array",
|
|
13
|
+
"Float64Array",
|
|
14
|
+
"Uint8ClampedArray",
|
|
15
|
+
];
|
|
16
|
+
const allowedMax = [
|
|
17
|
+
2 ** 8,
|
|
18
|
+
2 ** 16,
|
|
19
|
+
2 ** 32,
|
|
20
|
+
2 ** 8,
|
|
21
|
+
2 ** 16,
|
|
22
|
+
2 ** 32,
|
|
23
|
+
2 ** 32,
|
|
24
|
+
2 ** 64,
|
|
25
|
+
2 ** 8,
|
|
26
|
+
];
|
|
7
27
|
const getRandomValues = (a) => {
|
|
8
28
|
const type = (0, getType_1.getType)(a);
|
|
9
29
|
if (!allowed.includes(type))
|
|
10
30
|
throw DOMException.NOT_SUPPORTED_ERR;
|
|
11
|
-
const length =
|
|
12
|
-
if (length >
|
|
31
|
+
const length = Array.from(a).length;
|
|
32
|
+
if (length > 2 ** 16)
|
|
13
33
|
throw DOMException.QUOTA_EXCEEDED_ERR;
|
|
14
34
|
const max = allowedMax[allowed.indexOf(type)];
|
|
15
35
|
return a.map(() => Math.random() * max);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ext_fetch = void 0;
|
|
4
|
+
const ext_fetch = (window) => {
|
|
5
|
+
//@ts-ignore
|
|
6
|
+
window.fetch = async () => {
|
|
7
|
+
return {
|
|
8
|
+
json: async () => ({}),
|
|
9
|
+
text: async () => "",
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
exports.ext_fetch = ext_fetch;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.writeLogElement = void 0;
|
|
4
4
|
const writeLogElement = (message, document, type = "tkeron_log") => {
|
|
5
|
-
let tkeronBackLogs = document.body.querySelector(".tkeron_back_logs") ||
|
|
5
|
+
let tkeronBackLogs = document.body.querySelector(".tkeron_back_logs") ||
|
|
6
|
+
document.createElement("div");
|
|
6
7
|
if (!document.body.querySelector(".tkeron_back_logs")) {
|
|
7
8
|
tkeronBackLogs.classList.add("tkeron_back_logs");
|
|
8
9
|
tkeronBackLogs.innerHTML = "TKERON BACK LOGS:";
|
package/dist/libFiles.ts.js
CHANGED
package/dist/main.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.main = void 0;
|
|
4
|
+
const commands_1 = require("@tkeron/commands");
|
|
4
5
|
const colorette_1 = require("colorette");
|
|
5
|
-
const commander_1 = require("commander");
|
|
6
6
|
const base64_1 = require("./base64");
|
|
7
7
|
const cmdBuild_1 = require("./cmdBuild");
|
|
8
8
|
const cmdDev_1 = require("./cmdDev");
|
|
@@ -26,33 +26,33 @@ const main = (command = "tkeron", argv) => {
|
|
|
26
26
|
console["log"](info, `\n\n type '${command} help' to see commands\n\n`);
|
|
27
27
|
process.exit(0);
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
.
|
|
33
|
-
.
|
|
34
|
-
.
|
|
35
|
-
.
|
|
36
|
-
|
|
37
|
-
.
|
|
38
|
-
.
|
|
39
|
-
.
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
.
|
|
44
|
-
.
|
|
45
|
-
.
|
|
46
|
-
|
|
47
|
-
.
|
|
48
|
-
.
|
|
49
|
-
.
|
|
50
|
-
.
|
|
51
|
-
|
|
52
|
-
.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
29
|
+
(0, commands_1.getCommands)()
|
|
30
|
+
.addCommand("init")
|
|
31
|
+
.addAliases("i")
|
|
32
|
+
.addPositionedArgument("sourceDir")
|
|
33
|
+
.addPositionedArgument("outDir")
|
|
34
|
+
.setCallback(cmdInit_1.cmdInit)
|
|
35
|
+
.next()
|
|
36
|
+
.addCommand("dev")
|
|
37
|
+
.addAliases("d")
|
|
38
|
+
.addPositionedArgument("sourceDir")
|
|
39
|
+
.addPositionedArgument("outDir")
|
|
40
|
+
.addPositionedArgument("port")
|
|
41
|
+
.addPositionedArgument("addr")
|
|
42
|
+
.setCallback(cmdDev_1.cmdDev)
|
|
43
|
+
.next()
|
|
44
|
+
.addCommand("build")
|
|
45
|
+
.addAliases("b")
|
|
46
|
+
.addPositionedArgument("sourceDir")
|
|
47
|
+
.addPositionedArgument("outDir")
|
|
48
|
+
.setCallback(cmdBuild_1.cmdBuild)
|
|
49
|
+
.next()
|
|
50
|
+
.addCommand("generate")
|
|
51
|
+
.addAliases("g")
|
|
52
|
+
.addPositionedArgument("item")
|
|
53
|
+
.addPositionedArgument("path")
|
|
54
|
+
.setCallback(cmdGenerate_1.cmdGenerate)
|
|
55
|
+
.next()
|
|
56
|
+
.run();
|
|
57
57
|
};
|
|
58
58
|
exports.main = main;
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const build: (
|
|
2
|
-
export declare const init: (
|
|
3
|
-
export declare const dev: (
|
|
1
|
+
export declare const build: import("@tkeron/commands").Callback;
|
|
2
|
+
export declare const init: import("@tkeron/commands").Callback;
|
|
3
|
+
export declare const dev: import("@tkeron/commands").Callback;
|
package/dist/range.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.range = void 0;
|
|
4
|
-
const range = (start, stop, step = 1) => Array.from({ length: (stop - start) / step + 1 }, (_, i) => start +
|
|
4
|
+
const range = (start, stop, step = 1) => Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step);
|
|
5
5
|
exports.range = range;
|
package/dist/rnda.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.rnda = void 0;
|
|
4
4
|
const rnda = (a, randomGenerator = Math.random) => a
|
|
5
|
-
.map(_ => [_, randomGenerator()])
|
|
5
|
+
.map((_) => [_, randomGenerator()])
|
|
6
6
|
.sort((w, e) => (w[1] == e[1] ? 0 : w[1] > e[1] ? 1 : -1))
|
|
7
|
-
.map(_ => _[0]);
|
|
7
|
+
.map((_) => _[0]);
|
|
8
8
|
exports.rnda = rnda;
|
package/dist/simpleHotRestart.js
CHANGED
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
(async () => {
|
|
4
4
|
const review = async () => {
|
|
5
5
|
const cb = new Date().getTime();
|
|
6
|
-
const result = await fetch("/compdate.txt?cb=" + cb)
|
|
7
|
-
.
|
|
6
|
+
const result = await fetch("/compdate.txt?cb=" + cb)
|
|
7
|
+
.then((_) => _.json())
|
|
8
|
+
.catch((_) => ({ reload: false }));
|
|
8
9
|
const { reload } = result;
|
|
9
10
|
if (reload) {
|
|
10
11
|
location.reload();
|