structured-fw 0.7.2
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/Config.ts +47 -0
- package/LICENSE +21 -0
- package/README.md +332 -0
- package/app/Types.ts +1 -0
- package/app/models/README.md +9 -0
- package/app/routes/README.md +19 -0
- package/app/views/README.md +1 -0
- package/app/views/layout.html +1 -0
- package/bin/structured +114 -0
- package/build/Config.d.ts +2 -0
- package/build/Config.js +31 -0
- package/build/app/Types.d.ts +1 -0
- package/build/app/Types.js +1 -0
- package/build/app/models/Users.d.ts +0 -0
- package/build/app/models/Users.js +1 -0
- package/build/app/routes/Auth.d.ts +0 -0
- package/build/app/routes/Auth.js +1 -0
- package/build/app/routes/Test.d.ts +2 -0
- package/build/app/routes/Test.js +101 -0
- package/build/app/routes/Todo.d.ts +0 -0
- package/build/app/routes/Todo.js +1 -0
- package/build/app/routes/Upload.d.ts +0 -0
- package/build/app/routes/Upload.js +1 -0
- package/build/app/routes/Validation.d.ts +2 -0
- package/build/app/routes/Validation.js +34 -0
- package/build/app/views/components/ClientImport/ClientImport.client.d.ts +2 -0
- package/build/app/views/components/ClientImport/ClientImport.client.js +4 -0
- package/build/app/views/components/ClientImport/Export.d.ts +1 -0
- package/build/app/views/components/ClientImport/Export.js +1 -0
- package/build/app/views/components/Conditionals/Conditionals.client.d.ts +2 -0
- package/build/app/views/components/Conditionals/Conditionals.client.js +43 -0
- package/build/app/views/components/FormTest/FormTestNested/FormTestNested.d.ts +8 -0
- package/build/app/views/components/FormTest/FormTestNested/FormTestNested.js +7 -0
- package/build/app/views/components/ModelsTest/ModelsTest.client.d.ts +2 -0
- package/build/app/views/components/ModelsTest/ModelsTest.client.js +5 -0
- package/build/app/views/components/MultipartForm/MultipartForm.client.d.ts +0 -0
- package/build/app/views/components/MultipartForm/MultipartForm.client.js +1 -0
- package/build/app/views/components/PassObject/PassObject.d.ts +10 -0
- package/build/app/views/components/PassObject/PassObject.js +10 -0
- package/build/app/views/components/PassObject/ReceiveObj/ReceiveObj.d.ts +6 -0
- package/build/app/views/components/PassObject/ReceiveObj/ReceiveObj.js +6 -0
- package/build/app/views/components/RedrawAbort/RedrawAbort.client.d.ts +2 -0
- package/build/app/views/components/RedrawAbort/RedrawAbort.client.js +6 -0
- package/build/app/views/components/RedrawAbort/RedrawAbort.d.ts +8 -0
- package/build/app/views/components/RedrawAbort/RedrawAbort.js +8 -0
- package/build/app/views/components/ServerSideContext/ServerSideContext.d.ts +7 -0
- package/build/app/views/components/ServerSideContext/ServerSideContext.js +10 -0
- package/build/assets/ts/Export.d.ts +1 -0
- package/build/assets/ts/Export.js +1 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +3 -0
- package/build/system/Helpers.d.ts +3 -0
- package/build/system/Helpers.js +72 -0
- package/build/system/Symbols.d.ts +3 -0
- package/build/system/Symbols.js +3 -0
- package/build/system/Types.d.ts +171 -0
- package/build/system/Types.js +1 -0
- package/build/system/Util.d.ts +20 -0
- package/build/system/Util.js +336 -0
- package/build/system/client/App.d.ts +7 -0
- package/build/system/client/App.js +8 -0
- package/build/system/client/Client.d.ts +6 -0
- package/build/system/client/Client.js +9 -0
- package/build/system/client/ClientComponent.d.ts +68 -0
- package/build/system/client/ClientComponent.js +734 -0
- package/build/system/client/DataStore.d.ts +22 -0
- package/build/system/client/DataStore.js +64 -0
- package/build/system/client/DataStoreView.d.ts +19 -0
- package/build/system/client/DataStoreView.js +56 -0
- package/build/system/client/EventEmitter.d.ts +7 -0
- package/build/system/client/EventEmitter.js +31 -0
- package/build/system/client/Net.d.ts +13 -0
- package/build/system/client/Net.js +39 -0
- package/build/system/client/NetRequest.d.ts +13 -0
- package/build/system/client/NetRequest.js +45 -0
- package/build/system/server/Application.d.ts +31 -0
- package/build/system/server/Application.js +171 -0
- package/build/system/server/Component.d.ts +27 -0
- package/build/system/server/Component.js +249 -0
- package/build/system/server/Components.d.ts +12 -0
- package/build/system/server/Components.js +77 -0
- package/build/system/server/Cookies.d.ts +6 -0
- package/build/system/server/Cookies.js +19 -0
- package/build/system/server/Document.d.ts +24 -0
- package/build/system/server/Document.js +107 -0
- package/build/system/server/DocumentHead.d.ts +32 -0
- package/build/system/server/DocumentHead.js +118 -0
- package/build/system/server/FormValidation.d.ts +16 -0
- package/build/system/server/FormValidation.js +197 -0
- package/build/system/server/Handlebars.d.ts +11 -0
- package/build/system/server/Handlebars.js +34 -0
- package/build/system/server/Request.d.ts +21 -0
- package/build/system/server/Request.js +356 -0
- package/build/system/server/Session.d.ts +23 -0
- package/build/system/server/Session.js +114 -0
- package/build/system/server/dom/DOMFragment.d.ts +4 -0
- package/build/system/server/dom/DOMFragment.js +6 -0
- package/build/system/server/dom/DOMNode.d.ts +31 -0
- package/build/system/server/dom/DOMNode.js +110 -0
- package/build/system/server/dom/HTMLParser.d.ts +21 -0
- package/build/system/server/dom/HTMLParser.js +204 -0
- package/index.ts +4 -0
- package/package.json +31 -0
- package/system/Helpers.ts +97 -0
- package/system/Symbols.ts +6 -0
- package/system/Types.ts +234 -0
- package/system/Util.ts +488 -0
- package/system/client/App.ts +11 -0
- package/system/client/Client.ts +9 -0
- package/system/client/ClientComponent.ts +1117 -0
- package/system/client/DataStore.ts +101 -0
- package/system/client/DataStoreView.ts +82 -0
- package/system/client/EventEmitter.ts +38 -0
- package/system/client/Net.ts +58 -0
- package/system/client/NetRequest.ts +64 -0
- package/system/server/Application.ts +230 -0
- package/system/server/Component.ts +404 -0
- package/system/server/Components.ts +111 -0
- package/system/server/Cookies.ts +29 -0
- package/system/server/Document.ts +163 -0
- package/system/server/DocumentHead.ts +150 -0
- package/system/server/FormValidation.ts +231 -0
- package/system/server/Handlebars.ts +51 -0
- package/system/server/Request.ts +497 -0
- package/system/server/Session.ts +151 -0
- package/system/server/dom/DOMFragment.ts +7 -0
- package/system/server/dom/DOMNode.ts +140 -0
- package/system/server/dom/HTMLParser.ts +238 -0
- package/tsconfig.json +35 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
export function queryStringDecode(queryString, initialValue = {}, trimValues = true) {
|
|
2
|
+
const pairsRaw = queryString.replaceAll('+', ' ').split('&');
|
|
3
|
+
let pairs = pairsRaw.map((pair) => {
|
|
4
|
+
let parts = pair.split('=');
|
|
5
|
+
if (parts.length > 2) {
|
|
6
|
+
parts = [parts[0]].concat(parts.slice(1).join('='));
|
|
7
|
+
}
|
|
8
|
+
const hasValue = parts.length > 1;
|
|
9
|
+
const keyRaw = decodeURIComponent(parts[0]);
|
|
10
|
+
const value = hasValue ? (trimValues ? decodeURIComponent(parts[1]).trim() : decodeURIComponent(parts[1])) : true;
|
|
11
|
+
const arrayOrObject = /\[[^\[\]]*\]/.test(keyRaw);
|
|
12
|
+
const pathStart = arrayOrObject ? /\[(.*?)\]/.exec(keyRaw)[1] : null;
|
|
13
|
+
const isObject = pathStart !== null && /[^\[\]]+/.test(pathStart) && !/^\s+$/.test(pathStart) && !/^\d+$/.test(pathStart);
|
|
14
|
+
const isArray = pathStart !== null && !isObject;
|
|
15
|
+
const key = isArray || isObject ? keyRaw.substring(0, keyRaw.indexOf('[')) : keyRaw;
|
|
16
|
+
return {
|
|
17
|
+
key,
|
|
18
|
+
value,
|
|
19
|
+
isArray,
|
|
20
|
+
isObject,
|
|
21
|
+
path: pathStart,
|
|
22
|
+
keyRaw
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
while (pairs.length > 0) {
|
|
26
|
+
const item = pairs.shift();
|
|
27
|
+
if (item) {
|
|
28
|
+
if (!item.isArray && !item.isObject) {
|
|
29
|
+
initialValue[item.key] = item.value;
|
|
30
|
+
}
|
|
31
|
+
else if (item.isObject) {
|
|
32
|
+
const properties = [item].concat(pairs.filter((pair) => {
|
|
33
|
+
return pair.isObject && pair.key === item.key;
|
|
34
|
+
}));
|
|
35
|
+
pairs = pairs.filter((pair) => {
|
|
36
|
+
return !(pair.isObject && pair.key === item.key);
|
|
37
|
+
});
|
|
38
|
+
let obj = {};
|
|
39
|
+
const simpleProperties = properties.filter((prop) => {
|
|
40
|
+
return prop.keyRaw === `${prop.key}[${prop.path}]`;
|
|
41
|
+
});
|
|
42
|
+
const complexProperties = properties.filter((prop) => {
|
|
43
|
+
return prop.keyRaw !== `${prop.key}[${prop.path}]`;
|
|
44
|
+
});
|
|
45
|
+
for (const property of simpleProperties) {
|
|
46
|
+
if (!property.path) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
obj[property.path] = property.value;
|
|
50
|
+
}
|
|
51
|
+
const complexPropertyPathsResolved = [];
|
|
52
|
+
for (const property of complexProperties) {
|
|
53
|
+
if (!property.path) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (complexPropertyPathsResolved.includes(property.path)) {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const objectProperties = complexProperties.filter((prop) => {
|
|
60
|
+
return prop.path === property.path;
|
|
61
|
+
});
|
|
62
|
+
complexPropertyPathsResolved.push(property.path);
|
|
63
|
+
obj[property.path] = queryStringDecode(objectProperties.map((prop) => {
|
|
64
|
+
const pathRemaining = prop.keyRaw.substring(prop.key.length + (prop.path?.length || 0) + 3);
|
|
65
|
+
const val = prop.value === true ? '' : `=${encodeURIComponent(prop.value)}`;
|
|
66
|
+
return `value[${pathRemaining.substring(0, pathRemaining.length - 1)}]${val}`;
|
|
67
|
+
}).join('&')).value;
|
|
68
|
+
}
|
|
69
|
+
initialValue[item.key] = obj;
|
|
70
|
+
}
|
|
71
|
+
else if (item.isArray) {
|
|
72
|
+
let arrayValues = [item].concat(pairs.filter((pair) => {
|
|
73
|
+
return pair.isArray && pair.key === item.key;
|
|
74
|
+
}));
|
|
75
|
+
pairs = pairs.filter((pair) => {
|
|
76
|
+
return !(pair.isArray && pair.key === item.key);
|
|
77
|
+
});
|
|
78
|
+
arrayValues.sort((a, b) => {
|
|
79
|
+
if (a.path === b.path) {
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
if (a.path && b.path && a.path.trim().length > 0 && b.path.trim().length > 0) {
|
|
83
|
+
const aIndex = parseInt(a.path);
|
|
84
|
+
const bIndex = parseInt(b.path);
|
|
85
|
+
return aIndex - bIndex;
|
|
86
|
+
}
|
|
87
|
+
return 0;
|
|
88
|
+
});
|
|
89
|
+
const complexPropertyPathsResolved = [];
|
|
90
|
+
const arrayItems = arrayValues.map((value) => {
|
|
91
|
+
const simpleValue = value.keyRaw === `${value.key}[${value.path}]`;
|
|
92
|
+
if (simpleValue) {
|
|
93
|
+
return value.value;
|
|
94
|
+
}
|
|
95
|
+
if (complexPropertyPathsResolved.includes(value.path)) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
const objectProperties = arrayValues.filter((prop) => {
|
|
99
|
+
return prop.path === value.path;
|
|
100
|
+
});
|
|
101
|
+
complexPropertyPathsResolved.push(value.path);
|
|
102
|
+
return queryStringDecode(objectProperties.map((prop) => {
|
|
103
|
+
const pathRemaining = prop.keyRaw.substring(prop.key.length + (prop.path?.length || 0) + 3);
|
|
104
|
+
return `value${pathRemaining.length > 0 ? `[${pathRemaining.substring(0, pathRemaining.length - 1)}]` : ''}=${encodeURIComponent(prop.value)}`;
|
|
105
|
+
}).join('&')).value;
|
|
106
|
+
}).filter((val) => {
|
|
107
|
+
return val !== null;
|
|
108
|
+
});
|
|
109
|
+
initialValue[item.key] = arrayItems;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return initialValue;
|
|
114
|
+
}
|
|
115
|
+
export function queryStringDecodedSetValue(obj, value) {
|
|
116
|
+
if (typeof obj === 'string') {
|
|
117
|
+
obj = queryStringDecode(obj);
|
|
118
|
+
}
|
|
119
|
+
const setValue = (obj) => {
|
|
120
|
+
for (const key in obj) {
|
|
121
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
122
|
+
setValue(obj[key]);
|
|
123
|
+
}
|
|
124
|
+
else if (obj[key] === true) {
|
|
125
|
+
obj[key] = value;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
setValue(obj);
|
|
130
|
+
return obj;
|
|
131
|
+
}
|
|
132
|
+
export function objectEach(obj, callbackEach) {
|
|
133
|
+
for (const key in obj) {
|
|
134
|
+
callbackEach(key, obj[key]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export function toCamelCase(dataKey, separator = '-') {
|
|
138
|
+
let index;
|
|
139
|
+
do {
|
|
140
|
+
index = dataKey.indexOf(separator);
|
|
141
|
+
if (index > -1) {
|
|
142
|
+
dataKey = dataKey.substring(0, index) + dataKey.substring(index + 1, index + 2).toUpperCase() + dataKey.substring(index + 2);
|
|
143
|
+
}
|
|
144
|
+
} while (index > -1);
|
|
145
|
+
return dataKey;
|
|
146
|
+
}
|
|
147
|
+
export function toSnakeCase(str, joinWith = '_') {
|
|
148
|
+
let start = 0;
|
|
149
|
+
const parts = [];
|
|
150
|
+
if (str.length < 2) {
|
|
151
|
+
return str.toLowerCase();
|
|
152
|
+
}
|
|
153
|
+
for (let i = 1; i < str.length; i++) {
|
|
154
|
+
if (str[i] !== str[i].toLowerCase()) {
|
|
155
|
+
parts.push(str.substring(start, i).toLowerCase());
|
|
156
|
+
start = i;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (start === 0) {
|
|
160
|
+
return str.toLowerCase();
|
|
161
|
+
}
|
|
162
|
+
parts.push(str.substring(start).toLowerCase());
|
|
163
|
+
return parts.join(joinWith);
|
|
164
|
+
}
|
|
165
|
+
export function capitalize(str) {
|
|
166
|
+
return str.substring(0, 1).toUpperCase() + str.substring(1);
|
|
167
|
+
}
|
|
168
|
+
export function isAsync(fn) {
|
|
169
|
+
return fn.constructor.name === 'AsyncFunction';
|
|
170
|
+
}
|
|
171
|
+
export function randomString(len) {
|
|
172
|
+
const charCodes = new Uint8Array(len);
|
|
173
|
+
const generators = [
|
|
174
|
+
function () {
|
|
175
|
+
return 65 + Math.floor(Math.random() * 26);
|
|
176
|
+
},
|
|
177
|
+
function () {
|
|
178
|
+
return 97 + Math.floor(Math.random() * 26);
|
|
179
|
+
},
|
|
180
|
+
function () {
|
|
181
|
+
return 48 + Math.floor(Math.random() * 10);
|
|
182
|
+
}
|
|
183
|
+
];
|
|
184
|
+
for (let i = 0; i < len; i++) {
|
|
185
|
+
charCodes[i] = generators[Math.floor(Math.random() * generators.length)]();
|
|
186
|
+
}
|
|
187
|
+
return String.fromCodePoint(...charCodes);
|
|
188
|
+
}
|
|
189
|
+
export function unique(arr) {
|
|
190
|
+
return arr.reduce((prev, curr) => {
|
|
191
|
+
if (!prev.includes(curr)) {
|
|
192
|
+
prev.push(curr);
|
|
193
|
+
}
|
|
194
|
+
return prev;
|
|
195
|
+
}, []);
|
|
196
|
+
}
|
|
197
|
+
export function stripTags(contentWithHTML, keepTags = []) {
|
|
198
|
+
if (contentWithHTML === undefined) {
|
|
199
|
+
return '';
|
|
200
|
+
}
|
|
201
|
+
;
|
|
202
|
+
return contentWithHTML.replaceAll(/<\s*\/?\s*[a-zA-Z]+[^>]*?>/g, (sub, index) => {
|
|
203
|
+
const keep = keepTags.some((kept) => {
|
|
204
|
+
const match = new RegExp(`^<\s*\/?\s*${kept}`);
|
|
205
|
+
return match.test(sub);
|
|
206
|
+
});
|
|
207
|
+
if (keep) {
|
|
208
|
+
return sub;
|
|
209
|
+
}
|
|
210
|
+
return sub.replaceAll('<', '<').replaceAll('>', '>');
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function base64ToBytes(base64) {
|
|
214
|
+
const binString = atob(base64);
|
|
215
|
+
return Uint8Array.from(binString, (m) => m.codePointAt(0));
|
|
216
|
+
}
|
|
217
|
+
function bytesToBase64(bytes) {
|
|
218
|
+
const binString = String.fromCodePoint(...bytes);
|
|
219
|
+
return btoa(binString);
|
|
220
|
+
}
|
|
221
|
+
export function attributeValueToString(key, value) {
|
|
222
|
+
return 'base64:' + bytesToBase64(new TextEncoder().encode(JSON.stringify({ key, value })));
|
|
223
|
+
}
|
|
224
|
+
export function attributeValueFromString(attributeValue) {
|
|
225
|
+
if (attributeValue.indexOf('base64:') === 0) {
|
|
226
|
+
try {
|
|
227
|
+
const decoded = new TextDecoder().decode(base64ToBytes(attributeValue.substring(7)));
|
|
228
|
+
if (decoded.indexOf('{') !== 0) {
|
|
229
|
+
return attributeValue;
|
|
230
|
+
}
|
|
231
|
+
const valObj = JSON.parse(decoded);
|
|
232
|
+
if (!('value' in valObj) || !('key' in valObj)) {
|
|
233
|
+
return decoded;
|
|
234
|
+
}
|
|
235
|
+
return valObj;
|
|
236
|
+
}
|
|
237
|
+
catch (e) {
|
|
238
|
+
return attributeValue;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return attributeValue;
|
|
242
|
+
}
|
|
243
|
+
export function attributeValueEscape(str) {
|
|
244
|
+
return str.replaceAll('"', '"');
|
|
245
|
+
}
|
|
246
|
+
export function isObject(item) {
|
|
247
|
+
if (typeof window === 'undefined') {
|
|
248
|
+
return (item && typeof item === 'object' && !Array.isArray(item)) && !Buffer.isBuffer(item);
|
|
249
|
+
}
|
|
250
|
+
return (item && typeof item === 'object' && !Array.isArray(item));
|
|
251
|
+
}
|
|
252
|
+
export function equalDeep(a, b) {
|
|
253
|
+
if (a === b) {
|
|
254
|
+
return true;
|
|
255
|
+
}
|
|
256
|
+
const keysA = Object.keys(a);
|
|
257
|
+
const keysB = Object.keys(b);
|
|
258
|
+
if (keysA.length !== keysB.length) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
const keyDifferent = keysA.some((keyA) => {
|
|
262
|
+
return !(keyA in b);
|
|
263
|
+
});
|
|
264
|
+
if (keyDifferent) {
|
|
265
|
+
return false;
|
|
266
|
+
}
|
|
267
|
+
for (let i = 0; i < keysA.length; i++) {
|
|
268
|
+
const key = keysA[i];
|
|
269
|
+
const valA = a[key];
|
|
270
|
+
const valB = b[key];
|
|
271
|
+
const typeA = typeof valA;
|
|
272
|
+
const typeB = typeof valB;
|
|
273
|
+
if (valA === valB) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (typeA !== typeB) {
|
|
277
|
+
return false;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
if (typeA !== 'object') {
|
|
281
|
+
if (valA !== valB) {
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if ((valA === null && valB !== null) || (valA !== null && valB === null)) {
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
const isArrayA = Array.isArray(valA);
|
|
290
|
+
const isArrayB = Array.isArray(valB);
|
|
291
|
+
if ((isArrayA && !isArrayB) || (!isArrayA && isArrayB)) {
|
|
292
|
+
return false;
|
|
293
|
+
}
|
|
294
|
+
if (!isArrayA && !isArrayB) {
|
|
295
|
+
if (!equalDeep(valA, valB)) {
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (isArrayA && isArrayB) {
|
|
300
|
+
if (valA.length !== valB.length) {
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
for (let j = 0; j < valA.length; j++) {
|
|
304
|
+
if (!equalDeep({
|
|
305
|
+
value: valA[j]
|
|
306
|
+
}, {
|
|
307
|
+
value: valB[j]
|
|
308
|
+
})) {
|
|
309
|
+
return false;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
export function mergeDeep(target, ...sources) {
|
|
317
|
+
if (!sources.length)
|
|
318
|
+
return target;
|
|
319
|
+
const source = sources.shift();
|
|
320
|
+
if (isObject(target) && isObject(source)) {
|
|
321
|
+
for (const key in source) {
|
|
322
|
+
if (isObject(source[key])) {
|
|
323
|
+
if (!target[key])
|
|
324
|
+
Object.assign(target, { [key]: {} });
|
|
325
|
+
mergeDeep(target[key], source[key]);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
Object.assign(target, { [key]: source[key] });
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
if (Array.isArray(target) && Array.isArray(source)) {
|
|
333
|
+
return target.concat(source);
|
|
334
|
+
}
|
|
335
|
+
return mergeDeep(target, ...sources);
|
|
336
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { InitializerFunction, LooseObject, StructuredClientConfig } from '../Types.js';
|
|
2
|
+
import { DataStoreView } from './DataStoreView.js';
|
|
3
|
+
import { DataStore } from './DataStore.js';
|
|
4
|
+
import { Net } from './Net.js';
|
|
5
|
+
import { EventEmitter } from './EventEmitter.js';
|
|
6
|
+
declare global {
|
|
7
|
+
interface Window {
|
|
8
|
+
initializers: Record<string, InitializerFunction | string>;
|
|
9
|
+
structuredClientConfig: StructuredClientConfig;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export declare class ClientComponent extends EventEmitter {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
children: Array<ClientComponent>;
|
|
15
|
+
readonly parent: ClientComponent;
|
|
16
|
+
readonly domNode: HTMLElement;
|
|
17
|
+
readonly isRoot: boolean;
|
|
18
|
+
readonly root: ClientComponent;
|
|
19
|
+
store: DataStoreView;
|
|
20
|
+
private storeGlobal;
|
|
21
|
+
readonly net: Net;
|
|
22
|
+
private initializerExecuted;
|
|
23
|
+
destroyed: boolean;
|
|
24
|
+
private redrawRequest;
|
|
25
|
+
onDestroy?: Function;
|
|
26
|
+
onRedraw?: Function;
|
|
27
|
+
private bound;
|
|
28
|
+
private conditionals;
|
|
29
|
+
private conditionalCallbacks;
|
|
30
|
+
private conditionalClassNames;
|
|
31
|
+
private refs;
|
|
32
|
+
private refsArray;
|
|
33
|
+
loaded: boolean;
|
|
34
|
+
private initializer;
|
|
35
|
+
private data;
|
|
36
|
+
constructor(parent: ClientComponent | null, name: string, domNode: HTMLElement, store: DataStore, runInitializer?: boolean);
|
|
37
|
+
private init;
|
|
38
|
+
private runInitializer;
|
|
39
|
+
private initData;
|
|
40
|
+
pathData(): Array<{
|
|
41
|
+
[key: string]: string;
|
|
42
|
+
}>;
|
|
43
|
+
setData(key: string, value: any, updateStore?: boolean): ClientComponent;
|
|
44
|
+
private initChildren;
|
|
45
|
+
redraw(data?: LooseObject): Promise<void>;
|
|
46
|
+
private initConditionals;
|
|
47
|
+
private initRefs;
|
|
48
|
+
private initModels;
|
|
49
|
+
private promoteRefs;
|
|
50
|
+
ref<T>(refName: string): T;
|
|
51
|
+
refArray<T>(refName: string): Array<T>;
|
|
52
|
+
private execCondition;
|
|
53
|
+
conditionalCallback(name: string, callback: (args?: any) => boolean, updateConditionals?: boolean): void;
|
|
54
|
+
private updateConditionals;
|
|
55
|
+
remove(): Promise<void>;
|
|
56
|
+
parentFind(parentName: string): ClientComponent | null;
|
|
57
|
+
find(componentName: string, recursive?: boolean): null | ClientComponent;
|
|
58
|
+
query(componentName: string, recursive?: boolean, results?: Array<ClientComponent>): Array<ClientComponent>;
|
|
59
|
+
add(appendTo: string | HTMLElement, componentName: string, data?: LooseObject): Promise<ClientComponent | null>;
|
|
60
|
+
getData<T>(key?: string): T;
|
|
61
|
+
show(domNode: HTMLElement, enableTransition?: boolean): void;
|
|
62
|
+
hide(domNode: HTMLElement, enableTransition?: boolean): void;
|
|
63
|
+
private transitionAttributes;
|
|
64
|
+
private transitionAxis;
|
|
65
|
+
private destroy;
|
|
66
|
+
bind(element: HTMLElement, event: string, callback: (e: Event) => void): void;
|
|
67
|
+
private unbindAll;
|
|
68
|
+
}
|