@scalar/helpers 0.1.1 → 0.1.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @scalar/helpers
2
2
 
3
+ ## 0.1.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#7387](https://github.com/scalar/scalar/pull/7387) [`bfd814a`](https://github.com/scalar/scalar/commit/bfd814a4219660face190041cc4845182b56ab03) Thanks [@geoffgscott](https://github.com/geoffgscott)! - hotfix: patch exports from build tooling bug
8
+
9
+ - [#7416](https://github.com/scalar/scalar/pull/7416) [`86f028d`](https://github.com/scalar/scalar/commit/86f028deb0b456f923edd261f5f4b0fa9b616b7d) Thanks [@amritk](https://github.com/amritk)! - feat: add update method to client v2
10
+
11
+ ## 0.1.2
12
+
13
+ ### Patch Changes
14
+
15
+ - [#7392](https://github.com/scalar/scalar/pull/7392) [`d86f1d6`](https://github.com/scalar/scalar/commit/d86f1d6911ecbca70b011a2a0efb6d6e0eca59bb) Thanks [@amritk](https://github.com/amritk)! - fix: move away from wasm hashing algo
16
+
17
+ - [#7348](https://github.com/scalar/scalar/pull/7348) [`cded2d6`](https://github.com/scalar/scalar/commit/cded2d6c087418c3c44731d344d0827a87b78b74) Thanks [@hwkr](https://github.com/hwkr)! - feat(components): add ScalarWrappingText component
18
+
3
19
  ## 0.1.1
4
20
 
5
21
  ### Patch Changes
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Validates that a key is safe to use and does not pose a prototype pollution risk.
3
+ * Throws an error if a dangerous key is detected.
4
+ *
5
+ * @param key - The key to validate
6
+ * @param context - Optional context string to help identify where the validation failed
7
+ * @throws {Error} If the key matches a known prototype pollution vector
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * preventPollution('__proto__') // throws Error
12
+ * preventPollution('safeName') // passes
13
+ * preventPollution('constructor', 'operation update') // throws Error with context
14
+ * ```
15
+ */
16
+ export declare const preventPollution: (key: string, context?: string) => void;
17
+ //# sourceMappingURL=prevent-pollution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prevent-pollution.d.ts","sourceRoot":"","sources":["../../src/object/prevent-pollution.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,KAAG,IAQhE,CAAA"}
@@ -0,0 +1,11 @@
1
+ const PROTOTYPE_POLLUTION_KEYS = ["__proto__", "prototype", "constructor"];
2
+ const preventPollution = (key, context) => {
3
+ if (PROTOTYPE_POLLUTION_KEYS.includes(key)) {
4
+ const errorMessage = context ? `Prototype pollution key detected: "${key}" in ${context}` : `Prototype pollution key detected: "${key}"`;
5
+ throw new Error(errorMessage);
6
+ }
7
+ };
8
+ export {
9
+ preventPollution
10
+ };
11
+ //# sourceMappingURL=prevent-pollution.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/object/prevent-pollution.ts"],
4
+ "sourcesContent": ["/**\n * List of dangerous keys that can be used for prototype pollution attacks.\n * These keys should never be used as property names in dynamic object operations.\n */\nconst PROTOTYPE_POLLUTION_KEYS = ['__proto__', 'prototype', 'constructor'] as const\n\n/**\n * Validates that a key is safe to use and does not pose a prototype pollution risk.\n * Throws an error if a dangerous key is detected.\n *\n * @param key - The key to validate\n * @param context - Optional context string to help identify where the validation failed\n * @throws {Error} If the key matches a known prototype pollution vector\n *\n * @example\n * ```ts\n * preventPollution('__proto__') // throws Error\n * preventPollution('safeName') // passes\n * preventPollution('constructor', 'operation update') // throws Error with context\n * ```\n */\nexport const preventPollution = (key: string, context?: string): void => {\n if (PROTOTYPE_POLLUTION_KEYS.includes(key as never)) {\n const errorMessage = context\n ? `Prototype pollution key detected: \"${key}\" in ${context}`\n : `Prototype pollution key detected: \"${key}\"`\n\n throw new Error(errorMessage)\n }\n}\n"],
5
+ "mappings": "AAIA,MAAM,2BAA2B,CAAC,aAAa,aAAa,aAAa;AAiBlE,MAAM,mBAAmB,CAAC,KAAa,YAA2B;AACvE,MAAI,yBAAyB,SAAS,GAAY,GAAG;AACnD,UAAM,eAAe,UACjB,sCAAsC,GAAG,QAAQ,OAAO,KACxD,sCAAsC,GAAG;AAE7C,UAAM,IAAI,MAAM,YAAY;AAAA,EAC9B;AACF;",
6
+ "names": []
7
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Simple 32 bit non-secure hash from a string input
3
3
  *
4
- * @deprecated Use generateHash from @scalar/json-magic/helpers/generate-hash instead
4
+ * @deprecated Please use generateHash from ./generate-hash.ts instead
5
5
  *
6
6
  * @see https://stackoverflow.com/a/7616484/1624255
7
7
  */
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/string/create-hash.ts"],
4
- "sourcesContent": ["/**\n * Simple 32 bit non-secure hash from a string input\n *\n * @deprecated Use generateHash from @scalar/json-magic/helpers/generate-hash instead\n *\n * @see https://stackoverflow.com/a/7616484/1624255\n */\nexport const createHash = (input?: string): number => {\n let chr = 0\n let hash = 0\n let i = 0\n\n if (!input?.length) {\n return hash\n }\n\n for (i = 0; i < input.length; i++) {\n chr = input.charCodeAt(i)\n hash = (hash << 5) - hash + chr\n hash |= 0 // Convert to 32bit integer\n }\n return hash\n}\n"],
4
+ "sourcesContent": ["/**\n * Simple 32 bit non-secure hash from a string input\n *\n * @deprecated Please use generateHash from ./generate-hash.ts instead\n *\n * @see https://stackoverflow.com/a/7616484/1624255\n */\nexport const createHash = (input?: string): number => {\n let chr = 0\n let hash = 0\n let i = 0\n\n if (!input?.length) {\n return hash\n }\n\n for (i = 0; i < input.length; i++) {\n chr = input.charCodeAt(i)\n hash = (hash << 5) - hash + chr\n hash |= 0 // Convert to 32bit integer\n }\n return hash\n}\n"],
5
5
  "mappings": "AAOO,MAAM,aAAa,CAAC,UAA2B;AACpD,MAAI,MAAM;AACV,MAAI,OAAO;AACX,MAAI,IAAI;AAER,MAAI,CAAC,OAAO,QAAQ;AAClB,WAAO;AAAA,EACT;AAEA,OAAK,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;AACjC,UAAM,MAAM,WAAW,CAAC;AACxB,YAAQ,QAAQ,KAAK,OAAO;AAC5B,YAAQ;AAAA,EACV;AACA,SAAO;AACT;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * MurmurHash3 64-bit (x64_128) implementation
3
+ *
4
+ * Generate a hash from a string using the MurmurHash3 algorithm
5
+ * Provides 128-bit hash output with excellent speed and distribution
6
+ *
7
+ * We had to move away from xxhash-wasm since it was causing issues with content security policy (CSP) violations.
8
+ *
9
+ * We cannot use crypto.subtle because it is only available in secure contexts (HTTPS) or on localhost.
10
+ *
11
+ * @param input - The string to hash
12
+ * @returns The hash of the input string
13
+ */
14
+ export declare const generateHash: (input: string) => string;
15
+ //# sourceMappingURL=generate-hash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-hash.d.ts","sourceRoot":"","sources":["../../src/string/generate-hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,MA4K5C,CAAA"}
@@ -0,0 +1,130 @@
1
+ const generateHash = (input) => {
2
+ const seed = 0;
3
+ let h1 = seed;
4
+ let h2 = seed;
5
+ const len = input.length;
6
+ const remainder = len & 15;
7
+ const bytes = len - remainder;
8
+ const c1 = 2277735313;
9
+ const c2 = 1291169091;
10
+ const c3 = 1390208809;
11
+ const c4 = 944331445;
12
+ for (let i = 0; i < bytes; i += 16) {
13
+ let k1 = input.charCodeAt(i) & 255 | (input.charCodeAt(i + 1) & 255) << 8 | (input.charCodeAt(i + 2) & 255) << 16 | (input.charCodeAt(i + 3) & 255) << 24;
14
+ let k2 = input.charCodeAt(i + 4) & 255 | (input.charCodeAt(i + 5) & 255) << 8 | (input.charCodeAt(i + 6) & 255) << 16 | (input.charCodeAt(i + 7) & 255) << 24;
15
+ let k3 = input.charCodeAt(i + 8) & 255 | (input.charCodeAt(i + 9) & 255) << 8 | (input.charCodeAt(i + 10) & 255) << 16 | (input.charCodeAt(i + 11) & 255) << 24;
16
+ let k4 = input.charCodeAt(i + 12) & 255 | (input.charCodeAt(i + 13) & 255) << 8 | (input.charCodeAt(i + 14) & 255) << 16 | (input.charCodeAt(i + 15) & 255) << 24;
17
+ k1 = Math.imul(k1, c1);
18
+ k1 = k1 << 15 | k1 >>> 17;
19
+ k1 = Math.imul(k1, c2);
20
+ h1 ^= k1;
21
+ h1 = h1 << 13 | h1 >>> 19;
22
+ h1 = Math.imul(h1, 5) + 3864292196;
23
+ k2 = Math.imul(k2, c2);
24
+ k2 = k2 << 16 | k2 >>> 16;
25
+ k2 = Math.imul(k2, c3);
26
+ h2 ^= k2;
27
+ h2 = h2 << 17 | h2 >>> 15;
28
+ h2 = Math.imul(h2, 5) + 461845907;
29
+ k3 = Math.imul(k3, c3);
30
+ k3 = k3 << 17 | k3 >>> 15;
31
+ k3 = Math.imul(k3, c4);
32
+ h1 ^= k3;
33
+ h1 = h1 << 15 | h1 >>> 17;
34
+ h1 = Math.imul(h1, 5) + 1390208809;
35
+ k4 = Math.imul(k4, c4);
36
+ k4 = k4 << 18 | k4 >>> 14;
37
+ k4 = Math.imul(k4, c1);
38
+ h2 ^= k4;
39
+ h2 = h2 << 13 | h2 >>> 19;
40
+ h2 = Math.imul(h2, 5) + 944331445;
41
+ }
42
+ if (remainder > 0) {
43
+ let k1 = 0;
44
+ let k2 = 0;
45
+ let k3 = 0;
46
+ let k4 = 0;
47
+ if (remainder >= 15) {
48
+ k4 ^= (input.charCodeAt(bytes + 14) & 255) << 16;
49
+ }
50
+ if (remainder >= 14) {
51
+ k4 ^= (input.charCodeAt(bytes + 13) & 255) << 8;
52
+ }
53
+ if (remainder >= 13) {
54
+ k4 ^= input.charCodeAt(bytes + 12) & 255;
55
+ k4 = Math.imul(k4, c4);
56
+ k4 = k4 << 18 | k4 >>> 14;
57
+ k4 = Math.imul(k4, c1);
58
+ h2 ^= k4;
59
+ }
60
+ if (remainder >= 12) {
61
+ k3 ^= (input.charCodeAt(bytes + 11) & 255) << 24;
62
+ }
63
+ if (remainder >= 11) {
64
+ k3 ^= (input.charCodeAt(bytes + 10) & 255) << 16;
65
+ }
66
+ if (remainder >= 10) {
67
+ k3 ^= (input.charCodeAt(bytes + 9) & 255) << 8;
68
+ }
69
+ if (remainder >= 9) {
70
+ k3 ^= input.charCodeAt(bytes + 8) & 255;
71
+ k3 = Math.imul(k3, c3);
72
+ k3 = k3 << 17 | k3 >>> 15;
73
+ k3 = Math.imul(k3, c4);
74
+ h1 ^= k3;
75
+ }
76
+ if (remainder >= 8) {
77
+ k2 ^= (input.charCodeAt(bytes + 7) & 255) << 24;
78
+ }
79
+ if (remainder >= 7) {
80
+ k2 ^= (input.charCodeAt(bytes + 6) & 255) << 16;
81
+ }
82
+ if (remainder >= 6) {
83
+ k2 ^= (input.charCodeAt(bytes + 5) & 255) << 8;
84
+ }
85
+ if (remainder >= 5) {
86
+ k2 ^= input.charCodeAt(bytes + 4) & 255;
87
+ k2 = Math.imul(k2, c2);
88
+ k2 = k2 << 16 | k2 >>> 16;
89
+ k2 = Math.imul(k2, c3);
90
+ h2 ^= k2;
91
+ }
92
+ if (remainder >= 4) {
93
+ k1 ^= (input.charCodeAt(bytes + 3) & 255) << 24;
94
+ }
95
+ if (remainder >= 3) {
96
+ k1 ^= (input.charCodeAt(bytes + 2) & 255) << 16;
97
+ }
98
+ if (remainder >= 2) {
99
+ k1 ^= (input.charCodeAt(bytes + 1) & 255) << 8;
100
+ }
101
+ if (remainder >= 1) {
102
+ k1 ^= input.charCodeAt(bytes) & 255;
103
+ k1 = Math.imul(k1, c1);
104
+ k1 = k1 << 15 | k1 >>> 17;
105
+ k1 = Math.imul(k1, c2);
106
+ h1 ^= k1;
107
+ }
108
+ }
109
+ h1 ^= len;
110
+ h2 ^= len;
111
+ h1 += h2;
112
+ h2 += h1;
113
+ h1 ^= h1 >>> 16;
114
+ h1 = Math.imul(h1, 2246822507);
115
+ h1 ^= h1 >>> 13;
116
+ h1 = Math.imul(h1, 3266489909);
117
+ h1 ^= h1 >>> 16;
118
+ h2 ^= h2 >>> 16;
119
+ h2 = Math.imul(h2, 2246822507);
120
+ h2 ^= h2 >>> 13;
121
+ h2 = Math.imul(h2, 3266489909);
122
+ h2 ^= h2 >>> 16;
123
+ h1 += h2;
124
+ h2 += h1;
125
+ return (h1 >>> 0).toString(16).padStart(8, "0") + (h2 >>> 0).toString(16).padStart(8, "0");
126
+ };
127
+ export {
128
+ generateHash
129
+ };
130
+ //# sourceMappingURL=generate-hash.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/string/generate-hash.ts"],
4
+ "sourcesContent": ["/**\n * MurmurHash3 64-bit (x64_128) implementation\n *\n * Generate a hash from a string using the MurmurHash3 algorithm\n * Provides 128-bit hash output with excellent speed and distribution\n *\n * We had to move away from xxhash-wasm since it was causing issues with content security policy (CSP) violations.\n *\n * We cannot use crypto.subtle because it is only available in secure contexts (HTTPS) or on localhost.\n *\n * @param input - The string to hash\n * @returns The hash of the input string\n */\nexport const generateHash = (input: string): string => {\n const seed = 0\n\n // Working with 64-bit values using pairs of 32-bit integers\n let h1 = seed\n let h2 = seed\n\n const len = input.length\n const remainder = len & 15 // len % 16\n const bytes = len - remainder\n\n const c1 = 0x87c37b91\n const c2 = 0x4cf5ad43\n const c3 = 0x52dce729\n const c4 = 0x38495ab5\n\n // Process 16-byte chunks\n for (let i = 0; i < bytes; i += 16) {\n let k1 =\n (input.charCodeAt(i) & 0xff) |\n ((input.charCodeAt(i + 1) & 0xff) << 8) |\n ((input.charCodeAt(i + 2) & 0xff) << 16) |\n ((input.charCodeAt(i + 3) & 0xff) << 24)\n\n let k2 =\n (input.charCodeAt(i + 4) & 0xff) |\n ((input.charCodeAt(i + 5) & 0xff) << 8) |\n ((input.charCodeAt(i + 6) & 0xff) << 16) |\n ((input.charCodeAt(i + 7) & 0xff) << 24)\n\n let k3 =\n (input.charCodeAt(i + 8) & 0xff) |\n ((input.charCodeAt(i + 9) & 0xff) << 8) |\n ((input.charCodeAt(i + 10) & 0xff) << 16) |\n ((input.charCodeAt(i + 11) & 0xff) << 24)\n\n let k4 =\n (input.charCodeAt(i + 12) & 0xff) |\n ((input.charCodeAt(i + 13) & 0xff) << 8) |\n ((input.charCodeAt(i + 14) & 0xff) << 16) |\n ((input.charCodeAt(i + 15) & 0xff) << 24)\n\n k1 = Math.imul(k1, c1)\n k1 = (k1 << 15) | (k1 >>> 17)\n k1 = Math.imul(k1, c2)\n h1 ^= k1\n\n h1 = (h1 << 13) | (h1 >>> 19)\n h1 = Math.imul(h1, 5) + 0xe6546b64\n\n k2 = Math.imul(k2, c2)\n k2 = (k2 << 16) | (k2 >>> 16)\n k2 = Math.imul(k2, c3)\n h2 ^= k2\n\n h2 = (h2 << 17) | (h2 >>> 15)\n h2 = Math.imul(h2, 5) + 0x1b873593\n\n k3 = Math.imul(k3, c3)\n k3 = (k3 << 17) | (k3 >>> 15)\n k3 = Math.imul(k3, c4)\n h1 ^= k3\n\n h1 = (h1 << 15) | (h1 >>> 17)\n h1 = Math.imul(h1, 5) + 0x52dce729\n\n k4 = Math.imul(k4, c4)\n k4 = (k4 << 18) | (k4 >>> 14)\n k4 = Math.imul(k4, c1)\n h2 ^= k4\n\n h2 = (h2 << 13) | (h2 >>> 19)\n h2 = Math.imul(h2, 5) + 0x38495ab5\n }\n\n // Process remaining bytes\n if (remainder > 0) {\n let k1 = 0\n let k2 = 0\n let k3 = 0\n let k4 = 0\n\n if (remainder >= 15) {\n k4 ^= (input.charCodeAt(bytes + 14) & 0xff) << 16\n }\n if (remainder >= 14) {\n k4 ^= (input.charCodeAt(bytes + 13) & 0xff) << 8\n }\n if (remainder >= 13) {\n k4 ^= input.charCodeAt(bytes + 12) & 0xff\n k4 = Math.imul(k4, c4)\n k4 = (k4 << 18) | (k4 >>> 14)\n k4 = Math.imul(k4, c1)\n h2 ^= k4\n }\n\n if (remainder >= 12) {\n k3 ^= (input.charCodeAt(bytes + 11) & 0xff) << 24\n }\n if (remainder >= 11) {\n k3 ^= (input.charCodeAt(bytes + 10) & 0xff) << 16\n }\n if (remainder >= 10) {\n k3 ^= (input.charCodeAt(bytes + 9) & 0xff) << 8\n }\n if (remainder >= 9) {\n k3 ^= input.charCodeAt(bytes + 8) & 0xff\n k3 = Math.imul(k3, c3)\n k3 = (k3 << 17) | (k3 >>> 15)\n k3 = Math.imul(k3, c4)\n h1 ^= k3\n }\n\n if (remainder >= 8) {\n k2 ^= (input.charCodeAt(bytes + 7) & 0xff) << 24\n }\n if (remainder >= 7) {\n k2 ^= (input.charCodeAt(bytes + 6) & 0xff) << 16\n }\n if (remainder >= 6) {\n k2 ^= (input.charCodeAt(bytes + 5) & 0xff) << 8\n }\n if (remainder >= 5) {\n k2 ^= input.charCodeAt(bytes + 4) & 0xff\n k2 = Math.imul(k2, c2)\n k2 = (k2 << 16) | (k2 >>> 16)\n k2 = Math.imul(k2, c3)\n h2 ^= k2\n }\n\n if (remainder >= 4) {\n k1 ^= (input.charCodeAt(bytes + 3) & 0xff) << 24\n }\n if (remainder >= 3) {\n k1 ^= (input.charCodeAt(bytes + 2) & 0xff) << 16\n }\n if (remainder >= 2) {\n k1 ^= (input.charCodeAt(bytes + 1) & 0xff) << 8\n }\n if (remainder >= 1) {\n k1 ^= input.charCodeAt(bytes) & 0xff\n k1 = Math.imul(k1, c1)\n k1 = (k1 << 15) | (k1 >>> 17)\n k1 = Math.imul(k1, c2)\n h1 ^= k1\n }\n }\n\n // Finalization\n h1 ^= len\n h2 ^= len\n\n h1 += h2\n h2 += h1\n\n h1 ^= h1 >>> 16\n h1 = Math.imul(h1, 0x85ebca6b)\n h1 ^= h1 >>> 13\n h1 = Math.imul(h1, 0xc2b2ae35)\n h1 ^= h1 >>> 16\n\n h2 ^= h2 >>> 16\n h2 = Math.imul(h2, 0x85ebca6b)\n h2 ^= h2 >>> 13\n h2 = Math.imul(h2, 0xc2b2ae35)\n h2 ^= h2 >>> 16\n\n h1 += h2\n h2 += h1\n\n // Return 128-bit hash as hex string\n return (h1 >>> 0).toString(16).padStart(8, '0') + (h2 >>> 0).toString(16).padStart(8, '0')\n}\n"],
5
+ "mappings": "AAaO,MAAM,eAAe,CAAC,UAA0B;AACrD,QAAM,OAAO;AAGb,MAAI,KAAK;AACT,MAAI,KAAK;AAET,QAAM,MAAM,MAAM;AAClB,QAAM,YAAY,MAAM;AACxB,QAAM,QAAQ,MAAM;AAEpB,QAAM,KAAK;AACX,QAAM,KAAK;AACX,QAAM,KAAK;AACX,QAAM,KAAK;AAGX,WAAS,IAAI,GAAG,IAAI,OAAO,KAAK,IAAI;AAClC,QAAI,KACD,MAAM,WAAW,CAAC,IAAI,OACrB,MAAM,WAAW,IAAI,CAAC,IAAI,QAAS,KACnC,MAAM,WAAW,IAAI,CAAC,IAAI,QAAS,MACnC,MAAM,WAAW,IAAI,CAAC,IAAI,QAAS;AAEvC,QAAI,KACD,MAAM,WAAW,IAAI,CAAC,IAAI,OACzB,MAAM,WAAW,IAAI,CAAC,IAAI,QAAS,KACnC,MAAM,WAAW,IAAI,CAAC,IAAI,QAAS,MACnC,MAAM,WAAW,IAAI,CAAC,IAAI,QAAS;AAEvC,QAAI,KACD,MAAM,WAAW,IAAI,CAAC,IAAI,OACzB,MAAM,WAAW,IAAI,CAAC,IAAI,QAAS,KACnC,MAAM,WAAW,IAAI,EAAE,IAAI,QAAS,MACpC,MAAM,WAAW,IAAI,EAAE,IAAI,QAAS;AAExC,QAAI,KACD,MAAM,WAAW,IAAI,EAAE,IAAI,OAC1B,MAAM,WAAW,IAAI,EAAE,IAAI,QAAS,KACpC,MAAM,WAAW,IAAI,EAAE,IAAI,QAAS,MACpC,MAAM,WAAW,IAAI,EAAE,IAAI,QAAS;AAExC,SAAK,KAAK,KAAK,IAAI,EAAE;AACrB,SAAM,MAA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AK,IAAI,EAAE;AACrB,YAAM;AAAA,IACR;AAAA,EACF;AAGA,QAAM;AACN,QAAM;AAEN,QAAM;AACN,QAAM;AAEN,QAAM,OAAO;AACb,OAAK,KAAK,KAAK,IAAI,UAAU;AAC7B,QAAM,OAAO;AACb,OAAK,KAAK,KAAK,IAAI,UAAU;AAC7B,QAAM,OAAO;AAEb,QAAM,OAAO;AACb,OAAK,KAAK,KAAK,IAAI,UAAU;AAC7B,QAAM,OAAO;AACb,OAAK,KAAK,KAAK,IAAI,UAAU;AAC7B,QAAM,OAAO;AAEb,QAAM;AACN,QAAM;AAGN,UAAQ,OAAO,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,KAAK,OAAO,GAAG,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG;AAC3F;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -14,18 +14,24 @@
14
14
  "helpers",
15
15
  "js"
16
16
  ],
17
- "version": "0.1.1",
17
+ "version": "0.1.3",
18
18
  "engines": {
19
19
  "node": ">=20"
20
20
  },
21
21
  "type": "module",
22
22
  "main": "dist/index.js",
23
+ "module": "dist/index.js",
23
24
  "exports": {
24
25
  "./array/*": {
25
26
  "import": "./dist/array/*.js",
26
27
  "types": "./dist/array/*.d.ts",
27
28
  "default": "./dist/array/*.js"
28
29
  },
30
+ "./crypto/*": {
31
+ "import": "./dist/crypto/*.js",
32
+ "types": "./dist/crypto/*.d.ts",
33
+ "default": "./dist/crypto/*.js"
34
+ },
29
35
  "./dom/*": {
30
36
  "import": "./dist/dom/*.js",
31
37
  "types": "./dist/dom/*.d.ts",
@@ -75,29 +81,23 @@
75
81
  "import": "./dist/url/*.js",
76
82
  "types": "./dist/url/*.d.ts",
77
83
  "default": "./dist/url/*.js"
78
- },
79
- "./crypto/*": {
80
- "import": "./dist/crypto/*.js",
81
- "types": "./dist/crypto/*.d.ts",
82
- "default": "./dist/crypto/*.js"
83
84
  }
84
85
  },
85
86
  "files": [
86
87
  "dist",
87
88
  "CHANGELOG.md"
88
89
  ],
89
- "module": "dist/index.js",
90
90
  "devDependencies": {
91
+ "jsdom": "26.1.0",
91
92
  "vite": "7.1.11",
92
93
  "vitest": "3.2.4",
93
- "@scalar/build-tooling": "0.2.8"
94
+ "@scalar/build-tooling": "0.3.1"
94
95
  },
95
96
  "scripts": {
96
97
  "build": "scalar-build-esbuild",
97
98
  "lint:check": "biome lint --diagnostic-level=error",
98
99
  "lint:fix": "biome lint --write",
99
100
  "test": "vitest",
100
- "test:coverage": "vitest run --coverage",
101
101
  "types:build": "scalar-types-build",
102
102
  "types:check": "scalar-types-check"
103
103
  }
@@ -1,32 +0,0 @@
1
- /**
2
- * A list of preset styles for word breaks
3
- */
4
- declare const PRESETS: {
5
- /** Breaks on `/` and `-` for urls or file paths */
6
- readonly path: RegExp;
7
- /**
8
- * Breaks on capitals, `_` and `.` for properties written in
9
- * camel, pascal or snake case
10
- */
11
- readonly property: RegExp;
12
- };
13
- /** Word break options */
14
- type WordBreakOptions = {
15
- /**
16
- * Presets for word wrapping
17
- */
18
- preset?: keyof typeof PRESETS;
19
- /**
20
- * Explicit regex to allow wrapping on, overrides any `preset`
21
- */
22
- regex?: RegExp;
23
- };
24
- /**
25
- * String utility to add word break opportunities
26
- *
27
- * Adds a zero-width space before certain characters to allow improved
28
- * line wrapping in the. Allows wrapping on "/" and * "-" by default.
29
- */
30
- export declare const addWordBreaks: (label: string, opts?: WordBreakOptions) => string;
31
- export {};
32
- //# sourceMappingURL=add-word-breaks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-word-breaks.d.ts","sourceRoot":"","sources":["../../src/string/add-word-breaks.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,QAAA,MAAM,OAAO;IACX,mDAAmD;;IAEnD;;;OAGG;;CAEsC,CAAA;AAE3C,yBAAyB;AACzB,KAAK,gBAAgB,GAAG;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,OAAO,OAAO,CAAA;IAC7B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,EAAE,OAAM,gBAAqB,KAAG,MAI1E,CAAA"}
@@ -1,19 +0,0 @@
1
- const ZWSP = "\u200B";
2
- const PRESETS = {
3
- /** Breaks on `/` and `-` for urls or file paths */
4
- "path": /[\/-]/,
5
- /**
6
- * Breaks on capitals, `_` and `.` for properties written in
7
- * camel, pascal or snake case
8
- */
9
- "property": /[A-Z\_\.-]/
10
- };
11
- const addWordBreaks = (label, opts = {}) => {
12
- const { preset = "path", regex } = opts;
13
- const wrapRegex = new RegExp(regex ?? PRESETS[preset], "g");
14
- return label.replace(wrapRegex, `${ZWSP}$&`);
15
- };
16
- export {
17
- addWordBreaks
18
- };
19
- //# sourceMappingURL=add-word-breaks.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/string/add-word-breaks.ts"],
4
- "sourcesContent": ["/**\n * Unicode character for zero-width space\n *\n * @see https://en.wikipedia.org/wiki/Zero-width_space\n */\nconst ZWSP = '\\u200B'\n\n/**\n * A list of preset styles for word breaks\n */\nconst PRESETS = {\n /** Breaks on `/` and `-` for urls or file paths */\n 'path': /[\\/-]/,\n /**\n * Breaks on capitals, `_` and `.` for properties written in\n * camel, pascal or snake case\n */\n 'property': /[A-Z\\_\\.-]/,\n} as const satisfies Record<string, RegExp>\n\n/** Word break options */\ntype WordBreakOptions = {\n /**\n * Presets for word wrapping\n */\n preset?: keyof typeof PRESETS\n /**\n * Explicit regex to allow wrapping on, overrides any `preset`\n */\n regex?: RegExp\n}\n\n/**\n * String utility to add word break opportunities\n *\n * Adds a zero-width space before certain characters to allow improved\n * line wrapping in the. Allows wrapping on \"/\" and * \"-\" by default.\n */\nexport const addWordBreaks = (label: string, opts: WordBreakOptions = {}): string => {\n const { preset = 'path', regex } = opts\n const wrapRegex = new RegExp(regex ?? PRESETS[preset], 'g')\n return label.replace(wrapRegex, `${ZWSP}$&`)\n}\n"],
5
- "mappings": "AAKA,MAAM,OAAO;AAKb,MAAM,UAAU;AAAA;AAAA,EAEd,QAAQ;AAAA;AAAA;AAAA;AAAA;AAAA,EAKR,YAAY;AACd;AAoBO,MAAM,gBAAgB,CAAC,OAAe,OAAyB,CAAC,MAAc;AACnF,QAAM,EAAE,SAAS,QAAQ,MAAM,IAAI;AACnC,QAAM,YAAY,IAAI,OAAO,SAAS,QAAQ,MAAM,GAAG,GAAG;AAC1D,SAAO,MAAM,QAAQ,WAAW,GAAG,IAAI,IAAI;AAC7C;",
6
- "names": []
7
- }