@egen-civitas/egen 3.0.1 → 3.2.0

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 (49) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +31 -0
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +106 -0
  5. package/dist/commands/check-app.d.ts +31 -0
  6. package/dist/commands/check-app.d.ts.map +1 -0
  7. package/dist/commands/check-app.js +366 -0
  8. package/dist/commands/cli-actions.d.ts +26 -0
  9. package/dist/commands/cli-actions.d.ts.map +1 -0
  10. package/dist/commands/cli-actions.js +51 -0
  11. package/dist/commands/create.d.ts +27 -0
  12. package/dist/commands/create.d.ts.map +1 -0
  13. package/dist/commands/create.js +63 -0
  14. package/dist/commands/develop.d.ts.map +1 -1
  15. package/dist/commands/develop.js +73 -3
  16. package/dist/commands/manifest.d.ts +16 -0
  17. package/dist/commands/manifest.d.ts.map +1 -0
  18. package/dist/commands/manifest.js +54 -0
  19. package/package.json +9 -4
  20. package/templates/react-embedded/README.md +14 -0
  21. package/templates/react-embedded/_gitignore +3 -0
  22. package/templates/react-embedded/index.html +12 -0
  23. package/templates/react-embedded/package.json +27 -0
  24. package/templates/react-embedded/public/egen-config.json +15 -0
  25. package/templates/react-embedded/src/App.tsx +14 -0
  26. package/templates/react-embedded/src/egen.test.ts +9 -0
  27. package/templates/react-embedded/src/egen.ts +12 -0
  28. package/templates/react-embedded/src/main.tsx +13 -0
  29. package/templates/react-embedded/tsconfig.json +14 -0
  30. package/templates/react-embedded/vite.config.ts +4 -0
  31. package/templates/vanilla-embedded/README.md +13 -0
  32. package/templates/vanilla-embedded/_gitignore +3 -0
  33. package/templates/vanilla-embedded/package.json +15 -0
  34. package/templates/vanilla-embedded/public/egen-config.json +15 -0
  35. package/templates/vanilla-embedded/public/index.html +19 -0
  36. package/templates/vanilla-embedded/public/main.js +15 -0
  37. package/templates/vanilla-embedded/scripts/vendor.mjs +10 -0
  38. package/templates/vue-embedded/README.md +14 -0
  39. package/templates/vue-embedded/_gitignore +3 -0
  40. package/templates/vue-embedded/index.html +12 -0
  41. package/templates/vue-embedded/package.json +25 -0
  42. package/templates/vue-embedded/public/egen-config.json +15 -0
  43. package/templates/vue-embedded/src/App.vue +18 -0
  44. package/templates/vue-embedded/src/egen.test.ts +9 -0
  45. package/templates/vue-embedded/src/egen.ts +12 -0
  46. package/templates/vue-embedded/src/env.d.ts +1 -0
  47. package/templates/vue-embedded/src/main.ts +6 -0
  48. package/templates/vue-embedded/tsconfig.json +13 -0
  49. package/templates/vue-embedded/vite.config.ts +4 -0
