piral-core 0.14.0-unstable.3096 → 0.14.1-beta.3244
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/dependencies.codegen +31 -5
- package/esm/modules/api.js +10 -8
- package/esm/modules/api.js.map +1 -1
- package/esm/modules/dependencies.js +19 -11
- package/esm/modules/dependencies.js.map +1 -1
- package/lib/modules/api.js +10 -8
- package/lib/modules/api.js.map +1 -1
- package/lib/modules/dependencies.js +19 -11
- package/lib/modules/dependencies.js.map +1 -1
- package/package.json +15 -6
- package/src/modules/api.ts +14 -12
- package/src/modules/dependencies.test.ts +4 -6
- package/src/modules/dependencies.ts +17 -11
- package/debug-pilet.ts +0 -11
- package/debug-piral.ts +0 -74
package/dependencies.codegen
CHANGED
|
@@ -1,9 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
function getIdentifiers(packageName) {
|
|
2
|
+
const packageJson = `${packageName}/package.json`;
|
|
3
|
+
|
|
4
|
+
try {
|
|
5
|
+
const details = require(packageJson);
|
|
6
|
+
|
|
7
|
+
if (details.version) {
|
|
8
|
+
return [packageName, `${packageName}@${details.version}`];
|
|
9
|
+
}
|
|
10
|
+
} catch {}
|
|
11
|
+
|
|
12
|
+
return [packageName];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
module.exports = function () {
|
|
2
16
|
const appName = process.env.BUILD_PCKG_NAME || '';
|
|
3
|
-
const externals = (process.env.SHARED_DEPENDENCIES || '').split(',');
|
|
4
|
-
const
|
|
5
|
-
|
|
17
|
+
const externals = (process.env.SHARED_DEPENDENCIES || '').split(',').filter(Boolean);
|
|
18
|
+
const assignments = [];
|
|
19
|
+
|
|
20
|
+
if (appName) {
|
|
21
|
+
assignments.push(`deps['${appName}']={}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (const name of externals) {
|
|
25
|
+
const identifiers = getIdentifiers(name);
|
|
26
|
+
|
|
27
|
+
for (const id of identifiers) {
|
|
28
|
+
assignments.push(`deps[${JSON.stringify(id)}]=require(${JSON.stringify(name)})`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
6
32
|
return `module.exports = function(deps){
|
|
7
|
-
${
|
|
33
|
+
${assignments.join(';')}
|
|
8
34
|
}`;
|
|
9
35
|
};
|
package/esm/modules/api.js
CHANGED
|
@@ -2,7 +2,7 @@ import { isfunc, initializeApi, mergeApis } from 'piral-base';
|
|
|
2
2
|
import { withApi } from '../state';
|
|
3
3
|
import { ExtensionSlot } from '../components';
|
|
4
4
|
import { createDataOptions, getDataExpiration, renderInDom, tryParseJson, changeDomPortal, noop } from '../utils';
|
|
5
|
-
if ('customElements' in window) {
|
|
5
|
+
if (typeof window !== 'undefined' && 'customElements' in window) {
|
|
6
6
|
class PiralExtension extends HTMLElement {
|
|
7
7
|
constructor() {
|
|
8
8
|
super(...arguments);
|
|
@@ -48,13 +48,15 @@ function render(context, element, props) {
|
|
|
48
48
|
return [dispose, update];
|
|
49
49
|
}
|
|
50
50
|
export function createCoreApi(context) {
|
|
51
|
-
document
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
if (typeof document !== 'undefined') {
|
|
52
|
+
document.body.addEventListener('render-html', (ev) => {
|
|
53
|
+
ev.stopPropagation();
|
|
54
|
+
const container = ev.detail.target;
|
|
55
|
+
const [dispose, update] = render(context, container, ev.detail.props);
|
|
56
|
+
container.dispose = dispose;
|
|
57
|
+
container.update = update;
|
|
58
|
+
}, false);
|
|
59
|
+
}
|
|
58
60
|
return (api, target) => {
|
|
59
61
|
const pilet = target.name;
|
|
60
62
|
return {
|
package/esm/modules/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqC,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE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,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAChC,OAAO,SAAS,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import { isfunc } from 'piral-base';
|
|
2
|
+
import { __assign } from 'tslib';
|
|
2
3
|
/**
|
|
3
4
|
* The global dependencies, which represent the dependencies
|
|
4
5
|
* shared from the app shell itself.
|
|
5
6
|
*/
|
|
6
|
-
export const globalDependencies = {
|
|
7
|
-
react: require('react'),
|
|
8
|
-
'react-dom': require('react-dom'),
|
|
9
|
-
'react-router': require('react-router'),
|
|
10
|
-
'react-router-dom': require('react-router-dom'),
|
|
11
|
-
history: require('history'),
|
|
12
|
-
tslib: require('tslib'),
|
|
13
|
-
'path-to-regexp': require('path-to-regexp'),
|
|
14
|
-
'@libre/atom': require('@libre/atom'),
|
|
15
|
-
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
16
|
-
};
|
|
7
|
+
export const globalDependencies = {};
|
|
17
8
|
if (process.env.SHARED_DEPENDENCIES) {
|
|
18
9
|
const fillDependencies = require('../../dependencies.codegen');
|
|
19
10
|
if (isfunc(fillDependencies)) {
|
|
20
11
|
fillDependencies(globalDependencies);
|
|
21
12
|
}
|
|
13
|
+
else {
|
|
14
|
+
// fall back to the default list if the codegen is invalid / not supported
|
|
15
|
+
__assign(globalDependencies, {
|
|
16
|
+
react: require('react'),
|
|
17
|
+
'react-dom': require('react-dom'),
|
|
18
|
+
'react-router': require('react-router'),
|
|
19
|
+
'react-router-dom': require('react-router-dom'),
|
|
20
|
+
history: require('history'),
|
|
21
|
+
tslib: require('tslib'),
|
|
22
|
+
'path-to-regexp': require('path-to-regexp'),
|
|
23
|
+
'@libre/atom': require('@libre/atom'),
|
|
24
|
+
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
// App shell is built with something else than the Piral CLI - just don't fill ...
|
|
22
30
|
}
|
|
23
31
|
/**
|
|
24
32
|
* The default dependency selector, which just returns the provided
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,MAAM,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,MAAM,EAAE,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC;;;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/lib/modules/api.js
CHANGED
|
@@ -5,7 +5,7 @@ const piral_base_1 = require("piral-base");
|
|
|
5
5
|
const state_1 = require("../state");
|
|
6
6
|
const components_1 = require("../components");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
-
if ('customElements' in window) {
|
|
8
|
+
if (typeof window !== 'undefined' && 'customElements' in window) {
|
|
9
9
|
class PiralExtension extends HTMLElement {
|
|
10
10
|
constructor() {
|
|
11
11
|
super(...arguments);
|
|
@@ -51,13 +51,15 @@ function render(context, element, props) {
|
|
|
51
51
|
return [dispose, update];
|
|
52
52
|
}
|
|
53
53
|
function createCoreApi(context) {
|
|
54
|
-
document
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
if (typeof document !== 'undefined') {
|
|
55
|
+
document.body.addEventListener('render-html', (ev) => {
|
|
56
|
+
ev.stopPropagation();
|
|
57
|
+
const container = ev.detail.target;
|
|
58
|
+
const [dispose, update] = render(context, container, ev.detail.props);
|
|
59
|
+
container.dispose = dispose;
|
|
60
|
+
container.update = update;
|
|
61
|
+
}, false);
|
|
62
|
+
}
|
|
61
63
|
return (api, target) => {
|
|
62
64
|
const pilet = target.name;
|
|
63
65
|
return {
|
package/lib/modules/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":";;;AAAA,2CAAiG;AAEjG,oCAAmC;AACnC,8CAA8C;AAC9C,o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elector = exports.globalDependencies = void 0;
|
|
4
4
|
const piral_base_1 = require("piral-base");
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
5
6
|
/**
|
|
6
7
|
* The global dependencies, which represent the dependencies
|
|
7
8
|
* shared from the app shell itself.
|
|
8
9
|
*/
|
|
9
|
-
exports.globalDependencies = {
|
|
10
|
-
react: require('react'),
|
|
11
|
-
'react-dom': require('react-dom'),
|
|
12
|
-
'react-router': require('react-router'),
|
|
13
|
-
'react-router-dom': require('react-router-dom'),
|
|
14
|
-
history: require('history'),
|
|
15
|
-
tslib: require('tslib'),
|
|
16
|
-
'path-to-regexp': require('path-to-regexp'),
|
|
17
|
-
'@libre/atom': require('@libre/atom'),
|
|
18
|
-
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
19
|
-
};
|
|
10
|
+
exports.globalDependencies = {};
|
|
20
11
|
if (process.env.SHARED_DEPENDENCIES) {
|
|
21
12
|
const fillDependencies = require('../../dependencies.codegen');
|
|
22
13
|
if ((0, piral_base_1.isfunc)(fillDependencies)) {
|
|
23
14
|
fillDependencies(exports.globalDependencies);
|
|
24
15
|
}
|
|
16
|
+
else {
|
|
17
|
+
// fall back to the default list if the codegen is invalid / not supported
|
|
18
|
+
(0, tslib_1.__assign)(exports.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
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// App shell is built with something else than the Piral CLI - just don't fill ...
|
|
25
33
|
}
|
|
26
34
|
/**
|
|
27
35
|
* The default dependency selector, which just returns the provided
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAC1E,iCAAiC;AAEjC;;;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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-core",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.1-beta.3244",
|
|
4
4
|
"description": "The core library for creating a Piral instance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -22,8 +22,6 @@
|
|
|
22
22
|
"esm",
|
|
23
23
|
"lib",
|
|
24
24
|
"src",
|
|
25
|
-
"debug-pilet.ts",
|
|
26
|
-
"debug-piral.ts",
|
|
27
25
|
"debug-pilet.d.ts",
|
|
28
26
|
"debug-piral.d.ts",
|
|
29
27
|
"debug-pilet.js",
|
|
@@ -64,10 +62,21 @@
|
|
|
64
62
|
"react-router": ">=5.0.0",
|
|
65
63
|
"react-router-dom": ">=5.0.0"
|
|
66
64
|
},
|
|
65
|
+
"sharedDependencies": [
|
|
66
|
+
"react",
|
|
67
|
+
"react-dom",
|
|
68
|
+
"react-router",
|
|
69
|
+
"react-router-dom",
|
|
70
|
+
"history",
|
|
71
|
+
"tslib",
|
|
72
|
+
"path-to-regexp",
|
|
73
|
+
"@libre/atom",
|
|
74
|
+
"@dbeining/react-atom"
|
|
75
|
+
],
|
|
67
76
|
"dependencies": {
|
|
68
77
|
"@dbeining/react-atom": "^4.0.0",
|
|
69
|
-
"piral-base": "
|
|
70
|
-
"piral-debug-utils": "
|
|
78
|
+
"piral-base": "0.14.1-beta.3244",
|
|
79
|
+
"piral-debug-utils": "0.14.1-beta.3244"
|
|
71
80
|
},
|
|
72
|
-
"gitHead": "
|
|
81
|
+
"gitHead": "358d1d5a45743dac772d437b26a875b3d98c3008"
|
|
73
82
|
}
|
package/src/modules/api.ts
CHANGED
|
@@ -9,7 +9,7 @@ interface Updatable {
|
|
|
9
9
|
(newProps: any): void;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
if ('customElements' in window) {
|
|
12
|
+
if (typeof window !== 'undefined' && 'customElements' in window) {
|
|
13
13
|
class PiralExtension extends HTMLElement {
|
|
14
14
|
dispose: Disposable = noop;
|
|
15
15
|
update: Updatable = noop;
|
|
@@ -62,17 +62,19 @@ function render(context: GlobalStateContext, element: HTMLElement | ShadowRoot,
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
export function createCoreApi(context: GlobalStateContext): PiletApiExtender<PiletCoreApi> {
|
|
65
|
-
document
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
ev
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
65
|
+
if (typeof document !== 'undefined') {
|
|
66
|
+
document.body.addEventListener(
|
|
67
|
+
'render-html',
|
|
68
|
+
(ev: CustomEvent) => {
|
|
69
|
+
ev.stopPropagation();
|
|
70
|
+
const container = ev.detail.target;
|
|
71
|
+
const [dispose, update] = render(context, container, ev.detail.props);
|
|
72
|
+
container.dispose = dispose;
|
|
73
|
+
container.update = update;
|
|
74
|
+
},
|
|
75
|
+
false,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
76
78
|
|
|
77
79
|
return (api, target) => {
|
|
78
80
|
const pilet = target.name;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { globalDependencies, defaultDependencySelector, defaultModuleRequester } from './dependencies';
|
|
2
2
|
|
|
3
3
|
describe('Dependencies Module', () => {
|
|
4
|
-
it('globalDependencies should contain
|
|
5
|
-
expect(globalDependencies).
|
|
6
|
-
expect(globalDependencies).toHaveProperty('history');
|
|
7
|
-
expect(globalDependencies).not.toHaveProperty('foo');
|
|
4
|
+
it('globalDependencies should not contain any dependencies', () => {
|
|
5
|
+
expect(globalDependencies).toEqual({});
|
|
8
6
|
});
|
|
9
|
-
|
|
7
|
+
|
|
10
8
|
it('defaultDependencySelector should return given dependencies', () => {
|
|
11
9
|
const deps = defaultDependencySelector({
|
|
12
10
|
foo: 'bar',
|
|
@@ -14,7 +12,7 @@ describe('Dependencies Module', () => {
|
|
|
14
12
|
expect(deps).toHaveProperty('foo');
|
|
15
13
|
expect(deps).not.toHaveProperty('bar');
|
|
16
14
|
});
|
|
17
|
-
|
|
15
|
+
|
|
18
16
|
it('defaultModuleRequester should return given dependencies', async () => {
|
|
19
17
|
const mods = await defaultModuleRequester();
|
|
20
18
|
expect(mods).toEqual([]);
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import { PiletMetadata, AvailableDependencies, isfunc } from 'piral-base';
|
|
2
|
+
import { __assign } from 'tslib';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* The global dependencies, which represent the dependencies
|
|
5
6
|
* shared from the app shell itself.
|
|
6
7
|
*/
|
|
7
|
-
export const globalDependencies: AvailableDependencies = {
|
|
8
|
-
react: require('react'),
|
|
9
|
-
'react-dom': require('react-dom'),
|
|
10
|
-
'react-router': require('react-router'),
|
|
11
|
-
'react-router-dom': require('react-router-dom'),
|
|
12
|
-
history: require('history'),
|
|
13
|
-
tslib: require('tslib'),
|
|
14
|
-
'path-to-regexp': require('path-to-regexp'),
|
|
15
|
-
'@libre/atom': require('@libre/atom'),
|
|
16
|
-
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
17
|
-
};
|
|
8
|
+
export const globalDependencies: AvailableDependencies = {};
|
|
18
9
|
|
|
19
10
|
if (process.env.SHARED_DEPENDENCIES) {
|
|
20
11
|
const fillDependencies = require('../../dependencies.codegen');
|
|
21
12
|
|
|
22
13
|
if (isfunc(fillDependencies)) {
|
|
23
14
|
fillDependencies(globalDependencies);
|
|
15
|
+
} else {
|
|
16
|
+
// fall back to the default list if the codegen is invalid / not supported
|
|
17
|
+
__assign(globalDependencies, {
|
|
18
|
+
react: require('react'),
|
|
19
|
+
'react-dom': require('react-dom'),
|
|
20
|
+
'react-router': require('react-router'),
|
|
21
|
+
'react-router-dom': require('react-router-dom'),
|
|
22
|
+
history: require('history'),
|
|
23
|
+
tslib: require('tslib'),
|
|
24
|
+
'path-to-regexp': require('path-to-regexp'),
|
|
25
|
+
'@libre/atom': require('@libre/atom'),
|
|
26
|
+
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
27
|
+
});
|
|
24
28
|
}
|
|
29
|
+
} else {
|
|
30
|
+
// App shell is built with something else than the Piral CLI - just don't fill ...
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
/**
|
package/debug-pilet.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LoadPiletsOptions } from 'piral-base';
|
|
2
|
-
import { withEmulatorPilets } from 'piral-debug-utils';
|
|
3
|
-
import { GlobalStateContext } from './lib/types';
|
|
4
|
-
|
|
5
|
-
export function integrate(context: GlobalStateContext, options: LoadPiletsOptions) {
|
|
6
|
-
options.fetchPilets = withEmulatorPilets(options.fetchPilets, {
|
|
7
|
-
injectPilet: context.injectPilet,
|
|
8
|
-
createApi: options.createApi,
|
|
9
|
-
loadPilet: options.loadPilet,
|
|
10
|
-
});
|
|
11
|
-
}
|
package/debug-piral.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
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 './lib/types';
|
|
5
|
-
|
|
6
|
-
export function integrate(
|
|
7
|
-
context: GlobalStateContext,
|
|
8
|
-
options: LoadPiletsOptions,
|
|
9
|
-
debug: DebuggerExtensionOptions = {},
|
|
10
|
-
) {
|
|
11
|
-
installPiralDebug({
|
|
12
|
-
...debug,
|
|
13
|
-
createApi: options.createApi,
|
|
14
|
-
loadPilet: options.loadPilet,
|
|
15
|
-
injectPilet: context.injectPilet,
|
|
16
|
-
fireEvent: context.emit,
|
|
17
|
-
getDependencies() {
|
|
18
|
-
return Object.keys(options.dependencies);
|
|
19
|
-
},
|
|
20
|
-
getExtensions() {
|
|
21
|
-
return context.readState((s) => Object.keys(s.registry.extensions));
|
|
22
|
-
},
|
|
23
|
-
getRoutes() {
|
|
24
|
-
const registeredRoutes = context.readState((state) => Object.keys(state.registry.pages));
|
|
25
|
-
const componentRoutes = context.readState((state) => Object.keys(state.routes));
|
|
26
|
-
return [...componentRoutes, ...registeredRoutes];
|
|
27
|
-
},
|
|
28
|
-
getGlobalState() {
|
|
29
|
-
return context.readState((s) => s);
|
|
30
|
-
},
|
|
31
|
-
getPilets() {
|
|
32
|
-
return context.readState((s) => s.modules);
|
|
33
|
-
},
|
|
34
|
-
setPilets(modules) {
|
|
35
|
-
context.dispatch((state) => ({
|
|
36
|
-
...state,
|
|
37
|
-
modules,
|
|
38
|
-
}));
|
|
39
|
-
},
|
|
40
|
-
integrate(dbg) {
|
|
41
|
-
context.dispatch((s) => ({
|
|
42
|
-
...s,
|
|
43
|
-
components: {
|
|
44
|
-
...s.components,
|
|
45
|
-
...dbg.components,
|
|
46
|
-
},
|
|
47
|
-
routes: {
|
|
48
|
-
...s.routes,
|
|
49
|
-
...dbg.routes,
|
|
50
|
-
},
|
|
51
|
-
registry: {
|
|
52
|
-
...s.registry,
|
|
53
|
-
wrappers: {
|
|
54
|
-
...s.registry.wrappers,
|
|
55
|
-
...dbg.wrappers,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
addChangeHandler(context.state, 'debugging', ({ previous, current }) => {
|
|
61
|
-
const pilets = current.modules !== previous.modules;
|
|
62
|
-
const pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
|
|
63
|
-
const extensions = current.registry.extensions !== previous.registry.extensions;
|
|
64
|
-
const state = current !== previous;
|
|
65
|
-
dbg.onChange(previous, current, {
|
|
66
|
-
pilets,
|
|
67
|
-
pages,
|
|
68
|
-
extensions,
|
|
69
|
-
state,
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
}
|