mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-19 21:18:20 +02:00
Jauge de contexte, espace disque sur partage agrégé, panneau Fichiers
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>
This commit is contained in:
1 parent
895ff92ed8
commit
b405adea6c
5118 files changed
+1264007
-23
No files matched your search
+160
@@ -0,0 +1,160 @@
|
||||
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
var _tokenizer = require('../parser/tokenizer');
|
||||
var _types = require('../parser/tokenizer/types');
|
||||
|
||||
|
||||
var _Transformer = require('./Transformer'); var _Transformer2 = _interopRequireDefault(_Transformer);
|
||||
|
||||
/**
|
||||
* Implementation of babel-plugin-transform-react-display-name, which adds a
|
||||
* display name to usages of React.createClass and createReactClass.
|
||||
*/
|
||||
class ReactDisplayNameTransformer extends _Transformer2.default {
|
||||
constructor(
|
||||
rootTransformer,
|
||||
tokens,
|
||||
importProcessor,
|
||||
options,
|
||||
) {
|
||||
super();this.rootTransformer = rootTransformer;this.tokens = tokens;this.importProcessor = importProcessor;this.options = options;;
|
||||
}
|
||||
|
||||
process() {
|
||||
const startIndex = this.tokens.currentIndex();
|
||||
if (this.tokens.identifierName() === "createReactClass") {
|
||||
const newName =
|
||||
this.importProcessor && this.importProcessor.getIdentifierReplacement("createReactClass");
|
||||
if (newName) {
|
||||
this.tokens.replaceToken(`(0, ${newName})`);
|
||||
} else {
|
||||
this.tokens.copyToken();
|
||||
}
|
||||
this.tryProcessCreateClassCall(startIndex);
|
||||
return true;
|
||||
}
|
||||
if (
|
||||
this.tokens.matches3(_types.TokenType.name, _types.TokenType.dot, _types.TokenType.name) &&
|
||||
this.tokens.identifierName() === "React" &&
|
||||
this.tokens.identifierNameAtIndex(this.tokens.currentIndex() + 2) === "createClass"
|
||||
) {
|
||||
const newName = this.importProcessor
|
||||
? this.importProcessor.getIdentifierReplacement("React") || "React"
|
||||
: "React";
|
||||
if (newName) {
|
||||
this.tokens.replaceToken(newName);
|
||||
this.tokens.copyToken();
|
||||
this.tokens.copyToken();
|
||||
} else {
|
||||
this.tokens.copyToken();
|
||||
this.tokens.copyToken();
|
||||
this.tokens.copyToken();
|
||||
}
|
||||
this.tryProcessCreateClassCall(startIndex);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is called with the token position at the open-paren.
|
||||
*/
|
||||
tryProcessCreateClassCall(startIndex) {
|
||||
const displayName = this.findDisplayName(startIndex);
|
||||
if (!displayName) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.classNeedsDisplayName()) {
|
||||
this.tokens.copyExpectedToken(_types.TokenType.parenL);
|
||||
this.tokens.copyExpectedToken(_types.TokenType.braceL);
|
||||
this.tokens.appendCode(`displayName: '${displayName}',`);
|
||||
this.rootTransformer.processBalancedCode();
|
||||
this.tokens.copyExpectedToken(_types.TokenType.braceR);
|
||||
this.tokens.copyExpectedToken(_types.TokenType.parenR);
|
||||
}
|
||||
}
|
||||
|
||||
findDisplayName(startIndex) {
|
||||
if (startIndex < 2) {
|
||||
return null;
|
||||
}
|
||||
if (this.tokens.matches2AtIndex(startIndex - 2, _types.TokenType.name, _types.TokenType.eq)) {
|
||||
// This is an assignment (or declaration) and the LHS is either an identifier or a member
|
||||
// expression ending in an identifier, so use that identifier name.
|
||||
return this.tokens.identifierNameAtIndex(startIndex - 2);
|
||||
}
|
||||
if (
|
||||
startIndex >= 2 &&
|
||||
this.tokens.tokens[startIndex - 2].identifierRole === _tokenizer.IdentifierRole.ObjectKey
|
||||
) {
|
||||
// This is an object literal value.
|
||||
return this.tokens.identifierNameAtIndex(startIndex - 2);
|
||||
}
|
||||
if (this.tokens.matches2AtIndex(startIndex - 2, _types.TokenType._export, _types.TokenType._default)) {
|
||||
return this.getDisplayNameFromFilename();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getDisplayNameFromFilename() {
|
||||
const filePath = this.options.filePath || "unknown";
|
||||
const pathSegments = filePath.split("/");
|
||||
const filename = pathSegments[pathSegments.length - 1];
|
||||
const dotIndex = filename.lastIndexOf(".");
|
||||
const baseFilename = dotIndex === -1 ? filename : filename.slice(0, dotIndex);
|
||||
if (baseFilename === "index" && pathSegments[pathSegments.length - 2]) {
|
||||
return pathSegments[pathSegments.length - 2];
|
||||
} else {
|
||||
return baseFilename;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We only want to add a display name when this is a function call containing
|
||||
* one argument, which is an object literal without `displayName` as an
|
||||
* existing key.
|
||||
*/
|
||||
classNeedsDisplayName() {
|
||||
let index = this.tokens.currentIndex();
|
||||
if (!this.tokens.matches2(_types.TokenType.parenL, _types.TokenType.braceL)) {
|
||||
return false;
|
||||
}
|
||||
// The block starts on the {, and we expect any displayName key to be in
|
||||
// that context. We need to ignore other other contexts to avoid matching
|
||||
// nested displayName keys.
|
||||
const objectStartIndex = index + 1;
|
||||
const objectContextId = this.tokens.tokens[objectStartIndex].contextId;
|
||||
if (objectContextId == null) {
|
||||
throw new Error("Expected non-null context ID on object open-brace.");
|
||||
}
|
||||
|
||||
for (; index < this.tokens.tokens.length; index++) {
|
||||
const token = this.tokens.tokens[index];
|
||||
if (token.type === _types.TokenType.braceR && token.contextId === objectContextId) {
|
||||
index++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (
|
||||
this.tokens.identifierNameAtIndex(index) === "displayName" &&
|
||||
this.tokens.tokens[index].identifierRole === _tokenizer.IdentifierRole.ObjectKey &&
|
||||
token.contextId === objectContextId
|
||||
) {
|
||||
// We found a displayName key, so bail out.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (index === this.tokens.tokens.length) {
|
||||
throw new Error("Unexpected end of input when processing React class.");
|
||||
}
|
||||
|
||||
// If we got this far, we know we have createClass with an object with no
|
||||
// display name, so we want to proceed as long as that was the only argument.
|
||||
return (
|
||||
this.tokens.matches1AtIndex(index, _types.TokenType.parenR) ||
|
||||
this.tokens.matches2AtIndex(index, _types.TokenType.comma, _types.TokenType.parenR)
|
||||
);
|
||||
}
|
||||
} exports.default = ReactDisplayNameTransformer;
|
||||
Reference in new issue
Block a user