@merkur/plugin-component 0.45.0 → 0.46.0-rc.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 (2) hide show
  1. package/package.json +3 -3
  2. package/types.d.ts +23 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkur/plugin-component",
3
- "version": "0.45.0",
3
+ "version": "0.46.0-rc.0",
4
4
  "description": "Merkur component plugin.",
5
5
  "main": "lib/index",
6
6
  "module": "lib/index",
@@ -61,10 +61,10 @@
61
61
  },
62
62
  "homepage": "https://merkur.js.org/",
63
63
  "devDependencies": {
64
- "@merkur/core": "^0.45.0"
64
+ "@merkur/core": "0.46.0-rc.0"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@merkur/core": "*"
68
68
  },
69
- "gitHead": "733c19257814dcdc584cb5e7453c28d6fd24fa82"
69
+ "gitHead": "737814ec3ae39a32c8551196aed5be7925f1a1e1"
70
70
  }
package/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Widget } from '@merkur/core';
2
2
 
3
3
  export interface ViewType {
4
- (widget: Widget): any;
4
+ (widget: WidgetPartial): any;
5
5
  }
6
6
 
7
7
  export type MapViewArgs = {
@@ -22,7 +22,10 @@ export type MapViewArgs = {
22
22
 
23
23
  export type SSRMountResult = {
24
24
  html: string;
25
- slot: Record<string, { name: string; html: string, containerSelector?: string }>;
25
+ slot: Record<
26
+ string,
27
+ { name: string; html: string; containerSelector?: string }
28
+ >;
26
29
  };
27
30
 
28
31
  export interface WidgetState {}
@@ -33,12 +36,17 @@ declare module '@merkur/core' {
33
36
  viewFactory: ViewFactory;
34
37
  }
35
38
 
36
- interface Widget {
39
+ interface WidgetDefinition {
40
+ bootstrap?: (widget: WidgetPartial) => void;
37
41
  container?: Element;
38
- shouldHydrate: (viewArgs: MapViewArgs) => boolean;
39
- mount: () => Promise<void | SSRMountResult>;
40
- update: () => Promise<void>;
41
- unmount: () => Promise<void>;
42
+ info?: (widget: WidgetPartial) => Promise<void>;
43
+ mount?: (widget: WidgetPartial) => Promise<void | SSRMountResult>;
44
+ shouldHydrate?: (widget: WidgetPartial, viewArgs: MapViewArgs) => boolean;
45
+ update?: (widget: WidgetPartial) => Promise<void>;
46
+ unmount?: (widget: WidgetPartial) => Promise<void>;
47
+ }
48
+
49
+ interface WidgetPartial {
42
50
  slot: Record<
43
51
  string,
44
52
  | {
@@ -51,20 +59,14 @@ declare module '@merkur/core' {
51
59
  >;
52
60
  state: WidgetState;
53
61
  props: WidgetProps;
54
- }
55
-
56
- interface WidgetDefinition {
57
- shouldHydrate: (widget: Widget, viewArgs: MapViewArgs) => boolean;
58
- mount: (widget: Widget) => Promise<void | SSRMountResult>;
59
- update: (widget: Widget) => Promise<void>;
60
- unmount: (widget: Widget) => Promise<void>;
62
+ setState: (newState: WidgetState) => void;
61
63
  }
62
64
  interface WidgetInternal {
63
65
  component: {
64
- lifeCycle: Record<string, function>;
66
+ lifeCycle: Record<string, MerkurWidgetFunction>;
65
67
  isMounted: boolean;
66
68
  isHydrated: boolean;
67
- suspendedTasks: Array<function>;
69
+ suspendedTasks: Array<() => Promise<void>>;
68
70
  resolvedViews: Map<ViewFactory, MapViewArgs[]>;
69
71
  };
70
72
  }
@@ -91,19 +93,19 @@ export interface ViewFactoryResult {
91
93
 
92
94
  export interface ViewFactorySlotType {
93
95
  name: string;
94
- containerSelector?: string,
96
+ containerSelector?: string;
95
97
  View: ViewType;
96
98
  }
97
99
 
98
100
  export type ViewFactory = (widget: Widget) => Promise<ViewFactoryResult>;
99
- export type SlotFactory = (widget: Widget) => Promise<SlotDefinition>;
101
+ export type SlotFactory = (widget: WidgetPartial) => Promise<SlotDefinition>;
100
102
 
101
103
  export declare function createSlotFactory(
102
- creator: (widget: Widget) => SlotDefinition | Promise<SlotDefinition>,
104
+ creator: (widget: WidgetPartial) => SlotDefinition | Promise<SlotDefinition>,
103
105
  ): SlotFactory;
104
106
 
105
107
  export declare function createViewFactory(
106
- creator: (widget: Widget) => ViewDefinition | Promise<ViewDefinition>,
108
+ creator: (widget: WidgetPartial) => ViewDefinition | Promise<ViewDefinition>,
107
109
  ): ViewFactory;
108
110
 
109
- export declare function componentPlugin();
111
+ export declare function componentPlugin(): WidgetPlugin;