@contractspec/example.learning-journey-registry 0.0.0-canary-20260113170453
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/.turbo/turbo-build$colon$bundle.log +50 -0
- package/.turbo/turbo-build.log +51 -0
- package/CHANGELOG.md +612 -0
- package/LICENSE +21 -0
- package/README.md +25 -0
- package/dist/api-types.d.ts +41 -0
- package/dist/api-types.d.ts.map +1 -0
- package/dist/api-types.js +0 -0
- package/dist/api.d.ts +13 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +171 -0
- package/dist/api.js.map +1 -0
- package/dist/docs/index.d.ts +1 -0
- package/dist/docs/index.js +1 -0
- package/dist/docs/learning-journey-registry.docblock.d.ts +1 -0
- package/dist/docs/learning-journey-registry.docblock.js +38 -0
- package/dist/docs/learning-journey-registry.docblock.js.map +1 -0
- package/dist/example.d.ts +7 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/example.js +42 -0
- package/dist/example.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10 -0
- package/dist/learning-journey-registry.feature.d.ts +12 -0
- package/dist/learning-journey-registry.feature.d.ts.map +1 -0
- package/dist/learning-journey-registry.feature.js +75 -0
- package/dist/learning-journey-registry.feature.js.map +1 -0
- package/dist/presentations/index.d.ts +10 -0
- package/dist/presentations/index.d.ts.map +1 -0
- package/dist/presentations/index.js +71 -0
- package/dist/presentations/index.js.map +1 -0
- package/dist/progress-store.d.ts +11 -0
- package/dist/progress-store.d.ts.map +1 -0
- package/dist/progress-store.js +31 -0
- package/dist/progress-store.js.map +1 -0
- package/dist/tracks.d.ts +40 -0
- package/dist/tracks.d.ts.map +1 -0
- package/dist/tracks.js +48 -0
- package/dist/tracks.js.map +1 -0
- package/dist/ui/LearningMiniApp.d.ts +24 -0
- package/dist/ui/LearningMiniApp.d.ts.map +1 -0
- package/dist/ui/LearningMiniApp.js +80 -0
- package/dist/ui/LearningMiniApp.js.map +1 -0
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +3 -0
- package/example.ts +1 -0
- package/package.json +86 -0
- package/src/api-types.ts +43 -0
- package/src/api.test.ts +46 -0
- package/src/api.ts +301 -0
- package/src/docs/index.ts +1 -0
- package/src/docs/learning-journey-registry.docblock.ts +36 -0
- package/src/example.ts +31 -0
- package/src/index.ts +8 -0
- package/src/learning-journey-registry.feature.ts +64 -0
- package/src/presentations/index.ts +65 -0
- package/src/progress-store.ts +39 -0
- package/src/tracks.ts +91 -0
- package/src/ui/LearningMiniApp.tsx +121 -0
- package/src/ui/index.ts +5 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/tsdown.config.js +17 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { GamifiedMiniApp } from '@contractspec/example.learning-journey-ui-gamified';
|
|
5
|
+
import { OnboardingMiniApp } from '@contractspec/example.learning-journey-ui-onboarding';
|
|
6
|
+
import { CoachingMiniApp } from '@contractspec/example.learning-journey-ui-coaching';
|
|
7
|
+
import type { LearningView } from '@contractspec/example.learning-journey-ui-shared';
|
|
8
|
+
import { learningJourneyTracks } from '../tracks';
|
|
9
|
+
|
|
10
|
+
/** Template IDs that map to learning journey tracks */
|
|
11
|
+
type LearningTemplateId =
|
|
12
|
+
| 'learning-journey-duo-drills'
|
|
13
|
+
| 'learning-journey-quest-challenges'
|
|
14
|
+
| 'learning-journey-studio-onboarding'
|
|
15
|
+
| 'learning-journey-platform-tour'
|
|
16
|
+
| 'learning-journey-ambient-coach'
|
|
17
|
+
| 'learning-journey-crm-onboarding';
|
|
18
|
+
|
|
19
|
+
/** Map template IDs to track IDs */
|
|
20
|
+
const TEMPLATE_TO_TRACK: Record<LearningTemplateId, string> = {
|
|
21
|
+
'learning-journey-duo-drills': 'drills_language_basics',
|
|
22
|
+
'learning-journey-quest-challenges': 'money_reset_7day',
|
|
23
|
+
'learning-journey-studio-onboarding': 'studio_getting_started',
|
|
24
|
+
'learning-journey-platform-tour': 'platform_tour',
|
|
25
|
+
'learning-journey-ambient-coach': 'money_ambient_coach',
|
|
26
|
+
'learning-journey-crm-onboarding': 'crm_first_win',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/** Map template IDs to mini-app type */
|
|
30
|
+
const TEMPLATE_TO_APP_TYPE: Record<
|
|
31
|
+
LearningTemplateId,
|
|
32
|
+
'gamified' | 'onboarding' | 'coaching'
|
|
33
|
+
> = {
|
|
34
|
+
'learning-journey-duo-drills': 'gamified',
|
|
35
|
+
'learning-journey-quest-challenges': 'gamified',
|
|
36
|
+
'learning-journey-studio-onboarding': 'onboarding',
|
|
37
|
+
'learning-journey-platform-tour': 'onboarding',
|
|
38
|
+
'learning-journey-ambient-coach': 'coaching',
|
|
39
|
+
'learning-journey-crm-onboarding': 'coaching',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
interface LearningMiniAppProps {
|
|
43
|
+
templateId: string;
|
|
44
|
+
initialView?: LearningView;
|
|
45
|
+
onViewChange?: (view: LearningView) => void;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Router component that picks the correct mini-app based on template ID */
|
|
49
|
+
export function LearningMiniApp({
|
|
50
|
+
templateId,
|
|
51
|
+
initialView = 'overview',
|
|
52
|
+
onViewChange,
|
|
53
|
+
}: LearningMiniAppProps) {
|
|
54
|
+
// Find the track for this template
|
|
55
|
+
const track = useMemo(() => {
|
|
56
|
+
const trackId = TEMPLATE_TO_TRACK[templateId as LearningTemplateId];
|
|
57
|
+
if (!trackId) return null;
|
|
58
|
+
return learningJourneyTracks.find((t) => t.id === trackId);
|
|
59
|
+
}, [templateId]);
|
|
60
|
+
|
|
61
|
+
// Determine app type
|
|
62
|
+
const appType = TEMPLATE_TO_APP_TYPE[templateId as LearningTemplateId];
|
|
63
|
+
|
|
64
|
+
if (!track) {
|
|
65
|
+
return (
|
|
66
|
+
<div className="rounded-lg border border-amber-500/50 bg-amber-500/10 p-6 text-center">
|
|
67
|
+
<p className="text-amber-500">
|
|
68
|
+
Unknown learning template: {templateId}
|
|
69
|
+
</p>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Render the appropriate mini-app
|
|
75
|
+
switch (appType) {
|
|
76
|
+
case 'gamified':
|
|
77
|
+
return (
|
|
78
|
+
<GamifiedMiniApp
|
|
79
|
+
track={track}
|
|
80
|
+
initialView={initialView}
|
|
81
|
+
onViewChange={onViewChange}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
case 'onboarding':
|
|
85
|
+
return (
|
|
86
|
+
<OnboardingMiniApp
|
|
87
|
+
track={track}
|
|
88
|
+
initialView={initialView}
|
|
89
|
+
onViewChange={onViewChange}
|
|
90
|
+
/>
|
|
91
|
+
);
|
|
92
|
+
case 'coaching':
|
|
93
|
+
return (
|
|
94
|
+
<CoachingMiniApp
|
|
95
|
+
track={track}
|
|
96
|
+
initialView={initialView}
|
|
97
|
+
onViewChange={onViewChange}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
default:
|
|
101
|
+
return (
|
|
102
|
+
<div className="rounded-lg border border-red-500/50 bg-red-500/10 p-6 text-center">
|
|
103
|
+
<p className="text-red-500">
|
|
104
|
+
Unknown app type for template: {templateId}
|
|
105
|
+
</p>
|
|
106
|
+
</div>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** Check if a template ID is a learning journey template */
|
|
112
|
+
export function isLearningTemplate(
|
|
113
|
+
templateId: string
|
|
114
|
+
): templateId is LearningTemplateId {
|
|
115
|
+
return templateId in TEMPLATE_TO_TRACK;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** Get all learning template IDs */
|
|
119
|
+
export function getLearningTemplateIds(): LearningTemplateId[] {
|
|
120
|
+
return Object.keys(TEMPLATE_TO_TRACK) as LearningTemplateId[];
|
|
121
|
+
}
|
package/src/ui/index.ts
ADDED