🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@kucrut/vite-for-wp

Package Overview
Dependencies
Maintainers
0
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@kucrut/vite-for-wp - npm Package Compare versions

Comparing version

to
0.11.3

src/types.ts

8

package.json
{
"name": "@kucrut/vite-for-wp",
"version": "0.11.2",
"version": "0.11.3",
"description": "Vite integration for WordPress plugins and themes development.",

@@ -32,4 +32,4 @@ "author": "Dzikri Aziz",

"typescript": "~5.7.3",
"typescript-eslint": "^8.26.0",
"vite": "^6.2.1",
"typescript-eslint": "^8.26.1",
"vite": "^6.2.2",
"vite-plugin-external": "^6.0.1"

@@ -39,3 +39,3 @@ },

"rollup-plugin-external-globals": "^0.13.0",
"vite": "^6.2.1",
"vite": "^6.2.2",
"vite-plugin-external": "^6.0.1"

@@ -42,0 +42,0 @@ },

@@ -158,5 +158,3 @@ # Vite for WordPress

wp_scripts(),
react( {
jsxRuntime: 'classic',
} ),
react(),
],

@@ -163,0 +161,0 @@ };

import { createLogger, mergeConfig } from 'vite';
import { dev_server } from './plugins/dev-server.js';
/** @typedef {import('vite').UserConfig} UserConfig */
/** @typedef {import('vite').ResolvedConfig['build']['rollupOptions']['input']} Input */
/** @typedef {import('vite').ResolvedConfig['build']['outDir']} OutDir */
/** @typedef {import('vite').PluginOption} Plugin */
/**
* v4wp options
*
* @typedef V4wpOptions
*
* @property {Input=} input Entry points (optional, defaults to 'src/main.js'). See https://rollupjs.org/configuration-options/#input
* @property {OutDir=} outDir Output directory (optional, defaults to 'dist'). See https://vitejs.dev/config/build-options.html#build-outdir
*/
/**
* v4wp

@@ -25,5 +11,4 @@ *

*
* @type {(options?: V4wpOptions) => Plugin}
* @param {V4wpOptions=} options Plugin options (optional).
* @return {Plugin} Vite plugin objects.
* @param {import('../types.ts').V4wpOptions=} options Plugin options (optional).
* @return {import('vite').PluginOption[]} Vite plugin objects.
*/

