Skip to content

Commit

Permalink
update types
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardo-devis-agullo committed Dec 28, 2023
1 parent 3be31a9 commit db32bae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
48 changes: 26 additions & 22 deletions packages/oc-generic-template-compiler/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
type Callback<T = unknown> = (err: Error | null, data: T) => void;

interface PackageJson {
name: string;
version: string;
dependencies?: Record<string, string>;
devDependencies?: Record<string, string>;
}

interface CompiledViewInfo {
template: {
type: string;
hashKey: string;
src: string;
};
bundle: { hashKey: string };
bundle: {
hashKey: string;
};
}

type OcOptions = {
files: {
data: string;
Expand All @@ -26,8 +25,7 @@ type OcOptions = {
static: string[];
};
};

interface CompilerOptions {
export interface CompilerOptions {
componentPackage: PackageJson & {
oc: OcOptions;
};
Expand All @@ -39,17 +37,21 @@ interface CompilerOptions {
verbose: boolean;
watch: boolean;
}

type CompileView = (
export type CompileView = (
options: CompilerOptions,
cb: Callback<CompiledViewInfo>
) => void;
type CompileServer = (
options: CompilerOptions & { compiledViewInfo: CompiledViewInfo },
export type CompileServer = (
options: CompilerOptions & {
compiledViewInfo: CompiledViewInfo;
},
cb: Callback<any>
) => void;
type CompileStatics = (options: CompilerOptions, cb: Callback<'ok'>) => void;
type GetInfo = () => {
export type CompileStatics = (
options: CompilerOptions,
cb: Callback<'ok'>
) => void;
export type GetInfo = () => {
type: string;
version: string;
externals: Array<{
Expand All @@ -58,14 +60,16 @@ type GetInfo = () => {
url: string;
}>;
};

declare const compiler: {
createCompile: (compilers: {
compileView: CompileView;
compileServer: CompileServer;
compileStatics: CompileStatics;
getInfo: GetInfo;
}) => (options: CompilerOptions, cb: Callback) => void;
export type Compilers = {
compileView: CompileView;
compileServer: CompileServer;
compileStatics: CompileStatics;
getInfo: GetInfo;
};

export = compiler;
export declare const createCompile: ({
compileServer,
compileView,
compileStatics,
getInfo
}: Compilers) => (options: CompilerOptions, callback: Callback) => void;
export {};
4 changes: 2 additions & 2 deletions packages/oc-generic-template-compiler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oc-generic-template-compiler",
"version": "2.1.1",
"version": "2.1.2",
"description": "OC-Generic-Template-Compiler",
"main": "index.js",
"types": "index.d.ts",
Expand Down Expand Up @@ -34,4 +34,4 @@
"lodash": "^4.17.4",
"oc-get-unix-utc-timestamp": "1.0.3"
}
}
}

0 comments on commit db32bae

Please sign in to comment.