@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/dist/index.mjs CHANGED
@@ -1,48 +1,48 @@
1
1
  var J = Object.defineProperty;
2
- var I = (i) => {
3
- throw TypeError(i);
2
+ var L = (r) => {
3
+ throw TypeError(r);
4
4
  };
5
- var R = (i, t, e) => t in i ? J(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
6
- var N = (i, t, e) => R(i, typeof t != "symbol" ? t + "" : t, e), z = (i, t, e) => t.has(i) || I("Cannot " + e);
7
- var s = (i, t, e) => (z(i, t, "read from private field"), e ? e.call(i) : t.get(i)), u = (i, t, e) => t.has(i) ? I("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(i) : t.set(i, e), c = (i, t, e, n) => (z(i, t, "write to private field"), n ? n.call(i, e) : t.set(i, e), e), f = (i, t, e) => (z(i, t, "access private method"), e);
8
- var O = (i, t, e, n) => ({
9
- set _(r) {
10
- c(i, t, r, e);
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 s(i, t, n);
13
+ return n(r, t, i);
14
14
  }
15
15
  });
16
- class U extends Error {
16
+ class F extends Error {
17
17
  constructor(e) {
18
18
  super(`[jogak] Unknown entry id: ${e}`);
19
- N(this, "id");
19
+ O(this, "id");
20
20
  this.name = "UnknownEntryError", this.id = e;
21
21
  }
22
22
  }
23
- var a, P, b, v, k, E, w, j, A, T, l, m, C, q;
23
+ var a, M, C, v, k, E, w, j, A, T, u, p, x, $;
24
24
  class B {
25
25
  constructor() {
26
- u(this, l);
27
- u(this, a, /* @__PURE__ */ new Map());
28
- u(this, P);
26
+ f(this, u);
27
+ f(this, a, /* @__PURE__ */ new Map());
28
+ f(this, M);
29
29
  // ── F2: subscribe + 내부 캐시 ────────────────────────────────────────
30
- u(this, b, /* @__PURE__ */ new Set());
31
- u(this, v);
32
- u(this, k);
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
- u(this, E);
35
- u(this, w);
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
- u(this, j);
41
+ f(this, j);
42
42
  /** register()가 registerMeta + hydrateEntry를 합쳐 호출할 때 중간 notify를 억제한다. */
43
- u(this, A, !1);
43
+ f(this, A, !1);
44
44
  /** batch 도중에 mutation이 한 번이라도 일어났는지 — false면 batch 종료 시 notify 안 한다. */
45
- u(this, T, !1);
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 = V(t);
57
- f(this, l, q).call(this, () => {
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 = s(this, a).get(t);
63
- e !== void 0 && (e.kind === "pending" && e.reject(new U(t)), s(this, a).delete(t), f(this, l, m).call(this));
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 = s(this, a).get(t);
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 (s(this, E) !== void 0) return s(this, E);
72
+ if (n(this, E) !== void 0) return n(this, E);
73
73
  const t = [];
74
- for (const n of f(this, l, C).call(this)) {
75
- const r = s(this, a).get(n);
76
- (r == null ? void 0 : r.kind) === "hydrated" && t.push(r.entry);
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((n) => n.title.toLowerCase().includes(e));
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 (s(this, w) !== void 0) return s(this, w);
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 n = e.title.split("/");
96
- let r = t;
97
- for (let h = 0; h < n.length - 1; h++) {
98
- const d = n[h];
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 = r[d];
101
- (g === void 0 || "id" in g) && (r[d] = {}), r = r[d];
100
+ const g = s[d];
101
+ (g === void 0 || "id" in g) && (s[d] = {}), s = s[d];
102
102
  }
103
- const o = n[n.length - 1];
104
- o !== void 0 && (r[o] = e);
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 (s(this, a).size !== 0) {
110
- for (const t of s(this, a).values())
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
- s(this, a).clear(), f(this, l, m).call(this);
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 s(this, a).values())
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 = s(this, a).get(t.id);
128
+ const e = n(this, a).get(t.id);
129
129
  if (e === void 0) {
130
- s(this, a).set(t.id, { kind: "meta", meta: t }), f(this, l, m).call(this);
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
- s(this, a).set(t.id, { kind: "meta", meta: t }), f(this, l, m).call(this);
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
- s(this, a).set(t.id, {
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
- }), f(this, l, m).call(this);
144
+ }), l(this, u, p).call(this);
145
145
  return;
146
146
  }
147
- const n = {
147
+ const i = {
148
148
  ...e.entry,
149
149
  title: t.title,
150
150
  filePath: t.filePath,
151
151
  source: t.source,
152
- meta: $(t, e.entry.meta.component)
152
+ meta: N(t, e.entry.meta.component)
153
153
  };
154
- s(this, a).set(t.id, { kind: "hydrated", meta: t, entry: n }), f(this, l, m).call(this);
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, n) {
161
- const r = s(this, a).get(t);
160
+ hydrateEntry(t, e, i) {
161
+ const s = n(this, a).get(t);
162
162
  let o;
163
- r === void 0 ? (console.warn(
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 = r.meta;
174
+ }) : o = s.meta;
175
175
  const h = {
176
176
  id: o.id,
177
177
  title: o.title,
178
178
  jogaks: e,
179
- meta: $(o, n),
179
+ meta: N(o, i),
180
180
  ...o.filePath ? { filePath: o.filePath } : {},
181
181
  ...o.source ? { source: o.source } : {}
182
182
  };
183
- if ((r == null ? void 0 : r.kind) === "pending") {
184
- s(this, a).set(t, { kind: "hydrated", meta: o, entry: h }), f(this, l, m).call(this), r.resolve(h);
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
- s(this, a).set(t, { kind: "hydrated", meta: o, entry: h }), f(this, l, m).call(this);
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 = s(this, a).get(t);
196
- e === void 0 || e.kind !== "hydrated" || (s(this, a).set(t, { kind: "meta", meta: e.meta }), f(this, l, m).call(this));
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 = s(this, a).get(t);
207
+ const e = n(this, a).get(t);
208
208
  if (e === void 0)
209
- return Promise.reject(new U(t));
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 n = s(this, P);
215
- if (n === void 0)
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 r, o;
221
+ let s, o;
222
222
  const h = new Promise((d, g) => {
223
- r = d, o = g;
223
+ s = d, o = g;
224
224
  });
225
- return s(this, a).set(t, {
225
+ return n(this, a).set(t, {
226
226
  kind: "pending",
227
227
  meta: e.meta,
228
228
  promise: h,
229
- resolve: r,
229
+ resolve: s,
230
230
  reject: o
231
- }), n(t).then(
231
+ }), i(t).then(
232
232
  () => {
233
- const d = s(this, a).get(t);
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 = s(this, a).get(t);
240
- (y == null ? void 0 : y.kind) === "pending" && y.promise === h && s(this, a).set(t, { kind: "meta", meta: e.meta }), o(g);
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 (s(this, v) !== void 0) return s(this, v);
251
+ if (n(this, v) !== void 0) return n(this, v);
252
252
  const t = [];
253
- for (const n of f(this, l, C).call(this)) {
254
- const r = s(this, a).get(n);
255
- r !== void 0 && t.push(r.meta);
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 (s(this, k) !== void 0) return s(this, k);
265
+ if (n(this, k) !== void 0) return n(this, k);
266
266
  const t = {};
267
- for (const e of f(this, l, C).call(this)) {
268
- const n = s(this, a).get(e);
269
- if (n === void 0) continue;
270
- const r = n.meta, o = r.title.split("/");
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 L = h[y];
276
- (L === void 0 || "id" in L) && (h[y] = {}), h = h[y];
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] = r);
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 = s(this, a).get(t);
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, P, t);
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
- s(this, b).add(t);
307
+ n(this, C).add(t);
308
308
  let e = !0;
309
309
  return () => {
310
- e && (e = !1, s(this, b).delete(t));
310
+ e && (e = !1, n(this, C).delete(t));
311
311
  };
312
312
  }
313
313
  }
314
- a = new WeakMap(), P = 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(), // ── 내부 헬퍼 ─────────────────────────────────────────────────────────
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
- m = 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), s(this, A)) {
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(s(this, b));
324
+ const t = Array.from(n(this, C));
325
325
  for (const e of t)
326
326
  try {
327
327
  e();
328
- } catch (n) {
329
- console.error("[jogak] subscribe listener threw:", n);
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
- C = function() {
338
- if (s(this, j) !== void 0) return s(this, j);
337
+ x = function() {
338
+ if (n(this, j) !== void 0) return n(this, j);
339
339
  const t = [];
340
- for (const [n, r] of s(this, a))
341
- t.push({ id: n, title: r.meta.title });
342
- t.sort(G);
343
- const e = t.map((n) => n.id);
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
- q = function(t) {
350
- if (s(this, A)) {
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), s(this, T) && (c(this, T, !1), f(this, l, m).call(this));
358
+ c(this, A, !1), n(this, T) && (c(this, T, !1), l(this, u, p).call(this));
359
359
  }
360
360
  };
361
- function V(i) {
362
- const t = i.meta.argTypes ?? {};
361
+ function D(r) {
362
+ const t = r.meta.argTypes ?? {};
363
363
  return {
364
- id: i.id,
365
- title: i.title,
366
- jogakNames: i.jogaks.map((e) => e.name),
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: i.source ?? "",
370
- filePath: i.filePath ?? "",
369
+ source: r.source ?? "",
370
+ filePath: r.filePath ?? "",
371
371
  metaExtras: {
372
- ...i.meta.tags !== void 0 ? { tags: i.meta.tags } : {},
373
- ...i.meta.parameters !== void 0 ? { parameters: i.meta.parameters } : {}
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 $(i, t) {
377
+ function N(r, t) {
378
378
  const e = {
379
- ...i.autoArgTypes
379
+ ...r.autoArgTypes
380
380
  };
381
- for (const n of Object.keys(i.userArgTypes)) {
382
- const r = i.userArgTypes[n];
383
- r !== void 0 && (e[n] = { ...e[n], ...r });
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: i.title,
386
+ title: r.title,
387
387
  component: t,
388
388
  argTypes: e,
389
- ...i.metaExtras.tags !== void 0 ? { tags: i.metaExtras.tags } : {},
390
- ...i.metaExtras.parameters !== void 0 ? { parameters: i.metaExtras.parameters } : {}
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 G(i, t) {
394
- const e = i.title.localeCompare(t.title, "en", {
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 : i.id.localeCompare(t.id, "en", { sensitivity: "base", numeric: !0 });
398
+ return e !== 0 ? e : r.id.localeCompare(t.id, "en", { sensitivity: "base", numeric: !0 });
399
399
  }
400
- const W = new B();
401
- var p, x, S, M, F;
402
- class H {
400
+ const Q = new B();
401
+ var m, P, I, b, _;
402
+ class V {
403
403
  constructor() {
404
- u(this, M);
405
- u(this, p, []);
406
- u(this, x, /* @__PURE__ */ new Set());
407
- u(this, S, 1);
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 n = {
411
- id: O(this, S)._++,
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, p, [...s(this, p), n]), f(this, M, F).call(this);
416
+ c(this, m, [...n(this, m), i]), l(this, b, _).call(this);
417
417
  }
418
418
  subscribe(t) {
419
- return s(this, x).add(t), t(s(this, p)), () => {
420
- s(this, x).delete(t);
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
- s(this, p).length !== 0 && (c(this, p, []), f(this, M, F).call(this));
424
+ n(this, m).length !== 0 && (c(this, m, []), l(this, b, _).call(this));
425
425
  }
426
426
  getLogs() {
427
- return s(this, p);
427
+ return n(this, m);
428
428
  }
429
429
  }
430
- p = new WeakMap(), x = new WeakMap(), S = new WeakMap(), M = new WeakSet(), F = function() {
431
- for (const t of s(this, x)) t(s(this, p));
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 D = new H();
434
- function K(i, t = D) {
433
+ const q = new V();
434
+ function G(r, t = q) {
435
435
  return (...e) => {
436
- t.emit(i, e);
436
+ t.emit(r, e);
437
437
  };
438
438
  }
439
- function X(i, t, e = D) {
440
- const n = { ...i };
441
- for (const r of Object.keys(t)) {
442
- const o = t[r];
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 n[r] == "function") continue;
446
- const g = typeof o.action == "string" ? o.action : r;
447
- n[r] = K(g, e);
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
- H as ActionChannel,
502
+ V as ActionChannel,
456
503
  B as ComponentRegistry,
457
- U as UnknownEntryError,
458
- K as action,
459
- D as defaultActionChannel,
460
- W as defaultRegistry,
504
+ F as UnknownEntryError,
505
+ G as action,
506
+ q as defaultActionChannel,
507
+ Q as defaultRegistry,
461
508
  Y as defineJogakConfig,
462
- X as injectActions
509
+ W as injectActions,
510
+ Z as renderPreviewEntrySource
463
511
  };