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
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapComponent = void 0;
4
+ const React = require("react");
5
+ const react_router_1 = require("react-router");
6
+ const PortalRenderer_1 = require("./PortalRenderer");
7
+ const ForeignComponentContainer_1 = require("./ForeignComponentContainer");
8
+ const hooks_1 = require("../hooks");
9
+ const utils_1 = require("../utils");
10
+ // this is an arbitrary start number to have 6 digits
11
+ let portalIdBase = 123456;
12
+ function wrapReactComponent(Component, captured, Wrapper) {
13
+ return (props) => (React.createElement(Wrapper, Object.assign({}, props),
14
+ React.createElement(Component, Object.assign({}, props, captured))));
15
+ }
16
+ function wrapForeignComponent(component, captured, Wrapper) {
17
+ return React.memo((props) => {
18
+ const { state, readState, destroyPortal } = (0, hooks_1.useGlobalStateContext)();
19
+ const router = React.useContext(react_router_1.__RouterContext);
20
+ const id = React.useMemo(() => (portalIdBase++).toString(26), utils_1.none);
21
+ const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
22
+ const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
23
+ React.useEffect(() => () => destroyPortal(id), utils_1.none);
24
+ return (React.createElement(Wrapper, Object.assign({}, props),
25
+ React.createElement(PortalRenderer_1.PortalRenderer, { id: id }),
26
+ React.createElement(ForeignComponentContainer_1.ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context })));
27
+ });
28
+ }
29
+ function isNotExotic(component) {
30
+ return !component.$$typeof;
31
+ }
32
+ function wrapComponent(converters, component, captured, Wrapper) {
33
+ if (!component) {
34
+ const pilet = captured.piral.meta.name;
35
+ console.error(`[${pilet}] The given value is not a valid component.`);
36
+ // tslint:disable-next-line:no-null-keyword
37
+ component = () => null;
38
+ }
39
+ if (typeof component === 'object' && isNotExotic(component)) {
40
+ const result = (0, utils_1.convertComponent)(converters[component.type], component);
41
+ return wrapForeignComponent(result, captured, Wrapper);
42
+ }
43
+ return wrapReactComponent(component, captured, Wrapper);
44
+ }
45
+ exports.wrapComponent = wrapComponent;
46
+ //# sourceMappingURL=wrapComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+CAA+C;AAC/C,qDAAkD;AAClD,2EAAwE;AACxE,oCAAiD;AACjD,oCAAkD;AAGlD,qDAAqD;AACrD,IAAI,YAAY,GAAG,MAAM,CAAC;AAM1B,SAAS,kBAAkB,CACzB,SAAsD,EACtD,QAAuB,EACvB,OAAoB;IAEpB,OAAO,CAAC,KAAQ,EAAE,EAAE,CAAC,CACnB,oBAAC,OAAO,oBAAK,KAAK;QAChB,oBAAC,SAAS,oBAAK,KAAK,EAAM,QAAQ,EAAI,CAC9B,CACX,CAAC;AACJ,CAAC;AAED,SAAS,oBAAoB,CAC3B,SAAmD,EACnD,QAAuB,EACvB,OAAoB;IAEpB,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,KAAQ,EAAE,EAAE;QAC7B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,aAA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;QACtE,2CAA2C;QAC3C,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;KACxB;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE;QAC3D,MAAM,MAAM,GAAG,IAAA,wBAAgB,EAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;QACvE,OAAO,oBAAoB,CAAI,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC3D;IAED,OAAO,kBAAkB,CAAI,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC;AAnBD,sCAmBC"}
@@ -36,7 +36,7 @@ function createInstance(config = {}) {
36
36
  const usedPlugins = Array.isArray(definedPlugins) ? definedPlugins : [definedPlugins];
37
37
  const createApi = apiFactory(context, usedPlugins);
38
38
  const root = createApi({
39
- name: 'root',
39
+ name: '_',
40
40
  version: process.env.BUILD_PCKG_VERSION || '1.0.0',
41
41
  spec: 'v0',
42
42
  basePath: '',
@@ -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,OAAO,EACP,KAAK,EACL,UAAU,GAAG,2BAAiB,GAC/B,GAAG,MAAM,CAAC;IACX,MAAM,WAAW,GAAG,IAAA,yBAAiB,EAAC,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AM,OAAO,GAAG,IAAA,4BAAkB,EAAC;QACjC,OAAO;QACP,SAAS;QACT,OAAO;QACP,SAAS;QACT,eAAe;QACf,YAAY;QACZ,iBAAiB;QACjB,QAAQ,EAAE,IAAA,mBAAM,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,4BAAe,CAAC,CAAC,CAAC,6BAAgB;QAC5E,aAAa;QACb,KAAK;KACN,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE;QACX,IAAA,sBAAc,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAClC;IAED,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAE1B,OAAO,IAAA,gBAAQ,EAAC,MAAM,EAAE;QACtB,EAAE;QACF,SAAS;QACT,OAAO;QACP,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAzDD,wCAyDC"}
@@ -0,0 +1,4 @@
1
+ import { LoadPiletsOptions } from 'piral-base';
2
+ import { DebuggerExtensionOptions } from 'piral-debug-utils';
3
+ import { GlobalStateContext } from './types';
4
+ export declare function integrateDebugger(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.integrateDebugger = void 0;
4
+ const react_atom_1 = require("@dbeining/react-atom");
5
+ const piral_debug_utils_1 = require("piral-debug-utils");
6
+ function integrateDebugger(context, options, debug = {}) {
7
+ (0, piral_debug_utils_1.installPiralDebug)(Object.assign(Object.assign({}, debug), { addPilet: context.addPilet, removePilet: context.removePilet, updatePilet(pilet) {
8
+ if (!pilet.disabled) {
9
+ const { createApi } = options;
10
+ const newApi = createApi(pilet);
11
+ try {
12
+ context.injectPilet(pilet);
13
+ pilet.setup(newApi);
14
+ }
15
+ catch (error) {
16
+ console.error(error);
17
+ }
18
+ }
19
+ else {
20
+ context.injectPilet(pilet);
21
+ }
22
+ }, fireEvent: context.emit, getDependencies() {
23
+ return Object.keys(options.dependencies);
24
+ },
25
+ getExtensions() {
26
+ return context.readState((s) => Object.keys(s.registry.extensions));
27
+ },
28
+ getRoutes() {
29
+ const registeredRoutes = context.readState((state) => Object.keys(state.registry.pages));
30
+ const componentRoutes = context.readState((state) => Object.keys(state.routes));
31
+ return [...componentRoutes, ...registeredRoutes];
32
+ },
33
+ getGlobalState() {
34
+ return context.readState((s) => s);
35
+ },
36
+ getPilets() {
37
+ return context.readState((s) => s.modules);
38
+ },
39
+ integrate(dbg) {
40
+ context.dispatch((s) => (Object.assign(Object.assign({}, s), { components: Object.assign(Object.assign({}, s.components), dbg.components), routes: Object.assign(Object.assign({}, s.routes), dbg.routes), registry: Object.assign(Object.assign({}, s.registry), { wrappers: Object.assign(Object.assign({}, s.registry.wrappers), dbg.wrappers) }) })));
41
+ (0, react_atom_1.addChangeHandler)(context.state, 'debugging', ({ previous, current }) => {
42
+ const pilets = current.modules !== previous.modules;
43
+ const pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
44
+ const extensions = current.registry.extensions !== previous.registry.extensions;
45
+ const state = current !== previous;
46
+ dbg.onChange(previous, current, {
47
+ pilets,
48
+ pages,
49
+ extensions,
50
+ state,
51
+ });
52
+ });
53
+ } }));
54
+ }
55
+ exports.integrateDebugger = integrateDebugger;
56
+ //# sourceMappingURL=debugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AAExD,yDAAgF;AAGhF,SAAgB,iBAAiB,CAC/B,OAA2B,EAC3B,OAA0B,EAC1B,QAAkC,EAAE;IAEpC,IAAA,qCAAiB,kCACZ,KAAK,KACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,WAAW,CAAC,KAAK;YACf,IAAI,CAAC,KAAK,CAAC,QAAQ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CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAC7C,CAAC;QACD,SAAS,CAAC,GAAG;YACX,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCACnB,CAAC,KACJ,UAAU,kCACL,CAAC,CAAC,UAAU,GACZ,GAAG,CAAC,UAAU,GAEnB,MAAM,kCACD,CAAC,CAAC,MAAM,GACR,GAAG,CAAC,MAAM,GAEf,QAAQ,kCACH,CAAC,CAAC,QAAQ,KACb,QAAQ,kCACH,CAAC,CAAC,QAAQ,CAAC,QAAQ,GACnB,GAAG,CAAC,QAAQ,QAGnB,CAAC,CAAC;YAEJ,IAAA,6BAAgB,EAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE;gBACrE,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO,CAAC;gBACpD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;gBACvG,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAChF,MAAM,KAAK,GAAG,OAAO,KAAK,QAAQ,CAAC;gBACnC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE;oBAC9B,MAAM;oBACN,KAAK;oBACL,UAAU;oBACV,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,IACD,CAAC;AACL,CAAC;AA5ED,8CA4EC"}
@@ -0,0 +1,3 @@
1
+ import { LoadPiletsOptions } from 'piral-base';
2
+ import { GlobalStateContext } from './types';
3
+ export declare function integrateEmulator(context: GlobalStateContext, options: LoadPiletsOptions): void;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.integrateEmulator = void 0;
4
+ const piral_debug_utils_1 = require("piral-debug-utils");
5
+ function integrateEmulator(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.integrateEmulator = integrateEmulator;
12
+ //# sourceMappingURL=emulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":";;;AACA,yDAAuD;AAGvD,SAAgB,iBAAiB,CAAC,OAA2B,EAAE,OAA0B;IACvF,OAAO,CAAC,WAAW,GAAG,IAAA,sCAAkB,EAAC,OAAO,CAAC,WAAW,EAAE;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC,CAAC;AACL,CAAC;AALD,8CAKC"}
package/lib/helpers.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PiletApiCreator, LoadPiletsOptions, CustomSpecLoaders, DefaultLoaderConfig, PiletLoader, PiletLifecycleHooks } from 'piral-base';
2
- import { DebuggerExtensionOptions } from 'piral-debug-utils';
2
+ import type { DebuggerExtensionOptions } from 'piral-debug-utils';
3
3
  import type { Pilet, PiletRequester, GlobalStateContext, PiletLoadingStrategy, DependencySelector } from './types';
4
4
  export interface PiletOptionsConfig {
5
5
  context: GlobalStateContext;
package/lib/helpers.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createPiletOptions = void 0;
4
4
  const piral_base_1 = require("piral-base");
5
5
  const modules_1 = require("./modules");
6
+ const debug_codegen_1 = require("../debug.codegen");
6
7
  function createPiletOptions({ hooks, context, loaders, loaderConfig, availablePilets, strategy, createApi, loadPilet, requestPilets, shareDependencies, debug, }) {
7
8
  const options = {
8
9
  config: loaderConfig,
@@ -14,16 +15,8 @@ function createPiletOptions({ hooks, context, loaders, loaderConfig, availablePi
14
15
  hooks,
15
16
  dependencies: shareDependencies(modules_1.globalDependencies),
16
17
  };
17
- // if we build the debug version of piral (debug and emulator build)
18
- if (process.env.DEBUG_PIRAL) {
19
- const { integrate } = require('../debug-piral');
20
- integrate(context, options, debug);
21
- }
22
- // if we build the emulator version of piral (shipped to pilets)
23
- if (process.env.DEBUG_PILET) {
24
- const { integrate } = require('../debug-pilet');
25
- integrate(context, options);
26
- }
18
+ (0, debug_codegen_1.integrateDebugger)(context, options, debug);
19
+ (0, debug_codegen_1.integrateEmulator)(context, options, debug);
27
20
  return options;
28
21
  }
29
22
  exports.createPiletOptions = createPiletOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":";;;AAAA,2CASoB;AAEpB,uCAA+C;AAiB/C,SAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,OAAO,EACP,OAAO,EACP,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,KAAK,GACc;IACnB,MAAM,OAAO,GAAsB;QACjC,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,SAAS,EAAE,IAAA,yBAAY,EAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAA,6BAAgB,EAAC,YAAY,CAAC,EAAE,OAAO,CAAC;QAC7E,SAAS;QACT,MAAM,EAAE,eAAe;QACvB,WAAW,EAAE,aAAa;QAC1B,KAAK;QACL,YAAY,EAAE,iBAAiB,CAAC,4BAAkB,CAAC;KACpD,CAAC;IAEF,oEAAoE;IACpE,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAChD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;KACpC;IAED,gEAAgE;IAChE,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAChD,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAC7B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AArCD,gDAqCC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":";;;AAAA,2CASoB;AAEpB,uCAA+C;AAE/C,oDAAwE;AAgBxE,SAAgB,kBAAkB,CAAC,EACjC,KAAK,EACL,OAAO,EACP,OAAO,EACP,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,KAAK,GACc;IACnB,MAAM,OAAO,GAAsB;QACjC,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,SAAS,EAAE,IAAA,yBAAY,EAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAA,6BAAgB,EAAC,YAAY,CAAC,EAAE,OAAO,CAAC;QAC7E,SAAS;QACT,MAAM,EAAE,eAAe;QACvB,WAAW,EAAE,aAAa;QAC1B,KAAK;QACL,YAAY,EAAE,iBAAiB,CAAC,4BAAkB,CAAC;KACpD,CAAC;IAEF,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC;AACjB,CAAC;AA5BD,gDA4BC"}
@@ -17,25 +17,27 @@ function createCoreApi(context) {
17
17
  const expiration = (0, utils_1.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 = (0, state_1.withApi)(context, arg, api, 'page', undefined, { meta });
21
22
  context.registerPage(route, {
22
23
  pilet,
23
24
  meta,
24
- component: (0, state_1.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
+ registerExtension(name, reference, defaults) {
33
+ const component = (0, state_1.withApi)(context, reference, api, 'extension');
32
34
  context.registerExtension(name, {
33
35
  pilet,
34
- component: (0, state_1.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
43
  context.unregisterExtension(name, arg);
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/modules/core.ts"],"names":[],"mappings":";;;AACA,uCAA0C;AAC1C,oCAAmC;AACnC,8CAA8C;AAC9C,oCAAgE;AAGhE,SAAgB,aAAa,CAAC,OAA2B;IACvD,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,OAAO;YACL,OAAO,CAAC,IAAI;gBACV,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO;gBAC1B,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAA,yBAAiB,EAAC,OAAO,CAAC,CAAC;gBAClE,MAAM,UAAU,GAAG,IAAA,yBAAiB,EAAC,OAAO,CAAC,CAAC;gBAC9C,OAAO,OAAO,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;YAC1E,CAA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oBAC9B,KAAK;oBACL,SAAS;oBACT,SAAS;oBACT,QAAQ;iBACT,CAAC,CAAC;gBACH,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACxD,CAAC;YACD,mBAAmB,CAAC,IAAI,EAAE,GAAG;gBAC3B,OAAO,CAAC,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACzC,CAAC;YACD,mBAAmB,CAAC,OAAO,EAAE,KAAK;gBAChC,MAAM,CAAC,OAAO,CAAC,GAAG,IAAA,uBAAa,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;gBACzD,OAAO,OAAO,CAAC;YACjB,CAAC;YACD,SAAS,EAAE,0BAAa;SACzB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA5CD,sCA4CC"}
@@ -2,34 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultModuleRequester = exports.defaultDependencySelector = exports.globalDependencies = void 0;
4
4
  const piral_base_1 = require("piral-base");
5
- const tslib_1 = require("tslib");
5
+ const dependencies_codegen_1 = require("../../dependencies.codegen");
6
6
  /**
7
7
  * The global dependencies, which represent the dependencies
8
8
  * shared from the app shell itself.
9
9
  */
10
10
  exports.globalDependencies = {};
11
- if (process.env.SHARED_DEPENDENCIES) {
12
- const fillDependencies = require('../../dependencies.codegen');
13
- if ((0, piral_base_1.isfunc)(fillDependencies)) {
14
- fillDependencies(exports.globalDependencies);
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 ...
11
+ if ((0, piral_base_1.isfunc)(dependencies_codegen_1.default)) {
12
+ (0, dependencies_codegen_1.default)(exports.globalDependencies);
33
13
  }
34
14
  /**
35
15
  * 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,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"}
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AAEpC,qEAA0D;AAE1D;;;GAGG;AACU,QAAA,kBAAkB,GAA0B,EAAE,CAAC;AAE5D,IAAI,IAAA,mBAAM,EAAC,8BAAgB,CAAC,EAAE;IAC5B,IAAA,8BAAgB,EAAC,0BAAkB,CAAC,CAAC;CACtC;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"}
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { AnyComponent, Errors, PiletApi, BaseComponentProps, GlobalStateContext } from '../types';
3
- export declare function withApi<TProps>(context: GlobalStateContext, component: AnyComponent<TProps & BaseComponentProps>, piral: PiletApi, errorType: keyof Errors, wrapperType?: string): React.MemoExoticComponent<(props: TProps) => JSX.Element> | React.ComponentType<TProps>;
3
+ export declare function withApi<TProps>(context: GlobalStateContext, component: AnyComponent<TProps & BaseComponentProps>, piral: PiletApi, errorType: keyof Errors, wrapperType?: string, captured?: {}): React.MemoExoticComponent<(props: TProps) => JSX.Element> | React.ComponentType<TProps>;
@@ -2,114 +2,28 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withApi = void 0;
4
4
  const React = require("react");
5
- const piral_base_1 = require("piral-base");
6
- const react_router_1 = require("react-router");
7
5
  const components_1 = require("../components");
8
- const hooks_1 = require("../hooks");
9
6
  const utils_1 = require("../utils");
10
- // this is an arbitrary start number to have 6 digits
11
- let portalIdBase = 123456;
12
7
  const DefaultWrapper = (props) => (0, utils_1.defaultRender)(props.children);
13
- class ForeignComponentContainer extends React.Component {
14
- constructor() {
15
- super(...arguments);
16
- this.handler = (ev) => {
17
- const { innerProps } = this.props;
18
- ev.stopPropagation();
19
- innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
20
- };
21
- this.setNode = (node) => {
22
- this.current = node;
23
- };
24
- }
25
- componentDidMount() {
26
- const node = this.current;
27
- const { $component, $context, innerProps } = this.props;
28
- const { mount } = $component;
29
- if (node && (0, piral_base_1.isfunc)(mount)) {
30
- mount(node, innerProps, $context);
31
- node.addEventListener('render-html', this.handler, false);
32
- }
33
- this.previous = node;
34
- }
35
- componentDidUpdate() {
36
- const { current, previous } = this;
37
- const { $component, $context, innerProps } = this.props;
38
- const { update } = $component;
39
- if (current !== previous) {
40
- previous && this.componentWillUnmount();
41
- current && this.componentDidMount();
42
- }
43
- else if ((0, piral_base_1.isfunc)(update)) {
44
- update(current, innerProps, $context);
45
- }
46
- }
47
- componentWillUnmount() {
48
- const node = this.previous;
49
- const { $component } = this.props;
50
- const { unmount } = $component;
51
- if (node && (0, piral_base_1.isfunc)(unmount)) {
52
- unmount(node);
53
- node.removeEventListener('render-html', this.handler, false);
54
- }
55
- this.previous = undefined;
56
- }
57
- render() {
58
- const { $portalId } = this.props;
59
- return React.createElement("div", { "data-portal-id": $portalId, ref: this.setNode });
60
- }
61
- }
62
- function wrapReactComponent(Component, stasisOptions, piral, Wrapper) {
63
- return (props) => (React.createElement(Wrapper, Object.assign({}, props, { piral: piral }),
64
- React.createElement(components_1.ErrorBoundary, Object.assign({}, stasisOptions, { renderProps: props }),
65
- React.createElement(Component, Object.assign({}, props, { piral: piral })))));
66
- }
67
- function wrapForeignComponent(component, stasisOptions, piral, Wrapper) {
68
- return React.memo((props) => {
69
- const { state, readState, destroyPortal } = (0, hooks_1.useGlobalStateContext)();
70
- const router = React.useContext(react_router_1.__RouterContext);
71
- const id = React.useMemo(() => (portalIdBase++).toString(26), utils_1.none);
72
- const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
73
- const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), { piral })), [props]);
74
- React.useEffect(() => () => destroyPortal(id), utils_1.none);
75
- return (React.createElement(Wrapper, Object.assign({}, innerProps),
76
- React.createElement(components_1.ErrorBoundary, Object.assign({}, stasisOptions, { renderProps: props }),
77
- React.createElement(components_1.PortalRenderer, { id: id }),
78
- React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context }))));
79
- });
80
- }
81
- function isNotExotic(component) {
82
- return !component.$$typeof;
83
- }
84
- function wrapComponent(converters, component, piral, Wrapper, stasisOptions) {
85
- if (!component) {
86
- console.error('The given value is not a valid component.');
87
- // tslint:disable-next-line:no-null-keyword
88
- component = () => null;
89
- }
90
- if (typeof component === 'object' && isNotExotic(component)) {
91
- const result = (0, utils_1.convertComponent)(converters[component.type], component);
92
- return wrapForeignComponent(result, stasisOptions, piral, Wrapper);
8
+ function getWrapper(wrappers, wrapperType) {
9
+ const WrapAll = wrappers['*'];
10
+ const WrapType = wrappers[wrapperType];
11
+ if (WrapAll && WrapType) {
12
+ return (props) => (React.createElement(WrapAll, Object.assign({}, props),
13
+ React.createElement(WrapType, Object.assign({}, props))));
93
14
  }
94
- return wrapReactComponent(component, stasisOptions, piral, Wrapper);
15
+ return WrapType || WrapAll || DefaultWrapper;
95
16
  }
96
- function getWrapper(wrappers, wrapperType) {
97
- return wrappers[wrapperType] || wrappers['*'] || DefaultWrapper;
17
+ function makeWrapper(context, outerProps, wrapperType, errorType) {
18
+ const OuterWrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
19
+ return (props) => (React.createElement(OuterWrapper, Object.assign({}, outerProps, props),
20
+ React.createElement(components_1.ErrorBoundary, Object.assign({}, outerProps, props, { errorType: errorType }), props.children)));
98
21
  }
99
- function withApi(context, component, piral, errorType, wrapperType = errorType) {
22
+ function withApi(context, component, piral, errorType, wrapperType = errorType, captured = {}) {
23
+ const outerProps = Object.assign(Object.assign({}, captured), { piral });
100
24
  const converters = context.converters;
101
- const Wrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
102
- return wrapComponent(converters, component, piral, Wrapper, {
103
- onError(error) {
104
- console.error(piral, error);
105
- },
106
- renderChild(child) {
107
- return React.createElement(React.Suspense, { fallback: React.createElement(components_1.PiralLoadingIndicator, null) }, child);
108
- },
109
- renderError(error, props) {
110
- return React.createElement(components_1.PiralError, Object.assign({ type: errorType, error: error }, props));
111
- },
112
- });
25
+ const Wrapper = makeWrapper(context, outerProps, wrapperType, errorType);
26
+ return (0, components_1.wrapComponent)(converters, component, outerProps, Wrapper);
113
27
  }
114
28
  exports.withApi = withApi;
115
29
  //# sourceMappingURL=withApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withApi.js","sourceRoot":"","sources":["../../src/state/withApi.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAoC;AACpC,+CAA+C;AAC/C,8CAAuH;AACvH,oCAAiD;AACjD,oCAAiE;AAYjE,qDAAqD;AACrD,IAAI,YAAY,GAAG,MAAM,CAAC;AAE1B,MAAM,cAAc,GAAa,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAS1E,MAAM,yBAA6B,SAAQ,KAAK,CAAC,SAA4C;IAA7F;;QAGU,YAAO,GAAG,CAAC,EAAe,EAAE,EAAE;YACpC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAClC,EAAE,CAAC,eAAe,EAAE,CAAC;YACrB,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1E,CAAC,CAAC;QAEM,YAAO,GAAG,CAAC,IAAoB,EAAE,EAAE;YACzC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACtB,C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{ ReactElement } from 'react';
2
2
  import type { RouteComponentProps } from 'react-router';
3
- import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter } from 'piral-base';
3
+ import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter, PiletLoader, PiletLoadingStrategy } from 'piral-base';
4
4
  import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
5
5
  import type { AnyComponent } from './components';
6
- import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
6
+ import type { ExtensionParams, 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, PiletEntry, PiletEntries };
9
+ export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries, PiletLoader, PiletLoadingStrategy };
10
10
  /**
11
11
  * The props that every registered component obtains.
12
12
  */
@@ -34,6 +34,11 @@ export interface ExtensionComponentProps<T> extends BaseComponentProps {
34
34
  */
35
35
  params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
36
36
  }
37
+ /**
38
+ * The meta data registered for a page.
39
+ */
40
+ export interface PiralPageMeta extends PiralCustomPageMeta {
41
+ }
37
42
  /**
38
43
  * The props that every registered page component obtains.
39
44
  */
@@ -43,11 +48,10 @@ export interface RouteBaseProps<UrlParams = any, UrlState = any> extends RouteCo
43
48
  * The props used by a page component.
44
49
  */
45
50
  export interface PageComponentProps<T = any, S = any> extends RouteBaseProps<T, S> {
46
- }
47
- /**
48
- * The meta data registered for a page.
49
- */
50
- export interface PiralPageMeta extends PiralCustomPageMeta {
51
+ /**
52
+ * The meta data registered with the page.
53
+ */
54
+ meta: PiralPageMeta;
51
55
  }
52
56
  /**
53
57
  * Defines the Pilet API from piral-core.
@@ -89,7 +93,7 @@ export interface PiletCoreApi {
89
93
  * @param Component The component to be rendered.
90
94
  * @param defaults Optionally, sets the default values for the expected data.
91
95
  */
92
- registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>, defaults?: TName): RegistrationDisposer;
96
+ registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>, defaults?: Partial<ExtensionParams<TName>>): RegistrationDisposer;
93
97
  /**
94
98
  * Unregisters a global extension component.
95
99
  * Only previously registered extension components can be unregistered.
@@ -111,7 +115,7 @@ export interface PiletCoreApi {
111
115
  */
112
116
  renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
113
117
  }
114
- declare module 'piral-base/lib/types' {
118
+ declare module 'piral-base/lib/types/runtime' {
115
119
  interface PiletApi extends PiletCustomApi, PiletCoreApi {
116
120
  }
117
121
  }
@@ -32,7 +32,11 @@ export interface BaseExtensionSlotProps<TName, TParams> {
32
32
  */
33
33
  name: TName;
34
34
  }
35
+ /**
36
+ * Gives the extension params shape for the given extension slot name.
37
+ */
38
+ export declare type ExtensionParams<TName> = TName extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[TName] : TName extends string ? any : TName;
35
39
  /**
36
40
  * The props for defining an extension slot.
37
41
  */
38
- export declare type ExtensionSlotProps<K = string> = BaseExtensionSlotProps<K extends string ? K : string, K extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[K] : K extends string ? any : K>;
42
+ export declare type ExtensionSlotProps<TName = string> = BaseExtensionSlotProps<TName extends string ? TName : string, ExtensionParams<TName>>;
@@ -1,3 +1,4 @@
1
+ export { isfunc, requireModule } from 'piral-base';
1
2
  export * from './compare';
2
3
  export * from './data';
3
4
  export * from './extension';
@@ -1,6 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.requireModule = exports.isfunc = void 0;
3
4
  const tslib_1 = require("tslib");
5
+ var piral_base_1 = require("piral-base");
6
+ Object.defineProperty(exports, "isfunc", { enumerable: true, get: function () { return piral_base_1.isfunc; } });
7
+ Object.defineProperty(exports, "requireModule", { enumerable: true, get: function () { return piral_base_1.requireModule; } });
4
8
  (0, tslib_1.__exportStar)(require("./compare"), exports);
5
9
  (0, tslib_1.__exportStar)(require("./data"), exports);
6
10
  (0, tslib_1.__exportStar)(require("./extension"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,yDAA0B;AAC1B,sDAAuB;AACvB,2DAA4B;AAC5B,yDAA0B;AAC1B,sDAAuB;AACvB,yDAA0B;AAC1B,uDAAwB;AACxB,uDAAwB;AACxB,uDAAwB;AACxB,yDAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;AAAA,yCAAmD;AAA1C,oGAAA,MAAM,OAAA;AAAE,2GAAA,aAAa,OAAA;AAE9B,yDAA0B;AAC1B,sDAAuB;AACvB,2DAA4B;AAC5B,yDAA0B;AAC1B,sDAAuB;AACvB,yDAA0B;AAC1B,uDAAwB;AACxB,uDAAwB;AACxB,uDAAwB;AACxB,yDAA0B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "0.15.0-alpha.3555",
3
+ "version": "0.15.0-alpha.3640",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -22,12 +22,10 @@
22
22
  "esm",
23
23
  "lib",
24
24
  "src",
25
- "debug-pilet.d.ts",
26
- "debug-piral.d.ts",
27
- "debug-pilet.js",
28
- "debug-piral.js",
25
+ "debug.codegen",
26
+ "debug.codegen.*",
29
27
  "dependencies.codegen",
30
- "dependencies.codegen.native.js"
28
+ "dependencies.codegen.*"
31
29
  ],
32
30
  "funding": {
33
31
  "type": "github",
@@ -41,8 +39,7 @@
41
39
  "url": "https://github.com/smapiot/piral/issues"
42
40
  },
43
41
  "scripts": {
44
- "build": "yarn build:commonjs && yarn build:esnext && yarn build:convert",
45
- "build:convert": "tsc debug-pilet.ts debug-piral.ts --skipLibCheck --declaration",
42
+ "build": "yarn build:commonjs && yarn build:esnext",
46
43
  "build:commonjs": "tsc --project tsconfig.json --outDir lib --module commonjs",
47
44
  "build:esnext": "tsc --project tsconfig.json --outDir esm --module esnext",
48
45
  "typedoc": "typedoc --json ../../../docs/types/piral-core.json src --exclude \"src/**/*.test.*\"",
@@ -50,8 +47,8 @@
50
47
  },
51
48
  "dependencies": {
52
49
  "@dbeining/react-atom": "^4.0.0",
53
- "piral-base": "0.15.0-alpha.3555",
54
- "piral-debug-utils": "0.15.0-alpha.3555"
50
+ "piral-base": "0.15.0-alpha.3640",
51
+ "piral-debug-utils": "0.15.0-alpha.3640"
55
52
  },
56
53
  "peerDependencies": {
57
54
  "react": ">=16.8.0",
@@ -62,10 +59,13 @@
62
59
  "devDependencies": {
63
60
  "@types/history": "^4.7.8",
64
61
  "@types/react": "^17.0.0",
62
+ "@types/react-dom": "^17.0.0",
65
63
  "@types/react-router": "^5.1.8",
66
64
  "@types/react-router-dom": "^5.1.6",
67
65
  "react": "^17.0.1",
68
- "react-dom": "^17.0.1"
66
+ "react-dom": "^17.0.1",
67
+ "react-router": "^5.2.0",
68
+ "react-router-dom": "^5.2.0"
69
69
  },
70
70
  "sharedDependencies": [
71
71
  "react",
@@ -78,5 +78,5 @@
78
78
  "@libre/atom",
79
79
  "@dbeining/react-atom"
80
80
  ],
81
- "gitHead": "0727a5c782dd1bbc7ccaa11a036a9f16e616bf10"
81
+ "gitHead": "29ee91f865f9ee42229e58a7804cba6ab5e9145b"
82
82
  }