tkeron 3.7.1 → 4.0.0-alpha.1

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.
Files changed (113) hide show
  1. package/.github/workflows/npm_deploy.yml +29 -0
  2. package/bun.lock +38 -0
  3. package/changelog.md +19 -0
  4. package/examples/basic_build/src/index.html +13 -0
  5. package/examples/basic_build/src/index.ts +10 -0
  6. package/index.ts +18 -0
  7. package/package.json +15 -29
  8. package/readme.md +25 -51
  9. package/src/build.test.ts +45 -0
  10. package/src/build.ts +26 -0
  11. package/src/buildFile.ts +44 -0
  12. package/tkeron_library/index.ts +23 -0
  13. package/tsconfig.json +25 -7
  14. package/dist/base64.d.ts +0 -2
  15. package/dist/base64.js +0 -7
  16. package/dist/build.d.ts +0 -10
  17. package/dist/build.js +0 -138
  18. package/dist/buildFront.d.ts +0 -10
  19. package/dist/buildFront.js +0 -27
  20. package/dist/buildLoaders.d.ts +0 -14
  21. package/dist/buildLoaders.js +0 -24
  22. package/dist/bundleTs.d.ts +0 -1
  23. package/dist/bundleTs.js +0 -35
  24. package/dist/cicd.d.ts +0 -1
  25. package/dist/cicd.js +0 -12
  26. package/dist/cmdBuild.d.ts +0 -4
  27. package/dist/cmdBuild.js +0 -12
  28. package/dist/cmdDev.d.ts +0 -17
  29. package/dist/cmdDev.js +0 -76
  30. package/dist/cmdGenerate.d.ts +0 -4
  31. package/dist/cmdGenerate.js +0 -41
  32. package/dist/cmdInit.d.ts +0 -4
  33. package/dist/cmdInit.js +0 -28
  34. package/dist/copyDir.d.ts +0 -2
  35. package/dist/copyDir.js +0 -17
  36. package/dist/copyFile.d.ts +0 -8
  37. package/dist/copyFile.js +0 -27
  38. package/dist/createTsConfigFile.d.ts +0 -1
  39. package/dist/createTsConfigFile.js +0 -39
  40. package/dist/eventEmitter.d.ts +0 -5
  41. package/dist/eventEmitter.js +0 -29
  42. package/dist/fileExist.d.ts +0 -2
  43. package/dist/fileExist.js +0 -17
  44. package/dist/generateItems.d.ts +0 -11
  45. package/dist/generateItems.js +0 -16
  46. package/dist/getDocument.d.ts +0 -11
  47. package/dist/getDocument.js +0 -38
  48. package/dist/getFilesRecursive.d.ts +0 -9
  49. package/dist/getFilesRecursive.js +0 -57
  50. package/dist/getOptions.d.ts +0 -8
  51. package/dist/getOptions.js +0 -27
  52. package/dist/getType.d.ts +0 -1
  53. package/dist/getType.js +0 -5
  54. package/dist/getVersion.d.ts +0 -2
  55. package/dist/getVersion.js +0 -16
  56. package/dist/index.d.ts +0 -2
  57. package/dist/index.js +0 -5
  58. package/dist/injectCode.d.ts +0 -1
  59. package/dist/injectCode.js +0 -7
  60. package/dist/injectTsFile.d.ts +0 -8
  61. package/dist/injectTsFile.js +0 -22
  62. package/dist/jsDom/crypto.d.ts +0 -3
  63. package/dist/jsDom/crypto.js +0 -42
  64. package/dist/jsDom/errors.d.ts +0 -3
  65. package/dist/jsDom/errors.js +0 -30
  66. package/dist/jsDom/fetch.d.ts +0 -2
  67. package/dist/jsDom/fetch.js +0 -13
  68. package/dist/jsDom/joinScripts.d.ts +0 -1
  69. package/dist/jsDom/joinScripts.js +0 -25
  70. package/dist/jsDom/logs.d.ts +0 -1
  71. package/dist/jsDom/logs.js +0 -10
  72. package/dist/jsDom/writeLogElement.d.ts +0 -1
  73. package/dist/jsDom/writeLogElement.js +0 -50
  74. package/dist/libFiles.ts.d.ts +0 -1
  75. package/dist/libFiles.ts.js +0 -13
  76. package/dist/main.d.ts +0 -1
  77. package/dist/main.js +0 -62
  78. package/dist/mod.d.ts +0 -12
  79. package/dist/mod.js +0 -9
  80. package/dist/pathToUrlResource.d.ts +0 -4
  81. package/dist/pathToUrlResource.js +0 -11
  82. package/dist/random.d.ts +0 -3
  83. package/dist/random.js +0 -31
  84. package/dist/range.d.ts +0 -1
  85. package/dist/range.js +0 -5
  86. package/dist/readJsonFile.d.ts +0 -1
  87. package/dist/readJsonFile.js +0 -20
  88. package/dist/rectReady.d.ts +0 -1
  89. package/dist/rectReady.js +0 -33
  90. package/dist/rnd.d.ts +0 -2
  91. package/dist/rnd.js +0 -11
  92. package/dist/rnda.d.ts +0 -1
  93. package/dist/rnda.js +0 -8
  94. package/dist/runOncePerTime.d.ts +0 -1
  95. package/dist/runOncePerTime.js +0 -17
  96. package/dist/serializeDocument.d.ts +0 -1
  97. package/dist/serializeDocument.js +0 -5
  98. package/dist/simpleHotRestart.d.ts +0 -1
  99. package/dist/simpleHotRestart.js +0 -26
  100. package/dist/tk.d.ts +0 -2
  101. package/dist/tk.js +0 -5
  102. package/dist/wait.d.ts +0 -1
  103. package/dist/wait.js +0 -5
  104. package/distFiles/eventEmitter.ts +0 -28
  105. package/distFiles/getType.ts +0 -2
  106. package/distFiles/random.ts +0 -25
  107. package/distFiles/range.ts +0 -2
  108. package/distFiles/rectReady.ts +0 -30
  109. package/distFiles/rnda.ts +0 -5
  110. package/distFiles/runOncePerTime.ts +0 -13
  111. package/distFiles/simpleHotRestart.ts +0 -28
  112. package/jest.config.js +0 -8
  113. package/tkeron.json +0 -4
