@yummacss/intellisense 3.18.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/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/adapters/monaco.cjs +1 -0
- package/dist/adapters/monaco.d.cts +9 -0
- package/dist/adapters/monaco.d.mts +9 -0
- package/dist/adapters/monaco.mjs +1 -0
- package/dist/adapters/vscode.cjs +1 -0
- package/dist/adapters/vscode.d.cts +22 -0
- package/dist/adapters/vscode.d.mts +22 -0
- package/dist/adapters/vscode.mjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +82 -0
- package/dist/index.d.mts +82 -0
- package/dist/index.mjs +1 -0
- package/dist/sort-DLflxnyO.mjs +4 -0
- package/dist/sort-z_8wNh4l.cjs +4 -0
- package/package.json +63 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yumma CSS
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @yummacss/intellisense
|
|
2
|
+
|
|
3
|
+
Shared editor intellisense for Yumma CSS.
|
|
4
|
+
|
|
5
|
+
## Use cases
|
|
6
|
+
|
|
7
|
+
- Building editor extensions or IDE plugins
|
|
8
|
+
- Adding Yumma CSS intellisense to a Monaco-based playground or editor
|
|
9
|
+
- Extending support to new editors via the framework-agnostic core
|
|
10
|
+
|
|
11
|
+
**For styling projects, use [yummacss](https://www.npmjs.com/package/yummacss) instead.**
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
### Monaco
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import {
|
|
19
|
+
registerCompletionProvider,
|
|
20
|
+
registerHoverProvider,
|
|
21
|
+
registerColorProvider,
|
|
22
|
+
registerConflictMarkers,
|
|
23
|
+
registerCodeActionsProvider,
|
|
24
|
+
registerSortAction,
|
|
25
|
+
} from '@yummacss/intellisense/monaco';
|
|
26
|
+
|
|
27
|
+
registerCompletionProvider(monaco);
|
|
28
|
+
registerHoverProvider(monaco);
|
|
29
|
+
registerColorProvider(monaco);
|
|
30
|
+
registerCodeActionsProvider(monaco);
|
|
31
|
+
registerConflictMarkers(monaco, editor);
|
|
32
|
+
registerSortAction(monaco, editor);
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### VS Code
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import {
|
|
39
|
+
CompletionProvider,
|
|
40
|
+
HoverProvider,
|
|
41
|
+
ColorProvider,
|
|
42
|
+
ActionProvider,
|
|
43
|
+
subscribeToDocChanges,
|
|
44
|
+
registerSortCommand,
|
|
45
|
+
} from '@yummacss/intellisense/vscode';
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **Completions** - autocomplete for all Yumma CSS utility classes
|
|
51
|
+
- **Hover** - CSS output, variant context, and docs link on hover
|
|
52
|
+
- **Color decorations** - color swatches inline for color utilities
|
|
53
|
+
- **Conflict detection** - warnings when utilities set the same CSS property
|
|
54
|
+
- **Quick fixes** - one-click resolution for conflicting utilities
|
|
55
|
+
- **Class sorting** - opinionated sort order based on property category
|
|
56
|
+
|
|
57
|
+
Learn more at [yummacss.com](https://yummacss.com)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../sort-z_8wNh4l.cjs`);function t(t){return t.languages.registerCompletionItemProvider(`html`,{provideCompletionItems:(n,r)=>{let i=n.getValueInRange({startLineNumber:1,startColumn:1,endLineNumber:r.lineNumber,endColumn:r.column});if(!/(?:class(?:Name)?)\s*=\s*["'{`][^"'`]*$/.test(i))return{suggestions:[]};let a=n.getWordUntilPosition(r),o={startLineNumber:r.lineNumber,endLineNumber:r.lineNumber,startColumn:a.startColumn,endColumn:a.endColumn};return{suggestions:e.s().map(e=>({label:e.label,insertText:e.insertText,detail:e.detail,kind:e.isColor?t.languages.CompletionItemKind.Color:t.languages.CompletionItemKind.Constant,range:o}))}}})}function n(t){return t.languages.registerHoverProvider(`html`,{provideHover:(n,r)=>{let i=e.r(n.getLineContent(r.lineNumber),r.column-1);if(!i)return null;let a=e.i(i.className);return a?{range:new t.Range(r.lineNumber,i.startIndex+1,r.lineNumber,i.endIndex+1),contents:[{value:a,isTrusted:!0}]}:null}})}function r(t){let n=e.o();return t.languages.registerColorProvider(`html`,{provideColorPresentations:()=>[],provideDocumentColors:r=>{let i=[];for(let a=1;a<=r.getLineCount();a++){let o=r.getLineContent(a),s=new RegExp(e.f.source,`g`),c;for(c=s.exec(o);c!==null;){let r=c[2]??c[4]??c[5];if(!r){c=s.exec(o);continue}let l=c.index+c[0].indexOf(r),u=r.split(/\s+/).filter(Boolean),d=0;for(let o of u){let s=o.includes(`:`)?o.slice(o.lastIndexOf(`:`)+1):o,c=n.get(s);if(c){let n=e.c(c.cssValue);if(n){let e=r.indexOf(o,d);if(e!==-1){let r=l+e;i.push({color:{red:n.r,green:n.g,blue:n.b,alpha:n.a},range:new t.Range(a,r+1,a,r+o.length+1)}),d=e+o.length}}}}c=s.exec(o)}}return i}})}function i(t,n){function r(){let r=n.getModel();if(!r)return;let i=[];for(let n=1;n<=r.getLineCount();n++){let a=e.u(r.getLineContent(n));for(let e of a)i.push({severity:t.MarkerSeverity.Warning,message:`${[...new Set(e.utilities)].map(e=>`"${e}"`).join(`, `)} conflict — both set \`${e.property}\``,startLineNumber:n,startColumn:e.startIndex+1,endLineNumber:n,endColumn:e.endIndex+1,source:`yummacss`})}t.editor.setModelMarkers(r,`yummacss`,i)}r(),n.onDidChangeModelContent(r)}function a(e){return e.languages.registerCodeActionProvider(`html`,{provideCodeActions:(e,t,n)=>{let r=[],i=(n.markers??[]).filter(e=>e.source===`yummacss`);for(let t of i){let n=t.message.match(/^(.*) conflict — both set/);if(!n)continue;let i=n[1].split(`, `).map(e=>e.replace(/"/g,``));for(let n of i){let a=i.filter(e=>e!==n);r.push({title:`Keep "${n}", remove ${a.map(e=>`"${e}"`).join(`, `)}`,kind:`quickfix`,diagnostics:[t],edit:{edits:[{resource:e.uri,textEdit:{range:t,text:(()=>{let n=e.getValueInRange(t);for(let e of a)n=n.replace(RegExp(`\\b${e}\\b\\s*`,`g`),``);return n.replace(/\s+/g,` `).trim()})()}}]}})}}return{actions:r,dispose:()=>{}}}})}function o(t,n){n.addAction({id:`yummacss.sortClasses`,label:`Yumma CSS: Sort Classes`,keybindings:[t.KeyMod.CtrlCmd|t.KeyCode.KeyS],run:t=>{let n=t.getModel();if(!n)return;let r=n.getValue(),i=e.n(r);i!==r&&t.executeEdits(`yummacss.sortClasses`,[{range:n.getFullModelRange(),text:i}])}})}exports.registerCodeActionsProvider=a,exports.registerColorProvider=r,exports.registerCompletionProvider=t,exports.registerConflictMarkers=i,exports.registerHoverProvider=n,exports.registerSortAction=o;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/adapters/monaco.d.ts
|
|
2
|
+
declare function registerCompletionProvider(monaco: any): any;
|
|
3
|
+
declare function registerHoverProvider(monaco: any): any;
|
|
4
|
+
declare function registerColorProvider(monaco: any): any;
|
|
5
|
+
declare function registerConflictMarkers(monaco: any, editor: any): void;
|
|
6
|
+
declare function registerCodeActionsProvider(monaco: any): any;
|
|
7
|
+
declare function registerSortAction(monaco: any, editor: any): void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { registerCodeActionsProvider, registerColorProvider, registerCompletionProvider, registerConflictMarkers, registerHoverProvider, registerSortAction };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/adapters/monaco.d.ts
|
|
2
|
+
declare function registerCompletionProvider(monaco: any): any;
|
|
3
|
+
declare function registerHoverProvider(monaco: any): any;
|
|
4
|
+
declare function registerColorProvider(monaco: any): any;
|
|
5
|
+
declare function registerConflictMarkers(monaco: any, editor: any): void;
|
|
6
|
+
declare function registerCodeActionsProvider(monaco: any): any;
|
|
7
|
+
declare function registerSortAction(monaco: any, editor: any): void;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { registerCodeActionsProvider, registerColorProvider, registerCompletionProvider, registerConflictMarkers, registerHoverProvider, registerSortAction };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,f as t,i as n,n as r,o as i,r as a,s as o,u as s}from"../sort-DLflxnyO.mjs";function c(e){return e.languages.registerCompletionItemProvider(`html`,{provideCompletionItems:(t,n)=>{let r=t.getValueInRange({startLineNumber:1,startColumn:1,endLineNumber:n.lineNumber,endColumn:n.column});if(!/(?:class(?:Name)?)\s*=\s*["'{`][^"'`]*$/.test(r))return{suggestions:[]};let i=t.getWordUntilPosition(n),a={startLineNumber:n.lineNumber,endLineNumber:n.lineNumber,startColumn:i.startColumn,endColumn:i.endColumn};return{suggestions:o().map(t=>({label:t.label,insertText:t.insertText,detail:t.detail,kind:t.isColor?e.languages.CompletionItemKind.Color:e.languages.CompletionItemKind.Constant,range:a}))}}})}function l(e){return e.languages.registerHoverProvider(`html`,{provideHover:(t,r)=>{let i=a(t.getLineContent(r.lineNumber),r.column-1);if(!i)return null;let o=n(i.className);return o?{range:new e.Range(r.lineNumber,i.startIndex+1,r.lineNumber,i.endIndex+1),contents:[{value:o,isTrusted:!0}]}:null}})}function u(n){let r=i();return n.languages.registerColorProvider(`html`,{provideColorPresentations:()=>[],provideDocumentColors:i=>{let a=[];for(let o=1;o<=i.getLineCount();o++){let s=i.getLineContent(o),c=new RegExp(t.source,`g`),l;for(l=c.exec(s);l!==null;){let t=l[2]??l[4]??l[5];if(!t){l=c.exec(s);continue}let i=l.index+l[0].indexOf(t),u=t.split(/\s+/).filter(Boolean),d=0;for(let s of u){let c=s.includes(`:`)?s.slice(s.lastIndexOf(`:`)+1):s,l=r.get(c);if(l){let r=e(l.cssValue);if(r){let e=t.indexOf(s,d);if(e!==-1){let t=i+e;a.push({color:{red:r.r,green:r.g,blue:r.b,alpha:r.a},range:new n.Range(o,t+1,o,t+s.length+1)}),d=e+s.length}}}}l=c.exec(s)}}return a}})}function d(e,t){function n(){let n=t.getModel();if(!n)return;let r=[];for(let t=1;t<=n.getLineCount();t++){let i=s(n.getLineContent(t));for(let n of i)r.push({severity:e.MarkerSeverity.Warning,message:`${[...new Set(n.utilities)].map(e=>`"${e}"`).join(`, `)} conflict — both set \`${n.property}\``,startLineNumber:t,startColumn:n.startIndex+1,endLineNumber:t,endColumn:n.endIndex+1,source:`yummacss`})}e.editor.setModelMarkers(n,`yummacss`,r)}n(),t.onDidChangeModelContent(n)}function f(e){return e.languages.registerCodeActionProvider(`html`,{provideCodeActions:(e,t,n)=>{let r=[],i=(n.markers??[]).filter(e=>e.source===`yummacss`);for(let t of i){let n=t.message.match(/^(.*) conflict — both set/);if(!n)continue;let i=n[1].split(`, `).map(e=>e.replace(/"/g,``));for(let n of i){let a=i.filter(e=>e!==n);r.push({title:`Keep "${n}", remove ${a.map(e=>`"${e}"`).join(`, `)}`,kind:`quickfix`,diagnostics:[t],edit:{edits:[{resource:e.uri,textEdit:{range:t,text:(()=>{let n=e.getValueInRange(t);for(let e of a)n=n.replace(RegExp(`\\b${e}\\b\\s*`,`g`),``);return n.replace(/\s+/g,` `).trim()})()}}]}})}}return{actions:r,dispose:()=>{}}}})}function p(e,t){t.addAction({id:`yummacss.sortClasses`,label:`Yumma CSS: Sort Classes`,keybindings:[e.KeyMod.CtrlCmd|e.KeyCode.KeyS],run:e=>{let t=e.getModel();if(!t)return;let n=t.getValue(),i=r(n);i!==n&&e.executeEdits(`yummacss.sortClasses`,[{range:t.getFullModelRange(),text:i}])}})}export{f as registerCodeActionsProvider,u as registerColorProvider,c as registerCompletionProvider,d as registerConflictMarkers,l as registerHoverProvider,p as registerSortAction};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../sort-z_8wNh4l.cjs`);let t=require(`vscode`);t=e.m(t);function n(e){"@babel/helpers - typeof";return n=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},n(e)}function r(e,t){if(n(e)!=`object`||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var i=r.call(e,t||`default`);if(n(i)!=`object`)return i;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function i(e){var t=r(e,`string`);return n(t)==`symbol`?t:t+``}function a(e,t,n){return(t=i(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const o=e.o();var s=class{provideCompletionItems(n,r){let i=n.lineAt(r).text.substring(0,r.character);if(/(?:class(?:Name)?)\s*=\s*["'{`][^"'`]*$/.test(i))return e.s().map(e=>{let n=new t.CompletionItem({label:e.label,description:e.detail},e.isColor?t.CompletionItemKind.Color:t.CompletionItemKind.Constant);return n.documentation=new t.MarkdownString(`\`\`\`css\n${e.detail}\n\`\`\``),n})}},c=class{provideHover(n,r){let i=n.lineAt(r).text,a=e.r(i,r.character);if(!a)return;let o=e.i(a.className);if(!o)return;let s=new t.Range(r.line,a.startIndex,r.line,a.endIndex),c=new t.MarkdownString(o,!0);return c.isTrusted=!0,new t.Hover(c,s)}},l=class{provideDocumentColors(n){let r=[];for(let i=0;i<n.lineCount;i++){let a=n.lineAt(i).text,s=new RegExp(e.f.source,`g`),c;for(c=s.exec(a);c!==null;){let n=e.p(c);if(!n){c=s.exec(a);continue}let l=c.index+c[0].indexOf(n),u=n.split(/\s+/).filter(Boolean),d=0;for(let a of u){let s=a.includes(`:`)?a.slice(a.lastIndexOf(`:`)+1):a,c=o.get(s);if(c){let o=e.c(c.cssValue);if(o){let e=n.indexOf(a,d);if(e!==-1){let n=l+e,s=new t.Range(i,n,i,n+a.length);r.push(new t.ColorInformation(s,new t.Color(o.r,o.g,o.b,o.a))),d=e+a.length}}}}c=s.exec(a)}}return r}provideColorPresentations(){return[]}},u=class{provideCodeActions(n,r,i){return i.diagnostics.filter(e=>e.source===`yummacss`).flatMap(r=>{let i=r.data;if(!i)return[];let{conflicts:a}=i,o=n.lineAt(r.range.start.line).text,s=new RegExp(e.f.source,`g`),c,l=null,u=-1;for(c=s.exec(o);c!==null;){if(r.range.start.character>=c.index&&r.range.start.character<=c.index+c[0].length){l=e.p(c),l&&(u=o.indexOf(l,c.index));break}c=s.exec(o)}if(!l||u===-1)return[];let d=new t.Range(r.range.start.line,u,r.range.start.line,u+l.length);return a.map((e,i)=>{let o=a.filter(t=>t!==e),s=o.length===1?`Keep "${e}", remove "${o[0]}"`:`Keep "${e}", remove ${o.map(e=>`"${e}"`).join(`, `)}`,c=new t.CodeAction(s,t.CodeActionKind.QuickFix);c.diagnostics=[r],c.isPreferred=i===a.length-1;let u=l;for(let e of o)u=u.replace(RegExp(`\\b${e}\\b`,`g`),``).replace(/\s+/g,` `).trim();let f=new t.WorkspaceEdit;return f.replace(n.uri,d,u),c.edit=f,c})})}};a(u,`providedCodeActionKinds`,[t.CodeActionKind.QuickFix]);function d(n,r){let i=[];for(let r=0;r<n.lineCount;r++){let a=n.lineAt(r).text,o=e.u(a);for(let e of o){let n=new t.Range(r,e.startIndex,r,e.endIndex),a=[...new Set(e.utilities)],o=new t.Diagnostic(n,`${a.map(e=>`"${e}"`).join(`, `)} conflict — both set \`${e.property}\``,t.DiagnosticSeverity.Warning);o.source=`yummacss`,o.code=`conflicting_utilities`,o.data={conflicts:e.utilities,property:e.property},i.push(o)}}r.set(n.uri,i)}function f(e,n,r){t.window.activeTextEditor&&d(t.window.activeTextEditor.document,n),e.subscriptions.push(t.window.onDidChangeActiveTextEditor(e=>{e&&d(e.document,n)}),t.workspace.onDidChangeTextDocument(e=>d(e.document,n)),t.workspace.onDidCloseTextDocument(e=>n.delete(e.uri)))}function p(n,r){let i=t.commands.registerCommand(`yummacss.sortClasses`,async()=>{let n=t.window.activeTextEditor;if(!n)return;let r=n.document.getText(),i=e.n(r);if(i===r){t.window.showInformationMessage(`Yumma CSS: classes are already sorted!`);return}await n.edit(e=>{let a=new t.Range(n.document.positionAt(0),n.document.positionAt(r.length));e.replace(a,i)}),t.window.showInformationMessage(`Yumma CSS: classes sorted!`)}),a=t.workspace.onWillSaveTextDocument(n=>{if(n.reason!==t.TextDocumentSaveReason.Manual||!t.workspace.getConfiguration(`yummacss`).get(`sortOnSave`,!0)||!r.includes(n.document.languageId))return;let i=n.document.getText(),a=e.n(i);if(a===i)return;let o=new t.Range(n.document.positionAt(0),n.document.positionAt(i.length));n.waitUntil(Promise.resolve([new t.TextEdit(o,a)]))});n.subscriptions.push(i,a)}exports.ActionProvider=u,exports.ColorProvider=l,exports.CompletionProvider=s,exports.HoverProvider=c,exports.refreshDiagnostics=d,exports.registerSortCommand=p,exports.subscribeToDocChanges=f;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as vscode from "vscode";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/vscode.d.ts
|
|
4
|
+
declare class CompletionProvider implements vscode.CompletionItemProvider {
|
|
5
|
+
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] | undefined;
|
|
6
|
+
}
|
|
7
|
+
declare class HoverProvider implements vscode.HoverProvider {
|
|
8
|
+
provideHover(document: vscode.TextDocument, position: vscode.Position): vscode.Hover | undefined;
|
|
9
|
+
}
|
|
10
|
+
declare class ColorProvider implements vscode.DocumentColorProvider {
|
|
11
|
+
provideDocumentColors(document: vscode.TextDocument): vscode.ColorInformation[];
|
|
12
|
+
provideColorPresentations(): vscode.ColorPresentation[];
|
|
13
|
+
}
|
|
14
|
+
declare class ActionProvider implements vscode.CodeActionProvider {
|
|
15
|
+
static readonly providedCodeActionKinds: vscode.CodeActionKind[];
|
|
16
|
+
provideCodeActions(document: vscode.TextDocument, _range: vscode.Range, context: vscode.CodeActionContext): vscode.CodeAction[];
|
|
17
|
+
}
|
|
18
|
+
declare function refreshDiagnostics(document: vscode.TextDocument, collection: vscode.DiagnosticCollection): void;
|
|
19
|
+
declare function subscribeToDocChanges(context: vscode.ExtensionContext, collection: vscode.DiagnosticCollection, languages: string[]): void;
|
|
20
|
+
declare function registerSortCommand(context: vscode.ExtensionContext, languages: string[]): void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ActionProvider, ColorProvider, CompletionProvider, HoverProvider, refreshDiagnostics, registerSortCommand, subscribeToDocChanges };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as vscode from "vscode";
|
|
2
|
+
|
|
3
|
+
//#region src/adapters/vscode.d.ts
|
|
4
|
+
declare class CompletionProvider implements vscode.CompletionItemProvider {
|
|
5
|
+
provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] | undefined;
|
|
6
|
+
}
|
|
7
|
+
declare class HoverProvider implements vscode.HoverProvider {
|
|
8
|
+
provideHover(document: vscode.TextDocument, position: vscode.Position): vscode.Hover | undefined;
|
|
9
|
+
}
|
|
10
|
+
declare class ColorProvider implements vscode.DocumentColorProvider {
|
|
11
|
+
provideDocumentColors(document: vscode.TextDocument): vscode.ColorInformation[];
|
|
12
|
+
provideColorPresentations(): vscode.ColorPresentation[];
|
|
13
|
+
}
|
|
14
|
+
declare class ActionProvider implements vscode.CodeActionProvider {
|
|
15
|
+
static readonly providedCodeActionKinds: vscode.CodeActionKind[];
|
|
16
|
+
provideCodeActions(document: vscode.TextDocument, _range: vscode.Range, context: vscode.CodeActionContext): vscode.CodeAction[];
|
|
17
|
+
}
|
|
18
|
+
declare function refreshDiagnostics(document: vscode.TextDocument, collection: vscode.DiagnosticCollection): void;
|
|
19
|
+
declare function subscribeToDocChanges(context: vscode.ExtensionContext, collection: vscode.DiagnosticCollection, languages: string[]): void;
|
|
20
|
+
declare function registerSortCommand(context: vscode.ExtensionContext, languages: string[]): void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ActionProvider, ColorProvider, CompletionProvider, HoverProvider, refreshDiagnostics, registerSortCommand, subscribeToDocChanges };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,f as t,i as n,n as r,o as i,p as a,r as o,s,u as c}from"../sort-DLflxnyO.mjs";import*as l from"vscode";function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const m=i();var h=class{provideCompletionItems(e,t){let n=e.lineAt(t).text.substring(0,t.character);if(/(?:class(?:Name)?)\s*=\s*["'{`][^"'`]*$/.test(n))return s().map(e=>{let t=new l.CompletionItem({label:e.label,description:e.detail},e.isColor?l.CompletionItemKind.Color:l.CompletionItemKind.Constant);return t.documentation=new l.MarkdownString(`\`\`\`css\n${e.detail}\n\`\`\``),t})}},g=class{provideHover(e,t){let r=e.lineAt(t).text,i=o(r,t.character);if(!i)return;let a=n(i.className);if(!a)return;let s=new l.Range(t.line,i.startIndex,t.line,i.endIndex),c=new l.MarkdownString(a,!0);return c.isTrusted=!0,new l.Hover(c,s)}},_=class{provideDocumentColors(n){let r=[];for(let i=0;i<n.lineCount;i++){let o=n.lineAt(i).text,s=new RegExp(t.source,`g`),c;for(c=s.exec(o);c!==null;){let t=a(c);if(!t){c=s.exec(o);continue}let n=c.index+c[0].indexOf(t),u=t.split(/\s+/).filter(Boolean),d=0;for(let a of u){let o=a.includes(`:`)?a.slice(a.lastIndexOf(`:`)+1):a,s=m.get(o);if(s){let o=e(s.cssValue);if(o){let e=t.indexOf(a,d);if(e!==-1){let t=n+e,s=new l.Range(i,t,i,t+a.length);r.push(new l.ColorInformation(s,new l.Color(o.r,o.g,o.b,o.a))),d=e+a.length}}}}c=s.exec(o)}}return r}provideColorPresentations(){return[]}},v=class{provideCodeActions(e,n,r){return r.diagnostics.filter(e=>e.source===`yummacss`).flatMap(n=>{let r=n.data;if(!r)return[];let{conflicts:i}=r,o=e.lineAt(n.range.start.line).text,s=new RegExp(t.source,`g`),c,u=null,d=-1;for(c=s.exec(o);c!==null;){if(n.range.start.character>=c.index&&n.range.start.character<=c.index+c[0].length){u=a(c),u&&(d=o.indexOf(u,c.index));break}c=s.exec(o)}if(!u||d===-1)return[];let f=new l.Range(n.range.start.line,d,n.range.start.line,d+u.length);return i.map((t,r)=>{let a=i.filter(e=>e!==t),o=a.length===1?`Keep "${t}", remove "${a[0]}"`:`Keep "${t}", remove ${a.map(e=>`"${e}"`).join(`, `)}`,s=new l.CodeAction(o,l.CodeActionKind.QuickFix);s.diagnostics=[n],s.isPreferred=r===i.length-1;let c=u;for(let e of a)c=c.replace(RegExp(`\\b${e}\\b`,`g`),``).replace(/\s+/g,` `).trim();let d=new l.WorkspaceEdit;return d.replace(e.uri,f,c),s.edit=d,s})})}};p(v,`providedCodeActionKinds`,[l.CodeActionKind.QuickFix]);function y(e,t){let n=[];for(let t=0;t<e.lineCount;t++){let r=e.lineAt(t).text,i=c(r);for(let e of i){let r=new l.Range(t,e.startIndex,t,e.endIndex),i=[...new Set(e.utilities)],a=new l.Diagnostic(r,`${i.map(e=>`"${e}"`).join(`, `)} conflict — both set \`${e.property}\``,l.DiagnosticSeverity.Warning);a.source=`yummacss`,a.code=`conflicting_utilities`,a.data={conflicts:e.utilities,property:e.property},n.push(a)}}t.set(e.uri,n)}function b(e,t,n){l.window.activeTextEditor&&y(l.window.activeTextEditor.document,t),e.subscriptions.push(l.window.onDidChangeActiveTextEditor(e=>{e&&y(e.document,t)}),l.workspace.onDidChangeTextDocument(e=>y(e.document,t)),l.workspace.onDidCloseTextDocument(e=>t.delete(e.uri)))}function x(e,t){let n=l.commands.registerCommand(`yummacss.sortClasses`,async()=>{let e=l.window.activeTextEditor;if(!e)return;let t=e.document.getText(),n=r(t);if(n===t){l.window.showInformationMessage(`Yumma CSS: classes are already sorted!`);return}await e.edit(r=>{let i=new l.Range(e.document.positionAt(0),e.document.positionAt(t.length));r.replace(i,n)}),l.window.showInformationMessage(`Yumma CSS: classes sorted!`)}),i=l.workspace.onWillSaveTextDocument(e=>{if(e.reason!==l.TextDocumentSaveReason.Manual||!l.workspace.getConfiguration(`yummacss`).get(`sortOnSave`,!0)||!t.includes(e.document.languageId))return;let n=e.document.getText(),i=r(n);if(i===n)return;let a=new l.Range(e.document.positionAt(0),e.document.positionAt(n.length));e.waitUntil(Promise.resolve([new l.TextEdit(a,i)]))});e.subscriptions.push(n,i)}export{v as ActionProvider,_ as ColorProvider,h as CompletionProvider,g as HoverProvider,y as refreshDiagnostics,x as registerSortCommand,b as subscribeToDocChanges};
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`./sort-z_8wNh4l.cjs`);exports.CLASS_ATTR_REGEX=e.f,exports.buildUtilityMap=e.o,exports.extractClassContent=e.p,exports.findConflicts=e.u,exports.findHoverTarget=e.r,exports.getHoverMarkdown=e.i,exports.getSuggestions=e.s,exports.hexToRgba=e.c,exports.isHexColor=e.l,exports.parseUtility=e.a,exports.propertyMap=e.d,exports.sortUtilities=e.t,exports.sortUtilityClasses=e.n;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region src/conflicts.d.ts
|
|
2
|
+
interface Conflict {
|
|
3
|
+
utilities: string[];
|
|
4
|
+
property: string;
|
|
5
|
+
startIndex: number;
|
|
6
|
+
endIndex: number;
|
|
7
|
+
}
|
|
8
|
+
interface ConflictGroup {
|
|
9
|
+
conflicts: string[];
|
|
10
|
+
property: string;
|
|
11
|
+
}
|
|
12
|
+
declare const propertyMap: Map<string, string[]>;
|
|
13
|
+
declare function findConflicts(line: string): Conflict[];
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/constants.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Matches class/className attribute values across all supported syntaxes:
|
|
18
|
+
*
|
|
19
|
+
* class="..." className="..."
|
|
20
|
+
* class='...' className='...'
|
|
21
|
+
* className={'...'} className={"..."}
|
|
22
|
+
* className={`...`} — only when there are no ${} expressions inside
|
|
23
|
+
*
|
|
24
|
+
* Capture groups:
|
|
25
|
+
* [1] quote char for "..." / '...'
|
|
26
|
+
* [2] content for "..." / '...'
|
|
27
|
+
* [3] quote char for {`...`} / {"..."}
|
|
28
|
+
* [4] content for {'...'} / {"..."}
|
|
29
|
+
* [5] content for {`...`}
|
|
30
|
+
*/
|
|
31
|
+
declare const CLASS_ATTR_REGEX: RegExp;
|
|
32
|
+
/**
|
|
33
|
+
* Extracts the class string content from a CLASS_ATTR_REGEX match.
|
|
34
|
+
* Returns null if the match is empty or dynamic (should never happen with the regex).
|
|
35
|
+
*/
|
|
36
|
+
declare function extractClassContent(match: RegExpExecArray): string | null;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/core.d.ts
|
|
39
|
+
interface UtilityInfo {
|
|
40
|
+
cssValue: string;
|
|
41
|
+
slug: string;
|
|
42
|
+
properties: string[];
|
|
43
|
+
}
|
|
44
|
+
interface RgbaColor {
|
|
45
|
+
r: number;
|
|
46
|
+
g: number;
|
|
47
|
+
b: number;
|
|
48
|
+
a: number;
|
|
49
|
+
}
|
|
50
|
+
interface Suggestion {
|
|
51
|
+
label: string;
|
|
52
|
+
insertText: string;
|
|
53
|
+
detail: string;
|
|
54
|
+
isColor: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare function buildUtilityMap(): Map<string, UtilityInfo>;
|
|
57
|
+
declare function isHexColor(cssValue: string): boolean;
|
|
58
|
+
declare function hexToRgba(cssValue: string): RgbaColor | null;
|
|
59
|
+
declare function getSuggestions(): Suggestion[];
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/hover.d.ts
|
|
62
|
+
interface HoverContent {
|
|
63
|
+
markdown: string;
|
|
64
|
+
startIndex: number;
|
|
65
|
+
endIndex: number;
|
|
66
|
+
}
|
|
67
|
+
declare function parseUtility(className: string): {
|
|
68
|
+
variants: string[];
|
|
69
|
+
baseUtility: string;
|
|
70
|
+
};
|
|
71
|
+
declare function getHoverMarkdown(className: string): string | null;
|
|
72
|
+
declare function findHoverTarget(line: string, cursorIndex: number): {
|
|
73
|
+
className: string;
|
|
74
|
+
startIndex: number;
|
|
75
|
+
endIndex: number;
|
|
76
|
+
} | null;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/sort.d.ts
|
|
79
|
+
declare function sortUtilities(classString: string): string;
|
|
80
|
+
declare function sortUtilityClasses(text: string): string;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { CLASS_ATTR_REGEX, Conflict, ConflictGroup, HoverContent, RgbaColor, Suggestion, UtilityInfo, buildUtilityMap, extractClassContent, findConflicts, findHoverTarget, getHoverMarkdown, getSuggestions, hexToRgba, isHexColor, parseUtility, propertyMap, sortUtilities, sortUtilityClasses };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
//#region src/conflicts.d.ts
|
|
2
|
+
interface Conflict {
|
|
3
|
+
utilities: string[];
|
|
4
|
+
property: string;
|
|
5
|
+
startIndex: number;
|
|
6
|
+
endIndex: number;
|
|
7
|
+
}
|
|
8
|
+
interface ConflictGroup {
|
|
9
|
+
conflicts: string[];
|
|
10
|
+
property: string;
|
|
11
|
+
}
|
|
12
|
+
declare const propertyMap: Map<string, string[]>;
|
|
13
|
+
declare function findConflicts(line: string): Conflict[];
|
|
14
|
+
//#endregion
|
|
15
|
+
//#region src/constants.d.ts
|
|
16
|
+
/**
|
|
17
|
+
* Matches class/className attribute values across all supported syntaxes:
|
|
18
|
+
*
|
|
19
|
+
* class="..." className="..."
|
|
20
|
+
* class='...' className='...'
|
|
21
|
+
* className={'...'} className={"..."}
|
|
22
|
+
* className={`...`} — only when there are no ${} expressions inside
|
|
23
|
+
*
|
|
24
|
+
* Capture groups:
|
|
25
|
+
* [1] quote char for "..." / '...'
|
|
26
|
+
* [2] content for "..." / '...'
|
|
27
|
+
* [3] quote char for {`...`} / {"..."}
|
|
28
|
+
* [4] content for {'...'} / {"..."}
|
|
29
|
+
* [5] content for {`...`}
|
|
30
|
+
*/
|
|
31
|
+
declare const CLASS_ATTR_REGEX: RegExp;
|
|
32
|
+
/**
|
|
33
|
+
* Extracts the class string content from a CLASS_ATTR_REGEX match.
|
|
34
|
+
* Returns null if the match is empty or dynamic (should never happen with the regex).
|
|
35
|
+
*/
|
|
36
|
+
declare function extractClassContent(match: RegExpExecArray): string | null;
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/core.d.ts
|
|
39
|
+
interface UtilityInfo {
|
|
40
|
+
cssValue: string;
|
|
41
|
+
slug: string;
|
|
42
|
+
properties: string[];
|
|
43
|
+
}
|
|
44
|
+
interface RgbaColor {
|
|
45
|
+
r: number;
|
|
46
|
+
g: number;
|
|
47
|
+
b: number;
|
|
48
|
+
a: number;
|
|
49
|
+
}
|
|
50
|
+
interface Suggestion {
|
|
51
|
+
label: string;
|
|
52
|
+
insertText: string;
|
|
53
|
+
detail: string;
|
|
54
|
+
isColor: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare function buildUtilityMap(): Map<string, UtilityInfo>;
|
|
57
|
+
declare function isHexColor(cssValue: string): boolean;
|
|
58
|
+
declare function hexToRgba(cssValue: string): RgbaColor | null;
|
|
59
|
+
declare function getSuggestions(): Suggestion[];
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/hover.d.ts
|
|
62
|
+
interface HoverContent {
|
|
63
|
+
markdown: string;
|
|
64
|
+
startIndex: number;
|
|
65
|
+
endIndex: number;
|
|
66
|
+
}
|
|
67
|
+
declare function parseUtility(className: string): {
|
|
68
|
+
variants: string[];
|
|
69
|
+
baseUtility: string;
|
|
70
|
+
};
|
|
71
|
+
declare function getHoverMarkdown(className: string): string | null;
|
|
72
|
+
declare function findHoverTarget(line: string, cursorIndex: number): {
|
|
73
|
+
className: string;
|
|
74
|
+
startIndex: number;
|
|
75
|
+
endIndex: number;
|
|
76
|
+
} | null;
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region src/sort.d.ts
|
|
79
|
+
declare function sortUtilities(classString: string): string;
|
|
80
|
+
declare function sortUtilityClasses(text: string): string;
|
|
81
|
+
//#endregion
|
|
82
|
+
export { CLASS_ATTR_REGEX, Conflict, ConflictGroup, HoverContent, RgbaColor, Suggestion, UtilityInfo, buildUtilityMap, extractClassContent, findConflicts, findHoverTarget, getHoverMarkdown, getSuggestions, hexToRgba, isHexColor, parseUtility, propertyMap, sortUtilities, sortUtilityClasses };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,n as o,o as s,p as c,r as l,s as u,t as d,u as f}from"./sort-DLflxnyO.mjs";export{r as CLASS_ATTR_REGEX,s as buildUtilityMap,c as extractClassContent,f as findConflicts,l as findHoverTarget,i as getHoverMarkdown,u as getSuggestions,t as hexToRgba,a as isHexColor,e as parseUtility,n as propertyMap,d as sortUtilities,o as sortUtilityClasses};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{backgroundUtils as e,borderUtils as t,boxModelUtils as n,colorUtils as r,coreUtils as i,effectUtils as a,flexboxUtils as o,fontUtils as s,gridUtils as c,interactivityUtils as l,layoutUtils as u,mediaQueries as d,opacity as f,outlineUtils as p,positioningUtils as m,pseudoClasses as h,pseudoElements as g,svgUtils as _,tableUtils as v,textUtils as y,transformUtils as b,transitionUtils as x}from"@yummacss/core";import S from"tinycolor2";const C=/(?:class(?:Name)?)\s*=\s*(?:(["'])([^"']+)\1|\{(["'])([^"']+)\3\}|\{`([^`$]*)`\})/g;function w(e){return e[2]??e[4]??e[5]??null}function T(){let e=new Map,t=i();return Object.values(t).forEach(t=>{Object.entries(t.values).forEach(([n])=>{let r=n===``?t.prefix:`${t.prefix}-${n}`;e.set(r,t.properties)})}),e}const E=T();function D(e){let t=[],n=new RegExp(C.source,`g`),r;for(r=n.exec(e);r!==null;){let i=w(r);if(!i)continue;let a=r.index+r[0].indexOf(i),o=i.split(/\s+/).filter(e=>e.trim()!==``),s=new Map;for(let e of o){let t=e.split(`:`),n=t.pop()||e,r=t.join(`:`),i=E.get(n);if(i)for(let t of i){let n=`${t}@${r}`,i=s.get(n)??[];i.push(e),s.set(n,i)}}for(let[e,n]of s){if(n.length<=1)continue;let r=e.split(`@`)[0],o=2**53-1,s=0,c=0;for(let e of n){let t=i.indexOf(e,c);t!==-1&&(o=Math.min(o,a+t),s=Math.max(s,a+t+e.length),c=t+e.length)}t.push({utilities:n,property:r,startIndex:o,endIndex:s})}r=n.exec(e)}return t}function O(){let e=new Map,t=i();return Object.values(t).forEach(t=>{let n=t.slug||``,r=t.properties||[];Object.entries(t.values).forEach(([i,a])=>{let o=i===``?t.prefix:`${t.prefix}-${i}`;e.set(o,{cssValue:String(a),slug:n,properties:r})})}),e}function k(e){return S(e).isValid()&&e.trim().startsWith(`#`)}function A(e){let t=S(e);if(!t.isValid())return null;let{r:n,g:r,b:i,a}=t.toRgb();return{r:n/255,g:r/255,b:i/255,a}}function j(){let e=i(),t=[];return Object.values(e).forEach(e=>{Object.entries(e.values).forEach(([n,r])=>{let i=n===``?e.prefix:`${e.prefix}-${n}`,a=e.properties[0];t.push({label:i,insertText:i,detail:`${a}: ${r};`,isColor:k(String(r))})})}),t}const M=O(),N={};for(let e of d)N[e.prefix]=e.value;const P={};for(let e of h)P[e.prefix]=e.value;const F={};for(let e of g)F[e.prefix]=e.value;const I={};for(let e of f)I[e.prefix]=e.value;function L(){let n=new Map;for(let i of[r(),e(),t(),p()])Object.values(i).forEach(e=>{Object.entries(e.values).forEach(([t,r])=>{let i=t===``?e.prefix:`${e.prefix}-${t}`;n.set(i,r)})});return n}const R=L();function z(e){return`})`}function B(e){let t=e.split(`:`);return{variants:t,baseUtility:t.pop()??e}}function V(e){let{variants:t,baseUtility:n}=B(e),r=M.get(n);if(!r)return null;let i=``;if(t.length>0){let e=[];for(let n of t)N[n]?e.push(`**Media:** \`${N[n]}\``):P[n]?e.push(`**Pseudo:** \`${P[n]}\``):F[n]?e.push(`**Pseudo element:** \`${F[n]}\``):I[n]?e.push(`**Opacity:** \`${I[n]}\``):e.push(`**Variant:** \`${n}\``);i+=`${e.join(`
|
|
2
|
+
|
|
3
|
+
`)}\n\n---\n\n`}let a=R.get(n);a&&(i+=`${z(a)}\n\n`);let o=r.properties.map(e=>`${e}: ${r.cssValue};`).join(`
|
|
4
|
+
`);return i+=`\`\`\`css\n${o}\n\`\`\``,r.slug&&(i+=`\n\n[Yumma CSS Reference](https://yummacss.com/docs/${r.slug})`),i}function H(e,t){let n=/class(?:Name)?\s*=\s*["']([^"']+)["']/g,r;for(r=n.exec(e);r!==null;){let i=r[1];if(!i)continue;let a=r.index+r[0].indexOf(i),o=i.split(/\s+/),s=0;for(let e of o){if(!e)continue;let n=i.indexOf(e,s),r=a+n,o=r+e.length;if(t>=r&&t<=o){let{baseUtility:t}=B(e);if(M.has(t))return{className:e,startIndex:r,endIndex:o}}s=n+e.length}r=n.exec(e)}return null}var U=function(e){return e[e.Layout=0]=`Layout`,e[e.Positioning=1]=`Positioning`,e[e.FlexboxGrid=2]=`FlexboxGrid`,e[e.BoxModel=3]=`BoxModel`,e[e.Background=4]=`Background`,e[e.Colors=5]=`Colors`,e[e.BorderOutline=6]=`BorderOutline`,e[e.Typography=7]=`Typography`,e[e.Effects=8]=`Effects`,e[e.Transition=9]=`Transition`,e[e.Interactivity=10]=`Interactivity`,e[e.Table=11]=`Table`,e[e.SVG=12]=`SVG`,e[e.Unknown=13]=`Unknown`,e[e.OrphanVariant=14]=`OrphanVariant`,e}(U||{});function W(){let i=new Map,d=new Map,f=[[u(),U.Layout],[m(),U.Positioning],[o(),U.FlexboxGrid],[c(),U.FlexboxGrid],[n(),U.BoxModel],[e(),U.Background],[r(),U.Colors],[t(),U.BorderOutline],[p(),U.BorderOutline],[s(),U.Typography],[y(),U.Typography],[b(),U.Typography],[a(),U.Effects],[x(),U.Transition],[l(),U.Interactivity],[v(),U.Table],[_(),U.SVG]];Object.values(r()).forEach((e,t)=>{d.set(e.prefix,t)});for(let[e,t]of f)Object.values(e).forEach(e=>{for(let n of Object.keys(e.values)){let r=n===``?e.prefix:`${e.prefix}-${n}`;i.has(r)||i.set(r,t)}i.has(e.prefix)||i.set(e.prefix,t)});return{prefixCategoryMap:i,colorIndexMap:d}}const{prefixCategoryMap:G,colorIndexMap:K}=W();function q(e){if(G.has(e))return G.get(e);let t=e.split(`-`);for(let e=t.length-1;e>=1;e--){let n=t.slice(0,e).join(`-`);if(G.has(n))return G.get(n)}return G.has(t[0])?G.get(t[0]):U.Unknown}function J(e){let t=e.split(`-`);for(let e=t.length;e>=1;e--){let n=t.slice(0,e).join(`-`);if(K.has(n))return K.get(n)}return 99}function Y(e){let t=e.lastIndexOf(`:`);return t===-1?{base:e,variant:null}:{base:e.slice(t+1),variant:e.slice(0,t)}}function X(e,t){if(t.has(e))return e;let n=e.split(`-`);for(let e=n.length-1;e>=1;e--){let r=n.slice(0,e).join(`-`);if(t.has(r))return r}return null}function Z(e){let t=e.split(/\s+/).filter(e=>e.trim()!==``);if(t.length===0)return e;let n=[],r=[];for(let e of t){let{variant:t}=Y(e);t===null?n.push(e):r.push(e)}let i=new Set(n),a=new Map,o=[];for(let e of r){let{base:t}=Y(e),n=X(t,i);if(n){let t=a.get(n)??[];t.push(e),a.set(n,t)}else o.push(e)}let s=[...n].sort((e,t)=>{let n=q(e),r=q(t);return n===r?n===U.Colors?J(e)-J(t):0:n-r}),c=[];for(let e of s){c.push(e);let t=a.get(e);t&&c.push(...t)}return c.push(...o),c.join(` `)}function Q(e){let t=new RegExp(C.source,`g`);return e.replace(t,(...e)=>{let t=e[0],n=w([t,e[1],e[2],e[3],e[4],e[5]]);if(!n)return t;let r=Z(n);return t.replace(n,r)})}export{B as a,A as c,E as d,C as f,V as i,k as l,Q as n,O as o,w as p,H as r,j as s,Z as t,D as u};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@yummacss/core`),l=require(`tinycolor2`);l=s(l);const u=/(?:class(?:Name)?)\s*=\s*(?:(["'])([^"']+)\1|\{(["'])([^"']+)\3\}|\{`([^`$]*)`\})/g;function d(e){return e[2]??e[4]??e[5]??null}function f(){let e=new Map,t=(0,c.coreUtils)();return Object.values(t).forEach(t=>{Object.entries(t.values).forEach(([n])=>{let r=n===``?t.prefix:`${t.prefix}-${n}`;e.set(r,t.properties)})}),e}const p=f();function m(e){let t=[],n=new RegExp(u.source,`g`),r;for(r=n.exec(e);r!==null;){let i=d(r);if(!i)continue;let a=r.index+r[0].indexOf(i),o=i.split(/\s+/).filter(e=>e.trim()!==``),s=new Map;for(let e of o){let t=e.split(`:`),n=t.pop()||e,r=t.join(`:`),i=p.get(n);if(i)for(let t of i){let n=`${t}@${r}`,i=s.get(n)??[];i.push(e),s.set(n,i)}}for(let[e,n]of s){if(n.length<=1)continue;let r=e.split(`@`)[0],o=2**53-1,s=0,c=0;for(let e of n){let t=i.indexOf(e,c);t!==-1&&(o=Math.min(o,a+t),s=Math.max(s,a+t+e.length),c=t+e.length)}t.push({utilities:n,property:r,startIndex:o,endIndex:s})}r=n.exec(e)}return t}function h(){let e=new Map,t=(0,c.coreUtils)();return Object.values(t).forEach(t=>{let n=t.slug||``,r=t.properties||[];Object.entries(t.values).forEach(([i,a])=>{let o=i===``?t.prefix:`${t.prefix}-${i}`;e.set(o,{cssValue:String(a),slug:n,properties:r})})}),e}function g(e){return(0,l.default)(e).isValid()&&e.trim().startsWith(`#`)}function _(e){let t=(0,l.default)(e);if(!t.isValid())return null;let{r:n,g:r,b:i,a}=t.toRgb();return{r:n/255,g:r/255,b:i/255,a}}function v(){let e=(0,c.coreUtils)(),t=[];return Object.values(e).forEach(e=>{Object.entries(e.values).forEach(([n,r])=>{let i=n===``?e.prefix:`${e.prefix}-${n}`,a=e.properties[0];t.push({label:i,insertText:i,detail:`${a}: ${r};`,isColor:g(String(r))})})}),t}const y=h(),b={};for(let e of c.mediaQueries)b[e.prefix]=e.value;const x={};for(let e of c.pseudoClasses)x[e.prefix]=e.value;const S={};for(let e of c.pseudoElements)S[e.prefix]=e.value;const C={};for(let e of c.opacity)C[e.prefix]=e.value;function w(){let e=new Map;for(let t of[(0,c.colorUtils)(),(0,c.backgroundUtils)(),(0,c.borderUtils)(),(0,c.outlineUtils)()])Object.values(t).forEach(t=>{Object.entries(t.values).forEach(([n,r])=>{let i=n===``?t.prefix:`${t.prefix}-${n}`;e.set(i,r)})});return e}const T=w();function E(e){return`})`}function D(e){let t=e.split(`:`);return{variants:t,baseUtility:t.pop()??e}}function O(e){let{variants:t,baseUtility:n}=D(e),r=y.get(n);if(!r)return null;let i=``;if(t.length>0){let e=[];for(let n of t)b[n]?e.push(`**Media:** \`${b[n]}\``):x[n]?e.push(`**Pseudo:** \`${x[n]}\``):S[n]?e.push(`**Pseudo element:** \`${S[n]}\``):C[n]?e.push(`**Opacity:** \`${C[n]}\``):e.push(`**Variant:** \`${n}\``);i+=`${e.join(`
|
|
2
|
+
|
|
3
|
+
`)}\n\n---\n\n`}let a=T.get(n);a&&(i+=`${E(a)}\n\n`);let o=r.properties.map(e=>`${e}: ${r.cssValue};`).join(`
|
|
4
|
+
`);return i+=`\`\`\`css\n${o}\n\`\`\``,r.slug&&(i+=`\n\n[Yumma CSS Reference](https://yummacss.com/docs/${r.slug})`),i}function k(e,t){let n=/class(?:Name)?\s*=\s*["']([^"']+)["']/g,r;for(r=n.exec(e);r!==null;){let i=r[1];if(!i)continue;let a=r.index+r[0].indexOf(i),o=i.split(/\s+/),s=0;for(let e of o){if(!e)continue;let n=i.indexOf(e,s),r=a+n,o=r+e.length;if(t>=r&&t<=o){let{baseUtility:t}=D(e);if(y.has(t))return{className:e,startIndex:r,endIndex:o}}s=n+e.length}r=n.exec(e)}return null}var A=function(e){return e[e.Layout=0]=`Layout`,e[e.Positioning=1]=`Positioning`,e[e.FlexboxGrid=2]=`FlexboxGrid`,e[e.BoxModel=3]=`BoxModel`,e[e.Background=4]=`Background`,e[e.Colors=5]=`Colors`,e[e.BorderOutline=6]=`BorderOutline`,e[e.Typography=7]=`Typography`,e[e.Effects=8]=`Effects`,e[e.Transition=9]=`Transition`,e[e.Interactivity=10]=`Interactivity`,e[e.Table=11]=`Table`,e[e.SVG=12]=`SVG`,e[e.Unknown=13]=`Unknown`,e[e.OrphanVariant=14]=`OrphanVariant`,e}(A||{});function j(){let e=new Map,t=new Map,n=[[(0,c.layoutUtils)(),A.Layout],[(0,c.positioningUtils)(),A.Positioning],[(0,c.flexboxUtils)(),A.FlexboxGrid],[(0,c.gridUtils)(),A.FlexboxGrid],[(0,c.boxModelUtils)(),A.BoxModel],[(0,c.backgroundUtils)(),A.Background],[(0,c.colorUtils)(),A.Colors],[(0,c.borderUtils)(),A.BorderOutline],[(0,c.outlineUtils)(),A.BorderOutline],[(0,c.fontUtils)(),A.Typography],[(0,c.textUtils)(),A.Typography],[(0,c.transformUtils)(),A.Typography],[(0,c.effectUtils)(),A.Effects],[(0,c.transitionUtils)(),A.Transition],[(0,c.interactivityUtils)(),A.Interactivity],[(0,c.tableUtils)(),A.Table],[(0,c.svgUtils)(),A.SVG]];Object.values((0,c.colorUtils)()).forEach((e,n)=>{t.set(e.prefix,n)});for(let[t,r]of n)Object.values(t).forEach(t=>{for(let n of Object.keys(t.values)){let i=n===``?t.prefix:`${t.prefix}-${n}`;e.has(i)||e.set(i,r)}e.has(t.prefix)||e.set(t.prefix,r)});return{prefixCategoryMap:e,colorIndexMap:t}}const{prefixCategoryMap:M,colorIndexMap:N}=j();function P(e){if(M.has(e))return M.get(e);let t=e.split(`-`);for(let e=t.length-1;e>=1;e--){let n=t.slice(0,e).join(`-`);if(M.has(n))return M.get(n)}return M.has(t[0])?M.get(t[0]):A.Unknown}function F(e){let t=e.split(`-`);for(let e=t.length;e>=1;e--){let n=t.slice(0,e).join(`-`);if(N.has(n))return N.get(n)}return 99}function I(e){let t=e.lastIndexOf(`:`);return t===-1?{base:e,variant:null}:{base:e.slice(t+1),variant:e.slice(0,t)}}function L(e,t){if(t.has(e))return e;let n=e.split(`-`);for(let e=n.length-1;e>=1;e--){let r=n.slice(0,e).join(`-`);if(t.has(r))return r}return null}function R(e){let t=e.split(/\s+/).filter(e=>e.trim()!==``);if(t.length===0)return e;let n=[],r=[];for(let e of t){let{variant:t}=I(e);t===null?n.push(e):r.push(e)}let i=new Set(n),a=new Map,o=[];for(let e of r){let{base:t}=I(e),n=L(t,i);if(n){let t=a.get(n)??[];t.push(e),a.set(n,t)}else o.push(e)}let s=[...n].sort((e,t)=>{let n=P(e),r=P(t);return n===r?n===A.Colors?F(e)-F(t):0:n-r}),c=[];for(let e of s){c.push(e);let t=a.get(e);t&&c.push(...t)}return c.push(...o),c.join(` `)}function z(e){let t=new RegExp(u.source,`g`);return e.replace(t,(...e)=>{let t=e[0],n=d([t,e[1],e[2],e[3],e[4],e[5]]);if(!n)return t;let r=R(n);return t.replace(n,r)})}Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return D}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return z}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return R}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return m}});
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@yummacss/intellisense",
|
|
3
|
+
"version": "3.18.0",
|
|
4
|
+
"description": "Shared editor intellisense for Yumma CSS.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"css-framework",
|
|
7
|
+
"typescript",
|
|
8
|
+
"yummacss"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://yummacss.com",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/yummacss/yummacss.git",
|
|
14
|
+
"directory": "packages/intellisense"
|
|
15
|
+
},
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Renildo Pereira",
|
|
18
|
+
"type": "module",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.mts",
|
|
22
|
+
"import": "./dist/index.mjs",
|
|
23
|
+
"require": "./dist/index.cjs",
|
|
24
|
+
"default": "./dist/index.mjs"
|
|
25
|
+
},
|
|
26
|
+
"./monaco": {
|
|
27
|
+
"types": "./dist/adapters/monaco.d.mts",
|
|
28
|
+
"import": "./dist/adapters/monaco.mjs",
|
|
29
|
+
"require": "./dist/adapters/monaco.cjs",
|
|
30
|
+
"default": "./dist/adapters/monaco.mjs"
|
|
31
|
+
},
|
|
32
|
+
"./vscode": {
|
|
33
|
+
"types": "./dist/adapters/vscode.d.mts",
|
|
34
|
+
"import": "./dist/adapters/vscode.mjs",
|
|
35
|
+
"require": "./dist/adapters/vscode.cjs",
|
|
36
|
+
"default": "./dist/adapters/vscode.mjs"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"main": "dist/index.cjs",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.mts",
|
|
42
|
+
"files": [
|
|
43
|
+
"dist"
|
|
44
|
+
],
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"tinycolor2": "^1.6.0",
|
|
47
|
+
"@yummacss/core": "3.18.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@types/tinycolor2": "^1.4.6",
|
|
51
|
+
"@types/vscode": "^1.100.0"
|
|
52
|
+
},
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public",
|
|
55
|
+
"provenance": true
|
|
56
|
+
},
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "tsdown",
|
|
59
|
+
"check": "tsc --noEmit",
|
|
60
|
+
"dev": "tsdown --watch",
|
|
61
|
+
"lint": "biome check --write"
|
|
62
|
+
}
|
|
63
|
+
}
|