taleem-engine 1.0.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.
Files changed (65) hide show
  1. package/package.json +51 -0
  2. package/readme.md +472 -0
  3. package/src/compiler/TaleemCompiler.js +122 -0
  4. package/src/compiler/animation-primtives/eqHighlightOne.js +41 -0
  5. package/src/compiler/animation-primtives/progressiveReveal.js +14 -0
  6. package/src/compiler/animation-primtives/runPrimitive.js +71 -0
  7. package/src/compiler/animation-primtives/showAllHighlightOne.js +34 -0
  8. package/src/compiler/animation-primtives/showOneAtATime.js +24 -0
  9. package/src/compiler/templates/compileBarChart.js +91 -0
  10. package/src/compiler/templates/compileBulletList.js +37 -0
  11. package/src/compiler/templates/compileEq.js +135 -0
  12. package/src/compiler/templates/compileFillImage.js +50 -0
  13. package/src/compiler/templates/compileFocusList.js +75 -0
  14. package/src/compiler/templates/compileImageGrid.js +60 -0
  15. package/src/compiler/templates/compileImageLeftBulletsRight.js +78 -0
  16. package/src/compiler/templates/compileImageRightBulletsLeft.js +79 -0
  17. package/src/compiler/templates/compileImageSlide.js +52 -0
  18. package/src/compiler/templates/compileImageStrip.js +60 -0
  19. package/src/compiler/templates/compileImageWithCaption.js +75 -0
  20. package/src/compiler/templates/compileImageWithTitle.js +75 -0
  21. package/src/compiler/templates/compileKeyIdeasSlide.js +62 -0
  22. package/src/compiler/templates/compileProgressbar.js +74 -0
  23. package/src/compiler/templates/compileQuoteSlide.js +72 -0
  24. package/src/compiler/templates/compileSkeletonSlide.js +80 -0
  25. package/src/compiler/templates/compileTable.js +70 -0
  26. package/src/compiler/templates/compileTextGrid.js +57 -0
  27. package/src/compiler/templates/compileTitleAndPara.js +79 -0
  28. package/src/compiler/templates/compileTitleAndSubtitle.js +84 -0
  29. package/src/compiler/templates/compileTwoColumnText.js +116 -0
  30. package/src/compiler/templates/helpers/addIdToItems.js +17 -0
  31. package/src/compiler/templates/helpers/buildSequentialStates.js +24 -0
  32. package/src/compiler/templates/index.js +108 -0
  33. package/src/compiler/utils/applyBackground.js +9 -0
  34. package/src/compiler/utils/assignMockTimings.js +47 -0
  35. package/src/compiler/utils/compileTimings.js +16 -0
  36. package/src/compiler/utils/getDeckImages.js +40 -0
  37. package/src/compiler/utils/resolveAssetPaths.js +42 -0
  38. package/src/compiler/utils/resolveBackground.js +29 -0
  39. package/src/dsl/Taleem.js +400 -0
  40. package/src/dsl/TimelineContext.js +256 -0
  41. package/src/dsl/slides/BarChart.js +31 -0
  42. package/src/dsl/slides/BulletListBuilder.js +23 -0
  43. package/src/dsl/slides/Eq.js +65 -0
  44. package/src/dsl/slides/FillImage.js +25 -0
  45. package/src/dsl/slides/FocusListBuilder.js +37 -0
  46. package/src/dsl/slides/ImageGrid.js +25 -0
  47. package/src/dsl/slides/ImageLeftBulletsRight.js +37 -0
  48. package/src/dsl/slides/ImageRightBulletsLeft.js +37 -0
  49. package/src/dsl/slides/ImageSlide.js +25 -0
  50. package/src/dsl/slides/ImageStrip.js +25 -0
  51. package/src/dsl/slides/ImageWithCaption.js +37 -0
  52. package/src/dsl/slides/ImageWithTitle.js +37 -0
  53. package/src/dsl/slides/KeyIdeasSlide.js +31 -0
  54. package/src/dsl/slides/Progressbar.js +31 -0
  55. package/src/dsl/slides/QuoteSlide.js +37 -0
  56. package/src/dsl/slides/SkeletonSlideBuilder.js +43 -0
  57. package/src/dsl/slides/Table.js +25 -0
  58. package/src/dsl/slides/TextGrid.js +25 -0
  59. package/src/dsl/slides/TitleAndPara.js +37 -0
  60. package/src/dsl/slides/TitleAndSubtitle.js +37 -0
  61. package/src/dsl/slides/TwoColumnText.js +61 -0
  62. package/src/index.js +4 -0
  63. package/src/primitives/index.js +0 -0
  64. package/src/types/index.js +0 -0
  65. package/src/utils/index.js +0 -0
