This repository has been archived by the owner on Mar 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support dynamic particle and recipe updates in custom particle (#149)
- Loading branch information
1 parent
5c4cf4d
commit 516c727
Showing
18 changed files
with
197 additions
and
104 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* Copyright (c) 2022 Google LLC All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
({ | ||
|
||
async update({builtinNodeTypes, selectedPipeline}, state, {service}) { | ||
const results = {}; | ||
entries(builtinNodeTypes).forEach(([key, nodeType]) => results[key] = nodeType); | ||
for (const [nodeId, {html, js, spec}] of entries(selectedPipeline?.custom)) { | ||
if (spec?.$meta?.id && spec?.$meta?.category) { | ||
results[nodeId] = spec; | ||
} | ||
await this.registerCustomParticle(nodeId, {html, js}, state, service); | ||
} | ||
return {results}; | ||
}, | ||
|
||
async registerCustomParticle(nodeId, {html, js}, state, service) { | ||
if (html !== state[nodeId]?.html || js !== state[nodeId]?.js) { | ||
assign(state, {[nodeId]: {html, js}}); | ||
await service({msg: 'updateParticle', data: { | ||
kind: nodeId, | ||
code: this.formatCode({html, js}) | ||
}}); | ||
} | ||
}, | ||
|
||
formatCode({html, js}) { | ||
return `({ | ||
${js ? `${js},` : ''} | ||
${html ? `template: html\`${html}\`` : ''} | ||
});`; | ||
} | ||
|
||
}); |
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
Oops, something went wrong.