@maxelms/create-plugin-cli 1.1.26 → 1.1.27

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.
Files changed (92) hide show
  1. package/package.json +1 -1
  2. package/templates/angular-micro-app/.eslintrc.js +3 -0
  3. package/templates/angular-micro-app/README.md +5 -0
  4. package/templates/angular-micro-app/examples/main.css +2 -0
  5. package/templates/angular-micro-app/examples/main.js +2 -0
  6. package/templates/angular-micro-app/examples/main.js.LICENSE.txt +52 -0
  7. package/templates/angular-micro-app/examples/playground.html +1 -0
  8. package/templates/angular-micro-app/examples/react-dom.production.min.js +2 -0
  9. package/templates/angular-micro-app/examples/react-dom.production.min.js.LICENSE.txt +8 -0
  10. package/templates/angular-micro-app/examples/react.production.min.js +2 -0
  11. package/templates/angular-micro-app/examples/react.production.min.js.LICENSE.txt +8 -0
  12. package/templates/angular-micro-app/examples/vue.runtime.global.js +9054 -0
  13. package/templates/angular-micro-app/examples/zone.umd.min.js +2 -0
  14. package/templates/angular-micro-app/examples/zone.umd.min.js.LICENSE.txt +29 -0
  15. package/templates/angular-micro-app/manifest.json.tpl +3 -0
  16. package/templates/angular-micro-app/package.json.tpl +40 -0
  17. package/templates/angular-micro-app/pnpm-lock.yaml +7998 -0
  18. package/templates/angular-micro-app/public/configuration.json +34 -0
  19. package/templates/angular-micro-app/public/index.html.tpl +15 -0
  20. package/templates/angular-micro-app/src/about.component.ts +42 -0
  21. package/templates/angular-micro-app/src/app-routing.module.ts +12 -0
  22. package/templates/angular-micro-app/src/app.component.css +22 -0
  23. package/templates/angular-micro-app/src/app.component.html +304 -0
  24. package/templates/angular-micro-app/src/app.component.ts +42 -0
  25. package/templates/angular-micro-app/src/app.module.ts +27 -0
  26. package/templates/angular-micro-app/src/contact.component.ts +42 -0
  27. package/templates/angular-micro-app/src/home.component.ts +42 -0
  28. package/templates/angular-micro-app/src/index.ts +54 -0
  29. package/templates/angular-micro-app/src/props.service.ts +18 -0
  30. package/templates/angular-micro-app/src/single-spa-props.ts +7 -0
  31. package/templates/angular-micro-app/tsconfig.json +25 -0
  32. package/templates/angular-micro-app/webpack.config.js +112 -0
  33. package/templates/angular-micro-button/.eslintrc.js +3 -0
  34. package/templates/angular-micro-button/README.md +5 -0
  35. package/templates/angular-micro-button/manifest.json.tpl +3 -0
  36. package/templates/angular-micro-button/package.json.tpl +39 -0
  37. package/templates/angular-micro-button/pnpm-lock.yaml +7977 -0
  38. package/templates/angular-micro-button/public/configuration.json +34 -0
  39. package/templates/angular-micro-button/public/index.html.tpl +15 -0
  40. package/templates/angular-micro-button/src/app.component.css +10 -0
  41. package/templates/angular-micro-button/src/app.component.html +2 -0
  42. package/templates/angular-micro-button/src/app.component.ts.tpl +38 -0
  43. package/templates/angular-micro-button/src/app.module.ts +27 -0
  44. package/templates/angular-micro-button/src/components/content.component.css +116 -0
  45. package/templates/angular-micro-button/src/components/content.component.html +3 -0
  46. package/templates/angular-micro-button/src/components/content.component.ts +16 -0
  47. package/templates/angular-micro-button/src/index.ts.tpl +107 -0
  48. package/templates/angular-micro-button/src/master-props.ts +7 -0
  49. package/templates/angular-micro-button/tsconfig.json +25 -0
  50. package/templates/angular-micro-button/webpack.config.js +112 -0
  51. package/templates/angular-micro-field/.eslintrc.js +3 -0
  52. package/templates/angular-micro-field/README.md +5 -0
  53. package/templates/angular-micro-field/examples/main.css +2 -0
  54. package/templates/angular-micro-field/examples/main.js +2 -0
  55. package/templates/angular-micro-field/examples/main.js.LICENSE.txt +52 -0
  56. package/templates/angular-micro-field/examples/playground.html +1 -0
  57. package/templates/angular-micro-field/examples/react-dom.production.min.js +2 -0
  58. package/templates/angular-micro-field/examples/react-dom.production.min.js.LICENSE.txt +8 -0
  59. package/templates/angular-micro-field/examples/react.production.min.js +2 -0
  60. package/templates/angular-micro-field/examples/react.production.min.js.LICENSE.txt +8 -0
  61. package/templates/angular-micro-field/examples/vue.runtime.global.js +9054 -0
  62. package/templates/angular-micro-field/examples/zone.umd.min.js +2 -0
  63. package/templates/angular-micro-field/examples/zone.umd.min.js.LICENSE.txt +29 -0
  64. package/templates/angular-micro-field/manifest.json.tpl +3 -0
  65. package/templates/angular-micro-field/package.json.tpl +39 -0
  66. package/templates/angular-micro-field/pnpm-lock.yaml +7977 -0
  67. package/templates/angular-micro-field/public/configuration.json +34 -0
  68. package/templates/angular-micro-field/public/index.html.tpl +15 -0
  69. package/templates/angular-micro-field/src/app.component.css +10 -0
  70. package/templates/angular-micro-field/src/app.component.html +8 -0
  71. package/templates/angular-micro-field/src/app.component.ts.tpl +60 -0
  72. package/templates/angular-micro-field/src/app.module.ts +14 -0
  73. package/templates/angular-micro-field/src/components/content.component.css +116 -0
  74. package/templates/angular-micro-field/src/components/content.component.html +10 -0
  75. package/templates/angular-micro-field/src/components/content.component.ts +21 -0
  76. package/templates/angular-micro-field/src/index.ts.tpl +101 -0
  77. package/templates/angular-micro-field/src/master-props.ts +7 -0
  78. package/templates/angular-micro-field/tsconfig.json +25 -0
  79. package/templates/angular-micro-field/webpack.config.js +112 -0
  80. package/templates/angular-micro-plugin/package.json.tpl +2 -2
  81. package/templates/react-micro-app/package.json.tpl +6 -0
  82. package/templates/react-micro-button/package.json.tpl +5 -0
  83. package/templates/react-micro-button/src/index.tsx +1 -0
  84. package/templates/react-micro-field/package.json.tpl +5 -0
  85. package/templates/react-micro-field-umi/package.json.tpl +5 -0
  86. package/templates/react-micro-plugin/package.json.tpl +5 -0
  87. package/templates/react-micro-plugin-umi/package.json.tpl +5 -0
  88. package/templates/vue3-micro-button/package.json.tpl +1 -1
  89. package/templates/vue3-micro-field/package.json.tpl +1 -1
  90. package/templates/vue3-micro-plugin/package.json.tpl +1 -1
  91. package/templates/vue3vite-micro-button/package.json.tpl +1 -1
  92. package/templates/vue3vite-micro-plugin/package.json.tpl +1 -1
@@ -0,0 +1,34 @@
1
+ {
2
+ "propName1": {
3
+ "label": "配置项一",
4
+ "type": "string",
5
+ "defaultValue": "配置项内容"
6
+ },
7
+ "propName2": {
8
+ "label": "配置项二",
9
+ "type": "number",
10
+ "defaultValue": 350
11
+ },
12
+ "propName3": {
13
+ "label": "配置项三",
14
+ "type": "select",
15
+ "options": [
16
+ {
17
+ "label": "选项1",
18
+ "value": "option1"
19
+ },
20
+ {
21
+ "label": "选项2",
22
+ "value": "option2"
23
+ },
24
+ {
25
+ "label": "选项3",
26
+ "value": "option3"
27
+ }
28
+ ]
29
+ },
30
+ "externalParams": {
31
+ "label": "外部参数",
32
+ "type": "string"
33
+ }
34
+ }
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>Maxelms 按钮组件 angular13</title>
7
+ <base href="/">
8
+ <meta name="viewport" content="width=device-width, initial-scale=1">
9
+ </head>
10
+
11
+ <body>
12
+ <div id="root-<%= timestamp %>"></div>
13
+ </body>
14
+
15
+ </html>
@@ -0,0 +1,10 @@
1
+ /* App component styles - minimal styles for layout */
2
+ :host {
3
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
4
+ font-size: 14px;
5
+ color: #333;
6
+ box-sizing: border-box;
7
+ -webkit-font-smoothing: antialiased;
8
+ -moz-osx-font-smoothing: grayscale;
9
+ }
10
+
@@ -0,0 +1,2 @@
1
+ <app-content [title]="title" [propName1]="propName1" [propName2]="propName2">
2
+ </app-content>
@@ -0,0 +1,38 @@
1
+ import { Component, OnDestroy, OnInit, ChangeDetectorRef } from '@angular/core'
2
+ import { Subscription } from 'rxjs'
3
+ import { MasterPropsSubject } from './master-props'
4
+
5
+ @Component({
6
+ selector: '#root-<%= timestamp %>',
7
+ templateUrl: './app.component.html',
8
+ styleUrls: ['./app.component.css'],
9
+ })
10
+ export class AppComponent implements OnInit, OnDestroy {
11
+
12
+ title = 'angular13';
13
+ propName1: string = '';
14
+ propName2: string = '';
15
+
16
+ private propsSub?: Subscription;
17
+
18
+ constructor(private cdr: ChangeDetectorRef) {}
19
+
20
+ ngOnInit() {
21
+ console.log('ngOnInit')
22
+
23
+ // 订阅 singleSpaProps
24
+ this.propsSub = MasterPropsSubject.subscribe((props: any) => {
25
+ // console.log('收到主应用传来的 props:', props)
26
+ const {
27
+ configurations, bizData,
28
+ } = props || {}
29
+ this.propName1 = configurations?.propName1 || ''
30
+ this.propName2 = configurations?.propName2 || ''
31
+ // this.cdr.detectChanges() // 手动触发变更检测
32
+ })
33
+ }
34
+
35
+ ngOnDestroy() {
36
+ this.propsSub?.unsubscribe()
37
+ }
38
+ }
@@ -0,0 +1,27 @@
1
+ import { NgModule, Injector } from '@angular/core'
2
+ import { BrowserModule } from '@angular/platform-browser'
3
+ import { createCustomElement } from '@angular/elements'
4
+ import { AppComponent } from './app.component'
5
+ import { ContentComponent } from './components/content.component'
6
+
7
+ @NgModule({
8
+ declarations: [
9
+ AppComponent,
10
+ ContentComponent,
11
+ ],
12
+ imports: [BrowserModule],
13
+ bootstrap: [],
14
+ })
15
+ export class AppModule {
16
+ constructor(private injector: Injector) {
17
+
18
+ // 把 Angular 组件转成浏览器自定义元素
19
+ const element = createCustomElement(AppComponent, { injector })
20
+ // 注册到浏览器,标签名可以随意取
21
+ if (!customElements.get('my-dynamic')) {
22
+ customElements.define('my-dynamic', element)
23
+ }
24
+ }
25
+
26
+ ngDoBootstrap() {}
27
+ }
@@ -0,0 +1,116 @@
1
+ .content {
2
+ /* display: flex;
3
+ margin: 82px auto 32px;
4
+ padding: 0 16px;
5
+ max-width: 960px;
6
+ flex-direction: column;
7
+ align-items: center; */
8
+ }
9
+
10
+ .readonly-text {
11
+ padding: 20px;
12
+ border: 1px solid #ddd;
13
+ border-radius: 8px;
14
+ background-color: #f9f9f9;
15
+ min-width: 300px;
16
+ }
17
+
18
+ .readonly-text p {
19
+ margin: 8px 0;
20
+ color: #333;
21
+ }
22
+
23
+ input {
24
+ padding: 10px;
25
+ border: 1px solid #ccc;
26
+ border-radius: 4px;
27
+ font-size: 14px;
28
+ min-width: 300px;
29
+ }
30
+
31
+ input:focus {
32
+ outline: none;
33
+ border-color: #1976d2;
34
+ box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.2);
35
+ }
36
+
37
+ .card {
38
+ border-radius: 4px;
39
+ border: 1px solid #eee;
40
+ background-color: #fafafa;
41
+ height: 40px;
42
+ width: 200px;
43
+ margin: 0 8px 16px;
44
+ padding: 16px;
45
+ display: flex;
46
+ flex-direction: row;
47
+ justify-content: center;
48
+ align-items: center;
49
+ transition: all 0.2s ease-in-out;
50
+ line-height: 24px;
51
+ }
52
+
53
+ .card.card-small {
54
+ height: 16px;
55
+ width: 168px;
56
+ }
57
+
58
+ .card.highlight-card {
59
+ background-color: #1976d2;
60
+ color: white;
61
+ font-weight: 600;
62
+ border: none;
63
+ width: auto;
64
+ min-width: 30%;
65
+ position: relative;
66
+ }
67
+
68
+ .card.card.highlight-card span {
69
+ margin-left: 60px;
70
+ }
71
+
72
+ svg#rocket {
73
+ width: 80px;
74
+ position: absolute;
75
+ left: -10px;
76
+ top: -24px;
77
+ }
78
+
79
+ svg#rocket-smoke {
80
+ height: calc(100vh - 95px);
81
+ position: absolute;
82
+ top: 10px;
83
+ right: 180px;
84
+ z-index: -10;
85
+ }
86
+
87
+ svg#clouds {
88
+ position: fixed;
89
+ bottom: -160px;
90
+ left: -230px;
91
+ z-index: -10;
92
+ width: 1920px;
93
+ }
94
+
95
+ /* Responsive Styles */
96
+ @media screen and (max-width: 767px) {
97
+ .content {
98
+ width: 100%;
99
+ }
100
+
101
+ .card.highlight-card span {
102
+ margin-left: 72px;
103
+ }
104
+
105
+ svg#rocket-smoke {
106
+ right: 120px;
107
+ transform: rotate(-5deg);
108
+ }
109
+ }
110
+
111
+ @media screen and (max-width: 575px) {
112
+ svg#rocket-smoke {
113
+ display: none;
114
+ visibility: hidden;
115
+ }
116
+ }
@@ -0,0 +1,3 @@
1
+ <div class="content" role="main">
2
+ <button (click)="onButtonClick()">点击弹框</button>
3
+ </div>
@@ -0,0 +1,16 @@
1
+ import { Component, Input, Output, EventEmitter } from '@angular/core'
2
+
3
+ @Component({
4
+ selector: 'app-content',
5
+ templateUrl: './content.component.html',
6
+ styleUrls: ['./content.component.css'],
7
+ })
8
+ export class ContentComponent {
9
+ @Input() title: string = 'angular13';
10
+ @Input() propName1: string = '';
11
+ @Input() propName2: string = '';
12
+
13
+ onButtonClick(): void {
14
+ alert(`propName1: ${this.propName1}, propName2: ${this.propName2}`);
15
+ }
16
+ }
@@ -0,0 +1,107 @@
1
+ import { enableProdMode } from '@angular/core'
2
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
3
+ // import { singleSpaAngular, getSingleSpaExtraProviders } from 'single-spa-angular';
4
+ import { registerPlugin, poweredByMaxelms } from '@maxelms/create-pulgin-api'
5
+
6
+ import { AppModule } from './app.module'
7
+ import { MasterPropsSubject } from './master-props'
8
+
9
+ let container = '#root-<%= timestamp %>'
10
+ const environment = process.env.NODE_ENV === 'production'
11
+ let $root: any
12
+ let appModuleRef: any = null // 保存应用模块引用
13
+
14
+ if (environment) {
15
+ enableProdMode()
16
+ }
17
+
18
+ if (!poweredByMaxelms) {
19
+ const props = {
20
+ configurations: {
21
+ 'propName1': '11',
22
+ 'propName2': 3502,
23
+ },
24
+ }
25
+ console.log(props, 'props poweredByMaxelms')
26
+ render(props, 'mount');
27
+
28
+ // 为开发环境添加全局卸载函数
29
+ (window as any).unmountAngularApp = unmountApp
30
+ } else {
31
+
32
+ registerPlugin?.({
33
+ bootstrap() {
34
+ },
35
+ mount(props: any) {
36
+ console.log(props, 'props mount')
37
+ render(props, 'mount')
38
+ },
39
+ update(props: any) {
40
+ // console.log(props, 'props update')
41
+ render(props, 'update')
42
+ },
43
+ unmount(props: any) {
44
+ console.log(props, 'props unmount')
45
+ unmountApp()
46
+ },
47
+ })
48
+ }
49
+
50
+ function render(singleSpaProps: any, mode: 'mount' | 'update') {
51
+ MasterPropsSubject.next(singleSpaProps)
52
+
53
+ if (mode === 'mount') {
54
+ container = `${container}-${Date.now()}`
55
+ // 首次挂载时创建应用
56
+ console.log('首次挂载,创建 Angular 应用')
57
+ appModuleRef = platformBrowserDynamic().bootstrapModule(AppModule, {
58
+ ngZone: 'noop',
59
+ })
60
+
61
+ const $wrapper = document.querySelector(`#${singleSpaProps.containerId}`) || document.body
62
+ const $div = document.createElement('my-dynamic')
63
+ $div.id = container
64
+ $wrapper.appendChild($div)
65
+ $root = document.querySelector(`#${singleSpaProps.containerId} ${container}`)
66
+
67
+ return appModuleRef
68
+ } else if (mode === 'update') {
69
+ // 更新时只发送新的 props,不重新创建应用
70
+ console.log('更新模式,只发送新的 props')
71
+ MasterPropsSubject.next(singleSpaProps)
72
+ return appModuleRef
73
+ }
74
+ }
75
+
76
+ function unmountApp() {
77
+ console.log('卸载 Angular 应用')
78
+
79
+ if (appModuleRef) {
80
+ try {
81
+ // 销毁 Angular 应用实例
82
+ appModuleRef.destroy()
83
+ console.log('Angular 应用已成功销毁')
84
+ } catch (error) {
85
+ console.error('销毁 Angular 应用时出错:', error)
86
+ } finally {
87
+ // 清理引用
88
+ appModuleRef = null
89
+ }
90
+ } else {
91
+ console.log('没有找到 Angular 应用实例,无需销毁')
92
+ }
93
+
94
+ // 清理 DOM 元素
95
+ try {
96
+ const containerElement = document.querySelector(container)
97
+ if (containerElement) {
98
+ containerElement.innerHTML = ''
99
+ console.log('DOM 容器已清理')
100
+ }
101
+ } catch (error) {
102
+ console.error('清理 DOM 时出错:', error)
103
+ }
104
+
105
+ // 清理全局变量
106
+ $root = null
107
+ }
@@ -0,0 +1,7 @@
1
+ import { ReplaySubject } from 'rxjs'
2
+
3
+ export const MasterPropsSubject = new ReplaySubject<MasterProps>(1)
4
+
5
+ // Add any custom single-spa props you have to this type def
6
+ // https://single-spa.js.org/docs/building-applications.html#custom-props
7
+ export type MasterProps = any;
@@ -0,0 +1,25 @@
1
+ {
2
+ "compileOnSave": false,
3
+ "compilerOptions": {
4
+ "baseUrl": "./",
5
+ "outDir": "./dist",
6
+ "sourceMap": true,
7
+ "declaration": false,
8
+ "downlevelIteration": true,
9
+ "experimentalDecorators": true,
10
+ "moduleResolution": "node",
11
+ "importHelpers": true,
12
+ "target": "es2017",
13
+ "module": "es2020",
14
+ "lib": ["es2018", "dom"],
15
+ "skipLibCheck": true,
16
+ "noImplicitAny": false,
17
+ "strict": false
18
+ },
19
+ "files": [
20
+ "src/index.ts"
21
+ ],
22
+ "include": [
23
+ "src/app/**/*",
24
+ ]
25
+ }
@@ -0,0 +1,112 @@
1
+ const path = require('path')
2
+ const HtmlWebpackPlugin = require('html-webpack-plugin')
3
+ const CopyWebpackPlugin = require('copy-webpack-plugin')
4
+ const { AngularWebpackPlugin } = require('@ngtools/webpack')
5
+
6
+ const isProduction = process.env.NODE_ENV == 'production'
7
+
8
+ const config = {
9
+ entry: {
10
+ index: './src/index.ts',
11
+ },
12
+ output: {
13
+ publicPath: '',
14
+ path: path.resolve(__dirname, 'dist'),
15
+ filename: isProduction
16
+ ? '[name].[contenthash].bundle.js'
17
+ : '[name].bundle.js',
18
+ },
19
+ devServer: {
20
+ open: ['/'],
21
+ host: 'localhost',
22
+ port: 8080,
23
+ headers: {
24
+ 'Access-Control-Allow-Origin': '*',
25
+ },
26
+ proxy: {
27
+ '/api/': {
28
+ target: 'https://max-ai.maxelms.com/',
29
+ changeOrigin: true,
30
+ cookieDomainRewrite: '',
31
+ },
32
+ '/app/api/': {
33
+ target: 'https://max-ai.maxelms.com/',
34
+ changeOrigin: true,
35
+ cookieDomainRewrite: '',
36
+ },
37
+ '/app-admin/api/': {
38
+ target: 'https://max-ai.maxelms.com/',
39
+ changeOrigin: true,
40
+ cookieDomainRewrite: '',
41
+ },
42
+ },
43
+ static: [{
44
+ directory: path.join(__dirname, 'examples/'),
45
+ }, {
46
+ directory: path.join(__dirname, 'public/'),
47
+ }],
48
+ },
49
+ plugins: [
50
+ new HtmlWebpackPlugin({
51
+ inject: true,
52
+ template: 'public/index.html',
53
+ chunks: ['index'],
54
+ filename: 'index.html',
55
+ }),
56
+ new CopyWebpackPlugin({
57
+ patterns: [
58
+ {
59
+ from: 'public',
60
+ globOptions: {
61
+ dot: true,
62
+ gitignore: true,
63
+ ignore: ['**/public/index.html', '**/public/configuration.html'],
64
+ },
65
+ noErrorOnMissing: true,
66
+ },
67
+ { from: 'README.md' },
68
+ { from: 'manifest.json' },
69
+ ],
70
+ }),
71
+ new AngularWebpackPlugin({
72
+ tsconfig: './tsconfig.json',
73
+ jitMode: true,
74
+ }),
75
+ ],
76
+ module: {
77
+ rules: [
78
+ {
79
+ test: /\.ts$/,
80
+ loader: '@ngtools/webpack',
81
+ exclude: /node_modules/,
82
+ },
83
+ {
84
+ test: /\.html$/,
85
+ use: 'raw-loader',
86
+ },
87
+ {
88
+ test: /\.css$/,
89
+ use: ['to-string-loader', 'css-loader'],
90
+ },
91
+ {
92
+ test: /\.(eot|svg|ttf|woff|woff2|png|jpg|gif)$/i,
93
+ type: 'asset',
94
+ },
95
+ ],
96
+ },
97
+ resolve: {
98
+ extensions: ['.ts', '.js'],
99
+ alias: {
100
+ '@': path.resolve('src'),
101
+ },
102
+ },
103
+ }
104
+
105
+ module.exports = () => {
106
+ if (isProduction) {
107
+ config.mode = 'production'
108
+ } else {
109
+ config.mode = 'development'
110
+ }
111
+ return config
112
+ }
@@ -0,0 +1,3 @@
1
+
2
+ const rule = require('@max-kit/eslint')
3
+ module.exports = rule
@@ -0,0 +1,5 @@
1
+ # Maxelms Custom Plugin
2
+
3
+ ## 功能介绍
4
+
5
+ ## 使用说明