@h3ravel/support 1.29.0-alpha.16 → 2.0.0-alpha.16
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.
- package/dist/facades.d.ts +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +5 -3
- package/package.json +7 -18
- package/dist/RuntimeException-vs-j61-c.cjs +0 -17
- package/dist/Time-CjHXeIZv.cjs +0 -303
- package/dist/facades.cjs +0 -144
- package/dist/index.cjs +0 -6754
- package/dist/traits.cjs +0 -55
package/dist/facades.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ declare abstract class Facades {
|
|
|
9
9
|
/**
|
|
10
10
|
* The resolved object instances.
|
|
11
11
|
*/
|
|
12
|
-
protected static resolvedInstance: Map<string | (new (...args: any[]) => unknown), any>;
|
|
12
|
+
protected static resolvedInstance: Map<string | symbol | (new (...args: any[]) => unknown), any>;
|
|
13
13
|
/**
|
|
14
14
|
* Indicates if the resolved instance should be cached.
|
|
15
15
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
2
|
import { n as format, t as DateTime } from "./Time-D96uToox.js";
|
|
3
|
-
import { CallableConstructor, ClassConstructor, ConcreteConstructor, IApplication, IServiceProvider } from "@h3ravel/contracts";
|
|
4
3
|
import { Collection as Collection$1 } from "@h3ravel/collect.js";
|
|
5
4
|
import { DotFlatten, DotNestedKeys, DotNestedValue } from "@h3ravel/shared";
|
|
5
|
+
import { CallableConstructor, ClassConstructor, ConcreteConstructor, IApplication, IServiceProvider } from "@h3ravel/contracts";
|
|
6
6
|
|
|
7
|
-
//#region \0rolldown/runtime.js
|
|
8
|
-
//#endregion
|
|
9
7
|
//#region src/Collection.d.ts
|
|
10
8
|
declare class Collection<Item = any> extends Collection$1<Item> {
|
|
11
9
|
/**
|
package/dist/index.js
CHANGED
|
@@ -6653,9 +6653,11 @@ var RouteServiceProvider = class RouteServiceProvider extends ServiceProvider {
|
|
|
6653
6653
|
* Load the application routes.
|
|
6654
6654
|
*/
|
|
6655
6655
|
async loadRoutes() {
|
|
6656
|
-
if (RouteServiceProvider.alwaysLoadRoutesUsing != null) this.app.call(RouteServiceProvider.alwaysLoadRoutesUsing);
|
|
6657
|
-
if (this.loadRoutesUsing != null) this.app.call(this.loadRoutesUsing);
|
|
6658
|
-
else if (typeof this["map"] === "function") this.app.call(this["map"]);
|
|
6656
|
+
if (RouteServiceProvider.alwaysLoadRoutesUsing != null) await this.app.call(RouteServiceProvider.alwaysLoadRoutesUsing);
|
|
6657
|
+
if (this.loadRoutesUsing != null) await this.app.call(this.loadRoutesUsing);
|
|
6658
|
+
else if (typeof this["map"] === "function") await this.app.call(this["map"]);
|
|
6659
|
+
const router = this.app.make(IRouter);
|
|
6660
|
+
if (typeof router.routesLoaded === "function") await router.routesLoaded();
|
|
6659
6661
|
}
|
|
6660
6662
|
};
|
|
6661
6663
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h3ravel/support",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.16",
|
|
4
4
|
"description": "Shared helpers, facades and utilities for H3ravel.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.cjs",
|
|
7
6
|
"types": "./dist/index.d.ts",
|
|
8
|
-
"module": "./dist/index.js",
|
|
9
7
|
"exports": {
|
|
10
|
-
".":
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
"./facades": {
|
|
15
|
-
"import": "./dist/facades.js",
|
|
16
|
-
"require": "./dist/facades.cjs"
|
|
17
|
-
},
|
|
18
|
-
"./traits": {
|
|
19
|
-
"import": "./dist/traits.js",
|
|
20
|
-
"require": "./dist/traits.cjs"
|
|
21
|
-
},
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./facades": "./dist/facades.js",
|
|
10
|
+
"./traits": "./dist/traits.js",
|
|
22
11
|
"./package.json": "./package.json"
|
|
23
12
|
},
|
|
24
13
|
"files": [
|
|
@@ -44,19 +33,19 @@
|
|
|
44
33
|
"laravel"
|
|
45
34
|
],
|
|
46
35
|
"devDependencies": {
|
|
47
|
-
"@h3ravel/shared": "^
|
|
36
|
+
"@h3ravel/shared": "^2.0.0-alpha.16",
|
|
48
37
|
"@types/luxon": "^3.7.1",
|
|
49
38
|
"typescript": "^6.0.0"
|
|
50
39
|
},
|
|
51
40
|
"dependencies": {
|
|
52
41
|
"@h3ravel/collect.js": "^5.3.7",
|
|
53
|
-
"@h3ravel/contracts": "^
|
|
42
|
+
"@h3ravel/contracts": "^2.0.0-alpha.16",
|
|
54
43
|
"dayjs": "^1.11.18",
|
|
55
44
|
"luxon": "^3.7.2"
|
|
56
45
|
},
|
|
57
46
|
"scripts": {
|
|
58
47
|
"build": "tsdown --config-loader unrun",
|
|
59
|
-
"dev": "
|
|
48
|
+
"dev": "tsdown --watch --config-loader unrun",
|
|
60
49
|
"start": "node dist/index.js",
|
|
61
50
|
"lint": "eslint . --ext .ts",
|
|
62
51
|
"test": "jest --passWithNoTests",
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
//#region src/Exceptions/RuntimeException.ts
|
|
2
|
-
/**
|
|
3
|
-
* Exception thrown if an error which can only be found on runtime occurs.
|
|
4
|
-
*/
|
|
5
|
-
var RuntimeException = class extends Error {
|
|
6
|
-
constructor(message = "") {
|
|
7
|
-
super(message);
|
|
8
|
-
this.name = "RuntimeException";
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
//#endregion
|
|
12
|
-
Object.defineProperty(exports, "RuntimeException", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function() {
|
|
15
|
-
return RuntimeException;
|
|
16
|
-
}
|
|
17
|
-
});
|
package/dist/Time-CjHXeIZv.cjs
DELETED
|
@@ -1,303 +0,0 @@
|
|
|
1
|
-
//#region \0rolldown/runtime.js
|
|
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 __exportAll = (all, no_symbols) => {
|
|
9
|
-
let target = {};
|
|
10
|
-
for (var name in all) __defProp(target, name, {
|
|
11
|
-
get: all[name],
|
|
12
|
-
enumerable: true
|
|
13
|
-
});
|
|
14
|
-
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
15
|
-
return target;
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
19
|
-
key = keys[i];
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
21
|
-
get: ((k) => from[k]).bind(null, key),
|
|
22
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
28
|
-
value: mod,
|
|
29
|
-
enumerable: true
|
|
30
|
-
}) : target, mod));
|
|
31
|
-
//#endregion
|
|
32
|
-
let dayjs = require("dayjs");
|
|
33
|
-
dayjs = __toESM(dayjs, 1);
|
|
34
|
-
let dayjs_plugin_advancedFormat_js = require("dayjs/plugin/advancedFormat.js");
|
|
35
|
-
dayjs_plugin_advancedFormat_js = __toESM(dayjs_plugin_advancedFormat_js, 1);
|
|
36
|
-
let dayjs_plugin_customParseFormat_js = require("dayjs/plugin/customParseFormat.js");
|
|
37
|
-
dayjs_plugin_customParseFormat_js = __toESM(dayjs_plugin_customParseFormat_js, 1);
|
|
38
|
-
let dayjs_plugin_dayOfYear_js = require("dayjs/plugin/dayOfYear.js");
|
|
39
|
-
dayjs_plugin_dayOfYear_js = __toESM(dayjs_plugin_dayOfYear_js, 1);
|
|
40
|
-
let dayjs_plugin_isBetween_js = require("dayjs/plugin/isBetween.js");
|
|
41
|
-
dayjs_plugin_isBetween_js = __toESM(dayjs_plugin_isBetween_js, 1);
|
|
42
|
-
let dayjs_plugin_isLeapYear_js = require("dayjs/plugin/isLeapYear.js");
|
|
43
|
-
dayjs_plugin_isLeapYear_js = __toESM(dayjs_plugin_isLeapYear_js, 1);
|
|
44
|
-
let dayjs_plugin_relativeTime_js = require("dayjs/plugin/relativeTime.js");
|
|
45
|
-
dayjs_plugin_relativeTime_js = __toESM(dayjs_plugin_relativeTime_js, 1);
|
|
46
|
-
let dayjs_plugin_timezone_js = require("dayjs/plugin/timezone.js");
|
|
47
|
-
dayjs_plugin_timezone_js = __toESM(dayjs_plugin_timezone_js, 1);
|
|
48
|
-
let dayjs_plugin_utc_js = require("dayjs/plugin/utc.js");
|
|
49
|
-
dayjs_plugin_utc_js = __toESM(dayjs_plugin_utc_js, 1);
|
|
50
|
-
//#region src/Helpers/Time.ts
|
|
51
|
-
dayjs.default.extend(dayjs_plugin_utc_js.default);
|
|
52
|
-
dayjs.default.extend(dayjs_plugin_timezone_js.default);
|
|
53
|
-
dayjs.default.extend(dayjs_plugin_dayOfYear_js.default);
|
|
54
|
-
dayjs.default.extend(dayjs_plugin_isBetween_js.default);
|
|
55
|
-
dayjs.default.extend(dayjs_plugin_isLeapYear_js.default);
|
|
56
|
-
dayjs.default.extend(dayjs_plugin_relativeTime_js.default);
|
|
57
|
-
dayjs.default.extend(dayjs_plugin_advancedFormat_js.default);
|
|
58
|
-
dayjs.default.extend(dayjs_plugin_customParseFormat_js.default);
|
|
59
|
-
const phpToDayjsTokens = (format) => format.replace(/Y/g, "YYYY").replace(/m/g, "MM").replace(/d/g, "DD").replace(/H/g, "HH").replace(/i/g, "mm").replace(/s/g, "ss");
|
|
60
|
-
function format(date, fmt) {
|
|
61
|
-
return (0, dayjs.default)(date).format(phpToDayjsTokens(fmt));
|
|
62
|
-
}
|
|
63
|
-
const TimeClass = class {};
|
|
64
|
-
var DateTime = class DateTime extends TimeClass {
|
|
65
|
-
instance;
|
|
66
|
-
constructor(config, format, locale, strict) {
|
|
67
|
-
super(config);
|
|
68
|
-
if (config instanceof DateTime) config = config.instance;
|
|
69
|
-
this.instance = (0, dayjs.default)(config, format, locale, strict);
|
|
70
|
-
return new Proxy(this, { get: (target, prop, receiver) => {
|
|
71
|
-
if (prop in target) return Reflect.get(target, prop, receiver);
|
|
72
|
-
const value = Reflect.get(this.instance, prop, receiver);
|
|
73
|
-
if (typeof value === "function") return (...args) => {
|
|
74
|
-
const result = value.apply(this.instance, args);
|
|
75
|
-
return dayjs.default.isDayjs(result) ? new DateTime(result) : result;
|
|
76
|
-
};
|
|
77
|
-
return value;
|
|
78
|
-
} });
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Start time of a specific unit.
|
|
82
|
-
*
|
|
83
|
-
* @returns
|
|
84
|
-
*/
|
|
85
|
-
start(unit = "days") {
|
|
86
|
-
return this.startOf(unit);
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Set the timezone for the instance
|
|
90
|
-
*
|
|
91
|
-
* @param timezone
|
|
92
|
-
* @returns
|
|
93
|
-
*/
|
|
94
|
-
setTimezone(timezone, keepLocalTime) {
|
|
95
|
-
return new DateTime(this.tz(timezone, keepLocalTime));
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Returns a cloned Day.js object with a specified amount of time added.
|
|
99
|
-
* ```
|
|
100
|
-
* dayjs().add(7, 'day')// => Dayjs
|
|
101
|
-
* ```
|
|
102
|
-
* Units are case insensitive, and support plural and short forms.
|
|
103
|
-
*
|
|
104
|
-
* Docs: https://day.js.org/docs/en/manipulate/add
|
|
105
|
-
*
|
|
106
|
-
* @alias dayjs().add()
|
|
107
|
-
*/
|
|
108
|
-
add(value, unit) {
|
|
109
|
-
return new DateTime(this.instance.add(value, unit));
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* End time of a specific unit.
|
|
113
|
-
*
|
|
114
|
-
* @returns
|
|
115
|
-
*/
|
|
116
|
-
end(unit = "days") {
|
|
117
|
-
return this.endOf(unit);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* This indicates the difference between two date-time in the specified unit.
|
|
121
|
-
*
|
|
122
|
-
* To get the difference in milliseconds, use `dayjs#diff`
|
|
123
|
-
* ```
|
|
124
|
-
* const date1 = dayjs('2019-01-25')
|
|
125
|
-
* const date2 = dayjs('2018-06-05')
|
|
126
|
-
* date1.diff(date2) // 20214000000 default milliseconds
|
|
127
|
-
* date1.diff() // milliseconds to current time
|
|
128
|
-
* ```
|
|
129
|
-
*
|
|
130
|
-
* To get the difference in another unit of measurement, pass that measurement as the second argument.
|
|
131
|
-
* ```
|
|
132
|
-
* const date1 = dayjs('2019-01-25')
|
|
133
|
-
* date1.diff('2018-06-05', 'month') // 7
|
|
134
|
-
* ```
|
|
135
|
-
* Units are case insensitive, and support plural and short forms.
|
|
136
|
-
*
|
|
137
|
-
* Docs: https://day.js.org/docs/en/display/difference
|
|
138
|
-
*/
|
|
139
|
-
diff(date, unit, float) {
|
|
140
|
-
if (date instanceof DateTime) date = date.instance;
|
|
141
|
-
return this.instance.diff(date, unit, float);
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Get the first day of the month of the given date
|
|
145
|
-
*
|
|
146
|
-
* @returns
|
|
147
|
-
*/
|
|
148
|
-
firstDayOfMonth() {
|
|
149
|
-
return new DateTime(new Date(Date.UTC(this.year(), this.month(), 1)));
|
|
150
|
-
}
|
|
151
|
-
carbonFormat(template) {
|
|
152
|
-
return template ? this.format(phpToDayjsTokens(template)) : this.format();
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* This returns the Unix timestamp (the number of **seconds** since the Unix Epoch) of the Day.js object.
|
|
156
|
-
* ```
|
|
157
|
-
* dayjs('2019-01-25').unix() // 1548381600
|
|
158
|
-
* ```
|
|
159
|
-
* This value is floored to the nearest second, and does not include a milliseconds component.
|
|
160
|
-
*
|
|
161
|
-
* Docs: https://day.js.org/docs/en/display/unix-timestamp
|
|
162
|
-
*
|
|
163
|
-
* @alias dayjs('2019-01-25').unix()
|
|
164
|
-
*/
|
|
165
|
-
getTimestamp() {
|
|
166
|
-
return this.instance.unix();
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Get the last day of the month of the given date
|
|
170
|
-
*
|
|
171
|
-
* @returns
|
|
172
|
-
*/
|
|
173
|
-
lastDayOfMonth() {
|
|
174
|
-
return new DateTime(new Date(Date.UTC(this.year(), this.month() + 1, 0)));
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Get a random time between the specified hour and minute.
|
|
178
|
-
*
|
|
179
|
-
* @param startHour
|
|
180
|
-
* @param startMinute
|
|
181
|
-
* @param endHour
|
|
182
|
-
* @param endMinute
|
|
183
|
-
* @returns
|
|
184
|
-
*/
|
|
185
|
-
randomTime(startHour = 9, startMinute = 0, endHour = 17, endMinute = 0) {
|
|
186
|
-
const today = /* @__PURE__ */ new Date();
|
|
187
|
-
const startMinutes = startHour * 60 + startMinute;
|
|
188
|
-
const endMinutes = endHour * 60 + endMinute;
|
|
189
|
-
const randomMinutes = Math.floor(Math.random() * (endMinutes - startMinutes)) + startMinutes;
|
|
190
|
-
const hour = Math.floor(randomMinutes / 60);
|
|
191
|
-
const minute = randomMinutes % 60;
|
|
192
|
-
const date = new Date(today);
|
|
193
|
-
date.setHours(hour, minute, 0, 0);
|
|
194
|
-
return new DateTime(date);
|
|
195
|
-
}
|
|
196
|
-
/**
|
|
197
|
-
* Create a date for a given timestamp.
|
|
198
|
-
*
|
|
199
|
-
* @param timestamp - Unix timestamp
|
|
200
|
-
*
|
|
201
|
-
* @return {Date} object
|
|
202
|
-
*/
|
|
203
|
-
static fromTimestamp(timestamp) {
|
|
204
|
-
return new DateTime(timestamp * 1e3);
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Get current time instance.
|
|
208
|
-
*
|
|
209
|
-
* @returns Current time
|
|
210
|
-
*/
|
|
211
|
-
static now() {
|
|
212
|
-
return new DateTime();
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Parse the time
|
|
216
|
-
*
|
|
217
|
-
* @param date
|
|
218
|
-
* @returns
|
|
219
|
-
*/
|
|
220
|
-
static parse(date) {
|
|
221
|
-
return new DateTime(date);
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Get the formatted date according to the string of tokens passed in.
|
|
225
|
-
*
|
|
226
|
-
* To escape characters, wrap them in square brackets (e.g. [MM]).
|
|
227
|
-
*
|
|
228
|
-
* @param time - current time
|
|
229
|
-
* @param template - time format
|
|
230
|
-
*/
|
|
231
|
-
static format(time, template) {
|
|
232
|
-
return new DateTime(time).format(template);
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Get the difference in days from today.
|
|
236
|
-
*
|
|
237
|
-
* @param time
|
|
238
|
-
* @param startHour
|
|
239
|
-
* @param startMinute
|
|
240
|
-
* @param endHour
|
|
241
|
-
* @param endMinute
|
|
242
|
-
* @returns
|
|
243
|
-
*/
|
|
244
|
-
static randomTime(time, startHour, startMinute, endHour, endMinute) {
|
|
245
|
-
return new DateTime(time).randomTime(startHour, startMinute, endHour, endMinute);
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Use a dayjs plugin
|
|
249
|
-
*
|
|
250
|
-
* @param plugin
|
|
251
|
-
* @param option
|
|
252
|
-
* @returns
|
|
253
|
-
*/
|
|
254
|
-
static plugin(plugin, option) {
|
|
255
|
-
dayjs.default.extend(plugin, option);
|
|
256
|
-
return dayjs.default;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Get the first day of the month of the given date
|
|
260
|
-
*
|
|
261
|
-
* @param time
|
|
262
|
-
*
|
|
263
|
-
* @returns
|
|
264
|
-
*/
|
|
265
|
-
static firstDayOfMonth(time) {
|
|
266
|
-
return new DateTime(time).firstDayOfMonth();
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Get the last day of the month of the given date
|
|
270
|
-
*
|
|
271
|
-
* @param time
|
|
272
|
-
*
|
|
273
|
-
* @returns
|
|
274
|
-
*/
|
|
275
|
-
static lastDayOfMonth(time) {
|
|
276
|
-
return new DateTime(time).lastDayOfMonth();
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
//#endregion
|
|
280
|
-
Object.defineProperty(exports, "DateTime", {
|
|
281
|
-
enumerable: true,
|
|
282
|
-
get: function() {
|
|
283
|
-
return DateTime;
|
|
284
|
-
}
|
|
285
|
-
});
|
|
286
|
-
Object.defineProperty(exports, "__exportAll", {
|
|
287
|
-
enumerable: true,
|
|
288
|
-
get: function() {
|
|
289
|
-
return __exportAll;
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
Object.defineProperty(exports, "__toESM", {
|
|
293
|
-
enumerable: true,
|
|
294
|
-
get: function() {
|
|
295
|
-
return __toESM;
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
Object.defineProperty(exports, "format", {
|
|
299
|
-
enumerable: true,
|
|
300
|
-
get: function() {
|
|
301
|
-
return format;
|
|
302
|
-
}
|
|
303
|
-
});
|
package/dist/facades.cjs
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_RuntimeException = require("./RuntimeException-vs-j61-c.cjs");
|
|
3
|
-
let _h3ravel_shared = require("@h3ravel/shared");
|
|
4
|
-
//#region src/Facades/Facades.ts
|
|
5
|
-
var Facades = class {
|
|
6
|
-
/**
|
|
7
|
-
* The application instance being facaded.
|
|
8
|
-
*/
|
|
9
|
-
static app;
|
|
10
|
-
/**
|
|
11
|
-
* The resolved object instances.
|
|
12
|
-
*/
|
|
13
|
-
static resolvedInstance = /* @__PURE__ */ new Map();
|
|
14
|
-
/**
|
|
15
|
-
* Indicates if the resolved instance should be cached.
|
|
16
|
-
*/
|
|
17
|
-
static cached = true;
|
|
18
|
-
/**
|
|
19
|
-
* Called once during bootstrap
|
|
20
|
-
*
|
|
21
|
-
* @param app
|
|
22
|
-
*/
|
|
23
|
-
static setApplication(app) {
|
|
24
|
-
this.app = app;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Get the application instance behind the facade.
|
|
28
|
-
*/
|
|
29
|
-
static getApplication() {
|
|
30
|
-
return this.app;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Get the registered name of the component.
|
|
34
|
-
* Each facade must define its container key
|
|
35
|
-
*
|
|
36
|
-
* @return string
|
|
37
|
-
*
|
|
38
|
-
* @throws {RuntimeException}
|
|
39
|
-
*/
|
|
40
|
-
static getFacadeAccessor() {
|
|
41
|
-
throw new require_RuntimeException.RuntimeException("Facade accessor not implemented.");
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Get the root object behind the facade.
|
|
45
|
-
*/
|
|
46
|
-
static getFacadeRoot() {
|
|
47
|
-
return this.resolveInstance(this.getFacadeAccessor());
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Resolve the facade root instance from the container.
|
|
51
|
-
*
|
|
52
|
-
* @param name
|
|
53
|
-
*/
|
|
54
|
-
static resolveInstance(name) {
|
|
55
|
-
if (this.resolvedInstance.has(name)) return this.resolvedInstance.get(name);
|
|
56
|
-
if (this.app) {
|
|
57
|
-
const instance = this.app.make(name);
|
|
58
|
-
if (this.cached) this.resolvedInstance.set(name, instance);
|
|
59
|
-
return instance;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Clear a resolved facade instance.
|
|
64
|
-
*
|
|
65
|
-
* @param name
|
|
66
|
-
*/
|
|
67
|
-
static clearResolvedInstance(name) {
|
|
68
|
-
this.resolvedInstance.delete(name);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Clear all of the resolved instances.
|
|
72
|
-
*/
|
|
73
|
-
static clearResolvedInstances() {
|
|
74
|
-
this.resolvedInstance.clear();
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Hotswap the underlying instance behind the facade.
|
|
78
|
-
*
|
|
79
|
-
* @param instance
|
|
80
|
-
*/
|
|
81
|
-
static swap(instance) {
|
|
82
|
-
this.resolvedInstance.set(this.getFacadeAccessor(), instance);
|
|
83
|
-
if (this.app) this.app.instance(this.getFacadeAccessor(), instance);
|
|
84
|
-
}
|
|
85
|
-
static __callStatic(method, args) {
|
|
86
|
-
const instance = this.getFacadeRoot();
|
|
87
|
-
if (!instance) throw new Error("Facade root not resolved.");
|
|
88
|
-
if (typeof instance[method] === "function" && !(0, _h3ravel_shared.isInternal)(instance, method)) return Reflect.apply(instance[method], instance, args);
|
|
89
|
-
if (typeof instance.__call === "function") return instance.__call(method, args);
|
|
90
|
-
throw new Error(`Method [${method}] does not exist on [${instance.constructor.name}] facade root.`);
|
|
91
|
-
}
|
|
92
|
-
static createFacade() {
|
|
93
|
-
return new Proxy({}, { get: (_target, prop) => {
|
|
94
|
-
return (...args) => this.__callStatic(prop, args);
|
|
95
|
-
} });
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
//#endregion
|
|
99
|
-
//#region src/Facades/HashFacade.ts
|
|
100
|
-
var HashFacade = class extends Facades {
|
|
101
|
-
static getFacadeAccessor() {
|
|
102
|
-
return "hash";
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const Hash = HashFacade.createFacade();
|
|
106
|
-
//#endregion
|
|
107
|
-
//#region src/Facades/RequestFacade.ts
|
|
108
|
-
var RequestFacade = class extends Facades {
|
|
109
|
-
static getFacadeAccessor() {
|
|
110
|
-
return "http.request";
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
const Request = RequestFacade.createFacade();
|
|
114
|
-
//#endregion
|
|
115
|
-
//#region src/Facades/ResponseFacade.ts
|
|
116
|
-
var ResponseFacade = class extends Facades {
|
|
117
|
-
static getFacadeAccessor() {
|
|
118
|
-
return "http.response";
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
const Response = ResponseFacade.createFacade();
|
|
122
|
-
//#endregion
|
|
123
|
-
//#region src/Facades/RouteFacade.ts
|
|
124
|
-
var RouteFacade = class extends Facades {
|
|
125
|
-
static getFacadeAccessor() {
|
|
126
|
-
return "router";
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
const Route = RouteFacade.createFacade();
|
|
130
|
-
//#endregion
|
|
131
|
-
//#region src/Facades/URLFacade.ts
|
|
132
|
-
var URLFacade = class extends Facades {
|
|
133
|
-
static getFacadeAccessor() {
|
|
134
|
-
return "url";
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const URL = URLFacade.createFacade();
|
|
138
|
-
//#endregion
|
|
139
|
-
exports.Facades = Facades;
|
|
140
|
-
exports.Hash = Hash;
|
|
141
|
-
exports.Request = Request;
|
|
142
|
-
exports.Response = Response;
|
|
143
|
-
exports.Route = Route;
|
|
144
|
-
exports.URL = URL;
|