@wp-playground/storage 3.0.22 → 3.0.31
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/index.cjs +60 -60
- package/index.cjs.map +1 -1
- package/index.d.ts +8 -0
- package/index.js +2378 -1987
- package/index.js.map +1 -1
- package/lib/browser-fs.d.ts +5 -0
- package/lib/changeset.d.ts +62 -0
- package/lib/filesystems.d.ts +211 -0
- package/lib/git-create-dotgit-directory.d.ts +16 -0
- package/lib/git-sparse-checkout.d.ts +88 -0
- package/lib/github.d.ts +47 -0
- package/lib/paths.d.ts +3 -0
- package/lib/playground.d.ts +4 -0
- package/package.json +10 -8
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MountDevice } from '@php-wasm/web';
|
|
2
|
+
export declare function directoryHandleFromMountDevice(device: MountDevice): Promise<FileSystemDirectoryHandle>;
|
|
3
|
+
export declare function opfsPathToDirectoryHandle(opfsPath: string): Promise<FileSystemDirectoryHandle>;
|
|
4
|
+
export declare function directoryHandleToOpfsPath(directoryHandle: FileSystemDirectoryHandle): Promise<string>;
|
|
5
|
+
export declare function clearContentsFromMountDevice(mountDevice: MountDevice): Promise<void>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { UniversalPHP } from '@php-wasm/universal';
|
|
2
|
+
export type IterateFilesOptions = {
|
|
3
|
+
/**
|
|
4
|
+
* Should yield paths relative to the root directory?
|
|
5
|
+
* If false, all paths will be absolute.
|
|
6
|
+
*/
|
|
7
|
+
relativePaths?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* The root directory that Playground paths start from.
|
|
10
|
+
*/
|
|
11
|
+
playgroundRoot?: string;
|
|
12
|
+
/**
|
|
13
|
+
* A prefix to add to all paths.
|
|
14
|
+
* Only used if `relativePaths` is true.
|
|
15
|
+
*/
|
|
16
|
+
pathPrefix?: string;
|
|
17
|
+
/**
|
|
18
|
+
* A list of paths to exclude from the results.
|
|
19
|
+
*/
|
|
20
|
+
exceptPaths?: string[];
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Iterates over all files in a Playground directory and its subdirectories.
|
|
24
|
+
*
|
|
25
|
+
* @param playground - The Playground/PHP instance.
|
|
26
|
+
* @param root - The root directory to start iterating from.
|
|
27
|
+
* @param options - Optional configuration.
|
|
28
|
+
* @returns All files found in the tree.
|
|
29
|
+
*/
|
|
30
|
+
export declare function iterateFiles(playground: UniversalPHP, root: string, { exceptPaths }?: IterateFilesOptions): AsyncGenerator<FileEntry>;
|
|
31
|
+
export type FileEntry = {
|
|
32
|
+
path: string;
|
|
33
|
+
read: () => Promise<Uint8Array>;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Represents a set of changes to be applied to a data store.
|
|
37
|
+
*/
|
|
38
|
+
export type Changeset = {
|
|
39
|
+
/**
|
|
40
|
+
* Created files.
|
|
41
|
+
*/
|
|
42
|
+
create: Map<string, Uint8Array>;
|
|
43
|
+
/**
|
|
44
|
+
* Updated files.
|
|
45
|
+
*/
|
|
46
|
+
update: Map<string, Uint8Array>;
|
|
47
|
+
/**
|
|
48
|
+
* Deleted files.
|
|
49
|
+
*/
|
|
50
|
+
delete: Set<string>;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Compares two sets of files and returns a changeset object that describes
|
|
54
|
+
* the differences between them.
|
|
55
|
+
*
|
|
56
|
+
* @param filesBefore - A map of file paths to Uint8Array objects representing the contents
|
|
57
|
+
* of the files before the changes.
|
|
58
|
+
* @param filesAfter - An async generator that yields FileEntry objects representing the files
|
|
59
|
+
* after the changes.
|
|
60
|
+
* @returns A changeset object that describes the differences between the two sets of files.
|
|
61
|
+
*/
|
|
62
|
+
export declare function changeset(filesBefore: Map<string, Uint8Array>, filesAfter: AsyncGenerator<FileEntry> | Iterable<FileEntry>): Promise<Changeset>;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { StreamedFile } from '@php-wasm/stream-compression';
|
|
2
|
+
import type { FileTree } from '@php-wasm/universal';
|
|
3
|
+
import { ZipReader, BlobReader } from '@zip.js/zip.js';
|
|
4
|
+
export interface ReadableFilesystemBackend {
|
|
5
|
+
read(path: string): Promise<StreamedFile>;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* A readable filesystem that can also be traversed (list directories).
|
|
9
|
+
*/
|
|
10
|
+
export interface TraversableFilesystemBackend extends ReadableFilesystemBackend {
|
|
11
|
+
listFiles(path: string): Promise<string[]>;
|
|
12
|
+
isDir(path: string): Promise<boolean>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Backend interface for writable filesystem operations.
|
|
16
|
+
* All paths passed to these methods are expected to be absolute paths.
|
|
17
|
+
*/
|
|
18
|
+
export interface WritableFilesystemBackend extends TraversableFilesystemBackend {
|
|
19
|
+
fileExists(absolutePath: string): Promise<boolean>;
|
|
20
|
+
writeFile(absolutePath: string, data: Uint8Array): Promise<void>;
|
|
21
|
+
mkdir(absolutePath: string, recursive?: boolean): Promise<void>;
|
|
22
|
+
rmdir(absolutePath: string, recursive: boolean): Promise<void>;
|
|
23
|
+
mv(absoluteSource: string, absoluteDestination: string): Promise<void>;
|
|
24
|
+
unlink(absolutePath: string): Promise<void>;
|
|
25
|
+
clear(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Interface for a writable filesystem with EventTarget support.
|
|
29
|
+
* Used by UI components that need to react to filesystem changes.
|
|
30
|
+
*/
|
|
31
|
+
export interface AsyncWritableFilesystem extends EventTarget {
|
|
32
|
+
isDir(path: string): Promise<boolean>;
|
|
33
|
+
fileExists(path: string): Promise<boolean>;
|
|
34
|
+
read(path: string): Promise<{
|
|
35
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
36
|
+
}>;
|
|
37
|
+
readFileAsText(path: string): Promise<string>;
|
|
38
|
+
listFiles(path: string): Promise<string[]>;
|
|
39
|
+
writeFile(path: string, data: Uint8Array | string): Promise<void>;
|
|
40
|
+
mkdir(path: string, options?: {
|
|
41
|
+
recursive?: boolean;
|
|
42
|
+
}): Promise<void>;
|
|
43
|
+
rmdir(path: string, options?: {
|
|
44
|
+
recursive?: boolean;
|
|
45
|
+
}): Promise<void>;
|
|
46
|
+
mv(source: string, destination: string): Promise<void>;
|
|
47
|
+
unlink(path: string): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Copy all files from source filesystem to destination filesystem.
|
|
51
|
+
* Clears the destination before copying.
|
|
52
|
+
*/
|
|
53
|
+
export declare function copyFilesystem(source: TraversableFilesystemBackend, destination: WritableFilesystemBackend): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Wraps a WritableFilesystemBackend with EventTarget support and convenience methods.
|
|
56
|
+
* Dispatches 'change' events on write operations.
|
|
57
|
+
*/
|
|
58
|
+
export declare class EventedFilesystem extends EventTarget implements AsyncWritableFilesystem {
|
|
59
|
+
private readonly encoder;
|
|
60
|
+
private readonly decoder;
|
|
61
|
+
readonly backend: WritableFilesystemBackend;
|
|
62
|
+
constructor(backend: WritableFilesystemBackend);
|
|
63
|
+
isDir(path: string): Promise<boolean>;
|
|
64
|
+
fileExists(path: string): Promise<boolean>;
|
|
65
|
+
read(path: string): Promise<StreamedFile>;
|
|
66
|
+
readFileAsText(path: string): Promise<string>;
|
|
67
|
+
listFiles(path: string): Promise<string[]>;
|
|
68
|
+
writeFile(path: string, data: Uint8Array | string): Promise<void>;
|
|
69
|
+
mkdir(path: string, options?: {
|
|
70
|
+
recursive?: boolean;
|
|
71
|
+
}): Promise<void>;
|
|
72
|
+
rmdir(path: string, options?: {
|
|
73
|
+
recursive?: boolean;
|
|
74
|
+
}): Promise<void>;
|
|
75
|
+
mv(source: string, destination: string): Promise<void>;
|
|
76
|
+
unlink(path: string): Promise<void>;
|
|
77
|
+
clear(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
export declare class InMemoryFilesystem implements ReadableFilesystemBackend {
|
|
80
|
+
private fileTree;
|
|
81
|
+
constructor(fileTree: FileTree);
|
|
82
|
+
read(path: string): Promise<StreamedFile>;
|
|
83
|
+
private getEntryAtPath;
|
|
84
|
+
}
|
|
85
|
+
export declare class ZipFilesystem implements ReadableFilesystemBackend {
|
|
86
|
+
private entries;
|
|
87
|
+
private zipReader;
|
|
88
|
+
static fromStream(stream: ReadableStream<Uint8Array>): ZipFilesystem;
|
|
89
|
+
static fromArrayBuffer(arrayBuffer: ArrayBuffer): ZipFilesystem;
|
|
90
|
+
constructor(zipReader: ZipReader<BlobReader>);
|
|
91
|
+
read(relativePath: string): Promise<StreamedFile>;
|
|
92
|
+
private getEntry;
|
|
93
|
+
private getEntries;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A Filesystem implementation that cascades through multiple filesystems
|
|
97
|
+
* and returns the first successful result.
|
|
98
|
+
*
|
|
99
|
+
* This is useful for creating a layered approach to file resolution,
|
|
100
|
+
* such as checking a local cache before fetching from a remote source.
|
|
101
|
+
*/
|
|
102
|
+
export declare class OverlayFilesystem implements ReadableFilesystemBackend {
|
|
103
|
+
private filesystems;
|
|
104
|
+
/**
|
|
105
|
+
* Creates a new OverlayFilesystem.
|
|
106
|
+
*
|
|
107
|
+
* @param filesystems An array of Filesystem instances to cascade through.
|
|
108
|
+
* The order determines the priority - earlier filesystems
|
|
109
|
+
* are checked first.
|
|
110
|
+
*/
|
|
111
|
+
constructor(filesystems: ReadableFilesystemBackend[]);
|
|
112
|
+
/**
|
|
113
|
+
* Reads a file by trying each filesystem in order until one succeeds.
|
|
114
|
+
*
|
|
115
|
+
* @param path The path to the file to read.
|
|
116
|
+
* @returns A Promise that resolves to a StreamedFile from the first
|
|
117
|
+
* filesystem that successfully resolves the path.
|
|
118
|
+
* @throws Error if all filesystems fail to resolve the path.
|
|
119
|
+
*/
|
|
120
|
+
read(path: string): Promise<StreamedFile>;
|
|
121
|
+
}
|
|
122
|
+
export interface FetchFilesystemOptions {
|
|
123
|
+
corsProxy?: string;
|
|
124
|
+
baseUrl: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A Filesystem implementation that fetches files from URLs.
|
|
128
|
+
* It can optionally use a CORS proxy and resolve paths relative to a base URL.
|
|
129
|
+
*/
|
|
130
|
+
export declare class FetchFilesystem implements ReadableFilesystemBackend {
|
|
131
|
+
private baseUrl;
|
|
132
|
+
private options;
|
|
133
|
+
private isDataUrl;
|
|
134
|
+
constructor(options: FetchFilesystemOptions);
|
|
135
|
+
read(path: string): Promise<StreamedFile>;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A Filesystem implementation that uses the "fs" and "path" modules from Node.js
|
|
139
|
+
* to read files from the local file system.
|
|
140
|
+
*
|
|
141
|
+
* This is only available in a local environment.
|
|
142
|
+
*/
|
|
143
|
+
export declare class NodeJsFilesystem implements ReadableFilesystemBackend {
|
|
144
|
+
private fs;
|
|
145
|
+
private path;
|
|
146
|
+
private root;
|
|
147
|
+
constructor(root: string);
|
|
148
|
+
private ensureNodeModules;
|
|
149
|
+
read(filePath: string): Promise<StreamedFile>;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* OPFS filesystem backend that operates directly on the Origin Private File System.
|
|
153
|
+
* Implements both ReadableFilesystemBackend (for BlueprintBundle) and
|
|
154
|
+
* WritableFilesystemBackend (for the editor).
|
|
155
|
+
*/
|
|
156
|
+
export declare class OpfsFilesystemBackend implements WritableFilesystemBackend {
|
|
157
|
+
private readonly opfsRoot;
|
|
158
|
+
constructor(opfsRoot: FileSystemDirectoryHandle);
|
|
159
|
+
/**
|
|
160
|
+
* Create a backend for a specific OPFS directory handle.
|
|
161
|
+
*/
|
|
162
|
+
static fromDirectoryHandle(handle: FileSystemDirectoryHandle): OpfsFilesystemBackend;
|
|
163
|
+
/**
|
|
164
|
+
* Create a backend for a specific path in OPFS.
|
|
165
|
+
* The path will be created if `create` is true.
|
|
166
|
+
* @throws Error if OPFS is not available or path doesn't exist (when create=false)
|
|
167
|
+
*/
|
|
168
|
+
static fromPath(path: string, create?: boolean): Promise<OpfsFilesystemBackend>;
|
|
169
|
+
clear(): Promise<void>;
|
|
170
|
+
read(path: string): Promise<StreamedFile>;
|
|
171
|
+
isDir(absolutePath: string): Promise<boolean>;
|
|
172
|
+
fileExists(absolutePath: string): Promise<boolean>;
|
|
173
|
+
listFiles(absolutePath: string): Promise<string[]>;
|
|
174
|
+
writeFile(absolutePath: string, data: Uint8Array): Promise<void>;
|
|
175
|
+
mkdir(absolutePath: string, recursive?: boolean): Promise<void>;
|
|
176
|
+
rmdir(absolutePath: string, recursive: boolean): Promise<void>;
|
|
177
|
+
mv(absoluteSource: string, absoluteDestination: string): Promise<void>;
|
|
178
|
+
unlink(absolutePath: string): Promise<void>;
|
|
179
|
+
private readFileAsBuffer;
|
|
180
|
+
private copyDir;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* In-memory writable filesystem backend that stores files in a tree structure.
|
|
184
|
+
*/
|
|
185
|
+
export declare class InMemoryFilesystemBackend implements WritableFilesystemBackend {
|
|
186
|
+
private root;
|
|
187
|
+
constructor(initialFiles?: Record<string, Uint8Array>);
|
|
188
|
+
read(path: string): Promise<StreamedFile>;
|
|
189
|
+
isDir(absolutePath: string): Promise<boolean>;
|
|
190
|
+
fileExists(absolutePath: string): Promise<boolean>;
|
|
191
|
+
listFiles(absolutePath: string): Promise<string[]>;
|
|
192
|
+
writeFile(absolutePath: string, data: Uint8Array): Promise<void>;
|
|
193
|
+
mkdir(absolutePath: string, recursive?: boolean): Promise<void>;
|
|
194
|
+
rmdir(absolutePath: string, recursive: boolean): Promise<void>;
|
|
195
|
+
mv(absoluteSource: string, absoluteDestination: string): Promise<void>;
|
|
196
|
+
unlink(absolutePath: string): Promise<void>;
|
|
197
|
+
clear(): Promise<void>;
|
|
198
|
+
private writeFileSync;
|
|
199
|
+
private getNode;
|
|
200
|
+
private getDir;
|
|
201
|
+
private getFile;
|
|
202
|
+
/**
|
|
203
|
+
* Get parent directory, throwing if it doesn't exist.
|
|
204
|
+
*/
|
|
205
|
+
private getParent;
|
|
206
|
+
/**
|
|
207
|
+
* Get parent directory, creating it if it doesn't exist.
|
|
208
|
+
*/
|
|
209
|
+
private getOrCreateParent;
|
|
210
|
+
private ensureDir;
|
|
211
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SparseCheckoutObject } from './git-sparse-checkout';
|
|
2
|
+
type GitDirectoryRefType = 'branch' | 'tag' | 'commit' | 'refname';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a complete .git directory structure with all necessary files.
|
|
5
|
+
* This includes HEAD, config, refs, objects, and the Git index.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createDotGitDirectory({ repoUrl, commitHash, ref, refType, objects, fileOids, pathPrefix, }: {
|
|
8
|
+
repoUrl: string;
|
|
9
|
+
commitHash: string;
|
|
10
|
+
ref: string;
|
|
11
|
+
refType?: GitDirectoryRefType;
|
|
12
|
+
objects: SparseCheckoutObject[];
|
|
13
|
+
fileOids: Record<string, string>;
|
|
14
|
+
pathPrefix: string;
|
|
15
|
+
}): Promise<Record<string, string | Uint8Array>>;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error class for git authentication failures.
|
|
3
|
+
*/
|
|
4
|
+
export declare class GitAuthenticationError extends Error {
|
|
5
|
+
repoUrl: string;
|
|
6
|
+
status: number;
|
|
7
|
+
constructor(repoUrl: string, status: number);
|
|
8
|
+
}
|
|
9
|
+
export type GitAdditionalHeaders = Record<string, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Downloads specific files from a git repository.
|
|
12
|
+
* It uses the git protocol over HTTP to fetch the files. It only uses
|
|
13
|
+
* three HTTP requests regardless of the number of paths requested.
|
|
14
|
+
*
|
|
15
|
+
* @param repoUrl The URL of the git repository.
|
|
16
|
+
* @param fullyQualifiedBranchName The full name of the branch to fetch from (e.g., 'refs/heads/main').
|
|
17
|
+
* @param filesPaths An array of all the file paths to fetch from the repository. Does **not** accept
|
|
18
|
+
* patterns, wildcards, directory paths. All files must be explicitly listed.
|
|
19
|
+
* @returns The requested files and packfiles required to recreate the Git objects locally.
|
|
20
|
+
*/
|
|
21
|
+
export type SparseCheckoutPackfile = {
|
|
22
|
+
name: string;
|
|
23
|
+
pack: Uint8Array;
|
|
24
|
+
index: Uint8Array;
|
|
25
|
+
promisor?: boolean;
|
|
26
|
+
};
|
|
27
|
+
export type SparseCheckoutObject = {
|
|
28
|
+
oid: string;
|
|
29
|
+
type: 'blob' | 'tree' | 'commit' | 'tag';
|
|
30
|
+
body: Uint8Array;
|
|
31
|
+
};
|
|
32
|
+
export type SparseCheckoutResult = {
|
|
33
|
+
files: Record<string, any>;
|
|
34
|
+
packfiles?: SparseCheckoutPackfile[];
|
|
35
|
+
objects?: SparseCheckoutObject[];
|
|
36
|
+
fileOids?: Record<string, string>;
|
|
37
|
+
};
|
|
38
|
+
export declare function sparseCheckout(repoUrl: string, commitHash: string, filesPaths: string[], options?: {
|
|
39
|
+
withObjects?: boolean;
|
|
40
|
+
additionalHeaders?: GitAdditionalHeaders;
|
|
41
|
+
}): Promise<SparseCheckoutResult>;
|
|
42
|
+
export type GitFileTreeFile = {
|
|
43
|
+
name: string;
|
|
44
|
+
type: 'file';
|
|
45
|
+
};
|
|
46
|
+
export type GitFileTreeFolder = {
|
|
47
|
+
name: string;
|
|
48
|
+
type: 'folder';
|
|
49
|
+
children: GitFileTree[];
|
|
50
|
+
};
|
|
51
|
+
export type GitFileTree = GitFileTreeFile | GitFileTreeFolder;
|
|
52
|
+
/**
|
|
53
|
+
* A Git ref in a human-readable format. Could be a single string,
|
|
54
|
+
* e.g. 'main', 'v0.1.28', '1234567890abcdef1234567890abcdef12345678',
|
|
55
|
+
* could be a string and an explicit type, e.g. { value: 'main', type: 'branch' },
|
|
56
|
+
*/
|
|
57
|
+
export type GitRef = {
|
|
58
|
+
value: string;
|
|
59
|
+
type?: 'branch' | 'commit' | 'refname' | 'tag' | 'infer';
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Lists all files in a git repository.
|
|
63
|
+
*
|
|
64
|
+
* See https://git-scm.com/book/en/v2/Git-Internals-Git-Objects for more information.
|
|
65
|
+
*
|
|
66
|
+
* @param repoUrl The URL of the git repository.
|
|
67
|
+
* @param commitHash The commit hash to fetch from.
|
|
68
|
+
* @returns A list of all files in the repository.
|
|
69
|
+
*/
|
|
70
|
+
export declare function listGitFiles(repoUrl: string, commitHash: string, additionalHeaders?: GitAdditionalHeaders): Promise<GitFileTree[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Resolves a ref description, e.g. a branch name, to a commit hash.
|
|
73
|
+
*
|
|
74
|
+
* @param repoUrl The URL of the git repository.
|
|
75
|
+
* @param ref The branch name or commit hash.
|
|
76
|
+
* @returns The commit hash.
|
|
77
|
+
*/
|
|
78
|
+
export declare function resolveCommitHash(repoUrl: string, ref: GitRef, additionalHeaders?: GitAdditionalHeaders): Promise<string>;
|
|
79
|
+
/**
|
|
80
|
+
* Retrieves a list of refs from a git repository.
|
|
81
|
+
*
|
|
82
|
+
* See https://git-scm.com/book/en/v2/Git-Internals-Git-References for more information.
|
|
83
|
+
*
|
|
84
|
+
* @param repoUrl The URL of the git repository. For example: https://github.com/WordPress/gutenberg.git
|
|
85
|
+
* @param fullyQualifiedBranchPrefix The prefix of the refs to fetch. For example: refs/heads/my-feature-branch
|
|
86
|
+
* @returns A map of refs to their corresponding commit hashes.
|
|
87
|
+
*/
|
|
88
|
+
export declare function listGitRefs(repoUrl: string, fullyQualifiedBranchPrefix: string, additionalHeaders?: GitAdditionalHeaders): Promise<Record<string, string>>;
|
package/lib/github.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Octokit } from 'octokit';
|
|
2
|
+
import type { Changeset } from './changeset';
|
|
3
|
+
export type GithubClient = ReturnType<typeof createClient>;
|
|
4
|
+
export declare function createClient(githubToken: string): Octokit;
|
|
5
|
+
export type Files = Record<string, Uint8Array>;
|
|
6
|
+
export declare function filesListToObject(files: any[], root?: string): Files;
|
|
7
|
+
export interface GetFilesProgress {
|
|
8
|
+
foundFiles: number;
|
|
9
|
+
downloadedFiles: number;
|
|
10
|
+
}
|
|
11
|
+
export interface GetFilesOptions {
|
|
12
|
+
onProgress?: ({ foundFiles, downloadedFiles }: GetFilesProgress) => void;
|
|
13
|
+
progress?: GetFilesProgress;
|
|
14
|
+
}
|
|
15
|
+
export declare function getFilesFromDirectory(octokit: GithubClient, owner: string, repo: string, ref: string, path: string, options?: GetFilesOptions): Promise<any[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Usage:
|
|
18
|
+
* > await getArtifact('wordpress', 'wordpress-develop', 5511, 'build.yml')
|
|
19
|
+
*
|
|
20
|
+
* To get the first artifact produced by the "build.yml" workflow running
|
|
21
|
+
* as a part of the PR 5511
|
|
22
|
+
*
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export declare function getArtifact(octokit: GithubClient, owner: string, repo: string, pull_number: number, workflow_id: string): Promise<unknown>;
|
|
26
|
+
export declare function mayPush(octokit: Octokit, owner: string, repo: string): Promise<boolean>;
|
|
27
|
+
export declare function createOrUpdateBranch(octokit: Octokit, owner: string, repo: string, branch: string, newHead: string): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* @param octokit
|
|
30
|
+
* @param owner
|
|
31
|
+
* @param repo
|
|
32
|
+
* @returns The owner of the forked repository
|
|
33
|
+
*/
|
|
34
|
+
export declare function fork(octokit: Octokit, owner: string, repo: string): Promise<string>;
|
|
35
|
+
export declare function createCommit(octokit: Octokit, owner: string, repo: string, message: string, parentSha: string, treeSha: string): Promise<string>;
|
|
36
|
+
export declare function createTree(octokit: Octokit, owner: string, repo: string, parentSha: string, changeset: Changeset): Promise<string | null>;
|
|
37
|
+
export type GitHubTreeNode = {
|
|
38
|
+
path: string;
|
|
39
|
+
mode: '100644';
|
|
40
|
+
} & ({
|
|
41
|
+
sha: string | null;
|
|
42
|
+
} | {
|
|
43
|
+
content: string;
|
|
44
|
+
});
|
|
45
|
+
export declare function createTreeNodes(octokit: Octokit, owner: string, repo: string, parentSha: string, changeset: Changeset): Promise<GitHubTreeNode[]>;
|
|
46
|
+
export declare function createTreeNode(octokit: Octokit, owner: string, repo: string, path: string, content: string | Uint8Array): Promise<GitHubTreeNode>;
|
|
47
|
+
export declare function deleteFile(octokit: Octokit, owner: string, repo: string, parentSha: string, path: string): Promise<GitHubTreeNode | undefined>;
|
package/lib/paths.d.ts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wp-playground/storage",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.31",
|
|
4
4
|
"description": "Bindings for storing WordPress Playground on different backends.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"license": "GPL-2.0-or-later",
|
|
36
36
|
"type": "module",
|
|
37
|
+
"types": "index.d.ts",
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@zip.js/zip.js": "2.7.57",
|
|
39
40
|
"async-lock": "^1.4.1",
|
|
@@ -48,25 +49,26 @@
|
|
|
48
49
|
"pako": "^1.0.10",
|
|
49
50
|
"pify": "^4.0.1",
|
|
50
51
|
"readable-stream": "^3.4.0",
|
|
52
|
+
"selfsigned": "2.4.1",
|
|
51
53
|
"sha.js": "^2.4.9",
|
|
52
54
|
"simple-get": "^4.0.1",
|
|
53
55
|
"wasm-feature-detect": "1.8.0",
|
|
54
56
|
"ws": "8.18.3",
|
|
55
57
|
"yargs": "17.7.2",
|
|
56
|
-
"@php-wasm/web": "3.0.
|
|
57
|
-
"@php-wasm/universal": "3.0.
|
|
58
|
-
"@php-wasm/util": "3.0.
|
|
59
|
-
"@php-wasm/stream-compression": "3.0.
|
|
58
|
+
"@php-wasm/web": "3.0.31",
|
|
59
|
+
"@php-wasm/universal": "3.0.31",
|
|
60
|
+
"@php-wasm/util": "3.0.31",
|
|
61
|
+
"@php-wasm/stream-compression": "3.0.31"
|
|
60
62
|
},
|
|
61
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "e28b6d2a2e663abc3cbb8fce9a3c5cc8abaa5bbe",
|
|
62
64
|
"packageManager": "npm@10.9.2",
|
|
63
65
|
"overrides": {
|
|
64
66
|
"rollup": "^4.34.6",
|
|
65
67
|
"react": "18.3.1",
|
|
66
68
|
"react-dom": "18.3.1",
|
|
67
69
|
"typescript": "5.4.5",
|
|
68
|
-
"@playwright/test": "1.
|
|
69
|
-
"ws": "
|
|
70
|
+
"@playwright/test": "1.55.1",
|
|
71
|
+
"ws": "8.18.3",
|
|
70
72
|
"tmp": "0.2.5",
|
|
71
73
|
"form-data": "^4.0.4"
|
|
72
74
|
},
|