vaderjs 1.3.3-7924566dd811 → 1.3.3-7b27417dd2e1
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/client/index.js +221 -222
- package/package.json +4 -2
- package/runtime/router.js +1 -1
- package/runtime/vader.js +1 -1
- package/vader.js +462 -434
package/client/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {Function} callback
|
|
6
6
|
*/
|
|
7
7
|
export const strictMount = (key, callback) => {
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -26,15 +26,15 @@ export const strictMount = (key, callback) => {
|
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
28
|
export const $metdata = {
|
|
29
|
-
title:'',
|
|
29
|
+
title: '',
|
|
30
30
|
styles,
|
|
31
|
-
description:'',
|
|
32
|
-
keywords:'',
|
|
33
|
-
author:'',
|
|
34
|
-
image:'',
|
|
35
|
-
url:'',
|
|
36
|
-
robot:'',
|
|
37
|
-
manifest:'',
|
|
31
|
+
description: '',
|
|
32
|
+
keywords: '',
|
|
33
|
+
author: '',
|
|
34
|
+
image: '',
|
|
35
|
+
url: '',
|
|
36
|
+
robot: '',
|
|
37
|
+
manifest: '',
|
|
38
38
|
tags: []
|
|
39
39
|
|
|
40
40
|
}
|
|
@@ -48,9 +48,9 @@ export const $prerender = {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
54
|
/**
|
|
55
55
|
* Represents a component in the Vader framework.
|
|
56
56
|
*/
|
|
@@ -69,52 +69,52 @@ export class Component {
|
|
|
69
69
|
* @private
|
|
70
70
|
*/
|
|
71
71
|
this.components = {};
|
|
72
|
-
this.mounted = false;
|
|
72
|
+
this.mounted = false;
|
|
73
73
|
this.checkIFMounted();
|
|
74
74
|
this.memoizes = []
|
|
75
75
|
/**
|
|
76
76
|
* @private
|
|
77
77
|
*/
|
|
78
|
-
this.functions = []
|
|
78
|
+
this.functions = []
|
|
79
79
|
this.children = []
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
|
|
81
|
+
|
|
82
82
|
/**
|
|
83
83
|
* Parent of the current component.
|
|
84
84
|
* @type {Component}
|
|
85
85
|
*/
|
|
86
|
-
this.parentNode =
|
|
87
|
-
|
|
86
|
+
this.parentNode = {}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Request object.
|
|
90
|
+
*/
|
|
91
|
+
this.request = {
|
|
88
92
|
/**
|
|
89
|
-
*
|
|
93
|
+
* @type {string}
|
|
94
|
+
* @description The headers for the current route
|
|
90
95
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* @type {string}
|
|
114
|
-
* @description query: query object for the current route ?name=hello -> {name: 'hello'}
|
|
115
|
-
*/
|
|
116
|
-
query: {},
|
|
117
|
-
},
|
|
96
|
+
headers: {},
|
|
97
|
+
/**
|
|
98
|
+
* @type {string}
|
|
99
|
+
* @description The method for the current route
|
|
100
|
+
*/
|
|
101
|
+
method: "GET",
|
|
102
|
+
/**
|
|
103
|
+
* @type {string}
|
|
104
|
+
* @description params for the given route /:id/:name etc
|
|
105
|
+
*/
|
|
106
|
+
params: {},
|
|
107
|
+
/**
|
|
108
|
+
* @type {string}
|
|
109
|
+
* @description path: current route path
|
|
110
|
+
*/
|
|
111
|
+
path: "",
|
|
112
|
+
/**
|
|
113
|
+
* @type {string}
|
|
114
|
+
* @description query: query object for the current route ?name=hello -> {name: 'hello'}
|
|
115
|
+
*/
|
|
116
|
+
query: {},
|
|
117
|
+
},
|
|
118
118
|
/**
|
|
119
119
|
* @type {string}
|
|
120
120
|
* @description The response object for the current route
|
|
@@ -125,90 +125,90 @@ export class Component {
|
|
|
125
125
|
* @description This method allows you to send json data to the client
|
|
126
126
|
* @param {*} data
|
|
127
127
|
*/
|
|
128
|
-
json: (data) => {},
|
|
128
|
+
json: (data) => { },
|
|
129
129
|
/**
|
|
130
130
|
* @method send
|
|
131
131
|
* @description This method allows you to send text data to the client
|
|
132
132
|
* @param {*} data
|
|
133
133
|
*/
|
|
134
|
-
send: (data) => {},
|
|
134
|
+
send: (data) => { },
|
|
135
135
|
/**
|
|
136
136
|
* @method redirect
|
|
137
137
|
* @description This method allows you to redirect the client to a new route
|
|
138
138
|
* @param {*} path
|
|
139
139
|
*/
|
|
140
|
-
redirect: (path) => {},
|
|
140
|
+
redirect: (path) => { },
|
|
141
141
|
/**
|
|
142
142
|
* @method render
|
|
143
143
|
* @description render a new component to the client
|
|
144
144
|
* @param {*} Component
|
|
145
145
|
*/
|
|
146
|
-
render: async (Component) => {},
|
|
146
|
+
render: async (Component) => { },
|
|
147
147
|
/**
|
|
148
148
|
* @method log
|
|
149
149
|
* @description This method is used to log the request and response
|
|
150
150
|
* @param {String} type
|
|
151
151
|
*/
|
|
152
|
-
log: (type) => {},
|
|
152
|
+
log: (type) => { },
|
|
153
153
|
/**
|
|
154
154
|
* @method setQuery
|
|
155
155
|
* @description This method is used to set the query object for the current route
|
|
156
156
|
*/
|
|
157
|
-
setQuery: (query) => {},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
157
|
+
setQuery: (query) => { },
|
|
158
|
+
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* @method router
|
|
162
|
+
* @description use router methods directly from the parent component
|
|
163
|
+
*/
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
this.router = {
|
|
166
166
|
/**
|
|
167
167
|
* @method use
|
|
168
168
|
* @description add a middleware to the current route
|
|
169
169
|
* @param {Function} middleware
|
|
170
170
|
* @returns {void}
|
|
171
171
|
*/
|
|
172
|
-
use: (/**@type {Function} */ middleware) => {},
|
|
173
|
-
|
|
174
|
-
}
|
|
172
|
+
use: (/**@type {Function} */ middleware) => { },
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
175
|
|
|
176
|
-
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
176
|
+
/**
|
|
177
|
+
* @method createComponent
|
|
178
|
+
* @description This method allows you to create a component from a class or function
|
|
179
|
+
* @param {Component} component
|
|
180
|
+
* @param {Object} props
|
|
181
|
+
* @param {Array} children
|
|
182
|
+
*/
|
|
183
183
|
createComponent(/**@type {Component}**/component, props, children) {
|
|
184
|
-
|
|
184
|
+
|
|
185
185
|
}
|
|
186
186
|
/**
|
|
187
187
|
* @private
|
|
188
188
|
*/
|
|
189
|
-
reset(){
|
|
190
|
-
|
|
189
|
+
reset() {
|
|
190
|
+
|
|
191
191
|
}
|
|
192
192
|
/**
|
|
193
193
|
* @method memoize
|
|
194
194
|
* @description This method allows you to memoize a component which when rerendered will not be reinstantiated
|
|
195
195
|
* @param {Component} component
|
|
196
196
|
*/
|
|
197
|
-
memoize(/**@type {Component}**/component){
|
|
198
|
-
|
|
197
|
+
memoize(/**@type {Component}**/component) {
|
|
198
|
+
|
|
199
199
|
}
|
|
200
200
|
/**
|
|
201
201
|
* @method parseStyle
|
|
202
202
|
* @description This method allows you to parse a jsx style object to a string
|
|
203
203
|
* @param {object} styles
|
|
204
204
|
*/
|
|
205
|
-
parseStyle(styles){
|
|
206
|
-
|
|
205
|
+
parseStyle(styles) {
|
|
206
|
+
|
|
207
207
|
}
|
|
208
208
|
/**
|
|
209
209
|
* @private
|
|
210
210
|
*/
|
|
211
|
-
bindMount(){
|
|
211
|
+
bindMount() {
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/**
|
|
@@ -216,29 +216,29 @@ export class Component {
|
|
|
216
216
|
* @private
|
|
217
217
|
*/
|
|
218
218
|
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
domDifference(oldDom, newDom) {
|
|
220
|
+
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* @private
|
|
224
224
|
* @param {*} diff
|
|
225
225
|
*/
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
226
|
+
|
|
227
|
+
updateChangedElements(diff) {
|
|
228
|
+
|
|
229
229
|
}
|
|
230
|
-
|
|
230
|
+
|
|
231
231
|
/**
|
|
232
232
|
* @method hydrate
|
|
233
233
|
* @description This method allows you to hydrate a component
|
|
234
234
|
* @private
|
|
235
235
|
* @param {*} hook
|
|
236
236
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
hydrate(hook) {
|
|
238
|
+
|
|
239
239
|
}
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
|
|
241
|
+
|
|
242
242
|
/**
|
|
243
243
|
* @method patch
|
|
244
244
|
* @description This method allows you to patch the dom
|
|
@@ -246,14 +246,14 @@ export class Component {
|
|
|
246
246
|
* @param {*} oldElements
|
|
247
247
|
* @param {*} newElements
|
|
248
248
|
*/
|
|
249
|
-
|
|
249
|
+
|
|
250
250
|
patch(oldElements, newElements) {
|
|
251
|
-
|
|
251
|
+
|
|
252
252
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
|
|
257
257
|
|
|
258
258
|
/**
|
|
259
259
|
* Handles an object by parsing it as JSON and evaluating it.
|
|
@@ -262,10 +262,10 @@ export class Component {
|
|
|
262
262
|
* @prvate
|
|
263
263
|
*/
|
|
264
264
|
handleObject(obj) {
|
|
265
|
-
|
|
265
|
+
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
|
|
268
|
+
|
|
269
269
|
|
|
270
270
|
/**
|
|
271
271
|
* Binds a function to the component.
|
|
@@ -276,11 +276,11 @@ export class Component {
|
|
|
276
276
|
* @param {...*} params - The parameters.
|
|
277
277
|
* @returns {string} - A valid inline JS function call.
|
|
278
278
|
*/
|
|
279
|
-
bind(funcTion,isTerny, jsx,ref, paramNames, ...params) {
|
|
280
|
-
|
|
279
|
+
bind(funcTion, isTerny, jsx, ref, paramNames, ...params) {
|
|
280
|
+
|
|
281
281
|
}
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
|
|
283
|
+
|
|
284
284
|
|
|
285
285
|
/**
|
|
286
286
|
* useState hook.
|
|
@@ -290,46 +290,46 @@ export class Component {
|
|
|
290
290
|
* @param {T} initialState - The initial state value.
|
|
291
291
|
* @returns {[() => T, (newValue: T, hook: Function) => void]} - A tuple with getter and setter functions.
|
|
292
292
|
*/
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
293
|
+
useState(key, initialState) {
|
|
294
|
+
if (!this.state[key]) {
|
|
295
|
+
this.state[key] = initialState;
|
|
296
|
+
}
|
|
297
297
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
298
|
+
/**
|
|
299
|
+
* Get the current state value.
|
|
300
|
+
*
|
|
301
|
+
* @returns {T} The current state value.
|
|
302
|
+
*/
|
|
303
|
+
let updatedValue = () => this.state[key];
|
|
304
304
|
|
|
305
|
-
|
|
305
|
+
const getValue = updatedValue();
|
|
306
306
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
307
|
+
/**
|
|
308
|
+
* Set a new value for the state.
|
|
309
|
+
*
|
|
310
|
+
* @param {T} newValue - The new value to set.
|
|
311
|
+
* @param {Function} hook - The hook to hydrate after setting the value.
|
|
312
|
+
*/
|
|
313
|
+
const set = (newValue, hook) => {
|
|
314
|
+
this.state[key] = newValue;
|
|
315
|
+
this.hydrate(hook);
|
|
316
|
+
};
|
|
317
317
|
|
|
318
|
-
|
|
319
318
|
|
|
320
|
-
return [getValue, set];
|
|
321
|
-
}
|
|
322
319
|
|
|
323
|
-
|
|
320
|
+
return [getValue, set];
|
|
321
|
+
}
|
|
324
322
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* useRef hook.
|
|
327
|
+
* @param {string} key
|
|
328
|
+
* @param {any} initialState
|
|
329
|
+
* @returns {{ current: HTMLElement|any, bind: string }} - An object containing the current value and a bind string.
|
|
330
|
+
*/
|
|
331
331
|
useRef(key = null, initialState) {
|
|
332
|
-
|
|
332
|
+
|
|
333
333
|
}
|
|
334
334
|
|
|
335
335
|
/**
|
|
@@ -340,17 +340,17 @@ export class Component {
|
|
|
340
340
|
* @returns {[*, (newValue: *, hook: Function) => void]} - A tuple with getter and setter functions.
|
|
341
341
|
* **/
|
|
342
342
|
|
|
343
|
-
|
|
344
|
-
|
|
343
|
+
useReducer(key = null, initialState, func = null) {
|
|
344
|
+
|
|
345
345
|
}
|
|
346
|
-
|
|
346
|
+
|
|
347
347
|
|
|
348
348
|
/**
|
|
349
349
|
* Placeholder for content to be rendered.
|
|
350
350
|
* @method render
|
|
351
351
|
* @returns {string} - The rendered content.
|
|
352
352
|
*/
|
|
353
|
-
render() {}
|
|
353
|
+
render() { }
|
|
354
354
|
|
|
355
355
|
/**
|
|
356
356
|
* Checks if the component is mounted and triggers the onMount method.
|
|
@@ -359,15 +359,15 @@ export class Component {
|
|
|
359
359
|
checkIFMounted() {
|
|
360
360
|
let observer = new MutationObserver((mutations) => {
|
|
361
361
|
mutations.forEach((mutation) => {
|
|
362
|
-
|
|
362
|
+
|
|
363
363
|
if (mutation.target.querySelector(`[key="${this.key}"]`) && !this.mounted) {
|
|
364
|
-
this.onMount();
|
|
365
|
-
this.mounted = true;
|
|
364
|
+
this.onMount();
|
|
365
|
+
this.mounted = true;
|
|
366
366
|
}
|
|
367
|
-
|
|
368
|
-
if(Array.from(mutation.removedNodes).find((node) => node.attributes && node.attributes.key && node.attributes.key.value === this.key)){
|
|
367
|
+
|
|
368
|
+
if (Array.from(mutation.removedNodes).find((node) => node.attributes && node.attributes.key && node.attributes.key.value === this.key)) {
|
|
369
369
|
this.onUnmount();
|
|
370
|
-
this.reset();
|
|
370
|
+
this.reset();
|
|
371
371
|
}
|
|
372
372
|
})
|
|
373
373
|
})
|
|
@@ -381,16 +381,16 @@ export class Component {
|
|
|
381
381
|
* Method that is called when the component is mounted.
|
|
382
382
|
* @method onMount
|
|
383
383
|
*/
|
|
384
|
-
onMount() {}
|
|
384
|
+
onMount() { }
|
|
385
385
|
/**
|
|
386
386
|
* Method that is called when the component is unmounted.
|
|
387
387
|
* @method onUnmount
|
|
388
388
|
*/
|
|
389
|
-
onUnmount() {}
|
|
389
|
+
onUnmount() { }
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
|
|
393
|
-
|
|
392
|
+
|
|
393
|
+
|
|
394
394
|
/**
|
|
395
395
|
* useState hook.
|
|
396
396
|
*
|
|
@@ -424,7 +424,7 @@ export const useState = (key, initialState) => {
|
|
|
424
424
|
return [states[key], set];
|
|
425
425
|
};
|
|
426
426
|
|
|
427
|
-
|
|
427
|
+
|
|
428
428
|
|
|
429
429
|
/**
|
|
430
430
|
* @method useReducer
|
|
@@ -433,16 +433,16 @@ export const useState = (key, initialState) => {
|
|
|
433
433
|
* @returns {Array} [value, set]
|
|
434
434
|
*/
|
|
435
435
|
export const useReducer = (/**@type {*}**/initialState, /**@type {function}**/reducer) => {
|
|
436
|
-
return [initialState, (newValue) => {}];
|
|
436
|
+
return [initialState, (newValue) => { }];
|
|
437
437
|
};
|
|
438
|
-
|
|
439
438
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* useRef hook.
|
|
442
|
+
* @param {string} key
|
|
443
|
+
* @param {any} initialState
|
|
444
|
+
* @returns {{ current: HTMLElement|any, bind: string }} - An object containing the current value and a bind string.
|
|
445
|
+
*/
|
|
446
446
|
export const useRef = (initialState) => {
|
|
447
447
|
return {
|
|
448
448
|
/**
|
|
@@ -458,34 +458,33 @@ export const useRef = (initialState) => {
|
|
|
458
458
|
};
|
|
459
459
|
};
|
|
460
460
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
461
|
+
/**
|
|
462
|
+
* @class Link
|
|
463
|
+
* @description Allows you to seamlessly navigate to different pages in your application
|
|
464
|
+
* @extends Component
|
|
465
|
+
* @example
|
|
466
|
+
* <Link href="/some-path" class="custom-link" style="color: blue;">Click me!</Link>
|
|
467
|
+
*/
|
|
468
468
|
export class Link extends Component {
|
|
469
469
|
/**
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
*/
|
|
470
|
+
* @constructor
|
|
471
|
+
* @param {object} props - Component props
|
|
472
|
+
* @param {string} props.href - URL for the link
|
|
473
|
+
* @param {string} props.action - Action to be performed when the link is clicked
|
|
474
|
+
* @param {string} [props.class] - CSS class for the link
|
|
475
|
+
* @param {string} [props.style] - Inline CSS style for the link
|
|
476
|
+
* @param {string} [props.children] - Content to be displayed inside the link
|
|
477
|
+
*/
|
|
479
478
|
constructor(props) {
|
|
480
479
|
super(props);
|
|
481
|
-
|
|
482
480
|
/**
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
481
|
+
* @type {object}
|
|
482
|
+
* @property {string} href - URL for the link
|
|
483
|
+
* @property {string} [action] - Action to be performed when the link is clicked
|
|
484
|
+
* @property {string} [class] - CSS class for the link
|
|
485
|
+
* @property {string} [style] - Inline CSS style for the link
|
|
486
|
+
* @property {string} [children] - Content to be displayed inside the link
|
|
487
|
+
*/
|
|
489
488
|
this.props = props;
|
|
490
489
|
|
|
491
490
|
/**
|
|
@@ -504,20 +503,20 @@ export class Link extends Component {
|
|
|
504
503
|
* @returns {string} - Rendered HTML for the Link component
|
|
505
504
|
*/
|
|
506
505
|
render() {
|
|
507
|
-
|
|
506
|
+
|
|
508
507
|
return this.link.outerHTML;
|
|
509
508
|
}
|
|
510
509
|
}
|
|
511
510
|
|
|
512
511
|
|
|
513
512
|
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
513
|
+
/**
|
|
514
|
+
* @class Image
|
|
515
|
+
* @description Image component
|
|
516
|
+
* @extends Component
|
|
517
|
+
* @example
|
|
518
|
+
* <Image src="https://via.placeholder.com/150" alt="image" />
|
|
519
|
+
*/
|
|
521
520
|
export class Image extends Component {
|
|
522
521
|
/**
|
|
523
522
|
* @constructor
|
|
@@ -586,32 +585,32 @@ export class Image extends Component {
|
|
|
586
585
|
*/
|
|
587
586
|
render() {
|
|
588
587
|
// adjust width and height to the user's screen size
|
|
589
|
-
|
|
588
|
+
|
|
590
589
|
|
|
591
590
|
return this.img.outerHTML;
|
|
592
591
|
}
|
|
593
592
|
}
|
|
594
593
|
|
|
595
594
|
export class Head extends Component {
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
595
|
+
/**
|
|
596
|
+
* @constructor
|
|
597
|
+
* @param {object} props - Component props
|
|
598
|
+
* @param {string} props.children - Content to be displayed inside the head
|
|
599
|
+
*/
|
|
601
600
|
constructor(props) {
|
|
602
601
|
super(props);
|
|
603
602
|
this.props = {
|
|
604
|
-
children: props.children,
|
|
603
|
+
children: props.children,
|
|
605
604
|
}
|
|
606
605
|
this.key = 'head';
|
|
607
606
|
this.head = document.createElement('head');
|
|
608
607
|
}
|
|
609
608
|
|
|
610
|
-
|
|
609
|
+
|
|
611
610
|
|
|
612
611
|
render() {
|
|
613
612
|
this.head.innerHTML = this.props.children;
|
|
614
|
-
return
|
|
613
|
+
return this.head.outerHTML;
|
|
615
614
|
}
|
|
616
615
|
|
|
617
616
|
onMount() {
|
|
@@ -621,32 +620,32 @@ export class Head extends Component {
|
|
|
621
620
|
}
|
|
622
621
|
|
|
623
622
|
export class Script extends Component {
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
}
|
|
634
|
-
this.key = 'script';
|
|
635
|
-
this.script = document.createElement('script');
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
render() {
|
|
641
|
-
this.script.innerHTML = this.props.children.split('\n').join(';\n');
|
|
642
|
-
return this.script.outerHTML;
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
onMount() {
|
|
646
|
-
document.head.appendChild(this.script);
|
|
647
|
-
document.body.querySelector(`[key="${this.key}"]`).remove();
|
|
623
|
+
/**
|
|
624
|
+
* @constructor
|
|
625
|
+
* @param {object} props - Component props
|
|
626
|
+
* @param {string} props.children - Content to be displayed inside the script
|
|
627
|
+
*/
|
|
628
|
+
constructor(props) {
|
|
629
|
+
super(props);
|
|
630
|
+
this.props = {
|
|
631
|
+
children: props.children,
|
|
648
632
|
}
|
|
649
|
-
|
|
633
|
+
this.key = 'script';
|
|
634
|
+
this.script = document.createElement('script');
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
|
|
639
|
+
render() {
|
|
640
|
+
this.script.innerHTML = this.props.children.split('\n').join(';\n');
|
|
641
|
+
return this.script.outerHTML;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
onMount() {
|
|
645
|
+
document.head.appendChild(this.script);
|
|
646
|
+
document.body.querySelector(`[key="${this.key}"]`).remove();
|
|
647
|
+
}
|
|
648
|
+
|
|
650
649
|
}
|
|
651
650
|
|
|
652
651
|
/**
|
|
@@ -692,14 +691,14 @@ export class Html extends Component {
|
|
|
692
691
|
|
|
693
692
|
}
|
|
694
693
|
export default {
|
|
695
|
-
Component,
|
|
694
|
+
Component,
|
|
696
695
|
useRef,
|
|
697
696
|
useReducer,
|
|
698
697
|
useState,
|
|
699
|
-
strictMount,
|
|
698
|
+
strictMount,
|
|
700
699
|
Link,
|
|
701
700
|
Image,
|
|
702
701
|
Head,
|
|
703
702
|
Html,
|
|
704
|
-
|
|
703
|
+
|
|
705
704
|
}
|