@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.
@@ -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)),f=(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),u=(i,t,e)=>(z(i,t,"access private method"),e);var N=(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,x,b,v,k,E,w,j,A,T,l,m,C,D;class q{constructor(){f(this,l);f(this,a,new Map);f(this,x);f(this,b,new Set);f(this,v);f(this,k);f(this,E);f(this,w);f(this,j);f(this,A,!1);f(this,T,!1)}register(t){const e=H(t);u(this,l,D).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),u(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 u(this,l,C).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(),u(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}),u(this,l,m).call(this);return}if(e.kind==="meta"){s(this,a).set(t.id,{kind:"meta",meta:t}),u(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}),u(this,l,m).call(this);return}const n={...e.entry,title:t.title,filePath:t.filePath,source:t.source,meta:$(t,e.entry.meta.component)};s(this,a).set(t.id,{kind:"hydrated",meta:t,entry:n}),u(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:$(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}),u(this,l,m).call(this),r.resolve(h);return}s(this,a).set(t,{kind:"hydrated",meta:o,entry:h}),u(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}),u(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,x);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 u(this,l,C).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 u(this,l,C).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,x,t)}subscribe(t){s(this,b).add(t);let e=!0;return()=>{e&&(e=!1,s(this,b).delete(t))}}}a=new WeakMap,x=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)}},C=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},D=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),u(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 $(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 q;var y,P,S,M,L;class B{constructor(){f(this,M);f(this,y,[]);f(this,P,new Set);f(this,S,1)}emit(t,e){const n={id:N(this,S)._++,name:t,args:e,timestamp:Date.now()};d(this,y,[...s(this,y),n]),u(this,M,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,[]),u(this,M,L).call(this))}getLogs(){return s(this,y)}}y=new WeakMap,P=new WeakMap,S=new WeakMap,M=new WeakSet,L=function(){for(const t of s(this,P))t(s(this,y))};const O=new B;function J(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]=J(g,e)}return n}exports.ActionChannel=B;exports.ComponentRegistry=q;exports.UnknownEntryError=F;exports.action=J;exports.defaultActionChannel=O;exports.defaultRegistry=Q;exports.injectActions=W;
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 R = Object.defineProperty;
1
+ var J = Object.defineProperty;
2
2
  var I = (i) => {
3
3
  throw TypeError(i);
4
4
  };
5
- var B = (i, t, e) => t in i ? R(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
- var N = (i, t, e) => B(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)), f = (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), u = (i, t, e) => (z(i, t, "access private method"), e);
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 J {
24
+ class B {
25
25
  constructor() {
26
- f(this, l);
27
- f(this, a, /* @__PURE__ */ new Map());
28
- f(this, P);
26
+ u(this, l);
27
+ u(this, a, /* @__PURE__ */ new Map());
28
+ u(this, P);
29
29
  // ── F2: subscribe + 내부 캐시 ────────────────────────────────────────
30
- f(this, b, /* @__PURE__ */ new Set());
31
- f(this, v);
32
- f(this, k);
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
- f(this, E);
35
- f(this, w);
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
- f(this, j);
41
+ u(this, j);
42
42
  /** register()가 registerMeta + hydrateEntry를 합쳐 호출할 때 중간 notify를 억제한다. */
43
- f(this, A, !1);
43
+ u(this, A, !1);
44
44
  /** batch 도중에 mutation이 한 번이라도 일어났는지 — false면 batch 종료 시 notify 안 한다. */
45
- f(this, T, !1);
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
- u(this, l, q).call(this, () => {
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), u(this, l, m).call(this));
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 u(this, l, C).call(this)) {
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(), u(this, l, m).call(this);
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 }), u(this, l, m).call(this);
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 }), u(this, l, m).call(this);
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
- }), u(this, l, m).call(this);
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 }), u(this, l, m).call(this);
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 }), u(this, l, m).call(this), r.resolve(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 }), u(this, l, m).call(this);
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 }), u(this, l, m).call(this));
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 u(this, l, C).call(this)) {
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 u(this, l, C).call(this)) {
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), u(this, l, m).call(this));
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 J();
400
+ const W = new B();
401
401
  var p, x, S, M, F;
402
402
  class H {
403
403
  constructor() {
404
- f(this, M);
405
- f(this, p, []);
406
- f(this, x, /* @__PURE__ */ new Set());
407
- f(this, S, 1);
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]), u(this, M, F).call(this);
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, []), u(this, M, F).call(this));
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
- J as ComponentRegistry,
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
  }
