@wp-playground/blueprints 0.3.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/blueprint-schema.json +282 -176
- package/index.cjs +257 -201
- package/index.d.ts +1771 -7
- package/index.js +3932 -3513
- package/lib/steps/apply-wordpress-patches/index.d.ts +2 -1
- package/lib/steps/common.d.ts +9 -6
- package/lib/steps/define-wp-config-consts.d.ts +7 -8
- package/lib/steps/export-wxr.d.ts +9 -0
- package/lib/steps/export-wxz.d.ts +9 -0
- package/lib/steps/handlers.d.ts +7 -1
- package/lib/steps/import-file.d.ts +29 -0
- package/lib/steps/import-wp-content.d.ts +41 -0
- package/lib/steps/index.d.ts +9 -5
- package/lib/steps/install-asset.d.ts +1 -1
- package/lib/steps/request.d.ts +1 -1
- package/lib/steps/run-php-with-options.d.ts +1 -1
- package/lib/steps/run-sql.d.ts +35 -0
- package/lib/steps/unzip.d.ts +28 -0
- package/lib/steps/zip-wp-content.d.ts +17 -0
- package/package.json +2 -2
- package/lib/blueprint.d.ts +0 -31
- package/lib/compile.d.ts +0 -43
- package/lib/resources.d.ts +0 -211
- package/lib/steps/import-export.d.ts +0 -107
- package/lib/steps/migration.d.ts +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UniversalPHP } from '
|
|
1
|
+
import { UniversalPHP } from '../../../../../../php-wasm/universal/src/index.ts';
|
|
2
2
|
import { StepHandler } from '..';
|
|
3
3
|
/**
|
|
4
4
|
* @private
|
|
@@ -13,6 +13,7 @@ export interface ApplyWordPressPatchesStep {
|
|
|
13
13
|
disableWpNewBlogNotification?: boolean;
|
|
14
14
|
makeEditorFrameControlled?: boolean;
|
|
15
15
|
prepareForRunningInsideWebBrowser?: boolean;
|
|
16
|
+
addFetchNetworkTransport?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export declare const applyWordPressPatches: StepHandler<ApplyWordPressPatchesStep>;
|
|
18
19
|
/**
|
package/lib/steps/common.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { UniversalPHP } from '
|
|
1
|
+
import type { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Used by the export step to exclude the Playground-specific files
|
|
4
|
+
* from the zip file. Keep it in sync with the list of files created
|
|
5
|
+
* by WordPressPatcher.
|
|
6
|
+
*/
|
|
7
|
+
export declare const wpContentFilesExcludedFromExport: string[];
|
|
2
8
|
export declare function zipNameToHumanName(zipName: string): string;
|
|
3
9
|
type PatchFileCallback = (contents: string) => string | Uint8Array;
|
|
4
10
|
export declare function updateFile(php: UniversalPHP, path: string, callback: PatchFileCallback): Promise<void>;
|
|
5
11
|
export declare function fileToUint8Array(file: File): Promise<Uint8Array>;
|
|
6
|
-
declare
|
|
7
|
-
|
|
8
|
-
prototype: File;
|
|
9
|
-
};
|
|
10
|
-
export { FileWithArrayBuffer as File };
|
|
12
|
+
export declare function runPhpWithZipFunctions(playground: UniversalPHP, code: string): Promise<import('../../../../../php-wasm/universal/src/index.ts').PHPResponse>;
|
|
13
|
+
export {};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { StepHandler } from '.';
|
|
2
|
-
export declare const VFS_TMP_DIRECTORY = "/vfs-blueprints";
|
|
3
2
|
/**
|
|
4
3
|
* @inheritDoc defineWpConfigConsts
|
|
5
4
|
* @hasRunnableExample
|
|
@@ -10,8 +9,7 @@ export declare const VFS_TMP_DIRECTORY = "/vfs-blueprints";
|
|
|
10
9
|
* "step": "defineWpConfigConsts",
|
|
11
10
|
* "consts": {
|
|
12
11
|
* "WP_DEBUG": true
|
|
13
|
-
* }
|
|
14
|
-
* "virtualize": true
|
|
12
|
+
* }
|
|
15
13
|
* }
|
|
16
14
|
* </code>
|
|
17
15
|
*/
|
|
@@ -20,15 +18,16 @@ export interface DefineWpConfigConstsStep {
|
|
|
20
18
|
/** The constants to define */
|
|
21
19
|
consts: Record<string, unknown>;
|
|
22
20
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* @see https://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
|
|
21
|
+
* @deprecated This option is noop and will be removed in a future version.
|
|
22
|
+
* This option is only kept in here to avoid breaking Blueprint schema validation
|
|
23
|
+
* for existing apps using this option.
|
|
27
24
|
*/
|
|
28
25
|
virtualize?: boolean;
|
|
29
26
|
}
|
|
30
27
|
/**
|
|
31
|
-
* Defines
|
|
28
|
+
* Defines constants to be used in wp-config.php file.
|
|
29
|
+
*
|
|
30
|
+
* This step can be called multiple times, and the constants will be merged.
|
|
32
31
|
*
|
|
33
32
|
* @param playground The playground client.
|
|
34
33
|
* @param wpConfigConst
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Exports the WordPress database as a WXR file using
|
|
4
|
+
* the core WordPress export tool.
|
|
5
|
+
*
|
|
6
|
+
* @param playground Playground client
|
|
7
|
+
* @returns WXR file
|
|
8
|
+
*/
|
|
9
|
+
export declare function exportWXR(playground: UniversalPHP): Promise<File>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Exports the WordPress database as a WXZ file using
|
|
4
|
+
* the export-wxz plugin from https://github.com/akirk/export-wxz.
|
|
5
|
+
*
|
|
6
|
+
* @param playground Playground client
|
|
7
|
+
* @returns WXZ file
|
|
8
|
+
*/
|
|
9
|
+
export declare function exportWXZ(playground: UniversalPHP): Promise<File>;
|
package/lib/steps/handlers.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { activateTheme } from './activate-theme';
|
|
|
3
3
|
export { applyWordPressPatches } from './apply-wordpress-patches';
|
|
4
4
|
export { runPHP } from './run-php';
|
|
5
5
|
export { runPHPWithOptions } from './run-php-with-options';
|
|
6
|
+
export { runSql } from './run-sql';
|
|
6
7
|
export { setPhpIniEntry } from './set-php-ini-entry';
|
|
7
8
|
export { request } from './request';
|
|
8
9
|
export { cp } from './cp';
|
|
@@ -12,10 +13,15 @@ export { mkdir } from './mkdir';
|
|
|
12
13
|
export { rmdir } from './rmdir';
|
|
13
14
|
export { writeFile } from './write-file';
|
|
14
15
|
export { defineSiteUrl } from './define-site-url';
|
|
15
|
-
export { importFile
|
|
16
|
+
export { importFile } from './import-file';
|
|
17
|
+
export { importWordPressFiles } from './import-wp-content';
|
|
18
|
+
export { exportWXR } from './export-wxr';
|
|
19
|
+
export { exportWXZ } from './export-wxz';
|
|
20
|
+
export { unzip } from './unzip';
|
|
16
21
|
export { installPlugin } from './install-plugin';
|
|
17
22
|
export { installTheme } from './install-theme';
|
|
18
23
|
export { login } from './login';
|
|
19
24
|
export { runWpInstallationWizard } from './run-wp-installation-wizard';
|
|
20
25
|
export { setSiteOptions, updateUserMeta } from './site-data';
|
|
21
26
|
export { defineWpConfigConsts } from './define-wp-config-consts';
|
|
27
|
+
export { zipWpContent } from './zip-wp-content';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { StepHandler } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc importFile
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* <code>
|
|
7
|
+
* {
|
|
8
|
+
* "step": "importFile",
|
|
9
|
+
* "file": {
|
|
10
|
+
* "resource": "url",
|
|
11
|
+
* "url": "https://your-site.com/starter-content.wxz"
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* </code>
|
|
15
|
+
*/
|
|
16
|
+
export interface ImportFileStep<ResourceType> {
|
|
17
|
+
step: 'importFile';
|
|
18
|
+
/** The file to import */
|
|
19
|
+
file: ResourceType;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Uploads a file to the WordPress importer and returns the response.
|
|
23
|
+
* Supports both WXR and WXZ files.
|
|
24
|
+
*
|
|
25
|
+
* @see https://github.com/WordPress/wordpress-importer/compare/master...akirk:wordpress-importer:import-wxz.patch
|
|
26
|
+
* @param playground Playground client.
|
|
27
|
+
* @param file The file to import.
|
|
28
|
+
*/
|
|
29
|
+
export declare const importFile: StepHandler<ImportFileStep<File>>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { StepHandler } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc importWordPressFiles
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* <code>
|
|
7
|
+
* {
|
|
8
|
+
* "step": "importWordPressFilesStep",
|
|
9
|
+
* "wordPressFilesZip": {
|
|
10
|
+
* "resource": "fetch",
|
|
11
|
+
* "url": "https://mysite.com/import.zip"
|
|
12
|
+
* }
|
|
13
|
+
* }
|
|
14
|
+
* </code>
|
|
15
|
+
*/
|
|
16
|
+
export interface ImportWordPressFilesStep<ResourceType> {
|
|
17
|
+
step: 'importWordPressFiles';
|
|
18
|
+
/**
|
|
19
|
+
* The zip file containing the top-level WordPress files and
|
|
20
|
+
* directories.
|
|
21
|
+
*/
|
|
22
|
+
wordPressFilesZip: ResourceType;
|
|
23
|
+
/**
|
|
24
|
+
* The path inside the zip file where the WordPress files are.
|
|
25
|
+
*/
|
|
26
|
+
pathInZip?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Imports top-level WordPress files from a given zip file into
|
|
30
|
+
* the documentRoot. For example, if a zip file contains the
|
|
31
|
+
* `wp-content` and `wp-includes` directories, they will replace
|
|
32
|
+
* the corresponding directories in Playground's documentRoot.
|
|
33
|
+
*
|
|
34
|
+
* Any files that Playground recognizes as "excluded from the export"
|
|
35
|
+
* will carry over from the existing document root into the imported
|
|
36
|
+
* directories. For example, the sqlite-database-integration plugin.
|
|
37
|
+
*
|
|
38
|
+
* @param playground Playground client.
|
|
39
|
+
* @param wordPressFilesZip Zipped WordPress site.
|
|
40
|
+
*/
|
|
41
|
+
export declare const importWordPressFiles: StepHandler<ImportWordPressFilesStep<File>>;
|
package/lib/steps/index.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ProgressTracker } from '
|
|
2
|
-
import { UniversalPHP } from '
|
|
1
|
+
import { ProgressTracker } from '../../../../../php-wasm/progress/src/index.ts';
|
|
2
|
+
import { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
3
3
|
import { FileReference } from '../resources';
|
|
4
4
|
import { ActivatePluginStep } from './activate-plugin';
|
|
5
5
|
import { ApplyWordPressPatchesStep } from './apply-wordpress-patches';
|
|
6
6
|
import { DefineSiteUrlStep } from './define-site-url';
|
|
7
|
-
import { ImportFileStep, ReplaceSiteStep, UnzipStep } from './import-export';
|
|
8
7
|
import { InstallPluginStep, InstallPluginOptions } from './install-plugin';
|
|
9
8
|
import { InstallThemeStep, InstallThemeOptions } from './install-theme';
|
|
10
9
|
import { LoginStep } from './login';
|
|
@@ -13,6 +12,7 @@ import { SetSiteOptionsStep, UpdateUserMetaStep } from './site-data';
|
|
|
13
12
|
import { RmStep } from './rm';
|
|
14
13
|
import { CpStep } from './cp';
|
|
15
14
|
import { RmdirStep } from './rmdir';
|
|
15
|
+
import { RunSqlStep } from './run-sql';
|
|
16
16
|
import { MkdirStep } from './mkdir';
|
|
17
17
|
import { MvStep } from './mv';
|
|
18
18
|
import { SetPhpIniEntryStep } from './set-php-ini-entry';
|
|
@@ -22,6 +22,9 @@ import { RequestStep } from './request';
|
|
|
22
22
|
import { WriteFileStep } from './write-file';
|
|
23
23
|
import { DefineWpConfigConstsStep } from './define-wp-config-consts';
|
|
24
24
|
import { ActivateThemeStep } from './activate-theme';
|
|
25
|
+
import { UnzipStep } from './unzip';
|
|
26
|
+
import { ImportWordPressFilesStep } from './import-wp-content';
|
|
27
|
+
import { ImportFileStep } from './import-file';
|
|
25
28
|
export type Step = GenericStep<FileReference>;
|
|
26
29
|
export type StepDefinition = Step & {
|
|
27
30
|
progress?: {
|
|
@@ -29,12 +32,13 @@ export type StepDefinition = Step & {
|
|
|
29
32
|
caption?: string;
|
|
30
33
|
};
|
|
31
34
|
};
|
|
35
|
+
export { wpContentFilesExcludedFromExport } from './common';
|
|
32
36
|
/**
|
|
33
37
|
* If you add a step here, make sure to also
|
|
34
38
|
* add it to the exports below.
|
|
35
39
|
*/
|
|
36
|
-
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | ImportFileStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep |
|
|
37
|
-
export type { ActivatePluginStep, ActivateThemeStep, ApplyWordPressPatchesStep, CpStep, DefineWpConfigConstsStep, DefineSiteUrlStep, ImportFileStep, InstallPluginStep, InstallPluginOptions, InstallThemeStep, InstallThemeOptions, LoginStep, MkdirStep, MvStep, RequestStep,
|
|
40
|
+
export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | ImportFileStep<Resource> | ImportWordPressFilesStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | RunSqlStep<Resource> | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep | UpdateUserMetaStep | WriteFileStep<Resource>;
|
|
41
|
+
export type { ActivatePluginStep, ActivateThemeStep, ApplyWordPressPatchesStep, CpStep, DefineWpConfigConstsStep, DefineSiteUrlStep, ImportFileStep, ImportWordPressFilesStep, InstallPluginStep, InstallPluginOptions, InstallThemeStep, InstallThemeOptions, LoginStep, MkdirStep, MvStep, RequestStep, RmStep, RmdirStep, RunPHPStep, RunPHPWithOptionsStep, RunWpInstallationWizardStep, RunSqlStep, WordPressInstallationOptions, SetPhpIniEntryStep, SetSiteOptionsStep, UnzipStep, UpdateUserMetaStep, WriteFileStep, };
|
|
38
42
|
/**
|
|
39
43
|
* Progress reporting details.
|
|
40
44
|
*/
|
package/lib/steps/request.d.ts
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { StepHandler } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc runSql
|
|
4
|
+
* @hasRunnableExample
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* <code>
|
|
8
|
+
* {
|
|
9
|
+
* "step": "runSql",
|
|
10
|
+
* "sql": {
|
|
11
|
+
* "resource": "literal",
|
|
12
|
+
* "name": "schema.sql",
|
|
13
|
+
* "contents": "DELETE FROM wp_posts"
|
|
14
|
+
* }
|
|
15
|
+
* }
|
|
16
|
+
* </code>
|
|
17
|
+
*/
|
|
18
|
+
export interface RunSqlStep<ResourceType> {
|
|
19
|
+
/**
|
|
20
|
+
* The step identifier.
|
|
21
|
+
*/
|
|
22
|
+
step: 'runSql';
|
|
23
|
+
/**
|
|
24
|
+
* The SQL to run. Each non-empty line must contain a valid SQL query.
|
|
25
|
+
*/
|
|
26
|
+
sql: ResourceType;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Run one or more SQL queries.
|
|
30
|
+
*
|
|
31
|
+
* This step will treat each non-empty line in the input SQL as a query and
|
|
32
|
+
* try to execute it using `$wpdb`. Queries spanning multiple lines are not
|
|
33
|
+
* yet supported.
|
|
34
|
+
*/
|
|
35
|
+
export declare const runSql: StepHandler<RunSqlStep<File>>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { StepHandler } from '.';
|
|
2
|
+
/**
|
|
3
|
+
* @inheritDoc unzip
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* <code>
|
|
7
|
+
* {
|
|
8
|
+
* "step": "unzip",
|
|
9
|
+
* "zipPath": "/wordpress/data.zip",
|
|
10
|
+
* "extractToPath": "/wordpress"
|
|
11
|
+
* }
|
|
12
|
+
* </code>
|
|
13
|
+
*/
|
|
14
|
+
export interface UnzipStep {
|
|
15
|
+
step: 'unzip';
|
|
16
|
+
/** The zip file to extract */
|
|
17
|
+
zipPath: string;
|
|
18
|
+
/** The path to extract the zip file to */
|
|
19
|
+
extractToPath: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Unzip a zip file.
|
|
23
|
+
*
|
|
24
|
+
* @param playground Playground client.
|
|
25
|
+
* @param zipPath The zip file to unzip.
|
|
26
|
+
* @param extractTo The directory to extract the zip file to.
|
|
27
|
+
*/
|
|
28
|
+
export declare const unzip: StepHandler<UnzipStep>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UniversalPHP } from '../../../../../php-wasm/universal/src/index.ts';
|
|
2
|
+
interface ZipWpContentOptions {
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* A temporary workaround to enable including the WordPress default theme
|
|
6
|
+
* in the exported zip file.
|
|
7
|
+
*/
|
|
8
|
+
selfContained?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Replace the current wp-content directory with one from the provided zip file.
|
|
12
|
+
*
|
|
13
|
+
* @param playground Playground client.
|
|
14
|
+
* @param wpContentZip Zipped WordPress site.
|
|
15
|
+
*/
|
|
16
|
+
export declare const zipWpContent: (playground: UniversalPHP, { selfContained }?: ZipWpContentOptions) => Promise<Uint8Array>;
|
|
17
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/blueprints",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"access": "public",
|
|
22
22
|
"directory": "../../../dist/packages/playground/blueprints"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "6c2256a8f3b6bafb2d9a5860f236b00832839769",
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">=16.15.1",
|
|
27
27
|
"npm": ">=8.11.0"
|
package/lib/blueprint.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { SupportedPHPExtensionBundle, SupportedPHPVersion } from '@php-wasm/universal';
|
|
2
|
-
import { StepDefinition } from './steps';
|
|
3
|
-
export interface Blueprint {
|
|
4
|
-
/**
|
|
5
|
-
* The URL to navigate to after the blueprint has been run.
|
|
6
|
-
*/
|
|
7
|
-
landingPage?: string;
|
|
8
|
-
/**
|
|
9
|
-
* The preferred PHP and WordPress versions to use.
|
|
10
|
-
*/
|
|
11
|
-
preferredVersions?: {
|
|
12
|
-
/**
|
|
13
|
-
* The preferred PHP version to use.
|
|
14
|
-
* If not specified, the latest supported version will be used
|
|
15
|
-
*/
|
|
16
|
-
php: SupportedPHPVersion | 'latest';
|
|
17
|
-
/**
|
|
18
|
-
* The preferred WordPress version to use.
|
|
19
|
-
* If not specified, the latest supported version will be used
|
|
20
|
-
*/
|
|
21
|
-
wp: string | 'latest';
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* The PHP extensions to use.
|
|
25
|
-
*/
|
|
26
|
-
phpExtensionBundles?: SupportedPHPExtensionBundle[];
|
|
27
|
-
/**
|
|
28
|
-
* The steps to run.
|
|
29
|
-
*/
|
|
30
|
-
steps?: Array<StepDefinition | string | undefined | false | null>;
|
|
31
|
-
}
|
package/lib/compile.d.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ProgressTracker } from '@php-wasm/progress';
|
|
2
|
-
import { Semaphore } from '@php-wasm/util';
|
|
3
|
-
import { SupportedPHPExtension, SupportedPHPVersion, UniversalPHP } from '@php-wasm/universal';
|
|
4
|
-
import { StepDefinition } from './steps';
|
|
5
|
-
import { Blueprint } from './blueprint';
|
|
6
|
-
export type CompiledStep = (php: UniversalPHP) => Promise<void> | void;
|
|
7
|
-
export interface CompiledBlueprint {
|
|
8
|
-
/** The requested versions of PHP and WordPress for the blueprint */
|
|
9
|
-
versions: {
|
|
10
|
-
php: SupportedPHPVersion;
|
|
11
|
-
wp: string;
|
|
12
|
-
};
|
|
13
|
-
/** The requested PHP extensions to load */
|
|
14
|
-
phpExtensions: SupportedPHPExtension[];
|
|
15
|
-
/** The compiled steps for the blueprint */
|
|
16
|
-
run: (playground: UniversalPHP) => Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export type OnStepCompleted = (output: any, step: StepDefinition) => any;
|
|
19
|
-
export interface CompileBlueprintOptions {
|
|
20
|
-
/** Optional progress tracker to monitor progress */
|
|
21
|
-
progress?: ProgressTracker;
|
|
22
|
-
/** Optional semaphore to control access to a shared resource */
|
|
23
|
-
semaphore?: Semaphore;
|
|
24
|
-
/** Optional callback with step output */
|
|
25
|
-
onStepCompleted?: OnStepCompleted;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Compiles Blueprint into a form that can be executed.
|
|
29
|
-
*
|
|
30
|
-
* @param playground The PlaygroundClient to use for the compilation
|
|
31
|
-
* @param blueprint The bBueprint to compile
|
|
32
|
-
* @param options Additional options for the compilation
|
|
33
|
-
* @returns The compiled blueprint
|
|
34
|
-
*/
|
|
35
|
-
export declare function compileBlueprint(blueprint: Blueprint, { progress, semaphore, onStepCompleted, }?: CompileBlueprintOptions): CompiledBlueprint;
|
|
36
|
-
export declare function validateBlueprint(blueprintMaybe: object): {
|
|
37
|
-
valid: true;
|
|
38
|
-
errors?: undefined;
|
|
39
|
-
} | {
|
|
40
|
-
valid: false;
|
|
41
|
-
errors: import("ajv").ErrorObject<string, Record<string, any>, unknown>[] | undefined;
|
|
42
|
-
};
|
|
43
|
-
export declare function runBlueprintSteps(compiledBlueprint: CompiledBlueprint, playground: UniversalPHP): Promise<void>;
|
package/lib/resources.d.ts
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import { ProgressTracker } from '@php-wasm/progress';
|
|
2
|
-
import { UniversalPHP } from '@php-wasm/universal';
|
|
3
|
-
import { Semaphore } from '@php-wasm/util';
|
|
4
|
-
export declare const ResourceTypes: readonly ["vfs", "literal", "wordpress.org/themes", "wordpress.org/plugins", "url"];
|
|
5
|
-
export type VFSReference = {
|
|
6
|
-
/** Identifies the file resource as Virtual File System (VFS) */
|
|
7
|
-
resource: 'vfs';
|
|
8
|
-
/** The path to the file in the VFS */
|
|
9
|
-
path: string;
|
|
10
|
-
};
|
|
11
|
-
export type LiteralReference = {
|
|
12
|
-
/** Identifies the file resource as a literal file */
|
|
13
|
-
resource: 'literal';
|
|
14
|
-
/** The name of the file */
|
|
15
|
-
name: string;
|
|
16
|
-
/** The contents of the file */
|
|
17
|
-
contents: string | Uint8Array;
|
|
18
|
-
};
|
|
19
|
-
export type CoreThemeReference = {
|
|
20
|
-
/** Identifies the file resource as a WordPress Core theme */
|
|
21
|
-
resource: 'wordpress.org/themes';
|
|
22
|
-
/** The slug of the WordPress Core theme */
|
|
23
|
-
slug: string;
|
|
24
|
-
};
|
|
25
|
-
export type CorePluginReference = {
|
|
26
|
-
/** Identifies the file resource as a WordPress Core plugin */
|
|
27
|
-
resource: 'wordpress.org/plugins';
|
|
28
|
-
/** The slug of the WordPress Core plugin */
|
|
29
|
-
slug: string;
|
|
30
|
-
};
|
|
31
|
-
export type UrlReference = {
|
|
32
|
-
/** Identifies the file resource as a URL */
|
|
33
|
-
resource: 'url';
|
|
34
|
-
/** The URL of the file */
|
|
35
|
-
url: string;
|
|
36
|
-
/** Optional caption for displaying a progress message */
|
|
37
|
-
caption?: string;
|
|
38
|
-
};
|
|
39
|
-
export type FileReference = VFSReference | LiteralReference | CoreThemeReference | CorePluginReference | UrlReference;
|
|
40
|
-
export declare function isFileReference(ref: any): ref is FileReference;
|
|
41
|
-
export interface ResourceOptions {
|
|
42
|
-
/** Optional semaphore to limit concurrent downloads */
|
|
43
|
-
semaphore?: Semaphore;
|
|
44
|
-
progress?: ProgressTracker;
|
|
45
|
-
}
|
|
46
|
-
export declare abstract class Resource {
|
|
47
|
-
/** Optional progress tracker to monitor progress */
|
|
48
|
-
abstract progress?: ProgressTracker;
|
|
49
|
-
/** A Promise that resolves to the file contents */
|
|
50
|
-
protected promise?: Promise<File>;
|
|
51
|
-
protected playground?: UniversalPHP;
|
|
52
|
-
/**
|
|
53
|
-
* Creates a new Resource based on the given file reference
|
|
54
|
-
*
|
|
55
|
-
* @param ref The file reference to create the Resource for
|
|
56
|
-
* @param options Additional options for the Resource
|
|
57
|
-
* @returns A new Resource instance
|
|
58
|
-
*/
|
|
59
|
-
static create(ref: FileReference, { semaphore, progress }: ResourceOptions): Resource;
|
|
60
|
-
setPlayground(playground: UniversalPHP): void;
|
|
61
|
-
/**
|
|
62
|
-
* Resolves the file contents
|
|
63
|
-
* @returns The resolved file.
|
|
64
|
-
*/
|
|
65
|
-
abstract resolve(): Promise<File>;
|
|
66
|
-
/** The name of the referenced file */
|
|
67
|
-
abstract get name(): string;
|
|
68
|
-
/** Whether this Resource is loaded asynchronously */
|
|
69
|
-
get isAsync(): boolean;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* A `Resource` that represents a file in the VFS (virtual file system) of the playground.
|
|
73
|
-
*/
|
|
74
|
-
export declare class VFSResource extends Resource {
|
|
75
|
-
private resource;
|
|
76
|
-
progress?: ProgressTracker | undefined;
|
|
77
|
-
/**
|
|
78
|
-
* Creates a new instance of `VFSResource`.
|
|
79
|
-
* @param playground The playground client.
|
|
80
|
-
* @param resource The VFS reference.
|
|
81
|
-
* @param progress The progress tracker.
|
|
82
|
-
*/
|
|
83
|
-
constructor(resource: VFSReference, progress?: ProgressTracker | undefined);
|
|
84
|
-
/** @inheritDoc */
|
|
85
|
-
resolve(): Promise<File>;
|
|
86
|
-
/** @inheritDoc */
|
|
87
|
-
get name(): string;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* A `Resource` that represents a literal file.
|
|
91
|
-
*/
|
|
92
|
-
export declare class LiteralResource extends Resource {
|
|
93
|
-
private resource;
|
|
94
|
-
progress?: ProgressTracker | undefined;
|
|
95
|
-
/**
|
|
96
|
-
* Creates a new instance of `LiteralResource`.
|
|
97
|
-
* @param resource The literal reference.
|
|
98
|
-
* @param progress The progress tracker.
|
|
99
|
-
*/
|
|
100
|
-
constructor(resource: LiteralReference, progress?: ProgressTracker | undefined);
|
|
101
|
-
/** @inheritDoc */
|
|
102
|
-
resolve(): Promise<File>;
|
|
103
|
-
/** @inheritDoc */
|
|
104
|
-
get name(): string;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* A base class for `Resource`s that require fetching data from a remote URL.
|
|
108
|
-
*/
|
|
109
|
-
export declare abstract class FetchResource extends Resource {
|
|
110
|
-
progress?: ProgressTracker | undefined;
|
|
111
|
-
/**
|
|
112
|
-
* Creates a new instance of `FetchResource`.
|
|
113
|
-
* @param progress The progress tracker.
|
|
114
|
-
*/
|
|
115
|
-
constructor(progress?: ProgressTracker | undefined);
|
|
116
|
-
/** @inheritDoc */
|
|
117
|
-
resolve(): Promise<File>;
|
|
118
|
-
/**
|
|
119
|
-
* Gets the URL to fetch the data from.
|
|
120
|
-
* @returns The URL.
|
|
121
|
-
*/
|
|
122
|
-
protected abstract getURL(): string;
|
|
123
|
-
/**
|
|
124
|
-
* Gets the caption for the progress tracker.
|
|
125
|
-
* @returns The caption.
|
|
126
|
-
*/
|
|
127
|
-
protected get caption(): string;
|
|
128
|
-
/** @inheritDoc */
|
|
129
|
-
get name(): string;
|
|
130
|
-
/** @inheritDoc */
|
|
131
|
-
get isAsync(): boolean;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* A `Resource` that represents a file available from a URL.
|
|
135
|
-
*/
|
|
136
|
-
export declare class UrlResource extends FetchResource {
|
|
137
|
-
private resource;
|
|
138
|
-
/**
|
|
139
|
-
* Creates a new instance of `UrlResource`.
|
|
140
|
-
* @param resource The URL reference.
|
|
141
|
-
* @param progress The progress tracker.
|
|
142
|
-
*/
|
|
143
|
-
constructor(resource: UrlReference, progress?: ProgressTracker);
|
|
144
|
-
/** @inheritDoc */
|
|
145
|
-
getURL(): string;
|
|
146
|
-
/** @inheritDoc */
|
|
147
|
-
protected get caption(): string;
|
|
148
|
-
}
|
|
149
|
-
export declare function setPluginProxyURL(url: string): void;
|
|
150
|
-
/**
|
|
151
|
-
* A `Resource` that represents a WordPress core theme.
|
|
152
|
-
*/
|
|
153
|
-
export declare class CoreThemeResource extends FetchResource {
|
|
154
|
-
private resource;
|
|
155
|
-
constructor(resource: CoreThemeReference, progress?: ProgressTracker);
|
|
156
|
-
get name(): string;
|
|
157
|
-
getURL(): string;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* A resource that fetches a WordPress plugin from wordpress.org.
|
|
161
|
-
*/
|
|
162
|
-
export declare class CorePluginResource extends FetchResource {
|
|
163
|
-
private resource;
|
|
164
|
-
constructor(resource: CorePluginReference, progress?: ProgressTracker);
|
|
165
|
-
/** @inheritDoc */
|
|
166
|
-
get name(): string;
|
|
167
|
-
/** @inheritDoc */
|
|
168
|
-
getURL(): string;
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Transforms a plugin slug into a directory zip name.
|
|
172
|
-
* If the input already ends with ".zip", returns it unchanged.
|
|
173
|
-
* Otherwise, appends ".latest-stable.zip".
|
|
174
|
-
*/
|
|
175
|
-
export declare function toDirectoryZipName(rawInput: string): string;
|
|
176
|
-
/**
|
|
177
|
-
* A decorator for a resource that adds functionality such as progress tracking and caching.
|
|
178
|
-
*/
|
|
179
|
-
export declare class DecoratedResource<T extends Resource> extends Resource {
|
|
180
|
-
private resource;
|
|
181
|
-
constructor(resource: T);
|
|
182
|
-
/** @inheritDoc */
|
|
183
|
-
resolve(): Promise<File>;
|
|
184
|
-
/** @inheritDoc */
|
|
185
|
-
setPlayground(playground: UniversalPHP): Promise<void>;
|
|
186
|
-
/** @inheritDoc */
|
|
187
|
-
get progress(): ProgressTracker | undefined;
|
|
188
|
-
/** @inheritDoc */
|
|
189
|
-
set progress(value: ProgressTracker | undefined);
|
|
190
|
-
/** @inheritDoc */
|
|
191
|
-
get name(): string;
|
|
192
|
-
/** @inheritDoc */
|
|
193
|
-
get isAsync(): boolean;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* A decorator for a resource that adds caching functionality.
|
|
197
|
-
*/
|
|
198
|
-
export declare class CachedResource<T extends Resource> extends DecoratedResource<T> {
|
|
199
|
-
protected promise?: Promise<File>;
|
|
200
|
-
/** @inheritDoc */
|
|
201
|
-
resolve(): Promise<File>;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* A decorator for a resource that adds concurrency control functionality through a semaphore.
|
|
205
|
-
*/
|
|
206
|
-
export declare class SemaphoreResource<T extends Resource> extends DecoratedResource<T> {
|
|
207
|
-
private readonly semaphore;
|
|
208
|
-
constructor(resource: T, semaphore: Semaphore);
|
|
209
|
-
/** @inheritDoc */
|
|
210
|
-
resolve(): Promise<File>;
|
|
211
|
-
}
|