tkeron 0.0.6 → 0.0.8
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 +4 -1
- package/dist/build.js +48 -12
- package/dist/cmdBuild.d.ts +4 -1
- package/dist/cmdBuild.js +4 -3
- package/dist/cmdDev.d.ts +6 -1
- package/dist/cmdDev.js +8 -2
- package/dist/cmdGenerate.d.ts +4 -1
- package/dist/cmdGenerate.js +1 -1
- package/dist/cmdInit.d.ts +4 -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/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/writeLogElement.js +2 -1
- package/dist/libFiles.ts.js +1 -1
- package/dist/main.js +29 -29
- package/dist/mod.d.ts +14 -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 +5 -3
- package/tkeron.json +3 -3
- package/tsconfig.json +10 -14
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
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
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
|
@@ -4,4 +4,9 @@ export declare const dev: (sourceDir: string, outputDir: string, port?: number,
|
|
|
4
4
|
closeWatcher: () => void;
|
|
5
5
|
closeServer: () => Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>;
|
|
6
6
|
}>;
|
|
7
|
-
export declare const cmdDev: (sourceDir
|
|
7
|
+
export declare const cmdDev: ({ sourceDir, outputDir, port, addr }?: {
|
|
8
|
+
sourceDir: string;
|
|
9
|
+
outputDir: string;
|
|
10
|
+
port: string;
|
|
11
|
+
addr: string;
|
|
12
|
+
}) => void;
|
package/dist/cmdDev.js
CHANGED
|
@@ -57,7 +57,13 @@ 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
|
+
const numberPort = Number(port) || 5000;
|
|
67
|
+
(0, exports.dev)(sourceDir, outputDir, numberPort, addr);
|
|
62
68
|
};
|
|
63
69
|
exports.cmdDev = cmdDev;
|
package/dist/cmdGenerate.d.ts
CHANGED
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
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"];
|
|
@@ -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);
|
|
@@ -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
|
+
.addAlias("i")
|
|
32
|
+
.addPositionedArgument("sourceDir")
|
|
33
|
+
.addPositionedArgument("outDir")
|
|
34
|
+
.setCallback(cmdInit_1.cmdInit)
|
|
35
|
+
.commands()
|
|
36
|
+
.addCommand("dev")
|
|
37
|
+
.addAlias("d")
|
|
38
|
+
.addPositionedArgument("sourceDir")
|
|
39
|
+
.addPositionedArgument("outDir")
|
|
40
|
+
.addPositionedArgument("port")
|
|
41
|
+
.addPositionedArgument("addr")
|
|
42
|
+
.setCallback(cmdDev_1.cmdDev)
|
|
43
|
+
.commands()
|
|
44
|
+
.addCommand("build")
|
|
45
|
+
.addAlias("b")
|
|
46
|
+
.addPositionedArgument("sourceDir")
|
|
47
|
+
.addPositionedArgument("outDir")
|
|
48
|
+
.setCallback(cmdBuild_1.cmdBuild)
|
|
49
|
+
.commands()
|
|
50
|
+
.addCommand("generate")
|
|
51
|
+
.addAlias("g")
|
|
52
|
+
.addPositionedArgument("item")
|
|
53
|
+
.addPositionedArgument("path")
|
|
54
|
+
.setCallback(cmdGenerate_1.cmdGenerate)
|
|
55
|
+
.commands()
|
|
56
|
+
.start();
|
|
57
57
|
};
|
|
58
58
|
exports.main = main;
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
export declare const build: (sourceDir
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export declare const build: ({ sourceDir, outputDir }?: {
|
|
2
|
+
sourceDir: string;
|
|
3
|
+
outputDir: string;
|
|
4
|
+
}) => Promise<void>;
|
|
5
|
+
export declare const init: ({ sourceDir, outputDir }?: {
|
|
6
|
+
sourceDir: string;
|
|
7
|
+
outputDir: string;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
export declare const dev: ({ sourceDir, outputDir, port, addr }?: {
|
|
10
|
+
sourceDir: string;
|
|
11
|
+
outputDir: string;
|
|
12
|
+
port: string;
|
|
13
|
+
addr: string;
|
|
14
|
+
}) => void;
|
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();
|
package/dist/tkeron.js
CHANGED
|
@@ -34,10 +34,7 @@ const tkeron = (opt, ...classes) => {
|
|
|
34
34
|
}
|
|
35
35
|
if (!opt)
|
|
36
36
|
opt = { type: "div" };
|
|
37
|
-
const valueProp = [
|
|
38
|
-
"input",
|
|
39
|
-
"textarea"
|
|
40
|
-
].some(n => {
|
|
37
|
+
const valueProp = ["input", "textarea"].some((n) => {
|
|
41
38
|
if ("type" in opt)
|
|
42
39
|
return opt.type === n;
|
|
43
40
|
});
|
|
@@ -45,7 +42,7 @@ const tkeron = (opt, ...classes) => {
|
|
|
45
42
|
const priv = {
|
|
46
43
|
parent: {},
|
|
47
44
|
childs: [],
|
|
48
|
-
css: ""
|
|
45
|
+
css: "",
|
|
49
46
|
};
|
|
50
47
|
priv.parent = null;
|
|
51
48
|
const com = {
|
|
@@ -62,7 +59,7 @@ const tkeron = (opt, ...classes) => {
|
|
|
62
59
|
},
|
|
63
60
|
childs: priv.childs,
|
|
64
61
|
add: (...c) => {
|
|
65
|
-
c.forEach(_ => {
|
|
62
|
+
c.forEach((_) => {
|
|
66
63
|
_._setParent(com);
|
|
67
64
|
priv.childs.push(_);
|
|
68
65
|
_.getHTMLElement((ele) => {
|
|
@@ -73,12 +70,12 @@ const tkeron = (opt, ...classes) => {
|
|
|
73
70
|
},
|
|
74
71
|
remove: (c) => {
|
|
75
72
|
c._setParent(null);
|
|
76
|
-
priv.childs = priv.childs.filter(_c => {
|
|
73
|
+
priv.childs = priv.childs.filter((_c) => {
|
|
77
74
|
if (_c.id === c.id)
|
|
78
75
|
return false;
|
|
79
76
|
return true;
|
|
80
77
|
});
|
|
81
|
-
c.getHTMLElement(_el => {
|
|
78
|
+
c.getHTMLElement((_el) => {
|
|
82
79
|
el.removeChild(_el);
|
|
83
80
|
});
|
|
84
81
|
return com;
|
|
@@ -184,7 +181,7 @@ const tkeron = (opt, ...classes) => {
|
|
|
184
181
|
Object.defineProperty(com, "attributes", {
|
|
185
182
|
get() {
|
|
186
183
|
return el.attributes;
|
|
187
|
-
}
|
|
184
|
+
},
|
|
188
185
|
});
|
|
189
186
|
Object.defineProperty(com, "value", {
|
|
190
187
|
get() {
|
|
@@ -200,22 +197,22 @@ const tkeron = (opt, ...classes) => {
|
|
|
200
197
|
el.value = v;
|
|
201
198
|
return true;
|
|
202
199
|
}
|
|
203
|
-
priv.childs.forEach(c => c._setParent(null));
|
|
200
|
+
priv.childs.forEach((c) => c._setParent(null));
|
|
204
201
|
priv.childs.length = 0;
|
|
205
202
|
el.innerHTML = v;
|
|
206
203
|
return true;
|
|
207
|
-
}
|
|
204
|
+
},
|
|
208
205
|
});
|
|
209
206
|
Object.defineProperty(com, "classList", {
|
|
210
207
|
get() {
|
|
211
208
|
//@ts-ignore
|
|
212
209
|
return Array.from(el.classList);
|
|
213
|
-
}
|
|
210
|
+
},
|
|
214
211
|
});
|
|
215
212
|
if (typeof opt.value !== "undefined")
|
|
216
213
|
com.setValue(opt.value);
|
|
217
214
|
if (classes.length) {
|
|
218
|
-
classes.forEach(c => {
|
|
215
|
+
classes.forEach((c) => {
|
|
219
216
|
com.addClass(c);
|
|
220
217
|
});
|
|
221
218
|
}
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
|
|
2
1
|
export interface EventEmitter {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
emit: (event: string, ...args: any[]) => void;
|
|
3
|
+
on: (event: string, listener: (...args: any[]) => void) => () => void;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
export const getEventEmitter = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
7
|
+
let handlers: any = {};
|
|
8
|
+
let n = 0;
|
|
9
|
+
const ee: EventEmitter = {
|
|
10
|
+
emit: (event: string, ...args: any[]) => {
|
|
11
|
+
if (!(event in handlers)) return;
|
|
12
|
+
for (const listener of handlers[event]) {
|
|
13
|
+
listener(...args);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
on: (event: string, listener: (...args: any[]) => void) => {
|
|
17
|
+
if (!(event in handlers)) handlers[event] = [];
|
|
18
|
+
n++;
|
|
19
|
+
const id = n;
|
|
20
|
+
(listener as any).id = id;
|
|
21
|
+
handlers[event].push(listener);
|
|
22
|
+
return () => {
|
|
23
|
+
handlers[event] = handlers[event].filter((_: any) => _.id !== id);
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
return ee;
|
|
29
28
|
};
|
package/distFiles/getType.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export const getType = (o: any) =>
|
|
2
|
+
Object.prototype.toString.call(o).match(/\w*\s(\w*)/)![1];
|
package/distFiles/random.ts
CHANGED
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
|
|
2
1
|
export function* pseudoRnd(seed = 0, limit = 0) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
let current = 0;
|
|
3
|
+
while (true) {
|
|
4
|
+
seed ^= seed << 13;
|
|
5
|
+
seed ^= seed >> 17;
|
|
6
|
+
seed ^= seed << 5;
|
|
7
|
+
yield seed;
|
|
8
|
+
if (limit > 0) current++;
|
|
9
|
+
if (limit > 0 && current >= limit) break;
|
|
10
|
+
}
|
|
12
11
|
}
|
|
13
12
|
|
|
14
13
|
export const getPseudoRnd = (seed = 0) => {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const rnd = pseudoRnd(seed);
|
|
15
|
+
return () => rnd.next().value || seed;
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
export const rnd = (seed = 0, min = 0, max = 100) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const range = Math.abs(max - min) + 1;
|
|
20
|
+
const prnd = getPseudoRnd(seed);
|
|
21
|
+
return () => {
|
|
22
|
+
seed = Math.abs(prnd()) % range;
|
|
23
|
+
return seed + min;
|
|
24
|
+
};
|
|
26
25
|
};
|
package/distFiles/range.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export const range = (start: number, stop: number, step = 1) =>
|
|
2
|
+
Array.from({ length: (stop - start) / step + 1 }, (_, i) => start + i * step);
|
package/distFiles/rectReady.ts
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
export const rectReady = async (
|
|
2
|
+
querySelector: string,
|
|
3
|
+
limit = 0,
|
|
4
|
+
): Promise<DOMRect> => {
|
|
5
|
+
const tryTimeout = 100;
|
|
6
|
+
let timeoutHandler = null;
|
|
7
|
+
let limitHandler = null;
|
|
8
|
+
return new Promise((ok, err) => {
|
|
9
|
+
const tryRect = () => {
|
|
10
|
+
const element = document.querySelector(querySelector);
|
|
11
|
+
if (!element) {
|
|
12
|
+
timeoutHandler = setTimeout(() => tryRect(), tryTimeout);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
const rect = element.getClientRects();
|
|
16
|
+
if (!rect || rect.length === 0) {
|
|
17
|
+
timeoutHandler = setTimeout(() => tryRect(), tryTimeout);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
if (limitHandler) clearTimeout(limitHandler);
|
|
21
|
+
ok(rect[0]);
|
|
22
|
+
};
|
|
23
|
+
if (limit > 0)
|
|
24
|
+
limitHandler = setTimeout(() => {
|
|
25
|
+
if (timeoutHandler) clearTimeout(timeoutHandler);
|
|
26
|
+
err("timeout");
|
|
27
|
+
}, limit);
|
|
28
|
+
tryRect();
|
|
29
|
+
});
|
|
27
30
|
};
|
package/distFiles/rnda.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
.map(_ => [_, randomGenerator()])
|
|
1
|
+
export const rnda = (a: any[], randomGenerator = Math.random) =>
|
|
2
|
+
a
|
|
3
|
+
.map((_) => [_, randomGenerator()])
|
|
4
4
|
.sort((w, e) => (w[1] == e[1] ? 0 : w[1] > e[1] ? 1 : -1))
|
|
5
|
-
.map(_ => _[0]);
|
|
5
|
+
.map((_) => _[0]);
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
export const runOncePerTime = (msec: number): ((fn: any) => void) => {
|
|
2
|
+
let lastDiff = 0;
|
|
3
|
+
let lastFunc = () => {};
|
|
4
|
+
return (fn: any) => {
|
|
5
|
+
lastFunc = fn;
|
|
6
|
+
const now = new Date().getTime();
|
|
7
|
+
if (now - lastDiff < msec) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
lastFunc();
|
|
11
|
+
lastDiff = now;
|
|
12
|
+
};
|
|
12
13
|
};
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
2
1
|
(async () => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
const review = async () => {
|
|
3
|
+
const cb = new Date().getTime();
|
|
4
|
+
const result = await fetch("/compdate.txt?cb=" + cb)
|
|
5
|
+
.then((_) => _.json())
|
|
6
|
+
.catch((_) => ({ reload: false }));
|
|
7
|
+
const { reload } = result as { reload: boolean };
|
|
8
|
+
if (reload) {
|
|
9
|
+
location.reload();
|
|
10
|
+
setTimeout(review, 618);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
setTimeout(review, 618 * 2);
|
|
14
|
+
};
|
|
15
|
+
review();
|
|
16
16
|
})();
|
|
17
|
-
|
|
18
|
-
|
package/distFiles/tkeron.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
export interface tkeronOptions {
|
|
3
2
|
type?: string;
|
|
4
3
|
value?: string;
|
|
@@ -48,12 +47,13 @@ export interface Component {
|
|
|
48
47
|
const enum event {
|
|
49
48
|
render,
|
|
50
49
|
append,
|
|
51
|
-
msg
|
|
50
|
+
msg,
|
|
52
51
|
}
|
|
53
52
|
const handlers: any = {};
|
|
54
53
|
const addHandler = (id: string, event: event, fn: (...args: any[]) => void) => {
|
|
55
54
|
if (typeof handlers[event] === "undefined") handlers[event] = {} as any;
|
|
56
|
-
if (typeof handlers[event][id] === "undefined")
|
|
55
|
+
if (typeof handlers[event][id] === "undefined")
|
|
56
|
+
handlers[event][id] = [] as any[];
|
|
57
57
|
handlers[event][id].push(fn);
|
|
58
58
|
};
|
|
59
59
|
const runHandlers = (id: string, event: event, ...args: any[]) => {
|
|
@@ -62,8 +62,10 @@ const runHandlers = (id: string, event: event, ...args: any[]) => {
|
|
|
62
62
|
handlers[event][id].forEach((fn: (...args: any[]) => void) => fn(...args));
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
const toHexString = (bytes: Uint8Array): string =>
|
|
66
|
-
|
|
65
|
+
const toHexString = (bytes: Uint8Array): string =>
|
|
66
|
+
bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
|
|
67
|
+
const rnds = (n: number): string =>
|
|
68
|
+
toHexString(crypto.getRandomValues(new Uint8Array(n))).slice(0, n);
|
|
67
69
|
|
|
68
70
|
const IDs: string[] = [];
|
|
69
71
|
const getID = (): string => {
|
|
@@ -75,23 +77,23 @@ const getID = (): string => {
|
|
|
75
77
|
return id;
|
|
76
78
|
};
|
|
77
79
|
|
|
78
|
-
export const tkeron = (
|
|
80
|
+
export const tkeron = (
|
|
81
|
+
opt?: tkeronOptions | string,
|
|
82
|
+
...classes: string[]
|
|
83
|
+
): Component => {
|
|
79
84
|
if (typeof opt === "string") {
|
|
80
85
|
classes.push(opt);
|
|
81
86
|
opt = { type: "div" };
|
|
82
87
|
}
|
|
83
88
|
if (!opt) opt = { type: "div" };
|
|
84
|
-
const valueProp: boolean = [
|
|
85
|
-
"input",
|
|
86
|
-
"textarea"
|
|
87
|
-
].some(n => {
|
|
89
|
+
const valueProp: boolean = ["input", "textarea"].some((n) => {
|
|
88
90
|
if ("type" in (opt as any)) return (opt as any).type === n;
|
|
89
91
|
});
|
|
90
92
|
let el = document.createElement(opt.type || "div");
|
|
91
93
|
const priv = {
|
|
92
94
|
parent: {} as Component | null,
|
|
93
95
|
childs: [] as Component[],
|
|
94
|
-
css: ""
|
|
96
|
+
css: "",
|
|
95
97
|
};
|
|
96
98
|
priv.parent = null;
|
|
97
99
|
const com: Component = {
|
|
@@ -108,7 +110,7 @@ export const tkeron = (opt?: tkeronOptions | string, ...classes: string[]): Comp
|
|
|
108
110
|
},
|
|
109
111
|
childs: priv.childs,
|
|
110
112
|
add: (...c: Component[]) => {
|
|
111
|
-
c.forEach(_ => {
|
|
113
|
+
c.forEach((_) => {
|
|
112
114
|
_._setParent(com);
|
|
113
115
|
priv.childs.push(_);
|
|
114
116
|
_.getHTMLElement((ele) => {
|
|
@@ -119,11 +121,11 @@ export const tkeron = (opt?: tkeronOptions | string, ...classes: string[]): Comp
|
|
|
119
121
|
},
|
|
120
122
|
remove: (c: Component) => {
|
|
121
123
|
c._setParent(null);
|
|
122
|
-
priv.childs = priv.childs.filter(_c => {
|
|
124
|
+
priv.childs = priv.childs.filter((_c) => {
|
|
123
125
|
if (_c.id === c.id) return false;
|
|
124
126
|
return true;
|
|
125
127
|
});
|
|
126
|
-
c.getHTMLElement(_el => {
|
|
128
|
+
c.getHTMLElement((_el) => {
|
|
127
129
|
el.removeChild(_el);
|
|
128
130
|
});
|
|
129
131
|
return com;
|
|
@@ -229,7 +231,7 @@ export const tkeron = (opt?: tkeronOptions | string, ...classes: string[]): Comp
|
|
|
229
231
|
Object.defineProperty(com, "attributes", {
|
|
230
232
|
get() {
|
|
231
233
|
return el.attributes;
|
|
232
|
-
}
|
|
234
|
+
},
|
|
233
235
|
});
|
|
234
236
|
Object.defineProperty(com, "value", {
|
|
235
237
|
get() {
|
|
@@ -245,23 +247,23 @@ export const tkeron = (opt?: tkeronOptions | string, ...classes: string[]): Comp
|
|
|
245
247
|
el.value = v;
|
|
246
248
|
return true;
|
|
247
249
|
}
|
|
248
|
-
priv.childs.forEach(c => c._setParent(null));
|
|
250
|
+
priv.childs.forEach((c) => c._setParent(null));
|
|
249
251
|
priv.childs.length = 0;
|
|
250
252
|
el.innerHTML = v;
|
|
251
253
|
return true;
|
|
252
|
-
}
|
|
254
|
+
},
|
|
253
255
|
});
|
|
254
256
|
Object.defineProperty(com, "classList", {
|
|
255
257
|
get() {
|
|
256
258
|
//@ts-ignore
|
|
257
259
|
return Array.from(el.classList);
|
|
258
|
-
}
|
|
260
|
+
},
|
|
259
261
|
});
|
|
260
262
|
|
|
261
263
|
if (typeof opt.value !== "undefined") com.setValue(opt.value);
|
|
262
264
|
|
|
263
265
|
if (classes.length) {
|
|
264
|
-
classes.forEach(c => {
|
|
266
|
+
classes.forEach((c) => {
|
|
265
267
|
com.addClass(c);
|
|
266
268
|
});
|
|
267
269
|
}
|
|
@@ -291,9 +293,11 @@ export interface scriptOptions {
|
|
|
291
293
|
globalFunctions?: CallableFunction[];
|
|
292
294
|
}
|
|
293
295
|
tkeron.script = (anonFunc: CallableFunction, options?: scriptOptions) => {
|
|
294
|
-
const { appendIn, runOnDOMContentLoaded, globalFunctions } =
|
|
296
|
+
const { appendIn, runOnDOMContentLoaded, globalFunctions } =
|
|
297
|
+
options || ({} as scriptOptions);
|
|
295
298
|
let value = `(${anonFunc.toString()})();`;
|
|
296
|
-
if (runOnDOMContentLoaded)
|
|
299
|
+
if (runOnDOMContentLoaded)
|
|
300
|
+
value = `document.addEventListener("DOMContentLoaded",(${anonFunc.toString()}));`;
|
|
297
301
|
|
|
298
302
|
if (globalFunctions) {
|
|
299
303
|
let functions = "";
|
|
@@ -312,6 +316,4 @@ tkeron.script = (anonFunc: CallableFunction, options?: scriptOptions) => {
|
|
|
312
316
|
tkeron({ type: "script", value }).appendIn(appendIn || "body");
|
|
313
317
|
};
|
|
314
318
|
|
|
315
|
-
|
|
316
319
|
export const version = "1.9.0";
|
|
317
|
-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tkeron",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"description": "Micro framework for developing web user interfaces with typescript.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tkeron": "dist/index.js",
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
"tk": "npm run build && node dist/index.js",
|
|
14
14
|
"test": "rm -rf dist && npm run build && jest --roots dist --detectOpenHandles --coverage --coverageReporters=\"json-summary\" --verbose ",
|
|
15
15
|
"coverage": "rm -rf dist && npm run build && jest --roots dist --detectOpenHandles --verbose --coverage ",
|
|
16
|
-
"cicd": "node dist/cicd.js"
|
|
16
|
+
"cicd": "node dist/cicd.js",
|
|
17
|
+
"lint": "prettier --write ."
|
|
17
18
|
},
|
|
18
19
|
"author": "tkeron",
|
|
19
20
|
"license": "MIT",
|
|
20
21
|
"dependencies": {
|
|
22
|
+
"@tkeron/commands": "^0.2.0",
|
|
21
23
|
"colorette": "^2.0.19",
|
|
22
|
-
"commander": "^9.4.1",
|
|
23
24
|
"esbuild": "^0.16.6",
|
|
24
25
|
"express": "^4.18.2",
|
|
25
26
|
"jsdom": "^20.0.3",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"@types/jest": "^29.2.4",
|
|
32
33
|
"@types/jsdom": "^20.0.1",
|
|
33
34
|
"jest": "^29.3.1",
|
|
35
|
+
"prettier": "^3.0.3",
|
|
34
36
|
"typescript": "^4.9.4"
|
|
35
37
|
},
|
|
36
38
|
"keywords": [
|
package/tkeron.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
2
|
+
"sourceDir": "front",
|
|
3
|
+
"outputDir": "web"
|
|
4
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"include": [
|
|
13
|
-
"src"
|
|
14
|
-
]
|
|
15
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "NodeNext",
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"declaration": true
|
|
8
|
+
},
|
|
9
|
+
"exclude": ["node_modules"],
|
|
10
|
+
"include": ["src"]
|
|
11
|
+
}
|