@lionrapid/core 0.4.0 → 0.5.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.
Files changed (41) hide show
  1. package/dist/browser/auto-init.d.ts +5 -0
  2. package/dist/browser/auto-init.d.ts.map +1 -1
  3. package/dist/browser/auto-init.js +22 -2
  4. package/dist/browser/auto-init.js.map +1 -1
  5. package/dist/browser/lionrapid.auto.dev.js +175 -98
  6. package/dist/browser/lionrapid.auto.dev.js.map +3 -3
  7. package/dist/browser/lionrapid.auto.js +175 -98
  8. package/dist/browser/lionrapid.auto.js.map +3 -3
  9. package/dist/browser/lionrapid.auto.min.js +3 -3
  10. package/dist/browser/lionrapid.auto.min.js.map +4 -4
  11. package/dist/browser/lionrapid.esm.js +367 -95
  12. package/dist/browser/lionrapid.esm.js.map +3 -3
  13. package/dist/browser/lionrapid.esm.min.js +2 -2
  14. package/dist/browser/lionrapid.esm.min.js.map +4 -4
  15. package/dist/browser/lionrapid.iife.dev.js +367 -95
  16. package/dist/browser/lionrapid.iife.dev.js.map +3 -3
  17. package/dist/browser/lionrapid.iife.js +367 -95
  18. package/dist/browser/lionrapid.iife.js.map +3 -3
  19. package/dist/browser/lionrapid.iife.min.js +2 -2
  20. package/dist/browser/lionrapid.iife.min.js.map +4 -4
  21. package/dist/browser/lionrapid.umd.js +367 -95
  22. package/dist/browser/lionrapid.umd.js.map +3 -3
  23. package/dist/browser/lionrapid.umd.min.js +2 -2
  24. package/dist/browser/lionrapid.umd.min.js.map +4 -4
  25. package/dist/builder.d.ts +8 -0
  26. package/dist/builder.d.ts.map +1 -1
  27. package/dist/builder.js +10 -0
  28. package/dist/builder.js.map +1 -1
  29. package/dist/index.d.ts +5 -0
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +11 -0
  32. package/dist/index.js.map +1 -1
  33. package/dist/repositories/index.d.ts +1 -0
  34. package/dist/repositories/index.d.ts.map +1 -1
  35. package/dist/repositories/index.js +1 -0
  36. package/dist/repositories/index.js.map +1 -1
  37. package/dist/repositories/static-repository.d.ts +40 -0
  38. package/dist/repositories/static-repository.d.ts.map +1 -0
  39. package/dist/repositories/static-repository.js +60 -0
  40. package/dist/repositories/static-repository.js.map +1 -0
  41. package/package.json +1 -1
