From 640ed3f45d71dbd5fe5e67de49aea6e6dc717132 Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:49:28 +0300 Subject: [PATCH 01/12] feat: setup package build system for sync providers --- packages/sync-providers/jest.config.ts | 201 ++++++++++++++++++ packages/sync-providers/package.json | 22 +- .../src/constants/BoxShadowTypes.ts | 4 + .../src/constants/EditTokenFormStatus.ts | 5 + packages/sync-providers/src/index.ts | 3 + .../providers/github/GitHubTokenStorage.ts | 6 +- packages/sync-providers/tsconfig.json | 1 + packages/sync-providers/tsup.config.ts | 13 ++ 8 files changed, 251 insertions(+), 4 deletions(-) create mode 100644 packages/sync-providers/jest.config.ts create mode 100644 packages/sync-providers/src/constants/BoxShadowTypes.ts create mode 100644 packages/sync-providers/src/constants/EditTokenFormStatus.ts create mode 100644 packages/sync-providers/src/index.ts create mode 100644 packages/sync-providers/tsup.config.ts diff --git a/packages/sync-providers/jest.config.ts b/packages/sync-providers/jest.config.ts new file mode 100644 index 000000000..603b727eb --- /dev/null +++ b/packages/sync-providers/jest.config.ts @@ -0,0 +1,201 @@ +// @ts-ignore This is due to weird @types/node issues based on hoistng +require('dotenv').config(); + +/* + * For a detailed explanation regarding each configuration property and type check, visit: + * https://jestjs.io/docs/en/configuration.html + */ + +export default { + // All imported modules in your tests should be mocked automatically + // automock: false, + + // Stop running tests after `n` failures + // bail: 0, + + // The directory where Jest should store its cached dependency information + // cacheDirectory: "/tmp/jest_rs", + + // Automatically clear mock calls and instances between every test + clearMocks: true, + + // Indicates whether the coverage information should be collected while executing the test + collectCoverage: true, + + // An array of glob patterns indicating a set of files for which coverage information should be collected + // collectCoverageFrom: undefined, + + // The directory where Jest should output its coverage files + coverageDirectory: 'coverage', + + // An array of regexp pattern strings used to skip coverage collection + // coveragePathIgnorePatterns: [ + // "/node_modules/" + // ], + + // Indicates which provider should be used to instrument code for coverage + // coverageProvider: "babel", + + // A list of reporter names that Jest uses when writing coverage reports + coverageReporters: [ + 'json', + 'text', + 'lcov', + 'clover', + ], + + // An object that configures minimum threshold enforcement for coverage results + // coverageThreshold: undefined, + + // A path to a custom dependency extractor + // dependencyExtractor: undefined, + + // Make calling deprecated APIs throw helpful error messages + // errorOnDeprecated: false, + + // Force coverage collection from ignored files using an array of glob patterns + // forceCoverageMatch: [], + + // A path to a module which exports an async function that is triggered once before all test suites + // globalSetup: undefined, + + // A path to a module which exports an async function that is triggered once after all test suites + // globalTeardown: undefined, + + // A set of global variables that need to be available in all test environments + // globals: { + // "ts-jest": { + // babelConfig: true, + // }, + // }, + + // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers. + // maxWorkers: "50%", + + // An array of directory names to be searched recursively up from the requiring module's location + moduleDirectories: ['node_modules', 'src'], + + // An array of file extensions your modules use + // moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], + + // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module + moduleNameMapper: { + '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': + '/tests/__mocks__/fileMock.js', + '\\.(css)$': '/tests/__mocks__/styleMock.js', + '^@/(.*)$': '/src/$1', + '^@/types/(.*)$': '/src/types/$1', + }, + + // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader + // modulePathIgnorePatterns: [], + + // Activates notifications for test results + // notify: false, + + // An enum that specifies notification mode. Requires { notify: true } + // notifyMode: "failure-change", + + // A preset that is used as a base for Jest's configuration + // preset: 'ts-jest', + + // Run tests from one or more projects + // projects: undefined, + + // Use this configuration option to add custom reporters to Jest + // reporters: undefined, + + // Automatically reset mock state between every test + // resetMocks: false, + + // Reset the module registry before running each individual test + // resetModules: false, + + // A path to a custom resolver + // resolver: undefined, + + // Automatically restore mock state between every test + // restoreMocks: false, + + // The root directory that Jest should scan for tests and modules within + // rootDir: undefined, + + // A list of paths to directories that Jest should use to search for files in + // roots: [ + // "" + // ], + + // Allows you to use a custom runner instead of Jest's default test runner + // runner: "jest-runner", + + // The paths to modules that run some code to configure or set up the testing environment before each test + setupFiles: [ + './tests/__mocks__/textEncoderDecoderMock.js', + './tests/__mocks__/octokitRestMock.js', + './tests/__mocks__/figmaMock.js', + './tests/__mocks__/mixpanelMock.js', + './tests/__mocks__/supernovaMock.js', + './tests/__mocks__/domRect.js', + './tests/__mocks__/i18nMock.js', + ], + + // A list of paths to modules that run some code to configure or set up the testing framework before each test + // setupFilesAfterEnv: [], + + // The number of seconds after which a test is considered as slow and reported as such in the results. + // slowTestThreshold: 5, + + // A list of paths to snapshot serializer modules Jest should use for snapshot testing + // snapshotSerializers: [], + + // The test environment that will be used for testing + testEnvironment: 'jsdom', + + // Options that will be passed to the testEnvironment + // testEnvironmentOptions: {}, + + // Adds a location field to test results + // testLocationInResults: false, + + // The glob patterns Jest uses to detect test files + // testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'], + testMatch: ['**/?(*.)+(spec|test).[tj]s?(x)'], + + // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped + testPathIgnorePatterns: ['/node_modules/', '/cypress/', '/dist/', '/token-transformer/'], + + // The regexp pattern or array of patterns that Jest uses to detect test files + // testRegex: [], + + // This option allows the use of a custom results processor + // testResultsProcessor: undefined, + + // This option allows use of a custom test runner + // testRunner: "jasmine2", + + // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href + // testURL: "http://localhost", + + // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout" + // timers: "real", + + // A map from regular expressions to paths to transformers + // transform: { + // "node_modules/(react-dnd|dnd-core|@react-dnd)/.+\\.(j|t)sx?$": "ts-jest", + // "^.+\\.js$": "babel-jest", + // }, + // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation + transformIgnorePatterns: ['/node_modules/(?!(@figma-plugin|react-dnd|@react-dnd|react-colorful|dnd-core|react-dnd-html5-backend|culori|dot-prop)/)', '\\.pnp\\.[^\\/]+$'], + + // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them + // unmockedModulePathPatterns: undefined, + + // Indicates whether each individual test should be reported during the run + // verbose: undefined, + + // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode + // watchPathIgnorePatterns: [], + + // Whether to use watchman for file crawling + // watchman: true, +}; diff --git a/packages/sync-providers/package.json b/packages/sync-providers/package.json index cc8bcbecd..1bf4def45 100644 --- a/packages/sync-providers/package.json +++ b/packages/sync-providers/package.json @@ -1,9 +1,25 @@ { "name": "sync-providers", + "private": true, "version": "1.0.0", "description": "A collection of helper functions for syncing data between different providers", - "main": "index.js", + "main": "./dist/index.cjs", + "module": "./dist/index.js", + "type": "module", + "exports": { + ".": { + "import": { + "types": "./dist/types/index.d.ts", + "default": "./dist/index.js" + }, + "require": { + "types": "./dist/types/index.d.cts", + "default": "./dist/index.cjs" + } + } + }, "scripts": { + "build": "tsup", "lint": "eslint . --quiet --fix", "lint:nofix": "eslint ." }, @@ -24,6 +40,7 @@ }, "devDependencies": { "@figma/plugin-typings": "^1.99.0", + "@types/jest": "^29.5.12", "@types/node": "^22.5.2", "@typescript-eslint/eslint-plugin": "^6.11.0", "@typescript-eslint/parser": "^6.11.0", @@ -35,6 +52,7 @@ "eslint-plugin-jsx-a11y": "^6.5.1", "eslint-plugin-react": "^7.27.1", "eslint-plugin-react-hooks": "^4.4.0", - "eslint-plugin-validate-jsx-nesting": "^0.1.1" + "eslint-plugin-validate-jsx-nesting": "^0.1.1", + "tsup": "^8.2.4" } } diff --git a/packages/sync-providers/src/constants/BoxShadowTypes.ts b/packages/sync-providers/src/constants/BoxShadowTypes.ts new file mode 100644 index 000000000..b32c3a5cc --- /dev/null +++ b/packages/sync-providers/src/constants/BoxShadowTypes.ts @@ -0,0 +1,4 @@ +export enum BoxShadowTypes { + DROP_SHADOW = 'dropShadow', + INNER_SHADOW = 'innerShadow', +} diff --git a/packages/sync-providers/src/constants/EditTokenFormStatus.ts b/packages/sync-providers/src/constants/EditTokenFormStatus.ts new file mode 100644 index 000000000..af523e032 --- /dev/null +++ b/packages/sync-providers/src/constants/EditTokenFormStatus.ts @@ -0,0 +1,5 @@ +export enum EditTokenFormStatus { + CREATE = 'create', + EDIT = 'edit', + DUPLICATE = 'duplicate', +} diff --git a/packages/sync-providers/src/index.ts b/packages/sync-providers/src/index.ts new file mode 100644 index 000000000..2d588e932 --- /dev/null +++ b/packages/sync-providers/src/index.ts @@ -0,0 +1,3 @@ +import { GithubTokenStorage } from './providers/github/GitHubTokenStorage'; + +export { GithubTokenStorage }; diff --git a/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts b/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts index 96eb62a4b..d5ce11b8a 100644 --- a/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts +++ b/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts @@ -1,5 +1,7 @@ import compact from 'just-compact'; import { Octokit } from '@octokit/rest'; +import commitMultipleFiles from 'octokit-commit-multiple-files'; + import type { RemoteTokenstorageErrorMessage, RemoteTokenStorageFile, RemoteTokenStorageMetadata } from '../../types'; import { isJSONString, joinPath } from '../../utils'; import { @@ -55,7 +57,7 @@ export class GithubTokenStorage extends GitTokenStorage { }; // eslint-disable-next-line - const ExtendedOctokitConstructor = Octokit.plugin(require('octokit-commit-multiple-files')); + const ExtendedOctokitConstructor = Octokit.plugin(commitMultipleFiles); this.octokitClient = new ExtendedOctokitConstructor({ auth: this.secret, baseUrl: this.baseUrl || undefined, @@ -272,7 +274,7 @@ export class GithubTokenStorage extends GitTokenStorage { } public async createOrUpdate(changeset: Record, message: string, branch: string, shouldCreateBranch?: boolean, filesToDelete?: string[], ignoreDeletionFailures?: boolean): Promise { - const response = await this.octokitClient.createOrUpdateFiles({ + const response = await this.octokitClient.repos.createOrUpdateFiles({ branch, owner: this.owner, repo: this.repository, diff --git a/packages/sync-providers/tsconfig.json b/packages/sync-providers/tsconfig.json index e2af8a433..01954d301 100644 --- a/packages/sync-providers/tsconfig.json +++ b/packages/sync-providers/tsconfig.json @@ -48,6 +48,7 @@ "include": [ "flags.d.ts", "jest.config.ts", + "tsup.config.ts", "src/app/components/custom.d.ts", "css.d.ts", "src/**/*.ts", diff --git a/packages/sync-providers/tsup.config.ts b/packages/sync-providers/tsup.config.ts new file mode 100644 index 000000000..3b7267c27 --- /dev/null +++ b/packages/sync-providers/tsup.config.ts @@ -0,0 +1,13 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/index.ts'], + // entry: ['src/**/*.ts'], + dts: true, + bundle: true, + splitting: true, + sourcemap: true, + format: ['esm', 'cjs'], + skipNodeModulesBundle: true, + clean: true, +}); From ff40a444c440d6778c39b4e3dc1c7ee636c6c48d Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Fri, 6 Sep 2024 21:52:05 +0300 Subject: [PATCH 02/12] feat: [WIP] setup initial plugin for variable sync with experimental bootloader + inline plugin messaging --- packages/variables-sync-plugin/bootloader.js | 52 +++++ .../variables-sync-plugin/lib/figmaAPI.js | 93 ++++++++ packages/variables-sync-plugin/manifest.json | 9 + packages/variables-sync-plugin/package.json | 13 ++ .../variables-sync-plugin/webpage/code.js | 65 ++++++ .../variables-sync-plugin/webpage/ui.html | 214 ++++++++++++++++++ 6 files changed, 446 insertions(+) create mode 100644 packages/variables-sync-plugin/bootloader.js create mode 100644 packages/variables-sync-plugin/lib/figmaAPI.js create mode 100644 packages/variables-sync-plugin/manifest.json create mode 100644 packages/variables-sync-plugin/package.json create mode 100644 packages/variables-sync-plugin/webpage/code.js create mode 100644 packages/variables-sync-plugin/webpage/ui.html diff --git a/packages/variables-sync-plugin/bootloader.js b/packages/variables-sync-plugin/bootloader.js new file mode 100644 index 000000000..bbac18e67 --- /dev/null +++ b/packages/variables-sync-plugin/bootloader.js @@ -0,0 +1,52 @@ +figma.showUI( + `` +); + +figma.ui.onmessage = (code) => { + // console.log({ code }); + // if (code === 'RELOAD') { + // figma.showUI( + // `` + // ); + // return; + // } + eval(code); +} + +// figma.ui.onmessage = async (message, props) => { +// if (props.origin !== SITE_URL) { +// return; +// } + +// switch (message.type) { +// case "EVAL": { +// const fn = eval.call(null, message.code); + +// try { +// const result = await fn(figma, message.params); +// figma.ui.postMessage({ +// type: "EVAL_RESULT", +// result, +// id: message.id, +// }); +// } catch (e) { +// figma.ui.postMessage({ +// type: "EVAL_REJECT", +// error: +// typeof e === "string" +// ? e +// : e && typeof e === "object" && "message" in e +// ? e.message +// : null, +// id: message.id, +// }); +// } + +// break; +// } +// } +// }; diff --git a/packages/variables-sync-plugin/lib/figmaAPI.js b/packages/variables-sync-plugin/lib/figmaAPI.js new file mode 100644 index 000000000..9c9786fbf --- /dev/null +++ b/packages/variables-sync-plugin/lib/figmaAPI.js @@ -0,0 +1,93 @@ +/** + * This is a magic file that allows us to run code in the Figma plugin context + * from the iframe. It does this by getting the code as a string, and sending it + * to the plugin via postMessage. The plugin then evals the code and sends the + * result back to the iframe. There are a few caveats: + * 1. The code cannot reference any variables outside of the function. This is + * because the code is stringified and sent to the plugin, and the plugin + * evals it. The plugin has no access to the variables in the iframe. + * 2. The return value of the function must be JSON serializable. This is + * because the result is sent back to the iframe via postMessage, which only + * supports JSON. + * + * You can get around these limitations by passing in the variables you need + * as parameters to the function. + * + * @example + * ```ts + * const result = await figmaAPI.run((figma, {nodeId}) => { + * return figma.getNodeById(nodeId)?.name; + * }, {nodeId: "0:2"}); + * + * console.log(result); // "Page 1" + * ``` + */ +class FigmaAPI { + // private id = 0; + + /** + * Run a function in the Figma plugin context. The function cannot reference + * any variables outside of itself, and the return value must be JSON + * serializable. If you need to pass in variables, you can do so by passing + * them as the second parameter. + */ + run( + fn, + params, + ) { + + return new Promise((resolve, reject) => { + const id = this.id++; + const cb = (event) => { + if ( + event.origin !== "https://www.figma.com" && + event.origin !== "https://staging.figma.com" + ) { + return; + } + + if (event.data.pluginMessage?.type === "EVAL_RESULT") { + if (event.data.pluginMessage.id === id) { + window.removeEventListener("message", cb); + resolve(event.data.pluginMessage.result); + } + } + + if (event.data.pluginMessage?.type === "EVAL_REJECT") { + if (event.data.pluginMessage.id === id) { + window.removeEventListener("message", cb); + const message = event.data.pluginMessage.error; + reject( + new Error( + typeof message === "string" + ? message + : "An error occurred in FigmaAPI.run()", + ), + ); + } + } + }; + window.addEventListener("message", cb); + + const msg = { + pluginMessage: { + type: "EVAL", + code: fn.toString(), + id, + params, + }, + pluginId: "*", + }; + + ["https://www.figma.com", "https://staging.figma.com"].forEach( + (origin) => { + try { + parent.postMessage(msg, origin); + } catch {} + }, + ); + }); + } +} + +export const figmaAPI = new FigmaAPI(); \ No newline at end of file diff --git a/packages/variables-sync-plugin/manifest.json b/packages/variables-sync-plugin/manifest.json new file mode 100644 index 000000000..a650301dc --- /dev/null +++ b/packages/variables-sync-plugin/manifest.json @@ -0,0 +1,9 @@ +{ + "name": "Variables Sync: Beta", + "id": "34512349747178972", + "api": "1.0.0", + "main": "bootloader.js", + "editorType": [ + "figma" + ] +} diff --git a/packages/variables-sync-plugin/package.json b/packages/variables-sync-plugin/package.json new file mode 100644 index 000000000..45601aef6 --- /dev/null +++ b/packages/variables-sync-plugin/package.json @@ -0,0 +1,13 @@ +{ + "name": "variables-sync-plugin", + "private": true, + "version": "0.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/packages/variables-sync-plugin/webpage/code.js b/packages/variables-sync-plugin/webpage/code.js new file mode 100644 index 000000000..70a19575d --- /dev/null +++ b/packages/variables-sync-plugin/webpage/code.js @@ -0,0 +1,65 @@ +const INTER_BOLD = { family: "Inter", style: "Bold" }; +figma.loadFontAsync(INTER_BOLD); +console.log(123); + +figma.ui.onmessage = async (message, props) => { + // console.log({ message, props }, '123'); + // if (props.origin !== SITE_URL) { + // return; + // } + // if (message.type === 'RELOAD') { + // eval(message.code); + // return; + // } + + switch (message.type) { + case "EVAL": { + // const fn = eval.call(null, message.code); + const fn = Function(`"use strict"; return ${message.code}`)(); + + try { + const result = await fn(figma, {}); + figma.ui.postMessage({ + type: "EVAL_RESULT", + result, + id: message.id, + }); + } catch (e) { + figma.ui.postMessage({ + type: "EVAL_REJECT", + error: + typeof e === "string" + ? e + : e && typeof e === "object" && "message" in e + ? e.message + : null, + id: message.id, + }); + } + + break; + } + } +}; + +// getLocalVariableCollectionsAsync + +// figma.ui.onmessage = characters => { +// if (characters === 'RELOAD') { +// window.location.reload(); +// return; +// } +// if (figma.currentPage.selection.length === 0) { +// const text = figma.createText(); +// figma.currentPage.selection = [text]; +// } + +// for (const node of figma.currentPage.selection) { +// if (node.type === 'TEXT') { +// node.fontName = INTER_BOLD; +// node.characters = characters; +// } +// } + +// // figma.closePlugin(); +// } diff --git a/packages/variables-sync-plugin/webpage/ui.html b/packages/variables-sync-plugin/webpage/ui.html new file mode 100644 index 000000000..25be90027 --- /dev/null +++ b/packages/variables-sync-plugin/webpage/ui.html @@ -0,0 +1,214 @@ + + + + From 6b871515a988e1f440b79a27fe25210f7b08015d Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:15:25 +0300 Subject: [PATCH 03/12] fix(exports): sync provider package build fix --- packages/sync-providers/package.json | 14 ++++++++++++-- packages/sync-providers/tsup.config.ts | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/sync-providers/package.json b/packages/sync-providers/package.json index 1bf4def45..50e649202 100644 --- a/packages/sync-providers/package.json +++ b/packages/sync-providers/package.json @@ -1,7 +1,7 @@ { - "name": "sync-providers", + "name": "@tokens-studio/sync-providers", "private": true, - "version": "1.0.0", + "version": "0.0.1", "description": "A collection of helper functions for syncing data between different providers", "main": "./dist/index.cjs", "module": "./dist/index.js", @@ -16,6 +16,16 @@ "types": "./dist/types/index.d.cts", "default": "./dist/index.cjs" } + }, + "./types": { + "import": { + "types": "./dist/types/index.d.ts", + "default": "./dist/types/index.js" + }, + "require": { + "types": "./dist/types/index.d.cts", + "default": "./dist/types/index.cjs" + } } }, "scripts": { diff --git a/packages/sync-providers/tsup.config.ts b/packages/sync-providers/tsup.config.ts index 3b7267c27..7d58b5179 100644 --- a/packages/sync-providers/tsup.config.ts +++ b/packages/sync-providers/tsup.config.ts @@ -1,7 +1,7 @@ import { defineConfig } from 'tsup'; export default defineConfig({ - entry: ['src/index.ts'], + entry: ['src/**/*.ts'], // entry: ['src/**/*.ts'], dts: true, bundle: true, From ab5111dd9f5f70ab614f9f2406e7a01e76229773 Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Thu, 12 Sep 2024 17:17:51 +0300 Subject: [PATCH 04/12] feat: [WIP] vite bundling for variable sync plugin --- .../variables-sync-plugin/figma.manifest.ts | 11 + packages/variables-sync-plugin/package.json | 19 +- packages/variables-sync-plugin/src/index.ts | 0 .../src/plugin/bootloader.ts | 93 ++++++++ .../variables-sync-plugin/src/plugin/code.ts | 66 ++++++ .../variables-sync-plugin/src/ui/index.html | 218 ++++++++++++++++++ .../variables-sync-plugin/src/ui/index.ts | 65 ++++++ packages/variables-sync-plugin/tsconfig.json | 30 +++ .../variables-sync-plugin/tsconfig.node.json | 12 + .../vite.config.plugin.ts | 36 +++ .../variables-sync-plugin/vite.config.ui.ts | 35 +++ 11 files changed, 584 insertions(+), 1 deletion(-) create mode 100644 packages/variables-sync-plugin/figma.manifest.ts create mode 100644 packages/variables-sync-plugin/src/index.ts create mode 100644 packages/variables-sync-plugin/src/plugin/bootloader.ts create mode 100644 packages/variables-sync-plugin/src/plugin/code.ts create mode 100644 packages/variables-sync-plugin/src/ui/index.html create mode 100644 packages/variables-sync-plugin/src/ui/index.ts create mode 100644 packages/variables-sync-plugin/tsconfig.json create mode 100644 packages/variables-sync-plugin/tsconfig.node.json create mode 100644 packages/variables-sync-plugin/vite.config.plugin.ts create mode 100644 packages/variables-sync-plugin/vite.config.ui.ts diff --git a/packages/variables-sync-plugin/figma.manifest.ts b/packages/variables-sync-plugin/figma.manifest.ts new file mode 100644 index 000000000..b58393ae4 --- /dev/null +++ b/packages/variables-sync-plugin/figma.manifest.ts @@ -0,0 +1,11 @@ +// https://www.figma.com/plugin-docs/manifest/ +export default { + name: "Variables Sync: Beta", + id: "34512349747178972", + api: "1.0.0", + main: "bootloader.js", + ui: "index.html", + editorType: [ + "figma" + ] +}; diff --git a/packages/variables-sync-plugin/package.json b/packages/variables-sync-plugin/package.json index 45601aef6..280a30d47 100644 --- a/packages/variables-sync-plugin/package.json +++ b/packages/variables-sync-plugin/package.json @@ -4,10 +4,27 @@ "version": "0.0.0", "description": "", "main": "index.js", + "dependencies": { + "@tokens-studio/sync-providers": "*" + }, "scripts": { + "build:ui": "vite build -c ./vite.config.ui.ts", + "build:plugin": "vite build -c ./vite.config.plugin.ts", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", - "license": "ISC" + "license": "ISC", + "devDependencies": { + "@figma/plugin-typings": "^1.99.0", + "@types/node": "^22.5.4", + "@types/postcss-url": "^10.0.4", + "@types/react": "^18.3.5", + "@types/react-dom": "^18.3.0", + "@vitejs/plugin-react-swc": "^3.7.0", + "postcss-url": "^10.1.3", + "vite": "^5.4.4", + "vite-plugin-generate-file": "^0.2.0", + "vite-plugin-singlefile": "^2.0.2" + } } diff --git a/packages/variables-sync-plugin/src/index.ts b/packages/variables-sync-plugin/src/index.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/variables-sync-plugin/src/plugin/bootloader.ts b/packages/variables-sync-plugin/src/plugin/bootloader.ts new file mode 100644 index 000000000..9592de054 --- /dev/null +++ b/packages/variables-sync-plugin/src/plugin/bootloader.ts @@ -0,0 +1,93 @@ +async function checkUrlExists(url: string) { + try { + const response = await fetch(url, { + referrer: 'http://127.0.0.1:8080' + // mode: 'no-cors', + // headers: { + // Origin: "http://127.0.0.1:8080", + // } + }); + console.log({ response }); + if (!response.ok) { + return false; + } + + return true; + } catch (error) { + console.log({ error }); + return false; + } +} + +async function bootstrap() { + const exists = await checkUrlExists('http://127.0.0.1:8080'); + + console.log({ exists }); + // FIXME: Get this working + if (exists) { + figma.showUI( + `` + ); + figma.ui.onmessage = (code) => { + eval(code); + } + + } else { + figma.showUI(__html__); + + figma.loadFontAsync({ family: "Inter", style: "Bold" }); + console.log(123); + + figma.ui.onmessage = async (message, props) => { + // console.log({ message, props }, '123'); + // if (props.origin !== SITE_URL) { + // return; + // } + // if (message.type === 'RELOAD') { + // eval(message.code); + // return; + // } + + switch (message.type) { + case "EVAL": { + // const fn = eval.call(null, message.code); + const fn = Function(`"use strict"; return ${message.code}`)(); + + try { + const result = await fn(figma, {}); + figma.ui.postMessage({ + type: "EVAL_RESULT", + result, + id: message.id, + }); + } catch (e) { + figma.ui.postMessage({ + type: "EVAL_REJECT", + error: + typeof e === "string" + ? e + : e && typeof e === "object" && "message" in e + ? e.message + : null, + id: message.id, + }); + } + + break; + } + } + }; + } +} + + +bootstrap(); + +// figma.showUI( +// `` +// ); + diff --git a/packages/variables-sync-plugin/src/plugin/code.ts b/packages/variables-sync-plugin/src/plugin/code.ts new file mode 100644 index 000000000..75749cc29 --- /dev/null +++ b/packages/variables-sync-plugin/src/plugin/code.ts @@ -0,0 +1,66 @@ +// const INTER_BOLD = { family: "Inter", style: "Bold" }; + +figma.loadFontAsync({ family: "Inter", style: "Bold" }); +console.log(123); + +figma.ui.onmessage = async (message, props) => { + // console.log({ message, props }, '123'); + // if (props.origin !== SITE_URL) { + // return; + // } + // if (message.type === 'RELOAD') { + // eval(message.code); + // return; + // } + + switch (message.type) { + case "EVAL": { + // const fn = eval.call(null, message.code); + const fn = Function(`"use strict"; return ${message.code}`)(); + + try { + const result = await fn(figma, {}); + figma.ui.postMessage({ + type: "EVAL_RESULT", + result, + id: message.id, + }); + } catch (e) { + figma.ui.postMessage({ + type: "EVAL_REJECT", + error: + typeof e === "string" + ? e + : e && typeof e === "object" && "message" in e + ? e.message + : null, + id: message.id, + }); + } + + break; + } + } +}; + +// getLocalVariableCollectionsAsync + +// figma.ui.onmessage = characters => { +// if (characters === 'RELOAD') { +// window.location.reload(); +// return; +// } +// if (figma.currentPage.selection.length === 0) { +// const text = figma.createText(); +// figma.currentPage.selection = [text]; +// } + +// for (const node of figma.currentPage.selection) { +// if (node.type === 'TEXT') { +// node.fontName = INTER_BOLD; +// node.characters = characters; +// } +// } + +// // figma.closePlugin(); +// } diff --git a/packages/variables-sync-plugin/src/ui/index.html b/packages/variables-sync-plugin/src/ui/index.html new file mode 100644 index 000000000..324d8d521 --- /dev/null +++ b/packages/variables-sync-plugin/src/ui/index.html @@ -0,0 +1,218 @@ + + + + diff --git a/packages/variables-sync-plugin/src/ui/index.ts b/packages/variables-sync-plugin/src/ui/index.ts new file mode 100644 index 000000000..70a19575d --- /dev/null +++ b/packages/variables-sync-plugin/src/ui/index.ts @@ -0,0 +1,65 @@ +const INTER_BOLD = { family: "Inter", style: "Bold" }; +figma.loadFontAsync(INTER_BOLD); +console.log(123); + +figma.ui.onmessage = async (message, props) => { + // console.log({ message, props }, '123'); + // if (props.origin !== SITE_URL) { + // return; + // } + // if (message.type === 'RELOAD') { + // eval(message.code); + // return; + // } + + switch (message.type) { + case "EVAL": { + // const fn = eval.call(null, message.code); + const fn = Function(`"use strict"; return ${message.code}`)(); + + try { + const result = await fn(figma, {}); + figma.ui.postMessage({ + type: "EVAL_RESULT", + result, + id: message.id, + }); + } catch (e) { + figma.ui.postMessage({ + type: "EVAL_REJECT", + error: + typeof e === "string" + ? e + : e && typeof e === "object" && "message" in e + ? e.message + : null, + id: message.id, + }); + } + + break; + } + } +}; + +// getLocalVariableCollectionsAsync + +// figma.ui.onmessage = characters => { +// if (characters === 'RELOAD') { +// window.location.reload(); +// return; +// } +// if (figma.currentPage.selection.length === 0) { +// const text = figma.createText(); +// figma.currentPage.selection = [text]; +// } + +// for (const node of figma.currentPage.selection) { +// if (node.type === 'TEXT') { +// node.fontName = INTER_BOLD; +// node.characters = characters; +// } +// } + +// // figma.closePlugin(); +// } diff --git a/packages/variables-sync-plugin/tsconfig.json b/packages/variables-sync-plugin/tsconfig.json new file mode 100644 index 000000000..4d60ce805 --- /dev/null +++ b/packages/variables-sync-plugin/tsconfig.json @@ -0,0 +1,30 @@ +{ + "compilerOptions": { + "target": "ES2022", + "module": "ES2022", + "moduleResolution": "Node", + "useDefineForClassFields": true, + "skipLibCheck": true, + "esModuleInterop": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "isolatedModules": false, + "noEmit": true, + "jsx": "react-jsx", + "typeRoots": [ + "node_modules/@types", + "node_modules/@figma" + ], + "paths": { + "@common/*": ["./src/common/*"], + "@ui/*": ["./src/ui/*"], + "@plugin/*": ["./src/plugin/*"] + } + }, + "include": [ + "src/**/*.d.ts", + "src/**/*.ts", + "src/**/*.tsx" + ] +} diff --git a/packages/variables-sync-plugin/tsconfig.node.json b/packages/variables-sync-plugin/tsconfig.node.json new file mode 100644 index 000000000..b7445bdb3 --- /dev/null +++ b/packages/variables-sync-plugin/tsconfig.node.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "noEmit": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "Node", + "esModuleInterop": true + }, + "include": [ + "*.ts" + ] +} diff --git a/packages/variables-sync-plugin/vite.config.plugin.ts b/packages/variables-sync-plugin/vite.config.plugin.ts new file mode 100644 index 000000000..af3d1152c --- /dev/null +++ b/packages/variables-sync-plugin/vite.config.plugin.ts @@ -0,0 +1,36 @@ +import path from "node:path"; +import { defineConfig } from "vite"; +import generateFile from "vite-plugin-generate-file"; +import { viteSingleFile } from "vite-plugin-singlefile"; + +import figmaManifest from './figma.manifest'; + +export default defineConfig(({ mode }) => ({ + plugins: [ + viteSingleFile(), + generateFile({ + type: "json", + output: "./manifest.json", + data: figmaManifest, + }), + ], + build: { + minify: mode === 'production', + sourcemap: mode !== 'production' ? 'inline' : false, + target: 'es2017', + emptyOutDir: false, + outDir: path.resolve("dist"), + rollupOptions: { + input: path.resolve('./src/plugin/bootloader.ts'), + output: { + entryFileNames: 'bootloader.js', + }, + }, + }, + resolve: { + alias: { + "@common": path.resolve("./src/common"), + "@plugin": path.resolve("./src/plugin"), + }, + }, +})); diff --git a/packages/variables-sync-plugin/vite.config.ui.ts b/packages/variables-sync-plugin/vite.config.ui.ts new file mode 100644 index 000000000..e5a18dcc9 --- /dev/null +++ b/packages/variables-sync-plugin/vite.config.ui.ts @@ -0,0 +1,35 @@ +import { defineConfig } from "vite"; +import path from "node:path"; +import { viteSingleFile } from "vite-plugin-singlefile"; +import react from '@vitejs/plugin-react-swc'; +// import richSvg from "vite-plugin-react-rich-svg"; +import postcssUrl from "postcss-url"; + +// import figmaManifest from './figma.manifest'; + +// https://vitejs.dev/config/ +export default defineConfig(({ mode }) => ({ + plugins: [react(),/* richSvg()*/, viteSingleFile()], + root: path.resolve("src/ui"), + build: { + minify: mode === "production", + cssMinify: mode === "production", + sourcemap: mode !== "production" ? "inline" : false, + emptyOutDir: false, + outDir: path.resolve("dist"), + rollupOptions: { + input: path.resolve("src/ui/index.html"), + }, + }, + css: { + postcss: { + plugins: [postcssUrl({ url: "inline" })], + }, + }, + resolve: { + alias: { + "@common": path.resolve("src/common"), + "@ui": path.resolve("src/ui"), + }, + }, +})); From e534fc2f4d8217024ea0b0d276115a71f940b9dc Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Mon, 16 Sep 2024 22:52:53 +0300 Subject: [PATCH 05/12] fix variable sync package json/vite config path --- packages/sync-providers/package.json | 4 +- .../variables-sync-plugin/vite.config.ui.ts | 6 +- yarn.lock | 873 +++++++++++++++++- 3 files changed, 867 insertions(+), 16 deletions(-) diff --git a/packages/sync-providers/package.json b/packages/sync-providers/package.json index 50e649202..700e14a30 100644 --- a/packages/sync-providers/package.json +++ b/packages/sync-providers/package.json @@ -9,11 +9,11 @@ "exports": { ".": { "import": { - "types": "./dist/types/index.d.ts", + "types": "./dist/index.d.ts", "default": "./dist/index.js" }, "require": { - "types": "./dist/types/index.d.cts", + "types": "./dist/index.d.cts", "default": "./dist/index.cjs" } }, diff --git a/packages/variables-sync-plugin/vite.config.ui.ts b/packages/variables-sync-plugin/vite.config.ui.ts index e5a18dcc9..d1e2a68fe 100644 --- a/packages/variables-sync-plugin/vite.config.ui.ts +++ b/packages/variables-sync-plugin/vite.config.ui.ts @@ -10,7 +10,7 @@ import postcssUrl from "postcss-url"; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ plugins: [react(),/* richSvg()*/, viteSingleFile()], - root: path.resolve("src/ui"), + root: path.resolve("src/app"), build: { minify: mode === "production", cssMinify: mode === "production", @@ -18,7 +18,7 @@ export default defineConfig(({ mode }) => ({ emptyOutDir: false, outDir: path.resolve("dist"), rollupOptions: { - input: path.resolve("src/ui/index.html"), + input: path.resolve("src/app/index.html"), }, }, css: { @@ -29,7 +29,7 @@ export default defineConfig(({ mode }) => ({ resolve: { alias: { "@common": path.resolve("src/common"), - "@ui": path.resolve("src/ui"), + "@ui": path.resolve("src/app"), }, }, })); diff --git a/yarn.lock b/yarn.lock index d6a37d343..baeac4a5f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2953,6 +2953,241 @@ resolved "https://registry.npmjs.org/@emotion/memoize/-/memoize-0.7.4.tgz" integrity sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw== +"@esbuild/aix-ppc64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f" + integrity sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ== + +"@esbuild/aix-ppc64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.23.1.tgz#51299374de171dbd80bb7d838e1cfce9af36f353" + integrity sha512-6VhYk1diRqrhBAqpJEdjASR/+WVRtfjpqKuNw11cLiaWpAT/Uu+nokB+UJnevzy/P9C/ty6AOe0dwueMrGh/iQ== + +"@esbuild/android-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052" + integrity sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A== + +"@esbuild/android-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.23.1.tgz#58565291a1fe548638adb9c584237449e5e14018" + integrity sha512-xw50ipykXcLstLeWH7WRdQuysJqejuAGPd30vd1i5zSyKK3WE+ijzHmLKxdiCMtH1pHz78rOg0BKSYOSB/2Khw== + +"@esbuild/android-arm@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28" + integrity sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg== + +"@esbuild/android-arm@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.23.1.tgz#5eb8c652d4c82a2421e3395b808e6d9c42c862ee" + integrity sha512-uz6/tEy2IFm9RYOyvKl88zdzZfwEfKZmnX9Cj1BHjeSGNuGLuMD1kR8y5bteYmwqKm1tj8m4cb/aKEorr6fHWQ== + +"@esbuild/android-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e" + integrity sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA== + +"@esbuild/android-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.23.1.tgz#ae19d665d2f06f0f48a6ac9a224b3f672e65d517" + integrity sha512-nlN9B69St9BwUoB+jkyU090bru8L0NA3yFvAd7k8dNsVH8bi9a8cUAUSEcEEgTp2z3dbEDGJGfP6VUnkQnlReg== + +"@esbuild/darwin-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a" + integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ== + +"@esbuild/darwin-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.23.1.tgz#05b17f91a87e557b468a9c75e9d85ab10c121b16" + integrity sha512-YsS2e3Wtgnw7Wq53XXBLcV6JhRsEq8hkfg91ESVadIrzr9wO6jJDMZnCQbHm1Guc5t/CdDiFSSfWP58FNuvT3Q== + +"@esbuild/darwin-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22" + integrity sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw== + +"@esbuild/darwin-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.23.1.tgz#c58353b982f4e04f0d022284b8ba2733f5ff0931" + integrity sha512-aClqdgTDVPSEGgoCS8QDG37Gu8yc9lTHNAQlsztQ6ENetKEO//b8y31MMu2ZaPbn4kVsIABzVLXYLhCGekGDqw== + +"@esbuild/freebsd-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e" + integrity sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g== + +"@esbuild/freebsd-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.23.1.tgz#f9220dc65f80f03635e1ef96cfad5da1f446f3bc" + integrity sha512-h1k6yS8/pN/NHlMl5+v4XPfikhJulk4G+tKGFIOwURBSFzE8bixw1ebjluLOjfwtLqY0kewfjLSrO6tN2MgIhA== + +"@esbuild/freebsd-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261" + integrity sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ== + +"@esbuild/freebsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.23.1.tgz#69bd8511fa013b59f0226d1609ac43f7ce489730" + integrity sha512-lK1eJeyk1ZX8UklqFd/3A60UuZ/6UVfGT2LuGo3Wp4/z7eRTRYY+0xOu2kpClP+vMTi9wKOfXi2vjUpO1Ro76g== + +"@esbuild/linux-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b" + integrity sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q== + +"@esbuild/linux-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.23.1.tgz#8050af6d51ddb388c75653ef9871f5ccd8f12383" + integrity sha512-/93bf2yxencYDnItMYV/v116zff6UyTjo4EtEQjUBeGiVpMmffDNUyD9UN2zV+V3LRV3/on4xdZ26NKzn6754g== + +"@esbuild/linux-arm@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9" + integrity sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA== + +"@esbuild/linux-arm@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.23.1.tgz#ecaabd1c23b701070484990db9a82f382f99e771" + integrity sha512-CXXkzgn+dXAPs3WBwE+Kvnrf4WECwBdfjfeYHpMeVxWE0EceB6vhWGShs6wi0IYEqMSIzdOF1XjQ/Mkm5d7ZdQ== + +"@esbuild/linux-ia32@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2" + integrity sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg== + +"@esbuild/linux-ia32@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.23.1.tgz#3ed2273214178109741c09bd0687098a0243b333" + integrity sha512-VTN4EuOHwXEkXzX5nTvVY4s7E/Krz7COC8xkftbbKRYAl96vPiUssGkeMELQMOnLOJ8k3BY1+ZY52tttZnHcXQ== + +"@esbuild/linux-loong64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df" + integrity sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg== + +"@esbuild/linux-loong64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.23.1.tgz#a0fdf440b5485c81b0fbb316b08933d217f5d3ac" + integrity sha512-Vx09LzEoBa5zDnieH8LSMRToj7ir/Jeq0Gu6qJ/1GcBq9GkfoEAoXvLiW1U9J1qE/Y/Oyaq33w5p2ZWrNNHNEw== + +"@esbuild/linux-mips64el@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe" + integrity sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg== + +"@esbuild/linux-mips64el@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.23.1.tgz#e11a2806346db8375b18f5e104c5a9d4e81807f6" + integrity sha512-nrFzzMQ7W4WRLNUOU5dlWAqa6yVeI0P78WKGUo7lg2HShq/yx+UYkeNSE0SSfSure0SqgnsxPvmAUu/vu0E+3Q== + +"@esbuild/linux-ppc64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4" + integrity sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w== + +"@esbuild/linux-ppc64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.23.1.tgz#06a2744c5eaf562b1a90937855b4d6cf7c75ec96" + integrity sha512-dKN8fgVqd0vUIjxuJI6P/9SSSe/mB9rvA98CSH2sJnlZ/OCZWO1DJvxj8jvKTfYUdGfcq2dDxoKaC6bHuTlgcw== + +"@esbuild/linux-riscv64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc" + integrity sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA== + +"@esbuild/linux-riscv64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.23.1.tgz#65b46a2892fc0d1af4ba342af3fe0fa4a8fe08e7" + integrity sha512-5AV4Pzp80fhHL83JM6LoA6pTQVWgB1HovMBsLQ9OZWLDqVY8MVobBXNSmAJi//Csh6tcY7e7Lny2Hg1tElMjIA== + +"@esbuild/linux-s390x@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de" + integrity sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A== + +"@esbuild/linux-s390x@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.23.1.tgz#e71ea18c70c3f604e241d16e4e5ab193a9785d6f" + integrity sha512-9ygs73tuFCe6f6m/Tb+9LtYxWR4c9yg7zjt2cYkjDbDpV/xVn+68cQxMXCjUpYwEkze2RcU/rMnfIXNRFmSoDw== + +"@esbuild/linux-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz#6d8f0c768e070e64309af8004bb94e68ab2bb3b0" + integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ== + +"@esbuild/linux-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.23.1.tgz#d47f97391e80690d4dfe811a2e7d6927ad9eed24" + integrity sha512-EV6+ovTsEXCPAp58g2dD68LxoP/wK5pRvgy0J/HxPGB009omFPv3Yet0HiaqvrIrgPTBuC6wCH1LTOY91EO5hQ== + +"@esbuild/netbsd-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047" + integrity sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg== + +"@esbuild/netbsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.23.1.tgz#44e743c9778d57a8ace4b72f3c6b839a3b74a653" + integrity sha512-aevEkCNu7KlPRpYLjwmdcuNz6bDFiE7Z8XC4CPqExjTvrHugh28QzUXVOZtiYghciKUacNktqxdpymplil1beA== + +"@esbuild/openbsd-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.23.1.tgz#05c5a1faf67b9881834758c69f3e51b7dee015d7" + integrity sha512-3x37szhLexNA4bXhLrCC/LImN/YtWis6WXr1VESlfVtVeoFJBRINPJ3f0a/6LV8zpikqoUg4hyXw0sFBt5Cr+Q== + +"@esbuild/openbsd-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70" + integrity sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow== + +"@esbuild/openbsd-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.23.1.tgz#2e58ae511bacf67d19f9f2dcd9e8c5a93f00c273" + integrity sha512-aY2gMmKmPhxfU+0EdnN+XNtGbjfQgwZj43k8G3fyrDM/UdZww6xrWxmDkuz2eCZchqVeABjV5BpildOrUbBTqA== + +"@esbuild/sunos-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b" + integrity sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg== + +"@esbuild/sunos-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.23.1.tgz#adb022b959d18d3389ac70769cef5a03d3abd403" + integrity sha512-RBRT2gqEl0IKQABT4XTj78tpk9v7ehp+mazn2HbUeZl1YMdaGAQqhapjGTCe7uw7y0frDi4gS0uHzhvpFuI1sA== + +"@esbuild/win32-arm64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d" + integrity sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A== + +"@esbuild/win32-arm64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.23.1.tgz#84906f50c212b72ec360f48461d43202f4c8b9a2" + integrity sha512-4O+gPR5rEBe2FpKOVyiJ7wNDPA8nGzDuJ6gN4okSA1gEOYZ67N8JPk58tkWtdtPeLz7lBnY6I5L3jdsr3S+A6A== + +"@esbuild/win32-ia32@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b" + integrity sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA== + +"@esbuild/win32-ia32@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.23.1.tgz#5e3eacc515820ff729e90d0cb463183128e82fac" + integrity sha512-BcaL0Vn6QwCwre3Y717nVHZbAa4UBEigzFm6VdsVdT/MbZ38xoj1X9HPkZhbmaBGUD1W8vxAfffbDe8bA6AKnQ== + +"@esbuild/win32-x64@0.21.5": + version "0.21.5" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c" + integrity sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw== + +"@esbuild/win32-x64@0.23.1": + version "0.23.1" + resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.23.1.tgz#81fd50d11e2c32b2d6241470e3185b70c7b30699" + integrity sha512-BHpFFeslkWrXWyUPnbKm+xYYVYruCinGcftSBaa8zoF9hZO4BcSCFUvHVTtzpIY6YzUnYtuEhZ+C9iEXjxnasg== + "@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": version "4.4.0" resolved "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz" @@ -4042,7 +4277,19 @@ dependencies: "@babel/runtime" "^7.13.10" -"@radix-ui/react-dismissable-layer@1.0.4", "@radix-ui/react-dismissable-layer@1.0.5": +"@radix-ui/react-dismissable-layer@1.0.4": + version "1.0.4" + resolved "https://registry.yarnpkg.com/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.0.4.tgz#883a48f5f938fa679427aa17fcba70c5494c6978" + integrity sha512-7UpBa/RKMoHJYjie1gkF1DlK8l1fdU/VKDpoS3rCCo8YBJR294GwcEHyxHw72yvphJ7ld0AXEcSLAzY2F/WyCg== + dependencies: + "@babel/runtime" "^7.13.10" + "@radix-ui/primitive" "1.0.1" + "@radix-ui/react-compose-refs" "1.0.1" + "@radix-ui/react-primitive" "1.0.3" + "@radix-ui/react-use-callback-ref" "1.0.1" + "@radix-ui/react-use-escape-keydown" "1.0.3" + +"@radix-ui/react-dismissable-layer@1.0.5": version "1.0.5" resolved "https://registry.npmjs.org/@radix-ui/react-dismissable-layer/-/react-dismissable-layer-1.0.5.tgz" integrity sha512-aJeDjQhywg9LBu2t/At58hCvr7pEm0o2Ke1x33B+MhjNmmZ17sy4KImo0KPLgsnc/zN7GPdce8Cnn0SWvwZO7g== @@ -4614,6 +4861,86 @@ resolved "https://registry.npmjs.org/@rematch/core/-/core-2.2.0.tgz" integrity sha512-Sj3nC/2X+bOBZeOf4jdJ00nhCcx9wLbVK9SOs6eFR4Y1qKXqRY0hGigbQgfTpCdjRFlwTHHfN3m41MlNvMhDgw== +"@rollup/rollup-android-arm-eabi@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.2.tgz#0412834dc423d1ff7be4cb1fc13a86a0cd262c11" + integrity sha512-fSuPrt0ZO8uXeS+xP3b+yYTCBUd05MoSp2N/MFOgjhhUhMmchXlpTQrTpI8T+YAwAQuK7MafsCOxW7VrPMrJcg== + +"@rollup/rollup-android-arm64@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.21.2.tgz#baf1a014b13654f3b9e835388df9caf8c35389cb" + integrity sha512-xGU5ZQmPlsjQS6tzTTGwMsnKUtu0WVbl0hYpTPauvbRAnmIvpInhJtgjj3mcuJpEiuUw4v1s4BimkdfDWlh7gA== + +"@rollup/rollup-darwin-arm64@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.2.tgz#0a2c364e775acdf1172fe3327662eec7c46e55b1" + integrity sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q== + +"@rollup/rollup-darwin-x64@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.21.2.tgz#a972db75890dfab8df0da228c28993220a468c42" + integrity sha512-ZbRaUvw2iN/y37x6dY50D8m2BnDbBjlnMPotDi/qITMJ4sIxNY33HArjikDyakhSv0+ybdUxhWxE6kTI4oX26w== + +"@rollup/rollup-linux-arm-gnueabihf@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.21.2.tgz#1609d0630ef61109dd19a278353e5176d92e30a1" + integrity sha512-ztRJJMiE8nnU1YFcdbd9BcH6bGWG1z+jP+IPW2oDUAPxPjo9dverIOyXz76m6IPA6udEL12reYeLojzW2cYL7w== + +"@rollup/rollup-linux-arm-musleabihf@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.21.2.tgz#3c1dca5f160aa2e79e4b20ff6395eab21804f266" + integrity sha512-flOcGHDZajGKYpLV0JNc0VFH361M7rnV1ee+NTeC/BQQ1/0pllYcFmxpagltANYt8FYf9+kL6RSk80Ziwyhr7w== + +"@rollup/rollup-linux-arm64-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.21.2.tgz#c2fe376e8b04eafb52a286668a8df7c761470ac7" + integrity sha512-69CF19Kp3TdMopyteO/LJbWufOzqqXzkrv4L2sP8kfMaAQ6iwky7NoXTp7bD6/irKgknDKM0P9E/1l5XxVQAhw== + +"@rollup/rollup-linux-arm64-musl@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.21.2.tgz#e62a4235f01e0f66dbba587c087ca6db8008ec80" + integrity sha512-48pD/fJkTiHAZTnZwR0VzHrao70/4MlzJrq0ZsILjLW/Ab/1XlVUStYyGt7tdyIiVSlGZbnliqmult/QGA2O2w== + +"@rollup/rollup-linux-powerpc64le-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.21.2.tgz#24b3457e75ee9ae5b1c198bd39eea53222a74e54" + integrity sha512-cZdyuInj0ofc7mAQpKcPR2a2iu4YM4FQfuUzCVA2u4HI95lCwzjoPtdWjdpDKyHxI0UO82bLDoOaLfpZ/wviyQ== + +"@rollup/rollup-linux-riscv64-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.21.2.tgz#38edfba9620fe2ca8116c97e02bd9f2d606bde09" + integrity sha512-RL56JMT6NwQ0lXIQmMIWr1SW28z4E4pOhRRNqwWZeXpRlykRIlEpSWdsgNWJbYBEWD84eocjSGDu/XxbYeCmwg== + +"@rollup/rollup-linux-s390x-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.21.2.tgz#a3bfb8bc5f1e802f8c76cff4a4be2e9f9ac36a18" + integrity sha512-PMxkrWS9z38bCr3rWvDFVGD6sFeZJw4iQlhrup7ReGmfn7Oukrr/zweLhYX6v2/8J6Cep9IEA/SmjXjCmSbrMQ== + +"@rollup/rollup-linux-x64-gnu@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.2.tgz#0dadf34be9199fcdda44b5985a086326344f30ad" + integrity sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw== + +"@rollup/rollup-linux-x64-musl@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.2.tgz#7b7deddce240400eb87f2406a445061b4fed99a8" + integrity sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg== + +"@rollup/rollup-win32-arm64-msvc@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.21.2.tgz#a0ca0c5149c2cfb26fab32e6ba3f16996fbdb504" + integrity sha512-9rRero0E7qTeYf6+rFh3AErTNU1VCQg2mn7CQcI44vNUWM9Ze7MSRS/9RFuSsox+vstRt97+x3sOhEey024FRQ== + +"@rollup/rollup-win32-ia32-msvc@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.21.2.tgz#aae2886beec3024203dbb5569db3a137bc385f8e" + integrity sha512-5rA4vjlqgrpbFVVHX3qkrCo/fZTj1q0Xxpg+Z7yIo3J2AilW7t2+n6Q8Jrx+4MrYpAnjttTYF8rr7bP46BPzRw== + +"@rollup/rollup-win32-x64-msvc@4.21.2": + version "4.21.2" + resolved "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.21.2.tgz#e4291e3c1bc637083f87936c333cdbcad22af63b" + integrity sha512-6UUxd0+SKomjdzuAcp+HAmxw1FlGBnl1v2yEPSabtx4lBfdXHDVsW7+lQkgz9cNFJGY3AWR7+V8P5BqkD9L9nA== + "@samverschueren/stream-to-observable@^0.3.0": version "0.3.1" resolved "https://registry.npmjs.org/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.1.tgz" @@ -4766,7 +5093,7 @@ "@stitches/react@^1.2.8": version "1.2.8" - resolved "https://registry.npmjs.org/@stitches/react/-/react-1.2.8.tgz" + resolved "https://registry.yarnpkg.com/@stitches/react/-/react-1.2.8.tgz#954f8008be8d9c65c4e58efa0937f32388ce3a38" integrity sha512-9g9dWI4gsSVe8bNLlb+lMkBYsnIKCZTmvqvDG+Avnn69XfmHZKiaMrx7cgTaddq7aTPPmXiTsbFcUy0xgI4+wA== "@storybook/addon-actions@6.5.16", "@storybook/addon-actions@^6.5.8": @@ -6009,51 +6336,101 @@ resolved "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.92.tgz" integrity sha512-v7PqZUBtIF6Q5Cp48gqUiG8zQQnEICpnfNdoiY3xjQAglCGIQCjJIDjreZBoeZQZspB27lQN4eZ43CX18+2SnA== +"@swc/core-darwin-arm64@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-arm64/-/core-darwin-arm64-1.7.26.tgz#5f4096c00e71771ca1b18c824f0c92a052c70760" + integrity sha512-FF3CRYTg6a7ZVW4yT9mesxoVVZTrcSWtmZhxKCYJX9brH4CS/7PRPjAKNk6kzWgWuRoglP7hkjQcd6EpMcZEAw== + "@swc/core-darwin-x64@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.3.92.tgz#1728e7ebbfe37b56c07d99e29dde78bfa90cf8d1" integrity sha512-Q3XIgQfXyxxxms3bPN+xGgvwk0TtG9l89IomApu+yTKzaIIlf051mS+lGngjnh9L0aUiCp6ICyjDLtutWP54fw== +"@swc/core-darwin-x64@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-darwin-x64/-/core-darwin-x64-1.7.26.tgz#867b7a4f094e6b64201090ca5fcbf3da7d0f3e22" + integrity sha512-az3cibZdsay2HNKmc4bjf62QVukuiMRh5sfM5kHR/JMTrLyS6vSw7Ihs3UTkZjUxkLTT8ro54LI6sV6sUQUbLQ== + "@swc/core-linux-arm-gnueabihf@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.92.tgz#6f7c20833b739f8911c936c9783976ded2c449dc" integrity sha512-tnOCoCpNVXC+0FCfG84PBZJyLlz0Vfj9MQhyhCvlJz9hQmvpf8nTdKH7RHrOn8VfxtUBLdVi80dXgIFgbvl7qA== +"@swc/core-linux-arm-gnueabihf@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.7.26.tgz#35bb43894def296d92aaa2cc9372d48042f37777" + integrity sha512-VYPFVJDO5zT5U3RpCdHE5v1gz4mmR8BfHecUZTmD2v1JeFY6fv9KArJUpjrHEEsjK/ucXkQFmJ0jaiWXmpOV9Q== + "@swc/core-linux-arm64-gnu@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.92.tgz#bb01dd9b922b0c076c38924013bd10036ce39c7c" integrity sha512-lFfGhX32w8h1j74Iyz0Wv7JByXIwX11OE9UxG+oT7lG0RyXkF4zKyxP8EoxfLrDXse4Oop434p95e3UNC3IfCw== +"@swc/core-linux-arm64-gnu@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.7.26.tgz#8e2321cc4ec84cbfed8f8e16ff1ed7b854450443" + integrity sha512-YKevOV7abpjcAzXrhsl+W48Z9mZvgoVs2eP5nY+uoMAdP2b3GxC0Df1Co0I90o2lkzO4jYBpTMcZlmUXLdXn+Q== + "@swc/core-linux-arm64-musl@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.92.tgz#0070165eed2805475c98eb732bab8bdca955932e" integrity sha512-rOZtRcLj57MSAbiecMsqjzBcZDuaCZ8F6l6JDwGkQ7u1NYR57cqF0QDyU7RKS1Jq27Z/Vg21z5cwqoH5fLN+Sg== +"@swc/core-linux-arm64-musl@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.7.26.tgz#b1c16e4b23ffa9ff19973eda6ffee35d2a7de7b0" + integrity sha512-3w8iZICMkQQON0uIcvz7+Q1MPOW6hJ4O5ETjA0LSP/tuKqx30hIniCGOgPDnv3UTMruLUnQbtBwVCZTBKR3Rkg== + "@swc/core-linux-x64-gnu@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.92.tgz#d9785f93b9121eeef0f54e8d845dd216698e0115" integrity sha512-qptoMGnBL6v89x/Qpn+l1TH1Y0ed+v0qhNfAEVzZvCvzEMTFXphhlhYbDdpxbzRmCjH6GOGq7Y+xrWt9T1/ARg== +"@swc/core-linux-x64-gnu@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.7.26.tgz#388e2cc13a010cd28787aead2cecf31eb491836d" + integrity sha512-c+pp9Zkk2lqb06bNGkR2Looxrs7FtGDMA4/aHjZcCqATgp348hOKH5WPvNLBl+yPrISuWjbKDVn3NgAvfvpH4w== + "@swc/core-linux-x64-musl@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.92.tgz#8fe5cf244695bf4f0bc7dc7df450a9bd1bfccc2b" integrity sha512-g2KrJ43bZkCZHH4zsIV5ErojuV1OIpUHaEyW1gf7JWKaFBpWYVyubzFPvPkjcxHGLbMsEzO7w/NVfxtGMlFH/Q== +"@swc/core-linux-x64-musl@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.7.26.tgz#51e0ff30981f26d7a5b97a7a7b5b291bad050d1a" + integrity sha512-PgtyfHBF6xG87dUSSdTJHwZ3/8vWZfNIXQV2GlwEpslrOkGqy+WaiiyE7Of7z9AvDILfBBBcJvJ/r8u980wAfQ== + "@swc/core-win32-arm64-msvc@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.92.tgz#d6150785455c813a8e62f4e4b0a22773baf398eb" integrity sha512-3MCRGPAYDoQ8Yyd3WsCMc8eFSyKXY5kQLyg/R5zEqA0uthomo0m0F5/fxAJMZGaSdYkU1DgF73ctOWOf+Z/EzQ== +"@swc/core-win32-arm64-msvc@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.7.26.tgz#a7fdcc4074c34ee6a026506b594d00323383c11f" + integrity sha512-9TNXPIJqFynlAOrRD6tUQjMq7KApSklK3R/tXgIxc7Qx+lWu8hlDQ/kVPLpU7PWvMMwC/3hKBW+p5f+Tms1hmA== + "@swc/core-win32-ia32-msvc@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.92.tgz#8142166bceafbaa209d440b36fdc8cd4b4f82768" integrity sha512-zqTBKQhgfWm73SVGS8FKhFYDovyRl1f5dTX1IwSKynO0qHkRCqJwauFJv/yevkpJWsI2pFh03xsRs9HncTQKSA== +"@swc/core-win32-ia32-msvc@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.7.26.tgz#ae7be6dde798eebee2000b8fd84e01a439b5bd6a" + integrity sha512-9YngxNcG3177GYdsTum4V98Re+TlCeJEP4kEwEg9EagT5s3YejYdKwVAkAsJszzkXuyRDdnHUpYbTrPG6FiXrQ== + "@swc/core-win32-x64-msvc@1.3.92": version "1.3.92" resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.92.tgz#4ba542875fc690b579232721ccec7873e139646a" integrity sha512-41bE66ddr9o/Fi1FBh0sHdaKdENPTuDpv1IFHxSg0dJyM/jX8LbkjnpdInYXHBxhcLVAPraVRrNsC4SaoPw2Pg== +"@swc/core-win32-x64-msvc@1.7.26": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.7.26.tgz#310d607004d7319085a4dec20c0c38c3405cc05b" + integrity sha512-VR+hzg9XqucgLjXxA13MtV5O3C0bK0ywtLIBw/+a+O+Oc6mxFWHtdUeXDbIi5AiPbn0fjgVJMqYnyjGyyX8u0w== + "@swc/core@^1.3.61": version "1.3.92" resolved "https://registry.npmjs.org/@swc/core/-/core-1.3.92.tgz" @@ -6073,11 +6450,42 @@ "@swc/core-win32-ia32-msvc" "1.3.92" "@swc/core-win32-x64-msvc" "1.3.92" +"@swc/core@^1.5.7": + version "1.7.26" + resolved "https://registry.yarnpkg.com/@swc/core/-/core-1.7.26.tgz#beda9b82063fcec7b56c958804a4d175aecf9a9d" + integrity sha512-f5uYFf+TmMQyYIoxkn/evWhNGuUzC730dFwAKGwBVHHVoPyak1/GvJUm6i1SKl+2Hrj9oN0i3WSoWWZ4pgI8lw== + dependencies: + "@swc/counter" "^0.1.3" + "@swc/types" "^0.1.12" + optionalDependencies: + "@swc/core-darwin-arm64" "1.7.26" + "@swc/core-darwin-x64" "1.7.26" + "@swc/core-linux-arm-gnueabihf" "1.7.26" + "@swc/core-linux-arm64-gnu" "1.7.26" + "@swc/core-linux-arm64-musl" "1.7.26" + "@swc/core-linux-x64-gnu" "1.7.26" + "@swc/core-linux-x64-musl" "1.7.26" + "@swc/core-win32-arm64-msvc" "1.7.26" + "@swc/core-win32-ia32-msvc" "1.7.26" + "@swc/core-win32-x64-msvc" "1.7.26" + "@swc/counter@^0.1.1": version "0.1.2" resolved "https://registry.npmjs.org/@swc/counter/-/counter-0.1.2.tgz" integrity sha512-9F4ys4C74eSTEUNndnER3VJ15oru2NumfQxS8geE+f3eB5xvfxpWyqE5XlVnxb/R14uoXi6SLbBwwiDSkv+XEw== +"@swc/counter@^0.1.3": + version "0.1.3" + resolved "https://registry.yarnpkg.com/@swc/counter/-/counter-0.1.3.tgz#cc7463bd02949611c6329596fccd2b0ec782b0e9" + integrity sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ== + +"@swc/types@^0.1.12": + version "0.1.12" + resolved "https://registry.yarnpkg.com/@swc/types/-/types-0.1.12.tgz#7f632c06ab4092ce0ebd046ed77ff7557442282f" + integrity sha512-wBJA+SdtkbFhHjTMYH+dEH1y4VpfGdAc2Kw/LK09i9bXd/K6j6PkDcFCEzb6iVfZMkPRrl/q0e3toqTAJdkIVA== + dependencies: + "@swc/counter" "^0.1.3" + "@swc/types@^0.1.5": version "0.1.5" resolved "https://registry.npmjs.org/@swc/types/-/types-0.1.5.tgz" @@ -6200,7 +6608,7 @@ eslint "^8.31.0" prettier "^2.8.3" -"@tokens-studio/tokens@0.2.5": +"@tokens-studio/tokens@0.2.5", "@tokens-studio/tokens@^0.2.5": version "0.2.5" resolved "https://registry.yarnpkg.com/@tokens-studio/tokens/-/tokens-0.2.5.tgz#a42559da95cc0434bb2915b8410463a0c2b3749a" integrity sha512-gVqHNGI7MmWnHEORQ0f3/+rpWn+GIaPbMpNogCfV/Sjn0uPlCMbhIqpmHcZg7cTM1U7wDI8hbjvpph0t4aARcw== @@ -6246,6 +6654,30 @@ "@radix-ui/react-toggle-group" "^1.0.2" "@radix-ui/react-tooltip" "^1.0.4" +"@tokens-studio/ui@^0.11.0": + version "0.11.0" + resolved "https://registry.yarnpkg.com/@tokens-studio/ui/-/ui-0.11.0.tgz#fd3f1a41bbe4f6cbb20a7c1086aff7f2f4240205" + integrity sha512-omy25qnA3XhG97nSsaij2b6hw3gxdwU3YEt3HzRp/T0PmSPo9BHqtQXbIn6epS7D9HR0WRcjN9XLMr4SWcrVhg== + dependencies: + "@iconicicons/react" "^1.5.1" + "@radix-ui/react-accordion" "^1.1.2" + "@radix-ui/react-avatar" "^1.0.2" + "@radix-ui/react-checkbox" "^1.0.4" + "@radix-ui/react-context-menu" "^2.1.1" + "@radix-ui/react-dialog" "^1.0.3" + "@radix-ui/react-dropdown-menu" "^2.0.2" + "@radix-ui/react-icons" "^1.3.0" + "@radix-ui/react-label" "^2.0.0" + "@radix-ui/react-radio-group" "^1.1.3" + "@radix-ui/react-scroll-area" "^1.0.4" + "@radix-ui/react-select" "^1.2.1" + "@radix-ui/react-separator" "^1.0.2" + "@radix-ui/react-switch" "^1.0.3" + "@radix-ui/react-tabs" "^1.0.3" + "@radix-ui/react-toast" "^1.1.3" + "@radix-ui/react-toggle-group" "^1.0.2" + "@radix-ui/react-tooltip" "^1.0.4" + "@tootallnate/once@2": version "2.0.0" resolved "https://registry.npmjs.org/@tootallnate/once/-/once-2.0.0.tgz" @@ -6616,6 +7048,11 @@ resolved "https://registry.npmjs.org/@types/estree/-/estree-1.0.2.tgz" integrity sha512-VeiPZ9MMwXjO32/Xu7+OwflfmeoRwkE/qzndw42gGtgJwZopBnzy2gD//NN1+go1mADzkDcqf/KnFRSjTJ8xJA== +"@types/estree@1.0.5": + version "1.0.5" + resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4" + integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw== + "@types/estree@^0.0.51": version "0.0.51" resolved "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz" @@ -6763,6 +7200,14 @@ jest-diff "^26.0.0" pretty-format "^26.0.0" +"@types/jest@^29.5.12": + version "29.5.12" + resolved "https://registry.yarnpkg.com/@types/jest/-/jest-29.5.12.tgz#7f7dc6eb4cf246d2474ed78744b05d06ce025544" + integrity sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw== + dependencies: + expect "^29.0.0" + pretty-format "^29.0.0" + "@types/js-levenshtein@^1.1.1": version "1.1.1" resolved "https://registry.npmjs.org/@types/js-levenshtein/-/js-levenshtein-1.1.1.tgz" @@ -6902,6 +7347,13 @@ dependencies: undici-types "~6.19.2" +"@types/node@^22.5.4": + version "22.5.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.5.4.tgz#83f7d1f65bc2ed223bdbf57c7884f1d5a4fa84e8" + integrity sha512-FDuKUJQm/ju9fT/SeX/6+gBzoPzlVCzfzmGkwKvRHQVxi4BntVbyIwf6a4Xn62mrvndLiml6z/UBXIdEVjQLXg== + dependencies: + undici-types "~6.19.2" + "@types/normalize-package-data@^2.4.0": version "2.4.2" resolved "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.2.tgz" @@ -6932,6 +7384,14 @@ resolved "https://registry.npmjs.org/@types/phoenix/-/phoenix-1.6.2.tgz" integrity sha512-I3mm7x5XIi+5NsIY3nfreY+H4PmQdyBwJ84SiUSOxSg1axwEPNmkKWYVm56y+emDpPPUL3cPzrLcgRWSd9gI7g== +"@types/postcss-url@^10.0.4": + version "10.0.4" + resolved "https://registry.yarnpkg.com/@types/postcss-url/-/postcss-url-10.0.4.tgz#4403bfcd3257c1380f04a6b81eb78e06a2a354d9" + integrity sha512-5QIO9NgbWmAkle65haRqkdgYPCOXheNsaFdbTJJQjT302yK3H49ql4t9a4y0NfpuPtU/UBo15VcV64WCSIMJKg== + dependencies: + "@types/node" "*" + postcss "^8.0.0" + "@types/pretty-hrtime@^1.0.0": version "1.0.1" resolved "https://registry.npmjs.org/@types/pretty-hrtime/-/pretty-hrtime-1.0.1.tgz" @@ -6971,6 +7431,13 @@ dependencies: "@types/react" "*" +"@types/react-dom@^18.3.0": + version "18.3.0" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.3.0.tgz#0cbc818755d87066ab6ca74fbedb2547d74a82b0" + integrity sha512-EhwApuTmMBmXuFOikhQLIBUn6uFg81SwLMOAUgodJF14SOBOCMdU04gDoYi0WOJJHD144TL32z4yDqCW3dnkQg== + dependencies: + "@types/react" "*" + "@types/react-modal@^3.16.3": version "3.16.3" resolved "https://registry.npmjs.org/@types/react-modal/-/react-modal-3.16.3.tgz" @@ -7003,6 +7470,14 @@ "@types/scheduler" "*" csstype "^3.0.2" +"@types/react@^18.3.5": + version "18.3.5" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.5.tgz#5f524c2ad2089c0ff372bbdabc77ca2c4dbadf8f" + integrity sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA== + dependencies: + "@types/prop-types" "*" + csstype "^3.0.2" + "@types/responselike@^1.0.0": version "1.0.1" resolved "https://registry.npmjs.org/@types/responselike/-/responselike-1.0.1.tgz" @@ -7300,6 +7775,13 @@ resolved "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz" integrity sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ== +"@vitejs/plugin-react-swc@^3.7.0": + version "3.7.0" + resolved "https://registry.yarnpkg.com/@vitejs/plugin-react-swc/-/plugin-react-swc-3.7.0.tgz#e456c0a6d7f562268e1d231af9ac46b86ef47d88" + integrity sha512-yrknSb3Dci6svCd/qhHqhFPDSw0QtjumcqdKMoNNzmOl5lMXTTiqzjWtG4Qask2HdvvzaNgSunbQGet8/GrKdA== + dependencies: + "@swc/core" "^1.5.7" + "@webassemblyjs/ast@1.11.6", "@webassemblyjs/ast@^1.11.5": version "1.11.6" resolved "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.6.tgz" @@ -7933,6 +8415,11 @@ any-observable@^0.3.0: resolved "https://registry.npmjs.org/any-observable/-/any-observable-0.3.0.tgz" integrity sha512-/FQM1EDkTsf63Ub2C6O7GuYFDsSXUwsaZDurV0np41ocwq0jthUAYCmhBX9f+KwlaCgIuWyr/4WlUQUBfKfZog== +any-promise@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" + integrity sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A== + anymatch@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/anymatch/-/anymatch-2.0.0.tgz" @@ -8264,6 +8751,11 @@ async@^3.2.0: resolved "https://registry.npmjs.org/async/-/async-3.2.4.tgz" integrity sha512-iAB+JbDEGXhyIUavoDl9WP/Jj106Kz9DEn1DPgYw5ruDn0e3Wgi3sKFm55sASdGBNOQB8F59d9qQ7deqrHA8wQ== +async@^3.2.3: + version "3.2.6" + resolved "https://registry.yarnpkg.com/async/-/async-3.2.6.tgz#1b0728e14929d51b85b449b7f06e27c1145e38ce" + integrity sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA== + asynciterator.prototype@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/asynciterator.prototype/-/asynciterator.prototype-1.0.0.tgz" @@ -9060,6 +9552,13 @@ builtin-status-codes@^3.0.0: resolved "https://registry.npmjs.org/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz" integrity sha512-HpGFw18DgFWlncDfjTa2rcQ4W88O1mC8e8yZ2AvQY5KDaktSTwo+KRf6nHK6FRI5FyRyb/5T6+TSxfP7QyGsmQ== +bundle-require@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/bundle-require/-/bundle-require-5.0.0.tgz#071521bdea6534495cf23e92a83f889f91729e93" + integrity sha512-GuziW3fSSmopcx4KRymQEJVbZUfqlCqcq7dvs6TYwKRZiegK/2buMxQTPs6MGlNv50wms1699qYO54R8XfRX4w== + dependencies: + load-tsconfig "^0.2.3" + bytes@3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz" @@ -9088,6 +9587,11 @@ c8@^7.6.0: yargs "^16.2.0" yargs-parser "^20.2.9" +cac@^6.7.14: + version "6.7.14" + resolved "https://registry.yarnpkg.com/cac/-/cac-6.7.14.tgz#804e1e6f506ee363cb0e3ccbb09cad5dd9870959" + integrity sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ== + cacache@^12.0.2: version "12.0.4" resolved "https://registry.npmjs.org/cacache/-/cacache-12.0.4.tgz" @@ -9345,7 +9849,7 @@ chalk@^3.0.0: ansi-styles "^4.1.0" supports-color "^7.1.0" -chalk@^4.0.0, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2: +chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.1, chalk@^4.1.2: version "4.1.2" resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz" integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== @@ -9425,6 +9929,21 @@ chokidar@^3.3.0, chokidar@^3.4.1, chokidar@^3.4.2, chokidar@^3.5.3: optionalDependencies: fsevents "~2.3.2" +chokidar@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.6.0.tgz#197c6cc669ef2a8dc5e7b4d97ee4e092c3eb0d5b" + integrity sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw== + dependencies: + anymatch "~3.1.2" + braces "~3.0.2" + glob-parent "~5.1.2" + is-binary-path "~2.1.0" + is-glob "~4.0.1" + normalize-path "~3.0.0" + readdirp "~3.6.0" + optionalDependencies: + fsevents "~2.3.2" + chownr@^1.1.1: version "1.1.4" resolved "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz" @@ -9942,6 +10461,11 @@ connect-history-api-fallback@^1.6.0: resolved "https://registry.yarnpkg.com/connect-history-api-fallback/-/connect-history-api-fallback-1.6.0.tgz#8b32089359308d111115d81cad3fceab888f97bc" integrity sha512-e54B99q/OUoH64zYYRf3HBP5z24G38h5D3qXu23JGRoigpX5Ss4r9ZnDk3g0Z8uQC2x2lPaJ+UlWBc1ZWBWdLg== +consola@^3.2.3: + version "3.2.3" + resolved "https://registry.yarnpkg.com/consola/-/consola-3.2.3.tgz#0741857aa88cfa0d6fd53f1cff0375136e98502f" + integrity sha512-I5qxpzLv+sJhTVEoLYNcTW+bThDCPsit0vLNKShZx6rLtpilNpmmeTPaeqJb9ZE9dV3DGaeby6Vuhrw38WjeyQ== + console-browserify@^1.1.0: version "1.2.0" resolved "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz" @@ -10426,6 +10950,11 @@ csv@^5.5.3: csv-stringify "^5.6.5" stream-transform "^2.1.3" +cuint@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/cuint/-/cuint-0.2.2.tgz#408086d409550c2631155619e9fa7bcadc3b991b" + integrity sha512-d4ZVpCW31eWwCMe1YT3ur7mUDnTXbgwyzaL320DrcRT45rfjYxkt5QWLrmOJ+/UEAI2+fQgKe/fCjR8l4TpRgw== + culori@^3.1.2: version "3.3.0" resolved "https://registry.yarnpkg.com/culori/-/culori-3.3.0.tgz#e33530adbd124d53bd6550394397e695eaaed739" @@ -10787,6 +11316,13 @@ debug@^3.0.0, debug@^3.1.0, debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.3.5: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + decamelize-keys@^1.1.0: version "1.1.1" resolved "https://registry.npmjs.org/decamelize-keys/-/decamelize-keys-1.1.1.tgz" @@ -11446,6 +11982,13 @@ ee-first@1.1.1: resolved "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== +ejs@^3.1.9: + version "3.1.10" + resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b" + integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA== + dependencies: + jake "^10.8.5" + electron-to-chromium@^1.4.535: version "1.4.553" resolved "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.553.tgz" @@ -11774,6 +12317,65 @@ es6-weak-map@^2.0.3: es6-iterator "^2.0.3" es6-symbol "^3.1.1" +esbuild@^0.21.3: + version "0.21.5" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.5.tgz#9ca301b120922959b766360d8ac830da0d02997d" + integrity sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw== + optionalDependencies: + "@esbuild/aix-ppc64" "0.21.5" + "@esbuild/android-arm" "0.21.5" + "@esbuild/android-arm64" "0.21.5" + "@esbuild/android-x64" "0.21.5" + "@esbuild/darwin-arm64" "0.21.5" + "@esbuild/darwin-x64" "0.21.5" + "@esbuild/freebsd-arm64" "0.21.5" + "@esbuild/freebsd-x64" "0.21.5" + "@esbuild/linux-arm" "0.21.5" + "@esbuild/linux-arm64" "0.21.5" + "@esbuild/linux-ia32" "0.21.5" + "@esbuild/linux-loong64" "0.21.5" + "@esbuild/linux-mips64el" "0.21.5" + "@esbuild/linux-ppc64" "0.21.5" + "@esbuild/linux-riscv64" "0.21.5" + "@esbuild/linux-s390x" "0.21.5" + "@esbuild/linux-x64" "0.21.5" + "@esbuild/netbsd-x64" "0.21.5" + "@esbuild/openbsd-x64" "0.21.5" + "@esbuild/sunos-x64" "0.21.5" + "@esbuild/win32-arm64" "0.21.5" + "@esbuild/win32-ia32" "0.21.5" + "@esbuild/win32-x64" "0.21.5" + +esbuild@^0.23.0: + version "0.23.1" + resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.23.1.tgz#40fdc3f9265ec0beae6f59824ade1bd3d3d2dab8" + integrity sha512-VVNz/9Sa0bs5SELtn3f7qhJCDPCF5oMEl5cO9/SSinpE9hbPVvxbd572HH5AKiP7WD8INO53GgfDDhRjkylHEg== + optionalDependencies: + "@esbuild/aix-ppc64" "0.23.1" + "@esbuild/android-arm" "0.23.1" + "@esbuild/android-arm64" "0.23.1" + "@esbuild/android-x64" "0.23.1" + "@esbuild/darwin-arm64" "0.23.1" + "@esbuild/darwin-x64" "0.23.1" + "@esbuild/freebsd-arm64" "0.23.1" + "@esbuild/freebsd-x64" "0.23.1" + "@esbuild/linux-arm" "0.23.1" + "@esbuild/linux-arm64" "0.23.1" + "@esbuild/linux-ia32" "0.23.1" + "@esbuild/linux-loong64" "0.23.1" + "@esbuild/linux-mips64el" "0.23.1" + "@esbuild/linux-ppc64" "0.23.1" + "@esbuild/linux-riscv64" "0.23.1" + "@esbuild/linux-s390x" "0.23.1" + "@esbuild/linux-x64" "0.23.1" + "@esbuild/netbsd-x64" "0.23.1" + "@esbuild/openbsd-arm64" "0.23.1" + "@esbuild/openbsd-x64" "0.23.1" + "@esbuild/sunos-x64" "0.23.1" + "@esbuild/win32-arm64" "0.23.1" + "@esbuild/win32-ia32" "0.23.1" + "@esbuild/win32-x64" "0.23.1" + escalade@^3.1.1: version "3.1.1" resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz" @@ -12396,7 +12998,7 @@ expand-tilde@^2.0.0, expand-tilde@^2.0.2: dependencies: homedir-polyfill "^1.0.1" -expect@^29.7.0: +expect@^29.0.0, expect@^29.7.0: version "29.7.0" resolved "https://registry.npmjs.org/expect/-/expect-29.7.0.tgz" integrity sha512-2Zks0hf1VLFYI1kbh0I5jP3KHHyCHpkfyHBzsSXRFgl/Bg9mWYfMW8oD+PdMPlEwy5HNsR9JutYy6pMeOh61nw== @@ -12757,6 +13359,13 @@ file-uri-to-path@1.0.0: resolved "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz" integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== +filelist@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/filelist/-/filelist-1.0.4.tgz#f78978a1e944775ff9e62e744424f215e58352b5" + integrity sha512-w1cEuf3S+DrLCQL7ET6kz+gmlJdbq9J7yXCSjK/OZCPA+qEN1WyF4ZAf0YYJa4/shHJra2t/d/r8SV4Ji+x+8Q== + dependencies: + minimatch "^5.0.1" + fill-range@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz" @@ -13148,7 +13757,7 @@ fsevents@^1.2.7: bindings "^1.5.0" nan "^2.12.1" -fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2: +fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3: version "2.3.3" resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== @@ -15163,6 +15772,16 @@ jackspeak@^2.3.5: optionalDependencies: "@pkgjs/parseargs" "^0.11.0" +jake@^10.8.5: + version "10.9.2" + resolved "https://registry.yarnpkg.com/jake/-/jake-10.9.2.tgz#6ae487e6a69afec3a5e167628996b59f35ae2b7f" + integrity sha512-2P4SQ0HrLQ+fw6llpLnOaGAvN2Zu6778SJMrCUwns4fOoG9ayrTiZk3VV8sCPkVZF8ab0zksVpS8FDY5pRCNBA== + dependencies: + async "^3.2.3" + chalk "^4.0.2" + filelist "^1.0.4" + minimatch "^3.1.2" + jest-changed-files@^29.7.0: version "29.7.0" resolved "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.7.0.tgz" @@ -15630,6 +16249,11 @@ jest@^29.7.0: import-local "^3.0.2" jest-cli "^29.7.0" +joycon@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/joycon/-/joycon-3.1.1.tgz#bce8596d6ae808f8b68168f5fc69280996894f03" + integrity sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw== + jpeg-js@^0.4.1: version "0.4.4" resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.4.tgz#a9f1c6f1f9f0fa80cdb3484ed9635054d28936aa" @@ -16045,6 +16669,11 @@ lilconfig@^2.0.5: resolved "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz" integrity sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ== +lilconfig@^3.1.1: + version "3.1.2" + resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-3.1.2.tgz#e4a7c3cb549e3a606c8dcc32e5ae1005e62c05cb" + integrity sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow== + lines-and-columns@^1.1.6: version "1.2.4" resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz" @@ -16149,6 +16778,11 @@ load-json-file@^4.0.0: pify "^3.0.0" strip-bom "^3.0.0" +load-tsconfig@^0.2.3: + version "0.2.5" + resolved "https://registry.yarnpkg.com/load-tsconfig/-/load-tsconfig-0.2.5.tgz#453b8cd8961bfb912dea77eb6c168fe8cca3d3a1" + integrity sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg== + load-yaml-file@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/load-yaml-file/-/load-yaml-file-0.2.0.tgz" @@ -16254,6 +16888,11 @@ lodash.orderby@^4.6.0: resolved "https://registry.yarnpkg.com/lodash.orderby/-/lodash.orderby-4.6.0.tgz#e697f04ce5d78522f54d9338b32b81a3393e4eb3" integrity sha512-T0rZxKmghOOf5YPnn8EY5iLYeWCpZq8G41FfqoVHH5QDTAFaghJRmAdLiadEDq+ztgM2q5PjA+Z1fOwGrLgmtg== +lodash.sortby@^4.7.0: + version "4.7.0" + resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438" + integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA== + lodash.startcase@^4.4.0: version "4.4.0" resolved "https://registry.npmjs.org/lodash.startcase/-/lodash.startcase-4.4.0.tgz" @@ -16418,7 +17057,7 @@ make-dir@^2.0.0, make-dir@^2.1.0: pify "^4.0.1" semver "^5.6.0" -make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0: +make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0, make-dir@~3.1.0: version "3.1.0" resolved "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz" integrity sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw== @@ -16720,6 +17359,14 @@ micromatch@^4.0.2, micromatch@^4.0.4, micromatch@^4.0.5: braces "^3.0.2" picomatch "^2.3.1" +micromatch@^4.0.7: + version "4.0.8" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.8.tgz#d66fa18f3a47076789320b9b1af32bd86d9fa202" + integrity sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA== + dependencies: + braces "^3.0.3" + picomatch "^2.3.1" + miller-rabin@^4.0.0: version "4.0.1" resolved "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz" @@ -16745,7 +17392,7 @@ mime-types@2.1.18: dependencies: mime-db "~1.33.0" -mime-types@^2.0.1, mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.30, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24, mime-types@~2.1.34: +mime-types@^2.0.1, mime-types@^2.1.12, mime-types@^2.1.27, mime-types@^2.1.30, mime-types@^2.1.35, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -16762,6 +17409,11 @@ mime@^2.4.4: resolved "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz" integrity sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg== +mime@~2.5.2: + version "2.5.2" + resolved "https://registry.yarnpkg.com/mime/-/mime-2.5.2.tgz#6e3dc6cc2b9510643830e5f19d5cb753da5eeabe" + integrity sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg== + mimic-fn@^1.0.0: version "1.2.0" resolved "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz" @@ -16844,6 +17496,13 @@ minimatch@^9.0.1: dependencies: brace-expansion "^2.0.1" +minimatch@~3.0.4: + version "3.0.8" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.8.tgz#5e6a59bd11e2ab0de1cfb843eb2d82e546c321c1" + integrity sha512-6FsRAQsxQ61mw+qP1ZzbL9Bc78x2p5OqNgNpnoAFLTrX8n5Kxph0CsnhmKKNXTWjXqU5L0pGPR7hYk+XWZr60Q== + dependencies: + brace-expansion "^1.1.7" + minimist-options@^4.0.2: version "4.1.0" resolved "https://registry.npmjs.org/minimist-options/-/minimist-options-4.1.0.tgz" @@ -17054,7 +17713,7 @@ ms@2.1.2: resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@2.1.3, ms@^2.1.1: +ms@2.1.3, ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -17109,6 +17768,15 @@ mutexify@^1.1.0: dependencies: queue-tick "^1.0.0" +mz@^2.7.0: + version "2.7.0" + resolved "https://registry.yarnpkg.com/mz/-/mz-2.7.0.tgz#95008057a56cafadc2bc63dde7f9ff6955948e32" + integrity sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q== + dependencies: + any-promise "^1.0.0" + object-assign "^4.0.1" + thenify-all "^1.0.0" + nan@^2.12.1: version "2.18.0" resolved "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz" @@ -17151,6 +17819,11 @@ nanoid@^3.1.20, nanoid@^3.3.1, nanoid@^3.3.6: resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.6.tgz" integrity sha512-BGcqMMJuToF7i1rt+2PWSNVnWIkGCU78jBG3RxO/bZlnZPK2Cmi2QaffxGO/2RvWi9sL+FAiRiXMgsyxQ1DIDA== +nanoid@^3.3.7: + version "3.3.7" + resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8" + integrity sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g== + nanomatch@^1.2.9: version "1.2.13" resolved "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz" @@ -18110,6 +18783,11 @@ picocolors@^1.0.0: resolved "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== +picocolors@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.0.tgz#5358b76a78cde483ba5cef6a9dc9671440b27d59" + integrity sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw== + picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.2.3, picomatch@^2.3.0, picomatch@^2.3.1: version "2.3.1" resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz" @@ -18278,6 +18956,13 @@ postcss-load-config@^3.0.0: lilconfig "^2.0.5" yaml "^1.10.2" +postcss-load-config@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/postcss-load-config/-/postcss-load-config-6.0.1.tgz#6fd7dcd8ae89badcf1b2d644489cbabf83aa8096" + integrity sha512-oPtTM4oerL+UXmx+93ytZVN82RrlY/wPUV8IeDxFrzIjXOLF1pN+EmKPLbubvKHT2HC20xXsCAH2Z+CKV6Oz/g== + dependencies: + lilconfig "^3.1.1" + postcss-loader@^4.2.0: version "4.3.0" resolved "https://registry.npmjs.org/postcss-loader/-/postcss-loader-4.3.0.tgz" @@ -18366,6 +19051,16 @@ postcss-selector-parser@^6.0.0, postcss-selector-parser@^6.0.2, postcss-selector cssesc "^3.0.0" util-deprecate "^1.0.2" +postcss-url@^10.1.3: + version "10.1.3" + resolved "https://registry.yarnpkg.com/postcss-url/-/postcss-url-10.1.3.tgz#54120cc910309e2475ec05c2cfa8f8a2deafdf1e" + integrity sha512-FUzyxfI5l2tKmXdYc6VTu3TWZsInayEKPbiyW+P6vmmIrrb4I6CGX0BFoewgYHLK+oIL5FECEK02REYRpBvUCw== + dependencies: + make-dir "~3.1.0" + mime "~2.5.2" + minimatch "~3.0.4" + xxhashjs "~0.2.2" + postcss-value-parser@^3.3.1: version "3.3.1" resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz" @@ -18384,6 +19079,15 @@ postcss@^7.0.14, postcss@^7.0.26, postcss@^7.0.32, postcss@^7.0.35, postcss@^7.0 picocolors "^0.2.1" source-map "^0.6.1" +postcss@^8.0.0, postcss@^8.4.43: + version "8.4.45" + resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.4.45.tgz#538d13d89a16ef71edbf75d895284ae06b79e603" + integrity sha512-7KTLTdzdZZYscUc65XmjFiB73vBhBfbPztCYdUNvlaso9PrzjzcmjqBPR0lNGkcVlcO4BjiO5rK/qNz+XAen1Q== + dependencies: + nanoid "^3.3.7" + picocolors "^1.0.1" + source-map-js "^1.2.0" + postcss@^8.2.15, postcss@^8.4.31: version "8.4.31" resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.31.tgz" @@ -18475,7 +19179,7 @@ pretty-format@^27.0.2: ansi-styles "^5.0.0" react-is "^17.0.1" -pretty-format@^29.7.0: +pretty-format@^29.0.0, pretty-format@^29.7.0: version "29.7.0" resolved "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz" integrity sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ== @@ -19226,7 +19930,7 @@ react-window@^1.8.8: "@babel/runtime" "^7.0.0" memoize-one ">=3.1.1 <6" -react@^18, react@^18.2.0: +react@^18.2.0: version "18.3.1" resolved "https://registry.yarnpkg.com/react/-/react-18.3.1.tgz#49ab892009c53933625bd16b2533fc754cab2891" integrity sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ== @@ -19823,6 +20527,31 @@ roarr@^2.15.3: semver-compare "^1.0.0" sprintf-js "^1.1.2" +rollup@^4.19.0, rollup@^4.20.0: + version "4.21.2" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.21.2.tgz#f41f277a448d6264e923dd1ea179f0a926aaf9b7" + integrity sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw== + dependencies: + "@types/estree" "1.0.5" + optionalDependencies: + "@rollup/rollup-android-arm-eabi" "4.21.2" + "@rollup/rollup-android-arm64" "4.21.2" + "@rollup/rollup-darwin-arm64" "4.21.2" + "@rollup/rollup-darwin-x64" "4.21.2" + "@rollup/rollup-linux-arm-gnueabihf" "4.21.2" + "@rollup/rollup-linux-arm-musleabihf" "4.21.2" + "@rollup/rollup-linux-arm64-gnu" "4.21.2" + "@rollup/rollup-linux-arm64-musl" "4.21.2" + "@rollup/rollup-linux-powerpc64le-gnu" "4.21.2" + "@rollup/rollup-linux-riscv64-gnu" "4.21.2" + "@rollup/rollup-linux-s390x-gnu" "4.21.2" + "@rollup/rollup-linux-x64-gnu" "4.21.2" + "@rollup/rollup-linux-x64-musl" "4.21.2" + "@rollup/rollup-win32-arm64-msvc" "4.21.2" + "@rollup/rollup-win32-ia32-msvc" "4.21.2" + "@rollup/rollup-win32-x64-msvc" "4.21.2" + fsevents "~2.3.2" + rooks@^6.4.2: version "6.4.3" resolved "https://registry.npmjs.org/rooks/-/rooks-6.4.3.tgz" @@ -20439,6 +21168,11 @@ source-map-js@^1.0.1, source-map-js@^1.0.2: resolved "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz" integrity sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw== +source-map-js@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46" + integrity sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA== + source-map-resolve@^0.5.0: version "0.5.3" resolved "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz" @@ -20471,6 +21205,13 @@ source-map-url@^0.4.0: resolved "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz" integrity sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw== +source-map@0.8.0-beta.0: + version "0.8.0-beta.0" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.8.0-beta.0.tgz#d4c1bb42c3f7ee925f005927ba10709e0d1d1f11" + integrity sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA== + dependencies: + whatwg-url "^7.0.0" + source-map@^0.5.0, source-map@^0.5.6, source-map@~0.5.3: version "0.5.7" resolved "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz" @@ -21057,6 +21798,19 @@ subarg@^1.0.0: dependencies: minimist "^1.1.0" +sucrase@^3.35.0: + version "3.35.0" + resolved "https://registry.yarnpkg.com/sucrase/-/sucrase-3.35.0.tgz#57f17a3d7e19b36d8995f06679d121be914ae263" + integrity sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA== + dependencies: + "@jridgewell/gen-mapping" "^0.3.2" + commander "^4.0.0" + glob "^10.3.10" + lines-and-columns "^1.1.6" + mz "^2.7.0" + pirates "^4.0.1" + ts-interface-checker "^0.1.9" + sumchecker@^3.0.1: version "3.0.1" resolved "https://registry.npmjs.org/sumchecker/-/sumchecker-3.0.1.tgz" @@ -21323,6 +22077,20 @@ thenby@^1.3.4: resolved "https://registry.npmjs.org/thenby/-/thenby-1.3.4.tgz" integrity sha512-89Gi5raiWA3QZ4b2ePcEwswC3me9JIg+ToSgtE0JWeCynLnLxNr/f9G+xfo9K+Oj4AFdom8YNJjibIARTJmapQ== +thenify-all@^1.0.0: + version "1.6.0" + resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" + integrity sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA== + dependencies: + thenify ">= 3.1.0 < 4" + +"thenify@>= 3.1.0 < 4": + version "3.3.1" + resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.1.tgz#8932e686a4066038a016dd9e2ca46add9838a95f" + integrity sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw== + dependencies: + any-promise "^1.0.0" + throttleit@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/throttleit/-/throttleit-1.0.0.tgz" @@ -21491,6 +22259,13 @@ tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" +tr46@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09" + integrity sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA== + dependencies: + punycode "^2.1.0" + tr46@^3.0.0: version "3.0.0" resolved "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz" @@ -21561,6 +22336,11 @@ ts-dedent@^2.0.0, ts-dedent@^2.2.0: resolved "https://registry.npmjs.org/ts-dedent/-/ts-dedent-2.2.0.tgz" integrity sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ== +ts-interface-checker@^0.1.9: + version "0.1.13" + resolved "https://registry.yarnpkg.com/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz#784fd3d679722bc103b1b4b8030bcddb5db2a699" + integrity sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA== + ts-jest@^29.1.1: version "29.1.1" resolved "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.1.tgz" @@ -21661,6 +22441,28 @@ tslint@^5.18.0: tslib "^1.8.0" tsutils "^2.29.0" +tsup@^8.2.4: + version "8.2.4" + resolved "https://registry.yarnpkg.com/tsup/-/tsup-8.2.4.tgz#5e31790c1e66392cee384ad746ed51c106614beb" + integrity sha512-akpCPePnBnC/CXgRrcy72ZSntgIEUa1jN0oJbbvpALWKNOz1B7aM+UVDWGRGIO/T/PZugAESWDJUAb5FD48o8Q== + dependencies: + bundle-require "^5.0.0" + cac "^6.7.14" + chokidar "^3.6.0" + consola "^3.2.3" + debug "^4.3.5" + esbuild "^0.23.0" + execa "^5.1.1" + globby "^11.1.0" + joycon "^3.1.1" + picocolors "^1.0.1" + postcss-load-config "^6.0.1" + resolve-from "^5.0.0" + rollup "^4.19.0" + source-map "0.8.0-beta.0" + sucrase "^3.35.0" + tree-kill "^1.2.2" + tsutils@^2.29.0: version "2.29.0" resolved "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz" @@ -22465,6 +23267,34 @@ vfile@^4.0.0: unist-util-stringify-position "^2.0.0" vfile-message "^2.0.0" +vite-plugin-generate-file@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/vite-plugin-generate-file/-/vite-plugin-generate-file-0.2.0.tgz#fe143a80888c7320ffe1dad42925e8b5bf2b606c" + integrity sha512-mAHqvyFWrqbYNmWmSjhfyxShEgVN9ZPSI/cRove86KEYQIJUZ74XajXpPMwIE1xll9piA5Cmhi8kt/ydQSzZ/Q== + dependencies: + ejs "^3.1.9" + js-yaml "^4.1.0" + mime-types "^2.1.35" + picocolors "^1.0.0" + +vite-plugin-singlefile@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/vite-plugin-singlefile/-/vite-plugin-singlefile-2.0.2.tgz#af2c95e0182bd363dbe29b80bea5c5a78209f649" + integrity sha512-Z2ou6HcvED5CF0hM+vcFSaFa+klyS8RyyLxW0PbMRLnMbvzTI6ueWyxdYNFhpuXZgz/aj6+E/dHFTdEcw6gb9w== + dependencies: + micromatch "^4.0.7" + +vite@^5.4.4: + version "5.4.4" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.4.tgz#3da90314b617047366459443320ea78f39111008" + integrity sha512-RHFCkULitycHVTtelJ6jQLd+KSAAzOgEYorV32R2q++M6COBjKJR6BxqClwp5sf0XaBDjVMuJ9wnNfyAJwjMkA== + dependencies: + esbuild "^0.21.3" + postcss "^8.4.43" + rollup "^4.20.0" + optionalDependencies: + fsevents "~2.3.3" + vm-browserify@^1.0.0, vm-browserify@^1.0.1: version "1.1.2" resolved "https://registry.npmjs.org/vm-browserify/-/vm-browserify-1.1.2.tgz" @@ -22555,6 +23385,11 @@ webidl-conversions@^3.0.0: resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz" integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ== +webidl-conversions@^4.0.2: + version "4.0.2" + resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad" + integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg== + webidl-conversions@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff" @@ -22841,6 +23676,15 @@ whatwg-url@^5.0.0: tr46 "~0.0.3" webidl-conversions "^3.0.0" +whatwg-url@^7.0.0: + version "7.1.0" + resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-7.1.0.tgz#c2c492f1eca612988efd3d2266be1b9fc6170d06" + integrity sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg== + dependencies: + lodash.sortby "^4.7.0" + tr46 "^1.0.1" + webidl-conversions "^4.0.2" + which-boxed-primitive@^1.0.2: version "1.0.2" resolved "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz" @@ -23088,6 +23932,13 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@^4.0.2, xtend@~4.0.1: resolved "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== +xxhashjs@~0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/xxhashjs/-/xxhashjs-0.2.2.tgz#8a6251567621a1c46a5ae204da0249c7f8caa9d8" + integrity sha512-AkTuIuVTET12tpsVIQo+ZU6f/qDmKuRUcjaqR+OIvm+aCBsZ95i7UVY5WJ9TMsSaZ0DA2WxoZ4acu0sPH+OKAw== + dependencies: + cuint "^0.2.2" + y18n@^4.0.0: version "4.0.3" resolved "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz" From 21b3f4dec458e71edc491c627b973f8e21c6d622 Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Mon, 16 Sep 2024 22:53:32 +0300 Subject: [PATCH 06/12] add variables sync package.json dependencies --- packages/variables-sync-plugin/package.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/variables-sync-plugin/package.json b/packages/variables-sync-plugin/package.json index 280a30d47..37c36a4d5 100644 --- a/packages/variables-sync-plugin/package.json +++ b/packages/variables-sync-plugin/package.json @@ -5,9 +5,20 @@ "description": "", "main": "index.js", "dependencies": { - "@tokens-studio/sync-providers": "*" + "@octokit/rest": "^21.0.2", + "@stitches/react": "^1.2.8", + "@tokens-studio/sync-providers": "*", + "@tokens-studio/tokens": "^0.2.5", + "@tokens-studio/ui": "^0.11.0", + "octokit-commit-multiple-files": "^5.0.2" }, "scripts": { + "start": "run-s dev", + "dev": "run-s watch", + "dev:ui-only": "vite -c ./vite.config.ui.ts", + "watch": "run-p watch:*", + "watch:ui": "npm run build:ui -- --watch --mode=development", + "watch:plugin": "npm run build:plugin -- --watch --mode=development", "build:ui": "vite build -c ./vite.config.ui.ts", "build:plugin": "vite build -c ./vite.config.plugin.ts", "test": "echo \"Error: no test specified\" && exit 1" From f2034fc4a28747e09dc3a7680bc1362a34b1d0cf Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Wed, 18 Sep 2024 01:36:46 +0400 Subject: [PATCH 07/12] [WIP] push to github button for variable sync plugin --- .../providers/github/GitHubTokenStorage.ts | 11 +- packages/variables-sync-plugin/package.json | 1 + .../src/app/AppContainer/index.tsx | 92 ++++++ .../variables-sync-plugin/src/app/app.tsx | 24 ++ .../variables-sync-plugin/src/app/index.html | 3 + .../variables-sync-plugin/src/app/index.tsx | 307 ++++++++++++++++++ .../src/app/lib/figmaAPI.ts | 70 ++++ .../src/app/stitches.config.ts | 72 ++++ .../src/app/sync/GitHubSync.tsx | 158 +++++++++ .../variables-sync-plugin/vite.config.ui.ts | 3 +- yarn.lock | 216 +++++++++++- 11 files changed, 947 insertions(+), 10 deletions(-) create mode 100644 packages/variables-sync-plugin/src/app/AppContainer/index.tsx create mode 100644 packages/variables-sync-plugin/src/app/app.tsx create mode 100644 packages/variables-sync-plugin/src/app/index.html create mode 100644 packages/variables-sync-plugin/src/app/index.tsx create mode 100644 packages/variables-sync-plugin/src/app/lib/figmaAPI.ts create mode 100644 packages/variables-sync-plugin/src/app/stitches.config.ts create mode 100644 packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx diff --git a/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts b/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts index d5ce11b8a..d9f9e890b 100644 --- a/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts +++ b/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts @@ -1,6 +1,7 @@ import compact from 'just-compact'; import { Octokit } from '@octokit/rest'; -import commitMultipleFiles from 'octokit-commit-multiple-files'; +import OctokitCommitMultipleFiles from 'octokit-commit-multiple-files'; +import octokitCommitMultipleFilesFallback from 'octokit-commit-multiple-files/create-or-update-files'; import type { RemoteTokenstorageErrorMessage, RemoteTokenStorageFile, RemoteTokenStorageMetadata } from '../../types'; import { isJSONString, joinPath } from '../../utils'; @@ -42,6 +43,8 @@ const octokitClientDefaultHeaders = { }; +const commitMultipleFiles = octokitClient => async (params) => octokitCommitMultipleFilesFallback(octokitClient, params); + export class GithubTokenStorage extends GitTokenStorage { private octokitClient: ExtendedOctokitClient; @@ -57,7 +60,7 @@ export class GithubTokenStorage extends GitTokenStorage { }; // eslint-disable-next-line - const ExtendedOctokitConstructor = Octokit.plugin(commitMultipleFiles); + const ExtendedOctokitConstructor = Octokit.plugin(OctokitCommitMultipleFiles); this.octokitClient = new ExtendedOctokitConstructor({ auth: this.secret, baseUrl: this.baseUrl || undefined, @@ -274,7 +277,9 @@ export class GithubTokenStorage extends GitTokenStorage { } public async createOrUpdate(changeset: Record, message: string, branch: string, shouldCreateBranch?: boolean, filesToDelete?: string[], ignoreDeletionFailures?: boolean): Promise { - const response = await this.octokitClient.repos.createOrUpdateFiles({ + const createOrUpdateFiles = this.octokitClient.repos.createOrUpdateFiles || commitMultipleFiles(this.octokitClient); + + const response = await createOrUpdateFiles({ branch, owner: this.owner, repo: this.repository, diff --git a/packages/variables-sync-plugin/package.json b/packages/variables-sync-plugin/package.json index 37c36a4d5..a2ef05d9d 100644 --- a/packages/variables-sync-plugin/package.json +++ b/packages/variables-sync-plugin/package.json @@ -36,6 +36,7 @@ "postcss-url": "^10.1.3", "vite": "^5.4.4", "vite-plugin-generate-file": "^0.2.0", + "vite-plugin-node-polyfills": "^0.22.0", "vite-plugin-singlefile": "^2.0.2" } } diff --git a/packages/variables-sync-plugin/src/app/AppContainer/index.tsx b/packages/variables-sync-plugin/src/app/AppContainer/index.tsx new file mode 100644 index 000000000..ec764ebb2 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/AppContainer/index.tsx @@ -0,0 +1,92 @@ + +import { Box, Button } from '@tokens-studio/ui'; + +import { figmaAPI } from "../lib/figmaAPI"; +import GitHubSync from '../sync/GitHubSync'; + +function rgbToHex({ r, g, b, a }: { r: number, g: number, b: number, a: number }) { + if (a !== 1) { + return `rgba(${[r, g, b] + .map((n) => Math.round(n * 255)) + .join(", ")}, ${a.toFixed(4)})`; + } + const toHex = (value: number) => { + const hex = Math.round(value * 255).toString(16); + return hex.length === 1 ? "0" + hex : hex; + }; + + const hex = [toHex(r), toHex(g), toHex(b)].join(""); + return `#${hex}`; +} + +export default () => ( + <> + + + + + + + +); diff --git a/packages/variables-sync-plugin/src/app/app.tsx b/packages/variables-sync-plugin/src/app/app.tsx new file mode 100644 index 000000000..ea851bc3d --- /dev/null +++ b/packages/variables-sync-plugin/src/app/app.tsx @@ -0,0 +1,24 @@ +import React, { useEffect, useState } from 'react'; +import { createRoot } from 'react-dom/client'; +import AppContainer from './AppContainer'; + + +export default async () => { + const container = document.getElementById('app'); + + // Side effect from first load + + const root = createRoot(container!); + root.render( + + ) + // root.render( + // // + // // + // // + // + // {/* + // + // , */} + // ); +}; diff --git a/packages/variables-sync-plugin/src/app/index.html b/packages/variables-sync-plugin/src/app/index.html new file mode 100644 index 000000000..7152adbe7 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/index.html @@ -0,0 +1,3 @@ +
+ + diff --git a/packages/variables-sync-plugin/src/app/index.tsx b/packages/variables-sync-plugin/src/app/index.tsx new file mode 100644 index 000000000..92aa92eda --- /dev/null +++ b/packages/variables-sync-plugin/src/app/index.tsx @@ -0,0 +1,307 @@ +// const INTER_BOLD = { family: "Inter", style: "Bold" }; +// figma.loadFontAsync(INTER_BOLD); +// console.log(123); +import React from 'react'; +import { createRoot } from 'react-dom/client'; + +// import render from './app'; + +// figma.ui.onmessage = async (message, props) => { +// // console.log({ message, props }, '123'); +// // if (props.origin !== SITE_URL) { +// // return; +// // } +// // if (message.type === 'RELOAD') { +// // eval(message.code); +// // return; +// // } + +// switch (message.type) { +// case "EVAL": { +// // const fn = eval.call(null, message.code); +// const fn = Function(`"use strict"; return ${message.code}`)(); + +// try { +// const result = await fn(figma, {}); +// figma.ui.postMessage({ +// type: "EVAL_RESULT", +// result, +// id: message.id, +// }); +// } catch (e) { +// figma.ui.postMessage({ +// type: "EVAL_REJECT", +// error: +// typeof e === "string" +// ? e +// : e && typeof e === "object" && "message" in e +// ? e.message +// : null, +// id: message.id, +// }); +// } + +// break; +// } +// } +// }; + +// app(); + +// // getLocalVariableCollectionsAsync + +// // figma.ui.onmessage = characters => { +// // if (characters === 'RELOAD') { +// // window.location.reload(); +// // return; +// // } +// // if (figma.currentPage.selection.length === 0) { +// // const text = figma.createText(); +// // figma.currentPage.selection = [text]; +// // } + +// // for (const node of figma.currentPage.selection) { +// // if (node.type === 'TEXT') { +// // node.fontName = INTER_BOLD; +// // node.characters = characters; +// // } +// // } + +// // // figma.closePlugin(); +// // } + +class FigmaAPI { + // private id = 0; + id = 0; + + /** + * Run a function in the Figma plugin context. The function cannot reference + * any variables outside of itself, and the return value must be JSON + * serializable. If you need to pass in variables, you can do so by passing + * them as the second parameter. + */ + run( + fn: (figma: PluginAPI, params: U) => Promise | T, + params?: U, + ): Promise { + + return new Promise((resolve, reject) => { + const id = this.id++; + const cb = (event: MessageEvent) => { + if ( + event.origin !== "https://www.figma.com" && + event.origin !== "https://staging.figma.com" + ) { + return; + } + + if (event.data.pluginMessage?.type === "EVAL_RESULT") { + if (event.data.pluginMessage.id === id) { + window.removeEventListener("message", cb); + resolve(event.data.pluginMessage.result); + } + } + + if (event.data.pluginMessage?.type === "EVAL_REJECT") { + if (event.data.pluginMessage.id === id) { + window.removeEventListener("message", cb); + const message = event.data.pluginMessage.error; + reject( + new Error( + typeof message === "string" + ? message + : "An error occurred in FigmaAPI.run()", + ), + ); + } + } + }; + window.addEventListener("message", cb); + + const msg = { + pluginMessage: { + type: "EVAL", + code: fn.toString(), + id, + params, + }, + pluginId: "*", + }; + + ["https://www.figma.com", "https://staging.figma.com"].forEach( + (origin) => { + try { + parent.postMessage(msg, origin); + } catch {} + }, + ); + }); + } +} + +const figmaAPI = new FigmaAPI(); + +function postMessage(pluginMessage: any) { + parent.postMessage({ pluginMessage, pluginId: '*' }, '*'); +} + +// (async () => { + +// try { +// // Bootload code +// await fetch('./code.js?nocache=' + (new Date()).getTime()) +// .then(response => response.text()) +// .then(code => postMessage(code)); +// } catch (err) { +// // Silent fail, since we're assuming the remote code.js isn't available and the plugin is falling back to the local build +// } + +// // Setup event handlers +// document.querySelector('#clickMe').onclick = async () => { +// const text = 'Hello, World!'; + +// // postMessage('Hello Config!'); +// const success = await figmaAPI.run(async (figma) => { +// const characters = 'Hello, World!'; +// const INTER_BOLD = { family: "Inter", style: "Bold" }; + +// if (figma.currentPage.selection.length === 0) { +// const text = figma.createText(); +// figma.currentPage.selection = [text]; +// } + +// for (const node of figma.currentPage.selection) { +// if (node.type === 'TEXT') { +// node.fontName = INTER_BOLD; +// node.characters = characters; +// } +// } +// // // if (figma.currentPage.selection.length === 0) { +// // // const text = figma.createText(); +// // // figma.currentPage.selection = [text]; +// // // console.log('createText()') +// // // } +// // figma.notify( +// // "Please select a layer with text in it to generate a poem. 123", +// // { error: true }, +// // ); +// return true; +// }); +// console.log({ success }) +// } + +// document.querySelector('#getVariables').onclick = async () => { +// const variablesJSON = await figmaAPI.run(async (figma) => { +// function rgbToHex({ r, g, b, a }) { +// if (a !== 1) { +// return `rgba(${[r, g, b] +// .map((n) => Math.round(n * 255)) +// .join(", ")}, ${a.toFixed(4)})`; +// } +// const toHex = (value) => { +// const hex = Math.round(value * 255).toString(16); +// return hex.length === 1 ? "0" + hex : hex; +// }; + +// const hex = [toHex(r), toHex(g), toHex(b)].join(""); +// return `#${hex}`; +// } +// const collections = await figma.variables.getLocalVariableCollectionsAsync(); + +// async function processCollection({ name, modes, variableIds }) { +// const files = []; +// for (const mode of modes) { +// const file = { fileName: `${name}.${mode.name}.tokens.json`, body: {} }; +// for (const variableId of variableIds) { +// const { name, resolvedType, valuesByMode } = +// await figma.variables.getVariableByIdAsync(variableId); +// const value = valuesByMode[mode.modeId]; +// if (value !== undefined && ["COLOR", "FLOAT"].includes(resolvedType)) { +// let obj = file.body; +// name.split("/").forEach((groupName) => { +// obj[groupName] = obj[groupName] || {}; +// obj = obj[groupName]; +// }); +// obj.$type = resolvedType === "COLOR" ? "color" : "number"; +// if (value.type === "VARIABLE_ALIAS") { +// const currentVar = await figma.variables.getVariableByIdAsync( +// value.id +// ); +// obj.$value = `{${currentVar.name.replace(/\//g, ".")}}`; +// } else { +// obj.$value = resolvedType === "COLOR" ? rgbToHex(value) : value; +// } +// } +// } +// files.push(file); +// } +// return files; +// } + +// const files = []; +// for (const collection of collections) { +// try { +// files.push(...(await processCollection(collection))); +// } catch (err) { +// console.log({ err }) +// } +// } +// // let allVariables = []; + +// // // Loop through each collection and fetch variables +// // for (const collection of variableCollections) { +// // const variablesInCollection = figma.variables.getVariablesById(collection.id); + +// // // Format variables for JSON +// // const formattedCollection = { +// // id: collection.id, +// // name: collection.name, +// // description: collection.description, +// // variables: variablesInCollection.map((variable) => ({ +// // id: variable.id, +// // name: variable.name, +// // type: variable.type, +// // resolvedValue: variable.getValueForMode("default") // Get value for default mode (or other modes if needed) +// // })), +// // }; + +// // allVariables.push(formattedCollection); +// // } + +// // Prepare the data as JSON string +// return files; +// }); +// // const jsonData = JSON.stringify(files, null, 2); // Pretty print with 2-space indent +// console.log(JSON.stringify(variablesJSON, null, 2)); +// } +// document.querySelector('#refreshButton').onclick = async () => { +// // postMessage('RELOAD'); +// await fetch('./code.js?nocache=' + (new Date()).getTime()) +// .then(response => response.text()) +// .then(code => postMessage({ type: 'RELOAD', code })); + +// window.location = 'http://127.0.0.1:8080/webpage/ui.html?nocache=' + (new Date()).getTime(); +// } +// })() + +async function bootstrap() { + try { + // Bootload code + await fetch('./code.js?nocache=' + (new Date()).getTime()) + .then(response => response.text()) + .then(code => postMessage(code)); + } catch (err) { + // Silent fail, since we're assuming the remote code.js isn't available and the plugin is falling back to the local build + } + + const App = (await import("./AppContainer")).default; + + const container = document.getElementById('app'); + + const root = createRoot(container!); + root.render( + + ) +} + +bootstrap(); diff --git a/packages/variables-sync-plugin/src/app/lib/figmaAPI.ts b/packages/variables-sync-plugin/src/app/lib/figmaAPI.ts new file mode 100644 index 000000000..9dee88a18 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/lib/figmaAPI.ts @@ -0,0 +1,70 @@ +class FigmaAPI { + // private id = 0; + id = 0; + + /** + * Run a function in the Figma plugin context. The function cannot reference + * any variables outside of itself, and the return value must be JSON + * serializable. If you need to pass in variables, you can do so by passing + * them as the second parameter. + */ + run( + fn: (figma: PluginAPI, params: U) => Promise | T, + params?: U, + ): Promise { + + return new Promise((resolve, reject) => { + const id = this.id++; + const cb = (event: MessageEvent) => { + if ( + event.origin !== "https://www.figma.com" && + event.origin !== "https://staging.figma.com" + ) { + return; + } + + if (event.data.pluginMessage?.type === "EVAL_RESULT") { + if (event.data.pluginMessage.id === id) { + window.removeEventListener("message", cb); + resolve(event.data.pluginMessage.result); + } + } + + if (event.data.pluginMessage?.type === "EVAL_REJECT") { + if (event.data.pluginMessage.id === id) { + window.removeEventListener("message", cb); + const message = event.data.pluginMessage.error; + reject( + new Error( + typeof message === "string" + ? message + : "An error occurred in FigmaAPI.run()", + ), + ); + } + } + }; + window.addEventListener("message", cb); + + const msg = { + pluginMessage: { + type: "EVAL", + code: fn.toString(), + id, + params, + }, + pluginId: "*", + }; + + ["https://www.figma.com", "https://staging.figma.com"].forEach( + (origin) => { + try { + parent.postMessage(msg, origin); + } catch {} + }, + ); + }); + } +} + +export const figmaAPI = new FigmaAPI(); diff --git a/packages/variables-sync-plugin/src/app/stitches.config.ts b/packages/variables-sync-plugin/src/app/stitches.config.ts new file mode 100644 index 000000000..e3d0dbb41 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/stitches.config.ts @@ -0,0 +1,72 @@ +// stitches.config.ts +import { createStitches } from '@stitches/react'; +import { lightFigmaTheme as lightTheme, darkFigmaTheme as darkTheme, core } from '@tokens-studio/tokens'; + +export const stitchesInstance = createStitches({ + theme: { + colors: { + ...lightTheme.colors, + // TODO: We need to add these to the ui tokens. + proBg: '#e1d8ec', + proBorder: '#c2b2d8', + proFg: '#694993', + }, + shadows: lightTheme.shadows, + ...core, + fontWeights: { + ...core.fontWeights, + // TODO: We should likely make everything 500 and get rid of 600 + sansBold: 500, + }, + fontSizes: { + ...core.fontSizes, + // TODO: We should remove this once we have a way to choose density / font size + xxsmall: '11px !important', + xsmall: '11px !important', + small: '12px !important', + base: '13px !important', + medium: '13px !important', + large: '14px !important', + }, + radii: { + ...core.radii, + // TODO: Add to tokens + full: '999px', + }, + sizes: { + ...core.sizes, + // TODO: Add to tokens + scrollbarWidth: '8px', + }, + }, +}); + +const { + createTheme, styled, css, keyframes, theme, globalCss, +} = stitchesInstance; + +const lightThemeMode = createTheme('figma-light', { + colors: { + ...lightTheme.colors, + // TODO: We need to add these to the ui tokens. + proBg: '#e1d8ec', + proBorder: '#c2b2d8', + proFg: '#694993', + }, + shadows: lightTheme.shadows, +}); + +const darkThemeMode = createTheme('figma-dark', { + colors: { + ...darkTheme.colors, + // TODO: We need to add these to the ui tokens. + proBg: '#402d5a', + proBorder: '#694993', + proFg: '#c2b2d8', + }, + shadows: darkTheme.shadows, +}); + +export { + lightThemeMode, darkThemeMode, styled, css, keyframes, theme, globalCss, +}; diff --git a/packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx b/packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx new file mode 100644 index 000000000..46f554259 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx @@ -0,0 +1,158 @@ +// @ts-nocheck +import { GithubTokenStorage } from "@tokens-studio/sync-providers"; +import { StorageTypeCredentials } from "@tokens-studio/sync-providers/types"; +import { Button } from "@tokens-studio/ui"; +import { useCallback, useState } from "react"; +import { figmaAPI } from "../lib/figmaAPI"; + +type GithubCredentials = Extract< + StorageTypeCredentials, + { provider: StorageProviderType.GITHUB } +>; + +export default () => { + const [variables, setVariables] = useState([]); + const storageClientFactory = useCallback( + (context: GithubCredentials, owner?: string, repo?: string) => { + const splitContextId = context.id.split("/"); + const storageClient = new GithubTokenStorage( + context.secret, + owner ?? splitContextId[0], + repo ?? splitContextId[1], + context.baseUrl ?? "" + ); + + if (context.filePath) storageClient.changePath(context.filePath); + if (context.branch) storageClient.selectBranch(context.branch); + storageClient.enableMultiFile(); + // if (isProUser) storageClient.enableMultiFile(); + + return storageClient; + }, + [] + ); + + const pushTokensToGitHub = useCallback( + async ( + context: GithubCredentials, + overrides?: PushOverrides + ): Promise => { + const storage = storageClientFactory({ + id: "user/repo", + secret: "github_key", + branch: "branchname", + filePath: "variables", + }); + + const files = variables?.map(({ fileName, body }) => ({ + type: "tokenSet", + name: "setName", + path: fileName, + data: body, + })); + if (files.length > 0) { + storage.write(files, { commitMessage: "test" }); + } + } + ); + // if (dispatch) { + // dispatch.uiState.setLocalApiState({ ...context }); + // } + + return ( + <> + + + + ); +}; diff --git a/packages/variables-sync-plugin/vite.config.ui.ts b/packages/variables-sync-plugin/vite.config.ui.ts index d1e2a68fe..25b5b54ee 100644 --- a/packages/variables-sync-plugin/vite.config.ui.ts +++ b/packages/variables-sync-plugin/vite.config.ui.ts @@ -3,13 +3,14 @@ import path from "node:path"; import { viteSingleFile } from "vite-plugin-singlefile"; import react from '@vitejs/plugin-react-swc'; // import richSvg from "vite-plugin-react-rich-svg"; +import { nodePolyfills } from 'vite-plugin-node-polyfills'; import postcssUrl from "postcss-url"; // import figmaManifest from './figma.manifest'; // https://vitejs.dev/config/ export default defineConfig(({ mode }) => ({ - plugins: [react(),/* richSvg()*/, viteSingleFile()], + plugins: [react(),/* richSvg()*/, viteSingleFile(), nodePolyfills()], root: path.resolve("src/app"), build: { minify: mode === "production", diff --git a/yarn.lock b/yarn.lock index baeac4a5f..97093bb73 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3670,6 +3670,11 @@ resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== +"@jridgewell/sourcemap-codec@^1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz#3188bcb273a414b0d215fd22a58540b989b9409a" + integrity sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ== + "@jridgewell/trace-mapping@0.3.9": version "0.3.9" resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz" @@ -4861,6 +4866,24 @@ resolved "https://registry.npmjs.org/@rematch/core/-/core-2.2.0.tgz" integrity sha512-Sj3nC/2X+bOBZeOf4jdJ00nhCcx9wLbVK9SOs6eFR4Y1qKXqRY0hGigbQgfTpCdjRFlwTHHfN3m41MlNvMhDgw== +"@rollup/plugin-inject@^5.0.5": + version "5.0.5" + resolved "https://registry.yarnpkg.com/@rollup/plugin-inject/-/plugin-inject-5.0.5.tgz#616f3a73fe075765f91c5bec90176608bed277a3" + integrity sha512-2+DEJbNBoPROPkgTDNe8/1YXWcqxbN5DTjASVIOx8HS+pITXushyNiBV56RB08zuptzz8gT3YfkqriTBVycepg== + dependencies: + "@rollup/pluginutils" "^5.0.1" + estree-walker "^2.0.2" + magic-string "^0.30.3" + +"@rollup/pluginutils@^5.0.1": + version "5.1.0" + resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-5.1.0.tgz#7e53eddc8c7f483a4ad0b94afb1f7f5fd3c771e0" + integrity sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g== + dependencies: + "@types/estree" "^1.0.0" + estree-walker "^2.0.2" + picomatch "^2.3.1" + "@rollup/rollup-android-arm-eabi@4.21.2": version "4.21.2" resolved "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.21.2.tgz#0412834dc423d1ff7be4cb1fc13a86a0cd262c11" @@ -8695,6 +8718,17 @@ assert@^1.1.1, assert@^1.4.0: object.assign "^4.1.4" util "^0.10.4" +assert@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/assert/-/assert-2.1.0.tgz#6d92a238d05dc02e7427c881fb8be81c8448b2dd" + integrity sha512-eLHpSK/Y4nhMJ07gDaAzoX/XAKS8PSaojml3M0DM4JpV1LAi5JOJ/p6H/XWrl8L+DzVEvVCW1z3vWAaB9oTsQw== + dependencies: + call-bind "^1.0.2" + is-nan "^1.3.2" + object-is "^1.1.5" + object.assign "^4.1.4" + util "^0.12.5" + assign-symbols@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz" @@ -9511,7 +9545,7 @@ buffer@4.9.2, buffer@^4.3.0: ieee754 "^1.1.4" isarray "^1.0.0" -buffer@^5.4.3, buffer@^5.5.0, buffer@^5.6.0: +buffer@^5.4.3, buffer@^5.5.0, buffer@^5.6.0, buffer@^5.7.1: version "5.7.1" resolved "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz" integrity sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ== @@ -9688,6 +9722,17 @@ call-bind@^1.0.0, call-bind@^1.0.2: function-bind "^1.1.1" get-intrinsic "^1.0.2" +call-bind@^1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.7.tgz#06016599c40c56498c18769d2730be242b6fa3b9" + integrity sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + set-function-length "^1.2.1" + call-me-maybe@^1.0.1: version "1.0.2" resolved "https://registry.npmjs.org/call-me-maybe/-/call-me-maybe-1.0.2.tgz" @@ -10702,7 +10747,7 @@ create-jest@^29.7.0: jest-util "^29.7.0" prompts "^2.0.1" -create-require@^1.1.0: +create-require@^1.1.0, create-require@^1.1.1: version "1.1.1" resolved "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz" integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== @@ -11470,6 +11515,15 @@ define-data-property@^1.0.1: gopd "^1.0.1" has-property-descriptors "^1.0.0" +define-data-property@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/define-data-property/-/define-data-property-1.1.4.tgz#894dc141bb7d3060ae4366f6a0107e68fbe48c5e" + integrity sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A== + dependencies: + es-define-property "^1.0.0" + es-errors "^1.3.0" + gopd "^1.0.1" + define-lazy-prop@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-2.0.0.tgz" @@ -11800,6 +11854,11 @@ domain-browser@^1.1.1, domain-browser@^1.2.0: resolved "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz" integrity sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA== +domain-browser@^4.22.0: + version "4.23.0" + resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-4.23.0.tgz#427ebb91efcb070f05cffdfb8a4e9a6c25f8c94b" + integrity sha512-ArzcM/II1wCCujdCNyQjXrAFwS4mrLh4C7DZWlaI8mdh7h3BfKdNd3bKXITfl2PT9FtfQqaGvhi1vPRQPimjGA== + domelementtype@1: version "1.3.1" resolved "https://registry.npmjs.org/domelementtype/-/domelementtype-1.3.1.tgz" @@ -12191,6 +12250,18 @@ es-array-method-boxes-properly@^1.0.0: resolved "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz" integrity sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA== +es-define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/es-define-property/-/es-define-property-1.0.0.tgz#c7faefbdff8b2696cf5f46921edfb77cc4ba3845" + integrity sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ== + dependencies: + get-intrinsic "^1.2.4" + +es-errors@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/es-errors/-/es-errors-1.3.0.tgz#05f75a25dab98e4fb1dcd5e1472c0546d5057c8f" + integrity sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw== + es-get-iterator@^1.0.2, es-get-iterator@^1.1.3: version "1.1.3" resolved "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz" @@ -12819,6 +12890,11 @@ estree-to-babel@^3.1.0: "@babel/types" "^7.2.0" c8 "^7.6.0" +estree-walker@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-2.0.2.tgz#52f010178c2a4c117a7757cfe942adb7d2da4cac" + integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== + esutils@^2.0.2: version "2.0.3" resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz" @@ -13762,7 +13838,7 @@ fsevents@^2.1.2, fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3: resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== -function-bind@^1.1.1: +function-bind@^1.1.1, function-bind@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz" integrity sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA== @@ -13832,6 +13908,17 @@ get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@ has-proto "^1.0.1" has-symbols "^1.0.3" +get-intrinsic@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.4.tgz#e385f5a4b5227d449c3eabbad05494ef0abbeadd" + integrity sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ== + dependencies: + es-errors "^1.3.0" + function-bind "^1.1.2" + has-proto "^1.0.1" + has-symbols "^1.0.3" + hasown "^2.0.0" + get-nonce@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/get-nonce/-/get-nonce-1.0.1.tgz" @@ -14307,6 +14394,13 @@ has-property-descriptors@^1.0.0: dependencies: get-intrinsic "^1.1.1" +has-property-descriptors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz#963ed7d071dc7bf5f084c5bfbe0d1b6222586854" + integrity sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg== + dependencies: + es-define-property "^1.0.0" + has-proto@^1.0.1: version "1.0.1" resolved "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz" @@ -14382,6 +14476,13 @@ hash.js@^1.0.0, hash.js@^1.0.3: inherits "^2.0.3" minimalistic-assert "^1.0.1" +hasown@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.2.tgz#003eaf91be7adc372e84ec59dc37252cedb80003" + integrity sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ== + dependencies: + function-bind "^1.1.2" + hast-to-hyperscript@^9.0.0: version "9.0.1" resolved "https://registry.npmjs.org/hast-to-hyperscript/-/hast-to-hyperscript-9.0.1.tgz" @@ -15372,6 +15473,14 @@ is-map@^2.0.1, is-map@^2.0.2: resolved "https://registry.npmjs.org/is-map/-/is-map-2.0.2.tgz" integrity sha512-cOZFQQozTha1f4MxLFzlgKYPTyj26picdZTx82hbc/Xf4K/tZOOXSCkMvU4pKioRXGDLJRn0GM7Upe7kR721yg== +is-nan@^1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/is-nan/-/is-nan-1.3.2.tgz#043a54adea31748b55b6cd4e09aadafa69bd9e1d" + integrity sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + is-negative-zero@^2.0.2: version "2.0.2" resolved "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz" @@ -15673,6 +15782,11 @@ isobject@^4.0.0: resolved "https://registry.npmjs.org/isobject/-/isobject-4.0.0.tgz" integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA== +isomorphic-timers-promises@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/isomorphic-timers-promises/-/isomorphic-timers-promises-1.0.1.tgz#e4137c24dbc54892de8abae3a4b5c1ffff381598" + integrity sha512-u4sej9B1LPSxTGKB/HiuzvEQnXH0ECYkSVQU39koSwmFAxhlEAFl9RdTvLv4TOTQUgBS5O3O5fwUxk6byBZ+IQ== + isomorphic-unfetch@^3.0.0, isomorphic-unfetch@^3.1.0: version "3.1.0" resolved "https://registry.npmjs.org/isomorphic-unfetch/-/isomorphic-unfetch-3.1.0.tgz" @@ -17042,6 +17156,13 @@ magic-string@^0.23.2: dependencies: sourcemap-codec "^1.4.1" +magic-string@^0.30.3: + version "0.30.11" + resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.11.tgz#301a6f93b3e8c2cb13ac1a7a673492c0dfd12954" + integrity sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A== + dependencies: + "@jridgewell/sourcemap-codec" "^1.5.0" + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz" @@ -17981,6 +18102,39 @@ node-releases@^2.0.13: resolved "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz" integrity sha512-uYr7J37ae/ORWdZeQ1xxMJe3NtdmqMC/JZK+geofDrkLUApKRHPd18/TxtBOJ4A0/+uUIliorNrfYV6s1b02eQ== +node-stdlib-browser@^1.2.0: + version "1.2.1" + resolved "https://registry.yarnpkg.com/node-stdlib-browser/-/node-stdlib-browser-1.2.1.tgz#888fa104914af94143ca4d8a8980fe0ed242d2d1" + integrity sha512-dZezG3D88Lg22DwyjsDuUs7cCT/XGr8WwJgg/S3ZnkcWuPet2Tt/W1d2Eytb1Z73JpZv+XVCDI5TWv6UMRq0Gg== + dependencies: + assert "^2.0.0" + browser-resolve "^2.0.0" + browserify-zlib "^0.2.0" + buffer "^5.7.1" + console-browserify "^1.1.0" + constants-browserify "^1.0.0" + create-require "^1.1.1" + crypto-browserify "^3.11.0" + domain-browser "^4.22.0" + events "^3.0.0" + https-browserify "^1.0.0" + isomorphic-timers-promises "^1.0.1" + os-browserify "^0.3.0" + path-browserify "^1.0.1" + pkg-dir "^5.0.0" + process "^0.11.10" + punycode "^1.4.1" + querystring-es3 "^0.2.1" + readable-stream "^3.6.0" + stream-browserify "^3.0.0" + stream-http "^3.2.0" + string_decoder "^1.0.0" + timers-browserify "^2.0.4" + tty-browserify "0.0.1" + url "^0.11.4" + util "^0.12.4" + vm-browserify "^1.0.1" + normalize-html-whitespace@^0.2.0: version "0.2.0" resolved "https://registry.npmjs.org/normalize-html-whitespace/-/normalize-html-whitespace-0.2.0.tgz" @@ -18122,6 +18276,11 @@ object-inspect@^1.12.3, object-inspect@^1.9.0: resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz" integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== +object-inspect@^1.13.1: + version "1.13.2" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.13.2.tgz#dea0088467fb991e67af4058147a24824a3043ff" + integrity sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g== + object-is@^1.1.5: version "1.1.5" resolved "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz" @@ -19390,12 +19549,19 @@ qs@^6.10.0, qs@^6.11.2, qs@^6.9.1, qs@^6.9.4: dependencies: side-channel "^1.0.4" +qs@^6.12.3: + version "6.13.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.13.0.tgz#6ca3bd58439f7e245655798997787b0d88a51906" + integrity sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg== + dependencies: + side-channel "^1.0.6" + qs@~6.5.2: version "6.5.3" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== -querystring-es3@^0.2.0, querystring-es3@~0.2.0: +querystring-es3@^0.2.0, querystring-es3@^0.2.1, querystring-es3@~0.2.0: version "0.2.1" resolved "https://registry.npmjs.org/querystring-es3/-/querystring-es3-0.2.1.tgz" integrity sha512-773xhDQnZBMFobEiztv8LIl70ch5MSF/jUQVlhwFyBILqq96anmoctVIYz+ZRp0qbCKATTn6ev02M3r7Ga5vqA== @@ -20903,6 +21069,18 @@ set-cookie-parser@^2.4.6: resolved "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.6.0.tgz" integrity sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ== +set-function-length@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/set-function-length/-/set-function-length-1.2.2.tgz#aac72314198eaed975cf77b2c3b6b880695e5449" + integrity sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg== + dependencies: + define-data-property "^1.1.4" + es-errors "^1.3.0" + function-bind "^1.1.2" + get-intrinsic "^1.2.4" + gopd "^1.0.1" + has-property-descriptors "^1.0.2" + set-function-name@^2.0.0, set-function-name@^2.0.1: version "2.0.1" resolved "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.1.tgz" @@ -21012,6 +21190,16 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" +side-channel@^1.0.6: + version "1.0.6" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.6.tgz#abd25fb7cd24baf45466406b1096b7831c9215f2" + integrity sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA== + dependencies: + call-bind "^1.0.7" + es-errors "^1.3.0" + get-intrinsic "^1.2.4" + object-inspect "^1.13.1" + signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: version "3.0.7" resolved "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz" @@ -21479,7 +21667,7 @@ stream-http@^2.7.2: to-arraybuffer "^1.0.0" xtend "^4.0.0" -stream-http@^3.0.0: +stream-http@^3.0.0, stream-http@^3.2.0: version "3.2.0" resolved "https://registry.npmjs.org/stream-http/-/stream-http-3.2.0.tgz" integrity sha512-Oq1bLqisTyK3TSCXpPbT4sdeYNdmyZJv1LxpEm2vu1ZhK89kSE5YXwZc3cWk0MagGaKriBh9mCFbVGtO+vY29A== @@ -23078,6 +23266,14 @@ url@^0.11.0, url@~0.11.0: punycode "^1.4.1" qs "^6.11.2" +url@^0.11.4: + version "0.11.4" + resolved "https://registry.yarnpkg.com/url/-/url-0.11.4.tgz#adca77b3562d56b72746e76b330b7f27b6721f3c" + integrity sha512-oCwdVC7mTuWiPyjLUz/COz5TLk6wgp0RCsN+wHZ2Ekneac9w8uuV0njcbbie2ME+Vs+d6duwmYuR3HgQXs1fOg== + dependencies: + punycode "^1.4.1" + qs "^6.12.3" + use-callback-ref@^1.3.0: version "1.3.0" resolved "https://registry.npmjs.org/use-callback-ref/-/use-callback-ref-1.3.0.tgz" @@ -23157,7 +23353,7 @@ util@^0.11.0: dependencies: inherits "2.0.3" -util@^0.12.3, util@~0.12.0: +util@^0.12.3, util@^0.12.4, util@^0.12.5, util@~0.12.0: version "0.12.5" resolved "https://registry.npmjs.org/util/-/util-0.12.5.tgz" integrity sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA== @@ -23277,6 +23473,14 @@ vite-plugin-generate-file@^0.2.0: mime-types "^2.1.35" picocolors "^1.0.0" +vite-plugin-node-polyfills@^0.22.0: + version "0.22.0" + resolved "https://registry.yarnpkg.com/vite-plugin-node-polyfills/-/vite-plugin-node-polyfills-0.22.0.tgz#d0afcf82eb985fc02244620d7cec1ddd1c6e0864" + integrity sha512-F+G3LjiGbG8QpbH9bZ//GSBr9i1InSTkaulfUHFa9jkLqVGORFBoqc2A/Yu5Mmh1kNAbiAeKeK+6aaQUf3x0JA== + dependencies: + "@rollup/plugin-inject" "^5.0.5" + node-stdlib-browser "^1.2.0" + vite-plugin-singlefile@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/vite-plugin-singlefile/-/vite-plugin-singlefile-2.0.2.tgz#af2c95e0182bd363dbe29b80bea5c5a78209f649" From 85adfe14e75c6f7ce0107cefd7e7ccb30ea98bbc Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:48:52 +0400 Subject: [PATCH 08/12] [WIP] sync provider refactor --- packages/sync-providers/package.json | 10 +- .../src/hooks/useSyncProvider.ts | 37 ++++ packages/sync-providers/src/index.ts | 2 +- .../{github/useGitHub.tsx => github.ts} | 169 +++++++++++++++++- .../sync-providers/src/providers/index.ts | 2 +- packages/sync-providers/src/remoteTokens.ts | 0 .../github => storage}/GitHubTokenStorage.ts | 10 +- .../{providers => storage}/GitTokenStorage.ts | 0 .../RemoteTokenStorage.ts | 0 9 files changed, 210 insertions(+), 20 deletions(-) create mode 100644 packages/sync-providers/src/hooks/useSyncProvider.ts rename packages/sync-providers/src/providers/{github/useGitHub.tsx => github.ts} (66%) create mode 100644 packages/sync-providers/src/remoteTokens.ts rename packages/sync-providers/src/{providers/github => storage}/GitHubTokenStorage.ts (98%) rename packages/sync-providers/src/{providers => storage}/GitTokenStorage.ts (100%) rename packages/sync-providers/src/{providers => storage}/RemoteTokenStorage.ts (100%) diff --git a/packages/sync-providers/package.json b/packages/sync-providers/package.json index 700e14a30..436c52364 100644 --- a/packages/sync-providers/package.json +++ b/packages/sync-providers/package.json @@ -12,20 +12,14 @@ "types": "./dist/index.d.ts", "default": "./dist/index.js" }, - "require": { - "types": "./dist/index.d.cts", - "default": "./dist/index.cjs" - } + "require": "./dist/index.cjs" }, "./types": { "import": { "types": "./dist/types/index.d.ts", "default": "./dist/types/index.js" }, - "require": { - "types": "./dist/types/index.d.cts", - "default": "./dist/types/index.cjs" - } + "require": "./dist/types/index.cjs" } }, "scripts": { diff --git a/packages/sync-providers/src/hooks/useSyncProvider.ts b/packages/sync-providers/src/hooks/useSyncProvider.ts new file mode 100644 index 000000000..ab91f2343 --- /dev/null +++ b/packages/sync-providers/src/hooks/useSyncProvider.ts @@ -0,0 +1,37 @@ +import { useEffect, useState } from 'react'; + +import { SyncProvider, SyncState } from '@/providers/provider'; + +// [WIP] - Unused for now + +export function useSyncProvider(syncProvider: SyncProvider) { + const [syncState, setSyncState] = useState(syncProvider.getState()); + const [data, setData] = useState(null); + const [error, setError] = useState(null); + + useEffect(() => { + const handleStateChange = (state: SyncState) => { + setSyncState(state); + }; + + const handleError = (err: any) => { + setError(err); + }; + + const handlePullSuccess = (pulledData: any) => { + setData(pulledData); + }; + + syncProvider.on('stateChange', handleStateChange); + syncProvider.on('error', handleError); + syncProvider.on('pullSuccess', handlePullSuccess); + + return () => { + syncProvider.on('stateChange', () => {}); + syncProvider.on('error', () => {}); + syncProvider.on('pullSuccess', () => {}); + }; + }, [syncProvider]); + + return { syncState, data, error }; +} diff --git a/packages/sync-providers/src/index.ts b/packages/sync-providers/src/index.ts index 2d588e932..7fafc217a 100644 --- a/packages/sync-providers/src/index.ts +++ b/packages/sync-providers/src/index.ts @@ -1,3 +1,3 @@ -import { GithubTokenStorage } from './providers/github/GitHubTokenStorage'; +import { GithubTokenStorage } from './storage/GitHubTokenStorage'; export { GithubTokenStorage }; diff --git a/packages/sync-providers/src/providers/github/useGitHub.tsx b/packages/sync-providers/src/providers/github.ts similarity index 66% rename from packages/sync-providers/src/providers/github/useGitHub.tsx rename to packages/sync-providers/src/providers/github.ts index 29bc993c1..8df923a4b 100644 --- a/packages/sync-providers/src/providers/github/useGitHub.tsx +++ b/packages/sync-providers/src/providers/github.ts @@ -3,15 +3,174 @@ import { LDProps } from 'launchdarkly-react-client-sdk/lib/withLDConsumer'; import compact from 'just-compact'; import type { StorageProviderType, StorageTypeCredentials, StorageTypeFormValues, RemoteResponseData, PushOverrides, -} from '../../types'; -import { TokenFormat } from '../../classes/TokenFormatStoreClass'; -import { ErrorMessages } from '../../constants'; -import { applyTokenSetOrder, isEqual } from '../../utils'; -import { GithubTokenStorage } from './GitHubTokenStorage'; +} from '../types'; +import { TokenFormat } from '../classes/TokenFormatStoreClass'; +import { ErrorMessages } from '../constants'; +import { applyTokenSetOrder, isEqual } from '../utils'; +import { GithubTokenStorage } from '../storage/GitHubTokenStorage'; type GithubCredentials = Extract; type GithubFormValues = Extract, { provider: StorageProviderType.GITHUB }>; +// const storageClientFactory = useCallback((context: GithubCredentials, owner?: string, repo?: string) => { +// const splitContextId = context.id.split('/'); +// const storageClient = new GithubTokenStorage(context.secret, owner ?? splitContextId[0], repo ?? splitContextId[1], context.baseUrl ?? ''); + +// if (context.filePath) storageClient.changePath(context.filePath); +// if (context.branch) storageClient.selectBranch(context.branch); +// if (isProUser) storageClient.enableMultiFile(); + +// return storageClient; +// }, [isProUser]); + +interface ProviderState { + editProhibited?: boolean; + branches?: string[]; +} + +class ProviderWithState { + private eventListeners: Record = {}; + private state: State | null = null; + + constructor(initialState: State) { + this.state = initialState; + } + + on(event: string, listener: EventListener) { + if (!this.eventListeners[event]) { + this.eventListeners[event] = []; + } + this.eventListeners[event].push(listener); + } + + private triggerEvent(event: string, data?: any) { + const listeners = this.eventListeners[event]; + if (listeners) { + listeners.forEach((listener) => listener(data)); + } + } + + setState(newState: State) { + this.state = newState; + this.triggerEvent('stateChange', newState); + } +} + +export class GitHubProvider extends ProviderWithState { + private storage; + private context; + + constructor(context, owner?: string, repo?: string, isMultiFileEnabled?: boolean) { + super({}); + const splitContextId = context.id.split('/'); + this.storage = new GithubTokenStorage(context.secret, owner ?? splitContextId[0], repo ?? splitContextId[1], context.baseUrl ?? ''); + this.context = context; + if (context.filePath) this.storage.changePath(context.filePath); + if (context.branch) this.storage.selectBranch(context.branch); + if (isMultiFileEnabled) this.storage.enableMultiFile(); + } + + private setEditProhibited(value) { + this.setState({ + ...this.setState, + editProhibited: value, + }); + } + private setBranches(branches) { + this.setState({ + ...this.setState, + branches, + }); + } + + private askUserIfPull(confirm) { + // this.on('') + const confirmResult = await confirm({ + text: 'Pull from GitHub?', + description: 'Your repo already contains tokens, do you want to pull these now?', + }); + return confirmResult; + } + + + + + public checkAndSetAccess(receivedFeatureFlags?: LDProps['flags']) { + if (receivedFeatureFlags?.multiFileSync) this.storage.enableMultiFile(); + const hasWriteAccess = await this.storage.canWrite(); + this.setEditProhibited(!hasWriteAccess); + } + + + public async syncTokensWithGitHub(confirm) { + async (): Promise => { + try { + const hasBranches = await this.storage.fetchBranches(); + this.setBranches(hasBranches); + if (!hasBranches || !hasBranches.length) { + return { + status: 'failure', + errorMessage: ErrorMessages.EMPTY_BRANCH_ERROR, + }; + } + + await this.checkAndSetAccess(); + + const content = await this.storage.retrieve(); + if (content?.status === 'failure') { + return { + status: 'failure', + errorMessage: content.errorMessage, + }; + } + if (content) { + if ( + !isEqual(content.tokens, tokens) + || !isEqual(content.themes, themes) + || !isEqual(content.metadata?.tokenSetOrder ?? Object.keys(tokens), Object.keys(tokens)) + ) { + const userDecision = await this.askUserIfPull(confirm); + // if (userDecision) { + // const commitSha = await this.storage.getCommitSha(); + // const sortedValues = applyTokenSetOrder(content.tokens, content.metadata?.tokenSetOrder); + // if (dispatch) { + // dispatch.tokenState.setTokenData({ + // values: sortedValues, + // themes: content.themes, + // activeTheme, + // usedTokenSet, + // hasChangedRemote: true, + // }); + // dispatch.tokenState.setRemoteData({ + // tokens: sortedValues, + // themes: content.themes, + // metadata: content.metadata, + // }); + // const stringifiedRemoteTokens = JSON.stringify(compact([content.tokens, content.themes, TokenFormat.format]), null, 2); + // dispatch.tokenState.setLastSyncedState(stringifiedRemoteTokens); + // dispatch.tokenState.setCollapsedTokenSets([]); + // dispatch.uiState.setApiData({ ...context, ...(commitSha ? { commitSha } : {}) }); + // } + // if (notifyToUI) { + // notifyToUI('Pulled tokens from GitHub'); + // } + // } + } + return content; + } + return await this.pushTokensToGitHub(); + } catch (e) { + // if (notifyToUI) { + // notifyToUI(ErrorMessages.GITHUB_CREDENTIAL_ERROR, { error: true }); + // } + console.log('Error', e); + return { + status: 'failure', + errorMessage: ErrorMessages.GITHUB_CREDENTIAL_ERROR, + }; + } +} + export function useGitHub({ isProUser, dispatch, confirm, pushDialog, closePushDialog, tokens, themes, activeTheme, usedTokenSet, storeTokenIdInJsonEditor, localApiState, notifyToUI, asyncMessageCredentialsCallback, }: { isProUser: boolean; dispatch?: any, confirm?: any, pushDialog?: any, closePushDialog?: any, tokens: any, themes: any, activeTheme: any, usedTokenSet: any, storeTokenIdInJsonEditor: any, localApiState: any, notifyToUI?: any, asyncMessageCredentialsCallback?: any }) { diff --git a/packages/sync-providers/src/providers/index.ts b/packages/sync-providers/src/providers/index.ts index 5e825d693..7302c7ad2 100644 --- a/packages/sync-providers/src/providers/index.ts +++ b/packages/sync-providers/src/providers/index.ts @@ -1 +1 @@ -export * from './github/useGitHub'; +export * from './github'; diff --git a/packages/sync-providers/src/remoteTokens.ts b/packages/sync-providers/src/remoteTokens.ts new file mode 100644 index 000000000..e69de29bb diff --git a/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts b/packages/sync-providers/src/storage/GitHubTokenStorage.ts similarity index 98% rename from packages/sync-providers/src/providers/github/GitHubTokenStorage.ts rename to packages/sync-providers/src/storage/GitHubTokenStorage.ts index d9f9e890b..a235924d4 100644 --- a/packages/sync-providers/src/providers/github/GitHubTokenStorage.ts +++ b/packages/sync-providers/src/storage/GitHubTokenStorage.ts @@ -3,13 +3,13 @@ import { Octokit } from '@octokit/rest'; import OctokitCommitMultipleFiles from 'octokit-commit-multiple-files'; import octokitCommitMultipleFilesFallback from 'octokit-commit-multiple-files/create-or-update-files'; -import type { RemoteTokenstorageErrorMessage, RemoteTokenStorageFile, RemoteTokenStorageMetadata } from '../../types'; -import { isJSONString, joinPath } from '../../utils'; +import type { RemoteTokenstorageErrorMessage, RemoteTokenStorageFile, RemoteTokenStorageMetadata } from '../types'; +import { isJSONString, joinPath } from '../utils'; import { AnyTokenSet, ThemeObjectsList, GitMultiFileObject, GitSingleFileObject, -} from '../../types'; -import { SystemFilenames, ErrorMessages } from '../../constants'; -import { GitTokenStorage } from '../GitTokenStorage'; +} from '../types'; +import { SystemFilenames, ErrorMessages } from '../constants'; +import { GitTokenStorage } from './GitTokenStorage'; type ExtendedOctokitClient = Omit & { repos: Octokit['repos'] & { diff --git a/packages/sync-providers/src/providers/GitTokenStorage.ts b/packages/sync-providers/src/storage/GitTokenStorage.ts similarity index 100% rename from packages/sync-providers/src/providers/GitTokenStorage.ts rename to packages/sync-providers/src/storage/GitTokenStorage.ts diff --git a/packages/sync-providers/src/providers/RemoteTokenStorage.ts b/packages/sync-providers/src/storage/RemoteTokenStorage.ts similarity index 100% rename from packages/sync-providers/src/providers/RemoteTokenStorage.ts rename to packages/sync-providers/src/storage/RemoteTokenStorage.ts From fe7d01ef28705167d19479d4185db399080e0bb5 Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Mon, 30 Sep 2024 13:57:34 +0400 Subject: [PATCH 09/12] [WIP] initial state storage + refactoring of variable sync plugin --- packages/variables-sync-plugin/package.json | 5 +- .../src/app/AppContainer/index.tsx | 92 ------ .../variables-sync-plugin/src/app/app.tsx | 24 -- .../src/app/components/App.tsx | 288 ++++++++++++++++++ .../src/app/components/WindowResizer.tsx | 96 ++++++ .../src/app/hooks/useFigmaTheme.ts | 25 ++ .../variables-sync-plugin/src/app/index.tsx | 31 +- .../src/app/lib/figmaAPI.ts | 3 +- .../src/app/store/adapter.ts | 16 + .../src/app/store/providers.ts | 30 ++ .../src/plugin/bootloader.ts | 17 +- .../variables-sync-plugin/src/plugin/code.ts | 3 +- packages/variables-sync-plugin/tsconfig.json | 4 +- 13 files changed, 484 insertions(+), 150 deletions(-) delete mode 100644 packages/variables-sync-plugin/src/app/AppContainer/index.tsx delete mode 100644 packages/variables-sync-plugin/src/app/app.tsx create mode 100644 packages/variables-sync-plugin/src/app/components/App.tsx create mode 100644 packages/variables-sync-plugin/src/app/components/WindowResizer.tsx create mode 100644 packages/variables-sync-plugin/src/app/hooks/useFigmaTheme.ts create mode 100644 packages/variables-sync-plugin/src/app/store/adapter.ts create mode 100644 packages/variables-sync-plugin/src/app/store/providers.ts diff --git a/packages/variables-sync-plugin/package.json b/packages/variables-sync-plugin/package.json index a2ef05d9d..c081ff242 100644 --- a/packages/variables-sync-plugin/package.json +++ b/packages/variables-sync-plugin/package.json @@ -4,13 +4,15 @@ "version": "0.0.0", "description": "", "main": "index.js", + "type": "module", "dependencies": { "@octokit/rest": "^21.0.2", "@stitches/react": "^1.2.8", "@tokens-studio/sync-providers": "*", "@tokens-studio/tokens": "^0.2.5", "@tokens-studio/ui": "^0.11.0", - "octokit-commit-multiple-files": "^5.0.2" + "octokit-commit-multiple-files": "^5.0.2", + "react-hook-form": "^7.53.0" }, "scripts": { "start": "run-s dev", @@ -33,6 +35,7 @@ "@types/react": "^18.3.5", "@types/react-dom": "^18.3.0", "@vitejs/plugin-react-swc": "^3.7.0", + "http-server": "^14.1.1", "postcss-url": "^10.1.3", "vite": "^5.4.4", "vite-plugin-generate-file": "^0.2.0", diff --git a/packages/variables-sync-plugin/src/app/AppContainer/index.tsx b/packages/variables-sync-plugin/src/app/AppContainer/index.tsx deleted file mode 100644 index ec764ebb2..000000000 --- a/packages/variables-sync-plugin/src/app/AppContainer/index.tsx +++ /dev/null @@ -1,92 +0,0 @@ - -import { Box, Button } from '@tokens-studio/ui'; - -import { figmaAPI } from "../lib/figmaAPI"; -import GitHubSync from '../sync/GitHubSync'; - -function rgbToHex({ r, g, b, a }: { r: number, g: number, b: number, a: number }) { - if (a !== 1) { - return `rgba(${[r, g, b] - .map((n) => Math.round(n * 255)) - .join(", ")}, ${a.toFixed(4)})`; - } - const toHex = (value: number) => { - const hex = Math.round(value * 255).toString(16); - return hex.length === 1 ? "0" + hex : hex; - }; - - const hex = [toHex(r), toHex(g), toHex(b)].join(""); - return `#${hex}`; -} - -export default () => ( - <> - - - - - - - -); diff --git a/packages/variables-sync-plugin/src/app/app.tsx b/packages/variables-sync-plugin/src/app/app.tsx deleted file mode 100644 index ea851bc3d..000000000 --- a/packages/variables-sync-plugin/src/app/app.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import React, { useEffect, useState } from 'react'; -import { createRoot } from 'react-dom/client'; -import AppContainer from './AppContainer'; - - -export default async () => { - const container = document.getElementById('app'); - - // Side effect from first load - - const root = createRoot(container!); - root.render( - - ) - // root.render( - // // - // // - // // - // - // {/* - // - // , */} - // ); -}; diff --git a/packages/variables-sync-plugin/src/app/components/App.tsx b/packages/variables-sync-plugin/src/app/components/App.tsx new file mode 100644 index 000000000..d6bdb0e51 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/components/App.tsx @@ -0,0 +1,288 @@ +import { useEffect, useState } from "react"; +import { + Box, + Button, + Dialog, + Heading, + IconButton, + Stack, + Tabs, + Text, +} from "@tokens-studio/ui"; +import { XIcon } from "@primer/octicons-react"; +import { useForm } from "react-hook-form"; + +// import { figmaAPI } from "../lib/figmaAPI"; +import GitHubSync from "../sync/GitHubSync.js"; +import WindowResizer from "./WindowResizer.js"; +import { useFigmaTheme } from "../hooks/useFigmaTheme.js"; +import { darkThemeMode, lightThemeMode, styled } from "../stitches.config.js"; + +export type FormValues = { + id: string; + secret?: string; + branch?: string; + filePath?: string; +}; + +function rgbToHex({ + r, + g, + b, + a, +}: { + r: number; + g: number; + b: number; + a: number; +}) { + if (a !== 1) { + return `rgba(${[r, g, b] + .map((n) => Math.round(n * 255)) + .join(", ")}, ${a.toFixed(4)})`; + } + const toHex = (value: number) => { + const hex = Math.round(value * 255).toString(16); + return hex.length === 1 ? "0" + hex : hex; + }; + + const hex = [toHex(r), toHex(g), toHex(b)].join(""); + return `#${hex}`; +} + +const StyledDialogContent = styled(Dialog.Content, { + "&:focus-visible": { + outline: "none", + }, + variants: { + size: { + large: { + width: "calc(100vw - $7)", + maxWidth: "480px", + padding: 0, + boxShadow: "$contextMenu", + borderColor: "$borderSubtle", + }, + fullscreen: { + width: "100vw", + maxWidth: "100vw", + padding: 0, + height: "100vh", + maxHeight: "100vh", + borderRadius: 0, + border: "none", + boxShadow: "none", + }, + regular: { + padding: "0", + }, + }, + }, + defaultVariants: { + size: "regular", + }, +}); + +const StyledBody = styled("div", { + position: "relative", + padding: "$4", + variants: { + full: { + true: { + padding: 0, + }, + }, + compact: { + true: { + padding: "$4", + }, + }, + }, +}); + +export default function App() { + const { isDarkTheme } = useFigmaTheme(); + const [isGitHubModalOpen, setIsGitHubModalOpen] = useState(false); + const showClose = true; + const backArrow = false; + const title = "GitHub Sync"; + + const handleClose = () => { + setIsGitHubModalOpen(false); + }; + + const { register, handleSubmit, control, resetField } = useForm({ + defaultValues: { + id: "user/repo", + secret: "", + branch: "add-variables", + filePath: "variables", + }, + }); + + const onSubmit = () => {}; + + useEffect(() => { + if (isDarkTheme) { + document.body.className = darkThemeMode; + } else { + document.body.className = lightThemeMode; + } + }, [isDarkTheme]); + + return ( + + + + Variables + Settings + + + + + {/* */} + + + + + + + + + {}} + modal={true} + > + + + + {}} + > + + {showClose && ( + + + {title && ( + + + {title} + + + )} + + {showClose && ( + } + size="small" + variant="invisible" + /> + )} + + )} + +
+ + + + + + +
+
+
+
+
+
+ {/* + + , { provider: StorageProviderType.URL }>} + hasErrored={hasErrored} + errorMessage={errorMessage} + /> + + */} + {/* Tab 2 content + + Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut + enim ad minim veniam, quis nostrud exercitation ullamco laboris + nisi ut aliquip ex ea commodo consequat.{" "} + */} +
+
+
+
+ +
+ ); +} diff --git a/packages/variables-sync-plugin/src/app/components/WindowResizer.tsx b/packages/variables-sync-plugin/src/app/components/WindowResizer.tsx new file mode 100644 index 000000000..08670cccc --- /dev/null +++ b/packages/variables-sync-plugin/src/app/components/WindowResizer.tsx @@ -0,0 +1,96 @@ +/* eslint-disable jsx-a11y/label-has-associated-control */ +import React, { useState } from "react"; +import { useDispatch } from "react-redux"; +import debounce from "lodash.debounce"; +// import { Box } from "@tokens-studio/ui"; + +import { figmaAPI } from "../lib/figmaAPI.js"; + +// import { Dispatch } from '../store'; +// import IconResizeWindow from '@/icons/resizewindow.svg'; +// import { track } from '@/utils/analytics'; + +export default function WindowResizer() { + // const dispatch = useDispatch(); + const [windowSize, setWindowSize] = useState({ width: 300, height: 300 }); + const cornerRef = React.useRef(null); + + const debouncedSizeChange = React.useRef( + debounce((width, height) => {}, 300) + ).current; + + const handleSizeChange = React.useCallback( + (e: PointerEvent) => { + const size = { + width: Math.max(300, Math.floor(e.clientX + 5)), + height: Math.max(200, Math.floor(e.clientY + 5)), + }; + setWindowSize({ ...size }); + + debouncedSizeChange(size.width, size.height); + }, + [debouncedSizeChange, windowSize] + ); + + const onDown = React.useCallback( + (e: any) => { + if (cornerRef.current) { + cornerRef.current.onpointermove = handleSizeChange; + cornerRef.current.setPointerCapture(e.pointerId); + } + }, + [handleSizeChange] + ); + + const onUp = React.useCallback( + async (e: any) => { + if (cornerRef.current) { + cornerRef.current.onpointermove = null; + cornerRef.current.releasePointerCapture(e.pointerId); + // dispatch.settings.triggerWindowChange(); + + const success = await figmaAPI.run(async (figma, { width, height }) => { + console.log({ width, height }); + await figma.ui.resize(width, height); + return true; + }, windowSize); + console.log({ success }); + } + }, + [windowSize] + ); + + // @TODO: Fix this when modals are open + return ( +
+ {/* */} + {/* */} + + + +
+ ); +} diff --git a/packages/variables-sync-plugin/src/app/hooks/useFigmaTheme.ts b/packages/variables-sync-plugin/src/app/hooks/useFigmaTheme.ts new file mode 100644 index 000000000..35b2fdd01 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/hooks/useFigmaTheme.ts @@ -0,0 +1,25 @@ +import { useState, useEffect } from 'react'; + +export function useFigmaTheme() { + const [isDarkTheme, setIsDarkTheme] = useState(false); + + useEffect(() => { + const htmlClassList = document.documentElement?.classList || []; + const isDark = htmlClassList.contains('figma-dark'); + setIsDarkTheme(isDark); + + const observer = new MutationObserver(() => { + const isDarkMode = htmlClassList.contains('figma-dark'); + setIsDarkTheme(isDarkMode); + }); + + observer.observe(document.documentElement, { + attributes: true, + attributeFilter: ['class'], + }); + + return () => observer.disconnect(); + }, []); + + return { isDarkTheme }; +} diff --git a/packages/variables-sync-plugin/src/app/index.tsx b/packages/variables-sync-plugin/src/app/index.tsx index 92aa92eda..71ea45a5c 100644 --- a/packages/variables-sync-plugin/src/app/index.tsx +++ b/packages/variables-sync-plugin/src/app/index.tsx @@ -1,8 +1,8 @@ // const INTER_BOLD = { family: "Inter", style: "Bold" }; // figma.loadFontAsync(INTER_BOLD); // console.log(123); -import React from 'react'; -import { createRoot } from 'react-dom/client'; +import React from "react"; +import { createRoot } from "react-dom/client"; // import render from './app'; @@ -82,9 +82,8 @@ class FigmaAPI { */ run( fn: (figma: PluginAPI, params: U) => Promise | T, - params?: U, + params?: U ): Promise { - return new Promise((resolve, reject) => { const id = this.id++; const cb = (event: MessageEvent) => { @@ -110,8 +109,8 @@ class FigmaAPI { new Error( typeof message === "string" ? message - : "An error occurred in FigmaAPI.run()", - ), + : "An error occurred in FigmaAPI.run()" + ) ); } } @@ -133,7 +132,7 @@ class FigmaAPI { try { parent.postMessage(msg, origin); } catch {} - }, + } ); }); } @@ -142,7 +141,7 @@ class FigmaAPI { const figmaAPI = new FigmaAPI(); function postMessage(pluginMessage: any) { - parent.postMessage({ pluginMessage, pluginId: '*' }, '*'); + parent.postMessage({ pluginMessage, pluginId: "*" }, "*"); } // (async () => { @@ -251,7 +250,7 @@ function postMessage(pluginMessage: any) { // // // Loop through each collection and fetch variables // // for (const collection of variableCollections) { // // const variablesInCollection = figma.variables.getVariablesById(collection.id); - + // // // Format variables for JSON // // const formattedCollection = { // // id: collection.id, @@ -287,21 +286,19 @@ function postMessage(pluginMessage: any) { async function bootstrap() { try { // Bootload code - await fetch('./code.js?nocache=' + (new Date()).getTime()) - .then(response => response.text()) - .then(code => postMessage(code)); + await fetch("./code.js?nocache=" + new Date().getTime()) + .then((response) => response.text()) + .then((code) => postMessage(code)); } catch (err) { // Silent fail, since we're assuming the remote code.js isn't available and the plugin is falling back to the local build } - const App = (await import("./AppContainer")).default; + const App = (await import("./components/App.js")).default; - const container = document.getElementById('app'); + const container = document.getElementById("app"); const root = createRoot(container!); - root.render( - - ) + root.render(); } bootstrap(); diff --git a/packages/variables-sync-plugin/src/app/lib/figmaAPI.ts b/packages/variables-sync-plugin/src/app/lib/figmaAPI.ts index 9dee88a18..1c122c638 100644 --- a/packages/variables-sync-plugin/src/app/lib/figmaAPI.ts +++ b/packages/variables-sync-plugin/src/app/lib/figmaAPI.ts @@ -1,6 +1,5 @@ class FigmaAPI { - // private id = 0; - id = 0; + private id = 0; /** * Run a function in the Figma plugin context. The function cannot reference diff --git a/packages/variables-sync-plugin/src/app/store/adapter.ts b/packages/variables-sync-plugin/src/app/store/adapter.ts new file mode 100644 index 000000000..4e36ff4d3 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/store/adapter.ts @@ -0,0 +1,16 @@ +import { StateStorage } from 'zustand/middleware'; + +export const figmaStorage: StateStorage = { + getItem: async (name: string): Promise => { + console.log(name, 'has been retrieved') + return (await figma.clientStorage.getAsync(name)) || null + }, + setItem: async (name: string, value: string): Promise => { + console.log(name, 'with value', value, 'has been saved') + await figma.clientStorage.setAsync(name, value); + }, + removeItem: async (name: string): Promise => { + console.log(name, 'has been deleted') + await figma.clientStorage.deleteAsync(name); + }, +} diff --git a/packages/variables-sync-plugin/src/app/store/providers.ts b/packages/variables-sync-plugin/src/app/store/providers.ts new file mode 100644 index 000000000..abbd2e430 --- /dev/null +++ b/packages/variables-sync-plugin/src/app/store/providers.ts @@ -0,0 +1,30 @@ +import { create } from 'zustand' +import { persist, createJSONStorage } from 'zustand/middleware'; + +import { StorageProviderType, StorageType } from '@tokens-studio/sync-providers/types'; +// import { StorageType } from '@tokens-studio/sync-providers'; +import { figmaStorage } from './adapter.js'; + +interface ProvidersState extends StorageType { + +} + +export const useProvidersStore = create()( + persist( + (set, get) => ({ + secret: '', + id: '', + provider: StorageProviderType.GITHUB, + internalId: '', + name: '', + branch: '', + filePath: '', + setProvider: (provider: any) => set({ ...get(), provider }), + // addABear: () => set({ bears: get().bears + 1 }), + }), + { + name: 'providers-storage', // name of the item in the storage (must be unique) + storage: createJSONStorage(() => figmaStorage), // (optional) by default, 'localStorage' is used + }, + ), +) \ No newline at end of file diff --git a/packages/variables-sync-plugin/src/plugin/bootloader.ts b/packages/variables-sync-plugin/src/plugin/bootloader.ts index 9592de054..deebde0ff 100644 --- a/packages/variables-sync-plugin/src/plugin/bootloader.ts +++ b/packages/variables-sync-plugin/src/plugin/bootloader.ts @@ -1,12 +1,6 @@ async function checkUrlExists(url: string) { try { - const response = await fetch(url, { - referrer: 'http://127.0.0.1:8080' - // mode: 'no-cors', - // headers: { - // Origin: "http://127.0.0.1:8080", - // } - }); + const response = await fetch(url); console.log({ response }); if (!response.ok) { return false; @@ -20,7 +14,7 @@ async function checkUrlExists(url: string) { } async function bootstrap() { - const exists = await checkUrlExists('http://127.0.0.1:8080'); + const exists = await checkUrlExists('http://127.0.0.1:8080/webpage/ui.html?nocache=' + (new Date()).getTime()); console.log({ exists }); // FIXME: Get this working @@ -28,14 +22,15 @@ async function bootstrap() { figma.showUI( `` + `, + { themeColors: true } ); figma.ui.onmessage = (code) => { eval(code); } } else { - figma.showUI(__html__); + figma.showUI(__html__, { themeColors: true, width: 400, height: 400 }); figma.loadFontAsync({ family: "Inter", style: "Bold" }); console.log(123); @@ -56,7 +51,7 @@ async function bootstrap() { const fn = Function(`"use strict"; return ${message.code}`)(); try { - const result = await fn(figma, {}); + const result = await fn(figma, message.params); figma.ui.postMessage({ type: "EVAL_RESULT", result, diff --git a/packages/variables-sync-plugin/src/plugin/code.ts b/packages/variables-sync-plugin/src/plugin/code.ts index 75749cc29..7a0418c70 100644 --- a/packages/variables-sync-plugin/src/plugin/code.ts +++ b/packages/variables-sync-plugin/src/plugin/code.ts @@ -19,7 +19,8 @@ figma.ui.onmessage = async (message, props) => { const fn = Function(`"use strict"; return ${message.code}`)(); try { - const result = await fn(figma, {}); + // console.log(message.params); + const result = await fn(figma, message.params); figma.ui.postMessage({ type: "EVAL_RESULT", result, diff --git a/packages/variables-sync-plugin/tsconfig.json b/packages/variables-sync-plugin/tsconfig.json index 4d60ce805..1595c3229 100644 --- a/packages/variables-sync-plugin/tsconfig.json +++ b/packages/variables-sync-plugin/tsconfig.json @@ -1,8 +1,8 @@ { "compilerOptions": { "target": "ES2022", - "module": "ES2022", - "moduleResolution": "Node", + "module": "NodeNext", + "moduleResolution": "NodeNext", "useDefineForClassFields": true, "skipLibCheck": true, "esModuleInterop": true, From ca1c75e89ea6abe69c15c668b45f33a83bab2365 Mon Sep 17 00:00:00 2001 From: macintoshhelper <6757532+macintoshhelper@users.noreply.github.com> Date: Mon, 30 Sep 2024 14:57:22 +0400 Subject: [PATCH 10/12] [WIP]: add reload message --- .../src/app/sync/GitHubSync.tsx | 170 +++++++++--------- .../variables-sync-plugin/webpage/code.js | 10 +- .../variables-sync-plugin/webpage/ui.html | 11 +- 3 files changed, 97 insertions(+), 94 deletions(-) diff --git a/packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx b/packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx index 46f554259..5acbf6c60 100644 --- a/packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx +++ b/packages/variables-sync-plugin/src/app/sync/GitHubSync.tsx @@ -32,8 +32,86 @@ export default () => { [] ); + const getVariables = useCallback(async () => { + const variablesJSON = await figmaAPI.run(async (figma) => { + const collections = + await figma.variables.getLocalVariableCollectionsAsync(); + + // console.log({ collections }); + + async function processCollection({ + name, + modes, + variableIds, + }: VariableCollection) { + const files = []; + for (const mode of modes) { + const file: any = { + fileName: `${name}.${mode.name}.tokens.json`, + body: {}, + }; + // console.log({ variableIds }); + for (const variableId of variableIds) { + const variable = await figma.variables.getVariableByIdAsync( + variableId + ); + + if (variable) { + const { name, resolvedType, valuesByMode } = variable; + + const value = valuesByMode[mode.modeId]; + + if ( + value !== undefined && + ["COLOR", "FLOAT"].includes(resolvedType) + ) { + let obj = file.body; + name.split("/").forEach((groupName) => { + obj[groupName] = obj[groupName] || {}; + obj = obj[groupName]; + }); + obj.$type = resolvedType === "COLOR" ? "color" : "number"; + if ( + typeof value === "object" && + (value as VariableAlias)?.type === "VARIABLE_ALIAS" + ) { + const currentVar = await figma.variables.getVariableByIdAsync( + (value as VariableAlias).id + ); + if (currentVar) { + obj.$value = `{${currentVar.name.replace(/\//g, ".")}}`; + } + } else { + obj.$value = value; + // obj.$value = resolvedType === "COLOR" ? rgbToHex(value) : value; + } + } + } + } + files.push(file); + } + return files; + } + + const files = []; + for (const collection of collections) { + try { + const processedCollection = await processCollection(collection); + console.log({ processedCollection }); + files.push(...processedCollection); + } catch (err) { + console.log({ err }); + } + } + return files; + }); + + return variablesJSON; + }); + const pushTokensToGitHub = useCallback( async ( + variables, context: GithubCredentials, overrides?: PushOverrides ): Promise => { @@ -46,10 +124,11 @@ export default () => { const files = variables?.map(({ fileName, body }) => ({ type: "tokenSet", - name: "setName", + name: fileName.replace(".json", "").split(".").join("/"), path: fileName, data: body, })); + console.log(JSON.stringify({ files }, null, 2)); if (files.length > 0) { storage.write(files, { commitMessage: "test" }); } @@ -61,94 +140,11 @@ export default () => { return ( <> + {/* */} -