@jogak/core 0.1.0-alpha.5 → 0.1.0-alpha.6
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/types.d.ts +54 -0
- package/dist/vite/detect-global-css.d.ts +33 -0
- package/dist/vite/index.js +14 -9
- package/dist/vite/index.mjs +201 -163
- package/dist/vite/virtual-ids.d.ts +3 -0
- package/package.json +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -154,4 +154,58 @@ export interface JogakPluginOptions {
|
|
|
154
154
|
* jogak({ resolveAlias: { '@': './src', '@components': './src/components' } })
|
|
155
155
|
*/
|
|
156
156
|
readonly resolveAlias?: Readonly<Record<string, string>>;
|
|
157
|
+
/**
|
|
158
|
+
* 사용자 globalCss를 jogak SPA에 import한다 (알파.6 opt-in).
|
|
159
|
+
*
|
|
160
|
+
* 동기:
|
|
161
|
+
* - `runHost`는 vite root를 `@jogak/ui` 패키지로 두고 사용자 `vite.config.ts`/
|
|
162
|
+
* `main.tsx`를 무시하므로(`configFile: false`), 사용자 `index.css`(Tailwind/
|
|
163
|
+
* shadcn 디자인 토큰)가 jogak SPA에 자동 적용되지 않는다.
|
|
164
|
+
* - 본 옵션이 `true`이거나 명시 경로면 plugin이 사용자 css를 가상 모듈로
|
|
165
|
+
* 주입해 jogak SPA가 import한다.
|
|
166
|
+
*
|
|
167
|
+
* 의미:
|
|
168
|
+
* - `false` (default): 미주입. jogak chrome 기본 스타일만 사용 (알파.4~5 동작 그대로).
|
|
169
|
+
* - `true`: `<userRoot>/src/{index,main,styles,global,app,globals}.css` 후보를
|
|
170
|
+
* 순차 검사해 **첫 발견 1개**만 import. 미발견 시 빈 모듈 (no-op).
|
|
171
|
+
* - `string`: 사용자 root 기준 상대 경로 또는 절대 경로 1개. 자동 감지 비활성화.
|
|
172
|
+
* - `string[]`: 명시 경로 N개를 배열 순서대로 모두 import. 자동 감지 비활성화.
|
|
173
|
+
*
|
|
174
|
+
* 자동 감지 후보 (우선순위 순):
|
|
175
|
+
* 1. `src/index.css` (shadcn/ui Vite)
|
|
176
|
+
* 2. `src/main.css`
|
|
177
|
+
* 3. `src/styles.css`
|
|
178
|
+
* 4. `src/styles/globals.css` (Next.js shadcn)
|
|
179
|
+
* 5. `src/styles/index.css`
|
|
180
|
+
* 6. `src/app/globals.css` (Next.js App Router shadcn)
|
|
181
|
+
* 7. `src/global.css`
|
|
182
|
+
* 8. `src/app.css`
|
|
183
|
+
*
|
|
184
|
+
* 격리:
|
|
185
|
+
* - jogak UI는 알파.4~5에서 Tailwind v4 + `prefix=jogak`로 마이그레이션되어
|
|
186
|
+
* 사용자 utility class와 충돌 zero (예: 사용자 `.bg-primary` ≠ jogak `.jogak\:bg-...`).
|
|
187
|
+
* - jogak CSS variable은 `--jogak-*` prefix → 사용자 `:root { --primary }` 같은
|
|
188
|
+
* 토큰과 namespace 충돌 zero.
|
|
189
|
+
* - 단, 사용자 css의 `*` selector / `body` selector / reset 류는 jogak chrome에
|
|
190
|
+
* 영향 가능. README의 "scope 가이드" 패턴 참조.
|
|
191
|
+
*
|
|
192
|
+
* 한계 (알파.7+ 로드맵):
|
|
193
|
+
* - 사용자 css를 preview 영역으로만 한정하는 Shadow DOM/iframe 격리는 미지원.
|
|
194
|
+
* - `previewIsolation` 옵션은 알파.7+에서 별도 도입.
|
|
195
|
+
* - `globalCss: true` 자동 감지는 dev 시작 시점에 한 번만 수행 — 후보 css 파일이
|
|
196
|
+
* dev 시작 후에 새로 추가되면 dev 서버 재시작이 필요하다. 명시 경로
|
|
197
|
+
* (`globalCss: './src/index.css'`)는 파일이 나중에 생성되어도 정상 hot reload된다.
|
|
198
|
+
*
|
|
199
|
+
* @default false
|
|
200
|
+
*
|
|
201
|
+
* @example 자동 감지
|
|
202
|
+
* jogak({ globalCss: true })
|
|
203
|
+
*
|
|
204
|
+
* @example 명시 경로
|
|
205
|
+
* jogak({ globalCss: './src/index.css' })
|
|
206
|
+
*
|
|
207
|
+
* @example 다중 import (디자인 토큰 + reset 분리)
|
|
208
|
+
* jogak({ globalCss: ['./src/tokens.css', './src/index.css'] })
|
|
209
|
+
*/
|
|
210
|
+
readonly globalCss?: boolean | string | readonly string[];
|
|
157
211
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 사용자 globalCss 자동 감지 + 옵션 정규화 (알파.6, opt-in).
|
|
3
|
+
*
|
|
4
|
+
* 본 모듈은 `JogakPluginOptions.globalCss` 옵션 값을 절대 경로 배열로 변환한다.
|
|
5
|
+
* 자동 감지(`true`)는 첫 발견 1개만 반환 — 다중 import는 명시 배열로 사용자가 선언.
|
|
6
|
+
*
|
|
7
|
+
* 자동 감지 후보(우선순위 순)는 spec `_workspace/01_arch/api-contracts.md` §4.1을 따른다.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* 사용자 globalCss 자동 감지.
|
|
11
|
+
*
|
|
12
|
+
* `<userRoot>/src/...` 후보를 우선순위 순으로 검사해 **첫 발견 1개**만 반환.
|
|
13
|
+
* 미발견 시 빈 배열.
|
|
14
|
+
*
|
|
15
|
+
* 첫 발견 stop 정책:
|
|
16
|
+
* - 사용자가 다중 import를 원하면 명시 배열(`globalCss: ['...', '...']`)을 쓰게 한다.
|
|
17
|
+
* - 자동 감지에서 모든 후보를 import하면 의도치 않은 css 중복(예: index.css와
|
|
18
|
+
* styles.css 둘 다 존재 시)이 발생할 수 있다.
|
|
19
|
+
*/
|
|
20
|
+
export declare function detectUserGlobalCss(userRoot: string): readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* 옵션 값 → 절대 경로 배열로 정규화.
|
|
23
|
+
*
|
|
24
|
+
* - `false`/`undefined`: `[]`
|
|
25
|
+
* - `true`: `detectUserGlobalCss(userRoot)`
|
|
26
|
+
* - `string`: `[resolve(userRoot, string)]`. 빈 문자열은 `[]`.
|
|
27
|
+
* - `string[]`: 각 요소 resolve, 빈 요소 무시 (배열 순서 보존)
|
|
28
|
+
*
|
|
29
|
+
* `existsSync` 검증은 명시 경로(string/string[])에서는 하지 않는다 — 사용자가
|
|
30
|
+
* 의도적으로 빈 파일 또는 동적 css generator를 쓸 수 있고, 미존재 시 Vite가
|
|
31
|
+
* 자체 에러로 알려주는 게 더 명확하다 (silent skip은 디버깅 어려움).
|
|
32
|
+
*/
|
|
33
|
+
export declare function resolveGlobalCssPaths(option: boolean | string | readonly string[] | undefined, userRoot: string): readonly string[];
|
package/dist/vite/index.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
"use strict";var
|
|
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.
|
|
2
|
+
export {}
|
|
3
|
+
`:`${n.map(c=>`import ${JSON.stringify(c)}`).join(`
|
|
4
|
+
`)}
|
|
5
|
+
export {}
|
|
6
|
+
`}if(r===M){const n=(await T()).map(f=>f.meta);return`import { defaultRegistry } from '@jogak/core'
|
|
2
7
|
|
|
3
8
|
const _entryLoader = (slug) =>
|
|
4
9
|
import(/* @vite-ignore */ '/@id/__x00__virtual:jogak/entry/' + slug)
|
|
5
10
|
defaultRegistry.setEntryLoader((id) => {
|
|
6
|
-
const slug = ${
|
|
11
|
+
const slug = ${ue()}
|
|
7
12
|
return _entryLoader(slug(id))
|
|
8
13
|
})
|
|
9
14
|
|
|
10
|
-
const _metas = ${JSON.stringify(
|
|
15
|
+
const _metas = ${JSON.stringify(n)}
|
|
11
16
|
|
|
12
17
|
for (const m of _metas) defaultRegistry.registerMeta(m)
|
|
13
18
|
|
|
14
|
-
export const _jogakCodeTheme = ${JSON.stringify(
|
|
19
|
+
export const _jogakCodeTheme = ${JSON.stringify(s)}
|
|
15
20
|
export const _jogakMetas = _metas
|
|
16
|
-
`}if(
|
|
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)}
|
|
17
22
|
export {}
|
|
18
|
-
`:`import * as _user from ${JSON.stringify(
|
|
23
|
+
`:`import * as _user from ${JSON.stringify(f)}
|
|
19
24
|
import { defaultRegistry } from '@jogak/core'
|
|
20
25
|
|
|
21
26
|
const _meta = _user.default
|
|
@@ -24,18 +29,18 @@ delete _named.default
|
|
|
24
29
|
const _jogaks = Object.values(_named).filter(
|
|
25
30
|
(v) => v !== null && typeof v === 'object' && typeof v.name === 'string'
|
|
26
31
|
)
|
|
27
|
-
defaultRegistry.hydrateEntry(${JSON.stringify(
|
|
32
|
+
defaultRegistry.hydrateEntry(${JSON.stringify(n)}, _jogaks, _meta?.component)
|
|
28
33
|
|
|
29
34
|
if (import.meta.hot) {
|
|
30
35
|
import.meta.hot.accept()
|
|
31
36
|
}
|
|
32
37
|
|
|
33
38
|
export {}
|
|
34
|
-
`}},async handleHotUpdate({file:
|
|
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) => {
|
|
35
40
|
if (typeof Buffer !== 'undefined') return Buffer.from(rawId, 'utf8').toString('base64url')
|
|
36
41
|
// 브라우저 폴백: btoa는 binary string 기준이라 UTF-8을 한번 인코딩해야 한다.
|
|
37
42
|
const enc = new TextEncoder().encode(rawId)
|
|
38
43
|
let bin = ''
|
|
39
44
|
for (let i = 0; i < enc.length; i++) bin += String.fromCharCode(enc[i])
|
|
40
45
|
return btoa(bin).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '')
|
|
41
|
-
}`}exports.jogak=
|
|
46
|
+
}`}exports.jogak=le;
|
package/dist/vite/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { resolve as
|
|
2
|
-
import { existsSync as
|
|
3
|
-
import { stat as
|
|
4
|
-
import { c as
|
|
5
|
-
const
|
|
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 = [
|
|
6
6
|
"@jogak/core",
|
|
7
7
|
"@jogak/react",
|
|
8
8
|
"@jogak/web-components",
|
|
@@ -10,175 +10,202 @@ const W = [
|
|
|
10
10
|
];
|
|
11
11
|
async function P(t) {
|
|
12
12
|
try {
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
15
|
-
return
|
|
13
|
+
const n = await M(t);
|
|
14
|
+
if (!n.isDirectory())
|
|
15
|
+
return n.mtimeMs;
|
|
16
16
|
} catch {
|
|
17
17
|
return 0;
|
|
18
18
|
}
|
|
19
|
-
let
|
|
19
|
+
let r = 0, s;
|
|
20
20
|
try {
|
|
21
|
-
|
|
21
|
+
s = await Y(t);
|
|
22
22
|
} catch {
|
|
23
23
|
return 0;
|
|
24
24
|
}
|
|
25
|
-
for (const
|
|
26
|
-
const
|
|
25
|
+
for (const n of s) {
|
|
26
|
+
const g = $(t, n);
|
|
27
27
|
try {
|
|
28
|
-
const
|
|
29
|
-
if (
|
|
30
|
-
const p = await P(
|
|
31
|
-
p >
|
|
32
|
-
} else
|
|
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);
|
|
33
33
|
} catch {
|
|
34
34
|
continue;
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return r;
|
|
38
38
|
}
|
|
39
|
-
async function
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
39
|
+
async function H(t) {
|
|
40
|
+
const r = y(t.root, "node_modules/.vite/deps");
|
|
41
|
+
if (!b(r))
|
|
42
42
|
return { purged: !1 };
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
43
|
+
const s = $(r, "_metadata.json");
|
|
44
|
+
if (!b(s))
|
|
45
45
|
return { purged: !1 };
|
|
46
|
-
let
|
|
46
|
+
let n;
|
|
47
47
|
try {
|
|
48
|
-
|
|
49
|
-
} catch (
|
|
48
|
+
n = (await M(s)).mtimeMs;
|
|
49
|
+
} catch (l) {
|
|
50
50
|
return t.logger.warn(
|
|
51
|
-
`[jogak] cache validation: failed to stat _metadata.json (${
|
|
51
|
+
`[jogak] cache validation: failed to stat _metadata.json (${l.message})`
|
|
52
52
|
), { purged: !1 };
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
for (const
|
|
56
|
-
const p =
|
|
57
|
-
if (!
|
|
58
|
-
let
|
|
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;
|
|
58
|
+
let h;
|
|
59
59
|
try {
|
|
60
|
-
|
|
61
|
-
} catch (
|
|
60
|
+
h = await P(p);
|
|
61
|
+
} catch (a) {
|
|
62
62
|
t.logger.warn(
|
|
63
|
-
`[jogak] cache validation: failed to walk ${
|
|
63
|
+
`[jogak] cache validation: failed to walk ${l}/dist (${a.message})`
|
|
64
64
|
);
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
|
-
if (
|
|
67
|
+
if (h > n + 1e3)
|
|
68
68
|
try {
|
|
69
|
-
return await
|
|
70
|
-
`[jogak] vite deps cache invalidated (stale): ${
|
|
71
|
-
), { purged: !0, reason:
|
|
72
|
-
} catch (
|
|
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) {
|
|
73
73
|
return t.logger.warn(
|
|
74
|
-
`[jogak] cache validation: failed to purge ${
|
|
74
|
+
`[jogak] cache validation: failed to purge ${r} (${a.message})`
|
|
75
75
|
), { purged: !1 };
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
return { purged: !1 };
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
const z = [
|
|
81
|
+
"src/index.css",
|
|
82
|
+
"src/main.css",
|
|
83
|
+
"src/styles.css",
|
|
84
|
+
"src/styles/globals.css",
|
|
85
|
+
"src/styles/index.css",
|
|
86
|
+
"src/app/globals.css",
|
|
87
|
+
"src/global.css",
|
|
88
|
+
"src/app.css"
|
|
89
|
+
];
|
|
90
|
+
function Q(t) {
|
|
91
|
+
for (const r of z) {
|
|
92
|
+
const s = y(t, r);
|
|
93
|
+
if (b(s)) return [s];
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
function Z(t, r) {
|
|
98
|
+
if (t === void 0 || t === !1) return [];
|
|
99
|
+
if (t === !0) return Q(r);
|
|
100
|
+
if (typeof t == "string")
|
|
101
|
+
return t.length > 0 ? [y(r, t)] : [];
|
|
102
|
+
const s = [];
|
|
103
|
+
for (const n of t)
|
|
104
|
+
typeof n == "string" && n.length > 0 && s.push(y(r, n));
|
|
105
|
+
return s;
|
|
106
|
+
}
|
|
107
|
+
function tt(t) {
|
|
81
108
|
return t.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
|
|
82
109
|
}
|
|
83
|
-
function
|
|
84
|
-
if (
|
|
110
|
+
function et(t) {
|
|
111
|
+
if (b(t))
|
|
85
112
|
try {
|
|
86
|
-
const
|
|
87
|
-
return JSON.parse(
|
|
113
|
+
const r = W(t, "utf8");
|
|
114
|
+
return JSON.parse(tt(r));
|
|
88
115
|
} catch {
|
|
89
116
|
return;
|
|
90
117
|
}
|
|
91
118
|
}
|
|
92
|
-
function
|
|
93
|
-
if (!t.endsWith("/*") || !
|
|
94
|
-
const
|
|
95
|
-
return [
|
|
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];
|
|
96
123
|
}
|
|
97
|
-
function
|
|
98
|
-
var
|
|
99
|
-
const
|
|
124
|
+
function ot(t, r) {
|
|
125
|
+
var g, l;
|
|
126
|
+
const s = {}, n = /* @__PURE__ */ new Set([
|
|
100
127
|
t,
|
|
101
|
-
|
|
128
|
+
y(r, "tsconfig.app.json")
|
|
102
129
|
]);
|
|
103
|
-
for (const p of
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
if (
|
|
108
|
-
const
|
|
109
|
-
for (const [_,
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
const [
|
|
115
|
-
|
|
130
|
+
for (const p of n) {
|
|
131
|
+
const h = et(p);
|
|
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);
|
|
116
143
|
}
|
|
117
144
|
}
|
|
118
|
-
return
|
|
145
|
+
return s;
|
|
119
146
|
}
|
|
120
|
-
const
|
|
121
|
-
function
|
|
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) {
|
|
122
149
|
return Buffer.from(t, "utf8").toString("base64url");
|
|
123
150
|
}
|
|
124
|
-
function
|
|
151
|
+
function at(t) {
|
|
125
152
|
return Buffer.from(t, "base64url").toString("utf8");
|
|
126
153
|
}
|
|
127
|
-
function
|
|
154
|
+
function D(t) {
|
|
128
155
|
return {
|
|
129
156
|
title: t.title,
|
|
130
157
|
jogakNamesKey: [...t.jogakNames].sort().join("|")
|
|
131
158
|
};
|
|
132
159
|
}
|
|
133
|
-
function
|
|
134
|
-
return t !== void 0 && t.title ===
|
|
160
|
+
function nt(t, r) {
|
|
161
|
+
return t !== void 0 && t.title === r.title && t.jogakNamesKey === r.jogakNamesKey;
|
|
135
162
|
}
|
|
136
|
-
function
|
|
163
|
+
function ft(t = {}) {
|
|
137
164
|
const {
|
|
138
|
-
patterns:
|
|
139
|
-
codeTheme:
|
|
140
|
-
} = t,
|
|
141
|
-
let
|
|
142
|
-
const
|
|
143
|
-
async function
|
|
144
|
-
const { glob: e } = await import("glob"),
|
|
145
|
-
|
|
146
|
-
for (const
|
|
147
|
-
let
|
|
165
|
+
patterns: r = ["src/**/*.jogak.ts", "src/**/*.jogak.tsx"],
|
|
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) {
|
|
174
|
+
let v = "";
|
|
148
175
|
try {
|
|
149
|
-
|
|
176
|
+
v = await L(i, "utf8");
|
|
150
177
|
} catch {
|
|
151
178
|
continue;
|
|
152
179
|
}
|
|
153
|
-
let
|
|
154
|
-
if (
|
|
180
|
+
let w = {}, c = null;
|
|
181
|
+
if (m !== void 0) {
|
|
155
182
|
try {
|
|
156
|
-
|
|
183
|
+
w = await m.extract(i);
|
|
157
184
|
} catch {
|
|
158
|
-
|
|
185
|
+
w = {};
|
|
159
186
|
}
|
|
160
187
|
try {
|
|
161
|
-
|
|
188
|
+
c = await m.extractMeta(i);
|
|
162
189
|
} catch {
|
|
163
|
-
|
|
190
|
+
c = null;
|
|
164
191
|
}
|
|
165
192
|
}
|
|
166
|
-
if (
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
const
|
|
170
|
-
id:
|
|
171
|
-
title:
|
|
172
|
-
jogakNames:
|
|
173
|
-
autoArgTypes:
|
|
174
|
-
userArgTypes:
|
|
175
|
-
source:
|
|
176
|
-
filePath:
|
|
177
|
-
metaExtras:
|
|
193
|
+
if (c === null) continue;
|
|
194
|
+
const f = c.title;
|
|
195
|
+
_.set(f, i), C.set(i, f);
|
|
196
|
+
const S = {
|
|
197
|
+
id: f,
|
|
198
|
+
title: c.title,
|
|
199
|
+
jogakNames: c.jogakNames,
|
|
200
|
+
autoArgTypes: w,
|
|
201
|
+
userArgTypes: c.userArgTypes,
|
|
202
|
+
source: v,
|
|
203
|
+
filePath: i,
|
|
204
|
+
metaExtras: c.metaExtras
|
|
178
205
|
};
|
|
179
|
-
|
|
206
|
+
k.set(i, D(S)), d.push({ id: f, filePath: i, meta: S });
|
|
180
207
|
}
|
|
181
|
-
return
|
|
208
|
+
return d;
|
|
182
209
|
}
|
|
183
210
|
return {
|
|
184
211
|
name: "vite-plugin-jogak",
|
|
@@ -193,65 +220,76 @@ function it(t = {}) {
|
|
|
193
220
|
* 우선순위: `options.resolveAlias` (명시) > tsconfig 자동 추출.
|
|
194
221
|
*/
|
|
195
222
|
config() {
|
|
196
|
-
const e =
|
|
223
|
+
const e = n ?? process.cwd(), u = g ?? y(e, "tsconfig.json"), o = ot(u, e), d = {};
|
|
197
224
|
if (p !== void 0)
|
|
198
|
-
for (const [
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
if (Object.keys(
|
|
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)
|
|
202
229
|
return {
|
|
203
|
-
resolve: { alias:
|
|
230
|
+
resolve: { alias: i }
|
|
204
231
|
};
|
|
205
232
|
},
|
|
206
233
|
async configResolved(e) {
|
|
207
|
-
|
|
234
|
+
j = n ?? e.root, e.command === "serve" && !l && await H({
|
|
208
235
|
root: e.root,
|
|
209
236
|
logger: {
|
|
210
|
-
info: (
|
|
211
|
-
warn: (
|
|
237
|
+
info: (o) => e.logger.info(o),
|
|
238
|
+
warn: (o) => e.logger.warn(o)
|
|
212
239
|
}
|
|
213
240
|
});
|
|
214
|
-
const
|
|
215
|
-
|
|
241
|
+
const u = g ?? y(j, "tsconfig.json");
|
|
242
|
+
m = b(u) ? N({ tsConfigFilePath: u }) : N();
|
|
216
243
|
},
|
|
217
244
|
configureServer(e) {
|
|
218
|
-
|
|
245
|
+
a = e;
|
|
219
246
|
},
|
|
220
247
|
buildEnd() {
|
|
221
|
-
|
|
248
|
+
m == null || m.releaseCache();
|
|
222
249
|
},
|
|
223
250
|
resolveId(e) {
|
|
224
|
-
if (e ===
|
|
251
|
+
if (e === F)
|
|
225
252
|
return x;
|
|
226
|
-
if (e
|
|
253
|
+
if (e === U)
|
|
254
|
+
return R;
|
|
255
|
+
if (e.startsWith(G))
|
|
227
256
|
return "\0" + e;
|
|
228
257
|
},
|
|
229
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.
|
|
262
|
+
export {}
|
|
263
|
+
` : `${o.map((i) => `import ${JSON.stringify(i)}`).join(`
|
|
264
|
+
`)}
|
|
265
|
+
export {}
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
230
268
|
if (e === x) {
|
|
231
|
-
const
|
|
269
|
+
const o = (await T()).map((d) => d.meta);
|
|
232
270
|
return `import { defaultRegistry } from '@jogak/core'
|
|
233
271
|
|
|
234
272
|
const _entryLoader = (slug) =>
|
|
235
273
|
import(/* @vite-ignore */ '/@id/__x00__virtual:jogak/entry/' + slug)
|
|
236
274
|
defaultRegistry.setEntryLoader((id) => {
|
|
237
|
-
const slug = ${
|
|
275
|
+
const slug = ${it()}
|
|
238
276
|
return _entryLoader(slug(id))
|
|
239
277
|
})
|
|
240
278
|
|
|
241
|
-
const _metas = ${JSON.stringify(
|
|
279
|
+
const _metas = ${JSON.stringify(o)}
|
|
242
280
|
|
|
243
281
|
for (const m of _metas) defaultRegistry.registerMeta(m)
|
|
244
282
|
|
|
245
|
-
export const _jogakCodeTheme = ${JSON.stringify(
|
|
283
|
+
export const _jogakCodeTheme = ${JSON.stringify(s)}
|
|
246
284
|
export const _jogakMetas = _metas
|
|
247
285
|
`;
|
|
248
286
|
}
|
|
249
|
-
if (e.startsWith(
|
|
250
|
-
const
|
|
251
|
-
let
|
|
252
|
-
return
|
|
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)}
|
|
253
291
|
export {}
|
|
254
|
-
` : `import * as _user from ${JSON.stringify(
|
|
292
|
+
` : `import * as _user from ${JSON.stringify(d)}
|
|
255
293
|
import { defaultRegistry } from '@jogak/core'
|
|
256
294
|
|
|
257
295
|
const _meta = _user.default
|
|
@@ -260,7 +298,7 @@ delete _named.default
|
|
|
260
298
|
const _jogaks = Object.values(_named).filter(
|
|
261
299
|
(v) => v !== null && typeof v === 'object' && typeof v.name === 'string'
|
|
262
300
|
)
|
|
263
|
-
defaultRegistry.hydrateEntry(${JSON.stringify(
|
|
301
|
+
defaultRegistry.hydrateEntry(${JSON.stringify(o)}, _jogaks, _meta?.component)
|
|
264
302
|
|
|
265
303
|
if (import.meta.hot) {
|
|
266
304
|
import.meta.hot.accept()
|
|
@@ -270,60 +308,60 @@ export {}
|
|
|
270
308
|
`;
|
|
271
309
|
}
|
|
272
310
|
},
|
|
273
|
-
async handleHotUpdate({ file: e, modules:
|
|
274
|
-
const
|
|
275
|
-
if (!
|
|
276
|
-
const
|
|
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(
|
|
277
315
|
x
|
|
278
|
-
),
|
|
279
|
-
let
|
|
280
|
-
if (
|
|
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 = "";
|
|
318
|
+
if (m !== void 0) {
|
|
281
319
|
try {
|
|
282
|
-
|
|
320
|
+
f = await m.extractMeta(e);
|
|
283
321
|
} catch {
|
|
284
|
-
|
|
322
|
+
f = null;
|
|
285
323
|
}
|
|
286
324
|
try {
|
|
287
|
-
|
|
325
|
+
S = await m.extract(e);
|
|
288
326
|
} catch {
|
|
289
|
-
|
|
327
|
+
S = {};
|
|
290
328
|
}
|
|
291
329
|
try {
|
|
292
|
-
|
|
330
|
+
A = await L(e, "utf8");
|
|
293
331
|
} catch {
|
|
294
|
-
|
|
332
|
+
A = "";
|
|
295
333
|
}
|
|
296
334
|
}
|
|
297
|
-
if (
|
|
298
|
-
|
|
335
|
+
if (f === null) {
|
|
336
|
+
i !== void 0 && a.moduleGraph.invalidateModule(i), c !== void 0 && a.moduleGraph.invalidateModule(c), a.ws.send({ type: "full-reload" });
|
|
299
337
|
return;
|
|
300
338
|
}
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
|
|
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" });
|
|
304
342
|
return;
|
|
305
343
|
}
|
|
306
|
-
const
|
|
307
|
-
id:
|
|
308
|
-
title:
|
|
309
|
-
jogakNames:
|
|
310
|
-
autoArgTypes:
|
|
311
|
-
userArgTypes:
|
|
312
|
-
source:
|
|
344
|
+
const J = {
|
|
345
|
+
id: v,
|
|
346
|
+
title: f.title,
|
|
347
|
+
jogakNames: f.jogakNames,
|
|
348
|
+
autoArgTypes: S,
|
|
349
|
+
userArgTypes: f.userArgTypes,
|
|
350
|
+
source: A,
|
|
313
351
|
filePath: e,
|
|
314
|
-
metaExtras:
|
|
352
|
+
metaExtras: f.metaExtras
|
|
315
353
|
};
|
|
316
|
-
|
|
354
|
+
c !== void 0 && a.moduleGraph.invalidateModule(c), a.ws.send({
|
|
317
355
|
type: "custom",
|
|
318
356
|
event: "jogak:meta-update",
|
|
319
|
-
data: { id:
|
|
357
|
+
data: { id: v, meta: J }
|
|
320
358
|
});
|
|
321
|
-
const
|
|
322
|
-
return
|
|
359
|
+
const E = [...u];
|
|
360
|
+
return c !== void 0 && !E.includes(c) && E.push(c), E;
|
|
323
361
|
}
|
|
324
362
|
};
|
|
325
363
|
}
|
|
326
|
-
function
|
|
364
|
+
function it() {
|
|
327
365
|
return `(rawId) => {
|
|
328
366
|
if (typeof Buffer !== 'undefined') return Buffer.from(rawId, 'utf8').toString('base64url')
|
|
329
367
|
// 브라우저 폴백: btoa는 binary string 기준이라 UTF-8을 한번 인코딩해야 한다.
|
|
@@ -334,5 +372,5 @@ function et() {
|
|
|
334
372
|
}`;
|
|
335
373
|
}
|
|
336
374
|
export {
|
|
337
|
-
|
|
375
|
+
ft as jogak
|
|
338
376
|
};
|
|
@@ -15,5 +15,8 @@ export declare const RESOLVED_VIRTUAL_INDEX_ID: string;
|
|
|
15
15
|
/** Entry 모듈 prefix — 뒤에 base64url(id)이 붙는다. */
|
|
16
16
|
export declare const VIRTUAL_ENTRY_PREFIX = "virtual:jogak/entry/";
|
|
17
17
|
export declare const RESOLVED_VIRTUAL_ENTRY_PREFIX: string;
|
|
18
|
+
/** Global css 모듈 — 사용자 globalCss를 import한다 (알파.6, opt-in). */
|
|
19
|
+
export declare const VIRTUAL_GLOBAL_CSS_ID = "virtual:jogak/global-css";
|
|
20
|
+
export declare const RESOLVED_VIRTUAL_GLOBAL_CSS_ID: string;
|
|
18
21
|
export declare function idToSlug(id: string): string;
|
|
19
22
|
export declare function slugToId(slug: string): string;
|