@vmz/plugin-codemirror 0.3.5 → 0.3.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.
Files changed (3) hide show
  1. package/package.json +23 -8
  2. package/runtime.ts +0 -40
  3. package/vmz.plugin.ts +0 -46
package/package.json CHANGED
@@ -1,18 +1,30 @@
1
1
  {
2
2
  "dependencies": {
3
- "@vmz/plugin": "0.3.5"
3
+ "@vmz/plugin": "0.3.7"
4
4
  },
5
5
  "description": "VMZ CodeMirror 6 editor adapter - <Codemirror>",
6
+ "devDependencies": {
7
+ "@types/node": "^22.15.0",
8
+ "typescript": "^5.8.3"
9
+ },
10
+ "engines": {
11
+ "node": ">=24.12.0"
12
+ },
6
13
  "exports": {
7
14
  ".": {
8
- "default": "./vmz.plugin.ts",
9
- "types": "./vmz.plugin.ts"
15
+ "default": "./dist/vmz.plugin.js",
16
+ "types": "./dist/vmz.plugin.d.ts"
10
17
  },
11
18
  "./runtime": {
12
- "default": "./runtime.ts",
13
- "types": "./runtime.ts"
19
+ "default": "./dist/runtime.js",
20
+ "types": "./dist/runtime.d.ts"
14
21
  }
15
22
  },
23
+ "files": [
24
+ "dist",
25
+ "components",
26
+ "README.md"
27
+ ],
16
28
  "keywords": [
17
29
  "vmz",
18
30
  "plugin",
@@ -20,7 +32,7 @@
20
32
  "editor"
21
33
  ],
22
34
  "license": "MIT",
23
- "main": "./vmz.plugin.ts",
35
+ "main": "./dist/vmz.plugin.js",
24
36
  "name": "@vmz/plugin-codemirror",
25
37
  "peerDependencies": {
26
38
  "@codemirror/state": ">=6",
@@ -35,7 +47,10 @@
35
47
  "type": "git",
36
48
  "url": "git+https://github.com/doki-land/vmz-framework.git"
37
49
  },
50
+ "scripts": {
51
+ "build": "tsc -p tsconfig.json"
52
+ },
38
53
  "type": "module",
39
- "types": "./vmz.plugin.ts",
40
- "version": "0.3.5"
54
+ "types": "./dist/vmz.plugin.d.ts",
55
+ "version": "0.3.7"
41
56
  }
package/runtime.ts DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * CodeMirror 6 mount helper (browser).
3
- */
4
-
5
- export type MountCodemirrorOptions = {
6
- value?: string;
7
- onChange?: (v: string) => void;
8
- };
9
-
10
- export async function mountCodemirror(el: HTMLElement, opts: MountCodemirrorOptions = {}) {
11
- const { EditorView, basicSetup } = await import('codemirror').catch(async () => {
12
- const view = await import('@codemirror/view');
13
- const state = await import('@codemirror/state');
14
- return {
15
- EditorView: view.EditorView,
16
- basicSetup: [] as unknown[],
17
- EditorState: state.EditorState,
18
- };
19
- });
20
- const { EditorState } = await import('@codemirror/state');
21
- const sync = EditorView.updateListener.of((u) => {
22
- if (u.docChanged && typeof opts.onChange === 'function') {
23
- opts.onChange(u.state.doc.toString());
24
- }
25
- });
26
- const state = EditorState.create({
27
- doc: opts.value ?? '',
28
- extensions: [basicSetup, sync].flat().filter(Boolean),
29
- });
30
- const view = new EditorView({ state, parent: el });
31
- return {
32
- view,
33
- getValue: () => view.state.doc.toString(),
34
- setValue: (v: string) =>
35
- view.dispatch({
36
- changes: { from: 0, to: view.state.doc.length, insert: v ?? '' },
37
- }),
38
- dispose: () => view.destroy(),
39
- };
40
- }
package/vmz.plugin.ts DELETED
@@ -1,46 +0,0 @@
1
- import { definePlugin, loadPluginSource } from '@vmz/plugin';
2
-
3
- const source = loadPluginSource(import.meta.url, 'components/Codemirror.vmz');
4
-
5
- export default definePlugin({
6
- name: '@vmz/plugin-codemirror',
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-codemirror:Codemirror.vmz:${source.contentHash.slice(0, 12)}`,
16
- items: [
17
- {
18
- id: 'component-codemirror',
19
- kind: 'source',
20
- path: 'src/components/Codemirror.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-codemirror:analyzer',
32
- items: [
33
- {
34
- id: 'component-codemirror-online',
35
- kind: 'analyzer',
36
- path: 'src/components/Codemirror.vmz',
37
- severity: 'advice',
38
- message: 'Codemirror component online',
39
- code: 'vmz.plugin.codemirror',
40
- },
41
- ],
42
- };
43
- }
44
- return { stage: ctx.stage, items: [] };
45
- },
46
- });