nuxt-monaco-editor 1.2.8 → 1.3.0

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,13 @@
1
+ import * as _nuxt_schema from '@nuxt/schema';
2
+
3
+ type MonacoEditorLocale = 'cs' | 'de' | 'es' | 'fr' | 'it' | 'ja' | 'ko' | 'pl' | 'pt-br' | 'qps-ploc' | 'ru' | 'tr' | 'zh-hans' | 'zh-hant' | 'en';
4
+ interface ModuleOptions {
5
+ locale?: MonacoEditorLocale;
6
+ componentName?: {
7
+ codeEditor?: string;
8
+ diffEditor?: string;
9
+ };
10
+ }
11
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
12
+
13
+ export { type ModuleOptions, type MonacoEditorLocale, _default as default };
package/dist/module.d.ts CHANGED
@@ -8,6 +8,6 @@ interface ModuleOptions {
8
8
  diffEditor?: string;
9
9
  };
10
10
  }
11
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
11
+ declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
12
12
 
13
- export { ModuleOptions, MonacoEditorLocale, _default as default };
13
+ export { type ModuleOptions, type MonacoEditorLocale, _default as default };
package/dist/module.json CHANGED
@@ -2,7 +2,11 @@
2
2
  "name": "nuxt-monaco-editor",
3
3
  "configKey": "monacoEditor",
4
4
  "compatibility": {
5
- "nuxt": "^3.1.0"
5
+ "nuxt": ">=3.1.0"
6
6
  },
7
- "version": "1.2.8"
7
+ "version": "1.3.0",
8
+ "builder": {
9
+ "@nuxt/module-builder": "0.8.4",
10
+ "unbuild": "2.0.0"
11
+ }
8
12
  }
