diff --git a/examples/basic-project/src/app.tsx b/examples/basic-project/src/app.tsx index d5f870e6a..eec7a959d 100644 --- a/examples/basic-project/src/app.tsx +++ b/examples/basic-project/src/app.tsx @@ -1,4 +1,20 @@ import * as React from 'react'; -import { runApp } from 'ice'; +// import { AppConfig } from 'ice'; -runApp({}); \ No newline at end of file +// runApp({ +// app: { +// getInitialData: async (ctx) => { +// console.log(ctx); +// return { +// auth: { +// admin: true, +// }, +// }; +// }, +// }, +// }); + +const appConfig = { + +}; +export default appConfig; \ No newline at end of file diff --git a/packages/build-webpack-config/src/index.ts b/packages/build-webpack-config/src/index.ts index ba3f1c78b..593350776 100644 --- a/packages/build-webpack-config/src/index.ts +++ b/packages/build-webpack-config/src/index.ts @@ -30,7 +30,7 @@ const getWebpackConfig: GetWebpackConfig = ({ rootDir, config }) => { const webpackPlugins = getTransformPlugins(rootDir, config).map((plugin) => createUnplugin(() => plugin).webpack()); return { mode, - entry: path.join(rootDir, 'src/app'), + entry: path.join(rootDir, '.ice/entry.client'), externals, output: { publicPath, @@ -44,6 +44,7 @@ const getWebpackConfig: GetWebpackConfig = ({ rootDir, config }) => { resolve: { alias: { ice: path.join(rootDir, '.ice', 'index.ts'), + '@': path.join(rootDir, 'src'), ...alias, }, extensions: ['.ts', '.tsx', '.jsx', '...'], diff --git a/packages/ice/package.json b/packages/ice/package.json index 5778ae479..d8c035b74 100644 --- a/packages/ice/package.json +++ b/packages/ice/package.json @@ -22,6 +22,7 @@ "@builder/pack": "^0.6.0", "@builder/webpack-config": "^3.0.0", "@ice/plugin-app": "^1.0.0", + "@ice/plugin-auth": "^1.0.0", "@ice/plugin-router": "^1.0.0", "@ice/runtime": "^1.0.0", "address": "^1.1.2", diff --git a/packages/ice/src/commands/build.ts b/packages/ice/src/commands/build.ts index cf1d4b5b8..486ca81f5 100644 --- a/packages/ice/src/commands/build.ts +++ b/packages/ice/src/commands/build.ts @@ -1,3 +1,4 @@ +import * as path from 'path'; import consola from 'consola'; import type { Context } from 'build-scripts'; import type { StatsError } from 'webpack'; @@ -5,6 +6,7 @@ import webpackCompiler from '../service/webpackCompiler.js'; import formatWebpackMessages from '../utils/formatWebpackMessages.js'; import { getWebpackConfig, getTransformPlugins } from '@builder/webpack-config'; import type { Config } from '@ice/types'; +import { config } from 'process'; const build = async (context: Context) => { const { getConfig, applyHook, commandArgs, command } = context; @@ -14,11 +16,17 @@ const build = async (context: Context) => { await applyHook('error', { err: new Error(errMsg) }); return; } + // transform config to webpack config const webpackConfig = configs.map((task) => { + const { config } = task; + config.alias = { + ...config.alias, + '@ice/plugin-auth/runtime': path.join(require.resolve('@ice/plugin-auth'), '../../runtime'), + }; return getWebpackConfig({ rootDir, - config: task.config, + config, }); }); const transformPlugins = getTransformPlugins(rootDir, configs.find(({ name }) => name === 'web').config); diff --git a/packages/ice/src/commands/start.ts b/packages/ice/src/commands/start.ts index 37b9c40f3..dd26fb74b 100644 --- a/packages/ice/src/commands/start.ts +++ b/packages/ice/src/commands/start.ts @@ -1,3 +1,5 @@ +import { createRequire } from 'module'; +import * as path from 'path'; import WebpackDevServer from 'webpack-dev-server'; import type { Context } from 'build-scripts'; import { getWebpackConfig, getTransformPlugins } from '@builder/webpack-config'; @@ -6,6 +8,7 @@ import webpackCompiler from '../service/webpackCompiler.js'; import prepareURLs from '../utils/prepareURLs.js'; import type { Config } from '@ice/types'; +const require = createRequire(import.meta.url); const { defaultsDeep } = lodash; interface IWebTaskConfig { @@ -32,6 +35,13 @@ const start = async (context: Context) => { return; } const { config } = webConfig as IWebTaskConfig; + config.alias = { + ...config.alias, + // TODO: 放在各自插件里还是放在 ice 里? + // TODO: make pkg.json exports works; build 复用逻辑 + // '@ice/plugin-auth/runtime': require.resolve('@ice/plugin-auth/runtime'), + '@ice/plugin-auth/runtime': path.join(require.resolve('@ice/plugin-auth'), '../../runtime'), + }; // transform config to webpack config const webpackConfig = getWebpackConfig({ diff --git a/packages/ice/src/getBuiltInPlugins.ts b/packages/ice/src/getBuiltInPlugins.ts index e32c34f80..b312fe642 100644 --- a/packages/ice/src/getBuiltInPlugins.ts +++ b/packages/ice/src/getBuiltInPlugins.ts @@ -64,6 +64,7 @@ const getBuiltInPlugins: IGetBuiltInPlugins = (userConfig) => { // react base plugin require.resolve('@ice/plugin-app'), require.resolve('@ice/plugin-router'), + require.resolve('@ice/plugin-auth'), // for ice/react plugins /* 'build-plugin-ice-config', 'build-plugin-ice-mpa', diff --git a/packages/ice/template/entry.client.ts.ejs b/packages/ice/template/entry.client.ts.ejs new file mode 100644 index 000000000..eb7928791 --- /dev/null +++ b/packages/ice/template/entry.client.ts.ejs @@ -0,0 +1,6 @@ +import { runApp } from '@ice/runtime'; +import appConfig from '@/app'; +import runtimeModules from './runtimeModules'; +import routes from './routes'; + +runApp(appConfig, runtimeModules, routes); \ No newline at end of file diff --git a/packages/ice/template/entry.server.ts.ejs b/packages/ice/template/entry.server.ts.ejs new file mode 100644 index 000000000..338e9d868 --- /dev/null +++ b/packages/ice/template/entry.server.ts.ejs @@ -0,0 +1,8 @@ +import { runServerApp } from '@ice/runtime'; +import appConfig from '@/app'; +import runtimeModules from './runtimeModules'; +import routes from './routes'; + +export async function render() { + return await runServerApp(appConfig, runtimeModules, routes); +} \ No newline at end of file diff --git a/packages/ice/template/index.ts.ejs b/packages/ice/template/index.ts.ejs index 52df93a55..ab01f031f 100644 --- a/packages/ice/template/index.ts.ejs +++ b/packages/ice/template/index.ts.ejs @@ -4,5 +4,4 @@ export { <%- framework.exports %> } -<% } %> -export * from './runApp'; \ No newline at end of file +<% } %> \ No newline at end of file diff --git a/packages/ice/template/loadRuntimeModules.ts.ejs b/packages/ice/template/loadRuntimeModules.ts.ejs deleted file mode 100644 index 26df149b0..000000000 --- a/packages/ice/template/loadRuntimeModules.ts.ejs +++ /dev/null @@ -1,13 +0,0 @@ -<% const moduleNames = []; %> -<% if (runtimeModules.length) {%> - <% runtimeModules.filter((moduleInfo) => !moduleInfo.staticModule).forEach((runtimeModule, index) => { %> - <% moduleNames.push('module' + index) %>import module<%= index %> from '<%= runtimeModule.path %>';<% }) %><% } %> -import type { Runtime } from '@ice/runtime'; - -function loadRuntimeModules(runtime: Runtime) { - <% if (moduleNames.length) {%> - <% moduleNames.forEach((name) => { %>runtime.loadModule(<%= name%>);<% }) %> - <% } %> -} - -export default loadRuntimeModules; \ No newline at end of file diff --git a/packages/ice/template/loadStaticModules.ts.ejs b/packages/ice/template/loadStaticModules.ts.ejs deleted file mode 100644 index 36cfd5ed6..000000000 --- a/packages/ice/template/loadStaticModules.ts.ejs +++ /dev/null @@ -1,14 +0,0 @@ -<% const moduleNames = []; %> -<% if (runtimeModules.length) {%> - <% runtimeModules.filter((moduleInfo) => moduleInfo.staticModule).forEach((runtimeModule, index) => { %> - <% moduleNames.push('module' + index) %>import module<%= index %> from '<%= runtimeModule.path %>';<% }) %> -<% } %> -import type { AppConfig } from './types'; - -function loadStaticModules(appConfig: AppConfig) { - <% if (moduleNames.length) {%> - <% moduleNames.forEach((name) => { %><%= name%>({appConfig});<% }) %> - <% } %> -} - -export default loadStaticModules; diff --git a/packages/ice/template/runApp.tsx.ejs b/packages/ice/template/runApp.tsx.ejs deleted file mode 100644 index 61c54cc46..000000000 --- a/packages/ice/template/runApp.tsx.ejs +++ /dev/null @@ -1,40 +0,0 @@ -import * as React from 'react'; -import { Runtime, App, render } from '@ice/runtime'; -import type { BuildConfig } from '@ice/runtime'; -import loadStaticModules from './loadStaticModules'; -import loadRuntimeModules from './loadRuntimeModules'; -import type { AppConfig } from './types'; -import routes from './routes'; - -export function runApp(config: AppConfig = {}) { - const appConfig = { - ...config, - app: { - rootId: 'root', - strict: true, - ...(config?.app || {}), - }, - router: { - type: 'hash', - ...(config?.router || {}), - } - }; - loadStaticModules(appConfig); - // TODO generate buildConfig - const buildConfig: BuildConfig = { - ssr: false, - }; - // TODO create context - const context: Context = { - routes, - }; - - const runtime = new Runtime(appConfig, buildConfig, context); - - runtime.setRenderApp((args) => { - return ; - }); - - loadRuntimeModules(runtime); - render(runtime); -} \ No newline at end of file diff --git a/packages/ice/template/runtimeModules.ts.ejs b/packages/ice/template/runtimeModules.ts.ejs new file mode 100644 index 000000000..e03b5c13e --- /dev/null +++ b/packages/ice/template/runtimeModules.ts.ejs @@ -0,0 +1,14 @@ +<% const moduleNames = []; %> +<% if (runtimeModules.length) {%> + <% runtimeModules.filter((moduleInfo) => !moduleInfo.staticModule).forEach((runtimeModule, index) => { %> + <% moduleNames.push('module' + index) %>import module<%= index %> from '<%= runtimeModule.path %>'; + <% }) %> +<% } %> + +const modules = [ +<% moduleNames.forEach((moduleName, index) => { %> + <%= moduleName %>, +<% }) %> +]; + +export default modules; \ No newline at end of file diff --git a/packages/ice/template/server.ts b/packages/ice/template/server.ts deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/ice/template/types.ts.ejs b/packages/ice/template/types.ts.ejs index d6bf3f6b1..78e03c164 100644 --- a/packages/ice/template/types.ts.ejs +++ b/packages/ice/template/types.ts.ejs @@ -1,21 +1,15 @@ +import type { AppConfig as DefaultAppConfig } from '@ice/runtime'; + <%- configTypes.imports %> -export interface App { - rootId?: string; - mountNode?: HTMLElement; - renderComponent?: ComponentType; -} <% if (configTypes.imports) {%> -interface ExtendsAppConfig { +interface ExtendsAppConfig extends DefaultAppConfig { <% if (configTypes.imports) { %> <%- configTypes.exports %> <% } %> }; -export type AppConfig = Omit & { - app?: App & ('app' extends keyof ExtendsAppConfig ? ExtendsAppConfig['app'] : {}); -} + +export type AppConfig = ExtendsAppConfig; <% } else { %> -export interface AppConfig { - app?: App; -} +export type AppConfig = DefaultAppConfig; <% } %> \ No newline at end of file diff --git a/packages/plugin-auth/CHANGELOG.md b/packages/plugin-auth/CHANGELOG.md new file mode 100644 index 000000000..0b58a1a09 --- /dev/null +++ b/packages/plugin-auth/CHANGELOG.md @@ -0,0 +1,3 @@ +# Changelog + +## 1.0.0 \ No newline at end of file diff --git a/packages/plugin-auth/README.md b/packages/plugin-auth/README.md new file mode 100644 index 000000000..22796a97b --- /dev/null +++ b/packages/plugin-auth/README.md @@ -0,0 +1 @@ +# `plugin-auth` diff --git a/packages/plugin-auth/package.json b/packages/plugin-auth/package.json new file mode 100644 index 000000000..7aed28621 --- /dev/null +++ b/packages/plugin-auth/package.json @@ -0,0 +1,28 @@ +{ + "name": "@ice/plugin-auth", + "version": "1.0.0", + "description": "", + "license": "MIT", + "type": "module", + "main": "./esm/index.js", + "exports": { + ".": "./esm/index.js", + "./runtime": "./runtime" + }, + "files": [ + "esm", + "runtime", + "!esm/**/*.map" + ], + "dependencies": { + "@ice/types": "^1.0.0" + }, + "peerDependencies": { + "react": ">16.0.0", + "react-dom": ">16.0.0" + }, + "repository": { + "type": "http", + "url": "https://github.com/ice-lab/ice-next/tree/master/packages/plugin-auth" + } +} \ No newline at end of file diff --git a/packages/plugin-auth/runtime/Auth.tsx b/packages/plugin-auth/runtime/Auth.tsx new file mode 100644 index 000000000..0a6467274 --- /dev/null +++ b/packages/plugin-auth/runtime/Auth.tsx @@ -0,0 +1,44 @@ +import * as React from 'react'; +import { createContext, useState, useContext } from 'react'; +import type { FC } from 'react'; +import type { ContextType, AuthType } from './types'; + +const Context = createContext(null); + +interface ProviderProps { + value: AuthType; +} + +interface InjectProps { + auth: ContextType[0]; + useAuth: ContextType[1]; +} + +const AuthProvider: FC = ({ value = {}, children }) => { + const [state, setState] = useState(value); + const updateState: InjectProps['useAuth'] = (newState = {}) => { + setState({ + ...state, + ...newState, + }); + }; + return {children}; +}; + +const useAuth = (): ContextType => { + const value = useContext(Context); + return value; +}; + +// class 组件支持 Hoc 用法 +function withAuth(Component: React.ComponentType) { + type OriginalProps = Omit; + const AuthWrapped = (props: OriginalProps) => { + const [auth, setAuth] = useAuth(); + const WrappedComponent = Component as React.ComponentType; + return ; + }; + return AuthWrapped; +} + +export { useAuth, withAuth, AuthProvider }; \ No newline at end of file diff --git a/packages/plugin-auth/runtime/index.tsx b/packages/plugin-auth/runtime/index.tsx new file mode 100644 index 000000000..fa0d3f415 --- /dev/null +++ b/packages/plugin-auth/runtime/index.tsx @@ -0,0 +1,52 @@ +import * as React from 'react'; +import type { RuntimePlugin } from '@ice/types'; +import { AuthProvider, useAuth } from './Auth'; +import type { IAuth } from './types'; + +const wrapperComponentFn = (authConfig: IAuth) => (PageComponent) => { + const { pageConfig = {} } = PageComponent; + + const AuthWrappedComponent = (props) => { + const [auth] = useAuth(); + const pageConfigAuth = pageConfig.auth; + + if (pageConfigAuth && !Array.isArray(pageConfigAuth)) { + throw new Error('pageConfig.auth must be an array'); + } + + const hasAuth = + Array.isArray(pageConfigAuth) && pageConfigAuth.length + ? Object.keys(auth).filter((item) => + (pageConfigAuth.includes(item) ? auth[item] : false), + ).length + : true; + + if (!hasAuth) { + if (authConfig.NoAuthFallback) { + if (typeof authConfig.NoAuthFallback === 'function') { + return ; + } + return authConfig.NoAuthFallback; + } + return <>No Auth; + } + return ; + }; + return AuthWrappedComponent; +}; + +const runtime: RuntimePlugin = ({ context, appConfig, addProvider, wrapperPageComponent }) => { + const initialData = context && context.initialData ? context.initialData : {}; + const initialAuth = initialData.auth || {}; + const authConfig = appConfig.auth || {}; + + // TODO: React Devtools 里多一层 + const AuthStoreProvider = ({ children }) => { + return {children}; + }; + + addProvider(AuthStoreProvider); + wrapperPageComponent(wrapperComponentFn(authConfig)); +}; + +export default runtime; \ No newline at end of file diff --git a/packages/plugin-auth/runtime/types.ts b/packages/plugin-auth/runtime/types.ts new file mode 100644 index 000000000..04e1830c0 --- /dev/null +++ b/packages/plugin-auth/runtime/types.ts @@ -0,0 +1,6 @@ +export interface IAuth { + NoAuthFallback?: React.ReactNode; +} + +export type AuthType = Record; +export type ContextType = [AuthType, React.Dispatch>]; \ No newline at end of file diff --git a/packages/plugin-auth/src/index.ts b/packages/plugin-auth/src/index.ts new file mode 100644 index 000000000..47f64b294 --- /dev/null +++ b/packages/plugin-auth/src/index.ts @@ -0,0 +1,24 @@ +import type { Plugin } from '@ice/types'; + +const plugin: Plugin = ({ generator }) => { + // 注册 API:import { useAuth, withAuth } from 'ice'; + generator.addExport({ + specifier: ['withAuth', 'useAuth'], + source: '@ice/plugin-auth/runtime/Auth', + }); + + // 注册类型:appConfig.auth + // export interface IAppConfig { + // auth?: IAuth; + // } + generator.addConfigTypes({ + specifier: ['IAuth'], + source: '@ice/plugin-auth/runtime/types', + type: true, + exportAlias: { + IAuth: 'auth?', + }, + }); +}; + +export default plugin; \ No newline at end of file diff --git a/packages/plugin-auth/tsconfig.json b/packages/plugin-auth/tsconfig.json new file mode 100644 index 000000000..972f3542f --- /dev/null +++ b/packages/plugin-auth/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "baseUrl": "./", + "rootDir": "src", + "outDir": "esm", + "jsx": "react" + }, + "include": ["src"] +} \ No newline at end of file diff --git a/packages/plugin-router/runtime/index.tsx b/packages/plugin-router/runtime/index.tsx index fa9ae32dc..fb6aa8f1a 100644 --- a/packages/plugin-router/runtime/index.tsx +++ b/packages/plugin-router/runtime/index.tsx @@ -5,6 +5,7 @@ const runtime: RuntimePlugin = ({ setRenderApp }) => { // setRenderApp(({ renderComponent }) => { // return renderComponent || (() => <>empty content); // }); + }; export default runtime; diff --git a/packages/runtime/src/AppRouter.tsx b/packages/runtime/src/AppRouter.tsx index 55b81cacd..736f83689 100644 --- a/packages/runtime/src/AppRouter.tsx +++ b/packages/runtime/src/AppRouter.tsx @@ -21,14 +21,14 @@ export default function AppRouter(props: RenderOptions) { { routes.map((route, index) => { - const RouteComponent = route.component; + const PageComponent = route.component; return ( loading chunk....}> - + } /> diff --git a/packages/runtime/src/RouteItem.tsx b/packages/runtime/src/RouteItem.tsx new file mode 100644 index 000000000..431ff11e4 --- /dev/null +++ b/packages/runtime/src/RouteItem.tsx @@ -0,0 +1,33 @@ +import * as React from 'react'; +import type { Context } from './types'; + +interface Props { + context: Context; + // pageWrappers: React.ComponentType[]; + PageComponent: React.ComponentType; +} + +export default function RouteItem(props: Props) { + const { context, PageComponent } = props; + // const Wrapper = pageWrappers[0]; + + return ( + loading chunk....}> + {/* { + (pageWrappers || []).reduce((Prev, Curr) => { + // const compose = curr(acc); + // if (acc.pageConfig) { + // compose.pageConfig = acc.pageConfig; + // } + // if (acc.getInitialProps) { + // compose.getInitialProps = acc.getInitialProps; + // } + return ; + }, PageComponent) + } */} + {/* */} + + {/* */} + + ); +} diff --git a/packages/runtime/src/index.ts b/packages/runtime/src/index.ts index cf855dc19..9282f3c37 100644 --- a/packages/runtime/src/index.ts +++ b/packages/runtime/src/index.ts @@ -1,19 +1,24 @@ import Runtime from './runtime.js'; import App from './App.js'; import render from './render.js'; +import runApp from './runApp.js'; +import runServerApp from './runServerApp.js'; import { RuntimePlugin, Context, BuildConfig, + AppConfig, } from './types.js'; export { Runtime, App, render, - + runApp, + runServerApp, // types RuntimePlugin, BuildConfig, Context, + AppConfig, }; \ No newline at end of file diff --git a/packages/runtime/src/runApp.tsx b/packages/runtime/src/runApp.tsx new file mode 100644 index 000000000..adbf509a3 --- /dev/null +++ b/packages/runtime/src/runApp.tsx @@ -0,0 +1,60 @@ + +import * as React from 'react'; +import Runtime from './runtime.js'; +import App from './App.js'; +import render from './render.js'; +import type { BuildConfig, Context, InitialContext, AppConfig } from './types'; + +export default async function runApp(config: AppConfig, runtimeModules, routes) { + const appConfig: AppConfig = { + ...config, + app: { + rootId: 'root', + strict: true, + ...(config?.app || {}), + }, + router: { + type: 'hash', + ...(config?.router || {}), + }, + }; + + // loadStaticModules(appConfig); + + // TODO generate buildConfig + const buildConfig: BuildConfig = {}; + + const context: Context = { + routes, + }; + + // ssr enabled and the server has returned data + if ((window as any).__ICE_APP_DATA__) { + context.initialData = (window as any).__ICE_APP_DATA__; + // context.pageInitialProps = (window as any).__ICE_PAGE_PROPS__; + } else if (appConfig?.app?.getInitialData) { + const { href, origin, pathname, search } = window.location; + const path = href.replace(origin, ''); + // const query = queryString.parse(search); + const query = {}; + const ssrError = (window as any).__ICE_SSR_ERROR__; + const initialContext: InitialContext = { + pathname, + path, + query, + ssrError, + }; + context.initialData = await appConfig.app.getInitialData(initialContext); + } + + const runtime = new Runtime(appConfig, buildConfig, context); + runtime.setRenderApp((args) => { + return ; + }); + + runtimeModules.forEach(m => { + runtime.loadModule(m); + }); + + render(runtime); +} \ No newline at end of file diff --git a/packages/runtime/src/runServerApp.tsx b/packages/runtime/src/runServerApp.tsx new file mode 100644 index 000000000..24bea8458 --- /dev/null +++ b/packages/runtime/src/runServerApp.tsx @@ -0,0 +1,4 @@ + +export default async function runServerApp(appConfig, runtimeModules, routes) { + +} \ No newline at end of file diff --git a/packages/runtime/src/types.ts b/packages/runtime/src/types.ts index d3d5e84fe..ab399960c 100644 --- a/packages/runtime/src/types.ts +++ b/packages/runtime/src/types.ts @@ -1,20 +1,19 @@ -import type { ComponentType } from 'react'; -import { RouterProps } from 'react-router-dom'; +import type { ComponentType, ReactNode } from 'react'; type VoidFunction = () => void; type AppLifecycle = 'onShow' | 'onHide' | 'onPageNotFound' | 'onShareAppMessage' | 'onUnhandledRejection' | 'onLaunch' | 'onError' | 'onTabItemClick'; type App = Partial<{ - rootId: string; - strict: boolean; + rootId?: string; + strict?: boolean; + addProvider?: ({ children }: { children: ReactNode }) => ReactNode; + getInitialData?: (ctx?: any) => Promise; } & Record>; -interface Router { - type: 'hash' | 'browser'; - basename: string; -} - export interface AppConfig extends Record { - app: App; - router: Router; + app?: App; + router?: { + type: 'hash' | 'browser'; + basename?: string; + }; } // simplify page item type while it has been defined in plugin-router export interface DOMRender { @@ -47,10 +46,17 @@ export interface BuildConfig extends Record { target?: string[]; } +// getInitialData: (ctx: InitialContext) => {} +export interface InitialContext { + pathname: string; + path: string; + query: Record; + ssrError?: any; +} + export interface Context { appManifest?: Record; routes?: Routes; - initialContext?: Record; initialData?: any; } export interface RuntimeAPI { diff --git a/packages/types/src/generator.ts b/packages/types/src/generator.ts index 784263f7d..2f2484a76 100644 --- a/packages/types/src/generator.ts +++ b/packages/types/src/generator.ts @@ -29,7 +29,7 @@ export type ParseRenderData = () => Record; export type GenerateImportStr = (apiName: string) => string; export type Render = () => void; export type ModifyRenderData = (registration: RenderDataRegistration) => void; -export type AddRenderFile = (templatePath: string, targetPath: string, extraData: ExtraData) => void; +export type AddRenderFile = (templatePath: string, targetPath: string, extraData?: ExtraData) => void; export type AddTemplateFiles = (templateOptions: string | TemplateOptions, extraData?: ExtraData) => void; export type RenderFile = (templatePath: string, targetDir: string, extraData?: ExtraData) => void; export type AddDisableRuntimePlugin = (pluginName: string) => void; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 469152b4d..a825ac189 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -109,6 +109,7 @@ importers: '@builder/pack': ^0.6.0 '@builder/webpack-config': ^3.0.0 '@ice/plugin-app': ^1.0.0 + '@ice/plugin-auth': workspace:^1.0.0 '@ice/plugin-router': ^1.0.0 '@ice/runtime': ^1.0.0 '@ice/types': ^1.0.0 @@ -134,6 +135,7 @@ importers: '@builder/pack': 0.6.0 '@builder/webpack-config': link:../build-webpack-config '@ice/plugin-app': link:../plugin-app + '@ice/plugin-auth': link:../plugin-auth '@ice/plugin-router': link:../plugin-router '@ice/runtime': link:../runtime address: 1.1.2 @@ -176,6 +178,12 @@ importers: '@types/react': 17.0.39 '@types/react-dom': 17.0.11 + packages/plugin-auth: + specifiers: + '@ice/types': workspace:^1.0.0 + dependencies: + '@ice/types': link:../types + packages/plugin-router: specifiers: '@ice/types': ^1.0.0 diff --git a/tsconfig.json b/tsconfig.json index 066b94e7c..0d24dded6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,6 +6,7 @@ { "path": "packages/build-webpack-config" }, { "path": "packages/plugin-app"}, { "path": "packages/ice" }, - { "path": "packages/plugin-router" } + { "path": "packages/plugin-router" }, + { "path": "packages/plugin-auth" } ] }