kimu-core 0.4.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 (146) hide show
  1. package/.editorconfig +30 -0
  2. package/.gitattributes +11 -0
  3. package/.github/FUNDING.yml +8 -0
  4. package/.github/copilot-instructions.md +103 -0
  5. package/.github/kimu-copilot-instructions.md +3779 -0
  6. package/.github/workflows/deploy-demo.yml +39 -0
  7. package/AUTHORS.md +20 -0
  8. package/CHANGELOG.md +20 -0
  9. package/CODE_GUIDELINES.md +165 -0
  10. package/CODE_OF_CONDUCT.md +47 -0
  11. package/CONTRIBUTING.md +62 -0
  12. package/FUNDING.md +31 -0
  13. package/ISSUE_GUIDELINES.md +74 -0
  14. package/LICENSE +17 -0
  15. package/LICENSE.it.md +17 -0
  16. package/MPL-2.0.txt +373 -0
  17. package/NOTICE +65 -0
  18. package/README-KIMU.md +40 -0
  19. package/README.it.md +208 -0
  20. package/README.md +266 -0
  21. package/SECURITY.md +64 -0
  22. package/docs/get-started-en.md +207 -0
  23. package/docs/images/icon.svg +64 -0
  24. package/docs/images/logo_kimu.png +0 -0
  25. package/docs/index.md +29 -0
  26. package/env/dev.config.json +6 -0
  27. package/env/local.config.json +6 -0
  28. package/env/prod.config.json +6 -0
  29. package/env/staging.config.json +6 -0
  30. package/env/test.config.json +4 -0
  31. package/icon.svg +10 -0
  32. package/logo_kimu.png +0 -0
  33. package/package.json +79 -0
  34. package/public/favicon.svg +64 -0
  35. package/public/logo_kimu.svg +1 -0
  36. package/scripts/build-all-config.js +59 -0
  37. package/scripts/build-all-core.js +65 -0
  38. package/scripts/build-all-extensions.js +64 -0
  39. package/scripts/build-all-modules.js +99 -0
  40. package/scripts/build-extension.js +60 -0
  41. package/scripts/clear-kimu-build.js +31 -0
  42. package/scripts/generate-kimu-build-config.js +79 -0
  43. package/scripts/install-module.js +162 -0
  44. package/scripts/list-modules.js +109 -0
  45. package/scripts/minify-css-assets.js +82 -0
  46. package/scripts/remove-module.js +122 -0
  47. package/scripts/utils/fix-imports.js +85 -0
  48. package/src/assets/index.css +43 -0
  49. package/src/assets/kimu-style.css +84 -0
  50. package/src/assets/style.css +116 -0
  51. package/src/config/kimu-base-config.json +5 -0
  52. package/src/core/index.ts +47 -0
  53. package/src/core/kimu-app.ts +76 -0
  54. package/src/core/kimu-asset-manager.ts +167 -0
  55. package/src/core/kimu-component-element.ts +325 -0
  56. package/src/core/kimu-component.ts +33 -0
  57. package/src/core/kimu-engine.ts +188 -0
  58. package/src/core/kimu-extension-manager.ts +281 -0
  59. package/src/core/kimu-global-styles.ts +136 -0
  60. package/src/core/kimu-module-manager.ts +69 -0
  61. package/src/core/kimu-module.ts +21 -0
  62. package/src/core/kimu-path-config.ts +127 -0
  63. package/src/core/kimu-reactive.ts +196 -0
  64. package/src/core/kimu-render.ts +91 -0
  65. package/src/core/kimu-store.ts +147 -0
  66. package/src/core/kimu-types.ts +65 -0
  67. package/src/extensions/.gitkeep +0 -0
  68. package/src/extensions/extensions-manifest.json +13 -0
  69. package/src/extensions/kimu-home/component.ts +80 -0
  70. package/src/extensions/kimu-home/lang/en.json +5 -0
  71. package/src/extensions/kimu-home/lang/it.json +5 -0
  72. package/src/extensions/kimu-home/style.css +61 -0
  73. package/src/extensions/kimu-home/view.html +51 -0
  74. package/src/index.html +26 -0
  75. package/src/main.ts +68 -0
  76. package/src/modules/.gitkeep +0 -0
  77. package/src/modules/README.md +79 -0
  78. package/src/modules/i18n/README.it.md +63 -0
  79. package/src/modules/i18n/README.md +63 -0
  80. package/src/modules/i18n/kimu-global-lang.ts +26 -0
  81. package/src/modules/i18n/kimu-i18n-service.ts +108 -0
  82. package/src/modules/i18n/manifest.json +22 -0
  83. package/src/modules/i18n/module.ts +39 -0
  84. package/src/modules/modules-manifest.json +12 -0
  85. package/src/modules-repository/README.md +108 -0
  86. package/src/modules-repository/api-axios/CHANGELOG.md +48 -0
  87. package/src/modules-repository/api-axios/QUICK-REFERENCE.md +178 -0
  88. package/src/modules-repository/api-axios/README.md +304 -0
  89. package/src/modules-repository/api-axios/api-axios-service.ts +355 -0
  90. package/src/modules-repository/api-axios/examples.ts +293 -0
  91. package/src/modules-repository/api-axios/index.ts +19 -0
  92. package/src/modules-repository/api-axios/interfaces.ts +71 -0
  93. package/src/modules-repository/api-axios/module.ts +41 -0
  94. package/src/modules-repository/api-core/CHANGELOG.md +42 -0
  95. package/src/modules-repository/api-core/QUICK-REFERENCE.md +192 -0
  96. package/src/modules-repository/api-core/README.md +435 -0
  97. package/src/modules-repository/api-core/api-core-service.ts +289 -0
  98. package/src/modules-repository/api-core/examples.ts +432 -0
  99. package/src/modules-repository/api-core/index.ts +8 -0
  100. package/src/modules-repository/api-core/interfaces.ts +83 -0
  101. package/src/modules-repository/api-core/module.ts +30 -0
  102. package/src/modules-repository/event-bus/README.md +273 -0
  103. package/src/modules-repository/event-bus/event-bus-service.ts +176 -0
  104. package/src/modules-repository/event-bus/module.ts +30 -0
  105. package/src/modules-repository/i18n/README.it.md +63 -0
  106. package/src/modules-repository/i18n/README.md +63 -0
  107. package/src/modules-repository/i18n/kimu-global-lang.ts +26 -0
  108. package/src/modules-repository/i18n/kimu-i18n-service.ts +108 -0
  109. package/src/modules-repository/i18n/manifest.json +22 -0
  110. package/src/modules-repository/i18n/module.ts +39 -0
  111. package/src/modules-repository/notification/README.md +423 -0
  112. package/src/modules-repository/notification/module.ts +30 -0
  113. package/src/modules-repository/notification/notification-service.ts +436 -0
  114. package/src/modules-repository/router/README.it.md +39 -0
  115. package/src/modules-repository/router/README.md +39 -0
  116. package/src/modules-repository/router/manifest.json +21 -0
  117. package/src/modules-repository/router/module.ts +23 -0
  118. package/src/modules-repository/router/router.ts +144 -0
  119. package/src/modules-repository/state/README.md +409 -0
  120. package/src/modules-repository/state/module.ts +30 -0
  121. package/src/modules-repository/state/state-service.ts +296 -0
  122. package/src/modules-repository/theme/README.md +267 -0
  123. package/src/modules-repository/theme/module.ts +30 -0
  124. package/src/modules-repository/theme/pre-build.js +40 -0
  125. package/src/modules-repository/theme/theme-service.ts +389 -0
  126. package/src/modules-repository/theme/themes/theme-cherry-blossom.css +78 -0
  127. package/src/modules-repository/theme/themes/theme-cozy.css +111 -0
  128. package/src/modules-repository/theme/themes/theme-cyberpunk.css +150 -0
  129. package/src/modules-repository/theme/themes/theme-dark.css +79 -0
  130. package/src/modules-repository/theme/themes/theme-forest.css +171 -0
  131. package/src/modules-repository/theme/themes/theme-gold.css +100 -0
  132. package/src/modules-repository/theme/themes/theme-high-contrast.css +126 -0
  133. package/src/modules-repository/theme/themes/theme-lava.css +101 -0
  134. package/src/modules-repository/theme/themes/theme-lavender.css +90 -0
  135. package/src/modules-repository/theme/themes/theme-light.css +79 -0
  136. package/src/modules-repository/theme/themes/theme-matrix.css +103 -0
  137. package/src/modules-repository/theme/themes/theme-midnight.css +81 -0
  138. package/src/modules-repository/theme/themes/theme-nord.css +94 -0
  139. package/src/modules-repository/theme/themes/theme-ocean.css +84 -0
  140. package/src/modules-repository/theme/themes/theme-retro80s.css +343 -0
  141. package/src/modules-repository/theme/themes/theme-sunset.css +62 -0
  142. package/src/modules-repository/theme/themes-config.d.ts +27 -0
  143. package/src/modules-repository/theme/themes-config.json +213 -0
  144. package/src/vite-env.d.ts +1 -0
  145. package/tsconfig.json +33 -0
  146. package/vite.config.ts +99 -0
