wu-framework 1.1.14 → 1.1.16

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 (90) hide show
  1. package/LICENSE +39 -39
  2. package/README.md +408 -408
  3. package/dist/wu-framework.cjs.js.map +1 -1
  4. package/dist/wu-framework.dev.js +15151 -15151
  5. package/dist/wu-framework.dev.js.map +1 -1
  6. package/dist/wu-framework.esm.js.map +1 -1
  7. package/dist/wu-framework.umd.js.map +1 -1
  8. package/integrations/astro/README.md +127 -127
  9. package/integrations/astro/WuApp.astro +63 -63
  10. package/integrations/astro/WuShell.astro +39 -39
  11. package/integrations/astro/index.js +68 -68
  12. package/integrations/astro/package.json +38 -38
  13. package/integrations/astro/types.d.ts +53 -53
  14. package/package.json +161 -161
  15. package/src/adapters/angular/ai.js +30 -30
  16. package/src/adapters/angular/index.d.ts +154 -154
  17. package/src/adapters/angular/index.js +932 -932
  18. package/src/adapters/angular.d.ts +3 -3
  19. package/src/adapters/angular.js +3 -3
  20. package/src/adapters/index.js +168 -168
  21. package/src/adapters/lit/ai.js +20 -20
  22. package/src/adapters/lit/index.d.ts +120 -120
  23. package/src/adapters/lit/index.js +721 -721
  24. package/src/adapters/lit.d.ts +3 -3
  25. package/src/adapters/lit.js +3 -3
  26. package/src/adapters/preact/ai.js +33 -33
  27. package/src/adapters/preact/index.d.ts +108 -108
  28. package/src/adapters/preact/index.js +661 -661
  29. package/src/adapters/preact.d.ts +3 -3
  30. package/src/adapters/preact.js +3 -3
  31. package/src/adapters/react/index.js +48 -54
  32. package/src/adapters/react.d.ts +3 -3
  33. package/src/adapters/react.js +3 -3
  34. package/src/adapters/shared.js +64 -64
  35. package/src/adapters/solid/ai.js +32 -32
  36. package/src/adapters/solid/index.d.ts +101 -101
  37. package/src/adapters/solid/index.js +586 -586
  38. package/src/adapters/solid.d.ts +3 -3
  39. package/src/adapters/solid.js +3 -3
  40. package/src/adapters/svelte/ai.js +31 -31
  41. package/src/adapters/svelte/index.d.ts +166 -166
  42. package/src/adapters/svelte/index.js +798 -798
  43. package/src/adapters/svelte.d.ts +3 -3
  44. package/src/adapters/svelte.js +3 -3
  45. package/src/adapters/vanilla/ai.js +30 -30
  46. package/src/adapters/vanilla/index.d.ts +179 -179
  47. package/src/adapters/vanilla/index.js +785 -785
  48. package/src/adapters/vanilla.d.ts +3 -3
  49. package/src/adapters/vanilla.js +3 -3
  50. package/src/adapters/vue/ai.js +52 -52
  51. package/src/adapters/vue/index.d.ts +299 -299
  52. package/src/adapters/vue/index.js +610 -610
  53. package/src/adapters/vue.d.ts +3 -3
  54. package/src/adapters/vue.js +3 -3
  55. package/src/ai/wu-ai-actions.js +261 -261
  56. package/src/ai/wu-ai-agent.js +546 -546
  57. package/src/ai/wu-ai-browser-primitives.js +354 -354
  58. package/src/ai/wu-ai-browser.js +380 -380
  59. package/src/ai/wu-ai-context.js +332 -332
  60. package/src/ai/wu-ai-conversation.js +613 -613
  61. package/src/ai/wu-ai-orchestrate.js +1021 -1021
  62. package/src/ai/wu-ai-permissions.js +381 -381
  63. package/src/ai/wu-ai-provider.js +700 -700
  64. package/src/ai/wu-ai-schema.js +225 -225
  65. package/src/ai/wu-ai-triggers.js +396 -396
  66. package/src/ai/wu-ai.js +804 -804
  67. package/src/core/wu-app.js +236 -236
  68. package/src/core/wu-cache.js +477 -477
  69. package/src/core/wu-core.js +1398 -1398
  70. package/src/core/wu-error-boundary.js +382 -382
  71. package/src/core/wu-event-bus.js +348 -348
  72. package/src/core/wu-hooks.js +350 -350
  73. package/src/core/wu-html-parser.js +190 -190
  74. package/src/core/wu-iframe-sandbox.js +328 -328
  75. package/src/core/wu-loader.js +272 -272
  76. package/src/core/wu-logger.js +134 -134
  77. package/src/core/wu-manifest.js +509 -509
  78. package/src/core/wu-mcp-bridge.js +432 -432
  79. package/src/core/wu-overrides.js +510 -510
  80. package/src/core/wu-performance.js +228 -228
  81. package/src/core/wu-plugin.js +348 -348
  82. package/src/core/wu-prefetch.js +414 -414
  83. package/src/core/wu-proxy-sandbox.js +476 -476
  84. package/src/core/wu-sandbox.js +779 -779
  85. package/src/core/wu-script-executor.js +113 -113
  86. package/src/core/wu-snapshot-sandbox.js +227 -227
  87. package/src/core/wu-strategies.js +256 -256
  88. package/src/core/wu-style-bridge.js +477 -477
  89. package/src/index.js +224 -224
  90. package/src/utils/dependency-resolver.js +327 -327
