@cleanweb/oore 2.0.0-alpha.21 → 2.0.0-alpha.23

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 (93) hide show
  1. package/build/_cjs/base/index.d.ts +3 -3
  2. package/build/_cjs/base/index.js +3 -3
  3. package/build/_cjs/base/state/class-types.d.ts +2 -2
  4. package/build/_cjs/base/state/class.d.ts +1 -1
  5. package/build/_cjs/base/state/hook-types.d.ts +1 -1
  6. package/build/_cjs/base/state/hooks.d.ts +1 -1
  7. package/build/_cjs/base/state/hooks.js +1 -1
  8. package/build/_cjs/base/state/index.d.ts +5 -5
  9. package/build/_cjs/base/state/index.js +3 -3
  10. package/build/_cjs/classy/class/index.d.ts +3 -3
  11. package/build/_cjs/classy/class/index.js +3 -3
  12. package/build/_cjs/classy/class/types/extractor.d.ts +1 -1
  13. package/build/_cjs/classy/index.d.ts +3 -3
  14. package/build/_cjs/classy/index.js +3 -3
  15. package/build/_cjs/classy/instance/index.d.ts +3 -3
  16. package/build/_cjs/classy/instance/index.js +3 -3
  17. package/build/_cjs/classy/instance/mount-callbacks.d.ts +1 -1
  18. package/build/_cjs/classy/instance/mount-callbacks.js +1 -1
  19. package/build/_cjs/classy/instance/types/hook.d.ts +1 -1
  20. package/build/_cjs/classy/logic/index.d.ts +2 -2
  21. package/build/_cjs/classy/logic/index.js +1 -1
  22. package/build/_cjs/classy/logic/types/hook.d.ts +1 -1
  23. package/build/_cjs/docs-src/api/base-classes.d.ts +3 -3
  24. package/build/_cjs/docs-src/api/base-classes.js +3 -3
  25. package/build/_cjs/docs-src/api/index.d.ts +8 -8
  26. package/build/_cjs/docs-src/api/index.js +8 -8
  27. package/build/_cjs/docs-src/api/references.d.ts +5 -5
  28. package/build/_cjs/docs-src/api/references.js +5 -5
  29. package/build/_cjs/helpers/index.d.ts +4 -4
  30. package/build/_cjs/helpers/index.js +4 -4
  31. package/build/_cjs/helpers/rerender.js +1 -1
  32. package/build/_cjs/helpers/use-component/index.d.ts +1 -1
  33. package/build/_cjs/index.d.ts +3 -3
  34. package/build/_cjs/index.js +3 -3
  35. package/build/_cjs/slots/hook.d.ts +2 -2
  36. package/build/_cjs/slots/hook.js +1 -1
  37. package/build/_cjs/slots/index.d.ts +1 -1
  38. package/build/_cjs/slots/index.js +1 -1
  39. package/build/base/index.d.ts +3 -3
  40. package/build/base/index.js +3 -19
  41. package/build/base/merged-state.js +4 -8
  42. package/build/base/methods.js +5 -9
  43. package/build/base/state/class-types.d.ts +2 -2
  44. package/build/base/state/class-types.js +1 -2
  45. package/build/base/state/class.d.ts +1 -1
  46. package/build/base/state/class.js +5 -9
  47. package/build/base/state/hook-types.d.ts +1 -1
  48. package/build/base/state/hook-types.js +1 -2
  49. package/build/base/state/hooks.d.ts +1 -1
  50. package/build/base/state/hooks.js +7 -11
  51. package/build/base/state/index.d.ts +5 -5
  52. package/build/base/state/index.js +3 -31
  53. package/build/classy/class/index.d.ts +3 -3
  54. package/build/classy/class/index.js +16 -20
  55. package/build/classy/class/types/extractor.d.ts +1 -1
  56. package/build/classy/class/types/extractor.js +1 -2
  57. package/build/classy/class/utils/function-name.js +1 -5
  58. package/build/classy/index.d.ts +3 -3
  59. package/build/classy/index.js +3 -19
  60. package/build/classy/instance/index.d.ts +3 -3
  61. package/build/classy/instance/index.js +11 -16
  62. package/build/classy/instance/mount-callbacks.d.ts +1 -1
  63. package/build/classy/instance/mount-callbacks.js +5 -9
  64. package/build/classy/instance/types/hook.d.ts +1 -1
  65. package/build/classy/instance/types/hook.js +1 -2
  66. package/build/classy/logic/index.d.ts +2 -2
  67. package/build/classy/logic/index.js +7 -12
  68. package/build/classy/logic/types/hook.d.ts +1 -1
  69. package/build/classy/logic/types/hook.js +1 -2
  70. package/build/docs-src/api/base-classes.d.ts +3 -3
  71. package/build/docs-src/api/base-classes.js +3 -9
  72. package/build/docs-src/api/index.d.ts +8 -8
  73. package/build/docs-src/api/index.js +8 -39
  74. package/build/docs-src/api/references.d.ts +5 -5
  75. package/build/docs-src/api/references.js +5 -31
  76. package/build/helpers/errors.js +1 -5
  77. package/build/helpers/index.d.ts +4 -4
  78. package/build/helpers/index.js +5 -23
  79. package/build/helpers/mount-state.js +4 -8
  80. package/build/helpers/rerender.js +7 -11
  81. package/build/helpers/type-guards.js +1 -5
  82. package/build/helpers/use-component/index.d.ts +1 -1
  83. package/build/helpers/use-component/index.js +3 -7
  84. package/build/helpers/use-component/types.js +1 -2
  85. package/build/index.d.ts +3 -3
  86. package/build/index.js +3 -19
  87. package/build/slots/hook.d.ts +2 -2
  88. package/build/slots/hook.js +15 -45
  89. package/build/slots/index.d.ts +1 -1
  90. package/build/slots/index.js +1 -17
  91. package/build/slots/types.js +1 -2
  92. package/build/tsconfig.json +6 -2
  93. package/package.json +1 -1
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.throwDevError = void 0;
4
1
  /**
5
2
  * Throw an error with the provided message
6
3
  * only when `NODE_ENV` is *not* 'production'.
@@ -10,7 +7,7 @@ exports.throwDevError = void 0;
10
7
  * Useful for enforcing certain conditions in development
11
8
  * while failing more gracefully in production.
12
9
  */
