@eliceio/cdk-cli 1.2.1 → 1.3.0-contenttypes.1
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/README.md +63 -53
- package/es/cli.js +11 -2
- package/es/commands/build/index.js +12 -0
- package/es/commands/create/index.js +2 -0
- package/es/commands/create/scaffold.d.ts +2 -2
- package/es/commands/create/scaffold.js +3 -3
- package/es/commands/dev/index.d.ts +10 -1
- package/es/commands/dev/index.js +47 -7
- package/es/commands/doctor/index.js +6 -2
- package/es/core/config.d.ts +42 -9
- package/es/core/config.js +217 -12
- package/es/core/project-check.d.ts +3 -2
- package/es/core/project-check.js +14 -3
- package/es/core/regex.d.ts +11 -0
- package/es/core/regex.js +41 -0
- package/es/core/sandbox.d.ts +26 -0
- package/es/core/sandbox.js +240 -30
- package/es/dev/assets.d.ts +80 -0
- package/es/dev/assets.js +240 -0
- package/es/dev/check.d.ts +30 -0
- package/es/dev/check.js +224 -34
- package/es/dev/grading.d.ts +49 -14
- package/es/dev/grading.js +109 -29
- package/es/dev/host-page.js +27 -3
- package/es/dev/inject.d.ts +2 -1
- package/es/dev/inject.js +10 -2
- package/es/dev/mock-api.d.ts +26 -3
- package/es/dev/mock-api.js +219 -40
- package/es/dev/server.d.ts +12 -1
- package/es/dev/server.js +115 -9
- package/es/engines/vite/index.js +1 -1
- package/es/engines/vite/plugin.d.ts +2 -0
- package/es/engines/vite/plugin.js +33 -5
- package/es/rules/answers.d.ts +13 -0
- package/es/rules/answers.js +94 -0
- package/es/rules/check.js +70 -1
- package/es/rules/index.d.ts +1 -0
- package/es/rules/index.js +1 -0
- package/es/rules/size.d.ts +31 -0
- package/es/rules/size.js +58 -0
- package/es/rules/types.d.ts +12 -0
- package/es/rules.json.js +2 -2
- package/package.json +2 -2
- package/rules.json +34 -5
- package/skills/_shared/always.md +3 -3
- package/skills/_shared/references/00-what-the-person-decides.md +1 -1
- package/skills/_shared/references/02-design-the-material.md +10 -7
- package/skills/_shared/references/03-create-the-project.md +10 -8
- package/skills/_shared/references/04-rules.md +1 -1
- package/skills/_shared/references/05-screen-code.md +52 -23
- package/skills/_shared/references/06-using-the-quiz-template.md +7 -6
- package/skills/_shared/references/08-fix-check-errors.md +23 -22
- package/skills/_shared/references/09-check.md +8 -6
- package/skills/_shared/references/12-upload-with-the-material-mcp.md +13 -13
- package/skills/_shared/references/13-edit-screen-design.md +122 -0
- package/skills/_shared/references/14-layouts.md +96 -0
- package/skills/elice-content-check/SKILL.md +2 -2
- package/skills/elice-content-create/SKILL.md +1 -1
- package/skills/elice-content-migrate/SKILL.md +1 -1
- package/skills/elice-content-publish/SKILL.md +1 -1
- package/templates/_shared/lib/cdk-mock.d.ts +47 -3
- package/templates/_shared/lib/cdk-mock.js +293 -15
- package/templates/_shared/lib/elice-content-editor.js +89 -58
- package/templates/_shared/lib/elice-content.css +1313 -126
- package/templates/_shared/lib/elice-content.d.ts +222 -23
- package/templates/_shared/lib/elice-content.js +1176 -88
- package/templates/_shared/lib/icons/empty-content.d.ts +2 -0
- package/templates/_shared/lib/icons/empty-content.js +11 -0
- package/templates/_shared/lib/icons/file-video.d.ts +2 -0
- package/templates/_shared/lib/icons/file-video.js +11 -0
- package/templates/_shared/lib/icons/file.d.ts +2 -0
- package/templates/_shared/lib/icons/file.js +11 -0
- package/templates/blank/README.md +6 -4
- package/templates/blank/edit.html +8 -2
- package/templates/blank/index.html +6 -1
- package/templates/blank/instructor.html +6 -1
- package/templates/blank/screens/instructor.js +8 -2
- package/templates/blank/screens/learn.js +1 -1
- package/templates/blank/template.json +1 -1
- package/templates/document/README.md +92 -0
- package/templates/document/commentary.txt +2 -0
- package/templates/document/core/dom.d.ts +13 -0
- package/templates/document/core/dom.js +83 -0
- package/templates/document/core/file-type.d.ts +21 -0
- package/templates/document/core/file-type.js +85 -0
- package/templates/document/core/group-3d.d.ts +20 -0
- package/templates/document/core/group-3d.js +256 -0
- package/templates/document/core/inline-edit.d.ts +15 -0
- package/templates/document/core/inline-edit.js +377 -0
- package/templates/document/core/load.d.ts +13 -0
- package/templates/document/core/load.js +40 -0
- package/templates/document/core/pdf-options.d.ts +9 -0
- package/templates/document/core/pdf-options.js +36 -0
- package/templates/document/core/pdf-worker.d.ts +24 -0
- package/templates/document/core/pdf-worker.js +122 -0
- package/templates/document/core/pdf.d.ts +12 -0
- package/templates/document/core/pdf.js +190 -0
- package/templates/document/core/pptx-edit.d.ts +14 -0
- package/templates/document/core/pptx-edit.js +137 -0
- package/templates/document/core/pptx-fonts.d.ts +5 -0
- package/templates/document/core/pptx-fonts.js +115 -0
- package/templates/document/core/pptx-media.d.ts +18 -0
- package/templates/document/core/pptx-media.js +83 -0
- package/templates/document/core/pptx-view.d.ts +5 -0
- package/templates/document/core/pptx-view.js +185 -0
- package/templates/document/core/settings.d.ts +25 -0
- package/templates/document/core/settings.js +86 -0
- package/templates/document/core/slide-edges.d.ts +3 -0
- package/templates/document/core/slide-edges.js +82 -0
- package/templates/document/core/viewer.d.ts +28 -0
- package/templates/document/core/viewer.js +159 -0
- package/templates/document/edit.html +17 -0
- package/templates/document/gitignore +4 -0
- package/templates/document/index.html +18 -0
- package/templates/document/metadata.json +9 -0
- package/templates/document/package.json +17 -0
- package/templates/document/public/fonts/OFL-Caladea.txt +93 -0
- package/templates/document/public/fonts/OFL-Carlito.txt +93 -0
- package/templates/document/public/fonts/caladea-latin-400-normal.woff2 +0 -0
- package/templates/document/public/fonts/caladea-latin-700-normal.woff2 +0 -0
- package/templates/document/public/fonts/carlito-latin-400-normal.woff2 +0 -0
- package/templates/document/public/fonts/carlito-latin-700-normal.woff2 +0 -0
- package/templates/document/screens/edit.js +574 -0
- package/templates/document/screens/learn.js +61 -0
- package/templates/document/styles.css +644 -0
- package/templates/document/template.json +6 -0
- package/templates/document/ui/templates/edit.js +82 -0
- package/templates/document/ui/templates/page.js +11 -0
- package/templates/document/ui/templates/viewer.js +41 -0
- package/templates/document/ui/texts.d.ts +3 -0
- package/templates/document/ui/texts.js +62 -0
- package/templates/document/ui/theme.css +69 -0
- package/templates/quiz/README.md +32 -14
- package/templates/quiz/core/behaviors.d.ts +17 -7
- package/templates/quiz/core/behaviors.js +40 -53
- package/templates/quiz/core/editor.d.ts +27 -2
- package/templates/quiz/core/editor.js +412 -11
- package/templates/quiz/core/markdown.d.ts +19 -0
- package/templates/quiz/core/markdown.js +225 -11
- package/templates/quiz/core/model.d.ts +40 -3
- package/templates/quiz/core/model.js +112 -5
- package/templates/quiz/core/rich-text.d.ts +18 -0
- package/templates/quiz/core/rich-text.js +469 -0
- package/templates/quiz/edit.html +12 -3
- package/templates/quiz/index.html +12 -3
- package/templates/quiz/public/img/mascot-half.webp +0 -0
- package/templates/quiz/screens/edit.js +331 -49
- package/templates/quiz/screens/learn.js +147 -15
- package/templates/quiz/styles.css +1244 -622
- package/templates/quiz/template.json +9 -2
- package/templates/quiz/ui/templates/edit.d.ts +19 -5
- package/templates/quiz/ui/templates/edit.js +371 -77
- package/templates/quiz/ui/templates/group.js +19 -8
- package/templates/quiz/ui/templates/order.js +25 -24
- package/templates/quiz/ui/templates/page.js +33 -8
- package/templates/quiz/ui/templates/question.js +6 -4
- package/templates/quiz/ui/texts.js +91 -26
- package/templates/quiz/ui/theme.css +8 -9
- package/templates/steps/README.md +77 -0
- package/templates/steps/commentary.txt +7 -0
- package/templates/steps/edit.html +21 -0
- package/templates/steps/gitignore +4 -0
- package/templates/steps/index.html +69 -0
- package/templates/steps/metadata.json +9 -0
- package/templates/steps/package.json +13 -0
- package/templates/steps/screens/edit.js +32 -0
- package/templates/steps/screens/learn.js +108 -0
- package/templates/steps/styles.css +54 -0
- package/templates/steps/template.json +6 -0
package/es/dev/assets.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { createWriteStream, createReadStream } from 'node:fs';
|
|
3
|
+
import { mkdir, rm, rename, stat } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { pipeline } from 'node:stream/promises';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 자료 파일(PDF · PPTX 문서, PNG · JPEG · WebP · GIF 이미지) 올리기 · 보기 흉내 (dev 전용). 서버 스펙과 같은 흐름:
|
|
9
|
+
* 1. 편집 화면 SDK `assets.post` → 흉내 API `POST /storage/upload-url` `{ key: "asset.pdf" | "asset.png" | …,
|
|
10
|
+
* content_length, content_type }` → `{ upload_url, key: "assets/{material_id}/{asset_id}.{ext}" }`
|
|
11
|
+
* 2. SDK가 `upload_url`로 PUT → 콘텐츠 서버 `/__ecdk/blob/{asset_id}.{ext}`가 받아 `.ecdk/assets/`에 둔다
|
|
12
|
+
* (운영은 Azure Blob, 다른 출처)
|
|
13
|
+
* 3. 흉내 API `GET /materials/{id}`의 `current_version`(edit 토큰은 `draft`도) `asset_base_url`
|
|
14
|
+
* (운영처럼 자료 API 출처의 서명 경로까지, dev: `{API}/s/dev/`) + 저장 경로 `assets/{material_id}/{asset_key}`로
|
|
15
|
+
* 흉내 API가 내준다 (Range 206, pdf.js가 필요한 부분만 받음). 자료 API 출처는 운영 CSP `connect-src`에 있다
|
|
16
|
+
* 운영 콘텐츠 CSP `connect-src`에는 Blob 출처가 없어 2의 PUT이 막힌다. dev는 이 경로만
|
|
17
|
+
* `connect-src`에 더한다 (server.ts `devOnlyConnectSrc`). `.ecdk/`는 점 폴더라 감시 · zip에서 빠진다.
|
|
18
|
+
*/
|
|
19
|
+
/** 받은 파일을 두는 곳 (프로젝트 기준) */
|
|
20
|
+
const ASSETS_DIR = '.ecdk/assets';
|
|
21
|
+
/** 콘텐츠 서버가 PUT을 받는 경로 (운영의 Blob 업로드 URL 자리) */
|
|
22
|
+
const DEV_BLOB_PREFIX = '/__ecdk/blob/';
|
|
23
|
+
/** 흉내 API 아래 서명 경로 (asset_base_url 끝, 운영 `https://{API}/s/{서명}/` 자리) */
|
|
24
|
+
const ASSET_SIGNED_PATH = '/s/dev/';
|
|
25
|
+
/**
|
|
26
|
+
* 콘텐츠 주소를 직접 열어 mock SDK로 돌 때 쓰는 dev 전용 upload-url (호스트, 토큰 없음, 결과는 /storage/upload-url과 같음).
|
|
27
|
+
* ecdk dev는 작성자 PC에서만 돌고 올린 파일은 작성자 프로젝트(.ecdk/assets/)에만 남아 막을 대상이 없다
|
|
28
|
+
*/
|
|
29
|
+
const MOCK_UPLOAD_URL_PATH = '/__ecdk/mock-upload-url';
|
|
30
|
+
/** asset_base_url 아래 저장 경로: `assets/{material_id}/` (+ asset_key) */
|
|
31
|
+
const assetStoragePath = materialId => `assets/${materialId}/`;
|
|
32
|
+
/** 서버 한도: 문서(asset.pdf · asset.pptx) 최대 95MB */
|
|
33
|
+
const MAX_ASSET_BYTES = 95 * 1024 * 1024;
|
|
34
|
+
/** 서버 한도: 이미지(asset.png · .jpg · .jpeg · .webp · .gif) 최대 10MB. SVG는 받지 않는다 */
|
|
35
|
+
const MAX_IMAGE_BYTES = 10 * 1024 * 1024;
|
|
36
|
+
/** upload-url `key` → 확장자 · Content-Type · 최대 크기 */
|
|
37
|
+
const ASSET_UPLOAD_KINDS = Object.freeze({
|
|
38
|
+
'asset.pdf': {
|
|
39
|
+
ext: 'pdf',
|
|
40
|
+
type: 'application/pdf',
|
|
41
|
+
maxBytes: MAX_ASSET_BYTES
|
|
42
|
+
},
|
|
43
|
+
'asset.pptx': {
|
|
44
|
+
ext: 'pptx',
|
|
45
|
+
type: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
46
|
+
maxBytes: MAX_ASSET_BYTES
|
|
47
|
+
},
|
|
48
|
+
'asset.png': {
|
|
49
|
+
ext: 'png',
|
|
50
|
+
type: 'image/png',
|
|
51
|
+
maxBytes: MAX_IMAGE_BYTES
|
|
52
|
+
},
|
|
53
|
+
'asset.jpg': {
|
|
54
|
+
ext: 'jpg',
|
|
55
|
+
type: 'image/jpeg',
|
|
56
|
+
maxBytes: MAX_IMAGE_BYTES
|
|
57
|
+
},
|
|
58
|
+
'asset.jpeg': {
|
|
59
|
+
ext: 'jpeg',
|
|
60
|
+
type: 'image/jpeg',
|
|
61
|
+
maxBytes: MAX_IMAGE_BYTES
|
|
62
|
+
},
|
|
63
|
+
'asset.webp': {
|
|
64
|
+
ext: 'webp',
|
|
65
|
+
type: 'image/webp',
|
|
66
|
+
maxBytes: MAX_IMAGE_BYTES
|
|
67
|
+
},
|
|
68
|
+
'asset.gif': {
|
|
69
|
+
ext: 'gif',
|
|
70
|
+
type: 'image/gif',
|
|
71
|
+
maxBytes: MAX_IMAGE_BYTES
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const TYPE_BY_EXT = Object.freeze(Object.fromEntries(Object.values(ASSET_UPLOAD_KINDS).map(k => [k.ext, k.type])));
|
|
75
|
+
/** asset_key 모양: `{24자리 hex}.{확장자}` */
|
|
76
|
+
const ASSET_KEY = /^([0-9a-f]{24})\.(pdf|pptx|png|jpg|jpeg|webp|gif)$/;
|
|
77
|
+
/** 서버처럼 업로드 주소 유효 시간 (초) */
|
|
78
|
+
const UPLOAD_URL_EXPIRES_IN = 900;
|
|
79
|
+
/**
|
|
80
|
+
* `POST /storage/upload-url` 흉내: 종류 · 형식 · 크기를 확인하고 PUT할 주소를 준다. 오류는 서버처럼
|
|
81
|
+
* (SDK가 바꾸는 코드): 모르는 key · 크기 0은 INVALID_INPUT, 다른 content_type은 INVALID_INPUT + `unsupported_content_type`
|
|
82
|
+
* (→ file_invalid_type), 한도(문서 95MB · 이미지 10MB) 초과는 MATERIAL_PACKAGE_TOO_LARGE (→ file_invalid_size).
|
|
83
|
+
* SVG(asset.svg)는 모르는 key라 INVALID_INPUT (서버와 같음)
|
|
84
|
+
* @param opts.uploadOrigin PUT을 받는 콘텐츠 출처 (운영은 Blob 출처)
|
|
85
|
+
*/
|
|
86
|
+
function createUploadUrl(body, opts) {
|
|
87
|
+
const b = body && typeof body === 'object' ? body : {};
|
|
88
|
+
const kind = typeof b.key === 'string' ? ASSET_UPLOAD_KINDS[b.key] : undefined;
|
|
89
|
+
if (!kind) return {
|
|
90
|
+
ok: false,
|
|
91
|
+
status: 400,
|
|
92
|
+
code: 'INVALID_INPUT',
|
|
93
|
+
message: `key: one of ${Object.keys(ASSET_UPLOAD_KINDS).join(', ')}`
|
|
94
|
+
};
|
|
95
|
+
const type = b.content_type ?? b.contentType;
|
|
96
|
+
if (type != null && type !== kind.type) return {
|
|
97
|
+
ok: false,
|
|
98
|
+
status: 400,
|
|
99
|
+
code: 'INVALID_INPUT',
|
|
100
|
+
message: `content_type: ${kind.type} for ${String(b.key)}`,
|
|
101
|
+
details: [{
|
|
102
|
+
msg: 'unsupported content type',
|
|
103
|
+
type: 'app_exception_detail',
|
|
104
|
+
ctx: {
|
|
105
|
+
field: 'content_type',
|
|
106
|
+
reason: 'unsupported_content_type'
|
|
107
|
+
}
|
|
108
|
+
}]
|
|
109
|
+
};
|
|
110
|
+
const length = Number(b.content_length ?? b.contentLength);
|
|
111
|
+
if (!Number.isInteger(length) || length <= 0) return {
|
|
112
|
+
ok: false,
|
|
113
|
+
status: 400,
|
|
114
|
+
code: 'INVALID_INPUT',
|
|
115
|
+
message: 'content_length: 1 byte or more'
|
|
116
|
+
};
|
|
117
|
+
if (length > kind.maxBytes) return {
|
|
118
|
+
ok: false,
|
|
119
|
+
status: 400,
|
|
120
|
+
code: 'MATERIAL_PACKAGE_TOO_LARGE',
|
|
121
|
+
message: `content_length: up to ${kind.maxBytes} bytes (${kind.maxBytes / 1024 / 1024}MB)`,
|
|
122
|
+
details: [{
|
|
123
|
+
msg: 'too large',
|
|
124
|
+
type: 'app_exception_detail',
|
|
125
|
+
ctx: {
|
|
126
|
+
max_bytes: kind.maxBytes
|
|
127
|
+
}
|
|
128
|
+
}]
|
|
129
|
+
};
|
|
130
|
+
const assetKey = `${randomBytes(12).toString('hex')}.${kind.ext}`;
|
|
131
|
+
opts.pending.set(assetKey, length);
|
|
132
|
+
return {
|
|
133
|
+
ok: true,
|
|
134
|
+
data: {
|
|
135
|
+
upload_url: `${opts.uploadOrigin}${DEV_BLOB_PREFIX}${assetKey}?sig=dev`,
|
|
136
|
+
key: `assets/${opts.materialId}/${assetKey}`,
|
|
137
|
+
expires_in: UPLOAD_URL_EXPIRES_IN
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* 콘텐츠 서버 `PUT /__ecdk/blob/{asset_key}`: 발급한 주소만, 알린 크기까지 받아 `.ecdk/assets/{asset_key}`에 둔다 (201).
|
|
143
|
+
* 처리했으면 true, 이 경로가 아니면 false
|
|
144
|
+
*/
|
|
145
|
+
async function handleBlobPut(req, res, pathname, opts) {
|
|
146
|
+
if (!pathname.startsWith(DEV_BLOB_PREFIX)) return false;
|
|
147
|
+
const assetKey = pathname.slice(DEV_BLOB_PREFIX.length);
|
|
148
|
+
const allowed = opts.pending.get(assetKey);
|
|
149
|
+
if (req.method !== 'PUT' || allowed === undefined || !ASSET_KEY.test(assetKey)) {
|
|
150
|
+
req.resume();
|
|
151
|
+
res.writeHead(req.method === 'PUT' ? 403 : 405).end();
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
opts.pending.delete(assetKey);
|
|
155
|
+
const folder = join(opts.dir, ASSETS_DIR);
|
|
156
|
+
await mkdir(folder, {
|
|
157
|
+
recursive: true
|
|
158
|
+
});
|
|
159
|
+
const partial = join(folder, `${assetKey}.part`);
|
|
160
|
+
let size = 0;
|
|
161
|
+
try {
|
|
162
|
+
await pipeline(req, async function* (source) {
|
|
163
|
+
for await (const chunk of source) {
|
|
164
|
+
size += chunk.length;
|
|
165
|
+
if (size > allowed) throw new Error('larger than content_length');
|
|
166
|
+
yield chunk;
|
|
167
|
+
}
|
|
168
|
+
}, createWriteStream(partial));
|
|
169
|
+
} catch (e) {
|
|
170
|
+
await rm(partial, {
|
|
171
|
+
force: true
|
|
172
|
+
});
|
|
173
|
+
res.writeHead(413).end(e.message);
|
|
174
|
+
return true;
|
|
175
|
+
}
|
|
176
|
+
await rename(partial, join(folder, assetKey));
|
|
177
|
+
opts.log?.(`파일을 받았습니다: ${assetKey} (${size} bytes) → ${ASSETS_DIR}/`);
|
|
178
|
+
res.writeHead(201).end();
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* 흉내 API `GET · HEAD /s/dev/assets/{material_id}/{asset_key}`. Range(206)를 받는다.
|
|
183
|
+
* 받은 파일이 없으면 false
|
|
184
|
+
*/
|
|
185
|
+
async function serveAsset(req, res, assetKey, dir) {
|
|
186
|
+
const m = ASSET_KEY.exec(assetKey);
|
|
187
|
+
if (!m || req.method !== 'GET' && req.method !== 'HEAD') return false;
|
|
188
|
+
const file = join(dir, ASSETS_DIR, assetKey);
|
|
189
|
+
const info = await stat(file).catch(() => null);
|
|
190
|
+
if (!info) return false;
|
|
191
|
+
const total = info.size;
|
|
192
|
+
const base = {
|
|
193
|
+
'Content-Type': TYPE_BY_EXT[m[2] ?? ''] ?? 'application/octet-stream',
|
|
194
|
+
'Accept-Ranges': 'bytes'
|
|
195
|
+
};
|
|
196
|
+
const range = /^bytes=(\d*)-(\d*)$/.exec(req.headers.range ?? '');
|
|
197
|
+
let start = 0;
|
|
198
|
+
let end = total - 1;
|
|
199
|
+
if (range) {
|
|
200
|
+
const [, from = '', to = ''] = range;
|
|
201
|
+
if (from === '') {
|
|
202
|
+
// bytes=-N: 끝에서 N바이트
|
|
203
|
+
start = Math.max(0, total - Number(to));
|
|
204
|
+
} else {
|
|
205
|
+
start = Number(from);
|
|
206
|
+
if (to !== '') end = Math.min(Number(to), total - 1);
|
|
207
|
+
}
|
|
208
|
+
if (start > end || start >= total) {
|
|
209
|
+
res.writeHead(416, {
|
|
210
|
+
...base,
|
|
211
|
+
'Content-Range': `bytes */${total}`
|
|
212
|
+
}).end();
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
res.writeHead(206, {
|
|
216
|
+
...base,
|
|
217
|
+
'Content-Range': `bytes ${start}-${end}/${total}`,
|
|
218
|
+
'Content-Length': String(end - start + 1)
|
|
219
|
+
});
|
|
220
|
+
} else res.writeHead(200, {
|
|
221
|
+
...base,
|
|
222
|
+
'Content-Length': String(total)
|
|
223
|
+
});
|
|
224
|
+
if (req.method === 'HEAD' || total === 0) {
|
|
225
|
+
res.end();
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
await pipeline(createReadStream(file, {
|
|
229
|
+
start,
|
|
230
|
+
end
|
|
231
|
+
}), res).catch(() => undefined);
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
/** "처음 상태로": 받은 파일도 지운다 */
|
|
235
|
+
const removeAssets = dir => rm(join(dir, ASSETS_DIR), {
|
|
236
|
+
recursive: true,
|
|
237
|
+
force: true
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
export { ASSETS_DIR, ASSET_SIGNED_PATH, ASSET_UPLOAD_KINDS, DEV_BLOB_PREFIX, MAX_ASSET_BYTES, MAX_IMAGE_BYTES, MOCK_UPLOAD_URL_PATH, assetStoragePath, createUploadUrl, handleBlobPut, removeAssets, serveAsset };
|
package/es/dev/check.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export declare const CHECK_VIEWPORTS: {
|
|
|
6
6
|
readonly desktop: "100%";
|
|
7
7
|
readonly mobile: "360px";
|
|
8
8
|
};
|
|
9
|
+
/** --theme: 콘텐츠 문서에 EDS 테마(data-eds-theme)를 붙여 찍는다. 없으면 프로젝트 그대로 */
|
|
10
|
+
export declare const CHECK_THEMES: readonly ["light", "dark"];
|
|
11
|
+
export type CheckTheme = (typeof CHECK_THEMES)[number];
|
|
12
|
+
/** --step: 키트 스테퍼가 있는 화면은 단계마다 찍는다 ('all' 또는 1부터 센 단계 번호) */
|
|
13
|
+
export type CheckSteps = 'all' | number[];
|
|
9
14
|
export type CheckViewport = keyof typeof CHECK_VIEWPORTS;
|
|
10
15
|
/** 화면 하나를 기다리는 최대 시간. 넘으면 그때 모습으로 기록한다 */
|
|
11
16
|
export declare const SCREEN_WAIT_MS = 8000;
|
|
@@ -25,6 +30,14 @@ export interface ScreenResult {
|
|
|
25
30
|
/** 콘텐츠 · 흉내 API의 4xx · 5xx "상태 경로" */
|
|
26
31
|
failedRequests: string[];
|
|
27
32
|
overflowX: boolean;
|
|
33
|
+
/** --theme로 찍은 테마 (없으면 프로젝트 그대로) */
|
|
34
|
+
theme?: CheckTheme;
|
|
35
|
+
/** --step으로 찍은 단계 (1부터). 스테퍼가 없는 화면 · --step 없이는 없음 */
|
|
36
|
+
step?: number;
|
|
37
|
+
/** --step에 적은 단계가 없을 때 (스테퍼 없음 · 단계 수 밖) 그 안내 */
|
|
38
|
+
missingStep?: string;
|
|
39
|
+
/** 키트 스테퍼 · 레이아웃 배치 문제 (layoutProbe). 옛 결과에는 없음 */
|
|
40
|
+
layout?: LayoutFinding[];
|
|
28
41
|
/** 프로젝트 기준 경로 (/ 구분). 찍지 못했으면 null */
|
|
29
42
|
screenshot: string | null;
|
|
30
43
|
ms: number;
|
|
@@ -61,6 +74,19 @@ export type Finding = {
|
|
|
61
74
|
level: 'fail' | 'warn';
|
|
62
75
|
message: string;
|
|
63
76
|
};
|
|
77
|
+
/**
|
|
78
|
+
* 키트 스테퍼 · 레이아웃 배치 문제. id는 화면 검사 규칙 이름(render.*)
|
|
79
|
+
* - render.covered-control (fail): 스테퍼 버튼 가운데 점(elementFromPoint)에 다른 요소가 있음,
|
|
80
|
+
* 키트 제출 바(.ec-submitbar) 버튼이 스테퍼 버튼 줄과 겹침
|
|
81
|
+
* (warn): 칸 안 작성자 조작(버튼 · 입력 · 슬라이더)이 키트 스테퍼 버튼에 깔림 (모바일 아래 줄 등)
|
|
82
|
+
* - render.readout-below · render.controls-below (warn): stage 레이아웃의 실시간 값 · 조작이 첫 화면 밖
|
|
83
|
+
* - render.outside-region (warn): split · stage · media 레이아웃 바로 아래에 영역(data-ec-region) 밖 내용
|
|
84
|
+
*/
|
|
85
|
+
export type LayoutFinding = {
|
|
86
|
+
id: string;
|
|
87
|
+
level: 'fail' | 'warn';
|
|
88
|
+
message: string;
|
|
89
|
+
};
|
|
64
90
|
/** 화면 하나의 문제. fail: 오류 · 막힘 · 빈 화면, warn: 불러오는 중이 남음 · 가로 넘침 */
|
|
65
91
|
export declare function findingsOf(r: ScreenResult): Finding[];
|
|
66
92
|
export declare function statusOf(r: ScreenResult): 'ok' | 'warn' | 'fail';
|
|
@@ -73,6 +99,10 @@ export interface RunCheckOptions {
|
|
|
73
99
|
/** 없으면 defaultScreens */
|
|
74
100
|
screens?: CheckScreen[];
|
|
75
101
|
viewports?: CheckViewport[];
|
|
102
|
+
/** 없으면 프로젝트 테마 그대로 한 번 */
|
|
103
|
+
themes?: CheckTheme[];
|
|
104
|
+
/** 없으면 첫 화면만 */
|
|
105
|
+
steps?: CheckSteps;
|
|
76
106
|
}
|
|
77
107
|
/** 프로젝트에 없는 화면을 고른 경우 (사용법 오류) */
|
|
78
108
|
export declare class ScreenNotFoundError extends Error {
|
package/es/dev/check.js
CHANGED
|
@@ -17,6 +17,8 @@ const CHECK_VIEWPORTS = {
|
|
|
17
17
|
desktop: '100%',
|
|
18
18
|
mobile: '360px'
|
|
19
19
|
};
|
|
20
|
+
/** --theme: 콘텐츠 문서에 EDS 테마(data-eds-theme)를 붙여 찍는다. 없으면 프로젝트 그대로 */
|
|
21
|
+
const CHECK_THEMES = ['light', 'dark'];
|
|
20
22
|
const WINDOW = {
|
|
21
23
|
width: 1280,
|
|
22
24
|
height: 860
|
|
@@ -77,6 +79,16 @@ function findingsOf(r) {
|
|
|
77
79
|
level: 'warn',
|
|
78
80
|
message: '가로로 넘침 (가로 스크롤 생김)'
|
|
79
81
|
});
|
|
82
|
+
if (r.missingStep) out.push({
|
|
83
|
+
level: 'warn',
|
|
84
|
+
message: r.missingStep
|
|
85
|
+
});
|
|
86
|
+
const byId = new Map();
|
|
87
|
+
for (const l of r.layout ?? []) byId.set(l.id, [...(byId.get(l.id) ?? []), l]);
|
|
88
|
+
for (const [id, list] of byId) out.push({
|
|
89
|
+
level: list.some(l => l.level === 'fail') ? 'fail' : 'warn',
|
|
90
|
+
message: list.length > 1 ? `${id} ${list.length}개` : id
|
|
91
|
+
});
|
|
80
92
|
return out;
|
|
81
93
|
}
|
|
82
94
|
function statusOf(r) {
|
|
@@ -97,7 +109,7 @@ function formatText(report) {
|
|
|
97
109
|
for (const r of report.screens) {
|
|
98
110
|
const findings = findingsOf(r).map(f => f.message);
|
|
99
111
|
const shot = r.screenshot ? `화면 그림 ${r.screenshot}` : '화면 그림 없음';
|
|
100
|
-
lines.push(`[${statusOf(r)}] ${r.screen
|
|
112
|
+
lines.push(`[${statusOf(r)}] ${[r.screen, r.viewport, r.theme, r.step === undefined ? undefined : `단계 ${r.step}`].filter(Boolean).join(' · ')} ${r.width}px ${[...findings, shot].join(' · ')}`);
|
|
101
113
|
const detail = (label, items) => {
|
|
102
114
|
for (const item of items.slice(0, DETAIL_LIMIT)) lines.push(` ${label}: ${item.split('\n')[0]}`);
|
|
103
115
|
if (items.length > DETAIL_LIMIT) lines.push(` … ${label} 외 ${items.length - DETAIL_LIMIT}개`);
|
|
@@ -106,6 +118,7 @@ function formatText(report) {
|
|
|
106
118
|
detail('콘솔 오류', r.consoleErrors);
|
|
107
119
|
detail('막힌 외부 요청', r.blocked);
|
|
108
120
|
detail('실패한 요청', r.failedRequests);
|
|
121
|
+
detail('배치', (r.layout ?? []).map(l => `${l.id} ${l.message}`));
|
|
109
122
|
}
|
|
110
123
|
const bad = report.screens.filter(r => statusOf(r) !== 'ok').length;
|
|
111
124
|
lines.push('', `${report.ok ? '[ok]' : '[fail]'} 화면 ${report.screens.length}개 중 문제 ${bad}개${v.errors ? ` · 검사 오류 ${v.errors}` : ''} (${(report.durationMs / 1000).toFixed(1)}초)`, `화면 그림: ${report.screenshotsDir}`);
|
|
@@ -139,6 +152,115 @@ function probe() {
|
|
|
139
152
|
width: window.innerWidth
|
|
140
153
|
};
|
|
141
154
|
}
|
|
155
|
+
/**
|
|
156
|
+
* 키트 스테퍼 · 레이아웃 배치 (브라우저 안에서 돈다). 첫 화면(스크롤 0) 그대로 본다.
|
|
157
|
+
* 스테퍼 버튼은 <ec-stepper-nav> Shadow DOM 안(옛 키트는 문서의 .ec-step-nav)이라 그 루트의 elementFromPoint로 맞힌다
|
|
158
|
+
*/
|
|
159
|
+
function layoutProbe() {
|
|
160
|
+
const out = [];
|
|
161
|
+
const vw = window.innerWidth;
|
|
162
|
+
const vh = window.innerHeight;
|
|
163
|
+
const shown = el => el.getClientRects().length > 0;
|
|
164
|
+
const name = el => !el ? '없음' : `<${el.tagName.toLowerCase()}${el.id ? `#${el.id}` : ''}${typeof el.className === 'string' && el.className.trim() ? `.${el.className.trim().split(/\s+/).join('.')}` : ''}>`;
|
|
165
|
+
const buttons = [];
|
|
166
|
+
for (const host of document.querySelectorAll('ec-stepper-nav')) if (host.shadowRoot) for (const b of host.shadowRoot.querySelectorAll('button')) buttons.push([b, host.shadowRoot]);
|
|
167
|
+
for (const b of document.querySelectorAll('.ec-step-nav')) buttons.push([b, document]);
|
|
168
|
+
for (const [b, root] of buttons) {
|
|
169
|
+
const r = b.getBoundingClientRect();
|
|
170
|
+
if (!shown(b) || r.width === 0 || r.height === 0) continue;
|
|
171
|
+
const x = r.left + r.width / 2;
|
|
172
|
+
const y = r.top + r.height / 2;
|
|
173
|
+
// 틀 안에 겹친 옛 방식은 내용이 길면 첫 화면 밖에 있을 수 있다 (가려진 것과 다름)
|
|
174
|
+
if (x < 0 || y < 0 || x >= vw || y >= vh) continue;
|
|
175
|
+
const hit = root.elementFromPoint(x, y);
|
|
176
|
+
if (hit && (hit === b || b.contains(hit))) continue;
|
|
177
|
+
out.push({
|
|
178
|
+
id: 'render.covered-control',
|
|
179
|
+
level: 'fail',
|
|
180
|
+
message: `스테퍼 버튼 "${b.getAttribute('aria-label') ?? b.textContent ?? ''}"을 ${name(hit)}이 덮음 (${Math.round(x)}, ${Math.round(y)})`
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
// 작성자 조작(칸 안 버튼 · 입력 · 슬라이더)이 키트 스테퍼 버튼 · n / N 밑에 깔림 (모바일 화면 아래 줄 등).
|
|
184
|
+
// 둥근 버튼은 모서리가 비어 한 점 맞히기로는 놓치므로 상자끼리 겹침(2px 넘게)으로 본다
|
|
185
|
+
const navBoxes = [...document.querySelectorAll('ec-stepper-nav')].flatMap(host => [...(host.shadowRoot?.querySelectorAll('button, .count') ?? [])].filter(el => shown(el)).map(el => el.getBoundingClientRect()).filter(r => r.width > 0 && r.height > 0));
|
|
186
|
+
const CONTROLS = 'button, input:not([type="hidden"]), select, textarea, a[href], [role="button"], [role="slider"]';
|
|
187
|
+
const overlapsNav = r => navBoxes.find(n => Math.min(n.right, r.right) - Math.max(n.left, r.left) > 2 && Math.min(n.bottom, r.bottom) - Math.max(n.top, r.top) > 2);
|
|
188
|
+
// 키트 제출 · 저장 바의 버튼(.ec-submitbar)이 스테퍼 버튼 줄 밑에 깔림: 바는 화면 아래에 붙어(sticky) 스크롤해도
|
|
189
|
+
// 빠져나오지 못하므로 fail. 키트는 스테퍼가 있으면 모바일에서 바를 줄 위로 올린다 (작성자 CSS가 되돌렸을 때 등)
|
|
190
|
+
if (navBoxes.length) for (const button of document.querySelectorAll('.ec-submitbar button')) {
|
|
191
|
+
if (!shown(button)) continue;
|
|
192
|
+
const r = button.getBoundingClientRect();
|
|
193
|
+
if (r.width === 0 || r.height === 0 || r.bottom <= 0 || r.top >= vh) continue;
|
|
194
|
+
const nav = overlapsNav(r);
|
|
195
|
+
if (!nav) continue;
|
|
196
|
+
out.push({
|
|
197
|
+
id: 'render.covered-control',
|
|
198
|
+
level: 'fail',
|
|
199
|
+
message: `제출 바 버튼 "${button.textContent?.trim().slice(0, 20) ?? ''}"이 키트 스테퍼 버튼 줄에 깔림 (${Math.round(nav.left)}, ${Math.round(nav.top)}): .ec-submitbar의 bottom · padding을 바꾸지 마세요`
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (navBoxes.length) for (const control of document.querySelectorAll(`[data-ec-region] :is(${CONTROLS})`)) {
|
|
203
|
+
if (!shown(control)) continue;
|
|
204
|
+
const r = control.getBoundingClientRect();
|
|
205
|
+
if (r.width === 0 || r.height === 0 || r.bottom <= 0 || r.top >= vh) continue;
|
|
206
|
+
const nav = overlapsNav(r);
|
|
207
|
+
if (!nav) continue;
|
|
208
|
+
const label = control.textContent?.trim().slice(0, 20);
|
|
209
|
+
out.push({
|
|
210
|
+
id: 'render.covered-control',
|
|
211
|
+
level: 'warn',
|
|
212
|
+
message: `${name(control)}${label ? ` "${label}"` : ''}이 키트 스테퍼 버튼 줄과 겹침 (${Math.round(nav.left)}, ${Math.round(nav.top)}): 첫 화면 아래쪽 조작은 무대를 줄이거나 --ec-nav-reserve-mobile만큼 띄워 주세요`
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
for (const layout of document.querySelectorAll('[data-ec-layout]')) {
|
|
216
|
+
if (!shown(layout)) continue;
|
|
217
|
+
const kind = layout.getAttribute('data-ec-layout');
|
|
218
|
+
if (kind === 'stage') for (const [region, id, label] of [['readout', 'render.readout-below', '실시간 값(readout)'], ['controls', 'render.controls-below', '조작(controls)']]) {
|
|
219
|
+
const el = layout.querySelector(`:scope > [data-ec-region="${region}"]`);
|
|
220
|
+
if (!el || !shown(el)) continue;
|
|
221
|
+
const r = el.getBoundingClientRect();
|
|
222
|
+
if (r.top >= 0 && r.bottom <= vh + 1) continue;
|
|
223
|
+
out.push({
|
|
224
|
+
id,
|
|
225
|
+
level: 'warn',
|
|
226
|
+
message: `stage 레이아웃의 ${label}이 첫 화면 밖 (아래 끝 ${Math.round(r.bottom)}px, 화면 높이 ${vh}px)`
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
// 실시간 값이 무대 그림을 덮는지: 무대 안 그림 요소(canvas · img · video · svg와 그 도형 · 글이 있는 끝 요소)와 겹치면
|
|
230
|
+
if (kind === 'stage') {
|
|
231
|
+
const readout = layout.querySelector(':scope > [data-ec-region="readout"]');
|
|
232
|
+
const stage = layout.querySelector(':scope > [data-ec-region="stage"]');
|
|
233
|
+
if (readout && stage && shown(readout)) {
|
|
234
|
+
const ro = readout.getBoundingClientRect();
|
|
235
|
+
const DRAWN = 'canvas, img, video, svg, circle, ellipse, line, path, polygon, polyline, rect, text, image, use';
|
|
236
|
+
const hit = [...stage.querySelectorAll(DRAWN), ...stage.querySelectorAll('*')].find(el => {
|
|
237
|
+
if (!shown(el)) return false;
|
|
238
|
+
const isDrawn = el.matches(DRAWN);
|
|
239
|
+
const isTextLeaf = !isDrawn && el.children.length === 0 && (el.textContent ?? '').trim() !== '';
|
|
240
|
+
if (!isDrawn && !isTextLeaf) return false;
|
|
241
|
+
const r = el.getBoundingClientRect();
|
|
242
|
+
if (r.width === 0 || r.height === 0) return false;
|
|
243
|
+
const w = Math.min(r.right, ro.right) - Math.max(r.left, ro.left);
|
|
244
|
+
const hgt = Math.min(r.bottom, ro.bottom) - Math.max(r.top, ro.top);
|
|
245
|
+
return w > 1 && hgt > 1;
|
|
246
|
+
});
|
|
247
|
+
if (hit) out.push({
|
|
248
|
+
id: 'render.readout-covers',
|
|
249
|
+
level: 'warn',
|
|
250
|
+
message: `stage 레이아웃의 실시간 값(readout)이 무대 그림 ${name(hit)}을 덮음: 무대 바로 아래 그림은 키트가 위쪽 띠(--ec-readout-safe)를 비워 두니 그림을 직접 position: absolute로 칸 전체에 붙이지 마세요`
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
if (kind === 'single') continue;
|
|
255
|
+
const loose = [...layout.children].filter(c => !c.hasAttribute('data-ec-region') && !/^(H[1-3]|SCRIPT|STYLE|TEMPLATE)$/.test(c.tagName) && shown(c));
|
|
256
|
+
if (loose.length) out.push({
|
|
257
|
+
id: 'render.outside-region',
|
|
258
|
+
level: 'warn',
|
|
259
|
+
message: `${kind} 레이아웃 바로 아래에 영역 밖 내용 ${loose.length}개 (${name(loose[0] ?? null)}): data-ec-region 칸 안에 넣어 주세요`
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
return out;
|
|
263
|
+
}
|
|
142
264
|
const wait = ms => new Promise(r => setTimeout(r, ms));
|
|
143
265
|
async function checkScreen(page, o) {
|
|
144
266
|
const started = Date.now();
|
|
@@ -186,37 +308,102 @@ async function checkScreen(page, o) {
|
|
|
186
308
|
}
|
|
187
309
|
await wait(SETTLE_MS);
|
|
188
310
|
state = (await read()) ?? state;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
311
|
+
const frameEval = async (fn, arg) => {
|
|
312
|
+
const frame = contentFrame();
|
|
313
|
+
if (!frame) return null;
|
|
314
|
+
try {
|
|
315
|
+
return (await frame.evaluate(fn, arg)) ?? null;
|
|
316
|
+
} catch {
|
|
317
|
+
return null; // 다시 띄우는 중
|
|
318
|
+
}
|
|
319
|
+
};
|
|
320
|
+
// --theme: 키트 · EDS 색은 <html data-eds-theme="dark">로 바뀐다 (light는 속성을 뗀다)
|
|
321
|
+
if (o.theme) {
|
|
322
|
+
await frameEval(theme => {
|
|
323
|
+
if (theme === 'dark') document.documentElement.setAttribute('data-eds-theme', 'dark');else document.documentElement.removeAttribute('data-eds-theme');
|
|
324
|
+
}, o.theme);
|
|
325
|
+
await wait(150);
|
|
326
|
+
state = (await read()) ?? state;
|
|
199
327
|
}
|
|
200
328
|
let blocked = [];
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
screenshot
|
|
218
|
-
|
|
329
|
+
const readBlocked = async () => {
|
|
330
|
+
try {
|
|
331
|
+
blocked = await page.evaluate(() => (window.__ECDK_HOST__?.blocked ?? []).map(b => `${b.blockedURI} (${b.violatedDirective})`));
|
|
332
|
+
} catch {
|
|
333
|
+
// 화면이 닫혔으면 빈 목록
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
// 단계마다 그때까지 새로 난 오류만 그 단계 결과에
|
|
337
|
+
const seen = {
|
|
338
|
+
console: 0,
|
|
339
|
+
page: 0,
|
|
340
|
+
failed: 0
|
|
341
|
+
};
|
|
342
|
+
const capture = async (step, missingStep) => {
|
|
343
|
+
const layout = (await frameEval(layoutProbe)) ?? [];
|
|
344
|
+
const name = [o.screen, o.viewport, o.theme, step === undefined ? undefined : `step${step}`].filter(Boolean).join('-');
|
|
345
|
+
let screenshot = null;
|
|
346
|
+
const file = join(o.shotDir, `${name}.png`);
|
|
347
|
+
try {
|
|
348
|
+
await page.locator('#content').screenshot({
|
|
349
|
+
path: file,
|
|
350
|
+
timeout: 5000
|
|
351
|
+
});
|
|
352
|
+
screenshot = relative(o.dir, file).split(sep).join('/');
|
|
353
|
+
} catch {
|
|
354
|
+
// 그림 없이 결과만
|
|
355
|
+
}
|
|
356
|
+
await readBlocked();
|
|
357
|
+
const fresh = (list, key) => {
|
|
358
|
+
const out = [...new Set(list.slice(seen[key]))];
|
|
359
|
+
seen[key] = list.length;
|
|
360
|
+
return out;
|
|
361
|
+
};
|
|
362
|
+
return {
|
|
363
|
+
screen: o.screen,
|
|
364
|
+
viewport: o.viewport,
|
|
365
|
+
...(o.theme ? {
|
|
366
|
+
theme: o.theme
|
|
367
|
+
} : {}),
|
|
368
|
+
...(step === undefined ? {} : {
|
|
369
|
+
step
|
|
370
|
+
}),
|
|
371
|
+
...(missingStep ? {
|
|
372
|
+
missingStep
|
|
373
|
+
} : {}),
|
|
374
|
+
width: state?.width ?? 0,
|
|
375
|
+
rendered: !!state && (state.text > 0 || state.media) && !state.loading,
|
|
376
|
+
loading: state?.loading ?? null,
|
|
377
|
+
consoleErrors: fresh(consoleErrors, 'console'),
|
|
378
|
+
pageErrors: fresh(pageErrors, 'page'),
|
|
379
|
+
blocked,
|
|
380
|
+
failedRequests: fresh(failedRequests, 'failed'),
|
|
381
|
+
overflowX: state?.overflowX ?? false,
|
|
382
|
+
layout,
|
|
383
|
+
screenshot,
|
|
384
|
+
ms: Date.now() - started
|
|
385
|
+
};
|
|
219
386
|
};
|
|
387
|
+
if (!o.steps) return [await capture()];
|
|
388
|
+
// --step: 키트 스테퍼(<ec-stepper-nav>의 ecStepper 손잡이)로 단계를 바꿔 찍는다. canNext와 상관없이 그 단계로 간다
|
|
389
|
+
const count = (await frameEval(() => document.querySelector('ec-stepper-nav')?.ecStepper?.count ?? 0)) ?? 0;
|
|
390
|
+
// 스테퍼가 없는 화면(편집 화면 등): all이면 그대로 한 번, 단계 번호를 적었으면 알린다
|
|
391
|
+
if (count === 0) return [await capture(undefined, o.steps === 'all' ? undefined : '스테퍼가 없는 화면이라 단계별로 찍지 않음 (--step)')];
|
|
392
|
+
const wanted = o.steps === 'all' ? Array.from({
|
|
393
|
+
length: count
|
|
394
|
+
}, (_, i) => i + 1) : o.steps;
|
|
395
|
+
const results = [];
|
|
396
|
+
for (const step of wanted) {
|
|
397
|
+
if (step > count) {
|
|
398
|
+
results.push(await capture(undefined, `단계 ${step}이 없음 (이 화면은 ${count}단계)`));
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
await frameEval(i => document.querySelector('ec-stepper-nav').ecStepper.go(i), step - 1);
|
|
402
|
+
await wait(SETTLE_MS);
|
|
403
|
+
state = (await read()) ?? state;
|
|
404
|
+
results.push(await capture(step));
|
|
405
|
+
}
|
|
406
|
+
return results;
|
|
220
407
|
}
|
|
221
408
|
/** 프로젝트에 없는 화면을 고른 경우 (사용법 오류) */
|
|
222
409
|
class ScreenNotFoundError extends Error {}
|
|
@@ -265,10 +452,12 @@ async function runCheck(opts) {
|
|
|
265
452
|
recursive: true
|
|
266
453
|
});
|
|
267
454
|
const contentOrigin = new URL(server.contentUrl).origin;
|
|
268
|
-
const
|
|
455
|
+
const themes = opts.themes ?? [undefined];
|
|
456
|
+
const jobs = screens.flatMap(screen => viewports.flatMap(viewport => themes.map(theme => ({
|
|
269
457
|
screen,
|
|
270
|
-
viewport
|
|
271
|
-
|
|
458
|
+
viewport,
|
|
459
|
+
theme
|
|
460
|
+
}))));
|
|
272
461
|
const results = new Array(jobs.length);
|
|
273
462
|
let next = 0;
|
|
274
463
|
await Promise.all(Array.from({
|
|
@@ -282,6 +471,7 @@ async function runCheck(opts) {
|
|
|
282
471
|
hostUrl: server.hostUrl,
|
|
283
472
|
contentOrigin,
|
|
284
473
|
...jobs[i],
|
|
474
|
+
steps: opts.steps,
|
|
285
475
|
dir,
|
|
286
476
|
shotDir
|
|
287
477
|
});
|
|
@@ -309,7 +499,7 @@ async function runCheck(opts) {
|
|
|
309
499
|
browser: launched.name,
|
|
310
500
|
durationMs: 0,
|
|
311
501
|
screenshotsDir: shotDir,
|
|
312
|
-
screens: results,
|
|
502
|
+
screens: results.flat(),
|
|
313
503
|
validate,
|
|
314
504
|
notes
|
|
315
505
|
};
|
|
@@ -323,4 +513,4 @@ async function runCheck(opts) {
|
|
|
323
513
|
}
|
|
324
514
|
}
|
|
325
515
|
|
|
326
|
-
export { CHECK_SCREENS, CHECK_VIEWPORTS, SCREEN_WAIT_MS, ScreenNotFoundError, defaultScreens, exitCodeOf, findingsOf, formatText, parseList, runCheck, statusOf };
|
|
516
|
+
export { CHECK_SCREENS, CHECK_THEMES, CHECK_VIEWPORTS, SCREEN_WAIT_MS, ScreenNotFoundError, defaultScreens, exitCodeOf, findingsOf, formatText, parseList, runCheck, statusOf };
|