fix: workflow executions not show and format codes (#1184)
Co-authored-by: sealday <sealday@gmail.com> Reviewed-on: daoyoucloud/tachybase#1184
This commit is contained in:
		
							parent
							
								
									64741b1726
								
							
						
					
					
						commit
						d99bd8f4a5
					
				| @ -1,5 +1,6 @@ | |||||||
| import { getUmiConfig, IndexGenerator } from '@tachybase/devtools/umiConfig'; |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
|  | import { getUmiConfig, IndexGenerator } from '@tachybase/devtools/umiConfig'; | ||||||
|  | 
 | ||||||
| import { defineConfig } from 'umi'; | import { defineConfig } from 'umi'; | ||||||
| 
 | 
 | ||||||
| const umiConfig = getUmiConfig(); | const umiConfig = getUmiConfig(); | ||||||
| @ -10,7 +11,8 @@ process.env.DID_YOU_KNOW = 'none'; | |||||||
| const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '').split(',').filter((item) => !item.includes('preset')); // 因为现在 preset 是直接引入的,所以不能忽略,如果以后 preset 也是动态插件的形式引入,那么这里可以去掉
 | const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '').split(',').filter((item) => !item.includes('preset')); // 因为现在 preset 是直接引入的,所以不能忽略,如果以后 preset 也是动态插件的形式引入,那么这里可以去掉
 | ||||||
| 
 | 
 | ||||||
| const pluginDirs = (process.env.PLUGIN_PATH || 'packages/plugins/,packages/samples/,packages/pro-plugins/') | const pluginDirs = (process.env.PLUGIN_PATH || 'packages/plugins/,packages/samples/,packages/pro-plugins/') | ||||||
|   .split(',').map(item => path.join(process.cwd(), item)); |   .split(',') | ||||||
|  |   .map((item) => path.join(process.cwd(), item)); | ||||||
| 
 | 
 | ||||||
