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
package/loader/README.md DELETED
@@ -1,509 +0,0 @@
1
- # Pulse Build Tool Integrations
2
-
3
- Build tool loaders and plugins for the Pulse JavaScript framework.
4
-
5
- ## Available Integrations
6
-
7
- ### Vite Plugin (`vite-plugin.js`) ✅
8
-
9
- Full-featured Vite plugin with HMR support and CSS extraction.
10
-
11
- **Installation:**
12
-
13
- ```javascript
14
- // vite.config.js
15
- import pulsePlugin from 'pulse-js-framework/vite';
16
-
17
- export default {
18
- plugins: [pulsePlugin({
19
- sourceMap: true,
20
- sass: {
21
- loadPaths: ['src/styles'],
22
- compressed: false
23
- }
24
- })]
25
- };
26
- ```
27
-
28
- **Features:**
29
- - ✅ Automatic `.pulse` file transformation
30
- - ✅ Hot Module Replacement (HMR)
31
- - ✅ CSS extraction to Vite's CSS pipeline
32
- - ✅ Source map generation
33
- - ✅ SASS/LESS/Stylus auto-detection and compilation
34
- - ✅ Virtual CSS modules
35
-
36
- ### Webpack Loader (`webpack-loader.js`) ✅
37
-
38
- Webpack loader with CSS extraction and preprocessor support.
39
-
40
- **Installation:**
41
-
42
- ```javascript
43
- // webpack.config.js
44
- module.exports = {
45
- module: {
46
- rules: [
47
- {
48
- test: /\.pulse$/,
49
- use: [
50
- 'style-loader', // Inject CSS into DOM
51
- 'css-loader', // Resolve CSS imports
52
- {
53
- loader: 'pulse-js-framework/loader/webpack-loader',
54
- options: {
55
- sourceMap: true,
56
- extractCss: true, // Extract CSS for css-loader
57
- hmr: true, // Enable HMR support
58
- sass: {
59
- loadPaths: ['src/styles']
60
- }
61
- }
62
- }
63
- ]
64
- }
65
- ]
66
- }
67
- };
68
- ```
69
-
70
- **With MiniCssExtractPlugin (production):**
71
-
72
- ```javascript
73
- const MiniCssExtractPlugin = require('mini-css-extract-plugin');
74
-
75
- module.exports = {
76
- module: {
77
- rules: [
78
- {
79
- test: /\.pulse$/,
80
- use: [
81
- MiniCssExtractPlugin.loader, // Extract to .css file
82
- 'css-loader',
83
- 'pulse-js-framework/loader/webpack-loader'
84
- ]
85
- }
86
- ]
87
- },
88
- plugins: [
89
- new MiniCssExtractPlugin({
90
- filename: '[name].[contenthash].css'
91
- })
92
- ]
93
- };
94
- ```
95
-
96
- **Features:**
97
- - ✅ Webpack 5+ support
98
- - ✅ CSS extraction for loaders chain
99
- - ✅ Hot Module Replacement (HMR)
100
- - ✅ Source map generation
101
- - ✅ SASS/LESS/Stylus auto-detection
102
- - ✅ Compatible with style-loader and MiniCssExtractPlugin
103
-
104
- ### Rollup Plugin (`rollup-plugin.js`) ✅
105
-
106
- Rollup plugin with CSS extraction and tree-shaking support.
107
-
108
- **Installation:**
109
-
110
- ```javascript
111
- // rollup.config.js
112
- import pulsePlugin from 'pulse-js-framework/rollup';
113
- import resolve from '@rollup/plugin-node-resolve';
114
-
115
- export default {
116
- input: 'src/main.js',
117
- output: {
118
- file: 'dist/bundle.js',
119
- format: 'es',
120
- sourcemap: true
121
- },
122
- plugins: [
123
- pulsePlugin({
124
- sourceMap: true,
125
- extractCss: 'bundle.css', // Extract to CSS file
126
- sass: {
127
- loadPaths: ['src/styles']
128
- }
129
- }),
130
- resolve()
131
- ]
132
- };
133
- ```
134
-
135
- **Features:**
136
- - ✅ Rollup 4+ support
137
- - ✅ CSS extraction to separate file
138
- - ✅ Source map generation
139
- - ✅ SASS/LESS/Stylus auto-detection
140
- - ✅ Tree-shaking compatible (ES modules)
141
- - ✅ No external dependencies required
142
-
143
- ## CSS Preprocessor Support
144
-
145
- Both integrations support **automatic CSS preprocessing** for SASS, LESS, and Stylus:
146
-
147
- 1. **Install the preprocessor** in your project:
148
- ```bash
149
- npm install -D sass # For SASS/SCSS
150
- npm install -D less # For LESS
151
- npm install -D stylus # For Stylus
152
- ```
153
-
154
- 2. **Use preprocessor syntax** in `.pulse` style blocks:
155
- ```pulse
156
- style {
157
- $primary: #646cff; // SASS
158
- @primary: #646cff; // LESS
159
- primary = #646cff // Stylus
160
-
161
- .button {
162
- background: $primary;
163
- &:hover { opacity: 0.8; }
164
- }
165
- }
166
- ```
167
-
168
- 3. **Auto-detection** - Framework detects preprocessor syntax automatically:
169
- - Priority: SASS > LESS > Stylus
170
- - Falls back to plain CSS if no preprocessor detected
171
-
172
- ## Options Reference
173
-
174
- ### Vite Plugin Options
175
-
176
- | Option | Type | Default | Description |
177
- |--------|------|---------|-------------|
178
- | `exclude` | RegExp | `/node_modules/` | Files to exclude |
179
- | `sourceMap` | boolean | `true` | Generate source maps |
180
- | `sass.loadPaths` | string[] | `[]` | SASS include paths |
181
- | `sass.compressed` | boolean | `false` | Minify SASS output |
182
-
183
- ### Webpack Loader Options
184
-
185
- | Option | Type | Default | Description |
186
- |--------|------|---------|-------------|
187
- | `sourceMap` | boolean | `true` | Generate source maps |
188
- | `extractCss` | boolean | `true` | Extract CSS for css-loader |
189
- | `hmr` | boolean | `true` | Enable HMR support |
190
- | `verbose` | boolean | `true` | Log preprocessor info |
191
- | `sass.loadPaths` | string[] | `[]` | SASS include paths |
192
- | `sass.compressed` | boolean | `false` | Minify SASS output |
193
- | `sass.verbose` | boolean | `false` | Log SASS compilation |
194
- | `less.*` | object | `{}` | LESS-specific options |
195
- | `stylus.*` | object | `{}` | Stylus-specific options |
196
-
197
- ### Rollup Plugin Options
198
-
199
- | Option | Type | Default | Description |
200
- |--------|------|---------|-------------|
201
- | `include` | RegExp/Array | `/\.pulse$/` | Files to include |
202
- | `exclude` | RegExp/Array | `/node_modules/` | Files to exclude |
203
- | `sourceMap` | boolean | `true` | Generate source maps |
204
- | `extractCss` | string | `null` | Output CSS filename (null = inline) |
205
- | `sass.loadPaths` | string[] | `[]` | SASS include paths |
206
- | `sass.compressed` | boolean | `false` | Minify SASS output |
207
- | `sass.verbose` | boolean | `false` | Log SASS compilation |
208
- | `less.*` | object | `{}` | LESS-specific options |
209
- | `stylus.*` | object | `{}` | Stylus-specific options |
210
-
211
- ### ESBuild Plugin Options
212
-
213
- | Option | Type | Default | Description |
214
- |--------|------|---------|-------------|
215
- | `sourceMap` | boolean | `true` | Generate source maps |
216
- | `extractCss` | string | `null` | Output CSS filename (null = inline) |
217
- | `sass.loadPaths` | string[] | `[]` | SASS include paths |
218
- | `sass.compressed` | boolean | `false` | Minify SASS output |
219
- | `sass.verbose` | boolean | `false` | Log SASS compilation |
220
- | `less.*` | object | `{}` | LESS-specific options |
221
- | `stylus.*` | object | `{}` | Stylus-specific options |
222
-
223
- ### Parcel Plugin Options
224
-
225
- | Option | Type | Default | Description |
226
- |--------|------|---------|-------------|
227
- | `sourceMap` | boolean | `true` | Generate source maps |
228
- | `extractCss` | boolean | `true` | Extract CSS for Parcel's CSS pipeline |
229
- | `verbose` | boolean | `false` | Log preprocessor info |
230
- | `sass.loadPaths` | string[] | `[]` | SASS include paths |
231
- | `sass.compressed` | boolean | `false` | Minify SASS output |
232
- | `sass.verbose` | boolean | `false` | Log SASS compilation |
233
- | `less.*` | object | `{}` | LESS-specific options |
234
- | `stylus.*` | object | `{}` | Stylus-specific options |
235
-
236
- ### SWC Plugin Options
237
-
238
- | Option | Type | Default | Description |
239
- |--------|------|---------|-------------|
240
- | `sourceMap` | boolean | `true` | Generate source maps |
241
- | `extractCss` | string | `null` | Output CSS filename (null = inline) |
242
- | `sass.loadPaths` | string[] | `[]` | SASS include paths |
243
- | `sass.compressed` | boolean | `false` | Minify SASS output |
244
- | `sass.verbose` | boolean | `false` | Log SASS compilation |
245
- | `less.*` | object | `{}` | LESS-specific options |
246
- | `stylus.*` | object | `{}` | Stylus-specific options |
247
-
248
- ## Development
249
-
250
- ### Testing Vite Plugin
251
-
252
- ```bash
253
- cd examples/vite-example
254
- npm install
255
- npm run dev
256
- ```
257
-
258
- ### Testing Webpack Loader
259
-
260
- ```bash
261
- cd examples/webpack-example
262
- npm install
263
- npm run dev
264
- ```
265
-
266
- ### Testing Rollup Plugin
267
-
268
- ```bash
269
- cd examples/rollup-example
270
- npm install
271
- npm run dev
272
- ```
273
-
274
- ### Testing ESBuild Plugin
275
-
276
- ```bash
277
- cd examples/esbuild-example
278
- npm install
279
- npm run dev
280
- ```
281
-
282
- ### Testing Parcel Plugin
283
-
284
- ```bash
285
- cd examples/parcel-example
286
- npm install
287
- npm run dev
288
- ```
289
-
290
- ### Testing SWC Plugin
291
-
292
- ```bash
293
- npm run test:swc-plugin
294
- ```
295
-
296
- ### ESBuild Plugin (`esbuild-plugin.js`) ✅
297
-
298
- ESBuild plugin with CSS extraction and preprocessor support.
299
-
300
- **Installation:**
301
-
302
- ```javascript
303
- // build.js
304
- import * as esbuild from 'esbuild';
305
- import pulsePlugin from 'pulse-js-framework/esbuild';
306
-
307
- await esbuild.build({
308
- entryPoints: ['src/main.js'],
309
- bundle: true,
310
- outfile: 'dist/bundle.js',
311
- plugins: [
312
- pulsePlugin({
313
- sourceMap: true,
314
- extractCss: 'dist/bundle.css', // Extract to CSS file
315
- sass: {
316
- loadPaths: ['src/styles']
317
- }
318
- })
319
- ]
320
- });
321
- ```
322
-
323
- **Features:**
324
- - ✅ ESBuild support
325
- - ✅ CSS extraction to separate file
326
- - ✅ Source map generation
327
- - ✅ SASS/LESS/Stylus auto-detection
328
- - ✅ Fast incremental builds
329
- - ✅ Watch mode compatible
330
- - ✅ No external dependencies required
331
-
332
- ### Parcel Plugin (`parcel-plugin.js`) ✅
333
-
334
- Parcel transformer with CSS extraction and preprocessor support.
335
-
336
- **Installation:**
337
-
338
- 1. Install Pulse as a dev dependency:
339
- ```bash
340
- npm install -D pulse-js-framework
341
- ```
342
-
343
- 2. Create `.parcelrc` configuration:
344
- ```json
345
- {
346
- "extends": "@parcel/config-default",
347
- "transformers": {
348
- "*.pulse": ["pulse-js-framework/parcel"]
349
- }
350
- }
351
- ```
352
-
353
- 3. Optionally create `.pulserc` or `.pulserc.json` for plugin options:
354
- ```json
355
- {
356
- "sourceMap": true,
357
- "extractCss": true,
358
- "verbose": false,
359
- "sass": {
360
- "loadPaths": ["src/styles"],
361
- "compressed": false
362
- },
363
- "less": {
364
- "loadPaths": []
365
- },
366
- "stylus": {
367
- "loadPaths": []
368
- }
369
- }
370
- ```
371
-
372
- Or configure via `package.json`:
373
- ```json
374
- {
375
- "pulse": {
376
- "sourceMap": true,
377
- "extractCss": true,
378
- "sass": {
379
- "loadPaths": ["src/styles"]
380
- }
381
- }
382
- }
383
- ```
384
-
385
- **Usage:**
386
-
387
- ```javascript
388
- // src/main.js
389
- import MyComponent from './MyComponent.pulse';
390
- import { mount } from 'pulse-js-framework/runtime';
391
-
392
- mount('#app', MyComponent());
393
- ```
394
-
395
- **Features:**
396
- - ✅ Automatic `.pulse` file transformation
397
- - ✅ CSS extraction to Parcel's CSS pipeline
398
- - ✅ Source map generation
399
- - ✅ SASS/LESS/Stylus auto-detection and compilation
400
- - ✅ Hot Module Replacement (HMR)
401
- - ✅ Watch mode support
402
- - ✅ Zero configuration (works out of the box)
403
-
404
- **Development Server:**
405
-
406
- ```bash
407
- parcel src/index.html
408
- ```
409
-
410
- **Production Build:**
411
-
412
- ```bash
413
- parcel build src/index.html
414
- ```
415
-
416
- ### SWC Plugin (`swc-plugin.js`) ✅
417
-
418
- SWC plugin with CSS extraction, preprocessor support, and standalone transform API.
419
-
420
- **Usage with plugin interface:**
421
-
422
- ```javascript
423
- // build.js
424
- import pulsePlugin from 'pulse-js-framework/swc';
425
-
426
- const plugin = pulsePlugin({
427
- sourceMap: true,
428
- extractCss: 'dist/bundle.css',
429
- sass: {
430
- loadPaths: ['src/styles']
431
- }
432
- });
433
-
434
- plugin.buildStart();
435
-
436
- // Transform each .pulse file
437
- const result = plugin.transform(pulseSource, 'src/App.pulse');
438
- console.log(result.code); // Compiled JavaScript
439
- console.log(result.css); // Extracted CSS
440
-
441
- plugin.buildEnd(); // Writes accumulated CSS to dist/bundle.css
442
- ```
443
-
444
- **Usage with direct transform API:**
445
-
446
- ```javascript
447
- import { transformPulseFile, transformPulseCode } from 'pulse-js-framework/swc';
448
-
449
- // Transform a file
450
- const result = transformPulseFile('src/App.pulse', { sourceMap: true });
451
-
452
- // Transform source code
453
- const result2 = transformPulseCode(source, { filename: 'App.pulse' });
454
- ```
455
-
456
- **Batch processing:**
457
-
458
- ```javascript
459
- import { buildPulseFiles } from 'pulse-js-framework/swc';
460
-
461
- const results = buildPulseFiles(
462
- ['src/App.pulse', 'src/Home.pulse'],
463
- { extractCss: 'dist/bundle.css' }
464
- );
465
- ```
466
-
467
- **Features:**
468
- - ✅ Standalone transform API (no SWC dependency required)
469
- - ✅ Plugin interface with build lifecycle
470
- - ✅ CSS extraction to separate file
471
- - ✅ Source map generation
472
- - ✅ SASS/LESS/Stylus auto-detection and compilation
473
- - ✅ Batch file processing
474
- - ✅ No external dependencies required
475
-
476
- ## Planned Integrations
477
-
478
- All planned integrations have been implemented.
479
-
480
- ## Architecture
481
-
482
- All integrations follow the same pattern:
483
-
484
- 1. **Compile** `.pulse` files to JavaScript using `compiler/index.js`
485
- 2. **Extract CSS** from compiled output
486
- 3. **Preprocess CSS** if SASS/LESS/Stylus detected and available
487
- 4. **Pass to build tool** pipeline:
488
- - Vite: Virtual CSS modules
489
- - Webpack: css-loader chain
490
- - Rollup: Accumulated CSS asset
491
- - ESBuild: File-based CSS accumulation
492
- - Parcel: Asset API
493
- - SWC: File-based CSS accumulation with standalone transform API
494
- 5. **Enable HMR** for development (where supported)
495
-
496
- ## Contributing
497
-
498
- When adding a new build tool integration:
499
-
500
- 1. Follow the naming convention: `{tool}-{type}.js` (e.g., `rollup-plugin.js`)
501
- 2. Support CSS extraction for the tool's pipeline
502
- 3. Enable HMR if the tool supports it
503
- 4. Add preprocessor auto-detection
504
- 5. Document options in this README
505
- 6. Add example project in `examples/`
506
-
507
- ## License
508
-
509
- MIT