Skip to content

Commit 95fb0fd

Browse files
authored
Generate API documentation (#63)
1 parent d3bdbb3 commit 95fb0fd

File tree

104 files changed

+1968
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1968
-0
lines changed

docs/api/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md)
4+
5+
## API Reference
6+
## Packages
7+
8+
| Package | Description |
9+
| --- | --- |
10+
| [php-wasm](./php-wasm.md) | |
11+
| [php-wasm-browser](./php-wasm-browser.md) | |
12+
| [wordpress-wasm](./wordpress-wasm.md) | |
13+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [awaitReply](./php-wasm-browser.awaitreply.md)
4+
5+
## awaitReply() function
6+
awaitReply<!-- -->(\
7+
&emsp;&emsp;&emsp;<!-- -->messageTarget<!-- -->: [EventTarget](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget)<!-- -->, \
8+
&emsp;&emsp;&emsp;<!-- -->requestId<!-- -->: [number](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)<!-- -->, \
9+
&emsp;&emsp;&emsp;<!-- -->timeout?<!-- -->: [number](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)\
10+
)<!-- -->: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<!-- -->&lt;[any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)<!-- -->&gt;
11+
12+
* `messageTarget` – EventEmitter emitting `message` events, e.g. `window` or a `Worker` instance.
13+
* `requestId` – The message ID returned by postMessageExpectReply().
14+
* `timeout` – Optional. The number of milliseconds to wait for a reply before throwing an error.
15+
* Returns: The reply from the messageTarget.
16+
17+
Exceptions:
18+
19+
20+
Awaits a reply to the message with the given ID.
21+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [cloneResponseMonitorProgress](./php-wasm-browser.cloneresponsemonitorprogress.md)
4+
5+
## cloneResponseMonitorProgress() function
6+
cloneResponseMonitorProgress<!-- -->(\
7+
&emsp;&emsp;&emsp;<!-- -->response<!-- -->: [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response)<!-- -->, \
8+
&emsp;&emsp;&emsp;<!-- -->onProgress<!-- -->: [DownloadProgressCallback](./php-wasm-browser.downloadprogresscallback.md)\
9+
)<!-- -->: [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response)
10+
11+
* `response` – The fetch Response object to clone.
12+
* `onProgress` – The callback to call when the download progress changes.
13+
* Returns: The cloned response
14+
15+
16+
Clones a fetch Response object and returns a version that calls the `onProgress` callback as the progress changes.
17+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [currentBackend](./php-wasm-browser.currentbackend.md)
4+
5+
## currentBackend variable
6+
<b>Signature:</b>
7+
8+
```typescript
9+
currentBackend: WorkerThreadBackend
10+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [DEFAULT_BASE_URL](./php-wasm-browser.default_base_url.md)
4+
5+
## DEFAULT_BASE_URL variable
6+
<b>Signature:</b>
7+
8+
```typescript
9+
DEFAULT_BASE_URL = "http://example.com"
10+
```
11+
The default base used to convert a path into the URL object.
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [DownloadProgressCallback](./php-wasm-browser.downloadprogresscallback.md)
4+
5+
## DownloadProgressCallback type
6+
<b>Signature:</b>
7+
8+
```typescript
9+
type DownloadProgressCallback = (event: DownloadProgressEvent) => void;
10+
```
11+
<b>References:</b> [DownloadProgressEvent](./php-wasm-browser.downloadprogressevent.md)
12+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [DownloadProgressEvent](./php-wasm-browser.downloadprogressevent.md) > [loaded](./php-wasm-browser.downloadprogressevent.loaded.md)
4+
5+
## DownloadProgressEvent.loaded property
6+
<b>Signature:</b>
7+
8+
```typescript
9+
loaded: number;
10+
```
11+
The number of bytes loaded so far.
12+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [DownloadProgressEvent](./php-wasm-browser.downloadprogressevent.md)
4+
5+
## DownloadProgressEvent interface
6+
<b>Signature:</b>
7+
8+
```typescript
9+
interface DownloadProgressEvent
10+
```
11+
## Properties
12+
13+
* `loaded` [number](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) – The number of bytes loaded so far.
14+
* `total` [number](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean) – The total number of bytes to load.
15+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [DownloadProgressEvent](./php-wasm-browser.downloadprogressevent.md) > [total](./php-wasm-browser.downloadprogressevent.total.md)
4+
5+
## DownloadProgressEvent.total property
6+
<b>Signature:</b>
7+
8+
```typescript
9+
total: number;
10+
```
11+
The total number of bytes to load.
12+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [getPathQueryFragment](./php-wasm-browser.getpathqueryfragment.md)
4+
5+
## getPathQueryFragment() function
6+
getPathQueryFragment<!-- -->(<!-- -->url<!-- -->: [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)<!-- -->)<!-- -->: [string](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)
7+
8+
* `url` – The URL.
9+
* Returns: The path, query, and fragment.
10+
11+
12+
Returns a string representing the path, query, and fragment of the given URL.
13+
14+
## Example
15+
16+
```js
17+
const url = new URL('http://example.com/foo/bar?baz=qux#quux');
18+
getPathQueryFragment(url); // '/foo/bar?baz=qux#quux'
19+
```
20+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [getURLScope](./php-wasm-browser.geturlscope.md)
4+
5+
## getURLScope() function
6+
getURLScope<!-- -->(<!-- -->url<!-- -->: [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)<!-- -->)<!-- -->: [string](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)<!-- -->|<!-- -->null
7+
8+
* `url` – The URL.
9+
* Returns: The scope if the URL contains a scope, `null` otherwise.
10+
11+
12+
Returns the scope stored in the given URL.
13+
14+
## Example
15+
16+
```js
17+
getScopeFromURL(new URL('http://localhost/scope:96253/index.php'));
18+
// '96253'
19+
20+
getScopeFromURL(new URL('http://localhost/index.php'));
21+
// null
22+
```
23+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [initializeServiceWorker](./php-wasm-browser.initializeserviceworker.md)
4+
5+
## initializeServiceWorker() function
6+
initializeServiceWorker<!-- -->(<!-- -->config<!-- -->: [ServiceWorkerConfiguration](./php-wasm-browser.serviceworkerconfiguration.md)<!-- -->)<!-- -->: [void](https://www.typescriptlang.org/docs/handbook/2/functions.html#void)
7+
8+
* `config`
9+
10+
11+
Run this function in the service worker to install the required event handlers.
12+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [initializeWorkerThread](./php-wasm-browser.initializeworkerthread.md)
4+
5+
## initializeWorkerThread() function
6+
initializeWorkerThread<!-- -->(<!-- -->config<!-- -->: [WorkerThreadConfiguration](./php-wasm-browser.workerthreadconfiguration.md)<!-- -->)<!-- -->: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<!-- -->&lt;[any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)<!-- -->&gt;
7+
8+
* `config` – The worker thread configuration. The backend object to communicate with the parent thread.
9+
10+
11+
Call this in a worker thread script to set the stage for offloading the PHP processing. This function:
12+
13+
* Initializes the PHP runtime * Starts PHPServer and PHPBrowser * Lets the main app know when its ready * Listens for messages from the main app * Runs the requested operations (like `run_php`<!-- -->) * Replies to the main app with the results using the [request/reply protocol](#request-reply-protocol)
14+
15+
Remember: The worker thread code must live in a separate JavaScript file.
16+
17+
A minimal worker thread script looks like this:
18+
19+
```js
20+
import { initializeWorkerThread } from 'php-wasm-browser';
21+
initializeWorkerThread();
22+
```
23+
You can customize the PHP loading flow via the first argument:
24+
25+
```js
26+
import { initializeWorkerThread, loadPHPWithProgress } from 'php-wasm-browser';
27+
initializeWorkerThread( bootBrowser );
28+
29+
async function bootBrowser({ absoluteUrl }) {
30+
const [phpLoaderModule, myDependencyLoaderModule] = await Promise.all([
31+
import(`/php.js`),
32+
import(`/wp.js`)
33+
]);
34+
35+
const php = await loadPHPWithProgress(phpLoaderModule, [myDependencyLoaderModule]);
36+
37+
const server = new PHPServer(php, {
38+
documentRoot: '/www',
39+
absoluteUrl: absoluteUrl
40+
});
41+
42+
return new PHPBrowser(server);
43+
}
44+
```
45+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [isURLScoped](./php-wasm-browser.isurlscoped.md)
4+
5+
## isURLScoped() function
6+
isURLScoped<!-- -->(<!-- -->url<!-- -->: [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL)<!-- -->)<!-- -->: [boolean](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)
7+
8+
* `url` – The URL to check.
9+
* Returns: `true` if the URL contains scope information, `false` otherwise.
10+
11+
12+
Checks if the given URL contains scope information.
13+
14+
## Example
15+
16+
```js
17+
isURLScoped(new URL('http://localhost/scope:96253/index.php'));
18+
// true
19+
20+
isURLScoped(new URL('http://localhost/index.php'));
21+
// false
22+
```
23+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [loadPHPWithProgress](./php-wasm-browser.loadphpwithprogress.md)
4+
5+
## loadPHPWithProgress() function
6+
loadPHPWithProgress<!-- -->(\
7+
&emsp;&emsp;&emsp;<!-- -->phpLoaderModule<!-- -->: [any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)<!-- -->, \
8+
&emsp;&emsp;&emsp;<!-- -->dataDependenciesModules?<!-- -->: [any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)<!-- -->[]<!-- -->, \
9+
&emsp;&emsp;&emsp;<!-- -->phpModuleArgs?<!-- -->: [any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)\
10+
)<!-- -->: [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)<!-- -->&lt;[PHP](./php-wasm.php.md)<!-- -->&gt;
11+
12+
* `phpLoaderModule` – The ESM-wrapped Emscripten module. Consult the Dockerfile for the build process.
13+
* `dataDependenciesModules` – Optional. A list of the ESM-wrapped Emscripten data dependency modules.
14+
* `phpModuleArgs` – Optional. The Emscripten module arguments, see https://emscripten.org/docs/api_reference/module.html#affecting-execution.
15+
* Returns: PHP instance.
16+
17+
18+
Call this in a Worker Thread to start load the PHP runtime and post the progress to the main thread.
19+

docs/api/php-wasm-browser.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md)
4+
5+
## php-wasm-browser package
6+
## Classes
7+
8+
* [SpawnedWorkerThread](./php-wasm-browser.spawnedworkerthread.md)
9+
10+
## Functions
11+
12+
* [awaitReply](./php-wasm-browser.awaitreply.md)
13+
* [cloneResponseMonitorProgress](./php-wasm-browser.cloneresponsemonitorprogress.md)
14+
* [getPathQueryFragment](./php-wasm-browser.getpathqueryfragment.md)
15+
* [getURLScope](./php-wasm-browser.geturlscope.md)
16+
* [initializeServiceWorker](./php-wasm-browser.initializeserviceworker.md)
17+
* [initializeWorkerThread](./php-wasm-browser.initializeworkerthread.md)
18+
* [isURLScoped](./php-wasm-browser.isurlscoped.md)
19+
* [loadPHPWithProgress](./php-wasm-browser.loadphpwithprogress.md)
20+
* [postMessageExpectReply](./php-wasm-browser.postmessageexpectreply.md)
21+
* [registerServiceWorker](./php-wasm-browser.registerserviceworker.md)
22+
* [removeURLScope](./php-wasm-browser.removeurlscope.md)
23+
* [responseTo](./php-wasm-browser.responseto.md)
24+
* [seemsLikeAPHPServerPath](./php-wasm-browser.seemslikeaphpserverpath.md)
25+
* [setURLScope](./php-wasm-browser.seturlscope.md)
26+
* [spawnPHPWorkerThread](./php-wasm-browser.spawnphpworkerthread.md)
27+
28+
## Interfaces
29+
30+
* [DownloadProgressEvent](./php-wasm-browser.downloadprogressevent.md)
31+
* [MessageResponse](./php-wasm-browser.messageresponse.md)
32+
* [PostMessageTarget](./php-wasm-browser.postmessagetarget.md)
33+
* [ServiceWorkerConfiguration](./php-wasm-browser.serviceworkerconfiguration.md)
34+
* [WorkerThreadBackend](./php-wasm-browser.workerthreadbackend.md)
35+
* [WorkerThreadConfig](./php-wasm-browser.workerthreadconfig.md)
36+
* [WorkerThreadConfiguration](./php-wasm-browser.workerthreadconfiguration.md)
37+
38+
## Variables
39+
40+
* [currentBackend](./php-wasm-browser.currentbackend.md)
41+
* [DEFAULT_BASE_URL](./php-wasm-browser.default_base_url.md)
42+
43+
## Type Aliases
44+
45+
* [DownloadProgressCallback](./php-wasm-browser.downloadprogresscallback.md)
46+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [MessageResponse](./php-wasm-browser.messageresponse.md)
4+
5+
## MessageResponse interface
6+
<b>Signature:</b>
7+
8+
```typescript
9+
interface MessageResponse<T>
10+
```
11+
## Properties
12+
13+
* `requestId` [number](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)
14+
* `response` T
15+
* `type` 'response'
16+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [MessageResponse](./php-wasm-browser.messageresponse.md) > [requestId](./php-wasm-browser.messageresponse.requestid.md)
4+
5+
## MessageResponse.requestId property
6+
<b>Signature:</b>
7+
8+
```typescript
9+
requestId: number;
10+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [MessageResponse](./php-wasm-browser.messageresponse.md) > [response](./php-wasm-browser.messageresponse.response.md)
4+
5+
## MessageResponse.response property
6+
<b>Signature:</b>
7+
8+
```typescript
9+
response: T;
10+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [MessageResponse](./php-wasm-browser.messageresponse.md) > [type](./php-wasm-browser.messageresponse.type.md)
4+
5+
## MessageResponse.type property
6+
<b>Signature:</b>
7+
8+
```typescript
9+
type: 'response';
10+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) > [php-wasm-browser](./php-wasm-browser.md) > [postMessageExpectReply](./php-wasm-browser.postmessageexpectreply.md)
4+
5+
## postMessageExpectReply() function
6+
postMessageExpectReply<!-- -->(\
7+
&emsp;&emsp;&emsp;<!-- -->target<!-- -->: [PostMessageTarget](./php-wasm-browser.postmessagetarget.md)<!-- -->, \
8+
&emsp;&emsp;&emsp;<!-- -->message<!-- -->: [Record](https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type)<!-- -->&lt;[string](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)<!-- -->,[any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)<!-- -->&gt;<!-- -->, \
9+
&emsp;&emsp;&emsp;<!-- -->postMessageArgs<!-- -->: [any](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#any)<!-- -->[]\
10+
)<!-- -->: [number](https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean)
11+
12+
* `target` – An object that has a `postMessage` method.
13+
* `message` – A key-value object that can be serialized to JSON.
14+
* `postMessageArgs` – Additional arguments to pass to `postMessage`<!-- -->.
15+
* Returns: The message ID for awaitReply().
16+
17+
18+
Posts a message branded with a unique `requestId` to the given `target`<!-- -->. Then returns the `requestId` so it can be used to await a reply.
19+

0 commit comments

Comments
 (0)