@mdgate/image 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 mdgate
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # @mdgate/image
2
+
3
+ Registers an image-to-markdown function with `create()`. The function can be `@mdgate/ai`, Apple OCR, or anything else that returns markdown.
4
+
5
+ ```ts
6
+ import { create } from '@mdgate/core';
7
+ import { image } from '@mdgate/image';
8
+ import { pdf } from '@mdgate/pdf';
9
+ import { ai } from '@mdgate/ai';
10
+
11
+ const convert = create([
12
+ pdf(),
13
+ image(ai({ baseURL, apiKey, model }).convertImage),
14
+ ]);
15
+ ```
@@ -0,0 +1,3 @@
1
+ import type { ConvertImage, ImagePlugin } from './types.js';
2
+ /** Register an image-to-markdown function with `create([pdf(), image(fn)])`. */
3
+ export declare function image(convert: ConvertImage): ImagePlugin;
@@ -0,0 +1,2 @@
1
+ export { image } from './image.js';
2
+ export type { ConvertImage, ImageInput, ImageMime, ImagePlugin } from './types.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ function I(m){return{kind:"image",convert:m}}export{I as image};
@@ -0,0 +1,13 @@
1
+ export type ImageMime = 'image/jpeg' | 'image/png' | 'image/webp';
2
+ export type ImageInput = {
3
+ bytes: Uint8Array;
4
+ mime: ImageMime;
5
+ /** 1-based page number when the image came from a paged document. */
6
+ page?: number;
7
+ };
8
+ /** Convert an image the format converter cannot handle into markdown. */
9
+ export type ConvertImage = (image: ImageInput) => Promise<string>;
10
+ export type ImagePlugin = {
11
+ readonly kind: 'image';
12
+ readonly convert: ConvertImage;
13
+ };
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@mdgate/image",
3
+ "version": "0.1.0",
4
+ "description": "Image-to-markdown plugin for mdgate: image(fn)",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "main": "./dist/index.js",
15
+ "types": "./dist/index.d.ts",
16
+ "files": [
17
+ "dist/**/*.js",
18
+ "dist/**/*.d.ts"
19
+ ],
20
+ "scripts": {
21
+ "build": "bun ../../scripts/build-package.ts",
22
+ "prepublishOnly": "bun run build"
23
+ },
24
+ "dependencies": {
25
+ "@mdgate/core": "0.1.2"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
30
+ "engines": {
31
+ "node": ">=20"
32
+ },
33
+ "keywords": [
34
+ "mdgate",
35
+ "markdown",
36
+ "image"
37
+ ]
38
+ }