@sparkle-learning/core 0.0.23 → 0.0.26

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 (42) hide show
  1. package/dist/cjs/header-mobile-collapse_60.cjs.entry.js +1 -1
  2. package/dist/cjs/{index.es-c12b0714.js → index.es-91493ac6.js} +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/{purify-e34cd5cf.js → purify-ed567052.js} +1 -1
  5. package/dist/cjs/sparkle-animation-player.cjs.entry.js +5 -2
  6. package/dist/cjs/sparkle-core.cjs.js +1 -1
  7. package/dist/cjs/sparkle-youtube.cjs.entry.js +14 -168
  8. package/dist/collection/assets/img/forward.svg +5 -0
  9. package/dist/collection/assets/img/pause.svg +5 -0
  10. package/dist/collection/assets/img/play-symbol.svg +8 -0
  11. package/dist/collection/assets/img/play.svg +4 -0
  12. package/dist/collection/assets/img/rewind.svg +5 -0
  13. package/dist/collection/components/sparkle-animation-player/assets/play-button-disabled-overlay.png +0 -0
  14. package/dist/collection/components/sparkle-animation-player/assets/play-button-overlay.png +0 -0
  15. package/dist/collection/components/sparkle-animation-player/sparkle-animation-player.js +10 -7
  16. package/dist/collection/components/sparkle-course-root/sparkle-course-root.js +14 -0
  17. package/dist/collection/components/sparkle-youtube/sparkle-youtube.css +16 -0
  18. package/dist/collection/components/sparkle-youtube/sparkle-youtube.js +25 -307
  19. package/dist/collection/pages/course/welcome-to-mind-body/introduction/animation/m4l1p1_part1.js +2727 -0
  20. package/dist/collection/pages/course/welcome-to-mind-body/introduction/animation/m4l1p1_part2.js +2042 -0
  21. package/dist/esm/header-mobile-collapse_60.entry.js +1 -1
  22. package/dist/esm/{index.es-34d81aa0.js → index.es-32e2f407.js} +1 -1
  23. package/dist/esm/loader.js +1 -1
  24. package/dist/esm/{purify-76414f98.js → purify-f1a55787.js} +1 -1
  25. package/dist/esm/sparkle-animation-player.entry.js +6 -3
  26. package/dist/esm/sparkle-core.js +1 -1
  27. package/dist/esm/sparkle-youtube.entry.js +15 -169
  28. package/dist/sparkle-core/assets/play-button-disabled-overlay.png +0 -0
  29. package/dist/sparkle-core/assets/play-button-overlay.png +0 -0
  30. package/dist/sparkle-core/{p-315af535.js → p-0d3fe46c.js} +1 -1
  31. package/dist/sparkle-core/{p-fc739e6b.js → p-14ff8097.js} +4 -4
  32. package/dist/sparkle-core/p-1e1f5e98.entry.js +1 -0
  33. package/dist/sparkle-core/p-82d95fcd.entry.js +1 -0
  34. package/dist/sparkle-core/{p-ba79a250.js → p-ab5cdfeb.js} +1 -1
  35. package/dist/sparkle-core/{p-1af89970.entry.js → p-f6ce91f2.entry.js} +1 -1
  36. package/dist/sparkle-core/sparkle-core.esm.js +1 -1
  37. package/dist/types/components/sparkle-course-root/sparkle-course-root.d.ts +1 -0
  38. package/dist/types/components/sparkle-youtube/sparkle-youtube.d.ts +6 -20
  39. package/dist/types/components.d.ts +3 -14
  40. package/package.json +2 -2
  41. package/dist/sparkle-core/p-0bd3e81f.entry.js +0 -1
  42. package/dist/sparkle-core/p-d069b834.entry.js +0 -1
@@ -4,188 +4,34 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-fbf4d3bf.js');
6
6
 
