@common-stack/client-react 0.1.21 → 0.2.1

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 (159) hide show
  1. package/lib/__tests__/fill-register-test.d.ts +1 -0
  2. package/lib/__tests__/fill-register-test.js +66 -0
  3. package/lib/__tests__/fill-register-test.js.map +1 -0
  4. package/lib/__tests__/helpers/sample-menu.d.ts +79 -0
  5. package/lib/__tests__/helpers/sample-menu.js +78 -0
  6. package/lib/__tests__/helpers/sample-menu.js.map +1 -0
  7. package/lib/__tests__/integrated-routes.test.d.ts +1 -0
  8. package/lib/__tests__/integrated-routes.test.js +83 -0
  9. package/lib/__tests__/integrated-routes.test.js.map +1 -0
  10. package/lib/__tests__/render-routes.test.d.ts +3 -0
  11. package/lib/__tests__/render-routes.test.js +89 -0
  12. package/lib/__tests__/render-routes.test.js.map +1 -0
  13. package/lib/connector/base-connector.d.ts +52 -0
  14. package/lib/connector/base-connector.js +148 -0
  15. package/lib/connector/base-connector.js.map +1 -0
  16. package/lib/connector/connector.d.ts +7 -43
  17. package/lib/connector/connector.js +15 -0
  18. package/lib/connector/connector.js.map +1 -0
  19. package/lib/connector/connector.native.d.ts +7 -0
  20. package/lib/connector/connector.native.js +14 -0
  21. package/lib/connector/connector.native.js.map +1 -0
  22. package/lib/connector/connector.test.d.ts +1 -0
  23. package/lib/connector/connector.test.js +32 -0
  24. package/lib/connector/connector.test.js.map +1 -0
  25. package/lib/connector/index.js +14 -0
  26. package/lib/connector/index.js.map +1 -0
  27. package/lib/index.d.ts +1 -2
  28. package/lib/index.js +9 -2147
  29. package/lib/index.js.map +1 -1
  30. package/lib/index.native.d.ts +9 -0
  31. package/lib/index.native.js +24 -0
  32. package/lib/index.native.js.map +1 -0
  33. package/lib/interfaces/extended-feature.js +3 -0
  34. package/lib/interfaces/extended-feature.js.map +1 -0
  35. package/lib/interfaces/index.js +17 -0
  36. package/lib/interfaces/index.js.map +1 -0
  37. package/lib/interfaces/menu.js +12 -0
  38. package/lib/interfaces/menu.js.map +1 -0
  39. package/lib/interfaces/new-router.d.ts +18 -1
  40. package/lib/interfaces/new-router.js +3 -0
  41. package/lib/interfaces/new-router.js.map +1 -0
  42. package/lib/interfaces/router.js +3 -0
  43. package/lib/interfaces/router.js.map +1 -0
  44. package/lib/inversify/InversifyContext.js +37 -0
  45. package/lib/inversify/InversifyContext.js.map +1 -0
  46. package/lib/inversify/index.js +14 -0
  47. package/lib/inversify/index.js.map +1 -0
  48. package/lib/plugin-area/__tests__/higher-order-component-util.test.d.ts +1 -0
  49. package/lib/plugin-area/__tests__/higher-order-component-util.test.js +60 -0
  50. package/lib/plugin-area/__tests__/higher-order-component-util.test.js.map +1 -0
  51. package/lib/plugin-area/__tests__/plugin-api.test.d.ts +1 -0
  52. package/lib/plugin-area/__tests__/plugin-api.test.js +54 -0
  53. package/lib/plugin-area/__tests__/plugin-api.test.js.map +1 -0
  54. package/lib/plugin-area/{plugin-area.d.ts → base-plugin-area.d.ts} +1 -1
  55. package/lib/plugin-area/base-plugin-area.js +68 -0
  56. package/lib/plugin-area/base-plugin-area.js.map +1 -0
  57. package/lib/plugin-area/higher-order-component-util.js +23 -0
  58. package/lib/plugin-area/higher-order-component-util.js.map +1 -0
  59. package/lib/plugin-area/index.d.ts +2 -2
  60. package/lib/plugin-area/index.js +34 -0
  61. package/lib/plugin-area/index.js.map +1 -0
  62. package/lib/plugin-area/index.native.d.ts +2 -0
  63. package/lib/plugin-area/index.native.js +31 -0
  64. package/lib/plugin-area/index.native.js.map +1 -0
  65. package/lib/plugin-area/plugin-api.js +79 -0
  66. package/lib/plugin-area/plugin-api.js.map +1 -0
  67. package/lib/plugin-area/plugin-context.js +44 -0
  68. package/lib/plugin-area/plugin-context.js.map +1 -0
  69. package/lib/route/__tests__/admin-new-routes.test.d.ts +1 -0
  70. package/lib/route/__tests__/admin-new-routes.test.js +175 -0
  71. package/lib/route/__tests__/admin-new-routes.test.js.map +1 -0
  72. package/lib/route/__tests__/config-routes.test.d.ts +0 -0
  73. package/lib/route/__tests__/config-routes.test.js +326 -0
  74. package/lib/route/__tests__/config-routes.test.js.map +1 -0
  75. package/lib/route/__tests__/getFlatMenus.test.d.ts +1 -0
  76. package/lib/route/__tests__/getFlatMenus.test.js +96 -0
  77. package/lib/route/__tests__/getFlatMenus.test.js.map +1 -0
  78. package/lib/route/__tests__/render-routes-config.test.d.ts +2 -0
  79. package/lib/route/__tests__/render-routes-config.test.js +69 -0
  80. package/lib/route/__tests__/render-routes-config.test.js.map +1 -0
  81. package/lib/route/__tests__/route-type.test.d.ts +1 -0
  82. package/lib/route/__tests__/route-type.test.js +9 -0
  83. package/lib/route/__tests__/route-type.test.js.map +1 -0
  84. package/lib/route/get-routes.d.ts +3 -0
  85. package/lib/route/get-routes.js +86 -0
  86. package/lib/route/get-routes.js.map +1 -0
  87. package/lib/route/get-routes.test.d.ts +1 -0
  88. package/lib/route/get-routes.test.js +170 -0
  89. package/lib/route/get-routes.test.js.map +1 -0
  90. package/lib/route/index.js +14 -0
  91. package/lib/route/index.js.map +1 -0
  92. package/lib/route/index.native.d.ts +1 -0
  93. package/lib/route/index.native.js +14 -0
  94. package/lib/route/index.native.js.map +1 -0
  95. package/lib/route/old/__tests__/config-sidebar-menu.test.d.ts +1 -0
  96. package/lib/route/old/__tests__/config-sidebar-menu.test.js +198 -0
  97. package/lib/route/old/__tests__/config-sidebar-menu.test.js.map +1 -0
  98. package/lib/route/old/get-menus.d.ts +2 -0
  99. package/lib/route/old/get-menus.js +63 -0
  100. package/lib/route/old/get-menus.js.map +1 -0
  101. package/lib/route/old/get-routes-notused.d.ts +11 -0
  102. package/lib/route/old/get-routes-notused.js +61 -0
  103. package/lib/route/old/get-routes-notused.js.map +1 -0
  104. package/lib/route/old/render.d.ts +2 -0
  105. package/lib/route/old/render.js +30 -0
  106. package/lib/route/old/render.js.map +1 -0
  107. package/lib/route/render-routes-test.d.ts +1 -0
  108. package/lib/route/render-routes-test.js +40 -0
  109. package/lib/route/render-routes-test.js.map +1 -0
  110. package/lib/route/render-routes.d.ts +2 -14
  111. package/lib/route/render-routes.js +164 -0
  112. package/lib/route/render-routes.js.map +1 -0
  113. package/lib/route/render-routes.native.d.ts +4 -0
  114. package/lib/route/render-routes.native.js +158 -0
  115. package/lib/route/render-routes.native.js.map +1 -0
  116. package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.d.ts +1 -0
  117. package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js +60 -0
  118. package/lib/route-based-plugin-area/__tests__/higher-order-component-util.test.js.map +1 -0
  119. package/lib/route-based-plugin-area/__tests__/plugin-api.test.d.ts +1 -0
  120. package/lib/route-based-plugin-area/__tests__/plugin-api.test.js +54 -0
  121. package/lib/route-based-plugin-area/__tests__/plugin-api.test.js.map +1 -0
  122. package/lib/route-based-plugin-area/higher-order-component-util.js +23 -0
  123. package/lib/route-based-plugin-area/higher-order-component-util.js.map +1 -0
  124. package/lib/route-based-plugin-area/index.js +15 -0
  125. package/lib/route-based-plugin-area/index.js.map +1 -0
  126. package/lib/route-based-plugin-area/plugin-api.js +79 -0
  127. package/lib/route-based-plugin-area/plugin-api.js.map +1 -0
  128. package/lib/route-based-plugin-area/plugin-context.js +44 -0
  129. package/lib/route-based-plugin-area/plugin-context.js.map +1 -0
  130. package/lib/route-based-plugin-area/route-based-plugin-area.js +68 -0
  131. package/lib/route-based-plugin-area/route-based-plugin-area.js.map +1 -0
  132. package/lib/{router/router.d.ts → router-factory/index.d.ts} +0 -0
  133. package/lib/router-factory/index.js +30 -0
  134. package/lib/router-factory/index.js.map +1 -0
  135. package/lib/router-factory/index.native.d.ts +2 -0
  136. package/lib/router-factory/index.native.js +30 -0
  137. package/lib/router-factory/index.native.js.map +1 -0
  138. package/lib/utils/index.d.ts +2 -1
  139. package/lib/utils/index.js +15 -0
  140. package/lib/utils/index.js.map +1 -0
  141. package/lib/utils/sort-keys.d.ts +1 -0
  142. package/lib/utils/sort-keys.js +73 -0
  143. package/lib/utils/sort-keys.js.map +1 -0
  144. package/lib/utils/sort-keys.test.d.ts +1 -0
  145. package/lib/utils/sort-keys.test.js +30 -0
  146. package/lib/utils/sort-keys.test.js.map +1 -0
  147. package/lib/utils/utils.d.ts +4 -0
  148. package/lib/utils/utils.js +13 -0
  149. package/lib/utils/utils.js.map +1 -0
  150. package/package.json +7 -6
  151. package/lib/plugin-area/browser-plugin-area.d.ts +0 -2
  152. package/lib/router/index.d.ts +0 -1
  153. package/lib/slot-fill/context.d.ts +0 -94
  154. package/lib/slot-fill/fill.d.ts +0 -10
  155. package/lib/slot-fill/index.d.ts +0 -4
  156. package/lib/slot-fill/slot.d.ts +0 -8
  157. package/lib/slot-fill/utils/index.d.ts +0 -1
  158. package/lib/slot-fill/utils/isEmptyElement.d.ts +0 -8
  159. package/lib/utils/route-utils.d.ts +0 -17
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRouteBasePlugins = exports.getRouteBasePlugin = exports.unregisterRouteBasePlugin = exports.registerRouteBasePlugin = void 0;
4
+ const lodash_1 = require("lodash");
5
+ const hooks_1 = require("@wordpress/hooks");
6
+ /**
7
+ * Plugin definitions keyed by plugin name.
8
+ */
9
+ const plugins = {};
10
+ /**
11
+ * Registeres a plugin to the App.
12
+ *
13
+ * @param name A string identifying the plugin. Must be unique across all registered plugins.
14
+ * @param settings The settings for this plugin.
15
+ */
16
+ function registerRouteBasePlugin(name, settings) {
17
+ if (typeof settings !== 'object') {
18
+ console.error('No settings object provided!');
19
+ return null;
20
+ }
21
+ if (typeof name !== 'string') {
22
+ console.error('Plugin names must be strings.');
23
+ return null;
24
+ }
25
+ if (!/^[a-z][a-z0-9-]*$/.test(name)) {
26
+ console.error('Plugin names must include only lowercase alphanumeric characters or dashes, and start with a letter. Example: "my-pluin".');
27
+ return null;
28
+ }
29
+ if (plugins[name]) {
30
+ console.error(`Plugin "${name}" is alread registered.`);
31
+ }
32
+ settings = hooks_1.applyFilters('plugins.registerPlugin', settings, name);
33
+ if (!lodash_1.isFunction(settings.render)) {
34
+ console.error('The "render" property must be specified and must be a valid function.');
35
+ return null;
36
+ }
37
+ plugins[name] = Object.assign({ name, icon: 'admin-plugins' }, settings);
38
+ hooks_1.doAction('plugins.pluginRegistered', settings, name);
39
+ return settings;
40
+ }
41
+ exports.registerRouteBasePlugin = registerRouteBasePlugin;
42
+ /**
43
+ * Unregisteres a plugin by name.
44
+ * @param name Plugin name.
45
+ *
46
+ * @return The previous plugin settings object, if it has been successfully unregistered; otherwise `undefined`.
47
+ */
48
+ function unregisterRouteBasePlugin(name) {
49
+ if (!plugins[name]) {
50
+ console.error('Plugin "' + name + '" is not registered.');
51
+ return;
52
+ }
53
+ const oldPlugin = plugins[name];
54
+ delete plugins[name];
55
+ hooks_1.doAction('plugin.pluginUnregistered', oldPlugin, name);
56
+ return oldPlugin;
57
+ }
58
+ exports.unregisterRouteBasePlugin = unregisterRouteBasePlugin;
59
+ /**
60
+ * Returns a registered plugin settings.
61
+ *
62
+ * @param name Plugin name.
63
+ *
64
+ * @returns Plugin setting.
65
+ */
66
+ function getRouteBasePlugin(name) {
67
+ return plugins[name];
68
+ }
69
+ exports.getRouteBasePlugin = getRouteBasePlugin;
70
+ /**
71
+ * Return all registered plugins.
72
+ *
73
+ * @return Plugin settings.
74
+ */
75
+ function getRouteBasePlugins() {
76
+ return Object.values(plugins);
77
+ }
78
+ exports.getRouteBasePlugins = getRouteBasePlugins;
79
+ //# sourceMappingURL=plugin-api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-api.js","sourceRoot":"","sources":["../../src/route-based-plugin-area/plugin-api.ts"],"names":[],"mappings":";;;AAEA,mCAAoC;AACpC,4CAA0D;AAgB1D;;GAEG;AACH,MAAM,OAAO,GAAyC,EAAE,CAAC;AAEzD;;;;;GAKG;AACH,SAAgB,uBAAuB,CAAC,IAAI,EAAE,QAAQ;IAClD,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC9B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC;KACf;IACD,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QAC1B,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC;KACf;IACD,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QACjC,OAAO,CAAC,KAAK,CACT,2HAA2H,CAC9H,CAAC;QACF,OAAO,IAAI,CAAC;KACf;IACD,IAAI,OAAO,CAAC,IAAI,CAAC,EAAE;QACf,OAAO,CAAC,KAAK,CAAC,WAAW,IAAI,yBAAyB,CAAC,CAAC;KAC3D;IACD,QAAQ,GAAG,oBAAY,CAAC,wBAAwB,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IAElE,IAAI,CAAC,mBAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC9B,OAAO,CAAC,KAAK,CACT,uEAAuE,CAC1E,CAAC;QACF,OAAO,IAAI,CAAC;KACf;IACD,OAAO,CAAC,IAAI,CAAC,mBACT,IAAI,EACJ,IAAI,EAAE,eAAe,IAClB,QAAQ,CACd,CAAC;IAEF,gBAAQ,CAAC,0BAA0B,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;IAErD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAnCD,0DAmCC;AAED;;;;;GAKG;AACH,SAAgB,yBAAyB,CAAC,IAAI;IAC1C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAChB,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,IAAI,GAAG,sBAAsB,CAAC,CAAC;QAC1D,OAAO;KACV;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;IAErB,gBAAQ,CAAC,2BAA2B,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAEvD,OAAO,SAAS,CAAC;AACrB,CAAC;AAXD,8DAWC;AAED;;;;;;GAMG;AACH,SAAgB,kBAAkB,CAAC,IAAI;IACnC,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAFD,gDAEC;AAED;;;;GAIG;AACH,SAAgB,mBAAmB;IAC/B,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAClC,CAAC;AAFD,kDAEC"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.withPluginContext = exports.PluginContextProvider = void 0;
23
+ const React = __importStar(require("react"));
24
+ const higher_order_component_util_1 = require("./higher-order-component-util");
25
+ const { createContext } = React;
26
+ const { Consumer, Provider } = createContext({
27
+ name: null,
28
+ icon: null,
29
+ });
30
+ exports.PluginContextProvider = Provider;
31
+ /**
32
+ * A Higher Order Component used to inject Plugin context to the
33
+ * wrapped component.
34
+ *
35
+ * @param mapContextToProps Function called on every context change, expected to return object of
36
+ * props to merge with the component's own props.
37
+ *
38
+ * @return Enhanced component with injected context as props.
39
+ */
40
+ const withPluginContext = (mapContextToProps) => higher_order_component_util_1.createHigherOrderComponent((OriginalComponent) => {
41
+ return (props) => (React.createElement(Consumer, null, (context) => (React.createElement(OriginalComponent, Object.assign({}, props, mapContextToProps(context, props))))));
42
+ }, 'withPluginContext');
43
+ exports.withPluginContext = withPluginContext;
44
+ //# sourceMappingURL=plugin-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-context.js","sourceRoot":"","sources":["../../src/route-based-plugin-area/plugin-context.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA,6CAA+B;AAC/B,+EAA2E;AAE3E,MAAO,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;AACjC,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,aAAa,CAAC;IACzC,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;CACb,CAAC,CAAC;AAEkB,yCAAqB;AAG1C;;;;;;;;GAQG;AACI,MAAM,iBAAiB,GAAG,CAAC,iBAAiB,EAAE,EAAE,CACnD,wDAA0B,CAAC,CAAC,iBAAiB,EAAE,EAAE;IAC7C,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CACd,oBAAC,QAAQ,QACJ,CAAC,OAAO,EAAE,EAAE,CAAC,CACV,oBAAC,iBAAiB,oBACV,KAAK,EACL,iBAAiB,CAAC,OAAO,EAAE,KAAK,CAAC,EACvC,CACL,CACM,CACd,CAAC;AACN,CAAC,EAAE,mBAAmB,CAAC,CAAC;AAZf,QAAA,iBAAiB,qBAYF"}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.RouteBasedPluginArea = void 0;
23
+ const lodash_1 = require("lodash");
24
+ const React = __importStar(require("react"));
25
+ const hooks_1 = require("@wordpress/hooks");
26
+ const plugin_context_1 = require("./plugin-context");
27
+ const plugin_api_1 = require("./plugin-api");
28
+ /**
29
+ * A component that renders all plugin fills in a hidden div.
30
+ */
31
+ class RouteBasedPluginArea extends React.Component {
32
+ constructor(args) {
33
+ super(args);
34
+ this.setPlugins = this.setPlugins.bind(this);
35
+ this.state = { plugins: [] };
36
+ }
37
+ getCurrentPluginsState() {
38
+ return {
39
+ plugins: lodash_1.map(plugin_api_1.getRouteBasePlugins(), ({ icon, name, render }) => {
40
+ return {
41
+ Plugin: render,
42
+ context: {
43
+ name,
44
+ icon,
45
+ },
46
+ };
47
+ }),
48
+ };
49
+ }
50
+ componentDidMount() {
51
+ hooks_1.addAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered', this.setPlugins);
52
+ hooks_1.addAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered', this.setPlugins);
53
+ this.setPlugins();
54
+ }
55
+ componentWillUnMount() {
56
+ hooks_1.removeAction('plugins.pluginRegistered', 'core/plugins/plugin-area/plugins-registered');
57
+ hooks_1.removeAction('plugins.pluginUnregistered', 'core/plugins/plugin-area/plugins-unregistered');
58
+ }
59
+ setPlugins() {
60
+ this.setState(this.getCurrentPluginsState);
61
+ }
62
+ render() {
63
+ return (React.createElement("div", { style: { display: 'none' } }, lodash_1.map(this.state.plugins, ({ context, Plugin }) => (React.createElement(plugin_context_1.PluginContextProvider, { key: context.name, value: context },
64
+ React.createElement(Plugin, null))))));
65
+ }
66
+ }
67
+ exports.RouteBasedPluginArea = RouteBasedPluginArea;
68
+ //# sourceMappingURL=route-based-plugin-area.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route-based-plugin-area.js","sourceRoot":"","sources":["../../src/route-based-plugin-area/route-based-plugin-area.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA6B;AAC7B,6CAA+B;AAC/B,4CAA2D;AAC3D,qDAAyD;AACzD,6CAAmD;AAEnD;;GAEG;AAEH,MAAa,oBAAqB,SAAQ,KAAK,CAAC,SAAgD;IAE5F,YAAY,IAAI;QACZ,KAAK,CAAC,IAAI,CAAC,CAAC;QACZ,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,KAAK,GAAG,EAAC,OAAO,EAAE,EAAE,EAAC,CAAC;IAC/B,CAAC;IAEM,sBAAsB;QACzB,OAAO;YACH,OAAO,EAAE,YAAG,CAAC,gCAAmB,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC3D,OAAO;oBACH,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE;wBACL,IAAI;wBACJ,IAAI;qBACP;iBACJ,CAAC;YACN,CAAC,CAAC;SACL,CAAC;IACN,CAAC;IAEM,iBAAiB;QACpB,iBAAS,CACL,0BAA0B,EAC1B,6CAA6C,EAC7C,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,iBAAS,CACL,4BAA4B,EAC5B,+CAA+C,EAC/C,IAAI,CAAC,UAAU,CAClB,CAAC;QACF,IAAI,CAAC,UAAU,EAAE,CAAC;IACtB,CAAC;IAEM,oBAAoB;QACvB,oBAAY,CACR,0BAA0B,EAC1B,6CAA6C,CAChD,CAAC;QACF,oBAAY,CACR,4BAA4B,EAC5B,+CAA+C,CAClD,CAAC;IACN,CAAC;IAEM,UAAU;QACb,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IAC/C,CAAC;IAEM,MAAM;QACT,OAAO,CACH,6BAAK,KAAK,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,IAC1B,YAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAC9C,oBAAC,sCAAqB,IAClB,GAAG,EAAE,OAAO,CAAC,IAAI,EACjB,KAAK,EAAE,OAAO;YAEd,oBAAC,MAAM,OAAG,CACU,CAC3B,CAAC,CACA,CACT,CAAC;IACN,CAAC;CACJ;AAjED,oDAiEC"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.FeatureWithRouterFactory = void 0;
23
+ const React = __importStar(require("react"));
24
+ const react_router_1 = require("react-router");
25
+ const connector_1 = require("../connector");
26
+ const routerFactory = (routes) => React.createElement(react_router_1.Switch, null, routes);
27
+ exports.FeatureWithRouterFactory = new connector_1.Feature({
28
+ routerFactory,
29
+ });
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/router-factory/index.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,+CAAsC;AACtC,4CAAuC;AAGvC,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAC,qBAAM,QAAE,MAAM,CAAU,CAAC;AAE/C,QAAA,wBAAwB,GAAG,IAAI,mBAAO,CAAC;IAChD,aAAa;CACC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Feature } from '../connector/connector.native';
2
+ export declare const FeatureWithRouterFactory: Feature;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
11
+ }) : function(o, v) {
12
+ o["default"] = v;
13
+ });
14
+ var __importStar = (this && this.__importStar) || function (mod) {
15
+ if (mod && mod.__esModule) return mod;
16
+ var result = {};
17
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
+ __setModuleDefault(result, mod);
19
+ return result;
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.FeatureWithRouterFactory = void 0;
23
+ const React = __importStar(require("react"));
24
+ const react_router_1 = require("react-router");
25
+ const connector_native_1 = require("../connector/connector.native");
26
+ const routerFactory = (routes) => React.createElement(react_router_1.Switch, null, routes);
27
+ exports.FeatureWithRouterFactory = new connector_native_1.Feature({
28
+ routerFactory,
29
+ });
30
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.native.js","sourceRoot":"","sources":["../../src/router-factory/index.native.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA+B;AAC/B,+CAAsC;AACtC,oEAAwD;AAGxD,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,oBAAC,qBAAM,QAAE,MAAM,CAAU,CAAC;AAE/C,QAAA,wBAAwB,GAAG,IAAI,0BAAO,CAAC;IAChD,aAAa;CACC,CAAC,CAAC"}
@@ -1 +1,2 @@
1
- export * from './route-utils';
1
+ export * from './sort-keys';
2
+ export * from './utils';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./sort-keys"), exports);
14
+ __exportStar(require("./utils"), exports);
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0CAAwB"}
@@ -0,0 +1 @@
1
+ export declare function sortKeys(routeData: any): any;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortKeys = void 0;
4
+ const defaultSortKeys = require('sort-keys');
5
+ function sortKeys(routeData) {
6
+ return defaultSortKeys(routeData, { compare });
7
+ }
8
+ exports.sortKeys = sortKeys;
9
+ const compare = ((a, b) => {
10
+ const aStr = String(a).toLowerCase();
11
+ const bStr = String(b).toLowerCase();
12
+ // Alphanumeric elements always come before non-alphanumeric elements
13
+ const aIsAlphanumeric = notStartWithColon(aStr);
14
+ const bIsAlphanumeric = notStartWithColon(bStr);
15
+ if (aIsAlphanumeric + bIsAlphanumeric !== -2) {
16
+ if (aIsAlphanumeric * bIsAlphanumeric > 0) {
17
+ if (aIsAlphanumeric === bIsAlphanumeric) {
18
+ return aStr.localeCompare(bStr);
19
+ }
20
+ return aIsAlphanumeric - bIsAlphanumeric;
21
+ }
22
+ if (aIsAlphanumeric > 0) {
23
+ return -1;
24
+ }
25
+ else if (bIsAlphanumeric > 0) {
26
+ return 1;
27
+ }
28
+ }
29
+ // Numerical elements always come before alphabetic elements
30
+ const aNum = Number(a);
31
+ const bNum = Number(b);
32
+ // If both are numerical, sort in the usual fashion (smaller goes first)
33
+ if (aNum && bNum) {
34
+ return aNum - bNum;
35
+ // If a is numerical but b isn't, put a first.
36
+ }
37
+ else if (aNum) {
38
+ return -1;
39
+ // If b is numerical but a isn't, put b first.
40
+ }
41
+ else if (bNum) {
42
+ return 1;
43
+ }
44
+ // In all other cases, default to usual sort order.
45
+ return aStr.localeCompare(bStr);
46
+ });
47
+ function notStartWithColon(str) {
48
+ const match = (str.match(/^[\/, *, :]{1,}/) || [-1])[0];
49
+ if (match === -1) {
50
+ return -1;
51
+ }
52
+ var i = match.length;
53
+ let count = 0;
54
+ while (i--) {
55
+ const char = match[i];
56
+ if (char === '/') {
57
+ if (str === '/') { // if it is root only we put at the last
58
+ count = count + 6;
59
+ }
60
+ else {
61
+ count = count + 3;
62
+ }
63
+ }
64
+ else if (char === ':') {
65
+ count = count + 1;
66
+ }
67
+ else if (char === '*') {
68
+ count = count + 2;
69
+ }
70
+ }
71
+ return count;
72
+ }
73
+ //# sourceMappingURL=sort-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-keys.js","sourceRoot":"","sources":["../../src/utils/sort-keys.ts"],"names":[],"mappings":";;;AAAA,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AAG7C,SAAgB,QAAQ,CAAC,SAAS;IAChC,OAAO,eAAe,CAAC,SAAS,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;AAChD,CAAC;AAFD,4BAEC;AAGD,MAAM,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;IACxB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACrC,qEAAqE;IACrE,MAAM,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChD,MAAM,eAAe,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAChD,IAAI,eAAe,GAAG,eAAe,KAAK,CAAC,CAAC,EAAE;QAC5C,IAAI,eAAe,GAAG,eAAe,GAAG,CAAC,EAAE;YACzC,IAAI,eAAe,KAAK,eAAe,EAAE;gBACvC,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;aACjC;YACD,OAAO,eAAe,GAAG,eAAe,CAAC;SAC1C;QACD,IAAI,eAAe,GAAG,CAAC,EAAE;YACvB,OAAO,CAAC,CAAC,CAAC;SACX;aAAM,IAAI,eAAe,GAAG,CAAC,EAAE;YAC9B,OAAO,CAAC,CAAC;SACV;KACF;IAED,4DAA4D;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACvB,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACvB,wEAAwE;IACxE,IAAI,IAAI,IAAI,IAAI,EAAE;QAChB,OAAO,IAAI,GAAG,IAAI,CAAC;QACnB,8CAA8C;KAC/C;SAAM,IAAI,IAAI,EAAE;QACf,OAAO,CAAC,CAAC,CAAC;QACV,8CAA8C;KAC/C;SAAM,IAAI,IAAI,EAAE;QACf,OAAO,CAAC,CAAC;KACV;IAED,mDAAmD;IACnD,OAAO,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC,CAAC,CAAC;AAEH,SAAS,iBAAiB,CAAC,GAAG;IAC5B,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD,IAAI,KAAK,KAAK,CAAC,CAAC,EAAE;QAChB,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IACrB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,CAAC,EAAE,EAAE;QACV,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,IAAI,KAAK,GAAG,EAAE;YAChB,IAAI,GAAG,KAAK,GAAG,EAAE,EAAE,wCAAwC;gBACzD,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;aACnB;iBAAM;gBACL,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;aACnB;SACF;aAAM,IAAI,IAAI,KAAK,GAAG,EAAE;YACvB,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;SACnB;aAAM,IAAI,IAAI,KAAK,GAAG,EAAE;YACvB,KAAK,GAAG,KAAK,GAAG,CAAC,CAAC;SACnB;KACF;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sort_keys_1 = require("./sort-keys");
4
+ function MyComponent(props) {
5
+ return {};
6
+ }
7
+ describe('utility with basic routes', () => {
8
+ const routerConfig = {
9
+ ["//menu"]: { exact: true, component: MyComponent },
10
+ ["/login"]: { exact: true, component: MyComponent },
11
+ ["/callback"]: { exact: true, component: MyComponent },
12
+ ["/:orgName/usermenu/logout"]: { exact: true, component: MyComponent },
13
+ ["/"]: { exact: false, component: MyComponent },
14
+ ["/:orgName/usermenu/profile"]: { exact: true, component: MyComponent },
15
+ ["/authenticate-popup"]: { exact: true, component: MyComponent },
16
+ ["/reset-password"]: { exact: true, component: MyComponent },
17
+ ["/:orgName/usermenu/account/"]: { exact: false, component: MyComponent },
18
+ ["/o/orgname2"]: { exact: false, component: MyComponent },
19
+ ["/o/:orgName/account/line/"]: { exact: false, component: MyComponent },
20
+ ["/o/:orgName/account/line2/"]: { exact: false, component: MyComponent },
21
+ ["/o/orgname"]: { exact: false, component: MyComponent },
22
+ };
23
+ it('sort will have `root` at the top', () => {
24
+ const sortedRoutes = sort_keys_1.sortKeys(routerConfig);
25
+ const keys = Object.keys(sortedRoutes)[0];
26
+ expect(keys).toEqual('/');
27
+ expect(keys).toMatchSnapshot();
28
+ });
29
+ });
30
+ //# sourceMappingURL=sort-keys.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sort-keys.test.js","sourceRoot":"","sources":["../../src/utils/sort-keys.test.ts"],"names":[],"mappings":";;AAAA,2CAAuC;AAEvC,SAAS,WAAW,CAAC,KAAK;IACtB,OAAO,EAAE,CAAC;AACd,CAAC;AACD,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IAGvC,MAAM,YAAY,GAAG;QACjB,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;QACnD,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;QACnD,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;QACtD,CAAC,2BAA2B,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;QACtE,CAAC,GAAG,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE;QAC/C,CAAC,4BAA4B,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;QACvE,CAAC,qBAAqB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;QAChE,CAAC,iBAAiB,CAAC,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE;QAC5D,CAAC,6BAA6B,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE;QACzE,CAAC,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE;QACzD,CAAC,2BAA2B,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE;QACvE,CAAC,4BAA4B,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE;QACxE,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE;KAC3D,CAAC;IAEF,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QACxC,MAAM,YAAY,GAAG,oBAAQ,CAAC,YAAY,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;QACzB,MAAM,CAAC,IAAI,CAAC,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC,CAAC,CAAA;AAEN,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const formatSlash: (route: any) => {
2
+ path: any;
3
+ _pathPrefix: any;
4
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatSlash = void 0;
4
+ const startWithMoreThanOneSlash = /^(\/)\1+/; // for exame `//abc, ///abc, ...`
5
+ const formatSlash = (route) => {
6
+ // replaced `//` with `/` in the routes.
7
+ return {
8
+ path: route.replace(startWithMoreThanOneSlash, '/'),
9
+ _pathPrefix: (route.match(/^\/(\/{1,})/) || ['', ''])[1],
10
+ };
11
+ };
12
+ exports.formatSlash = formatSlash;
13
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":";;;AAEA,MAAM,yBAAyB,GAAG,UAAU,CAAC,CAAC,iCAAiC;AACxE,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,EAAE;IACnC,wCAAwC;IACxC,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,yBAAyB,EAAE,GAAG,CAAC;QACnD,WAAW,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;KACzD,CAAA;AACH,CAAC,CAAA;AANY,QAAA,WAAW,eAMvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/client-react",
3
- "version": "0.1.21",
3
+ "version": "0.2.1",
4
4
  "description": "browser plugin for git",
5
5
  "homepage": "https://github.com/cdmbase/fullstack-pro#readme",
6
6
  "bugs": {
@@ -13,11 +13,12 @@
13
13
  "license": "MIT",
14
14
  "author": "CDMBase LLC",
15
15
  "main": "lib/index.js",
16
+ "react-native": "lib/index.native.js",
16
17
  "typings": "lib/index.d.ts",
17
18
  "scripts": {
18
19
  "build": "npm run build:clean && npm run build:lib",
19
20
  "build:clean": "rimraf lib",
20
- "build:lib": "webpack",
21
+ "build:lib": "tsc",
21
22
  "build:lib:watch": "npm run build:lib -- --watch",
22
23
  "jest": "./node_modules/.bin/jest",
23
24
  "prepublish": "npm run build",
@@ -40,14 +41,14 @@
40
41
  "src"
41
42
  ],
42
43
  "testEnvironment": "node",
43
- "testRegex": "/__tests__/.*test*\\.(ts|tsx|js)$",
44
+ "testRegex": ".*test*\\.(ts|tsx|js)$",
44
45
  "transform": {
45
46
  "\\.(ts|tsx)$": "<rootDir>/../../node_modules/ts-jest/preprocessor.js"
46
47
  }
47
48
  },
48
49
  "dependencies": {
49
- "@common-stack/client-core": "^0.1.21",
50
- "@common-stack/core": "^0.1.21",
50
+ "@common-stack/client-core": "^0.2.1",
51
+ "@common-stack/core": "^0.2.1",
51
52
  "@wordpress/hooks": "^2.10.0",
52
53
  "browser-bunyan": "^1.6.3",
53
54
  "history-with-query": "^4.10.4",
@@ -66,7 +67,7 @@
66
67
  "publishConfig": {
67
68
  "access": "public"
68
69
  },
69
- "gitHead": "c3e769cce851a170b380a58a894ed6f312fed8a0",
70
+ "gitHead": "8cc362c6c7307e7ea43a9563ccdcb938c93c6008",
70
71
  "typescript": {
71
72
  "definition": "lib/index.d.ts"
72
73
  }
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const BrowserPluginArea: () => JSX.Element;
@@ -1 +0,0 @@
1
- export * from './router';
@@ -1,94 +0,0 @@
1
- import * as React from 'react';
2
- export interface IFillProps {
3
- name: Name;
4
- [key: string]: any;
5
- }
6
- export interface IFill extends React.Component<IFillProps> {
7
- occurrence: number;
8
- children: React.ReactNode;
9
- }
10
- export declare type Name = string | Symbol;
11
- export interface ISlotProps {
12
- /**
13
- * The name of the component. Use a symbol if you want to be 100% sure the Slot
14
- * will only be filled by a component you create
15
- */
16
- name: Name;
17
- /**
18
- * Props to be applied to the child Element of every fill which has the same name.
19
- *
20
- * If the value is a function, it must have the following signature:
21
- * (target: Fill, fills: Fill[]) => void;
22
- *
23
- * This allows you to access props on the fill which invoked the function
24
- * by using target.props.something()
25
- */
26
- fillProps?: {
27
- [key: string]: any;
28
- };
29
- /**
30
- * A an optional function which gets all of the current fills for this slot
31
- * Allows sorting, or filtering before rendering. An example use-case could
32
- * be to only show a limited amount of fills.
33
- *
34
- * By default Slot injects an unstyled `<div>` element. If you want greater
35
- * control over presentation use this function.
36
- *
37
- * @example
38
- * <Slot name="My.Slot">
39
- * {(items) => <Component>{items}</Component>}
40
- * </Slot>
41
- */
42
- children?: (fills: IFill[]) => JSX.Element;
43
- bubblesVirtually?: boolean;
44
- /**
45
- * `Slot` with `bubblesVirtually` set to true also accept an optional `className` to
46
- * add to the slot container.
47
- *
48
- * @type {string}
49
- * @memberof ISlotProps
50
- */
51
- className?: string;
52
- }
53
- export interface ISlot extends React.Component<ISlotProps> {
54
- node: Element;
55
- }
56
- export interface IContext extends IProviderState {
57
- }
58
- declare const Consumer: React.Consumer<IContext>;
59
- export interface IProviderState {
60
- registerFill: (a: Name, b: any) => void;
61
- unregisterFill: (a: Name, b: any) => void;
62
- unregisterSlot: (a: Name, b?: any) => void;
63
- registerSlot: (a: Name, b?: any) => void;
64
- getSlot: (a: Name) => ISlot;
65
- getFills: (a: Name, b?: any) => IFill[] | [];
66
- subscribe: (listener: any) => void;
67
- }
68
- declare class SlotFillProvider extends React.Component<{}, {}> {
69
- private slots;
70
- private fills;
71
- private listeners;
72
- private contextValue;
73
- constructor(props: any);
74
- registerSlot(name: any, slot: any): void;
75
- registerFill(name: any, instance: any): void;
76
- unregisterSlot(name: any, instance: any): void;
77
- unregisterFill(name: any, instance: IFill): void;
78
- getSlot(name: any): ISlot;
79
- getFills(name: any, slotInstance: any): IFill[];
80
- private resetFillOccurrence;
81
- private forceUpdateSlot;
82
- private triggerListeners;
83
- subscribe(listener: any): () => void;
84
- render(): JSX.Element;
85
- }
86
- /**
87
- * React hook returning the active slot given a name.
88
- *
89
- * @param {string} name Slot name.
90
- * @return {Object} Slot object.
91
- */
92
- export declare const useSlot: (name: any) => ISlot;
93
- export default SlotFillProvider;
94
- export { Consumer };
@@ -1,10 +0,0 @@
1
- import * as React from 'react';
2
- import { IFillProps, IContext } from './context';
3
- export declare namespace IFillComponent {
4
- interface Props extends IFillProps, Partial<IContext> {
5
- }
6
- }
7
- declare type IFillComponentProps<T = IFillProps> = T;
8
- declare type IFillComponent<T = IFillProps> = React.FC<IFillComponentProps<T>>;
9
- declare const Fill: IFillComponent;
10
- export { Fill };
@@ -1,4 +0,0 @@
1
- import { Slot } from './slot';
2
- import { Fill } from './fill';
3
- import SlotFillProvider from './context';
4
- export { Slot, Fill, SlotFillProvider };
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- import { ISlotProps, IContext } from './context';
3
- export declare namespace ISlotComponent {
4
- interface Props extends Partial<IContext>, ISlotProps {
5
- }
6
- }
7
- declare const Slot: React.SFC<ISlotProps>;
8
- export { Slot };
@@ -1 +0,0 @@
1
- export * from './isEmptyElement';
@@ -1,8 +0,0 @@
1
- import * as React from 'react';
2
- /**
3
- * Checks if the provided element to check.
4
- *
5
- * @param element React Component to check.
6
- * @returns True when an element is considered empty.
7
- */
8
- export declare const isEmptyElement: (element: React.ComponentElement<any, any> | any) => boolean;