@aprovan/patchwork-compiler 0.1.0 → 0.1.2-dev.1a732c5
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 +2838 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +835 -0
- package/dist/index.d.ts +137 -54
- package/dist/index.js +1010 -119
- 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
|
|
@@ -142,6 +136,12 @@ interface CompilerOptions {
|
|
|
142
136
|
cdnBaseUrl?: string;
|
|
143
137
|
/** Base URL for widget imports (default: same as cdnBaseUrl). Used for transforming imports in widget code. */
|
|
144
138
|
widgetCdnBaseUrl?: string;
|
|
139
|
+
/**
|
|
140
|
+
* URL overrides for bundled assets/packages.
|
|
141
|
+
* Keys are asset identifiers (e.g., 'esbuild-wasm/esbuild.wasm'), values are local URLs.
|
|
142
|
+
* Use this to bundle assets locally for offline support or improved performance.
|
|
143
|
+
*/
|
|
144
|
+
urlOverrides?: Record<string, string>;
|
|
145
145
|
}
|
|
146
146
|
interface Compiler {
|
|
147
147
|
/** Pre-load an image package */
|
|
@@ -545,68 +545,151 @@ interface VFSPluginOptions {
|
|
|
545
545
|
}
|
|
546
546
|
declare function vfsPlugin(project: VirtualProject, options?: VFSPluginOptions): Plugin;
|
|
547
547
|
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
548
|
+
/**
|
|
549
|
+
* File statistics matching Node.js fs.Stats subset
|
|
550
|
+
*/
|
|
551
|
+
interface FileStats {
|
|
552
|
+
size: number;
|
|
553
|
+
mtime: Date;
|
|
554
|
+
isFile(): boolean;
|
|
555
|
+
isDirectory(): boolean;
|
|
556
|
+
}
|
|
557
|
+
/**
|
|
558
|
+
* Directory entry matching Node.js fs.Dirent
|
|
559
|
+
*/
|
|
560
|
+
interface DirEntry {
|
|
561
|
+
name: string;
|
|
562
|
+
isFile(): boolean;
|
|
563
|
+
isDirectory(): boolean;
|
|
564
|
+
}
|
|
565
|
+
type WatchEventType = "create" | "update" | "delete";
|
|
566
|
+
type WatchCallback = (event: WatchEventType, path: string) => void;
|
|
567
|
+
/**
|
|
568
|
+
* FSProvider - Node.js fs/promises compatible interface
|
|
569
|
+
* All paths are relative to provider root
|
|
570
|
+
*/
|
|
571
|
+
interface FSProvider {
|
|
572
|
+
readFile(path: string, encoding?: "utf8" | "base64"): Promise<string>;
|
|
573
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
574
|
+
unlink(path: string): Promise<void>;
|
|
575
|
+
stat(path: string): Promise<FileStats>;
|
|
576
|
+
mkdir(path: string, options?: {
|
|
577
|
+
recursive?: boolean;
|
|
578
|
+
}): Promise<void>;
|
|
579
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
580
|
+
rmdir(path: string, options?: {
|
|
581
|
+
recursive?: boolean;
|
|
582
|
+
}): Promise<void>;
|
|
583
|
+
exists(path: string): Promise<boolean>;
|
|
584
|
+
watch?(path: string, callback: WatchCallback): () => void;
|
|
564
585
|
}
|
|
586
|
+
/**
|
|
587
|
+
* Change record for sync operations
|
|
588
|
+
*/
|
|
589
|
+
interface ChangeRecord {
|
|
590
|
+
path: string;
|
|
591
|
+
type: WatchEventType;
|
|
592
|
+
mtime: Date;
|
|
593
|
+
checksum?: string;
|
|
594
|
+
}
|
|
595
|
+
type ConflictStrategy = "local-wins" | "remote-wins" | "newest-wins" | "manual";
|
|
596
|
+
interface SyncResult {
|
|
597
|
+
pushed: number;
|
|
598
|
+
pulled: number;
|
|
599
|
+
conflicts: ConflictRecord[];
|
|
600
|
+
}
|
|
601
|
+
interface ConflictRecord {
|
|
602
|
+
path: string;
|
|
603
|
+
localMtime: Date;
|
|
604
|
+
remoteMtime: Date;
|
|
605
|
+
resolved?: "local" | "remote";
|
|
606
|
+
}
|
|
607
|
+
type SyncStatus = "idle" | "syncing" | "error";
|
|
608
|
+
type SyncEventType = "change" | "conflict" | "error" | "status";
|
|
609
|
+
type SyncEventCallback<T = unknown> = (data: T) => void;
|
|
565
610
|
|
|
566
|
-
declare class IndexedDBBackend implements
|
|
611
|
+
declare class IndexedDBBackend implements FSProvider {
|
|
567
612
|
private prefix;
|
|
568
613
|
constructor(prefix?: string);
|
|
569
614
|
private key;
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
615
|
+
readFile(path: string): Promise<string>;
|
|
616
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
617
|
+
unlink(path: string): Promise<void>;
|
|
618
|
+
stat(path: string): Promise<FileStats>;
|
|
619
|
+
mkdir(path: string, options?: {
|
|
620
|
+
recursive?: boolean;
|
|
621
|
+
}): Promise<void>;
|
|
622
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
623
|
+
rmdir(path: string, options?: {
|
|
624
|
+
recursive?: boolean;
|
|
625
|
+
}): Promise<void>;
|
|
574
626
|
exists(path: string): Promise<boolean>;
|
|
627
|
+
private dirExists;
|
|
575
628
|
}
|
|
576
629
|
|
|
577
|
-
interface
|
|
630
|
+
interface HttpBackendConfig {
|
|
578
631
|
baseUrl: string;
|
|
579
632
|
}
|
|
580
|
-
|
|
633
|
+
/**
|
|
634
|
+
* HTTP-based FSProvider for connecting to remote servers (e.g., stitchery)
|
|
635
|
+
*/
|
|
636
|
+
declare class HttpBackend implements FSProvider {
|
|
581
637
|
private config;
|
|
582
|
-
constructor(config:
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
638
|
+
constructor(config: HttpBackendConfig);
|
|
639
|
+
readFile(path: string): Promise<string>;
|
|
640
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
641
|
+
unlink(path: string): Promise<void>;
|
|
642
|
+
stat(path: string): Promise<FileStats>;
|
|
643
|
+
mkdir(path: string, options?: {
|
|
644
|
+
recursive?: boolean;
|
|
645
|
+
}): Promise<void>;
|
|
646
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
647
|
+
rmdir(path: string, options?: {
|
|
648
|
+
recursive?: boolean;
|
|
649
|
+
}): Promise<void>;
|
|
587
650
|
exists(path: string): Promise<boolean>;
|
|
651
|
+
watch(path: string, callback: WatchCallback): () => void;
|
|
652
|
+
private startWatch;
|
|
653
|
+
private url;
|
|
588
654
|
}
|
|
589
655
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
656
|
+
declare function createProjectFromFiles(files: VirtualFile[], id?: string): VirtualProject;
|
|
657
|
+
declare function resolveEntry(files: Map<string, VirtualFile>): string;
|
|
658
|
+
declare function detectMainFile(language?: string): string;
|
|
659
|
+
declare function createSingleFileProject(content: string, entry?: string, id?: string): VirtualProject;
|
|
660
|
+
|
|
661
|
+
interface VFSStoreOptions {
|
|
662
|
+
root?: string;
|
|
663
|
+
sync?: boolean;
|
|
664
|
+
conflictStrategy?: ConflictStrategy;
|
|
665
|
+
autoSyncIntervalMs?: number;
|
|
598
666
|
}
|
|
599
|
-
declare class
|
|
600
|
-
private
|
|
601
|
-
|
|
602
|
-
private
|
|
603
|
-
private
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
667
|
+
declare class VFSStore {
|
|
668
|
+
private provider;
|
|
669
|
+
private local?;
|
|
670
|
+
private syncEngine?;
|
|
671
|
+
private root;
|
|
672
|
+
constructor(provider: FSProvider, options?: VFSStoreOptions);
|
|
673
|
+
readFile(path: string, encoding?: "utf8" | "base64"): Promise<string>;
|
|
674
|
+
writeFile(path: string, content: string): Promise<void>;
|
|
675
|
+
unlink(path: string): Promise<void>;
|
|
676
|
+
stat(path: string): Promise<FileStats>;
|
|
677
|
+
mkdir(path: string, options?: {
|
|
678
|
+
recursive?: boolean;
|
|
679
|
+
}): Promise<void>;
|
|
680
|
+
readdir(path: string): Promise<DirEntry[]>;
|
|
681
|
+
rmdir(path: string, options?: {
|
|
682
|
+
recursive?: boolean;
|
|
683
|
+
}): Promise<void>;
|
|
608
684
|
exists(path: string): Promise<boolean>;
|
|
609
|
-
|
|
685
|
+
listFiles(prefix?: string): Promise<string[]>;
|
|
686
|
+
loadProject(id: string): Promise<VirtualProject | null>;
|
|
687
|
+
saveProject(project: VirtualProject): Promise<void>;
|
|
688
|
+
watch(path: string, callback: WatchCallback): () => void;
|
|
689
|
+
sync(): Promise<SyncResult>;
|
|
690
|
+
on<T extends SyncEventType>(event: T, callback: SyncEventCallback<T extends "change" ? ChangeRecord : T extends "conflict" ? ConflictRecord : T extends "error" ? Error : SyncStatus>): () => void;
|
|
691
|
+
private remotePath;
|
|
692
|
+
private walkFiles;
|
|
610
693
|
}
|
|
611
694
|
|
|
612
695
|
/**
|
|
@@ -749,4 +832,4 @@ declare function createIframeServiceProxy(): ServiceProxy;
|
|
|
749
832
|
*/
|
|
750
833
|
declare function generateIframeBridgeScript(services: string[]): string;
|
|
751
834
|
|
|
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,
|
|
835
|
+
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, type WatchCallback, type WatchEventType, 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 };
|