@wry-smile/lexid 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +211 -2
- package/README.zh-CN.md +178 -0
- package/dist/dictionaries-DqOja3dc.mjs +6574 -0
- package/dist/dictionaries-DwfVfnJX.cjs +6741 -0
- package/dist/dictionaries.cjs +30 -0
- package/dist/dictionaries.d.cts +2 -0
- package/dist/dictionaries.d.mts +2 -0
- package/dist/dictionaries.mjs +2 -0
- package/dist/index-BGuJLQZS.d.mts +19 -0
- package/dist/index-CBG7Ua1f.d.mts +87 -0
- package/dist/index-CvKRlqot.d.cts +87 -0
- package/dist/index-kBjONiKH.d.cts +19 -0
- package/dist/index.cjs +126 -0
- package/dist/index.d.cts +16 -0
- package/dist/index.d.mts +16 -0
- package/dist/index.mjs +87 -0
- package/dist/patterns-DC47BwpJ.cjs +285 -0
- package/dist/patterns-H0XRwCVB.mjs +250 -0
- package/dist/patterns.cjs +8 -0
- package/dist/patterns.d.cts +2 -0
- package/dist/patterns.d.mts +2 -0
- package/dist/patterns.mjs +2 -0
- package/dist/random.cjs +43 -0
- package/dist/random.d.cts +6 -0
- package/dist/random.d.mts +6 -0
- package/dist/random.mjs +42 -0
- package/dist/types-BsCTggdZ.d.mts +37 -0
- package/dist/types-DKjF96ZA.d.cts +37 -0
- package/package.json +97 -3
- package/skills/lexid/SKILL.md +65 -0
- package/skills/lexid/references/api.md +69 -0
- package/skills/lexid/references/customization.md +66 -0
- package/skills/lexid/references/dictionaries.md +33 -0
- package/skills/lexid/references/examples.md +54 -0
- package/skills/lexid/references/patterns.md +45 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
const require_dictionaries = require("./dictionaries-DwfVfnJX.cjs");
|
|
2
|
+
const require_random = require("./random.cjs");
|
|
3
|
+
//#region src/patterns/four-word.ts
|
|
4
|
+
const fourWordPatterns = /* @__PURE__ */ Object.freeze([
|
|
5
|
+
/* @__PURE__ */ Object.freeze([
|
|
6
|
+
require_dictionaries.adjectives,
|
|
7
|
+
require_dictionaries.colors,
|
|
8
|
+
require_dictionaries.nature,
|
|
9
|
+
require_dictionaries.animals
|
|
10
|
+
]),
|
|
11
|
+
/* @__PURE__ */ Object.freeze([
|
|
12
|
+
require_dictionaries.adjectives,
|
|
13
|
+
require_dictionaries.colors,
|
|
14
|
+
require_dictionaries.nature,
|
|
15
|
+
require_dictionaries.birds
|
|
16
|
+
]),
|
|
17
|
+
/* @__PURE__ */ Object.freeze([
|
|
18
|
+
require_dictionaries.adjectives,
|
|
19
|
+
require_dictionaries.colors,
|
|
20
|
+
require_dictionaries.materials,
|
|
21
|
+
require_dictionaries.nouns
|
|
22
|
+
]),
|
|
23
|
+
/* @__PURE__ */ Object.freeze([
|
|
24
|
+
require_dictionaries.adjectives,
|
|
25
|
+
require_dictionaries.colors,
|
|
26
|
+
require_dictionaries.space,
|
|
27
|
+
require_dictionaries.nouns
|
|
28
|
+
]),
|
|
29
|
+
/* @__PURE__ */ Object.freeze([
|
|
30
|
+
require_dictionaries.adjectives,
|
|
31
|
+
require_dictionaries.materials,
|
|
32
|
+
require_dictionaries.architecture,
|
|
33
|
+
require_dictionaries.modifiers
|
|
34
|
+
]),
|
|
35
|
+
/* @__PURE__ */ Object.freeze([
|
|
36
|
+
require_dictionaries.adjectives,
|
|
37
|
+
require_dictionaries.seasons,
|
|
38
|
+
require_dictionaries.colors,
|
|
39
|
+
require_dictionaries.birds
|
|
40
|
+
]),
|
|
41
|
+
/* @__PURE__ */ Object.freeze([
|
|
42
|
+
require_dictionaries.adjectives,
|
|
43
|
+
require_dictionaries.colors,
|
|
44
|
+
require_dictionaries.technologies,
|
|
45
|
+
require_dictionaries.domains
|
|
46
|
+
]),
|
|
47
|
+
/* @__PURE__ */ Object.freeze([
|
|
48
|
+
require_dictionaries.adjectives,
|
|
49
|
+
require_dictionaries.categories,
|
|
50
|
+
require_dictionaries.domains,
|
|
51
|
+
require_dictionaries.modifiers
|
|
52
|
+
]),
|
|
53
|
+
/* @__PURE__ */ Object.freeze([
|
|
54
|
+
require_dictionaries.adjectives,
|
|
55
|
+
require_dictionaries.technologies,
|
|
56
|
+
require_dictionaries.domains,
|
|
57
|
+
require_dictionaries.modifiers
|
|
58
|
+
]),
|
|
59
|
+
/* @__PURE__ */ Object.freeze([
|
|
60
|
+
require_dictionaries.adjectives,
|
|
61
|
+
require_dictionaries.seasons,
|
|
62
|
+
require_dictionaries.nature,
|
|
63
|
+
require_dictionaries.animals
|
|
64
|
+
]),
|
|
65
|
+
/* @__PURE__ */ Object.freeze([
|
|
66
|
+
require_dictionaries.adjectives,
|
|
67
|
+
require_dictionaries.seasons,
|
|
68
|
+
require_dictionaries.nature,
|
|
69
|
+
require_dictionaries.birds
|
|
70
|
+
]),
|
|
71
|
+
/* @__PURE__ */ Object.freeze([
|
|
72
|
+
require_dictionaries.adjectives,
|
|
73
|
+
require_dictionaries.weather,
|
|
74
|
+
require_dictionaries.nature,
|
|
75
|
+
require_dictionaries.nouns
|
|
76
|
+
]),
|
|
77
|
+
/* @__PURE__ */ Object.freeze([
|
|
78
|
+
require_dictionaries.adjectives,
|
|
79
|
+
require_dictionaries.space,
|
|
80
|
+
require_dictionaries.technologies,
|
|
81
|
+
require_dictionaries.domains
|
|
82
|
+
]),
|
|
83
|
+
/* @__PURE__ */ Object.freeze([
|
|
84
|
+
require_dictionaries.adjectives,
|
|
85
|
+
require_dictionaries.nature,
|
|
86
|
+
require_dictionaries.animals,
|
|
87
|
+
require_dictionaries.modifiers
|
|
88
|
+
]),
|
|
89
|
+
/* @__PURE__ */ Object.freeze([
|
|
90
|
+
require_dictionaries.adjectives,
|
|
91
|
+
require_dictionaries.colors,
|
|
92
|
+
require_dictionaries.mythology,
|
|
93
|
+
require_dictionaries.modifiers
|
|
94
|
+
])
|
|
95
|
+
]);
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/patterns/three-word.ts
|
|
98
|
+
const threeWordPatterns = /* @__PURE__ */ Object.freeze([
|
|
99
|
+
/* @__PURE__ */ Object.freeze([
|
|
100
|
+
require_dictionaries.adjectives,
|
|
101
|
+
require_dictionaries.colors,
|
|
102
|
+
require_dictionaries.animals
|
|
103
|
+
]),
|
|
104
|
+
/* @__PURE__ */ Object.freeze([
|
|
105
|
+
require_dictionaries.adjectives,
|
|
106
|
+
require_dictionaries.colors,
|
|
107
|
+
require_dictionaries.birds
|
|
108
|
+
]),
|
|
109
|
+
/* @__PURE__ */ Object.freeze([
|
|
110
|
+
require_dictionaries.adjectives,
|
|
111
|
+
require_dictionaries.colors,
|
|
112
|
+
require_dictionaries.flowers
|
|
113
|
+
]),
|
|
114
|
+
/* @__PURE__ */ Object.freeze([
|
|
115
|
+
require_dictionaries.adjectives,
|
|
116
|
+
require_dictionaries.colors,
|
|
117
|
+
require_dictionaries.plants
|
|
118
|
+
]),
|
|
119
|
+
/* @__PURE__ */ Object.freeze([
|
|
120
|
+
require_dictionaries.adjectives,
|
|
121
|
+
require_dictionaries.nature,
|
|
122
|
+
require_dictionaries.animals
|
|
123
|
+
]),
|
|
124
|
+
/* @__PURE__ */ Object.freeze([
|
|
125
|
+
require_dictionaries.adjectives,
|
|
126
|
+
require_dictionaries.nature,
|
|
127
|
+
require_dictionaries.nouns
|
|
128
|
+
]),
|
|
129
|
+
/* @__PURE__ */ Object.freeze([
|
|
130
|
+
require_dictionaries.adjectives,
|
|
131
|
+
require_dictionaries.elements,
|
|
132
|
+
require_dictionaries.animals
|
|
133
|
+
]),
|
|
134
|
+
/* @__PURE__ */ Object.freeze([
|
|
135
|
+
require_dictionaries.adjectives,
|
|
136
|
+
require_dictionaries.elements,
|
|
137
|
+
require_dictionaries.nouns
|
|
138
|
+
]),
|
|
139
|
+
/* @__PURE__ */ Object.freeze([
|
|
140
|
+
require_dictionaries.adjectives,
|
|
141
|
+
require_dictionaries.technologies,
|
|
142
|
+
require_dictionaries.domains
|
|
143
|
+
]),
|
|
144
|
+
/* @__PURE__ */ Object.freeze([
|
|
145
|
+
require_dictionaries.adjectives,
|
|
146
|
+
require_dictionaries.categories,
|
|
147
|
+
require_dictionaries.domains
|
|
148
|
+
]),
|
|
149
|
+
/* @__PURE__ */ Object.freeze([
|
|
150
|
+
require_dictionaries.adjectives,
|
|
151
|
+
require_dictionaries.domains,
|
|
152
|
+
require_dictionaries.modifiers
|
|
153
|
+
]),
|
|
154
|
+
/* @__PURE__ */ Object.freeze([
|
|
155
|
+
require_dictionaries.adjectives,
|
|
156
|
+
require_dictionaries.materials,
|
|
157
|
+
require_dictionaries.nouns
|
|
158
|
+
]),
|
|
159
|
+
/* @__PURE__ */ Object.freeze([
|
|
160
|
+
require_dictionaries.adjectives,
|
|
161
|
+
require_dictionaries.space,
|
|
162
|
+
require_dictionaries.nouns
|
|
163
|
+
]),
|
|
164
|
+
/* @__PURE__ */ Object.freeze([
|
|
165
|
+
require_dictionaries.adjectives,
|
|
166
|
+
require_dictionaries.weather,
|
|
167
|
+
require_dictionaries.nouns
|
|
168
|
+
]),
|
|
169
|
+
/* @__PURE__ */ Object.freeze([
|
|
170
|
+
require_dictionaries.adjectives,
|
|
171
|
+
require_dictionaries.seasons,
|
|
172
|
+
require_dictionaries.animals
|
|
173
|
+
]),
|
|
174
|
+
/* @__PURE__ */ Object.freeze([
|
|
175
|
+
require_dictionaries.adjectives,
|
|
176
|
+
require_dictionaries.weather,
|
|
177
|
+
require_dictionaries.birds
|
|
178
|
+
]),
|
|
179
|
+
/* @__PURE__ */ Object.freeze([
|
|
180
|
+
require_dictionaries.adjectives,
|
|
181
|
+
require_dictionaries.gemstones,
|
|
182
|
+
require_dictionaries.nouns
|
|
183
|
+
]),
|
|
184
|
+
/* @__PURE__ */ Object.freeze([
|
|
185
|
+
require_dictionaries.adjectives,
|
|
186
|
+
require_dictionaries.mythology,
|
|
187
|
+
require_dictionaries.nouns
|
|
188
|
+
]),
|
|
189
|
+
/* @__PURE__ */ Object.freeze([
|
|
190
|
+
require_dictionaries.adjectives,
|
|
191
|
+
require_dictionaries.colors,
|
|
192
|
+
require_dictionaries.architecture
|
|
193
|
+
]),
|
|
194
|
+
/* @__PURE__ */ Object.freeze([
|
|
195
|
+
require_dictionaries.colors,
|
|
196
|
+
require_dictionaries.nature,
|
|
197
|
+
require_dictionaries.animals
|
|
198
|
+
]),
|
|
199
|
+
/* @__PURE__ */ Object.freeze([
|
|
200
|
+
require_dictionaries.colors,
|
|
201
|
+
require_dictionaries.materials,
|
|
202
|
+
require_dictionaries.nouns
|
|
203
|
+
]),
|
|
204
|
+
/* @__PURE__ */ Object.freeze([
|
|
205
|
+
require_dictionaries.colors,
|
|
206
|
+
require_dictionaries.space,
|
|
207
|
+
require_dictionaries.nouns
|
|
208
|
+
]),
|
|
209
|
+
/* @__PURE__ */ Object.freeze([
|
|
210
|
+
require_dictionaries.seasons,
|
|
211
|
+
require_dictionaries.nature,
|
|
212
|
+
require_dictionaries.animals
|
|
213
|
+
]),
|
|
214
|
+
/* @__PURE__ */ Object.freeze([
|
|
215
|
+
require_dictionaries.technologies,
|
|
216
|
+
require_dictionaries.domains,
|
|
217
|
+
require_dictionaries.modifiers
|
|
218
|
+
])
|
|
219
|
+
]);
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/patterns/pick-pattern.ts
|
|
222
|
+
function pickPattern(patterns) {
|
|
223
|
+
if (!Array.isArray(patterns)) throw new TypeError("patterns must be an array");
|
|
224
|
+
const valid = [];
|
|
225
|
+
for (let index = 0; index < patterns.length; index++) {
|
|
226
|
+
if (!Object.hasOwn(patterns, index)) continue;
|
|
227
|
+
const pattern = patterns[index];
|
|
228
|
+
if (!Array.isArray(pattern) || pattern.length === 0) continue;
|
|
229
|
+
let usable = true;
|
|
230
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
231
|
+
const dictionary = pattern[i];
|
|
232
|
+
if (!Object.hasOwn(pattern, i) || !Array.isArray(dictionary) || dictionary.length === 0) {
|
|
233
|
+
usable = false;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (usable) valid.push(pattern);
|
|
238
|
+
}
|
|
239
|
+
if (valid.length === 0) throw new RangeError("patterns contains no nonempty template with nonempty dictionaries");
|
|
240
|
+
return require_random.random.pick(valid);
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/patterns/index.ts
|
|
244
|
+
/** @deprecated Use threeWordPatterns. */
|
|
245
|
+
const fourSegmentPatterns = threeWordPatterns;
|
|
246
|
+
/** @deprecated Use fourWordPatterns. */
|
|
247
|
+
const fiveSegmentPatterns = fourWordPatterns;
|
|
248
|
+
const defaultPatterns = /* @__PURE__ */ Object.freeze([...threeWordPatterns, ...fourWordPatterns]);
|
|
249
|
+
//#endregion
|
|
250
|
+
Object.defineProperty(exports, "defaultPatterns", {
|
|
251
|
+
enumerable: true,
|
|
252
|
+
get: function() {
|
|
253
|
+
return defaultPatterns;
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
Object.defineProperty(exports, "fiveSegmentPatterns", {
|
|
257
|
+
enumerable: true,
|
|
258
|
+
get: function() {
|
|
259
|
+
return fiveSegmentPatterns;
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
Object.defineProperty(exports, "fourSegmentPatterns", {
|
|
263
|
+
enumerable: true,
|
|
264
|
+
get: function() {
|
|
265
|
+
return fourSegmentPatterns;
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
Object.defineProperty(exports, "fourWordPatterns", {
|
|
269
|
+
enumerable: true,
|
|
270
|
+
get: function() {
|
|
271
|
+
return fourWordPatterns;
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(exports, "pickPattern", {
|
|
275
|
+
enumerable: true,
|
|
276
|
+
get: function() {
|
|
277
|
+
return pickPattern;
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
Object.defineProperty(exports, "threeWordPatterns", {
|
|
281
|
+
enumerable: true,
|
|
282
|
+
get: function() {
|
|
283
|
+
return threeWordPatterns;
|
|
284
|
+
}
|
|
285
|
+
});
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { C as categories, E as animals, O as adjectives, S as colors, T as architecture, _ as gemstones, a as space, b as domains, c as nouns, f as modifiers, i as technologies, l as nature, o as seasons, p as materials, s as plants, t as weather, u as mythology, v as flowers, w as birds, y as elements } from "./dictionaries-DqOja3dc.mjs";
|
|
2
|
+
import { random } from "./random.mjs";
|
|
3
|
+
//#region src/patterns/four-word.ts
|
|
4
|
+
const fourWordPatterns = /* @__PURE__ */ Object.freeze([
|
|
5
|
+
/* @__PURE__ */ Object.freeze([
|
|
6
|
+
adjectives,
|
|
7
|
+
colors,
|
|
8
|
+
nature,
|
|
9
|
+
animals
|
|
10
|
+
]),
|
|
11
|
+
/* @__PURE__ */ Object.freeze([
|
|
12
|
+
adjectives,
|
|
13
|
+
colors,
|
|
14
|
+
nature,
|
|
15
|
+
birds
|
|
16
|
+
]),
|
|
17
|
+
/* @__PURE__ */ Object.freeze([
|
|
18
|
+
adjectives,
|
|
19
|
+
colors,
|
|
20
|
+
materials,
|
|
21
|
+
nouns
|
|
22
|
+
]),
|
|
23
|
+
/* @__PURE__ */ Object.freeze([
|
|
24
|
+
adjectives,
|
|
25
|
+
colors,
|
|
26
|
+
space,
|
|
27
|
+
nouns
|
|
28
|
+
]),
|
|
29
|
+
/* @__PURE__ */ Object.freeze([
|
|
30
|
+
adjectives,
|
|
31
|
+
materials,
|
|
32
|
+
architecture,
|
|
33
|
+
modifiers
|
|
34
|
+
]),
|
|
35
|
+
/* @__PURE__ */ Object.freeze([
|
|
36
|
+
adjectives,
|
|
37
|
+
seasons,
|
|
38
|
+
colors,
|
|
39
|
+
birds
|
|
40
|
+
]),
|
|
41
|
+
/* @__PURE__ */ Object.freeze([
|
|
42
|
+
adjectives,
|
|
43
|
+
colors,
|
|
44
|
+
technologies,
|
|
45
|
+
domains
|
|
46
|
+
]),
|
|
47
|
+
/* @__PURE__ */ Object.freeze([
|
|
48
|
+
adjectives,
|
|
49
|
+
categories,
|
|
50
|
+
domains,
|
|
51
|
+
modifiers
|
|
52
|
+
]),
|
|
53
|
+
/* @__PURE__ */ Object.freeze([
|
|
54
|
+
adjectives,
|
|
55
|
+
technologies,
|
|
56
|
+
domains,
|
|
57
|
+
modifiers
|
|
58
|
+
]),
|
|
59
|
+
/* @__PURE__ */ Object.freeze([
|
|
60
|
+
adjectives,
|
|
61
|
+
seasons,
|
|
62
|
+
nature,
|
|
63
|
+
animals
|
|
64
|
+
]),
|
|
65
|
+
/* @__PURE__ */ Object.freeze([
|
|
66
|
+
adjectives,
|
|
67
|
+
seasons,
|
|
68
|
+
nature,
|
|
69
|
+
birds
|
|
70
|
+
]),
|
|
71
|
+
/* @__PURE__ */ Object.freeze([
|
|
72
|
+
adjectives,
|
|
73
|
+
weather,
|
|
74
|
+
nature,
|
|
75
|
+
nouns
|
|
76
|
+
]),
|
|
77
|
+
/* @__PURE__ */ Object.freeze([
|
|
78
|
+
adjectives,
|
|
79
|
+
space,
|
|
80
|
+
technologies,
|
|
81
|
+
domains
|
|
82
|
+
]),
|
|
83
|
+
/* @__PURE__ */ Object.freeze([
|
|
84
|
+
adjectives,
|
|
85
|
+
nature,
|
|
86
|
+
animals,
|
|
87
|
+
modifiers
|
|
88
|
+
]),
|
|
89
|
+
/* @__PURE__ */ Object.freeze([
|
|
90
|
+
adjectives,
|
|
91
|
+
colors,
|
|
92
|
+
mythology,
|
|
93
|
+
modifiers
|
|
94
|
+
])
|
|
95
|
+
]);
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/patterns/three-word.ts
|
|
98
|
+
const threeWordPatterns = /* @__PURE__ */ Object.freeze([
|
|
99
|
+
/* @__PURE__ */ Object.freeze([
|
|
100
|
+
adjectives,
|
|
101
|
+
colors,
|
|
102
|
+
animals
|
|
103
|
+
]),
|
|
104
|
+
/* @__PURE__ */ Object.freeze([
|
|
105
|
+
adjectives,
|
|
106
|
+
colors,
|
|
107
|
+
birds
|
|
108
|
+
]),
|
|
109
|
+
/* @__PURE__ */ Object.freeze([
|
|
110
|
+
adjectives,
|
|
111
|
+
colors,
|
|
112
|
+
flowers
|
|
113
|
+
]),
|
|
114
|
+
/* @__PURE__ */ Object.freeze([
|
|
115
|
+
adjectives,
|
|
116
|
+
colors,
|
|
117
|
+
plants
|
|
118
|
+
]),
|
|
119
|
+
/* @__PURE__ */ Object.freeze([
|
|
120
|
+
adjectives,
|
|
121
|
+
nature,
|
|
122
|
+
animals
|
|
123
|
+
]),
|
|
124
|
+
/* @__PURE__ */ Object.freeze([
|
|
125
|
+
adjectives,
|
|
126
|
+
nature,
|
|
127
|
+
nouns
|
|
128
|
+
]),
|
|
129
|
+
/* @__PURE__ */ Object.freeze([
|
|
130
|
+
adjectives,
|
|
131
|
+
elements,
|
|
132
|
+
animals
|
|
133
|
+
]),
|
|
134
|
+
/* @__PURE__ */ Object.freeze([
|
|
135
|
+
adjectives,
|
|
136
|
+
elements,
|
|
137
|
+
nouns
|
|
138
|
+
]),
|
|
139
|
+
/* @__PURE__ */ Object.freeze([
|
|
140
|
+
adjectives,
|
|
141
|
+
technologies,
|
|
142
|
+
domains
|
|
143
|
+
]),
|
|
144
|
+
/* @__PURE__ */ Object.freeze([
|
|
145
|
+
adjectives,
|
|
146
|
+
categories,
|
|
147
|
+
domains
|
|
148
|
+
]),
|
|
149
|
+
/* @__PURE__ */ Object.freeze([
|
|
150
|
+
adjectives,
|
|
151
|
+
domains,
|
|
152
|
+
modifiers
|
|
153
|
+
]),
|
|
154
|
+
/* @__PURE__ */ Object.freeze([
|
|
155
|
+
adjectives,
|
|
156
|
+
materials,
|
|
157
|
+
nouns
|
|
158
|
+
]),
|
|
159
|
+
/* @__PURE__ */ Object.freeze([
|
|
160
|
+
adjectives,
|
|
161
|
+
space,
|
|
162
|
+
nouns
|
|
163
|
+
]),
|
|
164
|
+
/* @__PURE__ */ Object.freeze([
|
|
165
|
+
adjectives,
|
|
166
|
+
weather,
|
|
167
|
+
nouns
|
|
168
|
+
]),
|
|
169
|
+
/* @__PURE__ */ Object.freeze([
|
|
170
|
+
adjectives,
|
|
171
|
+
seasons,
|
|
172
|
+
animals
|
|
173
|
+
]),
|
|
174
|
+
/* @__PURE__ */ Object.freeze([
|
|
175
|
+
adjectives,
|
|
176
|
+
weather,
|
|
177
|
+
birds
|
|
178
|
+
]),
|
|
179
|
+
/* @__PURE__ */ Object.freeze([
|
|
180
|
+
adjectives,
|
|
181
|
+
gemstones,
|
|
182
|
+
nouns
|
|
183
|
+
]),
|
|
184
|
+
/* @__PURE__ */ Object.freeze([
|
|
185
|
+
adjectives,
|
|
186
|
+
mythology,
|
|
187
|
+
nouns
|
|
188
|
+
]),
|
|
189
|
+
/* @__PURE__ */ Object.freeze([
|
|
190
|
+
adjectives,
|
|
191
|
+
colors,
|
|
192
|
+
architecture
|
|
193
|
+
]),
|
|
194
|
+
/* @__PURE__ */ Object.freeze([
|
|
195
|
+
colors,
|
|
196
|
+
nature,
|
|
197
|
+
animals
|
|
198
|
+
]),
|
|
199
|
+
/* @__PURE__ */ Object.freeze([
|
|
200
|
+
colors,
|
|
201
|
+
materials,
|
|
202
|
+
nouns
|
|
203
|
+
]),
|
|
204
|
+
/* @__PURE__ */ Object.freeze([
|
|
205
|
+
colors,
|
|
206
|
+
space,
|
|
207
|
+
nouns
|
|
208
|
+
]),
|
|
209
|
+
/* @__PURE__ */ Object.freeze([
|
|
210
|
+
seasons,
|
|
211
|
+
nature,
|
|
212
|
+
animals
|
|
213
|
+
]),
|
|
214
|
+
/* @__PURE__ */ Object.freeze([
|
|
215
|
+
technologies,
|
|
216
|
+
domains,
|
|
217
|
+
modifiers
|
|
218
|
+
])
|
|
219
|
+
]);
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/patterns/pick-pattern.ts
|
|
222
|
+
function pickPattern(patterns) {
|
|
223
|
+
if (!Array.isArray(patterns)) throw new TypeError("patterns must be an array");
|
|
224
|
+
const valid = [];
|
|
225
|
+
for (let index = 0; index < patterns.length; index++) {
|
|
226
|
+
if (!Object.hasOwn(patterns, index)) continue;
|
|
227
|
+
const pattern = patterns[index];
|
|
228
|
+
if (!Array.isArray(pattern) || pattern.length === 0) continue;
|
|
229
|
+
let usable = true;
|
|
230
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
231
|
+
const dictionary = pattern[i];
|
|
232
|
+
if (!Object.hasOwn(pattern, i) || !Array.isArray(dictionary) || dictionary.length === 0) {
|
|
233
|
+
usable = false;
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
if (usable) valid.push(pattern);
|
|
238
|
+
}
|
|
239
|
+
if (valid.length === 0) throw new RangeError("patterns contains no nonempty template with nonempty dictionaries");
|
|
240
|
+
return random.pick(valid);
|
|
241
|
+
}
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/patterns/index.ts
|
|
244
|
+
/** @deprecated Use threeWordPatterns. */
|
|
245
|
+
const fourSegmentPatterns = threeWordPatterns;
|
|
246
|
+
/** @deprecated Use fourWordPatterns. */
|
|
247
|
+
const fiveSegmentPatterns = fourWordPatterns;
|
|
248
|
+
const defaultPatterns = /* @__PURE__ */ Object.freeze([...threeWordPatterns, ...fourWordPatterns]);
|
|
249
|
+
//#endregion
|
|
250
|
+
export { threeWordPatterns as a, pickPattern as i, fiveSegmentPatterns as n, fourWordPatterns as o, fourSegmentPatterns as r, defaultPatterns as t };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_patterns = require("./patterns-DC47BwpJ.cjs");
|
|
3
|
+
exports.defaultPatterns = require_patterns.defaultPatterns;
|
|
4
|
+
exports.fiveSegmentPatterns = require_patterns.fiveSegmentPatterns;
|
|
5
|
+
exports.fourSegmentPatterns = require_patterns.fourSegmentPatterns;
|
|
6
|
+
exports.fourWordPatterns = require_patterns.fourWordPatterns;
|
|
7
|
+
exports.pickPattern = require_patterns.pickPattern;
|
|
8
|
+
exports.threeWordPatterns = require_patterns.threeWordPatterns;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as threeWordPatterns, i as pickPattern, n as fiveSegmentPatterns, o as fourWordPatterns, r as fourSegmentPatterns, t as defaultPatterns } from "./index-kBjONiKH.cjs";
|
|
2
|
+
export { defaultPatterns, fiveSegmentPatterns, fourSegmentPatterns, fourWordPatterns, pickPattern, threeWordPatterns };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as threeWordPatterns, i as pickPattern, n as fiveSegmentPatterns, o as fourWordPatterns, r as fourSegmentPatterns, t as defaultPatterns } from "./index-BGuJLQZS.mjs";
|
|
2
|
+
export { defaultPatterns, fiveSegmentPatterns, fourSegmentPatterns, fourWordPatterns, pickPattern, threeWordPatterns };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as threeWordPatterns, i as pickPattern, n as fiveSegmentPatterns, o as fourWordPatterns, r as fourSegmentPatterns, t as defaultPatterns } from "./patterns-H0XRwCVB.mjs";
|
|
2
|
+
export { defaultPatterns, fiveSegmentPatterns, fourSegmentPatterns, fourWordPatterns, pickPattern, threeWordPatterns };
|
package/dist/random.cjs
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/random.ts
|
|
3
|
+
const letters = "abcdefghijklmnopqrstuvwxyz";
|
|
4
|
+
const digits = "0123456789";
|
|
5
|
+
const wordRange = 2 ** 32;
|
|
6
|
+
const sampleRange = 2 ** 48;
|
|
7
|
+
function int(max) {
|
|
8
|
+
if (!Number.isSafeInteger(max) || max <= 0 || max >= sampleRange) throw new RangeError("max must be a positive integer less than 2^48");
|
|
9
|
+
const crypto = globalThis.crypto;
|
|
10
|
+
if (typeof crypto?.getRandomValues !== "function") throw new Error("LexID requires crypto.getRandomValues for secure randomness");
|
|
11
|
+
const words = new Uint32Array(2);
|
|
12
|
+
const limit = sampleRange - sampleRange % max;
|
|
13
|
+
let sample;
|
|
14
|
+
do {
|
|
15
|
+
crypto.getRandomValues(words);
|
|
16
|
+
sample = (words[0] & 65535) * wordRange + words[1];
|
|
17
|
+
} while (sample >= limit);
|
|
18
|
+
return sample % max;
|
|
19
|
+
}
|
|
20
|
+
function pick(items) {
|
|
21
|
+
if (!Array.isArray(items) || items.length === 0) throw new TypeError("items must be a nonempty array");
|
|
22
|
+
for (let index = 0; index < items.length; index++) if (!Object.hasOwn(items, index)) throw new TypeError(`items[${index}] must not be a hole`);
|
|
23
|
+
return items[int(items.length)];
|
|
24
|
+
}
|
|
25
|
+
function string(alphabet, length) {
|
|
26
|
+
if (typeof alphabet !== "string" || alphabet.length === 0) throw new TypeError("alphabet must be a nonempty string");
|
|
27
|
+
if (!Number.isSafeInteger(length) || length < 0) throw new RangeError("length must be a nonnegative safe integer");
|
|
28
|
+
const characters = [...new Set(alphabet)];
|
|
29
|
+
let result = "";
|
|
30
|
+
for (let index = 0; index < length; index++) result += characters[int(characters.length)];
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
const random = /* @__PURE__ */ Object.freeze({
|
|
34
|
+
int,
|
|
35
|
+
pick,
|
|
36
|
+
string,
|
|
37
|
+
numeric: (length) => string(digits, length),
|
|
38
|
+
alphabetic: (length) => string(letters, length),
|
|
39
|
+
alphanumeric: (length) => string(letters + digits, length),
|
|
40
|
+
hexadecimal: (length) => string(digits + "abcdef", length)
|
|
41
|
+
});
|
|
42
|
+
//#endregion
|
|
43
|
+
exports.random = random;
|
package/dist/random.mjs
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/random.ts
|
|
2
|
+
const letters = "abcdefghijklmnopqrstuvwxyz";
|
|
3
|
+
const digits = "0123456789";
|
|
4
|
+
const wordRange = 2 ** 32;
|
|
5
|
+
const sampleRange = 2 ** 48;
|
|
6
|
+
function int(max) {
|
|
7
|
+
if (!Number.isSafeInteger(max) || max <= 0 || max >= sampleRange) throw new RangeError("max must be a positive integer less than 2^48");
|
|
8
|
+
const crypto = globalThis.crypto;
|
|
9
|
+
if (typeof crypto?.getRandomValues !== "function") throw new Error("LexID requires crypto.getRandomValues for secure randomness");
|
|
10
|
+
const words = new Uint32Array(2);
|
|
11
|
+
const limit = sampleRange - sampleRange % max;
|
|
12
|
+
let sample;
|
|
13
|
+
do {
|
|
14
|
+
crypto.getRandomValues(words);
|
|
15
|
+
sample = (words[0] & 65535) * wordRange + words[1];
|
|
16
|
+
} while (sample >= limit);
|
|
17
|
+
return sample % max;
|
|
18
|
+
}
|
|
19
|
+
function pick(items) {
|
|
20
|
+
if (!Array.isArray(items) || items.length === 0) throw new TypeError("items must be a nonempty array");
|
|
21
|
+
for (let index = 0; index < items.length; index++) if (!Object.hasOwn(items, index)) throw new TypeError(`items[${index}] must not be a hole`);
|
|
22
|
+
return items[int(items.length)];
|
|
23
|
+
}
|
|
24
|
+
function string(alphabet, length) {
|
|
25
|
+
if (typeof alphabet !== "string" || alphabet.length === 0) throw new TypeError("alphabet must be a nonempty string");
|
|
26
|
+
if (!Number.isSafeInteger(length) || length < 0) throw new RangeError("length must be a nonnegative safe integer");
|
|
27
|
+
const characters = [...new Set(alphabet)];
|
|
28
|
+
let result = "";
|
|
29
|
+
for (let index = 0; index < length; index++) result += characters[int(characters.length)];
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
const random = /* @__PURE__ */ Object.freeze({
|
|
33
|
+
int,
|
|
34
|
+
pick,
|
|
35
|
+
string,
|
|
36
|
+
numeric: (length) => string(digits, length),
|
|
37
|
+
alphabetic: (length) => string(letters, length),
|
|
38
|
+
alphanumeric: (length) => string(letters + digits, length),
|
|
39
|
+
hexadecimal: (length) => string(digits + "abcdef", length)
|
|
40
|
+
});
|
|
41
|
+
//#endregion
|
|
42
|
+
export { random };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type Dictionary = readonly string[];
|
|
3
|
+
type Segments = readonly Dictionary[];
|
|
4
|
+
type Pattern = Segments;
|
|
5
|
+
type Patterns = readonly Pattern[];
|
|
6
|
+
interface RandomUtils {
|
|
7
|
+
int(max: number): number;
|
|
8
|
+
pick<T>(items: readonly T[]): T;
|
|
9
|
+
string(alphabet: string, length: number): string;
|
|
10
|
+
numeric(length: number): string;
|
|
11
|
+
alphabetic(length: number): string;
|
|
12
|
+
alphanumeric(length: number): string;
|
|
13
|
+
hexadecimal(length: number): string;
|
|
14
|
+
}
|
|
15
|
+
interface SuffixContext {
|
|
16
|
+
readonly words: readonly string[];
|
|
17
|
+
readonly random: RandomUtils;
|
|
18
|
+
}
|
|
19
|
+
type SuffixGenerator = (context: SuffixContext) => string;
|
|
20
|
+
interface LexidOptions {
|
|
21
|
+
/** Ordered word dictionaries. Defaults to a randomly selected built-in pattern. */
|
|
22
|
+
segments?: Segments;
|
|
23
|
+
/** Separator between all segments. Defaults to '-'. */
|
|
24
|
+
separator?: string;
|
|
25
|
+
/** Set to false to omit the suffix, or pass a callback. Defaults to six lowercase alphanumeric characters. */
|
|
26
|
+
suffix?: SuffixGenerator | false;
|
|
27
|
+
/** Maximum length including separators and suffix. Defaults to 63. */
|
|
28
|
+
maxLength?: number;
|
|
29
|
+
}
|
|
30
|
+
interface LexidValidateOptions {
|
|
31
|
+
separator?: string;
|
|
32
|
+
maxLength?: number;
|
|
33
|
+
/** Whether to expect a final suffix segment. Defaults to true. */
|
|
34
|
+
hasSuffix?: boolean;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { Patterns as a, SuffixContext as c, Pattern as i, SuffixGenerator as l, LexidOptions as n, RandomUtils as o, LexidValidateOptions as r, Segments as s, Dictionary as t };
|