@@ -0,0 +1,27 @@
1
+ export declare const FRAMEWORKS: readonly ["react", "vue", "vanilla"];
2
+ export type Framework = (typeof FRAMEWORKS)[number];
3
+ export declare const INTEGRATIONS: readonly ["embedded", "native", "webcomponent"];
4
+ export type Integration = (typeof INTEGRATIONS)[number];
5
+ export interface CreateAppOptions {
6
+ /** Nom du projet et du module (minuscules, chiffres, tirets). */
7
+ name: string;
8
+ framework?: Framework;
9
+ /** Seule `embedded` (iframe) est disponible : les gabarits natifs et Web Component viendront avec leurs apps de référence. */
10
+ integration?: Integration;
11
+ /** Répertoire à créer (défaut : `./<name>`). Refusé s'il existe et n'est pas vide. */
12
+ dir?: string;
13
+ /** Titre affiché (défaut : le nom, lisible). */
14
+ title?: string;
15
+ /** Surcharges pour les tests. */
16
+ templatesDir?: string;
17
+ sdkVersion?: string;
18
+ egenVersion?: string;
19
+ }
20
+ export interface CreateAppResult {
21
+ dir: string;
22
+ template: string;
23
+ files: string[];
24
+ }
25
+ /** Crée un projet à partir d'un gabarit versionné avec la CLI (épinglé sur la version du SDK avec laquelle il a été testé). */
26
+ export declare function createApp(o: CreateAppOptions): CreateAppResult;
27
+ //# sourceMappingURL=create.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,UAAU,sCAAuC,CAAC;AAC/D,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AACpD,eAAO,MAAM,YAAY,iDAAkD,CAAC;AAC5E,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,MAAM,WAAW,gBAAgB;IAC/B,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,8HAA8H;IAC9H,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,sFAAsF;IACtF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAgBD,+HAA+H;AAC/H,wBAAgB,SAAS,CAAC,CAAC,EAAE,gBAAgB,GAAG,eAAe,CAkC9D"}
@@ -0,0 +1,63 @@
1
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
2
+ import { createRequire } from "node:module";
3
+ import { dirname, join, relative, resolve } from "node:path";
4
+ export const FRAMEWORKS = [
5
+ 'react',
6
+ 'vue',
7
+ 'vanilla'
8
+ ];
9
+ export const INTEGRATIONS = [
10
+ 'embedded',
11
+ 'native',
12
+ 'webcomponent'
13
+ ];
14
+ const NAME_RE = /^[a-z][a-z0-9-]{1,62}$/;
15
+ // `import.meta.dirname` : src/commands (tests) ou dist/commands (publié) — la racine du paquet est deux niveaux plus haut dans les deux cas.
16
+ const PKG_ROOT = resolve(import.meta.dirname, '..', '..');
17
+ const titleOf = (name)=>name.split('-').map((w)=>w.charAt(0).toUpperCase() + w.slice(1)).join(' ');
18
+ function* walk(dir) {
19
+ for (const entry of readdirSync(dir, {
20
+ withFileTypes: true
21
+ })){
22
+ const p = join(dir, entry.name);
23
+ if (entry.isDirectory()) yield* walk(p);
24
+ else yield p;
25
+ }
26
+ }
27
+ /** Crée un projet à partir d'un gabarit versionné avec la CLI (épinglé sur la version du SDK avec laquelle il a été testé). */ export function createApp(o) {
28
+ const framework = o.framework ?? 'react';
29
+ const integration = o.integration ?? 'embedded';
30
+ if (!NAME_RE.test(o.name ?? '')) throw new Error(`Nom invalide « ${o.name} » : minuscules, chiffres et tirets, commençant par une lettre (2 à 63 caractères).`);
31
+ if (!FRAMEWORKS.includes(framework)) throw new Error(`Framework inconnu « ${framework} » (${FRAMEWORKS.join(', ')}).`);
32
+ if (!INTEGRATIONS.includes(integration)) throw new Error(`Intégration inconnue « ${integration} » (${INTEGRATIONS.join(', ')}).`);
33
+ if (integration !== 'embedded') throw new Error(`L'intégration « ${integration} » n'est pas encore disponible dans egen create : seule « embedded » (iframe) l'est.`);
34
+ const template = `${framework}-${integration}`;
35
+ const templateDir = join(o.templatesDir ?? join(PKG_ROOT, 'templates'), template);
36
+ if (!existsSync(templateDir)) throw new Error(`Gabarit introuvable : ${template}`);
37
+ const dir = resolve(o.dir ?? o.name);
38
+ if (existsSync(dir) && readdirSync(dir).length > 0) throw new Error(`Le répertoire ${dir} existe et n'est pas vide : choisir un autre nom ou un autre répertoire.`);
39
+ const require = createRequire(import.meta.url);
40
+ const vars = {
41
+ __NAME__: o.name,
42
+ __TITLE__: o.title ?? titleOf(o.name),
43
+ __SDK_VERSION__: o.sdkVersion ?? require('@egen-civitas/sdk/package.json').version,
44
+ __EGEN_VERSION__: o.egenVersion ?? JSON.parse(readFileSync(join(PKG_ROOT, 'package.json'), 'utf8')).version
45
+ };
46
+ const substitute = (text)=>text.replace(/__[A-Z_]+__/g, (m)=>vars[m] ?? m);
47
+ const files = [];
48
+ for (const src of walk(templateDir)){
49
+ const rel = relative(templateDir, src).replace(/(^|[\\/])_gitignore$/, '$1.gitignore'); // npm ne publie pas les .gitignore
50
+ const out = join(dir, rel);
51
+ mkdirSync(dirname(out), {
52
+ recursive: true
53
+ });
54
+ if (/\.(json|html|md|ts|tsx|vue|js|mjs)$|\.gitignore$/.test(rel)) writeFileSync(out, substitute(readFileSync(src, 'utf8')));
55
+ else copyFileSync(src, out);
56
+ files.push(rel);
57
+ }
58
+ return {
59
+ dir,
60
+ template,
61
+ files: files.sort()
62
+ };
63
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"develop.d.ts","sourceRoot":"","sources":["../../src/commands/develop.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EAKvB,MAAM,UAAU,CAAC;AAyClB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,oBAAoB,CAAC;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,iBAsOvE"}
1
+ {"version":3,"file":"develop.d.ts","sourceRoot":"","sources":["../../src/commands/develop.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EAKvB,MAAM,UAAU,CAAC;AAwDlB,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,oBAAoB,CAAC;IAChC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,OAAO,CAAC;IACxB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,WAAW,iBAyOvE"}
@@ -16,8 +16,8 @@ import { logInfo, logWarn, removeTrailingSlash, resolveBrandDir } from "../utils
16
16
  * `window` APRÈS coup, au moment où la page est servie, le peut encore.
17
17
  *
18
18
  * `windowKey` suit la même convention que window.egenTenantMode
19
- * (voir esm-globals/src/types.ts) — la table EGEN_TENANT_*
20
- * ci-dessous est recopiée à l'identique depuis EGEN_TENANT_ENV_TO_WINDOW_KEY
19
+ * (voir esm-globals/src/types.ts) — les tables EGEN_TENANT_* et EGEN_CTX_*
20
+ * ci-dessous sont recopiées à l'identique depuis EGEN_TENANT_ENV_TO_WINDOW_KEY et EGEN_CTX_ENV_TO_WINDOW_KEY
21
21
  * dans esm-app-shell/rspack.config.js (même mapping, deux moments différents
22
22
  * : build du framework là-bas, service par `egen develop` ici).
23
23
  *
@@ -73,6 +73,73 @@ import { logInfo, logWarn, removeTrailingSlash, resolveBrandDir } from "../utils
73
73
  envKey: 'EGEN_TENANT_ROOT_DOMAIN',
74
74
  windowKey: 'egenTenantRootDomain',
75
75
  type: 'string'
76
+ },
77
+ // Système de contexte organisationnel (Espace/Site) — recopie de EGEN_CTX_ENV_TO_WINDOW_KEY
78
+ // (esm-app-shell/rspack.config.js), même ordre ; verrouillé par tools/env-bridge-drift.test.ts.
79
+ {
80
+ envKey: 'EGEN_CTX_MODE',
81
+ windowKey: 'egenCtxMode',
82
+ type: 'string'
83
+ },
84
+ {
85
+ envKey: 'EGEN_CTX_DEFAULT_SPACE',
86
+ windowKey: 'egenCtxDefaultSpace',
87
+ type: 'string'
88
+ },
89
+ {
90
+ envKey: 'EGEN_CTX_PRESET',
91
+ windowKey: 'egenCtxPreset',
92
+ type: 'string'
93
+ },
94
+ {
95
+ envKey: 'EGEN_CTX_BOOTSTRAP_URL',
96
+ windowKey: 'egenCtxBootstrapUrl',
97
+ type: 'string'
98
+ },
99
+ {
100
+ envKey: 'EGEN_CTX_ADMIN',
101
+ windowKey: 'egenCtxAdmin',
102
+ type: 'string'
103
+ },
104
+ {
105
+ envKey: 'EGEN_CTX_ADMIN_PRIVILEGE',
106
+ windowKey: 'egenCtxAdminPrivilege',
107
+ type: 'string'
108
+ },
109
+ {
110
+ envKey: 'EGEN_CTX_LOCK',
111
+ windowKey: 'egenCtxLock',
112
+ type: 'string'
113
+ },
114
+ {
115
+ envKey: 'EGEN_CTX_PERSIST',
116
+ windowKey: 'egenCtxPersist',
117
+ type: 'string'
118
+ },
119
+ {
120
+ envKey: 'EGEN_CTX_PERSIST_URL',
121
+ windowKey: 'egenCtxPersistUrl',
122
+ type: 'string'
123
+ },
124
+ {
125
+ envKey: 'EGEN_CTX_REMEMBER',
126
+ windowKey: 'egenCtxRemember',
127
+ type: 'string'
128
+ },
129
+ {
130
+ envKey: 'EGEN_CTX_URL_SYNC',
131
+ windowKey: 'egenCtxUrlSync',
132
+ type: 'string'
133
+ },
134
+ {
135
+ envKey: 'EGEN_CTX_SPACE_PARAM',
136
+ windowKey: 'egenCtxSpaceParam',
137
+ type: 'string'
138
+ },
139
+ {
140
+ envKey: 'EGEN_CTX_TENANT_SCOPED',
141
+ windowKey: 'egenCtxTenantScoped',
142
+ type: 'string'
76
143
  }
77
144
  ];
