@bscotch/gcdata
Advanced tools
Comparing version 0.16.0 to 0.17.0
@@ -5,3 +5,3 @@ import { assert } from './assert.js'; | ||
import { bsArrayToArray, changedPosition, createBsArrayKey, updateBsArrayOrder, } from './helpers.js'; | ||
import { parsedItemToWords } from './util.js'; | ||
import { checkWords } from './util.js'; | ||
export function parseStringifiedQuest(text, packed, options = {}) { | ||
@@ -64,9 +64,5 @@ const motes = getMoteLists(packed.working); | ||
const checkSpelling = (item) => { | ||
if (!item || !options.checkSpelling) | ||
if (!item || !options.checkSpelling || !packed.glossary) | ||
return; | ||
// Parse out the word positions so they can be used as ranges to check cursor position | ||
const words = parsedItemToWords(item); | ||
for (const word of words) { | ||
result.words.push(packed.spellChecker.checkWord(word)); | ||
} | ||
result.words.push(...checkWords(item, packed.glossary)); | ||
}; | ||
@@ -73,0 +69,0 @@ /** The MoteId for the last speaker we saw. Used to figure out who to assign stuff to */ |
import { assert } from './assert.js'; | ||
import { arrayTagPattern, getStorylineMote, getStorylineSchema, lineIsArrayItem, linePatterns, parseIfMatch, storylineSchemaId, } from './cl2.storyline.types.js'; | ||
import { bsArrayToArray, createBsArrayKey, updateBsArrayOrder, } from './helpers.js'; | ||
import { parsedItemToWords } from './util.js'; | ||
import { checkWords } from './util.js'; | ||
export function parseStringifiedStoryline(text, packed, options = {}) { | ||
@@ -19,7 +19,3 @@ const result = { | ||
return; | ||
// Parse out the word positions so they can be used as ranges to check cursor position | ||
const words = parsedItemToWords(item); | ||
for (const word of words) { | ||
result.words.push(packed.spellChecker.checkWord(word)); | ||
} | ||
result.words.push(...checkWords(item, packed.glossary)); | ||
}; | ||
@@ -26,0 +22,0 @@ const lines = text.split(/(\r?\n)/g); |
@@ -12,2 +12,7 @@ import type { Range } from './types.editor.js'; | ||
} | ||
export type ParsedWord = Range & { | ||
value: string; | ||
suggestions?: string[]; | ||
valid: boolean; | ||
}; | ||
export interface ParserResult { | ||
@@ -25,9 +30,5 @@ diagnostics: (Range & { | ||
completions: Range[]; | ||
words: (Range & { | ||
value: string; | ||
suggestions?: string[]; | ||
valid: boolean; | ||
})[]; | ||
words: ParsedWord[]; | ||
parsed: ParsedBase; | ||
} | ||
//# sourceMappingURL=cl2.types.editor.d.ts.map |
@@ -0,3 +1,3 @@ | ||
import { Glossary } from '@bscotch/cl2-string-server-shared'; | ||
import { Pathy } from '@bscotch/pathy'; | ||
import { SpellChecker } from './SpellChecker.js'; | ||
import { GameChangerRumpusMetadata } from './types.cl2.rumpus.js'; | ||
@@ -46,3 +46,2 @@ import { Bschema, ChangeType, Changes, type Mote, type MoteId, type PackedData, type SchemaId } from './types.js'; | ||
export declare class GameChanger { | ||
#private; | ||
readonly projectName: string; | ||
@@ -52,4 +51,4 @@ base: Gcdata; | ||
protected changes: Changes; | ||
glossary?: Glossary; | ||
protected constructor(projectName: string); | ||
get spellChecker(): SpellChecker; | ||
protected get workingData(): PackedData; | ||
@@ -72,2 +71,7 @@ protected get baseData(): PackedData; | ||
load(): Promise<void>; | ||
loadGlossary(access: { | ||
host: string; | ||
username: string; | ||
password: string; | ||
}): Promise<Glossary>; | ||
/** | ||
@@ -74,0 +78,0 @@ * @param path Either the path to a .yyp file (to get the included packed file) or the direct path to a GameChanger snapshot (e.g. a packed file or a base file). |
@@ -0,4 +1,5 @@ | ||
import { Client, Glossary } from '@bscotch/cl2-string-server-shared'; | ||
import { pathy } from '@bscotch/pathy'; | ||
import fetch from 'node-fetch'; | ||
import { gameChangerEvents } from './GameChanger.events.js'; | ||
import { SpellChecker } from './SpellChecker.js'; | ||
import { GcdataError, assert } from './assert.js'; | ||
@@ -134,11 +135,6 @@ import { gameChangerRumpusMetadataSchema, } from './types.cl2.rumpus.js'; | ||
changes; | ||
#spellChecker; | ||
glossary; | ||
constructor(projectName) { | ||
this.projectName = projectName; | ||
} | ||
get spellChecker() { | ||
// Lazy-load the spell checker to save some compute | ||
this.#spellChecker ||= new SpellChecker(this); | ||
return this.#spellChecker; | ||
} | ||
get workingData() { | ||
@@ -444,2 +440,13 @@ return this.working.data; | ||
} | ||
async loadGlossary(access) { | ||
const client = new Client({ | ||
baseUrl: access.host, | ||
password: access.password, | ||
user: access.username, | ||
// @ts-expect-error A type mismatch, but this is the correct thing! | ||
fetch, | ||
}); | ||
this.glossary = await Glossary.create(client); | ||
return this.glossary; | ||
} | ||
/** | ||
@@ -446,0 +453,0 @@ * @param path Either the path to a .yyp file (to get the included packed file) or the direct path to a GameChanger snapshot (e.g. a packed file or a base file). |
@@ -0,3 +1,5 @@ | ||
import type { Glossary } from '@bscotch/cl2-string-server-shared'; | ||
import type { Gcdata } from './GameChanger.js'; | ||
import { ParsedLineItem } from './cl2.quest.types.js'; | ||
import { ParsedWord } from './cl2.types.editor.js'; | ||
import { type Bschema, type Mote } from './types.js'; | ||
@@ -42,2 +44,3 @@ export declare function objectToMap<T>(obj: T): Map<keyof T, T[keyof T]>; | ||
export declare function parsedItemToWords(item: ParsedLineItem): ParsedLineItem[]; | ||
export declare function checkWords(item: ParsedLineItem<any> | undefined, glossary?: Glossary): ParsedWord[]; | ||
//# sourceMappingURL=util.d.ts.map |
@@ -272,2 +272,24 @@ import { assert } from './assert.js'; | ||
} | ||
export function checkWords(item, glossary) { | ||
const result = []; | ||
if (!item || !glossary) | ||
return result; | ||
// Parse out the word positions so they can be used as ranges to check cursor position | ||
const words = glossary.parse(item.value); | ||
for (const word of words) { | ||
const checked = glossary.checkWord(word); | ||
const asGcWord = { | ||
valid: checked.valid, | ||
value: checked.substr, | ||
start: { ...item.start }, | ||
end: { ...item.start }, | ||
}; | ||
asGcWord.start.character += checked.start; | ||
asGcWord.start.index += checked.start; | ||
asGcWord.end.character = asGcWord.start.character + checked.substr.length; | ||
asGcWord.end.index = asGcWord.start.index + checked.substr.length; | ||
result.push(asGcWord); | ||
} | ||
return result; | ||
} | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "@bscotch/gcdata", | ||
"version": "0.16.0", | ||
"version": "0.17.0", | ||
"license": "MIT", | ||
@@ -8,4 +8,6 @@ "type": "module", | ||
"dependencies": { | ||
"@bscotch/cl2-string-server-shared": "0.5.2", | ||
"@bscotch/emitter": "0.2.1", | ||
"@bscotch/pathy": "^2.12.0", | ||
"node-fetch": "^3.3.2", | ||
"nspell": "2.1.5", | ||
@@ -12,0 +14,0 @@ "zod": "3.22.4" |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance 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
2645889
6
103
78867
1
+ Addednode-fetch@^3.3.2
+ Added@bscotch/cl2-string-server-shared@0.5.2(transitive)
+ Added@emnapi/runtime@0.45.0(transitive)
+ Added@img/sharp-darwin-arm64@0.33.2(transitive)
+ Added@img/sharp-darwin-x64@0.33.2(transitive)
+ Added@img/sharp-libvips-darwin-arm64@1.0.1(transitive)
+ Added@img/sharp-libvips-darwin-x64@1.0.1(transitive)
+ Added@img/sharp-libvips-linux-arm@1.0.1(transitive)
+ Added@img/sharp-libvips-linux-arm64@1.0.1(transitive)
+ Added@img/sharp-libvips-linux-s390x@1.0.1(transitive)
+ Added@img/sharp-libvips-linux-x64@1.0.1(transitive)
+ Added@img/sharp-libvips-linuxmusl-arm64@1.0.1(transitive)
+ Added@img/sharp-libvips-linuxmusl-x64@1.0.1(transitive)
+ Added@img/sharp-linux-arm@0.33.2(transitive)
+ Added@img/sharp-linux-arm64@0.33.2(transitive)
+ Added@img/sharp-linux-s390x@0.33.2(transitive)
+ Added@img/sharp-linux-x64@0.33.2(transitive)
+ Added@img/sharp-linuxmusl-arm64@0.33.2(transitive)
+ Added@img/sharp-linuxmusl-x64@0.33.2(transitive)
+ Added@img/sharp-wasm32@0.33.2(transitive)
+ Added@img/sharp-win32-ia32@0.33.2(transitive)
+ Added@img/sharp-win32-x64@0.33.2(transitive)
+ Addedcolor@4.2.3(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addedcolor-string@1.9.1(transitive)
+ Addeddata-uri-to-buffer@4.0.1(transitive)
+ Addeddetect-libc@2.0.3(transitive)
+ Addedfetch-blob@3.2.0(transitive)
+ Addedformdata-polyfill@4.0.10(transitive)
+ Addedis-arrayish@0.3.2(transitive)
+ Addedmarked@11.1.1(transitive)
+ Addednode-domexception@1.0.0(transitive)
+ Addednode-fetch@3.3.2(transitive)
+ Addedsemver@7.6.3(transitive)
+ Addedsharp@0.33.2(transitive)
+ Addedsimple-swizzle@0.2.2(transitive)
+ Addedweb-streams-polyfill@3.3.3(transitive)