Commit graph

4 commits

Author SHA1 Message Date
Claude
8ca12ee61a
Simplify JS worker integration using tokenization detection
Remove virtual model approach and use Monaco's built-in tokenization
to detect when cursor is in embedded JavaScript region. With
nextEmbedded, Monaco automatically syncs model content to the JS
worker, so we can call the worker directly on the model's URI
instead of creating a separate virtual model.
2025-12-09 20:48:51 +00:00
Claude
a96c488593
Use JavaScript worker for interpolation IntelliSense
Inside ${...} interpolations, the package now uses Monaco's JavaScript
language service worker for full IntelliSense:

- getCompletionsAtPosition: Property access, method completions
- getQuickInfoAtPosition: Type info and documentation on hover
- getSignatureHelpItems: Function parameter hints

This allows users to configure the context using setExtraLibs:

```typescript
monaco.languages.typescript.javascriptDefaults.setExtraLibs([{
  content: `
    declare const config: { debug: boolean; port: number };
    declare const env: string;
  `,
  filePath: 'context.d.ts'
}]);
```

Then typing `config.` inside ${...} will show `debug` and `port` completions
with proper types.
2025-12-09 20:29:58 +00:00
Claude
59eafca1f2
Integrate JSON language service worker for full functionality
The standalone package now taps into Monaco's built-in JSON language
service via monaco.languages.json.getWorker() to provide:

- Schema-aware completions (doComplete)
- JSON hover information (doHover)
- Full validation with interpolation filtering (doValidation)
- Document formatting (format)
- Document symbols/outline (findDocumentSymbols)
- Folding ranges (getFoldingRanges)
- Selection ranges (getSelectionRanges)
- Color provider (findDocumentColors, getColorPresentations)

Inside ${...} interpolations, the custom variable provider takes over
for completions and hover. All JSON diagnostics that overlap with
interpolations are automatically filtered out.
2025-12-09 20:11:36 +00:00
Claude
6039262df7
Add standalone monaco-json-interpolation package
Extract the JSON interpolation language as a standalone npm package that
works with the official Monaco Editor as a peer dependency.

Features:
- Zero dependencies on monaco-editor internals
- Simple registration API: register() and getDefaults()
- Variable context for custom completions and hover
- Monarch tokenizer with nextEmbedded for JavaScript
- TypeScript types included
- ESM and CommonJS builds via tsup

Usage:
```typescript
import { register, getDefaults } from 'monaco-json-interpolation';

register();
getDefaults().setVariableContext({
  getVariables: () => [{ name: 'env', value: 'prod' }]
});
```
2025-12-09 19:58:21 +00:00