@egen-civitas/esm-nextjs-utils 0.2.0 → 0.3.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @egen-civitas/esm-nextjs-utils
2
2
 
3
+ ## 0.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 1d47a26: L'iframe créée par `getEmbedLifecycle` porte désormais `data-egen-fill` :
8
+ le conteneur single-spa reçoit `height: 100%` de `#egen-scroll-region`
9
+ (règle opt-in du styleguide), sans travail requis côté application
10
+ embarquée.
11
+
12
+ ## 0.3.0
13
+
14
+ ### Minor Changes
15
+
16
+ - 3f171d9: Navigation partagée Shell ↔ application embarquée (protocole 1.1, additif) : l'URL du Core reflète la page courante de l'app (actualisation, retour/avance, partage).
17
+
18
+ - Hôte : option `navigation` de `getEmbedLifecycle` (`route`, `mode` `history` | `hash` | `none`, `sensitiveParams`, `pathMap`, `onTitle`) ; messages `hello`, `location`, `goto`.
19
+ - Client : `reportLocation()` et `onGoto()`.
20
+ - Script injectable sans dépendance `assets/egen-bridge.js` (export `@egen-civitas/esm-nextjs-utils/egen-bridge.js`).
21
+ - Fonctions pures exportées (`normalizeAppPath`, `stripSensitive`, `coreSubpath`, `buildCoreUrl`, `buildEmbedSrc`…). Paramètres sensibles jamais recopiés dans l'URL du Core.
22
+ - Sans l'option `navigation`, comportement inchangé.
23
+
3
24
  ## 0.2.0
4
25
 
5
26
  ### Minor Changes
package/README.md CHANGED
@@ -69,3 +69,16 @@ App → Shell : `ready`, `navigate { to }`, `resize { height }`, `title { title
69
69
  - Les apps natives (Android/iOS) exigent un contenu embarqué : une iframe distante n'y est pas adaptée.
70
70
 
71
71
  Tests : `yarn test` (fenêtres simulées ; l'exécution inter-fenêtres dans un vrai navigateur reste à valider).
72
+
73
+ ## Navigation partagée (protocole 1.1)
74
+
75
+ L'URL du Core reflète la page courante de l'application embarquée : actualisation, retour/avance et liens partageables fonctionnent comme pour une app interne.
76
+
77
+ ```ts
78
+ getEmbedLifecycle({
79
+ moduleName, featureName, url,
80
+ navigation: { route: 'mon-app', mode: 'history' /* | 'hash' | 'none' */, sensitiveParams: ['invite'] },
81
+ });
82
+ ```
83
+
84
+ Côté application : soit le script injectable `assets/egen-bridge.js` (`<script src="/egen-bridge.js" defer data-mode="history">`), soit le client (`bridge.reportLocation(path)`, `bridge.onGoto(fn)`). Sans l'option `navigation`, rien ne change. Détails, sécurité et exemples : `docs/integration-apps/16-navigation-partagee-apps-externes.md` du dépôt Core.
package/dist/client.d.ts CHANGED
@@ -23,6 +23,13 @@ export interface EgenBridge {
23
23
  setHeight(height: number): void;
24
24
  /** Annonce un titre accessible pour l'iframe. */
25
25
  setTitle(title: string): void;
26
+ /** Protocole 1.1 : annonce la page courante de l'application (`/chemin?q#h`) ; `replace` n'ajoute pas d'entrée d'historique. */
27
+ reportLocation(path: string, options?: {
28
+ replace?: boolean;
29
+ title?: string;
30
+ }): void;
31
+ /** Protocole 1.1 : le Shell demande d'aller à `path` (retour/avance, lien du Core) ; renvoie le désabonnement. */
32
+ onGoto(listener: (path: string) => void): () => void;
26
33
  /** Annonce automatiquement la hauteur du document (ResizeObserver). */
27
34
  autoResize(): () => void;
