@tamagui/simple-hash 2.7.6 → 3.0.0-beta.637.1

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.
@@ -1,80 +1,67 @@
1
+
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
6
  var __export = (target, all) => {
6
- for (var name in all) __defProp(target, name, {
7
- get: all[name],
8
- enumerable: true
9
- });
7
+ for (var name in all) __defProp(target, name, {
8
+ get: all[name],
9
+ enumerable: true
10
+ });
10
11
  };
11
12
  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, {
14
- get: () => from[key],
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- return to;
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
15
+ get: () => from[key],
16
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
17
+ });
18
+ }
19
+ return to;
19
20
  };
20
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
21
- value: true
22
- }), mod);
21
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
22
  var index_exports = {};
24
- __export(index_exports, {
25
- simpleHash: () => simpleHash
26
- });
23
+ __export(index_exports, { simpleHash: () => simpleHash });
27
24
  module.exports = __toCommonJS(index_exports);
28
- const cache = /* @__PURE__ */new Map();
25
+ const cache = /* @__PURE__ */ new Map();
29
26
  let cacheSize = 0;
30
27
  const simpleHash = (strIn, hashMin = 10) => {
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;
53
- }
54
- }
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;
28
+ const cacheKey = `${hashMin}:${strIn}`;
29
+ if (cache.has(cacheKey)) {
30
+ return cache.get(cacheKey);
31
+ }
32
+ let str = strIn;
33
+ if (str[0] === "v" && str.startsWith("var(")) {
34
+ str = str.slice(6, str.length - 1);
35
+ }
36
+ let hash = 0;
37
+ let valids = "";
38
+ let added = 0;
39
+ const len = str.length;
40
+ for (let i = 0; i < len; i++) {
41
+ if (hashMin !== "strict" && added <= hashMin) {
42
+ const char = str.charCodeAt(i);
43
+ if (char === 46) {
44
+ valids += "--";
45
+ continue;
46
+ }
47
+ if (isValidCSSCharCode(char)) {
48
+ added++;
49
+ valids += str[i];
50
+ continue;
51
+ }
52
+ }
53
+ hash = hashChar(hash, str[i]);
54
+ }
55
+ const res = valids + (hash ? Math.abs(hash) : "");
56
+ if (cacheSize > 1e4) {
57
+ cache.clear();
58
+ cacheSize = 0;
59
+ }
60
+ cache.set(cacheKey, res);
61
+ cacheSize++;
62
+ return res;
65
63
  };
66
64
  const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
67
65
  function isValidCSSCharCode(code) {
68
- return (
69
- // A-Z
70
- code >= 65 && code <= 90 ||
71
- // a-z
72
- code >= 97 && code <= 122 ||
73
- // _
74
- code === 95 ||
75
- // -
76
- code === 45 ||
77
- // 0-9
78
- code >= 48 && code <= 57
79
- );
80
- }
66
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95 || code === 45 || code >= 48 && code <= 57;
67
+ }
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
22
+ };
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
24
+ var index_exports = {};
25
+ __export(index_exports, { simpleHash: () => simpleHash });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var cache = /* @__PURE__ */ new Map();
28
+ var cacheSize = 0;
29
+ var simpleHash = function(strIn) {
30
+ var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;
31
+ var cacheKey = `${hashMin}:${strIn}`;
32
+ if (cache.has(cacheKey)) {
33
+ return cache.get(cacheKey);
34
+ }
35
+ var str = strIn;
36
+ if (str[0] === "v" && str.startsWith("var(")) {
37
+ str = str.slice(6, str.length - 1);
38
+ }
39
+ var hash = 0;
40
+ var valids = "";
41
+ var added = 0;
42
+ var len = str.length;
43
+ for (var i = 0; i < len; i++) {
44
+ if (hashMin !== "strict" && added <= hashMin) {
45
+ var char = str.charCodeAt(i);
46
+ if (char === 46) {
47
+ valids += "--";
48
+ continue;
49
+ }
50
+ if (isValidCSSCharCode(char)) {
51
+ added++;
52
+ valids += str[i];
53
+ continue;
54
+ }
55
+ }
56
+ hash = hashChar(hash, str[i]);
57
+ }
58
+ var res = valids + (hash ? Math.abs(hash) : "");
59
+ if (cacheSize > 1e4) {
60
+ cache.clear();
61
+ cacheSize = 0;
62
+ }
63
+ cache.set(cacheKey, res);
64
+ cacheSize++;
65
+ return res;
66
+ };
67
+ var hashChar = function(hash, c) {
68
+ return Math.imul(31, hash) + c.charCodeAt(0) | 0;
69
+ };
70
+ function isValidCSSCharCode(code) {
71
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95 || code === 45 || code >= 48 && code <= 57;
72
+ }
@@ -1,86 +1,74 @@
1
1
  "use strict";
