@wippy-fe/types-global-proxy 0.0.22 → 0.0.23

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 (2) hide show
  1. package/index.d.ts +77 -16
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -25,12 +25,23 @@ declare namespace PageApi {
25
25
  content_type?: 'text/html' | 'text/markdown' | 'application/json';
26
26
  /** Per-page config overrides — merged into AppConfig before CSS injection. Populated from registry entry config_overrides. */
27
27
  configOverrides?: AppConfigOverrides;
28
+ /**
29
+ * Optional Vue-Router-4 path that claims a top-level URL for this page.
30
+ * v1 canonical form: `/<literal>/:part(.*)*` (e.g. `/keeper/:part(.*)*`, `/:part(.*)*`).
31
+ * When set, the FE registers a dynamic route that renders this page at the claimed URL.
32
+ */
33
+ mountRoute?: string;
28
34
  }
29
35
  interface PagesResponse {
30
36
  count: number;
31
37
  pages: Page[];
32
38
  success: boolean;
33
39
  }
40
+ interface PagesRoutesResponse {
41
+ count: number;
42
+ routes: Record<string, string>;
43
+ success: boolean;
44
+ }
34
45
  interface PageContentResponse {
35
46
  content: string;
36
47
  success: boolean;
@@ -77,6 +88,7 @@ interface ApiRoutes {
77
88
  };
78
89
  pages: {
79
90
  list: string;
91
+ routes: string;
80
92
  get: string;
81
93
  content: string;
82
94
  baseUrl: string;
@@ -257,7 +269,6 @@ interface HostConfig {
257
269
  allowHtml: boolean;
258
270
  };
259
271
  };
260
- apiRoutes?: ApiRoutesOverride;
261
272
  stateCache?: {
262
273
  maxPages?: number;
263
274
  maxSizePerPage?: number;
@@ -274,6 +285,8 @@ interface AppContext {
274
285
  route?: string;
275
286
  parentResourceId?: string;
276
287
  nestingDepth?: number;
288
+ /** This iframe is the navigation owner of its parent level. */
289
+ isNavOwner?: boolean;
277
290
  layoutPanelId?: string;
278
291
  layoutId?: string;
279
292
  extensions?: Record<string, unknown>;
@@ -289,6 +302,7 @@ interface AppConfig {
289
302
  env: AppEnv;
290
303
  axiosDefaults?: Partial<AxiosDefaults>;
291
304
  routePrefix?: string;
305
+ apiRoutes?: ApiRoutesOverride;
292
306
  theming: {
293
307
  global?: ThemingScope;
294
308
  host?: HostThemingScope;
@@ -297,17 +311,19 @@ interface AppConfig {
297
311
  hostConfig: HostConfig;
298
312
  context: AppContext;
299
313
  }
300
- interface ChildAppConfig {
301
- $schema: string;
302
- auth: AppAuthConfig;
303
- env: AppEnv;
304
- axiosDefaults?: Partial<AxiosDefaults>;
305
- routePrefix?: string;
306
- apiRoutes?: ApiRoutesOverride;
307
- customization: AppCustomization;
308
- context: AppContext;
309
- configOverrides?: AppConfigOverrides;
310
- }
314
+ type ChildAppConfig = Omit<AppConfig, 'hostConfig'> & {
315
+ /**
316
+ * This iframe's own pageId. Used by the link classifier to exclude
317
+ * self from mount route matching (prevents self-match on root mounts).
318
+ */
319
+ selfPageId?: string;
320
+ /**
321
+ * Map of mountRoute pattern → pageId for host-level routes claimed by view pages.
322
+ * Used by child iframes' link classifier to detect host-nav links and relay them
323
+ * via postMessage instead of triggering in-child navigation.
324
+ */
325
+ mountRoutes?: Record<string, string>;
326
+ };
311
327
  interface AppConfigOverrides {
312
328
  customization?: Partial<AppCustomization>;
313
329
  axiosDefaults?: Partial<AxiosDefaults>;
@@ -324,7 +340,7 @@ interface ProxyConfig {
324
340
  primevue: boolean;
325
341
  markdown: boolean;
326
342
  customCss: boolean;
327
- customVariabled: boolean;
343
+ customVariables: boolean;
328
344
  };
329
345
  tailwindConfig: boolean;
330
346
  resizeObserver: boolean;
@@ -759,6 +775,7 @@ type Events = {
759
775
  /** Emitted when pages are updated */
760
776
  '@history': (data: {
761
777
  path: string;
778
+ navId?: number;
762
779
  }) => void;
763
780
  '@visibility': (visible: boolean) => void;
764
781
  '@message': (data: WsMessage) => void;
@@ -771,6 +788,36 @@ type Events = {
771
788
  };
772
789
  declare function createEvents(): <T extends string>(topicPattern: T, callback: T extends KnownTopics ? Events[T] : Events["@message"]) => nanoevents.Unsubscribe;
773
790
 
791
+ /**
792
+ * Link classifier — decides whether an href targets:
793
+ * - `host-nav` host-level route claimed by a view page or system route
794
+ * - `child-nav` internal route belonging to the subapp's own router
795
+ * - `external` different origin / mailto / tel / ftp / file / javascript
796
+ * - `ignore` empty href, pure hash
797
+ *
798
+ * Pure function, framework-agnostic. Used by:
799
+ * - `prevent-clicks.ts` fallback handler for raw <a> clicks
800
+ * - `ProxyApiInstance.host.classifyLink(href)` exposed to vanilla subapp code
801
+ * - `@wippy-fe/router` RouterLink wrapper transparent host-nav relay
802
+ *
803
+ * Matching strategy for host-nav:
804
+ * 1. Compare the path's first literal segment against known system routes
805
+ * (`/chat`, `/c`, `/web`, `/page`, `/keeper`, `/login`, `/logout`)
806
+ * 2. Compare against mountRoute top literal segments from ChildAppConfig.mountRoutes
807
+ * 3. Root-mount fallback — if a view page claimed `/:part(.*)*`, it catches
808
+ * everything not otherwise matched
809
+ */
810
+ type LinkKind = 'ignore' | 'external' | 'host-nav' | 'child-nav';
811
+ interface LinkClassification {
812
+ kind: LinkKind;
813
+ /** The original href the caller passed in (echoed for convenience) */
814
+ href: string;
815
+ /** Path after origin + routePrefix stripping, when applicable */
816
+ normalizedPath?: string;
817
+ /** For host-nav matched to a mountRoute, the page id of the target */
818
+ targetPageId?: string;
819
+ }
820
+
774
821
  declare const LogLevel: {
775
822
  readonly Emergency: 0;
776
823
  readonly Alert: 1;
@@ -876,7 +923,7 @@ interface ProxyApiInstance {
876
923
  target: 'modal' | 'sidebar';
877
924
  }) => void;
878
925
  navigate: (url: string) => void;
879
- onRouteChanged: (internalRoute: string) => void;
926
+ onRouteChanged: (internalRoute: string, navId?: number) => void;
880
927
  handleError: (code: ('auth-expired' | 'other'), error: Record<string, unknown>) => void;
881
928
  setContext: (context: Record<string, unknown>, sessionUUID?: string, source?: {
882
929
  type: 'page' | 'artifact';
@@ -884,6 +931,12 @@ interface ProxyApiInstance {
884
931
  instanceUUID?: string;
885
932
  }) => void;
886
933
  formatUrl: (relativeUrl: string) => string;
934
+ /**
935
+ * Classify a link href as `host-nav` / `child-nav` / `external` / `ignore`.
936
+ * Uses mountRoutes and routePrefix from the child's ChildAppConfig plus baked-in
937
+ * system route segments. Pure function — safe to call anywhere.
938
+ */
939
+ classifyLink: (href: string | null | undefined) => LinkClassification;
887
940
  logout: () => void;
888
941
  };
889
942
  api: AxiosInstance;
@@ -892,6 +945,16 @@ interface ProxyApiInstance {
892
945
  get: () => Promise<FormState>;
893
946
  submit: (data: FormData | Record<string, unknown>) => Promise<FormResult>;
894
947
  };
948
+ /**
949
+ * Subscribe to events. Returns an unsubscribe function that MUST be called
950
+ * on component unmount to prevent subscription leaks.
951
+ *
952
+ * ```ts
953
+ * const unsub = instance.on('session:*:message:*', (msg) => { ... })
954
+ * // Later, on unmount:
955
+ * unsub()
956
+ * ```
957
+ */
895
958
  on: ReturnType<typeof createEvents>;
896
959
  logger: LoggerApi;
897
960
  state: StateApi;
@@ -901,7 +964,6 @@ interface ProxyApiInstance {
901
964
 
902
965
  declare const GLOBAL_CONFIG_VAR: "__WIPPY_APP_CONFIG__";
903
966
  declare const GLOBAL_PROXY_CONFIG_VAR: "__WIPPY_PROXY_CONFIG__";
904
- declare const GLOBAL_CONFIG_OVERRIDES_VAR: "__WIPPY_CONFIG_OVERRIDES__";
905
967
  declare const GLOBAL_API_PROVIDER: "__WIPPY_APP_API__";
906
968
  declare const GLOBAL_WEB_COMPONENT_CACHE: "__WIPPY_WEB_COMPONENT_CACHE__";
907
969
  declare global {
@@ -909,7 +971,6 @@ declare global {
909
971
  [GLOBAL_CONFIG_VAR]: AppConfig | ChildAppConfig;
910
972
  [GLOBAL_API_PROVIDER]: ProxyApiInstance;
911
973
  [GLOBAL_PROXY_CONFIG_VAR]?: ProxyConfig;
912
- [GLOBAL_CONFIG_OVERRIDES_VAR]?: AppConfigOverrides;
913
974
  [GLOBAL_WEB_COMPONENT_CACHE]: Record<string, {
914
975
  usedAt: number;
915
976
  data: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wippy-fe/types-global-proxy",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Global type declarations for Wippy iframe proxy (window.getWippyApi, $W, etc.)",
5
5
  "license": "UNLICENSED",
6
6
  "types": "index.d.ts"