codemirror-graphql
Advanced tools
Comparing version 2.0.3 to 2.0.4
@@ -5,3 +5,3 @@ import CodeMirror from 'codemirror'; | ||
CodeMirror.registerHelper('hint', 'graphql', (editor, options) => { | ||
const { schema } = options; | ||
const { schema, externalFragments } = options; | ||
if (!schema) { | ||
@@ -16,3 +16,3 @@ return; | ||
const position = new Position(cur.line, tokenStart); | ||
const rawResults = getAutocompleteSuggestions(schema, editor.getValue(), position, token, options.externalFragments); | ||
const rawResults = getAutocompleteSuggestions(schema, editor.getValue(), position, token, externalFragments); | ||
const results = { | ||
@@ -19,0 +19,0 @@ list: rawResults.map(item => ({ |
@@ -10,4 +10,4 @@ import CodeMirror from 'codemirror'; | ||
CodeMirror.registerHelper('lint', 'graphql', (text, options) => { | ||
const { schema } = options; | ||
const rawResults = getDiagnostics(text, schema, options.validationRules, undefined, options.externalFragments); | ||
const { schema, validationRules, externalFragments } = options; | ||
const rawResults = getDiagnostics(text, schema, validationRules, undefined, externalFragments); | ||
const results = rawResults.map(error => ({ | ||
@@ -14,0 +14,0 @@ message: error.message, |
@@ -25,5 +25,5 @@ import CodeMirror from 'codemirror'; | ||
var _a, _b; | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
const level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -30,0 +30,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -71,5 +71,5 @@ import CodeMirror from 'codemirror'; | ||
const onClick = (clickEvent) => { | ||
const { destination } = cm.state.jump; | ||
const { destination, options } = cm.state.jump; | ||
if (destination) { | ||
cm.state.jump.options.onClick(destination, clickEvent); | ||
options.onClick(destination, clickEvent); | ||
} | ||
@@ -76,0 +76,0 @@ }; |
export default function indent(state, textAfter) { | ||
var _a, _b; | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
const level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -7,0 +7,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -25,5 +25,5 @@ import CodeMirror from 'codemirror'; | ||
var _a, _b; | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
const level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -30,0 +30,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -5,3 +5,3 @@ import CodeMirror from 'codemirror'; | ||
CodeMirror.registerHelper('hint', 'graphql', (editor, options) => { | ||
const { schema } = options; | ||
const { schema, externalFragments } = options; | ||
if (!schema) { | ||
@@ -16,3 +16,3 @@ return; | ||
const position = new Position(cur.line, tokenStart); | ||
const rawResults = getAutocompleteSuggestions(schema, editor.getValue(), position, token, options.externalFragments); | ||
const rawResults = getAutocompleteSuggestions(schema, editor.getValue(), position, token, externalFragments); | ||
const results = { | ||
@@ -19,0 +19,0 @@ list: rawResults.map(item => ({ |
@@ -10,3 +10,3 @@ "use strict"; | ||
codemirror_1.default.registerHelper('hint', 'graphql', function (editor, options) { | ||
var schema = options.schema; | ||
var schema = options.schema, externalFragments = options.externalFragments; | ||
if (!schema) { | ||
@@ -21,3 +21,3 @@ return; | ||
var position = new graphql_language_service_1.Position(cur.line, tokenStart); | ||
var rawResults = (0, graphql_language_service_1.getAutocompleteSuggestions)(schema, editor.getValue(), position, token, options.externalFragments); | ||
var rawResults = (0, graphql_language_service_1.getAutocompleteSuggestions)(schema, editor.getValue(), position, token, externalFragments); | ||
var results = { | ||
@@ -24,0 +24,0 @@ list: rawResults.map(function (item) { return ({ |
@@ -10,4 +10,4 @@ import CodeMirror from 'codemirror'; | ||
CodeMirror.registerHelper('lint', 'graphql', (text, options) => { | ||
const { schema } = options; | ||
const rawResults = getDiagnostics(text, schema, options.validationRules, undefined, options.externalFragments); | ||
const { schema, validationRules, externalFragments } = options; | ||
const rawResults = getDiagnostics(text, schema, validationRules, undefined, externalFragments); | ||
const results = rawResults.map(error => ({ | ||
@@ -14,0 +14,0 @@ message: error.message, |
@@ -15,4 +15,4 @@ "use strict"; | ||
codemirror_1.default.registerHelper('lint', 'graphql', function (text, options) { | ||
var schema = options.schema; | ||
var rawResults = (0, graphql_language_service_1.getDiagnostics)(text, schema, options.validationRules, undefined, options.externalFragments); | ||
var schema = options.schema, validationRules = options.validationRules, externalFragments = options.externalFragments; | ||
var rawResults = (0, graphql_language_service_1.getDiagnostics)(text, schema, validationRules, undefined, externalFragments); | ||
var results = rawResults.map(function (error) { return ({ | ||
@@ -19,0 +19,0 @@ message: error.message, |
{ | ||
"name": "codemirror-graphql", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "GraphQL mode and helpers for CodeMirror.", | ||
@@ -54,3 +54,3 @@ "contributors": [ | ||
"dependencies": { | ||
"graphql-language-service": "5.1.1" | ||
"graphql-language-service": "5.1.2" | ||
}, | ||
@@ -57,0 +57,0 @@ "devDependencies": { |
@@ -25,5 +25,5 @@ import CodeMirror from 'codemirror'; | ||
var _a, _b; | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
const level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -30,0 +30,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -30,5 +30,5 @@ "use strict"; | ||
var _a, _b; | ||
var levels = state.levels; | ||
var levels = state.levels, indentLevel = state.indentLevel; | ||
var level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -35,0 +35,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -12,4 +12,4 @@ /** | ||
import 'codemirror/addon/lint/lint'; | ||
import { readFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
import { readFileSync } from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import { GraphQLError, OperationDefinitionNode } from 'graphql'; | ||
@@ -16,0 +16,0 @@ import '../lint'; |
@@ -12,4 +12,4 @@ /** | ||
import 'codemirror/addon/runmode/runmode'; | ||
import { readFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
import { readFileSync } from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import '../mode'; | ||
@@ -16,0 +16,0 @@ |
@@ -73,3 +73,3 @@ /** | ||
): IHints | undefined => { | ||
const { schema } = options; | ||
const { schema, externalFragments } = options; | ||
if (!schema) { | ||
@@ -94,3 +94,3 @@ return; | ||
token, | ||
options.externalFragments, | ||
externalFragments, | ||
); | ||
@@ -97,0 +97,0 @@ |
import 'codemirror/addon/hint/show-hint'; | ||
declare module 'codemirror' { | ||
var Init: any; | ||
let Init: any; | ||
@@ -16,2 +16,3 @@ interface Editor { | ||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
interface CodeMirrorHintMap {} | ||
@@ -18,0 +19,0 @@ |
@@ -45,9 +45,9 @@ /** | ||
(text: string, options: GraphQLLintOptions): CodeMirror.Annotation[] => { | ||
const { schema } = options; | ||
const { schema, validationRules, externalFragments } = options; | ||
const rawResults = getDiagnostics( | ||
text, | ||
schema, | ||
options.validationRules, | ||
validationRules, | ||
undefined, | ||
options.externalFragments, | ||
externalFragments, | ||
); | ||
@@ -54,0 +54,0 @@ |
@@ -55,3 +55,3 @@ /** | ||
) { | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
// If there is no stack of levels, use the current level. | ||
@@ -61,3 +61,3 @@ // Otherwise, use the top level, preemptively dedenting for close braces. | ||
!levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -64,0 +64,0 @@ (this.electricInput?.test(textAfter) ? 1 : 0); |
@@ -12,3 +12,3 @@ /** | ||
describe('jsonParse', () => { | ||
function checkEscapedString( | ||
function expectEscapedString( | ||
str: string, | ||
@@ -25,3 +25,3 @@ key: ParseTokenOutput, | ||
it('correctly parses escaped strings', () => { | ||
checkEscapedString( | ||
expectEscapedString( | ||
'{ "test": "\\"" }', | ||
@@ -31,3 +31,3 @@ { kind: 'String', start: 2, end: 8, value: 'test' }, | ||
); | ||
checkEscapedString( | ||
expectEscapedString( | ||
'{ "test": "\\\\" }', | ||
@@ -37,3 +37,3 @@ { kind: 'String', start: 2, end: 8, value: 'test' }, | ||
); | ||
checkEscapedString( | ||
expectEscapedString( | ||
'{ "slash": "\\/" }', | ||
@@ -40,0 +40,0 @@ { kind: 'String', start: 2, end: 9, value: 'slash' }, |
@@ -106,5 +106,5 @@ /** | ||
const onClick = (clickEvent: MouseEvent) => { | ||
const { destination } = cm.state.jump; | ||
const { destination, options } = cm.state.jump; | ||
if (destination) { | ||
cm.state.jump.options.onClick(destination, clickEvent); | ||
options.onClick(destination, clickEvent); | ||
} | ||
@@ -111,0 +111,0 @@ }; |
@@ -22,3 +22,3 @@ /** | ||
) { | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
// If there is no stack of levels, use the current level. | ||
@@ -28,3 +28,3 @@ // Otherwise, use the top level, preemptively dedenting for close braces. | ||
!levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -31,0 +31,0 @@ (this.electricInput?.test(textAfter) ? 1 : 0); |
@@ -51,3 +51,3 @@ /** | ||
function checkSuggestions(source: string[], suggestions?: IHint[]) { | ||
function expectSuggestions(source: string[], suggestions?: IHint[]) { | ||
const titles = suggestions?.map(suggestion => suggestion.text); | ||
@@ -66,3 +66,3 @@ expect(titles).toEqual(source); | ||
const initialKeywords = ['{']; | ||
checkSuggestions(initialKeywords, suggestions?.list); | ||
expectSuggestions(initialKeywords, suggestions?.list); | ||
}); | ||
@@ -76,3 +76,3 @@ | ||
); | ||
checkSuggestions(['"foo": ', '"bar": '], suggestions?.list); | ||
expectSuggestions(['"foo": ', '"bar": '], suggestions?.list); | ||
}); | ||
@@ -96,3 +96,3 @@ | ||
); | ||
checkSuggestions(['"bar": '], suggestions?.list); | ||
expectSuggestions(['"bar": '], suggestions?.list); | ||
expect(suggestions?.from).toEqual({ line: 1, ch: 2, sticky: null }); | ||
@@ -108,3 +108,3 @@ expect(suggestions?.to).toEqual({ line: 1, ch: 4, sticky: null }); | ||
); | ||
checkSuggestions(['"foo": ', '"bar": '], suggestions?.list); | ||
expectSuggestions(['"foo": ', '"bar": '], suggestions?.list); | ||
expect(suggestions?.from).toEqual({ line: 1, ch: 2, sticky: null }); | ||
@@ -121,3 +121,3 @@ expect(suggestions?.to).toEqual({ line: 1, ch: 3, sticky: null }); | ||
const TestEnum = TestSchema.getType('TestEnum'); | ||
checkSuggestions( | ||
expectSuggestions( | ||
(TestEnum as GraphQLEnumType) | ||
@@ -136,3 +136,3 @@ ?.getValues() | ||
); | ||
checkSuggestions(['{'], suggestions?.list); | ||
expectSuggestions(['{'], suggestions?.list); | ||
}); | ||
@@ -147,3 +147,3 @@ | ||
const TestInput = TestSchema.getType('TestInput'); | ||
checkSuggestions( | ||
expectSuggestions( | ||
Object.keys((TestInput as GraphQLInputObjectType).getFields()).map( | ||
@@ -164,3 +164,3 @@ name => `"${name}": `, | ||
); | ||
checkSuggestions(['"boolean": ', '"listBoolean": '], suggestions?.list); | ||
expectSuggestions(['"boolean": ', '"listBoolean": '], suggestions?.list); | ||
expect(suggestions?.from).toEqual({ line: 2, ch: 4, sticky: null }); | ||
@@ -176,4 +176,4 @@ expect(suggestions?.to).toEqual({ line: 2, ch: 8, sticky: null }); | ||
); | ||
checkSuggestions(['true', 'false'], suggestions?.list); | ||
expectSuggestions(['true', 'false'], suggestions?.list); | ||
}); | ||
}); |
@@ -56,3 +56,3 @@ /** | ||
) { | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
// If there is no stack of levels, use the current level. | ||
@@ -62,3 +62,3 @@ // Otherwise, use the top level, preemptively dedenting for close braces. | ||
!levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -65,0 +65,0 @@ (this.electricInput?.test(textAfter) ? 1 : 0); |
@@ -71,5 +71,5 @@ import CodeMirror from 'codemirror'; | ||
const onClick = (clickEvent) => { | ||
const { destination } = cm.state.jump; | ||
const { destination, options } = cm.state.jump; | ||
if (destination) { | ||
cm.state.jump.options.onClick(destination, clickEvent); | ||
options.onClick(destination, clickEvent); | ||
} | ||
@@ -76,0 +76,0 @@ }; |
@@ -76,5 +76,5 @@ "use strict"; | ||
var onClick = function (clickEvent) { | ||
var destination = cm.state.jump.destination; | ||
var _a = cm.state.jump, destination = _a.destination, options = _a.options; | ||
if (destination) { | ||
cm.state.jump.options.onClick(destination, clickEvent); | ||
options.onClick(destination, clickEvent); | ||
} | ||
@@ -81,0 +81,0 @@ }; |
export default function indent(state, textAfter) { | ||
var _a, _b; | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
const level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -7,0 +7,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -5,5 +5,5 @@ "use strict"; | ||
var _a, _b; | ||
var levels = state.levels; | ||
var levels = state.levels, indentLevel = state.indentLevel; | ||
var level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -10,0 +10,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -25,5 +25,5 @@ import CodeMirror from 'codemirror'; | ||
var _a, _b; | ||
const { levels } = state; | ||
const { levels, indentLevel } = state; | ||
const level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -30,0 +30,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
@@ -30,5 +30,5 @@ "use strict"; | ||
var _a, _b; | ||
var levels = state.levels; | ||
var levels = state.levels, indentLevel = state.indentLevel; | ||
var level = !levels || levels.length === 0 | ||
? state.indentLevel | ||
? indentLevel | ||
: levels[levels.length - 1] - | ||
@@ -35,0 +35,0 @@ (((_a = this.electricInput) === null || _a === void 0 ? void 0 : _a.test(textAfter)) ? 1 : 0); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 2 instances in 1 package
447481
9196
+ Addedgraphql-language-service@5.1.2(transitive)
- Removedgraphql-language-service@5.1.1(transitive)