pull/723/merge
Naftali Beder 1 year ago committed by GitHub
commit 1b59edb640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,3 +2,4 @@
dist/*
coverage/*
karma.conf.js
/**/*.d.ts

40
dist/mercury.d.ts vendored

@ -0,0 +1,40 @@
declare module '@postlight/parser' {
export type ExtractorArgs = any;
export type ParserOptions = {
html?: string;
fetchAllPages?: boolean;
fallback?: boolean;
contentType?: 'html' | 'markdown' | 'text';
headers?: Record<string, string>;
extend?: boolean;
customExtractor?: (args: ExtractorArgs) => ParserResult;
};
export type ParserResult = {
title: string;
content: string;
author: string;
date_published: string;
lead_image_url: string;
dek: string;
next_page_url: string;
url: string;
domain: string;
excerpt: string;
word_count: number;
direction: string;
total_pages: number;
rendered_pages: number;
};
export function parse(
url: string,
opts: ParserOptions
): Promise<ParserResult>;
const exported: {
parse: typeof parse;
};
export default exported;
}

@ -1,7 +1,12 @@
/* eslint-disable import/no-extraneous-dependencies */
import fs from 'fs';
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
const copyDeclarations = (src, dest) => {
fs.copyFileSync(src, dest);
};
export default {
input: 'src/mercury.js',
plugins: [
@ -10,6 +15,7 @@ export default {
externalHelpers: false,
runtimeHelpers: true,
}),
copyDeclarations('src/mercury.d.ts', 'dist/mercury.d.ts'),
],
treeshake: true,
output: {

40
src/mercury.d.ts vendored

@ -0,0 +1,40 @@
declare module '@postlight/parser' {
export type ExtractorArgs = any;
export type ParserOptions = {
html?: string;
fetchAllPages?: boolean;
fallback?: boolean;
contentType?: 'html' | 'markdown' | 'text';
headers?: Record<string, string>;
extend?: boolean;
customExtractor?: (args: ExtractorArgs) => ParserResult;
};
export type ParserResult = {
title: string;
content: string;
author: string;
date_published: string;
lead_image_url: string;
dek: string;
next_page_url: string;
url: string;
domain: string;
excerpt: string;
word_count: number;
direction: string;
total_pages: number;
rendered_pages: number;
};
export function parse(
url: string,
opts: ParserOptions
): Promise<ParserResult>;
const exported: {
parse: typeof parse;
};
export default exported;
}
Loading…
Cancel
Save