kreftjs 0.0.4-beta → 0.0.6-beta
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/LICENSE +95 -0
- package/README.md +2 -2
- package/bin/build.js +23 -1
- package/bin/kreftjs.js +1 -0
- package/docs/README.md +47 -2
- package/kreftjs.d.ts +1 -1
- package/kreftjs.js +2 -2
- package/package.json +2 -1
- package/templates/app/frontend/errors/ErrorMonitor.kreftjs +2 -2
- package/templates/app/frontend/kreftjs.d.ts +1 -1
- package/templates/app/frontend/kreftjs.js +2 -2
- package/templates/app/frontend/pages/Dashboard.kreftjs +1 -1
- package/templates/errors/ErrorMonitor.kreftjs +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
Copyright 2026 Maxamuud Xuseen
|
|
2
|
+
|
|
3
|
+
Elastic License 2.0
|
|
4
|
+
|
|
5
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
14
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
15
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
16
|
+
the limitations and conditions below.
|
|
17
|
+
|
|
18
|
+
## Limitations
|
|
19
|
+
|
|
20
|
+
You may not provide the software to third parties as a hosted or managed
|
|
21
|
+
service, where the service provides users with access to any substantial set of
|
|
22
|
+
the features or functionality of the software.
|
|
23
|
+
|
|
24
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
25
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
26
|
+
software that is protected by the license key.
|
|
27
|
+
|
|
28
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
29
|
+
of the licensor in the software. Any use of the licensor’s trademarks is subject
|
|
30
|
+
to applicable law.
|
|
31
|
+
|
|
32
|
+
## Patents
|
|
33
|
+
|
|
34
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
35
|
+
license, or becomes able to license, to make, have made, use, sell, offer for
|
|
36
|
+
sale, import and have imported the software, in each case subject to the
|
|
37
|
+
limitations and conditions in this license. This license does not cover any
|
|
38
|
+
patent claims that you cause to be infringed by modifications or additions to
|
|
39
|
+
the software. If you or your company make any written claim that the software
|
|
40
|
+
infringes or contributes to infringement of any patent, your patent license for
|
|
41
|
+
the software granted under these terms ends immediately. If your company makes
|
|
42
|
+
such a claim, your patent license ends immediately for work on behalf of your
|
|
43
|
+
company.
|
|
44
|
+
|
|
45
|
+
## Notices
|
|
46
|
+
|
|
47
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
48
|
+
also gets a copy of these terms.
|
|
49
|
+
|
|
50
|
+
If you modify the software, you must include in any modified copies of the
|
|
51
|
+
software prominent notices stating that you have modified the software.
|
|
52
|
+
|
|
53
|
+
## No Other Rights
|
|
54
|
+
|
|
55
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
56
|
+
these terms.
|
|
57
|
+
|
|
58
|
+
## Termination
|
|
59
|
+
|
|
60
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
61
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
62
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
63
|
+
later than 30 days after you receive that notice, your licenses will be
|
|
64
|
+
reinstated retroactively. However, if you violate these terms after such
|
|
65
|
+
reinstatement, any additional violation of these terms will cause your licenses
|
|
66
|
+
to terminate automatically and permanently.
|
|
67
|
+
|
|
68
|
+
## No Liability
|
|
69
|
+
|
|
70
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
71
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
72
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
73
|
+
legal claim.*
|
|
74
|
+
|
|
75
|
+
## Definitions
|
|
76
|
+
|
|
77
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
78
|
+
software the licensor makes available under these terms, including any portion
|
|
79
|
+
of it.
|
|
80
|
+
|
|
81
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
82
|
+
|
|
83
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
84
|
+
organization that you work for, plus all organizations that have control over,
|
|
85
|
+
are under the control of, or are under common control with that
|
|
86
|
+
organization. **control** means ownership of substantially all the assets of an
|
|
87
|
+
entity, or the power to direct its management and policies by vote, contract, or
|
|
88
|
+
otherwise. Control can be direct or indirect.
|
|
89
|
+
|
|
90
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
91
|
+
these terms.
|
|
92
|
+
|
|
93
|
+
**use** means anything you do with the software requiring one of your licenses.
|
|
94
|
+
|
|
95
|
+
**trademark** means trademarks, service marks, and similar rights.
|
package/README.md
CHANGED
|
@@ -75,7 +75,7 @@ Views are escaped, logins use HttpOnly cookies with CSRF protection, passwords u
|
|
|
75
75
|
|
|
76
76
|
## Migrating from Som.js
|
|
77
77
|
|
|
78
|
-
Kreft is Som.js under a new name: the package is `kreftjs` (version 0.0.
|
|
78
|
+
Kreft is Som.js under a new name: the package is `kreftjs` (version 0.0.6-beta), the command is `kreft` (`kreftjs` works too), the global is `Kreftjs` and component files end in `.kreftjs`. The old names keep working, so an existing project runs without edits. New files and everything the tools write use the new names. Move over when it suits you. (`kreft` was an earlier spelling of the new name; it is accepted in the same places.)
|
|
79
79
|
|
|
80
80
|
| Som.js | Kreft | Still works? |
|
|
81
81
|
|---|---|---|
|
|
@@ -101,4 +101,4 @@ Kept on purpose, with a TODO for 3.1: the `som_migrations` table (renaming it wo
|
|
|
101
101
|
|
|
102
102
|
## License
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
Kreft is released under the [Elastic License 2.0](LICENSE). You may use it, including to build and sell your own applications, copy it and change it. You may not offer Kreft itself to others as a hosted or managed service, and you may not remove or hide its license notices.
|
package/bin/build.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* kreft build --prerender also save every page as ready HTML (needs: npm i -D jsdom)
|
|
9
9
|
* kreft build --prerender --urls urls.js ... and the addresses in that file (pages that come from your data)
|
|
10
10
|
* kreft build --include docs also copy another folder into the output
|
|
11
|
+
* kreft build --no-htaccess do not write dist/.htaccess (the Apache / Hostinger page-address rules)
|
|
11
12
|
*
|
|
12
13
|
* What it does:
|
|
13
14
|
* 1. Compiles every .kreftjs file ahead of time into app.js (no .kreftjs files are downloaded in production).
|
|
@@ -33,11 +34,12 @@ const SERVER_DIRS = new Set();
|
|
|
33
34
|
const SKIP = new Set(['node_modules', '.git', '.vscode', '.idea', 'package.json', 'package-lock.json', '.DS_Store']);
|
|
34
35
|
|
|
35
36
|
module.exports = function build(args) {
|
|
36
|
-
let folder = null, out = null, base = null, prerender = null, urlsFile = null;
|
|
37
|
+
let folder = null, out = null, base = null, prerender = null, urlsFile = null, htaccess = true;
|
|
37
38
|
const include = [];
|
|
38
39
|
for (let i = 0; i < args.length; i++) {
|
|
39
40
|
if (args[i] === '--out' || args[i] === '-o') out = args[++i];
|
|
40
41
|
else if (args[i] === '--base') base = args[++i];
|
|
42
|
+
else if (args[i] === '--no-htaccess') htaccess = false;
|
|
41
43
|
else if (args[i] === '--include') include.push(args[++i]); // another folder to copy in, like the docs
|
|
42
44
|
else if (args[i] === '--prerender') prerender = args[i + 1] && !args[i + 1].startsWith('-') && args[i + 1].includes('/') ? args[++i].split(',') : [];
|
|
43
45
|
else if (args[i] === '--urls') urlsFile = args[++i]; // a file with more addresses to prerender (pages from your data)
|
|
@@ -227,6 +229,7 @@ ${indent(components.join('\n\n'))}
|
|
|
227
229
|
: html.replace(/<head>/i, `<head>\n <base href="${b}">`);
|
|
228
230
|
}
|
|
229
231
|
write(dist, 'index.html', html);
|
|
232
|
+
if (htaccess) writeHtaccess(dist, html);
|
|
230
233
|
|
|
231
234
|
const report = () => {
|
|
232
235
|
const files = walk(dist, null).map((f) => [path.relative(dist, f), fs.statSync(f).size]);
|
|
@@ -249,6 +252,25 @@ ${indent(components.join('\n\n'))}
|
|
|
249
252
|
report();
|
|
250
253
|
};
|
|
251
254
|
|
|
255
|
+
// Apache (Hostinger, cPanel …) answers /docs with a 404, because only index.html exists on disk. These rules send every address
|
|
256
|
+
// that is not a real file or folder to index.html, so reloading a page works. An .htaccess you keep in public/ is left alone;
|
|
257
|
+
// a relative base (./, as the desktop build uses) has no server and gets no file.
|
|
258
|
+
function writeHtaccess(dist, html) {
|
|
259
|
+
const m = /<base\b[^>]*\bhref="([^"]*)"/i.exec(html);
|
|
260
|
+
const base = m ? m[1] : '/';
|
|
261
|
+
if (!base.startsWith('/') || fs.existsSync(path.join(dist, '.htaccess'))) return;
|
|
262
|
+
write(dist, '.htaccess', `# Written by kreft build: every address that is not a file or a folder opens index.html (turn off: kreft build --no-htaccess)
|
|
263
|
+
<IfModule mod_rewrite.c>
|
|
264
|
+
RewriteEngine On
|
|
265
|
+
RewriteBase ${base}
|
|
266
|
+
RewriteRule ^index\\.html$ - [L]
|
|
267
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
268
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
269
|
+
RewriteRule . ${base}index.html [L]
|
|
270
|
+
</IfModule>
|
|
271
|
+
`);
|
|
272
|
+
}
|
|
273
|
+
|
|
252
274
|
// a frontend .ts file → the browser's JavaScript (types removed); its own './x.ts' imports become './x.js'
|
|
253
275
|
function tsToJs(file, project) {
|
|
254
276
|
const { transpileTs } = require('./backend/typescript.js');
|
package/bin/kreftjs.js
CHANGED
|
@@ -163,6 +163,7 @@ function help() {
|
|
|
163
163
|
--base <path> Change the <base href> (for example /)
|
|
164
164
|
--prerender [paths] Also save every page as ready HTML (needs: npm i -D jsdom)
|
|
165
165
|
--include <folder> Also copy this folder into the output (for example docs)
|
|
166
|
+
--no-htaccess Do not write dist/.htaccess (page-address rules for Apache and Hostinger)
|
|
166
167
|
kreft add <packages...> Install npm packages with strict security gatekeeper (alias: kreft install, kreft i)
|
|
167
168
|
-D, --dev Install as devDependency
|
|
168
169
|
-y, --yes Auto-confirm unverified community packages in CI/CD
|
package/docs/README.md
CHANGED
|
@@ -82,7 +82,7 @@ npx kreftjs dev
|
|
|
82
82
|
### Check that it works
|
|
83
83
|
|
|
84
84
|
```bash
|
|
85
|
-
kreft --version # for example 0.0.
|
|
85
|
+
kreft --version # for example 0.0.6-beta
|
|
86
86
|
kreft about # Kreft and Node.js versions, this project's settings and drivers
|
|
87
87
|
kreft list # every command your version has
|
|
88
88
|
```
|
|
@@ -1737,7 +1737,52 @@ What you get:
|
|
|
1737
1737
|
- **A strict Content-Security-Policy works.** Every expression becomes a real function, so the built app never uses `eval` or `new Function`.
|
|
1738
1738
|
- **Errors before you deploy.** A mistake in any `.kreftjs` file stops the build and names the file and line.
|
|
1739
1739
|
|
|
1740
|
-
Options: `kreft build ./site --out public` builds another folder, and `--base /` changes `<base href>`.
|
|
1740
|
+
Options: `kreft build ./site --out public` builds another folder, and `--base /` changes `<base href>`. `--no-htaccess` skips the `.htaccess` file described below.
|
|
1741
|
+
|
|
1742
|
+
### Upload to a host
|
|
1743
|
+
|
|
1744
|
+
**Static hosting: Hostinger, cPanel, any Apache host.** Upload what is *inside* `dist/` (not the `dist` folder itself) to the folder the website is served from, normally `public_html`. In Hostinger's hPanel: **Files → File Manager → public_html → Upload**, or use FTP. Do not use the "framework" or "Node.js app" importers for this: they look for a `package.json` and say *Unsupported framework or invalid project structure*, because `dist/` holds only finished files.
|
|
1745
|
+
|
|
1746
|
+
`kreft build` also writes `dist/.htaccess`:
|
|
1747
|
+
|
|
1748
|
+
```apache
|
|
1749
|
+
RewriteEngine On
|
|
1750
|
+
RewriteBase /
|
|
1751
|
+
RewriteRule ^index\.html$ - [L]
|
|
1752
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
1753
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
1754
|
+
RewriteRule . /index.html [L]
|
|
1755
|
+
```
|
|
1756
|
+
|
|
1757
|
+
Apache only knows the files on disk, so without these rules `/docs` or any other clean address gives a 404 when someone opens or reloads it. With them, every address that is not a real file or folder opens `index.html` and the router takes over. Upload the file too (it starts with a dot, so some file managers hide it; turn on "show hidden files"). If the site lives in a folder, build with `--base /folder/` and the rules follow it. An `.htaccess` you keep in `public/` is used as it is. A relative base (`--base ./`, used by the desktop build) gets no file.
|
|
1758
|
+
|
|
1759
|
+
> [!NOTE]
|
|
1760
|
+
> This hosts the front end only. Login, the database and everything under `/api` need the Node.js server, which Apache does not run.
|
|
1761
|
+
|
|
1762
|
+
**A Node.js plan or a VPS.** Upload the whole project (without `node_modules`), not `dist/`. Add Kreft to its dependencies with `npm i kreftjs`, build with `npm run build`, and start the server with `npm run serve` (it reads the `PORT` your host sets). The generated `start` script runs the development server, so do not use it in production.
|
|
1763
|
+
|
|
1764
|
+
|
|
1765
|
+
On a VPS, keep it running with PM2 and put nginx in front of it for your domain and HTTPS:
|
|
1766
|
+
|
|
1767
|
+
```bash
|
|
1768
|
+
npm install && npm run build
|
|
1769
|
+
npm i -g pm2
|
|
1770
|
+
pm2 start "npm run serve" --name my-app && pm2 save
|
|
1771
|
+
```
|
|
1772
|
+
|
|
1773
|
+
```nginx
|
|
1774
|
+
server {
|
|
1775
|
+
server_name example.com;
|
|
1776
|
+
location / {
|
|
1777
|
+
proxy_pass http://127.0.0.1:8000;
|
|
1778
|
+
proxy_set_header Host $host;
|
|
1779
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
```
|
|
1783
|
+
|
|
1784
|
+
Then `sudo certbot --nginx -d example.com` adds HTTPS. Set `APP_ENV=production` and a real `APP_KEY` in `.env` first, and read the [Production checklist](#production-checklist).
|
|
1785
|
+
|
|
1741
1786
|
|
|
1742
1787
|
### Ready HTML for every page: `--prerender`
|
|
1743
1788
|
|
package/kreftjs.d.ts
CHANGED
package/kreftjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Kreft v0.0.
|
|
2
|
+
* Kreft v0.0.6-beta — reactive by nature
|
|
3
3
|
* The .kreftjs component language (state · derive · action · when · watch · on),
|
|
4
4
|
* { } views with k-if / k-each / k-model, components, slots, router, stores,
|
|
5
5
|
* share / receive, event bus and a template engine.
|
|
@@ -5032,7 +5032,7 @@
|
|
|
5032
5032
|
stores, storeLog, busLog,
|
|
5033
5033
|
};
|
|
5034
5034
|
|
|
5035
|
-
const VERSION = '0.0.
|
|
5035
|
+
const VERSION = '0.0.6-beta';
|
|
5036
5036
|
const Kreftjs = {
|
|
5037
5037
|
version: VERSION,
|
|
5038
5038
|
// PUBLIC_ values from .env (kreft dev and kreft build put them here); never secrets
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kreftjs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6-beta",
|
|
4
4
|
"description": "A tiny reactive framework with its own component language (.kreftjs files): router with nested routes, stores, saved data, animations, an API client, hot reload, DevTools and a template engine.",
|
|
5
|
+
"license": "Elastic-2.0",
|
|
5
6
|
"main": "kreftjs.js",
|
|
6
7
|
"browser": "kreftjs.js",
|
|
7
8
|
"bin": {
|
|
@@ -90,7 +90,7 @@ action copyReport() {
|
|
|
90
90
|
<div class="badges">
|
|
91
91
|
<span class="badge danger-badge">HTTP {status}</span>
|
|
92
92
|
<span class="badge solid">{currentTitle}</span>
|
|
93
|
-
<span class="badge">Kreft {Kreftjs.version || '0.0.
|
|
93
|
+
<span class="badge">Kreft {Kreftjs.version || '0.0.6-beta'}</span>
|
|
94
94
|
</div>
|
|
95
95
|
<div class="actions">
|
|
96
96
|
<button class="sm" @click={copyReport}>{copied ? 'Copied Markdown' : 'Copy Report'}</button>
|
|
@@ -187,7 +187,7 @@ action copyReport() {
|
|
|
187
187
|
<h3>Kreft Runtime</h3>
|
|
188
188
|
<table>
|
|
189
189
|
<tbody>
|
|
190
|
-
<tr><th>Engine</th><td><code>Kreft v{Kreftjs.version || '0.0.
|
|
190
|
+
<tr><th>Engine</th><td><code>Kreft v{Kreftjs.version || '0.0.6-beta'}</code></td></tr>
|
|
191
191
|
<tr><th>Sanitizer</th><td><code>Active (cleanHtml / SafeHtml)</code></td></tr>
|
|
192
192
|
<tr><th>Environment</th><td><code>development (APP_DEBUG=true)</code></td></tr>
|
|
193
193
|
</tbody>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Kreft v0.0.
|
|
2
|
+
* Kreft v0.0.6-beta — reactive by nature
|
|
3
3
|
* The .kreftjs component language (state · derive · action · when · watch · on),
|
|
4
4
|
* { } views with k-if / k-each / k-model, components, slots, router, stores,
|
|
5
5
|
* share / receive, event bus and a template engine.
|
|
@@ -5032,7 +5032,7 @@
|
|
|
5032
5032
|
stores, storeLog, busLog,
|
|
5033
5033
|
};
|
|
5034
5034
|
|
|
5035
|
-
const VERSION = '0.0.
|
|
5035
|
+
const VERSION = '0.0.6-beta';
|
|
5036
5036
|
const Kreftjs = {
|
|
5037
5037
|
version: VERSION,
|
|
5038
5038
|
// PUBLIC_ values from .env (kreft dev and kreft build put them here); never secrets
|
|
@@ -110,7 +110,7 @@ load board = api.get('/api/dashboard')
|
|
|
110
110
|
<div class="info-list">
|
|
111
111
|
<div class="info-item">
|
|
112
112
|
<span class="info-label">Framework Engine</span>
|
|
113
|
-
<span class="info-value">Kreft {Kreftjs.version || '0.0.
|
|
113
|
+
<span class="info-value">Kreft {Kreftjs.version || '0.0.6-beta'}</span>
|
|
114
114
|
</div>
|
|
115
115
|
<div class="info-item">
|
|
116
116
|
<span class="info-label">Active Database</span>
|
|
@@ -116,7 +116,7 @@ action copyReport() {
|
|
|
116
116
|
<div class="hero-badges">
|
|
117
117
|
<span class="badge-exception">{currentTitle}</span>
|
|
118
118
|
<span class="badge-env">Node.js {typeof process !== 'undefined' ? process.version : 'v22.0.0'}</span>
|
|
119
|
-
<span class="badge-env">Kreft v0.0.
|
|
119
|
+
<span class="badge-env">Kreft v0.0.6-beta</span>
|
|
120
120
|
</div>
|
|
121
121
|
<h1 class="hero-error-message">{currentMessage}</h1>
|
|
122
122
|
</div>
|