piral-core 0.15.0-alpha.3549 → 0.15.0-alpha.3555
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-pilet.js +2 -4
- package/debug-piral.js +16 -3
- 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/createInstance.js +5 -1
- package/esm/createInstance.js.map +1 -1
- package/esm/modules/dependencies.d.ts +2 -2
- package/esm/modules/dependencies.js.map +1 -1
- package/esm/types/api.d.ts +2 -2
- package/esm/types/state.d.ts +13 -3
- package/esm/types/utils.d.ts +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/createInstance.js +5 -1
- package/lib/createInstance.js.map +1 -1
- package/lib/modules/dependencies.d.ts +2 -2
- package/lib/modules/dependencies.js.map +1 -1
- package/lib/types/api.d.ts +2 -2
- package/lib/types/state.d.ts +13 -3
- package/lib/types/utils.d.ts +1 -1
- package/package.json +4 -4
- package/src/actions/app.ts +25 -0
- package/src/createInstance.tsx +5 -1
- package/src/modules/dependencies.ts +3 -2
- package/src/types/api.ts +2 -2
- package/src/types/state.ts +13 -3
- package/src/types/utils.ts +1 -1
package/debug-pilet.js
CHANGED
|
@@ -4,10 +4,8 @@ exports.integrate = void 0;
|
|
|
4
4
|
var piral_debug_utils_1 = require("piral-debug-utils");
|
|
5
5
|
function integrate(context, options) {
|
|
6
6
|
options.fetchPilets = (0, piral_debug_utils_1.withEmulatorPilets)(options.fetchPilets, {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
createApi: options.createApi,
|
|
10
|
-
loadPilet: options.loadPilet
|
|
7
|
+
addPilet: context.addPilet,
|
|
8
|
+
removePilet: context.removePilet
|
|
11
9
|
});
|
|
12
10
|
}
|
|
13
11
|
exports.integrate = integrate;
|
package/debug-piral.js
CHANGED
|
@@ -25,7 +25,22 @@ var react_atom_1 = require("@dbeining/react-atom");
|
|
|
25
25
|
var piral_debug_utils_1 = require("piral-debug-utils");
|
|
26
26
|
function integrate(context, options, debug) {
|
|
27
27
|
if (debug === void 0) { debug = {}; }
|
|
28
|
-
(0, piral_debug_utils_1.installPiralDebug)(__assign(__assign({}, 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 () {
|
|
29
44
|
return Object.keys(options.dependencies);
|
|
30
45
|
}, getExtensions: function () {
|
|
31
46
|
return context.readState(function (s) { return Object.keys(s.registry.extensions); });
|
|
@@ -37,8 +52,6 @@ function integrate(context, options, debug) {
|
|
|
37
52
|
return context.readState(function (s) { return s; });
|
|
38
53
|
}, getPilets: function () {
|
|
39
54
|
return context.readState(function (s) { return s.modules; });
|
|
40
|
-
}, setPilets: function (modules) {
|
|
41
|
-
context.dispatch(function (state) { return (__assign(__assign({}, state), { modules: modules })); });
|
|
42
55
|
}, integrate: function (dbg) {
|
|
43
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) }) })); });
|
|
44
57
|
(0, react_atom_1.addChangeHandler)(context.state, 'debugging', function (_a) {
|
package/esm/actions/app.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { RouteComponentProps } from 'react-router';
|
|
3
|
-
import { LayoutType, ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet } from '../types';
|
|
3
|
+
import { LayoutType, ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet, PiletEntry } from '../types';
|
|
4
4
|
export declare function changeLayout(ctx: GlobalStateContext, current: LayoutType): void;
|
|
5
5
|
export declare function initialize(ctx: GlobalStateContext, loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
6
|
+
export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): void;
|
|
7
|
+
export declare function removePilet(ctx: GlobalStateContext, name: string): void;
|
|
6
8
|
export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet): void;
|
|
7
9
|
export declare function setComponent<TKey extends keyof ComponentsState>(ctx: GlobalStateContext, name: TKey, component: ComponentsState[TKey]): void;
|
|
8
10
|
export declare function setErrorComponent<TKey extends keyof ErrorComponentsState>(ctx: GlobalStateContext, type: TKey, component: ErrorComponentsState[TKey]): void;
|
package/esm/actions/app.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runPilet } from 'piral-base';
|
|
1
2
|
import { withKey, replaceOrAddItem, removeNested, withProvider, withRoute } from '../utils';
|
|
2
3
|
export function changeLayout(ctx, current) {
|
|
3
4
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { app: withKey(state.app, 'layout', current) })));
|
|
@@ -6,6 +7,23 @@ export function initialize(ctx, loading, error, modules) {
|
|
|
6
7
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { app: Object.assign(Object.assign({}, state.app), { error,
|
|
7
8
|
loading }), modules })));
|
|
8
9
|
}
|
|
10
|
+
export function addPilet(ctx, meta) {
|
|
11
|
+
ctx.options.loadPilet(meta).then((pilet) => {
|
|
12
|
+
try {
|
|
13
|
+
ctx.injectPilet(pilet);
|
|
14
|
+
runPilet(ctx.options.createApi, pilet, ctx.options.hooks);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
console.error(error);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function removePilet(ctx, name) {
|
|
22
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modules: state.modules.filter((m) => m.name !== name), registry: removeNested(state.registry, (m) => m.pilet === name) })));
|
|
23
|
+
ctx.emit('unload-pilet', {
|
|
24
|
+
name,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
9
27
|
export function injectPilet(ctx, pilet) {
|
|
10
28
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modules: replaceOrAddItem(state.modules, pilet, (m) => m.name === pilet.name), registry: removeNested(state.registry, (m) => m.pilet === pilet.name) })));
|
|
11
29
|
ctx.emit('unload-pilet', {
|
package/esm/actions/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAY5F,MAAM,UAAU,YAAY,CAAC,GAAuB,EAAE,OAAmB;IACvE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,IAC1C,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,UAA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@@ -35,7 +35,11 @@ export function createInstance(config = {}) {
|
|
|
35
35
|
const root = createApi({
|
|
36
36
|
name: 'root',
|
|
37
37
|
version: process.env.BUILD_PCKG_VERSION || '1.0.0',
|
|
38
|
-
spec: '',
|
|
38
|
+
spec: 'v0',
|
|
39
|
+
basePath: '',
|
|
40
|
+
link: '',
|
|
41
|
+
config: {},
|
|
42
|
+
dependencies: {},
|
|
39
43
|
});
|
|
40
44
|
const options = createPiletOptions({
|
|
41
45
|
context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInstance.js","sourceRoot":"","sources":["../src/createInstance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,cAAc,CAAC,SAA+B,EAAE;IAC9D,MAAM,EACJ,EAAE,GAAG,UAAU,EAAE,EACjB,KAAK,EACL,OAAO,EACP,eAAe,GAAG,EAAE,EACpB,OAAO,EACP,aAAa,GAAG,sBAAsB,EACtC,YAAY,EACZ,KAAK,GAAG,KAAK,EACb,iBAAiB,GAAG,yBAAyB,EAC7C,SAAS,EACT,OAAO,EACP,KAAK,EACL,UAAU,GAAG,iBAAiB,GAC/B,GAAG,MAAM,CAAC;IACX,MAAM,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,cAA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T,OAAO;QACP,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AvailableDependencies, PiletEntries } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* The global dependencies, which represent the dependencies
|
|
4
4
|
* shared from the app shell itself.
|
|
@@ -20,4 +20,4 @@ return fetch('https://feed.piral.cloud/api/v1/pilet/sample')
|
|
|
20
20
|
.then(res => res.items);
|
|
21
21
|
```
|
|
22
22
|
*/
|
|
23
|
-
export declare function defaultModuleRequester(): Promise<
|
|
23
|
+
export declare function defaultModuleRequester(): Promise<PiletEntries>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA0B,EAAE,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE;QAC5B,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;KACtC;SAAM;QACL,0EAA0E;QAC1E,QAAQ,CAAC,kBAAkB,EAAE;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;YACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;YACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;YAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;YAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;YACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;SACxD,CAAC,CAAC;KACJ;CACF;KAAM;IACL,kFAAkF;CACnF;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC"}
|
package/esm/types/api.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { RouteComponentProps } from 'react-router';
|
|
3
|
-
import type { PiletApi, Pilet,
|
|
3
|
+
import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter } from 'piral-base';
|
|
4
4
|
import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
|
|
5
5
|
import type { AnyComponent } from './components';
|
|
6
6
|
import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
7
7
|
import type { SharedData, DataStoreOptions } from './data';
|
|
8
8
|
import type { Disposable } from './utils';
|
|
9
|
-
export { PiletApi, Pilet, PiletMetadata, EventEmitter,
|
|
9
|
+
export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries };
|
|
10
10
|
/**
|
|
11
11
|
* The props that every registered component obtains.
|
|
12
12
|
*/
|
package/esm/types/state.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Dict, Without } from './common';
|
|
|
6
6
|
import type { LayoutType } from './layout';
|
|
7
7
|
import type { SharedDataItem, DataStoreTarget } from './data';
|
|
8
8
|
import type { PiralCustomActions, PiralCustomState, PiralCustomRegistryState, PiralCustomComponentsState } from './custom';
|
|
9
|
-
import type {
|
|
9
|
+
import type { EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta, PiletEntry } from './api';
|
|
10
10
|
import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, RouterProps, LayoutProps, Errors } from './components';
|
|
11
11
|
export interface StateDispatcher<TState> {
|
|
12
12
|
(state: TState): Partial<TState>;
|
|
@@ -130,7 +130,7 @@ export interface GlobalState extends PiralCustomState {
|
|
|
130
130
|
/**
|
|
131
131
|
* Gets the loaded modules.
|
|
132
132
|
*/
|
|
133
|
-
modules: Array<
|
|
133
|
+
modules: Array<Pilet>;
|
|
134
134
|
/**
|
|
135
135
|
* The foreign component portals to render.
|
|
136
136
|
*/
|
|
@@ -172,10 +172,20 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
172
172
|
*/
|
|
173
173
|
initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
174
174
|
/**
|
|
175
|
-
* Injects
|
|
175
|
+
* Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
|
|
176
176
|
* @param pilet The pilet to be injected.
|
|
177
177
|
*/
|
|
178
178
|
injectPilet(pilet: Pilet): void;
|
|
179
|
+
/**
|
|
180
|
+
* Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
|
|
181
|
+
* @param pilet The pilet to be added.
|
|
182
|
+
*/
|
|
183
|
+
addPilet(pilet: PiletEntry): void;
|
|
184
|
+
/**
|
|
185
|
+
* Removes a pilet by unloading it and deleting all component registrations.
|
|
186
|
+
* @param name The name of the pilet to remove.
|
|
187
|
+
*/
|
|
188
|
+
removePilet(name: string): void;
|
|
179
189
|
/**
|
|
180
190
|
* Defines a single action for Piral.
|
|
181
191
|
* @param actionName The name of the action to define.
|
package/esm/types/utils.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface PiralStoreDataEvent<TValue = any> {
|
|
|
55
55
|
*/
|
|
56
56
|
expires: number;
|
|
57
57
|
}
|
|
58
|
-
declare module 'piral-base/lib/types' {
|
|
58
|
+
declare module 'piral-base/lib/types/api' {
|
|
59
59
|
interface PiralEventMap extends PiralCustomEventMap {
|
|
60
60
|
'store-data': PiralStoreDataEvent;
|
|
61
61
|
}
|
package/lib/actions/app.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { RouteComponentProps } from 'react-router';
|
|
3
|
-
import { LayoutType, ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet } from '../types';
|
|
3
|
+
import { LayoutType, ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet, PiletEntry } from '../types';
|
|
4
4
|
export declare function changeLayout(ctx: GlobalStateContext, current: LayoutType): void;
|
|
5
5
|
export declare function initialize(ctx: GlobalStateContext, loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
6
|
+
export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): void;
|
|
7
|
+
export declare function removePilet(ctx: GlobalStateContext, name: string): void;
|
|
6
8
|
export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet): void;
|
|
7
9
|
export declare function setComponent<TKey extends keyof ComponentsState>(ctx: GlobalStateContext, name: TKey, component: ComponentsState[TKey]): void;
|
|
8
10
|
export declare function setErrorComponent<TKey extends keyof ErrorComponentsState>(ctx: GlobalStateContext, type: TKey, component: ErrorComponentsState[TKey]): void;
|
package/lib/actions/app.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.includeProvider = exports.setRoute = exports.setErrorComponent = exports.setComponent = exports.injectPilet = exports.initialize = exports.changeLayout = void 0;
|
|
3
|
+
exports.includeProvider = exports.setRoute = exports.setErrorComponent = exports.setComponent = exports.injectPilet = exports.removePilet = exports.addPilet = exports.initialize = exports.changeLayout = void 0;
|
|
4
|
+
const piral_base_1 = require("piral-base");
|
|
4
5
|
const utils_1 = require("../utils");
|
|
5
6
|
function changeLayout(ctx, current) {
|
|
6
7
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { app: (0, utils_1.withKey)(state.app, 'layout', current) })));
|
|
@@ -11,6 +12,25 @@ function initialize(ctx, loading, error, modules) {
|
|
|
11
12
|
loading }), modules })));
|
|
12
13
|
}
|
|
13
14
|
exports.initialize = initialize;
|
|
15
|
+
function addPilet(ctx, meta) {
|
|
16
|
+
ctx.options.loadPilet(meta).then((pilet) => {
|
|
17
|
+
try {
|
|
18
|
+
ctx.injectPilet(pilet);
|
|
19
|
+
(0, piral_base_1.runPilet)(ctx.options.createApi, pilet, ctx.options.hooks);
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
console.error(error);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
exports.addPilet = addPilet;
|
|
27
|
+
function removePilet(ctx, name) {
|
|
28
|
+
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modules: state.modules.filter((m) => m.name !== name), registry: (0, utils_1.removeNested)(state.registry, (m) => m.pilet === name) })));
|
|
29
|
+
ctx.emit('unload-pilet', {
|
|
30
|
+
name,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
exports.removePilet = removePilet;
|
|
14
34
|
function injectPilet(ctx, pilet) {
|
|
15
35
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modules: (0, utils_1.replaceOrAddItem)(state.modules, pilet, (m) => m.name === pilet.name), registry: (0, utils_1.removeNested)(state.registry, (m) => m.pilet === pilet.name) })));
|
|
16
36
|
ctx.emit('unload-pilet', {
|
package/lib/actions/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":";;;AAEA,oCAA4F;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions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KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,SAAS,CAAC,IAChE,CAAC,CAAC;AACN,CAAC;AATD,8CASC;AAED,SAAgB,QAAQ,CACtB,GAAuB,EACvB,IAAY,EACZ,SAAgD;IAEhD,GAAG,CAAC,QAAQ,CAAC,IAAA,iBAAS,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3C,CAAC;AAND,4BAMC;AAED,SAAgB,eAAe,CAAC,GAAuB,EAAE,QAAqB;IAC5E,GAAG,CAAC,QAAQ,CAAC,IAAA,oBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC;AACvC,CAAC;AAFD,0CAEC"}
|
package/lib/createInstance.js
CHANGED
|
@@ -38,7 +38,11 @@ function createInstance(config = {}) {
|
|
|
38
38
|
const root = createApi({
|
|
39
39
|
name: 'root',
|
|
40
40
|
version: process.env.BUILD_PCKG_VERSION || '1.0.0',
|
|
41
|
-
spec: '',
|
|
41
|
+
spec: 'v0',
|
|
42
|
+
basePath: '',
|
|
43
|
+
link: '',
|
|
44
|
+
config: {},
|
|
45
|
+
dependencies: {},
|
|
42
46
|
});
|
|
43
47
|
const options = (0, helpers_1.createPiletOptions)({
|
|
44
48
|
context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInstance.js","sourceRoot":"","sources":["../src/createInstance.tsx"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2CAAuF;AACvF,uCAAiG;AACjG,mCAA2E;AAC3E,uCAA+C;AAC/C,mCAAqC;AAGrC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,cAAc,CAAC,SAA+B,EAAE;IAC9D,MAAM,EACJ,EAAE,GAAG,IAAA,kBAAU,GAAE,EACjB,KAAK,EACL,OAAO,EACP,eAAe,GAAG,EAAE,EACpB,OAAO,EACP,aAAa,GAAG,gCAAsB,EACtC,YAAY,EACZ,KAAK,GAAG,KAAK,EACb,iBAAiB,GAAG,mCAAyB,EAC7C,SAAS,EACT,OAA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|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AvailableDependencies, PiletEntries } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* The global dependencies, which represent the dependencies
|
|
4
4
|
* shared from the app shell itself.
|
|
@@ -20,4 +20,4 @@ return fetch('https://feed.piral.cloud/api/v1/pilet/sample')
|
|
|
20
20
|
.then(res => res.items);
|
|
21
21
|
```
|
|
22
22
|
*/
|
|
23
|
-
export declare function defaultModuleRequester(): Promise<
|
|
23
|
+
export declare function defaultModuleRequester(): Promise<PiletEntries>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AACpC,iCAAiC;AAGjC;;;GAGG;AACU,QAAA,kBAAkB,GAA0B,EAAE,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,IAAA,mBAAM,EAAC,gBAAgB,CAAC,EAAE;QAC5B,gBAAgB,CAAC,0BAAkB,CAAC,CAAC;KACtC;SAAM;QACL,0EAA0E;QAC1E,IAAA,gBAAQ,EAAC,0BAAkB,EAAE;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;YACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;YACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;YAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;YAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;YACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;SACxD,CAAC,CAAC;KACJ;CACF;KAAM;IACL,kFAAkF;CACnF;AAED;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,8DAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAFD,wDAEC"}
|
package/lib/types/api.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { RouteComponentProps } from 'react-router';
|
|
3
|
-
import type { PiletApi, Pilet,
|
|
3
|
+
import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter } from 'piral-base';
|
|
4
4
|
import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
|
|
5
5
|
import type { AnyComponent } from './components';
|
|
6
6
|
import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
7
7
|
import type { SharedData, DataStoreOptions } from './data';
|
|
8
8
|
import type { Disposable } from './utils';
|
|
9
|
-
export { PiletApi, Pilet, PiletMetadata, EventEmitter,
|
|
9
|
+
export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries };
|
|
10
10
|
/**
|
|
11
11
|
* The props that every registered component obtains.
|
|
12
12
|
*/
|
package/lib/types/state.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { Dict, Without } from './common';
|
|
|
6
6
|
import type { LayoutType } from './layout';
|
|
7
7
|
import type { SharedDataItem, DataStoreTarget } from './data';
|
|
8
8
|
import type { PiralCustomActions, PiralCustomState, PiralCustomRegistryState, PiralCustomComponentsState } from './custom';
|
|
9
|
-
import type {
|
|
9
|
+
import type { EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta, PiletEntry } from './api';
|
|
10
10
|
import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, RouterProps, LayoutProps, Errors } from './components';
|
|
11
11
|
export interface StateDispatcher<TState> {
|
|
12
12
|
(state: TState): Partial<TState>;
|
|
@@ -130,7 +130,7 @@ export interface GlobalState extends PiralCustomState {
|
|
|
130
130
|
/**
|
|
131
131
|
* Gets the loaded modules.
|
|
132
132
|
*/
|
|
133
|
-
modules: Array<
|
|
133
|
+
modules: Array<Pilet>;
|
|
134
134
|
/**
|
|
135
135
|
* The foreign component portals to render.
|
|
136
136
|
*/
|
|
@@ -172,10 +172,20 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
172
172
|
*/
|
|
173
173
|
initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
174
174
|
/**
|
|
175
|
-
* Injects
|
|
175
|
+
* Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
|
|
176
176
|
* @param pilet The pilet to be injected.
|
|
177
177
|
*/
|
|
178
178
|
injectPilet(pilet: Pilet): void;
|
|
179
|
+
/**
|
|
180
|
+
* Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
|
|
181
|
+
* @param pilet The pilet to be added.
|
|
182
|
+
*/
|
|
183
|
+
addPilet(pilet: PiletEntry): void;
|
|
184
|
+
/**
|
|
185
|
+
* Removes a pilet by unloading it and deleting all component registrations.
|
|
186
|
+
* @param name The name of the pilet to remove.
|
|
187
|
+
*/
|
|
188
|
+
removePilet(name: string): void;
|
|
179
189
|
/**
|
|
180
190
|
* Defines a single action for Piral.
|
|
181
191
|
* @param actionName The name of the action to define.
|
package/lib/types/utils.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export interface PiralStoreDataEvent<TValue = any> {
|
|
|
55
55
|
*/
|
|
56
56
|
expires: number;
|
|
57
57
|
}
|
|
58
|
-
declare module 'piral-base/lib/types' {
|
|
58
|
+
declare module 'piral-base/lib/types/api' {
|
|
59
59
|
interface PiralEventMap extends PiralCustomEventMap {
|
|
60
60
|
'store-data': PiralStoreDataEvent;
|
|
61
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-core",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.3555",
|
|
4
4
|
"description": "The core library for creating a Piral instance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@dbeining/react-atom": "^4.0.0",
|
|
53
|
-
"piral-base": "0.15.0-alpha.
|
|
54
|
-
"piral-debug-utils": "0.15.0-alpha.
|
|
53
|
+
"piral-base": "0.15.0-alpha.3555",
|
|
54
|
+
"piral-debug-utils": "0.15.0-alpha.3555"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": ">=16.8.0",
|
|
@@ -78,5 +78,5 @@
|
|
|
78
78
|
"@libre/atom",
|
|
79
79
|
"@dbeining/react-atom"
|
|
80
80
|
],
|
|
81
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "0727a5c782dd1bbc7ccaa11a036a9f16e616bf10"
|
|
82
82
|
}
|
package/src/actions/app.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { RouteComponentProps } from 'react-router';
|
|
3
|
+
import { runPilet } from 'piral-base';
|
|
3
4
|
import { withKey, replaceOrAddItem, removeNested, withProvider, withRoute } from '../utils';
|
|
4
5
|
import {
|
|
5
6
|
LayoutType,
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
RegistryState,
|
|
10
11
|
GlobalStateContext,
|
|
11
12
|
Pilet,
|
|
13
|
+
PiletEntry,
|
|
12
14
|
} from '../types';
|
|
13
15
|
|
|
14
16
|
export function changeLayout(ctx: GlobalStateContext, current: LayoutType) {
|
|
@@ -30,6 +32,29 @@ export function initialize(ctx: GlobalStateContext, loading: boolean, error: Err
|
|
|
30
32
|
}));
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
export function addPilet(ctx: GlobalStateContext, meta: PiletEntry) {
|
|
36
|
+
ctx.options.loadPilet(meta).then((pilet) => {
|
|
37
|
+
try {
|
|
38
|
+
ctx.injectPilet(pilet);
|
|
39
|
+
runPilet(ctx.options.createApi, pilet, ctx.options.hooks);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(error);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function removePilet(ctx: GlobalStateContext, name: string) {
|
|
47
|
+
ctx.dispatch((state) => ({
|
|
48
|
+
...state,
|
|
49
|
+
modules: state.modules.filter((m) => m.name !== name),
|
|
50
|
+
registry: removeNested<RegistryState, BaseRegistration>(state.registry, (m) => m.pilet === name),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
ctx.emit('unload-pilet', {
|
|
54
|
+
name,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
33
58
|
export function injectPilet(ctx: GlobalStateContext, pilet: Pilet) {
|
|
34
59
|
ctx.dispatch((state) => ({
|
|
35
60
|
...state,
|
package/src/createInstance.tsx
CHANGED
|
@@ -51,7 +51,11 @@ export function createInstance(config: PiralInstanceOptions = {}): PiralInstance
|
|
|
51
51
|
const root = createApi({
|
|
52
52
|
name: 'root',
|
|
53
53
|
version: process.env.BUILD_PCKG_VERSION || '1.0.0',
|
|
54
|
-
spec: '',
|
|
54
|
+
spec: 'v0',
|
|
55
|
+
basePath: '',
|
|
56
|
+
link: '',
|
|
57
|
+
config: {},
|
|
58
|
+
dependencies: {},
|
|
55
59
|
});
|
|
56
60
|
const options = createPiletOptions({
|
|
57
61
|
context,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isfunc } from 'piral-base';
|
|
2
2
|
import { __assign } from 'tslib';
|
|
3
|
+
import type { AvailableDependencies, PiletEntries } from '../types';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* The global dependencies, which represent the dependencies
|
|
@@ -49,6 +50,6 @@ return fetch('https://feed.piral.cloud/api/v1/pilet/sample')
|
|
|
49
50
|
.then(res => res.items);
|
|
50
51
|
```
|
|
51
52
|
*/
|
|
52
|
-
export function defaultModuleRequester(): Promise<
|
|
53
|
+
export function defaultModuleRequester(): Promise<PiletEntries> {
|
|
53
54
|
return Promise.resolve([]);
|
|
54
55
|
}
|
package/src/types/api.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ReactElement } from 'react';
|
|
2
2
|
import type { RouteComponentProps } from 'react-router';
|
|
3
|
-
import type { PiletApi, Pilet,
|
|
3
|
+
import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter } from 'piral-base';
|
|
4
4
|
import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
|
|
5
5
|
import type { AnyComponent } from './components';
|
|
6
6
|
import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
7
7
|
import type { SharedData, DataStoreOptions } from './data';
|
|
8
8
|
import type { Disposable } from './utils';
|
|
9
9
|
|
|
10
|
-
export { PiletApi, Pilet, PiletMetadata, EventEmitter,
|
|
10
|
+
export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries };
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* The props that every registered component obtains.
|
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
|
}
|