@absoluteui/helpers 0.0.0-stage → 0.13.2
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 +201 -0
- package/NOTICE +5 -0
- package/README.md +47 -2
- package/SECURITY.md +102 -0
- package/dist/array/compare.d.ts +8 -0
- package/dist/array/compare.js +2 -0
- package/dist/array/index.d.ts +328 -0
- package/dist/array/index.js +2 -0
- package/dist/array/tree.d.ts +48 -0
- package/dist/array/tree.js +2 -0
- package/dist/async/batch.d.ts +103 -0
- package/dist/async/batch.js +2 -0
- package/dist/async/concurrency.d.ts +92 -0
- package/dist/async/concurrency.js +2 -0
- package/dist/async/control.d.ts +77 -0
- package/dist/async/control.js +2 -0
- package/dist/async/index.d.ts +8 -0
- package/dist/async/index.js +2 -0
- package/dist/async/signal.d.ts +95 -0
- package/dist/async/signal.js +2 -0
- package/dist/boolean/index.d.ts +83 -0
- package/dist/boolean/index.js +2 -0
- package/dist/business-calendar/days.d.ts +397 -0
- package/dist/business-calendar/days.js +2 -0
- package/dist/business-calendar/describe.d.ts +45 -0
- package/dist/business-calendar/describe.js +2 -0
- package/dist/business-calendar/engine.d.ts +305 -0
- package/dist/business-calendar/engine.js +2 -0
- package/dist/business-calendar/hours.d.ts +96 -0
- package/dist/business-calendar/hours.js +2 -0
- package/dist/business-calendar/index.d.ts +29 -0
- package/dist/business-calendar/index.js +2 -0
- package/dist/business-calendar/internal.d.ts +44 -0
- package/dist/business-calendar/internal.js +2 -0
- package/dist/business-calendar/rules.d.ts +260 -0
- package/dist/business-calendar/rules.js +2 -0
- package/dist/color/index.d.ts +200 -0
- package/dist/color/index.js +2 -0
- package/dist/color/named.d.ts +4 -0
- package/dist/color/named.js +2 -0
- package/dist/compare/index.d.ts +186 -0
- package/dist/compare/index.js +2 -0
- package/dist/convert/index.d.ts +152 -0
- package/dist/convert/index.js +2 -0
- package/dist/csv/index.d.ts +6 -0
- package/dist/csv/index.js +2 -0
- package/dist/csv/parse.d.ts +85 -0
- package/dist/csv/parse.js +12 -0
- package/dist/csv/stringify.d.ts +48 -0
- package/dist/csv/stringify.js +5 -0
- package/dist/date/calendar.d.ts +339 -0
- package/dist/date/calendar.js +2 -0
- package/dist/date/format.d.ts +66 -0
- package/dist/date/format.js +2 -0
- package/dist/date/index.d.ts +26 -0
- package/dist/date/index.js +2 -0
- package/dist/date/intervals.d.ts +110 -0
- package/dist/date/intervals.js +2 -0
- package/dist/date/intl-cache.d.ts +10 -0
- package/dist/date/intl-cache.js +2 -0
- package/dist/date/locale.d.ts +58 -0
- package/dist/date/locale.js +2 -0
- package/dist/date/plain-date.d.ts +105 -0
- package/dist/date/plain-date.js +2 -0
- package/dist/date/plain-time.d.ts +121 -0
- package/dist/date/plain-time.js +2 -0
- package/dist/date/zone.d.ts +121 -0
- package/dist/date/zone.js +2 -0
- package/dist/decimal/index.d.ts +149 -0
- package/dist/decimal/index.js +2 -0
- package/dist/ds/avl.d.ts +50 -0
- package/dist/ds/avl.js +2 -0
- package/dist/ds/bitset.d.ts +46 -0
- package/dist/ds/bitset.js +2 -0
- package/dist/ds/bloom.d.ts +41 -0
- package/dist/ds/bloom.js +2 -0
- package/dist/ds/caches.d.ts +141 -0
- package/dist/ds/caches.js +2 -0
- package/dist/ds/disjoint-set.d.ts +38 -0
- package/dist/ds/disjoint-set.js +2 -0
- package/dist/ds/emitter.d.ts +53 -0
- package/dist/ds/emitter.js +2 -0
- package/dist/ds/graph.d.ts +84 -0
- package/dist/ds/graph.js +2 -0
- package/dist/ds/heap.d.ts +49 -0
- package/dist/ds/heap.js +2 -0
- package/dist/ds/index.d.ts +20 -0
- package/dist/ds/index.js +2 -0
- package/dist/ds/internal.d.ts +19 -0
- package/dist/ds/internal.js +2 -0
- package/dist/ds/interval-tree.d.ts +49 -0
- package/dist/ds/interval-tree.js +2 -0
- package/dist/ds/linked-list.d.ts +54 -0
- package/dist/ds/linked-list.js +2 -0
- package/dist/ds/maps.d.ts +89 -0
- package/dist/ds/maps.js +2 -0
- package/dist/ds/ring.d.ts +99 -0
- package/dist/ds/ring.js +2 -0
- package/dist/ds/sorted.d.ts +104 -0
- package/dist/ds/sorted.js +2 -0
- package/dist/ds/stack.d.ts +28 -0
- package/dist/ds/stack.js +2 -0
- package/dist/ds/trie.d.ts +84 -0
- package/dist/ds/trie.js +2 -0
- package/dist/duration/index.d.ts +146 -0
- package/dist/duration/index.js +2 -0
- package/dist/encoding/index.d.ts +144 -0
- package/dist/encoding/index.js +2 -0
- package/dist/error/index.d.ts +316 -0
- package/dist/error/index.js +2 -0
- package/dist/fn/index.d.ts +129 -0
- package/dist/fn/index.js +2 -0
- package/dist/fn/memo.d.ts +46 -0
- package/dist/fn/memo.js +2 -0
- package/dist/fn/timing.d.ts +64 -0
- package/dist/fn/timing.js +2 -0
- package/dist/http/headers.d.ts +160 -0
- package/dist/http/headers.js +2 -0
- package/dist/http/index.d.ts +10 -0
- package/dist/http/index.js +2 -0
- package/dist/http/problem.d.ts +37 -0
- package/dist/http/problem.js +2 -0
- package/dist/http/response.d.ts +43 -0
- package/dist/http/response.js +2 -0
- package/dist/http/status.d.ts +169 -0
- package/dist/http/status.js +2 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +2 -0
- package/dist/internal/keys.d.ts +6 -0
- package/dist/internal/keys.js +2 -0
- package/dist/is/index.d.ts +219 -0
- package/dist/is/index.js +2 -0
- package/dist/json/index.d.ts +9 -0
- package/dist/json/index.js +2 -0
- package/dist/json/internal.d.ts +12 -0
- package/dist/json/internal.js +2 -0
- package/dist/json/ndjson.d.ts +28 -0
- package/dist/json/ndjson.js +4 -0
- package/dist/json/parse.d.ts +45 -0
- package/dist/json/parse.js +2 -0
- package/dist/json/patch.d.ts +62 -0
- package/dist/json/patch.js +2 -0
- package/dist/json/pointer.d.ts +43 -0
- package/dist/json/pointer.js +2 -0
- package/dist/json/stringify.d.ts +42 -0
- package/dist/json/stringify.js +2 -0
- package/dist/linq/enumerable.d.ts +208 -0
- package/dist/linq/enumerable.js +2 -0
- package/dist/linq/index.d.ts +6 -0
- package/dist/linq/index.js +2 -0
- package/dist/linq/operators.d.ts +503 -0
- package/dist/linq/operators.js +2 -0
- package/dist/number/core.d.ts +164 -0
- package/dist/number/core.js +2 -0
- package/dist/number/format.d.ts +80 -0
- package/dist/number/format.js +2 -0
- package/dist/number/index.d.ts +12 -0
- package/dist/number/index.js +2 -0
- package/dist/number/internal.d.ts +18 -0
- package/dist/number/internal.js +2 -0
- package/dist/number/parse.d.ts +45 -0
- package/dist/number/parse.js +2 -0
- package/dist/number/words.d.ts +19 -0
- package/dist/number/words.js +2 -0
- package/dist/object/basic.d.ts +130 -0
- package/dist/object/basic.js +2 -0
- package/dist/object/deep.d.ts +90 -0
- package/dist/object/deep.js +2 -0
- package/dist/object/diff.d.ts +57 -0
- package/dist/object/diff.js +2 -0
- package/dist/object/index.d.ts +8 -0
- package/dist/object/index.js +2 -0
- package/dist/object/internal.d.ts +21 -0
- package/dist/object/internal.js +2 -0
- package/dist/object/path.d.ts +17 -0
- package/dist/object/path.js +2 -0
- package/dist/random/core.d.ts +14 -0
- package/dist/random/core.js +2 -0
- package/dist/random/index.d.ts +167 -0
- package/dist/random/index.js +2 -0
- package/dist/random/seeded.d.ts +27 -0
- package/dist/random/seeded.js +2 -0
- package/dist/sanitize/index.d.ts +8 -0
- package/dist/sanitize/index.js +2 -0
- package/dist/sanitize/pii.d.ts +48 -0
- package/dist/sanitize/pii.js +2 -0
- package/dist/sanitize/records.d.ts +100 -0
- package/dist/sanitize/records.js +2 -0
- package/dist/sanitize/text.d.ts +101 -0
- package/dist/sanitize/text.js +2 -0
- package/dist/set/index.d.ts +162 -0
- package/dist/set/index.js +2 -0
- package/dist/stats/index.d.ts +190 -0
- package/dist/stats/index.js +2 -0
- package/dist/string/index.d.ts +494 -0
- package/dist/string/index.js +8 -0
- package/dist/string/internal.d.ts +33 -0
- package/dist/string/internal.js +2 -0
- package/dist/string/words.d.ts +14 -0
- package/dist/string/words.js +2 -0
- package/dist/timezone/index.d.ts +76 -0
- package/dist/timezone/index.js +2 -0
- package/dist/url/index.d.ts +178 -0
- package/dist/url/index.js +2 -0
- package/dist/validate/builders.d.ts +6 -0
- package/dist/validate/builders.js +2 -0
- package/dist/validate/formats.d.ts +237 -0
- package/dist/validate/formats.js +2 -0
- package/dist/validate/index.d.ts +13 -0
- package/dist/validate/index.js +2 -0
- package/dist/validate/schema.d.ts +220 -0
- package/dist/validate/schema.js +2 -0
- package/dist/zip/index.d.ts +8 -0
- package/dist/zip/index.js +2 -0
- package/dist/zip/internal.d.ts +69 -0
- package/dist/zip/internal.js +2 -0
- package/dist/zip/reader.d.ts +56 -0
- package/dist/zip/reader.js +2 -0
- package/dist/zip/writer.d.ts +65 -0
- package/dist/zip/writer.js +2 -0
- package/package.json +150 -4
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Small composable schema validator (docs/PLAN-HELPERS.md section 2, section 5, section 6). Not a full schema
|
|
3
|
+
* library: builders are plain functions (tree-shakeable), output objects are freshly built and
|
|
4
|
+
* never receive `__proto__`/`constructor`/`prototype` keys, depth and size are bounded, and
|
|
5
|
+
* failures map field paths (`address.zip`, `items[2].qty`) to actionable, localizable messages.
|
|
6
|
+
*/
|
|
7
|
+
import { ValidationError, type Result } from '../error/index.js';
|
|
8
|
+
import { type DateInput, type PlainDate } from '../date/plain-date.js';
|
|
9
|
+
import { type EmailOptions, type UrlOptions } from './formats.js';
|
|
10
|
+
/** One validation failure. `params` hold schema-defined values (limits, options), never input. */
|
|
11
|
+
export interface Issue {
|
|
12
|
+
/** Field path: `''` for the root, `address.zip`, `items[2].qty`. */
|
|
13
|
+
readonly path: string;
|
|
14
|
+
/** Message code, for example `string.min`, resolved through the message catalog. */
|
|
15
|
+
readonly code: string;
|
|
16
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
17
|
+
}
|
|
18
|
+
/** Internal traversal state (exported for declaration output only). */
|
|
19
|
+
export interface ParseContext {
|
|
20
|
+
readonly issues: Issue[];
|
|
21
|
+
depth: number;
|
|
22
|
+
nodes: number;
|
|
23
|
+
stopped: boolean;
|
|
24
|
+
readonly maxDepth: number;
|
|
25
|
+
readonly maxNodes: number;
|
|
26
|
+
readonly maxIssues: number;
|
|
27
|
+
readonly maxStringLength: number;
|
|
28
|
+
}
|
|
29
|
+
/** Internal parse outcome. */
|
|
30
|
+
export type Outcome<T> = {
|
|
31
|
+
readonly ok: true;
|
|
32
|
+
readonly value: T;
|
|
33
|
+
} | {
|
|
34
|
+
readonly ok: false;
|
|
35
|
+
};
|
|
36
|
+
/** A validator for values of type `T`. Build with the `v.*` functions. */
|
|
37
|
+
export interface Schema<T> {
|
|
38
|
+
readonly kind: string;
|
|
39
|
+
/** True for `v.optional(...)`: the property may be absent from an object. */
|
|
40
|
+
readonly optional: boolean;
|
|
41
|
+
/** @internal Runs the check; prefer {@link validate}. */
|
|
42
|
+
readonly run: (input: unknown, ctx: ParseContext, path: string) => Outcome<T>;
|
|
43
|
+
}
|
|
44
|
+
/** Schema produced by `v.optional`. */
|
|
45
|
+
export interface OptionalSchema<T> extends Schema<T | undefined> {
|
|
46
|
+
readonly optional: true;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Output type of a schema.
|
|
50
|
+
* @example
|
|
51
|
+
* const userSchema = v.object({ email: v.string({ email: true }), age: v.optional(v.number()) });
|
|
52
|
+
* type User = Infer<typeof userSchema>; // { email: string; age?: number | undefined }
|
|
53
|
+
*/
|
|
54
|
+
export type Infer<S> = S extends Schema<infer T> ? T : never;
|
|
55
|
+
type Shape = Readonly<Record<string, Schema<unknown>>>;
|
|
56
|
+
type OptionalKeys<S extends Shape> = {
|
|
57
|
+
[K in keyof S]: S[K] extends {
|
|
58
|
+
readonly optional: true;
|
|
59
|
+
} ? K : never;
|
|
60
|
+
}[keyof S];
|
|
61
|
+
type Simplify<T> = {
|
|
62
|
+
[K in keyof T]: T[K];
|
|
63
|
+
} & {};
|
|
64
|
+
/** Object type inferred from a shape; `v.optional` properties become optional. */
|
|
65
|
+
export type InferShape<S extends Shape> = Simplify<{
|
|
66
|
+
-readonly [K in Exclude<keyof S, OptionalKeys<S>>]: Infer<S[K]>;
|
|
67
|
+
} & {
|
|
68
|
+
-readonly [K in OptionalKeys<S>]?: Infer<S[K]>;
|
|
69
|
+
}>;
|
|
70
|
+
export interface StringOptions {
|
|
71
|
+
/** Minimum length in code points. `min >= 1` reports an empty value as `required`. */
|
|
72
|
+
readonly min?: number;
|
|
73
|
+
/** Maximum length in code points. */
|
|
74
|
+
readonly max?: number;
|
|
75
|
+
/** Pattern the value must match (`g`/`y` flags are ignored). Keep it linear-time. */
|
|
76
|
+
readonly pattern?: RegExp;
|
|
77
|
+
/** Message code for a pattern mismatch. Default `string.pattern`. */
|
|
78
|
+
readonly patternCode?: string;
|
|
79
|
+
/** Trim before checking; the output is trimmed. Default false. */
|
|
80
|
+
readonly trim?: boolean;
|
|
81
|
+
/** Lowercase the output. Default false. */
|
|
82
|
+
readonly lowercase?: boolean;
|
|
83
|
+
/** Require an e-mail address ({@link isEmail}). */
|
|
84
|
+
readonly email?: boolean | EmailOptions;
|
|
85
|
+
/** Require an absolute URL ({@link isUrl}; http/https by default). */
|
|
86
|
+
readonly url?: boolean | UrlOptions;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* String schema.
|
|
90
|
+
* @example string({ min: 1, max: 80, trim: true })
|
|
91
|
+
*/
|
|
92
|
+
export declare function string(options?: StringOptions): Schema<string>;
|
|
93
|
+
export interface NumberOptions {
|
|
94
|
+
readonly min?: number;
|
|
95
|
+
readonly max?: number;
|
|
96
|
+
/** Require a safe integer. */
|
|
97
|
+
readonly integer?: boolean;
|
|
98
|
+
/** Accept numeric strings (trimmed, plain decimal) such as form input. Default false. */
|
|
99
|
+
readonly coerce?: boolean;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Finite number schema (`NaN` and infinities are rejected).
|
|
103
|
+
* @example number({ min: 0, integer: true })
|
|
104
|
+
*/
|
|
105
|
+
export declare function number(options?: NumberOptions): Schema<number>;
|
|
106
|
+
/**
|
|
107
|
+
* Boolean schema. With `coerce`, accepts `'true'/'false'`, `'on'/'off'`, `'yes'/'no'`, `'1'/'0'`.
|
|
108
|
+
* @example boolean({ coerce: true })
|
|
109
|
+
*/
|
|
110
|
+
export declare function boolean(options?: {
|
|
111
|
+
readonly coerce?: boolean;
|
|
112
|
+
}): Schema<boolean>;
|
|
113
|
+
export interface DateOptions {
|
|
114
|
+
/** Earliest allowed date (inclusive). */
|
|
115
|
+
readonly min?: DateInput;
|
|
116
|
+
/** Latest allowed date (inclusive). */
|
|
117
|
+
readonly max?: DateInput;
|
|
118
|
+
/** Time zone used to take the calendar date of a `Date` input. Default: runtime zone. */
|
|
119
|
+
readonly timeZone?: string;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Date-only schema producing a `PlainDate`. Accepts `'YYYY-MM-DD'`, a `PlainDate`, or a valid
|
|
123
|
+
* `Date` (its calendar date in `timeZone`).
|
|
124
|
+
* @example date({ min: '2000-01-01' })
|
|
125
|
+
*/
|
|
126
|
+
export declare function date(options?: DateOptions): Schema<PlainDate>;
|
|
127
|
+
/**
|
|
128
|
+
* Exactly one primitive value.
|
|
129
|
+
* @example literal('admin')
|
|
130
|
+
*/
|
|
131
|
+
export declare function literal<const T extends string | number | boolean | null>(value: T): Schema<T>;
|
|
132
|
+
/**
|
|
133
|
+
* One of a fixed list of strings or numbers.
|
|
134
|
+
* @example enumOf(['draft', 'published'] as const)
|
|
135
|
+
*/
|
|
136
|
+
export declare function enumOf<const T extends readonly (string | number)[]>(values: T): Schema<T[number]>;
|
|
137
|
+
/**
|
|
138
|
+
* Array schema; every item is validated and reported with its index.
|
|
139
|
+
* @example array(string(), { min: 1, max: 10 })
|
|
140
|
+
*/
|
|
141
|
+
export declare function array<T>(item: Schema<T>, options?: {
|
|
142
|
+
readonly min?: number;
|
|
143
|
+
readonly max?: number;
|
|
144
|
+
}): Schema<T[]>;
|
|
145
|
+
export interface ObjectOptions {
|
|
146
|
+
/**
|
|
147
|
+
* Keys not in the shape: `'strip'` (default) drops them, `'error'` reports each, `'keep'`
|
|
148
|
+
* copies them. `__proto__`, `constructor` and `prototype` are always rejected.
|
|
149
|
+
*/
|
|
150
|
+
readonly unknownKeys?: 'strip' | 'error' | 'keep';
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Object schema. Accepts plain objects only and builds a fresh output object.
|
|
154
|
+
* @example object({ name: string({ min: 1 }), age: optional(number({ integer: true })) })
|
|
155
|
+
*/
|
|
156
|
+
export declare function object<const S extends Shape>(shape: S, options?: ObjectOptions): Schema<InferShape<S>>;
|
|
157
|
+
/**
|
|
158
|
+
* Allows `undefined` (and a missing object property).
|
|
159
|
+
* @example optional(string())
|
|
160
|
+
*/
|
|
161
|
+
export declare function optional<T>(schema: Schema<T>): OptionalSchema<T>;
|
|
162
|
+
/**
|
|
163
|
+
* Allows `null`.
|
|
164
|
+
* @example nullable(date())
|
|
165
|
+
*/
|
|
166
|
+
export declare function nullable<T>(schema: Schema<T>): Schema<T | null>;
|
|
167
|
+
/**
|
|
168
|
+
* First matching schema wins. If none match, one `union` issue is reported at the path.
|
|
169
|
+
* @example union(literal('auto'), number({ min: 0 }))
|
|
170
|
+
*/
|
|
171
|
+
export declare function union<const S extends readonly Schema<unknown>[]>(...schemas: S): Schema<Infer<S[number]>>;
|
|
172
|
+
/**
|
|
173
|
+
* Adds a custom rule; runs only when the base schema passed. A throwing predicate counts as
|
|
174
|
+
* a failure.
|
|
175
|
+
* @example refine(string(), (s) => s !== 'admin', 'username.reserved')
|
|
176
|
+
*/
|
|
177
|
+
export declare function refine<T>(schema: Schema<T>, predicate: (value: T) => boolean, code?: string, params?: Readonly<Record<string, unknown>>): Schema<T>;
|
|
178
|
+
/**
|
|
179
|
+
* Maps the validated value. A throwing mapper reports `invalid` at the path.
|
|
180
|
+
* @example transform(string({ trim: true }), (s) => s.split(','))
|
|
181
|
+
*/
|
|
182
|
+
export declare function transform<T, U>(schema: Schema<T>, fn: (value: T) => U): Schema<U>;
|
|
183
|
+
/** Resolves a message code to text. Replace it to localize. */
|
|
184
|
+
export type MessageCatalog = (code: string, params: Readonly<Record<string, unknown>>) => string;
|
|
185
|
+
/**
|
|
186
|
+
* English default catalog. Unknown codes get a generic, still actionable message.
|
|
187
|
+
* @example defaultMessages('string.min', { min: 3 }) // => 'Enter at least 3 characters.'
|
|
188
|
+
*/
|
|
189
|
+
export declare const defaultMessages: MessageCatalog;
|
|
190
|
+
export interface ValidateOptions {
|
|
191
|
+
/** Message catalog; defaults to {@link defaultMessages}. */
|
|
192
|
+
readonly messages?: MessageCatalog;
|
|
193
|
+
/** Maximum object/array nesting. Default 32. */
|
|
194
|
+
readonly maxDepth?: number;
|
|
195
|
+
/** Maximum number of values visited. Default 100 000. */
|
|
196
|
+
readonly maxNodes?: number;
|
|
197
|
+
/** Stop after this many issues. Default 100. */
|
|
198
|
+
readonly maxIssues?: number;
|
|
199
|
+
/** Maximum string length (UTF-16 units) before any check. Default 1 000 000. */
|
|
200
|
+
readonly maxStringLength?: number;
|
|
201
|
+
/** `fields` key for root-level issues. Default `'_form'`. */
|
|
202
|
+
readonly formKey?: string;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Validates `input`. On failure returns a `ValidationError` (`HLP_VALIDATE_FAILED`) whose
|
|
206
|
+
* `fields` map each path to its first message and whose `details.issues` list every issue.
|
|
207
|
+
* @example
|
|
208
|
+
* const r = validate(v.object({ email: v.string({ email: true }) }), { email: 'x' });
|
|
209
|
+
* r.ok ? {} : r.error.fields; // => { email: 'Enter an email address in the format name@example.com.' }
|
|
210
|
+
*/
|
|
211
|
+
export declare function validate<T>(schema: Schema<T>, input: unknown, options?: ValidateOptions): Result<T, ValidationError>;
|
|
212
|
+
/**
|
|
213
|
+
* Binds a message catalog (for example a localized one) to {@link validate}.
|
|
214
|
+
* @example
|
|
215
|
+
* const check = createValidator((code) => `validation.${code}`);
|
|
216
|
+
* const r = check(v.object({ name: v.string({ min: 1 }) }), { name: 42 });
|
|
217
|
+
* r.ok ? {} : r.error.fields; // => { name: 'validation.type.string' }
|
|
218
|
+
*/
|
|
219
|
+
export declare function createValidator(messages: MessageCatalog, defaults?: Omit<ValidateOptions, 'messages'>): <T>(schema: Schema<T>, input: unknown, options?: Omit<ValidateOptions, "messages">) => Result<T, ValidationError>;
|
|
220
|
+
export {};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
import{ValidationError as C,err as P,ok as D}from"../error/index.js";import{assertSafeKey as I,hasOwn as k,isUnsafeKey as R}from"../internal/keys.js";import{isPlainObject as j}from"../is/index.js";import{formatPlainDate as T,isPlainDate as K,parsePlainDate as O,plainDateFromInstant as v,toEpochDay as S,toPlainDate as w}from"../date/plain-date.js";import{isEmail as $,isUrl as N}from"./formats.js";const h=Object.freeze({ok:!1}),y=e=>({ok:!0,value:e});function i(e,n,r,o={}){return e.issues.length<e.maxIssues?e.issues.push({path:n,code:r,params:o}):e.stopped=!0,h}function z(e,n){return e.nodes++,e.nodes>e.maxNodes?(e.stopped||i(e,"","limit.size",{max:e.maxNodes}),e.stopped=!0,!1):e.depth>e.maxDepth?(i(e,n,"limit.depth",{max:e.maxDepth}),!1):!e.stopped}const q=/^[a-z_$][\w$]*$/i,x=(e,n)=>{const r=n.length>100?n.slice(0,100):n,o=q.test(r)?r:`[${JSON.stringify(r)}]`;return e===""||o.startsWith("[")?e+o:`${e}.${o}`},A=(e,n)=>`${e}[${n}]`;function b(e,n){return Object.freeze({kind:e,optional:!1,run:(r,o,a)=>z(o,a)?n(r,o,a):h})}const L=e=>{let n=0;for(let r=0;r<e.length;r++){const o=e.charCodeAt(r);(o<56320||o>57343)&&n++}return n};function G(e={}){const{min:n,max:r,trim:o=!1,lowercase:a=!1,patternCode:t="string.pattern"}=e,u=e.pattern?new RegExp(e.pattern.source,e.pattern.flags.replace(/[gy]/g,"")):void 0,s=e.email===!0?{}:e.email===!1?void 0:e.email,d=e.url===!0?{}:e.url===!1?void 0:e.url;return b("string",(m,l,c)=>{if(m==null)return i(l,c,"required");if(typeof m!="string")return i(l,c,"type.string");if(m.length>l.maxStringLength)return i(l,c,"limit.size",{max:l.maxStringLength});let f=o?m.trim():m;if(a&&(f=f.toLowerCase()),f===""&&n!==void 0&&n>0)return i(l,c,"required");const p=n!==void 0||r!==void 0?L(f):0;return n!==void 0&&p<n?i(l,c,"string.min",{min:n}):r!==void 0&&p>r?i(l,c,"string.max",{max:r}):s&&!$(f,s)?i(l,c,"string.email"):d&&!N(f,d)?i(l,c,"string.url"):u&&!u.test(f)?i(l,c,t):y(f)})}const M=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;function H(e={}){const{min:n,max:r,integer:o=!1,coerce:a=!1}=e;return b("number",(t,u,s)=>{let d=t;if(a&&typeof d=="string"){const m=d.trim();if(m==="")return i(u,s,"required");d=m.length<=400&&M.test(m)?Number(m):Number.NaN}return d==null?i(u,s,"required"):typeof d!="number"||!Number.isFinite(d)?i(u,s,"type.number"):o&&!Number.isSafeInteger(d)?i(u,s,"number.integer"):n!==void 0&&d<n?i(u,s,"number.min",{min:n}):r!==void 0&&d>r?i(u,s,"number.max",{max:r}):y(d)})}function J(e={}){const n=e.coerce===!0;return b("boolean",(r,o,a)=>{if(typeof r=="boolean")return y(r);if(n&&typeof r=="string"){const t=r.trim().toLowerCase();if(t==="true"||t==="on"||t==="yes"||t==="1")return y(!0);if(t==="false"||t==="off"||t==="no"||t==="0")return y(!1)}return r==null?i(o,a,"required"):i(o,a,"type.boolean")})}function B(e={}){const n=e.min===void 0?void 0:w(e.min),r=e.max===void 0?void 0:w(e.max),{timeZone:o}=e;return b("date",(a,t,u)=>{if(a==null||a==="")return i(t,u,"required");let s;return typeof a=="string"?s=O(a.trim()):K(a)?s=O(T(a)):a instanceof Date&&!Number.isNaN(a.getTime())&&(s=v(a,o)),s?n&&S(s)<S(n)?i(t,u,"date.min",{min:T(n)}):r&&S(s)>S(r)?i(t,u,"date.max",{max:T(r)}):y(s):i(t,u,"type.date")})}function Q(e){return b("literal",(n,r,o)=>Object.is(n,e)?y(e):n===void 0?i(r,o,"required"):i(r,o,"literal",{expected:e}))}function X(e){const n=new Set(e),r=Object.freeze([...e]);return b("enum",(o,a,t)=>n.has(o)?y(o):o==null||o===""?i(a,t,"required"):i(a,t,"enum",{options:r}))}function ee(e,n={}){const{min:r,max:o}=n;return b("array",(a,t,u)=>{if(a==null)return i(t,u,"required");if(!Array.isArray(a))return i(t,u,"type.array");if(a.length>t.maxNodes)return i(t,u,"limit.size",{max:t.maxNodes});if(r!==void 0&&a.length<r)return i(t,u,"array.min",{min:r});if(o!==void 0&&a.length>o)return i(t,u,"array.max",{max:o});const s=[];let d=!0;t.depth++;try{for(let m=0;m<a.length;m++){if(t.stopped)return h;const l=e.run(a[m],t,A(u,m));l.ok?s.push(l.value):d=!1}}finally{t.depth--}return d?y(s):h})}function ne(e,n={}){const r=n.unknownKeys??"strip",o=Object.keys(e);for(const t of o)I(t);const a=new Set(o);return b("object",(t,u,s)=>{if(t==null)return i(u,s,"required");if(!j(t))return i(u,s,"type.object");const d={};let m=!0;u.depth++;try{for(const l of o){if(u.stopped)return h;const c=e[l];if(!c)continue;const f=k(t,l),p=c.run(f?t[l]:void 0,u,x(s,l));p.ok?(f||p.value!==void 0)&&(d[l]=p.value):m=!1}for(const l of Object.keys(t))a.has(l)||(R(l)?(m=!1,i(u,x(s,l),"object.unsafeKey")):r==="error"?(m=!1,i(u,x(s,l),"object.unknownKey")):r==="keep"&&(d[l]=t[l]))}finally{u.depth--}return m?y(d):h})}function re(e){return Object.freeze({kind:"optional",optional:!0,run:(n,r,o)=>n===void 0?y(void 0):e.run(n,r,o)})}function te(e){return Object.freeze({kind:"nullable",optional:e.optional,run:(n,r,o)=>n===null?y(null):e.run(n,r,o)})}function oe(...e){return b("union",(n,r,o)=>{for(const a of e){const t={...r,issues:[],stopped:!1},u=a.run(n,t,o);if(r.nodes=t.nodes,u.ok)return u;if(t.issues.some(s=>s.code.startsWith("limit."))){for(const s of t.issues)i(r,s.path,s.code,s.params);return h}}return n==null?i(r,o,"required"):i(r,o,"union")})}function ae(e,n,r="custom",o={}){return Object.freeze({kind:e.kind,optional:e.optional,run:(a,t,u)=>{const s=e.run(a,t,u);if(!s.ok)return s;let d;try{d=n(s.value)}catch{d=!1}return d?s:i(t,u,r,o)}})}function ie(e,n){return Object.freeze({kind:e.kind,optional:e.optional,run:(r,o,a)=>{const t=e.run(r,o,a);if(!t.ok)return t;try{return y(n(t.value))}catch{return i(o,a,"invalid")}}})}const g=e=>typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):e===null?"null":"",E={required:()=>"Enter a value for this field.","type.string":()=>"Enter text.","type.number":()=>"Enter a number, for example 42 or 3.5.","type.boolean":()=>"Choose yes or no.","type.date":()=>"Enter a date in the format YYYY-MM-DD.","type.array":()=>"Provide a list of values.","type.object":()=>"Provide the details for this section.","string.min":e=>`Enter at least ${g(e.min)} characters.`,"string.max":e=>`Enter no more than ${g(e.max)} characters.`,"string.pattern":()=>"Enter a value in the required format.","string.email":()=>"Enter an email address in the format name@example.com.","string.url":()=>"Enter a web address in the format https://example.com.","number.integer":()=>"Enter a whole number without decimals.","number.min":e=>`Enter a number that is ${g(e.min)} or more.`,"number.max":e=>`Enter a number that is ${g(e.max)} or less.`,"date.min":e=>`Enter a date on or after ${g(e.min)}.`,"date.max":e=>`Enter a date on or before ${g(e.max)}.`,literal:e=>`Enter ${g(e.expected)}.`,enum:e=>{const n=Array.isArray(e.options)?e.options:[];return n.length>0&&n.length<=10?`Choose one of: ${n.map(g).join(", ")}.`:"Choose one of the available options."},"array.min":e=>`Add at least ${g(e.min)} ${e.min===1?"item":"items"}.`,"array.max":e=>`Add no more than ${g(e.max)} ${e.max===1?"item":"items"}.`,"object.unknownKey":()=>"Remove this field; it is not recognized.","object.unsafeKey":()=>"Remove this field; its name is not allowed.",union:()=>"Enter a value in one of the accepted formats.",invalid:()=>"Check this value and correct it.",custom:()=>"Check this value and correct it.","limit.depth":()=>"The data is nested too deeply. Simplify it and try again.","limit.size":()=>"The data is too large. Reduce its size and try again."},V=(e,n)=>{const r=k(E,e)?E[e]:void 0;return r?r(n):"Check this value and correct it."};function U(e,n,r={}){const{messages:o=V,maxDepth:a=32,maxNodes:t=1e5,maxIssues:u=100,maxStringLength:s=1e6,formKey:d="_form"}=r,m={issues:[],depth:0,nodes:0,stopped:!1,maxDepth:a,maxNodes:t,maxIssues:u,maxStringLength:s},l=e.run(n,m,"");if(l.ok&&m.issues.length===0)return D(l.value);const c={};for(const f of m.issues){const p=f.path===""?d:f.path;k(c,p)||Object.defineProperty(c,p,{value:o(f.code,f.params),enumerable:!0,writable:!0,configurable:!0})}return P(new C("HLP_VALIDATE_FAILED","The input is not valid.",{fields:c,details:{issues:m.issues.map(f=>({path:f.path,code:f.code,params:f.params}))}}))}function se(e,n={}){return(r,o,a={})=>U(r,o,{...n,...a,messages:e})}export{ee as array,J as boolean,se as createValidator,B as date,V as defaultMessages,X as enumOf,Q as literal,te as nullable,H as number,ne as object,re as optional,ae as refine,G as string,ie as transform,oe as union,U as validate};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Streaming ZIP writer and reader on native `CompressionStream('deflate-raw')` (docs/PLAN-HELPERS.md section 3;
|
|
3
|
+
* moved from @absoluteui/services/zip by R11-17, which re-exports it).
|
|
4
|
+
* Writer: data descriptors, UTF-8 names, ZIP64, "zip slip" name validation. Reader: ZIP64,
|
|
5
|
+
* zip-bomb guards, CRC-32 verification, sanitized names.
|
|
6
|
+
*/
|
|
7
|
+
export { createZipWriter, zipFiles, type ZipWriter, type ZipWriterOptions, type ZipAddOptions, type ZipCompression, type ZipEntryData, type ZipFileInput } from './writer.js';
|
|
8
|
+
export { readZip, type ReadZipOptions, type ZipEntry, type ZipArchive } from './reader.js';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
import{createZipWriter as i,zipFiles as t}from"./writer.js";import{readZip as y}from"./reader.js";export{i as createZipWriter,y as readZip,t as zipFiles};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ZIP format constants and shared helpers (PKWARE APPNOTE 6.3.10). Internal to the zip module.
|
|
3
|
+
*/
|
|
4
|
+
import { HelperError, ValidationError } from '../error/index.js';
|
|
5
|
+
export declare const SIG_LOCAL = 67324752;
|
|
6
|
+
export declare const SIG_CENTRAL = 33639248;
|
|
7
|
+
export declare const SIG_EOCD = 101010256;
|
|
8
|
+
export declare const SIG_ZIP64_EOCD = 101075792;
|
|
9
|
+
export declare const SIG_ZIP64_LOCATOR = 117853008;
|
|
10
|
+
export declare const SIG_DESCRIPTOR = 134695760;
|
|
11
|
+
export declare const U16_MAX = 65535;
|
|
12
|
+
export declare const U32_MAX = 4294967295;
|
|
13
|
+
export declare const FLAG_ENCRYPTED = 1;
|
|
14
|
+
export declare const FLAG_DESCRIPTOR = 8;
|
|
15
|
+
export declare const FLAG_STRONG_ENCRYPTION = 64;
|
|
16
|
+
export declare const FLAG_UTF8 = 2048;
|
|
17
|
+
export declare const METHOD_STORE = 0;
|
|
18
|
+
export declare const METHOD_DEFLATE = 8;
|
|
19
|
+
export declare const METHOD_AES = 99;
|
|
20
|
+
export declare const EXTRA_ZIP64 = 1;
|
|
21
|
+
export declare const EXTRA_TIMESTAMP = 21589;
|
|
22
|
+
/** Maximum UTF-8 length of an entry name or comment (16-bit length fields). */
|
|
23
|
+
export declare const MAX_NAME_BYTES = 65535;
|
|
24
|
+
/** Little-endian fixed-size record builder. */
|
|
25
|
+
export declare class ByteWriter {
|
|
26
|
+
readonly bytes: Uint8Array<ArrayBuffer>;
|
|
27
|
+
private readonly view;
|
|
28
|
+
private p;
|
|
29
|
+
constructor(size: number);
|
|
30
|
+
u16(v: number): this;
|
|
31
|
+
u32(v: number): this;
|
|
32
|
+
/** Writes a non-negative safe integer as 64-bit little endian. */
|
|
33
|
+
u64(v: number): this;
|
|
34
|
+
raw(b: Uint8Array): this;
|
|
35
|
+
}
|
|
36
|
+
/** Reads a 64-bit little-endian value; throws when it exceeds `Number.MAX_SAFE_INTEGER`. */
|
|
37
|
+
export declare function readU64(view: DataView, offset: number): number;
|
|
38
|
+
export declare const corrupt: (cause?: unknown) => ValidationError;
|
|
39
|
+
export declare const unsupported: (code: string, message: string) => HelperError;
|
|
40
|
+
/** MS-DOS date and time (local time, 2-second resolution), clamped to 1980-2107. */
|
|
41
|
+
export declare function toDosDateTime(date: Date): {
|
|
42
|
+
readonly date: number;
|
|
43
|
+
readonly time: number;
|
|
44
|
+
};
|
|
45
|
+
/** Inverse of `toDosDateTime` (local time). */
|
|
46
|
+
export declare function fromDosDateTime(date: number, time: number): Date;
|
|
47
|
+
/**
|
|
48
|
+
* Validates and normalizes a name for writing ("zip slip" prevention): backslashes become `/`,
|
|
49
|
+
* empty and `.` segments are dropped; absolute paths, drive letters, `..` segments and control
|
|
50
|
+
* characters are rejected. Directories get a trailing `/`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function normalizeEntryName(name: unknown, isDirectory: boolean): string;
|
|
53
|
+
/**
|
|
54
|
+
* Makes a name read from an archive safe to use as a relative path: backslashes become `/`,
|
|
55
|
+
* control characters, drive letters, empty and `.` segments are removed, and `..` segments
|
|
56
|
+
* can never climb above the archive root.
|
|
57
|
+
*/
|
|
58
|
+
export declare function sanitizeEntryName(raw: string, isDirectory: boolean): string;
|
|
59
|
+
/** Decodes code page 437 bytes (the ZIP default when the UTF-8 flag is not set). */
|
|
60
|
+
export declare function decodeCp437(bytes: Uint8Array): string;
|
|
61
|
+
export declare const CP437_TABLE_LENGTH: number;
|
|
62
|
+
/** Views a chunk as `Uint8Array<ArrayBuffer>` (copies only when backed by a SharedArrayBuffer). */
|
|
63
|
+
export declare function ownBytes(chunk: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
64
|
+
/** True when `CompressionStream('deflate-raw')` exists (resolved lazily, cached). */
|
|
65
|
+
export declare function supportsDeflateRaw(): boolean;
|
|
66
|
+
/** Wraps an async iterator as a pull-based (back-pressured) `ReadableStream`. */
|
|
67
|
+
export declare function iteratorToStream<T>(it: AsyncIterator<T>): ReadableStream<T>;
|
|
68
|
+
/** Iterates a stream, releasing (and cancelling, on early exit) the reader. */
|
|
69
|
+
export declare function streamToIterator<T>(stream: ReadableStream<T>): AsyncGenerator<T, void, undefined>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
import{HelperError as p,ValidationError as a}from"../error/index.js";import{utf8Encode as h}from"../encoding/index.js";const A=67324752,y=33639248,_=101010256,T=101075792,w=117853008,g=134695760,l=65535,E=4294967295,I=1,P=8,D=64,S=2048,L=0,C=8,N=99,R=1,M=21589,x=l;class U{bytes;view;p=0;constructor(e){this.bytes=new Uint8Array(e),this.view=new DataView(this.bytes.buffer)}u16(e){return this.view.setUint16(this.p,e,!0),this.p+=2,this}u32(e){return this.view.setUint32(this.p,e>>>0,!0),this.p+=4,this}u64(e){return this.view.setUint32(this.p,e%4294967296,!0),this.view.setUint32(this.p+4,Math.floor(e/4294967296),!0),this.p+=8,this}raw(e){return this.bytes.set(e,this.p),this.p+=e.length,this}}function H(t,e){const r=t.getUint32(e,!0),u=t.getUint32(e+4,!0)*4294967296+r;if(!Number.isSafeInteger(u))throw b();return u}const b=t=>new a("HLP_ZIP_CORRUPT","The ZIP archive is damaged or not a ZIP file.",t===void 0?{}:{cause:t}),O=(t,e)=>new p(t,e,{kind:"unsupported"});function G(t){const e=t.getTime(),r=Number.isNaN(e)?new Date(1980,0,1):t,n=r.getFullYear();return n<1980?{date:33,time:0}:n>2107?{date:65439,time:49021}:{date:n-1980<<9|r.getMonth()+1<<5|r.getDate(),time:r.getHours()<<11|r.getMinutes()<<5|Math.floor(r.getSeconds()/2)}}function v(t,e){const r=(t>>>9&127)+1980,n=Math.max(1,t>>>5&15)-1,u=Math.max(1,t&31);return new Date(r,n,u,e>>>11&31,e>>>5&63,(e&31)*2)}const i=t=>t<32||t===127,c=t=>/^[a-z]:/i.test(t);function Z(t,e){if(typeof t!="string")throw new a("HLP_ZIP_INVALID_NAME","The entry name must be a string.");const r=t.replaceAll("\\","/");for(let o=0;o<r.length;o++)if(i(r.charCodeAt(o)))throw new a("HLP_ZIP_INVALID_NAME","The entry name must not contain control characters.");if(r.startsWith("/")||c(r))throw new a("HLP_ZIP_ABSOLUTE_PATH","The entry name must be a relative path.");const n=[];for(const o of r.split("/"))if(!(o===""||o===".")){if(o==="..")throw new a("HLP_ZIP_PATH_TRAVERSAL",'The entry name must not contain ".." segments.');n.push(o)}if(n.length===0)throw new a("HLP_ZIP_INVALID_NAME","The entry name is empty.");const u=n.join("/")+(e?"/":"");if(h(u).length>x)throw new a("HLP_ZIP_INVALID_NAME","The entry name is too long.");return u}function V(t,e){let r="";for(let u=0;u<t.length;u++){const o=t.charCodeAt(u);i(o)||(r+=o===92?"/":t.charAt(u))}for(;c(r);)r=r.slice(2);const n=[];for(const u of r.split("/"))u===""||u==="."||(u===".."?n.pop():n.push(u));return n.join("/")+(e&&n.length>0?"/":"")}const f="\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";function B(t){let e="";for(const r of t)e+=r<128?String.fromCharCode(r):f.charAt(r-128);return e}const F=f.length;function X(t){return t.buffer instanceof ArrayBuffer?t:t.slice()}let s;function k(){if(s===void 0)try{s=typeof CompressionStream=="function"&&typeof DecompressionStream=="function"&&new CompressionStream("deflate-raw")instanceof CompressionStream}catch{s=!1}return s}function Y(t){return new ReadableStream({async pull(e){const r=await t.next();r.done===!0?e.close():e.enqueue(r.value)},async cancel(e){await t.return?.(e)}},{highWaterMark:0})}async function*z(t){const e=t.getReader();let r=!1;try{for(;;){const n=await e.read();if(n.done){r=!0;return}yield n.value}}finally{r||await e.cancel().catch(()=>{}),e.releaseLock()}}export{U as ByteWriter,F as CP437_TABLE_LENGTH,M as EXTRA_TIMESTAMP,R as EXTRA_ZIP64,P as FLAG_DESCRIPTOR,I as FLAG_ENCRYPTED,D as FLAG_STRONG_ENCRYPTION,S as FLAG_UTF8,x as MAX_NAME_BYTES,N as METHOD_AES,C as METHOD_DEFLATE,L as METHOD_STORE,y as SIG_CENTRAL,g as SIG_DESCRIPTOR,_ as SIG_EOCD,A as SIG_LOCAL,T as SIG_ZIP64_EOCD,w as SIG_ZIP64_LOCATOR,l as U16_MAX,E as U32_MAX,b as corrupt,B as decodeCp437,v as fromDosDateTime,Y as iteratorToStream,Z as normalizeEntryName,X as ownBytes,H as readU64,V as sanitizeEntryName,z as streamToIterator,k as supportsDeflateRaw,G as toDosDateTime,O as unsupported};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export interface ReadZipOptions {
|
|
2
|
+
/** Maximum number of entries. Default 10,000. */
|
|
3
|
+
readonly maxEntries?: number;
|
|
4
|
+
/** Zip-bomb guard: maximum sum of declared uncompressed sizes. Default 1 GiB. */
|
|
5
|
+
readonly maxTotalUncompressed?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Zip-bomb guard: maximum uncompressed/compressed ratio for entries of 1 MiB or more.
|
|
8
|
+
* Default 100.
|
|
9
|
+
*/
|
|
10
|
+
readonly maxCompressionRatio?: number;
|
|
11
|
+
/** Return names exactly as stored in `name` instead of sanitized ones. Default false. */
|
|
12
|
+
readonly rawNames?: boolean;
|
|
13
|
+
readonly signal?: AbortSignal;
|
|
14
|
+
}
|
|
15
|
+
/** One entry of an archive opened with `readZip`. */
|
|
16
|
+
export interface ZipEntry {
|
|
17
|
+
/** Safe relative path (see `rawNames`); directories end with `/`. */
|
|
18
|
+
readonly name: string;
|
|
19
|
+
/** Name exactly as stored. Never use it as a file-system path without validation. */
|
|
20
|
+
readonly rawName: string;
|
|
21
|
+
readonly size: number;
|
|
22
|
+
readonly compressedSize: number;
|
|
23
|
+
readonly lastModified: Date;
|
|
24
|
+
readonly isDirectory: boolean;
|
|
25
|
+
readonly encrypted: boolean;
|
|
26
|
+
/** Compression method (0 store, 8 deflate). Others cannot be read. */
|
|
27
|
+
readonly method: number;
|
|
28
|
+
readonly crc32: number;
|
|
29
|
+
readonly comment: string;
|
|
30
|
+
/** Reads and verifies the content (CRC-32 and size). */
|
|
31
|
+
read(options?: {
|
|
32
|
+
readonly signal?: AbortSignal;
|
|
33
|
+
}): Promise<Uint8Array<ArrayBuffer>>;
|
|
34
|
+
/** Streams the content; the stream errors on CRC or size mismatch at the end. */
|
|
35
|
+
stream(): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
36
|
+
}
|
|
37
|
+
/** An opened archive. */
|
|
38
|
+
export interface ZipArchive {
|
|
39
|
+
readonly entries: readonly ZipEntry[];
|
|
40
|
+
readonly comment: string;
|
|
41
|
+
/** Finds an entry by (sanitized, unless `rawNames`) name. */
|
|
42
|
+
get(name: string): ZipEntry | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Opens a ZIP archive (including ZIP64) by reading its central directory; entry data is read
|
|
46
|
+
* lazily. Guards against zip bombs (entry count, total size, compression ratio, actual output
|
|
47
|
+
* never exceeding the declared size), verifies CRC-32, rejects encrypted entries, and
|
|
48
|
+
* sanitizes names so they cannot escape the extraction root ("zip slip").
|
|
49
|
+
* @example
|
|
50
|
+
* const file = await zipFiles([{ name: 'reports/q1.csv', data: 'id,name\n1,Ada' }]); // or a File from a picker
|
|
51
|
+
* const zip = await readZip(file);
|
|
52
|
+
* zip.entries.map((e) => e.name); // => ['reports/q1.csv']
|
|
53
|
+
* const first = zip.entries[0];
|
|
54
|
+
* const text = first ? new TextDecoder().decode(await first.read()) : ''; // => 'id,name\n1,Ada'
|
|
55
|
+
*/
|
|
56
|
+
export declare function readZip(input: Blob | Uint8Array | ArrayBuffer, options?: ReadZipOptions): Promise<ZipArchive>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
import{AbortError as q,HelperError as V,LimitError as T,ValidationError as x}from"../error/index.js";import{crc32 as W}from"../encoding/index.js";import{EXTRA_TIMESTAMP as K,EXTRA_ZIP64 as j,FLAG_ENCRYPTED as J,FLAG_STRONG_ENCRYPTION as Q,FLAG_UTF8 as $,METHOD_AES as ee,METHOD_DEFLATE as k,METHOD_STORE as L,SIG_CENTRAL as te,SIG_EOCD as re,SIG_LOCAL as ne,SIG_ZIP64_EOCD as ie,SIG_ZIP64_LOCATOR as oe,U16_MAX as ae,U32_MAX as N,corrupt as f,decodeCp437 as se,fromDosDateTime as ce,ownBytes as G,readU64 as _,sanitizeEntryName as de,streamToIterator as fe,unsupported as I}from"./internal.js";const me=1024*1024,le=ae;async function b(e,t,s){if(t<0||s>e.size||s<t)throw f();return new Uint8Array(await e.slice(t,s).arrayBuffer())}const S=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function P(e){if(e?.aborted===!0)throw new q("HLP_ZIP_ABORTED","Reading the ZIP archive was aborted.",{cause:e.reason})}async function ue(e){if(e.size<22)throw f();const t=Math.max(0,e.size-22-le),s=await b(e,t,e.size),r=S(s);let a=-1,i=-1;for(let n=s.length-22;n>=0;n--){if(r.getUint32(n,!0)!==re)continue;const p=n+22+r.getUint16(n+20,!0);if(p===s.length){a=n;break}i<0&&p<s.length&&(i=n)}if(a<0&&(a=i),a<0)throw f();const l=t+a,c=r.getUint16(a+4,!0),o=r.getUint16(a+6,!0);let d=r.getUint16(a+10,!0),m=r.getUint32(a+12,!0),u=r.getUint32(a+16,!0);const g=s.subarray(a+22,a+22+r.getUint16(a+20,!0));let y=l;if(l>=20){const n=await b(e,l-20,l),p=S(n);if(p.getUint32(0,!0)===oe){const A=_(p,8);if(A+56>l-20)throw f();const z=await b(e,A,A+56),h=S(z);if(h.getUint32(0,!0)!==ie)throw f();if(h.getUint32(16,!0)!==0||h.getUint32(20,!0)!==0)throw I("HLP_ZIP_MULTI_DISK","Split (multi-disk) archives are not supported.");d=_(h,32),m=_(h,40),u=_(h,48),y=A}}if(c!==0||o!==0)throw I("HLP_ZIP_MULTI_DISK","Split (multi-disk) archives are not supported.");if(u>y)throw f();return u+m>y&&(m=y-u),{count:d,cdOffset:u,cdSize:m,comment:g}}let F;function C(e,t){return t?(F??=new TextDecoder("utf-8"),F.decode(e)):se(e)}function ye(e,t,s){const r=S(e),a=[];let i=0;for(let l=0;l<t;l++){if(i+46>e.length||r.getUint32(i,!0)!==te)throw f();const c=r.getUint16(i+8,!0),o=r.getUint16(i+10,!0),d=r.getUint16(i+12,!0),m=r.getUint16(i+14,!0),u=r.getUint32(i+16,!0);let g=r.getUint32(i+20,!0),y=r.getUint32(i+24,!0);const n=r.getUint16(i+28,!0),p=r.getUint16(i+30,!0),A=r.getUint16(i+32,!0),z=r.getUint32(i+38,!0);let h=r.getUint32(i+42,!0);const D=i+46+n+p+A;if(D>e.length)throw f();const v=(c&$)!==0,R=C(e.subarray(i+46,i+46+n),v);let B=ce(m,d),U=i+46+n;const O=U+p;for(;U+4<=O;){const H=r.getUint16(U,!0),E=r.getUint16(U+2,!0),w=U+4;if(w+E>O)throw f();if(H===j){let M=w;const Z=()=>{if(M+8>w+E)throw f();const Y=_(r,M);return M+=8,Y};y===N&&(y=Z()),g===N&&(g=Z()),h===N&&(h=Z())}else H===K&&E>=5&&(r.getUint8(w)&1)===1&&(B=new Date(r.getUint32(w+1,!0)*1e3));U=w+E}const X=C(e.subarray(O,D),v);if(h+30>s)throw f();a.push({rawName:R,flags:c,method:o,crc:u,compressedSize:g,size:y,offset:h,lastModified:B,isDirectory:R.endsWith("/")||R.endsWith("\\")||(z&16)!==0,comment:X}),i=D}return a}function he(e,t){let s=0,r=0;return new TransformStream({transform(a,i){if(s+=a.length,s>e)throw new T("HLP_ZIP_SIZE_MISMATCH","An entry is larger than its declared size.");r=W(a,r),i.enqueue(G(a))},flush(){if(s!==e)throw new x("HLP_ZIP_SIZE_MISMATCH","An entry is smaller than its declared size.");if(r!==t)throw new x("HLP_ZIP_CRC_MISMATCH","An entry failed its CRC-32 check; the archive is damaged.")}})}const ge=e=>e instanceof V?e:f(e);function pe(e,t,s,r){const a=(t.flags&(J|Q))!==0||t.method===ee,i=async()=>{if(a)throw I("HLP_ZIP_ENCRYPTED","Encrypted ZIP entries are not supported.");if(t.method!==L&&t.method!==k)throw I("HLP_ZIP_UNSUPPORTED_METHOD","The entry uses an unsupported compression method.");if(t.method===L&&t.compressedSize!==t.size)throw f();const c=await b(e,t.offset,t.offset+30),o=S(c);if(o.getUint32(0,!0)!==ne)throw f();const d=t.offset+30+o.getUint16(26,!0)+o.getUint16(28,!0),m=d+t.compressedSize;if(m>r)throw f();const u=e.slice(d,m).stream();return(t.method===k?u.pipeThrough(new DecompressionStream("deflate-raw")):u).pipeThrough(he(t.size,t.crc))},l=()=>{let c;return new ReadableStream({async pull(o){try{c??=(await i()).getReader();const d=await c.read();d.done?o.close():o.enqueue(d.value)}catch(d){o.error(ge(d))}},async cancel(o){await c?.cancel(o)}},{highWaterMark:0})};return{name:s,rawName:t.rawName,size:t.size,compressedSize:t.compressedSize,lastModified:t.lastModified,isDirectory:t.isDirectory,encrypted:a,method:t.method,crc32:t.crc,comment:t.comment,stream:l,async read(c={}){if(P(c.signal),t.isDirectory&&t.size===0)return new Uint8Array(0);const o=new Uint8Array(t.size);let d=0;for await(const m of fe(l()))P(c.signal),o.set(m,d),d+=m.length;return o}}}async function _e(e,t={}){const{maxEntries:s=1e4,maxTotalUncompressed:r=1024*1024*1024,maxCompressionRatio:a=100,rawNames:i=!1,signal:l}=t;P(l);const c=e instanceof Blob?e:new Blob([e instanceof Uint8Array?G(e):e]),o=await ue(c);if(o.count>s)throw new T("HLP_ZIP_TOO_MANY_ENTRIES","The archive has too many entries.",{details:{limit:s}});if(o.count*46>o.cdSize)throw f();P(l);const d=await b(c,o.cdOffset,o.cdOffset+o.cdSize),m=ye(d,o.count,o.cdOffset);let u=0;for(const n of m){if(u+=n.size,u>r)throw new T("HLP_ZIP_TOO_LARGE","The archive expands beyond the allowed size.",{details:{limit:r}});if(n.size>0&&n.compressedSize===0&&n.method!==L)throw f();if(n.size>=me&&n.compressedSize>0&&n.size/n.compressedSize>a)throw new T("HLP_ZIP_RATIO","The archive has a suspicious compression ratio (possible zip bomb).",{details:{limit:a}})}const g=m.map(n=>pe(c,n,i?n.rawName:de(n.rawName,n.isDirectory),o.cdOffset)),y=new Map;for(const n of g)y.has(n.name)||y.set(n.name,n);return{entries:g,comment:C(o.comment,!0),get:n=>y.get(n)}}export{_e as readZip};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/** `deflate` uses native `CompressionStream('deflate-raw')`; `store` writes bytes as they are. */
|
|
2
|
+
export type ZipCompression = 'deflate' | 'store';
|
|
3
|
+
/** Entry content. Streams and Blobs are read lazily while the archive is produced. */
|
|
4
|
+
export type ZipEntryData = string | Uint8Array | ArrayBuffer | Blob | ReadableStream<Uint8Array>;
|
|
5
|
+
export interface ZipWriterOptions {
|
|
6
|
+
/** Default `deflate` when `CompressionStream('deflate-raw')` exists, else `store`. */
|
|
7
|
+
readonly compression?: ZipCompression;
|
|
8
|
+
/** Archive comment (UTF-8, at most 65535 bytes). */
|
|
9
|
+
readonly comment?: string;
|
|
10
|
+
/**
|
|
11
|
+
* `auto` (default) switches to ZIP64 records only when needed (known size >= ~4 GiB, offsets
|
|
12
|
+
* >= 4 GiB, more than 65535 entries). `always` writes ZIP64 for every entry, which lets
|
|
13
|
+
* streams of unknown size exceed 4 GiB.
|
|
14
|
+
*/
|
|
15
|
+
readonly zip64?: 'auto' | 'always';
|
|
16
|
+
/** Maximum number of entries. Default 1,000,000. */
|
|
17
|
+
readonly maxEntries?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface ZipAddOptions {
|
|
20
|
+
/** Modification time. Default: `File.lastModified` for files, else now. */
|
|
21
|
+
readonly lastModified?: Date;
|
|
22
|
+
/** Overrides the writer default (for example `store` for already-compressed JPEGs). */
|
|
23
|
+
readonly compression?: ZipCompression;
|
|
24
|
+
/** Entry comment (UTF-8, at most 65535 bytes). */
|
|
25
|
+
readonly comment?: string;
|
|
26
|
+
}
|
|
27
|
+
/** Streaming ZIP archive builder. */
|
|
28
|
+
export interface ZipWriter {
|
|
29
|
+
/** Queues a file. Throws on unsafe or duplicate names ("zip slip" prevention). */
|
|
30
|
+
add(name: string, data: ZipEntryData, options?: ZipAddOptions): void;
|
|
31
|
+
/** Queues an explicit directory entry. */
|
|
32
|
+
addDirectory(name: string, options?: Pick<ZipAddOptions, 'lastModified' | 'comment'>): void;
|
|
33
|
+
/** Number of queued entries. */
|
|
34
|
+
readonly size: number;
|
|
35
|
+
/** Produces the archive; can be called once. Entries cannot be added afterwards. */
|
|
36
|
+
stream(): ReadableStream<Uint8Array<ArrayBuffer>>;
|
|
37
|
+
/** Produces the archive as a `Blob` (`application/zip`). */
|
|
38
|
+
toBlob(): Promise<Blob>;
|
|
39
|
+
}
|
|
40
|
+
/** End records: ZIP64 end of central directory and locator when needed, then the classic EOCD. */
|
|
41
|
+
export declare function endRecords(count: number, cdOffset: number, cdSize: number, comment: Uint8Array, forceZip64: boolean): Uint8Array<ArrayBuffer>;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a streaming ZIP writer. Entries stream through without knowing their sizes (local
|
|
44
|
+
* headers use data descriptors), names are UTF-8, and CRC-32 is computed incrementally.
|
|
45
|
+
* @example
|
|
46
|
+
* const zip = createZipWriter();
|
|
47
|
+
* zip.add('reports/q1.csv', 'id,name\n1,Ada');
|
|
48
|
+
* zip.add('photo.jpg', new File([new Uint8Array([0xff, 0xd8, 0xff])], 'photo.jpg'), { compression: 'store' });
|
|
49
|
+
* const blob = await zip.toBlob();
|
|
50
|
+
* (await readZip(blob)).entries.map((e) => e.name); // => ['reports/q1.csv', 'photo.jpg']
|
|
51
|
+
*/
|
|
52
|
+
export declare function createZipWriter(options?: ZipWriterOptions): ZipWriter;
|
|
53
|
+
/** A file for `zipFiles`. */
|
|
54
|
+
export interface ZipFileInput extends ZipAddOptions {
|
|
55
|
+
readonly name: string;
|
|
56
|
+
readonly data: ZipEntryData;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Zips files into a `Blob` in one call.
|
|
60
|
+
* @example
|
|
61
|
+
* const pngBlob = new Blob([new Uint8Array([0x89, 0x50, 0x4e, 0x47])], { type: 'image/png' });
|
|
62
|
+
* const blob = await zipFiles([{ name: 'a.txt', data: 'hello' }, { name: 'img/b.png', data: pngBlob, compression: 'store' }]);
|
|
63
|
+
* blob.type; // => 'application/zip'
|
|
64
|
+
*/
|
|
65
|
+
export declare function zipFiles(files: readonly ZipFileInput[], options?: ZipWriterOptions): Promise<Blob>;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
import{LimitError as D,ValidationError as h}from"../error/index.js";import{crc32 as H,utf8Encode as E}from"../encoding/index.js";import{ByteWriter as A,EXTRA_TIMESTAMP as G,EXTRA_ZIP64 as P,FLAG_DESCRIPTOR as Z,FLAG_UTF8 as z,MAX_NAME_BYTES as W,METHOD_DEFLATE as S,METHOD_STORE as v,SIG_CENTRAL as F,SIG_DESCRIPTOR as B,SIG_EOCD as V,SIG_LOCAL as X,SIG_ZIP64_EOCD as Y,SIG_ZIP64_LOCATOR as K,U16_MAX as U,U32_MAX as y,iteratorToStream as O,normalizeEntryName as j,ownBytes as R,streamToIterator as T,supportsDeflateRaw as L,toDosDateTime as C,unsupported as q}from"./internal.js";const N=64*1024,J=4278190080,x=20,w=45,Q=16;function $(e){if(typeof e!="string"){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return e.byteLength;if(e instanceof Blob)return e.size}}function M(e){const r=E(e??"");if(r.length>W)throw new h("HLP_ZIP_COMMENT_TOO_LONG","The comment is longer than 65535 bytes.");return r}async function*ee(e){if(typeof e=="string"){yield E(e);return}if(e instanceof Uint8Array||e instanceof ArrayBuffer){const n=e instanceof Uint8Array?e:new Uint8Array(e);for(let t=0;t<n.length;t+=N)yield n.subarray(t,t+N);return}const r=e instanceof Blob?e.stream():e;for await(const n of T(r)){if(!(n instanceof Uint8Array))throw new h("HLP_ZIP_INVALID_CHUNK","Entry streams must produce Uint8Array chunks.");yield n}}async function*ne(e,r){for await(const n of e)r.crc=H(n,r.crc),r.size+=n.length,yield R(n)}function k(e){const r=Math.floor(e.getTime()/1e3);return!Number.isFinite(r)||r<0||r>y?new Uint8Array(0):new A(9).u16(G).u16(5).raw(Uint8Array.of(1)).u32(r).bytes}function re(e,r,n,t,u){const i=n?new A(20).u16(P).u16(16).u64(0).u64(0).bytes:new Uint8Array(0),a=new A(30+e.name.length+i.length+u.length);return a.u32(X).u16(n?w:x).u16(Z|z).u16(r).u16(t.time).u16(t.date).u32(0).u32(n?y:0).u32(n?y:0).u16(e.name.length).u16(i.length+u.length).raw(e.name).raw(i).raw(u),a.bytes}function te(e,r,n,t){return t?new A(24).u32(B).u32(e).u64(r).u64(n).bytes:new A(16).u32(B).u32(e).u32(r).u32(n).bytes}function oe(e,r){const{entry:n}=e,t=r||e.zip64||e.size>=y,u=r||e.zip64||e.compressedSize>=y,i=r||e.offset>=y,a=[t?e.size:-1,u?e.compressedSize:-1,i?e.offset:-1].filter(s=>s>=0);let o=new Uint8Array(0);if(a.length>0){const s=new A(4+a.length*8).u16(P).u16(a.length*8);for(const l of a)s.u64(l);o=s.bytes}const d=k(n.date),m=C(n.date),c=a.length>0||e.zip64?w:x,f=new A(46+n.name.length+o.length+d.length+n.comment.length);return f.u32(F).u16(c).u16(c).u16(Z|z).u16(e.method).u16(m.time).u16(m.date).u32(e.crc).u32(u?y:e.compressedSize).u32(t?y:e.size).u16(n.name.length).u16(o.length+d.length).u16(n.comment.length).u16(0).u16(0).u32(n.isDirectory?Q:0).u32(i?y:e.offset).raw(n.name).raw(o).raw(d).raw(n.comment),f.bytes}function ie(e,r,n,t,u){const i=u||e>U-1||r>=y||n>=y,a=new A(22+t.length);if(a.u32(V).u16(0).u16(0).u16(i?U:e).u16(i?U:e).u32(i?y:n).u32(i?y:r).u16(t.length).raw(t),!i)return a.bytes;const o=new A(76+a.bytes.length);return o.u32(Y).u64(44).u16(w).u16(w).u32(0).u32(0).u64(e).u64(e).u64(n).u64(r).u32(K).u32(0).u64(r+n).u32(1).raw(a.bytes),o.bytes}async function*ae(e,r,n){let t=0;const u=[];for(const o of e){const d=!o.isDirectory&&o.data!==void 0&&o.knownSize!==0,m=d&&o.compression==="deflate"?S:v,c=n||o.knownSize!==void 0&&o.knownSize>=J,f=re(o,m,c,C(o.date),k(o.date)),s=t;yield f,t+=f.length;const l={crc:0,size:0};let p=0;if(d){const g=ne(ee(o.data),l),_=m===S?T(O(g).pipeThrough(new CompressionStream("deflate-raw"))):g;for await(const I of _)p+=I.length,yield R(I);t+=p}if(!c&&(l.size>=y||p>=y))throw new D("HLP_ZIP_ENTRY_TOO_LARGE","An entry of unknown size exceeded 4 GiB. Create the writer with zip64: 'always'.");const b=te(l.crc,p,l.size,c);yield b,t+=b.length,u.push({entry:o,method:m,zip64:c,offset:s,crc:l.crc,size:l.size,compressedSize:p})}const i=t;let a=0;for(const o of u){const d=oe(o,n);a+=d.length,yield d}yield ie(u.length,i,a,r,n)}function se(e={}){const r=e.compression??(L()?"deflate":"store"),n=M(e.comment),t=e.maxEntries??1e6,u=e.zip64==="always",i=[],a=new Set;let o=!1;const d=(c,f,s,l)=>{if(o)throw new h("HLP_ZIP_WRITER_CLOSED","Entries cannot be added after the archive has started.");if(i.length>=t)throw new D("HLP_ZIP_TOO_MANY_ENTRIES","The archive has too many entries.");const p=j(c,f),b=f?p.slice(0,-1):p;if(a.has(b))throw new h("HLP_ZIP_DUPLICATE_NAME","The archive already contains an entry with this name.");const g=l.compression??r;if(g==="deflate"&&!L())throw q("HLP_ZIP_DEFLATE_UNSUPPORTED",'This browser cannot compress; use compression: "store".');if(s!==void 0&&!(typeof s=="string"||s instanceof Uint8Array||s instanceof ArrayBuffer||s instanceof Blob||s instanceof ReadableStream))throw new h("HLP_ZIP_INVALID_DATA","Entry data must be a string, bytes, a Blob, or a ReadableStream.");const _=s instanceof File?new Date(s.lastModified):void 0;a.add(b),i.push({name:E(p),isDirectory:f,data:s,knownSize:s===void 0?0:$(s),compression:g,date:l.lastModified??_??new Date,comment:M(l.comment)})},m=()=>{if(o)throw new h("HLP_ZIP_WRITER_CLOSED","The archive can be produced only once.");return o=!0,O(ae(i.slice(),n,u))};return{add(c,f,s={}){d(c,!1,f,s)},addDirectory(c,f={}){d(c,!0,void 0,f)},get size(){return i.length},stream:m,async toBlob(){const c=[];for await(const f of T(m()))c.push(f);return new Blob(c,{type:"application/zip"})}}}async function ye(e,r={}){const n=se(r);for(const t of e){const{name:u,data:i,...a}=t;n.add(u,i,a)}return n.toBlob()}export{se as createZipWriter,ie as endRecords,ye as zipFiles};
|
package/package.json
CHANGED
|
@@ -1,6 +1,152 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@absoluteui/helpers",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.13.2",
|
|
4
|
+
"description": "AbsoluteUI helpers: pure, zero-dependency functions and data structures (collections, dates, business calendar, strings, numbers, JSON, LINQ, validation).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"homepage": "https://aui.kasadara.com/docs/api/helpers/",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/kasadara-labs/AbsoluteUI.git",
|
|
11
|
+
"directory": "packages/helpers"
|
|
12
|
+
},
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"registry": "https://registry.npmjs.org/"
|
|
16
|
+
},
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"NOTICE",
|
|
22
|
+
"SECURITY.md"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./is": {
|
|
30
|
+
"types": "./dist/is/index.d.ts",
|
|
31
|
+
"default": "./dist/is/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./convert": {
|
|
34
|
+
"types": "./dist/convert/index.d.ts",
|
|
35
|
+
"default": "./dist/convert/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./error": {
|
|
38
|
+
"types": "./dist/error/index.d.ts",
|
|
39
|
+
"default": "./dist/error/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./array": {
|
|
42
|
+
"types": "./dist/array/index.d.ts",
|
|
43
|
+
"default": "./dist/array/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./set": {
|
|
46
|
+
"types": "./dist/set/index.d.ts",
|
|
47
|
+
"default": "./dist/set/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./object": {
|
|
50
|
+
"types": "./dist/object/index.d.ts",
|
|
51
|
+
"default": "./dist/object/index.js"
|
|
52
|
+
},
|
|
53
|
+
"./linq": {
|
|
54
|
+
"types": "./dist/linq/index.d.ts",
|
|
55
|
+
"default": "./dist/linq/index.js"
|
|
56
|
+
},
|
|
57
|
+
"./string": {
|
|
58
|
+
"types": "./dist/string/index.d.ts",
|
|
59
|
+
"default": "./dist/string/index.js"
|
|
60
|
+
},
|
|
61
|
+
"./number": {
|
|
62
|
+
"types": "./dist/number/index.d.ts",
|
|
63
|
+
"default": "./dist/number/index.js"
|
|
64
|
+
},
|
|
65
|
+
"./decimal": {
|
|
66
|
+
"types": "./dist/decimal/index.d.ts",
|
|
67
|
+
"default": "./dist/decimal/index.js"
|
|
68
|
+
},
|
|
69
|
+
"./stats": {
|
|
70
|
+
"types": "./dist/stats/index.d.ts",
|
|
71
|
+
"default": "./dist/stats/index.js"
|
|
72
|
+
},
|
|
73
|
+
"./boolean": {
|
|
74
|
+
"types": "./dist/boolean/index.d.ts",
|
|
75
|
+
"default": "./dist/boolean/index.js"
|
|
76
|
+
},
|
|
77
|
+
"./compare": {
|
|
78
|
+
"types": "./dist/compare/index.d.ts",
|
|
79
|
+
"default": "./dist/compare/index.js"
|
|
80
|
+
},
|
|
81
|
+
"./random": {
|
|
82
|
+
"types": "./dist/random/index.d.ts",
|
|
83
|
+
"default": "./dist/random/index.js"
|
|
84
|
+
},
|
|
85
|
+
"./encoding": {
|
|
86
|
+
"types": "./dist/encoding/index.d.ts",
|
|
87
|
+
"default": "./dist/encoding/index.js"
|
|
88
|
+
},
|
|
89
|
+
"./zip": {
|
|
90
|
+
"types": "./dist/zip/index.d.ts",
|
|
91
|
+
"default": "./dist/zip/index.js"
|
|
92
|
+
},
|
|
93
|
+
"./url": {
|
|
94
|
+
"types": "./dist/url/index.d.ts",
|
|
95
|
+
"default": "./dist/url/index.js"
|
|
96
|
+
},
|
|
97
|
+
"./color": {
|
|
98
|
+
"types": "./dist/color/index.d.ts",
|
|
99
|
+
"default": "./dist/color/index.js"
|
|
100
|
+
},
|
|
101
|
+
"./json": {
|
|
102
|
+
"types": "./dist/json/index.d.ts",
|
|
103
|
+
"default": "./dist/json/index.js"
|
|
104
|
+
},
|
|
105
|
+
"./csv": {
|
|
106
|
+
"types": "./dist/csv/index.d.ts",
|
|
107
|
+
"default": "./dist/csv/index.js"
|
|
108
|
+
},
|
|
109
|
+
"./validate": {
|
|
110
|
+
"types": "./dist/validate/index.d.ts",
|
|
111
|
+
"default": "./dist/validate/index.js"
|
|
112
|
+
},
|
|
113
|
+
"./sanitize": {
|
|
114
|
+
"types": "./dist/sanitize/index.d.ts",
|
|
115
|
+
"default": "./dist/sanitize/index.js"
|
|
116
|
+
},
|
|
117
|
+
"./http": {
|
|
118
|
+
"types": "./dist/http/index.d.ts",
|
|
119
|
+
"default": "./dist/http/index.js"
|
|
120
|
+
},
|
|
121
|
+
"./fn": {
|
|
122
|
+
"types": "./dist/fn/index.d.ts",
|
|
123
|
+
"default": "./dist/fn/index.js"
|
|
124
|
+
},
|
|
125
|
+
"./async": {
|
|
126
|
+
"types": "./dist/async/index.d.ts",
|
|
127
|
+
"default": "./dist/async/index.js"
|
|
128
|
+
},
|
|
129
|
+
"./ds": {
|
|
130
|
+
"types": "./dist/ds/index.d.ts",
|
|
131
|
+
"default": "./dist/ds/index.js"
|
|
132
|
+
},
|
|
133
|
+
"./date": {
|
|
134
|
+
"types": "./dist/date/index.d.ts",
|
|
135
|
+
"default": "./dist/date/index.js"
|
|
136
|
+
},
|
|
137
|
+
"./timezone": {
|
|
138
|
+
"types": "./dist/timezone/index.d.ts",
|
|
139
|
+
"default": "./dist/timezone/index.js"
|
|
140
|
+
},
|
|
141
|
+
"./duration": {
|
|
142
|
+
"types": "./dist/duration/index.d.ts",
|
|
143
|
+
"default": "./dist/duration/index.js"
|
|
144
|
+
},
|
|
145
|
+
"./business-calendar": {
|
|
146
|
+
"types": "./dist/business-calendar/index.d.ts",
|
|
147
|
+
"default": "./dist/business-calendar/index.js"
|
|
148
|
+
},
|
|
149
|
+
"./package.json": "./package.json"
|
|
150
|
+
},
|
|
151
|
+
"dependencies": {}
|
|
152
|
+
}
|