Skip to content

Commit

Permalink
Update preview runner to YS 3
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Sep 7, 2024
1 parent 25cb9a3 commit 61379e6
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Trace } from "vscode-jsonrpc/node";
import { YarnSpinnerEditorProvider } from './editor';
import * as fs from 'fs';
import { EventEmitter } from 'vscode';
import { CompilerOutput, DidChangeNodesNotification, DidRequestNodeInGraphViewParams } from './nodes';
import { CompilerOutput, DidChangeNodesNotification, DidRequestNodeInGraphViewParams, MetadataEntry } from './nodes';

import { DidChangeNodesParams, VOStringExport } from './nodes';
import { YarnPreviewPanel } from './preview';
Expand All @@ -29,8 +29,9 @@ let client: LanguageClient;
let server: ChildProcess;

export type YarnData = {
stringTable: { [key: string]: string },
programData: number[]
programData: string,
stringTable: Record<string, string>,
metadata: Record<string, MetadataEntry>
}

export function isStandaloneYarnSpinnerEditor() {
Expand Down Expand Up @@ -578,11 +579,10 @@ async function compileWorkspace(client: languageClient.LanguageClient): Promise<
return null;
}

let dataString = result.data as any; // turns out the server base64 encodes it

let yarnData : YarnData = {
programData: Buffer.from(dataString, "base64").toJSON().data,
stringTable: result.stringTable
programData: result.data,
stringTable: result.stringTable,
metadata: result.metadataTable,
};

return yarnData;
Expand Down
13 changes: 11 additions & 2 deletions src/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,18 @@ export interface DidRequestNodeInGraphViewParams {
nodeName: string
}

export type MetadataEntry = {
id: string;
node: string;
lineNumber: string;
tags: string[];
[key: string]: unknown;
};

export interface CompilerOutput {
data: Uint8Array;
stringTable: { [key: string]: string };
data: string;
stringTable: Record<string,string>;
metadataTable: Record<string, MetadataEntry>;
errors: string[];
}
export interface VOStringExport {
Expand Down
5 changes: 3 additions & 2 deletions src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ export class YarnPreviewPanel {
let injectedYarnProgramScript = `
<script>
window.yarnData = {
programData : Uint8Array.from(${JSON.stringify(yarnData.programData)}),
stringTable : ${JSON.stringify(yarnData.stringTable)}
data : "${yarnData.programData}",
stringTable : ${JSON.stringify(yarnData.stringTable)},
metadataTable : ${JSON.stringify(yarnData.metadata)}
};
${saveButton}
</script>
Expand Down
23 changes: 11 additions & 12 deletions src/runner.html

Large diffs are not rendered by default.

0 comments on commit 61379e6

Please sign in to comment.