@appsemble/node-utils 0.38.0 → 0.38.2-test.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/README.md +3 -3
- package/app.js +32 -1
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Node Utilities
|
|
1
|
+
#  Appsemble Node Utilities
|
|
2
2
|
|
|
3
3
|
> NodeJS utilities used by Appsemble internally.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/node-utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.38.0)
|
|
6
|
+
[](https://gitlab.com/appsemble/appsemble/-/releases/0.38.2-test.0)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ compatibility is not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.38.0/LICENSE.md) ©
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.38.2-test.0/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/app.js
CHANGED
|
@@ -94,6 +94,32 @@ export async function getRemapperContext(app, language, options, context) {
|
|
|
94
94
|
group: groupInfo ?? undefined,
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Split a style patch value into the declaration value and its `!important` flag.
|
|
99
|
+
*
|
|
100
|
+
* Patch values are written the way they appear in a stylesheet, so they may end in `!important`
|
|
101
|
+
* and a semicolon. css-tree keeps the important flag separate from the raw value; embedding
|
|
102
|
+
* `!important` in the value would serialize as `!important!important` on declarations that
|
|
103
|
+
* already carry the flag.
|
|
104
|
+
*
|
|
105
|
+
* @param property The declaration property.
|
|
106
|
+
* @param value The raw value from `styles.json`.
|
|
107
|
+
* @returns The value without the trailing semicolon and important flag, and whether it had one.
|
|
108
|
+
*/
|
|
109
|
+
function parseStyleValue(property, value) {
|
|
110
|
+
const declarationList = parse(`${property}:${value}`, {
|
|
111
|
+
context: 'declarationList',
|
|
112
|
+
parseValue: false,
|
|
113
|
+
});
|
|
114
|
+
if (declarationList.type !== 'DeclarationList' || declarationList.children.size !== 1) {
|
|
115
|
+
throw new Error('Style patch value must contain exactly one declaration');
|
|
116
|
+
}
|
|
117
|
+
const declaration = declarationList.children.first;
|
|
118
|
+
if (declaration?.type !== 'Declaration' || declaration.value.type !== 'Raw') {
|
|
119
|
+
throw new Error('Style patch value must be a raw declaration value');
|
|
120
|
+
}
|
|
121
|
+
return { important: Boolean(declaration.important), value: declaration.value.value };
|
|
122
|
+
}
|
|
97
123
|
function replaceStyle(stylesheet, selector, property, value) {
|
|
98
124
|
try {
|
|
99
125
|
walk(stylesheet, (nodeSelector) => {
|
|
@@ -106,8 +132,13 @@ function replaceStyle(stylesheet, selector, property, value) {
|
|
|
106
132
|
return;
|
|
107
133
|
}
|
|
108
134
|
if (declaration.property === property) {
|
|
135
|
+
const { important, value: patchValue } = parseStyleValue(property, value);
|
|
109
136
|
// eslint-disable-next-line no-param-reassign
|
|
110
|
-
declaration.value.value =
|
|
137
|
+
declaration.value.value = patchValue;
|
|
138
|
+
if (important) {
|
|
139
|
+
// eslint-disable-next-line no-param-reassign
|
|
140
|
+
declaration.important = true;
|
|
141
|
+
}
|
|
111
142
|
}
|
|
112
143
|
});
|
|
113
144
|
}
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/node-utils",
|
|
3
|
-
"version": "0.38.0",
|
|
3
|
+
"version": "0.38.2-test.0",
|
|
4
4
|
"description": "NodeJS utilities used by Appsemble internally.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -40,9 +40,9 @@
|
|
|
40
40
|
"test": "vitest"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@appsemble/lang-sdk": "0.38.0",
|
|
44
|
-
"@appsemble/types": "0.38.0",
|
|
45
|
-
"@appsemble/utils": "0.38.0",
|
|
43
|
+
"@appsemble/lang-sdk": "0.38.2-test.0",
|
|
44
|
+
"@appsemble/types": "0.38.2-test.0",
|
|
45
|
+
"@appsemble/utils": "0.38.2-test.0",
|
|
46
46
|
"@formatjs/fast-memoize": "^2.0.0",
|
|
47
47
|
"@fortawesome/fontawesome-free": "^6.0.0",
|
|
48
48
|
"@inquirer/prompts": "^8.0.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@odata/parser": "^0.2.0",
|
|
52
52
|
"@types/koa": "^2.0.0",
|
|
53
53
|
"axios": "^1.0.0",
|
|
54
|
-
"bcrypt": "^
|
|
54
|
+
"bcrypt": "^6.0.0",
|
|
55
55
|
"bulma": "=0.9.4",
|
|
56
56
|
"bulma-checkradio": "=2.1.1",
|
|
57
57
|
"bulma-slider": "=2.0.4",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"pg": "^8.16.3",
|
|
94
94
|
"request-filtering-agent": "^3.2.0",
|
|
95
95
|
"sass": "^1.0.0",
|
|
96
|
-
"sharp": "0.35.
|
|
96
|
+
"sharp": "0.35.4",
|
|
97
97
|
"sort-keys": "^5.0.0",
|
|
98
98
|
"strip-bom": "^5.0.0",
|
|
99
99
|
"type-fest": "^4.0.0",
|