78
145
  export async function runDevelop(args, signal) {
@@ -111,11 +178,14 @@ export async function runDevelop(args, signal) {
111
178
  }
112
179
  }
113
180
  if (runtimeWindowOverrides.egenDevNoAuth) {
114
- logInfo('EGEN_DEV_NO_AUTH=true — bypass d\'authentification actif (session admin fictive, sans backend).');
181
+ logInfo("EGEN_DEV_NO_AUTH=true — bypass d'authentification actif (session admin fictive, sans backend).");
115
182
  }
116
183
  if (runtimeWindowOverrides.egenTenantMode && runtimeWindowOverrides.egenTenantMode !== 'off') {
117
184
  logInfo(`EGEN_TENANT_MODE=${runtimeWindowOverrides.egenTenantMode} — système multi-tenant actif.`);
118
185
  }
186
+ if (runtimeWindowOverrides.egenCtxMode && runtimeWindowOverrides.egenCtxMode !== 'off') {
187
+ logInfo(`EGEN_CTX_MODE=${runtimeWindowOverrides.egenCtxMode} — système de contexte (Espace/Site) actif.`);
188
+ }
119
189
  // URL same-origin du flux de logs du terminal, lue par l'app de logs du shell.
120
190
  const logsPath = `${spaPath}/__egen_logs__`;
