Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update npm dependencies to latest #798

Merged
merged 4 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions jupyterlab/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
activate: async (
app: JupyterFrontEnd,
codemirrorLanguageRegistry: IEditorLanguageRegistry,
notebookTracker: INotebookTracker
notebookTracker: INotebookTracker,
) => {
registerQSharpLanguage(codemirrorLanguageRegistry);
registerQSharpNotebookHandlers(notebookTracker);
Expand All @@ -28,7 +28,7 @@ const plugin: JupyterFrontEndPlugin<void> = {
* and associates them with the qsharp CodeMirror mode.
*/
function registerQSharpLanguage(
codemirrorLanguageRegistry: IEditorLanguageRegistry
codemirrorLanguageRegistry: IEditorLanguageRegistry,
) {
const rules = [
{
Expand Down
2 changes: 1 addition & 1 deletion makeNpmDrop.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,5 @@ The main source file to show hooking up the compiler and Monaco on a web page is

The test files in "./npm/test/basics.js" show minimal examples of the qsharp compiler API usage.
`,
{ encoding: "utf8" }
{ encoding: "utf8" },
);
76 changes: 38 additions & 38 deletions npm/generate_katas_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function tryGetTitleFromSegment(segment, errorPrefix) {
if (segment.type !== "markdown") {
throw new Error(
`${errorPrefix}\n` +
`segment is expected to be the title but found a segment of type '${segment.type}' instead`
`segment is expected to be the title but found a segment of type '${segment.type}' instead`,
);
}

Expand All @@ -50,7 +50,7 @@ function tryGetTitleFromSegment(segment, errorPrefix) {
throw new Error(
`${errorPrefix}\n` +
`A title segment must be 1 line, but ${linesCount} lines are present\n` +
`Hint: is the markdown missing a @[section] macro?`
`Hint: is the markdown missing a @[section] macro?`,
);
}
const title = tryGetTitleFromMarkdown(segment.markdown, errorPrefix);
Expand Down Expand Up @@ -103,18 +103,18 @@ function resolveSvgSegment(properties, baseFolderPath) {
const requiredProperties = ["path"];
const missingProperties = identifyMissingProperties(
properties,
requiredProperties
requiredProperties,
);
if (missingProperties.length > 0) {
throw new Error(
`SVG macro is missing the following properties: ${missingProperties}`
`SVG macro is missing the following properties: ${missingProperties}`,
);
}

const svgPath = join(baseFolderPath, properties.path);
const svg = tryReadFile(
svgPath,
`Could not read the contents of the SVG file at ${svgPath}`
`Could not read the contents of the SVG file at ${svgPath}`,
);

properties["svg"] = svg;
Expand All @@ -135,7 +135,7 @@ function appendToMarkdownSegment(markdownSegment, segmentToAppend) {
markdownSegment.markdown += "\n" + segmentToAppend.properties.svg;
} else {
throw new Error(
`Cannot append segment of type "${segmentToAppend.type}" into markdown segment`
`Cannot append segment of type "${segmentToAppend.type}" into markdown segment`,
);
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ function coalesceSegments(segments) {
if (currentSegment.type === "markdown" || currentSegment.type === "svg") {
coalescedSegment = coalesceIntoSingleMarkdownSegment(
currentSegment,
segmentsStack
segmentsStack,
);
} else {
coalescedSegment = currentSegment;
Expand Down Expand Up @@ -195,7 +195,7 @@ function parseMarkdown(markdown) {
const delta = match.index - latestProcessedIndex;
if (delta > 0) {
const textSegment = tryCreateMarkdownSegment(
markdown.substring(latestProcessedIndex, match.index)
markdown.substring(latestProcessedIndex, match.index),
);
if (textSegment !== null) {
segments.push(textSegment);
Expand All @@ -209,7 +209,7 @@ function parseMarkdown(markdown) {
} else {
// No more matches were found, create a text segment with the remaining content.
const textSegment = tryCreateMarkdownSegment(
markdown.substring(latestProcessedIndex, markdown.length)
markdown.substring(latestProcessedIndex, markdown.length),
);
if (textSegment !== null) {
segments.push(textSegment);
Expand All @@ -226,19 +226,19 @@ function createExample(baseFolderPath, properties) {
const requiredProperties = ["id", "codePath"];
const missingProperties = identifyMissingProperties(
properties,
requiredProperties
requiredProperties,
);
if (missingProperties.length > 0) {
throw new Error(
`Example macro is missing the following properties: ${missingProperties}`
`Example macro is missing the following properties: ${missingProperties}`,
);
}

// Generate the object using the macro properties.
const codePath = join(baseFolderPath, properties.codePath);
const code = tryReadFile(
codePath,
`Could not read the contents of the example code file at ${codePath}`
`Could not read the contents of the example code file at ${codePath}`,
);
return {
type: "example",
Expand All @@ -257,19 +257,19 @@ function createSolution(baseFolderPath, properties) {
const requiredProperties = ["id", "codePath"];
const missingProperties = identifyMissingProperties(
properties,
requiredProperties
requiredProperties,
);
if (missingProperties.length > 0) {
throw new Error(
`Solution macro is missing the following properties: ${missingProperties}`
`Solution macro is missing the following properties: ${missingProperties}`,
);
}

// Generate the object using the macro properties.
const codePath = join(baseFolderPath, properties.codePath);
const code = tryReadFile(
codePath,
`Could not read the contents of the solution code file at ${codePath}`
`Could not read the contents of the solution code file at ${codePath}`,
);
return {
type: "solution",
Expand All @@ -281,7 +281,7 @@ function createSolution(baseFolderPath, properties) {
function createExplainedSolution(markdownFilePath) {
const markdown = tryReadFile(
markdownFilePath,
`Could not read solution markdown file at ${markdownFilePath}`
`Could not read solution markdown file at ${markdownFilePath}`,
);

const solutionFolderPath = dirname(markdownFilePath);
Expand Down Expand Up @@ -312,7 +312,7 @@ function createExplainedSolution(markdownFilePath) {
function createAnswer(markdownFilePath) {
const markdown = tryReadFile(
markdownFilePath,
`Could not read answer markdown file at ${markdownFilePath}`
`Could not read answer markdown file at ${markdownFilePath}`,
);

const answerFolderPath = dirname(markdownFilePath);
Expand Down Expand Up @@ -340,21 +340,21 @@ function createQuestion(kataPath, properties) {
const requiredProperties = ["descriptionPath", "answerPath"];
const missingProperties = identifyMissingProperties(
properties,
requiredProperties
requiredProperties,
);
if (missingProperties.length > 0) {
throw new Error(
`Question macro is missing the following properties\n` +
`${missingProperties}\n` +
`Macro properties:\n` +
`${JSON.stringify(properties, undefined, 2)}`
`${JSON.stringify(properties, undefined, 2)}`,
);
}

// Generate the object using the macro properties.
const descriptionMarkdown = tryReadFile(
join(kataPath, properties.descriptionPath),
`Could not read descripton for question ${properties.id}`
`Could not read descripton for question ${properties.id}`,
);
const description = createTextContent(descriptionMarkdown);
const answer = createAnswer(join(kataPath, properties.answerPath));
Expand All @@ -378,33 +378,33 @@ function createExerciseSection(kataPath, properties, globalCodeSources) {
];
const missingProperties = identifyMissingProperties(
properties,
requiredProperties
requiredProperties,
);
if (missingProperties.length > 0) {
throw new Error(
`Exercise macro is missing the following properties\n` +
`${missingProperties}\n` +
`Macro properties:\n` +
`${JSON.stringify(properties, undefined, 2)}`
`${JSON.stringify(properties, undefined, 2)}`,
);
}

// Generate the object using the macro properties.
const descriptionMarkdown = tryReadFile(
join(kataPath, properties.descriptionPath),
`Could not read descripton for exercise ${properties.id}`
`Could not read descripton for exercise ${properties.id}`,
);
const description = createTextContent(descriptionMarkdown);
const resolvedCodePaths = properties.codePaths.map((path) =>
join(kataPath, path)
join(kataPath, path),
);
const sourceIds = aggregateSources(resolvedCodePaths, globalCodeSources);
const placeholderCode = tryReadFile(
join(kataPath, properties.placeholderSourcePath),
`Could not read placeholder code for exercise '${properties.id}'`
`Could not read placeholder code for exercise '${properties.id}'`,
);
const explainedSolution = createExplainedSolution(
join(kataPath, properties.solutionPath)
join(kataPath, properties.solutionPath),
);

return {
Expand All @@ -423,14 +423,14 @@ function createLessonSection(kataPath, properties, segmentsStack) {
const requiredProperties = ["id", "title"];
const missingProperties = identifyMissingProperties(
properties,
requiredProperties
requiredProperties,
);
if (missingProperties.length > 0) {
throw new Error(
`Section macro is missing the following properties\n` +
`${missingProperties}\n` +
`Macro properties:\n` +
`${JSON.stringify(properties, undefined, 2)}`
`${JSON.stringify(properties, undefined, 2)}`,
);
}

Expand All @@ -457,7 +457,7 @@ function createLessonSection(kataPath, properties, segmentsStack) {
throw new Error(
`Lesson item could not be generated for segment of type '${currentSegment.type}'\n` +
`segment:\n` +
`${JSON.stringify(currentSegment, undefined, 2)}`
`${JSON.stringify(currentSegment, undefined, 2)}`,
);
}

Expand All @@ -477,7 +477,7 @@ function createMacroSegment(match) {
const propertiesJson = match.groups.json;
const properties = tryParseJSON(
propertiesJson,
`Invalid JSON for macro of type ${type}.\n` + `JSON: ${propertiesJson}`
`Invalid JSON for macro of type ${type}.\n` + `JSON: ${propertiesJson}`,
);
return {
type,
Expand Down Expand Up @@ -511,13 +511,13 @@ function createKata(kataPath, id, title, segments, globalCodeSources) {
section = createExerciseSection(
kataPath,
currentSegment.properties,
globalCodeSources
globalCodeSources,
);
} else if (currentSegment.type === "section") {
section = createLessonSection(
kataPath,
currentSegment.properties,
segmentsStack
segmentsStack,
);
}

Expand All @@ -527,7 +527,7 @@ function createKata(kataPath, id, title, segments, globalCodeSources) {
`Unexpexted segment of type '${currentSegment.type}'\n` +
`segment:\n` +
`${JSON.stringify(currentSegment, undefined, 2)}\n` +
`Hint: is the markdown missing a @[section] macro?`
`Hint: is the markdown missing a @[section] macro?`,
);
}

Expand All @@ -546,7 +546,7 @@ function generateKataContent(path, globalCodeSources) {
const markdownPath = join(path, contentFileNames.kataMarkdown);
const markdown = tryReadFile(
markdownPath,
"Could not read the contents of the kata markdown file"
"Could not read the contents of the kata markdown file",
);

const kataId = basename(path);
Expand All @@ -556,7 +556,7 @@ function generateKataContent(path, globalCodeSources) {
const firstSegment = rawSegments.at(0);
const title = tryGetTitleFromSegment(
firstSegment,
`Could not get title for kata '${kataId}'`
`Could not get title for kata '${kataId}'`,
);

// Do not use the first segment since it was already processed to get the kata's title.
Expand Down Expand Up @@ -607,11 +607,11 @@ function generateKatasContent(katasPath, outputPath) {
const indexPath = join(katasPath, contentFileNames.katasIndex);
const indexJson = tryReadFile(
indexPath,
"Could not read the contents of the katas index file"
"Could not read the contents of the katas index file",
);
const katasDirs = tryParseJSON(
indexJson,
`Invalid katas index at ${indexPath}`
`Invalid katas index at ${indexPath}`,
);

// Initialize an object where all the global code sources will be aggregated.
Expand Down Expand Up @@ -654,7 +654,7 @@ function generateKatasContent(katasPath, outputPath) {
writeFileSync(
contentJsPath,
`export default ${JSON.stringify(katasContent, undefined, 2)}`,
"utf-8"
"utf-8",
);
}

Expand Down
2 changes: 1 addition & 1 deletion npm/generate_samples_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ const contentPath = join(sampleGeneratedDir, "samples.generated.ts");
writeFileSync(
contentPath,
`export default ${JSON.stringify(result, undefined, 2)}`,
"utf-8"
"utf-8",
);
8 changes: 4 additions & 4 deletions npm/src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function wasmLoader(uriOrBuffer: string | ArrayBuffer) {
}

export function loadWasmModule(
uriOrBuffer: string | ArrayBuffer
uriOrBuffer: string | ArrayBuffer,
): Promise<void> {
// Only initiate if not already in flight, to avoid race conditions
if (!wasmModulePromise) {
Expand Down Expand Up @@ -86,7 +86,7 @@ async function instantiateWasm() {
}

export async function getLibrarySourceContent(
path: string
path: string,
): Promise<string | undefined> {
await instantiateWasm();
return wasm.get_library_source_content(path);
Expand All @@ -101,7 +101,7 @@ export async function getDebugService(): Promise<IDebugService> {
// If the Worker was already created via other means and is ready to receive
// messages, then the worker may be passed in and it will be initialized.
export function getDebugServiceWorker(
workerArg: string | Worker
workerArg: string | Worker,
): IDebugServiceWorker {
if (!wasmModule) throw "Wasm module must be loaded first";

Expand Down Expand Up @@ -171,7 +171,7 @@ export async function getLanguageService(): Promise<ILanguageService> {
// If the Worker was already created via other means and is ready to receive
// messages, then the worker may be passed in and it will be initialized.
export function getLanguageServiceWorker(
workerArg: string | Worker
workerArg: string | Worker,
): ILanguageServiceWorker {
if (!wasmModule) throw "Wasm module must be loaded first";

Expand Down
Loading