@powerlines/plugin-date 0.12.143 → 0.12.144

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 (198) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/components/date-fns.cjs +527 -0
  3. package/dist/components/date-fns.d.cts +13 -0
  4. package/dist/components/date-fns.d.mts +13 -0
  5. package/dist/components/date-fns.mjs +527 -0
  6. package/dist/components/dayjs.cjs +472 -0
  7. package/dist/components/dayjs.d.cts +13 -0
  8. package/dist/components/dayjs.d.mts +13 -0
  9. package/dist/components/dayjs.mjs +472 -0
  10. package/dist/components/index.cjs +4 -0
  11. package/dist/components/index.d.cts +4 -0
  12. package/dist/components/index.d.mts +4 -0
  13. package/dist/components/index.mjs +6 -0
  14. package/dist/components/luxon.cjs +476 -0
  15. package/dist/components/luxon.d.cts +13 -0
  16. package/dist/components/luxon.d.mts +13 -0
  17. package/dist/components/luxon.mjs +476 -0
  18. package/dist/components/moment.cjs +462 -0
  19. package/dist/components/moment.d.cts +13 -0
  20. package/dist/components/moment.d.mts +13 -0
  21. package/dist/components/moment.mjs +462 -0
  22. package/dist/deepkit/schemas/reflection.cjs +3998 -0
  23. package/dist/deepkit/schemas/reflection.d.cts +1560 -0
  24. package/dist/deepkit/schemas/reflection.d.mts +1560 -0
  25. package/dist/deepkit/schemas/reflection.mjs +3996 -0
  26. package/dist/deepkit/schemas/reflection2.cjs +4112 -0
  27. package/dist/deepkit/schemas/reflection2.mjs +4110 -0
  28. package/dist/deepkit/src/capnp.cjs +913 -0
  29. package/dist/deepkit/src/capnp.mjs +911 -0
  30. package/dist/deepkit/src/esbuild-plugin.cjs +47 -0
  31. package/dist/deepkit/src/esbuild-plugin.mjs +46 -0
  32. package/dist/deepkit/src/reflect-type.cjs +22 -0
  33. package/dist/deepkit/src/reflect-type.mjs +20 -0
  34. package/dist/deepkit/src/resolve-reflections.cjs +16 -0
  35. package/dist/deepkit/src/resolve-reflections.mjs +15 -0
  36. package/dist/deepkit/src/transformer.cjs +52 -0
  37. package/dist/deepkit/src/transformer.mjs +49 -0
  38. package/dist/deepkit/src/transpile.cjs +29 -0
  39. package/dist/deepkit/src/transpile.mjs +27 -0
  40. package/dist/deepkit/src/types.d.cts +10 -0
  41. package/dist/deepkit/src/types.d.mts +10 -0
  42. package/dist/deepkit/src/utilities.cjs +66 -0
  43. package/dist/deepkit/src/utilities.mjs +65 -0
  44. package/dist/index.cjs +17 -13844
  45. package/dist/index.d.cts +9 -40
  46. package/dist/index.d.mts +9 -40
  47. package/dist/index.mjs +6 -13800
  48. package/dist/plugin-alloy/src/core/components/output.cjs +38 -0
  49. package/dist/plugin-alloy/src/core/components/output.mjs +37 -0
  50. package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +20 -0
  51. package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +19 -0
  52. package/dist/plugin-alloy/src/core/components/source-file.cjs +60 -0
  53. package/dist/plugin-alloy/src/core/components/source-file.mjs +58 -0
  54. package/dist/plugin-alloy/src/core/contexts/context.cjs +60 -0
  55. package/dist/plugin-alloy/src/core/contexts/context.mjs +54 -0
  56. package/dist/plugin-alloy/src/core/contexts/index.cjs +2 -0
  57. package/dist/plugin-alloy/src/core/contexts/index.mjs +4 -0
  58. package/dist/plugin-alloy/src/core/contexts/reflection.cjs +46 -0
  59. package/dist/plugin-alloy/src/core/contexts/reflection.mjs +42 -0
  60. package/dist/plugin-alloy/src/helpers/refkey.cjs +16 -0
  61. package/dist/plugin-alloy/src/helpers/refkey.mjs +15 -0
  62. package/dist/plugin-alloy/src/index.cjs +90 -0
  63. package/dist/plugin-alloy/src/index.mjs +88 -0
  64. package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +7 -0
  65. package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +9 -0
  66. package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +5 -0
  67. package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +7 -0
  68. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +17 -0
  69. package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +17 -0
  70. package/dist/plugin-alloy/src/types/components.d.mts +3 -0
  71. package/dist/plugin-alloy/src/types/index.d.mts +2 -0
  72. package/dist/plugin-alloy/src/types/plugin.d.cts +37 -0
  73. package/dist/plugin-alloy/src/types/plugin.d.mts +37 -0
  74. package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +47 -0
  75. package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +46 -0
  76. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +75 -0
  77. package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +73 -0
  78. package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +359 -0
  79. package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +350 -0
  80. package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +143 -0
  81. package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +140 -0
  82. package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +53 -0
  83. package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +52 -0
  84. package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +94 -0
  85. package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +93 -0
  86. package/dist/plugin-automd/src/index.cjs +101 -0
  87. package/dist/plugin-automd/src/index.mjs +98 -0
  88. package/dist/plugin-automd/src/types/plugin.d.cts +38 -0
  89. package/dist/plugin-automd/src/types/plugin.d.mts +40 -0
  90. package/dist/plugin-automd/src/types/toc.d.cts +33 -0
  91. package/dist/plugin-automd/src/types/toc.d.mts +33 -0
  92. package/dist/plugin-babel/src/helpers/ast-utils.cjs +10 -0
  93. package/dist/plugin-babel/src/helpers/ast-utils.mjs +9 -0
  94. package/dist/plugin-babel/src/helpers/create-plugin.cjs +41 -0
  95. package/dist/plugin-babel/src/helpers/create-plugin.mjs +39 -0
  96. package/dist/plugin-babel/src/helpers/filters.cjs +23 -0
  97. package/dist/plugin-babel/src/helpers/filters.mjs +21 -0
  98. package/dist/plugin-babel/src/helpers/index.cjs +5 -0
  99. package/dist/plugin-babel/src/helpers/index.mjs +7 -0
  100. package/dist/plugin-babel/src/helpers/module-helpers.cjs +38 -0
  101. package/dist/plugin-babel/src/helpers/module-helpers.mjs +35 -0
  102. package/dist/plugin-babel/src/helpers/options.cjs +50 -0
  103. package/dist/plugin-babel/src/helpers/options.mjs +47 -0
  104. package/dist/plugin-babel/src/index.cjs +91 -0
  105. package/dist/plugin-babel/src/index.mjs +89 -0
  106. package/dist/plugin-babel/src/types/index.d.mts +1 -0
  107. package/dist/plugin-babel/src/types/plugin.d.cts +15 -0
  108. package/dist/plugin-babel/src/types/plugin.d.mts +15 -0
  109. package/dist/plugin-env/src/babel/index.cjs +1 -0
  110. package/dist/plugin-env/src/babel/index.mjs +3 -0
  111. package/dist/plugin-env/src/babel/plugin.cjs +121 -0
  112. package/dist/plugin-env/src/babel/plugin.mjs +119 -0
  113. package/dist/plugin-env/src/components/docs.cjs +9 -0
  114. package/dist/plugin-env/src/components/docs.mjs +11 -0
  115. package/dist/plugin-env/src/components/env.cjs +487 -0
  116. package/dist/plugin-env/src/components/env.mjs +484 -0
  117. package/dist/plugin-env/src/components/index.cjs +2 -0
  118. package/dist/plugin-env/src/components/index.mjs +4 -0
  119. package/dist/plugin-env/src/helpers/automd-generator.cjs +22 -0
  120. package/dist/plugin-env/src/helpers/automd-generator.mjs +21 -0
  121. package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +55 -0
  122. package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +54 -0
  123. package/dist/plugin-env/src/helpers/index.cjs +6 -0
  124. package/dist/plugin-env/src/helpers/index.mjs +8 -0
  125. package/dist/plugin-env/src/helpers/load.cjs +83 -0
  126. package/dist/plugin-env/src/helpers/load.mjs +80 -0
  127. package/dist/plugin-env/src/helpers/persistence.cjs +199 -0
  128. package/dist/plugin-env/src/helpers/persistence.mjs +188 -0
  129. package/dist/plugin-env/src/helpers/reflect.cjs +125 -0
  130. package/dist/plugin-env/src/helpers/reflect.mjs +117 -0
  131. package/dist/plugin-env/src/helpers/source-file-env.cjs +24 -0
  132. package/dist/plugin-env/src/helpers/source-file-env.mjs +23 -0
  133. package/dist/plugin-env/src/helpers/template-helpers.cjs +2 -0
  134. package/dist/plugin-env/src/helpers/template-helpers.mjs +4 -0
  135. package/dist/plugin-env/src/index.cjs +172 -0
  136. package/dist/plugin-env/src/index.mjs +170 -0
  137. package/dist/plugin-env/src/types/plugin.d.cts +151 -0
  138. package/dist/plugin-env/src/types/plugin.d.mts +153 -0
  139. package/dist/plugin-env/src/types/runtime.d.cts +792 -0
  140. package/dist/plugin-env/src/types/runtime.d.mts +792 -0
  141. package/dist/powerlines/src/lib/build/esbuild.cjs +102 -0
  142. package/dist/powerlines/src/lib/build/esbuild.mjs +100 -0
  143. package/dist/powerlines/src/lib/entry.cjs +12 -0
  144. package/dist/powerlines/src/lib/entry.mjs +14 -0
  145. package/dist/powerlines/src/lib/logger.cjs +41 -0
  146. package/dist/powerlines/src/lib/logger.mjs +39 -0
  147. package/dist/powerlines/src/lib/utilities/bundle.cjs +35 -0
  148. package/dist/powerlines/src/lib/utilities/bundle.mjs +34 -0
  149. package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
  150. package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
  151. package/dist/powerlines/src/lib/utilities/resolve.cjs +30 -0
  152. package/dist/powerlines/src/lib/utilities/resolve.mjs +29 -0
  153. package/dist/powerlines/src/plugin-utils/paths.cjs +1 -0
  154. package/dist/powerlines/src/plugin-utils/paths.mjs +3 -0
  155. package/dist/powerlines/src/types/babel.d.cts +22 -0
  156. package/dist/powerlines/src/types/babel.d.mts +22 -0
  157. package/dist/powerlines/src/types/build.d.cts +145 -0
  158. package/dist/powerlines/src/types/build.d.mts +145 -0
  159. package/dist/powerlines/src/types/commands.d.cts +8 -0
  160. package/dist/powerlines/src/types/commands.d.mts +9 -0
  161. package/dist/powerlines/src/types/config.d.cts +387 -0
  162. package/dist/powerlines/src/types/config.d.mts +388 -0
  163. package/dist/powerlines/src/types/context.d.cts +414 -0
  164. package/dist/powerlines/src/types/context.d.mts +416 -0
  165. package/dist/powerlines/src/types/fs.d.cts +486 -0
  166. package/dist/powerlines/src/types/fs.d.mts +486 -0
  167. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  168. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  169. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  170. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  171. package/dist/powerlines/src/types/resolved.d.mts +82 -0
  172. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  173. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  174. package/dist/types/index.cjs +0 -3
  175. package/dist/types/index.d.cts +2 -3
  176. package/dist/types/index.d.mts +2 -3
  177. package/dist/types/index.mjs +0 -4
  178. package/dist/types/plugin.cjs +0 -1
  179. package/dist/types/plugin.d.cts +42 -1
  180. package/dist/types/plugin.d.mts +42 -1
  181. package/dist/types/plugin.mjs +0 -2
  182. package/dist/types/runtime.cjs +0 -1
  183. package/dist/types/runtime.d.cts +710 -1
  184. package/dist/types/runtime.d.mts +710 -1
  185. package/dist/types/runtime.mjs +0 -2
  186. package/package.json +5 -5
  187. package/dist/index-CA4VvAY_.d.mts +0 -1
  188. package/dist/index-CmCelmEL.d.cts +0 -1
  189. package/dist/plugin-Bb-hCaYN.d.mts +0 -4441
  190. package/dist/plugin-BmurFkyw.d.cts +0 -4439
  191. package/dist/plugin-DHXHjv16.cjs +0 -0
  192. package/dist/plugin-ufqFO5xS.mjs +0 -1
  193. package/dist/runtime-B7WoCmC4.mjs +0 -1
  194. package/dist/runtime-B8LVkjWB.d.cts +0 -711
  195. package/dist/runtime-CiYq8JJ6.d.mts +0 -711
  196. package/dist/runtime-D4zTdSwv.cjs +0 -0
  197. package/dist/types-BReKsBV6.mjs +0 -1
  198. package/dist/types-CBTc19th.cjs +0 -0