@@ -0,0 +1,79 @@
1
+
2
+ // /src/compiler/templates/compileImageRightBulletsLeft.js
3
+
4
+ import { addIdToItems } from "./helpers/addIdToItems.js";
5
+
6
+ export function compileImageRightBulletsLeft(
7
+ slide
8
+ ) {
9
+ const rawItems =
10
+ slide.data ?? [];
11
+
12
+ const items =
13
+ addIdToItems(rawItems);
14
+
15
+ const imageItem =
16
+ items.find(
17
+ d => d.name === "image"
18
+ );
19
+
20
+ const bullets =
21
+ items.filter(
22
+ d => d.name === "bullet"
23
+ );
24
+
25
+ if (
26
+ !imageItem ||
27
+ !bullets.length
28
+ ) {
29
+ throw new Error(
30
+ "imageRightBulletsLeft: requires image and bullets"
31
+ );
32
+ }
33
+
34
+ const ids =
35
+ items.map(i => i.id);
36
+
37
+ const html = `
38
+ <section class="slide imageRightBulletsLeft">
39
+
40
+ <ul>
41
+
42
+ ${bullets.map(b => `
43
+ <li
44
+ id="${b.id}"
45
+
46
+ class="
47
+ hidden
48
+ ${b.classes || ""}
49
+ "
50
+ >
51
+ ${b.content}
52
+ </li>
53
+ `).join("")}
54
+
55
+ </ul>
56
+
57
+ <img
58
+ id="${imageItem.id}"
59
+
60
+ class="
61
+ hidden
62
+ ${imageItem.classes || ""}
63
+ "
64
+
65
+ src="${imageItem.content}"
66
+ />
67
+
68
+ </section>
69
+ `;
70
+
71
+ return {
72
+ html,
73
+
74
+ animation:
75
+ "progressiveReveal",
76
+
77
+ ids
78
+ };
79
+ }
@@ -0,0 +1,52 @@
1
+ // /src/compiler/templates/compileImageSlide.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileImageSlide(slide) {
6
+ const rawItems = slide.data ?? [];
7
+
8
+ const items =
9
+ addIdToItems(rawItems);
10
+
11
+ const imageItem =
12
+ items.find(
13
+ d => d.name === "image"
14
+ );
15
+
16
+ if (!imageItem) {
17
+ throw new Error(
18
+ "imageSlide: requires image"
19
+ );
20
+ }
21
+
22
+ const ids =
23
+ items.map(i => i.id);
24
+
25
+ const html = `
26
+ <section class="slide imageSlide">
27
+
28
+ <img
29
+ id="${imageItem.id}"
30
+
31
+ class="
32
+ hidden
33
+ ${imageItem.classes || ""}
34
+ "
35
+
36
+ src="${imageItem.content}"
37
+
38
+ alt=""
39
+ />
40
+
41
+ </section>
42
+ `;
43
+
44
+ return {
45
+ html,
46
+
47
+ animation:
48
+ "progressiveReveal",
49
+
50
+ ids
51
+ };
52
+ }
@@ -0,0 +1,60 @@
1
+ // /src/compiler/templates/compileImageStrip.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileImageStrip(slide) {
6
+ const rawItems = slide.data ?? [];
7
+
8
+ const items =
9
+ addIdToItems(rawItems);
10
+
11
+ const images =
12
+ items.filter(
13
+ d => d.name === "image"
14
+ );
15
+
16
+ if (!images.length) {
17
+ throw new Error(
18
+ "imageStrip: requires images"
19
+ );
20
+ }
21
+
22
+ const ids =
23
+ items.map(i => i.id);
24
+
25
+ const html = `
26
+ <section class="slide imageStrip">
27
+
28
+ <div class="image-strip">
29
+
30
+ ${images.map(img => `
31
+ <div class="image-strip-item">
32
+
33
+ <img
34
+ id="${img.id}"
35
+
36
+ class="
37
+ hidden
38
+ ${img.classes || ""}
39
+ "
40
+
41
+ src="${img.content}"
42
+ />
43
+
44
+ </div>
45
+ `).join("")}
46
+
47
+ </div>
48
+
49
+ </section>
50
+ `;
51
+
52
+ return {
53
+ html,
54
+
55
+ animation:
56
+ "progressiveReveal",
57
+
58
+ ids
59
+ };
60
+ }
@@ -0,0 +1,75 @@
1
+ // /src/compiler/templates/compileImageWithCaption.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileImageWithCaption(
6
+ slide
7
+ ) {
8
+ const rawItems =
9
+ slide.data ?? [];
10
+
11
+ const items =
12
+ addIdToItems(rawItems);
13
+
14
+ const imageItem =
15
+ items.find(
16
+ d => d.name === "image"
17
+ );
18
+
19
+ const captionItem =
20
+ items.find(
21
+ d => d.name === "caption"
22
+ );
23
+
24
+ if (!imageItem) {
25
+ throw new Error(
26
+ "imageWithCaption: requires image"
27
+ );
28
+ }
29
+
30
+ const ids =
31
+ items.map(i => i.id);
32
+
33
+ const html = `
34
+ <figure class="slide imageWithCaption">
35
+
36
+ <img
37
+ id="${imageItem.id}"
38
+
39
+ class="
40
+ hidden
41
+ ${imageItem.classes || ""}
42
+ "
43
+
44
+ src="${imageItem.content}"
45
+ />
46
+
47
+ ${
48
+ captionItem
49
+ ? `
50
+ <figcaption
51
+ id="${captionItem.id}"
52
+
53
+ class="
54
+ hidden
55
+ ${captionItem.classes || ""}
56
+ "
57
+ >
58
+ ${captionItem.content}
59
+ </figcaption>
60
+ `
61
+ : ""
62
+ }
63
+
64
+ </figure>
65
+ `;
66
+
67
+ return {
68
+ html,
69
+
70
+ animation:
71
+ "progressiveReveal",
72
+
73
+ ids
74
+ };
75
+ }
@@ -0,0 +1,75 @@
1
+ // /src/compiler/templates/compileImageWithTitle.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileImageWithTitle(
6
+ slide
7
+ ) {
8
+ const rawItems =
9
+ slide.data ?? [];
10
+
11
+ const items =
12
+ addIdToItems(rawItems);
13
+
14
+ const titleItem =
15
+ items.find(
16
+ d => d.name === "title"
17
+ );
18
+
19
+ const imageItem =
20
+ items.find(
21
+ d => d.name === "image"
22
+ );
23
+
24
+ if (!imageItem) {
25
+ throw new Error(
26
+ "imageWithTitle: requires image"
27
+ );
28
+ }
29
+
30
+ const ids =
31
+ items.map(i => i.id);
32
+
33
+ const html = `
34
+ <section class="slide imageWithTitle">
35
+
36
+ ${
37
+ titleItem
38
+ ? `
39
+ <h1
40
+ id="${titleItem.id}"
41
+
42
+ class="
43
+ hidden
44
+ ${titleItem.classes || ""}
45
+ "
46
+ >
47
+ ${titleItem.content}
48
+ </h1>
49
+ `
50
+ : ""
51
+ }
52
+
53
+ <img
54
+ id="${imageItem.id}"
55
+
56
+ class="
57
+ hidden
58
+ ${imageItem.classes || ""}
59
+ "
60
+
61
+ src="${imageItem.content}"
62
+ />
63
+
64
+ </section>
65
+ `;
66
+
67
+ return {
68
+ html,
69
+
70
+ animation:
71
+ "progressiveReveal",
72
+
73
+ ids
74
+ };
75
+ }
@@ -0,0 +1,62 @@
1
+ // /src/compiler/templates/compileKeyIdeasSlide.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileKeyIdeasSlide(
6
+ slide
7
+ ) {
8
+ const rawItems =
9
+ slide.data ?? [];
10
+
11
+ const items =
12
+ addIdToItems(rawItems);
13
+
14
+ const cards =
15
+ items.filter(
16
+ d => d.name === "card"
17
+ );
18
+
19
+ if (!cards.length) {
20
+ throw new Error(
21
+ "keyIdeasSlide: requires cards"
22
+ );
23
+ }
24
+
25
+ const ids =
26
+ items.map(i => i.id);
27
+
28
+ const html = `
29
+ <section class="slide keyIdeasSlide">
30
+
31
+ ${cards.map(card => `
32
+ <div
33
+ id="${card.id}"
34
+
35
+ class="
36
+ key-idea
37
+ hidden
38
+ ${card.classes || ""}
39
+ "
40
+ >
41
+ <div class="icon">
42
+ ${card.icon ?? ""}
43
+ </div>
44
+
45
+ <div class="label">
46
+ ${card.label}
47
+ </div>
48
+ </div>
49
+ `).join("")}
50
+
51
+ </section>
52
+ `;
53
+
54
+ return {
55
+ html,
56
+
57
+ animation:
58
+ "progressiveReveal",
59
+
60
+ ids
61
+ };
62
+ }
@@ -0,0 +1,74 @@
1
+ // /src/compiler/templates/compileProgressbar.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileProgressbar(slide) {
6
+ const rawItems = slide.data ?? [];
7
+
8
+ const items =
9
+ addIdToItems(rawItems);
10
+
11
+ const bars =
12
+ items.filter(
13
+ d => d.name === "bar"
14
+ );
15
+
16
+ const ids =
17
+ items.map(i => i.id);
18
+
19
+ const html = `
20
+ <section class="slide progressbar">
21
+
22
+ ${bars.map(bar => {
23
+ const value =
24
+ Math.max(
25
+ 0,
26
+
27
+ Math.min(
28
+ 100,
29
+
30
+ Number(
31
+ bar.value ?? 0
32
+ )
33
+ )
34
+ );
35
+
36
+ return `
37
+ <div
38
+ id="${bar.id}"
39
+
40
+ class="
41
+ progressbar-item
42
+ hidden
43
+ ${bar.classes || ""}
44
+ "
45
+ >
46
+
47
+ <div class="progressbar-label">
48
+ ${bar.label}
49
+ </div>
50
+
51
+ <div class="progressbar-track">
52
+ <div
53
+ class="progressbar-fill"
54
+
55
+ style="width:${value}%"
56
+ ></div>
57
+ </div>
58
+
59
+ </div>
60
+ `;
61
+ }).join("")}
62
+
63
+ </section>
64
+ `;
65
+
66
+ return {
67
+ html,
68
+
69
+ animation:
70
+ "progressiveReveal",
71
+
72
+ ids
73
+ };
74
+ }
@@ -0,0 +1,72 @@
1
+ // /src/compiler/templates/compileQuoteSlide.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileQuoteSlide(slide) {
6
+ const rawItems = slide.data ?? [];
7
+
8
+ const items =
9
+ addIdToItems(rawItems);
10
+
11
+ const quoteItem =
12
+ items.find(
13
+ d => d.name === "quote"
14
+ );
15
+
16
+ const authorItem =
17
+ items.find(
18
+ d => d.name === "author"
19
+ );
20
+
21
+ if (!quoteItem) {
22
+ throw new Error(
23
+ "quoteSlide: requires quote"
24
+ );
25
+ }
26
+
27
+ const ids =
28
+ items.map(i => i.id);
29
+
30
+ const html = `
31
+ <blockquote class="slide quoteSlide">
32
+
33
+ <p
34
+ id="${quoteItem.id}"
35
+
36
+ class="
37
+ hidden
38
+ ${quoteItem.classes || ""}
39
+ "
40
+ >
41
+ ${quoteItem.content}
42
+ </p>
43
+
44
+ ${
45
+ authorItem
46
+ ? `
47
+ <footer
48
+ id="${authorItem.id}"
49
+
50
+ class="
51
+ hidden
52
+ ${authorItem.classes || ""}
53
+ "
54
+ >
55
+ ${authorItem.content}
56
+ </footer>
57
+ `
58
+ : ""
59
+ }
60
+
61
+ </blockquote>
62
+ `;
63
+
64
+ return {
65
+ html,
66
+
67
+ animation:
68
+ "progressiveReveal",
69
+
70
+ ids
71
+ };
72
+ }
@@ -0,0 +1,80 @@
1
+ // /src/compiler/templates/compileSkeletonSlide.js
2
+
3
+ import { addIdToItems } from "./helpers/addIdToItems.js";
4
+
5
+ export function compileSkeletonSlide(slide) {
6
+ const rawItems = slide.data ?? [];
7
+
8
+ if (!rawItems.length) {
9
+ throw new Error(
10
+ "skeletonSlide: requires items"
11
+ );
12
+ }
13
+
14
+ const items = addIdToItems(rawItems);
15
+
16
+ const ids = items.map(i => i.id);
17
+
18
+ function renderItem(item) {
19
+ const id = item.id;
20
+
21
+ const classes =
22
+ item.classes ?? "";
23
+
24
+ // --- title ---
25
+ if (item.name === "title") {
26
+ return `
27
+ <h1
28
+ id="${id}"
29
+ class="hidden ${classes}"
30
+ >
31
+ ${item.content}
32
+ </h1>
33
+ `;
34
+ }
35
+
36
+ // --- para ---
37
+ if (item.name === "para") {
38
+ return `
39
+ <p
40
+ id="${id}"
41
+ class="hidden ${classes}"
42
+ >
43
+ ${item.content}
44
+ </p>
45
+ `;
46
+ }
47
+
48
+ // --- image ---
49
+ if (item.name === "image") {
50
+ return `
51
+ <div
52
+ id="${id}"
53
+ class="skeleton-image hidden ${classes}"
54
+ >
55
+ <img src="${item.content}" />
56
+ </div>
57
+ `;
58
+ }
59
+
60
+ return "";
61
+ }
62
+
63
+ const html = `
64
+ <section class="slide skeleton">
65
+
66
+ <div class="skeleton-body">
67
+ ${items.map(renderItem).join("")}
68
+ </div>
69
+
70
+ </section>
71
+ `;
72
+
73
+ return {
74
+ html,
75
+
76
+ animation: "oneAtATime",
77
+
78
+ ids
79
+ };
80
+ }
@@ -0,0 +1,70 @@
1
+
2
+ // /src/compiler/templates/compileTable.js
3
+
4
+ import { addIdToItems } from "./helpers/addIdToItems.js";
5
+
6
+ export function compileTable(slide) {
7
+ const rawItems = slide.data ?? [];
8
+
9
+ if (!rawItems.length) {
10
+ throw new Error(
11
+ "table: requires rows"
12
+ );
13
+ }
14
+
15
+ const items =
16
+ addIdToItems(rawItems);
17
+
18
+ const rows =
19
+ items.filter(
20
+ d => d.name === "row"
21
+ );
22
+
23
+ const ids =
24
+ items.map(i => i.id);
25
+
26
+ const html = `
27
+ <section class="slide table">
28
+
29
+ <table>
30
+ <tbody>
31
+
32
+ ${rows.map(row => {
33
+ const cells =
34
+ row.content
35
+ .split(",")
36
+ .map(s => s.trim());
37
+
38
+ return `
39
+ <tr
40
+ id="${row.id}"
41
+
42
+ class="hidden ${
43
+ row.classes || ""
44
+ }"
45
+ >
46
+ ${cells
47
+ .map(
48
+ cell =>
49
+ `<td>${cell}</td>`
50
+ )
51
+ .join("")}
52
+ </tr>
53
+ `;
54
+ }).join("")}
55
+
56
+ </tbody>
57
+ </table>
58
+
59
+ </section>
60
+ `;
61
+
62
+ return {
63
+ html,
64
+
65
+ animation:
66
+ "progressiveReveal",
67
+
68
+ ids
69
+ };
70
+ }