Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frames client #166

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/pre.json
Original file line number Diff line number Diff line change
@@ -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": []
}
5 changes: 5 additions & 0 deletions .changeset/ten-rings-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@xmtp/frames-client": minor
---

Initialize Frames Client
7 changes: 7 additions & 0 deletions packages/frames-client/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
root: true,
extends: ["xmtp-web"],
parserOptions: {
project: "./tsconfig.eslint.json",
},
};
1 change: 1 addition & 0 deletions packages/frames-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# frames-client
92 changes: 92 additions & 0 deletions packages/frames-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"name": "@xmtp/frames-client",
"packageManager": "[email protected]",
"version": "0.0.1",
"author": "XMTP Labs <[email protected]>",
"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": "[email protected]: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"
}
}
37 changes: 37 additions & 0 deletions packages/frames-client/rollup.config.js
Original file line number Diff line number Diff line change
@@ -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()],
},
]);
1 change: 1 addition & 0 deletions packages/frames-client/src/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const OG_PROXY_URL = "https://og-proxy.fly.dev";
18 changes: 18 additions & 0 deletions packages/frames-client/src/index.ts
Original file line number Diff line number Diff line change
@@ -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<FramesResponse> {
const response = await fetch(
`${OG_PROXY_URL}?url=${encodeURIComponent(url)}`,
);
return (await response.json()) as FramesResponse;
}
}
4 changes: 4 additions & 0 deletions packages/frames-client/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type FramesResponse = {
url: string;
extractedTags: { [k: string]: string };
};
5 changes: 5 additions & 0 deletions packages/frames-client/tsconfig.eslint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "./tsconfig.json",
"include": [".", ".eslintrc.cjs", "rollup.config.js"],
"exclude": ["lib", "node_modules"]
}
9 changes: 9 additions & 0 deletions packages/frames-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "@xmtp/tsconfig/react-sdk.json",
"include": ["src", ".eslintrc.cjs", "vitest.config.ts", "vitest.setup.ts"],
"compilerOptions": {
"paths": {
"@/*": ["./src/*"],
},
},
}
24 changes: 24 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down