@aprovan/patchwork-compiler 0.1.0 → 0.1.2-dev.6bd527d
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/LICENSE +261 -247
- package/dist/index.cjs +2822 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +828 -0
- package/dist/index.d.ts +130 -54
- package/dist/index.js +990 -115
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -6,19 +6,13 @@ interface VirtualFile {
|
|
|
6
6
|
content: string;
|
|
7
7
|
language?: string;
|
|
8
8
|
note?: string;
|
|
9
|
+
encoding?: "utf8" | "base64";
|
|
9
10
|
}
|
|
10
11
|
interface VirtualProject {
|
|
11
12
|
id: string;
|
|
12
13
|
entry: string;
|
|
13
14
|
files: Map<string, VirtualFile>;
|
|
14
15
|
}
|
|
15
|
-
interface StorageBackend {
|
|
16
|
-
get(path: string): Promise<string | null>;
|
|
17
|
-
put(path: string, content: string): Promise<void>;
|
|
18
|
-
delete(path: string): Promise<void>;
|
|
19
|
-
list(prefix?: string): Promise<string[]>;
|
|
20
|
-
exists(path: string): Promise<boolean>;
|
|
21
|
-
}
|
|
22
16
|
|
|
23
17
|
/**
|
|
24
18
|
* Core types for the Patchwork compiler
|
|
@@ -545,68 +539,150 @@ interface VFSPluginOptions {
|
|
|
545
539
|
}
|
|
546
540
|
declare function vfsPlugin(project: VirtualProject, options?: VFSPluginOptions): Plugin;
|
|
547
541
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
542
|
+
/**
|
|
543
|
+
* File statistics matching Node.js fs.Stats subset
|
|
544
|
+
*/
|
|
545
|
+
interface FileStats {
|
|
546
|
+
size: number;
|
|
547
|
+
mtime: Date;
|
|
548
|
+
isFile(): boolean;
|
|
549
|
+
isDirectory(): boolean;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Directory entry matching Node.js fs.Dirent
|
|
553
|
+
*/
|
|
554
|
+
interface DirEntry {
|
|
555
|
+
name: string;
|
|
556
|
+
isFile(): boolean;
|
|
557
|
+
isDirectory(): boolean;
|
|
564
558
|
}
|
|
559
|
+
type WatchEventType = "create" | "update" | "delete";
|
|
560
|
+
type WatchCallback = (event: WatchEventType, path: string) => void;
|
|
561
|
+
/**
|
|
562
|
+
* FSProvider - Node.js fs/promises compatible interface
|
|
563
|
+
* All paths are relative to provider root
|
|
564
|
+
*/
|
|
565
|
+
interface FSProvider {
|
|
566
|
+
readFile(path: string, encoding?: "utf8" | "base64"): Promise<string>;
|
|
567
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
568
|
+
unlink(path: string): Promise<void>;
|
|
569
|
+
stat(path: string): Promise<FileStats>;
|
|
570
|
+
mkdir(path: string, options?: {
|
|
571
|
+
recursive?: boolean;
|
|
572
|
+
}): Promise<void>;
|
|
573
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
574
|
+
rmdir(path: string, options?: {
|
|
575
|
+
recursive?: boolean;
|
|
576
|
+
}): Promise<void>;
|
|
577
|
+
exists(path: string): Promise<boolean>;
|
|
578
|
+
watch?(path: string, callback: WatchCallback): () => void;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Change record for sync operations
|
|
582
|
+
*/
|
|
583
|
+
interface ChangeRecord {
|
|
584
|
+
path: string;
|
|
585
|
+
type: WatchEventType;
|
|
586
|
+
mtime: Date;
|
|
587
|
+
checksum?: string;
|
|
588
|
+
}
|
|
589
|
+
type ConflictStrategy = "local-wins" | "remote-wins" | "newest-wins" | "manual";
|
|
590
|
+
interface SyncResult {
|
|
591
|
+
pushed: number;
|
|
592
|
+
pulled: number;
|
|
593
|
+
conflicts: ConflictRecord[];
|
|
594
|
+
}
|
|
595
|
+
interface ConflictRecord {
|
|
596
|
+
path: string;
|
|
597
|
+
localMtime: Date;
|
|
598
|
+
remoteMtime: Date;
|
|
599
|
+
resolved?: "local" | "remote";
|
|
600
|
+
}
|
|
601
|
+
type SyncStatus = "idle" | "syncing" | "error";
|
|
602
|
+
type SyncEventType = "change" | "conflict" | "error" | "status";
|
|
603
|
+
type SyncEventCallback<T = unknown> = (data: T) => void;
|
|
565
604
|
|
|
566
|
-
declare class IndexedDBBackend implements
|
|
605
|
+
declare class IndexedDBBackend implements FSProvider {
|
|
567
606
|
private prefix;
|
|
568
607
|
constructor(prefix?: string);
|
|
569
608
|
private key;
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
609
|
+
readFile(path: string): Promise<string>;
|
|
610
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
611
|
+
unlink(path: string): Promise<void>;
|
|
612
|
+
stat(path: string): Promise<FileStats>;
|
|
613
|
+
mkdir(path: string, options?: {
|
|
614
|
+
recursive?: boolean;
|
|
615
|
+
}): Promise<void>;
|
|
616
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
617
|
+
rmdir(path: string, options?: {
|
|
618
|
+
recursive?: boolean;
|
|
619
|
+
}): Promise<void>;
|
|
574
620
|
exists(path: string): Promise<boolean>;
|
|
621
|
+
private dirExists;
|
|
575
622
|
}
|
|
576
623
|
|
|
577
|
-
interface
|
|
624
|
+
interface HttpBackendConfig {
|
|
578
625
|
baseUrl: string;
|
|
579
626
|
}
|
|
580
|
-
|
|
627
|
+
/**
|
|
628
|
+
* HTTP-based FSProvider for connecting to remote servers (e.g., stitchery)
|
|
629
|
+
*/
|
|
630
|
+
declare class HttpBackend implements FSProvider {
|
|
581
631
|
private config;
|
|
582
|
-
constructor(config:
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
632
|
+
constructor(config: HttpBackendConfig);
|
|
633
|
+
readFile(path: string): Promise<string>;
|
|
634
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
635
|
+
unlink(path: string): Promise<void>;
|
|
636
|
+
stat(path: string): Promise<FileStats>;
|
|
637
|
+
mkdir(path: string, options?: {
|
|
638
|
+
recursive?: boolean;
|
|
639
|
+
}): Promise<void>;
|
|
640
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
641
|
+
rmdir(path: string, options?: {
|
|
642
|
+
recursive?: boolean;
|
|
643
|
+
}): Promise<void>;
|
|
587
644
|
exists(path: string): Promise<boolean>;
|
|
645
|
+
watch(path: string, callback: WatchCallback): () => void;
|
|
646
|
+
private startWatch;
|
|
647
|
+
private url;
|
|
588
648
|
}
|
|
589
649
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
650
|
+
declare function createProjectFromFiles(files: VirtualFile[], id?: string): VirtualProject;
|
|
651
|
+
declare function resolveEntry(files: Map<string, VirtualFile>): string;
|
|
652
|
+
declare function detectMainFile(language?: string): string;
|
|
653
|
+
declare function createSingleFileProject(content: string, entry?: string, id?: string): VirtualProject;
|
|
654
|
+
|
|
655
|
+
interface VFSStoreOptions {
|
|
656
|
+
root?: string;
|
|
657
|
+
sync?: boolean;
|
|
658
|
+
conflictStrategy?: ConflictStrategy;
|
|
659
|
+
autoSyncIntervalMs?: number;
|
|
598
660
|
}
|
|
599
|
-
declare class
|
|
600
|
-
private
|
|
601
|
-
|
|
602
|
-
private
|
|
603
|
-
private
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
661
|
+
declare class VFSStore {
|
|
662
|
+
private provider;
|
|
663
|
+
private local?;
|
|
664
|
+
private syncEngine?;
|
|
665
|
+
private root;
|
|
666
|
+
constructor(provider: FSProvider, options?: VFSStoreOptions);
|
|
667
|
+
readFile(path: string, encoding?: "utf8" | "base64"): Promise<string>;
|
|
668
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
669
|
+
unlink(path: string): Promise<void>;
|
|
670
|
+
stat(path: string): Promise<FileStats>;
|
|
671
|
+
mkdir(path: string, options?: {
|
|
672
|
+
recursive?: boolean;
|
|
673
|
+
}): Promise<void>;
|
|
674
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
675
|
+
rmdir(path: string, options?: {
|
|
676
|
+
recursive?: boolean;
|
|
677
|
+
}): Promise<void>;
|
|
608
678
|
exists(path: string): Promise<boolean>;
|
|
609
|
-
|
|
679
|
+
listFiles(prefix?: string): Promise<string[]>;
|
|
680
|
+
loadProject(id: string): Promise<VirtualProject | null>;
|
|
681
|
+
saveProject(project: VirtualProject): Promise<void>;
|
|
682
|
+
sync(): Promise<SyncResult>;
|
|
683
|
+
on<T extends SyncEventType>(event: T, callback: SyncEventCallback<T extends "change" ? ChangeRecord : T extends "conflict" ? ConflictRecord : T extends "error" ? Error : SyncStatus>): () => void;
|
|
684
|
+
private remotePath;
|
|
685
|
+
private walkFiles;
|
|
610
686
|
}
|
|
611
687
|
|
|
612
688
|
/**
|
|
@@ -749,4 +825,4 @@ declare function createIframeServiceProxy(): ServiceProxy;
|
|
|
749
825
|
*/
|
|
750
826
|
declare function generateIframeBridgeScript(services: string[]): string;
|
|
751
827
|
|
|
752
|
-
export { type BridgeMessage, type BridgeMessageType, type CdnTransformOptions, type CompileOptions, CompileOptionsSchema, type CompiledWidget, type Compiler, type CompilerOptions, DEFAULT_CLI_IMAGE_CONFIG, DEFAULT_IMAGE_CONFIG, DEV_SANDBOX, EsbuildConfigSchema, type GlobalInterfaceDefinition, type ImageConfig$1 as ImageConfig, ImageConfigSchema, type ImageMountFn, ImageRegistry, IndexedDBBackend, type InputSpec, InputSpecSchema, type LoadedImage,
|
|
828
|
+
export { type BridgeMessage, type BridgeMessageType, type CdnTransformOptions, type ChangeRecord, type CompileOptions, CompileOptionsSchema, type CompiledWidget, type Compiler, type CompilerOptions, DEFAULT_CLI_IMAGE_CONFIG, DEFAULT_IMAGE_CONFIG, DEV_SANDBOX, EsbuildConfigSchema, type GlobalInterfaceDefinition, HttpBackend, type HttpBackendConfig, type ImageConfig$1 as ImageConfig, ImageConfigSchema, type ImageMountFn, ImageRegistry, IndexedDBBackend, type InputSpec, InputSpecSchema, type LoadedImage, type Manifest$1 as Manifest, ManifestSchema, type MountMode, MountModeSchema, type MountOptions, MountOptionsSchema, type MountedWidget, ParentBridge, type Platform, PlatformSchema, type ServiceCallHandler, type ServiceCallPayload, type ServiceProxy, type ServiceResultPayload, type VFSPluginOptions, VFSStore, type VFSStoreOptions, type VirtualFile, type VirtualProject, cdnTransformPlugin, createCompiler, createFieldAccessProxy, createHttpServiceProxy, createIframeServiceProxy, createImageRegistry, createProjectFromFiles, createSingleFileProject, detectMainFile, disposeIframeBridge, extractNamespaces, fetchPackageJson, generateIframeBridgeScript, generateImportMap, generateNamespaceGlobals, getCdnBaseUrl, getImageRegistry, injectNamespaceGlobals, loadImage, mountEmbedded, mountIframe, parseImageConfig, parseImageSpec, parseManifest, reloadEmbedded, reloadIframe, removeNamespaceGlobals, resolveEntry, safeParseImageConfig, safeParseManifest, setCdnBaseUrl, vfsPlugin };
|