@merkur/core 0.46.0-rc.1 → 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 +15 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/core",
3
- "version": "0.46.0-rc.1",
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": "a1bd899f564cab2204edd3e30edc40e1a81c3999"
56
+ "gitHead": "f0910c6fab2206dceced9ad7e31da4ed65dd7098"
57
57
  }
package/types.d.ts CHANGED
@@ -34,9 +34,17 @@ export interface WidgetDefinition {
34
34
  setup?: WidgetFunction;
35
35
  }
36
36
 
37
+ export interface RequiredWidgetKeys {
38
+ $dependencies: unknown;
39
+ $external: unknown;
40
+ create: WidgetFunction;
41
+ setup: WidgetFunction;
42
+ }
43
+
37
44
  // Type used during initialization within `createMerkurWidget()`
38
- // it initializes some properties (= they're not optional anymore)
39
- type WidgetWithRequiredIntermediary = WidgetDefinition & Required<Pick<WidgetDefinition, '$dependencies' | '$external' | 'create' | 'setup'>>;
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>>;
40
48
  export interface WidgetPartial extends WidgetWithRequiredIntermediary {
41
49
  $in: WidgetInternal;
42
50
  }
@@ -88,13 +96,15 @@ export declare function createMerkurWidget<
88
96
  >(widgetDefinition: T): Widget;
89
97
 
90
98
  // `createMerkurWidget()` binds all WidgetFunctions to the widget instance using `bindWidgetToFunctions()`
91
- // This series of types replicates that for the typing.
99
+ // This series of types replicates that for the typing.
92
100
  type TupleTail<T extends any[]> = T extends [any, ...infer Rest] ? Rest : never;
93
101
  type FunctionLike = (...args: any[]) => any;
94
- 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>;
95
105
  type BoundWidget<T> = {
96
106
  [K in keyof T]: T[K] extends FunctionLike ? BoundWidgetFunction<T[K]> : T[K];
97
- }
107
+ };
98
108
  export interface Widget extends BoundWidget<WidgetPartial> {}
99
109
 
100
110
  export type MerkurCreate = (