@musnows/scriverse 0.2.0 → 0.3.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.
Files changed (74) hide show
  1. package/README.en.md +13 -4
  2. package/README.md +13 -4
  3. package/dist/ai.js +3548 -0
  4. package/dist/ai.js.map +1 -0
  5. package/dist/app.js +1079 -0
  6. package/dist/app.js.map +1 -0
  7. package/dist/cli-core.js +147 -20
  8. package/dist/cli-core.js.map +1 -1
  9. package/dist/credential-vault.js +40 -0
  10. package/dist/credential-vault.js.map +1 -0
  11. package/dist/database.js +1220 -0
  12. package/dist/database.js.map +1 -0
  13. package/dist/docx-security.js +184 -0
  14. package/dist/docx-security.js.map +1 -0
  15. package/dist/domain.js +21 -0
  16. package/dist/domain.js.map +1 -0
  17. package/dist/errors.js +16 -0
  18. package/dist/errors.js.map +1 -0
  19. package/dist/http-logging.js +76 -0
  20. package/dist/http-logging.js.map +1 -0
  21. package/dist/image-captcha.js +173 -0
  22. package/dist/image-captcha.js.map +1 -0
  23. package/dist/image-metadata.js +128 -0
  24. package/dist/image-metadata.js.map +1 -0
  25. package/dist/import-security.js +46 -0
  26. package/dist/import-security.js.map +1 -0
  27. package/dist/logger.js +110 -0
  28. package/dist/logger.js.map +1 -0
  29. package/dist/parser.js +223 -0
  30. package/dist/parser.js.map +1 -0
  31. package/dist/public/ai-context-meter.js +10 -0
  32. package/dist/public/ai-conversation.js +3 -0
  33. package/dist/public/ai-mentions.js +55 -0
  34. package/dist/public/ai-message-actions.js +27 -0
  35. package/dist/public/ai-message-meta.js +15 -0
  36. package/dist/public/ai-message-time.js +23 -0
  37. package/dist/public/ai-prompt-keyboard.js +3 -0
  38. package/dist/public/app.js +4435 -0
  39. package/dist/public/character-profile.d.ts +9 -0
  40. package/dist/public/character-profile.js +65 -0
  41. package/dist/public/character-version.d.ts +2 -0
  42. package/dist/public/character-version.js +31 -0
  43. package/dist/public/entity-version.js +34 -0
  44. package/dist/public/icon.svg +10 -0
  45. package/dist/public/index.html +547 -0
  46. package/dist/public/line-number-layout.js +15 -0
  47. package/dist/public/markdown.js +199 -0
  48. package/dist/public/model-config.d.ts +17 -0
  49. package/dist/public/model-config.js +57 -0
  50. package/dist/public/page-route.d.ts +11 -0
  51. package/dist/public/page-route.js +81 -0
  52. package/dist/public/relationship-graph.js +2017 -0
  53. package/dist/public/site.webmanifest +17 -0
  54. package/dist/public/styles.css +1441 -0
  55. package/dist/public/text-formatting.d.ts +2 -0
  56. package/dist/public/text-formatting.js +20 -0
  57. package/dist/public/theme-init.js +8 -0
  58. package/dist/public/theme.js +13 -0
  59. package/dist/public/whitespace-visualization.js +20 -0
  60. package/dist/request-context.js +16 -0
  61. package/dist/request-context.js.map +1 -0
  62. package/dist/security.js +247 -0
  63. package/dist/security.js.map +1 -0
  64. package/dist/server-runtime.js +90 -0
  65. package/dist/server-runtime.js.map +1 -0
  66. package/dist/server.js +26 -0
  67. package/dist/server.js.map +1 -0
  68. package/dist/store.js +2568 -0
  69. package/dist/store.js.map +1 -0
  70. package/dist/user-auth.js +515 -0
  71. package/dist/user-auth.js.map +1 -0
  72. package/dist/utils.js +67 -0
  73. package/dist/utils.js.map +1 -0
  74. package/package.json +4 -9
@@ -0,0 +1,27 @@
1
+ function copyWithDocument(rawMarkdown, documentRef) {
2
+ if (!documentRef?.body || typeof documentRef.execCommand !== "function") return false;
3
+ const textarea = documentRef.createElement("textarea");
4
+ textarea.value = rawMarkdown;
5
+ textarea.setAttribute("readonly", "");
6
+ Object.assign(textarea.style, { position: "fixed", left: "-9999px", opacity: "0" });
7
+ documentRef.body.append(textarea);
8
+ textarea.select();
9
+ const copied = documentRef.execCommand("copy");
10
+ textarea.remove();
11
+ return copied;
12
+ }
13
+
14
+ export async function copyAiRawMarkdown(markdown, clipboard = globalThis.navigator?.clipboard, documentRef = globalThis.document) {
15
+ const rawMarkdown = String(markdown ?? "");
16
+ if (clipboard?.writeText) {
17
+ try {
18
+ await clipboard.writeText(rawMarkdown);
19
+ return rawMarkdown;
20
+ } catch {
21
+ if (copyWithDocument(rawMarkdown, documentRef)) return rawMarkdown;
22
+ }
23
+ } else if (copyWithDocument(rawMarkdown, documentRef)) {
24
+ return rawMarkdown;
25
+ }
26
+ throw new Error("当前浏览器不支持剪贴板写入");
27
+ }
@@ -0,0 +1,15 @@
1
+ export function formatAiMessageMeta(modelDisplayName, outputTokens, suffix = "") {
2
+ const modelName = String(modelDisplayName || "模型").trim();
3
+ const tokenCount = Math.max(0, Math.round(Number(outputTokens) || 0)).toLocaleString("zh-CN");
4
+ return [modelName, `${tokenCount} tok`, String(suffix || "").trim()].filter(Boolean).join(" · ");
5
+ }
6
+
7
+ export function estimateAiMessageTokens(value) {
8
+ let wideCharacters = 0;
9
+ let narrowCharacters = 0;
10
+ for (const character of String(value || "")) {
11
+ if (/[^\u0000-\u00ff]/u.test(character)) wideCharacters += 1;
12
+ else narrowCharacters += 1;
13
+ }
14
+ return Math.max(1, Math.ceil(wideCharacters * 1.1 + narrowCharacters / 4));
15
+ }
@@ -0,0 +1,23 @@
1
+ function validDate(value) {
2
+ if (value === null || value === undefined || value === "") return null;
3
+ const date = value instanceof Date ? value : new Date(value);
4
+ return Number.isNaN(date.getTime()) ? null : date;
5
+ }
6
+
7
+ function pad(value) {
8
+ return String(value).padStart(2, "0");
9
+ }
10
+
11
+ function localDayKey(date) {
12
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
13
+ }
14
+
15
+ export function formatAiMessageTime(createdAt, previousCreatedAt = null) {
16
+ const created = validDate(createdAt);
17
+ if (!created) return "";
18
+ const time = `${pad(created.getHours())}:${pad(created.getMinutes())}`;
19
+ const previous = validDate(previousCreatedAt);
20
+ return previous && localDayKey(previous) !== localDayKey(created)
21
+ ? `${localDayKey(created)} ${time}`
22
+ : time;
23
+ }
@@ -0,0 +1,3 @@
1
+ export function shouldSendAiPrompt(event) {
2
+ return event.key === "Enter" && !event.shiftKey && !event.isComposing;
3
+ }