13
- const throwDevError = (message) => {
10
+ export const throwDevError = (message) => {
14
11
  if (process.env.NODE_ENV === 'production') {
15
12
  console.warn(message);
16
13
  }
@@ -18,4 +15,3 @@ const throwDevError = (message) => {
18
15
  throw new Error(message);
19
16
  }
20
17
  };
21
- exports.throwDevError = throwDevError;
@@ -2,10 +2,10 @@
2
2
  * <!-- @ mergeModuleWith API -->
3
3
  * @module Helpers
4
4
  */
5
- export * from './mount-state';
6
- export * from './rerender';
7
- export * from './use-component';
8
- export * from './type-guards';
5
+ export * from './mount-state.js';
6
+ export * from './rerender.js';
7
+ export * from './use-component/index.js';
8
+ export * from './type-guards.js';
9
9
  /**
10
10
  * An empty function.
11
11
  * It returns (void) without performing any operations.
@@ -1,31 +1,13 @@
1
- "use strict";
2
1
  /**
3
2
  * <!-- @ mergeModuleWith API -->
4
3
  * @module Helpers
5
4
  */
6
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
- if (k2 === undefined) k2 = k;
8
- var desc = Object.getOwnPropertyDescriptor(m, k);
9
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
- desc = { enumerable: true, get: function() { return m[k]; } };
11
- }
12
- Object.defineProperty(o, k2, desc);
13
- }) : (function(o, m, k, k2) {
14
- if (k2 === undefined) k2 = k;
15
- o[k2] = m[k];
16
- }));
17
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
18
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.noOp = void 0;
22
- __exportStar(require("./mount-state"), exports);
23
- __exportStar(require("./rerender"), exports);
24
- __exportStar(require("./use-component"), exports);
25
- __exportStar(require("./type-guards"), exports);
5
+ export * from './mount-state.js';
6
+ export * from './rerender.js';
7
+ export * from './use-component/index.js';
8
+ export * from './type-guards.js';
26
9
  /**
27
10
  * An empty function.
28
11
  * It returns (void) without performing any operations.
29
12
  */
