@moon-x/core 0.10.0 → 0.11.0

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,4 +1,4 @@
1
- export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-2NAnU0Lf.mjs';
1
+ export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-BR2NClJ5.mjs';
2
2
 
3
3
  /**
4
4
  * Get the appropriate MoonKey API URL based on environment configuration
@@ -8,4 +8,16 @@ declare const getMoonKeyApiUrl: () => string;
8
8
  declare const getIframeUrl: (path?: string) => string;
9
9
  declare const getIframeOrigin: (url: string) => string;
10
10
 
11
- export { getIframeOrigin, getIframeUrl, getMoonKeyApiUrl };
11
+ /**
12
+ * Reserved key in the SDK → iframe `theme` query-param map. Its value is a JSON
13
+ * array of font-stylesheet URLs (NOT a CSS custom property); the iframe applier
14
+ * injects them as `<link rel="stylesheet">` rather than calling `setProperty`.
15
+ *
16
+ * Lives in `@moon-x/core` so the producer (react-sdk's `serializeThemeVars`) and
17
+ * the consumer (the iframe's `applyThemeParam`) share one source of truth — a
18
+ * rename is then a compile error on both sides instead of a silent wire-contract
19
+ * drift.
20
+ */
21
+ declare const FONT_URLS_KEY = "__moonxFontUrls";
22
+
23
+ export { FONT_URLS_KEY, getIframeOrigin, getIframeUrl, getMoonKeyApiUrl };
@@ -1,4 +1,4 @@
1
- export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-2NAnU0Lf.js';
1
+ export { F as FORWARDED_ERROR_FIELDS, P as PostMessageClient, a as PostMessageMethod, b as PostMessageServer, c as PostMessageType } from '../post-message-BR2NClJ5.js';
2
2
 
3
3
  /**
4
4
  * Get the appropriate MoonKey API URL based on environment configuration
@@ -8,4 +8,16 @@ declare const getMoonKeyApiUrl: () => string;
8
8
  declare const getIframeUrl: (path?: string) => string;
9
9
  declare const getIframeOrigin: (url: string) => string;
10
10
 
11
- export { getIframeOrigin, getIframeUrl, getMoonKeyApiUrl };
11
+ /**
12
+ * Reserved key in the SDK → iframe `theme` query-param map. Its value is a JSON
13
+ * array of font-stylesheet URLs (NOT a CSS custom property); the iframe applier
14
+ * injects them as `<link rel="stylesheet">` rather than calling `setProperty`.
15
+ *
16
+ * Lives in `@moon-x/core` so the producer (react-sdk's `serializeThemeVars`) and
17
+ * the consumer (the iframe's `applyThemeParam`) share one source of truth — a
18
+ * rename is then a compile error on both sides instead of a silent wire-contract
19
+ * drift.
20
+ */
21
+ declare const FONT_URLS_KEY = "__moonxFontUrls";
22
+
23
+ export { FONT_URLS_KEY, getIframeOrigin, getIframeUrl, getMoonKeyApiUrl };
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/utils/index.ts
21
21
  var utils_exports = {};