@@ -28,6 +28,7 @@ var LionRapid = (() => {
28
28
  Colors: () => Colors,
29
29
  ContentValidator: () => ContentValidator,
30
30
  EventEmitter: () => EventEmitter,
31
+ ExcludeFilter: () => ExcludeFilter,
31
32
  HTMLSerializer: () => HTMLSerializer,
32
33
  HandlerChain: () => HandlerChain,
33
34
  LionRapidBuilder: () => LionRapidBuilder,
@@ -41,6 +42,7 @@ var LionRapid = (() => {
41
42
  NetworkError: () => NetworkError,
42
43
  NetworkRepository: () => NetworkRepository,
43
44
  ServerError: () => ServerError,
45
+ StaticRepository: () => StaticRepository,
44
46
  TranslationError: () => TranslationError,
45
47
  TranslationLockedError: () => TranslationLockedError,
46
48
  TranslationNotFoundError: () => TranslationNotFoundError,
@@ -48,10 +50,12 @@ var LionRapid = (() => {
48
50
  VOID_TAGS: () => VOID_TAGS,
49
51
  createPackageLogger: () => createPackageLogger,
50
52
  extractTagName: () => extractTagName,
53
+ generateAutoKey: () => generateAutoKey,
51
54
  isClientError: () => isClientError,
52
55
  isRetryableError: () => isRetryableError,
53
56
  isTranslationError: () => isTranslationError,
54
57
  logger: () => logger,
58
+ md5: () => md5,
55
59
  measure: () => measure,
56
60
  parseKeyPath: () => parseKeyPath,
57
61
  prepareTranslationRequest: () => prepareTranslationRequest,
@@ -3220,6 +3224,155 @@ var LionRapid = (() => {
3220
3224
  }
3221
3225
  };
3222
3226
 
3227
+ // src/repositories/memory-repository.ts
3228
+ var MemoryRepository = class {
3229
+ constructor(config) {
3230
+ __publicField(this, "name", "MemoryRepository");
3231
+ __publicField(this, "type", "memory");
3232
+ __publicField(this, "config", {});
3233
+ __publicField(this, "cache", /* @__PURE__ */ new Map());
3234
+ __publicField(this, "accessOrder", /* @__PURE__ */ new Map());
3235
+ __publicField(this, "maxSize", 1e3);
3236
+ this.config = config;
3237
+ this.maxSize = this.config.options?.maxSize || 1e3;
3238
+ }
3239
+ get(key) {
3240
+ const value = this.cache.get(key);
3241
+ if (value !== void 0) {
3242
+ this.accessOrder.set(key, Date.now());
3243
+ return value;
3244
+ }
3245
+ return null;
3246
+ }
3247
+ set(key, value) {
3248
+ if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
3249
+ this.evictOldest();
3250
+ }
3251
+ this.cache.set(key, value);
3252
+ this.accessOrder.set(key, Date.now());
3253
+ }
3254
+ remove(key) {
3255
+ this.cache.delete(key);
3256
+ this.accessOrder.delete(key);
3257
+ }
3258
+ clear() {
3259
+ this.cache.clear();
3260
+ this.accessOrder.clear();
3261
+ }
3262
+ /**
3263
+ * Clear all entries for a specific namespace
3264
+ * Removes both the namespace cache entry and all individual translation keys
3265
+ */
3266
+ clearNamespace(locale, namespace) {
3267
+ const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
3268
+ const keyPrefix = `${locale}:${namespace}:`;
3269
+ this.cache.delete(namespaceCacheKey);
3270
+ this.accessOrder.delete(namespaceCacheKey);
3271
+ for (const key of this.cache.keys()) {
3272
+ if (key.startsWith(keyPrefix)) {
3273
+ this.cache.delete(key);
3274
+ this.accessOrder.delete(key);
3275
+ }
3276
+ }
3277
+ }
3278
+ getNamespace(locale, namespace) {
3279
+ const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
3280
+ const namespaceData = this.cache.get(namespaceCacheKey);
3281
+ if (!namespaceData) return null;
3282
+ try {
3283
+ return JSON.parse(namespaceData);
3284
+ } catch (error) {
3285
+ this.cache.delete(namespaceCacheKey);
3286
+ return null;
3287
+ }
3288
+ }
3289
+ setNamespace(locale, namespace, translations) {
3290
+ const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
3291
+ this.cache.set(namespaceCacheKey, JSON.stringify(translations));
3292
+ }
3293
+ evictOldest() {
3294
+ let oldestKey = "";
3295
+ let oldestTime = Date.now();
3296
+ for (const [key, time] of this.accessOrder.entries()) {
3297
+ if (time < oldestTime) {
3298
+ oldestTime = time;
3299
+ oldestKey = key;
3300
+ }
3301
+ }
3302
+ if (oldestKey) {
3303
+ this.cache.delete(oldestKey);
3304
+ this.accessOrder.delete(oldestKey);
3305
+ }
3306
+ }
3307
+ /**
3308
+ * Get all cache entries for debugging
3309
+ */
3310
+ getEntries() {
3311
+ const entries = {};
3312
+ for (const [key, value] of this.cache.entries()) {
3313
+ entries[key] = value;
3314
+ }
3315
+ return entries;
3316
+ }
3317
+ getConfig() {
3318
+ return this.config;
3319
+ }
3320
+ };
3321
+
3322
+ // src/repositories/static-repository.ts
3323
+ var StaticRepository = class {
3324
+ constructor(bundle, config = {}) {
3325
+ __publicField(this, "name", "StaticRepository");
3326
+ __publicField(this, "type", "memory");
3327
+ __publicField(this, "config");
3328
+ __publicField(this, "mem");
3329
+ this.config = {
3330
+ enabled: config.enabled ?? true,
3331
+ priority: config.priority ?? 0.5,
3332
+ // after the live memory (0), before storage
3333
+ options: {
3334
+ ttl: Number.MAX_SAFE_INTEGER,
3335
+ maxSize: Number.MAX_SAFE_INTEGER,
3336
+ ...config.options
3337
+ }
3338
+ };
3339
+ this.mem = new MemoryRepository({ options: { maxSize: Number.MAX_SAFE_INTEGER } });
3340
+ for (const [locale, namespaces] of Object.entries(bundle)) {
3341
+ for (const [namespace, translations] of Object.entries(namespaces)) {
3342
+ this.mem.setNamespace(locale, namespace, translations);
3343
+ const flat = flattenTranslations(
3344
+ translations,
3345
+ "",
3346
+ locale,
3347
+ namespace
3348
+ );
3349
+ for (const [key, value] of Object.entries(flat)) this.mem.set(key, value);
3350
+ }
3351
+ }
3352
+ }
3353
+ get(key) {
3354
+ return this.mem.get(key);
3355
+ }
3356
+ getNamespace(locale, namespace) {
3357
+ return this.mem.getNamespace(locale, namespace);
3358
+ }
3359
+ getEntries() {
3360
+ return this.mem.getEntries();
3361
+ }
3362
+ getConfig() {
3363
+ return this.config;
3364
+ }
3365
+ // Read-only: the live memory layer owns fresh network data; this stays pristine.
3366
+ set() {
3367
+ }
3368
+ remove() {
3369
+ }
3370
+ clear() {
3371
+ }
3372
+ setNamespace() {
3373
+ }
3374
+ };
3375
+
3223
3376
  // src/sync/missing-translation-queue.ts
3224
3377
  var COOLDOWN_MS = 6e4;
3225
3378
  var MissingTranslationQueue = class {
@@ -3428,6 +3581,15 @@ var LionRapid = (() => {
3428
3581
  }
3429
3582
  return this;
3430
3583
  }
3584
+ /**
3585
+ * Offline resilience: seed a translation bundle (or the CLI's snapshot files)
3586
+ * as a read-only sync layer that resolves synchronously even with the server
3587
+ * down and nothing cached. Sits after the live memory layer (priority 0) at
3588
+ * `priority` (default 0.5), so fresh network data always shadows it.
3589
+ */
3590
+ useStaticBundle(bundle, priority = 0.5) {
3591
+ return this.use(new StaticRepository(bundle, { priority }));
3592
+ }
3431
3593
  async build() {
3432
3594
  const eventEmitter = new EventEmitter();
3433
3595
  const buildBus = eventEmitter.builder();
@@ -4025,101 +4187,6 @@ var LionRapid = (() => {
4025
4187
  __publicField(_NetworkRepository, "VERSION_PREFIX", "lionrapid:v:");
4026
4188
  var NetworkRepository = _NetworkRepository;
4027
4189
 
4028
- // src/repositories/memory-repository.ts
4029
- var MemoryRepository = class {
4030
- constructor(config) {
4031
- __publicField(this, "name", "MemoryRepository");
4032
- __publicField(this, "type", "memory");
4033
- __publicField(this, "config", {});
4034
- __publicField(this, "cache", /* @__PURE__ */ new Map());
4035
- __publicField(this, "accessOrder", /* @__PURE__ */ new Map());
4036
- __publicField(this, "maxSize", 1e3);
4037
- this.config = config;
4038
- this.maxSize = this.config.options?.maxSize || 1e3;
4039
- }
4040
- get(key) {
4041
- const value = this.cache.get(key);
4042
- if (value !== void 0) {
4043
- this.accessOrder.set(key, Date.now());
4044
- return value;
4045
- }
4046
- return null;
4047
- }
4048
- set(key, value) {
4049
- if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
4050
- this.evictOldest();
4051
- }
4052
- this.cache.set(key, value);
4053
- this.accessOrder.set(key, Date.now());
4054
- }
4055
- remove(key) {
4056
- this.cache.delete(key);
4057
- this.accessOrder.delete(key);
4058
- }
4059
- clear() {
4060
- this.cache.clear();
4061
- this.accessOrder.clear();
4062
- }
4063
- /**
4064
- * Clear all entries for a specific namespace
4065
- * Removes both the namespace cache entry and all individual translation keys
4066
- */
4067
- clearNamespace(locale, namespace) {
4068
- const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
4069
- const keyPrefix = `${locale}:${namespace}:`;
4070
- this.cache.delete(namespaceCacheKey);
4071
- this.accessOrder.delete(namespaceCacheKey);
4072
- for (const key of this.cache.keys()) {
4073
- if (key.startsWith(keyPrefix)) {
4074
- this.cache.delete(key);
4075
- this.accessOrder.delete(key);
4076
- }
4077
- }
4078
- }
4079
- getNamespace(locale, namespace) {
4080
- const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
4081
- const namespaceData = this.cache.get(namespaceCacheKey);
4082
- if (!namespaceData) return null;
4083
- try {
4084
- return JSON.parse(namespaceData);
4085
- } catch (error) {
4086
- this.cache.delete(namespaceCacheKey);
4087
- return null;
4088
- }
4089
- }
4090
- setNamespace(locale, namespace, translations) {
4091
- const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
4092
- this.cache.set(namespaceCacheKey, JSON.stringify(translations));
4093
- }
4094
- evictOldest() {
4095
- let oldestKey = "";
4096
- let oldestTime = Date.now();
4097
- for (const [key, time] of this.accessOrder.entries()) {
4098
- if (time < oldestTime) {
4099
- oldestTime = time;
4100
- oldestKey = key;
4101
- }
4102
- }
4103
- if (oldestKey) {
4104
- this.cache.delete(oldestKey);
4105
- this.accessOrder.delete(oldestKey);
4106
- }
4107
- }
4108
- /**
4109
- * Get all cache entries for debugging
4110
- */
4111
- getEntries() {
4112
- const entries = {};
4113
- for (const [key, value] of this.cache.entries()) {
4114
- entries[key] = value;
4115
- }
4116
- return entries;
4117
- }
4118
- getConfig() {
4119
- return this.config;
4120
- }
4121
- };
4122
-
4123
4190
  // src/content/validator/ContentValidator.ts
4124
4191
  var ContentValidator = class {
4125
4192
  /**
@@ -4273,6 +4340,211 @@ var LionRapid = (() => {
4273
4340
  }
4274
4341
  };
4275
4342
 
4343
+ // src/browser/md5.ts
4344
+ function safeAdd(x, y) {
4345
+ const lsw = (x & 65535) + (y & 65535);
4346
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
4347
+ return msw << 16 | lsw & 65535;
4348
+ }
4349
+ function bitRotateLeft(num, cnt) {
4350
+ return num << cnt | num >>> 32 - cnt;
4351
+ }
4352
+ function md5cmn(q, a, b, x, s, t) {
4353
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
4354
+ }
4355
+ function md5ff(a, b, c, d, x, s, t) {
4356
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
4357
+ }
4358
+ function md5gg(a, b, c, d, x, s, t) {
4359
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
4360
+ }
4361
+ function md5hh(a, b, c, d, x, s, t) {
4362
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
4363
+ }
4364
+ function md5ii(a, b, c, d, x, s, t) {
4365
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
4366
+ }
4367
+ function binlMD5(x, len) {
4368
+ x[len >> 5] |= 128 << len % 32;
4369
+ x[(len + 64 >>> 9 << 4) + 14] = len;
4370
+ let a = 1732584193;
4371
+ let b = -271733879;
4372
+ let c = -1732584194;
4373
+ let d = 271733878;
4374
+ for (let i = 0; i < x.length; i += 16) {
4375
+ const olda = a;
4376
+ const oldb = b;
4377
+ const oldc = c;
4378
+ const oldd = d;
4379
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
4380
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
4381
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
4382
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
4383
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
4384
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
4385
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
4386
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
4387
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
4388
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
4389
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
4390
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
4391
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
4392
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
4393
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
4394
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
4395
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
4396
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
4397
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
4398
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
4399
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
4400
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
4401
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
4402
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
4403
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
4404
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
4405
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
4406
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
4407
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
4408
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
4409
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
4410
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
4411
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
4412
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
4413
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
4414
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
4415
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
4416
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
4417
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
4418
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
4419
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
4420
+ d = md5hh(d, a, b, c, x[i + 0], 11, -358537222);
4421
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
4422
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
4423
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
4424
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
4425
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
4426
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
4427
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
4428
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
4429
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
4430
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
4431
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
4432
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
4433
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
4434
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
4435
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
4436
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
4437
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
4438
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
4439
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
4440
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
4441
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
4442
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
4443
+ a = safeAdd(a, olda);
4444
+ b = safeAdd(b, oldb);
4445
+ c = safeAdd(c, oldc);
4446
+ d = safeAdd(d, oldd);
4447
+ }
4448
+ return [a, b, c, d];
4449
+ }
4450
+ function binl2hex(binarray) {
4451
+ const hexTab = "0123456789abcdef";
4452
+ let str = "";
4453
+ for (let i = 0; i < binarray.length * 4; i++) {
4454
+ str += hexTab.charAt(binarray[i >> 2] >> i % 4 * 8 + 4 & 15) + hexTab.charAt(binarray[i >> 2] >> i % 4 * 8 & 15);
4455
+ }
4456
+ return str;
4457
+ }
4458
+ function utf8Bytes(str) {
4459
+ if (typeof TextEncoder !== "undefined") {
4460
+ return new TextEncoder().encode(str);
4461
+ }
4462
+ const out = [];
4463
+ for (let i = 0; i < str.length; i++) {
4464
+ const c = str.charCodeAt(i);
4465
+ if (c < 128) {
4466
+ out.push(c);
4467
+ } else if (c < 2048) {
4468
+ out.push(192 | c >> 6, 128 | c & 63);
4469
+ } else if (c >= 55296 && c < 56320 && i + 1 < str.length) {
4470
+ const c2 = str.charCodeAt(++i);
4471
+ const cp = 65536 + (c - 55296 << 10) + (c2 - 56320);
4472
+ out.push(
4473
+ 240 | cp >> 18,
4474
+ 128 | cp >> 12 & 63,
4475
+ 128 | cp >> 6 & 63,
4476
+ 128 | cp & 63
4477
+ );
4478
+ } else {
4479
+ out.push(
4480
+ 224 | c >> 12,
4481
+ 128 | c >> 6 & 63,
4482
+ 128 | c & 63
4483
+ );
4484
+ }
4485
+ }
4486
+ return new Uint8Array(out);
4487
+ }
4488
+ function bytes2binl(bytes) {
4489
+ const bin = [];
4490
+ for (let i = 0; i < bytes.length; i++) {
4491
+ bin[i >> 2] |= bytes[i] << i % 4 * 8;
4492
+ }
4493
+ return bin;
4494
+ }
4495
+ function md5(str) {
4496
+ const bytes = utf8Bytes(str);
4497
+ return binl2hex(binlMD5(bytes2binl(bytes), bytes.length * 8));
4498
+ }
4499
+ function generateAutoKey(text) {
4500
+ const trimmed = text.trim();
4501
+ return "auto_" + md5(trimmed).substring(0, 12);
4502
+ }
4503
+
4504
+ // src/browser/exclude-filter.ts
4505
+ var DEFAULT_PATTERNS = {
4506
+ emails: true,
4507
+ urls: true,
4508
+ numbers: true,
4509
+ phones: true
4510
+ };
4511
+ var PATTERNS = {
4512
+ email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
4513
+ url: /^(https?:\/\/|www\.)[^\s]+$/i,
4514
+ number: /^[\d\s.,+-]+$/,
4515
+ phone: /^[+\d][\d\s().-]{6,}$/
4516
+ };
4517
+ var ExcludeFilter = class {
4518
+ constructor(patterns = {}, minTextLength = 2) {
4519
+ __publicField(this, "patterns");
4520
+ __publicField(this, "minTextLength");
4521
+ this.patterns = { ...DEFAULT_PATTERNS, ...patterns };
4522
+ this.minTextLength = minTextLength;
4523
+ }
4524
+ /**
4525
+ * Check if text should be excluded from translation
4526
+ */
4527
+ shouldExclude(text) {
4528
+ const trimmed = text.trim();
4529
+ if (trimmed.length < this.minTextLength) {
4530
+ return true;
4531
+ }
4532
+ if (this.patterns.emails && PATTERNS.email.test(trimmed)) {
4533
+ return true;
4534
+ }
4535
+ if (this.patterns.urls && PATTERNS.url.test(trimmed)) {
4536
+ return true;
4537
+ }
4538
+ if (this.patterns.numbers && PATTERNS.number.test(trimmed)) {
4539
+ return true;
4540
+ }
4541
+ if (this.patterns.phones && PATTERNS.phone.test(trimmed)) {
4542
+ return true;
4543
+ }
4544
+ return false;
4545
+ }
4546
+ };
4547
+
4276
4548
  // src/browser/storage/localstorage-repository.ts
4277
4549
  var STORAGE_PREFIX = "lionrapid:";
4278
4550
  var VERSION_KEY = `${STORAGE_PREFIX}version`;