@graphiql/plugin-collections 1.0.0-beta.1 → 1.0.0-beta.3

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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +5 -6
  3. package/dist/components/collection-item-row.js +212 -282
  4. package/dist/components/collection-item-row.js.map +1 -1
  5. package/dist/components/collection-row.js +139 -159
  6. package/dist/components/collection-row.js.map +1 -1
  7. package/dist/components/collections-panel.js +408 -496
  8. package/dist/components/collections-panel.js.map +1 -1
  9. package/dist/components/conflict-dialog.js +148 -164
  10. package/dist/components/conflict-dialog.js.map +1 -1
  11. package/dist/components/export-dialog.js +52 -52
  12. package/dist/components/export-dialog.js.map +1 -1
  13. package/dist/components/import-dialog.js +100 -112
  14. package/dist/components/import-dialog.js.map +1 -1
  15. package/dist/components/save-dialog.js +116 -124
  16. package/dist/components/save-dialog.js.map +1 -1
  17. package/dist/components/session-actions.js +23 -31
  18. package/dist/components/session-actions.js.map +1 -1
  19. package/dist/icons/check.js +18 -9
  20. package/dist/icons/check.js.map +1 -1
  21. package/dist/icons/collections.js +16 -9
  22. package/dist/icons/collections.js.map +1 -1
  23. package/dist/icons/download.js +16 -9
  24. package/dist/icons/download.js.map +1 -1
  25. package/dist/icons/upload.js +16 -9
  26. package/dist/icons/upload.js.map +1 -1
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.js +32 -41
  29. package/dist/index.js.map +1 -1
  30. package/dist/operation-method.js +24 -24
  31. package/dist/operation-method.js.map +1 -1
  32. package/dist/storage/local-storage.js +32 -37
  33. package/dist/storage/local-storage.js.map +1 -1
  34. package/dist/storage/tab-links.js +27 -30
  35. package/dist/storage/tab-links.js.map +1 -1
  36. package/dist/store.js +365 -402
  37. package/dist/store.js.map +1 -1
  38. package/dist/style.css +6 -27
  39. package/dist/types.js +9 -8
  40. package/dist/types.js.map +1 -1
  41. package/dist/utility/uuid.js +11 -9
  42. package/dist/utility/uuid.js.map +1 -1
  43. 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
