@h3ravel/support 0.16.0 → 0.17.0-alpha.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.
@@ -0,0 +1,314 @@
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 __export = (all, symbols) => {
9
+ let target = {};
10
+ for (var name in all) {
11
+ __defProp(target, name, {
12
+ get: all[name],
13
+ enumerable: true
14
+ });
15
+ }
16
+ if (symbols) {
17
+ __defProp(target, Symbol.toStringTag, { value: "Module" });
18
+ }
19
+ return target;
20
+ };
21
+ var __copyProps = (to, from, except, desc) => {
22
+ if (from && typeof from === "object" || typeof from === "function") {
23
+ for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
24
+ key = keys[i];
25
+ if (!__hasOwnProp.call(to, key) && key !== except) {
26
+ __defProp(to, key, {
27
+ get: ((k) => from[k]).bind(null, key),
28
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
29
+ });
30
+ }
31
+ }
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
36
+ value: mod,
37
+ enumerable: true
38
+ }) : target, mod));
39
+
40
+ //#endregion
41
+ let dayjs = require("dayjs");
42
+ dayjs = __toESM(dayjs);
43
+ let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
44
+ dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js);
45
+ let dayjs_plugin_customParseFormat_js = require("dayjs/plugin/customParseFormat.js");
46
+ dayjs_plugin_customParseFormat_js = __toESM(dayjs_plugin_customParseFormat_js);
47
+ let dayjs_plugin_dayOfYear_js = require("dayjs/plugin/dayOfYear.js");
48
+ dayjs_plugin_dayOfYear_js = __toESM(dayjs_plugin_dayOfYear_js);
49
+ let dayjs_plugin_isBetween_js = require("dayjs/plugin/isBetween.js");
50
+ dayjs_plugin_isBetween_js = __toESM(dayjs_plugin_isBetween_js);
51
+ let dayjs_plugin_isLeapYear_js = require("dayjs/plugin/isLeapYear.js");
52
+ dayjs_plugin_isLeapYear_js = __toESM(dayjs_plugin_isLeapYear_js);
53
+ let dayjs_plugin_relativeTime_js = require("dayjs/plugin/relativeTime.js");
54
+ dayjs_plugin_relativeTime_js = __toESM(dayjs_plugin_relativeTime_js);
55
+ let dayjs_plugin_timezone_js = require("dayjs/plugin/timezone.js");
56
+ dayjs_plugin_timezone_js = __toESM(dayjs_plugin_timezone_js);
57
+ let dayjs_plugin_utc_js = require("dayjs/plugin/utc.js");
58
+ dayjs_plugin_utc_js = __toESM(dayjs_plugin_utc_js);
59
+
60
+ //#region src/Helpers/Time.ts
61
+ dayjs.default.extend(dayjs_plugin_utc_js.default);
62
+ dayjs.default.extend(dayjs_plugin_timezone_js.default);
63
+ dayjs.default.extend(dayjs_plugin_dayOfYear_js.default);
64
+ dayjs.default.extend(dayjs_plugin_isBetween_js.default);
65
+ dayjs.default.extend(dayjs_plugin_isLeapYear_js.default);
66
+ dayjs.default.extend(dayjs_plugin_relativeTime_js.default);
67
+ dayjs.default.extend(dayjs_plugin_advancedFormat_js.default);
68
+ dayjs.default.extend(dayjs_plugin_customParseFormat_js.default);
69
+ const phpToDayjsTokens = (format$1) => format$1.replace(/Y/g, "YYYY").replace(/m/g, "MM").replace(/d/g, "DD").replace(/H/g, "HH").replace(/i/g, "mm").replace(/s/g, "ss");
70
+ function format(date, fmt) {
71
+ return (0, dayjs.default)(date).format(phpToDayjsTokens(fmt));
72
+ }
73
+ const TimeClass = class {};
74
+ var DateTime = class DateTime extends TimeClass {
75
+ instance;
76
+ constructor(config, format$1, locale, strict) {
77
+ super(config);
78
+ if (config instanceof DateTime) config = config.instance;
79
+ this.instance = (0, dayjs.default)(config, format$1, locale, strict);
80
+ return new Proxy(this, { get: (target, prop, receiver) => {
81
+ if (prop in target) return Reflect.get(target, prop, receiver);
82
+ const value = Reflect.get(this.instance, prop, receiver);
83
+ if (typeof value === "function") return (...args) => {
84
+ const result = value.apply(this.instance, args);
85
+ return dayjs.default.isDayjs(result) ? new DateTime(result) : result;
86
+ };
87
+ return value;
88
+ } });
89
+ }
90
+ /**
91
+ * Start time of a specific unit.
92
+ *
93
+ * @returns
94
+ */
95
+ start(unit = "days") {
96
+ return this.startOf(unit);
97
+ }
98
+ /**
99
+ * Set the timezone for the instance
100
+ *
101
+ * @param timezone
102
+ * @returns
103
+ */
104
+ setTimezone(timezone$1, keepLocalTime) {
105
+ return new DateTime(this.tz(timezone$1, keepLocalTime));
106
+ }
107
+ /**
108
+ * Returns a cloned Day.js object with a specified amount of time added.
109
+ * ```
110
+ * dayjs().add(7, 'day')// => Dayjs
111
+ * ```
112
+ * Units are case insensitive, and support plural and short forms.
113
+ *
114
+ * Docs: https://day.js.org/docs/en/manipulate/add
115
+ *
116
+ * @alias dayjs().add()
117
+ */
118
+ add(value, unit) {
119
+ return new DateTime(this.instance.add(value, unit));
120
+ }
121
+ /**
122
+ * End time of a specific unit.
123
+ *
124
+ * @returns
125
+ */
126
+ end(unit = "days") {
127
+ return this.endOf(unit);
128
+ }
129
+ /**
130
+ * This indicates the difference between two date-time in the specified unit.
131
+ *
132
+ * To get the difference in milliseconds, use `dayjs#diff`
133
+ * ```
134
+ * const date1 = dayjs('2019-01-25')
135
+ * const date2 = dayjs('2018-06-05')
136
+ * date1.diff(date2) // 20214000000 default milliseconds
137
+ * date1.diff() // milliseconds to current time
138
+ * ```
139
+ *
140
+ * To get the difference in another unit of measurement, pass that measurement as the second argument.
141
+ * ```
142
+ * const date1 = dayjs('2019-01-25')
143
+ * date1.diff('2018-06-05', 'month') // 7
144
+ * ```
145
+ * Units are case insensitive, and support plural and short forms.
146
+ *
147
+ * Docs: https://day.js.org/docs/en/display/difference
148
+ */
149
+ diff(date, unit, float) {
150
+ if (date instanceof DateTime) date = date.instance;
151
+ return this.instance.diff(date, unit, float);
152
+ }
153
+ /**
154
+ * Get the first day of the month of the given date
155
+ *
156
+ * @returns
157
+ */
158
+ firstDayOfMonth() {
159
+ return new DateTime(new Date(Date.UTC(this.year(), this.month(), 1)));
160
+ }
161
+ carbonFormat(template) {
162
+ return template ? this.format(phpToDayjsTokens(template)) : this.format();
163
+ }
164
+ /**
165
+ * This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object.
166
+ * ```
167
+ * dayjs('2019-01-25').unix() // 1548381600
168
+ * ```
169
+ * This value is floored to the nearest second, and does not include a milliseconds component.
170
+ *
171
+ * Docs: https://day.js.org/docs/en/display/unix-timestamp
172
+ *
173
+ * @alias dayjs('2019-01-25').unix()
174
+ */
175
+ getTimestamp() {
176
+ return this.instance.unix();
177
+ }
178
+ /**
179
+ * Get the last day of the month of the given date
180
+ *
181
+ * @returns
182
+ */
183
+ lastDayOfMonth() {
184
+ return new DateTime(new Date(Date.UTC(this.year(), this.month() + 1, 0)));
185
+ }
186
+ /**
187
+ * Get a random time between the specified hour and minute.
188
+ *
189
+ * @param startHour
190
+ * @param startMinute
191
+ * @param endHour
192
+ * @param endMinute
193
+ * @returns
194
+ */
195
+ randomTime(startHour = 9, startMinute = 0, endHour = 17, endMinute = 0) {
196
+ const today = /* @__PURE__ */ new Date();
197
+ const startMinutes = startHour * 60 + startMinute;
198
+ const endMinutes = endHour * 60 + endMinute;
199
+ const randomMinutes = Math.floor(Math.random() * (endMinutes - startMinutes)) + startMinutes;
200
+ const hour = Math.floor(randomMinutes / 60);
201
+ const minute = randomMinutes % 60;
202
+ const date = new Date(today);
203
+ date.setHours(hour, minute, 0, 0);
204
+ return new DateTime(date);
205
+ }
206
+ /**
207
+ * Create a date for a given timestamp.
208
+ *
209
+ * @param timestamp - Unix timestamp
210
+ *
211
+ * @return {Date} object
212
+ */
213
+ static fromTimestamp(timestamp) {
214
+ return new DateTime(timestamp * 1e3);
215
+ }
216
+ /**
217
+ * Get current time instance.
218
+ *
219
+ * @returns Current time
220
+ */
221
+ static now() {
222
+ return new DateTime();
223
+ }
224
+ /**
225
+ * Parse the time
226
+ *
227
+ * @param date
228
+ * @returns
229
+ */
230
+ static parse(date) {
231
+ return new DateTime(date);
232
+ }
233
+ /**
234
+ * Get the formatted date according to the string of tokens passed in.
235
+ *
236
+ * To escape characters, wrap them in square brackets (e.g. [MM]).
237
+ *
238
+ * @param time - current time
239
+ * @param template - time format
240
+ */
241
+ static format(time, template) {
242
+ return new DateTime(time).format(template);
243
+ }
244
+ /**
245
+ * Get the difference in days from today.
246
+ *
247
+ * @param time
248
+ * @param startHour
249
+ * @param startMinute
250
+ * @param endHour
251
+ * @param endMinute
252
+ * @returns
253
+ */
254
+ static randomTime(time, startHour, startMinute, endHour, endMinute) {
255
+ return new DateTime(time).randomTime(startHour, startMinute, endHour, endMinute);
256
+ }
257
+ /**
258
+ * Use a dayjs plugin
259
+ *
260
+ * @param plugin
261
+ * @param option
262
+ * @returns
263
+ */
264
+ static plugin(plugin, option) {
265
+ dayjs.default.extend(plugin, option);
266
+ return dayjs.default;
267
+ }
268
+ /**
269
+ * Get the first day of the month of the given date
270
+ *
271
+ * @param time
272
+ *
273
+ * @returns
274
+ */
275
+ static firstDayOfMonth(time) {
276
+ return new DateTime(time).firstDayOfMonth();
277
+ }
278
+ /**
279
+ * Get the last day of the month of the given date
280
+ *
281
+ * @param time
282
+ *
283
+ * @returns
284
+ */
285
+ static lastDayOfMonth(time) {
286
+ return new DateTime(time).lastDayOfMonth();
287
+ }
288
+ };
289
+
290
+ //#endregion
291
+ Object.defineProperty(exports, 'DateTime', {
292
+ enumerable: true,
293
+ get: function () {
294
+ return DateTime;
295
+ }
296
+ });
297
+ Object.defineProperty(exports, '__export', {
298
+ enumerable: true,
299
+ get: function () {
300
+ return __export;
301
+ }
302
+ });
303
+ Object.defineProperty(exports, '__toESM', {
304
+ enumerable: true,
305
+ get: function () {
306
+ return __toESM;
307
+ }
308
+ });
309
+ Object.defineProperty(exports, 'format', {
310
+ enumerable: true,
311
+ get: function () {
312
+ return format;
313
+ }
314
+ });
package/dist/facades.cjs CHANGED
@@ -1,6 +1,6 @@
1
- const require_RuntimeException = require('./RuntimeException-CmsL83ow.cjs');
2
- const require_index = require('./index.cjs');
3
- let __h3ravel_foundation = require("@h3ravel/foundation");
1
+ const require_Time = require('./Time-H1gLMvCJ.cjs');
2
+ const require_RuntimeException = require('./RuntimeException-BlF2onMq.cjs');
3
+ let __h3ravel_shared = require("@h3ravel/shared");
4
4
 
