Skip to content

Commit

Permalink
Add package langium-website-foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisalmen committed Oct 16, 2023
1 parent 320d353 commit f386f48
Show file tree
Hide file tree
Showing 21 changed files with 168 additions and 74 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/public/
/hugo/resources/
/hugo/static/css/
hugo/static/libs
hugo/static/showcase/
hugo/static/libs/
hugo/static/playground/
node_modules/
.DS_Store
.hugo_build.lock
2 changes: 2 additions & 0 deletions foundation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bundle/
dist/
67 changes: 67 additions & 0 deletions foundation/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"name": "langium-website-foundation",
"version": "1.0.0",
"type": "module",
"description": "Bundling complex sources for hugo",
"author": "TypeFox",
"license": "MIT",
"private": true,
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./bundle": {
"types": "./dist/index.d.ts",
"default": "./bundle/monaco-editor-wrapper-bundle/index.js"
}
},
"typesVersions": {
"*": {
".": [
"dist/index"
],
"bundle": [
"dist/index"
]
}
},
"files": [
"dist",
"bundle",
"src",
"LICENSE",
"README.md"
],
"scripts": {
"clean": "shx rm -rf ./bundle ./dist",
"compile": "tsc",
"build:bundle": "vite --config vite.bundle.ts build",
"build": "npm run clean && npm run compile && npm run build:bundle"
},
"devDependencies": {
"@types/react": "~18.2.28",
"@types/react-dom": "~18.2.13",
"@types/vscode": "~1.82.0",
"typescript": "~5.2.2",
"vite": "~4.4.11"
},
"dependencies": {
"@codingame/monaco-vscode-keybindings-service-override": "~1.82.5",
"@typefox/monaco-editor-react": "2.3.0-next.3",
"monaco-editor": "~0.43.0",
"monaco-editor-workers": "~0.43.0",
"monaco-editor-wrapper": "~3.3.0-next.3",
"monaco-languageclient": "~6.5.3",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.82.5 <1.83.0",
"vscode-languageserver": "~8.0.2"
},
"volta": {
"node": "18.18.1",
"npm": "9.9.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { addMonacoStyles } from 'monaco-editor-wrapper/styles';

export * from "monaco-editor-wrapper";
export type * from "monaco-editor-wrapper";
export * from "./monaco-editor-wrapper-utils";
export * from "./monaco-editor-wrapper-utils.js";

export {
monaco,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as monaco from "monaco-editor";
import { languages } from "monaco-editor";
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
import { EditorAppConfigClassic, EditorAppConfigExtended, LanguageClientConfig, UserConfig } from "monaco-editor-wrapper";

Expand All @@ -25,7 +25,7 @@ export interface MonacoExtendedReactConfig extends MonacoReactConfig {
* Editor config, specifically for monarch grammar usage
*/
export interface MonacoEditorReactConfig extends MonacoReactConfig {
monarchGrammar?: monaco.languages.IMonarchLanguage;
monarchGrammar?: languages.IMonarchLanguage;
}

/**
Expand Down
15 changes: 15 additions & 0 deletions foundation/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"compilerOptions": {
"noImplicitAny": true,
"target": "ES2022",
"module": "Node16",
"moduleResolution": "Node16",
"rootDir": "src",
"outDir": "dist",
"declaration": true,
"declarationDir": "dist"
},
"include": [
"src/**/*.ts",
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@ import { defineConfig } from 'vite';
const config = defineConfig({
build: {
lib: {
entry: resolve(__dirname, './content/playground/common.ts'),
name: 'playground-common',
fileName: () => 'common.js',
entry: resolve(__dirname, './src/index.ts'),
name: 'monaco-editor-wrapper-bundle',
fileName: () => 'index.js',
formats: ['es']
},
outDir: resolve(__dirname, 'static/playground/libs/worker'),
assetsDir: resolve(__dirname, 'static/playground/libs/worker/assets'),
emptyOutDir: false,
outDir: resolve(__dirname, 'bundle/monaco-editor-wrapper-bundle'),
assetsDir: resolve(__dirname, 'bundle/monaco-editor-wrapper-bundle/assets'),
emptyOutDir: true,
cssCodeSplit: false,
commonjsOptions: {
strictRequires: true
},
rollupOptions: {
output: {
name: 'playground-common',
name: 'monaco-editor-wrapper-bundle',
exports: 'named',
sourcemap: false,
assetFileNames: (assetInfo) => {
Expand All @@ -32,4 +32,4 @@ const config = defineConfig({
}
});

export default config;
export default config;
5 changes: 5 additions & 0 deletions hugo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resources/
static/css/
static/showcase/
static/libs/
static/playground/
2 changes: 1 addition & 1 deletion hugo/assets/scripts/arithmetics/arithmetics-tools.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { monaco } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { monaco } from "langium-website-foundation/bundle";
import { Pos } from "../langium-utils/langium-ast";

export interface Evaluation {
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/arithmetics/arithmetics.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "langium-website-foundation/bundle";
import { buildWorkerDefinition } from "monaco-editor-workers";
import React from "react";
import { createRoot } from "react-dom/client";
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/domainmodel/domainmodel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "langium-website-foundation/bundle";
import { buildWorkerDefinition } from "monaco-editor-workers";
import React from "react";
import { createRoot } from "react-dom/client";
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/minilogo/minilogo-tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { monaco } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { monaco } from "langium-website-foundation/bundle";

export interface Command {
name: 'penUp' | 'penDown' | 'move' | 'color';
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/minilogo/minilogo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "langium-website-foundation/bundle";
import { buildWorkerDefinition } from "monaco-editor-workers";
import React, { createRef } from "react";
import { createRoot } from "react-dom/client";
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/sql/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { monaco } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { monaco } from "langium-website-foundation/bundle";

export const syntaxHighlighting: monaco.languages.IMonarchLanguage = {
tokenizer: {
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/sql/ui.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "langium-website-foundation/bundle";
import { buildWorkerDefinition } from "monaco-editor-workers";
import React from "react";
import { createRoot } from "react-dom/client";
Expand Down
2 changes: 1 addition & 1 deletion hugo/assets/scripts/statemachine/statemachine.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "./static/libs/monaco-editor-react/monaco-editor-react.js";
import { createUserConfig, MonacoEditorReactComp, UserConfig } from "langium-website-foundation/bundle";
import { buildWorkerDefinition } from "monaco-editor-workers";
import React from "react";
import { createRoot } from "react-dom/client";
Expand Down
3 changes: 1 addition & 2 deletions hugo/content/playground/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import { Disposable } from "vscode-languageserver";
import { DefaultAstNodeLocator, createServicesForGrammar } from "langium";
import { render } from './Tree';
import { overlay, throttle } from "./utils";
import { createUserConfig } from "../../assets/scripts/monaco-editor-wrapper-utils";
import { MonacoEditorLanguageClientWrapper } from "monaco-editor-wrapper";
import { createUserConfig, MonacoEditorLanguageClientWrapper } from "langium-website-foundation/bundle";
import { DocumentChangeResponse } from "../../assets/scripts/langium-utils/langium-ast";

export { share, overlay } from './utils'
Expand Down
10 changes: 4 additions & 6 deletions hugo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@
"copy:libs:prepare": "shx mkdir -p ./static/libs/monaco-editor-workers/workers",
"copy:monaco-workers": "npm run copy:libs:prepare && shx cp -f ../node_modules/monaco-editor-workers/dist/index.* ./static/libs/monaco-editor-workers && shx cp -f ../node_modules/monaco-editor-workers/dist/workers/editorWorker-iife.js ./static/libs/monaco-editor-workers/workers",
"build:worker/statemachine": "esbuild ../node_modules/langium-statemachine-dsl/out/language-server/main-browser.js --bundle --format=iife --outfile=./static/showcase/libs/worker/statemachineServerWorker.js",
"vite:build:worker/statemachine": "vite --config vite.showcase-worker.ts build",
"build:worker/monaco-editor-react": "vite --config vite.bundle-monaco-editor-react.ts build",
"build:worker/arithmetics": "esbuild ../node_modules/langium-arithmetics-dsl/out/language-server/main-browser.js --bundle --format=iife --outfile=./static/showcase/libs/worker/arithmeticsServerWorker.js",
"build:worker/domainmodel": "esbuild ../node_modules/langium-domainmodel-dsl/out/language-server/main-browser.js --bundle --format=iife --outfile=./static/showcase/libs/worker/domainmodelServerWorker.js",
"build:worker/playground-langium": "esbuild ./content/playground/langium-worker.ts --bundle --format=iife --outfile=./static/playground/libs/worker/langiumServerWorker.js",
"build:worker/playground-user": "esbuild ./content/playground/user-worker.ts --bundle --format=iife --outfile=./static/playground/libs/worker/userServerWorker.js",
"build:worker/playground-common": "vite --config vite.bundle-playground-common.ts build",
"build:worker/playground-common": "esbuild ./content/playground/common.ts --bundle --format=esm --outfile=./static/playground/libs/worker/common.js",
"build:worker/sql": "esbuild ./assets/scripts/sql/language-server.ts --bundle --format=iife --outfile=./static/showcase/libs/worker/sqlServerWorker.js",
"build:worker/minilogo": "esbuild ../node_modules/langium-minilogo/out/language-server/main-browser.js --bundle --format=iife --outfile=./static/showcase/libs/worker/minilogoServerWorker.js",
"build:static": "npm run clean:static && npm run build:worker/monaco-editor-react && npm run build:worker/statemachine && npm run build:worker/domainmodel && npm run build:worker/sql && npm run build:worker/minilogo && npm run build:worker/arithmetics && npm run build:worker/playground-common && npm run build:worker/playground-langium && npm run build:worker/playground-user && npm run copy:monaco-workers",
"build:static": "npm run clean:static && npm run build:worker/statemachine && npm run build:worker/domainmodel && npm run build:worker/sql && npm run build:worker/minilogo && npm run build:worker/arithmetics && npm run build:worker/playground-common && npm run build:worker/playground-langium && npm run build:worker/playground-user && npm run copy:monaco-workers",
"build": "npm run build:static && cross-env NODE_ENV=production hugo --config ./config.toml -b / -d ../public --gc --minify ",
"watch": "npm run build:static && cross-env NODE_ENV=development hugo server --config ./config.toml -D -b localhost:1313 -d ../public --appendPort=false",
"watch:gitpod": "npm run build:static && cross-env NODE_ENV=development hugo server --config ./config.toml -D -b `gp url 1313` -d ../public --appendPort=false"
Expand All @@ -29,8 +27,7 @@
"@types/mustache": "^4.2.1",
"@types/react": "~18.2.28",
"@types/react-dom": "~18.2.13",
"esbuild": "~0.19.4",
"vite": "~4.4.11"
"esbuild": "~0.19.4"
},
"dependencies": {
"@babel/cli": "~7.19.3",
Expand All @@ -49,6 +46,7 @@
"langium-minilogo": "^1.2.0",
"langium-sql": "^0.2.3",
"langium-statemachine-dsl": "~1.2.0",
"langium-website-foundation": "~1.0.0",
"lz-string": "^1.4.4",
"monaco-editor": "~0.43.0",
"monaco-editor-workers": "~0.43.0",
Expand Down
35 changes: 0 additions & 35 deletions hugo/vite.bundle-monaco-editor-react.ts

This file was deleted.

52 changes: 50 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f386f48

Please sign in to comment.