@eliceio/cdk-cli 1.6.1 → 1.7.1-entryqa.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 (66) hide show
  1. package/es/commands/create/scaffold.d.ts +1 -1
  2. package/es/commands/create/scaffold.js +1 -1
  3. package/es/commands/dev/index.d.ts +1 -1
  4. package/es/commands/dev/index.js +1 -1
  5. package/es/dev/host-page.js +19 -3
  6. package/es/dev/kv-public-mock.d.ts +101 -0
  7. package/es/dev/kv-public-mock.js +489 -0
  8. package/es/dev/mock-api.d.ts +28 -6
  9. package/es/dev/mock-api.js +57 -59
  10. package/es/dev/mock-http.d.ts +28 -0
  11. package/es/dev/mock-http.js +53 -0
  12. package/es/dev/server.js +8 -3
  13. package/package.json +2 -2
  14. package/skills/_shared/references/17-using-the-entry-template.md +6 -4
  15. package/templates/_shared/lib/cdk-mock.d.ts +37 -0
  16. package/templates/_shared/lib/cdk-mock.js +89 -1
  17. package/templates/_shared/lib/elice-content.d.ts +5 -0
  18. package/templates/_shared/lib/elice-content.js +7 -0
  19. package/templates/board/README.md +118 -0
  20. package/templates/board/commentary.txt +6 -0
  21. package/templates/board/core/board.d.ts +176 -0
  22. package/templates/board/core/board.js +732 -0
  23. package/templates/board/core/dom.d.ts +13 -0
  24. package/templates/board/core/dom.js +83 -0
  25. package/templates/board/core/model.d.ts +58 -0
  26. package/templates/board/core/model.js +217 -0
  27. package/templates/board/core/settings.d.ts +44 -0
  28. package/templates/board/core/settings.js +131 -0
  29. package/templates/board/edit.html +23 -0
  30. package/templates/board/gitignore +4 -0
  31. package/templates/board/index.html +22 -0
  32. package/templates/board/instructor.html +23 -0
  33. package/templates/board/metadata.json +9 -0
  34. package/templates/board/package.json +13 -0
  35. package/templates/board/screens/board.js +318 -0
  36. package/templates/board/screens/edit.js +631 -0
  37. package/templates/board/screens/instructor.js +16 -0
  38. package/templates/board/screens/learn.js +14 -0
  39. package/templates/board/template.json +14 -0
  40. package/templates/board/ui/background.css +8 -0
  41. package/templates/board/ui/board-bg.webp +0 -0
  42. package/templates/board/ui/board.css +1124 -0
  43. package/templates/board/ui/card.js +141 -0
  44. package/templates/board/ui/composer.js +329 -0
  45. package/templates/board/ui/dropdown.js +185 -0
  46. package/templates/board/ui/icons.js +36 -0
  47. package/templates/board/ui/learn.css +141 -0
  48. package/templates/board/ui/menu.js +104 -0
  49. package/templates/board/ui/texts.d.ts +3 -0
  50. package/templates/board/ui/texts.js +162 -0
  51. package/templates/entry/README.md +5 -5
  52. package/templates/entry/core/grading.js +1 -1
  53. package/templates/entry/docs/storage.md +2 -2
  54. package/templates/entry/screens/edit/panels/answer-project.js +1 -1
  55. package/templates/entry/screens/edit/panels/grading.d.ts +2 -1
  56. package/templates/entry/screens/edit/panels/grading.js +15 -11
  57. package/templates/entry/screens/edit/panels/index.js +6 -5
  58. package/templates/entry/screens/edit/panels/preference.d.ts +15 -0
  59. package/templates/entry/screens/edit/panels/preference.js +9 -21
  60. package/templates/entry/screens/edit/panels/project-panel.js +3 -6
  61. package/templates/entry/screens/edit.js +39 -10
  62. package/templates/entry/styles.css +226 -210
  63. package/templates/entry/template.json +1 -1
  64. package/templates/entry/ui/templates/page.js +22 -4
  65. package/templates/entry/ui/texts.js +11 -13
  66. package/templates/entry/ui/theme.css +19 -2
@@ -1,4 +1,4 @@
1
- // 패널: 언어 선택 (블록 코딩 · 엔트리파이썬). settings.entry.preference = { workspaceMode }
1
+ // 패널: 언어 선택 ('설정' 탭 맨 위 구역, 블록 코딩 · 엔트리파이썬). settings.entry.preference = { workspaceMode }
2
2
  // 학생 화면은 이 값을 워크스페이스 GET_ELICE_PREFERENCE 답으로 줍니다. 편집 화면은 바꾸면 워크스페이스를 다시 엽니다 (screens/edit.js).
