@kokimoki/kit 1.6.6 → 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 +5 -0
- package/dist/index.js +7 -0
- package/dist/kokimoki-kit-plugin.d.ts +47 -4
- package/dist/kokimoki-kit-plugin.js +403 -82
- package/dist/preprocess-style.js +13 -14
- package/dist/preprocess-style.spec.js +1 -1
- package/dist/production-loading-screen.d.ts +20 -0
- package/dist/production-loading-screen.js +123 -0
- package/dist/schema-builder.d.ts +89 -74
- package/dist/schema-builder.js +149 -132
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/zod.d.ts +1 -0
- package/dist/zod.js +5 -0
- package/docs/kokimoki-kit.instructions.md +341 -0
- package/llms.txt +46 -0
- package/package.json +10 -3
package/dist/preprocess-style.js
CHANGED
|
@@ -3,9 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
6
|
+
exports.hexToRgb = hexToRgb;
|
|
7
|
+
exports.rgbToHex = rgbToHex;
|
|
8
|
+
exports.revertReplaceForColorPickers = revertReplaceForColorPickers;
|
|
9
|
+
exports.hexToTailwindRgbString = hexToTailwindRgbString;
|
|
10
|
+
exports.getLuminance = getLuminance;
|
|
11
|
+
exports.calculateRatio = calculateRatio;
|
|
12
|
+
exports.handleStringColor = handleStringColor;
|
|
13
|
+
exports.destringRgb = destringRgb;
|
|
14
|
+
exports.generateA11yOnColor = generateA11yOnColor;
|
|
15
|
+
exports.generatePalette = generatePalette;
|
|
16
|
+
exports.preprocessStyle = preprocessStyle;
|
|
8
17
|
const colorjs_io_1 = __importDefault(require("colorjs.io"));
|
|
18
|
+
const colornames_1 = __importDefault(require("colornames"));
|
|
9
19
|
// List of rgb tuple variable names (possibly temporary system to support color picker for these variables)
|
|
10
20
|
const rgbTupleVariableNames = [
|
|
11
21
|
"theme-font-color-base",
|
|
@@ -103,12 +113,10 @@ function hexToRgb(hex) {
|
|
|
103
113
|
b: parseInt(b, 16),
|
|
104
114
|
};
|
|
105
115
|
}
|
|
106
|
-
exports.hexToRgb = hexToRgb;
|
|
107
116
|
function rgbToHex(r, g, b) {
|
|
108
117
|
const toHex = (c) => `0${c.toString(16)}`.slice(-2);
|
|
109
118
|
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
110
119
|
}
|
|
111
|
-
exports.rgbToHex = rgbToHex;
|
|
112
120
|
// export function replaceForColorPickers(code: string) {
|
|
113
121
|
// return code.replace(
|
|
114
122
|
// /--([a-z0-9-]+):\s*(\d+)\s+(\d+)\s+(\d+);/gi,
|
|
@@ -145,7 +153,6 @@ function revertReplaceForColorPickers(code) {
|
|
|
145
153
|
return match;
|
|
146
154
|
});
|
|
147
155
|
}
|
|
148
|
-
exports.revertReplaceForColorPickers = revertReplaceForColorPickers;
|
|
149
156
|
function lighten(hex, intensity) {
|
|
150
157
|
const color = hexToRgb(`#${hex}`);
|
|
151
158
|
if (!color)
|
|
@@ -172,7 +179,6 @@ function hexToTailwindRgbString(hex) {
|
|
|
172
179
|
const [, r, g, b] = colorParts;
|
|
173
180
|
return `${parseInt(r, 16)} ${parseInt(g, 16)} ${parseInt(b, 16)}`;
|
|
174
181
|
}
|
|
175
|
-
exports.hexToTailwindRgbString = hexToTailwindRgbString;
|
|
176
182
|
function getLuminance(r, g, b) {
|
|
177
183
|
const { _r, _g, _b } = typeof r === "object"
|
|
178
184
|
? { _r: r.r, _g: r.g, _b: r.b }
|
|
@@ -186,7 +192,6 @@ function getLuminance(r, g, b) {
|
|
|
186
192
|
});
|
|
187
193
|
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
|
|
188
194
|
}
|
|
189
|
-
exports.getLuminance = getLuminance;
|
|
190
195
|
function calculateRatio(luminance1, luminance2) {
|
|
191
196
|
const lum1 = typeof luminance1 === "string"
|
|
192
197
|
? getLuminance(handleStringColor(luminance1))
|
|
@@ -200,7 +205,6 @@ function calculateRatio(luminance1, luminance2) {
|
|
|
200
205
|
? (lum2 + 0.05) / (lum1 + 0.05)
|
|
201
206
|
: (lum1 + 0.05) / (lum2 + 0.05);
|
|
202
207
|
}
|
|
203
|
-
exports.calculateRatio = calculateRatio;
|
|
204
208
|
function handleStringColor(colorString, returnType = "rgb") {
|
|
205
209
|
// if it's a css variable
|
|
206
210
|
if (colorString.includes("--")) {
|
|
@@ -224,7 +228,6 @@ function handleStringColor(colorString, returnType = "rgb") {
|
|
|
224
228
|
}
|
|
225
229
|
return colorString;
|
|
226
230
|
}
|
|
227
|
-
exports.handleStringColor = handleStringColor;
|
|
228
231
|
function cssColorToHex(colorString) {
|
|
229
232
|
if (colorString.includes("#"))
|
|
230
233
|
return colorString;
|
|
@@ -251,13 +254,11 @@ function destringRgb(rgbString) {
|
|
|
251
254
|
b: parseInt(rgb[3], 10),
|
|
252
255
|
};
|
|
253
256
|
}
|
|
254
|
-
exports.destringRgb = destringRgb;
|
|
255
257
|
function generateA11yOnColor(hex) {
|
|
256
258
|
const black = calculateRatio(hex, "#000000");
|
|
257
259
|
const white = calculateRatio(hex, "#FFFFFF");
|
|
258
260
|
return black < white ? "0 0 0" : "255 255 255";
|
|
259
261
|
}
|
|
260
|
-
exports.generateA11yOnColor = generateA11yOnColor;
|
|
261
262
|
function generatePalette(baseColor) {
|
|
262
263
|
const hexValidation = new RegExp(/^#[0-9a-f]{6}$/i);
|
|
263
264
|
if (!hexValidation.test(baseColor))
|
|
@@ -299,7 +300,6 @@ function generatePalette(baseColor) {
|
|
|
299
300
|
});
|
|
300
301
|
return response;
|
|
301
302
|
}
|
|
302
|
-
exports.generatePalette = generatePalette;
|
|
303
303
|
function preprocessGfcThemeBlock(code) {
|
|
304
304
|
// Generate map of defined css variables
|
|
305
305
|
const cssVariableMap = {};
|
|
@@ -353,7 +353,7 @@ function preprocessDaisyThemeBlock(code) {
|
|
|
353
353
|
const hStr = (h || 0).toFixed(1); // h can be NaN for achromatic colors
|
|
354
354
|
return `--${name}: ${lStr}% ${cStr} ${hStr};`;
|
|
355
355
|
}
|
|
356
|
-
catch
|
|
356
|
+
catch {
|
|
357
357
|
// unable to parse color
|
|
358
358
|
return `--${name}: ${value};`;
|
|
359
359
|
}
|
|
@@ -376,4 +376,3 @@ function preprocessStyle(code) {
|
|
|
376
376
|
}
|
|
377
377
|
});
|
|
378
378
|
}
|
|
379
|
-
exports.preprocessStyle = preprocessStyle;
|
|
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const preprocess_style_1 = require("./preprocess-style");
|
|
7
6
|
const assert_1 = __importDefault(require("assert"));
|
|
7
|
+
const preprocess_style_1 = require("./preprocess-style");
|
|
8
8
|
describe("rgb-utils", () => {
|
|
9
9
|
// data-theme detection
|
|
10
10
|
describe("data-theme detection", () => {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Production loading screen HTML/CSS/JS for kokimoki-kit plugin.
|
|
3
|
+
* This screen is injected into production builds and removed when km:ready is received.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Loading screen styles
|
|
7
|
+
*/
|
|
8
|
+
export declare const loadingScreenStyles = "\n<style id=\"km-loading-style\">\n #km-loading {\n position: fixed;\n inset: 0;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 1.5rem;\n background: #fff;\n z-index: 9999;\n transition: opacity 0.3s ease-out;\n color: #1a1a2e;\n text-decoration: none;\n }\n #km-loading.km-ready {\n opacity: 0;\n pointer-events: none;\n }\n #km-loading .km-spinner {\n height: 2rem;\n animation: km-spin 1s linear infinite;\n }\n #km-loading .km-logo {\n height: 3rem;\n }\n #km-loading .km-powered {\n font-size: 0.75rem;\n font-weight: 600;\n opacity: 0.65;\n font-family: system-ui, -apple-system, sans-serif;\n }\n @keyframes km-spin {\n to { transform: rotate(360deg); }\n }\n</style>";
|
|
9
|
+
/**
|
|
10
|
+
* km:ready listener script with 3s minimum display time
|
|
11
|
+
*/
|
|
12
|
+
export declare const loadingScreenScript = "\n<script>\n (function() {\n var startTime = Date.now();\n var minDisplayTime = 3000;\n var appReady = false;\n \n function hideLoading() {\n var el = document.getElementById('km-loading');\n var style = document.getElementById('km-loading-style');\n if (el) {\n el.classList.add('km-ready');\n setTimeout(function() {\n el.remove();\n if (style) style.remove();\n }, 300);\n }\n }\n \n function tryHide() {\n if (!appReady) return;\n var elapsed = Date.now() - startTime;\n var remaining = Math.max(0, minDisplayTime - elapsed);\n setTimeout(hideLoading, remaining);\n }\n \n window.addEventListener('message', function(e) {\n if (e.data === 'km:ready' && !appReady) {\n appReady = true;\n tryHide();\n }\n });\n })();\n</script>";
|
|
13
|
+
/**
|
|
14
|
+
* Loading screen HTML element with Games for Crowds branding
|
|
15
|
+
*/
|
|
16
|
+
export declare const loadingScreenElement = "<a href=\"https://gamesforcrowds.com\" target=\"_blank\" id=\"km-loading\">\n <svg class=\"km-spinner\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\">\n <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\"/>\n </svg>\n <svg class=\"km-logo\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 797.59 219.07\" fill=\"currentColor\">\n <g>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n <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\"/>\n </g>\n <g>\n <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\"/>\n <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\"/>\n <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\"/>\n </g>\n </svg>\n <p class=\"km-powered\">Powered by Kokimoki</p>\n</a>";
|
|
17
|
+
/**
|
|
18
|
+
* Removes any existing km-loading elements from HTML
|
|
19
|
+
*/
|
|
20
|
+
export declare function removeExistingLoadingScreen(html: string): string;
|
|
@@ -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/schema-builder.d.ts
CHANGED
|
@@ -1,95 +1,110 @@
|
|
|
1
1
|
export interface FieldOptions {
|
|
2
|
-
|
|
2
|
+
label?: string;
|
|
3
3
|
}
|
|
4
4
|
export declare abstract class Field<T> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
readonly options: FieldOptions;
|
|
6
|
+
constructor(options: FieldOptions);
|
|
7
|
+
abstract get value(): T;
|
|
8
|
+
abstract get schema(): any;
|
|
9
9
|
}
|
|
10
10
|
export declare class BooleanField extends Field<boolean> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
value: boolean;
|
|
12
|
+
constructor(value: boolean, options?: FieldOptions);
|
|
13
|
+
get schema(): {
|
|
14
|
+
type: string;
|
|
15
|
+
default: boolean;
|
|
16
|
+
};
|
|
17
17
|
}
|
|
18
|
-
export declare class ConstField<T extends string> extends Field<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
export declare class ConstField<T extends string> extends Field<
|
|
19
|
+
string extends T ? never : T
|
|
20
|
+
> {
|
|
21
|
+
value: string extends T ? never : T;
|
|
22
|
+
constructor(value: string extends T ? never : T, options?: FieldOptions);
|
|
23
|
+
get schema(): {
|
|
24
|
+
const: string extends T ? never : T;
|
|
25
|
+
};
|
|
24
26
|
}
|
|
25
27
|
export declare class ImageField extends Field<string> {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
value: string;
|
|
29
|
+
constructor(value: string, options?: FieldOptions);
|
|
30
|
+
get schema(): {
|
|
31
|
+
type: string;
|
|
32
|
+
default: string;
|
|
33
|
+
};
|
|
32
34
|
}
|
|
33
35
|
export declare class TextField extends Field<string> {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
value: string;
|
|
37
|
+
constructor(value: string, options?: FieldOptions);
|
|
38
|
+
get schema(): {
|
|
39
|
+
type: string;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
40
42
|
}
|
|
41
|
-
export declare class EnumField<T extends Record<string, string>> extends Field<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
export declare class EnumField<T extends Record<string, string>> extends Field<
|
|
44
|
+
keyof T
|
|
45
|
+
> {
|
|
46
|
+
enumValues: T;
|
|
47
|
+
value: keyof T;
|
|
48
|
+
constructor(enumValues: T, value: keyof T, options?: FieldOptions);
|
|
49
|
+
get schema(): {
|
|
50
|
+
enum: string[];
|
|
51
|
+
};
|
|
48
52
|
}
|
|
49
53
|
export declare class IntegerField extends Field<number> {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
value: number;
|
|
55
|
+
constructor(value: number, options?: FieldOptions);
|
|
56
|
+
get schema(): {
|
|
57
|
+
type: string;
|
|
58
|
+
default: number;
|
|
59
|
+
};
|
|
56
60
|
}
|
|
57
61
|
export declare class FloatField extends Field<number> {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
value: number;
|
|
63
|
+
constructor(value: number, options?: FieldOptions);
|
|
64
|
+
get schema(): {
|
|
65
|
+
type: string;
|
|
66
|
+
default: number;
|
|
67
|
+
};
|
|
64
68
|
}
|
|
65
|
-
export declare class FormGroup<
|
|
69
|
+
export declare class FormGroup<
|
|
70
|
+
T extends Record<string, Field<any>>,
|
|
71
|
+
O extends Record<string, Field<any>>,
|
|
72
|
+
> extends Field<
|
|
73
|
+
{
|
|
66
74
|
[key in keyof T]: T[key]["value"];
|
|
67
|
-
} & Partial<{
|
|
75
|
+
} & Partial<{
|
|
68
76
|
[key in keyof O]: O[key]["value"];
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
}>
|
|
78
|
+
> {
|
|
79
|
+
requiredFields: T;
|
|
80
|
+
optionalFields: O;
|
|
81
|
+
constructor(requiredFields: T, optionalFields?: O, options?: FieldOptions);
|
|
82
|
+
get value(): {
|
|
83
|
+
[key in keyof T]: T[key]["value"];
|
|
84
|
+
} & Partial<{
|
|
85
|
+
[key in keyof O]: O[key]["value"];
|
|
86
|
+
}>;
|
|
87
|
+
get schema(): {
|
|
88
|
+
type: string;
|
|
89
|
+
properties: any;
|
|
90
|
+
required: string[];
|
|
91
|
+
};
|
|
83
92
|
}
|
|
84
93
|
export declare class FormArray<T> extends Field<T[]> {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
private factory;
|
|
95
|
+
value: Field<T>["value"][];
|
|
96
|
+
constructor(
|
|
97
|
+
factory: () => Field<T>,
|
|
98
|
+
value: Field<T>["value"][],
|
|
99
|
+
options?: FieldOptions,
|
|
100
|
+
);
|
|
101
|
+
get schema(): {
|
|
102
|
+
type: string;
|
|
103
|
+
items: any;
|
|
104
|
+
default: T[];
|
|
105
|
+
};
|
|
95
106
|
}
|
|
107
|
+
export declare class Form<
|
|
108
|
+
R extends Record<string, Field<any>>,
|
|
109
|
+
O extends Record<string, Field<any>>,
|
|
110
|
+
> extends FormGroup<R, O> {}
|