utilium 2.8.8 → 3.1.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/dist/buffer.d.ts +0 -7
- package/dist/buffer.js +0 -36
- package/dist/requests.d.ts +0 -22
- package/dist/requests.js +0 -6
- package/dist/shell.d.ts +5 -4
- package/dist/shell.js +37 -4
- package/dist/types.d.ts +1 -12
- package/eslint.shared.js +2 -1
- package/package.json +11 -2
package/dist/buffer.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Mutable } from './objects.js';
|
|
2
1
|
/**
|
|
3
2
|
* A generic constructor for an `ArrayBufferView`
|
|
4
3
|
*/
|
|
@@ -229,12 +228,6 @@ export interface TypedArrayConstructor {
|
|
|
229
228
|
*/
|
|
230
229
|
export declare function extendBuffer<T extends ArrayBufferLike | ArrayBufferView>(buffer: T, newByteLength: number): T;
|
|
231
230
|
export declare function toUint8Array(buffer: ArrayBufferLike | ArrayBufferView): Uint8Array;
|
|
232
|
-
/**
|
|
233
|
-
* @hidden @deprecated
|
|
234
|
-
*/
|
|
235
|
-
export declare function initView<T extends ArrayBufferLike = ArrayBuffer>(view: Mutable<ArrayBufferView<T> & {
|
|
236
|
-
BYTES_PER_ELEMENT?: number;
|
|
237
|
-
}>, buffer?: T | ArrayBufferView<T> | ArrayLike<number> | number, byteOffset?: number, byteLength?: number): void;
|
|
238
231
|
/** A generic view of an array buffer */
|
|
239
232
|
export declare class BufferView<T extends ArrayBufferLike = ArrayBufferLike> extends DataView<T> implements ArrayBufferView<T> {
|
|
240
233
|
constructor(_buffer?: T | ArrayBufferView<T> | ArrayLike<number> | number, _byteOffset?: number, _byteLength?: number);
|
package/dist/buffer.js
CHANGED
|
@@ -39,42 +39,6 @@ export function toUint8Array(buffer) {
|
|
|
39
39
|
return new Uint8Array(buffer);
|
|
40
40
|
return new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength);
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
43
|
-
* @hidden @deprecated
|
|
44
|
-
*/
|
|
45
|
-
export function initView(view, buffer, byteOffset, byteLength) {
|
|
46
|
-
if (typeof buffer == 'number') {
|
|
47
|
-
view.buffer = new ArrayBuffer(buffer);
|
|
48
|
-
view.byteOffset = 0;
|
|
49
|
-
view.byteLength = buffer;
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
if (!buffer
|
|
53
|
-
|| buffer instanceof ArrayBuffer
|
|
54
|
-
|| (globalThis.SharedArrayBuffer && buffer instanceof SharedArrayBuffer)) {
|
|
55
|
-
const size = byteLength
|
|
56
|
-
?? view.constructor?.size // Memium types
|
|
57
|
-
?? buffer?.byteLength
|
|
58
|
-
?? 0;
|
|
59
|
-
view.buffer = buffer ?? new ArrayBuffer(size);
|
|
60
|
-
view.byteOffset = byteOffset ?? 0;
|
|
61
|
-
view.byteLength = size;
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (ArrayBuffer.isView(buffer)) {
|
|
65
|
-
view.buffer = buffer.buffer;
|
|
66
|
-
view.byteOffset = buffer.byteOffset;
|
|
67
|
-
view.byteLength = buffer.byteLength;
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const u8 = new Uint8Array(buffer.length);
|
|
71
|
-
view.buffer = u8.buffer;
|
|
72
|
-
view.byteOffset = 0;
|
|
73
|
-
view.byteLength = u8.length;
|
|
74
|
-
for (let i = 0; i < u8.length; i++) {
|
|
75
|
-
u8[i] = buffer[i];
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
42
|
/** A generic view of an array buffer */
|
|
79
43
|
export class BufferView extends DataView {
|
|
80
44
|
constructor(_buffer, _byteOffset, _byteLength) {
|
package/dist/requests.d.ts
CHANGED
|
@@ -4,16 +4,6 @@
|
|
|
4
4
|
* Copyright (c) 2025 James Prevett
|
|
5
5
|
*/
|
|
6
6
|
import * as cache from './cache.js';
|
|
7
|
-
/** @deprecated Use `cache.Options` */
|
|
8
|
-
export type ResourceCacheOptions = cache.Options;
|
|
9
|
-
/** @deprecated Use `cache.Resource` */
|
|
10
|
-
export declare const ResourceCache: typeof cache.Resource;
|
|
11
|
-
/** @deprecated Use `cache.Resource` */
|
|
12
|
-
export type ResourceCache = cache.Resource<string>;
|
|
13
|
-
/** @deprecated Use `cache.Range` */
|
|
14
|
-
export type CacheRange = cache.Range;
|
|
15
|
-
/** @deprecated Use `cache.Options` */
|
|
16
|
-
export type CacheOptions = cache.Options;
|
|
17
7
|
/**
|
|
18
8
|
* @internal
|
|
19
9
|
*/
|
|
@@ -29,18 +19,10 @@ export type Issue = {
|
|
|
29
19
|
tag: 'fetch' | 'size';
|
|
30
20
|
message: string;
|
|
31
21
|
} | Error;
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated Use `Issue`
|
|
34
|
-
*/
|
|
35
|
-
export type RequestError = Issue;
|
|
36
22
|
export interface Options extends cache.Options {
|
|
37
23
|
/** Optionally provide a function for logging warnings */
|
|
38
24
|
warn?(message: string): unknown;
|
|
39
25
|
}
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated Use `Options`
|
|
42
|
-
*/
|
|
43
|
-
export type RequestOptions = Options;
|
|
44
26
|
export interface GetOptions extends Options {
|
|
45
27
|
/**
|
|
46
28
|
* When using range requests,
|
|
@@ -58,10 +40,6 @@ export interface GetOptions extends Options {
|
|
|
58
40
|
* @throws RequestError
|
|
59
41
|
*/
|
|
60
42
|
export declare function get(url: string, options: GetOptions, init?: RequestInit): Promise<Uint8Array>;
|
|
61
|
-
/**
|
|
62
|
-
* @deprecated Use `get`
|
|
63
|
-
*/
|
|
64
|
-
export declare const GET: typeof get;
|
|
65
43
|
/**
|
|
66
44
|
* Synchronously gets a cached resource
|
|
67
45
|
* Assumes you pass valid start and end when using ranges
|
package/dist/requests.js
CHANGED
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
* Copyright (c) 2025 James Prevett
|
|
6
6
|
*/
|
|
7
7
|
import * as cache from './cache.js';
|
|
8
|
-
/** @deprecated Use `cache.Resource` */
|
|
9
|
-
export const ResourceCache = cache.Resource;
|
|
10
8
|
/* eslint-disable @typescript-eslint/only-throw-error */
|
|
11
9
|
/**
|
|
12
10
|
* @internal
|
|
@@ -72,10 +70,6 @@ export async function get(url, options, init = {}) {
|
|
|
72
70
|
const region = resource.regionAt(start);
|
|
73
71
|
return region.data.subarray(start - region.offset, end - region.offset);
|
|
74
72
|
}
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated Use `get`
|
|
77
|
-
*/
|
|
78
|
-
export const GET = get;
|
|
79
73
|
/**
|
|
80
74
|
* Synchronously gets a cached resource
|
|
81
75
|
* Assumes you pass valid start and end when using ranges
|
package/dist/shell.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { Terminal } from '@xterm/xterm';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
3
|
+
* Parse a line into arguments.
|
|
4
|
+
* Supports single and double quoted strings as well as backslash escaping.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
export declare function splitIntoArgs(input: string): string[];
|
|
6
7
|
export interface ShellOptions {
|
|
7
8
|
/**
|
|
8
9
|
* The terminal associated with the context
|
|
@@ -40,6 +41,6 @@ export interface ShellContext extends Required<ShellOptions> {
|
|
|
40
41
|
inputs: string[];
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
|
-
*
|
|
44
|
+
* A simple wrapper for xterm.js that makes implementing shells easier.
|
|
44
45
|
*/
|
|
45
46
|
export declare function createShell(options: ShellOptions): ShellContext;
|
package/dist/shell.js
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* Parse a line into arguments.
|
|
3
|
+
* Supports single and double quoted strings as well as backslash escaping.
|
|
5
4
|
*/
|
|
5
|
+
export function splitIntoArgs(input) {
|
|
6
|
+
input = input.trim();
|
|
7
|
+
const args = [];
|
|
8
|
+
let current = '', inQuote = null, escape = false;
|
|
9
|
+
for (const char of input) {
|
|
10
|
+
if (escape) {
|
|
11
|
+
current += char;
|
|
12
|
+
escape = false;
|
|
13
|
+
}
|
|
14
|
+
else if (char === '\\') {
|
|
15
|
+
escape = true;
|
|
16
|
+
}
|
|
17
|
+
else if (inQuote) {
|
|
18
|
+
if (char === inQuote)
|
|
19
|
+
inQuote = null;
|
|
20
|
+
else
|
|
21
|
+
current += char;
|
|
22
|
+
}
|
|
23
|
+
else if (char === '"' || char === "'")
|
|
24
|
+
inQuote = char;
|
|
25
|
+
else if (/\s/.test(char)) {
|
|
26
|
+
if (current.length) {
|
|
27
|
+
args.push(current);
|
|
28
|
+
current = '';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
current += char;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (current.length)
|
|
36
|
+
args.push(current);
|
|
37
|
+
return args;
|
|
38
|
+
}
|
|
6
39
|
async function handleData($, data) {
|
|
7
40
|
if ($.index == -1) {
|
|
8
41
|
$.currentInput = $.input;
|
|
@@ -67,7 +100,7 @@ async function handleData($, data) {
|
|
|
67
100
|
}
|
|
68
101
|
}
|
|
69
102
|
/**
|
|
70
|
-
*
|
|
103
|
+
* A simple wrapper for xterm.js that makes implementing shells easier.
|
|
71
104
|
*/
|
|
72
105
|
export function createShell(options) {
|
|
73
106
|
const context = {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Subtract } from './type-math.js';
|
|
1
|
+
import type { Push } from './array.js';
|
|
3
2
|
/**
|
|
4
3
|
* Expands the type T (for intellisense and debugging)
|
|
5
4
|
* @see https://stackoverflow.com/a/69288824/17637456
|
|
@@ -24,16 +23,6 @@ type StrictUnionHelper<T, TAll> = T extends unknown ? T & Partial<Record<Exclude
|
|
|
24
23
|
* @see https://stackoverflow.com/a/65805753/17637456
|
|
25
24
|
*/
|
|
26
25
|
export type StrictUnion<T> = Expand<StrictUnionHelper<T, T>>;
|
|
27
|
-
/**
|
|
28
|
-
* Increments N
|
|
29
|
-
* @deprecated Use Add<N, 1> instead
|
|
30
|
-
*/
|
|
31
|
-
export type Increment<N extends number> = Length<Unshift<FromLength<N>, 0>>;
|
|
32
|
-
/**
|
|
33
|
-
* Decrements N
|
|
34
|
-
* @deprecated Use Subtract<N, 1> instead
|
|
35
|
-
*/
|
|
36
|
-
export type Decrement<N extends number> = Subtract<N, 1>;
|
|
37
26
|
/**
|
|
38
27
|
* Keys of a Map
|
|
39
28
|
*/
|
package/eslint.shared.js
CHANGED
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
* Copyright (c) 2025 James Prevett
|
|
5
5
|
*/
|
|
6
6
|
import eslint from '@eslint/js';
|
|
7
|
+
import { defineConfig } from 'eslint/config';
|
|
7
8
|
import globals from 'globals';
|
|
8
9
|
import tseslint from 'typescript-eslint';
|
|
9
10
|
|
|
10
11
|
export default function (tsconfigRootDir) {
|
|
11
|
-
return
|
|
12
|
+
return defineConfig(
|
|
12
13
|
{
|
|
13
14
|
name: 'Utilium',
|
|
14
15
|
extends: [eslint.configs.recommended, ...tseslint.configs.recommendedTypeChecked],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "utilium",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Typescript utilities",
|
|
5
5
|
"funding": {
|
|
6
6
|
"type": "individual",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": "./dist/index.js",
|
|
14
|
-
"./*": "./dist
|
|
14
|
+
"./*": "./dist/*.js",
|
|
15
15
|
"./eslint": "./eslint.shared.js"
|
|
16
16
|
},
|
|
17
17
|
"bin": {
|
|
@@ -57,5 +57,14 @@
|
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">=22.0.0"
|
|
60
|
+
},
|
|
61
|
+
"prettier": {
|
|
62
|
+
"singleQuote": true,
|
|
63
|
+
"useTabs": true,
|
|
64
|
+
"trailingComma": "es5",
|
|
65
|
+
"tabWidth": 4,
|
|
66
|
+
"printWidth": 120,
|
|
67
|
+
"arrowParens": "avoid",
|
|
68
|
+
"experimentalOperatorPosition": "start"
|
|
60
69
|
}
|
|
61
70
|
}
|