16 lines
859 B
TypeScript
16 lines
859 B
TypeScript
/**
|
|
* Which plugins a project switches on (#119), read straight off the untrusted JSON of the project
|
|
* file. This is deliberately its own module rather than a part of `deserializeProject`: the editor
|
|
* has to know the list *before* it deserializes anything, because a plugin may add node types and
|
|
* asset kinds that the deserializer would otherwise throw away as unknown.
|
|
*/
|
|
export function pluginsOf(raw: unknown): string[] {
|
|
const list = (raw as { plugins?: unknown } | null)?.plugins;
|
|
const files = (Array.isArray(list) ? list : []).filter(
|
|
(file): file is string => typeof file === 'string' && file !== '',
|
|
);
|
|
// Sorted and without repeats: that is also the order the loader activates them in, so a project
|
|
// file written by hand cannot make one plugin come before another by listing it first.
|
|
return [...new Set(files)].sort();
|
|
}
|