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.
Files changed (105) hide show
  1. package/debug.codegen +24 -0
  2. package/debug.codegen.d.ts +11 -0
  3. package/dependencies.codegen +6 -4
  4. package/dependencies.codegen.d.ts +1 -0
  5. package/dependencies.codegen.native.js +1 -1
  6. package/esm/RootListener.js +1 -1
  7. package/esm/RootListener.js.map +1 -1
  8. package/esm/components/ErrorBoundary.d.ts +12 -33
  9. package/esm/components/ErrorBoundary.js +12 -14
  10. package/esm/components/ErrorBoundary.js.map +1 -1
  11. package/esm/components/ExtensionSlot.js +20 -2
  12. package/esm/components/ExtensionSlot.js.map +1 -1
  13. package/esm/components/ForeignComponentContainer.d.ts +19 -0
  14. package/esm/components/ForeignComponentContainer.js +52 -0
  15. package/esm/components/ForeignComponentContainer.js.map +1 -0
  16. package/esm/components/index.d.ts +1 -0
  17. package/esm/components/index.js +1 -0
  18. package/esm/components/index.js.map +1 -1
  19. package/esm/components/wrapComponent.d.ts +7 -0
  20. package/esm/components/wrapComponent.js +42 -0
  21. package/esm/components/wrapComponent.js.map +1 -0
  22. package/esm/createInstance.js +1 -1
  23. package/esm/createInstance.js.map +1 -1
  24. package/esm/debugger.d.ts +4 -0
  25. package/esm/debugger.js +52 -0
  26. package/esm/debugger.js.map +1 -0
  27. package/esm/emulator.d.ts +3 -0
  28. package/esm/emulator.js +8 -0
  29. package/esm/emulator.js.map +1 -0
  30. package/esm/helpers.d.ts +1 -1
  31. package/esm/helpers.js +3 -10
  32. package/esm/helpers.js.map +1 -1
  33. package/esm/modules/core.js +8 -6
  34. package/esm/modules/core.js.map +1 -1
  35. package/esm/modules/dependencies.js +3 -23
  36. package/esm/modules/dependencies.js.map +1 -1
  37. package/esm/state/withApi.d.ts +1 -1
  38. package/esm/state/withApi.js +17 -103
  39. package/esm/state/withApi.js.map +1 -1
  40. package/esm/types/api.d.ts +14 -10
  41. package/esm/types/extension.d.ts +5 -1
  42. package/esm/utils/index.d.ts +1 -0
  43. package/esm/utils/index.js +1 -0
  44. package/esm/utils/index.js.map +1 -1
  45. package/lib/RootListener.js +2 -2
  46. package/lib/RootListener.js.map +1 -1
  47. package/lib/components/ErrorBoundary.d.ts +12 -33
  48. package/lib/components/ErrorBoundary.js +12 -14
  49. package/lib/components/ErrorBoundary.js.map +1 -1
  50. package/lib/components/ExtensionSlot.js +19 -1
  51. package/lib/components/ExtensionSlot.js.map +1 -1
  52. package/lib/components/ForeignComponentContainer.d.ts +19 -0
  53. package/lib/components/ForeignComponentContainer.js +56 -0
  54. package/lib/components/ForeignComponentContainer.js.map +1 -0
  55. package/lib/components/index.d.ts +1 -0
  56. package/lib/components/index.js +1 -0
  57. package/lib/components/index.js.map +1 -1
  58. package/lib/components/wrapComponent.d.ts +7 -0
  59. package/lib/components/wrapComponent.js +46 -0
  60. package/lib/components/wrapComponent.js.map +1 -0
  61. package/lib/createInstance.js +1 -1
  62. package/lib/createInstance.js.map +1 -1
  63. package/lib/debugger.d.ts +4 -0
  64. package/lib/debugger.js +56 -0
  65. package/lib/debugger.js.map +1 -0
  66. package/lib/emulator.d.ts +3 -0
  67. package/lib/emulator.js +12 -0
  68. package/lib/emulator.js.map +1 -0
  69. package/lib/helpers.d.ts +1 -1
  70. package/lib/helpers.js +3 -10
  71. package/lib/helpers.js.map +1 -1
  72. package/lib/modules/core.js +8 -6
  73. package/lib/modules/core.js.map +1 -1
  74. package/lib/modules/dependencies.js +3 -23
  75. package/lib/modules/dependencies.js.map +1 -1
  76. package/lib/state/withApi.d.ts +1 -1
  77. package/lib/state/withApi.js +15 -101
  78. package/lib/state/withApi.js.map +1 -1
  79. package/lib/types/api.d.ts +14 -10
  80. package/lib/types/extension.d.ts +5 -1
  81. package/lib/utils/index.d.ts +1 -0
  82. package/lib/utils/index.js +4 -0
  83. package/lib/utils/index.js.map +1 -1
  84. package/package.json +12 -12
  85. package/src/RootListener.tsx +1 -1
  86. package/src/components/ErrorBoundary.tsx +19 -51
  87. package/src/components/ExtensionSlot.tsx +25 -3
  88. package/src/components/ForeignComponentContainer.tsx +69 -0
  89. package/src/components/index.ts +1 -0
  90. package/src/components/wrapComponent.tsx +74 -0
  91. package/src/createInstance.tsx +1 -1
  92. package/src/debugger.ts +82 -0
  93. package/src/emulator.ts +10 -0
  94. package/src/helpers.tsx +4 -12
  95. package/src/modules/core.ts +10 -8
  96. package/src/modules/dependencies.ts +3 -22
  97. package/src/state/withApi.test.tsx +20 -4
  98. package/src/state/withApi.tsx +31 -157
  99. package/src/types/api.ts +25 -11
  100. package/src/types/extension.ts +12 -3
  101. package/src/utils/index.ts +2 -0
  102. package/debug-pilet.d.ts +0 -3
  103. package/debug-pilet.js +0 -11
  104. package/debug-piral.d.ts +0 -4
  105. package/debug-piral.js +0 -72
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { useGlobalStateContext } from '.';
2
+ import { useGlobalStateContext } from './hooks';
3
3
  import { renderElement } from './modules';
