@design-sdk/figma-url 0.0.52 → 0.0.54

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.
@@ -74,8 +74,16 @@ function analyze(url) {
74
74
  // but the only case the url is encoded is when it's for embeding
75
75
  // - which will be returned above. it's fine.
76
76
  if (_u.hostname == "figma.com" || _u.hostname == "www.figma.com") {
77
- // file path is required for both file and node.
78
- if (_u.pathname.includes("file/")) {
77
+ // Support all Figma URL patterns: file/, design/, board/, slides/, site/
78
+ const supportedPathPatterns = [
79
+ "file/",
80
+ "design/",
81
+ "board/",
82
+ "slides/",
83
+ "site/",
84
+ ];
85
+ const matchedPattern = supportedPathPatterns.find((pattern) => _u.pathname.includes(pattern));
86
+ if (matchedPattern) {
79
87
  if (((_a = _u.searchParams.get(constants_1._PARAM_NODE_ID)) === null || _a === void 0 ? void 0 : _a.length) > 0) {
80
88
  return FigmaUrlType.node;
81
89
  }
@@ -1,15 +1,40 @@
1
1
  /**
2
2
  * e.g. full url should look like -
3
- * https://www.figma.com/embed?embed_host=astra&url=https://www.figma.com/file/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
3
+ * https://www.figma.com/embed?embed_host=astra&url=https://www.figma.com/design/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
4
4
  *
5
5
  * ref: https://www.figma.com/developers/embed
6
6
  */
7
7
  export declare const _FIGMA_EMBED_URL_PREFIX = "https://www.figma.com/embed";
8
8
  /**
9
+ * Legacy file URL prefix (for backward compatibility)
9
10
  * e.g. full url should look like -
10
11
  * https://www.figma.com/file/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
11
12
  */
12
13
  export declare const _FIGMA_FILE_URL_PREFIX = "https://www.figma.com/file";
14
+ /**
15
+ * Design file URL prefix (current standard, replaces /file/)
16
+ * e.g. full url should look like -
17
+ * https://www.figma.com/design/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
18
+ */
19
+ export declare const _FIGMA_DESIGN_URL_PREFIX = "https://www.figma.com/design";
20
+ /**
21
+ * FigJam board URL prefix
22
+ * e.g. full url should look like -
23
+ * https://www.figma.com/board/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
24
+ */
25
+ export declare const _FIGMA_BOARD_URL_PREFIX = "https://www.figma.com/board";
26
+ /**
27
+ * Figma Slides URL prefix
28
+ * e.g. full url should look like -
29
+ * https://www.figma.com/slides/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
30
+ */
31
+ export declare const _FIGMA_SLIDES_URL_PREFIX = "https://www.figma.com/slides";
32
+ /**
33
+ * Figma Site URL prefix
34
+ * e.g. full url should look like -
35
+ * https://www.figma.com/site/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
36
+ */
37
+ export declare const _FIGMA_SITE_URL_PREFIX = "https://www.figma.com/site";
13
38
  /**
14
39
  * param key for node id specification.
15
40
  *
package/dist/constants.js CHANGED
@@ -1,18 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.__FIGMA_DEMO_DEFAULT_FILE_NODE_URL = exports.__FIGMA_DEMO_DEFAULT_FILE_URL = exports.__FIGMA_DEMO_DEFAULT_FILE_ID = exports._PARAM_NODE_ID = exports._FIGMA_FILE_URL_PREFIX = exports._FIGMA_EMBED_URL_PREFIX = void 0;
3
+ exports.__FIGMA_DEMO_DEFAULT_FILE_NODE_URL = exports.__FIGMA_DEMO_DEFAULT_FILE_URL = exports.__FIGMA_DEMO_DEFAULT_FILE_ID = exports._PARAM_NODE_ID = exports._FIGMA_SITE_URL_PREFIX = exports._FIGMA_SLIDES_URL_PREFIX = exports._FIGMA_BOARD_URL_PREFIX = exports._FIGMA_DESIGN_URL_PREFIX = exports._FIGMA_FILE_URL_PREFIX = exports._FIGMA_EMBED_URL_PREFIX = void 0;
4
4
  /**
5
5
  * e.g. full url should look like -
6
- * https://www.figma.com/embed?embed_host=astra&url=https://www.figma.com/file/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
6
+ * https://www.figma.com/embed?embed_host=astra&url=https://www.figma.com/design/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
7
7
  *
8
8
  * ref: https://www.figma.com/developers/embed
9
9
  */
10
10
  exports._FIGMA_EMBED_URL_PREFIX = "https://www.figma.com/embed";
11
11
  /**
12
+ * Legacy file URL prefix (for backward compatibility)
12
13
  * e.g. full url should look like -
13
14
  * https://www.figma.com/file/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
14
15
  */
15
16
  exports._FIGMA_FILE_URL_PREFIX = "https://www.figma.com/file";
17
+ /**
18
+ * Design file URL prefix (current standard, replaces /file/)
19
+ * e.g. full url should look like -
20
+ * https://www.figma.com/design/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
21
+ */
22
+ exports._FIGMA_DESIGN_URL_PREFIX = "https://www.figma.com/design";
23
+ /**
24
+ * FigJam board URL prefix
25
+ * e.g. full url should look like -
26
+ * https://www.figma.com/board/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
27
+ */
28
+ exports._FIGMA_BOARD_URL_PREFIX = "https://www.figma.com/board";
29
+ /**
30
+ * Figma Slides URL prefix
31
+ * e.g. full url should look like -
32
+ * https://www.figma.com/slides/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
33
+ */
34
+ exports._FIGMA_SLIDES_URL_PREFIX = "https://www.figma.com/slides";
35
+ /**
36
+ * Figma Site URL prefix
37
+ * e.g. full url should look like -
38
+ * https://www.figma.com/site/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
39
+ */
40
+ exports._FIGMA_SITE_URL_PREFIX = "https://www.figma.com/site";
16
41
  /**
17
42
  * param key for node id specification.
18
43
  *
@@ -11,7 +11,7 @@ export declare type FigmaEmbedInput = string | {
11
11
  */
12
12
  export declare function embed(src: FigmaEmbedInput): string;
13
13
  /**
14
- * e.g. - https://www.figma.com/file/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
14
+ * e.g. - https://www.figma.com/design/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
15
15
  *
16
16
  * (*this does not contain logic for checking if input url is valid.*)
17
17
  * @param src : ;
package/dist/embed-url.js CHANGED
@@ -29,7 +29,7 @@ function _build(url) {
29
29
  return _embed_url;
30
30
  }
31
31
  /**
32
- * e.g. - https://www.figma.com/file/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
32
+ * e.g. - https://www.figma.com/design/HSozKEVWhh8saZa2vr1Nxd?node-id=111%3A0
33
33
  *
34
34
  * (*this does not contain logic for checking if input url is valid.*)
35
35
  * @param src : ;
@@ -47,7 +47,8 @@ function builEmbedableSourceUrl(src) {
47
47
  }
48
48
  else if ("fileid" in src) {
49
49
  /// WWW prefix is required. if non passed, figma embed won't accept it.
50
- return `https://www.figma.com/file/${src.fileid}/${src.nodeid && `?node-id=${src.nodeid}`}`;
50
+ /// Use /design/ pattern for new URLs (replaces /file/)
51
+ return `https://www.figma.com/design/${src.fileid}/${src.nodeid && `?node-id=${src.nodeid}`}`;
51
52
  }
52
53
  else {
53
54
  return undefined;
@@ -2,7 +2,12 @@ import { FigmaTargetNodeConfig } from "./target-node-config";
2
2
  /**
3
3
  * extracts file id from share link
4
4
  *
5
- * e.g. in - "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
5
+ * Supports multiple Figma URL patterns:
6
+ * - Old: "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
7
+ * - New: "https://www.figma.com/design/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
8
+ * - New: "https://www.figma.com/board/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
9
+ * - New: "https://www.figma.com/slides/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
10
+ * - New: "https://www.figma.com/site/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
6
11
  *
7
12
  * out - "Y0Gh77AqBoHH7dG1GtK3xF"
8
13
  * @param url
@@ -17,7 +22,12 @@ export declare function parseFileId(url: string): string;
17
22
  */
18
23
  export declare function formatNodeId(node_id: string): string;
19
24
  /**
20
- * pattern is "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
25
+ * pattern examples:
26
+ * - "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
27
+ * - "https://www.figma.com/design/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
28
+ * - "https://www.figma.com/board/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
29
+ * - "https://www.figma.com/slides/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
30
+ * - "https://www.figma.com/site/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
21
31
  * @param url
22
32
  */
23
33
  export declare function parseFileAndNodeId(url: string): FigmaTargetNodeConfig | undefined;
package/dist/parse-url.js CHANGED
@@ -4,19 +4,32 @@ exports.parseFileAndNodeId = exports.formatNodeId = exports.parseFileId = void 0
4
4
  /**
5
5
  * extracts file id from share link
6
6
  *
7
- * e.g. in - "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
7
+ * Supports multiple Figma URL patterns:
8
+ * - Old: "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
9
+ * - New: "https://www.figma.com/design/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
10
+ * - New: "https://www.figma.com/board/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
11
+ * - New: "https://www.figma.com/slides/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
12
+ * - New: "https://www.figma.com/site/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
8
13
  *
9
14
  * out - "Y0Gh77AqBoHH7dG1GtK3xF"
10
15
  * @param url
11
16
  * @returns
12
17
  */
13
18
  function parseFileId(url) {
14
- // this logic is dangerous, but clean and simple. works for now. (think the url format won't change)
15
- if (url.includes("https://www.figma.com/file/")) {
19
+ // File ID is in the same position (4th segment) for all URL patterns
20
+ const supportedPatterns = [
21
+ "https://www.figma.com/file/",
22
+ "https://www.figma.com/design/",
23
+ "https://www.figma.com/board/",
24
+ "https://www.figma.com/slides/",
25
+ "https://www.figma.com/site/",
26
+ ];
27
+ const matchedPattern = supportedPatterns.find((pattern) => url.includes(pattern));
28
+ if (matchedPattern) {
16
29
  return url.split("/")[4];
17
30
  }
18
31
  else {
19
- throw `figma file url must contain "https://www.figma.com/file/". the givven was ${url}, which we cannot extract file id from it.`;
32
+ throw `figma url must contain one of the supported patterns (file/, design/, board/, slides/, site/). the given was ${url}, which we cannot extract file id from it.`;
20
33
  }
21
34
  }
22
35
  exports.parseFileId = parseFileId;
@@ -47,7 +60,12 @@ function formatNodeId(node_id) {
47
60
  }
48
61
  exports.formatNodeId = formatNodeId;
49
62
  /**
50
- * pattern is "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
63
+ * pattern examples:
64
+ * - "https://www.figma.com/file/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
65
+ * - "https://www.figma.com/design/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
66
+ * - "https://www.figma.com/board/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
67
+ * - "https://www.figma.com/slides/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
68
+ * - "https://www.figma.com/site/Y0Gh77AqBoHH7dG1GtK3xF/?node-id=775%3A112"
51
69
  * @param url
52
70
  */
53
71
  function parseFileAndNodeId(url) {
package/package.json CHANGED
@@ -1,29 +1,28 @@
1
1
  {
2
- "name": "@design-sdk/figma-url",
3
- "version": "0.0.52",
4
- "description": "Figma url utils for sharing & embeding and url inspection",
5
- "license": "MIT",
6
- "private": false,
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
- "homepage": "https://github.com/gridaco/design-sdk",
10
- "repository": "https://github.com/gridaco/design-sdk",
11
- "authors": [
12
- "grida.co",
13
- "softmarshmallow <universe@grida.co>"
14
- ],
15
- "scripts": {
16
- "clean": "rimraf dist",
17
- "build": "tsc",
18
- "test": "jest"
19
- },
20
- "files": [
21
- "dist",
22
- "README",
23
- "LICENSE"
24
- ],
25
- "publishConfig": {
26
- "access": "public"
27
- },
28
- "gitHead": "c7fa15b65fda9c04d459a88f868e5ea8d137fa61"
2
+ "name": "@design-sdk/figma-url",
3
+ "version": "0.0.54",
4
+ "description": "Figma url utils for sharing & embeding and url inspection",
5
+ "license": "MIT",
6
+ "private": false,
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "homepage": "https://github.com/gridaco/design-sdk",
10
+ "repository": "https://github.com/gridaco/design-sdk",
11
+ "authors": [
12
+ "grida.co",
13
+ "softmarshmallow <universe@grida.co>"
14
+ ],
15
+ "scripts": {
16
+ "clean": "rimraf dist",
17
+ "build": "tsc",
18
+ "test": "jest"
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README",
23
+ "LICENSE"
24
+ ],
25
+ "publishConfig": {
26
+ "access": "public"
27
+ }
29
28
  }