@orieljs/support 0.1.0-alpha.4 → 0.1.0-alpha.6
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/NOTICE +3 -0
- package/dist/index.d.ts +145 -3
- package/dist/index.js +1858 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/NOTICE
CHANGED
|
@@ -7,3 +7,6 @@ This product includes software developed by the Oriel project
|
|
|
7
7
|
Oriel is licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
8
8
|
The Oriel name and logo are not covered by that license; see TRADEMARKS.md
|
|
9
9
|
(https://github.com/orieljs/framework/blob/main/TRADEMARKS.md).
|
|
10
|
+
|
|
11
|
+
@orieljs/support (and @orieljs/framework, which bundles it) includes transliteration data from
|
|
12
|
+
voku/portable-ascii (https://github.com/voku/portable-ascii), Copyright (C) 2019 Lars Moelleken, MIT License.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,72 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Collection } from '@orieljs/collections';
|
|
2
2
|
export { collect } from '@orieljs/collections';
|
|
3
|
+
import { ServiceProvider as ServiceProvider$1, Application, Abstract, ClassRegistry as ClassRegistry$1, Class, ConfigRepository } from '@orieljs/contracts';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Laravel's Stringable: a string with Str's helpers as chainable methods, each returning a new Stringable.
|
|
7
|
+
* `Str.of(' Café ').trim().slug().toString()` is 'cafe'; `request().string('q')` returns one. It prints as its string.
|
|
8
|
+
*/
|
|
9
|
+
declare class Stringable {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(value?: string);
|
|
12
|
+
after(search: string): Stringable;
|
|
13
|
+
afterLast(search: string): Stringable;
|
|
14
|
+
append(...values: string[]): Stringable;
|
|
15
|
+
ascii(): Stringable;
|
|
16
|
+
before(search: string): Stringable;
|
|
17
|
+
beforeLast(search: string): Stringable;
|
|
18
|
+
between(from: string, to: string): Stringable;
|
|
19
|
+
camel(): Stringable;
|
|
20
|
+
contains(needles: string | string[]): boolean;
|
|
21
|
+
endsWith(needles: string | string[]): boolean;
|
|
22
|
+
/** The same string as `value` (a string or another Stringable). */
|
|
23
|
+
exactly(value: string | Stringable): boolean;
|
|
24
|
+
/** The parts between the delimiters, as a Collection (PHP's explode()). */
|
|
25
|
+
explode(delimiter: string): Collection<string>;
|
|
26
|
+
finish(cap: string): Stringable;
|
|
27
|
+
/** Wildcard match, as Str.is(): `*` matches anything. */
|
|
28
|
+
is(pattern: string): boolean;
|
|
29
|
+
isEmpty(): boolean;
|
|
30
|
+
isNotEmpty(): boolean;
|
|
31
|
+
kebab(): Stringable;
|
|
32
|
+
lcfirst(): Stringable;
|
|
33
|
+
/** The number of characters (code points, as PHP's mb_strlen()). */
|
|
34
|
+
length(): number;
|
|
35
|
+
limit(limit?: number, end?: string): Stringable;
|
|
36
|
+
lower(): Stringable;
|
|
37
|
+
/** Strips whitespace and invisible characters from the start, or the characters given. */
|
|
38
|
+
ltrim(characters?: string): Stringable;
|
|
39
|
+
plural(count?: number): Stringable;
|
|
40
|
+
prepend(...values: string[]): Stringable;
|
|
41
|
+
/** Replaces every occurrence of the search string (or of each of several) with `replace`. */
|
|
42
|
+
replace(search: string | string[], replace: string): Stringable;
|
|
43
|
+
/** Strips whitespace and invisible characters from the end, or the characters given. */
|
|
44
|
+
rtrim(characters?: string): Stringable;
|
|
45
|
+
singular(): Stringable;
|
|
46
|
+
slug(separator?: string): Stringable;
|
|
47
|
+
snake(delimiter?: string): Stringable;
|
|
48
|
+
start(prefix: string): Stringable;
|
|
49
|
+
startsWith(needles: string | string[]): boolean;
|
|
50
|
+
studly(): Stringable;
|
|
51
|
+
title(): Stringable;
|
|
52
|
+
/** PHP's filter_var(FILTER_VALIDATE_BOOLEAN): '1', 'true', 'on' and 'yes' (any case, trimmed) are true. */
|
|
53
|
+
toBoolean(): boolean;
|
|
54
|
+
/** PHP's floatval(): the leading number, else 0. */
|
|
55
|
+
toFloat(): number;
|
|
56
|
+
/** PHP's intval(): the leading digits, else 0. */
|
|
57
|
+
toInteger(): number;
|
|
58
|
+
toJSON(): string;
|
|
59
|
+
toString(): string;
|
|
60
|
+
/** Strips whitespace and invisible characters from both ends (Laravel's Str::trim()), or the characters given. */
|
|
61
|
+
trim(characters?: string): Stringable;
|
|
62
|
+
ucfirst(): Stringable;
|
|
63
|
+
upper(): Stringable;
|
|
64
|
+
value(): string;
|
|
65
|
+
}
|
|
3
66
|
|
|
4
67
|
declare const Str: {
|
|
68
|
+
/** Laravel's Str::of(): the value as a Stringable, for chaining: Str.of(title).trim().slug(). */
|
|
69
|
+
of: (value?: unknown) => Stringable;
|
|
5
70
|
ucfirst: (v: string) => string;
|
|
6
71
|
lcfirst: (v: string) => string;
|
|
7
72
|
studly: (v: string) => string;
|
|
@@ -9,11 +74,31 @@ declare const Str: {
|
|
|
9
74
|
snake: (v: string, delimiter?: string) => string;
|
|
10
75
|
kebab: (v: string) => string;
|
|
11
76
|
title: (v: string) => string;
|
|
12
|
-
|
|
77
|
+
/** Laravel's Str::ascii(): the value in plain ASCII ('Café' → 'Cafe', 'Ελληνικά' → 'Ellinika'), as for English. */
|
|
78
|
+
ascii: (v: string) => string;
|
|
79
|
+
/**
|
|
80
|
+
* Laravel's Str::slug(): transliterated to ASCII first (unless `language` is null), '@' read as 'at', then lower-cased
|
|
81
|
+
* letters and digits joined by the separator: 'Café crème' → 'cafe-creme'. What has no ASCII form is dropped.
|
|
82
|
+
*/
|
|
83
|
+
slug: (title: string, separator?: string, language?: "en" | null, dictionary?: Readonly<Record<string, string>>) => string;
|
|
13
84
|
plural: (v: string, count?: number) => string;
|
|
14
85
|
singular: (v: string) => string;
|
|
15
86
|
random: (length?: number) => string;
|
|
16
87
|
uuid: () => `${string}-${string}-${string}-${string}-${string}`;
|
|
88
|
+
/**
|
|
89
|
+
* A version 7 UUID (RFC 9562): the time in milliseconds first, so ids from later milliseconds sort after earlier ones
|
|
90
|
+
* (within one millisecond the order is random). Throws a TypeError for a time before 1970, after 10889 or invalid.
|
|
91
|
+
*/
|
|
92
|
+
uuid7: (time?: Date) => string;
|
|
93
|
+
/**
|
|
94
|
+
* A ULID: 26 upper-case Crockford characters, ten for the time in milliseconds and sixteen random, so ids from later
|
|
95
|
+
* milliseconds sort after earlier ones. Throws a TypeError for a time before 1970, after 10889 or invalid.
|
|
96
|
+
*/
|
|
97
|
+
ulid: (time?: Date) => string;
|
|
98
|
+
/** Laravel's Str::isUuid(): five groups of hex digits, any version. */
|
|
99
|
+
isUuid: (value: unknown) => value is string;
|
|
100
|
+
/** Laravel's Str::isUlid(): 26 Crockford characters in either case, the first at most 7. */
|
|
101
|
+
isUlid: (value: unknown) => value is string;
|
|
17
102
|
/** Wildcard match: `*` matches anything; everything else is literal. */
|
|
18
103
|
is: (pattern: string, value: string) => boolean;
|
|
19
104
|
startsWith: (v: string, needles: string | string[]) => boolean;
|
|
@@ -92,4 +177,61 @@ declare function retry<T>(times: number, fn: (attempt: number) => T | Promise<T>
|
|
|
92
177
|
*/
|
|
93
178
|
declare function __(key: string, replace?: Record<string, string | number>): string;
|
|
94
179
|
|
|
95
|
-
|
|
180
|
+
/**
|
|
181
|
+
* What a file's bytes show it to be, read from its leading bytes the way PHP's finfo reads them for Laravel (the file
|
|
182
|
+
* validation rules, and the extension a stored upload gets). The client's file name and MIME type are never consulted.
|
|
183
|
+
*/
|
|
184
|
+
interface DetectedType {
|
|
185
|
+
/** 'image/png', 'text/plain', …; 'application/octet-stream' when no format matches, 'application/x-empty' for no bytes. */
|
|
186
|
+
readonly mime: string;
|
|
187
|
+
/** The extensions that name the type, the usual one first. Empty when the bytes match no format. */
|
|
188
|
+
readonly extensions: readonly string[];
|
|
189
|
+
}
|
|
190
|
+
declare const JPEG: DetectedType;
|
|
191
|
+
declare const PNG: DetectedType;
|
|
192
|
+
declare const GIF: DetectedType;
|
|
193
|
+
declare const WEBP: DetectedType;
|
|
194
|
+
declare const AVIF: DetectedType;
|
|
195
|
+
declare const BMP: DetectedType;
|
|
196
|
+
declare const SVG: DetectedType;
|
|
197
|
+
declare const PDF: DetectedType;
|
|
198
|
+
declare const HTML: DetectedType;
|
|
199
|
+
declare const XML: DetectedType;
|
|
200
|
+
declare const TEXT: DetectedType;
|
|
201
|
+
declare const UNKNOWN: DetectedType;
|
|
202
|
+
declare const EMPTY: DetectedType;
|
|
203
|
+
/** The raster formats the image rule accepts: Laravel 12's jpg, jpeg, png, gif, bmp and webp, plus AVIF. */
|
|
204
|
+
declare const RASTER_IMAGES: ReadonlySet<string>;
|
|
205
|
+
/** Every format recognised by its bytes other than plain text. */
|
|
206
|
+
declare const BINARY_AND_MARKUP_TYPES: readonly DetectedType[];
|
|
207
|
+
/**
|
|
208
|
+
* How much of a file is read to tell its type: the window checked for binary bytes (libmagic reads its first megabyte
|
|
209
|
+
* too). Uploads read this much to be named, so naming and validation see the same bytes.
|
|
210
|
+
*/
|
|
211
|
+
declare const SNIFF_BYTES: number;
|
|
212
|
+
/** The type the bytes show. */
|
|
213
|
+
declare function detectFileType(bytes: Uint8Array): DetectedType;
|
|
214
|
+
|
|
215
|
+
declare const fileType_AVIF: typeof AVIF;
|
|
216
|
+
declare const fileType_BINARY_AND_MARKUP_TYPES: typeof BINARY_AND_MARKUP_TYPES;
|
|
217
|
+
declare const fileType_BMP: typeof BMP;
|
|
218
|
+
type fileType_DetectedType = DetectedType;
|
|
219
|
+
declare const fileType_EMPTY: typeof EMPTY;
|
|
220
|
+
declare const fileType_GIF: typeof GIF;
|
|
221
|
+
declare const fileType_HTML: typeof HTML;
|
|
222
|
+
declare const fileType_JPEG: typeof JPEG;
|
|
223
|
+
declare const fileType_PDF: typeof PDF;
|
|
224
|
+
declare const fileType_PNG: typeof PNG;
|
|
225
|
+
declare const fileType_RASTER_IMAGES: typeof RASTER_IMAGES;
|
|
226
|
+
declare const fileType_SNIFF_BYTES: typeof SNIFF_BYTES;
|
|
227
|
+
declare const fileType_SVG: typeof SVG;
|
|
228
|
+
declare const fileType_TEXT: typeof TEXT;
|
|
229
|
+
declare const fileType_UNKNOWN: typeof UNKNOWN;
|
|
230
|
+
declare const fileType_WEBP: typeof WEBP;
|
|
231
|
+
declare const fileType_XML: typeof XML;
|
|
232
|
+
declare const fileType_detectFileType: typeof detectFileType;
|
|
233
|
+
declare namespace fileType {
|
|
234
|
+
export { fileType_AVIF as AVIF, fileType_BINARY_AND_MARKUP_TYPES as BINARY_AND_MARKUP_TYPES, fileType_BMP as BMP, type fileType_DetectedType as DetectedType, fileType_EMPTY as EMPTY, fileType_GIF as GIF, fileType_HTML as HTML, fileType_JPEG as JPEG, fileType_PDF as PDF, fileType_PNG as PNG, fileType_RASTER_IMAGES as RASTER_IMAGES, fileType_SNIFF_BYTES as SNIFF_BYTES, fileType_SVG as SVG, fileType_TEXT as TEXT, fileType_UNKNOWN as UNKNOWN, fileType_WEBP as WEBP, fileType_XML as XML, fileType_detectFileType as detectFileType };
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export { Arr, ClassRegistry, type Facade, type FacadeStatics, fileType as FileType, ServiceProvider, Str, Stringable, __, app, config, facade, now, retry, tap, value };
|