onelaraveljs 1.0.0
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/README.md +87 -0
- package/docs/integration_analysis.md +116 -0
- package/docs/onejs_analysis.md +108 -0
- package/docs/optimization_implementation_group2.md +458 -0
- package/docs/optimization_plan.md +130 -0
- package/index.js +16 -0
- package/package.json +13 -0
- package/src/app.js +61 -0
- package/src/core/API.js +72 -0
- package/src/core/ChildrenRegistry.js +410 -0
- package/src/core/DOMBatcher.js +207 -0
- package/src/core/ErrorBoundary.js +226 -0
- package/src/core/EventDelegator.js +416 -0
- package/src/core/Helper.js +817 -0
- package/src/core/LoopContext.js +97 -0
- package/src/core/OneDOM.js +246 -0
- package/src/core/OneMarkup.js +444 -0
- package/src/core/Router.js +996 -0
- package/src/core/SEOConfig.js +321 -0
- package/src/core/SectionEngine.js +75 -0
- package/src/core/TemplateEngine.js +83 -0
- package/src/core/View.js +273 -0
- package/src/core/ViewConfig.js +229 -0
- package/src/core/ViewController.js +1410 -0
- package/src/core/ViewControllerOptimized.js +164 -0
- package/src/core/ViewIdentifier.js +361 -0
- package/src/core/ViewLoader.js +272 -0
- package/src/core/ViewManager.js +1962 -0
- package/src/core/ViewState.js +761 -0
- package/src/core/ViewSystem.js +301 -0
- package/src/core/ViewTemplate.js +4 -0
- package/src/core/helpers/BindingHelper.js +239 -0
- package/src/core/helpers/ConfigHelper.js +37 -0
- package/src/core/helpers/EventHelper.js +172 -0
- package/src/core/helpers/LifecycleHelper.js +17 -0
- package/src/core/helpers/ReactiveHelper.js +169 -0
- package/src/core/helpers/RenderHelper.js +15 -0
- package/src/core/helpers/ResourceHelper.js +89 -0
- package/src/core/helpers/TemplateHelper.js +11 -0
- package/src/core/managers/BindingManager.js +671 -0
- package/src/core/managers/ConfigurationManager.js +136 -0
- package/src/core/managers/EventManager.js +309 -0
- package/src/core/managers/LifecycleManager.js +356 -0
- package/src/core/managers/ReactiveManager.js +334 -0
- package/src/core/managers/RenderEngine.js +292 -0
- package/src/core/managers/ResourceManager.js +441 -0
- package/src/core/managers/ViewHierarchyManager.js +258 -0
- package/src/core/managers/ViewTemplateManager.js +127 -0
- package/src/core/reactive/ReactiveComponent.js +592 -0
- package/src/core/services/EventService.js +418 -0
- package/src/core/services/HttpService.js +106 -0
- package/src/core/services/LoggerService.js +57 -0
- package/src/core/services/StateService.js +512 -0
- package/src/core/services/StorageService.js +856 -0
- package/src/core/services/StoreService.js +258 -0
- package/src/core/services/TemplateDetectorService.js +361 -0
- package/src/core/services/Test.js +18 -0
- package/src/helpers/devWarnings.js +205 -0
- package/src/helpers/performance.js +226 -0
- package/src/helpers/utils.js +287 -0
- package/src/init.js +343 -0
- package/src/plugins/auto-plugin.js +34 -0
- package/src/services/Test.js +18 -0
- package/src/types/index.js +193 -0
- package/src/utils/date-helper.js +51 -0
- package/src/utils/helpers.js +39 -0
- package/src/utils/validation.js +32 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViewTemplateManager - Manages view templates, wrappers, blocks, and sections
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { ATTR } from '../ViewConfig.js';
|
|
6
|
+
|
|
7
|
+
export class ViewTemplateManager {
|
|
8
|
+
constructor(controller) {
|
|
9
|
+
this.controller = controller;
|
|
10
|
+
|
|
11
|
+
// Wrapper configuration
|
|
12
|
+
this.wrapTag = null;
|
|
13
|
+
this.wrapperConfig = {
|
|
14
|
+
enable: false,
|
|
15
|
+
tag: null,
|
|
16
|
+
subscribe: true,
|
|
17
|
+
attributes: {}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Section management
|
|
21
|
+
this.sections = {};
|
|
22
|
+
this.cachedSections = {};
|
|
23
|
+
this.renderedSections = {};
|
|
24
|
+
|
|
25
|
+
// Child view configuration
|
|
26
|
+
this.childrenConfig = [];
|
|
27
|
+
this.childrenIndex = 0;
|
|
28
|
+
this.refreshChildrenIndex = 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
initializeWrapperConfig(config) {
|
|
32
|
+
this.wrapperConfig = {
|
|
33
|
+
...this.wrapperConfig,
|
|
34
|
+
...(typeof config === 'object' ? config : {})
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resetChildrenIndex() {
|
|
39
|
+
this.childrenIndex = 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
wrapperAttribute() {
|
|
43
|
+
return ` ${ATTR.KEYS.VIEW_WRAPPER}="${this.controller.id}"`;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
startWrapper(tag = null, attributes = {}) {
|
|
47
|
+
this.wrapTag = null;
|
|
48
|
+
|
|
49
|
+
if (typeof tag === 'string') {
|
|
50
|
+
this.wrapTag = tag;
|
|
51
|
+
} else if (typeof tag === 'object' && tag !== null) {
|
|
52
|
+
this.wrapTag = tag.tag || 'div';
|
|
53
|
+
delete tag.tag;
|
|
54
|
+
attributes = { ...attributes, ...tag.attributes };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (typeof attributes === 'string' || !attributes) {
|
|
58
|
+
attributes = {};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (this.wrapTag) {
|
|
62
|
+
const attrString = Object.entries(attributes)
|
|
63
|
+
.map(([key, value]) => `${key}="${value}"`)
|
|
64
|
+
.join(' ');
|
|
65
|
+
return `<${this.wrapTag} data-wrap-view="${this.controller.path}" data-wrap-id="${this.controller.id}" ${attrString}>`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return `<!-- [one:view name="${this.controller.path}" id="${this.controller.id}"] -->`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
endWrapper() {
|
|
72
|
+
if (this.wrapTag) {
|
|
73
|
+
const closeTag = `</${this.wrapTag}>`;
|
|
74
|
+
this.wrapTag = null;
|
|
75
|
+
return closeTag;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
this.wrapTag = null;
|
|
79
|
+
return `<!-- [/one:view] -->`;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
addBlock(name, attributes = {}, content) {
|
|
83
|
+
if (typeof name !== 'string' || name === '') {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const blockContent = `<!-- [one:block name="${this.controller.path}" ref="${this.controller.id}"] -->${content}<!-- [/one:block] -->`;
|
|
88
|
+
return this.controller.App.View.section("block." + name, blockContent, 'html');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
useBlock(name, defaultValue = '') {
|
|
92
|
+
if (typeof name !== 'string' || name === '') {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const content = this.controller.App.View.yield("block." + name, defaultValue);
|
|
97
|
+
return `<!-- [one:subscribe type="block" key="${name}"] -->${content}<!-- [/one:subscribe] -->`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
mountBlock(name, defaultValue = '') {
|
|
101
|
+
return this.useBlock(name, defaultValue);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
subscribeBlock(name, defaultValue = '') {
|
|
105
|
+
return ` data-subscribe-block="${name}"`;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
section(name, content, type) {
|
|
109
|
+
this.cachedSections[name] = content;
|
|
110
|
+
return this.controller.App.View.section(name, content, type);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
yieldSection(name, defaultValue = '') {
|
|
114
|
+
return this.controller.App.View.yield(name, defaultValue);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
yieldContent(name, defaultValue = '') {
|
|
118
|
+
return this.controller.App.View.yieldContent(name, defaultValue);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
storeChildrenReferences(children) {
|
|
122
|
+
children.forEach(child => {
|
|
123
|
+
const { name, id } = child;
|
|
124
|
+
this.childrenConfig.push({ name, id });
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|