@unngh/google-vision 1.0.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.
@@ -0,0 +1,107 @@
1
+ /**
2
+ * TypeScript type definitions for the dart2js-compiled google_vision
3
+ * runtime and the public API surface.
4
+ */
5
+ /**
6
+ * Raw handle returned by `GoogleVisionJs.create()`.
7
+ *
8
+ * Each method on this handle is a closure that captures the underlying
9
+ * Dart `GoogleVision` instance. Promise-returning methods use native
10
+ * JS `Promise`, automatically converted from Dart `Future` by dart2js.
11
+ */
12
+ interface VisionJsHandle {
13
+ /** Synchronous — returns the handle for chaining. */
14
+ withApiKey(apiKey: string): VisionJsHandle;
15
+ /** Asynchronous — resolves with the handle after JWT auth. */
16
+ withJwt(credentialsJson: string, scope?: string): Promise<VisionJsHandle>;
17
+ /** Image source can be a URL string or an object with `imageUri` / `content` (base64). */
18
+ imageLabelDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
19
+ imageTextDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
20
+ imageFaceDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
21
+ imageSafeSearchDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
22
+ imageCropHints(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
23
+ imageDocumentTextDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
24
+ imageProperties(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
25
+ imageLandmarkDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
26
+ imageLogoDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
27
+ imageObjectLocalization(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
28
+ imageWebDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
29
+ fileLabelDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
30
+ fileTextDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
31
+ fileDocumentTextDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
32
+ fileFaceDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
33
+ }
34
+ /**
35
+ * Image source: either a URL string or an object with `imageUri` or `content`.
36
+ */
37
+ interface ImageSource {
38
+ imageUri?: string;
39
+ content?: string;
40
+ }
41
+
42
+ /**
43
+ * Loads the dart2js-compiled runtime and returns the `GoogleVisionJs`
44
+ * namespace installed on `globalThis`. Dispatch is platform-specific — see
45
+ * `browser.ts` and `node.ts` for the actual loader implementations.
46
+ */
47
+
48
+ type DartRuntimeLoader = () => Promise<void>;
49
+
50
+ /**
51
+ * google_vision_js — public TypeScript API.
52
+ *
53
+ * This facade wraps the dart2js-compiled `google_vision` core, exposing an
54
+ * idiomatic JavaScript API: Promise-based methods, `image` and `file`
55
+ * sub-APIs that mirror the Dart API shape.
56
+ */
57
+
58
+ /** Sub-API for image-based Google Vision operations. */
59
+ declare class GoogleVisionImage {
60
+ private readonly handle;
61
+ constructor(handle: VisionJsHandle);
62
+ labelDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
63
+ textDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
64
+ faceDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
65
+ safeSearchDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
66
+ cropHints(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
67
+ documentTextDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
68
+ imageProperties(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
69
+ landmarkDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
70
+ logoDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
71
+ objectLocalization(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
72
+ webDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
73
+ }
74
+ /** Sub-API for file-based Google Vision operations (PDFs, GCS files). */
75
+ declare class GoogleVisionFile {
76
+ private readonly handle;
77
+ constructor(handle: VisionJsHandle);
78
+ labelDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
79
+ textDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
80
+ documentTextDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
81
+ faceDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
82
+ }
83
+ declare class GoogleVision$1 {
84
+ private readonly handle;
85
+ readonly image: GoogleVisionImage;
86
+ readonly file: GoogleVisionFile;
87
+ protected constructor(handle: VisionJsHandle);
88
+ static create(loader?: DartRuntimeLoader): Promise<GoogleVision$1>;
89
+ /** Authenticate using an API key (synchronous, chainable). */
90
+ withApiKey(apiKey: string): this;
91
+ /** Authenticate using JWT credentials (asynchronous, chainable). */
92
+ withJwt(credentialsJson: string, scope?: string): Promise<this>;
93
+ }
94
+
95
+ /**
96
+ * Node.js entrypoint for google_vision_js.
97
+ *
98
+ * dart2js output targets the browser runtime — it expects `self`,
99
+ * `window`, and `XMLHttpRequest` globals. We polyfill these before
100
+ * loading the compiled module.
101
+ */
102
+
103
+ declare class GoogleVision extends GoogleVision$1 {
104
+ static create(): Promise<GoogleVision>;
105
+ }
106
+
107
+ export { GoogleVision, type ImageSource };
package/dist/node.d.ts ADDED
@@ -0,0 +1,107 @@
1
+ /**
2
+ * TypeScript type definitions for the dart2js-compiled google_vision
3
+ * runtime and the public API surface.
4
+ */
5
+ /**
6
+ * Raw handle returned by `GoogleVisionJs.create()`.
7
+ *
8
+ * Each method on this handle is a closure that captures the underlying
9
+ * Dart `GoogleVision` instance. Promise-returning methods use native
10
+ * JS `Promise`, automatically converted from Dart `Future` by dart2js.
11
+ */
12
+ interface VisionJsHandle {
13
+ /** Synchronous — returns the handle for chaining. */
14
+ withApiKey(apiKey: string): VisionJsHandle;
15
+ /** Asynchronous — resolves with the handle after JWT auth. */
16
+ withJwt(credentialsJson: string, scope?: string): Promise<VisionJsHandle>;
17
+ /** Image source can be a URL string or an object with `imageUri` / `content` (base64). */
18
+ imageLabelDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
19
+ imageTextDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
20
+ imageFaceDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
21
+ imageSafeSearchDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
22
+ imageCropHints(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
23
+ imageDocumentTextDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
24
+ imageProperties(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
25
+ imageLandmarkDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
26
+ imageLogoDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
27
+ imageObjectLocalization(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
28
+ imageWebDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
29
+ fileLabelDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
30
+ fileTextDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
31
+ fileDocumentTextDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
32
+ fileFaceDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
33
+ }
34
+ /**
35
+ * Image source: either a URL string or an object with `imageUri` or `content`.
36
+ */
37
+ interface ImageSource {
38
+ imageUri?: string;
39
+ content?: string;
40
+ }
41
+
42
+ /**
43
+ * Loads the dart2js-compiled runtime and returns the `GoogleVisionJs`
44
+ * namespace installed on `globalThis`. Dispatch is platform-specific — see
45
+ * `browser.ts` and `node.ts` for the actual loader implementations.
46
+ */
47
+
48
+ type DartRuntimeLoader = () => Promise<void>;
49
+
50
+ /**
51
+ * google_vision_js — public TypeScript API.
52
+ *
53
+ * This facade wraps the dart2js-compiled `google_vision` core, exposing an
54
+ * idiomatic JavaScript API: Promise-based methods, `image` and `file`
55
+ * sub-APIs that mirror the Dart API shape.
56
+ */
57
+
58
+ /** Sub-API for image-based Google Vision operations. */
59
+ declare class GoogleVisionImage {
60
+ private readonly handle;
61
+ constructor(handle: VisionJsHandle);
62
+ labelDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
63
+ textDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
64
+ faceDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
65
+ safeSearchDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
66
+ cropHints(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
67
+ documentTextDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
68
+ imageProperties(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
69
+ landmarkDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
70
+ logoDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
71
+ objectLocalization(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any>[]>;
72
+ webDetection(imageSource: string | ImageSource, maxResults?: number): Promise<Record<string, any> | null>;
73
+ }
74
+ /** Sub-API for file-based Google Vision operations (PDFs, GCS files). */
75
+ declare class GoogleVisionFile {
76
+ private readonly handle;
77
+ constructor(handle: VisionJsHandle);
78
+ labelDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
79
+ textDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
80
+ documentTextDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
81
+ faceDetection(gcsUri: string, maxResults?: number): Promise<Record<string, any>[]>;
82
+ }
83
+ declare class GoogleVision$1 {
84
+ private readonly handle;
85
+ readonly image: GoogleVisionImage;
86
+ readonly file: GoogleVisionFile;
87
+ protected constructor(handle: VisionJsHandle);
88
+ static create(loader?: DartRuntimeLoader): Promise<GoogleVision$1>;
89
+ /** Authenticate using an API key (synchronous, chainable). */
90
+ withApiKey(apiKey: string): this;
91
+ /** Authenticate using JWT credentials (asynchronous, chainable). */
92
+ withJwt(credentialsJson: string, scope?: string): Promise<this>;
93
+ }
94
+
95
+ /**
96
+ * Node.js entrypoint for google_vision_js.
97
+ *
98
+ * dart2js output targets the browser runtime — it expects `self`,
99
+ * `window`, and `XMLHttpRequest` globals. We polyfill these before
100
+ * loading the compiled module.
101
+ */
102
+
103
+ declare class GoogleVision extends GoogleVision$1 {
104
+ static create(): Promise<GoogleVision>;
105
+ }
106
+
107
+ export { GoogleVision, type ImageSource };
package/dist/node.js ADDED
@@ -0,0 +1,127 @@
1
+ // src/runtime.ts
2
+ var cached;
3
+ async function getRuntime(loader) {
4
+ if (cached) return cached;
5
+ await loader();
6
+ const ns = globalThis.GoogleVisionJs;
7
+ if (!ns) {
8
+ throw new Error(
9
+ "google_vision_js runtime failed to initialise: globalThis.GoogleVisionJs was not installed."
10
+ );
11
+ }
12
+ cached = ns;
13
+ return ns;
14
+ }
15
+
16
+ // src/index.ts
17
+ var GoogleVisionImage = class {
18
+ constructor(handle) {
19
+ this.handle = handle;
20
+ }
21
+ handle;
22
+ labelDetection(imageSource, maxResults) {
23
+ return this.handle.imageLabelDetection(imageSource, maxResults);
24
+ }
25
+ textDetection(imageSource, maxResults) {
26
+ return this.handle.imageTextDetection(imageSource, maxResults);
27
+ }
28
+ faceDetection(imageSource, maxResults) {
29
+ return this.handle.imageFaceDetection(imageSource, maxResults);
30
+ }
31
+ safeSearchDetection(imageSource, maxResults) {
32
+ return this.handle.imageSafeSearchDetection(imageSource, maxResults);
33
+ }
34
+ cropHints(imageSource, maxResults) {
35
+ return this.handle.imageCropHints(imageSource, maxResults);
36
+ }
37
+ documentTextDetection(imageSource, maxResults) {
38
+ return this.handle.imageDocumentTextDetection(imageSource, maxResults);
39
+ }
40
+ imageProperties(imageSource, maxResults) {
41
+ return this.handle.imageProperties(imageSource, maxResults);
42
+ }
43
+ landmarkDetection(imageSource, maxResults) {
44
+ return this.handle.imageLandmarkDetection(imageSource, maxResults);
45
+ }
46
+ logoDetection(imageSource, maxResults) {
47
+ return this.handle.imageLogoDetection(imageSource, maxResults);
48
+ }
49
+ objectLocalization(imageSource, maxResults) {
50
+ return this.handle.imageObjectLocalization(imageSource, maxResults);
51
+ }
52
+ webDetection(imageSource, maxResults) {
53
+ return this.handle.imageWebDetection(imageSource, maxResults);
54
+ }
55
+ };
56
+ var GoogleVisionFile = class {
57
+ constructor(handle) {
58
+ this.handle = handle;
59
+ }
60
+ handle;
61
+ labelDetection(gcsUri, maxResults) {
62
+ return this.handle.fileLabelDetection(gcsUri, maxResults);
63
+ }
64
+ textDetection(gcsUri, maxResults) {
65
+ return this.handle.fileTextDetection(gcsUri, maxResults);
66
+ }
67
+ documentTextDetection(gcsUri, maxResults) {
68
+ return this.handle.fileDocumentTextDetection(gcsUri, maxResults);
69
+ }
70
+ faceDetection(gcsUri, maxResults) {
71
+ return this.handle.fileFaceDetection(gcsUri, maxResults);
72
+ }
73
+ };
74
+ var GoogleVision = class _GoogleVision {
75
+ constructor(handle) {
76
+ this.handle = handle;
77
+ this.image = new GoogleVisionImage(handle);
78
+ this.file = new GoogleVisionFile(handle);
79
+ }
80
+ handle;
81
+ image;
82
+ file;
83
+ static async create(loader) {
84
+ if (!loader) {
85
+ throw new Error(
86
+ "No Dart runtime loader provided. Import from '@unngh/google-vision/node' or '@unngh/google-vision/browser' instead."
87
+ );
88
+ }
89
+ const ns = await getRuntime(loader);
90
+ const handle = ns.create();
91
+ return new _GoogleVision(handle);
92
+ }
93
+ /** Authenticate using an API key (synchronous, chainable). */
94
+ withApiKey(apiKey) {
95
+ this.handle.withApiKey(apiKey);
96
+ return this;
97
+ }
98
+ /** Authenticate using JWT credentials (asynchronous, chainable). */
99
+ async withJwt(credentialsJson, scope) {
100
+ await this.handle.withJwt(credentialsJson, scope);
101
+ return this;
102
+ }
103
+ };
104
+
105
+ // src/node.ts
106
+ var ensurePolyfills = async () => {
107
+ const g = globalThis;
108
+ if (!g.self) g.self = g;
109
+ if (!g.window) g.window = g;
110
+ if (!g.XMLHttpRequest) {
111
+ const mod = await import("xhr2");
112
+ g.XMLHttpRequest = mod.XMLHttpRequest ?? mod.default;
113
+ }
114
+ };
115
+ var loadDart = async () => {
116
+ await ensurePolyfills();
117
+ await import("./google_vision-FY62C7II.js");
118
+ };
119
+ var GoogleVision2 = class extends GoogleVision {
120
+ static async create() {
121
+ return await GoogleVision.create(loadDart);
122
+ }
123
+ };
124
+ export {
125
+ GoogleVision2 as GoogleVision
126
+ };
127
+ //# sourceMappingURL=node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/runtime.ts","../src/index.ts","../src/node.ts"],"sourcesContent":["/**\n * Loads the dart2js-compiled runtime and returns the `GoogleVisionJs`\n * namespace installed on `globalThis`. Dispatch is platform-specific — see\n * `browser.ts` and `node.ts` for the actual loader implementations.\n */\n\nimport type { VisionJsNamespace } from './types.js';\n\nlet cached: VisionJsNamespace | undefined;\n\nexport type DartRuntimeLoader = () => Promise<void>;\n\nexport async function getRuntime(\n loader: DartRuntimeLoader,\n): Promise<VisionJsNamespace> {\n if (cached) return cached;\n await loader();\n const ns = (globalThis as any).GoogleVisionJs as\n | VisionJsNamespace\n | undefined;\n if (!ns) {\n throw new Error(\n 'google_vision_js runtime failed to initialise: ' +\n 'globalThis.GoogleVisionJs was not installed.',\n );\n }\n cached = ns;\n return ns;\n}\n","/**\n * google_vision_js — public TypeScript API.\n *\n * This facade wraps the dart2js-compiled `google_vision` core, exposing an\n * idiomatic JavaScript API: Promise-based methods, `image` and `file`\n * sub-APIs that mirror the Dart API shape.\n */\n\nimport type { DartRuntimeLoader } from './runtime.js';\nimport { getRuntime } from './runtime.js';\nimport type {\n ImageSource,\n VisionJsHandle,\n} from './types.js';\n\nexport type { ImageSource } from './types.js';\n\n/** Sub-API for image-based Google Vision operations. */\nclass GoogleVisionImage {\n constructor(private readonly handle: VisionJsHandle) {}\n\n labelDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.imageLabelDetection(imageSource, maxResults);\n }\n\n textDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.imageTextDetection(imageSource, maxResults);\n }\n\n faceDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.imageFaceDetection(imageSource, maxResults);\n }\n\n safeSearchDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any> | null> {\n return this.handle.imageSafeSearchDetection(imageSource, maxResults);\n }\n\n cropHints(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any> | null> {\n return this.handle.imageCropHints(imageSource, maxResults);\n }\n\n documentTextDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any> | null> {\n return this.handle.imageDocumentTextDetection(imageSource, maxResults);\n }\n\n imageProperties(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any> | null> {\n return this.handle.imageProperties(imageSource, maxResults);\n }\n\n landmarkDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.imageLandmarkDetection(imageSource, maxResults);\n }\n\n logoDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.imageLogoDetection(imageSource, maxResults);\n }\n\n objectLocalization(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.imageObjectLocalization(imageSource, maxResults);\n }\n\n webDetection(\n imageSource: string | ImageSource,\n maxResults?: number,\n ): Promise<Record<string, any> | null> {\n return this.handle.imageWebDetection(imageSource, maxResults);\n }\n}\n\n/** Sub-API for file-based Google Vision operations (PDFs, GCS files). */\nclass GoogleVisionFile {\n constructor(private readonly handle: VisionJsHandle) {}\n\n labelDetection(\n gcsUri: string,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.fileLabelDetection(gcsUri, maxResults);\n }\n\n textDetection(\n gcsUri: string,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.fileTextDetection(gcsUri, maxResults);\n }\n\n documentTextDetection(\n gcsUri: string,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.fileDocumentTextDetection(gcsUri, maxResults);\n }\n\n faceDetection(\n gcsUri: string,\n maxResults?: number,\n ): Promise<Record<string, any>[]> {\n return this.handle.fileFaceDetection(gcsUri, maxResults);\n }\n}\n\nexport class GoogleVision {\n readonly image: GoogleVisionImage;\n readonly file: GoogleVisionFile;\n\n protected constructor(private readonly handle: VisionJsHandle) {\n this.image = new GoogleVisionImage(handle);\n this.file = new GoogleVisionFile(handle);\n }\n\n static async create(\n loader?: DartRuntimeLoader,\n ): Promise<GoogleVision> {\n if (!loader) {\n throw new Error(\n 'No Dart runtime loader provided. Import from ' +\n \"'@unngh/google-vision/node' or '@unngh/google-vision/browser' instead.\",\n );\n }\n const ns = await getRuntime(loader);\n const handle = ns.create();\n return new GoogleVision(handle);\n }\n\n /** Authenticate using an API key (synchronous, chainable). */\n withApiKey(apiKey: string): this {\n this.handle.withApiKey(apiKey);\n return this;\n }\n\n /** Authenticate using JWT credentials (asynchronous, chainable). */\n async withJwt(\n credentialsJson: string,\n scope?: string,\n ): Promise<this> {\n await this.handle.withJwt(credentialsJson, scope);\n return this;\n }\n}\n","/**\n * Node.js entrypoint for google_vision_js.\n *\n * dart2js output targets the browser runtime — it expects `self`,\n * `window`, and `XMLHttpRequest` globals. We polyfill these before\n * loading the compiled module.\n */\n\nimport { GoogleVision as Base } from './index.js';\n\nexport * from './index.js';\n\nconst ensurePolyfills = async () => {\n const g = globalThis as any;\n if (!g.self) g.self = g;\n if (!g.window) g.window = g;\n if (!g.XMLHttpRequest) {\n const mod = await import('xhr2');\n g.XMLHttpRequest = (mod as any).XMLHttpRequest ?? (mod as any).default;\n }\n};\n\nconst loadDart = async () => {\n await ensurePolyfills();\n // @ts-expect-error -- resolved at build time; present in dist/.\n await import('../build/dart/google_vision.js');\n};\n\nexport class GoogleVision extends Base {\n static override async create(): Promise<GoogleVision> {\n return (await Base.create(loadDart)) as GoogleVision;\n }\n}\n"],"mappings":"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","names":["GoogleVision"]}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@unngh/google-vision",
3
+ "version": "1.0.0",
4
+ "description": "Google Vision API client for Node.js and browsers — image labeling, face detection, OCR, safe search, and more. Compiled from Dart.",
5
+ "license": "MIT",
6
+ "author": "Chris Davis",
7
+ "homepage": "https://github.com/cdavis-code/google_vision_workspace/tree/main/packages/google_vision_js",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/cdavis-code/google_vision_workspace.git",
11
+ "directory": "packages/google_vision_js"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/cdavis-code/google_vision_workspace/issues"
15
+ },
16
+ "keywords": [
17
+ "google-vision",
18
+ "vision-api",
19
+ "ocr",
20
+ "face-detection",
21
+ "label-detection",
22
+ "safe-search",
23
+ "image-analysis",
24
+ "dart2js"
25
+ ],
26
+ "type": "module",
27
+ "main": "./dist/node.cjs",
28
+ "module": "./dist/node.js",
29
+ "types": "./dist/index.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "browser": "./dist/browser.js",
34
+ "import": "./dist/node.js",
35
+ "require": "./dist/node.cjs",
36
+ "default": "./dist/node.js"
37
+ },
38
+ "./node": {
39
+ "types": "./dist/node.d.ts",
40
+ "import": "./dist/node.js",
41
+ "require": "./dist/node.cjs",
42
+ "default": "./dist/node.js"
43
+ },
44
+ "./browser": {
45
+ "types": "./dist/browser.d.ts",
46
+ "import": "./dist/browser.js",
47
+ "default": "./dist/browser.js"
48
+ }
49
+ },
50
+ "files": [
51
+ "dist/",
52
+ "package.json",
53
+ "README.md",
54
+ "LICENSE",
55
+ "CHANGELOG.md"
56
+ ],
57
+ "scripts": {
58
+ "build": "bash scripts/build.sh",
59
+ "prepublishOnly": "npm run build"
60
+ },
61
+ "engines": {
62
+ "node": ">=18.0.0"
63
+ },
64
+ "devDependencies": {
65
+ "tsup": "^8.0.0",
66
+ "typescript": "^5.4.0"
67
+ },
68
+ "dependencies": {
69
+ "xhr2": "^0.2.1"
70
+ }
71
+ }