Skip to content

Commit

Permalink
regen types
Browse files Browse the repository at this point in the history
  • Loading branch information
UrielCh committed Apr 28, 2024
1 parent e02d34b commit f9477c6
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 10 deletions.
13 changes: 13 additions & 0 deletions extra/meta.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRequire = exports.getDirName = void 0;

function getDirName() {
return __dirname;
}
exports.getDirName = getDirName;

function getRequire() {
return require;
}
exports.getRequire = getRequire;
8 changes: 8 additions & 0 deletions extra/meta.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { createRequire } from 'node:module';
import { fileURLToPath } from 'node:url';
export function getDirName() {
return fileURLToPath(new URL('.', import.meta.url));
}
export function getRequire() {
return createRequire(import.meta.url);
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@
"module": "./esm/lib/opencv4nodejs.js",
"typings": "./typings/index.d.ts",
"scripts": {
"build": "tsc --pretty --project tsconfig.json && tsc --pretty --project tsconfig-esm.json",
"build": "tsc --pretty --project tsconfig.json && tsc --pretty --project tsconfig-esm.json && npm run copyfile",
"build-types": "rimraf types && tsc --pretty --project tsconfig-types.json",
"copyfile": "shx cp extra/meta.mjs esm/lib/meta.js && shx cp extra/meta.cjs cjs/lib/meta.js",
"prepack": "npm run build",
"install_old": "node bin/install.js auto",
"install_Mac": "CXXFLAGS=\"-std=c++17 -Wno-c++11-narrowing -Wno-c++17-extensions -Wno-c++17-attribute-extensions\" node ./bin/install.js --version 4.5.3 build",
Expand Down Expand Up @@ -89,6 +90,7 @@
"eslint-plugin-react-hooks": "^4.6.0",
"progress": "^2.0.3",
"rimraf": "^5.0.5",
"shx": "^0.3.4",
"typescript": "^5.4.5"
},
"files": [
Expand Down
34 changes: 34 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/lib/opencv4nodejs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import extendWithJsSources from './src/index.js';
import { getOpenCV } from './cvloader.js';
import type * as openCV from '../../typings/index.js';
export type * as openCV from '../../typings/index.js';
export { getDirName, getRequire } from "./meta.js"

declare type OpenCVType = typeof openCV;

Expand Down
2 changes: 1 addition & 1 deletion types/lib/cvloader.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type OpenCVBuildEnvParams } from '@u4/opencv-build';
import type * as openCV from '../../typings/index';
import type * as openCV from '../../typings/index.js';
declare type OpenCVType = typeof openCV;
export declare function getOpenCV(opt?: OpenCVBuildEnvParams): OpenCVType;
export default getOpenCV;
3 changes: 3 additions & 0 deletions types/lib/meta.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/// <reference types="node" />
export declare function getDirName(): string;
export declare function getRequire(): NodeRequire;
5 changes: 3 additions & 2 deletions types/lib/opencv4nodejs.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type * as openCV from '../../typings/index';
export type * as openCV from '../../typings/index';
import type * as openCV from '../../typings/index.js';
export type * as openCV from '../../typings/index.js';
export declare const cv: typeof openCV;
declare const defExport: {
[key: string]: any;
};
export { getDirName, getRequire } from "./meta.js";
export default defExport;
2 changes: 1 addition & 1 deletion types/lib/src/deprecations.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import type * as openCV from '../../../typings/index';
import type * as openCV from '../../../typings/index.js';
export default function (cv: typeof openCV): void;
4 changes: 2 additions & 2 deletions types/lib/src/drawUtils.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as openCV from '../../../typings/index';
import { Mat, Rect, Vec3 } from '../../../typings/index';
import type * as openCV from '../../../typings/index.js';
import { Mat, Rect, Vec3 } from '../../../typings/index.js';
export interface TextParams {
fontType: number;
fontSize: number;
Expand Down
2 changes: 1 addition & 1 deletion types/lib/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import * as OpenCV from '../../../typings/index';
import * as OpenCV from '../../../typings/index.js';
export default function extendWithJsSources(cv: typeof OpenCV): typeof OpenCV;
4 changes: 2 additions & 2 deletions types/lib/src/misc.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type * as openCV from '../../../typings/index';
import type { Mat, Rect } from '../../../typings/index';
import type * as openCV from '../../../typings/index.js';
import type { Mat, Rect } from '../../../typings/index.js';
export declare const allTypes: readonly ["CV_8U", "CV_8S", "CV_16U", "CV_16S", "CV_32S", "CV_32F", "CV_64F", "CV_8UC1", "CV_8UC2", "CV_8UC3", "CV_8UC4", "CV_8SC1", "CV_8SC2", "CV_8SC3", "CV_8SC4", "CV_16UC1", "CV_16UC2", "CV_16UC3", "CV_16UC4", "CV_16SC1", "CV_16SC2", "CV_16SC3", "CV_16SC4", "CV_32SC1", "CV_32SC2", "CV_32SC3", "CV_32SC4", "CV_32FC1", "CV_32FC2", "CV_32FC3", "CV_32FC4", "CV_64FC1", "CV_64FC2", "CV_64FC3", "CV_64FC4"];
export type MatTypes = typeof allTypes[number];
/**
Expand Down

0 comments on commit f9477c6

Please sign in to comment.