@@ -0,0 +1,29 @@
1
+ name: cli package
2
+ on:
3
+ push:
4
+ branches:
5
+ - master
6
+
7
+ jobs:
8
+ build-test-publish:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: actions/setup-node@v4.0.3
13
+ with:
14
+ node-version: 20.x
15
+ registry-url: "https://registry.npmjs.org/"
16
+
17
+ - uses: oven-sh/setup-bun@v2
18
+
19
+ - name: Install dependencies
20
+ run: bun i
21
+
22
+ - name: Run tests
23
+ run: bun test
24
+
25
+ - name: Publish to npm
26
+ run: npm publish --access public
27
+ env:
28
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
29
+
package/bun.lock ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "lockfileVersion": 1,
3
+ "workspaces": {
4
+ "": {
5
+ "name": "tkeron",
6
+ "dependencies": {
7
+ "@tkeron/commands": "0.3.1",
8
+ "@tkeron/tools": "^0.2.2",
9
+ },
10
+ "devDependencies": {
11
+ "@types/bun": "^1.3.1",
12
+ "prettier": "^3.6.2",
13
+ "typescript": "^5.9.3",
14
+ },
15
+ },
16
+ },
17
+ "packages": {
18
+ "@tkeron/commands": ["@tkeron/commands@0.3.1", "", { "peerDependencies": { "typescript": "^5.9.3" } }, "sha512-b7YpdpwVrq8dwnvztpFYCNhjYjiQhX5xix1XXL1Dvt2oHcWiZ3RnG/6yzH0woL3Vbc7shpRNfIexlxmtEkhnIQ=="],
19
+
20
+ "@tkeron/tools": ["@tkeron/tools@0.2.2", "", { "peerDependencies": { "typescript": "^5.7.3" } }, "sha512-DaS1bMiJnmrTJ1QBeYvI0CMDADPHArRj+bwI5FDp3ohgWrnXwK22vbDfqf4dyhqBUSGjdx5N7t/L2UZ8XLc1hg=="],
21
+
22
+ "@types/bun": ["@types/bun@1.3.1", "", { "dependencies": { "bun-types": "1.3.1" } }, "sha512-4jNMk2/K9YJtfqwoAa28c8wK+T7nvJFOjxI4h/7sORWcypRNxBpr+TPNaCfVWq70tLCJsqoFwcf0oI0JU/fvMQ=="],
23
+
24
+ "@types/node": ["@types/node@24.9.1", "", { "dependencies": { "undici-types": "~7.16.0" } }, "sha512-QoiaXANRkSXK6p0Duvt56W208du4P9Uye9hWLWgGMDTEoKPhuenzNcC4vGUmrNkiOKTlIrBoyNQYNpSwfEZXSg=="],
25
+
26
+ "@types/react": ["@types/react@19.2.2", "", { "dependencies": { "csstype": "^3.0.2" } }, "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA=="],
27
+
28
+ "bun-types": ["bun-types@1.3.1", "", { "dependencies": { "@types/node": "*" }, "peerDependencies": { "@types/react": "^19" } }, "sha512-NMrcy7smratanWJ2mMXdpatalovtxVggkj11bScuWuiOoXTiKIu2eVS1/7qbyI/4yHedtsn175n4Sm4JcdHLXw=="],
29
+
30
+ "csstype": ["csstype@3.1.3", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
31
+
32
+ "prettier": ["prettier@3.6.2", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-I7AIg5boAr5R0FFtJ6rCfD+LFsWHp81dolrFD8S79U9tb8Az2nGrJncnMSnys+bpQJfRUzqs9hnA81OAA3hCuQ=="],
33
+
34
+ "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
35
+
36
+ "undici-types": ["undici-types@7.16.0", "", {}, "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw=="],
37
+ }
38
+ }
package/changelog.md CHANGED
@@ -1,3 +1,22 @@
1
+ # v4.0.0-alpha.1
2
+
3
+ ## ⚠️ Alpha Release - Work in Progress
4
+
5
+ Complete rewrite from v3. Migration from Node.js to Bun runtime.
6
+ Only basic build functionality is available.
7
+
8
+ ## Changes
9
+ - Add `build` command with TypeScript bundling and minification
10
+ - Migration to Bun runtime (replacing Node.js)
11
+ - Add `@tkeron/tools` dependency
12
+ - Update `@tkeron/commands` to 0.3.1
13
+ - Update tsconfig with DOM types
14
+ - Include basic build example
15
+
16
+ # v3.8.0
17
+
18
+ - add addScript to send code to the web browser in pre rendered components
19
+
1
20
  # v3.7.1
2
21
 
3
22
  - add mp3 to loader files
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Document</title>
7
+ </head>
8
+ <body>
9
+ <h1>Clicks: 0</h1>
10
+ <button>Tap</button>
11
+ <script type="module" src="./index.ts"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,10 @@
1
+ // Simple click counter
2
+ let clickCount = 0;
3
+
4
+ const button = document.querySelector('button') as HTMLButtonElement;
5
+ const heading = document.querySelector('h1') as HTMLHeadingElement;
6
+
7
+ button.addEventListener('click', () => {
8
+ clickCount++;
9
+ heading.textContent = `Clicks: ${clickCount}`;
10
+ });
package/index.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { getCommands } from "@tkeron/commands";
2
+ import { build } from "./src/build";
3
+
4
+ getCommands()
5
+
6
+
7
+
8
+ .addCommand("build")
9
+ .addAlias("b")
10
+ .addDescription("Build the project")
11
+ .addPositionedArgument("sourceDir")
12
+ .addPositionedArgument("targetDir")
13
+ .setCallback(build)
14
+
15
+
16
+ .commands().start();
17
+
18
+
package/package.json CHANGED
@@ -1,39 +1,28 @@
1
1
  {
2
2
  "name": "tkeron",
3
- "version": "3.7.1",
4
- "description": "Micro framework for developing web user interfaces with typescript.",
3
+ "version": "4.0.0-alpha.1",
4
+ "description": "CLI tool and micro framework for developing web user interfaces with TypeScript.",
5
+ "type": "module",
5
6
  "bin": {
6
- "tkeron": "dist/index.js",
7
- "tk": "dist/tk.js"
7
+ "tkeron": "./index.ts",
8
+ "tk": "./index.ts"
8
9
  },
9
- "main": "dist/mod.js",
10
10
  "scripts": {
11
- "build": "tsc",
12
- "start": "node dist/index.js",
13
- "tk": "npm run build && node dist/index.js",
14
- "test": "jest ",
15
- "cicd": "node dist/cicd.js",
16
- "lint": "prettier --write ."
11
+ "start": "bun run index.ts",
12
+ "test": "bun test",
13
+ "lint": "prettier --write .",
14
+ "build_examples": "bun . build examples/basic_build/src"
17
15
  },
18
16
  "author": "tkeron",
19
17
  "license": "MIT",
20
18
  "dependencies": {
21
- "@tkeron/commands": "0.2.1",
22
- "colorette": "^2.0.19",
23
- "esbuild": "^0.25.0",
24
- "express": "^4.21.1",
25
- "jsdom": "^25.0.1",
26
- "node-watch": "^0.7.3",
27
- "rxjs": "^7.6.0"
19
+ "@tkeron/commands": "0.3.1",
20
+ "@tkeron/tools": "^0.2.2"
28
21
  },
29
22
  "devDependencies": {
30
- "@types/express": "^5.0.0",
31
- "@types/jest": "^29.2.4",
32
- "@types/jsdom": "^21.1.7",
33
- "jest": "^29.3.1",
34
- "prettier": "^3.4.1",
35
- "ts-jest": "^29.2.5",
36
- "typescript": "5.7.2"
23
+ "@types/bun": "^1.3.1",
24
+ "prettier": "^3.6.2",
25
+ "typescript": "^5.9.3"
37
26
  },
38
27
  "keywords": [
39
28
  "cli",
@@ -45,8 +34,5 @@
45
34
  ],
46
35
  "repository": {
47
36
  "url": "git@github.com:tkeron/tkeron.git"
48
- },
49
- "engines": {
50
- "node": ">=18"
51
37
  }
52
- }
38
+ }
package/readme.md CHANGED
@@ -1,69 +1,43 @@
1
1
  # tkeron
