@tamagui/simple-hash 2.0.0-rc.4 → 2.0.0-rc.40
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/cjs/index.cjs +46 -33
- package/dist/cjs/index.native.js +52 -35
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/esm/index.js +29 -14
- package/dist/esm/index.js.map +1 -6
- package/dist/esm/index.mjs +34 -23
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/index.native.js +40 -25
- package/dist/esm/index.native.js.map +1 -1
- package/package.json +5 -8
- package/types/index.d.ts.map +2 -2
- package/dist/cjs/index.js +0 -56
- package/dist/cjs/index.js.map +0 -6
package/dist/cjs/index.cjs
CHANGED
|
@@ -3,20 +3,22 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
14
|
get: () => from[key],
|
|
14
15
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
16
|
});
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
18
20
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
19
|
-
value:
|
|
21
|
+
value: true
|
|
20
22
|
}), mod);
|
|
21
23
|
var index_exports = {};
|
|
22
24
|
__export(index_exports, {
|
|
@@ -26,31 +28,42 @@ module.exports = __toCommonJS(index_exports);
|
|
|
26
28
|
const cache = /* @__PURE__ */new Map();
|
|
27
29
|
let cacheSize = 0;
|
|
28
30
|
const simpleHash = (strIn, hashMin = 10) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
if (cache.has(strIn)) {
|
|
32
|
+
return cache.get(strIn);
|
|
33
|
+
}
|
|
34
|
+
let str = strIn;
|
|
35
|
+
if (str[0] === "v" && str.startsWith("var(")) {
|
|
36
|
+
str = str.slice(6, str.length - 1);
|
|
37
|
+
}
|
|
38
|
+
let hash = 0;
|
|
39
|
+
let valids = "";
|
|
40
|
+
let added = 0;
|
|
41
|
+
const len = str.length;
|
|
42
|
+
for (let i = 0; i < len; i++) {
|
|
43
|
+
if (hashMin !== "strict" && added <= hashMin) {
|
|
44
|
+
const char = str.charCodeAt(i);
|
|
45
|
+
if (char === 46) {
|
|
46
|
+
valids += "--";
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (isValidCSSCharCode(char)) {
|
|
50
|
+
added++;
|
|
51
|
+
valids += str[i];
|
|
52
|
+
continue;
|
|
47
53
|
}
|
|
48
|
-
hash = hashChar(hash, str[i]);
|
|
49
54
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
55
|
+
hash = hashChar(hash, str[i]);
|
|
56
|
+
}
|
|
57
|
+
const res = valids + (hash ? Math.abs(hash) : "");
|
|
58
|
+
if (cacheSize > 1e4) {
|
|
59
|
+
cache.clear();
|
|
60
|
+
cacheSize = 0;
|
|
61
|
+
}
|
|
62
|
+
cache.set(strIn, res);
|
|
63
|
+
cacheSize++;
|
|
64
|
+
return res;
|
|
65
|
+
};
|
|
66
|
+
const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
54
67
|
function isValidCSSCharCode(code) {
|
|
55
68
|
return (
|
|
56
69
|
// A-Z
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,53 +5,70 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
15
16
|
get: () => from[key],
|
|
16
17
|
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
18
|
});
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
20
22
|
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value:
|
|
23
|
+
value: true
|
|
22
24
|
}), mod);
|
|
23
25
|
var index_exports = {};
|
|
24
26
|
__export(index_exports, {
|
|
25
27
|
simpleHash: () => simpleHash
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(index_exports);
|
|
28
|
-
var cache = /* @__PURE__ */new Map()
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
var cache = /* @__PURE__ */new Map();
|
|
31
|
+
var cacheSize = 0;
|
|
32
|
+
var simpleHash = function (strIn) {
|
|
33
|
+
var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;
|
|
34
|
+
if (cache.has(strIn)) {
|
|
35
|
+
return cache.get(strIn);
|
|
36
|
+
}
|
|
37
|
+
var str = strIn;
|
|
38
|
+
if (str[0] === "v" && str.startsWith("var(")) {
|
|
39
|
+
str = str.slice(6, str.length - 1);
|
|
40
|
+
}
|
|
41
|
+
var hash = 0;
|
|
42
|
+
var valids = "";
|
|
43
|
+
var added = 0;
|
|
44
|
+
var len = str.length;
|
|
45
|
+
for (var i = 0; i < len; i++) {
|
|
46
|
+
if (hashMin !== "strict" && added <= hashMin) {
|
|
47
|
+
var char = str.charCodeAt(i);
|
|
48
|
+
if (char === 46) {
|
|
49
|
+
valids += "--";
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (isValidCSSCharCode(char)) {
|
|
53
|
+
added++;
|
|
54
|
+
valids += str[i];
|
|
55
|
+
continue;
|
|
46
56
|
}
|
|
47
|
-
hash = hashChar(hash, str[i]);
|
|
48
57
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
58
|
+
hash = hashChar(hash, str[i]);
|
|
59
|
+
}
|
|
60
|
+
var res = valids + (hash ? Math.abs(hash) : "");
|
|
61
|
+
if (cacheSize > 1e4) {
|
|
62
|
+
cache.clear();
|
|
63
|
+
cacheSize = 0;
|
|
64
|
+
}
|
|
65
|
+
cache.set(strIn, res);
|
|
66
|
+
cacheSize++;
|
|
67
|
+
return res;
|
|
68
|
+
};
|
|
69
|
+
var hashChar = function (hash, c) {
|
|
70
|
+
return Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
71
|
+
};
|
|
55
72
|
function isValidCSSCharCode(code) {
|
|
56
73
|
return (
|
|
57
74
|
// A-Z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","simpleHash","module","exports","cache","Map","cacheSize","strIn","hashMin","arguments","length","has","get","str","startsWith","slice","hash","valids","added","len","i","char","charCodeAt","isValidCSSCharCode","hashChar","res","Math","abs","clear","set","c","imul","code"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","index_exports","__export","simpleHash","module","exports","cache","Map","cacheSize","strIn","hashMin","arguments","length","has","get","str","startsWith","slice","hash","valids","added","len","i","char","charCodeAt","isValidCSSCharCode","hashChar","res","Math","abs","clear","set","c","imul","code"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,aAAA;AAAAC,QAAA,CAAAD,aAAA;EAAAE,UAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAM,CAAAC,OAAQ,GAAAT,YAAA,CAAAK,aAAwB;AACtC,IAAIK,KAAA,kBAAY,IAAAC,GAAA;AAET,IAAAC,SAAM;AACX,IAAAL,UAAU,GAAI,SAAAA,CAAQM,KAAA;EACpB,IAAAC,OAAO,GAAAC,SAAU,CAAKC,MAAA,QAAAD,SAAA,iBAAAA,SAAA;EACxB,IAAAL,KAAA,CAAAO,GAAA,CAAAJ,KAAA;IAEA,OAAIH,KAAM,CAAAQ,GAAA,CAAAL,KAAA;EAGV;EACE,IAAAM,GAAA,GAAMN,KAAI;EACZ,IAAAM,GAAA,eAAAA,GAAA,CA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= /* @__PURE__ */new Map();
|
|
2
2
|
let cacheSize = 0;
|
|
3
3
|
const simpleHash = (strIn, hashMin = 10) => {
|
|
4
|
-
if (cache.has(strIn))
|
|
4
|
+
if (cache.has(strIn)) {
|
|
5
5
|
return cache.get(strIn);
|
|
6
|
+
}
|
|
6
7
|
let str = strIn;
|
|
7
|
-
str[0] === "v" && str.startsWith("var(")
|
|
8
|
-
|
|
8
|
+
if (str[0] === "v" && str.startsWith("var(")) {
|
|
9
|
+
str = str.slice(6, str.length - 1);
|
|
10
|
+
}
|
|
11
|
+
let hash = 0;
|
|
12
|
+
let valids = "";
|
|
13
|
+
let added = 0;
|
|
9
14
|
const len = str.length;
|
|
10
15
|
for (let i = 0; i < len; i++) {
|
|
11
16
|
if (hashMin !== "strict" && added <= hashMin) {
|
|
@@ -15,26 +20,36 @@ const simpleHash = (strIn, hashMin = 10) => {
|
|
|
15
20
|
continue;
|
|
16
21
|
}
|
|
17
22
|
if (isValidCSSCharCode(char)) {
|
|
18
|
-
added
|
|
23
|
+
added++;
|
|
24
|
+
valids += str[i];
|
|
19
25
|
continue;
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
28
|
hash = hashChar(hash, str[i]);
|
|
23
29
|
}
|
|
24
30
|
const res = valids + (hash ? Math.abs(hash) : "");
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
if (cacheSize > 1e4) {
|
|
32
|
+
cache.clear();
|
|
33
|
+
cacheSize = 0;
|
|
34
|
+
}
|
|
35
|
+
cache.set(strIn, res);
|
|
36
|
+
cacheSize++;
|
|
37
|
+
return res;
|
|
38
|
+
};
|
|
39
|
+
const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
27
40
|
function isValidCSSCharCode(code) {
|
|
28
41
|
return (
|
|
29
42
|
// A-Z
|
|
30
|
-
code >= 65 && code <= 90 ||
|
|
31
|
-
|
|
32
|
-
code
|
|
33
|
-
|
|
43
|
+
code >= 65 && code <= 90 ||
|
|
44
|
+
// a-z
|
|
45
|
+
code >= 97 && code <= 122 ||
|
|
46
|
+
// _
|
|
47
|
+
code === 95 ||
|
|
48
|
+
// -
|
|
49
|
+
code === 45 ||
|
|
50
|
+
// 0-9
|
|
34
51
|
code >= 48 && code <= 57
|
|
35
52
|
);
|
|
36
53
|
}
|
|
37
|
-
export {
|
|
38
|
-
simpleHash
|
|
39
|
-
};
|
|
54
|
+
export { simpleHash };
|
|
40
55
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": "AAAA,MAAM,QAAQ,oBAAI,IAAoB;AACtC,IAAI,YAAY;AAET,MAAM,aAAa,CAAC,OAAe,UAA6B,OAAe;AACpF,MAAI,MAAM,IAAI,KAAK;AACjB,WAAO,MAAM,IAAI,KAAK;AAGxB,MAAI,MAAM;AAGV,EAAI,IAAI,CAAC,MAAM,OAAO,IAAI,WAAW,MAAM,MACzC,MAAM,IAAI,MAAM,GAAG,IAAI,SAAS,CAAC;AAGnC,MAAI,OAAO,GACP,SAAS,IACT,QAAQ;AACZ,QAAM,MAAM,IAAI;AAEhB,WAAS,IAAI,GAAG,IAAI,KAAK,KAAK;AAC5B,QAAI,YAAY,YAAY,SAAS,SAAS;AAC5C,YAAM,OAAO,IAAI,WAAW,CAAC;AAC7B,UAAI,SAAS,IAAI;AACf,kBAAU;AACV;AAAA,MACF;AACA,UAAI,mBAAmB,IAAI,GAAG;AAC5B,iBACA,UAAU,IAAI,CAAC;AACf;AAAA,MACF;AAAA,IACF;AACA,WAAO,SAAS,MAAM,IAAI,CAAC,CAAC;AAAA,EAC9B;AAEA,QAAM,MAAM,UAAU,OAAO,KAAK,IAAI,IAAI,IAAI;AAE9C,SAAI,YAAY,QACd,MAAM,MAAM,GACZ,YAAY,IAGd,MAAM,IAAI,OAAO,GAAG,GACpB,aAEO;AACT,GAEM,WAAW,CAAC,MAAc,MAAe,KAAK,KAAK,IAAI,IAAI,IAAI,EAAE,WAAW,CAAC,IAAK;AAExF,SAAS,mBAAmB,MAAc;AACxC;AAAA;AAAA,IAEG,QAAQ,MAAM,QAAQ;AAAA,IAEtB,QAAQ,MAAM,QAAQ;AAAA,IAEvB,SAAS;AAAA,IAET,SAAS;AAAA,IAER,QAAQ,MAAM,QAAQ;AAAA;AAE3B;",
|
|
5
|
-
"names": []
|
|
6
|
-
}
|
|
1
|
+
{"version":3,"names":["cache","Map","cacheSize","simpleHash","strIn","hashMin","has","get","str","startsWith","slice","length","hash","valids","added","len","i","char","charCodeAt","isValidCSSCharCode","hashChar","res","Math","abs","clear","set","c","imul","code"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,MAAMA,KAAA,GAAQ,mBAAIC,GAAA,CAAoB;AACtC,IAAIC,SAAA,GAAY;AAET,MAAMC,UAAA,GAAaA,CAACC,KAAA,EAAeC,OAAA,GAA6B,OAAe;EACpF,IAAIL,KAAA,CAAMM,GAAA,CAAIF,KAAK,GAAG;IACpB,OAAOJ,KAAA,CAAMO,GAAA,CAAIH,KAAK;EACxB;EAEA,IAAII,GAAA,GAAMJ,KAAA;EAGV,IAAII,GAAA,CAAI,CAAC,MAAM,OAAOA,GAAA,CAAIC,UAAA,CAAW,MAAM,GAAG;IAC5CD,GAAA,GAAMA,GAAA,CAAIE,KAAA,CAAM,GAAGF,GAAA,CAAIG,MAAA,GAAS,CAAC;EACnC;EAEA,IAAIC,IAAA,GAAO;EACX,IAAIC,MAAA,GAAS;EACb,IAAIC,KAAA,GAAQ;EACZ,MAAMC,GAAA,GAAMP,GAAA,CAAIG,MAAA;EAEhB,SAASK,CAAA,GAAI,GAAGA,CAAA,GAAID,GAAA,EAAKC,CAAA,IAAK;IAC5B,IAAIX,OAAA,KAAY,YAAYS,KAAA,IAAST,OAAA,EAAS;MAC5C,MAAMY,IAAA,GAAOT,GAAA,CAAIU,UAAA,CA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-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
4
|
+
if (cache.has(strIn)) {
|
|
5
|
+
return cache.get(strIn);
|
|
6
|
+
}
|
|
7
|
+
let str = strIn;
|
|
8
|
+
if (str[0] === "v" && str.startsWith("var(")) {
|
|
9
|
+
str = str.slice(6, str.length - 1);
|
|
10
|
+
}
|
|
11
|
+
let hash = 0;
|
|
12
|
+
let valids = "";
|
|
13
|
+
let added = 0;
|
|
14
|
+
const len = str.length;
|
|
15
|
+
for (let i = 0; i < len; i++) {
|
|
16
|
+
if (hashMin !== "strict" && added <= hashMin) {
|
|
17
|
+
const char = str.charCodeAt(i);
|
|
18
|
+
if (char === 46) {
|
|
19
|
+
valids += "--";
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (isValidCSSCharCode(char)) {
|
|
23
|
+
added++;
|
|
24
|
+
valids += str[i];
|
|
25
|
+
continue;
|
|
22
26
|
}
|
|
23
|
-
hash = hashChar(hash, str[i]);
|
|
24
27
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
hash = hashChar(hash, str[i]);
|
|
29
|
+
}
|
|
30
|
+
const res = valids + (hash ? Math.abs(hash) : "");
|
|
31
|
+
if (cacheSize > 1e4) {
|
|
32
|
+
cache.clear();
|
|
33
|
+
cacheSize = 0;
|
|
34
|
+
}
|
|
35
|
+
cache.set(strIn, res);
|
|
36
|
+
cacheSize++;
|
|
37
|
+
return res;
|
|
38
|
+
};
|
|
39
|
+
const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
29
40
|
function isValidCSSCharCode(code) {
|
|
30
41
|
return (
|
|
31
42
|
// A-Z
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cache","Map","cacheSize","simpleHash","strIn","hashMin","has","get","str","startsWith","slice","length","hash","valids","added","len","i","char","charCodeAt","isValidCSSCharCode","hashChar","res","Math","abs","clear","set","c","imul","code"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,MAAMA,KAAA,GAAQ,mBAAIC,GAAA,CAAoB;AACtC,IAAIC,SAAA,GAAY;AAET,MAAMC,UAAA,GAAaA,CAACC,KAAA,EAAeC,OAAA,GAA6B,OAAe;
|
|
1
|
+
{"version":3,"names":["cache","Map","cacheSize","simpleHash","strIn","hashMin","has","get","str","startsWith","slice","length","hash","valids","added","len","i","char","charCodeAt","isValidCSSCharCode","hashChar","res","Math","abs","clear","set","c","imul","code"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,MAAMA,KAAA,GAAQ,mBAAIC,GAAA,CAAoB;AACtC,IAAIC,SAAA,GAAY;AAET,MAAMC,UAAA,GAAaA,CAACC,KAAA,EAAeC,OAAA,GAA6B,OAAe;EACpF,IAAIL,KAAA,CAAMM,GAAA,CAAIF,KAAK,GAAG;IACpB,OAAOJ,KAAA,CAAMO,GAAA,CAAIH,KAAK;EACxB;EAEA,IAAII,GAAA,GAAMJ,KAAA;EAGV,IAAII,GAAA,CAAI,CAAC,MAAM,OAAOA,GAAA,CAAIC,UAAA,CAAW,MAAM,GAAG;IAC5CD,GAAA,GAAMA,GAAA,CAAIE,KAAA,CAAM,GAAGF,GAAA,CAAIG,MAAA,GAAS,CAAC;EACnC;EAEA,IAAIC,IAAA,GAAO;EACX,IAAIC,MAAA,GAAS;EACb,IAAIC,KAAA,GAAQ;EACZ,MAAMC,GAAA,GAAMP,GAAA,CAAIG,MAAA;EAEhB,SAASK,CAAA,GAAI,GAAGA,CAAA,GAAID,GAAA,EAAKC,CAAA,IAAK;IAC5B,IAAIX,OAAA,KAAY,YAAYS,KAAA,IAAST,OAAA,EAAS;MAC5C,MAAMY,IAAA,GAAOT,GAAA,CAAIU,UAAA,CAAWF,CAAC;MAC7B,IAAIC,IAAA,KAAS,IAAI;QACfJ,MAAA,IAAU;QACV;MAC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var simpleHash = function (strIn) {
|
|
4
|
+
var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;
|
|
5
|
+
if (cache.has(strIn)) {
|
|
6
|
+
return cache.get(strIn);
|
|
7
|
+
}
|
|
8
|
+
var str = strIn;
|
|
9
|
+
if (str[0] === "v" && str.startsWith("var(")) {
|
|
10
|
+
str = str.slice(6, str.length - 1);
|
|
11
|
+
}
|
|
12
|
+
var hash = 0;
|
|
13
|
+
var valids = "";
|
|
14
|
+
var added = 0;
|
|
15
|
+
var len = str.length;
|
|
16
|
+
for (var i = 0; i < len; i++) {
|
|
17
|
+
if (hashMin !== "strict" && added <= hashMin) {
|
|
18
|
+
var char = str.charCodeAt(i);
|
|
19
|
+
if (char === 46) {
|
|
20
|
+
valids += "--";
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (isValidCSSCharCode(char)) {
|
|
24
|
+
added++;
|
|
25
|
+
valids += str[i];
|
|
26
|
+
continue;
|
|
19
27
|
}
|
|
20
|
-
hash = hashChar(hash, str[i]);
|
|
21
28
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
hash = hashChar(hash, str[i]);
|
|
30
|
+
}
|
|
31
|
+
var res = valids + (hash ? Math.abs(hash) : "");
|
|
32
|
+
if (cacheSize > 1e4) {
|
|
33
|
+
cache.clear();
|
|
34
|
+
cacheSize = 0;
|
|
35
|
+
}
|
|
36
|
+
cache.set(strIn, res);
|
|
37
|
+
cacheSize++;
|
|
38
|
+
return res;
|
|
39
|
+
};
|
|
40
|
+
var hashChar = function (hash, c) {
|
|
41
|
+
return Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
42
|
+
};
|
|
28
43
|
function isValidCSSCharCode(code) {
|
|
29
44
|
return (
|
|
30
45
|
// A-Z
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["cache","Map","cacheSize","simpleHash","strIn","hashMin","arguments","length","has","get","str","startsWith","slice","hash","valids","added","len","i","char","charCodeAt","isValidCSSCharCode","hashChar","res","Math","abs","clear","set","c","imul","code"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,IAAAA,KAAM,kBAAQ,IAAAC,GAAI;
|
|
1
|
+
{"version":3,"names":["cache","Map","cacheSize","simpleHash","strIn","hashMin","arguments","length","has","get","str","startsWith","slice","hash","valids","added","len","i","char","charCodeAt","isValidCSSCharCode","hashChar","res","Math","abs","clear","set","c","imul","code"],"sources":["../../src/index.ts"],"sourcesContent":[null],"mappings":"AAAA,IAAAA,KAAM,kBAAQ,IAAAC,GAAI;AAClB,IAAIC,SAAA,GAAY;AAET,IAAAC,UAAM,YAAAA,CAAcC,KAAe;EACxC,IAAIC,OAAM,GAAIC,SAAQ,CAAAC,MAAA,QAAAD,SAAA,iBAAAA,SAAA;EACpB,IAAAN,KAAO,CAAAQ,GAAA,CAAAJ,KAAU;IACnB,OAAAJ,KAAA,CAAAS,GAAA,CAAAL,KAAA;EAEA;EAGA,IAAIM,GAAA,GAAKN,KAAM;EACb,IAAAM,GAAA,CAAM,OAAI,GAAM,IAAGA,GAAI,CAAAC,UAAU;IACnCD,GAAA,GAAAA,GAAA,CAAAE,KAAA,IAAAF,GAAA,CAAAH,MAAA;EAEA;EACA,IAAIM,IAAA;EACJ,IAAIC,MAAA,GAAQ;EACZ,IAAAC,KAAM,GAAM;EAEZ,IAAAC,GAAA,GAASN,GAAI,CAAAH,MAAO;EAClB,SAAIU,CAAA,MAAAA,CAAA,GAAYD,GAAA,EAAAC,CAAA,IAAY;IAC1B,IAAAZ,OAAM,KAAO,QAAI,IAAAU,KAAY,IAAAV,OAAA;MAC7B,IAAIa,IAAA,GAAAR,GAAS,CAAAS,UAAI,CAAAF,CAAA;MACf,IAAAC,IAAA,KAAU;QACVJ,MAAA;QACF;MACA;MACE,IAAAM,kBAAA,CAAAF,IAAA;QACAH,KAAA;QACAD,MAAA,IAAAJ,GAAA,CAAAO,CAAA;QACF;MACF;IACA;IACFJ,IAAA,GAAAQ,QAAA,CAAAR,IAAA,EAAAH,GAAA,CAAAO,CAAA;EAEA;EAEA,IAAIK,GAAA,GAAAR,MAAY,IAAAD,IAAQ,GAAAU,IAAA,CAAAC,GAAA,CAAAX,IAAA;EACtB,IAAAX,SAAM,GAAM;IACZF,KAAA,CAAAyB,KAAA,CAAY;IACdvB,SAAA;EAEA;EACAF,KAAA,CAAA0B,GAAA,CAAAtB,KAAA,EAAAkB,GAAA;EAEApB,SAAO;EACT,OAAAoB,GAAA;AAEA;AAEA,IAAAD,QAAS,YAAAA,CAAAR,IAAmB,EAAAc,CAAA;EAC1B,OAAAJ,IAAA,CAAAK,IAAA,KAAAf,IAAA,IAAAc,CAAA,CAAAR,UAAA;AAAA;AAAA,SAEGC,kBAAsBA,CAAAS,IAAA;EAAA;IAIvB;IAEAA,IAAA,MAAS,IAAAA,IAAA;IAAA;IAERA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;IAAA;IAAAA,IAAA;IAAA;IAE3BA,IAAA;IAAA","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/simple-hash",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.40",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"types",
|
|
@@ -15,15 +15,12 @@
|
|
|
15
15
|
"./package.json": "./package.json",
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./types/index.d.ts",
|
|
18
|
-
"react-native":
|
|
19
|
-
|
|
20
|
-
"import": "./dist/esm/index.native.js",
|
|
21
|
-
"require": "./dist/cjs/index.native.js"
|
|
22
|
-
},
|
|
18
|
+
"react-native": "./dist/esm/index.native.js",
|
|
19
|
+
"browser": "./dist/esm/index.mjs",
|
|
23
20
|
"module": "./dist/esm/index.mjs",
|
|
24
21
|
"import": "./dist/esm/index.mjs",
|
|
25
22
|
"require": "./dist/cjs/index.cjs",
|
|
26
|
-
"default": "./dist/
|
|
23
|
+
"default": "./dist/esm/index.mjs"
|
|
27
24
|
}
|
|
28
25
|
},
|
|
29
26
|
"publishConfig": {
|
|
@@ -36,6 +33,6 @@
|
|
|
36
33
|
"clean:build": "tamagui-build clean:build"
|
|
37
34
|
},
|
|
38
35
|
"devDependencies": {
|
|
39
|
-
"@tamagui/build": "2.0.0-rc.
|
|
36
|
+
"@tamagui/build": "2.0.0-rc.40"
|
|
40
37
|
}
|
|
41
38
|
}
|
package/types/index.d.ts.map
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"sources": [
|
|
5
5
|
"src/index.ts"
|
|
6
6
|
],
|
|
7
|
+
"version": 3,
|
|
7
8
|
"sourcesContent": [
|
|
8
9
|
"const cache = new Map<string, string>()\nlet cacheSize = 0\n\nexport const simpleHash = (strIn: string, hashMin: number | 'strict' = 10): string => {\n if (cache.has(strIn)) {\n return cache.get(strIn)!\n }\n\n let str = strIn\n\n // remove var()\n if (str[0] === 'v' && str.startsWith('var(')) {\n str = str.slice(6, str.length - 1)\n }\n\n let hash = 0\n let valids = ''\n let added = 0\n const len = str.length\n\n for (let i = 0; i < len; i++) {\n if (hashMin !== 'strict' && added <= hashMin) {\n const char = str.charCodeAt(i)\n if (char === 46) {\n valids += '--'\n continue\n }\n if (isValidCSSCharCode(char)) {\n added++\n valids += str[i]\n continue\n }\n }\n hash = hashChar(hash, str[i])\n }\n\n const res = valids + (hash ? Math.abs(hash) : '')\n\n if (cacheSize > 10_000) {\n cache.clear()\n cacheSize = 0\n }\n\n cache.set(strIn, res)\n cacheSize++\n\n return res\n}\n\nconst hashChar = (hash: number, c: string) => (Math.imul(31, hash) + c.charCodeAt(0)) | 0\n\nfunction isValidCSSCharCode(code: number) {\n return (\n // A-Z\n (code >= 65 && code <= 90) ||\n // a-z\n (code >= 97 && code <= 122) ||\n // _\n code === 95 ||\n // -\n code === 45 ||\n // 0-9\n (code >= 48 && code <= 57)\n )\n}\n"
|
|
9
|
-
]
|
|
10
|
-
"version": 3
|
|
10
|
+
]
|
|
11
11
|
}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: !0 });
|
|
8
|
-
}, __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from == "object" || typeof from == "function")
|
|
10
|
-
for (let key of __getOwnPropNames(from))
|
|
11
|
-
!__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
|
|
15
|
-
var index_exports = {};
|
|
16
|
-
__export(index_exports, {
|
|
17
|
-
simpleHash: () => simpleHash
|
|
18
|
-
});
|
|
19
|
-
module.exports = __toCommonJS(index_exports);
|
|
20
|
-
const cache = /* @__PURE__ */ new Map();
|
|
21
|
-
let cacheSize = 0;
|
|
22
|
-
const simpleHash = (strIn, hashMin = 10) => {
|
|
23
|
-
if (cache.has(strIn))
|
|
24
|
-
return cache.get(strIn);
|
|
25
|
-
let str = strIn;
|
|
26
|
-
str[0] === "v" && str.startsWith("var(") && (str = str.slice(6, str.length - 1));
|
|
27
|
-
let hash = 0, valids = "", added = 0;
|
|
28
|
-
const len = str.length;
|
|
29
|
-
for (let i = 0; i < len; i++) {
|
|
30
|
-
if (hashMin !== "strict" && added <= hashMin) {
|
|
31
|
-
const char = str.charCodeAt(i);
|
|
32
|
-
if (char === 46) {
|
|
33
|
-
valids += "--";
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (isValidCSSCharCode(char)) {
|
|
37
|
-
added++, valids += str[i];
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
hash = hashChar(hash, str[i]);
|
|
42
|
-
}
|
|
43
|
-
const res = valids + (hash ? Math.abs(hash) : "");
|
|
44
|
-
return cacheSize > 1e4 && (cache.clear(), cacheSize = 0), cache.set(strIn, res), cacheSize++, res;
|
|
45
|
-
}, hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
|
|
46
|
-
function isValidCSSCharCode(code) {
|
|
47
|
-
return (
|
|
48
|
-
// A-Z
|
|
49
|
-
code >= 65 && code <= 90 || // a-z
|
|
50
|
-
code >= 97 && code <= 122 || // _
|
|
51
|
-
code === 95 || // -
|
|
52
|
-
code === 45 || // 0-9
|
|
53
|
-
code >= 48 && code <= 57
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/index.ts"],
|
|
4
|
-
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,QAAQ,oBAAI,IAAoB;AACtC,IAAI,YAAY;AAET,MAAM,aAAa,CAAC,OAAe,UAA6B,OAAe;AACpF,MAAI,MAAM,IAAI,KAAK;AACjB,WAAO,MAAM,IAAI,KAAK;AAGxB,MAAI,MAAM;AAGV,EAAI,IAAI,CAAC,MAAM,OAAO,IAAI,WAAW,MAAM,MACzC,MAAM,IAAI,MAAM,GAAG,IAAI,SAAS,CAAC;AAGnC,MAAI,OAAO,GACP,SAAS,IACT,QAAQ;AACZ,QAAM,MAAM,IAAI;AAEhB,WAAS,IAAI,GAAG,IAAI,KAAK,KAA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