4
4
 
5
5
  export const RootListener: React.FC = () => {
@@ -1,42 +1,18 @@
1
1
  import * as React from 'react';
2
- import { isfunc } from 'piral-base';
2
+ import { PiralError, PiralLoadingIndicator } from './components';
3
+ import { Errors, PiletApi } from '../types';
3
4
 
4
- /**
5
- * The options to be used for determining the boundary's behavior.
6
- */
7
- export interface ErrorBoundaryOptions<T> {
8
- /**
9
- * Callback to be used in case of an emitted error.
10
- * @param error The error caught by the boundary.
11
- */
12
- onError(error: Error): void;
5
+ export interface ErrorBoundaryProps {
13
6
  /**
14
- * Callback to be used when an error should be rendered.
15
- * @param error The error caught by the boundary.
16
- * @param props The props used by the boundary.
7
+ * The type of error to indicate when caught.
17
8
  */
18
- renderError?(error: Error, props: T): React.ReactNode;
19
- /**
20
- * Callback to used when no error should be rendered.
21
- * @param children The standard children to render.
22
- * @param props The props used by the boundary.
23
- */
24
- renderChild(children: React.ReactNode, props: T): React.ReactNode;
25
- }
26
-
27
- /**
28
- * The props of the ErrorBoundary component.
29
- */
30
- export interface ErrorBoundaryProps<T> extends ErrorBoundaryOptions<T> {
9
+ errorType: keyof Errors;
31
10
  /**
32
- * The render props for the specific ErrorBoundary.
11
+ * The associated pilet api for the metadata.
33
12
  */
34
- renderProps: T;
13
+ piral: PiletApi;
35
14
  }
36
15
 
37
- /**
38
- * The state of the ErrorBoundary component.
39
- */
40
16
  export interface ErrorBoundaryState {
41
17
  /**
42
18
  * The current error (if any) caught by the boundary.
@@ -45,22 +21,17 @@ export interface ErrorBoundaryState {
45
21
  }
46
22
 
47
23
  /**
48
- * The React component for catching errors and displaying error information.
24
+ * The component for catching errors and displaying error information.
49
25
  */
50
- export class ErrorBoundary<T> extends React.Component<ErrorBoundaryProps<T>, ErrorBoundaryState> {
51
- constructor(props: ErrorBoundaryProps<T>) {
52
- super(props);
53
- this.state = {
54
- error: undefined,
55
- };
56
- }
26
+ export class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
27
+ state = {
28
+ error: undefined,
29
+ };
57
30
 
58
31
  componentDidCatch(error: Error) {
59
- const { onError } = this.props;
60
-
61
- if (isfunc(onError)) {
62
- onError(error);
63
- }
32
+ const { piral, errorType } = this.props;
33
+ const pilet = piral.meta.name;
34
+ console.error(`[${pilet}] Exception in component of type "${errorType}".`, error);
64
35
 
65
36
  this.setState({
66
37
  error,
@@ -68,17 +39,14 @@ export class ErrorBoundary<T> extends React.Component<ErrorBoundaryProps<T>, Err
68
39
  }
69
40
 
70
41
  render() {
71
- const { children, renderError, renderChild, renderProps } = this.props;
42
+ const { children, piral, errorType, ...renderProps } = this.props;
72
43
  const { error } = this.state;
44
+ const rest: any = renderProps;
73
45
 
74
46
  if (error) {
75
- if (isfunc(renderError)) {
76
- return renderError(error, renderProps);
77
- }
78
-
79
- return <div style={{ whiteSpace: 'pre-wrap' }}>{error && error.message}</div>;
47
+ return <PiralError type={errorType} error={error} {...rest} />;
80
48
  }
81
49
 
82
- return isfunc(renderChild) ? renderChild(children, renderProps) : children;
50
+ return <React.Suspense fallback={<PiralLoadingIndicator />}>{children}</React.Suspense>;
83
51
  }
84
52
  }
@@ -1,8 +1,30 @@
1
1
  import * as React from 'react';
2
2
  import { isfunc } from 'piral-base';
3
- import { useGlobalState } from '../hooks';
3
+ import { wrapComponent } from './wrapComponent';
4
+ import { useGlobalState, useGlobalStateContext } from '../hooks';
4
5
  import { defaultRender, none } from '../utils';
5
- import { ExtensionSlotProps } from '../types';
6
+ import { ExtensionRegistration, ExtensionSlotProps } from '../types';
7
+
8
+ const renderExtensions: [ExtensionRegistration] = [
9
+ {
10
+ component: (props) => {
11
+ const context = useGlobalStateContext();
12
+ const converters = context.converters;
13
+ const piral = context.apis._;
14
+ const { component, props: args } = props.params;
15
+ const Component = React.useMemo(
16
+ () => wrapComponent(converters, component, { piral }, defaultRender),
17
+ [component],
18
+ );
19
+ return <Component {...args} />;
20
+ },
21
+ defaults: {},
22
+ pilet: '',
23
+ reference: {
24
+ displayName: 'RenderExtension',
25
+ },
26
+ },
27
+ ];
6
28
 
7
29
  /**
8
30
  * The extension slot component to be used when the available
@@ -11,7 +33,7 @@ import { ExtensionSlotProps } from '../types';
11
33
  */
12
34
  export function ExtensionSlot<T extends string>(props: ExtensionSlotProps<T>) {
13
35
  const { name, render = defaultRender, empty, params, children } = props;
14
- const extensions = useGlobalState((s) => s.registry.extensions[name] || none);
36
+ const extensions = useGlobalState((s) => (name ? s.registry.extensions[name] || none : renderExtensions));
15
37
  return render(
16
38
  extensions.length === 0 && isfunc(empty)
17
39
  ? [defaultRender(empty(), 'empty')]
@@ -0,0 +1,69 @@
1
+ import * as React from 'react';
2
+ import { isfunc } from 'piral-base';
3
+ import { __RouterContext } from 'react-router';
4
+ import { ForeignComponent, BaseComponentProps, ComponentContext } from '../types';
5
+
6
+ interface ForeignComponentContainerProps<T> {
7
+ $portalId: string;
8
+ $component: ForeignComponent<T>;
9
+ $context: ComponentContext;
10
+ innerProps: T & BaseComponentProps;
11
+ }
12
+
13
+ export class ForeignComponentContainer<T> extends React.Component<ForeignComponentContainerProps<T>> {
14
+ private current?: HTMLElement;
15
+ private previous?: HTMLElement;
16
+ private handler = (ev: CustomEvent) => {
17
+ const { innerProps } = this.props;
18
+ ev.stopPropagation();
19
+ innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
20
+ };
21
+
22
+ private setNode = (node: HTMLDivElement) => {
23
+ this.current = node;
24
+ };
25
+
26
+ componentDidMount() {
27
+ const node = this.current;
28
+ const { $component, $context, innerProps } = this.props;
29
+ const { mount } = $component;
30
+
31
+ if (node && isfunc(mount)) {
32
+ mount(node, innerProps, $context);
33
+ node.addEventListener('render-html', this.handler, false);
34
+ }
35
+
36
+ this.previous = node;
37
+ }
38
+
39
+ componentDidUpdate() {
40
+ const { current, previous } = this;
41
+ const { $component, $context, innerProps } = this.props;
42
+ const { update } = $component;
43
+
44
+ if (current !== previous) {
45
+ previous && this.componentWillUnmount();
46
+ current && this.componentDidMount();
47
+ } else if (isfunc(update)) {
48
+ update(current, innerProps, $context);
49
+ }
50
+ }
51
+
52
+ componentWillUnmount() {
53
+ const node = this.previous;
54
+ const { $component } = this.props;
55
+ const { unmount } = $component;
56
+
57
+ if (node && isfunc(unmount)) {
58
+ unmount(node);
59
+ node.removeEventListener('render-html', this.handler, false);
60
+ }
61
+
62
+ this.previous = undefined;
63
+ }
64
+
65
+ render() {
66
+ const { $portalId } = this.props;
67
+ return <div data-portal-id={$portalId} ref={this.setNode} />;
68
+ }
69
+ }
@@ -18,3 +18,4 @@ export * from './SetProvider';
18
18
  export * from './SetRedirect';
19
19
  export * from './SetRoute';
20
20
  export * from './SwitchErrorInfo';
21
+ export * from './wrapComponent';
@@ -0,0 +1,74 @@
1
+ import * as React from 'react';
2
+ import { __RouterContext } from 'react-router';
3
+ import { PortalRenderer } from './PortalRenderer';
4
+ import { ForeignComponentContainer } from './ForeignComponentContainer';
5
+ import { useGlobalStateContext } from '../hooks';
6
+ import { convertComponent, none } from '../utils';
7
+ import { AnyComponent, ComponentConverters, ForeignComponent, PiletApi, BaseComponentProps } from '../types';
8
+
9
+ // this is an arbitrary start number to have 6 digits
10
+ let portalIdBase = 123456;
11
+
12
+ interface CapturedProps {
13
+ piral: PiletApi;
14
+ }
15
+
16
+ function wrapReactComponent<T>(
17
+ Component: React.ComponentType<T & BaseComponentProps>,
18
+ captured: CapturedProps,
19
+ Wrapper: React.FC<T>,
20
+ ): React.ComponentType<T> {
21
+ return (props: T) => (
22
+ <Wrapper {...props}>
23
+ <Component {...props} {...captured} />
24
+ </Wrapper>
25
+ );
26
+ }
27
+
28
+ function wrapForeignComponent<T>(
29
+ component: ForeignComponent<T & BaseComponentProps>,
30
+ captured: CapturedProps,
31
+ Wrapper: React.FC<T>,
32
+ ) {
33
+ return React.memo((props: T) => {
34
+ const { state, readState, destroyPortal } = useGlobalStateContext();
35
+ const router = React.useContext(__RouterContext);
36
+ const id = React.useMemo(() => (portalIdBase++).toString(26), none);
37
+ const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
38
+ const innerProps = React.useMemo(() => ({ ...props, ...captured }), [props]);
39
+
40
+ React.useEffect(() => () => destroyPortal(id), none);
41
+
42
+ return (
43
+ <Wrapper {...props}>
44
+ <PortalRenderer id={id} />
45
+ <ForeignComponentContainer innerProps={innerProps} $portalId={id} $component={component} $context={context} />
46
+ </Wrapper>
47
+ );
48
+ });
49
+ }
50
+
51
+ function isNotExotic(component: any): component is object {
52
+ return !(component as React.ExoticComponent).$$typeof;
53
+ }
54
+
55
+ export function wrapComponent<T>(
56
+ converters: ComponentConverters<T & BaseComponentProps>,
57
+ component: AnyComponent<T & BaseComponentProps>,
58
+ captured: CapturedProps,
59
+ Wrapper: React.FC<T>,
60
+ ) {
61
+ if (!component) {
62
+ const pilet = captured.piral.meta.name;
63
+ console.error(`[${pilet}] The given value is not a valid component.`);
64
+ // tslint:disable-next-line:no-null-keyword
65
+ component = () => null;
66
+ }
67
+
68
+ if (typeof component === 'object' && isNotExotic(component)) {
69
+ const result = convertComponent(converters[component.type], component);
70
+ return wrapForeignComponent<T>(result, captured, Wrapper);
71
+ }
72
+
73
+ return wrapReactComponent<T>(component, captured, Wrapper);
74
+ }
@@ -49,7 +49,7 @@ export function createInstance(config: PiralInstanceOptions = {}): PiralInstance
49
49
  const usedPlugins = Array.isArray(definedPlugins) ? definedPlugins : [definedPlugins];
50
50
  const createApi = apiFactory(context, usedPlugins);
51
51
  const root = createApi({
52
- name: 'root',
52
+ name: '_',
53
53
  version: process.env.BUILD_PCKG_VERSION || '1.0.0',
54
54
  spec: 'v0',
55
55
  basePath: '',
@@ -0,0 +1,82 @@
1
+ import { addChangeHandler } from '@dbeining/react-atom';
2
+ import { LoadPiletsOptions } from 'piral-base';
3
+ import { installPiralDebug, DebuggerExtensionOptions } from 'piral-debug-utils';
4
+ import { GlobalStateContext } from './types';
5
+
6
+ export function integrateDebugger(
7
+ context: GlobalStateContext,
8
+ options: LoadPiletsOptions,
9
+ debug: DebuggerExtensionOptions = {},
10
+ ) {
11
+ installPiralDebug({
12
+ ...debug,
13
+ addPilet: context.addPilet,
14
+ removePilet: context.removePilet,
15
+ updatePilet(pilet) {
16
+ if (!pilet.disabled) {
17
+ const { createApi } = options;
18
+ const newApi = createApi(pilet);
19
+
20
+ try {
21
+ context.injectPilet(pilet);
22
+ pilet.setup(newApi);
23
+ } catch (error) {
24
+ console.error(error);
25
+ }
26
+ } else {
27
+ context.injectPilet(pilet);
28
+ }
29
+ },
30
+ fireEvent: context.emit,
31
+ getDependencies() {
32
+ return Object.keys(options.dependencies);
33
+ },
34
+ getExtensions() {
35
+ return context.readState((s) => Object.keys(s.registry.extensions));
36
+ },
37
+ getRoutes() {
38
+ const registeredRoutes = context.readState((state) => Object.keys(state.registry.pages));
39
+ const componentRoutes = context.readState((state) => Object.keys(state.routes));
40
+ return [...componentRoutes, ...registeredRoutes];
41
+ },
42
+ getGlobalState() {
43
+ return context.readState((s) => s);
44
+ },
45
+ getPilets() {
46
+ return context.readState((s) => s.modules);
47
+ },
48
+ integrate(dbg) {
49
+ context.dispatch((s) => ({
50
+ ...s,
51
+ components: {
52
+ ...s.components,
53
+ ...dbg.components,
54
+ },
55
+ routes: {
56
+ ...s.routes,
57
+ ...dbg.routes,
58
+ },
59
+ registry: {
60
+ ...s.registry,
61
+ wrappers: {
62
+ ...s.registry.wrappers,
63
+ ...dbg.wrappers,
64
+ },
65
+ },
66
+ }));
67
+
68
+ addChangeHandler(context.state, 'debugging', ({ previous, current }) => {
69
+ const pilets = current.modules !== previous.modules;
70
+ const pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
71
+ const extensions = current.registry.extensions !== previous.registry.extensions;
72
+ const state = current !== previous;
73
+ dbg.onChange(previous, current, {
74
+ pilets,
75
+ pages,
76
+ extensions,
77
+ state,
78
+ });
79
+ });
80
+ },
81
+ });
82
+ }
@@ -0,0 +1,10 @@
1
+ import { LoadPiletsOptions } from 'piral-base';
2
+ import { withEmulatorPilets } from 'piral-debug-utils';
3
+ import { GlobalStateContext } from './types';
4
+
5
+ export function integrateEmulator(context: GlobalStateContext, options: LoadPiletsOptions) {
6
+ options.fetchPilets = withEmulatorPilets(options.fetchPilets, {
7
+ addPilet: context.addPilet,
8
+ removePilet: context.removePilet,
9
+ });
10
+ }
package/src/helpers.tsx CHANGED
@@ -8,9 +8,10 @@ import {
8
8
  PiletLoader,
9
9
  PiletLifecycleHooks,
10
10
  } from 'piral-base';
11
- import { DebuggerExtensionOptions } from 'piral-debug-utils';
11
+ import type { DebuggerExtensionOptions } from 'piral-debug-utils';
12
12
  import { globalDependencies } from './modules';
13
13
  import type { Pilet, PiletRequester, GlobalStateContext, PiletLoadingStrategy, DependencySelector } from './types';
14
+ import { integrateDebugger, integrateEmulator } from '../debug.codegen';
14
15
 
15
16
  export interface PiletOptionsConfig {
16
17
  context: GlobalStateContext;
@@ -50,17 +51,8 @@ export function createPiletOptions({
50
51
  dependencies: shareDependencies(globalDependencies),
51
52
  };
52
53
 
53
- // if we build the debug version of piral (debug and emulator build)
54
- if (process.env.DEBUG_PIRAL) {
55
- const { integrate } = require('../debug-piral');
56
- integrate(context, options, debug);
57
- }
58
-
59
- // if we build the emulator version of piral (shipped to pilets)
60
- if (process.env.DEBUG_PILET) {
61
- const { integrate } = require('../debug-pilet');
62
- integrate(context, options);
63
- }
54
+ integrateDebugger(context, options, debug);
55
+ integrateEmulator(context, options, debug);
64
56
 
65
57
  return options;
66
58
  }
@@ -17,28 +17,30 @@ export function createCoreApi(context: GlobalStateContext): PiletApiExtender<Pil
17
17
  const expiration = getDataExpiration(expires);
18
18
  return context.tryWriteDataItem(name, value, pilet, target, expiration);
19
19
  },
20
- registerPage(route, arg, meta) {
20
+ registerPage(route, arg, meta = {}) {
21
+ const component = withApi(context, arg, api, 'page', undefined, { meta });
21
22
  context.registerPage(route, {
22
23
  pilet,
23
24
  meta,
24
- component: withApi(context, arg, api, 'page'),
25
+ component,
25
26
  });
26
27
  return () => api.unregisterPage(route);
27
28
  },
28
29
  unregisterPage(route) {
29
30
  context.unregisterPage(route);
30
31
  },
31
- registerExtension(name, arg, defaults) {
32
- context.registerExtension(name as string, {
32
+ registerExtension(name, reference, defaults) {
33
+ const component = withApi(context, reference, api, 'extension');
34
+ context.registerExtension(name, {
33
35
  pilet,
34
- component: withApi(context, arg, api, 'extension'),
35
- reference: arg,
36
+ component,
37
+ reference,
36
38
  defaults,
37
39
  });
38
- return () => api.unregisterExtension(name, arg);
40
+ return () => api.unregisterExtension(name, reference);
39
41
  },
40
42
  unregisterExtension(name, arg) {
41
- context.unregisterExtension(name as string, arg);
43
+ context.unregisterExtension(name, arg);
42
44
  },
43
45
  renderHtmlExtension(element, props) {
44
46
  const [dispose] = renderElement(context, element, props);
@@ -1,6 +1,6 @@
1
1
  import { isfunc } from 'piral-base';
2
- import { __assign } from 'tslib';
3
2
  import type { AvailableDependencies, PiletEntries } from '../types';
3
+ import fillDependencies from '../../dependencies.codegen';
4
4
 
5
5
  /**
6
6
  * The global dependencies, which represent the dependencies
@@ -8,27 +8,8 @@ import type { AvailableDependencies, PiletEntries } from '../types';
8
8
  */
9
9
  export const globalDependencies: AvailableDependencies = {};
10
10
 
11
- if (process.env.SHARED_DEPENDENCIES) {
12
- const fillDependencies = require('../../dependencies.codegen');
13
-
14
- if (isfunc(fillDependencies)) {
15
- fillDependencies(globalDependencies);
16
- } else {
17
- // fall back to the default list if the codegen is invalid / not supported
18
- __assign(globalDependencies, {
19
- react: require('react'),
20
- 'react-dom': require('react-dom'),
21
- 'react-router': require('react-router'),
22
- 'react-router-dom': require('react-router-dom'),
23
- history: require('history'),
24
- tslib: require('tslib'),
25
- 'path-to-regexp': require('path-to-regexp'),
26
- '@libre/atom': require('@libre/atom'),
27
- '@dbeining/react-atom': require('@dbeining/react-atom'),
28
- });
29
- }
30
- } else {
31
- // App shell is built with something else than the Piral CLI - just don't fill ...
11
+ if (isfunc(fillDependencies)) {
12
+ fillDependencies(globalDependencies);
32
13
  }
33
14
 
34
15
  /**
@@ -58,7 +58,11 @@ StubComponent.displayName = 'StubComponent';
58
58
 
59
59
  describe('withApi Module', () => {
60
60
  it('wraps a component and forwards the API as piral', () => {
61
- const api: any = {};
61
+ const api: any = {
62
+ meta: {
63
+ name: 'foo',
64
+ },
65
+ };
62
66
  const { context } = createMockContainer();
63
67
  const Component = withApi(context, StubComponent, api, 'feed' as any);
64
68
  const node = mount(<Component />);
@@ -67,7 +71,11 @@ describe('withApi Module', () => {
67
71
 
68
72
  it('is protected against a component crash', () => {
69
73
  console.error = jest.fn();
70
- const api: any = {};
74
+ const api: any = {
75
+ meta: {
76
+ name: 'foo',
77
+ },
78
+ };
71
79
  const { context } = createMockContainer();
72
80
  const Component = withApi(context, StubComponent, api, 'feed' as any);
73
81
  const node = mount(<Component shouldCrash />);
@@ -88,7 +96,11 @@ describe('withApi Module', () => {
88
96
  });
89
97
 
90
98
  it('Wraps component of type object', () => {
91
- const api: any = {};
99
+ const api: any = {
100
+ meta: {
101
+ name: 'foo',
102
+ },
103
+ };
92
104
  const { context } = createMockContainer();
93
105
  context.converters = {
94
106
  html: (component) => {
@@ -107,7 +119,11 @@ describe('withApi Module', () => {
107
119
  });
108
120
 
109
121
  it('Wraps component which is object == null.', () => {
110
- const api: any = {};
122
+ const api: any = {
123
+ meta: {
124
+ name: 'foo',
125
+ },
126
+ };
111
127
  const { context } = createMockContainer();
112
128
  context.converters = {
113
129
  html: (component) => {