@jogak/core 0.1.0-alpha.8 → 0.1.0-alpha.9

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.
@@ -1,51 +1,52 @@
1
- import { resolve as y, join as B, dirname as q } from "node:path";
2
- import { existsSync as S, readFileSync as tt } from "node:fs";
3
- import { stat as x, rm as et, readdir as rt, readFile as P } from "node:fs/promises";
4
- import { c as D } from "../extractor-client-CReBed7x.js";
1
+ import { resolve as _, join as B, dirname as tt } from "node:path";
2
+ import { existsSync as S, readFileSync as et } from "node:fs";
3
+ import { stat as L, rm as rt, readdir as ot, readFile as U } from "node:fs/promises";
4
+ import { r as W } from "../detect-global-css-CIVMmgzy.js";
5
+ import { c as $ } from "../extractor-client-CReBed7x.js";
5
6
  const nt = [
6
7
  "@jogak/core",
7
8
  "@jogak/react",
8
9
  "@jogak/web-components",
9
10
  "@jogak/next"
10
11
  ];
11
- async function J(t) {
12
+ async function K(t) {
12
13
  try {
13
- const o = await x(t);
14
- if (!o.isDirectory())
15
- return o.mtimeMs;
14
+ const a = await L(t);
15
+ if (!a.isDirectory())
16
+ return a.mtimeMs;
16
17
  } catch {
17
18
  return 0;
18
19
  }
19
- let e = 0, n;
20
+ let r = 0, o;
20
21
  try {
21
- n = await rt(t);
22
+ o = await ot(t);
22
23
  } catch {
23
24
  return 0;
24
25
  }
25
- for (const o of n) {
26
- const c = B(t, o);
26
+ for (const a of o) {
27
+ const c = B(t, a);
27
28
  try {
28
- const l = await x(c);
29
+ const l = await L(c);
29
30
  if (l.isDirectory()) {
30
- const g = await J(c);
31
- g > e && (e = g);
32
- } else l.mtimeMs > e && (e = l.mtimeMs);
31
+ const g = await K(c);
32
+ g > r && (r = g);
33
+ } else l.mtimeMs > r && (r = l.mtimeMs);
33
34
  } catch {
34
35
  continue;
35
36
  }
36
37
  }
37
- return e;
38
+ return r;
38
39
  }
39
- async function ot(t) {
40
- const e = y(t.root, "node_modules/.vite/deps");
41
- if (!S(e))
40
+ async function at(t) {
41
+ const r = _(t.root, "node_modules/.vite/deps");
42
+ if (!S(r))
42
43
  return { purged: !1 };
43
- const n = B(e, "_metadata.json");
44
- if (!S(n))
44
+ const o = B(r, "_metadata.json");
45
+ if (!S(o))
45
46
  return { purged: !1 };
46
- let o;
47
+ let a;
47
48
  try {
48
- o = (await x(n)).mtimeMs;
49
+ a = (await L(o)).mtimeMs;
49
50
  } catch (l) {
50
51
  return t.logger.warn(
51
52
  `[jogak] cache validation: failed to stat _metadata.json (${l.message})`
@@ -53,138 +54,111 @@ async function ot(t) {
53
54
  }
54
55
  const c = t.packages ?? nt;
55
56
  for (const l of c) {
56
- const g = y(t.root, "node_modules", l, "dist");
57
+ const g = _(t.root, "node_modules", l, "dist");
57
58
  if (!S(g)) continue;
58
- let v;
59
+ let y;
59
60
  try {
60
- v = await J(g);
61
+ y = await K(g);
61
62
  } catch (w) {
62
63
  t.logger.warn(
63
64
  `[jogak] cache validation: failed to walk ${l}/dist (${w.message})`
64
65
  );
65
66
  continue;
66
67
  }
67
- if (v > o + 1e3)
68
+ if (y > a + 1e3)
68
69
  try {
69
- return await et(e, { recursive: !0, force: !0 }), t.logger.info(
70
+ return await rt(r, { recursive: !0, force: !0 }), t.logger.info(
70
71
  `[jogak] vite deps cache invalidated (stale): ${l} dist newer than cache`
71
72
  ), { purged: !0, reason: l };
72
73
  } catch (w) {
73
74
  return t.logger.warn(
74
- `[jogak] cache validation: failed to purge ${e} (${w.message})`
75
+ `[jogak] cache validation: failed to purge ${r} (${w.message})`
75
76
  ), { purged: !1 };
76
77
  }
77
78
  }
78
79
  return { purged: !1 };
79
80
  }
80
- const at = [
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 st(t) {
91
- for (const e of at) {
92
- const n = y(t, e);
93
- if (S(n)) return [n];
94
- }
95
- return [];
96
- }
97
- function W(t, e) {
98
- if (t === void 0 || t === !1) return [];
99
- if (t === !0) return st(e);
100
- if (typeof t == "string")
101
- return t.length > 0 ? [y(e, t)] : [];
102
- const n = [];
103
- for (const o of t)
104
- typeof o == "string" && o.length > 0 && n.push(y(e, o));
105
- return n;
106
- }
107
81
  function it(t) {
108
82
  return t.replace(/\/\*[\s\S]*?\*\//g, "").replace(/^\s*\/\/.*$/gm, "");
109
83
  }
110
- function ct(t) {
84
+ function st(t) {
111
85
  if (S(t))
112
86
  try {
113
- const e = tt(t, "utf8");
114
- return JSON.parse(it(e));
87
+ const r = et(t, "utf8");
88
+ return JSON.parse(it(r));
115
89
  } catch {
116
90
  return;
117
91
  }
118
92
  }
119
- function lt(t, e, n) {
120
- if (!t.endsWith("/*") || !e.endsWith("/*")) return;
121
- const o = t.slice(0, -2), c = y(n, e.slice(0, -2));
122
- return [o, c];
93
+ function ct(t, r, o) {
94
+ if (!t.endsWith("/*") || !r.endsWith("/*")) return;
95
+ const a = t.slice(0, -2), c = _(o, r.slice(0, -2));
96
+ return [a, c];
123
97
  }
124
- function ut(t, e) {
98
+ function lt(t, r) {
125
99
  var c, l;
126
- const n = {}, o = /* @__PURE__ */ new Set([
100
+ const o = {}, a = /* @__PURE__ */ new Set([
127
101
  t,
128
- y(e, "tsconfig.app.json")
102
+ _(r, "tsconfig.app.json")
129
103
  ]);
130
- for (const g of o) {
131
- const v = ct(g);
132
- if (v === void 0) continue;
133
- const w = (c = v.compilerOptions) == null ? void 0 : c.paths;
104
+ for (const g of a) {
105
+ const y = st(g);
106
+ if (y === void 0) continue;
107
+ const w = (c = y.compilerOptions) == null ? void 0 : c.paths;
134
108
  if (w === void 0) continue;
135
- const b = ((l = v.compilerOptions) == null ? void 0 : l.baseUrl) ?? ".", T = y(q(g), b);
136
- for (const [d, p] of Object.entries(w)) {
137
- const _ = p[0];
138
- if (_ === void 0) continue;
139
- const k = lt(d, _, T);
140
- if (k === void 0) continue;
141
- const [E, C] = k;
142
- n[E] === void 0 && (n[E] = C);
109
+ const R = ((l = y.compilerOptions) == null ? void 0 : l.baseUrl) ?? ".", C = _(tt(g), R);
110
+ for (const [T, d] of Object.entries(w)) {
111
+ const f = d[0];
112
+ if (f === void 0) continue;
113
+ const j = ct(T, f, C);
114
+ if (j === void 0) continue;
115
+ const [k, I] = j;
116
+ o[k] === void 0 && (o[k] = I);
143
117
  }
144
118
  }
145
- return n;
119
+ return o;
146
120
  }
147
- const K = "virtual:jogak", L = "\0" + K, H = "virtual:jogak/entry/", O = "\0" + H, Y = "virtual:jogak/global-css", U = "\0" + Y, M = "virtual:jogak/preview-entry", $ = "\0" + M, X = "virtual:jogak/preview-global-css", F = "\0" + X;
148
- function dt(t) {
121
+ const H = "virtual:jogak", x = "\0" + H, Y = "virtual:jogak/entry/", P = "\0" + Y, X = "virtual:jogak/global-css", D = "\0" + X, M = "virtual:jogak/preview-entry", F = "\0" + M, z = "virtual:jogak/preview-global-css", G = "\0" + z;
122
+ function ut(t) {
149
123
  return Buffer.from(t, "utf8").toString("base64url");
150
124
  }
151
- function gt(t) {
125
+ function dt(t) {
152
126
  return Buffer.from(t, "base64url").toString("utf8");
153
127
  }
154
- const ft = "/__jogak_preview__/index.html";
128
+ const gt = "/__jogak_preview__/index.html";
155
129
  function kt(t) {
156
130
  return {
157
131
  name: "vite-plugin-jogak-preview-frame",
158
132
  enforce: "pre",
159
- configureServer(e) {
160
- e.middlewares.use((n, o, c) => {
161
- if (n.url === void 0 || n.url.split("?")[0] !== ft || n.method !== "GET") return c();
162
- const g = mt();
163
- e.transformIndexHtml(n.url, g).then((v) => {
164
- o.statusCode = 200, o.setHeader("Content-Type", "text/html; charset=utf-8"), o.end(v);
133
+ configureServer(r) {
134
+ r.middlewares.use((o, a, c) => {
135
+ if (o.url === void 0 || o.url.split("?")[0] !== gt || o.method !== "GET") return c();
136
+ const g = ft();
137
+ r.transformIndexHtml(o.url, g).then((y) => {
138
+ a.statusCode = 200, a.setHeader("Content-Type", "text/html; charset=utf-8"), a.end(y);
165
139
  }).catch(c);
166
140
  });
167
141
  },
168
- resolveId(e) {
169
- if (e === M) return $;
170
- if (e === X) return F;
142
+ resolveId(r) {
143
+ if (r === M) return F;
144
+ if (r === z) return G;
171
145
  },
172
- load(e) {
173
- if (e === F) {
174
- const n = W(t.globalCss, t.userRoot);
175
- return n.length === 0 ? `// [jogak] preview-global-css: no candidates
146
+ load(r) {
147
+ if (r === G) {
148
+ const o = W(t.globalCss, t.userRoot);
149
+ return o.length === 0 ? `// [jogak] preview-global-css: no candidates
176
150
  export {}
177
- ` : n.map((o) => `import ${JSON.stringify(o)}`).join(`
151
+ ` : o.map((a) => `import ${JSON.stringify(a)}`).join(`
178
152
  `) + `
179
153
  export {}
180
154
  `;
181
155
  }
182
- if (e === $)
183
- return pt;
156
+ if (r === F)
157
+ return mt;
184
158
  }
185
159
  };
186
160
  }
187
- function mt() {
161
+ function ft() {
188
162
  return `<!doctype html>
189
163
  <html lang="en">
190
164
  <head>
@@ -203,7 +177,7 @@ function mt() {
203
177
  </html>
204
178
  `;
205
179
  }
206
- const pt = `
180
+ const mt = `
207
181
  import { reactAdapter } from '@jogak/react'
208
182
  import { defaultRegistry } from '@jogak/core'
209
183
  import 'virtual:jogak'
@@ -251,59 +225,59 @@ window.addEventListener('message', (event) => {
251
225
 
252
226
  window.parent.postMessage({ type: 'jogak:ready' }, '*')
253
227
  `;
254
- function G(t) {
228
+ function J(t) {
255
229
  return {
256
230
  title: t.title,
257
231
  jogakNamesKey: [...t.jogakNames].sort().join("|")
258
232
  };
259
233
  }
260
- function yt(t, e) {
261
- return t !== void 0 && t.title === e.title && t.jogakNamesKey === e.jogakNamesKey;
234
+ function pt(t, r) {
235
+ return t !== void 0 && t.title === r.title && t.jogakNamesKey === r.jogakNamesKey;
262
236
  }
263
237
  function Et(t = {}) {
264
238
  const {
265
- patterns: e = ["src/**/*.jogak.ts", "src/**/*.jogak.tsx"],
266
- codeTheme: n = "vsDark"
267
- } = t, o = t.cwd, c = t.tsConfigFilePath, l = t.disableCacheValidation === !0, g = t.resolveAlias, v = t.globalCss, w = t.previewIsolation ?? "iframe", b = t.previewFrame === !0, T = t.userViteUrl ?? "";
268
- let d, p, _;
269
- const k = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
270
- async function V() {
271
- const { glob: r } = await import("glob"), f = _ ?? process.cwd(), a = (await r(e, { cwd: f, absolute: !0 })).sort(), u = [];
272
- k.clear(), E.clear();
273
- for (const s of a) {
274
- let h = "";
239
+ patterns: r = ["src/**/*.jogak.ts", "src/**/*.jogak.tsx"],
240
+ codeTheme: o = "vsDark"
241
+ } = t, a = t.cwd, c = t.tsConfigFilePath, l = t.disableCacheValidation === !0, g = t.resolveAlias, y = t.globalCss, w = t.previewIsolation ?? "iframe", R = t.previewFrame === !0, C = t.userPreviewUrl ?? t.userViteUrl ?? "", T = t.previewEntryPath ?? "/__jogak_preview__/index.html";
242
+ let d, f, j;
243
+ const k = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
244
+ async function N() {
245
+ const { glob: e } = await import("glob"), m = j ?? process.cwd(), n = (await e(r, { cwd: m, absolute: !0 })).sort(), u = [];
246
+ k.clear(), I.clear();
247
+ for (const i of n) {
248
+ let v = "";
275
249
  try {
276
- h = await P(s, "utf8");
250
+ v = await U(i, "utf8");
277
251
  } catch {
278
252
  continue;
279
253
  }
280
- let j = {}, i = null;
281
- if (p !== void 0) {
254
+ let h = {}, s = null;
255
+ if (f !== void 0) {
282
256
  try {
283
- j = await p.extract(s);
257
+ h = await f.extract(i);
284
258
  } catch {
285
- j = {};
259
+ h = {};
286
260
  }
287
261
  try {
288
- i = await p.extractMeta(s);
262
+ s = await f.extractMeta(i);
289
263
  } catch {
290
- i = null;
264
+ s = null;
291
265
  }
292
266
  }
293
- if (i === null) continue;
294
- const m = i.title;
295
- k.set(m, s), E.set(s, m);
296
- const I = {
297
- id: m,
298
- title: i.title,
299
- jogakNames: i.jogakNames,
300
- autoArgTypes: j,
301
- userArgTypes: i.userArgTypes,
302
- source: h,
303
- filePath: s,
304
- metaExtras: i.metaExtras
267
+ if (s === null) continue;
268
+ const p = s.title;
269
+ k.set(p, i), I.set(i, p);
270
+ const E = {
271
+ id: p,
272
+ title: s.title,
273
+ jogakNames: s.jogakNames,
274
+ autoArgTypes: h,
275
+ userArgTypes: s.userArgTypes,
276
+ source: v,
277
+ filePath: i,
278
+ metaExtras: s.metaExtras
305
279
  };
306
- C.set(s, G(I)), u.push({ id: m, filePath: s, meta: I });
280
+ b.set(i, J(E)), u.push({ id: p, filePath: i, meta: E });
307
281
  }
308
282
  return u;
309
283
  }
@@ -320,56 +294,58 @@ function Et(t = {}) {
320
294
  * 우선순위: `options.resolveAlias` (명시) > tsconfig 자동 추출.
321
295
  */
322
296
  config() {
323
- const r = o ?? process.cwd(), f = c ?? y(r, "tsconfig.json"), a = ut(f, r), u = {};
297
+ const e = a ?? process.cwd(), m = c ?? _(e, "tsconfig.json"), n = lt(m, e), u = {};
324
298
  if (g !== void 0)
325
- for (const [h, j] of Object.entries(g))
326
- u[h] = y(r, j);
327
- const s = { ...a, ...u };
328
- if (Object.keys(s).length !== 0)
299
+ for (const [v, h] of Object.entries(g))
300
+ u[v] = _(e, h);
301
+ const i = { ...n, ...u };
302
+ if (Object.keys(i).length !== 0)
329
303
  return {
330
- resolve: { alias: s }
304
+ resolve: { alias: i }
331
305
  };
332
306
  },
333
- async configResolved(r) {
334
- _ = o ?? r.root, r.command === "serve" && !l && await ot({
335
- root: r.root,
307
+ async configResolved(e) {
308
+ j = a ?? e.root, e.command === "serve" && !l && await at({
309
+ root: e.root,
336
310
  logger: {
337
- info: (a) => r.logger.info(a),
338
- warn: (a) => r.logger.warn(a)
311
+ info: (n) => e.logger.info(n),
312
+ warn: (n) => e.logger.warn(n)
339
313
  }
340
314
  });
341
- const f = c ?? y(_, "tsconfig.json");
342
- p = S(f) ? D({ tsConfigFilePath: f }) : D();
315
+ const m = c ?? _(j, "tsconfig.json");
316
+ f = S(m) ? $({ tsConfigFilePath: m }) : $();
343
317
  },
344
- configureServer(r) {
345
- d = r;
318
+ configureServer(e) {
319
+ d = e;
346
320
  },
347
321
  buildEnd() {
348
- p == null || p.releaseCache();
322
+ f == null || f.releaseCache();
349
323
  },
350
- resolveId(r) {
351
- if (r === K)
352
- return L;
353
- if (r === Y)
354
- return U;
355
- if (r.startsWith(H))
356
- return "\0" + r;
324
+ resolveId(e) {
325
+ if (e === H)
326
+ return x;
327
+ if (e === X)
328
+ return D;
329
+ if (e.startsWith(Y))
330
+ return "\0" + e;
357
331
  },
358
- async load(r) {
359
- if (r === U) {
360
- const f = _ ?? process.cwd(), a = W(v, f);
361
- return a.length === 0 ? `// [jogak] globalCss not configured or no candidates found.
332
+ async load(e) {
333
+ if (e === D) {
334
+ const m = j ?? process.cwd(), n = W(y, m);
335
+ return n.length === 0 ? `// [jogak] globalCss not configured or no candidates found.
362
336
  export {}
363
- ` : `${a.map((s) => `import ${JSON.stringify(s)}`).join(`
337
+ ` : `${n.map((i) => `import ${JSON.stringify(i)}`).join(`
364
338
  `)}
365
339
  export {}
366
340
  `;
367
341
  }
368
- if (r === L) {
369
- const a = (await V()).map((s) => s.meta), u = b ? "" : `
370
- export const _jogakCodeTheme = ${JSON.stringify(n)}
342
+ if (e === x) {
343
+ const n = (await N()).map((i) => i.meta), u = R ? "" : `
344
+ export const _jogakCodeTheme = ${JSON.stringify(o)}
371
345
  export const _jogakPreviewIsolation = ${JSON.stringify(w)}
372
- export const _jogakUserViteUrl = ${JSON.stringify(T)}
346
+ export const _jogakUserPreviewUrl = ${JSON.stringify(C)}
347
+ export const _jogakPreviewEntryPath = ${JSON.stringify(T)}
348
+ export const _jogakUserViteUrl = ${JSON.stringify(C)}
373
349
  export const _jogakMetas = _metas
374
350
  `;
375
351
  return `import { defaultRegistry } from '@jogak/core'
@@ -377,19 +353,19 @@ export const _jogakMetas = _metas
377
353
  const _entryLoader = (slug) =>
378
354
  import(/* @vite-ignore */ '/@id/__x00__virtual:jogak/entry/' + slug)
379
355
  defaultRegistry.setEntryLoader((id) => {
380
- const slug = ${vt()}
356
+ const slug = ${yt()}
381
357
  return _entryLoader(slug(id))
382
358
  })
383
359
 
384
- const _metas = ${JSON.stringify(a)}
360
+ const _metas = ${JSON.stringify(n)}
385
361
 
386
362
  for (const m of _metas) defaultRegistry.registerMeta(m)
387
363
  ${u}`;
388
364
  }
389
- if (r.startsWith(O)) {
390
- const f = r.slice(O.length), a = gt(f);
391
- let u = k.get(a);
392
- return u === void 0 && (await V(), u = k.get(a)), u === void 0 ? `// [jogak] unknown entry id: ${JSON.stringify(a)}
365
+ if (e.startsWith(P)) {
366
+ const m = e.slice(P.length), n = dt(m);
367
+ let u = k.get(n);
368
+ return u === void 0 && (await N(), u = k.get(n)), u === void 0 ? `// [jogak] unknown entry id: ${JSON.stringify(n)}
393
369
  export {}
394
370
  ` : `import * as _user from ${JSON.stringify(u)}
395
371
  import { defaultRegistry } from '@jogak/core'
@@ -400,7 +376,7 @@ delete _named.default
400
376
  const _jogaks = Object.values(_named).filter(
401
377
  (v) => v !== null && typeof v === 'object' && typeof v.name === 'string'
402
378
  )
403
- defaultRegistry.hydrateEntry(${JSON.stringify(a)}, _jogaks, _meta?.component)
379
+ defaultRegistry.hydrateEntry(${JSON.stringify(n)}, _jogaks, _meta?.component)
404
380
 
405
381
  if (import.meta.hot) {
406
382
  import.meta.hot.accept()
@@ -410,60 +386,60 @@ export {}
410
386
  `;
411
387
  }
412
388
  },
413
- async handleHotUpdate({ file: r, modules: f }) {
414
- const a = /\.jogak\.(tsx?|jsx?)$/.test(r), u = /\.(tsx?|jsx?)$/.test(r) && !a;
415
- if (!a && !u || d === void 0 || !a) return;
416
- const s = d.moduleGraph.getModuleById(
417
- L
418
- ), h = E.get(r), j = h !== void 0 ? O + dt(h) : void 0, i = j !== void 0 ? d.moduleGraph.getModuleById(j) : void 0;
419
- let m = null, I = {}, R = "";
420
- if (p !== void 0) {
389
+ async handleHotUpdate({ file: e, modules: m }) {
390
+ const n = /\.jogak\.(tsx?|jsx?)$/.test(e), u = /\.(tsx?|jsx?)$/.test(e) && !n;
391
+ if (!n && !u || d === void 0 || !n) return;
392
+ const i = d.moduleGraph.getModuleById(
393
+ x
394
+ ), v = I.get(e), h = v !== void 0 ? P + ut(v) : void 0, s = h !== void 0 ? d.moduleGraph.getModuleById(h) : void 0;
395
+ let p = null, E = {}, A = "";
396
+ if (f !== void 0) {
421
397
  try {
422
- m = await p.extractMeta(r);
398
+ p = await f.extractMeta(e);
423
399
  } catch {
424
- m = null;
400
+ p = null;
425
401
  }
426
402
  try {
427
- I = await p.extract(r);
403
+ E = await f.extract(e);
428
404
  } catch {
429
- I = {};
405
+ E = {};
430
406
  }
431
407
  try {
432
- R = await P(r, "utf8");
408
+ A = await U(e, "utf8");
433
409
  } catch {
434
- R = "";
410
+ A = "";
435
411
  }
436
412
  }
437
- if (m === null) {
438
- s !== void 0 && d.moduleGraph.invalidateModule(s), i !== void 0 && d.moduleGraph.invalidateModule(i), d.ws.send({ type: "full-reload" });
413
+ if (p === null) {
414
+ i !== void 0 && d.moduleGraph.invalidateModule(i), s !== void 0 && d.moduleGraph.invalidateModule(s), d.ws.send({ type: "full-reload" });
439
415
  return;
440
416
  }
441
- const N = G(m), z = C.get(r), Q = yt(z, N);
442
- if (C.set(r, N), !Q || h === void 0) {
443
- s !== void 0 && d.moduleGraph.invalidateModule(s), i !== void 0 && d.moduleGraph.invalidateModule(i), d.ws.send({ type: "full-reload" });
417
+ const V = J(p), Q = b.get(e), Z = pt(Q, V);
418
+ if (b.set(e, V), !Z || v === void 0) {
419
+ i !== void 0 && d.moduleGraph.invalidateModule(i), s !== void 0 && d.moduleGraph.invalidateModule(s), d.ws.send({ type: "full-reload" });
444
420
  return;
445
421
  }
446
- const Z = {
447
- id: h,
448
- title: m.title,
449
- jogakNames: m.jogakNames,
450
- autoArgTypes: I,
451
- userArgTypes: m.userArgTypes,
452
- source: R,
453
- filePath: r,
454
- metaExtras: m.metaExtras
422
+ const q = {
423
+ id: v,
424
+ title: p.title,
425
+ jogakNames: p.jogakNames,
426
+ autoArgTypes: E,
427
+ userArgTypes: p.userArgTypes,
428
+ source: A,
429
+ filePath: e,
430
+ metaExtras: p.metaExtras
455
431
  };
456
- i !== void 0 && d.moduleGraph.invalidateModule(i), d.ws.send({
432
+ s !== void 0 && d.moduleGraph.invalidateModule(s), d.ws.send({
457
433
  type: "custom",
458
434
  event: "jogak:meta-update",
459
- data: { id: h, meta: Z }
435
+ data: { id: v, meta: q }
460
436
  });
461
- const A = [...f];
462
- return i !== void 0 && !A.includes(i) && A.push(i), A;
437
+ const O = [...m];
438
+ return s !== void 0 && !O.includes(s) && O.push(s), O;
463
439
  }
464
440
  };
465
441
  }
466
- function vt() {
442
+ function yt() {
467
443
  return `(rawId) => {
468
444
  if (typeof Buffer !== 'undefined') return Buffer.from(rawId, 'utf8').toString('base64url')
469
445
  // 브라우저 폴백: btoa는 binary string 기준이라 UTF-8을 한번 인코딩해야 한다.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jogak/core",
3
- "version": "0.1.0-alpha.8",
3
+ "version": "0.1.0-alpha.9",
4
4
  "description": "Core types, registry, and Vite plugin for Jogak — a lightweight Storybook alternative.",
5
5
  "keywords": [
6
6
  "jogak",
@@ -25,14 +25,14 @@
25
25
  },
26
26
  "type": "module",
27
27
  "sideEffects": false,
28
- "main": "./dist/index.js",
28
+ "main": "./dist/index.cjs",
29
29
  "module": "./dist/index.mjs",
30
30
  "types": "./dist/index.d.ts",
31
31
  "exports": {
32
32
  ".": {
33
33
  "types": "./dist/index.d.ts",
34
34
  "import": "./dist/index.mjs",
35
- "require": "./dist/index.js"
35
+ "require": "./dist/index.cjs"
36
36
  },
37
37
  "./vite": {
38
38
  "types": "./dist/vite/plugin.d.ts",
@@ -41,6 +41,11 @@
41
41
  "./build": {
42
42
  "types": "./dist/build/index.d.ts",
43
43
  "import": "./dist/build/index.mjs"
44
+ },
45
+ "./server": {
46
+ "types": "./dist/server.d.ts",
47
+ "import": "./dist/server.mjs",
48
+ "require": "./dist/server.cjs"
44
49
  }
45
50
  },
46
51
  "files": [
package/dist/index.js DELETED
@@ -1 +0,0 @@
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;