@pacem/pacem-foundation 1.0.0-abel

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,458 @@
1
+ export declare interface Angle {
2
+ vertex: Point;
3
+ start: Point;
4
+ end: Point;
5
+ }
6
+
7
+ export declare class Angle {
8
+ static isAngle(obj: any): obj is Angle;
9
+ /**
10
+ * Returns the angle span in radians.
11
+ * Clockwise angles are positive, counterclockwise angles are negative.
12
+ */
13
+ static value(angle: Angle): number;
14
+ /**
15
+ * Returns the angle (in radians) given the angle vertex and two points belonging to the rays that combine to build the angle sides.
16
+ * Clockwise angles are positive, counterclockwise angles are negative.
17
+ * @param vertex Angle vertex
18
+ * @param start Point belonging to the start side
19
+ * @param end Point belonging to the end side
20
+ * @returns Angle span in radians [-pi, pi]
21
+ */
22
+ static angleBetween(vertex: Point, start: Point, end: Point): number;
23
+ }
24
+
25
+ export declare class Arrays {
26
+ static range(items: number): number[];
27
+ static range(min: number, max: number, items?: number): number[];
28
+ static chunkify(source: any[], size: number): any[][];
29
+ }
30
+
31
+ export declare class Blobs {
32
+ static blobToDataURL(blob: Blob): Promise<string>;
33
+ private static _b64ToUint8Array;
34
+ static base64ToBlob(bstr: string, options?: BlobPropertyBag): Blob;
35
+ static dataURLToBlob(dataurl: string): Blob;
36
+ static blobToText(blob: Blob, encoding?: string): Promise<string>;
37
+ static textToBlob(content: string): Blob;
38
+ static textToBlob(content: string, type: string): Blob;
39
+ static textToBlob(content: string, type: string, charset: BlobTextEncoding): Blob;
40
+ static textToBlob(content: string, type: string, charset: BlobTextEncoding, bom: boolean): Blob;
41
+ static textToBlob(content: string, type: string, charset: BlobTextEncoding, bom: boolean, lossyChar: number): Blob;
42
+ }
43
+
44
+ declare type BlobTextEncoding = 'utf-8' | 'utf-16' | 'utf-16be' | 'utf-16le' | 'iso-8859-1' | 'ascii';
45
+
46
+ export declare interface CieXYZ {
47
+ readonly x: number;
48
+ readonly y: number;
49
+ readonly z: number;
50
+ a?: number;
51
+ }
52
+
53
+ export declare class Colors {
54
+ static WCAG_MINIMUM_CONTRAST: number;
55
+ static WCAG_NORMAL_TEXT_CONTRAST: number;
56
+ static WCAG_SAFE_CONTRAST: number;
57
+ private static _clampRGB;
58
+ private static _normalize;
59
+ static parse(clr: string): Rgba;
60
+ static hsl(rgb: Rgba): Hsla;
61
+ static cieXYZ(rgb: Rgba): CieXYZ;
62
+ static cieXYZ(hsl: Hsla): CieXYZ;
63
+ static rgb(hsl: Hsla): Rgba;
64
+ static rgb(cieXYZ: CieXYZ): Rgba;
65
+ static stringify(hsl: Hsla, precision?: number): string;
66
+ static stringify(rgb: Rgba, hex?: boolean): string;
67
+ /**
68
+ * Contrast ratio betwen two colors (useful for accessibility assessments). Output range: 1 (no-contrast) to 21 (maximum contrast)
69
+ */
70
+ static contrastRatio(clr1: Rgba | Hsla, clr2: Rgba | Hsla): number;
71
+ /**
72
+ * Returns the relative luminance as of WCAG specs.
73
+ */
74
+ static luminance(clr: Rgba | Hsla): number;
75
+ static lighten(rgb: Rgba, amount?: number): Rgba;
76
+ static lighten(rgb: Hsla, amount?: number): Hsla;
77
+ static darken(rgb: Rgba, amount?: number): Rgba;
78
+ static darken(rgb: Hsla, amount?: number): Hsla;
79
+ static saturate(rgb: Rgba, amount?: number): Rgba;
80
+ static saturate(rgb: Hsla, amount?: number): Hsla;
81
+ static desaturate(rgb: Rgba, amount?: number): Rgba;
82
+ static desaturate(rgb: Hsla, amount?: number): Hsla;
83
+ static interpolate(rgb1: Rgba, rgb2: Rgba, weight1?: number, weight2?: number): Rgba;
84
+ static interpolate(hsl1: Hsla, hsl2: Hsla, weight1?: number, weight2?: number): Hsla;
85
+ static interpolate(cieXYZ1: CieXYZ, cieXYZ2: CieXYZ, weight1?: number, weight2?: number): CieXYZ;
86
+ }
87
+
88
+ export declare namespace Compile {
89
+ export {
90
+ Markdown,
91
+ Rule,
92
+ Token,
93
+ Lexer,
94
+ Renderer,
95
+ Parser
96
+ }
97
+ }
98
+
99
+ declare namespace Compile_2 {
100
+ export {
101
+ Rule,
102
+ Token,
103
+ Lexer,
104
+ Renderer,
105
+ Parser
106
+ }
107
+ }
108
+
109
+ export declare class Dates {
110
+ static parse(input: string | Date | number): Date;
111
+ static isLeapYear(year: number): boolean;
112
+ static daysInMonth(year: number, month: number): number;
113
+ /**
114
+ * Gets whether a date is an `Invalid Date` or not.
115
+ * @param date
116
+ */
117
+ static isDate(date: any): date is Date;
118
+ /**
119
+ * Returns the date-only equaivalent of a provided datetime.
120
+ * @param datetime
121
+ */
122
+ static dateOnly(datetime: Date): Date;
123
+ static addMonths(input: Date, value: number): Date;
124
+ static addDays(input: Date, value: number): Date;
125
+ static daysBetween(start: Date, end: Date): number;
126
+ }
127
+
128
+ export declare class DeepMerger {
129
+ private constructor();
130
+ static merge<S extends PlainObject, T extends PlainObject>(source: S, target?: T): T & S;
131
+ }
132
+
133
+ export declare function detect(userAgent?: string): {
134
+ name: string;
135
+ version: any;
136
+ };
137
+
138
+ export declare type DiffMode = 'char' | 'word' | 'line';
139
+
140
+ export declare type DiffToken = {
141
+ type: DiffTokenType;
142
+ value: string;
143
+ };
144
+
145
+ export declare type DiffTokenType = '=' | '-' | '+';
146
+
147
+ declare type ExtraRule = (Compile_2.Rule | {
148
+ rule: Compile_2.Rule;
149
+ type: 'block' | 'inline';
150
+ } | {
151
+ rule: Compile_2.Rule;
152
+ type: 'code';
153
+ lang: string;
154
+ });
155
+
156
+ /** Grants undo/redo functionalities for given state. */
157
+ export declare class HistoryService<TState = any> {
158
+ #private;
159
+ constructor(state: TState, maxlength?: number);
160
+ /**
161
+ * Gets the current state.
162
+ */
163
+ get current(): TState;
164
+ get canUndo(): boolean;
165
+ get canRedo(): boolean;
166
+ /** Sets the maximum number of stored states, queue + stack.
167
+ */
168
+ set maxlength(v: number);
169
+ undo(): void;
170
+ redo(): void;
171
+ push(state: TState): void;
172
+ reset(): void;
173
+ }
174
+
175
+ export declare interface Hsla {
176
+ readonly h: number;
177
+ readonly s: number;
178
+ readonly l: number;
179
+ a?: number;
180
+ }
181
+
182
+ export declare class Imaging {
183
+ static loadImage(url: string): Promise<Blob>;
184
+ static resizeImage(img: Blob, width: number, height: number, options?: ImagingResizeOptions): Promise<Blob>;
185
+ static resizeImage(img: string, width: number, height: number, options?: ImagingResizeOptions): Promise<Blob>;
186
+ }
187
+
188
+ export declare type ImagingResizeOptions = {
189
+ mode?: 'contain' | 'cover' | 'stretch';
190
+ align?: 'left' | 'center' | 'right';
191
+ valign?: 'top' | 'middle' | 'bottom';
192
+ quality?: number;
193
+ type?: string;
194
+ background?: string;
195
+ };
196
+
197
+ export declare class Keys {
198
+ #private;
199
+ static uniqueId(): number;
200
+ static uniqueCode(): string;
201
+ static randomString(length: number): string;
202
+ }
203
+
204
+ declare interface Lexer {
205
+ tokenize(input: string, grammar: Rule[]): Token[];
206
+ }
207
+
208
+ export declare namespace Markdown {
209
+ export {
210
+ ExtraRule,
211
+ Parser_2 as Parser
212
+ }
213
+ }
214
+
215
+ /** Represents the typical matrix for 2D graphics (css, svg, ...) */
216
+ export declare interface Matrix2D {
217
+ readonly a: number;
218
+ readonly b: number;
219
+ readonly c: number;
220
+ readonly d: number;
221
+ readonly e: number;
222
+ readonly f: number;
223
+ }
224
+
225
+ export declare class Matrix2D {
226
+ static isIdentity(m: Matrix2D): boolean;
227
+ static get identity(): Matrix2D;
228
+ static copy(m: Matrix2D): Matrix2D;
229
+ static scale(m: Matrix2D, s: number): Matrix2D;
230
+ static scale(m: Matrix2D, sx: number, sy: number): Matrix2D;
231
+ static translate(m: Matrix2D, t: Point): Matrix2D;
232
+ static rotate(m: Matrix2D, rad: number): Matrix2D;
233
+ static multiply(m: Matrix2D, f: number): Matrix2D;
234
+ static multiply(p: Point, m: Matrix2D): Point;
235
+ static multiply(m1: Matrix2D, m2: Matrix2D): Matrix2D;
236
+ static det(m: Matrix2D): number;
237
+ static invert(m: Matrix2D): Matrix2D;
238
+ static toComponents(m: Matrix2D, transformOrigin?: Point): {
239
+ scaleX: number;
240
+ scaleY: number;
241
+ rotation: number;
242
+ translation: Point;
243
+ };
244
+ /**
245
+ * Returns the matrix that transforms the triangle defined by the points p0, p1, p2 into the triangle defined by the points q0, q1, q2.
246
+ * @param param0 Triangle defined by the points p0, p1, p2 (before transformation).
247
+ * @param param1 Triangle defined by the points q0, q1, q2 (after transformation).
248
+ * @returns Transformation matrix.
249
+ */
250
+ static fromTransform([p0, p1, p2]: [Point, Point, Point], [q0, q1, q2]: [Point, Point, Point]): Matrix2D;
251
+ /**
252
+ * Returns whether two matrices are equal to each other, within a certain precision (number of decimal digits).
253
+ * @param m1
254
+ * @param m2
255
+ * @param precision
256
+ * @returns
257
+ */
258
+ static areClose(m1: Matrix2D, m2: Matrix2D, precision?: number): boolean;
259
+ }
260
+
261
+ export declare class NullChecker {
262
+ static isNull(o: any): o is null | undefined;
263
+ static isEmpty(o: any): boolean;
264
+ static isNullOrEmpty(o: any): boolean;
265
+ }
266
+
267
+ export declare class Numbers {
268
+ static round(x: number, step?: number): number;
269
+ static log(x: number, base: number): number;
270
+ static rebase(v: number | string, from: number, to: number): string;
271
+ }
272
+
273
+ export declare function parseAsNumericalArray(input: string): number[];
274
+
275
+ declare class Parser {
276
+ private _lexer;
277
+ constructor(_lexer?: Lexer);
278
+ parse(input: string, grammar: Rule[], renderer: Renderer): string;
279
+ }
280
+
281
+ declare class Parser_2 extends Compile_2.Parser {
282
+ toHtml(input: string, extraGrammar?: ExtraRule[], extraItemRenderer?: (token: Compile_2.Token, allTokens: Compile_2.Token[]) => string): string;
283
+ tokenize(input: string, extraGrammar?: ExtraRule[]): any[];
284
+ parse(input: string): string;
285
+ parse(input: string, renderer: Compile_2.Renderer): string;
286
+ parse(input: string, grammar: Compile_2.Rule[]): string;
287
+ parse(input: string, grammar: Compile_2.Rule[], renderer: Compile_2.Renderer): string;
288
+ }
289
+
290
+ declare type PlainObject = Record<string, unknown>;
291
+
292
+ export declare interface Point {
293
+ x: number;
294
+ y: number;
295
+ }
296
+
297
+ export declare class Point {
298
+ static parse(pt: string): Point;
299
+ static isPoint(obj: any): obj is Point;
300
+ /**
301
+ * Computes the distance between two points.
302
+ * @param p1 Point 1
303
+ * @param p2 Point 2
304
+ */
305
+ static distance(p1: Point, p2: Point): number;
306
+ /**
307
+ * Subtracts a point p from another and returns the resulting vector.
308
+ * @param p Point to subtract
309
+ * @param from Point to be subtracted from
310
+ */
311
+ static subtract(p: Point, from: Point): Point;
312
+ /**
313
+ * Adds a set of points together and returns the resulting vector.
314
+ * @param points Points to add
315
+ */
316
+ static add(...points: Point[]): Point;
317
+ /**
318
+ * Memberwise multiplication.
319
+ * @param p Original Point object
320
+ * @param f Factor
321
+ * @returns New Point object.
322
+ */
323
+ static multiply(p: Point, f: number): Point;
324
+ }
325
+
326
+ export declare interface Rect extends Point, Size {
327
+ }
328
+
329
+ export declare class Rect {
330
+ static parse(rect: string): Rect;
331
+ static isRect(obj: any): obj is Rect;
332
+ private static _stretch;
333
+ private static _contain;
334
+ private static _cover;
335
+ private static _align;
336
+ /**
337
+ * Computes the 2D matrix that transforms one rect into another.
338
+ * @param a Rect from
339
+ * @param b Rect to
340
+ * @param mode Transformation mode
341
+ * @param align Horizontal alignment
342
+ * @param valign Vertical alignment
343
+ */
344
+ static findTransform(a: Rect, b: Rect, mode?: 'contain' | 'cover' | 'stretch', align?: 'left' | 'center' | 'right', valign?: 'top' | 'middle' | 'bottom'): Matrix2D;
345
+ /**
346
+ * Computes the intersection rect among a set of provided rects.
347
+ * @param rects Rects to intersect
348
+ */
349
+ static intersect(...rects: Rect[]): Rect;
350
+ /**
351
+ * Returns the minimum rect that contains all the provided points.
352
+ * @param points Points to contain
353
+ */
354
+ static expand(...points: Point[]): Rect;
355
+ /**
356
+ * Returns the minimum rect that contains all the provided points.
357
+ * @param rect Starting rect
358
+ * @param points Points to contain
359
+ */
360
+ static expand(rect: Rect, ...points: Point[]): Rect;
361
+ }
362
+
363
+ declare interface Renderer {
364
+ render: (tree: Token[]) => string;
365
+ }
366
+
367
+ export declare interface Rgba {
368
+ readonly r: number;
369
+ readonly g: number;
370
+ readonly b: number;
371
+ a?: number;
372
+ }
373
+
374
+ declare interface Rule {
375
+ exec: (input: string, lexer?: Lexer) => Token[];
376
+ }
377
+
378
+ export declare interface Size {
379
+ width: number;
380
+ height: number;
381
+ }
382
+
383
+ export declare class Size {
384
+ static parse(sz: string): Size;
385
+ static isSize(obj: any): obj is Size;
386
+ }
387
+
388
+ export declare class Strings {
389
+ /** @deprecated Use String.prototype.padStart() instead. */
390
+ static leftPad(v: any, targetLength: number, padChar: string): string;
391
+ static format(template: string, ...args: any[]): string;
392
+ static diff(a: string, b: string, mode?: DiffMode): DiffToken[];
393
+ static hash(input: string, algo?: HashAlgorithmIdentifier): Promise<string>;
394
+ }
395
+
396
+ declare interface Token {
397
+ readonly index?: number;
398
+ readonly type: string;
399
+ readonly raw: string;
400
+ readonly text: string;
401
+ readonly tokens?: Token[];
402
+ }
403
+
404
+ declare global {
405
+ interface Number {
406
+ isCloseTo(other: number, precision?: number): boolean;
407
+ roundoff(precision?: number): number;
408
+ clamp(min: number, max: number): any;
409
+ toBase62(): string;
410
+ toBase36(): string;
411
+ }
412
+ }
413
+
414
+ declare global {
415
+ interface Array<T> {
416
+ moveWithin(from: number, to: number): void;
417
+ /** Checks content equality between arrays. */
418
+ equalsContent(other: T[]): boolean;
419
+ cloneFrom(other: T[]): void;
420
+ union(other: T[]): T[];
421
+ distinct(): T[];
422
+ }
423
+ }
424
+
425
+
426
+ declare global {
427
+ namespace Pacem {
428
+ export {
429
+ Angle,
430
+ Arrays,
431
+ Blobs,
432
+ CieXYZ,
433
+ Colors,
434
+ Compile,
435
+ Dates,
436
+ DeepMerger,
437
+ detect,
438
+ DiffMode,
439
+ DiffToken,
440
+ DiffTokenType,
441
+ HistoryService,
442
+ Hsla,
443
+ Imaging,
444
+ ImagingResizeOptions,
445
+ Keys,
446
+ Markdown,
447
+ Matrix2D,
448
+ NullChecker,
449
+ Numbers,
450
+ parseAsNumericalArray,
451
+ Point,
452
+ Rect,
453
+ Rgba,
454
+ Size,
455
+ Strings
456
+ };
457
+ }
458
+ }