pdl-editor 0.30.0 → 0.30.1
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 +12 -0
- package/dist/index.cjs +20 -8
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +20 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,10 +21,22 @@ cross-repo development:
|
|
|
21
21
|
```ts
|
|
22
22
|
import { PdlEditor } from "pdl-editor";
|
|
23
23
|
import { loadPdlRuntime } from "pdl-wasm";
|
|
24
|
+
import EditorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
|
25
|
+
import onigasmWasmUrl from "onigasm/lib/onigasm.wasm?url";
|
|
24
26
|
|
|
25
27
|
const runtime = await loadPdlRuntime({ wasmUrl: "/wasm/pdl.wasm" });
|
|
28
|
+
|
|
29
|
+
const setupOptions = {
|
|
30
|
+
createEditorWorker: () => new EditorWorker(),
|
|
31
|
+
onigasmWasmUrl,
|
|
32
|
+
};
|
|
26
33
|
```
|
|
27
34
|
|
|
35
|
+
The editor package keeps Vite-specific `?worker` and `?url` imports out of its
|
|
36
|
+
published `dist/` entrypoints. Vite hosts should import those assets in the app
|
|
37
|
+
and pass them through `setupOptions`; other bundlers can provide equivalent
|
|
38
|
+
worker factories and asset URLs.
|
|
39
|
+
|
|
28
40
|
Use packed mode before publishing by running `npm pack --dry-run` in
|
|
29
41
|
`packages/wasm` and `editors/monaco`, then inspecting the file lists for
|
|
30
42
|
`dist/`, declarations, README, package metadata, and editor assets.
|
package/dist/index.cjs
CHANGED
|
@@ -50,11 +50,9 @@ var import_react = __toESM(require("react"), 1);
|
|
|
50
50
|
var monaco = __toESM(require("monaco-editor/esm/vs/editor/editor.api"), 1);
|
|
51
51
|
var import_editor_main = require("monaco-editor/min/vs/editor/editor.main.css");
|
|
52
52
|
var import_hoverContribution = require("monaco-editor/esm/vs/editor/contrib/hover/browser/hoverContribution");
|
|
53
|
-
var import_editor = __toESM(require("monaco-editor/esm/vs/editor/editor.worker?worker"), 1);
|
|
54
53
|
var import_monaco_editor_textmate = require("monaco-editor-textmate");
|
|
55
54
|
var import_monaco_textmate = require("monaco-textmate");
|
|
56
55
|
var import_onigasm = require("onigasm");
|
|
57
|
-
var import_onigasm2 = __toESM(require("onigasm/lib/onigasm.wasm?url"), 1);
|
|
58
56
|
|
|
59
57
|
// assets/language-configuration.json
|
|
60
58
|
var language_configuration_default = {
|
|
@@ -689,11 +687,11 @@ function ensurePdlProviders(languageId) {
|
|
|
689
687
|
}
|
|
690
688
|
async function setupPdlMonacoOnce(options) {
|
|
691
689
|
if (options.configureWorker !== false) {
|
|
692
|
-
configureMonacoWorker();
|
|
690
|
+
configureMonacoWorker(options);
|
|
693
691
|
}
|
|
694
692
|
registerPdlLanguage(options);
|
|
695
693
|
definePdlTheme(options.themeName ?? PDL_THEME_NAME, options.theme ?? defaultPdlTheme());
|
|
696
|
-
await loadOnigasmOnce(options
|
|
694
|
+
await loadOnigasmOnce(resolveOnigasmWasmUrl(options));
|
|
697
695
|
const registry = new import_monaco_textmate.Registry({
|
|
698
696
|
getGrammarDefinition: async () => ({
|
|
699
697
|
format: "json",
|
|
@@ -706,11 +704,25 @@ async function setupPdlMonacoOnce(options) {
|
|
|
706
704
|
/* @__PURE__ */ new Map([[options.languageId ?? PDL_LANGUAGE_ID, options.scopeName ?? PDL_SCOPE_NAME]])
|
|
707
705
|
);
|
|
708
706
|
}
|
|
709
|
-
function configureMonacoWorker() {
|
|
707
|
+
function configureMonacoWorker(options) {
|
|
710
708
|
const target = globalThis;
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
}
|
|
709
|
+
if (target.MonacoEnvironment?.getWorker) {
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
const createEditorWorker = options.createEditorWorker;
|
|
713
|
+
if (!createEditorWorker) {
|
|
714
|
+
throw new Error("pdl-editor requires setupPdlMonaco({ createEditorWorker }) unless configureWorker is false.");
|
|
715
|
+
}
|
|
716
|
+
target.MonacoEnvironment = {
|
|
717
|
+
...target.MonacoEnvironment,
|
|
718
|
+
getWorker: () => createEditorWorker()
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
function resolveOnigasmWasmUrl(options) {
|
|
722
|
+
if (options.onigasmWasmUrl) {
|
|
723
|
+
return options.onigasmWasmUrl;
|
|
724
|
+
}
|
|
725
|
+
throw new Error("pdl-editor requires setupPdlMonaco({ onigasmWasmUrl }) for TextMate grammar loading.");
|
|
714
726
|
}
|
|
715
727
|
function loadOnigasmOnce(url) {
|
|
716
728
|
onigasmPromise ?? (onigasmPromise = (0, import_onigasm.loadWASM)(url).catch((error) => {
|
package/dist/index.d.cts
CHANGED
|
@@ -102,6 +102,7 @@ interface SetupPdlMonacoOptions {
|
|
|
102
102
|
grammar?: unknown;
|
|
103
103
|
languageConfiguration?: monaco.languages.LanguageConfiguration;
|
|
104
104
|
onigasmWasmUrl?: string;
|
|
105
|
+
createEditorWorker?: () => Worker | Promise<Worker>;
|
|
105
106
|
configureWorker?: boolean;
|
|
106
107
|
}
|
|
107
108
|
declare function PdlEditor({ value, files, diagnostics, runtime, onChange, modelUri, languageId, themeName, theme, className, editorClassName, options, setupOptions, }: PdlEditorProps): React.ReactElement;
|
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,7 @@ interface SetupPdlMonacoOptions {
|
|
|
102
102
|
grammar?: unknown;
|
|
103
103
|
languageConfiguration?: monaco.languages.LanguageConfiguration;
|
|
104
104
|
onigasmWasmUrl?: string;
|
|
105
|
+
createEditorWorker?: () => Worker | Promise<Worker>;
|
|
105
106
|
configureWorker?: boolean;
|
|
106
107
|
}
|
|
107
108
|
declare function PdlEditor({ value, files, diagnostics, runtime, onChange, modelUri, languageId, themeName, theme, className, editorClassName, options, setupOptions, }: PdlEditorProps): React.ReactElement;
|
package/dist/index.mjs
CHANGED
|
@@ -3,11 +3,9 @@ import React from "react";
|
|
|
3
3
|
import * as monaco from "monaco-editor/esm/vs/editor/editor.api";
|
|
4
4
|
import "monaco-editor/min/vs/editor/editor.main.css";
|
|
5
5
|
import "monaco-editor/esm/vs/editor/contrib/hover/browser/hoverContribution";
|
|
6
|
-
import EditorWorker from "monaco-editor/esm/vs/editor/editor.worker?worker";
|
|
7
6
|
import { wireTmGrammars } from "monaco-editor-textmate";
|
|
8
7
|
import { Registry } from "monaco-textmate";
|
|
9
8
|
import { loadWASM as loadOnigasm } from "onigasm";
|
|
10
|
-
import onigasmWasmUrl from "onigasm/lib/onigasm.wasm?url";
|
|
11
9
|
|
|
12
10
|
// assets/language-configuration.json
|
|
13
11
|
var language_configuration_default = {
|
|
@@ -642,11 +640,11 @@ function ensurePdlProviders(languageId) {
|
|
|
642
640
|
}
|
|
643
641
|
async function setupPdlMonacoOnce(options) {
|
|
644
642
|
if (options.configureWorker !== false) {
|
|
645
|
-
configureMonacoWorker();
|
|
643
|
+
configureMonacoWorker(options);
|
|
646
644
|
}
|
|
647
645
|
registerPdlLanguage(options);
|
|
648
646
|
definePdlTheme(options.themeName ?? PDL_THEME_NAME, options.theme ?? defaultPdlTheme());
|
|
649
|
-
await loadOnigasmOnce(options
|
|
647
|
+
await loadOnigasmOnce(resolveOnigasmWasmUrl(options));
|
|
650
648
|
const registry = new Registry({
|
|
651
649
|
getGrammarDefinition: async () => ({
|
|
652
650
|
format: "json",
|
|
@@ -659,11 +657,25 @@ async function setupPdlMonacoOnce(options) {
|
|
|
659
657
|
/* @__PURE__ */ new Map([[options.languageId ?? PDL_LANGUAGE_ID, options.scopeName ?? PDL_SCOPE_NAME]])
|
|
660
658
|
);
|
|
661
659
|
}
|
|
662
|
-
function configureMonacoWorker() {
|
|
660
|
+
function configureMonacoWorker(options) {
|
|
663
661
|
const target = globalThis;
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
}
|
|
662
|
+
if (target.MonacoEnvironment?.getWorker) {
|
|
663
|
+
return;
|
|
664
|
+
}
|
|
665
|
+
const createEditorWorker = options.createEditorWorker;
|
|
666
|
+
if (!createEditorWorker) {
|
|
667
|
+
throw new Error("pdl-editor requires setupPdlMonaco({ createEditorWorker }) unless configureWorker is false.");
|
|
668
|
+
}
|
|
669
|
+
target.MonacoEnvironment = {
|
|
670
|
+
...target.MonacoEnvironment,
|
|
671
|
+
getWorker: () => createEditorWorker()
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
function resolveOnigasmWasmUrl(options) {
|
|
675
|
+
if (options.onigasmWasmUrl) {
|
|
676
|
+
return options.onigasmWasmUrl;
|
|
677
|
+
}
|
|
678
|
+
throw new Error("pdl-editor requires setupPdlMonaco({ onigasmWasmUrl }) for TextMate grammar loading.");
|
|
667
679
|
}
|
|
668
680
|
function loadOnigasmOnce(url) {
|
|
669
681
|
onigasmPromise ?? (onigasmPromise = loadOnigasm(url).catch((error) => {
|