5
5
  //#region src/Facades/Facades.ts
6
6
  var Facades = class {
@@ -86,7 +86,7 @@ var Facades = class {
86
86
  static __callStatic(method, args) {
87
87
  const instance = this.getFacadeRoot();
88
88
  if (!instance) throw new Error("Facade root not resolved.");
89
- if (typeof instance[method] === "function" && !(0, __h3ravel_foundation.isInternal)(instance, method)) return Reflect.apply(instance[method], instance, args);
89
+ if (typeof instance[method] === "function" && !(0, __h3ravel_shared.isInternal)(instance, method)) return Reflect.apply(instance[method], instance, args);
90
90
  if (typeof instance.__call === "function") return instance.__call(method, args);
91
91
  throw new Error(`Method [${method}] does not exist on [${instance.constructor.name}] facade root.`);
92
92
  }
@@ -97,6 +97,33 @@ var Facades = class {
97
97
  }
98
98
  };
99
99
 
100
+ //#endregion
101
+ //#region src/Facades/HashFacade.ts
102
+ var HashFacade = class extends Facades {
103
+ static getFacadeAccessor() {
104
+ return "hash";
105
+ }
106
+ };
107
+ const Hash = HashFacade.createFacade();
108
+
109
+ //#endregion
110
+ //#region src/Facades/RequestFacade.ts
111
+ var RequestFacade = class extends Facades {
112
+ static getFacadeAccessor() {
113
+ return "http.request";
114
+ }
115
+ };
116
+ const Request = RequestFacade.createFacade();
117
+
118
+ //#endregion
119
+ //#region src/Facades/ResponseFacade.ts
120
+ var ResponseFacade = class extends Facades {
121
+ static getFacadeAccessor() {
122
+ return "http.response";
123
+ }
124
+ };
125
+ const Response = ResponseFacade.createFacade();
126
+
100
127
  //#endregion
101
128
  //#region src/Facades/RouteFacade.ts
102
129
  var RouteFacade = class extends Facades {
@@ -106,6 +133,19 @@ var RouteFacade = class extends Facades {
106
133
  };
107
134
  const Route = RouteFacade.createFacade();
108
135
 
136
+ //#endregion
137
+ //#region src/Facades/URLFacade.ts
138
+ var URLFacade = class extends Facades {
139
+ static getFacadeAccessor() {
140
+ return "url";
141
+ }
142
+ };
143
+ const URL = URLFacade.createFacade();
144
+
109
145
  //#endregion
110
146
  exports.Facades = Facades;
111
- exports.Route = Route;
147
+ exports.Hash = Hash;
148
+ exports.Request = Request;
149
+ exports.Response = Response;
150
+ exports.Route = Route;
151
+ exports.URL = URL;
package/dist/facades.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ClassConstructor, ConcreteConstructor, IApplication, IBinding, IRouteRegistrar, IRouter } from "@h3ravel/contracts";
1
+ import { ClassConstructor, ConcreteConstructor, IApplication, IBinding, IHashManager, IRequest, IResponse, IRouteRegistrar, IRouter, IUrlGenerator } from "@h3ravel/contracts";
2
2
 
3
3
  //#region src/Facades/Facades.d.ts
4
4
  declare abstract class Facades {
@@ -63,8 +63,20 @@ declare abstract class Facades {
63
63
  static createFacade<T extends object>(): T;
64
64
  }
65
65
  //#endregion
66
+ //#region src/Facades/HashFacade.d.ts
67
+ declare const Hash: IHashManager;
68
+ //#endregion
69
+ //#region src/Facades/RequestFacade.d.ts
70
+ declare const Request: IRequest<Record<string, any>, Record<string, any>, Record<string, any>>;
71
+ //#endregion
72
+ //#region src/Facades/ResponseFacade.d.ts
73
+ declare const Response: IResponse;
74
+ //#endregion
66
75
  //#region src/Facades/RouteFacade.d.ts
67
76
  type FRoute = Omit<IRouter, 'group' | 'apiSingleton' | 'match' | 'resource' | 'apiResource' | 'singleton' | 'middleware'>;
68
77
  declare const Route: IRouteRegistrar & FRoute;
69
78
  //#endregion
70
- export { FRoute, Facades, Route };
79
+ //#region src/Facades/URLFacade.d.ts
80
+ declare const URL: IUrlGenerator;
81
+ //#endregion
82
+ export { FRoute, Facades, Hash, Request, Response, Route, URL };
package/dist/facades.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as RuntimeException } from "./RuntimeException-CrNX0B-p.js";
2
- import { isInternal } from "@h3ravel/foundation";
1
+ import { t as RuntimeException } from "./RuntimeException-Bt4SxSOi.js";
2
+ import { isInternal } from "@h3ravel/shared";
3
3
 
4
4
  //#region src/Facades/Facades.ts
5
5
  var Facades = class {
@@ -96,6 +96,33 @@ var Facades = class {
96
96
  }
97
97
  };
98
98
 
99
+ //#endregion
100
+ //#region src/Facades/HashFacade.ts
101
+ var HashFacade = class extends Facades {
102
+ static getFacadeAccessor() {
103
+ return "hash";
104
+ }
105
+ };
106
+ const Hash = HashFacade.createFacade();
107
+
108
+ //#endregion
109
+ //#region src/Facades/RequestFacade.ts
110
+ var RequestFacade = class extends Facades {
111
+ static getFacadeAccessor() {
112
+ return "http.request";
113
+ }
114
+ };
115
+ const Request = RequestFacade.createFacade();
116
+
117
+ //#endregion
118
+ //#region src/Facades/ResponseFacade.ts
119
+ var ResponseFacade = class extends Facades {
120
+ static getFacadeAccessor() {
121
+ return "http.response";
122
+ }
123
+ };
124
+ const Response = ResponseFacade.createFacade();
125
+
99
126
  //#endregion
100
127
  //#region src/Facades/RouteFacade.ts
101
128
  var RouteFacade = class extends Facades {
@@ -106,4 +133,13 @@ var RouteFacade = class extends Facades {
106
133
  const Route = RouteFacade.createFacade();
107
134
 
108
135
  //#endregion
109
- export { Facades, Route };
136
+ //#region src/Facades/URLFacade.ts
137
+ var URLFacade = class extends Facades {
138
+ static getFacadeAccessor() {
139
+ return "url";
140
+ }
141
+ };
142
+ const URL = URLFacade.createFacade();
143
+
144
+ //#endregion
145
+ export { Facades, Hash, Request, Response, Route, URL };