@aprovan/patchwork-compiler 0.1.2-dev.6bd527d → 0.1.2-dev.78c0b14

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.d.cts CHANGED
@@ -17,7 +17,7 @@ interface VirtualProject {
17
17
  /**
18
18
  * Core types for the Patchwork compiler
19
19
  */
20
- type Platform = 'browser' | 'cli';
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: 'string' | 'number' | 'boolean' | 'object' | 'array';
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 = 'embedded' | 'iframe';
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?: 'esm' | 'cjs' | 'iife';
83
- jsx?: 'automatic' | 'transform' | 'preserve';
82
+ format?: "esm" | "cjs" | "iife";
83
+ jsx?: "automatic" | "transform" | "preserve";
84
84
  jsxFactory?: string;
85
85
  jsxFragment?: string;
86
86
  };
@@ -136,6 +136,12 @@ interface CompilerOptions {
136
136
  cdnBaseUrl?: string;
137
137
  /** Base URL for widget imports (default: same as cdnBaseUrl). Used for transforming imports in widget code. */
138
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>;
139
145
  }
140
146
  interface Compiler {
141
147
  /** Pre-load an image package */
@@ -157,7 +163,7 @@ interface Compiler {
157
163
  * The compiler provides the interface; actual implementation (e.g., UTCP, MCP)
158
164
  * is handled by the runtime/backend.
159
165
  */
160
- interface ServiceProxy {
166
+ interface Proxy {
161
167
  call(namespace: string, procedure: string, args: unknown[]): Promise<unknown>;
162
168
  }
163
169
  /**
@@ -178,7 +184,7 @@ interface GlobalInterfaceDefinition {
178
184
  /** Optional TypeScript type definitions for methods */
179
185
  types?: string;
180
186
  }
181
- type BridgeMessageType = 'service-call' | 'service-result' | 'error';
187
+ type BridgeMessageType = "service-call" | "service-result" | "error";
182
188
  interface BridgeMessage {
183
189
  type: BridgeMessageType;
184
190
  id: string;
@@ -216,15 +222,15 @@ declare const EsbuildConfigSchema: z.ZodOptional<z.ZodObject<{
216
222
  jsxFactory: z.ZodOptional<z.ZodString>;
217
223
  jsxFragment: z.ZodOptional<z.ZodString>;
218
224
  }, "strict", z.ZodTypeAny, {
219
- jsx?: "automatic" | "transform" | "preserve" | undefined;
220
225
  target?: string | undefined;
221
226
  format?: "esm" | "cjs" | "iife" | undefined;
227
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
222
228
  jsxFactory?: string | undefined;
223
229
  jsxFragment?: string | undefined;
224
230
  }, {
225
- jsx?: "automatic" | "transform" | "preserve" | undefined;
226
231
  target?: string | undefined;
227
232
  format?: "esm" | "cjs" | "iife" | undefined;
233
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
228
234
  jsxFactory?: string | undefined;
229
235
  jsxFragment?: string | undefined;
230
236
  }>>;
@@ -238,15 +244,15 @@ declare const ImageConfigSchema: z.ZodObject<{
238
244
  jsxFactory: z.ZodOptional<z.ZodString>;
239
245
  jsxFragment: z.ZodOptional<z.ZodString>;
240
246
  }, "strict", z.ZodTypeAny, {
241
- jsx?: "automatic" | "transform" | "preserve" | undefined;
242
247
  target?: string | undefined;
243
248
  format?: "esm" | "cjs" | "iife" | undefined;
249
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
244
250
  jsxFactory?: string | undefined;
245
251
  jsxFragment?: string | undefined;
246
252
  }, {
247
- jsx?: "automatic" | "transform" | "preserve" | undefined;
248
253
  target?: string | undefined;
249
254
  format?: "esm" | "cjs" | "iife" | undefined;
255
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
250
256
  jsxFactory?: string | undefined;
251
257
  jsxFragment?: string | undefined;
252
258
  }>>;
@@ -268,9 +274,9 @@ declare const ImageConfigSchema: z.ZodObject<{
268
274
  platform: "browser" | "cli";
269
275
  dependencies?: Record<string, string> | undefined;
270
276
  esbuild?: {
271
- jsx?: "automatic" | "transform" | "preserve" | undefined;
272
277
  target?: string | undefined;
273
278
  format?: "esm" | "cjs" | "iife" | undefined;
279
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
274
280
  jsxFactory?: string | undefined;
275
281
  jsxFragment?: string | undefined;
276
282
  } | undefined;
@@ -284,9 +290,9 @@ declare const ImageConfigSchema: z.ZodObject<{
284
290
  platform: "browser" | "cli";
285
291
  dependencies?: Record<string, string> | undefined;
286
292
  esbuild?: {
287
- jsx?: "automatic" | "transform" | "preserve" | undefined;
288
293
  target?: string | undefined;
289
294
  format?: "esm" | "cjs" | "iife" | undefined;
295
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
290
296
  jsxFactory?: string | undefined;
291
297
  jsxFragment?: string | undefined;
292
298
  } | undefined;
@@ -416,19 +422,65 @@ declare const DEFAULT_IMAGE_CONFIG: ImageConfig;
416
422
  declare const DEFAULT_CLI_IMAGE_CONFIG: ImageConfig;
417
423
 
418
424
  /**
419
- * Image loader - fetches and loads image packages from CDN or local
425
+ * Shared CDN configuration for the patchwork compiler
420
426
  *
421
- * Images must be installed as npm packages or available on CDN.
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)
422
431
  */
423
-
432
+ declare const DEFAULT_CDN_BASE = "https://esm.sh";
424
433
  /**
425
- * Set the CDN base URL for image loading
434
+ * Set the CDN base URL for all CDN operations
426
435
  */
427
436
  declare function setCdnBaseUrl(url: string): void;
428
437
  /**
429
438
  * Get the current CDN base URL
430
439
  */
431
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
+
432
484
  interface ImagePackageJson {
433
485
  name: string;
434
486
  version: string;
@@ -438,6 +490,7 @@ interface ImagePackageJson {
438
490
  }
439
491
  /**
440
492
  * Parse image specifier into name and version
493
+ * (Alias of parsePackageSpec for image-specific usage)
441
494
  */
442
495
  declare function parseImageSpec(spec: string): {
443
496
  name: string;
@@ -625,7 +678,7 @@ interface HttpBackendConfig {
625
678
  baseUrl: string;
626
679
  }
627
680
  /**
628
- * HTTP-based FSProvider for connecting to remote servers (e.g., stitchery)
681
+ * HTTP-based FSProvider for connecting to remote VFS servers
629
682
  */
630
683
  declare class HttpBackend implements FSProvider {
631
684
  private config;
@@ -679,6 +732,7 @@ declare class VFSStore {
679
732
  listFiles(prefix?: string): Promise<string[]>;
680
733
  loadProject(id: string): Promise<VirtualProject | null>;
681
734
  saveProject(project: VirtualProject): Promise<void>;
735
+ watch(path: string, callback: WatchCallback): () => void;
682
736
  sync(): Promise<SyncResult>;
683
737
  on<T extends SyncEventType>(event: T, callback: SyncEventCallback<T extends "change" ? ChangeRecord : T extends "conflict" ? ConflictRecord : T extends "error" ? Error : SyncStatus>): () => void;
684
738
  private remotePath;
@@ -694,11 +748,11 @@ declare class VFSStore {
694
748
  /**
695
749
  * Mount a widget in embedded mode (direct DOM injection)
696
750
  */
697
- declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
751
+ declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
698
752
  /**
699
753
  * Hot reload an embedded widget
700
754
  */
701
- declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
755
+ declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
702
756
 
703
757
  /**
704
758
  * Iframe mount mode - mounts widgets in sandboxed iframes
@@ -724,11 +778,11 @@ declare const DEV_SANDBOX: string[];
724
778
  /**
725
779
  * Mount a widget in iframe mode (sandboxed)
726
780
  */
727
- declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
781
+ declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
728
782
  /**
729
783
  * Hot reload an iframe widget
730
784
  */
731
- declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
785
+ declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
732
786
  /**
733
787
  * Dispose the shared bridge (call on app shutdown)
734
788
  */
@@ -741,7 +795,7 @@ declare function disposeIframeBridge(): void;
741
795
  /**
742
796
  * Create a service proxy that calls the backend via HTTP
743
797
  */
744
- declare function createHttpServiceProxy(proxyUrl: string): ServiceProxy;
798
+ declare function createHttpProxy(proxyUrl: string): Proxy;
745
799
  /**
746
800
  * Creates a proxy that enables fluent method chaining for dynamic field access.
747
801
  *
@@ -769,7 +823,7 @@ declare function createFieldAccessProxy<T = unknown>(namespace: string, handler:
769
823
  * // calls proxy.call('github', 'repos.list_for_user', [{ username: 'x' }])
770
824
  * ```
771
825
  */
772
- declare function generateNamespaceGlobals(services: string[], proxy: ServiceProxy): Record<string, unknown>;
826
+ declare function generateNamespaceGlobals(services: string[], proxy: Proxy): Record<string, unknown>;
773
827
  /**
774
828
  * Inject namespace globals into a window object
775
829
  */
@@ -792,7 +846,7 @@ declare class ParentBridge {
792
846
  private pendingCalls;
793
847
  private iframes;
794
848
  private messageHandler;
795
- constructor(proxy: ServiceProxy);
849
+ constructor(proxy: Proxy);
796
850
  /**
797
851
  * Register an iframe to receive messages from
798
852
  */
@@ -815,7 +869,7 @@ declare class ParentBridge {
815
869
  *
816
870
  * Creates a service proxy that sends postMessage to parent.
817
871
  */
818
- declare function createIframeServiceProxy(): ServiceProxy;
872
+ declare function createIframeProxy(): Proxy;
819
873
  /**
820
874
  * Generate the bridge script to inject into iframes
821
875
  *
@@ -825,4 +879,4 @@ declare function createIframeServiceProxy(): ServiceProxy;
825
879
  */
826
880
  declare function generateIframeBridgeScript(services: string[]): string;
827
881
 
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 };
882
+ 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 = 'browser' | 'cli';
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: 'string' | 'number' | 'boolean' | 'object' | 'array';
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 = 'embedded' | 'iframe';
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?: 'esm' | 'cjs' | 'iife';
83
- jsx?: 'automatic' | 'transform' | 'preserve';
82
+ format?: "esm" | "cjs" | "iife";
83
+ jsx?: "automatic" | "transform" | "preserve";
84
84
  jsxFactory?: string;
85
85
  jsxFragment?: string;
86
86
  };
@@ -136,6 +136,12 @@ interface CompilerOptions {
136
136
  cdnBaseUrl?: string;
137
137
  /** Base URL for widget imports (default: same as cdnBaseUrl). Used for transforming imports in widget code. */
138
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>;
139
145
  }
140
146
  interface Compiler {
141
147
  /** Pre-load an image package */
@@ -157,7 +163,7 @@ interface Compiler {
157
163
  * The compiler provides the interface; actual implementation (e.g., UTCP, MCP)
158
164
  * is handled by the runtime/backend.
159
165
  */
160
- interface ServiceProxy {
166
+ interface Proxy {
161
167
  call(namespace: string, procedure: string, args: unknown[]): Promise<unknown>;
162
168
  }
163
169
  /**
@@ -178,7 +184,7 @@ interface GlobalInterfaceDefinition {
178
184
  /** Optional TypeScript type definitions for methods */
179
185
  types?: string;
180
186
  }
181
- type BridgeMessageType = 'service-call' | 'service-result' | 'error';
187
+ type BridgeMessageType = "service-call" | "service-result" | "error";
182
188
  interface BridgeMessage {
183
189
  type: BridgeMessageType;
184
190
  id: string;
@@ -216,15 +222,15 @@ declare const EsbuildConfigSchema: z.ZodOptional<z.ZodObject<{
216
222
  jsxFactory: z.ZodOptional<z.ZodString>;
217
223
  jsxFragment: z.ZodOptional<z.ZodString>;
218
224
  }, "strict", z.ZodTypeAny, {
219
- jsx?: "automatic" | "transform" | "preserve" | undefined;
220
225
  target?: string | undefined;
221
226
  format?: "esm" | "cjs" | "iife" | undefined;
227
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
222
228
  jsxFactory?: string | undefined;
223
229
  jsxFragment?: string | undefined;
224
230
  }, {
225
- jsx?: "automatic" | "transform" | "preserve" | undefined;
226
231
  target?: string | undefined;
227
232
  format?: "esm" | "cjs" | "iife" | undefined;
233
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
228
234
  jsxFactory?: string | undefined;
229
235
  jsxFragment?: string | undefined;
230
236
  }>>;
@@ -238,15 +244,15 @@ declare const ImageConfigSchema: z.ZodObject<{
238
244
  jsxFactory: z.ZodOptional<z.ZodString>;
239
245
  jsxFragment: z.ZodOptional<z.ZodString>;
240
246
  }, "strict", z.ZodTypeAny, {
241
- jsx?: "automatic" | "transform" | "preserve" | undefined;
242
247
  target?: string | undefined;
243
248
  format?: "esm" | "cjs" | "iife" | undefined;
249
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
244
250
  jsxFactory?: string | undefined;
245
251
  jsxFragment?: string | undefined;
246
252
  }, {
247
- jsx?: "automatic" | "transform" | "preserve" | undefined;
248
253
  target?: string | undefined;
249
254
  format?: "esm" | "cjs" | "iife" | undefined;
255
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
250
256
  jsxFactory?: string | undefined;
251
257
  jsxFragment?: string | undefined;
252
258
  }>>;
@@ -268,9 +274,9 @@ declare const ImageConfigSchema: z.ZodObject<{
268
274
  platform: "browser" | "cli";
269
275
  dependencies?: Record<string, string> | undefined;
270
276
  esbuild?: {
271
- jsx?: "automatic" | "transform" | "preserve" | undefined;
272
277
  target?: string | undefined;
273
278
  format?: "esm" | "cjs" | "iife" | undefined;
279
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
274
280
  jsxFactory?: string | undefined;
275
281
  jsxFragment?: string | undefined;
276
282
  } | undefined;
@@ -284,9 +290,9 @@ declare const ImageConfigSchema: z.ZodObject<{
284
290
  platform: "browser" | "cli";
285
291
  dependencies?: Record<string, string> | undefined;
286
292
  esbuild?: {
287
- jsx?: "automatic" | "transform" | "preserve" | undefined;
288
293
  target?: string | undefined;
289
294
  format?: "esm" | "cjs" | "iife" | undefined;
295
+ jsx?: "automatic" | "transform" | "preserve" | undefined;
290
296
  jsxFactory?: string | undefined;
291
297
  jsxFragment?: string | undefined;
292
298
  } | undefined;
@@ -416,19 +422,65 @@ declare const DEFAULT_IMAGE_CONFIG: ImageConfig;
416
422
  declare const DEFAULT_CLI_IMAGE_CONFIG: ImageConfig;
417
423
 
418
424
  /**
419
- * Image loader - fetches and loads image packages from CDN or local
425
+ * Shared CDN configuration for the patchwork compiler
420
426
  *
421
- * Images must be installed as npm packages or available on CDN.
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)
422
431
  */
423
-
432
+ declare const DEFAULT_CDN_BASE = "https://esm.sh";
424
433
  /**
425
- * Set the CDN base URL for image loading
434
+ * Set the CDN base URL for all CDN operations
426
435
  */
427
436
  declare function setCdnBaseUrl(url: string): void;
428
437
  /**
429
438
  * Get the current CDN base URL
430
439
  */
431
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
+
432
484
  interface ImagePackageJson {
433
485
  name: string;
434
486
  version: string;
@@ -438,6 +490,7 @@ interface ImagePackageJson {
438
490
  }
439
491
  /**
440
492
  * Parse image specifier into name and version
493
+ * (Alias of parsePackageSpec for image-specific usage)
441
494
  */
442
495
  declare function parseImageSpec(spec: string): {
443
496
  name: string;
@@ -625,7 +678,7 @@ interface HttpBackendConfig {
625
678
  baseUrl: string;
626
679
  }
627
680
  /**
628
- * HTTP-based FSProvider for connecting to remote servers (e.g., stitchery)
681
+ * HTTP-based FSProvider for connecting to remote VFS servers
629
682
  */
630
683
  declare class HttpBackend implements FSProvider {
631
684
  private config;
@@ -679,6 +732,7 @@ declare class VFSStore {
679
732
  listFiles(prefix?: string): Promise<string[]>;
680
733
  loadProject(id: string): Promise<VirtualProject | null>;
681
734
  saveProject(project: VirtualProject): Promise<void>;
735
+ watch(path: string, callback: WatchCallback): () => void;
682
736
  sync(): Promise<SyncResult>;
683
737
  on<T extends SyncEventType>(event: T, callback: SyncEventCallback<T extends "change" ? ChangeRecord : T extends "conflict" ? ConflictRecord : T extends "error" ? Error : SyncStatus>): () => void;
684
738
  private remotePath;
@@ -694,11 +748,11 @@ declare class VFSStore {
694
748
  /**
695
749
  * Mount a widget in embedded mode (direct DOM injection)
696
750
  */
697
- declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
751
+ declare function mountEmbedded(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
698
752
  /**
699
753
  * Hot reload an embedded widget
700
754
  */
701
- declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
755
+ declare function reloadEmbedded(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
702
756
 
703
757
  /**
704
758
  * Iframe mount mode - mounts widgets in sandboxed iframes
@@ -724,11 +778,11 @@ declare const DEV_SANDBOX: string[];
724
778
  /**
725
779
  * Mount a widget in iframe mode (sandboxed)
726
780
  */
727
- declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
781
+ declare function mountIframe(widget: CompiledWidget, options: MountOptions, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
728
782
  /**
729
783
  * Hot reload an iframe widget
730
784
  */
731
- declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: ServiceProxy): Promise<MountedWidget>;
785
+ declare function reloadIframe(mounted: MountedWidget, widget: CompiledWidget, image: LoadedImage | null, proxy: Proxy): Promise<MountedWidget>;
732
786
  /**
733
787
  * Dispose the shared bridge (call on app shutdown)
734
788
  */
@@ -741,7 +795,7 @@ declare function disposeIframeBridge(): void;
741
795
  /**
742
796
  * Create a service proxy that calls the backend via HTTP
743
797
  */
744
- declare function createHttpServiceProxy(proxyUrl: string): ServiceProxy;
798
+ declare function createHttpProxy(proxyUrl: string): Proxy;
745
799
  /**
746
800
  * Creates a proxy that enables fluent method chaining for dynamic field access.
747
801
  *
@@ -769,7 +823,7 @@ declare function createFieldAccessProxy<T = unknown>(namespace: string, handler:
769
823
  * // calls proxy.call('github', 'repos.list_for_user', [{ username: 'x' }])
770
824
  * ```
771
825
  */
772
- declare function generateNamespaceGlobals(services: string[], proxy: ServiceProxy): Record<string, unknown>;
826
+ declare function generateNamespaceGlobals(services: string[], proxy: Proxy): Record<string, unknown>;
773
827
  /**
774
828
  * Inject namespace globals into a window object
775
829
  */
@@ -792,7 +846,7 @@ declare class ParentBridge {
792
846
  private pendingCalls;
793
847
  private iframes;
794
848
  private messageHandler;
795
- constructor(proxy: ServiceProxy);
849
+ constructor(proxy: Proxy);
796
850
  /**
797
851
  * Register an iframe to receive messages from
798
852
  */
@@ -815,7 +869,7 @@ declare class ParentBridge {
815
869
  *
816
870
  * Creates a service proxy that sends postMessage to parent.
817
871
  */
818
- declare function createIframeServiceProxy(): ServiceProxy;
872
+ declare function createIframeProxy(): Proxy;
819
873
  /**
820
874
  * Generate the bridge script to inject into iframes
821
875
  *
@@ -825,4 +879,4 @@ declare function createIframeServiceProxy(): ServiceProxy;
825
879
  */
826
880
  declare function generateIframeBridgeScript(services: string[]): string;
827
881
 
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 };
882
+ 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 };