2
2
 
3
+
3
4
  var __defProp = Object.defineProperty;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  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, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
23
- value: true
24
- }), mod);
23
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
24
  var index_exports = {};
26
- __export(index_exports, {
27
- simpleHash: () => simpleHash
28
- });
25
+ __export(index_exports, { simpleHash: () => simpleHash });
29
26
  module.exports = __toCommonJS(index_exports);
30
- var cache = /* @__PURE__ */new Map();
27
+ var cache = /* @__PURE__ */ new Map();
31
28
  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;
56
- }
57
- }
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;
29
+ var simpleHash = function(strIn) {
30
+ var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;
31
+ var cacheKey = `${hashMin}:${strIn}`;
32
+ if (cache.has(cacheKey)) {
33
+ return cache.get(cacheKey);
34
+ }
35
+ var str = strIn;
36
+ if (str[0] === "v" && str.startsWith("var(")) {
37
+ str = str.slice(6, str.length - 1);
38
+ }
39
+ var hash = 0;
40
+ var valids = "";
41
+ var added = 0;
42
+ var len = str.length;
43
+ for (var i = 0; i < len; i++) {
44
+ if (hashMin !== "strict" && added <= hashMin) {
45
+ var char = str.charCodeAt(i);
46
+ if (char === 46) {
47
+ valids += "--";
48
+ continue;
49
+ }
50
+ if (isValidCSSCharCode(char)) {
51
+ added++;
52
+ valids += str[i];
53
+ continue;
54
+ }
55
+ }
56
+ hash = hashChar(hash, str[i]);
57
+ }
58
+ var res = valids + (hash ? Math.abs(hash) : "");
59
+ if (cacheSize > 1e4) {
60
+ cache.clear();
61
+ cacheSize = 0;
62
+ }
63
+ cache.set(cacheKey, res);
64
+ cacheSize++;
65
+ return res;
68
66
  };
