@vmz/plugin-monaco 0.0.0 → 0.0.3

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.
package/README.md CHANGED
@@ -1,3 +1,37 @@
1
1
  # @vmz/plugin-monaco
2
2
 
3
- Placeholder package (0.0.0). Reserved for the VMZ project.
3
+ ## Bring an IDE-class editor to the browser
4
+
5
+ `@vmz/plugin-monaco` integrates Monaco for VMZ applications that genuinely need a rich code-editing experience: browser
6
+ IDEs, serious language playgrounds, configuration workbenches, and professional developer tools.
7
+
8
+ ## When Monaco is the right answer
9
+
10
+ Monaco is familiar to many developers because it powers the editing experience behind VS Code. That capability comes
11
+ with a meaningful browser cost. It is the right choice when editing is central to the product and advanced editor
12
+ behavior justifies the payload; it is not the automatic choice for a small form field or a documentation snippet.
13
+
14
+ For lighter embedded editing, choose `@vmz/plugin-codemirror`. The distinction is intentionally product-oriented rather
15
+ than ideological: VMZ should let an application choose the right interaction tool while still keeping delivery and
16
+ resumption boundaries visible.
17
+
18
+ | Monaco is a strong fit for... | Prefer CodeMirror for... |
19
+ |---------------------------------------------|---------------------------------------------|
20
+ | Browser IDEs and rich developer workbenches | Lightweight embedded editing |
21
+ | Products where editing is the main task | Documentation pages and smaller playgrounds |
22
+
23
+ ## VMZ boundary
24
+
25
+ Monaco owns the editor experience. VMZ owns the surrounding page, its SSR fallback, the Island or client boundary that
26
+ loads Monaco, and the test and deployment evidence for that boundary. This prevents one rich widget from turning the
27
+ whole application into an eager client runtime.
28
+
29
+ ## Features worth paying for 🚀
30
+
31
+ - Familiar IDE-style editing for developer audiences.
32
+ - A foundation for rich language services, diagnostics, navigation, and completion.
33
+ - Strong fit for multi-file playgrounds and browser workbenches.
34
+ - An interaction surface substantial enough to justify an isolated delivery boundary.
35
+
36
+ Monaco works best when users arrive to edit, inspect, or debug code. VMZ's Island and application boundaries make that
37
+ tradeoff explicit: deliver the IDE when the user reaches the IDE experience.
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div class="monaco-host" data-vmz-monaco style="min-height: 240px; width: 100%"></div>
3
+ </template>
4
+
5
+ <script client>
6
+ import { mountMonaco } from '@vmz/plugin-monaco/runtime';
7
+
8
+ export default class Monaco {
9
+ public value: string = '';
10
+ public language: string = 'typescript';
11
+ public theme: string = 'vs-dark';
12
+ public readOnly: boolean = false;
13
+
14
+ #api: { dispose: () => void } | null = null;
15
+
16
+ async onMount() {
17
+ const root = this.__vmzDomRoot;
18
+ const el =
19
+ (root && root.nodeType === 1 && root.matches?.('[data-vmz-monaco]') && root) ||
20
+ root?.querySelector?.('[data-vmz-monaco]') ||
21
+ root;
22
+ if (!el || el.nodeType !== 1) return;
23
+ this.#api = await mountMonaco(el, {
24
+ value: this.value,
25
+ language: this.language,
26
+ theme: this.theme,
27
+ readOnly: this.readOnly,
28
+ onChange: (v) => {
29
+ this.value = v;
30
+ },
31
+ });
32
+ }
33
+
34
+ onDestroy() {
35
+ this.#api?.dispose();
36
+ this.#api = null;
37
+ }
38
+ }
39
+ </script>
package/package.json CHANGED
@@ -1,10 +1,38 @@
1
1
  {
2
2
  "name": "@vmz/plugin-monaco",
3
- "version": "0.0.0",
4
- "description": "VMZ placeholder — not for production use.",
3
+ "version": "0.0.3",
4
+ "type": "module",
5
+ "description": "VMZ Monaco editor adapter - <Monaco>",
5
6
  "license": "MIT",
6
- "private": false,
7
- "files": [
8
- "README.md"
9
- ]
7
+ "main": "./vmz.plugin.ts",
8
+ "types": "./vmz.plugin.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./vmz.plugin.ts",
12
+ "default": "./vmz.plugin.ts"
13
+ },
14
+ "./runtime": {
15
+ "types": "./runtime.ts",
16
+ "default": "./runtime.ts"
17
+ }
18
+ },
19
+ "dependencies": {
20
+ "@vmz/plugin": "0.0.3"
21
+ },
22
+ "peerDependencies": {
23
+ "monaco-editor": ">=0.52"
24
+ },
25
+ "keywords": [
26
+ "vmz",
27
+ "plugin",
28
+ "monaco",
29
+ "editor"
30
+ ],
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "git+https://github.com/doki-land/vmz-framework.git"
37
+ }
10
38
  }
