@wabot-dev/framework 0.4.0-beta.2 → 0.4.0-beta.4

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 (45) hide show
  1. package/dist/src/_virtual/CronDate.js +3 -0
  2. package/dist/src/_virtual/CronDayOfMonth.js +3 -0
  3. package/dist/src/_virtual/CronDayOfWeek.js +3 -0
  4. package/dist/src/_virtual/CronExpression.js +3 -0
  5. package/dist/src/_virtual/CronExpressionParser.js +3 -0
  6. package/dist/src/_virtual/CronField.js +3 -0
  7. package/dist/src/_virtual/CronFieldCollection.js +3 -0
  8. package/dist/src/_virtual/CronFileParser.js +3 -0
  9. package/dist/src/_virtual/CronHour.js +3 -0
  10. package/dist/src/_virtual/CronMinute.js +3 -0
  11. package/dist/src/_virtual/CronMonth.js +3 -0
  12. package/dist/src/_virtual/CronSecond.js +3 -0
  13. package/dist/src/_virtual/index.js +5 -0
  14. package/dist/src/_virtual/index2.js +3 -0
  15. package/dist/src/_virtual/index3.js +3 -0
  16. package/dist/src/_virtual/luxon.js +3 -0
  17. package/dist/src/_virtual/random.js +3 -0
  18. package/dist/src/_virtual/types.js +3 -0
  19. package/dist/src/addon/async/pg/PgCronJobRepository.js +49 -0
  20. package/dist/src/addon/async/pg/PgJobRepository.js +2 -0
  21. package/dist/src/feature/async/@cron.js +17 -0
  22. package/dist/src/feature/async/CronJob.js +67 -0
  23. package/dist/src/feature/async/CronJobRepository.js +19 -0
  24. package/dist/src/feature/async/CronScheduler.js +165 -0
  25. package/dist/src/feature/async/runCronHandlers.js +18 -0
  26. package/dist/src/index.d.ts +62 -1
  27. package/dist/src/index.js +5 -0
  28. package/dist/src/node_modules/cron-parser/dist/CronDate.js +510 -0
  29. package/dist/src/node_modules/cron-parser/dist/CronExpression.js +420 -0
  30. package/dist/src/node_modules/cron-parser/dist/CronExpressionParser.js +396 -0
  31. package/dist/src/node_modules/cron-parser/dist/CronFieldCollection.js +382 -0
  32. package/dist/src/node_modules/cron-parser/dist/CronFileParser.js +122 -0
  33. package/dist/src/node_modules/cron-parser/dist/fields/CronDayOfMonth.js +55 -0
  34. package/dist/src/node_modules/cron-parser/dist/fields/CronDayOfWeek.js +62 -0
  35. package/dist/src/node_modules/cron-parser/dist/fields/CronField.js +193 -0
  36. package/dist/src/node_modules/cron-parser/dist/fields/CronHour.js +51 -0
  37. package/dist/src/node_modules/cron-parser/dist/fields/CronMinute.js +51 -0
  38. package/dist/src/node_modules/cron-parser/dist/fields/CronMonth.js +56 -0
  39. package/dist/src/node_modules/cron-parser/dist/fields/CronSecond.js +51 -0
  40. package/dist/src/node_modules/cron-parser/dist/fields/index.js +44 -0
  41. package/dist/src/node_modules/cron-parser/dist/fields/types.js +12 -0
  42. package/dist/src/node_modules/cron-parser/dist/index.js +49 -0
  43. package/dist/src/node_modules/cron-parser/dist/utils/random.js +48 -0
  44. package/dist/src/node_modules/luxon/build/node/luxon.js +7802 -0
  45. package/package.json +1 -1
