Skip to content

Commit db8ba54

Browse files
committed
Fix extraction of Blueprint schema
1 parent 2119086 commit db8ba54

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

packages/php-wasm/universal/src/lib/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export type {
6464
} from './php-request-handler';
6565
export { rotatePHPRuntime } from './rotate-php-runtime';
6666
export { writeFiles } from './write-files';
67-
export type { FileTree } from './write-files';
67+
export type { FileTree, FileTreeAsync } from './write-files';
6868

6969
export {
7070
DEFAULT_BASE_URL,

packages/php-wasm/universal/src/lib/write-files.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ export interface WriteFilesOptions {
99
rmRoot?: boolean;
1010
}
1111

12-
// TODO: Consider supporting promised values for content so we can make a lazy version of FileTree
1312
type FileContent = Uint8Array | string | FileTree;
1413
type MaybePromise<T> = T | Promise<T>;
1514

16-
export interface FileTree extends Record<string, MaybePromise<FileContent>> {}
15+
export interface FileTree extends Record<string, FileContent> {}
16+
17+
export interface FileTreeAsync
18+
extends Record<string, MaybePromise<FileContent>> {}
1719

1820
/**
1921
* Writes multiple files to a specified directory in the Playground
@@ -35,7 +37,7 @@ export interface FileTree extends Record<string, MaybePromise<FileContent>> {}
3537
export async function writeFiles(
3638
php: UniversalPHP,
3739
root: string,
38-
newFiles: MaybePromise<FileTree>,
40+
newFiles: MaybePromise<FileTreeAsync>,
3941
{ rmRoot = false }: WriteFilesOptions = {}
4042
) {
4143
if (rmRoot) {

packages/playground/blueprints/src/lib/resources.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {
22
cloneResponseMonitorProgress,
33
ProgressTracker,
44
} from '@php-wasm/progress';
5-
import { FileTree, UniversalPHP } from '@php-wasm/universal';
5+
import { FileTree, FileTreeAsync, UniversalPHP } from '@php-wasm/universal';
66
import { dirname, joinPaths, Semaphore } from '@php-wasm/util';
77
import {
88
listDescendantFiles,
@@ -27,6 +27,12 @@ export type VFSReference = {
2727
/** The path to the file in the VFS */
2828
path: string;
2929
};
30+
export type VFSDirectoryReference = {
31+
/** Identifies the file resource as Virtual File System (VFS) */
32+
resource: 'vfs';
33+
/** The path to the file in the VFS */
34+
path: string;
35+
};
3036
export type LiteralReference = {
3137
/** Identifies the file resource as a literal file */
3238
resource: 'literal';
@@ -79,13 +85,14 @@ export type BlueprintAssetDirectoryReference = {
7985
};
8086

8187
export interface Directory {
82-
// TODO: I think FileTree contains data that is already read. Can/should we have this lazily read instead?
83-
files: FileTree;
88+
files: FileTreeAsync;
8489
name: string;
8590
}
86-
export type DirectoryLiteralReference = Directory & {
91+
export type DirectoryLiteralReference = {
8792
/** Identifies the file resource as a git directory */
8893
resource: 'literal:directory';
94+
files: FileTree;
95+
name: string;
8996
};
9097

9198
export type FileReference =
@@ -99,6 +106,7 @@ export type FileReference =
99106
export type DirectoryReference =
100107
| GitDirectoryReference
101108
| DirectoryLiteralReference
109+
| VFSDirectoryReference
102110
| BlueprintAssetDirectoryReference;
103111

104112
export function isResourceReference(ref: any): ref is FileReference {
@@ -339,7 +347,8 @@ export class BlueprintAssetDirectoryResource extends VFSDirectoryResource {
339347
}
340348
}
341349

342-
export async function createLazyVFSFileTree(
350+
// TODO: Should we export this?
351+
async function createLazyVFSFileTree(
343352
path: string,
344353
playground: UniversalPHP
345354
): Promise<FileTree> {

0 commit comments

Comments
 (0)