@sharadox/web-library 0.4.0 → 0.5.0

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.
Files changed (279) hide show
  1. package/README.md +40 -28
  2. package/distribution/assert/never/index.d.ts +13 -0
  3. package/distribution/assert/never/index.d.ts.map +1 -0
  4. package/distribution/assert/never/index.js +15 -0
  5. package/distribution/assert/never/index.js.map +1 -0
  6. package/distribution/class-name/index.d.ts +6 -1
  7. package/distribution/class-name/index.d.ts.map +1 -1
  8. package/distribution/class-name/index.js +6 -1
  9. package/distribution/class-name/index.js.map +1 -1
  10. package/distribution/html/escape/index.d.ts +6 -1
  11. package/distribution/html/escape/index.d.ts.map +1 -1
  12. package/distribution/html/escape/index.js +7 -2
  13. package/distribution/html/escape/index.js.map +1 -1
  14. package/distribution/math/clamp/index.d.ts +6 -1
  15. package/distribution/math/clamp/index.d.ts.map +1 -1
  16. package/distribution/math/clamp/index.js +6 -1
  17. package/distribution/math/clamp/index.js.map +1 -1
  18. package/distribution/math/pseudo-random/index.d.ts +6 -1
  19. package/distribution/math/pseudo-random/index.d.ts.map +1 -1
  20. package/distribution/math/pseudo-random/index.js +6 -1
  21. package/distribution/math/pseudo-random/index.js.map +1 -1
  22. package/distribution/math/radians/index.d.ts +6 -1
  23. package/distribution/math/radians/index.d.ts.map +1 -1
  24. package/distribution/math/radians/index.js +6 -1
  25. package/distribution/math/radians/index.js.map +1 -1
  26. package/distribution/text/separate/index.d.ts +9 -0
  27. package/distribution/text/separate/index.d.ts.map +1 -0
  28. package/distribution/text/separate/index.js +11 -0
  29. package/distribution/text/separate/index.js.map +1 -0
  30. package/distribution/type-guard/is-boolean/index.d.ts +8 -0
  31. package/distribution/type-guard/is-boolean/index.d.ts.map +1 -0
  32. package/distribution/type-guard/is-boolean/index.js +10 -0
  33. package/distribution/type-guard/is-boolean/index.js.map +1 -0
  34. package/distribution/type-guard/is-defined/index.d.ts +8 -0
  35. package/distribution/type-guard/is-defined/index.d.ts.map +1 -0
  36. package/distribution/type-guard/is-defined/index.js +10 -0
  37. package/distribution/type-guard/is-defined/index.js.map +1 -0
  38. package/distribution/type-guard/is-non-empty-string/index.d.ts +8 -0
  39. package/distribution/type-guard/is-non-empty-string/index.d.ts.map +1 -0
  40. package/distribution/type-guard/is-non-empty-string/index.js +11 -0
  41. package/distribution/type-guard/is-non-empty-string/index.js.map +1 -0
  42. package/distribution/type-guard/is-number/index.d.ts +9 -0
  43. package/distribution/type-guard/is-number/index.d.ts.map +1 -0
  44. package/distribution/type-guard/is-number/index.js +11 -0
  45. package/distribution/type-guard/is-number/index.js.map +1 -0
  46. package/distribution/type-guard/is-record/index.d.ts +9 -0
  47. package/distribution/type-guard/is-record/index.d.ts.map +1 -0
  48. package/distribution/type-guard/is-record/index.js +14 -0
  49. package/distribution/type-guard/is-record/index.js.map +1 -0
  50. package/distribution/type-guard/is-string/index.d.ts +9 -0
  51. package/distribution/type-guard/is-string/index.d.ts.map +1 -0
  52. package/distribution/type-guard/is-string/index.js +11 -0
  53. package/distribution/type-guard/is-string/index.js.map +1 -0
  54. package/llms.txt +17 -0
  55. package/package.json +18 -46
  56. package/distribution/animation/count-up/index.d.ts +0 -6
  57. package/distribution/animation/count-up/index.d.ts.map +0 -1
  58. package/distribution/animation/count-up/index.js +0 -29
  59. package/distribution/animation/count-up/index.js.map +0 -1
  60. package/distribution/animation/in-view/index.d.ts +0 -3
  61. package/distribution/animation/in-view/index.d.ts.map +0 -1
  62. package/distribution/animation/in-view/index.js +0 -15
  63. package/distribution/animation/in-view/index.js.map +0 -1
  64. package/distribution/animation/marquee/index.d.ts +0 -9
  65. package/distribution/animation/marquee/index.d.ts.map +0 -1
  66. package/distribution/animation/marquee/index.js +0 -78
  67. package/distribution/animation/marquee/index.js.map +0 -1
  68. package/distribution/animation/marquee/type.d.ts +0 -5
  69. package/distribution/animation/marquee/type.d.ts.map +0 -1
  70. package/distribution/animation/marquee/type.js +0 -2
  71. package/distribution/animation/marquee/type.js.map +0 -1
  72. package/distribution/animation/reveal/index.d.ts +0 -4
  73. package/distribution/animation/reveal/index.d.ts.map +0 -1
  74. package/distribution/animation/reveal/index.js +0 -9
  75. package/distribution/animation/reveal/index.js.map +0 -1
  76. package/distribution/animation/reveal/type.d.ts +0 -14
  77. package/distribution/animation/reveal/type.d.ts.map +0 -1
  78. package/distribution/animation/reveal/type.js +0 -2
  79. package/distribution/animation/reveal/type.js.map +0 -1
  80. package/distribution/animation/scroll-word/index.d.ts +0 -4
  81. package/distribution/animation/scroll-word/index.d.ts.map +0 -1
  82. package/distribution/animation/scroll-word/index.js +0 -16
  83. package/distribution/animation/scroll-word/index.js.map +0 -1
  84. package/distribution/animation/scroll-word/type.d.ts +0 -11
  85. package/distribution/animation/scroll-word/type.d.ts.map +0 -1
  86. package/distribution/animation/scroll-word/type.js +0 -2
  87. package/distribution/animation/scroll-word/type.js.map +0 -1
  88. package/distribution/animation/scroll-word/word/index.d.ts +0 -4
  89. package/distribution/animation/scroll-word/word/index.d.ts.map +0 -1
  90. package/distribution/animation/scroll-word/word/index.js +0 -10
  91. package/distribution/animation/scroll-word/word/index.js.map +0 -1
  92. package/distribution/animation/scroll-word/word/type.d.ts +0 -14
  93. package/distribution/animation/scroll-word/word/type.d.ts.map +0 -1
  94. package/distribution/animation/scroll-word/word/type.js +0 -2
  95. package/distribution/animation/scroll-word/word/type.js.map +0 -1
  96. package/distribution/animation/smooth-scroll/index.d.ts +0 -4
  97. package/distribution/animation/smooth-scroll/index.d.ts.map +0 -1
  98. package/distribution/animation/smooth-scroll/index.js +0 -33
  99. package/distribution/animation/smooth-scroll/index.js.map +0 -1
  100. package/distribution/animation/smooth-scroll/type.d.ts +0 -7
  101. package/distribution/animation/smooth-scroll/type.d.ts.map +0 -1
  102. package/distribution/animation/smooth-scroll/type.js +0 -2
  103. package/distribution/animation/smooth-scroll/type.js.map +0 -1
  104. package/distribution/form/bot-check/index.d.ts +0 -4
  105. package/distribution/form/bot-check/index.d.ts.map +0 -1
  106. package/distribution/form/bot-check/index.js +0 -6
  107. package/distribution/form/bot-check/index.js.map +0 -1
  108. package/distribution/form/bot-check/type.d.ts +0 -11
  109. package/distribution/form/bot-check/type.d.ts.map +0 -1
  110. package/distribution/form/bot-check/type.js +0 -2
  111. package/distribution/form/bot-check/type.js.map +0 -1
  112. package/distribution/form/field/index.d.ts +0 -3
  113. package/distribution/form/field/index.d.ts.map +0 -1
  114. package/distribution/form/field/index.js +0 -7
  115. package/distribution/form/field/index.js.map +0 -1
  116. package/distribution/form/rate-limit/index.d.ts +0 -4
  117. package/distribution/form/rate-limit/index.d.ts.map +0 -1
  118. package/distribution/form/rate-limit/index.js +0 -14
  119. package/distribution/form/rate-limit/index.js.map +0 -1
  120. package/distribution/form/rate-limit/type.d.ts +0 -9
  121. package/distribution/form/rate-limit/type.d.ts.map +0 -1
  122. package/distribution/form/rate-limit/type.js +0 -2
  123. package/distribution/form/rate-limit/type.js.map +0 -1
  124. package/distribution/internationalization/locale/index.d.ts +0 -7
  125. package/distribution/internationalization/locale/index.d.ts.map +0 -1
  126. package/distribution/internationalization/locale/index.js +0 -17
  127. package/distribution/internationalization/locale/index.js.map +0 -1
  128. package/distribution/internationalization/locale/type.d.ts +0 -3
  129. package/distribution/internationalization/locale/type.d.ts.map +0 -1
  130. package/distribution/internationalization/locale/type.js +0 -2
  131. package/distribution/internationalization/locale/type.js.map +0 -1
  132. package/distribution/internationalization/locale-preference/index.d.ts +0 -5
  133. package/distribution/internationalization/locale-preference/index.d.ts.map +0 -1
  134. package/distribution/internationalization/locale-preference/index.js +0 -9
  135. package/distribution/internationalization/locale-preference/index.js.map +0 -1
  136. package/distribution/internationalization/locale-redirect/index.d.ts +0 -8
  137. package/distribution/internationalization/locale-redirect/index.d.ts.map +0 -1
  138. package/distribution/internationalization/locale-redirect/index.js +0 -24
  139. package/distribution/internationalization/locale-redirect/index.js.map +0 -1
  140. package/distribution/internationalization/locale-redirect/type.d.ts +0 -12
  141. package/distribution/internationalization/locale-redirect/type.d.ts.map +0 -1
  142. package/distribution/internationalization/locale-redirect/type.js +0 -2
  143. package/distribution/internationalization/locale-redirect/type.js.map +0 -1
  144. package/distribution/internationalization/translate/index.d.ts +0 -4
  145. package/distribution/internationalization/translate/index.d.ts.map +0 -1
  146. package/distribution/internationalization/translate/index.js +0 -5
  147. package/distribution/internationalization/translate/index.js.map +0 -1
  148. package/distribution/pointer/spotlight/index.d.ts +0 -3
  149. package/distribution/pointer/spotlight/index.d.ts.map +0 -1
  150. package/distribution/pointer/spotlight/index.js +0 -20
  151. package/distribution/pointer/spotlight/index.js.map +0 -1
  152. package/distribution/pointer/tilt/index.d.ts +0 -7
  153. package/distribution/pointer/tilt/index.d.ts.map +0 -1
  154. package/distribution/pointer/tilt/index.js +0 -34
  155. package/distribution/pointer/tilt/index.js.map +0 -1
  156. package/distribution/privacy/consent/index.d.ts +0 -22
  157. package/distribution/privacy/consent/index.d.ts.map +0 -1
  158. package/distribution/privacy/consent/index.js +0 -75
  159. package/distribution/privacy/consent/index.js.map +0 -1
  160. package/distribution/privacy/consent/type.d.ts +0 -35
  161. package/distribution/privacy/consent/type.d.ts.map +0 -1
  162. package/distribution/privacy/consent/type.js +0 -2
  163. package/distribution/privacy/consent/type.js.map +0 -1
  164. package/distribution/privacy/use-consent/index.d.ts +0 -5
  165. package/distribution/privacy/use-consent/index.d.ts.map +0 -1
  166. package/distribution/privacy/use-consent/index.js +0 -22
  167. package/distribution/privacy/use-consent/index.js.map +0 -1
  168. package/distribution/privacy/use-consent/type.d.ts +0 -10
  169. package/distribution/privacy/use-consent/type.d.ts.map +0 -1
  170. package/distribution/privacy/use-consent/type.js +0 -2
  171. package/distribution/privacy/use-consent/type.js.map +0 -1
  172. package/distribution/scroll/active-section/index.d.ts +0 -7
  173. package/distribution/scroll/active-section/index.d.ts.map +0 -1
  174. package/distribution/scroll/active-section/index.js +0 -49
  175. package/distribution/scroll/active-section/index.js.map +0 -1
  176. package/distribution/scroll/active-section/type.d.ts +0 -9
  177. package/distribution/scroll/active-section/type.d.ts.map +0 -1
  178. package/distribution/scroll/active-section/type.js +0 -2
  179. package/distribution/scroll/active-section/type.js.map +0 -1
  180. package/distribution/search-engine/robots/index.d.ts +0 -4
  181. package/distribution/search-engine/robots/index.d.ts.map +0 -1
  182. package/distribution/search-engine/robots/index.js +0 -7
  183. package/distribution/search-engine/robots/index.js.map +0 -1
  184. package/distribution/search-engine/robots/type.d.ts +0 -17
  185. package/distribution/search-engine/robots/type.d.ts.map +0 -1
  186. package/distribution/search-engine/robots/type.js +0 -2
  187. package/distribution/search-engine/robots/type.js.map +0 -1
  188. package/distribution/search-engine/sitemap/index.d.ts +0 -4
  189. package/distribution/search-engine/sitemap/index.d.ts.map +0 -1
  190. package/distribution/search-engine/sitemap/index.js +0 -12
  191. package/distribution/search-engine/sitemap/index.js.map +0 -1
  192. package/distribution/search-engine/sitemap/type.d.ts +0 -22
  193. package/distribution/search-engine/sitemap/type.d.ts.map +0 -1
  194. package/distribution/search-engine/sitemap/type.js +0 -2
  195. package/distribution/search-engine/sitemap/type.js.map +0 -1
  196. package/distribution/search-engine/structured-data/index.d.ts +0 -4
  197. package/distribution/search-engine/structured-data/index.d.ts.map +0 -1
  198. package/distribution/search-engine/structured-data/index.js +0 -6
  199. package/distribution/search-engine/structured-data/index.js.map +0 -1
  200. package/distribution/search-engine/structured-data/type.d.ts +0 -5
  201. package/distribution/search-engine/structured-data/type.d.ts.map +0 -1
  202. package/distribution/search-engine/structured-data/type.js +0 -2
  203. package/distribution/search-engine/structured-data/type.js.map +0 -1
  204. package/distribution/style/apply/index.d.ts +0 -11
  205. package/distribution/style/apply/index.d.ts.map +0 -1
  206. package/distribution/style/apply/index.js +0 -50
  207. package/distribution/style/apply/index.js.map +0 -1
  208. package/distribution/style/apply/type.d.ts +0 -12
  209. package/distribution/style/apply/type.d.ts.map +0 -1
  210. package/distribution/style/apply/type.js +0 -2
  211. package/distribution/style/apply/type.js.map +0 -1
  212. package/distribution/style/definition/index.d.ts +0 -14
  213. package/distribution/style/definition/index.d.ts.map +0 -1
  214. package/distribution/style/definition/index.js +0 -26
  215. package/distribution/style/definition/index.js.map +0 -1
  216. package/distribution/style/definition/type.d.ts +0 -29
  217. package/distribution/style/definition/type.d.ts.map +0 -1
  218. package/distribution/style/definition/type.js +0 -2
  219. package/distribution/style/definition/type.js.map +0 -1
  220. package/distribution/style/style-script/index.d.ts +0 -10
  221. package/distribution/style/style-script/index.d.ts.map +0 -1
  222. package/distribution/style/style-script/index.js +0 -16
  223. package/distribution/style/style-script/index.js.map +0 -1
  224. package/distribution/style/style-script/type.d.ts +0 -5
  225. package/distribution/style/style-script/type.d.ts.map +0 -1
  226. package/distribution/style/style-script/type.js +0 -2
  227. package/distribution/style/style-script/type.js.map +0 -1
  228. package/distribution/style/style-sheet/index.d.ts +0 -8
  229. package/distribution/style/style-sheet/index.d.ts.map +0 -1
  230. package/distribution/style/style-sheet/index.js +0 -25
  231. package/distribution/style/style-sheet/index.js.map +0 -1
  232. package/distribution/style/use-style/index.d.ts +0 -5
  233. package/distribution/style/use-style/index.d.ts.map +0 -1
  234. package/distribution/style/use-style/index.js +0 -37
  235. package/distribution/style/use-style/index.js.map +0 -1
  236. package/distribution/style/use-style/type.d.ts +0 -9
  237. package/distribution/style/use-style/type.d.ts.map +0 -1
  238. package/distribution/style/use-style/type.js +0 -2
  239. package/distribution/style/use-style/type.js.map +0 -1
  240. package/distribution/test/visual-snapshot/index.d.ts +0 -8
  241. package/distribution/test/visual-snapshot/index.d.ts.map +0 -1
  242. package/distribution/test/visual-snapshot/index.js +0 -20
  243. package/distribution/test/visual-snapshot/index.js.map +0 -1
  244. package/distribution/test/visual-snapshot/type.d.ts +0 -7
  245. package/distribution/test/visual-snapshot/type.d.ts.map +0 -1
  246. package/distribution/test/visual-snapshot/type.js +0 -2
  247. package/distribution/test/visual-snapshot/type.js.map +0 -1
  248. package/distribution/time/format-time/index.d.ts +0 -3
  249. package/distribution/time/format-time/index.d.ts.map +0 -1
  250. package/distribution/time/format-time/index.js +0 -5
  251. package/distribution/time/format-time/index.js.map +0 -1
  252. package/distribution/time/open-state/index.d.ts +0 -4
  253. package/distribution/time/open-state/index.d.ts.map +0 -1
  254. package/distribution/time/open-state/index.js +0 -11
  255. package/distribution/time/open-state/index.js.map +0 -1
  256. package/distribution/time/open-state/type.d.ts +0 -5
  257. package/distribution/time/open-state/type.d.ts.map +0 -1
  258. package/distribution/time/open-state/type.js +0 -2
  259. package/distribution/time/open-state/type.js.map +0 -1
  260. package/distribution/time/sun-time/index.d.ts +0 -4
  261. package/distribution/time/sun-time/index.d.ts.map +0 -1
  262. package/distribution/time/sun-time/index.js +0 -27
  263. package/distribution/time/sun-time/index.js.map +0 -1
  264. package/distribution/time/sun-time/type.d.ts +0 -6
  265. package/distribution/time/sun-time/type.d.ts.map +0 -1
  266. package/distribution/time/sun-time/type.js +0 -2
  267. package/distribution/time/sun-time/type.js.map +0 -1
  268. package/distribution/time/sun-today/index.d.ts +0 -4
  269. package/distribution/time/sun-today/index.d.ts.map +0 -1
  270. package/distribution/time/sun-today/index.js +0 -25
  271. package/distribution/time/sun-today/index.js.map +0 -1
  272. package/distribution/time/sun-today/type.d.ts +0 -9
  273. package/distribution/time/sun-today/type.d.ts.map +0 -1
  274. package/distribution/time/sun-today/type.js +0 -2
  275. package/distribution/time/sun-today/type.js.map +0 -1
  276. package/distribution/time/zone-minute/index.d.ts +0 -3
  277. package/distribution/time/zone-minute/index.d.ts.map +0 -1
  278. package/distribution/time/zone-minute/index.js +0 -13
  279. package/distribution/time/zone-minute/index.js.map +0 -1