| const outputPluginPath = path.join(__dirname, 'src', '.plugins'); | const outputPluginPath = path.join(__dirname, 'src', '.plugins'); | ||||||
| const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs); | const indexGenerator = new IndexGenerator(outputPluginPath, pluginDirs); | ||||||
| @ -36,7 +38,9 @@ export default defineConfig({ | |||||||
|       src: `${appPublicPath}browser-checker.js`, |       src: `${appPublicPath}browser-checker.js`, | ||||||
|     }, |     }, | ||||||
|     { |     { | ||||||
|       content: isDevCmd ? '' : ` |       content: isDevCmd | ||||||
|  |         ? '' | ||||||
|  |         : ` | ||||||
|         window['__webpack_public_path__'] = '{{env.APP_PUBLIC_PATH}}'; |         window['__webpack_public_path__'] = '{{env.APP_PUBLIC_PATH}}'; | ||||||
|         window['__tachybase_public_path__'] = '{{env.APP_PUBLIC_PATH}}'; |         window['__tachybase_public_path__'] = '{{env.APP_PUBLIC_PATH}}'; | ||||||
|         window['__tachybase_api_base_url__'] = '{{env.API_BASE_URL}}'; |         window['__tachybase_api_base_url__'] = '{{env.API_BASE_URL}}'; | ||||||
| @ -71,7 +75,7 @@ export default defineConfig({ | |||||||
|     safari: 12, |     safari: 12, | ||||||
|   }, |   }, | ||||||
|   codeSplitting: { |   codeSplitting: { | ||||||
|     jsStrategy: 'depPerChunk' |     jsStrategy: 'depPerChunk', | ||||||
|   }, |   }, | ||||||
|   chainWebpack(config, { env }) { |   chainWebpack(config, { env }) { | ||||||
|     if (env === 'production') { |     if (env === 'production') { | ||||||
|  | |||||||
| @ -68,7 +68,9 @@ function css_browser_selector(u) { | |||||||
|                       (/Version\/(\d+)(\.(\d+))+/i.test(ua) |                       (/Version\/(\d+)(\.(\d+))+/i.test(ua) | ||||||
|                         ? ' ' + a + RegExp.$1 + ' ' + a + RegExp.$1 + RegExp.$2.replace('.', '_') |                         ? ' ' + a + RegExp.$1 + ' ' + a + RegExp.$1 + RegExp.$2.replace('.', '_') | ||||||
|                         : '') + |                         : '') + | ||||||
|           (/Android (.+); (.+) Build/i.test(ua) ? ' ' + dv + RegExp.$2.replace(/ /g, '_').replace(/-/g, '_') : '') |                       (/Android (.+); (.+) Build/i.test(ua) | ||||||
|  |                         ? ' ' + dv + RegExp.$2.replace(/ /g, '_').replace(/-/g, '_') | ||||||
|  |                         : '') | ||||||
|                     : is('chrome') |                     : is('chrome') | ||||||
|                       ? w + |                       ? w + | ||||||
|                         ' ' + |                         ' ' + | ||||||
| @ -113,7 +115,9 @@ function css_browser_selector(u) { | |||||||
|                 ? 'playbook' |                 ? 'playbook' | ||||||
|                 : is('mac') |                 : is('mac') | ||||||
|                   ? 'mac' + |                   ? 'mac' + | ||||||
|           (/mac os x ((\d+)[.|_](\d+))/.test(ua) ? ' mac' + RegExp.$2 + ' mac' + RegExp.$1.replace('.', '_') : '') |                     (/mac os x ((\d+)[.|_](\d+))/.test(ua) | ||||||
|  |                       ? ' mac' + RegExp.$2 + ' mac' + RegExp.$1.replace('.', '_') | ||||||
|  |                       : '') | ||||||
|                   : is('win') |                   : is('win') | ||||||
|                     ? 'win' + |                     ? 'win' + | ||||||
|                       (is('windows nt 6.2') |                       (is('windows nt 6.2') | ||||||
|  | |||||||
| @ -1 +1,11 @@ | |||||||
| {"name":"","short_name":"","icons":[{"src":"./android-chrome-192x192.png","sizes":"192x192","type":"image/png"},{"src":"/android-chrome-512x512.png","sizes":"512x512","type":"image/png"}],"theme_color":"#ffffff","background_color":"#ffffff","display":"standalone"} | { | ||||||
|  |   "name": "", | ||||||
|  |   "short_name": "", | ||||||
|  |   "icons": [ | ||||||
|  |     { "src": "./android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }, | ||||||
|  |     { "src": "/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" } | ||||||
|  |   ], | ||||||
|  |   "theme_color": "#ffffff", | ||||||
|  |   "background_color": "#ffffff", | ||||||
|  |   "display": "standalone" | ||||||
|  | } | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import { PluginConfiguration } from '@tachybase/server'; |  | ||||||
| import process from 'process'; | import process from 'process'; | ||||||
|  | import { PluginConfiguration } from '@tachybase/server'; | ||||||
| 
 | 
 | ||||||
| export default [process.env.PRESET_NAME ?? 'tachybase'] as PluginConfiguration[]; | export default [process.env.PRESET_NAME ?? 'tachybase'] as PluginConfiguration[]; | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { Gateway } from '@tachybase/server'; | import { Gateway } from '@tachybase/server'; | ||||||
|  | 
 | ||||||
| import { getConfig } from './config'; | import { getConfig } from './config'; | ||||||
| 
 | 
 | ||||||
| getConfig() | getConfig() | ||||||
|  | |||||||
| @ -1,26 +1,39 @@ | |||||||
| import { EventEmitter } from 'events'; | import { EventEmitter } from 'events'; | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| import type { Project } from '@pnpm/workspace.find-packages'; | import type { Project } from '@pnpm/workspace.find-packages'; | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import execa from 'execa'; | import execa from 'execa'; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| import { buildCjs } from './buildCjs'; | import { buildCjs } from './buildCjs'; | ||||||
| import { buildClient } from './buildClient'; | import { buildClient } from './buildClient'; | ||||||
| import { buildDeclaration } from './buildDeclaration'; | import { buildDeclaration } from './buildDeclaration'; | ||||||
| import { buildEsm } from './buildEsm'; | import { buildEsm } from './buildEsm'; | ||||||
| import { buildPlugin } from './buildPlugin'; | import { buildPlugin } from './buildPlugin'; | ||||||
| import { CORE_APP, CORE_CLIENT, ESM_PACKAGES, getCjsPackages, getPluginPackages, getPresetsPackages, PACKAGES_PATH, ROOT_PATH } from './constant'; | import { | ||||||
|  |   CORE_APP, | ||||||
|  |   CORE_CLIENT, | ||||||
|  |   ESM_PACKAGES, | ||||||
|  |   getCjsPackages, | ||||||
|  |   getPluginPackages, | ||||||
|  |   getPresetsPackages, | ||||||
|  |   PACKAGES_PATH, | ||||||
|  |   ROOT_PATH, | ||||||
|  | } from './constant'; | ||||||
| import { signals } from './stats'; | import { signals } from './stats'; | ||||||
| import { tarPlugin } from './tarPlugin'; | import { tarPlugin } from './tarPlugin'; | ||||||
| import { getPackageJson, getPkgLog, getUserConfig, PkgLog, readFromCache, toUnixPath, UserConfig, writeToCache } from './utils'; | import { | ||||||
|  |   getPackageJson, | ||||||
|  |   getPkgLog, | ||||||
|  |   getUserConfig, | ||||||
|  |   PkgLog, | ||||||
|  |   readFromCache, | ||||||
|  |   toUnixPath, | ||||||
|  |   UserConfig, | ||||||
|  |   writeToCache, | ||||||
|  | } from './utils'; | ||||||
| import { getPackages } from './utils/getPackages'; | import { getPackages } from './utils/getPackages'; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| const BUILD_ERROR = 'build-error'; | const BUILD_ERROR = 'build-error'; | ||||||
| 
 | 
 | ||||||
| export async function build(pkgs: string[]) { | export async function build(pkgs: string[]) { | ||||||
|  | |||||||
| @ -1,8 +1,10 @@ | |||||||
| import { build } from 'tsup'; |  | ||||||
| import fg from 'fast-glob'; |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
|  | 
 | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import { globExcludeFiles, EsbuildSupportExts } from './constant'; | import fg from 'fast-glob'; | ||||||
|  | import { build } from 'tsup'; | ||||||
|  | 
 | ||||||
|  | import { EsbuildSupportExts, globExcludeFiles } from './constant'; | ||||||
| import { PkgLog, UserConfig } from './utils'; | import { PkgLog, UserConfig } from './utils'; | ||||||
| 
 | 
 | ||||||
| export function buildCjs(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { | export function buildCjs(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { | ||||||
| @ -10,11 +12,14 @@ export function buildCjs(cwd: string, userConfig: UserConfig, sourcemap: boolean | |||||||
| 
 | 
 | ||||||
|   const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd, absolute: true }); |   const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd, absolute: true }); | ||||||
|   const outDir = path.join(cwd, 'lib'); |   const outDir = path.join(cwd, 'lib'); | ||||||
|   const otherExts = Array.from(new Set(entry.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item)))); |   const otherExts = Array.from( | ||||||
|  |     new Set(entry.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item))), | ||||||
|  |   ); | ||||||
|   if (otherExts.length) { |   if (otherExts.length) { | ||||||
|     log('%s will not be processed, only be copied to the lib directory.', chalk.yellow(otherExts.join(','))); |     log('%s will not be processed, only be copied to the lib directory.', chalk.yellow(otherExts.join(','))); | ||||||
|   } |   } | ||||||
|   return build(userConfig.modifyTsupConfig({ |   return build( | ||||||
|  |     userConfig.modifyTsupConfig({ | ||||||
|       entry, |       entry, | ||||||
|       splitting: false, |       splitting: false, | ||||||
|       clean: true, |       clean: true, | ||||||
| @ -31,5 +36,6 @@ export function buildCjs(cwd: string, userConfig: UserConfig, sourcemap: boolean | |||||||
|       }, |       }, | ||||||
|       format: 'cjs', |       format: 'cjs', | ||||||
|       skipNodeModulesBundle: true, |       skipNodeModulesBundle: true, | ||||||
|   })); |     }), | ||||||
|  |   ); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,7 +1,8 @@ | |||||||
|  | import path from 'path'; | ||||||
|  | 
 | ||||||
| import react from '@vitejs/plugin-react'; | import react from '@vitejs/plugin-react'; | ||||||
| import fg from 'fast-glob'; | import fg from 'fast-glob'; | ||||||
| import fs from 'fs-extra'; | import fs from 'fs-extra'; | ||||||
| import path from 'path'; |  | ||||||
| import { build as tsupBuild } from 'tsup'; | import { build as tsupBuild } from 'tsup'; | ||||||
| import { build as viteBuild } from 'vite'; | import { build as viteBuild } from 'vite'; | ||||||
| import { libInjectCss } from 'vite-plugin-lib-inject-css'; | import { libInjectCss } from 'vite-plugin-lib-inject-css'; | ||||||
|  | |||||||
| @ -1,8 +1,9 @@ | |||||||
| 
 |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import { PkgLog, UserConfig } from './utils'; | 
 | ||||||
| import { build as viteBuild } from 'vite'; |  | ||||||
| import fg from 'fast-glob'; | import fg from 'fast-glob'; | ||||||
|  | import { build as viteBuild } from 'vite'; | ||||||
|  | 
 | ||||||
|  | import { PkgLog, UserConfig } from './utils'; | ||||||
| 
 | 
 | ||||||
| export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { | export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { | ||||||
|   log('build esm'); |   log('build esm'); | ||||||
| @ -12,7 +13,9 @@ export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: b | |||||||
| 
 | 
 | ||||||
|   await build(cwd, indexEntry, outDir, userConfig, sourcemap, log); |   await build(cwd, indexEntry, outDir, userConfig, sourcemap, log); | ||||||
| 
 | 
 | ||||||
|   const clientEntry = fg.sync(['src/client/index.ts', 'src/client.ts'], { cwd, absolute: true, onlyFiles: true })?.[0]?.replaceAll(/\\/g, '/'); |   const clientEntry = fg | ||||||
|  |     .sync(['src/client/index.ts', 'src/client.ts'], { cwd, absolute: true, onlyFiles: true })?.[0] | ||||||
|  |     ?.replaceAll(/\\/g, '/'); | ||||||
|   const clientOutDir = path.resolve(cwd, 'es/client'); |   const clientOutDir = path.resolve(cwd, 'es/client'); | ||||||
|   if (clientEntry) { |   if (clientEntry) { | ||||||
|     await build(cwd, clientEntry, clientOutDir, userConfig, sourcemap, log); |     await build(cwd, clientEntry, clientOutDir, userConfig, sourcemap, log); | ||||||
| @ -26,7 +29,14 @@ export async function buildEsm(cwd: string, userConfig: UserConfig, sourcemap: b | |||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function build(cwd: string, entry: string, outDir: string, userConfig: UserConfig, sourcemap: boolean = false, log: PkgLog) { | function build( | ||||||
|  |   cwd: string, | ||||||
|  |   entry: string, | ||||||
|  |   outDir: string, | ||||||
|  |   userConfig: UserConfig, | ||||||
|  |   sourcemap: boolean = false, | ||||||
|  |   log: PkgLog, | ||||||
|  | ) { | ||||||
|   const cwdWin = cwd.replaceAll(/\\/g, '/'); |   const cwdWin = cwd.replaceAll(/\\/g, '/'); | ||||||
|   const cwdUnix = cwd.replaceAll(/\//g, '\\'); |   const cwdUnix = cwd.replaceAll(/\//g, '\\'); | ||||||
|   const external = function (id: string) { |   const external = function (id: string) { | ||||||
|  | |||||||
| @ -1,15 +1,16 @@ | |||||||
|  | import path from 'path'; | ||||||
|  | 
 | ||||||
| import ncc from '@vercel/ncc'; | import ncc from '@vercel/ncc'; | ||||||
| import react from '@vitejs/plugin-react'; | import react from '@vitejs/plugin-react'; | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import fg from 'fast-glob'; | import fg from 'fast-glob'; | ||||||
| import fs from 'fs-extra'; | import fs from 'fs-extra'; | ||||||
| import path from 'path'; |  | ||||||
| import { build as tsupBuild } from 'tsup'; | import { build as tsupBuild } from 'tsup'; | ||||||
| import { build as viteBuild } from 'vite'; | import { build as viteBuild } from 'vite'; | ||||||
| import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'; | import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'; | ||||||
| 
 | 
 | ||||||
| import { EsbuildSupportExts, globExcludeFiles } from './constant'; | import { EsbuildSupportExts, globExcludeFiles } from './constant'; | ||||||
| import { PkgLog, UserConfig, getPackageJson } from './utils'; | import { getPackageJson, PkgLog, UserConfig } from './utils'; | ||||||
| import { | import { | ||||||
|   buildCheck, |   buildCheck, | ||||||
|   checkFileSize, |   checkFileSize, | ||||||
| @ -123,9 +124,9 @@ const external = [ | |||||||
|   'lodash', |   'lodash', | ||||||
|   'china-division', |   'china-division', | ||||||
| ]; | ]; | ||||||
| const pluginPrefix = ( | const pluginPrefix = (process.env.PLUGIN_PACKAGE_PREFIX || '@tachybase/plugin-,@tachybase/preset-,@hera/plugin-').split( | ||||||
|   process.env.PLUGIN_PACKAGE_PREFIX || '@tachybase/plugin-,@tachybase/preset-,@hera/plugin-' |   ',', | ||||||
| ).split(','); | ); | ||||||
| 
 | 
 | ||||||
| const target_dir = 'dist'; | const target_dir = 'dist'; | ||||||
| 
 | 
 | ||||||
| @ -150,7 +151,9 @@ export function deleteServerFiles(cwd: string, log: PkgLog) { | |||||||
| 
 | 
 | ||||||
| export function writeExternalPackageVersion(cwd: string, log: PkgLog) { | export function writeExternalPackageVersion(cwd: string, log: PkgLog) { | ||||||
|   log('write external version'); |   log('write external version'); | ||||||
|   const sourceFiles = fg.globSync(sourceGlobalFiles, { cwd, absolute: true }).map((item) => fs.readFileSync(item, 'utf-8')); |   const sourceFiles = fg | ||||||
|  |     .globSync(sourceGlobalFiles, { cwd, absolute: true }) | ||||||
|  |     .map((item) => fs.readFileSync(item, 'utf-8')); | ||||||
|   const sourcePackages = getSourcePackages(sourceFiles); |   const sourcePackages = getSourcePackages(sourceFiles); | ||||||
|   const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix); |   const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix); | ||||||
|   const data = excludePackages.reduce<Record<string, string>>((prev, packageName) => { |   const data = excludePackages.reduce<Record<string, string>>((prev, packageName) => { | ||||||
| @ -171,7 +174,9 @@ export function writeExternalPackageVersion(cwd: string, log: PkgLog) { | |||||||
| export async function buildServerDeps(cwd: string, serverFiles: string[], log: PkgLog) { | export async function buildServerDeps(cwd: string, serverFiles: string[], log: PkgLog) { | ||||||
|   log('build plugin server dependencies'); |   log('build plugin server dependencies'); | ||||||
|   const outDir = path.join(cwd, target_dir, 'node_modules'); |   const outDir = path.join(cwd, target_dir, 'node_modules'); | ||||||
|   const serverFileSource = serverFiles.filter(item => validExts.includes(path.extname(item))).map((item) => fs.readFileSync(item, 'utf-8')); |   const serverFileSource = serverFiles | ||||||
|  |     .filter((item) => validExts.includes(path.extname(item))) | ||||||
|  |     .map((item) => fs.readFileSync(item, 'utf-8')); | ||||||
|   const sourcePackages = getSourcePackages(serverFileSource); |   const sourcePackages = getSourcePackages(serverFileSource); | ||||||
|   const includePackages = getIncludePackages(sourcePackages, external, pluginPrefix); |   const includePackages = getIncludePackages(sourcePackages, external, pluginPrefix); | ||||||
|   const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix); |   const excludePackages = getExcludePackages(sourcePackages, external, pluginPrefix); | ||||||
| @ -265,14 +270,17 @@ export async function buildPluginServer(cwd: string, userConfig: UserConfig, sou | |||||||
|   const packageJson = getPackageJson(cwd); |   const packageJson = getPackageJson(cwd); | ||||||
|   const serverFiles = fg.globSync(serverGlobalFiles, { cwd, absolute: true }); |   const serverFiles = fg.globSync(serverGlobalFiles, { cwd, absolute: true }); | ||||||
|   buildCheck({ cwd, packageJson, entry: 'server', files: serverFiles, log }); |   buildCheck({ cwd, packageJson, entry: 'server', files: serverFiles, log }); | ||||||
|   const otherExts = Array.from(new Set(serverFiles.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item)))); |   const otherExts = Array.from( | ||||||
|  |     new Set(serverFiles.map((item) => path.extname(item)).filter((item) => !EsbuildSupportExts.includes(item))), | ||||||
|  |   ); | ||||||
|   if (otherExts.length) { |   if (otherExts.length) { | ||||||
|     log('%s will not be processed, only be copied to the dist directory.', chalk.yellow(otherExts.join(','))); |     log('%s will not be processed, only be copied to the dist directory.', chalk.yellow(otherExts.join(','))); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   deleteServerFiles(cwd, log); |   deleteServerFiles(cwd, log); | ||||||
| 
 | 
 | ||||||
|   await tsupBuild(userConfig.modifyTsupConfig({ |   await tsupBuild( | ||||||
|  |     userConfig.modifyTsupConfig({ | ||||||
|       entry: serverFiles, |       entry: serverFiles, | ||||||
|       splitting: false, |       splitting: false, | ||||||
|       clean: false, |       clean: false, | ||||||
| @ -288,7 +296,8 @@ export async function buildPluginServer(cwd: string, userConfig: UserConfig, sou | |||||||
|         ...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: 'copy' }), {}), |         ...otherExts.reduce((prev, cur) => ({ ...prev, [cur]: 'copy' }), {}), | ||||||
|         '.json': 'copy', |         '.json': 'copy', | ||||||
|       }, |       }, | ||||||
|   })); |     }), | ||||||
|  |   ); | ||||||
| 
 | 
 | ||||||
|   await buildServerDeps(cwd, serverFiles, log); |   await buildServerDeps(cwd, serverFiles, log); | ||||||
| } | } | ||||||
| @ -316,7 +325,8 @@ export async function buildPluginClient(cwd: string, userConfig: UserConfig, sou | |||||||
|   const entry = fg.globSync('src/client/index.{ts,tsx,js,jsx}', { absolute: true, cwd }); |   const entry = fg.globSync('src/client/index.{ts,tsx,js,jsx}', { absolute: true, cwd }); | ||||||
|   const outputFileName = 'index.js'; |   const outputFileName = 'index.js'; | ||||||
| 
 | 
 | ||||||
|   await viteBuild(userConfig.modifyViteConfig({ |   await viteBuild( | ||||||
|  |     userConfig.modifyViteConfig({ | ||||||
|       mode: process.env.NODE_ENV || 'production', |       mode: process.env.NODE_ENV || 'production', | ||||||
|       define: { |       define: { | ||||||
|         'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'), |         'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'), | ||||||
| @ -350,11 +360,9 @@ export async function buildPluginClient(cwd: string, userConfig: UserConfig, sou | |||||||
|           }, |           }, | ||||||
|         }, |         }, | ||||||
|       }, |       }, | ||||||
|     plugins: [ |       plugins: [react(), cssInjectedByJsPlugin({ styleId: packageJson.name })], | ||||||
|       react(), |     }), | ||||||
|       cssInjectedByJsPlugin({ styleId: packageJson.name }), |   ); | ||||||
|     ], |  | ||||||
|   })); |  | ||||||
| 
 | 
 | ||||||
|   checkFileSize(outDir, log); |   checkFileSize(outDir, log); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import type { Project } from '@pnpm/workspace.find-packages'; |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| 
 | 
 | ||||||
|  | import type { Project } from '@pnpm/workspace.find-packages'; | ||||||
|  | 
 | ||||||
| export const globExcludeFiles = [ | export const globExcludeFiles = [ | ||||||
|   '!src/**/__tests__', |   '!src/**/__tests__', | ||||||
|   '!src/**/__test__', |   '!src/**/__test__', | ||||||
|  | |||||||
							
								
								
									
										5
									
								
								packages/core/build/src/index.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5
									
								
								packages/core/build/src/index.d.ts
									
									
									
									
										vendored
									
									
								
							| @ -1,6 +1,5 @@ | |||||||
| 
 | import { Options as TsupConfig } from 'tsup'; | ||||||
| import { Options as TsupConfig } from 'tsup' | import { InlineConfig as ViteConfig } from 'vite'; | ||||||
| import { InlineConfig as ViteConfig } from 'vite' |  | ||||||
| 
 | 
 | ||||||
| export type PkgLog = (msg: string, ...args: any[]) => void; | export type PkgLog = (msg: string, ...args: any[]) => void; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,2 +1,2 @@ | |||||||
| export * from './build'; | export * from './build'; | ||||||
| export * from './utils' | export * from './utils'; | ||||||
|  | |||||||
| @ -1,10 +1,11 @@ | |||||||
| import path from 'path'; | import path from 'path'; | ||||||
| import tar from 'tar'; | 
 | ||||||
| import fg from 'fast-glob'; | import fg from 'fast-glob'; | ||||||
| import fs from 'fs-extra'; | import fs from 'fs-extra'; | ||||||
|  | import tar from 'tar'; | ||||||
| 
 | 
 | ||||||
| import { PkgLog } from "./utils"; | import { TAR_OUTPUT_DIR, tarIncludesFiles } from './constant'; | ||||||
| import { TAR_OUTPUT_DIR, tarIncludesFiles } from './constant' | import { PkgLog } from './utils'; | ||||||
| 
 | 
 | ||||||
| export function tarPlugin(cwd: string, log: PkgLog) { | export function tarPlugin(cwd: string, log: PkgLog) { | ||||||
|   log('tar package'); |   log('tar package'); | ||||||
| @ -12,14 +13,24 @@ export function tarPlugin(cwd: string, log: PkgLog) { | |||||||
|   const npmIgnore = path.join(cwd, '.npmignore'); |   const npmIgnore = path.join(cwd, '.npmignore'); | ||||||
|   let files = pkg.files || []; |   let files = pkg.files || []; | ||||||
|   if (fs.existsSync(npmIgnore)) { |   if (fs.existsSync(npmIgnore)) { | ||||||
|     files = fs.readFileSync(npmIgnore, 'utf-8').split('\n').filter((item) => item.trim()).map(item => `!${item}`); |     files = fs | ||||||
|  |       .readFileSync(npmIgnore, 'utf-8') | ||||||
|  |       .split('\n') | ||||||
|  |       .filter((item) => item.trim()) | ||||||
|  |       .map((item) => `!${item}`); | ||||||
|     files.push('**/*'); |     files.push('**/*'); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   // 必须包含的文件
 |   // 必须包含的文件
 | ||||||
|   files.push(...tarIncludesFiles); |   files.push(...tarIncludesFiles); | ||||||
| 
 | 
 | ||||||
|   files = files.map((item: string) => item !== '**/*' && fs.existsSync(path.join(cwd, item.replace('!', ''))) && fs.statSync(path.join(cwd, item.replace('!', ''))).isDirectory() ? `${item}/**/*` : item); |   files = files.map((item: string) => | ||||||
|  |     item !== '**/*' && | ||||||
|  |     fs.existsSync(path.join(cwd, item.replace('!', ''))) && | ||||||
|  |     fs.statSync(path.join(cwd, item.replace('!', ''))).isDirectory() | ||||||
|  |       ? `${item}/**/*` | ||||||
|  |       : item, | ||||||
|  |   ); | ||||||
| 
 | 
 | ||||||
|   const tarball = path.join(TAR_OUTPUT_DIR, `${pkg.name}-${pkg.version}.tgz`); |   const tarball = path.join(TAR_OUTPUT_DIR, `${pkg.name}-${pkg.version}.tgz`); | ||||||
|   const tarFiles = fg.sync(files, { cwd }); |   const tarFiles = fg.sync(files, { cwd }); | ||||||
|  | |||||||
| @ -1,8 +1,9 @@ | |||||||
| import fs from 'fs'; | import fs from 'fs'; | ||||||
| import chalk from 'chalk'; |  | ||||||
| import { builtinModules } from 'module'; | import { builtinModules } from 'module'; | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
| 
 | 
 | ||||||
|  | import chalk from 'chalk'; | ||||||
|  | 
 | ||||||
| const requireRegex = /require\s*\(['"`](.*?)['"`]\)/g; | const requireRegex = /require\s*\(['"`](.*?)['"`]\)/g; | ||||||
| const importRegex = /^import(?:['"\s]*([\w*${}\s,]+)from\s*)?['"\s]['"\s](.*[@\w_-]+)['"\s].*/gm; | const importRegex = /^import(?:['"\s]*([\w*${}\s,]+)from\s*)?['"\s]['"\s](.*[@\w_-]+)['"\s].*/gm; | ||||||
| 
 | 
 | ||||||
| @ -156,10 +157,14 @@ export function checkRequire(sourceFiles: string[], log: Log) { | |||||||
| export function checkFileSize(outDir: string, log: Log) { | export function checkFileSize(outDir: string, log: Log) { | ||||||
|   const files = fs.readdirSync(outDir); |   const files = fs.readdirSync(outDir); | ||||||
| 
 | 
 | ||||||
|   files.forEach(file => { |   files.forEach((file) => { | ||||||
|     const fileSize = getFileSize(path.join(outDir, file)); |     const fileSize = getFileSize(path.join(outDir, file)); | ||||||
|     if (fileSize > 1024 * 1024) { |     if (fileSize > 1024 * 1024) { | ||||||
|       log(`The %s size %s exceeds 1MB. You can use dynamic import \`import()\` for lazy loading content.`, chalk.red(file), chalk.red(formatFileSize(fileSize))); |       log( | ||||||
|  |         `The %s size %s exceeds 1MB. You can use dynamic import \`import()\` for lazy loading content.`, | ||||||
|  |         chalk.red(file), | ||||||
|  |         chalk.red(formatFileSize(fileSize)), | ||||||
|  |       ); | ||||||
|     } |     } | ||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import path from 'path'; | import path from 'path'; | ||||||
|  | 
 | ||||||
| import fs from 'fs-extra'; | import fs from 'fs-extra'; | ||||||
| 
 | 
 | ||||||
| export function winPath(path: string) { | export function winPath(path: string) { | ||||||
| @ -17,20 +18,15 @@ export function getRltExternalsFromDeps( | |||||||
|   depExternals: Record<string, string>, |   depExternals: Record<string, string>, | ||||||
|   current: { name: string; outputDir: string }, |   current: { name: string; outputDir: string }, | ||||||
| ) { | ) { | ||||||
|   return Object.entries(depExternals).reduce<Record<string, string>>( |   return Object.entries(depExternals).reduce<Record<string, string>>((r, [dep, target]) => { | ||||||
|     (r, [dep, target]) => { |  | ||||||
|     // skip self
 |     // skip self
 | ||||||
|     if (dep !== current.name) { |     if (dep !== current.name) { | ||||||
|       // transform dep externals path to relative path
 |       // transform dep externals path to relative path
 | ||||||
|         r[dep] = winPath( |       r[dep] = winPath(path.relative(current.outputDir, path.dirname(target))); | ||||||
|           path.relative(current.outputDir, path.dirname(target)), |  | ||||||
|         ); |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     return r; |     return r; | ||||||
|     }, |   }, {}); | ||||||
|     {}, |  | ||||||
|   ); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function findPackageJson(filePath) { | function findPackageJson(filePath) { | ||||||
| @ -44,7 +40,7 @@ function findPackageJson(filePath) { | |||||||
|     // 递归寻找直到根目录
 |     // 递归寻找直到根目录
 | ||||||
|     return findPackageJson(directory); |     return findPackageJson(directory); | ||||||
|   } else { |   } else { | ||||||
|     throw new Error('package.json not found.') |     throw new Error('package.json not found.'); | ||||||
|   } |   } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -100,10 +96,10 @@ export function getDepsConfig(cwd: string, outDir: string, depsName: string[], e | |||||||
|       pkg: depPkg, |       pkg: depPkg, | ||||||
|       outputDir, |       outputDir, | ||||||
|       mainFile, |       mainFile, | ||||||
|     } |     }; | ||||||
| 
 | 
 | ||||||
|     return acc; |     return acc; | ||||||
|   }, {}) |   }, {}); | ||||||
| 
 | 
 | ||||||
|   // process externals for deps
 |   // process externals for deps
 | ||||||
|   Object.values(deps).forEach((depConfig) => { |   Object.values(deps).forEach((depConfig) => { | ||||||
|  | |||||||
| @ -1,10 +1,11 @@ | |||||||
| import Topo from '@hapi/topo'; |  | ||||||
| import fg from 'fast-glob'; |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
|  | 
 | ||||||
|  | import Topo from '@hapi/topo'; | ||||||
|  | import { findWorkspacePackages, type Project } from '@pnpm/workspace.find-packages'; | ||||||
|  | import fg from 'fast-glob'; | ||||||
|  | 
 | ||||||
| import { PACKAGES_PATH, ROOT_PATH } from '../constant'; | import { PACKAGES_PATH, ROOT_PATH } from '../constant'; | ||||||
| import { toUnixPath } from './utils'; | import { toUnixPath } from './utils'; | ||||||
| import { findWorkspacePackages } from '@pnpm/workspace.find-packages'; |  | ||||||
| import type { Project } from '@pnpm/workspace.find-packages'; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 获取构建包的绝对路径,支持项目路径和 npm 两种形式 |  * 获取构建包的绝对路径,支持项目路径和 npm 两种形式 | ||||||
|  | |||||||
| @ -1,10 +1,12 @@ | |||||||
| import chalk from 'chalk'; |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
|  | 
 | ||||||
|  | import chalk from 'chalk'; | ||||||
|  | import { register } from 'esbuild-register/dist/node'; | ||||||
| import fg from 'fast-glob'; | import fg from 'fast-glob'; | ||||||
| import fs from 'fs-extra'; | import fs from 'fs-extra'; | ||||||
| import { Options as TsupConfig } from 'tsup' | import { Options as TsupConfig } from 'tsup'; | ||||||
| import { InlineConfig as ViteConfig } from 'vite' | import { InlineConfig as ViteConfig } from 'vite'; | ||||||
| import { register } from 'esbuild-register/dist/node'; | 
 | ||||||
| import { NODE_MODULES } from '../constant'; | import { NODE_MODULES } from '../constant'; | ||||||
| 
 | 
 | ||||||
| let previousColor = ''; | let previousColor = ''; | ||||||
| @ -73,9 +75,9 @@ export function getUserConfig(cwd: string) { | |||||||
|     throw new Error(`Multiple build configs found: ${buildConfigs.join(', ')}`); |     throw new Error(`Multiple build configs found: ${buildConfigs.join(', ')}`); | ||||||
|   } |   } | ||||||
|   if (buildConfigs.length === 1) { |   if (buildConfigs.length === 1) { | ||||||
|     const { unregister } = register({}) |     const { unregister } = register({}); | ||||||
|     const userConfig = require(path.join(cwd, buildConfigs[0])); |     const userConfig = require(path.join(cwd, buildConfigs[0])); | ||||||
|     unregister() |     unregister(); | ||||||
|     Object.assign(config, userConfig.default || userConfig); |     Object.assign(config, userConfig.default || userConfig); | ||||||
|   } |   } | ||||||
|   return config; |   return config; | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { defineConfig } from 'tsup'; |  | ||||||
| import fg from 'fast-glob'; |  | ||||||
| import path from 'path'; | import path from 'path'; | ||||||
|  | 
 | ||||||
|  | import fg from 'fast-glob'; | ||||||
|  | import { defineConfig } from 'tsup'; | ||||||
|  | 
 | ||||||
| import { globExcludeFiles } from './src/constant'; | import { globExcludeFiles } from './src/constant'; | ||||||
| 
 | 
 | ||||||
| const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd: __dirname, absolute: true }); | const entry = fg.globSync(['src/**', ...globExcludeFiles], { cwd: __dirname, absolute: true }); | ||||||
|  | |||||||
| @ -1,11 +1,12 @@ | |||||||
| import { builtinModules, createRequire } from 'node:module'; | import { builtinModules, createRequire } from 'node:module'; | ||||||
| import esbuild from 'rollup-plugin-esbuild'; |  | ||||||
| import process from 'node:process'; | import process from 'node:process'; | ||||||
| import dts from 'rollup-plugin-dts'; | 
 | ||||||
| import resolve from '@rollup/plugin-node-resolve'; |  | ||||||
| import commonjs from '@rollup/plugin-commonjs'; | import commonjs from '@rollup/plugin-commonjs'; | ||||||
| import json from '@rollup/plugin-json'; | import json from '@rollup/plugin-json'; | ||||||
|  | import resolve from '@rollup/plugin-node-resolve'; | ||||||
| import { defineConfig } from 'rollup'; | import { defineConfig } from 'rollup'; | ||||||
|  | import dts from 'rollup-plugin-dts'; | ||||||
|  | import esbuild from 'rollup-plugin-esbuild'; | ||||||
| 
 | 
 | ||||||
| const require = createRequire(import.meta.url); | const require = createRequire(import.meta.url); | ||||||
| const pkg = require('./package.json'); | const pkg = require('./package.json'); | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| #!/usr/bin/env node | #!/usr/bin/env node | ||||||
| 
 |  | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
| import { initEnv, genTsConfigPaths } from './util'; |  | ||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
| import commands from './commands'; |  | ||||||
| import semver from 'semver'; | import semver from 'semver'; | ||||||
| 
 | 
 | ||||||
|  | import commands from './commands'; | ||||||
|  | import { genTsConfigPaths, initEnv } from './util'; | ||||||
|  | 
 | ||||||
| const cli = new Command(); | const cli = new Command(); | ||||||
| 
 | 
 | ||||||
| cli.version((await import('../package.json')).version); | cli.version((await import('../package.json')).version); | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { resolve } from 'path'; | import { resolve } from 'path'; | ||||||
|  | 
 | ||||||
| import { type Command } from 'commander'; | import { type Command } from 'commander'; | ||||||
| import { run, nodeCheck, isPackageValid, buildIndexHtml } from '../util'; | 
 | ||||||
|  | import { buildIndexHtml, isPackageValid, nodeCheck, run } from '../util'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * |  * | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
| import { run, isDev } from '../util'; | 
 | ||||||
|  | import { isDev, run } from '../util'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * |  * | ||||||
|  | |||||||
| @ -1,8 +1,9 @@ | |||||||
| import { resolve } from 'path'; |  | ||||||
| import { Command } from 'commander'; |  | ||||||
| import { readFileSync, writeFileSync } from 'fs'; | import { readFileSync, writeFileSync } from 'fs'; | ||||||
|  | import { resolve } from 'path'; | ||||||
| import { URL } from 'url'; | import { URL } from 'url'; | ||||||
| 
 | 
 | ||||||
|  | import { Command } from 'commander'; | ||||||
|  | 
 | ||||||
| const __dirname = new URL('.', import.meta.url).pathname; | const __dirname = new URL('.', import.meta.url).pathname; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| import { resolve } from 'path'; | import { resolve } from 'path'; | ||||||
|  | 
 | ||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
|  | 
 | ||||||
| import { PluginGenerator } from '../plugin-generator'; | import { PluginGenerator } from '../plugin-generator'; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|  | |||||||
| @ -1,7 +1,8 @@ | |||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
| import { run, postCheck, nodeCheck, promptForTs } from '../util'; |  | ||||||
| import { getPortPromise } from 'portfinder'; | import { getPortPromise } from 'portfinder'; | ||||||
| 
 | 
 | ||||||
|  | import { nodeCheck, postCheck, promptForTs, run } from '../util'; | ||||||
|  | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|   const { APP_PACKAGE_ROOT } = process.env; |   const { APP_PACKAGE_ROOT } = process.env; | ||||||
|   cli |   cli | ||||||
|  | |||||||
| @ -1,11 +1,13 @@ | |||||||
| import { Command } from 'commander'; |  | ||||||
| import { run, isPortReachable } from '../util'; |  | ||||||
| import { execSync } from 'node:child_process'; | import { execSync } from 'node:child_process'; | ||||||
| import axios from 'axios'; |  | ||||||
| import { pTest } from './p-test'; |  | ||||||
| import { cpus } from 'os'; | import { cpus } from 'os'; | ||||||
| import treeKill from 'tree-kill'; | 
 | ||||||
|  | import axios from 'axios'; | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
|  | import { Command } from 'commander'; | ||||||
|  | import treeKill from 'tree-kill'; | ||||||
|  | 
 | ||||||
|  | import { isPortReachable, run } from '../util'; | ||||||
|  | import { pTest } from './p-test'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * 检查服务是否启动成功 |  * 检查服务是否启动成功 | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
| import { run, isDev, isProd, promptForTs } from '../util'; | 
 | ||||||
|  | import { isDev, isProd, promptForTs, run } from '../util'; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|   const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env; |   const { APP_PACKAGE_ROOT, SERVER_TSCONFIG_PATH } = process.env; | ||||||
|  | |||||||
| @ -1,19 +1,20 @@ | |||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
|  | 
 | ||||||
| import { generateAppDir } from '../util'; | import { generateAppDir } from '../util'; | ||||||
| import global from './global'; |  | ||||||
| import createNginxConf from './create-nginx-conf'; |  | ||||||
| import build from './build'; | import build from './build'; | ||||||
| import tar from './tar'; |  | ||||||
| import dev from './dev'; |  | ||||||
| import start from './start'; |  | ||||||
| import e2e from './e2e'; |  | ||||||
| import clean from './clean'; | import clean from './clean'; | ||||||
|  | import createNginxConf from './create-nginx-conf'; | ||||||
|  | import createPlugin from './create-plugin'; | ||||||
|  | import dev from './dev'; | ||||||
|  | import e2e from './e2e'; | ||||||
|  | import global from './global'; | ||||||
| import pm2 from './pm2'; | import pm2 from './pm2'; | ||||||
|  | import postinstall from './postinstall'; | ||||||
|  | import start from './start'; | ||||||
|  | import tar from './tar'; | ||||||
| import test from './test'; | import test from './test'; | ||||||
| import umi from './umi'; | import umi from './umi'; | ||||||
| import upgrade from './upgrade'; | import upgrade from './upgrade'; | ||||||
| import postinstall from './postinstall'; |  | ||||||
| import createPlugin from './create-plugin'; |  | ||||||
| 
 | 
 | ||||||
| export default async (cli: Command) => { | export default async (cli: Command) => { | ||||||
|   generateAppDir(); |   generateAppDir(); | ||||||
|  | |||||||
| @ -1,10 +1,11 @@ | |||||||
| import { execa } from 'execa'; | import { existsSync, mkdirSync, readFileSync } from 'fs'; | ||||||
| import { resolve } from 'path'; | import { resolve } from 'path'; | ||||||
| import pAll from 'p-all'; | 
 | ||||||
| import { parse } from 'dotenv'; | import { parse } from 'dotenv'; | ||||||
| import { existsSync, readFileSync, mkdirSync } from 'fs'; | import { execa } from 'execa'; | ||||||
| import fastGlob from 'fast-glob'; | import fastGlob from 'fast-glob'; | ||||||
| import lodash from 'lodash'; | import lodash from 'lodash'; | ||||||
|  | import pAll from 'p-all'; | ||||||
| 
 | 
 | ||||||
| let ENV_FILE = resolve(process.cwd(), '.env.e2e'); | let ENV_FILE = resolve(process.cwd(), '.env.e2e'); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
|  | 
 | ||||||
| import { run } from '../util'; | import { run } from '../util'; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|  | |||||||
| @ -1,9 +1,11 @@ | |||||||
| import { Command } from 'commander'; |  | ||||||
| import { run, isDev, isPackageValid, generatePlaywrightPath } from '../util'; |  | ||||||
| import { resolve } from 'path'; |  | ||||||
| import { existsSync } from 'fs'; | import { existsSync } from 'fs'; | ||||||
| import { readFile, writeFile } from 'fs/promises'; | import { readFile, writeFile } from 'fs/promises'; | ||||||
| import { createStoragePluginsSymlink, createDevPluginsSymlink } from '@tachybase/utils/plugin-symlink'; | import { resolve } from 'path'; | ||||||
|  | import { createDevPluginsSymlink, createStoragePluginsSymlink } from '@tachybase/utils/plugin-symlink'; | ||||||
|  | 
 | ||||||
|  | import { Command } from 'commander'; | ||||||
|  | 
 | ||||||
|  | import { generatePlaywrightPath, isDev, isPackageValid, run } from '../util'; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|   const { APP_PACKAGE_ROOT } = process.env; |   const { APP_PACKAGE_ROOT } = process.env; | ||||||
|  | |||||||
| @ -1,10 +1,12 @@ | |||||||
| import { Command } from 'commander'; |  | ||||||
| import { run, postCheck, promptForTs } from '../util'; |  | ||||||
| import { existsSync } from 'fs'; | import { existsSync } from 'fs'; | ||||||
| import { resolve } from 'path'; | import { resolve } from 'path'; | ||||||
|  | 
 | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
|  | import { Command } from 'commander'; | ||||||
| import _ from 'lodash'; | import _ from 'lodash'; | ||||||
| 
 | 
 | ||||||
|  | import { postCheck, promptForTs, run } from '../util'; | ||||||
|  | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|   const { APP_PACKAGE_ROOT, NODE_ARGS } = process.env; |   const { APP_PACKAGE_ROOT, NODE_ARGS } = process.env; | ||||||
|   cli |   cli | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { resolve } from 'path'; | import { resolve } from 'path'; | ||||||
|  | 
 | ||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
| import { run, nodeCheck, isPackageValid } from '../util'; | 
 | ||||||
|  | import { isPackageValid, nodeCheck, run } from '../util'; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|   cli |   cli | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
| import { Command } from 'commander'; |  | ||||||
| import { run } from '../util'; |  | ||||||
| import { sep } from 'path'; | import { sep } from 'path'; | ||||||
| 
 | 
 | ||||||
|  | import { Command } from 'commander'; | ||||||
|  | 
 | ||||||
|  | import { run } from '../util'; | ||||||
|  | 
 | ||||||
| function addTestCommand(name: string, cli: Command) { | function addTestCommand(name: string, cli: Command) { | ||||||
|   return cli |   return cli | ||||||
|     .command(name) |     .command(name) | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import { Command } from 'commander'; | import { Command } from 'commander'; | ||||||
| import { run, isDev } from '../util'; | 
 | ||||||
|  | import { isDev, run } from '../util'; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|   const { APP_PACKAGE_ROOT } = process.env; |   const { APP_PACKAGE_ROOT } = process.env; | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
| import { Command } from 'commander'; |  | ||||||
| import { resolve } from 'path'; |  | ||||||
| import { run, promptForTs, runAppCommand, hasCorePackages, hasTsNode } from '../util'; |  | ||||||
| import { existsSync, rmSync } from 'fs'; | import { existsSync, rmSync } from 'fs'; | ||||||
|  | import { resolve } from 'path'; | ||||||
|  | 
 | ||||||
|  | import { Command } from 'commander'; | ||||||
|  | 
 | ||||||
|  | import { hasCorePackages, hasTsNode, promptForTs, run, runAppCommand } from '../util'; | ||||||
| 
 | 
 | ||||||
| export default (cli: Command) => { | export default (cli: Command) => { | ||||||
|   cli |   cli | ||||||
|  | |||||||
| @ -1,12 +1,14 @@ | |||||||
| import chalk from 'chalk'; |  | ||||||
| import { existsSync } from 'fs'; | import { existsSync } from 'fs'; | ||||||
| import { join, resolve } from 'path'; |  | ||||||
| import { Generator } from '@umijs/utils'; |  | ||||||
| import { readFile } from 'fs/promises'; | import { readFile } from 'fs/promises'; | ||||||
| import { genTsConfigPaths } from './util'; | import { join, resolve } from 'path'; | ||||||
| import { execa } from 'execa'; |  | ||||||
| import { URL } from 'url'; | import { URL } from 'url'; | ||||||
| 
 | 
 | ||||||
|  | import { Generator } from '@umijs/utils'; | ||||||
|  | import chalk from 'chalk'; | ||||||
|  | import { execa } from 'execa'; | ||||||
|  | 
 | ||||||
|  | import { genTsConfigPaths } from './util'; | ||||||
|  | 
 | ||||||
| const __dirname = new URL('.', import.meta.url).pathname; | const __dirname = new URL('.', import.meta.url).pathname; | ||||||
| 
 | 
 | ||||||
| function camelize(str: string) { | function camelize(str: string) { | ||||||
| @ -40,7 +42,7 @@ export class PluginGenerator extends Generator { | |||||||
|       ...this.context, |       ...this.context, | ||||||
|       packageName: name, |       packageName: name, | ||||||
|       packageVersion, |       packageVersion, | ||||||
|       tachybaseVersion: "0.0.1", |       tachybaseVersion: '0.0.1', | ||||||
|       pascalCaseName: capitalize(camelize(name.split('/').pop())), |       pascalCaseName: capitalize(camelize(name.split('/').pop())), | ||||||
|     }; |     }; | ||||||
|   } |   } | ||||||
|  | |||||||
| @ -1,27 +1,32 @@ | |||||||
|  | import { | ||||||
|  |   cpSync as _cpSync, | ||||||
|  |   existsSync as _existsSync, | ||||||
|  |   writeFileSync as _writeFileSync, | ||||||
|  |   copyFileSync, | ||||||
|  |   cpSync, | ||||||
|  |   existsSync, | ||||||
|  |   mkdirSync, | ||||||
|  |   readFileSync, | ||||||
|  |   rmSync, | ||||||
|  |   symlinkSync, | ||||||
|  |   unlinkSync, | ||||||
|  |   writeFileSync, | ||||||
|  | } from 'fs'; | ||||||
|  | import { readFile, writeFile } from 'fs/promises'; | ||||||
|  | import { createRequire } from 'module'; | ||||||
| import { Socket } from 'net'; | import { Socket } from 'net'; | ||||||
|  | import { dirname, join, resolve, sep } from 'path'; | ||||||
|  | 
 | ||||||
| import chalk from 'chalk'; | import chalk from 'chalk'; | ||||||
|  | import { config } from 'dotenv'; | ||||||
| import { execa, Options } from 'execa'; | import { execa, Options } from 'execa'; | ||||||
| import fastGlob from 'fast-glob'; | import fastGlob from 'fast-glob'; | ||||||
| import { dirname, join, resolve, sep } from 'path'; | 
 | ||||||
| import { readFile, writeFile } from 'fs/promises'; |  | ||||||
| import { existsSync, mkdirSync, cpSync, writeFileSync } from 'fs'; |  | ||||||
| import { config } from 'dotenv'; |  | ||||||
| import { |  | ||||||
|   unlinkSync, |  | ||||||
|   symlinkSync, |  | ||||||
|   existsSync as _existsSync, |  | ||||||
|   rmSync, |  | ||||||
|   cpSync as _cpSync, |  | ||||||
|   copyFileSync, |  | ||||||
|   readFileSync, |  | ||||||
|   writeFileSync as _writeFileSync, |  | ||||||
| } from 'fs'; |  | ||||||
| import { createRequire } from 'module'; |  | ||||||
| const require = createRequire(import.meta.url); | const require = createRequire(import.meta.url); | ||||||
| 
 | 
 | ||||||
| export function isPackageValid(pkg: string) { | export function isPackageValid(pkg: string) { | ||||||
|   try { |   try { | ||||||
|     require(pkg) |     require(pkg); | ||||||
|     return true; |     return true; | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     return false; |     return false; | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import axios from 'axios'; | import axios from 'axios'; | ||||||
|  | 
 | ||||||
| import { APIClient } from '../APIClient'; | import { APIClient } from '../APIClient'; | ||||||
| 
 | 
 | ||||||
| describe('APIClient', () => { | describe('APIClient', () => { | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client'; |  | ||||||
| import MockAdapter from 'axios-mock-adapter'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client'; | ||||||
|  | 
 | ||||||
|  | import MockAdapter from 'axios-mock-adapter'; | ||||||
| 
 | 
 | ||||||
| const apiClient = new APIClient(); | const apiClient = new APIClient(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client'; |  | ||||||
| import MockAdapter from 'axios-mock-adapter'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { APIClient, APIClientProvider, compose, useRequest } from '@tachybase/client'; | ||||||
|  | 
 | ||||||
|  | import MockAdapter from 'axios-mock-adapter'; | ||||||
| 
 | 
 | ||||||
| const apiClient = new APIClient(); | const apiClient = new APIClient(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,8 +1,9 @@ | |||||||
| import { uid } from '@tachybase/schema'; | import React from 'react'; | ||||||
| import { APIClient, APIClientProvider, useAPIClient, useRequest } from '@tachybase/client'; | import { APIClient, APIClientProvider, useAPIClient, useRequest } from '@tachybase/client'; | ||||||
|  | import { uid } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
| import { Button, Input, Space, Table } from 'antd'; | import { Button, Input, Space, Table } from 'antd'; | ||||||
| import MockAdapter from 'axios-mock-adapter'; | import MockAdapter from 'axios-mock-adapter'; | ||||||
| import React from 'react'; |  | ||||||
| 
 | 
 | ||||||
| const apiClient = new APIClient(); | const apiClient = new APIClient(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,9 +1,11 @@ | |||||||
|  | import React, { Component } from 'react'; | ||||||
| import { render, screen, sleep, userEvent, waitFor } from '@tachybase/test/client'; | import { render, screen, sleep, userEvent, waitFor } from '@tachybase/test/client'; | ||||||
|  | 
 | ||||||
| import axios from 'axios'; | import axios from 'axios'; | ||||||
| import MockAdapter from 'axios-mock-adapter'; | import MockAdapter from 'axios-mock-adapter'; | ||||||
| import React, { Component } from 'react'; |  | ||||||
| import { Link, Outlet } from 'react-router-dom'; | import { Link, Outlet } from 'react-router-dom'; | ||||||
| import { describe } from 'vitest'; | import { describe } from 'vitest'; | ||||||
|  | 
 | ||||||
| import { Application } from '../Application'; | import { Application } from '../Application'; | ||||||
| import { Plugin } from '../Plugin'; | import { Plugin } from '../Plugin'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,8 @@ | |||||||
| import { Application } from '../Application'; |  | ||||||
| import axios from 'axios'; | import axios from 'axios'; | ||||||
| import MockAdapter from 'axios-mock-adapter'; | import MockAdapter from 'axios-mock-adapter'; | ||||||
| 
 | 
 | ||||||
|  | import { Application } from '../Application'; | ||||||
|  | 
 | ||||||
| describe('PluginSettingsManager', () => { | describe('PluginSettingsManager', () => { | ||||||
|   let app: Application; |   let app: Application; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,11 +1,13 @@ | |||||||
| import { render, screen, userEvent, sleep, waitFor } from '@tachybase/test/client'; | import React, { FC } from 'react'; | ||||||
|  | import { render, screen, sleep, userEvent, waitFor } from '@tachybase/test/client'; | ||||||
|  | 
 | ||||||
| import axios from 'axios'; | import axios from 'axios'; | ||||||
| import MockAdapter from 'axios-mock-adapter'; | import MockAdapter from 'axios-mock-adapter'; | ||||||
| import React, { FC } from 'react'; |  | ||||||
| import { Link, Outlet } from 'react-router-dom'; | import { Link, Outlet } from 'react-router-dom'; | ||||||
| import { beforeAll } from 'vitest'; | import { beforeAll } from 'vitest'; | ||||||
|  | 
 | ||||||
| import { Application } from '../Application'; | import { Application } from '../Application'; | ||||||
| import { RouteType, RouterManager, createRouterManager } from '../RouterManager'; | import { createRouterManager, RouterManager, RouteType } from '../RouterManager'; | ||||||
| 
 | 
 | ||||||
| describe('Router', () => { | describe('Router', () => { | ||||||
|   let app: Application; |   let app: Application; | ||||||
|  | |||||||
| @ -1,9 +1,10 @@ | |||||||
| import React from 'react'; | import React from 'react'; | ||||||
| import { fireEvent, render, screen, waitFor } from '@tachybase/test/client'; |  | ||||||
| import { SchemaToolbarProvider, useSchemaToolbar, useSchemaToolbarRender } from '../schema-toolbar'; |  | ||||||
| import { SchemaComponent, SchemaComponentProvider, SortableContext, SortableProvider } from '../../schema-component'; |  | ||||||
| import { useFieldSchema } from '@tachybase/schema'; |  | ||||||
| import { Application, ApplicationContext } from '@tachybase/client'; | import { Application, ApplicationContext } from '@tachybase/client'; | ||||||
|  | import { useFieldSchema } from '@tachybase/schema'; | ||||||
|  | import { fireEvent, render, screen, waitFor } from '@tachybase/test/client'; | ||||||
|  | 
 | ||||||
|  | import { SchemaComponent, SchemaComponentProvider, SortableContext, SortableProvider } from '../../schema-component'; | ||||||
|  | import { SchemaToolbarProvider, useSchemaToolbar, useSchemaToolbarRender } from '../schema-toolbar'; | ||||||
| 
 | 
 | ||||||
| describe('SchemaToolbar', () => { | describe('SchemaToolbar', () => { | ||||||
|   test('SchemaToolbarProvider & useSchemaToolbar', () => { |   test('SchemaToolbarProvider & useSchemaToolbar', () => { | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import React from 'react'; | import React from 'react'; | ||||||
| import { SchemaComponent, SchemaComponentProvider } from '../../../schema-component'; |  | ||||||
| import { render } from '@tachybase/test/client'; | import { render } from '@tachybase/test/client'; | ||||||
|  | 
 | ||||||
|  | import { SchemaComponent, SchemaComponentProvider } from '../../../schema-component'; | ||||||
| import { withDynamicSchemaProps } from '../../hoc'; | import { withDynamicSchemaProps } from '../../hoc'; | ||||||
| 
 | 
 | ||||||
| const HelloComponent = withDynamicSchemaProps((props: any) => ( | const HelloComponent = withDynamicSchemaProps((props: any) => ( | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { render, screen } from '@tachybase/test/client'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { render, screen } from '@tachybase/test/client'; | ||||||
|  | 
 | ||||||
| import { describe } from 'vitest'; | import { describe } from 'vitest'; | ||||||
|  | 
 | ||||||
| import { compose, normalizeContainer } from '../utils'; | import { compose, normalizeContainer } from '../utils'; | ||||||
| 
 | 
 | ||||||
| describe('utils', () => { | describe('utils', () => { | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { createContext } from 'react'; | import { createContext } from 'react'; | ||||||
|  | 
 | ||||||
| import { Application } from './Application'; | import { Application } from './Application'; | ||||||
| 
 | 
 | ||||||
| export const ApplicationContext = createContext<Application>(null); | export const ApplicationContext = createContext<Application>(null); | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import type { ButtonProps } from 'antd'; | import type { ButtonProps } from 'antd'; | ||||||
|  | 
 | ||||||
| import { SchemaInitializerItemType, SchemaInitializerItemTypeWithoutName, SchemaInitializerOptions } from './types'; | import { SchemaInitializerItemType, SchemaInitializerItemTypeWithoutName, SchemaInitializerOptions } from './types'; | ||||||
| 
 | 
 | ||||||
| export class SchemaInitializer<P1 = ButtonProps, P2 = {}> { | export class SchemaInitializer<P1 = ButtonProps, P2 = {}> { | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { ButtonProps } from 'antd'; | import { ButtonProps } from 'antd'; | ||||||
|  | 
 | ||||||
| import { Application } from '../Application'; | import { Application } from '../Application'; | ||||||
| import { SchemaInitializer } from './SchemaInitializer'; | import { SchemaInitializer } from './SchemaInitializer'; | ||||||
| import { SchemaInitializerItemTypeWithoutName } from './types'; | import { SchemaInitializerItemTypeWithoutName } from './types'; | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { useForm } from '@tachybase/schema'; |  | ||||||
| import React, { FC, useCallback, useMemo } from 'react'; | import React, { FC, useCallback, useMemo } from 'react'; | ||||||
| import { useActionContext, SchemaComponent } from '../../../schema-component'; | import { useForm } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { SchemaComponent, useActionContext } from '../../../schema-component'; | ||||||
| import { useSchemaInitializerItem } from '../context'; | import { useSchemaInitializerItem } from '../context'; | ||||||
| 
 | 
 | ||||||
| export interface SchemaInitializerActionModalProps { | export interface SchemaInitializerActionModalProps { | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| import { Button, ButtonProps } from 'antd'; |  | ||||||
| import React, { FC } from 'react'; | import React, { FC } from 'react'; | ||||||
|  | 
 | ||||||
|  | import { Button, ButtonProps } from 'antd'; | ||||||
|  | 
 | ||||||
| import { Icon } from '../../../icon'; | import { Icon } from '../../../icon'; | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| import { useGetAriaLabelOfSchemaInitializer } from '../../../schema-initializer/hooks/useGetAriaLabelOfSchemaInitializer'; | import { useGetAriaLabelOfSchemaInitializer } from '../../../schema-initializer/hooks/useGetAriaLabelOfSchemaInitializer'; | ||||||
|  | |||||||
| @ -3,6 +3,7 @@ import React, { FC, memo, useMemo } from 'react'; | |||||||
| import { useFindComponent } from '../../../schema-component'; | import { useFindComponent } from '../../../schema-component'; | ||||||
| import { SchemaInitializerItemContext } from '../context'; | import { SchemaInitializerItemContext } from '../context'; | ||||||
| import { SchemaInitializerItemType } from '../types'; | import { SchemaInitializerItemType } from '../types'; | ||||||
|  | 
 | ||||||
| export const SchemaInitializerChildren: FC<{ children: SchemaInitializerItemType[] }> = (props) => { | export const SchemaInitializerChildren: FC<{ children: SchemaInitializerItemType[] }> = (props) => { | ||||||
|   const { children } = props; |   const { children } = props; | ||||||
|   if (!children) return null; |   if (!children) return null; | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { Divider, theme } from 'antd'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
| 
 | 
 | ||||||
|  | import { Divider, theme } from 'antd'; | ||||||
|  | 
 | ||||||
| export const SchemaInitializerDivider = () => { | export const SchemaInitializerDivider = () => { | ||||||
|   const { token } = theme.useToken(); |   const { token } = theme.useToken(); | ||||||
|   return <Divider style={{ marginTop: token.marginXXS, marginBottom: token.marginXXS }} />; |   return <Divider style={{ marginTop: token.marginXXS, marginBottom: token.marginXXS }} />; | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
|  | import React, { memo, ReactNode, useMemo } from 'react'; | ||||||
| import { uid } from '@tachybase/schema'; | import { uid } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
| import classNames from 'classnames'; | import classNames from 'classnames'; | ||||||
| import React, { ReactNode, memo, useMemo } from 'react'; | 
 | ||||||
| import { Icon } from '../../../icon'; | import { Icon } from '../../../icon'; | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| import { useSchemaInitializerItem } from '../context'; | import { useSchemaInitializerItem } from '../context'; | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| import { theme } from 'antd'; |  | ||||||
| import React, { FC } from 'react'; | import React, { FC } from 'react'; | ||||||
|  | 
 | ||||||
|  | import { theme } from 'antd'; | ||||||
|  | 
 | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| import { useSchemaInitializerItem } from '../context'; | import { useSchemaInitializerItem } from '../context'; | ||||||
| import { SchemaInitializerOptions } from '../types'; | import { SchemaInitializerOptions } from '../types'; | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
| import { ButtonProps } from 'antd'; |  | ||||||
| import React, { FC } from 'react'; | import React, { FC } from 'react'; | ||||||
| import { SchemaInitializerChildren } from './SchemaInitializerChildren'; | 
 | ||||||
|  | import { ButtonProps } from 'antd'; | ||||||
|  | 
 | ||||||
| import { SchemaInitializerOptions } from '../types'; | import { SchemaInitializerOptions } from '../types'; | ||||||
|  | import { SchemaInitializerChildren } from './SchemaInitializerChildren'; | ||||||
| 
 | 
 | ||||||
| export type SchemaInitializerItemsProps<P1 = ButtonProps, P2 = {}> = P2 & { | export type SchemaInitializerItemsProps<P1 = ButtonProps, P2 = {}> = P2 & { | ||||||
|   options?: SchemaInitializerOptions<P1, P2>; |   options?: SchemaInitializerOptions<P1, P2>; | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
| import { Select, SelectProps } from 'antd'; |  | ||||||
| import React, { FC, useCallback, useMemo, useState } from 'react'; | import React, { FC, useCallback, useMemo, useState } from 'react'; | ||||||
| import { SchemaInitializerItemProps, SchemaInitializerItem } from './SchemaInitializerItem'; | 
 | ||||||
|  | import { Select, SelectProps } from 'antd'; | ||||||
|  | 
 | ||||||
| import { useSchemaInitializerItem } from '../context'; | import { useSchemaInitializerItem } from '../context'; | ||||||
|  | import { SchemaInitializerItem, SchemaInitializerItemProps } from './SchemaInitializerItem'; | ||||||
| 
 | 
 | ||||||
| export interface SchemaInitializerSelectItemProps extends SchemaInitializerItemProps { | export interface SchemaInitializerSelectItemProps extends SchemaInitializerItemProps { | ||||||
|   options?: SelectProps['options']; |   options?: SelectProps['options']; | ||||||
|  | |||||||
| @ -1,8 +1,10 @@ | |||||||
| import { Switch } from 'antd'; |  | ||||||
| import React, { FC } from 'react'; | import React, { FC } from 'react'; | ||||||
| import { SchemaInitializerItemProps, SchemaInitializerItem } from './SchemaInitializerItem'; | 
 | ||||||
|  | import { Switch } from 'antd'; | ||||||
|  | 
 | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| import { useSchemaInitializerItem } from '../context'; | import { useSchemaInitializerItem } from '../context'; | ||||||
|  | import { SchemaInitializerItem, SchemaInitializerItemProps } from './SchemaInitializerItem'; | ||||||
| 
 | 
 | ||||||
| export interface SchemaInitializerSwitchItemProps extends SchemaInitializerItemProps { | export interface SchemaInitializerSwitchItemProps extends SchemaInitializerItemProps { | ||||||
|   checked?: boolean; |   checked?: boolean; | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import React, { createContext } from 'react'; | import React, { createContext } from 'react'; | ||||||
|  | 
 | ||||||
| import { InsertType, SchemaInitializerItemType, SchemaInitializerOptions } from '../types'; | import { InsertType, SchemaInitializerItemType, SchemaInitializerOptions } from '../types'; | ||||||
| 
 | 
 | ||||||
| export const SchemaInitializerContext = createContext<{ | export const SchemaInitializerContext = createContext<{ | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { useMemo } from 'react'; | import { useMemo } from 'react'; | ||||||
|  | 
 | ||||||
| import { useSchemaInitializerSubMenuContext } from '../components/SchemaInitializerSubMenu'; | import { useSchemaInitializerSubMenuContext } from '../components/SchemaInitializerSubMenu'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { ISchema } from '@tachybase/schema'; |  | ||||||
| import { ButtonProps, PopoverProps } from 'antd'; |  | ||||||
| import { ComponentType, ReactNode } from 'react'; | import { ComponentType, ReactNode } from 'react'; | ||||||
|  | import { ISchema } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { ButtonProps, PopoverProps } from 'antd'; | ||||||
|  | 
 | ||||||
| import type { | import type { | ||||||
|   SchemaInitializerActionModalProps, |   SchemaInitializerActionModalProps, | ||||||
|   SchemaInitializerItemGroupProps, |   SchemaInitializerItemGroupProps, | ||||||
|  | |||||||
| @ -1,10 +1,12 @@ | |||||||
| import { ISchema, useFieldSchema } from '@tachybase/schema'; |  | ||||||
| import { SchemaSettingsItemType } from './types'; |  | ||||||
| import { useTranslation } from 'react-i18next'; |  | ||||||
| import { createDesignable, useDesignable } from '../../schema-component'; |  | ||||||
| import { saveAs } from 'file-saver'; |  | ||||||
| import { useAPIClient } from '../../api-client'; |  | ||||||
| import { useMemo } from 'react'; | import { useMemo } from 'react'; | ||||||
|  | import { ISchema, useFieldSchema } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { saveAs } from 'file-saver'; | ||||||
|  | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
|  | import { useAPIClient } from '../../api-client'; | ||||||
|  | import { createDesignable, useDesignable } from '../../schema-component'; | ||||||
|  | import { SchemaSettingsItemType } from './types'; | ||||||
| 
 | 
 | ||||||
| export const defaultSettingItems = [ | export const defaultSettingItems = [ | ||||||
|   { |   { | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| import { MenuOutlined } from '@ant-design/icons'; |  | ||||||
| import React, { FC, useMemo } from 'react'; | import React, { FC, useMemo } from 'react'; | ||||||
|  | 
 | ||||||
|  | import { MenuOutlined } from '@ant-design/icons'; | ||||||
|  | 
 | ||||||
| import { useGetAriaLabelOfDesigner } from '../../../schema-settings/hooks/useGetAriaLabelOfDesigner'; | import { useGetAriaLabelOfDesigner } from '../../../schema-settings/hooks/useGetAriaLabelOfDesigner'; | ||||||
| import { SchemaSettingOptions } from '../types'; | import { SchemaSettingOptions } from '../types'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| import { FC, useMemo } from 'react'; | import React, { FC, useMemo } from 'react'; | ||||||
|  | import { useField, useFieldSchema } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { useDesignable } from '../../../schema-component'; | ||||||
| import { SchemaSettingsDropdown } from '../../../schema-settings'; | import { SchemaSettingsDropdown } from '../../../schema-settings'; | ||||||
| import { SchemaSettingOptions } from '../types'; | import { SchemaSettingOptions } from '../types'; | ||||||
| import { SchemaSettingsChildren } from './SchemaSettingsChildren'; | import { SchemaSettingsChildren } from './SchemaSettingsChildren'; | ||||||
| import { SchemaSettingsIcon } from './SchemaSettingsIcon'; | import { SchemaSettingsIcon } from './SchemaSettingsIcon'; | ||||||
| import React from 'react'; |  | ||||||
| import { useDesignable } from '../../../schema-component'; |  | ||||||
| import { useField, useFieldSchema } from '@tachybase/schema'; |  | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * @internal |  * @internal | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { createContext, useContext } from 'react'; | import { createContext, useContext } from 'react'; | ||||||
|  | 
 | ||||||
| import { SchemaSettingsItemType } from '../types'; | import { SchemaSettingsItemType } from '../types'; | ||||||
| 
 | 
 | ||||||
| export const SchemaSettingItemContext = createContext<SchemaSettingsItemType>({} as any); | export const SchemaSettingItemContext = createContext<SchemaSettingsItemType>({} as any); | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { ComponentType } from 'react'; | import { ComponentType } from 'react'; | ||||||
|  | 
 | ||||||
| import { | import { | ||||||
|   SchemaSettingsCascaderItemProps, |   SchemaSettingsCascaderItemProps, | ||||||
|   SchemaSettingsItemProps, |   SchemaSettingsItemProps, | ||||||
|  | |||||||
| @ -1,5 +1,4 @@ | |||||||
| import React from 'react'; | import React, { createContext, useContext } from 'react'; | ||||||
| import { createContext, useContext } from 'react'; |  | ||||||
| 
 | 
 | ||||||
| export const SchemaToolbarContext = createContext<any>({}); | export const SchemaToolbarContext = createContext<any>({}); | ||||||
| SchemaToolbarContext.displayName = 'SchemaToolbarContext'; | SchemaToolbarContext.displayName = 'SchemaToolbarContext'; | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import React, { useMemo } from 'react'; | import React, { useMemo } from 'react'; | ||||||
| import { ISchema } from '@tachybase/schema'; | import { ISchema } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
| import { useComponent, useDesignable } from '../../../schema-component'; | import { useComponent, useDesignable } from '../../../schema-component'; | ||||||
| import { SchemaToolbar, SchemaToolbarProps } from '../../../schema-settings/GeneralSchemaDesigner'; | import { SchemaToolbar, SchemaToolbarProps } from '../../../schema-settings/GeneralSchemaDesigner'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -2,12 +2,12 @@ | |||||||
| // @ts-nocheck
 | // @ts-nocheck
 | ||||||
| /* eslint-disable */ | /* eslint-disable */ | ||||||
| /* prettier-ignore */ | /* prettier-ignore */ | ||||||
| import type { Require, RequireDefine } from './types' | import type { Require, RequireDefine } from './types'; | ||||||
| 
 | 
 | ||||||
| export interface RequireJS { | export interface RequireJS { | ||||||
|   require: Require |   require: Require; | ||||||
|   requirejs: Require |   requirejs: Require; | ||||||
|   define: RequireDefine |   define: RequireDefine; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
| @ -15,10 +15,18 @@ export interface RequireJS { | |||||||
|  */ |  */ | ||||||
| export function getRequireJs(): RequireJS { | export function getRequireJs(): RequireJS { | ||||||
|   var requirejs, require, define; |   var requirejs, require, define; | ||||||
|   var req, s, head, baseElement, dataMain, src, |   var req, | ||||||
|     interactiveScript, currentlyAddingScript, mainScript, subPath, |     s, | ||||||
|  |     head, | ||||||
|  |     baseElement, | ||||||
|  |     dataMain, | ||||||
|  |     src, | ||||||
|  |     interactiveScript, | ||||||
|  |     currentlyAddingScript, | ||||||
|  |     mainScript, | ||||||
|  |     subPath, | ||||||
|     version = '2.3.6', |     version = '2.3.6', | ||||||
|     commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg, |     commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/gm, | ||||||
|     cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, |     cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, | ||||||
|     jsSuffixRegExp = /\.js$/, |     jsSuffixRegExp = /\.js$/, | ||||||
|     currDirRegExp = /^\.\//, |     currDirRegExp = /^\.\//, | ||||||
| @ -31,8 +39,7 @@ export function getRequireJs(): RequireJS { | |||||||
|     //specifically. Sequence is 'loading', 'loaded', execution,
 |     //specifically. Sequence is 'loading', 'loaded', execution,
 | ||||||
|     // then 'complete'. The UA check is unfortunate, but not sure how
 |     // then 'complete'. The UA check is unfortunate, but not sure how
 | ||||||
|     //to feature test w/o causing perf issues.
 |     //to feature test w/o causing perf issues.
 | ||||||
|     readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? |     readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? /^complete$/ : /^(complete|loaded)$/, | ||||||
|       /^complete$/ : /^(complete|loaded)$/, |  | ||||||
|     defContextName = '_', |     defContextName = '_', | ||||||
|     //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
 |     //Oh the tragedy, detecting opera. See the usage of isOpera for reason.
 | ||||||
|     isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]', |     isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]', | ||||||
| @ -116,10 +123,14 @@ export function getRequireJs(): RequireJS { | |||||||
|     if (source) { |     if (source) { | ||||||
|       eachProp(source, function (value, prop) { |       eachProp(source, function (value, prop) { | ||||||
|         if (force || !hasProp(target, prop)) { |         if (force || !hasProp(target, prop)) { | ||||||
|           if (deepStringMixin && typeof value === 'object' && value && |           if ( | ||||||
|             !isArray(value) && !isFunction(value) && |             deepStringMixin && | ||||||
|             !(value instanceof RegExp)) { |             typeof value === 'object' && | ||||||
| 
 |             value && | ||||||
|  |             !isArray(value) && | ||||||
|  |             !isFunction(value) && | ||||||
|  |             !(value instanceof RegExp) | ||||||
|  |           ) { | ||||||
|             if (!target[prop]) { |             if (!target[prop]) { | ||||||
|               target[prop] = {}; |               target[prop] = {}; | ||||||
|             } |             } | ||||||
| @ -203,7 +214,10 @@ export function getRequireJs(): RequireJS { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   function newContext(contextName) { |   function newContext(contextName) { | ||||||
|     var inCheckLoaded, Module, context, handlers, |     var inCheckLoaded, | ||||||
|  |       Module, | ||||||
|  |       context, | ||||||
|  |       handlers, | ||||||
|       checkLoadedTimeoutId, |       checkLoadedTimeoutId, | ||||||
|       config = { |       config = { | ||||||
|         //Defaults. Do not set a default for map
 |         //Defaults. Do not set a default for map
 | ||||||
| @ -215,7 +229,7 @@ export function getRequireJs(): RequireJS { | |||||||
|         bundles: {}, |         bundles: {}, | ||||||
|         pkgs: {}, |         pkgs: {}, | ||||||
|         shim: {}, |         shim: {}, | ||||||
|         config: {} |         config: {}, | ||||||
|       }, |       }, | ||||||
|       registry = {}, |       registry = {}, | ||||||
|       //registry of just enabled modules, to speed
 |       //registry of just enabled modules, to speed
 | ||||||
| @ -273,9 +287,19 @@ export function getRequireJs(): RequireJS { | |||||||
|      * @returns {String} normalized name |      * @returns {String} normalized name | ||||||
|      */ |      */ | ||||||
|     function normalize(name, baseName, applyMap) { |     function normalize(name, baseName, applyMap) { | ||||||
|       var pkgMain, mapValue, nameParts, i, j, nameSegment, lastIndex, |       var pkgMain, | ||||||
|         foundMap, foundI, foundStarMap, starI, normalizedBaseParts, |         mapValue, | ||||||
|         baseParts = (baseName && baseName.split('/')), |         nameParts, | ||||||
|  |         i, | ||||||
|  |         j, | ||||||
|  |         nameSegment, | ||||||
|  |         lastIndex, | ||||||
|  |         foundMap, | ||||||
|  |         foundI, | ||||||
|  |         foundStarMap, | ||||||
|  |         starI, | ||||||
|  |         normalizedBaseParts, | ||||||
|  |         baseParts = baseName && baseName.split('/'), | ||||||
|         map = config.map, |         map = config.map, | ||||||
|         starMap = map && map['*']; |         starMap = map && map['*']; | ||||||
| 
 | 
 | ||||||
| @ -364,8 +388,10 @@ export function getRequireJs(): RequireJS { | |||||||
|     function removeScript(name) { |     function removeScript(name) { | ||||||
|       if (isBrowser) { |       if (isBrowser) { | ||||||
|         each(scripts(), function (scriptNode) { |         each(scripts(), function (scriptNode) { | ||||||
|           if (scriptNode.getAttribute('data-requiremodule') === name && |           if ( | ||||||
|             scriptNode.getAttribute('data-requirecontext') === context.contextName) { |             scriptNode.getAttribute('data-requiremodule') === name && | ||||||
|  |             scriptNode.getAttribute('data-requirecontext') === context.contextName | ||||||
|  |           ) { | ||||||
|             scriptNode.parentNode.removeChild(scriptNode); |             scriptNode.parentNode.removeChild(scriptNode); | ||||||
|             return true; |             return true; | ||||||
|           } |           } | ||||||
| @ -384,7 +410,7 @@ export function getRequireJs(): RequireJS { | |||||||
|         //Custom require that does not do map translation, since
 |         //Custom require that does not do map translation, since
 | ||||||
|         //ID is "absolute", already mapped/resolved.
 |         //ID is "absolute", already mapped/resolved.
 | ||||||
|         context.makeRequire(null, { |         context.makeRequire(null, { | ||||||
|           skipMap: true |           skipMap: true, | ||||||
|         })([id]); |         })([id]); | ||||||
| 
 | 
 | ||||||
|         return true; |         return true; | ||||||
| @ -420,7 +446,10 @@ export function getRequireJs(): RequireJS { | |||||||
|      * @returns {Object} |      * @returns {Object} | ||||||
|      */ |      */ | ||||||
|     function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { |     function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { | ||||||
|       var url, pluginModule, suffix, nameParts, |       var url, | ||||||
|  |         pluginModule, | ||||||
|  |         suffix, | ||||||
|  |         nameParts, | ||||||
|         prefix = null, |         prefix = null, | ||||||
|         parentName = parentModuleMap ? parentModuleMap.name : null, |         parentName = parentModuleMap ? parentModuleMap.name : null, | ||||||
|         originalName = name, |         originalName = name, | ||||||
| @ -461,9 +490,7 @@ export function getRequireJs(): RequireJS { | |||||||
|             // loaded and all normalizations to allow for async
 |             // loaded and all normalizations to allow for async
 | ||||||
|             // loading of a loader plugin. But for now, fixes the
 |             // loading of a loader plugin. But for now, fixes the
 | ||||||
|             // common uses. Details in #1131
 |             // common uses. Details in #1131
 | ||||||
|             normalizedName = name.indexOf('!') === -1 ? |             normalizedName = name.indexOf('!') === -1 ? normalize(name, parentName, applyMap) : name; | ||||||
|               normalize(name, parentName, applyMap) : |  | ||||||
|               name; |  | ||||||
|           } |           } | ||||||
|         } else { |         } else { | ||||||
|           //A regular module.
 |           //A regular module.
 | ||||||
| @ -484,9 +511,7 @@ export function getRequireJs(): RequireJS { | |||||||
|       //If the id is a plugin id that cannot be determined if it needs
 |       //If the id is a plugin id that cannot be determined if it needs
 | ||||||
|       //normalization, stamp it with a unique ID so two matching relative
 |       //normalization, stamp it with a unique ID so two matching relative
 | ||||||
|       //ids that may conflict can be separate.
 |       //ids that may conflict can be separate.
 | ||||||
|       suffix = prefix && !pluginModule && !isNormalized ? |       suffix = prefix && !pluginModule && !isNormalized ? '_unnormalized' + (unnormalizedCounter += 1) : ''; | ||||||
|         '_unnormalized' + (unnormalizedCounter += 1) : |  | ||||||
|         ''; |  | ||||||
| 
 | 
 | ||||||
|       return { |       return { | ||||||
|         prefix: prefix, |         prefix: prefix, | ||||||
| @ -496,9 +521,7 @@ export function getRequireJs(): RequireJS { | |||||||
|         url: url, |         url: url, | ||||||
|         originalName: originalName, |         originalName: originalName, | ||||||
|         isDefine: isDefine, |         isDefine: isDefine, | ||||||
|         id: (prefix ? |         id: (prefix ? prefix + '!' + normalizedName : normalizedName) + suffix, | ||||||
|           prefix + '!' + normalizedName : |  | ||||||
|           normalizedName) + suffix |  | ||||||
|       }; |       }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -517,8 +540,7 @@ export function getRequireJs(): RequireJS { | |||||||
|       var id = depMap.id, |       var id = depMap.id, | ||||||
|         mod = getOwn(registry, id); |         mod = getOwn(registry, id); | ||||||
| 
 | 
 | ||||||
|       if (hasProp(defined, id) && |       if (hasProp(defined, id) && (!mod || mod.defineEmitComplete)) { | ||||||
|         (!mod || mod.defineEmitComplete)) { |  | ||||||
|         if (name === 'defined') { |         if (name === 'defined') { | ||||||
|           fn(defined[id]); |           fn(defined[id]); | ||||||
|         } |         } | ||||||
| @ -576,14 +598,14 @@ export function getRequireJs(): RequireJS { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     handlers = { |     handlers = { | ||||||
|       'require': function (mod) { |       require: function (mod) { | ||||||
|         if (mod.require) { |         if (mod.require) { | ||||||
|           return mod.require; |           return mod.require; | ||||||
|         } else { |         } else { | ||||||
|           return (mod.require = context.makeRequire(mod.map)); |           return (mod.require = context.makeRequire(mod.map)); | ||||||
|         } |         } | ||||||
|       }, |       }, | ||||||
|       'exports': function (mod) { |       exports: function (mod) { | ||||||
|         mod.usingExports = true; |         mod.usingExports = true; | ||||||
|         if (mod.map.isDefine) { |         if (mod.map.isDefine) { | ||||||
|           if (mod.exports) { |           if (mod.exports) { | ||||||
| @ -593,7 +615,7 @@ export function getRequireJs(): RequireJS { | |||||||
|           } |           } | ||||||
|         } |         } | ||||||
|       }, |       }, | ||||||
|       'module': function (mod) { |       module: function (mod) { | ||||||
|         if (mod.module) { |         if (mod.module) { | ||||||
|           return mod.module; |           return mod.module; | ||||||
|         } else { |         } else { | ||||||
| @ -603,10 +625,10 @@ export function getRequireJs(): RequireJS { | |||||||
|             config: function () { |             config: function () { | ||||||
|               return getOwn(config.config, mod.map.id) || {}; |               return getOwn(config.config, mod.map.id) || {}; | ||||||
|             }, |             }, | ||||||
|             exports: mod.exports || (mod.exports = {}) |             exports: mod.exports || (mod.exports = {}), | ||||||
|           }); |           }); | ||||||
|         } |         } | ||||||
|       } |       }, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     function cleanRegistry(id) { |     function cleanRegistry(id) { | ||||||
| @ -644,10 +666,11 @@ export function getRequireJs(): RequireJS { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     function checkLoaded() { |     function checkLoaded() { | ||||||
|       var err, usingPathFallback, |       var err, | ||||||
|  |         usingPathFallback, | ||||||
|         waitInterval = config.waitSeconds * 1000, |         waitInterval = config.waitSeconds * 1000, | ||||||
|         //It is possible to disable the wait interval by using waitSeconds of 0.
 |         //It is possible to disable the wait interval by using waitSeconds of 0.
 | ||||||
|         expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), |         expired = waitInterval && context.startTime + waitInterval < new Date().getTime(), | ||||||
|         noLoads = [], |         noLoads = [], | ||||||
|         reqCalls = [], |         reqCalls = [], | ||||||
|         stillLoading = false, |         stillLoading = false, | ||||||
| @ -813,7 +836,7 @@ export function getRequireJs(): RequireJS { | |||||||
|         } |         } | ||||||
|         this.fetched = true; |         this.fetched = true; | ||||||
| 
 | 
 | ||||||
|         context.startTime = (new Date()).getTime(); |         context.startTime = new Date().getTime(); | ||||||
| 
 | 
 | ||||||
|         var map = this.map; |         var map = this.map; | ||||||
| 
 | 
 | ||||||
| @ -821,10 +844,13 @@ export function getRequireJs(): RequireJS { | |||||||
|         //ask the plugin to load it now.
 |         //ask the plugin to load it now.
 | ||||||
|         if (this.shim) { |         if (this.shim) { | ||||||
|           context.makeRequire(this.map, { |           context.makeRequire(this.map, { | ||||||
|             enableBuildCallback: true |             enableBuildCallback: true, | ||||||
|           })(this.shim.deps || [], bind(this, function () { |           })( | ||||||
|  |             this.shim.deps || [], | ||||||
|  |             bind(this, function () { | ||||||
|               return map.prefix ? this.callPlugin() : this.load(); |               return map.prefix ? this.callPlugin() : this.load(); | ||||||
|           })); |             }), | ||||||
|  |           ); | ||||||
|         } else { |         } else { | ||||||
|           //Regular dependency.
 |           //Regular dependency.
 | ||||||
|           return map.prefix ? this.callPlugin() : this.load(); |           return map.prefix ? this.callPlugin() : this.load(); | ||||||
| @ -850,7 +876,8 @@ export function getRequireJs(): RequireJS { | |||||||
|           return; |           return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         var err, cjsModule, |         var err, | ||||||
|  |           cjsModule, | ||||||
|           id = this.map.id, |           id = this.map.id, | ||||||
|           depExports = this.depExports, |           depExports = this.depExports, | ||||||
|           exports = this.exports, |           exports = this.exports, | ||||||
| @ -878,8 +905,7 @@ export function getRequireJs(): RequireJS { | |||||||
|               //errbacks should not be called for failures in
 |               //errbacks should not be called for failures in
 | ||||||
|               //their callbacks (#699). However if a global
 |               //their callbacks (#699). However if a global
 | ||||||
|               //onError is set, use that.
 |               //onError is set, use that.
 | ||||||
|               if ((this.events.error && this.map.isDefine) || |               if ((this.events.error && this.map.isDefine) || req.onError !== defaultOnError) { | ||||||
|                 req.onError !== defaultOnError) { |  | ||||||
|                 try { |                 try { | ||||||
|                   exports = context.execCb(id, factory, depExports, exports); |                   exports = context.execCb(id, factory, depExports, exports); | ||||||
|                 } catch (e) { |                 } catch (e) { | ||||||
| @ -908,7 +934,6 @@ export function getRequireJs(): RequireJS { | |||||||
|                 err.requireType = this.map.isDefine ? 'define' : 'require'; |                 err.requireType = this.map.isDefine ? 'define' : 'require'; | ||||||
|                 return onError((this.error = err)); |                 return onError((this.error = err)); | ||||||
|               } |               } | ||||||
| 
 |  | ||||||
|             } else { |             } else { | ||||||
|               //Just a literal value
 |               //Just a literal value
 | ||||||
|               exports = factory; |               exports = factory; | ||||||
| @ -944,7 +969,6 @@ export function getRequireJs(): RequireJS { | |||||||
|             this.emit('defined', this.exports); |             this.emit('defined', this.exports); | ||||||
|             this.defineEmitComplete = true; |             this.defineEmitComplete = true; | ||||||
|           } |           } | ||||||
| 
 |  | ||||||
|         } |         } | ||||||
|       }, |       }, | ||||||
| 
 | 
 | ||||||
| @ -958,13 +982,18 @@ export function getRequireJs(): RequireJS { | |||||||
|         //can be traced for cycles.
 |         //can be traced for cycles.
 | ||||||
|         this.depMaps.push(pluginMap); |         this.depMaps.push(pluginMap); | ||||||
| 
 | 
 | ||||||
|         on(pluginMap, 'defined', bind(this, function (plugin) { |         on( | ||||||
|           var load, normalizedMap, normalizedMod, |           pluginMap, | ||||||
|  |           'defined', | ||||||
|  |           bind(this, function (plugin) { | ||||||
|  |             var load, | ||||||
|  |               normalizedMap, | ||||||
|  |               normalizedMod, | ||||||
|               bundleId = getOwn(bundlesMap, this.map.id), |               bundleId = getOwn(bundlesMap, this.map.id), | ||||||
|               name = this.map.name, |               name = this.map.name, | ||||||
|               parentName = this.map.parentMap ? this.map.parentMap.name : null, |               parentName = this.map.parentMap ? this.map.parentMap.name : null, | ||||||
|               localRequire = context.makeRequire(map.parentMap, { |               localRequire = context.makeRequire(map.parentMap, { | ||||||
|               enableBuildCallback: true |                 enableBuildCallback: true, | ||||||
|               }); |               }); | ||||||
| 
 | 
 | ||||||
|             //If current map is not normalized, wait for that
 |             //If current map is not normalized, wait for that
 | ||||||
| @ -972,24 +1001,33 @@ export function getRequireJs(): RequireJS { | |||||||
|             if (this.map.unnormalized) { |             if (this.map.unnormalized) { | ||||||
|               //Normalize the ID if the plugin allows it.
 |               //Normalize the ID if the plugin allows it.
 | ||||||
|               if (plugin.normalize) { |               if (plugin.normalize) { | ||||||
|               name = plugin.normalize(name, function (name) { |                 name = | ||||||
|  |                   plugin.normalize(name, function (name) { | ||||||
|                     return normalize(name, parentName, true); |                     return normalize(name, parentName, true); | ||||||
|                   }) || ''; |                   }) || ''; | ||||||
|               } |               } | ||||||
| 
 | 
 | ||||||
|               //prefix and name should already be normalized, no need
 |               //prefix and name should already be normalized, no need
 | ||||||
|               //for applying map config again either.
 |               //for applying map config again either.
 | ||||||
|             normalizedMap = makeModuleMap(map.prefix + '!' + name, |               normalizedMap = makeModuleMap(map.prefix + '!' + name, this.map.parentMap, true); | ||||||
|               this.map.parentMap, |               on( | ||||||
|               true); |                 normalizedMap, | ||||||
|             on(normalizedMap, |                 'defined', | ||||||
|               'defined', bind(this, function (value) { |                 bind(this, function (value) { | ||||||
|                   this.map.normalizedMap = normalizedMap; |                   this.map.normalizedMap = normalizedMap; | ||||||
|                 this.init([], function () { return value; }, null, { |                   this.init( | ||||||
|  |                     [], | ||||||
|  |                     function () { | ||||||
|  |                       return value; | ||||||
|  |                     }, | ||||||
|  |                     null, | ||||||
|  |                     { | ||||||
|                       enabled: true, |                       enabled: true, | ||||||
|                   ignore: true |                       ignore: true, | ||||||
|                 }); |                     }, | ||||||
|               })); |                   ); | ||||||
|  |                 }), | ||||||
|  |               ); | ||||||
| 
 | 
 | ||||||
|               normalizedMod = getOwn(registry, normalizedMap.id); |               normalizedMod = getOwn(registry, normalizedMap.id); | ||||||
|               if (normalizedMod) { |               if (normalizedMod) { | ||||||
| @ -998,9 +1036,12 @@ export function getRequireJs(): RequireJS { | |||||||
|                 this.depMaps.push(normalizedMap); |                 this.depMaps.push(normalizedMap); | ||||||
| 
 | 
 | ||||||
|                 if (this.events.error) { |                 if (this.events.error) { | ||||||
|                 normalizedMod.on('error', bind(this, function (err) { |                   normalizedMod.on( | ||||||
|  |                     'error', | ||||||
|  |                     bind(this, function (err) { | ||||||
|                       this.emit('error', err); |                       this.emit('error', err); | ||||||
|                 })); |                     }), | ||||||
|  |                   ); | ||||||
|                 } |                 } | ||||||
|                 normalizedMod.enable(); |                 normalizedMod.enable(); | ||||||
|               } |               } | ||||||
| @ -1017,9 +1058,16 @@ export function getRequireJs(): RequireJS { | |||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             load = bind(this, function (value) { |             load = bind(this, function (value) { | ||||||
|             this.init([], function () { return value; }, null, { |               this.init( | ||||||
|               enabled: true |                 [], | ||||||
|             }); |                 function () { | ||||||
|  |                   return value; | ||||||
|  |                 }, | ||||||
|  |                 null, | ||||||
|  |                 { | ||||||
|  |                   enabled: true, | ||||||
|  |                 }, | ||||||
|  |               ); | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             load.error = bind(this, function (err) { |             load.error = bind(this, function (err) { | ||||||
| @ -1072,11 +1120,7 @@ export function getRequireJs(): RequireJS { | |||||||
|               try { |               try { | ||||||
|                 req.exec(text); |                 req.exec(text); | ||||||
|               } catch (e) { |               } catch (e) { | ||||||
|               return onError(makeError('fromtexteval', |                 return onError(makeError('fromtexteval', 'fromText eval for ' + id + ' failed: ' + e, e, [id])); | ||||||
|                 'fromText eval for ' + id + |  | ||||||
|                 ' failed: ' + e, |  | ||||||
|                 e, |  | ||||||
|                 [id])); |  | ||||||
|               } |               } | ||||||
| 
 | 
 | ||||||
|               if (hasInteractive) { |               if (hasInteractive) { | ||||||
| @ -1099,7 +1143,8 @@ export function getRequireJs(): RequireJS { | |||||||
|             //could be some weird string with no path that actually wants to
 |             //could be some weird string with no path that actually wants to
 | ||||||
|             //reference the parentName's path.
 |             //reference the parentName's path.
 | ||||||
|             plugin.load(map.name, localRequire, load, config); |             plugin.load(map.name, localRequire, load, config); | ||||||
|         })); |           }), | ||||||
|  |         ); | ||||||
| 
 | 
 | ||||||
|         context.enable(pluginMap, this); |         context.enable(pluginMap, this); | ||||||
|         this.pluginMaps[pluginMap.id] = pluginMap; |         this.pluginMaps[pluginMap.id] = pluginMap; | ||||||
| @ -1116,16 +1161,15 @@ export function getRequireJs(): RequireJS { | |||||||
|         this.enabling = true; |         this.enabling = true; | ||||||
| 
 | 
 | ||||||
|         //Enable each dependency
 |         //Enable each dependency
 | ||||||
|         each(this.depMaps, bind(this, function (depMap, i) { |         each( | ||||||
|  |           this.depMaps, | ||||||
|  |           bind(this, function (depMap, i) { | ||||||
|             var id, mod, handler; |             var id, mod, handler; | ||||||
| 
 | 
 | ||||||
|             if (typeof depMap === 'string') { |             if (typeof depMap === 'string') { | ||||||
|               //Dependency needs to be converted to a depMap
 |               //Dependency needs to be converted to a depMap
 | ||||||
|               //and wired up to this module.
 |               //and wired up to this module.
 | ||||||
|             depMap = makeModuleMap(depMap, |               depMap = makeModuleMap(depMap, this.map.isDefine ? this.map : this.map.parentMap, false, !this.skipMap); | ||||||
|               (this.map.isDefine ? this.map : this.map.parentMap), |  | ||||||
|               false, |  | ||||||
|               !this.skipMap); |  | ||||||
|               this.depMaps[i] = depMap; |               this.depMaps[i] = depMap; | ||||||
| 
 | 
 | ||||||
|               handler = getOwn(handlers, depMap.id); |               handler = getOwn(handlers, depMap.id); | ||||||
| @ -1137,13 +1181,17 @@ export function getRequireJs(): RequireJS { | |||||||
| 
 | 
 | ||||||
|               this.depCount += 1; |               this.depCount += 1; | ||||||
| 
 | 
 | ||||||
|             on(depMap, 'defined', bind(this, function (depExports) { |               on( | ||||||
|  |                 depMap, | ||||||
|  |                 'defined', | ||||||
|  |                 bind(this, function (depExports) { | ||||||
|                   if (this.undefed) { |                   if (this.undefed) { | ||||||
|                     return; |                     return; | ||||||
|                   } |                   } | ||||||
|                   this.defineDep(i, depExports); |                   this.defineDep(i, depExports); | ||||||
|                   this.check(); |                   this.check(); | ||||||
|             })); |                 }), | ||||||
|  |               ); | ||||||
| 
 | 
 | ||||||
|               if (this.errback) { |               if (this.errback) { | ||||||
|                 on(depMap, 'error', bind(this, this.errback)); |                 on(depMap, 'error', bind(this, this.errback)); | ||||||
| @ -1151,9 +1199,13 @@ export function getRequireJs(): RequireJS { | |||||||
|                 // No direct errback on this module, but something
 |                 // No direct errback on this module, but something
 | ||||||
|                 // else is listening for errors, so be sure to
 |                 // else is listening for errors, so be sure to
 | ||||||
|                 // propagate the error correctly.
 |                 // propagate the error correctly.
 | ||||||
|               on(depMap, 'error', bind(this, function (err) { |                 on( | ||||||
|  |                   depMap, | ||||||
|  |                   'error', | ||||||
|  |                   bind(this, function (err) { | ||||||
|                     this.emit('error', err); |                     this.emit('error', err); | ||||||
|               })); |                   }), | ||||||
|  |                 ); | ||||||
|               } |               } | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
| @ -1166,16 +1218,20 @@ export function getRequireJs(): RequireJS { | |||||||
|             if (!hasProp(handlers, id) && mod && !mod.enabled) { |             if (!hasProp(handlers, id) && mod && !mod.enabled) { | ||||||
|               context.enable(depMap, this); |               context.enable(depMap, this); | ||||||
|             } |             } | ||||||
|         })); |           }), | ||||||
|  |         ); | ||||||
| 
 | 
 | ||||||
|         //Enable each plugin that is used in
 |         //Enable each plugin that is used in
 | ||||||
|         //a dependency
 |         //a dependency
 | ||||||
|         eachProp(this.pluginMaps, bind(this, function (pluginMap) { |         eachProp( | ||||||
|  |           this.pluginMaps, | ||||||
|  |           bind(this, function (pluginMap) { | ||||||
|             var mod = getOwn(registry, pluginMap.id); |             var mod = getOwn(registry, pluginMap.id); | ||||||
|             if (mod && !mod.enabled) { |             if (mod && !mod.enabled) { | ||||||
|               context.enable(pluginMap, this); |               context.enable(pluginMap, this); | ||||||
|             } |             } | ||||||
|         })); |           }), | ||||||
|  |         ); | ||||||
| 
 | 
 | ||||||
|         this.enabling = false; |         this.enabling = false; | ||||||
| 
 | 
 | ||||||
| @ -1200,7 +1256,7 @@ export function getRequireJs(): RequireJS { | |||||||
|           //can stay around for a while in the registry.
 |           //can stay around for a while in the registry.
 | ||||||
|           delete this.events[name]; |           delete this.events[name]; | ||||||
|         } |         } | ||||||
|       } |       }, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     function callGetModule(args) { |     function callGetModule(args) { | ||||||
| @ -1243,7 +1299,7 @@ export function getRequireJs(): RequireJS { | |||||||
| 
 | 
 | ||||||
|       return { |       return { | ||||||
|         node: node, |         node: node, | ||||||
|         id: node && node.getAttribute('data-requiremodule') |         id: node && node.getAttribute('data-requiremodule'), | ||||||
|       }; |       }; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -1257,8 +1313,7 @@ export function getRequireJs(): RequireJS { | |||||||
|       while (defQueue.length) { |       while (defQueue.length) { | ||||||
|         args = defQueue.shift(); |         args = defQueue.shift(); | ||||||
|         if (args[0] === null) { |         if (args[0] === null) { | ||||||
|           return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + |           return onError(makeError('mismatch', 'Mismatched anonymous define() module: ' + args[args.length - 1])); | ||||||
|             args[args.length - 1])); |  | ||||||
|         } else { |         } else { | ||||||
|           //args are id, deps, factory. Should be normalized by the
 |           //args are id, deps, factory. Should be normalized by the
 | ||||||
|           //define() function.
 |           //define() function.
 | ||||||
| @ -1308,7 +1363,7 @@ export function getRequireJs(): RequireJS { | |||||||
|             paths: true, |             paths: true, | ||||||
|             bundles: true, |             bundles: true, | ||||||
|             config: true, |             config: true, | ||||||
|             map: true |             map: true, | ||||||
|           }; |           }; | ||||||
| 
 | 
 | ||||||
|         eachProp(cfg, function (value, prop) { |         eachProp(cfg, function (value, prop) { | ||||||
| @ -1339,7 +1394,7 @@ export function getRequireJs(): RequireJS { | |||||||
|             //Normalize the structure
 |             //Normalize the structure
 | ||||||
|             if (isArray(value)) { |             if (isArray(value)) { | ||||||
|               value = { |               value = { | ||||||
|                 deps: value |                 deps: value, | ||||||
|               }; |               }; | ||||||
|             } |             } | ||||||
|             if ((value.exports || value.init) && !value.exportsFn) { |             if ((value.exports || value.init) && !value.exportsFn) { | ||||||
| @ -1368,9 +1423,8 @@ export function getRequireJs(): RequireJS { | |||||||
|             //and remove any trailing .js, since different package
 |             //and remove any trailing .js, since different package
 | ||||||
|             //envs have different conventions: some use a module name,
 |             //envs have different conventions: some use a module name,
 | ||||||
|             //some use a file name.
 |             //some use a file name.
 | ||||||
|             config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main') |             config.pkgs[name] = | ||||||
|               .replace(currDirRegExp, '') |               pkgObj.name + '/' + (pkgObj.main || 'main').replace(currDirRegExp, '').replace(jsSuffixRegExp, ''); | ||||||
|               .replace(jsSuffixRegExp, ''); |  | ||||||
|           }); |           }); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -1439,11 +1493,16 @@ export function getRequireJs(): RequireJS { | |||||||
|             id = map.id; |             id = map.id; | ||||||
| 
 | 
 | ||||||
|             if (!hasProp(defined, id)) { |             if (!hasProp(defined, id)) { | ||||||
|               return onError(makeError('notloaded', 'Module name "' + |               return onError( | ||||||
|  |                 makeError( | ||||||
|  |                   'notloaded', | ||||||
|  |                   'Module name "' + | ||||||
|                     id + |                     id + | ||||||
|                     '" has not been loaded yet for context: ' + |                     '" has not been loaded yet for context: ' + | ||||||
|                     contextName + |                     contextName + | ||||||
|                 (relMap ? '' : '. Use require([])'))); |                     (relMap ? '' : '. Use require([])'), | ||||||
|  |                 ), | ||||||
|  |               ); | ||||||
|             } |             } | ||||||
|             return defined[id]; |             return defined[id]; | ||||||
|           } |           } | ||||||
| @ -1464,7 +1523,7 @@ export function getRequireJs(): RequireJS { | |||||||
|             requireMod.skipMap = options.skipMap; |             requireMod.skipMap = options.skipMap; | ||||||
| 
 | 
 | ||||||
|             requireMod.init(deps, callback, errback, { |             requireMod.init(deps, callback, errback, { | ||||||
|               enabled: true |               enabled: true, | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             checkLoaded(); |             checkLoaded(); | ||||||
| @ -1494,8 +1553,7 @@ export function getRequireJs(): RequireJS { | |||||||
|               moduleNamePlusExt = moduleNamePlusExt.substring(0, index); |               moduleNamePlusExt = moduleNamePlusExt.substring(0, index); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             return context.nameToUrl(normalize(moduleNamePlusExt, |             return context.nameToUrl(normalize(moduleNamePlusExt, relMap && relMap.id, true), ext, true); | ||||||
|               relMap && relMap.id, true), ext, true); |  | ||||||
|           }, |           }, | ||||||
| 
 | 
 | ||||||
|           defined: function (id) { |           defined: function (id) { | ||||||
| @ -1505,7 +1563,7 @@ export function getRequireJs(): RequireJS { | |||||||
|           specified: function (id) { |           specified: function (id) { | ||||||
|             id = makeModuleMap(id, relMap, false, true).id; |             id = makeModuleMap(id, relMap, false, true).id; | ||||||
|             return hasProp(defined, id) || hasProp(registry, id); |             return hasProp(defined, id) || hasProp(registry, id); | ||||||
|           } |           }, | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|         //Only allow undef on top level require calls
 |         //Only allow undef on top level require calls
 | ||||||
| @ -1571,7 +1629,9 @@ export function getRequireJs(): RequireJS { | |||||||
|        * @param {String} moduleName the name of the module to potentially complete. |        * @param {String} moduleName the name of the module to potentially complete. | ||||||
|        */ |        */ | ||||||
|       completeLoad: function (moduleName) { |       completeLoad: function (moduleName) { | ||||||
|         var found, args, mod, |         var found, | ||||||
|  |           args, | ||||||
|  |           mod, | ||||||
|           shim = getOwn(config.shim, moduleName) || {}, |           shim = getOwn(config.shim, moduleName) || {}, | ||||||
|           shExports = shim.exports; |           shExports = shim.exports; | ||||||
| 
 | 
 | ||||||
| @ -1606,15 +1666,12 @@ export function getRequireJs(): RequireJS { | |||||||
|             if (hasPathFallback(moduleName)) { |             if (hasPathFallback(moduleName)) { | ||||||
|               return; |               return; | ||||||
|             } else { |             } else { | ||||||
|               return onError(makeError('nodefine', |               return onError(makeError('nodefine', 'No define call for ' + moduleName, null, [moduleName])); | ||||||
|                 'No define call for ' + moduleName, |  | ||||||
|                 null, |  | ||||||
|                 [moduleName])); |  | ||||||
|             } |             } | ||||||
|           } else { |           } else { | ||||||
|             //A script that does not call define(), so just simulate
 |             //A script that does not call define(), so just simulate
 | ||||||
|             //the call for it.
 |             //the call for it.
 | ||||||
|             callGetModule([moduleName, (shim.deps || []), shim.exportsFn]); |             callGetModule([moduleName, shim.deps || [], shim.exportsFn]); | ||||||
|           } |           } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
| @ -1629,8 +1686,13 @@ export function getRequireJs(): RequireJS { | |||||||
|        * internal API, not a public one. Use toUrl for the public API. |        * internal API, not a public one. Use toUrl for the public API. | ||||||
|        */ |        */ | ||||||
|       nameToUrl: function (moduleName, ext, skipExt) { |       nameToUrl: function (moduleName, ext, skipExt) { | ||||||
|         var paths, syms, i, parentModule, url, |         var paths, | ||||||
|           parentPath, bundleId, |           syms, | ||||||
|  |           i, | ||||||
|  |           parentModule, | ||||||
|  |           url, | ||||||
|  |           parentPath, | ||||||
|  |           bundleId, | ||||||
|           pkgMain = getOwn(config.pkgs, moduleName); |           pkgMain = getOwn(config.pkgs, moduleName); | ||||||
| 
 | 
 | ||||||
|         if (pkgMain) { |         if (pkgMain) { | ||||||
| @ -1677,12 +1739,11 @@ export function getRequireJs(): RequireJS { | |||||||
| 
 | 
 | ||||||
|           //Join the path parts together, then figure out if baseUrl is needed.
 |           //Join the path parts together, then figure out if baseUrl is needed.
 | ||||||
|           url = syms.join('/'); |           url = syms.join('/'); | ||||||
|           url += (ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js')); |           url += ext || (/^data\:|^blob\:|\?/.test(url) || skipExt ? '' : '.js'); | ||||||
|           url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; |           url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return config.urlArgs && !/^blob\:/.test(url) ? |         return config.urlArgs && !/^blob\:/.test(url) ? url + config.urlArgs(moduleName, url) : url; | ||||||
|           url + config.urlArgs(moduleName, url) : url; |  | ||||||
|       }, |       }, | ||||||
| 
 | 
 | ||||||
|       //Delegates to req.load. Broken out as a separate function to
 |       //Delegates to req.load. Broken out as a separate function to
 | ||||||
| @ -1712,8 +1773,7 @@ export function getRequireJs(): RequireJS { | |||||||
|         //Using currentTarget instead of target for Firefox 2.0's sake. Not
 |         //Using currentTarget instead of target for Firefox 2.0's sake. Not
 | ||||||
|         //all old browsers will be supported, but this one was easy enough
 |         //all old browsers will be supported, but this one was easy enough
 | ||||||
|         //to support and still makes sense.
 |         //to support and still makes sense.
 | ||||||
|         if (evt.type === 'load' || |         if (evt.type === 'load' || readyRegExp.test((evt.currentTarget || evt.srcElement).readyState)) { | ||||||
|           (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { |  | ||||||
|           //Reset interactive script so a script node is not held onto for
 |           //Reset interactive script so a script node is not held onto for
 | ||||||
|           //to long.
 |           //to long.
 | ||||||
|           interactiveScript = null; |           interactiveScript = null; | ||||||
| @ -1741,12 +1801,16 @@ export function getRequireJs(): RequireJS { | |||||||
|               }); |               }); | ||||||
|             } |             } | ||||||
|           }); |           }); | ||||||
|           return onError(makeError('scripterror', 'Script error for "' + data.id + |           return onError( | ||||||
|             (parents.length ? |             makeError( | ||||||
|               '", needed by: ' + parents.join(', ') : |               'scripterror', | ||||||
|               '"'), evt, [data.id])); |               'Script error for "' + data.id + (parents.length ? '", needed by: ' + parents.join(', ') : '"'), | ||||||
|         } |               evt, | ||||||
|  |               [data.id], | ||||||
|  |             ), | ||||||
|  |           ); | ||||||
|         } |         } | ||||||
|  |       }, | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|     context.require = context.makeRequire(); |     context.require = context.makeRequire(); | ||||||
| @ -1768,9 +1832,9 @@ export function getRequireJs(): RequireJS { | |||||||
|    * name for minification/local scope use. |    * name for minification/local scope use. | ||||||
|    */ |    */ | ||||||
|   req = requirejs = function (deps, callback, errback, optional) { |   req = requirejs = function (deps, callback, errback, optional) { | ||||||
| 
 |  | ||||||
|     //Find the right context, use default
 |     //Find the right context, use default
 | ||||||
|     var context, config, |     var context, | ||||||
|  |       config, | ||||||
|       contextName = defContextName; |       contextName = defContextName; | ||||||
| 
 | 
 | ||||||
|     // Determine if have config object in the call.
 |     // Determine if have config object in the call.
 | ||||||
| @ -1817,9 +1881,14 @@ export function getRequireJs(): RequireJS { | |||||||
|    * that have a better solution than setTimeout. |    * that have a better solution than setTimeout. | ||||||
|    * @param  {Function} fn function to execute later. |    * @param  {Function} fn function to execute later. | ||||||
|    */ |    */ | ||||||
|   req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) { |   req.nextTick = | ||||||
|  |     typeof setTimeout !== 'undefined' | ||||||
|  |       ? function (fn) { | ||||||
|           setTimeout(fn, 4); |           setTimeout(fn, 4); | ||||||
|   } : function (fn) { fn(); }; |         } | ||||||
|  |       : function (fn) { | ||||||
|  |           fn(); | ||||||
|  |         }; | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
|    * Export require as a global, but only if it does not already exist. |    * Export require as a global, but only if it does not already exist. | ||||||
| @ -1835,19 +1904,14 @@ export function getRequireJs(): RequireJS { | |||||||
|   req.isBrowser = isBrowser; |   req.isBrowser = isBrowser; | ||||||
|   s = req.s = { |   s = req.s = { | ||||||
|     contexts: contexts, |     contexts: contexts, | ||||||
|     newContext: newContext |     newContext: newContext, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   //Create default context.
 |   //Create default context.
 | ||||||
|   req({}); |   req({}); | ||||||
| 
 | 
 | ||||||
|   //Exports some context-sensitive methods on global require.
 |   //Exports some context-sensitive methods on global require.
 | ||||||
|   each([ |   each(['toUrl', 'undef', 'defined', 'specified'], function (prop) { | ||||||
|     'toUrl', |  | ||||||
|     'undef', |  | ||||||
|     'defined', |  | ||||||
|     'specified' |  | ||||||
|   ], function (prop) { |  | ||||||
|     //Reference from contexts instead of early binding to default context,
 |     //Reference from contexts instead of early binding to default context,
 | ||||||
|     //so that during builds, the latest instance of the default context
 |     //so that during builds, the latest instance of the default context
 | ||||||
|     //with its config gets used.
 |     //with its config gets used.
 | ||||||
| @ -1879,9 +1943,9 @@ export function getRequireJs(): RequireJS { | |||||||
|    * Creates the node for the load command. Only used in browser envs. |    * Creates the node for the load command. Only used in browser envs. | ||||||
|    */ |    */ | ||||||
|   req.createNode = function (config, moduleName, url) { |   req.createNode = function (config, moduleName, url) { | ||||||
|     var node = config.xhtml ? |     var node = config.xhtml | ||||||
|       document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : |       ? document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') | ||||||
|       document.createElement('script'); |       : document.createElement('script'); | ||||||
|     node.type = config.scriptType || 'text/javascript'; |     node.type = config.scriptType || 'text/javascript'; | ||||||
|     node.charset = 'utf-8'; |     node.charset = 'utf-8'; | ||||||
|     node.async = true; |     node.async = true; | ||||||
| @ -1915,7 +1979,8 @@ export function getRequireJs(): RequireJS { | |||||||
|       //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
 |       //https://connect.microsoft.com/IE/feedback/details/648057/script-onload-event-is-not-fired-immediately-after-script-execution
 | ||||||
|       //UNFORTUNATELY Opera implements attachEvent but does not follow the script
 |       //UNFORTUNATELY Opera implements attachEvent but does not follow the script
 | ||||||
|       //script execution mode.
 |       //script execution mode.
 | ||||||
|       if (node.attachEvent && |       if ( | ||||||
|  |         node.attachEvent && | ||||||
|         //Check if node.attachEvent is artificially added by custom script or
 |         //Check if node.attachEvent is artificially added by custom script or
 | ||||||
|         //natively supported by browser
 |         //natively supported by browser
 | ||||||
|         //read https://github.com/requirejs/requirejs/issues/187
 |         //read https://github.com/requirejs/requirejs/issues/187
 | ||||||
| @ -1924,7 +1989,8 @@ export function getRequireJs(): RequireJS { | |||||||
|         //Note the test for "[native code" with no closing brace, see:
 |         //Note the test for "[native code" with no closing brace, see:
 | ||||||
|         //https://github.com/requirejs/requirejs/issues/273
 |         //https://github.com/requirejs/requirejs/issues/273
 | ||||||
|         !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && |         !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && | ||||||
|         !isOpera) { |         !isOpera | ||||||
|  |       ) { | ||||||
|         //Probably IE. IE (at least 6-8) do not fire
 |         //Probably IE. IE (at least 6-8) do not fire
 | ||||||
|         //script onload right after executing the script, so
 |         //script onload right after executing the script, so
 | ||||||
|         //we cannot tie the anonymous define call to a name.
 |         //we cannot tie the anonymous define call to a name.
 | ||||||
| @ -1981,17 +2047,15 @@ export function getRequireJs(): RequireJS { | |||||||
|         // Post a task to the event loop to work around a bug in WebKit
 |         // Post a task to the event loop to work around a bug in WebKit
 | ||||||
|         // where the worker gets garbage-collected after calling
 |         // where the worker gets garbage-collected after calling
 | ||||||
|         // importScripts(): https://webkit.org/b/153317
 |         // importScripts(): https://webkit.org/b/153317
 | ||||||
|         setTimeout(function () { }, 0); |         setTimeout(function () {}, 0); | ||||||
|         importScripts(url); |         importScripts(url); | ||||||
| 
 | 
 | ||||||
|         //Account for anonymous modules
 |         //Account for anonymous modules
 | ||||||
|         context.completeLoad(moduleName); |         context.completeLoad(moduleName); | ||||||
|       } catch (e) { |       } catch (e) { | ||||||
|         context.onError(makeError('importscripts', |         context.onError( | ||||||
|           'importScripts failed for ' + |           makeError('importscripts', 'importScripts failed for ' + moduleName + ' at ' + url, e, [moduleName]), | ||||||
|           moduleName + ' at ' + url, |         ); | ||||||
|           e, |  | ||||||
|           [moduleName])); |  | ||||||
|       } |       } | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
| @ -2132,7 +2196,7 @@ export function getRequireJs(): RequireJS { | |||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   define.amd = { |   define.amd = { | ||||||
|     jQuery: true |     jQuery: true, | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   /** |   /** | ||||||
| @ -2150,6 +2214,8 @@ export function getRequireJs(): RequireJS { | |||||||
|   req(cfg); |   req(cfg); | ||||||
| 
 | 
 | ||||||
|   return { |   return { | ||||||
|     requirejs, require, define |     requirejs, | ||||||
|   } |     require, | ||||||
|  |     define, | ||||||
|  |   }; | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| import { FC, ReactNode } from 'react'; | import React, { FC, ReactNode } from 'react'; | ||||||
| import { CollectionProvider } from '../data-source/collection/CollectionProvider'; | 
 | ||||||
| import { CollectionManagerProvider } from '../data-source/collection/CollectionManagerProvider'; |  | ||||||
| import { CollectionOptions } from '../data-source/collection/Collection'; | import { CollectionOptions } from '../data-source/collection/Collection'; | ||||||
| import React from 'react'; | import { CollectionManagerProvider } from '../data-source/collection/CollectionManagerProvider'; | ||||||
|  | import { CollectionProvider } from '../data-source/collection/CollectionProvider'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * @deprecated use `CollectionProvider` instead |  * @deprecated use `CollectionProvider` instead | ||||||
|  | |||||||
| @ -1,17 +1,18 @@ | |||||||
| import { DownOutlined, PlusOutlined } from '@ant-design/icons'; | import React, { useMemo, useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { ISchema, useField, useForm } from '@tachybase/schema'; | import { ISchema, uid, useField, useForm } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
|  | import { DownOutlined, PlusOutlined } from '@ant-design/icons'; | ||||||
| import { Button, Dropdown, MenuProps } from 'antd'; | import { Button, Dropdown, MenuProps } from 'antd'; | ||||||
| import { cloneDeep } from 'lodash'; | import { cloneDeep } from 'lodash'; | ||||||
| import React, { useMemo, useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useRequest } from '../../api-client'; | import { useRequest } from '../../api-client'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | ||||||
| import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; |  | ||||||
| import { useCancelAction } from '../action-hooks'; | import { useCancelAction } from '../action-hooks'; | ||||||
| import { useCollectionManager_deprecated } from '../hooks'; | import { useCollectionManager_deprecated } from '../hooks'; | ||||||
|  | import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; | ||||||
| import * as components from './components'; | import * as components from './components'; | ||||||
| import { TemplateSummary } from './components/TemplateSummary'; | import { TemplateSummary } from './components/TemplateSummary'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,19 +1,20 @@ | |||||||
| import { PlusOutlined } from '@ant-design/icons'; | import React, { useCallback, useMemo, useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { useField, useForm } from '@tachybase/schema'; | import { uid, useField, useForm } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
|  | import { PlusOutlined } from '@ant-design/icons'; | ||||||
| import { Button, Dropdown, MenuProps } from 'antd'; | import { Button, Dropdown, MenuProps } from 'antd'; | ||||||
| import { cloneDeep } from 'lodash'; | import { cloneDeep } from 'lodash'; | ||||||
| import React, { useCallback, useMemo, useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useRequest } from '../../api-client'; | import { useRequest } from '../../api-client'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | ||||||
| import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; |  | ||||||
| import { useCancelAction } from '../action-hooks'; | import { useCancelAction } from '../action-hooks'; | ||||||
| import { useCollectionManager_deprecated } from '../hooks'; | import { useCollectionManager_deprecated } from '../hooks'; | ||||||
| import useDialect from '../hooks/useDialect'; | import useDialect from '../hooks/useDialect'; | ||||||
| import { IField } from '../interfaces/types'; | import { IField } from '../interfaces/types'; | ||||||
|  | import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; | ||||||
| import * as components from './components'; | import * as components from './components'; | ||||||
| import { useFieldInterfaceOptions } from './interfaces'; | import { useFieldInterfaceOptions } from './interfaces'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,11 +1,12 @@ | |||||||
| import { PlusOutlined } from '@ant-design/icons'; | import React, { useMemo, useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { ISchema } from '@tachybase/schema'; | import { ISchema, uid } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
|  | import { PlusOutlined } from '@ant-design/icons'; | ||||||
| import { Button, Dropdown, MenuProps } from 'antd'; | import { Button, Dropdown, MenuProps } from 'antd'; | ||||||
| import { cloneDeep } from 'lodash'; | import { cloneDeep } from 'lodash'; | ||||||
| import React, { useMemo, useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useRequest } from '../../api-client'; | import { useRequest } from '../../api-client'; | ||||||
| import { useCollectionRecordData } from '../../data-source'; | import { useCollectionRecordData } from '../../data-source'; | ||||||
| import { RecordProvider } from '../../record-provider'; | import { RecordProvider } from '../../record-provider'; | ||||||
|  | |||||||
| @ -1,17 +1,18 @@ | |||||||
|  | import React, { useEffect, useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { ISchema, useForm } from '@tachybase/schema'; | import { ISchema, uid, useForm } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
| import cloneDeep from 'lodash/cloneDeep'; | import cloneDeep from 'lodash/cloneDeep'; | ||||||
| import omit from 'lodash/omit'; | import omit from 'lodash/omit'; | ||||||
| import React, { useEffect, useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useAPIClient, useRequest } from '../../api-client'; | import { useAPIClient, useRequest } from '../../api-client'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | ||||||
| import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; |  | ||||||
| import { useCancelAction } from '../action-hooks'; | import { useCancelAction } from '../action-hooks'; | ||||||
| import { useCollectionManager_deprecated } from '../hooks'; | import { useCollectionManager_deprecated } from '../hooks'; | ||||||
| import { IField } from '../interfaces/types'; | import { IField } from '../interfaces/types'; | ||||||
|  | import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; | ||||||
| import * as components from './components'; | import * as components from './components'; | ||||||
| 
 | 
 | ||||||
| const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { | const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { | ||||||
|  | |||||||
| @ -1,20 +1,21 @@ | |||||||
|  | import React, { useMemo, useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { ISchema, useForm } from '@tachybase/schema'; | import { ISchema, uid, useForm } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
| import cloneDeep from 'lodash/cloneDeep'; | import cloneDeep from 'lodash/cloneDeep'; | ||||||
| import omit from 'lodash/omit'; | import omit from 'lodash/omit'; | ||||||
| import set from 'lodash/set'; | import set from 'lodash/set'; | ||||||
| import React, { useMemo, useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useAPIClient, useRequest } from '../../api-client'; | import { useAPIClient, useRequest } from '../../api-client'; | ||||||
| import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider'; | import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | ||||||
| import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; |  | ||||||
| import { useCancelAction } from '../action-hooks'; | import { useCancelAction } from '../action-hooks'; | ||||||
| import { useCollectionManager_deprecated } from '../hooks'; | import { useCollectionManager_deprecated } from '../hooks'; | ||||||
| import useDialect from '../hooks/useDialect'; | import useDialect from '../hooks/useDialect'; | ||||||
| import { IField } from '../interfaces/types'; | import { IField } from '../interfaces/types'; | ||||||
|  | import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; | ||||||
| import * as components from './components'; | import * as components from './components'; | ||||||
| 
 | 
 | ||||||
| const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { | const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { | ||||||
|  | |||||||
| @ -1,9 +1,10 @@ | |||||||
| import { ArrayTable } from '@tachybase/components'; |  | ||||||
| import { ISchema, useForm } from '@tachybase/schema'; |  | ||||||
| import { uid } from '@tachybase/schema'; |  | ||||||
| import cloneDeep from 'lodash/cloneDeep'; |  | ||||||
| import React, { useState } from 'react'; | import React, { useState } from 'react'; | ||||||
|  | import { ArrayTable } from '@tachybase/components'; | ||||||
|  | import { ISchema, uid, useForm } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import cloneDeep from 'lodash/cloneDeep'; | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useAPIClient, useRequest } from '../../api-client'; | import { useAPIClient, useRequest } from '../../api-client'; | ||||||
| import { useRecord } from '../../record-provider'; | import { useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, SchemaComponent } from '../../schema-component'; | import { ActionContextProvider, SchemaComponent } from '../../schema-component'; | ||||||
|  | |||||||
| @ -1,18 +1,19 @@ | |||||||
|  | import React, { useMemo, useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { ISchema, useForm } from '@tachybase/schema'; | import { ISchema, uid, useForm } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
| import { omit, set } from 'lodash'; | import { omit, set } from 'lodash'; | ||||||
| import cloneDeep from 'lodash/cloneDeep'; | import cloneDeep from 'lodash/cloneDeep'; | ||||||
| import React, { useMemo, useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useAPIClient, useRequest } from '../../api-client'; | import { useAPIClient, useRequest } from '../../api-client'; | ||||||
| import { useCollectionParentRecordData } from '../../data-source'; | import { useCollectionParentRecordData } from '../../data-source'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | ||||||
| import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; |  | ||||||
| import { useCancelAction } from '../action-hooks'; | import { useCancelAction } from '../action-hooks'; | ||||||
| import { useCollectionManager_deprecated } from '../hooks'; | import { useCollectionManager_deprecated } from '../hooks'; | ||||||
| import { IField } from '../interfaces/types'; | import { IField } from '../interfaces/types'; | ||||||
|  | import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; | ||||||
| import * as components from './components'; | import * as components from './components'; | ||||||
| 
 | 
 | ||||||
| const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { | const getSchema = (schema: IField, record: any, compile, getContainer): ISchema => { | ||||||
|  | |||||||
| @ -1,18 +1,19 @@ | |||||||
| import { PlusOutlined } from '@ant-design/icons'; | import React, { useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { useField, useForm } from '@tachybase/schema'; | import { uid, useField, useForm } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
|  | import { PlusOutlined } from '@ant-design/icons'; | ||||||
| import { Button } from 'antd'; | import { Button } from 'antd'; | ||||||
| import { cloneDeep } from 'lodash'; | import { cloneDeep } from 'lodash'; | ||||||
| import React, { useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useAPIClient, useRequest } from '../../api-client'; | import { useAPIClient, useRequest } from '../../api-client'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | import { ActionContextProvider, SchemaComponent, useActionContext, useCompile } from '../../schema-component'; | ||||||
| import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; |  | ||||||
| import { useCancelAction } from '../action-hooks'; | import { useCancelAction } from '../action-hooks'; | ||||||
| import { useCollectionManager_deprecated } from '../hooks'; | import { useCollectionManager_deprecated } from '../hooks'; | ||||||
| import { IField } from '../interfaces/types'; | import { IField } from '../interfaces/types'; | ||||||
|  | import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; | ||||||
| import { PreviewFields } from '../templates/components/PreviewFields'; | import { PreviewFields } from '../templates/components/PreviewFields'; | ||||||
| import { PreviewTable } from '../templates/components/PreviewTable'; | import { PreviewTable } from '../templates/components/PreviewTable'; | ||||||
| import * as components from './components'; | import * as components from './components'; | ||||||
|  | |||||||
| @ -1,18 +1,18 @@ | |||||||
| import { SyncOutlined } from '@ant-design/icons'; |  | ||||||
| import { FormLayout } from '@tachybase/components'; |  | ||||||
| import { createForm } from '@tachybase/schema'; |  | ||||||
| import { useField, useForm } from '@tachybase/schema'; |  | ||||||
| import { uid } from '@tachybase/schema'; |  | ||||||
| import { Button } from 'antd'; |  | ||||||
| import React, { useMemo, useState } from 'react'; | import React, { useMemo, useState } from 'react'; | ||||||
|  | import { FormLayout } from '@tachybase/components'; | ||||||
|  | import { createForm, uid, useField, useForm } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { SyncOutlined } from '@ant-design/icons'; | ||||||
|  | import { Button } from 'antd'; | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useAPIClient } from '../../api-client'; | import { useAPIClient } from '../../api-client'; | ||||||
| import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider'; | import { useCollectionParentRecordData } from '../../data-source/collection-record/CollectionRecordProvider'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
| import { ActionContextProvider, FormProvider, SchemaComponent, useActionContext } from '../../schema-component'; | import { ActionContextProvider, FormProvider, SchemaComponent, useActionContext } from '../../schema-component'; | ||||||
| import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; |  | ||||||
| import { useCancelAction } from '../action-hooks'; | import { useCancelAction } from '../action-hooks'; | ||||||
| import { useCollectionManager_deprecated } from '../hooks/useCollectionManager_deprecated'; | import { useCollectionManager_deprecated } from '../hooks/useCollectionManager_deprecated'; | ||||||
|  | import { useResourceActionContext, useResourceContext } from '../ResourceActionProvider'; | ||||||
| import { FieldsConfigure, PreviewTable, SQLRequestProvider } from '../templates/components/sql-collection'; | import { FieldsConfigure, PreviewTable, SQLRequestProvider } from '../templates/components/sql-collection'; | ||||||
| 
 | 
 | ||||||
| const schema = { | const schema = { | ||||||
|  | |||||||
| @ -1,10 +1,11 @@ | |||||||
|  | import React, { useMemo, useState } from 'react'; | ||||||
| import { ArrayTable } from '@tachybase/components'; | import { ArrayTable } from '@tachybase/components'; | ||||||
| import { ISchema } from '@tachybase/schema'; | import { ISchema, uid } from '@tachybase/schema'; | ||||||
| import { uid } from '@tachybase/schema'; | 
 | ||||||
| import cloneDeep from 'lodash/cloneDeep'; | import cloneDeep from 'lodash/cloneDeep'; | ||||||
| import set from 'lodash/set'; | import set from 'lodash/set'; | ||||||
| import React, { useMemo, useState } from 'react'; |  | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useAPIClient, useRequest } from '../../api-client'; | import { useAPIClient, useRequest } from '../../api-client'; | ||||||
| import { useCollectionParentRecordData } from '../../data-source'; | import { useCollectionParentRecordData } from '../../data-source'; | ||||||
| import { RecordProvider, useRecord } from '../../record-provider'; | import { RecordProvider, useRecord } from '../../record-provider'; | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { observer } from '@tachybase/schema'; |  | ||||||
| import { Tag } from 'antd'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { observer } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { Tag } from 'antd'; | ||||||
|  | 
 | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| 
 | 
 | ||||||
| export const CollectionCategory = observer( | export const CollectionCategory = observer( | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { observer } from '@tachybase/schema'; |  | ||||||
| import { Tag } from 'antd'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { observer } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { Tag } from 'antd'; | ||||||
|  | 
 | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| import { useCollectionManager_deprecated } from '../../hooks'; | import { useCollectionManager_deprecated } from '../../hooks'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { observer } from '@tachybase/schema'; |  | ||||||
| import { Tag } from 'antd'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { observer } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { Tag } from 'antd'; | ||||||
|  | 
 | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| import { useCollectionManager_deprecated } from '../../hooks'; | import { useCollectionManager_deprecated } from '../../hooks'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| import React, { useMemo } from 'react'; | import React, { useMemo } from 'react'; | ||||||
|  | 
 | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useCollectionManager_deprecated } from '../../hooks'; | import { useCollectionManager_deprecated } from '../../hooks'; | ||||||
| import Summary from './Summary'; | import Summary from './Summary'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,9 @@ | |||||||
|  | import React, { useMemo } from 'react'; | ||||||
| import { observer } from '@tachybase/schema'; | import { observer } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
| import { Tag } from 'antd'; | import { Tag } from 'antd'; | ||||||
| import { useAntdToken } from 'antd-style'; | import { useAntdToken } from 'antd-style'; | ||||||
| import React, { useMemo } from 'react'; | 
 | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| 
 | 
 | ||||||
| const Summary = observer( | const Summary = observer( | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| import React, { useMemo } from 'react'; | import React, { useMemo } from 'react'; | ||||||
|  | 
 | ||||||
| import { useTranslation } from 'react-i18next'; | import { useTranslation } from 'react-i18next'; | ||||||
|  | 
 | ||||||
| import { useCollectionManager_deprecated } from '../../hooks'; | import { useCollectionManager_deprecated } from '../../hooks'; | ||||||
| import Summary from './Summary'; | import Summary from './Summary'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,7 +1,8 @@ | |||||||
| import { Field } from '@tachybase/schema'; | import React, { useEffect, useState } from 'react'; | ||||||
| import { observer, useField, useForm } from '@tachybase/schema'; | import { Field, observer, useField, useForm } from '@tachybase/schema'; | ||||||
| import { Select, AutoComplete } from 'antd'; | 
 | ||||||
| import React, { useState, useEffect } from 'react'; | import { AutoComplete, Select } from 'antd'; | ||||||
|  | 
 | ||||||
| import { useRecord } from '../../../record-provider'; | import { useRecord } from '../../../record-provider'; | ||||||
| import { useCompile } from '../../../schema-component'; | import { useCompile } from '../../../schema-component'; | ||||||
| import { useCollectionManager_deprecated } from '../../hooks'; | import { useCollectionManager_deprecated } from '../../hooks'; | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface'; |  | ||||||
| import { useMemo } from 'react'; | import { useMemo } from 'react'; | ||||||
|  | 
 | ||||||
|  | import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface'; | ||||||
| import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider'; | import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider'; | ||||||
| 
 | 
 | ||||||
| export const getOptions = ( | export const getOptions = ( | ||||||
|  | |||||||
| @ -1,6 +1,8 @@ | |||||||
| import { useField } from '@tachybase/schema'; |  | ||||||
| import { Result } from 'ahooks/es/useRequest/src/types'; |  | ||||||
| import React, { createContext, useContext, useEffect } from 'react'; | import React, { createContext, useContext, useEffect } from 'react'; | ||||||
|  | import { useField } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { Result } from 'ahooks/es/useRequest/src/types'; | ||||||
|  | 
 | ||||||
| import { useCollectionManager_deprecated } from '.'; | import { useCollectionManager_deprecated } from '.'; | ||||||
| import { CollectionProvider_deprecated, useRecord } from '..'; | import { CollectionProvider_deprecated, useRecord } from '..'; | ||||||
| import { useAPIClient, useRequest } from '../api-client'; | import { useAPIClient, useRequest } from '../api-client'; | ||||||
|  | |||||||
| @ -1,5 +1,4 @@ | |||||||
| import { FormItem, Input } from '@tachybase/components'; | import React from 'react'; | ||||||
| import { ISchema, observer, useForm } from '@tachybase/schema'; |  | ||||||
| import { | import { | ||||||
|   Action, |   Action, | ||||||
|   CollectionField, |   CollectionField, | ||||||
| @ -8,7 +7,8 @@ import { | |||||||
|   SchemaComponent, |   SchemaComponent, | ||||||
|   SchemaComponentProvider, |   SchemaComponentProvider, | ||||||
| } from '@tachybase/client'; | } from '@tachybase/client'; | ||||||
| import React from 'react'; | import { FormItem, Input } from '@tachybase/components'; | ||||||
|  | import { ISchema, observer, useForm } from '@tachybase/schema'; | ||||||
| 
 | 
 | ||||||
| export default observer(() => { | export default observer(() => { | ||||||
|   const collection = { |   const collection = { | ||||||
|  | |||||||
| @ -8,6 +8,7 @@ import { | |||||||
|   RecordProvider, |   RecordProvider, | ||||||
|   useCollectionField_deprecated, |   useCollectionField_deprecated, | ||||||
| } from '@tachybase/client'; | } from '@tachybase/client'; | ||||||
|  | 
 | ||||||
| import MockAdapter from 'axios-mock-adapter'; | import MockAdapter from 'axios-mock-adapter'; | ||||||
| 
 | 
 | ||||||
| const apiClient = new APIClient(); | const apiClient = new APIClient(); | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| import { ISchema } from '@tachybase/schema'; | import React from 'react'; | ||||||
| import { | import { | ||||||
|   AntdSchemaComponentProvider, |   AntdSchemaComponentProvider, | ||||||
|   ExtendCollectionsProvider, |   ExtendCollectionsProvider, | ||||||
|   SchemaComponent, |   SchemaComponent, | ||||||
|   SchemaComponentProvider, |   SchemaComponentProvider, | ||||||
| } from '@tachybase/client'; | } from '@tachybase/client'; | ||||||
| import React from 'react'; | import { ISchema } from '@tachybase/schema'; | ||||||
| 
 | 
 | ||||||
| const schema: ISchema = { | const schema: ISchema = { | ||||||
|   type: 'object', |   type: 'object', | ||||||
|  | |||||||
| @ -1,14 +1,10 @@ | |||||||
| import { FormDrawer, FormLayout } from '@tachybase/components'; | import React, { useContext } from 'react'; | ||||||
| import { createForm } from '@tachybase/schema'; |  | ||||||
| import { ISchema } from '@tachybase/schema'; |  | ||||||
| import { FormContext, SchemaOptionsContext } from '@tachybase/schema'; |  | ||||||
| import { uid } from '@tachybase/schema'; |  | ||||||
| import { | import { | ||||||
|   AntdSchemaComponentProvider, |   AntdSchemaComponentProvider, | ||||||
|   Application, |   Application, | ||||||
|   CardItem, |   CardItem, | ||||||
|   CollectionManagerProvider_deprecated, |  | ||||||
|   CollectionManagerProvider, |   CollectionManagerProvider, | ||||||
|  |   CollectionManagerProvider_deprecated, | ||||||
|   CollectionProvider_deprecated, |   CollectionProvider_deprecated, | ||||||
|   FormItem, |   FormItem, | ||||||
|   Grid, |   Grid, | ||||||
| @ -20,13 +16,15 @@ import { | |||||||
|   SchemaComponentOptions, |   SchemaComponentOptions, | ||||||
|   SchemaInitializer, |   SchemaInitializer, | ||||||
|   SchemaInitializerItem, |   SchemaInitializerItem, | ||||||
|   useCollectionManager_deprecated, |  | ||||||
|   useCollectionManager, |   useCollectionManager, | ||||||
|  |   useCollectionManager_deprecated, | ||||||
|   useSchemaInitializer, |   useSchemaInitializer, | ||||||
|   useSchemaInitializerItem, |   useSchemaInitializerItem, | ||||||
| } from '@tachybase/client'; | } from '@tachybase/client'; | ||||||
|  | import { FormDrawer, FormLayout } from '@tachybase/components'; | ||||||
|  | import { createForm, FormContext, ISchema, SchemaOptionsContext, uid } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
| import { cloneDeep } from 'lodash'; | import { cloneDeep } from 'lodash'; | ||||||
| import React, { useContext } from 'react'; |  | ||||||
| 
 | 
 | ||||||
| const collection: any = { | const collection: any = { | ||||||
|   name: 'posts', |   name: 'posts', | ||||||
|  | |||||||
| @ -1,14 +1,16 @@ | |||||||
|  | import { useCallback, useMemo, useState } from 'react'; | ||||||
|  | import { uid } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
| import { CascaderProps } from 'antd'; | import { CascaderProps } from 'antd'; | ||||||
| import _ from 'lodash'; | import _ from 'lodash'; | ||||||
| import { useCallback, useMemo, useState } from 'react'; | 
 | ||||||
| import { useCompile, useSchemaComponentContext } from '../../schema-component'; | import { useCollectionManager } from '../../data-source/collection/CollectionManagerProvider'; | ||||||
| import { CollectionFieldOptions_deprecated, CollectionOptions } from '../types'; | import { DEFAULT_DATA_SOURCE_KEY } from '../../data-source/data-source/DataSourceManager'; | ||||||
| import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin'; |  | ||||||
| import { uid } from '@tachybase/schema'; |  | ||||||
| import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider'; | import { useDataSourceManager } from '../../data-source/data-source/DataSourceManagerProvider'; | ||||||
| import { useDataSource } from '../../data-source/data-source/DataSourceProvider'; | import { useDataSource } from '../../data-source/data-source/DataSourceProvider'; | ||||||
| import { DEFAULT_DATA_SOURCE_KEY } from '../../data-source/data-source/DataSourceManager'; | import { useCompile, useSchemaComponentContext } from '../../schema-component'; | ||||||
| import { useCollectionManager } from '../../data-source/collection/CollectionManagerProvider'; | import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin'; | ||||||
|  | import { CollectionFieldOptions_deprecated, CollectionOptions } from '../types'; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * @deprecated use `useCollectionManager` instead |  * @deprecated use `useCollectionManager` instead | ||||||
|  | |||||||
| @ -1,8 +1,9 @@ | |||||||
| import { SchemaKey } from '@tachybase/schema'; |  | ||||||
| import { useAPIClient } from '../../api-client'; |  | ||||||
| import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin'; |  | ||||||
| import { useCallback, useMemo } from 'react'; | import { useCallback, useMemo } from 'react'; | ||||||
|  | import { SchemaKey } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
|  | import { useAPIClient } from '../../api-client'; | ||||||
| import { useCollection } from '../../data-source/collection/CollectionProvider'; | import { useCollection } from '../../data-source/collection/CollectionProvider'; | ||||||
|  | import { InheritanceCollectionMixin } from '../mixins/InheritanceCollectionMixin'; | ||||||
| 
 | 
 | ||||||
| export type Collection_deprecated = ReturnType<typeof useCollection_deprecated>; | export type Collection_deprecated = ReturnType<typeof useCollection_deprecated>; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| import { render, screen, waitFor } from '@tachybase/test/client'; |  | ||||||
| import React from 'react'; | import React from 'react'; | ||||||
|  | import { render, screen, waitFor } from '@tachybase/test/client'; | ||||||
|  | 
 | ||||||
| import { CurrentAppInfoContext } from '../../../appInfo'; | import { CurrentAppInfoContext } from '../../../appInfo'; | ||||||
| import { Checkbox } from '../../../schema-component/antd/checkbox'; | import { Checkbox } from '../../../schema-component/antd/checkbox'; | ||||||
| import { Input } from '../../../schema-component/antd/input'; | import { Input } from '../../../schema-component/antd/input'; | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { ISchema } from '@tachybase/schema'; | import { ISchema } from '@tachybase/schema'; | ||||||
|  | 
 | ||||||
| import { defaultProps, operators } from '../'; | import { defaultProps, operators } from '../'; | ||||||
| import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface'; | import { CollectionFieldInterface } from '../../data-source/collection-field-interface/CollectionFieldInterface'; | ||||||
| 
 | 
 | ||||||
|  | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
		Reference in New Issue
	
	Block a user