@graphiql/plugin-collections 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/components/collection-item-row.js +3 -4
  2. package/dist/components/collection-item-row.js.map +1 -1
  3. package/dist/components/collection-row.js +3 -4
  4. package/dist/components/collection-row.js.map +1 -1
  5. package/dist/components/collections-panel.js +3 -4
  6. package/dist/components/collections-panel.js.map +1 -1
  7. package/dist/components/conflict-dialog.js +1 -2
  8. package/dist/components/export-dialog.js +1 -2
  9. package/dist/components/import-dialog.js +1 -2
  10. package/dist/components/save-dialog.js +85 -92
  11. package/dist/components/save-dialog.js.map +1 -1
  12. package/dist/components/session-actions.d.ts +1 -1
  13. package/dist/components/session-actions.js +2 -3
  14. package/dist/icons/{check.js → check.svg_react.js} +2 -3
  15. package/dist/icons/check.svg_react.js.map +1 -0
  16. package/dist/icons/{collections.js → collections.svg_react.js} +2 -3
  17. package/dist/icons/collections.svg_react.js.map +1 -0
  18. package/dist/icons/{download.js → download.svg_react.js} +2 -3
  19. package/dist/icons/download.svg_react.js.map +1 -0
  20. package/dist/icons/{upload.js → upload.svg_react.js} +2 -3
  21. package/dist/icons/upload.svg_react.js.map +1 -0
  22. package/dist/index.js +5 -6
  23. package/dist/index.js.map +1 -1
  24. package/dist/operation-method.js +1 -2
  25. package/dist/storage/local-storage.js +1 -2
  26. package/dist/storage/tab-links.js +1 -2
  27. package/dist/store.d.ts +3 -1
  28. package/dist/store.js +6 -5
  29. package/dist/store.js.map +1 -1
  30. package/dist/types.js +1 -2
  31. package/dist/utility/uuid.js +1 -2
  32. package/package.json +9 -9
  33. package/dist/icons/check.js.map +0 -1
  34. package/dist/icons/collections.js.map +0 -1
  35. package/dist/icons/download.js.map +0 -1
  36. package/dist/icons/upload.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"save-dialog.js","names":[],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC, useEffect, useState } from 'react';\nimport { Button, Dialog } from '@graphiql/react';\nimport { useCollectionsStore, collectionsStore } from '../store';\n\nconst NEW_COLLECTION = '__new__';\n\n/**\n * The single \"Save to collection\" dialog. Its open state and the operation\n * being saved live in the collections store, so ⌘S and the save button can open\n * it imperatively via `requestSave`.\n */\nexport const SaveDialog: FC = () => {\n const collections = useCollectionsStore(s => s.collections);\n const actions = useCollectionsStore(s => s.actions);\n const { open, name: initialName } = useCollectionsStore(s => s.saveDialog);\n const [saving, setSaving] = useState(false);\n\n const [name, setName] = useState(initialName);\n const [description, setDescription] = useState('');\n const [selectedCollectionId, setSelectedCollectionId] =\n useState<string>(NEW_COLLECTION);\n const [newCollectionName, setNewCollectionName] = useState('New Collection');\n\n // Reset the form each time the dialog opens with a fresh operation.\n useEffect(() => {\n if (open) {\n const { collections: current } = collectionsStore.getState();\n setName(initialName);\n setDescription('');\n setSelectedCollectionId(current[0]?.id ?? NEW_COLLECTION);\n setNewCollectionName('New Collection');\n setSaving(false);\n }\n }, [open, initialName]);\n\n const handleSave = async () => {\n setSaving(true);\n try {\n await collectionsStore.getState().actions.commitSaveDialog({\n name: name || 'Unnamed operation',\n description: description || undefined,\n collectionId:\n selectedCollectionId === NEW_COLLECTION\n ? undefined\n : selectedCollectionId,\n newCollectionName,\n });\n } catch {\n // The editor displays the rejected save; it retains the dirty state.\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <Dialog open={open} onOpenChange={o => !o && actions.closeSaveDialog()}>\n <Dialog.Header>Save to collection</Dialog.Header>\n <Dialog.Description className=\"graphiql-sr-only\">\n Save the current operation to a collection.\n </Dialog.Description>\n <form\n onSubmit={e => {\n e.preventDefault();\n void handleSave();\n }}\n >\n <Dialog.Body>\n <label className=\"graphiql-save-dialog-field\">\n <span>Operation name</span>\n <input\n type=\"text\"\n value={name}\n onChange={e => setName(e.target.value)}\n placeholder=\"Unnamed operation\"\n className=\"graphiql-save-dialog-input\"\n autoFocus\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={e => setDescription(e.target.value)}\n placeholder=\"Description (optional)\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection</span>\n <select\n value={selectedCollectionId}\n onChange={e => setSelectedCollectionId(e.target.value)}\n className=\"graphiql-save-dialog-select\"\n >\n <option value={NEW_COLLECTION}>+ New collection</option>\n {collections.map(c => (\n <option key={c.id} value={c.id}>\n {c.name}\n </option>\n ))}\n </select>\n </label>\n {selectedCollectionId === NEW_COLLECTION && (\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection name</span>\n <input\n type=\"text\"\n value={newCollectionName}\n onChange={e => setNewCollectionName(e.target.value)}\n placeholder=\"Collection name\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Button\n type=\"button\"\n disabled={saving}\n onClick={() => actions.closeSaveDialog()}\n >\n Cancel\n </Button>\n <Button type=\"submit\" variant=\"primary\" disabled={saving}>\n {saving ? 'Saving…' : 'Save'}\n </Button>\n </Dialog.Footer>\n </form>\n </Dialog>\n );\n};\n"],"mappings":";;;;;AAIA,IAAM,iBAAiB;;;;;;AAOvB,IAAa,mBAAuB;CAClC,MAAM,cAAc,qBAAoB,MAAK,EAAE,WAAW;CAC1D,MAAM,UAAU,qBAAoB,MAAK,EAAE,OAAO;CAClD,MAAM,EAAE,MAAM,MAAM,gBAAgB,qBAAoB,MAAK,EAAE,UAAU;CACzE,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,CAAC,MAAM,WAAW,SAAS,WAAW;CAC5C,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;CACjD,MAAM,CAAC,sBAAsB,2BAC3B,SAAiB,cAAc;CACjC,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,gBAAgB;CAG3E,gBAAgB;EACd,IAAI,MAAM;GACR,MAAM,E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O,WAAU;MAAjB,UAAA,CACE,oBAAC,QAAD,EAAA,UAAM,aAAgB,CAAA,GACtB,qBAAC,UAAD;OACE,OAAO;OACP,WAAU,MAAK,wBAAwB,EAAE,OAAO,KAAK;OACrD,WAAU;OAHZ,UAAA,CAKE,oBAAC,UAAD;QAAQ,OAAO;QAAgB,UAAA;OAAwB,CAAA,GACtD,YAAY,KAAI,MACf,oBAAC,UAAD;QAAmB,OAAO,EAAE;QACzB,UAAA,EAAE;OACG,GAFK,EAAE,EAEP,CACT,CACK;MACH,CAAA,CAAA;;KACN,yBAAyB,kBACxB,qBAAC,SAAD;MAAO,WAAU;MAAjB,UAAA,CACE,oBAAC,QAAD,EAAA,UAAM,kBAAqB,CAAA,GAC3B,oBAAC,SAAD;OACE,MAAK;OACL,OAAO;OACP,WAAU,MAAK,qBAAqB,EAAE,OAAO,KAAK;OAClD,aAAY;OACZ,WAAU;MACX,CAAA,CACI;;IAEE,EAAA,CAAA,GACb,qBAAC,OAAO,QAAR,EAAA,UAAA,CACE,oBAAC,QAAD;KACE,MAAK;KACL,UAAU;KACV,eAAe,QAAQ,gBAAgB;KACxC,UAAA;IAEO,CAAA,GACR,oBAAC,QAAD;KAAQ,MAAK;KAAS,SAAQ;KAAU,UAAU;KAC/C,UAAA,SAAS,YAAY;IAChB,CAAA,CACK,EAAA,CAAA,CACX;;EACA;;AAEZ"}
1
+ {"version":3,"file":"save-dialog.js","names":["_Fragment"],"sources":["../../src/components/save-dialog.tsx"],"sourcesContent":["import { FC, useState } from 'react';\nimport { Button, Dialog } from '@graphiql/react';\nimport { useCollectionsStore, collectionsStore } from '../store';\n\nconst NEW_COLLECTION = '__new__';\n\n/**\n * The single \"Save to collection\" dialog. Its open state and the operation\n * being saved live in the collections store, so ⌘S and the save button can open\n * it imperatively via `requestSave`.\n */\nexport const SaveDialog: FC = () => {\n const { open, name, requestId } = useCollectionsStore(s => s.saveDialog);\n const closeSaveDialog = useCollectionsStore(s => s.actions.closeSaveDialog);\n\n return (\n <Dialog open={open} onOpenChange={o => !o && closeSaveDialog()}>\n {open && <SaveDialogForm key={requestId} initialName={name} />}\n </Dialog>\n );\n};\n\nconst SaveDialogForm: FC<{ initialName: string }> = ({ initialName }) => {\n const collections = useCollectionsStore(s => s.collections);\n const closeSaveDialog = useCollectionsStore(s => s.actions.closeSaveDialog);\n const [saving, setSaving] = useState(false);\n const [name, setName] = useState(initialName);\n const [description, setDescription] = useState('');\n const [selectedCollectionId, setSelectedCollectionId] = useState(\n () => collections[0]?.id ?? NEW_COLLECTION,\n );\n const [newCollectionName, setNewCollectionName] = useState('New Collection');\n\n const handleSave = async () => {\n setSaving(true);\n try {\n await collectionsStore.getState().actions.commitSaveDialog({\n name: name || 'Unnamed operation',\n description: description || undefined,\n collectionId:\n selectedCollectionId === NEW_COLLECTION\n ? undefined\n : selectedCollectionId,\n newCollectionName,\n });\n } catch {\n // The editor displays the rejected save; it retains the dirty state.\n } finally {\n setSaving(false);\n }\n };\n\n return (\n <>\n <Dialog.Header>Save to collection</Dialog.Header>\n <Dialog.Description className=\"graphiql-sr-only\">\n Save the current operation to a collection.\n </Dialog.Description>\n <form\n onSubmit={e => {\n e.preventDefault();\n void handleSave();\n }}\n >\n <Dialog.Body>\n <label className=\"graphiql-save-dialog-field\">\n <span>Operation name</span>\n <input\n type=\"text\"\n value={name}\n onChange={e => setName(e.target.value)}\n placeholder=\"Unnamed operation\"\n className=\"graphiql-save-dialog-input\"\n autoFocus\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Description</span>\n <input\n type=\"text\"\n value={description}\n onChange={e => setDescription(e.target.value)}\n placeholder=\"Description (optional)\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection</span>\n <select\n value={selectedCollectionId}\n onChange={e => setSelectedCollectionId(e.target.value)}\n className=\"graphiql-save-dialog-select\"\n >\n <option value={NEW_COLLECTION}>+ New collection</option>\n {collections.map(c => (\n <option key={c.id} value={c.id}>\n {c.name}\n </option>\n ))}\n </select>\n </label>\n {selectedCollectionId === NEW_COLLECTION && (\n <label className=\"graphiql-save-dialog-field\">\n <span>Collection name</span>\n <input\n type=\"text\"\n value={newCollectionName}\n onChange={e => setNewCollectionName(e.target.value)}\n placeholder=\"Collection name\"\n className=\"graphiql-save-dialog-input\"\n />\n </label>\n )}\n </Dialog.Body>\n <Dialog.Footer>\n <Button type=\"button\" disabled={saving} onClick={closeSaveDialog}>\n Cancel\n </Button>\n <Button type=\"submit\" variant=\"primary\" disabled={saving}>\n {saving ? 'Saving…' : 'Save'}\n </Button>\n </Dialog.Footer>\n </form>\n </>\n );\n};\n"],"mappings":";;;;;AAIA,IAAM,iBAAiB;;;;;;AAOvB,IAAa,mBAAuB;CAClC,MAAM,EAAE,MAAM,MAAM,cAAc,qBAAoB,MAAK,EAAE,UAAU;CACvE,MAAM,kBAAkB,qBAAoB,MAAK,EAAE,QAAQ,eAAe;CAE1E,OACE,oBAAC,QAAD;EAAc;EAAM,eAAc,MAAK,CAAC,KAAK,gBAAgB;EAC1D,UAAA,QAAQ,oBAAC,gBAAD,EAAgC,aAAa,KAAO,GAA/B,SAA+B;CACvD,CAAA;AAEZ;AAEA,IAAM,kBAA+C,EAAE,kBAAkB;CACvE,MAAM,cAAc,qBAAoB,MAAK,EAAE,WAAW;CAC1D,MAAM,kBAAkB,qBAAoB,MAAK,EAAE,QAAQ,eAAe;CAC1E,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAC1C,MAAM,CAAC,MAAM,WAAW,SAAS,WAAW;CAC5C,MAAM,CAAC,aAAa,kBAAkB,SAAS,EAAE;CACjD,MAAM,CAAC,sBAAsB,2BAA2B,eAChD,YAAY,EAAE,EAAE,MAAM,cAC9B;CACA,MAAM,CAAC,mBAAmB,wBAAwB,SAAS,gBAAgB;CAE3E,MAAM,aAAa,YAAY;EAC7B,UAAU,IAAI;EACd,IAAI;GACF,MAAM,iBAAiB,SAAS,CAAC,CAAC,QAAQ,iB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,yBAAyB,kBACxB,qBAAC,SAAD;KAAO,WAAU;KAAjB,UAAA,CACE,oBAAC,QAAD,EAAA,UAAM,kBAAqB,CAAA,GAC3B,oBAAC,SAAD;MACE,MAAK;MACL,OAAO;MACP,WAAU,MAAK,qBAAqB,EAAE,OAAO,KAAK;MAClD,aAAY;MACZ,WAAU;KACX,CAAA,CACI;;GAEE,EAAA,CAAA,GACb,qBAAC,OAAO,QAAR,EAAA,UAAA,CACE,oBAAC,QAAD;IAAQ,MAAK;IAAS,UAAU;IAAQ,SAAS;IAAiB,UAAA;GAE1D,CAAA,GACR,oBAAC,QAAD;IAAQ,MAAK;IAAS,SAAQ;IAAU,UAAU;IAC/C,UAAA,SAAS,YAAY;GAChB,CAAA,CACK,EAAA,CAAA,CACX;;CACN,EAAA,CAAA;AAEN"}
@@ -5,5 +5,5 @@ type CollectionsSessionActionsProps = {
5
5
  allowImportExport?: boolean;
6
6
  allowReplace?: boolean;
7
7
  };
8
- export declare const CollectionsSessionActions: ({ storage, readOnly, allowImportExport, allowReplace, }: CollectionsSessionActionsProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const CollectionsSessionActions: ({ storage, readOnly, allowImportExport, allowReplace, }: CollectionsSessionActionsProps) => import('react').JSX.Element;
9
9
  export {};
@@ -1,10 +1,10 @@
1
- import { localStorageAdapter } from "../storage/local-storage.js";
2
1
  import { collectionsStore } from "../store.js";
2
+ import { localStorageAdapter } from "../storage/local-storage.js";
3
3
  import { SaveDialog } from "./save-dialog.js";
4
4
  import { useEffect } from "react";
5
5
  import { useGraphiQLActions } from "@graphiql/react";
6
6
  import { jsx } from "react/jsx-runtime";
7
- //#region src/components/session-actions.tsx
7
+ // src/components/session-actions.tsx
8
8
  var CollectionsSessionActions = ({ storage, readOnly = false, allowImportExport = true, allowReplace = true }) => {
9
9
  useEffect(() => {
10
10
  collectionsStore.getState().actions.init(storage ?? localStorageAdapter, {
@@ -20,7 +20,6 @@ var CollectionsSessionActions = ({ storage, readOnly = false, allowImportExport
20
20
  }, [readOnly, registerSaveHandler]);
21
21
  return /* @__PURE__ */ jsx(SaveDialog, {});
22
22
  };
23
- //#endregion
24
23
  export { CollectionsSessionActions };
25
24
 
26
25
  //# sourceMappingURL=session-actions.js.map
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/check.svg?react
3
+ // src/icons/check.svg?react
4
4
  var SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -18,7 +18,6 @@ var SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
18
18
  d: "m3.5 8.5 3 3 6-7"
19
19
  })]
20
20
  });
21
- //#endregion
22
21
  export { SvgCheck as default };
23
22
 
24
- //# sourceMappingURL=check.js.map
23
+ //# sourceMappingURL=check.svg_react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check.svg_react.js","names":[],"sources":["../../src/icons/check.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tviewBox: \"0 0 16 16\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", {\n\t\tstroke: \"currentColor\",\n\t\tstrokeLinecap: \"round\",\n\t\tstrokeLinejoin: \"round\",\n\t\tstrokeWidth: 1.75,\n\t\td: \"m3.5 8.5 3 3 6-7\"\n\t})]\n});\nexport default SvgCheck;\n"],"mappings":";;;AAEA,IAAM,YAAY,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAC/E,OAAO;CACP,MAAM;CACN,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ;EACvC,QAAQ;EACR,eAAe;EACf,gBAAgB;EAChB,aAAa;EACb,GAAG;CACJ,CAAC,CAAC;AACH,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/collections.svg?react
3
+ // src/icons/collections.svg?react
4
4
  var SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -16,7 +16,6 @@ var SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg
16
16
  children: title
17
17
  }) : null, /* @__PURE__ */ jsx("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" })]
