-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
695 additions
and
2,253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const {Plugin} = require("./bundle.js"); | ||
|
||
/** | ||
* Creates a new plugin. | ||
* @param {Partial<import("./index.js").PluginOptions>} options The plugin options. | ||
* @returns {import("./index.js").Plugin} The newly created instance. | ||
*/ | ||
module.exports = function phpMinifier(options = {}) { | ||
return new Plugin(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import {Transform} from "node:stream"; | ||
|
||
/** | ||
* Minifies PHP source code by removing comments and whitespace. | ||
*/ | ||
export class Plugin extends Transform { | ||
|
||
/** | ||
* The path to the PHP executable. | ||
*/ | ||
readonly binary: string; | ||
|
||
/** | ||
* The operation mode. | ||
*/ | ||
readonly mode: TransformMode; | ||
|
||
/** | ||
* Value indicating whether to silence the plugin output. | ||
*/ | ||
readonly silent: boolean; | ||
|
||
/** | ||
* Creates a new plugin. | ||
* @param options An object providing values to initialize this instance. | ||
*/ | ||
constructor(options?: Partial<PluginOptions>); | ||
} | ||
|
||
/** | ||
* Defines the options of a {@link Plugin} instance. | ||
*/ | ||
export type PluginOptions = { | ||
|
||
/** | ||
* The path to the PHP executable. | ||
*/ | ||
binary: string; | ||
|
||
/** | ||
* The operation mode of the plugin. | ||
*/ | ||
mode: TransformMode; | ||
|
||
/** | ||
* Value indicating whether to silence the plugin output. | ||
*/ | ||
silent: boolean; | ||
}; | ||
|
||
/** | ||
* The operation mode of the minifier. | ||
*/ | ||
export type TransformMode = "fast" | "safe"; | ||
|
||
/** | ||
* Creates a new plugin. | ||
* @param options The plugin options. | ||
* @returns The newly created instance. | ||
*/ | ||
export default function phpMinifier(options?: Partial<PluginOptions>): Plugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import bundle from "./bundle.js"; | ||
|
||
/** | ||
* Creates a new plugin. | ||
* @param {Partial<import("./index.js").PluginOptions>} options The plugin options. | ||
* @returns {import("./index.js").Plugin} The newly created instance. | ||
*/ | ||
export default function phpMinifier(options = {}) { | ||
const {Plugin} = bundle; | ||
return new Plugin(options); | ||
} |
Oops, something went wrong.