@alanizcreative/formation-static 0.0.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.
Files changed (329) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +145 -0
  3. package/cjs/actions/actions.d.ts +8 -0
  4. package/cjs/actions/actions.js +1 -0
  5. package/cjs/actions/actionsTypes.d.ts +10 -0
  6. package/cjs/actions/actionsTypes.js +1 -0
  7. package/cjs/components/Navigation/Navigation.d.ts +14 -0
  8. package/cjs/components/Navigation/Navigation.js +1 -0
  9. package/cjs/components/Navigation/NavigationTypes.d.ts +88 -0
  10. package/cjs/components/Navigation/NavigationTypes.js +1 -0
  11. package/cjs/components/Pagination/Pagination.d.ts +3 -0
  12. package/cjs/components/Pagination/Pagination.js +1 -0
  13. package/cjs/components/Pagination/PaginationTypes.d.ts +54 -0
  14. package/cjs/components/Pagination/PaginationTypes.js +1 -0
  15. package/cjs/config/config.d.ts +5 -0
  16. package/cjs/config/config.js +1 -0
  17. package/cjs/config/configTypes.d.ts +66 -0
  18. package/cjs/config/configTypes.js +1 -0
  19. package/cjs/contentful/contentfulData.d.ts +5 -0
  20. package/cjs/contentful/contentfulData.js +1 -0
  21. package/cjs/contentful/contentfulDataNormal.d.ts +4 -0
  22. package/cjs/contentful/contentfulDataNormal.js +1 -0
  23. package/cjs/contentful/contentfulDataTypes.d.ts +78 -0
  24. package/cjs/contentful/contentfulDataTypes.js +1 -0
  25. package/cjs/filters/filters.d.ts +8 -0
  26. package/cjs/filters/filters.js +1 -0
  27. package/cjs/filters/filtersTypes.d.ts +60 -0
  28. package/cjs/filters/filtersTypes.js +1 -0
  29. package/cjs/global/globalTypes.d.ts +34 -0
  30. package/cjs/global/globalTypes.js +1 -0
  31. package/cjs/layouts/Column/Column.d.ts +3 -0
  32. package/cjs/layouts/Column/Column.js +1 -0
  33. package/cjs/layouts/Column/ColumnTypes.d.ts +16 -0
  34. package/cjs/layouts/Column/ColumnTypes.js +1 -0
  35. package/cjs/layouts/Container/Container.d.ts +3 -0
  36. package/cjs/layouts/Container/Container.js +1 -0
  37. package/cjs/layouts/Container/ContainerTypes.d.ts +15 -0
  38. package/cjs/layouts/Container/ContainerTypes.js +1 -0
  39. package/cjs/local/localData.d.ts +5 -0
  40. package/cjs/local/localData.js +1 -0
  41. package/cjs/local/localDataNormal.d.ts +3 -0
  42. package/cjs/local/localDataNormal.js +1 -0
  43. package/cjs/local/localDataTypes.d.ts +14 -0
  44. package/cjs/local/localDataTypes.js +1 -0
  45. package/cjs/objects/Form/Form.d.ts +3 -0
  46. package/cjs/objects/Form/Form.js +1 -0
  47. package/cjs/objects/Form/FormField.d.ts +3 -0
  48. package/cjs/objects/Form/FormField.js +1 -0
  49. package/cjs/objects/Form/FormOption.d.ts +3 -0
  50. package/cjs/objects/Form/FormOption.js +1 -0
  51. package/cjs/objects/Form/FormTypes.d.ts +76 -0
  52. package/cjs/objects/Form/FormTypes.js +1 -0
  53. package/cjs/package.json +1 -0
  54. package/cjs/redirects/redirects.d.ts +4 -0
  55. package/cjs/redirects/redirects.js +1 -0
  56. package/cjs/redirects/redirectsFile.d.ts +2 -0
  57. package/cjs/redirects/redirectsFile.js +1 -0
  58. package/cjs/render/render.d.ts +11 -0
  59. package/cjs/render/render.js +1 -0
  60. package/cjs/render/renderInline.d.ts +4 -0
  61. package/cjs/render/renderInline.js +1 -0
  62. package/cjs/render/renderTypes.d.ts +197 -0
  63. package/cjs/render/renderTypes.js +1 -0
  64. package/cjs/scripts/scripts.d.ts +8 -0
  65. package/cjs/scripts/scripts.js +1 -0
  66. package/cjs/scripts/scriptsTypes.d.ts +15 -0
  67. package/cjs/scripts/scriptsTypes.js +1 -0
  68. package/cjs/serverless/Contact/Contact.d.ts +3 -0
  69. package/cjs/serverless/Contact/Contact.js +1 -0
  70. package/cjs/serverless/Contact/ContactTypes.d.ts +13 -0
  71. package/cjs/serverless/Contact/ContactTypes.js +1 -0
  72. package/cjs/serverless/serverless.d.ts +12 -0
  73. package/cjs/serverless/serverless.js +1 -0
  74. package/cjs/serverless/serverlessTypes.d.ts +41 -0
  75. package/cjs/serverless/serverlessTypes.js +1 -0
  76. package/cjs/shortcodes/shortcodes.d.ts +10 -0
  77. package/cjs/shortcodes/shortcodes.js +1 -0
  78. package/cjs/shortcodes/shortcodesTypes.d.ts +20 -0
  79. package/cjs/shortcodes/shortcodesTypes.js +1 -0
  80. package/cjs/store/store.d.ts +9 -0
  81. package/cjs/store/store.js +1 -0
  82. package/cjs/store/storeFiles.d.ts +2 -0
  83. package/cjs/store/storeFiles.js +1 -0
  84. package/cjs/store/storeTypes.d.ts +28 -0
  85. package/cjs/store/storeTypes.js +1 -0
  86. package/cjs/text/RichText/RichText.d.ts +4 -0
  87. package/cjs/text/RichText/RichText.js +1 -0
  88. package/cjs/text/RichText/RichTextTypes.d.ts +54 -0
  89. package/cjs/text/RichText/RichTextTypes.js +1 -0
  90. package/cjs/utils/ResponseError/ResponseError.d.ts +5 -0
  91. package/cjs/utils/ResponseError/ResponseError.js +1 -0
  92. package/cjs/utils/archive/archive.d.ts +10 -0
  93. package/cjs/utils/archive/archive.js +1 -0
  94. package/cjs/utils/archive/archiveTypes.d.ts +29 -0
  95. package/cjs/utils/archive/archiveTypes.js +1 -0
  96. package/cjs/utils/array/array.d.ts +3 -0
  97. package/cjs/utils/array/array.js +1 -0
  98. package/cjs/utils/boolean/boolean.d.ts +2 -0
  99. package/cjs/utils/boolean/boolean.js +1 -0
  100. package/cjs/utils/contentType/contentType.d.ts +2 -0
  101. package/cjs/utils/contentType/contentType.js +1 -0
  102. package/cjs/utils/dataSource/dataSource.d.ts +3 -0
  103. package/cjs/utils/dataSource/dataSource.js +1 -0
  104. package/cjs/utils/dataSource/dataSourceTypes.d.ts +9 -0
  105. package/cjs/utils/dataSource/dataSourceTypes.js +1 -0
  106. package/cjs/utils/escape/escape.d.ts +2 -0
  107. package/cjs/utils/escape/escape.js +1 -0
  108. package/cjs/utils/excerpt/excerpt.d.ts +3 -0
  109. package/cjs/utils/excerpt/excerpt.js +1 -0
  110. package/cjs/utils/excerpt/excerptTypes.d.ts +14 -0
  111. package/cjs/utils/excerpt/excerptTypes.js +1 -0
  112. package/cjs/utils/file/file.d.ts +3 -0
  113. package/cjs/utils/file/file.js +1 -0
  114. package/cjs/utils/file/filePath.d.ts +2 -0
  115. package/cjs/utils/file/filePath.js +1 -0
  116. package/cjs/utils/function/function.d.ts +3 -0
  117. package/cjs/utils/function/function.js +1 -0
  118. package/cjs/utils/heading/heading.d.ts +2 -0
  119. package/cjs/utils/heading/heading.js +1 -0
  120. package/cjs/utils/image/image.d.ts +5 -0
  121. package/cjs/utils/image/image.js +1 -0
  122. package/cjs/utils/image/imageLocal.d.ts +3 -0
  123. package/cjs/utils/image/imageLocal.js +1 -0
  124. package/cjs/utils/image/imageRemote.d.ts +3 -0
  125. package/cjs/utils/image/imageRemote.js +1 -0
  126. package/cjs/utils/image/imageTypes.d.ts +69 -0
  127. package/cjs/utils/image/imageTypes.js +1 -0
  128. package/cjs/utils/json/json.d.ts +3 -0
  129. package/cjs/utils/json/json.js +1 -0
  130. package/cjs/utils/link/link.d.ts +6 -0
  131. package/cjs/utils/link/link.js +1 -0
  132. package/cjs/utils/link/linkShare.d.ts +3 -0
  133. package/cjs/utils/link/linkShare.js +1 -0
  134. package/cjs/utils/link/linkTypes.d.ts +28 -0
  135. package/cjs/utils/link/linkTypes.js +1 -0
  136. package/cjs/utils/map/map.d.ts +2 -0
  137. package/cjs/utils/map/map.js +1 -0
  138. package/cjs/utils/minify/minify.d.ts +2 -0
  139. package/cjs/utils/minify/minify.js +1 -0
  140. package/cjs/utils/number/number.d.ts +2 -0
  141. package/cjs/utils/number/number.js +1 -0
  142. package/cjs/utils/object/object.d.ts +4 -0
  143. package/cjs/utils/object/object.js +1 -0
  144. package/cjs/utils/object/objectUtils.d.ts +2 -0
  145. package/cjs/utils/object/objectUtils.js +1 -0
  146. package/cjs/utils/path/path.d.ts +3 -0
  147. package/cjs/utils/path/path.js +1 -0
  148. package/cjs/utils/print/print.d.ts +2 -0
  149. package/cjs/utils/print/print.js +1 -0
  150. package/cjs/utils/set/set.d.ts +3 -0
  151. package/cjs/utils/set/set.js +1 -0
  152. package/cjs/utils/string/string.d.ts +3 -0
  153. package/cjs/utils/string/string.js +1 -0
  154. package/cjs/utils/tag/tag.d.ts +4 -0
  155. package/cjs/utils/tag/tag.js +1 -0
  156. package/cjs/utils/tag/tagTypes.d.ts +6 -0
  157. package/cjs/utils/tag/tagTypes.js +1 -0
  158. package/cjs/utils/year/year.d.ts +2 -0
  159. package/cjs/utils/year/year.js +1 -0
  160. package/cjs/wordpress/wordpressData.d.ts +6 -0
  161. package/cjs/wordpress/wordpressData.js +1 -0
  162. package/cjs/wordpress/wordpressDataNormal.d.ts +9 -0
  163. package/cjs/wordpress/wordpressDataNormal.js +1 -0
  164. package/cjs/wordpress/wordpressDataTypes.d.ts +208 -0
  165. package/cjs/wordpress/wordpressDataTypes.js +1 -0
  166. package/lib/actions/actions.d.ts +8 -0
  167. package/lib/actions/actions.js +1 -0
  168. package/lib/actions/actionsTypes.d.ts +10 -0
  169. package/lib/actions/actionsTypes.js +1 -0
  170. package/lib/components/Navigation/Navigation.d.ts +14 -0
  171. package/lib/components/Navigation/Navigation.js +1 -0
  172. package/lib/components/Navigation/NavigationTypes.d.ts +88 -0
  173. package/lib/components/Navigation/NavigationTypes.js +1 -0
  174. package/lib/components/Pagination/Pagination.d.ts +3 -0
  175. package/lib/components/Pagination/Pagination.js +1 -0
  176. package/lib/components/Pagination/PaginationTypes.d.ts +54 -0
  177. package/lib/components/Pagination/PaginationTypes.js +1 -0
  178. package/lib/config/config.d.ts +5 -0
  179. package/lib/config/config.js +1 -0
  180. package/lib/config/configTypes.d.ts +66 -0
  181. package/lib/config/configTypes.js +1 -0
  182. package/lib/contentful/contentfulData.d.ts +5 -0
  183. package/lib/contentful/contentfulData.js +1 -0
  184. package/lib/contentful/contentfulDataNormal.d.ts +4 -0
  185. package/lib/contentful/contentfulDataNormal.js +1 -0
  186. package/lib/contentful/contentfulDataTypes.d.ts +78 -0
  187. package/lib/contentful/contentfulDataTypes.js +1 -0
  188. package/lib/filters/filters.d.ts +8 -0
  189. package/lib/filters/filters.js +1 -0
  190. package/lib/filters/filtersTypes.d.ts +60 -0
  191. package/lib/filters/filtersTypes.js +1 -0
  192. package/lib/global/globalTypes.d.ts +34 -0
  193. package/lib/global/globalTypes.js +1 -0
  194. package/lib/layouts/Column/Column.d.ts +3 -0
  195. package/lib/layouts/Column/Column.js +1 -0
  196. package/lib/layouts/Column/ColumnTypes.d.ts +16 -0
  197. package/lib/layouts/Column/ColumnTypes.js +1 -0
  198. package/lib/layouts/Container/Container.d.ts +3 -0
  199. package/lib/layouts/Container/Container.js +1 -0
  200. package/lib/layouts/Container/ContainerTypes.d.ts +15 -0
  201. package/lib/layouts/Container/ContainerTypes.js +1 -0
  202. package/lib/local/localData.d.ts +5 -0
  203. package/lib/local/localData.js +1 -0
  204. package/lib/local/localDataNormal.d.ts +3 -0
  205. package/lib/local/localDataNormal.js +1 -0
  206. package/lib/local/localDataTypes.d.ts +14 -0
  207. package/lib/local/localDataTypes.js +1 -0
  208. package/lib/objects/Form/Form.d.ts +3 -0
  209. package/lib/objects/Form/Form.js +1 -0
  210. package/lib/objects/Form/FormField.d.ts +3 -0
  211. package/lib/objects/Form/FormField.js +1 -0
  212. package/lib/objects/Form/FormOption.d.ts +3 -0
  213. package/lib/objects/Form/FormOption.js +1 -0
  214. package/lib/objects/Form/FormTypes.d.ts +76 -0
  215. package/lib/objects/Form/FormTypes.js +1 -0
  216. package/lib/package.json +1 -0
  217. package/lib/redirects/redirects.d.ts +4 -0
  218. package/lib/redirects/redirects.js +1 -0
  219. package/lib/redirects/redirectsFile.d.ts +2 -0
  220. package/lib/redirects/redirectsFile.js +1 -0
  221. package/lib/render/render.d.ts +11 -0
  222. package/lib/render/render.js +1 -0
  223. package/lib/render/renderInline.d.ts +4 -0
  224. package/lib/render/renderInline.js +1 -0
  225. package/lib/render/renderTypes.d.ts +197 -0
  226. package/lib/render/renderTypes.js +1 -0
  227. package/lib/scripts/scripts.d.ts +8 -0
  228. package/lib/scripts/scripts.js +1 -0
  229. package/lib/scripts/scriptsTypes.d.ts +15 -0
  230. package/lib/scripts/scriptsTypes.js +1 -0
  231. package/lib/serverless/Contact/Contact.d.ts +3 -0
  232. package/lib/serverless/Contact/Contact.js +1 -0
  233. package/lib/serverless/Contact/ContactTypes.d.ts +13 -0
  234. package/lib/serverless/Contact/ContactTypes.js +1 -0
  235. package/lib/serverless/serverless.d.ts +12 -0
  236. package/lib/serverless/serverless.js +1 -0
  237. package/lib/serverless/serverlessTypes.d.ts +41 -0
  238. package/lib/serverless/serverlessTypes.js +1 -0
  239. package/lib/shortcodes/shortcodes.d.ts +10 -0
  240. package/lib/shortcodes/shortcodes.js +1 -0
  241. package/lib/shortcodes/shortcodesTypes.d.ts +20 -0
  242. package/lib/shortcodes/shortcodesTypes.js +1 -0
  243. package/lib/store/store.d.ts +9 -0
  244. package/lib/store/store.js +1 -0
  245. package/lib/store/storeFiles.d.ts +2 -0
  246. package/lib/store/storeFiles.js +1 -0
  247. package/lib/store/storeTypes.d.ts +28 -0
  248. package/lib/store/storeTypes.js +1 -0
  249. package/lib/text/RichText/RichText.d.ts +4 -0
  250. package/lib/text/RichText/RichText.js +1 -0
  251. package/lib/text/RichText/RichTextTypes.d.ts +54 -0
  252. package/lib/text/RichText/RichTextTypes.js +1 -0
  253. package/lib/utils/ResponseError/ResponseError.d.ts +5 -0
  254. package/lib/utils/ResponseError/ResponseError.js +1 -0
  255. package/lib/utils/archive/archive.d.ts +10 -0
  256. package/lib/utils/archive/archive.js +1 -0
  257. package/lib/utils/archive/archiveTypes.d.ts +29 -0
  258. package/lib/utils/archive/archiveTypes.js +1 -0
  259. package/lib/utils/array/array.d.ts +3 -0
  260. package/lib/utils/array/array.js +1 -0
  261. package/lib/utils/boolean/boolean.d.ts +2 -0
  262. package/lib/utils/boolean/boolean.js +1 -0
  263. package/lib/utils/contentType/contentType.d.ts +2 -0
  264. package/lib/utils/contentType/contentType.js +1 -0
  265. package/lib/utils/dataSource/dataSource.d.ts +3 -0
  266. package/lib/utils/dataSource/dataSource.js +1 -0
  267. package/lib/utils/dataSource/dataSourceTypes.d.ts +9 -0
  268. package/lib/utils/dataSource/dataSourceTypes.js +1 -0
  269. package/lib/utils/escape/escape.d.ts +2 -0
  270. package/lib/utils/escape/escape.js +1 -0
  271. package/lib/utils/excerpt/excerpt.d.ts +3 -0
  272. package/lib/utils/excerpt/excerpt.js +1 -0
  273. package/lib/utils/excerpt/excerptTypes.d.ts +14 -0
  274. package/lib/utils/excerpt/excerptTypes.js +1 -0
  275. package/lib/utils/file/file.d.ts +3 -0
  276. package/lib/utils/file/file.js +1 -0
  277. package/lib/utils/file/filePath.d.ts +2 -0
  278. package/lib/utils/file/filePath.js +1 -0
  279. package/lib/utils/function/function.d.ts +3 -0
  280. package/lib/utils/function/function.js +1 -0
  281. package/lib/utils/heading/heading.d.ts +2 -0
  282. package/lib/utils/heading/heading.js +1 -0
  283. package/lib/utils/image/image.d.ts +5 -0
  284. package/lib/utils/image/image.js +1 -0
  285. package/lib/utils/image/imageLocal.d.ts +3 -0
  286. package/lib/utils/image/imageLocal.js +1 -0
  287. package/lib/utils/image/imageRemote.d.ts +3 -0
  288. package/lib/utils/image/imageRemote.js +1 -0
  289. package/lib/utils/image/imageTypes.d.ts +69 -0
  290. package/lib/utils/image/imageTypes.js +1 -0
  291. package/lib/utils/json/json.d.ts +3 -0
  292. package/lib/utils/json/json.js +1 -0
  293. package/lib/utils/link/link.d.ts +6 -0
  294. package/lib/utils/link/link.js +1 -0
  295. package/lib/utils/link/linkShare.d.ts +3 -0
  296. package/lib/utils/link/linkShare.js +1 -0
  297. package/lib/utils/link/linkTypes.d.ts +28 -0
  298. package/lib/utils/link/linkTypes.js +1 -0
  299. package/lib/utils/map/map.d.ts +2 -0
  300. package/lib/utils/map/map.js +1 -0
  301. package/lib/utils/minify/minify.d.ts +2 -0
  302. package/lib/utils/minify/minify.js +1 -0
  303. package/lib/utils/number/number.d.ts +2 -0
  304. package/lib/utils/number/number.js +1 -0
  305. package/lib/utils/object/object.d.ts +4 -0
  306. package/lib/utils/object/object.js +1 -0
  307. package/lib/utils/object/objectUtils.d.ts +2 -0
  308. package/lib/utils/object/objectUtils.js +1 -0
  309. package/lib/utils/path/path.d.ts +3 -0
  310. package/lib/utils/path/path.js +1 -0
  311. package/lib/utils/print/print.d.ts +2 -0
  312. package/lib/utils/print/print.js +1 -0
  313. package/lib/utils/set/set.d.ts +3 -0
  314. package/lib/utils/set/set.js +1 -0
  315. package/lib/utils/string/string.d.ts +3 -0
  316. package/lib/utils/string/string.js +1 -0
  317. package/lib/utils/tag/tag.d.ts +4 -0
  318. package/lib/utils/tag/tag.js +1 -0
  319. package/lib/utils/tag/tagTypes.d.ts +6 -0
  320. package/lib/utils/tag/tagTypes.js +1 -0
  321. package/lib/utils/year/year.d.ts +2 -0
  322. package/lib/utils/year/year.js +1 -0
  323. package/lib/wordpress/wordpressData.d.ts +6 -0
  324. package/lib/wordpress/wordpressData.js +1 -0
  325. package/lib/wordpress/wordpressDataNormal.d.ts +9 -0
  326. package/lib/wordpress/wordpressDataNormal.js +1 -0
  327. package/lib/wordpress/wordpressDataTypes.d.ts +208 -0
  328. package/lib/wordpress/wordpressDataTypes.js +1 -0
  329. package/package.json +96 -0