@@ -0,0 +1,29 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
+ key = keys[i];
12
+ if (!__hasOwnProp.call(to, key) && key !== except) {
13
+ __defProp(to, key, {
14
+ get: ((k) => from[k]).bind(null, key),
15
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
+ });
17
+ }
18
+ }
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
23
+ value: mod,
24
+ enumerable: true
25
+ }) : target, mod));
26
+
27
+ //#endregion
28
+
29
+ exports.__toESM = __toESM;
@@ -0,0 +1,527 @@
1
+ const require_file_header = require('../powerlines/src/lib/utilities/file-header.cjs');
2
+
3
+ //#region src/components/date-fns.ts
4
+ /**
5
+ * Generates the Powerlines configuration file.
6
+ *
7
+ * @param context - The build context containing runtime information.
8
+ * @returns A string representing the configuration file content.
9
+ */
10
+ function dateFnsModule(context) {
11
+ return `
12
+ /**
13
+ * The Date module provides utility functions for date manipulation and formatting
14
+ *
15
+ * @module ${context.config.output.builtinPrefix}:date
16
+ */
17
+
18
+ ${require_file_header.getFileHeader(context)}
19
+
20
+ import { DateFormats, TimeUnit } from "@powerlines/plugin-date/types/runtime";
21
+ import { addDays as dateFnsAddDays } from "date-fns/addDays";
22
+ import { addHours as dateFnsAddHours } from "date-fns/addHours";
23
+ import { addMinutes as dateFnsAddMinutes } from "date-fns/addMinutes";
24
+ import { addMonths as dateFnsAddMonths } from "date-fns/addMonths";
25
+ import { addSeconds as dateFnsAddSeconds } from "date-fns/addSeconds";
26
+ import { addWeeks as dateFnsAddWeeks } from "date-fns/addWeeks";
27
+ import { addYears as dateFnsAddYears } from "date-fns/addYears";
28
+ import { differenceInDays } from "date-fns/differenceInDays";
29
+ import { differenceInHours } from "date-fns/differenceInHours";
30
+ import { differenceInMilliseconds } from "date-fns/differenceInMilliseconds";
31
+ import { differenceInMinutes } from "date-fns/differenceInMinutes";
32
+ import { differenceInMonths } from "date-fns/differenceInMonths";
33
+ import { differenceInQuarters } from "date-fns/differenceInQuarters";
34
+ import { differenceInSeconds } from "date-fns/differenceInSeconds";
35
+ import { differenceInWeeks } from "date-fns/differenceInWeeks";
36
+ import { differenceInYears } from "date-fns/differenceInYears";
37
+ import { eachDayOfInterval } from "date-fns/eachDayOfInterval";
38
+ import { endOfDay as dateFnsEndOfDay } from "date-fns/endOfDay";
39
+ import { endOfMonth as dateFnsEndOfMonth } from "date-fns/endOfMonth";
40
+ import { endOfWeek as dateFnsEndOfWeek } from "date-fns/endOfWeek";
41
+ import { endOfYear as dateFnsEndOfYear } from "date-fns/endOfYear";
42
+ import { format as dateFnsFormat, longFormatters } from "date-fns/format";
43
+ import { formatISO } from "date-fns/formatISO";
44
+ import { getDate as dateFnsGetDate } from "date-fns/getDate";
45
+ import { getDay as dateFnsGetDay } from "date-fns/getDay";
46
+ import { getDaysInMonth as dateFnsGetDaysInMonth } from "date-fns/getDaysInMonth";
47
+ import { getHours as dateFnsGetHours } from "date-fns/getHours";
48
+ import { getMinutes as dateFnsGetMinutes } from "date-fns/getMinutes";
49
+ import { getMonth as dateFnsGetMonth } from "date-fns/getMonth";
50
+ import { getSeconds as dateFnsGetSeconds } from "date-fns/getSeconds";
51
+ import { getWeek as dateFnsGetWeek } from "date-fns/getWeek";
52
+ import { getYear as dateFnsGetYear } from "date-fns/getYear";
53
+ import { isAfter as dateFnsIsAfter } from "date-fns/isAfter";
54
+ import { isBefore as dateFnsIsBefore } from "date-fns/isBefore";
55
+ import { isEqual as dateFnsIsEqual } from "date-fns/isEqual";
56
+ import { isSameDay as dateFnsIsSameDay } from "date-fns/isSameDay";
57
+ import { isSameHour as dateFnsIsSameHour } from "date-fns/isSameHour";
58
+ import { isSameMonth as dateFnsIsSameMonth } from "date-fns/isSameMonth";
59
+ import { isSameYear as dateFnsIsSameYear } from "date-fns/isSameYear";
60
+ import { isValid as dateFnsIsValid } from "date-fns/isValid";
61
+ import { isWithinInterval } from "date-fns/isWithinInterval";
62
+ import { Locale } from "date-fns/locale";
63
+ import { ${context.env.parsed.DEFAULT_LOCALE?.replaceAll("-", "") || "enUS"} as defaultLocale } from "date-fns/locale/${context.env.parsed.DEFAULT_LOCALE || "en-US"}";
64
+ import { parse as dateFnsParse } from "date-fns/parse";
65
+ import { parseISO as dateFnsParseISO } from "date-fns/parseISO";
66
+ import { setDate as dateFnsSetDate } from "date-fns/setDate";
67
+ import { setHours as dateFnsSetHours } from "date-fns/setHours";
68
+ import { setMinutes as dateFnsSetMinutes } from "date-fns/setMinutes";
69
+ import { setMonth as dateFnsSetMonth } from "date-fns/setMonth";
70
+ import { setSeconds as dateFnsSetSeconds } from "date-fns/setSeconds";
71
+ import { setYear as dateFnsSetYear } from "date-fns/setYear";
72
+ import { startOfDay as dateFnsStartOfDay } from "date-fns/startOfDay";
73
+ import { startOfMonth as dateFnsStartOfMonth } from "date-fns/startOfMonth";
74
+ import { startOfWeek as dateFnsStartOfWeek } from "date-fns/startOfWeek";
75
+ import { startOfYear as dateFnsStartOfYear } from "date-fns/startOfYear";
76
+
77
+ export const formats: DateFormats = {
78
+ dayOfMonth: "d",
79
+ fullDate: "PP",
80
+ fullDateWithWeekday: "PPPP",
81
+ fullDateTime: "PP p",
82
+ fullDateTime12h: "PP hh:mm aa",
83
+ fullDateTime24h: "PP HH:mm",
84
+ fullTime: "p",
85
+ fullTime12h: "hh:mm aa",
86
+ fullTime24h: "HH:mm",
87
+ hours12h: "hh",
88
+ hours24h: "HH",
89
+ keyboardDate: "P",
90
+ keyboardDateTime: "P p",
91
+ keyboardDateTime12h: "P hh:mm aa",
92
+ keyboardDateTime24h: "P HH:mm",
93
+ systemDateTime: "P HH:mm:ss.SSS",
94
+ filePathDateTime: "P_HH-mm-ss-SSS",
95
+ minutes: "mm",
96
+ month: "LLLL",
97
+ monthAndDate: "MMMM d",
98
+ monthAndYear: "LLLL yyyy",
99
+ monthShort: "MMM",
100
+ weekday: "EEEE",
101
+ weekdayShort: "EEE",
102
+ normalDate: "d MMMM",
103
+ normalDateWithWeekday: "EEE, MMM d",
104
+ seconds: "ss",
105
+ shortDate: "MMM d",
106
+ year: "yyyy"
107
+ };
108
+
109
+ export const locale: Locale = defaultLocale;
110
+
111
+ /**
112
+ * Creates a date object using the provided value.
113
+ *
114
+ * @remarks
115
+ * This function creates a date object using the provided value. If the value is \`null\`, it returns \`null\`. If the value is \`undefined\`, it returns the current date. If the value is a string, it parses the string as a date. If the value is a number, it treats it as a timestamp. If the value is a date object, it returns the date object.
116
+ *
117
+ * @example
118
+ * \`\`\`ts
119
+ * import { createDate } from "storm:date";
120
+ *
121
+ * const date = createDate("2023-10-01");
122
+ * console.log(date.format("YYYY-MM-DD")); // Outputs: 2023-10-01
123
+ * \`\`\`
124
+ *
125
+ * @param value - The value to create the date object from.
126
+ * @returns A date object or \`null\` if the value is \`null\`.
127
+ */
128
+ export function createDate<
129
+ TArg = undefined,
130
+ TResultingDate = TArg extends null
131
+ ? null
132
+ : TArg extends undefined
133
+ ? Date
134
+ : Date | null
135
+ >(value?: TArg): TResultingDate {
136
+ if (typeof value === "undefined") {
137
+ return new Date() as TResultingDate;
138
+ }
139
+ if (value === null) {
140
+ return null as TResultingDate;
141
+ }
142
+ return new Date(value as string | number) as TResultingDate;
143
+ }
144
+
145
+ export const type = "date-fns";
146
+
147
+ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more
148
+ // strict signature and delegate to the more lenient signature. Otherwise, we have downstream type errors upon usage.
149
+ export function is12HourCycleInCurrentLocale(): boolean {
150
+ if (locale) {
151
+ return /a/.test(locale.formatLong?.time({}));
152
+ }
153
+
154
+ // By default date-fns is using en-US locale with am/pm enabled
155
+ return true;
156
+ }
157
+
158
+ export function getFormatHelperText(format: string) {
159
+ // @see https://github.com/date-fns/date-fns/blob/master/src/format/index.js#L31
160
+ const longFormatRegexp = /P+p+|P+|p+|''|'(?:''|[^'])+(?:'|$)|./g;
161
+ const _locale = locale || defaultLocale;
162
+
163
+ return (
164
+ format
165
+ .match(longFormatRegexp)
166
+ ?.map(token => {
167
+ const firstCharacter = token[0];
168
+ if (firstCharacter === "p" || firstCharacter === "P") {
169
+ const longFormatter = longFormatters[firstCharacter]!;
170
+
171
+ return longFormatter(token, _locale.formatLong);
172
+ }
173
+
174
+ return token;
175
+ })
176
+ .join("")
177
+ .replace(/aaa|aa|a/g, "(a|p)m")
178
+ .toLocaleLowerCase() ?? format
179
+ );
180
+ }
181
+
182
+ export function parseISO(isoString: string) {
183
+ return dateFnsParseISO(isoString);
184
+ }
185
+
186
+ export function toISO(value: Date) {
187
+ return formatISO(value, {
188
+ format: "extended"
189
+ });
190
+ }
191
+
192
+ export function getCurrentLocaleCode() {
193
+ return locale?.code || $storm.env.DEFAULT_LOCALE;
194
+ }
195
+
196
+ export function addSeconds(value: Date, count: number) {
197
+ return dateFnsAddSeconds(value, count);
198
+ }
199
+
200
+ export function addMinutes(value: Date, count: number) {
201
+ return dateFnsAddMinutes(value, count);
202
+ }
203
+
204
+ export function addHours(value: Date, count: number) {
205
+ return dateFnsAddHours(value, count);
206
+ }
207
+
208
+ export function addDays(value: Date, count: number) {
209
+ return dateFnsAddDays(value, count);
210
+ }
211
+
212
+ export function addWeeks(value: Date, count: number) {
213
+ return dateFnsAddWeeks(value, count);
214
+ }
215
+
216
+ export function addMonths(value: Date, count: number) {
217
+ return dateFnsAddMonths(value, count);
218
+ }
219
+
220
+ export function addYears(value: Date, count: number) {
221
+ return dateFnsAddYears(value, count);
222
+ }
223
+
224
+ export function isValid(value: any) {
225
+ return dateFnsIsValid(createDate(value));
226
+ }
227
+
228
+ export function getDiff(
229
+ value: Date,
230
+ comparing: Date | string,
231
+ unit?: TimeUnit
232
+ ) {
233
+ // we output 0 if the compare date is string and parsing is not valid
234
+ const dateToCompare = createDate(comparing) ?? value;
235
+ if (!isValid(dateToCompare)) {
236
+ return 0;
237
+ }
238
+
239
+ switch (unit) {
240
+ case "years":
241
+ return differenceInYears(value, dateToCompare);
242
+ case "quarters":
243
+ return differenceInQuarters(value, dateToCompare);
244
+ case "months":
245
+ return differenceInMonths(value, dateToCompare);
246
+ case "weeks":
247
+ return differenceInWeeks(value, dateToCompare);
248
+ case "days":
249
+ return differenceInDays(value, dateToCompare);
250
+ case "hours":
251
+ return differenceInHours(value, dateToCompare);
252
+ case "minutes":
253
+ return differenceInMinutes(value, dateToCompare);
254
+ case "seconds":
255
+ return differenceInSeconds(value, dateToCompare);
256
+ case "milliseconds":
257
+ case undefined:
258
+ default:
259
+ return differenceInMilliseconds(value, dateToCompare);
260
+ }
261
+ }
262
+
263
+ export function isAfter(value: Date, comparing: Date) {
264
+ return dateFnsIsAfter(value, comparing);
265
+ }
266
+
267
+ export function isBefore(value: Date, comparing: Date) {
268
+ return dateFnsIsBefore(value, comparing);
269
+ }
270
+
271
+ export function startOfDay(value: Date) {
272
+ return dateFnsStartOfDay(value);
273
+ }
274
+
275
+ export function endOfDay(value: Date) {
276
+ return dateFnsEndOfDay(value);
277
+ }
278
+
279
+ export function getHours(value: Date) {
280
+ return dateFnsGetHours(value);
281
+ }
282
+
283
+ export function setHours(value: Date, count: number) {
284
+ return dateFnsSetHours(value, count);
285
+ }
286
+
287
+ export function setMinutes(value: Date, count: number) {
288
+ return dateFnsSetMinutes(value, count);
289
+ }
290
+
291
+ export function getSeconds(value: Date) {
292
+ return dateFnsGetSeconds(value);
293
+ }
294
+
295
+ export function setSeconds(value: Date, count: number) {
296
+ return dateFnsSetSeconds(value, count);
297
+ }
298
+
299
+ export function isSameDay(value: Date, comparing: Date) {
300
+ return dateFnsIsSameDay(value, comparing);
301
+ }
302
+
303
+ export function isSameMonth(value: Date, comparing: Date) {
304
+ return dateFnsIsSameMonth(value, comparing);
305
+ }
306
+
307
+ export function isSameYear(value: Date, comparing: Date) {
308
+ return dateFnsIsSameYear(value, comparing);
309
+ }
310
+
311
+ export function isSameHour(value: Date, comparing: Date) {
312
+ return dateFnsIsSameHour(value, comparing);
313
+ }
314
+
315
+ export function startOfYear(value: Date) {
316
+ return dateFnsStartOfYear(value);
317
+ }
318
+
319
+ export function endOfYear(value: Date) {
320
+ return dateFnsEndOfYear(value);
321
+ }
322
+
323
+ export function startOfMonth(value: Date) {
324
+ return dateFnsStartOfMonth(value);
325
+ }
326
+
327
+ export function endOfMonth(value: Date) {
328
+ return dateFnsEndOfMonth(value);
329
+ }
330
+
331
+ export function startOfWeek(value: Date) {
332
+ return dateFnsStartOfWeek(value, {
333
+ locale
334
+ });
335
+ }
336
+
337
+ export function endOfWeek(value: Date) {
338
+ return dateFnsEndOfWeek(value, {
339
+ locale
340
+ });
341
+ }
342
+
343
+ export function getYear(value: Date) {
344
+ return dateFnsGetYear(value);
345
+ }
346
+
347
+ export function setYear(value: Date, count: number) {
348
+ return dateFnsSetYear(value, count);
349
+ }
350
+
351
+ export function toJsDate(value: Date) {
352
+ return value;
353
+ }
354
+
355
+ export function parse(value: string, formatString: string) {
356
+ if (value === "") {
357
+ return null;
358
+ }
359
+ return dateFnsParse(value, formatString, new Date(), {
360
+ locale
361
+ });
362
+ }
363
+
364
+ export function format(date: Date, formatKey: keyof DateFormats) {
365
+ return formatByString(date, formats[formatKey]);
366
+ }
367
+
368
+ export function formatByString(date: Date, formatString: string) {
369
+ return dateFnsFormat(date, formatString, {
370
+ locale
371
+ });
372
+ }
373
+
374
+ export function isEqual(date: any, comparing: any) {
375
+ if (date === null && comparing === null) {
376
+ return true;
377
+ }
378
+ return dateFnsIsEqual(date, comparing);
379
+ }
380
+
381
+ export function isNull(date: Date) {
382
+ return date === null;
383
+ }
384
+
385
+ export function isAfterDay(date: Date, value: Date) {
386
+ return isAfter(date, endOfDay(value));
387
+ }
388
+
389
+ export function isBeforeDay(date: Date, value: Date) {
390
+ return isBefore(date, startOfDay(value));
391
+ }
392
+
393
+ export function isBeforeYear(date: Date, value: Date) {
394
+ return isBefore(date, startOfYear(value));
395
+ }
396
+
397
+ export function isBeforeMonth(value: Date, comparing: Date): boolean {
398
+ return isBefore(value, startOfMonth(comparing));
399
+ }
400
+
401
+ export function isAfterMonth(value: Date, comparing: Date): boolean {
402
+ return isAfter(value, startOfMonth(comparing));
403
+ }
404
+
405
+ export function isAfterYear(date: Date, value: Date) {
406
+ return isAfter(date, endOfYear(value));
407
+ }
408
+
409
+ export function isWithinRange(date: Date, [start, end]: [Date, Date]) {
410
+ return isWithinInterval(date, {
411
+ start,
412
+ end
413
+ });
414
+ }
415
+
416
+ export function formatNumber(numberToFormat: string) {
417
+ return numberToFormat;
418
+ }
419
+
420
+ export function getMinutes(date: Date) {
421
+ return dateFnsGetMinutes(date);
422
+ }
423
+
424
+ export function getDate(date: Date) {
425
+ return dateFnsGetDate(date);
426
+ }
427
+
428
+ export function setDate(date: Date, count: number) {
429
+ return dateFnsSetDate(date, count);
430
+ }
431
+
432
+ export function getWeek(date: Date) {
433
+ return dateFnsGetWeek(date);
434
+ }
435
+
436
+ export function getMonth(date: Date) {
437
+ return dateFnsGetMonth(date);
438
+ }
439
+
440
+ export function getDaysInMonth(date: Date) {
441
+ return dateFnsGetDaysInMonth(date);
442
+ }
443
+
444
+ export function setMonth(date: Date, count: number) {
445
+ return dateFnsSetMonth(date, count);
446
+ }
447
+
448
+ export function getMeridiemText(meridiem: "am" | "pm") {
449
+ return meridiem === "am" ? "AM" : "PM";
450
+ }
451
+
452
+ export function getNextMonth(date: Date) {
453
+ return addMonths(date, 1);
454
+ }
455
+
456
+ export function getPreviousMonth(date: Date) {
457
+ return addMonths(date, -1);
458
+ }
459
+
460
+ export function getMonthArray(date: Date) {
461
+ const firstMonth = startOfYear(date);
462
+ const monthArray = [firstMonth];
463
+
464
+ while (monthArray.length < 12) {
465
+ const prevMonth = monthArray[monthArray.length - 1]!;
466
+ monthArray.push(getNextMonth(prevMonth));
467
+ }
468
+
469
+ return monthArray;
470
+ }
471
+
472
+ export function mergeDateAndTime(date: Date, time: Date) {
473
+ return setSeconds(
474
+ setMinutes(setHours(date, getHours(time)), getMinutes(time)),
475
+ getSeconds(time)
476
+ );
477
+ }
478
+
479
+ export function getWeekdays() {
480
+ const now = new Date();
481
+
482
+ return eachDayOfInterval({
483
+ start: startOfWeek(now),
484
+ end: endOfWeek(now)
485
+ }).map(day => formatByString(day, "EEEEEE"));
486
+ }
487
+
488
+ export function getWeekArray(date: Date) {
489
+ const start = startOfWeek(startOfMonth(date));
490
+ const end = endOfWeek(endOfMonth(date));
491
+ let count = 0;
492
+ let current = start;
493
+ const nestedWeeks: Date[][] = [];
494
+ let lastDay = null as null | number;
495
+ while (isBefore(current, end)) {
496
+ const weekNumber = Math.floor(count / 7);
497
+ nestedWeeks[weekNumber] ??= [];
498
+ const day = dateFnsGetDay(current);
499
+ if (lastDay !== day) {
500
+ lastDay = day;
501
+ nestedWeeks[weekNumber].push(current);
502
+ count += 1;
503
+ }
504
+ current = addDays(current, 1);
505
+ }
506
+ return nestedWeeks;
507
+ }
508
+
509
+ export function getYearRange(start: Date, end: Date) {
510
+ const startDate = startOfYear(start);
511
+ const endDate = endOfYear(end);
512
+ const years: Date[] = [];
513
+
514
+ let current = startDate;
515
+ while (isBefore(current, endDate)) {
516
+ years.push(current);
517
+ current = addYears(current, 1);
518
+ }
519
+ return years;
520
+ }
521
+
522
+
523
+ `;
524
+ }
525
+
526
+ //#endregion
527
+ exports.dateFnsModule = dateFnsModule;
@@ -0,0 +1,13 @@
1
+ import { DatePluginContext } from "../types/plugin.cjs";
2
+
3
+ //#region src/components/date-fns.d.ts
4
+
5
+ /**
6
+ * Generates the Powerlines configuration file.
7
+ *
8
+ * @param context - The build context containing runtime information.
9
+ * @returns A string representing the configuration file content.
10
+ */
11
+ declare function dateFnsModule(context: DatePluginContext): string;
12
+ //#endregion
13
+ export { dateFnsModule };
@@ -0,0 +1,13 @@
1
+ import { DatePluginContext } from "../types/plugin.mjs";
2
+
3
+ //#region src/components/date-fns.d.ts
4
+
5
+ /**
6
+ * Generates the Powerlines configuration file.
7
+ *
8
+ * @param context - The build context containing runtime information.
9
+ * @returns A string representing the configuration file content.
10
+ */
11
+ declare function dateFnsModule(context: DatePluginContext): string;
12
+ //#endregion
13
+ export { dateFnsModule };