zova-cli-set-front 1.1.180 → 1.1.182

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  file: 'controller.ts',
3
3
  parseOptions: { language: 'plain' },
4
- async transform({ ast }) {
4
+ async transform({ cli, ast }) {
5
5
  if (ast.includes('export type Emits')) throw new Error('Emits exists');
6
6
  const matchController = ast.match(/export class ([^< ]*)(.*?) extends/);
7
7
  // const className = matchController[1];
@@ -11,8 +11,8 @@ module.exports = {
11
11
  //
12
12
  ast = ast.replace('@Local', `export type Emits${genericT2} = {};\n\n@Local`);
13
13
  // BeanControllerBase
14
- ast = ast.replace(/BeanControllerBase<(.*?)> \{/, (_, $1) => {
15
- const parts = $1.split(',');
14
+ ast = ast.replace(/BeanControllerBase<([\s\S]*?)> \{/, (_, $1) => {
15
+ const parts = cli.helper.safeSplit($1, ',');
16
16
  if (!parts[1]) parts[1] = ' unknown';
17
17
  parts[2] = ` Emits${genericT}`;
18
18
  return `BeanControllerBase<${parts.join(',')}> {`;
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  file: 'controller.ts',
3
3
  parseOptions: { language: 'plain' },
4
- async transform({ ast }) {
4
+ async transform({ cli, ast }) {
5
5
  if (ast.includes('export interface Props<')) return;
6
6
  const matchController = ast.match(/export class (.*?) extends/);
7
7
  const className = matchController[1];
@@ -13,11 +13,11 @@ module.exports = {
13
13
  .replace('export interface Slots', 'export interface Slots<_T>')
14
14
  .replace(`export class ${className}`, `export class ${className}<T = unknown>`);
15
15
  // BeanControllerBase
16
- ast = ast.replace(/BeanControllerBase<(.*?)> \{/, (_, $1) => {
17
- const parts = $1.split(',');
18
- if (parts[1] === ' Props') parts[1] = ' Props<T>';
19
- if (parts[2] === ' Emits') parts[2] = ' Emits<T>';
20
- if (parts[3] === ' Slots') parts[3] = ' Slots<T>';
16
+ ast = ast.replace(/BeanControllerBase<([\s\S]*?)> \{/, (_, $1) => {
17
+ const parts = cli.helper.safeSplit($1, ',');
18
+ if (parts[1]?.includes('Props')) parts[1] = parts[1].replace('Props', 'Props<T>');
19
+ if (parts[2]?.includes('Emits')) parts[2] = parts[2].replace('Emits', 'Emits<T>');
20
+ if (parts[3]?.includes('Slots')) parts[3] = parts[3].replace('Slots', 'Slots<T>');
21
21
  return `BeanControllerBase<${parts.join(',')}> {`;
22
22
  });
23
23
  // ok
@@ -23,7 +23,7 @@ module.exports = {
23
23
  return `${localName}: number;\n\n ${$0}`;
24
24
  });
25
25
  ast = ast.replace(/protected async __init__([^\{]*) \{/, $0 => {
26
- return `${$0}\n this.${localName} = this.$useModel(${modelName === 'modelValue' ? '' : `'${modelName}'`})!;`;
26
+ return `${$0}\n this.${localName} = this.$useModel(${modelName === 'modelValue' ? '' : `'${modelName}'`});`;
27
27
  });
28
28
  // ok
29
29
  return ast;
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  file: 'controller.ts',
3
3
  parseOptions: { language: 'plain' },
4
- async transform({ ast }) {
4
+ async transform({ cli, ast }) {
5
5
  if (ast.includes('export interface Props')) throw new Error('Props exists');
6
6
  const matchController = ast.match(/export class ([^< ]*)(.*?) extends/);
7
7
  const className = matchController[1];
@@ -15,14 +15,21 @@ module.exports = {
15
15
  return `import { ${$1}, PropsBase } from 'zova';`;
16
16
  });
17
17
  }
18
+ // RequiredSome
19
+ if (!ast.match(/import \{[^\}]*RequiredSome[^\}]*\} from 'zova';/)) {
20
+ ast = ast.replace(/import \{ ([^\}]*) \} from 'zova';/, (_, $1) => {
21
+ return `import { ${$1}, RequiredSome } from 'zova';`;
22
+ });
23
+ }
24
+ // Props
18
25
  ast = ast.replace(
19
26
  '@Local',
20
27
  `export interface Props${hasSlots ? genericT : genericT2} extends PropsBase<${className}${genericT}${hasSlots ? `, Slots${genericT}` : ''}> {}\n\n@Local`,
21
28
  );
22
29
  // BeanControllerBase
23
- ast = ast.replace(/BeanControllerBase<(.*?)> \{/, (_, $1) => {
24
- const parts = $1.split(',');
25
- parts[1] = ` Props${genericT}`;
30
+ ast = ast.replace(/BeanControllerBase<([\s\S]*?)> \{/, (_, $1) => {
31
+ const parts = cli.helper.safeSplit($1, ',');
32
+ parts[1] = ` RequiredSome<Props${genericT}, keyof typeof ${className}.$propsDefault>`;
26
33
  return `BeanControllerBase<${parts.join(',')}> {\n static $propsDefault = {};\n\n`;
27
34
  });
28
35
  // ok
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
2
  file: 'controller.ts',
3
3
  parseOptions: { language: 'plain' },
4
- async transform({ ast }) {
4
+ async transform({ cli, ast }) {
5
5
  if (ast.includes('export interface Slots')) throw new Error('Slots exists');
6
6
  const matchController = ast.match(/export class ([^< ]*)(.*?) extends/);
7
7
  // const className = matchController[1];
@@ -22,8 +22,8 @@ module.exports = {
22
22
  // Slots
23
23
  ast = ast.replace('@Local', `export interface Slots${genericT2} {}\n\n@Local`);
24
24
  // BeanControllerBase
25
- ast = ast.replace(/BeanControllerBase<(.*?)> \{/, (_, $1) => {
26
- const parts = $1.split(',');
25
+ ast = ast.replace(/BeanControllerBase<([\s\S]*?)> \{/, (_, $1) => {
26
+ const parts = cli.helper.safeSplit($1, ',');
27
27
  if (!parts[1]) parts[1] = ' unknown';
28
28
  if (!parts[2]) parts[2] = ' unknown';
29
29
  parts[3] = ` Slots${genericT}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zova-cli-set-front",
3
- "version": "1.1.180",
3
+ "version": "1.1.182",
4
4
  "description": "zova cli-set-front",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -48,5 +48,5 @@
48
48
  "zova-shared": "^1.0.4",
49
49
  "zova-vite": "^1.0.176"
50
50
  },
51
- "gitHead": "2b22e9148dc8348edb6321e415184a7b83ace284"
51
+ "gitHead": "e9e4c722b0aa3d259dd1d3d89a5868171154de43"
52
52
  }