ruru-components 2.0.0-0.5
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/CHANGELOG.md +8 -0
- package/LICENSE.md +20 -0
- package/README.md +26 -0
- package/dist/components/Copy.d.ts +6 -0
- package/dist/components/Copy.d.ts.map +1 -0
- package/dist/components/Copy.js +23 -0
- package/dist/components/Copy.js.map +1 -0
- package/dist/components/ErrorPopup.d.ts +6 -0
- package/dist/components/ErrorPopup.d.ts.map +1 -0
- package/dist/components/ErrorPopup.js +8 -0
- package/dist/components/ErrorPopup.js.map +1 -0
- package/dist/components/Explain.d.ts +14 -0
- package/dist/components/Explain.d.ts.map +1 -0
- package/dist/components/Explain.js +59 -0
- package/dist/components/Explain.js.map +1 -0
- package/dist/components/Footer.d.ts +3 -0
- package/dist/components/Footer.d.ts.map +1 -0
- package/dist/components/Footer.js +7 -0
- package/dist/components/Footer.js.map +1 -0
- package/dist/components/Mermaid.d.ts +5 -0
- package/dist/components/Mermaid.d.ts.map +1 -0
- package/dist/components/Mermaid.js +21 -0
- package/dist/components/Mermaid.js.map +1 -0
- package/dist/defaultQuery.d.ts +2 -0
- package/dist/defaultQuery.d.ts.map +1 -0
- package/dist/defaultQuery.js +37 -0
- package/dist/defaultQuery.js.map +1 -0
- package/dist/hooks/useExplain.d.ts +19 -0
- package/dist/hooks/useExplain.d.ts.map +1 -0
- package/dist/hooks/useExplain.js +47 -0
- package/dist/hooks/useExplain.js.map +1 -0
- package/dist/hooks/useFetcher.d.ts +28 -0
- package/dist/hooks/useFetcher.d.ts.map +1 -0
- package/dist/hooks/useFetcher.js +179 -0
- package/dist/hooks/useFetcher.js.map +1 -0
- package/dist/hooks/useGraphQLChangeStream.d.ts +5 -0
- package/dist/hooks/useGraphQLChangeStream.d.ts.map +1 -0
- package/dist/hooks/useGraphQLChangeStream.js +55 -0
- package/dist/hooks/useGraphQLChangeStream.js.map +1 -0
- package/dist/hooks/usePrettify.d.ts +12 -0
- package/dist/hooks/usePrettify.d.ts.map +1 -0
- package/dist/hooks/usePrettify.js +33 -0
- package/dist/hooks/usePrettify.js.map +1 -0
- package/dist/hooks/useSchema.d.ts +8 -0
- package/dist/hooks/useSchema.d.ts.map +1 -0
- package/dist/hooks/useSchema.js +74 -0
- package/dist/hooks/useSchema.js.map +1 -0
- package/dist/hooks/useStorage.d.ts +18 -0
- package/dist/hooks/useStorage.d.ts.map +1 -0
- package/dist/hooks/useStorage.js +63 -0
- package/dist/hooks/useStorage.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces.d.ts +27 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/interfaces.js +3 -0
- package/dist/interfaces.js.map +1 -0
- package/dist/plugins/explain.d.ts +3 -0
- package/dist/plugins/explain.d.ts.map +1 -0
- package/dist/plugins/explain.js +18 -0
- package/dist/plugins/explain.js.map +1 -0
- package/dist/ruru.d.ts +13 -0
- package/dist/ruru.d.ts.map +1 -0
- package/dist/ruru.js +72 -0
- package/dist/ruru.js.map +1 -0
- package/package.json +73 -0
- package/ruru.css +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGraphQLChangeStream.d.ts","sourceRoot":"","sources":["../../src/hooks/useGraphQLChangeStream.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,eAAO,MAAM,sBAAsB,UAC1B,SAAS,WACP,MAAM,IAAI,kBACH,MAAM,GAAG,IAAI;;CAyD9B,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useGraphQLChangeStream = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useGraphQLChangeStream = (props, refetch, streamEndpoint) => {
|
|
6
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
7
|
+
const eventSourceRef = (0, react_1.useRef)(null);
|
|
8
|
+
// Starts listening to the event stream at the `sourceUrl`.
|
|
9
|
+
(0, react_1.useEffect)(() => {
|
|
10
|
+
eventSourceRef.current = streamEndpoint
|
|
11
|
+
? new EventSource(streamEndpoint)
|
|
12
|
+
: null;
|
|
13
|
+
const eventSource = eventSourceRef.current;
|
|
14
|
+
return () => {
|
|
15
|
+
if (eventSource) {
|
|
16
|
+
eventSource.close();
|
|
17
|
+
if (eventSourceRef.current !== eventSource) {
|
|
18
|
+
console.error("Logic error in EventSource handling in useGraphQLChangeStream");
|
|
19
|
+
}
|
|
20
|
+
eventSourceRef.current = null;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}, [streamEndpoint]);
|
|
24
|
+
const eventSource = eventSourceRef.current;
|
|
25
|
+
(0, react_1.useEffect)(() => {
|
|
26
|
+
if (eventSource) {
|
|
27
|
+
if (eventSource.readyState === eventSource.CLOSED) {
|
|
28
|
+
throw new Error("Lifecycle management error for EventSource");
|
|
29
|
+
}
|
|
30
|
+
const onOpen = () => {
|
|
31
|
+
console.log("Ruru: Listening for server sent events");
|
|
32
|
+
setError(null);
|
|
33
|
+
refetch();
|
|
34
|
+
};
|
|
35
|
+
const onError = (error) => {
|
|
36
|
+
console.error("Ruru: Failed to connect to event stream", error);
|
|
37
|
+
setError(new Error("Failed to connect to event stream"));
|
|
38
|
+
};
|
|
39
|
+
// When we get a change notification, we want to update our schema.
|
|
40
|
+
eventSource.addEventListener("change", refetch, false);
|
|
41
|
+
// Add event listeners that just log things in the console.
|
|
42
|
+
eventSource.addEventListener("open", onOpen, false);
|
|
43
|
+
eventSource.addEventListener("error", onError, false);
|
|
44
|
+
// Make sure to unsubscribe when we're not needed any more.
|
|
45
|
+
return () => {
|
|
46
|
+
eventSource.removeEventListener("change", refetch, false);
|
|
47
|
+
eventSource.removeEventListener("open", onOpen, false);
|
|
48
|
+
eventSource.removeEventListener("error", onError, false);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}, [error, eventSource, refetch, streamEndpoint]);
|
|
52
|
+
return { error };
|
|
53
|
+
};
|
|
54
|
+
exports.useGraphQLChangeStream = useGraphQLChangeStream;
|
|
55
|
+
//# sourceMappingURL=useGraphQLChangeStream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGraphQLChangeStream.js","sourceRoot":"","sources":["../../src/hooks/useGraphQLChangeStream.ts"],"names":[],"mappings":";;;AAAA,iCAAoD;AAI7C,MAAM,sBAAsB,GAAG,CACpC,KAAgB,EAChB,OAAmB,EACnB,cAA6B,EAC7B,EAAE;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAA,gBAAQ,EAAe,IAAI,CAAC,CAAC;IAEvD,MAAM,cAAc,GAAG,IAAA,cAAM,EAAqB,IAAI,CAAC,CAAC;IAExD,2DAA2D;IAC3D,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,cAAc,CAAC,OAAO,GAAG,cAAc;YACrC,CAAC,CAAC,IAAI,WAAW,CAAC,cAAc,CAAC;YACjC,CAAC,CAAC,IAAI,CAAC;QACT,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC;QAC3C,OAAO,GAAG,EAAE;YACV,IAAI,WAAW,EAAE;gBACf,WAAW,CAAC,KAAK,EAAE,CAAC;gBACpB,IAAI,cAAc,CAAC,OAAO,KAAK,WAAW,EAAE;oBAC1C,OAAO,CAAC,KAAK,CACX,+DAA+D,CAChE,CAAC;iBACH;gBACD,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC;aAC/B;QACH,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC;IAC3C,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,WAAW,EAAE;YACf,IAAI,WAAW,CAAC,UA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interface Window {
|
|
3
|
+
prettier: any;
|
|
4
|
+
prettierPlugins: any;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Prettifies with 'prettier' if available, otherwise using GraphiQL's built in
|
|
9
|
+
* prettify.
|
|
10
|
+
*/
|
|
11
|
+
export declare const usePrettify: () => () => void;
|
|
12
|
+
//# sourceMappingURL=usePrettify.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrettify.d.ts","sourceRoot":"","sources":["../../src/hooks/usePrettify.tsx"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,QAAQ,EAAE,GAAG,CAAC;QACd,eAAe,EAAE,GAAG,CAAC;KACtB;CACF;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,kBAwBvB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePrettify = void 0;
|
|
4
|
+
const react_1 = require("@graphiql/react");
|
|
5
|
+
const react_2 = require("react");
|
|
6
|
+
/**
|
|
7
|
+
* Prettifies with 'prettier' if available, otherwise using GraphiQL's built in
|
|
8
|
+
* prettify.
|
|
9
|
+
*/
|
|
10
|
+
const usePrettify = () => {
|
|
11
|
+
const editorContext = (0, react_1.useEditorContext)();
|
|
12
|
+
const fallbackPrettify = (0, react_1.usePrettifyEditors)();
|
|
13
|
+
return (0, react_2.useCallback)(() => {
|
|
14
|
+
const queryEditor = editorContext?.queryEditor;
|
|
15
|
+
if (!queryEditor) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (queryEditor &&
|
|
19
|
+
typeof window.prettier !== "undefined" &&
|
|
20
|
+
typeof window.prettierPlugins !== "undefined") {
|
|
21
|
+
// TODO: window.prettier.formatWithCursor
|
|
22
|
+
queryEditor.setValue(window.prettier.format(queryEditor.getValue(), {
|
|
23
|
+
parser: "graphql",
|
|
24
|
+
plugins: window.prettierPlugins,
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
fallbackPrettify();
|
|
29
|
+
}
|
|
30
|
+
}, [editorContext?.queryEditor, fallbackPrettify]);
|
|
31
|
+
};
|
|
32
|
+
exports.usePrettify = usePrettify;
|
|
33
|
+
//# sourceMappingURL=usePrettify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrettify.js","sourceRoot":"","sources":["../../src/hooks/usePrettify.tsx"],"names":[],"mappings":";;;AAAA,2CAAuE;AACvE,iCAAoC;AASpC;;;GAGG;AACI,MAAM,WAAW,GAAG,GAAG,EAAE;IAC9B,MAAM,aAAa,GAAG,IAAA,wBAAgB,GAAE,CAAC;IACzC,MAAM,gBAAgB,GAAG,IAAA,0BAAkB,GAAE,CAAC;IAC9C,OAAO,IAAA,mBAAW,EAAC,GAAG,EAAE;QACtB,MAAM,WAAW,GAAG,aAAa,EAAE,WAAW,CAAC;QAC/C,IAAI,CAAC,WAAW,EAAE;YAChB,OAAO;SACR;QACD,IACE,WAAW;YACX,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW;YACtC,OAAO,MAAM,CAAC,eAAe,KAAK,WAAW,EAC7C;YACA,yCAAyC;YACzC,WAAW,CAAC,QAAQ,CAClB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE;gBAC7C,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,MAAM,CAAC,eAAe;aAChC,CAAC,CACH,CAAC;SACH;aAAM;YACL,gBAAgB,EAAE,CAAC;SACpB;IACH,CAAC,EAAE,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC,CAAC;AACrD,CAAC,CAAC;AAxBW,QAAA,WAAW,eAwBtB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { GraphiQLProps } from "graphiql";
|
|
2
|
+
import type { GraphQLSchema } from "graphql";
|
|
3
|
+
import type { Dispatch, SetStateAction } from "react";
|
|
4
|
+
import type { RuruProps } from "../interfaces.js";
|
|
5
|
+
export declare const useSchema: (props: RuruProps, fetcher: GraphiQLProps["fetcher"], setError: Dispatch<SetStateAction<Error | null>>, streamEndpoint: string | null) => {
|
|
6
|
+
schema: GraphQLSchema | null;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=useSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSchema.d.ts","sourceRoot":"","sources":["../../src/hooks/useSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAM7C,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD,eAAO,MAAM,SAAS,UACb,SAAS,WACP,aAAa,CAAC,SAAS,CAAC,YACvB,SAAS,eAAe,KAAK,GAAG,IAAI,CAAC,CAAC,kBAChC,MAAM,GAAG,IAAI;;CAmF9B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSchema = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
// import { updateGraphiQLDocExplorerNavStack } from "../updateGraphiQLDocExplorerNavStack.js";
|
|
7
|
+
const useGraphQLChangeStream_js_1 = require("./useGraphQLChangeStream.js");
|
|
8
|
+
const useSchema = (props, fetcher, setError, streamEndpoint) => {
|
|
9
|
+
const [schema, setSchema] = (0, react_1.useState)(null);
|
|
10
|
+
const refetchStatusRef = (0, react_1.useRef)({
|
|
11
|
+
inProgress: false,
|
|
12
|
+
fetchAgain: null,
|
|
13
|
+
});
|
|
14
|
+
const refetch = (0, react_1.useCallback)(() => {
|
|
15
|
+
if (refetchStatusRef.current.inProgress) {
|
|
16
|
+
refetchStatusRef.current.fetchAgain = refetch;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
refetchStatusRef.current.inProgress = true;
|
|
20
|
+
refetchStatusRef.current.fetchAgain = null;
|
|
21
|
+
(async () => {
|
|
22
|
+
// Fetch the schema using our introspection query and report once that has
|
|
23
|
+
// finished.
|
|
24
|
+
const result = await fetcher({
|
|
25
|
+
query: (0, graphql_1.getIntrospectionQuery)(),
|
|
26
|
+
// TODO: remove this TypeScript hack once https://github.com/graphql/graphiql/pull/2373 is merged/released
|
|
27
|
+
operationName: null,
|
|
28
|
+
});
|
|
29
|
+
let payload;
|
|
30
|
+
if (typeof result.next === "function") {
|
|
31
|
+
// Handle async iterator; we're only expecting a single payload.
|
|
32
|
+
for await (const entry of result) {
|
|
33
|
+
payload = entry;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
payload = result;
|
|
38
|
+
}
|
|
39
|
+
const { data, errors } = payload;
|
|
40
|
+
if (errors) {
|
|
41
|
+
if (errors[0]) {
|
|
42
|
+
throw new graphql_1.GraphQLError(errors[0].message ?? "Error has no message?!", null, null, null, errors[0].path, null, errors[0].extensions);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
throw new Error("'errors' was set on the payload, but was empty or contained null? This is forbidden by the GraphQL spec.");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Use the data we got back from GraphQL to build a client schema (a
|
|
49
|
+
// schema without resolvers).
|
|
50
|
+
const schema = (0, graphql_1.buildClientSchema)(data);
|
|
51
|
+
setSchema(schema);
|
|
52
|
+
setError(null);
|
|
53
|
+
console.log("Ruru: Schema updated");
|
|
54
|
+
})()
|
|
55
|
+
.catch((error) => {
|
|
56
|
+
console.error("Error occurred when updating the schema:");
|
|
57
|
+
console.error(error);
|
|
58
|
+
setError(new Error(`Introspecting the GraphQL schema failed; please check the endpoint and try again.\n${String(error)}`));
|
|
59
|
+
})
|
|
60
|
+
.finally(() => {
|
|
61
|
+
refetchStatusRef.current.inProgress = false;
|
|
62
|
+
if (refetchStatusRef.current.fetchAgain) {
|
|
63
|
+
refetchStatusRef.current.fetchAgain();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}, [fetcher, setError]);
|
|
67
|
+
(0, useGraphQLChangeStream_js_1.useGraphQLChangeStream)(props, refetch, streamEndpoint);
|
|
68
|
+
(0, react_1.useEffect)(() => {
|
|
69
|
+
refetch();
|
|
70
|
+
}, [refetch]);
|
|
71
|
+
return { schema };
|
|
72
|
+
};
|
|
73
|
+
exports.useSchema = useSchema;
|
|
74
|
+
//# sourceMappingURL=useSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSchema.js","sourceRoot":"","sources":["../../src/hooks/useSchema.ts"],"names":[],"mappings":";;;AAEA,qCAIiB;AAEjB,iCAAiE;AAGjE,+FAA+F;AAC/F,2EAAqE;AAE9D,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,OAAiC,EACjC,QAAgD,EAChD,cAA6B,EAC7B,EAAE;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAuB,IAAI,CAAC,CAAC;IACjE,MAAM,gBAAgB,GAAG,IAAA,cAAM,EAAC;QAC9B,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,IAA6B;KAC1C,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC/B,IAAI,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE;YACvC,gBAAgB,CAAC,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC;YAC9C,OAAO;SACR;QACD,gBAAgB,CAAC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC;QA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A0C,CAAC,CAAC;YAC1D,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,QAAQ,CACN,IAAI,KAAK,CACP,sFAAsF,MAAM,CAC1F,KAAK,CACN,EAAE,CACJ,CACF,CAAC;QACJ,CAAC,CAAC;aACD,OAAO,CAAC,GAAG,EAAE;YACZ,gBAAgB,CAAC,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;YAC5C,IAAI,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE;gBACvC,gBAAgB,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;aACvC;QACH,CAAC,CAAC,CAAC;IACP,CAAC,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IACxB,IAAA,kDAAsB,EAAC,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IAEvD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,OAAO,EAAE,CAAC;IACZ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,EAAE,MAAM,EAAE,CAAC;AACpB,CAAC,CAAC;AAvFW,QAAA,SAAS,aAuFpB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface StoredKeys {
|
|
2
|
+
saveHeaders: "true" | "";
|
|
3
|
+
headers: string;
|
|
4
|
+
explain: "true" | "";
|
|
5
|
+
explorerIsOpen: "true" | "";
|
|
6
|
+
explainIsOpen: "true" | "";
|
|
7
|
+
explainAtBottom: "true" | "";
|
|
8
|
+
explainSize: string;
|
|
9
|
+
query: string;
|
|
10
|
+
verbose: "true" | "";
|
|
11
|
+
}
|
|
12
|
+
export interface RuruStorage {
|
|
13
|
+
get<TKey extends keyof StoredKeys>(key: TKey): StoredKeys[TKey] | null;
|
|
14
|
+
set<TKey extends keyof StoredKeys>(key: TKey, value: StoredKeys[TKey]): void;
|
|
15
|
+
toggle<TKey extends keyof StoredKeys>(key: TKey): void;
|
|
16
|
+
}
|
|
17
|
+
export declare const useStorage: () => RuruStorage;
|
|
18
|
+
//# sourceMappingURL=useStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStorage.d.ts","sourceRoot":"","sources":["../../src/hooks/useStorage.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IACzB,WAAW,EAAE,MAAM,GAAG,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC;IACrB,cAAc,EAAE,MAAM,GAAG,EAAE,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,EAAE,CAAC;IAC3B,eAAe,EAAE,MAAM,GAAG,EAAE,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,GAAG,EAAE,CAAC;CACtB;AAgBD,MAAM,WAAW,WAAW;IAC1B,GAAG,CAAC,IAAI,SAAS,MAAM,UAAU,EAAE,GAAG,EAAE,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvE,GAAG,CAAC,IAAI,SAAS,MAAM,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAC7E,MAAM,CAAC,IAAI,SAAS,MAAM,UAAU,EAAE,GAAG,EAAE,IAAI,GAAG,IAAI,CAAC;CACxD;AAED,eAAO,MAAM,UAAU,QAAO,WA4C7B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStorage = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const KEYS = {
|
|
6
|
+
saveHeaders: "Ruru:saveHeadersText",
|
|
7
|
+
headers: "Ruru:headersText",
|
|
8
|
+
explain: "Ruru:explain",
|
|
9
|
+
explainSize: "Ruru:explainSize",
|
|
10
|
+
explainIsOpen: "Ruru:explainIsOpen",
|
|
11
|
+
explainAtBottom: "Ruru:explainAtBottom",
|
|
12
|
+
explorerIsOpen: "graphiql:explorerIsOpen",
|
|
13
|
+
query: "graphiql:query",
|
|
14
|
+
verbose: "Ruru:verbose",
|
|
15
|
+
};
|
|
16
|
+
const up = (v) => v + 1;
|
|
17
|
+
const useStorage = () => {
|
|
18
|
+
const storage = typeof window !== "undefined" ? window.localStorage : null;
|
|
19
|
+
// Trigger re-render every time we set
|
|
20
|
+
const [revision, bump] = (0, react_1.useState)(0);
|
|
21
|
+
const [cache] = (0, react_1.useState)(Object.create(null));
|
|
22
|
+
return (0, react_1.useMemo)(() => {
|
|
23
|
+
if (!storage) {
|
|
24
|
+
return {
|
|
25
|
+
_revision: revision,
|
|
26
|
+
get(key) {
|
|
27
|
+
return cache[key] ?? null;
|
|
28
|
+
},
|
|
29
|
+
set(key, value) {
|
|
30
|
+
cache[key] = value;
|
|
31
|
+
},
|
|
32
|
+
toggle(key) {
|
|
33
|
+
cache[key] = cache[key] ? "" : "true";
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
_revision: revision,
|
|
39
|
+
get(key) {
|
|
40
|
+
const val = storage.getItem(KEYS[key]);
|
|
41
|
+
if (val === "null" || val === "undefined") {
|
|
42
|
+
storage.removeItem(KEYS[key]);
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
return val ?? null;
|
|
46
|
+
},
|
|
47
|
+
set(key, value) {
|
|
48
|
+
storage.setItem(KEYS[key], value);
|
|
49
|
+
bump(up);
|
|
50
|
+
},
|
|
51
|
+
toggle(key) {
|
|
52
|
+
if (this.get(key)) {
|
|
53
|
+
this.set(key, "");
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
this.set(key, "true");
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
}, [storage, revision, cache]);
|
|
61
|
+
};
|
|
62
|
+
exports.useStorage = useStorage;
|
|
63
|
+
//# sourceMappingURL=useStorage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useStorage.js","sourceRoot":"","sources":["../../src/hooks/useStorage.ts"],"names":[],"mappings":";;;AAAA,iCAA0C;AAc1C,MAAM,IAAI,GAA0C;IAClD,WAAW,EAAE,sBAAsB;IACnC,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,cAAc;IACvB,WAAW,EAAE,kBAAkB;IAC/B,aAAa,EAAE,oBAAoB;IACnC,eAAe,EAAE,sBAAsB;IACvC,cAAc,EAAE,yBAAyB;IACzC,KAAK,EAAE,gBAAgB;IACvB,OAAO,EAAE,cAAc;CACxB,CAAC;AAEF,MAAM,EAAE,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC;AAQzB,MAAM,UAAU,GAAG,GAAgB,EAAE;IAC1C,MAAM,OAAO,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC;IAC3E,sCAAsC;IACtC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IACrC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAA,gBAAQ,EAAsB,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAEnE,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;gBACL,SAAS,EAAE,QAAQ;gBACnB,GAAG,CAAC,GAAG;oBACL,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC;gBAC5B,CAAC;gBACD,GAAG,CAAC,GAAG,EAAE,KAAK;oBACZ,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;gBACrB,CAAC;gBACD,MAAM,CAAC,GA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EAAE,MAAM,WAAW,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Ruru = void 0;
|
|
4
|
+
var ruru_js_1 = require("./ruru.js");
|
|
5
|
+
Object.defineProperty(exports, "Ruru", { enumerable: true, get: function () { return ruru_js_1.Ruru; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":";;;AACA,qCAAiC;AAAxB,+FAAA,IAAI,OAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Fetcher } from "@graphiql/toolkit";
|
|
2
|
+
import type { GraphiQLProps } from "graphiql";
|
|
3
|
+
export { Fetcher };
|
|
4
|
+
export interface RuruProps {
|
|
5
|
+
/**
|
|
6
|
+
* Optionally override the fetcher.
|
|
7
|
+
*/
|
|
8
|
+
fetcher?: Fetcher;
|
|
9
|
+
/**
|
|
10
|
+
* The URL to the GraphQL endpoint. (http:// or https://)
|
|
11
|
+
*/
|
|
12
|
+
endpoint?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The URL to the GraphQL subscriptions endpoint. (ws:// or wss://)
|
|
15
|
+
*/
|
|
16
|
+
subscriptionEndpoint?: string;
|
|
17
|
+
editorTheme?: GraphiQLProps["editorTheme"];
|
|
18
|
+
/**
|
|
19
|
+
* The list of debug tools available to the user.
|
|
20
|
+
*
|
|
21
|
+
* explain - output the SQL executed
|
|
22
|
+
* plan - output the plan executed
|
|
23
|
+
*/
|
|
24
|
+
debugTools?: Array<"explain" | "plan">;
|
|
25
|
+
defaultQuery?: string;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=interfaces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB,MAAM,WAAW,SAAS;IACxB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;OAEG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAE9B,WAAW,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;IAE3C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;IAEvC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.d.ts","sourceRoot":"","sources":["../../src/plugins/explain.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA6BtD,eAAO,MAAM,cAAc,EAAE,cAI5B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EXPLAIN_PLUGIN = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@graphiql/react");
|
|
6
|
+
const react_2 = require("react");
|
|
7
|
+
const Explain_js_1 = require("../components/Explain.js");
|
|
8
|
+
const useExplain_js_1 = require("../hooks/useExplain.js");
|
|
9
|
+
const ExplainPanel = () => {
|
|
10
|
+
const { explainHelpers, explain, explainResults, setExplain } = (0, react_2.useContext)(useExplain_js_1.ExplainContext);
|
|
11
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("div", { className: "graphiql-doc-explorer-header", children: (0, jsx_runtime_1.jsx)("div", { className: "graphiql-doc-explorer-title", children: "Explain" }) }), (0, jsx_runtime_1.jsx)("div", { className: "graphiql-doc-explorer-content", children: (0, jsx_runtime_1.jsx)(Explain_js_1.Explain, { explain: explain, setExplain: setExplain, helpers: explainHelpers, results: explainResults }) })] }));
|
|
12
|
+
};
|
|
13
|
+
exports.EXPLAIN_PLUGIN = {
|
|
14
|
+
title: "Explain",
|
|
15
|
+
icon: react_1.MagnifyingGlassIcon,
|
|
16
|
+
content: ExplainPanel,
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=explain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explain.js","sourceRoot":"","sources":["../../src/plugins/explain.tsx"],"names":[],"mappings":";;;;AACA,2CAAsD;AAEtD,iCAAmC;AAEnC,yDAAmD;AACnD,0DAAwD;AAExD,MAAM,YAAY,GAAO,GAAG,EAAE;IAC5B,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,GAC3D,IAAA,kBAAU,EAAC,8BAAc,CAAC,CAAC;IAE7B,OAAO,CACL,4CACE,gCAAK,SAAS,EAAC,8BAA8B,YAC3C,gCAAK,SAAS,EAAC,6BAA6B,wBAAc,GACtD,EACN,gCAAK,SAAS,EAAC,+BAA+B,YAC5C,uBAAC,oBAAO,IACN,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,cAAc,GACvB,GACE,IACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEW,QAAA,cAAc,GAAmB;IAC5C,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,2BAAmB;IACzB,OAAO,EAAE,YAAY;CACtB,CAAC"}
|
package/dist/ruru.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GraphiQLProps } from "graphiql";
|
|
2
|
+
import type { FC } from "react";
|
|
3
|
+
import type { RuruStorage } from "./hooks/useStorage.js";
|
|
4
|
+
import type { RuruProps } from "./interfaces.js";
|
|
5
|
+
export declare const Ruru: FC<RuruProps>;
|
|
6
|
+
export declare const RuruInner: FC<{
|
|
7
|
+
editorTheme?: string;
|
|
8
|
+
storage: RuruStorage;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
setError: React.Dispatch<React.SetStateAction<Error | null>>;
|
|
11
|
+
onEditQuery: GraphiQLProps["onEditQuery"];
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=ruru.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruru.d.ts","sourceRoot":"","sources":["../src/ruru.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAUhC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOjD,eAAO,MAAM,IAAI,EAAE,EAAE,CAAC,SAAS,CAoD9B,CAAC;AAEF,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,WAAW,CAAC;IACrB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC;IAC7D,WAAW,EAAE,aAAa,CAAC,aAAa,CAAC,CAAC;CAC3C,CAgHA,CAAC"}
|
package/dist/ruru.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RuruInner = exports.Ruru = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const plugin_explorer_1 = require("@graphiql/plugin-explorer");
|
|
6
|
+
const react_1 = require("@graphiql/react");
|
|
7
|
+
const graphiql_1 = require("graphiql");
|
|
8
|
+
const react_2 = require("react");
|
|
9
|
+
const ErrorPopup_js_1 = require("./components/ErrorPopup.js");
|
|
10
|
+
const Footer_js_1 = require("./components/Footer.js");
|
|
11
|
+
const defaultQuery_js_1 = require("./defaultQuery.js");
|
|
12
|
+
const useExplain_js_1 = require("./hooks/useExplain.js");
|
|
13
|
+
const useFetcher_js_1 = require("./hooks/useFetcher.js");
|
|
14
|
+
const usePrettify_js_1 = require("./hooks/usePrettify.js");
|
|
15
|
+
const useSchema_js_1 = require("./hooks/useSchema.js");
|
|
16
|
+
const useStorage_js_1 = require("./hooks/useStorage.js");
|
|
17
|
+
const explain_js_1 = require("./plugins/explain.js");
|
|
18
|
+
const checkCss = { width: "1.5rem", display: "inline-block" };
|
|
19
|
+
const check = (0, jsx_runtime_1.jsx)("span", { style: checkCss, children: "\u2714" });
|
|
20
|
+
const nocheck = (0, jsx_runtime_1.jsx)("span", { style: checkCss });
|
|
21
|
+
const Ruru = (props) => {
|
|
22
|
+
const storage = (0, useStorage_js_1.useStorage)();
|
|
23
|
+
const explain = storage.get("explain") === "true";
|
|
24
|
+
const verbose = storage.get("verbose") === "true";
|
|
25
|
+
const setExplain = (0, react_2.useCallback)((newExplain) => {
|
|
26
|
+
storage.set("explain", newExplain ? "true" : "");
|
|
27
|
+
}, [storage]);
|
|
28
|
+
const { fetcher, explainResults, streamEndpoint } = (0, useFetcher_js_1.useFetcher)(props, {
|
|
29
|
+
explain,
|
|
30
|
+
verbose,
|
|
31
|
+
});
|
|
32
|
+
const [error, setError] = (0, react_2.useState)(null);
|
|
33
|
+
const explainHelpers = (0, useExplain_js_1.useExplain)(storage);
|
|
34
|
+
const { schema } = (0, useSchema_js_1.useSchema)(props, fetcher, setError, streamEndpoint);
|
|
35
|
+
const defaultQuery = props.defaultQuery ?? defaultQuery_js_1.defaultQuery;
|
|
36
|
+
const [query, setQuery] = (0, react_2.useState)(storage.get("query") ?? defaultQuery);
|
|
37
|
+
const explorerPlugin = (0, plugin_explorer_1.useExplorerPlugin)({
|
|
38
|
+
query,
|
|
39
|
+
onEdit: setQuery,
|
|
40
|
+
});
|
|
41
|
+
const plugins = (0, react_2.useMemo)(() => {
|
|
42
|
+
return [explorerPlugin, explain_js_1.EXPLAIN_PLUGIN];
|
|
43
|
+
}, [explorerPlugin]);
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(useExplain_js_1.ExplainContext.Provider, { value: {
|
|
45
|
+
explainHelpers,
|
|
46
|
+
explain,
|
|
47
|
+
setExplain,
|
|
48
|
+
explainResults,
|
|
49
|
+
}, children: (0, jsx_runtime_1.jsx)(react_1.GraphiQLProvider, { fetcher: fetcher, schema: schema, defaultQuery: defaultQuery, query: query, plugins: plugins, children: (0, jsx_runtime_1.jsx)(exports.RuruInner, { storage: storage, editorTheme: props.editorTheme, error: error, setError: setError, onEditQuery: setQuery }) }) }));
|
|
50
|
+
};
|
|
51
|
+
exports.Ruru = Ruru;
|
|
52
|
+
const RuruInner = (props) => {
|
|
53
|
+
const { storage, editorTheme, error, setError, onEditQuery } = props;
|
|
54
|
+
const prettify = (0, usePrettify_js_1.usePrettify)();
|
|
55
|
+
const mergeQuery = (0, react_1.useMergeQuery)();
|
|
56
|
+
const copyQuery = (0, react_1.useCopyQuery)();
|
|
57
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "graphiql-container", style: {
|
|
58
|
+
position: "absolute",
|
|
59
|
+
width: "100%",
|
|
60
|
+
height: "100%",
|
|
61
|
+
display: "flex",
|
|
62
|
+
flexDirection: "column",
|
|
63
|
+
overflow: "hidden",
|
|
64
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
65
|
+
display: "flex",
|
|
66
|
+
flex: "1 1 100%",
|
|
67
|
+
overflow: "hidden",
|
|
68
|
+
position: "relative",
|
|
69
|
+
}, children: (0, jsx_runtime_1.jsxs)(graphiql_1.GraphiQLInterface, { editorTheme: editorTheme ?? "graphiql", onEditQuery: onEditQuery, children: [(0, jsx_runtime_1.jsx)(graphiql_1.GraphiQL.Logo, { children: (0, jsx_runtime_1.jsx)("a", { href: "https://grafast.org/ruru", style: { textDecoration: "none" }, target: "_blank", rel: "noreferrer", children: "Ruru" }) }), (0, jsx_runtime_1.jsxs)(graphiql_1.GraphiQL.Toolbar, { children: [(0, jsx_runtime_1.jsx)(react_1.ToolbarButton, { onClick: prettify, label: "Prettify Query (Shift-Ctrl-P)", children: (0, jsx_runtime_1.jsx)(react_1.PrettifyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), (0, jsx_runtime_1.jsx)(react_1.ToolbarButton, { onSelect: mergeQuery, label: "Merge Query (Shift-Ctrl-M)", children: (0, jsx_runtime_1.jsx)(react_1.MergeIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), (0, jsx_runtime_1.jsx)(react_1.ToolbarButton, { onClick: copyQuery, label: "Copy query (Shift-Ctrl-C)", children: (0, jsx_runtime_1.jsx)(react_1.CopyIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), (0, jsx_runtime_1.jsxs)(react_1.ToolbarMenu, { label: "Options", button: (0, jsx_runtime_1.jsx)(react_1.ToolbarButton, { label: "Options", children: (0, jsx_runtime_1.jsx)(react_1.SettingsIcon, { className: "graphiql-toolbar-icon", "aria-hidden": "true" }) }), children: [(0, jsx_runtime_1.jsx)(react_1.ToolbarMenu.Item, { title: "View the SQL statements that this query invokes", onSelect: () => storage.toggle("explain"), children: (0, jsx_runtime_1.jsxs)("span", { children: [storage.get("explain") === "true" ? check : nocheck, "Explain (if supported)"] }) }), (0, jsx_runtime_1.jsx)(react_1.ToolbarMenu.Item, { title: "Don't hide explain from results", onSelect: () => storage.toggle("verbose"), children: (0, jsx_runtime_1.jsxs)("span", { children: [storage.get("verbose") === "true" ? check : nocheck, "Verbose"] }) }), (0, jsx_runtime_1.jsx)(react_1.ToolbarMenu.Item, { title: "Should we persist the headers to localStorage? Header editor is next to variable editor at the bottom.", onSelect: () => storage.toggle("saveHeaders"), children: (0, jsx_runtime_1.jsxs)("span", { children: [storage.get("saveHeaders") === "true" ? check : nocheck, "Save headers"] }) })] })] }), (0, jsx_runtime_1.jsx)(graphiql_1.GraphiQL.Footer, { children: (0, jsx_runtime_1.jsx)(Footer_js_1.RuruFooter, {}) })] }) }), error ? ((0, jsx_runtime_1.jsx)(ErrorPopup_js_1.ErrorPopup, { error: error, onClose: () => setError(null) })) : null] }));
|
|
70
|
+
};
|
|
71
|
+
exports.RuruInner = RuruInner;
|
|
72
|
+
//# sourceMappingURL=ruru.js.map
|
package/dist/ruru.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ruru.js","sourceRoot":"","sources":["../src/ruru.tsx"],"names":[],"mappings":";;;;AAAA,+DAA8D;AAC9D,2CAUyB;AAEzB,uCAAuD;AAEvD,iCAAuD;AAEvD,8DAAwD;AACxD,sDAAoD;AACpD,uDAAkE;AAClE,yDAAmE;AACnE,yDAAmD;AACnD,2DAAqD;AACrD,uDAAiD;AAEjD,yDAAmD;AAEnD,qDAAsD;AAEtD,MAAM,QAAQ,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;AAC9D,MAAM,KAAK,GAAG,iCAAM,KAAK,EAAE,QAAQ,uBAAU,CAAC;AAC9C,MAAM,OAAO,GAAG,iCAAM,KAAK,EAAE,QAAQ,GAAS,CAAC;AAExC,MAAM,IAAI,GAAkB,CAAC,KAAK,EAAE,EAAE;IAC3C,MAAM,OAAO,GAAG,IAAA,0BAAU,GAAE,CAAC;IAC7B,MAAM,OAAO,GAAG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O,eAE/C,GACU,EACnB,uBAAC,mBAAW,CAAC,IAAI,IACf,KAAK,EAAC,wGAAwG,EAC9G,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,YAE7C,6CACG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,oBAEnD,GACU,IACP,IACG,EACnB,uBAAC,mBAAQ,CAAC,MAAM,cACd,uBAAC,sBAAU,KAAG,GACE,IACA,GAChB,EACL,KAAK,CAAC,CAAC,CAAC,CACP,uBAAC,0BAAU,IAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAI,CAC5D,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC,CAAC;AAtHW,QAAA,SAAS,aAsHpB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ruru-components",
|
|
3
|
+
"version": "2.0.0-0.5",
|
|
4
|
+
"description": "Grafast-flavoured GraphiQL distribution; the underlying React components",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"node": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./ruru.css": {
|
|
14
|
+
"default": "./ruru.css"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"prepack": "tsc -b"
|
|
19
|
+
},
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/graphile/heart.git"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"graphile",
|
|
26
|
+
"graphql",
|
|
27
|
+
"graphiql",
|
|
28
|
+
"graphite",
|
|
29
|
+
"ruru",
|
|
30
|
+
"react",
|
|
31
|
+
"components"
|
|
32
|
+
],
|
|
33
|
+
"author": "Benjie Gillam <code@benjiegillam.com>",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/graphile/heart/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://grafast.org/ruru/",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@graphiql/plugin-explorer": "^0.1.12",
|
|
41
|
+
"@graphiql/react": "^0.15.0",
|
|
42
|
+
"@graphiql/toolkit": "^0.8.0",
|
|
43
|
+
"@types/node": "^16.11.15",
|
|
44
|
+
"graphiql": "^2.2.0",
|
|
45
|
+
"mermaid": "^8.14.0",
|
|
46
|
+
"react": ">=16 <17",
|
|
47
|
+
"react-dom": ">=16 <17",
|
|
48
|
+
"tslib": "^2.4.0"
|
|
49
|
+
},
|
|
50
|
+
"engines": {
|
|
51
|
+
"node": ">=16"
|
|
52
|
+
},
|
|
53
|
+
"peerDependencies": {
|
|
54
|
+
"graphql": "^16.1.0-experimental-stream-defer.6"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist",
|
|
58
|
+
"index.js",
|
|
59
|
+
"ruru.css"
|
|
60
|
+
],
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/codemirror": "^5.60.5",
|
|
63
|
+
"@types/debug": "^4.1.7",
|
|
64
|
+
"@types/jest": "^27.5.1",
|
|
65
|
+
"@types/nodemon": "1.19.1",
|
|
66
|
+
"@types/react": "^18",
|
|
67
|
+
"@types/react-dom": "^18.0.0",
|
|
68
|
+
"graphql": "16.1.0-experimental-stream-defer.6",
|
|
69
|
+
"jest": "^28.1.0",
|
|
70
|
+
"nodemon": "^2.0.15",
|
|
71
|
+
"typescript": "^4.8.1-rc"
|
|
72
|
+
}
|
|
73
|
+
}
|