3
3
  import { html } from '../../../core/dom.js';
4
4
  import { normalizePreference, WORKSPACE_MODES } from '../../../core/settings.js';
@@ -7,6 +7,9 @@ import { texts } from '../../../ui/texts.js';
7
7
  export default {
8
8
  id: 'preference',
9
9
  title: texts.edit.preference.title,
10
+ tab: 'settings',
11
+ /** 탭 안에서도 구역 제목을 보임 */
12
+ heading: true,
10
13
  normalize: normalizePreference,
11
14
  render(el, ctx) {
12
15
  const t = texts.edit.preference;
@@ -29,26 +32,11 @@ export default {
29
32
  if (input.checked) ctx.set({ workspaceMode: input.value });
30
33
  });
31
34
  }
32
- // 안내 한 줄: 파란 정보 아이콘 + 글 (바꾸면 워크스페이스를 다시 엶)
33
- const info = html`<div class="en-alert" role="status">
34
- <span class="en-alert-icon" aria-hidden="true"
35
- ><svg
36
- width="20"
37
- height="20"
38
- viewBox="0 0 24 24"
39
- fill="none"
40
- stroke="currentColor"
41
- stroke-width="1.75"
42
- stroke-linecap="round"
43
- stroke-linejoin="round"
44
- >
45
- <circle cx="12" cy="12" r="9.25" />
46
- <path d="M12 11v6" />
47
- <circle cx="12" cy="7.75" r="0.6" fill="currentColor" /></svg
48
- ></span>
49
- <span>${t.info}</span>
50
- </div>`;
51
- el.append(group, info);
35
+ // 세그먼트 오른쪽 안내 한 줄 (바꾸면 워크스페이스를 다시 엶)
36
+ const info = html`<p class="en-settings-hint">${t.info}</p>`;
37
+ const row = html`<div class="en-settings-row"></div>`;
38
+ row.append(group, info);
39
+ el.append(row);
52
40
  },
