@merkur/core 0.46.0-rc.0 → 0.46.0-rc.4

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/package.json +2 -2
  2. package/types.d.ts +16 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/core",
3
- "version": "0.46.0-rc.0",
3
+ "version": "0.46.0-rc.4",
4
4
  "description": "Merkur is tiny and extensible library for creating front-end microservices.",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -53,5 +53,5 @@
53
53
  "access": "public"
54
54
  },
55
55
  "homepage": "https://merkur.js.org/",
56
- "gitHead": "737814ec3ae39a32c8551196aed5be7925f1a1e1"
56
+ "gitHead": "f0910c6fab2206dceced9ad7e31da4ed65dd7098"
57
57
  }
package/types.d.ts CHANGED
@@ -34,12 +34,19 @@ export interface WidgetDefinition {
34
34
  setup?: WidgetFunction;
35
35
  }
36
36
 
37
- // Type used during initialization within `createMerkurWidget()`
38
- // it initializes some properties (= they're not optional anymore)
37
+ export interface RequiredWidgetKeys {
38
+ $dependencies: unknown;
39
+ $external: unknown;
40
+ create: WidgetFunction;
41
+ setup: WidgetFunction;
42
+ }
39
43
 
40
- export interface WidgetPartial extends WidgetDefinition, Required<Pick<WidgetDefinition, '$dependencies' | '$external' | 'create' | 'setup'>> {
44
+ // Type used during initialization within `createMerkurWidget()`
45
+ // many properties are initialized with defaults, so we can rely on them being present
46
+ type WidgetWithRequiredIntermediary = WidgetDefinition &
47
+ Required<Pick<WidgetDefinition, keyof RequiredWidgetKeys>>;
48
+ export interface WidgetPartial extends WidgetWithRequiredIntermediary {
41
49
  $in: WidgetInternal;
42
- slot: Record<any, any>; // @merkur/core knows (incorrectly?) about slot and initializes it to an empty object.
43
50
  }
44
51
 
45
52
  export interface WidgetParams {}
@@ -89,13 +96,15 @@ export declare function createMerkurWidget<
89
96
  >(widgetDefinition: T): Widget;
90
97
 
91
98
  // `createMerkurWidget()` binds all WidgetFunctions to the widget instance using `bindWidgetToFunctions()`
92
- // This series of types replicates that for the typing.
99
+ // This series of types replicates that for the typing.
93
100
  type TupleTail<T extends any[]> = T extends [any, ...infer Rest] ? Rest : never;
94
101
  type FunctionLike = (...args: any[]) => any;
95
- type BoundWidgetFunction<T extends FunctionLike> = (...args: TupleTail<Parameters<T>>) => ReturnType<T>;
102
+ type BoundWidgetFunction<T extends FunctionLike> = (
103
+ ...args: TupleTail<Parameters<T>>
104
+ ) => ReturnType<T>;
96
105
  type BoundWidget<T> = {
97
106
  [K in keyof T]: T[K] extends FunctionLike ? BoundWidgetFunction<T[K]> : T[K];
98
- }
107
+ };
99
108
  export interface Widget extends BoundWidget<WidgetPartial> {}
100
109
 
101
110
  export type MerkurCreate = (