@ai-react-markdown/engine 2.3.0 → 2.3.2

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.cjs CHANGED
@@ -62,6 +62,7 @@ __export(src_exports, {
62
62
  extractContributions: () => extractContributions,
63
63
  extractDefBodiesFromHast: () => extractDefBodiesFromHast,
64
64
  getEnginePluginInternals: () => getEnginePluginInternals,
65
+ hasLoneSurrogate: () => hasLoneSurrogate,
65
66
  highlight: () => highlight,
66
67
  isFootnoteSection: () => isFootnoteSection,
67
68
  lastRegionStart: () => lastRegionStart,
@@ -3319,7 +3320,9 @@ var C1 = 3432918353;
3319
3320
  var C2 = 461845907;
3320
3321
  var UTF8_ENCODER = /* @__PURE__ */ new TextEncoder();
3321
3322
  function murmur3_32(s, seed = 0) {
3322
- const bytes = UTF8_ENCODER.encode(s);
3323
+ return murmur3_32_bytes(UTF8_ENCODER.encode(s), seed);
3324
+ }
3325
+ function murmur3_32_bytes(bytes, seed = 0) {
3323
3326
  const len = bytes.length;
3324
3327
  let h1 = seed >>> 0;
3325
3328
  const nblocks = len >>> 2;
@@ -3353,7 +3356,22 @@ function murmur3_32(s, seed = 0) {
3353
3356
  h1 ^= h1 >>> 16;
3354
3357
  return h1 >>> 0;
3355
3358
  }
3359
+ var LONE_SURROGATE_RE = /[\uD800-\uDFFF]/u;
3360
+ function hasLoneSurrogate(id) {
3361
+ return LONE_SURROGATE_RE.test(id);
3362
+ }
3363
+ var ILL_FORMED_SEED = 1;
3364
+ function utf16leBytes(s) {
3365
+ const bytes = new Uint8Array(s.length * 2);
3366
+ for (let i = 0; i < s.length; i++) {
3367
+ const c = s.charCodeAt(i);
3368
+ bytes[i * 2] = c & 255;
3369
+ bytes[i * 2 + 1] = c >>> 8;
3370
+ }
3371
+ return bytes;
3372
+ }
3356
3373
  function shortenDocumentId(id, threshold = 16) {
3374
+ if (hasLoneSurrogate(id)) return toBase62(murmur3_32_bytes(utf16leBytes(id), ILL_FORMED_SEED));
3357
3375
  if (id.length <= threshold) return id;
3358
3376
  return toBase62(murmur3_32(id));
3359
3377
  }
@@ -4111,6 +4129,7 @@ function createRemendPreprocessor(options) {
4111
4129
  extractContributions,
4112
4130
  extractDefBodiesFromHast,
4113
4131
  getEnginePluginInternals,
4132
+ hasLoneSurrogate,
4114
4133
  highlight,
4115
4134
  isFootnoteSection,
4116
4135
  lastRegionStart,