pubuilder 0.3.0 → 0.5.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.
- package/README.md +26 -3
- package/dist/api.d.ts +47 -0
- package/dist/cli.js +729 -225
- package/dist/components/PageMap.d.ts +4 -2
- package/dist/components/PublishPanel.d.ts +1 -0
- package/dist/components/SkillDrawer.d.ts +1 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +58 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +802 -413
- package/dist/index.js.map +1 -1
- package/dist/inspector/inspector.d.ts +1 -1
- package/dist/server/agent.d.ts +7 -3
- package/dist/server/errors.d.ts +2 -2
- package/dist/server/http.d.ts +15 -0
- package/dist/store.d.ts +5 -1
- package/package.json +5 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IAConfig } from '../types';
|
|
1
|
+
import type { IAConfig } from '../types.js';
|
|
2
2
|
export interface PageMapProps {
|
|
3
3
|
config: IAConfig;
|
|
4
4
|
/**
|
|
@@ -6,5 +6,7 @@ export interface PageMapProps {
|
|
|
6
6
|
* 자동으로 렌더하지 않는다 (dev 전용 안전장치).
|
|
7
7
|
*/
|
|
8
8
|
enabled?: boolean;
|
|
9
|
+
/** 컴패니언 서버 URL. 기본 http://localhost:4816 */
|
|
10
|
+
serverUrl?: string;
|
|
9
11
|
}
|
|
10
|
-
export declare function PageMap({ config, enabled }: PageMapProps): import("react").ReactPortal | null;
|
|
12
|
+
export declare function PageMap({ config, enabled, serverUrl }: PageMapProps): import("react").ReactPortal | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PublishPanel(): import("react").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SkillDrawer(): import("react").JSX.Element;
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
function w(r) {
|
|
2
|
+
return r;
|
|
3
|
+
}
|
|
4
|
+
const d = { width: 1440, height: 900 };
|
|
5
|
+
function u(r, a, e) {
|
|
6
|
+
e != null && r.append(a, String(e));
|
|
7
|
+
}
|
|
8
|
+
function f(r, a) {
|
|
9
|
+
const e = r.indexOf("#"), p = e >= 0 ? r.slice(e) : "", i = e >= 0 ? r.slice(0, e) : r, o = i.indexOf("?"), s = o >= 0 ? i.slice(0, o) : i, t = new URLSearchParams(o >= 0 ? i.slice(o + 1) : "");
|
|
10
|
+
for (const [n, l] of Object.entries(a.query))
|
|
11
|
+
if (t.delete(n), Array.isArray(l))
|
|
12
|
+
for (const c of l) u(t, n, c);
|
|
13
|
+
else
|
|
14
|
+
u(t, n, l);
|
|
15
|
+
const h = t.toString();
|
|
16
|
+
return `${s}${h ? `?${h}` : ""}${p}`;
|
|
17
|
+
}
|
|
18
|
+
function g(r) {
|
|
19
|
+
const a = [], e = /* @__PURE__ */ new Set(), p = (i, o, s) => {
|
|
20
|
+
for (const t of i) {
|
|
21
|
+
if (!t.path) throw new Error("[pubuilder] page.path는 필수입니다");
|
|
22
|
+
if (!t.title) throw new Error(`[pubuilder] "${t.path}"의 title이 없습니다`);
|
|
23
|
+
if (e.has(t.path)) throw new Error(`[pubuilder] 중복 path: ${t.path}`);
|
|
24
|
+
if (e.add(t.path), a.push({
|
|
25
|
+
id: t.path,
|
|
26
|
+
path: t.path,
|
|
27
|
+
title: t.title,
|
|
28
|
+
external: t.external ?? /^https?:\/\//.test(t.path),
|
|
29
|
+
parentId: o,
|
|
30
|
+
depth: s
|
|
31
|
+
}), t.variants?.length) {
|
|
32
|
+
if (t.external ?? /^https?:\/\//.test(t.path))
|
|
33
|
+
throw new Error(`[pubuilder] 외부 페이지에는 variants를 사용할 수 없습니다: ${t.path}`);
|
|
34
|
+
for (const h of t.variants) {
|
|
35
|
+
if (!h.title) throw new Error(`[pubuilder] "${t.path}" variant의 title이 없습니다`);
|
|
36
|
+
const n = f(t.path, h);
|
|
37
|
+
if (e.has(n)) throw new Error(`[pubuilder] 중복 path: ${n}`);
|
|
38
|
+
e.add(n), a.push({
|
|
39
|
+
id: n,
|
|
40
|
+
path: n,
|
|
41
|
+
title: h.title,
|
|
42
|
+
external: !1,
|
|
43
|
+
parentId: t.path,
|
|
44
|
+
depth: s + 1
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
t.children?.length && p(t.children, t.path, s + 1);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
if (p(r.pages, null, 0), a.length === 0) throw new Error("[pubuilder] pages가 비어 있습니다");
|
|
52
|
+
return { nodes: a, viewport: r.viewport ?? d };
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
w as defineIA,
|
|
56
|
+
g as normalizeIA
|
|
57
|
+
};
|
|
58
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../src/config.ts"],"sourcesContent":["import type { IAConfig, IANode, IAPage, IAPageVariant, IAQueryValue } from './types.js'\n\n/** ia.config.ts 작성용 헬퍼 — 타입 추론만 제공 */\nexport function defineIA(config: IAConfig): IAConfig {\n return config\n}\n\nexport interface NormalizedIA {\n nodes: IANode[]\n viewport: { width: number; height: number }\n}\n\nconst DEFAULT_VIEWPORT = { width: 1440, height: 900 }\n\nfunction appendQueryValue(params: URLSearchParams, key: string, value: IAQueryValue) {\n if (value == null) return\n params.append(key, String(value))\n}\n\n/** 기존 query/hash를 보존하면서 variant query를 추가한다. */\nfunction variantPath(path: string, variant: IAPageVariant): string {\n const hashIndex = path.indexOf('#')\n const hash = hashIndex >= 0 ? path.slice(hashIndex) : ''\n const pathAndSearch = hashIndex >= 0 ? path.slice(0, hashIndex) : path\n const queryIndex = pathAndSearch.indexOf('?')\n const pathname = queryIndex >= 0 ? pathAndSearch.slice(0, queryIndex) : pathAndSearch\n const params = new URLSearchParams(queryIndex >= 0 ? pathAndSearch.slice(queryIndex + 1) : '')\n\n for (const [key, value] of Object.entries(variant.query)) {\n // variant에 선언한 key는 base path의 같은 query를 대체한다.\n params.delete(key)\n if (Array.isArray(value)) {\n for (const item of value) appendQueryValue(params, key, item)\n } else {\n appendQueryValue(params, key, value as IAQueryValue)\n }\n }\n\n const search = params.toString()\n return `${pathname}${search ? `?${search}` : ''}${hash}`\n}\n\n/** IAConfig 트리를 검증하고 평탄화한다 */\nexport function normalizeIA(config: IAConfig): NormalizedIA {\n const nodes: IANode[] = []\n const seen = new Set<string>()\n\n const walk = (pages: IAPage[], parentId: string | null, depth: number) => {\n for (const page of pages) {\n if (!page.path) throw new Error('[pubuilder] page.path는 필수입니다')\n if (!page.title) throw new Error(`[pubuilder] \"${page.path}\"의 title이 없습니다`)\n if (seen.has(page.path)) throw new Error(`[pubuilder] 중복 path: ${page.path}`)\n seen.add(page.path)\n nodes.push({\n id: page.path,\n path: page.path,\n title: page.title,\n external: page.external ?? /^https?:\\/\\//.test(page.path),\n parentId,\n depth,\n })\n if (page.variants?.length) {\n if (page.external ?? /^https?:\\/\\//.test(page.path)) {\n throw new Error(`[pubuilder] 외부 페이지에는 variants를 사용할 수 없습니다: ${page.path}`)\n }\n for (const variant of page.variants) {\n if (!variant.title) throw new Error(`[pubuilder] \"${page.path}\" variant의 title이 없습니다`)\n const path = variantPath(page.path, variant)\n if (seen.has(path)) throw new Error(`[pubuilder] 중복 path: ${path}`)\n seen.add(path)\n nodes.push({\n id: path,\n path,\n title: variant.title,\n external: false,\n parentId: page.path,\n depth: depth + 1,\n })\n }\n }\n if (page.children?.length) walk(page.children, page.path, depth + 1)\n }\n }\n walk(config.pages, null, 0)\n\n if (nodes.length === 0) throw new Error('[pubuilder] pages가 비어 있습니다')\n return { nodes, viewport: config.viewport ?? DEFAULT_VIEWPORT }\n}\n"],"names":["defineIA","config","DEFAULT_VIEWPORT","appendQueryValue","params","key","value","variantPath","path","variant","hashIndex","hash","pathAndSearch","queryIndex","pathname","item","search","normalizeIA","nodes","seen","walk","pages","parentId","dep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
-
export { PageMap, type PageMapProps } from './components/PageMap';
|
|
2
|
-
export { defineIA, normalizeIA, type NormalizedIA } from './config';
|
|
3
|
-
export type { BlockSelection, Granularity, IAConfig, IANode, IAPage, } from './types';
|
|
1
|
+
export { PageMap, type PageMapProps } from './components/PageMap.js';
|
|
2
|
+
export { defineIA, normalizeIA, type NormalizedIA } from './config.js';
|
|
3
|
+
export type { BlockSelection, Granularity, IAConfig, IANode, IAPage, } from './types.js';
|