53
41
  toPreference(value) {
54
42
  return { workspaceMode: value.workspaceMode };
@@ -1,8 +1,7 @@
1
- // 작품 패널 만들기: 워크스페이스(?mode=skeleton) 하나 + 아래 줄(왼쪽 안내 목록 · 오른쪽 용량 칩). 시작 화면 · 정답 작품 패널이 씁니다.
1
+ // 작품 패널 만들기: 워크스페이스(?mode=skeleton) 하나 + 아래 줄(오른쪽 용량 칩, 한도의 80%를 넘을 때만). 시작 화면 · 정답 작품 패널이 씁니다.
2
2
  // 저장 직전 워크스페이스에서 작품을 꺼내 core/pack.js 모양({ enc: 'gzip+base64', data })으로 줄입니다.
3
3
  // 용량: 블록이 바뀌면 2초 뒤 작품을 꺼내 settings 전체 크기를 다시 재고(칩은 screens/edit.js가 두 탭 모두 같이 바꿈),
4
4
  // 저장할 때 다시 잽니다. settings 전체가 서버 한도(64KB)를 넘으면 칩 위에 빨간 글을 띄우고 저장을 막습니다.
5
- import { infoList } from '../../../lib/elice-content.js';
6
5
  import { html } from '../../../core/dom.js';
7
6
  import { packedProject } from '../../../core/grading.js';
8
7
  import { formatBytes, pack } from '../../../core/pack.js';
@@ -15,7 +14,7 @@ const MEASURE_DELAY_MS = 2000;
15
14
  * @param {{
16
15
  * id: string,
17
16
  * tab: string,
18
- * t: { title: string, info: string[], noProject: string },
17
+ * t: { title: string, noProject: string },
19
18
  * lazy?: boolean, // 탭을 처음 열 때 워크스페이스를 띄움 (그 전에는 저장된 값을 그대로 저장)
20
19
  * secret?: boolean, // settings.entry가 아니라 settings.grading에 저장 (학생에게 안 감). normalize는 app.grading을 받음
21
20
  * fromGrading?: (grading: unknown) => unknown,
@@ -29,9 +28,7 @@ export function projectPanel({ id, tab, t, lazy = false, secret = false, fromGra
29
28
  secret,
30
29
  normalize: raw => packedProject(secret ? fromGrading(raw) : raw),
31
30
  render(el, ctx) {
32
- const info = infoList(t.info);
33
- info.setAttribute('data-ec-quiet', '');
34
- const footer = html`<div class="en-panel-footer">${info}${ctx.sizeBox()}</div>`;
31
+ const footer = html`<div class="en-panel-footer">${ctx.sizeBox()}</div>`;
35
32
  el.append(footer);
36
33
 
37
34
  let timer = null;
@@ -1,11 +1,12 @@
1
- // 내용 편집 화면. 위에 언어 선택, 아래 탭 카드('시작 화면' · '채점 설정')에 패널(screens/edit/panels/index.js)을 그리고,
2
- // 키트 저장 바(useSave)로 저장합니다. 새 기능은 패널 파일 하나 + 목록에 한 줄 (panels/index.js 머리 주석).
1
+ // 내용 편집 화면. 탭 카드('시작 화면' · '채점 화면' · '설정')에 패널(screens/edit/panels/index.js)을 그리고,
2
+ // 키트 저장 바(useSave)로 저장합니다. 배치는 디자인 시안 '내용 편집 다이얼로그 (Full screen)' (머리 줄 · 아래 저장 줄은 LXP 편집기가 그림). 새 기능은 패널 파일 하나 + 목록에 한 줄 (panels/index.js 머리 주석).
3
3
  //
4
4
  // 저장하는 곳 (docs/storage.md):
5
5
  // settings.entry.<패널 id> : 학생에게도 내려가는 값 (시작 화면 작품 · 언어)
6
6
  // settings.grading : secret 패널(채점 방식 · 정답 작품)을 core/grading.js buildGrading으로 합친 것. 서버가 학생에게 내려주지 않음
7
7
  //
8
- // 워크스페이스(?mode=skeleton)는 탭마다 하나: 시작 화면은 처음부터 띄우고, 정답 작품은 '채점 설정' 탭을 처음 열 때 띄웁니다.
8
+ // 워크스페이스(?mode=skeleton)는 작품 탭마다 하나: 시작 화면은 처음부터 띄우고, 정답 작품은 '채점 화면' 탭을 처음 열 때 띄웁니다.
9
+ // '설정' 탭: 언어 선택 → 채점 방식(AI 채점이면 AI 채점 기준).
9
10
  // 저장 전 검사(서버 422와 같은 규칙): AI 채점은 정답 작품 · 시작 화면 작품이 있어야 하고 기준의 오브젝트가 정답 작품에 있어야 함,
10
11
  // 일반 채점은 정답 작품에 블록(또는 전역 리스트)이 있어야 함. 서버가 그래도 거절하면 키트가 서버 코드를 한국어 문구로 보여 줌.
11
12
  import { start } from '../lib/elice-content.js';
@@ -14,7 +15,7 @@ import { buildGrading, hasGradable, hasUnknownObject, projectObjects } from '../
14
15
  import { formatBytes, jsonBytes, unpack } from '../core/pack.js';
15
16
  import { joinSettings, LIMITS, splitSettings } from '../core/settings.js';
16
17
  import { connectWorkspace } from '../core/workspace.js';
17
- import { loading, panelSection, sizeBox, tabCard, unavailable } from '../ui/templates/page.js';
18
+ import { loading, panelSection, saveHint, sizeBox, tabCard, unavailable } from '../ui/templates/page.js';
18
19
  import { texts } from '../ui/texts.js';
19
20
  import panels from './edit/panels/index.js';
20
21
 
@@ -108,13 +109,15 @@ async function reloadWorkspaces() {
108
109
  }
109
110
  }
110
111
 
111
- // 용량 칩 (작품 패널 아래 오른쪽, 탭마다 하나): settings 전체 크기 / 서버 한도. 넘으면 칩 위에 빨간 글
112
+ // 용량 칩 (작품 패널 아래 오른쪽, 탭마다 하나): settings 전체 크기 / 서버 한도. 한도의 80%를 넘을 때만 보이고, 넘으면 칩 위에 빨간 글
113
+ const SIZE_CHIP_FROM = 0.8;
112
114
  const sizeBoxes = [];
113
115
  let lastTotal = null;
114
116
  function showTotal(total) {
115
117
  lastTotal = total;
116
118
  const over = total > LIMITS.settingsBytes;
117
- for (const { chip, message } of sizeBoxes) {
119
+ for (const { box, chip, message } of sizeBoxes) {
120
+ box.hidden = total <= LIMITS.settingsBytes * SIZE_CHIP_FROM;
118
121
  chip.textContent = texts.edit.size.chip(formatBytes(total), formatBytes(LIMITS.settingsBytes));
119
122
  chip.dataset.over = String(over);
120
123
  message.textContent = over
@@ -166,10 +169,10 @@ const contexts = new Map(
166
169
  onShow: cb => showListeners.get(panel).add(cb),
167
170
  /** 이 패널 값이 v일 때 settings 전체 크기 (바이트, grading 포함) */
168
171
  settingsBytes: v => totalBytes({ [panel.id]: v }),
169
- /** 용량 칩 하나 (작품 패널 아래). 칩은 모든 탭이 같은 값 */
172
+ /** 용량 칩 하나 (작품 패널 아래, 한도의 80%를 넘을 때만 보임). 칩은 모든 탭이 같은 값 */
170
173
  sizeBox() {
171
174
  const box = sizeBox();
172
- sizeBoxes.push({ chip: part(box, 'size-chip'), message: part(box, 'size-message') });
175
+ sizeBoxes.push({ box, chip: part(box, 'size-chip'), message: part(box, 'size-message') });
173
176
  showTotal(lastTotal ?? totalBytes({}));
174
177
  return box;
175
178
  },
@@ -194,7 +197,12 @@ const contexts = new Map(
194
197
  );
195
198
 
196
199
  const sections = panels.map(panel => {
197
- const section = panelSection({ id: panel.id, title: panel.title, inTab: Boolean(panel.tab) });
200
+ const section = panelSection({
201
+ id: panel.id,
202
+ title: panel.title,
203
+ inTab: Boolean(panel.tab),
204
+ heading: Boolean(panel.heading),
205
+ });
198
206
  panel.render(part(section, 'body'), contexts.get(panel));
199
207
  return section;
200
208
  });
@@ -207,6 +215,7 @@ const tabNames = [...new Set(tabbed.map(x => x.panel.tab))];
207
215
  if (tabbed.length) {
208
216
  const card = tabCard({ tabs: tabNames });
209
217
  tabbed[0].section.before(card);
218
+ card.dataset.tabs = String(tabNames.length);
210
219
  card.append(...tabbed.map(x => x.section));
211
220
  const tabs = [...card.querySelectorAll('[data-role="tab"]')];
212
221
  const select = (name, focus = false) => {
@@ -216,6 +225,7 @@ if (tabbed.length) {
216
225
  tab.tabIndex = on ? 0 : -1;
217
226
  if (on && focus) tab.focus();
218
227
  }
228
+ card.dataset.selected = name;
219
229
  for (const { panel, section } of tabbed) {
220
230
  const on = panel.tab === name;
221
231
  section.hidden = !on;
@@ -289,6 +299,25 @@ const save = app.useSave({
289
299
  } else if (values.answerProject && answerDecoded && !hasGradable(answerDecoded)) return g.emptyAnswer;
290
300
  return true;
291
301
  },
292
- // settings.grading: 정답 작품이 없으면(채점 설정 탭을 열지 않은 새 자료, 일반 채점) 저장된 채점 설정을 그대로 둠
302
+ // settings.grading: 정답 작품이 없으면(채점 화면 탭을 열지 않은 새 자료, 일반 채점) 저장된 채점 설정을 그대로 둠
293
303
  getGrading: () => gradingWith({}) ?? undefined,
294
304
  });
305
+ // 아래 저장 줄 (시안): 화면 맨 아래 고정, 버튼 왼쪽에 '초안으로 저장'을 눌러야 저장된다는 안내. 저장 동작은 키트 그대로
306
+ save.element.classList.add('en-savebar');
307
+ save.element.querySelector('button')?.before(saveHint());
308
+ // 저장 줄 왼쪽 키트 상태 문구: 평소('저장하지 않은 변경' 표시 · 빈 글)에는 숨기고, 검사 오류 · 저장 결과일 때만 보임.
309
+ // 키트 문구를 그대로 비교한다 (키트 lib/elice-content.js mountSave의 markDirty 문구. 키트가 바꾸면 여기도)
310
+ const KIT_DIRTY_TEXT = '저장하지 않은 변경이 있어요.';
311
+ const saveStatus = save.element.querySelector('[role="status"]');
312
+ if (saveStatus) {
313
+ const paintStatus = () => {
314
+ const text = saveStatus.textContent.trim();
315
+ saveStatus.hidden = !text || text === KIT_DIRTY_TEXT;
316
+ };
317
+ paintStatus();
318
+ new MutationObserver(paintStatus).observe(saveStatus, {
319
+ childList: true,
320
+ characterData: true,
321
+ subtree: true,
322
+ });
323
+ }