@storyshelf/design-figma 0.6.2 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.d.mts +0 -2
- package/dist/api.mjs +1 -2
- package/dist/index.d.mts +0 -2
- package/dist/index.mjs +1 -2
- package/dist/metadata.mjs +2 -3
- package/dist/oauth.d.mts +0 -2
- package/dist/oauth.mjs +1 -2
- package/dist/url.d.mts +0 -2
- package/dist/url.mjs +1 -2
- package/package.json +3 -3
package/dist/api.d.mts
CHANGED
|
@@ -2,7 +2,6 @@ import __tsdown_shims_path from 'node:path';
|
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
3
|
import { DesignCallOptions, DesignClient, DesignMeta, DesignRef } from "@storyshelf/core/adapter/design";
|
|
4
4
|
import { Buffer } from "node:buffer";
|
|
5
|
-
//#region src/api.d.ts
|
|
6
5
|
/** A Figma client bound to a personal access token (or, with `authType: "oauth"`, a user's OAuth token). */
|
|
7
6
|
declare function createFigmaClient(credential: string, authType?: "token" | "oauth"): DesignClient;
|
|
8
7
|
/**
|
|
@@ -18,6 +17,5 @@ declare function fetchFigmaMetas(token: string, fileKey: string, refs: readonly
|
|
|
18
17
|
* Throws when the Images API call itself fails.
|
|
19
18
|
*/
|
|
20
19
|
declare function fetchFigmaRenders(token: string, fileKey: string, nodeIds: readonly string[], options?: DesignCallOptions): Promise<Map<string, Buffer>>;
|
|
21
|
-
//#endregion
|
|
22
20
|
export { createFigmaClient, fetchFigmaMetas, fetchFigmaRenders };
|
|
23
21
|
//# sourceMappingURL=api.d.mts.map
|
package/dist/api.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import "node:path";
|
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
4
|
import { HttpError, httpBytes, httpJson } from "@storyshelf/core/utils";
|
|
5
|
-
|
|
5
|
+
// src/api.ts
|
|
6
6
|
const FIGMA_API = "https://api.figma.com/v1";
|
|
7
7
|
/**
|
|
8
8
|
* Render scale: 2x keeps text legible next to retina screenshots without the
|
|
@@ -125,7 +125,6 @@ async function download(url, options) {
|
|
|
125
125
|
const { headers: _headers, ...rest } = requestOptions("", 3e4, options);
|
|
126
126
|
return await httpBytes(url, rest);
|
|
127
127
|
}
|
|
128
|
-
//#endregion
|
|
129
128
|
export { createFigmaClient, fetchFigmaMetas, fetchFigmaRenders };
|
|
130
129
|
|
|
131
130
|
//# sourceMappingURL=api.mjs.map
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,6 @@ import { FigmaOAuthOptions, createFigmaOAuth, figmaOAuthFromEnv } from "./oauth.
|
|
|
4
4
|
import { createFigmaClient, fetchFigmaMetas, fetchFigmaRenders } from "./api.mjs";
|
|
5
5
|
import { parseFigmaUrl } from "./url.mjs";
|
|
6
6
|
import { DesignProvider } from "@storyshelf/core/adapter/design";
|
|
7
|
-
//#region src/index.d.ts
|
|
8
7
|
/** Options of {@link createFigmaDesign}. */
|
|
9
8
|
interface FigmaDesignOptions {
|
|
10
9
|
/** Registered Figma OAuth app: lets members connect their own account when the project has no token. */
|
|
@@ -12,6 +11,5 @@ interface FigmaDesignOptions {
|
|
|
12
11
|
}
|
|
13
12
|
/** Figma design provider for StoryShelf: pass it as `design: [createFigmaDesign()]`. */
|
|
14
13
|
declare function createFigmaDesign(options?: FigmaDesignOptions): DesignProvider;
|
|
15
|
-
//#endregion
|
|
16
14
|
export { FigmaDesignOptions, type FigmaOAuthOptions, createFigmaClient, createFigmaDesign, createFigmaOAuth, fetchFigmaMetas, fetchFigmaRenders, figmaOAuthFromEnv, parseFigmaUrl };
|
|
17
15
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { createFigmaClient, fetchFigmaMetas, fetchFigmaRenders } from "./api.mjs
|
|
|
5
5
|
import { getMetadata } from "./metadata.mjs";
|
|
6
6
|
import { createFigmaOAuth, figmaOAuthFromEnv } from "./oauth.mjs";
|
|
7
7
|
import { parseFigmaUrl } from "./url.mjs";
|
|
8
|
-
|
|
8
|
+
// src/index.ts
|
|
9
9
|
/** Figma design provider for StoryShelf: pass it as `design: [createFigmaDesign()]`. */
|
|
10
10
|
function createFigmaDesign(options = {}) {
|
|
11
11
|
return {
|
|
@@ -15,7 +15,6 @@ function createFigmaDesign(options = {}) {
|
|
|
15
15
|
...options.oauth ? { oauth: createFigmaOAuth(options.oauth) } : {}
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
//#endregion
|
|
19
18
|
export { createFigmaClient, createFigmaDesign, createFigmaOAuth, fetchFigmaMetas, fetchFigmaRenders, figmaOAuthFromEnv, parseFigmaUrl };
|
|
20
19
|
|
|
21
20
|
//# sourceMappingURL=index.mjs.map
|
package/dist/metadata.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "node:path";
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
|
-
|
|
4
|
+
// src/metadata.ts
|
|
5
5
|
/** Describe the Figma provider (name, version, credential copy). */
|
|
6
6
|
function getMetadata() {
|
|
7
7
|
return {
|
|
8
8
|
name: "Figma",
|
|
9
|
-
version: "0.
|
|
9
|
+
version: "0.8.0",
|
|
10
10
|
description: "Figma links, file metadata and rendered previews via the Figma REST API",
|
|
11
11
|
kind: "figma",
|
|
12
12
|
category: "design",
|
|
@@ -17,7 +17,6 @@ function getMetadata() {
|
|
|
17
17
|
credentialMaxAgeDays: 90
|
|
18
18
|
};
|
|
19
19
|
}
|
|
20
|
-
//#endregion
|
|
21
20
|
export { getMetadata };
|
|
22
21
|
|
|
23
22
|
//# sourceMappingURL=metadata.mjs.map
|
package/dist/oauth.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
3
|
import { OAuthClient } from "@storyshelf/core/adapter/oauth";
|
|
4
|
-
//#region src/oauth.d.ts
|
|
5
4
|
/** Operator-registered Figma OAuth app (Figma → Settings → OAuth apps). */
|
|
6
5
|
interface FigmaOAuthOptions {
|
|
7
6
|
clientId: string;
|
|
@@ -11,6 +10,5 @@ interface FigmaOAuthOptions {
|
|
|
11
10
|
declare function figmaOAuthFromEnv(env?: Record<string, string | undefined>): FigmaOAuthOptions | undefined;
|
|
12
11
|
/** Figma's {@link OAuthClient} for one registered OAuth app. */
|
|
13
12
|
declare function createFigmaOAuth(options: FigmaOAuthOptions): OAuthClient;
|
|
14
|
-
//#endregion
|
|
15
13
|
export { FigmaOAuthOptions, createFigmaOAuth, figmaOAuthFromEnv };
|
|
16
14
|
//# sourceMappingURL=oauth.d.mts.map
|
package/dist/oauth.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import "node:path";
|
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
4
|
import { httpJson } from "@storyshelf/core/utils";
|
|
5
|
-
|
|
5
|
+
// src/oauth.ts
|
|
6
6
|
const AUTHORIZE_URL = "https://www.figma.com/oauth";
|
|
7
7
|
const TOKEN_URL = "https://api.figma.com/v1/oauth/token";
|
|
8
8
|
const REFRESH_URL = "https://api.figma.com/v1/oauth/refresh";
|
|
@@ -58,7 +58,6 @@ function toTokens(response) {
|
|
|
58
58
|
expiresAt: new Date(Date.now() + seconds * 1e3).toISOString()
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
//#endregion
|
|
62
61
|
export { createFigmaOAuth, figmaOAuthFromEnv };
|
|
63
62
|
|
|
64
63
|
//# sourceMappingURL=oauth.mjs.map
|
package/dist/url.d.mts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import __tsdown_shims_path from 'node:path';
|
|
2
2
|
import __tsdown_shims_url from 'node:url';
|
|
3
3
|
import { DesignRef } from "@storyshelf/core/adapter/design";
|
|
4
|
-
//#region src/url.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* Parse a Figma file/design/board/proto/make URL, or null when it is not a Figma
|
|
7
6
|
* link. Embed (`/embed`), community and Figma Sites (`figma.site`) links are
|
|
8
7
|
* deliberately rejected, as are malformed `node-id` values.
|
|
9
8
|
*/
|
|
10
9
|
declare function parseFigmaUrl(raw: string): DesignRef | null;
|
|
11
|
-
//#endregion
|
|
12
10
|
export { parseFigmaUrl };
|
|
13
11
|
//# sourceMappingURL=url.d.mts.map
|
package/dist/url.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:path";
|
|
2
2
|
import "node:url";
|
|
3
3
|
import.meta.url;
|
|
4
|
-
|
|
4
|
+
// src/url.ts
|
|
5
5
|
const FIGMA_HOSTS = /* @__PURE__ */ new Set(["figma.com", "www.figma.com"]);
|
|
6
6
|
const FILE_PATH = /^\/(?:file|design|proto|board|make)\/(?<key>[A-Za-z0-9]+)(?:\/|$)/u;
|
|
7
7
|
/** `1:2` after normalizing; Figma node ids are `<number>:<number>`. */
|
|
@@ -37,7 +37,6 @@ function withoutCredentials(url) {
|
|
|
37
37
|
clean.hash = "";
|
|
38
38
|
return clean.toString();
|
|
39
39
|
}
|
|
40
|
-
//#endregion
|
|
41
40
|
export { parseFigmaUrl };
|
|
42
41
|
|
|
43
42
|
//# sourceMappingURL=url.mjs.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storyshelf/design-figma",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Figma design-link provider for StoryShelf: link validation, file metadata and rendered previews.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"prepublishOnly": "nub run build"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@storyshelf/core": "0.
|
|
54
|
+
"@storyshelf/core": "0.8.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^26.0.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"oxlint-tsgolint": "^7.0.2001",
|
|
62
62
|
"tsdown": "^0.22.14",
|
|
63
63
|
"typescript": "^7.0.2",
|
|
64
|
-
"vitest": "^5.0.
|
|
64
|
+
"vitest": "^5.0.5"
|
|
65
65
|
},
|
|
66
66
|
"engines": {
|
|
67
67
|
"node": ">=24"
|