Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 apps/design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"generate:assets": "echo \"No assets to configure\"",
"test": "echo \"No tests\"",
"eject": "react-scripts eject",
"dev": "concurrently 'npm run watch:*'",
"dev": "concurrently 'pnpm run watch:*'",
"watch:storybook": "storybook dev -p 6006 --no-open",
"watch:tailwind": "npx tailwindcss -i ./src/styles/tailwind.css -o ./src/styles/tailwind.output.css --watch",
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
Expand Down Expand Up @@ -75,4 +75,4 @@
"publishConfig": {
"access": "public"
}
}
}
84 changes: 43 additions & 41 deletions apps/studio/src/services/editor.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ export interface UpdateState {
updateModel?: boolean;
sendToServer?: boolean;
file?: Partial<File>;
}
}

export class EditorService extends AbstractService {
private created = false;
private decorations: Map<string, string[]> = new Map();
private instance: monacoAPI.editor.IStandaloneCodeEditor | undefined;

override onInit() {
this.subcribeToDocuments();
this.subscribeToDocuments();
}

async onDidCreate(editor: monacoAPI.editor.IStandaloneCodeEditor) {
Expand All @@ -43,13 +43,13 @@ export class EditorService extends AbstractService {
} else {
this.applyMarkersAndDecorations(document.diagnostics.filtered);
}

// apply save command
editor.addCommand(
KeyMod.CtrlCmd | KeyCode.KeyS,
() => this.saveToLocalStorage(),
);

appState.setState({ initialized: true });
}

Expand Down Expand Up @@ -107,12 +107,12 @@ export class EditorService extends AbstractService {
return fetch(url)
.then(res => res.text())
.then(async text => {
this.updateState({
content: text,
updateModel: true,
file: {
source: url,
from: 'url'
this.updateState({
content: text,
updateModel: true,
file: {
source: url,
from: 'url'
},
});
})
Expand All @@ -131,7 +131,7 @@ export class EditorService extends AbstractService {
if (!file) {
return;
}

// Check if file is valid (only JSON and YAML are allowed currently) ----Change afterwards as per the requirement
if (
file.type !== 'application/json' &&
Expand All @@ -152,12 +152,12 @@ export class EditorService extends AbstractService {
async importBase64(content: string) {
try {
const decoded = this.svcs.formatSvc.decodeBase64(content);
this.updateState({
content: String(decoded),
updateModel: true,
file: {
from: 'base64',
source: undefined,
this.updateState({
content: String(decoded),
updateModel: true,
file: {
from: 'base64',
source: undefined,
},
});
} catch (err) {
Expand All @@ -174,12 +174,12 @@ export class EditorService extends AbstractService {
}

const data = await response.json();
this.updateState({
content: data.content,
updateModel: true,
file: {
from: 'share',
source: undefined,
this.updateState({
content: data.content,
updateModel: true,
file: {
from: 'share',
source: undefined,
},
});
} catch (err) {
Expand Down Expand Up @@ -219,9 +219,9 @@ export class EditorService extends AbstractService {
try {
const yamlContent = this.svcs.formatSvc.convertToYaml(this.value);
if (yamlContent) {
this.updateState({
content: yamlContent,
updateModel: true,
this.updateState({
content: yamlContent,
updateModel: true,
file: {
language: 'yaml',
}
Expand All @@ -237,9 +237,9 @@ export class EditorService extends AbstractService {
try {
const jsonContent = this.svcs.formatSvc.convertToJSON(this.value);
if (jsonContent) {
this.updateState({
content: jsonContent,
updateModel: true,
this.updateState({
content: jsonContent,
updateModel: true,
file: {
language: 'json',
}
Expand Down Expand Up @@ -339,7 +339,7 @@ export class EditorService extends AbstractService {
id: 'asyncapi',
ownerId: 0,
range: new Range(
range.start.line + 1,
range.start.line + 1,
range.start.character + 1,
range.end.line + 1,
range.end.character + 1
Expand All @@ -351,7 +351,7 @@ export class EditorService extends AbstractService {
});
return;
}

newMarkers.push({
startLineNumber: range.start.line + 1,
startColumn: range.start.character + 1,
Expand All @@ -365,31 +365,33 @@ export class EditorService extends AbstractService {
return { decorations: newDecorations, markers: newMarkers };
}

/* eslint-disable indent */
private getSeverity(severity: DiagnosticSeverity): monacoAPI.MarkerSeverity {
switch (severity) {
case DiagnosticSeverity.Error: return MarkerSeverity.Error;
case DiagnosticSeverity.Warning: return MarkerSeverity.Warning;
case DiagnosticSeverity.Information: return MarkerSeverity.Info;
case DiagnosticSeverity.Hint: return MarkerSeverity.Hint;
default: return MarkerSeverity.Error;
case DiagnosticSeverity.Error: return MarkerSeverity.Error;
case DiagnosticSeverity.Warning: return MarkerSeverity.Warning;
case DiagnosticSeverity.Information: return MarkerSeverity.Info;
case DiagnosticSeverity.Hint: return MarkerSeverity.Hint;
default: return MarkerSeverity.Error;
}
}

private getSeverityClassName(severity: DiagnosticSeverity): string {
switch (severity) {
case DiagnosticSeverity.Warning: return 'diagnostic-warning';
case DiagnosticSeverity.Information: return 'diagnostic-information';
case DiagnosticSeverity.Hint: return 'diagnostic-hint';
default: return 'diagnostic-warning';
case DiagnosticSeverity.Warning: return 'diagnostic-warning';
case DiagnosticSeverity.Information: return 'diagnostic-information';
case DiagnosticSeverity.Hint: return 'diagnostic-hint';
default: return 'diagnostic-warning';
}
}
/* eslint-enable indent */

private fileName = 'asyncapi';
private downloadFile(content: string, fileName: string) {
return fileDownload(content, fileName);
}

private subcribeToDocuments() {
private subscribeToDocuments() {
documentsState.subscribe((state, prevState) => {
const newDocuments = state.documents;
const oldDocuments = prevState.documents;
Expand Down
8 changes: 4 additions & 4 deletions apps/studio/src/services/monaco.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class MonacoService extends AbstractService {
// load initial language config (for json and yaml)
this.setLanguageConfig(this.svcs.specificationSvc.latestVersion);
// subscribe to document to update JSON/YAML language config
this.subcribeToDocuments();
this.subscribeToDocuments();
}

get monaco() {
Expand Down Expand Up @@ -85,7 +85,7 @@ export class MonacoService extends AbstractService {
if (process.env.NODE_ENV === 'test') {
return;
}

const monaco = this.monacoInstance = await import('monaco-editor');
loader.config({ monaco });
}
Expand Down Expand Up @@ -124,7 +124,7 @@ export class MonacoService extends AbstractService {
}

return {
uri,
uri,
schema,
};
});
Expand Down Expand Up @@ -158,7 +158,7 @@ export class MonacoService extends AbstractService {
})) as JSONSchema7;
}

private subcribeToDocuments() {
private subscribeToDocuments() {
documentsState.subscribe((state, prevState) => {
const newDocuments = state.documents;
const oldDocuments = prevState.documents;
Expand Down
6 changes: 3 additions & 3 deletions apps/studio/src/services/specification.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type { SpecVersions } from '../types';
export class SpecificationService extends AbstractService {
private keySessionStorage = 'informed-about-latest';
override onInit() {
this.subcribeToDocuments();
this.subscribeToDocuments();
this.subscribeToSettings();
}

Expand All @@ -21,14 +21,14 @@ export class SpecificationService extends AbstractService {
}

get latestVersion(): SpecVersions {
return Object.keys(this.specs).pop() as SpecVersions;
return Object.keys(this.specs).pop() as SpecVersions;
}

getSpec(version: SpecVersions) {
return this.specs[String(version) as SpecVersions];
}

private subcribeToDocuments() {
private subscribeToDocuments() {
documentsState.subscribe((state, prevState) => {
const newDocuments = state.documents;
const oldDocuments = prevState.documents;
Expand Down
5 changes: 3 additions & 2 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"types": "dist/index.d.ts",
"private": true,
"scripts": {
"build": "tsup"
"build": "tsup",
"dev": "tsup --watch"
},
"keywords": [],
"author": "",
Expand All @@ -18,4 +19,4 @@
"devDependencies": {
"tsup": "^8.0.2"
}
}
}
27 changes: 21 additions & 6 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
{
"$schema": "https://turbo.build/schema.json",
"globalDependencies": ["**/.env.*local"],
"globalDependencies": [
"**/.env.*local"
],
"pipeline": {
"build": {
"dependsOn": ["^build"],
"outputs": ["dist/**", "storybook-static/**"],
"dependsOn": [
"^build"
],
"outputs": [
"dist/**",
"storybook-static/**"
],
"cache": false
},
"dev": {
"dependsOn": [
"^build"
],
"cache": false,
"persistent": true
},
"release": {
"dependsOn": ["build"]
"dependsOn": [
"build"
]
},
"test": {
"dependsOn": ["lint", "generate:assets"]
"dependsOn": [
"lint",
"generate:assets"
]
},
"clean": {},
"lint": {},
"generate:assets": {}
}
}
}