pax_global_header00006660000000000000000000000064150247752070014523gustar00rootroot0000000000000052 comment=ef0c630e5f3735f3c8c1c3d39ea10cde0046cc85 lang-json-6.0.2/000077500000000000000000000000001502477520700134205ustar00rootroot00000000000000lang-json-6.0.2/.github/000077500000000000000000000000001502477520700147605ustar00rootroot00000000000000lang-json-6.0.2/.github/workflows/000077500000000000000000000000001502477520700170155ustar00rootroot00000000000000lang-json-6.0.2/.github/workflows/dispatch.yml000066400000000000000000000006371502477520700213450ustar00rootroot00000000000000name: Trigger CI on: push jobs: build: name: Dispatch to main repo runs-on: ubuntu-latest steps: - name: Emit repository_dispatch uses: mvasigh/dispatch-action@main with: # You should create a personal access token and store it in your repository token: ${{ secrets.DISPATCH_AUTH }} repo: dev owner: codemirror event_type: push lang-json-6.0.2/.gitignore000066400000000000000000000001271502477520700154100ustar00rootroot00000000000000/node_modules package-lock.json /dist /test/*.js /test/*.d.ts /test/*.d.ts.map .tern-* lang-json-6.0.2/.npmignore000066400000000000000000000001001502477520700154060ustar00rootroot00000000000000/src /test /node_modules .tern-* rollup.config.js tsconfig.json lang-json-6.0.2/CHANGELOG.md000066400000000000000000000014311502477520700152300ustar00rootroot00000000000000## 6.0.2 (2025-06-19) ### Bug fixes Add a .d.cts file to make TypeScript happy. ## 6.0.1 (2022-10-24) ### Bug fixes Make sure the language object has a name. ## 6.0.0 (2022-06-08) ### Breaking changes Update dependencies to 6.0.0 ## 0.20.0 (2022-04-20) ### Breaking changes Update dependencies to 0.20.0 ## 0.19.2 (2022-02-15) ### Bug fixes Fix highlighting of `null` tokens. ## 0.19.1 (2021-08-11) ### Bug fixes Fix incorrect versions for @lezer dependencies. ## 0.19.0 (2021-08-11) ### Breaking changes Update dependencies to 0.19.0 ## 0.18.0 (2021-03-03) ### Breaking changes Update dependencies to 0.18. ## 0.17.1 (2021-01-06) ### New features The package now also exports a CommonJS module. ## 0.17.0 (2020-12-29) ### Breaking changes First numbered release. lang-json-6.0.2/LICENSE000066400000000000000000000021361502477520700144270ustar00rootroot00000000000000MIT License Copyright (C) 2018-2021 by Marijn Haverbeke and others Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. lang-json-6.0.2/README.md000066400000000000000000000046671502477520700147140ustar00rootroot00000000000000 # @codemirror/lang-json [![NPM version](https://img.shields.io/npm/v/@codemirror/lang-json.svg)](https://www.npmjs.org/package/@codemirror/lang-json) [ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-json/blob/main/CHANGELOG.md) ] This package implements JSON language support for the [CodeMirror](https://codemirror.net/) code editor. The [project page](https://codemirror.net/) has more information, a number of [examples](https://codemirror.net/examples/) and the [documentation](https://codemirror.net/docs/). This code is released under an [MIT license](https://github.com/codemirror/lang-json/tree/main/LICENSE). We aim to be an inclusive, welcoming community. To make that explicit, we have a [code of conduct](http://contributor-covenant.org/version/1/1/0/) that applies to communication around the project. ## Usage ```javascript import {EditorView, basicSetup} from "codemirror" import {json} from "@codemirror/lang-json" const view = new EditorView({ parent: document.body, doc: `{"version": "9.99.99", "data": [1, 2, 3]}`, extensions: [basicSetup, json()] }) ``` ## API Reference
json() → LanguageSupport

JSON language support.

jsonLanguage: LRLanguage

A language provider that provides JSON parsing.

jsonParseLinter() → fn(viewEditorView) → Diagnostic[]

Calls JSON.parse on the document and, if that throws an error, reports it as a single diagnostic.

