mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-19 13:08:15 +02:00
Trois défauts sans rapport entre eux, tous visibles à l'écran. Jauge de contexte bloquée à « 0 / N (0 %) » : le comptage exact vient de usage.prompt_tokens (include_usage), qu'un llama-server récent a cessé de renvoyer. On note désormais si l'usage est arrivé ; sinon la fin de tour publie l'estimation qui pilote déjà la compaction — approximative, mais jamais absente. Et la souscription envoie la valeur courante juste après le rattrapage : une page rechargée affichait zéro sur une discussion pourtant pleine, faute d'événement ctx_used dans la fenêtre rejouée. Espace disque : « il ne reste que 11,9 Go » sur un partage Unraid qui en a des centaines. /mnt/user est servi par shfs, un FUSE qui agrège plusieurs disques — statfs y renvoie l'espace d'un seul, et ce chiffre REFUSAIT l'installation du modèle. Les systèmes de fichiers qui approximent (FUSE, overlay, NFS, CIFS, Ceph, Gluster) sont reconnus par leur magie : leur chiffre reste affiché, précédé d'un « ~ », mais ne bloque plus rien. Panneau Fichiers : le panneau entier défilait, emportant vers le haut l'en-tête, le fil d'Ariane et le pied (occupation disque, bouton .zip) dès qu'il y avait quelques fichiers. Seule la liste défile maintenant ; le pied reste en bas et l'état vide se centre. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
272 lines
4.6 KiB
Markdown
272 lines
4.6 KiB
Markdown
# style-to-js
|
|
|
|
[](https://nodei.co/npm/style-to-js/)
|
|
|
|
[](https://www.npmjs.com/package/style-to-js)
|
|
[](https://bundlephobia.com/package/style-to-js)
|
|
[](https://github.com/remarkablemark/style-to-js/actions/workflows/build.yml)
|
|
[](https://codecov.io/gh/remarkablemark/style-to-js)
|
|
[](https://www.npmjs.com/package/style-to-js)
|
|
|
|
Parses CSS inline style to JavaScript object (camelCased):
|
|
|
|
```
|
|
StyleToJS(string)
|
|
```
|
|
|
|
## Example
|
|
|
|
```js
|
|
import parse from 'style-to-js';
|
|
|
|
parse('background-color: #BADA55;');
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{ "backgroundColor": "#BADA55" }
|
|
```
|
|
|
|
[JSFiddle](https://jsfiddle.net/remarkablemark/04nob1y7/) | [Examples](https://github.com/remarkablemark/style-to-js/tree/master/examples)
|
|
|
|
## Install
|
|
|
|
[NPM](https://www.npmjs.com/package/style-to-js):
|
|
|
|
```sh
|
|
npm install style-to-js --save
|
|
```
|
|
|
|
[Yarn](https://yarnpkg.com/package/style-to-js):
|
|
|
|
```sh
|
|
yarn add style-to-js
|
|
```
|
|
|
|
[CDN](https://unpkg.com/style-to-js/):
|
|
|
|
```html
|
|
<script src="https://unpkg.com/style-to-js@latest/umd/style-to-js.min.js"></script>
|
|
<script>
|
|
window.StyleToJS(/* string */);
|
|
</script>
|
|
```
|
|
|
|
## Usage
|
|
|
|
### Import
|
|
|
|
Import with ES Modules:
|
|
|
|
```js
|
|
import parse from 'style-to-js';
|
|
```
|
|
|
|
Require with CommonJS:
|
|
|
|
```js
|
|
const parse = require('style-to-js');
|
|
```
|
|
|
|
### Parse style
|
|
|
|
Parse single declaration:
|
|
|
|
```js
|
|
parse('line-height: 42');
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{ "lineHeight": "42" }
|
|
```
|
|
|
|
> [!NOTE]
|
|
> Notice that the CSS property is camelCased.
|
|
|
|
Parse multiple declarations:
|
|
|
|
```js
|
|
parse(`
|
|
border-color: #ACE;
|
|
z-index: 1337;
|
|
`);
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{
|
|
"borderColor": "#ACE",
|
|
"zIndex": "1337"
|
|
}
|
|
```
|
|
|
|
### Vendor prefix
|
|
|
|
Parse [vendor prefix](https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix):
|
|
|
|
```js
|
|
parse(`
|
|
-webkit-transition: all 4s ease;
|
|
-moz-transition: all 4s ease;
|
|
-ms-transition: all 4s ease;
|
|
-o-transition: all 4s ease;
|
|
-khtml-transition: all 4s ease;
|
|
`);
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{
|
|
"webkitTransition": "all 4s ease",
|
|
"mozTransition": "all 4s ease",
|
|
"msTransition": "all 4s ease",
|
|
"oTransition": "all 4s ease",
|
|
"khtmlTransition": "all 4s ease"
|
|
}
|
|
```
|
|
|
|
### Custom property
|
|
|
|
Parse [custom property](https://developer.mozilla.org/en-US/docs/Web/CSS/--*):
|
|
|
|
```js
|
|
parse('--custom-property: #f00');
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{ "--custom-property": "#f00" }
|
|
```
|
|
|
|
### Unknown declaration
|
|
|
|
This library does not validate declarations, so unknown declarations can be parsed:
|
|
|
|
```js
|
|
parse('the-answer: 42;');
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{ "theAnswer": "42" }
|
|
```
|
|
|
|
### Invalid declaration
|
|
|
|
Declarations with missing value are removed:
|
|
|
|
```js
|
|
parse(`
|
|
margin-top: ;
|
|
margin-right: 1em;
|
|
`);
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{ "marginRight": "1em" }
|
|
```
|
|
|
|
Other invalid declarations or arguments:
|
|
|
|
```js
|
|
parse(); // {}
|
|
parse(null); // {}
|
|
parse(1); // {}
|
|
parse(true); // {}
|
|
parse('top:'); // {}
|
|
parse(':12px'); // {}
|
|
parse(':'); // {}
|
|
parse(';'); // {}
|
|
```
|
|
|
|
The following values will throw an error:
|
|
|
|
```js
|
|
parse('top'); // Uncaught Error: property missing ':'
|
|
parse('/*'); // Uncaught Error: End of comment missing
|
|
```
|
|
|
|
### Options
|
|
|
|
#### reactCompat
|
|
|
|
When option `reactCompat` is true, the [vendor prefix](https://developer.mozilla.org/en-US/docs/Glossary/Vendor_Prefix) will be capitalized:
|
|
|
|
```js
|
|
parse(
|
|
`
|
|
-webkit-transition: all 4s ease;
|
|
-moz-transition: all 4s ease;
|
|
-ms-transition: all 4s ease;
|
|
-o-transition: all 4s ease;
|
|
-khtml-transition: all 4s ease;
|
|
`,
|
|
{ reactCompat: true },
|
|
);
|
|
```
|
|
|
|
Output:
|
|
|
|
```json
|
|
{
|
|
"WebkitTransition": "all 4s ease",
|
|
"MozTransition": "all 4s ease",
|
|
"msTransition": "all 4s ease",
|
|
"OTransition": "all 4s ease",
|
|
"KhtmlTransition": "all 4s ease"
|
|
}
|
|
```
|
|
|
|
This removes the React warning:
|
|
|
|
```
|
|
Warning: Unsupported vendor-prefixed style property %s. Did you mean %s?%s", "oTransition", "OTransition"
|
|
```
|
|
|
|
## Testing
|
|
|
|
Run tests with coverage:
|
|
|
|
```sh
|
|
npm test
|
|
```
|
|
|
|
Run tests in watch mode:
|
|
|
|
```sh
|
|
npm run test:watch
|
|
```
|
|
|
|
Lint files:
|
|
|
|
```sh
|
|
npm run lint
|
|
```
|
|
|
|
Fix lint errors:
|
|
|
|
```sh
|
|
npm run lint:fix
|
|
```
|
|
|
|
## Release
|
|
|
|
Release and publish are automated by [Release Please](https://github.com/googleapis/release-please).
|
|
|
|
## Special Thanks
|
|
|
|
- [style-to-object](https://github.com/remarkablemark/style-to-object)
|
|
|
|
## License
|
|
|
|
[MIT](https://github.com/remarkablemark/style-to-js/blob/master/LICENSE)
|