pulse-js-framework 1.11.2 → 1.11.4

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.
Files changed (48) hide show
  1. package/cli/analyze.js +21 -8
  2. package/cli/build.js +83 -56
  3. package/cli/dev.js +108 -94
  4. package/cli/docs-test.js +52 -33
  5. package/cli/index.js +81 -51
  6. package/cli/mobile.js +92 -40
  7. package/cli/release.js +64 -46
  8. package/cli/scaffold.js +14 -13
  9. package/compiler/lexer.js +55 -54
  10. package/compiler/parser/core.js +1 -0
  11. package/compiler/parser/state.js +6 -12
  12. package/compiler/parser/style.js +17 -20
  13. package/compiler/parser/view.js +1 -3
  14. package/compiler/preprocessor.js +124 -262
  15. package/compiler/sourcemap.js +10 -4
  16. package/compiler/transformer/expressions.js +122 -106
  17. package/compiler/transformer/index.js +2 -4
  18. package/compiler/transformer/style.js +74 -7
  19. package/compiler/transformer/view.js +86 -36
  20. package/loader/esbuild-plugin-server-components.js +209 -0
  21. package/loader/esbuild-plugin.js +41 -93
  22. package/loader/parcel-plugin.js +37 -97
  23. package/loader/rollup-plugin-server-components.js +30 -169
  24. package/loader/rollup-plugin.js +27 -78
  25. package/loader/shared.js +362 -0
  26. package/loader/swc-plugin.js +65 -82
  27. package/loader/vite-plugin-server-components.js +30 -171
  28. package/loader/vite-plugin.js +25 -10
  29. package/loader/webpack-loader-server-components.js +21 -134
  30. package/loader/webpack-loader.js +25 -80
  31. package/package.json +52 -12
  32. package/runtime/dom-selector.js +2 -1
  33. package/runtime/form.js +4 -3
  34. package/runtime/http.js +6 -1
  35. package/runtime/logger.js +44 -24
  36. package/runtime/router/utils.js +14 -7
  37. package/runtime/security.js +13 -1
  38. package/runtime/server-components/actions-server.js +23 -19
  39. package/runtime/server-components/error-sanitizer.js +18 -18
  40. package/runtime/server-components/security.js +41 -24
  41. package/runtime/ssr-preload.js +5 -3
  42. package/runtime/testing.js +759 -0
  43. package/runtime/utils.js +3 -2
  44. package/server/utils.js +15 -9
  45. package/sw/index.js +2 -0
  46. package/types/loaders.d.ts +1043 -0
  47. package/compiler/parser/_extract.js +0 -393
  48. package/loader/README.md +0 -509