@@ -33,3 +18,3 @@ export function v4wp( options = {} ) {

/** @type {Plugin} */
/** @type {import('vite').Plugin} */
const plugin = {

@@ -65,9 +50,7 @@ name: 'v4wp:config',

*
* @type {(input: Input, out_dir: string, extra_config?: UserConfig) => UserConfig}
* @param {import('../types.ts').Input} input Entry points. See https://rollupjs.org/configuration-options/#input
* @param {string} out_dir Output directory. See https://vitejs.dev/config/build-options.html#build-outdir
* @param {import('vite').UserConfig=} extra_config Extra configuration.
*
* @param {Input} input Entry points. See https://rollupjs.org/configuration-options/#input
* @param {string} out_dir Output directory. See https://vitejs.dev/config/build-options.html#build-outdir
* @param {UserConfig=} extra_config Extra configuration.
*
* @return {UserConfig} Vite configuration object.
* @return {import('vite').UserConfig} Vite configuration object.
*/

@@ -81,3 +64,3 @@ export default function create_config( input, out_dir, extra_config ) {

/** @type {UserConfig} */
/** @type {import('vite').UserConfig} */
let config = {

@@ -84,0 +67,0 @@ clearScreen: false,

@@ -6,10 +6,2 @@ import { choose_port } from '../utils/choose-port.js';

/**
* Dev Server Options
*
* @typedef DevServerOptions
*
* @property {string=} manifest_dir Path to directory where the dev server manifest should be stored. Defaults to the value of `build.outDir` option.
*/
/**
* Dev server plugin

@@ -20,6 +12,4 @@ *

*
* @type {(options?: DevServerOptions) => import('vite').Plugin}
*
* @param {DevServerOptions=} options Plugin options.
* @return {import('vite').Plugin} Plugin object.
* @param {import('../../types.ts').DevServerOptions=} options Plugin options.
* @return {import('vite').Plugin<import('../../types.ts').DevServerOptions>} Plugin object.
*/

@@ -26,0 +16,0 @@ export function dev_server( options = {} ) {

import { wp_globals } from '../utils/wp-globals.js';
/** @typedef {import('vite').PluginOption} Plugin */
/**

@@ -23,5 +21,4 @@ * WPScriptsOptions

*
* @type {(options?: WPScriptsOptions) => Plugin}
* @param {WPScriptsOptions} options Plugin options.
* @return {Promise<Plugin>} Vite plugins objects.
* @return {Promise<import('vite').PluginOption[]>} Vite plugins objects.
*/

@@ -39,3 +36,3 @@ export async function wp_scripts( options = {} ) {

/** @type {Plugin} */
/** @type {import('vite').Plugin<WPScriptsOptions>} */
const plugin = {

@@ -49,3 +46,6 @@ name: 'v4wp:wp-scripts',

rollupOptions: {
external: Object.keys( scripts ),
external: [
...Object.keys( scripts ),
'react/jsx-runtime',
],
output: {

@@ -52,0 +52,0 @@ globals: scripts,

/**
* Given a kebab-case string, returns a new camelCase string.
*
* @type {(str: string) => string}
* @param {string} str Input kebab-case string.

@@ -6,0 +5,0 @@ * @return {string} Camel-cased string.

import { createServer } from 'net';
/**
* choose_port options
*
* @typedef ChoosePortOptions
*
* @property {string=} [host=localhost] Host name or IP address, defaults to 'localhost'.
* @property {number=} [port=5173] Preferred port number, defaults to 5173
*/
/**
* Choose port

@@ -17,4 +8,3 @@ *

*
* @type {(options: ChoosePortOptions) => Promise<number>}
* @param {ChoosePortOptions} options Options.
* @param {import('../../types.ts').ChoosePortOptions} options Options.
* @return {Promise<number>} Chosen port.

@@ -21,0 +11,0 @@ */

@@ -6,3 +6,2 @@ import { camel_case_dash } from './camel-case-dash.js';

*
* @type {() => Record<string, string>}
* @return {Record<string, string>} Object containing global script names registered by WordPress.

@@ -22,12 +21,14 @@ */

'blocks',
'commands',
'components',
'compose',
'core-commands',
'core-data',
'customize-widgets',
'data-controls',
'data',
'data-controls',
'date',
'deprecated',
'dom-ready',
'dom',
'dom-ready',
'edit-post',

@@ -39,2 +40,3 @@ 'edit-site',

'escape-html',
'fields',
'format-library',

@@ -51,10 +53,13 @@ 'hooks',

'nux',
'patterns',
'plugins',
'preferences-persistence',
'preferences',
'preferences-persistence',
'primitives',
'priority-queue',
'private-apis',
'redux-routine',
'reusable-blocks',
'rich-text',
'router',
'server-side-render',

@@ -64,2 +69,3 @@ 'shortcode',

'token-list',
'undo-manager',
'url',

@@ -66,0 +72,0 @@ 'viewport',

declare module '@kucrut/vite-for-wp' {
export function v4wp(options?: V4wpOptions): Plugin;
export default function create_config(input: Input, out_dir: string, extra_config?: UserConfig): UserConfig;
export type UserConfig = import("vite").UserConfig;
export type Input = import("vite").ResolvedConfig["build"]["rollupOptions"]["input"];
export type OutDir = import("vite").ResolvedConfig["build"]["outDir"];
export type Plugin = import("vite").PluginOption;
import type { ResolvedConfig } from 'vite';
/**
* v4wp options
* v4wp
*
* Vite plugin to simplify plugins & themes development on WordPress with Vite.
*
* @since 0.7.0
*
* @param options Plugin options (optional).
* @return {import('vite').PluginOption[]} Vite plugin objects.
*/
export type V4wpOptions = {
export function v4wp(options?: V4wpOptions | undefined): import("vite").PluginOption[];
/**
* Create vite config
*
* @deprecated Use v4wp() instead.
*
* @param input Entry points. See https://rollupjs.org/configuration-options/#input
* @param out_dir Output directory. See https://vitejs.dev/config/build-options.html#build-outdir
* @param extra_config Extra configuration.
*
* @return {import('vite').UserConfig} Vite configuration object.
*/
export default function create_config(input: Input, out_dir: string, extra_config?: import("vite").UserConfig | undefined): import("vite").UserConfig;
type Input = ResolvedConfig['build']['rollupOptions']['input'];
interface V4wpOptions {
/**
* Entry points (optional, defaults to 'src/main.js'). See https://rollupjs.org/configuration-options/#input
* @description Entry points (optional, defaults to 'src/main.js'). See https://rollupjs.org/configuration-options/#input
*/
input?: Input | undefined;
input?: Input;
/**
* Output directory (optional, defaults to 'dist'). See https://vitejs.dev/config/build-options.html#build-outdir
* @description Output directory (optional, defaults to 'dist'). See https://vitejs.dev/config/build-options.html#build-outdir
*/
outDir?: OutDir | undefined;
};
outDir?: ResolvedConfig['build']['outDir'];
}

@@ -26,17 +42,33 @@ export {};

declare module '@kucrut/vite-for-wp/plugins' {
export function dev_server(options?: DevServerOptions): import("vite").Plugin;
/**
* Dev Server Options
* Dev server plugin
*
* @since 0.1.0
* @since 0.8.0 Accept options.
*
* @param options Plugin options.
* @return {import('vite').Plugin<import('../../types.ts').DevServerOptions>} Plugin object.
*/
type DevServerOptions = {
/**
* Path to directory where the dev server manifest should be stored. Defaults to the value of `build.outDir` option.
*/
manifest_dir?: string | undefined;
};
export function wp_scripts(options?: WPScriptsOptions): Plugin;
type Plugin = import("vite").PluginOption;
export function dev_server(options?: DevServerOptions | undefined): import("vite").Plugin<DevServerOptions>;
/**
* WPScriptsOptions
*
* */
/**
* WordPress scripts plugin
*
* Provide easy access to built-in WordPress scripts and exclude them from the final build.
*
* @since 0.7.0
* @since 0.8.0 Import dependencies dynamically.
* @since 0.11.0 Remove vite-plugin-external dependency.
* @since 0.11.1 Bring back vite-plugin-external dependency with proper args.
*
* @param options Plugin options.
* @return {Promise<import('vite').PluginOption[]>} Vite plugins objects.
*/
export function wp_scripts(options?: WPScriptsOptions): Promise<import("vite").PluginOption[]>;
/**
* WPScriptsOptions
*/
type WPScriptsOptions = {

@@ -50,2 +82,8 @@ /**

};
interface DevServerOptions {
/**
* @description Path to directory where the dev server manifest should be stored. Defaults to the value of `build.outDir` option.
*/
manifest_dir?: string;
}

@@ -56,18 +94,36 @@ export {};

declare module '@kucrut/vite-for-wp/utils' {
/**
* Given a kebab-case string, returns a new camelCase string.
*
* @param str Input kebab-case string.
* @return {string} Camel-cased string.
*/
export function camel_case_dash(str: string): string;
export function choose_port(options: ChoosePortOptions): Promise<number>;
/**
* choose_port options
* Choose port
*
* Stolen from vite.
*
* @param options Options.
* @return {Promise<number>} Chosen port.
*/
type ChoosePortOptions = {
export function choose_port(options?: ChoosePortOptions): Promise<number>;
/**
* Get all global scripts registered by WordPress
*
* @return {Record<string, string>} Object containing global script names registered by WordPress.
*/
export function wp_globals(): Record<string, string>;
interface ChoosePortOptions {
/**
* Host name or IP address, defaults to 'localhost'.
* @default localhost
* @description Host name or IP address, defaults to 'localhost'.
*/
host?: string | undefined;
host?: string;
/**
* Preferred port number, defaults to 5173
* @default 5173
* @description Preferred port number, defaults to 5173.
*/
port?: number | undefined;
};
export function wp_globals(): Record<string, string>;
port?: number;
}

@@ -74,0 +130,0 @@ export {};

Sorry, the diff of this file is not supported yet