@itrocks/template 0.0.24 → 0.0.25

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/cjs/template.d.ts CHANGED
@@ -31,6 +31,7 @@ export default class Template {
31
31
  literalParts: string[];
32
32
  literalPartStack: string[][];
33
33
  lockLiteral: boolean;
34
+ addLinks: SortedArray<string>;
34
35
  doHeadLinks: boolean;
35
36
  doneLinks: SortedArray<string>;
36
37
  headLinks: SortedArray<string>;
@@ -54,6 +55,7 @@ export default class Template {
54
55
  combineLiterals(text: string, parts?: string[]): string;
55
56
  debugEvents(): void;
56
57
  getCleanContext(): {
58
+ addLinks: SortedArray<string>;
57
59
  doHeadLinks: boolean;
58
60
  doneLinks: SortedArray<string>;
59
61
  headLinks: SortedArray<string>;
@@ -73,6 +75,7 @@ export default class Template {
73
75
  target: string;
74
76
  };
75
77
  getContext(): {
78
+ addLinks: SortedArray<string>;
76
79
  doHeadLinks: boolean;
77
80
  doneLinks: SortedArray<string>;
78
81
  headLinks: SortedArray<string>;
package/cjs/template.js CHANGED
@@ -34,6 +34,7 @@ class Template {
34
34
  literalPartStack = [];
35
35
  lockLiteral = false;
36
36
  // html head
37
+ addLinks = new sorted_array_1.SortedArray();
37
38
  doHeadLinks = false;
38
39
  doneLinks = new sorted_array_1.SortedArray();
39
40
  headLinks = new sorted_array_1.SortedArray();
@@ -61,6 +62,7 @@ class Template {
61
62
  constructor(data, containerData) {
62
63
  this.data = data;
63
64
  this.containerData = containerData;
65
+ this.addLinks.distinct = true;
64
66
  this.doneLinks.distinct = true;
65
67
  this.headLinks.distinct = true;
66
68
  this.blockStack = [];
@@ -112,11 +114,14 @@ class Template {
112
114
  this.onTagClose = (name) => console.log('tag.closed =', name);
113
115
  }
114
116
  getCleanContext() {
117
+ const addLinks = new sorted_array_1.SortedArray;
115
118
  const doneLinks = new sorted_array_1.SortedArray;
116
119
  const headLinks = new sorted_array_1.SortedArray;
120
+ addLinks.distinct = true;
117
121
  doneLinks.distinct = true;
118
122
  headLinks.distinct = true;
119
123
  return {
124
+ addLinks: addLinks,
120
125
  doHeadLinks: false,
121
126
  doneLinks: doneLinks,
122
127
  headLinks: headLinks,
@@ -136,6 +141,7 @@ class Template {
136
141
  }
137
142
  getContext() {
138
143
  return {
144
+ addLinks: this.addLinks,
139
145
  doHeadLinks: this.doHeadLinks,
140
146
  doneLinks: this.doneLinks,
141
147
  headLinks: this.headLinks,
@@ -166,6 +172,9 @@ class Template {
166
172
  const parsed = await template.parseFile(((path[0] === node_path_1.sep) || (path[1] === ':'))
167
173
  ? path
168
174
  : (this.filePath + node_path_1.sep + path));
175
+ if (!this.doHeadLinks) {
176
+ this.addLinks.push(...template.headLinks);
177
+ }
169
178
  this.headLinks.push(...template.headLinks);
170
179
  this.headTitle = template.headTitle;
171
180
  return parsed.substring(parsed.indexOf('<!--BEGIN-->') + 12, parsed.indexOf('<!--END-->'));
@@ -174,6 +183,8 @@ class Template {
174
183
  const clean = this.getCleanContext();
175
184
  const context = this.getContext();
176
185
  return context.doHeadLinks === clean.doHeadLinks
186
+ && context.addLinks.distinct === clean.addLinks.distinct
187
+ && context.addLinks.length === clean.addLinks.length
177
188
  && context.doneLinks.distinct === clean.doneLinks.distinct
178
189
  && context.doneLinks.length === clean.doneLinks.length
179
190
  && context.headLinks.distinct === clean.headLinks.distinct
@@ -210,9 +221,9 @@ class Template {
210
221
  if (this.doHeadLinks) {
211
222
  return this.target;
212
223
  }
213
- if (this.headLinks.length) {
224
+ if (this.addLinks.length) {
214
225
  const position = this.target.lastIndexOf('>', this.target.indexOf('</head>')) + 1;
215
- this.target = this.target.slice(0, position) + '\n\t' + this.headLinks.join('\n\t') + this.target.slice(position);
226
+ this.target = this.target.slice(0, position) + '\n\t' + this.addLinks.join('\n\t') + this.target.slice(position);
216
227
  }
217
228
  if (this.headTitle && !this.included) {
218
229
  const position = this.target.indexOf('>', this.target.indexOf('<title') + 6) + 1;
package/esm/template.d.ts CHANGED
@@ -31,6 +31,7 @@ export default class Template {
31
31
  literalParts: string[];
32
32
  literalPartStack: string[][];
33
33
  lockLiteral: boolean;
34
+ addLinks: SortedArray<string>;
34
35
  doHeadLinks: boolean;
35
36
  doneLinks: SortedArray<string>;
36
37
  headLinks: SortedArray<string>;
@@ -54,6 +55,7 @@ export default class Template {
54
55
  combineLiterals(text: string, parts?: string[]): string;
55
56
  debugEvents(): void;
56
57
  getCleanContext(): {
58
+ addLinks: SortedArray<string>;
57
59
  doHeadLinks: boolean;
58
60
  doneLinks: SortedArray<string>;
59
61
  headLinks: SortedArray<string>;
@@ -73,6 +75,7 @@ export default class Template {
73
75
  target: string;
74
76
  };
75
77
  getContext(): {
78
+ addLinks: SortedArray<string>;
76
79
  doHeadLinks: boolean;
77
80
  doneLinks: SortedArray<string>;
78
81
  headLinks: SortedArray<string>;
package/esm/template.js CHANGED
@@ -29,6 +29,7 @@ export default class Template {
29
29
  literalPartStack = [];
30
30
  lockLiteral = false;
31
31
  // html head
32
+ addLinks = new SortedArray();
32
33
  doHeadLinks = false;
33
34
  doneLinks = new SortedArray();
34
35
  headLinks = new SortedArray();
@@ -56,6 +57,7 @@ export default class Template {
56
57
  constructor(data, containerData) {
57
58
  this.data = data;
58
59
  this.containerData = containerData;
60
+ this.addLinks.distinct = true;
59
61
  this.doneLinks.distinct = true;
60
62
  this.headLinks.distinct = true;
61
63
  this.blockStack = [];
@@ -107,11 +109,14 @@ export default class Template {
107
109
  this.onTagClose = (name) => console.log('tag.closed =', name);
108
110
  }
109
111
  getCleanContext() {
112
+ const addLinks = new SortedArray;
110
113
  const doneLinks = new SortedArray;
111
114
  const headLinks = new SortedArray;
115
+ addLinks.distinct = true;
112
116
  doneLinks.distinct = true;
113
117
  headLinks.distinct = true;
114
118
  return {
119
+ addLinks: addLinks,
115
120
  doHeadLinks: false,
116
121
  doneLinks: doneLinks,
117
122
  headLinks: headLinks,
@@ -131,6 +136,7 @@ export default class Template {
131
136
  }
132
137
  getContext() {
133
138
  return {
139
+ addLinks: this.addLinks,
134
140
  doHeadLinks: this.doHeadLinks,
135
141
  doneLinks: this.doneLinks,
136
142
  headLinks: this.headLinks,
@@ -161,6 +167,9 @@ export default class Template {
161
167
  const parsed = await template.parseFile(((path[0] === sep) || (path[1] === ':'))
162
168
  ? path
163
169
  : (this.filePath + sep + path));
170
+ if (!this.doHeadLinks) {
171
+ this.addLinks.push(...template.headLinks);
172
+ }
164
173
  this.headLinks.push(...template.headLinks);
165
174
  this.headTitle = template.headTitle;
166
175
  return parsed.substring(parsed.indexOf('<!--BEGIN-->') + 12, parsed.indexOf('<!--END-->'));
@@ -169,6 +178,8 @@ export default class Template {
169
178
  const clean = this.getCleanContext();
170
179
  const context = this.getContext();
171
180
  return context.doHeadLinks === clean.doHeadLinks
181
+ && context.addLinks.distinct === clean.addLinks.distinct
182
+ && context.addLinks.length === clean.addLinks.length
172
183
  && context.doneLinks.distinct === clean.doneLinks.distinct
173
184
  && context.doneLinks.length === clean.doneLinks.length
174
185
  && context.headLinks.distinct === clean.headLinks.distinct
@@ -205,9 +216,9 @@ export default class Template {
205
216
  if (this.doHeadLinks) {
206
217
  return this.target;
207
218
  }
208
- if (this.headLinks.length) {
219
+ if (this.addLinks.length) {
209
220
  const position = this.target.lastIndexOf('>', this.target.indexOf('</head>')) + 1;
210
- this.target = this.target.slice(0, position) + '\n\t' + this.headLinks.join('\n\t') + this.target.slice(position);
221
+ this.target = this.target.slice(0, position) + '\n\t' + this.addLinks.join('\n\t') + this.target.slice(position);
211
222
  }
212
223
  if (this.headTitle && !this.included) {
213
224
  const position = this.target.indexOf('>', this.target.indexOf('<title') + 6) + 1;
package/package.json CHANGED
@@ -67,5 +67,5 @@
67
67
  "test": "jest"
68
68
  },
69
69
  "types": "./esm/template.d.ts",
70
- "version": "0.0.24"
70
+ "version": "0.0.25"
71
71
  }