69
- var hashChar = function (hash, c) {
70
- return Math.imul(31, hash) + c.charCodeAt(0) | 0;
67
+ var hashChar = function(hash, c) {
68
+ return Math.imul(31, hash) + c.charCodeAt(0) | 0;
71
69
  };
72
70
  function isValidCSSCharCode(code) {
73
- return (
74
- // A-Z
75
- code >= 65 && code <= 90 ||
76
- // a-z
77
- code >= 97 && code <= 122 ||
78
- // _
79
- code === 95 ||
80
- // -
81
- code === 45 ||
82
- // 0-9
83
- code >= 48 && code <= 57
84
- );
71
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95 || code === 45 || code >= 48 && code <= 57;
85
72
  }
73
+
86
74
  //# sourceMappingURL=index.native.js.map
@@ -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":";;;;;;;;;;;;;;;;;;;;;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,CAAAC,UAAA;IAEAD,GAAI,GAAAA,GAAO,CAAAE,KAAA,IAAAF,GAAA,CAAAH,MAAA;EACX;EACA,IAAIM,IAAA,IAAQ;EACZ,IAAAC,MAAM,GAAM;EAEZ,IAAAC,KAAS,IAAI;EACX,IAAAC,GAAI,GAAAN,GAAA,CAAAH,MAAY;EACd,SAAAU,CAAM,MAAAA,CAAO,GAAAD,GAAI,EAAAC,CAAA;IACjB,IAAAZ,OAAI,KAAS,QAAI,IAAAU,KAAA,IAAAV,OAAA;MACf,IAAAa,IAAA,GAAAR,GAAU,CAAAS,UAAA,CAAAF,CAAA;MACV,IAAAC,IAAA;QACFJ,MAAA;QACA;MACE;MACA,IAAAM,kBAAe,CAAAF,IAAA;QACfH,KAAA;QACFD,MAAA,IAAAJ,GAAA,CAAAO,CAAA;QACF;MACA;IACF;IAEAJ,IAAM,GAAAQ,QAAM,CAAAR,IAAU,EAAAH,GAAA,CAAAO,CAAO;EAE7B;EACE,IAAAK,GAAA,GAAMR,MAAM,IAAAD,IAAA,GAAAU,IAAA,CAAAC,GAAA,CAAAX,IAAA;EACZ,IAAAV,SAAA,GAAY;IACdF,KAAA,CAAAwB,KAAA;IAEAtB,SAAU;EACV;EAEAF,KAAA,CAAAyB,GAAO,CAAAtB,KAAA,EAAAkB,GAAA;EACTnB,SAAA;EAEA,OAAMmB,GAAA;AAEN;AACE,IAAAD,QAAA,YAAAA,CAAAR,IAAA,EAAAc,CAAA;EAAA,OAAAJ,IAAA,CAAAK,IAAA,KAAAf,IAAA,IAAAc,CAAA,CAAAR,UAAA;AAAA;AAEyB,SAEtBC,kBAAsBA,CAAAS,IAAA;EAAA;IAIvB;IAECA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;IAAA;IAAAA,IAAA,UAAAA,IAAA;IAAA;IAE3BA,IAAA;IAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\n__export(index_exports, {\n simpleHash: () => simpleHash\n});\nmodule.exports = __toCommonJS(index_exports);\nvar cache = /* @__PURE__ */ new Map();\nvar cacheSize = 0;\nvar simpleHash = function(strIn) {\n var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;\n var cacheKey = `${hashMin}:${strIn}`;\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n var str = strIn;\n if (str[0] === \"v\" && str.startsWith(\"var(\")) {\n str = str.slice(6, str.length - 1);\n }\n var hash = 0;\n var valids = \"\";\n var added = 0;\n var len = str.length;\n for (var i = 0; i < len; i++) {\n if (hashMin !== \"strict\" && added <= hashMin) {\n var 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 var res = valids + (hash ? Math.abs(hash) : \"\");\n if (cacheSize > 1e4) {\n cache.clear();\n cacheSize = 0;\n }\n cache.set(cacheKey, res);\n cacheSize++;\n return res;\n};\nvar hashChar = function(hash, c) {\n return Math.imul(31, hash) + c.charCodeAt(0) | 0;\n};\nfunction isValidCSSCharCode(code) {\n return (\n // A-Z\n code >= 65 && code <= 90 || // a-z\n code >= 97 && code <= 122 || // _\n code === 95 || // -\n code === 45 || // 0-9\n code >= 48 && code <= 57\n );\n}\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,SAAS,eAAe,EACtB,kBAAkB,WACpB,CAAC;AACD,OAAO,UAAU,aAAa,aAAa;AAC3C,IAAI,wBAAwB,IAAI,IAAI;AACpC,IAAI,YAAY;AAChB,IAAI,aAAa,SAAS,OAAO;CAC/B,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAC/E,IAAI,WAAW,GAAG,QAAQ,GAAG;CAC7B,IAAI,MAAM,IAAI,QAAQ,GAAG;EACvB,OAAO,MAAM,IAAI,QAAQ;CAC3B;CACA,IAAI,MAAM;CACV,IAAI,IAAI,OAAO,OAAO,IAAI,WAAW,MAAM,GAAG;EAC5C,MAAM,IAAI,MAAM,GAAG,IAAI,SAAS,CAAC;CACnC;CACA,IAAI,OAAO;CACX,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,IAAI,MAAM,IAAI;CACd,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK;EAC5B,IAAI,YAAY,YAAY,SAAS,SAAS;GAC5C,IAAI,OAAO,IAAI,WAAW,CAAC;GAC3B,IAAI,SAAS,IAAI;IACf,UAAU;IACV;GACF;GACA,IAAI,mBAAmB,IAAI,GAAG;IAC5B;IACA,UAAU,IAAI;IACd;GACF;EACF;EACA,OAAO,SAAS,MAAM,IAAI,EAAE;CAC9B;CACA,IAAI,MAAM,UAAU,OAAO,KAAK,IAAI,IAAI,IAAI;CAC5C,IAAI,YAAY,KAAK;EACnB,MAAM,MAAM;EACZ,YAAY;CACd;CACA,MAAM,IAAI,UAAU,GAAG;CACvB;CACA,OAAO;AACT;AACA,IAAI,WAAW,SAAS,MAAM,GAAG;CAC/B,OAAO,KAAK,KAAK,IAAI,IAAI,IAAI,EAAE,WAAW,CAAC,IAAI;AACjD;AACA,SAAS,mBAAmB,MAAM;CAChC,OAEE,QAAQ,MAAM,QAAQ,MACtB,QAAQ,MAAM,QAAQ,OACtB,SAAS,MACT,SAAS,MACT,QAAQ,MAAM,QAAQ;AAE1B"}
package/dist/esm/index.js CHANGED
@@ -1,55 +1,46 @@
1
- const cache = /* @__PURE__ */new Map();
1
+ const cache = /* @__PURE__ */ new Map();
2
2
  let cacheSize = 0;
3
3
  const simpleHash = (strIn, hashMin = 10) => {
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;
26
- }
27
- }
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;
4
+ const cacheKey = `${hashMin}:${strIn}`;
5
+ if (cache.has(cacheKey)) {
6
+ return cache.get(cacheKey);
7
+ }
8
+ let str = strIn;
9
+ if (str[0] === "v" && str.startsWith("var(")) {
10
+ str = str.slice(6, str.length - 1);
11
+ }
12
+ let hash = 0;
13
+ let valids = "";
14
+ let added = 0;
15
+ const len = str.length;
16
+ for (let i = 0; i < len; i++) {
17
+ if (hashMin !== "strict" && added <= hashMin) {
18
+ const 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;
27
+ }
28
+ }
29
+ hash = hashChar(hash, str[i]);
30
+ }
31
+ const res = valids + (hash ? Math.abs(hash) : "");
32
+ if (cacheSize > 1e4) {
33
+ cache.clear();
34
+ cacheSize = 0;
35
+ }
36
+ cache.set(cacheKey, res);
37
+ cacheSize++;
38
+ return res;
38
39
  };