121
191
  if (logsPort) runtimeWindowOverrides.egenLogsUrl = logsPath;
@@ -0,0 +1,16 @@
1
+ import type { AppIssue } from './check-app';
2
+ export interface ValidateManifestOptions {
3
+ /** Chemin de la déclaration (défaut : `egen-config.json` du répertoire courant). */
4
+ file?: string;
5
+ allowInsecureLocalhost?: boolean;
6
+ }
7
+ export interface ManifestReport {
8
+ file: string;
9
+ valid: boolean;
10
+ /** `1` ou `2` quand la version est lisible. */
11
+ version?: number;
12
+ issues: AppIssue[];
13
+ }
14
+ /** Valide une déclaration `egen-config.json` avec `validateManifest` (la même validation que le Shell). */
15
+ export declare function validateManifestFile(o?: ValidateManifestOptions): ManifestReport;
16
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/commands/manifest.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sBAAsB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,EAAE,CAAC;CACpB;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,CAAC,GAAE,uBAA4B,GAAG,cAAc,CAmBpF"}
@@ -0,0 +1,54 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { validateManifest } from "@egen-civitas/esm-embed-protocol";
4
+ /** Valide une déclaration `egen-config.json` avec `validateManifest` (la même validation que le Shell). */ export function validateManifestFile(o = {}) {
5
+ const file = resolve(o.file ?? 'egen-config.json');
6
+ const issues = [];
7
+ let raw;
8
+ try {
9
+ raw = JSON.parse(readFileSync(file, 'utf8'));
10
+ } catch (e) {
11
+ const missing = e.code === 'ENOENT';
12
+ issues.push({
13
+ level: 'error',
14
+ code: 'E-MANIFEST',
15
+ message: missing ? `Fichier introuvable : ${file}` : `JSON invalide (${e.message})`,
16
+ file
17
+ });
18
+ return {
19
+ file,
20
+ valid: false,
21
+ issues
22
+ };
23
+ }
24
+ const version = typeof raw?.manifestVersion === 'number' ? raw.manifestVersion : undefined;
25
+ const r = validateManifest(raw, {
26
+ allowInsecureLocalhost: o.allowInsecureLocalhost
27
+ });
28
+ if (!r.ok) {
29
+ for (const message of r.errors)issues.push({
30
+ level: 'error',
31
+ code: 'E-MANIFEST',
32
+ message,
33
+ file
34
+ });
35
+ return {
36
+ file,
37
+ valid: false,
38
+ version,
39
+ issues
40
+ };
41
+ }
42
+ if (version === 1) issues.push({
43
+ level: 'warn',
44
+ code: 'E-MANIFEST-V1',
45
+ message: 'manifestVersion 1 : accepté, mais migrer vers 2 (additif : description, publisher, sdk.range, provides…)',
46
+ file
47
+ });
48
+ return {
49
+ file,
50
+ valid: true,
51
+ version,
52
+ issues
53
+ };
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egen-civitas/egen",
3
- "version": "3.0.1",
3
+ "version": "3.2.0",
4
4
  "license": "MPL-2.0",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -9,7 +9,8 @@
9
9
  "default-rspack-config.cjs",
10
10
  "default-rspack-config.d.cts",
11
11
  "default-webpack-config.cjs",
12
- "default-webpack-config.d.cts"
12
+ "default-webpack-config.d.cts",
13
+ "templates"
13
14
  ],
