sheel-deer 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/.vscode/launch.json +51 -0
- package/.vscode/settings.json +94 -0
- package/.vscode/tasks.json +57 -0
- package/App.elen +70 -0
- package/README.MD +0 -0
- package/Test.elen +24 -0
- package/compile-all-ts.js +76 -0
- package/dist/index.es.js +1 -0
- package/dist/index.umd.js +1 -0
- package/elen/App.elen +7 -0
- package/elen/LICENSE +15 -0
- package/elen/dist/extension.js +130 -0
- package/elen/dist/init.js +28 -0
- package/elen/elen-1.0.0.vsix +0 -0
- package/elen/extension.ts +122 -0
- package/elen/icon-theme.json +2423 -0
- package/elen/icon.svg +1 -0
- package/elen/images/icon.svg +1 -0
- package/elen/init.ts +28 -0
- package/elen/language-configuration.json +26 -0
- package/elen/package-lock.json +549 -0
- package/elen/package.json +52 -0
- package/elen/seti.woff +0 -0
- package/elen/src/App.elen +0 -0
- package/elen/syntaxes/elen.tmLanguage.json +312 -0
- package/elen/tsconfig.json +14 -0
- package/elen-icon-theme/LICENSE +15 -0
- package/elen-icon-theme/README.md +18 -0
- package/elen-icon-theme/elen-icon-theme-1.0.0.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.1.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.13.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.15.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.16.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.17.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.18.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.19.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.2.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.20.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.3.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.4.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.5.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.6.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.7.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.8.vsix +0 -0
- package/elen-icon-theme/elen-icon-theme-1.0.9.vsix +0 -0
- package/elen-icon-theme/extension.js +226 -0
- package/elen-icon-theme/icon-theme.json +2425 -0
- package/elen-icon-theme/icon.svg +1 -0
- package/elen-icon-theme/images/icon.svg +1 -0
- package/elen-icon-theme/package.json +36 -0
- package/elen-icon-theme/seti.woff +0 -0
- package/icon.svg +8 -0
- package/index.html +11 -0
- package/init-start-page.ts +59 -0
- package/logo.html +15 -0
- package/package.json +42 -0
- package/server.ts +31 -0
- package/shells/data-page/Elen.ts +23 -0
- package/squarings/.json +132 -0
- package/squarings/App.json +59 -0
- package/squarings/Test.json +27 -0
- package/src/base/Component.ts +113 -0
- package/src/classes/BinaryData.ts +81 -0
- package/src/classes/DataModel.ts +386 -0
- package/src/classes/DataTypes.ts +116 -0
- package/src/components/squaring.ts +226 -0
- package/src/components/vtm.ts +231 -0
- package/src/data/ascii.ts +134 -0
- package/src/data/binary-resources.ts +209 -0
- package/src/events/event-handler.js +34 -0
- package/src/index.ts +1 -0
- package/src/methods/app-template.ts +7 -0
- package/src/methods/array-helpers.ts +176 -0
- package/src/methods/css-template.ts +5 -0
- package/src/methods/errors-helpers.ts +26 -0
- package/src/methods/html-template.ts +22 -0
- package/src/methods/parsers.ts +1012 -0
- package/src/methods/square.ts +80 -0
- package/src/methods/ts-template.ts +36 -0
- package/src/methods/using-template.ts +3 -0
- package/src/models/ascii.ts +26 -0
- package/src/models/data-stream.ts +5 -0
- package/src/models/data-type-model.ts +22 -0
- package/src/models/template-binary-model.ts +5 -0
- package/src/routes.ts +9 -0
- package/syntaxes/enel.tmLanguage.json +28 -0
- package/tsconfig.json +68 -0
- package/viewController/Inital.elen +8 -0
- package/vite.config.ts +25 -0
- package/vue.config.js +30 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { equal, fromAscii } from '../methods/parsers';
|
|
2
|
+
import { DataList } from '../models/data-type-model';
|
|
3
|
+
import { TemplateBinary } from '../models/template-binary-model';
|
|
4
|
+
import { getStreamModel } from './DataModel';
|
|
5
|
+
|
|
6
|
+
export class BinaryData{
|
|
7
|
+
replaceBinaryData = (array: number[], replace: number[]) => {
|
|
8
|
+
let data: DataList = new DataList();
|
|
9
|
+
|
|
10
|
+
let i = 0;
|
|
11
|
+
for(let num of array){
|
|
12
|
+
if(num == 32){
|
|
13
|
+
i++
|
|
14
|
+
}else{
|
|
15
|
+
data.list[i].array = [...data.list[i].array, num];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let result = [] as number[];
|
|
21
|
+
|
|
22
|
+
for(let array of data.list){
|
|
23
|
+
if(!equal(array.array, replace)){
|
|
24
|
+
result = [...result, ...array.array];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setTemplateBinaryData = (startIndex: number, endIndex: number, number: number[]) => {
|
|
32
|
+
const streamModel = getStreamModel();
|
|
33
|
+
const data = streamModel.data;
|
|
34
|
+
|
|
35
|
+
if (startIndex < 0 || endIndex < startIndex || endIndex > data.length) {
|
|
36
|
+
throw new Error(`Invalid template replacement range: ${startIndex}-${endIndex}`);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
streamModel.data = [
|
|
40
|
+
...data.slice(0, startIndex),
|
|
41
|
+
...number,
|
|
42
|
+
...data.slice(endIndex)
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return streamModel;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getTemplateBinaryDataDirective = (index: number, start: number, directive: TemplateBinary) : number => {
|
|
49
|
+
const streamModel = getStreamModel();
|
|
50
|
+
console.log(fromAscii(streamModel.data));
|
|
51
|
+
const data = streamModel.data;
|
|
52
|
+
const pattern = directive.bitMap;
|
|
53
|
+
|
|
54
|
+
for (let i = index; i <= data.length - pattern.length; i++) {
|
|
55
|
+
let match = true;
|
|
56
|
+
for (let j = 0; j < pattern.length; j++) {
|
|
57
|
+
if (data[i + j] !== pattern[j]) {
|
|
58
|
+
match = false;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (match) {
|
|
63
|
+
return i + pattern.length;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
throw new Error(`Directive ${directive.name} not found in stream`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
getTemplateBinaryData = (start: number, end: number) => {
|
|
71
|
+
const streamModel = getStreamModel();
|
|
72
|
+
let binary = [] as number[];
|
|
73
|
+
for(let i = start; i < end; i++) {
|
|
74
|
+
const charCode = streamModel.data[i];
|
|
75
|
+
|
|
76
|
+
binary = [...binary, charCode];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return binary;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { DataStream } from '../models/data-stream';
|
|
2
|
+
import { DataComponentModel } from '../models/data-type-model';
|
|
3
|
+
import { DataTypes } from './DataTypes';
|
|
4
|
+
import { asciiTable } from './../data/ascii';
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
import { returnCssLinkByteArray, translateTS,createPage, fromPage, returnJSLinkByteArray, nestedComponents, fromString, fromAscii, fromPageToString, createFromString } from './../methods/parsers';
|
|
7
|
+
import fs from 'fs';
|
|
8
|
+
import path from 'path';
|
|
9
|
+
import { initComponent } from '../../init-start-page';
|
|
10
|
+
import { getCurrentSquaring, Squaring } from '../components/squaring';
|
|
11
|
+
import { flatList } from '../methods/array-helpers';
|
|
12
|
+
import { ContentFile } from '../models/ascii';
|
|
13
|
+
import { HtmlTemplate } from './../methods/html-template';
|
|
14
|
+
import { newRow, pageEnd, pageStart } from '../data/binary-resources';
|
|
15
|
+
import { TemplateBinary } from '../models/template-binary-model';
|
|
16
|
+
import { BinaryData } from './BinaryData';
|
|
17
|
+
|
|
18
|
+
let streamModel = {} as DataStream;
|
|
19
|
+
export let lastStreamModel = {} as DataStream;
|
|
20
|
+
export const getStreamModel = () => streamModel;
|
|
21
|
+
|
|
22
|
+
export const squaring = new Squaring();
|
|
23
|
+
|
|
24
|
+
export class DataModel {
|
|
25
|
+
|
|
26
|
+
initDataStream = (stream: Buffer | DataStream, saveLast: boolean = false) => {
|
|
27
|
+
if(saveLast){
|
|
28
|
+
if (Buffer.isBuffer(stream)) {
|
|
29
|
+
lastStreamModel = { type: 'buffer', data: Array.from(stream) } as DataStream;
|
|
30
|
+
} else {
|
|
31
|
+
lastStreamModel = JSON.parse(JSON.stringify(stream)) as DataStream;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (Buffer.isBuffer(stream)) {
|
|
36
|
+
streamModel = { type: 'buffer', data: Array.from(stream) } as DataStream;
|
|
37
|
+
} else {
|
|
38
|
+
streamModel = JSON.parse(JSON.stringify(stream)) as DataStream;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
returnDataStream = (dataStream: DataStream) => {
|
|
43
|
+
let buffer = Buffer.from(JSON.stringify(dataStream, null, 2), "utf-8");
|
|
44
|
+
|
|
45
|
+
return buffer;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
createHTMLPage = (byteArray: number[]) => {
|
|
49
|
+
let result = "";
|
|
50
|
+
let depth = 0;
|
|
51
|
+
let buffer = "";
|
|
52
|
+
|
|
53
|
+
const getChar = (byte: number) =>
|
|
54
|
+
asciiTable.ascii.find(x => x.code === byte)?.char || "";
|
|
55
|
+
|
|
56
|
+
const voidTags = new Set([
|
|
57
|
+
"meta","br","img","input","hr","link",
|
|
58
|
+
"area","base","col","embed","source","track","wbr"
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < byteArray.length; i++) {
|
|
62
|
+
const byte = byteArray[i];
|
|
63
|
+
const char = getChar(byte);
|
|
64
|
+
|
|
65
|
+
buffer += char;
|
|
66
|
+
|
|
67
|
+
// TAG CLOSED
|
|
68
|
+
if (byte === 62) { // ">"
|
|
69
|
+
const tag = buffer.trim();
|
|
70
|
+
buffer = "";
|
|
71
|
+
|
|
72
|
+
const isDoctype = tag.startsWith("<!DOCTYPE");
|
|
73
|
+
const isClosing = tag.startsWith("</");
|
|
74
|
+
const isSelfClosing = tag.endsWith("/>");
|
|
75
|
+
|
|
76
|
+
const tagName = tag
|
|
77
|
+
.replace(/<\/?|\/?>/g, "")
|
|
78
|
+
.split(" ")[0]
|
|
79
|
+
.toLowerCase();
|
|
80
|
+
|
|
81
|
+
const isVoid = voidTags.has(tagName);
|
|
82
|
+
|
|
83
|
+
let j = i + 1;
|
|
84
|
+
let text = "";
|
|
85
|
+
|
|
86
|
+
while (j < byteArray.length && byteArray[j] !== 60) {
|
|
87
|
+
text += getChar(byteArray[j]);
|
|
88
|
+
j++;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let closingTag = "";
|
|
92
|
+
let k = j;
|
|
93
|
+
|
|
94
|
+
while (k < byteArray.length && byteArray[k] !== 62) {
|
|
95
|
+
closingTag += getChar(byteArray[k]);
|
|
96
|
+
k++;
|
|
97
|
+
}
|
|
98
|
+
closingTag += ">";
|
|
99
|
+
|
|
100
|
+
const isInline =
|
|
101
|
+
!isClosing &&
|
|
102
|
+
!isSelfClosing &&
|
|
103
|
+
!isVoid &&
|
|
104
|
+
text.trim().length > 0 &&
|
|
105
|
+
closingTag.startsWith(`</${tagName}`);
|
|
106
|
+
|
|
107
|
+
if (isClosing) depth--;
|
|
108
|
+
|
|
109
|
+
if (isDoctype) {
|
|
110
|
+
result += "\n" + tag;
|
|
111
|
+
}
|
|
112
|
+
else if (isInline) {
|
|
113
|
+
result +=
|
|
114
|
+
"\n" +
|
|
115
|
+
"\t".repeat(depth) +
|
|
116
|
+
tag +
|
|
117
|
+
text.trim() +
|
|
118
|
+
closingTag;
|
|
119
|
+
|
|
120
|
+
i = k;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
result += "\n" + "\t".repeat(depth) + tag;
|
|
124
|
+
|
|
125
|
+
if (!isClosing && !isSelfClosing && !isVoid) {
|
|
126
|
+
depth++;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return result.trim();
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
createAppModel = (stream: Buffer) => {
|
|
137
|
+
this.initDataStream(stream);
|
|
138
|
+
|
|
139
|
+
let dataTypes = new DataTypes();
|
|
140
|
+
let appDataModel: DataComponentModel = {
|
|
141
|
+
template: dataTypes.htmlDataTemplate(),
|
|
142
|
+
shell: dataTypes.tsDataType(),
|
|
143
|
+
visual: dataTypes.cssDataType()
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return appDataModel;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
createComponentModel = (stream: Buffer) => {
|
|
151
|
+
this.initDataStream(stream, true);
|
|
152
|
+
|
|
153
|
+
let dataTypes = new DataTypes();
|
|
154
|
+
let appDataModel: DataComponentModel = {
|
|
155
|
+
template: dataTypes.htmlDataTemplate(),
|
|
156
|
+
shell: dataTypes.tsDataType(),
|
|
157
|
+
visual: dataTypes.cssDataType()
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return appDataModel;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setHtmlTemplate = (number: number[], currentComponent: string, currentFile?: string) : DataStream => {
|
|
164
|
+
let dataTypes = new DataTypes();
|
|
165
|
+
let bodyDataType = dataTypes.bodyDataType();
|
|
166
|
+
let properties = getCurrentSquaring().find(x=> x.name == currentComponent)?.data.imports[0].properties;
|
|
167
|
+
|
|
168
|
+
let resultStream: DataStream = {
|
|
169
|
+
type: "",
|
|
170
|
+
data: number
|
|
171
|
+
} as DataStream;
|
|
172
|
+
|
|
173
|
+
if(properties && properties.length){
|
|
174
|
+
for(let prop of properties){
|
|
175
|
+
if(prop.name.trim() != ""){
|
|
176
|
+
resultStream = this.setNestedComponent(resultStream.data, prop.name, prop.path);
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let dataArray = fromAscii(resultStream.data).split('\n');
|
|
183
|
+
let contentFile = new ContentFile();
|
|
184
|
+
|
|
185
|
+
for(let arrayItem of dataArray){
|
|
186
|
+
let dataRow = fromString(arrayItem);
|
|
187
|
+
contentFile.contentFile.push(newRow.name);
|
|
188
|
+
contentFile.contentFile.push(arrayItem);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
let result = {
|
|
192
|
+
type: bodyDataType.type,
|
|
193
|
+
data: number,
|
|
194
|
+
dataList: createFromString(contentFile)
|
|
195
|
+
} as DataStream;
|
|
196
|
+
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
setNestedComponent = (number: number[], name: string, path: string) : DataStream => {
|
|
201
|
+
let dataTypes = new DataTypes();
|
|
202
|
+
let component = initComponent(path.replace('./', ''), name);
|
|
203
|
+
const initDataModel = new DataModel();
|
|
204
|
+
let dataBody = new DataTypes();
|
|
205
|
+
|
|
206
|
+
initDataModel.initDataStream({ type: "", data: number } as DataStream, true);
|
|
207
|
+
|
|
208
|
+
let start = fromString(`<${name}>`), end = fromString(`</${name}>`);
|
|
209
|
+
let startDirective = {name: `<${name}>`, code: start.length, bitMap: start };
|
|
210
|
+
let endDirective = {name: `</${name}>`, code: end.length, bitMap: end};
|
|
211
|
+
let customResult = dataBody.customDataType(startDirective, endDirective);
|
|
212
|
+
|
|
213
|
+
let templateResult = dataTypes.writeDataBinary(customResult.startIndex - startDirective.code, customResult.endIndex + endDirective.code, component.template.byteTemplate);
|
|
214
|
+
|
|
215
|
+
initDataModel.initDataStream(lastStreamModel);
|
|
216
|
+
|
|
217
|
+
console.log(fromAscii(templateResult.data))
|
|
218
|
+
return templateResult;
|
|
219
|
+
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
setTsTemplate = (number: number[], cssPage: string) : DataStream => {
|
|
225
|
+
|
|
226
|
+
let result = translateTS(number, cssPage);
|
|
227
|
+
|
|
228
|
+
return {
|
|
229
|
+
type: 'ts',
|
|
230
|
+
data: flatList(result),
|
|
231
|
+
dataList: result
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
getEvents = (number: number[], name: string) => {
|
|
236
|
+
let content = fromAscii(number);
|
|
237
|
+
let events: string[] = [];
|
|
238
|
+
|
|
239
|
+
for(let i = 0; i < content.length; i++){
|
|
240
|
+
let char = content[i];
|
|
241
|
+
let event = false;
|
|
242
|
+
let item = '';
|
|
243
|
+
if(char == "@"){
|
|
244
|
+
event = true
|
|
245
|
+
item += char;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if(event){
|
|
249
|
+
item += char;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if(char == ")" && content[i + 1] == '"' && event){
|
|
253
|
+
item += char;
|
|
254
|
+
event = false;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
content.replace('item', '');
|
|
258
|
+
|
|
259
|
+
events = [...events, item];
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
for(let item of events){
|
|
263
|
+
|
|
264
|
+
const match = item.match(/@(\w+)="(\w+)\(([^)]*)\)"/);
|
|
265
|
+
|
|
266
|
+
if (match) {
|
|
267
|
+
const eventType = match[1]; // click
|
|
268
|
+
const methodName = match[2]; // handleClick
|
|
269
|
+
const argument = match[3]; // $event
|
|
270
|
+
|
|
271
|
+
squaring.updateNotationType(methodName, eventType);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return fromString(content);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private runTsChecks = (content: string): string => {
|
|
280
|
+
const check = ts.transpileModule(content, {
|
|
281
|
+
compilerOptions: {
|
|
282
|
+
module: ts.ModuleKind.CommonJS,
|
|
283
|
+
target: ts.ScriptTarget.ES2020,
|
|
284
|
+
},
|
|
285
|
+
reportDiagnostics: true,
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
if (check.diagnostics?.length) {
|
|
289
|
+
console.error(
|
|
290
|
+
check.diagnostics.map(d =>
|
|
291
|
+
ts.flattenDiagnosticMessageText(d.messageText, "\n")
|
|
292
|
+
)
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
return check.outputText;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
createTsTemplate = (
|
|
300
|
+
number: number[],
|
|
301
|
+
page: string,
|
|
302
|
+
cssPage: string,
|
|
303
|
+
headers: string[] = [],
|
|
304
|
+
bootstrap: boolean = true
|
|
305
|
+
): DataStream => {
|
|
306
|
+
|
|
307
|
+
if(cssPage === "App"){
|
|
308
|
+
// Copy './base/Component.ts' to 'public/Component.ts' as-is
|
|
309
|
+
const dir = path.join(__dirname, "public");
|
|
310
|
+
const filePath = path.join(dir, `Component.ts`);
|
|
311
|
+
const srcPath = path.join(__dirname, '..', './src/classes/public/Component.ts');
|
|
312
|
+
if (!fs.existsSync(dir)) {
|
|
313
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
314
|
+
}
|
|
315
|
+
if (fs.existsSync(srcPath)) {
|
|
316
|
+
fs.copyFileSync(srcPath, filePath);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const initPage = bootstrap ? fromPage(`let page = new ${cssPage}();`) : [];
|
|
321
|
+
|
|
322
|
+
let result = this.setTsTemplate(number, cssPage);
|
|
323
|
+
|
|
324
|
+
let compiledFile = createPage(result.dataList);
|
|
325
|
+
|
|
326
|
+
const dir = path.join(__dirname, "public");
|
|
327
|
+
const filePath = path.join(dir, `${page}.ts`);
|
|
328
|
+
|
|
329
|
+
if (!fs.existsSync(dir)) {
|
|
330
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
331
|
+
}
|
|
332
|
+
fs.writeFileSync(filePath, compiledFile, "utf8");
|
|
333
|
+
|
|
334
|
+
const outText = this.runTsChecks(compiledFile);
|
|
335
|
+
|
|
336
|
+
|
|
337
|
+
const outPath = filePath.replace(/\.ts$/, ".js");
|
|
338
|
+
fs.writeFileSync(outPath, outText, "utf8");
|
|
339
|
+
|
|
340
|
+
return result;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
createHtmlTemplate = (number: number[], page: string, cssPage: string, currentFile?: string) : DataStream => {
|
|
345
|
+
let result = this.setHtmlTemplate(number, cssPage, currentFile);
|
|
346
|
+
|
|
347
|
+
let htmlTemplate = createPage(result.dataList);
|
|
348
|
+
|
|
349
|
+
const dir = path.join(__dirname, "public");
|
|
350
|
+
const filePath = path.join(dir, `${page}.html`);
|
|
351
|
+
|
|
352
|
+
if (!fs.existsSync(dir)) {
|
|
353
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
let content = fromPageToString(result.data);
|
|
357
|
+
content = content.replace(/<visual>[\s\S]*?<\/visual>/g, "");
|
|
358
|
+
|
|
359
|
+
let html = new HtmlTemplate()
|
|
360
|
+
|
|
361
|
+
fs.writeFileSync(filePath, html.createHtmlTemplate(
|
|
362
|
+
{
|
|
363
|
+
bodyContent: htmlTemplate
|
|
364
|
+
}
|
|
365
|
+
), "utf8");
|
|
366
|
+
|
|
367
|
+
return result;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
createCssTemplate = (bytes: number[], page: string) => {
|
|
371
|
+
const dir = path.join(__dirname, "public");
|
|
372
|
+
const filePath = path.join(dir, `${page}.css`);
|
|
373
|
+
|
|
374
|
+
if (!fs.existsSync(dir)) {
|
|
375
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
let content = fromPageToString(bytes);
|
|
379
|
+
|
|
380
|
+
fs.writeFileSync(filePath, content, "utf8");
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
createCSSPage = (byteArray: number[]) => {
|
|
384
|
+
return byteArray;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
|
|
2
|
+
import { dataVisualStart, dataVisualEnd, pageStart, dataCodeStart, dataCodeEnd, dataBodyStart, dataBodyEnd, dataHeadStart, dataHeadEnd, pageEnd } from "../data/binary-resources";
|
|
3
|
+
import { DataStream } from "../models/data-stream";
|
|
4
|
+
import { DataComponentModel, DataTypeModel } from "../models/data-type-model";
|
|
5
|
+
import { BinaryData } from './BinaryData';
|
|
6
|
+
|
|
7
|
+
export class DataTypes {
|
|
8
|
+
initDataTypes() {
|
|
9
|
+
let app = {
|
|
10
|
+
template: this.htmlDataTemplate(),
|
|
11
|
+
shell: this.tsDataType(),
|
|
12
|
+
visual: this.cssDataType()
|
|
13
|
+
} as DataComponentModel;
|
|
14
|
+
|
|
15
|
+
return app;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
writeDataBinary = (startIndex:number, endIndex: number, number: number[]) : DataStream => {
|
|
19
|
+
let binaryData = new BinaryData();
|
|
20
|
+
|
|
21
|
+
let result = binaryData.setTemplateBinaryData(startIndex, endIndex, number);
|
|
22
|
+
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
headDataType = () : DataTypeModel => {
|
|
27
|
+
let binaryData = new BinaryData();
|
|
28
|
+
let startIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataHeadStart);
|
|
29
|
+
let endIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataHeadEnd) - dataHeadEnd.bitMap.length;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
name: 'head',
|
|
33
|
+
type: 'head-attr',
|
|
34
|
+
byteTemplate: binaryData.getTemplateBinaryData(startIndex, endIndex),
|
|
35
|
+
startIndex: startIndex,
|
|
36
|
+
endIndex: endIndex
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
customDataType = (customDataStart :{ name: string; code: number; bitMap: number[]; }, customDataEnd:{ name: string; code: number; bitMap: number[];}) : DataTypeModel => {
|
|
41
|
+
let binaryData = new BinaryData();
|
|
42
|
+
let startIndex = binaryData.getTemplateBinaryDataDirective(0, 0, customDataStart);
|
|
43
|
+
let endIndex = binaryData.getTemplateBinaryDataDirective(0, 0, customDataEnd) - customDataEnd.bitMap.length;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
name: customDataStart.name,
|
|
47
|
+
type: customDataStart.name + '-page',
|
|
48
|
+
byteTemplate: binaryData.getTemplateBinaryData(startIndex, endIndex),
|
|
49
|
+
startIndex: startIndex,
|
|
50
|
+
endIndex: endIndex
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bodyDataType = () : DataTypeModel => {
|
|
55
|
+
let binaryData = new BinaryData();
|
|
56
|
+
let startIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataBodyStart);
|
|
57
|
+
let endIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataBodyEnd) - dataBodyEnd.bitMap.length;
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
name: 'index',
|
|
61
|
+
type: 'index-page',
|
|
62
|
+
byteTemplate: binaryData.getTemplateBinaryData(startIndex, endIndex),
|
|
63
|
+
startIndex: startIndex,
|
|
64
|
+
endIndex: endIndex
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
cssDataType =(): DataTypeModel => {
|
|
69
|
+
let binaryData = new BinaryData();
|
|
70
|
+
let startIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataVisualStart);
|
|
71
|
+
let endIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataVisualEnd) - dataVisualEnd.bitMap.length;
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
name: 'css',
|
|
75
|
+
type: 'css-template',
|
|
76
|
+
byteTemplate: binaryData.getTemplateBinaryData(startIndex, endIndex),
|
|
77
|
+
startIndex: startIndex,
|
|
78
|
+
endIndex: endIndex
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
htmlDataTemplate = (): DataTypeModel => {
|
|
83
|
+
let binaryData = new BinaryData();
|
|
84
|
+
let startIndex = binaryData.getTemplateBinaryDataDirective(0, 0, pageStart);
|
|
85
|
+
let endIndex;
|
|
86
|
+
try{
|
|
87
|
+
endIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataCodeStart) - pageStart.code;
|
|
88
|
+
|
|
89
|
+
}catch(ex){
|
|
90
|
+
endIndex = binaryData.getTemplateBinaryDataDirective(0, 0, pageEnd) - pageStart.code
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
name: 'html',
|
|
95
|
+
type: 'html-template',
|
|
96
|
+
byteTemplate: binaryData.getTemplateBinaryData(startIndex, endIndex),
|
|
97
|
+
startIndex: startIndex,
|
|
98
|
+
endIndex: endIndex
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
tsDataType: () => DataTypeModel = () => {
|
|
104
|
+
let binaryData = new BinaryData();
|
|
105
|
+
let startIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataCodeStart);
|
|
106
|
+
let endIndex = binaryData.getTemplateBinaryDataDirective(0, 0, dataCodeEnd) - dataCodeEnd.bitMap.length;
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
name: 'ts',
|
|
110
|
+
type: 'ts-template',
|
|
111
|
+
byteTemplate: binaryData.getTemplateBinaryData(startIndex, endIndex),
|
|
112
|
+
startIndex: startIndex,
|
|
113
|
+
endIndex: endIndex
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|