kreftjs 0.0.7-beta → 0.0.9-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.
Files changed (92) hide show
  1. package/README.md +5 -31
  2. package/bin/artisan-more.js +2 -0
  3. package/bin/artisan.js +51 -49
  4. package/bin/backend/config.js +2 -2
  5. package/bin/backend/http.js +5 -5
  6. package/bin/backend/index.js +2 -2
  7. package/bin/backend/mcp.js +3 -5
  8. package/bin/backend/migrator.js +1 -3
  9. package/bin/backend/query.js +1 -1
  10. package/bin/backend/queue.js +8 -9
  11. package/bin/backend/redis.js +1 -1
  12. package/bin/backend/typescript.js +1 -1
  13. package/bin/build.js +22 -18
  14. package/bin/db-api.js +2 -2
  15. package/bin/db.js +4 -4
  16. package/bin/deps.js +1 -1
  17. package/bin/electron.js +3 -5
  18. package/bin/kreftjs-config.js +1 -6
  19. package/bin/kreftjs.js +34 -35
  20. package/bin/layout.js +1 -1
  21. package/bin/no-auth.js +18 -18
  22. package/bin/prerender.js +1 -1
  23. package/bin/ssr.js +3 -3
  24. package/bin/update.js +10 -10
  25. package/docs/{Docs.kreftjs → Docs.kreft} +1 -1
  26. package/docs/README.md +89 -102
  27. package/editors/vscode/README.md +3 -3
  28. package/editors/vscode/package.json +3 -4
  29. package/editors/vscode/snippets/kreftjs.json +2 -2
  30. package/kreftjs.d.ts +15 -27
  31. package/kreftjs.js +69 -79
  32. package/package.json +4 -4
  33. package/templates/app/README.md +10 -10
  34. package/templates/app/_env.example +2 -2
  35. package/templates/app/_vscode/settings.json +3 -2
  36. package/templates/app/backend/app/Http/Controllers/Admin/DashboardController.js +2 -2
  37. package/templates/app/backend/app/Http/Controllers/Admin/UserController.js +1 -1
  38. package/templates/app/backend/app/Http/Controllers/Auth/ApiTokenController.js +1 -1
  39. package/templates/app/backend/app/Http/Controllers/Auth/AuthenticatedSessionController.js +1 -1
  40. package/templates/app/backend/app/Http/Controllers/Auth/ConfirmablePasswordController.js +1 -1
  41. package/templates/app/backend/app/Http/Controllers/Auth/EmailVerificationController.js +1 -1
  42. package/templates/app/backend/app/Http/Controllers/Auth/NewPasswordController.js +1 -1
  43. package/templates/app/backend/app/Http/Controllers/Auth/PasswordResetLinkController.js +1 -1
  44. package/templates/app/backend/app/Http/Controllers/Auth/RegisteredUserController.js +1 -1
  45. package/templates/app/backend/app/Http/Controllers/Auth/SessionController.js +1 -1
  46. package/templates/app/backend/app/Http/Controllers/Auth/TwoFactorController.js +1 -1
  47. package/templates/app/backend/app/Http/Controllers/ProfileController.js +1 -1
  48. package/templates/app/backend/app/Http/Middleware/RequirePassword.js +1 -1
  49. package/templates/app/frontend/{App.kreftjs → App.kreft} +1 -1
  50. package/templates/app/frontend/components/profile/{ApiTokens.kreftjs → ApiTokens.kreft} +1 -1
  51. package/templates/app/frontend/components/profile/{Sessions.kreftjs → Sessions.kreft} +1 -1
  52. package/templates/app/frontend/components/profile/{TwoFactor.kreftjs → TwoFactor.kreft} +1 -1
  53. package/templates/app/frontend/errors/{ErrorMonitor.kreftjs → ErrorMonitor.kreft} +3 -3
  54. package/templates/app/frontend/index.html +8 -8
  55. package/templates/app/frontend/kreftjs.d.ts +15 -27
  56. package/templates/app/frontend/kreftjs.js +69 -79
  57. package/templates/app/frontend/layouts/{docs.kreftjs → docs.kreft} +1 -1
  58. package/templates/app/frontend/pages/{Dashboard.kreftjs → Dashboard.kreft} +1 -1
  59. package/templates/app/frontend/pages/{ErrorMonitor.kreftjs → ErrorMonitor.kreft} +2 -2
  60. package/templates/app/frontend/pages/{Home.kreftjs → Home.kreft} +2 -2
  61. package/templates/app/frontend/pages/{Profile.kreftjs → Profile.kreft} +3 -3
  62. package/templates/app/frontend/routes/web.kreft +34 -0
  63. package/templates/app/frontend/tests/components/{Counter.kreftjs → Counter.kreft} +1 -1
  64. package/templates/app/frontend/tests/pages/About.kreft +12 -0
  65. package/templates/app/frontend/tests/pages/{Test.kreftjs → Test.kreft} +1 -1
  66. package/templates/errors/{401.kreftjs → 401.kreft} +2 -2
  67. package/templates/errors/{402.kreftjs → 402.kreft} +2 -2
  68. package/templates/errors/{403.kreftjs → 403.kreft} +2 -2
  69. package/templates/errors/{404.kreftjs → 404.kreft} +2 -2
  70. package/templates/errors/{419.kreftjs → 419.kreft} +2 -2
  71. package/templates/errors/{429.kreftjs → 429.kreft} +2 -2
  72. package/templates/errors/{500.kreftjs → 500.kreft} +2 -2
  73. package/templates/errors/{503.kreftjs → 503.kreft} +2 -2
  74. package/templates/errors/{ErrorMonitor.kreftjs → ErrorMonitor.kreft} +13 -12
  75. package/templates/errors/{error.kreftjs → error.kreft} +2 -2
  76. package/templates/errors/{minimal.kreftjs → minimal.kreft} +1 -1
  77. package/tools/dev-client.js +2 -2
  78. package/tools/vite-plugin-kreftjs.d.ts +3 -5
  79. package/tools/vite-plugin-kreftjs.js +12 -14
  80. package/templates/app/frontend/routes/web.kreftjs +0 -34
  81. package/templates/app/frontend/tests/pages/About.kreftjs +0 -12
  82. /package/templates/app/frontend/components/{Field.kreftjs → Field.kreft} +0 -0
  83. /package/templates/app/frontend/components/{StatCard.kreftjs → StatCard.kreft} +0 -0
  84. /package/templates/app/frontend/layouts/{app.kreftjs → app.kreft} +0 -0
  85. /package/templates/app/frontend/layouts/{guest.kreftjs → guest.kreft} +0 -0
  86. /package/templates/app/frontend/pages/{Users.kreftjs → Users.kreft} +0 -0
  87. /package/templates/app/frontend/pages/auth/{ConfirmPassword.kreftjs → ConfirmPassword.kreft} +0 -0
  88. /package/templates/app/frontend/pages/auth/{ForgotPassword.kreftjs → ForgotPassword.kreft} +0 -0
  89. /package/templates/app/frontend/pages/auth/{Login.kreftjs → Login.kreft} +0 -0
  90. /package/templates/app/frontend/pages/auth/{Register.kreftjs → Register.kreft} +0 -0
  91. /package/templates/app/frontend/pages/auth/{ResetPassword.kreftjs → ResetPassword.kreft} +0 -0
  92. /package/templates/app/frontend/pages/auth/{VerifyEmail.kreftjs → VerifyEmail.kreft} +0 -0
