-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remote components (External design systems) (#140)
* remote components processing * changeset * fixes * fixes * fixes * fixes * fix everything * revert for now * fixes * change delete nodes flag --------- Co-authored-by: Jordi Sala Morales <[email protected]>
- Loading branch information
1 parent
3094f05
commit be5ff3b
Showing
10 changed files
with
96 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"penpot-exporter": minor | ||
--- | ||
|
||
Remote components processing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class RemoteComponentsLibrary { | ||
private components: Record<string, ComponentNode | ComponentSetNode> = {}; | ||
private queue: string[] = []; | ||
|
||
public register(id: string, component: ComponentNode | ComponentSetNode) { | ||
if (!Object.prototype.hasOwnProperty.call(this.components, id)) { | ||
this.queue.push(id); | ||
} | ||
|
||
this.components[id] = component; | ||
} | ||
|
||
public get(id: string): ComponentNode | ComponentSetNode | undefined { | ||
return this.components[id]; | ||
} | ||
|
||
public next(): ComponentNode | ComponentSetNode { | ||
const lastKey = this.queue.pop(); | ||
|
||
if (!lastKey) throw new Error('No components to pop'); | ||
|
||
return this.components[lastKey]; | ||
} | ||
|
||
public remaining(): number { | ||
return this.queue.length; | ||
} | ||
} | ||
|
||
export const remoteComponentLibrary = new RemoteComponentsLibrary(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters