@linagora/linid-im-front-corelib 0.0.5 → 0.0.7
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.
- package/README.md +3 -3
- package/dist/core-lib.es.js +923 -852
- package/dist/core-lib.umd.js +9 -9
- package/dist/package.json +19 -14
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/services/httpClientService.d.ts +13 -0
- package/dist/types/src/services/linIdConfigurationService.d.ts +21 -0
- package/dist/types/src/stores/linIdConfigurationStore.d.ts +79 -0
- package/dist/types/src/types/linidConfiguration.d.ts +42 -0
- package/package.json +18 -13
- package/.github/ISSUE_TEMPLATE/bug_report.yml +0 -83
- package/.github/ISSUE_TEMPLATE/feature_request.yml +0 -90
- package/.github/ISSUE_TEMPLATE/question.yml +0 -31
- package/.github/ISSUE_TEMPLATE/security.yml +0 -69
- package/.github/actions/setup-node-pnpm/action.yml +0 -29
- package/.github/workflows/pull-request.yml +0 -147
- package/.github/workflows/release.yml +0 -90
- package/.prettierignore +0 -7
- package/.prettierrc.json +0 -5
- package/.vscode/extensions.json +0 -3
- package/.vscode/settings.json +0 -9
- package/CHANGELOG.md +0 -40
- package/CONTRIBUTING.md +0 -269
- package/COPYRIGHT +0 -23
- package/docs/components-plugin-zones.md +0 -168
- package/docs/helpers.md +0 -188
- package/docs/module-lifecycle.md +0 -717
- package/docs/types-and-interfaces.md +0 -92
- package/eslint.config.js +0 -136
- package/src/components/LinidZoneRenderer.vue +0 -77
- package/src/index.ts +0 -51
- package/src/lifecycle/skeleton.ts +0 -147
- package/src/services/federationService.ts +0 -44
- package/src/stores/linidZoneStore.ts +0 -62
- package/src/types/linidZone.ts +0 -48
- package/src/types/module.ts +0 -96
- package/src/types/moduleLifecycle.ts +0 -154
- package/tests/unit/components/LinidZoneRenderer.spec.js +0 -135
- package/tests/unit/lifecycle/skeleton.spec.js +0 -138
- package/tests/unit/services/federationService.spec.js +0 -146
- package/tests/unit/stores/linidZoneStore.spec.js +0 -94
- package/tsconfig.json +0 -14
- package/tsconfig.lib.json +0 -20
- package/tsconfig.node.json +0 -9
- package/tsconfig.spec.json +0 -16
- package/vite.config.ts +0 -37
- package/vitest.config.ts +0 -19
package/CONTRIBUTING.md
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
# **CONTRIBUTING 🤝**
|
|
2
|
-
|
|
3
|
-
Thank you for contributing to **linid-im-front-corelib**, the core front-end library of the LinID Identity Manager platform.
|
|
4
|
-
This document explains the conventions, workflows, and best practices to follow when contributing.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# **📌 Git Conventions**
|
|
9
|
-
|
|
10
|
-
## **🌿 Branch Naming**
|
|
11
|
-
|
|
12
|
-
All branches must follow one of the following naming patterns:
|
|
13
|
-
|
|
14
|
-
| Type | Pattern | Example |
|
|
15
|
-
| --------------- | --------------------------------- | --------------------------------- |
|
|
16
|
-
| **Main** | `main` or `dev` | `main` |
|
|
17
|
-
| **Feature** | `feature/<short-description>` | `feature/plugin-zone-support` |
|
|
18
|
-
| **Bugfix** | `bugfix/<short-description>` | `bugfix/fix-null-validation` |
|
|
19
|
-
| **Improvement** | `improvement/<short-description>` | `improvement/refactor-core-types` |
|
|
20
|
-
| **Release** | `release/<version>` | `release/1.2.0` |
|
|
21
|
-
| **Hotfix** | `hotfix/<short-description>` | `hotfix/fix-critical-crash` |
|
|
22
|
-
|
|
23
|
-
### **Rules**
|
|
24
|
-
|
|
25
|
-
- ✔ Allowed characters: lowercase letters, numbers, dashes (`-`), underscores (`_`), and dots (`.`)
|
|
26
|
-
- ✔ Names must be concise and descriptive
|
|
27
|
-
- ✔ Use English keywords and descriptions
|
|
28
|
-
|
|
29
|
-
---
|
|
30
|
-
|
|
31
|
-
## **📝 Commit Message Format (Conventional Commits)**
|
|
32
|
-
|
|
33
|
-
We follow the **Conventional Commits** specification:
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
<type>(<scope>): <short summary>
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### **Accepted types**
|
|
40
|
-
|
|
41
|
-
* **feat** – Introduces, updates, or removes a feature in the API or UI
|
|
42
|
-
* **fix** – Resolves a bug in the API or UI originating from a previous feature
|
|
43
|
-
* **refactor** – Rewrites or restructures code without changing API or UI behavior
|
|
44
|
-
* **perf** – A specialized refactor focused on improving performance
|
|
45
|
-
* **style** – Addresses code style issues (e.g., whitespace, formatting, missing semicolons) without affecting behavior
|
|
46
|
-
* **test** – Adds missing tests or updates existing tests
|
|
47
|
-
* **docs** – Documentation-only changes
|
|
48
|
-
* **build** – Modifies build-related components (tooling, dependencies, versioning, CI/CD, etc.)
|
|
49
|
-
* **ops** – Changes to operational or infrastructure components (deployment, backup, recovery, etc.)
|
|
50
|
-
* **chore** – Miscellaneous maintenance tasks (e.g., updating `.gitignore`)
|
|
51
|
-
|
|
52
|
-
### **Examples**
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
feat(core): add identity validation helpers
|
|
56
|
-
fix(plugins): prevent crash on remote loading
|
|
57
|
-
docs(contributing): add commit format rules
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
---
|
|
61
|
-
|
|
62
|
-
## **🔏 Commit Signing (GPG)**
|
|
63
|
-
|
|
64
|
-
All commits **must be GPG-signed**:
|
|
65
|
-
|
|
66
|
-
```bash
|
|
67
|
-
git commit -S -m "feat(core): add new service"
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
Unsigned commits will be rejected.
|
|
71
|
-
If you need help setting up GPG signing, refer to your Git hosting provider’s documentation.
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
# **📚 Documentation Guidelines**
|
|
76
|
-
|
|
77
|
-
## **📁 Documentation Directory**
|
|
78
|
-
|
|
79
|
-
All functional or technical documentation must be placed inside:
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
/docs
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
Please keep this folder organized and up to date.
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## **📊 Diagrams with Mermaid**
|
|
90
|
-
|
|
91
|
-
We use **Mermaid** for architecture diagrams, flowcharts, sequence diagrams, etc.
|
|
92
|
-
|
|
93
|
-
* Source files must be `.md` or `.mmd`
|
|
94
|
-
* They must be stored in the `docs` directory
|
|
95
|
-
* Generated images must be committed together with source files
|
|
96
|
-
|
|
97
|
-
### **Install Mermaid CLI**
|
|
98
|
-
|
|
99
|
-
```bash
|
|
100
|
-
npm install -g @mermaid-js/mermaid-cli
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
### **Generate a PNG**
|
|
104
|
-
|
|
105
|
-
```bash
|
|
106
|
-
mmdc -i docs/diagram.mmd -o docs/diagram.png
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
💡 Any modification to a Mermaid diagram **must include** regeneration of the corresponding PNG.
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
# **🚀 Development**
|
|
114
|
-
|
|
115
|
-
This project uses **pnpm** as the preferred package manager.
|
|
116
|
-
Node.js **22.19+** is recommended.
|
|
117
|
-
|
|
118
|
-
## **📦 Installation**
|
|
119
|
-
|
|
120
|
-
### ⭐ Quick Start
|
|
121
|
-
|
|
122
|
-
```sh
|
|
123
|
-
corepack enable
|
|
124
|
-
pnpm install
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
### Using pnpm (recommended)
|
|
128
|
-
|
|
129
|
-
```sh
|
|
130
|
-
pnpm install
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Using npm (legacy support and not recommended by the dev team)
|
|
134
|
-
|
|
135
|
-
```sh
|
|
136
|
-
npm install
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## **🛠️ Build the Library**
|
|
142
|
-
|
|
143
|
-
```sh
|
|
144
|
-
pnpm build
|
|
145
|
-
# or (not recommended by the dev team)
|
|
146
|
-
npm run build
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
## **🔧 Development Mode**
|
|
152
|
-
|
|
153
|
-
```sh
|
|
154
|
-
pnpm dev
|
|
155
|
-
# or (not recommended by the dev team)
|
|
156
|
-
npm run dev
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## **🧪 Run Tests**
|
|
162
|
-
|
|
163
|
-
```sh
|
|
164
|
-
pnpm test # Runs the full test suite once
|
|
165
|
-
pnpm test:watch # Runs tests in watch mode
|
|
166
|
-
pnpm test:coverage # Generates a coverage report
|
|
167
|
-
|
|
168
|
-
# or (not recommended by the dev team)
|
|
169
|
-
npm run test # Runs the full test suite once
|
|
170
|
-
npm run test:watch # Runs tests in watch mode
|
|
171
|
-
npm run test:coverage # Generates a coverage report
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
---
|
|
175
|
-
|
|
176
|
-
# **🧼 Code Quality**
|
|
177
|
-
|
|
178
|
-
We use **ESLint**, **Prettier**, and **TypeScript** to enforce consistent code style and reliability.
|
|
179
|
-
|
|
180
|
-
## **🔍 Lint**
|
|
181
|
-
|
|
182
|
-
```sh
|
|
183
|
-
pnpm lint
|
|
184
|
-
pnpm lint:fix
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## **🎨 Format**
|
|
188
|
-
|
|
189
|
-
```sh
|
|
190
|
-
pnpm format
|
|
191
|
-
pnpm format:check
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
## **📘 Type Checking**
|
|
195
|
-
|
|
196
|
-
```sh
|
|
197
|
-
pnpm type-check
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
## **✔ Full Validation**
|
|
201
|
-
|
|
202
|
-
```sh
|
|
203
|
-
pnpm validate
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
## Copyright Headers
|
|
207
|
-
|
|
208
|
-
All source files located in the `src` folder must contain a copyright header at the beginning of the file. This header is based on the content of the `COPYRIGHT` file at the project root.
|
|
209
|
-
|
|
210
|
-
### Affected Files
|
|
211
|
-
|
|
212
|
-
Copyright headers are mandatory for the following files:
|
|
213
|
-
|
|
214
|
-
- TypeScript files (`.ts`)
|
|
215
|
-
- JavaScript files (`.js`)
|
|
216
|
-
- Vue files (`.vue`)
|
|
217
|
-
|
|
218
|
-
### Automatic Verification
|
|
219
|
-
|
|
220
|
-
An ESLint rule is configured via the `eslint-plugin-headers` plugin to check for the presence of these headers.
|
|
221
|
-
|
|
222
|
-
### Automatic Header Addition
|
|
223
|
-
|
|
224
|
-
If a file does not contain the required copyright header, you can add it automatically by running:
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
pnpm lint:fix
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
This command will analyze all files in the `src` folder and add missing headers according to the `COPYRIGHT` file.
|
|
231
|
-
|
|
232
|
-
### Manual Verification
|
|
233
|
-
|
|
234
|
-
To check compliance without modifying files, use:
|
|
235
|
-
|
|
236
|
-
```bash
|
|
237
|
-
pnpm lint
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
Any file without the appropriate header will be reported as a lint error.
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
# **🧪 E2E & Integration Testing**
|
|
245
|
-
|
|
246
|
-
Full E2E testing documentation is **Coming soon… ⏳**
|
|
247
|
-
This library will later integrate with the LinID front-end test runner.
|
|
248
|
-
|
|
249
|
-
---
|
|
250
|
-
|
|
251
|
-
# **🚀 Releases (Semantic Release)**
|
|
252
|
-
|
|
253
|
-
Releases are fully automated using **Semantic Release**.
|
|
254
|
-
|
|
255
|
-
When a merge is performed into `main`:
|
|
256
|
-
|
|
257
|
-
* The version bump is automatically calculated from commit messages
|
|
258
|
-
* `package.json` is updated
|
|
259
|
-
* A changelog entry is generated
|
|
260
|
-
* A Git tag is created
|
|
261
|
-
|
|
262
|
-
⚠ No manual intervention is needed.
|
|
263
|
-
|
|
264
|
-
---
|
|
265
|
-
|
|
266
|
-
# **📜 License**
|
|
267
|
-
|
|
268
|
-
This project is licensed under the **GNU Affero General Public License v3**.
|
|
269
|
-
See: [`LICENSE.md`](LICENSE.md)
|
package/COPYRIGHT
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
Copyright (C) 2025 Linagora
|
|
2
|
-
|
|
3
|
-
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General
|
|
4
|
-
Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option)
|
|
5
|
-
any later version, provided you comply with the Additional Terms applicable for LinID Identity Manager software by
|
|
6
|
-
LINAGORA pursuant to Section 7 of the GNU Affero General Public License, subsections (b), (c), and (e), pursuant to
|
|
7
|
-
which these Appropriate Legal Notices must notably (i) retain the display of the "LinID™" trademark/logo at the top
|
|
8
|
-
of the interface window, the display of the “You are using the Open Source and free version of LinID™, powered by
|
|
9
|
-
Linagora © 2009–2013. Contribute to LinID R&D by subscribing to an Enterprise offer!” infobox and in the e-mails
|
|
10
|
-
sent with the Program, notice appended to any type of outbound messages (e.g. e-mail and meeting requests) as well
|
|
11
|
-
as in the LinID Identity Manager user interface, (ii) retain all hypertext links between LinID Identity Manager
|
|
12
|
-
and https://linid.org/, as well as between LINAGORA and LINAGORA.com, and (iii) refrain from infringing LINAGORA
|
|
13
|
-
intellectual property rights over its trademarks and commercial brands. Other Additional Terms apply, see
|
|
14
|
-
<http://www.linagora.com/licenses/> for more details.
|
|
15
|
-
|
|
16
|
-
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
17
|
-
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
18
|
-
details.
|
|
19
|
-
|
|
20
|
-
You should have received a copy of the GNU Affero General Public License and its applicable Additional Terms for
|
|
21
|
-
LinID Identity Manager along with this program. If not, see <http://www.gnu.org/licenses/> for the GNU Affero
|
|
22
|
-
General Public License version 3 and <http://www.linagora.com/licenses/> for the Additional Terms applicable to the
|
|
23
|
-
LinID Identity Manager software.
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
# LinidZoneRenderer Component 🔌
|
|
2
|
-
|
|
3
|
-
The **LinidZoneRenderer** component is a core feature of `linid-im-front-corelib`.
|
|
4
|
-
It allows the host application to **dynamically render remote Vue components (plugins)** inside predefined “zones” of the UI.
|
|
5
|
-
|
|
6
|
-
This component works together with the **Linid Zone Store**, which manages plugin registration and provides reactive updates.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## 🎯 Purpose
|
|
11
|
-
|
|
12
|
-
LinidZoneRenderer provides:
|
|
13
|
-
|
|
14
|
-
- **Dynamic rendering:** Components are loaded asynchronously only when needed.
|
|
15
|
-
- **Reactive updates:** New plugins registered to a zone appear automatically.
|
|
16
|
-
- **Extensibility:** New features can be added via plugins without modifying the host app.
|
|
17
|
-
- **Standardization:** All plugins follow the `LinidZoneEntry` interface.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 🧱 How to Use the Component
|
|
22
|
-
|
|
23
|
-
### Basic Usage
|
|
24
|
-
|
|
25
|
-
```vue
|
|
26
|
-
<template>
|
|
27
|
-
<LinidZoneRenderer zone="user-details" />
|
|
28
|
-
</template>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
* `zone` (string): Identifier of the zone where components should be rendered.
|
|
32
|
-
* The component automatically fetches all registered plugins for this zone from the store and renders them asynchronously.
|
|
33
|
-
|
|
34
|
-
### Props
|
|
35
|
-
|
|
36
|
-
| Prop | Type | Description |
|
|
37
|
-
| ---------- | ------------- | -------------------------------------------------- |
|
|
38
|
-
| `zone` | string | The name of the zone to render |
|
|
39
|
-
|
|
40
|
-
### Default Slot - Fallback Component
|
|
41
|
-
|
|
42
|
-
The `LinidZoneRenderer` component provides a **default slot** that is displayed when no components are registered in the specified zone **after loading is complete**.
|
|
43
|
-
|
|
44
|
-
#### Purpose
|
|
45
|
-
|
|
46
|
-
The default slot allows you to:
|
|
47
|
-
- Display a custom message when a zone is empty
|
|
48
|
-
- Render a placeholder component
|
|
49
|
-
- Show alternative content for zones without plugins
|
|
50
|
-
|
|
51
|
-
#### Behavior
|
|
52
|
-
|
|
53
|
-
The slot is rendered **only when**:
|
|
54
|
-
1. ✅ The loading process is complete
|
|
55
|
-
2. ✅ No components are registered in the zone
|
|
56
|
-
|
|
57
|
-
**Important:** The slot will **not** be displayed during the initial loading phase to avoid flickering.
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
#### Usage
|
|
62
|
-
|
|
63
|
-
##### Default Fallback (No Custom Slot)
|
|
64
|
-
|
|
65
|
-
If you don't provide a custom slot, the component displays a default message:
|
|
66
|
-
|
|
67
|
-
```vue
|
|
68
|
-
<template>
|
|
69
|
-
<LinidZoneRenderer zone="sidebar" />
|
|
70
|
-
</template>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**Rendered when zone is empty:**
|
|
74
|
-
```html
|
|
75
|
-
<div>No components to render in this zone.</div>
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
##### Custom Fallback Component
|
|
81
|
-
|
|
82
|
-
You can provide your own fallback content using the default slot:
|
|
83
|
-
|
|
84
|
-
```vue
|
|
85
|
-
<template>
|
|
86
|
-
<LinidZoneRenderer zone="user-actions">
|
|
87
|
-
<template #default>
|
|
88
|
-
<div>
|
|
89
|
-
<p>No actions available for this user.</p>
|
|
90
|
-
</div>
|
|
91
|
-
</template>
|
|
92
|
-
</LinidZoneRenderer>
|
|
93
|
-
</template>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
---
|
|
97
|
-
|
|
98
|
-
## ⚡ Adding a Plugin with the Store
|
|
99
|
-
|
|
100
|
-
Plugins must be registered in the **Linid Zone Store** before they can be rendered.
|
|
101
|
-
|
|
102
|
-
```ts
|
|
103
|
-
import { useLinidZoneStore } from '@linagora/linid-im-front-corelib';
|
|
104
|
-
|
|
105
|
-
const linidZoneStore = useLinidZoneStore();
|
|
106
|
-
|
|
107
|
-
linidZoneStore.register("user-details", {
|
|
108
|
-
plugin: "@/remote/UserCard",
|
|
109
|
-
props: { userId: 42 },
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
* `plugin`: Path or identifier of the remote component to load.
|
|
114
|
-
* `props`: Optional props passed to the plugin component.
|
|
115
|
-
|
|
116
|
-
> Once registered, the `LinidZoneRenderer` component will automatically render this plugin in the specified zone.
|
|
117
|
-
|
|
118
|
-
---
|
|
119
|
-
|
|
120
|
-
## 🧩 How It Works
|
|
121
|
-
|
|
122
|
-
1. The component retrieves all entries for the given `zone` from the **Linid Zone Store**.
|
|
123
|
-
2. Each entry is wrapped as an **async component** retrieved from its remote module using the `loadAsyncComponent(entry.plugin)` method.
|
|
124
|
-
3. All plugins in the zone are rendered sequentially with:
|
|
125
|
-
|
|
126
|
-
```vue
|
|
127
|
-
<component :is="entry.component" v-bind="entry.props" />
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
* This allows multiple plugins to coexist in a single zone.
|
|
131
|
-
* The component reacts automatically to changes in the store.
|
|
132
|
-
|
|
133
|
-
---
|
|
134
|
-
|
|
135
|
-
## 🔧 Plugin Types
|
|
136
|
-
|
|
137
|
-
Plugins must implement the `LinidZoneEntry` interface:
|
|
138
|
-
|
|
139
|
-
```ts
|
|
140
|
-
export interface LinidZoneEntry {
|
|
141
|
-
/** Path to the remote module */
|
|
142
|
-
plugin: string;
|
|
143
|
-
|
|
144
|
-
/** Props forwarded to the plugin component */
|
|
145
|
-
props?: Record<string, unknown>;
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
* Props are automatically forwarded to the dynamically loaded component.
|
|
150
|
-
* Components are wrapped in `loadAsyncComponent` for asynchronous loading.
|
|
151
|
-
|
|
152
|
-
---
|
|
153
|
-
|
|
154
|
-
## ✅ Advantages
|
|
155
|
-
|
|
156
|
-
* **Decoupled architecture:** Plugins are independent of the host.
|
|
157
|
-
* **Lazy loading:** Only load components when needed.
|
|
158
|
-
* **Reactive:** Supports runtime addition/removal of plugins.
|
|
159
|
-
* **Standardized interface:** All plugins conform to `LinidZoneEntry`.
|
|
160
|
-
* **Framework-friendly:** Works natively with Vue 3, Pinia, and Module Federation.
|
|
161
|
-
|
|
162
|
-
---
|
|
163
|
-
|
|
164
|
-
## 📌 Notes
|
|
165
|
-
|
|
166
|
-
* Multiple plugins can be registered for the same zone; they are rendered in registration order.
|
|
167
|
-
* Failed imports are handled automatically; you can provide a `fallback` component.
|
|
168
|
-
* Designed for scalable front-end applications using Module Federation.
|
package/docs/helpers.md
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
# Helper Functions
|
|
2
|
-
|
|
3
|
-
This document describes utility functions provided by `linid-im-front-corelib` to simplify common tasks.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## `loadAsyncComponent`
|
|
8
|
-
|
|
9
|
-
Loads a remote Vue component from a Module Federation remote using the enhanced runtime.
|
|
10
|
-
|
|
11
|
-
This helper wraps Vue's `defineAsyncComponent` and Module Federation's `loadRemote` to provide a simple way to load federated components asynchronously.
|
|
12
|
-
|
|
13
|
-
### Import
|
|
14
|
-
|
|
15
|
-
```typescript
|
|
16
|
-
import { loadAsyncComponent } from '@linagora/linid-im-front-corelib';
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Parameters
|
|
20
|
-
|
|
21
|
-
| Parameter | Type | Description |
|
|
22
|
-
| --------- | -------- | -------------------------------------------------------------------------------------------------------------------- |
|
|
23
|
-
| `plugin` | `string` | The Module Federation remote identifier in the format `remoteName/modulePath`.<br/>Example: `'myRemote/MyComponent'` |
|
|
24
|
-
|
|
25
|
-
### Returns
|
|
26
|
-
|
|
27
|
-
Returns a Vue async component that can be used in templates or rendered programmatically.
|
|
28
|
-
|
|
29
|
-
### Behavior
|
|
30
|
-
|
|
31
|
-
1. **Lazy loading:** The component is only loaded when it's actually rendered
|
|
32
|
-
2. **Error handling:** Throws an error if the remote module doesn't export a default component
|
|
33
|
-
3. **Type safety:** Expects the remote module to follow the `RemoteComponentModule` structure
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## Usage Examples
|
|
38
|
-
|
|
39
|
-
### Basic Usage
|
|
40
|
-
|
|
41
|
-
```vue
|
|
42
|
-
<template>
|
|
43
|
-
<component :is="remoteComponent" />
|
|
44
|
-
</template>
|
|
45
|
-
|
|
46
|
-
<script setup lang="ts">
|
|
47
|
-
import { loadAsyncComponent } from '@linagora/linid-im-front-corelib';
|
|
48
|
-
|
|
49
|
-
const remoteComponent = loadAsyncComponent('myRemote/HeaderWidget');
|
|
50
|
-
</script>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
### Dynamic Component Loading
|
|
56
|
-
|
|
57
|
-
```vue
|
|
58
|
-
<template>
|
|
59
|
-
<component
|
|
60
|
-
v-for="plugin in plugins"
|
|
61
|
-
:key="plugin"
|
|
62
|
-
:is="loadAsyncComponent(plugin)"
|
|
63
|
-
/>
|
|
64
|
-
</template>
|
|
65
|
-
|
|
66
|
-
<script setup lang="ts">
|
|
67
|
-
import { loadAsyncComponent } from '@linagora/linid-im-front-corelib';
|
|
68
|
-
|
|
69
|
-
const plugins = ['remote1/ComponentA', 'remote2/ComponentB'];
|
|
70
|
-
</script>
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
### In LinidZoneRenderer Context
|
|
76
|
-
|
|
77
|
-
The `loadAsyncComponent` function is used internally by `LinidZoneRenderer`:
|
|
78
|
-
|
|
79
|
-
```typescript
|
|
80
|
-
// Internal usage in LinidZoneRenderer
|
|
81
|
-
const components = entries.map((entry) => ({
|
|
82
|
-
...entry,
|
|
83
|
-
component: loadAsyncComponent(entry.plugin),
|
|
84
|
-
}));
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Error Handling
|
|
90
|
-
|
|
91
|
-
### Module Not Found
|
|
92
|
-
|
|
93
|
-
If the remote module cannot be loaded:
|
|
94
|
-
|
|
95
|
-
```typescript
|
|
96
|
-
const component = loadAsyncComponent('invalidRemote/Component');
|
|
97
|
-
// Throws: Error loading remote module
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Missing Default Export
|
|
101
|
-
|
|
102
|
-
If the module doesn't export a default component:
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
// Remote module exports: export { MyComponent }
|
|
106
|
-
const component = loadAsyncComponent('myRemote/MyComponent');
|
|
107
|
-
// Throws: Failed to load component from myRemote/MyComponent
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
**Solution:** Ensure your remote module exports a default component:
|
|
111
|
-
|
|
112
|
-
```vue
|
|
113
|
-
<!-- ✅ Correct - remote module (.vue file) -->
|
|
114
|
-
<template>
|
|
115
|
-
<div>My Component</div>
|
|
116
|
-
</template>
|
|
117
|
-
|
|
118
|
-
<script setup lang="ts">
|
|
119
|
-
// Default export automatic with <script setup>
|
|
120
|
-
// Nothing special to do!
|
|
121
|
-
</script>
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
**Alternative with Options API:**
|
|
125
|
-
|
|
126
|
-
```vue
|
|
127
|
-
<!-- ✅ Correct - remote module (.vue file) -->
|
|
128
|
-
<template>
|
|
129
|
-
<div>My Component</div>
|
|
130
|
-
</template>
|
|
131
|
-
|
|
132
|
-
<script lang="ts">
|
|
133
|
-
import { defineComponent } from 'vue';
|
|
134
|
-
|
|
135
|
-
export default defineComponent({
|
|
136
|
-
name: 'MyComponent',
|
|
137
|
-
// ...
|
|
138
|
-
});
|
|
139
|
-
</script>
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
**❌ Wrong - TypeScript/JavaScript file (not .vue):**
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
// In a .ts file (not .vue)
|
|
146
|
-
// ❌ Named export only - doesn't work with loadAsyncComponent
|
|
147
|
-
export const MyComponent = defineComponent({
|
|
148
|
-
// ...
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
// ✅ Correct - default export
|
|
152
|
-
export default defineComponent({
|
|
153
|
-
name: 'MyComponent',
|
|
154
|
-
// ...
|
|
155
|
-
});
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
## TypeScript Support
|
|
161
|
-
|
|
162
|
-
### Remote Module Structure
|
|
163
|
-
|
|
164
|
-
The function expects remotes to follow this structure:
|
|
165
|
-
|
|
166
|
-
```typescript
|
|
167
|
-
/**
|
|
168
|
-
* Module structure for a Vue component exposed via Module Federation.
|
|
169
|
-
*/
|
|
170
|
-
interface RemoteComponentModule {
|
|
171
|
-
/**
|
|
172
|
-
* The default exported Vue component.
|
|
173
|
-
*/
|
|
174
|
-
default: Component;
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Type Inference
|
|
179
|
-
|
|
180
|
-
The returned component is fully typed as a Vue `Component`:
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
import type { Component } from 'vue';
|
|
184
|
-
|
|
185
|
-
const myComponent: Component = loadAsyncComponent('remote/Component');
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
---
|