@@ -22,12 +22,12 @@ Your project cleanly isolates client-side UI (`frontend/`) from server-side busi
22
22
  ```text
23
23
  ├── frontend/ # Public client application (the only folder served to browsers)
24
24
  │ ├── index.html # HTML entry, auth store, router & app bootstrap
25
- │ ├── App.kreftjs # Root reactive shell
26
- │ ├── routes/web.kreftjs # Client-side routes (Dashboard, Users, Profile, Auth)
27
- │ ├── layouts/ # app.kreftjs (authenticated shell) & guest.kreftjs (auth pages)
25
+ │ ├── App.kreft # Root reactive shell
26
+ │ ├── routes/web.kreft # Client-side routes (Dashboard, Users, Profile, Auth)
27
+ │ ├── layouts/ # app.kreft (authenticated shell) & guest.kreft (auth pages)
28
28
  │ ├── pages/ # Route views (Home, Dashboard, Users, Profile, auth/*)
29
- │ ├── components/ # Reusable widgets (Field.kreftjs, StatCard.kreftjs, profile/*)
30
- │ ├── errors/ # Custom HTTP error views (404.kreftjs, 500.kreftjs, ErrorMonitor.kreftjs)
29
+ │ ├── components/ # Reusable widgets (Field.kreft, StatCard.kreft, profile/*)
30
+ │ ├── errors/ # Custom HTTP error views (404.kreft, 500.kreft, ErrorMonitor.kreft)
31
31
  │ ├── docs/ # Built-in copy of the documentation (at /docs); the pages link to PUBLIC_DOCS_URL, http://kreftjs.com
32
32
  │ └── ui.css # Design system tokens & component styles
33
33
  │
@@ -50,7 +50,7 @@ Your project cleanly isolates client-side UI (`frontend/`) from server-side busi
50
50
  Generate full-stack features from the terminal:
51
51
 
52
52
  ```bash