package/package.json ADDED
@@ -0,0 +1,79 @@
1
+ {
2
+ "name": "kimu-core",
3
+ "version": "0.4.1",
4
+ "private": false,
5
+ "type": "module",
6
+ "license": "MPL-2.0",
7
+ "description": "KIMU core framework - Keep It Minimal UI Framework",
8
+ "author": {
9
+ "name": "Marco Di Pasquale",
10
+ "email": "info@unicoverso.com",
11
+ "url": "https://unicoverso.com"
12
+ },
13
+ "homepage": "https://unicoverso.com/kimu",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/unicoverso/kimu-core.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/unicoverso/kimu-core/issues"
20
+ },
21
+ "keywords": [
22
+ "web-components",
23
+ "ui-framework",
24
+ "modular",
25
+ "frontend",
26
+ "minimal",
27
+ "declarative",
28
+ "kiosk",
29
+ "unicoVerso",
30
+ "KIMU"
31
+ ],
32
+ "scripts": {
33
+ "start": "vite",
34
+ "dev": "vite",
35
+ "vite": "vite",
36
+ "preview": "vite preview",
37
+ "build": "npm run build:compile && npm run build:bundle && npm run build:post",
38
+ "build:dev": "npm run generate-config:dev && npm run build:compile && npm run build:bundle && npm run build:post",
39
+ "build:local": "npm run generate-config:local && npm run build:compile && npm run build:bundle && npm run build:post",
40
+ "build:prod": "npm run generate-config:prod && npm run build:compile && npm run build:bundle && npm run build:post",
41
+ "build:compile": "tsc && npm run generate-config:dev",
42
+ "build:bundle": "vite build && npm run minify:css",
43
+ "build:post": "npm run build:all-config && npm run build:all-core && npm run build:all-modules && npm run build:all-ext",
44
+ "generate-config": "node scripts/generate-kimu-build-config.js dev",
45
+ "generate-config:dev": "node scripts/generate-kimu-build-config.js dev",
46
+ "generate-config:local": "node scripts/generate-kimu-build-config.js local",
47
+ "generate-config:prod": "node scripts/generate-kimu-build-config.js prod",
48
+ "clear:build": "node scripts/clear-kimu-build.js",
49
+ "minify:css": "node scripts/minify-css-assets.js",
50
+ "build:ext": "node scripts/build-extension.js",
51
+ "build:all-ext": "node scripts/build-all-extensions.js",
52
+ "build:all-config": "node scripts/build-all-config.js",
53
+ "build:all-core": "node scripts/build-all-core.js",
54
+ "build:all-modules": "node scripts/build-all-modules.js",
55
+ "install:module": "node scripts/install-module.js",
56
+ "remove:module": "node scripts/remove-module.js",
57
+ "list:modules": "node scripts/list-modules.js",
58
+ "pack": "npm pack",
59
+ "pack:dry": "npm pack --dry-run",
60
+ "prepack": "npm run clear:build",
61
+ "postpack": "echo 'Package created successfully! Check kimu-core-*.tgz'"
62
+ },
63
+ "engines": {
64
+ "node": ">=18.0.0",
65
+ "npm": ">=9.0.0"
66
+ },
67
+ "dependencies": {
68
+ "axios": "^1.13.1",
69
+ "idb": "^8.0.2",
70
+ "lit": "^3.2.1"
71
+ },
72
+ "devDependencies": {
73
+ "esbuild": "^0.25.2",
74
+ "path": "^0.12.7",
75
+ "rollup-plugin-copy": "^3.5.0",
76
+ "typescript": "^5.8.3",
77
+ "vite": "^6.2.0"
78
+ }
79
+ }
@@ -0,0 +1,64 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ id="Livello_2"
4
+ viewBox="0 0 128 128"
5
+ version="1.1"
6
+ sodipodi:docname="kimu-icon-128x128.svg"
7
+ width="128"
8
+ height="128"
9
+ inkscape:version="1.4 (e7c3feb1, 2024-10-09)"
10
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
11
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
12
+ xmlns="http://www.w3.org/2000/svg"
13
+ xmlns:svg="http://www.w3.org/2000/svg">
14
+ <sodipodi:namedview
15
+ id="namedview4"
16
+ pagecolor="#ffffff"
17
+ bordercolor="#000000"
18
+ borderopacity="0.25"
19
+ inkscape:showpageshadow="2"
20
+ inkscape:pageopacity="0.0"
21
+ inkscape:pagecheckerboard="0"
22
+ inkscape:deskcolor="#d1d1d1"
23
+ inkscape:zoom="1.5142353"
24
+ inkscape:cx="124.15507"
25
+ inkscape:cy="86.182112"
26
+ inkscape:window-width="1440"
27
+ inkscape:window-height="872"
28
+ inkscape:window-x="0"
29
+ inkscape:window-y="28"
30
+ inkscape:window-maximized="0"
31
+ inkscape:current-layer="Livello_2" />
32
+ <defs
33
+ id="defs1">
34
+ <style
35
+ id="style1">.cls-1{fill:#f45e32;}.cls-2{fill:#fff463;}.cls-3{fill:#88d1e2;}.cls-4{fill:#91d292;}</style>
36
+ </defs>
37
+ <g
38
+ id="g4"
39
+ transform="translate(0,-0.83295207)">
40
+ <g
41
+ id="Girandola"
42
+ transform="matrix(0.91533181,0,0,0.91533181,-1.552e-7,14)">
43
+ <g
44
+ id="Aste">
45
+ <path
46
+ class="cls-3"
47
+ d="m 57.47,111.07 c 18.74,0 33.94,-15.19 33.94,-33.94 0,-9.65 -4.03,-18.36 -10.49,-24.54 L 47.95,109.7 c 3.02,0.88 6.22,1.36 9.53,1.36 z"
48
+ id="path1" />
49
+ <path
50
+ class="cls-1"
51
+ d="M 82.48,0 C 63.74,0 48.54,15.19 48.54,33.94 c 0,9.65 4.03,18.36 10.49,24.54 L 92.01,1.36 C 88.99,0.48 85.79,0 82.48,0 Z"
52
+ id="path2" />
53
+ <path
54
+ class="cls-2"
55
+ d="m 3.59,71.31 c 9.37,16.23 30.13,21.79 46.36,12.42 8.36,-4.82 13.88,-12.67 16,-21.36 H 0 c 0.75,3.06 1.93,6.07 3.59,8.94 z"
56
+ id="path3" />
57
+ <path
58
+ class="cls-4"
59
+ d="M 136.25,39.58 C 126.88,23.35 106.12,17.79 89.89,27.16 c -8.36,4.82 -13.88,12.67 -16,21.36 h 65.95 c -0.75,-3.06 -1.93,-6.07 -3.59,-8.94 z"
60
+ id="path4" />
61
+ </g>
62
+ </g>
63
+ </g>
64
+ </svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" id="Livello_1" width="256" height="256" viewBox="0 0 256 256"><defs id="defs1"><style id="style1">.st4{fill:#d19d29}</style></defs><g id="KIMU" transform="translate(-330.145 -133.58)scale(.48535)"><g id="g4"><path id="path1" d="m705.8 595.5 88.7 133.3h-6.7l-85-127.2v127.2h-5V462.3h5v128l85-128h6.7l-88.7 133.3z" class="st4"/><path id="path2" d="M825.6 462.2v266.5h-5V462.2Z" class="st4"/><path id="path3" d="M1023.7 472.3v254c0 1.4-1.1 2.5-2.5 2.5s-2.5-1.1-2.5-2.5V487.9c0-2.4-3.1-3.4-4.5-1.4l-65.1 92.6c-.5.7-1.2 1-2 1h-2.4c-.8 0-1.6-.4-2-1l-65.4-92.6c-1.4-2-4.5-1-4.5 1.5v238.4c0 1.4-1.1 2.5-2.5 2.5s-2.5-1.1-2.5-2.5v-254c0-1.4 1.1-2.5 2.5-2.5h1.2c.8 0 1.6.4 2.1 1.1l70.3 102.9c1 1.4 3.1 1.4 4.1 0l70-102.9c.5-.7 1.2-1.1 2.1-1.1h1.2c1.4 0 2.5 1.1 2.5 2.5z" class="st4"/><path id="path4" d="M1069.7 462.2v165.5c0 33.8 0 60.1 9.6 75.5 9.7 15.4 27.7 21.5 44.3 21.5s34-6.1 43.4-21.5 9.3-41.6 9.3-75.5V462.2h5v165.5c0 35.3-.2 63.1-10.4 80s-29.2 23.7-47.3 23.7-37.3-6.9-47.9-23.9-11-44.7-11-79.8V462.2Z" class="st4"/></g></g><g id="Girandola" transform="translate(-330.145 -133.58)scale(.48535)"><g id="Aste"><path id="path5" d="M1116.3 430.9c18.7 0 33.9-15.2 33.9-33.9 0-9.6-4-18.4-10.5-24.5l-33 57.1c3 .9 6.2 1.4 9.5 1.4z" style="fill:#88d1e2"/><path id="path6" d="M1141.3 319.9c-18.7 0-33.9 15.2-33.9 33.9s4 18.4 10.5 24.5l33-57.1c-3-.9-6.2-1.4-9.5-1.4z" style="fill:#f45e32"/><path id="path7" d="M1062.4 391.2c9.4 16.2 30.1 21.8 46.4 12.4 8.4-4.8 13.9-12.7 16-21.4h-65.9c.7 3.1 1.9 6.1 3.6 8.9z" style="fill:#fff463"/><path id="path8" d="M1195.1 359.4c-9.4-16.2-30.1-21.8-46.4-12.4-8.4 4.8-13.9 12.7-16 21.4h65.9c-.7-3.1-1.9-6.1-3.6-8.9z" style="fill:#91d292"/></g></g></svg>
@@ -0,0 +1,59 @@
1
+ /**
2
+ * This script compiles all config files located in "src/config" using esbuild.
3
+ * The compiled output is saved in "dist/config/",
4
+ * preserving the source folder structure.
5
+ */
6
+ import { build } from 'esbuild';
7
+ import fs from 'fs';
8
+ import path from 'path';
9
+ import { fixImportsInFiles } from './utils/fix-imports.js';
10
+
11
+ const SRC_DIR = 'src/config';
12
+ const DIST_DIR = 'dist/config';
13
+
14
+ // Ensure output directory exists
15
+ if (!fs.existsSync(DIST_DIR)) {
16
+ fs.mkdirSync(DIST_DIR, { recursive: true });
17
+ }
18
+
19
+ // Find all TypeScript files in the config directory
20
+ const tsFiles = fs.readdirSync(SRC_DIR)
21
+ .filter(file => file.endsWith('.ts'))
22
+ .map(file => path.join(SRC_DIR, file));
23
+
24
+ if (tsFiles.length === 0) {
25
+ console.warn(`⚠️ No .ts files found in ${SRC_DIR}`);
26
+ process.exit(0);
27
+ }
28
+
29
+ try {
30
+ // Compile all TypeScript files individually
31
+ const compiledFiles = [];
32
+
33
+ for (const tsFile of tsFiles) {
34
+ const fileName = path.basename(tsFile, '.ts');
35
+ const outFile = path.join(DIST_DIR, `${fileName}.js`);
36
+
37
+ await build({
38
+ entryPoints: [tsFile],
39
+ bundle: false, // Don't bundle, keep individual files
40
+ minify: true,
41
+ format: 'esm',
42
+ outfile: outFile,
43
+ platform: 'browser'
44
+ });
45
+
46
+ compiledFiles.push(outFile);
47
+ }
48
+
49
+ // Fix import paths in all compiled files
50
+ const fixedCount = fixImportsInFiles(compiledFiles);
51
+
52
+ console.log(`✅ Config files compiled: ${tsFiles.length} files → ${DIST_DIR}`);
53
+ if (fixedCount > 0) {
54
+ console.log(`🔧 Fixed imports in ${fixedCount} config files`);
55
+ }
56
+ } catch (err) {
57
+ console.error(`❌ Error compiling config files:`, err.message);
58
+ process.exit(1);
59
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * This script compiles all core files located in "src/core" using esbuild.
3
+ * The compiled output is saved in "dist/core/",
4
+ * preserving the source folder structure.
5
+ *
6
+ * Features:
7
+ * - Compiles all TypeScript files in "src/core".
8
+ * - Compiles TypeScript to JavaScript (ESM format) with minification.
9
+ * - Automatically fixes import paths by adding .js extensions.
10
+ * - Logs success or failure for each file compilation.
11
+ */
12
+ import { build } from 'esbuild';
13
+ import fs from 'fs';
14
+ import path from 'path';
15
+ import { fixImportsInFiles } from './utils/fix-imports.js';
16
+
17
+ const SRC_DIR = 'src/core';
18
+ const DIST_DIR = 'dist/core';
19
+
20
+ // Ensure output directory exists
21
+ if (!fs.existsSync(DIST_DIR)) {
22
+ fs.mkdirSync(DIST_DIR, { recursive: true });
23
+ }
24
+
25
+ // Find all TypeScript files in the core directory
26
+ const tsFiles = fs.readdirSync(SRC_DIR)
27
+ .filter(file => file.endsWith('.ts'))
28
+ .map(file => path.join(SRC_DIR, file));
29
+
30
+ if (tsFiles.length === 0) {
31
+ console.warn(`⚠️ No .ts files found in ${SRC_DIR}`);
32
+ process.exit(0);
33
+ }
34
+
35
+ try {
36
+ // Compile all TypeScript files individually
37
+ const compiledFiles = [];
38
+
39
+ for (const tsFile of tsFiles) {
40
+ const fileName = path.basename(tsFile, '.ts');
41
+ const outFile = path.join(DIST_DIR, `${fileName}.js`);
42
+
43
+ await build({
44
+ entryPoints: [tsFile],
45
+ bundle: false, // Don't bundle, keep individual files
46
+ minify: true,
47
+ format: 'esm',
48
+ outfile: outFile,
49
+ platform: 'browser'
50
+ });
51
+
52
+ compiledFiles.push(outFile);
53
+ }
54
+
55
+ // Fix import paths in all compiled files
56
+ const fixedCount = fixImportsInFiles(compiledFiles);
57
+
58
+ console.log(`✅ Core files compiled: ${tsFiles.length} files → ${DIST_DIR}`);
59
+ if (fixedCount > 0) {
60
+ console.log(`🔧 Fixed imports in ${fixedCount} core files`);
61
+ }
62
+ } catch (err) {
63
+ console.error(`❌ Error compiling core files:`, err.message);
64
+ process.exit(1);
65
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * This script compiles all extensions located in the "src/extensions" directory
3
+ * using esbuild. Each extension is expected to have a "component.ts" entry file.
4
+ * The compiled output is saved in the "dist/extensions" directory, maintaining
5
+ * the folder structure of the source directory.
6
+ *
7
+ * Key functionalities:
8
+ * - Reads all subdirectories in "src/extensions".
9
+ * - Checks for the presence of "component.ts" in each subdirectory.
10
+ * - Compiles the TypeScript files into JavaScript (ESM format) with minification.
11
+ * - Automatically fixes import paths by adding .js extensions.
12
+ * - Logs the success or failure of each compilation process.
13
+ */
14
+
15
+ import { build } from 'esbuild';
16
+ import fs from 'fs';
17
+ import path from 'path';
18
+ import { fixImportsInFile } from './utils/fix-imports.js';
19
+
20
+ // Starting paths
21
+ const SRC_DIR = 'src/extensions';
22
+ const DIST_DIR = 'dist/extensions';
23
+
24
+ // Read all subfolders inside src/extensions
25
+ const extensions = fs.readdirSync(SRC_DIR, { withFileTypes: true })
26
+ .filter(dirent => dirent.isDirectory())
27
+ .map(dirent => dirent.name);
28
+
29
+ for (const ext of extensions) {
30
+ const entry = path.join(SRC_DIR, ext, 'component.ts');
31
+ const outDir = path.join(DIST_DIR, ext);
32
+ const outFile = path.join(outDir, 'component.js');
33
+
34
+ if (!fs.existsSync(entry)) {
35
+ console.warn(`⚠️ "${ext}" ignorata (component.ts non trovato)`);
36
+ continue;
37
+ }
38
+
39
+ try {
40
+ await build({
41
+ entryPoints: [entry],
42
+ bundle: true,
43
+ minify: true,
44
+ format: 'esm',
45
+ outfile: outFile,
46
+ platform: 'browser',
47
+ external: [
48
+ '../../core/*',
49
+ '../../modules/*',
50
+ '../../utils/*'
51
+ ]
52
+ });
53
+
54
+ // Fix import paths in the compiled extension file
55
+ const fixed = fixImportsInFile(outFile);
56
+
57
+ console.log(`✅ Extension compiled "${ext}" to ${outFile}`);
58
+ if (fixed) {
59
+ console.log(`🔧 Fixed imports for extension "${ext}"`);
60
+ }
61
+ } catch (err) {
62
+ console.error(`❌ Error compiling extension "${ext}":`, err.message);
63
+ }
64
+ }
@@ -0,0 +1,99 @@
1
+ /**
2
+ * This script compiles all modules located in "src/modules" using esbuild.
3
+ * Each module must have a "module.ts" entry file.
4
+ * The compiled output is saved in "dist/modules/<module-name>/module.js",
5
+ * preserving the source folder structure.
6
+ *
7
+ * Features:
8
+ * - Scans all subdirectories in "src/modules".
9
+ * - Checks for the presence of "module.ts" in each subdirectory.
10
+ * - Compiles TypeScript to JavaScript (ESM format) with minification.
11
+ * - Automatically fixes import paths by adding .js extensions.
12
+ * - Logs success or failure for each module compilation.
13
+ */
14
+ import { build } from 'esbuild';
15
+ import fs from 'fs';
16
+ import path from 'path';
17
+ import { fileURLToPath, pathToFileURL } from 'url';
18
+ import { fixImportsInFile } from './utils/fix-imports.js';
19
+
20
+ // ES modules don't have __dirname, so we need to derive it
21
+ const __filename = fileURLToPath(import.meta.url);
22
+ const __dirname = path.dirname(__filename);
23
+
24
+ const SRC_DIR = 'src/modules';
25
+ const DIST_DIR = 'dist/modules';
26
+
27
+ // Get all module subfolders in src/modules
28
+ const modules = fs.readdirSync(SRC_DIR, { withFileTypes: true })
29
+ .filter(dirent => dirent.isDirectory())
30
+ .map(dirent => dirent.name);
31
+
32
+ // Run pre-build scripts first (before compilation)
33
+ for (const mod of modules) {
34
+ const moduleDir = path.join(SRC_DIR, mod);
35
+ const preBuildScript = path.join(moduleDir, 'pre-build.js');
36
+
37
+ if (fs.existsSync(preBuildScript)) {
38
+ try {
39
+ const preBuild = await import(pathToFileURL(preBuildScript).href);
40
+ if (preBuild.default && typeof preBuild.default === 'function') {
41
+ await preBuild.default({
42
+ moduleDir,
43
+ moduleName: mod,
44
+ rootDir: path.join(__dirname, '..')
45
+ });
46
+ }
47
+ } catch (err) {
48
+ console.warn(`⚠️ Pre-build script failed for "${mod}":`, err.message);
49
+ }
50
+ }
51
+ }
52
+
53
+ // Now compile all modules
54
+ for (const mod of modules) {
55
+ const moduleDir = path.join(SRC_DIR, mod);
56
+ const outDir = path.join(DIST_DIR, mod);
57
+
58
+ // Ensure output directory exists and is clean
59
+ if (fs.existsSync(outDir)) {
60
+ fs.rmSync(outDir, { recursive: true });
61
+ }
62
+ fs.mkdirSync(outDir, { recursive: true });
63
+
64
+ // Look for the main entry point (module.ts)
65
+ const entryPoint = path.join(moduleDir, 'module.ts');
66
+
67
+ if (!fs.existsSync(entryPoint)) {
68
+ console.warn(`⚠️ Module "${mod}" skipped (module.ts not found)`);
69
+ continue;
70
+ }
71
+
72
+ try {
73
+ // Bundle the entire module into a single file
74
+ await build({
75
+ entryPoints: [entryPoint],
76
+ bundle: true, // Bundle all dependencies into a single file
77
+ minify: true,
78
+ format: 'esm',
79
+ outfile: path.join(outDir, 'module.js'),
80
+ platform: 'browser',
81
+ external: [
82
+ // Keep external references to core framework parts
83
+ '../../core/*',
84
+ '../../config/*'
85
+ ]
86
+ });
87
+
88
+ // Fix import paths in the bundled module file
89
+ const outFile = path.join(outDir, 'module.js');
90
+ const fixed = fixImportsInFile ? fixImportsInFile(outFile) : false;
91
+
92
+ console.log(`✅ Module compiled: "${mod}" → ${outDir} (bundled)`);
93
+ if (fixed) {
94
+ console.log(`🔧 Fixed imports for module "${mod}"`);
95
+ }
96
+ } catch (err) {
97
+ console.error(`❌ Error compiling module "${mod}":`, err.message);
98
+ }
99
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * This script compiles a single extension located in the "src/extensions" directory
3
+ * using esbuild. The extension name must be provided as a command-line argument.
4
+ * The compiled output is saved in the "dist/extensions" directory.
5
+ *
6
+ * Key functionalities:
7
+ * - Validates the presence of the extension name argument.
8
+ * - Checks for the existence of the "component.ts" entry file in the specified extension folder.
9
+ * - Creates the output directory if it does not exist.
10
+ * - Compiles the TypeScript file into JavaScript (ESM format) with minification.
11
+ * - Logs the success or failure of the compilation process.
12
+ *
13
+ * Usage:
14
+ * node build-extension.js <extension-name>
15
+ * Example:
16
+ * node build-extension.js hello
17
+ */
18
+
19
+ import { build } from 'esbuild';
20
+ import fs from 'fs';
21
+ import path from 'path';
22
+
23
+ const ext = process.argv[2]; // e.g. hello
24
+
25
+ if (!ext) {
26
+ console.error('❌ You must specify the extension name (e.g., hello)');
27
+ process.exit(1);
28
+ }
29
+
30
+ const SRC_DIR = 'src/extensions';
31
+ const DIST_DIR = 'dist/extensions';
32
+
33
+ const entry = path.join(SRC_DIR, ext, 'component.ts');
34
+ const outDir = path.join(DIST_DIR, ext);
35
+ const outFile = path.join(outDir, 'component.js');
36
+
37
+ // Check if the entry file exists
38
+ if (!fs.existsSync(entry)) {
39
+ console.error(`❌ Il file component.ts per "${ext}" non è stato trovato in ${entry}`);
40
+ process.exit(1);
41
+ }
42
+
43
+ // Create the output directory if it does not exist
44
+ fs.mkdirSync(outDir, { recursive: true });
45
+
46
+ // Compilation
47
+ try {
48
+ await build({
49
+ entryPoints: [entry],
50
+ bundle: true,
51
+ minify: true,
52
+ format: 'esm',
53
+ outfile: outFile,
54
+ platform: 'browser'
55
+ });
56
+
57
+ console.log(`✅ Extension compiled "${ext}" to ${outFile}`);
58
+ } catch (err) {
59
+ console.error(`❌ Error during the compilation of extension "${ext}":`, err.message);
60
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * This script removes the "kimu-build-config.ts" file located in the "src/config" directory.
3
+ * It checks if the file exists and deletes it if found.
4
+ * If the file does not exist, it logs a message indicating that there is nothing to remove.
5
+ *
6
+ * Key functionalities:
7
+ * - Resolves the path to "kimu-build-config.ts" based on the script's location.
8
+ * - Checks for the existence of the file.
9
+ * - Deletes the file if it exists.
10
+ * - Logs the result of the operation.
11
+ */
12
+
13
+ import fs from 'fs';
14
+ import path from 'path';
15
+ import { fileURLToPath } from 'url';
16
+
17
+ // Get the directory name of the current script file
18
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
19
+
20
+ // Resolve the path to the "kimu-build-config.ts" file
21
+ const buildPath = path.resolve(__dirname, '../src/config/kimu-build-config.ts');
22
+
23
+ // Check if the file exists
24
+ if (fs.existsSync(buildPath)) {
25
+ // Delete the file if it exists
26
+ fs.unlinkSync(buildPath);
27
+ console.log('[KIMU] 🧹 kimu-build-config.json removed');
28
+ } else {
29
+ // Log a message if the file does not exist
30
+ console.log('[KIMU] No file to remove');
31
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * This script generates the "kimu-build-config.ts" file based on the base configuration,
3
+ * environment-specific configuration, and the version from the project's package.json.
4
+ * The generated file is saved in the "src/config" directory.
5
+ *
6
+ * Key functionalities:
7
+ * - Reads the base configuration from "kimu-base-config.json".
8
+ * - Reads the environment-specific configuration from "<env>.config.json".
9
+ * - Extracts the version from "package.json".
10
+ * - Combines the configurations and version into a single object.
11
+ * - Generates a TypeScript file with the final configuration.
12
+ * - Logs the success or failure of the operation.
13
+ *
14
+ * Usage:
15
+ * node generate-kimu-build-config.js <environment>
16
+ * Example:
17
+ * node generate-kimu-build-config.js production
18
+ */
19
+
20
+ import fs from 'fs';
21
+ import path from 'path';
22
+ import { fileURLToPath } from 'url';
23
+
24
+ // Get the directory name of the current script file
25
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
26
+
27
+ // Get the environment argument or default to "dev"
28
+ const env = process.argv[2] || 'dev';
29
+
30
+ // Import the package.json to retrieve the version
31
+ // Note: Importing package.json this way ensures compatibility with different paths
32
+ const pkg = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../package.json'), 'utf-8'));
33
+ const version = pkg.version || '0.0.0';
34
+
35
+ // Paths to configuration files
36
+ const configPath = path.resolve(__dirname, '../src/config/kimu-base-config.json');
37
+ const envConfigPath = path.resolve(__dirname, `../env/${env}.config.json`);
38
+ const outputPath = path.resolve(__dirname, '../src/config/kimu-build-config.ts');
39
+
40
+ // Check if the environment-specific configuration file exists
41
+ if (!fs.existsSync(envConfigPath)) {
42
+ console.error(`[KIMU] ❌ Missing env config: ${envConfigPath}`);
43
+ process.exit(1);
44
+ }
45
+
46
+ // Read and parse the base and environment-specific configurations
47
+ const base = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
48
+ const build = JSON.parse(fs.readFileSync(envConfigPath, 'utf-8'));
49
+
50
+ // Override with environment variables if present
51
+ if (process.env.KIMU_BASE_PATH) {
52
+ build['base-path'] = process.env.KIMU_BASE_PATH;
53
+ console.log(`[KIMU] 🔧 Base path overridden from env: ${process.env.KIMU_BASE_PATH}`);
54
+ }
55
+ if (process.env.KIMU_API_URL) {
56
+ build['api-url'] = process.env.KIMU_API_URL;
57
+ console.log(`[KIMU] 🔧 API URL overridden from env: ${process.env.KIMU_API_URL}`);
58
+ }
59
+ if (process.env.KIMU_WEB_URL) {
60
+ build['web-url'] = process.env.KIMU_WEB_URL;
61
+ console.log(`[KIMU] 🔧 Web URL overridden from env: ${process.env.KIMU_WEB_URL}`);
62
+ }
63
+
64
+ // Combine the configurations, version, and environment into the final object
65
+ const finalConfig = {
66
+ ...base,
67
+ version,
68
+ environment: env,
69
+ build
70
+ };
71
+
72
+ // Generate the TypeScript content for the configuration file
73
+ const tsContent = `/** Automatically generated file. Do not modify. */
74
+ export const KimuBuildConfig = ${JSON.stringify(finalConfig, null, 2)} as const;
75
+ `;
76
+
77
+ // Write the generated content to the output file
78
+ fs.writeFileSync(outputPath, tsContent);
79
+ console.log(`[KIMU] ✅ Generated kimu-build-config.ts for "${env}" → version ${version}`);