Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/core/src/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ export const validatePatch = (patch: Patch) => {
if (typeof patch.replace !== 'object') throw new Error('patch.replace isnt an object');
};

export const validatePluginDefintion = (definition: PluginDefinition) => {
if (typeof definition !== 'object') throw new Error('defintion isnt an object');
export const validatePluginDefinition = (definition: PluginDefinition) => {
if (typeof definition !== 'object') throw new Error('definition isnt an object');
if (!Array.isArray(definition.patches)) throw new Error('definition.patches isnt an array');
for (let i = 0; i < definition.patches.length; i++) {
const patch = definition.patches[i];
Expand All @@ -38,8 +38,8 @@ export const validatePluginDefintion = (definition: PluginDefinition) => {
throw new Error('failed to validate definition.patches[' + i + ']' + '\n' + error.toString());
}
}
if (definition.init && typeof definition.init !== 'function') throw new Error('defintion.init isnt a function');
if (definition.load && typeof definition.load !== 'function') throw new Error('defintion.load isnt a function');
if (definition.init && typeof definition.init !== 'function') throw new Error('definition.init isnt a function');
if (definition.load && typeof definition.load !== 'function') throw new Error('definition.load isnt a function');
};

export const fetchManifest = async (url: string) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/plugins/loader.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fetchManifest, PluginState, validatePluginDefintion } from '.';
import { fetchManifest, PluginState, validatePluginDefinition } from '.';
import { fetchWithoutCors, getUtils, getValue, setValue } from '../utils/gm';
import { PluginManifest, Plugin, PluginDefinition } from '@placecharity/framework-types';

Expand Down Expand Up @@ -29,7 +29,7 @@ export const loadPlugin = async (url: string, manifest: PluginManifest) => {
const module = URL.createObjectURL(new Blob([await res.text()], { type: 'text/javascript' }));

const def: PluginDefinition = (await import(module)).default;
validatePluginDefintion(def);
validatePluginDefinition(def);

const utils = getUtils(manifest.id);

Expand Down