39
40
  const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
40
41
  function isValidCSSCharCode(code) {
41
- return (
42
- // A-Z
43
- code >= 65 && code <= 90 ||
44
- // a-z
45
- code >= 97 && code <= 122 ||
46
- // _
47
- code === 95 ||
48
- // -
49
- code === 45 ||
50
- // 0-9
51
- code >= 48 && code <= 57
52
- );
42
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95 || code === 45 || code >= 48 && code <= 57;
53
43
  }
44
+
54
45
  export { simpleHash };
55
46
  //# sourceMappingURL=index.js.map
@@ -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;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;MACF;MACA,IAAIM,kBAAA,CAAmBF,IAAI,GAAG;QAC5BH,KAAA;QACAD,MAAA,IAAUL,GAAA,CAAIQ,CAAC;QACf;MACF;IACF;IACAJ,IAAA,GAAOQ,QAAA,CAASR,IAAA,EAAMJ,GAAA,CAAIQ,CAAC,CAAC;EAC9B;EAEA,MAAMK,GAAA,GAAMR,MAAA,IAAUD,IAAA,GAAOU,IAAA,CAAKC,GAAA,CAAIX,IAAI,IAAI;EAE9C,IAAIV,SAAA,GAAY,KAAQ;IACtBF,KAAA,CAAMwB,KAAA,CAAM;IACZtB,SAAA,GAAY;EACd;EAEAF,KAAA,CAAMyB,GAAA,CAAIrB,KAAA,EAAOiB,GAAG;EACpBnB,SAAA;EAEA,OAAOmB,GAAA;AACT;AAEA,MAAMD,QAAA,GAAWA,CAACR,IAAA,EAAcc,CAAA,KAAeJ,IAAA,CAAKK,IAAA,CAAK,IAAIf,IAAI,IAAIc,CAAA,CAAER,UAAA,CAAW,CAAC,IAAK;AAExF,SAASC,mBAAmBS,IAAA,EAAc;EACxC;IAAA;IAEGA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;IAAA;IAEtBA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;IAAA;IAEvBA,IAAA,KAAS;IAAA;IAETA,IAAA,KAAS;IAAA;IAERA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;EAAA;AAE3B","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["const cache = /* @__PURE__ */ new Map();\nlet cacheSize = 0;\nconst simpleHash = (strIn, hashMin = 10) => {\n const cacheKey = `${hashMin}:${strIn}`;\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n let str = strIn;\n if (str[0] === \"v\" && str.startsWith(\"var(\")) {\n str = str.slice(6, str.length - 1);\n }\n let hash = 0;\n let valids = \"\";\n let added = 0;\n const len = str.length;\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 const res = valids + (hash ? Math.abs(hash) : \"\");\n if (cacheSize > 1e4) {\n cache.clear();\n cacheSize = 0;\n }\n cache.set(cacheKey, res);\n cacheSize++;\n return res;\n};\nconst hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;\nfunction isValidCSSCharCode(code) {\n return (\n // A-Z\n code >= 65 && code <= 90 || // a-z\n code >= 97 && code <= 122 || // _\n code === 95 || // -\n code === 45 || // 0-9\n code >= 48 && code <= 57\n );\n}\nexport {\n simpleHash\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";AAAA,MAAM,wBAAwB,IAAI,IAAI;AACtC,IAAI,YAAY;AAChB,MAAM,cAAc,OAAO,UAAU,OAAO;CAC1C,MAAM,WAAW,GAAG,QAAQ,GAAG;CAC/B,IAAI,MAAM,IAAI,QAAQ,GAAG;EACvB,OAAO,MAAM,IAAI,QAAQ;CAC3B;CACA,IAAI,MAAM;CACV,IAAI,IAAI,OAAO,OAAO,IAAI,WAAW,MAAM,GAAG;EAC5C,MAAM,IAAI,MAAM,GAAG,IAAI,SAAS,CAAC;CACnC;CACA,IAAI,OAAO;CACX,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,MAAM,MAAM,IAAI;CAChB,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK;EAC5B,IAAI,YAAY,YAAY,SAAS,SAAS;GAC5C,MAAM,OAAO,IAAI,WAAW,CAAC;GAC7B,IAAI,SAAS,IAAI;IACf,UAAU;IACV;GACF;GACA,IAAI,mBAAmB,IAAI,GAAG;IAC5B;IACA,UAAU,IAAI;IACd;GACF;EACF;EACA,OAAO,SAAS,MAAM,IAAI,EAAE;CAC9B;CACA,MAAM,MAAM,UAAU,OAAO,KAAK,IAAI,IAAI,IAAI;CAC9C,IAAI,YAAY,KAAK;EACnB,MAAM,MAAM;EACZ,YAAY;CACd;CACA,MAAM,IAAI,UAAU,GAAG;CACvB;CACA,OAAO;AACT;AACA,MAAM,YAAY,MAAM,MAAM,KAAK,KAAK,IAAI,IAAI,IAAI,EAAE,WAAW,CAAC,IAAI;AACtE,SAAS,mBAAmB,MAAM;CAChC,OAEE,QAAQ,MAAM,QAAQ,MACtB,QAAQ,MAAM,QAAQ,OACtB,SAAS,MACT,SAAS,MACT,QAAQ,MAAM,QAAQ;AAE1B"}
@@ -1,55 +1,46 @@
1
- const cache = /* @__PURE__ */new Map();
1
+ const cache = /* @__PURE__ */ new Map();
2
2
  let cacheSize = 0;
3
3
  const simpleHash = (strIn, hashMin = 10) => {
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;
26
- }
27
- }
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;
4
+ const cacheKey = `${hashMin}:${strIn}`;
5
+ if (cache.has(cacheKey)) {
6
+ return cache.get(cacheKey);
7
+ }
8
+ let str = strIn;
9
+ if (str[0] === "v" && str.startsWith("var(")) {
10
+ str = str.slice(6, str.length - 1);
11
+ }
12
+ let hash = 0;
13
+ let valids = "";
14
+ let added = 0;
15
+ const len = str.length;
16
+ for (let i = 0; i < len; i++) {
17
+ if (hashMin !== "strict" && added <= hashMin) {
18
+ const 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;
27
+ }
28
+ }
29
+ hash = hashChar(hash, str[i]);
30
+ }
31
+ const res = valids + (hash ? Math.abs(hash) : "");
32
+ if (cacheSize > 1e4) {
33
+ cache.clear();
34
+ cacheSize = 0;
35
+ }
36
+ cache.set(cacheKey, res);
37
+ cacheSize++;
38
+ return res;
38
39
  };