18
18
  });
19
- //#endregion
20
19
  export { SvgCollections as default };
21
20
 
22
- //# sourceMappingURL=collections.js.map
21
+ //# sourceMappingURL=collections.svg_react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collections.svg_react.js","names":[],"sources":["../../src/icons/collections.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"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\" })]\n});\nexport default SvgCollections;\n"],"mappings":";;;AAEA,IAAM,kBAAkB,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CACrF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,8EAA8E,CAAC,CAAC;AAC9H,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/download.svg?react
3
+ // src/icons/download.svg?react
4
4
  var SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -16,7 +16,6 @@ var SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg",
16
16
  children: title
17
17
  }) : null, /* @__PURE__ */ jsx("path", { d: "M12 3v11m-5-4 5 4 5-4M4 20h16" })]
18
18
  });
19
- //#endregion
20
19
  export { SvgDownload as default };
21
20
 
22
- //# sourceMappingURL=download.js.map
21
+ //# sourceMappingURL=download.svg_react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"download.svg_react.js","names":[],"sources":["../../src/icons/download.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", { d: \"M12 3v11m-5-4 5 4 5-4M4 20h16\" })]\n});\nexport default SvgDownload;\n"],"mappings":";;;AAEA,IAAM,eAAe,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAClF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC;AAChF,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
- //#region src/icons/upload.svg?react
3
+ // src/icons/upload.svg?react
4
4
  var SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
