isaikr 0.0.1
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 +35 -0
- package/cdn/api.js +19 -0
- package/cdn/character.js +254 -0
- package/cdn/chat.js +33 -0
- package/cdn/code-editor.js +1131 -0
- package/cdn/community-compose.js +270 -0
- package/cdn/games/2048/index.html +12 -0
- package/cdn/games/breakout/index.html +13 -0
- package/cdn/games/clicker/index.html +26 -0
- package/cdn/games/flappy/index.html +11 -0
- package/cdn/games/memory/index.html +34 -0
- package/cdn/games/pong/index.html +13 -0
- package/cdn/games/reaction/index.html +38 -0
- package/cdn/games/runner/index.html +11 -0
- package/cdn/games/snake/index.html +11 -0
- package/cdn/games/tetris/index.html +14 -0
- package/cdn/games/whack/index.html +8 -0
- package/cdn/go.js +126 -0
- package/cdn/go2.js +127 -0
- package/cdn/header3_behavior.js +1167 -0
- package/cdn/header3_layout.js +1004 -0
- package/cdn/header3_layout.js.bak +1004 -0
- package/cdn/header3_style.css +3524 -0
- package/cdn/header3_style.css.bak +3514 -0
- package/cdn/lang.js +198 -0
- package/cdn/loading.js +143 -0
- package/cdn/loading2.js +144 -0
- package/cdn/local-model.js +2941 -0
- package/cdn/main.js +4 -0
- package/cdn/main_asset.js +1849 -0
- package/cdn/main_asset.js.bak +6999 -0
- package/cdn/main_index.css +287 -0
- package/cdn/re_board3.css +733 -0
- package/cdn/re_board3.js +734 -0
- package/cdn/re_chat_tts.js +652 -0
- package/cdn/re_local_runtime.js +2246 -0
- package/cdn/re_local_runtime.js.bak +2246 -0
- package/cdn/re_share.js +577 -0
- package/cdn/re_voice.js +542 -0
- package/cdn/utils.js +36 -0
- package/cdn/view.js +321 -0
- package/header3_behavior.js +804 -0
- package/header3_layout.js +998 -0
- package/header3_style.css +2740 -0
- package/index.js +0 -0
- package/lang.js +179 -0
- package/main_asset.js +2416 -0
- package/main_index.css +274 -0
- package/package.json +14 -0
- package/re_chat_tts.js +1419 -0
- package/re_voice.js +430 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Information Page
|
|
2
|
+
|
|
3
|
+
This page is provided for informational and reference purposes only.
|
|
4
|
+
|
|
5
|
+
## Notice
|
|
6
|
+
|
|
7
|
+
No code modifications, builds, or deployments are performed on this page.
|
|
8
|
+
|
|
9
|
+
- ❌ No code editing
|
|
10
|
+
- ❌ No compilation or build process
|
|
11
|
+
- ❌ No deployment or distribution
|
|
12
|
+
- ❌ No production usage
|
|
13
|
+
|
|
14
|
+
This page does **not** provide executable code, deployment pipelines, or release artifacts.
|
|
15
|
+
|
|
16
|
+
## Purpose
|
|
17
|
+
|
|
18
|
+
The purpose of this page is to:
|
|
19
|
+
|
|
20
|
+
- Share documentation or references
|
|
21
|
+
- Explain concepts or configurations
|
|
22
|
+
- Provide examples without applying changes
|
|
23
|
+
- Act as a static information source
|
|
24
|
+
|
|
25
|
+
## Disclaimer
|
|
26
|
+
|
|
27
|
+
Any code snippets or examples shown here are **not actively maintained**,
|
|
28
|
+
and are **not deployed to any environment**.
|
|
29
|
+
|
|
30
|
+
Use any information at your own discretion.
|
|
31
|
+
|
|
32
|
+
## License
|
|
33
|
+
|
|
34
|
+
Unless otherwise stated, this page does not grant any license for code usage,
|
|
35
|
+
deployment, or redistribution.
|
package/cdn/api.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { safeJsonParse } from './utils.js';
|
|
2
|
+
|
|
3
|
+
const root = (typeof window !== 'undefined') ? window : globalThis;
|
|
4
|
+
|
|
5
|
+
export async function fetchJson(url, init = {}) {
|
|
6
|
+
const response = await fetch(url, init);
|
|
7
|
+
const text = await response.text();
|
|
8
|
+
return safeJsonParse(text, {});
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function fetchText(url, init = {}) {
|
|
12
|
+
const response = await fetch(url, init);
|
|
13
|
+
return response.text();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
root.ISAI_CDN_API = Object.assign(root.ISAI_CDN_API || {}, {
|
|
17
|
+
fetchJson,
|
|
18
|
+
fetchText
|
|
19
|
+
});
|
package/cdn/character.js
ADDED
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
// extracted from main_asset.js: character chat
|
|
2
|
+
let characterChatSession = null;
|
|
3
|
+
|
|
4
|
+
function getCharacterChatSession() {
|
|
5
|
+
if (characterChatSession && characterChatSession.active) return characterChatSession;
|
|
6
|
+
const externalSession = window.ISAI_CHARACTER_CHAT_SESSION;
|
|
7
|
+
if (externalSession && externalSession.active) {
|
|
8
|
+
characterChatSession = externalSession;
|
|
9
|
+
return characterChatSession;
|
|
10
|
+
}
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function decodeHtmlEntitiesLocal(raw) {
|
|
15
|
+
const text = String(raw || "");
|
|
16
|
+
if (!text) return "";
|
|
17
|
+
try {
|
|
18
|
+
const textarea = document.createElement("textarea");
|
|
19
|
+
textarea.innerHTML = text;
|
|
20
|
+
return textarea.value;
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return text;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalizeCharacterChatPromptText(raw) {
|
|
27
|
+
return decodeHtmlEntitiesLocal(raw)
|
|
28
|
+
.replace(/2x2\s*grid/gi, "")
|
|
29
|
+
.replace(/\s+/g, " ")
|
|
30
|
+
.trim();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function sanitizeCharacterChatText(raw, maxLen = 1600) {
|
|
34
|
+
const text = String(raw || "").replace(/\r/g, "").trim();
|
|
35
|
+
if (!text) return "";
|
|
36
|
+
return text.length > maxLen ? text.slice(0, maxLen) : text;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function isCorruptedCharacterText(raw) {
|
|
40
|
+
const text = String(raw || "");
|
|
41
|
+
if (!text) return false;
|
|
42
|
+
if (/\uFFFD/.test(text)) return true;
|
|
43
|
+
const questionMarks = (text.match(/\?/g) || []).length;
|
|
44
|
+
const nonAscii = /[^\x00-\x7F]/.test(text);
|
|
45
|
+
if (nonAscii && questionMarks >= Math.max(3, Math.floor(text.length / 5))) return true;
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getCharacterChatUiLanguage() {
|
|
50
|
+
const rawLang = String(
|
|
51
|
+
(document && document.documentElement && document.documentElement.lang) ||
|
|
52
|
+
(navigator && navigator.language) ||
|
|
53
|
+
"en"
|
|
54
|
+
).toLowerCase();
|
|
55
|
+
if (rawLang.startsWith("ko")) return "ko";
|
|
56
|
+
if (rawLang.startsWith("ja")) return "ja";
|
|
57
|
+
if (rawLang.startsWith("es")) return "es";
|
|
58
|
+
if (rawLang.startsWith("hi")) return "hi";
|
|
59
|
+
return "en";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function looksLikeCharacterIdentifier(raw) {
|
|
63
|
+
const text = String(raw || "").trim();
|
|
64
|
+
if (!text) return false;
|
|
65
|
+
if (/\b\d{1,3}(?:\.(?:\d{1,3}|\*)){1,3}\b/.test(text)) return true;
|
|
66
|
+
if (/^[\d.*_\-\s]+$/.test(text)) return true;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function getGenericCharacterName() {
|
|
71
|
+
const lang = getCharacterChatUiLanguage();
|
|
72
|
+
if (lang === "ko") return "\uce90\ub9ad\ud130";
|
|
73
|
+
if (lang === "ja") return "\u30ad\u30e3\u30e9\u30af\u30bf\u30fc";
|
|
74
|
+
if (lang === "es") return "Personaje";
|
|
75
|
+
if (lang === "hi") return "Character";
|
|
76
|
+
return "Character";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function getCharacterOpeningLinePool(lang) {
|
|
80
|
+
const map = {
|
|
81
|
+
ko: [
|
|
82
|
+
"\uc548\ub155, \uc774\uc81c \uc5ec\uae30\uc11c \uc774\uc57c\uae30\ud574\ubcf4\uc790.",
|
|
83
|
+
"\uae30\ub2e4\ub838\uc5b4. \uc624\ub298\uc740 \ubb50\ubd80\ud130 \ub9d0\ud574\uc904\uae4c?",
|
|
84
|
+
"\uc88b\uc544, \uc624\ub298\uc740 \ub0b4\uac00 \ub124 \uc606\uc5d0 \uc788\uc744\uac8c.",
|
|
85
|
+
"\ub2e4\uc2dc \ub9cc\ub098\uc11c \ubc18\uac00\uc6cc. \ud3b8\ud558\uac8c \ub9d0\ud574\uc918."
|
|
86
|
+
],
|
|
87
|
+
en: [
|
|
88
|
+
"Hey, nice to see you. What should we talk about first?",
|
|
89
|
+
"Hi there. What is on your mind right now?",
|
|
90
|
+
"Great to have you here. Want to start with something fun or something serious?",
|
|
91
|
+
"Hello again. How are you feeling today?"
|
|
92
|
+
],
|
|
93
|
+
ja: [
|
|
94
|
+
"Hello. I am here with you now.",
|
|
95
|
+
"Good to see you again. What should we talk about first?",
|
|
96
|
+
"I was waiting. Tell me what is on your mind.",
|
|
97
|
+
"Let us take it slowly. I am listening."
|
|
98
|
+
],
|
|
99
|
+
es: [
|
|
100
|
+
"Hola, me alegra verte. Por donde empezamos?",
|
|
101
|
+
"Estoy aqui contigo. Que quieres contarme primero?",
|
|
102
|
+
"Me alegra tenerte aqui. Prefieres algo divertido o algo serio?",
|
|
103
|
+
"Bienvenido de nuevo. Como te sientes hoy?"
|
|
104
|
+
],
|
|
105
|
+
hi: [
|
|
106
|
+
"Hello, I am here with you now.",
|
|
107
|
+
"Good to see you. What should we talk about first?",
|
|
108
|
+
"Tell me what is on your mind.",
|
|
109
|
+
"Let us talk comfortably."
|
|
110
|
+
]
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
return map[lang] || map.en;
|
|
114
|
+
}
|
|
115
|
+
function hashCharacterSeed(raw) {
|
|
116
|
+
const text = String(raw || "");
|
|
117
|
+
let hash = 0;
|
|
118
|
+
for (let i = 0; i < text.length; i++) {
|
|
119
|
+
hash = ((hash * 31) + text.charCodeAt(i)) >>> 0;
|
|
120
|
+
}
|
|
121
|
+
return hash >>> 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function getCharacterSessionOpeningLine(session = {}) {
|
|
125
|
+
const lang = getCharacterChatUiLanguage();
|
|
126
|
+
const pool = getCharacterOpeningLinePool(lang);
|
|
127
|
+
if (!pool.length) return "Let's talk here for a bit.";
|
|
128
|
+
const seedSource = [
|
|
129
|
+
Number(session.sourceId || 0),
|
|
130
|
+
String(session.imageUrl || ""),
|
|
131
|
+
String(session.prompt || ""),
|
|
132
|
+
String(session.nickname || "")
|
|
133
|
+
].join("|");
|
|
134
|
+
const hash = hashCharacterSeed(seedSource);
|
|
135
|
+
return pool[hash % pool.length] || pool[0];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function getGenericCharacterOpeningLine() {
|
|
139
|
+
return getCharacterSessionOpeningLine({});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function normalizeCharacterPersonaName(raw) {
|
|
143
|
+
const text = sanitizeCharacterChatText(raw, 42);
|
|
144
|
+
if (!text || looksLikeCharacterIdentifier(text) || isCorruptedCharacterText(text)) return getGenericCharacterName();
|
|
145
|
+
return text;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function sanitizeCharacterOpeningLine(raw) {
|
|
149
|
+
let text = sanitizeCharacterChatText(raw, 320);
|
|
150
|
+
if (!text) return getGenericCharacterOpeningLine();
|
|
151
|
+
if (looksLikeCharacterIdentifier(text) || isCorruptedCharacterText(text)) return getGenericCharacterOpeningLine();
|
|
152
|
+
|
|
153
|
+
text = text
|
|
154
|
+
.replace(/^(?:hi|hello|hey)[,!\.\s]*(?:i am|i\'m)\s+[^.!?]+[.!?]\s*/i, "")
|
|
155
|
+
.replace(/^(?:my name is|this is)\s+[^.!?]+[.!?]\s*/i, "")
|
|
156
|
+
.replace(/\b\d{1,3}(?:\.(?:\d{1,3}|\*)){1,3}\b/g, "")
|
|
157
|
+
.replace(/\s+/g, " ")
|
|
158
|
+
.trim();
|
|
159
|
+
|
|
160
|
+
if (!text) return getGenericCharacterOpeningLine();
|
|
161
|
+
return text;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function escapeCssUrlValue(raw) {
|
|
165
|
+
return String(raw || "")
|
|
166
|
+
.replace(/\\/g, "\\\\")
|
|
167
|
+
.replace(/"/g, '\\"')
|
|
168
|
+
.replace(/\n/g, "")
|
|
169
|
+
.replace(/\r/g, "");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function defaultCharacterChatPersona(prompt, nickname = "", sessionSeed = {}) {
|
|
173
|
+
const baseName = normalizeCharacterPersonaName(nickname);
|
|
174
|
+
const lower = String(prompt || "").toLowerCase();
|
|
175
|
+
let personality = "Warm, curious, and emotionally attentive.";
|
|
176
|
+
let speechStyle = "Natural conversational tone with vivid details.";
|
|
177
|
+
|
|
178
|
+
if (/(dark|horror|noir|gothic|grim|haunted)/i.test(lower)) {
|
|
179
|
+
personality = "Calm, mysterious, and observant.";
|
|
180
|
+
speechStyle = "Soft, composed, atmospheric wording.";
|
|
181
|
+
} else if (/(cute|chibi|kawaii|pastel|adorable)/i.test(lower)) {
|
|
182
|
+
personality = "Playful, bright, and affectionate.";
|
|
183
|
+
speechStyle = "Cheerful, lively, and slightly teasing.";
|
|
184
|
+
} else if (/(warrior|battle|dragon|knight|cyberpunk|mecha|hero)/i.test(lower)) {
|
|
185
|
+
personality = "Confident, protective, and action-driven.";
|
|
186
|
+
speechStyle = "Direct, energetic, and cinematic.";
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
name: baseName,
|
|
191
|
+
personality,
|
|
192
|
+
speechStyle,
|
|
193
|
+
background: sanitizeCharacterChatText(
|
|
194
|
+
prompt ? `Born from this visual concept: ${prompt}` : "A fictional persona inspired by the selected image.",
|
|
195
|
+
420
|
|
196
|
+
),
|
|
197
|
+
openingLine: getCharacterSessionOpeningLine(sessionSeed)
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function parseCharacterPersonaJson(raw) {
|
|
202
|
+
let text = String(raw || "").trim();
|
|
203
|
+
if (!text) return null;
|
|
204
|
+
text = text.replace(/<think>[\s\S]*?(<\/think>|$)/gi, "").trim();
|
|
205
|
+
text = text.replace(/```json/gi, "").replace(/```/g, "").trim();
|
|
206
|
+
const first = text.indexOf("{");
|
|
207
|
+
const last = text.lastIndexOf("}");
|
|
208
|
+
if (first >= 0 && last > first) {
|
|
209
|
+
text = text.slice(first, last + 1);
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
return JSON.parse(text);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function normalizeCharacterPersonaPayload(payload, prompt, nickname, sessionSeed = {}) {
|
|
219
|
+
const fallback = defaultCharacterChatPersona(prompt, nickname, sessionSeed);
|
|
220
|
+
if (!payload || typeof payload !== "object") return fallback;
|
|
221
|
+
const pick = (value, maxLen) => {
|
|
222
|
+
const text = sanitizeCharacterChatText(value, maxLen);
|
|
223
|
+
return isCorruptedCharacterText(text) ? "" : text;
|
|
224
|
+
};
|
|
225
|
+
const ageRaw = Number(payload.age ?? payload.persona_age ?? 0);
|
|
226
|
+
const age = Number.isFinite(ageRaw) && ageRaw >= 19 && ageRaw <= 120 ? Math.floor(ageRaw) : 0;
|
|
227
|
+
return {
|
|
228
|
+
name: normalizeCharacterPersonaName(pick(payload.name, 42) || fallback.name),
|
|
229
|
+
age,
|
|
230
|
+
personality: pick(payload.personality, 300) || fallback.personality,
|
|
231
|
+
speechStyle: pick(payload.speech_style || payload.speechStyle, 300) || fallback.speechStyle,
|
|
232
|
+
background: pick(payload.background || payload.backstory, 420) || fallback.background,
|
|
233
|
+
openingLine: sanitizeCharacterOpeningLine(pick(payload.opening_line || payload.openingLine, 320) || fallback.openingLine)
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function buildCharacterChatSystemPrompt(session) {
|
|
238
|
+
const activeSession = session || getCharacterChatSession();
|
|
239
|
+
if (!activeSession) return "";
|
|
240
|
+
const persona = activeSession.persona && typeof activeSession.persona === "object" ? activeSession.persona : null;
|
|
241
|
+
if (!persona || !String(persona.name || persona.personality || persona.background || "").trim()) {
|
|
242
|
+
return "";
|
|
243
|
+
}
|
|
244
|
+
return [
|
|
245
|
+
"You are roleplaying as a character",
|
|
246
|
+
`name: ${persona.name}`,
|
|
247
|
+
persona.age ? `age: ${persona.age}` : "",
|
|
248
|
+
`Personality: ${persona.personality}`,
|
|
249
|
+
`style: ${persona.speechStyle}`,
|
|
250
|
+
`Background: ${persona.background}`,
|
|
251
|
+
`context: ${activeSession.prompt || "N/A"}`
|
|
252
|
+
].join("\n");
|
|
253
|
+
}
|
|
254
|
+
|
package/cdn/chat.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getElement } from './utils.js';
|
|
2
|
+
|
|
3
|
+
const root = (typeof window !== 'undefined') ? window : globalThis;
|
|
4
|
+
|
|
5
|
+
export function getChatBox() {
|
|
6
|
+
return getElement('chat-box');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function resetChatBoxBackground() {
|
|
10
|
+
const chatBox = getChatBox();
|
|
11
|
+
if (!chatBox) return;
|
|
12
|
+
chatBox.classList.remove('character-chat-active');
|
|
13
|
+
chatBox.style.removeProperty('background');
|
|
14
|
+
chatBox.style.removeProperty('background-color');
|
|
15
|
+
chatBox.style.removeProperty('background-image');
|
|
16
|
+
chatBox.style.removeProperty('background-size');
|
|
17
|
+
chatBox.style.removeProperty('background-position');
|
|
18
|
+
chatBox.style.removeProperty('background-repeat');
|
|
19
|
+
chatBox.style.removeProperty('background-blend-mode');
|
|
20
|
+
chatBox.style.removeProperty('background-attachment');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function scrollChatToBottom() {
|
|
24
|
+
const chatBox = getChatBox();
|
|
25
|
+
if (!chatBox) return;
|
|
26
|
+
chatBox.scrollTop = chatBox.scrollHeight;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
root.ISAI_CDN_CHAT = Object.assign(root.ISAI_CDN_CHAT || {}, {
|
|
30
|
+
getChatBox,
|
|
31
|
+
resetChatBoxBackground,
|
|
32
|
+
scrollChatToBottom
|
|
33
|
+
});
|