39
40
  const hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;
40
41
  function isValidCSSCharCode(code) {
41
- return (
42
- // A-Z
43
- code >= 65 && code <= 90 ||
44
- // a-z
45
- code >= 97 && code <= 122 ||
46
- // _
47
- code === 95 ||
48
- // -
49
- code === 45 ||
50
- // 0-9
51
- code >= 48 && code <= 57
52
- );
42
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95 || code === 45 || code >= 48 && code <= 57;
53
43
  }
44
+
54
45
  export { simpleHash };
55
46
  //# sourceMappingURL=index.mjs.map
@@ -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;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;MACF;MACA,IAAIM,kBAAA,CAAmBF,IAAI,GAAG;QAC5BH,KAAA;QACAD,MAAA,IAAUL,GAAA,CAAIQ,CAAC;QACf;MACF;IACF;IACAJ,IAAA,GAAOQ,QAAA,CAASR,IAAA,EAAMJ,GAAA,CAAIQ,CAAC,CAAC;EAC9B;EAEA,MAAMK,GAAA,GAAMR,MAAA,IAAUD,IAAA,GAAOU,IAAA,CAAKC,GAAA,CAAIX,IAAI,IAAI;EAE9C,IAAIV,SAAA,GAAY,KAAQ;IACtBF,KAAA,CAAMwB,KAAA,CAAM;IACZtB,SAAA,GAAY;EACd;EAEAF,KAAA,CAAMyB,GAAA,CAAIrB,KAAA,EAAOiB,GAAG;EACpBnB,SAAA;EAEA,OAAOmB,GAAA;AACT;AAEA,MAAMD,QAAA,GAAWA,CAACR,IAAA,EAAcc,CAAA,KAAeJ,IAAA,CAAKK,IAAA,CAAK,IAAIf,IAAI,IAAIc,CAAA,CAAER,UAAA,CAAW,CAAC,IAAK;AAExF,SAASC,mBAAmBS,IAAA,EAAc;EACxC;IAAA;IAEGA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;IAAA;IAEtBA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;IAAA;IAEvBA,IAAA,KAAS;IAAA;IAETA,IAAA,KAAS;IAAA;IAERA,IAAA,IAAQ,MAAMA,IAAA,IAAQ;EAAA;AAE3B","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["esm/index.js"],"sourcesContent":["const cache = /* @__PURE__ */ new Map();\nlet cacheSize = 0;\nconst simpleHash = (strIn, hashMin = 10) => {\n const cacheKey = `${hashMin}:${strIn}`;\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n let str = strIn;\n if (str[0] === \"v\" && str.startsWith(\"var(\")) {\n str = str.slice(6, str.length - 1);\n }\n let hash = 0;\n let valids = \"\";\n let added = 0;\n const len = str.length;\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 const res = valids + (hash ? Math.abs(hash) : \"\");\n if (cacheSize > 1e4) {\n cache.clear();\n cacheSize = 0;\n }\n cache.set(cacheKey, res);\n cacheSize++;\n return res;\n};\nconst hashChar = (hash, c) => Math.imul(31, hash) + c.charCodeAt(0) | 0;\nfunction isValidCSSCharCode(code) {\n return (\n // A-Z\n code >= 65 && code <= 90 || // a-z\n code >= 97 && code <= 122 || // _\n code === 95 || // -\n code === 45 || // 0-9\n code >= 48 && code <= 57\n );\n}\nexport {\n simpleHash\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";AAAA,MAAM,wBAAwB,IAAI,IAAI;AACtC,IAAI,YAAY;AAChB,MAAM,cAAc,OAAO,UAAU,OAAO;CAC1C,MAAM,WAAW,GAAG,QAAQ,GAAG;CAC/B,IAAI,MAAM,IAAI,QAAQ,GAAG;EACvB,OAAO,MAAM,IAAI,QAAQ;CAC3B;CACA,IAAI,MAAM;CACV,IAAI,IAAI,OAAO,OAAO,IAAI,WAAW,MAAM,GAAG;EAC5C,MAAM,IAAI,MAAM,GAAG,IAAI,SAAS,CAAC;CACnC;CACA,IAAI,OAAO;CACX,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,MAAM,MAAM,IAAI;CAChB,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK;EAC5B,IAAI,YAAY,YAAY,SAAS,SAAS;GAC5C,MAAM,OAAO,IAAI,WAAW,CAAC;GAC7B,IAAI,SAAS,IAAI;IACf,UAAU;IACV;GACF;GACA,IAAI,mBAAmB,IAAI,GAAG;IAC5B;IACA,UAAU,IAAI;IACd;GACF;EACF;EACA,OAAO,SAAS,MAAM,IAAI,EAAE;CAC9B;CACA,MAAM,MAAM,UAAU,OAAO,KAAK,IAAI,IAAI,IAAI;CAC9C,IAAI,YAAY,KAAK;EACnB,MAAM,MAAM;EACZ,YAAY;CACd;CACA,MAAM,IAAI,UAAU,GAAG;CACvB;CACA,OAAO;AACT;AACA,MAAM,YAAY,MAAM,MAAM,KAAK,KAAK,IAAI,IAAI,IAAI,EAAE,WAAW,CAAC,IAAI;AACtE,SAAS,mBAAmB,MAAM;CAChC,OAEE,QAAQ,MAAM,QAAQ,MACtB,QAAQ,MAAM,QAAQ,OACtB,SAAS,MACT,SAAS,MACT,QAAQ,MAAM,QAAQ;AAE1B"}
@@ -1,58 +1,49 @@
1
- var cache = /* @__PURE__ */new Map();
1
+ var cache = /* @__PURE__ */ new Map();
2
2
  var cacheSize = 0;
3
- 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;
27
- }
28
- }
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;
3
+ var simpleHash = function(strIn) {
4
+ var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;
5
+ var cacheKey = `${hashMin}:${strIn}`;
6
+ if (cache.has(cacheKey)) {
7
+ return cache.get(cacheKey);
8
+ }
9
+ var str = strIn;
10
+ if (str[0] === "v" && str.startsWith("var(")) {
11
+ str = str.slice(6, str.length - 1);
12
+ }
13
+ var hash = 0;
14
+ var valids = "";
15
+ var added = 0;
16
+ var len = str.length;
17
+ for (var i = 0; i < len; i++) {
18
+ if (hashMin !== "strict" && added <= hashMin) {
19
+ var char = str.charCodeAt(i);
20
+ if (char === 46) {
21
+ valids += "--";
22
+ continue;
23
+ }
24
+ if (isValidCSSCharCode(char)) {
25
+ added++;
26
+ valids += str[i];
27
+ continue;
28
+ }
29
+ }
30
+ hash = hashChar(hash, str[i]);
31
+ }
32
+ var res = valids + (hash ? Math.abs(hash) : "");
33
+ if (cacheSize > 1e4) {
34
+ cache.clear();
35
+ cacheSize = 0;
36
+ }
37
+ cache.set(cacheKey, res);
38
+ cacheSize++;
39
+ return res;
39
40
  };
