@merkur/plugin-component 0.45.0 → 0.46.0-rc.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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/types.d.ts +58 -50
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.1",
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.1"
65
65
  },
66
66
  "peerDependencies": {
67
67
  "@merkur/core": "*"
68
68
  },
69
- "gitHead": "733c19257814dcdc584cb5e7453c28d6fd24fa82"
69
+ "gitHead": "a1bd899f564cab2204edd3e30edc40e1a81c3999"
70
70
  }
package/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Widget } from '@merkur/core';
1
+ import { type Widget, type WidgetFunction, type WidgetPartial, type WidgetPlugin } 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,54 +22,15 @@ 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 {}
29
32
  export interface WidgetProps {}
30
33
 
31
- declare module '@merkur/core' {
32
- interface DefineWidgetArgs {
33
- viewFactory: ViewFactory;
34
- }
35
-
36
- interface Widget {
37
- container?: Element;
38
- shouldHydrate: (viewArgs: MapViewArgs) => boolean;
39
- mount: () => Promise<void | SSRMountResult>;
40
- update: () => Promise<void>;
41
- unmount: () => Promise<void>;
42
- slot: Record<
43
- string,
44
- | {
45
- name: string;
46
- html: string;
47
- containerSelector: string;
48
- container?: Element;
49
- }
50
- | undefined
51
- >;
52
- state: WidgetState;
53
- 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>;
61
- }
62
- interface WidgetInternal {
63
- component: {
64
- lifeCycle: Record<string, function>;
65
- isMounted: boolean;
66
- isHydrated: boolean;
67
- suspendedTasks: Array<function>;
68
- resolvedViews: Map<ViewFactory, MapViewArgs[]>;
69
- };
70
- }
71
- }
72
-
73
34
  export interface SlotDefinition {
74
35
  name: string;
75
36
  View: ViewType;
@@ -91,19 +52,66 @@ export interface ViewFactoryResult {
91
52
 
92
53
  export interface ViewFactorySlotType {
93
54
  name: string;
94
- containerSelector?: string,
55
+ containerSelector?: string;
95
56
  View: ViewType;
96
57
  }
97
58
 
98
59
  export type ViewFactory = (widget: Widget) => Promise<ViewFactoryResult>;
99
- export type SlotFactory = (widget: Widget) => Promise<SlotDefinition>;
60
+ export type SlotFactory = (widget: WidgetPartial) => Promise<SlotDefinition>;
100
61
 
101
62
  export declare function createSlotFactory(
102
- creator: (widget: Widget) => SlotDefinition | Promise<SlotDefinition>,
63
+ creator: (widget: WidgetPartial) => SlotDefinition | Promise<SlotDefinition>,
103
64
  ): SlotFactory;
104
65
 
105
66
  export declare function createViewFactory(
106
- creator: (widget: Widget) => ViewDefinition | Promise<ViewDefinition>,
67
+ creator: (widget: WidgetPartial) => ViewDefinition | Promise<ViewDefinition>,
107
68
  ): ViewFactory;
108
69
 
109
- export declare function componentPlugin();
70
+ export declare function componentPlugin(): WidgetPlugin;
71
+
72
+
73
+ declare module '@merkur/core' {
74
+ interface DefineWidgetArgs {
75
+ viewFactory: ViewFactory;
76
+ }
77
+
78
+ interface Widget {}
79
+
80
+ interface WidgetPlugin {}
81
+
82
+ interface WidgetDefinition {
83
+ bootstrap?: (widget: WidgetPartial) => void;
84
+ container?: Element;
85
+ info?: (widget: WidgetPartial) => Promise<void>;
86
+ mount?: (widget: WidgetPartial) => Promise<void | SSRMountResult>;
87
+ shouldHydrate?: (widget: WidgetPartial, viewArgs: MapViewArgs) => boolean;
88
+ update?: (widget: WidgetPartial) => Promise<void>;
89
+ unmount?: (widget: WidgetPartial) => Promise<void>;
90
+ }
91
+
92
+ interface WidgetPartial {
93
+ slot: Record<
94
+ string,
95
+ | {
96
+ name: string;
97
+ html: string;
98
+ containerSelector: string;
99
+ container?: Element;
100
+ }
101
+ | undefined
102
+ >;
103
+ state: WidgetState;
104
+ props: WidgetProps;
105
+ setState: (widget: WidgetPartial, newState: WidgetState) => void;
106
+ setProps: (widget: WidgetPartial, newProps: WidgetProps) => void;
107
+ }
108
+ interface WidgetInternal {
109
+ component: {
110
+ lifeCycle: Record<string, WidgetFunction>;
111
+ isMounted: boolean;
112
+ isHydrated: boolean;
113
+ suspendedTasks: Array<() => Promise<void>>;
114
+ resolvedViews: Map<ViewFactory, MapViewArgs[]>;
115
+ };
116
+ }
117
+ }