@eliceio/cdk-cli 1.8.1-qa.0 → 1.9.0-youtubeqa.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 (45) hide show
  1. package/README.md +21 -20
  2. package/assets/link-bridge.js +1 -0
  3. package/es/commands/create/scaffold.d.ts +1 -1
  4. package/es/commands/create/scaffold.js +1 -1
  5. package/es/dev/host-page.js +11 -0
  6. package/es/dev/link-bridge.d.ts +27 -0
  7. package/es/dev/link-bridge.js +142 -0
  8. package/es/dev/server.js +3 -0
  9. package/es/rules/check.js +3 -3
  10. package/es/rules/csp.d.ts +2 -2
  11. package/es/rules/csp.js +30 -5
  12. package/es/rules.json.js +1 -1
  13. package/package.json +3 -2
  14. package/rules.json +5 -5
  15. package/skills/_shared/references/02-design-the-material.md +1 -1
  16. package/skills/_shared/references/03-create-the-project.md +1 -0
  17. package/skills/_shared/references/04-rules.md +2 -2
  18. package/skills/_shared/references/08-fix-check-errors.md +1 -1
  19. package/skills/_shared/references/12-upload-with-the-material-mcp.md +1 -1
  20. package/skills/_shared/references/18-using-the-lesson-template.md +1 -1
  21. package/skills/elice-content-create/SKILL.md +1 -1
  22. package/templates/entry/screens/edit.js +3 -8
  23. package/templates/entry/template.json +1 -1
  24. package/templates/youtube/README.md +66 -0
  25. package/templates/youtube/commentary.txt +2 -0
  26. package/templates/youtube/core/dom.d.ts +13 -0
  27. package/templates/youtube/core/dom.js +83 -0
  28. package/templates/youtube/core/settings.d.ts +21 -0
  29. package/templates/youtube/core/settings.js +71 -0
  30. package/templates/youtube/core/youtube.d.ts +9 -0
  31. package/templates/youtube/core/youtube.js +111 -0
  32. package/templates/youtube/edit.html +17 -0
  33. package/templates/youtube/gitignore +4 -0
  34. package/templates/youtube/index.html +17 -0
  35. package/templates/youtube/metadata.json +9 -0
  36. package/templates/youtube/package.json +13 -0
  37. package/templates/youtube/screens/edit.js +69 -0
  38. package/templates/youtube/screens/learn.js +18 -0
  39. package/templates/youtube/styles.css +101 -0
  40. package/templates/youtube/template.json +14 -0
  41. package/templates/youtube/ui/templates/edit.js +60 -0
  42. package/templates/youtube/ui/templates/player.js +61 -0
  43. package/templates/youtube/ui/texts.d.ts +3 -0
  44. package/templates/youtube/ui/texts.js +50 -0
  45. package/templates/youtube/ui/theme.css +14 -0