@@ -1,14 +1,14 @@
1
- "use strict";var J=Object.create;var L=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var q=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of q(t))!X.call(e,i)&&i!==s&&L(e,i,{get:()=>t[i],enumerable:!(o=K(t,i))||o.enumerable});return e};var H=(e,t,s)=>(s=e!=null?J(W(e)):{},Y(t||!e||!e.__esModule?L(s,"default",{value:e,enumerable:!0}):s,e));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("node:path"),j=require("node:fs"),_=require("node:fs/promises"),N=require("../extractor-client-CiWszHel.cjs"),z=["@jogak/core","@jogak/react","@jogak/web-components","@jogak/next"];async function $(e){try{const o=await _.stat(e);if(!o.isDirectory())return o.mtimeMs}catch{return 0}let t=0,s;try{s=await _.readdir(e)}catch{return 0}for(const o of s){const i=g.join(e,o);try{const u=await _.stat(i);if(u.isDirectory()){const y=await $(i);y>t&&(t=y)}else u.mtimeMs>t&&(t=u.mtimeMs)}catch{continue}}return t}async function Q(e){const t=g.resolve(e.root,"node_modules/.vite/deps");if(!j.existsSync(t))return{purged:!1};const s=g.join(t,"_metadata.json");if(!j.existsSync(s))return{purged:!1};let o;try{o=(await _.stat(s)).mtimeMs}catch(u){return e.logger.warn(`[jogak] cache validation: failed to stat _metadata.json (${u.message})`),{purged:!1}}const i=e.packages??z;for(const u of i){const y=g.resolve(e.root,"node_modules",u,"dist");if(!j.existsSync(y))continue;let h;try{h=await $(y)}catch(a){e.logger.warn(`[jogak] cache validation: failed to walk ${u}/dist (${a.message})`);continue}if(h>o+1e3)try{return await _.rm(t,{recursive:!0,force:!0}),e.logger.info(`[jogak] vite deps cache invalidated (stale): ${u} dist newer than cache`),{purged:!0,reason:u}}catch(a){return e.logger.warn(`[jogak] cache validation: failed to purge ${t} (${a.message})`),{purged:!1}}}return{purged:!1}}const Z=["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 ee(e){for(const t of Z){const s=g.resolve(e,t);if(j.existsSync(s))return[s]}return[]}function te(e,t){if(e===void 0||e===!1)return[];if(e===!0)return ee(t);if(typeof e=="string")return e.length>0?[g.resolve(t,e)]:[];const s=[];for(const o of e)typeof o=="string"&&o.length>0&&s.push(g.resolve(t,o));return s}function re(e){return e.replace(/\/\*[\s\S]*?\*\//g,"").replace(/^\s*\/\/.*$/gm,"")}function se(e){if(j.existsSync(e))try{const t=j.readFileSync(e,"utf8");return JSON.parse(re(t))}catch{return}}function oe(e,t,s){if(!e.endsWith("/*")||!t.endsWith("/*"))return;const o=e.slice(0,-2),i=g.resolve(s,t.slice(0,-2));return[o,i]}function ne(e,t){var i,u;const s={},o=new Set([e,g.resolve(t,"tsconfig.app.json")]);for(const y of o){const h=se(y);if(h===void 0)continue;const a=(i=h.compilerOptions)==null?void 0:i.paths;if(a===void 0)continue;const p=((u=h.compilerOptions)==null?void 0:u.baseUrl)??".",k=g.resolve(g.dirname(y),p);for(const[S,C]of Object.entries(a)){const b=C[0];if(b===void 0)continue;const T=oe(S,b,k);if(T===void 0)continue;const[r,d]=T;s[r]===void 0&&(s[r]=d)}}return s}const P="virtual:jogak",M="\0"+P,F="virtual:jogak/entry/",I="\0"+F,G="virtual:jogak/global-css",R="\0"+G;function ae(e){return Buffer.from(e,"utf8").toString("base64url")}function ie(e){return Buffer.from(e,"base64url").toString("utf8")}function D(e){return{title:e.title,jogakNamesKey:[...e.jogakNames].sort().join("|")}}function ce(e,t){return e!==void 0&&e.title===t.title&&e.jogakNamesKey===t.jogakNamesKey}function le(e={}){const{patterns:t=["src/**/*.jogak.ts","src/**/*.jogak.tsx"],codeTheme:s="vsDark"}=e,o=e.cwd,i=e.tsConfigFilePath,u=e.disableCacheValidation===!0,y=e.resolveAlias,h=e.globalCss;let a,p,k;const S=new Map,C=new Map,b=new Map;async function T(){const{glob:r}=await import("glob"),d=k??process.cwd(),n=(await r(t,{cwd:d,absolute:!0})).sort(),f=[];S.clear(),C.clear();for(const c of n){let v="";try{v=await _.readFile(c,"utf8")}catch{continue}let w={},l=null;if(p!==void 0){try{w=await p.extract(c)}catch{w={}}try{l=await p.extractMeta(c)}catch{l=null}}if(l===null)continue;const m=l.title;S.set(m,c),C.set(c,m);const x={id:m,title:l.title,jogakNames:l.jogakNames,autoArgTypes:w,userArgTypes:l.userArgTypes,source:v,filePath:c,metaExtras:l.metaExtras};b.set(c,D(x)),f.push({id:m,filePath:c,meta:x})}return f}return{name:"vite-plugin-jogak",config(){const r=o??process.cwd(),d=i??g.resolve(r,"tsconfig.json"),n=ne(d,r),f={};if(y!==void 0)for(const[v,w]of Object.entries(y))f[v]=g.resolve(r,w);const c={...n,...f};if(Object.keys(c).length!==0)return{resolve:{alias:c}}},async configResolved(r){k=o??r.root,r.command==="serve"&&!u&&await Q({root:r.root,logger:{info:n=>r.logger.info(n),warn:n=>r.logger.warn(n)}});const d=i??g.resolve(k,"tsconfig.json");p=j.existsSync(d)?N.createPropsExtractor({tsConfigFilePath:d}):N.createPropsExtractor()},configureServer(r){a=r},buildEnd(){p==null||p.releaseCache()},resolveId(r){if(r===P)return M;if(r===G)return R;if(r.startsWith(F))return"\0"+r},async load(r){if(r===R){const d=k??process.cwd(),n=te(h,d);return n.length===0?`// [jogak] globalCss not configured or no candidates found.
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(c=>`import ${JSON.stringify(c)}`).join(`
3
+ `:`${n.map(i=>`import ${JSON.stringify(i)}`).join(`
4
4
  `)}
5
5
  export {}
6
- `}if(r===M){const n=(await T()).map(f=>f.meta);return`import { defaultRegistry } from '@jogak/core'
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 = ${ue()}
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(I)){const d=r.slice(I.length),n=ie(d);let f=S.get(n);return f===void 0&&(await T(),f=S.get(n)),f===void 0?`// [jogak] unknown entry id: ${JSON.stringify(n)}
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(f)}
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:d}){const n=/\.jogak\.(tsx?|jsx?)$/.test(r),f=/\.(tsx?|jsx?)$/.test(r)&&!n;if(!n&&!f||a===void 0||!n)return;const c=a.moduleGraph.getModuleById(M),v=C.get(r),w=v!==void 0?I+ae(v):void 0,l=w!==void 0?a.moduleGraph.getModuleById(w):void 0;let m=null,x={},A="";if(p!==void 0){try{m=await p.extractMeta(r)}catch{m=null}try{x=await p.extract(r)}catch{x={}}try{A=await _.readFile(r,"utf8")}catch{A=""}}if(m===null){c!==void 0&&a.moduleGraph.invalidateModule(c),l!==void 0&&a.moduleGraph.invalidateModule(l),a.ws.send({type:"full-reload"});return}const O=D(m),U=b.get(r),V=ce(U,O);if(b.set(r,O),!V||v===void 0){c!==void 0&&a.moduleGraph.invalidateModule(c),l!==void 0&&a.moduleGraph.invalidateModule(l),a.ws.send({type:"full-reload"});return}const B={id:v,title:m.title,jogakNames:m.jogakNames,autoArgTypes:x,userArgTypes:m.userArgTypes,source:A,filePath:r,metaExtras:m.metaExtras};l!==void 0&&a.moduleGraph.invalidateModule(l),a.ws.send({type:"custom",event:"jogak:meta-update",data:{id:v,meta:B}});const E=[...d];return l!==void 0&&!E.includes(l)&&E.push(l),E}}}function ue(){return`(rawId) => {
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=le;
47
+ }`}exports.jogak=ue;
@@ -1,83 +1,83 @@
1
- import { resolve as y, join as $, dirname as K } from "node:path";
2
- import { existsSync as b, readFileSync as W } from "node:fs";
3
- import { stat as M, rm as X, readdir as Y, readFile as L } from "node:fs/promises";
4
- import { c as N } from "../extractor-client-CReBed7x.js";
5
- const q = [
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 P(t) {
11
+ async function F(t) {
12
12
  try {
13
- const n = await M(t);
14
- if (!n.isDirectory())
15
- return n.mtimeMs;
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 r = 0, s;
19
+ let o = 0, s;
20
20
  try {
21
- s = await Y(t);
21
+ s = await q(t);
22
22
  } catch {
23
23
  return 0;
24
24
  }
25
- for (const n of s) {
26
- const g = $(t, n);
25
+ for (const a of s) {
26
+ const g = P(t, a);
27
27
  try {
28
- const l = await M(g);
29
- if (l.isDirectory()) {
30
- const p = await P(g);
31
- p > r && (r = p);
32
- } else l.mtimeMs > r && (r = l.mtimeMs);
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 r;
37
+ return o;
38
38
  }
39
- async function H(t) {
40
- const r = y(t.root, "node_modules/.vite/deps");
41
- if (!b(r))
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 = $(r, "_metadata.json");
44
- if (!b(s))
43
+ const s = P(o, "_metadata.json");
44
+ if (!T(s))
45
45
  return { purged: !1 };
46
- let n;
46
+ let a;
47
47
  try {
48
- n = (await M(s)).mtimeMs;
49
- } catch (l) {
48
+ a = (await O(s)).mtimeMs;
49
+ } catch (c) {
50
50
  return t.logger.warn(
51
- `[jogak] cache validation: failed to stat _metadata.json (${l.message})`
51
+ `[jogak] cache validation: failed to stat _metadata.json (${c.message})`
52
52
  ), { purged: !1 };
53
53
  }
54
- const g = t.packages ?? q;
55
- for (const l of g) {
56
- const p = y(t.root, "node_modules", l, "dist");
57
- if (!b(p)) continue;
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 P(p);
61
- } catch (a) {
60
+ h = await F(p);
61
+ } catch (w) {
62
62
  t.logger.warn(
63
- `[jogak] cache validation: failed to walk ${l}/dist (${a.message})`
63
+ `[jogak] cache validation: failed to walk ${c}/dist (${w.message})`
64
64
  );
65
65
  continue;
66
66
  }
67
- if (h > n + 1e3)
67
+ if (h > a + 1e3)
68
68
  try {
69
- return await X(r, { recursive: !0, force: !0 }), t.logger.info(
70
- `[jogak] vite deps cache invalidated (stale): ${l} dist newer than cache`
71
- ), { purged: !0, reason: l };
72
- } catch (a) {
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 ${r} (${a.message})`
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 z = [
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 Q(t) {
91
- for (const r of z) {
92
- const s = y(t, r);
93
- if (b(s)) return [s];
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 Z(t, r) {
97
+ function tt(t, o) {
98
98
  if (t === void 0 || t === !1) return [];
99
- if (t === !0) return Q(r);
99
+ if (t === !0) return Z(o);
100
100
  if (typeof t == "string")
101
- return t.length > 0 ? [y(r, t)] : [];
101
+ return t.length > 0 ? [y(o, t)] : [];
102
102
  const s = [];
103
- for (const n of t)
104
- typeof n == "string" && n.length > 0 && s.push(y(r, n));
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 tt(t) {
107
+ function et(t) {
108
108
  return t.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
109
109
  }
110
- function et(t) {
111
- if (b(t))
110
+ function ot(t) {
111
+ if (T(t))
112
112
  try {
113
- const r = W(t, "utf8");
114
- return JSON.parse(tt(r));
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, r, s) {
120
- if (!t.endsWith("/*") || !r.endsWith("/*")) return;
121
- const n = t.slice(0, -2), g = y(s, r.slice(0, -2));
122
- return [n, g];
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 ot(t, r) {
125
- var g, l;
126
- const s = {}, n = /* @__PURE__ */ new Set([
124
+ function st(t, o) {
125
+ var g, c;
126
+ const s = {}, a = /* @__PURE__ */ new Set([
127
127
  t,
128
- y(r, "tsconfig.app.json")
128
+ y(o, "tsconfig.app.json")
129
129
  ]);
130
- for (const p of n) {
131
- const h = et(p);
130
+ for (const p of a) {
131
+ const h = ot(p);
132
132
  if (h === void 0) continue;
133
- const a = (g = h.compilerOptions) == null ? void 0 : g.paths;
134
- if (a === void 0) continue;
135
- const m = ((l = h.compilerOptions) == null ? void 0 : l.baseUrl) ?? ".", j = y(K(p), m);
136
- for (const [_, C] of Object.entries(a)) {
137
- const k = C[0];
138
- if (k === void 0) continue;
139
- const T = rt(_, k, j);
140
- if (T === void 0) continue;
141
- const [e, u] = T;
142
- s[e] === void 0 && (s[e] = u);
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 F = "virtual:jogak", x = "\0" + F, G = "virtual:jogak/entry/", I = "\0" + G, U = "virtual:jogak/global-css", R = "\0" + U;
148
- function st(t) {
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 at(t) {
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 nt(t, r) {
161
- return t !== void 0 && t.title === r.title && t.jogakNamesKey === r.jogakNamesKey;
160
+ function it(t, o) {
161
+ return t !== void 0 && t.title === o.title && t.jogakNamesKey === o.jogakNamesKey;
162
162
  }
163
- function ft(t = {}) {
163
+ function gt(t = {}) {
164
164
  const {
165
- patterns: r = ["src/**/*.jogak.ts", "src/**/*.jogak.tsx"],
165
+ patterns: o = ["src/**/*.jogak.ts", "src/**/*.jogak.tsx"],
166
166
  codeTheme: s = "vsDark"
167
- } = t, n = t.cwd, g = t.tsConfigFilePath, l = t.disableCacheValidation === !0, p = t.resolveAlias, h = t.globalCss;
168
- let a, m, j;
169
- const _ = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), k = /* @__PURE__ */ new Map();
170
- async function T() {
171
- const { glob: e } = await import("glob"), u = j ?? process.cwd(), o = (await e(r, { cwd: u, absolute: !0 })).sort(), d = [];
172
- _.clear(), C.clear();
173
- for (const i of o) {
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(i, "utf8");
176
+ v = await L(n, "utf8");
177
177
  } catch {
178
178
  continue;
179
179
  }
180
- let w = {}, c = null;
180
+ let j = {}, i = null;
181
181
  if (m !== void 0) {
182
182
  try {
183
- w = await m.extract(i);
183
+ j = await m.extract(n);
184
184
  } catch {
185
- w = {};
185
+ j = {};
186
186
  }
187
187
  try {
188
- c = await m.extractMeta(i);
188
+ i = await m.extractMeta(n);
189
189
  } catch {
190
- c = null;
190
+ i = null;
191
191
  }
192
192
  }
193
- if (c === null) continue;
194
- const f = c.title;
195
- _.set(f, i), C.set(i, f);
196
- const S = {
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: c.title,
199
- jogakNames: c.jogakNames,
200
- autoArgTypes: w,
201
- userArgTypes: c.userArgTypes,
198
+ title: i.title,
199
+ jogakNames: i.jogakNames,
200
+ autoArgTypes: j,
201
+ userArgTypes: i.userArgTypes,
202
202
  source: v,
203
- filePath: i,
204
- metaExtras: c.metaExtras
203
+ filePath: n,
204
+ metaExtras: i.metaExtras
205
205
  };
206
- k.set(i, D(S)), d.push({ id: f, filePath: i, meta: S });
206
+ b.set(n, D(C)), l.push({ id: f, filePath: n, meta: C });
207
207
  }
208
- return d;
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 = n ?? process.cwd(), u = g ?? y(e, "tsconfig.json"), o = ot(u, e), d = {};
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, w] of Object.entries(p))
226
- d[v] = y(e, w);
227
- const i = { ...o, ...d };
228
- if (Object.keys(i).length !== 0)
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: i }
230
+ resolve: { alias: n }
231
231
  };
232
232
  },
233
233
  async configResolved(e) {
234
- j = n ?? e.root, e.command === "serve" && !l && await H({
234
+ _ = a ?? e.root, e.command === "serve" && !c && await z({
235
235
  root: e.root,
236
236
  logger: {
237
- info: (o) => e.logger.info(o),
238
- warn: (o) => e.logger.warn(o)
237
+ info: (r) => e.logger.info(r),
238
+ warn: (r) => e.logger.warn(r)
239
239
  }
240
240
  });
241
- const u = g ?? y(j, "tsconfig.json");
242
- m = b(u) ? N({ tsConfigFilePath: u }) : N();
241
+ const d = g ?? y(_, "tsconfig.json");
242
+ m = T(d) ? R({ tsConfigFilePath: d }) : R();
243
243
  },
244
244
  configureServer(e) {
245
- a = e;
245
+ u = e;
246
246
  },
247
247
  buildEnd() {
248
248
  m == null || m.releaseCache();
249
249
  },
250
250
  resolveId(e) {
251
- if (e === F)
252
- return x;
253
- if (e === U)
254
- return R;
255
- if (e.startsWith(G))
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 === R) {
260
- const u = j ?? process.cwd(), o = Z(h, u);
261
- return o.length === 0 ? `// [jogak] globalCss not configured or no candidates found.
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
- ` : `${o.map((i) => `import ${JSON.stringify(i)}`).join(`
263
+ ` : `${r.map((n) => `import ${JSON.stringify(n)}`).join(`
264
264
  `)}
265
265
  export {}
266
266
  `;
267
267
  }
268
- if (e === x) {
269
- const o = (await T()).map((d) => d.meta);
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 = ${it()}
275
+ const slug = ${ct()}
276
276
  return _entryLoader(slug(id))
277
277
  })
278
278
 
279
- const _metas = ${JSON.stringify(o)}
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(I)) {
288
- const u = e.slice(I.length), o = at(u);
289
- let d = _.get(o);
290
- return d === void 0 && (await T(), d = _.get(o)), d === void 0 ? `// [jogak] unknown entry id: ${JSON.stringify(o)}
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(d)}
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(o)}, _jogaks, _meta?.component)
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: u }) {
312
- const o = /\.jogak\.(tsx?|jsx?)$/.test(e), d = /\.(tsx?|jsx?)$/.test(e) && !o;
313
- if (!o && !d || a === void 0 || !o) return;
314
- const i = a.moduleGraph.getModuleById(
315
- x
316
- ), v = C.get(e), w = v !== void 0 ? I + st(v) : void 0, c = w !== void 0 ? a.moduleGraph.getModuleById(w) : void 0;
317
- let f = null, S = {}, A = "";
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
- S = await m.extract(e);
326
+ C = await m.extract(e);
326
327
  } catch {
327
- S = {};
328
+ C = {};
328
329
  }
329
330
  try {
330
- A = await L(e, "utf8");
331
+ I = await L(e, "utf8");
331
332
  } catch {
332
- A = "";
333
+ I = "";
333
334
  }
334
335
  }
335
336
  if (f === null) {
336
- i !== void 0 && a.moduleGraph.invalidateModule(i), c !== void 0 && a.moduleGraph.invalidateModule(c), a.ws.send({ type: "full-reload" });
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 O = D(f), V = k.get(e), B = nt(V, O);
340
- if (k.set(e, O), !B || v === void 0) {
341
- i !== void 0 && a.moduleGraph.invalidateModule(i), c !== void 0 && a.moduleGraph.invalidateModule(c), a.ws.send({ type: "full-reload" });
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 J = {
345
+ const K = {
345
346
  id: v,
346
347
  title: f.title,
347
348
  jogakNames: f.jogakNames,
348
- autoArgTypes: S,
349
+ autoArgTypes: C,
349
350
  userArgTypes: f.userArgTypes,
350
- source: A,
351
+ source: I,
351
352
  filePath: e,
352
353
  metaExtras: f.metaExtras
353
354
  };
354
- c !== void 0 && a.moduleGraph.invalidateModule(c), a.ws.send({
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: J }
358
+ data: { id: v, meta: K }
358
359
  });
359
- const E = [...u];
360
- return c !== void 0 && !E.includes(c) && E.push(c), E;
360
+ const x = [...d];
361
+ return i !== void 0 && !x.includes(i) && x.push(i), x;
361
362
  }
362
363
  };
363
364
  }
364
- function it() {
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
- ft as jogak
376
+ gt as jogak
376
377
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jogak/core",
3
- "version": "0.1.0-alpha.6",
3
+ "version": "0.1.0-alpha.7.1",
4
4
  "description": "Core types, registry, and Vite plugin for Jogak — a lightweight Storybook alternative.",
5
5
  "keywords": [
6
6
  "jogak",