53
- # Generate Model + Migration + Factory + Seeder + Controller + .kreftjs Page + Route:
53
+ # Generate Model + Migration + Factory + Seeder + Controller + .kreft Page + Route:
54
54
  kreft make:model Post --all
55
55
 
56
56
  # Or pick specific layers (-m migration, -f factory, -s seeder, -c controller, -p page, -r route):
@@ -65,7 +65,7 @@ kreft make:observer PostObserver --model Post
65
65
  kreft make:middleware EnsureSubscribed
66
66
  kreft make:job ProcessWebhook
67
67
  kreft make:mail InvoiceReady
68
- kreft make:routes billing # Creates frontend/routes/billing.kreftjs & backend/routes/billing.js
68
+ kreft make:routes billing # Creates frontend/routes/billing.kreft & backend/routes/billing.js
69
69
 
70
70
  # Database & inspection tools:
71
71
  kreftjs db:migrate # Run pending migrations
@@ -77,12 +77,12 @@ kreft tinker # Interactive REPL with your Models, DB, Cache
77
77
 
78
78
  ---
79
79
 
80
- ## Writing `.kreftjs` Components
80
+ ## Writing `.kreft` Components
81
81
 
82
- Every `.kreftjs` file combines reactive state, actions, `<view>`, and optional `<style scoped>`:
82
+ Every `.kreft` file combines reactive state, actions, `<view>`, and optional `<style scoped>`:
83
83
 