5
5
  xmlns: "http://www.w3.org/2000/svg",
6
6
  fill: "none",
@@ -16,7 +16,6 @@ var SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ jsxs("svg", {
16
16
  children: title
17
17
  }) : null, /* @__PURE__ */ jsx("path", { d: "M12 21V10m-5 4 5-4 5 4M4 4h16" })]
18
18
  });
19
- //#endregion
20
19
  export { SvgUpload as default };
21
20
 
22
- //# sourceMappingURL=upload.js.map
21
+ //# sourceMappingURL=upload.svg_react.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"upload.svg_react.js","names":[],"sources":["../../src/icons/upload.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", { d: \"M12 21V10m-5 4 5-4 5 4M4 4h16\" })]\n});\nexport default SvgUpload;\n"],"mappings":";;;AAEA,IAAM,aAAa,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAChF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC;AAChF,CAAC"}
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { createLocalStorageAdapter, localStorageAdapter } from "./storage/local-storage.js";
2
- import { collectionsStore, useCollectionsStore } from "./store.js";
3
1
  import { CollectionsPanel } from "./components/collections-panel.js";
4
- import { SaveDialog } from "./components/save-dialog.js";
5
2
  import { CollectionsSessionActions } from "./components/session-actions.js";
6
- import SvgCollections from "./icons/collections.js";
3
+ import SvgCollections from "./icons/collections.svg_react.js";
7
4
  /* empty css */
5
+ import { collectionsStore, useCollectionsStore } from "./store.js";
6
+ import { createLocalStorageAdapter, localStorageAdapter } from "./storage/local-storage.js";
7
+ import { SaveDialog } from "./components/save-dialog.js";
8
8
  import { jsx } from "react/jsx-runtime";
