piral-core 0.15.0-alpha.3555 → 0.15.0-alpha.3640
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.
- package/debug.codegen +24 -0
- package/debug.codegen.d.ts +11 -0
- package/dependencies.codegen +6 -4
- package/dependencies.codegen.d.ts +1 -0
- package/dependencies.codegen.native.js +1 -1
- package/esm/RootListener.js +1 -1
- package/esm/RootListener.js.map +1 -1
- package/esm/components/ErrorBoundary.d.ts +12 -33
- package/esm/components/ErrorBoundary.js +12 -14
- package/esm/components/ErrorBoundary.js.map +1 -1
- package/esm/components/ExtensionSlot.js +20 -2
- package/esm/components/ExtensionSlot.js.map +1 -1
- package/esm/components/ForeignComponentContainer.d.ts +19 -0
- package/esm/components/ForeignComponentContainer.js +52 -0
- package/esm/components/ForeignComponentContainer.js.map +1 -0
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.js +1 -0
- package/esm/components/index.js.map +1 -1
- package/esm/components/wrapComponent.d.ts +7 -0
- package/esm/components/wrapComponent.js +42 -0
- package/esm/components/wrapComponent.js.map +1 -0
- package/esm/createInstance.js +1 -1
- package/esm/createInstance.js.map +1 -1
- package/esm/debugger.d.ts +4 -0
- package/esm/debugger.js +52 -0
- package/esm/debugger.js.map +1 -0
- package/esm/emulator.d.ts +3 -0
- package/esm/emulator.js +8 -0
- package/esm/emulator.js.map +1 -0
- package/esm/helpers.d.ts +1 -1
- package/esm/helpers.js +3 -10
- package/esm/helpers.js.map +1 -1
- package/esm/modules/core.js +8 -6
- package/esm/modules/core.js.map +1 -1
- package/esm/modules/dependencies.js +3 -23
- package/esm/modules/dependencies.js.map +1 -1
- package/esm/state/withApi.d.ts +1 -1
- package/esm/state/withApi.js +17 -103
- package/esm/state/withApi.js.map +1 -1
- package/esm/types/api.d.ts +14 -10
- package/esm/types/extension.d.ts +5 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/lib/RootListener.js +2 -2
- package/lib/RootListener.js.map +1 -1
- package/lib/components/ErrorBoundary.d.ts +12 -33
- package/lib/components/ErrorBoundary.js +12 -14
- package/lib/components/ErrorBoundary.js.map +1 -1
- package/lib/components/ExtensionSlot.js +19 -1
- package/lib/components/ExtensionSlot.js.map +1 -1
- package/lib/components/ForeignComponentContainer.d.ts +19 -0
- package/lib/components/ForeignComponentContainer.js +56 -0
- package/lib/components/ForeignComponentContainer.js.map +1 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/index.js.map +1 -1
- package/lib/components/wrapComponent.d.ts +7 -0
- package/lib/components/wrapComponent.js +46 -0
- package/lib/components/wrapComponent.js.map +1 -0
- package/lib/createInstance.js +1 -1
- package/lib/createInstance.js.map +1 -1
- package/lib/debugger.d.ts +4 -0
- package/lib/debugger.js +56 -0
- package/lib/debugger.js.map +1 -0
- package/lib/emulator.d.ts +3 -0
- package/lib/emulator.js +12 -0
- package/lib/emulator.js.map +1 -0
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +3 -10
- package/lib/helpers.js.map +1 -1
- package/lib/modules/core.js +8 -6
- package/lib/modules/core.js.map +1 -1
- package/lib/modules/dependencies.js +3 -23
- package/lib/modules/dependencies.js.map +1 -1
- package/lib/state/withApi.d.ts +1 -1
- package/lib/state/withApi.js +15 -101
- package/lib/state/withApi.js.map +1 -1
- package/lib/types/api.d.ts +14 -10
- package/lib/types/extension.d.ts +5 -1
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +4 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +12 -12
- package/src/RootListener.tsx +1 -1
- package/src/components/ErrorBoundary.tsx +19 -51
- package/src/components/ExtensionSlot.tsx +25 -3
- package/src/components/ForeignComponentContainer.tsx +69 -0
- package/src/components/index.ts +1 -0
- package/src/components/wrapComponent.tsx +74 -0
- package/src/createInstance.tsx +1 -1
- package/src/debugger.ts +82 -0
- package/src/emulator.ts +10 -0
- package/src/helpers.tsx +4 -12
- package/src/modules/core.ts +10 -8
- package/src/modules/dependencies.ts +3 -22
- package/src/state/withApi.test.tsx +20 -4
- package/src/state/withApi.tsx +31 -157
- package/src/types/api.ts +25 -11
- package/src/types/extension.ts +12 -3
- package/src/utils/index.ts +2 -0
- package/debug-pilet.d.ts +0 -3
- package/debug-pilet.js +0 -11
- package/debug-piral.d.ts +0 -4
- package/debug-piral.js +0 -72
package/src/state/withApi.tsx
CHANGED
|
@@ -1,179 +1,53 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { isfunc } from 'piral-base';
|
|
3
2
|
import { __RouterContext } from 'react-router';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
AnyComponent,
|
|
9
|
-
Errors,
|
|
10
|
-
ComponentConverters,
|
|
11
|
-
ForeignComponent,
|
|
12
|
-
PiletApi,
|
|
13
|
-
BaseComponentProps,
|
|
14
|
-
ComponentContext,
|
|
15
|
-
GlobalStateContext,
|
|
16
|
-
} from '../types';
|
|
17
|
-
|
|
18
|
-
// this is an arbitrary start number to have 6 digits
|
|
19
|
-
let portalIdBase = 123456;
|
|
3
|
+
import { ErrorBoundary, wrapComponent } from '../components';
|
|
4
|
+
import { defaultRender } from '../utils';
|
|
5
|
+
import { AnyComponent, Errors, PiletApi, BaseComponentProps, GlobalStateContext } from '../types';
|
|
20
6
|
|
|
21
7
|
const DefaultWrapper: React.FC = (props) => defaultRender(props.children);
|
|
22
8
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
private handler = (ev: CustomEvent) => {
|
|
34
|
-
const { innerProps } = this.props;
|
|
35
|
-
ev.stopPropagation();
|
|
36
|
-
innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
private setNode = (node: HTMLDivElement) => {
|
|
40
|
-
this.current = node;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
componentDidMount() {
|
|
44
|
-
const node = this.current;
|
|
45
|
-
const { $component, $context, innerProps } = this.props;
|
|
46
|
-
const { mount } = $component;
|
|
47
|
-
|
|
48
|
-
if (node && isfunc(mount)) {
|
|
49
|
-
mount(node, innerProps, $context);
|
|
50
|
-
node.addEventListener('render-html', this.handler, false);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
this.previous = node;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
componentDidUpdate() {
|
|
57
|
-
const { current, previous } = this;
|
|
58
|
-
const { $component, $context, innerProps } = this.props;
|
|
59
|
-
const { update } = $component;
|
|
60
|
-
|
|
61
|
-
if (current !== previous) {
|
|
62
|
-
previous && this.componentWillUnmount();
|
|
63
|
-
current && this.componentDidMount();
|
|
64
|
-
} else if (isfunc(update)) {
|
|
65
|
-
update(current, innerProps, $context);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
componentWillUnmount() {
|
|
70
|
-
const node = this.previous;
|
|
71
|
-
const { $component } = this.props;
|
|
72
|
-
const { unmount } = $component;
|
|
73
|
-
|
|
74
|
-
if (node && isfunc(unmount)) {
|
|
75
|
-
unmount(node);
|
|
76
|
-
node.removeEventListener('render-html', this.handler, false);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
this.previous = undefined;
|
|
9
|
+
function getWrapper(wrappers: Record<string, React.ComponentType<any>>, wrapperType: string) {
|
|
10
|
+
const WrapAll = wrappers['*'];
|
|
11
|
+
const WrapType = wrappers[wrapperType];
|
|
12
|
+
|
|
13
|
+
if (WrapAll && WrapType) {
|
|
14
|
+
return (props) => (
|
|
15
|
+
<WrapAll {...props}>
|
|
16
|
+
<WrapType {...props} />
|
|
17
|
+
</WrapAll>
|
|
18
|
+
);
|
|
80
19
|
}
|
|
81
20
|
|
|
82
|
-
|
|
83
|
-
const { $portalId } = this.props;
|
|
84
|
-
return <div data-portal-id={$portalId} ref={this.setNode} />;
|
|
85
|
-
}
|
|
21
|
+
return WrapType || WrapAll || DefaultWrapper;
|
|
86
22
|
}
|
|
87
23
|
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
): React.
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
24
|
+
function makeWrapper<TProps>(
|
|
25
|
+
context: GlobalStateContext,
|
|
26
|
+
outerProps: any,
|
|
27
|
+
wrapperType: string,
|
|
28
|
+
errorType: keyof Errors,
|
|
29
|
+
): React.FC<TProps> {
|
|
30
|
+
const OuterWrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
|
|
31
|
+
|
|
32
|
+
return (props) => (
|
|
33
|
+
<OuterWrapper {...outerProps} {...props}>
|
|
34
|
+
<ErrorBoundary {...outerProps} {...props} errorType={errorType}>
|
|
35
|
+
{props.children}
|
|
98
36
|
</ErrorBoundary>
|
|
99
|
-
</
|
|
37
|
+
</OuterWrapper>
|
|
100
38
|
);
|
|
101
39
|
}
|
|
102
40
|
|
|
103
|
-
function wrapForeignComponent<T>(
|
|
104
|
-
component: ForeignComponent<T & BaseComponentProps>,
|
|
105
|
-
stasisOptions: ErrorBoundaryOptions<T>,
|
|
106
|
-
piral: PiletApi,
|
|
107
|
-
Wrapper: React.ComponentType<any>,
|
|
108
|
-
) {
|
|
109
|
-
return React.memo((props: T) => {
|
|
110
|
-
const { state, readState, destroyPortal } = useGlobalStateContext();
|
|
111
|
-
const router = React.useContext(__RouterContext);
|
|
112
|
-
const id = React.useMemo(() => (portalIdBase++).toString(26), none);
|
|
113
|
-
const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
|
|
114
|
-
const innerProps = React.useMemo(() => ({ ...props, piral }), [props]);
|
|
115
|
-
|
|
116
|
-
React.useEffect(() => () => destroyPortal(id), none);
|
|
117
|
-
|
|
118
|
-
return (
|
|
119
|
-
<Wrapper {...innerProps}>
|
|
120
|
-
<ErrorBoundary {...stasisOptions} renderProps={props}>
|
|
121
|
-
<PortalRenderer id={id} />
|
|
122
|
-
<ForeignComponentContainer innerProps={innerProps} $portalId={id} $component={component} $context={context} />
|
|
123
|
-
</ErrorBoundary>
|
|
124
|
-
</Wrapper>
|
|
125
|
-
);
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function isNotExotic(component: any): component is object {
|
|
130
|
-
return !(component as React.ExoticComponent).$$typeof;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
function wrapComponent<T>(
|
|
134
|
-
converters: ComponentConverters<T & BaseComponentProps>,
|
|
135
|
-
component: AnyComponent<T & BaseComponentProps>,
|
|
136
|
-
piral: PiletApi,
|
|
137
|
-
Wrapper: React.ComponentType<any>,
|
|
138
|
-
stasisOptions: ErrorBoundaryOptions<T>,
|
|
139
|
-
) {
|
|
140
|
-
if (!component) {
|
|
141
|
-
console.error('The given value is not a valid component.');
|
|
142
|
-
// tslint:disable-next-line:no-null-keyword
|
|
143
|
-
component = () => null;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (typeof component === 'object' && isNotExotic(component)) {
|
|
147
|
-
const result = convertComponent(converters[component.type], component);
|
|
148
|
-
return wrapForeignComponent<T>(result, stasisOptions, piral, Wrapper);
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return wrapReactComponent<T>(component, stasisOptions, piral, Wrapper);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
function getWrapper(wrappers: Record<string, React.ComponentType<any>>, wrapperType: string) {
|
|
155
|
-
return wrappers[wrapperType] || wrappers['*'] || DefaultWrapper;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
41
|
export function withApi<TProps>(
|
|
159
42
|
context: GlobalStateContext,
|
|
160
43
|
component: AnyComponent<TProps & BaseComponentProps>,
|
|
161
44
|
piral: PiletApi,
|
|
162
45
|
errorType: keyof Errors,
|
|
163
46
|
wrapperType: string = errorType,
|
|
47
|
+
captured = {},
|
|
164
48
|
) {
|
|
49
|
+
const outerProps = { ...captured, piral };
|
|
165
50
|
const converters = context.converters;
|
|
166
|
-
const Wrapper = context
|
|
167
|
-
|
|
168
|
-
return wrapComponent<TProps>(converters, component, piral, Wrapper, {
|
|
169
|
-
onError(error) {
|
|
170
|
-
console.error(piral, error);
|
|
171
|
-
},
|
|
172
|
-
renderChild(child) {
|
|
173
|
-
return <React.Suspense fallback={<PiralLoadingIndicator />}>{child}</React.Suspense>;
|
|
174
|
-
},
|
|
175
|
-
renderError(error, props: any) {
|
|
176
|
-
return <PiralError type={errorType} error={error} {...props} />;
|
|
177
|
-
},
|
|
178
|
-
});
|
|
51
|
+
const Wrapper = makeWrapper<TProps>(context, outerProps, wrapperType, errorType);
|
|
52
|
+
return wrapComponent(converters, component, outerProps, Wrapper);
|
|
179
53
|
}
|
package/src/types/api.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { RouteComponentProps } from 'react-router';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
PiletApi,
|
|
5
|
+
Pilet,
|
|
6
|
+
PiletEntry,
|
|
7
|
+
PiletEntries,
|
|
8
|
+
PiletMetadata,
|
|
9
|
+
EventEmitter,
|
|
10
|
+
PiletLoader,
|
|
11
|
+
PiletLoadingStrategy,
|
|
12
|
+
} from 'piral-base';
|
|
4
13
|
import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
|
|
5
14
|
import type { AnyComponent } from './components';
|
|
6
|
-
import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
15
|
+
import type { ExtensionParams, ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
7
16
|
import type { SharedData, DataStoreOptions } from './data';
|
|
8
17
|
import type { Disposable } from './utils';
|
|
9
18
|
|
|
10
|
-
export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries };
|
|
19
|
+
export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries, PiletLoader, PiletLoadingStrategy };
|
|
11
20
|
|
|
12
21
|
/**
|
|
13
22
|
* The props that every registered component obtains.
|
|
@@ -39,6 +48,11 @@ export interface ExtensionComponentProps<T> extends BaseComponentProps {
|
|
|
39
48
|
params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
|
|
40
49
|
}
|
|
41
50
|
|
|
51
|
+
/**
|
|
52
|
+
* The meta data registered for a page.
|
|
53
|
+
*/
|
|
54
|
+
export interface PiralPageMeta extends PiralCustomPageMeta {}
|
|
55
|
+
|
|
42
56
|
/**
|
|
43
57
|
* The props that every registered page component obtains.
|
|
44
58
|
*/
|
|
@@ -49,12 +63,12 @@ export interface RouteBaseProps<UrlParams = any, UrlState = any>
|
|
|
49
63
|
/**
|
|
50
64
|
* The props used by a page component.
|
|
51
65
|
*/
|
|
52
|
-
export interface PageComponentProps<T = any, S = any> extends RouteBaseProps<T, S> {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
66
|
+
export interface PageComponentProps<T = any, S = any> extends RouteBaseProps<T, S> {
|
|
67
|
+
/**
|
|
68
|
+
* The meta data registered with the page.
|
|
69
|
+
*/
|
|
70
|
+
meta: PiralPageMeta;
|
|
71
|
+
}
|
|
58
72
|
|
|
59
73
|
/**
|
|
60
74
|
* Defines the Pilet API from piral-core.
|
|
@@ -99,7 +113,7 @@ export interface PiletCoreApi {
|
|
|
99
113
|
registerExtension<TName>(
|
|
100
114
|
name: TName extends string ? TName : string,
|
|
101
115
|
Component: AnyComponent<ExtensionComponentProps<TName>>,
|
|
102
|
-
defaults?: TName
|
|
116
|
+
defaults?: Partial<ExtensionParams<TName>>,
|
|
103
117
|
): RegistrationDisposer;
|
|
104
118
|
/**
|
|
105
119
|
* Unregisters a global extension component.
|
|
@@ -126,7 +140,7 @@ export interface PiletCoreApi {
|
|
|
126
140
|
renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
|
|
127
141
|
}
|
|
128
142
|
|
|
129
|
-
declare module 'piral-base/lib/types' {
|
|
143
|
+
declare module 'piral-base/lib/types/runtime' {
|
|
130
144
|
interface PiletApi extends PiletCustomApi, PiletCoreApi {}
|
|
131
145
|
}
|
|
132
146
|
|
package/src/types/extension.ts
CHANGED
|
@@ -34,10 +34,19 @@ export interface BaseExtensionSlotProps<TName, TParams> {
|
|
|
34
34
|
name: TName;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Gives the extension params shape for the given extension slot name.
|
|
39
|
+
*/
|
|
40
|
+
export type ExtensionParams<TName> = TName extends keyof PiralExtensionSlotMap
|
|
41
|
+
? PiralExtensionSlotMap[TName]
|
|
42
|
+
: TName extends string
|
|
43
|
+
? any
|
|
44
|
+
: TName;
|
|
45
|
+
|
|
37
46
|
/**
|
|
38
47
|
* The props for defining an extension slot.
|
|
39
48
|
*/
|
|
40
|
-
export type ExtensionSlotProps<
|
|
41
|
-
|
|
42
|
-
|
|
49
|
+
export type ExtensionSlotProps<TName = string> = BaseExtensionSlotProps<
|
|
50
|
+
TName extends string ? TName : string,
|
|
51
|
+
ExtensionParams<TName>
|
|
43
52
|
>;
|
package/src/utils/index.ts
CHANGED
package/debug-pilet.d.ts
DELETED
package/debug-pilet.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.__esModule = true;
|
|
3
|
-
exports.integrate = void 0;
|
|
4
|
-
var piral_debug_utils_1 = require("piral-debug-utils");
|
|
5
|
-
function integrate(context, options) {
|
|
6
|
-
options.fetchPilets = (0, piral_debug_utils_1.withEmulatorPilets)(options.fetchPilets, {
|
|
7
|
-
addPilet: context.addPilet,
|
|
8
|
-
removePilet: context.removePilet
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
exports.integrate = integrate;
|
package/debug-piral.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { LoadPiletsOptions } from 'piral-base';
|
|
2
|
-
import { DebuggerExtensionOptions } from 'piral-debug-utils';
|
|
3
|
-
import { GlobalStateContext } from './lib/types';
|
|
4
|
-
export declare function integrate(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
|
package/debug-piral.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
-
if (ar || !(i in from)) {
|
|
16
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
-
ar[i] = from[i];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
-
};
|
|
22
|
-
exports.__esModule = true;
|
|
23
|
-
exports.integrate = void 0;
|
|
24
|
-
var react_atom_1 = require("@dbeining/react-atom");
|
|
25
|
-
var piral_debug_utils_1 = require("piral-debug-utils");
|
|
26
|
-
function integrate(context, options, debug) {
|
|
27
|
-
if (debug === void 0) { debug = {}; }
|
|
28
|
-
(0, piral_debug_utils_1.installPiralDebug)(__assign(__assign({}, debug), { addPilet: context.addPilet, removePilet: context.removePilet, updatePilet: function (pilet) {
|
|
29
|
-
if (!pilet.disabled) {
|
|
30
|
-
var createApi = options.createApi;
|
|
31
|
-
var newApi = createApi(pilet);
|
|
32
|
-
try {
|
|
33
|
-
context.injectPilet(pilet);
|
|
34
|
-
pilet.setup(newApi);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
console.error(error);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
else {
|
|
41
|
-
context.injectPilet(pilet);
|
|
42
|
-
}
|
|
43
|
-
}, fireEvent: context.emit, getDependencies: function () {
|
|
44
|
-
return Object.keys(options.dependencies);
|
|
45
|
-
}, getExtensions: function () {
|
|
46
|
-
return context.readState(function (s) { return Object.keys(s.registry.extensions); });
|
|
47
|
-
}, getRoutes: function () {
|
|
48
|
-
var registeredRoutes = context.readState(function (state) { return Object.keys(state.registry.pages); });
|
|
49
|
-
var componentRoutes = context.readState(function (state) { return Object.keys(state.routes); });
|
|
50
|
-
return __spreadArray(__spreadArray([], componentRoutes, true), registeredRoutes, true);
|
|
51
|
-
}, getGlobalState: function () {
|
|
52
|
-
return context.readState(function (s) { return s; });
|
|
53
|
-
}, getPilets: function () {
|
|
54
|
-
return context.readState(function (s) { return s.modules; });
|
|
55
|
-
}, integrate: function (dbg) {
|
|
56
|
-
context.dispatch(function (s) { return (__assign(__assign({}, s), { components: __assign(__assign({}, s.components), dbg.components), routes: __assign(__assign({}, s.routes), dbg.routes), registry: __assign(__assign({}, s.registry), { wrappers: __assign(__assign({}, s.registry.wrappers), dbg.wrappers) }) })); });
|
|
57
|
-
(0, react_atom_1.addChangeHandler)(context.state, 'debugging', function (_a) {
|
|
58
|
-
var previous = _a.previous, current = _a.current;
|
|
59
|
-
var pilets = current.modules !== previous.modules;
|
|
60
|
-
var pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
|
|
61
|
-
var extensions = current.registry.extensions !== previous.registry.extensions;
|
|
62
|
-
var state = current !== previous;
|
|
63
|
-
dbg.onChange(previous, current, {
|
|
64
|
-
pilets: pilets,
|
|
65
|
-
pages: pages,
|
|
66
|
-
extensions: extensions,
|
|
67
|
-
state: state
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
} }));
|
|
71
|
-
}
|
|
72
|
-
exports.integrate = integrate;
|