@ape-egg/vibe 1.3.2 → 1.6.1
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/CHANGELOG.md +195 -0
- package/README.md +214 -16
- package/boot.js +0 -1
- package/compiler/native/vibe-compiler-darwin-arm64 +0 -0
- package/compiler/src/Cargo.lock +720 -41
- package/compiler/src/Cargo.toml +12 -3
- package/compiler/src/compiler/PRE-RENDERING-IMPLEMENTATION.md +241 -0
- package/compiler/src/compiler/compile.rs +562 -180
- package/compiler/src/compiler/component_tagger.rs +234 -0
- package/compiler/src/compiler/iteration_optimizer.rs +351 -0
- package/compiler/src/compiler/js_analyzer.rs +572 -0
- package/compiler/src/compiler/manifest_builder.rs +251 -26
- package/compiler/src/compiler/mod.rs +5 -1
- package/compiler/src/compiler/state_extractor.rs +140 -25
- package/compiler/src/compiler/value_stamper.rs +579 -88
- package/compiler/src/compiler/watcher.rs +579 -0
- package/compiler/src/config.rs +51 -8
- package/compiler/src/main.rs +47 -31
- package/compiler/src/parser/html.rs +229 -118
- package/component.js +23 -11
- package/package.json +1 -1
- package/runtime/cleanup.js +4 -4
- package/runtime/component.js +98 -21
- package/runtime/conditionals.js +2 -2
- package/runtime/constants.js +2 -1
- package/runtime/index.js +152 -30
- package/runtime/iterate.js +27 -5
- package/runtime/parse.js +2 -1
- package/runtime/pre-compiled-iterations.js +153 -0
- package/runtime/{hyperspeed.js → pre-compiled-manifest.js} +219 -133
- package/runtime/utils.js +2 -1
- package/test-results/.last-run.json +4 -0
- package/vibe.css +19 -0
- package/runtime/component-state.js +0 -63
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
// Shared utility for processing component state
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generate unique component ID
|
|
5
|
-
*/
|
|
6
|
-
export const generateComponentId = () => {
|
|
7
|
-
return `_c${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Transform variable declarations to property assignments
|
|
12
|
-
* let count = 0; → this.count = 0;
|
|
13
|
-
*/
|
|
14
|
-
const transformDeclarations = (code) => {
|
|
15
|
-
return code
|
|
16
|
-
// Transform: let varName = value;
|
|
17
|
-
.replace(/\b(let|const|var)\s+(\w+)\s*=\s*([^;]+);/g, 'this.$2 = $3;')
|
|
18
|
-
// Transform: let varName;
|
|
19
|
-
.replace(/\b(let|const|var)\s+(\w+)\s*;/g, 'this.$2 = undefined;');
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Execute component script and return state object
|
|
24
|
-
* @param {string} scriptContent - JavaScript code to execute
|
|
25
|
-
* @returns {object} - Component state object
|
|
26
|
-
*/
|
|
27
|
-
export const executeComponentScript = (scriptContent) => {
|
|
28
|
-
const componentState = {};
|
|
29
|
-
|
|
30
|
-
if (!scriptContent || !scriptContent.trim()) {
|
|
31
|
-
return componentState;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
// Transform declarations to property assignments
|
|
36
|
-
const transformed = transformDeclarations(scriptContent);
|
|
37
|
-
|
|
38
|
-
// Execute script with 'this' = componentState
|
|
39
|
-
const fn = new Function(transformed);
|
|
40
|
-
fn.call(componentState);
|
|
41
|
-
|
|
42
|
-
} catch (error) {
|
|
43
|
-
console.error('[vibe] Error executing component script:', error);
|
|
44
|
-
console.error('[vibe] Script content:', scriptContent);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return componentState;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Register component state in global store
|
|
52
|
-
* @param {string} componentId - Unique component identifier
|
|
53
|
-
* @param {object} state - Component state object
|
|
54
|
-
* @param {object} globalState - Global $ object
|
|
55
|
-
*/
|
|
56
|
-
export const registerComponentState = (componentId, state, globalState) => {
|
|
57
|
-
if (!globalState[componentId]) {
|
|
58
|
-
globalState[componentId] = state;
|
|
59
|
-
} else {
|
|
60
|
-
// Component already registered, merge new state
|
|
61
|
-
Object.assign(globalState[componentId], state);
|
|
62
|
-
}
|
|
63
|
-
};
|