Skip to content

Commit

Permalink
chore(release): bump all packages' version to 0.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
DemoMacro committed Sep 3, 2024
1 parent 195f629 commit fa53b16
Show file tree
Hide file tree
Showing 19 changed files with 95 additions and 50 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@
"type": "git",
"url": "git+https://github.com/docenjs/docen.git"
},
"keywords": ["pandoc", "mammoth"],
"keywords": [
"pandoc",
"mammoth"
],
"author": {
"name": "Demo Macro",
"email": "[email protected]",
Expand Down
13 changes: 10 additions & 3 deletions packages/csv/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "@docen/csv",
"version": "0.0.7-edge.3",
"version": "0.0.7",
"description": "Programmed implementation of csv format, powered by Demo Macro.",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/index.mjs",
Expand All @@ -18,7 +20,12 @@
"type": "git",
"url": "git+https://github.com/docenjs/docen.git"
},
"keywords": ["pandoc", "papaparse", "csv", "json"],
"keywords": [
"pandoc",
"papaparse",
"csv",
"json"
],
"author": {
"name": "Demo Macro",
"email": "[email protected]",
Expand Down
12 changes: 6 additions & 6 deletions packages/csv/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function convertCSVToJSON(source: string, options?: csvConvertOptions) {
// const regex = /("[^"]*"|[^,]+)/g;
const regex = new RegExp(
`(${quotechar}[^${quotechar}]*${quotechar}|[^${delimiter}]+)`,
"g"
"g",
);

return row.match(regex) ?? [];
Expand All @@ -40,7 +40,7 @@ export function convertCSVToJSON(source: string, options?: csvConvertOptions) {
} else if (options?.header) {
header = Array.from(
{ length: maxColumns },
(_, i) => `${options?.header}${i + 1}`
(_, i) => `${options?.header}${i + 1}`,
);
}

Expand All @@ -52,7 +52,7 @@ export function convertCSVToJSON(source: string, options?: csvConvertOptions) {

if (header.length < maxColumns) {
header = header.concat(
Array.from({ length: maxColumns - header.length }, (_, i) => `${i + 1}`)
Array.from({ length: maxColumns - header.length }, (_, i) => `${i + 1}`),
);
}

Expand Down Expand Up @@ -80,7 +80,7 @@ export function convertCSVToJSON(source: string, options?: csvConvertOptions) {
export function convertJSONToCSV(
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
source: Record<string, any>[],
options?: csvConvertOptions
options?: csvConvertOptions,
) {
const delimiter = options?.delimiter ?? ",";

Expand All @@ -103,7 +103,7 @@ export function convertJSONToCSV(
} else if (options?.header) {
header = Array.from(
{ length: maxColumns },
(_, i) => `${options?.header}${i + 1}`
(_, i) => `${options?.header}${i + 1}`,
);
}

Expand All @@ -115,7 +115,7 @@ export function convertJSONToCSV(

if (header.length < maxColumns) {
header = header.concat(
Array.from({ length: maxColumns - header.length }, (_, i) => `${i + 1}`)
Array.from({ length: maxColumns - header.length }, (_, i) => `${i + 1}`),
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/docen/bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ execSync("pnpm prepack", { stdio: "inherit" });
execSync("pnpm ncc build dist/cli.cjs -o .cache/ncc -a", { stdio: "inherit" });

const version = readFileSync("package.json", "utf-8").match(
/"version": "(.*?)"/
/"version": "(.*?)"/,
)[1];

execSync(`mv .cache/ncc/index.cjs .cache/ncc/docen-${version}.js`, {
Expand All @@ -17,5 +17,5 @@ execSync(
`pnpm dlx pkg .cache/ncc/docen-${version}.js --out-path .cache/bundle -c pkg.config.json -C GZip`,
{
stdio: "inherit",
}
},
);
11 changes: 8 additions & 3 deletions packages/docen/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "docen",
"version": "0.0.7-edge.3",
"version": "0.0.7",
"description": "Programmatically and command-line implementation of document formatting, powered by Demo Macro.",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"bin": {
"docen": "dist/cli.mjs"
},
Expand All @@ -22,7 +24,10 @@
"type": "git",
"url": "git+https://github.com/docenjs/docen.git"
},
"keywords": ["pandoc", "mammoth"],
"keywords": [
"pandoc",
"mammoth"
],
"author": {
"name": "Demo Macro",
"email": "[email protected]",
Expand Down
6 changes: 3 additions & 3 deletions packages/docen/src/text.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { extractTextFromDocx } from "@docen/docx";
import { extractTextFromPDF } from "@docen/pdf";
import { type DataType, toText, toUint8Array } from "undio";
import { type DataType, toArrayBuffer, toText } from "undio";
import { detectFileType } from "./utils";

export async function extractText(
source: DataType,
options?: {
sourceType?: string;
}
},
) {
let text: string;

const fileType =
options?.sourceType ?? (await detectFileType(toUint8Array(source))).ext;
options?.sourceType ?? (await detectFileType(toArrayBuffer(source))).ext;

switch (fileType) {
case "docx":
Expand Down
4 changes: 2 additions & 2 deletions packages/docen/src/utils/file-type.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fileTypeFromBuffer } from "file-type";

export async function detectFileType(source: Uint8Array) {
export async function detectFileType(source: Uint8Array | ArrayBuffer) {
let fileType = null;

fileType = await fileTypeFromBuffer(source);
Expand All @@ -10,7 +10,7 @@ export async function detectFileType(source: Uint8Array) {
const buffer = Buffer.from(source);
const isTxt = Buffer.compare(
buffer.subarray(0, 3),
Buffer.from([0xef, 0xbb, 0xbf])
Buffer.from([0xef, 0xbb, 0xbf]),
);
if (isTxt) {
fileType = {
Expand Down
11 changes: 8 additions & 3 deletions packages/docx/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "@docen/docx",
"version": "0.0.7-edge.3",
"version": "0.0.7",
"description": "Programmed implementation of docx format, powered by Demo Macro.",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/index.mjs",
Expand All @@ -18,7 +20,10 @@
"type": "git",
"url": "git+https://github.com/docenjs/docen.git"
},
"keywords": ["pandoc", "mammoth"],
"keywords": [
"pandoc",
"mammoth"
],
"author": {
"name": "Demo Macro",
"email": "[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions packages/docx/src/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { type DataType, toUint8Array } from "undio";

export async function getDocumentXML(source: DataType) {
return JSZIP.loadAsync(toUint8Array(source)).then((zip) =>
zip?.file("word/document.xml")?.async("text")
zip?.file("word/document.xml")?.async("text"),
);
}

export async function getStylesXML(source: DataType) {
return JSZIP.loadAsync(toUint8Array(source)).then((zip) =>
zip?.file("word/styles.xml")?.async("text")
zip?.file("word/styles.xml")?.async("text"),
);
}

Expand Down
11 changes: 8 additions & 3 deletions packages/image/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "@docen/image",
"version": "0.0.7-edge.3",
"version": "0.0.7",
"description": "Programmed implementation of image format, powered by Demo Macro.",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/index.mjs",
Expand All @@ -18,7 +20,10 @@
"type": "git",
"url": "git+https://github.com/docenjs/docen.git"
},
"keywords": ["pandoc", "image"],
"keywords": [
"pandoc",
"image"
],
"author": {
"name": "Demo Macro",
"email": "[email protected]",
Expand Down
2 changes: 1 addition & 1 deletion packages/image/src/ocr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export async function convertImageToText(
options?: {
// https://tesseract-ocr.github.io/tessdoc/Data-Files
lang?: string | string[];
}
},
) {
const { type } = imageMeta(toUint8Array(source));

Expand Down
13 changes: 10 additions & 3 deletions packages/jsonp/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "@docen/jsonp",
"version": "0.0.7-edge.3",
"version": "0.0.7",
"description": "Programmed implementation of jsonp format, powered by Demo Macro.",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/index.mjs",
Expand All @@ -18,7 +20,12 @@
"type": "git",
"url": "git+https://github.com/docenjs/docen.git"
},
"keywords": ["pandoc", "jsonp", "csv", "json"],
"keywords": [
"pandoc",
"jsonp",
"csv",
"json"
],
"author": {
"name": "Demo Macro",
"email": "[email protected]",
Expand Down
4 changes: 2 additions & 2 deletions packages/jsonp/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export function convertJSONPToJSON(
source: string,
options: { callbackName?: string; multiple?: boolean } = {}
options: { callbackName?: string; multiple?: boolean } = {},
): unknown {
const multiple: boolean = options.multiple ?? false;

const regGroup: RegExpMatchArray | null = source.match(
/(?<functionName>.+)\(.*\)/
/(?<functionName>.+)\(.*\)/,
);

const functionName: string | undefined = regGroup?.groups?.functionName;
Expand Down
12 changes: 9 additions & 3 deletions packages/pdf/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "@docen/pdf",
"version": "0.0.7-edge.3",
"version": "0.0.7",
"description": "Programmed implementation of pdf format, powered by Demo Macro.",
"main": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": ["dist"],
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/index.mjs",
Expand All @@ -18,7 +20,11 @@
"type": "git",
"url": "git+https://github.com/docenjs/docen.git"
},
"keywords": ["pandoc", "unpdf", "pdf"],
"keywords": [
"pandoc",
"unpdf",
"pdf"
],
"author": {
"name": "Demo Macro",
"email": "[email protected]",
Expand Down
8 changes: 4 additions & 4 deletions packages/pdf/src/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function extractImageFromPDF(
source: DataType,
options?: {
pages?: number[];
}
},
) {
// Load a PDF document.
const { getDocument, OPS } = await getResolvedPDFJS();
Expand Down Expand Up @@ -71,7 +71,7 @@ export async function extractImageFromPDF(
index: index,
data: useCanvas.toBuffer("image/png"),
});
}
},
);
}
});
Expand All @@ -85,7 +85,7 @@ export async function convertPDFToImage(
options?: {
pages?: number[];
canvas?: () => Promise<typeof canvas>;
}
},
) {
// Load a PDF document.
const { getDocument } = await getResolvedPDFJS();
Expand All @@ -107,7 +107,7 @@ export async function convertPDFToImage(
i,
{
canvas: options?.canvas,
}
},
);

images.push(image);
Expand Down
2 changes: 1 addition & 1 deletion packages/pdf/src/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export async function extractTextFromPDF(
source: DataType,
options?: {
pages?: number[];
}
},
) {
// Load a PDF document.
const { getDocument } = await getResolvedPDFJS();
Expand Down
Loading

0 comments on commit fa53b16

Please sign in to comment.