From 659cde401715d2103051530bb2a3cbce1915a912 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Fri, 27 Dec 2024 11:14:28 +0000 Subject: [PATCH] feat: prepare as pesde & npm package * Add README with basic documentation * Add exports.ts with required TS and Luau exports * Add build script to extract Luau exports from exports.ts * Setup pesde package manifest * Apply formatting, setup stylua --- .gitignore | 4 + .prettierrc | 2 +- .vscode/extensions.json | 6 +- .vscode/settings.json | 6 +- README.md | 35 ++++++++ build.ts | 24 ++++++ bun.lockb | Bin 71344 -> 98736 bytes package.json | 100 ++++++++++++----------- pesde.lock | 3 + pesde.toml | 30 +++++++ src/deflate.ts | 12 +-- src/exports.ts | 176 ++++++++++++++++++++++++++++++++++++++++ src/inflate.ts | 16 +--- src/zlib/README.md | 19 ++--- src/zlib/deflate.ts | 3 +- src/zlib/zstream.ts | 2 +- tsconfig.json | 4 +- 17 files changed, 354 insertions(+), 88 deletions(-) create mode 100644 build.ts mode change 100644 => 100755 bun.lockb create mode 100644 pesde.lock create mode 100644 pesde.toml create mode 100644 src/exports.ts diff --git a/.gitignore b/.gitignore index bb3e43c..b98d765 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,8 @@ +# ts /node_modules /out /include *.tsbuildinfo + +# pesde +*_packages/ \ No newline at end of file diff --git a/.prettierrc b/.prettierrc index 0d69450..537ac33 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,4 +3,4 @@ "tabWidth": 4, "trailingComma": "all", "useTabs": true -} \ No newline at end of file +} diff --git a/.vscode/extensions.json b/.vscode/extensions.json index ef27118..0da040b 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,3 @@ { - "recommendations": [ - "esbenp.prettier-vscode", - "dbaeumer.vscode-eslint", - "DavidAnson.vscode-markdownlint" - ] + "recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint", "DavidAnson.vscode-markdownlint"] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 3fc6e65..779ad19 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { - "editor.formatOnSave": true, - "editor.defaultFormatter": "esbenp.prettier-vscode", -} \ No newline at end of file + "editor.formatOnSave": true, + "editor.defaultFormatter": "esbenp.prettier-vscode" +} diff --git a/README.md b/README.md index 1c714e8..7b005e3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,38 @@ # pako-roblox-ts Fork of [pako](https://github.com/nodeca/pako) for Roblox-TS. + +## Installation + +Supported as a pesde (Luau) package and npm (roblox-ts) package: + +```sh +# pesde +pesde add 0x5eal/pako + +# roblox-ts +npm add @rbxts/pako +``` + +## Usage + +### Luau + +```luau +local serde = require("@lune/serde") +local pako = require("./luau_packages/pako") + +local test = { my = "super", puper = { 456, 567 }, awesome = "pako" } +local compressed = pako.deflate(serde.encode("json", test)) +local restored = serde.decode(pako.inflate(compressed, { to = "string" })) +``` + +### roblox-ts + +```ts +import pako from "@rbxts/pako"; + +const test = { my: "super", puper: [456, 567], awesome: "pako" }; +const compressed = pako.deflate(JSON.stringify(test)); +const restored = JSON.parse(pako.inflate(compressed, { to: "string" })); +``` diff --git a/build.ts b/build.ts new file mode 100644 index 0000000..af2443b --- /dev/null +++ b/build.ts @@ -0,0 +1,24 @@ +// extracts the Luau exports section from a given file path +async function extractLuauExports(file: string): Promise { + const input = await Bun.file(file).text(); + const regex = /\/\/ @@@@@@@@@ LUAU_START @@@@@@@@@([\s\S]*?)\/\/ @@@@@@@@@ LUAU_END @@@@@@@@@/; + const match = input.match(regex); + if (match) { + // remove leading comment specifier from each line from each line + return match[1] + .split("\n") + .map((line) => line.replace(/\/\/\s?/, "")) + .join("\n") + .trim(); + } + + return null; +} + +const EXPORTS_TS_FILE = "./src/exports.ts"; +const EXPORTS_LUAU_FILE = "./out/init.luau"; + +console.log("extract and export Luau type thunk"); +await extractLuauExports(EXPORTS_TS_FILE).then((exports) => Bun.write(EXPORTS_LUAU_FILE, exports!)); + +export {}; // treat as esmodule diff --git a/bun.lock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1OO^P%!Uli{HGI@`tL> z(NJ*d3Wg!wt)MLG^Po85U=cyGzm(gV)QXBnqj|$SVOmP>KCRp5OP6GflEoJoD%ZRS zTiJcgvQB$?7mxxH8HUYk;I&)EZGYqF$1~89o0&&L9ud7GnBDSCs2CN&x~MjretB6T zh98g{`WU06q1w*q$WHiWnF_6esF)JEojjL{7 zsStN77}Kew)b?{b>#>ZJ5vE8^@JX{&JA zG13WfFL9^Ed^;<0nD^@4w-!G8_xTfMp%-FIK^Y@1LxBYecP!Koh?ZCuA-u6H!C~H_ zuUXaS=;?i3hvastZ)L+;-ng$Fzc9G&>LmcL9dY{Pm*YrFbOk-m? zXzb%+nFFrMZD6-tix=k|?DpJWSRVxEXU;PmE)=%C;;s&`BooEXdWxnFY!90$O5z~Y z*M}_>JHa{3i}I$VQGfb&{`Yhg(D4CpaE8TUZOj|=&)Ou~ThC3+f`YNd^_+wC!SO$s ztru(KSyz@LUWjK&xj&P9bfCgR^E!Lu^n)4RH>}k#>q0c0S&B3pWyR;fmz~9X$;fwO zJDPXTmGS>PeCC}LY;a>2D`{e00tU5-oe6BQ#pvcR@9Hh*7u>&Qadzbo`t_nB5h-dY zicN_uHvFgWrBL>WcqNflv6G^A65?Rq?!WrCXQrpw#|PuNmfvBUgjgj3s+djC8d%`02qLhpz;~p==(8 z!Y7PR-+HG0&nOo5&XK2Ge=)ohJk<{cQybaan@hb;Z;a`@%MMnY&z zhm6zAVgAmc)sUI@O-=v2pM@FUMEK@$cSgX?A4II&`~36XWapwE6n+#kF)EFP<=!M< z#{9-1DeRc%q_f(S#Tohk6UsUZe`l6tM(QRG>5G!`>th(fc9_3?sX18O^n|5-i_AJ1 zg&!?*#;;opeh+S=EP787b=j=1*q6", - "Erica Marigold " - ], - "author": "", - "license": "(MIT AND Zlib)", - "types": "out/index.d.ts", - "files": [ - "out", - "!**/*.tsbuildinfo" - ], - "publishConfig": { - "access": "public" - }, - "devDependencies": { - "@rbxts/compiler-types": "3.0.0-types.0", - "@rbxts/types": "^1.0.813", - "@typescript-eslint/eslint-plugin": "^8.18.2", - "@typescript-eslint/parser": "^8.18.2", - "eslint": "^9.17.0", - "eslint-config-prettier": "^9.1.0", - "eslint-plugin-prettier": "^5.2.1", - "eslint-plugin-roblox-ts": "^0.0.36", - "prettier": "^3.4.2", - "roblox-ts": "^3.0.0", - "typescript": "^5.7.2" - }, - "patchedDependencies": { - "@rbxts/types@1.0.813": "patches/@rbxts%2Ftypes@1.0.813.patch" - } -} \ No newline at end of file + "name": "@rbxts/pako", + "version": "0.1.0", + "description": "fork of pako for Roblox-TS", + "main": "out/init.lua", + "scripts": { + "build": "rbxtsc --verbose && bun run build.ts", + "fmt": "prettier -w . && stylua .", + "watch": "rbxtsc -w", + "prepublishOnly": "bun run build" + }, + "keywords": [], + "contributors": [ + "Andrei Tuputcyn (https://github.com/andr83)", + "Vitaly Puzrin (https://github.com/puzrin)", + "Friedel Ziegelmayer (https://github.com/dignifiedquire)", + "Kirill Efimov (https://github.com/Kirill89)", + "Jean-loup Gailly", + "Mark Adler", + "daimond113 (https://www.daimond113.com) ", + "Erica Marigold " + ], + "author": "", + "license": "(MIT AND Zlib)", + "types": "out/index.d.ts", + "files": [ + "out", + "!**/*.tsbuildinfo" + ], + "publishConfig": { + "access": "public" + }, + "devDependencies": { + "@johnnymorganz/stylua-bin": "^2.0.2", + "@rbxts/compiler-types": "3.0.0-types.0", + "@rbxts/types": "^1.0.813", + "@types/bun": "^1.1.14", + "@typescript-eslint/eslint-plugin": "^8.18.2", + "@typescript-eslint/parser": "^8.18.2", + "eslint": "^9.17.0", + "eslint-config-prettier": "^9.1.0", + "eslint-plugin-prettier": "^5.2.1", + "eslint-plugin-roblox-ts": "^0.0.36", + "prettier": "^3.4.2", + "roblox-ts": "^3.0.0", + "typescript": "^5.7.2" + }, + "patchedDependencies": { + "@rbxts/types@1.0.813": "patches/@rbxts%2Ftypes@1.0.813.patch" + }, + "trustedDependencies": [ + "@johnnymorganz/stylua-bin" + ] +} diff --git a/pesde.lock b/pesde.lock new file mode 100644 index 0000000..658d260 --- /dev/null +++ b/pesde.lock @@ -0,0 +1,3 @@ +name = "0x5eal/pako" +version = "0.1.0" +target = "luau" diff --git a/pesde.toml b/pesde.toml new file mode 100644 index 0000000..6ec2b94 --- /dev/null +++ b/pesde.toml @@ -0,0 +1,30 @@ +name = "0x5eal/pako" +version = "0.1.0" +description = "ZLib port for JavaScript, compiled to Luau" +repository = "https://github.com/0x5eal/rbxts-pako" +license = "MIT" +authors = [ + "Andrei Tuputcyn (https://github.com/andr83)", + "Vitaly Puzrin (https://github.com/puzrin)", + "Friedel Ziegelmayer (https://github.com/dignifiedquire)", + "Kirill Efimov (https://github.com/Kirill89)", + "Jean-loup Gailly", + "Mark Adler", + "daimond113 (https://www.daimond113.com) ", + "Erica Marigold " +] + +includes = [ + "pesde.toml", + "README.md", + "out/**/*.luau", + "!out/*.tsbuildinfo", + "!out/**/*.d.ts" +] + +[target] +environment = "luau" +lib = "out/init.luau" + +[indices] +default = "https://github.com/pesde-pkg/index" diff --git a/src/deflate.ts b/src/deflate.ts index 40003d6..c43b8f8 100644 --- a/src/deflate.ts +++ b/src/deflate.ts @@ -1,20 +1,20 @@ "use strict"; import type { DeflateState } from "./zlib/deflate"; -import type Messages from "./zlib/messages" -import type * as TypedArrays from "./utils/typedArrays"; +import type Messages from "./zlib/messages"; +import type * as TypedArrays from "./utils/typedArrays"; const { ZStream } = require("./zlib/zstream") as typeof import("./zlib/zstream"); const zlibDeflate = require("./zlib/deflate") as typeof import("./zlib/deflate"); const messages = require("./zlib/messages") as typeof Messages; const { assign, flattenChunks } = require("./utils/common") as typeof import("./utils/common"); -const { Uint8Array } = require("./utils/typedArrays") as typeof TypedArrays; +const { Uint8Array } = require("./utils/typedArrays") as typeof TypedArrays; /* Public constants ==========================================================*/ /* ===========================================================================*/ -export const { +const { Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FULL_FLUSH, @@ -113,7 +113,7 @@ export const { * ``` **/ -type Options = { +export type Options = { level: number; method: number; chunkSize: number; @@ -238,7 +238,7 @@ export class Deflate { strm.next_in = 0; strm.avail_in = strm.input.length; - for (; ;) { + for (;;) { if (strm.avail_out === 0) { strm.output = new Uint8Array(chunkSize); strm.next_out = 0; diff --git a/src/exports.ts b/src/exports.ts new file mode 100644 index 0000000..98c2114 --- /dev/null +++ b/src/exports.ts @@ -0,0 +1,176 @@ +// +// Luau exports +// + +// @@@@@@@@@ LUAU_START @@@@@@@@@ +// export type InflateOptions = { +// chunkSize: number?, +// windowBits: number?, +// to: string?, +// raw: boolean?, +// dictionary: (string | buffer)? +// } +// +// export type InflateRawOptions = { +// chunkSize: number?, +// windowBits: number?, +// to: string?, +// dictionary: (string | buffer)? +// } +// +// export type DeflateOptions = { +// level: number?, +// method: number?, +// chunkSize: number?, +// windowBits: number?, +// memLevel: number?, +// strategy: number?, +// raw: boolean?, +// gzip: boolean?, +// header: ({ +// done: boolean?, +// time: number?, +// xflags: number?, +// os: number?, +// extra_len: number?, +// comment: string?, +// extra: buffer?, +// name: string?, +// hcrc: number?, +// text: number?, +// })?, +// dictionary: (buffer | string)?, +// } +// +// export type DeflateRawOptions = { +// level: number?, +// method: number?, +// chunkSize: number?, +// windowBits: number?, +// memLevel: number?, +// strategy: number?, +// gzip: boolean?, +// header: ({ +// done: boolean?, +// time: number?, +// xflags: number?, +// os: number?, +// extra_len: number?, +// comment: string?, +// extra: buffer?, +// name: string?, +// hcrc: number?, +// text: number?, +// })?, +// dictionary: (buffer | string)?, +// } +// +// return require("./exports") :: { +// -- Inflate exports -- +// Inflate: any, -- TODO: type Inflate class +// inflate: (input: string | buffer, options: InflateOptions?) -> (string | buffer)?, +// inflateRaw: (input: string | buffer, options: InflateRawOptions?) -> (string | buffer)?, +// +// -- Deflate exports -- +// Deflate: any, -- TODO: type Deflate class +// deflate: (input: string | buffer, options: DeflateOptions?) -> buffer?, +// deflateRaw: (input: string | buffer, options: DeflateRawOptions?) -> buffer?, +// } +// @@@@@@@@@ LUAU_END @@@@@@@@@ + +const { Uint8Array } = require("./utils/typedArrays") as typeof import("./utils/typedArrays"); + +// +// Type exports +// + +import type { Options as InflateOptionsInner } from "./inflate"; +import type { Options as DeflateOptionsInner } from "./deflate"; +export type InflateOptions = Omit & { + dictionary?: string | buffer; +}; +export type DeflateOptions = Omit & { + dictionary?: string | buffer; +}; + +// +// Inflate exports +// + +const { + Inflate, + inflate: inflateImpl, + inflateRaw: inflateRawImpl, +} = require("./inflate") as typeof import("./inflate"); + +export function inflate(input: string | buffer, options?: Partial): string | buffer | undefined { + const inputArray = Uint8Array.from(typeIs(input, "string") ? buffer.fromstring(input) : input); + const modifiedOptions = options as Partial; + if (typeIs(options?.dictionary, "buffer")) { + modifiedOptions.dictionary = Uint8Array.from(options.dictionary); + } + + return inflateImpl(inputArray, modifiedOptions); +} + +export function inflateRaw( + input: string | buffer, + options?: Exclude, "raw">, +): string | buffer | undefined { + const inputArray = Uint8Array.from(typeIs(input, "string") ? buffer.fromstring(input) : input); + const modifiedOptions = options as Exclude, "raw">; + if (typeIs(options?.dictionary, "buffer")) { + modifiedOptions.dictionary = Uint8Array.from(options.dictionary); + } + + return inflateRawImpl(inputArray, modifiedOptions); +} + +export { Inflate }; + +// +// Deflate exports +// + +const { + Deflate, + deflate: deflateImpl, + deflateRaw: deflateRawImpl, +} = require("./deflate") as typeof import("./deflate"); + +export function deflate(input: string | buffer, options?: Partial): buffer | undefined { + const inputArray = Uint8Array.from(typeIs(input, "string") ? buffer.fromstring(input) : input); + const modifiedOptions = options as Partial; + if (typeIs(modifiedOptions?.dictionary, "buffer")) { + modifiedOptions.dictionary = Uint8Array.from(modifiedOptions.dictionary); + } + if (typeIs(modifiedOptions?.header?.extra, "buffer")) { + modifiedOptions.header.extra = Uint8Array.from(modifiedOptions.header.extra); + } + + return deflateImpl(inputArray, modifiedOptions); +} + +export function deflateRaw( + input: string | buffer, + options?: Exclude, "raw">, +): buffer | undefined { + const inputArray = Uint8Array.from(typeIs(input, "string") ? buffer.fromstring(input) : input); + const modifiedOptions = options as Exclude, "raw">; + if (typeIs(modifiedOptions?.dictionary, "buffer")) { + modifiedOptions.dictionary = Uint8Array.from(modifiedOptions.dictionary); + } + if (typeIs(modifiedOptions?.header?.extra, "buffer")) { + modifiedOptions.header.extra = Uint8Array.from(modifiedOptions.header.extra); + } + + return deflateRawImpl(inputArray, modifiedOptions); +} + +export { Deflate }; + +// +// Constants exports +// + +export const constants = require("./zlib/constants") as typeof import("./zlib/constants"); diff --git a/src/inflate.ts b/src/inflate.ts index 8f93f56..2880710 100644 --- a/src/inflate.ts +++ b/src/inflate.ts @@ -1,7 +1,7 @@ "use strict"; import type { InflateState } from "./zlib/inflate"; -import type Messages from "./zlib/messages"; +import type Messages from "./zlib/messages"; import type * as TypedArrays from "./utils/typedArrays"; const zlibInflate = require("./zlib/inflate") as typeof import("./zlib/inflate"); @@ -14,16 +14,8 @@ const { assign, flattenChunks } = require("./utils/common") as typeof import("./ /* Public constants ==========================================================*/ /* ===========================================================================*/ -export const { - Z_NO_FLUSH, - Z_FINISH, - Z_OK, - Z_STREAM_END, - Z_NEED_DICT, - Z_STREAM_ERROR, - Z_DATA_ERROR, - Z_MEM_ERROR, -} = require("./zlib/constants") as typeof import("./zlib/constants"); +const { Z_NO_FLUSH, Z_FINISH, Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR } = + require("./zlib/constants") as typeof import("./zlib/constants"); /* ===========================================================================*/ @@ -104,7 +96,7 @@ export const { * ``` **/ -type Options = { +export type Options = { chunkSize: number; windowBits: number; to: string; diff --git a/src/zlib/README.md b/src/zlib/README.md index 88a8752..47e2874 100644 --- a/src/zlib/README.md +++ b/src/zlib/README.md @@ -21,20 +21,18 @@ Copyright: (C) 1995-2013 Jean-loup Gailly and Mark Adler (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin - -From zlib's README -============================================================================= +# From zlib's README Acknowledgments: - The deflate format used by zlib was defined by Phil Katz. The deflate and - zlib specifications were written by L. Peter Deutsch. Thanks to all the - people who reported problems and suggested various improvements in zlib; they - are too numerous to cite here. +The deflate format used by zlib was defined by Phil Katz. The deflate and +zlib specifications were written by L. Peter Deutsch. Thanks to all the +people who reported problems and suggested various improvements in zlib; they +are too numerous to cite here. Copyright notice: - (C) 1995-2013 Jean-loup Gailly and Mark Adler +(C) 1995-2013 Jean-loup Gailly and Mark Adler Copyright (c) <''year''> <''copyright holders''> @@ -54,6 +52,5 @@ freely, subject to the following restrictions: misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu +Jean-loup Gailly Mark Adler +jloup@gzip.org madler@alumni.caltech.edu diff --git a/src/zlib/deflate.ts b/src/zlib/deflate.ts index cbc46d5..6c03b56 100644 --- a/src/zlib/deflate.ts +++ b/src/zlib/deflate.ts @@ -24,7 +24,8 @@ import type { TreeDesc } from "./trees"; import type Messages from "./messages"; import type * as TypedArrays from "../utils/typedArrays"; -const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = require("./trees") as typeof import("./trees"); +const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = + require("./trees") as typeof import("./trees"); const { adler32 } = require("./adler32") as typeof import("./adler32"); const { crc32 } = require("./crc32") as typeof import("./crc32"); const { diff --git a/src/zlib/zstream.ts b/src/zlib/zstream.ts index fc80b5e..778c46b 100644 --- a/src/zlib/zstream.ts +++ b/src/zlib/zstream.ts @@ -1,6 +1,6 @@ "use strict"; -import type * as TypedArrays from "../utils/typedArrays"; +import type * as TypedArrays from "../utils/typedArrays"; const { Z_UNKNOWN } = require("./constants") as typeof import("./constants"); diff --git a/tsconfig.json b/tsconfig.json index b255ab8..baab57e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,5 +23,7 @@ "incremental": true, "tsBuildInfoFile": "out/tsconfig.tsbuildinfo", "declaration": true - } + }, + + "include": ["src/**/*.ts"] }