@seed-design/figma 0.0.18 → 0.0.20

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/lib/index.cjs CHANGED
@@ -10797,7 +10797,7 @@ function createIconService({ iconRepository }) {
10797
10797
  }
10798
10798
  const iconData = iconRepository.getIconData(key);
10799
10799
  if (!iconData) {
10800
- throw new Error(`Icon not found: ${key}`);
10800
+ return "UnknownIcon";
10801
10801
  }
10802
10802
  const { name, weight } = iconData;
10803
10803
  return changeCase.pascalCase(`${name}${weight ? weight : ""}`);
@@ -10813,16 +10813,22 @@ function createStyleService({ styleRepository, styleNameTransformer }) {
10813
10813
  function getFigmaStyleName(id) {
10814
10814
  const style = styleRepository.findOneByKey(id);
10815
10815
  if (!style) {
10816
- throw new Error(`Style not found: ${id}`);
10816
+ return undefined;
10817
10817
  }
10818
10818
  return style.name;
10819
10819
  }
10820
10820
  function getFigmaStyleSlug(id) {
10821
10821
  const name = getFigmaStyleName(id);
10822
+ if (!name) {
10823
+ return undefined;
10824
+ }
10822
10825
  return name.split("/");
10823
10826
  }
10824
10827
  function getStyleName(id) {
10825
10828
  const slug = getFigmaStyleSlug(id);
10829
+ if (!slug) {
10830
+ return undefined;
10831
+ }
10826
10832
  return styleNameTransformer({
10827
10833
  slug
10828
10834
  });
package/lib/index.d.ts CHANGED
@@ -194,7 +194,7 @@ declare function createIconService({ iconRepository, }: {
194
194
  }): IconService;
195
195
 
196
196
  interface StyleService {
197
- getStyleName: (id: string) => string;
197
+ getStyleName: (id: string) => string | undefined;
198
198
  }
199
199
  declare function createStyleService({ styleRepository, styleNameTransformer, }: {
200
200
  styleRepository: StyleRepository;
package/lib/index.js CHANGED
@@ -10797,7 +10797,7 @@ function createIconService({ iconRepository }) {
10797
10797
  }
10798
10798
  const iconData = iconRepository.getIconData(key);
10799
10799
  if (!iconData) {
10800
- throw new Error(`Icon not found: ${key}`);
10800
+ return "UnknownIcon";
10801
10801
  }
10802
10802
  const { name, weight } = iconData;
10803
10803
  return pascalCase(`${name}${weight ? weight : ""}`);
@@ -10813,16 +10813,22 @@ function createStyleService({ styleRepository, styleNameTransformer }) {
10813
10813
  function getFigmaStyleName(id) {
10814
10814
  const style = styleRepository.findOneByKey(id);
10815
10815
  if (!style) {
10816
- throw new Error(`Style not found: ${id}`);
10816
+ return undefined;
10817
10817
  }
10818
10818
  return style.name;
10819
10819
  }
10820
10820
  function getFigmaStyleSlug(id) {
10821
10821
  const name = getFigmaStyleName(id);
10822
+ if (!name) {
10823
+ return undefined;
10824
+ }
10822
10825
  return name.split("/");
10823
10826
  }
10824
10827
  function getStyleName(id) {
10825
10828
  const slug = getFigmaStyleSlug(id);
10829
+ if (!slug) {
10830
+ return undefined;
10831
+ }
10826
10832
  return styleNameTransformer({
10827
10833
  slug
10828
10834
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/figma",
3
- "version": "0.0.18",
3
+ "version": "0.0.20",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@create-figma-plugin/utilities": "^3.0.2",
32
- "@seed-design/css": "0.0.17",
32
+ "@seed-design/css": "0.0.19",
33
33
  "change-case": "^5.2.0",
34
34
  "ts-pattern": "^5.2.0"
35
35
  },
@@ -20,7 +20,7 @@ export function createIconService({
20
20
 
21
21
  const iconData = iconRepository.getIconData(key);
22
22
  if (!iconData) {
23
- throw new Error(`Icon not found: ${key}`);
23
+ return "UnknownIcon";
24
24
  }
25
25
 
26
26
  const { name, weight } = iconData;
@@ -1,7 +1,7 @@
1
1
  import type { StyleRepository } from "./style.repository";
2
2
 
3
3
  export interface StyleService {
4
- getStyleName: (id: string) => string;
4
+ getStyleName: (id: string) => string | undefined;
5
5
  }
6
6
 
7
7
  // TODO: inferStyleName 추가해야 함, rest api에서 style value가 제공되지 않고 있어 보류
@@ -16,19 +16,29 @@ export function createStyleService({
16
16
  const style = styleRepository.findOneByKey(id);
17
17
 
18
18
  if (!style) {
19
- throw new Error(`Style not found: ${id}`);
19
+ return undefined;
20
20
  }
21
21
 
22
22
  return style.name;
23
23
  }
24
24
 
25
- function getFigmaStyleSlug(id: string): string[] {
25
+ function getFigmaStyleSlug(id: string): string[] | undefined {
26
26
  const name = getFigmaStyleName(id);
27
+
28
+ if (!name) {
29
+ return undefined;
30
+ }
31
+
27
32
  return name.split("/");
28
33
  }
29
34
 
30
35
  function getStyleName(id: string) {
31
36
  const slug = getFigmaStyleSlug(id);
37
+
38
+ if (!slug) {
39
+ return undefined;
40
+ }
41
+
32
42
  return styleNameTransformer({ slug });
33
43
  }
34
44