@@ -0,0 +1,1043 @@
1
+ /**
2
+ * Pulse Framework - Build Tool Loader / Plugin Type Definitions
3
+ * @module pulse-js-framework/loaders
4
+ */
5
+
6
+ // ============================================================================
7
+ // Shared Option Types
8
+ // ============================================================================
9
+
10
+ /**
11
+ * Options for SASS/SCSS compilation within style blocks.
12
+ * Requires `sass` to be installed as a dev dependency.
13
+ */
14
+ export interface SassOptions {
15
+ /** Additional directories to search when resolving @use / @import (default: []) */
16
+ loadPaths?: string[];
17
+
18
+ /** Produce compressed (minified) CSS output (default: false) */
19
+ compressed?: boolean;
20
+
21
+ /** Log a message each time SASS compiles a file (default: false) */
22
+ verbose?: boolean;
23
+ }
24
+
25
+ /**
26
+ * Options for LESS compilation within style blocks.
27
+ * Requires `less` to be installed as a dev dependency.
28
+ */
29
+ export interface LessOptions {
30
+ /** Additional directories to search when resolving @import (default: []) */
31
+ paths?: string[];
32
+
33
+ /** Produce compressed (minified) CSS output (default: false) */
34
+ compress?: boolean;
35
+
36
+ /** Log a message each time LESS compiles a file (default: false) */
37
+ verbose?: boolean;
38
+ }
39
+
40
+ /**
41
+ * Options for Stylus compilation within style blocks.
42
+ * Requires `stylus` to be installed as a dev dependency.
43
+ */
44
+ export interface StylusOptions {
45
+ /** Additional directories to search when resolving @import (default: []) */
46
+ paths?: string[];
47
+
48
+ /** Produce compressed (minified) CSS output (default: false) */
49
+ compress?: boolean;
50
+
51
+ /** Log a message each time Stylus compiles a file (default: false) */
52
+ verbose?: boolean;
53
+ }
54
+
55
+ /**
56
+ * CSS preprocessor options shared by most loader plugins.
57
+ */
58
+ export interface PreprocessorOptions {
59
+ /** Options forwarded to the SASS/SCSS compiler (optional, requires `sass`) */
60
+ sass?: SassOptions;
61
+
62
+ /** Options forwarded to the LESS compiler (optional, requires `less`) */
63
+ less?: LessOptions;
64
+
65
+ /** Options forwarded to the Stylus compiler (optional, requires `stylus`) */
66
+ stylus?: StylusOptions;
67
+ }
68
+
69
+ /**
70
+ * Shared options accepted by every Pulse build-tool plugin.
71
+ */
72
+ export interface BasePulsePluginOptions extends PreprocessorOptions {
73
+ /**
74
+ * Whether to emit a V3 source map alongside the compiled JavaScript.
75
+ * @default true
76
+ */
77
+ sourceMap?: boolean;
78
+
79
+ /**
80
+ * Suppress all informational log output (errors and warnings are still shown).
81
+ * Useful for CI environments and test runs.
82
+ * @default false
83
+ */
84
+ quiet?: boolean;
85
+ }
86
+
87
+ // ============================================================================
88
+ // Vite – 'pulse-js-framework/vite'
89
+ // ============================================================================
90
+
91
+ /**
92
+ * Options for the Pulse Vite plugin.
93
+ */
94
+ export interface VitePluginOptions extends BasePulsePluginOptions {
95
+ /**
96
+ * Pattern of module IDs to exclude from transformation.
97
+ * @default /node_modules/
98
+ */
99
+ exclude?: RegExp;
100
+ }
101
+
102
+ /**
103
+ * Additional utility helpers exported alongside the Vite plugin.
104
+ */
105
+ export interface VitePluginUtils {
106
+ /**
107
+ * Return true when `id` is a `.pulse` file path.
108
+ * @param id - Module ID / file path to test
109
+ */
110
+ isPulseFile(id: string): boolean;
111
+
112
+ /**
113
+ * Derive the output `.js` filename from a `.pulse` file path.
114
+ * @param id - `.pulse` file path
115
+ */
116
+ getOutputFilename(id: string): string;
117
+
118
+ /**
119
+ * Return the virtual CSS module ID that Vite uses for the styles extracted
120
+ * from a given `.pulse` file.
121
+ * @param id - `.pulse` file path
122
+ */
123
+ getVirtualCssId(id: string): string;
124
+ }
125
+
126
+ declare module 'pulse-js-framework/vite' {
127
+ /**
128
+ * Create the Pulse Vite plugin.
129
+ *
130
+ * Transforms `.pulse` files to JavaScript and routes their `style` blocks
131
+ * through Vite's CSS pipeline via a virtual CSS module.
132
+ * SASS/SCSS is compiled automatically when `sass` is installed.
133
+ *
134
+ * @param options - Plugin configuration
135
+ * @returns Vite plugin object
136
+ *
137
+ * @example
138
+ * // vite.config.js
139
+ * import { defineConfig } from 'vite';
140
+ * import pulsePlugin from 'pulse-js-framework/vite';
141
+ *
142
+ * export default defineConfig({
143
+ * plugins: [
144
+ * pulsePlugin({ sourceMap: true })
145
+ * ]
146
+ * });
147
+ */
148
+ export default function pulsePlugin(options?: VitePluginOptions): object;
149
+
150
+ /**
151
+ * HMR runtime snippet (string of JavaScript).
152
+ *
153
+ * Injected into `.pulse` module output in development to enable hot
154
+ * module replacement via `import.meta.hot`.
155
+ *
156
+ * @example
157
+ * import { hmrRuntime } from 'pulse-js-framework/vite';
158
+ * // hmrRuntime is a JS string; concatenate it into your build output if needed
159
+ */
160
+ export const hmrRuntime: string;
161
+
162
+ /**
163
+ * Utility helpers for working with `.pulse` paths in custom Vite integrations.
164
+ */
165
+ export const utils: VitePluginUtils;
166
+ }
167
+
168
+ // ============================================================================
169
+ // Webpack – 'pulse-js-framework/webpack'
170
+ // ============================================================================
171
+
172
+ /**
173
+ * Options recognised by the Pulse Webpack loader (passed via `options:` in
174
+ * the rule or `getOptions()`).
175
+ */
176
+ export interface WebpackLoaderOptions extends BasePulsePluginOptions {
177
+ /**
178
+ * When `true` (default), emit the extracted CSS as a sidecar `.pulse.css`
179
+ * file for downstream loaders (e.g. `css-loader` + `style-loader`).
180
+ * When `false`, CSS injection is kept inline in the JS output.
181
+ * @default true
182
+ */
183
+ extractCss?: boolean;
184
+
185
+ /**
186
+ * Enable Webpack Hot Module Replacement support.
187
+ * @default true
188
+ */
189
+ hmr?: boolean;
190
+
191
+ /**
192
+ * Print preprocessor version info at startup.
193
+ * @default true
194
+ */
195
+ verbose?: boolean;
196
+ }
197
+
198
+ /**
199
+ * Result object returned to Webpack after the pitch phase.
200
+ * The pitch loader has no meaningful return value but is typed for
201
+ * compatibility with Webpack's loader interface.
202
+ */
203
+ export type WebpackPitchResult = string | Buffer | undefined;
204
+
205
+ declare module 'pulse-js-framework/webpack' {
206
+ /**
207
+ * Pulse Webpack loader function.
208
+ *
209
+ * Add to your `module.rules` array:
210
+ *
211
+ * @example
212
+ * // webpack.config.js
213
+ * module.exports = {
214
+ * module: {
215
+ * rules: [
216
+ * {
217
+ * test: /\.pulse$/,
218
+ * use: [
219
+ * 'style-loader',
220
+ * 'css-loader',
221
+ * 'pulse-js-framework/webpack'
222
+ * ]
223
+ * }
224
+ * ]
225
+ * }
226
+ * };
227
+ *
228
+ * @param source - Raw `.pulse` file contents
229
+ */
230
+ export default function pulseLoader(this: object, source: string): void;
231
+
232
+ /**
233
+ * Pitch phase loader – runs before the normal loader chain.
234
+ * Logs preprocessor availability on the first invocation.
235
+ */
236
+ export function pitch(this: object): WebpackPitchResult;
237
+
238
+ /**
239
+ * `false` – instructs Webpack to pass the source as a `string`, not a
240
+ * `Buffer`. Required for any loader that processes text.
241
+ */
242
+ export const raw: false;
243
+ }
244
+
245
+ // ============================================================================
246
+ // Rollup – 'pulse-js-framework/rollup'
247
+ // ============================================================================
248
+
249
+ /**
250
+ * Options for the Pulse Rollup plugin.
251
+ */
252
+ export interface RollupPluginOptions extends BasePulsePluginOptions {
253
+ /**
254
+ * Glob / RegExp / string[] pattern of files to include.
255
+ * @default /\.pulse$/
256
+ */
257
+ include?: RegExp | string | string[];
258
+
259
+ /**
260
+ * Glob / RegExp / string[] pattern of files to exclude.
261
+ * @default /node_modules/
262
+ */
263
+ exclude?: RegExp | string | string[];
264
+
265
+ /**
266
+ * File path for the emitted CSS bundle, relative to Rollup's `output.dir`.
267
+ * When `null`, style injection remains inline in the compiled JS.
268
+ * @default null
269
+ */
270
+ extractCss?: string | null;
271
+ }
272
+
273
+ declare module 'pulse-js-framework/rollup' {
274
+ /**
275
+ * Create the Pulse Rollup plugin.
276
+ *
277
+ * Transforms `.pulse` files to JavaScript. Styles can be accumulated and
278
+ * emitted as a single CSS asset via the `extractCss` option.
279
+ *
280
+ * @param options - Plugin configuration
281
+ * @returns Rollup plugin object
282
+ *
283
+ * @example
284
+ * // rollup.config.js
285
+ * import pulsePlugin from 'pulse-js-framework/rollup';
286
+ *
287
+ * export default {
288
+ * input: 'src/main.js',
289
+ * output: { file: 'dist/bundle.js', format: 'es' },
290
+ * plugins: [
291
+ * pulsePlugin({
292
+ * sourceMap: true,
293
+ * extractCss: 'dist/bundle.css',
294
+ * sass: { loadPaths: ['src/styles'] }
295
+ * })
296
+ * ]
297
+ * };
298
+ */
299
+ export default function pulsePlugin(options?: RollupPluginOptions): object;
300
+ }
301
+
302
+ // ============================================================================
303
+ // ESBuild – 'pulse-js-framework/esbuild'
304
+ // ============================================================================
305
+
306
+ /**
307
+ * Options for the Pulse ESBuild plugin.
308
+ */
309
+ export interface EsbuildPluginOptions extends BasePulsePluginOptions {
310
+ /**
311
+ * File path for the emitted CSS bundle.
312
+ * When `null`, style injection remains inline in the compiled JS.
313
+ * @default null
314
+ */
315
+ extractCss?: string | null;
316
+ }
317
+
318
+ declare module 'pulse-js-framework/esbuild' {
319
+ /**
320
+ * Create the Pulse ESBuild plugin.
321
+ *
322
+ * Registers an `onLoad` handler for `.pulse` files so ESBuild can include
323
+ * them in the bundle. Collected CSS is written to disk via an `onEnd` hook.
324
+ *
325
+ * @param options - Plugin configuration
326
+ * @returns ESBuild plugin object (`{ name, setup }`)
327
+ *
328
+ * @example
329
+ * // build.js
330
+ * import * as esbuild from 'esbuild';
331
+ * import pulsePlugin from 'pulse-js-framework/esbuild';
332
+ *
333
+ * await esbuild.build({
334
+ * entryPoints: ['src/main.js'],
335
+ * bundle: true,
336
+ * outfile: 'dist/bundle.js',
337
+ * plugins: [
338
+ * pulsePlugin({
339
+ * sourceMap: true,
340
+ * extractCss: 'dist/bundle.css'
341
+ * })
342
+ * ]
343
+ * });
344
+ */
345
+ export default function pulsePlugin(options?: EsbuildPluginOptions): object;
346
+ }
347
+
348
+ // ============================================================================
349
+ // Parcel – 'pulse-js-framework/parcel'
350
+ // ============================================================================
351
+
352
+ /**
353
+ * Logger object supplied by Parcel to transformer functions.
354
+ */
355
+ export interface ParcelLogger {
356
+ info(opts: { message: string }): void;
357
+ warn(opts: { message: string; filePath?: string }): void;
358
+ verbose(opts: { message: string }): void;
359
+ }
360
+
361
+ /**
362
+ * Asset object supplied by Parcel to transformer functions.
363
+ * Only the properties used by the Pulse transformer are typed here.
364
+ */
365
+ export interface ParcelAsset {
366
+ /** Absolute path to the source file */
367
+ filePath: string;
368
+
369
+ /** The current asset MIME type (e.g. `'js'`, `'css'`) */
370
+ type: string;
371
+
372
+ /** Read the asset's source code */
373
+ getCode(): Promise<string>;
374
+
375
+ /** Write compiled code back into the asset */
376
+ setCode(code: string): void;
377
+
378
+ /** Attach a source map to the asset */
379
+ setMap(map: object): void;
380
+
381
+ /**
382
+ * Load a config file for this asset (searches for `.pulserc`, `.pulserc.json`,
383
+ * or the `pulse` key in `package.json`).
384
+ */
385
+ getConfig(
386
+ filenames: string[],
387
+ opts?: { packageKey?: string }
388
+ ): Promise<ParcelTransformerConfig | null>;
389
+
390
+ /** Add a URL dependency (e.g. the sidecar CSS asset) */
391
+ addDependency(opts: { specifier: string; specifierType: string }): void;
392
+
393
+ /** Emit a child asset (e.g. extracted CSS) */
394
+ addAsset(opts: { type: string; content: string; uniqueKey: string }): Promise<void>;
395
+ }
396
+
397
+ /**
398
+ * Configuration object read from `.pulserc` / `.pulserc.json` / `package.json#pulse`.
399
+ */
400
+ export interface ParcelTransformerConfig extends BasePulsePluginOptions {
401
+ /**
402
+ * Whether to route extracted CSS through Parcel's CSS pipeline.
403
+ * @default true
404
+ */
405
+ extractCss?: boolean;
406
+
407
+ /**
408
+ * Print preprocessor version info at startup.
409
+ * @default false
410
+ */
411
+ verbose?: boolean;
412
+ }
413
+
414
+ /**
415
+ * The context object passed to `transformPulse`.
416
+ */
417
+ export interface ParcelTransformContext {
418
+ /** The Parcel asset being processed */
419
+ asset: ParcelAsset;
420
+
421
+ /** Parcel's structured logger */
422
+ logger: ParcelLogger;
423
+ }
424
+
425
+ declare module 'pulse-js-framework/parcel' {
426
+ /**
427
+ * Core Parcel transformer function.
428
+ *
429
+ * This is the function invoked by Parcel's `Transformer` API.
430
+ * It reads the asset source, compiles it, optionally preprocesses styles,
431
+ * and returns the transformed asset(s).
432
+ *
433
+ * Configuration is read from `.pulserc`, `.pulserc.json`, or the `pulse`
434
+ * key in `package.json`.
435
+ *
436
+ * @param context - `{ asset, logger }` supplied by Parcel
437
+ * @returns Array containing the (mutated) asset
438
+ *
439
+ * @example
440
+ * // .parcelrc
441
+ * {
442
+ * "extends": "@parcel/config-default",
443
+ * "transformers": {
444
+ * "*.pulse": ["pulse-js-framework/parcel"]
445
+ * }
446
+ * }
447
+ */
448
+ export function transformPulse(context: ParcelTransformContext): Promise<ParcelAsset[]>;
449
+
450
+ /**
451
+ * Default export – Parcel `Transformer`-compatible object with a `transform`
452
+ * method that delegates to `transformPulse`.
453
+ *
454
+ * @example
455
+ * import parcelPlugin from 'pulse-js-framework/parcel';
456
+ * // parcelPlugin.transform === transformPulse
457
+ */
458
+ const _default: {
459
+ transform: typeof transformPulse;
460
+ };
461
+ export default _default;
462
+ }
463
+
464
+ // ============================================================================
465
+ // SWC – 'pulse-js-framework/swc'
466
+ // ============================================================================
467
+
468
+ /**
469
+ * Options for the Pulse SWC plugin and standalone transform functions.
470
+ */
471
+ export interface SwcPluginOptions extends BasePulsePluginOptions {
472
+ /**
473
+ * File path for the emitted CSS bundle.
474
+ * When `null`, style injection remains inline in the compiled JS.
475
+ * @default null
476
+ */
477
+ extractCss?: string | null;
478
+ }
479
+
480
+ /**
481
+ * Result returned by the SWC plugin's `transform` method and the standalone
482
+ * `transformPulseFile` / `transformPulseCode` functions.
483
+ */
484
+ export interface SwcTransformResult {
485
+ /**
486
+ * Compiled JavaScript source, or `null` if compilation failed.
487
+ */
488
+ code: string | null;
489
+
490
+ /**
491
+ * V3 source map object, or `null` if source maps are disabled or unavailable.
492
+ */
493
+ map: object | null;
494
+
495
+ /**
496
+ * Extracted (and optionally preprocessed) CSS, or `null` when no `style`
497
+ * block was present in the source.
498
+ */
499
+ css: string | null;
500
+
501
+ /**
502
+ * Error message string if compilation failed, otherwise `null`.
503
+ */
504
+ error: string | null;
505
+ }
506
+
507
+ /**
508
+ * Result item returned by `buildPulseFiles` for each processed file.
509
+ */
510
+ export interface SwcBatchResult extends SwcTransformResult {
511
+ /** The original file path that was processed */
512
+ file: string;
513
+ }
514
+
515
+ /**
516
+ * The plugin instance returned by `pulsePlugin` (default export from swc).
517
+ */
518
+ export interface SwcPluginInstance {
519
+ /** Plugin name */
520
+ name: 'pulse';
521
+
522
+ /**
523
+ * Prepare the plugin for a new build: reset the accumulated CSS buffer and
524
+ * (on first call) log preprocessor availability.
525
+ */
526
+ buildStart(): void;
527
+
528
+ /**
529
+ * Compile a single `.pulse` source string.
530
+ *
531
+ * @param source - `.pulse` source code
532
+ * @param filePath - File path used in error messages and preprocessor resolution
533
+ * @returns Transform result
534
+ */
535
+ transform(source: string, filePath: string): SwcTransformResult;
536
+
537
+ /**
538
+ * Flush any accumulated CSS to disk.
539
+ * Call after all `transform` calls are complete.
540
+ */
541
+ buildEnd(): void;
542
+ }
543
+
544
+ declare module 'pulse-js-framework/swc' {
545
+ /**
546
+ * Create a Pulse SWC plugin instance.
547
+ *
548
+ * Returns a plugin object with `buildStart`, `transform`, and `buildEnd`
549
+ * methods that mirror the lifecycle of Rollup / ESBuild plugins so the
550
+ * same plugin can be integrated into any SWC-based pipeline.
551
+ *
552
+ * @param options - Plugin configuration
553
+ * @returns SWC plugin instance
554
+ *
555
+ * @example
556
+ * import pulsePlugin from 'pulse-js-framework/swc';
557
+ *
558
+ * const plugin = pulsePlugin({ extractCss: 'dist/bundle.css' });
559
+ * plugin.buildStart();
560
+ * const result = plugin.transform(source, 'src/App.pulse');
561
+ * plugin.buildEnd(); // Writes accumulated CSS
562
+ */
563
+ export default function pulsePlugin(options?: SwcPluginOptions): SwcPluginInstance;
564
+
565
+ /**
566
+ * Read a `.pulse` file from disk and compile it to JavaScript.
567
+ *
568
+ * This is a convenience wrapper around `transformPulseCode` that handles
569
+ * file I/O for you.
570
+ *
571
+ * @param filePath - Path to the `.pulse` file
572
+ * @param options - Plugin options (same as `pulsePlugin`)
573
+ * @returns Transform result
574
+ *
575
+ * @example
576
+ * import { transformPulseFile } from 'pulse-js-framework/swc';
577
+ *
578
+ * const { code, css, error } = transformPulseFile('src/App.pulse', {
579
+ * sourceMap: true
580
+ * });
581
+ */
582
+ export function transformPulseFile(
583
+ filePath: string,
584
+ options?: SwcPluginOptions
585
+ ): SwcTransformResult;
586
+
587
+ /**
588
+ * Compile a `.pulse` source string to JavaScript.
589
+ *
590
+ * @param source - `.pulse` source code
591
+ * @param options - Plugin options plus an optional `filename` for source maps
592
+ * @returns Transform result
593
+ *
594
+ * @example
595
+ * import { transformPulseCode } from 'pulse-js-framework/swc';
596
+ *
597
+ * const { code, css, error } = transformPulseCode(pulseSource, {
598
+ * filename: 'App.pulse',
599
+ * sourceMap: true
600
+ * });
601
+ */
602
+ export function transformPulseCode(
603
+ source: string,
604
+ options?: SwcPluginOptions & { filename?: string }
605
+ ): SwcTransformResult;
606
+
607
+ /**
608
+ * Compile multiple `.pulse` files in a single pass.
609
+ *
610
+ * Internally creates one plugin instance for the whole batch so CSS is
611
+ * accumulated and written to disk once at the end (when `extractCss` is set).
612
+ *
613
+ * @param files - Array of `.pulse` file paths
614
+ * @param options - Plugin options (same as `pulsePlugin`)
615
+ * @returns Array of per-file results
616
+ *
617
+ * @example
618
+ * import { buildPulseFiles } from 'pulse-js-framework/swc';
619
+ *
620
+ * const results = buildPulseFiles(
621
+ * ['src/App.pulse', 'src/Home.pulse'],
622
+ * { extractCss: 'dist/bundle.css' }
623
+ * );
624
+ */
625
+ export function buildPulseFiles(
626
+ files: string[],
627
+ options?: SwcPluginOptions
628
+ ): SwcBatchResult[];
629
+
630
+ /**
631
+ * Async variant of `transformPulseFile` that reads files non-blocking.
632
+ *
633
+ * @param filePath - Path to the `.pulse` file
634
+ * @param options - Plugin options
635
+ * @returns Promise resolving to transform result
636
+ */
637
+ export function transformPulseFileAsync(
638
+ filePath: string,
639
+ options?: SwcPluginOptions
640
+ ): Promise<SwcTransformResult>;
641
+
642
+ /**
643
+ * Async variant of `buildPulseFiles` that reads files non-blocking.
644
+ *
645
+ * @param files - Array of `.pulse` file paths
646
+ * @param options - Plugin options
647
+ * @returns Promise resolving to array of per-file results
648
+ */
649
+ export function buildPulseFilesAsync(
650
+ files: string[],
651
+ options?: SwcPluginOptions
652
+ ): Promise<SwcBatchResult[]>;
653
+ }
654
+
655
+ // ============================================================================
656
+ // Server Components shared types
657
+ // ============================================================================
658
+
659
+ /**
660
+ * A single entry in the client manifest produced by a Server Components plugin.
661
+ */
662
+ export interface ClientComponentManifestEntry {
663
+ /** URL / path to the chunk file that contains this component */
664
+ chunk: string | null;
665
+
666
+ /** Source file that defines this component */
667
+ file?: string;
668
+ }
669
+
670
+ /**
671
+ * The client manifest JSON written to disk by Server Components plugins.
672
+ */
673
+ export interface ClientManifest {
674
+ /** Manifest format version */
675
+ version: string;
676
+
677
+ /**
678
+ * Map of component IDs to their manifest entries.
679
+ * Keys are component IDs derived from export names / `__componentId`.
680
+ */
681
+ components: Record<string, ClientComponentManifestEntry>;
682
+ }
683
+
684
+ /**
685
+ * Options accepted by all three Server Components plugins (Vite / Webpack /
686
+ * Rollup).
687
+ */
688
+ export interface ServerComponentsPluginOptions {
689
+ /**
690
+ * File-system path where the JSON client manifest is written.
691
+ * @default 'dist/.pulse-manifest.json'
692
+ */
693
+ manifestPath?: string;
694
+
695
+ /**
696
+ * Public base URL prepended to chunk URLs inside the manifest.
697
+ * @default ''
698
+ */
699
+ base?: string;
700
+
701
+ /**
702
+ * Filename used when emitting the manifest as a bundle asset.
703
+ * @default '.pulse-manifest.json'
704
+ */
705
+ manifestFilename?: string;
706
+
707
+ /**
708
+ * Suppress all informational log output (errors and warnings are still shown).
709
+ * @default false
710
+ */
711
+ quiet?: boolean;
712
+ }
713
+
714
+ // ============================================================================
715
+ // Vite Server Components – 'pulse-js-framework/vite/server-components'
716
+ // ============================================================================
717
+
718
+ /**
719
+ * Options for the Vite Server Components plugin (extends the shared options).
720
+ */
721
+ export interface ViteServerComponentsPluginOptions extends ServerComponentsPluginOptions {
722
+ /**
723
+ * Whether to inject the client manifest into SSR HTML builds.
724
+ * @default true
725
+ */
726
+ injectManifest?: boolean;
727
+ }
728
+
729
+ declare module 'pulse-js-framework/vite/server-components' {
730
+ /**
731
+ * Create the Pulse Server Components Vite plugin.
732
+ *
733
+ * Should be used together with the main Pulse Vite plugin.
734
+ * Detects Client Components (marked via `'use client'` directive), splits
735
+ * them into separate chunks, generates a client manifest, and validates
736
+ * that Client Components do not import Server-only modules.
737
+ *
738
+ * @param options - Plugin configuration
739
+ * @returns Vite plugin object
740
+ *
741
+ * @example
742
+ * // vite.config.js
743
+ * import pulsePlugin from 'pulse-js-framework/vite';
744
+ * import pulseServerComponents from 'pulse-js-framework/vite/server-components';
745
+ *
746
+ * export default {
747
+ * plugins: [
748
+ * pulsePlugin(),
749
+ * pulseServerComponents()
750
+ * ]
751
+ * };
752
+ */
753
+ export default function pulseServerComponentsPlugin(
754
+ options?: ViteServerComponentsPluginOptions
755
+ ): object;
756
+
757
+ /**
758
+ * Load the client manifest from disk (for use in the SSR server).
759
+ *
760
+ * @param manifestPath - Path to the JSON manifest file
761
+ * @returns Parsed client manifest (returns an empty manifest on failure)
762
+ *
763
+ * @example
764
+ * import { loadClientManifest } from 'pulse-js-framework/vite/server-components';
765
+ *
766
+ * const manifest = loadClientManifest('./dist/.pulse-manifest.json');
767
+ */
768
+ export function loadClientManifest(manifestPath: string): ClientManifest;
769
+
770
+ /**
771
+ * Look up the chunk URL for a specific Client Component.
772
+ *
773
+ * @param manifest - Parsed client manifest
774
+ * @param componentId - The component's ID string
775
+ * @returns The chunk URL, or `null` if the component is not in the manifest
776
+ */
777
+ export function getComponentChunk(
778
+ manifest: ClientManifest,
779
+ componentId: string
780
+ ): string | null;
781
+
782
+ /**
783
+ * Return a `Set` of all Client Component IDs registered in the manifest.
784
+ *
785
+ * @param manifest - Parsed client manifest
786
+ * @returns Set of component ID strings
787
+ */
788
+ export function getClientComponentIds(manifest: ClientManifest): Set<string>;
789
+ }
790
+
791
+ // ============================================================================
792
+ // Webpack Server Components – 'pulse-js-framework/webpack/server-components'
793
+ // ============================================================================
794
+
795
+ declare module 'pulse-js-framework/webpack/server-components' {
796
+ /**
797
+ * Webpack plugin class that adds Server Components support alongside the
798
+ * standard Pulse Webpack loader.
799
+ *
800
+ * Detects Client Components, maps them to their output chunks, emits a
801
+ * client manifest asset, and validates import rules (Client must not import
802
+ * Server-only modules).
803
+ *
804
+ * @example
805
+ * const PulseServerComponentsPlugin = require('pulse-js-framework/webpack/server-components').default;
806
+ *
807
+ * module.exports = {
808
+ * plugins: [new PulseServerComponentsPlugin({ manifestPath: 'dist/.pulse-manifest.json' })]
809
+ * };
810
+ */
811
+ class PulseServerComponentsPlugin {
812
+ constructor(options?: ServerComponentsPluginOptions);
813
+
814
+ /**
815
+ * Webpack `apply` entry point.
816
+ * @param compiler - Webpack `Compiler` instance
817
+ */
818
+ apply(compiler: object): void;
819
+ }
820
+
821
+ export default PulseServerComponentsPlugin;
822
+
823
+ /**
824
+ * Convenience factory that constructs a `PulseServerComponentsPlugin`
825
+ * instance. Equivalent to `new PulseServerComponentsPlugin(options)`.
826
+ *
827
+ * @param options - Plugin configuration
828
+ * @returns Plugin instance ready to add to `config.plugins`
829
+ *
830
+ * @example
831
+ * const { addServerComponentsSupport } = require('pulse-js-framework/webpack/server-components');
832
+ *
833
+ * module.exports = {
834
+ * plugins: [
835
+ * addServerComponentsSupport({ manifestPath: 'dist/.pulse-manifest.json' })
836
+ * ]
837
+ * };
838
+ */
839
+ export function addServerComponentsSupport(
840
+ options?: ServerComponentsPluginOptions
841
+ ): PulseServerComponentsPlugin;
842
+
843
+ /**
844
+ * Load the client manifest from disk (for use in the SSR server).
845
+ *
846
+ * @param manifestPath - Path to the JSON manifest file
847
+ * @returns Parsed client manifest (returns an empty manifest on failure)
848
+ */
849
+ export function loadClientManifest(manifestPath: string): ClientManifest;
850
+
851
+ /**
852
+ * Look up the chunk URL for a specific Client Component.
853
+ *
854
+ * @param manifest - Parsed client manifest
855
+ * @param componentId - The component's ID string
856
+ * @returns The chunk URL, or `null` if the component is not in the manifest
857
+ */
858
+ export function getComponentChunk(
859
+ manifest: ClientManifest,
860
+ componentId: string
861
+ ): string | null;
862
+
863
+ /**
864
+ * Return a `Set` of all Client Component IDs registered in the manifest.
865
+ *
866
+ * @param manifest - Parsed client manifest
867
+ * @returns Set of component ID strings
868
+ */
869
+ export function getClientComponentIds(manifest: ClientManifest): Set<string>;
870
+ }
871
+
872
+ // ============================================================================
873
+ // Rollup Server Components – 'pulse-js-framework/rollup/server-components'
874
+ // ============================================================================
875
+
876
+ declare module 'pulse-js-framework/rollup/server-components' {
877
+ /**
878
+ * Create the Pulse Server Components Rollup plugin.
879
+ *
880
+ * Should be used together with the main Pulse Rollup plugin.
881
+ * Detects Client Components, creates separate output chunks for them,
882
+ * generates a client manifest, and validates Client → Server import rules.
883
+ * The `closeBundle` hook is async (uses non-blocking I/O).
884
+ *
885
+ * @param options - Plugin configuration
886
+ * @returns Rollup plugin object
887
+ *
888
+ * @example
889
+ * // rollup.config.js
890
+ * import pulsePlugin from 'pulse-js-framework/rollup';
891
+ * import pulseServerComponents from 'pulse-js-framework/rollup/server-components';
892
+ *
893
+ * export default {
894
+ * input: 'src/main.js',
895
+ * output: { dir: 'dist', format: 'es' },
896
+ * plugins: [
897
+ * pulsePlugin(),
898
+ * pulseServerComponents()
899
+ * ]
900
+ * };
901
+ */
902
+ export default function pulseServerComponentsPlugin(
903
+ options?: ServerComponentsPluginOptions
904
+ ): object;
905
+
906
+ /**
907
+ * Load the client manifest from disk (for use in the SSR server).
908
+ *
909
+ * @param manifestPath - Path to the JSON manifest file
910
+ * @returns Parsed client manifest (returns an empty manifest on failure)
911
+ *
912
+ * @example
913
+ * import { loadClientManifest } from 'pulse-js-framework/rollup/server-components';
914
+ *
915
+ * const manifest = loadClientManifest('./dist/.pulse-manifest.json');
916
+ */
917
+ export function loadClientManifest(manifestPath: string): ClientManifest;
918
+
919
+ /**
920
+ * Look up the chunk URL for a specific Client Component.
921
+ *
922
+ * @param manifest - Parsed client manifest
923
+ * @param componentId - The component's ID string
924
+ * @returns The chunk URL, or `null` if the component is not in the manifest
925
+ */
926
+ export function getComponentChunk(
927
+ manifest: ClientManifest,
928
+ componentId: string
929
+ ): string | null;
930
+
931
+ /**
932
+ * Return a `Set` of all Client Component IDs registered in the manifest.
933
+ *
934
+ * @param manifest - Parsed client manifest
935
+ * @returns Set of component ID strings
936
+ */
937
+ export function getClientComponentIds(manifest: ClientManifest): Set<string>;
938
+ }
939
+
940
+ // ============================================================================
941
+ // ESBuild Server Components – 'pulse-js-framework/esbuild/server-components'
942
+ // ============================================================================
943
+
944
+ declare module 'pulse-js-framework/esbuild/server-components' {
945
+ /**
946
+ * Create the Pulse Server Components ESBuild plugin.
947
+ *
948
+ * Should be used together with the main Pulse ESBuild plugin.
949
+ * Detects Client Components, validates Client → Server import boundaries,
950
+ * maps components to output chunks via metafile, and generates a client manifest.
951
+ *
952
+ * Note: ESBuild does not support `manualChunks`. Use `splitting: true` in
953
+ * your ESBuild config for code splitting.
954
+ *
955
+ * @param options - Plugin configuration
956
+ * @returns ESBuild plugin object (`{ name, setup }`)
957
+ *
958
+ * @example
959
+ * import * as esbuild from 'esbuild';
960
+ * import pulsePlugin from 'pulse-js-framework/esbuild';
961
+ * import pulseServerComponents from 'pulse-js-framework/esbuild/server-components';
962
+ *
963
+ * await esbuild.build({
964
+ * entryPoints: ['src/main.js'],
965
+ * bundle: true,
966
+ * outdir: 'dist',
967
+ * format: 'esm',
968
+ * splitting: true,
969
+ * metafile: true,
970
+ * plugins: [
971
+ * pulsePlugin(),
972
+ * pulseServerComponents()
973
+ * ]
974
+ * });
975
+ */
976
+ export default function pulseServerComponentsPlugin(
977
+ options?: ServerComponentsPluginOptions
978
+ ): object;
979
+
980
+ /**
981
+ * Load the client manifest from disk (for use in the SSR server).
982
+ *
983
+ * @param manifestPath - Path to the JSON manifest file
984
+ * @returns Parsed client manifest (returns an empty manifest on failure)
985
+ */
986
+ export function loadClientManifest(manifestPath: string): ClientManifest;
987
+
988
+ /**
989
+ * Look up the chunk URL for a specific Client Component.
990
+ *
991
+ * @param manifest - Parsed client manifest
992
+ * @param componentId - The component's ID string
993
+ * @returns The chunk URL, or `null` if the component is not in the manifest
994
+ */
995
+ export function getComponentChunk(
996
+ manifest: ClientManifest,
997
+ componentId: string
998
+ ): string | null;
999
+
1000
+ /**
1001
+ * Return a `Set` of all Client Component IDs registered in the manifest.
1002
+ *
1003
+ * @param manifest - Parsed client manifest
1004
+ * @returns Set of component ID strings
1005
+ */
1006
+ export function getClientComponentIds(manifest: ClientManifest): Set<string>;
1007
+ }
1008
+
1009
+ // ============================================================================
1010
+ // Shared Constants – 'pulse-js-framework/loader/shared'
1011
+ // ============================================================================
1012
+
1013
+ declare module 'pulse-js-framework/loader/shared' {
1014
+ /** Regex matching `__directive: "use client"` in compiled output */
1015
+ export const DIRECTIVE_REGEX: RegExp;
1016
+
1017
+ /** Regex extracting component ID from `__componentId: "Name"` */
1018
+ export const COMPONENT_ID_REGEX: RegExp;
1019
+
1020
+ /** Regex extracting component name from `export const Name = {` */
1021
+ export const EXPORT_CONST_REGEX: RegExp;
1022
+
1023
+ /** Chunk name prefix for Client Components (`"client-"`) */
1024
+ export const CLIENT_CHUNK_PREFIX: string;
1025
+
1026
+ /** Default manifest output path (`"dist/.pulse-manifest.json"`) */
1027
+ export const DEFAULT_MANIFEST_PATH: string;
1028
+
1029
+ /** Default manifest filename (`".pulse-manifest.json"`) */
1030
+ export const DEFAULT_MANIFEST_FILENAME: string;
1031
+
1032
+ /** Load client manifest from disk */
1033
+ export function loadClientManifest(manifestPath: string): ClientManifest;
1034
+
1035
+ /** Get chunk URL for a Client Component */
1036
+ export function getComponentChunk(
1037
+ manifest: ClientManifest,
1038
+ componentId: string
1039
+ ): string | null;
1040
+
1041
+ /** Get all Client Component IDs from manifest */
1042
+ export function getClientComponentIds(manifest: ClientManifest): Set<string>;
1043
+ }