@jogak/core 0.1.0-alpha.8 → 0.1.0-alpha.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -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/index.mjs
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
var J = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
throw TypeError(
|
|
2
|
+
var L = (r) => {
|
|
3
|
+
throw TypeError(r);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
set _(
|
|
10
|
-
c(
|
|
5
|
+
var U = (r, t, e) => t in r ? J(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
6
|
+
var O = (r, t, e) => U(r, typeof t != "symbol" ? t + "" : t, e), S = (r, t, e) => t.has(r) || L("Cannot " + e);
|
|
7
|
+
var n = (r, t, e) => (S(r, t, "read from private field"), e ? e.call(r) : t.get(r)), f = (r, t, e) => t.has(r) ? L("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(r) : t.set(r, e), c = (r, t, e, i) => (S(r, t, "write to private field"), i ? i.call(r, e) : t.set(r, e), e), l = (r, t, e) => (S(r, t, "access private method"), e);
|
|
8
|
+
var z = (r, t, e, i) => ({
|
|
9
|
+
set _(s) {
|
|
10
|
+
c(r, t, s, e);
|
|
11
11
|
},
|
|
12
12
|
get _() {
|
|
13
|
-
return
|
|
13
|
+
return n(r, t, i);
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
|
-
class
|
|
16
|
+
class F extends Error {
|
|
17
17
|
constructor(e) {
|
|
18
18
|
super(`[jogak] Unknown entry id: ${e}`);
|
|
19
|
-
|
|
19
|
+
O(this, "id");
|
|
20
20
|
this.name = "UnknownEntryError", this.id = e;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
var a,
|
|
23
|
+
var a, M, C, v, k, E, w, j, A, T, u, p, x, $;
|
|
24
24
|
class B {
|
|
25
25
|
constructor() {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
f(this, u);
|
|
27
|
+
f(this, a, /* @__PURE__ */ new Map());
|
|
28
|
+
f(this, M);
|
|
29
29
|
// ── F2: subscribe + 내부 캐시 ────────────────────────────────────────
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
f(this, C, /* @__PURE__ */ new Set());
|
|
31
|
+
f(this, v);
|
|
32
|
+
f(this, k);
|
|
33
33
|
// 결정성 fix: hydrated entry list / tree 도 캐시. mutation 시 invalidate.
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
f(this, E);
|
|
35
|
+
f(this, w);
|
|
36
36
|
/**
|
|
37
37
|
* 정렬된 id 순서. mutation 시 invalidate, 다음 호출에서 한 번만 재계산.
|
|
38
38
|
* getAll / getTree / getAllMeta / getMetaTree 모두 이 순서를 따른다.
|
|
39
39
|
* 결과: 모든 외부 노출 collection 이 동일 ordering 을 가진다.
|
|
40
40
|
*/
|
|
41
|
-
|
|
41
|
+
f(this, j);
|
|
42
42
|
/** register()가 registerMeta + hydrateEntry를 합쳐 호출할 때 중간 notify를 억제한다. */
|
|
43
|
-
|
|
43
|
+
f(this, A, !1);
|
|
44
44
|
/** batch 도중에 mutation이 한 번이라도 일어났는지 — false면 batch 종료 시 notify 안 한다. */
|
|
45
|
-
|
|
45
|
+
f(this, T, !1);
|
|
46
46
|
}
|
|
47
47
|
// ── 기존 외부 API: 시그니처 변경 없음. 시맨틱은 hydrated만 표면. ───────────
|
|
48
48
|
/**
|
|
@@ -53,34 +53,34 @@ class B {
|
|
|
53
53
|
* 두 mutation은 batch로 묶여 단일 notify만 발생한다.
|
|
54
54
|
*/
|
|
55
55
|
register(t) {
|
|
56
|
-
const e =
|
|
57
|
-
|
|
56
|
+
const e = D(t);
|
|
57
|
+
l(this, u, $).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
|
-
const e =
|
|
63
|
-
e !== void 0 && (e.kind === "pending" && e.reject(new
|
|
62
|
+
const e = n(this, a).get(t);
|
|
63
|
+
e !== void 0 && (e.kind === "pending" && e.reject(new F(t)), n(this, a).delete(t), l(this, u, p).call(this));
|
|
64
64
|
}
|
|
65
65
|
/** hydrated일 때만 RegistryEntry를 반환한다. meta-only/pending이면 undefined. */
|
|
66
66
|
get(t) {
|
|
67
|
-
const e =
|
|
67
|
+
const e = n(this, a).get(t);
|
|
68
68
|
return (e == null ? void 0 : e.kind) === "hydrated" ? e.entry : void 0;
|
|
69
69
|
}
|
|
70
70
|
/** hydrated 항목만 반환. meta-only는 `getAllMeta()` 사용. */
|
|
71
71
|
getAll() {
|
|
72
|
-
if (
|
|
72
|
+
if (n(this, E) !== void 0) return n(this, E);
|
|
73
73
|
const t = [];
|
|
74
|
-
for (const
|
|
75
|
-
const
|
|
76
|
-
(
|
|
74
|
+
for (const i of l(this, u, x).call(this)) {
|
|
75
|
+
const s = n(this, a).get(i);
|
|
76
|
+
(s == null ? void 0 : s.kind) === "hydrated" && t.push(s.entry);
|
|
77
77
|
}
|
|
78
78
|
const e = t;
|
|
79
79
|
return c(this, E, e), e;
|
|
80
80
|
}
|
|
81
81
|
search(t) {
|
|
82
82
|
const e = t.toLowerCase();
|
|
83
|
-
return this.getAll().filter((
|
|
83
|
+
return this.getAll().filter((i) => i.title.toLowerCase().includes(e));
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* title의 '/' 구분자로 hydrated entry만의 계층 트리를 구성한다.
|
|
@@ -89,33 +89,33 @@ class B {
|
|
|
89
89
|
* (ECMA-262 §OrdinaryOwnPropertyKeys: insertion order for string keys)도 결정적이다.
|
|
90
90
|
*/
|
|
91
91
|
getTree() {
|
|
92
|
-
if (
|
|
92
|
+
if (n(this, w) !== void 0) return n(this, w);
|
|
93
93
|
const t = {};
|
|
94
94
|
for (const e of this.getAll()) {
|
|
95
|
-
const
|
|
96
|
-
let
|
|
97
|
-
for (let h = 0; h <
|
|
98
|
-
const d =
|
|
95
|
+
const i = e.title.split("/");
|
|
96
|
+
let s = t;
|
|
97
|
+
for (let h = 0; h < i.length - 1; h++) {
|
|
98
|
+
const d = i[h];
|
|
99
99
|
if (d === void 0) continue;
|
|
100
|
-
const g =
|
|
101
|
-
(g === void 0 || "id" in g) && (
|
|
100
|
+
const g = s[d];
|
|
101
|
+
(g === void 0 || "id" in g) && (s[d] = {}), s = s[d];
|
|
102
102
|
}
|
|
103
|
-
const o =
|
|
104
|
-
o !== void 0 && (
|
|
103
|
+
const o = i[i.length - 1];
|
|
104
|
+
o !== void 0 && (s[o] = e);
|
|
105
105
|
}
|
|
106
106
|
return c(this, w, t), t;
|
|
107
107
|
}
|
|
108
108
|
clear() {
|
|
109
|
-
if (
|
|
110
|
-
for (const t of
|
|
109
|
+
if (n(this, a).size !== 0) {
|
|
110
|
+
for (const t of n(this, a).values())
|
|
111
111
|
t.kind === "pending" && t.reject(new Error("[jogak] registry cleared"));
|
|
112
|
-
|
|
112
|
+
n(this, a).clear(), l(this, u, p).call(this);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
/** hydrated 개수. */
|
|
116
116
|
get size() {
|
|
117
117
|
let t = 0;
|
|
118
|
-
for (const e of
|
|
118
|
+
for (const e of n(this, a).values())
|
|
119
119
|
e.kind === "hydrated" && t++;
|
|
120
120
|
return t;
|
|
121
121
|
}
|
|
@@ -125,42 +125,42 @@ class B {
|
|
|
125
125
|
* meta 등록만으로는 `getAll()` 결과에 안 들어간다.
|
|
126
126
|
*/
|
|
127
127
|
registerMeta(t) {
|
|
128
|
-
const e =
|
|
128
|
+
const e = n(this, a).get(t.id);
|
|
129
129
|
if (e === void 0) {
|
|
130
|
-
|
|
130
|
+
n(this, a).set(t.id, { kind: "meta", meta: t }), l(this, u, p).call(this);
|
|
131
131
|
return;
|
|
132
132
|
}
|
|
133
133
|
if (e.kind === "meta") {
|
|
134
|
-
|
|
134
|
+
n(this, a).set(t.id, { kind: "meta", meta: t }), l(this, u, p).call(this);
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
if (e.kind === "pending") {
|
|
138
|
-
|
|
138
|
+
n(this, a).set(t.id, {
|
|
139
139
|
kind: "pending",
|
|
140
140
|
meta: t,
|
|
141
141
|
promise: e.promise,
|
|
142
142
|
resolve: e.resolve,
|
|
143
143
|
reject: e.reject
|
|
144
|
-
}),
|
|
144
|
+
}), l(this, u, p).call(this);
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
const
|
|
147
|
+
const i = {
|
|
148
148
|
...e.entry,
|
|
149
149
|
title: t.title,
|
|
150
150
|
filePath: t.filePath,
|
|
151
151
|
source: t.source,
|
|
152
|
-
meta:
|
|
152
|
+
meta: N(t, e.entry.meta.component)
|
|
153
153
|
};
|
|
154
|
-
|
|
154
|
+
n(this, a).set(t.id, { kind: "hydrated", meta: t, entry: i }), l(this, u, p).call(this);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* entry 가상모듈이 호출. pending Promise들을 resolve.
|
|
158
158
|
* meta가 없는 상태에서 호출되면(=직접 import) 임시 meta를 합성한다 (defensive).
|
|
159
159
|
*/
|
|
160
|
-
hydrateEntry(t, e,
|
|
161
|
-
const
|
|
160
|
+
hydrateEntry(t, e, i) {
|
|
161
|
+
const s = n(this, a).get(t);
|
|
162
162
|
let o;
|
|
163
|
-
|
|
163
|
+
s === void 0 ? (console.warn(
|
|
164
164
|
`[jogak] hydrateEntry called for unknown id "${t}" — synthesizing minimal meta`
|
|
165
165
|
), o = {
|
|
166
166
|
id: t,
|
|
@@ -171,20 +171,20 @@ class B {
|
|
|
171
171
|
source: "",
|
|
172
172
|
filePath: "",
|
|
173
173
|
metaExtras: {}
|
|
174
|
-
}) : o =
|
|
174
|
+
}) : o = s.meta;
|
|
175
175
|
const h = {
|
|
176
176
|
id: o.id,
|
|
177
177
|
title: o.title,
|
|
178
178
|
jogaks: e,
|
|
179
|
-
meta:
|
|
179
|
+
meta: N(o, i),
|
|
180
180
|
...o.filePath ? { filePath: o.filePath } : {},
|
|
181
181
|
...o.source ? { source: o.source } : {}
|
|
182
182
|
};
|
|
183
|
-
if ((
|
|
184
|
-
|
|
183
|
+
if ((s == null ? void 0 : s.kind) === "pending") {
|
|
184
|
+
n(this, a).set(t, { kind: "hydrated", meta: o, entry: h }), l(this, u, p).call(this), s.resolve(h);
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
|
-
|
|
187
|
+
n(this, a).set(t, { kind: "hydrated", meta: o, entry: h }), l(this, u, p).call(this);
|
|
188
188
|
}
|
|
189
189
|
/**
|
|
190
190
|
* 어댑터가 호출. hydrated였던 entry를 meta 상태로 되돌린다.
|
|
@@ -192,8 +192,8 @@ class B {
|
|
|
192
192
|
* unknown / meta / pending 상태에는 영향 없음.
|
|
193
193
|
*/
|
|
194
194
|
invalidateEntry(t) {
|
|
195
|
-
const e =
|
|
196
|
-
e === void 0 || e.kind !== "hydrated" || (
|
|
195
|
+
const e = n(this, a).get(t);
|
|
196
|
+
e === void 0 || e.kind !== "hydrated" || (n(this, a).set(t, { kind: "meta", meta: e.meta }), l(this, u, p).call(this));
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
199
|
* UI/어댑터가 호출. entry id로 완전한 RegistryEntry를 비동기 획득.
|
|
@@ -204,40 +204,40 @@ class B {
|
|
|
204
204
|
* - unknown → 즉시 reject (UnknownEntryError)
|
|
205
205
|
*/
|
|
206
206
|
requestEntry(t) {
|
|
207
|
-
const e =
|
|
207
|
+
const e = n(this, a).get(t);
|
|
208
208
|
if (e === void 0)
|
|
209
|
-
return Promise.reject(new
|
|
209
|
+
return Promise.reject(new F(t));
|
|
210
210
|
if (e.kind === "hydrated")
|
|
211
211
|
return Promise.resolve(e.entry);
|
|
212
212
|
if (e.kind === "pending")
|
|
213
213
|
return e.promise;
|
|
214
|
-
const
|
|
215
|
-
if (
|
|
214
|
+
const i = n(this, M);
|
|
215
|
+
if (i === void 0)
|
|
216
216
|
return Promise.reject(
|
|
217
217
|
new Error(
|
|
218
218
|
"[jogak] entry loader not set — virtual:jogak index module did not load"
|
|
219
219
|
)
|
|
220
220
|
);
|
|
221
|
-
let
|
|
221
|
+
let s, o;
|
|
222
222
|
const h = new Promise((d, g) => {
|
|
223
|
-
|
|
223
|
+
s = d, o = g;
|
|
224
224
|
});
|
|
225
|
-
return
|
|
225
|
+
return n(this, a).set(t, {
|
|
226
226
|
kind: "pending",
|
|
227
227
|
meta: e.meta,
|
|
228
228
|
promise: h,
|
|
229
|
-
resolve:
|
|
229
|
+
resolve: s,
|
|
230
230
|
reject: o
|
|
231
|
-
}),
|
|
231
|
+
}), i(t).then(
|
|
232
232
|
() => {
|
|
233
|
-
const d =
|
|
233
|
+
const d = n(this, a).get(t);
|
|
234
234
|
(d == null ? void 0 : d.kind) !== "hydrated" && o(
|
|
235
235
|
new Error(`[jogak] entry module loaded but did not hydrate: ${t}`)
|
|
236
236
|
);
|
|
237
237
|
},
|
|
238
238
|
(d) => {
|
|
239
|
-
const g = d instanceof Error ? d : new Error(String(d)), y =
|
|
240
|
-
(y == null ? void 0 : y.kind) === "pending" && y.promise === h &&
|
|
239
|
+
const g = d instanceof Error ? d : new Error(String(d)), y = n(this, a).get(t);
|
|
240
|
+
(y == null ? void 0 : y.kind) === "pending" && y.promise === h && n(this, a).set(t, { kind: "meta", meta: e.meta }), o(g);
|
|
241
241
|
}
|
|
242
242
|
), h;
|
|
243
243
|
}
|
|
@@ -248,11 +248,11 @@ class B {
|
|
|
248
248
|
* useSyncExternalStore의 referential identity 요구를 만족시키기 위함.
|
|
249
249
|
*/
|
|
250
250
|
getAllMeta() {
|
|
251
|
-
if (
|
|
251
|
+
if (n(this, v) !== void 0) return n(this, v);
|
|
252
252
|
const t = [];
|
|
253
|
-
for (const
|
|
254
|
-
const
|
|
255
|
-
|
|
253
|
+
for (const i of l(this, u, x).call(this)) {
|
|
254
|
+
const s = n(this, a).get(i);
|
|
255
|
+
s !== void 0 && t.push(s.meta);
|
|
256
256
|
}
|
|
257
257
|
const e = t;
|
|
258
258
|
return c(this, v, e), e;
|
|
@@ -262,27 +262,27 @@ class B {
|
|
|
262
262
|
* F2: getAllMeta와 동일한 캐시 정책.
|
|
263
263
|
*/
|
|
264
264
|
getMetaTree() {
|
|
265
|
-
if (
|
|
265
|
+
if (n(this, k) !== void 0) return n(this, k);
|
|
266
266
|
const t = {};
|
|
267
|
-
for (const e of
|
|
268
|
-
const
|
|
269
|
-
if (
|
|
270
|
-
const
|
|
267
|
+
for (const e of l(this, u, x).call(this)) {
|
|
268
|
+
const i = n(this, a).get(e);
|
|
269
|
+
if (i === void 0) continue;
|
|
270
|
+
const s = i.meta, o = s.title.split("/");
|
|
271
271
|
let h = t;
|
|
272
272
|
for (let g = 0; g < o.length - 1; g++) {
|
|
273
273
|
const y = o[g];
|
|
274
274
|
if (y === void 0) continue;
|
|
275
|
-
const
|
|
276
|
-
(
|
|
275
|
+
const R = h[y];
|
|
276
|
+
(R === void 0 || "id" in R) && (h[y] = {}), h = h[y];
|
|
277
277
|
}
|
|
278
278
|
const d = o[o.length - 1];
|
|
279
|
-
d !== void 0 && (h[d] =
|
|
279
|
+
d !== void 0 && (h[d] = s);
|
|
280
280
|
}
|
|
281
281
|
return c(this, k, t), t;
|
|
282
282
|
}
|
|
283
283
|
/** 진단 — 상태 머신 노출. */
|
|
284
284
|
getEntryState(t) {
|
|
285
|
-
const e =
|
|
285
|
+
const e = n(this, a).get(t);
|
|
286
286
|
return e === void 0 ? "unknown" : e.kind;
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
@@ -290,7 +290,7 @@ class B {
|
|
|
290
290
|
* 빌드/SSR에서 정적 import 매핑으로 교체할 때도 사용.
|
|
291
291
|
*/
|
|
292
292
|
setEntryLoader(t) {
|
|
293
|
-
c(this,
|
|
293
|
+
c(this, M, t);
|
|
294
294
|
}
|
|
295
295
|
// ── F2: subscribe API ────────────────────────────────────────────────
|
|
296
296
|
/**
|
|
@@ -304,29 +304,29 @@ class B {
|
|
|
304
304
|
* - 반환값은 unsubscribe 함수 (멱등 — 두 번 호출해도 안전).
|
|
305
305
|
*/
|
|
306
306
|
subscribe(t) {
|
|
307
|
-
|
|
307
|
+
n(this, C).add(t);
|
|
308
308
|
let e = !0;
|
|
309
309
|
return () => {
|
|
310
|
-
e && (e = !1,
|
|
310
|
+
e && (e = !1, n(this, C).delete(t));
|
|
311
311
|
};
|
|
312
312
|
}
|
|
313
313
|
}
|
|
314
|
-
a = new WeakMap(),
|
|
314
|
+
a = new WeakMap(), M = new WeakMap(), C = new WeakMap(), v = new WeakMap(), k = new WeakMap(), E = new WeakMap(), w = new WeakMap(), j = new WeakMap(), A = new WeakMap(), T = new WeakMap(), u = new WeakSet(), // ── 내부 헬퍼 ─────────────────────────────────────────────────────────
|
|
315
315
|
/**
|
|
316
316
|
* 캐시 invalidate + listener 통지를 단일 헬퍼로.
|
|
317
317
|
* batch 모드에서는 dirty 플래그만 켜고 실제 통지는 batch 종료 시점에 한다.
|
|
318
318
|
*/
|
|
319
|
-
|
|
320
|
-
if (c(this, v, void 0), c(this, k, void 0), c(this, E, void 0), c(this, w, void 0), c(this, j, void 0),
|
|
319
|
+
p = function() {
|
|
320
|
+
if (c(this, v, void 0), c(this, k, void 0), c(this, E, void 0), c(this, w, void 0), c(this, j, void 0), n(this, A)) {
|
|
321
321
|
c(this, T, !0);
|
|
322
322
|
return;
|
|
323
323
|
}
|
|
324
|
-
const t = Array.from(
|
|
324
|
+
const t = Array.from(n(this, C));
|
|
325
325
|
for (const e of t)
|
|
326
326
|
try {
|
|
327
327
|
e();
|
|
328
|
-
} catch (
|
|
329
|
-
console.error("[jogak] subscribe listener threw:",
|
|
328
|
+
} catch (i) {
|
|
329
|
+
console.error("[jogak] subscribe listener threw:", i);
|
|
330
330
|
}
|
|
331
331
|
}, /**
|
|
332
332
|
* 모든 외부 노출 collection 이 공유하는 정렬된 id 순서.
|
|
@@ -334,20 +334,20 @@ m = function() {
|
|
|
334
334
|
*
|
|
335
335
|
* 정렬 정책은 module-private `compareMetaForOrdering` 단일 source.
|
|
336
336
|
*/
|
|
337
|
-
|
|
338
|
-
if (
|
|
337
|
+
x = function() {
|
|
338
|
+
if (n(this, j) !== void 0) return n(this, j);
|
|
339
339
|
const t = [];
|
|
340
|
-
for (const [
|
|
341
|
-
t.push({ id:
|
|
342
|
-
t.sort(
|
|
343
|
-
const e = t.map((
|
|
340
|
+
for (const [i, s] of n(this, a))
|
|
341
|
+
t.push({ id: i, title: s.meta.title });
|
|
342
|
+
t.sort(X);
|
|
343
|
+
const e = t.map((i) => i.id);
|
|
344
344
|
return c(this, j, e), e;
|
|
345
345
|
}, /**
|
|
346
346
|
* register() 처럼 여러 mutation을 묶어 단일 notify로 처리.
|
|
347
347
|
* 내부 전용 — public API 아님.
|
|
348
348
|
*/
|
|
349
|
-
|
|
350
|
-
if (
|
|
349
|
+
$ = function(t) {
|
|
350
|
+
if (n(this, A)) {
|
|
351
351
|
t();
|
|
352
352
|
return;
|
|
353
353
|
}
|
|
@@ -355,109 +355,157 @@ q = function(t) {
|
|
|
355
355
|
try {
|
|
356
356
|
t();
|
|
357
357
|
} finally {
|
|
358
|
-
c(this, A, !1),
|
|
358
|
+
c(this, A, !1), n(this, T) && (c(this, T, !1), l(this, u, p).call(this));
|
|
359
359
|
}
|
|
360
360
|
};
|
|
361
|
-
function
|
|
362
|
-
const t =
|
|
361
|
+
function D(r) {
|
|
362
|
+
const t = r.meta.argTypes ?? {};
|
|
363
363
|
return {
|
|
364
|
-
id:
|
|
365
|
-
title:
|
|
366
|
-
jogakNames:
|
|
364
|
+
id: r.id,
|
|
365
|
+
title: r.title,
|
|
366
|
+
jogakNames: r.jogaks.map((e) => e.name),
|
|
367
367
|
autoArgTypes: {},
|
|
368
368
|
userArgTypes: t,
|
|
369
|
-
source:
|
|
370
|
-
filePath:
|
|
369
|
+
source: r.source ?? "",
|
|
370
|
+
filePath: r.filePath ?? "",
|
|
371
371
|
metaExtras: {
|
|
372
|
-
...
|
|
373
|
-
...
|
|
372
|
+
...r.meta.tags !== void 0 ? { tags: r.meta.tags } : {},
|
|
373
|
+
...r.meta.parameters !== void 0 ? { parameters: r.meta.parameters } : {}
|
|
374
374
|
}
|
|
375
375
|
};
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function N(r, t) {
|
|
378
378
|
const e = {
|
|
379
|
-
...
|
|
379
|
+
...r.autoArgTypes
|
|
380
380
|
};
|
|
381
|
-
for (const
|
|
382
|
-
const
|
|
383
|
-
|
|
381
|
+
for (const i of Object.keys(r.userArgTypes)) {
|
|
382
|
+
const s = r.userArgTypes[i];
|
|
383
|
+
s !== void 0 && (e[i] = { ...e[i], ...s });
|
|
384
384
|
}
|
|
385
385
|
return {
|
|
386
|
-
title:
|
|
386
|
+
title: r.title,
|
|
387
387
|
component: t,
|
|
388
388
|
argTypes: e,
|
|
389
|
-
...
|
|
390
|
-
...
|
|
389
|
+
...r.metaExtras.tags !== void 0 ? { tags: r.metaExtras.tags } : {},
|
|
390
|
+
...r.metaExtras.parameters !== void 0 ? { parameters: r.metaExtras.parameters } : {}
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
|
-
function
|
|
394
|
-
const e =
|
|
393
|
+
function X(r, t) {
|
|
394
|
+
const e = r.title.localeCompare(t.title, "en", {
|
|
395
395
|
sensitivity: "base",
|
|
396
396
|
numeric: !0
|
|
397
397
|
});
|
|
398
|
-
return e !== 0 ? e :
|
|
398
|
+
return e !== 0 ? e : r.id.localeCompare(t.id, "en", { sensitivity: "base", numeric: !0 });
|
|
399
399
|
}
|
|
400
|
-
const
|
|
401
|
-
var
|
|
402
|
-
class
|
|
400
|
+
const Q = new B();
|
|
401
|
+
var m, P, I, b, _;
|
|
402
|
+
class V {
|
|
403
403
|
constructor() {
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
404
|
+
f(this, b);
|
|
405
|
+
f(this, m, []);
|
|
406
|
+
f(this, P, /* @__PURE__ */ new Set());
|
|
407
|
+
f(this, I, 1);
|
|
408
408
|
}
|
|
409
409
|
emit(t, e) {
|
|
410
|
-
const
|
|
411
|
-
id:
|
|
410
|
+
const i = {
|
|
411
|
+
id: z(this, I)._++,
|
|
412
412
|
name: t,
|
|
413
413
|
args: e,
|
|
414
414
|
timestamp: Date.now()
|
|
415
415
|
};
|
|
416
|
-
c(this,
|
|
416
|
+
c(this, m, [...n(this, m), i]), l(this, b, _).call(this);
|
|
417
417
|
}
|
|
418
418
|
subscribe(t) {
|
|
419
|
-
return
|
|
420
|
-
|
|
419
|
+
return n(this, P).add(t), t(n(this, m)), () => {
|
|
420
|
+
n(this, P).delete(t);
|
|
421
421
|
};
|
|
422
422
|
}
|
|
423
423
|
clear() {
|
|
424
|
-
|
|
424
|
+
n(this, m).length !== 0 && (c(this, m, []), l(this, b, _).call(this));
|
|
425
425
|
}
|
|
426
426
|
getLogs() {
|
|
427
|
-
return
|
|
427
|
+
return n(this, m);
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
|
-
|
|
431
|
-
for (const t of
|
|
430
|
+
m = new WeakMap(), P = new WeakMap(), I = new WeakMap(), b = new WeakSet(), _ = function() {
|
|
431
|
+
for (const t of n(this, P)) t(n(this, m));
|
|
432
432
|
};
|
|
433
|
-
const
|
|
434
|
-
function
|
|
433
|
+
const q = new V();
|
|
434
|
+
function G(r, t = q) {
|
|
435
435
|
return (...e) => {
|
|
436
|
-
t.emit(
|
|
436
|
+
t.emit(r, e);
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
|
-
function
|
|
440
|
-
const
|
|
441
|
-
for (const
|
|
442
|
-
const o = t[
|
|
439
|
+
function W(r, t, e = q) {
|
|
440
|
+
const i = { ...r };
|
|
441
|
+
for (const s of Object.keys(t)) {
|
|
442
|
+
const o = t[s];
|
|
443
443
|
if (o === void 0) continue;
|
|
444
444
|
const h = o.action !== void 0 && o.action !== !1, d = o.type === "function";
|
|
445
|
-
if (!h && !d || typeof
|
|
446
|
-
const g = typeof o.action == "string" ? o.action :
|
|
447
|
-
|
|
445
|
+
if (!h && !d || typeof i[s] == "function") continue;
|
|
446
|
+
const g = typeof o.action == "string" ? o.action : s;
|
|
447
|
+
i[s] = G(g, e);
|
|
448
448
|
}
|
|
449
|
-
return n;
|
|
450
|
-
}
|
|
451
|
-
function Y(i) {
|
|
452
449
|
return i;
|
|
453
450
|
}
|
|
451
|
+
function Y(r) {
|
|
452
|
+
return r;
|
|
453
|
+
}
|
|
454
|
+
const H = `
|
|
455
|
+
import { reactAdapter } from '@jogak/react'
|
|
456
|
+
import { defaultRegistry } from '@jogak/core'
|
|
457
|
+
__EXTRA_IMPORTS__
|
|
458
|
+
|
|
459
|
+
const rootEl = document.getElementById('jogak-preview-root')
|
|
460
|
+
if (rootEl === null) throw new Error('[jogak] #jogak-preview-root not found')
|
|
461
|
+
|
|
462
|
+
let currentContainer = null
|
|
463
|
+
|
|
464
|
+
async function renderEntry(entryId, args) {
|
|
465
|
+
const entry = await defaultRegistry.requestEntry(entryId)
|
|
466
|
+
if (currentContainer === null) {
|
|
467
|
+
currentContainer = document.createElement('div')
|
|
468
|
+
rootEl.replaceChildren(currentContainer)
|
|
469
|
+
}
|
|
470
|
+
reactAdapter.render(entry, args, currentContainer)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function unmount() {
|
|
474
|
+
if (currentContainer !== null) {
|
|
475
|
+
reactAdapter.unmount(currentContainer)
|
|
476
|
+
currentContainer = null
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
window.addEventListener('message', (event) => {
|
|
481
|
+
const data = event.data
|
|
482
|
+
if (data == null || typeof data !== 'object') return
|
|
483
|
+
if (data.type === 'jogak:setProps') {
|
|
484
|
+
void renderEntry(data.entryId, data.args ?? {}).then(() => {
|
|
485
|
+
window.parent.postMessage({ type: 'jogak:rendered', entryId: data.entryId }, '*')
|
|
486
|
+
}).catch((err) => {
|
|
487
|
+
window.parent.postMessage({ type: 'jogak:error', message: String(err?.message ?? err) }, '*')
|
|
488
|
+
})
|
|
489
|
+
} else if (data.type === 'jogak:unmount') {
|
|
490
|
+
unmount()
|
|
491
|
+
}
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
window.parent.postMessage({ type: 'jogak:ready' }, '*')
|
|
495
|
+
`;
|
|
496
|
+
function Z(r = {}) {
|
|
497
|
+
const e = (r.extraImports ?? []).map((i) => `import ${JSON.stringify(i)}`).join(`
|
|
498
|
+
`);
|
|
499
|
+
return H.replace("__EXTRA_IMPORTS__", e);
|
|
500
|
+
}
|
|
454
501
|
export {
|
|
455
|
-
|
|
502
|
+
V as ActionChannel,
|
|
456
503
|
B as ComponentRegistry,
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
504
|
+
F as UnknownEntryError,
|
|
505
|
+
G as action,
|
|
506
|
+
q as defaultActionChannel,
|
|
507
|
+
Q as defaultRegistry,
|
|
461
508
|
Y as defineJogakConfig,
|
|
462
|
-
|
|
509
|
+
W as injectActions,
|
|
510
|
+
Z as renderPreviewEntrySource
|
|
463
511
|
};
|