piral-core 0.15.0-alpha.3549 → 0.15.0-alpha.3592
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/esm/actions/app.d.ts +3 -1
- package/esm/actions/app.js +18 -0
- package/esm/actions/app.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/createInstance.js +5 -1
- package/esm/createInstance.js.map +1 -1
- package/{debug-piral.d.ts → esm/debugger.d.ts} +1 -1
- package/esm/debugger.js +52 -0
- package/esm/debugger.js.map +1 -0
- package/{debug-pilet.d.ts → esm/emulator.d.ts} +1 -1
- package/esm/emulator.js +8 -0
- package/esm/emulator.js.map +1 -0
- package/esm/helpers.js +2 -2
- 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.d.ts +2 -2
- package/esm/modules/dependencies.js.map +1 -1
- package/esm/state/withApi.d.ts +1 -1
- package/esm/state/withApi.js +31 -33
- package/esm/state/withApi.js.map +1 -1
- package/esm/types/api.d.ts +12 -8
- package/esm/types/state.d.ts +13 -3
- package/esm/types/utils.d.ts +1 -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/actions/app.d.ts +3 -1
- package/lib/actions/app.js +21 -1
- package/lib/actions/app.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/createInstance.js +5 -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.js +2 -2
- 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.d.ts +2 -2
- package/lib/modules/dependencies.js.map +1 -1
- package/lib/state/withApi.d.ts +1 -1
- package/lib/state/withApi.js +30 -32
- package/lib/state/withApi.js.map +1 -1
- package/lib/types/api.d.ts +12 -8
- package/lib/types/state.d.ts +13 -3
- package/lib/types/utils.d.ts +1 -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 +9 -11
- package/src/actions/app.ts +25 -0
- package/src/components/ErrorBoundary.tsx +19 -51
- package/src/createInstance.tsx +5 -1
- package/src/debugger.ts +82 -0
- package/src/emulator.ts +10 -0
- package/src/helpers.tsx +2 -2
- package/src/modules/core.ts +10 -8
- package/src/modules/dependencies.ts +3 -2
- package/src/state/withApi.test.tsx +20 -4
- package/src/state/withApi.tsx +51 -42
- package/src/types/api.ts +23 -9
- package/src/types/state.ts +13 -3
- package/src/types/utils.ts +1 -1
- package/src/utils/index.ts +2 -0
- package/debug-pilet.js +0 -13
- package/debug-piral.js +0 -59
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
15
|
import type { 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,
|
|
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.
|
|
@@ -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/state.ts
CHANGED
|
@@ -12,7 +12,6 @@ import type {
|
|
|
12
12
|
PiralCustomComponentsState,
|
|
13
13
|
} from './custom';
|
|
14
14
|
import type {
|
|
15
|
-
PiletMetadata,
|
|
16
15
|
EventEmitter,
|
|
17
16
|
Pilet,
|
|
18
17
|
BaseComponentProps,
|
|
@@ -20,6 +19,7 @@ import type {
|
|
|
20
19
|
ExtensionComponentProps,
|
|
21
20
|
PiletsBag,
|
|
22
21
|
PiralPageMeta,
|
|
22
|
+
PiletEntry,
|
|
23
23
|
} from './api';
|
|
24
24
|
import type {
|
|
25
25
|
ComponentConverters,
|
|
@@ -162,7 +162,7 @@ export interface GlobalState extends PiralCustomState {
|
|
|
162
162
|
/**
|
|
163
163
|
* Gets the loaded modules.
|
|
164
164
|
*/
|
|
165
|
-
modules: Array<
|
|
165
|
+
modules: Array<Pilet>;
|
|
166
166
|
/**
|
|
167
167
|
* The foreign component portals to render.
|
|
168
168
|
*/
|
|
@@ -205,10 +205,20 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
205
205
|
*/
|
|
206
206
|
initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
207
207
|
/**
|
|
208
|
-
* Injects
|
|
208
|
+
* Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
|
|
209
209
|
* @param pilet The pilet to be injected.
|
|
210
210
|
*/
|
|
211
211
|
injectPilet(pilet: Pilet): void;
|
|
212
|
+
/**
|
|
213
|
+
* Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
|
|
214
|
+
* @param pilet The pilet to be added.
|
|
215
|
+
*/
|
|
216
|
+
addPilet(pilet: PiletEntry): void;
|
|
217
|
+
/**
|
|
218
|
+
* Removes a pilet by unloading it and deleting all component registrations.
|
|
219
|
+
* @param name The name of the pilet to remove.
|
|
220
|
+
*/
|
|
221
|
+
removePilet(name: string): void;
|
|
212
222
|
/**
|
|
213
223
|
* Defines a single action for Piral.
|
|
214
224
|
* @param actionName The name of the action to define.
|
package/src/types/utils.ts
CHANGED
|
@@ -60,7 +60,7 @@ export interface PiralStoreDataEvent<TValue = any> {
|
|
|
60
60
|
expires: number;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
declare module 'piral-base/lib/types' {
|
|
63
|
+
declare module 'piral-base/lib/types/api' {
|
|
64
64
|
interface PiralEventMap extends PiralCustomEventMap {
|
|
65
65
|
'store-data': PiralStoreDataEvent;
|
|
66
66
|
}
|
package/src/utils/index.ts
CHANGED
package/debug-pilet.js
DELETED
|
@@ -1,13 +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
|
-
injectPilet: context.injectPilet,
|
|
8
|
-
hooks: options.hooks,
|
|
9
|
-
createApi: options.createApi,
|
|
10
|
-
loadPilet: options.loadPilet
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
exports.integrate = integrate;
|
package/debug-piral.js
DELETED
|
@@ -1,59 +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), { createApi: options.createApi, loadPilet: options.loadPilet, injectPilet: context.injectPilet, fireEvent: context.emit, getDependencies: function () {
|
|
29
|
-
return Object.keys(options.dependencies);
|
|
30
|
-
}, getExtensions: function () {
|
|
31
|
-
return context.readState(function (s) { return Object.keys(s.registry.extensions); });
|
|
32
|
-
}, getRoutes: function () {
|
|
33
|
-
var registeredRoutes = context.readState(function (state) { return Object.keys(state.registry.pages); });
|
|
34
|
-
var componentRoutes = context.readState(function (state) { return Object.keys(state.routes); });
|
|
35
|
-
return __spreadArray(__spreadArray([], componentRoutes, true), registeredRoutes, true);
|
|
36
|
-
}, getGlobalState: function () {
|
|
37
|
-
return context.readState(function (s) { return s; });
|
|
38
|
-
}, getPilets: function () {
|
|
39
|
-
return context.readState(function (s) { return s.modules; });
|
|
40
|
-
}, setPilets: function (modules) {
|
|
41
|
-
context.dispatch(function (state) { return (__assign(__assign({}, state), { modules: modules })); });
|
|
42
|
-
}, integrate: function (dbg) {
|
|
43
|
-
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) }) })); });
|
|
44
|
-
(0, react_atom_1.addChangeHandler)(context.state, 'debugging', function (_a) {
|
|
45
|
-
var previous = _a.previous, current = _a.current;
|
|
46
|
-
var pilets = current.modules !== previous.modules;
|
|
47
|
-
var pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
|
|
48
|
-
var extensions = current.registry.extensions !== previous.registry.extensions;
|
|
49
|
-
var state = current !== previous;
|
|
50
|
-
dbg.onChange(previous, current, {
|
|
51
|
-
pilets: pilets,
|
|
52
|
-
pages: pages,
|
|
53
|
-
extensions: extensions,
|
|
54
|
-
state: state
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
} }));
|
|
58
|
-
}
|
|
59
|
-
exports.integrate = integrate;
|