x4js 2.2.5 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ import { Component, ComponentProps } from '../../x4.js';
2
+
3
+ import * as monaco from './bin/monaco.js';
4
+ import "./bin/monaco.css"
5
+
6
+
7
+ interface MonacoEditorProps extends ComponentProps {
8
+ language: "typescript" | "javascript" | "json" | "css" | "html";
9
+ theme?: string;
10
+ content?: string;
11
+ }
12
+
13
+ export class MonacoEditor extends Component<MonacoEditorProps> {
14
+
15
+ constructor( props: MonacoEditorProps ) {
16
+ super( props );
17
+
18
+ monaco.editor.create( this.dom as HTMLElement, {
19
+ value: props.content,
20
+ language: props.language,
21
+ theme: props.theme,
22
+ });
23
+ }
24
+ }
25
+
@@ -0,0 +1,3 @@
1
+ # using monaco in x4
2
+
3
+ you must copy ./bin/* in your destination folder
@@ -0,0 +1,41 @@
1
+ import * as esbuild from 'esbuild';
2
+
3
+ const MONACO_DIR = 'node_modules/monaco-editor/esm/vs';
4
+
5
+ const commonConfig = {
6
+ bundle: true,
7
+ minify: true,
8
+ format: 'esm',
9
+ target: 'es2022',
10
+ logLevel: 'info',
11
+ };
12
+
13
+ async function build() {
14
+ // 1. Build des Workers (obligatoires pour la coloration/validation)
15
+ // On génère uniquement les workers dont on a besoin
16
+ await esbuild.build({
17
+ ...commonConfig,
18
+ entryPoints: {
19
+ 'editor.worker': `${MONACO_DIR}/editor/editor.worker.js`,
20
+ 'ts.worker': `${MONACO_DIR}/language/typescript/ts.worker.js`,
21
+ 'css.worker': `${MONACO_DIR}/language/css/css.worker.js`,
22
+ 'html.worker': `${MONACO_DIR}/language/html/html.worker.js`,
23
+ 'json.worker': `${MONACO_DIR}/language/json/json.worker.js`,
24
+ },
25
+ outdir: 'dist/workers',
26
+ });
27
+
28
+ // 2. Build de l'application principale
29
+ await esbuild.build({
30
+ ...commonConfig,
31
+ entryPoints: ['index.ts'],
32
+ outfile: 'dist/monaco.js',
33
+ globalName: 'monaco',
34
+ loader: {
35
+ '.ttf': 'file',
36
+ '.css': 'css',
37
+ },
38
+ });
39
+ }
40
+
41
+ build();
@@ -0,0 +1,57 @@
1
+ import monaco from './dist/monaco.js';
2
+
3
+ const myLibCode = `
4
+ declare namespace MyAPI {
5
+ /**
6
+ * Calcule une performance optimale.
7
+ * @param value Le coefficient d'entrée.
8
+ */
9
+ function compute(value: number): string;
10
+ }
11
+ `;
12
+
13
+ const myLibUri = 'ts:filename/myapi.d.ts';
14
+
15
+ const ts = (monaco.languages).typescript;
16
+ ts.typescriptDefaults.addExtraLib(myLibCode, myLibUri);
17
+
18
+ // Facultatif : Créer un modèle pour que l'éditeur "voie" le fichier
19
+ // Utile si tu veux que le "Go to Definition" fonctionne vers ce fichier
20
+ monaco.editor.createModel(myLibCode, 'typescript', monaco.Uri.parse(myLibUri));
21
+
22
+
23
+ const el = document.getElementById("container");
24
+
25
+ globalThis.MonacoEnvironment = {
26
+ getWorkerUrl: function (_moduleId, label) {
27
+ if (label === 'json') return './dist/workers/json.worker.js';
28
+ if (label === 'css' || label === 'scss' || label === 'less') return './dist/workers/css.worker.js';
29
+ if (label === 'html') return './dist/workers/html.worker.js';
30
+ if (label === 'typescript' || label === 'javascript') return './dist/workers/ts.worker.js';
31
+ return './dist/workers/editor.worker.js';
32
+ }
33
+ };
34
+
35
+ monaco.languages["typescript"].typescriptDefaults.setCompilerOptions({
36
+ target: monaco.languages.typescript.ScriptTarget.ESNext,
37
+ allowNonTsExtensions: true,
38
+ moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
39
+ module: monaco.languages.typescript.ModuleKind.CommonJS,
40
+ noEmit: true,
41
+ typeRoots: ["node_modules/@types"]
42
+ });
43
+
44
+ monaco.editor.create(el, {
45
+ value: `
46
+ function test( ) {
47
+ for( let i=0; i<1000; i++ ) {
48
+ console.log( "i", i );
49
+ }
50
+ }
51
+
52
+ test( );
53
+ `,
54
+ language: 'typescript',
55
+ theme: 'vs-dark'
56
+ });
57
+
@@ -0,0 +1 @@
1
+ import 'monaco-editor/esm/vs/editor/editor.worker.js';
@@ -0,0 +1,7 @@
1
+ import * as monaco from 'monaco-editor';
2
+
3
+ import 'monaco-editor/esm/vs/language/html/monaco.contribution.js';
4
+ import 'monaco-editor/esm/vs/language/css/monaco.contribution.js';
5
+ import 'monaco-editor/esm/vs/language/typescript/monaco.contribution.js';
6
+
7
+ export default monaco;
@@ -0,0 +1,7 @@
1
+ {
2
+ "type": "module",
3
+ "dependencies": {
4
+ "esbuild": "^0.27.4",
5
+ "monaco-editor": "^0.55.1"
6
+ }
7
+ }
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <link rel="stylesheet" href="./dist/monaco.css">
3
+ <script type="module" src="demo.js"></script>
4
+
5
+ <body>
6
+ <div style="width:500px; height: 500px; border: 1px solid red;" id="container"></div>
7
+ </body>
8
+
9
+ </html>
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "moduleResolution": "node",
4
+ "allowSyntheticDefaultImports": true,
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "baseUrl": ".",
8
+ "paths": {
9
+ "monaco-editor/*": [
10
+ "node_modules/monaco-editor/*"
11
+ ]
12
+ },
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": true
15
+ }
16
+ }
@@ -38,11 +38,11 @@
38
38
  }
39
39
  }
40
40
 
41
- .hsize {
41
+ &.hsize {
42
42
  cursor: ew-resize;
43
43
  }
44
44
 
45
- .vsize {
45
+ &.vsize {
46
46
  cursor: ns-resize;
47
47
  }
48
48