@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 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.outputStyles=exports.outputScripts=exports.addStyle=exports.addScript=exports.styles=exports.scripts=void 0;const array_js_1=require("../utils/array/array.js"),string_js_1=require("../utils/string/string.js"),config_js_1=require("../config/config.js"),scripts={priority:new Map,deps:new Map,item:new Map,build:new Map,meta:{}};exports.scripts=scripts;const styles={priority:new Map,deps:new Map,item:new Map,build:new Map};exports.styles=styles;const addScriptStyle=(type,path,deps=[],priority)=>{if(!(0,string_js_1.isStringStrict)(path))return!1;const isScripts="scripts"===type,assets=isScripts?scripts:styles,ext=isScripts?"js":"scss",{inputDir:inputDir,outputDir:outputDir}=config_js_1.config[type],input=`${inputDir}/${path}.${ext}`,output=`${outputDir}/${path}`;return assets.item.set(output,input),assets.build.set(output,input),(0,array_js_1.isArrayStrict)(deps)&&deps.forEach(dep=>{const depInput=`${inputDir}/${dep}.${ext}`,depOutput=`${outputDir}/${dep}`;assets.deps.has(output)||assets.deps.set(output,new Set),assets.deps.get(output)?.add(depOutput),assets.item.set(depOutput,depInput),assets.build.set(depOutput,depInput)}),priority&&assets.priority.set(output,priority),!0},addScript=(path,deps=[],priority)=>addScriptStyle("scripts",path,deps,priority);exports.addScript=addScript;const addStyle=(path,deps=[],priority)=>addScriptStyle("styles",path,deps,priority);exports.addStyle=addStyle;const outputScriptsStyles=(type,link)=>{if(!(0,string_js_1.isStringStrict)(link))return"";const{item:item,deps:deps,priority:priority}="scripts"===type?scripts:styles;if(!item.size)return"";const itemOut=Array.from(item.keys());itemOut.sort((a,b)=>{const aIsDep=deps.get(b)?.has(a),bIsDep=deps.get(a)?.has(b);return!0===aIsDep?-1:!0===bIsDep?1:0});let output="";return itemOut.forEach(out=>{const fetchPriority=priority.has(out)?` fetchpriority="${priority.get(out)}"`:"";"scripts"===type&&(output+=`<script type="module" src="${link}${out}.js"${fetchPriority}><\/script>`),"styles"===type&&(output+=`<link rel="stylesheet" href="${link}${out}.css" media="all"${fetchPriority}>`)}),output},outputScripts=link=>outputScriptsStyles("scripts",link);exports.outputScripts=outputScripts;const outputStyles=link=>outputScriptsStyles("styles",link);exports.outputStyles=outputStyles;
@@ -0,0 +1,15 @@
1
+ import type { Generic } from '../global/globalTypes.js';
2
+ export type ScriptsPriority = 'high' | 'low';
3
+ export interface Scripts {
4
+ item: Map<string, string>;
5
+ build: Map<string, string>;
6
+ deps: Map<string, Set<string>>;
7
+ priority: Map<string, ScriptsPriority>;
8
+ meta: Generic;
9
+ }
10
+ export interface Styles {
11
+ item: Map<string, string>;
12
+ build: Map<string, string>;
13
+ deps: Map<string, Set<string>>;
14
+ priority: Map<string, ScriptsPriority>;
15
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,3 @@
1
+ import type { ServerlessAction } from '../serverlessTypes.js';
2
+ declare const Contact: ServerlessAction;
3
+ export { Contact };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Contact=void 0;const config_js_1=require("../../config/config.js"),escape_js_1=require("../../utils/escape/escape.js"),array_js_1=require("../../utils/array/array.js"),string_js_1=require("../../utils/string/string.js"),object_js_1=require("../../utils/object/object.js"),objectUtils_js_1=require("../../utils/object/objectUtils.js"),filters_js_1=require("../../filters/filters.js"),link_js_1=require("../../utils/link/link.js"),store_js_1=require("../../store/store.js"),minify_js_1=require("../../utils/minify/minify.js"),file_js_1=require("../../utils/file/file.js"),recurseEmailHtml=(data,html,plain,depth=1)=>{if(!(0,object_js_1.isObject)(data))return;const isArr=(0,array_js_1.isArray)(data);(0,objectUtils_js_1.getObjectKeys)(data).forEach(label=>{const value=data[label],l=label.toString(),h=depth+1;1===depth&&(html.ref+='\n <tr>\n <td style="padding: 16px 0; border-bottom: 2px solid #ccc;">\n '),label&&!isArr&&(html.ref+=`\n <h${h} style="font-family: sans-serif; color: #222; margin: 16px 0; line-height: 1.3em">\n ${l}\n </h${h}>\n `,plain.ref+=`${l}\n`),recurseEmailHtml(value,html,plain,depth+1),(0,string_js_1.isString)(value)&&(html.ref+=`\n <p style="font-family: sans-serif; color: #222; margin: 16px 0; line-height: 1.5em;">\n ${value}\n </p>\n `,plain.ref+=value.replace(/<br\s*\/?>/gi,"\n").replace(/(<([^>]+)>)/gi,"")+"\n"),1===depth&&(html.ref+="\n </td>\n </tr>\n ",plain.ref+="\n")})},Contact=async args=>{const{id:id,action:action,inputs:inputs}=args;if(!(0,string_js_1.isStringStrict)(id))return{error:{message:"No ID"}};if(!(0,object_js_1.isObjectStrict)(inputs)||!Object.keys(inputs).length)return{error:{message:"No inputs"}};const formMetaData=(0,store_js_1.getStoreItem)("formMeta");if(!(0,object_js_1.isObjectStrict)(formMetaData))return{error:{message:"No meta"}};const meta=formMetaData[id];if(!(0,object_js_1.isObjectStrict)(meta))return{error:{message:"No meta object"}};const toEmail=meta.toEmail;if(!(0,string_js_1.isStringStrict)(toEmail))return{error:{message:"No to email"}};const toEmails=toEmail.split(","),senderEmail=meta.senderEmail;if(!(0,string_js_1.isStringStrict)(senderEmail))return{error:{message:"No sender email"}};let subject=(0,string_js_1.isStringStrict)(meta.subject)?meta.subject:"",replyToEmail="";const header=`${config_js_1.config.title} contact form submission`,footer=`This email was sent from a contact form on ${config_js_1.config.title} (${(0,link_js_1.getPermalink)()})`,outputData={},html={ref:""},plain={ref:""};for(const[name,input]of Object.entries(inputs)){const inputType=input.type,inputLabel=input.label?.trim()||`[${name}]`,inputValue=input.value;let inputValueStr="";if(inputValueStr=(0,array_js_1.isArray)(inputValue)?inputValue.map(v=>(0,file_js_1.isFile)(v)?v.name:(0,escape_js_1.escape)(v.toString().trim())).join("<br>"):(0,file_js_1.isFile)(inputValue)?inputValue.name:(0,escape_js_1.escape)(inputValue.toString().trim()),"subject"===name){subject=inputValueStr?`${(0,string_js_1.isStringStrict)(subject)?`${subject} - `:""}${inputValueStr}`:subject;continue}"email"===inputType&&inputValueStr&&(replyToEmail=inputValueStr,inputValueStr=`<a href="mailto:${inputValueStr}">${inputValueStr}</a>`);const outputValue=""===inputValueStr?"--":inputValueStr;let hasLegend=!1,legend="";if((0,string_js_1.isStringStrict)(input.legend)&&(hasLegend=!0,legend=input.legend),hasLegend){null==outputData[legend]&&(outputData[legend]={});null==outputData[legend][inputLabel]&&(outputData[legend][inputLabel]=[]),outputData[legend][inputLabel].push(outputValue)}if(!hasLegend){null==outputData[inputLabel]&&(outputData[inputLabel]=[]),outputData[inputLabel].push(outputValue)}}recurseEmailHtml(outputData,html,plain);const outputHtml=`\n <table width="100%" cellpadding="0" cellspacing="0" border="0">\n <tr>\n <td align="center" width="100%" style="padding: 0 16px 16px 16px;">\n <table align="center" cellpadding="0" cellspacing="0" border="0" style="margin-right: auto; margin-left: auto; border-spacing: 0; max-width: 37.5em;">\n <tr>\n <td style="padding: 32px 0 0 0;">\n <h1 style="font-family: sans-serif; color: #222; margin: 0; line-height: 1.3em;">\n ${header}\n </h1>\n </td>\n </tr>\n <tr>\n <td>\n <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;">\n ${html.ref}\n <tr>\n <td style="padding: 32px 0;">\n <p style="font-family: sans-serif; color: #222; margin: 0; line-height: 1.5em;">\n ${footer}\n </p>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n </td>\n </tr>\n </table>\n `,outputPlain=`${header}\n\n${plain.ref}${footer}`;subject||(subject=`${config_js_1.config.title} Contact Form`);const body={id:id,action:action,inputs:inputs,to:toEmails,sender:senderEmail,subject:subject,text:(0,minify_js_1.minify)(outputPlain),html:(0,minify_js_1.minify)(outputHtml)};return replyToEmail&&(body.replyTo=replyToEmail),await(0,filters_js_1.applyFilters)("contactResult",{},body,!0)};exports.Contact=Contact;
@@ -0,0 +1,13 @@
1
+ import type { ServerlessActionData, ServerlessActionReturn } from '../serverlessTypes.js';
2
+ export interface ContactData {
3
+ [key: string]: string[] | ContactData;
4
+ }
5
+ export interface ContactBody extends ServerlessActionData {
6
+ to: string[];
7
+ sender: string;
8
+ subject: string;
9
+ text: string;
10
+ html: string;
11
+ replyTo?: string;
12
+ }
13
+ export type ContactResultFilter = (res: ServerlessActionReturn | null, args: ContactBody) => Promise<ServerlessActionReturn | null>;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,12 @@
1
+ import type { ServerlessActions } from './serverlessTypes.js';
2
+ import type { RenderPreviewData, RenderServerlessData } from '../render/renderTypes.js';
3
+ import type { Generic, GenericStrings } from '../global/globalTypes.js';
4
+ import type { getAllContentfulData } from '../contentful/contentfulData.js';
5
+ import type { getAllWordPressData } from '../wordpress/wordpressData.js';
6
+ declare let serverlessActions: ServerlessActions;
7
+ declare const serverlessPreview: (request: Request) => RenderPreviewData | undefined;
8
+ declare const serverlessReload: (request: Request, allowedParams?: string[]) => RenderServerlessData | undefined;
9
+ declare const serverlessRender: (getData: typeof getAllContentfulData | typeof getAllWordPressData, serverlessData?: RenderServerlessData, previewData?: RenderPreviewData) => Promise<Response>;
10
+ declare const setServerless: (actions?: ServerlessActions) => void;
11
+ declare const doServerlessAction: (request: Request, env: Generic, headers?: GenericStrings, honeypotName?: string) => Promise<Response>;
12
+ export { serverlessActions, serverlessPreview, serverlessReload, serverlessRender, setServerless, doServerlessAction };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.doServerlessAction=exports.setServerless=exports.serverlessRender=exports.serverlessReload=exports.serverlessPreview=exports.serverlessActions=void 0;const ResponseError_js_1=require("../utils/ResponseError/ResponseError.js"),string_js_1=require("../utils/string/string.js"),object_js_1=require("../utils/object/object.js"),function_js_1=require("../utils/function/function.js"),filters_js_1=require("../filters/filters.js"),render_js_1=require("../render/render.js"),minify_js_1=require("../utils/minify/minify.js"),print_js_1=require("../utils/print/print.js");let serverlessActions={};exports.serverlessActions=serverlessActions;const serverlessPreview=request=>{const{method:method,url:url}=request;if("GET"!==method)return;const{searchParams:searchParams}=new URL(url),contentType=searchParams.get("content_type"),locale=searchParams.get("locale"),id=searchParams.get("preview");if(!(0,string_js_1.isStringStrict)(id)||!(0,string_js_1.isStringStrict)(contentType))return;const previewData={id:id,contentType:contentType};return(0,string_js_1.isStringStrict)(locale)&&(previewData.locale=locale),previewData};exports.serverlessPreview=serverlessPreview;const serverlessReload=(request,allowedParams=["page","filters"])=>{const{method:method,url:url}=request;if("GET"!==method)return;const{searchParams:searchParams,pathname:pathname}=new URL(url),path=pathname,query={};let hasParams=!1;for(const param of allowedParams){const value=searchParams.get(param);(0,string_js_1.isStringStrict)(value)&&(query[param]=value,hasParams=!0)}return hasParams?{query:query,path:path}:void 0};exports.serverlessReload=serverlessReload;const serverlessRender=async(getData,serverlessData,previewData)=>{try{const data=await(0,render_js_1.render)({serverlessData:serverlessData,previewData:previewData,allData:await getData({serverlessData:serverlessData,previewData:previewData})});let html="",status=200;(0,object_js_1.isObjectStrict)(data)&&(html=data.output);const isEmpty=""===html;return isEmpty&&(status=404),isEmpty&&(0,function_js_1.isFunction)(render_js_1.renderHttpError)&&(html=await(0,render_js_1.renderHttpError)({code:status})),new Response((0,minify_js_1.minify)(html),{status:status,headers:{"Content-Type":"text/html;charset=UTF-8"}})}catch(error){(0,print_js_1.print)("[FRM] Error on serverless render",error);const status=500,html=await(0,render_js_1.renderHttpError)({code:status});return new Response(html,{status:status,headers:{"Content-Type":"text/html;charset=UTF-8"}})}};exports.serverlessRender=serverlessRender;const setServerless=actions=>{(0,object_js_1.isObjectStrict)(actions)&&(exports.serverlessActions=serverlessActions={...actions})};exports.setServerless=setServerless;const doServerlessAction=async(request,env,headers,honeypotName)=>{const serverlessHeaders={"Content-Type":"application/json",...headers};try{if("POST"!==request.method)return new Response(JSON.stringify({error:"Method not allowed"}),{status:405,headers:serverlessHeaders});const data=await request.json();if(!(0,object_js_1.isObjectStrict)(data))throw new Error("Data not an object");if((0,string_js_1.isStringStrict)(honeypotName)&&(0,object_js_1.isObjectStrict)(data.inputs?.[honeypotName])){const honeypotValue=data.inputs[honeypotName].value;if((0,string_js_1.isStringStrict)(honeypotValue))return new Response(JSON.stringify({success:""}),{status:200,headers:serverlessHeaders});delete data.inputs[honeypotName]}const action=data.action;if(!(0,string_js_1.isStringStrict)(action))throw new Error("No action");let res=null;const serverlessAction=serverlessActions[action];(0,function_js_1.isFunction)(serverlessAction)&&(res=await serverlessAction(data,request,env));const serverlessResultFilterArgs={data:data,request:request,env:env};if(res=await(0,filters_js_1.applyFilters)("serverlessResult",res,serverlessResultFilterArgs,!0),!res)throw new Error("No result");if(res.error){const errorMessage=res.error.message;throw res.error.response?new ResponseError_js_1.ResponseError(errorMessage,res.error.response):new Error(errorMessage)}const options={status:200,headers:serverlessHeaders};let message="";if(res.success){const{message:successMessage,headers:successHeaders}=res.success;(0,string_js_1.isStringStrict)(successMessage)&&(message=successMessage),(0,object_js_1.isObjectStrict)(successHeaders)&&(options.headers={...options.headers,...successHeaders})}return new Response(JSON.stringify({success:message}),options)}catch(error){(0,print_js_1.print)("[FRM] Error with serverless action",error);let statusCode=500,message=error instanceof Error?error.message:"Unknown error";return error instanceof ResponseError_js_1.ResponseError&&(statusCode=error.response.status,message=error.message),new Response(JSON.stringify({error:message}),{status:statusCode,headers:serverlessHeaders})}};exports.doServerlessAction=doServerlessAction;
@@ -0,0 +1,41 @@
1
+ import type { Generic, GenericStrings } from '../global/globalTypes.js';
2
+ export interface ServerlessRoute {
3
+ path: string;
4
+ content?: string;
5
+ }
6
+ export type ServerlessActionPrimitive = string | number | boolean | File;
7
+ export interface ServerlessActionInput extends Generic {
8
+ value: ServerlessActionPrimitive | ServerlessActionPrimitive[];
9
+ type: string | string[];
10
+ label?: string;
11
+ legend?: string;
12
+ }
13
+ export interface ServerlessActionData {
14
+ id: string;
15
+ action: string;
16
+ inputs: Record<string, ServerlessActionInput>;
17
+ }
18
+ export interface ServerlessActionError {
19
+ message: string;
20
+ response?: Response;
21
+ }
22
+ export interface ServerlessActionSuccess {
23
+ message: string;
24
+ headers?: GenericStrings;
25
+ }
26
+ export interface ServerlessActionReturn {
27
+ error?: ServerlessActionError;
28
+ success?: ServerlessActionSuccess;
29
+ }
30
+ export type ServerlessAction = (args: ServerlessActionData, request: Request, env: Generic) => Promise<ServerlessActionReturn> | ServerlessActionReturn;
31
+ export type ServerlessActions = Record<string, ServerlessAction>;
32
+ export interface ServerlessResultOptions {
33
+ status: number;
34
+ headers?: GenericStrings;
35
+ }
36
+ export interface ServerlessResultFilterArgs {
37
+ data: ServerlessActionData;
38
+ request: Request;
39
+ env: Generic;
40
+ }
41
+ export type ServerlessResultFilter = (res: ServerlessActionReturn | null, args: ServerlessResultFilterArgs) => Promise<ServerlessActionReturn | null>;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,10 @@
1
+ import type { Shortcode, Shortcodes, ShortcodesSet } from './shortcodesTypes.js';
2
+ import type { RenderItem } from '../render/renderTypes.js';
3
+ declare const shortcodes: Shortcodes;
4
+ declare const addShortcode: <T extends Shortcode>(name: string, shortcode: T) => boolean;
5
+ declare const removeShortcode: (name: string) => boolean;
6
+ declare const doShortcodes: (content: string, itemData?: RenderItem) => Promise<string>;
7
+ declare const resetShortcodes: () => void;
8
+ declare const setShortcodes: <T extends ShortcodesSet>(args: T) => boolean;
9
+ declare const stripShortcodes: (content: string) => string;
10
+ export { shortcodes, addShortcode, removeShortcode, doShortcodes, resetShortcodes, setShortcodes, stripShortcodes };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.stripShortcodes=exports.setShortcodes=exports.resetShortcodes=exports.doShortcodes=exports.removeShortcode=exports.addShortcode=exports.shortcodes=void 0;const object_js_1=require("../utils/object/object.js"),array_js_1=require("../utils/array/array.js"),string_js_1=require("../utils/string/string.js"),function_js_1=require("../utils/function/function.js"),escape_js_1=require("../utils/escape/escape.js"),shortcodes=new Map;exports.shortcodes=shortcodes;const attrReg=/[\w-]+=".*?"/g,getShortcodeData=(content,tagNames,props,itemData)=>{if(!(0,string_js_1.isStringStrict)(content)||!(0,string_js_1.isStringStrict)(tagNames))return[];const reg=new RegExp(String.raw`\[(?:\/)?(?<name>${tagNames})(?:\s[^\]]*?)?\]`,"g"),matches=[...content.matchAll(reg)];if(!matches.length)return[];const data=[];return matches.forEach((opening,i)=>{const name=opening.groups?.name,tag=opening[0];if(!(0,string_js_1.isStringStrict)(name)||tag.startsWith("[/"))return;const info=props||shortcodes.get(name);if(!(0,object_js_1.isObjectStrict)(info))return;const child=info.child,hasChild=(0,string_js_1.isStringStrict)(child),startIndex=opening.index,startLen=tag.length;let endIndex=startIndex+tag.length,endLen=0;const closingTag=`[/${name}]`,closingMatch=hasChild?matches.find(m=>m[0]===closingTag):matches[i+1];closingMatch?.[0]===closingTag&&(endIndex=closingMatch.index,endLen=closingTag.length);const attrs={},attrTypes=(0,object_js_1.isObjectStrict)(info.attrTypes)?info.attrTypes:{},attr=tag.match(attrReg);(0,array_js_1.isArrayStrict)(attr)&&attr.forEach(a=>{const[key,value]=a.split("="),type=attrTypes[key];let val=(0,escape_js_1.escape)(value.replace(/"/g,""));if("number"===type){const num=parseInt(val,10);val=isNaN(num)?0:num}"boolean"===type&&(val="true"===val),attrs[key]=val});const replaceContent=content.slice(startIndex,endIndex+endLen),innerContent=content.slice(startIndex+startLen,endIndex);let children=[];hasChild&&(children=getShortcodeData(innerContent,child,props,itemData)),data.push({name:name,replaceContent:replaceContent,content:innerContent,attr:attrs,children:children,itemData:itemData})}),data},addShortcode=(name,shortcode)=>!(!(0,string_js_1.isStringStrict)(name)||!(0,object_js_1.isObjectStrict)(shortcode))&&(shortcodes.set(name,shortcode),!0);exports.addShortcode=addShortcode;const removeShortcode=name=>!!(0,string_js_1.isStringStrict)(name)&&shortcodes.delete(name);exports.removeShortcode=removeShortcode;const doShortcodes=async(content,itemData)=>{if(!shortcodes.size)return content;const names=[...shortcodes.keys()].join("|"),data=getShortcodeData(content,names,void 0,itemData);if(!data.length)return content;let newContent=content;for(const datum of data){const{name:name,replaceContent:replaceContent}=datum,callback=shortcodes.get(name)?.callback;(0,function_js_1.isFunction)(callback)&&(newContent=newContent.replace(replaceContent,await callback({...datum,itemData:itemData})))}return newContent};exports.doShortcodes=doShortcodes;const resetShortcodes=()=>{shortcodes.clear()};exports.resetShortcodes=resetShortcodes;const setShortcodes=args=>{if(!(0,object_js_1.isObjectStrict)(args))return!1;const names=Object.entries(args);return!!names.length&&(resetShortcodes(),names.forEach(([name,shortcode])=>{addShortcode(name,shortcode)}),!0)};exports.setShortcodes=setShortcodes;const stripShortcodes=content=>{if(!shortcodes.size)return content;const names=[...shortcodes.keys()].join("|"),reg=new RegExp(String.raw`\[(?:\/)?(?<name>${names})(?:\s[^\]]*?)?\]`,"g");return content.replace(reg,()=>"")};exports.stripShortcodes=stripShortcodes;
@@ -0,0 +1,20 @@
1
+ import type { RenderItem } from '../render/renderTypes.js';
2
+ export type ShortcodeAttrValue = string | number | boolean | undefined;
3
+ export type ShortcodeAttrs = Record<string, ShortcodeAttrValue>;
4
+ export type ShortcodeAttrTypes = Record<string, 'string' | 'number' | 'boolean'>;
5
+ export interface ShortcodeData {
6
+ name: string;
7
+ replaceContent: string;
8
+ content: string;
9
+ attr: ShortcodeAttrs;
10
+ children: ShortcodeData[];
11
+ itemData?: RenderItem;
12
+ }
13
+ export type ShortcodeCallback = (args: ShortcodeData) => string | Promise<string>;
14
+ export interface Shortcode {
15
+ callback: ShortcodeCallback;
16
+ attrTypes?: ShortcodeAttrTypes;
17
+ child?: string;
18
+ }
19
+ export type Shortcodes = Map<string, Shortcode>;
20
+ export type ShortcodesSet = Record<string, Shortcode>;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,9 @@
1
+ import type { Store } from './storeTypes.js';
2
+ import type { RenderAllData } from '../render/renderTypes.js';
3
+ declare let storeDir: string;
4
+ declare let store: Store;
5
+ declare const setStore: <T extends object>(args: T, dir?: string) => Store & T;
6
+ declare const setStoreItem: <T extends Store, K extends keyof T, V extends keyof T[K] | undefined = undefined>(prop: K, value: V extends keyof T[K] ? T[K][V] : T[K], subProp?: V) => boolean;
7
+ declare const setStoreData: (allData: RenderAllData) => boolean;
8
+ declare const getStoreItem: <T extends Store, K extends keyof T>(prop: K) => T[K];
9
+ export { store, storeDir, setStore, setStoreData, setStoreItem, getStoreItem };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getStoreItem=exports.setStoreItem=exports.setStoreData=exports.setStore=exports.storeDir=exports.store=void 0;const contentType_js_1=require("../utils/contentType/contentType.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"),archive_js_1=require("../utils/archive/archive.js"),config_js_1=require("../config/config.js");let storeDir="lib/store";exports.storeDir=storeDir;const defaultStore={slugs:{},parents:{},navigations:[],navigationItems:[],formMeta:{},archiveMeta:{},imageMeta:{},taxonomies:{},serverless:{}};let store={...defaultStore};exports.store=store;const setStore=(args,dir="lib/store")=>(0,object_js_1.isObjectStrict)(args)?(exports.store=store={...defaultStore,...args},(0,string_js_1.isStringStrict)(dir)&&(exports.storeDir=storeDir=dir),store):store;exports.setStore=setStore;const setStoreItem=(prop,value,subProp)=>!(!(0,string_js_1.isStringStrict)(prop)||!(0,object_js_1.isObject)(value)||null==store[prop])&&((0,string_js_1.isStringStrict)(subProp)?store[prop][subProp]=value:store[prop]=value,!0);exports.setStoreItem=setStoreItem;const setStoreData=allData=>{if(!(0,object_js_1.isObjectStrict)(allData))return!1;const{navigation:navigation,navigationItem:navigationItem,content:content}=allData;store.navigations=(0,array_js_1.isArrayStrict)(navigation)?navigation:[],store.navigationItems=(0,array_js_1.isArrayStrict)(navigationItem)?navigationItem:[];const data={...allData,...content};return config_js_1.config.hierarchicalTypes.forEach(type=>{const items=data[type];(0,array_js_1.isArrayStrict)(items)&&items.forEach(item=>{if(!(0,object_js_1.isObjectStrict)(item))return;const{id:id,parent:parent,archive:archive,slug:slug,title:title,locale:locale}=item;if(!(0,string_js_1.isStringStrict)(id))return;const archiveType=(0,contentType_js_1.normalizeContentType)(archive);if((0,string_js_1.isStringStrict)(archiveType)){const hasLocale=(0,string_js_1.isStringStrict)(locale),archiveMeta=(0,archive_js_1.getArchiveMeta)(archiveType),newArchive={id:id,slug:slug,title:title,contentType:type,...hasLocale?archiveMeta[locale]:archiveMeta};hasLocale?(store.archiveMeta[archiveType]||(store.archiveMeta[archiveType]={}),store.archiveMeta[archiveType][locale]=newArchive):store.archiveMeta[archiveType]=newArchive}if((0,object_js_1.isObjectStrict)(parent)){const parentSlug=parent.slug,parentTitle=parent.title,parentId=parent.id;(0,string_js_1.isStringStrict)(parentSlug)&&(0,string_js_1.isStringStrict)(parentTitle)&&(0,string_js_1.isStringStrict)(parentId)&&(null==store.parents[type]&&(store.parents[type]={}),store.parents[type][id]=[parentId,parentSlug,parentTitle])}})}),!0};exports.setStoreData=setStoreData;const getStoreItem=prop=>store[prop];exports.getStoreItem=getStoreItem;
@@ -0,0 +1,2 @@
1
+ declare const createStoreFiles: () => Promise<void>;
2
+ export { createStoreFiles };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.createStoreFiles=void 0;const promises_1=require("node:fs/promises"),node_path_1=require("node:path"),print_js_1=require("../utils/print/print.js"),store_js_1=require("./store.js"),createStoreFiles=async()=>{await(0,promises_1.mkdir)((0,node_path_1.resolve)(store_js_1.storeDir),{recursive:!0});for(const[key,data]of Object.entries(store_js_1.store)){const fileName=`${key}.json`,path=(0,node_path_1.resolve)(store_js_1.storeDir,fileName);await(0,promises_1.writeFile)(path,JSON.stringify(data)),(0,print_js_1.print)("[FRM] Successfully wrote",path,"success")}};exports.createStoreFiles=createStoreFiles;
@@ -0,0 +1,28 @@
1
+ import type { Generic, Taxonomy } from '../global/globalTypes.js';
2
+ import type { NavigationList, NavigationItem } from '../components/Navigation/NavigationTypes.js';
3
+ import type { ArchiveMeta } from '../utils/archive/archiveTypes.js';
4
+ import type { ImageProps } from '../utils/image/imageTypes.js';
5
+ import type { FormMeta } from '../objects/Form/FormTypes.js';
6
+ export type StoreSlugs = Record<string, [string, string, string?]>;
7
+ export type StoreParents = Record<string, Record<string, [string, string, string]>>;
8
+ export type StoreArchiveMeta = Record<string, ArchiveMeta | Record<string, ArchiveMeta>>;
9
+ export type StoreFormMeta = Record<string, FormMeta>;
10
+ export type StoreImageMeta = Record<string, ImageProps>;
11
+ export type StoreTaxonomies = Record<string, Taxonomy>;
12
+ interface StorePrimitiveGeneric {
13
+ [key: string]: StorePrimitive;
14
+ }
15
+ export type StorePrimitive = string | number | boolean | null | undefined | StorePrimitive[] | StorePrimitiveGeneric;
16
+ export type StoreServerless<T extends StorePrimitive[]> = Record<string, T>;
17
+ export interface Store extends Generic {
18
+ slugs: StoreSlugs;
19
+ parents: StoreParents;
20
+ archiveMeta: StoreArchiveMeta;
21
+ formMeta: StoreFormMeta;
22
+ imageMeta: StoreImageMeta;
23
+ navigations: NavigationList[];
24
+ navigationItems: NavigationItem[];
25
+ taxonomies: StoreTaxonomies;
26
+ serverless: StoreServerless<StorePrimitive[]>;
27
+ }
28
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,4 @@
1
+ import type { RichTextProps, RichTextContent } from './RichTextTypes.js';
2
+ declare const getPlainText: (args: RichTextContent | RichTextContent[] | string | undefined, _output?: string) => string;
3
+ declare const RichText: (props: RichTextProps) => string;
4
+ export { RichText, getPlainText };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getPlainText=exports.RichText=void 0;const link_js_1=require("../../utils/link/link.js"),excerpt_js_1=require("../../utils/excerpt/excerpt.js"),filters_js_1=require("../../filters/filters.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"),heading_js_1=require("../../utils/heading/heading.js"),containsShortcode=(tag,content)=>"p"===tag&&"["===content.charAt(0)&&"]"===content.charAt(content.length-1),addDataAttr=(dataAttr=!0,tag="")=>(0,array_js_1.isArrayStrict)(dataAttr)?dataAttr.includes(tag):dataAttr,getContent=args=>{const{content:content=[],props:props,dataAttr:dataAttr=!1}=args;let{_output:_output=""}=args;for(const item of content){const newItem=(0,filters_js_1.applyFilters)("richTextContentItem",item,props),{link:link,attr:attr,internalLink:internalLink,content:itemContent}=newItem;let{tag:tag=""}=newItem,newContent=itemContent;const isSingleTag="br"===tag||"hr"===tag;(0,array_js_1.isArrayStrict)(itemContent)&&(newContent=getContent({content:itemContent,props:props,dataAttr:dataAttr}));const attrs=[];if(addDataAttr(dataAttr,tag)&&attrs.push(`data-rich="${tag}"`),(0,string_js_1.isStringStrict)(attr)&&attrs.push(attr),(0,object_js_1.isObjectStrict)(attr)&&Object.entries(attr).forEach(([key,value])=>{attrs.push(`${key}="${value}"`)}),"a"===tag){let anchorLink=link;internalLink&&(anchorLink=(0,link_js_1.getLink)(internalLink)),(0,string_js_1.isStringStrict)(anchorLink)&&attrs.push(`href="${anchorLink}"`)}let outputStr="";if((0,string_js_1.isString)(newContent)){const richTextContentFilterArgs={args:newItem,props:props};outputStr+=(0,filters_js_1.applyFilters)("richTextContent",newContent,richTextContentFilterArgs)}containsShortcode(tag,outputStr)&&(tag="");let opening="",closing="",inner="";(0,string_js_1.isStringStrict)(tag)&&outputStr.trim()&&!isSingleTag&&(opening=`<${tag}${attrs.length?` ${attrs.join(" ")}`:""}>`,closing=`</${tag}>`,inner=outputStr,outputStr=`${opening}${outputStr}${closing}`),isSingleTag&&(outputStr=`<${tag}>`);const richTextContentOutputArgs={args:newItem,props:props,element:{opening:opening,closing:closing,content:inner}};_output+=(0,filters_js_1.applyFilters)("richTextContentOutput",outputStr,richTextContentOutputArgs)}return _output},getPlainText=(args,_output="")=>{if((0,string_js_1.isString)(args))return args;const content=(0,object_js_1.isObjectStrict)(args)?args.content:args;if(!(0,array_js_1.isArrayStrict)(content))return _output;for(const item of content){const{content:itemContent}=(0,object_js_1.isObjectStrict)(item)?item:{};(0,string_js_1.isString)(itemContent)&&(_output+=itemContent),(0,array_js_1.isArrayStrict)(itemContent)&&(_output=getPlainText({content:itemContent},_output))}return _output};exports.getPlainText=getPlainText;const RichText=props=>{if(!(0,object_js_1.isObjectStrict)(props))return"";props=(0,filters_js_1.applyFilters)("richTextProps",props);const{args:args}=props;if(!(0,object_js_1.isObjectStrict)(args))return"";const{content:content=[],classes:classes,link:link,internalLink:internalLink,textStyle:textStyle,headingStyle:headingStyle,align:align,style:style,attr:attr,dataAttr:dataAttr=!0}=args;let{tag:tag=""}=args;if("hr"===tag||"br"===tag)return`<${tag}>`;const isSectionHeading=(0,heading_js_1.isHeading)(tag),classesArr=[];(0,string_js_1.isStringStrict)(classes)&&classesArr.push(classes),(0,string_js_1.isStringStrict)(textStyle)&&classesArr.push(textStyle),(0,string_js_1.isStringStrict)(headingStyle)&&isSectionHeading&&classesArr.push(headingStyle),(0,string_js_1.isStringStrict)(align)&&classesArr.push(align);const filterProps={...props};filterProps.args.content=void 0;let headingObj,output="",headingStr="";(0,string_js_1.isStringStrict)(content)&&(output=content,headingStr=content),(0,array_js_1.isArrayStrict)(content)&&(headingObj=content,output=getContent({content:content,props:filterProps,dataAttr:dataAttr}));const attrs=[];if(addDataAttr(dataAttr,tag)&&attrs.push(`data-rich="${tag}"`),isSectionHeading){const headingContents=(0,excerpt_js_1.getExcerpt)({limit:10,limitExcerpt:!0,excerpt:headingStr,content:headingObj}),id=headingContents.trim().replace(/&hellip;/g,"").replace(/[^\w\s]|_/g,"").replace(/\s+/g,"-").toLowerCase();headingContents&&id&&(attrs.push(`id="${id}"`),(0,array_js_1.isArray)(props.headings)&&props.headings.push({id:id,title:headingContents,tag:tag}))}if("a"===tag){let anchorLink=link;const inLink=(0,link_js_1.getLink)(internalLink);(0,string_js_1.isStringStrict)(inLink)&&(anchorLink=inLink),(0,string_js_1.isStringStrict)(anchorLink)&&attrs.push(`href="${anchorLink}"`)}classesArr.length&&attrs.push(`class="${classesArr.join(" ")}"`),(0,string_js_1.isStringStrict)(style)&&attrs.push(`style="${style}"`),(0,string_js_1.isStringStrict)(attr)&&attrs.push(attr),(0,object_js_1.isObjectStrict)(attr)&&Object.entries(attr).forEach(([key,value])=>{attrs.push(`${key}="${value}"`)}),containsShortcode(tag,output)&&(tag="");let opening="",closing="",inner="";(0,string_js_1.isStringStrict)(tag)&&output.trim()&&(opening=`<${tag}${attrs.length?` ${attrs.join(" ")}`:""}>`,closing=`</${tag}>`,inner=output,output=`${opening}${output}${closing}`);const richTextOutputArgs={props:filterProps,element:{opening:opening,closing:closing,content:inner}};return(0,filters_js_1.applyFilters)("richTextOutput",output,richTextOutputArgs)};exports.RichText=RichText;
@@ -0,0 +1,54 @@
1
+ import type { InternalLink, Generic, GenericStrings } from '../../global/globalTypes.js';
2
+ import type { RenderRichText, RenderFunctionArgs, RenderItem } from '../../render/renderTypes.js';
3
+ export interface RichTextHeading {
4
+ title: string;
5
+ id: string;
6
+ tag: string;
7
+ }
8
+ export interface RichTextElement {
9
+ opening: string;
10
+ content: string;
11
+ closing: string;
12
+ }
13
+ export interface RichTextArgs extends Generic {
14
+ tag?: string;
15
+ content?: RenderRichText[] | string;
16
+ classes?: string;
17
+ textStyle?: string;
18
+ headingStyle?: string;
19
+ caption?: RenderRichText[] | string;
20
+ align?: string;
21
+ link?: string;
22
+ internalLink?: InternalLink;
23
+ style?: string;
24
+ attr?: string | GenericStrings;
25
+ dataAttr?: boolean | string[];
26
+ }
27
+ export interface RichTextContent extends Generic {
28
+ content?: RenderRichText[] | string;
29
+ }
30
+ export interface RichTextProps<A = RichTextArgs, R = RenderItem> extends RenderFunctionArgs<A, R> {
31
+ args: RichTextArgs & A;
32
+ }
33
+ export interface RichTextContentProps {
34
+ content: RenderRichText[];
35
+ props: RichTextProps;
36
+ dataAttr: boolean | string[];
37
+ _output?: string;
38
+ }
39
+ export interface RichTextContentFilterArgs {
40
+ args: RenderRichText;
41
+ props: RichTextProps;
42
+ }
43
+ export interface RichTextContentOutputFilterArgs extends RichTextContentFilterArgs {
44
+ element: RichTextElement;
45
+ }
46
+ export interface RichTextOutputFilterArgs {
47
+ props: RichTextProps;
48
+ element: RichTextElement;
49
+ }
50
+ export type RichTextPropsFilter = (props: RichTextProps) => RichTextProps;
51
+ export type RichTextOutputFilter = (output: string, args: RichTextContentOutputFilterArgs) => string;
52
+ export type RichTextContentItemFilter = (item: RenderRichText, args: RichTextProps) => RenderRichText;
53
+ export type RichTextContentFilter = (content: string, args: RichTextContentFilterArgs) => string;
54
+ export type RichTextContentOutputFilter = (content: string, args: RichTextContentOutputFilterArgs) => string;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,5 @@
1
+ declare class ResponseError extends Error {
2
+ response: Response;
3
+ constructor(message: string, resp: Response);
4
+ }
5
+ export { ResponseError };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ResponseError=void 0;class ResponseError extends Error{response;constructor(message,resp){super(message),this.message=message,this.response=resp}}exports.ResponseError=ResponseError;
@@ -0,0 +1,10 @@
1
+ import type { ArchiveInfo, ArchiveTaxonomy, ArchiveLink, ArchiveLabels, ArchiveMeta } from './archiveTypes.js';
2
+ import type { RenderItem } from '../../render/renderTypes.js';
3
+ declare const isTerm: (contentType: string, itemData: RenderItem) => boolean;
4
+ declare const isArchive: (contentType: string, itemData: RenderItem) => boolean;
5
+ declare const getArchiveMeta: (contentType: string, locale?: string) => ArchiveMeta;
6
+ declare const getArchiveInfo: (contentType: string, locale?: string) => ArchiveInfo;
7
+ declare const getTaxonomyInfo: (contentType: string, itemData?: RenderItem) => ArchiveTaxonomy;
8
+ declare const getArchiveLink: (contentType: string, itemData?: RenderItem) => ArchiveLink;
9
+ declare const getArchiveLabels: (contentType: string, itemData?: RenderItem) => ArchiveLabels;
10
+ export { isTerm, isArchive, getArchiveMeta, getArchiveInfo, getTaxonomyInfo, getArchiveLink, getArchiveLabels };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getArchiveLabels=exports.getArchiveLink=exports.getTaxonomyInfo=exports.getArchiveInfo=exports.getArchiveMeta=exports.isArchive=exports.isTerm=void 0;const store_js_1=require("../../store/store.js"),object_js_1=require("../object/object.js"),array_js_1=require("../array/array.js"),string_js_1=require("../string/string.js"),boolean_js_1=require("../boolean/boolean.js"),contentType_js_1=require("../contentType/contentType.js"),link_js_1=require("../link/link.js"),isTerm=(contentType,itemData)=>{if(!(0,object_js_1.isObjectStrict)(itemData))return!1;const{contentType:type,taxonomy:taxonomy}=itemData;return!("term"!==type||!(0,object_js_1.isObjectStrict)(taxonomy))&&taxonomy.contentTypes.includes(contentType)};exports.isTerm=isTerm;const isArchive=(contentType,itemData)=>{if(!(0,object_js_1.isObjectStrict)(itemData))return!1;const{archive:archive}=itemData;return archive===contentType||isTerm(contentType,itemData)};exports.isArchive=isArchive;const getArchiveMeta=(contentType,locale)=>{const archiveMeta=(0,store_js_1.getStoreItem)("archiveMeta")[contentType];return(0,object_js_1.isObjectStrict)(archiveMeta)?(0,string_js_1.isStringStrict)(locale)&&(0,object_js_1.isObjectStrict)(archiveMeta[locale])?archiveMeta[locale]:archiveMeta:{}};exports.getArchiveMeta=getArchiveMeta;const getArchiveInfo=(contentType,locale)=>{const value={id:"",slug:"",title:"",contentType:""};if("page"===(contentType=(0,contentType_js_1.normalizeContentType)(contentType)))return value;const{id:id,slug:slug,title:title,contentType:type}=getArchiveMeta(contentType,locale);return value.id=(0,string_js_1.isStringStrict)(id)?id:"",value.slug=(0,string_js_1.isStringStrict)(slug)?slug:"",value.title=(0,string_js_1.isStringStrict)(title)?title:"",value.contentType=(0,string_js_1.isStringStrict)(type)?type:"",value};exports.getArchiveInfo=getArchiveInfo;const getTaxonomyInfo=(contentType,itemData)=>{const value={id:"",slug:"",title:"",contentTypes:[],primaryContentType:"",usePrimaryContentTypeSlug:!0,isPage:!1},taxObj="taxonomy"===contentType?itemData:itemData?.taxonomy;if(!(0,object_js_1.isObjectStrict)(taxObj))return value;const{id:id,slug:slug,link:link,title:title,contentTypes:contentTypes,usePrimaryContentTypeSlug:usePrimaryContentTypeSlug,isPage:isPage}=taxObj,taxonomyTypes=(0,array_js_1.isArrayStrict)(contentTypes)?contentTypes.map(type=>(0,contentType_js_1.normalizeContentType)(type)):[],primaryTaxonomyType=taxonomyTypes[0];return value.id=(0,string_js_1.isStringStrict)(id)?id:"",value.slug=(0,string_js_1.isStringStrict)(slug)?slug:"",value.title=(0,string_js_1.isStringStrict)(title)?title:"",value.contentTypes=taxonomyTypes,value.primaryContentType=(0,string_js_1.isStringStrict)(primaryTaxonomyType)?primaryTaxonomyType:"",value.usePrimaryContentTypeSlug=!(0,boolean_js_1.isBoolean)(usePrimaryContentTypeSlug)||usePrimaryContentTypeSlug,value.isPage=!!(0,boolean_js_1.isBoolean)(isPage)&&isPage,(0,string_js_1.isStringStrict)(link)&&(value.link=link),value};exports.getTaxonomyInfo=getTaxonomyInfo;const getArchiveLink=(contentType,itemData)=>{let slug,title="";const locale=itemData?.locale,taxonomyInfo=getTaxonomyInfo(contentType,itemData),{title:taxonomyTitle,isPage:taxonomyIsPage,contentTypes:taxonomyTypes,usePrimaryContentTypeSlug:taxonomyUseTypeSlug}=taxonomyInfo;"term"===contentType&&taxonomyIsPage&&(slug=(0,link_js_1.getSlug)({slug:"",contentType:contentType,itemData:itemData}),title=taxonomyTitle);const taxonomyType=taxonomyTypes[0],useArchiveType=taxonomyUseTypeSlug&&(0,string_js_1.isStringStrict)(taxonomyType);"taxonomy"===contentType&&useArchiveType&&(contentType=taxonomyType),"term"===contentType&&!taxonomyIsPage&&useArchiveType&&(contentType=taxonomyType);const archiveInfo=getArchiveInfo(contentType,locale),{id:archiveId,slug:archiveSlug,title:archiveTitle,contentType:archiveType}=archiveInfo;return archiveSlug&&archiveId&&(slug=(0,link_js_1.getSlug)({id:archiveId,slug:archiveSlug,contentType:archiveType,itemData:{locale:locale}}),title=getArchiveLabel(contentType,itemData,"plural",archiveTitle)),{title:title,link:(0,string_js_1.isStringStrict)(slug)?(0,link_js_1.getPermalink)(slug):""}};exports.getArchiveLink=getArchiveLink;const getArchiveLabel=(contentType,itemData,labelType="singular",fallback)=>{fallback=(0,string_js_1.isStringStrict)(fallback)?fallback:"singular"===labelType?"Post":"Posts";const label=getArchiveMeta(contentType,itemData?.locale)[labelType];return(0,string_js_1.isStringStrict)(label)?label:fallback},getArchiveLabels=(contentType,itemData)=>{let singular="Post",plural="Posts";const taxonomyInfo=getTaxonomyInfo(contentType,itemData),{title:taxonomyTitle,isPage:taxonomyIsPage,primaryContentType:taxonomyType,usePrimaryContentTypeSlug:taxonomyUseTypeSlug}=taxonomyInfo;if("term"===contentType&&taxonomyIsPage&&(0,string_js_1.isStringStrict)(taxonomyTitle))return{singular:taxonomyTitle,plural:taxonomyTitle};const useArchiveType=taxonomyUseTypeSlug&&(0,string_js_1.isStringStrict)(taxonomyType);return"taxonomy"===contentType&&useArchiveType&&(contentType=taxonomyType),"term"===contentType&&!taxonomyIsPage&&useArchiveType&&(contentType=taxonomyType),(0,string_js_1.isStringStrict)(contentType)&&(contentType=(0,contentType_js_1.normalizeContentType)(contentType),singular=getArchiveLabel(contentType,itemData),plural=getArchiveLabel(contentType,itemData,"plural")),{singular:singular,plural:plural}};exports.getArchiveLabels=getArchiveLabels;
@@ -0,0 +1,29 @@
1
+ import type { Taxonomy } from '../../global/globalTypes.js';
2
+ export interface ArchiveMeta {
3
+ id?: string;
4
+ slug?: string;
5
+ title?: string;
6
+ singular?: string;
7
+ plural?: string;
8
+ contentType?: string;
9
+ layout?: string;
10
+ order?: string;
11
+ display?: number;
12
+ }
13
+ export interface ArchiveInfo {
14
+ id: string;
15
+ slug: string;
16
+ title: string;
17
+ contentType: string;
18
+ }
19
+ export interface ArchiveTaxonomy extends Omit<Required<Taxonomy>, 'link'>, Pick<Taxonomy, 'link'> {
20
+ primaryContentType: string;
21
+ }
22
+ export interface ArchiveLink {
23
+ title: string;
24
+ link: string;
25
+ }
26
+ export interface ArchiveLabels {
27
+ singular: string;
28
+ plural: string;
29
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,3 @@
1
+ declare const isArray: (value: unknown) => value is unknown[];
2
+ declare const isArrayStrict: (value: unknown) => value is unknown[];
3
+ export { isArray, isArrayStrict };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isArrayStrict=exports.isArray=void 0;const isArray=value=>Array.isArray(value);exports.isArray=isArray;const isArrayStrict=value=>isArray(value)&&value.length>0;exports.isArrayStrict=isArrayStrict;
@@ -0,0 +1,2 @@
1
+ declare const isBoolean: (value: unknown) => value is boolean;
2
+ export { isBoolean };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBoolean=void 0;const isBoolean=value=>"boolean"==typeof value;exports.isBoolean=isBoolean;
@@ -0,0 +1,2 @@
1
+ declare const normalizeContentType: (contentType?: string) => string;
2
+ export { normalizeContentType };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.normalizeContentType=void 0;const string_js_1=require("../string/string.js"),config_js_1=require("../../config/config.js"),normalizeContentType=(contentType="")=>{if(!(0,string_js_1.isStringStrict)(contentType))return"";const normalType=config_js_1.config.normalTypes[contentType];return(0,string_js_1.isStringStrict)(normalType)?normalType:contentType};exports.normalizeContentType=normalizeContentType;
@@ -0,0 +1,3 @@
1
+ import type { DataSource } from './dataSourceTypes.js';
2
+ declare const dataSource: DataSource;
3
+ export { dataSource };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.dataSource=void 0;const string_js_1=require("../string/string.js"),config_js_1=require("../../config/config.js"),dataSource={isContentful:(source=config_js_1.config.source)=>"contentful"===config_js_1.config.cms.name&&"cms"===source,isWordPress:(source=config_js_1.config.source)=>"wordpress"===config_js_1.config.cms.name&&"cms"===source,isLocal:(source=config_js_1.config.source)=>"local"===source,get(){const cmsName=config_js_1.config.cms.name;return(0,string_js_1.isStringStrict)(cmsName)?cmsName:config_js_1.config.source}};exports.dataSource=dataSource;
@@ -0,0 +1,9 @@
1
+ import type { Source } from '../../global/globalTypes.js';
2
+ export type DataSourceCheck = (source?: Source) => boolean;
3
+ export type DataSourceGet = () => string;
4
+ export interface DataSource {
5
+ isContentful: DataSourceCheck;
6
+ isWordPress: DataSourceCheck;
7
+ isLocal: DataSourceCheck;
8
+ get: DataSourceGet;
9
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,2 @@
1
+ declare const escape: (value: string) => string;
2
+ export { escape };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.escape=void 0;const string_js_1=require("../string/string.js"),escape=value=>{if(!(0,string_js_1.isString)(value))throw new TypeError("Value is not a string");return value.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\//g,"&#x2F;").replace(/\\/g,"&#x5C;").replace(/`/g,"&#96;")};exports.escape=escape;
@@ -0,0 +1,3 @@
1
+ import type { ExcerptArgs } from './excerptTypes.js';
2
+ declare const getExcerpt: <T extends object>(args: ExcerptArgs<T>) => string;
3
+ export { getExcerpt };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getExcerpt=void 0;const object_js_1=require("../object/object.js"),string_js_1=require("../string/string.js"),shortcodes_js_1=require("../../shortcodes/shortcodes.js"),getContentWords=args=>{const{content:content,prop:prop,limit:limit=25}=args;let{_words:_words=[]}=args;const max=limit+1,wordsLen=_words.length;if((0,object_js_1.isObject)(content)&&wordsLen<max){const addMax=max-wordsLen;for(const[key,value]of Object.entries(content)){if(key===prop&&(0,string_js_1.isStringStrict)(value)){const val=(0,shortcodes_js_1.stripShortcodes)(value);if((0,string_js_1.isStringStrict)(val)){let valArr=val.split(" ");valArr.length>addMax&&(valArr=valArr.slice(0,addMax)),_words=_words.concat(valArr)}}(0,object_js_1.isObject)(value)&&(_words=getContentWords({content:value,prop:prop,limit:limit,_words:_words}))}}return _words},getExcerpt=args=>{const{excerpt:excerpt,content:content,prop:prop="content",limit:limit=25,limitExcerpt:limitExcerpt=!1,more:more="&hellip;"}=(0,object_js_1.isObjectStrict)(args)?args:{};let output="";if((0,string_js_1.isStringStrict)(excerpt)){if(output=excerpt,limitExcerpt){let excerptArr=excerpt.split(" ");excerptArr.length>limit&&(excerptArr=excerptArr.slice(0,limit),output=`${excerptArr.join(" ")}${more}`)}}else{const words=getContentWords({content:content,prop:prop,limit:limit}),wordsLen=words.length;wordsLen>0&&(wordsLen>limit&&more&&words.pop(),output=`${words.join(" ")}${wordsLen>limit?more:""}`)}return output};exports.getExcerpt=getExcerpt;
@@ -0,0 +1,14 @@
1
+ export interface ExcerptArgs<T extends object> {
2
+ excerpt?: string;
3
+ content?: T;
4
+ prop?: string;
5
+ limit?: number;
6
+ limitExcerpt?: boolean;
7
+ more?: string;
8
+ }
9
+ export interface ExcerptContentWordArgs<T> {
10
+ content: T;
11
+ prop?: string;
12
+ limit?: number;
13
+ _words?: string[];
14
+ }
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1,3 @@
1
+ declare const isFile: (value: unknown) => value is File;
2
+ declare const isBlob: (value: unknown) => value is Blob;
3
+ export { isFile, isBlob };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isBlob=exports.isFile=void 0;const isFile=value=>value instanceof File;exports.isFile=isFile;const isBlob=value=>value instanceof Blob;exports.isBlob=isBlob;
@@ -0,0 +1,2 @@
1
+ declare const getFilePaths: (dir: string) => AsyncGenerator<string>;
2
+ export { getFilePaths };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getFilePaths=void 0;const promises_1=require("node:fs/promises"),node_path_1=require("node:path"),string_js_1=require("../string/string.js"),getFilePaths=async function*(dir){if(!(0,string_js_1.isStringStrict)(dir))throw new Error("No directory provided");const files=await(0,promises_1.readdir)(dir,{withFileTypes:!0});for(const file of files)file.isDirectory()?yield*getFilePaths((0,node_path_1.join)(dir,file.name)):yield(0,node_path_1.join)(dir,file.name)};exports.getFilePaths=getFilePaths;
@@ -0,0 +1,3 @@
1
+ import type { GenericFunction } from '../../global/globalTypes.js';
2
+ declare const isFunction: <T>(value: T) => value is GenericFunction & T;
3
+ export { isFunction };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isFunction=void 0;const isFunction=value=>"function"==typeof value;exports.isFunction=isFunction;
@@ -0,0 +1,2 @@
1
+ declare const isHeading: (tag: string) => boolean;
2
+ export { isHeading };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.isHeading=void 0;const isHeading=tag=>new Set(["h1","h2","h3","h4","h5","h6"]).has(tag);exports.isHeading=isHeading;
@@ -0,0 +1,5 @@
1
+ import type { ImageArgs, ImageReturnType, ImageSizesArgs, ImageSizesReturn } from './imageTypes.js';
2
+ declare const getImage: <V extends boolean = false>(args: ImageArgs, returnDetails?: V) => ImageReturnType<V>;
3
+ declare const getImageClosestSize: (size: number, sizes?: number[]) => number;
4
+ declare const getImageSizes: (args: ImageSizesArgs) => ImageSizesReturn;
5
+ export { getImage, getImageClosestSize, getImageSizes };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getImageSizes=exports.getImageClosestSize=exports.getImage=void 0;const config_js_1=require("../../config/config.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),number_js_1=require("../number/number.js"),object_js_1=require("../object/object.js"),dataSource_js_1=require("../dataSource/dataSource.js"),getImageUrl=(url,format,quality,width,height,params)=>{const urlObj=new URL(url);return Object.entries(params).forEach(([key,value])=>{let val=value;"%format"===val&&(val=format),"%quality"===val&&(val=`${quality}`),"%width"===val&&(val=`${width}`),"%height"===val&&(val=`${height}`),urlObj.searchParams.set(key,val)}),urlObj.toString()},getImage=(args,returnDetails=!1)=>{const{data:data,classes:classes,attr:attr,alt:imageAlt="inherit",width:width="auto",height:height="auto",lazy:lazy=!0,picture:picture=!1,quality:quality=75,source:source=config_js_1.config.source,maxWidth:maxWidth=1200,viewportWidth:viewportWidth=100,sizes:sizes,format:format="webp",params:params={fm:"%format",q:"%quality",w:"%width",h:"%height"}}=(0,object_js_1.isObjectStrict)(args)?args:{},fallback=returnDetails?{output:"",aspectRatio:0,naturalWidth:0,naturalHeight:0,src:"",srcFallback:"",srcset:[],sizes:""}:"";if(!(0,object_js_1.isObjectStrict)(data))return fallback;const{path:path="",alt:dataAlt="",width:naturalWidth=1,height:naturalHeight=1,format:naturalFormat="jpg",sizes:dataSizes}=data;let{url:url=config_js_1.config.image.remoteUrl}=data,alt="inherit"===imageAlt?dataAlt:imageAlt;(0,string_js_1.isStringStrict)(alt)||(alt="");const isLocal="local"===source,isRemote=dataSource_js_1.dataSource.isContentful(source)||"remote"===source,isWordpress=dataSource_js_1.dataSource.isWordPress(source);if(isLocal){if(!(0,string_js_1.isStringStrict)(path))return fallback;url=`${config_js_1.config.image.localUrl}/${path}`}const aspectRatio=naturalHeight/naturalWidth,aspectRatioReverse=naturalWidth/naturalHeight;let w=naturalWidth,h=naturalHeight;if((0,number_js_1.isNumber)(width)&&(w=width,h=(0,string_js_1.isString)(height)?w*aspectRatio:height),(0,number_js_1.isNumber)(height)&&(h=height,w=(0,string_js_1.isString)(width)?h*aspectRatioReverse:width),w>maxWidth&&(w=Math.round(maxWidth),h=Math.round(w*aspectRatio)),isWordpress&&dataSizes&&!dataSizes[w]){const isNatural=w===naturalWidth;isNatural||(w=getImageClosestSize(w,Object.keys(dataSizes).map(s=>parseInt(s,10))),h=Math.round(w*aspectRatio)),isNatural&&(dataSizes[w]=url)}let src=url,srcFallback=url;isLocal&&(src=`${url}.${format}`,srcFallback=`${url}.${naturalFormat}`),isRemote&&(src=getImageUrl(url,format,quality,w,h,params),srcFallback=getImageUrl(url,naturalFormat,quality,w,h,params));const sizesValue=sizes||`(min-width: ${w/16}rem) ${w/16}rem, ${viewportWidth}vw`,srcsetFallback=[];let srcset=[...config_js_1.config.image.sizes];srcset.includes(w)||srcset.push(w),srcset=srcset.filter(s=>s<=w),srcset.sort((a,b)=>a-b);const srcsetSource=[];srcset.forEach(s=>{if(isLocal){const base=`${url}${s!==naturalWidth?`@${s}`:""}`;srcsetFallback.push(`${base}.${naturalFormat} ${s}w`),srcsetSource.push(`${base}.${format} ${s}w`)}if(isRemote){const sizeHeight=Math.round(s*aspectRatio);srcsetFallback.push(getImageUrl(url,naturalFormat,quality,s,sizeHeight,params)+` ${s}w`),srcsetSource.push(getImageUrl(url,format,quality,s,sizeHeight,params)+` ${s}w`)}if(isWordpress){const sizeUrl=dataSizes?.[s];(0,string_js_1.isStringStrict)(sizeUrl)&&srcsetSource.push(`${sizeUrl} ${s}w`)}});let sourceOutput="";picture&&(sourceOutput=`<source srcset="${srcsetSource.join(", ")}" sizes="${sizesValue}" type="image/${format}">`);let eagerHackOutput="";lazy||(eagerHackOutput=`\n <img\n alt=""\n role="presentation"\n aria-hidden="true"\n src="data:image/svg+xml;charset=utf-8,%3Csvg height='${h}' width='${w}' xmlns='http://www.w3.org/2000/svg' version='1.1'%3E%3C/svg%3E" style="pointerEvents: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%"\n >\n `);const output=`\n ${eagerHackOutput}\n ${sourceOutput}\n <img\n ${(0,string_js_1.isStringStrict)(classes)?` class="${classes}"`:""}\n alt="${alt}"\n src="${picture?srcFallback:src}"\n srcset="${picture?srcsetFallback.join(", "):srcsetSource.join(", ")}"\n sizes="${sizesValue}"\n width="${w}"\n height="${h}"\n ${(0,string_js_1.isStringStrict)(attr)?` ${attr}`:""}\n ${lazy?' loading="lazy" decoding="async"':' loading="eager" fetchpriority="high"'}\n >\n `;return returnDetails?{output:output,aspectRatio:aspectRatio,naturalWidth:naturalWidth,naturalHeight:naturalHeight,src:src,srcFallback:srcFallback,srcset:srcsetSource,sizes:sizesValue}:output};exports.getImage=getImage;const getImageClosestSize=(size,sizes=[])=>(sizes.length||(sizes=config_js_1.config.image.sizes),[...sizes].reduce((prev,curr)=>Math.abs(curr-size)<=Math.abs(prev-size)?curr:prev));exports.getImageClosestSize=getImageClosestSize;const getImageSizes=args=>{const fallback={maxWidth:0,sizes:""};if(!(0,object_js_1.isObjectStrict)(args))return fallback;const{parents:parents,widths:widths,maxWidths:maxWidths,breakpoints:breakpoints,source:source=config_js_1.config.source,viewportWidth:viewportWidth=100,maxWidth:max}=args;if(!((0,array_js_1.isArrayStrict)(parents)&&(0,object_js_1.isObjectStrict)(widths)&&(0,object_js_1.isObjectStrict)(maxWidths)&&(0,array_js_1.isArrayStrict)(breakpoints)))return fallback;let containerWidth=0;const columnWidths=[];let col=1,colSmall=1,colMedium=1,colLarge=1;parents.forEach(parent=>{if(!(0,object_js_1.isObjectStrict)(parent))return;const{renderType:renderType,args:args}=parent;if((0,object_js_1.isObjectStrict)(args)){if("column"===renderType){const{width:width="Default",widthSmall:widthSmall="Default",widthMedium:widthMedium="Default",widthLarge:widthLarge="Default"}=args,base=(0,number_js_1.isNumber)(widths[width])&&widths[width]?widths[width]:1,baseSmall=(0,number_js_1.isNumber)(widths[widthSmall])&&widths[widthSmall]?widths[widthSmall]:base,baseMedium=(0,number_js_1.isNumber)(widths[widthMedium])&&widths[widthMedium]?widths[widthMedium]:baseSmall,baseLarge=(0,number_js_1.isNumber)(widths[widthLarge])&&widths[widthLarge]?widths[widthLarge]:baseMedium;col*=base,colSmall*=baseSmall,colMedium*=baseMedium,colLarge*=baseLarge,columnWidths[0]=col,columnWidths[1]=colSmall,columnWidths[2]=colMedium,columnWidths[3]=colLarge}if("container"===renderType){const{maxWidth:maxWidth="Default"}=args;(0,number_js_1.isNumber)(maxWidths[maxWidth])&&(containerWidth=maxWidths[maxWidth])}}});const columnWidthsLen=columnWidths.length,hasContainerWidth=!!containerWidth;if(!columnWidthsLen&&!hasContainerWidth)return fallback;const maxPx=(0,number_js_1.isNumber)(max)?max/2:0,maxRem=maxPx/16+"rem",hasMax=!!maxPx&&(!hasContainerWidth||maxPx<containerWidth),breakpointsLen=breakpoints.length,maxWidthArr=[],sizesArr=[],sizeFactor=viewportWidth/100;let lastWidth=1,lastBreakpoint=0,lastSize="",containerWidthAdded=!1,sizesArrLen=0,maxIndex=-1;for(let i=0;i<breakpointsLen;i+=1){const breakpoint=breakpoints[i],width=columnWidths[i];if(!(0,number_js_1.isNumber)(width))continue;const bk=0===breakpoint&&0===i?breakpoints[i+1]:breakpoint,gteContainerWidth=hasContainerWidth&&breakpoint>=containerWidth,breakpointWidth=Math.round(width*(gteContainerWidth?containerWidth:bk)),gtMaxWidth=hasMax&&breakpointWidth>maxPx,sizeWidth=gteContainerWidth?breakpointWidth/16:100*width*sizeFactor,size=gteContainerWidth?`${sizeWidth}rem`:`${sizeWidth%1==0?sizeWidth:sizeWidth.toFixed(2)}vw`;if(hasContainerWidth&&containerWidth>lastBreakpoint&&containerWidth<breakpoint){const relMaxWidth=Math.round(lastWidth*containerWidth),relSize=relMaxWidth/16+"rem";hasMax&&relMaxWidth>maxPx||(maxWidthArr.push(relMaxWidth),sizesArrLen=sizesArr.push(`(min-width: ${containerWidth/16}rem) ${relSize}`),containerWidthAdded=!0,lastSize=relSize)}gtMaxWidth||maxWidthArr.push(breakpointWidth),gtMaxWidth||lastSize===size||(sizesArrLen=sizesArr.push(breakpoint?`(min-width: ${breakpoint/16}rem) ${size}`:size)),hasMax&&maxPx>lastBreakpoint&&maxPx<breakpoint&&maxPx<breakpointWidth&&(maxIndex=sizesArrLen),lastWidth=width,lastBreakpoint=breakpoint,lastSize=size}if(!containerWidthAdded&&hasContainerWidth&&containerWidth>lastBreakpoint){const relMaxWidth=Math.round(lastWidth*containerWidth),relSize=relMaxWidth/16+"rem";hasMax&&relMaxWidth>maxPx||(maxWidthArr.push(relMaxWidth),sizesArrLen=sizesArr.push(`(min-width: ${containerWidth/16}rem) ${relSize}`),containerWidthAdded=!0)}hasMax&&maxPx>lastBreakpoint&&(maxIndex=sizesArrLen),-1!==maxIndex&&(maxWidthArr.push(maxPx),sizesArr.splice(maxIndex,0,`(min-width: ${maxRem}) ${maxRem}`));const maxWidth=2*Math.max(...maxWidthArr);if(!hasMax&&(!columnWidthsLen||1===col&&1===colSmall&&1===colMedium&&1===colLarge)){const sizeWidth=maxWidth/32+"rem";sizesArr[0]=`${viewportWidth}vw`,sizesArr[1]=`(min-width: ${sizeWidth}) ${sizeWidth}`}const sizes=sizesArr.reverse().join(", ");return"local"===source?{maxWidth:getImageClosestSize(maxWidth),sizes:sizes}:{maxWidth:maxWidth,sizes:sizes}};exports.getImageSizes=getImageSizes;
@@ -0,0 +1,3 @@
1
+ import sharp from 'sharp';
2
+ declare const setLocalImages: () => Promise<sharp.OutputInfo[]>;
3
+ export { setLocalImages };
@@ -0,0 +1 @@
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(mod){return mod&&mod.__esModule?mod:{default:mod}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.setLocalImages=void 0;const node_path_1=require("node:path"),promises_1=require("node:fs/promises"),sharp_1=__importDefault(require("sharp")),filePath_js_1=require("../file/filePath.js"),string_js_1=require("../string/string.js"),store_js_1=require("../../store/store.js"),config_js_1=require("../../config/config.js"),setLocalImages=async()=>{const inputDir=config_js_1.config.image.inputDir,outputDir=config_js_1.config.image.outputDir;if(!(0,string_js_1.isStringStrict)(inputDir)||!(0,string_js_1.isStringStrict)(outputDir))throw new Error("No input or output directories");await(0,promises_1.mkdir)((0,node_path_1.resolve)(outputDir),{recursive:!0});const images=[],meta={};for await(const path of(0,filePath_js_1.getFilePaths)(inputDir)){const baseName=(0,node_path_1.basename)(path),ext=(0,node_path_1.extname)(baseName);if(!(0,string_js_1.isStringStrict)(ext))continue;const[base]=baseName.split(ext);if(!(0,string_js_1.isStringStrict)(base?.trim()))continue;let[,folders]=(0,node_path_1.dirname)(path).split(`${inputDir}/`);(0,string_js_1.isStringStrict)(folders)&&folders!==baseName?await(0,promises_1.mkdir)((0,node_path_1.resolve)(outputDir,folders),{recursive:!0}):folders="";const instance=(0,sharp_1.default)(path),metadata=await(0,sharp_1.default)(path).metadata(),stats=await(0,promises_1.stat)(path),{width:width=0,height:height=0,format:fileFormat="jpeg"}=metadata,id=`${folders?`${folders}/`:""}${base}`,format=ext.replace(".","");meta[id]={path:id,name:baseName,type:`image/${fileFormat}`,format:format,size:stats.size,width:width,height:height};let sizes=[...config_js_1.config.image.sizes];sizes.includes(width)||sizes.push(width),sizes=sizes.filter(s=>s<=width),sizes.forEach(size=>{images.push({size:size,format:format,path:(0,node_path_1.resolve)(path),newPath:(0,node_path_1.resolve)(outputDir,folders,`${base}${size!==width?`@${size}`:""}`),instance:instance})})}if(!images.length)throw new Error("No local images to transform");return(0,store_js_1.setStoreItem)("imageMeta",meta),await Promise.all(images.map(async image=>{const{size:size,instance:instance,newPath:newPath,format:format}=image;return await instance.clone().resize(size).toFile(`${newPath}.${format}`),await instance.clone().resize(size).webp({quality:config_js_1.config.image.quality}).toFile(`${newPath}.webp`)}))};exports.setLocalImages=setLocalImages;
@@ -0,0 +1,3 @@
1
+ import type { ImageRemote } from './imageTypes.js';
2
+ declare const getRemoteImages: (images: ImageRemote[]) => Promise<string[]>;
3
+ export { getRemoteImages };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getRemoteImages=void 0;const promises_1=require("node:fs/promises"),node_path_1=require("node:path"),config_js_1=require("../../config/config.js"),string_js_1=require("../string/string.js"),array_js_1=require("../array/array.js"),getRemoteImages=async images=>{const inputDir=config_js_1.config.image.inputDir;if(!(0,string_js_1.isStringStrict)(inputDir))throw new Error("No input directory");if(!(0,array_js_1.isArrayStrict)(images))throw new Error("No images array");return await Promise.all(images.map(async image=>{const{path:path,url:url,format:format="jpg"}=image;if(!(0,string_js_1.isStringStrict)(path)||!(0,string_js_1.isStringStrict)(url)||!(0,string_js_1.isStringStrict)(format))throw new Error("No path, URL or format");const resp=await fetch(url);if(!resp.ok)throw new Error("Failed to fetch image");const buffer=await resp.arrayBuffer(),fullPath=`${inputDir}/${path}.${format}`,folders=fullPath.split("/");return folders.pop(),await(0,promises_1.mkdir)((0,node_path_1.resolve)(folders.join("/")),{recursive:!0}),await(0,promises_1.writeFile)((0,node_path_1.resolve)(fullPath),Buffer.from(buffer)),fullPath}))};exports.getRemoteImages=getRemoteImages;