package/runtime.ts ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Monaco mount helper (browser). First slice: imperative create/dispose.
3
+ * Peer: monaco-editor.
4
+ */
5
+
6
+ export type MountMonacoOptions = {
7
+ value?: string;
8
+ language?: string;
9
+ theme?: string;
10
+ readOnly?: boolean;
11
+ onChange?: (v: string) => void;
12
+ };
13
+
14
+ export async function mountMonaco(el: HTMLElement, opts: MountMonacoOptions = {}) {
15
+ const monaco = await import('monaco-editor');
16
+ const editor = monaco.editor.create(el, {
17
+ value: opts.value ?? '',
18
+ language: opts.language ?? 'typescript',
19
+ theme: opts.theme ?? 'vs-dark',
20
+ readOnly: !!opts.readOnly,
21
+ automaticLayout: true,
22
+ minimap: { enabled: false },
23
+ });
24
+ if (typeof opts.onChange === 'function') {
25
+ editor.onDidChangeModelContent(() => {
26
+ opts.onChange?.(editor.getValue());
27
+ });
28
+ }
29
+ return {
30
+ editor,
31
+ getValue: () => editor.getValue(),
32
+ setValue: (v: string) => editor.setValue(v ?? ''),
33
+ dispose: () => editor.dispose(),
34
+ };
35
+ }
package/vmz.plugin.ts ADDED
@@ -0,0 +1,46 @@
1
+ import { definePlugin, loadPluginSource } from '@vmz/plugin';
2
+
3
+ const source = loadPluginSource(import.meta.url, 'components/Monaco.vmz');
4
+
5
+ export default definePlugin({
6
+ name: '@vmz/plugin-monaco',
7
+ version: '0.1.0',
8
+ protocol: '0.1.0',
9
+ stages: ['workspace_resolve', 'analyzer'],
10
+ deterministic: true,
11
+ async contribute(ctx) {
12
+ if (ctx.stage === 'workspace_resolve') {
13
+ return {
14
+ stage: 'workspace_resolve',
15
+ cacheKey: `@vmz/plugin-monaco:Monaco.vmz:${source.contentHash.slice(0, 12)}`,
16
+ items: [
17
+ {
18
+ id: 'component-monaco',
19
+ kind: 'source',
20
+ path: 'src/components/Monaco.vmz',
21
+ content: source.content,
22
+ contentHash: source.contentHash,
23
+ materialize: true,
24
+ },
25
+ ],
26
+ };
27
+ }
28
+ if (ctx.stage === 'analyzer') {
29
+ return {
30
+ stage: 'analyzer',
31
+ cacheKey: '@vmz/plugin-monaco:analyzer',
32
+ items: [
33
+ {
34
+ id: 'component-monaco-online',
35
+ kind: 'analyzer',
36
+ path: 'src/components/Monaco.vmz',
37
+ severity: 'advice',
38
+ message: 'Monaco component online',
39
+ code: 'vmz.plugin.monaco',
40
+ },
41
+ ],
42
+ };
43
+ }
44
+ return { stage: ctx.stage, items: [] };
45
+ },
46
+ });