@@ -1,113 +1,113 @@
1
- /**
2
- * WU-SCRIPT-EXECUTOR: Execute scripts inside a Proxy sandbox.
3
- *
4
- * Two isolation levels:
5
- * - strictGlobal: true → with(proxy) { code } — all global access goes through proxy
6
- * - strictGlobal: false → (function(window){ code })(proxy) — only explicit window.xxx
7
- *
8
- * This is what makes the sandbox REAL instead of decorative.
9
- * Without this, import() runs code in global scope and the proxy is just a cleanup tracker.
10
- * With this, code receives the proxy as "window" and every setTimeout, addEventListener,
11
- * document.querySelector, localStorage access goes through the proxy's traps.
12
- */
13
-
14
- import { logger } from './wu-logger.js';
15
-
16
- export class WuScriptExecutor {
17
-
18
- /**
19
- * Execute a script string inside the proxy sandbox.
20
- *
21
- * @param {string} scriptText - JavaScript code to execute
22
- * @param {string} appName - App identifier (for logging)
23
- * @param {Proxy} proxy - The activated proxy sandbox
24
- * @param {Object} [options]
25
- * @param {boolean} [options.strictGlobal=true] - Use with(proxy) for maximum isolation
26
- * @param {string} [options.sourceUrl=''] - Source URL for devtools (//# sourceURL)
27
- * @returns {*} Return value of the executed code
28
- */
29
- execute(scriptText, appName, proxy, options = {}) {
30
- const { strictGlobal = true, sourceUrl = '' } = options;
31
-
32
- if (!scriptText || !scriptText.trim()) return;
33
-
34
- const sourceComment = sourceUrl ? `\n//# sourceURL=wu-sandbox:///${appName}/${sourceUrl}\n` : '';
35
-
36
- let wrappedCode;
37
-
38
- if (strictGlobal) {
39
- // MAXIMUM ISOLATION
40
- // with(window) makes ALL unqualified identifiers (setTimeout, fetch, document, etc.)
41
- // resolve through the proxy's has/get traps, not the real window.
42
- // Note: 'use strict' inside the with block becomes a no-op string expression,
43
- // so bundled code with strict mode still works.
44
- wrappedCode = `;(function(window, self, globalThis, top, parent) {
45
- with(window) {
46
- ;${scriptText}${sourceComment}
47
- }
48
- }).call(proxy, proxy, proxy, proxy, proxy, proxy);`;
49
- } else {
50
- // IIFE ONLY — only explicit window.xxx goes through proxy
51
- wrappedCode = `;(function(window, self, globalThis, top, parent) {
52
- ;${scriptText}${sourceComment}
53
- }).call(proxy, proxy, proxy, proxy, proxy, proxy);`;
54
- }
55
-
56
- try {
57
- // new Function('proxy', code) creates a function with 'proxy' as the single param.
58
- // This avoids polluting scope — the only bridge to the sandbox is the proxy argument.
59
- const fn = new Function('proxy', wrappedCode);
60
- return fn(proxy);
61
- } catch (error) {
62
- // If strictGlobal failed (rare edge case with with-statement), retry without it
63
- if (strictGlobal) {
64
- logger.wuWarn(`[ScriptExecutor] strictGlobal failed for ${appName}, retrying without with(): ${error.message}`);
65
- return this.execute(scriptText, appName, proxy, { ...options, strictGlobal: false });
66
- }
67
- logger.wuError(`[ScriptExecutor] Execution failed for ${appName}:`, error);
68
- throw error;
69
- }
70
- }
71
-
72
- /**
73
- * Fetch script content from a URL.
74
- * @param {string} url - Script URL
75
- * @returns {Promise<string>} Script text
76
- */
77
- async fetchScript(url) {
78
- const response = await fetch(url);
79
- if (!response.ok) {
80
- throw new Error(`Failed to fetch script ${url}: HTTP ${response.status}`);
81
- }
82
- return response.text();
83
- }
84
-
85
- /**
86
- * Execute an array of scripts in sequence inside the proxy.
87
- * External scripts (with src) are fetched first.
88
- *
89
- * @param {Array<{content?: string, src?: string}>} scripts
90
- * @param {string} appName
91
- * @param {Proxy} proxy
92
- * @param {Object} [options]
93
- */
94
- async executeAll(scripts, appName, proxy, options = {}) {
95
- for (const script of scripts) {
96
- let text = script.content;
97
-
98
- if (!text && script.src) {
99
- logger.wuDebug(`[ScriptExecutor] Fetching external script: ${script.src}`);
100
- text = await this.fetchScript(script.src);
101
- }
102
-
103
- if (text && text.trim()) {
104
- this.execute(text, appName, proxy, {
105
- ...options,
106
- sourceUrl: script.src || options.sourceUrl || ''
107
- });
108
- }
109
- }
110
-
111
- logger.wuDebug(`[ScriptExecutor] Executed ${scripts.length} scripts for ${appName}`);
112
- }
113
- }
1
+ /**
2
+ * WU-SCRIPT-EXECUTOR: Execute scripts inside a Proxy sandbox.
3
+ *
4
+ * Two isolation levels:
5
+ * - strictGlobal: true → with(proxy) { code } — all global access goes through proxy
6
+ * - strictGlobal: false → (function(window){ code })(proxy) — only explicit window.xxx
7
+ *
8
+ * This is what makes the sandbox REAL instead of decorative.
9
+ * Without this, import() runs code in global scope and the proxy is just a cleanup tracker.
10
+ * With this, code receives the proxy as "window" and every setTimeout, addEventListener,
11
+ * document.querySelector, localStorage access goes through the proxy's traps.
12
+ */
13
+
14
+ import { logger } from './wu-logger.js';
15
+
16
+ export class WuScriptExecutor {
17
+
18
+ /**
19
+ * Execute a script string inside the proxy sandbox.
20
+ *
21
+ * @param {string} scriptText - JavaScript code to execute
22
+ * @param {string} appName - App identifier (for logging)
23
+ * @param {Proxy} proxy - The activated proxy sandbox
24
+ * @param {Object} [options]
25
+ * @param {boolean} [options.strictGlobal=true] - Use with(proxy) for maximum isolation
26
+ * @param {string} [options.sourceUrl=''] - Source URL for devtools (//# sourceURL)
27
+ * @returns {*} Return value of the executed code
28
+ */
29
+ execute(scriptText, appName, proxy, options = {}) {
30
+ const { strictGlobal = true, sourceUrl = '' } = options;
31
+
32
+ if (!scriptText || !scriptText.trim()) return;
33
+
34
+ const sourceComment = sourceUrl ? `\n//# sourceURL=wu-sandbox:///${appName}/${sourceUrl}\n` : '';
35
+
36
+ let wrappedCode;
37
+
38
+ if (strictGlobal) {
39
+ // MAXIMUM ISOLATION
40
+ // with(window) makes ALL unqualified identifiers (setTimeout, fetch, document, etc.)
41
+ // resolve through the proxy's has/get traps, not the real window.
42
+ // Note: 'use strict' inside the with block becomes a no-op string expression,
43
+ // so bundled code with strict mode still works.
44
+ wrappedCode = `;(function(window, self, globalThis, top, parent) {
45
+ with(window) {
46
+ ;${scriptText}${sourceComment}
47
+ }
48
+ }).call(proxy, proxy, proxy, proxy, proxy, proxy);`;
49
+ } else {
50
+ // IIFE ONLY — only explicit window.xxx goes through proxy
51
+ wrappedCode = `;(function(window, self, globalThis, top, parent) {
52
+ ;${scriptText}${sourceComment}
53
+ }).call(proxy, proxy, proxy, proxy, proxy, proxy);`;
54
+ }
55
+
56
+ try {
57
+ // new Function('proxy', code) creates a function with 'proxy' as the single param.
58
+ // This avoids polluting scope — the only bridge to the sandbox is the proxy argument.
59
+ const fn = new Function('proxy', wrappedCode);
60
+ return fn(proxy);
61
+ } catch (error) {
62
+ // If strictGlobal failed (rare edge case with with-statement), retry without it
63
+ if (strictGlobal) {
64
+ logger.wuWarn(`[ScriptExecutor] strictGlobal failed for ${appName}, retrying without with(): ${error.message}`);
65
+ return this.execute(scriptText, appName, proxy, { ...options, strictGlobal: false });
66
+ }
67
+ logger.wuError(`[ScriptExecutor] Execution failed for ${appName}:`, error);
68
+ throw error;
69
+ }
70
+ }
71
+
72
+ /**
73
+ * Fetch script content from a URL.
74
+ * @param {string} url - Script URL
75
+ * @returns {Promise<string>} Script text
76
+ */
77
+ async fetchScript(url) {
78
+ const response = await fetch(url);
79
+ if (!response.ok) {
80
+ throw new Error(`Failed to fetch script ${url}: HTTP ${response.status}`);
81
+ }
82
+ return response.text();
83
+ }
84
+
85
+ /**
86
+ * Execute an array of scripts in sequence inside the proxy.
87
+ * External scripts (with src) are fetched first.
88
+ *
89
+ * @param {Array<{content?: string, src?: string}>} scripts
90
+ * @param {string} appName
91
+ * @param {Proxy} proxy
92
+ * @param {Object} [options]
93
+ */
94
+ async executeAll(scripts, appName, proxy, options = {}) {
95
+ for (const script of scripts) {
96
+ let text = script.content;
97
+
98
+ if (!text && script.src) {
99
+ logger.wuDebug(`[ScriptExecutor] Fetching external script: ${script.src}`);
100
+ text = await this.fetchScript(script.src);
101
+ }
102
+
103
+ if (text && text.trim()) {
104
+ this.execute(text, appName, proxy, {
105
+ ...options,
106
+ sourceUrl: script.src || options.sourceUrl || ''
107
+ });
108
+ }
109
+ }
110
+
111
+ logger.wuDebug(`[ScriptExecutor] Executed ${scripts.length} scripts for ${appName}`);
112
+ }
113
+ }