lang-json-6.0.2/package.json000066400000000000000000000016001502477520700157030ustar00rootroot00000000000000{ "name": "@codemirror/lang-json", "version": "6.0.2", "description": "JSON language support for the CodeMirror code editor", "scripts": { "test": "cm-runtests", "prepare": "cm-buildhelper src/json.ts" }, "keywords": [ "editor", "code" ], "author": { "name": "Marijn Haverbeke", "email": "marijn@haverbeke.berlin", "url": "http://marijnhaverbeke.nl" }, "type": "module", "main": "dist/index.cjs", "exports": { "import": "./dist/index.js", "require": "./dist/index.cjs" }, "types": "dist/index.d.ts", "module": "dist/index.js", "sideEffects": false, "license": "MIT", "dependencies": { "@codemirror/language": "^6.0.0", "@lezer/json": "^1.0.0" }, "devDependencies": { "@codemirror/buildhelper": "^1.0.0" }, "repository": { "type": "git", "url": "https://github.com/codemirror/lang-json.git" } } lang-json-6.0.2/src/000077500000000000000000000000001502477520700142075ustar00rootroot00000000000000lang-json-6.0.2/src/README.md000066400000000000000000000025201502477520700154650ustar00rootroot00000000000000 # @codemirror/lang-json [![NPM version](https://img.shields.io/npm/v/@codemirror/lang-json.svg)](https://www.npmjs.org/package/@codemirror/lang-json) [ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://github.com/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://github.com/codemirror/lang-json/blob/main/CHANGELOG.md) ] This package implements JSON language support for the [CodeMirror](https://codemirror.net/) code editor. The [project page](https://codemirror.net/) has more information, a number of [examples](https://codemirror.net/examples/) and the [documentation](https://codemirror.net/docs/). This code is released under an [MIT license](https://github.com/codemirror/lang-json/tree/main/LICENSE). We aim to be an inclusive, welcoming community. To make that explicit, we have a [code of conduct](http://contributor-covenant.org/version/1/1/0/) that applies to communication around the project. ## Usage ```javascript import {EditorView, basicSetup} from "codemirror" import {json} from "@codemirror/lang-json" const view = new EditorView({ parent: document.body, doc: `{"version": "9.99.99", "data": [1, 2, 3]}`, extensions: [basicSetup, json()] }) ``` ## API Reference @json @jsonLanguage @jsonParseLinter lang-json-6.0.2/src/json.ts000066400000000000000000000014201502477520700155250ustar00rootroot00000000000000import {parser} from "@lezer/json" import {continuedIndent, indentNodeProp, foldNodeProp, foldInside, LRLanguage, LanguageSupport} from "@codemirror/language" /// A language provider that provides JSON parsing. export const jsonLanguage = LRLanguage.define({ name: "json", parser: parser.configure({ props: [ indentNodeProp.add({ Object: continuedIndent({except: /^\s*\}/}), Array: continuedIndent({except: /^\s*\]/}) }), foldNodeProp.add({ "Object Array": foldInside }) ] }), languageData: { closeBrackets: {brackets: ["[", "{", '"']}, indentOnInput: /^\s*[\}\]]$/ } }) /// JSON language support. export function json() { return new LanguageSupport(jsonLanguage) } export {jsonParseLinter} from "./lint" lang-json-6.0.2/src/lint.ts000066400000000000000000000017571502477520700155370ustar00rootroot00000000000000import {Diagnostic} from "@codemirror/lint" import {EditorView} from "@codemirror/view" import {Text} from "@codemirror/state" /// Calls /// [`JSON.parse`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) /// on the document and, if that throws an error, reports it as a /// single diagnostic. export const jsonParseLinter = () => (view: EditorView): Diagnostic[] => { try { JSON.parse(view.state.doc.toString()) } catch (e) { if (!(e instanceof SyntaxError)) throw e const pos = getErrorPosition(e, view.state.doc) return [{ from: pos, message: e.message, severity: 'error', to: pos }] } return [] } function getErrorPosition(error: SyntaxError, doc: Text): number { let m if (m = error.message.match(/at position (\d+)/)) return Math.min(+m[1], doc.length) if (m = error.message.match(/at line (\d+) column (\d+)/)) return Math.min(doc.line(+m[1]).from + (+m[2]) - 1, doc.length) return 0 }