@@ -1,7 +0,0 @@
1
- /** A text field from submitted form data, trimmed and cut to `maximumLength` characters ("" when missing). */
2
- export function readField(form, name, maximumLength) {
3
- return String(form.get(name) ?? "")
4
- .trim()
5
- .slice(0, maximumLength);
6
- }
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/form/field/index.ts"],"names":[],"mappings":"AAAA,8GAA8G;AAC9G,MAAM,UAAU,SAAS,CAAC,IAAc,EAAE,IAAY,EAAE,aAAqB;IAC3E,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAChC,IAAI,EAAE;SACN,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;AAC7B,CAAC"}
@@ -1,4 +0,0 @@
1
- import type { RateLimiter, RateLimitOptions } from "@sharadox/web-library/form/rate-limit/type";
2
- /** In-memory sliding-window rate limiter. Best effort: each server instance keeps its own memory. */
3
- export declare function createRateLimiter({ window, maximum }: RateLimitOptions): RateLimiter;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/form/rate-limit/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAEhG,qGAAqG;AACrG,wBAAgB,iBAAiB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,gBAAgB,GAAG,WAAW,CAWpF"}
@@ -1,14 +0,0 @@
1
- /** In-memory sliding-window rate limiter. Best effort: each server instance keeps its own memory. */
2
- export function createRateLimiter({ window, maximum }) {
3
- const hits = new Map();
4
- return (key, now = Date.now()) => {
5
- const recent = (hits.get(key) ?? []).filter((time) => now - time < window);
6
- if (recent.length >= maximum) {
7
- hits.set(key, recent);
8
- return false;
9
- }
10
- hits.set(key, [...recent, now]);
11
- return true;
12
- };
13
- }
14
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/form/rate-limit/index.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,MAAM,UAAU,iBAAiB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAoB;IACrE,MAAM,IAAI,GAAG,IAAI,GAAG,EAAoB,CAAC;IACzC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE;QAC/B,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,GAAG,MAAM,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YACtB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC"}
@@ -1,9 +0,0 @@
1
- export interface RateLimitOptions {
2
- /** Window length in milliseconds. */
3
- window: number;
4
- /** Allowed hits per key inside the window. */
5
- maximum: number;
6
- }
7
- /** Records a hit for a key; returns false when the key is over its limit. */
8
- export type RateLimiter = (key: string, now?: number) => boolean;
9
- //# sourceMappingURL=type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../source/form/rate-limit/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,qCAAqC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,6EAA6E;AAC7E,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../source/form/rate-limit/type.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- /** Narrows an untrusted value (a route segment, a form field) to one of the published locales. */
2
- export declare function isLocale<Locale extends string>(value: string, locales: readonly Locale[]): value is Locale;
3
- /** The BCP 47 tag for `<html lang>`: European Portuguese is `pt-PT`; other languages keep their code. */
4
- export declare function languageTag(locale: string): string;
5
- /** The Open Graph locale (`og:locale`), for example `pt_PT` or `en_GB`. */
6
- export declare function openGraphLocale(locale: string): string;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/internationalization/locale/index.ts"],"names":[],"mappings":"AAKA,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,MAAM,EAAE,GAAG,KAAK,IAAI,MAAM,CAE1G;AAED,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -1,17 +0,0 @@
1
- /** Language tags for `<html lang>` and structured data's `inLanguage`, where the region matters. */
2
- const LANGUAGE_TAG = { pt: "pt-PT", en: "en" };
3
- /** Open Graph locales (`og:locale`). */
4
- const OPEN_GRAPH_LOCALE = { pt: "pt_PT", en: "en_GB", es: "es_ES", fr: "fr_FR", de: "de_DE" };
5
- /** Narrows an untrusted value (a route segment, a form field) to one of the published locales. */
6
- export function isLocale(value, locales) {
7
- return locales.includes(value);
8
- }
9
- /** The BCP 47 tag for `<html lang>`: European Portuguese is `pt-PT`; other languages keep their code. */
10
- export function languageTag(locale) {
11
- return LANGUAGE_TAG[locale] ?? locale;
12
- }
13
- /** The Open Graph locale (`og:locale`), for example `pt_PT` or `en_GB`. */
14
- export function openGraphLocale(locale) {
15
- return OPEN_GRAPH_LOCALE[locale] ?? locale;
16
- }
17
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/internationalization/locale/index.ts"],"names":[],"mappings":"AAAA,oGAAoG;AACpG,MAAM,YAAY,GAA2B,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACvE,wCAAwC;AACxC,MAAM,iBAAiB,GAA2B,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC;AAEtH,kGAAkG;AAClG,MAAM,UAAU,QAAQ,CAAwB,KAAa,EAAE,OAA0B;IACvF,OAAQ,OAA6B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AACxD,CAAC;AAED,yGAAyG;AACzG,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,OAAO,YAAY,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;AACxC,CAAC;AAED,2EAA2E;AAC3E,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,iBAAiB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC;AAC7C,CAAC"}
@@ -1,3 +0,0 @@
1
- /** A piece of copy written in every published language, for example `{ en: "Hello", pt: "Olá" }`. */
2
- export type Translated<Locale extends string = string> = Record<Locale, string>;
3
- //# sourceMappingURL=type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../source/internationalization/locale/type.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,MAAM,MAAM,UAAU,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../source/internationalization/locale/type.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- /** Cookie that remembers the language a visitor picked by hand; `localeRedirects` sends `/` to it. */
2
- export declare const LOCALE_COOKIE = "locale";
3
- /** Remembers a manual language choice for a year. Call it when the visitor switches language. */
4
- export declare function rememberLocale(locale: string, cookie?: string): void;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/internationalization/locale-preference/index.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,eAAO,MAAM,aAAa,WAAW,CAAC;AAGtC,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,MAAsB,GAAG,IAAI,CAGnF"}
@@ -1,9 +0,0 @@
1
- /** Cookie that remembers the language a visitor picked by hand; `localeRedirects` sends `/` to it. */
2
- export const LOCALE_COOKIE = "locale";
3
- const ONE_YEAR = 60 * 60 * 24 * 365;
4
- /** Remembers a manual language choice for a year. Call it when the visitor switches language. */
5
- export function rememberLocale(locale, cookie = LOCALE_COOKIE) {
6
- const secure = location.protocol === "https:" ? "; secure" : "";
7
- document.cookie = `${cookie}=${encodeURIComponent(locale)}; path=/; max-age=${ONE_YEAR}; samesite=lax${secure}`;
8
- }
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/internationalization/locale-preference/index.ts"],"names":[],"mappings":"AAAA,sGAAsG;AACtG,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC;AACtC,MAAM,QAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,GAAG,CAAC;AAEpC,iGAAiG;AACjG,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,SAAiB,aAAa;IAC3E,MAAM,MAAM,GAAG,QAAQ,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;IAChE,QAAQ,CAAC,MAAM,GAAG,GAAG,MAAM,IAAI,kBAAkB,CAAC,MAAM,CAAC,qBAAqB,QAAQ,iBAAiB,MAAM,EAAE,CAAC;AAClH,CAAC"}
@@ -1,8 +0,0 @@
1
- import type { LocaleRedirect } from "@sharadox/web-library/internationalization/locale-redirect/type";
2
- /**
3
- * Redirects for next.config `redirects()`. `/` goes to, in order: the language the visitor picked before (the
4
- * `locale` cookie set by `rememberLocale`), the language their browser asks for first (Accept-Language) when it is
5
- * published, and otherwise `/<defaultLocale>`.
6
- */
7
- export declare function localeRedirects(locales: readonly string[], defaultLocale: string, cookie?: string): LocaleRedirect[];
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/internationalization/locale-redirect/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iEAAiE,CAAC;AAEtG;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,SAAS,MAAM,EAAE,EAC1B,aAAa,EAAE,MAAM,EACrB,MAAM,GAAE,MAAsB,GAC7B,cAAc,EAAE,CAgBlB"}
@@ -1,24 +0,0 @@
1
- import { LOCALE_COOKIE } from "@sharadox/web-library/internationalization/locale-preference";
2
- /**
3
- * Redirects for next.config `redirects()`. `/` goes to, in order: the language the visitor picked before (the
4
- * `locale` cookie set by `rememberLocale`), the language their browser asks for first (Accept-Language) when it is
5
- * published, and otherwise `/<defaultLocale>`.
6
- */
7
- export function localeRedirects(locales, defaultLocale, cookie = LOCALE_COOKIE) {
8
- const remembered = locales.map((locale) => ({
9
- source: "/",
10
- has: [{ type: "cookie", key: cookie, value: locale }],
11
- destination: `/${locale}`,
12
- permanent: false,
13
- }));
14
- const preferred = locales
15
- .filter((locale) => locale !== defaultLocale)
16
- .map((locale) => ({
17
- source: "/",
18
- has: [{ type: "header", key: "accept-language", value: `${locale}.*` }],
19
- destination: `/${locale}`,
20
- permanent: false,
21
- }));
22
- return [...remembered, ...preferred, { source: "/", destination: `/${defaultLocale}`, permanent: false }];
23
- }
24
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/internationalization/locale-redirect/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,8DAA8D,CAAC;AAG7F;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,OAA0B,EAC1B,aAAqB,EACrB,SAAiB,aAAa;IAE9B,MAAM,UAAU,GAAqB,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAC5D,MAAM,EAAE,GAAG;QACX,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;QACrD,WAAW,EAAE,IAAI,MAAM,EAAE;QACzB,SAAS,EAAE,KAAK;KACjB,CAAC,CAAC,CAAC;IACJ,MAAM,SAAS,GAAqB,OAAO;SACxC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,KAAK,aAAa,CAAC;SAC5C,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QAChB,MAAM,EAAE,GAAG;QACX,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QACvE,WAAW,EAAE,IAAI,MAAM,EAAE;QACzB,SAAS,EAAE,KAAK;KACjB,CAAC,CAAC,CAAC;IACN,OAAO,CAAC,GAAG,UAAU,EAAE,GAAG,SAAS,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,aAAa,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5G,CAAC"}
@@ -1,12 +0,0 @@
1
- /** One Next.js redirect, as returned from `redirects()` in next.config. */
2
- export interface LocaleRedirect {
3
- source: string;
4
- destination: string;
5
- permanent: false;
6
- has?: {
7
- type: "header" | "cookie";
8
- key: string;
9
- value: string;
10
- }[];
11
- }
12
- //# sourceMappingURL=type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../source/internationalization/locale-redirect/type.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,KAAK,CAAC;IACjB,GAAG,CAAC,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACnE"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../source/internationalization/locale-redirect/type.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- import type { Translated } from "@sharadox/web-library/internationalization/locale/type";
2
- /** Picks the copy for a locale. */
3
- export declare function translate<Locale extends string>(value: Translated<Locale>, locale: NoInfer<Locale>): string;
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/internationalization/translate/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wDAAwD,CAAC;AAEzF,mCAAmC;AACnC,wBAAgB,SAAS,CAAC,MAAM,SAAS,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAE3G"}
@@ -1,5 +0,0 @@
1
- /** Picks the copy for a locale. */
2
- export function translate(value, locale) {
3
- return value[locale];
4
- }
5
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/internationalization/translate/index.ts"],"names":[],"mappings":"AAEA,mCAAmC;AACnC,MAAM,UAAU,SAAS,CAAwB,KAAyB,EAAE,MAAuB;IACjG,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;AACvB,CAAC"}
@@ -1,3 +0,0 @@
1
- /** Tracks the pointer inside an element as `--pointer-x`/`--pointer-y`, for lights that follow the cursor. */
2
- export declare function useSpotlight<Target extends HTMLElement>(): import("react").RefObject<Target | null>;
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/pointer/spotlight/index.ts"],"names":[],"mappings":"AAGA,8GAA8G;AAC9G,wBAAgB,YAAY,CAAC,MAAM,SAAS,WAAW,8CActD"}
@@ -1,20 +0,0 @@
1
- "use client";
2
- import { useEffect, useRef } from "react";
3
- /** Tracks the pointer inside an element as `--pointer-x`/`--pointer-y`, for lights that follow the cursor. */
4
- export function useSpotlight() {
5
- const reference = useRef(null);
6
- useEffect(() => {
7
- const element = reference.current;
8
- if (!element)
9
- return;
10
- const move = (event) => {
11
- const bounds = element.getBoundingClientRect();
12
- element.style.setProperty("--pointer-x", `${event.clientX - bounds.left}px`);
13
- element.style.setProperty("--pointer-y", `${event.clientY - bounds.top}px`);
14
- };
15
- element.addEventListener("pointermove", move);
16
- return () => element.removeEventListener("pointermove", move);
17
- }, []);
18
- return reference;
19
- }
20
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/pointer/spotlight/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C,8GAA8G;AAC9G,MAAM,UAAU,YAAY;IAC1B,MAAM,SAAS,GAAG,MAAM,CAAS,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,OAAO;YAAE,OAAO;QACrB,MAAM,IAAI,GAAG,CAAC,KAAmB,EAAE,EAAE;YACnC,MAAM,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;YAC/C,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,IAAI,CAAC,CAAC;YAC7E,OAAO,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,GAAG,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC;QAC9E,CAAC,CAAC;QACF,OAAO,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC,EAAE,EAAE,CAAC,CAAC;IACP,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,7 +0,0 @@
1
- /**
2
- * Tilts an element towards the pointer: sets `--tilt-x` and `--tilt-y` (degrees, up to `maximum`) while the pointer
3
- * is over it and eases back to 0 when it leaves. Use them in CSS, for example
4
- * `transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y))`. Off on touch screens.
5
- */
6
- export declare function useTilt<Target extends HTMLElement>(maximum?: number): import("react").RefObject<Target | null>;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/pointer/tilt/index.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,MAAM,SAAS,WAAW,EAAE,OAAO,SAAI,4CAwB9D"}
@@ -1,34 +0,0 @@
1
- "use client";
2
- import { useEffect, useRef } from "react";
3
- /**
4
- * Tilts an element towards the pointer: sets `--tilt-x` and `--tilt-y` (degrees, up to `maximum`) while the pointer
5
- * is over it and eases back to 0 when it leaves. Use them in CSS, for example
6
- * `transform: perspective(900px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y))`. Off on touch screens.
7
- */
8
- export function useTilt(maximum = 8) {
9
- const reference = useRef(null);
10
- useEffect(() => {
11
- const element = reference.current;
12
- if (!element || !window.matchMedia("(pointer: fine)").matches)
13
- return;
14
- const move = (event) => {
15
- const bounds = element.getBoundingClientRect();
16
- const x = (event.clientX - bounds.left) / bounds.width - 0.5;
17
- const y = (event.clientY - bounds.top) / bounds.height - 0.5;
18
- element.style.setProperty("--tilt-x", `${(-y * maximum * 2).toFixed(2)}deg`);
19
- element.style.setProperty("--tilt-y", `${(x * maximum * 2).toFixed(2)}deg`);
20
- };
21
- const leave = () => {
22
- element.style.setProperty("--tilt-x", "0deg");
23
- element.style.setProperty("--tilt-y", "0deg");
24
- };
25
- element.addEventListener("pointermove", move);
26
- element.addEventListener("pointerleave", leave);
27
- return () => {
28
- element.removeEventListener("pointermove", move);
29
- element.removeEventListener("pointerleave", leave);
30
- };
31
- }, [maximum]);
32
- return reference;
33
- }
34
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/pointer/tilt/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE1C;;;;GAIG;AACH,MAAM,UAAU,OAAO,CAA6B,OAAO,GAAG,CAAC;IAC7D,MAAM,SAAS,GAAG,MAAM,CAAS,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC;QAClC,IAAI,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,C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CAAC,CAAC;IACd,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -1,22 +0,0 @@
1
- import type { ConsentConfiguration, ConsentStatus } from "@sharadox/web-library/privacy/consent/type";
2
- /** Window event fired whenever the answer changes, and the one that reopens the consent panel. */
3
- export declare const CONSENT_CHANGE_EVENT = "consent-change";
4
- export declare const CONSENT_OPEN_EVENT = "consent-open";
5
- /** Only the required categories: what "Deny" grants. */
6
- export declare function requiredOnly(configuration: ConsentConfiguration): Record<string, boolean>;
7
- /** Every category: what "Accept All" grants. */
8
- export declare function everything(configuration: ConsentConfiguration): Record<string, boolean>;
9
- /** Reads the visitor's answer. A stored answer from an older version counts as not asked. */
10
- export declare function readConsent(configuration: ConsentConfiguration): ConsentStatus;
11
- /** True when the visitor allowed a category (required categories always are). */
12
- export declare function hasConsent(configuration: ConsentConfiguration, key: string): boolean;
13
- /** Stores an answer ("Accept All" or a manual selection) for good. Required categories are forced on. */
14
- export declare function saveConsent(configuration: ConsentConfiguration, granted: Record<string, boolean>): void;
15
- /**
16
- * "Deny": only required categories, and nothing kept for good — the answer lasts for this visit, and the visitor
17
- * is asked again next time they come.
18
- */
19
- export declare function declineConsent(configuration: ConsentConfiguration): void;
20
- /** Reopens the consent panel, for example from a "Cookie Preferences" link. */
21
- export declare function openConsent(): void;
22
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/privacy/consent/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAiB,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAErH,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,mBAAmB,CAAC;AACrD,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AAIjD,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,aAAa,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzF;AAED,gDAAgD;AAChD,wBAAgB,UAAU,CAAC,aAAa,EAAE,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEvF;AAED,6FAA6F;AAC7F,wBAAgB,WAAW,CAAC,aAAa,EAAE,oBAAoB,GAAG,aAAa,CAY9E;AAED,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,aAAa,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAIpF;AAID,yGAAyG;AACzG,wBAAgB,WAAW,CAAC,aAAa,EAAE,oBAAoB,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAkBvG;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,oBAAoB,GAAG,IAAI,CAQxE;AAED,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
@@ -1,75 +0,0 @@
1
- /** Window event fired whenever the answer changes, and the one that reopens the consent panel. */
2
- export const CONSENT_CHANGE_EVENT = "consent-change";
3
- export const CONSENT_OPEN_EVENT = "consent-open";
4
- const declinedKey = (configuration) => `${configuration.storageKey}-declined`;
5
- /** Only the required categories: what "Deny" grants. */
6
- export function requiredOnly(configuration) {
7
- return Object.fromEntries(configuration.categories.map((category) => [category.key, !!category.required]));
8
- }
9
- /** Every category: what "Accept All" grants. */
10
- export function everything(configuration) {
11
- return Object.fromEntries(configuration.categories.map((category) => [category.key, true]));
12
- }
13
- /** Reads the visitor's answer. A stored answer from an older version counts as not asked. */
14
- export function readConsent(configuration) {
15
- try {
16
- const stored = localStorage.getItem(configuration.storageKey);
17
- if (stored) {
18
- const record = JSON.parse(stored);
19
- if (record.version === configuration.version)
20
- return { kind: "decided", record };
21
- }
22
- if (sessionStorage.getItem(declinedKey(configuration)))
23
- return { kind: "declined" };
24
- }
25
- catch {
26
- // Unreadable or blocked storage: ask.
27
- }
28
- return { kind: "unknown" };
29
- }
30
- /** True when the visitor allowed a category (required categories always are). */
31
- export function hasConsent(configuration, key) {
32
- if (configuration.categories.some((category) => category.key === key && category.required))
33
- return true;
34
- const status = readConsent(configuration);
35
- return status.kind === "decided" && !!status.record.granted[key];
36
- }
37
- const announce = () => window.dispatchEvent(new Event(CONSENT_CHANGE_EVENT));
38
- /** Stores an answer ("Accept All" or a manual selection) for good. Required categories are forced on. */
39
- export function saveConsent(configuration, granted) {
40
- const record = {
41
- version: configuration.version,
42
- granted: {
43
- ...granted,
44
- ...Object.fromEntries(configuration.categories.filter((category) => category.required).map((category) => [category.key, true])),
45
- },
46
- date: new Date().toISOString(),
47
- };
48
- try {
49
- localStorage.setItem(configuration.storageKey, JSON.stringify(record));
50
- sessionStorage.removeItem(declinedKey(configuration));
51
- }
52
- catch {
53
- // Storage blocked: nothing persists, the panel asks again next time.
54
- }
55
- announce();
56
- }
57
- /**
58
- * "Deny": only required categories, and nothing kept for good — the answer lasts for this visit, and the visitor
59
- * is asked again next time they come.
60
- */
61
- export function declineConsent(configuration) {
62
- try {
63
- localStorage.removeItem(configuration.storageKey);
64
- sessionStorage.setItem(declinedKey(configuration), "1");
65
- }
66
- catch {
67
- // Storage blocked: the panel simply shows again.
68
- }
69
- announce();
70
- }
71
- /** Reopens the consent panel, for example from a "Cookie Preferences" link. */
72
- export function openConsent() {
73
- window.dispatchEvent(new Event(CONSENT_OPEN_EVENT));
74
- }
75
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/privacy/consent/index.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AAEjD,MAAM,WAAW,GAAG,CAAC,aAAmC,EAAE,EAAE,CAAC,GAAG,aAAa,CAAC,UAAU,WAAW,CAAC;AAEpG,wDAAwD;AACxD,MAAM,UAAU,YAAY,CAAC,aAAmC;IAC9D,OAAO,MAAM,CAAC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E,GAAG,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,iDAAiD;IACnD,CAAC;IACD,QAAQ,EAAE,CAAC;AACb,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAC;AACtD,CAAC"}
@@ -1,35 +0,0 @@
1
- /** One kind of cookie or storage the site asks about. */
2
- export interface ConsentCategory {
3
- key: string;
4
- /** Always on: the site needs it to work (language, style, form security). */
5
- required?: boolean;
6
- }
7
- /** What the site asks about and where the answer is kept. */
8
- export interface ConsentConfiguration {
9
- /** Browser storage key for the answer. */
10
- storageKey: string;
11
- /** Raise it when the categories change, so everyone is asked again. */
12
- version: number;
13
- categories: readonly ConsentCategory[];
14
- }
15
- /** A stored answer. */
16
- export interface ConsentRecord {
17
- version: number;
18
- /** Category key → allowed. Required categories are always true. */
19
- granted: Record<string, boolean>;
20
- /** When the visitor answered (ISO 8601). */
21
- date: string;
22
- }
23
- /**
24
- * Where the visitor stands: not asked yet (or the answer is out of date), declined during this visit (asked again
25
- * next visit), or answered.
26
- */
27
- export type ConsentStatus = {
28
- kind: "unknown";
29
- } | {
30
- kind: "declined";
31
- } | {
32
- kind: "decided";
33
- record: ConsentRecord;
34
- };
35
- //# sourceMappingURL=type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../source/privacy/consent/type.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,6DAA6D;AAC7D,MAAM,WAAW,oBAAoB;IACnC,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,SAAS,eAAe,EAAE,CAAC;CACxC;AAED,uBAAuB;AACvB,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACjC,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../source/privacy/consent/type.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import type { ConsentConfiguration } from "@sharadox/web-library/privacy/consent/type";
2
- import type { ConsentState } from "@sharadox/web-library/privacy/use-consent/type";
3
- /** The visitor's cookie answer, kept in sync across the page and other tabs, with the actions that change it. */
4
- export declare function useConsent(configuration: ConsentConfiguration): ConsentState;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/privacy/use-consent/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAWnF,iHAAiH;AACjH,wBAAgB,UAAU,CAAC,aAAa,EAAE,oBAAoB,GAAG,YAAY,CAY5E"}
@@ -1,22 +0,0 @@
1
- "use client";
2
- import { useCallback, useMemo, useSyncExternalStore } from "react";
3
- import { CONSENT_CHANGE_EVENT, declineConsent, everything, readConsent, saveConsent, } from "@sharadox/web-library/privacy/consent";
4
- const subscribe = (notify) => {
5
- window.addEventListener(CONSENT_CHANGE_EVENT, notify);
6
- window.addEventListener("storage", notify);
7
- return () => {
8
- window.removeEventListener(CONSENT_CHANGE_EVENT, notify);
9
- window.removeEventListener("storage", notify);
10
- };
11
- };
12
- /** The visitor's cookie answer, kept in sync across the page and other tabs, with the actions that change it. */
13
- export function useConsent(configuration) {
14
- // A string snapshot keeps useSyncExternalStore stable; it is parsed again below.
15
- const snapshot = useSyncExternalStore(subscribe, () => JSON.stringify(readConsent(configuration)), () => undefined);
16
- const status = useMemo(() => (snapshot ? JSON.parse(snapshot) : undefined), [snapshot]);
17
- const acceptAll = useCallback(() => saveConsent(configuration, everything(configuration)), [configuration]);
18
- const deny = useCallback(() => declineConsent(configuration), [configuration]);
19
- const save = useCallback((granted) => saveConsent(configuration, granted), [configuration]);
20
- return { status, acceptAll, deny, save };
21
- }
22
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../source/privacy/use-consent/index.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,UAAU,EACV,WAAW,EACX,WAAW,GACZ,MAAM,uCAAuC,CAAC;AAI/C,MAAM,SAAS,GAAG,CAAC,MAAkB,EAAE,EAAE;IACvC,MAAM,CAAC,gBAAgB,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;IACtD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,GAAG,EAAE;QACV,MAAM,CAAC,mBAAmB,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;QACzD,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,iHAAiH;AACjH,MAAM,UAAU,UAAU,CAAC,aAAmC;IAC5D,iFAAiF;IACjF,MAAM,QAAQ,GAAG,oBAAoB,CACnC,SAAS,EACT,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,EAChD,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;IACF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IACxF,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,UAAU,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAC5G,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/E,MAAM,IAAI,GAAG,WAAW,CAAC,CAAC,OAAgC,EAAE,EAAE,CAAC,WAAW,CAAC,aAAa,EAAE,OAAO,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACrH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAC3C,CAAC"}
@@ -1,10 +0,0 @@
1
- import type { ConsentStatus } from "@sharadox/web-library/privacy/consent/type";
2
- export interface ConsentState {
3
- /** `undefined` on the server and before hydration, so nothing flashes for visitors who already answered. */
4
- status: ConsentStatus | undefined;
5
- acceptAll: () => void;
6
- deny: () => void;
7
- /** Stores a manual selection. */
8
- save: (granted: Record<string, boolean>) => void;
9
- }
10
- //# sourceMappingURL=type.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../../source/privacy/use-consent/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4CAA4C,CAAC;AAEhF,MAAM,WAAW,YAAY;IAC3B,4GAA4G;IAC5G,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC;IAClC,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,iCAAiC;IACjC,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CAClD"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../source/privacy/use-consent/type.ts"],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import type { ActiveSection } from "@sharadox/web-library/scroll/active-section/type";
2
- /**
3
- * Follows the scroll: which of the sections (by element id, in page order) holds the middle of the screen, how far
4
- * through it, and how far down the page. For section indicators and progress bars.
5
- */
6
- export declare function useActiveSection(ids: readonly string[]): ActiveSection;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../source/scroll/active-section/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AAEtF;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAyCtE"}