@@ -0,0 +1,69 @@
1
+ import type { Source, GenericNumbers, ParentArgs } from '../../global/globalTypes.js';
2
+ import type { RenderFile } from '../../render/renderTypes.js';
3
+ import type { ColumnProps } from '../../layouts/Column/ColumnTypes.js';
4
+ import type { ContainerProps } from '../../layouts/Container/ContainerTypes.js';
5
+ import type sharp from 'sharp';
6
+ export interface ImageArgs {
7
+ data?: RenderFile;
8
+ classes?: string;
9
+ attr?: string;
10
+ alt?: string;
11
+ width?: string | number;
12
+ height?: string | number;
13
+ lazy?: boolean;
14
+ picture?: boolean;
15
+ quality?: number;
16
+ source?: Source | 'remote';
17
+ maxWidth?: number;
18
+ viewportWidth?: number;
19
+ sizes?: string;
20
+ format?: string;
21
+ params?: Record<string, string>;
22
+ }
23
+ export interface ImageReturn {
24
+ output: string;
25
+ src: string;
26
+ srcFallback: string;
27
+ srcset: string[];
28
+ sizes: string;
29
+ aspectRatio: number;
30
+ naturalWidth: number;
31
+ naturalHeight: number;
32
+ }
33
+ export type ImageReturnType<V extends false | true> = V extends true ? ImageReturn : string;
34
+ export type ImageSizesParents = ParentArgs & ColumnProps & ContainerProps;
35
+ export type ImageSizesParentsArgs = ParentArgs & ColumnProps<string, string | number> & ContainerProps<string, string | number>;
36
+ export interface ImageSizesArgs<T = ImageSizesParents> {
37
+ parents: T[];
38
+ widths: GenericNumbers;
39
+ maxWidths: GenericNumbers;
40
+ breakpoints: number[];
41
+ source?: Source;
42
+ viewportWidth?: number;
43
+ maxWidth?: number;
44
+ }
45
+ export interface ImageSizesReturn {
46
+ maxWidth: number;
47
+ sizes: string;
48
+ }
49
+ export interface ImageLocal {
50
+ instance: sharp.Sharp;
51
+ size: number;
52
+ format: string;
53
+ path: string;
54
+ newPath: string;
55
+ }
56
+ export interface ImageRemote {
57
+ path: string;
58
+ url: string;
59
+ format?: string;
60
+ }
61
+ export interface ImageProps {
62
+ path: string;
63
+ name: string;
64
+ type: string;
65
+ format: string;
66
+ width: number;
67
+ height: number;
68
+ size: number;
69
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,3 @@
1
+ declare const getJson: <T extends object>(value: string) => T | undefined;
2
+ declare const getJsonFile: <T>(path: string, store?: boolean) => Promise<(object & T) | undefined>;
3
+ export { getJson, getJsonFile };
@@ -0,0 +1 @@
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(o,m,k,k2){void 0===k2&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);desc&&!("get"in desc?!m.__esModule:desc.writable||desc.configurable)||(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}:function(o,m,k,k2){void 0===k2&&(k2=k),o[k2]=m[k]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}:function(o,v){o.default=v}),__importStar=this&&this.__importStar||function(){var ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o){var ar=[];for(var k in o)Object.prototype.hasOwnProperty.call(o,k)&&(ar[ar.length]=k);return ar},ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(null!=mod)for(var k=ownKeys(mod),i=0;i<k.length;i++)"default"!==k[i]&&__createBinding(result,mod,k[i]);return __setModuleDefault(result,mod),result}}();Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJsonFile=exports.getJson=void 0;const object_js_1=require("../object/object.js"),path_js_1=require("../path/path.js"),filters_js_1=require("../../filters/filters.js"),getJson=value=>{try{const val=JSON.parse(value);if((0,object_js_1.isObject)(val))return val;throw new Error("Parsed value is not an object")}catch{return}};exports.getJson=getJson;const getJsonFile=async(path,store=!1)=>{let res,newPath=path;try{newPath=store?(0,path_js_1.getPath)(path,"store"):path;const{default:obj}=await Promise.resolve(`${newPath}`).then(s=>__importStar(require(s)));if(!(0,object_js_1.isObject)(obj))throw new Error("No object in json file");res=obj}catch{res=void 0}return store?await(0,filters_js_1.applyFilters)("storeData",res,newPath,!0):res};exports.getJsonFile=getJsonFile;
@@ -0,0 +1,6 @@
1
+ import type { LinkSlugArgs, LinkSlugReturnType } from './linkTypes.js';
2
+ import type { InternalLink } from '../../global/globalTypes.js';
3
+ declare const getSlug: <T extends boolean = false>(args: LinkSlugArgs, returnParents?: T) => LinkSlugReturnType<T>;
4
+ declare const getPermalink: (slug?: string, trailingSlash?: boolean) => string;
5
+ declare const getLink: (internalLink?: InternalLink, externalLink?: string) => string;
6
+ export { getSlug, getLink, getPermalink };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPermalink=exports.getLink=exports.getSlug=void 0;const object_js_1=require("../object/object.js"),string_js_1=require("../string/string.js"),filters_js_1=require("../../filters/filters.js"),archive_js_1=require("../archive/archive.js"),store_js_1=require("../../store/store.js"),config_js_1=require("../../config/config.js"),getParentSlug=(id,contentType,parents,taxonomy,locale)=>{const storeParents=(0,store_js_1.getStoreItem)("parents"),parent=storeParents[contentType]?.[id];if(parent){const[parentId,parentSlug,parentTitle]=parent,newParent={id:parentId,slug:parentSlug,title:parentTitle,contentType:contentType,locale:locale};"term"===contentType&&(newParent.taxonomy=taxonomy),parents.unshift(newParent),getParentSlug(parentId,contentType,parents,taxonomy,locale)}},getSlug=(args,returnParents=!1)=>{const{id:id="",slug:initSlug="",contentType:contentType="page",itemData:itemData,params:params}=(0,object_js_1.isObjectStrict)(args)?args:{};let slug=initSlug,typeSlug="",taxSlug="",parentSlugs="",parts=[];const{hierarchicalTypes:hierarchicalTypes,typeInSlug:typeInSlug,localeInSlug:localeInSlug,taxonomyInSlug:taxonomyInSlug}=config_js_1.config,itemLocale=(0,string_js_1.isStringStrict)(itemData?.locale)?itemData.locale:void 0,hasItemLocale=null!=itemLocale,locale=hasItemLocale?localeInSlug[itemLocale]:"",hasLocale=(0,string_js_1.isStringStrict)(locale),taxonomyInfo=(0,archive_js_1.getTaxonomyInfo)(contentType,itemData),isTaxonomy="taxonomy"===contentType,isTerm="term"===contentType,{id:taxonomyId,slug:taxonomySlug,primaryContentType:taxonomyType,usePrimaryContentTypeSlug:taxonomyUseTypeSlug,isPage:taxonomyIsPage}=taxonomyInfo,archiveType=(0,string_js_1.isStringStrict)(taxonomyType)?taxonomyType:contentType,archiveInfo=(0,archive_js_1.getArchiveInfo)(archiveType,itemLocale),{id:archiveId,slug:archiveSlug,title:archiveTitle,contentType:archiveContentType}=archiveInfo,archiveParents=[];if(archiveSlug&&archiveId&&(typeSlug=archiveSlug,archiveParents.push({contentType:archiveContentType,title:archiveTitle,slug:archiveSlug,id:archiveId,locale:itemLocale})),!isTaxonomy&&!isTerm||taxonomyUseTypeSlug||(typeSlug=""),isTerm&&taxonomySlug&&taxonomyId){taxSlug=taxonomySlug;const taxInSlug=taxonomyInSlug[taxSlug];if((0,string_js_1.isString)(taxInSlug)&&(taxSlug=taxInSlug),(0,object_js_1.isObjectStrict)(taxInSlug)&&hasItemLocale){const localizedTaxSlug=taxInSlug[itemLocale];(0,string_js_1.isString)(localizedTaxSlug)&&(taxSlug=localizedTaxSlug)}taxonomyIsPage&&archiveParents.push({contentType:"taxonomy",locale:itemLocale,...taxonomyInfo})}const contentTypeInSlug=typeInSlug[archiveType];if((0,string_js_1.isString)(contentTypeInSlug)&&(typeSlug=contentTypeInSlug),(0,object_js_1.isObjectStrict)(contentTypeInSlug)&&hasItemLocale){const localizedTypeSlug=contentTypeInSlug[itemLocale];(0,string_js_1.isString)(localizedTypeSlug)&&(typeSlug=localizedTypeSlug)}const isHierarchical=hierarchicalTypes.includes(contentType);let parents=[],hasParents=!1;getParentSlug(isHierarchical?id:archiveId,isHierarchical?contentType:archiveContentType,parents,taxonomyInfo,itemLocale),parents.length&&(parentSlugs=parents.map(({slug:slug})=>slug).join("/"),hasParents=!0),parents=isHierarchical?[...archiveParents,...parents]:[...parents,...archiveParents];const isIndex="index"===slug;if(isIndex&&!returnParents&&(slug=""),hasLocale&&parts.push(locale),hasParents&&!isHierarchical&&parts.push(parentSlugs),typeSlug&&parts.push(typeSlug),taxSlug&&parts.push(taxSlug),hasParents&&isHierarchical&&parts.push(parentSlugs),(0,string_js_1.isStringStrict)(slug)&&!isIndex&&parts.push(slug),parts=(0,filters_js_1.applyFilters)("slugParts",parts,args),params){const paramsStr=new URLSearchParams(params).toString();paramsStr&&parts.push(`?${paramsStr}`)}let fullSlug=parts.length?parts.join("/"):"";if(fullSlug=(0,filters_js_1.applyFilters)("slug",fullSlug,args),returnParents){return{slug:fullSlug,parents:parents}}return fullSlug};exports.getSlug=getSlug;const getPermalink=(slug="",trailingSlash=!0)=>{let url="";if(config_js_1.config.env.prod&&(url=config_js_1.config.env.prodUrl),!(0,string_js_1.isStringStrict)(slug)||"/"===slug)return`${url}/`;const hasStartSlash=slug.startsWith("/"),hasEndSlash=slug.endsWith("/");return hasStartSlash||(slug=`/${slug}`),!hasEndSlash&&trailingSlash&&(slug=`${slug}/`),`${url}${slug}`};exports.getPermalink=getPermalink;const getLink=(internalLink,externalLink)=>{if((0,object_js_1.isObjectStrict)(internalLink)){const slug=internalLink.slug,res=getSlug({id:internalLink.id,contentType:internalLink.contentType,itemData:internalLink,slug:(0,string_js_1.isString)(slug)?slug:""});return getPermalink(res)}return(0,string_js_1.isStringStrict)(externalLink)?externalLink:""};exports.getLink=getLink;
@@ -0,0 +1,3 @@
1
+ import type { LinkShare, LinkShareReturn } from './linkTypes.js';
2
+ declare const getShareLinks: (url: string, platforms: Array<keyof LinkShare>, title?: string) => LinkShareReturn[];
3
+ export { getShareLinks };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getShareLinks=void 0;const string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),shareLinks={Facebook:"https://www.facebook.com/sharer.php?u=",X:"https://twitter.com/intent/tweet?url=",LinkedIn:"https://www.linkedin.com/shareArticle?url=",Pinterest:"https://pinterest.com/pin/create/button/?url=",Reddit:"https://reddit.com/submit?url=",Email:""},getShareLinks=(url,platforms,title)=>(0,string_js_1.isStringStrict)(url)&&(0,array_js_1.isArrayStrict)(platforms)?platforms.map(platform=>{const platformLink=shareLinks[platform];let link=(0,string_js_1.isStringStrict)(platformLink)?`${platformLink}${url}`:"";return"Email"===platform&&(link=`mailto:?subject=${encodeURIComponent((0,string_js_1.isStringStrict)(title)?title:"Check out this article")}&body=${url}`),{type:platform,link:link}}):[];exports.getShareLinks=getShareLinks;
@@ -0,0 +1,28 @@
1
+ import type { RenderItem } from '../../render/renderTypes.js';
2
+ import type { Parent } from '../../global/globalTypes.js';
3
+ export interface LinkSlugArgs {
4
+ slug: string;
5
+ id?: string;
6
+ contentType?: string;
7
+ itemData?: RenderItem;
8
+ params?: Record<string, string> | string;
9
+ }
10
+ export interface LinkSlugReturn {
11
+ slug: string;
12
+ parents: Parent[];
13
+ }
14
+ export type LinkSlugReturnType<T extends boolean> = T extends true ? LinkSlugReturn : string;
15
+ export interface LinkShare {
16
+ Facebook: string;
17
+ X: string;
18
+ LinkedIn: string;
19
+ Pinterest: string;
20
+ Reddit: string;
21
+ Email: string;
22
+ }
23
+ export interface LinkShareReturn {
24
+ type: keyof Partial<LinkShare>;
25
+ link: string;
26
+ }
27
+ export type LinkSlugPartsFilter = (parts: string[], args: LinkSlugArgs) => string[];
28
+ export type LinkSlugFilter = (slug: string, args: LinkSlugArgs) => string;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,2 @@
1
+ declare const isMap: <T, U>(value: unknown) => value is Map<T, U>;
2
+ export { isMap };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isMap=void 0;const isMap=value=>value instanceof Map;exports.isMap=isMap;
@@ -0,0 +1,2 @@
1
+ declare const minify: (value: string) => string;
2
+ export { minify };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.minify=void 0;const minify=value=>value.replace(/\s+/g," ").replace(/>\s+</g,"><").trim();exports.minify=minify;
@@ -0,0 +1,2 @@
1
+ declare const isNumber: (value: unknown) => value is number;
2
+ export { isNumber };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isNumber=void 0;const isNumber=value=>"number"==typeof value&&!isNaN(value);exports.isNumber=isNumber;
@@ -0,0 +1,4 @@
1
+ declare const isObject: <T>(value: T) => value is object & T;
2
+ type NotObject<T, K> = Exclude<T, string | number | boolean | Map<T, K> | Set<T> | FormData | null | undefined | unknown[] | string[] | number[] | boolean[]>;
3
+ declare const isObjectStrict: <T, K>(value: T) => value is object & NotObject<T, K>;
4
+ export { isObject, isObjectStrict };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isObjectStrict=exports.isObject=void 0;const isObject=value=>"object"==typeof value&&null!=value;exports.isObject=isObject;const isObjectStrict=value=>isObject(value)&&"[object Object]"===Object.prototype.toString.call(value);exports.isObjectStrict=isObjectStrict;
@@ -0,0 +1,2 @@
1
+ declare const getObjectKeys: <T>(obj: T) => Array<keyof T>;
2
+ export { getObjectKeys };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getObjectKeys=void 0;const getObjectKeys=obj=>Object.keys(obj);exports.getObjectKeys=getObjectKeys;
@@ -0,0 +1,3 @@
1
+ declare const getPath: (file: string, type?: string) => string;
2
+ declare const getPathDepth: (path?: string) => string;
3
+ export { getPath, getPathDepth };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPathDepth=exports.getPath=void 0;const string_js_1=require("../string/string.js"),config_js_1=require("../../config/config.js"),store_js_1=require("../../store/store.js"),getPath=(file,type)=>{const root=config_js_1.config.env.dir;if(!(0,string_js_1.isStringStrict)(root)||!(0,string_js_1.isStringStrict)(file))return"";let append=file;return"store"===type&&(append=`${store_js_1.storeDir}/${file}.json`),`${root}${root.endsWith("/")?"":"/"}${append}`};exports.getPath=getPath;const getPathDepth=(path="")=>{if(!(0,string_js_1.isStringStrict)(path))return"";let pathDepth=path.split("/");return pathDepth.pop(),pathDepth=pathDepth.map(()=>"../"),pathDepth.join("")};exports.getPathDepth=getPathDepth;
@@ -0,0 +1,2 @@
1
+ declare const print: (pre: string | undefined, message: unknown, type?: "error" | "warning" | "success" | "info") => void;
2
+ export { print };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.print=void 0;const array_js_1=require("../array/array.js"),print=(pre="Log",message,type="error")=>{const output=`${pre}: \n${((0,array_js_1.isArray)(message)?message:[message]).join("\n").trim()}`;"error"===type&&console.error(`${output}`),"warning"===type&&console.warn(`${output}`),"success"===type&&console.info(`${output}`),"info"===type&&console.info(`${output}`)};exports.print=print;
@@ -0,0 +1,3 @@
1
+ declare const isSet: <T>(value: unknown) => value is Set<T>;
2
+ declare const isSetStrict: <T>(value: unknown) => value is Set<T>;
3
+ export { isSet, isSetStrict };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isSetStrict=exports.isSet=void 0;const isSet=value=>value instanceof Set;exports.isSet=isSet;const isSetStrict=value=>isSet(value)&&value.size>0;exports.isSetStrict=isSetStrict;
@@ -0,0 +1,3 @@
1
+ declare const isString: (value: unknown) => value is string;
2
+ declare const isStringStrict: (value: unknown) => value is string;
3
+ export { isString, isStringStrict };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isStringStrict=exports.isString=void 0;const isString=value=>"string"==typeof value;exports.isString=isString;const isStringStrict=value=>isString(value)&&""!==value;exports.isStringStrict=isStringStrict;
@@ -0,0 +1,4 @@
1
+ import type { TagGet, TagExists } from './tagTypes.js';
2
+ declare const getTag: TagGet;
3
+ declare const tagExists: TagExists;
4
+ export { getTag, tagExists };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tagExists=exports.getTag=void 0;const object_js_1=require("../object/object.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),getTag=(item,id)=>{if(!(0,object_js_1.isObjectStrict)(item)||!(0,string_js_1.isStringStrict)(id))return;const tags=item.metadata?.tags;if(!(0,array_js_1.isArrayStrict)(tags))return;let tagInfo;return tags.find(tag=>{if(!(0,object_js_1.isObjectStrict)(tag))return!1;const tagId=tag.id;return tagId===id&&(tagInfo={id:tagId},!0)}),tagInfo};exports.getTag=getTag;const tagExists=(item,id)=>null!=getTag(item,id);exports.tagExists=tagExists;
@@ -0,0 +1,6 @@
1
+ import type { RenderItem } from '../../render/renderTypes.js';
2
+ export type TagGet = (item: RenderItem, id: string) => TagGetReturn | undefined;
3
+ export type TagExists = (item: RenderItem, id: string) => boolean;
4
+ export interface TagGetReturn {
5
+ id: string;
6
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,2 @@
1
+ declare const getYear: () => number;
2
+ export { getYear };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getYear=void 0;const getYear=()=>(new Date).getFullYear();exports.getYear=getYear;
@@ -0,0 +1,6 @@
1
+ import type { AllWordPressDataArgs, WordPressDataArgs } from './wordpressDataTypes.js';
2
+ import type { RenderAllData, RenderData } from '../render/renderTypes.js';
3
+ declare const getRoute: (type: string) => string;
4
+ declare const getWordPressData: (args: WordPressDataArgs, _page?: number) => Promise<RenderData>;
5
+ declare const getAllWordPressData: (args?: AllWordPressDataArgs) => Promise<RenderAllData | undefined>;
6
+ export { getRoute, getWordPressData, getAllWordPressData };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getAllWordPressData=exports.getWordPressData=exports.getRoute=void 0;const wordpressDataNormal_js_1=require("./wordpressDataNormal.js"),filters_js_1=require("../filters/filters.js"),object_js_1=require("../utils/object/object.js"),string_js_1=require("../utils/string/string.js"),array_js_1=require("../utils/array/array.js"),store_js_1=require("../store/store.js"),config_js_1=require("../config/config.js"),getRoute=type=>{const route=wordpressDataNormal_js_1.normalRoutes.get(type);return(0,string_js_1.isString)(route)?route:type};exports.getRoute=getRoute;const getWordPressData=async(args,_page=1)=>{if(!(0,object_js_1.isObjectStrict)(args))throw new Error("No args");const{key:key,route:route,params:params,fetcher:fetcher=fetch,options:options}=args;if(!(0,string_js_1.isStringStrict)(key))throw new Error("No key");if(config_js_1.config.env.cache){const cacheDataFilterArgs={key:key,type:"get"},cacheData=await(0,filters_js_1.applyFilters)("cacheData",void 0,cacheDataFilterArgs,!0);if((0,object_js_1.isObject)(cacheData))return structuredClone(cacheData)}if(!(0,string_js_1.isStringStrict)(route))throw new Error("No route");const{devUser:devUser,prodUser:prodUser,devCredential:devCredential,prodCredential:prodCredential,devHost:devHost,prodHost:prodHost,ssl:ssl=!0}=config_js_1.config.cms;let user=devUser,pass=devCredential,host=devHost,status="any";if(config_js_1.config.env.prod&&(user=prodUser,pass=prodCredential,host=prodHost,status="publish"),!(0,string_js_1.isStringStrict)(user)||!(0,string_js_1.isStringStrict)(pass)||!(0,string_js_1.isStringStrict)(host))throw new Error("No credentials");let url=`${ssl?"https":"http"}://${host}/wp-json/wp/v2/${route}?status=${status}`,loop=!1,embed=!1;if((0,object_js_1.isObjectStrict)(params))for(const[key,value]of Object.entries(params)){let val=value;"_embed"===key&&(embed=!0),"per_page"===key&&-1===value&&(val=100,loop=!0),url+=`&${key}=${val.toString()}`}loop&&(url+=`&page=${_page}`),embed||(url+="&_embed");const headers=new Headers;headers.set("Authorization",`Basic ${btoa(`${user}:${pass}`)}`);const resp=await fetcher(url,{headers:headers,...options}),data=await resp.json(),isErr=(0,object_js_1.isObjectStrict)(data)&&(0,string_js_1.isStringStrict)(data.message),message=isErr?data.message:"Bad fetch response";if(!resp.ok||isErr)throw new Error(message,{cause:data});const total=resp.headers.get("X-WP-Total"),totalPages=resp.headers.get("X-WP-TotalPages"),totalNum=(0,string_js_1.isStringStrict)(total)?parseInt(total,10):0,totalPagesNum=(0,string_js_1.isStringStrict)(totalPages)?parseInt(totalPages,10):0,dataItems=(0,array_js_1.isArray)(data)?data:[data];let newItems=(0,wordpressDataNormal_js_1.normalizeWordPressData)(dataItems,route);if(loop&&_page<totalPagesNum){const pagData=await getWordPressData({key:key,route:route,params:{per_page:-1}},_page+1),{items:pagItems}=pagData;newItems=[...newItems,...pagItems]}const newData={items:newItems,total:totalNum,pages:totalPagesNum};if(config_js_1.config.env.cache){const cacheDataFilterArgs={key:key,type:"set",data:data};await(0,filters_js_1.applyFilters)("cacheData",newData,cacheDataFilterArgs,!0)}return newData};exports.getWordPressData=getWordPressData;const getAllWordPressData=async args=>{const{serverlessData:serverlessData,previewData:previewData}=(0,object_js_1.isObjectStrict)(args)?args:{};let allData={navigationItem:[],navigation:[],content:{page:[]}};const isServerless=null!=serverlessData,isPreview=null!=previewData,wordpressDataFilterArgs={serverlessData:serverlessData,previewData:previewData};if(isServerless||isPreview){let contentType="",id="";if(isServerless){const item=(0,store_js_1.getStoreItem)("slugs")[serverlessData.path];if(item){const[itemId,itemContentType]=item;id=itemId||"",contentType=itemContentType||""}}if(isPreview&&(id=previewData.id,contentType=previewData.contentType),id){const key=`serverless_${id}_${contentType}`,data=await getWordPressData({key:key,route:`${getRoute(contentType)}/${id}`});let{items:items}=data;items=(0,filters_js_1.applyFilters)("wordpressData",items,{...wordpressDataFilterArgs,contentType:contentType}),allData.content[contentType]=items}}if(!isServerless){const partial=config_js_1.config.partialTypes;for(const contentType of partial){const isMenu="nav_menu"===contentType,isMenuItem="nav_menu_item"===contentType,partialType=isMenu?"navigation":isMenuItem?"navigationItem":contentType;allData[partialType]=[];const key=`all_${contentType}`,data=await getWordPressData({key:key,route:getRoute(contentType),params:{per_page:-1}});let{items:items}=data;isMenuItem&&(items=(0,wordpressDataNormal_js_1.normalizeWordPressMenuItems)(items)),isMenu&&(items=(0,wordpressDataNormal_js_1.normalizeWordPressMenus)(items)),items=(0,filters_js_1.applyFilters)("wordpressData",items,{...wordpressDataFilterArgs,contentType:contentType}),allData[partialType]=items}}if(!isServerless&&!isPreview){const whole=config_js_1.config.wholeTypes;for(const contentType of whole){allData.content[contentType]=[];const key=`all_${contentType}`,data=await getWordPressData({key:key,route:getRoute(contentType),params:{per_page:-1}});let{items:items}=data;items=(0,filters_js_1.applyFilters)("wordpressData",items,{...wordpressDataFilterArgs,contentType:contentType}),allData.content[contentType]=items}}return allData=(0,filters_js_1.applyFilters)("allData",allData,{type:"wordpress",serverlessData:serverlessData,previewData:previewData}),allData};exports.getAllWordPressData=getAllWordPressData;
@@ -0,0 +1,9 @@
1
+ import type { WordPressDataItem, WordPressDataMenuItem, WordPressDataMenu } from './wordpressDataTypes.js';
2
+ import type { RenderItem } from '../render/renderTypes.js';
3
+ import type { NavigationList, NavigationItem } from '../components/Navigation/NavigationTypes.js';
4
+ declare const normalRoutes: Map<string, string>;
5
+ declare const normalMetaKeys: Map<string, string>;
6
+ declare const normalizeWordPressMenuItems: (items: WordPressDataMenuItem[]) => NavigationItem[];
7
+ declare const normalizeWordPressMenus: (menus: WordPressDataMenu[]) => NavigationList[];
8
+ declare const normalizeWordPressData: (data: WordPressDataItem[], route?: string, _newData?: RenderItem[]) => RenderItem[];
9
+ export { normalizeWordPressData, normalizeWordPressMenuItems, normalizeWordPressMenus, normalRoutes, normalMetaKeys };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalMetaKeys=exports.normalRoutes=exports.normalizeWordPressMenus=exports.normalizeWordPressMenuItems=exports.normalizeWordPressData=void 0;const block_serialization_default_parser_1=require("@wordpress/block-serialization-default-parser"),contentType_js_1=require("../utils/contentType/contentType.js"),objectUtils_js_1=require("../utils/object/objectUtils.js"),store_js_1=require("../store/store.js"),string_js_1=require("../utils/string/string.js"),array_js_1=require("../utils/array/array.js"),object_js_1=require("../utils/object/object.js"),number_js_1=require("../utils/number/number.js"),config_js_1=require("../config/config.js"),normalRoutes=new Map([["page","pages"],["post","posts"],["taxonomy","taxonomies"],["category","categories"],["tag","tags"],["attachment","media"],["nav_menu","menus"],["nav_menu_item","menu-items"]]);exports.normalRoutes=normalRoutes;const normalMetaKeys=new Map;exports.normalMetaKeys=normalMetaKeys;const menusById=new Map,excludeProps=["_links","auto_add"],getTaxonomy=id=>{const taxonomy=(0,store_js_1.getStoreItem)("taxonomies")[id],{title:title="",slug:slug="",contentTypes:contentTypes=[]}=(0,object_js_1.isObjectStrict)(taxonomy)?taxonomy:{};return{id:id,title:title,slug:slug,contentTypes:contentTypes}},normalizeFile=file=>{const{url:url,filename:filename,alt:alt,width:width,height:height,filesizeInBytes:filesizeInBytes,subtype:subtype,mime:mime,sizes:sizes}=file;let newSizes;if((0,object_js_1.isObjectStrict)(sizes)){newSizes={};for(const[,value]of Object.entries(sizes)){const{width:width,source_url:src}=value;let{url:url}=value;(0,string_js_1.isStringStrict)(src)&&(url=src),(0,number_js_1.isNumber)(width)&&(0,string_js_1.isStringStrict)(url)&&(newSizes[width]=url)}}return{url:(0,string_js_1.isString)(url)?url:"",name:(0,string_js_1.isString)(filename)?filename:"",alt:(0,string_js_1.isString)(alt)?alt:"",width:(0,number_js_1.isNumber)(width)?width:0,height:(0,number_js_1.isNumber)(height)?height:0,size:(0,number_js_1.isNumber)(filesizeInBytes)?filesizeInBytes:0,format:"jpeg"===subtype?"jpg":subtype,type:mime,sizes:newSizes}},normalizeEmbedded=(value,item,newItem)=>{(0,objectUtils_js_1.getObjectKeys)(value).forEach(k=>{const embeds=value[k];if((0,array_js_1.isArrayStrict)(embeds)){if("author"===k){const exclude=[...excludeProps,"id","avatar_urls"];embeds.forEach(embed=>{if(!(0,object_js_1.isObjectStrict)(embed))return;const{id:id}=embed;if(item.author!==id)return;const newAuthor={id:id.toString()};Object.entries(embed).forEach(([key,val])=>{exclude.includes(key)||(newAuthor[key]=val)}),newItem.author=newAuthor})}if("up"===k&&embeds.forEach(embed=>{if(!(0,object_js_1.isObjectStrict)(embed))return;const{id:id,title:parentTitle,name:name,type:type,taxonomy:taxonomy,slug:slug}=embed;if(item.parent!==id)return;let title="";(0,string_js_1.isString)(parentTitle?.rendered)&&(title=parentTitle.rendered),(0,string_js_1.isString)(name)&&(title=name),newItem.parent={id:id.toString(),contentType:(0,string_js_1.isString)(taxonomy)?"term":type,title:title,slug:slug}}),"wp:featuredmedia"===k&&embeds.forEach(embed=>{if(!(0,object_js_1.isObjectStrict)(embed))return;const{id:id,source_url:url,media_details:details,mime_type:mimeType,alt_text:alt}=embed;if(!(0,object_js_1.isObjectStrict)(details))return;const{file:file,filesize:filesize,width:width,height:height,sizes:sizes}=details;item.featured_media===id&&(newItem.featured_media=normalizeFile({url:url,filename:file?.split("/").pop(),alt:alt,width:width,height:height,filesizeInBytes:filesize,subtype:mimeType?.split("/").pop(),mime:mimeType,sizes:sizes}))}),"wp:term"===k){const exclude=[...excludeProps,"id","name","taxonomy"];embeds.forEach(embed=>{(0,array_js_1.isArrayStrict)(embed)&&embed.forEach(e=>{if(!(0,object_js_1.isObjectStrict)(e))return;const{id:id,name:name,taxonomy:taxonomy=""}=e;let taxonomyLookup=taxonomy;"category"===taxonomy&&(taxonomyLookup="categories"),"post_tag"===taxonomy&&(taxonomyLookup="tags");const itemTaxonomy=newItem[taxonomyLookup]??item[taxonomyLookup];(0,array_js_1.isArrayStrict)(itemTaxonomy)&&(newItem[taxonomyLookup]=itemTaxonomy.map(taxonomyId=>{if(taxonomyId!==id)return taxonomyId;const newTerm={id:id.toString(),title:name,contentType:"term",taxonomy:getTaxonomy(taxonomy)};return Object.entries(e).forEach(([key,val])=>{exclude.includes(key)||(newTerm[key]=val)}),newTerm}))})})}}})},normalizeBlocks=blocks=>{const newItems=[];return blocks.forEach(block=>{const{blockName:blockName,attrs:attrs,innerBlocks:innerBlocks}=block,contentType=blockName;if(!(0,string_js_1.isStringStrict)(contentType))return;const{isItem:isItem}=attrs,attrItemArr=((0,string_js_1.isStringStrict)(isItem)?isItem:"").split(","),attrItemExists=attrItemArr.length;for(const[key,value]of Object.entries(attrs))if((0,object_js_1.isObjectStrict)(value)){if(attrItemExists&&attrItemArr.includes(key)){const itemValue=normalizeItem(value);itemValue.content=void 0,attrs[key]=itemValue}(0,string_js_1.isStringStrict)(value.mime)&&(attrs[key]=normalizeFile(value))}const newItem={contentType:contentType,...attrs},renderType=config_js_1.config.renderTypes[contentType];return(0,string_js_1.isString)(renderType)&&(newItem.renderType=renderType),(0,array_js_1.isArrayStrict)(innerBlocks)&&(newItem.content=normalizeBlocks(innerBlocks)),newItems.push(newItem)}),newItems},normalizeItem=item=>{const newItem={};for(const[key,value]of Object.entries(item)){if(excludeProps.includes(key))continue;let val=value,k=key;const isObj=(0,object_js_1.isObjectStrict)(value),isStr=(0,string_js_1.isStringStrict)(value);if("id"!==key&&"object_id"!==k||(val=value?.toString()),"type"===key&&isStr)newItem.contentType=(0,contentType_js_1.normalizeContentType)(value),(0,string_js_1.isString)(config_js_1.config.renderTypes[value])&&(newItem.renderType=config_js_1.config.renderTypes[value]);else{if("types"===key&&(k="contentTypes"),isObj){const{rendered:rendered}=value;(0,string_js_1.isString)(rendered)&&(val=rendered)}if("name"===key&&(k="title"),"_embedded"===key&&isObj)normalizeEmbedded(value,item,newItem);else{if((0,string_js_1.isStringStrict)(val)){if("excerpt"===key&&(val=val.replace(/<[^>]*>|\[.*?\]/g,"").trim()),"content"===key){const normalVal=normalizeBlocks((0,block_serialization_default_parser_1.parse)(val));val=normalVal.length?normalVal:val}"taxonomy"===key&&(newItem.contentType="term",val=getTaxonomy(val))}if("meta"===key&&isObj)for(const[metaKey,metaValue]of Object.entries(val)){newItem[normalMetaKeys.get(metaKey)??metaKey]=metaValue}else{if("media_details"===k&&isObj){const valObj=val,valFull=valObj.sizes?.full,sourceUrl=item.source_url,mimeType=item.mime_type;val=normalizeFile({url:sourceUrl,filename:sourceUrl?.split("/").pop(),alt:item.alt_text,width:valFull?.width,height:valFull?.height,filesizeInBytes:valObj.filesize,subtype:mimeType?.split("/")[1],mime:mimeType,sizes:valObj.sizes})}newItem[k]=val}}}}return newItem},normalizeWordPressMenuItems=items=>{const itemsObj=Object.fromEntries(items.map(item=>[item.id,item]));menusById.clear(),items.forEach(item=>{const{id:id="",title:title="",menu_order:menu_order=0,menus:menus=0}=item,parent=item.parent,hasMenuOrder=(0,number_js_1.isNumber)(menu_order);if(hasMenuOrder&&(0,object_js_1.isObjectStrict)(itemsObj[parent])&&(null==itemsObj[parent].children&&(itemsObj[parent].children=[]),itemsObj[parent].children.push({id:id,menu_order:menu_order,title:title})),hasMenuOrder&&(0,number_js_1.isNumber)(menus)&&0===parent){const menuId=menus.toString();null==menusById.get(menuId)&&menusById.set(menuId,[]),menusById.get(menuId)?.push({id:id,menu_order:menu_order,title:title})}});const newItems=[];for(const[id,obj]of Object.entries(itemsObj)){const{url:url="",title:title="",contentType:contentType="",children:children=[],object:object="",object_id:object_id="",locale:locale=""}=obj;if(!(0,string_js_1.isString)(url)||!(0,string_js_1.isStringStrict)(title))continue;const newItem={id:id,title:title},isCustom="custom"===contentType;if(!isCustom&&(0,string_js_1.isStringStrict)(object)&&(0,string_js_1.isStringStrict)(object_id)){const isTerm="taxonomy"===contentType,internalLink={contentType:isTerm?"term":object,id:object_id,slug:url.split("/").filter(Boolean).pop()};isTerm&&(internalLink.taxonomy=getTaxonomy(object)),(0,string_js_1.isStringStrict)(locale)&&(internalLink.locale=locale),newItem.link=url,newItem.internalLink=internalLink}if(isCustom){url.startsWith("http")&&!url.startsWith(config_js_1.config.env.prodUrl)?newItem.externalLink=url:newItem.link=url}(0,array_js_1.isArrayStrict)(children)&&(newItem.children=children.sort((a,b)=>a.menu_order-b.menu_order));const exclude=[...excludeProps,"url","type","type_label","object","object_id","invalid","meta","menu_order","menus","parent","contentType","status"];Object.entries(obj).forEach(([key,val])=>{exclude.includes(key)||(newItem[key]=val)}),newItems.push(newItem)}return newItems};exports.normalizeWordPressMenuItems=normalizeWordPressMenuItems;const normalizeWordPressMenus=menus=>{const newMenus=[];return menus.forEach(menu=>{const{id:id="",title:title="",description:description="",locations:locations=[],meta:meta=[]}=menu,newMenu={id:id,title:title,description:description,meta:meta,location:locations,items:menusById.get(id)?.sort((a,b)=>a.menu_order-b.menu_order)??[]};newMenus.push(newMenu)}),newMenus};exports.normalizeWordPressMenus=normalizeWordPressMenus;const normalizeWordPressData=(data,route,_newData=[])=>(0,array_js_1.isArrayStrict)(data)?("taxonomies"===route&&(data=Object.entries(data[0]).map(([key,value])=>({id:key,type:"taxonomy",...value}))),data.forEach(item=>{(0,object_js_1.isObjectStrict)(item)&&_newData.push(normalizeItem(item))}),"taxonomies"===route&&_newData.forEach(item=>{(0,store_js_1.setStoreItem)("taxonomies",item,item.id)}),_newData):[];exports.normalizeWordPressData=normalizeWordPressData;
@@ -0,0 +1,208 @@
1
+ import type { Generic, GenericStrings } from '../global/globalTypes.js';
2
+ import type { NavigationItem } from '../components/Navigation/NavigationTypes.js';
3
+ import type { RenderServerlessData, RenderPreviewData, RenderItem } from '../render/renderTypes.js';
4
+ export type WordPressDataParams = Record<string, string | number | boolean>;
5
+ interface WordPressDataErrorData {
6
+ status?: number;
7
+ params?: GenericStrings;
8
+ details?: Generic;
9
+ }
10
+ export interface WordPressDataError {
11
+ code?: string;
12
+ message?: string;
13
+ data?: WordPressDataErrorData;
14
+ }
15
+ export type WordPressDataStatus = 'publish' | 'draft' | 'future' | 'pending' | 'private' | 'trash' | 'auto-draft' | 'inherit';
16
+ export interface WordPressDataRendered {
17
+ rendered?: string;
18
+ }
19
+ export interface WordPressDataRenderedProtected {
20
+ rendered?: string;
21
+ protected?: boolean;
22
+ }
23
+ export interface WordPressDataMenuChild extends NavigationItem {
24
+ menu_order: number;
25
+ }
26
+ export interface WordPressDataMenuItem extends RenderItem {
27
+ children?: WordPressDataMenuChild[];
28
+ }
29
+ export interface WordPressDataMenu extends RenderItem {
30
+ name?: string;
31
+ locations?: string[];
32
+ }
33
+ export interface WordPressDataAuthor {
34
+ id: number;
35
+ name?: string;
36
+ url?: string;
37
+ description?: string;
38
+ link?: string;
39
+ slug?: string;
40
+ }
41
+ export interface WordPressDataMediaDetails {
42
+ width?: number;
43
+ height?: number;
44
+ filesize?: number;
45
+ file?: string;
46
+ sizes?: Record<string, WordPressDataMediaSize>;
47
+ }
48
+ export interface WordPressDataMediaSize {
49
+ source_url?: string;
50
+ mime_type?: string;
51
+ file?: string;
52
+ filesize?: number;
53
+ width?: number;
54
+ height?: number;
55
+ }
56
+ export interface WordPressDataFeaturedMedia {
57
+ id: number;
58
+ source_url?: string;
59
+ alt_text?: string;
60
+ caption?: WordPressDataRendered;
61
+ media_type?: string;
62
+ mime_type?: string;
63
+ media_details?: WordPressDataMediaDetails;
64
+ }
65
+ export interface WordPressDataTerm {
66
+ id: number;
67
+ link?: string;
68
+ name?: string;
69
+ slug?: string;
70
+ taxonomy?: string;
71
+ }
72
+ export interface WordPressDataAttachment {
73
+ id: number;
74
+ source_url?: string;
75
+ title?: WordPressDataRendered;
76
+ media_type?: string;
77
+ mime_type?: string;
78
+ }
79
+ export interface WordPressDataParent {
80
+ id: number;
81
+ title?: WordPressDataRendered;
82
+ excerpt?: WordPressDataRendered;
83
+ slug?: string;
84
+ type?: string;
85
+ link?: string;
86
+ author?: number;
87
+ featured_media?: number;
88
+ name?: string;
89
+ taxonomy?: string;
90
+ }
91
+ export interface WordPressDataEmbedded {
92
+ author?: WordPressDataAuthor[];
93
+ up?: WordPressDataParent[];
94
+ 'wp:featuredmedia'?: WordPressDataFeaturedMedia[];
95
+ 'wp:attachment'?: WordPressDataAttachment[];
96
+ 'wp:term'?: WordPressDataTerm[][];
97
+ }
98
+ export interface WordPressDataLink {
99
+ href: string;
100
+ name?: string;
101
+ templated?: boolean;
102
+ count?: number;
103
+ taxonomy?: string;
104
+ embeddable?: boolean;
105
+ }
106
+ export interface WordPressDataLinks {
107
+ self: WordPressDataLink[];
108
+ collection: WordPressDataLink[];
109
+ about: WordPressDataLink[];
110
+ 'version-history': WordPressDataLink[];
111
+ 'wp:attachment': WordPressDataLink[];
112
+ 'wp:term': WordPressDataLink[];
113
+ curies: WordPressDataLink[];
114
+ }
115
+ export interface WordPressDataFileSize {
116
+ height?: number;
117
+ width?: number;
118
+ url?: string;
119
+ source_url?: string;
120
+ orientation?: string;
121
+ }
122
+ interface WordPressDataFileNonces {
123
+ update: string;
124
+ delete: string;
125
+ edit: string;
126
+ }
127
+ export interface WordPressDataFile {
128
+ contentType?: string;
129
+ id?: number;
130
+ title?: string;
131
+ filename?: string;
132
+ url?: string;
133
+ link?: string;
134
+ alt?: string;
135
+ author?: string;
136
+ description?: string;
137
+ caption?: string;
138
+ name?: string;
139
+ status?: string;
140
+ uploadedTo?: number;
141
+ date?: string;
142
+ modified?: string;
143
+ menuOrder?: number;
144
+ mime?: string;
145
+ type?: string;
146
+ subtype?: string;
147
+ icon?: string;
148
+ dateFormatted?: string;
149
+ nonces?: WordPressDataFileNonces;
150
+ editLink?: string;
151
+ meta?: boolean;
152
+ authorName?: string;
153
+ authorLink?: string;
154
+ filesizeInBytes?: number;
155
+ filesizeHumanReadable?: string;
156
+ context?: string;
157
+ height?: number;
158
+ width?: number;
159
+ orientation?: string;
160
+ sizes?: Record<string, WordPressDataFileSize>;
161
+ }
162
+ export interface WordPressDataMeta extends Generic {
163
+ footnotes?: string;
164
+ }
165
+ export interface WordPressDataItem extends Partial<WordPressDataFeaturedMedia>, Generic {
166
+ id?: number;
167
+ date?: string;
168
+ date_gmt?: string;
169
+ guid?: WordPressDataRendered;
170
+ modified?: string;
171
+ modified_gmt?: string;
172
+ slug?: string;
173
+ status?: WordPressDataStatus;
174
+ type?: string;
175
+ link?: string;
176
+ title?: WordPressDataRendered;
177
+ content?: WordPressDataRenderedProtected;
178
+ excerpt?: WordPressDataRenderedProtected;
179
+ author?: number;
180
+ featured_media?: number;
181
+ parent?: number;
182
+ menu_order?: number;
183
+ comment_status?: string;
184
+ ping_status?: string;
185
+ sticky?: boolean;
186
+ template?: string;
187
+ format?: string;
188
+ meta?: WordPressDataMeta;
189
+ categories?: number[];
190
+ tags?: number[];
191
+ class_list?: string[];
192
+ taxonomy?: string;
193
+ name?: string;
194
+ _links?: WordPressDataLinks;
195
+ _embedded?: WordPressDataEmbedded;
196
+ }
197
+ export interface WordPressDataArgs {
198
+ key: string;
199
+ route: string;
200
+ params?: WordPressDataParams;
201
+ fetcher?: typeof fetch;
202
+ options?: RequestInit;
203
+ }
204
+ export interface AllWordPressDataArgs {
205
+ serverlessData?: RenderServerlessData;
206
+ previewData?: RenderPreviewData;
207
+ }
208
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,8 @@
1
+ import type { Actions, ActionMap, ActionReturnType } from './actionsTypes.js';
2
+ declare let actions: ActionMap;
3
+ declare const addAction: <T extends keyof Actions>(name: T, action: Actions[T]) => boolean;
4
+ declare const removeAction: <T extends keyof Actions>(name: T, action: Actions[T]) => boolean;
5
+ declare const doActions: <V extends boolean = false>(name: string, args?: unknown, isAsync?: V) => ActionReturnType<V>;
6
+ declare const resetActions: () => void;
7
+ declare const setActions: (args: Partial<Actions>) => boolean;
8
+ export { actions, addAction, removeAction, doActions, resetActions, setActions };
@@ -0,0 +1 @@
1
+ import{isSet,isSetStrict}from"../utils/set/set.js";import{isStringStrict}from"../utils/string/string.js";import{isObjectStrict}from"../utils/object/object.js";import{isFunction}from"../utils/function/function.js";let actions=new Map([["renderStart",new Set],["renderEnd",new Set],["renderItemStart",new Set],["renderItemEnd",new Set]]);const addAction=(name,action)=>!(!isStringStrict(name)||!isFunction(action))&&(isSet(actions.get(name))||actions.set(name,new Set),actions.get(name)?.add(action),!0),removeAction=(name,action)=>{if(!isStringStrict(name)||!isFunction(action))return!1;const actionSet=actions.get(name);return!!isSet(actionSet)&&actionSet.delete(action)},doSequentially=async(callbacks,args)=>{for(const callback of callbacks)await callback(args)},doActions=(name,args,isAsync=!1)=>{const actionSet=actions.get(name);if(!isSetStrict(actionSet))return;const callbacks=[];for(const callback of actionSet.values())isAsync?callbacks.push(callback):callback(args);isAsync&&doSequentially(callbacks,args).then(result=>result).catch(()=>{})},resetActions=()=>{actions=new Map([["renderStart",new Set],["renderEnd",new Set],["renderItemStart",new Set],["renderItemEnd",new Set]])},setActions=args=>{if(!isObjectStrict(args))return!1;const newActions=Object.entries(args);return!!newActions.length&&(resetActions(),newActions.forEach(([name,action])=>{action&&addAction(name,action)}),!0)};export{actions,addAction,removeAction,doActions,resetActions,setActions};
@@ -0,0 +1,10 @@
1
+ import type { GenericFunction } from '../global/globalTypes.js';
2
+ import type { RenderStartAction, RenderEndAction, RenderItemStartAction, RenderItemEndAction } from '../render/renderTypes.js';
3
+ export interface Actions extends Record<string, GenericFunction> {
4
+ renderStart: RenderStartAction;
5
+ renderEnd: RenderEndAction;
6
+ renderItemStart: RenderItemStartAction;
7
+ renderItemEnd: RenderItemEndAction;
8
+ }
9
+ export type ActionMap = Map<string, Set<GenericFunction>> & Map<'renderStart' | 'renderEnd' | 'renderItemStart' | 'renderItemEnd', Set<RenderStartAction | RenderEndAction | RenderItemStartAction | RenderItemEndAction>>;
10
+ export type ActionReturnType<V extends false | true> = V extends true ? Promise<void> : undefined;
@@ -0,0 +1 @@
1
+ export{};
@@ -0,0 +1,14 @@
1
+ import type { NavigationProps, NavigationList, NavigationByLocation, NavigationItem, NavigationItemsById, NavigationBreadcrumbItem, NavigationOutputArgs, NavigationBreadcrumbOutputArgs, NavigationByLocationItem } from './NavigationTypes.js';
2
+ declare class Navigation<L extends string = string> {
3
+ #private;
4
+ navigations: NavigationList[];
5
+ items: NavigationItem[];
6
+ init: boolean;
7
+ constructor(props: NavigationProps);
8
+ getOutput(location: L, args?: NavigationOutputArgs, maxDepth?: number): string;
9
+ getBreadcrumbs(items: NavigationBreadcrumbItem[], args?: NavigationBreadcrumbOutputArgs): string;
10
+ getItemsById(): NavigationItemsById;
11
+ getNavigationsByLocation(): NavigationByLocation<L>;
12
+ getNavigationByLocation(location: L): NavigationByLocationItem | undefined;
13
+ }
14
+ export { Navigation };
@@ -0,0 +1 @@
1
+ import{getSlug,getPermalink,getLink}from"../../utils/link/link.js";import{isArrayStrict}from"../../utils/array/array.js";import{isObjectStrict}from"../../utils/object/object.js";import{isStringStrict,isString}from"../../utils/string/string.js";import{isFunction}from"../../utils/function/function.js";import{isNumber}from"../../utils/number/number.js";import{normalizeContentType}from"../../utils/contentType/contentType.js";import{getArchiveMeta}from"../../utils/archive/archive.js";class Navigation{navigations=[];items=[];init=!1;#itemsById=new Map;#navigationsByLocation=new Map;constructor(props){this.init=this.#initialize(props)}#initialize(props){if(!isObjectStrict(props))return!1;const{navigations:navigations,items:items}=props;return!(!isArrayStrict(navigations)||!isArrayStrict(items))&&(this.navigations=navigations,this.items=items,this.items.forEach(item=>{isObjectStrict(item)&&this.#itemsById.set(item.id,item)}),this.navigations.forEach(nav=>{if(!isObjectStrict(nav))return;const{title:title,location:location,items:items=[]}=nav,locations=isArrayStrict(location)?location:[location];isStringStrict(title)&&isArrayStrict(items)&&locations.forEach(loc=>{this.#navigationsByLocation.set(loc,{title:title,items:items})})}),!0)}#recurseItemChildren(children,output,currentLink="",currentType=[]){let childCurrent=!1;return children.forEach(child=>{const newItem=this.#getItem(this.#itemsById.get(child?.id||""),currentLink,currentType);if(!newItem)return;const{current:current,archiveCurrent:archiveCurrent}=newItem;(current||archiveCurrent)&&(childCurrent=!0),output.push(newItem)}),childCurrent}#getItem(item,currentLink,currentType=[]){if(!isObjectStrict(item))return;const{id:id,title:title,link:link,internalLink:internalLink,externalLink:externalLink,children:children}=item;let external=!1;isStringStrict(externalLink)&&(external=!0);const newLink=isStringStrict(link)?link:getLink(internalLink,externalLink),newItem={...item,id:id,title:title,link:newLink,external:external};newLink&&!external&&(newItem.current=newLink===currentLink);const internalId=internalLink?.id;if(isStringStrict(internalId)){let archiveCurrent=!1;for(const type of currentType){if(internalId===getArchiveMeta(type,internalLink?.locale).id){archiveCurrent=!0;break}}newItem.archiveCurrent=archiveCurrent}let descendentCurrent=!1;if(isArrayStrict(children)){const newChildren=[];descendentCurrent=this.#recurseItemChildren(children,newChildren,currentLink,currentType),newItem.children=newChildren}return descendentCurrent&&(newItem.descendentCurrent=descendentCurrent),newItem}#getItems(items=[],currentLink,currentType){const resItems=[];return items.forEach(item=>{const newItem=this.#getItem(this.#itemsById.get(item?.id||""),currentLink,currentType);newItem&&resItems.push(newItem)}),resItems}#recurseOutput=(items,output,args,depth=0,maxDepth)=>{if(isNumber(maxDepth)&&depth>maxDepth)return;const dataAttr=isStringStrict(args.dataAttr)?args.dataAttr:"data-nav",depthAttr=args.depthAttr?` ${dataAttr}-depth="${depth}"`:"",listFilterArgs={args:args,output:output,items:items,depth:depth};isFunction(args.filterBeforeList)&&args.filterBeforeList(listFilterArgs);const listClasses=isStringStrict(args.listClass)?` class="${args.listClass}"`:"",listAttrs=isStringStrict(args.listAttr)?` ${args.listAttr}`:"",listTag=isStringStrict(args.listTag)?args.listTag:"ul";output.ref+=`<${listTag}${depthAttr}${listClasses}${listAttrs}>`,items.forEach((item,index)=>{const filterArgs={args:args,item:item,output:output,index:index,items:items,depth:depth};isFunction(args.filterBeforeItem)&&args.filterBeforeItem(filterArgs);const{title:title,link:link,external:external=!1,children:children,current:current=!1,descendentCurrent:descendentCurrent=!1,archiveCurrent:archiveCurrent=!1}=item,itemClasses=isStringStrict(args.itemClass)?` class="${args.itemClass}"`:"",itemTag=isStringStrict(args.itemTag)?args.itemTag:"li";let itemAttrs=isStringStrict(args.itemAttr)?` ${args.itemAttr}`:"";current&&(itemAttrs+=` ${dataAttr}-current`),descendentCurrent&&(itemAttrs+=` ${dataAttr}-descendent-current`),archiveCurrent&&(itemAttrs+=` ${dataAttr}-archive-current`),output.ref+=`<${itemTag}${depthAttr}${itemClasses}${itemAttrs}>`,isFunction(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];isStringStrict(args.linkClass)&&linkClassesArr.push(args.linkClass),!external&&isStringStrict(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const hasLink=isStringStrict(link),linkClasses=linkClassesArr.length?` class="${linkClassesArr.join(" ")}"`:"",linkAttrsArr=[hasLink?`href="${link}"`:'type="button"'];isStringStrict(args.linkAttr)&&linkAttrsArr.push(args.linkAttr),current&&(linkAttrsArr.push(`${dataAttr}-current`),hasLink&&linkAttrsArr.push('aria-current="page"')),descendentCurrent&&linkAttrsArr.push(`${dataAttr}-descendent-current`),archiveCurrent&&linkAttrsArr.push(`${dataAttr}-archive-current`);const linkAttrs=` ${linkAttrsArr.join(" ")}`,linkTag=hasLink?"a":"button";output.ref+=`<${linkTag}${depthAttr}${linkClasses}${linkAttrs}>`,isFunction(args.filterBeforeLinkText)&&args.filterBeforeLinkText(filterArgs),output.ref+=title,isFunction(args.filterAfterLinkText)&&args.filterAfterLinkText(filterArgs),output.ref+=`</${linkTag}>`,isFunction(args.filterAfterLink)&&args.filterAfterLink(filterArgs),isArrayStrict(children)&&this.#recurseOutput(children,output,args,depth+1,maxDepth),output.ref+=`</${itemTag}>`,isFunction(args.filterAfterItem)&&args.filterAfterItem(filterArgs)}),output.ref+=`</${listTag}>`,isFunction(args.filterAfterList)&&args.filterAfterList(listFilterArgs)};getOutput(location,args,maxDepth){const nav=this.#navigationsByLocation.get(location);if(!nav)return"";args=Object.assign({depthAttr:!1},args||{});const items=nav.items,{currentLink:currentLink,currentType:currentType}=args,currLink=isStringStrict(currentLink)?currentLink:"",currType=(isArrayStrict(currentType)?currentType:[currentType]).map(type=>normalizeContentType(type)),normalizedItems=this.#getItems(items,currLink,currType);if(!normalizedItems.length)return"";const output={ref:""};return this.#recurseOutput(normalizedItems,output,args,0,maxDepth),output.ref}getBreadcrumbs(items,args){if(!isArrayStrict(items))return"";const current=(args=Object.assign({a11yClass:"a-hide-vis"},args||{})).current,dataAttr=isStringStrict(args.dataAttr)?args.dataAttr:"data-nav",listClasses=isStringStrict(args.listClass)?` class="${args.listClass}"`:"",listAttrs=isStringStrict(args.listAttr)?` ${args.listAttr}`:"",filteredItems=items.filter(item=>!!isStringStrict(item.title)&&(!!isString(item.slug)&&(item.slug=getSlug({id:item.id,slug:item.slug,contentType:item.contentType,itemData:item.internalLink}),!0))),itemClasses=isStringStrict(args.itemClass)?` class="${args.itemClass}"`:"",itemAttrs=isStringStrict(args.itemAttr)?` ${args.itemAttr}`:"",lastItemIndex=filteredItems.length-1,itemsArr=filteredItems.map((item,index)=>{const{title:title,slug:slug}=item,link=getPermalink(slug),output={ref:""},lastLevel=lastItemIndex===index,filterArgs={output:output,lastLevel:lastLevel};output.ref+=`<li${itemClasses}${itemAttrs}${lastLevel?` ${dataAttr}-last`:""}>`,isFunction(args.filterBeforeLink)&&args.filterBeforeLink(filterArgs);const linkClassesArr=[];isStringStrict(args.linkClass)&&linkClassesArr.push(args.linkClass),isStringStrict(args.internalLinkClass)&&linkClassesArr.push(args.internalLinkClass);const linkClasses=linkClassesArr.length?` class="${linkClassesArr.join(" ")}"`:"",linkAttrs=isStringStrict(args.linkAttr)?` ${args.linkAttr}`:"";return output.ref+=`<a${linkClasses} href="${link}"${linkAttrs}>${title}</a>`,isFunction(args.filterAfterLink)&&args.filterAfterLink(filterArgs),output.ref+="</li>",output.ref}),currentLabel=isStringStrict(args.currentLabel)?args.currentLabel:"(current page)",currentClasses=isStringStrict(args.currentClass)?` class="${args.currentClass}"`:"",a11yClasses=isStringStrict(args.a11yClass)?` class="${args.a11yClass}"`:"",currentItem=isStringStrict(current)?`\n <li${itemClasses}${itemAttrs} ${dataAttr}-current>\n <span${currentClasses}>${current}<span${a11yClasses}> ${currentLabel}</span></span>\n </li>\n `:"";return`\n <ol${listClasses}${listAttrs}>\n ${itemsArr.join("")}\n ${currentItem}\n </ol>\n `}getItemsById(){return this.#itemsById}getNavigationsByLocation(){return this.#navigationsByLocation}getNavigationByLocation(location){return this.#navigationsByLocation.get(location)}}export{Navigation};