2
2
 
3
- **tkeron** is a lightweight microframework designed to streamline web development with TypeScript. Its key features include:
3
+ ⚠️ **v4.0.0-alpha.1 - Early Alpha Release**
4
4
 
5
- - **CLI for project initialization, page, and component creation.**
6
- - **Simple library for component management**, using functions instead of classes.
7
- - **Exclusive use of TypeScript, HTML, and CSS**, without additional configurations or new syntax.
8
- - **'No magic' philosophy**, where behavior is always explicit and controlled by the developer.
5
+ This is a complete rewrite of tkeron, migrating from Node.js to Bun runtime.
6
+ **Currently only basic build functionality is available.** More features coming soon.
9
7
 
10
- ## Main Features
8
+ ---
11
9
 
12
- - **Zero Configuration:** Start developing without any additional setup.
13
- - **TypeScript Based:** Leverage language features without learning new syntax.
14
- - **Simplicity:** Easy to understand, focusing on clarity and minimal functionality.
15
- - **Pre-rendering:** Built-in support for static content.
16
- - **Hot Reloading:** Real-time changes during development with the `tk dev` command.
10
+ **tkeron** is a lightweight microframework for web development with TypeScript, focused on:
17
11
 
18
- ## Installation
19
-
20
- Install **tkeron** globally using npm:
12
+ - **Simplicity:** Exclusive use of TypeScript, HTML, and CSS, without additional configurations or new syntax.
13
+ - **'No magic' philosophy:** Behavior is always explicit and controlled by the developer.
14
+ - **Bun-powered:** Fast builds and modern tooling.
21
15
 
