@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.
- package/CHANGELOG.md +23 -0
- package/dist/adapter.d.ts +80 -0
- package/dist/builder-detect.d.ts +9 -0
- package/dist/config.d.ts +21 -8
- package/dist/detect-global-css-CDcuUAYE.cjs +1 -0
- package/dist/detect-global-css-CIVMmgzy.js +33 -0
- package/dist/index.cjs +43 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.mjs +210 -162
- package/dist/preview-entry/protocol.d.ts +29 -0
- package/dist/preview-entry/source.d.ts +30 -0
- package/dist/server.cjs +1 -0
- package/dist/server.d.ts +12 -0
- package/dist/server.mjs +45 -0
- package/dist/types.d.ts +17 -5
- package/dist/vite/index.cjs +118 -0
- package/dist/vite/index.mjs +183 -207
- package/package.json +8 -3
- package/dist/index.js +0 -1
- package/dist/vite/index.js +0 -116
- /package/dist/build/{index.js → index.cjs} +0 -0
- /package/dist/meta/{extractor-child.js → extractor-child.cjs} +0 -0
package/dist/vite/index.mjs
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
import { resolve as
|
|
2
|
-
import { existsSync as S, readFileSync as
|
|
3
|
-
import { stat as
|
|
4
|
-
import {
|
|
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
|
|
12
|
+
async function K(t) {
|
|
12
13
|
try {
|
|
13
|
-
const
|
|
14
|
-
if (!
|
|
15
|
-
return
|
|
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
|
|
20
|
+
let r = 0, o;
|
|
20
21
|
try {
|
|
21
|
-
|
|
22
|
+
o = await ot(t);
|
|
22
23
|
} catch {
|
|
23
24
|
return 0;
|
|
24
25
|
}
|
|
25
|
-
for (const
|
|
26
|
-
const c = B(t,
|
|
26
|
+
for (const a of o) {
|
|
27
|
+
const c = B(t, a);
|
|
27
28
|
try {
|
|
28
|
-
const l = await
|
|
29
|
+
const l = await L(c);
|
|
29
30
|
if (l.isDirectory()) {
|
|
30
|
-
const g = await
|
|
31
|
-
g >
|
|
32
|
-
} else 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
|
|
38
|
+
return r;
|
|
38
39
|
}
|
|
39
|
-
async function
|
|
40
|
-
const
|
|
41
|
-
if (!S(
|
|
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
|
|
44
|
-
if (!S(
|
|
44
|
+
const o = B(r, "_metadata.json");
|
|
45
|
+
if (!S(o))
|
|
45
46
|
return { purged: !1 };
|
|
46
|
-
let
|
|
47
|
+
let a;
|
|
47
48
|
try {
|
|
48
|
-
|
|
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 =
|
|
57
|
+
const g = _(t.root, "node_modules", l, "dist");
|
|
57
58
|
if (!S(g)) continue;
|
|
58
|
-
let
|
|
59
|
+
let y;
|
|
59
60
|
try {
|
|
60
|
-
|
|
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 (
|
|
68
|
+
if (y > a + 1e3)
|
|
68
69
|
try {
|
|
69
|
-
return await
|
|
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 ${
|
|
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
|
|
84
|
+
function st(t) {
|
|
111
85
|
if (S(t))
|
|
112
86
|
try {
|
|
113
|
-
const
|
|
114
|
-
return JSON.parse(it(
|
|
87
|
+
const r = et(t, "utf8");
|
|
88
|
+
return JSON.parse(it(r));
|
|
115
89
|
} catch {
|
|
116
90
|
return;
|
|
117
91
|
}
|
|
118
92
|
}
|
|
119
|
-
function
|
|
120
|
-
if (!t.endsWith("/*") || !
|
|
121
|
-
const
|
|
122
|
-
return [
|
|
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
|
|
98
|
+
function lt(t, r) {
|
|
125
99
|
var c, l;
|
|
126
|
-
const
|
|
100
|
+
const o = {}, a = /* @__PURE__ */ new Set([
|
|
127
101
|
t,
|
|
128
|
-
|
|
102
|
+
_(r, "tsconfig.app.json")
|
|
129
103
|
]);
|
|
130
|
-
for (const g of
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
133
|
-
const w = (c =
|
|
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
|
|
136
|
-
for (const [
|
|
137
|
-
const
|
|
138
|
-
if (
|
|
139
|
-
const
|
|
140
|
-
if (
|
|
141
|
-
const [
|
|
142
|
-
|
|
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
|
|
119
|
+
return o;
|
|
146
120
|
}
|
|
147
|
-
const
|
|
148
|
-
function
|
|
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
|
|
125
|
+
function dt(t) {
|
|
152
126
|
return Buffer.from(t, "base64url").toString("utf8");
|
|
153
127
|
}
|
|
154
|
-
const
|
|
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(
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
const g =
|
|
163
|
-
|
|
164
|
-
|
|
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(
|
|
169
|
-
if (
|
|
170
|
-
if (
|
|
142
|
+
resolveId(r) {
|
|
143
|
+
if (r === M) return F;
|
|
144
|
+
if (r === z) return G;
|
|
171
145
|
},
|
|
172
|
-
load(
|
|
173
|
-
if (
|
|
174
|
-
const
|
|
175
|
-
return
|
|
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
|
-
` :
|
|
151
|
+
` : o.map((a) => `import ${JSON.stringify(a)}`).join(`
|
|
178
152
|
`) + `
|
|
179
153
|
export {}
|
|
180
154
|
`;
|
|
181
155
|
}
|
|
182
|
-
if (
|
|
183
|
-
return
|
|
156
|
+
if (r === F)
|
|
157
|
+
return mt;
|
|
184
158
|
}
|
|
185
159
|
};
|
|
186
160
|
}
|
|
187
|
-
function
|
|
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
|
|
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
|
|
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
|
|
261
|
-
return t !== void 0 && t.title ===
|
|
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:
|
|
266
|
-
codeTheme:
|
|
267
|
-
} = t,
|
|
268
|
-
let d,
|
|
269
|
-
const k = /* @__PURE__ */ new Map(),
|
|
270
|
-
async function
|
|
271
|
-
const { glob:
|
|
272
|
-
k.clear(),
|
|
273
|
-
for (const
|
|
274
|
-
let
|
|
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
|
-
|
|
250
|
+
v = await U(i, "utf8");
|
|
277
251
|
} catch {
|
|
278
252
|
continue;
|
|
279
253
|
}
|
|
280
|
-
let
|
|
281
|
-
if (
|
|
254
|
+
let h = {}, s = null;
|
|
255
|
+
if (f !== void 0) {
|
|
282
256
|
try {
|
|
283
|
-
|
|
257
|
+
h = await f.extract(i);
|
|
284
258
|
} catch {
|
|
285
|
-
|
|
259
|
+
h = {};
|
|
286
260
|
}
|
|
287
261
|
try {
|
|
288
|
-
|
|
262
|
+
s = await f.extractMeta(i);
|
|
289
263
|
} catch {
|
|
290
|
-
|
|
264
|
+
s = null;
|
|
291
265
|
}
|
|
292
266
|
}
|
|
293
|
-
if (
|
|
294
|
-
const
|
|
295
|
-
k.set(
|
|
296
|
-
const
|
|
297
|
-
id:
|
|
298
|
-
title:
|
|
299
|
-
jogakNames:
|
|
300
|
-
autoArgTypes:
|
|
301
|
-
userArgTypes:
|
|
302
|
-
source:
|
|
303
|
-
filePath:
|
|
304
|
-
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
|
-
|
|
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
|
|
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 [
|
|
326
|
-
u[
|
|
327
|
-
const
|
|
328
|
-
if (Object.keys(
|
|
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:
|
|
304
|
+
resolve: { alias: i }
|
|
331
305
|
};
|
|
332
306
|
},
|
|
333
|
-
async configResolved(
|
|
334
|
-
|
|
335
|
-
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: (
|
|
338
|
-
warn: (
|
|
311
|
+
info: (n) => e.logger.info(n),
|
|
312
|
+
warn: (n) => e.logger.warn(n)
|
|
339
313
|
}
|
|
340
314
|
});
|
|
341
|
-
const
|
|
342
|
-
|
|
315
|
+
const m = c ?? _(j, "tsconfig.json");
|
|
316
|
+
f = S(m) ? $({ tsConfigFilePath: m }) : $();
|
|
343
317
|
},
|
|
344
|
-
configureServer(
|
|
345
|
-
d =
|
|
318
|
+
configureServer(e) {
|
|
319
|
+
d = e;
|
|
346
320
|
},
|
|
347
321
|
buildEnd() {
|
|
348
|
-
|
|
322
|
+
f == null || f.releaseCache();
|
|
349
323
|
},
|
|
350
|
-
resolveId(
|
|
351
|
-
if (
|
|
352
|
-
return
|
|
353
|
-
if (
|
|
354
|
-
return
|
|
355
|
-
if (
|
|
356
|
-
return "\0" +
|
|
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(
|
|
359
|
-
if (
|
|
360
|
-
const
|
|
361
|
-
return
|
|
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
|
-
` : `${
|
|
337
|
+
` : `${n.map((i) => `import ${JSON.stringify(i)}`).join(`
|
|
364
338
|
`)}
|
|
365
339
|
export {}
|
|
366
340
|
`;
|
|
367
341
|
}
|
|
368
|
-
if (
|
|
369
|
-
const
|
|
370
|
-
export const _jogakCodeTheme = ${JSON.stringify(
|
|
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
|
|
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 = ${
|
|
356
|
+
const slug = ${yt()}
|
|
381
357
|
return _entryLoader(slug(id))
|
|
382
358
|
})
|
|
383
359
|
|
|
384
|
-
const _metas = ${JSON.stringify(
|
|
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 (
|
|
390
|
-
const
|
|
391
|
-
let u = k.get(
|
|
392
|
-
return u === void 0 && (await
|
|
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(
|
|
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:
|
|
414
|
-
const
|
|
415
|
-
if (!
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
),
|
|
419
|
-
let
|
|
420
|
-
if (
|
|
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
|
-
|
|
398
|
+
p = await f.extractMeta(e);
|
|
423
399
|
} catch {
|
|
424
|
-
|
|
400
|
+
p = null;
|
|
425
401
|
}
|
|
426
402
|
try {
|
|
427
|
-
|
|
403
|
+
E = await f.extract(e);
|
|
428
404
|
} catch {
|
|
429
|
-
|
|
405
|
+
E = {};
|
|
430
406
|
}
|
|
431
407
|
try {
|
|
432
|
-
|
|
408
|
+
A = await U(e, "utf8");
|
|
433
409
|
} catch {
|
|
434
|
-
|
|
410
|
+
A = "";
|
|
435
411
|
}
|
|
436
412
|
}
|
|
437
|
-
if (
|
|
438
|
-
|
|
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
|
|
442
|
-
if (
|
|
443
|
-
|
|
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
|
|
447
|
-
id:
|
|
448
|
-
title:
|
|
449
|
-
jogakNames:
|
|
450
|
-
autoArgTypes:
|
|
451
|
-
userArgTypes:
|
|
452
|
-
source:
|
|
453
|
-
filePath:
|
|
454
|
-
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
|
-
|
|
432
|
+
s !== void 0 && d.moduleGraph.invalidateModule(s), d.ws.send({
|
|
457
433
|
type: "custom",
|
|
458
434
|
event: "jogak:meta-update",
|
|
459
|
-
data: { id:
|
|
435
|
+
data: { id: v, meta: q }
|
|
460
436
|
});
|
|
461
|
-
const
|
|
462
|
-
return
|
|
437
|
+
const O = [...m];
|
|
438
|
+
return s !== void 0 && !O.includes(s) && O.push(s), O;
|
|
463
439
|
}
|
|
464
440
|
};
|
|
465
441
|
}
|
|
466
|
-
function
|
|
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.
|
|
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.
|
|
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.
|
|
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;
|