1- import React , { useEffect , useState } from "react" ;
2- import { api } from "@bridged.xyz/design-sdk/lib/figma-remote" ;
1+ import React , { useState } from "react" ;
2+ import { remote , utils , nodes } from "@design-sdk/figma" ;
3+ import { convert } from "@design-sdk/figma" ;
34import { utils_figma } from "../../utils" ;
4- import { utils , convert } from "@bridged.xyz/design-sdk" ;
5- import { mapFigmaRemoteToFigma } from "@bridged.xyz/design-sdk/lib/figma-remote/mapper" ;
6- import { ReflectSceneNode } from "@bridged.xyz/design-sdk/lib/nodes" ;
75import { UserInputCache } from "../../utils/user-input-value-cache" ;
8- import * as figrem from "@bridged.xyz/design-sdk/lib/figma-remote/types" ;
96
10- export type OnImportedCallback = ( reflect : ReflectSceneNode ) => void ;
11- type _OnRemoteLoadedCallback = ( reflect : figrem . Node ) => void ;
7+ export type OnImportedCallback = ( reflect : nodes . ReflectSceneNode ) => void ;
8+ type _OnRemoteLoadedCallback = ( reflect : remote . types . Node ) => void ;
129
1310async function fetchTarget ( file : string , node : string ) {
14- const client = api . Client ( {
11+ const client = remote . api . Client ( {
1512 personalAccessToken : utils_figma . figmaPersonalAccessToken ( ) ,
1613 } ) ;
1714
@@ -27,7 +24,7 @@ async function fetchTarget(file: string, node: string) {
2724
2825async function fetchDemo ( ) {
2926 const _nid = utils_figma . FIGMA_BRIDGED_DEMO_APP_ENTRY_NODE_ID ;
30- const client = api . Client ( {
27+ const client = remote . api . Client ( {
3128 personalAccessToken : utils_figma . figmaPersonalAccessToken ( ) ,
3229 } ) ;
3330
@@ -46,11 +43,11 @@ async function fetchDemo() {
4643}
4744
4845export function FigmaScreenImporter ( props : { onImported : OnImportedCallback } ) {
49- const [ reflect , setReflect ] = useState < ReflectSceneNode > ( ) ;
46+ const [ reflect , setReflect ] = useState < nodes . ReflectSceneNode > ( ) ;
5047
51- const handleLocalDataLoad = ( d : figrem . Node ) => {
48+ const handleLocalDataLoad = ( d : remote . types . Node ) => {
5249 console . log ( "api raw" , d ) ;
53- const _mapped = mapFigmaRemoteToFigma ( d as any ) ;
50+ const _mapped = remote . mapper . mapFigmaRemoteToFigma ( d as any ) ;
5451 console . log ( "mapped" , _mapped ) ;
5552 const _converted = convert . intoReflectNode ( _mapped ) ;
5653 console . log ( "converted" , _converted ) ;
@@ -85,7 +82,7 @@ function _DefaultImporterSegment(props: { onLoaded: _OnRemoteLoadedCallback }) {
8582 const handleOnLoadDefaultDesignClick = ( ) => {
8683 fetchDemo ( ) . then ( ( d ) => {
8784 // it's okay to force cast here. since the typings are the same (following official figma remote api spec)
88- props . onLoaded ( d as figrem . Node ) ;
85+ props . onLoaded ( d as remote . types . Node ) ;
8986 } ) ;
9087 } ;
9188
@@ -111,7 +108,7 @@ function _UrlImporterSegment(props: { onLoaded: _OnRemoteLoadedCallback }) {
111108 UserInputCache . set ( _FIGMA_FILE_URL_IMPORT_INPUT_CACHE_KEY , urlInput ) ;
112109 const q = utils . figmaApi . parseFileAndNodeIdFromUrl_Figma ( urlInput ) ;
113110 fetchTarget ( q . file , q . node ) . then ( ( d ) => {
114- props . onLoaded ( d as figrem . Node ) ;
111+ props . onLoaded ( d as remote . types . Node ) ;
115112 } ) ;
116113 } ;
117114
0 commit comments