- const CollectionsSessionActions = ({
8
- storage,
9
- readOnly = false,
10
- allowImportExport = true,
11
- allowReplace = true
12
- }) => {
13
- useEffect(() => {
14
- void collectionsStore.getState().actions.init(storage ?? localStorageAdapter, {
15
- readOnly,
16
- allowImportExport,
17
- allowReplace
18
- });
19
- }, []);
20
- const { registerSaveHandler } = useGraphiQLActions();
21
- useEffect(() => {
22
- if (readOnly) {
23
- return;
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
- //# sourceMappingURL=session-actions.js.map
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"],"names":[],"mappings":";;;;;;AAcO,MAAM,4BAA4B,CAAC;AAAA,EACxC;AAAA,EACA,WAAW;AAAA,EACX,oBAAoB;AAAA,EACpB,eAAe;AACjB,MAAsC;AACpC,YAAU,MAAM;AACd,SAAK,iBACF,SAAS,EACT,QAAQ,KAAK,WAAW,qBAAqB;AAAA,MAC5C;AAAA,MACA;AAAA,MACA;AAAA,IAAA,CACD;AAAA,EAGL,GAAG,EAAE;AAEC,QAAA,EAAE,oBAAoB,IAAI,mBAAmB;AAEnD,YAAU,MAAM;AACd,QAAI,UAAU;AACZ;AAAA,IAAA;AAEK,WAAA;AAAA,MAAoB,SACzB,iBAAiB,SAAW,EAAA,QAAQ,YAAY,GAAG;AAAA,IACrD;AAAA,EAAA,GACC,CAAC,UAAU,mBAAmB,CAAC;AAElC,6BAAQ,YAAW,EAAA;AACrB;"}
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"}
@@ -1,10 +1,19 @@
1
1
  import * as React from "react";
2
- const SvgCheck = ({
3
- title,
4
- titleId,
5
- ...props
6
- }) => /* @__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" }));
7
- export {
8
- SvgCheck as default
9
- };
10
- //# sourceMappingURL=check.js.map
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
@@ -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"],"names":[],"mappings":";AACK,MAAC,WAAW,CAAC;AAAA,EAChB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB,sBAAM,cAAc,OAAO,EAAE,OAAO,8BAA8B,MAAM,QAAQ,SAAS,aAAa,mBAAmB,SAAS,GAAG,MAAK,GAAI,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAO,GAAI,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ,EAAE,QAAQ,gBAAgB,eAAe,SAAS,gBAAgB,SAAS,aAAa,MAAM,GAAG,oBAAoB,CAAC;"}
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
- const SvgCollections = ({
3
- title,
4
- titleId,
5
- ...props
6
- }) => /* @__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" }));
7
- export {
8
- SvgCollections as default
9
- };
10
- //# sourceMappingURL=collections.js.map
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"],"names":[],"mappings":";AACK,MAAC,iBAAiB,CAAC;AAAA,EACtB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB,sBAAM,cAAc,OAAO,EAAE,OAAO,8BAA8B,MAAM,QAAQ,QAAQ,gBAAgB,eAAe,SAAS,gBAAgB,SAAS,aAAa,GAAG,SAAS,aAAa,mBAAmB,SAAS,GAAG,MAAK,GAAI,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAS,GAAE,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ,EAAE,GAAG,+EAA+E,CAAC;"}
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"}
@@ -1,10 +1,17 @@
1
1
  import * as React from "react";
2
- const SvgDownload = ({
3
- title,
4
- titleId,
5
- ...props
6
- }) => /* @__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" }));
7
- export {
8
- SvgDownload as default
9
- };
10
- //# sourceMappingURL=download.js.map
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"],"names":[],"mappings":";AACK,MAAC,cAAc,CAAC;AAAA,EACnB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB,sBAAM,cAAc,OAAO,EAAE,OAAO,8BAA8B,MAAM,QAAQ,QAAQ,gBAAgB,eAAe,SAAS,gBAAgB,SAAS,aAAa,GAAG,SAAS,aAAa,mBAAmB,SAAS,GAAG,MAAK,GAAI,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAS,GAAE,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ,EAAE,GAAG,iCAAiC,CAAC;"}
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"}
@@ -1,10 +1,17 @@
1
1
  import * as React from "react";
2
- const SvgUpload = ({
3
- title,
4
- titleId,
5
- ...props
6
- }) => /* @__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" }));
7
- export {
8
- SvgUpload as default
9
- };
10
- //# sourceMappingURL=upload.js.map
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
@@ -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"],"names":[],"mappings":";AACK,MAAC,YAAY,CAAC;AAAA,EACjB;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAsB,sBAAM,cAAc,OAAO,EAAE,OAAO,8BAA8B,MAAM,QAAQ,QAAQ,gBAAgB,eAAe,SAAS,gBAAgB,SAAS,aAAa,GAAG,SAAS,aAAa,mBAAmB,SAAS,GAAG,MAAK,GAAI,QAAwB,sBAAM,cAAc,SAAS,EAAE,IAAI,QAAS,GAAE,KAAK,IAAI,MAAsB,sBAAM,cAAc,QAAQ,EAAE,GAAG,iCAAiC,CAAC;"}
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.d.ts CHANGED
@@ -15,3 +15,4 @@ export type CollectionsPluginOptions = {
15
15
  allowReplace?: boolean;
16
16
  };
17
17
  export declare const collectionsPlugin: (options?: CollectionsPluginOptions) => GraphiQLPlugin;
18
+ export declare const COLLECTIONS_PLUGIN: GraphiQLPlugin;
package/dist/index.js CHANGED
@@ -1,46 +1,37 @@
1
- import { jsx } from "react/jsx-runtime";
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 { collectionsStore, useCollectionsStore } from "./store.js";
7
- import { createLocalStorageAdapter, localStorageAdapter } from "./storage/local-storage.js";
8
- import { SaveDialog } from "./components/save-dialog.js";
9
- const collectionsPlugin = (options) => {
10
- function CollectionsPanelWithOptions() {
11
- return /* @__PURE__ */ jsx(
12
- CollectionsPanel,
13
- {
14
- readOnly: options == null ? void 0 : options.readOnly,
15
- allowImportExport: options == null ? void 0 : options.allowImportExport,
16
- allowReplace: options == null ? void 0 : options.allowReplace
17
- }
18
- );
19
- }
20
- function CollectionsSessionActionsWithOptions() {
21
- return /* @__PURE__ */ jsx(
22
- CollectionsSessionActions,
23
- {
24
- storage: options == null ? void 0 : options.storage,
25
- readOnly: options == null ? void 0 : options.readOnly,
26
- allowImportExport: options == null ? void 0 : options.allowImportExport,
27
- allowReplace: options == null ? void 0 : options.allowReplace
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
- //# sourceMappingURL=index.js.map
33
+ var COLLECTIONS_PLUGIN = collectionsPlugin();
34
+ //#endregion
35
+ export { COLLECTIONS_PLUGIN, SaveDialog as CollectionsSaveDialog, collectionsPlugin, collectionsStore, createLocalStorageAdapter, localStorageAdapter, useCollectionsStore };
36
+
37
+ //# 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"],"names":["CollectionsIcon"],"mappings":";;;;;;;;AAmCa,MAAA,oBAAoB,CAC/B,YACmB;AACnB,WAAS,8BAA8B;AAEnC,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,UAAU,mCAAS;AAAA,QACnB,mBAAmB,mCAAS;AAAA,QAC5B,cAAc,mCAAS;AAAA,MAAA;AAAA,IACzB;AAAA,EAAA;AAGJ,WAAS,uCAAuC;AAE5C,WAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,SAAS,mCAAS;AAAA,QAClB,UAAU,mCAAS;AAAA,QACnB,mBAAmB,mCAAS;AAAA,QAC5B,cAAc,mCAAS;AAAA,MAAA;AAAA,IACzB;AAAA,EAAA;AAGG,SAAA;AAAA,IACL,OAAO;AAAA,IACP,MAAMA;AAAAA,IACN,SAAS;AAAA,IACT,gBAAgB;AAAA,EAClB;AACF;"}
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\nexport const COLLECTIONS_PLUGIN = collectionsPlugin();\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;AAEA,IAAa,qBAAqB,kBAAkB"}
@@ -1,28 +1,28 @@
1
- import { parse, Kind } from "graphql";
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
- var _a;
4
- const match = /^\s*(query|mutation|subscription)/i.exec(query);
5
- const keyword = (_a = match == null ? void 0 : match[1]) == null ? void 0 : _a.toLowerCase();
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
- try {
13
- const operations = parse(query).definitions.filter(
14
- (def) => def.kind === Kind.OPERATION_DEFINITION
15
- );
16
- if (operations.length > 1) {
17
- return "mix";
18
- }
19
- const [operation] = operations;
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
- export {
26
- getDocumentMethod
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"],"names":[],"mappings":";AAOA,SAAS,mBAAmB,OAA0B;;AAC9C,QAAA,QAAQ,qCAAqC,KAAK,KAAK;AAC7D,QAAM,WAAU,oCAAQ,OAAR,mBAAY;AACxB,MAAA,YAAY,cAAc,YAAY,gBAAgB;AACjD,WAAA;AAAA,EAAA;AAEF,SAAA;AACT;AAQO,SAAS,kBAAkB,OAA+B;AAC3D,MAAA;AACF,UAAM,aAAa,MAAM,KAAK,EAAE,YAAY;AAAA,MAC1C,CAAA,QAAO,IAAI,SAAS,KAAK;AAAA,IAC3B;AACI,QAAA,WAAW,SAAS,GAAG;AAClB,aAAA;AAAA,IAAA;AAEH,UAAA,CAAC,SAAS,IAAI;AACb,WAAA,YAAY,UAAU,YAAY;AAAA,EAAA,QACnC;AACN,WAAO,mBAAmB,KAAK;AAAA,EAAA;AAEnC;"}
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
- const DEFAULT_KEY = "graphiql:collections";
2
- const VERSION = 1;
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
- return {
5
- async load() {
6
- try {
7
- const raw = localStorage.getItem(storageKey);
8
- if (!raw) {
9
- return [];
10
- }
11
- const parsed = JSON.parse(raw);
12
- if (parsed.version !== VERSION) {
13
- console.warn(
14
- `[graphiql/plugin-collections] Storage version mismatch (found ${parsed.version}, expected ${VERSION}). Attempting to load collections as-is.`
15
- );
16
- return Array.isArray(parsed.collections) ? parsed.collections : [];
17
- }
18
- return parsed.collections ?? [];
19
- } catch {
20
- return [];
21
- }
22
- },
23
- async save(collections) {
24
- try {
25
- localStorage.setItem(
26
- storageKey,
27
- JSON.stringify({ version: VERSION, collections })
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
- const localStorageAdapter = createLocalStorageAdapter();
35
- export {
36
- createLocalStorageAdapter,
37
- localStorageAdapter
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"],"names":[],"mappings":"AAEA,MAAM,cAAc;AACpB,MAAM,UAAU;AAOA,SAAA,0BACd,aAAa,aACO;AACb,SAAA;AAAA,IACL,MAAM,OAAO;AACP,UAAA;AACI,cAAA,MAAM,aAAa,QAAQ,UAAU;AAC3C,YAAI,CAAC,KAAK;AACR,iBAAO,CAAC;AAAA,QAAA;AAEJ,cAAA,SAA0B,KAAK,MAAM,GAAG;AAC1C,YAAA,OAAO,YAAY,SAAS;AAKtB,kBAAA;AAAA,YACN,iEAAiE,OAAO,OAAO,cAAc,OAAO;AAAA,UACtG;AACA,iBAAO,MAAM,QAAQ,OAAO,WAAW,IAAI,OAAO,cAAc,CAAC;AAAA,QAAA;AAE5D,eAAA,OAAO,eAAe,CAAC;AAAA,MAAA,QACxB;AACN,eAAO,CAAC;AAAA,MAAA;AAAA,IAEZ;AAAA,IACA,MAAM,KAAK,aAAa;AAClB,UAAA;AACW,qBAAA;AAAA,UACX;AAAA,UACA,KAAK,UAAU,EAAE,SAAS,SAAS,YAAa,CAAA;AAAA,QAClD;AAAA,MAAA,QACM;AAAA,MAAA;AAAA,IAER;AAAA,EAEJ;AACF;AAEO,MAAM,sBAAsB,0BAA0B;"}
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
- const LINKS_KEY = "graphiql:collections:tab-links";
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
- return typeof value === "object" && value !== null && typeof value.collectionId === "string" && typeof value.itemId === "string";
10
+ return typeof value === "object" && value !== null && typeof value.collectionId === "string" && typeof value.itemId === "string";
4
11
  }
5
12
  function loadTabLinks() {
6
- try {
7
- const raw = localStorage.getItem(LINKS_KEY);
8
- if (!raw) {
9
- return {};
10
- }
11
- const parsed = JSON.parse(raw);
12
- if (typeof parsed !== "object" || parsed === null) {
13
- return {};
14
- }
15
- const links = {};
16
- for (const [tabId, link] of Object.entries(parsed)) {
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
- try {
28
- localStorage.setItem(LINKS_KEY, JSON.stringify(links));
29
- } catch {
30
- }
26
+ try {
27
+ localStorage.setItem(LINKS_KEY, JSON.stringify(links));
28
+ } catch {}
31
29
  }
32
- export {
33
- loadTabLinks,
34
- saveTabLinks
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"],"names":[],"mappings":"AASA,MAAM,YAAY;AAElB,SAAS,UAAU,OAAkC;AAEjD,SAAA,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAkB,iBAAiB,YAC3C,OAAQ,MAAkB,WAAW;AAEzC;AAEO,SAAS,eAAwC;AAClD,MAAA;AACI,UAAA,MAAM,aAAa,QAAQ,SAAS;AAC1C,QAAI,CAAC,KAAK;AACR,aAAO,CAAC;AAAA,IAAA;AAEJ,UAAA,SAAkB,KAAK,MAAM,GAAG;AACtC,QAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AACjD,aAAO,CAAC;AAAA,IAAA;AAEV,UAAM,QAAiC,CAAC;AACxC,eAAW,CAAC,OAAO,IAAI,KAAK,OAAO,QAAQ,MAAM,GAAG;AAC9C,UAAA,UAAU,IAAI,GAAG;AACnB,cAAM,KAAK,IAAI;AAAA,MAAA;AAAA,IACjB;AAEK,WAAA;AAAA,EAAA,QACD;AACN,WAAO,CAAC;AAAA,EAAA;AAEZ;AAEO,SAAS,aAAa,OAAsC;AAC7D,MAAA;AACF,iBAAa,QAAQ,WAAW,KAAK,UAAU,KAAK,CAAC;AAAA,EAAA,QAC/C;AAAA,EAAA;AAGV;"}
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"}