@scalar/helpers 0.0.12 → 0.0.13
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 +6 -0
- package/dist/crypto/generate-hash.d.ts +15 -0
- package/dist/crypto/generate-hash.d.ts.map +1 -0
- package/dist/crypto/generate-hash.js +10 -0
- package/dist/crypto/generate-hash.js.map +7 -0
- package/package.json +8 -3
- package/dist/dom/freeze-at-top.d.ts +0 -6
- package/dist/dom/freeze-at-top.d.ts.map +0 -1
- package/dist/dom/freeze-at-top.js +0 -34
- package/dist/dom/freeze-at-top.js.map +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @scalar/helpers
|
|
2
2
|
|
|
3
|
+
## 0.0.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#7129](https://github.com/scalar/scalar/pull/7129) [`6ec8c29`](https://github.com/scalar/scalar/commit/6ec8c299d912111b029e8058979d00968b70691a) Thanks [@geoffgscott](https://github.com/geoffgscott)! - Simplify ApiReferences state management and migrate to new shared sidebar component. Eliminates the useSidebar and useNav hooks in favour of event bubbling and centralized state management in ApiReference.vue
|
|
8
|
+
|
|
3
9
|
## 0.0.12
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a SHA-256 hexadecimal hash for the provided string input.
|
|
3
|
+
*
|
|
4
|
+
* This function uses the Web Crypto API, returning a lowercase hex string.
|
|
5
|
+
* The resulting hash is deterministic for the same input.
|
|
6
|
+
*
|
|
7
|
+
* @param input - The input string to hash.
|
|
8
|
+
* @returns A Promise that resolves to a hexadecimal string representing the SHA-256 hash.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const hash = await generateHash('hello world')
|
|
12
|
+
* console.log(hash) // => 'b94d27b9934d3e08a52e52d7da7dabfadeb...'
|
|
13
|
+
*/
|
|
14
|
+
export declare const generateHash: (input: string) => Promise<string>;
|
|
15
|
+
//# sourceMappingURL=generate-hash.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-hash.d.ts","sourceRoot":"","sources":["../../src/crypto/generate-hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,GAAU,OAAO,MAAM,KAAG,OAAO,CAAC,MAAM,CAUhE,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const generateHash = async (input) => {
|
|
2
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(input));
|
|
3
|
+
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
|
4
|
+
const hashHex = hashArray.map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
5
|
+
return hashHex;
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
generateHash
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=generate-hash.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/crypto/generate-hash.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Generates a SHA-256 hexadecimal hash for the provided string input.\n *\n * This function uses the Web Crypto API, returning a lowercase hex string.\n * The resulting hash is deterministic for the same input.\n *\n * @param input - The input string to hash.\n * @returns A Promise that resolves to a hexadecimal string representing the SHA-256 hash.\n *\n * @example\n * const hash = await generateHash('hello world')\n * console.log(hash) // => 'b94d27b9934d3e08a52e52d7da7dabfadeb...'\n */\nexport const generateHash = async (input: string): Promise<string> => {\n const hashBuffer = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(input))\n\n // Convert the ArrayBuffer to a Uint8Array\n const hashArray = Array.from(new Uint8Array(hashBuffer))\n\n // Convert each byte to its hexadecimal representation and join them\n const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join('')\n\n return hashHex\n}\n"],
|
|
5
|
+
"mappings": "AAaO,MAAM,eAAe,OAAO,UAAmC;AACpE,QAAM,aAAa,MAAM,OAAO,OAAO,OAAO,WAAW,IAAI,YAAY,EAAE,OAAO,KAAK,CAAC;AAGxF,QAAM,YAAY,MAAM,KAAK,IAAI,WAAW,UAAU,CAAC;AAGvD,QAAM,UAAU,UAAU,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAE7E,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"helpers",
|
|
15
15
|
"js"
|
|
16
16
|
],
|
|
17
|
-
"version": "0.0.
|
|
17
|
+
"version": "0.0.13",
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=20"
|
|
20
20
|
},
|
|
@@ -70,6 +70,11 @@
|
|
|
70
70
|
"import": "./dist/url/*.js",
|
|
71
71
|
"types": "./dist/url/*.d.ts",
|
|
72
72
|
"default": "./dist/url/*.js"
|
|
73
|
+
},
|
|
74
|
+
"./crypto/*": {
|
|
75
|
+
"import": "./dist/crypto/*.js",
|
|
76
|
+
"types": "./dist/crypto/*.d.ts",
|
|
77
|
+
"default": "./dist/crypto/*.js"
|
|
73
78
|
}
|
|
74
79
|
},
|
|
75
80
|
"files": [
|
|
@@ -78,9 +83,9 @@
|
|
|
78
83
|
],
|
|
79
84
|
"module": "dist/index.js",
|
|
80
85
|
"devDependencies": {
|
|
81
|
-
"vite": "7.1.
|
|
86
|
+
"vite": "7.1.11",
|
|
82
87
|
"vitest": "3.2.4",
|
|
83
|
-
"@scalar/build-tooling": "0.2.
|
|
88
|
+
"@scalar/build-tooling": "0.2.8"
|
|
84
89
|
},
|
|
85
90
|
"scripts": {
|
|
86
91
|
"build": "scalar-build-esbuild",
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Freezes an element at the top of the viewport using a mutation observer to check if the element has entered the dom
|
|
3
|
-
* Differs from freezeElement as the element doesn't need to exist yet
|
|
4
|
-
*/
|
|
5
|
-
export declare const freezeAtTop: (id: string) => () => void;
|
|
6
|
-
//# sourceMappingURL=freeze-at-top.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"freeze-at-top.d.ts","sourceRoot":"","sources":["../../src/dom/freeze-at-top.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,WAAW,GAAI,IAAI,MAAM,eAyCrC,CAAA"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
const freezeAtTop = (id) => {
|
|
2
|
-
if (!id) {
|
|
3
|
-
return () => null;
|
|
4
|
-
}
|
|
5
|
-
let rafId = null;
|
|
6
|
-
let element = document.getElementById(id);
|
|
7
|
-
const observer = new MutationObserver(() => {
|
|
8
|
-
element ||= document.getElementById(id);
|
|
9
|
-
if (!element) {
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
if (rafId !== null) {
|
|
13
|
-
cancelAnimationFrame(rafId);
|
|
14
|
-
}
|
|
15
|
-
rafId = requestAnimationFrame(() => {
|
|
16
|
-
element?.scrollIntoView();
|
|
17
|
-
rafId = null;
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
observer.observe(document.body, {
|
|
21
|
-
childList: true,
|
|
22
|
-
subtree: true
|
|
23
|
-
});
|
|
24
|
-
return () => {
|
|
25
|
-
if (rafId !== null) {
|
|
26
|
-
cancelAnimationFrame(rafId);
|
|
27
|
-
}
|
|
28
|
-
observer.disconnect();
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
freezeAtTop
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=freeze-at-top.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/dom/freeze-at-top.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Freezes an element at the top of the viewport using a mutation observer to check if the element has entered the dom\n * Differs from freezeElement as the element doesn't need to exist yet\n */\nexport const freezeAtTop = (id: string) => {\n if (!id) {\n return () => null\n }\n\n let rafId: number | null = null\n let element = document.getElementById(id)\n\n // Create mutation observer to watch for DOM changes\n const observer = new MutationObserver(() => {\n element ||= document.getElementById(id)\n\n if (!element) {\n return\n }\n\n // Cancel any pending animation frame\n if (rafId !== null) {\n cancelAnimationFrame(rafId)\n }\n\n // Schedule the scroll adjustment for the next frame\n rafId = requestAnimationFrame(() => {\n element?.scrollIntoView()\n rafId = null\n })\n })\n\n // Start observing with more specific configuration\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n })\n\n // Return function to stop maintaining position\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId)\n }\n observer.disconnect()\n }\n}\n"],
|
|
5
|
-
"mappings": "AAIO,MAAM,cAAc,CAAC,OAAe;AACzC,MAAI,CAAC,IAAI;AACP,WAAO,MAAM;AAAA,EACf;AAEA,MAAI,QAAuB;AAC3B,MAAI,UAAU,SAAS,eAAe,EAAE;AAGxC,QAAM,WAAW,IAAI,iBAAiB,MAAM;AAC1C,gBAAY,SAAS,eAAe,EAAE;AAEtC,QAAI,CAAC,SAAS;AACZ;AAAA,IACF;AAGA,QAAI,UAAU,MAAM;AAClB,2BAAqB,KAAK;AAAA,IAC5B;AAGA,YAAQ,sBAAsB,MAAM;AAClC,eAAS,eAAe;AACxB,cAAQ;AAAA,IACV,CAAC;AAAA,EACH,CAAC;AAGD,WAAS,QAAQ,SAAS,MAAM;AAAA,IAC9B,WAAW;AAAA,IACX,SAAS;AAAA,EACX,CAAC;AAGD,SAAO,MAAM;AACX,QAAI,UAAU,MAAM;AAClB,2BAAqB,KAAK;AAAA,IAC5B;AACA,aAAS,WAAW;AAAA,EACtB;AACF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|