package/dist/module.mjs CHANGED
@@ -36,7 +36,7 @@ const plugin = (options, nuxtOptions) => ({
36
36
  return { code: rewrittenMonacoFiles.get(id) };
37
37
  }
38
38
  if (/\/(vscode-)?nls\.m?js/.test(id)) {
39
- const code = (await fs.readFile(resolve("nls.mjs"), "utf-8")).replace("__LOCALE_DATA_PATH__", `nuxt-monaco-editor/dist/i18n/${options.locale}.json`);
39
+ const code = (await fs.readFile(resolve("nls.mjs"), "utf-8")).replace("__LOCALE_DATA_PATH__", `nuxt-monaco-editor/dist/i18n/${options.locale}.json`).replace("__LOCALE__", options.locale);
40
40
  rewrittenMonacoFiles.set(id, code);
41
41
  return { code };
42
42
  }
@@ -71,16 +71,13 @@ const module = defineNuxtModule({
71
71
  meta: {
72
72
  name: "nuxt-monaco-editor",
73
73
  configKey: "monacoEditor",
74
- compatibility: { nuxt: "^3.1.0" }
74
+ compatibility: { nuxt: ">=3.1.0" }
75
75
  },
76
76
  defaults: DEFAULTS,
77
77
  setup(options, nuxt) {
78
78
  const isDev = nuxt.options.dev;
79
79
  const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
80
80
  const { resolve } = createResolver(runtimeDir);
81
- if (isDev) {
82
- nuxt.options.vite.optimizeDeps?.exclude?.push("monaco-editor");
83
- }
84
81
  nuxt.options.build.transpile.push(runtimeDir);
85
82
  nuxt.options.build.transpile.push(({ isClient }) => isClient ? "monaco-editor" : false);
86
83
  addVitePlugin(plugin(options, nuxt.options));
@@ -20,6 +20,18 @@ interface Props {
20
20
  * Options passed to the second argument of `monaco.editor.createDiffEditor`
21
21
  */
22
22
  options?: Monaco.editor.IStandaloneDiffEditorConstructionOptions;
23
+ /**
24
+ * The URI that identifies models
25
+ */
26
+ // eslint-disable-next-line vue/require-default-prop
27
+ originalModelUri?: Monaco.Uri;
28
+
29
+ /**
30
+ * The URI that identifies models
31
+ */
32
+ // eslint-disable-next-line vue/require-default-prop
33
+ modelUri?: Monaco.Uri;
34
+
23
35
  original?: string;
24
36
  modelValue?: string;
25
37
  }
@@ -62,8 +74,8 @@ watch(() => props.lang, () => {
62
74
  const modifiedValue = modifiedModel?.getValue() || props.modelValue
63
75
  if (originalModel) { originalModel.dispose() }
64
76
  if (modifiedModel) { modifiedModel.dispose() }
65
- originalModel = monaco.editor.createModel(originalValue, props.lang)
66
- modifiedModel = monaco.editor.createModel(modifiedValue, props.lang)
77
+ originalModel = monaco.editor.createModel(originalValue, props.lang, props.originalModelUri)
78
+ modifiedModel = monaco.editor.createModel(modifiedValue, props.lang, props.modelUri)
67
79
  editor.setModel({
68
80
  original: originalModel,
69
81
  modified: modifiedModel
@@ -85,8 +97,8 @@ watch(editorElement, (newValue, oldValue) => {
85
97
  if (!editorElement.value || oldValue) { return }
86
98
  editor = monaco.editor.createDiffEditor(editorElement.value!, defu(props.options, defaultOptions))
87
99
  editorRef.value = editor
88
- originalModel = monaco.editor.createModel(props.original, props.lang)
89
- modifiedModel = monaco.editor.createModel(props.modelValue, props.lang)
100
+ originalModel = monaco.editor.createModel(props.original, props.lang, props.originalModelUri)
101
+ modifiedModel = monaco.editor.createModel(props.modelValue, props.lang, props.modelUri)
90
102
  editor.setModel({
91
103
  original: originalModel,
92
104
  modified: modifiedModel
@@ -5,7 +5,7 @@
5
5
  </template>
6
6
 
7
7
  <script lang="ts" setup>
8
- import type * as Monaco from 'monaco-editor'
8
+ import * as Monaco from 'monaco-editor'
9
9
  import { computed, ref, shallowRef, watch, onBeforeUnmount } from 'vue'
10
10
  import { defu } from 'defu'
11
11
  import { useMonaco } from './composables'
@@ -20,6 +20,12 @@ interface Props {
20
20
  * Options passed to the second argument of `monaco.editor.create`
21
21
  */
22
22
  options?: Monaco.editor.IStandaloneEditorConstructionOptions;
23
+ /**
24
+ * The URI that identifies models
25
+ */
26
+ // eslint-disable-next-line vue/require-default-prop
27
+ modelUri?: Monaco.Uri;
28
+
23
29
  modelValue?: string;
24
30
  }
25
31
 
@@ -53,11 +59,11 @@ watch(() => props.modelValue, () => {
53
59
  }
54
60
  })
55
61
 
56
- watch(() => props.lang, () => {
62
+ watch(() => [props.lang, props.modelUri], () => {
57
63
  if (model) {
58
64
  model.dispose()
59
65
  }
60
- model = monaco.editor.createModel(props.modelValue, lang.value)
66
+ model = monaco.editor.createModel(props.modelValue, lang.value, props.modelUri)
61
67
  editor?.setModel(model)
62
68
  })
63
69
 
@@ -68,7 +74,7 @@ watch(() => props.options, () => {
68
74
  watch(editorElement, (newValue, oldValue) => {
69
75
  if (!editorElement.value || oldValue) { return }
70
76
  editor = monaco.editor.create(editorElement.value!, defu(props.options, defaultOptions))
71
- model = monaco.editor.createModel(props.modelValue, lang.value)
77
+ model = monaco.editor.createModel(props.modelValue, lang.value, props.modelUri)
72
78
  editorRef.value = editor
73
79
  editor.layout()
74
80
  editor.setModel(model)
@@ -1,5 +1,5 @@
1
1
  import type * as Monaco from 'monaco-editor';
2
- export declare const _useMonacoState: () => any;
2
+ export declare const _useMonacoState: () => import("vue").Ref<typeof Monaco | null, typeof Monaco | null>;
3
3
  /**
4
4
  * Get `monaco` namespace
5
5
  * @returns `monaco` namespace: if unavailable (server-side), returns `null`
@@ -1,5 +1,7 @@
1
1
  export function _format(message: any, args: any): any;
2
2
  export function localize(path: any, _data: any, defaultMessage: any, ...args: any[]): any;
3
+ export function getNLSMessages(): never[];
4
+ export function getNLSLanguage(): string;
3
5
  export function loadMessageBundle(file: any): typeof localize;
4
6
  export function config(opt: any): typeof loadMessageBundle;
5
7
  export function getConfiguredDefaultLocale(): undefined;
@@ -35,6 +35,13 @@ export const localize2 = (data, message, ...args) => {
35
35
  }
36
36
  }
37
37
 
38
+ export function getNLSMessages () {
39
+ return []
40
+ }
41
+ export function getNLSLanguage () {
42
+ return '__LOCALE__'
43
+ }
44
+
38
45
  export function loadMessageBundle (file) {
39
46
  return localize
40
47
  }
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- import { _useMonacoState } from "./composables.mjs";
1
+ import { _useMonacoState } from "./composables.js";
2
2
  import { defineNuxtPlugin } from "#imports";
3
3
  export default defineNuxtPlugin(async (nuxtApp) => {
4
4
  const getWorkerModule = (moduleUrl, label) => {
@@ -1,2 +1,2 @@
1
- declare const _default: any;
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
2
  export default _default;
@@ -1,4 +1,4 @@
1
- import { _useMonacoState } from "./composables.mjs";
1
+ import { _useMonacoState } from "./composables.js";
2
2
  import { defineNuxtPlugin } from "#imports";
3
3
  export default defineNuxtPlugin(async (nuxtApp) => {
4
4
  const getWorkerModule = (moduleUrl, label) => {
@@ -0,0 +1 @@
1
+ export { type ModuleOptions, type MonacoEditorLocale, default } from './module.js'
package/dist/types.d.ts CHANGED
@@ -1,10 +1 @@
1
-
2
- import { ModuleOptions } from './module'
3
-
4
- declare module '@nuxt/schema' {
5
- interface NuxtConfig { ['monacoEditor']?: Partial<ModuleOptions> }
6
- interface NuxtOptions { ['monacoEditor']?: ModuleOptions }
7
- }
8
-
9
-
10
- export { ModuleOptions, MonacoEditorLocale, default } from './module'
1
+ export { type ModuleOptions, type MonacoEditorLocale, default } from './module'
package/package.json CHANGED
@@ -11,13 +11,14 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/e-chan1007/nuxt-monaco-editor.git"
13
13
  },
14
- "version": "1.2.8",
14
+ "version": "1.3.0",
15
15
  "type": "module",
16
16
  "license": "MIT",
17
17
  "exports": {
18
18
  ".": {
19
19
  "import": "./dist/module.mjs",
20
- "require": "./dist/module.cjs"
20
+ "require": "./dist/module.cjs",
21
+ "types": "./dist/types.d.ts"
21
22
  },
22
23
  "./dist/*": {
23
24
  "import": "./dist/*"
@@ -31,14 +32,14 @@
31
32
  "scripts": {
32
33
  "postpack": "pinst --enable",
33
34
  "_postinstall": "husky install && playwright install",
34
- "build": "nuxt-module-build && yarn loc:build",
35
+ "build": "nuxt-module-build build && yarn loc:build",
35
36
  "lint": "eslint --ext .js,.cjs,.mjs,.ts,.cts,.mts,.vue . && remark . -q",
36
37
  "test": "nuxt test",
37
- "prepack": "pinst --disable && nuxt-module-build",
38
+ "prepack": "pinst --disable && nuxt-module-build build && yarn loc:build",
38
39
  "release": "standard-version",
39
40
  "dev": "nuxt dev playground",
40
41
  "dev:build": "nuxt build playground",
41
- "dev:prepare": "nuxt-module-build --stub && nuxt prepare playground && yarn loc:build",
42
+ "dev:prepare": "nuxt-module-build build --stub && nuxt prepare playground && yarn loc:build",
42
43
  "docs:dev": "nuxt dev docs",
43
44
  "docs:generate": "nuxt generate docs",
44
45
  "docs:prepare": "nuxt prepare docs",
@@ -46,34 +47,35 @@
46
47
  "loc:build": "jiti scripts/build-loc.ts"
47
48
  },
48
49
  "dependencies": {
49
- "@nuxt/kit": "^3.11.2",
50
+ "@nuxt/kit": "^3.13.2",
50
51
  "defu": "^6.1.4",
51
- "vite-plugin-static-copy": "^1.0.3"
52
+ "vite-plugin-static-copy": "^2.0.0"
52
53
  },
53
54
  "devDependencies": {
54
- "@commitlint/cli": "^19.2.2",
55
- "@commitlint/config-conventional": "^19.2.2",
56
- "@nuxt-themes/docus": "^1.15.0",
57
- "@nuxt/module-builder": "latest",
55
+ "@commitlint/cli": "^19.5.0",
56
+ "@commitlint/config-conventional": "^19.5.0",
57
+ "@nuxt/module-builder": "0.8.4",
58
58
  "@nuxt/test-utils": "3.11.0",
59
59
  "@nuxtjs/eslint-config-typescript": "^12.1.0",
60
- "@vue/test-utils": "^2.4.5",
61
- "eslint": "^8.57.0",
62
- "execa": "^8.0.1",
63
- "happy-dom": "^14.7.1",
64
- "husky": "^9.0.11",
65
- "jiti": "^1.21.0",
66
- "monaco-editor": "^0.47.0",
67
- "nuxt": "^3.11.2",
60
+ "@vue/test-utils": "^2.4.6",
61
+ "eslint": "^8.57.1",
62
+ "execa": "^9.4.1",
63
+ "happy-dom": "^15.7.4",
64
+ "husky": "^9.1.6",
65
+ "jiti": "^2.3.3",
66
+ "monaco-editor": "^0.52.0",
67
+ "nuxt": "^3.13.2",
68
+ "nuxt-content-twoslash": "^0.1.1",
68
69
  "pinst": "^3.0.0",
69
- "playwright": "^1.43.1",
70
- "playwright-core": "^1.43.1",
71
- "remark-cli": "^12.0.0",
70
+ "playwright": "^1.48.1",
71
+ "playwright-core": "^1.48.1",
72
+ "remark-cli": "^12.0.1",
72
73
  "remark-lint": "^10.0.0",
73
74
  "remark-preset-lint-recommended": "^7.0.0",
75
+ "shadcn-docs-nuxt": "^0.6.4",
74
76
  "standard-version": "^9.5.0",
75
- "typescript": "^5.4.5",
76
- "vitest": "^1.5.0"
77
+ "typescript": "^5.6.3",
78
+ "vitest": "^2.1.3"
77
79
  },
78
80
  "peerDependencies": {
79
81
  "monaco-editor": "*"
@@ -90,5 +92,5 @@
90
92
  "workspaces": [
91
93
  "playground"
92
94
  ],
93
- "packageManager": "yarn@4.1.1"
95
+ "packageManager": "yarn@4.5.1"
94
96
  }