7
- const sparkleYoutubeCss = ":host(.loaded) div.youtube-container{opacity:var(--sparkle-youtube-opacity-loaded, 1)}div.youtube-container{opacity:var(--sparkle-youtube-opacity-not-loaded, 0);transition:var(--sparkle-youtube-transition, opacity 0.15s linear)}";
7
+ const sparkleYoutubeCss = ":host(.loaded) div.youtube-container{opacity:var(--sparkle-youtube-opacity-loaded, 1)}div.youtube-container{opacity:var(--sparkle-youtube-opacity-not-loaded, 0);transition:var(--sparkle-youtube-transition, opacity 0.15s linear)}.embed-container{position:relative;padding-bottom:56.25%;height:0;overflow:hidden;max-width:100%}.embed-container iframe,.embed-container object,.embed-container embed{position:absolute;top:0;left:0;width:100%;height:100%}";
8
8
 
9
9
  const SparkleYoutube = class {
10
10
  constructor(hostRef) {
11
11
  index.registerInstance(this, hostRef);
12
- this.allowFullscreen = true;
13
- this.instant = false;
14
- this.loading = false;
15
- this.loaded = false;
12
+ this.video_thumbnail = '';
16
13
  }
17
- async componentWillLoad() {
18
- await this.addPreconnectLink();
14
+ componentDidLoad() {
15
+ this.classMode = this.initialClassMode;
16
+ this.classModeChanged();
19
17
  }
20
- async componentDidLoad() {
21
- if (this.instant) {
22
- await this.lazyLoadContent();
23
- }
24
- }
25
- async updateIFrame(width, height) {
26
- const iframe = this.el.shadowRoot.querySelector('iframe');
27
- if (iframe) {
28
- iframe.width = '' + width;
29
- iframe.height = '' + height;
30
- }
31
- }
32
- lazyLoadContent() {
33
- return this.createIFrame();
34
- }
35
- async onSrcUpdate() {
36
- await this.createIFrame();
37
- }
38
- play() {
39
- return this.playPauseVideo(true);
40
- }
41
- pause() {
42
- return this.playPauseVideo(false);
43
- }
44
- addPreconnectLink() {
45
- return new Promise((resolve) => {
46
- if (!this.src || !document) {
47
- resolve();
48
- return;
49
- }
50
- const links = document.head.querySelectorAll("link[rel='preconnect'][youtube]");
51
- if (links && links.length > 0) {
52
- resolve();
53
- return;
54
- }
55
- const link = document.createElement('link');
56
- link.rel = 'preconnect';
57
- link.href = 'https://www.youtube.com';
58
- link.setAttribute('youtube', '');
59
- document.head.appendChild(link);
60
- resolve();
61
- });
62
- }
63
- createIFrame() {
64
- return new Promise(async (resolve) => {
65
- if (!this.src) {
66
- resolve();
67
- return;
68
- }
69
- if (this.loading) {
70
- resolve();
71
- return;
18
+ classModeChanged() {
19
+ if (this.classMode) {
20
+ var youtube_video_id = this.src.match(/youtube\.com.*(\?v=|\/embed\/)(.{11})/).pop();
21
+ if (youtube_video_id.length == 11) {
22
+ this.video_thumbnail = '//img.youtube.com/vi/' + youtube_video_id + '/0.jpg';
72
23
  }
73
- const iframe = this.el.shadowRoot.querySelector('iframe');
74
- if (iframe && !iframe.parentElement) {
75
- resolve();
76
- return;
77
- }
78
- this.loading = true;
79
- this.loaded = false;
80
- if (iframe) {
81
- iframe.parentElement.removeChild(iframe);
82
- }
83
- const element = document.createElement('iframe');
84
- const allow = document.createAttribute('allow');
85
- allow.value = 'accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture';
86
- this.setAttributeNode(element, allow);
87
- if (this.allowFullscreen) {
88
- const allowFullScreen = document.createAttribute('allowfullscreen');
89
- allowFullScreen.value = '';
90
- this.setAttributeNode(element, allowFullScreen);
91
- }
92
- let src = await this.formatSrc();
93
- if (!this.allowFullscreen) {
94
- // Not auto fullscreen on iOS: https://developers.google.com/youtube/player_parameters
95
- const playsinline = document.createAttribute('playsinline');
96
- playsinline.value = '1';
97
- this.setAttributeNode(element, playsinline);
98
- const split = src.split('?');
99
- src += `${split && split.length > 0 ? '&' : '?'}playsinline=1`;
100
- }
101
- element.src = src;
102
- element.width = '' + this.width;
103
- element.height = '' + this.height;
104
- element.frameBorder = '0';
105
- element.title = this.frameTitle;
106
- const div = this.el.shadowRoot.querySelector('div');
107
- if (!div) {
108
- resolve();
109
- return;
110
- }
111
- div.appendChild(element);
112
- this.loading = false;
113
- this.loaded = true;
114
- resolve();
115
- });
116
- }
117
- setAttributeNode(element, attr) {
118
- // Stencil prerendering
119
- if (element.setAttributeNode === 'function') {
120
- element.setAttributeNode(attr);
121
24
  }
122
25
  }
123
- formatSrc() {
124
- return new Promise(async (resolve) => {
125
- // Direct URL can't be embedded, like https://www.youtube.com/watch?v=oUOjJIfPIjw or https://youtu.be/e63Cgln6Yag
126
- const videoId = await this.findVideoId();
127
- if (videoId) {
128
- // In such a case return a link which could be embedded
129
- resolve('https://www.youtube.com/embed/' + videoId + '?enablejsapi=1');
130
- }
131
- else {
132
- // Otherwise we try the provided url
133
- if (!this.src) {
134
- resolve(this.src);
135
- return;
136
- }
137
- // But first, if an embed link, like https://www.youtube.com/embed/PnSNT5WpauE, would be passed, a parameter to enable js should be added otherwise play and pause could not be triggered
138
- // Therefore we add enablejsapi if needed in any case
139
- const url = new URL(this.src);
140
- if (!url.searchParams.get('enablejsapi')) {
141
- url.searchParams.append('enablejsapi', '1');
142
- }
143
- resolve(url.href);
144
- }
145
- });
146
- }
147
- findVideoId() {
148
- return new Promise((resolve) => {
149
- const url = new URL(this.src);
150
- let videoId = url.searchParams.get('v');
151
- if (!videoId) {
152
- const host = url.host;
153
- if (host === 'youtu.be') {
154
- // For shortened url
155
- const pathname = url.pathname;
156
- if (pathname) {
157
- const split = url.pathname.split('/');
158
- if (split && split.length >= 2) {
159
- videoId = url.pathname.split('/')[1];
160
- }
161
- }
162
- }
163
- }
164
- resolve(videoId);
165
- });
166
- }
167
- playPauseVideo(play) {
168
- return new Promise(async (resolve) => {
169
- const iframe = this.el.shadowRoot.querySelector('iframe');
170
- if (!iframe) {
171
- resolve();
172
- return;
173
- }
174
- iframe.contentWindow.postMessage(JSON.stringify({
175
- event: 'command',
176
- func: play ? 'playVideo' : 'pauseVideo',
177
- args: '',
178
- }), '*');
179
- resolve();
180
- });
26
+ classRoomModeChanged(val) {
27
+ this.classMode = val;
181
28
  }
182
29
  render() {
183
- const hostClass = this.loaded ? 'loaded' : '';
184
- return (index.h(index.Host, { class: hostClass }, index.h("div", { class: "youtube-container" })));
30
+ return (index.h("div", null, !this.classMode ? (index.h("div", { class: "embed-container" }, index.h("iframe", { src: this.src.replace("watch?v=", "embed/"), frameborder: "0", allowFullScreen: true }))) : (index.h("div", null, index.h("img", { src: this.video_thumbnail })))));
185
31
  }
186
32
  get el() { return index.getElement(this); }
187
33
  static get watchers() { return {
188
- "src": ["onSrcUpdate"]
34
+ "classMode": ["classModeChanged"]
189
35
  }; }
190
36
  };
191
37
  SparkleYoutube.style = sparkleYoutubeCss;
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="512px" height="512px" viewBox="0 0 220.682 220.682" style="enable-background:new 0 0 220.682 220.682;" xml:space="preserve"><g><g>
3
+ <polygon points="92.695,38.924 164.113,110.341 92.695,181.758 120.979,210.043 220.682,110.341 120.979,10.639 " data-original="#E5053A" fill="#E5053A"/>
4
+ <polygon points="28.284,210.043 127.986,110.341 28.284,10.639 0,38.924 71.417,110.341 0,181.758 " data-original="#E5053A" fill="#E5053A"/>
5
+ </g></g> </svg>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" viewBox="0 0 365 365" style="enable-background:new 0 0 365 365;" xml:space="preserve" width="512px" height="512px" class=""><g><g>
3
+ <rect x="74.5" width="73" height="365" data-original="#E5053A" class="active-path" fill="#E5053A"/>
4
+ <rect x="217.5" width="73" height="365" data-original="#E5053A" class="active-path" fill="#E5053A"/>
5
+ </g></g> </svg>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="512px" height="512px" viewBox="0 0 307.046 307.046" style="enable-background:new 0 0 307.046 307.046;" xml:space="preserve"><g><g>
3
+ <g id="_x34_84._Forward">
4
+ <g>
5
+ <path d="M239.087,142.427L101.259,4.597c-6.133-6.129-16.073-6.129-22.203,0L67.955,15.698c-6.129,6.133-6.129,16.076,0,22.201 l115.621,115.626L67.955,269.135c-6.129,6.136-6.129,16.086,0,22.209l11.101,11.101c6.13,6.136,16.07,6.136,22.203,0 l137.828-137.831C245.222,158.487,245.222,148.556,239.087,142.427z" data-original="#E5053A" fill="#E5053A"/>
6
+ </g>
7
+ </g>
8
+ </g></g> </svg>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="512px" height="512px" viewBox="0 0 314.41 314.41" style="enable-background:new 0 0 314.41 314.41;" xml:space="preserve"><g><g>
3
+ <path d="M288.318,145.307L39.832,1.841c-4.253-2.454-9.486-2.454-13.74,0c-4.249,2.452-6.871,6.991-6.871,11.898v286.93 c0,4.908,2.622,9.447,6.871,11.898c2.128,1.229,4.5,1.843,6.87,1.843c2.372,0,4.743-0.614,6.87-1.843l248.487-143.464 c4.25-2.452,6.871-6.991,6.871-11.898C295.189,152.297,292.568,147.759,288.318,145.307z M46.702,276.868V37.541l207.265,119.664 L46.702,276.868z" data-original="#E5053A" class="active-path" fill="#E5053A"/>
4
+ </g></g> </svg>
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" width="512px" height="512px" viewBox="0 0 220.682 220.682" style="enable-background:new 0 0 220.682 220.682;" xml:space="preserve"><g><g>
3
+ <polygon points="99.702,210.043 127.986,181.758 56.569,110.341 127.986,38.924 99.702,10.639 0,110.341 " data-original="#E5053A" class="active-path" fill="#E5053A"/>
4
+ <polygon points="192.398,10.639 92.695,110.341 192.398,210.043 220.682,181.758 149.264,110.341 220.682,38.924 " data-original="#E5053A" class="active-path" fill="#E5053A"/>
5
+ </g></g> </svg>
@@ -1,4 +1,4 @@
1
- import { Component, State, Prop, Method, Element, Listen, h } from "@stencil/core";
1
+ import { Component, State, Prop, Method, Element, getAssetPath, Listen, h } from "@stencil/core";
2
2
  import { CaptionParser } from "./caption-parser";
3
3
  export class SparkleAnimationPlayer {
4
4
  constructor() {
@@ -390,8 +390,8 @@ export class SparkleAnimationPlayer {
390
390
  this.showCaption ?
391
391
  h("div", { class: "caption" }, this.captionText) : "")) : (""),
392
392
  !this.dataLoaded ? (h("img", { class: "frame-img", src: this.firstFramePath })) : (""),
393
- this.classMode ? (h("img", { class: "overlay-img", src: "/assets/img/play-button-disabled-overlay.png" })) : (""),
394
- !this.classMode && this.paused ? (h("img", { class: "overlay-img", onClick: () => this.playButtonAction(), src: "/assets/img/play-button-overlay.png" })) : (""),
393
+ this.classMode ? (h("img", { class: "overlay-img", src: getAssetPath(`./assets/play-button-disabled-overlay.png`) })) : (""),
394
+ !this.classMode && this.paused ? (h("img", { class: "overlay-img", onClick: () => this.playButtonAction(), src: getAssetPath(`./assets/play-button-overlay.png`) })) : (""),
395
395
  this.isBusy ? (h("div", { class: "loading-container" },
396
396
  h("div", { class: "uil-ring-css" },
397
397
  h("div", null),
@@ -405,17 +405,19 @@ export class SparkleAnimationPlayer {
405
405
  h("div", { class: "button-panel" },
406
406
  h("ion-button", { size: "small", color: "transperant", onClick: () => this.rewind5Sec() },
407
407
  " ",
408
- h("ion-icon", { src: "/assets/img/rewind.svg" }),
408
+ h("ion-icon", { name: "play-back-outline" }),
409
409
  " "),
410
410
  h("ion-button", { size: "small", color: "transperant", onClick: () => this.playButtonAction() },
411
411
  " ",
412
- this.paused ? (h("ion-icon", { name: "pause" })) : (h("ion-icon", { src: "/assets/img/play-symbol.svg" }))),
412
+ this.paused ? (h("ion-icon", { name: "pause-outline" })) : (h("ion-icon", { name: "play-outline" })
413
+ // <ion-icon src="/assets/img/play-symbol.svg"></ion-icon>
414
+ )),
413
415
  h("ion-button", { size: "small", color: "transperant", onClick: () => this.fastForward5Sec() },
414
416
  " ",
415
- h("ion-icon", { src: "/assets/img/forward.svg" }))))) : (""),
417
+ h("ion-icon", { name: "play-forward-outline" }))))) : (""),
416
418
  (this.dataLoaded && this.captionText) ?
417
419
  h("div", { class: "closed-caption" },
418
- h("ion-item", null,
420
+ h("ion-item", { lines: "none" },
419
421
  h("ion-label", null, "Closed Caption"),
420
422
  h("ion-toggle", { slot: "end", color: "primary", checked: this.showCaption }))) : ""));
421
423
  }
@@ -426,6 +428,7 @@ export class SparkleAnimationPlayer {
426
428
  static get styleUrls() { return {
427
429
  "$": ["sparkle-animation-player.css"]
428
430
  }; }
431
+ static get assetsDirs() { return ["assets"]; }
429
432
  static get properties() { return {
430
433
  "src": {
431
434
  "type": "string",
@@ -100,6 +100,18 @@ export class SparkleCourseRoot {
100
100
  return (h("a", { slot: "logo", href: "https://girlsinclearning.com/", target: "_blank" },
101
101
  h("img", { class: "girls-inc-logo", src: "/assets/img/logo-primary.png" })));
102
102
  }
103
+ getFirstLessonUrl() {
104
+ if (this.tocData) {
105
+ let firstModule = this.tocData.courseModules[0];
106
+ let firstSession = firstModule.sessions[0];
107
+ let firstPage = firstSession.pages[0];
108
+ let url = '/course/' + firstModule.urlName + '/' + firstSession.urlName + '/' + firstPage.urlName;
109
+ return url;
110
+ }
111
+ else {
112
+ return '/home';
113
+ }
114
+ }
103
115
  render() {
104
116
  const layout = {
105
117
  'Layout': true,
@@ -109,6 +121,8 @@ export class SparkleCourseRoot {
109
121
  h("stencil-router", { class: layout },
110
122
  h("stencil-route", { style: { display: 'none' }, routeRender: this.setHistory }),
111
123
  h("stencil-route-switch", { scrollTopOffset: 0 },
124
+ h("stencil-route", { url: "/", exact: true },
125
+ h("stencil-router-redirect", { url: this.getFirstLessonUrl() })),
112
126
  h("stencil-route", { url: "/unauthorized", routeRender: props => [
113
127
  this.renderHeaderAndMenu(),
114
128
  h("sparkle-unauthorized", null)
@@ -5,4 +5,20 @@
5
5
  div.youtube-container {
6
6
  opacity: var(--sparkle-youtube-opacity-not-loaded, 0);
7
7
  transition: var(--sparkle-youtube-transition, opacity 0.15s linear);
8
+ }
9
+
10
+ .embed-container {
11
+ position: relative;
12
+ padding-bottom: 56.25%;
13
+ height: 0;
14
+ overflow: hidden;
15
+ max-width: 100%;
16
+ }
17
+
18
+ .embed-container iframe, .embed-container object, .embed-container embed {
19
+ position: absolute;
20
+ top: 0;
21
+ left: 0;
22
+ width: 100%;
23
+ height: 100%;
8
24
  }