{"id":16786450,"url":"https://github.com/pklaschka/xd-storage-helper","last_synced_at":"2025-07-27T11:35:08.209Z","repository":{"id":33558913,"uuid":"155054421","full_name":"pklaschka/xd-storage-helper","owner":"pklaschka","description":"A little helper to make storing key-value-pairs (e.g. settings) for Adobe XD plugins easier.","archived":false,"fork":false,"pushed_at":"2024-06-16T10:15:50.000Z","size":588,"stargazers_count":24,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-07T16:42:23.020Z","etag":null,"topics":["adobe","extensibility","helper","plugins","storage","utility","xd"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/xd-storage-helper","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pklaschka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-28T09:29:46.000Z","updated_at":"2024-11-13T12:42:25.000Z","dependencies_parsed_at":"2024-01-09T03:01:40.796Z","dependency_job_id":"f5b1116f-c68b-496e-a6ca-52fd5b0fd5ab","html_url":"https://github.com/pklaschka/xd-storage-helper","commit_stats":{"total_commits":122,"total_committers":5,"mean_commits":24.4,"dds":0.6311475409836065,"last_synced_commit":"6592c5fe95374c0fa3eb9182cd9cf489fbd0f681"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklaschka%2Fxd-storage-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklaschka%2Fxd-storage-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklaschka%2Fxd-storage-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pklaschka%2Fxd-storage-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pklaschka","download_url":"https://codeload.github.com/pklaschka/xd-storage-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841202,"owners_count":20356441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adobe","extensibility","helper","plugins","storage","utility","xd"],"created_at":"2024-10-13T08:12:16.565Z","updated_at":"2025-03-17T02:31:50.092Z","avatar_url":"https://github.com/pklaschka.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# :file_folder: xd-storage-helper\n\n[![Build Status](https://travis-ci.com/pklaschka/xd-storage-helper.svg?branch=master)](https://travis-ci.com/pklaschka/xd-storage-helper)\n[![npm version](https://badge.fury.io/js/xd-storage-helper.svg)](https://badge.fury.io/js/xd-storage-helper)\n![David](https://img.shields.io/david/pklaschka/xd-storage-helper.svg)\n[![Maintainability](https://api.codeclimate.com/v1/badges/51782a0bf71f3c02260a/maintainability)](https://codeclimate.com/github/pklaschka/xd-storage-helper/maintainability)\n\n\n[![NPM](https://nodei.co/npm/xd-storage-helper.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/xd-storage-helper/)\n\n---\n\nA little helper to make storing key-value-pairs (e.g. settings) for plugins for Adobe XD CC easier.\n\nIt allows to\n- Store settings with key-value-pairs\n- Retrieve settings (or default values, if nothing was previously saved)\n- Reset the settings\n\n## Usage\n\n### Option 1: With a package manager (npm)\nIf you already use a package manager like npm or yarn and have a bundler like webpack for your plugin, you can simply integrate the helper by running\n```\nnpm install xd-storage-helper\n```\n\nor\n\n```\nyarn add xd-storage-helper\n```\n\nin a terminal inside your project folder. After that, you can simply get a reference to the helper by using\n\n```javascript\nconst storageHelper = require('xd-storage-helper');\n```\n\nand access its static functions (e.g., `storageHelper.set([...])`).\n\n### Option 2: Without a package manager\nFirst, you'll need to copy the `storage-helper.js` file into your project. In this case, it gets inserted in a `lib`-folder (relative to the plugin's root folder). Then, the folder structure should be something like this:\n\n* lib\n  * storage-helper.js\n* main.js\n* mainfest.json\n\nAll functions are static members of the `storageHelper`. Therefore, you simply need to get a reference to it in your code (here from the `main.js` file):\n```javascript\nconst storageHelper = require('./lib/storage-helper')\n```\n\nAfter that, you can simply call the different functions on the `storageHelper` class.\n\n## Example\nOne common example would be to fill form fields in a dialog with previously used values while I won't show the whole boilerplate code for creating the dialog here (please refer to the Adobe XD plugin documentation for that), here is the basic concept of how to do it:\n\n```javascript\nconst storageHelper = require('./lib/storage-helper') // or const storageHelper = require('xd-storage-helper') if you chose option 1\n\n// [...] Create the dialog, so that you have a reference to your text input with the name myInput\n\nconst lastInput = await storageHelper.get('myLastInput', 'my default value'); // Retrieves last input or default 'my default value', if nothing is saved\nmyInput.value = lastInput; // and sets it as the input's default value\n\n// [...]\n\nfunction onsubmit() {\n  storageHelper.set('myLastInput', myInput.value).then(() =\u003e { // Save value when form gets submitted\n    dialog.close(myInput.value); // And then close the dialog\n  }); \n}\nform.onsubmit = onsubmit;\n\nconst result = await dialog.showModal();\n\n// [...] Do stuff with the results\n```\n\n## Functions reference\nHere is a list of the functions you can call:\n\n#### `storageHelper.get(key: string, defaultValue:*): Promise\u003c*\u003e`\nRetrieves a value from storage. Saves default value if none is set.\n\nParameters:\n* `key: string`: The identifier (the key of the key-value-pair)\n* `defaultValue: *`: The default value. Gets saved and returned if no value was previously set for the speciefied key.\n\nReturns:\nPromise for the value retrieved from storage. If none is saved, the `defaultValue` is returned.\n\n\n#### `storageHelper.set(key: string, value:*): Promise\u003cvoid\u003e`\nSaves a certain key-value-pair to the storage.\n\nParameters:\n* `key: string`: The identifier (the key of the key-value-pair)\n* `value: *`: The value that get's saved\n\nReturns:\nPromise that resolves when the value got saved successfully\n\n#### `storageHelper.delete(key: string): Promise\u003cvoid\u003e`\nDeletes a certain key-value-pair from the storage\n\nParameters:\n* `key: string`: The identifier (the key of the key-value-pair)\n\nReturns:\nPromise that resolves when the value got deleted successfully\n\n#### `storageHelper.reset(): Promise\u003cvoid\u003e`\nResets (i.e. purges) all stored settings.\n\nReturns:\nPromise that resolves when the storage got reset\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpklaschka%2Fxd-storage-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpklaschka%2Fxd-storage-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpklaschka%2Fxd-storage-helper/lists"}