40
- var hashChar = function (hash, c) {
41
- return Math.imul(31, hash) + c.charCodeAt(0) | 0;
41
+ var hashChar = function(hash, c) {
42
+ return Math.imul(31, hash) + c.charCodeAt(0) | 0;
42
43
  };
43
44
  function isValidCSSCharCode(code) {
44
- return (
45
- // A-Z
46
- code >= 65 && code <= 90 ||
47
- // a-z
48
- code >= 97 && code <= 122 ||
49
- // _
50
- code === 95 ||
51
- // -
52
- code === 45 ||
53
- // 0-9
54
- code >= 48 && code <= 57
55
- );
45
+ return code >= 65 && code <= 90 || code >= 97 && code <= 122 || code === 95 || code === 45 || code >= 48 && code <= 57;
56
46
  }
47
+
57
48
  export { simpleHash };
58
49
  //# sourceMappingURL=index.native.js.map
@@ -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;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":[]}
1
+ {"version":3,"file":"index.native.js","names":[],"sources":["esm/index.native.js"],"sourcesContent":["var cache = /* @__PURE__ */ new Map();\nvar cacheSize = 0;\nvar simpleHash = function(strIn) {\n var hashMin = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 10;\n var cacheKey = `${hashMin}:${strIn}`;\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey);\n }\n var str = strIn;\n if (str[0] === \"v\" && str.startsWith(\"var(\")) {\n str = str.slice(6, str.length - 1);\n }\n var hash = 0;\n var valids = \"\";\n var added = 0;\n var len = str.length;\n for (var i = 0; i < len; i++) {\n if (hashMin !== \"strict\" && added <= hashMin) {\n var 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 var res = valids + (hash ? Math.abs(hash) : \"\");\n if (cacheSize > 1e4) {\n cache.clear();\n cacheSize = 0;\n }\n cache.set(cacheKey, res);\n cacheSize++;\n return res;\n};\nvar hashChar = function(hash, c) {\n return Math.imul(31, hash) + c.charCodeAt(0) | 0;\n};\nfunction isValidCSSCharCode(code) {\n return (\n // A-Z\n code >= 65 && code <= 90 || // a-z\n code >= 97 && code <= 122 || // _\n code === 95 || // -\n code === 45 || // 0-9\n code >= 48 && code <= 57\n );\n}\nexport {\n simpleHash\n};\n//# sourceMappingURL=index.js.map\n"],"mappings":";AAAA,IAAI,wBAAwB,IAAI,IAAI;AACpC,IAAI,YAAY;AAChB,IAAI,aAAa,SAAS,OAAO;CAC/B,IAAI,UAAU,UAAU,SAAS,KAAK,UAAU,OAAO,KAAK,IAAI,UAAU,KAAK;CAC/E,IAAI,WAAW,GAAG,QAAQ,GAAG;CAC7B,IAAI,MAAM,IAAI,QAAQ,GAAG;EACvB,OAAO,MAAM,IAAI,QAAQ;CAC3B;CACA,IAAI,MAAM;CACV,IAAI,IAAI,OAAO,OAAO,IAAI,WAAW,MAAM,GAAG;EAC5C,MAAM,IAAI,MAAM,GAAG,IAAI,SAAS,CAAC;CACnC;CACA,IAAI,OAAO;CACX,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,IAAI,MAAM,IAAI;CACd,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK;EAC5B,IAAI,YAAY,YAAY,SAAS,SAAS;GAC5C,IAAI,OAAO,IAAI,WAAW,CAAC;GAC3B,IAAI,SAAS,IAAI;IACf,UAAU;IACV;GACF;GACA,IAAI,mBAAmB,IAAI,GAAG;IAC5B;IACA,UAAU,IAAI;IACd;GACF;EACF;EACA,OAAO,SAAS,MAAM,IAAI,EAAE;CAC9B;CACA,IAAI,MAAM,UAAU,OAAO,KAAK,IAAI,IAAI,IAAI;CAC5C,IAAI,YAAY,KAAK;EACnB,MAAM,MAAM;EACZ,YAAY;CACd;CACA,MAAM,IAAI,UAAU,GAAG;CACvB;CACA,OAAO;AACT;AACA,IAAI,WAAW,SAAS,MAAM,GAAG;CAC/B,OAAO,KAAK,KAAK,IAAI,IAAI,IAAI,EAAE,WAAW,CAAC,IAAI;AACjD;AACA,SAAS,mBAAmB,MAAM;CAChC,OAEE,QAAQ,MAAM,QAAQ,MACtB,QAAQ,MAAM,QAAQ,OACtB,SAAS,MACT,SAAS,MACT,QAAQ,MAAM,QAAQ;AAE1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/simple-hash",
3
- "version": "2.7.6",
3
+ "version": "3.0.0-beta.637.1",
4
4
  "files": [
5
5
  "src",
6
6
  "types",
@@ -33,7 +33,7 @@
33
33
  "clean:build": "tamagui-build clean:build"
34
34
  },
35
35
  "devDependencies": {
36
- "@tamagui/build": "2.7.6"
36
+ "@tamagui/build": "3.0.0-beta.637.1"
37
37
  },
38
38
  "repository": {
39
39
  "type": "git",
package/src/index.ts CHANGED
@@ -2,8 +2,9 @@ const cache = new Map<string, string>()
2
2
  let cacheSize = 0
3
3
 
4
4
  export const simpleHash = (strIn: string, hashMin: number | 'strict' = 10): string => {
5
- if (cache.has(strIn)) {
6
- return cache.get(strIn)!
5
+ const cacheKey = `${hashMin}:${strIn}`
6
+ if (cache.has(cacheKey)) {
7
+ return cache.get(cacheKey)!
7
8
  }
8
9
 
9
10
  let str = strIn
@@ -41,7 +42,7 @@ export const simpleHash = (strIn: string, hashMin: number | 'strict' = 10): stri
41
42
  cacheSize = 0
42
43
  }
43
44
 
44
- cache.set(strIn, res)
45
+ cache.set(cacheKey, res)
45
46
  cacheSize++
46
47
 
47
48
  return res
@@ -6,6 +6,6 @@
6
6
  ],
7
7
  "version": 3,
8
8
  "sourcesContent": [
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
+ "const cache = new Map<string, string>()\nlet cacheSize = 0\n\nexport const simpleHash = (strIn: string, hashMin: number | 'strict' = 10): string => {\n const cacheKey = `${hashMin}:${strIn}`\n if (cache.has(cacheKey)) {\n return cache.get(cacheKey)!\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(cacheKey, 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"
10
10
  ]
11
11
  }