kreftjs 0.0.5-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/README.md +1 -1
- 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 +1 -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/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
|
|---|---|---|
|
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,6 +1,6 @@
|
|
|
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
5
|
"license": "Elastic-2.0",
|
|
6
6
|
"main": "kreftjs.js",
|
|
@@ -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>
|