@etrepum/lexical-builder-devtools-core 0.0.17

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 ADDED
@@ -0,0 +1,3 @@
1
+ # `@etrepum/lexical-devtools-core`
2
+
3
+ **EXPERIMENTAL** Lexical Builder devtools
@@ -0,0 +1,12 @@
1
+ import { AnyLexicalPlan } from '@etrepum/lexical-builder';
2
+ import { LexicalEditor } from 'lexical';
3
+ import { ComponentProps } from 'react';
4
+
5
+ export interface BuilderGraphComponentProps {
6
+ editor: LexicalEditor;
7
+ className?: string;
8
+ }
9
+ export declare function displayName(plan: AnyLexicalPlan): string;
10
+ export declare function BuilderGraphComponent({ editor, ...rest }: BuilderGraphComponentProps & ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
11
+ export default BuilderGraphComponent;
12
+ //# sourceMappingURL=BuilderGraphComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuilderGraphComponent.d.ts","sourceRoot":"","sources":["../src/BuilderGraphComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,cAAc,EAAiB,MAAM,OAAO,CAAC;AAMtD,MAAM,WAAW,0BAA0B;IACzC,MAAM,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,cAAc,UAS/C;AAED,wBAAgB,qBAAqB,CAAC,EACpC,MAAM,EACN,GAAG,IAAI,EACR,EAAE,0BAA0B,GAAG,cAAc,CAAC,KAAK,CAAC,2CAmBpD;AAED,eAAe,qBAAqB,CAAC"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const BuilderGraphComponent: import('react').LazyExoticComponent<typeof import('./BuilderGraphComponent').BuilderGraphComponent>;
3
+ export declare const BuilderGraphPlan: import('@etrepum/lexical-builder').LexicalPlan<{}, "@etrepum/lexical-builder-devtools-core/BuilderGraphPlan", {
4
+ Component: () => import("react/jsx-runtime").JSX.Element;
5
+ }>;
6
+ //# sourceMappingURL=BuilderGraphPlan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BuilderGraphPlan.d.ts","sourceRoot":"","sources":["../src/BuilderGraphPlan.tsx"],"names":[],"mappings":";AASA,eAAO,MAAM,qBAAqB,qGAEjC,CAAC;AAEF,eAAO,MAAM,gBAAgB;;EAkB3B,CAAC"}
@@ -0,0 +1,44 @@
1
+ import { jsx as m } from "react/jsx-runtime";
2
+ import d from "mermaid";
3
+ import { useState as a, useEffect as l, useRef as c } from "react";
4
+ let f = 0;
5
+ function p() {
6
+ return `mermaid-tmp-${++f}`;
7
+ }
8
+ function v(t, n) {
9
+ const [u, e] = a();
10
+ return l(() => {
11
+ const r = p();
12
+ let s = !1;
13
+ return d.mermaidAPI.initialize({
14
+ startOnLoad: !1,
15
+ ...n
16
+ }), d.render(r, t).then(
17
+ (i) => s ? null : e(i),
18
+ (i) => {
19
+ var o;
20
+ throw (o = document.querySelector(`#d${r}`)) == null || o.remove(), i;
21
+ }
22
+ ), () => {
23
+ s = !0;
24
+ };
25
+ }, [t, n]), u;
26
+ }
27
+ function g({ text: t, config: n, ...u }) {
28
+ const e = v(t, n), r = c(null);
29
+ return l(() => {
30
+ e && e.bindFunctions && r.current && e.bindFunctions(r.current);
31
+ }, [e]), e && e.svg ? /* @__PURE__ */ m(
32
+ "div",
33
+ {
34
+ ...u,
35
+ ref: r,
36
+ dangerouslySetInnerHTML: { __html: e.svg }
37
+ }
38
+ ) : null;
39
+ }
40
+ export {
41
+ g as Mermaid,
42
+ g as default,
43
+ v as useMermaidRenderResult
44
+ };
@@ -0,0 +1,11 @@
1
+ import { MermaidConfig, RenderResult } from 'mermaid';
2
+ import { ComponentProps } from 'react';
3
+
4
+ export interface MermaidProps extends ComponentProps<"div"> {
5
+ text: string;
6
+ config?: MermaidConfig;
7
+ }
8
+ export declare function useMermaidRenderResult(text: string, config?: MermaidConfig): RenderResult | undefined;
9
+ export declare function Mermaid({ text, config, ...props }: MermaidProps): import("react/jsx-runtime").JSX.Element | null;
10
+ export default Mermaid;
11
+ //# sourceMappingURL=Mermaid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Mermaid.d.ts","sourceRoot":"","sources":["../src/Mermaid.tsx"],"names":[],"mappings":"AAAA,OAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,cAAc,EAA+B,MAAM,OAAO,CAAC;AAEpE,MAAM,WAAW,YAAa,SAAQ,cAAc,CAAC,KAAK,CAAC;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAMD,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,aAAa,GACrB,YAAY,GAAG,SAAS,CAsB1B;AAED,wBAAgB,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,EAAE,YAAY,kDAe/D;AAED,eAAe,OAAO,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { LexicalEditor } from 'lexical';
2
+
3
+ export declare function buildGraph(editor: LexicalEditor): string;
4
+ //# sourceMappingURL=buildGraph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"buildGraph.d.ts","sourceRoot":"","sources":["../src/buildGraph.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAIxC,wBAAgB,UAAU,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,CAkCxD"}
@@ -0,0 +1,2 @@
1
+ export declare function getMermaidLiveUrl(code: string): string;
2
+ //# sourceMappingURL=getMermaidLiveUrl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getMermaidLiveUrl.d.ts","sourceRoot":"","sources":["../src/getMermaidLiveUrl.tsx"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CActD"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export declare const PACKAGE_VERSION: string;
9
+ export { BuilderGraphComponent, type BuilderGraphComponentProps, } from './BuilderGraphComponent';
10
+ export { buildGraph } from './buildGraph';
11
+ export { BuilderGraphPlan } from './BuilderGraphPlan';
12
+ export { getMermaidLiveUrl } from './getMermaidLiveUrl';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,eAAO,MAAM,eAAe,EAAE,MAAwC,CAAC;AAEvE,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,106 @@
1
+ import { jsxs as G, jsx as s } from "react/jsx-runtime";
2
+ import { lazy as m, useMemo as v, Suspense as y } from "react";
3
+ import { LexicalBuilder as f, PACKAGE_VERSION as B, definePlan as P, provideOutput as x } from "@etrepum/lexical-builder";
4
+ import { deflate as A } from "pako";
5
+ import { fromUint8Array as E } from "js-base64";
6
+ import { ReactPlan as $ } from "@etrepum/lexical-react-plan";
7
+ function h(r, e, ...t) {
8
+ if (!r)
9
+ throw new Error(
10
+ t.reduce((o, i) => o.replace("%s", String(i)), e || "")
11
+ );
12
+ }
13
+ function b(r) {
14
+ const e = f.fromEditor(r);
15
+ h(
16
+ e !== void 0,
17
+ "buildGraph: editor was not created with this build of Lexical Builder %s",
18
+ B
19
+ );
20
+ const t = ["flowchart TB"];
21
+ function o(n) {
22
+ t.push(n);
23
+ }
24
+ const i = [...e.sortedPlanReps()], l = {};
25
+ for (let n = 0; n < i.length; n++)
26
+ l[i[n].plan.name] = `P${n}`;
27
+ function p(n) {
28
+ return l[n.name];
29
+ }
30
+ for (const n of i) {
31
+ const { plan: a } = n;
32
+ o(`${p(a)}["${g(a)}"]`);
33
+ for (const d of a.dependencies || [])
34
+ o(`${p(a)} --> ${p(Array.isArray(d) ? d[0] : d)}`);
35
+ for (const [d] of a.peerDependencies || []) {
36
+ const c = e.planNameMap.get(d);
37
+ c && o(`${p(a)} -.-> ${p(c.plan)}`);
38
+ }
39
+ }
40
+ return t.join(`
41
+ `) + `
42
+ `;
43
+ }
44
+ function C(r) {
45
+ const e = JSON.stringify({
46
+ code: r,
47
+ mermaid: JSON.stringify({ theme: "dark" }, null, 2),
48
+ autoSync: !0,
49
+ rough: !1,
50
+ updateDiagram: !0,
51
+ updateEditor: !1,
52
+ editorMode: "code"
53
+ });
54
+ return "https://mermaid.live/edit#pako:" + E(A(new TextEncoder().encode(e), { level: 9 }));
55
+ }
56
+ const S = m(() => import("./Mermaid-Dwi2amgd.js"));
57
+ function g(r) {
58
+ const { name: e } = r, t = e.split(/\//g);
59
+ for (; t.length > 1 && /^plan$/i.test(t[t.length - 1] ?? ""); )
60
+ t.pop();
61
+ return (t[t.length - 1] || e).replaceAll("/", "-").replaceAll(/[\\"<>]/g, "");
62
+ }
63
+ function u({
64
+ editor: r,
65
+ ...e
66
+ }) {
67
+ const { text: t, href: o } = v(() => {
68
+ const l = b(r);
69
+ return {
70
+ text: l,
71
+ href: C(l)
72
+ };
73
+ }, [r]), i = e.className ? {} : { style: { display: "grid", gap: "1rem" } };
74
+ return /* @__PURE__ */ G("div", { ...i, ...e, children: [
75
+ /* @__PURE__ */ s("a", { href: o, target: "_blank", children: "mermaid.live" }),
76
+ /* @__PURE__ */ s(S, { text: t })
77
+ ] });
78
+ }
79
+ const N = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
80
+ __proto__: null,
81
+ BuilderGraphComponent: u,
82
+ default: u,
83
+ displayName: g
84
+ }, Symbol.toStringTag, { value: "Module" })), O = m(
85
+ () => Promise.resolve().then(() => N)
86
+ ), L = P({
87
+ name: "@etrepum/lexical-builder-devtools-core/BuilderGraphPlan",
88
+ dependencies: [$],
89
+ config: {},
90
+ register(r) {
91
+ const e = f.fromEditor(r);
92
+ return h(
93
+ e !== void 0,
94
+ "BuilderGraphPlan: Could not get a LexicalBuilder reference"
95
+ ), x({
96
+ Component: () => /* @__PURE__ */ s(y, { children: /* @__PURE__ */ s(O, { editor: r }) })
97
+ });
98
+ }
99
+ }), T = "0.0.17";
100
+ export {
101
+ u as BuilderGraphComponent,
102
+ L as BuilderGraphPlan,
103
+ T as PACKAGE_VERSION,
104
+ b as buildGraph,
105
+ C as getMermaidLiveUrl
106
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ export default function invariant(cond?: boolean, message?: string, ...args: string[]): asserts cond;
9
+ //# sourceMappingURL=invariant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invariant.d.ts","sourceRoot":"","sources":["../../src/shared/invariant.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,IAAI,CAAC,EAAE,OAAO,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,GAAG,IAAI,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAQd"}
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@etrepum/lexical-builder-devtools-core",
3
+ "description": "[EXPERIMENTAL] Lexical Builder Devtools",
4
+ "type": "module",
5
+ "keywords": [
6
+ "lexical",
7
+ "lexical-builder",
8
+ "devtools",
9
+ "plug-in",
10
+ "plan"
11
+ ],
12
+ "scripts": {
13
+ "build": "tsc --noEmit && vite build",
14
+ "dev": "vite",
15
+ "test": "vitest run",
16
+ "test:watch": "vitest"
17
+ },
18
+ "version": "0.0.17",
19
+ "license": "MIT",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/etrepum/lexical-builder.git",
23
+ "directory": "packages/lexical-builder-devtools-core"
24
+ },
25
+ "bugs": {
26
+ "url": "https://github.com/etrepum/lexical-builder/issues"
27
+ },
28
+ "homepage": "https://github.com/etrepum/lexical-builder",
29
+ "dependencies": {
30
+ "@docusaurus/theme-mermaid": "^3.4.0",
31
+ "@etrepum/lexical-builder": "*",
32
+ "@etrepum/lexical-react-plan": "*",
33
+ "js-base64": "^3.7.7",
34
+ "mermaid": "^10.9.1",
35
+ "pako": "^2.1.0"
36
+ },
37
+ "peerDependencies": {
38
+ "@lexical/react": ">=0.16.0-0",
39
+ "@lexical/text": ">=0.16.0-0",
40
+ "@lexical/utils": ">=0.16.0-0",
41
+ "lexical": ">=0.16.0-0",
42
+ "react": ">=18"
43
+ },
44
+ "sideEffects": false,
45
+ "devDependencies": {
46
+ "@testing-library/dom": "^10.1.0",
47
+ "@testing-library/jest-dom": "^6.4.5",
48
+ "@testing-library/react": "^16.0.0",
49
+ "@testing-library/user-event": "^14.5.2",
50
+ "@types/pako": "^2.0.3",
51
+ "jsdom": "^24.1.0",
52
+ "tslib": "^2.6.2",
53
+ "typescript": "^5.4.5",
54
+ "vite": "^5.2.11",
55
+ "vite-plugin-dts": "^3.9.1",
56
+ "vite-plugin-package-version": "^1.1.0",
57
+ "vitest": "^1.6.0"
58
+ },
59
+ "module": "dist/index.js",
60
+ "types": "dist/index.d.ts",
61
+ "files": [
62
+ "dist"
63
+ ]
64
+ }