@plitzi/sdk-plugins 0.30.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1319 -0
- package/dist/PluginHelper.d.ts +4 -0
- package/dist/PluginHelper.mjs +78 -0
- package/dist/PluginsContext.d.ts +3 -0
- package/dist/PluginsContext.mjs +5 -0
- package/dist/helpers/manifestAssetToAsset.d.ts +3 -0
- package/dist/helpers/manifestAssetToAsset.mjs +24 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.mjs +3 -0
- package/package.json +48 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PluginManifest, ComponentDefinition, PluginRaw, Asset } from '@plitzi/sdk-shared';
|
|
2
|
+
export declare const fetchPluginsManifests: (manifests: string[]) => Promise<Record<string, PluginManifest>>;
|
|
3
|
+
export declare const pluginParseDefinition: (pluginsRaw?: PluginRaw | PluginRaw[]) => Promise<Record<string, ComponentDefinition>>;
|
|
4
|
+
export declare const getStyle: (plugins: Record<string, ComponentDefinition>) => Record<string, Asset>;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import e from "./helpers/manifestAssetToAsset.mjs";
|
|
2
|
+
import { get as t, omit as n } from "@plitzi/plitzi-ui/helpers";
|
|
3
|
+
import r from "@plitzi/sdk-shared/helpers/fetchManifest";
|
|
4
|
+
//#region src/PluginHelper.ts
|
|
5
|
+
var i = (r, i) => {
|
|
6
|
+
try {
|
|
7
|
+
let { resource: a, settings: o, type: s } = r, { runtime: { scope: c = "", module: l = "" }, definition: { name: u = "Plitzi's Demo Plugin", owner: d = "Plitzi", verified: f = !1, license: p = "MIT", website: m = "https://plitzi.com", backgroundColor: h = "#4422ee", icon: g = "https://cdn.plitzi.com/resources/img/favicon.svg" }, assets: _, assetsSettings: v, pluginSchema: y } = i;
|
|
8
|
+
return Object.values(t(i, "pluginSchema", {})).reduce((t, r) => {
|
|
9
|
+
let { definition: b, builder: x, defaultStyle: S, attributes: C } = r, w = [];
|
|
10
|
+
return b.type === s && (w = Object.keys(n(y, [s]))), {
|
|
11
|
+
...t,
|
|
12
|
+
[b.type]: {
|
|
13
|
+
attributes: C,
|
|
14
|
+
builder: x,
|
|
15
|
+
defaultStyle: S,
|
|
16
|
+
definition: b,
|
|
17
|
+
market: {
|
|
18
|
+
owner: d,
|
|
19
|
+
verified: f,
|
|
20
|
+
license: p,
|
|
21
|
+
website: m,
|
|
22
|
+
backgroundColor: h,
|
|
23
|
+
icon: g,
|
|
24
|
+
category: u
|
|
25
|
+
},
|
|
26
|
+
resource: a,
|
|
27
|
+
isMain: b.type === s,
|
|
28
|
+
manifest: i,
|
|
29
|
+
type: s,
|
|
30
|
+
settings: o,
|
|
31
|
+
assetsSettings: Object.values(v).filter(({ src: e }) => e ? [
|
|
32
|
+
".css",
|
|
33
|
+
".js",
|
|
34
|
+
".mjs",
|
|
35
|
+
".cjs"
|
|
36
|
+
].some((t) => e.endsWith(t)) : !1).map((t) => e(a, t, !0)),
|
|
37
|
+
assets: Object.values(_).filter(({ src: e }) => e ? [
|
|
38
|
+
".css",
|
|
39
|
+
".js",
|
|
40
|
+
".mjs",
|
|
41
|
+
".cjs"
|
|
42
|
+
].some((t) => e.endsWith(t)) : !1).map((t) => e(a, t)),
|
|
43
|
+
scope: c,
|
|
44
|
+
module: l,
|
|
45
|
+
subPlugins: w
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, {});
|
|
49
|
+
} catch {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
}, a = async (e) => {
|
|
53
|
+
if (!Array.isArray(e) || e.length === 0) return {};
|
|
54
|
+
let n = e.map((e) => r(e));
|
|
55
|
+
return (await Promise.allSettled(n)).reduce((e, n) => n.status === "fulfilled" && n.value ? {
|
|
56
|
+
...e,
|
|
57
|
+
[t(n.value, "root", "")]: n.value
|
|
58
|
+
} : e, {});
|
|
59
|
+
}, o = async (e = []) => {
|
|
60
|
+
let n = {};
|
|
61
|
+
if (!Array.isArray(e)) return n;
|
|
62
|
+
let r = await a(e.filter((e) => e.resource).reduce((e, t) => [...e, `${t.resource}/plugin-manifest.json`], []));
|
|
63
|
+
return e.forEach((e) => {
|
|
64
|
+
let { type: a } = e, o = t(r, a);
|
|
65
|
+
n = {
|
|
66
|
+
...n,
|
|
67
|
+
...i(e, o)
|
|
68
|
+
};
|
|
69
|
+
}), n;
|
|
70
|
+
}, s = (e) => Object.values(e).reduce((e, n) => ({
|
|
71
|
+
...e,
|
|
72
|
+
...t(n, "assets", []).filter((e) => e.type === "link").reduce((e, t) => ({
|
|
73
|
+
...e,
|
|
74
|
+
[btoa(t.id)]: t
|
|
75
|
+
}), {})
|
|
76
|
+
}), {});
|
|
77
|
+
//#endregion
|
|
78
|
+
export { a as fetchPluginsManifests, s as getStyle, o as pluginParseDefinition };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/helpers/manifestAssetToAsset.ts
|
|
2
|
+
var e = (e, { src: t, type: n, isMain: r }, i = !1) => {
|
|
3
|
+
let a = `${e}/${t}`, o = btoa(a), s;
|
|
4
|
+
return s = n === "style" && a.endsWith(".css") ? {
|
|
5
|
+
type: "link",
|
|
6
|
+
id: o,
|
|
7
|
+
params: {
|
|
8
|
+
href: a,
|
|
9
|
+
rel: "stylesheet",
|
|
10
|
+
type: "text/css"
|
|
11
|
+
},
|
|
12
|
+
isMain: r
|
|
13
|
+
} : {
|
|
14
|
+
type: "script",
|
|
15
|
+
id: o,
|
|
16
|
+
params: {
|
|
17
|
+
src: a,
|
|
18
|
+
type: "text/javascript"
|
|
19
|
+
},
|
|
20
|
+
isMain: r
|
|
21
|
+
}, i && delete s.isMain, s;
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { e as default };
|
package/dist/index.d.ts
ADDED
package/dist/index.mjs
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@plitzi/sdk-plugins",
|
|
3
|
+
"version": "0.30.19",
|
|
4
|
+
"license": "AGPL-3.0",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs"
|
|
12
|
+
},
|
|
13
|
+
"./PluginHelper": {
|
|
14
|
+
"types": "./dist/PluginHelper.d.ts",
|
|
15
|
+
"import": "./dist/PluginHelper.mjs"
|
|
16
|
+
},
|
|
17
|
+
"./PluginsContext": {
|
|
18
|
+
"types": "./dist/PluginsContext.d.ts",
|
|
19
|
+
"import": "./dist/PluginsContext.mjs"
|
|
20
|
+
},
|
|
21
|
+
"./helpers/manifestAssetToAsset": {
|
|
22
|
+
"types": "./dist/helpers/manifestAssetToAsset.d.ts",
|
|
23
|
+
"import": "./dist/helpers/manifestAssetToAsset.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./index": {
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"import": "./dist/index.mjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"lint": "eslint ./src",
|
|
32
|
+
"typecheck": "tsc -p tsconfig.app.json --noEmit",
|
|
33
|
+
"build:dev": "vite build --mode development --minify false && node ../sdk-shared/scripts/generate-exports.mjs",
|
|
34
|
+
"build:dev-watch": "vite build --mode development --watch --minify false",
|
|
35
|
+
"build:prod": "vite build && node ../sdk-shared/scripts/generate-exports.mjs"
|
|
36
|
+
},
|
|
37
|
+
"type": "module",
|
|
38
|
+
"sideEffects": false,
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@plitzi/sdk-shared": "0.30.19",
|
|
41
|
+
"prop-types": "^15.8.1"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"eslint": "^9.39.4",
|
|
45
|
+
"typescript": "^6.0.3",
|
|
46
|
+
"vite": "^8.0.10"
|
|
47
|
+
}
|
|
48
|
+
}
|