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,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* seo-config Module
|
|
3
|
+
* ES6 Module for Blade Compiler
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const ViewState = function (view) {
|
|
7
|
+
const viewRef = view;
|
|
8
|
+
const states = [];
|
|
9
|
+
let stateIndex = 0;
|
|
10
|
+
const stateMap = [];
|
|
11
|
+
|
|
12
|
+
}
|
|
13
|
+
export const SEOTagConfig = {
|
|
14
|
+
"meta:title": [
|
|
15
|
+
{
|
|
16
|
+
tag: "title",
|
|
17
|
+
selector: "title",
|
|
18
|
+
attribute: "@content",
|
|
19
|
+
attrs: {}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
tag: "meta",
|
|
23
|
+
selector: "meta[name='title']",
|
|
24
|
+
attribute: "content",
|
|
25
|
+
attrs: {
|
|
26
|
+
"name": "title"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"meta:description": [
|
|
32
|
+
{
|
|
33
|
+
tag: "meta",
|
|
34
|
+
selector: "meta[name='description']",
|
|
35
|
+
attribute: "content",
|
|
36
|
+
attrs: {
|
|
37
|
+
"name": "description"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"meta:keywords": [
|
|
42
|
+
{
|
|
43
|
+
tag: "meta",
|
|
44
|
+
selector: "meta[name='keywords']",
|
|
45
|
+
attribute: "content",
|
|
46
|
+
attrs: {
|
|
47
|
+
"name": "keywords"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"link:meta:canonical": [
|
|
52
|
+
{
|
|
53
|
+
tag: "link",
|
|
54
|
+
selector: "link[rel='canonical']",
|
|
55
|
+
attribute: "href",
|
|
56
|
+
attrs: {
|
|
57
|
+
"rel": "canonical"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
],
|
|
61
|
+
"meta:robots": [
|
|
62
|
+
{
|
|
63
|
+
tag: "meta",
|
|
64
|
+
selector: "meta[name='robots']",
|
|
65
|
+
attribute: "content",
|
|
66
|
+
attrs: {
|
|
67
|
+
"name": "robots"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
"meta:author": [
|
|
72
|
+
{
|
|
73
|
+
tag: "meta",
|
|
74
|
+
selector: "meta[name='author']",
|
|
75
|
+
attribute: "content",
|
|
76
|
+
attrs: {
|
|
77
|
+
"name": "author"
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"meta:image": [
|
|
82
|
+
{
|
|
83
|
+
tag: "meta",
|
|
84
|
+
selector: "meta[name='image']",
|
|
85
|
+
attribute: "content",
|
|
86
|
+
attrs: {
|
|
87
|
+
"name": "image"
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
"meta:og:image": [
|
|
92
|
+
{
|
|
93
|
+
tag: "meta",
|
|
94
|
+
selector: "meta[property='og:image']",
|
|
95
|
+
attribute: "content",
|
|
96
|
+
attrs: {
|
|
97
|
+
"property": "og:image"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
],
|
|
101
|
+
"meta:og:title": [
|
|
102
|
+
{
|
|
103
|
+
tag: "meta",
|
|
104
|
+
selector: "meta[property='og:title']",
|
|
105
|
+
attribute: "content",
|
|
106
|
+
attrs: {
|
|
107
|
+
"property": "og:title"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"meta:og:description": [
|
|
112
|
+
{
|
|
113
|
+
tag: "meta",
|
|
114
|
+
selector: "meta[property='og:description']",
|
|
115
|
+
attribute: "content",
|
|
116
|
+
attrs: {
|
|
117
|
+
"property": "og:description"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
],
|
|
121
|
+
"meta:og:type": [
|
|
122
|
+
{
|
|
123
|
+
tag: "meta",
|
|
124
|
+
selector: "meta[property='og:type']",
|
|
125
|
+
attribute: "content",
|
|
126
|
+
attrs: {
|
|
127
|
+
"property": "og:type"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"meta:og:url": [
|
|
132
|
+
{
|
|
133
|
+
tag: "meta",
|
|
134
|
+
selector: "meta[property='og:url']",
|
|
135
|
+
attribute: "content",
|
|
136
|
+
attrs: {
|
|
137
|
+
"property": "og:url"
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
"meta:og:site_name": [
|
|
142
|
+
{
|
|
143
|
+
tag: "meta",
|
|
144
|
+
selector: "meta[property='og:site_name']",
|
|
145
|
+
attribute: "content",
|
|
146
|
+
attrs: {
|
|
147
|
+
"property": "og:site_name"
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
],
|
|
151
|
+
"meta:og:locale": [
|
|
152
|
+
{
|
|
153
|
+
tag: "meta",
|
|
154
|
+
selector: "meta[property='og:locale']",
|
|
155
|
+
attribute: "content",
|
|
156
|
+
attrs: {
|
|
157
|
+
"property": "og:locale"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"meta:article:published_time": [
|
|
162
|
+
{
|
|
163
|
+
tag: "meta",
|
|
164
|
+
selector: "meta[property='article:published_time']",
|
|
165
|
+
attribute: "content",
|
|
166
|
+
attrs: {
|
|
167
|
+
"property": "article:published_time"
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"meta:article:modified_time": [
|
|
172
|
+
{
|
|
173
|
+
tag: "meta",
|
|
174
|
+
selector: "meta[property='article:modified_time']",
|
|
175
|
+
attribute: "content",
|
|
176
|
+
attrs: {
|
|
177
|
+
"property": "article:modified_time"
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
],
|
|
181
|
+
"meta:article:section": [
|
|
182
|
+
{
|
|
183
|
+
tag: "meta",
|
|
184
|
+
selector: "meta[property='article:section']",
|
|
185
|
+
attribute: "content",
|
|
186
|
+
attrs: {
|
|
187
|
+
"property": "article:section"
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"meta:article:tag": [
|
|
192
|
+
{
|
|
193
|
+
tag: "meta",
|
|
194
|
+
selector: "meta[property='article:tag']",
|
|
195
|
+
attribute: "content",
|
|
196
|
+
attrs: {
|
|
197
|
+
"property": "article:tag"
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"meta:article:author": [
|
|
202
|
+
{
|
|
203
|
+
tag: "meta",
|
|
204
|
+
selector: "meta[property='article:author']",
|
|
205
|
+
attribute: "content",
|
|
206
|
+
attrs: {
|
|
207
|
+
"property": "article:author"
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
"meta:article:publisher": [
|
|
212
|
+
{
|
|
213
|
+
tag: "meta",
|
|
214
|
+
selector: "meta[property='article:publisher']",
|
|
215
|
+
attribute: "content",
|
|
216
|
+
attrs: {
|
|
217
|
+
"property": "article:publisher"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
],
|
|
221
|
+
"meta:article:image": [
|
|
222
|
+
{
|
|
223
|
+
tag: "meta",
|
|
224
|
+
selector: "meta[property='article:image']",
|
|
225
|
+
attribute: "content",
|
|
226
|
+
attrs: {
|
|
227
|
+
"property": "article:image"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
],
|
|
231
|
+
"meta:og:image:width": [
|
|
232
|
+
{
|
|
233
|
+
tag: "meta",
|
|
234
|
+
selector: "meta[property='og:image:width']",
|
|
235
|
+
attribute: "content",
|
|
236
|
+
attrs: {
|
|
237
|
+
"property": "og:image:width"
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
],
|
|
241
|
+
"meta:og:image:height": [
|
|
242
|
+
{
|
|
243
|
+
tag: "meta",
|
|
244
|
+
selector: "meta[property='og:image:height']",
|
|
245
|
+
attribute: "content",
|
|
246
|
+
attrs: {
|
|
247
|
+
"property": "og:image:height"
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
],
|
|
251
|
+
"meta:twitter:card": [
|
|
252
|
+
{
|
|
253
|
+
tag: "meta",
|
|
254
|
+
selector: "meta[name='twitter:card']",
|
|
255
|
+
attribute: "content",
|
|
256
|
+
attrs: {
|
|
257
|
+
"name": "twitter:card"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
],
|
|
261
|
+
"meta:twitter:label1": [
|
|
262
|
+
{
|
|
263
|
+
tag: "meta",
|
|
264
|
+
selector: "meta[name='twitter:label1']",
|
|
265
|
+
attribute: "content",
|
|
266
|
+
attrs: {
|
|
267
|
+
"name": "twitter:label1"
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
],
|
|
271
|
+
"meta:twitter:label2": [
|
|
272
|
+
{
|
|
273
|
+
tag: "meta",
|
|
274
|
+
selector: "meta[name='twitter:label2']",
|
|
275
|
+
attribute: "content",
|
|
276
|
+
attrs: {
|
|
277
|
+
"name": "twitter:label2"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
],
|
|
281
|
+
"twitter:data1": [
|
|
282
|
+
{
|
|
283
|
+
tag: "meta",
|
|
284
|
+
selector: "meta[name='twitter:data1']",
|
|
285
|
+
attribute: "content",
|
|
286
|
+
attrs: {
|
|
287
|
+
"name": "twitter:data1"
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
],
|
|
291
|
+
"twitter:data2": [
|
|
292
|
+
{
|
|
293
|
+
tag: "meta",
|
|
294
|
+
selector: "meta[name='twitter:data2']",
|
|
295
|
+
attribute: "content",
|
|
296
|
+
attrs: {
|
|
297
|
+
"name": "twitter:data2"
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
],
|
|
301
|
+
"link:rel:shortlink": [
|
|
302
|
+
{
|
|
303
|
+
tag: "meta",
|
|
304
|
+
selector: "meta[name='rel:shortlink']",
|
|
305
|
+
attribute: "content",
|
|
306
|
+
attrs: {
|
|
307
|
+
"rel": "shortlink"
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
],
|
|
311
|
+
"link:rel:alternate": [
|
|
312
|
+
{
|
|
313
|
+
tag: "meta",
|
|
314
|
+
selector: "meta[name='rel:alternate']",
|
|
315
|
+
attribute: "content",
|
|
316
|
+
attrs: {
|
|
317
|
+
"rel": "alternate"
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { uniqId } from "../helpers/utils";
|
|
2
|
+
|
|
3
|
+
export const SectionEngine = function (name, content, type = 'string', View) {
|
|
4
|
+
const SECTION_ID = uniqId();
|
|
5
|
+
const placholder = `<section-placeholder id="${SECTION_ID}" data-section-name="${name}"></section-placeholder>`
|
|
6
|
+
const placeholderElement = View.templateToDom(placholder);
|
|
7
|
+
const templator = document.createElement('template');
|
|
8
|
+
templator.innerHTML = content;
|
|
9
|
+
const frag = templator.content;
|
|
10
|
+
/**
|
|
11
|
+
* @type {NodeList}
|
|
12
|
+
*/
|
|
13
|
+
const refs = [];
|
|
14
|
+
|
|
15
|
+
if (type === 'html') {
|
|
16
|
+
for (let i = 0; i < frag.childNodes.length; i++) {
|
|
17
|
+
const node = frag.childNodes[i];
|
|
18
|
+
refs.push(node);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
this.name = name;
|
|
22
|
+
this.content = frag;
|
|
23
|
+
this.refs = refs;
|
|
24
|
+
this.placeholder = placholder;
|
|
25
|
+
this.sectionId = SECTION_ID;
|
|
26
|
+
this.isInserted = false;
|
|
27
|
+
this.viewEngine = null;
|
|
28
|
+
this.textContent = type === 'html' ? placholder : content;
|
|
29
|
+
this.updateRefs = function () {
|
|
30
|
+
const fragment = templator.content;
|
|
31
|
+
refs.length = 0;
|
|
32
|
+
for (let i = 0; i < fragment.childNodes.length; i++) {
|
|
33
|
+
const node = fragment.childNodes[i];
|
|
34
|
+
refs.push(node);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
this.replace = function () {
|
|
38
|
+
const placeholder = document.querySelector(`#${this.sectionId}`);
|
|
39
|
+
if (placeholder && placeholder.parentNode) {
|
|
40
|
+
for (let i = refs.length - 1; i >= 0; i--) {
|
|
41
|
+
const node = refs[i];
|
|
42
|
+
placeholder.parentNode.insertBefore(node, placeholder);
|
|
43
|
+
}
|
|
44
|
+
placeholder.remove();
|
|
45
|
+
this.isInserted = true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
this.rerender = function (template) {
|
|
49
|
+
if (refs.length > 0) {
|
|
50
|
+
refs[0].parentNode.insertBefore(placeholderElement, refs[0]);
|
|
51
|
+
}
|
|
52
|
+
this.removeRefNodes();
|
|
53
|
+
templator.innerHTML = template;
|
|
54
|
+
this.updateRefs();
|
|
55
|
+
this.replace();
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
this.removeRefNodes = function () {
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < refs.length; i++) {
|
|
62
|
+
const node = refs[i];
|
|
63
|
+
node.remove();
|
|
64
|
+
}
|
|
65
|
+
refs.length = 0;
|
|
66
|
+
}
|
|
67
|
+
this.setViewEngine = function (viewEngine) {
|
|
68
|
+
this.viewEngine = viewEngine;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
};
|
|
73
|
+
SectionEngine.prototype.toString = function () {
|
|
74
|
+
return this.textContent;
|
|
75
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Template Engine for managing and rendering templates
|
|
3
|
+
*/
|
|
4
|
+
export class TemplateEngine {
|
|
5
|
+
constructor(App, View, viewInstance, subscribe) {
|
|
6
|
+
this.App = App;
|
|
7
|
+
this.View = View;
|
|
8
|
+
this.viewInstance = viewInstance;
|
|
9
|
+
this.subscribe = subscribe;
|
|
10
|
+
this.templates = {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Set templates
|
|
15
|
+
* @param {Object} templates - Object of template functions
|
|
16
|
+
*/
|
|
17
|
+
setTemplates(templates) {
|
|
18
|
+
this.templates = templates;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Render a template
|
|
23
|
+
* @param {string} name - Template name
|
|
24
|
+
* @param {Object} context - Context data
|
|
25
|
+
* @param {Array|Object} data - Template data
|
|
26
|
+
* @returns {string} Rendered template
|
|
27
|
+
*/
|
|
28
|
+
render(name, context, data = []) {
|
|
29
|
+
if (!this.templates[name]) {
|
|
30
|
+
console.warn(`Template '${name}' not found`);
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
try {
|
|
35
|
+
const templateFn = this.templates[name];
|
|
36
|
+
return templateFn(context, data);
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(`Error rendering template '${name}':`, error);
|
|
39
|
+
return `<div class="template-error">Template '${name}' error: ${error.message}</div>`;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check if template exists
|
|
45
|
+
* @param {string} name - Template name
|
|
46
|
+
* @returns {boolean} True if template exists
|
|
47
|
+
*/
|
|
48
|
+
hasTemplate(name) {
|
|
49
|
+
return !!this.templates[name];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Get template
|
|
54
|
+
* @param {string} name - Template name
|
|
55
|
+
* @returns {Function|null} Template function or null
|
|
56
|
+
*/
|
|
57
|
+
getTemplate(name) {
|
|
58
|
+
return this.templates[name] || null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Remove template
|
|
63
|
+
* @param {string} name - Template name
|
|
64
|
+
*/
|
|
65
|
+
removeTemplate(name) {
|
|
66
|
+
delete this.templates[name];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Clear all templates
|
|
71
|
+
*/
|
|
72
|
+
clearTemplates() {
|
|
73
|
+
this.templates = {};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get all template names
|
|
78
|
+
* @returns {Array} Array of template names
|
|
79
|
+
*/
|
|
80
|
+
getTemplateNames() {
|
|
81
|
+
return Object.keys(this.templates);
|
|
82
|
+
}
|
|
83
|
+
}
|