@wp-playground/client 0.3.1 → 0.5.2

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.
Files changed (4) hide show
  1. package/index.cjs +258 -202
  2. package/index.d.ts +348 -99
  3. package/index.js +4024 -3598
  4. package/package.json +2 -2
package/index.d.ts CHANGED
@@ -201,6 +201,22 @@ export declare class PHPResponse implements PHPResponseData {
201
201
  */
202
202
  get text(): string;
203
203
  }
204
+ /**
205
+ * Represents an event related to the PHP filesystem.
206
+ */
207
+ export interface PHPRequestEndEvent {
208
+ type: "request.end";
209
+ }
210
+ /**
211
+ * Represents an event related to the PHP instance.
212
+ * This is intentionally not an extension of CustomEvent
213
+ * to make it isomorphic between different JavaScript runtimes.
214
+ */
215
+ export type PHPEvent = PHPRequestEndEvent;
216
+ /**
217
+ * A callback function that handles PHP events.
218
+ */
219
+ export type PHPEventListener = (event: PHPEvent) => void;
204
220
  /**
205
221
  * Handles HTTP requests using PHP runtime as a backend.
206
222
  *
@@ -332,6 +348,24 @@ export interface RequestHandler {
332
348
  documentRoot: string;
333
349
  }
334
350
  export interface IsomorphicLocalPHP extends RequestHandler {
351
+ /**
352
+ * Defines a constant in the PHP runtime.
353
+ * @param key - The name of the constant.
354
+ * @param value - The value of the constant.
355
+ */
356
+ defineConstant(key: string, value: string | number | null): void;
357
+ /**
358
+ * Adds an event listener for a PHP event.
359
+ * @param eventType - The type of event to listen for.
360
+ * @param listener - The listener function to be called when the event is triggered.
361
+ */
362
+ addEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
363
+ /**
364
+ * Removes an event listener for a PHP event.
365
+ * @param eventType - The type of event to remove the listener from.
366
+ * @param listener - The listener function to be removed.
367
+ */
368
+ removeEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
335
369
  /**
336
370
  * Sets the path to the php.ini file to use for the PHP instance.
337
371
  *
@@ -544,8 +578,25 @@ export interface IsomorphicLocalPHP extends RequestHandler {
544
578
  * @param listener Callback function to handle the message.
545
579
  */
546
580
  onMessage(listener: MessageListener): void;
581
+ /**
582
+ * Registers a handler to spawns a child process when
583
+ * `proc_open()`, `popen()`, `exec()`, `system()`, or `passthru()`
584
+ * is called.
585
+ *
586
+ * @param handler Callback function to spawn a process.
587
+ */
588
+ setSpawnHandler(handler: SpawnHandler): void;
547
589
  }
548
- export type MessageListener = (data: string) => void;
590
+ export type MessageListener = (data: string) => Promise<string | Uint8Array | void> | string | void;
591
+ export interface EventEmitter {
592
+ on(event: string, listener: (...args: any[]) => void): this;
593
+ emit(event: string, ...args: any[]): boolean;
594
+ }
595
+ export type ChildProcess = EventEmitter & {
596
+ stdout: EventEmitter;
597
+ stderr: EventEmitter;
598
+ };
599
+ export type SpawnHandler = (command: string) => ChildProcess;
549
600
  export type IsomorphicRemotePHP = Remote<IsomorphicLocalPHP>;
550
601
  export type UniversalPHP = IsomorphicLocalPHP | IsomorphicRemotePHP;
551
602
  export type HTTPMethod = "GET" | "POST" | "HEAD" | "OPTIONS" | "PATCH" | "PUT" | "DELETE";
@@ -655,6 +706,7 @@ export interface ErrnoError extends Error {
655
706
  message: string;
656
707
  }
