@webiny/app-sdk-playground 6.3.0 → 6.4.0-beta.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/PermissionsSchema.js +22 -14
- package/PermissionsSchema.js.map +1 -1
- package/SecurityPermission.js +11 -14
- package/SecurityPermission.js.map +1 -1
- package/index.js +42 -41
- package/index.js.map +1 -1
- package/package.json +8 -8
- package/plugins/Playground.js +31 -43
- package/plugins/Playground.js.map +1 -1
- package/plugins/components/CodeEditor.js +48 -59
- package/plugins/components/CodeEditor.js.map +1 -1
- package/plugins/components/OutputLine.js +14 -15
- package/plugins/components/OutputLine.js.map +1 -1
- package/plugins/components/OutputPanel.js +19 -22
- package/plugins/components/OutputPanel.js.map +1 -1
- package/plugins/components/PlaygroundToolbar.js +23 -29
- package/plugins/components/PlaygroundToolbar.js.map +1 -1
- package/plugins/consoleCapture.js +61 -66
- package/plugins/consoleCapture.js.map +1 -1
- package/plugins/declarations/cms.js +2 -2
- package/plugins/declarations/cms.js.map +1 -1
- package/plugins/declarations/common.js +2 -2
- package/plugins/declarations/common.js.map +1 -1
- package/plugins/declarations/fileManager.js +2 -2
- package/plugins/declarations/fileManager.js.map +1 -1
- package/plugins/declarations/languages.js +2 -2
- package/plugins/declarations/languages.js.map +1 -1
- package/plugins/declarations/tasks.js +2 -2
- package/plugins/declarations/tasks.js.map +1 -1
- package/plugins/declarations/tenantManager.js +2 -2
- package/plugins/declarations/tenantManager.js.map +1 -1
- package/plugins/defaultCode.js +2 -2
- package/plugins/defaultCode.js.map +1 -1
- package/plugins/sdkGlobalDeclaration.js +2 -13
- package/plugins/sdkGlobalDeclaration.js.map +1 -1
- package/plugins/types.js +2 -2
- package/plugins/types.js.map +1 -1
- package/plugins/useCodeExecution.js +45 -59
- package/plugins/useCodeExecution.js.map +1 -1
- package/plugins/useMonacoEditor.js +43 -48
- package/plugins/useMonacoEditor.js.map +1 -1
- package/plugins/useResizableSplit.js +35 -38
- package/plugins/useResizableSplit.js.map +1 -1
- package/routes.js +6 -5
- package/routes.js.map +1 -1
|
@@ -1,44 +1,31 @@
|
|
|
1
1
|
import { useSnackbar, useTenantContext } from "@webiny/app-admin";
|
|
2
2
|
import { AuthenticationContextFeature } from "@webiny/app-admin/features/security/AuthenticationContext/feature.js";
|
|
3
3
|
import { useFeature } from "@webiny/app";
|
|
4
|
-
import { config
|
|
4
|
+
import { config } from "@webiny/app/config.js";
|
|
5
5
|
import { Webiny } from "@webiny/sdk";
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
7
|
import { createCustomConsole } from "./consoleCapture.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const messages = [];
|
|
30
|
-
|
|
31
|
-
// Create custom console for capturing output.
|
|
32
|
-
const customConsole = createCustomConsole(messages, setOutput);
|
|
33
|
-
try {
|
|
34
|
-
const sdk = new Webiny({
|
|
35
|
-
endpoint: apiUrl,
|
|
36
|
-
tenant: tenant || undefined,
|
|
37
|
-
token: () => authenticationContext.getIdToken()
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
// Wrap code in async function to allow top-level await.
|
|
41
|
-
const wrappedCode = `
|
|
8
|
+
function useCodeExecution(code, editorRef) {
|
|
9
|
+
const [output, setOutput] = useState([]);
|
|
10
|
+
const [isRunning, setIsRunning] = useState(false);
|
|
11
|
+
const { showSnackbar } = useSnackbar();
|
|
12
|
+
const { tenant } = useTenantContext();
|
|
13
|
+
const { authenticationContext } = useFeature(AuthenticationContextFeature);
|
|
14
|
+
const handleRun = useCallback(async ()=>{
|
|
15
|
+
const apiUrl = config.getKey("API_URL", process.env.REACT_APP_API_URL);
|
|
16
|
+
if (!apiUrl) return void showSnackbar("API URL is not configured");
|
|
17
|
+
const currentCode = editorRef.current?.getValue() || code;
|
|
18
|
+
setIsRunning(true);
|
|
19
|
+
setOutput([]);
|
|
20
|
+
const messages = [];
|
|
21
|
+
const customConsole = createCustomConsole(messages, setOutput);
|
|
22
|
+
try {
|
|
23
|
+
const sdk = new Webiny({
|
|
24
|
+
endpoint: apiUrl,
|
|
25
|
+
tenant: tenant || void 0,
|
|
26
|
+
token: ()=>authenticationContext.getIdToken()
|
|
27
|
+
});
|
|
28
|
+
const wrappedCode = `
|
|
42
29
|
(async () => {
|
|
43
30
|
try {
|
|
44
31
|
${currentCode}
|
|
@@ -48,30 +35,29 @@ export function useCodeExecution(code, editorRef) {
|
|
|
48
35
|
}
|
|
49
36
|
})()
|
|
50
37
|
`;
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
handleRun
|
|
74
|
-
};
|
|
38
|
+
const fn = new Function("console", "sdk", "window", wrappedCode);
|
|
39
|
+
const result = fn(customConsole, sdk, {
|
|
40
|
+
sdk
|
|
41
|
+
});
|
|
42
|
+
if (result && "function" == typeof result.then) await result;
|
|
43
|
+
} catch (error) {
|
|
44
|
+
customConsole.error("Execution error:", error);
|
|
45
|
+
} finally{
|
|
46
|
+
setIsRunning(false);
|
|
47
|
+
}
|
|
48
|
+
}, [
|
|
49
|
+
code,
|
|
50
|
+
editorRef,
|
|
51
|
+
showSnackbar,
|
|
52
|
+
tenant,
|
|
53
|
+
authenticationContext
|
|
54
|
+
]);
|
|
55
|
+
return {
|
|
56
|
+
output,
|
|
57
|
+
isRunning,
|
|
58
|
+
handleRun
|
|
59
|
+
};
|
|
75
60
|
}
|
|
61
|
+
export { useCodeExecution };
|
|
76
62
|
|
|
77
63
|
//# sourceMappingURL=useCodeExecution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/useCodeExecution.js","sources":["../../src/plugins/useCodeExecution.ts"],"sourcesContent":["import { useSnackbar, useTenantContext } from \"@webiny/app-admin\";\nimport { AuthenticationContextFeature } from \"@webiny/app-admin/features/security/AuthenticationContext/feature.js\";\nimport { useFeature } from \"@webiny/app\";\nimport { config as appConfig } from \"@webiny/app/config.js\";\nimport { Webiny } from \"@webiny/sdk\";\nimport type { editor } from \"monaco-editor\";\nimport type { MutableRefObject } from \"react\";\nimport { useCallback, useState } from \"react\";\nimport { createCustomConsole } from \"./consoleCapture.js\";\nimport type { ConsoleMessage } from \"./types.js\";\n\nexport function useCodeExecution(\n code: string,\n editorRef: MutableRefObject<editor.IStandaloneCodeEditor | null>\n) {\n const [output, setOutput] = useState<ConsoleMessage[]>([]);\n const [isRunning, setIsRunning] = useState(false);\n const { showSnackbar } = useSnackbar();\n const { tenant } = useTenantContext();\n const { authenticationContext } = useFeature(AuthenticationContextFeature);\n\n const handleRun = useCallback(async () => {\n const apiUrl = appConfig.getKey(\"API_URL\", process.env.REACT_APP_API_URL) as string;\n if (!apiUrl) {\n showSnackbar(\"API URL is not configured\");\n return;\n }\n\n const currentCode = editorRef.current?.getValue() || code;\n setIsRunning(true);\n setOutput([]);\n\n const messages: ConsoleMessage[] = [];\n\n // Create custom console for capturing output.\n const customConsole = createCustomConsole(messages, setOutput);\n\n try {\n const sdk = new Webiny({\n endpoint: apiUrl,\n tenant: tenant || undefined,\n token: () => authenticationContext.getIdToken() as Promise<string>\n });\n\n // Wrap code in async function to allow top-level await.\n const wrappedCode = `\n (async () => {\n try {\n ${currentCode}\n } catch (error) {\n console.error(\"Runtime error:\", error);\n throw error;\n }\n })()\n `;\n\n // Create function with injected dependencies.\n const fn = new Function(\"console\", \"sdk\", \"window\", wrappedCode);\n\n // Execute with custom console and SDK.\n const result = fn(customConsole, sdk, { sdk });\n\n // Handle async results.\n if (result && typeof result.then === \"function\") {\n await result;\n }\n } catch (error) {\n customConsole.error(\"Execution error:\", error);\n } finally {\n setIsRunning(false);\n }\n }, [code, editorRef, showSnackbar, tenant, authenticationContext]);\n\n return {\n output,\n isRunning,\n handleRun\n };\n}\n"],"names":["useCodeExecution","code","editorRef","output","setOutput","useState","isRunning","setIsRunning","showSnackbar","useSnackbar","tenant","useTenantContext","authenticationContext","useFeature","AuthenticationContextFeature","handleRun","useCallback","apiUrl","appConfig","process","currentCode","messages","customConsole","createCustomConsole","sdk","Webiny","undefined","wrappedCode","fn","Function","result","error"],"mappings":";;;;;;;AAWO,SAASA,iBACZC,IAAY,EACZC,SAAgE;IAEhE,MAAM,CAACC,QAAQC,UAAU,GAAGC,SAA2B,EAAE;IACzD,MAAM,CAACC,WAAWC,aAAa,GAAGF,SAAS;IAC3C,MAAM,EAAEG,YAAY,EAAE,GAAGC;IACzB,MAAM,EAAEC,MAAM,EAAE,GAAGC;IACnB,MAAM,EAAEC,qBAAqB,EAAE,GAAGC,WAAWC;IAE7C,MAAMC,YAAYC,YAAY;QAC1B,MAAMC,SAASC,OAAAA,MAAgB,CAAC,WAAWC,QAAQ,GAAG,CAAC,iBAAiB;QACxE,IAAI,CAACF,QAAQ,YACTT,aAAa;QAIjB,MAAMY,cAAclB,UAAU,OAAO,EAAE,cAAcD;QACrDM,aAAa;QACbH,UAAU,EAAE;QAEZ,MAAMiB,WAA6B,EAAE;QAGrC,MAAMC,gBAAgBC,oBAAoBF,UAAUjB;QAEpD,IAAI;YACA,MAAMoB,MAAM,IAAIC,OAAO;gBACnB,UAAUR;gBACV,QAAQP,UAAUgB;gBAClB,OAAO,IAAMd,sBAAsB,UAAU;YACjD;YAGA,MAAMe,cAAc,CAAC;;;wBAGT,EAAEP,YAAY;;;;;;YAM1B,CAAC;YAGD,MAAMQ,KAAK,IAAIC,SAAS,WAAW,OAAO,UAAUF;YAGpD,MAAMG,SAASF,GAAGN,eAAeE,KAAK;gBAAEA;YAAI;YAG5C,IAAIM,UAAU,AAAuB,cAAvB,OAAOA,OAAO,IAAI,EAC5B,MAAMA;QAEd,EAAE,OAAOC,OAAO;YACZT,cAAc,KAAK,CAAC,oBAAoBS;QAC5C,SAAU;YACNxB,aAAa;QACjB;IACJ,GAAG;QAACN;QAAMC;QAAWM;QAAcE;QAAQE;KAAsB;IAEjE,OAAO;QACHT;QACAG;QACAS;IACJ;AACJ"}
|
|
@@ -1,54 +1,49 @@
|
|
|
1
1
|
import { useCallback, useRef } from "react";
|
|
2
2
|
import { SDK_GLOBAL_DECLARATION } from "./sdkGlobalDeclaration.js";
|
|
3
3
|
import { defaultSdkCode } from "./defaultCode.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
editorRef,
|
|
48
|
-
handleBeforeMount,
|
|
49
|
-
handleEditorDidMount,
|
|
50
|
-
handleFormat
|
|
51
|
-
};
|
|
4
|
+
function useMonacoEditor(handleRun) {
|
|
5
|
+
const editorRef = useRef(null);
|
|
6
|
+
const handleBeforeMount = useCallback((monaco)=>{
|
|
7
|
+
monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
|
|
8
|
+
target: monaco.languages.typescript.ScriptTarget.ES2020,
|
|
9
|
+
allowNonTsExtensions: true,
|
|
10
|
+
moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,
|
|
11
|
+
module: monaco.languages.typescript.ModuleKind.CommonJS,
|
|
12
|
+
noEmit: true,
|
|
13
|
+
esModuleInterop: true,
|
|
14
|
+
allowJs: true
|
|
15
|
+
});
|
|
16
|
+
monaco.languages.typescript.typescriptDefaults.addExtraLib(SDK_GLOBAL_DECLARATION, "file:///sdk-globals.d.ts");
|
|
17
|
+
}, []);
|
|
18
|
+
const handleEditorDidMount = useCallback((ed, monaco)=>{
|
|
19
|
+
editorRef.current = ed;
|
|
20
|
+
const existingModel = ed.getModel();
|
|
21
|
+
const newModel = monaco.editor.createModel(existingModel?.getValue() ?? defaultSdkCode, "typescript", monaco.Uri.parse("file:///user-script.ts"));
|
|
22
|
+
ed.setModel(newModel);
|
|
23
|
+
existingModel?.dispose();
|
|
24
|
+
ed.addAction({
|
|
25
|
+
id: "run-code",
|
|
26
|
+
label: "Run Code",
|
|
27
|
+
keybindings: [
|
|
28
|
+
monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter
|
|
29
|
+
],
|
|
30
|
+
run: ()=>{
|
|
31
|
+
handleRun();
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}, [
|
|
35
|
+
handleRun
|
|
36
|
+
]);
|
|
37
|
+
const handleFormat = useCallback(()=>{
|
|
38
|
+
editorRef.current?.getAction("editor.action.formatDocument")?.run();
|
|
39
|
+
}, []);
|
|
40
|
+
return {
|
|
41
|
+
editorRef,
|
|
42
|
+
handleBeforeMount,
|
|
43
|
+
handleEditorDidMount,
|
|
44
|
+
handleFormat
|
|
45
|
+
};
|
|
52
46
|
}
|
|
47
|
+
export { useMonacoEditor };
|
|
53
48
|
|
|
54
49
|
//# sourceMappingURL=useMonacoEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/useMonacoEditor.js","sources":["../../src/plugins/useMonacoEditor.ts"],"sourcesContent":["import { useCallback, useRef } from \"react\";\nimport type { OnMount, BeforeMount } from \"@monaco-editor/react\";\nimport type { editor } from \"monaco-editor\";\nimport { SDK_GLOBAL_DECLARATION } from \"./sdkGlobalDeclaration.js\";\nimport { defaultSdkCode } from \"./defaultCode.js\";\n\nexport function useMonacoEditor(handleRun: () => void) {\n const editorRef = useRef<editor.IStandaloneCodeEditor | null>(null);\n\n // Configure Monaco editor with SDK types.\n const handleBeforeMount: BeforeMount = useCallback(monaco => {\n monaco.languages.typescript.typescriptDefaults.setCompilerOptions({\n target: monaco.languages.typescript.ScriptTarget.ES2020,\n allowNonTsExtensions: true,\n moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs,\n module: monaco.languages.typescript.ModuleKind.CommonJS,\n noEmit: true,\n esModuleInterop: true,\n allowJs: true\n });\n\n // Single addExtraLib call with a pure script-mode string (no import/export).\n // This makes TypeScript treat the file as an ambient script, so all\n // declare statements become true globals visible to user code.\n monaco.languages.typescript.typescriptDefaults.addExtraLib(\n SDK_GLOBAL_DECLARATION,\n \"file:///sdk-globals.d.ts\"\n );\n }, []);\n\n const handleEditorDidMount: OnMount = useCallback(\n (ed, monaco) => {\n editorRef.current = ed;\n\n // Re-create the model with a file:/// URI so it lives in the same\n // virtual FS namespace as the addExtraLib file, giving the TS\n // language service full visibility into the ambient declarations.\n const existingModel = ed.getModel();\n const newModel = monaco.editor.createModel(\n existingModel?.getValue() ?? defaultSdkCode,\n \"typescript\",\n monaco.Uri.parse(\"file:///user-script.ts\")\n );\n ed.setModel(newModel);\n existingModel?.dispose();\n\n ed.addAction({\n id: \"run-code\",\n label: \"Run Code\",\n keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter],\n run: () => {\n void handleRun();\n }\n });\n },\n [handleRun]\n );\n\n const handleFormat = useCallback(() => {\n editorRef.current?.getAction(\"editor.action.formatDocument\")?.run();\n }, []);\n\n return {\n editorRef,\n handleBeforeMount,\n handleEditorDidMount,\n handleFormat\n };\n}\n"],"names":["useMonacoEditor","handleRun","editorRef","useRef","handleBeforeMount","useCallback","monaco","SDK_GLOBAL_DECLARATION","handleEditorDidMount","ed","existingModel","newModel","defaultSdkCode","handleFormat"],"mappings":";;;AAMO,SAASA,gBAAgBC,SAAqB;IACjD,MAAMC,YAAYC,OAA4C;IAG9D,MAAMC,oBAAiCC,YAAYC,CAAAA;QAC/CA,OAAO,SAAS,CAAC,UAAU,CAAC,kBAAkB,CAAC,kBAAkB,CAAC;YAC9D,QAAQA,OAAO,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM;YACvD,sBAAsB;YACtB,kBAAkBA,OAAO,SAAS,CAAC,UAAU,CAAC,oBAAoB,CAAC,MAAM;YACzE,QAAQA,OAAO,SAAS,CAAC,UAAU,CAAC,UAAU,CAAC,QAAQ;YACvD,QAAQ;YACR,iBAAiB;YACjB,SAAS;QACb;QAKAA,OAAO,SAAS,CAAC,UAAU,CAAC,kBAAkB,CAAC,WAAW,CACtDC,wBACA;IAER,GAAG,EAAE;IAEL,MAAMC,uBAAgCH,YAClC,CAACI,IAAIH;QACDJ,UAAU,OAAO,GAAGO;QAKpB,MAAMC,gBAAgBD,GAAG,QAAQ;QACjC,MAAME,WAAWL,OAAO,MAAM,CAAC,WAAW,CACtCI,eAAe,cAAcE,gBAC7B,cACAN,OAAO,GAAG,CAAC,KAAK,CAAC;QAErBG,GAAG,QAAQ,CAACE;QACZD,eAAe;QAEfD,GAAG,SAAS,CAAC;YACT,IAAI;YACJ,OAAO;YACP,aAAa;gBAACH,OAAO,MAAM,CAAC,OAAO,GAAGA,OAAO,OAAO,CAAC,KAAK;aAAC;YAC3D,KAAK;gBACIL;YACT;QACJ;IACJ,GACA;QAACA;KAAU;IAGf,MAAMY,eAAeR,YAAY;QAC7BH,UAAU,OAAO,EAAE,UAAU,iCAAiC;IAClE,GAAG,EAAE;IAEL,OAAO;QACHA;QACAE;QACAI;QACAK;IACJ;AACJ"}
|
|
@@ -1,44 +1,41 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
2
|
import { MIN_PANE_PCT } from "./types.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
3
|
+
function useResizableSplit() {
|
|
4
|
+
const splitRef = useRef(null);
|
|
5
|
+
const [editorPct, setEditorPct] = useState(60);
|
|
6
|
+
const isDragging = useRef(false);
|
|
7
|
+
const handleDividerMouseDown = useCallback((e)=>{
|
|
8
|
+
e.preventDefault();
|
|
9
|
+
isDragging.current = true;
|
|
10
|
+
document.body.style.cursor = "col-resize";
|
|
11
|
+
document.body.style.userSelect = "none";
|
|
12
|
+
}, []);
|
|
13
|
+
useEffect(()=>{
|
|
14
|
+
const onMouseMove = (e)=>{
|
|
15
|
+
if (!isDragging.current || !splitRef.current) return;
|
|
16
|
+
const rect = splitRef.current.getBoundingClientRect();
|
|
17
|
+
const pct = (e.clientX - rect.left) / rect.width * 100;
|
|
18
|
+
setEditorPct(Math.min(100 - MIN_PANE_PCT, Math.max(MIN_PANE_PCT, pct)));
|
|
19
|
+
};
|
|
20
|
+
const onMouseUp = ()=>{
|
|
21
|
+
if (!isDragging.current) return;
|
|
22
|
+
isDragging.current = false;
|
|
23
|
+
document.body.style.cursor = "";
|
|
24
|
+
document.body.style.userSelect = "";
|
|
25
|
+
};
|
|
26
|
+
document.addEventListener("mousemove", onMouseMove);
|
|
27
|
+
document.addEventListener("mouseup", onMouseUp);
|
|
28
|
+
return ()=>{
|
|
29
|
+
document.removeEventListener("mousemove", onMouseMove);
|
|
30
|
+
document.removeEventListener("mouseup", onMouseUp);
|
|
31
|
+
};
|
|
32
|
+
}, []);
|
|
33
|
+
return {
|
|
34
|
+
splitRef,
|
|
35
|
+
editorPct,
|
|
36
|
+
handleDividerMouseDown
|
|
21
37
|
};
|
|
22
|
-
const onMouseUp = () => {
|
|
23
|
-
if (!isDragging.current) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
isDragging.current = false;
|
|
27
|
-
document.body.style.cursor = "";
|
|
28
|
-
document.body.style.userSelect = "";
|
|
29
|
-
};
|
|
30
|
-
document.addEventListener("mousemove", onMouseMove);
|
|
31
|
-
document.addEventListener("mouseup", onMouseUp);
|
|
32
|
-
return () => {
|
|
33
|
-
document.removeEventListener("mousemove", onMouseMove);
|
|
34
|
-
document.removeEventListener("mouseup", onMouseUp);
|
|
35
|
-
};
|
|
36
|
-
}, []);
|
|
37
|
-
return {
|
|
38
|
-
splitRef,
|
|
39
|
-
editorPct,
|
|
40
|
-
handleDividerMouseDown
|
|
41
|
-
};
|
|
42
38
|
}
|
|
39
|
+
export { useResizableSplit };
|
|
43
40
|
|
|
44
41
|
//# sourceMappingURL=useResizableSplit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"plugins/useResizableSplit.js","sources":["../../src/plugins/useResizableSplit.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from \"react\";\nimport { MIN_PANE_PCT } from \"./types.js\";\n\nexport function useResizableSplit() {\n const splitRef = useRef<HTMLDivElement | null>(null);\n const [editorPct, setEditorPct] = useState(60);\n const isDragging = useRef(false);\n\n const handleDividerMouseDown = useCallback((e: React.MouseEvent) => {\n e.preventDefault();\n isDragging.current = true;\n document.body.style.cursor = \"col-resize\";\n document.body.style.userSelect = \"none\";\n }, []);\n\n useEffect(() => {\n const onMouseMove = (e: MouseEvent) => {\n if (!isDragging.current || !splitRef.current) {\n return;\n }\n const rect = splitRef.current.getBoundingClientRect();\n const pct = ((e.clientX - rect.left) / rect.width) * 100;\n setEditorPct(Math.min(100 - MIN_PANE_PCT, Math.max(MIN_PANE_PCT, pct)));\n };\n\n const onMouseUp = () => {\n if (!isDragging.current) {\n return;\n }\n isDragging.current = false;\n document.body.style.cursor = \"\";\n document.body.style.userSelect = \"\";\n };\n\n document.addEventListener(\"mousemove\", onMouseMove);\n document.addEventListener(\"mouseup\", onMouseUp);\n return () => {\n document.removeEventListener(\"mousemove\", onMouseMove);\n document.removeEventListener(\"mouseup\", onMouseUp);\n };\n }, []);\n\n return {\n splitRef,\n editorPct,\n handleDividerMouseDown\n };\n}\n"],"names":["useResizableSplit","splitRef","useRef","editorPct","setEditorPct","useState","isDragging","handleDividerMouseDown","useCallback","e","document","useEffect","onMouseMove","rect","pct","Math","MIN_PANE_PCT","onMouseUp"],"mappings":";;AAGO,SAASA;IACZ,MAAMC,WAAWC,OAA8B;IAC/C,MAAM,CAACC,WAAWC,aAAa,GAAGC,SAAS;IAC3C,MAAMC,aAAaJ,OAAO;IAE1B,MAAMK,yBAAyBC,YAAY,CAACC;QACxCA,EAAE,cAAc;QAChBH,WAAW,OAAO,GAAG;QACrBI,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG;QAC7BA,SAAS,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG;IACrC,GAAG,EAAE;IAELC,UAAU;QACN,MAAMC,cAAc,CAACH;YACjB,IAAI,CAACH,WAAW,OAAO,IAAI,CAACL,SAAS,OAAO,EACxC;YAEJ,MAAMY,OAAOZ,SAAS,OAAO,CAAC,qBAAqB;YACnD,MAAMa,MAAQL,AAAAA,CAAAA,EAAE,OAAO,GAAGI,KAAK,IAAG,IAAKA,KAAK,KAAK,GAAI;YACrDT,aAAaW,KAAK,GAAG,CAAC,MAAMC,cAAcD,KAAK,GAAG,CAACC,cAAcF;QACrE;QAEA,MAAMG,YAAY;YACd,IAAI,CAACX,WAAW,OAAO,EACnB;YAEJA,WAAW,OAAO,GAAG;YACrBI,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG;YAC7BA,SAAS,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG;QACrC;QAEAA,SAAS,gBAAgB,CAAC,aAAaE;QACvCF,SAAS,gBAAgB,CAAC,WAAWO;QACrC,OAAO;YACHP,SAAS,mBAAmB,CAAC,aAAaE;YAC1CF,SAAS,mBAAmB,CAAC,WAAWO;QAC5C;IACJ,GAAG,EAAE;IAEL,OAAO;QACHhB;QACAE;QACAI;IACJ;AACJ"}
|
package/routes.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Route } from "@webiny/app-admin";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const Routes = {
|
|
3
|
+
SdkPlayground: new Route({
|
|
4
|
+
name: "SdkPlayground",
|
|
5
|
+
path: "/sdk-playground"
|
|
6
|
+
})
|
|
7
7
|
};
|
|
8
|
+
export { Routes };
|
|
8
9
|
|
|
9
10
|
//# sourceMappingURL=routes.js.map
|
package/routes.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"routes.js","sources":["../src/routes.ts"],"sourcesContent":["import { Route } from \"@webiny/app-admin\";\n\nexport const Routes = {\n SdkPlayground: new Route({\n name: \"SdkPlayground\",\n path: \"/sdk-playground\"\n })\n};\n"],"names":["Routes","Route"],"mappings":";AAEO,MAAMA,SAAS;IAClB,eAAe,IAAIC,MAAM;QACrB,MAAM;QACN,MAAM;IACV;AACJ"}
|