@kokimoki/kit 1.6.7 → 1.7.0
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 +76 -0
- package/dist/api.d.ts +63 -0
- package/dist/api.js +95 -0
- package/dist/credentials.d.ts +25 -0
- package/dist/credentials.js +44 -0
- package/dist/dev-app.d.ts +57 -0
- package/dist/dev-app.js +271 -0
- package/dist/dev-frame/index.d.ts +5 -0
- package/dist/dev-frame/index.js +9 -0
- package/dist/dev-frame/render-dev-frame.d.ts +30 -0
- package/dist/dev-frame/render-dev-frame.js +160 -0
- package/dist/dev-frame/styles.d.ts +4 -0
- package/dist/dev-frame/styles.js +191 -0
- package/dist/dev-i18n.d.ts +56 -0
- package/dist/dev-i18n.js +164 -0
- package/dist/dev-overlays.d.ts +19 -0
- package/dist/dev-overlays.js +300 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/kokimoki-kit-plugin.d.ts +47 -4
- package/dist/kokimoki-kit-plugin.js +383 -71
- package/dist/production-loading-screen.d.ts +20 -0
- package/dist/production-loading-screen.js +123 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/docs/kokimoki-kit.instructions.md +341 -0
- package/llms.txt +46 -0
- package/package.json +10 -3
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Production loading screen HTML/CSS/JS for kokimoki-kit plugin.
|
|
4
|
+
* This screen is injected into production builds and removed when km:ready is received.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.loadingScreenElement = exports.loadingScreenScript = exports.loadingScreenStyles = void 0;
|
|
8
|
+
exports.removeExistingLoadingScreen = removeExistingLoadingScreen;
|
|
9
|
+
/**
|
|
10
|
+
* Loading screen styles
|
|
11
|
+
*/
|
|
12
|
+
exports.loadingScreenStyles = `
|
|
13
|
+
<style id="km-loading-style">
|
|
14
|
+
#km-loading {
|
|
15
|
+
position: fixed;
|
|
16
|
+
inset: 0;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
align-items: center;
|
|
20
|
+
justify-content: center;
|
|
21
|
+
gap: 1.5rem;
|
|
22
|
+
background: #fff;
|
|
23
|
+
z-index: 9999;
|
|
24
|
+
transition: opacity 0.3s ease-out;
|
|
25
|
+
color: #1a1a2e;
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
}
|
|
28
|
+
#km-loading.km-ready {
|
|
29
|
+
opacity: 0;
|
|
30
|
+
pointer-events: none;
|
|
31
|
+
}
|
|
32
|
+
#km-loading .km-spinner {
|
|
33
|
+
height: 2rem;
|
|
34
|
+
animation: km-spin 1s linear infinite;
|
|
35
|
+
}
|
|
36
|
+
#km-loading .km-logo {
|
|
37
|
+
height: 3rem;
|
|
38
|
+
}
|
|
39
|
+
#km-loading .km-powered {
|
|
40
|
+
font-size: 0.75rem;
|
|
41
|
+
font-weight: 600;
|
|
42
|
+
opacity: 0.65;
|
|
43
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
44
|
+
}
|
|
45
|
+
@keyframes km-spin {
|
|
46
|
+
to { transform: rotate(360deg); }
|
|
47
|
+
}
|
|
48
|
+
</style>`;
|
|
49
|
+
/**
|
|
50
|
+
* km:ready listener script with 3s minimum display time
|
|
51
|
+
*/
|
|
52
|
+
exports.loadingScreenScript = `
|
|
53
|
+
<script>
|
|
54
|
+
(function() {
|
|
55
|
+
var startTime = Date.now();
|
|
56
|
+
var minDisplayTime = 3000;
|
|
57
|
+
var appReady = false;
|
|
58
|
+
|
|
59
|
+
function hideLoading() {
|
|
60
|
+
var el = document.getElementById('km-loading');
|
|
61
|
+
var style = document.getElementById('km-loading-style');
|
|
62
|
+
if (el) {
|
|
63
|
+
el.classList.add('km-ready');
|
|
64
|
+
setTimeout(function() {
|
|
65
|
+
el.remove();
|
|
66
|
+
if (style) style.remove();
|
|
67
|
+
}, 300);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function tryHide() {
|
|
72
|
+
if (!appReady) return;
|
|
73
|
+
var elapsed = Date.now() - startTime;
|
|
74
|
+
var remaining = Math.max(0, minDisplayTime - elapsed);
|
|
75
|
+
setTimeout(hideLoading, remaining);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
window.addEventListener('message', function(e) {
|
|
79
|
+
if (e.data === 'km:ready' && !appReady) {
|
|
80
|
+
appReady = true;
|
|
81
|
+
tryHide();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
})();
|
|
85
|
+
</script>`;
|
|
86
|
+
/**
|
|
87
|
+
* Loading screen HTML element with Games for Crowds branding
|
|
88
|
+
*/
|
|
89
|
+
exports.loadingScreenElement = `<a href="https://gamesforcrowds.com" target="_blank" id="km-loading">
|
|
90
|
+
<svg class="km-spinner" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
91
|
+
<path fill="currentColor" d="M12 22q-2.05 0-3.875-.788t-3.187-2.15t-2.15-3.187T2 12q0-2.075.788-3.887t2.15-3.175t3.187-2.15T12 2q.425 0 .713.288T13 3t-.288.713T12 4Q8.675 4 6.337 6.338T4 12t2.338 5.663T12 20t5.663-2.337T20 12q0-.425.288-.712T21 11t.713.288T22 12q0 2.05-.788 3.875t-2.15 3.188t-3.175 2.15T12 22"/>
|
|
92
|
+
</svg>
|
|
93
|
+
<svg class="km-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 797.59 219.07" fill="currentColor">
|
|
94
|
+
<g>
|
|
95
|
+
<path d="M162.8,96.03c30.87-26.51,10.41-92.22-28.46-95.03-29.39-2.13-60.31-.26-90.99.07-.73,0-1.45-.02-2.17.09C20.3,4.26,3.91,21.33.05,41.8l-.05,123.54c2.6,4.28,5.58,6,10.54,3.94,6.74-3.82,26.58-29.17,31.77-30.22,1.69-.34,3.72.1,5.48-.03-1.15,26.53,19.87,47.52,45.62,49.88,10.24.94,31.34-1.93,39.43.57,8.71,2.7,26.57,28.84,33.53,29.55,3.29.34,7.74-2.14,8.38-5.52,1.72-9.15-2.16-26.7.23-34.77.33-1.1,7.39-8.47,9.02-10.98,16.21-24.98,7.36-61.07-21.22-71.74ZM50.83,121.59l-15.96,2.04-19.08,18.42V46.55c1.67-14.1,15.14-27.27,28.74-30.26,27.33,1.33,57.83-2.6,84.8-.28,20.06,1.73,36.5,34.92,31,55.08-7.53,27.65-45.72,17.08-67.02,18.97-18.52,1.65-36.21,13.88-42.47,31.53ZM170.32,159.08c-1.85,3-10.53,10.69-10.53,11.47v20.5c-1.75.44-2-.72-3.01-1.49-5.71-4.38-11.7-14.4-18.92-16.08-20.43-4.73-47.91,7.68-65.09-10.9-16.98-18.36-8.23-50.63,16.23-55.82,10.35-2.2,44.8-1.74,56.33-.74,24.82,2.14,38.05,31.97,25,53.07Z"/>
|
|
96
|
+
<polygon points="573.74 181.88 556.14 122.98 538.69 122.81 519.73 181.89 501.74 122.88 481.24 122.88 508.73 212.9 525.78 213.95 527.35 213.29 545.25 152.88 564.73 212.9 583.28 213.42 611.24 122.88 590.24 122.88 573.74 181.88"/>
|
|
97
|
+
<path d="M666.74,122.88c-13.74-1.63-30.44,1.21-44.5,0v91h40.5c2.92,0,11.75-2.85,14.86-4.14,38.57-16.14,31.3-81.86-10.86-86.86ZM678.08,187.22c-2.88,4.2-11.41,9.66-16.34,9.66h-20.5v-58c6.18.55,13.48-.75,19.5,0,22.38,2.79,28.85,31.55,17.34,48.34Z"/>
|
|
98
|
+
<path d="M425,121.14c-41.35,5.24-51.11,67.28-16.45,87.94,28.45,16.96,67.81.39,70.73-33.66,2.97-34.62-18.81-58.77-54.28-54.28ZM427.98,198.64c-27.94-4.46-28.04-57.3,1.02-61.5,40.78-5.9,43.14,68.55-1.02,61.5Z"/>
|
|
99
|
+
<path d="M363.48,127.14c-1.58-.84-10.61-4.26-11.74-4.26h-41.5v91h19v-33l11.58.92,18.92,32.08h21.5l-20.99-35.44c19.78-8.94,22.88-40.88,3.23-51.3ZM355.77,157.91c-1.32,4.05-6.98,7.97-11.02,7.97h-15.5v-27c5.36.62,12.39-.85,17.5,0,9.11,1.51,11.57,11.21,9.02,19.03Z"/>
|
|
100
|
+
<path d="M777.02,179.61c-3.95-19.44-32.26-17.78-42.74-26.26-5.4-4.37-4.24-12.34,1.69-15.23,9.47-4.61,20.58,1.49,27.6,7.63l12.65-9.36c-10.04-12.51-23.17-17.41-39.22-15.24-28.56,3.86-35.71,38.53-7.02,50.5,9.33,3.89,33.09,5.53,28.6,20.07-3.99,12.93-29.66,6.57-35.83-2.65l-12.44,11.18c19.81,25.44,74.88,19.65,66.7-20.64Z"/>
|
|
101
|
+
<path d="M267.5,198.64c-41.37,7.02-43.83-58.8-9.75-61.75,10.54-.91,17.28,3.56,24.13,10.88l14.35-7.92c-9.32-19.99-38.11-23.5-56.51-14.99-32.89,15.21-33.7,69.52-.86,85.89,19.28,9.61,48.03,5.78,58.38-14.86l-12.64-7.94c-5.5,3.74-10.09,9.5-17.1,10.69Z"/>
|
|
102
|
+
<path d="M433.4,44.09l21.29,35.46c2.72,2.8,9.85,1.78,13.55,1.07l22.47-37.65v59.55h21.35V4.76l-20.8,1.11-27.53,50.58-29.76-51.69h-20.79v97.76h20.23v-58.43Z"/>
|
|
103
|
+
<path d="M306.43,48.58h-42.7v16.85h21.35c-.27,13.22-7.04,21.88-20.74,22.52-41.54,1.94-38.23-76.19,5.07-66.97,7.84,1.67,10.69,7.85,16.21,11.88l15.05-8.01c-.07-9-13.02-17.18-20.95-19.79-43.1-14.17-73.97,23.73-63.98,65.1,11.75,48.67,85.6,47.68,90.69-4.17.54-5.55-.39-11.78,0-17.42Z"/>
|
|
104
|
+
<path d="M340.09,81.68l33.82-.02,6.67,20.85h23.6L368.81,5.87c-1.88-2.26-20.12-1.02-24.2-.56l-34.81,97.22h23.6l6.7-20.83ZM356.43,29.47l10.67,34.84h-21.35l10.67-34.84Z"/>
|
|
105
|
+
<polygon points="590.71 84.54 551.39 84.54 551.39 60.94 585.1 60.94 585.1 42.96 551.39 42.96 551.39 22.74 588.47 22.74 588.47 4.76 530.04 4.76 530.04 102.52 590.71 102.52 590.71 84.54"/>
|
|
106
|
+
<path d="M608.77,97.39c25.08,16.57,67.45,5.44,61.46-30-1.89-11.15-12.36-17.09-21.93-20.77-7.64-2.94-35.54-8.52-22.36-22.37,8.09-8.51,23.15-1.69,30.32,5.07,2.52-1.37,13.45-9.1,13.04-11.48-14.3-20.97-60.08-20.5-65.72,7.08-2.89,14.13,1.82,25,14.48,31.72,10.24,5.44,38.71,7.15,31.37,24.24-3.47,8.09-18.1,7.13-25,4.22-4.16-1.76-9.85-8.71-12.66-8.29-2.01.3-13.33,8.46-13.03,10.32.38,2.39,7.73,8.73,10.04,10.25Z"/>
|
|
107
|
+
</g>
|
|
108
|
+
<g>
|
|
109
|
+
<path fill="#3c63e7" d="M735,55.98c-24.25,4.14-27.28,47.44,1.59,47.65,31.23.23,35.57-53.99-1.59-47.65ZM734.29,92.39c-9.51-2.94-5.29-24.14,2.49-26.5,16.88-5.12,14.38,31.73-2.49,26.5Z"/>
|
|
110
|
+
<path fill="#3c63e7" d="M716.28,56.67c-3.34-.27-7.15.39-10.41,0-1.21-.14-1.64.47-1.24-1.25,1.77-7.6,5.49-10.69,13.44-7.79l.86-10.79c-14.12-3.91-26.67,3.85-26.53,18.98l-8.25,1.69-1.3,9.08,8.13.02-3.61,36.13,12.26-.85,4.05-35.24h11.1c1.99-.47,1.49-8.28,1.51-9.99Z"/>
|
|
111
|
+
<path fill="#3c63e7" d="M796.72,56.17c-6.86-1.78-12.48,2-15.87,7.73l.45-7.22h-11.74s-4.51,46.06-4.51,46.06h12.65c2.16-13.01-1.47-38.8,18.96-34.32-.94-2.92,2.45-10.57.06-12.25Z"/>
|
|
112
|
+
</g>
|
|
113
|
+
</svg>
|
|
114
|
+
<p class="km-powered">Powered by Kokimoki</p>
|
|
115
|
+
</a>`;
|
|
116
|
+
/**
|
|
117
|
+
* Removes any existing km-loading elements from HTML
|
|
118
|
+
*/
|
|
119
|
+
function removeExistingLoadingScreen(html) {
|
|
120
|
+
return html
|
|
121
|
+
.replace(/<div[^>]*id=["']km-loading["'][^>]*>[\s\S]*?<\/div>/gi, "")
|
|
122
|
+
.replace(/<style[^>]*id=["']km-loading-style["'][^>]*>[\s\S]*?<\/style>/gi, "");
|
|
123
|
+
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const KOKIMOKI_KIT_VERSION = "1.
|
|
1
|
+
export declare const KOKIMOKI_KIT_VERSION = "1.7.0";
|
package/dist/version.js
CHANGED
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Vite plugin and development tools for Kokimoki apps
|
|
3
|
+
applyTo: "**/vite.config.{ts,js,mts,mjs}"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Kokimoki Kit
|
|
7
|
+
|
|
8
|
+
The `@kokimoki/kit` package provides the Vite plugin and development tools for building Kokimoki apps.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @kokimoki/kit
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Plugin Configuration
|
|
17
|
+
|
|
18
|
+
Add the plugin to your `vite.config.ts`:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import { defineConfig } from "vite";
|
|
22
|
+
import { kokimokiKitPlugin } from "@kokimoki/kit";
|
|
23
|
+
import { z } from "@kokimoki/kit";
|
|
24
|
+
|
|
25
|
+
export default defineConfig({
|
|
26
|
+
plugins: [
|
|
27
|
+
kokimokiKitPlugin({
|
|
28
|
+
// Required: Your concept ID from Kokimoki
|
|
29
|
+
conceptId: "your-concept-id",
|
|
30
|
+
|
|
31
|
+
// Required: Deploy configurations
|
|
32
|
+
deployCodes: [
|
|
33
|
+
{
|
|
34
|
+
name: "default",
|
|
35
|
+
description: "Default game mode",
|
|
36
|
+
clientContext: { mode: "standard" },
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "tournament",
|
|
40
|
+
description: "Tournament mode with stricter rules",
|
|
41
|
+
clientContext: { mode: "tournament", maxPlayers: 100 },
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
|
|
45
|
+
// Optional: Project config schema (validated in admin panel)
|
|
46
|
+
schema: z.object({
|
|
47
|
+
title: z.string(),
|
|
48
|
+
maxPlayers: z.number().min(2).max(100),
|
|
49
|
+
timeLimit: z.number().optional(),
|
|
50
|
+
}),
|
|
51
|
+
|
|
52
|
+
// Optional: Store schemas for validation
|
|
53
|
+
stores: [
|
|
54
|
+
{
|
|
55
|
+
pattern: "game",
|
|
56
|
+
schema: z.object({
|
|
57
|
+
status: z.enum(["waiting", "playing", "finished"]),
|
|
58
|
+
round: z.number(),
|
|
59
|
+
}),
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
pattern: "player-*",
|
|
63
|
+
schema: z.object({
|
|
64
|
+
name: z.string(),
|
|
65
|
+
score: z.number(),
|
|
66
|
+
}),
|
|
67
|
+
local: true, // Local store (per-client)
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
|
|
71
|
+
// Optional: i18n configuration
|
|
72
|
+
i18nPath: "./src/i18n",
|
|
73
|
+
i18nPrimaryLng: "en", // Source language for AI translations
|
|
74
|
+
|
|
75
|
+
// Optional: Custom API endpoint
|
|
76
|
+
endpoint: "https://api.kokimoki.com",
|
|
77
|
+
host: "y-wss.kokimoki.com",
|
|
78
|
+
|
|
79
|
+
// Optional: Dev view layout (see Dev Frame section)
|
|
80
|
+
devView: [
|
|
81
|
+
[{ label: "host", clientContext: { mode: "host" } }],
|
|
82
|
+
[
|
|
83
|
+
{ label: "player1", clientContext: { mode: "player" } },
|
|
84
|
+
{ label: "player2", clientContext: { mode: "player" } },
|
|
85
|
+
],
|
|
86
|
+
],
|
|
87
|
+
}),
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration Options
|
|
93
|
+
|
|
94
|
+
### Required Options
|
|
95
|
+
|
|
96
|
+
| Option | Type | Description |
|
|
97
|
+
| ------------- | -------- | --------------------------------- |
|
|
98
|
+
| `conceptId` | `string` | Your concept ID from Kokimoki |
|
|
99
|
+
| `deployCodes` | `array` | List of deployment configurations |
|
|
100
|
+
|
|
101
|
+
### Optional Options
|
|
102
|
+
|
|
103
|
+
| Option | Type | Description |
|
|
104
|
+
| -------------------------- | ---------------- | -------------------------------------------------- |
|
|
105
|
+
| `schema` | `ZodType` | Zod schema for project configuration |
|
|
106
|
+
| `stores` | `array` | Store definitions with patterns and schemas |
|
|
107
|
+
| `i18nPath` | `string` | Path to i18n folder (e.g., `./src/i18n`) |
|
|
108
|
+
| `i18nPrimaryLng` | `string` | Source language code (default: `"en"`) |
|
|
109
|
+
| `endpoint` | `string` | API endpoint (default: `https://api.kokimoki.com`) |
|
|
110
|
+
| `host` | `string` | WebSocket host (default: `y-wss.kokimoki.com`) |
|
|
111
|
+
| `devView` | `array \| false` | Dev frame layout or `false` to disable |
|
|
112
|
+
| `defaultProjectConfigPath` | `string` | Path to default project config file |
|
|
113
|
+
| `defaultProjectStylePath` | `string` | Path to default project style file |
|
|
114
|
+
|
|
115
|
+
## Dev Frame
|
|
116
|
+
|
|
117
|
+
The dev frame provides a multi-window view for testing different player modes simultaneously during development.
|
|
118
|
+
|
|
119
|
+
### Configuration
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
devView: [
|
|
123
|
+
// Row 1: Host and presenter
|
|
124
|
+
[
|
|
125
|
+
{ label: "host", clientContext: { mode: "host", playerCode: "admin" } },
|
|
126
|
+
{ label: "presenter", clientContext: { mode: "presenter" } },
|
|
127
|
+
],
|
|
128
|
+
// Row 2: Three players
|
|
129
|
+
[
|
|
130
|
+
{ label: "player1", clientContext: { mode: "player" } },
|
|
131
|
+
{ label: "player2", clientContext: { mode: "player" } },
|
|
132
|
+
{ label: "player3", clientContext: { mode: "player" } },
|
|
133
|
+
],
|
|
134
|
+
];
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### DevFrameCell Interface
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
interface DevFrameCell {
|
|
141
|
+
/** Label shown in the frame header (must be unique) */
|
|
142
|
+
label: string;
|
|
143
|
+
/** Client context passed to the app via URL */
|
|
144
|
+
clientContext: unknown;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Features
|
|
149
|
+
|
|
150
|
+
- **Grid layout**: Each inner array is a row of frames
|
|
151
|
+
- **Unique labels**: Each cell must have a unique label
|
|
152
|
+
- **New tab button**: Open any frame in a separate tab
|
|
153
|
+
- **Reset button**: Clear frame's local storage and reload
|
|
154
|
+
- **Error overlay**: Shows errors with reload option
|
|
155
|
+
|
|
156
|
+
### Disabling Dev Frame
|
|
157
|
+
|
|
158
|
+
Set `devView: false` to disable the dev frame entirely:
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
kokimokiKitPlugin({
|
|
162
|
+
conceptId: "...",
|
|
163
|
+
deployCodes: [...],
|
|
164
|
+
devView: false,
|
|
165
|
+
})
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Store Schemas
|
|
169
|
+
|
|
170
|
+
Define schemas to validate store state during development:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
stores: [
|
|
174
|
+
// Global store - shared across all clients
|
|
175
|
+
{
|
|
176
|
+
pattern: "game",
|
|
177
|
+
schema: z.object({
|
|
178
|
+
status: z.enum(["waiting", "playing", "finished"]),
|
|
179
|
+
players: z.record(
|
|
180
|
+
z.string(),
|
|
181
|
+
z.object({
|
|
182
|
+
name: z.string(),
|
|
183
|
+
score: z.number(),
|
|
184
|
+
})
|
|
185
|
+
),
|
|
186
|
+
}),
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
// Wildcard pattern - matches player-abc123, player-xyz789, etc.
|
|
190
|
+
{
|
|
191
|
+
pattern: "player-*",
|
|
192
|
+
schema: z.object({
|
|
193
|
+
name: z.string(),
|
|
194
|
+
avatar: z.string().optional(),
|
|
195
|
+
}),
|
|
196
|
+
local: true, // Local store (client-specific)
|
|
197
|
+
},
|
|
198
|
+
|
|
199
|
+
// Dynamic stores - chat rooms, teams, etc.
|
|
200
|
+
{
|
|
201
|
+
pattern: "chat-*",
|
|
202
|
+
schema: z.object({
|
|
203
|
+
messages: z.record(
|
|
204
|
+
z.string(),
|
|
205
|
+
z.object({
|
|
206
|
+
text: z.string(),
|
|
207
|
+
sender: z.string(),
|
|
208
|
+
})
|
|
209
|
+
),
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
212
|
+
];
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## i18n Integration
|
|
216
|
+
|
|
217
|
+
The plugin syncs translations to your dev app automatically.
|
|
218
|
+
|
|
219
|
+
### Folder Structure
|
|
220
|
+
|
|
221
|
+
```
|
|
222
|
+
src/i18n/
|
|
223
|
+
├── en/
|
|
224
|
+
│ ├── ui.json
|
|
225
|
+
│ └── game.json
|
|
226
|
+
├── et/
|
|
227
|
+
│ ├── ui.json
|
|
228
|
+
│ └── game.json
|
|
229
|
+
└── de/
|
|
230
|
+
├── ui.json
|
|
231
|
+
└── game.json
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Configuration
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
kokimokiKitPlugin({
|
|
238
|
+
// ...
|
|
239
|
+
i18nPath: "./src/i18n",
|
|
240
|
+
i18nPrimaryLng: "en", // Source language for AI translations
|
|
241
|
+
});
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### HMR Support
|
|
245
|
+
|
|
246
|
+
- Translation files are watched for changes
|
|
247
|
+
- Changes are synced to the dev app in real-time
|
|
248
|
+
- No need to restart the dev server
|
|
249
|
+
|
|
250
|
+
## Zod Re-export
|
|
251
|
+
|
|
252
|
+
The kit re-exports Zod for convenience:
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
import { z } from "@kokimoki/kit";
|
|
256
|
+
|
|
257
|
+
const mySchema = z.object({
|
|
258
|
+
name: z.string(),
|
|
259
|
+
count: z.number(),
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Project Files
|
|
264
|
+
|
|
265
|
+
### .kokimoki Directory
|
|
266
|
+
|
|
267
|
+
The plugin creates a `.kokimoki` directory in your project root:
|
|
268
|
+
|
|
269
|
+
```
|
|
270
|
+
.kokimoki/
|
|
271
|
+
├── app-id # Dev app ID (cached)
|
|
272
|
+
└── stores-hash # Hash of store schemas (for change detection)
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
**Add to `.gitignore`:**
|
|
276
|
+
|
|
277
|
+
```gitignore
|
|
278
|
+
.kokimoki/
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Credentials
|
|
282
|
+
|
|
283
|
+
Global credentials are stored in `~/.kokimoki`:
|
|
284
|
+
|
|
285
|
+
```json
|
|
286
|
+
{
|
|
287
|
+
"apiKeys": {
|
|
288
|
+
"org-id-1": "api-key-1",
|
|
289
|
+
"org-id-2": "api-key-2"
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
Use `npx @kokimoki/cli login` to authenticate.
|
|
295
|
+
|
|
296
|
+
## Style Preprocessing
|
|
297
|
+
|
|
298
|
+
The plugin processes CSS files with theme color variables:
|
|
299
|
+
|
|
300
|
+
- Converts color names to hex values
|
|
301
|
+
- Generates RGB tuple variables for opacity support
|
|
302
|
+
- Processes palette color scales (50-900)
|
|
303
|
+
|
|
304
|
+
### Supported Variables
|
|
305
|
+
|
|
306
|
+
```css
|
|
307
|
+
:root {
|
|
308
|
+
--color-primary-500: #3b82f6;
|
|
309
|
+
--color-secondary-500: #10b981;
|
|
310
|
+
--on-primary: 255 255 255;
|
|
311
|
+
--on-secondary: 255 255 255;
|
|
312
|
+
}
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Production Build
|
|
316
|
+
|
|
317
|
+
During production builds, the plugin:
|
|
318
|
+
|
|
319
|
+
1. Validates all store schemas
|
|
320
|
+
2. Generates production loading screen
|
|
321
|
+
3. Embeds i18n metadata for runtime loading
|
|
322
|
+
4. Removes dev frame and development overlays
|
|
323
|
+
|
|
324
|
+
## Error Handling
|
|
325
|
+
|
|
326
|
+
### Common Errors
|
|
327
|
+
|
|
328
|
+
| Error | Cause | Solution |
|
|
329
|
+
| --------------------- | ------------------ | -------------------------------- |
|
|
330
|
+
| `CONCEPT_NOT_FOUND` | Invalid concept ID | Check your `conceptId` in config |
|
|
331
|
+
| `NO_CREDENTIALS` | Not logged in | Run `npx @kokimoki/cli login` |
|
|
332
|
+
| `DEV_APP_INIT_FAILED` | API error | Check network and API endpoint |
|
|
333
|
+
|
|
334
|
+
### Store Schema Changes
|
|
335
|
+
|
|
336
|
+
If you change store schemas, the plugin detects this and shows a warning page with two options:
|
|
337
|
+
|
|
338
|
+
- **Keep Current State**: Dismiss the warning and continue with existing data
|
|
339
|
+
- **Reset State**: Clear the dev app state and localStorage to start fresh
|
|
340
|
+
|
|
341
|
+
No dev server restart is required.
|
package/llms.txt
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Kokimoki Kit Documentation
|
|
2
|
+
|
|
3
|
+
> Documentation for @kokimoki/kit - Vite plugin and development tools for Kokimoki apps.
|
|
4
|
+
|
|
5
|
+
## Instruction Files
|
|
6
|
+
|
|
7
|
+
The following instruction files provide detailed guidance for AI assistants:
|
|
8
|
+
|
|
9
|
+
### Plugin Configuration
|
|
10
|
+
- docs/kokimoki-kit.instructions.md: Complete guide to configuring the Vite plugin, including dev frame setup, store schemas, i18n integration, and style preprocessing.
|
|
11
|
+
|
|
12
|
+
## Key Concepts
|
|
13
|
+
|
|
14
|
+
- **kokimokiKitPlugin**: Vite plugin that integrates Kokimoki into your build
|
|
15
|
+
- **conceptId**: Unique identifier for your Kokimoki project/concept
|
|
16
|
+
- **deployCodes**: Named configurations for different deployment scenarios
|
|
17
|
+
- **devView**: Multi-window grid layout for development testing
|
|
18
|
+
- **stores**: Schema definitions for validating store state
|
|
19
|
+
- **i18nPath**: Folder path for translation files with auto-sync
|
|
20
|
+
|
|
21
|
+
## Configuration Structure
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
kokimokiKitPlugin({
|
|
25
|
+
conceptId: string, // Required
|
|
26
|
+
deployCodes: DeployCode[], // Required
|
|
27
|
+
schema?: ZodType, // Project config schema
|
|
28
|
+
stores?: StoreConfig[], // Store schemas
|
|
29
|
+
i18nPath?: string, // i18n folder path
|
|
30
|
+
i18nPrimaryLng?: string, // Source language (default: 'en')
|
|
31
|
+
devView?: DevFrameCell[][] | false, // Dev frame layout
|
|
32
|
+
endpoint?: string, // API endpoint
|
|
33
|
+
host?: string, // WebSocket host
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Related Packages
|
|
38
|
+
|
|
39
|
+
- @kokimoki/app: Core SDK for runtime (stores, transactions, AI, storage, i18n, leaderboard)
|
|
40
|
+
- @kokimoki/cli: CLI for project creation, login, and deployment
|
|
41
|
+
|
|
42
|
+
## File Patterns
|
|
43
|
+
|
|
44
|
+
Instruction files use YAML frontmatter with:
|
|
45
|
+
- `description`: Brief description of the file's purpose
|
|
46
|
+
- `applyTo`: Glob pattern for when the instructions apply (e.g., "**/vite.config.{ts,js}")
|
package/package.json
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kokimoki/kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
8
|
+
"dist",
|
|
9
|
+
"docs",
|
|
10
|
+
"llms.txt"
|
|
9
11
|
],
|
|
10
12
|
"scripts": {
|
|
11
13
|
"test": "ts-mocha src/**/*.spec.ts --exit",
|
|
@@ -25,9 +27,14 @@
|
|
|
25
27
|
"colorjs.io": "^0.5.2",
|
|
26
28
|
"colornames": "^1.1.1",
|
|
27
29
|
"yaml": "^2.7.0",
|
|
28
|
-
"zod": "^3.
|
|
30
|
+
"zod": "^4.3.5"
|
|
29
31
|
},
|
|
30
32
|
"peerDependencies": {
|
|
31
33
|
"vite": ">=4 <=6"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"vite": {
|
|
37
|
+
"optional": true
|
|
38
|
+
}
|
|
32
39
|
}
|
|
33
40
|
}
|