@@ -0,0 +1,193 @@
1
+ import { __exports as CronField } from '../../../../_virtual/CronField.js';
2
+
3
+ var hasRequiredCronField;
4
+
5
+ function requireCronField () {
6
+ if (hasRequiredCronField) return CronField;
7
+ hasRequiredCronField = 1;
8
+ Object.defineProperty(CronField, "__esModule", { value: true });
9
+ CronField.CronField = void 0;
10
+ /**
11
+ * Represents a field within a cron expression.
12
+ * This is a base class and should not be instantiated directly.
13
+ * @class CronField
14
+ */
15
+ let CronField$1 = class CronField {
16
+ #hasLastChar = false;
17
+ #hasQuestionMarkChar = false;
18
+ #wildcard = false;
19
+ #values = [];
20
+ options = { rawValue: '' };
21
+ /**
22
+ * Returns the minimum value allowed for this field.
23
+ */
24
+ /* istanbul ignore next */ static get min() {
25
+ /* istanbul ignore next */
26
+ throw new Error('min must be overridden');
27
+ }
28
+ /**
29
+ * Returns the maximum value allowed for this field.
30
+ */
31
+ /* istanbul ignore next */ static get max() {
32
+ /* istanbul ignore next */
33
+ throw new Error('max must be overridden');
34
+ }
35
+ /**
36
+ * Returns the allowed characters for this field.
37
+ */
38
+ /* istanbul ignore next */ static get chars() {
39
+ /* istanbul ignore next - this is overridden */
40
+ return Object.freeze([]);
41
+ }
42
+ /**
43
+ * Returns the regular expression used to validate this field.
44
+ */
45
+ static get validChars() {
46
+ return /^[?,*\dH/-]+$|^.*H\(\d+-\d+\)\/\d+.*$|^.*H\(\d+-\d+\).*$|^.*H\/\d+.*$/;
47
+ }
48
+ /**
49
+ * Returns the constraints for this field.
50
+ */
51
+ static get constraints() {
52
+ return { min: this.min, max: this.max, chars: this.chars, validChars: this.validChars };
53
+ }
54
+ /**
55
+ * CronField constructor. Initializes the field with the provided values.
56
+ * @param {number[] | string[]} values - Values for this field
57
+ * @param {CronFieldOptions} [options] - Options provided by the parser
58
+ * @throws {TypeError} if the constructor is called directly
59
+ * @throws {Error} if validation fails
60
+ */
61
+ constructor(values, options = { rawValue: '' }) {
62
+ if (!Array.isArray(values)) {
63
+ throw new Error(`${this.constructor.name} Validation error, values is not an array`);
64
+ }
65
+ if (!(values.length > 0)) {
66
+ throw new Error(`${this.constructor.name} Validation error, values contains no values`);
67
+ }
68
+ /* istanbul ignore next */
69
+ this.options = {
70
+ ...options,
71
+ rawValue: options.rawValue ?? '',
72
+ };
73
+ this.#values = values.sort(CronField.sorter);
74
+ this.#wildcard = this.options.wildcard !== undefined ? this.options.wildcard : this.#isWildcardValue();
75
+ this.#hasLastChar = this.options.rawValue.includes('L') || values.includes('L');
76
+ this.#hasQuestionMarkChar = this.options.rawValue.includes('?') || values.includes('?');
77
+ }
78
+ /**
79
+ * Returns the minimum value allowed for this field.
80
+ * @returns {number}
81
+ */
82
+ get min() {
83
+ // return the static value from the child class
84
+ return this.constructor.min;
85
+ }
86
+ /**
87
+ * Returns the maximum value allowed for this field.
88
+ * @returns {number}
89
+ */
90
+ get max() {
91
+ // return the static value from the child class
92
+ return this.constructor.max;
93
+ }
94
+ /**
95
+ * Returns an array of allowed special characters for this field.
96
+ * @returns {string[]}
97
+ */
98
+ get chars() {
99
+ // return the frozen static value from the child class
100
+ return this.constructor.chars;
101
+ }
102
+ /**
103
+ * Indicates whether this field has a "last" character.
104
+ * @returns {boolean}
105
+ */
106
+ get hasLastChar() {
107
+ return this.#hasLastChar;
108
+ }
109
+ /**
110
+ * Indicates whether this field has a "question mark" character.
111
+ * @returns {boolean}
112
+ */
113
+ get hasQuestionMarkChar() {
114
+ return this.#hasQuestionMarkChar;
115
+ }
116
+ /**
117
+ * Indicates whether this field is a wildcard.
118
+ * @returns {boolean}
119
+ */
120
+ get isWildcard() {
121
+ return this.#wildcard;
122
+ }
123
+ /**
124
+ * Returns an array of allowed values for this field.
125
+ * @returns {CronFieldType}
126
+ */
127
+ get values() {
128
+ return this.#values;
129
+ }
130
+ /**
131
+ * Helper function to sort values in ascending order.
132
+ * @param {number | string} a - First value to compare
133
+ * @param {number | string} b - Second value to compare
134
+ * @returns {number} - A negative, zero, or positive value, depending on the sort order
135
+ */
136
+ static sorter(a, b) {
137
+ const aIsNumber = typeof a === 'number';
138
+ const bIsNumber = typeof b === 'number';
139
+ if (aIsNumber && bIsNumber)
140
+ return a - b;
141
+ if (!aIsNumber && !bIsNumber)
142
+ return a.localeCompare(b);
143
+ return aIsNumber ? /* istanbul ignore next - A will always be a number until L-2 is supported */ -1 : 1;
144
+ }
145
+ /**
146
+ * Serializes the field to an object.
147
+ * @returns {SerializedCronField}
148
+ */
149
+ serialize() {
150
+ return {
151
+ wildcard: this.#wildcard,
152
+ values: this.#values,
153
+ };
154
+ }
155
+ /**
156
+ * Validates the field values against the allowed range and special characters.
157
+ * @throws {Error} if validation fails
158
+ */
159
+ validate() {
160
+ let badValue;
161
+ const charsString = this.chars.length > 0 ? ` or chars ${this.chars.join('')}` : '';
162
+ const charTest = (value) => (char) => new RegExp(`^\\d{0,2}${char}$`).test(value);
163
+ const rangeTest = (value) => {
164
+ badValue = value;
165
+ return typeof value === 'number' ? value >= this.min && value <= this.max : this.chars.some(charTest(value));
166
+ };
167
+ const isValidRange = this.#values.every(rangeTest);
168
+ if (!isValidRange) {
169
+ throw new Error(`${this.constructor.name} Validation error, got value ${badValue} expected range ${this.min}-${this.max}${charsString}`);
170
+ }
171
+ // check for duplicate value in this.#values array
172
+ const duplicate = this.#values.find((value, index) => this.#values.indexOf(value) !== index);
173
+ if (duplicate) {
174
+ throw new Error(`${this.constructor.name} Validation error, duplicate values found: ${duplicate}`);
175
+ }
176
+ }
177
+ /**
178
+ * Determines if the field is a wildcard based on the values.
179
+ * When options.rawValue is not empty, it checks if the raw value is a wildcard, otherwise it checks if all values in the range are included.
180
+ * @returns {boolean}
181
+ */
182
+ #isWildcardValue() {
183
+ if (this.options.rawValue.length > 0) {
184
+ return ['*', '?'].includes(this.options.rawValue);
185
+ }
186
+ return Array.from({ length: this.max - this.min + 1 }, (_, i) => i + this.min).every((value) => this.#values.includes(value));
187
+ }
188
+ };
189
+ CronField.CronField = CronField$1;
190
+ return CronField;
191
+ }
192
+
193
+ export { requireCronField as __require };
@@ -0,0 +1,51 @@
1
+ import { __exports as CronHour } from '../../../../_virtual/CronHour.js';
2
+ import { __require as requireCronField } from './CronField.js';
3
+
4
+ var hasRequiredCronHour;
5
+
6
+ function requireCronHour () {
7
+ if (hasRequiredCronHour) return CronHour;
8
+ hasRequiredCronHour = 1;
9
+ Object.defineProperty(CronHour, "__esModule", { value: true });
10
+ CronHour.CronHour = void 0;
11
+ const CronField_1 = requireCronField();
12
+ const MIN_HOUR = 0;
13
+ const MAX_HOUR = 23;
14
+ const HOUR_CHARS = Object.freeze([]);
15
+ /**
16
+ * Represents the "hour" field within a cron expression.
17
+ * @class CronHour
18
+ * @extends CronField
19
+ */
20
+ let CronHour$1 = class CronHour extends CronField_1.CronField {
21
+ static get min() {
22
+ return MIN_HOUR;
23
+ }
24
+ static get max() {
25
+ return MAX_HOUR;
26
+ }
27
+ static get chars() {
28
+ return HOUR_CHARS;
29
+ }
30
+ /**
31
+ * CronHour constructor. Initializes the "hour" field with the provided values.
32
+ * @param {HourRange[]} values - Values for the "hour" field
33
+ * @param {CronFieldOptions} [options] - Options provided by the parser
34
+ */
35
+ constructor(values, options) {
36
+ super(values, options);
37
+ this.validate();
38
+ }
39
+ /**
40
+ * Returns an array of allowed values for the "hour" field.
41
+ * @returns {HourRange[]}
42
+ */
43
+ get values() {
44
+ return super.values;
45
+ }
46
+ };
47
+ CronHour.CronHour = CronHour$1;
48
+ return CronHour;
49
+ }
50
+
51
+ export { requireCronHour as __require };
@@ -0,0 +1,51 @@
1
+ import { __exports as CronMinute } from '../../../../_virtual/CronMinute.js';
2
+ import { __require as requireCronField } from './CronField.js';
3
+
4
+ var hasRequiredCronMinute;
5
+
6
+ function requireCronMinute () {
7
+ if (hasRequiredCronMinute) return CronMinute;
8
+ hasRequiredCronMinute = 1;
9
+ Object.defineProperty(CronMinute, "__esModule", { value: true });
10
+ CronMinute.CronMinute = void 0;
11
+ const CronField_1 = requireCronField();
12
+ const MIN_MINUTE = 0;
13
+ const MAX_MINUTE = 59;
14
+ const MINUTE_CHARS = Object.freeze([]);
15
+ /**
16
+ * Represents the "second" field within a cron expression.
17
+ * @class CronSecond
18
+ * @extends CronField
19
+ */
20
+ let CronMinute$1 = class CronMinute extends CronField_1.CronField {
21
+ static get min() {
22
+ return MIN_MINUTE;
23
+ }
24
+ static get max() {
25
+ return MAX_MINUTE;
26
+ }
27
+ static get chars() {
28
+ return MINUTE_CHARS;
29
+ }
30
+ /**
31
+ * CronSecond constructor. Initializes the "second" field with the provided values.
32
+ * @param {SixtyRange[]} values - Values for the "second" field
33
+ * @param {CronFieldOptions} [options] - Options provided by the parser
34
+ */
35
+ constructor(values, options) {
36
+ super(values, options);
37
+ this.validate();
38
+ }
39
+ /**
40
+ * Returns an array of allowed values for the "second" field.
41
+ * @returns {SixtyRange[]}
42
+ */
43
+ get values() {
44
+ return super.values;
45
+ }
46
+ };
47
+ CronMinute.CronMinute = CronMinute$1;
48
+ return CronMinute;
49
+ }
50
+
51
+ export { requireCronMinute as __require };
@@ -0,0 +1,56 @@
1
+ import { __exports as CronMonth } from '../../../../_virtual/CronMonth.js';
2
+ import { __require as requireCronDate } from '../CronDate.js';
3
+ import { __require as requireCronField } from './CronField.js';
4
+
5
+ var hasRequiredCronMonth;
6
+
7
+ function requireCronMonth () {
8
+ if (hasRequiredCronMonth) return CronMonth;
9
+ hasRequiredCronMonth = 1;
10
+ Object.defineProperty(CronMonth, "__esModule", { value: true });
11
+ CronMonth.CronMonth = void 0;
12
+ const CronDate_1 = requireCronDate();
13
+ const CronField_1 = requireCronField();
14
+ const MIN_MONTH = 1;
15
+ const MAX_MONTH = 12;
16
+ const MONTH_CHARS = Object.freeze([]);
17
+ /**
18
+ * Represents the "day of the month" field within a cron expression.
19
+ * @class CronDayOfMonth
20
+ * @extends CronField
21
+ */
22
+ let CronMonth$1 = class CronMonth extends CronField_1.CronField {
23
+ static get min() {
24
+ return MIN_MONTH;
25
+ }
26
+ static get max() {
27
+ return MAX_MONTH;
28
+ }
29
+ static get chars() {
30
+ return MONTH_CHARS;
31
+ }
32
+ static get daysInMonth() {
33
+ return CronDate_1.DAYS_IN_MONTH;
34
+ }
35
+ /**
36
+ * CronDayOfMonth constructor. Initializes the "day of the month" field with the provided values.
37
+ * @param {MonthRange[]} values - Values for the "day of the month" field
38
+ * @param {CronFieldOptions} [options] - Options provided by the parser
39
+ */
40
+ constructor(values, options) {
41
+ super(values, options);
42
+ this.validate();
43
+ }
44
+ /**
45
+ * Returns an array of allowed values for the "day of the month" field.
46
+ * @returns {MonthRange[]}
47
+ */
48
+ get values() {
49
+ return super.values;
50
+ }
51
+ };
52
+ CronMonth.CronMonth = CronMonth$1;
53
+ return CronMonth;
54
+ }
55
+
56
+ export { requireCronMonth as __require };
@@ -0,0 +1,51 @@
1
+ import { __exports as CronSecond } from '../../../../_virtual/CronSecond.js';
2
+ import { __require as requireCronField } from './CronField.js';
3
+
4
+ var hasRequiredCronSecond;
5
+
6
+ function requireCronSecond () {
7
+ if (hasRequiredCronSecond) return CronSecond;
8
+ hasRequiredCronSecond = 1;
9
+ Object.defineProperty(CronSecond, "__esModule", { value: true });
10
+ CronSecond.CronSecond = void 0;
11
+ const CronField_1 = requireCronField();
12
+ const MIN_SECOND = 0;
13
+ const MAX_SECOND = 59;
14
+ const SECOND_CHARS = Object.freeze([]);
15
+ /**
16
+ * Represents the "second" field within a cron expression.
17
+ * @class CronSecond
18
+ * @extends CronField
19
+ */
20
+ let CronSecond$1 = class CronSecond extends CronField_1.CronField {
21
+ static get min() {
22
+ return MIN_SECOND;
23
+ }
24
+ static get max() {
25
+ return MAX_SECOND;
26
+ }
27
+ static get chars() {
28
+ return SECOND_CHARS;
29
+ }
30
+ /**
31
+ * CronSecond constructor. Initializes the "second" field with the provided values.
32
+ * @param {SixtyRange[]} values - Values for the "second" field
33
+ * @param {CronFieldOptions} [options] - Options provided by the parser
34
+ */
35
+ constructor(values, options) {
36
+ super(values, options);
37
+ this.validate();
38
+ }
39
+ /**
40
+ * Returns an array of allowed values for the "second" field.
41
+ * @returns {SixtyRange[]}
42
+ */
43
+ get values() {
44
+ return super.values;
45
+ }
46
+ };
47
+ CronSecond.CronSecond = CronSecond$1;
48
+ return CronSecond;
49
+ }
50
+
51
+ export { requireCronSecond as __require };
@@ -0,0 +1,44 @@
1
+ import { __exports as fields } from '../../../../_virtual/index3.js';
2
+ import { __require as requireTypes } from './types.js';
3
+ import { __require as requireCronDayOfMonth } from './CronDayOfMonth.js';
4
+ import { __require as requireCronDayOfWeek } from './CronDayOfWeek.js';
5
+ import { __require as requireCronField } from './CronField.js';
6
+ import { __require as requireCronHour } from './CronHour.js';
7
+ import { __require as requireCronMinute } from './CronMinute.js';
8
+ import { __require as requireCronMonth } from './CronMonth.js';
9
+ import { __require as requireCronSecond } from './CronSecond.js';
10
+
11
+ var hasRequiredFields;
12
+
13
+ function requireFields () {
14
+ if (hasRequiredFields) return fields;
15
+ hasRequiredFields = 1;
16
+ (function (exports) {
17
+ var __createBinding = (fields && fields.__createBinding) || (Object.create ? (function(o, m, k, k2) {
18
+ if (k2 === undefined) k2 = k;
19
+ var desc = Object.getOwnPropertyDescriptor(m, k);
20
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21
+ desc = { enumerable: true, get: function() { return m[k]; } };
22
+ }
23
+ Object.defineProperty(o, k2, desc);
24
+ }) : (function(o, m, k, k2) {
25
+ if (k2 === undefined) k2 = k;
26
+ o[k2] = m[k];
27
+ }));
28
+ var __exportStar = (fields && fields.__exportStar) || function(m, exports) {
29
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
30
+ };
31
+ Object.defineProperty(exports, "__esModule", { value: true });
32
+ __exportStar(requireTypes(), exports);
33
+ __exportStar(requireCronDayOfMonth(), exports);
34
+ __exportStar(requireCronDayOfWeek(), exports);
35
+ __exportStar(requireCronField(), exports);
36
+ __exportStar(requireCronHour(), exports);
37
+ __exportStar(requireCronMinute(), exports);
38
+ __exportStar(requireCronMonth(), exports);
39
+ __exportStar(requireCronSecond(), exports);
40
+ } (fields));
41
+ return fields;
42
+ }
43
+
44
+ export { requireFields as __require };
@@ -0,0 +1,12 @@
1
+ import { __exports as types } from '../../../../_virtual/types.js';
2
+
3
+ var hasRequiredTypes;
4
+
5
+ function requireTypes () {
6
+ if (hasRequiredTypes) return types;
7
+ hasRequiredTypes = 1;
8
+ Object.defineProperty(types, "__esModule", { value: true });
9
+ return types;
10
+ }
11
+
12
+ export { requireTypes as __require };
@@ -0,0 +1,49 @@
1
+ import { __exports as dist } from '../../../_virtual/index2.js';
2
+ import { __require as requireCronExpressionParser } from './CronExpressionParser.js';
3
+ import { __require as requireCronDate } from './CronDate.js';
4
+ import { __require as requireCronFieldCollection } from './CronFieldCollection.js';
5
+ import { __require as requireCronExpression } from './CronExpression.js';
6
+ import { __require as requireCronFileParser } from './CronFileParser.js';
7
+ import { __require as requireFields } from './fields/index.js';
8
+
9
+ var hasRequiredDist;
10
+
11
+ function requireDist () {
12
+ if (hasRequiredDist) return dist;
13
+ hasRequiredDist = 1;
14
+ (function (exports) {
15
+ var __createBinding = (dist && dist.__createBinding) || (Object.create ? (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ var desc = Object.getOwnPropertyDescriptor(m, k);
18
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
19
+ desc = { enumerable: true, get: function() { return m[k]; } };
20
+ }
21
+ Object.defineProperty(o, k2, desc);
22
+ }) : (function(o, m, k, k2) {
23
+ if (k2 === undefined) k2 = k;
24
+ o[k2] = m[k];
25
+ }));
26
+ var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
27
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.CronFileParser = exports.CronExpressionParser = exports.CronExpression = exports.CronFieldCollection = exports.CronDate = void 0;
31
+ /* istanbul ignore file */
32
+ const CronExpressionParser_1 = requireCronExpressionParser();
33
+ var CronDate_1 = requireCronDate();
34
+ Object.defineProperty(exports, "CronDate", { enumerable: true, get: function () { return CronDate_1.CronDate; } });
35
+ var CronFieldCollection_1 = requireCronFieldCollection();
36
+ Object.defineProperty(exports, "CronFieldCollection", { enumerable: true, get: function () { return CronFieldCollection_1.CronFieldCollection; } });
37
+ var CronExpression_1 = requireCronExpression();
38
+ Object.defineProperty(exports, "CronExpression", { enumerable: true, get: function () { return CronExpression_1.CronExpression; } });
39
+ var CronExpressionParser_2 = requireCronExpressionParser();
40
+ Object.defineProperty(exports, "CronExpressionParser", { enumerable: true, get: function () { return CronExpressionParser_2.CronExpressionParser; } });
41
+ var CronFileParser_1 = requireCronFileParser();
42
+ Object.defineProperty(exports, "CronFileParser", { enumerable: true, get: function () { return CronFileParser_1.CronFileParser; } });
43
+ __exportStar(requireFields(), exports);
44
+ exports.default = CronExpressionParser_1.CronExpressionParser;
45
+ } (dist));
46
+ return dist;
47
+ }
48
+
49
+ export { requireDist as __require };
@@ -0,0 +1,48 @@
1
+ import { __exports as random } from '../../../../_virtual/random.js';
2
+
3
+ var hasRequiredRandom;
4
+
5
+ function requireRandom () {
6
+ if (hasRequiredRandom) return random;
7
+ hasRequiredRandom = 1;
8
+ Object.defineProperty(random, "__esModule", { value: true });
9
+ random.seededRandom = seededRandom;
10
+ /**
11
+ * Computes a numeric hash from a given string
12
+ * @param {string} str A value to hash
13
+ * @returns {number} A numeric hash computed from the given value
14
+ */
15
+ function xfnv1a(str) {
16
+ let h = 2166136261 >>> 0;
17
+ for (let i = 0; i < str.length; i++) {
18
+ h ^= str.charCodeAt(i);
19
+ h = Math.imul(h, 16777619);
20
+ }
21
+ return () => h >>> 0;
22
+ }
23
+ /**
24
+ * Initialize a new PRNG using a given seed
25
+ * @param {number} seed The seed used to initialize the PRNG
26
+ * @returns {PRNG} A random number generator
27
+ */
28
+ function mulberry32(seed) {
29
+ return () => {
30
+ let t = (seed += 0x6d2b79f5);
31
+ t = Math.imul(t ^ (t >>> 15), t | 1);
32
+ t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
33
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
34
+ };
35
+ }
36
+ /**
37
+ * Generates a PRNG using a given seed. When not provided, the seed is randomly generated
38
+ * @param {string} str A string to derive the seed from
39
+ * @returns {PRNG} A random number generator correctly seeded
40
+ */
41
+ function seededRandom(str) {
42
+ const seed = str ? xfnv1a(str)() : Math.floor(Math.random() * 10_000_000_000);
43
+ return mulberry32(seed);
44
+ }
45
+ return random;
46
+ }
47
+
48
+ export { requireRandom as __require };