30
- const noOp = () => { };
31
- exports.noOp = noOp;
13
+ export const noOp = () => { };
@@ -1,20 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useMountState = void 0;
4
- const react_1 = require("react");
1
+ import { useEffect, useRef } from 'react';
5
2
  /**
6
3
  * Returns a value that is false before the component has been mounted,
7
4
  * then true during all subsequent rerenders.
8
5
  */
9
- const useMountState = () => {
6
+ export const useMountState = () => {
10
7
  /**
11
8
  * This must not be a state value. It should not be the cause of a rerender.
12
9
  * It merely provides information about the render count,
13
10
  * without influencing that count itself.
14
11
  * So `mounted` should never be created with `useState`.
15
12
  */
16
- const mounted = (0, react_1.useRef)(false);
17
- (0, react_1.useEffect)(() => {
13
+ const mounted = useRef(false);
14
+ useEffect(() => {
18
15
  mounted.current = true;
19
16
  return () => {
20
17
  mounted.current = false;
@@ -22,4 +19,3 @@ const useMountState = () => {
22
19
  }, []);
23
20
  return () => mounted.current;
24
21
  };
25
- exports.useMountState = useMountState;
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useRerender = void 0;
4
- const react_1 = require("react");
5
- const mount_state_1 = require("../helpers/mount-state");
1
+ import { useCallback, useRef, useState } from 'react';
2
+ import { useMountState } from '../helpers/mount-state.js';
6
3
  ;
7
4
  /**
8
5
  * Returns a function that can be called to manually trigger
9
6
  * a rerender of your component.
10
7
  */
11
- const useRerender = () => {
12
- const isMounted = (0, mount_state_1.useMountState)();
13
- const renderCount = (0, react_1.useRef)(0);
14
- const [, forceRerender] = (0, react_1.useState)(renderCount.current);
8
+ export const useRerender = () => {
9
+ const isMounted = useMountState();
10
+ const renderCount = useRef(0);
11
+ const [, forceRerender] = useState(renderCount.current);
15
12
  renderCount.current++;
16
- const rerender = (0, react_1.useCallback)(() => {
13
+ const rerender = useCallback(() => {
17
14
  let resolve;
18
15
  const promise = new Promise((_r) => resolve = _r);
19
16
  const execute = () => {
@@ -39,4 +36,3 @@ const useRerender = () => {
39
36
  refresher.currentCount = renderCount.current;
40
37
  return refresher;
41
38
  };
42
- exports.useRerender = useRerender;
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.canIndex = void 0;
4
- const canIndex = (key, targetObject) => {
1
+ export const canIndex = (key, targetObject) => {
5
2
  const test = typeof key === 'number' ? `${key}` : key;
6
3
  return Reflect.ownKeys(targetObject).includes(test);
7
4
  };
8
- exports.canIndex = canIndex;
@@ -1,4 +1,4 @@
1
- import type { ClassComponentHookWrapper } from './types';
1
+ import type { ClassComponentHookWrapper } from './types.js';
2
2
  /**
3
3
  * A component you can use to consume React hooks
4
4
  * in a {@link Component | React.Component} class.
@@ -1,17 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Use = void 0;
4
- const react_1 = require("react");
1
+ import { useEffect } from 'react';
5
2
  /**
6
3
  * A component you can use to consume React hooks
7
4
  * in a {@link Component | React.Component} class.
8
5
  */
9
- const Use = (params) => {
6
+ export const Use = (params) => {
10
7
  const { hook: useGenericHook, argumentsList, onUpdate } = params;
11
8
  const output = useGenericHook(...argumentsList);
12
- (0, react_1.useEffect)(() => {
9
+ useEffect(() => {
13
10
  onUpdate(output);
14
11
  }, [output]);
15
12
  return null;
16
13
  };
17
- exports.Use = Use;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/build/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './classy';
2
- export * from './base';
3
- export * from './helpers';
1
+ export * from './classy/index.js';
2
+ export * from './base/index.js';
3
+ export * from './helpers/index.js';
package/build/index.js CHANGED
@@ -1,19 +1,3 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./classy"), exports);
18
- __exportStar(require("./base"), exports);
19
- __exportStar(require("./helpers"), exports);
1
+ export * from './classy/index.js';
2
+ export * from './base/index.js';
3
+ export * from './helpers/index.js';
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement, ReactNode, ReactPortal } from 'react';
2
- import type { IUseSlots, PotentialSlotComponent } from './types';
2
+ import type { IUseSlots, PotentialSlotComponent } from './types.js';
3
3
  export declare const isElementChild: (child: ReactNode) => child is ReactElement<any, any>;
4
4
  interface IGetSlotName {
5
5
  (TargetComponent: PotentialSlotComponent, child?: ReactElement): string | undefined;
@@ -17,4 +17,4 @@ export declare const isPortalChild: (child: ReactNode) => child is ReactPortal;
17
17
  * @see {@link SlotComponent} for more on how to use the returned slot nodes.
18
18
  */
19
19
  export declare const useSlots: IUseSlots;
20
- export type { SlottedComponent, TSlotsRecord, SlotComponent, PotentialSlotComponent, } from './types';
20
+ export type { SlottedComponent, TSlotsRecord, SlotComponent, PotentialSlotComponent, } from './types.js';
@@ -1,39 +1,12 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.useSlots = exports.isPortalChild = exports.getComponentSlotName = exports.isElementChild = void 0;
27
- const errors_1 = require("../helpers/errors");
28
- const react_1 = __importStar(require("react"));
29
- const isElementChild = (child) => {
1
+ import { throwDevError } from '../helpers/errors.js';
2
+ import React, { useMemo } from 'react';
3
+ export const isElementChild = (child) => {
30
4
  if (child && typeof child === 'object' && 'type' in child) {
31
5
  return true;
32
6
  }
33
7
  return false;
34
8
  };
35
- exports.isElementChild = isElementChild;
36
- const getComponentSlotName = (TargetComponent, child) => {
9
+ export const getComponentSlotName = (TargetComponent, child) => {
37
10
  if (child) {
38
11
  const keyTypes = ['string', 'number', 'symbol'];
39
12
  const slotName = child.props['data-slot-name'];
@@ -52,13 +25,11 @@ const getComponentSlotName = (TargetComponent, child) => {
52
25
  }
53
26
  return undefined;
54
27
  };
55
- exports.getComponentSlotName = getComponentSlotName;
56
- const isPortalChild = (child) => {
28
+ export const isPortalChild = (child) => {
57
29
  return (!!child
58
30
  && typeof child === 'object'
59
31
  && 'children' in child);
60
32
  };
61
- exports.isPortalChild = isPortalChild;
62
33
  /**
63
34
  * Groups `children` prop into predefined slots.
64
35
  *
@@ -69,14 +40,14 @@ exports.isPortalChild = isPortalChild;
69
40
  *
70
41
  * @see {@link SlotComponent} for more on how to use the returned slot nodes.
71
42
  */
72
- const useSlots = (children, Caller) => {
73
- const slotsAliasLookup = (0, react_1.useMemo)(() => {
43
+ export const useSlots = (children, Caller) => {
44
+ const slotsAliasLookup = useMemo(() => {
74
45
  const entries = Object.entries(Caller.Slots);
75
46
  const aliasLookup = {};
76
47
  entries.forEach(([alias, RegisteredSlotComponent]) => {
77
- const slotName = (0, exports.getComponentSlotName)(RegisteredSlotComponent);
48
+ const slotName = getComponentSlotName(RegisteredSlotComponent);
78
49
  if (!slotName) {
79
- (0, errors_1.throwDevError)(`A registered slot component did not have a slot name. All components registered as slots must either be a string tag-name or a React component with either "slotName" or "displayName". The affected component was: ${RegisteredSlotComponent}`);
50
+ throwDevError(`A registered slot component did not have a slot name. All components registered as slots must either be a string tag-name or a React component with either "slotName" or "displayName". The affected component was: ${RegisteredSlotComponent}`);
80
51
  return;
81
52
  }
82
53
  aliasLookup[slotName] = alias;
@@ -84,7 +55,7 @@ const useSlots = (children, Caller) => {
84
55
  return aliasLookup;
85
56
  }, [Caller.Slots]);
86
57
  // @todo Expose original source order of `children` with respect to slot aliases.
87
- const result = (0, react_1.useMemo)(() => {
58
+ const result = useMemo(() => {
88
59
  var _a;
89
60
  const slotNodes = {};
90
61
  const unmatchedChildren = [];
@@ -92,27 +63,27 @@ const useSlots = (children, Caller) => {
92
63
  const requiredSlotAliases = [
93
64
  ...((_a = Caller.requiredSlotAliases) !== null && _a !== void 0 ? _a : [])
94
65
  ];
95
- react_1.default.Children.forEach(children, (_child) => {
66
+ React.Children.forEach(children, (_child) => {
96
67
  var _a;
97
68
  const child = _child;
98
69
  if (!child) {
99
70
  invalidChildren.push(child);
100
71
  return;
101
72
  }
102
- if (!react_1.default.isValidElement(child)) {
73
+ if (!React.isValidElement(child)) {
103
74
  console.warn(`Invalid node found in JSX children while parsing slots. Got: "${child}".`);
104
75
  invalidChildren.push(child);
105
76
  return;
106
77
  }
107
78
  ;
108
79
  // @todo Check for fragment
109
- if (!(0, exports.isElementChild)(child)) {
80
+ if (!isElementChild(child)) {
110
81
  unmatchedChildren.push(child);
111
82
  return;
112
83
  }
113
84
  const slotAlias = (() => {
114
85
  var _a;
115
- const slotName = (0, exports.getComponentSlotName)(child.type, child);
86
+ const slotName = getComponentSlotName(child.type, child);
116
87
  return slotName ? (_a = slotsAliasLookup[slotName]) !== null && _a !== void 0 ? _a : null : null;
117
88
  })();
118
89
  if (slotAlias) {
@@ -133,11 +104,10 @@ const useSlots = (children, Caller) => {
133
104
  });
134
105
  requiredSlotAliases.forEach((slotAlias) => {
135
106
  if (!slotNodes[slotAlias]) {
136
- (0, errors_1.throwDevError)(`Missing required slot "${String(slotAlias)}".`);
107
+ throwDevError(`Missing required slot "${String(slotAlias)}".`);
137
108
  }
138
109
  });
139
110
  return [slotNodes, unmatchedChildren, invalidChildren];
140
111
  }, [children]);
141
112
  return result;
142
113
  };
143
- exports.useSlots = useSlots;
@@ -1 +1 @@
1
- export * from './hook';
1
+ export * from './hook.js';
@@ -1,17 +1 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./hook"), exports);
1
+ export * from './hook.js';
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -23,8 +23,8 @@
23
23
  "forceConsistentCasingInFileNames": true,
24
24
  "incremental": false,
25
25
  "esModuleInterop": true,
26
- "module": "nodenext",
27
- "moduleResolution": "nodenext",
26
+ "module": "esnext",
27
+ "moduleResolution": "bundler",
28
28
  "resolveJsonModule": true,
29
29
  "isolatedModules": true,
30
30
  "jsx": "react-jsx",
@@ -35,6 +35,10 @@
35
35
  "strictBindCallApply": true,
36
36
  "exactOptionalPropertyTypes": true,
37
37
  },
38
+ "tsc-alias": {
39
+ "resolveFullPaths": true,
40
+ "resolveFullExtension": ".js"
41
+ },
38
42
  "include": [
39
43
  "./globals.d.ts",
40
44
  "**/*.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cleanweb/oore",
3
- "version": "2.0.0-alpha.21",
3
+ "version": "2.0.0-alpha.23",
4
4
  "description": "A library of helpers for writing cleaner React function components with object-oriented patterns.",
5
5
  "engines": {
6
6
  "node": ">=22"