ipx 1.3.0 → 2.0.0-1
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/README.md +69 -41
- package/dist/cli.cjs +51 -21
- package/dist/cli.mjs +52 -18
- package/dist/index.cjs +42 -680
- package/dist/index.d.cts +59 -46
- package/dist/index.d.mts +59 -46
- package/dist/index.d.ts +59 -46
- package/dist/index.mjs +29 -665
- package/dist/shared/ipx.57fad794.mjs +709 -0
- package/dist/shared/ipx.680a50a5.cjs +723 -0
- package/package.json +15 -10
package/dist/index.d.cts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Color, KernelEnum, Sharp, SharpOptions } from 'sharp';
|
|
2
|
+
import * as h3 from 'h3';
|
|
3
|
+
import { Storage, Driver } from 'unstorage';
|
|
3
4
|
|
|
4
|
-
interface ImageMeta {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
type: string;
|
|
8
|
-
mimeType: string;
|
|
9
|
-
}
|
|
10
|
-
interface SourceData {
|
|
11
|
-
mtime?: Date;
|
|
12
|
-
maxAge?: number;
|
|
13
|
-
getData: () => Promise<Buffer>;
|
|
14
|
-
}
|
|
15
|
-
type Source = (source: string, requestOptions?: any) => Promise<SourceData>;
|
|
16
|
-
type SourceFactory<T = Record<string, any>> = (options: T) => Source;
|
|
17
5
|
interface HandlerContext {
|
|
18
6
|
quality?: number;
|
|
19
7
|
fit?: "contain" | "cover" | "fill" | "inside" | "outside";
|
|
@@ -28,6 +16,23 @@ interface Handler {
|
|
|
28
16
|
order?: number;
|
|
29
17
|
apply: (context: HandlerContext, pipe: Sharp, ...arguments_: any[]) => any;
|
|
30
18
|
}
|
|
19
|
+
type IPXStorageMeta = {
|
|
20
|
+
mtime?: Date | number | string;
|
|
21
|
+
maxAge?: number | string;
|
|
22
|
+
};
|
|
23
|
+
type IPXStorageOptions = Record<string, unknown>;
|
|
24
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
25
|
+
interface IPXStorage {
|
|
26
|
+
name: string;
|
|
27
|
+
getMeta: (id: string, opts?: IPXStorageOptions) => MaybePromise<IPXStorageMeta | undefined>;
|
|
28
|
+
getData: (id: string, opts?: IPXStorageOptions) => MaybePromise<ArrayBuffer | undefined>;
|
|
29
|
+
}
|
|
30
|
+
interface ImageMeta {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
type: string;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
declare const quality: Handler;
|
|
33
38
|
declare const fit: Handler;
|
|
@@ -102,43 +107,51 @@ declare namespace Handlers {
|
|
|
102
107
|
|
|
103
108
|
type HandlerName = keyof typeof Handlers;
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
type IPXSourceMeta = {
|
|
111
|
+
mtime?: Date;
|
|
112
|
+
maxAge?: number;
|
|
113
|
+
};
|
|
108
114
|
type IPX = (id: string, modifiers?: Partial<Record<HandlerName | "f" | "format" | "a" | "animated", string>>, requestOptions?: any) => {
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
getSourceMeta: () => Promise<IPXSourceMeta>;
|
|
116
|
+
process: () => Promise<{
|
|
111
117
|
data: Buffer;
|
|
112
118
|
meta: ImageMeta;
|
|
113
119
|
format: string;
|
|
114
120
|
}>;
|
|
115
121
|
};
|
|
116
|
-
|
|
117
|
-
dir?: false | string;
|
|
122
|
+
type IPXOptions = {
|
|
118
123
|
maxAge?: number;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
declare function createIPX(userOptions:
|
|
124
|
+
alias?: Record<string, string>;
|
|
125
|
+
sharpOptions?: SharpOptions;
|
|
126
|
+
storage: IPXStorage;
|
|
127
|
+
httpStorage?: IPXStorage;
|
|
128
|
+
};
|
|
129
|
+
declare function createIPX(userOptions: IPXOptions): IPX;
|
|
125
130
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
declare function
|
|
131
|
+
declare function createIPXH3Handler(ipx: IPX): h3.EventHandler<h3.EventHandlerRequest, Promise<Buffer | {
|
|
132
|
+
error: {
|
|
133
|
+
message: string;
|
|
134
|
+
};
|
|
135
|
+
} | null>>;
|
|
136
|
+
declare function createIPXH3App(ipx: IPX): h3.App;
|
|
137
|
+
declare function createIPXWebServer(ipx: IPX): h3.WebHandler;
|
|
138
|
+
declare function createIPXNodeServer(ipx: IPX): h3.NodeListener;
|
|
139
|
+
declare function createIPXPlainServer(ipx: IPX): h3.PlainHandler;
|
|
140
|
+
|
|
141
|
+
type HTTPStorageOptions = {
|
|
142
|
+
fetchOptions?: RequestInit;
|
|
143
|
+
maxAge?: number;
|
|
144
|
+
domains?: string | string[];
|
|
145
|
+
allowAllDomains?: boolean;
|
|
146
|
+
};
|
|
147
|
+
declare function ipxHttpStorage(_options?: HTTPStorageOptions): IPXStorage;
|
|
148
|
+
|
|
149
|
+
type NodeFSSOptions = {
|
|
150
|
+
dir?: string;
|
|
151
|
+
maxAge?: number;
|
|
152
|
+
};
|
|
153
|
+
declare function ipxFSStorage(_options?: NodeFSSOptions): IPXStorage;
|
|
154
|
+
|
|
155
|
+
declare function unstorageToIPXStorage(storage: Storage | Driver, prefix: string): IPXStorage;
|
|
143
156
|
|
|
144
|
-
export { type
|
|
157
|
+
export { type HTTPStorageOptions, type Handler, type HandlerContext, type IPX, type IPXOptions, type IPXStorage, type IPXStorageMeta, type IPXStorageOptions, type ImageMeta, type NodeFSSOptions, createIPX, createIPXH3App, createIPXH3Handler, createIPXNodeServer, createIPXPlainServer, createIPXWebServer, ipxFSStorage, ipxHttpStorage, unstorageToIPXStorage };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Color, KernelEnum, Sharp, SharpOptions } from 'sharp';
|
|
2
|
+
import * as h3 from 'h3';
|
|
3
|
+
import { Storage, Driver } from 'unstorage';
|
|
3
4
|
|
|
4
|
-
interface ImageMeta {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
type: string;
|
|
8
|
-
mimeType: string;
|
|
9
|
-
}
|
|
10
|
-
interface SourceData {
|
|
11
|
-
mtime?: Date;
|
|
12
|
-
maxAge?: number;
|
|
13
|
-
getData: () => Promise<Buffer>;
|
|
14
|
-
}
|
|
15
|
-
type Source = (source: string, requestOptions?: any) => Promise<SourceData>;
|
|
16
|
-
type SourceFactory<T = Record<string, any>> = (options: T) => Source;
|
|
17
5
|
interface HandlerContext {
|
|
18
6
|
quality?: number;
|
|
19
7
|
fit?: "contain" | "cover" | "fill" | "inside" | "outside";
|
|
@@ -28,6 +16,23 @@ interface Handler {
|
|
|
28
16
|
order?: number;
|
|
29
17
|
apply: (context: HandlerContext, pipe: Sharp, ...arguments_: any[]) => any;
|
|
30
18
|
}
|
|
19
|
+
type IPXStorageMeta = {
|
|
20
|
+
mtime?: Date | number | string;
|
|
21
|
+
maxAge?: number | string;
|
|
22
|
+
};
|
|
23
|
+
type IPXStorageOptions = Record<string, unknown>;
|
|
24
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
25
|
+
interface IPXStorage {
|
|
26
|
+
name: string;
|
|
27
|
+
getMeta: (id: string, opts?: IPXStorageOptions) => MaybePromise<IPXStorageMeta | undefined>;
|
|
28
|
+
getData: (id: string, opts?: IPXStorageOptions) => MaybePromise<ArrayBuffer | undefined>;
|
|
29
|
+
}
|
|
30
|
+
interface ImageMeta {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
type: string;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
declare const quality: Handler;
|
|
33
38
|
declare const fit: Handler;
|
|
@@ -102,43 +107,51 @@ declare namespace Handlers {
|
|
|
102
107
|
|
|
103
108
|
type HandlerName = keyof typeof Handlers;
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
type IPXSourceMeta = {
|
|
111
|
+
mtime?: Date;
|
|
112
|
+
maxAge?: number;
|
|
113
|
+
};
|
|
108
114
|
type IPX = (id: string, modifiers?: Partial<Record<HandlerName | "f" | "format" | "a" | "animated", string>>, requestOptions?: any) => {
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
getSourceMeta: () => Promise<IPXSourceMeta>;
|
|
116
|
+
process: () => Promise<{
|
|
111
117
|
data: Buffer;
|
|
112
118
|
meta: ImageMeta;
|
|
113
119
|
format: string;
|
|
114
120
|
}>;
|
|
115
121
|
};
|
|
116
|
-
|
|
117
|
-
dir?: false | string;
|
|
122
|
+
type IPXOptions = {
|
|
118
123
|
maxAge?: number;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
declare function createIPX(userOptions:
|
|
124
|
+
alias?: Record<string, string>;
|
|
125
|
+
sharpOptions?: SharpOptions;
|
|
126
|
+
storage: IPXStorage;
|
|
127
|
+
httpStorage?: IPXStorage;
|
|
128
|
+
};
|
|
129
|
+
declare function createIPX(userOptions: IPXOptions): IPX;
|
|
125
130
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
declare function
|
|
131
|
+
declare function createIPXH3Handler(ipx: IPX): h3.EventHandler<h3.EventHandlerRequest, Promise<Buffer | {
|
|
132
|
+
error: {
|
|
133
|
+
message: string;
|
|
134
|
+
};
|
|
135
|
+
} | null>>;
|
|
136
|
+
declare function createIPXH3App(ipx: IPX): h3.App;
|
|
137
|
+
declare function createIPXWebServer(ipx: IPX): h3.WebHandler;
|
|
138
|
+
declare function createIPXNodeServer(ipx: IPX): h3.NodeListener;
|
|
139
|
+
declare function createIPXPlainServer(ipx: IPX): h3.PlainHandler;
|
|
140
|
+
|
|
141
|
+
type HTTPStorageOptions = {
|
|
142
|
+
fetchOptions?: RequestInit;
|
|
143
|
+
maxAge?: number;
|
|
144
|
+
domains?: string | string[];
|
|
145
|
+
allowAllDomains?: boolean;
|
|
146
|
+
};
|
|
147
|
+
declare function ipxHttpStorage(_options?: HTTPStorageOptions): IPXStorage;
|
|
148
|
+
|
|
149
|
+
type NodeFSSOptions = {
|
|
150
|
+
dir?: string;
|
|
151
|
+
maxAge?: number;
|
|
152
|
+
};
|
|
153
|
+
declare function ipxFSStorage(_options?: NodeFSSOptions): IPXStorage;
|
|
154
|
+
|
|
155
|
+
declare function unstorageToIPXStorage(storage: Storage | Driver, prefix: string): IPXStorage;
|
|
143
156
|
|
|
144
|
-
export { type
|
|
157
|
+
export { type HTTPStorageOptions, type Handler, type HandlerContext, type IPX, type IPXOptions, type IPXStorage, type IPXStorageMeta, type IPXStorageOptions, type ImageMeta, type NodeFSSOptions, createIPX, createIPXH3App, createIPXH3Handler, createIPXNodeServer, createIPXPlainServer, createIPXWebServer, ipxFSStorage, ipxHttpStorage, unstorageToIPXStorage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { Color, KernelEnum, Sharp, SharpOptions } from 'sharp';
|
|
2
|
+
import * as h3 from 'h3';
|
|
3
|
+
import { Storage, Driver } from 'unstorage';
|
|
3
4
|
|
|
4
|
-
interface ImageMeta {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
type: string;
|
|
8
|
-
mimeType: string;
|
|
9
|
-
}
|
|
10
|
-
interface SourceData {
|
|
11
|
-
mtime?: Date;
|
|
12
|
-
maxAge?: number;
|
|
13
|
-
getData: () => Promise<Buffer>;
|
|
14
|
-
}
|
|
15
|
-
type Source = (source: string, requestOptions?: any) => Promise<SourceData>;
|
|
16
|
-
type SourceFactory<T = Record<string, any>> = (options: T) => Source;
|
|
17
5
|
interface HandlerContext {
|
|
18
6
|
quality?: number;
|
|
19
7
|
fit?: "contain" | "cover" | "fill" | "inside" | "outside";
|
|
@@ -28,6 +16,23 @@ interface Handler {
|
|
|
28
16
|
order?: number;
|
|
29
17
|
apply: (context: HandlerContext, pipe: Sharp, ...arguments_: any[]) => any;
|
|
30
18
|
}
|
|
19
|
+
type IPXStorageMeta = {
|
|
20
|
+
mtime?: Date | number | string;
|
|
21
|
+
maxAge?: number | string;
|
|
22
|
+
};
|
|
23
|
+
type IPXStorageOptions = Record<string, unknown>;
|
|
24
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
25
|
+
interface IPXStorage {
|
|
26
|
+
name: string;
|
|
27
|
+
getMeta: (id: string, opts?: IPXStorageOptions) => MaybePromise<IPXStorageMeta | undefined>;
|
|
28
|
+
getData: (id: string, opts?: IPXStorageOptions) => MaybePromise<ArrayBuffer | undefined>;
|
|
29
|
+
}
|
|
30
|
+
interface ImageMeta {
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
type: string;
|
|
34
|
+
mimeType: string;
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
declare const quality: Handler;
|
|
33
38
|
declare const fit: Handler;
|
|
@@ -102,43 +107,51 @@ declare namespace Handlers {
|
|
|
102
107
|
|
|
103
108
|
type HandlerName = keyof typeof Handlers;
|
|
104
109
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
110
|
+
type IPXSourceMeta = {
|
|
111
|
+
mtime?: Date;
|
|
112
|
+
maxAge?: number;
|
|
113
|
+
};
|
|
108
114
|
type IPX = (id: string, modifiers?: Partial<Record<HandlerName | "f" | "format" | "a" | "animated", string>>, requestOptions?: any) => {
|
|
109
|
-
|
|
110
|
-
|
|
115
|
+
getSourceMeta: () => Promise<IPXSourceMeta>;
|
|
116
|
+
process: () => Promise<{
|
|
111
117
|
data: Buffer;
|
|
112
118
|
meta: ImageMeta;
|
|
113
119
|
format: string;
|
|
114
120
|
}>;
|
|
115
121
|
};
|
|
116
|
-
|
|
117
|
-
dir?: false | string;
|
|
122
|
+
type IPXOptions = {
|
|
118
123
|
maxAge?: number;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
declare function createIPX(userOptions:
|
|
124
|
+
alias?: Record<string, string>;
|
|
125
|
+
sharpOptions?: SharpOptions;
|
|
126
|
+
storage: IPXStorage;
|
|
127
|
+
httpStorage?: IPXStorage;
|
|
128
|
+
};
|
|
129
|
+
declare function createIPX(userOptions: IPXOptions): IPX;
|
|
125
130
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
declare function
|
|
131
|
+
declare function createIPXH3Handler(ipx: IPX): h3.EventHandler<h3.EventHandlerRequest, Promise<Buffer | {
|
|
132
|
+
error: {
|
|
133
|
+
message: string;
|
|
134
|
+
};
|
|
135
|
+
} | null>>;
|
|
136
|
+
declare function createIPXH3App(ipx: IPX): h3.App;
|
|
137
|
+
declare function createIPXWebServer(ipx: IPX): h3.WebHandler;
|
|
138
|
+
declare function createIPXNodeServer(ipx: IPX): h3.NodeListener;
|
|
139
|
+
declare function createIPXPlainServer(ipx: IPX): h3.PlainHandler;
|
|
140
|
+
|
|
141
|
+
type HTTPStorageOptions = {
|
|
142
|
+
fetchOptions?: RequestInit;
|
|
143
|
+
maxAge?: number;
|
|
144
|
+
domains?: string | string[];
|
|
145
|
+
allowAllDomains?: boolean;
|
|
146
|
+
};
|
|
147
|
+
declare function ipxHttpStorage(_options?: HTTPStorageOptions): IPXStorage;
|
|
148
|
+
|
|
149
|
+
type NodeFSSOptions = {
|
|
150
|
+
dir?: string;
|
|
151
|
+
maxAge?: number;
|
|
152
|
+
};
|
|
153
|
+
declare function ipxFSStorage(_options?: NodeFSSOptions): IPXStorage;
|
|
154
|
+
|
|
155
|
+
declare function unstorageToIPXStorage(storage: Storage | Driver, prefix: string): IPXStorage;
|
|
143
156
|
|
|
144
|
-
export { type
|
|
157
|
+
export { type HTTPStorageOptions, type Handler, type HandlerContext, type IPX, type IPXOptions, type IPXStorage, type IPXStorageMeta, type IPXStorageOptions, type ImageMeta, type NodeFSSOptions, createIPX, createIPXH3App, createIPXH3Handler, createIPXNodeServer, createIPXPlainServer, createIPXWebServer, ipxFSStorage, ipxHttpStorage, unstorageToIPXStorage };
|