9
- //#region src/index.tsx
9
+ // src/index.tsx
10
10
  var collectionsPlugin = (options) => {
11
11
  function CollectionsPanelWithOptions() {
12
12
  return /* @__PURE__ */ jsx(CollectionsPanel, {
@@ -31,7 +31,6 @@ var collectionsPlugin = (options) => {
31
31
  };
32
32
  };
33
33
  var COLLECTIONS_PLUGIN = collectionsPlugin();
34
- //#endregion
35
34
  export { COLLECTIONS_PLUGIN, SaveDialog as CollectionsSaveDialog, collectionsPlugin, collectionsStore, createLocalStorageAdapter, localStorageAdapter, useCollectionsStore };
36
35
 
37
36
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
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
+ {"version":3,"file":"index.js","names":["CollectionsIcon"],"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,MAAMA;EACN,SAAS;EACT,gBAAgB;CAClB;AACF;AAEA,IAAa,qBAAqB,kBAAkB"}
@@ -1,5 +1,5 @@
1
1
  import { Kind, parse } from "graphql";
2
- //#region src/operation-method.ts
2
+ // src/operation-method.ts
3
3
  /** Cheap regex fallback for when a document can't be parsed. */
4
4
  function inferOperationType(query) {
5
5
  const keyword = /^\s*(query|mutation|subscription)/i.exec(query)?.[1]?.toLowerCase();
@@ -22,7 +22,6 @@ function getDocumentMethod(query) {
22
22
  return inferOperationType(query);
23
23
  }
24
24
  }
25
- //#endregion
26
25
  export { getDocumentMethod };
27
26
 
28
27
  //# sourceMappingURL=operation-method.js.map
@@ -1,4 +1,4 @@
1
- //#region src/storage/local-storage.ts
1
+ // src/storage/local-storage.ts
2
2
  var DEFAULT_KEY = "graphiql:collections";
3
3
  var VERSION = 1;
4
4
  function createLocalStorageAdapter(storageKey = DEFAULT_KEY) {
@@ -28,7 +28,6 @@ function createLocalStorageAdapter(storageKey = DEFAULT_KEY) {
28
28
  };
29
29
  }
30
30
  var localStorageAdapter = createLocalStorageAdapter();
31
- //#endregion
32
31
  export { createLocalStorageAdapter, localStorageAdapter };
33
32
 
34
33
  //# sourceMappingURL=local-storage.js.map
@@ -1,4 +1,4 @@
1
- //#region src/storage/tab-links.ts
1
+ // src/storage/tab-links.ts
2
2
  /**
3
3
  * Tab↔item links are browser-local: they key off GraphiQL's own tab ids, which
4
4
  * live in localStorage and are stable across reloads. They are deliberately
@@ -27,7 +27,6 @@ function saveTabLinks(links) {
27
27
  localStorage.setItem(LINKS_KEY, JSON.stringify(links));
28
28
  } catch {}
29
29
  }
30
- //#endregion
31
30
  export { loadTabLinks, saveTabLinks };
32
31
 
33
32
  //# sourceMappingURL=tab-links.js.map
package/dist/store.d.ts CHANGED
@@ -3,6 +3,8 @@ import { TabLink } from './storage/tab-links';
3
3
  /** The active operation being saved, as seen by the save dialog. */
4
4
  export type SaveDialogState = {
5
5
  open: boolean;
6
+ /** Identifies a fresh request, including operations with the same name. */
7
+ requestId?: number;
6
8
  /** The tab this save originated from, linked to the item once saved. */
7
9
  tabId?: string;
8
10
  query: string;
@@ -68,7 +70,7 @@ type CollectionsActions = {
68
70
  collectionId?: string;
69
71
  newCollectionName?: string;
70
72
  }): Promise<void>;
71
- openSaveDialog(input: Omit<SaveDialogState, 'open'>): void;
73
+ openSaveDialog(input: Omit<SaveDialogState, 'open' | 'requestId'>): void;
72
74
  closeSaveDialog(): void;
73
75
  };
74
76
  export declare function deriveOperationName(query: string, fallback?: string | null): string;
package/dist/store.js CHANGED
@@ -5,9 +5,10 @@ import { loadTabLinks, saveTabLinks } from "./storage/tab-links.js";
5
5
  import { createBoundedUseStore } from "@graphiql/react";
6
6
  import { createStore } from "zustand";
7
7
  import { z } from "zod";
8
- //#region src/store.ts
8
+ // src/store.ts
9
9
  var INITIAL_SAVE_DIALOG = {
10
10
  open: false,
11
+ requestId: 0,
11
12
  query: "",
12
13
  variables: "",
13
14
  headers: "",
@@ -445,10 +446,11 @@ var collectionsStore = createStore((set, get) => {
445
446
  }
446
447
  },
447
448
  openSaveDialog(input) {
448
- set({ saveDialog: {
449
+ set((s) => ({ saveDialog: {
449
450
  ...input,
450
- open: true
451
- } });
451
+ open: true,
452
+ requestId: (s.saveDialog.requestId ?? 0) + 1
453
+ } }));
452
454
  },
453
455
  closeSaveDialog() {
454
456
  if (committingDialog) return;
@@ -463,7 +465,6 @@ var collectionsStore = createStore((set, get) => {
463
465
  };
464
466
  });
465
467
  var useCollectionsStore = createBoundedUseStore(collectionsStore);
466
- //#endregion
467
468
  export { collectionsStore, deriveOperationName, useCollectionsStore };
468
469
 
469
470
  //# sourceMappingURL=store.js.map
package/dist/store.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"store.js","names":[],"sources":["../src/store.ts"],"sourcesContent":["import { createStore } from 'zustand';\nimport { createBoundedUseStore } from '@graphiql/react';\nimport { z } from 'zod';\nimport { randomId } from './utility/uuid';\nimport type {\n Collection,\n CollectionItem,\n CollectionsConfig,\n CollectionsStorage,\n ImportAnalysis,\n ImportResolution,\n} from './types';\nimport { DEFAULT_COLLECTIONS_CONFIG } from './types';\nimport { localStorageAdapter } from './storage/local-storage';\nimport { loadTabLinks, saveTabLinks, type TabLink } from './storage/tab-links';\n\n/** The active operation being saved, as seen by the save dialog. */\nexport type SaveDialogState = {\n open: boolean;\n /** The tab this save originated from, linked to the item once saved. */\n tabId?: string;\n query: string;\n variables: string;\n headers: string;\n name: string;\n};\n\n/** The current operation handed to `requestSave` from ⌘S or the save button. */\nexport type ActiveOperation = {\n id?: string;\n query: string | null;\n variables?: string | null;\n headers?: string | null;\n operationName?: string | null;\n};\n\ntype CollectionsState = {\n collections: Collection[];\n loaded: boolean;\n storage: CollectionsStorage;\n /** Host-controlled capability flags; set on init from the plugin options. */\n config: CollectionsConfig;\n /** Maps a tab id to the collection item it is linked to. */\n links: Record<string, TabLink>;\n saveDialog: SaveDialogState;\n};\n\ntype CollectionsActions = {\n init(\n storage: CollectionsStorage,\n config?: Partial<CollectionsConfig>,\n ): Promise<void>;\n /**\n * Replace the in-memory collections wholesale without persisting. Use this\n * to reflect state loaded or merged externally — writing it back would be\n * redundant and, for a DB adapter, an unwanted extra write.\n */\n setCollections(collections: Collection[]): void;\n /** Re-read collections from the configured storage — call after an external/remote change to refresh the UI. */\n reload(): Promise<void>;\n createCollection(name: string, description?: string): Collection;\n deleteCollection(id: string): void;\n renameCollection(id: string, name: string): void;\n addItem(\n collectionId: string,\n item: Omit<CollectionItem, 'id' | 'createdAt' | 'updatedAt'>,\n ): CollectionItem;\n updateItem(\n collectionId: string,\n itemId: string,\n updates: Partial<Omit<CollectionItem, 'id' | 'createdAt'>>,\n ): void;\n deleteItem(collectionId: string, itemId: string): void;\n moveItem(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n /** Pure analysis of an import JSON string against current store state. Never mutates. */\n analyzeImport(json: string): ImportAnalysis;\n /** Commit an analysis to the store using the given resolution strategy. */\n applyImport(analysis: ImportAnalysis, resolution: ImportResolution): void;\n exportCollections(): string;\n /** Export a single collection as a (one-collection) export envelope. */\n exportCollection(id: string): string;\n /** Export a single item as a (one-item, one-collection) export envelope. */\n exportItem(itemId: string): string;\n /** Link a tab to a collection item so ⌘S updates it in place. */\n linkTab(tabId: string, collectionId: string, itemId: string): void;\n /**\n * Save the active operation: update the linked item in place if the tab is\n * already tied to a collection item, otherwise open the save dialog. The\n * returned promise settles after storage commits or the dialog is cancelled.\n */\n requestSave(operation: ActiveOperation): Promise<boolean>;\n commitSaveDialog(input: {\n name: string;\n description?: string;\n collectionId?: string;\n newCollectionName?: string;\n }): Promise<void>;\n openSaveDialog(input: Omit<SaveDialogState, 'open'>): void;\n closeSaveDialog(): void;\n};\n\nconst INITIAL_SAVE_DIALOG: SaveDialogState = {\n open: false,\n query: '',\n variables: '',\n headers: '',\n name: '',\n};\n\nexport function deriveOperationName(\n query: string,\n fallback?: string | null,\n): string {\n if (fallback) {\n return fallback;\n }\n const match =\n /(?:query|mutation|subscription)\\s+([A-Za-z_][A-Za-z0-9_]*)/i.exec(query);\n return match?.[1] ?? 'Unnamed operation';\n}\n\ntype StoreShape = CollectionsState & { actions: CollectionsActions };\n\n/** Drop every link that points at one of `itemIds`. */\nfunction pruneLinksForItems(\n links: Record<string, TabLink>,\n itemIds: Set<string>,\n): Record<string, TabLink> {\n const next: Record<string, TabLink> = {};\n for (const [tabId, link] of Object.entries(links)) {\n if (!itemIds.has(link.itemId)) {\n next[tabId] = link;\n }\n }\n return next;\n}\n\n/** Normalize optional string fields so undefined and '' are treated identically. */\nconst norm = (v: string | undefined): string => v ?? '';\n\n/** Compare only the user-visible content fields of two items, ignoring id and timestamps. */\nfunction itemContentEqual(a: CollectionItem, b: CollectionItem): boolean {\n return (\n a.name === b.name &&\n norm(a.query) === norm(b.query) &&\n norm(a.variables) === norm(b.variables) &&\n norm(a.headers) === norm(b.headers)\n );\n}\n\nexport const collectionsStore = createStore<StoreShape>((set, get) => {\n let pendingDialog:\n | { resolve: (saved: boolean) => void; reject: (error: unknown) => void }\n | undefined;\n let committingDialog = false;\n let lastPersist: Promise<void> = Promise.resolve();\n const queueWrite = async (write: () => Promise<void>) => {\n const previous = lastPersist;\n let release!: () => void;\n lastPersist = new Promise<void>(resolve => {\n release = resolve;\n });\n await previous;\n try {\n await write();\n } finally {\n release();\n }\n };\n const persist = async () => {\n try {\n await queueWrite(() => get().storage.save(get().collections));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to persist collections', error);\n }\n };\n\n return {\n collections: [],\n loaded: false,\n storage: localStorageAdapter,\n config: DEFAULT_COLLECTIONS_CONFIG,\n links: {},\n saveDialog: INITIAL_SAVE_DIALOG,\n actions: {\n async init(storage, config) {\n const collections = await storage.load();\n set({\n collections,\n loaded: true,\n storage,\n config: { ...DEFAULT_COLLECTIONS_CONFIG, ...config },\n // Restore tab↔item links so ⌘S on a tab reopened from the previous\n // session still updates its saved operation in place.\n links: loadTabLinks(),\n });\n },\n setCollections(collections) {\n set({ collections });\n },\n async reload() {\n const collections = await get().storage.load();\n set({ collections });\n },\n createCollection(name, description) {\n const c: Collection = {\n id: randomId(),\n name,\n description,\n items: [],\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({ collections: [...s.collections, c] }));\n void persist();\n return c;\n },\n deleteCollection(id) {\n const removed = get().collections.find(c => c.id === id);\n const removedItemIds = new Set(removed?.items.map(i => i.id) ?? []);\n set(s => ({\n collections: s.collections.filter(c => c.id !== id),\n links: pruneLinksForItems(s.links, removedItemIds),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n renameCollection(id, name) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === id ? { ...c, name, updatedAt: Date.now() } : c,\n ),\n }));\n void persist();\n },\n addItem(collectionId, item) {\n const newItem: CollectionItem = {\n ...item,\n id: randomId(),\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? { ...c, items: [...c.items, newItem], updatedAt: Date.now() }\n : c,\n ),\n }));\n void persist();\n return newItem;\n },\n updateItem(collectionId, itemId, updates) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n updatedAt: Date.now(),\n items: c.items.map(i =>\n i.id === itemId\n ? { ...i, ...updates, updatedAt: Date.now() }\n : i,\n ),\n }\n : c,\n ),\n }));\n void persist();\n },\n deleteItem(collectionId, itemId) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n items: c.items.filter(i => i.id !== itemId),\n updatedAt: Date.now(),\n }\n : c,\n ),\n links: pruneLinksForItems(s.links, new Set([itemId])),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n moveItem(fromCollectionId, fromIndex, toCollectionId, toIndex) {\n const { collections } = get();\n const fromCollection = collections.find(c => c.id === fromCollectionId);\n if (\n !fromCollection ||\n fromIndex < 0 ||\n fromIndex >= fromCollection.items.length\n ) {\n return;\n }\n\n const item = fromCollection.items[fromIndex];\n if (!item) {\n return;\n }\n const newCollections = collections.map(c => {\n if (c.id === fromCollectionId && c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(fromIndex, 1);\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n if (c.id === fromCollectionId) {\n return {\n ...c,\n items: c.items.filter((_, i) => i !== fromIndex),\n updatedAt: Date.now(),\n };\n }\n if (c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n return c;\n });\n set({ collections: newCollections });\n void persist();\n },\n analyzeImport(json) {\n const empty: ImportAnalysis = {\n ok: false,\n newCollections: [],\n newItems: [],\n changedItems: [],\n unchangedCount: 0,\n _incoming: [],\n };\n\n // Zod schemas for the import envelope.\n const CollectionItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n query: z.string(),\n variables: z.string().optional(),\n headers: z.string().optional(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n });\n\n const CollectionSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n items: z.array(CollectionItemSchema),\n });\n\n const EnvelopeSchema = z.union([\n z.object({\n version: z.number().optional(),\n collections: z.array(CollectionSchema),\n }),\n z.array(CollectionSchema),\n ]);\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n return empty;\n }\n\n const result = EnvelopeSchema.safeParse(parsed);\n if (!result.success) {\n return empty;\n }\n\n const incoming: Collection[] = Array.isArray(result.data)\n ? result.data\n : result.data.collections;\n\n if (incoming.length === 0) {\n return empty;\n }\n\n const localCollections = get().collections;\n\n // Build a flat map: item id → { item, collectionId } for all local items.\n const localItemMap = new Map<\n string,\n { item: CollectionItem; collectionId: string }\n >();\n for (const col of localCollections) {\n for (const item of col.items) {\n localItemMap.set(item.id, { item, collectionId: col.id });\n }\n }\n\n const localCollectionIds = new Set(localCollections.map(c => c.id));\n\n const newCollections: Collection[] = [];\n const newItems: ImportAnalysis['newItems'] = [];\n const changedItems: ImportAnalysis['changedItems'] = [];\n let unchangedCount = 0;\n\n for (const incomingCol of incoming) {\n // Determine which items in this collection are genuinely new locally.\n const genuinelyNewItems = incomingCol.items.filter(\n item => !localItemMap.has(item.id),\n );\n\n // Register a new collection shell only when:\n // - the collection id is absent locally, AND\n // - it is intentionally empty OR it contributes at least one genuinely new item.\n // A new-to-us collection that only re-homes already-known items must NOT be created.\n if (\n !localCollectionIds.has(incomingCol.id) &&\n (incomingCol.items.length === 0 || genuinelyNewItems.length > 0)\n ) {\n newCollections.push({ ...incomingCol, items: [] });\n }\n\n for (const incomingItem of incomingCol.items) {\n const local = localItemMap.get(incomingItem.id);\n if (!local) {\n newItems.push({\n item: incomingItem,\n // Land in the incoming parent; if that parent is new it will be\n // created during apply, otherwise it already exists locally.\n targetCollectionId: incomingCol.id,\n });\n } else if (itemContentEqual(incomingItem, local.item)) {\n unchangedCount++;\n } else {\n changedItems.push({\n incoming: incomingItem,\n current: local.item,\n // Use where the recipient actually keeps it, not the incoming parent.\n currentCollectionId: local.collectionId,\n });\n }\n }\n }\n\n return {\n ok: true,\n newCollections,\n newItems,\n changedItems,\n unchangedCount,\n _incoming: incoming,\n };\n },\n applyImport(analysis, resolution) {\n if (!analysis.ok) {\n return;\n }\n\n if (resolution.mode === 'replace') {\n set({ collections: analysis._incoming });\n void persist();\n return;\n }\n\n // Merge mode.\n const now = Date.now();\n let collections = [...get().collections];\n\n // 1. Create new collection shells.\n for (const shell of analysis.newCollections) {\n collections.push({ ...shell, items: [] });\n }\n\n // 2. Add new items into their target collections.\n for (const { item, targetCollectionId } of analysis.newItems) {\n collections = collections.map(c =>\n c.id === targetCollectionId\n ? { ...c, items: [...c.items, item], updatedAt: now }\n : c,\n );\n }\n\n // 3. Apply changed items per resolution.\n const shouldApply = (itemId: string): boolean => {\n if ('applyChanges' in resolution) {\n return resolution.applyChanges;\n }\n return resolution.changedItemIds.has(itemId);\n };\n\n for (const conflict of analysis.changedItems) {\n if (!shouldApply(conflict.incoming.id)) {\n continue;\n }\n collections = collections.map(c => {\n if (c.id !== conflict.currentCollectionId) {\n return c;\n }\n return {\n ...c,\n updatedAt: now,\n items: c.items.map(i =>\n i.id === conflict.incoming.id\n ? {\n // Replace content fields; keep the local createdAt.\n ...conflict.incoming,\n createdAt: conflict.current.createdAt,\n updatedAt: now,\n }\n : i,\n ),\n };\n });\n }\n\n set({ collections });\n void persist();\n },\n exportCollections() {\n return JSON.stringify(\n { version: 1, collections: get().collections },\n null,\n 2,\n );\n },\n exportCollection(id) {\n const collection = get().collections.find(c => c.id === id);\n return JSON.stringify(\n { version: 1, collections: collection ? [collection] : [] },\n null,\n 2,\n );\n },\n exportItem(itemId) {\n for (const col of get().collections) {\n const item = col.items.find(i => i.id === itemId);\n if (item) {\n const shell: Collection = {\n id: col.id,\n name: col.name,\n description: col.description,\n createdAt: col.createdAt,\n updatedAt: col.updatedAt,\n items: [item],\n };\n return JSON.stringify(\n { version: 1, collections: [shell] },\n null,\n 2,\n );\n }\n }\n return JSON.stringify({ version: 1, collections: [] }, null, 2);\n },\n linkTab(tabId, collectionId, itemId) {\n set(s => ({\n // An item lives in exactly one tab: drop any stale link to it (e.g. a\n // closed tab's) before recording the new one.\n links: {\n ...pruneLinksForItems(s.links, new Set([itemId])),\n [tabId]: { collectionId, itemId },\n },\n }));\n saveTabLinks(get().links);\n },\n async requestSave(operation) {\n // Authoritative gate: saving is disabled in read-only mode regardless\n // of how it was triggered (⌘S, save button, etc.).\n if (get().config.readOnly) {\n return false;\n }\n if (get().saveDialog.open) {\n return false;\n }\n const { links, collections, actions } = get();\n const link = operation.id ? links[operation.id] : undefined;\n if (link) {\n const collection = collections.find(c => c.id === link.collectionId);\n const item = collection?.items.find(i => i.id === link.itemId);\n if (item) {\n await queueWrite(async () => {\n const target = get()\n .collections.find(c => c.id === link.collectionId)\n ?.items.find(i => i.id === link.itemId);\n if (!target) {\n throw new Error('Saved collection item no longer exists');\n }\n const next = get().collections.map(c =>\n c.id === link.collectionId\n ? {\n ...c,\n updatedAt: Date.now(),\n items: c.items.map(i =>\n i.id === link.itemId\n ? {\n ...i,\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n updatedAt: Date.now(),\n }\n : i,\n ),\n }\n : c,\n );\n await get().storage.save(next);\n set({ collections: next });\n });\n return true;\n }\n }\n actions.openSaveDialog({\n tabId: operation.id,\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n name: deriveOperationName(\n operation.query ?? '',\n operation.operationName,\n ),\n });\n return new Promise<boolean>((resolve, reject) => {\n pendingDialog = { resolve, reject };\n });\n },\n async commitSaveDialog(input) {\n const { saveDialog, collections } = get();\n if (!saveDialog.open || committingDialog) {\n return;\n }\n if (\n input.collectionId &&\n !collections.some(c => c.id === input.collectionId)\n ) {\n const error = new Error('Selected collection no longer exists');\n pendingDialog?.reject(error);\n pendingDialog = undefined;\n get().actions.closeSaveDialog();\n throw error;\n }\n committingDialog = true;\n const now = Date.now();\n const item: CollectionItem = {\n id: randomId(),\n name: input.name || 'Unnamed operation',\n description: input.description || undefined,\n query: saveDialog.query,\n variables: saveDialog.variables,\n headers: saveDialog.headers,\n createdAt: now,\n updatedAt: now,\n };\n const collectionId = input.collectionId ?? randomId();\n try {\n await queueWrite(async () => {\n if (\n input.collectionId &&\n !get().collections.some(c => c.id === collectionId)\n ) {\n throw new Error('Selected collection no longer exists');\n }\n const next = input.collectionId\n ? get().collections.map(c =>\n c.id === collectionId\n ? { ...c, items: [...c.items, item], updatedAt: now }\n : c,\n )\n : [\n ...get().collections,\n {\n id: collectionId,\n name: input.newCollectionName || 'New Collection',\n items: [item],\n createdAt: now,\n updatedAt: now,\n },\n ];\n await get().storage.save(next);\n set({ collections: next });\n });\n if (saveDialog.tabId) {\n get().actions.linkTab(saveDialog.tabId, collectionId, item.id);\n }\n pendingDialog?.resolve(true);\n pendingDialog = undefined;\n committingDialog = false;\n get().actions.closeSaveDialog();\n } catch (error) {\n pendingDialog?.reject(error);\n pendingDialog = undefined;\n committingDialog = false;\n get().actions.closeSaveDialog();\n throw error;\n }\n },\n openSaveDialog(input) {\n set({ saveDialog: { ...input, open: true } });\n },\n closeSaveDialog() {\n if (committingDialog) {\n return;\n }\n pendingDialog?.resolve(false);\n pendingDialog = undefined;\n set(s => ({ saveDialog: { ...s.saveDialog, open: false } }));\n },\n },\n };\n});\n\nexport const useCollectionsStore = createBoundedUseStore(collectionsStore);\n"],"mappings":";;;;;;;;AA0GA,IAAM,sBAAuC;CAC3C,MAAM;CACN,OAAO;CACP,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,oBACd,OACA,UACQ;CACR,IAAI,UACF,OAAO;CAIT,OADE,8DAA8D,KAAK,KAC9D,CAAA,GAAQ,MAAM;AACvB;;AAKA,SAAS,mBACP,OACA,SACyB;CACzB,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,OAAO,SAAS,OAAO,QAAQ,KAAK,GAC9C,IAAI,CAAC,QAAQ,IAAI,KAAK,MAAM,GAC1B,KAAK,SAAS;CAGlB,OAAO;AACT;;AAGA,IAAM,QAAQ,MAAkC,KAAK;;AAGrD,SAAS,iBAAiB,GAAmB,GAA4B;CACvE,OACE,EAAE,SAAS,EAAE,QACb,KAAK,EAAE,KAAK,MAAM,KAAK,EAAE,KAAK,KAC9B,KAAK,EAAE,SAAS,MAAM,KAAK,EAAE,SAAS,KACtC,KAAK,EAAE,OAAO,MAAM,KAAK,EAAE,OAAO;AAEtC;AAEA,IAAa,mBAAmB,aAAyB,KAAK,QAAQ;CACpE,IAAI;CAGJ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3B,CAAC;KACD,IAAI,WAAW,OACb,IAAI,CAAC,CAAC,QAAQ,QAAQ,WAAW,OAAO,cAAc,KAAK,EAAE;KAE/D,eAAe,QAAQ,IAAI;KAC3B,gBAAgB,KAAA;KAChB,mBAAmB;KACnB,IAAI,CAAC,CAAC,QAAQ,gBAAgB;IAChC,SAAS,OAAO;KACd,eAAe,OAAO,KAAK;KAC3B,gBAAgB,KAAA;KAChB,mBAAmB;KACnB,IAAI,CAAC,CAAC,QAAQ,gBAAgB;KAC9B,MAAM;IACR;GACF;GACA,eAAe,OAAO;IACpB,IAAI,EAAE,YAAY;KAAE,GAAG;KAAO,MAAM;IAAK,EAAE,CAAC;GAC9C;GACA,kBAAkB;IAChB,IAAI,kBACF;IAEF,eAAe,QAAQ,KAAK;IAC5B,gBAAgB,KAAA;IAChB,KAAI,OAAM,EAAE,YAAY;KAAE,GAAG,EAAE;KAAY,MAAM;IAAM,EAAE,EAAE;GAC7D;EACF;CACF;AACF,CAAC;AAED,IAAa,sBAAsB,sBAAsB,gBAAgB"}
1
+ {"version":3,"file":"store.js","names":[],"sources":["../src/store.ts"],"sourcesContent":["import { createStore } from 'zustand';\nimport { createBoundedUseStore } from '@graphiql/react';\nimport { z } from 'zod';\nimport { randomId } from './utility/uuid';\nimport type {\n Collection,\n CollectionItem,\n CollectionsConfig,\n CollectionsStorage,\n ImportAnalysis,\n ImportResolution,\n} from './types';\nimport { DEFAULT_COLLECTIONS_CONFIG } from './types';\nimport { localStorageAdapter } from './storage/local-storage';\nimport { loadTabLinks, saveTabLinks, type TabLink } from './storage/tab-links';\n\n/** The active operation being saved, as seen by the save dialog. */\nexport type SaveDialogState = {\n open: boolean;\n /** Identifies a fresh request, including operations with the same name. */\n requestId?: number;\n /** The tab this save originated from, linked to the item once saved. */\n tabId?: string;\n query: string;\n variables: string;\n headers: string;\n name: string;\n};\n\n/** The current operation handed to `requestSave` from ⌘S or the save button. */\nexport type ActiveOperation = {\n id?: string;\n query: string | null;\n variables?: string | null;\n headers?: string | null;\n operationName?: string | null;\n};\n\ntype CollectionsState = {\n collections: Collection[];\n loaded: boolean;\n storage: CollectionsStorage;\n /** Host-controlled capability flags; set on init from the plugin options. */\n config: CollectionsConfig;\n /** Maps a tab id to the collection item it is linked to. */\n links: Record<string, TabLink>;\n saveDialog: SaveDialogState;\n};\n\ntype CollectionsActions = {\n init(\n storage: CollectionsStorage,\n config?: Partial<CollectionsConfig>,\n ): Promise<void>;\n /**\n * Replace the in-memory collections wholesale without persisting. Use this\n * to reflect state loaded or merged externally — writing it back would be\n * redundant and, for a DB adapter, an unwanted extra write.\n */\n setCollections(collections: Collection[]): void;\n /** Re-read collections from the configured storage — call after an external/remote change to refresh the UI. */\n reload(): Promise<void>;\n createCollection(name: string, description?: string): Collection;\n deleteCollection(id: string): void;\n renameCollection(id: string, name: string): void;\n addItem(\n collectionId: string,\n item: Omit<CollectionItem, 'id' | 'createdAt' | 'updatedAt'>,\n ): CollectionItem;\n updateItem(\n collectionId: string,\n itemId: string,\n updates: Partial<Omit<CollectionItem, 'id' | 'createdAt'>>,\n ): void;\n deleteItem(collectionId: string, itemId: string): void;\n moveItem(\n fromCollectionId: string,\n fromIndex: number,\n toCollectionId: string,\n toIndex: number,\n ): void;\n /** Pure analysis of an import JSON string against current store state. Never mutates. */\n analyzeImport(json: string): ImportAnalysis;\n /** Commit an analysis to the store using the given resolution strategy. */\n applyImport(analysis: ImportAnalysis, resolution: ImportResolution): void;\n exportCollections(): string;\n /** Export a single collection as a (one-collection) export envelope. */\n exportCollection(id: string): string;\n /** Export a single item as a (one-item, one-collection) export envelope. */\n exportItem(itemId: string): string;\n /** Link a tab to a collection item so ⌘S updates it in place. */\n linkTab(tabId: string, collectionId: string, itemId: string): void;\n /**\n * Save the active operation: update the linked item in place if the tab is\n * already tied to a collection item, otherwise open the save dialog. The\n * returned promise settles after storage commits or the dialog is cancelled.\n */\n requestSave(operation: ActiveOperation): Promise<boolean>;\n commitSaveDialog(input: {\n name: string;\n description?: string;\n collectionId?: string;\n newCollectionName?: string;\n }): Promise<void>;\n openSaveDialog(input: Omit<SaveDialogState, 'open' | 'requestId'>): void;\n closeSaveDialog(): void;\n};\n\nconst INITIAL_SAVE_DIALOG: SaveDialogState = {\n open: false,\n requestId: 0,\n query: '',\n variables: '',\n headers: '',\n name: '',\n};\n\nexport function deriveOperationName(\n query: string,\n fallback?: string | null,\n): string {\n if (fallback) {\n return fallback;\n }\n const match =\n /(?:query|mutation|subscription)\\s+([A-Za-z_][A-Za-z0-9_]*)/i.exec(query);\n return match?.[1] ?? 'Unnamed operation';\n}\n\ntype StoreShape = CollectionsState & { actions: CollectionsActions };\n\n/** Drop every link that points at one of `itemIds`. */\nfunction pruneLinksForItems(\n links: Record<string, TabLink>,\n itemIds: Set<string>,\n): Record<string, TabLink> {\n const next: Record<string, TabLink> = {};\n for (const [tabId, link] of Object.entries(links)) {\n if (!itemIds.has(link.itemId)) {\n next[tabId] = link;\n }\n }\n return next;\n}\n\n/** Normalize optional string fields so undefined and '' are treated identically. */\nconst norm = (v: string | undefined): string => v ?? '';\n\n/** Compare only the user-visible content fields of two items, ignoring id and timestamps. */\nfunction itemContentEqual(a: CollectionItem, b: CollectionItem): boolean {\n return (\n a.name === b.name &&\n norm(a.query) === norm(b.query) &&\n norm(a.variables) === norm(b.variables) &&\n norm(a.headers) === norm(b.headers)\n );\n}\n\nexport const collectionsStore = createStore<StoreShape>((set, get) => {\n let pendingDialog:\n | { resolve: (saved: boolean) => void; reject: (error: unknown) => void }\n | undefined;\n let committingDialog = false;\n let lastPersist: Promise<void> = Promise.resolve();\n const queueWrite = async (write: () => Promise<void>) => {\n const previous = lastPersist;\n let release!: () => void;\n lastPersist = new Promise<void>(resolve => {\n release = resolve;\n });\n await previous;\n try {\n await write();\n } finally {\n release();\n }\n };\n const persist = async () => {\n try {\n await queueWrite(() => get().storage.save(get().collections));\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to persist collections', error);\n }\n };\n\n return {\n collections: [],\n loaded: false,\n storage: localStorageAdapter,\n config: DEFAULT_COLLECTIONS_CONFIG,\n links: {},\n saveDialog: INITIAL_SAVE_DIALOG,\n actions: {\n async init(storage, config) {\n const collections = await storage.load();\n set({\n collections,\n loaded: true,\n storage,\n config: { ...DEFAULT_COLLECTIONS_CONFIG, ...config },\n // Restore tab↔item links so ⌘S on a tab reopened from the previous\n // session still updates its saved operation in place.\n links: loadTabLinks(),\n });\n },\n setCollections(collections) {\n set({ collections });\n },\n async reload() {\n const collections = await get().storage.load();\n set({ collections });\n },\n createCollection(name, description) {\n const c: Collection = {\n id: randomId(),\n name,\n description,\n items: [],\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({ collections: [...s.collections, c] }));\n void persist();\n return c;\n },\n deleteCollection(id) {\n const removed = get().collections.find(c => c.id === id);\n const removedItemIds = new Set(removed?.items.map(i => i.id) ?? []);\n set(s => ({\n collections: s.collections.filter(c => c.id !== id),\n links: pruneLinksForItems(s.links, removedItemIds),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n renameCollection(id, name) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === id ? { ...c, name, updatedAt: Date.now() } : c,\n ),\n }));\n void persist();\n },\n addItem(collectionId, item) {\n const newItem: CollectionItem = {\n ...item,\n id: randomId(),\n createdAt: Date.now(),\n updatedAt: Date.now(),\n };\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? { ...c, items: [...c.items, newItem], updatedAt: Date.now() }\n : c,\n ),\n }));\n void persist();\n return newItem;\n },\n updateItem(collectionId, itemId, updates) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n updatedAt: Date.now(),\n items: c.items.map(i =>\n i.id === itemId\n ? { ...i, ...updates, updatedAt: Date.now() }\n : i,\n ),\n }\n : c,\n ),\n }));\n void persist();\n },\n deleteItem(collectionId, itemId) {\n set(s => ({\n collections: s.collections.map(c =>\n c.id === collectionId\n ? {\n ...c,\n items: c.items.filter(i => i.id !== itemId),\n updatedAt: Date.now(),\n }\n : c,\n ),\n links: pruneLinksForItems(s.links, new Set([itemId])),\n }));\n void persist();\n saveTabLinks(get().links);\n },\n moveItem(fromCollectionId, fromIndex, toCollectionId, toIndex) {\n const { collections } = get();\n const fromCollection = collections.find(c => c.id === fromCollectionId);\n if (\n !fromCollection ||\n fromIndex < 0 ||\n fromIndex >= fromCollection.items.length\n ) {\n return;\n }\n\n const item = fromCollection.items[fromIndex];\n if (!item) {\n return;\n }\n const newCollections = collections.map(c => {\n if (c.id === fromCollectionId && c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(fromIndex, 1);\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n if (c.id === fromCollectionId) {\n return {\n ...c,\n items: c.items.filter((_, i) => i !== fromIndex),\n updatedAt: Date.now(),\n };\n }\n if (c.id === toCollectionId) {\n const items = [...c.items];\n items.splice(toIndex, 0, item);\n return { ...c, items, updatedAt: Date.now() };\n }\n return c;\n });\n set({ collections: newCollections });\n void persist();\n },\n analyzeImport(json) {\n const empty: ImportAnalysis = {\n ok: false,\n newCollections: [],\n newItems: [],\n changedItems: [],\n unchangedCount: 0,\n _incoming: [],\n };\n\n // Zod schemas for the import envelope.\n const CollectionItemSchema = z.object({\n id: z.string(),\n name: z.string(),\n query: z.string(),\n variables: z.string().optional(),\n headers: z.string().optional(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n });\n\n const CollectionSchema = z.object({\n id: z.string(),\n name: z.string(),\n description: z.string().optional(),\n createdAt: z.number(),\n updatedAt: z.number(),\n items: z.array(CollectionItemSchema),\n });\n\n const EnvelopeSchema = z.union([\n z.object({\n version: z.number().optional(),\n collections: z.array(CollectionSchema),\n }),\n z.array(CollectionSchema),\n ]);\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(json);\n } catch {\n return empty;\n }\n\n const result = EnvelopeSchema.safeParse(parsed);\n if (!result.success) {\n return empty;\n }\n\n const incoming: Collection[] = Array.isArray(result.data)\n ? result.data\n : result.data.collections;\n\n if (incoming.length === 0) {\n return empty;\n }\n\n const localCollections = get().collections;\n\n // Build a flat map: item id → { item, collectionId } for all local items.\n const localItemMap = new Map<\n string,\n { item: CollectionItem; collectionId: string }\n >();\n for (const col of localCollections) {\n for (const item of col.items) {\n localItemMap.set(item.id, { item, collectionId: col.id });\n }\n }\n\n const localCollectionIds = new Set(localCollections.map(c => c.id));\n\n const newCollections: Collection[] = [];\n const newItems: ImportAnalysis['newItems'] = [];\n const changedItems: ImportAnalysis['changedItems'] = [];\n let unchangedCount = 0;\n\n for (const incomingCol of incoming) {\n // Determine which items in this collection are genuinely new locally.\n const genuinelyNewItems = incomingCol.items.filter(\n item => !localItemMap.has(item.id),\n );\n\n // Register a new collection shell only when:\n // - the collection id is absent locally, AND\n // - it is intentionally empty OR it contributes at least one genuinely new item.\n // A new-to-us collection that only re-homes already-known items must NOT be created.\n if (\n !localCollectionIds.has(incomingCol.id) &&\n (incomingCol.items.length === 0 || genuinelyNewItems.length > 0)\n ) {\n newCollections.push({ ...incomingCol, items: [] });\n }\n\n for (const incomingItem of incomingCol.items) {\n const local = localItemMap.get(incomingItem.id);\n if (!local) {\n newItems.push({\n item: incomingItem,\n // Land in the incoming parent; if that parent is new it will be\n // created during apply, otherwise it already exists locally.\n targetCollectionId: incomingCol.id,\n });\n } else if (itemContentEqual(incomingItem, local.item)) {\n unchangedCount++;\n } else {\n changedItems.push({\n incoming: incomingItem,\n current: local.item,\n // Use where the recipient actually keeps it, not the incoming parent.\n currentCollectionId: local.collectionId,\n });\n }\n }\n }\n\n return {\n ok: true,\n newCollections,\n newItems,\n changedItems,\n unchangedCount,\n _incoming: incoming,\n };\n },\n applyImport(analysis, resolution) {\n if (!analysis.ok) {\n return;\n }\n\n if (resolution.mode === 'replace') {\n set({ collections: analysis._incoming });\n void persist();\n return;\n }\n\n // Merge mode.\n const now = Date.now();\n let collections = [...get().collections];\n\n // 1. Create new collection shells.\n for (const shell of analysis.newCollections) {\n collections.push({ ...shell, items: [] });\n }\n\n // 2. Add new items into their target collections.\n for (const { item, targetCollectionId } of analysis.newItems) {\n collections = collections.map(c =>\n c.id === targetCollectionId\n ? { ...c, items: [...c.items, item], updatedAt: now }\n : c,\n );\n }\n\n // 3. Apply changed items per resolution.\n const shouldApply = (itemId: string): boolean => {\n if ('applyChanges' in resolution) {\n return resolution.applyChanges;\n }\n return resolution.changedItemIds.has(itemId);\n };\n\n for (const conflict of analysis.changedItems) {\n if (!shouldApply(conflict.incoming.id)) {\n continue;\n }\n collections = collections.map(c => {\n if (c.id !== conflict.currentCollectionId) {\n return c;\n }\n return {\n ...c,\n updatedAt: now,\n items: c.items.map(i =>\n i.id === conflict.incoming.id\n ? {\n // Replace content fields; keep the local createdAt.\n ...conflict.incoming,\n createdAt: conflict.current.createdAt,\n updatedAt: now,\n }\n : i,\n ),\n };\n });\n }\n\n set({ collections });\n void persist();\n },\n exportCollections() {\n return JSON.stringify(\n { version: 1, collections: get().collections },\n null,\n 2,\n );\n },\n exportCollection(id) {\n const collection = get().collections.find(c => c.id === id);\n return JSON.stringify(\n { version: 1, collections: collection ? [collection] : [] },\n null,\n 2,\n );\n },\n exportItem(itemId) {\n for (const col of get().collections) {\n const item = col.items.find(i => i.id === itemId);\n if (item) {\n const shell: Collection = {\n id: col.id,\n name: col.name,\n description: col.description,\n createdAt: col.createdAt,\n updatedAt: col.updatedAt,\n items: [item],\n };\n return JSON.stringify(\n { version: 1, collections: [shell] },\n null,\n 2,\n );\n }\n }\n return JSON.stringify({ version: 1, collections: [] }, null, 2);\n },\n linkTab(tabId, collectionId, itemId) {\n set(s => ({\n // An item lives in exactly one tab: drop any stale link to it (e.g. a\n // closed tab's) before recording the new one.\n links: {\n ...pruneLinksForItems(s.links, new Set([itemId])),\n [tabId]: { collectionId, itemId },\n },\n }));\n saveTabLinks(get().links);\n },\n async requestSave(operation) {\n // Authoritative gate: saving is disabled in read-only mode regardless\n // of how it was triggered (⌘S, save button, etc.).\n if (get().config.readOnly) {\n return false;\n }\n if (get().saveDialog.open) {\n return false;\n }\n const { links, collections, actions } = get();\n const link = operation.id ? links[operation.id] : undefined;\n if (link) {\n const collection = collections.find(c => c.id === link.collectionId);\n const item = collection?.items.find(i => i.id === link.itemId);\n if (item) {\n await queueWrite(async () => {\n const target = get()\n .collections.find(c => c.id === link.collectionId)\n ?.items.find(i => i.id === link.itemId);\n if (!target) {\n throw new Error('Saved collection item no longer exists');\n }\n const next = get().collections.map(c =>\n c.id === link.collectionId\n ? {\n ...c,\n updatedAt: Date.now(),\n items: c.items.map(i =>\n i.id === link.itemId\n ? {\n ...i,\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n updatedAt: Date.now(),\n }\n : i,\n ),\n }\n : c,\n );\n await get().storage.save(next);\n set({ collections: next });\n });\n return true;\n }\n }\n actions.openSaveDialog({\n tabId: operation.id,\n query: operation.query ?? '',\n variables: operation.variables ?? '',\n headers: operation.headers ?? '',\n name: deriveOperationName(\n operation.query ?? '',\n operation.operationName,\n ),\n });\n return new Promise<boolean>((resolve, reject) => {\n pendingDialog = { resolve, reject };\n });\n },\n async commitSaveDialog(input) {\n const { saveDialog, collections } = get();\n if (!saveDialog.open || committingDialog) {\n return;\n }\n if (\n input.collectionId &&\n !collections.some(c => c.id === input.collectionId)\n ) {\n const error = new Error('Selected collection no longer exists');\n pendingDialog?.reject(error);\n pendingDialog = undefined;\n get().actions.closeSaveDialog();\n throw error;\n }\n committingDialog = true;\n const now = Date.now();\n const item: CollectionItem = {\n id: randomId(),\n name: input.name || 'Unnamed operation',\n description: input.description || undefined,\n query: saveDialog.query,\n variables: saveDialog.variables,\n headers: saveDialog.headers,\n createdAt: now,\n updatedAt: now,\n };\n const collectionId = input.collectionId ?? randomId();\n try {\n await queueWrite(async () => {\n if (\n input.collectionId &&\n !get().collections.some(c => c.id === collectionId)\n ) {\n throw new Error('Selected collection no longer exists');\n }\n const next = input.collectionId\n ? get().collections.map(c =>\n c.id === collectionId\n ? { ...c, items: [...c.items, item], updatedAt: now }\n : c,\n )\n : [\n ...get().collections,\n {\n id: collectionId,\n name: input.newCollectionName || 'New Collection',\n items: [item],\n createdAt: now,\n updatedAt: now,\n },\n ];\n await get().storage.save(next);\n set({ collections: next });\n });\n if (saveDialog.tabId) {\n get().actions.linkTab(saveDialog.tabId, collectionId, item.id);\n }\n pendingDialog?.resolve(true);\n pendingDialog = undefined;\n committingDialog = false;\n get().actions.closeSaveDialog();\n } catch (error) {\n pendingDialog?.reject(error);\n pendingDialog = undefined;\n committingDialog = false;\n get().actions.closeSaveDialog();\n throw error;\n }\n },\n openSaveDialog(input) {\n set(s => ({\n saveDialog: {\n ...input,\n open: true,\n requestId: (s.saveDialog.requestId ?? 0) + 1,\n },\n }));\n },\n closeSaveDialog() {\n if (committingDialog) {\n return;\n }\n pendingDialog?.resolve(false);\n pendingDialog = undefined;\n set(s => ({ saveDialog: { ...s.saveDialog, open: false } }));\n },\n },\n };\n});\n\nexport const useCollectionsStore = createBoundedUseStore(collectionsStore);\n"],"mappings":";;;;;;;;AA4GA,IAAM,sBAAuC;CAC3C,MAAM;CACN,WAAW;CACX,OAAO;CACP,WAAW;CACX,SAAS;CACT,MAAM;AACR;AAEA,SAAgB,oBACd,OACA,UACQ;CACR,IAAI,UACF,OAAO;CAIT,OADE,8DAA8D,KAAK,KAC9D,CAAA,GAAQ,MAAM;AACvB;;AAKA,SAAS,mBACP,OACA,SACyB;CACzB,MAAM,OAAgC,CAAC;CACvC,KAAK,MAAM,CAAC,OAAO,SAAS,OAAO,QAAQ,KAAK,GAC9C,IAAI,CAAC,QAAQ,IAAI,KAAK,MAAM,GAC1B,KAAK,SAAS;CAGlB,OAAO;AACT;;AAGA,IAAM,QAAQ,MAAkC,KAAK;;AAGrD,SAAS,iBAAiB,GAAmB,GAA4B;CACvE,OACE,EAAE,SAAS,EAAE,QACb,KAAK,EAAE,KAAK,MAAM,KAAK,EAAE,KAAK,KAC9B,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,qBAAqB;OACjC,OAAO,CAAC,IAAI;OACZ,WAAW;OACX,WAAW;MACb,CACF;MACJ,MAAM,IAAI,CAAC,CAAC,QAAQ,KAAK,IAAI;MAC7B,IAAI,EAAE,aAAa,KAAK,CAAC;KAC3B,CAAC;KACD,IAAI,WAAW,OACb,IAAI,CAAC,CAAC,QAAQ,QAAQ,WAAW,OAAO,cAAc,KAAK,EAAE;KAE/D,eAAe,QAAQ,IAAI;KAC3B,gBAAgB,KAAA;KAChB,mBAAmB;KACnB,IAAI,CAAC,CAAC,QAAQ,gBAAgB;IAChC,SAAS,OAAO;KACd,eAAe,OAAO,KAAK;KAC3B,gBAAgB,KAAA;KAChB,mBAAmB;KACnB,IAAI,CAAC,CAAC,QAAQ,gBAAgB;KAC9B,MAAM;IACR;GACF;GACA,eAAe,OAAO;IACpB,KAAI,OAAM,EACR,YAAY;KACV,GAAG;KACH,MAAM;KACN,YAAY,EAAE,WAAW,aAAa,KAAK;IAC7C,EACF,EAAE;GACJ;GACA,kBAAkB;IAChB,IAAI,kBACF;IAEF,eAAe,QAAQ,KAAK;IAC5B,gBAAgB,KAAA;IAChB,KAAI,OAAM,EAAE,YAAY;KAAE,GAAG,EAAE;KAAY,MAAM;IAAM,EAAE,EAAE;GAC7D;EACF;CACF;AACF,CAAC;AAED,IAAa,sBAAsB,sBAAsB,gBAAgB"}
package/dist/types.js CHANGED
@@ -1,10 +1,9 @@
1
- //#region src/types.ts
1
+ // src/types.ts
2
2
  var DEFAULT_COLLECTIONS_CONFIG = {
3
3
  readOnly: false,
4
4
  allowImportExport: true,
5
5
  allowReplace: true
6
6
  };
7
- //#endregion
8
7
  export { DEFAULT_COLLECTIONS_CONFIG };
9
8
 
10
9
  //# sourceMappingURL=types.js.map
@@ -1,4 +1,4 @@
1
- //#region src/utility/uuid.ts
1
+ // src/utility/uuid.ts
2
2
  /** Stable unique id for collections and operations. Uses `crypto.randomUUID`
3
3
  * when available, falling back to a timestamp + random suffix on plain http
4
4
  * where `crypto.randomUUID` is undefined. */
@@ -7,7 +7,6 @@ function randomId() {
7
7
  if (c && typeof c.randomUUID === "function") return c.randomUUID();
8
8
  return `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
9
9
  }
10
- //#endregion
11
10
  export { randomId };
12
11
 
13
12
  //# sourceMappingURL=uuid.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphiql/plugin-collections",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "sideEffects": [
5
5
  "*.css"
6
6
  ],
@@ -32,32 +32,32 @@
32
32
  "dist"
33
33
  ],
34
34
  "dependencies": {
35
- "zod": "^4.0.0",
35
+ "zod": "^4.6.6",
36
36
  "zustand": "^5"
37
37
  },
38
38
  "peerDependencies": {
39
- "@graphiql/react": "^1.0.0",
39
+ "@graphiql/react": "^1.0.1",
40
40
  "graphql": "^16.11.0 || ^17.0.0",
41
41
  "react": "^18 || ^19",
42
42
  "react-dom": "^18 || ^19"
43
43
  },
44
44
  "devDependencies": {
45
- "@graphiql/react": "^1.0.0",
45
+ "@graphiql/react": "^1.0.1",
46
46
  "@storybook/react-vite": "^10.3.6",
47
47
  "@testing-library/dom": "^10.4.0",
48
48
  "@testing-library/jest-dom": "^7.0.1",
49
49
  "@testing-library/react": "^16.3.0",
50
50
  "@types/react": "^19",
51
51
  "@types/react-dom": "^19",
52
- "@typescript/native": "npm:typescript@7.1.0-beta",
53
- "@vitejs/plugin-react": "^5.2.0",
52
+ "@typescript/native": "npm:typescript@^7.0.2",
53
+ "@vitejs/plugin-react": "^6.1.2",
54
54
  "graphql": "^17.0.2",
55
55
  "react": "^19.1.0",
56
56
  "react-dom": "^19.1.0",
57
- "vite": "^8.2.2",
58
- "vite-plugin-dts": "^4.5.3",
57
+ "vite": "^8.3.5",
58
+ "vite-plugin-dts": "^5.1.2",
59
59
  "vite-plugin-svgr": "^5.2.0",
60
- "typescript": "^5.8.0"
60
+ "typescript": "npm:@typescript/typescript6@^6.0.2"
61
61
  },
62
62
  "scripts": {
63
63
  "types:check": "tsc --noEmit",
@@ -1 +0,0 @@
1
- {"version":3,"file":"check.js","names":[],"sources":["../../src/icons/check.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgCheck = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tviewBox: \"0 0 16 16\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", {\n\t\tstroke: \"currentColor\",\n\t\tstrokeLinecap: \"round\",\n\t\tstrokeLinejoin: \"round\",\n\t\tstrokeWidth: 1.75,\n\t\td: \"m3.5 8.5 3 3 6-7\"\n\t})]\n});\nexport default SvgCheck;\n"],"mappings":";;;AAEA,IAAM,YAAY,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAC/E,OAAO;CACP,MAAM;CACN,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ;EACvC,QAAQ;EACR,eAAe;EACf,gBAAgB;EAChB,aAAa;EACb,GAAG;CACJ,CAAC,CAAC;AACH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"collections.js","names":[],"sources":["../../src/icons/collections.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgCollections = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"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\" })]\n});\nexport default SvgCollections;\n"],"mappings":";;;AAEA,IAAM,kBAAkB,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CACrF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,8EAA8E,CAAC,CAAC;AAC9H,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"download.js","names":[],"sources":["../../src/icons/download.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgDownload = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", { d: \"M12 3v11m-5-4 5 4 5-4M4 20h16\" })]\n});\nexport default SvgDownload;\n"],"mappings":";;;AAEA,IAAM,eAAe,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAClF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC;AAChF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"upload.js","names":[],"sources":["../../src/icons/upload.svg?react"],"sourcesContent":["import * as React from \"react\";\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst SvgUpload = ({ title, titleId, ...props }) => /* @__PURE__ */ _jsxs(\"svg\", {\n\txmlns: \"http://www.w3.org/2000/svg\",\n\tfill: \"none\",\n\tstroke: \"currentColor\",\n\tstrokeLinecap: \"round\",\n\tstrokeLinejoin: \"round\",\n\tstrokeWidth: 2,\n\tviewBox: \"0 0 24 24\",\n\t\"aria-labelledby\": titleId,\n\t...props,\n\tchildren: [title ? /* @__PURE__ */ _jsx(\"title\", {\n\t\tid: titleId,\n\t\tchildren: title\n\t}) : null, /* @__PURE__ */ _jsx(\"path\", { d: \"M12 21V10m-5 4 5-4 5 4M4 4h16\" })]\n});\nexport default SvgUpload;\n"],"mappings":";;;AAEA,IAAM,aAAa,EAAE,OAAO,SAAS,GAAG,YAA4B,qBAAM,OAAO;CAChF,OAAO;CACP,MAAM;CACN,QAAQ;CACR,eAAe;CACf,gBAAgB;CAChB,aAAa;CACb,SAAS;CACT,mBAAmB;CACnB,GAAG;CACH,UAAU,CAAC,QAAwB,oBAAK,SAAS;EAChD,IAAI;EACJ,UAAU;CACX,CAAC,IAAI,MAAsB,oBAAK,QAAQ,EAAE,GAAG,gCAAgC,CAAC,CAAC;AAChF,CAAC"}