28
35
  destroy(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAoB,KAAK,SAAS,EAAsC,MAAM,eAAe,CAAC;AAErG,YAAY,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,UAAU,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,kBAAkB,EAAE,MAAM,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,UAAU;IACzB,6DAA6D;IAC7D,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1B,mDAAmD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,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gIAAgI;IAChI,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACpF,kHAAkH;IAClH,MAAM,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACrD,uEAAuE;IACvE,UAAU,IAAI,MAAM,IAAI,CAAC;IACzB,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,UAAU,CAsEpE"}
package/dist/client.js CHANGED
@@ -65,6 +65,7 @@ export function createEgenBridge(opts) {
65
65
  if (host === window) throw new Error("createEgenBridge doit s'exécuter dans une iframe affichée par le Shell EGEN.");
66
66
  var state = {};
67
67
  var listeners = new Set();
68
+ var gotoListeners = new Set();
68
69
  var resolveReady;
69
70
  var ready = new Promise(function(r) {
70
71
  return resolveReady = r;
@@ -90,6 +91,18 @@ export function createEgenBridge(opts) {
90
91
  session: msg.session
91
92
  });
92
93
  emit();
94
+ } else if (msg.kind === 'hello') {
95
+ send({
96
+ kind: 'ready',
97
+ caps: [
98
+ 'location',
99
+ 'goto'
100
+ ]
101
+ });
102
+ } else if (msg.kind === 'goto') {
103
+ gotoListeners.forEach(function(l) {
104
+ return l(msg.path);
105
+ });
93
106
  } else if (msg.kind === 'locale') {
94
107
  state = _object_spread_props(_object_spread({}, state), {
95
108
  locale: msg.locale
@@ -107,13 +120,31 @@ export function createEgenBridge(opts) {
107
120
  });
108
121
  };
109
122
  send({
110
- kind: 'ready'
123
+ kind: 'ready',
124
+ caps: [
125
+ 'location',
126
+ 'goto'
127
+ ]
111
128
  });
112
129
  return {
113
130
  ready: ready,
114
131
  getState: function getState() {
115
132
  return state;
116
133
  },
134
+ reportLocation: function reportLocation(path, o) {
135
+ return send({
136
+ kind: 'location',
137
+ path: path,
138
+ replace: o === null || o === void 0 ? void 0 : o.replace,
139
+ title: o === null || o === void 0 ? void 0 : o.title
140
+ });
141
+ },
142
+ onGoto: function onGoto(l) {
143
+ gotoListeners.add(l);
144
+ return function() {
145
+ return gotoListeners.delete(l);
146
+ };
147
+ },
117
148
  subscribe: function subscribe(l) {
118
149
  listeners.add(l);
119
150
  return function() {
package/dist/host.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { LifeCycles } from 'single-spa';
2
2
  import { type LifecycleExport, type LifecycleOptions } from '@egen-civitas/esm-integration-utils';
3
+ import { type NavigationOptions } from './navigation.js';
3
4
  export interface EmbedLifecycleOptions extends LifecycleOptions {
4
5
  /** URL de l'application embarquée (ou fonction des props Single-SPA). */
5
6
  url: string | ((props: Record<string, any>) => string);
@@ -15,6 +16,11 @@ export interface EmbedLifecycleOptions extends LifecycleOptions {
15
16
  minHeight?: number;
16
17
  /** Navigation demandée par l'application (défaut : `singleSpaNavigate(spaBase + chemin)`). */
17
18
  onNavigate?: (to: string) => void;
19
+ /**
20
+ * Navigation partagée (protocole 1.1) : l'URL du Core reflète la page courante de l'application et inversement
21
+ * (actualisation, retour/avance, lien partageable). Absent ou `mode: 'none'` : comportement opaque d'origine.
22
+ */
23
+ navigation?: NavigationOptions;
18
24
  }
19
25
  /** Chemin relatif interne uniquement (`/x`), jamais d'URL absolue ni `//hôte`. */
20
26
  export declare function isSafeInternalPath(to: unknown): to is string;
@@ -1 +1 @@
1
- {"version":3,"file":"host.d.ts","sourceRoot":"","sources":["../src/host.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAML,KAAK,eAAe,EACpB,KAAK,gBAAgB,EAEtB,MAAM,qCAAqC,C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AwF;IACxF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8FAA8F;IAC9F,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC;;;OAGG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;CAChC;AAKD,kFAAkF;AAClF,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,IAAI,MAAM,CAE5D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,UAAU,CAwJ7E;AAED,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,qBAAqB,GAAG,eAAe,CAEhF"}
package/dist/host.js CHANGED
@@ -1,4 +1,57 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _object_spread(target) {
15
+ for(var i = 1; i < arguments.length; i++){
16
+ var source = arguments[i] != null ? arguments[i] : {};
17
+ var ownKeys = Object.keys(source);
18
+ if (typeof Object.getOwnPropertySymbols === "function") {
19
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
+ }));
22
+ }
23
+ ownKeys.forEach(function(key) {
24
+ _define_property(target, key, source[key]);
25
+ });
26
+ }
27
+ return target;
28
+ }
29
+ function ownKeys(object, enumerableOnly) {
30
+ var keys = Object.keys(object);
31
+ if (Object.getOwnPropertySymbols) {
32
+ var symbols = Object.getOwnPropertySymbols(object);
33
+ if (enumerableOnly) {
34
+ symbols = symbols.filter(function(sym) {
35
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
36
+ });
37
+ }
38
+ keys.push.apply(keys, symbols);
39
+ }
40
+ return keys;
41
+ }
42
+ function _object_spread_props(target, source) {
43
+ source = source != null ? source : {};
44
+ if (Object.getOwnPropertyDescriptors) {
45
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
46
+ } else {
47
+ ownKeys(Object(source)).forEach(function(key) {
48
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
49
+ });
50
+ }
51
+ return target;
52
+ }
1
53
  import { assertLifecycleOptions, resolveMountTarget, toLifecycleExport, watchSession, watchTranslations } from '@egen-civitas/esm-integration-utils';
54
+ import { buildCoreUrl, buildEmbedSrc, coreSubpath, createRateLimiter, stripSensitive, toAppPath, toCorePath } from './navigation.js';
2
55
  import { DEFAULT_SESSION_FIELDS, isEnvelope, pickFields, wrap } from './protocol.js';
3
56
  var DEFAULT_SANDBOX = 'allow-scripts allow-same-origin allow-forms allow-popups';
4
57
  var SAFE_PATH = /^\/(?!\/)[^\s\\]*$/;
@@ -22,9 +75,27 @@ var SAFE_PATH = /^\/(?!\/)[^\s\\]*$/;
22
75
  return Promise.resolve();
23
76
  },
24
77
  mount: function mount(props) {
25
- var _opts_allowedOrigin, _opts_sandbox, _opts_title, _opts_minHeight;
78
+ var _opts_navigation_mode, _opts_navigation_mode1, _currentCorePath, _toAppPath, _opts_allowedOrigin, _opts_sandbox, _opts_title, _opts_minHeight;
26
79
  var target = resolveMountTarget(props);
27
- var src = typeof opts.url === 'function' ? opts.url(props) : opts.url;
80
+ var baseUrl = typeof opts.url === 'function' ? opts.url(props) : opts.url;
81
+ var nav = opts.navigation && ((_opts_navigation_mode = opts.navigation.mode) !== null && _opts_navigation_mode !== void 0 ? _opts_navigation_mode : 'history') !== 'none' ? _object_spread_props(_object_spread({}, opts.navigation), {
82
+ mode: (_opts_navigation_mode1 = opts.navigation.mode) !== null && _opts_navigation_mode1 !== void 0 ? _opts_navigation_mode1 : 'history'
83
+ }) : undefined;
84
+ var spaBase = function spaBase() {
85
+ var _ref;
86
+ var _window_getEgenSpaBase, _window;
87
+ return (_ref = (_window_getEgenSpaBase = (_window = window).getEgenSpaBase) === null || _window_getEgenSpaBase === void 0 ? void 0 : _window_getEgenSpaBase.call(_window)) !== null && _ref !== void 0 ? _ref : '/';
88
+ };
89
+ /** Page courante du Core, en chemin (`/x?q#h`) relatif à la route de l'application ; `null` hors de cette page. */ var currentCorePath = function currentCorePath() {
90
+ if (!nav) return null;
91
+ var sub = coreSubpath(window.location.pathname, spaBase(), nav.route);
92
+ if (sub === null) return null;
93
+ var raw = sub + window.location.search + window.location.hash;
94
+ return stripSensitive(raw, nav.sensitiveParams);
95
+ };
96
+ var lastCorePath = (_currentCorePath = currentCorePath()) !== null && _currentCorePath !== void 0 ? _currentCorePath : '/';
97
+ var initialAppPath = nav ? (_toAppPath = toAppPath(lastCorePath, nav)) !== null && _toAppPath !== void 0 ? _toAppPath : '/' : '/';
98
+ var src = nav ? buildEmbedSrc(baseUrl, initialAppPath, nav.mode) : baseUrl;
28
99
  var origin = (_opts_allowedOrigin = opts.allowedOrigin) !== null && _opts_allowedOrigin !== void 0 ? _opts_allowedOrigin : new URL(src, window.location.href).origin;
29
100
  if (origin === '*' || origin === 'null') throw new Error('allowedOrigin invalide : une origine explicite est requise.');
30
101
  var sandbox = (_opts_sandbox = opts.sandbox) !== null && _opts_sandbox !== void 0 ? _opts_sandbox : DEFAULT_SANDBOX;
@@ -36,6 +107,9 @@ var SAFE_PATH = /^\/(?!\/)[^\s\\]*$/;
36
107
  iframe.title = (_opts_title = opts.title) !== null && _opts_title !== void 0 ? _opts_title : opts.featureName;
37
108
  iframe.setAttribute('sandbox', sandbox);
38
109
  iframe.setAttribute('referrerpolicy', 'strict-origin-when-cross-origin');
110
+ // Demande au Shell de donner à ce conteneur la hauteur de
111
+ // #egen-scroll-region (règle :has(> [data-egen-fill]) du styleguide).
112
+ iframe.setAttribute('data-egen-fill', '');
39
113
  iframe.style.cssText = "width:100%;border:0;display:block;min-height:".concat((_opts_minHeight = opts.minHeight) !== null && _opts_minHeight !== void 0 ? _opts_minHeight : 400, "px");
40
114
  var send = function send(message) {
41
115
  var _iframe_contentWindow;
@@ -44,6 +118,9 @@ var SAFE_PATH = /^\/(?!\/)[^\s\\]*$/;
44
118
  var stop = [];
45
119
  var ready = false;
46
120
  var lastSession;
121
+ var bridgeSeen = false;
122
+ var seq = 0;
123
+ var allowLocation = createRateLimiter();
47
124
  var onMessage = function onMessage(event) {
48
125
  if (event.source !== iframe.contentWindow || event.origin !== origin) return;
49
126
  if (!isEnvelope(event.data, opts.moduleName)) return;
@@ -53,13 +130,18 @@ var SAFE_PATH = /^\/(?!\/)[^\s\\]*$/;
53
130
  var _ref;
54
131
  var _window_i18next, _window_getEgenSpaBase, _window;
55
132
  ready = true;
133
+ bridgeSeen = true;
56
134
  send({
57
135
  kind: 'init',
58
136
  payload: {
59
137
  moduleName: opts.moduleName,
60
138
  locale: (_window_i18next = window.i18next) === null || _window_i18next === void 0 ? void 0 : _window_i18next.language,
61
139
  spaBase: (_ref = (_window_getEgenSpaBase = (_window = window).getEgenSpaBase) === null || _window_getEgenSpaBase === void 0 ? void 0 : _window_getEgenSpaBase.call(_window)) !== null && _ref !== void 0 ? _ref : '/',
62
- session: lastSession
140
+ session: lastSession,
141
+ navigation: nav ? {
142
+ mode: nav.mode,
143
+ route: nav.route
144
+ } : undefined
63
145
  }
64
146
  });
65
147
  break;
@@ -79,12 +161,61 @@ var SAFE_PATH = /^\/(?!\/)[^\s\\]*$/;
79
161
  case 'title':
80
162
  if (typeof msg.title === 'string') iframe.title = msg.title.slice(0, 200);
81
163
  break;
164
+ case 'location':
165
+ {
166
+ if (!nav || !allowLocation()) break;
167
+ bridgeSeen = true;
168
+ if (typeof msg.title === 'string') {
169
+ var _nav_onTitle;
170
+ iframe.title = msg.title.slice(0, 200);
171
+ (_nav_onTitle = nav.onTitle) === null || _nav_onTitle === void 0 ? void 0 : _nav_onTitle.call(nav, iframe.title);
172
+ }
173
+ var corePath = toCorePath(msg.path, nav);
174
+ if (!corePath || corePath === lastCorePath) break;
175
+ lastCorePath = corePath;
176
+ var url = buildCoreUrl(spaBase(), nav.route, corePath);
177
+ // History API (surchargée par Single-SPA) : la page reste active (la route correspond toujours), sans remontage.
178
+ window.history[msg.replace ? 'replaceState' : 'pushState'](window.history.state, '', url);
179
+ break;
180
+ }
82
181
  }
83
182
  };
84
183
  window.addEventListener('message', onMessage);
85
184
  stop.push(function() {
86
185
  return window.removeEventListener('message', onMessage);
87
186
  });
187
+ if (nav) {
188
+ // poignée de main à chaque chargement de l'iframe (le script injectable n'a pas besoin de connaître l'origine du Shell)
189
+ var onLoad = function onLoad() {
190
+ return send({
191
+ kind: 'hello'
192
+ });
193
+ };
194
+ iframe.addEventListener('load', onLoad);
195
+ stop.push(function() {
196
+ return iframe.removeEventListener('load', onLoad);
197
+ });
198
+ // URL du Core modifiée hors de l'application (retour/avance, lien) → l'application suit
199
+ var onCoreLocation = function onCoreLocation() {
200
+ var cur = currentCorePath();
201
+ if (cur === null || cur === lastCorePath) return;
202
+ lastCorePath = cur;
203
+ var appPath = toAppPath(cur, nav);
204
+ if (!appPath) return;
205
+ if (bridgeSeen) send({
206
+ kind: 'goto',
207
+ path: appPath,
208
+ seq: ++seq
209
+ });
210
+ else iframe.src = buildEmbedSrc(baseUrl, appPath, nav.mode);
211
+ };
212
+ window.addEventListener('single-spa:routing-event', onCoreLocation);
213
+ window.addEventListener('popstate', onCoreLocation);
214
+ stop.push(function() {
215
+ window.removeEventListener('single-spa:routing-event', onCoreLocation);
216
+ window.removeEventListener('popstate', onCoreLocation);
217
+ });
218
+ }
88
219
  stop.push(watchSession(function(session) {
89
220
  lastSession = pickFields(session, fields);
90
221
  if (ready) send({
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './host.js';
2
+ export * from './navigation.js';
2
3
  export * from './protocol.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './host.js';
2
+ export * from './navigation.js';
2
3
  export * from './protocol.js';