657
708
  export declare const SupportedPHPVersions: readonly [
709
+ "8.3",
658
710
  "8.2",
659
711
  "8.1",
660
712
  "8.0",
@@ -662,10 +714,9 @@ export declare const SupportedPHPVersions: readonly [
662
714
  "7.3",
663
715
  "7.2",
664
716
  "7.1",
665
- "7.0",
666
- "5.6"
717
+ "7.0"
667
718
  ];
668
- export declare const LatestSupportedPHPVersion: "8.2";
719
+ export declare const LatestSupportedPHPVersion: "8.3";
669
720
  export declare const SupportedPHPVersionsList: string[];
670
721
  export type SupportedPHPVersion = (typeof SupportedPHPVersions)[number];
671
722
  export type SupportedPHPExtension = "iconv" | "mbstring" | "xml-bundle" | "gd";
@@ -753,6 +804,8 @@ export declare class PHPBrowser implements RequestHandler {
753
804
  get absoluteUrl(): string;
754
805
  /** @inheritDoc */
755
806
  get documentRoot(): string;
807
+ setCookies(cookies: string[]): void;
808
+ serializeCookies(): string;
756
809
  }
757
810
  export type RuntimeType = "NODE" | "WEB" | "WORKER";
758
811
  export type PHPRuntimeId = number;
@@ -793,9 +846,14 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
793
846
  * @param serverOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
794
847
  */
795
848
  constructor(PHPRuntimeId?: PHPRuntimeId, serverOptions?: PHPRequestHandlerConfiguration);
849
+ addEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
850
+ removeEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
851
+ dispatchEvent<Event extends PHPEvent>(event: Event): void;
796
852
  /** @inheritDoc */
797
853
  onMessage(listener: MessageListener): Promise<void>;
798
854
  /** @inheritDoc */
855
+ setSpawnHandler(handler: SpawnHandler): Promise<void>;
856
+ /** @inheritDoc */
799
857
  get absoluteUrl(): string;
800
858
  /** @inheritDoc */
801
859
  get documentRoot(): string;
@@ -815,6 +873,7 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
815
873
  /** @inheritDoc */
816
874
  run(request: PHPRunOptions): Promise<PHPResponse>;
817
875
  addServerGlobalEntry(key: string, value: string): void;
876
+ defineConstant(key: string, value: string | number | null): void;
818
877
  /** @inheritDoc */
819
878
  mkdir(path: string): void;
820
879
  /** @inheritDoc */
@@ -837,6 +896,7 @@ declare abstract class BasePHP implements IsomorphicLocalPHP {
837
896
  isDir(path: string): boolean;
838
897
  /** @inheritDoc */
839
898
  fileExists(path: string): boolean;
899
+ exit(code?: number): any;
840
900
  }
841
901
  export interface SemaphoreOptions {
842
902
  concurrency: number;
@@ -1096,6 +1156,7 @@ export interface ApplyWordPressPatchesStep {
1096
1156
  disableWpNewBlogNotification?: boolean;
1097
1157
  makeEditorFrameControlled?: boolean;
1098
1158
  prepareForRunningInsideWebBrowser?: boolean;
1159
+ addFetchNetworkTransport?: boolean;
1099
1160
  }
1100
1161
  export declare const applyWordPressPatches: StepHandler<ApplyWordPressPatchesStep>;
1101
1162
  /**
@@ -1122,92 +1183,6 @@ export interface DefineSiteUrlStep {
1122
1183
  * @param siteUrl
1123
1184
  */
1124
1185
  export declare const defineSiteUrl: StepHandler<DefineSiteUrlStep>;
1125
- /**
1126
- * Full site export support:
1127
- */
1128
- /**
1129
- * Export the current site as a zip file.
1130
- *
1131
- * @param playground Playground client.
1132
- */
1133
- export declare function zipEntireSite(playground: UniversalPHP): Promise<File>;
1134
- /**
1135
- * @inheritDoc replaceSite
1136
- * @example
1137
- *
1138
- * <code>
1139
- * {
1140
- * "step": "replaceSite",
1141
- * "fullSiteZip": "https://mysite.com/import.zip"
1142
- * }
1143
- * </code>
1144
- */
1145
- export interface ReplaceSiteStep<ResourceType> {
1146
- step: "replaceSite";
1147
- /** The zip file containing the new WordPress site */
1148
- fullSiteZip: ResourceType;
1149
- }
1150
- /**
1151
- * Replace the current site with a site from the provided zip file.
1152
- * Remember to install the SQLite integration plugin in the zipped site:
1153
- * https://wordpress.org/plugins/sqlite-database-integration.
1154
- *
1155
- * @param playground Playground client.
1156
- * @param fullSiteZip Zipped WordPress site.
1157
- */
1158
- export declare const replaceSite: StepHandler<ReplaceSiteStep<File>>;
1159
- /**
1160
- * @inheritDoc unzip
1161
- * @example
1162
- *
1163
- * <code>
1164
- * {
1165
- * "step": "unzip",
1166
- * "zipPath": "/wordpress/data.zip",
1167
- * "extractToPath": "/wordpress"
1168
- * }
1169
- * </code>
1170
- */
1171
- export interface UnzipStep {
1172
- step: "unzip";
1173
- /** The zip file to extract */
1174
- zipPath: string;
1175
- /** The path to extract the zip file to */
1176
- extractToPath: string;
1177
- }
1178
- /**
1179
- * Unzip a zip file.
1180
- *
1181
- * @param playground Playground client.
1182
- * @param zipPath The zip file to unzip.
1183
- * @param extractTo The directory to extract the zip file to.
1184
- */
1185
- export declare const unzip: StepHandler<UnzipStep>;
1186
- /**
1187
- * @inheritDoc importFile
1188
- * @example
1189
- *
1190
- * <code>
1191
- * {
1192
- * "step": "importFile",
1193
- * "file": "https://mysite.com/import.WXR"
1194
- * }
1195
- * </code>
1196
- */
1197
- export interface ImportFileStep<ResourceType> {
1198
- step: "importFile";
1199
- /** The file to import */
1200
- file: ResourceType;
1201
- }
1202
- /**
1203
- * Uploads a file to the WordPress importer and returns the response.
1204
- * Supports both WXR and WXZ files.
1205
- *
1206
- * @see https://github.com/WordPress/wordpress-importer/compare/master...akirk:wordpress-importer:import-wxz.patch
1207
- * @param playground Playground client.
1208
- * @param file The file to import.
1209
- */
1210
- export declare const importFile: StepHandler<ImportFileStep<File>>;
1211
1186
  /**
1212
1187
  * @inheritDoc installPlugin
1213
1188
  * @hasRunnableExample
@@ -1481,6 +1456,40 @@ export interface RmdirStep {
1481
1456
  * Removes a directory at the specified path.
1482
1457
  */
1483
1458
  export declare const rmdir: StepHandler<RmdirStep>;
1459
+ /**
1460
+ * @inheritDoc runSql
1461
+ * @hasRunnableExample
1462
+ * @example
1463
+ *
1464
+ * <code>
1465
+ * {
1466
+ * "step": "runSql",
1467
+ * "sql": {
1468
+ * "resource": "literal",
1469
+ * "name": "schema.sql",
1470
+ * "contents": "DELETE FROM wp_posts"
1471
+ * }
1472
+ * }
1473
+ * </code>
1474
+ */
1475
+ export interface RunSqlStep<ResourceType> {
1476
+ /**
1477
+ * The step identifier.
1478
+ */
1479
+ step: "runSql";
1480
+ /**
1481
+ * The SQL to run. Each non-empty line must contain a valid SQL query.
1482
+ */
1483
+ sql: ResourceType;
1484
+ }
1485
+ /**
1486
+ * Run one or more SQL queries.
1487
+ *
1488
+ * This step will treat each non-empty line in the input SQL as a query and
1489
+ * try to execute it using `$wpdb`. Queries spanning multiple lines are not
1490
+ * yet supported.
1491
+ */
1492
+ export declare const runSql: StepHandler<RunSqlStep<File>>;
1484
1493
  /**
1485
1494
  * @inheritDoc mkdir
1486
1495
  * @hasRunnableExample
@@ -1667,8 +1676,7 @@ export declare const writeFile: StepHandler<WriteFileStep<File>>;
1667
1676
  * "step": "defineWpConfigConsts",
1668
1677
  * "consts": {
1669
1678
  * "WP_DEBUG": true
1670
- * },
1671
- * "virtualize": true
1679
+ * }
1672
1680
  * }
1673
1681
  * </code>
1674
1682
  */
@@ -1677,15 +1685,16 @@ export interface DefineWpConfigConstsStep {
1677
1685
  /** The constants to define */
1678
1686
  consts: Record<string, unknown>;
1679
1687
  /**
1680
- * Enables the virtualization of wp-config.php and playground-consts.json files, leaving the local system files untouched.
1681
- * The variables defined in the /vfs-blueprints/playground-consts.json file are loaded via the auto_prepend_file directive in the php.ini file.
1682
- * @default false
1683
- * @see https://www.php.net/manual/en/ini.core.php#ini.auto-prepend-file
1688
+ * @deprecated This option is noop and will be removed in a future version.
1689
+ * This option is only kept in here to avoid breaking Blueprint schema validation
1690
+ * for existing apps using this option.
1684
1691
  */
1685
1692
  virtualize?: boolean;
1686
1693
  }
1687
1694
  /**
1688
- * Defines the wp-config.php constants
1695
+ * Defines constants to be used in wp-config.php file.
1696
+ *
1697
+ * This step can be called multiple times, and the constants will be merged.
1689
1698
  *
1690
1699
  * @param playground The playground client.
1691
1700
  * @param wpConfigConst
@@ -1717,6 +1726,107 @@ export interface ActivateThemeStep {
1717
1726
  * @param themeFolderName The theme folder name.
1718
1727
  */
1719
1728
  export declare const activateTheme: StepHandler<ActivateThemeStep>;
1729
+ /**
1730
+ * @inheritDoc unzip
1731
+ * @example
1732
+ *
1733
+ * <code>
1734
+ * {
1735
+ * "step": "unzip",
1736
+ * "zipPath": "/wordpress/data.zip",
1737
+ * "extractToPath": "/wordpress"
1738
+ * }
1739
+ * </code>
1740
+ */
1741
+ export interface UnzipStep {
1742
+ step: "unzip";
1743
+ /** The zip file to extract */
1744
+ zipPath: string;
1745
+ /** The path to extract the zip file to */
1746
+ extractToPath: string;
1747
+ }
1748
+ /**
1749
+ * Unzip a zip file.
1750
+ *
1751
+ * @param playground Playground client.
1752
+ * @param zipPath The zip file to unzip.
1753
+ * @param extractTo The directory to extract the zip file to.
1754
+ */
1755
+ export declare const unzip: StepHandler<UnzipStep>;
1756
+ /**
1757
+ * @inheritDoc importWordPressFiles
1758
+ * @example
1759
+ *
1760
+ * <code>
1761
+ * {
1762
+ * "step": "importWordPressFilesStep",
1763
+ * "wordPressFilesZip": {
1764
+ * "resource": "fetch",
1765
+ * "url": "https://mysite.com/import.zip"
1766
+ * }
1767
+ * }
1768
+ * </code>
1769
+ */
1770
+ export interface ImportWordPressFilesStep<ResourceType> {
1771
+ step: "importWordPressFiles";
1772
+ /**
1773
+ * The zip file containing the top-level WordPress files and
1774
+ * directories.
1775
+ */
1776
+ wordPressFilesZip: ResourceType;
1777
+ /**
1778
+ * The path inside the zip file where the WordPress files are.
1779
+ */
1780
+ pathInZip?: string;
1781
+ }
1782
+ /**
1783
+ * Imports top-level WordPress files from a given zip file into
1784
+ * the documentRoot. For example, if a zip file contains the
1785
+ * `wp-content` and `wp-includes` directories, they will replace
1786
+ * the corresponding directories in Playground's documentRoot.
1787
+ *
1788
+ * Any files that Playground recognizes as "excluded from the export"
1789
+ * will carry over from the existing document root into the imported
1790
+ * directories. For example, the sqlite-database-integration plugin.
1791
+ *
1792
+ * @param playground Playground client.
1793
+ * @param wordPressFilesZip Zipped WordPress site.
1794
+ */
1795
+ export declare const importWordPressFiles: StepHandler<ImportWordPressFilesStep<File>>;
1796
+ /**
1797
+ * @inheritDoc importFile
1798
+ * @example
1799
+ *
1800
+ * <code>
1801
+ * {
1802
+ * "step": "importFile",
1803
+ * "file": {
1804
+ * "resource": "url",
1805
+ * "url": "https://your-site.com/starter-content.wxz"
1806
+ * }
1807
+ * }
1808
+ * </code>
1809
+ */
1810
+ export interface ImportFileStep<ResourceType> {
1811
+ step: "importFile";
1812
+ /** The file to import */
1813
+ file: ResourceType;
1814
+ }
1815
+ /**
1816
+ * Uploads a file to the WordPress importer and returns the response.
1817
+ * Supports both WXR and WXZ files.
1818
+ *
1819
+ * @see https://github.com/WordPress/wordpress-importer/compare/master...akirk:wordpress-importer:import-wxz.patch
1820
+ * @param playground Playground client.
1821
+ * @param file The file to import.
1822
+ */
1823
+ export declare const importFile: StepHandler<ImportFileStep<File>>;
1824
+ /**
1825
+ * Used by the export step to exclude the Playground-specific files
1826
+ * from the zip file. Keep it in sync with the list of files created
1827
+ * by WordPressPatcher.
1828
+ */
1829
+ export declare const wpContentFilesExcludedFromExport: string[];
1720
1830
  export type Step = GenericStep<FileReference>;
1721
1831
  export type StepDefinition = Step & {
1722
1832
  progress?: {
@@ -1728,7 +1838,7 @@ export type StepDefinition = Step & {
1728
1838
  * If you add a step here, make sure to also
1729
1839
  * add it to the exports below.
1730
1840
  */
1731
- export type GenericStep<Resource> = ActivatePluginStep | ActivateThemeStep | ApplyWordPressPatchesStep | CpStep | DefineWpConfigConstsStep | DefineSiteUrlStep | ImportFileStep<Resource> | InstallPluginStep<Resource> | InstallThemeStep<Resource> | LoginStep | MkdirStep | MvStep | RequestStep | ReplaceSiteStep<Resource> | RmStep | RmdirStep | RunPHPStep | RunPHPWithOptionsStep | RunWpInstallationWizardStep | SetPhpIniEntryStep | SetSiteOptionsStep | UnzipStep | UpdateUserMetaStep | WriteFileStep<Resource>;
1841
+ 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>;
1732
1842
  /**
1733
1843
  * Progress reporting details.
1734
1844
  */
@@ -1741,11 +1851,48 @@ export type StepHandler<S extends GenericStep<File>> = (
1741
1851
  * A PHP instance or Playground client.
1742
1852
  */
1743
1853
  php: UniversalPHP, args: Omit<S, "step">, progressArgs?: StepProgress) => any;
1854
+ /**
1855
+ * Exports the WordPress database as a WXR file using
1856
+ * the core WordPress export tool.
1857
+ *
1858
+ * @param playground Playground client
1859
+ * @returns WXR file
1860
+ */
1861
+ export declare function exportWXR(playground: UniversalPHP): Promise<File>;
1862
+ /**
1863
+ * Exports the WordPress database as a WXZ file using
1864
+ * the export-wxz plugin from https://github.com/akirk/export-wxz.
1865
+ *
1866
+ * @param playground Playground client
1867
+ * @returns WXZ file
1868
+ */
1869
+ export declare function exportWXZ(playground: UniversalPHP): Promise<File>;
1870
+ export interface ZipWpContentOptions {
1871
+ /**
1872
+ * @private
1873
+ * A temporary workaround to enable including the WordPress default theme
1874
+ * in the exported zip file.
1875
+ */
1876
+ selfContained?: boolean;
1877
+ }
1878
+ /**
1879
+ * Replace the current wp-content directory with one from the provided zip file.
1880
+ *
1881
+ * @param playground Playground client.
1882
+ * @param wpContentZip Zipped WordPress site.
1883
+ */
1884
+ export declare const zipWpContent: (playground: UniversalPHP, { selfContained }?: ZipWpContentOptions) => Promise<Uint8Array>;
1744
1885
  export interface Blueprint {
1745
1886
  /**
1746
1887
  * The URL to navigate to after the blueprint has been run.
1747
1888
  */
1748
1889
  landingPage?: string;
1890
+ /**
1891
+ * Optional description. It doesn't do anything but is exposed as
1892
+ * a courtesy to developers who may want to document which blueprint
1893
+ * file does what.
1894
+ */
1895
+ description?: string;
1749
1896
  /**
1750
1897
  * The preferred PHP and WordPress versions to use.
1751
1898
  */
@@ -1761,12 +1908,46 @@ export interface Blueprint {
1761
1908
  */
1762
1909
  wp: string | "latest";
1763
1910
  };
1911
+ features?: {
1912
+ /** Should boot with support for network request via wp_safe_remote_get? */
1913
+ networking?: boolean;
1914
+ };
1915
+ /**
1916
+ * PHP Constants to define on every request
1917
+ * @deprecated This experimental option will change without warning.
1918
+ * Use `steps` instead.
1919
+ */
1920
+ constants?: Record<string, string>;
1921
+ /**
1922
+ * WordPress plugins to install and activate
1923
+ * @deprecated This experimental option will change without warning.
1924
+ * Use `steps` instead.
1925
+ */
1926
+ plugins?: Array<string | FileReference>;
1927
+ /**
1928
+ * WordPress site options to define
1929
+ * @deprecated This experimental option will change without warning.
1930
+ * Use `steps` instead.
1931
+ */
1932
+ siteOptions?: Record<string, string> & {
1933
+ /** The site title */
1934
+ blogname?: string;
1935
+ };
1936
+ /**
1937
+ * User to log in as.
1938
+ * If true, logs the user in as admin/password.
1939
+ */
1940
+ login?: boolean | {
1941
+ username: string;
1942
+ password: string;
1943
+ };
1764
1944
  /**
1765
1945
  * The PHP extensions to use.
1766
1946
  */
1767
1947
  phpExtensionBundles?: SupportedPHPExtensionBundle[];
1768
1948
  /**
1769
- * The steps to run.
1949
+ * The steps to run after every other operation in this Blueprint was
1950
+ * executed.
1770
1951
  */
1771
1952
  steps?: Array<StepDefinition | string | undefined | false | null>;
1772
1953
  }
@@ -1779,6 +1960,10 @@ export interface CompiledBlueprint {
1779
1960
  };
1780
1961
  /** The requested PHP extensions to load */
1781
1962
  phpExtensions: SupportedPHPExtension[];
1963
+ features: {
1964
+ /** Should boot with support for network request via wp_safe_remote_get? */
1965
+ networking: boolean;
1966
+ };
1782
1967
  /** The compiled steps for the blueprint */
1783
1968
  run: (playground: UniversalPHP) => Promise<void>;
1784
1969
  }
@@ -1876,6 +2061,8 @@ declare class WebPHPEndpoint implements IsomorphicLocalPHP {
1876
2061
  request(request: PHPRequest, redirects?: number): Promise<PHPResponse>;
1877
2062
  /** @inheritDoc @php-wasm/web!WebPHP.run */
1878
2063
  run(request: PHPRunOptions): Promise<PHPResponse>;
2064
+ /** @inheritDoc @php-wasm/web!WebPHP.setSpawnHandler */
2065
+ setSpawnHandler(listener: SpawnHandler): void;
1879
2066
  /** @inheritDoc @php-wasm/web!WebPHP.chdir */
1880
2067
  chdir(path: string): void;
1881
2068
  /** @inheritDoc @php-wasm/web!WebPHP.setPhpIniPath */
@@ -1902,7 +2089,62 @@ declare class WebPHPEndpoint implements IsomorphicLocalPHP {
1902
2089
  fileExists(path: string): boolean;
1903
2090
  /** @inheritDoc @php-wasm/web!WebPHP.onMessage */
1904
2091
  onMessage(listener: MessageListener): void;
2092
+ /** @inheritDoc @php-wasm/web!WebPHP.defineConstant */
2093
+ defineConstant(key: string, value: string | number | null): void;
2094
+ /** @inheritDoc @php-wasm/web!WebPHP.addEventListener */
2095
+ addEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
2096
+ /** @inheritDoc @php-wasm/web!WebPHP.removeEventListener */
2097
+ removeEventListener(eventType: PHPEvent["type"], listener: PHPEventListener): void;
1905
2098
  }
2099
+ /**
2100
+ * Represents the type of node in PHP file system.
2101
+ */
2102
+ export type FSNodeType = "file" | "directory";
2103
+ /**
2104
+ * Represents an update operation on a file system node.
2105
+ */
2106
+ export type UpdateFileOperation = {
2107
+ /** The type of operation being performed. */
2108
+ operation: "WRITE";
2109
+ /** The path of the node being updated. */
2110
+ path: string;
2111
+ /** Optional. The new contents of the file. */
2112
+ data?: Uint8Array;
2113
+ nodeType: "file";
2114
+ };
2115
+ /**
2116
+ * Represents a directory operation.
2117
+ */
2118
+ export type CreateOperation = {
2119
+ /** The type of operation being performed. */
2120
+ operation: "CREATE";
2121
+ /** The path of the node being created. */
2122
+ path: string;
2123
+ /** The type of the node being created. */
2124
+ nodeType: FSNodeType;
2125
+ };
2126
+ export type DeleteOperation = {
2127
+ /** The type of operation being performed. */
2128
+ operation: "DELETE";
2129
+ /** The path of the node being updated. */
2130
+ path: string;
2131
+ /** The type of the node being updated. */
2132
+ nodeType: FSNodeType;
2133
+ };
2134
+ /**
2135
+ * Represents a rename operation on a file or directory in PHP file system.
2136
+ */
2137
+ export type RenameOperation = {
2138
+ /** The type of operation being performed. */
2139
+ operation: "RENAME";
2140
+ /** The original path of the file or directory being renamed. */
2141
+ path: string;
2142
+ /** The new path of the file or directory after the rename operation. */
2143
+ toPath: string;
2144
+ /** The type of node being renamed (file or directory). */
2145
+ nodeType: FSNodeType;
2146
+ };
2147
+ export type FilesystemOperation = CreateOperation | UpdateFileOperation | DeleteOperation | RenameOperation;
1906
2148
  export type SyncProgress = {
1907
2149
  /** The number of files that have been synced. */
1908
2150
  files: number;
@@ -1935,6 +2177,7 @@ declare class PlaygroundWorkerEndpoint extends WebPHPEndpoint {
1935
2177
  all: {
1936
2178
  nightly: string;
1937
2179
  beta: string;
2180
+ "6.4": string;
1938
2181
  "6.3": string;
1939
2182
  "6.2": string;
1940
2183
  "6.1": string;
@@ -1945,6 +2188,8 @@ declare class PlaygroundWorkerEndpoint extends WebPHPEndpoint {
1945
2188
  resetVirtualOpfs(): Promise<void>;
1946
2189
  reloadFilesFromOpfs(): Promise<void>;
1947
2190
  bindOpfs(opfs: FileSystemDirectoryHandle, onProgress?: SyncProgressCallback): Promise<void>;
2191
+ journalFSEvents(root: string, callback: (op: FilesystemOperation) => void): Promise<() => void>;
2192
+ replayFSJournal(events: FilesystemOperation[]): Promise<void>;
1948
2193
  }
1949
2194
  export interface ProgressBarOptions {
1950
2195
  caption?: string;
@@ -1985,6 +2230,10 @@ export interface WebClientMixin extends ProgressReceiver {
1985
2230
  * The onDownloadProgress event listener.
1986
2231
  */
1987
2232
  onDownloadProgress: PlaygroundWorkerEndpoint["onDownloadProgress"];
2233
+ journalFSEvents: PlaygroundWorkerEndpoint["journalFSEvents"];
2234
+ replayFSJournal: PlaygroundWorkerEndpoint["replayFSJournal"];
2235
+ addEventListener: PlaygroundWorkerEndpoint["addEventListener"];
2236
+ removeEventListener: PlaygroundWorkerEndpoint["removeEventListener"];
1988
2237
  /** @inheritDoc @php-wasm/universal!UniversalPHP.onMessage */
1989
2238
  onMessage: PlaygroundWorkerEndpoint["onMessage"];
1990
2239
  bindOpfs(opfs: FileSystemDirectoryHandle, onProgress?: SyncProgressCallback): Promise<void>;