@@ -0,0 +1,17 @@
1
+ <!doctype html>
2
+ <html lang="ko">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
6
+ <!-- 제목 · "불러오는 중" 문구는 ui/texts.js(page)에서 고칩니다. 여기 글은 스크립트가 돌기 전에만 보입니다 -->
7
+ <title>학생 화면</title>
8
+ <link rel="stylesheet" href="lib/elice-tokens.css" />
9
+ <link rel="stylesheet" href="lib/elice-content.css" />
10
+ <link rel="stylesheet" href="ui/theme.css" />
11
+ <link rel="stylesheet" href="styles.css" />
12
+ <script type="module" src="screens/learn.js"></script>
13
+ </head>
14
+ <body>
15
+ <main id="app"><div class="ec-sk ec-sk-learn ec-sk-shimmer" role="status"><span class="ec-visually-hidden">불러오는 중…</span></div></main>
16
+ </body>
17
+ </html>
@@ -0,0 +1,9 @@
1
+ {
2
+ "kind": "material",
3
+ "screens": {
4
+ "learn": { "enabled": true, "entry": "index.html" },
5
+ "instructor": { "enabled": false },
6
+ "edit": { "enabled": true, "entry": "edit.html" }
7
+ },
8
+ "commentary": "commentary.txt"
9
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "private": true,
3
+ "type": "module",
4
+ "scripts": {
5
+ "dev": "ecdk dev",
6
+ "build": "ecdk build",
7
+ "validate": "ecdk validate"
8
+ },
9
+ "dependencies": {
10
+ "@eliceio/cdk": "workspace:^1.3.0"
11
+ },
12
+ "ecdk": {}
13
+ }
@@ -0,0 +1,69 @@
1
+ // 내용 편집 화면. YouTube 주소 한 칸과 미리보기 플레이어입니다.
2
+ // 주소를 고칠 때마다 읽어서(core/youtube.js) 맞으면 미리보기를 바꾸고, 틀리면 칸 아래에 오류를 보입니다.
3
+ // 저장 버튼('초안으로 저장') · 변경 표시는 키트(useSave)가 합니다. 모양은 ui/(templates · texts · theme.css).
4
+ import { start } from '../lib/elice-content.js';
5
+ import { part } from '../core/dom.js';
6
+ import { fromUrl, normalizeSettings, toSettings, validateUrl } from '../core/settings.js';
7
+ import * as ui from '../ui/templates/edit.js';
8
+ import { frame, loading } from '../ui/templates/player.js';
9
+ import { texts } from '../ui/texts.js';
10
+
11
+ const t = texts.edit;
12
+ const root = document.getElementById('app');
13
+ document.title = texts.page.edit;
14
+ root.replaceChildren(loading('edit'));
15
+ const app = await start({ screen: 'edit' });
16
+ const draft = normalizeSettings(app.content);
17
+
18
+ const field = ui.urlField(draft.youtube?.url || '');
19
+ const input = part(field, 'input');
20
+ const error = part(field, 'error');
21
+ const preview = ui.previewSection();
22
+ const startLine = part(preview, 'start');
23
+ const previewBody = part(preview, 'preview');
24
+ root.replaceChildren(field, preview);
25
+
26
+ /** 지금 미리보기에 띄운 영상 (같은 영상 · 시각이면 iframe을 다시 만들지 않는다). null: 아직 아무것도 안 그림 */
27
+ let shown = null;
28
+ /** 오류 줄: 저장을 누른 뒤이거나 칸을 떠난 뒤에만 (입력하는 도중에는 보이지 않게) */
29
+ let showErrors = false;
30
+
31
+ function paint() {
32
+ const value = fromUrl(input.value);
33
+ draft.youtube = value;
34
+ const message = validateUrl(input.value, t.validation);
35
+ const invalid = showErrors && message !== true;
36
+ input.setAttribute('aria-invalid', String(invalid));
37
+ error.hidden = !invalid;
38
+ error.textContent = invalid ? message : '';
39
+
40
+ startLine.hidden = !value?.start;
41
+ startLine.textContent = value?.start ? t.startsAt(value.start) : '';
42
+ const key = value ? `${value.videoId}:${value.start ?? 0}` : '';
43
+ if (key === shown) return;
44
+ shown = key;
45
+ previewBody.replaceChildren(value ? frame(value) : ui.previewEmpty());
46
+ }
47
+
48
+ input.addEventListener('input', () => {
49
+ // 고쳐서 맞는 주소가 되면 오류를 바로 지운다
50
+ if (fromUrl(input.value)) showErrors = false;
51
+ paint();
52
+ });
53
+ input.addEventListener('blur', () => {
54
+ showErrors = input.value.trim() !== '';
55
+ paint();
56
+ });
57
+
58
+ app.useSave({
59
+ label: t.save,
60
+ getContent: () => toSettings(draft),
61
+ validate: () => {
62
+ showErrors = true;
63
+ paint();
64
+ const result = validateUrl(input.value, t.validation);
65
+ if (result !== true) input.focus();
66
+ return result;
67
+ },
68
+ });
69
+ paint();
@@ -0,0 +1,18 @@
1
+ // 학생 화면. 저장한 YouTube 영상을 16:9 플레이어로 보이고, 아래에 'YouTube에서 보기' 링크를 둡니다.
2
+ // 제출하지 않습니다: 완료 정책은 LXP 자료 편집 화면의 '설정'에서 '열람 시 완료'(on_access)로 둡니다 (기존 YouTube 자료와 같게).
3
+ // 시청 비율 · 재생 위치는 읽지 않습니다 (YouTube IFrame API 스크립트를 쓰지 않음, 콘텐츠 CSP가 외부 스크립트를 막음).
4
+ import { start } from '../lib/elice-content.js';
5
+ import { normalizeSettings } from '../core/settings.js';
6
+ import { loading, player } from '../ui/templates/player.js';
7
+ import { texts } from '../ui/texts.js';
8
+
9
+ const root = document.getElementById('app');
10
+ document.title = texts.page.learn;
11
+ document.body.classList.add('yt-page');
12
+ root.replaceChildren(loading('learn'));
13
+ const app = await start({ screen: 'learn' });
14
+ const { youtube } = normalizeSettings(app.content);
15
+
16
+ // 편집 화면에서 아직 주소를 저장하지 않았으면 안내만 보인다
17
+ if (app.hasContent && youtube) root.replaceChildren(player(youtube));
18
+ else root.replaceChildren(app.emptyState());
@@ -0,0 +1,101 @@
1
+ /* YouTube 화면 스타일. 이 자료에만 있는 것(플레이어 자리 · 링크 줄 · 미리보기 자리)만 둡니다.
2
+ 플레이어 안의 모양(컨트롤 · 오류 화면)은 YouTube iframe이 그려 여기서 바꿀 수 없습니다. 색은 ui/theme.css의 --yt-* (EDS 토큰)만 */
3
+
4
+ /* ---------- 공통: 16:9 플레이어 ---------- */
5
+ .yt-frame {
6
+ width: 100%;
7
+ aspect-ratio: 16 / 9;
8
+ overflow: hidden;
9
+ background: var(--yt-player-bg);
10
+ }
11
+ .yt-frame > iframe {
12
+ display: block;
13
+ width: 100%;
14
+ height: 100%;
15
+ border: 0;
16
+ }
17
+
18
+ /* ---------- 학생 화면 ---------- */
19
+ /* 플레이어가 화면 폭을 채우되, 아래 링크 줄까지 한 화면에 보이도록 높이에 맞춰 폭을 줄인다 (가운데) */
20
+ body.yt-page {
21
+ padding: 0;
22
+ }
23
+ body.yt-page main {
24
+ max-width: none;
25
+ gap: 0;
26
+ }
27
+ body.yt-page .ec-empty {
28
+ margin: 16px;
29
+ }
30
+ .yt-player {
31
+ display: flex;
32
+ flex-direction: column;
33
+ align-items: center;
34
+ }
35
+ .yt-player > .yt-frame {
36
+ /* 링크 줄(약 56px)을 뺀 높이의 16:9 폭까지 */
37
+ width: min(100%, calc((100dvh - 56px) * 16 / 9));
38
+ border-radius: var(--yt-player-radius);
39
+ }
40
+ .yt-open {
41
+ display: flex;
42
+ flex-wrap: wrap;
43
+ align-items: baseline;
44
+ justify-content: center;
45
+ gap: 4px 12px;
46
+ margin: 0;
47
+ padding: 12px 16px;
48
+ font-size: var(--eds-fs-body2);
49
+ text-align: center;
50
+ word-break: keep-all;
51
+ }
52
+ .yt-open-link {
53
+ display: inline-flex;
54
+ align-items: center;
55
+ min-height: 44px;
56
+ color: var(--yt-link);
57
+ font-weight: var(--eds-fw-semibold);
58
+ text-decoration: underline;
59
+ text-underline-offset: 3px;
60
+ }
61
+ .yt-open-hint {
62
+ color: var(--yt-hint);
63
+ font-size: var(--eds-fs-caption);
64
+ }
65
+
66
+ /* ---------- 편집 화면: 키트 body.ec-edit-page 위에 이 자료만의 것 ---------- */
67
+ /* 영상 템플릿처럼 화면 전체가 주소 한 칸 · 미리보기 한 칸이라 단은 화면 폭 가득, 바탕은 흰색(카드로 나누지 않음) */
68
+ :root:has(body.ec-edit-page) {
69
+ --ec-edit-page-bg: var(--ec-edit-card);
70
+ }
71
+ body.ec-edit-page main {
72
+ max-width: none;
73
+ gap: 16px;
74
+ }
75
+ body.ec-edit-page .ec-submitbar {
76
+ padding-inline: 16px;
77
+ }
78
+ .ye-start {
79
+ margin: 0;
80
+ }
81
+ .ye-preview-body > .yt-frame {
82
+ border-radius: var(--yt-preview-radius);
83
+ }
84
+ .ye-preview-empty {
85
+ display: flex;
86
+ flex-direction: column;
87
+ align-items: center;
88
+ justify-content: center;
89
+ gap: 8px;
90
+ width: 100%;
91
+ aspect-ratio: 16 / 9;
92
+ padding: 24px;
93
+ border-radius: var(--yt-preview-radius);
94
+ background: var(--yt-player-bg);
95
+ color: var(--yt-on-player);
96
+ text-align: center;
97
+ }
98
+ .ye-preview-empty p {
99
+ margin: 0;
100
+ font-size: var(--eds-fs-body2);
101
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "youtube",
3
+ "version": "1.0.0",
4
+ "title": "YouTube",
5
+ "description": "YouTube 영상 주소를 넣어 보여 줍니다",
6
+ "catalog": {
7
+ "category": "theory",
8
+ "icon": "video",
9
+ "sortOrder": 25,
10
+ "thumbnailUrl": "https://static.elice.io/elice-material/custom/templates/youtube/thumbnail.png",
11
+ "previewUrl": "https://static.elice.io/elice-material/custom/templates/youtube/preview.png",
12
+ "defaultCompletionPolicy": "on_access"
13
+ }
14
+ }
@@ -0,0 +1,60 @@
1
+ // 내용 편집 화면 마크업 (디자인 V3 "내용 편집"과 같은 키트 클래스). 바탕 · 밑줄 칸 · 저장 바는 키트(.ec-*,
2
+ // lib/elice-content.css "편집 화면")이고, 이 자료에만 있는 것(미리보기 자리)만 ye-* (styles.css)입니다.
3
+ // 클래스 · 배치는 바꿔도 되지만, 남겨야 하는 data-role (동작이 찾음): input · error · start · preview
4
+ // data-ec-quiet가 붙은 곳은 바뀌어도 "저장하지 않은 변경"으로 보지 않습니다 (키트 useSave).
5
+ import { html } from '../../core/dom.js';
6
+ import { texts } from '../texts.js';
7
+
8
+ const t = texts.edit;
9
+
10
+ /** 주소 칸: 위 라벨(필수 *) + 밑줄 칸 + 도움말 + 오류 줄 */
11
+ export const urlField = value => html`
12
+ <div class="ec-field ye-url">
13
+ <label class="ec-field-label" for="ye-url">
14
+ ${t.url}<span class="ec-required" aria-hidden="true"> ${t.required}</span>
15
+ </label>
16
+ <input
17
+ id="ye-url"
18
+ class="ec-field-input"
19
+ data-role="input"
20
+ type="url"
21
+ inputmode="url"
22
+ autocomplete="off"
23
+ spellcheck="false"
24
+ placeholder="${t.placeholder}"
25
+ aria-describedby="ye-url-hint ye-url-error"
26
+ aria-required="true"
27
+ value="${value}"
28
+ />
29
+ <p class="ec-field-hint" id="ye-url-hint">${t.hint}</p>
30
+ <p class="ec-error" id="ye-url-error" data-role="error" role="alert" data-ec-quiet hidden></p>
31
+ </div>
32
+ `;
33
+
34
+ /** 미리보기 구역: 시작 시각 안내 줄 + 플레이어 자리 */
35
+ export const previewSection = () => html`
36
+ <section class="ec-section ye-preview" data-ec-quiet>
37
+ <p class="ec-field-hint ye-start" data-role="start" hidden></p>
38
+ <div class="ye-preview-body" data-role="preview"></div>
39
+ </section>
40
+ `;
41
+
42
+ /** 주소가 없거나 틀렸을 때 미리보기 자리 */
43
+ export const previewEmpty = () => html`
44
+ <div class="ye-preview-empty">
45
+ <svg viewBox="0 0 24 24" width="28" height="28" aria-hidden="true" focusable="false">
46
+ <rect
47
+ x="3"
48
+ y="5"
49
+ width="18"
50
+ height="14"
51
+ rx="2"
52
+ fill="none"
53
+ stroke="currentColor"
54
+ stroke-width="1.8"
55
+ />
56
+ <path d="M10 9.5v5l4.5-2.5z" fill="currentColor" />
57
+ </svg>
58
+ <p>${t.previewEmpty}</p>
59
+ </div>
60
+ `;
@@ -0,0 +1,61 @@
1
+ // 학생 화면 · 편집 화면 미리보기의 플레이어 마크업. 플레이어 안(재생 · 컨트롤 · 오류 화면)은 YouTube iframe이 그립니다.
2
+ // 플레이어 주소는 core/youtube.js embedUrl()만 씁니다 (콘텐츠 CSP가 www.youtube-nocookie.com/embed/만 허용).
3
+ // 남겨야 하는 data-role: frame · link
4
+ import { html } from '../../core/dom.js';
5
+ import { embedUrl, watchUrl } from '../../core/youtube.js';
6
+ import { texts } from '../texts.js';
7
+
8
+ const t = texts.player;
9
+
10
+ /** 불러오는 동안 (키트 스켈레톤과 같은 모양) */
11
+ export const loading = layout =>
12
+ layout === 'edit'
13
+ ? html`<div class="ec-sk ec-sk-edit" role="status">
14
+ <span class="ec-visually-hidden">${texts.page.loading}</span>
15
+ <div class="ec-sk-bar ec-sk-shimmer"></div>
16
+ <div class="ec-sk-media ec-sk-shimmer"></div>
17
+ </div>`
18
+ : html`<div class="ec-sk ec-sk-learn ec-sk-shimmer" role="status">
19
+ <span class="ec-visually-hidden">${texts.page.loading}</span>
20
+ </div>`;
21
+
22
+ /**
23
+ * 16:9 플레이어 (iframe). referrerpolicy: YouTube가 퍼가는 페이지 출처를 보고 재생을 허락한다 (리퍼러가 없으면 오류 153)
24
+ * @param {{ videoId: string, start?: number }} video
25
+ */
26
+ export const frame = ({ videoId, start }) => html`
27
+ <div class="yt-frame">
28
+ <iframe
29
+ data-role="frame"
30
+ src="${embedUrl(videoId, start)}"
31
+ title="${t.title}"
32
+ allow="autoplay; encrypted-media; picture-in-picture; fullscreen"
33
+ allowfullscreen
34
+ referrerpolicy="strict-origin-when-cross-origin"
35
+ ></iframe>
36
+ </div>
37
+ `;
38
+
39
+ /**
40
+ * 플레이어 아래 줄: 'YouTube에서 보기' 링크 + 한 줄 안내.
41
+ * 보통 <a href>라 LXP가 sandbox 밖 새 탭(앱은 앱 브라우저)으로 엽니다. window.open은 쓰지 않습니다 (sandbox 팝업에서 깨짐)
42
+ * @param {{ videoId: string, start?: number }} video
43
+ */
44
+ export const openLink = ({ videoId, start }) => html`
45
+ <p class="yt-open">
46
+ <a
47
+ class="yt-open-link"
48
+ data-role="link"
49
+ href="${watchUrl(videoId, start)}"
50
+ target="_blank"
51
+ rel="noopener noreferrer"
52
+ >${t.openOnYouTube}</a
53
+ >
54
+ <span class="yt-open-hint">${t.hint}</span>
55
+ </p>
56
+ `;
57
+
58
+ /** 학생 화면: 플레이어 + 링크 */
59
+ export const player = video => html`
60
+ <div class="yt-player">${frame(video)} ${openLink(video)}</div>
61
+ `;
@@ -0,0 +1,3 @@
1
+ // ui/texts.js 타입 (테스트용). 문구는 texts.js에서만 고치면 됩니다.
2
+ /* eslint-disable @typescript-eslint/no-explicit-any */
3
+ export declare const texts: Record<string, any>;
@@ -0,0 +1,50 @@
1
+ // YouTube 화면에 보이는 문구 모음 (학생 · 편집). 문구를 바꾸려면 여기만 고치면 됩니다.
2
+ // 플레이어 안(재생 · 컨트롤 · '이 동영상은 재생할 수 없음' 같은 오류)은 YouTube가 그려 여기에 없습니다.
3
+
4
+ export const texts = {
5
+ /** 브라우저 탭 제목 · 불러오는 동안 보이는 문구 (화면이 넣음. HTML의 같은 글은 스크립트가 돌기 전 대비용) */
6
+ page: {
7
+ learn: '학생 화면',
8
+ edit: '내용 편집',
9
+ loading: '불러오는 중…',
10
+ },
11
+
12
+ /** 학생 화면 · 편집 화면 미리보기 플레이어 */
13
+ player: {
14
+ /** iframe 제목 (화면 읽기 프로그램) */
15
+ title: 'YouTube 동영상 플레이어',
16
+ /** 플레이어 아래 링크 (YouTube 페이지를 새 탭 · 앱 브라우저로 엶) */
17
+ openOnYouTube: 'YouTube에서 보기',
18
+ /** 링크 옆 한 줄 안내 */
19
+ hint: '영상이 재생되지 않으면(퍼가기를 막은 영상 등) YouTube에서 보세요.',
20
+ },
21
+
22
+ /** 내용 편집 화면 */
23
+ edit: {
24
+ required: '*',
25
+ url: 'YouTube 주소',
26
+ placeholder: 'https://www.youtube.com/watch?v=…',
27
+ /** 칸 아래 도움말 */
28
+ hint: 'YouTube 영상 주소를 붙여 넣으세요. youtu.be · Shorts · 라이브 주소도 됩니다. 주소에 시작 시각(t=)이 있으면 그 시각부터 재생합니다.',
29
+ /** 시작 시각을 읽었을 때 미리보기 위에 (예: "1분 30초부터 재생합니다.") */
30
+ startsAt: start => `${formatTime(start)}부터 재생합니다.`,
31
+ /** 주소가 없을 때 미리보기 자리 */
32
+ previewEmpty: '주소를 넣으면 여기에 미리보기가 보입니다.',
33
+
34
+ /** 저장 버튼 (키트 useSave label) */
35
+ save: '초안으로 저장',
36
+
37
+ validation: {
38
+ urlRequired: 'YouTube 주소를 입력하세요.',
39
+ urlInvalid: 'YouTube 영상 주소가 아닙니다. 영상 페이지의 주소를 붙여 넣으세요.',
40
+ },
41
+ },
42
+ };
43
+
44
+ /** 초 → "1시간 2분 3초" */
45
+ function formatTime(seconds) {
46
+ const h = Math.floor(seconds / 3600);
47
+ const m = Math.floor((seconds % 3600) / 60);
48
+ const s = seconds % 60;
49
+ return [h && `${h}시간`, m && `${m}분`, s && `${s}초`].filter(Boolean).join(' ');
50
+ }
@@ -0,0 +1,14 @@
1
+ /* YouTube 테마. 이 자료만의 색 · 모서리를 여기서 바꿉니다 (styles.css가 이 값을 씁니다).
2
+ 편집 화면의 바탕 · 밑줄 칸 · 저장 바는 키트(lib/elice-content.css "편집 화면", body.ec-edit-page)가 그리고,
3
+ 플레이어 안(재생 · 컨트롤 · 오류 화면)은 YouTube가 그립니다. 값은 EDS 토큰(lib/elice-tokens.css)만 씁니다. */
4
+ :root {
5
+ /* 플레이어 자리 바탕 (영상 위: 두 테마 모두 검정) · 그 위 안내 글자 */
6
+ --yt-player-bg: var(--eds-common-black);
7
+ --yt-on-player: color-mix(in srgb, var(--eds-common-white) 70%, transparent);
8
+ /* 학생 화면 플레이어는 화면 폭 가득이라 모서리 없음, 편집 화면 미리보기는 10px (영상 템플릿과 같게) */
9
+ --yt-player-radius: 0;
10
+ --yt-preview-radius: 10px;
11
+ /* 플레이어 아래 링크 줄 */
12
+ --yt-link: var(--eds-primary-main);
13
+ --yt-hint: var(--eds-text-tertiary);
14
+ }