@noy-db/hub 0.2.0-pre.7 → 0.2.0-pre.8
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/aggregate/index.cjs.map +1 -1
- package/dist/aggregate/index.js +2 -2
- package/dist/attestation/index.cjs.map +1 -1
- package/dist/attestation/index.d.cts +2 -2
- package/dist/attestation/index.d.ts +2 -2
- package/dist/attestation/index.js +5 -5
- package/dist/blobs/index.cjs.map +1 -1
- package/dist/blobs/index.d.cts +3 -3
- package/dist/blobs/index.d.ts +3 -3
- package/dist/blobs/index.js +4 -4
- package/dist/bundle/index.cjs +95 -15
- package/dist/bundle/index.cjs.map +1 -1
- package/dist/bundle/index.d.cts +4 -4
- package/dist/bundle/index.d.ts +4 -4
- package/dist/bundle/index.js +8 -8
- package/dist/{chunk-AYRTGXF3.js → chunk-22DWZL57.js} +62 -26
- package/dist/chunk-22DWZL57.js.map +1 -0
- package/dist/{chunk-4EOVWJL6.js → chunk-2GLDA55J.js} +2 -2
- package/dist/{chunk-CBHPW77B.js → chunk-2WUSG3IT.js} +2 -2
- package/dist/{chunk-WBUG3324.js → chunk-3BFJOWSU.js} +2 -2
- package/dist/{chunk-7IH5FDXD.js → chunk-3YPCK6JX.js} +5 -5
- package/dist/{chunk-SYOSRZN4.js → chunk-53XBRIRT.js} +4 -4
- package/dist/{chunk-UPBZ7NVY.js → chunk-5T22KDPN.js} +4 -4
- package/dist/{chunk-KK44CQ5B.js → chunk-5XHKQ56N.js} +2 -2
- package/dist/{chunk-3O5FNO5O.js → chunk-6774ZOQ7.js} +106 -50
- package/dist/chunk-6774ZOQ7.js.map +1 -0
- package/dist/chunk-6STK5TQP.js +139 -0
- package/dist/chunk-6STK5TQP.js.map +1 -0
- package/dist/{chunk-REQJJIPP.js → chunk-B6PB7JLN.js} +23 -1
- package/dist/{chunk-REQJJIPP.js.map → chunk-B6PB7JLN.js.map} +1 -1
- package/dist/{chunk-2TXMTYWZ.js → chunk-BVRYKATC.js} +3 -3
- package/dist/{chunk-6ILPGZXZ.js → chunk-DE6GKS6G.js} +2 -2
- package/dist/{chunk-TS4FQPDD.js → chunk-DFMLEQZB.js} +2 -2
- package/dist/{chunk-3XCXUJTM.js → chunk-DJHHA6XH.js} +2 -2
- package/dist/{chunk-LSY46G55.js → chunk-DL3HWOQ5.js} +3 -3
- package/dist/{chunk-6MXGU2PW.js → chunk-DO7C2TOG.js} +2 -2
- package/dist/{chunk-N4CDTRDH.js → chunk-DONMZAD2.js} +3 -3
- package/dist/{chunk-HNC55FLJ.js → chunk-F3GDRNUT.js} +3 -3
- package/dist/{chunk-VZOZ3DBN.js → chunk-H2X3ISXG.js} +3 -3
- package/dist/{chunk-XZCBBZLS.js → chunk-HNRHLRDC.js} +2 -2
- package/dist/{chunk-22ESLVUM.js → chunk-I5FOWO4J.js} +2 -2
- package/dist/{chunk-O3JCRQT3.js → chunk-JWRVQKRZ.js} +3 -3
- package/dist/{chunk-CSHY53CZ.js → chunk-K3DK3NU5.js} +2 -2
- package/dist/{chunk-BNUCCUES.js → chunk-ML236QKC.js} +2 -2
- package/dist/{chunk-GZIDTXC4.js → chunk-NONAAENK.js} +2 -2
- package/dist/{chunk-JZDA2SRB.js → chunk-O3VZPBZG.js} +4 -4
- package/dist/{chunk-PJKGXUMG.js → chunk-OQ6PIGHA.js} +2 -2
- package/dist/{chunk-QYO6I7KK.js → chunk-PE2FR4J3.js} +3 -3
- package/dist/{chunk-YAMTXW77.js → chunk-PP6W64Y3.js} +2 -2
- package/dist/{chunk-HNFXKQD7.js → chunk-PX35GA7L.js} +4 -4
- package/dist/{chunk-OXCFFRF3.js → chunk-QEILDE6R.js} +2 -2
- package/dist/{chunk-4YVVF6JN.js → chunk-QODLLGQ7.js} +4 -4
- package/dist/{chunk-ASFE2X62.js → chunk-RAZ4OVLL.js} +2 -2
- package/dist/{chunk-WM5GFORS.js → chunk-SYMWGEET.js} +2 -2
- package/dist/{chunk-SLJQIBT7.js → chunk-T7JEBOGN.js} +2 -2
- package/dist/{chunk-OA6HE2RW.js → chunk-TFBP23BX.js} +3 -3
- package/dist/{chunk-GI6S5ZF2.js → chunk-U26HQ6KJ.js} +2 -2
- package/dist/{chunk-WMKCAN4H.js → chunk-VTKGMEPP.js} +2 -2
- package/dist/{chunk-BRZFN354.js → chunk-WPLVTJ5D.js} +3 -3
- package/dist/{chunk-DCP4L4SH.js → chunk-XJFLDA7A.js} +2 -2
- package/dist/{chunk-BE5ZALMB.js → chunk-ZYWZWG6G.js} +4 -4
- package/dist/consent/index.cjs.map +1 -1
- package/dist/consent/index.d.cts +3 -3
- package/dist/consent/index.d.ts +3 -3
- package/dist/consent/index.js +3 -3
- package/dist/{crypto-TRZ5BJMY.js → crypto-HTZ4FJOP.js} +3 -3
- package/dist/{delegation-TLZTK2XW.js → delegation-RI54P6I5.js} +5 -5
- package/dist/derivations/index.cjs.map +1 -1
- package/dist/derivations/index.d.cts +4 -4
- package/dist/derivations/index.d.ts +4 -4
- package/dist/derivations/index.js +4 -4
- package/dist/{dev-unlock-L3z34v0J.d.cts → dev-unlock-M4VAWNq_.d.cts} +1 -1
- package/dist/{dev-unlock-ClAEZQC4.d.ts → dev-unlock-p3ysikWP.d.ts} +1 -1
- package/dist/executor-5PNY7LGW.js +8 -0
- package/dist/executor-B4QIYGZX.js +8 -0
- package/dist/executor-BWXXDQ7K.js +11 -0
- package/dist/guards/index.cjs.map +1 -1
- package/dist/guards/index.d.cts +4 -4
- package/dist/guards/index.d.ts +4 -4
- package/dist/guards/index.js +3 -3
- package/dist/{hash-M6-JI3Yu.d.cts → hash-BPsYPcv_.d.cts} +1 -1
- package/dist/{hash-B3lV6lw3.d.ts → hash-C1GtiOhR.d.ts} +1 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +4 -4
- package/dist/history/index.d.ts +4 -4
- package/dist/history/index.js +4 -4
- package/dist/i18n/index.cjs +217 -22
- package/dist/i18n/index.cjs.map +1 -1
- package/dist/i18n/index.d.cts +3 -3
- package/dist/i18n/index.d.ts +3 -3
- package/dist/i18n/index.js +15 -4
- package/dist/i18n/index.js.map +1 -1
- package/dist/{index-vB43MAt4.d.cts → index-4fBVt8j9.d.cts} +21 -1
- package/dist/{index-CmWQyC4e.d.ts → index-D8I_pyJD.d.ts} +21 -1
- package/dist/index.cjs +286 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.ts +11 -11
- package/dist/index.js +48 -38
- package/dist/index.js.map +1 -1
- package/dist/indexing/index.cjs.map +1 -1
- package/dist/indexing/index.js +2 -2
- package/dist/issue-VGDPP4B5.js +12 -0
- package/dist/{ledger-SQVVE2DR.js → ledger-TMRZYNVJ.js} +4 -4
- package/dist/materialized-views/index.cjs.map +1 -1
- package/dist/materialized-views/index.d.cts +5 -5
- package/dist/materialized-views/index.d.ts +5 -5
- package/dist/materialized-views/index.js +6 -6
- package/dist/noydb-LZBH3XDK.js +34 -0
- package/dist/overlay-views/index.cjs.map +1 -1
- package/dist/overlay-views/index.d.cts +4 -4
- package/dist/overlay-views/index.d.ts +4 -4
- package/dist/overlay-views/index.js +4 -4
- package/dist/periods/index.cjs.map +1 -1
- package/dist/periods/index.d.cts +3 -3
- package/dist/periods/index.d.ts +3 -3
- package/dist/periods/index.js +4 -4
- package/dist/{public-envelope-BXPXMN3U.js → public-envelope-BW6OXORV.js} +3 -3
- package/dist/query/index.cjs.map +1 -1
- package/dist/query/index.d.cts +1 -1
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +3 -3
- package/dist/registry-3QP3YKQS.js +8 -0
- package/dist/{registry-4R4IURUM.js → registry-OJIOSBV6.js} +3 -3
- package/dist/registry-USRVT6YF.js +8 -0
- package/dist/{revoke-Y7UDOXGH.js → revoke-JCC7N56X.js} +5 -5
- package/dist/session/index.cjs.map +1 -1
- package/dist/session/index.d.cts +4 -4
- package/dist/session/index.d.ts +4 -4
- package/dist/session/index.js +3 -3
- package/dist/shadow/index.cjs.map +1 -1
- package/dist/shadow/index.d.cts +3 -3
- package/dist/shadow/index.d.ts +3 -3
- package/dist/shadow/index.js +2 -2
- package/dist/{signer-UD2ZSVDJ.js → signer-72QAUSVW.js} +4 -4
- package/dist/snapshots/index.cjs.map +1 -1
- package/dist/snapshots/index.d.cts +3 -3
- package/dist/snapshots/index.d.ts +3 -3
- package/dist/snapshots/index.js +3 -3
- package/dist/{stale-F4V5E7ZK.js → stale-6ZDBTQT7.js} +2 -2
- package/dist/store/index.cjs.map +1 -1
- package/dist/store/index.d.cts +3 -3
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +2 -2
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +2 -2
- package/dist/sync/index.d.ts +2 -2
- package/dist/sync/index.js +3 -3
- package/dist/team/index.cjs.map +1 -1
- package/dist/team/index.d.cts +3 -3
- package/dist/team/index.d.ts +3 -3
- package/dist/team/index.js +7 -7
- package/dist/tx/index.cjs.map +1 -1
- package/dist/tx/index.d.cts +3 -3
- package/dist/tx/index.d.ts +3 -3
- package/dist/tx/index.js +3 -3
- package/dist/{types-DT7cXRHq.d.ts → types-DGU60JDt.d.ts} +174 -5
- package/dist/{types-r-y7TIqj.d.cts → types-DjunxzJa.d.cts} +174 -5
- package/dist/{ulid-Dt55yn4s.d.ts → ulid-BFJkYRRW.d.ts} +1 -1
- package/dist/{ulid-BkW3mLlz.d.cts → ulid-DPeuPgi3.d.cts} +1 -1
- package/dist/util/index.cjs.map +1 -1
- package/dist/util/index.js +1 -1
- package/dist/{with-derivation-DB63Po2m.d.cts → with-derivation-Df0kMlED.d.cts} +1 -1
- package/dist/{with-derivation-D_Ids_H6.d.ts → with-derivation-DfOpKjFw.d.ts} +1 -1
- package/dist/{with-guard-BJwdc0s6.d.ts → with-guard-0KksDtSR.d.ts} +1 -1
- package/dist/{with-guard-BHThLppa.d.cts → with-guard-C6W5RVrH.d.cts} +1 -1
- package/dist/{with-materialized-view-D-CRVSDX.d.ts → with-materialized-view-BiasFcYx.d.ts} +1 -1
- package/dist/{with-materialized-view-BJmJ-FrO.d.cts → with-materialized-view-BmDKyHrm.d.cts} +1 -1
- package/dist/{with-overlayed-view-zePNtUSq.d.cts → with-overlayed-view-CA66vhHz.d.cts} +1 -1
- package/dist/{with-overlayed-view-CNf6GbDG.d.ts → with-overlayed-view-CQViuko_.d.ts} +1 -1
- package/package.json +5 -4
- package/dist/chunk-3O5FNO5O.js.map +0 -1
- package/dist/chunk-AYRTGXF3.js.map +0 -1
- package/dist/executor-HAVRTQN4.js +0 -11
- package/dist/executor-V3DKOADS.js +0 -8
- package/dist/executor-XO4M4243.js +0 -8
- package/dist/issue-EJKUQ6FA.js +0 -12
- package/dist/noydb-MK4UQ626.js +0 -34
- package/dist/registry-GPBLCHG7.js +0 -8
- package/dist/registry-ZON5HNIV.js +0 -8
- /package/dist/{chunk-4EOVWJL6.js.map → chunk-2GLDA55J.js.map} +0 -0
- /package/dist/{chunk-CBHPW77B.js.map → chunk-2WUSG3IT.js.map} +0 -0
- /package/dist/{chunk-WBUG3324.js.map → chunk-3BFJOWSU.js.map} +0 -0
- /package/dist/{chunk-7IH5FDXD.js.map → chunk-3YPCK6JX.js.map} +0 -0
- /package/dist/{chunk-SYOSRZN4.js.map → chunk-53XBRIRT.js.map} +0 -0
- /package/dist/{chunk-UPBZ7NVY.js.map → chunk-5T22KDPN.js.map} +0 -0
- /package/dist/{chunk-KK44CQ5B.js.map → chunk-5XHKQ56N.js.map} +0 -0
- /package/dist/{chunk-2TXMTYWZ.js.map → chunk-BVRYKATC.js.map} +0 -0
- /package/dist/{chunk-6ILPGZXZ.js.map → chunk-DE6GKS6G.js.map} +0 -0
- /package/dist/{chunk-TS4FQPDD.js.map → chunk-DFMLEQZB.js.map} +0 -0
- /package/dist/{chunk-3XCXUJTM.js.map → chunk-DJHHA6XH.js.map} +0 -0
- /package/dist/{chunk-LSY46G55.js.map → chunk-DL3HWOQ5.js.map} +0 -0
- /package/dist/{chunk-6MXGU2PW.js.map → chunk-DO7C2TOG.js.map} +0 -0
- /package/dist/{chunk-N4CDTRDH.js.map → chunk-DONMZAD2.js.map} +0 -0
- /package/dist/{chunk-HNC55FLJ.js.map → chunk-F3GDRNUT.js.map} +0 -0
- /package/dist/{chunk-VZOZ3DBN.js.map → chunk-H2X3ISXG.js.map} +0 -0
- /package/dist/{chunk-XZCBBZLS.js.map → chunk-HNRHLRDC.js.map} +0 -0
- /package/dist/{chunk-22ESLVUM.js.map → chunk-I5FOWO4J.js.map} +0 -0
- /package/dist/{chunk-O3JCRQT3.js.map → chunk-JWRVQKRZ.js.map} +0 -0
- /package/dist/{chunk-CSHY53CZ.js.map → chunk-K3DK3NU5.js.map} +0 -0
- /package/dist/{chunk-BNUCCUES.js.map → chunk-ML236QKC.js.map} +0 -0
- /package/dist/{chunk-GZIDTXC4.js.map → chunk-NONAAENK.js.map} +0 -0
- /package/dist/{chunk-JZDA2SRB.js.map → chunk-O3VZPBZG.js.map} +0 -0
- /package/dist/{chunk-PJKGXUMG.js.map → chunk-OQ6PIGHA.js.map} +0 -0
- /package/dist/{chunk-QYO6I7KK.js.map → chunk-PE2FR4J3.js.map} +0 -0
- /package/dist/{chunk-YAMTXW77.js.map → chunk-PP6W64Y3.js.map} +0 -0
- /package/dist/{chunk-HNFXKQD7.js.map → chunk-PX35GA7L.js.map} +0 -0
- /package/dist/{chunk-OXCFFRF3.js.map → chunk-QEILDE6R.js.map} +0 -0
- /package/dist/{chunk-4YVVF6JN.js.map → chunk-QODLLGQ7.js.map} +0 -0
- /package/dist/{chunk-ASFE2X62.js.map → chunk-RAZ4OVLL.js.map} +0 -0
- /package/dist/{chunk-WM5GFORS.js.map → chunk-SYMWGEET.js.map} +0 -0
- /package/dist/{chunk-SLJQIBT7.js.map → chunk-T7JEBOGN.js.map} +0 -0
- /package/dist/{chunk-OA6HE2RW.js.map → chunk-TFBP23BX.js.map} +0 -0
- /package/dist/{chunk-GI6S5ZF2.js.map → chunk-U26HQ6KJ.js.map} +0 -0
- /package/dist/{chunk-WMKCAN4H.js.map → chunk-VTKGMEPP.js.map} +0 -0
- /package/dist/{chunk-BRZFN354.js.map → chunk-WPLVTJ5D.js.map} +0 -0
- /package/dist/{chunk-DCP4L4SH.js.map → chunk-XJFLDA7A.js.map} +0 -0
- /package/dist/{chunk-BE5ZALMB.js.map → chunk-ZYWZWG6G.js.map} +0 -0
- /package/dist/{crypto-TRZ5BJMY.js.map → crypto-HTZ4FJOP.js.map} +0 -0
- /package/dist/{delegation-TLZTK2XW.js.map → delegation-RI54P6I5.js.map} +0 -0
- /package/dist/{executor-HAVRTQN4.js.map → executor-5PNY7LGW.js.map} +0 -0
- /package/dist/{executor-V3DKOADS.js.map → executor-B4QIYGZX.js.map} +0 -0
- /package/dist/{executor-XO4M4243.js.map → executor-BWXXDQ7K.js.map} +0 -0
- /package/dist/{issue-EJKUQ6FA.js.map → issue-VGDPP4B5.js.map} +0 -0
- /package/dist/{ledger-SQVVE2DR.js.map → ledger-TMRZYNVJ.js.map} +0 -0
- /package/dist/{noydb-MK4UQ626.js.map → noydb-LZBH3XDK.js.map} +0 -0
- /package/dist/{public-envelope-BXPXMN3U.js.map → public-envelope-BW6OXORV.js.map} +0 -0
- /package/dist/{registry-4R4IURUM.js.map → registry-3QP3YKQS.js.map} +0 -0
- /package/dist/{registry-GPBLCHG7.js.map → registry-OJIOSBV6.js.map} +0 -0
- /package/dist/{registry-ZON5HNIV.js.map → registry-USRVT6YF.js.map} +0 -0
- /package/dist/{revoke-Y7UDOXGH.js.map → revoke-JCC7N56X.js.map} +0 -0
- /package/dist/{signer-UD2ZSVDJ.js.map → signer-72QAUSVW.js.map} +0 -0
- /package/dist/{stale-F4V5E7ZK.js.map → stale-6ZDBTQT7.js.map} +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ScriptViolationError
|
|
3
|
+
} from "./chunk-B6PB7JLN.js";
|
|
4
|
+
|
|
5
|
+
// src/i18n/script.ts
|
|
6
|
+
var LATIN_BASE = /* @__PURE__ */ new Set([
|
|
7
|
+
"en",
|
|
8
|
+
"fr",
|
|
9
|
+
"de",
|
|
10
|
+
"es",
|
|
11
|
+
"it",
|
|
12
|
+
"pt",
|
|
13
|
+
"nl",
|
|
14
|
+
"sv",
|
|
15
|
+
"no",
|
|
16
|
+
"da",
|
|
17
|
+
"fi",
|
|
18
|
+
"is",
|
|
19
|
+
"pl",
|
|
20
|
+
"cs",
|
|
21
|
+
"sk",
|
|
22
|
+
"hu",
|
|
23
|
+
"ro",
|
|
24
|
+
"hr",
|
|
25
|
+
"sl",
|
|
26
|
+
"et",
|
|
27
|
+
"lv",
|
|
28
|
+
"lt",
|
|
29
|
+
"tr",
|
|
30
|
+
"vi",
|
|
31
|
+
"id",
|
|
32
|
+
"ms",
|
|
33
|
+
"tl",
|
|
34
|
+
"sw",
|
|
35
|
+
"af",
|
|
36
|
+
"ca",
|
|
37
|
+
"gl",
|
|
38
|
+
"eu",
|
|
39
|
+
"cy",
|
|
40
|
+
"ga"
|
|
41
|
+
]);
|
|
42
|
+
var SCRIPT_TABLE = {
|
|
43
|
+
th: ["Thai"],
|
|
44
|
+
ko: ["Hangul", "Han"],
|
|
45
|
+
ja: ["Han", "Hiragana", "Katakana"],
|
|
46
|
+
zh: ["Han"],
|
|
47
|
+
ar: ["Arabic"],
|
|
48
|
+
fa: ["Arabic"],
|
|
49
|
+
ur: ["Arabic"],
|
|
50
|
+
ru: ["Cyrillic"],
|
|
51
|
+
uk: ["Cyrillic"],
|
|
52
|
+
bg: ["Cyrillic"],
|
|
53
|
+
sr: ["Cyrillic"],
|
|
54
|
+
he: ["Hebrew"],
|
|
55
|
+
el: ["Greek"],
|
|
56
|
+
hi: ["Devanagari"],
|
|
57
|
+
ta: ["Tamil"],
|
|
58
|
+
km: ["Khmer"],
|
|
59
|
+
lo: ["Lao"],
|
|
60
|
+
my: ["Myanmar"]
|
|
61
|
+
};
|
|
62
|
+
var SUBTAG_SCRIPTS = {
|
|
63
|
+
Latn: ["Latin"],
|
|
64
|
+
Cyrl: ["Cyrillic", "Latin"],
|
|
65
|
+
Hans: ["Han", "Latin"],
|
|
66
|
+
Hant: ["Han", "Latin"],
|
|
67
|
+
Thai: ["Thai", "Latin"],
|
|
68
|
+
Arab: ["Arabic", "Latin"]
|
|
69
|
+
};
|
|
70
|
+
function inferScripts(locale) {
|
|
71
|
+
const parts = locale.split("-");
|
|
72
|
+
const subtag = parts.find((t) => /^[A-Z][a-z]{3}$/.test(t));
|
|
73
|
+
if (subtag && SUBTAG_SCRIPTS[subtag]) return SUBTAG_SCRIPTS[subtag];
|
|
74
|
+
const base = (parts[0] ?? "").toLowerCase();
|
|
75
|
+
if (LATIN_BASE.has(base)) return ["Latin"];
|
|
76
|
+
const primary = SCRIPT_TABLE[base];
|
|
77
|
+
if (primary) return [...primary, "Latin"];
|
|
78
|
+
return ["Latin"];
|
|
79
|
+
}
|
|
80
|
+
function allowedFor(descriptor, locale) {
|
|
81
|
+
const script = descriptor.options.script;
|
|
82
|
+
if (script && script !== "auto") {
|
|
83
|
+
const explicit = script[locale];
|
|
84
|
+
if (explicit) return explicit;
|
|
85
|
+
}
|
|
86
|
+
return inferScripts(locale);
|
|
87
|
+
}
|
|
88
|
+
var BASELINE = String.raw`\p{White_Space}\p{Script=Common}\p{Script=Inherited}\p{Mark}`;
|
|
89
|
+
function fullMatcher(scripts) {
|
|
90
|
+
const cls = scripts.map((s) => `\\p{Script=${s}}`).join("");
|
|
91
|
+
return new RegExp(`^[${BASELINE}${cls}]*$`, "u");
|
|
92
|
+
}
|
|
93
|
+
function charMatcher(scripts) {
|
|
94
|
+
const cls = scripts.map((s) => `\\p{Script=${s}}`).join("");
|
|
95
|
+
return new RegExp(`[${BASELINE}${cls}]`, "u");
|
|
96
|
+
}
|
|
97
|
+
function offendingSample(str, scripts) {
|
|
98
|
+
const ok = charMatcher(scripts);
|
|
99
|
+
const bad = [];
|
|
100
|
+
for (const ch of str) {
|
|
101
|
+
if (!ok.test(ch)) bad.push(ch);
|
|
102
|
+
if (bad.length >= 8) break;
|
|
103
|
+
}
|
|
104
|
+
return bad.join("");
|
|
105
|
+
}
|
|
106
|
+
function stripDisallowed(str, scripts) {
|
|
107
|
+
const ok = charMatcher(scripts);
|
|
108
|
+
let out = "";
|
|
109
|
+
for (const ch of str) if (ok.test(ch)) out += ch;
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
function enforceScript(value, field, descriptor) {
|
|
113
|
+
const opt = descriptor.options;
|
|
114
|
+
if (!opt.script) return { value, warnings: [] };
|
|
115
|
+
const mode = opt.onScriptViolation ?? "reject";
|
|
116
|
+
const warnings = [];
|
|
117
|
+
let out = value;
|
|
118
|
+
for (const [locale, raw] of Object.entries(value)) {
|
|
119
|
+
if (typeof raw !== "string") continue;
|
|
120
|
+
const allowed = allowedFor(descriptor, locale);
|
|
121
|
+
if (fullMatcher(allowed).test(raw)) continue;
|
|
122
|
+
const sample = offendingSample(raw, allowed);
|
|
123
|
+
if (mode === "reject") {
|
|
124
|
+
throw new ScriptViolationError(field, locale, allowed, sample);
|
|
125
|
+
}
|
|
126
|
+
warnings.push({ field, locale, expected: allowed, sample });
|
|
127
|
+
if (mode === "filter") {
|
|
128
|
+
if (out === value) out = { ...value };
|
|
129
|
+
out[locale] = stripDisallowed(raw, allowed);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return { value: out, warnings };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export {
|
|
136
|
+
inferScripts,
|
|
137
|
+
enforceScript
|
|
138
|
+
};
|
|
139
|
+
//# sourceMappingURL=chunk-6STK5TQP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n/script.ts"],"sourcesContent":["/**\n * Per-locale script enforcement for `i18nText` fields (write-time).\n *\n * Each locale slot's string is validated against an allowed set of\n * Unicode scripts. `'auto'` infers the set from the locale code with\n * **asymmetric Latin tolerance** (#283): every non-Latin-script locale\n * also allows `Latin`, because proper names and addresses in those\n * locales routinely embed Latin brand/building/technical names — while\n * Latin-script locales do NOT allow other scripts, so the common error\n * (e.g. Thai text dumped into an `en` slot) is still caught.\n *\n * The always-on baseline is `Common` (digits, punctuation), `Inherited`\n * and `Mark` (combining diacritics, joiners, harakat, tone marks), and\n * whitespace — so Latin digits and in-script combining marks never\n * false-reject.\n *\n * @public\n */\nimport { ScriptViolationError } from '../errors.js'\nimport type { I18nTextDescriptor } from './core.js'\n\n/** Locales whose base language is written in the Latin script. */\nconst LATIN_BASE = new Set([\n 'en', 'fr', 'de', 'es', 'it', 'pt', 'nl', 'sv', 'no', 'da', 'fi', 'is',\n 'pl', 'cs', 'sk', 'hu', 'ro', 'hr', 'sl', 'et', 'lv', 'lt', 'tr', 'vi',\n 'id', 'ms', 'tl', 'sw', 'af', 'ca', 'gl', 'eu', 'cy', 'ga',\n])\n\n/** Base-language → primary (non-Latin) scripts. Latin is appended by inferScripts. */\nconst SCRIPT_TABLE: Record<string, readonly string[]> = {\n th: ['Thai'],\n ko: ['Hangul', 'Han'],\n ja: ['Han', 'Hiragana', 'Katakana'],\n zh: ['Han'],\n ar: ['Arabic'],\n fa: ['Arabic'],\n ur: ['Arabic'],\n ru: ['Cyrillic'],\n uk: ['Cyrillic'],\n bg: ['Cyrillic'],\n sr: ['Cyrillic'],\n he: ['Hebrew'],\n el: ['Greek'],\n hi: ['Devanagari'],\n ta: ['Tamil'],\n km: ['Khmer'],\n lo: ['Lao'],\n my: ['Myanmar'],\n}\n\n/** Map a BCP-47 script subtag (e.g. `Latn`, `Cyrl`) to allowed scripts. */\nconst SUBTAG_SCRIPTS: Record<string, readonly string[]> = {\n Latn: ['Latin'],\n Cyrl: ['Cyrillic', 'Latin'],\n Hans: ['Han', 'Latin'],\n Hant: ['Han', 'Latin'],\n Thai: ['Thai', 'Latin'],\n Arab: ['Arabic', 'Latin'],\n}\n\n/**\n * Infer the allowed Unicode scripts for a BCP-47 locale, with asymmetric\n * Latin tolerance. A script subtag (`th-Latn`) wins over the base\n * language. Unknown locales default to `['Latin']`.\n */\nexport function inferScripts(locale: string): readonly string[] {\n const parts = locale.split('-')\n const subtag = parts.find((t) => /^[A-Z][a-z]{3}$/.test(t))\n if (subtag && SUBTAG_SCRIPTS[subtag]) return SUBTAG_SCRIPTS[subtag]\n\n const base = (parts[0] ?? '').toLowerCase()\n if (LATIN_BASE.has(base)) return ['Latin']\n const primary = SCRIPT_TABLE[base]\n if (primary) return [...primary, 'Latin'] // asymmetric Latin tolerance (#283)\n return ['Latin']\n}\n\n/** Resolve the allowed scripts for a field's locale slot. */\nfunction allowedFor(descriptor: I18nTextDescriptor, locale: string): readonly string[] {\n const script = descriptor.options.script\n if (script && script !== 'auto') {\n const explicit = script[locale]\n if (explicit) return explicit\n }\n return inferScripts(locale)\n}\n\n/** Always-allowed baseline character classes (besides the named scripts). */\nconst BASELINE = String.raw`\\p{White_Space}\\p{Script=Common}\\p{Script=Inherited}\\p{Mark}`\n\n/** Build a whole-string matcher for the allowed scripts. */\nfunction fullMatcher(scripts: readonly string[]): RegExp {\n const cls = scripts.map((s) => `\\\\p{Script=${s}}`).join('')\n return new RegExp(`^[${BASELINE}${cls}]*$`, 'u')\n}\n\n/** Build a single-character matcher (for sampling / stripping). */\nfunction charMatcher(scripts: readonly string[]): RegExp {\n const cls = scripts.map((s) => `\\\\p{Script=${s}}`).join('')\n return new RegExp(`[${BASELINE}${cls}]`, 'u')\n}\n\n/** Collect a short sample of characters that violate the allowed scripts. */\nfunction offendingSample(str: string, scripts: readonly string[]): string {\n const ok = charMatcher(scripts)\n const bad: string[] = []\n for (const ch of str) {\n if (!ok.test(ch)) bad.push(ch)\n if (bad.length >= 8) break\n }\n return bad.join('')\n}\n\n/** Remove characters that violate the allowed scripts. */\nfunction stripDisallowed(str: string, scripts: readonly string[]): string {\n const ok = charMatcher(scripts)\n let out = ''\n for (const ch of str) if (ok.test(ch)) out += ch\n return out\n}\n\n/** A non-fatal script violation recorded under `'filter'`/`'warn'` modes. */\nexport interface ScriptWarning {\n readonly field: string\n readonly locale: string\n readonly expected: readonly string[]\n readonly sample: string\n}\n\n/**\n * Enforce a field's script constraint over an i18nText value map.\n *\n * - No `script` option ⇒ returns the value unchanged.\n * - `onScriptViolation: 'reject'` (default) ⇒ throws {@link ScriptViolationError}.\n * - `'filter'` ⇒ returns a copy with disallowed characters stripped + warnings.\n * - `'warn'` ⇒ returns the value unchanged + warnings.\n */\nexport function enforceScript(\n value: Record<string, unknown>,\n field: string,\n descriptor: I18nTextDescriptor,\n): { value: Record<string, unknown>; warnings: ScriptWarning[] } {\n const opt = descriptor.options\n if (!opt.script) return { value, warnings: [] }\n\n const mode = opt.onScriptViolation ?? 'reject'\n const warnings: ScriptWarning[] = []\n let out = value\n\n for (const [locale, raw] of Object.entries(value)) {\n if (typeof raw !== 'string') continue\n const allowed = allowedFor(descriptor, locale)\n if (fullMatcher(allowed).test(raw)) continue\n\n const sample = offendingSample(raw, allowed)\n if (mode === 'reject') {\n throw new ScriptViolationError(field, locale, allowed, sample)\n }\n warnings.push({ field, locale, expected: allowed, sample })\n if (mode === 'filter') {\n if (out === value) out = { ...value }\n out[locale] = stripDisallowed(raw, allowed)\n }\n }\n\n return { value: out, warnings }\n}\n"],"mappings":";;;;;AAsBA,IAAM,aAAa,oBAAI,IAAI;AAAA,EACzB;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAClE;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAClE;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAAA,EAAM;AAC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AK,GAAG;AACjD,QAAI,OAAO,QAAQ,SAAU;AAC7B,UAAM,UAAU,WAAW,YAAY,MAAM;AAC7C,QAAI,YAAY,OAAO,EAAE,KAAK,GAAG,EAAG;AAEpC,UAAM,SAAS,gBAAgB,KAAK,OAAO;AAC3C,QAAI,SAAS,UAAU;AACrB,YAAM,IAAI,qBAAqB,OAAO,QAAQ,SAAS,MAAM;AAAA,IAC/D;AACA,aAAS,KAAK,EAAE,OAAO,QAAQ,UAAU,SAAS,OAAO,CAAC;AAC1D,QAAI,SAAS,UAAU;AACrB,UAAI,QAAQ,MAAO,OAAM,EAAE,GAAG,MAAM;AACpC,UAAI,MAAM,IAAI,gBAAgB,KAAK,OAAO;AAAA,IAC5C;AAAA,EACF;AAEA,SAAO,EAAE,OAAO,KAAK,SAAS;AAChC;","names":[]}
|
|
@@ -513,6 +513,27 @@ var LocaleNotSpecifiedError = class extends NoydbError {
|
|
|
513
513
|
this.field = field;
|
|
514
514
|
}
|
|
515
515
|
};
|
|
516
|
+
var ScriptViolationError = class extends NoydbError {
|
|
517
|
+
/** The field whose value violated its script constraint. */
|
|
518
|
+
field;
|
|
519
|
+
/** The locale slot (e.g. `'en'`) that was checked. */
|
|
520
|
+
locale;
|
|
521
|
+
/** The Unicode scripts allowed for this slot. */
|
|
522
|
+
expected;
|
|
523
|
+
/** A short sample of the offending characters, for diagnostics. */
|
|
524
|
+
sample;
|
|
525
|
+
constructor(field, locale, expected, sample, message) {
|
|
526
|
+
super(
|
|
527
|
+
"SCRIPT_VIOLATION",
|
|
528
|
+
message ?? `Field "${field}" slot "${locale}" expects script(s) [${expected.join(", ")}] but contains disallowed character(s): "${sample}".`
|
|
529
|
+
);
|
|
530
|
+
this.name = "ScriptViolationError";
|
|
531
|
+
this.field = field;
|
|
532
|
+
this.locale = locale;
|
|
533
|
+
this.expected = expected;
|
|
534
|
+
this.sample = sample;
|
|
535
|
+
}
|
|
536
|
+
};
|
|
516
537
|
var TranslatorNotConfiguredError = class extends NoydbError {
|
|
517
538
|
/** The field that requested auto-translation. */
|
|
518
539
|
field;
|
|
@@ -893,6 +914,7 @@ export {
|
|
|
893
914
|
DictKeyInUseError,
|
|
894
915
|
MissingTranslationError,
|
|
895
916
|
LocaleNotSpecifiedError,
|
|
917
|
+
ScriptViolationError,
|
|
896
918
|
TranslatorNotConfiguredError,
|
|
897
919
|
BackupLedgerError,
|
|
898
920
|
BackupCorruptedError,
|
|
@@ -924,4 +946,4 @@ export {
|
|
|
924
946
|
OverlayIdMismatchError,
|
|
925
947
|
SnapshotNotFoundError
|
|
926
948
|
};
|
|
927
|
-
//# sourceMappingURL=chunk-
|
|
949
|
+
//# sourceMappingURL=chunk-B6PB7JLN.js.map
|