84
84
  ```html
85
- <!-- frontend/pages/Posts.kreftjs -->
85
+ <!-- frontend/pages/Posts.kreft -->
86
86
  state title = ''
87
87
  load posts = api.get('/api/posts')
88
88
 
@@ -8,7 +8,7 @@ APP_KEY=
8
8
  # Where the app runs: links in emails start with this
9
9
  APP_URL=http://localhost:8000
10
10
 
11
- # Only values that start with PUBLIC_ also reach the browser: {env.PUBLIC_APP_NAME} in any .kreftjs file.
11
+ # Only values that start with PUBLIC_ also reach the browser: {env.PUBLIC_APP_NAME} in any .kreft file.
12
12
  # Never put a password or a secret key in a PUBLIC_ value.
13
13
  PUBLIC_APP_NAME="${APP_NAME}"
14
14
  # Where the "Documentation" links of the pages go
@@ -54,7 +54,7 @@ SESSION_EXPIRE_ON_CLOSE=false
54
54
  SESSION_DRIVER=file
55
55
 
56
56
  # Frontend Inactivity Timer in minutes (auto-redirect to /login after inactivity)
57
- # Values starting with PUBLIC_ are sent to the browser and readable as {env.PUBLIC_...} in .kreftjs files
57
+ # Values starting with PUBLIC_ are sent to the browser and readable as {env.PUBLIC_...} in .kreft files
58
58
  PUBLIC_SESSION_TIMEOUT=15
59
59
  PUBLIC_SESSION_WARNING=2
60
60
 
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "files.associations": {
3
- "*.kreftjs": "kreft"
3
+ "*.kreft": "kreftjs",
4
+ "*.kreftjs": "kreftjs"
4
5
  },
5
- "[kreft]": {
6
+ "[kreftjs]": {
6
7
  "editor.defaultFormatter": "kreft.kreftjs",
7
8
  "editor.formatOnSave": true
8
9
  }
@@ -1,7 +1,7 @@
1
1
  const User = require('../../../Models/User')
2
2
  const PersonalAccessToken = require('../../../Models/PersonalAccessToken')
3
3
 
4
- // GET /api/admin/stats (frontend/pages/Dashboard.kreftjs)
4
+ // GET /api/admin/stats (frontend/pages/Dashboard.kreft)
5
5
  class DashboardController {
6
6
  async index(req) {
7
7
  if (!req.user || !req.user.is_admin) {
@@ -25,7 +25,7 @@ class DashboardController {
25
25
  }
26
26
  }
27
27
 
28
- // GET /api/admin/me (frontend/pages/Profile.kreftjs)
28
+ // GET /api/admin/me (frontend/pages/Profile.kreft)
29
29
  async me(req) {
30
30
  return { user: req.user, devices: await PersonalAccessToken.where('user_id', req.user.id).count() }
31
31
  }
@@ -5,7 +5,7 @@ const PersonalAccessToken = require('../../../Models/PersonalAccessToken')
5
5
  // the roles a user can have ('role:editor' in the routes); add your own
6
6
  const ROLES = ['user', 'editor']
7
7
 
8
- // /api/admin/users (frontend/pages/Users.kreftjs)
8
+ // /api/admin/users (frontend/pages/Users.kreft)
9
9
  class UserController {
10
10
  // GET /api/admin/users?q=ali&page=2
11
11
  async index(req) {
@@ -4,7 +4,7 @@ const PersonalAccessToken = require('../../../Models/PersonalAccessToken')
4
4
  // What an API token may do: change this list for your app. 'abilities:posts:write' in a route checks it.
5
5
  const ABILITIES = ['read', 'create', 'update', 'delete']
6
6
 
7
- // API tokens for scripts and other apps (pages/Profile.kreftjs → API tokens), like Jetstream / Sanctum
7
+ // API tokens for scripts and other apps (pages/Profile.kreft → API tokens), like Jetstream / Sanctum
8
8
  class ApiTokenController {
9
9
  // GET /api/user/tokens
10
10
  async index(req) {
@@ -8,7 +8,7 @@ const LoginRequest = require('../../Requests/Auth/LoginRequest')
8
8
  const { signIn, signOut, pendingTwoFactor } = require('../../../Auth/Session')
9
9
 
10
10
  class AuthenticatedSessionController {
11
- // POST /api/login { email, password, remember } (pages/auth/Login.kreftjs)
11
+ // POST /api/login { email, password, remember } (pages/auth/Login.kreft)
12
12
  // with two-factor on, the answer is { two_factor: true } and the code goes to /api/two-factor-challenge
13
13
  async store(req) {
14
14
  const data = await LoginRequest.validate(req)
@@ -1,7 +1,7 @@
1
1
  const { Hash, ValidationError } = require('kreftjs/server')
2
2
 
3
3
  class ConfirmablePasswordController {
4
- // POST /api/confirm-password (pages/auth/ConfirmPassword.kreftjs): opens 'password.confirm' routes for 3 hours
4
+ // POST /api/confirm-password (pages/auth/ConfirmPassword.kreft): opens 'password.confirm' routes for 3 hours
5
5
  async store(req) {
6
6
  const { password } = await req.validate({ password: 'required' })
7
7
  if (!Hash.check(password, req.user.password)) throw new ValidationError({ password: ['The password is incorrect.'] })
@@ -2,7 +2,7 @@ const { Hash, Url, abort, same } = require('kreftjs/server')
2
2
  const User = require('../../../Models/User')
3
3
 
4
4
  class EmailVerificationController {
5
- // POST /api/email/verification-notification: send the link again (pages/auth/VerifyEmail.kreftjs)
5
+ // POST /api/email/verification-notification: send the link again (pages/auth/VerifyEmail.kreft)
6
6
  async send(req) {
7
7
  if (req.user.hasVerifiedEmail()) return { message: 'Your email address is already verified.' }
8
8
  await req.user.sendEmailVerificationNotification()
@@ -5,7 +5,7 @@ const PersonalAccessToken = require('../../../Models/PersonalAccessToken')
5
5
  const MINUTES = 60 // how long a reset link works
6
6
 
7
7
  class NewPasswordController {
8
- // POST /api/reset-password (pages/auth/ResetPassword.kreftjs)
8
+ // POST /api/reset-password (pages/auth/ResetPassword.kreft)
9
9
  async store(req) {
10
10
  const data = await req.validate({
11
11
  token: 'required',
@@ -2,7 +2,7 @@ const { DB, Hash, Str } = require('kreftjs/server')
2
2
  const User = require('../../../Models/User')
3
3
 
4
4
  class PasswordResetLinkController {
5
- // POST /api/forgot-password (pages/auth/ForgotPassword.kreftjs)
5
+ // POST /api/forgot-password (pages/auth/ForgotPassword.kreft)
6
6
  async store(req) {
7
7
  const { email } = await req.validate({ email: 'required|email' })
8
8
  const user = await User.where('email', email.toLowerCase()).first()
@@ -3,7 +3,7 @@ const User = require('../../../Models/User')
3
3
  const { signIn } = require('../../../Auth/Session')
4
4
 
5
5
  class RegisteredUserController {
6
- // POST /api/register (pages/auth/Register.kreftjs)
6
+ // POST /api/register (pages/auth/Register.kreft)
7
7
  async store(req) {
8
8
  const data = await req.validate({
9
9
  name: 'required|string|max:255',
@@ -1,7 +1,7 @@
1
1
  const { noContent, abort } = require('kreftjs/server')
2
2
  const PersonalAccessToken = require('../../../Models/PersonalAccessToken')
3
3
 
4
- // The devices signed in to this account (pages/Profile.kreftjs → Browser sessions)
4
+ // The devices signed in to this account (pages/Profile.kreft → Browser sessions)
5
5
  class SessionController {
6
6
  ensureSession(req) {
7
7
  if (req.accessToken && req.accessToken.type !== 'session' && !req.accessToken.can('*')) {
@@ -1,6 +1,6 @@
1
1
  const { Crypt, TOTP, QR, ValidationError, abort, noContent } = require('kreftjs/server')
2
2
 
3
- // Two-factor authentication with an authenticator app (pages/Profile.kreftjs → Two-factor authentication)
3
+ // Two-factor authentication with an authenticator app (pages/Profile.kreft → Two-factor authentication)
4
4
  class TwoFactorController {
5
5
  ensureSession(req) {
6
6
  if (req.accessToken && req.accessToken.type !== 'session' && !req.accessToken.can('*')) {
@@ -1,7 +1,7 @@
1
1
  const { Hash, ValidationError, noContent, abort } = require('kreftjs/server')
2
2
  const PersonalAccessToken = require('../../Models/PersonalAccessToken')
3
3
 
4
- // pages/Profile.kreftjs
4
+ // pages/Profile.kreft
5
5
  class ProfileController {
6
6
  // GET /api/user: who is signed in
7
7
  async show(req) {
@@ -1,5 +1,5 @@
1
1
  // 'password.confirm' in the routes: the user typed their password again in the last 3 hours
2
- // (pages/auth/ConfirmPassword.kreftjs). Otherwise the answer is 423 and the app asks for it.
2
+ // (pages/auth/ConfirmPassword.kreft). Otherwise the answer is 423 and the app asks for it.
3
3
  const { abort } = require('kreftjs/server')
4
4
 
5
5
  const TIMEOUT = Number(process.env.PASSWORD_TIMEOUT || 10800) // seconds
@@ -1,4 +1,4 @@
1
- <!-- The app: the page for the current route, inside its layout (layouts/app.kreftjs) -->
1
+ <!-- The app: the page for the current route, inside its layout (layouts/app.kreft) -->
2
2
  <view>
3
3
  <kreft-view k-animate.after="fade"></kreft-view>
4
4
  </view>
@@ -1,4 +1,4 @@
1
- <!-- API tokens: for scripts and other apps (Authorization: Bearer …). pages/Profile.kreftjs, /api/user/tokens -->
1
+ <!-- API tokens: for scripts and other apps (Authorization: Bearer …). pages/Profile.kreft, /api/user/tokens -->
2
2
  load tokens = api.get('/api/user/tokens')
3
3
  state name = ''
4
4
  state chosen = ['read']
@@ -1,4 +1,4 @@
1
- <!-- Browser sessions: the devices signed in to this account (pages/Profile.kreftjs, /api/user/sessions) -->
1
+ <!-- Browser sessions: the devices signed in to this account (pages/Profile.kreft, /api/user/sessions) -->
2
2
  load sessions = api.get('/api/user/sessions')
3
3
  state problem = ''
4
4
 
@@ -1,4 +1,4 @@
1
- <!-- Two-factor authentication: a code from an authenticator app after the password (pages/Profile.kreftjs).
1
+ <!-- Two-factor authentication: a code from an authenticator app after the password (pages/Profile.kreft).
2
2
  /api/user/two-factor… in backend/routes/auth.js. Turning it on, off, and the recovery codes ask for the
3
3
  password first (the app goes to /confirm-password and comes back). -->
4
4
  state setup = null // { qr, secret } while turning it on
@@ -1,5 +1,5 @@
1
1
  <!--
2
- ErrorMonitor.kreftjs — Native Kreft Error Inspector & Diagnostic Component
2
+ ErrorMonitor.kreft — Native Kreft Error Inspector & Diagnostic Component
3
3
  Built with Kreft's own geometric design system (ui.css tokens, dark/light theme aware, 1px borders, terminal code view).
4
4
  -->
5
5
  prop error = null
@@ -92,7 +92,7 @@ state docs = (Kreftjs.env.PUBLIC_DOCS_URL || 'http://kreftjs.com').replace(/\/+$
92
92
  <div class="badges">
93
93
  <span class="badge danger-badge">HTTP {status}</span>
94
94
  <span class="badge solid">{currentTitle}</span>
95
- <span class="badge">Kreft {Kreftjs.version || '0.0.7-beta'}</span>
95
+ <span class="badge">Kreft {Kreftjs.version || '0.0.9-beta'}</span>
96
96
  </div>
97
97
  <div class="actions">
98
98
  <button class="sm" @click={copyReport}>{copied ? 'Copied Markdown' : 'Copy Report'}</button>
@@ -189,7 +189,7 @@ state docs = (Kreftjs.env.PUBLIC_DOCS_URL || 'http://kreftjs.com').replace(/\/+$
189
189
  <h3>Kreft Runtime</h3>
190
190
  <table>
191
191
  <tbody>
192
- <tr><th>Engine</th><td><code>Kreft v{Kreftjs.version || '0.0.7-beta'}</code></td></tr>
192
+ <tr><th>Engine</th><td><code>Kreft v{Kreftjs.version || '0.0.9-beta'}</code></td></tr>
193
193
  <tr><th>Sanitizer</th><td><code>Active (cleanHtml / SafeHtml)</code></td></tr>
194
194
  <tr><th>Environment</th><td><code>development (APP_DEBUG=true)</code></td></tr>
195
195
  </tbody>
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1">
6
- <!-- where the app lives: routes and .kreftjs paths start here -->
6
+ <!-- where the app lives: routes and .kreft paths start here -->
7
7
  <base href="/">
8
8
  <title>My Kreft app</title>
9
9
  <link rel="preconnect" href="https://fonts.googleapis.com">
@@ -31,9 +31,9 @@
31
31
  }, { saved: ['user'] })
32
32
 
33
33
  const router = Kreftjs.router({
34
- routes: ['routes/web.kreftjs'], // the pages are in routes/web.kreftjs; add more files: kreft make:routes admin
35
- layout: 'app', // every page goes inside layouts/app.kreftjs…
36
- errors: 'errors', // error pages: errors/404.kreftjs for unknown addresses, abort(403) → errors/403.kreftjs
34
+ routes: ['routes/web.kreft'], // the pages are in routes/web.kreft; add more files: kreft make:routes admin
35
+ layout: 'app', // every page goes inside layouts/app.kreft…
36
+ errors: 'errors', // error pages: errors/404.kreft for unknown addresses, abort(403) → errors/403.kreft
37
37
  // the names routes use in .middleware(…): return an address to send the visitor there instead
38
38
  middleware: {
39
39
  auth: (to) => (auth.user ? true : '/login?redirect=' + encodeURIComponent(to.fullPath)),
@@ -68,10 +68,10 @@
68
68
  )
69
69
  }
70
70
 
71
- Kreftjs.app('App.kreftjs')
72
- .component('Field', 'components/Field.kreftjs')
73
- .component('StatCard', 'components/StatCard.kreftjs')
74
- .component('Counter', 'tests/components/Counter.kreftjs')
71
+ Kreftjs.app('App.kreft')
72
+ .component('Field', 'components/Field.kreft')
73
+ .component('StatCard', 'components/StatCard.kreft')
74
+ .component('Counter', 'tests/components/Counter.kreft')
75
75
  .use(router)
76
76
  .mount('#app')
77
77
  </script>
@@ -1,4 +1,4 @@
1
- // Type definitions for Kreft 0.0.7-beta
1
+ // Type definitions for Kreft 0.0.9-beta
2
2
  // Use from TypeScript or for editor hints in plain JavaScript (// @ts-check).
3
3
 
4
4
  export interface Signal<T> { value: T }
@@ -212,7 +212,7 @@ export interface ComponentDef {
212
212
  destroyed?(): void
213
213
  [key: string]: any
214
214
  }
215
- /** A component: an object, an init function, a lazy() loader or the address of a .kreftjs file */
215
+ /** A component: an object, an init function, a lazy() loader or the address of a .kreft file */
216
216
  export type Component = ComponentDef | ((props: any, ctx: Context) => object | void) | LazyComponent | string
217
217
  export interface LazyComponent { __loader: () => Promise<any> }
218
218
 
@@ -248,7 +248,7 @@ export interface RouteRecord {
248
248
  guard?: Guard
249
249
  /** Child routes, shown in the page's own <kreft-view> */
250
250
  children?: RouteRecord[]
251
- /** The layout for this route and its children: 'admin' → layouts/admin.kreftjs, a .kreftjs path, a component, or false for none */
251
+ /** The layout for this route and its children: 'admin' → layouts/admin.kreft, a .kreft path, a component, or false for none */
252
252
  layout?: string | Component | false
253
253
  }
254
254
  export interface Route {
@@ -266,7 +266,7 @@ export type RouteTarget = string | { path?: string; name?: string; params?: Reco
266
266
  export type Guard = (to: Route, from: Route) => boolean | void | RouteTarget | Promise<boolean | void | RouteTarget>
267
267
  export interface Router {
268
268
  readonly route: Route
269
- /** shows errors/<status>.kreftjs for this address: abort(403, 'Only the owner can see this.') */
269
+ /** shows errors/<status>.kreft for this address: abort(403, 'Only the owner can see this.') */
270
270
  abort(status?: number, message?: string): void
271
271
  readonly routes: RouteRecord[]
272
272
  go(to: RouteTarget | number): Promise<void> | void
@@ -282,7 +282,7 @@ export interface Router {
282
282
  ready(): Promise<void>
283
283
  install(app: App): void
284
284
  }
285
- /** routes/web.kreftjs: `Route` is there without an import */
285
+ /** routes/web.kreft: `Route` is there without an import */
286
286
  export interface RouteEntry {
287
287
  name(name: string): RouteEntry
288
288
  title(title: string): RouteEntry
@@ -307,7 +307,7 @@ export interface RouteGroup {
307
307
  group(fn: (route: RouteFile) => void): RouteFile
308
308
  }
309
309
  export interface RouteFile {
310
- /** a page: Route.view('/posts/:id', 'pages/Post.kreftjs') — :id reaches the page as a prop */
310
+ /** a page: Route.view('/posts/:id', 'pages/Post.kreft') — :id reaches the page as a prop */
311
311
  view(path: string, component: string | Component): RouteEntry
312
312
  get(path: string, component: string | Component): RouteEntry
313
313
  redirect(from: string, to: string): void
@@ -325,25 +325,25 @@ export interface RouteFile {
325
325
  export type RouteMiddleware = (to: Route, from: Route, ...args: string[]) => boolean | string | object | void | Promise<boolean | string | object | void>
326
326
 
327
327
  export interface RouterOptions {
328
- /** route objects, or route files: 'routes/web.kreftjs' / ['routes/web.kreftjs', 'routes/admin.kreftjs'] (both can be mixed) */
328
+ /** route objects, or route files: 'routes/web.kreft' / ['routes/web.kreft', 'routes/admin.kreft'] (both can be mixed) */
329
329
  routes: RouteRecord[] | string | (string | RouteRecord)[]
330
330
  /** the names routes use in .middleware(…): { auth: (to) => auth.token ? true : '/login' } */
331
331
  middleware?: Record<string, RouteMiddleware>
332
332
  mode?: 'history' | 'hash'
333
333
  base?: string
334
334
  scrollToTop?: boolean
335
- /** The layout every page goes in: 'app' → layouts/app.kreftjs (a page's `layout x`, or a route's `layout`, wins) */
335
+ /** The layout every page goes in: 'app' → layouts/app.kreft (a page's `layout x`, or a route's `layout`, wins) */
336
336
  layout?: string | Component | false
337
- /** Names for layouts that live elsewhere: { admin: 'views/AdminShell.kreftjs' } */
337
+ /** Names for layouts that live elsewhere: { admin: 'views/AdminShell.kreft' } */
338
338
  layouts?: Record<string, string | Component>
339
- /** The folder with the error pages (errors/404.kreftjs, 403, 500…): unknown addresses show 404.kreftjs, abort(…) the others */
339
+ /** The folder with the error pages (errors/404.kreft, 403, 500…): unknown addresses show 404.kreft, abort(…) the others */
340
340
  errors?: string | boolean
341
341
  }
342
342
 
343
343
  /* ---------------- Kreft ---------------- */
344
344
  export interface KreftStatic {
345
345
  readonly version: string
346
- /** PUBLIC_ values from .env (also `env` in .kreftjs files). Never secrets: those stay in server code */
346
+ /** PUBLIC_ values from .env (also `env` in .kreft files). Never secrets: those stay in server code */
347
347
  readonly env: Readonly<Record<string, string>>
348
348
  /** true when running inside an Electron desktop window */
349
349
  readonly isElectron: boolean
@@ -354,15 +354,13 @@ export interface KreftStatic {
354
354
  __makeDef(parts: any, values?: any): ComponentDef
355
355
  __registerDef(path: string, def: any): any
356
356
  __hotDef(id: string, newDef: any): boolean
357
- /** the error page for this address: abort(404), abort(403, 'Only the owner can see this.') (also `abort` in .kreftjs files) */
357
+ /** the error page for this address: abort(404), abort(403, 'Only the owner can see this.') (also `abort` in .kreft files) */
358
358
  abort(status?: number, message?: string): void
359
359
  app(root?: Component, props?: Record<string, any>): App
360
360
  lazy(loader: () => Promise<any>): LazyComponent
361
361
  load(url: string): Promise<ComponentDef>
362
- /** Compiles the text of a .kreftjs file into a component */
362
+ /** Compiles the text of a .kreft file into a component */
363
363
  compile(source: string, url?: string): Promise<ComponentDef>
364
- /** @deprecated the Som.js name of `compile` */
365
- compileSom(source: string, url?: string): Promise<ComponentDef>
366
364
  /** Strips TypeScript type annotations, interfaces, type aliases and enums from source code while preserving line numbers */
367
365
  stripTypeScript(source: string): string
368
366
  /** The template engine: a view and data → an HTML string */
@@ -552,28 +550,18 @@ declare global {
552
550
  var Kreftjs: KreftStatic
553
551
  /** the shorter name of `Kreftjs` */
554
552
  var Kreft: KreftStatic
555
- /** @deprecated the Som.js name of `Kreftjs` */
556
- var Som: KreftStatic
557
553
  interface Window {
558
554
  kreftDesktop?: DesktopBridge
559
- /** @deprecated the Som.js name of `kreftDesktop` */
560
- somDesktop?: DesktopBridge
561
555
  }
562
556
  }
563
557
 
564
- declare module '*.kreftjs' {
565
- const component: import('./kreftjs.js').ComponentDef
566
- export default component
567
- }
568
-
569
- // files from older projects (.kreft, then Som.js's .som)
570
558
  declare module '*.kreft' {
571
559
  const component: import('./kreftjs.js').ComponentDef
572
560
  export default component
573
561
  }
574
562
 
575
- declare module '*.som' {
563
+ // files from the 0.0.x betas (.kreftjs)
564
+ declare module '*.kreftjs' {
576
565
  const component: import('./kreftjs.js').ComponentDef
577
566
  export default component
578
567
  }
579
-