@gesslar/toolkit 1.5.0 → 1.8.0
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/package.json +5 -5
- package/src/browser/lib/Data.js +0 -7
- package/src/browser/lib/Disposer.js +1 -24
- package/src/browser/lib/Util.js +1 -11
- package/src/index.js +1 -0
- package/src/lib/DirectoryObject.js +25 -0
- package/src/lib/Notify.js +87 -0
- package/src/types/browser/lib/Data.d.ts.map +1 -1
- package/src/types/browser/lib/Disposer.d.ts +0 -6
- package/src/types/browser/lib/Disposer.d.ts.map +1 -1
- package/src/types/browser/lib/Util.d.ts +0 -1
- package/src/types/browser/lib/Util.d.ts.map +1 -1
- package/src/types/index.d.ts +1 -0
- package/src/types/lib/DirectoryObject.d.ts +14 -0
- package/src/types/lib/DirectoryObject.d.ts.map +1 -1
- package/src/types/lib/Notify.d.ts +55 -0
- package/src/types/lib/Notify.d.ts.map +1 -0
- package/src/browser/lib/Hook.js +0 -82
- package/src/browser/lib/test.js +0 -25
- package/src/browser/lib/test2.js +0 -46
- package/src/types/Cache.d.ts +0 -30
- package/src/types/Collection.d.ts +0 -321
- package/src/types/Contract.d.ts +0 -162
- package/src/types/Data.d.ts +0 -175
- package/src/types/DirectoryObject.d.ts +0 -135
- package/src/types/FS.d.ts +0 -40
- package/src/types/FileObject.d.ts +0 -388
- package/src/types/Glog.d.ts +0 -345
- package/src/types/Sass.d.ts +0 -24
- package/src/types/Schemer.d.ts +0 -179
- package/src/types/Tantrum.d.ts +0 -81
- package/src/types/Term.d.ts +0 -16
- package/src/types/Terms.d.ts +0 -145
- package/src/types/Type.d.ts +0 -26
- package/src/types/Util.d.ts +0 -275
- package/src/types/Valid.d.ts +0 -13
- package/src/types/browser/lib/Disposable.d.ts +0 -35
- package/src/types/browser/lib/Disposable.d.ts.map +0 -10
- package/src/types/browser/lib/Hook.d.ts +0 -11
- package/src/types/browser/lib/Hook.d.ts.map +0 -1
- package/src/types/browser/lib/test.d.ts +0 -2
- package/src/types/browser/lib/test.d.ts.map +0 -1
- package/src/types/browser/lib/test2.d.ts +0 -2
- package/src/types/browser/lib/test2.d.ts.map +0 -1
- package/src/types/lib/Chide.d.ts +0 -37
- package/src/types/lib/Chide.d.ts.map +0 -1
- package/src/types/lib/Collection.d.ts +0 -246
- package/src/types/lib/Collection.d.ts.map +0 -1
- package/src/types/lib/Data.d.ts +0 -206
- package/src/types/lib/Data.d.ts.map +0 -1
- package/src/types/lib/Disposable.d.ts +0 -33
- package/src/types/lib/Disposable.d.ts.map +0 -10
- package/src/types/lib/TypeSpec.d.ts +0 -92
- package/src/types/lib/TypeSpec.d.ts.map +0 -1
package/src/types/Terms.d.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
// Implementation: ../lib/Terms.js
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Terms represents an interface definition - what an action promises to provide or accept.
|
|
5
|
-
* It's just the specification, not the negotiation. Contract handles the negotiation.
|
|
6
|
-
*
|
|
7
|
-
* Terms can be created from objects, strings (YAML/JSON), or file references.
|
|
8
|
-
* File references use the format "ref://path/to/file" for loading external definitions.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* // Create terms from object definition
|
|
13
|
-
* const terms = new Terms({
|
|
14
|
-
* provides: {
|
|
15
|
-
* type: "object",
|
|
16
|
-
* properties: {
|
|
17
|
-
* userId: { type: "string" },
|
|
18
|
-
* userName: { type: "string" }
|
|
19
|
-
* },
|
|
20
|
-
* required: ["userId"]
|
|
21
|
-
* }
|
|
22
|
-
* })
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* // Parse terms from YAML string
|
|
28
|
-
* const yamlData = `
|
|
29
|
-
* accepts:
|
|
30
|
-
* type: object
|
|
31
|
-
* properties:
|
|
32
|
-
* input:
|
|
33
|
-
* type: string
|
|
34
|
-
* minLength: 1
|
|
35
|
-
* `
|
|
36
|
-
* const parsedTerms = await Terms.parse(yamlData)
|
|
37
|
-
* ```
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```typescript
|
|
41
|
-
* // Parse terms from file reference
|
|
42
|
-
* const directory = new DirectoryObject("/path/to/schemas")
|
|
43
|
-
* const parsedTerms = await Terms.parse("ref://user-schema.json", directory)
|
|
44
|
-
* ```
|
|
45
|
-
*/
|
|
46
|
-
declare class Terms {
|
|
47
|
-
/**
|
|
48
|
-
* Creates a new Terms instance with the given definition
|
|
49
|
-
*
|
|
50
|
-
* @param definition - The terms definition object describing what is provided or accepted
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```typescript
|
|
54
|
-
* const terms = new Terms({
|
|
55
|
-
* provides: {
|
|
56
|
-
* type: "object",
|
|
57
|
-
* properties: {
|
|
58
|
-
* data: { type: "array", items: { type: "string" } },
|
|
59
|
-
* metadata: {
|
|
60
|
-
* type: "object",
|
|
61
|
-
* properties: {
|
|
62
|
-
* timestamp: { type: "string", format: "date-time" }
|
|
63
|
-
* }
|
|
64
|
-
* }
|
|
65
|
-
* }
|
|
66
|
-
* }
|
|
67
|
-
* })
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
constructor(definition: object)
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Parses terms data from various sources, handling file references
|
|
74
|
-
*
|
|
75
|
-
* @param termsData - Terms data as string (YAML/JSON/file reference) or object
|
|
76
|
-
* @param directoryObject - Directory context for resolving file references (required for ref:// URLs)
|
|
77
|
-
* @returns Promise resolving to parsed terms data object
|
|
78
|
-
*
|
|
79
|
-
* @throws {Sass} If termsData is not a string or object
|
|
80
|
-
* @throws {Sass} If string data cannot be parsed as YAML or JSON
|
|
81
|
-
* @throws {Sass} If file reference cannot be loaded (missing directory or file not found)
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* ```typescript
|
|
85
|
-
* // Parse from YAML string
|
|
86
|
-
* const yamlTerms = await Terms.parse(`
|
|
87
|
-
* provides:
|
|
88
|
-
* type: string
|
|
89
|
-
* pattern: "^[A-Z][a-z]+"
|
|
90
|
-
* `)
|
|
91
|
-
* ```
|
|
92
|
-
*
|
|
93
|
-
* @example
|
|
94
|
-
* ```typescript
|
|
95
|
-
* // Parse from JSON string
|
|
96
|
-
* const jsonTerms = await Terms.parse(`{
|
|
97
|
-
* "accepts": {
|
|
98
|
-
* "type": "number",
|
|
99
|
-
* "minimum": 0,
|
|
100
|
-
* "maximum": 100
|
|
101
|
-
* }
|
|
102
|
-
* }`)
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```typescript
|
|
107
|
-
* // Parse from file reference
|
|
108
|
-
* const directory = new DirectoryObject("./schemas")
|
|
109
|
-
* const fileTerms = await Terms.parse("ref://api-contract.yaml", directory)
|
|
110
|
-
* ```
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* ```typescript
|
|
114
|
-
* // Parse from object (returns as-is)
|
|
115
|
-
* const objectTerms = await Terms.parse({
|
|
116
|
-
* provides: { type: "boolean" }
|
|
117
|
-
* })
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
static parse(
|
|
121
|
-
termsData: string | object,
|
|
122
|
-
directoryObject?: import('./DirectoryObject.js').default
|
|
123
|
-
): Promise<object>
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get the terms definition object
|
|
127
|
-
*
|
|
128
|
-
* @returns The complete terms definition as provided to the constructor
|
|
129
|
-
*
|
|
130
|
-
* @example
|
|
131
|
-
* ```typescript
|
|
132
|
-
* const terms = new Terms({
|
|
133
|
-
* accepts: { type: "string" },
|
|
134
|
-
* provides: { type: "number" }
|
|
135
|
-
* })
|
|
136
|
-
*
|
|
137
|
-
* const definition = terms.definition
|
|
138
|
-
* console.log(definition.accepts) // { type: "string" }
|
|
139
|
-
* console.log(definition.provides) // { type: "number" }
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
get definition(): object
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
export default Terms
|
package/src/types/Type.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// Implementation: ../lib/Type.js
|
|
2
|
-
// Type definitions for Type specification class
|
|
3
|
-
|
|
4
|
-
interface TypeSpecDefinition {
|
|
5
|
-
typeName: string
|
|
6
|
-
array: boolean
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export default class TypeSpec {
|
|
10
|
-
constructor(string: string, options?: { delimiter?: string })
|
|
11
|
-
|
|
12
|
-
readonly specs: ReadonlyArray<TypeSpecDefinition>
|
|
13
|
-
readonly length: number
|
|
14
|
-
readonly stringRepresentation: string
|
|
15
|
-
|
|
16
|
-
toString(): string
|
|
17
|
-
toJSON(): { specs: Array<TypeSpecDefinition>, length: number, stringRepresentation: string }
|
|
18
|
-
forEach(callback: (spec: TypeSpecDefinition) => void): void
|
|
19
|
-
every(callback: (spec: TypeSpecDefinition) => boolean): boolean
|
|
20
|
-
some(callback: (spec: TypeSpecDefinition) => boolean): boolean
|
|
21
|
-
filter(callback: (spec: TypeSpecDefinition) => boolean): Array<TypeSpecDefinition>
|
|
22
|
-
map<T>(callback: (spec: TypeSpecDefinition) => T): Array<T>
|
|
23
|
-
reduce<T>(callback: (acc: T, spec: TypeSpecDefinition) => T, initialValue: T): T
|
|
24
|
-
find(callback: (spec: TypeSpecDefinition) => boolean): TypeSpecDefinition | undefined
|
|
25
|
-
match(value: unknown, options?: { allowEmpty?: boolean }): boolean
|
|
26
|
-
}
|
package/src/types/Util.d.ts
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
// Implementation: ../lib/Util.js
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Utility class providing common helper functions for string manipulation,
|
|
5
|
-
* timing, hashing, and option parsing.
|
|
6
|
-
*/
|
|
7
|
-
declare class Util {
|
|
8
|
-
/**
|
|
9
|
-
* Capitalizes the first letter of a string.
|
|
10
|
-
*
|
|
11
|
-
* @param text - The text to capitalize
|
|
12
|
-
* @returns Text with first letter capitalized
|
|
13
|
-
* @throws {TypeError} If `text` is not a string
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```typescript
|
|
17
|
-
* const result = Util.capitalize("hello world")
|
|
18
|
-
* console.log(result) // "Hello world"
|
|
19
|
-
*
|
|
20
|
-
* // Works with empty strings and single characters
|
|
21
|
-
* Util.capitalize("") // ""
|
|
22
|
-
* Util.capitalize("a") // "A"
|
|
23
|
-
* ```
|
|
24
|
-
*/
|
|
25
|
-
static capitalize(text: string): string
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Measure wall-clock time for an async function.
|
|
29
|
-
* Useful for performance monitoring and debugging async operations.
|
|
30
|
-
*
|
|
31
|
-
* @template T
|
|
32
|
-
* @param fn - Thunk returning a promise.
|
|
33
|
-
* @returns Object containing result and elapsed ms (number, 1 decimal).
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const {result, cost} = await Util.time(async () => {
|
|
38
|
-
* await new Promise(resolve => setTimeout(resolve, 100))
|
|
39
|
-
* return "completed"
|
|
40
|
-
* })
|
|
41
|
-
* console.log(`Operation took ${cost}ms`) // "Operation took 100.2ms"
|
|
42
|
-
* console.log(result) // "completed"
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
static time<T>(fn: () => Promise<T>): Promise<{result: T, cost: number}>
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Right-align a string inside a fixed width (left pad with spaces).
|
|
49
|
-
* If the string exceeds width it is returned unchanged.
|
|
50
|
-
*
|
|
51
|
-
* @param text - Text to align.
|
|
52
|
-
* @param width - Target field width (default 80).
|
|
53
|
-
* @returns Padded string.
|
|
54
|
-
*/
|
|
55
|
-
static rightAlignText(text: string | number, width?: number): string
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Centre-align a string inside a fixed width (pad with spaces on left).
|
|
59
|
-
* If the string exceeds width it is returned unchanged.
|
|
60
|
-
*
|
|
61
|
-
* @param text - Text to align.
|
|
62
|
-
* @param width - Target field width (default 80).
|
|
63
|
-
* @returns Padded string with text centred.
|
|
64
|
-
*/
|
|
65
|
-
static centreAlignText(text: string | number, width?: number): string
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Compute sha256 hash (hex) of the provided string.
|
|
69
|
-
*
|
|
70
|
-
* @param s - Input string.
|
|
71
|
-
* @returns 64-char hexadecimal digest.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* ```typescript
|
|
75
|
-
* const hash = Util.hashOf("hello world")
|
|
76
|
-
* console.log(hash) // "b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9"
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
static hashOf(s: string): string
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Extracts canonical option names from a Commander-style options object.
|
|
83
|
-
*
|
|
84
|
-
* Each key in the input object is a string containing one or more option
|
|
85
|
-
* forms, separated by commas (e.g. "-w, --watch"). This function splits each
|
|
86
|
-
* key, trims whitespace, and parses out the long option name (e.g. "watch")
|
|
87
|
-
* for each entry. If no long option ("--") is present, the short option (e.g.
|
|
88
|
-
* "v" from "-v") will be included in the result array. If both are present,
|
|
89
|
-
* the long option is preferred.
|
|
90
|
-
*
|
|
91
|
-
* @param object - Mapping of option strings to descriptions.
|
|
92
|
-
* @returns Array of canonical option names (long preferred, short if no long present).
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const options = {
|
|
97
|
-
* "-w, --watch": "Watch for changes",
|
|
98
|
-
* "-v": "Verbose output",
|
|
99
|
-
* "--config": "Config file path"
|
|
100
|
-
* }
|
|
101
|
-
* const names = Util.generateOptionNames(options)
|
|
102
|
-
* console.log(names) // ["watch", "v", "config"]
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @remarks
|
|
106
|
-
* Edge cases:
|
|
107
|
-
* - If a key contains only a short option ("-v"), that short name will be included
|
|
108
|
-
* - If multiple long options are present, only the first is used
|
|
109
|
-
* - Malformed option strings may return undefined (filtered out)
|
|
110
|
-
*/
|
|
111
|
-
static generateOptionNames(object: Record<string, any>): Array<string>
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Asynchronously awaits all promises in parallel.
|
|
115
|
-
* Wrapper around Promise.all for consistency with other utility methods.
|
|
116
|
-
*
|
|
117
|
-
* @param promises - Array of promises to await
|
|
118
|
-
* @returns Results of all promises
|
|
119
|
-
*/
|
|
120
|
-
static awaitAll<T>(promises: Array<Promise<T>>): Promise<Array<T>>
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Settles all promises (both fulfilled and rejected) in parallel.
|
|
124
|
-
* Wrapper around Promise.allSettled for consistency with other utility methods.
|
|
125
|
-
*
|
|
126
|
-
* @param promises - Array of promises to settle
|
|
127
|
-
* @returns Results of all settled promises with status and value/reason
|
|
128
|
-
*/
|
|
129
|
-
static settleAll<T>(promises: Array<Promise<T>>): Promise<Array<PromiseSettledResult<T>>>
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Returns the first promise to resolve or reject from an array of promises.
|
|
133
|
-
* Wrapper around Promise.race for consistency with other utility methods.
|
|
134
|
-
*
|
|
135
|
-
* @param promises - Array of promises to race
|
|
136
|
-
* @returns Result of the first settled promise
|
|
137
|
-
*/
|
|
138
|
-
static race<T>(promises: Array<Promise<T>>): Promise<T>
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Emits an event asynchronously and waits for all listeners to complete.
|
|
142
|
-
*
|
|
143
|
-
* Unlike the standard EventEmitter.emit() which is synchronous, this method
|
|
144
|
-
* properly handles async event listeners by waiting for all of them to
|
|
145
|
-
* resolve or reject using Promise.allSettled(). If any listener throws an
|
|
146
|
-
* error, the first error encountered will be re-thrown.
|
|
147
|
-
*
|
|
148
|
-
* Uses strict instanceof checking to ensure the emitter is a genuine EventEmitter.
|
|
149
|
-
*
|
|
150
|
-
* @param emitter - The EventEmitter instance to emit on
|
|
151
|
-
* @param event - The event name to emit
|
|
152
|
-
* @param args - Arguments to pass to event listeners
|
|
153
|
-
* @returns Resolves when all listeners have completed
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* import { EventEmitter } from 'events'
|
|
158
|
-
* import { Util } from '@gesslar/toolkit'
|
|
159
|
-
*
|
|
160
|
-
* const emitter = new EventEmitter()
|
|
161
|
-
*
|
|
162
|
-
* emitter.on('data', async (payload) => {
|
|
163
|
-
* console.log('Processing:', payload.id)
|
|
164
|
-
* await new Promise(resolve => setTimeout(resolve, 100))
|
|
165
|
-
* console.log('Completed:', payload.id)
|
|
166
|
-
* })
|
|
167
|
-
*
|
|
168
|
-
* // Wait for all async listeners to complete
|
|
169
|
-
* await Util.asyncEmit(emitter, 'data', { id: 'task-1' })
|
|
170
|
-
* console.log('All listeners finished')
|
|
171
|
-
* ```
|
|
172
|
-
*
|
|
173
|
-
* @throws Will throw an error if any listener rejects or throws
|
|
174
|
-
*/
|
|
175
|
-
static asyncEmit(emitter: import('events').EventEmitter, event: string, ...args: unknown[]): Promise<void>
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Emits an event asynchronously and waits for all listeners to complete.
|
|
179
|
-
* Like asyncEmit, but uses duck typing for more flexible emitter validation.
|
|
180
|
-
* Accepts any object that has the required EventEmitter-like methods.
|
|
181
|
-
*
|
|
182
|
-
* @param emitter - Any object with EventEmitter-like interface
|
|
183
|
-
* @param event - The event name to emit
|
|
184
|
-
* @param args - Arguments to pass to event listeners
|
|
185
|
-
* @returns Resolves when all listeners have completed
|
|
186
|
-
*/
|
|
187
|
-
static asyncEmitAnon(
|
|
188
|
-
emitter: {
|
|
189
|
-
listeners(event: string): Function[],
|
|
190
|
-
on(event: string, listener: Function): any,
|
|
191
|
-
emit(event: string, ...args: unknown[]): any
|
|
192
|
-
},
|
|
193
|
-
event: string,
|
|
194
|
-
...args: unknown[]
|
|
195
|
-
): Promise<void>
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* Determine the Levenshtein distance between two string values.
|
|
199
|
-
* The Levenshtein distance is the minimum number of single-character edits
|
|
200
|
-
* (insertions, deletions, or substitutions) required to change one string into another.
|
|
201
|
-
*
|
|
202
|
-
* @param a - The first string for comparison
|
|
203
|
-
* @param b - The second string for comparison
|
|
204
|
-
* @returns The Levenshtein distance (number of edits needed)
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```typescript
|
|
208
|
-
* Util.levenshteinDistance("kitten", "sitting") // 3
|
|
209
|
-
* Util.levenshteinDistance("book", "back") // 2
|
|
210
|
-
* Util.levenshteinDistance("hello", "hello") // 0
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
static levenshteinDistance(a: string, b: string): number
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Find the closest match between an input string and an array of allowed values
|
|
217
|
-
* using Levenshtein distance. Returns the closest match if it's within a threshold
|
|
218
|
-
* of 2 edits, otherwise returns null.
|
|
219
|
-
*
|
|
220
|
-
* Useful for fuzzy string matching, such as suggesting corrections for typos
|
|
221
|
-
* in command-line arguments or configuration values.
|
|
222
|
-
*
|
|
223
|
-
* @param input - The input string to find a match for
|
|
224
|
-
* @param allowedValues - Array of allowed string values to match against
|
|
225
|
-
* @param threshold - Maximum edit distance for a match (default: 2)
|
|
226
|
-
* @returns The closest matching string, or null if no match within threshold
|
|
227
|
-
*
|
|
228
|
-
* @example
|
|
229
|
-
* ```typescript
|
|
230
|
-
* const commands = ["help", "build", "test", "deploy"]
|
|
231
|
-
* Util.findClosestMatch("bulid", commands) // "build"
|
|
232
|
-
* Util.findClosestMatch("xyz", commands) // null
|
|
233
|
-
* ```
|
|
234
|
-
*/
|
|
235
|
-
static findClosestMatch(input: string, allowedValues: string[], threshold?: number): string | null
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* Creates a RegExp from a multiline string by removing line breaks and
|
|
239
|
-
* optionally trimming whitespace from each line.
|
|
240
|
-
*
|
|
241
|
-
* This utility makes complex regular expressions more readable by allowing
|
|
242
|
-
* them to be written across multiple lines with proper formatting and indentation.
|
|
243
|
-
* The resulting regex is functionally identical to writing it as a single line.
|
|
244
|
-
*
|
|
245
|
-
* @param input - Multiline string containing the regex pattern (required)
|
|
246
|
-
* @param trim - Whether to trim whitespace from each line (default: true)
|
|
247
|
-
* @param flags - Array of regex flags to apply (default: [])
|
|
248
|
-
* @returns A new RegExp object with the processed pattern
|
|
249
|
-
*
|
|
250
|
-
* @throws Will throw if input is not a string
|
|
251
|
-
* @throws Will throw if trim is not a boolean
|
|
252
|
-
* @throws Will throw if flags is not an array
|
|
253
|
-
* @throws Will throw if flags contains non-string elements
|
|
254
|
-
*
|
|
255
|
-
* @example
|
|
256
|
-
* ```typescript
|
|
257
|
-
* const regex = Util.regexify(`
|
|
258
|
-
* \\s*\\*\\s*
|
|
259
|
-
* @(?<tag>\\w+)
|
|
260
|
-
* \\s*
|
|
261
|
-
* \\{(?<type>\\w+(?:\\|\\w+)*(?:\\*)?)\\}
|
|
262
|
-
* \\s+
|
|
263
|
-
* (?<name>\\w+)
|
|
264
|
-
* `)
|
|
265
|
-
* // Creates: /\s*\*\s*@(?<tag>\w+)\s*\{(?<type>\w+(?:\|\w+)*(?:\*)?)\}\s+(?<name>\w+)/
|
|
266
|
-
*
|
|
267
|
-
* // With flags:
|
|
268
|
-
* const globalRegex = Util.regexify(pattern, true, ['g', 'i'])
|
|
269
|
-
* // Creates regex with global and case-insensitive flags
|
|
270
|
-
* ```
|
|
271
|
-
*/
|
|
272
|
-
static regexify(input: string, trim?: boolean, flags?: string[]): RegExp
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export default Util
|
package/src/types/Valid.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Implementation: ../lib/Valid.js
|
|
2
|
-
// Type definitions for Valid utility class
|
|
3
|
-
|
|
4
|
-
export default class Valid {
|
|
5
|
-
/** Validate a value against a type specification */
|
|
6
|
-
static type(value: unknown, type: string, options?: { allowEmpty?: boolean }): void
|
|
7
|
-
|
|
8
|
-
/** Assert a condition */
|
|
9
|
-
static assert(condition: boolean, message: string, arg?: number | null): void
|
|
10
|
-
|
|
11
|
-
/** Protect against prototype pollution by checking for dangerous keys */
|
|
12
|
-
static prototypePollutionProtection(keys: string[]): void
|
|
13
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Simple lifecycle helper that tracks disposer callbacks.
|
|
3
|
-
* Register any teardown functions and call dispose() to run them in reverse.
|
|
4
|
-
*/
|
|
5
|
-
export class Disposer {
|
|
6
|
-
/**
|
|
7
|
-
* Registers a disposer callback to be executed when disposed.
|
|
8
|
-
*
|
|
9
|
-
* @param {...(() => void)|Array<() => void>} disposers - Cleanup callbacks.
|
|
10
|
-
* @returns {(() => void)|Array<() => void>} Function(s) to unregister the disposer(s).
|
|
11
|
-
*/
|
|
12
|
-
register(...disposers: Array<(() => void) | Array<() => void>>): (() => void) | Array<() => void>;
|
|
13
|
-
/**
|
|
14
|
-
* Runs all registered disposers in reverse order.
|
|
15
|
-
*
|
|
16
|
-
* @returns {void}
|
|
17
|
-
*/
|
|
18
|
-
dispose(): void;
|
|
19
|
-
/**
|
|
20
|
-
* Whether disposal has run.
|
|
21
|
-
*
|
|
22
|
-
* @returns {boolean} True when dispose() has already been called.
|
|
23
|
-
*/
|
|
24
|
-
get disposed(): boolean;
|
|
25
|
-
/**
|
|
26
|
-
* Read-only list of registered disposers.
|
|
27
|
-
*
|
|
28
|
-
* @returns {Array<() => void>} Snapshot of disposer callbacks.
|
|
29
|
-
*/
|
|
30
|
-
get disposers(): Array<() => void>;
|
|
31
|
-
#private;
|
|
32
|
-
}
|
|
33
|
-
declare const _default: Disposer;
|
|
34
|
-
export default _default;
|
|
35
|
-
//# sourceMappingURL=Disposer.d.ts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"file": "Disposer.d.ts",
|
|
4
|
-
"sourceRoot": "",
|
|
5
|
-
"sources": [
|
|
6
|
-
"../../../browser/lib/Disposer.js"
|
|
7
|
-
],
|
|
8
|
-
"names": [],
|
|
9
|
-
"mappings": "AAAA;;;GAGG;AACH;IAIE;;;;;OAKG;IACH,2BAHW,MAAM,IAAI,GACR,MAAM,IAAI,CAStB;IAED;;;;OAIG;IACH,WAFa,IAAI,CAoBhB;IAED;;;;OAIG;IACH,gBAFa,OAAO,CAInB;IAED;;;;OAIG;IACH,iBAFa,KAAK,CAAC,MAAM,IAAI,CAAC,CAI7B;;CAQF"
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare const _default: typeof PipeClass;
|
|
2
|
-
export default _default;
|
|
3
|
-
declare class PipeClass {
|
|
4
|
-
static source(func: any): PipeClass;
|
|
5
|
-
constructor(func: any);
|
|
6
|
-
name: string;
|
|
7
|
-
then(func: any): Promise<this>;
|
|
8
|
-
get value(): any;
|
|
9
|
-
#private;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=Hook.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Hook.d.ts","sourceRoot":"","sources":["../../../browser/lib/Hook.js"],"names":[],"mappings":";;AAGA;IAYE,oCAEC;IARD,uBAIC;IATD,aAAa;IAeb,+BAgBC;IAED,iBAEC;;CAuBF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../../browser/lib/test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"test2.d.ts","sourceRoot":"","sources":["../../../browser/lib/test2.js"],"names":[],"mappings":""}
|
package/src/types/lib/Chide.d.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom error class for toolkit errors.
|
|
3
|
-
* Provides error chaining, trace management, and formatted error reporting.
|
|
4
|
-
*/
|
|
5
|
-
export default class Chide extends Sass {
|
|
6
|
-
/**
|
|
7
|
-
* Creates an Chide from an existing Error object with additional
|
|
8
|
-
* trace message.
|
|
9
|
-
*
|
|
10
|
-
* @param {Error} error - The original error object
|
|
11
|
-
* @param {string} message - Additional trace message to add
|
|
12
|
-
* @returns {Chide} New Chide instance with trace from the original error
|
|
13
|
-
* @throws {Chide} If the first parameter is not an Error instance
|
|
14
|
-
*/
|
|
15
|
-
static from(error: Error, message: string): Chide;
|
|
16
|
-
/**
|
|
17
|
-
* Factory method to create or enhance Sass instances.
|
|
18
|
-
* If error parameter is provided, enhances existing Sass or wraps
|
|
19
|
-
* other errors. Otherwise creates a new Sass instance.
|
|
20
|
-
*
|
|
21
|
-
* @param {string} message - The error message
|
|
22
|
-
* @param {Error|Sass|Tantrum|Chide} [error] - Optional existing error to wrap or enhance
|
|
23
|
-
* @returns {Chide} New or enhanced Sass instance
|
|
24
|
-
*/
|
|
25
|
-
static "new"(message: string, error?: Error | Sass | Tantrum | Chide): Chide;
|
|
26
|
-
/**
|
|
27
|
-
* Adds a trace message and returns this instance for chaining.
|
|
28
|
-
*
|
|
29
|
-
* @param {string} message - The trace message to add
|
|
30
|
-
* @returns {this} This Chide instance for method chaining
|
|
31
|
-
*/
|
|
32
|
-
addTrace(message: string): this;
|
|
33
|
-
#private;
|
|
34
|
-
}
|
|
35
|
-
import Sass from "./Sass.js";
|
|
36
|
-
import Tantrum from "./Tantrum.js";
|
|
37
|
-
//# sourceMappingURL=Chide.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Chide.d.ts","sourceRoot":"","sources":["../../lib/Chide.js"],"names":[],"mappings":"AAkBA;;;GAGG;AACH;IA2GE;;;;;;;;OAQG;IACH,mBALW,KAAK,WACL,MAAM,GACJ,KAAK,CAWjB;IAED;;;;;;;;OAQG;IACH,sBAJW,MAAM,UACN,KAAK,GAAC,IAAI,GAAC,OAAO,GAAC,KAAK,GACtB,KAAK,CAWjB;IA/GD;;;;;OAKG;IACH,kBAHW,MAAM,GACJ,IAAI,CAShB;;CAmGF;iBAzJgB,WAAW;oBAER,cAAc"}
|