22
22
  __export(utils_exports, {
23
+ FONT_URLS_KEY: () => FONT_URLS_KEY,
23
24
  FORWARDED_ERROR_FIELDS: () => FORWARDED_ERROR_FIELDS,
24
25
  PostMessageClient: () => PostMessageClient,
25
26
  PostMessageMethod: () => PostMessageMethod,
@@ -292,12 +293,13 @@ var PostMessageServer = class {
292
293
  if (queued?.length) {
293
294
  this.pending.delete(key);
294
295
  const now = Date.now();
295
- for (const { request, reply, at } of queued) {
296
+ for (const { request, reply, at, ctx } of queued) {
296
297
  if (now - at < QUEUE_TTL_MS) {
297
298
  void this.invokeHandler(
298
299
  handler,
299
300
  request,
300
- reply
301
+ reply,
302
+ ctx
301
303
  );
302
304
  }
303
305
  }
@@ -349,7 +351,7 @@ var PostMessageServer = class {
349
351
  id: request.id,
350
352
  type: request.type,
351
353
  success: false,
352
- error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonKey dashboard.`
354
+ error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonX dashboard.`
353
355
  });
354
356
  return;
355
357
  }
@@ -366,14 +368,20 @@ var PostMessageServer = class {
366
368
  const key = `${request.type}:${request.method}`;
367
369
  const handler = this.handlers.get(key);
368
370
  if (handler) {
369
- await this.invokeHandler(handler, request, reply);
371
+ await this.invokeHandler(handler, request, reply, {
372
+ origin: event.origin,
373
+ source: event.source
374
+ });
370
375
  } else {
371
- this.bufferRequest(key, request, reply);
376
+ this.bufferRequest(key, request, reply, {
377
+ origin: event.origin,
378
+ source: event.source
379
+ });
372
380
  }
373
381
  }
374
- async invokeHandler(handler, request, reply) {
382
+ async invokeHandler(handler, request, reply, ctx) {
375
383
  try {
376
- const data = await handler(request.payload);
384
+ const data = await handler(request.payload, ctx);
377
385
  reply({
378
386
  id: request.id,
379
387
  type: request.type,
@@ -397,14 +405,14 @@ var PostMessageServer = class {
397
405
  });
398
406
  }
399
407
  }
400
- bufferRequest(key, request, reply) {
408
+ bufferRequest(key, request, reply, ctx) {
401
409
  this.evictExpiredPending();
402
410
  let queue = this.pending.get(key);
403
411
  if (!queue) {
404
412
  queue = [];
405
413
  this.pending.set(key, queue);
406
414
  }
407
- queue.push({ request, reply, at: Date.now() });
415
+ queue.push({ request, reply, at: Date.now(), ctx });
408
416
  if (queue.length > MAX_PENDING_PER_KEY) {
409
417
  queue.splice(0, queue.length - MAX_PENDING_PER_KEY);
410
418
  }
@@ -421,8 +429,12 @@ var PostMessageServer = class {
421
429
  }
422
430
  }
423
431
  };
432
+
433
+ // src/utils/theme-param.ts
434
+ var FONT_URLS_KEY = "__moonxFontUrls";
424
435
  // Annotate the CommonJS export names for ESM import in node:
425
436
  0 && (module.exports = {
437
+ FONT_URLS_KEY,
426
438
  FORWARDED_ERROR_FIELDS,
427
439
  PostMessageClient,
428
440
  PostMessageMethod,
@@ -1,4 +1,6 @@
1
- import "../chunk-CMYR6AOY.mjs";
1
+ import {
2
+ FONT_URLS_KEY
3
+ } from "../chunk-527SU2F6.mjs";
2
4
  import {
3
5
  getIframeOrigin,
4
6
  getIframeUrl
@@ -9,11 +11,12 @@ import {
9
11
  PostMessageMethod,
10
12
  PostMessageServer,
11
13
  PostMessageType
12
- } from "../chunk-KRZVIDBQ.mjs";
14
+ } from "../chunk-Z57WM6IO.mjs";
13
15
  import {
14
16
  getMoonKeyApiUrl
15
17
  } from "../chunk-GQKIA37O.mjs";
16
18
  export {
19
+ FONT_URLS_KEY,
17
20
  FORWARDED_ERROR_FIELDS,
18
21
  PostMessageClient,
19
22
  PostMessageMethod,
@@ -1,5 +1,5 @@
1
- import { P as PostMessageClient } from '../post-message-2NAnU0Lf.mjs';
2
- import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-CF5UrEBb.mjs';
1
+ import { P as PostMessageClient } from '../post-message-BR2NClJ5.mjs';
2
+ import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-Bt5CAMSt.mjs';
3
3
 
4
4
  declare const getCachedPostMessageClient: (contentWindow: Window) => PostMessageClient;
5
5
  /**
@@ -1,5 +1,5 @@
1
- import { P as PostMessageClient } from '../post-message-2NAnU0Lf.js';
2
- import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-B5zxo2Jx.js';
1
+ import { P as PostMessageClient } from '../post-message-BR2NClJ5.js';
2
+ import { T as Transport, P as PasskeyAssertor, K as KvStorage } from '../interfaces-pGbKBjWD.js';
3
3
 
4
4
  declare const getCachedPostMessageClient: (contentWindow: Window) => PostMessageClient;
5
5
  /**
package/dist/web/index.js CHANGED
@@ -137,12 +137,13 @@ var PostMessageServer = class {
137
137
  if (queued?.length) {
138
138
  this.pending.delete(key);
139
139
  const now = Date.now();
140
- for (const { request, reply, at } of queued) {
140
+ for (const { request, reply, at, ctx } of queued) {
141
141
  if (now - at < QUEUE_TTL_MS) {
142
142
  void this.invokeHandler(
143
143
  handler,
144
144
  request,
145
- reply
145
+ reply,
146
+ ctx
146
147
  );
147
148
  }
148
149
  }
@@ -194,7 +195,7 @@ var PostMessageServer = class {
194
195
  id: request.id,
195
196
  type: request.type,
196
197
  success: false,
197
- error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonKey dashboard.`
198
+ error: `Origin ${event.origin} is not whitelisted. Please add it to your MoonX dashboard.`
198
199
  });
199
200
  return;
200
201
  }
@@ -211,14 +212,20 @@ var PostMessageServer = class {
211
212
  const key = `${request.type}:${request.method}`;
212
213
  const handler = this.handlers.get(key);
213
214
  if (handler) {
214
- await this.invokeHandler(handler, request, reply);
215
+ await this.invokeHandler(handler, request, reply, {
216
+ origin: event.origin,
217
+ source: event.source
218
+ });
215
219
  } else {
216
- this.bufferRequest(key, request, reply);
220
+ this.bufferRequest(key, request, reply, {
221
+ origin: event.origin,
222
+ source: event.source
223
+ });
217
224
  }
218
225
  }
219
- async invokeHandler(handler, request, reply) {
226
+ async invokeHandler(handler, request, reply, ctx) {
220
227
  try {
221
- const data = await handler(request.payload);
228
+ const data = await handler(request.payload, ctx);
222
229
  reply({
223
230
  id: request.id,
224
231
  type: request.type,
@@ -242,14 +249,14 @@ var PostMessageServer = class {
242
249
  });
243
250
  }
244
251
  }
245
- bufferRequest(key, request, reply) {
252
+ bufferRequest(key, request, reply, ctx) {
246
253
  this.evictExpiredPending();
247
254
  let queue = this.pending.get(key);
248
255
  if (!queue) {
249
256
  queue = [];
250
257
  this.pending.set(key, queue);
251
258
  }
252
- queue.push({ request, reply, at: Date.now() });
259
+ queue.push({ request, reply, at: Date.now(), ctx });
253
260
  if (queue.length > MAX_PENDING_PER_KEY) {
254
261
  queue.splice(0, queue.length - MAX_PENDING_PER_KEY);
255
262
  }
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  PostMessageClient,
7
7
  PostMessageServer
8
- } from "../chunk-KRZVIDBQ.mjs";
8
+ } from "../chunk-Z57WM6IO.mjs";
9
9
 
10
10
  // src/web/iframe-transport.ts
11
11
  var clientCache = /* @__PURE__ */ new WeakMap();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moon-x/core",
3
- "version": "0.10.0",
3
+ "version": "0.11.0",
4
4
  "license": "UNLICENSED",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -66,13 +66,14 @@
66
66
  "@testing-library/react": "16.3.2",
67
67
  "@types/react": "19.2.14",
68
68
  "@types/react-dom": "19.2.3",
69
- "@vitest/ui": "1.6.1",
69
+ "@vitest/ui": "4.1.0",
70
70
  "happy-dom": "20.8.9",
71
71
  "react": "18.3.1",
72
72
  "react-dom": "18.3.1",
73
73
  "tsup": "8.5.1",
74
74
  "typescript": "5.9.3",
75
- "vitest": "1.6.1"
75
+ "vite": "7.3.5",
76
+ "vitest": "4.1.0"
76
77
  },
77
78
  "peerDependencies": {
78
79
  "@solana/web3.js": "^1.98.4",
File without changes