14
15
  "bin": {
15
16
  "egen": "dist/cli.js",
@@ -60,8 +61,11 @@
60
61
  ],
61
62
  "homepage": "https://github.com/amourgit/Frontend-esm-framework/tree/main/packages/tooling/egen#readme",
62
63
  "dependencies": {
63
- "@egen-civitas/esm-app-shell": "^4.0.0",
64
- "@egen-civitas/rspack-config": "^3.0.0",
64
+ "@egen-civitas/esm-app-shell": "^4.3.0",
65
+ "@egen-civitas/esm-embed-protocol": "^0.12.0",
66
+ "@egen-civitas/esm-embed-testing": "^0.8.0",
67
+ "@egen-civitas/rspack-config": "^3.1.0",
68
+ "@egen-civitas/sdk": "^0.8.0",
65
69
  "@egen-civitas/webpack-config": "^2.0.0",
66
70
  "@inquirer/prompts": "8.3.2",
67
71
  "@pnpm/npm-conf": "^3.0.2",
@@ -107,6 +111,7 @@
107
111
  "@types/react": "^18.3.21",
108
112
  "@types/semver": "^7",
109
113
  "@types/yargs": "^17.0.0",
114
+ "@vue/compiler-sfc": "^3.5.0",
110
115
  "concurrently": "^9.2.1",
111
116
  "cross-env": "^10.1.0",
112
117
  "postcss": "^8.5.8",
@@ -0,0 +1,14 @@
1
+ # __TITLE__
2
+
3
+ Application EGEN embarquée (React + Vite), créée avec `egen create`.
4
+
5
+ ```bash
6
+ yarn install
7
+ yarn dev # http://localhost:5173
8
+ yarn test # fonctionne sans Shell (mode autonome)
9
+ yarn check # egen check-app : déclaration, sécurité, dépréciations
10
+ ```
11
+
12
+ - `public/egen-config.json` : la déclaration de l'app (**à servir à `/egen-config.json`**). Remplacer `url` par l'URL réelle.
13
+ - `src/egen.ts` : connexion au Shell ; `VITE_EGEN_SHELL_ORIGIN` fixe l'origine exacte du Shell.
14
+ - Les droits (`capabilities`) sont une *demande* : l'opérateur du Shell décide de ce qui est accordé (`yarn check` signale les écarts évidents).
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .env.local
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__TITLE__</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="/src/main.tsx"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "__NAME__",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "tsc --noEmit && vite build",
9
+ "preview": "vite preview",
10
+ "test": "vitest run",
11
+ "check": "egen check-app"
12
+ },
13
+ "dependencies": {
14
+ "@egen-civitas/sdk": "^__SDK_VERSION__",
15
+ "react": "^18.3.1",
16
+ "react-dom": "^18.3.1"
17
+ },
18
+ "devDependencies": {
19
+ "@egen-civitas/egen": "^__EGEN_VERSION__",
20
+ "@types/react": "^18.3.12",
21
+ "@types/react-dom": "^18.3.1",
22
+ "@vitejs/plugin-react": "^4.3.4",
23
+ "typescript": "^5.8.3",
24
+ "vite": "^6.0.0",
25
+ "vitest": "^3.0.0"
26
+ }
27
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "manifestVersion": 2,
3
+ "name": "__NAME__",
4
+ "version": "0.1.0",
5
+ "title": "__TITLE__",
6
+ "description": "Application intégrée au Shell EGEN.",
7
+ "url": "https://__NAME__.example.org",
8
+ "route": "__NAME__",
9
+ "technology": "react",
10
+ "integration": "embedded",
11
+ "sdk": { "range": "^__SDK_VERSION__" },
12
+ "navigation": { "mode": "history", "sensitiveParams": ["token", "access_token"] },
13
+ "locales": ["fr", "en"],
14
+ "capabilities": { "tenant": {}, "locale": {}, "navigation": {}, "lifecycle": {}, "notifications": {} }
15
+ }
@@ -0,0 +1,14 @@
1
+ import { useEgen, useEgenLocale, useEgenNotify } from '@egen-civitas/sdk/react';
2
+
3
+ export function App() {
4
+ const egen = useEgen();
5
+ const { value: locale } = useEgenLocale();
6
+ const { notify } = useEgenNotify();
7
+ return (
8
+ <main lang={locale}>
9
+ <h1>__TITLE__</h1>
10
+ <p>Mode : {egen.mode}</p>
11
+ <button onClick={() => void notify({ kind: 'success', title: 'Enregistré' })}>Enregistrer</button>
12
+ </main>
13
+ );
14
+ }
@@ -0,0 +1,9 @@
1
+ import { connect } from '@egen-civitas/sdk';
2
+ import { expect, it } from 'vitest';
3
+
4
+ it("fonctionne sans Shell : l'app passe en mode autonome", async () => {
5
+ const app = await connect({ moduleName: '__NAME__', mode: 'standalone', capabilities: ['locale'], standalone: { locale: 'fr' } });
6
+ expect(app.mode).toBe('standalone');
7
+ await expect(app.locale.get()).resolves.toBe('fr');
8
+ app.close();
9
+ });
@@ -0,0 +1,12 @@
1
+ import type { ConnectOptions } from '@egen-civitas/sdk';
2
+
3
+ /**
4
+ * Connexion à EGEN. `hostOrigins` : origines EXACTES du Shell (jamais `*`). Hors Shell (page ouverte seule), l'app passe
5
+ * automatiquement en mode autonome : le même code fonctionne avec ou sans EGEN.
6
+ */
7
+ export const egenOptions: ConnectOptions = {
8
+ moduleName: '__NAME__',
9
+ hostOrigins: [import.meta.env.VITE_EGEN_SHELL_ORIGIN ?? 'http://localhost:8081'],
10
+ capabilities: ['tenant', 'locale', 'navigation', 'lifecycle', 'notifications'],
11
+ required: ['navigation'],
12
+ };
@@ -0,0 +1,13 @@
1
+ import { EgenProvider } from '@egen-civitas/sdk/react';
2
+ import { StrictMode } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { App } from './App';
5
+ import { egenOptions } from './egen';
6
+
7
+ createRoot(document.getElementById('root')!).render(
8
+ <StrictMode>
9
+ <EgenProvider options={egenOptions} loading={<p>Connexion au Shell…</p>}>
10
+ <App />
11
+ </EgenProvider>
12
+ </StrictMode>,
13
+ );
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "jsx": "react-jsx",
8
+ "strict": true,
9
+ "skipLibCheck": true,
10
+ "noEmit": true,
11
+ "types": ["vite/client"]
12
+ },
13
+ "include": ["src"]
14
+ }
@@ -0,0 +1,4 @@
1
+ import react from '@vitejs/plugin-react';
2
+ import { defineConfig } from 'vite';
3
+
4
+ export default defineConfig({ plugins: [react()], server: { port: 5173 } });
@@ -0,0 +1,13 @@
1
+ # __TITLE__
2
+
3
+ Application EGEN embarquée (JavaScript natif, sans bundler), créée avec `egen create`.
4
+
5
+ ```bash
6
+ yarn install
7
+ yarn dev # http://localhost:5173
8
+ yarn check # egen check-app : déclaration, sécurité, dépréciations
9
+ ```
10
+
11
+ - `public/egen-config.json` : la déclaration de l'app (**à servir à `/egen-config.json`**). Remplacer `url` par l'URL réelle.
12
+ - `src/egen.ts` : connexion au Shell ; `VITE_EGEN_SHELL_ORIGIN` fixe l'origine exacte du Shell.
13
+ - Les droits (`capabilities`) sont une *demande* : l'opérateur du Shell décide de ce qui est accordé (`yarn check` signale les écarts évidents).
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .env.local
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "__NAME__",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "vendor": "node scripts/vendor.mjs",
8
+ "dev": "node scripts/vendor.mjs && npx --yes http-server public -p 5173 -c-1",
9
+ "check": "egen check-app"
10
+ },
11
+ "devDependencies": {
12
+ "@egen-civitas/egen": "^__EGEN_VERSION__",
13
+ "@egen-civitas/sdk": "^__SDK_VERSION__"
14
+ }
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "manifestVersion": 2,
3
+ "name": "__NAME__",
4
+ "version": "0.1.0",
5
+ "title": "__TITLE__",
6
+ "description": "Application intégrée au Shell EGEN.",
7
+ "url": "https://__NAME__.example.org",
8
+ "route": "__NAME__",
9
+ "technology": "vanilla",
10
+ "integration": "embedded",
11
+ "sdk": { "range": "^__SDK_VERSION__" },
12
+ "navigation": { "mode": "history", "sensitiveParams": ["token", "access_token"] },
13
+ "locales": ["fr", "en"],
14
+ "capabilities": { "tenant": {}, "locale": {}, "navigation": {}, "lifecycle": {}, "notifications": {} }
15
+ }
@@ -0,0 +1,19 @@
1
+ <!doctype html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__TITLE__</title>
7
+ <script type="importmap">
8
+ { "imports": { "@egen-civitas/sdk": "./vendor/egen-sdk.js" } }
9
+ </script>
10
+ </head>
11
+ <body>
12
+ <main>
13
+ <h1>__TITLE__</h1>
14
+ <p id="mode">Connexion au Shell…</p>
15
+ <button id="save" hidden>Enregistrer</button>
16
+ </main>
17
+ <script type="module" src="./main.js"></script>
18
+ </body>
19
+ </html>
@@ -0,0 +1,15 @@
1
+ import { connect } from '@egen-civitas/sdk';
2
+
3
+ // Origines EXACTES du Shell (jamais `*`). Hors Shell, l'app passe en mode autonome.
4
+ const egen = await connect({
5
+ moduleName: '__NAME__',
6
+ hostOrigins: ['http://localhost:8081'],
7
+ capabilities: ['locale', 'navigation', 'lifecycle', 'notifications'],
8
+ });
9
+
10
+ document.documentElement.lang = await egen.locale.get();
11
+ document.getElementById('mode').textContent = `Mode : ${egen.mode}`;
12
+ const save = document.getElementById('save');
13
+ save.hidden = false;
14
+ save.addEventListener('click', () => egen.notify({ kind: 'success', title: 'Enregistré' }));
15
+ window.addEventListener('pagehide', () => egen.close());
@@ -0,0 +1,10 @@
1
+ // Copie le bundle navigateur du SDK (ESM autonome, sans import nu) à côté de la page : l'import map le référence.
2
+ import { copyFileSync, mkdirSync } from 'node:fs';
3
+ import { createRequire } from 'node:module';
4
+ import { dirname, join } from 'node:path';
5
+
6
+ const require = createRequire(import.meta.url);
7
+ const pkgDir = dirname(require.resolve('@egen-civitas/sdk/package.json'));
8
+ mkdirSync('public/vendor', { recursive: true });
9
+ copyFileSync(join(pkgDir, 'dist/bundle/egen-sdk.js'), 'public/vendor/egen-sdk.js');
10
+ process.stdout.write('public/vendor/egen-sdk.js\n');
@@ -0,0 +1,14 @@
1
+ # __TITLE__
2
+
3
+ Application EGEN embarquée (Vue 3 + Vite), créée avec `egen create`.
4
+
5
+ ```bash
6
+ yarn install
7
+ yarn dev # http://localhost:5173
8
+ yarn test # fonctionne sans Shell (mode autonome)
9
+ yarn check # egen check-app : déclaration, sécurité, dépréciations
10
+ ```
11
+
12
+ - `public/egen-config.json` : la déclaration de l'app (**à servir à `/egen-config.json`**). Remplacer `url` par l'URL réelle.
13
+ - `src/egen.ts` : connexion au Shell ; `VITE_EGEN_SHELL_ORIGIN` fixe l'origine exacte du Shell.
14
+ - Les droits (`capabilities`) sont une *demande* : l'opérateur du Shell décide de ce qui est accordé (`yarn check` signale les écarts évidents).
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ dist
3
+ .env.local
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="fr">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>__TITLE__</title>
7
+ </head>
8
+ <body>
9
+ <div id="app"></div>
10
+ <script type="module" src="/src/main.ts"></script>
11
+ </body>
12
+ </html>
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "__NAME__",
3
+ "private": true,
4
+ "version": "0.1.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite",
8
+ "build": "vue-tsc --noEmit && vite build",
9
+ "preview": "vite preview",
10
+ "test": "vitest run",
11
+ "check": "egen check-app"
12
+ },
13
+ "dependencies": {
14
+ "@egen-civitas/sdk": "^__SDK_VERSION__",
15
+ "vue": "^3.5.0"
16
+ },
17
+ "devDependencies": {
18
+ "@egen-civitas/egen": "^__EGEN_VERSION__",
19
+ "@vitejs/plugin-vue": "^5.2.0",
20
+ "typescript": "^5.8.3",
21
+ "vite": "^6.0.0",
22
+ "vitest": "^3.0.0",
23
+ "vue-tsc": "^2.2.0"
24
+ }
25
+ }