@bbki.ng/site 2.0.52 → 3.0.0
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 +2 -0
- package/index.html +1 -1
- package/package.json +19 -17
- package/src/blog/app.tsx +0 -2
- package/src/blog/articles/index.ts +2 -2
- package/src/blog/articles/travel.mdx +1 -0
- package/src/blog/components/Img_ctx_menu/index.tsx +1 -1
- package/src/blog/components/app_ctx_menu/index.tsx +3 -15
- package/src/blog/components/article/index.tsx +4 -4
- package/src/blog/components/article_ctx_menu/index.tsx +1 -1
- package/src/blog/components/effect-layer/EffectLayer.tsx +1 -1
- package/src/blog/components/reaction/oh_reaction.tsx +1 -1
- package/src/blog/global/mdx.d.ts +1 -0
- package/src/blog/hooks/useTransitionCls.ts +1 -1
- package/src/blog/index.tsx +1 -1
- package/src/blog/main.css +40 -3
- package/src/blog/pages/extensions/txt/article.tsx +5 -1
- package/tailwind.config.cjs +1 -3
- package/vite.config.js +19 -12
- package/postcss.config.cjs +0 -6
- package/src/blog/components/plugin/PluginContentPage.tsx +0 -52
- package/src/blog/components/plugin/PluginDrawer.tsx +0 -39
- package/src/blog/components/plugin/PluginInit.tsx +0 -59
- package/src/blog/components/plugin/PluginInputForm.tsx +0 -117
- package/src/blog/components/plugin/PluginMenuItem.tsx +0 -70
- package/src/blog/components/plugin/PluginRoutes.tsx +0 -23
- package/src/blog/components/plugin/PluginsMenuItem.tsx +0 -70
- package/src/blog/components/plugin/hooks/useDependencies.ts +0 -80
- package/src/blog/components/plugin/hooks/usePluginOutput.tsx +0 -17
- package/src/blog/components/plugin/pluginUI/PluginUI.tsx +0 -34
- package/src/blog/demo/DemoBox.tsx +0 -15
- package/src/blog/demo/DemoMenu.tsx +0 -66
- package/src/blog/demo/ImgDemo.tsx +0 -34
- package/src/blog/demo/PluginDemo.ts +0 -24
- package/src/blog/demo/SpinnerDemo.tsx +0 -13
- package/src/blog/demo/Xwy.tsx +0 -13
- package/src/blog/plugin/Dependencies.ts +0 -14
- package/src/blog/plugin/HostFuncAdapter.ts +0 -28
- package/src/blog/plugin/Plugin.ts +0 -125
- package/src/blog/plugin/PluginEvent.ts +0 -50
- package/src/blog/plugin/PluginManager.ts +0 -166
- package/src/blog/plugin/PluginManagerPayload.ts +0 -3
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { PluginInput, PluginInputFieldType } from "@/plugin/Plugin";
|
|
3
|
-
import {
|
|
4
|
-
z,
|
|
5
|
-
zodResolver,
|
|
6
|
-
useForm,
|
|
7
|
-
Form,
|
|
8
|
-
FormField,
|
|
9
|
-
FormItem,
|
|
10
|
-
FormLabel,
|
|
11
|
-
Input,
|
|
12
|
-
Button,
|
|
13
|
-
ButtonType,
|
|
14
|
-
FormControl,
|
|
15
|
-
} from "@bbki.ng/components";
|
|
16
|
-
import { PluginDrawer } from "@/components/plugin/PluginDrawer";
|
|
17
|
-
import { DialogProps } from "vaul";
|
|
18
|
-
|
|
19
|
-
type PluginInputFormProps = {
|
|
20
|
-
input: PluginInput;
|
|
21
|
-
onSubmit: (input: string) => void;
|
|
22
|
-
} & Pick<DialogProps, "open"> &
|
|
23
|
-
Pick<DialogProps, "onOpenChange">;
|
|
24
|
-
|
|
25
|
-
const getPluginInputSchema = (input: PluginInput) => {
|
|
26
|
-
const obj: any = {};
|
|
27
|
-
const typeMap = {
|
|
28
|
-
[PluginInputFieldType.String]: z.string().default(""),
|
|
29
|
-
[PluginInputFieldType.Number]: z.number().default(0),
|
|
30
|
-
[PluginInputFieldType.Boolean]: z.boolean().default(false),
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
input.forEach((item) => {
|
|
34
|
-
obj[item.name] = typeMap[item.type];
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return z.object(obj);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const getInputDefaultValue = (type: PluginInputFieldType) => {
|
|
41
|
-
switch (type) {
|
|
42
|
-
case PluginInputFieldType.String:
|
|
43
|
-
return "";
|
|
44
|
-
case PluginInputFieldType.Number:
|
|
45
|
-
return 0;
|
|
46
|
-
case PluginInputFieldType.Boolean:
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const getPluginDefaultInput = (input: PluginInput) => {
|
|
52
|
-
const obj: any = {};
|
|
53
|
-
input.forEach((item) => {
|
|
54
|
-
obj[item.name] = getInputDefaultValue(item.type);
|
|
55
|
-
});
|
|
56
|
-
return obj;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getInputType = (type: PluginInputFieldType) => {
|
|
60
|
-
switch (type) {
|
|
61
|
-
case PluginInputFieldType.String:
|
|
62
|
-
return "text";
|
|
63
|
-
case PluginInputFieldType.Number:
|
|
64
|
-
return "number";
|
|
65
|
-
case PluginInputFieldType.Boolean:
|
|
66
|
-
return "checkbox";
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const PluginInputForm = (props: PluginInputFormProps) => {
|
|
71
|
-
const { input, onSubmit, open, onOpenChange } = props;
|
|
72
|
-
const schema = getPluginInputSchema(input);
|
|
73
|
-
const form = useForm<z.infer<typeof schema>>({
|
|
74
|
-
resolver: zodResolver(schema),
|
|
75
|
-
values: getPluginDefaultInput(input),
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
const ok = (data: z.infer<typeof schema>) => {
|
|
79
|
-
onSubmit(JSON.stringify(data));
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<PluginDrawer open={open} onOpenChange={onOpenChange}>
|
|
84
|
-
<Form {...form}>
|
|
85
|
-
<form onSubmit={form.handleSubmit(ok)}>
|
|
86
|
-
{input.map((item) => {
|
|
87
|
-
return (
|
|
88
|
-
<FormField
|
|
89
|
-
key={item.name}
|
|
90
|
-
control={form.control}
|
|
91
|
-
render={({ field }) => {
|
|
92
|
-
return (
|
|
93
|
-
<FormItem>
|
|
94
|
-
<FormLabel>{item.name}</FormLabel>
|
|
95
|
-
<FormControl>
|
|
96
|
-
<Input type={getInputType(item.type)} {...field} />
|
|
97
|
-
</FormControl>
|
|
98
|
-
</FormItem>
|
|
99
|
-
);
|
|
100
|
-
}}
|
|
101
|
-
name={item.name}
|
|
102
|
-
/>
|
|
103
|
-
);
|
|
104
|
-
})}
|
|
105
|
-
<Button
|
|
106
|
-
className="mt-16"
|
|
107
|
-
onClick={() => {}}
|
|
108
|
-
btnType="submit"
|
|
109
|
-
type={ButtonType.PRIMARY}
|
|
110
|
-
>
|
|
111
|
-
Ok
|
|
112
|
-
</Button>
|
|
113
|
-
</form>
|
|
114
|
-
</Form>
|
|
115
|
-
</PluginDrawer>
|
|
116
|
-
);
|
|
117
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
ContextMenuItem,
|
|
4
|
-
ContextMenuSub,
|
|
5
|
-
ContextMenuSubContent,
|
|
6
|
-
ContextMenuSubTrigger,
|
|
7
|
-
} from "@bbki.ng/components";
|
|
8
|
-
import { PluginConfig, PluginStatus } from "@/plugin/Plugin";
|
|
9
|
-
|
|
10
|
-
type PluginMenuItemProps = {
|
|
11
|
-
plugin: PluginConfig;
|
|
12
|
-
onUninstall: (plugin: PluginConfig) => void;
|
|
13
|
-
onInstall: (plugin: PluginConfig) => void;
|
|
14
|
-
onStop: (plugin: PluginConfig) => void;
|
|
15
|
-
onRun: (plugin: PluginConfig) => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const PluginMenuItem = (props: PluginMenuItemProps) => {
|
|
19
|
-
const { plugin, onUninstall, onStop, onRun, onInstall } = props;
|
|
20
|
-
return (
|
|
21
|
-
<ContextMenuSub>
|
|
22
|
-
<ContextMenuSubTrigger>
|
|
23
|
-
<div className="flex justify-between w-full mr-16">
|
|
24
|
-
<span>{plugin.name}</span>
|
|
25
|
-
<span>v{plugin.version}</span>
|
|
26
|
-
</div>
|
|
27
|
-
</ContextMenuSubTrigger>
|
|
28
|
-
<ContextMenuSubContent className="w-48">
|
|
29
|
-
{plugin.status !== PluginStatus.Available && (
|
|
30
|
-
<ContextMenuItem
|
|
31
|
-
onClick={() => {
|
|
32
|
-
onUninstall(plugin);
|
|
33
|
-
}}
|
|
34
|
-
>
|
|
35
|
-
uninstall
|
|
36
|
-
</ContextMenuItem>
|
|
37
|
-
)}
|
|
38
|
-
{plugin.status === PluginStatus.Available && (
|
|
39
|
-
<ContextMenuItem
|
|
40
|
-
onClick={() => {
|
|
41
|
-
onInstall(plugin);
|
|
42
|
-
}}
|
|
43
|
-
>
|
|
44
|
-
install
|
|
45
|
-
</ContextMenuItem>
|
|
46
|
-
)}
|
|
47
|
-
{plugin.status === PluginStatus.Running && (
|
|
48
|
-
<ContextMenuItem
|
|
49
|
-
onClick={() => {
|
|
50
|
-
onStop(plugin);
|
|
51
|
-
}}
|
|
52
|
-
>
|
|
53
|
-
stop
|
|
54
|
-
</ContextMenuItem>
|
|
55
|
-
)}
|
|
56
|
-
{(plugin.status === PluginStatus.Installed ||
|
|
57
|
-
plugin.status === PluginStatus.Stopped) &&
|
|
58
|
-
!plugin.route && (
|
|
59
|
-
<ContextMenuItem
|
|
60
|
-
onClick={() => {
|
|
61
|
-
onRun(plugin);
|
|
62
|
-
}}
|
|
63
|
-
>
|
|
64
|
-
run
|
|
65
|
-
</ContextMenuItem>
|
|
66
|
-
)}
|
|
67
|
-
</ContextMenuSubContent>
|
|
68
|
-
</ContextMenuSub>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { threeColWrapper } from "@/components/with_wrapper";
|
|
2
|
-
import { CenterLinkList } from "@/components";
|
|
3
|
-
import React, { useContext } from "react";
|
|
4
|
-
import { GlobalRoutesContext } from "@/context/global_routes_provider";
|
|
5
|
-
import { useSafeArticleLoading } from "@/hooks/use_safe_loading";
|
|
6
|
-
|
|
7
|
-
const PluginRoutesContent = () => {
|
|
8
|
-
const globalRouteCtx = useContext(GlobalRoutesContext);
|
|
9
|
-
const routes = globalRouteCtx.globalRoutes;
|
|
10
|
-
|
|
11
|
-
const isLoading = useSafeArticleLoading(0.2, 3);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<CenterLinkList
|
|
15
|
-
className="select-none"
|
|
16
|
-
links={routes}
|
|
17
|
-
title=""
|
|
18
|
-
loading={isLoading}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const PluginRoutes = PluginRoutesContent;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
ContextMenuSeparator,
|
|
4
|
-
ContextMenuItem,
|
|
5
|
-
ContextMenuSubContent,
|
|
6
|
-
ContextMenuSub,
|
|
7
|
-
ContextMenuSubTrigger,
|
|
8
|
-
} from "@bbki.ng/components";
|
|
9
|
-
import { Plugin, PluginConfig } from "@/plugin/Plugin";
|
|
10
|
-
import { PluginManager } from "@/plugin/PluginManager";
|
|
11
|
-
import { PluginMenuItem } from "@/components/plugin/PluginMenuItem";
|
|
12
|
-
|
|
13
|
-
export const PluginsMenuItem = () => {
|
|
14
|
-
const [plugins, setPlugins] = React.useState<PluginConfig[]>([]);
|
|
15
|
-
|
|
16
|
-
React.useEffect(() => {
|
|
17
|
-
setPlugins(PluginManager.instance.listAvailable());
|
|
18
|
-
}, []);
|
|
19
|
-
return (
|
|
20
|
-
<ContextMenuSub>
|
|
21
|
-
<ContextMenuSubTrigger>
|
|
22
|
-
<svg
|
|
23
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
24
|
-
width="16"
|
|
25
|
-
height="16"
|
|
26
|
-
viewBox="0 0 24 24"
|
|
27
|
-
fill="none"
|
|
28
|
-
stroke="currentColor"
|
|
29
|
-
strokeWidth="2"
|
|
30
|
-
strokeLinecap="round"
|
|
31
|
-
stroke-linejoin="round"
|
|
32
|
-
className="feather feather-cpu mr-8"
|
|
33
|
-
>
|
|
34
|
-
<rect x="4" y="4" width="16" height="16" rx="2" ry="2"></rect>
|
|
35
|
-
<rect x="9" y="9" width="6" height="6"></rect>
|
|
36
|
-
<line x1="9" y1="1" x2="9" y2="4"></line>
|
|
37
|
-
<line x1="15" y1="1" x2="15" y2="4"></line>
|
|
38
|
-
<line x1="9" y1="20" x2="9" y2="23"></line>
|
|
39
|
-
<line x1="15" y1="20" x2="15" y2="23"></line>
|
|
40
|
-
<line x1="20" y1="9" x2="23" y2="9"></line>
|
|
41
|
-
<line x1="20" y1="14" x2="23" y2="14"></line>
|
|
42
|
-
<line x1="1" y1="9" x2="4" y2="9"></line>
|
|
43
|
-
<line x1="1" y1="14" x2="4" y2="14"></line>
|
|
44
|
-
</svg>
|
|
45
|
-
Plugins
|
|
46
|
-
</ContextMenuSubTrigger>
|
|
47
|
-
<ContextMenuSubContent className="w-48">
|
|
48
|
-
{plugins.map((plugin) => (
|
|
49
|
-
<PluginMenuItem
|
|
50
|
-
key={plugin.id}
|
|
51
|
-
plugin={plugin}
|
|
52
|
-
onInstall={async (plugin: PluginConfig) => {
|
|
53
|
-
await PluginManager.instance.install(plugin.id);
|
|
54
|
-
setPlugins(PluginManager.instance.listAvailable());
|
|
55
|
-
}}
|
|
56
|
-
onUninstall={async (plugin: PluginConfig) => {
|
|
57
|
-
await PluginManager.instance.uninstall(plugin);
|
|
58
|
-
setPlugins(PluginManager.instance.listAvailable());
|
|
59
|
-
}}
|
|
60
|
-
onRun={async (plugin: PluginConfig) => {
|
|
61
|
-
await PluginManager.instance.run(plugin.id);
|
|
62
|
-
setPlugins(PluginManager.instance.listAvailable());
|
|
63
|
-
}}
|
|
64
|
-
onStop={(plugin: PluginConfig) => {}}
|
|
65
|
-
/>
|
|
66
|
-
))}
|
|
67
|
-
</ContextMenuSubContent>
|
|
68
|
-
</ContextMenuSub>
|
|
69
|
-
);
|
|
70
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { Dependencies } from "@/plugin/Dependencies";
|
|
2
|
-
import React, { useContext, useRef } from "react";
|
|
3
|
-
import { GlobalLoadingContext } from "@/context/global_loading_state_provider";
|
|
4
|
-
import { PluginInput } from "@/plugin/Plugin";
|
|
5
|
-
import { toast } from "sonner";
|
|
6
|
-
import { GlobalRoutesContext } from "@/context/global_routes_provider";
|
|
7
|
-
import { PluginManager } from "@/plugin/PluginManager";
|
|
8
|
-
import { apiFetcher } from "@/utils";
|
|
9
|
-
|
|
10
|
-
type inputResolve = (value: string | PromiseLike<string>) => void;
|
|
11
|
-
|
|
12
|
-
interface depHooksRes extends Dependencies {
|
|
13
|
-
setPluginFormInputOpen: (open: boolean) => void;
|
|
14
|
-
isPluginFormInputOpen: boolean;
|
|
15
|
-
pluginInputFormConf: PluginInput;
|
|
16
|
-
formDataResolver: inputResolve;
|
|
17
|
-
pluginUIRef: React.MutableRefObject<{
|
|
18
|
-
open: boolean;
|
|
19
|
-
setHtml: (html: string) => void;
|
|
20
|
-
} | null>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const useDependencies = (): depHooksRes => {
|
|
24
|
-
const { setIsLoading } = useContext(GlobalLoadingContext);
|
|
25
|
-
const [open, setOpen] = React.useState(false);
|
|
26
|
-
|
|
27
|
-
const [input, setInput] = React.useState<PluginInput>([]);
|
|
28
|
-
|
|
29
|
-
const resolveRef = useRef<inputResolve>();
|
|
30
|
-
|
|
31
|
-
const globalRouteCtx = useContext(GlobalRoutesContext);
|
|
32
|
-
|
|
33
|
-
const pluginUIRef = useRef<{ open: boolean; setHtml: (html: string) => void } | null>(null);
|
|
34
|
-
|
|
35
|
-
return {
|
|
36
|
-
callPlugin: (id, method) => {
|
|
37
|
-
if (!PluginManager.instance) {
|
|
38
|
-
return Promise.reject("Plugin manager not initialized");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return PluginManager.instance.run(id, method);
|
|
42
|
-
},
|
|
43
|
-
addRoute: (name, to) => {
|
|
44
|
-
globalRouteCtx.addGlobalRoute({
|
|
45
|
-
name,
|
|
46
|
-
to: "/plugins/" + to,
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
removeRoute: (name) => {
|
|
50
|
-
globalRouteCtx.removeGlobalRoute(name);
|
|
51
|
-
},
|
|
52
|
-
loading: setIsLoading,
|
|
53
|
-
toast: (content: string) => {
|
|
54
|
-
toast.success(content, {
|
|
55
|
-
position: "bottom-right",
|
|
56
|
-
});
|
|
57
|
-
},
|
|
58
|
-
showUI: (html: string) => {
|
|
59
|
-
if (!pluginUIRef.current) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
pluginUIRef.current.setHtml(html);
|
|
63
|
-
},
|
|
64
|
-
fetchPlugins: async () => {
|
|
65
|
-
return apiFetcher("plugin");
|
|
66
|
-
},
|
|
67
|
-
showForm: async (input) => {
|
|
68
|
-
setOpen(true);
|
|
69
|
-
setInput(input);
|
|
70
|
-
return new Promise<string>((resolve) => {
|
|
71
|
-
resolveRef.current = resolve;
|
|
72
|
-
});
|
|
73
|
-
},
|
|
74
|
-
pluginUIRef,
|
|
75
|
-
setPluginFormInputOpen: setOpen,
|
|
76
|
-
isPluginFormInputOpen: open,
|
|
77
|
-
pluginInputFormConf: input,
|
|
78
|
-
formDataResolver: resolveRef.current as inputResolve,
|
|
79
|
-
};
|
|
80
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { PluginManager } from "@/plugin/PluginManager";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
|
|
4
|
-
export const usePluginOutput = (pluginId?: number): string => {
|
|
5
|
-
const [output, setOutput] = useState<string>("");
|
|
6
|
-
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
if (!pluginId) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
PluginManager.instance.run(pluginId).then((result) => {
|
|
12
|
-
setOutput(result as string);
|
|
13
|
-
});
|
|
14
|
-
}, [pluginId]);
|
|
15
|
-
|
|
16
|
-
return output;
|
|
17
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useImperativeHandle, forwardRef } from "react"
|
|
2
|
-
import { PluginDrawer } from "../PluginDrawer"
|
|
3
|
-
|
|
4
|
-
export type PluginUIProps = {
|
|
5
|
-
html?: string,
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
const PluginUI = (props: PluginUIProps, ref: React.ForwardedRef<{ setHtml: (html: string) => void }>) => {
|
|
9
|
-
const iframeRef = useRef<HTMLIFrameElement>(null);
|
|
10
|
-
const [open, setOpen] = React.useState(false);
|
|
11
|
-
const [html, setHtml] = React.useState(props.html);
|
|
12
|
-
|
|
13
|
-
useImperativeHandle(ref, () => ({
|
|
14
|
-
setHtml: (h) => {
|
|
15
|
-
setHtml(h);
|
|
16
|
-
setOpen(true);
|
|
17
|
-
},
|
|
18
|
-
}), []);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<PluginDrawer
|
|
22
|
-
open={open}
|
|
23
|
-
onOpenChange={setOpen}
|
|
24
|
-
>
|
|
25
|
-
<iframe
|
|
26
|
-
sandbox="allow-scripts allow-same-origin"
|
|
27
|
-
ref={iframeRef}
|
|
28
|
-
srcDoc={html}
|
|
29
|
-
/>
|
|
30
|
-
</PluginDrawer>
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export default forwardRef(PluginUI)
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
export const DemoBox = (props: {
|
|
4
|
-
children?: ReactNode;
|
|
5
|
-
style?: React.CSSProperties;
|
|
6
|
-
}) => {
|
|
7
|
-
return (
|
|
8
|
-
<div
|
|
9
|
-
className="grid place-items-center md:p-32 border-gray-400 aspect-square border border-dotted aspect-1"
|
|
10
|
-
style={props.style || {}}
|
|
11
|
-
>
|
|
12
|
-
{props.children}
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
};
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
ContextMenu,
|
|
4
|
-
ContextMenuCheckboxItem,
|
|
5
|
-
ContextMenuContent,
|
|
6
|
-
ContextMenuItem,
|
|
7
|
-
ContextMenuLabel,
|
|
8
|
-
ContextMenuRadioGroup,
|
|
9
|
-
ContextMenuRadioItem,
|
|
10
|
-
ContextMenuSeparator,
|
|
11
|
-
ContextMenuShortcut,
|
|
12
|
-
ContextMenuSub,
|
|
13
|
-
ContextMenuSubContent,
|
|
14
|
-
ContextMenuSubTrigger,
|
|
15
|
-
ContextMenuTrigger,
|
|
16
|
-
} from "@bbki.ng/components";
|
|
17
|
-
|
|
18
|
-
export function ContextMenuDemo() {
|
|
19
|
-
return (
|
|
20
|
-
<ContextMenu>
|
|
21
|
-
<ContextMenuTrigger>Right click here</ContextMenuTrigger>
|
|
22
|
-
<ContextMenuContent className="w-256">
|
|
23
|
-
<ContextMenuItem inset>
|
|
24
|
-
Back
|
|
25
|
-
<ContextMenuShortcut>⌘[</ContextMenuShortcut>
|
|
26
|
-
</ContextMenuItem>
|
|
27
|
-
<ContextMenuItem inset disabled>
|
|
28
|
-
Forward
|
|
29
|
-
<ContextMenuShortcut>⌘]</ContextMenuShortcut>
|
|
30
|
-
</ContextMenuItem>
|
|
31
|
-
<ContextMenuItem inset>
|
|
32
|
-
Reload
|
|
33
|
-
<ContextMenuShortcut>⌘R</ContextMenuShortcut>
|
|
34
|
-
</ContextMenuItem>
|
|
35
|
-
<ContextMenuSub>
|
|
36
|
-
<ContextMenuSubTrigger inset>More Tools</ContextMenuSubTrigger>
|
|
37
|
-
<ContextMenuSubContent className="w-48">
|
|
38
|
-
<ContextMenuItem>
|
|
39
|
-
Save Page As...
|
|
40
|
-
<ContextMenuShortcut>⇧⌘S</ContextMenuShortcut>
|
|
41
|
-
</ContextMenuItem>
|
|
42
|
-
<ContextMenuItem>Create Shortcut...</ContextMenuItem>
|
|
43
|
-
<ContextMenuItem>Name Window...</ContextMenuItem>
|
|
44
|
-
<ContextMenuSeparator />
|
|
45
|
-
<ContextMenuItem>Developer Tools</ContextMenuItem>
|
|
46
|
-
</ContextMenuSubContent>
|
|
47
|
-
</ContextMenuSub>
|
|
48
|
-
<ContextMenuSeparator />
|
|
49
|
-
<ContextMenuCheckboxItem checked>
|
|
50
|
-
Show Bookmarks Bar
|
|
51
|
-
<ContextMenuShortcut>⌘⇧B</ContextMenuShortcut>
|
|
52
|
-
</ContextMenuCheckboxItem>
|
|
53
|
-
<ContextMenuCheckboxItem>Show Full URLs</ContextMenuCheckboxItem>
|
|
54
|
-
<ContextMenuSeparator />
|
|
55
|
-
<ContextMenuRadioGroup value="pedro">
|
|
56
|
-
<ContextMenuLabel inset>People</ContextMenuLabel>
|
|
57
|
-
<ContextMenuSeparator />
|
|
58
|
-
<ContextMenuRadioItem value="pedro">
|
|
59
|
-
Pedro Duarte
|
|
60
|
-
</ContextMenuRadioItem>
|
|
61
|
-
<ContextMenuRadioItem value="colm">Colm Tuite</ContextMenuRadioItem>
|
|
62
|
-
</ContextMenuRadioGroup>
|
|
63
|
-
</ContextMenuContent>
|
|
64
|
-
</ContextMenu>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { Button, Img, ImgProps } from "@bbki.ng/components";
|
|
3
|
-
import { PHOTOS_FOR_DEMO } from "@/constants/photos";
|
|
4
|
-
import { DemoBox } from "@/demo/DemoBox";
|
|
5
|
-
import { Photo } from "@/types/photo";
|
|
6
|
-
|
|
7
|
-
const ImgWrapper = (props: ImgProps) => {
|
|
8
|
-
return (
|
|
9
|
-
<DemoBox>
|
|
10
|
-
<Img {...props} />
|
|
11
|
-
</DemoBox>
|
|
12
|
-
);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const ImgDemo = () => {
|
|
16
|
-
const [count, setCount] = useState(0);
|
|
17
|
-
const refresh = () => {
|
|
18
|
-
setCount(count + 1);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const images: Photo[] = PHOTOS_FOR_DEMO;
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<div>
|
|
25
|
-
<ImgWrapper
|
|
26
|
-
{...images[count % images.length]}
|
|
27
|
-
key={count}
|
|
28
|
-
/>
|
|
29
|
-
<Button onClick={refresh} className="mx-32 my-16">
|
|
30
|
-
刷新
|
|
31
|
-
</Button>
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import createPlugin from "@extism/extism";
|
|
2
|
-
import { CurrentPlugin } from "@extism/extism";
|
|
3
|
-
import { toast } from "sonner";
|
|
4
|
-
|
|
5
|
-
const plugin = await createPlugin("http://localhost:5173/demo.wasm", {
|
|
6
|
-
useWasi: true,
|
|
7
|
-
functions: {
|
|
8
|
-
"extism:host/user": {
|
|
9
|
-
toast: (cp: CurrentPlugin, offs: bigint) => {
|
|
10
|
-
const content = cp.read(offs).text();
|
|
11
|
-
toast.success(content, {
|
|
12
|
-
position: "bottom-right",
|
|
13
|
-
});
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const testPlugin = async () => {
|
|
20
|
-
const input = "bbki.ng";
|
|
21
|
-
let out = await plugin.call("greet", input);
|
|
22
|
-
console.log(out.text());
|
|
23
|
-
return out.text();
|
|
24
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { DemoBox } from "@/demo/DemoBox.js";
|
|
3
|
-
import { Spinner } from "@/components/Spinner";
|
|
4
|
-
|
|
5
|
-
export const SpinnerDemo = () => {
|
|
6
|
-
return (
|
|
7
|
-
<DemoBox style={{ background: "#dc5530", borderColor: "white" }}>
|
|
8
|
-
<Spinner
|
|
9
|
-
disableDotIndicator
|
|
10
|
-
/>
|
|
11
|
-
</DemoBox>
|
|
12
|
-
);
|
|
13
|
-
};
|
package/src/blog/demo/Xwy.tsx
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Img } from "@bbki.ng/components";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
export const Xwy = () => {
|
|
5
|
-
const xwy = {
|
|
6
|
-
src: "https://zjh-im-res.oss-cn-shenzhen.aliyuncs.com/image/illustration/illustration/xwy.jpg",
|
|
7
|
-
renderedWidth: 400,
|
|
8
|
-
width: 1125,
|
|
9
|
-
height: 750,
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
return <Img {...xwy} />;
|
|
13
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PluginInput } from "@/plugin/Plugin";
|
|
2
|
-
import { PluginConfig } from "@/plugin/Plugin";
|
|
3
|
-
|
|
4
|
-
export interface Dependencies {
|
|
5
|
-
toast: (content: string) => void;
|
|
6
|
-
loading: (show: boolean) => void;
|
|
7
|
-
showForm: (input: PluginInput) => Promise<string>;
|
|
8
|
-
showUI: (html: string) => void;
|
|
9
|
-
|
|
10
|
-
addRoute: (name: string, to: string) => void;
|
|
11
|
-
removeRoute: (name: string) => void;
|
|
12
|
-
callPlugin: (id: number, method: string) => Promise<any>;
|
|
13
|
-
fetchPlugins: () => Promise<PluginConfig[]>;
|
|
14
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { CurrentPlugin, ExtismPluginOptions } from "@extism/extism";
|
|
2
|
-
import { Dependencies } from "@/plugin/Dependencies";
|
|
3
|
-
|
|
4
|
-
type HostFunctions = ExtismPluginOptions["functions"];
|
|
5
|
-
|
|
6
|
-
export const hostFuncAdapter = (dep: Dependencies): HostFunctions => {
|
|
7
|
-
return {
|
|
8
|
-
"extism:host/user": {
|
|
9
|
-
// ui state
|
|
10
|
-
loading: (cp: CurrentPlugin, offs: bigint) => {
|
|
11
|
-
const show = cp.read(offs).text() === "true";
|
|
12
|
-
dep.loading(show);
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
// ui io
|
|
16
|
-
toast: (cp: CurrentPlugin, offs: bigint) => {
|
|
17
|
-
const content = cp.read(offs).text();
|
|
18
|
-
dep.toast(content);
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
callPlugin: (cp: CurrentPlugin, name: bigint, args: bigint) => {
|
|
22
|
-
const id = cp.read(name).number();
|
|
23
|
-
const method = cp.read(args).text();
|
|
24
|
-
return dep.callPlugin(id, method);
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
};
|