@graphiql/plugin-collections 1.0.0-beta.0 → 1.0.0-beta.2
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/LICENSE +21 -0
- package/dist/components/collection-item-row.js +212 -282
- package/dist/components/collection-item-row.js.map +1 -1
- package/dist/components/collection-row.js +139 -159
- package/dist/components/collection-row.js.map +1 -1
- package/dist/components/collections-panel.js +408 -496
- package/dist/components/collections-panel.js.map +1 -1
- package/dist/components/conflict-dialog.js +148 -164
- package/dist/components/conflict-dialog.js.map +1 -1
- package/dist/components/export-dialog.js +52 -52
- package/dist/components/export-dialog.js.map +1 -1
- package/dist/components/import-dialog.js +100 -112
- package/dist/components/import-dialog.js.map +1 -1
- package/dist/components/save-dialog.js +116 -124
- package/dist/components/save-dialog.js.map +1 -1
- package/dist/components/session-actions.js +23 -31
- package/dist/components/session-actions.js.map +1 -1
- package/dist/icons/check.js +18 -9
- package/dist/icons/check.js.map +1 -1
- package/dist/icons/collections.js +16 -9
- package/dist/icons/collections.js.map +1 -1
- package/dist/icons/download.js +16 -9
- package/dist/icons/download.js.map +1 -1
- package/dist/icons/upload.js +16 -9
- package/dist/icons/upload.js.map +1 -1
- package/dist/index.js +31 -41
- package/dist/index.js.map +1 -1
- package/dist/operation-method.js +24 -24
- package/dist/operation-method.js.map +1 -1
- package/dist/storage/local-storage.js +32 -37
- package/dist/storage/local-storage.js.map +1 -1
- package/dist/storage/tab-links.js +27 -30
- package/dist/storage/tab-links.js.map +1 -1
- package/dist/store.js +365 -402
- package/dist/store.js.map +1 -1
- package/dist/style.css +6 -27
- package/dist/types.js +9 -8
- package/dist/types.js.map +1 -1
- package/dist/utility/uuid.js +11 -9
- package/dist/utility/uuid.js.map +1 -1
- package/package.json +19 -15
|
@@ -1,34 +1,26 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useGraphiQLActions } from "@graphiql/react";
|
|
4
|
-
import { collectionsStore } from "../store.js";
|
|
5
1
|
import { localStorageAdapter } from "../storage/local-storage.js";
|
|
2
|
+
import { collectionsStore } from "../store.js";
|
|
6
3
|
import { SaveDialog } from "./save-dialog.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return registerSaveHandler(
|
|
26
|
-
(tab) => collectionsStore.getState().actions.requestSave(tab)
|
|
27
|
-
);
|
|
28
|
-
}, [readOnly, registerSaveHandler]);
|
|
29
|
-
return /* @__PURE__ */ jsx(SaveDialog, {});
|
|
30
|
-
};
|
|
31
|
-
export {
|
|
32
|
-
CollectionsSessionActions
|
|
4
|
+
import { useEffect } from "react";
|
|
5
|
+
import { useGraphiQLActions } from "@graphiql/react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/session-actions.tsx
|
|
8
|
+
var CollectionsSessionActions = ({ storage, readOnly = false, allowImportExport = true, allowReplace = true }) => {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
collectionsStore.getState().actions.init(storage ?? localStorageAdapter, {
|
|
11
|
+
readOnly,
|
|
12
|
+
allowImportExport,
|
|
13
|
+
allowReplace
|
|
14
|
+
});
|
|
15
|
+
}, []);
|
|
16
|
+
const { registerSaveHandler } = useGraphiQLActions();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (readOnly) return;
|
|
19
|
+
return registerSaveHandler((tab) => collectionsStore.getState().actions.requestSave(tab));
|
|
20
|
+
}, [readOnly, registerSaveHandler]);
|
|
21
|
+
return /* @__PURE__ */ jsx(SaveDialog, {});
|
|
33
22
|
};
|
|
34
|
-
//#
|
|
23
|
+
//#endregion
|
|
24
|
+
export { CollectionsSessionActions };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=session-actions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-actions.js","sources":["../../src/components/session-actions.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useGraphiQLActions } from '@graphiql/react';\nimport { collectionsStore } from '../store';\nimport { localStorageAdapter } from '../storage/local-storage';\nimport { SaveDialog } from './save-dialog';\nimport type { CollectionsStorage } from '../types';\n\ntype CollectionsSessionActionsProps = {\n storage?: CollectionsStorage;\n readOnly?: boolean;\n allowImportExport?: boolean;\n allowReplace?: boolean;\n};\n\nexport const CollectionsSessionActions = ({\n storage,\n readOnly = false,\n allowImportExport = true,\n allowReplace = true,\n}: CollectionsSessionActionsProps) => {\n useEffect(() => {\n void collectionsStore\n .getState()\n .actions.init(storage ?? localStorageAdapter, {\n readOnly,\n allowImportExport,\n allowReplace,\n });\n // storage/config are intentionally only read on mount\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const { registerSaveHandler } = useGraphiQLActions();\n\n useEffect(() => {\n if (readOnly) {\n return;\n }\n return registerSaveHandler(tab =>\n collectionsStore.getState().actions.requestSave(tab),\n );\n }, [readOnly, registerSaveHandler]);\n\n return <SaveDialog />;\n};\n"],"
|
|
1
|
+
{"version":3,"file":"session-actions.js","names":[],"sources":["../../src/components/session-actions.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { useGraphiQLActions } from '@graphiql/react';\nimport { collectionsStore } from '../store';\nimport { localStorageAdapter } from '../storage/local-storage';\nimport { SaveDialog } from './save-dialog';\nimport type { CollectionsStorage } from '../types';\n\ntype CollectionsSessionActionsProps = {\n storage?: CollectionsStorage;\n readOnly?: boolean;\n allowImportExport?: boolean;\n allowReplace?: boolean;\n};\n\nexport const CollectionsSessionActions = ({\n storage,\n readOnly = false,\n allowImportExport = true,\n allowReplace = true,\n}: CollectionsSessionActionsProps) => {\n useEffect(() => {\n void collectionsStore\n .getState()\n .actions.init(storage ?? localStorageAdapter, {\n readOnly,\n allowImportExport,\n allowReplace,\n });\n // storage/config are intentionally only read on mount\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const { registerSaveHandler } = useGraphiQLActions();\n\n useEffect(() => {\n if (readOnly) {\n return;\n }\n return registerSaveHandler(tab =>\n collectionsStore.getState().actions.requestSave(tab),\n );\n }, [readOnly, registerSaveHandler]);\n\n return <SaveDialog />;\n};\n"],"mappings":";;;;;;;AAcA,IAAa,6BAA6B,EACxC,SACA,WAAW,OACX,oBAAoB,MACpB,eAAe,WACqB;CACpC,gBAAgB;EACd,iBACG,SAAS,CAAC,CACV,QAAQ,KAAK,WAAW,qBAAqB;GAC5C;GACA;GACA;EACF,CAAC;CAGL,GAAG,CAAC,CAAC;CAEL,MAAM,EAAE,wBAAwB,mBAAmB;CAEnD,gBAAgB;EACd,IAAI,UACF;EAEF,OAAO,qBAAoB,QACzB,iBAAiB,SAAS,CAAC,CAAC,QAAQ,YAAY,GAAG,CACrD;CACF,GAAG,CAAC,UAAU,mBAAmB,CAAC;CAElC,OAAO,oBAAC,YAAD,CAAa,CAAA;AACtB"}
|
package/dist/icons/check.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
2
|
+
//#region src/icons/check.svg?react
|
|
3
|
+
var SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ React.createElement("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
fill: "none",
|
|
6
|
+
viewBox: "0 0 16 16",
|
|
7
|
+
"aria-labelledby": titleId,
|
|
8
|
+
...props
|
|
9
|
+
}, title ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement("path", {
|
|
10
|
+
stroke: "currentColor",
|
|
11
|
+
strokeLinecap: "round",
|
|
12
|
+
strokeLinejoin: "round",
|
|
13
|
+
strokeWidth: 1.75,
|
|
14
|
+
d: "m3.5 8.5 3 3 6-7"
|
|
15
|
+
}));
|
|
16
|
+
//#endregion
|
|
17
|
+
export { SvgCheck as default };
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=check.js.map
|
package/dist/icons/check.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check.js","sources":["../../src/icons/check.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgCheck = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", viewBox: \"0 0 16 16\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 1.75, d: \"m3.5 8.5 3 3 6-7\" }));\nexport default SvgCheck;\n"],"
|
|
1
|
+
{"version":3,"file":"check.js","names":[],"sources":["../../src/icons/check.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgCheck = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", viewBox: \"0 0 16 16\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 1.75, d: \"m3.5 8.5 3 3 6-7\" }));\nexport default SvgCheck;\n"],"mappings":";;AACA,IAAM,YAAY,EAChB,OACA,SACA,GAAG,YACiB,sBAAM,cAAc,OAAO;CAAE,OAAO;CAA8B,MAAM;CAAQ,SAAS;CAAa,mBAAmB;CAAS,GAAG;AAAM,GAAG,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAQ,GAAG,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ;CAAE,QAAQ;CAAgB,eAAe;CAAS,gBAAgB;CAAS,aAAa;CAAM,GAAG;AAAmB,CAAC,CAAC"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
//#region src/icons/collections.svg?react
|
|
3
|
+
var SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ React.createElement("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeLinecap: "round",
|
|
8
|
+
strokeLinejoin: "round",
|
|
9
|
+
strokeWidth: 2,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
"aria-labelledby": titleId,
|
|
12
|
+
...props
|
|
13
|
+
}, title ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement("path", { d: "M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z" }));
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SvgCollections as default };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=collections.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collections.js","sources":["../../src/icons/collections.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgCollections = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 2, viewBox: \"0 0 24 24\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { d: \"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z\" }));\nexport default SvgCollections;\n"],"
|
|
1
|
+
{"version":3,"file":"collections.js","names":[],"sources":["../../src/icons/collections.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgCollections = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 2, viewBox: \"0 0 24 24\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { d: \"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z\" }));\nexport default SvgCollections;\n"],"mappings":";;AACA,IAAM,kBAAkB,EACtB,OACA,SACA,GAAG,YACiB,sBAAM,cAAc,OAAO;CAAE,OAAO;CAA8B,MAAM;CAAQ,QAAQ;CAAgB,eAAe;CAAS,gBAAgB;CAAS,aAAa;CAAG,SAAS;CAAa,mBAAmB;CAAS,GAAG;AAAM,GAAG,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAQ,GAAG,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ,EAAE,GAAG,8EAA8E,CAAC,CAAC"}
|
package/dist/icons/download.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
//#region src/icons/download.svg?react
|
|
3
|
+
var SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ React.createElement("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeLinecap: "round",
|
|
8
|
+
strokeLinejoin: "round",
|
|
9
|
+
strokeWidth: 2,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
"aria-labelledby": titleId,
|
|
12
|
+
...props
|
|
13
|
+
}, title ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement("path", { d: "M12 3v11m-5-4 5 4 5-4M4 20h16" }));
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SvgDownload as default };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=download.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.js","sources":["../../src/icons/download.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgDownload = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 2, viewBox: \"0 0 24 24\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { d: \"M12 3v11m-5-4 5 4 5-4M4 20h16\" }));\nexport default SvgDownload;\n"],"
|
|
1
|
+
{"version":3,"file":"download.js","names":[],"sources":["../../src/icons/download.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgDownload = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 2, viewBox: \"0 0 24 24\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { d: \"M12 3v11m-5-4 5 4 5-4M4 20h16\" }));\nexport default SvgDownload;\n"],"mappings":";;AACA,IAAM,eAAe,EACnB,OACA,SACA,GAAG,YACiB,sBAAM,cAAc,OAAO;CAAE,OAAO;CAA8B,MAAM;CAAQ,QAAQ;CAAgB,eAAe;CAAS,gBAAgB;CAAS,aAAa;CAAG,SAAS;CAAa,mBAAmB;CAAS,GAAG;AAAM,GAAG,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAQ,GAAG,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC"}
|
package/dist/icons/upload.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
//#region src/icons/upload.svg?react
|
|
3
|
+
var SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ React.createElement("svg", {
|
|
4
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
5
|
+
fill: "none",
|
|
6
|
+
stroke: "currentColor",
|
|
7
|
+
strokeLinecap: "round",
|
|
8
|
+
strokeLinejoin: "round",
|
|
9
|
+
strokeWidth: 2,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
"aria-labelledby": titleId,
|
|
12
|
+
...props
|
|
13
|
+
}, title ? /* @__PURE__ */ React.createElement("title", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement("path", { d: "M12 21V10m-5 4 5-4 5 4M4 4h16" }));
|
|
14
|
+
//#endregion
|
|
15
|
+
export { SvgUpload as default };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=upload.js.map
|
package/dist/icons/upload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upload.js","sources":["../../src/icons/upload.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgUpload = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 2, viewBox: \"0 0 24 24\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { d: \"M12 21V10m-5 4 5-4 5 4M4 4h16\" }));\nexport default SvgUpload;\n"],"
|
|
1
|
+
{"version":3,"file":"upload.js","names":[],"sources":["../../src/icons/upload.svg?react"],"sourcesContent":["import * as React from \"react\";\nconst SvgUpload = ({\n title,\n titleId,\n ...props\n}) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", fill: \"none\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\", strokeWidth: 2, viewBox: \"0 0 24 24\", \"aria-labelledby\": titleId, ...props }, title ? /* @__PURE__ */ React.createElement(\"title\", { id: titleId }, title) : null, /* @__PURE__ */ React.createElement(\"path\", { d: \"M12 21V10m-5 4 5-4 5 4M4 4h16\" }));\nexport default SvgUpload;\n"],"mappings":";;AACA,IAAM,aAAa,EACjB,OACA,SACA,GAAG,YACiB,sBAAM,cAAc,OAAO;CAAE,OAAO;CAA8B,MAAM;CAAQ,QAAQ;CAAgB,eAAe;CAAS,gBAAgB;CAAS,aAAa;CAAG,SAAS;CAAa,mBAAmB;CAAS,GAAG;AAAM,GAAG,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAQ,GAAG,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createLocalStorageAdapter, localStorageAdapter } from "./storage/local-storage.js";
|
|
2
|
+
import { collectionsStore, useCollectionsStore } from "./store.js";
|
|
2
3
|
import { CollectionsPanel } from "./components/collections-panel.js";
|
|
4
|
+
import { SaveDialog } from "./components/save-dialog.js";
|
|
3
5
|
import { CollectionsSessionActions } from "./components/session-actions.js";
|
|
4
6
|
import SvgCollections from "./icons/collections.js";
|
|
5
7
|
/* empty css */
|
|
6
|
-
import {
|
|
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
|
-
return {
|
|
32
|
-
title: "Collections",
|
|
33
|
-
icon: SvgCollections,
|
|
34
|
-
content: CollectionsPanelWithOptions,
|
|
35
|
-
sessionActions: CollectionsSessionActionsWithOptions
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
export {
|
|
39
|
-
SaveDialog as CollectionsSaveDialog,
|
|
40
|
-
collectionsPlugin,
|
|
41
|
-
collectionsStore,
|
|
42
|
-
createLocalStorageAdapter,
|
|
43
|
-
localStorageAdapter,
|
|
44
|
-
useCollectionsStore
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
//#region src/index.tsx
|
|
10
|
+
var collectionsPlugin = (options) => {
|
|
11
|
+
function CollectionsPanelWithOptions() {
|
|
12
|
+
return /* @__PURE__ */ jsx(CollectionsPanel, {
|
|
13
|
+
readOnly: options?.readOnly,
|
|
14
|
+
allowImportExport: options?.allowImportExport,
|
|
15
|
+
allowReplace: options?.allowReplace
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function CollectionsSessionActionsWithOptions() {
|
|
19
|
+
return /* @__PURE__ */ jsx(CollectionsSessionActions, {
|
|
20
|
+
storage: options?.storage,
|
|
21
|
+
readOnly: options?.readOnly,
|
|
22
|
+
allowImportExport: options?.allowImportExport,
|
|
23
|
+
allowReplace: options?.allowReplace
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
title: "Collections",
|
|
28
|
+
icon: SvgCollections,
|
|
29
|
+
content: CollectionsPanelWithOptions,
|
|
30
|
+
sessionActions: CollectionsSessionActionsWithOptions
|
|
31
|
+
};
|
|
45
32
|
};
|
|
46
|
-
//#
|
|
33
|
+
//#endregion
|
|
34
|
+
export { SaveDialog as CollectionsSaveDialog, collectionsPlugin, collectionsStore, createLocalStorageAdapter, localStorageAdapter, useCollectionsStore };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/index.tsx"],"sourcesContent":["import type { GraphiQLPlugin } from '@graphiql/react';\nimport { CollectionsPanel } from './components/collections-panel';\nimport { CollectionsSessionActions } from './components/session-actions';\nimport CollectionsIcon from './icons/collections.svg?react';\nimport type { CollectionsStorage } from './types';\nimport './index.css';\n\nexport type {\n CollectionsStorage,\n CollectionsConfig,\n Collection,\n CollectionItem,\n} from './types';\nexport {\n collectionsStore,\n useCollectionsStore,\n type ActiveOperation,\n} from './store';\nexport {\n createLocalStorageAdapter,\n localStorageAdapter,\n} from './storage/local-storage';\nexport { SaveDialog as CollectionsSaveDialog } from './components/save-dialog';\n\nexport type CollectionsPluginOptions = {\n /** Custom storage adapter. Defaults to localStorage with key 'graphiql:collections'. */\n storage?: CollectionsStorage;\n /** Disable all write operations (export & copy still allowed). Default false. */\n readOnly?: boolean;\n /** Master switch for the import/export feature. Default true. */\n allowImportExport?: boolean;\n /** Allow the destructive \"Replace\" import option. Default true. */\n allowReplace?: boolean;\n};\n\nexport const collectionsPlugin = (\n options?: CollectionsPluginOptions,\n): GraphiQLPlugin => {\n function CollectionsPanelWithOptions() {\n return (\n <CollectionsPanel\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n function CollectionsSessionActionsWithOptions() {\n return (\n <CollectionsSessionActions\n storage={options?.storage}\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n return {\n title: 'Collections',\n icon: CollectionsIcon,\n content: CollectionsPanelWithOptions,\n sessionActions: CollectionsSessionActionsWithOptions,\n };\n};\n"],"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.tsx"],"sourcesContent":["import type { GraphiQLPlugin } from '@graphiql/react';\nimport { CollectionsPanel } from './components/collections-panel';\nimport { CollectionsSessionActions } from './components/session-actions';\nimport CollectionsIcon from './icons/collections.svg?react';\nimport type { CollectionsStorage } from './types';\nimport './index.css';\n\nexport type {\n CollectionsStorage,\n CollectionsConfig,\n Collection,\n CollectionItem,\n} from './types';\nexport {\n collectionsStore,\n useCollectionsStore,\n type ActiveOperation,\n} from './store';\nexport {\n createLocalStorageAdapter,\n localStorageAdapter,\n} from './storage/local-storage';\nexport { SaveDialog as CollectionsSaveDialog } from './components/save-dialog';\n\nexport type CollectionsPluginOptions = {\n /** Custom storage adapter. Defaults to localStorage with key 'graphiql:collections'. */\n storage?: CollectionsStorage;\n /** Disable all write operations (export & copy still allowed). Default false. */\n readOnly?: boolean;\n /** Master switch for the import/export feature. Default true. */\n allowImportExport?: boolean;\n /** Allow the destructive \"Replace\" import option. Default true. */\n allowReplace?: boolean;\n};\n\nexport const collectionsPlugin = (\n options?: CollectionsPluginOptions,\n): GraphiQLPlugin => {\n function CollectionsPanelWithOptions() {\n return (\n <CollectionsPanel\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n function CollectionsSessionActionsWithOptions() {\n return (\n <CollectionsSessionActions\n storage={options?.storage}\n readOnly={options?.readOnly}\n allowImportExport={options?.allowImportExport}\n allowReplace={options?.allowReplace}\n />\n );\n }\n return {\n title: 'Collections',\n icon: CollectionsIcon,\n content: CollectionsPanelWithOptions,\n sessionActions: CollectionsSessionActionsWithOptions,\n };\n};\n"],"mappings":";;;;;;;;;AAmCA,IAAa,qBACX,YACmB;CACnB,SAAS,8BAA8B;EACrC,OACE,oBAAC,kBAAD;GACE,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,SAAS,uCAAuC;EAC9C,OACE,oBAAC,2BAAD;GACE,SAAS,SAAS;GAClB,UAAU,SAAS;GACnB,mBAAmB,SAAS;GAC5B,cAAc,SAAS;EACxB,CAAA;CAEL;CACA,OAAO;EACL,OAAO;EACP,MAAM;EACN,SAAS;EACT,gBAAgB;CAClB;AACF"}
|
package/dist/operation-method.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Kind, parse } from "graphql";
|
|
2
|
+
//#region src/operation-method.ts
|
|
3
|
+
/** Cheap regex fallback for when a document can't be parsed. */
|
|
2
4
|
function inferOperationType(query) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (keyword === "mutation" || keyword === "subscription") {
|
|
7
|
-
return keyword;
|
|
8
|
-
}
|
|
9
|
-
return "query";
|
|
5
|
+
const keyword = /^\s*(query|mutation|subscription)/i.exec(query)?.[1]?.toLowerCase();
|
|
6
|
+
if (keyword === "mutation" || keyword === "subscription") return keyword;
|
|
7
|
+
return "query";
|
|
10
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* A saved item holds a whole document, which may contain more than one
|
|
11
|
+
* operation. Return the single operation's type, or `'mix'` when there are
|
|
12
|
+
* several so the row shows a neutral pill instead of just the first one's.
|
|
13
|
+
* Anonymous shorthand (`{ ... }`) and unparseable text resolve to `'query'`.
|
|
14
|
+
*/
|
|
11
15
|
function getDocumentMethod(query) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return operation ? operation.operation : "query";
|
|
21
|
-
} catch {
|
|
22
|
-
return inferOperationType(query);
|
|
23
|
-
}
|
|
16
|
+
try {
|
|
17
|
+
const operations = parse(query).definitions.filter((def) => def.kind === Kind.OPERATION_DEFINITION);
|
|
18
|
+
if (operations.length > 1) return "mix";
|
|
19
|
+
const [operation] = operations;
|
|
20
|
+
return operation ? operation.operation : "query";
|
|
21
|
+
} catch {
|
|
22
|
+
return inferOperationType(query);
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
//# sourceMappingURL=operation-method.js.map
|
|
25
|
+
//#endregion
|
|
26
|
+
export { getDocumentMethod };
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=operation-method.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-method.js","sources":["../src/operation-method.ts"],"sourcesContent":["import { Kind, parse } from 'graphql';\nimport type { Operation } from '@graphiql/react';\n\n/** The pill shown for a saved item: a single operation's type, or `'mix'`. */\nexport type DocumentMethod = Operation | 'mix';\n\n/** Cheap regex fallback for when a document can't be parsed. */\nfunction inferOperationType(query: string): Operation {\n const match = /^\\s*(query|mutation|subscription)/i.exec(query);\n const keyword = match?.[1]?.toLowerCase();\n if (keyword === 'mutation' || keyword === 'subscription') {\n return keyword;\n }\n return 'query';\n}\n\n/**\n * A saved item holds a whole document, which may contain more than one\n * operation. Return the single operation's type, or `'mix'` when there are\n * several so the row shows a neutral pill instead of just the first one's.\n * Anonymous shorthand (`{ ... }`) and unparseable text resolve to `'query'`.\n */\nexport function getDocumentMethod(query: string): DocumentMethod {\n try {\n const operations = parse(query).definitions.filter(\n def => def.kind === Kind.OPERATION_DEFINITION,\n );\n if (operations.length > 1) {\n return 'mix';\n }\n const [operation] = operations;\n return operation ? operation.operation : 'query';\n } catch {\n return inferOperationType(query);\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"operation-method.js","names":[],"sources":["../src/operation-method.ts"],"sourcesContent":["import { Kind, parse } from 'graphql';\nimport type { Operation } from '@graphiql/react';\n\n/** The pill shown for a saved item: a single operation's type, or `'mix'`. */\nexport type DocumentMethod = Operation | 'mix';\n\n/** Cheap regex fallback for when a document can't be parsed. */\nfunction inferOperationType(query: string): Operation {\n const match = /^\\s*(query|mutation|subscription)/i.exec(query);\n const keyword = match?.[1]?.toLowerCase();\n if (keyword === 'mutation' || keyword === 'subscription') {\n return keyword;\n }\n return 'query';\n}\n\n/**\n * A saved item holds a whole document, which may contain more than one\n * operation. Return the single operation's type, or `'mix'` when there are\n * several so the row shows a neutral pill instead of just the first one's.\n * Anonymous shorthand (`{ ... }`) and unparseable text resolve to `'query'`.\n */\nexport function getDocumentMethod(query: string): DocumentMethod {\n try {\n const operations = parse(query).definitions.filter(\n def => def.kind === Kind.OPERATION_DEFINITION,\n );\n if (operations.length > 1) {\n return 'mix';\n }\n const [operation] = operations;\n return operation ? operation.operation : 'query';\n } catch {\n return inferOperationType(query);\n }\n}\n"],"mappings":";;;AAOA,SAAS,mBAAmB,OAA0B;CAEpD,MAAM,UADQ,qCAAqC,KAAK,KACxC,CAAA,GAAQ,EAAE,EAAE,YAAY;CACxC,IAAI,YAAY,cAAc,YAAY,gBACxC,OAAO;CAET,OAAO;AACT;;;;;;;AAQA,SAAgB,kBAAkB,OAA+B;CAC/D,IAAI;EACF,MAAM,aAAa,MAAM,KAAK,CAAC,CAAC,YAAY,QAC1C,QAAO,IAAI,SAAS,KAAK,oBAC3B;EACA,IAAI,WAAW,SAAS,GACtB,OAAO;EAET,MAAM,CAAC,aAAa;EACpB,OAAO,YAAY,UAAU,YAAY;CAC3C,QAAQ;EACN,OAAO,mBAAmB,KAAK;CACjC;AACF"}
|
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/storage/local-storage.ts
|
|
2
|
+
var DEFAULT_KEY = "graphiql:collections";
|
|
3
|
+
var VERSION = 1;
|
|
3
4
|
function createLocalStorageAdapter(storageKey = DEFAULT_KEY) {
|
|
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
|
-
} catch {
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
5
|
+
return {
|
|
6
|
+
async load() {
|
|
7
|
+
try {
|
|
8
|
+
const raw = localStorage.getItem(storageKey);
|
|
9
|
+
if (!raw) return [];
|
|
10
|
+
const parsed = JSON.parse(raw);
|
|
11
|
+
if (parsed.version !== VERSION) {
|
|
12
|
+
console.warn(`[graphiql/plugin-collections] Storage version mismatch (found ${parsed.version}, expected ${VERSION}). Attempting to load collections as-is.`);
|
|
13
|
+
return Array.isArray(parsed.collections) ? parsed.collections : [];
|
|
14
|
+
}
|
|
15
|
+
return parsed.collections ?? [];
|
|
16
|
+
} catch {
|
|
17
|
+
return [];
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
async save(collections) {
|
|
21
|
+
try {
|
|
22
|
+
localStorage.setItem(storageKey, JSON.stringify({
|
|
23
|
+
version: VERSION,
|
|
24
|
+
collections
|
|
25
|
+
}));
|
|
26
|
+
} catch {}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
33
29
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
//# sourceMappingURL=local-storage.js.map
|
|
30
|
+
var localStorageAdapter = createLocalStorageAdapter();
|
|
31
|
+
//#endregion
|
|
32
|
+
export { createLocalStorageAdapter, localStorageAdapter };
|
|
33
|
+
|
|
34
|
+
//# sourceMappingURL=local-storage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"local-storage.js","sources":["../../src/storage/local-storage.ts"],"sourcesContent":["import type { Collection, CollectionsStorage } from '../types';\n\nconst DEFAULT_KEY = 'graphiql:collections';\nconst VERSION = 1;\n\ntype StorageEnvelope = {\n version: number;\n collections: Collection[];\n};\n\nexport function createLocalStorageAdapter(\n storageKey = DEFAULT_KEY,\n): CollectionsStorage {\n return {\n async load() {\n try {\n const raw = localStorage.getItem(storageKey);\n if (!raw) {\n return [];\n }\n const parsed: StorageEnvelope = JSON.parse(raw);\n if (parsed.version !== VERSION) {\n // Version mismatch: attempt a best-effort migration.\n // V1 has the same shape — just update the version stamp and return collections.\n // Future migrations go here when VERSION is bumped.\n // eslint-disable-next-line no-console\n console.warn(\n `[graphiql/plugin-collections] Storage version mismatch (found ${parsed.version}, expected ${VERSION}). Attempting to load collections as-is.`,\n );\n return Array.isArray(parsed.collections) ? parsed.collections : [];\n }\n return parsed.collections ?? [];\n } catch {\n return [];\n }\n },\n async save(collections) {\n try {\n localStorage.setItem(\n storageKey,\n JSON.stringify({ version: VERSION, collections }),\n );\n } catch {\n // Storage quota exceeded or unavailable — silent no-op\n }\n },\n };\n}\n\nexport const localStorageAdapter = createLocalStorageAdapter();\n"],"
|
|
1
|
+
{"version":3,"file":"local-storage.js","names":[],"sources":["../../src/storage/local-storage.ts"],"sourcesContent":["import type { Collection, CollectionsStorage } from '../types';\n\nconst DEFAULT_KEY = 'graphiql:collections';\nconst VERSION = 1;\n\ntype StorageEnvelope = {\n version: number;\n collections: Collection[];\n};\n\nexport function createLocalStorageAdapter(\n storageKey = DEFAULT_KEY,\n): CollectionsStorage {\n return {\n async load() {\n try {\n const raw = localStorage.getItem(storageKey);\n if (!raw) {\n return [];\n }\n const parsed: StorageEnvelope = JSON.parse(raw);\n if (parsed.version !== VERSION) {\n // Version mismatch: attempt a best-effort migration.\n // V1 has the same shape — just update the version stamp and return collections.\n // Future migrations go here when VERSION is bumped.\n // eslint-disable-next-line no-console\n console.warn(\n `[graphiql/plugin-collections] Storage version mismatch (found ${parsed.version}, expected ${VERSION}). Attempting to load collections as-is.`,\n );\n return Array.isArray(parsed.collections) ? parsed.collections : [];\n }\n return parsed.collections ?? [];\n } catch {\n return [];\n }\n },\n async save(collections) {\n try {\n localStorage.setItem(\n storageKey,\n JSON.stringify({ version: VERSION, collections }),\n );\n } catch {\n // Storage quota exceeded or unavailable — silent no-op\n }\n },\n };\n}\n\nexport const localStorageAdapter = createLocalStorageAdapter();\n"],"mappings":";AAEA,IAAM,cAAc;AACpB,IAAM,UAAU;AAOhB,SAAgB,0BACd,aAAa,aACO;CACpB,OAAO;EACL,MAAM,OAAO;GACX,IAAI;IACF,MAAM,MAAM,aAAa,QAAQ,UAAU;IAC3C,IAAI,CAAC,KACH,OAAO,CAAC;IAEV,MAAM,SAA0B,KAAK,MAAM,GAAG;IAC9C,IAAI,OAAO,YAAY,SAAS;KAK9B,QAAQ,KACN,iEAAiE,OAAO,QAAQ,aAAa,QAAQ,yCACvG;KACA,OAAO,MAAM,QAAQ,OAAO,WAAW,IAAI,OAAO,cAAc,CAAC;IACnE;IACA,OAAO,OAAO,eAAe,CAAC;GAChC,QAAQ;IACN,OAAO,CAAC;GACV;EACF;EACA,MAAM,KAAK,aAAa;GACtB,IAAI;IACF,aAAa,QACX,YACA,KAAK,UAAU;KAAE,SAAS;KAAS;IAAY,CAAC,CAClD;GACF,QAAQ,CAER;EACF;CACF;AACF;AAEA,IAAa,sBAAsB,0BAA0B"}
|
|
@@ -1,36 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/storage/tab-links.ts
|
|
2
|
+
/**
|
|
3
|
+
* Tab↔item links are browser-local: they key off GraphiQL's own tab ids, which
|
|
4
|
+
* live in localStorage and are stable across reloads. They are deliberately
|
|
5
|
+
* kept out of `CollectionsStorage` — a remote/DB collections backend shared
|
|
6
|
+
* between machines must not receive another client's tab ids.
|
|
7
|
+
*/
|
|
8
|
+
var LINKS_KEY = "graphiql:collections:tab-links";
|
|
2
9
|
function isTabLink(value) {
|
|
3
|
-
|
|
10
|
+
return typeof value === "object" && value !== null && typeof value.collectionId === "string" && typeof value.itemId === "string";
|
|
4
11
|
}
|
|
5
12
|
function loadTabLinks() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (isTabLink(link)) {
|
|
18
|
-
links[tabId] = link;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return links;
|
|
22
|
-
} catch {
|
|
23
|
-
return {};
|
|
24
|
-
}
|
|
13
|
+
try {
|
|
14
|
+
const raw = localStorage.getItem(LINKS_KEY);
|
|
15
|
+
if (!raw) return {};
|
|
16
|
+
const parsed = JSON.parse(raw);
|
|
17
|
+
if (typeof parsed !== "object" || parsed === null) return {};
|
|
18
|
+
const links = {};
|
|
19
|
+
for (const [tabId, link] of Object.entries(parsed)) if (isTabLink(link)) links[tabId] = link;
|
|
20
|
+
return links;
|
|
21
|
+
} catch {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
25
24
|
}
|
|
26
25
|
function saveTabLinks(links) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
26
|
+
try {
|
|
27
|
+
localStorage.setItem(LINKS_KEY, JSON.stringify(links));
|
|
28
|
+
} catch {}
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=tab-links.js.map
|
|
30
|
+
//#endregion
|
|
31
|
+
export { loadTabLinks, saveTabLinks };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=tab-links.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tab-links.js","sources":["../../src/storage/tab-links.ts"],"sourcesContent":["/** A link from an editor tab to the collection item it was opened from or saved as. */\nexport type TabLink = { collectionId: string; itemId: string };\n\n/**\n * Tab↔item links are browser-local: they key off GraphiQL's own tab ids, which\n * live in localStorage and are stable across reloads. They are deliberately\n * kept out of `CollectionsStorage` — a remote/DB collections backend shared\n * between machines must not receive another client's tab ids.\n */\nconst LINKS_KEY = 'graphiql:collections:tab-links';\n\nfunction isTabLink(value: unknown): value is TabLink {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as TabLink).collectionId === 'string' &&\n typeof (value as TabLink).itemId === 'string'\n );\n}\n\nexport function loadTabLinks(): Record<string, TabLink> {\n try {\n const raw = localStorage.getItem(LINKS_KEY);\n if (!raw) {\n return {};\n }\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) {\n return {};\n }\n const links: Record<string, TabLink> = {};\n for (const [tabId, link] of Object.entries(parsed)) {\n if (isTabLink(link)) {\n links[tabId] = link;\n }\n }\n return links;\n } catch {\n return {};\n }\n}\n\nexport function saveTabLinks(links: Record<string, TabLink>): void {\n try {\n localStorage.setItem(LINKS_KEY, JSON.stringify(links));\n } catch {\n // Storage quota exceeded or unavailable — silent no-op.\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"tab-links.js","names":[],"sources":["../../src/storage/tab-links.ts"],"sourcesContent":["/** A link from an editor tab to the collection item it was opened from or saved as. */\nexport type TabLink = { collectionId: string; itemId: string };\n\n/**\n * Tab↔item links are browser-local: they key off GraphiQL's own tab ids, which\n * live in localStorage and are stable across reloads. They are deliberately\n * kept out of `CollectionsStorage` — a remote/DB collections backend shared\n * between machines must not receive another client's tab ids.\n */\nconst LINKS_KEY = 'graphiql:collections:tab-links';\n\nfunction isTabLink(value: unknown): value is TabLink {\n return (\n typeof value === 'object' &&\n value !== null &&\n typeof (value as TabLink).collectionId === 'string' &&\n typeof (value as TabLink).itemId === 'string'\n );\n}\n\nexport function loadTabLinks(): Record<string, TabLink> {\n try {\n const raw = localStorage.getItem(LINKS_KEY);\n if (!raw) {\n return {};\n }\n const parsed: unknown = JSON.parse(raw);\n if (typeof parsed !== 'object' || parsed === null) {\n return {};\n }\n const links: Record<string, TabLink> = {};\n for (const [tabId, link] of Object.entries(parsed)) {\n if (isTabLink(link)) {\n links[tabId] = link;\n }\n }\n return links;\n } catch {\n return {};\n }\n}\n\nexport function saveTabLinks(links: Record<string, TabLink>): void {\n try {\n localStorage.setItem(LINKS_KEY, JSON.stringify(links));\n } catch {\n // Storage quota exceeded or unavailable — silent no-op.\n }\n}\n"],"mappings":";;;;;;;AASA,IAAM,YAAY;AAElB,SAAS,UAAU,OAAkC;CACnD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAkB,iBAAiB,YAC3C,OAAQ,MAAkB,WAAW;AAEzC;AAEA,SAAgB,eAAwC;CACtD,IAAI;EACF,MAAM,MAAM,aAAa,QAAQ,SAAS;EAC1C,IAAI,CAAC,KACH,OAAO,CAAC;EAEV,MAAM,SAAkB,KAAK,MAAM,GAAG;EACtC,IAAI,OAAO,WAAW,YAAY,WAAW,MAC3C,OAAO,CAAC;EAEV,MAAM,QAAiC,CAAC;EACxC,KAAK,MAAM,CAAC,OAAO,SAAS,OAAO,QAAQ,MAAM,GAC/C,IAAI,UAAU,IAAI,GAChB,MAAM,SAAS;EAGnB,OAAO;CACT,QAAQ;EACN,OAAO,CAAC;CACV;AACF;AAEA,SAAgB,aAAa,OAAsC;CACjE,IAAI;EACF,aAAa,QAAQ,WAAW,KAAK,UAAU,KAAK,CAAC;CACvD,QAAQ,CAER;AACF"}
|