@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
|
@@ -3162,6 +3162,155 @@ var LionRapidCore = class {
|
|
|
3162
3162
|
}
|
|
3163
3163
|
};
|
|
3164
3164
|
|
|
3165
|
+
// src/repositories/memory-repository.ts
|
|
3166
|
+
var MemoryRepository = class {
|
|
3167
|
+
constructor(config) {
|
|
3168
|
+
__publicField(this, "name", "MemoryRepository");
|
|
3169
|
+
__publicField(this, "type", "memory");
|
|
3170
|
+
__publicField(this, "config", {});
|
|
3171
|
+
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
3172
|
+
__publicField(this, "accessOrder", /* @__PURE__ */ new Map());
|
|
3173
|
+
__publicField(this, "maxSize", 1e3);
|
|
3174
|
+
this.config = config;
|
|
3175
|
+
this.maxSize = this.config.options?.maxSize || 1e3;
|
|
3176
|
+
}
|
|
3177
|
+
get(key) {
|
|
3178
|
+
const value = this.cache.get(key);
|
|
3179
|
+
if (value !== void 0) {
|
|
3180
|
+
this.accessOrder.set(key, Date.now());
|
|
3181
|
+
return value;
|
|
3182
|
+
}
|
|
3183
|
+
return null;
|
|
3184
|
+
}
|
|
3185
|
+
set(key, value) {
|
|
3186
|
+
if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
|
|
3187
|
+
this.evictOldest();
|
|
3188
|
+
}
|
|
3189
|
+
this.cache.set(key, value);
|
|
3190
|
+
this.accessOrder.set(key, Date.now());
|
|
3191
|
+
}
|
|
3192
|
+
remove(key) {
|
|
3193
|
+
this.cache.delete(key);
|
|
3194
|
+
this.accessOrder.delete(key);
|
|
3195
|
+
}
|
|
3196
|
+
clear() {
|
|
3197
|
+
this.cache.clear();
|
|
3198
|
+
this.accessOrder.clear();
|
|
3199
|
+
}
|
|
3200
|
+
/**
|
|
3201
|
+
* Clear all entries for a specific namespace
|
|
3202
|
+
* Removes both the namespace cache entry and all individual translation keys
|
|
3203
|
+
*/
|
|
3204
|
+
clearNamespace(locale, namespace) {
|
|
3205
|
+
const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
|
|
3206
|
+
const keyPrefix = `${locale}:${namespace}:`;
|
|
3207
|
+
this.cache.delete(namespaceCacheKey);
|
|
3208
|
+
this.accessOrder.delete(namespaceCacheKey);
|
|
3209
|
+
for (const key of this.cache.keys()) {
|
|
3210
|
+
if (key.startsWith(keyPrefix)) {
|
|
3211
|
+
this.cache.delete(key);
|
|
3212
|
+
this.accessOrder.delete(key);
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
getNamespace(locale, namespace) {
|
|
3217
|
+
const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
|
|
3218
|
+
const namespaceData = this.cache.get(namespaceCacheKey);
|
|
3219
|
+
if (!namespaceData) return null;
|
|
3220
|
+
try {
|
|
3221
|
+
return JSON.parse(namespaceData);
|
|
3222
|
+
} catch (error) {
|
|
3223
|
+
this.cache.delete(namespaceCacheKey);
|
|
3224
|
+
return null;
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
setNamespace(locale, namespace, translations) {
|
|
3228
|
+
const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
|
|
3229
|
+
this.cache.set(namespaceCacheKey, JSON.stringify(translations));
|
|
3230
|
+
}
|
|
3231
|
+
evictOldest() {
|
|
3232
|
+
let oldestKey = "";
|
|
3233
|
+
let oldestTime = Date.now();
|
|
3234
|
+
for (const [key, time] of this.accessOrder.entries()) {
|
|
3235
|
+
if (time < oldestTime) {
|
|
3236
|
+
oldestTime = time;
|
|
3237
|
+
oldestKey = key;
|
|
3238
|
+
}
|
|
3239
|
+
}
|
|
3240
|
+
if (oldestKey) {
|
|
3241
|
+
this.cache.delete(oldestKey);
|
|
3242
|
+
this.accessOrder.delete(oldestKey);
|
|
3243
|
+
}
|
|
3244
|
+
}
|
|
3245
|
+
/**
|
|
3246
|
+
* Get all cache entries for debugging
|
|
3247
|
+
*/
|
|
3248
|
+
getEntries() {
|
|
3249
|
+
const entries = {};
|
|
3250
|
+
for (const [key, value] of this.cache.entries()) {
|
|
3251
|
+
entries[key] = value;
|
|
3252
|
+
}
|
|
3253
|
+
return entries;
|
|
3254
|
+
}
|
|
3255
|
+
getConfig() {
|
|
3256
|
+
return this.config;
|
|
3257
|
+
}
|
|
3258
|
+
};
|
|
3259
|
+
|
|
3260
|
+
// src/repositories/static-repository.ts
|
|
3261
|
+
var StaticRepository = class {
|
|
3262
|
+
constructor(bundle, config = {}) {
|
|
3263
|
+
__publicField(this, "name", "StaticRepository");
|
|
3264
|
+
__publicField(this, "type", "memory");
|
|
3265
|
+
__publicField(this, "config");
|
|
3266
|
+
__publicField(this, "mem");
|
|
3267
|
+
this.config = {
|
|
3268
|
+
enabled: config.enabled ?? true,
|
|
3269
|
+
priority: config.priority ?? 0.5,
|
|
3270
|
+
// after the live memory (0), before storage
|
|
3271
|
+
options: {
|
|
3272
|
+
ttl: Number.MAX_SAFE_INTEGER,
|
|
3273
|
+
maxSize: Number.MAX_SAFE_INTEGER,
|
|
3274
|
+
...config.options
|
|
3275
|
+
}
|
|
3276
|
+
};
|
|
3277
|
+
this.mem = new MemoryRepository({ options: { maxSize: Number.MAX_SAFE_INTEGER } });
|
|
3278
|
+
for (const [locale, namespaces] of Object.entries(bundle)) {
|
|
3279
|
+
for (const [namespace, translations] of Object.entries(namespaces)) {
|
|
3280
|
+
this.mem.setNamespace(locale, namespace, translations);
|
|
3281
|
+
const flat = flattenTranslations(
|
|
3282
|
+
translations,
|
|
3283
|
+
"",
|
|
3284
|
+
locale,
|
|
3285
|
+
namespace
|
|
3286
|
+
);
|
|
3287
|
+
for (const [key, value] of Object.entries(flat)) this.mem.set(key, value);
|
|
3288
|
+
}
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
get(key) {
|
|
3292
|
+
return this.mem.get(key);
|
|
3293
|
+
}
|
|
3294
|
+
getNamespace(locale, namespace) {
|
|
3295
|
+
return this.mem.getNamespace(locale, namespace);
|
|
3296
|
+
}
|
|
3297
|
+
getEntries() {
|
|
3298
|
+
return this.mem.getEntries();
|
|
3299
|
+
}
|
|
3300
|
+
getConfig() {
|
|
3301
|
+
return this.config;
|
|
3302
|
+
}
|
|
3303
|
+
// Read-only: the live memory layer owns fresh network data; this stays pristine.
|
|
3304
|
+
set() {
|
|
3305
|
+
}
|
|
3306
|
+
remove() {
|
|
3307
|
+
}
|
|
3308
|
+
clear() {
|
|
3309
|
+
}
|
|
3310
|
+
setNamespace() {
|
|
3311
|
+
}
|
|
3312
|
+
};
|
|
3313
|
+
|
|
3165
3314
|
// src/sync/missing-translation-queue.ts
|
|
3166
3315
|
var COOLDOWN_MS = 6e4;
|
|
3167
3316
|
var MissingTranslationQueue = class {
|
|
@@ -3370,6 +3519,15 @@ var LionRapidBuilder = class _LionRapidBuilder {
|
|
|
3370
3519
|
}
|
|
3371
3520
|
return this;
|
|
3372
3521
|
}
|
|
3522
|
+
/**
|
|
3523
|
+
* Offline resilience: seed a translation bundle (or the CLI's snapshot files)
|
|
3524
|
+
* as a read-only sync layer that resolves synchronously even with the server
|
|
3525
|
+
* down and nothing cached. Sits after the live memory layer (priority 0) at
|
|
3526
|
+
* `priority` (default 0.5), so fresh network data always shadows it.
|
|
3527
|
+
*/
|
|
3528
|
+
useStaticBundle(bundle, priority = 0.5) {
|
|
3529
|
+
return this.use(new StaticRepository(bundle, { priority }));
|
|
3530
|
+
}
|
|
3373
3531
|
async build() {
|
|
3374
3532
|
const eventEmitter = new EventEmitter();
|
|
3375
3533
|
const buildBus = eventEmitter.builder();
|
|
@@ -3967,101 +4125,6 @@ var _NetworkRepository = class _NetworkRepository {
|
|
|
3967
4125
|
__publicField(_NetworkRepository, "VERSION_PREFIX", "lionrapid:v:");
|
|
3968
4126
|
var NetworkRepository = _NetworkRepository;
|
|
3969
4127
|
|
|
3970
|
-
// src/repositories/memory-repository.ts
|
|
3971
|
-
var MemoryRepository = class {
|
|
3972
|
-
constructor(config) {
|
|
3973
|
-
__publicField(this, "name", "MemoryRepository");
|
|
3974
|
-
__publicField(this, "type", "memory");
|
|
3975
|
-
__publicField(this, "config", {});
|
|
3976
|
-
__publicField(this, "cache", /* @__PURE__ */ new Map());
|
|
3977
|
-
__publicField(this, "accessOrder", /* @__PURE__ */ new Map());
|
|
3978
|
-
__publicField(this, "maxSize", 1e3);
|
|
3979
|
-
this.config = config;
|
|
3980
|
-
this.maxSize = this.config.options?.maxSize || 1e3;
|
|
3981
|
-
}
|
|
3982
|
-
get(key) {
|
|
3983
|
-
const value = this.cache.get(key);
|
|
3984
|
-
if (value !== void 0) {
|
|
3985
|
-
this.accessOrder.set(key, Date.now());
|
|
3986
|
-
return value;
|
|
3987
|
-
}
|
|
3988
|
-
return null;
|
|
3989
|
-
}
|
|
3990
|
-
set(key, value) {
|
|
3991
|
-
if (this.cache.size >= this.maxSize && !this.cache.has(key)) {
|
|
3992
|
-
this.evictOldest();
|
|
3993
|
-
}
|
|
3994
|
-
this.cache.set(key, value);
|
|
3995
|
-
this.accessOrder.set(key, Date.now());
|
|
3996
|
-
}
|
|
3997
|
-
remove(key) {
|
|
3998
|
-
this.cache.delete(key);
|
|
3999
|
-
this.accessOrder.delete(key);
|
|
4000
|
-
}
|
|
4001
|
-
clear() {
|
|
4002
|
-
this.cache.clear();
|
|
4003
|
-
this.accessOrder.clear();
|
|
4004
|
-
}
|
|
4005
|
-
/**
|
|
4006
|
-
* Clear all entries for a specific namespace
|
|
4007
|
-
* Removes both the namespace cache entry and all individual translation keys
|
|
4008
|
-
*/
|
|
4009
|
-
clearNamespace(locale, namespace) {
|
|
4010
|
-
const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
|
|
4011
|
-
const keyPrefix = `${locale}:${namespace}:`;
|
|
4012
|
-
this.cache.delete(namespaceCacheKey);
|
|
4013
|
-
this.accessOrder.delete(namespaceCacheKey);
|
|
4014
|
-
for (const key of this.cache.keys()) {
|
|
4015
|
-
if (key.startsWith(keyPrefix)) {
|
|
4016
|
-
this.cache.delete(key);
|
|
4017
|
-
this.accessOrder.delete(key);
|
|
4018
|
-
}
|
|
4019
|
-
}
|
|
4020
|
-
}
|
|
4021
|
-
getNamespace(locale, namespace) {
|
|
4022
|
-
const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
|
|
4023
|
-
const namespaceData = this.cache.get(namespaceCacheKey);
|
|
4024
|
-
if (!namespaceData) return null;
|
|
4025
|
-
try {
|
|
4026
|
-
return JSON.parse(namespaceData);
|
|
4027
|
-
} catch (error) {
|
|
4028
|
-
this.cache.delete(namespaceCacheKey);
|
|
4029
|
-
return null;
|
|
4030
|
-
}
|
|
4031
|
-
}
|
|
4032
|
-
setNamespace(locale, namespace, translations) {
|
|
4033
|
-
const namespaceCacheKey = createNamespaceCacheKey(locale, namespace);
|
|
4034
|
-
this.cache.set(namespaceCacheKey, JSON.stringify(translations));
|
|
4035
|
-
}
|
|
4036
|
-
evictOldest() {
|
|
4037
|
-
let oldestKey = "";
|
|
4038
|
-
let oldestTime = Date.now();
|
|
4039
|
-
for (const [key, time] of this.accessOrder.entries()) {
|
|
4040
|
-
if (time < oldestTime) {
|
|
4041
|
-
oldestTime = time;
|
|
4042
|
-
oldestKey = key;
|
|
4043
|
-
}
|
|
4044
|
-
}
|
|
4045
|
-
if (oldestKey) {
|
|
4046
|
-
this.cache.delete(oldestKey);
|
|
4047
|
-
this.accessOrder.delete(oldestKey);
|
|
4048
|
-
}
|
|
4049
|
-
}
|
|
4050
|
-
/**
|
|
4051
|
-
* Get all cache entries for debugging
|
|
4052
|
-
*/
|
|
4053
|
-
getEntries() {
|
|
4054
|
-
const entries = {};
|
|
4055
|
-
for (const [key, value] of this.cache.entries()) {
|
|
4056
|
-
entries[key] = value;
|
|
4057
|
-
}
|
|
4058
|
-
return entries;
|
|
4059
|
-
}
|
|
4060
|
-
getConfig() {
|
|
4061
|
-
return this.config;
|
|
4062
|
-
}
|
|
4063
|
-
};
|
|
4064
|
-
|
|
4065
4128
|
// src/content/validator/ContentValidator.ts
|
|
4066
4129
|
var ContentValidator = class {
|
|
4067
4130
|
/**
|
|
@@ -4215,6 +4278,211 @@ var ContentValidator = class {
|
|
|
4215
4278
|
}
|
|
4216
4279
|
};
|
|
4217
4280
|
|
|
4281
|
+
// src/browser/md5.ts
|
|
4282
|
+
function safeAdd(x, y) {
|
|
4283
|
+
const lsw = (x & 65535) + (y & 65535);
|
|
4284
|
+
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
4285
|
+
return msw << 16 | lsw & 65535;
|
|
4286
|
+
}
|
|
4287
|
+
function bitRotateLeft(num, cnt) {
|
|
4288
|
+
return num << cnt | num >>> 32 - cnt;
|
|
4289
|
+
}
|
|
4290
|
+
function md5cmn(q, a, b, x, s, t) {
|
|
4291
|
+
return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
|
|
4292
|
+
}
|
|
4293
|
+
function md5ff(a, b, c, d, x, s, t) {
|
|
4294
|
+
return md5cmn(b & c | ~b & d, a, b, x, s, t);
|
|
4295
|
+
}
|
|
4296
|
+
function md5gg(a, b, c, d, x, s, t) {
|
|
4297
|
+
return md5cmn(b & d | c & ~d, a, b, x, s, t);
|
|
4298
|
+
}
|
|
4299
|
+
function md5hh(a, b, c, d, x, s, t) {
|
|
4300
|
+
return md5cmn(b ^ c ^ d, a, b, x, s, t);
|
|
4301
|
+
}
|
|
4302
|
+
function md5ii(a, b, c, d, x, s, t) {
|
|
4303
|
+
return md5cmn(c ^ (b | ~d), a, b, x, s, t);
|
|
4304
|
+
}
|
|
4305
|
+
function binlMD5(x, len) {
|
|
4306
|
+
x[len >> 5] |= 128 << len % 32;
|
|
4307
|
+
x[(len + 64 >>> 9 << 4) + 14] = len;
|
|
4308
|
+
let a = 1732584193;
|
|
4309
|
+
let b = -271733879;
|
|
4310
|
+
let c = -1732584194;
|
|
4311
|
+
let d = 271733878;
|
|
4312
|
+
for (let i = 0; i < x.length; i += 16) {
|
|
4313
|
+
const olda = a;
|
|
4314
|
+
const oldb = b;
|
|
4315
|
+
const oldc = c;
|
|
4316
|
+
const oldd = d;
|
|
4317
|
+
a = md5ff(a, b, c, d, x[i], 7, -680876936);
|
|
4318
|
+
d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
|
|
4319
|
+
c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
|
|
4320
|
+
b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
|
|
4321
|
+
a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
|
|
4322
|
+
d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
|
|
4323
|
+
c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
|
|
4324
|
+
b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
|
|
4325
|
+
a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
|
|
4326
|
+
d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
|
|
4327
|
+
c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
|
|
4328
|
+
b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
|
|
4329
|
+
a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
|
|
4330
|
+
d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
|
|
4331
|
+
c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
|
|
4332
|
+
b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
|
|
4333
|
+
a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
|
|
4334
|
+
d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
|
|
4335
|
+
c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
|
|
4336
|
+
b = md5gg(b, c, d, a, x[i], 20, -373897302);
|
|
4337
|
+
a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
|
|
4338
|
+
d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
|
|
4339
|
+
c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
|
|
4340
|
+
b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
|
|
4341
|
+
a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
|
|
4342
|
+
d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
|
|
4343
|
+
c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
|
|
4344
|
+
b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
|
|
4345
|
+
a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
|
|
4346
|
+
d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
|
|
4347
|
+
c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
|
|
4348
|
+
b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
|
|
4349
|
+
a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
|
|
4350
|
+
d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
|
|
4351
|
+
c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
|
|
4352
|
+
b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
|
|
4353
|
+
a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
|
|
4354
|
+
d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
|
|
4355
|
+
c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
|
|
4356
|
+
b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
|
|
4357
|
+
a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
|
|
4358
|
+
d = md5hh(d, a, b, c, x[i + 0], 11, -358537222);
|
|
4359
|
+
c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
|
|
4360
|
+
b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
|
|
4361
|
+
a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
|
|
4362
|
+
d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
|
|
4363
|
+
c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
|
|
4364
|
+
b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
|
|
4365
|
+
a = md5ii(a, b, c, d, x[i], 6, -198630844);
|
|
4366
|
+
d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
|
|
4367
|
+
c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
|
|
4368
|
+
b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
|
|
4369
|
+
a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
|
|
4370
|
+
d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
|
|
4371
|
+
c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
|
|
4372
|
+
b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
|
|
4373
|
+
a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
|
|
4374
|
+
d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
|
|
4375
|
+
c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
|
|
4376
|
+
b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
|
|
4377
|
+
a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
|
|
4378
|
+
d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
|
|
4379
|
+
c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
|
|
4380
|
+
b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
|
|
4381
|
+
a = safeAdd(a, olda);
|
|
4382
|
+
b = safeAdd(b, oldb);
|
|
4383
|
+
c = safeAdd(c, oldc);
|
|
4384
|
+
d = safeAdd(d, oldd);
|
|
4385
|
+
}
|
|
4386
|
+
return [a, b, c, d];
|
|
4387
|
+
}
|
|
4388
|
+
function binl2hex(binarray) {
|
|
4389
|
+
const hexTab = "0123456789abcdef";
|
|
4390
|
+
let str = "";
|
|
4391
|
+
for (let i = 0; i < binarray.length * 4; i++) {
|
|
4392
|
+
str += hexTab.charAt(binarray[i >> 2] >> i % 4 * 8 + 4 & 15) + hexTab.charAt(binarray[i >> 2] >> i % 4 * 8 & 15);
|
|
4393
|
+
}
|
|
4394
|
+
return str;
|
|
4395
|
+
}
|
|
4396
|
+
function utf8Bytes(str) {
|
|
4397
|
+
if (typeof TextEncoder !== "undefined") {
|
|
4398
|
+
return new TextEncoder().encode(str);
|
|
4399
|
+
}
|
|
4400
|
+
const out = [];
|
|
4401
|
+
for (let i = 0; i < str.length; i++) {
|
|
4402
|
+
const c = str.charCodeAt(i);
|
|
4403
|
+
if (c < 128) {
|
|
4404
|
+
out.push(c);
|
|
4405
|
+
} else if (c < 2048) {
|
|
4406
|
+
out.push(192 | c >> 6, 128 | c & 63);
|
|
4407
|
+
} else if (c >= 55296 && c < 56320 && i + 1 < str.length) {
|
|
4408
|
+
const c2 = str.charCodeAt(++i);
|
|
4409
|
+
const cp = 65536 + (c - 55296 << 10) + (c2 - 56320);
|
|
4410
|
+
out.push(
|
|
4411
|
+
240 | cp >> 18,
|
|
4412
|
+
128 | cp >> 12 & 63,
|
|
4413
|
+
128 | cp >> 6 & 63,
|
|
4414
|
+
128 | cp & 63
|
|
4415
|
+
);
|
|
4416
|
+
} else {
|
|
4417
|
+
out.push(
|
|
4418
|
+
224 | c >> 12,
|
|
4419
|
+
128 | c >> 6 & 63,
|
|
4420
|
+
128 | c & 63
|
|
4421
|
+
);
|
|
4422
|
+
}
|
|
4423
|
+
}
|
|
4424
|
+
return new Uint8Array(out);
|
|
4425
|
+
}
|
|
4426
|
+
function bytes2binl(bytes) {
|
|
4427
|
+
const bin = [];
|
|
4428
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
4429
|
+
bin[i >> 2] |= bytes[i] << i % 4 * 8;
|
|
4430
|
+
}
|
|
4431
|
+
return bin;
|
|
4432
|
+
}
|
|
4433
|
+
function md5(str) {
|
|
4434
|
+
const bytes = utf8Bytes(str);
|
|
4435
|
+
return binl2hex(binlMD5(bytes2binl(bytes), bytes.length * 8));
|
|
4436
|
+
}
|
|
4437
|
+
function generateAutoKey(text) {
|
|
4438
|
+
const trimmed = text.trim();
|
|
4439
|
+
return "auto_" + md5(trimmed).substring(0, 12);
|
|
4440
|
+
}
|
|
4441
|
+
|
|
4442
|
+
// src/browser/exclude-filter.ts
|
|
4443
|
+
var DEFAULT_PATTERNS = {
|
|
4444
|
+
emails: true,
|
|
4445
|
+
urls: true,
|
|
4446
|
+
numbers: true,
|
|
4447
|
+
phones: true
|
|
4448
|
+
};
|
|
4449
|
+
var PATTERNS = {
|
|
4450
|
+
email: /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,
|
|
4451
|
+
url: /^(https?:\/\/|www\.)[^\s]+$/i,
|
|
4452
|
+
number: /^[\d\s.,+-]+$/,
|
|
4453
|
+
phone: /^[+\d][\d\s().-]{6,}$/
|
|
4454
|
+
};
|
|
4455
|
+
var ExcludeFilter = class {
|
|
4456
|
+
constructor(patterns = {}, minTextLength = 2) {
|
|
4457
|
+
__publicField(this, "patterns");
|
|
4458
|
+
__publicField(this, "minTextLength");
|
|
4459
|
+
this.patterns = { ...DEFAULT_PATTERNS, ...patterns };
|
|
4460
|
+
this.minTextLength = minTextLength;
|
|
4461
|
+
}
|
|
4462
|
+
/**
|
|
4463
|
+
* Check if text should be excluded from translation
|
|
4464
|
+
*/
|
|
4465
|
+
shouldExclude(text) {
|
|
4466
|
+
const trimmed = text.trim();
|
|
4467
|
+
if (trimmed.length < this.minTextLength) {
|
|
4468
|
+
return true;
|
|
4469
|
+
}
|
|
4470
|
+
if (this.patterns.emails && PATTERNS.email.test(trimmed)) {
|
|
4471
|
+
return true;
|
|
4472
|
+
}
|
|
4473
|
+
if (this.patterns.urls && PATTERNS.url.test(trimmed)) {
|
|
4474
|
+
return true;
|
|
4475
|
+
}
|
|
4476
|
+
if (this.patterns.numbers && PATTERNS.number.test(trimmed)) {
|
|
4477
|
+
return true;
|
|
4478
|
+
}
|
|
4479
|
+
if (this.patterns.phones && PATTERNS.phone.test(trimmed)) {
|
|
4480
|
+
return true;
|
|
4481
|
+
}
|
|
4482
|
+
return false;
|
|
4483
|
+
}
|
|
4484
|
+
};
|
|
4485
|
+
|
|
4218
4486
|
// src/browser/storage/localstorage-repository.ts
|
|
4219
4487
|
var STORAGE_PREFIX = "lionrapid:";
|
|
4220
4488
|
var VERSION_KEY = `${STORAGE_PREFIX}version`;
|
|
@@ -4615,6 +4883,7 @@ export {
|
|
|
4615
4883
|
Colors,
|
|
4616
4884
|
ContentValidator,
|
|
4617
4885
|
EventEmitter,
|
|
4886
|
+
ExcludeFilter,
|
|
4618
4887
|
HTMLSerializer,
|
|
4619
4888
|
HandlerChain,
|
|
4620
4889
|
LionRapidBuilder,
|
|
@@ -4628,6 +4897,7 @@ export {
|
|
|
4628
4897
|
NetworkError,
|
|
4629
4898
|
NetworkRepository,
|
|
4630
4899
|
ServerError,
|
|
4900
|
+
StaticRepository,
|
|
4631
4901
|
TranslationError,
|
|
4632
4902
|
TranslationLockedError,
|
|
4633
4903
|
TranslationNotFoundError,
|
|
@@ -4635,10 +4905,12 @@ export {
|
|
|
4635
4905
|
VOID_TAGS,
|
|
4636
4906
|
createPackageLogger,
|
|
4637
4907
|
extractTagName,
|
|
4908
|
+
generateAutoKey,
|
|
4638
4909
|
isClientError,
|
|
4639
4910
|
isRetryableError,
|
|
4640
4911
|
isTranslationError,
|
|
4641
4912
|
logger,
|
|
4913
|
+
md5,
|
|
4642
4914
|
measure,
|
|
4643
4915
|
parseKeyPath,
|
|
4644
4916
|
prepareTranslationRequest,
|