From 8d41b65428bf6465a46965c9d7b70f28c60bcd00 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:04:53 -0800 Subject: [PATCH 1/2] Add frames client --- packages/frames-client/.eslintrc.cjs | 7 ++ packages/frames-client/README.md | 1 + packages/frames-client/package.json | 92 +++++++++++++++++++++ packages/frames-client/rollup.config.js | 37 +++++++++ packages/frames-client/src/constants.ts | 1 + packages/frames-client/src/index.ts | 18 ++++ packages/frames-client/src/types.ts | 4 + packages/frames-client/tsconfig.eslint.json | 5 ++ packages/frames-client/tsconfig.json | 9 ++ yarn.lock | 24 ++++++ 10 files changed, 198 insertions(+) create mode 100644 packages/frames-client/.eslintrc.cjs create mode 100644 packages/frames-client/README.md create mode 100644 packages/frames-client/package.json create mode 100644 packages/frames-client/rollup.config.js create mode 100644 packages/frames-client/src/constants.ts create mode 100644 packages/frames-client/src/index.ts create mode 100644 packages/frames-client/src/types.ts create mode 100644 packages/frames-client/tsconfig.eslint.json create mode 100644 packages/frames-client/tsconfig.json diff --git a/packages/frames-client/.eslintrc.cjs b/packages/frames-client/.eslintrc.cjs new file mode 100644 index 00000000..0e3d6a26 --- /dev/null +++ b/packages/frames-client/.eslintrc.cjs @@ -0,0 +1,7 @@ +module.exports = { + root: true, + extends: ["xmtp-web"], + parserOptions: { + project: "./tsconfig.eslint.json", + }, +}; diff --git a/packages/frames-client/README.md b/packages/frames-client/README.md new file mode 100644 index 00000000..cdc25b1a --- /dev/null +++ b/packages/frames-client/README.md @@ -0,0 +1 @@ +# frames-client diff --git a/packages/frames-client/package.json b/packages/frames-client/package.json new file mode 100644 index 00000000..577910f2 --- /dev/null +++ b/packages/frames-client/package.json @@ -0,0 +1,92 @@ +{ + "name": "@xmtp/frames-client", + "packageManager": "yarn@4.0.2", + "version": "0.0.1", + "author": "XMTP Labs ", + "license": "MIT", + "type": "module", + "browser": "lib/index.js", + "module": "lib/index.js", + "types": "lib/index.d.ts", + "exports": { + ".": { + "types": "./lib/index.d.ts", + "default": "./lib/index.js" + } + }, + "files": [ + "lib" + ], + "sideEffects": false, + "repository": { + "type": "git", + "url": "git@github.com:xmtp/xmtp-web.git", + "directory": "packages/react-sdk" + }, + "homepage": "https://github.com/xmtp/xmtp-web", + "bugs": { + "url": "https://github.com/xmtp/xmtp-web/issues" + }, + "keywords": [ + "xmtp", + "messaging", + "web3", + "sdk", + "js", + "ts", + "javascript", + "typescript", + "react", + "reactjs", + "react-hooks", + "hooks" + ], + "publishConfig": { + "access": "public" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 3 chrome versions", + "last 3 firefox versions", + "last 3 safari versions" + ] + }, + "devDependencies": { + "@rollup/plugin-terser": "^0.4.4", + "@rollup/plugin-typescript": "^11.1.6", + "@xmtp/tsconfig": "workspace:*", + "eslint": "^8.56.0", + "eslint-config-xmtp-web": "workspace:*", + "prettier": "^3.2.4", + "rollup": "^4.9.6", + "rollup-plugin-dts": "^6.1.0", + "rollup-plugin-filesize": "^10.0.0", + "rollup-plugin-tsconfig-paths": "^1.5.2", + "typedoc": "^0.25.7", + "typescript": "^5.3.3", + "vite": "^5.0.12", + "vite-tsconfig-paths": "^4.3.1", + "vitest": "^1.2.1" + }, + "scripts": { + "build": "yarn clean:lib && yarn rollup -c", + "dev": "yarn clean:lib && yarn rollup -c --watch", + "clean:lib": "rm -rf lib", + "clean": "rm -rf .turbo && rm -rf node_modules && yarn clean:lib", + "lint": "eslint . --ignore-path ../../.gitignore", + "format:base": "prettier --ignore-path ../../.gitignore", + "format:check": "yarn format:base -c .", + "format": "yarn format:base -w .", + "test": "vitest run --passWithNoTests", + "typecheck": "tsc", + "typedoc": "typedoc" + }, + "peerDependencies": { + "@xmtp/xmtp-js": "^11.3.7" + } +} diff --git a/packages/frames-client/rollup.config.js b/packages/frames-client/rollup.config.js new file mode 100644 index 00000000..28ff8e43 --- /dev/null +++ b/packages/frames-client/rollup.config.js @@ -0,0 +1,37 @@ +import { defineConfig } from "rollup"; +import typescript from "@rollup/plugin-typescript"; +import { dts } from "rollup-plugin-dts"; +import tsConfigPaths from "rollup-plugin-tsconfig-paths"; +import terser from "@rollup/plugin-terser"; +import filesize from "rollup-plugin-filesize"; + +export default defineConfig([ + { + input: "src/index.ts", + output: { + file: "lib/index.js", + format: "es", + sourcemap: true, + }, + plugins: [ + tsConfigPaths(), + typescript({ + declaration: false, + declarationMap: false, + }), + terser(), + filesize({ + showMinifiedSize: false, + }), + ], + external: [], + }, + { + input: "src/index.ts", + output: { + file: "lib/index.d.ts", + format: "es", + }, + plugins: [tsConfigPaths(), dts()], + }, +]); diff --git a/packages/frames-client/src/constants.ts b/packages/frames-client/src/constants.ts new file mode 100644 index 00000000..2355a34b --- /dev/null +++ b/packages/frames-client/src/constants.ts @@ -0,0 +1 @@ +export const OG_PROXY_URL = "https://og-proxy.fly.dev"; diff --git a/packages/frames-client/src/index.ts b/packages/frames-client/src/index.ts new file mode 100644 index 00000000..5e00d689 --- /dev/null +++ b/packages/frames-client/src/index.ts @@ -0,0 +1,18 @@ +import type { Client } from "@xmtp/xmtp-js"; +import { OG_PROXY_URL } from "./constants"; +import type { FramesResponse } from "./types"; + +export class FramesClient { + xmtpClient: Client; + + constructor(xmtpClient: Client) { + this.xmtpClient = xmtpClient; + } + + static async readMetadata(url: string): Promise { + const response = await fetch( + `${OG_PROXY_URL}?url=${encodeURIComponent(url)}`, + ); + return (await response.json()) as FramesResponse; + } +} diff --git a/packages/frames-client/src/types.ts b/packages/frames-client/src/types.ts new file mode 100644 index 00000000..bf3d7be9 --- /dev/null +++ b/packages/frames-client/src/types.ts @@ -0,0 +1,4 @@ +export type FramesResponse = { + url: string; + extractedTags: { [k: string]: string }; +}; diff --git a/packages/frames-client/tsconfig.eslint.json b/packages/frames-client/tsconfig.eslint.json new file mode 100644 index 00000000..bf165d3f --- /dev/null +++ b/packages/frames-client/tsconfig.eslint.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "include": [".", ".eslintrc.cjs", "rollup.config.js"], + "exclude": ["lib", "node_modules"] +} diff --git a/packages/frames-client/tsconfig.json b/packages/frames-client/tsconfig.json new file mode 100644 index 00000000..56054a9a --- /dev/null +++ b/packages/frames-client/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "@xmtp/tsconfig/react-sdk.json", + "include": ["src", ".eslintrc.cjs", "vitest.config.ts", "vitest.setup.ts"], + "compilerOptions": { + "paths": { + "@/*": ["./src/*"], + }, + }, +} diff --git a/yarn.lock b/yarn.lock index d71379bd..64b66c41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4298,6 +4298,30 @@ __metadata: languageName: node linkType: hard +"@xmtp/frames-client@workspace:packages/frames-client": + version: 0.0.0-use.local + resolution: "@xmtp/frames-client@workspace:packages/frames-client" + dependencies: + "@rollup/plugin-terser": "npm:^0.4.4" + "@rollup/plugin-typescript": "npm:^11.1.6" + "@xmtp/tsconfig": "workspace:*" + eslint: "npm:^8.56.0" + eslint-config-xmtp-web: "workspace:*" + prettier: "npm:^3.2.4" + rollup: "npm:^4.9.6" + rollup-plugin-dts: "npm:^6.1.0" + rollup-plugin-filesize: "npm:^10.0.0" + rollup-plugin-tsconfig-paths: "npm:^1.5.2" + typedoc: "npm:^0.25.7" + typescript: "npm:^5.3.3" + vite: "npm:^5.0.12" + vite-tsconfig-paths: "npm:^4.3.1" + vitest: "npm:^1.2.1" + peerDependencies: + "@xmtp/xmtp-js": ^11.3.7 + languageName: unknown + linkType: soft + "@xmtp/proto@npm:^3.29.0": version: 3.29.0 resolution: "@xmtp/proto@npm:3.29.0" From 502c402cb92c4000dbd9b5d6bb35d19a84edb21e Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Mon, 29 Jan 2024 16:06:37 -0800 Subject: [PATCH 2/2] Get into prerelease version --- .changeset/pre.json | 13 +++++++++++++ .changeset/ten-rings-argue.md | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 .changeset/pre.json create mode 100644 .changeset/ten-rings-argue.md diff --git a/.changeset/pre.json b/.changeset/pre.json new file mode 100644 index 00000000..caed0030 --- /dev/null +++ b/.changeset/pre.json @@ -0,0 +1,13 @@ +{ + "mode": "pre", + "tag": "beta", + "initialVersions": { + "@xmtp/react-app": "0.0.0", + "@xmtp/react-vite-example": "0.0.0", + "eslint-config-xmtp-web": "1.0.0", + "@xmtp/frames-client": "0.0.1", + "@xmtp/react-sdk": "5.0.1", + "@xmtp/tsconfig": "0.0.0" + }, + "changesets": [] +} diff --git a/.changeset/ten-rings-argue.md b/.changeset/ten-rings-argue.md new file mode 100644 index 00000000..72cd3038 --- /dev/null +++ b/.changeset/ten-rings-argue.md @@ -0,0 +1,5 @@ +--- +"@xmtp/frames-client": minor +--- + +Initialize Frames Client