chore: remove useless templates (#330)
This commit is contained in:
parent
ce521dae8a
commit
cacdba67cd
|
|
@ -56,7 +56,7 @@ export default class SelectTeamPlugin implements IPlugin {
|
||||||
projectFolderPrompt.default = (answers) => {
|
projectFolderPrompt.default = (answers) => {
|
||||||
// 文件夹名去除scope,如 @coze-arch/foo -> foo
|
// 文件夹名去除scope,如 @coze-arch/foo -> foo
|
||||||
const folderDir = answers.packageName.split('/').slice(-1)[0];
|
const folderDir = answers.packageName.split('/').slice(-1)[0];
|
||||||
return `packages/${answers.team}/${folderDir}`
|
return `frontend/packages/${answers.team}/${folderDir}`;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,11 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { IPlugin, IHooks, IPromptsHookParams } from 'rush-init-project-plugin';
|
import type {
|
||||||
|
IPlugin,
|
||||||
|
IHooks,
|
||||||
|
IPromptsHookParams,
|
||||||
|
} from 'rush-init-project-plugin';
|
||||||
// FIXME:
|
// FIXME:
|
||||||
// 按照 https://github.com/bytemate/rush-plugins/blob/main/rush-plugins/rush-init-project-plugin/docs/init_project_configuration.md
|
// 按照 https://github.com/bytemate/rush-plugins/blob/main/rush-plugins/rush-init-project-plugin/docs/init_project_configuration.md
|
||||||
// 一文的指引,无法正确 resolve 到对应模块,暂时没找到解决方案,故此处先用相对路径引用
|
// 一文的指引,无法正确 resolve 到对应模块,暂时没找到解决方案,故此处先用相对路径引用
|
||||||
|
|
@ -24,27 +28,34 @@ import { exec } from './utils';
|
||||||
|
|
||||||
export default class SetDefaultAuthorPlugin implements IPlugin {
|
export default class SetDefaultAuthorPlugin implements IPlugin {
|
||||||
private readonly logger = createLog({
|
private readonly logger = createLog({
|
||||||
prefix: SetDefaultAuthorPlugin.name
|
prefix: SetDefaultAuthorPlugin.name,
|
||||||
});
|
});
|
||||||
|
|
||||||
apply(hooks: IHooks): void {
|
apply(hooks: IHooks): void {
|
||||||
hooks.prompts.tap(SetDefaultAuthorPlugin.name, async (prompts: IPromptsHookParams) => {
|
hooks.prompts.tap(
|
||||||
const prompAuthorEmail = prompts.promptQueue.find((r) => r.name === 'authorName');
|
SetDefaultAuthorPlugin.name,
|
||||||
if (prompAuthorEmail) {
|
async (prompts: IPromptsHookParams) => {
|
||||||
const userEmail = String(await exec(this.logger, 'git', ['config', '--get', 'user.email']));
|
const prompAuthorEmail = prompts.promptQueue.find(
|
||||||
Object.assign(prompAuthorEmail, {
|
r => r.name === 'authorName',
|
||||||
default() {
|
);
|
||||||
return userEmail;
|
if (prompAuthorEmail) {
|
||||||
},
|
const userEmail = String(
|
||||||
validate(author: string) {
|
await exec(this.logger, 'git', ['config', '--get', 'user.email']),
|
||||||
return /@bytedance\.com$/.test(author);
|
);
|
||||||
}
|
Object.assign(prompAuthorEmail, {
|
||||||
});
|
default() {
|
||||||
|
return userEmail;
|
||||||
|
},
|
||||||
|
validate(author: string) {
|
||||||
|
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(author);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
hooks.answers.tap("authorPrefix", (answers) => {
|
hooks.answers.tap('authorPrefix', answers => {
|
||||||
answers.authorPrefix = userEmail.split('@')?.[0] ?? '';
|
answers.authorPrefix = userEmail.split('@')?.[0] ?? '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type { IHooks, IPlugin, IPromptsHookParams } from 'rush-init-project-plugin';
|
|
||||||
import { parseCommandLineArguments } from './utils/parse-args';
|
|
||||||
|
|
||||||
export default class FornaxPlugin implements IPlugin {
|
|
||||||
apply(hooks: IHooks): void {
|
|
||||||
hooks.answers.tap('FornaxPlugin', (answers) => {
|
|
||||||
if(answers.template === 'fornax-child-app') {
|
|
||||||
if(answers.packageName.startsWith('@flow-devops/fornax-')) {
|
|
||||||
answers.childAppName = answers.packageName.replace('@flow-devops/fornax-','');
|
|
||||||
} else {
|
|
||||||
throw new Error('The initialization of field childAppName failed because the packageName is invalid. Please use "@flow-devops/fornax-xxx."');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -14,28 +14,42 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { IPlugin, IHooks, ITemplatesHook, IPromptsHookParams } from 'rush-init-project-plugin';
|
import type {
|
||||||
|
IPlugin,
|
||||||
|
IHooks,
|
||||||
|
ITemplatesHook,
|
||||||
|
IPromptsHookParams,
|
||||||
|
} from 'rush-init-project-plugin';
|
||||||
// FIXME:
|
// FIXME:
|
||||||
// 按照 https://github.com/bytemate/rush-plugins/blob/main/rush-plugins/rush-init-project-plugin/docs/init_project_configuration.md
|
// 按照 https://github.com/bytemate/rush-plugins/blob/main/rush-plugins/rush-init-project-plugin/docs/init_project_configuration.md
|
||||||
// 一文的指引,无法正确 resolve 到对应模块,暂时没找到解决方案,故此处先用相对路径引用
|
// 一文的指引,无法正确 resolve 到对应模块,暂时没找到解决方案,故此处先用相对路径引用
|
||||||
// 未来需要调整为正常的 node_modules 引用方式
|
// 未来需要调整为正常的 node_modules 引用方式
|
||||||
import { getTemplatesFolder, getTemplateNameList } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin/lib/logic/templateFolder';
|
import {
|
||||||
|
getTemplatesFolder,
|
||||||
|
getTemplateNameList,
|
||||||
|
} from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin/lib/logic/templateFolder';
|
||||||
import { parseCommandLineArguments } from './utils/parse-args';
|
import { parseCommandLineArguments } from './utils/parse-args';
|
||||||
|
|
||||||
export default class ShowChatAreaTemplatePlugin implements IPlugin {
|
export default class ShowTemplatePlugin implements IPlugin {
|
||||||
apply(hooks: IHooks): void {
|
apply(hooks: IHooks): void {
|
||||||
const args = parseCommandLineArguments();
|
const args = parseCommandLineArguments();
|
||||||
|
|
||||||
const answer = JSON.parse(args.answer ?? '{}');
|
const answer = JSON.parse(args.answer ?? '{}');
|
||||||
const isShowChatAreaTemplate = answer['showChatAreaTemplate'];
|
const isShowChatAreaTemplate = answer['showTemplate'];
|
||||||
|
|
||||||
hooks.templates.tap("ShowChatAreaTemplatePlugin", (templates: ITemplatesHook) => {
|
hooks.templates.tap('ShowTemplatePlugin', (templates: ITemplatesHook) => {
|
||||||
const templateFolder: string = getTemplatesFolder();
|
const templateFolder: string = getTemplatesFolder();
|
||||||
const templateNameList = getTemplateNameList(templateFolder)
|
const templateNameList = getTemplateNameList(templateFolder);
|
||||||
|
|
||||||
const filteredNormalTemplateNameList = templateNameList.filter(item => !item.templateFolder?.includes('chat-'));
|
const filteredNormalTemplateNameList = templateNameList.filter(
|
||||||
|
item => !item.templateFolder?.includes('chat-'),
|
||||||
|
);
|
||||||
|
|
||||||
templates.templates.push(...(isShowChatAreaTemplate ? templateNameList : filteredNormalTemplateNameList ));
|
templates.templates.push(
|
||||||
|
...(isShowChatAreaTemplate
|
||||||
|
? templateNameList
|
||||||
|
: filteredNormalTemplateNameList),
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,11 +15,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { IConfig } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin';
|
import type { IConfig } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin';
|
||||||
import ShowChatAreaTemplatePlugin from './ShowChatAreaTemplatePlugin';
|
import ShowTemplatePlugin from './ShowTemplatePlugin';
|
||||||
import SetFornaxChildAppPlugin from './SetFornaxChildAppPlugin';
|
|
||||||
|
|
||||||
const config: IConfig = {
|
const config: IConfig = {
|
||||||
plugins: [new ShowChatAreaTemplatePlugin(), new SetFornaxChildAppPlugin()]
|
plugins: [new ShowTemplatePlugin()],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default config;
|
export default config;
|
||||||
|
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
import { mergeConfig } from 'vite';
|
|
||||||
import svgr from 'vite-plugin-svgr';
|
|
||||||
|
|
||||||
/** @type { import('@storybook/react-vite').StorybookConfig } */
|
|
||||||
const config = {
|
|
||||||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.tsx'],
|
|
||||||
addons: [
|
|
||||||
'@storybook/addon-links',
|
|
||||||
'@storybook/addon-essentials',
|
|
||||||
'@storybook/addon-onboarding',
|
|
||||||
'@storybook/addon-interactions',
|
|
||||||
],
|
|
||||||
framework: {
|
|
||||||
name: '@storybook/react-vite',
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
docs: {
|
|
||||||
autodocs: 'tag',
|
|
||||||
},
|
|
||||||
viteFinal: config =>
|
|
||||||
mergeConfig(config, {
|
|
||||||
plugins: [
|
|
||||||
svgr({
|
|
||||||
svgrOptions: {
|
|
||||||
native: false,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
export default config;
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
/** @type { import('@storybook/react').Preview } */
|
|
||||||
const preview = {
|
|
||||||
parameters: {
|
|
||||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
||||||
controls: {
|
|
||||||
matchers: {
|
|
||||||
color: /(background|color)$/i,
|
|
||||||
date: /Date$/i,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default preview;
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
const { defineConfig } = require('@coze-arch/stylelint-config');
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
extends: [],
|
|
||||||
});
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
# {{ packageName }}
|
|
||||||
|
|
||||||
> Project template for react component with storybook.
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- [x] eslint & ts
|
|
||||||
- [x] esm bundle
|
|
||||||
- [x] umd bundle
|
|
||||||
- [x] storybook
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
- init: `rush update`
|
|
||||||
- dev: `npm run dev`
|
|
||||||
- build: `npm run build`
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"operationSettings": [
|
|
||||||
{
|
|
||||||
"operationName": "test:cov",
|
|
||||||
"outputFolderNames": ["coverage"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"operationName": "ts-check",
|
|
||||||
"outputFolderNames": ["dist"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
const { defineConfig } = require('@coze-arch/eslint-config');
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
packageRoot: __dirname,
|
|
||||||
preset: 'web',
|
|
||||||
rules: {},
|
|
||||||
});
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import SelectTeamPlugin from '../_plugins/SelectTeamPlugin';
|
|
||||||
import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
|
|
||||||
import type { IConfig } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin';
|
|
||||||
|
|
||||||
const config: IConfig = {
|
|
||||||
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
|
|
||||||
defaultProjectConfiguration: {
|
|
||||||
tags:['level-3']
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
{
|
|
||||||
"name": "{{ packageName }}",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"description": "{{ description }}",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"author": "{{ authorName }}",
|
|
||||||
"maintainers": [],
|
|
||||||
"main": "src/index.tsx",
|
|
||||||
"scripts": {
|
|
||||||
"build": "exit 0",
|
|
||||||
"dev": "storybook dev -p 6006",
|
|
||||||
"lint": "eslint ./ --cache",
|
|
||||||
"test": "vitest --run --passWithNoTests",
|
|
||||||
"test:cov": "npm run test -- --coverage"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@coze-common/chat-area": "workspace:*",
|
|
||||||
"classnames": "^2.3.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@coze-arch/bot-typings": "workspace:*",
|
|
||||||
"@coze-arch/eslint-config": "workspace:*",
|
|
||||||
"@coze-arch/stylelint-config": "workspace:*",
|
|
||||||
"@coze-arch/ts-config": "workspace:*",
|
|
||||||
"@coze-arch/vitest-config": "workspace:*",
|
|
||||||
"@storybook/addon-essentials": "^7.6.7",
|
|
||||||
"@storybook/addon-interactions": "^7.6.7",
|
|
||||||
"@storybook/addon-links": "^7.6.7",
|
|
||||||
"@storybook/addon-onboarding": "^1.0.10",
|
|
||||||
"@storybook/blocks": "^7.6.7",
|
|
||||||
"@storybook/react": "^7.6.7",
|
|
||||||
"@storybook/react-vite": "^7.6.7",
|
|
||||||
"@storybook/test": "^7.6.7",
|
|
||||||
"@testing-library/jest-dom": "^6.1.5",
|
|
||||||
"@testing-library/react": "^14.1.2",
|
|
||||||
"@testing-library/react-hooks": "^8.0.1",
|
|
||||||
"@types/react": "18.2.37",
|
|
||||||
"@types/react-dom": "18.2.15",
|
|
||||||
"@vitest/coverage-v8": "~3.0.5",
|
|
||||||
"react": "~18.2.0",
|
|
||||||
"react-dom": "~18.2.0",
|
|
||||||
"storybook": "^7.6.7",
|
|
||||||
"stylelint": "^15.11.0",
|
|
||||||
|
|
||||||
"vite-plugin-svgr": "~3.3.0",
|
|
||||||
"vitest": "~3.0.5"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": ">=18.2.0",
|
|
||||||
"react-dom": ">=18.2.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type FC } from 'react';
|
|
||||||
|
|
||||||
type IProps = Record<string, unknown>;
|
|
||||||
|
|
||||||
export const BizMessageInnerAddonBottom: FC<IProps> = () => (
|
|
||||||
<div>hello world</div>
|
|
||||||
);
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type PluginRegistryEntry } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from './types/biz-context';
|
|
||||||
import { BizPlugin } from './plugin';
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- 插件命名大写开头符合预期
|
|
||||||
export const BizPluginRegistry: PluginRegistryEntry<PluginBizContext> = {
|
|
||||||
/**
|
|
||||||
* 贯穿插件生命周期、组件的上下文
|
|
||||||
*/
|
|
||||||
createPluginBizContext() {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 插件本体
|
|
||||||
*/
|
|
||||||
Plugin: BizPlugin,
|
|
||||||
};
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {
|
|
||||||
PluginMode,
|
|
||||||
PluginName,
|
|
||||||
ReadonlyChatAreaPlugin,
|
|
||||||
createReadonlyLifeCycleServices,
|
|
||||||
createCustomComponents,
|
|
||||||
} from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from './types/biz-context';
|
|
||||||
import { bizLifeCycleServiceGenerator } from './services/life-cycle';
|
|
||||||
import { BizMessageInnerAddonBottom } from './custom-components/message-inner-addon-bottom';
|
|
||||||
|
|
||||||
export class BizPlugin extends ReadonlyChatAreaPlugin<PluginBizContext> {
|
|
||||||
/**
|
|
||||||
* 插件类型
|
|
||||||
* PluginMode.Readonly = 只读模式
|
|
||||||
* PluginMode.Writeable = 可写模式
|
|
||||||
*/
|
|
||||||
public pluginMode = PluginMode.Readonly;
|
|
||||||
/**
|
|
||||||
* 插件名称
|
|
||||||
* 请点 PluginName 里面去定义
|
|
||||||
*/
|
|
||||||
public pluginName = PluginName.Demo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期服务
|
|
||||||
*/
|
|
||||||
public lifeCycleServices = createReadonlyLifeCycleServices(
|
|
||||||
this,
|
|
||||||
bizLifeCycleServiceGenerator,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义组件
|
|
||||||
*/
|
|
||||||
public customComponents = createCustomComponents({
|
|
||||||
MessageInnerBottomSlot: BizMessageInnerAddonBottom,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type ReadonlyAppLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const appLifeCycleServiceGenerator: ReadonlyAppLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type ReadonlyCommandLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const commandLifeCycleServiceGenerator: ReadonlyCommandLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type ReadonlyLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
import { renderLifeCycleServiceGenerator } from './render';
|
|
||||||
import { messageLifeCycleServiceGenerator } from './message';
|
|
||||||
import { commandLifeCycleServiceGenerator } from './command';
|
|
||||||
import { appLifeCycleServiceGenerator } from './app';
|
|
||||||
|
|
||||||
export const bizLifeCycleServiceGenerator: ReadonlyLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({
|
|
||||||
appLifeCycleService: appLifeCycleServiceGenerator(plugin),
|
|
||||||
messageLifeCycleService: messageLifeCycleServiceGenerator(plugin),
|
|
||||||
commandLifeCycleService: commandLifeCycleServiceGenerator(plugin),
|
|
||||||
renderLifeCycleService: renderLifeCycleServiceGenerator(plugin),
|
|
||||||
});
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type ReadonlyMessageLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const messageLifeCycleServiceGenerator: ReadonlyMessageLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type ReadonlyRenderLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const renderLifeCycleServiceGenerator: ReadonlyRenderLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export type PluginBizContext = Record<string, unknown>;
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { DemoComponent } from '../src';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
title: 'Example/Demo',
|
|
||||||
component: DemoComponent,
|
|
||||||
parameters: {
|
|
||||||
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
||||||
layout: 'centered',
|
|
||||||
},
|
|
||||||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
||||||
tags: ['autodocs'],
|
|
||||||
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
||||||
argTypes: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
||||||
export const Base = {
|
|
||||||
args: {
|
|
||||||
name: 'tecvan',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import { Meta } from "@storybook/blocks";
|
|
||||||
|
|
||||||
<Meta title="Hello world" />
|
|
||||||
|
|
||||||
<div className="sb-container">
|
|
||||||
<div className='sb-section-title'>
|
|
||||||
# Hello world
|
|
||||||
|
|
||||||
Hello world
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
{`
|
|
||||||
.sb-container {
|
|
||||||
margin-bottom: 48px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sb-section {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sb-section-title {
|
|
||||||
margin-bottom: 32px;
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "@coze-arch/ts-config/tsconfig.web.json",
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "dist",
|
|
||||||
"rootDir": "src",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"lib": ["DOM", "ESNext"],
|
|
||||||
"module": "ESNext",
|
|
||||||
"target": "ES2020",
|
|
||||||
"moduleResolution": "bundler"
|
|
||||||
},
|
|
||||||
"include": ["src"],
|
|
||||||
"exclude": ["node_modules", "dist"]
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"exclude": ["**/*"],
|
|
||||||
"compilerOptions": {
|
|
||||||
"composite": true
|
|
||||||
},
|
|
||||||
"references": [
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.build.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.misc.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "@coze-arch/ts-config/tsconfig.base.json",
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"rootDir": "./",
|
|
||||||
"outDir": "./dist",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"lib": ["DOM", "ESNext"],
|
|
||||||
"module": "ESNext",
|
|
||||||
"target": "ES2020",
|
|
||||||
"moduleResolution": "bundler"
|
|
||||||
},
|
|
||||||
"include": ["__tests__", "vitest.config.ts", "stories"],
|
|
||||||
"exclude": ["./dist"],
|
|
||||||
"references": [
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.build.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { defineConfig } from '@coze-arch/vitest-config';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
dirname: __dirname,
|
|
||||||
preset: 'web',
|
|
||||||
});
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
import { mergeConfig } from 'vite';
|
|
||||||
import svgr from 'vite-plugin-svgr';
|
|
||||||
|
|
||||||
/** @type { import('@storybook/react-vite').StorybookConfig } */
|
|
||||||
const config = {
|
|
||||||
stories: ['../stories/**/*.mdx', '../stories/**/*.stories.tsx'],
|
|
||||||
addons: [
|
|
||||||
'@storybook/addon-links',
|
|
||||||
'@storybook/addon-essentials',
|
|
||||||
'@storybook/addon-onboarding',
|
|
||||||
'@storybook/addon-interactions',
|
|
||||||
],
|
|
||||||
framework: {
|
|
||||||
name: '@storybook/react-vite',
|
|
||||||
options: {},
|
|
||||||
},
|
|
||||||
docs: {
|
|
||||||
autodocs: 'tag',
|
|
||||||
},
|
|
||||||
viteFinal: config =>
|
|
||||||
mergeConfig(config, {
|
|
||||||
plugins: [
|
|
||||||
svgr({
|
|
||||||
svgrOptions: {
|
|
||||||
native: false,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
};
|
|
||||||
export default config;
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
/** @type { import('@storybook/react').Preview } */
|
|
||||||
const preview = {
|
|
||||||
parameters: {
|
|
||||||
actions: { argTypesRegex: "^on[A-Z].*" },
|
|
||||||
controls: {
|
|
||||||
matchers: {
|
|
||||||
color: /(background|color)$/i,
|
|
||||||
date: /Date$/i,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
export default preview;
|
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
const { defineConfig } = require('@coze-arch/stylelint-config');
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
extends: [],
|
|
||||||
});
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
# {{ packageName }}
|
|
||||||
|
|
||||||
> Project template for react component with storybook.
|
|
||||||
|
|
||||||
## Features
|
|
||||||
|
|
||||||
- [x] eslint & ts
|
|
||||||
- [x] esm bundle
|
|
||||||
- [x] umd bundle
|
|
||||||
- [x] storybook
|
|
||||||
|
|
||||||
## Commands
|
|
||||||
|
|
||||||
- init: `rush update`
|
|
||||||
- dev: `npm run dev`
|
|
||||||
- build: `npm run build`
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
{
|
|
||||||
"operationSettings": [
|
|
||||||
{
|
|
||||||
"operationName": "test:cov",
|
|
||||||
"outputFolderNames": ["coverage"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"operationName": "ts-check",
|
|
||||||
"outputFolderNames": ["dist"]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
const { defineConfig } = require('@coze-arch/eslint-config');
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
packageRoot: __dirname,
|
|
||||||
preset: 'web',
|
|
||||||
rules: {},
|
|
||||||
});
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import SelectTeamPlugin from '../_plugins/SelectTeamPlugin';
|
|
||||||
import SetDefaultAuthorPlugin from '../_plugins/SetDefaultAuthorPlugin';
|
|
||||||
import type { IConfig } from '../../autoinstallers/plugins/node_modules/rush-init-project-plugin';
|
|
||||||
|
|
||||||
const config: IConfig = {
|
|
||||||
plugins: [new SetDefaultAuthorPlugin(), new SelectTeamPlugin()],
|
|
||||||
defaultProjectConfiguration: {
|
|
||||||
tags:['level-3']
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default config;
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
{
|
|
||||||
"name": "{{ packageName }}",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"description": "{{ description }}",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"author": "{{ authorName }}",
|
|
||||||
"maintainers": [],
|
|
||||||
"main": "src/index.tsx",
|
|
||||||
"scripts": {
|
|
||||||
"build": "exit 0",
|
|
||||||
"dev": "storybook dev -p 6006",
|
|
||||||
"lint": "eslint ./ --cache",
|
|
||||||
"test": "vitest --run --passWithNoTests",
|
|
||||||
"test:cov": "npm run test -- --coverage"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@coze-common/chat-area": "workspace:*",
|
|
||||||
"classnames": "^2.3.2"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@coze-arch/bot-typings": "workspace:*",
|
|
||||||
"@coze-arch/eslint-config": "workspace:*",
|
|
||||||
"@coze-arch/stylelint-config": "workspace:*",
|
|
||||||
"@coze-arch/ts-config": "workspace:*",
|
|
||||||
"@coze-arch/vitest-config": "workspace:*",
|
|
||||||
"@storybook/addon-essentials": "^7.6.7",
|
|
||||||
"@storybook/addon-interactions": "^7.6.7",
|
|
||||||
"@storybook/addon-links": "^7.6.7",
|
|
||||||
"@storybook/addon-onboarding": "^1.0.10",
|
|
||||||
"@storybook/blocks": "^7.6.7",
|
|
||||||
"@storybook/react": "^7.6.7",
|
|
||||||
"@storybook/react-vite": "^7.6.7",
|
|
||||||
"@storybook/test": "^7.6.7",
|
|
||||||
"@testing-library/jest-dom": "^6.1.5",
|
|
||||||
"@testing-library/react": "^14.1.2",
|
|
||||||
"@testing-library/react-hooks": "^8.0.1",
|
|
||||||
"@types/react": "18.2.37",
|
|
||||||
"@types/react-dom": "18.2.15",
|
|
||||||
"@vitest/coverage-v8": "~3.0.5",
|
|
||||||
"react": "~18.2.0",
|
|
||||||
"react-dom": "~18.2.0",
|
|
||||||
"storybook": "^7.6.7",
|
|
||||||
"stylelint": "^15.11.0",
|
|
||||||
|
|
||||||
"vite-plugin-svgr": "~3.3.0",
|
|
||||||
"vitest": "~3.0.5"
|
|
||||||
},
|
|
||||||
"peerDependencies": {
|
|
||||||
"react": ">=18.2.0",
|
|
||||||
"react-dom": ">=18.2.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type FC } from 'react';
|
|
||||||
|
|
||||||
type IProps = Record<string, unknown>;
|
|
||||||
|
|
||||||
export const BizMessageInnerAddonBottom: FC<IProps> = () => (
|
|
||||||
<div>hello world</div>
|
|
||||||
);
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type PluginRegistryEntry } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from './types/biz-context';
|
|
||||||
import { BizPlugin } from './plugin';
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- 插件命名大写开头符合预期
|
|
||||||
export const BizPluginRegistry: PluginRegistryEntry<PluginBizContext> = {
|
|
||||||
/**
|
|
||||||
* 贯穿插件生命周期、组件的上下文
|
|
||||||
*/
|
|
||||||
createPluginBizContext() {
|
|
||||||
return {};
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 插件本体
|
|
||||||
*/
|
|
||||||
Plugin: BizPlugin,
|
|
||||||
};
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import {
|
|
||||||
PluginMode,
|
|
||||||
PluginName,
|
|
||||||
WriteableChatAreaPlugin,
|
|
||||||
createCustomComponents,
|
|
||||||
createWriteableLifeCycleServices,
|
|
||||||
} from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from './types/biz-context';
|
|
||||||
import { bizLifeCycleServiceGenerator } from './services/life-cycle';
|
|
||||||
import { BizMessageInnerAddonBottom } from './custom-components/message-inner-addon-bottom';
|
|
||||||
|
|
||||||
export class BizPlugin extends WriteableChatAreaPlugin<PluginBizContext> {
|
|
||||||
/**
|
|
||||||
* 插件类型
|
|
||||||
* PluginMode.Readonly = 只读模式
|
|
||||||
* PluginMode.Writeable = 可写模式
|
|
||||||
*/
|
|
||||||
public pluginMode = PluginMode.Writeable;
|
|
||||||
/**
|
|
||||||
* 插件名称
|
|
||||||
* 请点 PluginName 里面去定义
|
|
||||||
*/
|
|
||||||
public pluginName = PluginName.Demo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期服务
|
|
||||||
*/
|
|
||||||
public lifeCycleServices = createWriteableLifeCycleServices(
|
|
||||||
this,
|
|
||||||
bizLifeCycleServiceGenerator,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 自定义组件
|
|
||||||
*/
|
|
||||||
public customComponents = createCustomComponents({
|
|
||||||
MessageInnerBottomSlot: BizMessageInnerAddonBottom,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type WriteableAppLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const appLifeCycleServiceGenerator: WriteableAppLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type WriteableCommandLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const commandLifeCycleServiceGenerator: WriteableCommandLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type WriteableLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
import { renderLifeCycleServiceGenerator } from './render';
|
|
||||||
import { messageLifeCycleServiceGenerator } from './message';
|
|
||||||
import { commandLifeCycleServiceGenerator } from './command';
|
|
||||||
import { appLifeCycleServiceGenerator } from './app';
|
|
||||||
|
|
||||||
export const bizLifeCycleServiceGenerator: WriteableLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({
|
|
||||||
appLifeCycleService: appLifeCycleServiceGenerator(plugin),
|
|
||||||
messageLifeCycleService: messageLifeCycleServiceGenerator(plugin),
|
|
||||||
commandLifeCycleService: commandLifeCycleServiceGenerator(plugin),
|
|
||||||
renderLifeCycleService: renderLifeCycleServiceGenerator(plugin),
|
|
||||||
});
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type WriteableMessageLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const messageLifeCycleServiceGenerator: WriteableMessageLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type WriteableRenderLifeCycleServiceGenerator } from '@coze-common/chat-area';
|
|
||||||
|
|
||||||
import { type PluginBizContext } from '../../types/biz-context';
|
|
||||||
|
|
||||||
export const renderLifeCycleServiceGenerator: WriteableRenderLifeCycleServiceGenerator<
|
|
||||||
PluginBizContext
|
|
||||||
> = plugin => ({});
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
export type PluginBizContext = Record<string, unknown>;
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/// <reference types='@coze-arch/bot-typings' />
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { DemoComponent } from '../src';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
title: 'Example/Demo',
|
|
||||||
component: DemoComponent,
|
|
||||||
parameters: {
|
|
||||||
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
||||||
layout: 'centered',
|
|
||||||
},
|
|
||||||
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
||||||
tags: ['autodocs'],
|
|
||||||
// More on argTypes: https://storybook.js.org/docs/api/argtypes
|
|
||||||
argTypes: {},
|
|
||||||
};
|
|
||||||
|
|
||||||
// More on writing stories with args: https://storybook.js.org/docs/writing-stories/args
|
|
||||||
export const Base = {
|
|
||||||
args: {
|
|
||||||
name: 'tecvan',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
import { Meta } from "@storybook/blocks";
|
|
||||||
|
|
||||||
<Meta title="Hello world" />
|
|
||||||
|
|
||||||
<div className="sb-container">
|
|
||||||
<div className='sb-section-title'>
|
|
||||||
# Hello world
|
|
||||||
|
|
||||||
Hello world
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
{`
|
|
||||||
.sb-container {
|
|
||||||
margin-bottom: 48px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sb-section {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
img {
|
|
||||||
object-fit: cover;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sb-section-title {
|
|
||||||
margin-bottom: 32px;
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
</style>
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "@coze-arch/ts-config/tsconfig.web.json",
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "dist",
|
|
||||||
"rootDir": "src",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"lib": ["DOM", "ESNext"],
|
|
||||||
"module": "ESNext",
|
|
||||||
"target": "ES2020",
|
|
||||||
"moduleResolution": "bundler"
|
|
||||||
},
|
|
||||||
"include": ["src"],
|
|
||||||
"exclude": ["node_modules", "dist"]
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
{
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"exclude": ["**/*"],
|
|
||||||
"compilerOptions": {
|
|
||||||
"composite": true
|
|
||||||
},
|
|
||||||
"references": [
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.build.json"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.misc.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
{
|
|
||||||
"extends": "@coze-arch/ts-config/tsconfig.web.json",
|
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
|
||||||
"compilerOptions": {
|
|
||||||
"rootDir": "./",
|
|
||||||
"outDir": "./dist",
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"lib": ["DOM", "ESNext"],
|
|
||||||
"module": "ESNext",
|
|
||||||
"target": "ES2020",
|
|
||||||
"moduleResolution": "bundler"
|
|
||||||
},
|
|
||||||
"include": ["__tests__", "vitest.config.ts", "stories"],
|
|
||||||
"exclude": ["./dist"],
|
|
||||||
"references": [
|
|
||||||
{
|
|
||||||
"path": "./tsconfig.build.json"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright 2025 coze-dev Authors
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { defineConfig } from '@coze-arch/vitest-config';
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
dirname: __dirname,
|
|
||||||
preset: 'web',
|
|
||||||
});
|
|
||||||
Loading…
Reference in New Issue