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/runtime/utils.js CHANGED
@@ -30,12 +30,13 @@ export { escapeHtml, sanitizeUrl };
30
30
  */
31
31
  export function unescapeHtml(str) {
32
32
  if (str == null) return '';
33
+ // Unescape &amp; LAST to avoid double-unescaping (e.g., '&amp;lt;' -> '&lt;' -> '<')
33
34
  return String(str)
34
- .replace(/&amp;/g, '&')
35
35
  .replace(/&lt;/g, '<')
36
36
  .replace(/&gt;/g, '>')
37
37
  .replace(/&quot;/g, '"')
38
- .replace(/&#39;/g, "'");
38
+ .replace(/&#39;/g, "'")
39
+ .replace(/&amp;/g, '&');
39
40
  }
40
41
 
41
42
  /**
package/server/utils.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * @module pulse-js-framework/server/utils
8
8
  */
9
9
 
10
- import { readFileSync, existsSync, statSync } from 'fs';
10
+ import { readFileSync } from 'fs';
11
11
  import { extname, resolve, sep } from 'path';
12
12
 
13
13
  // ============================================================================
@@ -104,11 +104,15 @@ export function readTemplate(templatePath) {
104
104
  return templateCache.get(templatePath);
105
105
  }
106
106
 
107
- if (!existsSync(templatePath)) {
108
- throw new Error(`[Pulse Server] Template not found: ${templatePath}`);
107
+ let content;
108
+ try {
109
+ content = readFileSync(templatePath, 'utf-8');
110
+ } catch (e) {
111
+ if (e.code === 'ENOENT') {
112
+ throw new Error(`[Pulse Server] Template not found: ${templatePath}`);
113
+ }
114
+ throw e;
109
115
  }
110
-
111
- const content = readFileSync(templatePath, 'utf-8');
112
116
  templateCache.set(templatePath, content);
113
117
  return content;
114
118
  }
@@ -155,11 +159,13 @@ export function resolveStaticAsset(pathname, distDir, options = {}) {
155
159
  return null;
156
160
  }
157
161
 
158
- if (!existsSync(filePath) || !statSync(filePath).isFile()) {
159
- return null;
162
+ let content;
163
+ try {
164
+ content = readFileSync(filePath);
165
+ } catch (err) {
166
+ if (err.code === 'ENOENT' || err.code === 'EISDIR') return null;
167
+ throw err;
160
168
  }
161
-
162
- const content = readFileSync(filePath);
163
169
  const mimeType = getMimeType(filePath);
164
170
 
165
171
  // Hashed assets get long cache
package/sw/index.js CHANGED
@@ -224,6 +224,8 @@ export function createCacheStrategy(name, options = {}) {
224
224
  */
225
225
  export function enableSkipWaiting() {
226
226
  self.addEventListener('message', (event) => {
227
+ // Validate origin: only accept messages from the same origin as the service worker
228
+ if (event.origin && event.origin !== self.location.origin) return;
227
229
  if (event.data?.type === 'SKIP_WAITING') {
228
230
  self.skipWaiting();
229
231
  }