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