@aprovan/patchwork-compiler 0.1.2-dev.98f1b7b → 0.1.2-dev.9c336a0
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/dist/index.cjs +576 -558
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +78 -29
- package/dist/index.d.ts +78 -29
- package/dist/index.js +566 -555
- package/dist/index.js.map +1 -1
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -17,7 +17,7 @@ interface VirtualProject {
|
|
|
17
17
|
/**
|
|
18
18
|
* Core types for the Patchwork compiler
|
|
19
19
|
*/
|
|
20
|
-
type Platform =
|
|
20
|
+
type Platform = "browser" | "cli";
|
|
21
21
|
interface Manifest$1 {
|
|
22
22
|
name: string;
|
|
23
23
|
version: string;
|
|
@@ -29,7 +29,7 @@ interface Manifest$1 {
|
|
|
29
29
|
packages?: Record<string, string>;
|
|
30
30
|
}
|
|
31
31
|
interface InputSpec {
|
|
32
|
-
type:
|
|
32
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
33
33
|
default?: unknown;
|
|
34
34
|
required?: boolean;
|
|
35
35
|
description?: string;
|
|
@@ -46,7 +46,7 @@ interface CompiledWidget {
|
|
|
46
46
|
/** Source map (if generated) */
|
|
47
47
|
sourceMap?: string;
|
|
48
48
|
}
|
|
49
|
-
type MountMode =
|
|
49
|
+
type MountMode = "embedded" | "iframe";
|
|
50
50
|
interface MountOptions {
|
|
51
51
|
/** Target DOM element to mount into */
|
|
52
52
|
target: HTMLElement;
|
|
@@ -79,8 +79,8 @@ interface ImageConfig$1 {
|
|
|
79
79
|
platform: Platform;
|
|
80
80
|
esbuild?: {
|
|
81
81
|
target?: string;
|
|
82
|
-
format?:
|
|
83
|
-
jsx?:
|
|
82
|
+
format?: "esm" | "cjs" | "iife";
|
|
83
|
+
jsx?: "automatic" | "transform" | "preserve";
|
|
84
84
|
jsxFactory?: string;
|
|
85
85
|
jsxFragment?: string;
|
|
86
86
|
};
|
|
@@ -163,7 +163,7 @@ interface Compiler {
|
|
|
163
163
|
* The compiler provides the interface; actual implementation (e.g., UTCP, MCP)
|
|
164
164
|
* is handled by the runtime/backend.
|
|
165
165
|
*/
|
|
166
|
-
interface
|
|
166
|
+
interface Proxy {
|
|
167
167
|
call(namespace: string, procedure: string, args: unknown[]): Promise<unknown>;
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
@@ -184,7 +184,7 @@ interface GlobalInterfaceDefinition {
|
|
|
184
184
|
/** Optional TypeScript type definitions for methods */
|
|
185
185
|
types?: string;
|
|
186
186
|
}
|
|
187
|
-
type BridgeMessageType =
|
|
187
|
+
type BridgeMessageType = "service-call" | "service-result" | "error";
|
|
188
188
|
interface BridgeMessage {
|
|
189
189
|
type: BridgeMessageType;
|
|
190
190
|
id: string;
|
|
@@ -222,15 +222,15 @@ declare const EsbuildConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
|
222
222
|
jsxFactory: z.ZodOptional<z.ZodString>;
|
|
223
223
|
jsxFragment: z.ZodOptional<z.ZodString>;
|
|
224
224
|
}, "strict", z.ZodTypeAny, {
|
|
225
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
226
225
|
target?: string | undefined;
|
|
227
226
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
227
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
228
228
|
jsxFactory?: string | undefined;
|
|
229
229
|
jsxFragment?: string | undefined;
|
|
230
230
|
}, {
|
|
231
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
232
231
|
target?: string | undefined;
|
|
233
232
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
233
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
234
234
|
jsxFactory?: string | undefined;
|
|
235
235
|
jsxFragment?: string | undefined;
|
|
236
236
|
}>>;
|
|
@@ -244,15 +244,15 @@ declare const ImageConfigSchema: z.ZodObject<{
|
|
|
244
244
|
jsxFactory: z.ZodOptional<z.ZodString>;
|
|
245
245
|
jsxFragment: z.ZodOptional<z.ZodString>;
|
|
246
246
|
}, "strict", z.ZodTypeAny, {
|
|
247
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
248
247
|
target?: string | undefined;
|
|
249
248
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
249
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
250
250
|
jsxFactory?: string | undefined;
|
|
251
251
|
jsxFragment?: string | undefined;
|
|
252
252
|
}, {
|
|
253
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
254
253
|
target?: string | undefined;
|
|
255
254
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
255
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
256
256
|
jsxFactory?: string | undefined;
|
|
257
257
|
jsxFragment?: string | undefined;
|
|
258
258
|
}>>;
|
|
@@ -274,9 +274,9 @@ declare const ImageConfigSchema: z.ZodObject<{
|
|
|
274
274
|
platform: "browser" | "cli";
|
|
275
275
|
dependencies?: Record<string, string> | undefined;
|
|
276
276
|
esbuild?: {
|
|
277
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
278
277
|
target?: string | undefined;
|
|
279
278
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
279
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
280
280
|
jsxFactory?: string | undefined;
|
|
281
281
|
jsxFragment?: string | undefined;
|
|
282
282
|
} | undefined;
|
|
@@ -290,9 +290,9 @@ declare const ImageConfigSchema: z.ZodObject<{
|
|
|
290
290
|
platform: "browser" | "cli";
|
|
291
291
|
dependencies?: Record<string, string> | undefined;
|
|
292
292
|
esbuild?: {
|
|
293
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
294
293
|
target?: string | undefined;
|
|
295
294
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
295
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
296
296
|
jsxFactory?: string | undefined;
|
|
297
297
|
jsxFragment?: string | undefined;
|
|
298
298
|
} | undefined;
|
|
@@ -422,19 +422,65 @@ declare const DEFAULT_IMAGE_CONFIG: ImageConfig;
|
|
|
422
422
|
declare const DEFAULT_CLI_IMAGE_CONFIG: ImageConfig;
|
|
423
423
|
|
|
424
424
|
/**
|
|
425
|
-
*
|
|
425
|
+
* Shared CDN configuration for the patchwork compiler
|
|
426
426
|
*
|
|
427
|
-
*
|
|
427
|
+
* This module centralizes CDN base URL management used by:
|
|
428
|
+
* - Image loading (images/loader.ts)
|
|
429
|
+
* - CDN transforms (transforms/cdn.ts)
|
|
430
|
+
* - Mount utilities (mount/embedded.ts)
|
|
428
431
|
*/
|
|
429
|
-
|
|
432
|
+
declare const DEFAULT_CDN_BASE = "https://esm.sh";
|
|
430
433
|
/**
|
|
431
|
-
* Set the CDN base URL for
|
|
434
|
+
* Set the CDN base URL for all CDN operations
|
|
432
435
|
*/
|
|
433
436
|
declare function setCdnBaseUrl(url: string): void;
|
|
434
437
|
/**
|
|
435
438
|
* Get the current CDN base URL
|
|
436
439
|
*/
|
|
437
440
|
declare function getCdnBaseUrl(): string;
|
|
441
|
+
/**
|
|
442
|
+
* Convert a package specifier to a CDN URL
|
|
443
|
+
*
|
|
444
|
+
* @param packageName - The npm package name
|
|
445
|
+
* @param version - Optional version specifier
|
|
446
|
+
* @param subpath - Optional subpath (e.g., '/client' for 'react-dom/client')
|
|
447
|
+
* @param deps - Optional dependency version overrides (use ?deps=react@18)
|
|
448
|
+
*/
|
|
449
|
+
declare function toEsmShUrl(packageName: string, version?: string, subpath?: string, deps?: Record<string, string>): string;
|
|
450
|
+
/**
|
|
451
|
+
* Check if an import path is a bare module specifier
|
|
452
|
+
*/
|
|
453
|
+
declare function isBareImport(path: string): boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Parse a package specifier into name and version
|
|
456
|
+
*/
|
|
457
|
+
declare function parsePackageSpec(spec: string): {
|
|
458
|
+
name: string;
|
|
459
|
+
version?: string;
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* Extract package name and subpath from an import
|
|
463
|
+
*/
|
|
464
|
+
declare function parseImportPath(importPath: string): {
|
|
465
|
+
packageName: string;
|
|
466
|
+
subpath?: string;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Match an import path against alias patterns
|
|
470
|
+
* Supports glob patterns like '@/components/ui/*'
|
|
471
|
+
*/
|
|
472
|
+
declare function matchAlias(importPath: string, aliases: Record<string, string>): string | null;
|
|
473
|
+
/**
|
|
474
|
+
* Get common named exports for known packages
|
|
475
|
+
*/
|
|
476
|
+
declare function getCommonExports(packageName: string): string[];
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Image loader - fetches and loads image packages from CDN or local
|
|
480
|
+
*
|
|
481
|
+
* Images must be installed as npm packages or available on CDN.
|
|
482
|
+
*/
|
|
483
|
+
|
|
438
484
|
interface ImagePackageJson {
|
|
439
485
|
name: string;
|
|
440
486
|
version: string;
|
|
@@ -444,6 +490,7 @@ interface ImagePackageJson {
|
|
|
444
490
|
}
|
|
445
491
|
/**
|
|
446
492
|
* Parse image specifier into name and version
|
|
493
|
+
* (Alias of parsePackageSpec for image-specific usage)
|
|
447
494
|
*/
|
|
448
495
|
declare function parseImageSpec(spec: string): {
|
|
449
496
|
name: string;
|
|
@@ -629,9 +676,11 @@ declare class IndexedDBBackend implements FSProvider {
|
|
|
629
676
|
|
|
630
677
|
interface HttpBackendConfig {
|
|
631
678
|
baseUrl: string;
|
|
679
|
+
/** How often to poll for external changes, in milliseconds. Default: 7000. */
|
|
680
|
+
pollIntervalMs?: number;
|
|
632
681
|
}
|
|
633
682
|
/**
|
|
634
|
-
* HTTP-based FSProvider for connecting to remote servers
|
|
683
|
+
* HTTP-based FSProvider for connecting to remote VFS servers
|
|
635
684
|
*/
|
|
636
685
|
declare class HttpBackend implements FSProvider {
|
|
637
686
|
private config;
|
|
@@ -648,8 +697,8 @@ declare class HttpBackend implements FSProvider {
|
|
|
648
697
|
recursive?: boolean;
|
|
649
698
|
}): Promise<void>;
|
|
650
699
|
exists(path: string): Promise<boolean>;
|
|
651
|
-
watch(
|
|
652
|
-
private
|
|
700
|
+
watch(_path: string, callback: WatchCallback): () => void;
|
|
701
|
+
private startPoll;
|
|
653
702
|
private url;
|
|
654
703
|
}
|
|
655
704
|
|
|
@@ -701,11 +750,11 @@ declare class VFSStore {
|
|
|
701
750
|
/**
|
|
702
751
|
* Mount a widget in embedded mode (direct DOM injection)
|
|
703
752
|
*/
|
|
704
|
-
declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy:
|
|
753
|
+
declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
705
754
|
/**
|
|
706
755
|
* Hot reload an embedded widget
|
|
707
756
|
*/
|
|
708
|
-
declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy:
|
|
757
|
+
declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
709
758
|
|
|
710
759
|
/**
|
|
711
760
|
* Iframe mount mode - mounts widgets in sandboxed iframes
|
|
@@ -731,11 +780,11 @@ declare const DEV_SANDBOX: string[];
|
|
|
731
780
|
/**
|
|
732
781
|
* Mount a widget in iframe mode (sandboxed)
|
|
733
782
|
*/
|
|
734
|
-
declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy:
|
|
783
|
+
declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
735
784
|
/**
|
|
736
785
|
* Hot reload an iframe widget
|
|
737
786
|
*/
|
|
738
|
-
declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy:
|
|
787
|
+
declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
739
788
|
/**
|
|
740
789
|
* Dispose the shared bridge (call on app shutdown)
|
|
741
790
|
*/
|
|
@@ -748,7 +797,7 @@ declare function disposeIframeBridge(): void;
|
|
|
748
797
|
/**
|
|
749
798
|
* Create a service proxy that calls the backend via HTTP
|
|
750
799
|
*/
|
|
751
|
-
declare function
|
|
800
|
+
declare function createHttpProxy(proxyUrl: string): Proxy;
|
|
752
801
|
/**
|
|
753
802
|
* Creates a proxy that enables fluent method chaining for dynamic field access.
|
|
754
803
|
*
|
|
@@ -776,7 +825,7 @@ declare function createFieldAccessProxy<T = unknown>(namespace: string, handler:
|
|
|
776
825
|
* // calls proxy.call('github', 'repos.list_for_user', [{ username: 'x' }])
|
|
777
826
|
* ```
|
|
778
827
|
*/
|
|
779
|
-
declare function generateNamespaceGlobals(services: string[], proxy:
|
|
828
|
+
declare function generateNamespaceGlobals(services: string[], proxy: Proxy): Record<string, unknown>;
|
|
780
829
|
/**
|
|
781
830
|
* Inject namespace globals into a window object
|
|
782
831
|
*/
|
|
@@ -799,7 +848,7 @@ declare class ParentBridge {
|
|
|
799
848
|
private pendingCalls;
|
|
800
849
|
private iframes;
|
|
801
850
|
private messageHandler;
|
|
802
|
-
constructor(proxy:
|
|
851
|
+
constructor(proxy: Proxy);
|
|
803
852
|
/**
|
|
804
853
|
* Register an iframe to receive messages from
|
|
805
854
|
*/
|
|
@@ -822,7 +871,7 @@ declare class ParentBridge {
|
|
|
822
871
|
*
|
|
823
872
|
* Creates a service proxy that sends postMessage to parent.
|
|
824
873
|
*/
|
|
825
|
-
declare function
|
|
874
|
+
declare function createIframeProxy(): Proxy;
|
|
826
875
|
/**
|
|
827
876
|
* Generate the bridge script to inject into iframes
|
|
828
877
|
*
|
|
@@ -832,4 +881,4 @@ declare function createIframeServiceProxy(): ServiceProxy;
|
|
|
832
881
|
*/
|
|
833
882
|
declare function generateIframeBridgeScript(services: string[]): string;
|
|
834
883
|
|
|
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
|
|
884
|
+
export { type BridgeMessage, type BridgeMessageType, type CdnTransformOptions, type ChangeRecord, type CompileOptions, CompileOptionsSchema, type CompiledWidget, type Compiler, type CompilerOptions, DEFAULT_CDN_BASE, 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 Proxy, type ServiceCallHandler, type ServiceCallPayload, type ServiceResultPayload, type VFSPluginOptions, VFSStore, type VFSStoreOptions, type VirtualFile, type VirtualProject, type WatchCallback, type WatchEventType, cdnTransformPlugin, createCompiler, createFieldAccessProxy, createHttpProxy, createIframeProxy, createImageRegistry, createProjectFromFiles, createSingleFileProject, detectMainFile, disposeIframeBridge, extractNamespaces, fetchPackageJson, generateIframeBridgeScript, generateImportMap, generateNamespaceGlobals, getCdnBaseUrl, getCommonExports, getImageRegistry, injectNamespaceGlobals, isBareImport, loadImage, matchAlias, mountEmbedded, mountIframe, parseImageConfig, parseImageSpec, parseImportPath, parseManifest, parsePackageSpec, reloadEmbedded, reloadIframe, removeNamespaceGlobals, resolveEntry, safeParseImageConfig, safeParseManifest, setCdnBaseUrl, toEsmShUrl, vfsPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface VirtualProject {
|
|
|
17
17
|
/**
|
|
18
18
|
* Core types for the Patchwork compiler
|
|
19
19
|
*/
|
|
20
|
-
type Platform =
|
|
20
|
+
type Platform = "browser" | "cli";
|
|
21
21
|
interface Manifest$1 {
|
|
22
22
|
name: string;
|
|
23
23
|
version: string;
|
|
@@ -29,7 +29,7 @@ interface Manifest$1 {
|
|
|
29
29
|
packages?: Record<string, string>;
|
|
30
30
|
}
|
|
31
31
|
interface InputSpec {
|
|
32
|
-
type:
|
|
32
|
+
type: "string" | "number" | "boolean" | "object" | "array";
|
|
33
33
|
default?: unknown;
|
|
34
34
|
required?: boolean;
|
|
35
35
|
description?: string;
|
|
@@ -46,7 +46,7 @@ interface CompiledWidget {
|
|
|
46
46
|
/** Source map (if generated) */
|
|
47
47
|
sourceMap?: string;
|
|
48
48
|
}
|
|
49
|
-
type MountMode =
|
|
49
|
+
type MountMode = "embedded" | "iframe";
|
|
50
50
|
interface MountOptions {
|
|
51
51
|
/** Target DOM element to mount into */
|
|
52
52
|
target: HTMLElement;
|
|
@@ -79,8 +79,8 @@ interface ImageConfig$1 {
|
|
|
79
79
|
platform: Platform;
|
|
80
80
|
esbuild?: {
|
|
81
81
|
target?: string;
|
|
82
|
-
format?:
|
|
83
|
-
jsx?:
|
|
82
|
+
format?: "esm" | "cjs" | "iife";
|
|
83
|
+
jsx?: "automatic" | "transform" | "preserve";
|
|
84
84
|
jsxFactory?: string;
|
|
85
85
|
jsxFragment?: string;
|
|
86
86
|
};
|
|
@@ -163,7 +163,7 @@ interface Compiler {
|
|
|
163
163
|
* The compiler provides the interface; actual implementation (e.g., UTCP, MCP)
|
|
164
164
|
* is handled by the runtime/backend.
|
|
165
165
|
*/
|
|
166
|
-
interface
|
|
166
|
+
interface Proxy {
|
|
167
167
|
call(namespace: string, procedure: string, args: unknown[]): Promise<unknown>;
|
|
168
168
|
}
|
|
169
169
|
/**
|
|
@@ -184,7 +184,7 @@ interface GlobalInterfaceDefinition {
|
|
|
184
184
|
/** Optional TypeScript type definitions for methods */
|
|
185
185
|
types?: string;
|
|
186
186
|
}
|
|
187
|
-
type BridgeMessageType =
|
|
187
|
+
type BridgeMessageType = "service-call" | "service-result" | "error";
|
|
188
188
|
interface BridgeMessage {
|
|
189
189
|
type: BridgeMessageType;
|
|
190
190
|
id: string;
|
|
@@ -222,15 +222,15 @@ declare const EsbuildConfigSchema: z.ZodOptional<z.ZodObject<{
|
|
|
222
222
|
jsxFactory: z.ZodOptional<z.ZodString>;
|
|
223
223
|
jsxFragment: z.ZodOptional<z.ZodString>;
|
|
224
224
|
}, "strict", z.ZodTypeAny, {
|
|
225
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
226
225
|
target?: string | undefined;
|
|
227
226
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
227
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
228
228
|
jsxFactory?: string | undefined;
|
|
229
229
|
jsxFragment?: string | undefined;
|
|
230
230
|
}, {
|
|
231
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
232
231
|
target?: string | undefined;
|
|
233
232
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
233
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
234
234
|
jsxFactory?: string | undefined;
|
|
235
235
|
jsxFragment?: string | undefined;
|
|
236
236
|
}>>;
|
|
@@ -244,15 +244,15 @@ declare const ImageConfigSchema: z.ZodObject<{
|
|
|
244
244
|
jsxFactory: z.ZodOptional<z.ZodString>;
|
|
245
245
|
jsxFragment: z.ZodOptional<z.ZodString>;
|
|
246
246
|
}, "strict", z.ZodTypeAny, {
|
|
247
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
248
247
|
target?: string | undefined;
|
|
249
248
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
249
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
250
250
|
jsxFactory?: string | undefined;
|
|
251
251
|
jsxFragment?: string | undefined;
|
|
252
252
|
}, {
|
|
253
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
254
253
|
target?: string | undefined;
|
|
255
254
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
255
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
256
256
|
jsxFactory?: string | undefined;
|
|
257
257
|
jsxFragment?: string | undefined;
|
|
258
258
|
}>>;
|
|
@@ -274,9 +274,9 @@ declare const ImageConfigSchema: z.ZodObject<{
|
|
|
274
274
|
platform: "browser" | "cli";
|
|
275
275
|
dependencies?: Record<string, string> | undefined;
|
|
276
276
|
esbuild?: {
|
|
277
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
278
277
|
target?: string | undefined;
|
|
279
278
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
279
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
280
280
|
jsxFactory?: string | undefined;
|
|
281
281
|
jsxFragment?: string | undefined;
|
|
282
282
|
} | undefined;
|
|
@@ -290,9 +290,9 @@ declare const ImageConfigSchema: z.ZodObject<{
|
|
|
290
290
|
platform: "browser" | "cli";
|
|
291
291
|
dependencies?: Record<string, string> | undefined;
|
|
292
292
|
esbuild?: {
|
|
293
|
-
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
294
293
|
target?: string | undefined;
|
|
295
294
|
format?: "esm" | "cjs" | "iife" | undefined;
|
|
295
|
+
jsx?: "automatic" | "transform" | "preserve" | undefined;
|
|
296
296
|
jsxFactory?: string | undefined;
|
|
297
297
|
jsxFragment?: string | undefined;
|
|
298
298
|
} | undefined;
|
|
@@ -422,19 +422,65 @@ declare const DEFAULT_IMAGE_CONFIG: ImageConfig;
|
|
|
422
422
|
declare const DEFAULT_CLI_IMAGE_CONFIG: ImageConfig;
|
|
423
423
|
|
|
424
424
|
/**
|
|
425
|
-
*
|
|
425
|
+
* Shared CDN configuration for the patchwork compiler
|
|
426
426
|
*
|
|
427
|
-
*
|
|
427
|
+
* This module centralizes CDN base URL management used by:
|
|
428
|
+
* - Image loading (images/loader.ts)
|
|
429
|
+
* - CDN transforms (transforms/cdn.ts)
|
|
430
|
+
* - Mount utilities (mount/embedded.ts)
|
|
428
431
|
*/
|
|
429
|
-
|
|
432
|
+
declare const DEFAULT_CDN_BASE = "https://esm.sh";
|
|
430
433
|
/**
|
|
431
|
-
* Set the CDN base URL for
|
|
434
|
+
* Set the CDN base URL for all CDN operations
|
|
432
435
|
*/
|
|
433
436
|
declare function setCdnBaseUrl(url: string): void;
|
|
434
437
|
/**
|
|
435
438
|
* Get the current CDN base URL
|
|
436
439
|
*/
|
|
437
440
|
declare function getCdnBaseUrl(): string;
|
|
441
|
+
/**
|
|
442
|
+
* Convert a package specifier to a CDN URL
|
|
443
|
+
*
|
|
444
|
+
* @param packageName - The npm package name
|
|
445
|
+
* @param version - Optional version specifier
|
|
446
|
+
* @param subpath - Optional subpath (e.g., '/client' for 'react-dom/client')
|
|
447
|
+
* @param deps - Optional dependency version overrides (use ?deps=react@18)
|
|
448
|
+
*/
|
|
449
|
+
declare function toEsmShUrl(packageName: string, version?: string, subpath?: string, deps?: Record<string, string>): string;
|
|
450
|
+
/**
|
|
451
|
+
* Check if an import path is a bare module specifier
|
|
452
|
+
*/
|
|
453
|
+
declare function isBareImport(path: string): boolean;
|
|
454
|
+
/**
|
|
455
|
+
* Parse a package specifier into name and version
|
|
456
|
+
*/
|
|
457
|
+
declare function parsePackageSpec(spec: string): {
|
|
458
|
+
name: string;
|
|
459
|
+
version?: string;
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* Extract package name and subpath from an import
|
|
463
|
+
*/
|
|
464
|
+
declare function parseImportPath(importPath: string): {
|
|
465
|
+
packageName: string;
|
|
466
|
+
subpath?: string;
|
|
467
|
+
};
|
|
468
|
+
/**
|
|
469
|
+
* Match an import path against alias patterns
|
|
470
|
+
* Supports glob patterns like '@/components/ui/*'
|
|
471
|
+
*/
|
|
472
|
+
declare function matchAlias(importPath: string, aliases: Record<string, string>): string | null;
|
|
473
|
+
/**
|
|
474
|
+
* Get common named exports for known packages
|
|
475
|
+
*/
|
|
476
|
+
declare function getCommonExports(packageName: string): string[];
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Image loader - fetches and loads image packages from CDN or local
|
|
480
|
+
*
|
|
481
|
+
* Images must be installed as npm packages or available on CDN.
|
|
482
|
+
*/
|
|
483
|
+
|
|
438
484
|
interface ImagePackageJson {
|
|
439
485
|
name: string;
|
|
440
486
|
version: string;
|
|
@@ -444,6 +490,7 @@ interface ImagePackageJson {
|
|
|
444
490
|
}
|
|
445
491
|
/**
|
|
446
492
|
* Parse image specifier into name and version
|
|
493
|
+
* (Alias of parsePackageSpec for image-specific usage)
|
|
447
494
|
*/
|
|
448
495
|
declare function parseImageSpec(spec: string): {
|
|
449
496
|
name: string;
|
|
@@ -629,9 +676,11 @@ declare class IndexedDBBackend implements FSProvider {
|
|
|
629
676
|
|
|
630
677
|
interface HttpBackendConfig {
|
|
631
678
|
baseUrl: string;
|
|
679
|
+
/** How often to poll for external changes, in milliseconds. Default: 7000. */
|
|
680
|
+
pollIntervalMs?: number;
|
|
632
681
|
}
|
|
633
682
|
/**
|
|
634
|
-
* HTTP-based FSProvider for connecting to remote servers
|
|
683
|
+
* HTTP-based FSProvider for connecting to remote VFS servers
|
|
635
684
|
*/
|
|
636
685
|
declare class HttpBackend implements FSProvider {
|
|
637
686
|
private config;
|
|
@@ -648,8 +697,8 @@ declare class HttpBackend implements FSProvider {
|
|
|
648
697
|
recursive?: boolean;
|
|
649
698
|
}): Promise<void>;
|
|
650
699
|
exists(path: string): Promise<boolean>;
|
|
651
|
-
watch(
|
|
652
|
-
private
|
|
700
|
+
watch(_path: string, callback: WatchCallback): () => void;
|
|
701
|
+
private startPoll;
|
|
653
702
|
private url;
|
|
654
703
|
}
|
|
655
704
|
|
|
@@ -701,11 +750,11 @@ declare class VFSStore {
|
|
|
701
750
|
/**
|
|
702
751
|
* Mount a widget in embedded mode (direct DOM injection)
|
|
703
752
|
*/
|
|
704
|
-
declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy:
|
|
753
|
+
declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
705
754
|
/**
|
|
706
755
|
* Hot reload an embedded widget
|
|
707
756
|
*/
|
|
708
|
-
declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy:
|
|
757
|
+
declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
709
758
|
|
|
710
759
|
/**
|
|
711
760
|
* Iframe mount mode - mounts widgets in sandboxed iframes
|
|
@@ -731,11 +780,11 @@ declare const DEV_SANDBOX: string[];
|
|
|
731
780
|
/**
|
|
732
781
|
* Mount a widget in iframe mode (sandboxed)
|
|
733
782
|
*/
|
|
734
|
-
declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy:
|
|
783
|
+
declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
735
784
|
/**
|
|
736
785
|
* Hot reload an iframe widget
|
|
737
786
|
*/
|
|
738
|
-
declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy:
|
|
787
|
+
declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
|
|
739
788
|
/**
|
|
740
789
|
* Dispose the shared bridge (call on app shutdown)
|
|
741
790
|
*/
|
|
@@ -748,7 +797,7 @@ declare function disposeIframeBridge(): void;
|
|
|
748
797
|
/**
|
|
749
798
|
* Create a service proxy that calls the backend via HTTP
|
|
750
799
|
*/
|
|
751
|
-
declare function
|
|
800
|
+
declare function createHttpProxy(proxyUrl: string): Proxy;
|
|
752
801
|
/**
|
|
753
802
|
* Creates a proxy that enables fluent method chaining for dynamic field access.
|
|
754
803
|
*
|
|
@@ -776,7 +825,7 @@ declare function createFieldAccessProxy<T = unknown>(namespace: string, handler:
|
|
|
776
825
|
* // calls proxy.call('github', 'repos.list_for_user', [{ username: 'x' }])
|
|
777
826
|
* ```
|
|
778
827
|
*/
|
|
779
|
-
declare function generateNamespaceGlobals(services: string[], proxy:
|
|
828
|
+
declare function generateNamespaceGlobals(services: string[], proxy: Proxy): Record<string, unknown>;
|
|
780
829
|
/**
|
|
781
830
|
* Inject namespace globals into a window object
|
|
782
831
|
*/
|
|
@@ -799,7 +848,7 @@ declare class ParentBridge {
|
|
|
799
848
|
private pendingCalls;
|
|
800
849
|
private iframes;
|
|
801
850
|
private messageHandler;
|
|
802
|
-
constructor(proxy:
|
|
851
|
+
constructor(proxy: Proxy);
|
|
803
852
|
/**
|
|
804
853
|
* Register an iframe to receive messages from
|
|
805
854
|
*/
|
|
@@ -822,7 +871,7 @@ declare class ParentBridge {
|
|
|
822
871
|
*
|
|
823
872
|
* Creates a service proxy that sends postMessage to parent.
|
|
824
873
|
*/
|
|
825
|
-
declare function
|
|
874
|
+
declare function createIframeProxy(): Proxy;
|
|
826
875
|
/**
|
|
827
876
|
* Generate the bridge script to inject into iframes
|
|
828
877
|
*
|
|
@@ -832,4 +881,4 @@ declare function createIframeServiceProxy(): ServiceProxy;
|
|
|
832
881
|
*/
|
|
833
882
|
declare function generateIframeBridgeScript(services: string[]): string;
|
|
834
883
|
|
|
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
|
|
884
|
+
export { type BridgeMessage, type BridgeMessageType, type CdnTransformOptions, type ChangeRecord, type CompileOptions, CompileOptionsSchema, type CompiledWidget, type Compiler, type CompilerOptions, DEFAULT_CDN_BASE, 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 Proxy, type ServiceCallHandler, type ServiceCallPayload, type ServiceResultPayload, type VFSPluginOptions, VFSStore, type VFSStoreOptions, type VirtualFile, type VirtualProject, type WatchCallback, type WatchEventType, cdnTransformPlugin, createCompiler, createFieldAccessProxy, createHttpProxy, createIframeProxy, createImageRegistry, createProjectFromFiles, createSingleFileProject, detectMainFile, disposeIframeBridge, extractNamespaces, fetchPackageJson, generateIframeBridgeScript, generateImportMap, generateNamespaceGlobals, getCdnBaseUrl, getCommonExports, getImageRegistry, injectNamespaceGlobals, isBareImport, loadImage, matchAlias, mountEmbedded, mountIframe, parseImageConfig, parseImageSpec, parseImportPath, parseManifest, parsePackageSpec, reloadEmbedded, reloadIframe, removeNamespaceGlobals, resolveEntry, safeParseImageConfig, safeParseManifest, setCdnBaseUrl, toEsmShUrl, vfsPlugin };
|