@veryfront/ext-content-mdx 0.1.1122 → 0.1.1124

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/esm/deno.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export default {
2
2
  "name": "veryfront",
3
- "version": "0.1.1122",
3
+ "version": "0.1.1124",
4
4
  "license": "Apache-2.0",
5
5
  "nodeModulesDir": "auto",
6
6
  "minimumDependencyAge": {
@@ -1,5 +1,13 @@
1
- /** Encode a UTF-8 string as standard base64 (handles non-Latin1 input). */
1
+ /**
2
+ * Encode a string as standard base64. Latin-1 input (all code points <= 0xFF)
3
+ * is encoded with btoa's binary-string semantics; input outside Latin-1 falls
4
+ * back to UTF-8 bytes. Callers that need guaranteed UTF-8 bytes regardless of
5
+ * input (e.g. data: URLs decoded as UTF-8) should use
6
+ * `encodeBase64Bytes(new TextEncoder().encode(value))` instead.
7
+ */
2
8
  export declare function encodeBase64(value: string): string;
9
+ /** Encode raw bytes as standard base64. */
10
+ export declare function encodeBase64Bytes(bytes: Uint8Array): string;
3
11
  /** Encode a string as unpadded base64url. */
4
12
  export declare function base64urlEncode(input: string): string;
5
13
  /** Encode raw bytes as unpadded base64url. */
@@ -1 +1 @@
1
- {"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../../src/src/utils/base64url.ts"],"names":[],"mappings":"AAYA,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAkBlD;AAED,6CAA6C;AAC7C,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAI9D"}
1
+ {"version":3,"file":"base64url.d.ts","sourceRoot":"","sources":["../../../src/src/utils/base64url.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAelD;AAED,2CAA2C;AAC3C,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAa3D;AAED,6CAA6C;AAC7C,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErD;AAED,8CAA8C;AAC9C,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE9D"}
@@ -5,19 +5,21 @@ import * as dntShim from "../../_dnt.shims.js";
5
5
  function toBase64Url(b64) {
6
6
  return b64.replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
7
7
  }
8
- /** Encode a UTF-8 string as standard base64 (handles non-Latin1 input). */
8
+ /**
9
+ * Encode a string as standard base64. Latin-1 input (all code points <= 0xFF)
10
+ * is encoded with btoa's binary-string semantics; input outside Latin-1 falls
11
+ * back to UTF-8 bytes. Callers that need guaranteed UTF-8 bytes regardless of
12
+ * input (e.g. data: URLs decoded as UTF-8) should use
13
+ * `encodeBase64Bytes(new TextEncoder().encode(value))` instead.
14
+ */
9
15
  export function encodeBase64(value) {
10
16
  if (typeof globalThis.btoa === "function") {
11
17
  try {
12
18
  return globalThis.btoa(value);
13
19
  }
14
20
  catch (_) {
15
- /* expected: non-Latin1 string — fall back to TextEncoder */
16
- const bytes = new TextEncoder().encode(value);
17
- let binary = "";
18
- for (const byte of bytes)
19
- binary += String.fromCharCode(byte);
20
- return globalThis.btoa(binary);
21
+ /* expected: non-Latin1 string — fall back to UTF-8 bytes */
22
+ return encodeBase64Bytes(new TextEncoder().encode(value));
21
23
  }
22
24
  }
23
25
  const bufferCtor = dntShim.dntGlobalThis.Buffer;
@@ -26,14 +28,26 @@ export function encodeBase64(value) {
26
28
  // This file ships in client bundles — keep it dependency-free (no error registry).
27
29
  throw new Error("Base64 encoding is not supported in this runtime");
28
30
  }
31
+ /** Encode raw bytes as standard base64. */
32
+ export function encodeBase64Bytes(bytes) {
33
+ // Prefer Buffer where available (Node): avoids building a large intermediate
34
+ // binary string, which is slower and can hit maximum-string-size limits.
35
+ const bufferCtor = dntShim.dntGlobalThis.Buffer;
36
+ if (bufferCtor)
37
+ return bufferCtor.from(bytes).toString("base64");
38
+ if (typeof globalThis.btoa === "function") {
39
+ let binary = "";
40
+ for (const byte of bytes)
41
+ binary += String.fromCharCode(byte);
42
+ return globalThis.btoa(binary);
43
+ }
44
+ throw new Error("Base64 encoding is not supported in this runtime");
45
+ }
29
46
  /** Encode a string as unpadded base64url. */
30
47
  export function base64urlEncode(input) {
31
48
  return toBase64Url(encodeBase64(input));
32
49
  }
33
50
  /** Encode raw bytes as unpadded base64url. */
34
51
  export function base64urlEncodeBytes(bytes) {
35
- let binary = "";
36
- for (const byte of bytes)
37
- binary += String.fromCharCode(byte);
38
- return toBase64Url(btoa(binary));
52
+ return toBase64Url(encodeBase64Bytes(bytes));
39
53
  }
@@ -17,8 +17,9 @@ export { redactSensitive, sanitizeUrlCredentials, sanitizeUrlForSpan } from "./l
17
17
  export { BREAKPOINT_LG, BREAKPOINT_MD, BREAKPOINT_SM, BREAKPOINT_XL, BYTES_PER_KB, DEFAULT_ALLOWED_CDN_HOSTS, DEFAULT_BUILD_CONCURRENCY, DEFAULT_DASHBOARD_PORT, DEFAULT_LRU_MAX_ENTRIES, DEV_SERVER_ENDPOINTS, FORBIDDEN_PATH_PATTERNS, getDenoStdNodeBase, getReactImportMap, HASH_SEED_DJB2, HASH_SEED_FNV1A, HMR_CLIENT_RELOAD_DELAY_MS, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_RATE_LIMIT_WINDOW_MS, HTTP_BAD_REQUEST, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPES, HTTP_MODULE_FETCH_TIMEOUT_MS, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_OK, HTTP_REDIRECT_FOUND, HTTP_SERVER_ERROR, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_STATUS_SUCCESS_MIN, HTTP_UNAVAILABLE, IMAGE_OPTIMIZATION, MAX_BATCH_SIZE, MAX_PATH_LENGTH, MAX_PATH_TRAVERSAL_DEPTH, MS_PER_SECOND, PREFETCH_DEFAULT_DELAY_MS, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, REACT_DEFAULT_VERSION, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, RSC_MANIFEST_CACHE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_PER_PROJECT_MAX_ENTRIES, Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, } from "./constants/index.js";
18
18
  export { VERSION } from "./version.js";
19
19
  export { type BundleCode as HashBundleCode, computeCodeHash, computeHash, computeHashBytes, fnv1aHash, shortHash, simpleHash, } from "./hash-utils.js";
20
- export { base64urlEncode, base64urlEncodeBytes, encodeBase64 } from "./base64url.js";
20
+ export { base64urlEncode, base64urlEncodeBytes, encodeBase64, encodeBase64Bytes, } from "./base64url.js";
21
21
  export { sleep } from "./sleep.js";
22
+ export { createSubscriberSet, type SubscriberSet } from "./subscriber-set.js";
22
23
  export { MemoCache, memoize, memoizeAsync, simpleHash as memoizeHash } from "./memoize.js";
23
24
  export { normalizePath } from "./path-utils.js";
24
25
  export { type BundleCode, type BundleMetadata, getBundleManifestStore } from "./bundle-manifest.js";
@@ -27,4 +28,5 @@ export { isCompiledBinary } from "./platform.js";
27
28
  export { computeIntegrity, createLockfileManager, type LockfileManager, } from "./import-lockfile.js";
28
29
  export { endRequest, isEnabled, startRequest, startTimer, timeAsync } from "./perf-timer.js";
29
30
  export { parallelMap } from "./parallel.js";
31
+ export { safeJsonParse, type SafeJsonParseResult } from "./json.js";
30
32
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/utils/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,GACf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,4BAA4B,IAAI,0BAA0B,EAC1D,WAAW,EACX,aAAa,EACb,SAAS,EACT,mBAAmB,EACnB,aAAa,EACb,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,0BAA0B,EAC1B,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG1E,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAEjG,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,aAAa,EACb,YAAY,EACZ,yBAAyB,EACzB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,0BAA0B,EAC1B,2BAA2B,EAC3B,gBAAgB,EAChB,oBAAoB,EACpB,0BAA0B,EAC1B,2BAA2B,EAC3B,wBAAwB,EACxB,gBAAgB,EAChB,2BAA2B,EAC3B,2BAA2B,EAC3B,4BAA4B,EAC5B,2BAA2B,EAC3B,2BAA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EAAE,MAAM,iBAAiB,CAAC;AAE7F,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,WAAW,CAAC"}
@@ -17,8 +17,9 @@ export { redactSensitive, sanitizeUrlCredentials, sanitizeUrlForSpan } from "./l
17
17
  export { BREAKPOINT_LG, BREAKPOINT_MD, BREAKPOINT_SM, BREAKPOINT_XL, BYTES_PER_KB, DEFAULT_ALLOWED_CDN_HOSTS, DEFAULT_BUILD_CONCURRENCY, DEFAULT_DASHBOARD_PORT, DEFAULT_LRU_MAX_ENTRIES, DEV_SERVER_ENDPOINTS, FORBIDDEN_PATH_PATTERNS, getDenoStdNodeBase, getReactImportMap, HASH_SEED_DJB2, HASH_SEED_FNV1A, HMR_CLIENT_RELOAD_DELAY_MS, HMR_CLOSE_MESSAGE_TOO_LARGE, HMR_CLOSE_NORMAL, HMR_CLOSE_RATE_LIMIT, HMR_MAX_MESSAGE_SIZE_BYTES, HMR_MAX_MESSAGES_PER_MINUTE, HMR_RATE_LIMIT_WINDOW_MS, HTTP_BAD_REQUEST, HTTP_CONTENT_TYPE_IMAGE_GIF, HTTP_CONTENT_TYPE_IMAGE_ICO, HTTP_CONTENT_TYPE_IMAGE_JPEG, HTTP_CONTENT_TYPE_IMAGE_PNG, HTTP_CONTENT_TYPE_IMAGE_SVG, HTTP_CONTENT_TYPE_IMAGE_WEBP, HTTP_CONTENT_TYPES, HTTP_MODULE_FETCH_TIMEOUT_MS, HTTP_NETWORK_CONNECT_TIMEOUT, HTTP_NOT_FOUND, HTTP_NOT_IMPLEMENTED, HTTP_OK, HTTP_REDIRECT_FOUND, HTTP_SERVER_ERROR, HTTP_STATUS_CLIENT_ERROR_MIN, HTTP_STATUS_REDIRECT_MIN, HTTP_STATUS_SERVER_ERROR_MIN, HTTP_STATUS_SUCCESS_MIN, HTTP_UNAVAILABLE, IMAGE_OPTIMIZATION, MAX_BATCH_SIZE, MAX_PATH_LENGTH, MAX_PATH_TRAVERSAL_DEPTH, MS_PER_SECOND, PREFETCH_DEFAULT_DELAY_MS, PREFETCH_DEFAULT_TIMEOUT_MS, PREFETCH_MAX_SIZE_BYTES, REACT_DEFAULT_VERSION, RESPONSIVE_IMAGE_WIDTH_LG, RESPONSIVE_IMAGE_WIDTHS, RSC_MANIFEST_CACHE_TTL_MS, TSX_LAYOUT_MAX_ENTRIES, TSX_LAYOUT_PER_PROJECT_MAX_ENTRIES, Z_INDEX_DEV_INDICATOR, Z_INDEX_ERROR_OVERLAY, } from "./constants/index.js";
18
18
  export { VERSION } from "./version.js";
19
19
  export { computeCodeHash, computeHash, computeHashBytes, fnv1aHash, shortHash, simpleHash, } from "./hash-utils.js";
20
- export { base64urlEncode, base64urlEncodeBytes, encodeBase64 } from "./base64url.js";
20
+ export { base64urlEncode, base64urlEncodeBytes, encodeBase64, encodeBase64Bytes, } from "./base64url.js";
21
21
  export { sleep } from "./sleep.js";
22
+ export { createSubscriberSet } from "./subscriber-set.js";
22
23
  export { MemoCache, memoize, memoizeAsync, simpleHash as memoizeHash } from "./memoize.js";
23
24
  export { normalizePath } from "./path-utils.js";
24
25
  export { getBundleManifestStore } from "./bundle-manifest.js";
@@ -27,3 +28,4 @@ export { isCompiledBinary } from "./platform.js";
27
28
  export { computeIntegrity, createLockfileManager, } from "./import-lockfile.js";
28
29
  export { endRequest, isEnabled, startRequest, startTimer, timeAsync } from "./perf-timer.js";
29
30
  export { parallelMap } from "./parallel.js";
31
+ export { safeJsonParse } from "./json.js";
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Safe JSON parse utilities, dependency-free.
3
+ *
4
+ * @module utils/json
5
+ */
6
+ /** Tagged-union result of {@link safeJsonParse}; narrow via the `ok` discriminant. */
7
+ export type SafeJsonParseResult<T = unknown> = {
8
+ ok: true;
9
+ value: T;
10
+ } | {
11
+ ok: false;
12
+ error: Error;
13
+ };
14
+ /**
15
+ * Parse `value` as JSON without throwing; failures return `{ ok: false, error }`
16
+ * so callers handle them without a surrounding try/catch.
17
+ */
18
+ export declare function safeJsonParse<T = unknown>(value: string): SafeJsonParseResult<T>;
19
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/src/utils/json.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,sFAAsF;AACtF,MAAM,MAAM,mBAAmB,CAAC,CAAC,GAAG,OAAO,IACvC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GACtB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,CAAC;AAEhC;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAAC,CAAC,CAAC,CAMhF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Safe JSON parse utilities, dependency-free.
3
+ *
4
+ * @module utils/json
5
+ */
6
+ /**
7
+ * Parse `value` as JSON without throwing; failures return `{ ok: false, error }`
8
+ * so callers handle them without a surrounding try/catch.
9
+ */
10
+ export function safeJsonParse(value) {
11
+ try {
12
+ return { ok: true, value: JSON.parse(value) };
13
+ }
14
+ catch (error) {
15
+ return { ok: false, error: error instanceof Error ? error : new Error(String(error)) };
16
+ }
17
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,eAAe,CAAC;AA8CrC;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAcnD;AA6ED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAEhD;AA2BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA4B5D;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBxD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,CAAC,SAAS;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,EAC5D,KAAK,EAAE,CAAC,GAAG,CAAC,CAMb"}
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../../../../src/src/utils/logger/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,6DAA6D;AAC7D,eAAO,MAAM,QAAQ,eAAe,CAAC;AAmDrC;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAcnD;AA6ED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAEhD;AA6BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAyB5D;AAqBD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgBxD;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,CAAC,SAAS;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,EAC5D,KAAK,EAAE,CAAC,GAAG,CAAC,CAMb"}
@@ -19,6 +19,10 @@
19
19
  import { isRecord } from "./core.js";
20
20
  /** Replacement value substituted for any sensitive field. */
21
21
  export const REDACTED = "[REDACTED]";
22
+ /** Strip all non-alphanumeric characters and lowercase, used for key normalization. */
23
+ function normalizeToAlphanumeric(s) {
24
+ return s.toLowerCase().replace(/[^a-z0-9]/g, "");
25
+ }
22
26
  /**
23
27
  * Normalized substrings that mark a key as sensitive. Matching is done against
24
28
  * a lowercased, non-alphanumeric-stripped form of the key, so `API-Key`,
@@ -72,7 +76,7 @@ export function isSensitiveKey(key) {
72
76
  const cached = sensitiveKeyCache.get(key);
73
77
  if (cached !== undefined)
74
78
  return cached;
75
- const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
79
+ const normalized = normalizeToAlphanumeric(key);
76
80
  const sensitive = SENSITIVE_KEY_PATTERNS.some((pattern) => normalized.includes(pattern));
77
81
  if (sensitiveKeyCache.size >= SENSITIVE_KEY_CACHE_MAX_SIZE) {
78
82
  const oldestKey = sensitiveKeyCache.keys().next().value;
@@ -191,6 +195,7 @@ const SENSITIVE_URL_PARAMS = [
191
195
  "signature",
192
196
  "auth",
193
197
  ];
198
+ const NORMALIZED_SENSITIVE_URL_PARAMS = new Set(SENSITIVE_URL_PARAMS.map(normalizeToAlphanumeric));
194
199
  const URL_USERINFO_RE = /(\b[a-z][a-z0-9+.-]*:\/\/)([^/?#@\s]+)@/gi;
195
200
  /**
196
201
  * Strip credentials from URL-shaped strings so they can be safely emitted in
@@ -222,8 +227,7 @@ export function sanitizeUrlCredentials(input) {
222
227
  // 2) sensitive query/fragment params: `key=value` → `key=[REDACTED]`.
223
228
  // Match `?key=`, `&key=`, `;key=` separators and stop at the next delimiter.
224
229
  out = out.replace(/([?&;])([a-z0-9_.\-]+)=([^&#;\s]*)/gi, (match, sep, key, _val) => {
225
- const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
226
- const sensitive = SENSITIVE_URL_PARAMS.some((p) => normalized === p.replace(/[^a-z0-9]/g, ""));
230
+ const sensitive = NORMALIZED_SENSITIVE_URL_PARAMS.has(normalizeToAlphanumeric(key));
227
231
  return sensitive ? `${sep}${key}=${REDACTED}` : match;
228
232
  });
229
233
  return out;
@@ -0,0 +1,19 @@
1
+ /** Listener registry returned by {@link createSubscriberSet}. */
2
+ export interface SubscriberSet<Args extends unknown[] = []> {
3
+ /** Register a listener; returns its unsubscribe function. */
4
+ subscribe(listener: (...args: Args) => void): () => void;
5
+ /** Invoke every listener; a throwing listener never stops the others. */
6
+ notify(...args: Args): void;
7
+ /** Number of registered listeners. */
8
+ readonly size: number;
9
+ /** Remove all listeners. */
10
+ clear(): void;
11
+ }
12
+ /**
13
+ * Create a subscriber set: the canonical subscribe/notify observable used
14
+ * across modules. Notification iterates a snapshot, so a listener that
15
+ * unsubscribes (itself or others) mid-notify is safe, and listener errors are
16
+ * isolated (routed to `onListenerError` when provided, otherwise swallowed).
17
+ */
18
+ export declare function createSubscriberSet<Args extends unknown[] = []>(onListenerError?: (error: unknown) => void): SubscriberSet<Args>;
19
+ //# sourceMappingURL=subscriber-set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscriber-set.d.ts","sourceRoot":"","sources":["../../../src/src/utils/subscriber-set.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,WAAW,aAAa,CAAC,IAAI,SAAS,OAAO,EAAE,GAAG,EAAE;IACxD,6DAA6D;IAC7D,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACzD,yEAAyE;IACzE,MAAM,CAAC,GAAG,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAC5B,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4BAA4B;IAC5B,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,SAAS,OAAO,EAAE,GAAG,EAAE,EAC7D,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACzC,aAAa,CAAC,IAAI,CAAC,CA8BrB"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Create a subscriber set: the canonical subscribe/notify observable used
3
+ * across modules. Notification iterates a snapshot, so a listener that
4
+ * unsubscribes (itself or others) mid-notify is safe, and listener errors are
5
+ * isolated (routed to `onListenerError` when provided, otherwise swallowed).
6
+ */
7
+ export function createSubscriberSet(onListenerError) {
8
+ const listeners = new Set();
9
+ return {
10
+ subscribe(listener) {
11
+ listeners.add(listener);
12
+ return () => {
13
+ listeners.delete(listener);
14
+ };
15
+ },
16
+ notify(...args) {
17
+ for (const listener of [...listeners]) {
18
+ try {
19
+ listener(...args);
20
+ }
21
+ catch (error) {
22
+ try {
23
+ onListenerError?.(error);
24
+ }
25
+ catch {
26
+ // A throwing error handler must not break notification either.
27
+ }
28
+ }
29
+ }
30
+ },
31
+ get size() {
32
+ return listeners.size;
33
+ },
34
+ clear() {
35
+ listeners.clear();
36
+ },
37
+ };
38
+ }
@@ -1,3 +1,3 @@
1
1
  /** Shared version value. */
2
- export declare const VERSION = "0.1.1122";
2
+ export declare const VERSION = "0.1.1124";
3
3
  //# sourceMappingURL=version-constant.d.ts.map
@@ -1,4 +1,4 @@
1
1
  // Keep in sync with deno.json version.
2
2
  // scripts/release.ts updates this constant during releases.
3
3
  /** Shared version value. */
4
- export const VERSION = "0.1.1122";
4
+ export const VERSION = "0.1.1124";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veryfront/ext-content-mdx",
3
- "version": "0.1.1122",
3
+ "version": "0.1.1124",
4
4
  "description": "Veryfront first-party extension package for ext-content-mdx",
5
5
  "keywords": [
6
6
  "veryfront",
@@ -67,7 +67,7 @@
67
67
  "vfile": "6.0.3"
68
68
  },
69
69
  "peerDependencies": {
70
- "veryfront": "^0.1.1122"
70
+ "veryfront": "^0.1.1124"
71
71
  },
72
72
  "type": "module",
73
73
  "types": "./esm/extensions/ext-content-mdx/src/index.d.ts",