@adminide-stack/yantra-mobile 12.0.94 → 12.0.95-alpha.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/lib/compute.js +113 -1
- package/lib/compute.js.map +1 -1
- package/lib/features/agent-chat/NativeAgentChat.js +1 -1
- package/lib/features/agent-chat/NativeAgentChat.js.map +1 -1
- package/lib/features/apps/AppsCatalog.js +20 -0
- package/lib/features/apps/AppsCatalog.js.map +1 -1
- package/lib/features/apps/appArt.js +3 -1
- package/lib/features/apps/appArt.js.map +1 -1
- package/lib/features/apps/appFavorites.js +8 -2
- package/lib/features/apps/appFavorites.js.map +1 -1
- package/lib/features/apps/mobileAppCatalog.js +27 -1
- package/lib/features/apps/mobileAppCatalog.js.map +1 -1
- package/lib/features/canvas/VideoGeneratorExperience.js +1 -0
- package/lib/features/canvas/VideoGeneratorExperience.js.map +1 -1
- package/lib/features/canvas/videoEditor/remoteMediaClient.js +51 -24
- package/lib/features/canvas/videoEditor/remoteMediaClient.js.map +1 -1
- package/lib/features/chat/connectorConnect.js +1 -1
- package/lib/features/inbox/InboxAgentChatPane.js +64 -0
- package/lib/features/inbox/InboxAgentChatPane.js.map +1 -0
- package/lib/features/inbox/InboxExperience.js +631 -0
- package/lib/features/inbox/InboxExperience.js.map +1 -0
- package/lib/features/inbox/components/BottomSheet.js +111 -0
- package/lib/features/inbox/components/BottomSheet.js.map +1 -0
- package/lib/features/inbox/components/ComposeSheet.js +298 -0
- package/lib/features/inbox/components/ComposeSheet.js.map +1 -0
- package/lib/features/inbox/components/InboxStates.js +182 -0
- package/lib/features/inbox/components/InboxStates.js.map +1 -0
- package/lib/features/inbox/components/MailBody.js +103 -0
- package/lib/features/inbox/components/MailBody.js.map +1 -0
- package/lib/features/inbox/components/MessageReader.js +396 -0
- package/lib/features/inbox/components/MessageReader.js.map +1 -0
- package/lib/features/inbox/components/MessageRow.js +153 -0
- package/lib/features/inbox/components/MessageRow.js.map +1 -0
- package/lib/features/inbox/components/SenderAvatar.js +24 -0
- package/lib/features/inbox/components/SenderAvatar.js.map +1 -0
- package/lib/features/inbox/components/Tap.js +55 -0
- package/lib/features/inbox/components/Tap.js.map +1 -0
- package/lib/features/inbox/composeDraft.js +89 -0
- package/lib/features/inbox/composeDraft.js.map +1 -0
- package/lib/features/inbox/formatMailDate.js +60 -0
- package/lib/features/inbox/formatMailDate.js.map +1 -0
- package/lib/features/inbox/inboxAccounts.js +110 -0
- package/lib/features/inbox/inboxAccounts.js.map +1 -0
- package/lib/features/inbox/inboxClient.js +293 -0
- package/lib/features/inbox/inboxClient.js.map +1 -0
- package/lib/features/inbox/inboxContext.js +27 -0
- package/lib/features/inbox/inboxContext.js.map +1 -0
- package/lib/features/inbox/inboxFolders.js +47 -0
- package/lib/features/inbox/inboxFolders.js.map +1 -0
- package/lib/features/inbox/inboxNormalize.js +144 -0
- package/lib/features/inbox/inboxNormalize.js.map +1 -0
- package/lib/features/inbox/inboxPreference.js +20 -0
- package/lib/features/inbox/inboxPreference.js.map +1 -0
- package/lib/features/inbox/inboxTheme.js +54 -0
- package/lib/features/inbox/inboxTheme.js.map +1 -0
- package/lib/features/inbox/nativeInboxRegistry.js +15 -0
- package/lib/features/inbox/nativeInboxRegistry.js.map +1 -0
- package/lib/features/inbox/openAttachment.js +43 -0
- package/lib/features/inbox/openAttachment.js.map +1 -0
- package/lib/features/inbox/useInboxMailbox.js +250 -0
- package/lib/features/inbox/useInboxMailbox.js.map +1 -0
- package/lib/features/inbox/useMailMessage.js +101 -0
- package/lib/features/inbox/useMailMessage.js.map +1 -0
- package/lib/features/study/StudyAgentChatPane.js +67 -0
- package/lib/features/study/StudyAgentChatPane.js.map +1 -0
- package/lib/features/study/StudyExperience.js +586 -0
- package/lib/features/study/StudyExperience.js.map +1 -0
- package/lib/features/study/components/CellView.js +133 -0
- package/lib/features/study/components/CellView.js.map +1 -0
- package/lib/features/study/components/IntakeCard.js +203 -0
- package/lib/features/study/components/IntakeCard.js.map +1 -0
- package/lib/features/study/components/NotebookSwitcher.js +74 -0
- package/lib/features/study/components/NotebookSwitcher.js.map +1 -0
- package/lib/features/study/components/SourceStrip.js +69 -0
- package/lib/features/study/components/SourceStrip.js.map +1 -0
- package/lib/features/study/components/StudyComposer.js +118 -0
- package/lib/features/study/components/StudyComposer.js.map +1 -0
- package/lib/features/study/components/StudyOnboarding.js +477 -0
- package/lib/features/study/components/StudyOnboarding.js.map +1 -0
- package/lib/features/study/components/StudySheet.js +120 -0
- package/lib/features/study/components/StudySheet.js.map +1 -0
- package/lib/features/study/components/StudyStates.js +148 -0
- package/lib/features/study/components/StudyStates.js.map +1 -0
- package/lib/features/study/components/TextEntrySheet.js +111 -0
- package/lib/features/study/components/TextEntrySheet.js.map +1 -0
- package/lib/features/study/nativeStudyRegistry.js +15 -0
- package/lib/features/study/nativeStudyRegistry.js.map +1 -0
- package/lib/features/study/shareExport.js +38 -0
- package/lib/features/study/shareExport.js.map +1 -0
- package/lib/features/study/studyClient.js +278 -0
- package/lib/features/study/studyClient.js.map +1 -0
- package/lib/features/study/studyContext.js +25 -0
- package/lib/features/study/studyContext.js.map +1 -0
- package/lib/features/study/studyFiles.js +140 -0
- package/lib/features/study/studyFiles.js.map +1 -0
- package/lib/features/study/studyNormalize.js +116 -0
- package/lib/features/study/studyNormalize.js.map +1 -0
- package/lib/features/study/studyPreference.js +24 -0
- package/lib/features/study/studyPreference.js.map +1 -0
- package/lib/features/study/studyProfile.js +233 -0
- package/lib/features/study/studyProfile.js.map +1 -0
- package/lib/features/study/studyPrompts.js +78 -0
- package/lib/features/study/studyPrompts.js.map +1 -0
- package/lib/features/study/studyTheme.js +47 -0
- package/lib/features/study/studyTheme.js.map +1 -0
- package/lib/features/study/useStudyWorkspace.js +401 -0
- package/lib/features/study/useStudyWorkspace.js.map +1 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/routes.json +108 -0
- package/lib/screens/InboxNative/index.js +77 -0
- package/lib/screens/InboxNative/index.js.map +1 -0
- package/lib/screens/InboxNative/useConnectMailbox.js +42 -0
- package/lib/screens/InboxNative/useConnectMailbox.js.map +1 -0
- package/lib/screens/InboxNative/useInboxHostChat.js +62 -0
- package/lib/screens/InboxNative/useInboxHostChat.js.map +1 -0
- package/lib/screens/InboxNative/useMailAccounts.js +54 -0
- package/lib/screens/InboxNative/useMailAccounts.js.map +1 -0
- package/lib/screens/StudyNative/index.js +80 -0
- package/lib/screens/StudyNative/index.js.map +1 -0
- package/lib/screens/StudyNative/useStudyHostChat.js +62 -0
- package/lib/screens/StudyNative/useStudyHostChat.js.map +1 -0
- package/lib/utils/authUserDisplay.js +11 -1
- package/lib/utils/authUserDisplay.js.map +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studyNormalize.js","sources":["../../../src/features/study/studyNormalize.ts"],"sourcesContent":["/**\n * yantra-notebook store objects -> the Study model. Defensive on purpose: the\n * store holds notebooks written by every connector version (pre-sources\n * notebooks have no `sources`), and a bad row must never crash the screen.\n */\nimport type {\n StudyCell,\n StudyCellType,\n StudyNotebook,\n StudyNotebookSummary,\n StudySource,\n StudySourceKind,\n} from './types';\n\ntype Json = Record<string, unknown>;\n\nfunction record(value: unknown): Json | null {\n return value && typeof value === 'object' && !Array.isArray(value) ? (value as Json) : null;\n}\n\nfunction str(value: unknown): string {\n return typeof value === 'string' ? value : '';\n}\n\nfunction num(value: unknown): number {\n return typeof value === 'number' && Number.isFinite(value) ? value : 0;\n}\n\nconst SOURCE_KINDS: readonly StudySourceKind[] = ['text', 'url', 'document', 'media'];\n\nexport function normalizeCell(raw: unknown): StudyCell | null {\n const row = record(raw);\n const id = str(row?.id).trim();\n if (!row || !id) return null;\n const type: StudyCellType = row.type === 'ai' ? 'ai' : 'markdown';\n const prompt = str(row.prompt).trim();\n const createdAt = str(row.createdAt);\n return {\n id,\n type,\n content: str(row.content),\n ...(prompt ? { prompt } : {}),\n createdAt,\n updatedAt: str(row.updatedAt) || createdAt,\n };\n}\n\nexport function normalizeSource(raw: unknown): StudySource | null {\n const row = record(raw);\n const id = str(row?.id).trim();\n if (!row || !id) return null;\n const kind = SOURCE_KINDS.includes(row.kind as StudySourceKind) ? (row.kind as StudySourceKind) : 'text';\n const origin = str(row.origin).trim();\n return {\n id,\n kind,\n title: str(row.title).trim() || origin || 'Untitled source',\n ...(origin ? { origin } : {}),\n charCount: num(row.charCount),\n truncated: row.truncated === true,\n addedAt: str(row.addedAt),\n };\n}\n\nexport function normalizeNotebook(raw: unknown): StudyNotebook | null {\n const row = record(raw);\n const id = str(row?.id).trim();\n if (!row || !id) return null;\n const cells = Array.isArray(row.cells) ? row.cells : [];\n const sources = Array.isArray(row.sources) ? row.sources : [];\n const topic = str(row.topic).trim();\n const createdAt = str(row.createdAt);\n return {\n id,\n title: str(row.title).trim() || 'Untitled notebook',\n ...(topic ? { topic } : {}),\n cells: cells.map(normalizeCell).filter((cell): cell is StudyCell => cell !== null),\n sources: sources.map(normalizeSource).filter((source): source is StudySource => source !== null),\n createdAt,\n updatedAt: str(row.updatedAt) || createdAt,\n };\n}\n\nexport function normalizeSummary(raw: unknown): StudyNotebookSummary | null {\n const row = record(raw);\n const id = str(row?.id).trim();\n if (!row || !id) return null;\n const topic = str(row.topic).trim();\n const createdAt = str(row.createdAt);\n return {\n id,\n title: str(row.title).trim() || 'Untitled notebook',\n ...(topic ? { topic } : {}),\n cellCount: num(row.cellCount),\n sourceCount: num(row.sourceCount),\n createdAt,\n updatedAt: str(row.updatedAt) || createdAt,\n };\n}\n\n/** The index row for a notebook just loaded, so the switcher stays current without a re-list. */\nexport function summaryOf(notebook: StudyNotebook): StudyNotebookSummary {\n return {\n id: notebook.id,\n title: notebook.title,\n ...(notebook.topic ? { topic: notebook.topic } : {}),\n cellCount: notebook.cells.length,\n sourceCount: notebook.sources.length,\n createdAt: notebook.createdAt,\n updatedAt: notebook.updatedAt,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;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AAS,CAAA;AACnC,EAAO,OAAA,aAAA,CAAA,cAAA,CAAA;AAAA,IACL,EAAA;AAAA,IACA,OAAO,GAAI,CAAA,GAAA,CAAI,KAAK,CAAA,CAAE,MAAU,IAAA;AAAA,GAAA,EAC5B,KAAQ,GAAA;AAAA,IACV;AAAA,GACF,GAAI,EALC,CAAA,EAAA;AAAA,IAML,SAAA,EAAW,GAAI,CAAA,GAAA,CAAI,SAAS,CAAA;AAAA,IAC5B,WAAA,EAAa,GAAI,CAAA,GAAA,CAAI,WAAW,CAAA;AAAA,IAChC,SAAA;AAAA,IACA,SAAW,EAAA,GAAA,CAAI,GAAI,CAAA,SAAS,CAAK,IAAA;AAAA,GACnC,CAAA;AACF;AAGO,SAAS,UAAU,QAA+C,EAAA;AACvE,EAAO,OAAA,aAAA,CAAA,cAAA,CAAA;AAAA,IACL,IAAI,QAAS,CAAA,EAAA;AAAA,IACb,OAAO,QAAS,CAAA;AAAA,GAAA,EACZ,SAAS,KAAQ,GAAA;AAAA,IACnB,OAAO,QAAS,CAAA;AAAA,GAClB,GAAI,EALC,CAAA,EAAA;AAAA,IAML,SAAA,EAAW,SAAS,KAAM,CAAA,MAAA;AAAA,IAC1B,WAAA,EAAa,SAAS,OAAQ,CAAA,MAAA;AAAA,IAC9B,WAAW,QAAS,CAAA,SAAA;AAAA,IACpB,WAAW,QAAS,CAAA;AAAA,GACtB,CAAA;AACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
let AsyncStorage = null;
|
|
3
|
+
try {
|
|
4
|
+
AsyncStorage = (_a = require("@react-native-async-storage/async-storage").default) != null ? _a : null;
|
|
5
|
+
} catch (e) {
|
|
6
|
+
AsyncStorage = null;
|
|
7
|
+
}
|
|
8
|
+
const KEY_PREFIX = "yantra.study.notebook.v1:";
|
|
9
|
+
function keyFor(scope) {
|
|
10
|
+
return `${KEY_PREFIX}${scope.trim().toLowerCase() || "default"}`;
|
|
11
|
+
}
|
|
12
|
+
async function readLastNotebook(scope) {
|
|
13
|
+
if (!AsyncStorage) return null;
|
|
14
|
+
try {
|
|
15
|
+
return await AsyncStorage.getItem(keyFor(scope)) || null;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function writeLastNotebook(scope, notebookId) {
|
|
21
|
+
if (!AsyncStorage) return;
|
|
22
|
+
const op = notebookId ? AsyncStorage.setItem(keyFor(scope), notebookId) : AsyncStorage.removeItem(keyFor(scope));
|
|
23
|
+
op.catch(() => void 0);
|
|
24
|
+
}export{readLastNotebook,writeLastNotebook};//# sourceMappingURL=studyPreference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studyPreference.js","sources":["../../../src/features/study/studyPreference.ts"],"sourcesContent":["/**\n * The notebook last open in Study, per workspace, so the next visit picks up\n * where the person left off. Only the notebook id is kept.\n */\ntype StorageLike = {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n};\n\nlet AsyncStorage: StorageLike | null = null;\ntry {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require\n AsyncStorage = require('@react-native-async-storage/async-storage').default ?? null;\n} catch {\n AsyncStorage = null;\n}\n\nconst KEY_PREFIX = 'yantra.study.notebook.v1:';\n\nfunction keyFor(scope: string): string {\n return `${KEY_PREFIX}${scope.trim().toLowerCase() || 'default'}`;\n}\n\nexport async function readLastNotebook(scope: string): Promise<string | null> {\n if (!AsyncStorage) return null;\n try {\n return (await AsyncStorage.getItem(keyFor(scope))) || null;\n } catch {\n return null;\n }\n}\n\nexport function writeLastNotebook(scope: string, notebookId: string | null): void {\n if (!AsyncStorage) return;\n const op = notebookId ? AsyncStorage.setItem(keyFor(scope), notebookId) : AsyncStorage.removeItem(keyFor(scope));\n op.catch(() => undefined);\n}\n"],"names":[],"mappings":"AAAA,IAAA,EAAA;AASA,IAAI,YAAmC,GAAA,IAAA;AACvC,IAAI;AAEF,EAAA,YAAA,GAAA,CAAe,EAAQ,GAAA,OAAA,CAAA,2CAA2C,CAAE,CAAA,OAAA,KAArD,IAAgE,GAAA,EAAA,GAAA,IAAA;AACjF,CAAQ,CAAA,OAAA,CAAA,EAAA;AACN,EAAe,YAAA,GAAA,IAAA;AACjB;AACA,MAAM,UAAa,GAAA,2BAAA;AACnB,SAAS,OAAO,KAAuB,EAAA;AACrC,EAAO,OAAA,CAAA,EAAG,UAAU,CAAG,EAAA,KAAA,CAAM,MAAO,CAAA,WAAA,MAAiB,SAAS,CAAA,CAAA;AAChE;AACA,eAAsB,iBAAiB,KAAuC,EAAA;AAC5E,EAAI,IAAA,CAAC,cAAqB,OAAA,IAAA;AAC1B,EAAI,IAAA;AACF,IAAA,OAAQ,MAAM,YAAa,CAAA,OAAA,CAAQ,MAAO,CAAA,KAAK,CAAC,CAAM,IAAA,IAAA;AAAA,GAChD,CAAA,OAAA,CAAA,EAAA;AACN,IAAO,OAAA,IAAA;AAAA;AAEX;AACgB,SAAA,iBAAA,CAAkB,OAAe,UAAiC,EAAA;AAChF,EAAA,IAAI,CAAC,YAAc,EAAA;AACnB,EAAA,MAAM,EAAK,GAAA,UAAA,GAAa,YAAa,CAAA,OAAA,CAAQ,MAAO,CAAA,KAAK,CAAG,EAAA,UAAU,CAAI,GAAA,YAAA,CAAa,UAAW,CAAA,MAAA,CAAO,KAAK,CAAC,CAAA;AAC/G,EAAG,EAAA,CAAA,KAAA,CAAM,MAAM,MAAS,CAAA;AAC1B"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {useState,useEffect,useCallback}from'react';var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var _a;
|
|
18
|
+
const STUDY_TIMES = [{
|
|
19
|
+
id: "early",
|
|
20
|
+
emoji: "\u{1F305}",
|
|
21
|
+
label: "Early Bird (5 \u2013 8 AM)",
|
|
22
|
+
description: "First light, fresh mind"
|
|
23
|
+
}, {
|
|
24
|
+
id: "morning",
|
|
25
|
+
emoji: "\u2600\uFE0F",
|
|
26
|
+
label: "Morning (8 AM \u2013 12 PM)",
|
|
27
|
+
description: "Prime focus hours"
|
|
28
|
+
}, {
|
|
29
|
+
id: "afternoon",
|
|
30
|
+
emoji: "\u{1F324}\uFE0F",
|
|
31
|
+
label: "Afternoon (12 \u2013 5 PM)",
|
|
32
|
+
description: "Steady midday blocks"
|
|
33
|
+
}, {
|
|
34
|
+
id: "evening",
|
|
35
|
+
emoji: "\u{1F306}",
|
|
36
|
+
label: "Evening (5 \u2013 10 PM)",
|
|
37
|
+
description: "Wind-down deep work"
|
|
38
|
+
}, {
|
|
39
|
+
id: "night",
|
|
40
|
+
emoji: "\u{1F989}",
|
|
41
|
+
label: "Night Owl (10 PM \u2013 2 AM)",
|
|
42
|
+
description: "Quiet late-night focus"
|
|
43
|
+
}];
|
|
44
|
+
const LEARNING_STYLES = [{
|
|
45
|
+
id: "visual",
|
|
46
|
+
emoji: "\u{1F3A8}",
|
|
47
|
+
label: "Visual",
|
|
48
|
+
description: "Diagrams, charts, and examples"
|
|
49
|
+
}, {
|
|
50
|
+
id: "reading",
|
|
51
|
+
emoji: "\u{1F4DD}",
|
|
52
|
+
label: "Reading and writing",
|
|
53
|
+
description: "Notes, outlines, and written explanations"
|
|
54
|
+
}, {
|
|
55
|
+
id: "practice",
|
|
56
|
+
emoji: "\u{1F527}",
|
|
57
|
+
label: "Practice problems",
|
|
58
|
+
description: "Worked examples, drills, and feedback"
|
|
59
|
+
}, {
|
|
60
|
+
id: "discussion",
|
|
61
|
+
emoji: "\u{1F4AC}",
|
|
62
|
+
label: "Discussion",
|
|
63
|
+
description: "Talk through concepts step by step"
|
|
64
|
+
}];
|
|
65
|
+
const ACCOUNTABILITY_LEVELS = [{
|
|
66
|
+
id: "light",
|
|
67
|
+
emoji: "\u{1F33F}",
|
|
68
|
+
label: "Light check-ins"
|
|
69
|
+
}, {
|
|
70
|
+
id: "steady",
|
|
71
|
+
emoji: "\u{1F4C8}",
|
|
72
|
+
label: "Steady follow-through"
|
|
73
|
+
}, {
|
|
74
|
+
id: "structured",
|
|
75
|
+
emoji: "\u{1F3AF}",
|
|
76
|
+
label: "Structured accountability"
|
|
77
|
+
}, {
|
|
78
|
+
id: "high",
|
|
79
|
+
emoji: "\u{1F525}",
|
|
80
|
+
label: "High-accountability mode"
|
|
81
|
+
}];
|
|
82
|
+
const REMINDER_TONES = [{
|
|
83
|
+
id: "gentle",
|
|
84
|
+
emoji: "\u{1F54A}\uFE0F",
|
|
85
|
+
label: "Gentle",
|
|
86
|
+
quote: '"You planned a study block today. Start with one small task."'
|
|
87
|
+
}, {
|
|
88
|
+
id: "encouraging",
|
|
89
|
+
emoji: "\u{1F31F}",
|
|
90
|
+
label: "Encouraging",
|
|
91
|
+
quote: `"You're building momentum. One focused session keeps it going."`
|
|
92
|
+
}, {
|
|
93
|
+
id: "direct",
|
|
94
|
+
emoji: "\u{1F4CB}",
|
|
95
|
+
label: "Direct",
|
|
96
|
+
quote: '"You missed yesterday. Do 20 minutes today to stay on track."'
|
|
97
|
+
}, {
|
|
98
|
+
id: "firm",
|
|
99
|
+
emoji: "\u{1F4AA}",
|
|
100
|
+
label: "Firm",
|
|
101
|
+
quote: `"Your exam is in 2 weeks. Let's put in the work today."`
|
|
102
|
+
}];
|
|
103
|
+
const EMPTY_PROFILE = {
|
|
104
|
+
preferredName: "",
|
|
105
|
+
studyTime: null,
|
|
106
|
+
learningStyles: [],
|
|
107
|
+
accountability: null,
|
|
108
|
+
reminderTone: null,
|
|
109
|
+
onboardedAt: null
|
|
110
|
+
};
|
|
111
|
+
function optionById(options, id) {
|
|
112
|
+
return id ? options.find((option) => option.id === id) : void 0;
|
|
113
|
+
}
|
|
114
|
+
const article = (word) => /^[aeiou]/i.test(word) ? "an" : "a";
|
|
115
|
+
function styleLabels(profile) {
|
|
116
|
+
return profile.learningStyles.map((id) => {
|
|
117
|
+
var _a2;
|
|
118
|
+
return (_a2 = optionById(LEARNING_STYLES, id)) == null ? void 0 : _a2.label.toLowerCase();
|
|
119
|
+
}).filter((label) => Boolean(label));
|
|
120
|
+
}
|
|
121
|
+
function buildTutorGreeting(profile) {
|
|
122
|
+
const name = profile.preferredName.trim() || "there";
|
|
123
|
+
const time = optionById(STUDY_TIMES, profile.studyTime);
|
|
124
|
+
const styles = styleLabels(profile);
|
|
125
|
+
const level = optionById(ACCOUNTABILITY_LEVELS, profile.accountability);
|
|
126
|
+
const tone = optionById(REMINDER_TONES, profile.reminderTone);
|
|
127
|
+
const traits = [];
|
|
128
|
+
if (time) {
|
|
129
|
+
const label = time.label.replace(/\s*\(.*\)/, "").toLowerCase();
|
|
130
|
+
traits.push(`you're ${article(label)} ${label} studier`);
|
|
131
|
+
}
|
|
132
|
+
if (styles.length) traits.push(`you like ${styles.join(" and ")}`);
|
|
133
|
+
if (level) traits.push(`you thrive on ${level.label.toLowerCase()}`);
|
|
134
|
+
if (tone) {
|
|
135
|
+
const label = tone.label.toLowerCase();
|
|
136
|
+
traits.push(`you prefer ${article(label)} ${label} tone`);
|
|
137
|
+
}
|
|
138
|
+
const seen = traits.length ? ` I see ${traits.join(", ")}, so I'll match that.` : "";
|
|
139
|
+
return `Hi ${name}!${seen} Tell me more about what you're working on, or just drop your first topic, assignment, exam, or question and we'll dig in.`;
|
|
140
|
+
}
|
|
141
|
+
function buildProfilePromptSuffix(profile) {
|
|
142
|
+
var _a2;
|
|
143
|
+
const styles = styleLabels(profile).join(" and ");
|
|
144
|
+
const tone = (_a2 = optionById(REMINDER_TONES, profile.reminderTone)) == null ? void 0 : _a2.label.toLowerCase();
|
|
145
|
+
const parts = [];
|
|
146
|
+
if (styles) parts.push(`in ${article(styles)} ${styles} format`);
|
|
147
|
+
if (tone) parts.push(`with ${article(tone)} ${tone} tone`);
|
|
148
|
+
return parts.length ? ` Teach ${parts.join(" ")}.` : "";
|
|
149
|
+
}
|
|
150
|
+
const PROFILE_SUFFIX_PATTERN = /\s+Teach (?:in an? .+? format(?: with an? \S+ tone)?|with an? \S+ tone)\.$/;
|
|
151
|
+
let storage = null;
|
|
152
|
+
try {
|
|
153
|
+
storage = (_a = require("@react-native-async-storage/async-storage").default) != null ? _a : null;
|
|
154
|
+
} catch (e) {
|
|
155
|
+
storage = null;
|
|
156
|
+
}
|
|
157
|
+
const KEY_PREFIX = "yantra.study.profile.v1:";
|
|
158
|
+
const cache = /* @__PURE__ */ new Map();
|
|
159
|
+
const hydrating = /* @__PURE__ */ new Map();
|
|
160
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
161
|
+
function scopeKey(scope) {
|
|
162
|
+
return scope.trim().toLowerCase() || "default";
|
|
163
|
+
}
|
|
164
|
+
function parseStudyProfile(raw) {
|
|
165
|
+
if (!raw) return EMPTY_PROFILE;
|
|
166
|
+
try {
|
|
167
|
+
const parsed = JSON.parse(raw);
|
|
168
|
+
if (!parsed || typeof parsed !== "object") return EMPTY_PROFILE;
|
|
169
|
+
return {
|
|
170
|
+
preferredName: typeof parsed.preferredName === "string" ? parsed.preferredName : "",
|
|
171
|
+
studyTime: typeof parsed.studyTime === "string" ? parsed.studyTime : null,
|
|
172
|
+
learningStyles: Array.isArray(parsed.learningStyles) ? parsed.learningStyles.filter((id) => typeof id === "string") : [],
|
|
173
|
+
accountability: typeof parsed.accountability === "string" ? parsed.accountability : null,
|
|
174
|
+
reminderTone: typeof parsed.reminderTone === "string" ? parsed.reminderTone : null,
|
|
175
|
+
onboardedAt: typeof parsed.onboardedAt === "string" ? parsed.onboardedAt : null
|
|
176
|
+
};
|
|
177
|
+
} catch (e) {
|
|
178
|
+
return EMPTY_PROFILE;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function hydrate(key) {
|
|
182
|
+
const known = cache.get(key);
|
|
183
|
+
if (known) return Promise.resolve(known);
|
|
184
|
+
let pending = hydrating.get(key);
|
|
185
|
+
if (!pending) {
|
|
186
|
+
pending = (storage ? storage.getItem(`${KEY_PREFIX}${key}`) : Promise.resolve(null)).catch(() => null).then((raw) => {
|
|
187
|
+
var _a2;
|
|
188
|
+
const profile = (_a2 = cache.get(key)) != null ? _a2 : parseStudyProfile(raw);
|
|
189
|
+
cache.set(key, profile);
|
|
190
|
+
hydrating.delete(key);
|
|
191
|
+
return profile;
|
|
192
|
+
});
|
|
193
|
+
hydrating.set(key, pending);
|
|
194
|
+
}
|
|
195
|
+
return pending;
|
|
196
|
+
}
|
|
197
|
+
function saveStudyProfile(scope, patch) {
|
|
198
|
+
var _a2, _b;
|
|
199
|
+
const key = scopeKey(scope);
|
|
200
|
+
const next = __spreadValues(__spreadValues({}, (_a2 = cache.get(key)) != null ? _a2 : EMPTY_PROFILE), patch);
|
|
201
|
+
cache.set(key, next);
|
|
202
|
+
storage == null ? void 0 : storage.setItem(`${KEY_PREFIX}${key}`, JSON.stringify(next)).catch(() => void 0);
|
|
203
|
+
(_b = listeners.get(key)) == null ? void 0 : _b.forEach((listener) => listener(next));
|
|
204
|
+
return next;
|
|
205
|
+
}
|
|
206
|
+
function useStudyProfile(scope) {
|
|
207
|
+
const key = scopeKey(scope);
|
|
208
|
+
const [profile, setProfile] = useState(() => {
|
|
209
|
+
var _a2;
|
|
210
|
+
return (_a2 = cache.get(key)) != null ? _a2 : null;
|
|
211
|
+
});
|
|
212
|
+
useEffect(() => {
|
|
213
|
+
var _a2;
|
|
214
|
+
let alive = true;
|
|
215
|
+
const listener = (next) => setProfile(next);
|
|
216
|
+
const set = (_a2 = listeners.get(key)) != null ? _a2 : /* @__PURE__ */ new Set();
|
|
217
|
+
set.add(listener);
|
|
218
|
+
listeners.set(key, set);
|
|
219
|
+
void hydrate(key).then((value) => {
|
|
220
|
+
if (alive) setProfile(value);
|
|
221
|
+
});
|
|
222
|
+
return () => {
|
|
223
|
+
alive = false;
|
|
224
|
+
set.delete(listener);
|
|
225
|
+
};
|
|
226
|
+
}, [key]);
|
|
227
|
+
const update = useCallback((patch) => void saveStudyProfile(key, patch), [key]);
|
|
228
|
+
return {
|
|
229
|
+
profile: profile != null ? profile : EMPTY_PROFILE,
|
|
230
|
+
loaded: profile !== null,
|
|
231
|
+
update
|
|
232
|
+
};
|
|
233
|
+
}export{ACCOUNTABILITY_LEVELS,EMPTY_PROFILE,LEARNING_STYLES,PROFILE_SUFFIX_PATTERN,REMINDER_TONES,STUDY_TIMES,buildProfilePromptSuffix,buildTutorGreeting,optionById,parseStudyProfile,saveStudyProfile,useStudyProfile};//# sourceMappingURL=studyProfile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studyProfile.js","sources":["../../../src/features/study/studyProfile.ts"],"sourcesContent":["/**\n * The tutor setup: how the person wants to be taught. Same answers and option\n * catalogs as the web Study wizard (yantra-surface notebooklm studyProfile.ts),\n * kept on the phone per workspace. They shape the tutor's greeting and how it\n * teaches; notebooks themselves stay entirely in the yantra-notebook store.\n */\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface StudyOption {\n id: string;\n emoji: string;\n label: string;\n description?: string;\n /** An example reminder in this tone. */\n quote?: string;\n}\n\nexport const STUDY_TIMES: StudyOption[] = [\n { id: 'early', emoji: '🌅', label: 'Early Bird (5 – 8 AM)', description: 'First light, fresh mind' },\n { id: 'morning', emoji: '☀️', label: 'Morning (8 AM – 12 PM)', description: 'Prime focus hours' },\n { id: 'afternoon', emoji: '🌤️', label: 'Afternoon (12 – 5 PM)', description: 'Steady midday blocks' },\n { id: 'evening', emoji: '🌆', label: 'Evening (5 – 10 PM)', description: 'Wind-down deep work' },\n { id: 'night', emoji: '🦉', label: 'Night Owl (10 PM – 2 AM)', description: 'Quiet late-night focus' },\n];\n\nexport const LEARNING_STYLES: StudyOption[] = [\n { id: 'visual', emoji: '🎨', label: 'Visual', description: 'Diagrams, charts, and examples' },\n {\n id: 'reading',\n emoji: '📝',\n label: 'Reading and writing',\n description: 'Notes, outlines, and written explanations',\n },\n { id: 'practice', emoji: '🔧', label: 'Practice problems', description: 'Worked examples, drills, and feedback' },\n { id: 'discussion', emoji: '💬', label: 'Discussion', description: 'Talk through concepts step by step' },\n];\n\nexport const ACCOUNTABILITY_LEVELS: StudyOption[] = [\n { id: 'light', emoji: '🌿', label: 'Light check-ins' },\n { id: 'steady', emoji: '📈', label: 'Steady follow-through' },\n { id: 'structured', emoji: '🎯', label: 'Structured accountability' },\n { id: 'high', emoji: '🔥', label: 'High-accountability mode' },\n];\n\nexport const REMINDER_TONES: StudyOption[] = [\n {\n id: 'gentle',\n emoji: '🕊️',\n label: 'Gentle',\n quote: '\"You planned a study block today. Start with one small task.\"',\n },\n {\n id: 'encouraging',\n emoji: '🌟',\n label: 'Encouraging',\n quote: '\"You\\'re building momentum. One focused session keeps it going.\"',\n },\n {\n id: 'direct',\n emoji: '📋',\n label: 'Direct',\n quote: '\"You missed yesterday. Do 20 minutes today to stay on track.\"',\n },\n { id: 'firm', emoji: '💪', label: 'Firm', quote: '\"Your exam is in 2 weeks. Let\\'s put in the work today.\"' },\n];\n\nexport interface StudyProfile {\n preferredName: string;\n studyTime: string | null;\n learningStyles: string[];\n accountability: string | null;\n reminderTone: string | null;\n /** ISO time the setup was finished; until then Study opens on the setup. */\n onboardedAt: string | null;\n}\n\nexport const EMPTY_PROFILE: StudyProfile = {\n preferredName: '',\n studyTime: null,\n learningStyles: [],\n accountability: null,\n reminderTone: null,\n onboardedAt: null,\n};\n\nexport function optionById(options: readonly StudyOption[], id: string | null | undefined): StudyOption | undefined {\n return id ? options.find((option) => option.id === id) : undefined;\n}\n\nconst article = (word: string) => (/^[aeiou]/i.test(word) ? 'an' : 'a');\n\nfunction styleLabels(profile: StudyProfile): string[] {\n return profile.learningStyles\n .map((id) => optionById(LEARNING_STYLES, id)?.label.toLowerCase())\n .filter((label): label is string => Boolean(label));\n}\n\n/** The tutor's first words in every notebook, in the person's own terms. */\nexport function buildTutorGreeting(profile: StudyProfile): string {\n const name = profile.preferredName.trim() || 'there';\n const time = optionById(STUDY_TIMES, profile.studyTime);\n const styles = styleLabels(profile);\n const level = optionById(ACCOUNTABILITY_LEVELS, profile.accountability);\n const tone = optionById(REMINDER_TONES, profile.reminderTone);\n const traits: string[] = [];\n if (time) {\n const label = time.label.replace(/\\s*\\(.*\\)/, '').toLowerCase();\n traits.push(`you're ${article(label)} ${label} studier`);\n }\n if (styles.length) traits.push(`you like ${styles.join(' and ')}`);\n if (level) traits.push(`you thrive on ${level.label.toLowerCase()}`);\n if (tone) {\n const label = tone.label.toLowerCase();\n traits.push(`you prefer ${article(label)} ${label} tone`);\n }\n const seen = traits.length ? ` I see ${traits.join(', ')}, so I'll match that.` : '';\n return (\n `Hi ${name}!${seen} Tell me more about what you're working on, ` +\n `or just drop your first topic, assignment, exam, or question and we'll dig in.`\n );\n}\n\n/** Appended to the tutor's outline requests: \" Teach in a visual format with an encouraging tone.\" */\nexport function buildProfilePromptSuffix(profile: StudyProfile): string {\n const styles = styleLabels(profile).join(' and ');\n const tone = optionById(REMINDER_TONES, profile.reminderTone)?.label.toLowerCase();\n const parts: string[] = [];\n if (styles) parts.push(`in ${article(styles)} ${styles} format`);\n if (tone) parts.push(`with ${article(tone)} ${tone} tone`);\n return parts.length ? ` Teach ${parts.join(' ')}.` : '';\n}\n\n/** The trailing \" Teach in … .\" a prompt was sent with, so the transcript shows the person's words. */\nexport const PROFILE_SUFFIX_PATTERN = /\\s+Teach (?:in an? .+? format(?: with an? \\S+ tone)?|with an? \\S+ tone)\\.$/;\n\n// ── Store ───────────────────────────────────────────────────────────────────\n\ntype StorageLike = {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n};\n\nlet storage: StorageLike | null = null;\ntry {\n // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require\n storage = require('@react-native-async-storage/async-storage').default ?? null;\n} catch {\n storage = null;\n}\n\nconst KEY_PREFIX = 'yantra.study.profile.v1:';\n\nconst cache = new Map<string, StudyProfile>();\nconst hydrating = new Map<string, Promise<StudyProfile>>();\nconst listeners = new Map<string, Set<(profile: StudyProfile) => void>>();\n\nfunction scopeKey(scope: string): string {\n return scope.trim().toLowerCase() || 'default';\n}\n\nexport function parseStudyProfile(raw: string | null): StudyProfile {\n if (!raw) return EMPTY_PROFILE;\n try {\n const parsed = JSON.parse(raw) as Partial<StudyProfile> | null;\n if (!parsed || typeof parsed !== 'object') return EMPTY_PROFILE;\n return {\n preferredName: typeof parsed.preferredName === 'string' ? parsed.preferredName : '',\n studyTime: typeof parsed.studyTime === 'string' ? parsed.studyTime : null,\n learningStyles: Array.isArray(parsed.learningStyles)\n ? parsed.learningStyles.filter((id): id is string => typeof id === 'string')\n : [],\n accountability: typeof parsed.accountability === 'string' ? parsed.accountability : null,\n reminderTone: typeof parsed.reminderTone === 'string' ? parsed.reminderTone : null,\n onboardedAt: typeof parsed.onboardedAt === 'string' ? parsed.onboardedAt : null,\n };\n } catch {\n return EMPTY_PROFILE;\n }\n}\n\nfunction hydrate(key: string): Promise<StudyProfile> {\n const known = cache.get(key);\n if (known) return Promise.resolve(known);\n let pending = hydrating.get(key);\n if (!pending) {\n pending = (storage ? storage.getItem(`${KEY_PREFIX}${key}`) : Promise.resolve(null))\n .catch(() => null)\n .then((raw) => {\n // A save that landed while reading wins over what was on disk.\n const profile = cache.get(key) ?? parseStudyProfile(raw);\n cache.set(key, profile);\n hydrating.delete(key);\n return profile;\n });\n hydrating.set(key, pending);\n }\n return pending;\n}\n\nexport function saveStudyProfile(scope: string, patch: Partial<StudyProfile>): StudyProfile {\n const key = scopeKey(scope);\n const next = { ...(cache.get(key) ?? EMPTY_PROFILE), ...patch };\n cache.set(key, next);\n storage?.setItem(`${KEY_PREFIX}${key}`, JSON.stringify(next)).catch(() => undefined);\n listeners.get(key)?.forEach((listener) => listener(next));\n return next;\n}\n\n/** Test seam: forget what was read. */\nexport function resetStudyProfileCache(): void {\n cache.clear();\n hydrating.clear();\n}\n\n/** The tutor setup for this workspace; `loaded` is false until the saved answers were read. */\nexport function useStudyProfile(scope: string): {\n profile: StudyProfile;\n loaded: boolean;\n update: (patch: Partial<StudyProfile>) => void;\n} {\n const key = scopeKey(scope);\n const [profile, setProfile] = useState<StudyProfile | null>(() => cache.get(key) ?? null);\n\n useEffect(() => {\n let alive = true;\n const listener = (next: StudyProfile) => setProfile(next);\n const set = listeners.get(key) ?? new Set();\n set.add(listener);\n listeners.set(key, set);\n void hydrate(key).then((value) => {\n if (alive) setProfile(value);\n });\n return () => {\n alive = false;\n set.delete(listener);\n };\n }, [key]);\n\n const update = useCallback((patch: Partial<StudyProfile>) => void saveStudyProfile(key, patch), [key]);\n\n return { profile: profile ?? EMPTY_PROFILE, loaded: profile !== null, update };\n}\n"],"names":["_a"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAA,EAAA;AAeO,MAAM,cAA6B,CAAC;AAAA,EACzC,EAAI,EAAA,OAAA;AAAA,EACJ,KAAO,EAAA,WAAA;AAAA,EACP,KAAO,EAAA,4BAAA;AAAA,EACP,WAAa,EAAA;AACf,CAAG,EAAA;AAAA,EACD,EAAI,EAAA,SAAA;AAAA,EACJ,KAAO,EAAA,cAAA;AAAA,EACP,KAAO,EAAA,6BAAA;AAAA,EACP,WAAa,EAAA;AACf,CAAG,EAAA;AA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,KAAK,CAAA;AAAA,KAC5B,CAAA;AACD,IAAA,OAAO,MAAM;AACX,MAAQ,KAAA,GAAA,KAAA;AACR,MAAA,GAAA,CAAI,OAAO,QAAQ,CAAA;AAAA,KACrB;AAAA,GACF,EAAG,CAAC,GAAG,CAAC,CAAA;AACR,EAAM,MAAA,MAAA,GAAS,WAAY,CAAA,CAAC,KAAiC,KAAA,KAAK,gBAAiB,CAAA,GAAA,EAAK,KAAK,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AACrG,EAAO,OAAA;AAAA,IACL,SAAS,OAAW,IAAA,IAAA,GAAA,OAAA,GAAA,aAAA;AAAA,IACpB,QAAQ,OAAY,KAAA,IAAA;AAAA,IACpB;AAAA,GACF;AACF"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {PROFILE_SUFFIX_PATTERN}from'./studyProfile.js';function deriveTitle(raw, fallback) {
|
|
2
|
+
const clean = raw.replace(/\s+/g, " ").trim();
|
|
3
|
+
if (!clean) return fallback;
|
|
4
|
+
return clean.length > 48 ? `${clean.slice(0, 47)}\u2026` : clean;
|
|
5
|
+
}
|
|
6
|
+
function titleFromText(raw, fallback) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
const firstLine = (_a = raw.split("\n").find((line) => line.trim())) != null ? _a : "";
|
|
9
|
+
const sentence = (_c = (_b = firstLine.trim().match(/^.*?[.!?](?=\s|$)/)) == null ? void 0 : _b[0]) != null ? _c : firstLine;
|
|
10
|
+
return deriveTitle(sentence.replace(/[.:;,]+$/, ""), fallback);
|
|
11
|
+
}
|
|
12
|
+
const OUTLINE_PROMPTS = {
|
|
13
|
+
files: "I added source material to this notebook. Create a study outline: the key concepts, what to master first, and three practice questions.",
|
|
14
|
+
link: "Outline what I should study from the page I shared, and the key questions to master.",
|
|
15
|
+
text: "Turn the pasted source into something I can master: key points, a short outline, and three practice questions."
|
|
16
|
+
};
|
|
17
|
+
const TUTOR_SHORTCUTS = [{
|
|
18
|
+
id: "summarize",
|
|
19
|
+
label: "Summarize",
|
|
20
|
+
kind: "summarize",
|
|
21
|
+
prompt: "Summarize this notebook",
|
|
22
|
+
said: "Summarize this notebook"
|
|
23
|
+
}, {
|
|
24
|
+
id: "quiz",
|
|
25
|
+
label: "Quiz me",
|
|
26
|
+
kind: "ask",
|
|
27
|
+
prompt: "Quiz me on this notebook: five questions that test the key ideas, with the answers listed at the end.",
|
|
28
|
+
said: "Quiz me"
|
|
29
|
+
}, {
|
|
30
|
+
id: "flashcards",
|
|
31
|
+
label: "Flashcards",
|
|
32
|
+
kind: "ask",
|
|
33
|
+
prompt: "Turn this notebook into flashcards: a question on the front and a short answer on the back, as a list.",
|
|
34
|
+
said: "Make me flashcards"
|
|
35
|
+
}, {
|
|
36
|
+
id: "simple",
|
|
37
|
+
label: "Explain simply",
|
|
38
|
+
kind: "ask",
|
|
39
|
+
prompt: "Explain the main topic of this notebook in simple terms, like I am new to it.",
|
|
40
|
+
said: "Explain it simply"
|
|
41
|
+
}, {
|
|
42
|
+
id: "plan",
|
|
43
|
+
label: "Study plan",
|
|
44
|
+
kind: "ask",
|
|
45
|
+
prompt: "Build me a one-week study plan for this notebook, with a short daily goal.",
|
|
46
|
+
said: "Build me a study plan"
|
|
47
|
+
}];
|
|
48
|
+
const SYSTEM_ASKS = [{
|
|
49
|
+
prefix: "I added source material to this notebook",
|
|
50
|
+
label: "Make me a study outline"
|
|
51
|
+
}, {
|
|
52
|
+
prefix: "I uploaded source material into this notebook",
|
|
53
|
+
label: "Make me a study outline"
|
|
54
|
+
}, {
|
|
55
|
+
prefix: "Outline what I should study from the page I shared",
|
|
56
|
+
label: "Outline this page for me"
|
|
57
|
+
}, {
|
|
58
|
+
prefix: "I shared this link:",
|
|
59
|
+
label: "Outline this page for me"
|
|
60
|
+
}, {
|
|
61
|
+
prefix: "Turn the pasted source",
|
|
62
|
+
label: "Help me master these notes"
|
|
63
|
+
}, {
|
|
64
|
+
prefix: "Seed an outline for this notebook",
|
|
65
|
+
label: "Outline this topic"
|
|
66
|
+
}];
|
|
67
|
+
function displayPrompt(prompt) {
|
|
68
|
+
const trimmed = prompt.trim();
|
|
69
|
+
const shortcut = TUTOR_SHORTCUTS.find((item) => item.prompt === trimmed);
|
|
70
|
+
if (shortcut) return shortcut.said;
|
|
71
|
+
const system = SYSTEM_ASKS.find((ask) => trimmed.startsWith(ask.prefix));
|
|
72
|
+
if (system) return system.label;
|
|
73
|
+
return trimmed.replace(PROFILE_SUFFIX_PATTERN, "").trim();
|
|
74
|
+
}
|
|
75
|
+
function cellRole(cell) {
|
|
76
|
+
if (cell.type === "ai") return "ask";
|
|
77
|
+
return /^###\s+(Source\b|Source link\b|Pasted source\b)/.test(cell.content.trimStart()) ? "source" : "note";
|
|
78
|
+
}export{OUTLINE_PROMPTS,TUTOR_SHORTCUTS,cellRole,deriveTitle,displayPrompt,titleFromText};//# sourceMappingURL=studyPrompts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studyPrompts.js","sources":["../../../src/features/study/studyPrompts.ts"],"sourcesContent":["/**\n * What Study asks the tutor, and how those asks read back in the transcript.\n * The tutor is the yantra-notebook connector: each ask becomes an AI cell whose\n * `prompt` is stored with it, so the transcript is rebuilt from the notebook.\n */\nimport { PROFILE_SUFFIX_PATTERN } from './studyProfile';\nimport type { StudyCell } from './types';\n\n/** A notebook title from what the person brought: whitespace folded, at most 48 characters. */\nexport function deriveTitle(raw: string, fallback: string): string {\n const clean = raw.replace(/\\s+/g, ' ').trim();\n if (!clean) return fallback;\n return clean.length > 48 ? `${clean.slice(0, 47)}…` : clean;\n}\n\n/**\n * A title from the opening of a text: its first sentence on the first line,\n * without a trailing full stop (\"Photosynthesis. Plants turn…\" -> \"Photosynthesis\").\n */\nexport function titleFromText(raw: string, fallback: string): string {\n const firstLine = raw.split('\\n').find((line) => line.trim()) ?? '';\n const sentence = firstLine.trim().match(/^.*?[.!?](?=\\s|$)/)?.[0] ?? firstLine;\n return deriveTitle(sentence.replace(/[.:;,]+$/, ''), fallback);\n}\n\n/** The intake asks: the tutor turns fresh sources into a plan, once. */\nexport const OUTLINE_PROMPTS = {\n files: 'I added source material to this notebook. Create a study outline: the key concepts, what to master first, and three practice questions.',\n link: 'Outline what I should study from the page I shared, and the key questions to master.',\n text: 'Turn the pasted source into something I can master: key points, a short outline, and three practice questions.',\n} as const;\n\nexport interface TutorShortcut {\n id: string;\n label: string;\n /** `summarize` runs the connector's own summary; anything else is a tutor ask. */\n kind: 'summarize' | 'ask';\n prompt: string;\n /** How the ask reads in the transcript: the person's words, not the instructions. */\n said: string;\n}\n\n/** One-tap asks under the composer once a notebook has something to work from. */\nexport const TUTOR_SHORTCUTS: TutorShortcut[] = [\n {\n id: 'summarize',\n label: 'Summarize',\n kind: 'summarize',\n prompt: 'Summarize this notebook',\n said: 'Summarize this notebook',\n },\n {\n id: 'quiz',\n label: 'Quiz me',\n kind: 'ask',\n prompt: 'Quiz me on this notebook: five questions that test the key ideas, with the answers listed at the end.',\n said: 'Quiz me',\n },\n {\n id: 'flashcards',\n label: 'Flashcards',\n kind: 'ask',\n prompt: 'Turn this notebook into flashcards: a question on the front and a short answer on the back, as a list.',\n said: 'Make me flashcards',\n },\n {\n id: 'simple',\n label: 'Explain simply',\n kind: 'ask',\n prompt: 'Explain the main topic of this notebook in simple terms, like I am new to it.',\n said: 'Explain it simply',\n },\n {\n id: 'plan',\n label: 'Study plan',\n kind: 'ask',\n prompt: 'Build me a one-week study plan for this notebook, with a short daily goal.',\n said: 'Build me a study plan',\n },\n];\n\n/** Asks Study (web or phone) makes on the person's behalf, shown by what they mean. */\nconst SYSTEM_ASKS: Array<{ prefix: string; label: string }> = [\n { prefix: 'I added source material to this notebook', label: 'Make me a study outline' },\n { prefix: 'I uploaded source material into this notebook', label: 'Make me a study outline' },\n { prefix: 'Outline what I should study from the page I shared', label: 'Outline this page for me' },\n { prefix: 'I shared this link:', label: 'Outline this page for me' },\n { prefix: 'Turn the pasted source', label: 'Help me master these notes' },\n { prefix: 'Seed an outline for this notebook', label: 'Outline this topic' },\n];\n\n/** The question as the person would say it: no profile suffix, no internal intake wording. */\nexport function displayPrompt(prompt: string): string {\n const trimmed = prompt.trim();\n const shortcut = TUTOR_SHORTCUTS.find((item) => item.prompt === trimmed);\n if (shortcut) return shortcut.said;\n const system = SYSTEM_ASKS.find((ask) => trimmed.startsWith(ask.prefix));\n if (system) return system.label;\n return trimmed.replace(PROFILE_SUFFIX_PATTERN, '').trim();\n}\n\nexport type CellRole = 'ask' | 'note' | 'source';\n\n/**\n * How a cell reads in the conversation: a tutor answer (with the question it\n * answers), a note the person wrote, or a source the web Study inlined as a\n * `### Source…` / `### Pasted source` note.\n */\nexport function cellRole(cell: StudyCell): CellRole {\n if (cell.type === 'ai') return 'ask';\n return /^###\\s+(Source\\b|Source link\\b|Pasted source\\b)/.test(cell.content.trimStart()) ? 'source' : 'note';\n}\n"],"names":[],"mappings":"uDASgB,SAAA,WAAA,CAAY,KAAa,QAA0B,EAAA;AACjE,EAAA,MAAM,QAAQ,GAAI,CAAA,OAAA,CAAQ,MAAQ,EAAA,GAAG,EAAE,IAAK,EAAA;AAC5C,EAAI,IAAA,CAAC,OAAc,OAAA,QAAA;AACnB,EAAO,OAAA,KAAA,CAAM,SAAS,EAAK,GAAA,CAAA,EAAG,MAAM,KAAM,CAAA,CAAA,EAAG,EAAE,CAAC,CAAM,MAAA,CAAA,GAAA,KAAA;AACxD;AAMgB,SAAA,aAAA,CAAc,KAAa,QAA0B,EAAA;AAnBrE,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAoBE,EAAM,MAAA,SAAA,GAAA,CAAY,EAAI,GAAA,GAAA,CAAA,KAAA,CAAM,IAAI,CAAA,CAAE,IAAK,CAAA,CAAA,IAAA,KAAQ,IAAK,CAAA,IAAA,EAAM,CAAA,KAAxC,IAA6C,GAAA,EAAA,GAAA,EAAA;AAC/D,EAAM,MAAA,QAAA,GAAA,CAAW,qBAAU,IAAK,EAAA,CAAE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+
border: "rgba(183,196,230,0.14)",
|
|
8
|
+
ink: "#eef1f8",
|
|
9
|
+
muted: "#a3acc2",
|
|
10
|
+
faint: "#6f7890",
|
|
11
|
+
selected: "rgba(183,196,230,0.12)",
|
|
12
|
+
selectedLine: "#5d6f9c",
|
|
13
|
+
chip: "#232b3d",
|
|
14
|
+
accent: "#dfe5f5",
|
|
15
|
+
accentInk: "#0d1b34",
|
|
16
|
+
bubble: "#232b3d",
|
|
17
|
+
danger: "#f87171",
|
|
18
|
+
dangerSoft: "rgba(248,113,113,0.14)",
|
|
19
|
+
toast: "#dfe5f5",
|
|
20
|
+
toastInk: "#0d1b34"
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
isDark: false,
|
|
25
|
+
screen: "#f2f1ee",
|
|
26
|
+
card: "#fbfaf8",
|
|
27
|
+
border: "#e2e0da",
|
|
28
|
+
ink: "#14213d",
|
|
29
|
+
muted: "#5f6b85",
|
|
30
|
+
faint: "#8b94a8",
|
|
31
|
+
selected: "#e9edf8",
|
|
32
|
+
selectedLine: "#b7c4e6",
|
|
33
|
+
chip: "#dfe5f5",
|
|
34
|
+
accent: "#0d1b34",
|
|
35
|
+
accentInk: "#ffffff",
|
|
36
|
+
bubble: "#ffffff",
|
|
37
|
+
danger: "#dc2626",
|
|
38
|
+
dangerSoft: "#fdecec",
|
|
39
|
+
toast: "#0d1b34",
|
|
40
|
+
toastInk: "#ffffff"
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const DISPLAY_FONT = Platform.select({
|
|
44
|
+
ios: "Iowan Old Style",
|
|
45
|
+
android: "serif",
|
|
46
|
+
default: void 0
|
|
47
|
+
});export{DISPLAY_FONT,studyTheme};//# sourceMappingURL=studyTheme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studyTheme.js","sources":["../../../src/features/study/studyTheme.ts"],"sourcesContent":["/**\n * Study visual tokens. The web Study palette (yantra-surface notebooklm\n * tailwind `study.*`): warm paper, deep navy ink and a navy accent, with a\n * book serif for headings. Dark mode keeps the same roles on a night desk.\n */\nimport { Platform } from 'react-native';\n\nexport type StudyTheme = {\n isDark: boolean;\n /** Screen background (web `study.bg`). */\n screen: string;\n /** Raised cards (web `study.card`). */\n card: string;\n /** Hairlines (web `study.line`). */\n border: string;\n ink: string;\n muted: string;\n faint: string;\n /** Selected option fill and border (web `study.sel` / `study.selline`). */\n selected: string;\n selectedLine: string;\n chip: string;\n accent: string;\n accentInk: string;\n /** The person's own words in the conversation. */\n bubble: string;\n danger: string;\n dangerSoft: string;\n toast: string;\n toastInk: string;\n};\n\nexport function studyTheme(isDark: boolean): StudyTheme {\n if (isDark) {\n return {\n isDark: true,\n screen: '#10141d',\n card: '#181d29',\n border: 'rgba(183,196,230,0.14)',\n ink: '#eef1f8',\n muted: '#a3acc2',\n faint: '#6f7890',\n selected: 'rgba(183,196,230,0.12)',\n selectedLine: '#5d6f9c',\n chip: '#232b3d',\n accent: '#dfe5f5',\n accentInk: '#0d1b34',\n bubble: '#232b3d',\n danger: '#f87171',\n dangerSoft: 'rgba(248,113,113,0.14)',\n toast: '#dfe5f5',\n toastInk: '#0d1b34',\n };\n }\n return {\n isDark: false,\n screen: '#f2f1ee',\n card: '#fbfaf8',\n border: '#e2e0da',\n ink: '#14213d',\n muted: '#5f6b85',\n faint: '#8b94a8',\n selected: '#e9edf8',\n selectedLine: '#b7c4e6',\n chip: '#dfe5f5',\n accent: '#0d1b34',\n accentInk: '#ffffff',\n bubble: '#ffffff',\n danger: '#dc2626',\n dangerSoft: '#fdecec',\n toast: '#0d1b34',\n toastInk: '#ffffff',\n };\n}\n\n/** The web's `font-display` stack: Iowan Old Style ships with iOS; Android has a system serif. */\nexport const DISPLAY_FONT = Platform.select({ ios: 'Iowan Old Style', android: 'serif', default: undefined });\n"],"names":[],"mappings":"oCA8BO,SAAS,WAAW,MAA6B,EAAA;AACtD,EAAA,IAAI,MAAQ,EAAA;AACV,IAAO,OAAA;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