@schukai/monster 3.110.2 → 3.110.3
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/CHANGELOG.md +12 -0
- package/package.json +1 -1
- package/source/text/bracketed-key-value-hash.mjs +187 -183
- package/source/types/version.mjs +1 -1
- package/test/cases/monster.mjs +1 -1
- package/test/web/test.html +2 -2
- package/test/web/tests.js +628 -300
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8","buffer":"^6.0.3"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.110.
|
1
|
+
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.6.13","@popperjs/core":"^2.11.8","buffer":"^6.0.3"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"3.110.3"}
|
@@ -12,7 +12,7 @@
|
|
12
12
|
* SPDX-License-Identifier: AGPL-3.0
|
13
13
|
*/
|
14
14
|
|
15
|
-
export {
|
15
|
+
export {parseBracketedKeyValueHash, createBracketedKeyValueHash};
|
16
16
|
|
17
17
|
/**
|
18
18
|
* Parses a string containing bracketed key-value pairs and returns an object representing the parsed result.
|
@@ -51,155 +51,155 @@ export { parseBracketedKeyValueHash, createBracketedKeyValueHash };
|
|
51
51
|
* @return {Object} - An object representing the parsed result, with keys representing the selectors and values representing the key-value pairs associated with each selector.
|
52
52
|
* - Returns an empty object if there was an error during parsing. */
|
53
53
|
function parseBracketedKeyValueHash(hashString) {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
54
|
+
const selectors = {};
|
55
|
+
//const selectorStack = [];
|
56
|
+
//const keyValueStack = [];
|
57
|
+
|
58
|
+
const trimmedHashString = hashString.trim();
|
59
|
+
const cleanedHashString =
|
60
|
+
trimmedHashString.charAt(0) === "#"
|
61
|
+
? trimmedHashString.slice(1)
|
62
|
+
: trimmedHashString;
|
63
|
+
|
64
|
+
//const selectors = (keyValueStack.length > 0) ? result[selectorStack[selectorStack.length - 1]] : result;
|
65
|
+
let currentSelector = "";
|
66
|
+
|
67
|
+
function addToResult(key, value) {
|
68
|
+
if (currentSelector && key) {
|
69
|
+
if (!selectors[currentSelector]) {
|
70
|
+
selectors[currentSelector] = {};
|
71
|
+
}
|
72
|
+
|
73
|
+
selectors[currentSelector][key] = value;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
let currentKey = "";
|
78
|
+
let currentValue = "";
|
79
|
+
let inKey = true;
|
80
|
+
let inValue = false;
|
81
|
+
let inQuotedValue = false;
|
82
|
+
let inSelector = true;
|
83
|
+
let escaped = false;
|
84
|
+
let quotedValueStartChar = "";
|
85
|
+
|
86
|
+
for (let i = 0; i < cleanedHashString.length; i++) {
|
87
|
+
const c = cleanedHashString[i];
|
88
|
+
const nextChar = cleanedHashString?.[i + 1];
|
89
|
+
|
90
|
+
if (c === "\\" && !escaped) {
|
91
|
+
escaped = true;
|
92
|
+
continue;
|
93
|
+
}
|
94
|
+
|
95
|
+
if (escaped) {
|
96
|
+
if (inSelector) {
|
97
|
+
currentSelector += c;
|
98
|
+
} else if (inKey) {
|
99
|
+
currentKey += c;
|
100
|
+
} else if (inValue) {
|
101
|
+
currentValue += c;
|
102
|
+
}
|
103
|
+
escaped = false;
|
104
|
+
continue;
|
105
|
+
}
|
106
|
+
|
107
|
+
if (inQuotedValue && quotedValueStartChar !== c) {
|
108
|
+
if (inSelector) {
|
109
|
+
currentSelector += c;
|
110
|
+
} else if (inKey) {
|
111
|
+
currentKey += c;
|
112
|
+
} else if (inValue) {
|
113
|
+
currentValue += c;
|
114
|
+
}
|
115
|
+
|
116
|
+
continue;
|
117
|
+
}
|
118
|
+
|
119
|
+
if (c === ";" && inSelector) {
|
120
|
+
inSelector = true;
|
121
|
+
currentSelector = "";
|
122
|
+
continue;
|
123
|
+
}
|
124
|
+
|
125
|
+
if (inSelector === true && c !== "(") {
|
126
|
+
currentSelector += c;
|
127
|
+
continue;
|
128
|
+
}
|
129
|
+
|
130
|
+
if (c === "(" && inSelector) {
|
131
|
+
inSelector = false;
|
132
|
+
inKey = true;
|
133
|
+
|
134
|
+
currentKey = "";
|
135
|
+
continue;
|
136
|
+
}
|
137
|
+
|
138
|
+
if (inKey === true && c !== "=") {
|
139
|
+
currentKey += c;
|
140
|
+
continue;
|
141
|
+
}
|
142
|
+
|
143
|
+
if (c === "=" && inKey) {
|
144
|
+
inKey = false;
|
145
|
+
inValue = true;
|
146
|
+
|
147
|
+
if (nextChar === '"' || nextChar === "'") {
|
148
|
+
inQuotedValue = true;
|
149
|
+
quotedValueStartChar = nextChar;
|
150
|
+
i++;
|
151
|
+
continue;
|
152
|
+
}
|
153
|
+
|
154
|
+
currentValue = "";
|
155
|
+
continue;
|
156
|
+
}
|
157
|
+
|
158
|
+
if (inValue === true) {
|
159
|
+
if (inQuotedValue) {
|
160
|
+
if (c === quotedValueStartChar) {
|
161
|
+
inQuotedValue = false;
|
162
|
+
continue;
|
163
|
+
}
|
164
|
+
|
165
|
+
currentValue += c;
|
166
|
+
continue;
|
167
|
+
}
|
168
|
+
|
169
|
+
if (c === ",") {
|
170
|
+
inValue = false;
|
171
|
+
inKey = true;
|
172
|
+
const decodedCurrentValue = decodeURIComponent(currentValue);
|
173
|
+
addToResult(currentKey, decodedCurrentValue);
|
174
|
+
currentKey = "";
|
175
|
+
currentValue = "";
|
176
|
+
continue;
|
177
|
+
}
|
178
|
+
|
179
|
+
if (c === ")") {
|
180
|
+
inValue = false;
|
181
|
+
//inKey = true;
|
182
|
+
inSelector = true;
|
183
|
+
|
184
|
+
const decodedCurrentValue = decodeURIComponent(currentValue);
|
185
|
+
addToResult(currentKey, decodedCurrentValue);
|
186
|
+
currentKey = "";
|
187
|
+
currentValue = "";
|
188
|
+
currentSelector = "";
|
189
|
+
continue;
|
190
|
+
}
|
191
|
+
|
192
|
+
currentValue += c;
|
193
|
+
|
194
|
+
continue;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
|
198
|
+
if (inSelector) {
|
199
|
+
return selectors;
|
200
|
+
}
|
201
|
+
|
202
|
+
return {};
|
203
203
|
}
|
204
204
|
|
205
205
|
/**
|
@@ -211,37 +211,41 @@ function parseBracketedKeyValueHash(hashString) {
|
|
211
211
|
* @since 3.37.0
|
212
212
|
*/
|
213
213
|
function createBracketedKeyValueHash(object, addHashPrefix = true) {
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
214
|
+
if (!object) {
|
215
|
+
return addHashPrefix ? "#" : "";
|
216
|
+
}
|
217
|
+
|
218
|
+
let hashString = "";
|
219
|
+
|
220
|
+
function encodeKeyValue(key, value) {
|
221
|
+
return encodeURIComponent(key) + "=" + encodeURIComponent(value);
|
222
|
+
}
|
223
|
+
|
224
|
+
for (const selector in object) {
|
225
|
+
if (object.hasOwnProperty(selector)) {
|
226
|
+
const keyValuePairs = object[selector];
|
227
|
+
let selectorString = selector;
|
228
|
+
let keyValueString = "";
|
229
|
+
|
230
|
+
for (const key in keyValuePairs) {
|
231
|
+
if (keyValuePairs.hasOwnProperty(key)) {
|
232
|
+
const value = keyValuePairs[key];
|
233
|
+
keyValueString += keyValueString.length === 0 ? "" : ",";
|
234
|
+
keyValueString += encodeKeyValue(key, value);
|
235
|
+
}
|
236
|
+
}
|
237
|
+
|
238
|
+
if (keyValueString.length > 0) {
|
239
|
+
selectorString += "(" + keyValueString + ")";
|
240
|
+
hashString += hashString.length === 0 ? "" : ";";
|
241
|
+
hashString += selectorString;
|
242
|
+
}
|
243
|
+
}
|
244
|
+
}
|
245
|
+
|
246
|
+
if (hashString.length>0 && addHashPrefix) {
|
247
|
+
hashString = "#" + hashString;
|
248
|
+
}
|
249
|
+
|
250
|
+
return hashString;
|
247
251
|
}
|
package/source/types/version.mjs
CHANGED
package/test/cases/monster.mjs
CHANGED
package/test/web/test.html
CHANGED
@@ -9,8 +9,8 @@
|
|
9
9
|
</head>
|
10
10
|
<body>
|
11
11
|
<div id="headline" style="display: flex;align-items: center;justify-content: center;flex-direction: column;">
|
12
|
-
<h1 style='margin-bottom: 0.1em;'>Monster 3.
|
13
|
-
<div id="lastupdate" style='font-size:0.7em'>last update
|
12
|
+
<h1 style='margin-bottom: 0.1em;'>Monster 3.110.2</h1>
|
13
|
+
<div id="lastupdate" style='font-size:0.7em'>last update Mi 19. Feb 22:20:07 CET 2025</div>
|
14
14
|
</div>
|
15
15
|
<div id="mocha-errors"
|
16
16
|
style="color: red;font-weight: bold;display: flex;align-items: center;justify-content: center;flex-direction: column;margin:20px;"></div>
|