22
- ```bash
23
- npm i -g tkeron
24
- ```
16
+ ## What's Available Now (v4 Alpha)
25
17
 
26
- ## Usage
18
+ - ✅ **Build command:** Bundle TypeScript and process HTML files
19
+ ```bash
20
+ tk build <sourceDir> <targetDir>
21
+ ```
27
22
 
28
- Here are some basic examples of how to use the tkeron CLI:
23
+ ## What's Coming
29
24
 
30
- - **Initialize a new project:**
25
+ - 🚧 Project initialization (`tk init`)
26
+ - 🚧 Page and component generators
27
+ - 🚧 Dev server with hot reloading
28
+ - 🚧 Pre-rendering capabilities
29
+ - 🚧 Component management library
31
30
 
32
- ```bash
33
- tk init
34
- ```
31
+ ## Installation
35
32
 
36
- - **Create a new page:**
33
+ Install **tkeron** globally using npm:
37
34
 
38
35
  ```bash
39
- tk g p <name>
36
+ npm i -g tkeron
40
37
  ```
41
38
 
42
- Example: `tk g p index` would create an initial page.
43
-
44
- **Each page generates the following files:**
45
-
46
- - **.html** for the page structure.
47
- - **.css** for styling.
48
- - **.page.ts** for client-side logic.
49
- - **.back.ts** for server-side pre-rendering.
50
-
51
- ## Requirements
52
-
53
- - Node.js (currently required).
54
- - Future plans for migrate to Bun.
55
-
56
- ## Differentiators
57
-
58
- **tkeron** stands out for its focus on simplicity, eliminating complex setups and allowing developers to concentrate solely on coding.
59
-
60
- ## Contributions
61
-
62
- Contributions are welcome! Developers can open issues or submit pull requests at [GitHub](https://github.com/tkeron/tkeron).
63
-
64
- ## Current Status
39
+ **Requirements:** Bun runtime (Node.js support coming later)
65
40
 
66
- The project is actively being developed. Roadmap details include:
41
+ ## Example
67
42
 
68
- - Future integration of its own DOM package.
69
- - Full compatibility with Bun.
43
+ See the `examples/basic_build` directory for a working example.
@@ -0,0 +1,45 @@
1
+ import { describe, test, expect, afterAll } from "bun:test";
2
+ import { build } from "./build";
3
+ import { rmSync, existsSync, mkdirSync, writeFileSync, readFileSync } from "fs";
4
+ import { join } from "path";
5
+ import { tmpdir } from "os";
6
+
7
+ describe("build", () => {
8
+ const TEST_DIR = join(tmpdir(), `tkeron-test-${Date.now()}`);
9
+ const TEST_SRC = join(TEST_DIR, "src");
10
+ const TEST_OUT = join(TEST_DIR, "webout");
11
+
12
+ afterAll(() => {
13
+ if (existsSync(TEST_DIR)) {
14
+ rmSync(TEST_DIR, { recursive: true, force: true });
15
+ }
16
+ });
17
+
18
+ test("should build HTML with TypeScript and inject bundled script", async () => {
19
+ mkdirSync(TEST_SRC, { recursive: true });
20
+ const htmlContent = `<!DOCTYPE html>
21
+ <html>
22
+ <head><title>Test</title></head>
23
+ <body>
24
+ <h1>Test</h1>
25
+ <script type="module" src="./index.ts"></script>
26
+ </body>
27
+ </html>`;
28
+
29
+ const tsContent = `const message: string = "hello"; console.log(message);`;
30
+
31
+ writeFileSync(join(TEST_SRC, "index.html"), htmlContent);
32
+ writeFileSync(join(TEST_SRC, "index.ts"), tsContent);
33
+
34
+ await build({
35
+ sourceDir: TEST_SRC,
36
+ targetDir: TEST_OUT,
37
+ });
38
+
39
+ expect(existsSync(join(TEST_OUT, "index.html"))).toBe(true);
40
+ expect(existsSync(join(TEST_OUT, "index.js"))).toBe(true);
41
+
42
+ const outputHtml = readFileSync(join(TEST_OUT, "index.html"), "utf-8");
43
+ expect(outputHtml).toContain("index.js");
44
+ });
45
+ });
package/src/build.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { getPaths } from "@tkeron/tools";
2
+ import { resolve, join, dirname } from "path";
3
+ import { buildFile } from "./buildFile";
4
+
5
+ export interface BuildOptions {
6
+ sourceDir?: string;
7
+ targetDir?: string;
8
+ }
9
+ export const build = async (options: BuildOptions) => {
10
+
11
+ const source = await resolve(options.sourceDir || "websrc");
12
+ const target = options.targetDir
13
+ ? await resolve(options.targetDir)
14
+ : await resolve(dirname(source), "webout");
15
+
16
+ const htmlFiles = await getPaths(source, "**/*.html", "no", true);
17
+
18
+ const files = await buildFile(htmlFiles, source);
19
+
20
+ for (const a of files?.artifacts || []) {
21
+ await Bun.write(join(target, a.pathR), a.artifact, { createPath: true });
22
+ }
23
+
24
+ };
25
+
26
+
@@ -0,0 +1,44 @@
1
+ import { normalize } from "path";
2
+
3
+ export const buildFile = async (filePaths: string[], root: string) => {
4
+ const { outputs, success } = await Bun.build({
5
+ entrypoints: filePaths,
6
+ minify: true,
7
+ splitting: false,
8
+ target: "browser",
9
+ root,
10
+ naming: {
11
+ asset: "[dir]/[name].[ext]",
12
+ chunk: "[dir]/[name].[ext]",
13
+ entry: "[dir]/[name].[ext]",
14
+ },
15
+ });
16
+
17
+ if (!success) return;
18
+
19
+ const artifacts = await Promise.all(
20
+ outputs?.map(async (artifact, index) => {
21
+ const path = artifact.path;
22
+ const pathR = normalize(artifact.path);
23
+ const hash = artifact.hash;
24
+ const kind = artifact.kind;
25
+ const loader = artifact.loader;
26
+ const type = artifact.type;
27
+ const sourcemap = await artifact.sourcemap?.text();
28
+
29
+ return {
30
+ path,
31
+ pathR,
32
+ hash,
33
+ index,
34
+ kind,
35
+ loader,
36
+ type,
37
+ sourcemap,
38
+ artifact,
39
+ };
40
+ })
41
+ );
42
+
43
+ return { artifacts };
44
+ };
@@ -9,6 +9,29 @@ export const addCss = (css: string) => {
9
9
  tk({ tag: "style" }).setHtml(css).appendIn.head;
10
10
  };
11
11
 
12
+ /**
13
+ *
14
+ * @param fn any sync or async function that will be called in web browser
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * const div = tk.addClass("my-component");
19
+ * // I want this component to change its background to orange when user clicks on it.
20
+ * const setBgOrange = () => {
21
+ * const div = tk.from(".my-component");
22
+ * div.htmlElement.addEventListener("click", () => {
23
+ * div.htmlElement.style.background = "#f60";
24
+ * });
25
+ * };
26
+ * addScript(setBgOrange);
27
+ * ```
28
+ */
29
+ export const addScript = (fn: CallableFunction) => {
30
+ tk("script").setHtml(`
31
+ (${fn})();
32
+ `).appendIn.body;
33
+ };
34
+
12
35
  export const addCssReset = () => {
13
36
  addCss(`
14
37
  * {
package/tsconfig.json CHANGED
@@ -1,11 +1,29 @@
1
1
  {
2
2
  "compilerOptions": {
3
- "module": "NodeNext",
4
- "outDir": "dist",
3
+ // Environment setup & latest features
4
+ "lib": ["ESNext", "ES2020", "DOM"],
5
5
  "target": "ESNext",
6
- "esModuleInterop": true,
7
- "declaration": true
8
- },
9
- "exclude": ["node_modules"],
10
- "include": ["src"]
6
+ "module": "Preserve",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ // Bundler mode
12
+ "moduleResolution": "bundler",
13
+ "allowImportingTsExtensions": true,
14
+ "verbatimModuleSyntax": true,
15
+ "noEmit": true,
16
+
17
+ // Best practices
18
+ "strict": true,
19
+ "skipLibCheck": true,
20
+ "noFallthroughCasesInSwitch": true,
21
+ "noUncheckedIndexedAccess": true,
22
+ "noImplicitOverride": true,
23
+
24
+ // Some stricter flags (disabled by default)
25
+ "noUnusedLocals": false,
26
+ "noUnusedParameters": false,
27
+ "noPropertyAccessFromIndexSignature": false
28
+ }
11
29
  }
package/dist/base64.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare const fromBase64: (base64str: string) => string;
2
- export declare const toBase64: (base64str: string) => string;
package/dist/base64.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toBase64 = exports.fromBase64 = void 0;
4
- const fromBase64 = (base64str) => Buffer.from(base64str, "base64").toString("utf-8");
5
- exports.fromBase64 = fromBase64;
6
- const toBase64 = (base64str) => Buffer.from(base64str, "utf-8").toString("base64");
7
- exports.toBase64 = toBase64;
package/dist/build.d.ts DELETED
@@ -1,10 +0,0 @@
1
- export interface buildArguments {
2
- sourceDir: string;
3
- outputDir: string;
4
- hotRestart?: boolean;
5
- ignoreConsoleLogs?: boolean;
6
- ignoreErrors?: boolean;
7
- minify?: boolean;
8
- }
9
- export declare const build: (args: buildArguments, minify?: boolean) => Promise<void>;
10
- export declare const tryBuildFront: (name: string, html: string, outHtmlFile: string, hotRestart: boolean, outTsFile: string, scriptId: string, tsFile: string, minify?: boolean) => Promise<[boolean, string, CallableFunction]>;
package/dist/build.js DELETED
@@ -1,138 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tryBuildFront = exports.build = void 0;
4
- const path_1 = require("path");
5
- const promises_1 = require("fs/promises");
6
- const fileExist_1 = require("./fileExist");
7
- const generateItems_1 = require("./generateItems");
8
- const getDocument_1 = require("./getDocument");
9
- const getFilesRecursive_1 = require("./getFilesRecursive");
10
- const getOptions_1 = require("./getOptions");
11
- const injectTsFile_1 = require("./injectTsFile");
12
- const rnd_1 = require("./rnd");
13
- const buildFront_1 = require("./buildFront");
14
- const serializeDocument_1 = require("./serializeDocument");
15
- const backRegex = /\.back\.ts$/;
16
- const htmlPageRegex = /\.page\.html$/;
17
- const build = async (args, minify = true) => {
18
- const { hotRestart, ignoreConsoleLogs, ignoreErrors } = args;
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)))
24
- throw "directory does not exist";
25
- await (0, promises_1.mkdir)(outputDir, { recursive: true });
26
- const pagesReady = [];
27
- const backFiles = [...(0, getFilesRecursive_1.getFilesRecursive)(sourceDir, { pattern: backRegex })];
28
- const buildFrontPromises = [];
29
- for (const file of backFiles) {
30
- const name = (0, path_1.basename)(file).replace(backRegex, "");
31
- const htmlFile = file.replace(backRegex, ".page.html");
32
- pagesReady.push(htmlFile);
33
- const htmlExist = await (0, fileExist_1.fileExists)(htmlFile);
34
- let html = htmlExist
35
- ? await (0, promises_1.readFile)(htmlFile, { encoding: "utf-8" })
36
- : (0, generateItems_1.pageItem)(name).html;
37
- const scriptId = "tmp" + (0, rnd_1.rnds)(25);
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
- });
49
- if (ignoreErrors && jsDomErrors.length)
50
- jsDomErrors.forEach((_) => console["log"](`page ${name} error: `, _.detail || _));
51
- await new Promise((ok) => {
52
- const handle = setTimeout(() => {
53
- console["log"](`time up: ${name}`);
54
- ok(0);
55
- }, 6e3);
56
- document.addEventListener("load", () => {
57
- clearTimeout(handle);
58
- ok(0);
59
- });
60
- });
61
- const scriptNode = document.querySelector(`#${scriptId}`);
62
- if (scriptNode)
63
- document.head.removeChild(scriptNode);
64
- html = (0, serializeDocument_1.serializeDocument)(document);
65
- window.close();
66
- const tsFile = htmlFile.replace(htmlPageRegex, ".page.ts");
67
- const outHtmlFile = file
68
- .replace(sourceDir, outputDir)
69
- .replace(backRegex, ".html");
70
- const outTsFile = file
71
- .replace(sourceDir, outputDir)
72
- .replace(backRegex, ".js");
73
- html = html.replace(/\/\*tkeron\-front\-script/g, "");
74
- html = html.replace(/tkeron\-front\-script\*\//g, "");
75
- buildFrontPromises.push((0, exports.tryBuildFront)(name, html, outHtmlFile, hotRestart, outTsFile, "tkeron_page_js", tsFile, minify));
76
- }
77
- const htmlFiles = [
78
- ...(0, getFilesRecursive_1.getFilesRecursive)(sourceDir, { pattern: htmlPageRegex }),
79
- ];
80
- for (const file of htmlFiles) {
81
- const name = (0, path_1.basename)(file).replace(htmlPageRegex, "");
82
- if (pagesReady.includes(file))
83
- continue;
84
- let html = await (0, promises_1.readFile)(file, { encoding: "utf-8" });
85
- const outHtmlFile = file
86
- .replace(sourceDir, outputDir)
87
- .replace(htmlPageRegex, ".html");
88
- const outTsFile = file
89
- .replace(sourceDir, outputDir)
90
- .replace(htmlPageRegex, ".html");
91
- const tsFile = file.replace(htmlPageRegex, ".page.ts");
92
- html = html.replace(/\/\*tkeron\-front\-script/g, "");
93
- html = html.replace(/tkeron\-front\-script\*\//g, "");
94
- buildFrontPromises.push((0, exports.tryBuildFront)(name, html, outHtmlFile, hotRestart, outTsFile, "tkeron_page_js", tsFile, minify));
95
- }
96
- const results = await Promise.all(buildFrontPromises);
97
- for (const result of results) {
98
- const [ok, name, retry] = result;
99
- if (ok)
100
- continue;
101
- console["log"](`\nretry build ${name}...`);
102
- await new Promise((done) => setTimeout(done, 300));
103
- const [done] = await retry();
104
- if (!done)
105
- throw `error building ${name}, try build command again...`;
106
- }
107
- const compdate = new Date().getTime().toString();
108
- const compdateDir = (0, path_1.join)(outputDir, "compdate.txt");
109
- await (0, promises_1.writeFile)(compdateDir, compdate, { encoding: "utf-8" });
110
- console["log"]("\nall site built");
111
- };
112
- exports.build = build;
113
- const tryBuildFront = async (name, html, outHtmlFile, hotRestart, outTsFile, scriptId, tsFile, minify = true) => {
114
- return new Promise(async (ok) => {
115
- try {
116
- await (0, buildFront_1.buildFront)({
117
- html,
118
- outHtmlFile,
119
- hotRestart,
120
- outTsFile,
121
- scriptId: "tkeron_page_js",
122
- tsFile,
123
- minify,
124
- });
125
- console["log"](`site ${name} built`);
126
- ok([true, name, async () => { }]);
127
- }
128
- catch (_) {
129
- console["log"](`error building site ${name}: `, _);
130
- ok([
131
- false,
132
- name,
133
- () => (0, exports.tryBuildFront)(name, html, outHtmlFile, hotRestart, outTsFile, scriptId, tsFile),
134
- ]);
135
- }
136
- });
137
- };
138
- exports.tryBuildFront = tryBuildFront;
@@ -1,10 +0,0 @@
1
- export interface buildFrontOptions {
2
- html: string;
3
- tsFile: string;
4
- outTsFile: string;
5
- outHtmlFile: string;
6
- hotRestart?: boolean;
7
- scriptId: string;
8
- minify?: boolean;
9
- }
10
- export declare const buildFront: (options: buildFrontOptions) => Promise<string>;