@jogak/core 0.1.0-alpha.6 → 0.1.0-alpha.7.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/dist/config.d.ts +45 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +42 -38
- package/dist/types.d.ts +35 -0
- package/dist/vite/index.js +9 -8
- package/dist/vite/index.mjs +164 -163
- package/package.json +1 -1
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { JogakPluginOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* `jogak.config.{ts,mts,mjs,js,json}`의 default export 타입.
|
|
4
|
+
*
|
|
5
|
+
* `JogakPluginOptions`의 모든 필드 + 사용자가 자주 변경하는 dev/build 옵션을
|
|
6
|
+
* 통합한다. 모든 필드 optional — 미지정 시 jogak 기본값 또는 CLI 플래그가 적용.
|
|
7
|
+
*
|
|
8
|
+
* **CLI 플래그 우선순위**: CLI 플래그가 본 config의 값을 override한다 (Vite 패턴).
|
|
9
|
+
* 예: `jogak.config.ts`에 `port: 3000`, CLI에 `--port 4000` → 4000 적용.
|
|
10
|
+
*
|
|
11
|
+
* 미노출 필드(예: `cwd`, `framework`, `disableCacheValidation`, `noGenerate`,
|
|
12
|
+
* `emitRegistry`)는 CLI 플래그 전용 또는 자동 감지로만 처리 — 사용자가 config
|
|
13
|
+
* 파일에서 자주 만지지 않는 옵션이라 표면을 줄였다.
|
|
14
|
+
*/
|
|
15
|
+
export interface JogakConfig extends JogakPluginOptions {
|
|
16
|
+
/** dev server 포트. 기본 5173. CLI `--port`로 override. */
|
|
17
|
+
readonly port?: number;
|
|
18
|
+
/** dev server bind host. 기본 'localhost'. CLI `--host`로 override. */
|
|
19
|
+
readonly host?: string | boolean;
|
|
20
|
+
/** dev 시작 시 브라우저 자동 오픈. 기본 false. CLI `--open`로 override. */
|
|
21
|
+
readonly open?: boolean | string;
|
|
22
|
+
/** 정적 빌드 출력 디렉토리. 기본 'jogak-static'. CLI `--out-dir`로 override. */
|
|
23
|
+
readonly outDir?: string;
|
|
24
|
+
/** 정적 빌드 base public path. 기본 './'. CLI `--base`로 override. */
|
|
25
|
+
readonly base?: string;
|
|
26
|
+
/** 빌드 minify 모드. 기본 'esbuild'. CLI `--minify`로 override. */
|
|
27
|
+
readonly minify?: boolean | 'esbuild' | 'terser';
|
|
28
|
+
/** 빌드 소스맵. 기본 false. CLI `--sourcemap`로 override. */
|
|
29
|
+
readonly sourcemap?: boolean;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* `jogak.config.ts`에서 사용자가 호출하는 identity helper.
|
|
33
|
+
*
|
|
34
|
+
* TypeScript 타입 추론을 위해서만 존재 — 런타임에는 입력 그대로 반환.
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* import { defineJogakConfig } from '@jogak/core'
|
|
38
|
+
*
|
|
39
|
+
* export default defineJogakConfig({
|
|
40
|
+
* globalCss: true,
|
|
41
|
+
* previewIsolation: 'none',
|
|
42
|
+
* port: 3000,
|
|
43
|
+
* })
|
|
44
|
+
*/
|
|
45
|
+
export declare function defineJogakConfig<T extends JogakConfig>(config: T): T;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { ArgType, JogakMeta, Jogak, RegistryEntry, RegistryEntryMeta, CategoryTree, CategoryMetaTree, JogakAdapter, JogakPluginOptions, } from './types.js';
|
|
2
2
|
export { ComponentRegistry, defaultRegistry, UnknownEntryError } from './registry.js';
|
|
3
3
|
export { ActionChannel, defaultActionChannel, action, injectActions, type ActionLog, type ActionListener, } from './actions.js';
|
|
4
|
+
export { defineJogakConfig, type JogakConfig } from './config.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var V=Object.defineProperty;var U=i=>{throw TypeError(i)};var G=(i,t,e)=>t in i?V(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var I=(i,t,e)=>G(i,typeof t!="symbol"?t+"":t,e),z=(i,t,e)=>t.has(i)||U("Cannot "+e);var s=(i,t,e)=>(z(i,t,"read from private field"),e?e.call(i):t.get(i)),
|
|
1
|
+
"use strict";var V=Object.defineProperty;var U=i=>{throw TypeError(i)};var G=(i,t,e)=>t in i?V(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var I=(i,t,e)=>G(i,typeof t!="symbol"?t+"":t,e),z=(i,t,e)=>t.has(i)||U("Cannot "+e);var s=(i,t,e)=>(z(i,t,"read from private field"),e?e.call(i):t.get(i)),u=(i,t,e)=>t.has(i)?U("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(i):t.set(i,e),d=(i,t,e,n)=>(z(i,t,"write to private field"),n?n.call(i,e):t.set(i,e),e),f=(i,t,e)=>(z(i,t,"access private method"),e);var J=(i,t,e,n)=>({set _(r){d(i,t,r,e)},get _(){return s(i,t,n)}});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class F extends Error{constructor(e){super(`[jogak] Unknown entry id: ${e}`);I(this,"id");this.name="UnknownEntryError",this.id=e}}var a,C,b,v,k,E,w,j,A,T,l,m,M,q;class ${constructor(){u(this,l);u(this,a,new Map);u(this,C);u(this,b,new Set);u(this,v);u(this,k);u(this,E);u(this,w);u(this,j);u(this,A,!1);u(this,T,!1)}register(t){const e=H(t);f(this,l,q).call(this,()=>{this.registerMeta(e),this.hydrateEntry(t.id,t.jogaks,t.meta.component)})}unregister(t){const e=s(this,a).get(t);e!==void 0&&(e.kind==="pending"&&e.reject(new F(t)),s(this,a).delete(t),f(this,l,m).call(this))}get(t){const e=s(this,a).get(t);return(e==null?void 0:e.kind)==="hydrated"?e.entry:void 0}getAll(){if(s(this,E)!==void 0)return s(this,E);const t=[];for(const n of f(this,l,M).call(this)){const r=s(this,a).get(n);(r==null?void 0:r.kind)==="hydrated"&&t.push(r.entry)}const e=t;return d(this,E,e),e}search(t){const e=t.toLowerCase();return this.getAll().filter(n=>n.title.toLowerCase().includes(e))}getTree(){if(s(this,w)!==void 0)return s(this,w);const t={};for(const e of this.getAll()){const n=e.title.split("/");let r=t;for(let h=0;h<n.length-1;h++){const c=n[h];if(c===void 0)continue;const g=r[c];(g===void 0||"id"in g)&&(r[c]={}),r=r[c]}const o=n[n.length-1];o!==void 0&&(r[o]=e)}return d(this,w,t),t}clear(){if(s(this,a).size!==0){for(const t of s(this,a).values())t.kind==="pending"&&t.reject(new Error("[jogak] registry cleared"));s(this,a).clear(),f(this,l,m).call(this)}}get size(){let t=0;for(const e of s(this,a).values())e.kind==="hydrated"&&t++;return t}registerMeta(t){const e=s(this,a).get(t.id);if(e===void 0){s(this,a).set(t.id,{kind:"meta",meta:t}),f(this,l,m).call(this);return}if(e.kind==="meta"){s(this,a).set(t.id,{kind:"meta",meta:t}),f(this,l,m).call(this);return}if(e.kind==="pending"){s(this,a).set(t.id,{kind:"pending",meta:t,promise:e.promise,resolve:e.resolve,reject:e.reject}),f(this,l,m).call(this);return}const n={...e.entry,title:t.title,filePath:t.filePath,source:t.source,meta:N(t,e.entry.meta.component)};s(this,a).set(t.id,{kind:"hydrated",meta:t,entry:n}),f(this,l,m).call(this)}hydrateEntry(t,e,n){const r=s(this,a).get(t);let o;r===void 0?(console.warn(`[jogak] hydrateEntry called for unknown id "${t}" — synthesizing minimal meta`),o={id:t,title:t,jogakNames:e.map(c=>c.name),autoArgTypes:{},userArgTypes:{},source:"",filePath:"",metaExtras:{}}):o=r.meta;const h={id:o.id,title:o.title,jogaks:e,meta:N(o,n),...o.filePath?{filePath:o.filePath}:{},...o.source?{source:o.source}:{}};if((r==null?void 0:r.kind)==="pending"){s(this,a).set(t,{kind:"hydrated",meta:o,entry:h}),f(this,l,m).call(this),r.resolve(h);return}s(this,a).set(t,{kind:"hydrated",meta:o,entry:h}),f(this,l,m).call(this)}invalidateEntry(t){const e=s(this,a).get(t);e===void 0||e.kind!=="hydrated"||(s(this,a).set(t,{kind:"meta",meta:e.meta}),f(this,l,m).call(this))}requestEntry(t){const e=s(this,a).get(t);if(e===void 0)return Promise.reject(new F(t));if(e.kind==="hydrated")return Promise.resolve(e.entry);if(e.kind==="pending")return e.promise;const n=s(this,C);if(n===void 0)return Promise.reject(new Error("[jogak] entry loader not set — virtual:jogak index module did not load"));let r,o;const h=new Promise((c,g)=>{r=c,o=g});return s(this,a).set(t,{kind:"pending",meta:e.meta,promise:h,resolve:r,reject:o}),n(t).then(()=>{const c=s(this,a).get(t);(c==null?void 0:c.kind)!=="hydrated"&&o(new Error(`[jogak] entry module loaded but did not hydrate: ${t}`))},c=>{const g=c instanceof Error?c:new Error(String(c)),p=s(this,a).get(t);(p==null?void 0:p.kind)==="pending"&&p.promise===h&&s(this,a).set(t,{kind:"meta",meta:e.meta}),o(g)}),h}getAllMeta(){if(s(this,v)!==void 0)return s(this,v);const t=[];for(const n of f(this,l,M).call(this)){const r=s(this,a).get(n);r!==void 0&&t.push(r.meta)}const e=t;return d(this,v,e),e}getMetaTree(){if(s(this,k)!==void 0)return s(this,k);const t={};for(const e of f(this,l,M).call(this)){const n=s(this,a).get(e);if(n===void 0)continue;const r=n.meta,o=r.title.split("/");let h=t;for(let g=0;g<o.length-1;g++){const p=o[g];if(p===void 0)continue;const R=h[p];(R===void 0||"id"in R)&&(h[p]={}),h=h[p]}const c=o[o.length-1];c!==void 0&&(h[c]=r)}return d(this,k,t),t}getEntryState(t){const e=s(this,a).get(t);return e===void 0?"unknown":e.kind}setEntryLoader(t){d(this,C,t)}subscribe(t){s(this,b).add(t);let e=!0;return()=>{e&&(e=!1,s(this,b).delete(t))}}}a=new WeakMap,C=new WeakMap,b=new WeakMap,v=new WeakMap,k=new WeakMap,E=new WeakMap,w=new WeakMap,j=new WeakMap,A=new WeakMap,T=new WeakMap,l=new WeakSet,m=function(){if(d(this,v,void 0),d(this,k,void 0),d(this,E,void 0),d(this,w,void 0),d(this,j,void 0),s(this,A)){d(this,T,!0);return}const t=Array.from(s(this,b));for(const e of t)try{e()}catch(n){console.error("[jogak] subscribe listener threw:",n)}},M=function(){if(s(this,j)!==void 0)return s(this,j);const t=[];for(const[n,r]of s(this,a))t.push({id:n,title:r.meta.title});t.sort(K);const e=t.map(n=>n.id);return d(this,j,e),e},q=function(t){if(s(this,A)){t();return}d(this,A,!0),d(this,T,!1);try{t()}finally{d(this,A,!1),s(this,T)&&(d(this,T,!1),f(this,l,m).call(this))}};function H(i){const t=i.meta.argTypes??{};return{id:i.id,title:i.title,jogakNames:i.jogaks.map(e=>e.name),autoArgTypes:{},userArgTypes:t,source:i.source??"",filePath:i.filePath??"",metaExtras:{...i.meta.tags!==void 0?{tags:i.meta.tags}:{},...i.meta.parameters!==void 0?{parameters:i.meta.parameters}:{}}}}function N(i,t){const e={...i.autoArgTypes};for(const n of Object.keys(i.userArgTypes)){const r=i.userArgTypes[n];r!==void 0&&(e[n]={...e[n],...r})}return{title:i.title,component:t,argTypes:e,...i.metaExtras.tags!==void 0?{tags:i.metaExtras.tags}:{},...i.metaExtras.parameters!==void 0?{parameters:i.metaExtras.parameters}:{}}}function K(i,t){const e=i.title.localeCompare(t.title,"en",{sensitivity:"base",numeric:!0});return e!==0?e:i.id.localeCompare(t.id,"en",{sensitivity:"base",numeric:!0})}const Q=new $;var y,P,S,x,L;class D{constructor(){u(this,x);u(this,y,[]);u(this,P,new Set);u(this,S,1)}emit(t,e){const n={id:J(this,S)._++,name:t,args:e,timestamp:Date.now()};d(this,y,[...s(this,y),n]),f(this,x,L).call(this)}subscribe(t){return s(this,P).add(t),t(s(this,y)),()=>{s(this,P).delete(t)}}clear(){s(this,y).length!==0&&(d(this,y,[]),f(this,x,L).call(this))}getLogs(){return s(this,y)}}y=new WeakMap,P=new WeakMap,S=new WeakMap,x=new WeakSet,L=function(){for(const t of s(this,P))t(s(this,y))};const O=new D;function B(i,t=O){return(...e)=>{t.emit(i,e)}}function W(i,t,e=O){const n={...i};for(const r of Object.keys(t)){const o=t[r];if(o===void 0)continue;const h=o.action!==void 0&&o.action!==!1,c=o.type==="function";if(!h&&!c||typeof n[r]=="function")continue;const g=typeof o.action=="string"?o.action:r;n[r]=B(g,e)}return n}function X(i){return i}exports.ActionChannel=D;exports.ComponentRegistry=$;exports.UnknownEntryError=F;exports.action=B;exports.defaultActionChannel=O;exports.defaultRegistry=Q;exports.defineJogakConfig=X;exports.injectActions=W;
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
var
|
|
1
|
+
var J = Object.defineProperty;
|
|
2
2
|
var I = (i) => {
|
|
3
3
|
throw TypeError(i);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var N = (i, t, e) =>
|
|
7
|
-
var s = (i, t, e) => (z(i, t, "read from private field"), e ? e.call(i) : t.get(i)),
|
|
5
|
+
var R = (i, t, e) => t in i ? J(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
6
|
+
var N = (i, t, e) => R(i, typeof t != "symbol" ? t + "" : t, e), z = (i, t, e) => t.has(i) || I("Cannot " + e);
|
|
7
|
+
var s = (i, t, e) => (z(i, t, "read from private field"), e ? e.call(i) : t.get(i)), u = (i, t, e) => t.has(i) ? I("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), c = (i, t, e, n) => (z(i, t, "write to private field"), n ? n.call(i, e) : t.set(i, e), e), f = (i, t, e) => (z(i, t, "access private method"), e);
|
|
8
8
|
var O = (i, t, e, n) => ({
|
|
9
9
|
set _(r) {
|
|
10
10
|
c(i, t, r, e);
|
|
@@ -21,28 +21,28 @@ class U extends Error {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
var a, P, b, v, k, E, w, j, A, T, l, m, C, q;
|
|
24
|
-
class
|
|
24
|
+
class B {
|
|
25
25
|
constructor() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
u(this, l);
|
|
27
|
+
u(this, a, /* @__PURE__ */ new Map());
|
|
28
|
+
u(this, P);
|
|
29
29
|
// ── F2: subscribe + 내부 캐시 ────────────────────────────────────────
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
u(this, b, /* @__PURE__ */ new Set());
|
|
31
|
+
u(this, v);
|
|
32
|
+
u(this, k);
|
|
33
33
|
// 결정성 fix: hydrated entry list / tree 도 캐시. mutation 시 invalidate.
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
u(this, E);
|
|
35
|
+
u(this, w);
|
|
36
36
|
/**
|
|
37
37
|
* 정렬된 id 순서. mutation 시 invalidate, 다음 호출에서 한 번만 재계산.
|
|
38
38
|
* getAll / getTree / getAllMeta / getMetaTree 모두 이 순서를 따른다.
|
|
39
39
|
* 결과: 모든 외부 노출 collection 이 동일 ordering 을 가진다.
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
u(this, j);
|
|
42
42
|
/** register()가 registerMeta + hydrateEntry를 합쳐 호출할 때 중간 notify를 억제한다. */
|
|
43
|
-
|
|
43
|
+
u(this, A, !1);
|
|
44
44
|
/** batch 도중에 mutation이 한 번이라도 일어났는지 — false면 batch 종료 시 notify 안 한다. */
|
|
45
|
-
|
|
45
|
+
u(this, T, !1);
|
|
46
46
|
}
|
|
47
47
|
// ── 기존 외부 API: 시그니처 변경 없음. 시맨틱은 hydrated만 표면. ───────────
|
|
48
48
|
/**
|
|
@@ -54,13 +54,13 @@ class J {
|
|
|
54
54
|
*/
|
|
55
55
|
register(t) {
|
|
56
56
|
const e = V(t);
|
|
57
|
-
|
|
57
|
+
f(this, l, q).call(this, () => {
|
|
58
58
|
this.registerMeta(e), this.hydrateEntry(t.id, t.jogaks, t.meta.component);
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
unregister(t) {
|
|
62
62
|
const e = s(this, a).get(t);
|
|
63
|
-
e !== void 0 && (e.kind === "pending" && e.reject(new U(t)), s(this, a).delete(t),
|
|
63
|
+
e !== void 0 && (e.kind === "pending" && e.reject(new U(t)), s(this, a).delete(t), f(this, l, m).call(this));
|
|
64
64
|
}
|
|
65
65
|
/** hydrated일 때만 RegistryEntry를 반환한다. meta-only/pending이면 undefined. */
|
|
66
66
|
get(t) {
|
|
@@ -71,7 +71,7 @@ class J {
|
|
|
71
71
|
getAll() {
|
|
72
72
|
if (s(this, E) !== void 0) return s(this, E);
|
|
73
73
|
const t = [];
|
|
74
|
-
for (const n of
|
|
74
|
+
for (const n of f(this, l, C).call(this)) {
|
|
75
75
|
const r = s(this, a).get(n);
|
|
76
76
|
(r == null ? void 0 : r.kind) === "hydrated" && t.push(r.entry);
|
|
77
77
|
}
|
|
@@ -109,7 +109,7 @@ class J {
|
|
|
109
109
|
if (s(this, a).size !== 0) {
|
|
110
110
|
for (const t of s(this, a).values())
|
|
111
111
|
t.kind === "pending" && t.reject(new Error("[jogak] registry cleared"));
|
|
112
|
-
s(this, a).clear(),
|
|
112
|
+
s(this, a).clear(), f(this, l, m).call(this);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
/** hydrated 개수. */
|
|
@@ -127,11 +127,11 @@ class J {
|
|
|
127
127
|
registerMeta(t) {
|
|
128
128
|
const e = s(this, a).get(t.id);
|
|
129
129
|
if (e === void 0) {
|
|
130
|
-
s(this, a).set(t.id, { kind: "meta", meta: t }),
|
|
130
|
+
s(this, a).set(t.id, { kind: "meta", meta: t }), f(this, l, m).call(this);
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
if (e.kind === "meta") {
|
|
134
|
-
s(this, a).set(t.id, { kind: "meta", meta: t }),
|
|
134
|
+
s(this, a).set(t.id, { kind: "meta", meta: t }), f(this, l, m).call(this);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
if (e.kind === "pending") {
|
|
@@ -141,7 +141,7 @@ class J {
|
|
|
141
141
|
promise: e.promise,
|
|
142
142
|
resolve: e.resolve,
|
|
143
143
|
reject: e.reject
|
|
144
|
-
}),
|
|
144
|
+
}), f(this, l, m).call(this);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
147
|
const n = {
|
|
@@ -151,7 +151,7 @@ class J {
|
|
|
151
151
|
source: t.source,
|
|
152
152
|
meta: $(t, e.entry.meta.component)
|
|
153
153
|
};
|
|
154
|
-
s(this, a).set(t.id, { kind: "hydrated", meta: t, entry: n }),
|
|
154
|
+
s(this, a).set(t.id, { kind: "hydrated", meta: t, entry: n }), f(this, l, m).call(this);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* entry 가상모듈이 호출. pending Promise들을 resolve.
|
|
@@ -181,10 +181,10 @@ class J {
|
|
|
181
181
|
...o.source ? { source: o.source } : {}
|
|
182
182
|
};
|
|
183
183
|
if ((r == null ? void 0 : r.kind) === "pending") {
|
|
184
|
-
s(this, a).set(t, { kind: "hydrated", meta: o, entry: h }),
|
|
184
|
+
s(this, a).set(t, { kind: "hydrated", meta: o, entry: h }), f(this, l, m).call(this), r.resolve(h);
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
|
-
s(this, a).set(t, { kind: "hydrated", meta: o, entry: h }),
|
|
187
|
+
s(this, a).set(t, { kind: "hydrated", meta: o, entry: h }), f(this, l, m).call(this);
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
190
|
* 어댑터가 호출. hydrated였던 entry를 meta 상태로 되돌린다.
|
|
@@ -193,7 +193,7 @@ class J {
|
|
|
193
193
|
*/
|
|
194
194
|
invalidateEntry(t) {
|
|
195
195
|
const e = s(this, a).get(t);
|
|
196
|
-
e === void 0 || e.kind !== "hydrated" || (s(this, a).set(t, { kind: "meta", meta: e.meta }),
|
|
196
|
+
e === void 0 || e.kind !== "hydrated" || (s(this, a).set(t, { kind: "meta", meta: e.meta }), f(this, l, m).call(this));
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* UI/어댑터가 호출. entry id로 완전한 RegistryEntry를 비동기 획득.
|
|
@@ -250,7 +250,7 @@ class J {
|
|
|
250
250
|
getAllMeta() {
|
|
251
251
|
if (s(this, v) !== void 0) return s(this, v);
|
|
252
252
|
const t = [];
|
|
253
|
-
for (const n of
|
|
253
|
+
for (const n of f(this, l, C).call(this)) {
|
|
254
254
|
const r = s(this, a).get(n);
|
|
255
255
|
r !== void 0 && t.push(r.meta);
|
|
256
256
|
}
|
|
@@ -264,7 +264,7 @@ class J {
|
|
|
264
264
|
getMetaTree() {
|
|
265
265
|
if (s(this, k) !== void 0) return s(this, k);
|
|
266
266
|
const t = {};
|
|
267
|
-
for (const e of
|
|
267
|
+
for (const e of f(this, l, C).call(this)) {
|
|
268
268
|
const n = s(this, a).get(e);
|
|
269
269
|
if (n === void 0) continue;
|
|
270
270
|
const r = n.meta, o = r.title.split("/");
|
|
@@ -355,7 +355,7 @@ q = function(t) {
|
|
|
355
355
|
try {
|
|
356
356
|
t();
|
|
357
357
|
} finally {
|
|
358
|
-
c(this, A, !1), s(this, T) && (c(this, T, !1),
|
|
358
|
+
c(this, A, !1), s(this, T) && (c(this, T, !1), f(this, l, m).call(this));
|
|
359
359
|
}
|
|
360
360
|
};
|
|
361
361
|
function V(i) {
|
|
@@ -397,14 +397,14 @@ function G(i, t) {
|
|
|
397
397
|
});
|
|
398
398
|
return e !== 0 ? e : i.id.localeCompare(t.id, "en", { sensitivity: "base", numeric: !0 });
|
|
399
399
|
}
|
|
400
|
-
const W = new
|
|
400
|
+
const W = new B();
|
|
401
401
|
var p, x, S, M, F;
|
|
402
402
|
class H {
|
|
403
403
|
constructor() {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
404
|
+
u(this, M);
|
|
405
|
+
u(this, p, []);
|
|
406
|
+
u(this, x, /* @__PURE__ */ new Set());
|
|
407
|
+
u(this, S, 1);
|
|
408
408
|
}
|
|
409
409
|
emit(t, e) {
|
|
410
410
|
const n = {
|
|
@@ -413,7 +413,7 @@ class H {
|
|
|
413
413
|
args: e,
|
|
414
414
|
timestamp: Date.now()
|
|
415
415
|
};
|
|
416
|
-
c(this, p, [...s(this, p), n]),
|
|
416
|
+
c(this, p, [...s(this, p), n]), f(this, M, F).call(this);
|
|
417
417
|
}
|
|
418
418
|
subscribe(t) {
|
|
419
419
|
return s(this, x).add(t), t(s(this, p)), () => {
|
|
@@ -421,7 +421,7 @@ class H {
|
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
423
|
clear() {
|
|
424
|
-
s(this, p).length !== 0 && (c(this, p, []),
|
|
424
|
+
s(this, p).length !== 0 && (c(this, p, []), f(this, M, F).call(this));
|
|
425
425
|
}
|
|
426
426
|
getLogs() {
|
|
427
427
|
return s(this, p);
|
|
@@ -448,12 +448,16 @@ function X(i, t, e = D) {
|
|
|
448
448
|
}
|
|
449
449
|
return n;
|
|
450
450
|
}
|
|
451
|
+
function Y(i) {
|
|
452
|
+
return i;
|
|
453
|
+
}
|
|
451
454
|
export {
|
|
452
455
|
H as ActionChannel,
|
|
453
|
-
|
|
456
|
+
B as ComponentRegistry,
|
|
454
457
|
U as UnknownEntryError,
|
|
455
458
|
K as action,
|
|
456
459
|
D as defaultActionChannel,
|
|
457
460
|
W as defaultRegistry,
|
|
461
|
+
Y as defineJogakConfig,
|
|
458
462
|
X as injectActions
|
|
459
463
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -208,4 +208,39 @@ export interface JogakPluginOptions {
|
|
|
208
208
|
* jogak({ globalCss: ['./src/tokens.css', './src/index.css'] })
|
|
209
209
|
*/
|
|
210
210
|
readonly globalCss?: boolean | string | readonly string[];
|
|
211
|
+
/**
|
|
212
|
+
* Preview 영역의 격리 모드 (알파.7 도입, 알파.7.1에서 default 변경).
|
|
213
|
+
*
|
|
214
|
+
* 사용자 globalCss와 jogak chrome의 양방향 격리를 제공한다. 알파.7까지는
|
|
215
|
+
* 사용자 globalCss를 outer document에 inject하면서 jogak chrome utility를
|
|
216
|
+
* 무력화하는 결함이 있었으나 알파.7.1에서 main.tsx + ShadowMount가 모드별
|
|
217
|
+
* scope을 분리하도록 정정됨.
|
|
218
|
+
*
|
|
219
|
+
* 모드:
|
|
220
|
+
* - `'shadow'` (default, 알파.7.1): Preview의 `[data-jogak-content]` 영역만
|
|
221
|
+
* ShadowRoot에 마운트하고 사용자 globalCss를 ShadowRoot scope에만 inject.
|
|
222
|
+
* outer document의 jogak chrome은 사용자 reset/preflight 침범을 받지 않는다.
|
|
223
|
+
* **한계**: Radix UI(shadcn dialog/popover/tooltip 등)는 default Portal target이
|
|
224
|
+
* `document.body` (shadow 외부) — portal 내용은 사용자 css 미적용. 회피:
|
|
225
|
+
* 사용자가 명시적으로 `<Portal container={shadowRootEl}>` 전달.
|
|
226
|
+
* - `'iframe'`: Preview를 별도 `<iframe>`에 로드. 완벽 격리. **한계**: jogak의
|
|
227
|
+
* "single Vite, no iframe" 차별점과 상충하므로 명시적 opt-in 한정. HMR은
|
|
228
|
+
* iframe도 Vite dev server module이라 작동하지만, args/이벤트 전달이
|
|
229
|
+
* `contentWindow` 직접 접근 한 단계 추가됨.
|
|
230
|
+
* - `'none'` (back-compat opt-in): Preview는 jogak SPA와 동일 document에 마운트하고
|
|
231
|
+
* 사용자 globalCss를 outer document에 inject. 사용자 reset/preflight가 jogak
|
|
232
|
+
* chrome에 침범 가능. 사용자가 침범을 의도적으로 허용하는 경우만 사용.
|
|
233
|
+
*
|
|
234
|
+
* @default 'shadow'
|
|
235
|
+
*
|
|
236
|
+
* @example 양방향 격리 (default — 미지정 시 적용)
|
|
237
|
+
* jogak({ globalCss: true }) // previewIsolation 'shadow' 자동 적용
|
|
238
|
+
*
|
|
239
|
+
* @example 사용자 reset이 chrome에도 영향을 주길 원하는 경우
|
|
240
|
+
* jogak({ globalCss: true, previewIsolation: 'none' })
|
|
241
|
+
*
|
|
242
|
+
* @example Radix portal까지 완벽 격리
|
|
243
|
+
* jogak({ globalCss: true, previewIsolation: 'iframe' })
|
|
244
|
+
*/
|
|
245
|
+
readonly previewIsolation?: 'none' | 'shadow' | 'iframe';
|
|
211
246
|
}
|
package/dist/vite/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var K=Object.create;var L=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var X=Object.getPrototypeOf,Y=Object.prototype.hasOwnProperty;var H=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of W(t))!Y.call(e,a)&&a!==s&&L(e,a,{get:()=>t[a],enumerable:!(o=q(t,a))||o.enumerable});return e};var z=(e,t,s)=>(s=e!=null?K(X(e)):{},H(t||!e||!e.__esModule?L(s,"default",{value:e,enumerable:!0}):s,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("node:path"),_=require("node:fs"),k=require("node:fs/promises"),R=require("../extractor-client-CiWszHel.cjs"),Q=["@jogak/core","@jogak/react","@jogak/web-components","@jogak/next"];async function P(e){try{const o=await k.stat(e);if(!o.isDirectory())return o.mtimeMs}catch{return 0}let t=0,s;try{s=await k.readdir(e)}catch{return 0}for(const o of s){const a=f.join(e,o);try{const l=await k.stat(a);if(l.isDirectory()){const y=await P(a);y>t&&(t=y)}else l.mtimeMs>t&&(t=l.mtimeMs)}catch{continue}}return t}async function Z(e){const t=f.resolve(e.root,"node_modules/.vite/deps");if(!_.existsSync(t))return{purged:!1};const s=f.join(t,"_metadata.json");if(!_.existsSync(s))return{purged:!1};let o;try{o=(await k.stat(s)).mtimeMs}catch(l){return e.logger.warn(`[jogak] cache validation: failed to stat _metadata.json (${l.message})`),{purged:!1}}const a=e.packages??Q;for(const l of a){const y=f.resolve(e.root,"node_modules",l,"dist");if(!_.existsSync(y))continue;let h;try{h=await P(y)}catch(w){e.logger.warn(`[jogak] cache validation: failed to walk ${l}/dist (${w.message})`);continue}if(h>o+1e3)try{return await k.rm(t,{recursive:!0,force:!0}),e.logger.info(`[jogak] vite deps cache invalidated (stale): ${l} dist newer than cache`),{purged:!0,reason:l}}catch(w){return e.logger.warn(`[jogak] cache validation: failed to purge ${t} (${w.message})`),{purged:!1}}}return{purged:!1}}const ee=["src/index.css","src/main.css","src/styles.css","src/styles/globals.css","src/styles/index.css","src/app/globals.css","src/global.css","src/app.css"];function te(e){for(const t of ee){const s=f.resolve(e,t);if(_.existsSync(s))return[s]}return[]}function re(e,t){if(e===void 0||e===!1)return[];if(e===!0)return te(t);if(typeof e=="string")return e.length>0?[f.resolve(t,e)]:[];const s=[];for(const o of e)typeof o=="string"&&o.length>0&&s.push(f.resolve(t,o));return s}function se(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"")}function oe(e){if(_.existsSync(e))try{const t=_.readFileSync(e,"utf8");return JSON.parse(se(t))}catch{return}}function ne(e,t,s){if(!e.endsWith("/*")||!t.endsWith("/*"))return;const o=e.slice(0,-2),a=f.resolve(s,t.slice(0,-2));return[o,a]}function ae(e,t){var a,l;const s={},o=new Set([e,f.resolve(t,"tsconfig.app.json")]);for(const y of o){const h=oe(y);if(h===void 0)continue;const w=(a=h.compilerOptions)==null?void 0:a.paths;if(w===void 0)continue;const d=((l=h.compilerOptions)==null?void 0:l.baseUrl)??".",p=f.resolve(f.dirname(y),d);for(const[S,b]of Object.entries(w)){const x=b[0];if(x===void 0)continue;const C=ne(S,x,p);if(C===void 0)continue;const[A,r]=C;s[A]===void 0&&(s[A]=r)}}return s}const F="virtual:jogak",M="\0"+F,G="virtual:jogak/entry/",O="\0"+G,U="virtual:jogak/global-css",$="\0"+U;function ie(e){return Buffer.from(e,"utf8").toString("base64url")}function ce(e){return Buffer.from(e,"base64url").toString("utf8")}function D(e){return{title:e.title,jogakNamesKey:[...e.jogakNames].sort().join("|")}}function le(e,t){return e!==void 0&&e.title===t.title&&e.jogakNamesKey===t.jogakNamesKey}function ue(e={}){const{patterns:t=["src/**/*.jogak.ts","src/**/*.jogak.tsx"],codeTheme:s="vsDark"}=e,o=e.cwd,a=e.tsConfigFilePath,l=e.disableCacheValidation===!0,y=e.resolveAlias,h=e.globalCss,w=e.previewIsolation??"shadow";let d,p,S;const b=new Map,x=new Map,C=new Map;async function A(){const{glob:r}=await import("glob"),g=S??process.cwd(),n=(await r(t,{cwd:g,absolute:!0})).sort(),u=[];b.clear(),x.clear();for(const i of n){let v="";try{v=await k.readFile(i,"utf8")}catch{continue}let j={},c=null;if(p!==void 0){try{j=await p.extract(i)}catch{j={}}try{c=await p.extractMeta(i)}catch{c=null}}if(c===null)continue;const m=c.title;b.set(m,i),x.set(i,m);const T={id:m,title:c.title,jogakNames:c.jogakNames,autoArgTypes:j,userArgTypes:c.userArgTypes,source:v,filePath:i,metaExtras:c.metaExtras};C.set(i,D(T)),u.push({id:m,filePath:i,meta:T})}return u}return{name:"vite-plugin-jogak",config(){const r=o??process.cwd(),g=a??f.resolve(r,"tsconfig.json"),n=ae(g,r),u={};if(y!==void 0)for(const[v,j]of Object.entries(y))u[v]=f.resolve(r,j);const i={...n,...u};if(Object.keys(i).length!==0)return{resolve:{alias:i}}},async configResolved(r){S=o??r.root,r.command==="serve"&&!l&&await Z({root:r.root,logger:{info:n=>r.logger.info(n),warn:n=>r.logger.warn(n)}});const g=a??f.resolve(S,"tsconfig.json");p=_.existsSync(g)?R.createPropsExtractor({tsConfigFilePath:g}):R.createPropsExtractor()},configureServer(r){d=r},buildEnd(){p==null||p.releaseCache()},resolveId(r){if(r===F)return M;if(r===U)return $;if(r.startsWith(G))return"\0"+r},async load(r){if(r===$){const g=S??process.cwd(),n=re(h,g);return n.length===0?`// [jogak] globalCss not configured or no candidates found.
|
|
2
2
|
export {}
|
|
3
|
-
`:`${n.map(
|
|
3
|
+
`:`${n.map(i=>`import ${JSON.stringify(i)}`).join(`
|
|
4
4
|
`)}
|
|
5
5
|
export {}
|
|
6
|
-
`}if(r===M){const n=(await
|
|
6
|
+
`}if(r===M){const n=(await A()).map(u=>u.meta);return`import { defaultRegistry } from '@jogak/core'
|
|
7
7
|
|
|
8
8
|
const _entryLoader = (slug) =>
|
|
9
9
|
import(/* @vite-ignore */ '/@id/__x00__virtual:jogak/entry/' + slug)
|
|
10
10
|
defaultRegistry.setEntryLoader((id) => {
|
|
11
|
-
const slug = ${
|
|
11
|
+
const slug = ${de()}
|
|
12
12
|
return _entryLoader(slug(id))
|
|
13
13
|
})
|
|
14
14
|
|
|
@@ -17,10 +17,11 @@ const _metas = ${JSON.stringify(n)}
|
|
|
17
17
|
for (const m of _metas) defaultRegistry.registerMeta(m)
|
|
18
18
|
|
|
19
19
|
export const _jogakCodeTheme = ${JSON.stringify(s)}
|
|
20
|
+
export const _jogakPreviewIsolation = ${JSON.stringify(w)}
|
|
20
21
|
export const _jogakMetas = _metas
|
|
21
|
-
`}if(r.startsWith(
|
|
22
|
+
`}if(r.startsWith(O)){const g=r.slice(O.length),n=ce(g);let u=b.get(n);return u===void 0&&(await A(),u=b.get(n)),u===void 0?`// [jogak] unknown entry id: ${JSON.stringify(n)}
|
|
22
23
|
export {}
|
|
23
|
-
`:`import * as _user from ${JSON.stringify(
|
|
24
|
+
`:`import * as _user from ${JSON.stringify(u)}
|
|
24
25
|
import { defaultRegistry } from '@jogak/core'
|
|
25
26
|
|
|
26
27
|
const _meta = _user.default
|
|
@@ -36,11 +37,11 @@ if (import.meta.hot) {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export {}
|
|
39
|
-
`}},async handleHotUpdate({file:r,modules:
|
|
40
|
+
`}},async handleHotUpdate({file:r,modules:g}){const n=/\.jogak\.(tsx?|jsx?)$/.test(r),u=/\.(tsx?|jsx?)$/.test(r)&&!n;if(!n&&!u||d===void 0||!n)return;const i=d.moduleGraph.getModuleById(M),v=x.get(r),j=v!==void 0?O+ie(v):void 0,c=j!==void 0?d.moduleGraph.getModuleById(j):void 0;let m=null,T={},E="";if(p!==void 0){try{m=await p.extractMeta(r)}catch{m=null}try{T=await p.extract(r)}catch{T={}}try{E=await k.readFile(r,"utf8")}catch{E=""}}if(m===null){i!==void 0&&d.moduleGraph.invalidateModule(i),c!==void 0&&d.moduleGraph.invalidateModule(c),d.ws.send({type:"full-reload"});return}const N=D(m),V=C.get(r),J=le(V,N);if(C.set(r,N),!J||v===void 0){i!==void 0&&d.moduleGraph.invalidateModule(i),c!==void 0&&d.moduleGraph.invalidateModule(c),d.ws.send({type:"full-reload"});return}const B={id:v,title:m.title,jogakNames:m.jogakNames,autoArgTypes:T,userArgTypes:m.userArgTypes,source:E,filePath:r,metaExtras:m.metaExtras};c!==void 0&&d.moduleGraph.invalidateModule(c),d.ws.send({type:"custom",event:"jogak:meta-update",data:{id:v,meta:B}});const I=[...g];return c!==void 0&&!I.includes(c)&&I.push(c),I}}}function de(){return`(rawId) => {
|
|
40
41
|
if (typeof Buffer !== 'undefined') return Buffer.from(rawId, 'utf8').toString('base64url')
|
|
41
42
|
// 브라우저 폴백: btoa는 binary string 기준이라 UTF-8을 한번 인코딩해야 한다.
|
|
42
43
|
const enc = new TextEncoder().encode(rawId)
|
|
43
44
|
let bin = ''
|
|
44
45
|
for (let i = 0; i < enc.length; i++) bin += String.fromCharCode(enc[i])
|
|
45
46
|
return btoa(bin).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '')
|
|
46
|
-
}`}exports.jogak=
|
|
47
|
+
}`}exports.jogak=ue;
|
package/dist/vite/index.mjs
CHANGED
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import { resolve as y, join as
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import { stat as
|
|
4
|
-
import { c as
|
|
5
|
-
const
|
|
1
|
+
import { resolve as y, join as P, dirname as W } from "node:path";
|
|
2
|
+
import { existsSync as T, readFileSync as X } from "node:fs";
|
|
3
|
+
import { stat as O, rm as Y, readdir as q, readFile as L } from "node:fs/promises";
|
|
4
|
+
import { c as R } from "../extractor-client-CReBed7x.js";
|
|
5
|
+
const H = [
|
|
6
6
|
"@jogak/core",
|
|
7
7
|
"@jogak/react",
|
|
8
8
|
"@jogak/web-components",
|
|
9
9
|
"@jogak/next"
|
|
10
10
|
];
|
|
11
|
-
async function
|
|
11
|
+
async function F(t) {
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
15
|
-
return
|
|
13
|
+
const a = await O(t);
|
|
14
|
+
if (!a.isDirectory())
|
|
15
|
+
return a.mtimeMs;
|
|
16
16
|
} catch {
|
|
17
17
|
return 0;
|
|
18
18
|
}
|
|
19
|
-
let
|
|
19
|
+
let o = 0, s;
|
|
20
20
|
try {
|
|
21
|
-
s = await
|
|
21
|
+
s = await q(t);
|
|
22
22
|
} catch {
|
|
23
23
|
return 0;
|
|
24
24
|
}
|
|
25
|
-
for (const
|
|
26
|
-
const g =
|
|
25
|
+
for (const a of s) {
|
|
26
|
+
const g = P(t, a);
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const p = await
|
|
31
|
-
p >
|
|
32
|
-
} else
|
|
28
|
+
const c = await O(g);
|
|
29
|
+
if (c.isDirectory()) {
|
|
30
|
+
const p = await F(g);
|
|
31
|
+
p > o && (o = p);
|
|
32
|
+
} else c.mtimeMs > o && (o = c.mtimeMs);
|
|
33
33
|
} catch {
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return o;
|
|
38
38
|
}
|
|
39
|
-
async function
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
39
|
+
async function z(t) {
|
|
40
|
+
const o = y(t.root, "node_modules/.vite/deps");
|
|
41
|
+
if (!T(o))
|
|
42
42
|
return { purged: !1 };
|
|
43
|
-
const s =
|
|
44
|
-
if (!
|
|
43
|
+
const s = P(o, "_metadata.json");
|
|
44
|
+
if (!T(s))
|
|
45
45
|
return { purged: !1 };
|
|
46
|
-
let
|
|
46
|
+
let a;
|
|
47
47
|
try {
|
|
48
|
-
|
|
49
|
-
} catch (
|
|
48
|
+
a = (await O(s)).mtimeMs;
|
|
49
|
+
} catch (c) {
|
|
50
50
|
return t.logger.warn(
|
|
51
|
-
`[jogak] cache validation: failed to stat _metadata.json (${
|
|
51
|
+
`[jogak] cache validation: failed to stat _metadata.json (${c.message})`
|
|
52
52
|
), { purged: !1 };
|
|
53
53
|
}
|
|
54
|
-
const g = t.packages ??
|
|
55
|
-
for (const
|
|
56
|
-
const p = y(t.root, "node_modules",
|
|
57
|
-
if (!
|
|
54
|
+
const g = t.packages ?? H;
|
|
55
|
+
for (const c of g) {
|
|
56
|
+
const p = y(t.root, "node_modules", c, "dist");
|
|
57
|
+
if (!T(p)) continue;
|
|
58
58
|
let h;
|
|
59
59
|
try {
|
|
60
|
-
h = await
|
|
61
|
-
} catch (
|
|
60
|
+
h = await F(p);
|
|
61
|
+
} catch (w) {
|
|
62
62
|
t.logger.warn(
|
|
63
|
-
`[jogak] cache validation: failed to walk ${
|
|
63
|
+
`[jogak] cache validation: failed to walk ${c}/dist (${w.message})`
|
|
64
64
|
);
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
|
-
if (h >
|
|
67
|
+
if (h > a + 1e3)
|
|
68
68
|
try {
|
|
69
|
-
return await
|
|
70
|
-
`[jogak] vite deps cache invalidated (stale): ${
|
|
71
|
-
), { purged: !0, reason:
|
|
72
|
-
} catch (
|
|
69
|
+
return await Y(o, { recursive: !0, force: !0 }), t.logger.info(
|
|
70
|
+
`[jogak] vite deps cache invalidated (stale): ${c} dist newer than cache`
|
|
71
|
+
), { purged: !0, reason: c };
|
|
72
|
+
} catch (w) {
|
|
73
73
|
return t.logger.warn(
|
|
74
|
-
`[jogak] cache validation: failed to purge ${
|
|
74
|
+
`[jogak] cache validation: failed to purge ${o} (${w.message})`
|
|
75
75
|
), { purged: !1 };
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
return { purged: !1 };
|
|
79
79
|
}
|
|
80
|
-
const
|
|
80
|
+
const Q = [
|
|
81
81
|
"src/index.css",
|
|
82
82
|
"src/main.css",
|
|
83
83
|
"src/styles.css",
|
|
@@ -87,68 +87,68 @@ const z = [
|
|
|
87
87
|
"src/global.css",
|
|
88
88
|
"src/app.css"
|
|
89
89
|
];
|
|
90
|
-
function
|
|
91
|
-
for (const
|
|
92
|
-
const s = y(t,
|
|
93
|
-
if (
|
|
90
|
+
function Z(t) {
|
|
91
|
+
for (const o of Q) {
|
|
92
|
+
const s = y(t, o);
|
|
93
|
+
if (T(s)) return [s];
|
|
94
94
|
}
|
|
95
95
|
return [];
|
|
96
96
|
}
|
|
97
|
-
function
|
|
97
|
+
function tt(t, o) {
|
|
98
98
|
if (t === void 0 || t === !1) return [];
|
|
99
|
-
if (t === !0) return
|
|
99
|
+
if (t === !0) return Z(o);
|
|
100
100
|
if (typeof t == "string")
|
|
101
|
-
return t.length > 0 ? [y(
|
|
101
|
+
return t.length > 0 ? [y(o, t)] : [];
|
|
102
102
|
const s = [];
|
|
103
|
-
for (const
|
|
104
|
-
typeof
|
|
103
|
+
for (const a of t)
|
|
104
|
+
typeof a == "string" && a.length > 0 && s.push(y(o, a));
|
|
105
105
|
return s;
|
|
106
106
|
}
|
|
107
|
-
function
|
|
107
|
+
function et(t) {
|
|
108
108
|
return t.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (
|
|
110
|
+
function ot(t) {
|
|
111
|
+
if (T(t))
|
|
112
112
|
try {
|
|
113
|
-
const
|
|
114
|
-
return JSON.parse(
|
|
113
|
+
const o = X(t, "utf8");
|
|
114
|
+
return JSON.parse(et(o));
|
|
115
115
|
} catch {
|
|
116
116
|
return;
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
function rt(t,
|
|
120
|
-
if (!t.endsWith("/*") || !
|
|
121
|
-
const
|
|
122
|
-
return [
|
|
119
|
+
function rt(t, o, s) {
|
|
120
|
+
if (!t.endsWith("/*") || !o.endsWith("/*")) return;
|
|
121
|
+
const a = t.slice(0, -2), g = y(s, o.slice(0, -2));
|
|
122
|
+
return [a, g];
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
var g,
|
|
126
|
-
const s = {},
|
|
124
|
+
function st(t, o) {
|
|
125
|
+
var g, c;
|
|
126
|
+
const s = {}, a = /* @__PURE__ */ new Set([
|
|
127
127
|
t,
|
|
128
|
-
y(
|
|
128
|
+
y(o, "tsconfig.app.json")
|
|
129
129
|
]);
|
|
130
|
-
for (const p of
|
|
131
|
-
const h =
|
|
130
|
+
for (const p of a) {
|
|
131
|
+
const h = ot(p);
|
|
132
132
|
if (h === void 0) continue;
|
|
133
|
-
const
|
|
134
|
-
if (
|
|
135
|
-
const
|
|
136
|
-
for (const [_,
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const [
|
|
142
|
-
s[
|
|
133
|
+
const w = (g = h.compilerOptions) == null ? void 0 : g.paths;
|
|
134
|
+
if (w === void 0) continue;
|
|
135
|
+
const u = ((c = h.compilerOptions) == null ? void 0 : c.baseUrl) ?? ".", m = y(W(p), u);
|
|
136
|
+
for (const [_, k] of Object.entries(w)) {
|
|
137
|
+
const S = k[0];
|
|
138
|
+
if (S === void 0) continue;
|
|
139
|
+
const b = rt(_, S, m);
|
|
140
|
+
if (b === void 0) continue;
|
|
141
|
+
const [A, e] = b;
|
|
142
|
+
s[A] === void 0 && (s[A] = e);
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
145
|
return s;
|
|
146
146
|
}
|
|
147
|
-
const
|
|
148
|
-
function
|
|
147
|
+
const G = "virtual:jogak", E = "\0" + G, U = "virtual:jogak/entry/", M = "\0" + U, V = "virtual:jogak/global-css", $ = "\0" + V;
|
|
148
|
+
function at(t) {
|
|
149
149
|
return Buffer.from(t, "utf8").toString("base64url");
|
|
150
150
|
}
|
|
151
|
-
function
|
|
151
|
+
function nt(t) {
|
|
152
152
|
return Buffer.from(t, "base64url").toString("utf8");
|
|
153
153
|
}
|
|
154
154
|
function D(t) {
|
|
@@ -157,55 +157,55 @@ function D(t) {
|
|
|
157
157
|
jogakNamesKey: [...t.jogakNames].sort().join("|")
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
|
-
function
|
|
161
|
-
return t !== void 0 && t.title ===
|
|
160
|
+
function it(t, o) {
|
|
161
|
+
return t !== void 0 && t.title === o.title && t.jogakNamesKey === o.jogakNamesKey;
|
|
162
162
|
}
|
|
163
|
-
function
|
|
163
|
+
function gt(t = {}) {
|
|
164
164
|
const {
|
|
165
|
-
patterns:
|
|
165
|
+
patterns: o = ["src/**/*.jogak.ts", "src/**/*.jogak.tsx"],
|
|
166
166
|
codeTheme: s = "vsDark"
|
|
167
|
-
} = t,
|
|
168
|
-
let
|
|
169
|
-
const
|
|
170
|
-
async function
|
|
171
|
-
const { glob: e } = await import("glob"),
|
|
172
|
-
|
|
173
|
-
for (const
|
|
167
|
+
} = t, a = t.cwd, g = t.tsConfigFilePath, c = t.disableCacheValidation === !0, p = t.resolveAlias, h = t.globalCss, w = t.previewIsolation ?? "shadow";
|
|
168
|
+
let u, m, _;
|
|
169
|
+
const k = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
|
|
170
|
+
async function A() {
|
|
171
|
+
const { glob: e } = await import("glob"), d = _ ?? process.cwd(), r = (await e(o, { cwd: d, absolute: !0 })).sort(), l = [];
|
|
172
|
+
k.clear(), S.clear();
|
|
173
|
+
for (const n of r) {
|
|
174
174
|
let v = "";
|
|
175
175
|
try {
|
|
176
|
-
v = await L(
|
|
176
|
+
v = await L(n, "utf8");
|
|
177
177
|
} catch {
|
|
178
178
|
continue;
|
|
179
179
|
}
|
|
180
|
-
let
|
|
180
|
+
let j = {}, i = null;
|
|
181
181
|
if (m !== void 0) {
|
|
182
182
|
try {
|
|
183
|
-
|
|
183
|
+
j = await m.extract(n);
|
|
184
184
|
} catch {
|
|
185
|
-
|
|
185
|
+
j = {};
|
|
186
186
|
}
|
|
187
187
|
try {
|
|
188
|
-
|
|
188
|
+
i = await m.extractMeta(n);
|
|
189
189
|
} catch {
|
|
190
|
-
|
|
190
|
+
i = null;
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
|
-
if (
|
|
194
|
-
const f =
|
|
195
|
-
|
|
196
|
-
const
|
|
193
|
+
if (i === null) continue;
|
|
194
|
+
const f = i.title;
|
|
195
|
+
k.set(f, n), S.set(n, f);
|
|
196
|
+
const C = {
|
|
197
197
|
id: f,
|
|
198
|
-
title:
|
|
199
|
-
jogakNames:
|
|
200
|
-
autoArgTypes:
|
|
201
|
-
userArgTypes:
|
|
198
|
+
title: i.title,
|
|
199
|
+
jogakNames: i.jogakNames,
|
|
200
|
+
autoArgTypes: j,
|
|
201
|
+
userArgTypes: i.userArgTypes,
|
|
202
202
|
source: v,
|
|
203
|
-
filePath:
|
|
204
|
-
metaExtras:
|
|
203
|
+
filePath: n,
|
|
204
|
+
metaExtras: i.metaExtras
|
|
205
205
|
};
|
|
206
|
-
|
|
206
|
+
b.set(n, D(C)), l.push({ id: f, filePath: n, meta: C });
|
|
207
207
|
}
|
|
208
|
-
return
|
|
208
|
+
return l;
|
|
209
209
|
}
|
|
210
210
|
return {
|
|
211
211
|
name: "vite-plugin-jogak",
|
|
@@ -220,76 +220,77 @@ function ft(t = {}) {
|
|
|
220
220
|
* 우선순위: `options.resolveAlias` (명시) > tsconfig 자동 추출.
|
|
221
221
|
*/
|
|
222
222
|
config() {
|
|
223
|
-
const e =
|
|
223
|
+
const e = a ?? process.cwd(), d = g ?? y(e, "tsconfig.json"), r = st(d, e), l = {};
|
|
224
224
|
if (p !== void 0)
|
|
225
|
-
for (const [v,
|
|
226
|
-
|
|
227
|
-
const
|
|
228
|
-
if (Object.keys(
|
|
225
|
+
for (const [v, j] of Object.entries(p))
|
|
226
|
+
l[v] = y(e, j);
|
|
227
|
+
const n = { ...r, ...l };
|
|
228
|
+
if (Object.keys(n).length !== 0)
|
|
229
229
|
return {
|
|
230
|
-
resolve: { alias:
|
|
230
|
+
resolve: { alias: n }
|
|
231
231
|
};
|
|
232
232
|
},
|
|
233
233
|
async configResolved(e) {
|
|
234
|
-
|
|
234
|
+
_ = a ?? e.root, e.command === "serve" && !c && await z({
|
|
235
235
|
root: e.root,
|
|
236
236
|
logger: {
|
|
237
|
-
info: (
|
|
238
|
-
warn: (
|
|
237
|
+
info: (r) => e.logger.info(r),
|
|
238
|
+
warn: (r) => e.logger.warn(r)
|
|
239
239
|
}
|
|
240
240
|
});
|
|
241
|
-
const
|
|
242
|
-
m =
|
|
241
|
+
const d = g ?? y(_, "tsconfig.json");
|
|
242
|
+
m = T(d) ? R({ tsConfigFilePath: d }) : R();
|
|
243
243
|
},
|
|
244
244
|
configureServer(e) {
|
|
245
|
-
|
|
245
|
+
u = e;
|
|
246
246
|
},
|
|
247
247
|
buildEnd() {
|
|
248
248
|
m == null || m.releaseCache();
|
|
249
249
|
},
|
|
250
250
|
resolveId(e) {
|
|
251
|
-
if (e ===
|
|
252
|
-
return
|
|
253
|
-
if (e ===
|
|
254
|
-
return
|
|
255
|
-
if (e.startsWith(
|
|
251
|
+
if (e === G)
|
|
252
|
+
return E;
|
|
253
|
+
if (e === V)
|
|
254
|
+
return $;
|
|
255
|
+
if (e.startsWith(U))
|
|
256
256
|
return "\0" + e;
|
|
257
257
|
},
|
|
258
258
|
async load(e) {
|
|
259
|
-
if (e ===
|
|
260
|
-
const
|
|
261
|
-
return
|
|
259
|
+
if (e === $) {
|
|
260
|
+
const d = _ ?? process.cwd(), r = tt(h, d);
|
|
261
|
+
return r.length === 0 ? `// [jogak] globalCss not configured or no candidates found.
|
|
262
262
|
export {}
|
|
263
|
-
` : `${
|
|
263
|
+
` : `${r.map((n) => `import ${JSON.stringify(n)}`).join(`
|
|
264
264
|
`)}
|
|
265
265
|
export {}
|
|
266
266
|
`;
|
|
267
267
|
}
|
|
268
|
-
if (e ===
|
|
269
|
-
const
|
|
268
|
+
if (e === E) {
|
|
269
|
+
const r = (await A()).map((l) => l.meta);
|
|
270
270
|
return `import { defaultRegistry } from '@jogak/core'
|
|
271
271
|
|
|
272
272
|
const _entryLoader = (slug) =>
|
|
273
273
|
import(/* @vite-ignore */ '/@id/__x00__virtual:jogak/entry/' + slug)
|
|
274
274
|
defaultRegistry.setEntryLoader((id) => {
|
|
275
|
-
const slug = ${
|
|
275
|
+
const slug = ${ct()}
|
|
276
276
|
return _entryLoader(slug(id))
|
|
277
277
|
})
|
|
278
278
|
|
|
279
|
-
const _metas = ${JSON.stringify(
|
|
279
|
+
const _metas = ${JSON.stringify(r)}
|
|
280
280
|
|
|
281
281
|
for (const m of _metas) defaultRegistry.registerMeta(m)
|
|
282
282
|
|
|
283
283
|
export const _jogakCodeTheme = ${JSON.stringify(s)}
|
|
284
|
+
export const _jogakPreviewIsolation = ${JSON.stringify(w)}
|
|
284
285
|
export const _jogakMetas = _metas
|
|
285
286
|
`;
|
|
286
287
|
}
|
|
287
|
-
if (e.startsWith(
|
|
288
|
-
const
|
|
289
|
-
let
|
|
290
|
-
return
|
|
288
|
+
if (e.startsWith(M)) {
|
|
289
|
+
const d = e.slice(M.length), r = nt(d);
|
|
290
|
+
let l = k.get(r);
|
|
291
|
+
return l === void 0 && (await A(), l = k.get(r)), l === void 0 ? `// [jogak] unknown entry id: ${JSON.stringify(r)}
|
|
291
292
|
export {}
|
|
292
|
-
` : `import * as _user from ${JSON.stringify(
|
|
293
|
+
` : `import * as _user from ${JSON.stringify(l)}
|
|
293
294
|
import { defaultRegistry } from '@jogak/core'
|
|
294
295
|
|
|
295
296
|
const _meta = _user.default
|
|
@@ -298,7 +299,7 @@ delete _named.default
|
|
|
298
299
|
const _jogaks = Object.values(_named).filter(
|
|
299
300
|
(v) => v !== null && typeof v === 'object' && typeof v.name === 'string'
|
|
300
301
|
)
|
|
301
|
-
defaultRegistry.hydrateEntry(${JSON.stringify(
|
|
302
|
+
defaultRegistry.hydrateEntry(${JSON.stringify(r)}, _jogaks, _meta?.component)
|
|
302
303
|
|
|
303
304
|
if (import.meta.hot) {
|
|
304
305
|
import.meta.hot.accept()
|
|
@@ -308,13 +309,13 @@ export {}
|
|
|
308
309
|
`;
|
|
309
310
|
}
|
|
310
311
|
},
|
|
311
|
-
async handleHotUpdate({ file: e, modules:
|
|
312
|
-
const
|
|
313
|
-
if (!
|
|
314
|
-
const
|
|
315
|
-
|
|
316
|
-
), v =
|
|
317
|
-
let f = null,
|
|
312
|
+
async handleHotUpdate({ file: e, modules: d }) {
|
|
313
|
+
const r = /\.jogak\.(tsx?|jsx?)$/.test(e), l = /\.(tsx?|jsx?)$/.test(e) && !r;
|
|
314
|
+
if (!r && !l || u === void 0 || !r) return;
|
|
315
|
+
const n = u.moduleGraph.getModuleById(
|
|
316
|
+
E
|
|
317
|
+
), v = S.get(e), j = v !== void 0 ? M + at(v) : void 0, i = j !== void 0 ? u.moduleGraph.getModuleById(j) : void 0;
|
|
318
|
+
let f = null, C = {}, I = "";
|
|
318
319
|
if (m !== void 0) {
|
|
319
320
|
try {
|
|
320
321
|
f = await m.extractMeta(e);
|
|
@@ -322,46 +323,46 @@ export {}
|
|
|
322
323
|
f = null;
|
|
323
324
|
}
|
|
324
325
|
try {
|
|
325
|
-
|
|
326
|
+
C = await m.extract(e);
|
|
326
327
|
} catch {
|
|
327
|
-
|
|
328
|
+
C = {};
|
|
328
329
|
}
|
|
329
330
|
try {
|
|
330
|
-
|
|
331
|
+
I = await L(e, "utf8");
|
|
331
332
|
} catch {
|
|
332
|
-
|
|
333
|
+
I = "";
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
336
|
if (f === null) {
|
|
336
|
-
|
|
337
|
+
n !== void 0 && u.moduleGraph.invalidateModule(n), i !== void 0 && u.moduleGraph.invalidateModule(i), u.ws.send({ type: "full-reload" });
|
|
337
338
|
return;
|
|
338
339
|
}
|
|
339
|
-
const
|
|
340
|
-
if (
|
|
341
|
-
|
|
340
|
+
const N = D(f), J = b.get(e), B = it(J, N);
|
|
341
|
+
if (b.set(e, N), !B || v === void 0) {
|
|
342
|
+
n !== void 0 && u.moduleGraph.invalidateModule(n), i !== void 0 && u.moduleGraph.invalidateModule(i), u.ws.send({ type: "full-reload" });
|
|
342
343
|
return;
|
|
343
344
|
}
|
|
344
|
-
const
|
|
345
|
+
const K = {
|
|
345
346
|
id: v,
|
|
346
347
|
title: f.title,
|
|
347
348
|
jogakNames: f.jogakNames,
|
|
348
|
-
autoArgTypes:
|
|
349
|
+
autoArgTypes: C,
|
|
349
350
|
userArgTypes: f.userArgTypes,
|
|
350
|
-
source:
|
|
351
|
+
source: I,
|
|
351
352
|
filePath: e,
|
|
352
353
|
metaExtras: f.metaExtras
|
|
353
354
|
};
|
|
354
|
-
|
|
355
|
+
i !== void 0 && u.moduleGraph.invalidateModule(i), u.ws.send({
|
|
355
356
|
type: "custom",
|
|
356
357
|
event: "jogak:meta-update",
|
|
357
|
-
data: { id: v, meta:
|
|
358
|
+
data: { id: v, meta: K }
|
|
358
359
|
});
|
|
359
|
-
const
|
|
360
|
-
return
|
|
360
|
+
const x = [...d];
|
|
361
|
+
return i !== void 0 && !x.includes(i) && x.push(i), x;
|
|
361
362
|
}
|
|
362
363
|
};
|
|
363
364
|
}
|
|
364
|
-
function
|
|
365
|
+
function ct() {
|
|
365
366
|
return `(rawId) => {
|
|
366
367
|
if (typeof Buffer !== 'undefined') return Buffer.from(rawId, 'utf8').toString('base64url')
|
|
367
368
|
// 브라우저 폴백: btoa는 binary string 기준이라 UTF-8을 한번 인코딩해야 한다.
|
|
@@ -372,5 +373,5 @@ function it() {
|
|
|
372
373
|
}`;
|
|
373
374
|
}
|
|
374
375
|
export {
|
|
375
|
-
|
|
376
|
+
gt as jogak
|
|
376
377
|
};
|