@fluentui-react-native/framework-base 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +16 -1
- package/CHANGELOG.md +43 -2
- package/README.md +18 -1
- package/babel.config.js +1 -1
- package/jsx-runtime.js +1 -0
- package/lib/component-patterns/directComponent.d.ts +7 -0
- package/lib/component-patterns/directComponent.d.ts.map +1 -0
- package/lib/component-patterns/directComponent.js +8 -0
- package/lib/component-patterns/directComponent.js.map +1 -0
- package/lib/component-patterns/extract.d.ts +22 -0
- package/lib/component-patterns/extract.d.ts.map +1 -0
- package/lib/component-patterns/extract.js +25 -0
- package/lib/component-patterns/extract.js.map +1 -0
- package/lib/component-patterns/phasedComponent.d.ts +18 -0
- package/lib/component-patterns/phasedComponent.d.ts.map +1 -0
- package/lib/component-patterns/phasedComponent.js +51 -0
- package/lib/component-patterns/phasedComponent.js.map +1 -0
- package/lib/component-patterns/render.d.ts +9 -3
- package/lib/component-patterns/render.d.ts.map +1 -1
- package/lib/component-patterns/render.js +39 -32
- package/lib/component-patterns/render.js.map +1 -1
- package/lib/component-patterns/render.types.d.ts +60 -34
- package/lib/component-patterns/render.types.d.ts.map +1 -1
- package/lib/component-patterns/render.types.js +1 -1
- package/lib/component-patterns/stagedComponent.d.ts +3 -8
- package/lib/component-patterns/stagedComponent.d.ts.map +1 -1
- package/lib/component-patterns/stagedComponent.js +10 -27
- package/lib/component-patterns/stagedComponent.js.map +1 -1
- package/lib/component-patterns/withSlots.d.ts +6 -2
- package/lib/component-patterns/withSlots.d.ts.map +1 -1
- package/lib/component-patterns/withSlots.js +3 -3
- package/lib/component-patterns/withSlots.js.map +1 -1
- package/lib/immutable-merge/Merge.d.ts +6 -3
- package/lib/immutable-merge/Merge.js +79 -83
- package/lib/immutable-merge/Merge.js.map +1 -1
- package/lib/immutable-merge/Merge.test.d.ts +1 -1
- package/lib/immutable-merge/Merge.test.js +231 -219
- package/lib/immutable-merge/Merge.test.js.map +1 -1
- package/lib/index.d.ts +33 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +13 -4
- package/lib/index.js.map +1 -1
- package/lib/jsx-namespace.d.ts +65 -0
- package/lib/jsx-namespace.d.ts.map +1 -0
- package/lib/jsx-namespace.js +2 -0
- package/lib/jsx-namespace.js.map +1 -0
- package/lib/jsx-runtime.d.ts +6 -4
- package/lib/jsx-runtime.d.ts.map +1 -1
- package/lib/jsx-runtime.js +9 -7
- package/lib/jsx-runtime.js.map +1 -1
- package/lib/memo-cache/getCacheEntry.d.ts +13 -13
- package/lib/memo-cache/getCacheEntry.js +20 -22
- package/lib/memo-cache/getCacheEntry.js.map +1 -1
- package/lib/memo-cache/getCacheEntry.test.d.ts +1 -1
- package/lib/memo-cache/getCacheEntry.test.js +90 -90
- package/lib/memo-cache/getCacheEntry.test.js.map +1 -1
- package/lib/memo-cache/getMemoCache.d.ts +1 -1
- package/lib/memo-cache/getMemoCache.js +11 -11
- package/lib/memo-cache/getMemoCache.js.map +1 -1
- package/lib/memo-cache/getMemoCache.test.d.ts +1 -1
- package/lib/memo-cache/getMemoCache.test.js +73 -73
- package/lib/memo-cache/getMemoCache.test.js.map +1 -1
- package/lib/memo-cache/memoize.d.ts +1 -1
- package/lib/memo-cache/memoize.js +9 -9
- package/lib/memo-cache/memoize.js.map +1 -1
- package/lib/memo-cache/memoize.test.d.ts +1 -1
- package/lib/memo-cache/memoize.test.js +36 -38
- package/lib/memo-cache/memoize.test.js.map +1 -1
- package/lib/merge-props/index.d.ts +1 -1
- package/lib/merge-props/index.js +1 -1
- package/lib/merge-props/mergeProps.d.ts +1 -1
- package/lib/merge-props/mergeProps.js +4 -4
- package/lib/merge-props/mergeProps.js.map +1 -1
- package/lib/merge-props/mergeStyles.d.ts +33 -4
- package/lib/merge-props/mergeStyles.d.ts.map +1 -1
- package/lib/merge-props/mergeStyles.js +16 -17
- package/lib/merge-props/mergeStyles.js.map +1 -1
- package/lib/merge-props/mergeStyles.test.d.ts +1 -1
- package/lib/merge-props/mergeStyles.test.js +75 -75
- package/lib/merge-props/mergeStyles.test.js.map +1 -1
- package/lib/merge-props/mergeStyles.types.d.ts +4 -4
- package/lib/merge-props/mergeStyles.types.d.ts.map +1 -1
- package/lib/merge-props/mergeStyles.types.js +1 -1
- package/lib/utilities/filterProps.d.ts +3 -0
- package/lib/utilities/filterProps.d.ts.map +1 -0
- package/lib/utilities/filterProps.js +12 -0
- package/lib/utilities/filterProps.js.map +1 -0
- package/lib-commonjs/component-patterns/directComponent.d.ts +7 -0
- package/lib-commonjs/component-patterns/directComponent.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/directComponent.js +11 -0
- package/lib-commonjs/component-patterns/directComponent.js.map +1 -0
- package/lib-commonjs/component-patterns/extract.d.ts +22 -0
- package/lib-commonjs/component-patterns/extract.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/extract.js +30 -0
- package/lib-commonjs/component-patterns/extract.js.map +1 -0
- package/lib-commonjs/component-patterns/phasedComponent.d.ts +18 -0
- package/lib-commonjs/component-patterns/phasedComponent.d.ts.map +1 -0
- package/lib-commonjs/component-patterns/phasedComponent.js +60 -0
- package/lib-commonjs/component-patterns/phasedComponent.js.map +1 -0
- package/lib-commonjs/component-patterns/render.d.ts +9 -3
- package/lib-commonjs/component-patterns/render.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/render.js +101 -39
- package/lib-commonjs/component-patterns/render.js.map +1 -1
- package/lib-commonjs/component-patterns/render.types.d.ts +60 -34
- package/lib-commonjs/component-patterns/render.types.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/render.types.js +3 -3
- package/lib-commonjs/component-patterns/stagedComponent.d.ts +3 -8
- package/lib-commonjs/component-patterns/stagedComponent.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/stagedComponent.js +64 -34
- package/lib-commonjs/component-patterns/stagedComponent.js.map +1 -1
- package/lib-commonjs/component-patterns/withSlots.d.ts +6 -2
- package/lib-commonjs/component-patterns/withSlots.d.ts.map +1 -1
- package/lib-commonjs/component-patterns/withSlots.js +7 -8
- package/lib-commonjs/component-patterns/withSlots.js.map +1 -1
- package/lib-commonjs/immutable-merge/Merge.d.ts +6 -3
- package/lib-commonjs/immutable-merge/Merge.js +85 -90
- package/lib-commonjs/immutable-merge/Merge.js.map +1 -1
- package/lib-commonjs/immutable-merge/Merge.test.d.ts +1 -1
- package/lib-commonjs/immutable-merge/Merge.test.js +234 -222
- package/lib-commonjs/immutable-merge/Merge.test.js.map +1 -1
- package/lib-commonjs/index.d.ts +33 -5
- package/lib-commonjs/index.d.ts.map +1 -1
- package/lib-commonjs/index.js +184 -31
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/jsx-namespace.d.ts +65 -0
- package/lib-commonjs/jsx-namespace.d.ts.map +1 -0
- package/lib-commonjs/jsx-namespace.js +3 -0
- package/lib-commonjs/jsx-namespace.js.map +1 -0
- package/lib-commonjs/jsx-runtime.d.ts +6 -4
- package/lib-commonjs/jsx-runtime.d.ts.map +1 -1
- package/lib-commonjs/jsx-runtime.js +70 -13
- package/lib-commonjs/jsx-runtime.js.map +1 -1
- package/lib-commonjs/memo-cache/getCacheEntry.d.ts +13 -13
- package/lib-commonjs/memo-cache/getCacheEntry.js +23 -26
- package/lib-commonjs/memo-cache/getCacheEntry.js.map +1 -1
- package/lib-commonjs/memo-cache/getCacheEntry.test.d.ts +1 -1
- package/lib-commonjs/memo-cache/getCacheEntry.test.js +93 -93
- package/lib-commonjs/memo-cache/getCacheEntry.test.js.map +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.d.ts +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.js +16 -17
- package/lib-commonjs/memo-cache/getMemoCache.js.map +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.test.d.ts +1 -1
- package/lib-commonjs/memo-cache/getMemoCache.test.js +76 -76
- package/lib-commonjs/memo-cache/getMemoCache.test.js.map +1 -1
- package/lib-commonjs/memo-cache/memoize.d.ts +1 -1
- package/lib-commonjs/memo-cache/memoize.js +13 -14
- package/lib-commonjs/memo-cache/memoize.js.map +1 -1
- package/lib-commonjs/memo-cache/memoize.test.d.ts +1 -1
- package/lib-commonjs/memo-cache/memoize.test.js +39 -41
- package/lib-commonjs/memo-cache/memoize.test.js.map +1 -1
- package/lib-commonjs/merge-props/index.d.ts +1 -1
- package/lib-commonjs/merge-props/index.js +17 -7
- package/lib-commonjs/merge-props/index.js.map +1 -1
- package/lib-commonjs/merge-props/mergeProps.d.ts +1 -1
- package/lib-commonjs/merge-props/mergeProps.js +9 -10
- package/lib-commonjs/merge-props/mergeProps.js.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.d.ts +33 -4
- package/lib-commonjs/merge-props/mergeStyles.d.ts.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.js +23 -25
- package/lib-commonjs/merge-props/mergeStyles.js.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.test.d.ts +1 -1
- package/lib-commonjs/merge-props/mergeStyles.test.js +78 -78
- package/lib-commonjs/merge-props/mergeStyles.test.js.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.types.d.ts +4 -4
- package/lib-commonjs/merge-props/mergeStyles.types.d.ts.map +1 -1
- package/lib-commonjs/merge-props/mergeStyles.types.js +3 -3
- package/lib-commonjs/utilities/filterProps.d.ts +3 -0
- package/lib-commonjs/utilities/filterProps.d.ts.map +1 -0
- package/lib-commonjs/utilities/filterProps.js +15 -0
- package/lib-commonjs/utilities/filterProps.js.map +1 -0
- package/package.json +48 -20
- package/src/component-patterns/README.md +53 -16
- package/src/component-patterns/directComponent.ts +9 -0
- package/src/component-patterns/extract.ts +32 -0
- package/src/component-patterns/phasedComponent.ts +54 -0
- package/src/component-patterns/render.ts +21 -13
- package/src/component-patterns/render.types.ts +55 -30
- package/src/component-patterns/stagedComponent.ts +24 -0
- package/src/immutable-merge/Merge.test.ts +5 -1
- package/src/index.ts +27 -7
- package/src/jsx-namespace.ts +83 -0
- package/src/jsx-runtime.ts +8 -4
- package/src/memo-cache/README.md +1 -1
- package/src/merge-props/mergeStyles.test.ts +3 -2
- package/src/merge-props/mergeStyles.ts +52 -4
- package/src/merge-props/mergeStyles.types.ts +2 -2
- package/src/utilities/filterProps.ts +14 -0
- package/src/component-patterns/stagedComponent.tsx +0 -45
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* This file defines a custom JSX namespace that re-exports React's JSX types, but also allows us to add our own custom behavior to the JSX runtime.
|
|
4
|
+
* The main reason we need this is to support our "direct component" pattern, which allows certain components to bypass React's createElement and
|
|
5
|
+
* return their own React elements directly from the JSX runtime.
|
|
6
|
+
*
|
|
7
|
+
* Exporting this custom namespace is required to make intrinsic attributes like key and ref work correctly with our custom JSX functions. The normal
|
|
8
|
+
* fallback behavior if not defined is to not allow any attributes on intrinsic elements, which breaks a lot of React functionality.
|
|
9
|
+
*
|
|
10
|
+
* The custom behavior is implemented in the jsx and jsxs functions, which first check if the type being rendered is a direct component and if so, call it directly.
|
|
11
|
+
*
|
|
12
|
+
* Thanks to the emotion library's jsx-namespace for providing a reference implementation of how to do this while handling both React 18 and React 19's
|
|
13
|
+
* changes to the JSX types.
|
|
14
|
+
*/
|
|
15
|
+
type IsPreReact19 = 2 extends Parameters<React.FunctionComponent<any>>['length'] ? true : false;
|
|
16
|
+
/**
|
|
17
|
+
* The following types are intrinsic types for React, but handled in a way that allows them to be correctly resolved in both
|
|
18
|
+
* React 18 and React 19.
|
|
19
|
+
*
|
|
20
|
+
* React 18:
|
|
21
|
+
* - JSX.Element, JSX.ElementClass, etc.
|
|
22
|
+
* - no React.JSX namespace
|
|
23
|
+
*
|
|
24
|
+
* React 19:
|
|
25
|
+
* - React.JSX.Element, React.JSX.ElementClass, etc.
|
|
26
|
+
* - no global JSX namespace
|
|
27
|
+
*
|
|
28
|
+
* In both cases, we want to be able to reference these types in our custom JSX namespace, so we conditionally define them based on whether we're in
|
|
29
|
+
* a pre-React 19 environment or not. The @ts-expect-error comments are used because both can't be valid at the same time so there will always be
|
|
30
|
+
* an error.
|
|
31
|
+
*/
|
|
32
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
33
|
+
type ReactJSXElement = true extends IsPreReact19 ? JSX.Element : React.JSX.Element;
|
|
34
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
35
|
+
type ReactJSXElementClass = true extends IsPreReact19 ? JSX.ElementClass : React.JSX.ElementClass;
|
|
36
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
37
|
+
type ReactJSXElementAttributesProperty = true extends IsPreReact19 ? JSX.ElementAttributesProperty : React.JSX.ElementAttributesProperty;
|
|
38
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
39
|
+
type ReactJSXElementChildrenAttribute = true extends IsPreReact19 ? JSX.ElementChildrenAttribute : React.JSX.ElementChildrenAttribute;
|
|
40
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
41
|
+
type ReactJSXLibraryManagedAttributes<C, P> = true extends IsPreReact19
|
|
42
|
+
? JSX.LibraryManagedAttributes<C, P>
|
|
43
|
+
: React.JSX.LibraryManagedAttributes<C, P>;
|
|
44
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
45
|
+
type ReactJSXIntrinsicAttributes = true extends IsPreReact19 ? JSX.IntrinsicAttributes : React.JSX.IntrinsicAttributes;
|
|
46
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
47
|
+
type ReactJSXIntrinsicClassAttributes<T> = true extends IsPreReact19
|
|
48
|
+
? JSX.IntrinsicClassAttributes<T>
|
|
49
|
+
: React.JSX.IntrinsicClassAttributes<T>;
|
|
50
|
+
/** @ts-expect-error references types for both react 18 and react 19, only one can be valid at a time */
|
|
51
|
+
type ReactJSXIntrinsicElements = true extends IsPreReact19 ? JSX.IntrinsicElements : React.JSX.IntrinsicElements;
|
|
52
|
+
type ReactJSXElementType = true extends IsPreReact19 ? string | React.JSXElementConstructor<any> : React.JSX.ElementType;
|
|
53
|
+
export declare namespace FurnJSX {
|
|
54
|
+
type ElementType = ReactJSXElementType;
|
|
55
|
+
interface Element extends ReactJSXElement {}
|
|
56
|
+
interface ElementClass extends ReactJSXElementClass {}
|
|
57
|
+
interface ElementAttributesProperty extends ReactJSXElementAttributesProperty {}
|
|
58
|
+
interface ElementChildrenAttribute extends ReactJSXElementChildrenAttribute {}
|
|
59
|
+
type LibraryManagedAttributes<C, P> = ReactJSXLibraryManagedAttributes<C, P>;
|
|
60
|
+
interface IntrinsicAttributes extends ReactJSXIntrinsicAttributes {}
|
|
61
|
+
interface IntrinsicClassAttributes<T> extends ReactJSXIntrinsicClassAttributes<T> {}
|
|
62
|
+
type IntrinsicElements = ReactJSXIntrinsicElements;
|
|
63
|
+
}
|
|
64
|
+
export {};
|
|
65
|
+
//# sourceMappingURL=jsx-namespace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-namespace.d.ts","sourceRoot":"","sources":["../src/jsx-namespace.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;;;;;;;;;;;GAYG;AAEH,KAAK,YAAY,GAAG,CAAC,SAAS,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,IAAI,GAAG,KAAK,CAAC;AAEhG;;;;;;;;;;;;;;;GAeG;AAEH,wGAAwG;AACxG,KAAK,eAAe,GAAG,IAAI,SAAS,YAAY,GAAG,GAAG,CAAC,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;AAEnF,wGAAwG;AACxG,KAAK,oBAAoB,GAAG,IAAI,SAAS,YAAY,GAAG,GAAG,CAAC,YAAY,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY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B;KAAG;IAE7D,UAAiB,yBAA0B,SAAQ,iCAAiC;KAAG;IAEvF,UAAiB,wBAAyB,SAAQ,gCAAgC;KAAG;IACrF,KAAY,wBAAwB,CAAC,CAAC,EAAE,CAAC,IAAI,gCAAgC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAEpF,UAAiB,mBAAoB,SAAQ,2BAA2B;KAAG;IAE3E,UAAiB,wBAAwB,CAAC,CAAC,CAAE,SAAQ,gCAAgC,CAAC,CAAC,CAAC;KAAG;IAC3F,KAAY,iBAAiB,GAAG,yBAAyB,CAAC;CAC3D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsx-namespace.js","sourceRoot":"","sources":["../src/jsx-namespace.ts"],"names":[],"mappings":""}
|
package/lib/jsx-runtime.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
export
|
|
3
|
-
export declare
|
|
4
|
-
|
|
1
|
+
import * as ReactJSX from 'react/jsx-runtime';
|
|
2
|
+
export type { FurnJSX as JSX } from './jsx-namespace';
|
|
3
|
+
export declare const jsx: typeof ReactJSX.jsx;
|
|
4
|
+
export declare const jsxs: typeof ReactJSX.jsxs;
|
|
5
|
+
export { Fragment } from 'react/jsx-runtime';
|
|
6
|
+
//# sourceMappingURL=jsx-runtime.d.ts.map
|
package/lib/jsx-runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAE9C,YAAY,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAEtD,eAAO,MAAM,GAAG,EAAE,OAAO,QAAQ,CAAC,GAEjC,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,OAAO,QAAQ,CAAC,IAElC,CAAC;AAGF,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
|
package/lib/jsx-runtime.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as ReactJSX from 'react/jsx-runtime';
|
|
2
2
|
import { renderForJsxRuntime } from './component-patterns/render';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
3
|
+
export const jsx = (type, props, key) => {
|
|
4
|
+
return renderForJsxRuntime(type, props, key, ReactJSX.jsx);
|
|
5
|
+
};
|
|
6
|
+
export const jsxs = (type, props, key) => {
|
|
7
|
+
return renderForJsxRuntime(type, props, key, ReactJSX.jsxs);
|
|
8
|
+
};
|
|
9
|
+
// Re-export Fragment for <></> syntax
|
|
10
|
+
export { Fragment } from 'react/jsx-runtime';
|
|
11
|
+
//# sourceMappingURL=jsx-runtime.js.map
|
package/lib/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAGlE,MAAM,CAAC,MAAM,GAAG,GAAwB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAe,EAAE,EAAE,CAAC;IACxE,OAAO,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;AAAA,CAC5D,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAyB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAe,EAAE,EAAE,CAAC;IAC1E,OAAO,mBAAmB,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;AAAA,CAC7D,CAAC;AAEF,sCAAsC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/** signature for the object/function key values, used for memoization */
|
|
2
2
|
export type MemoObjectKey = object | Function;
|
|
3
3
|
export type CacheEntry<T = unknown> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
/** stores the cached value if any */
|
|
5
|
+
value?: T;
|
|
6
|
+
/** entry used for undefined and null values, these both collapse to the same type */
|
|
7
|
+
empty?: CacheEntry<T>;
|
|
8
|
+
/** entry used for the case where the array of args is null or length 0 */
|
|
9
|
+
noargs?: CacheEntry<T>;
|
|
10
|
+
/** all remaining non-object types are keyed as strings for lookups */
|
|
11
|
+
str?: {
|
|
12
|
+
[key: string]: CacheEntry<T>;
|
|
13
|
+
};
|
|
14
|
+
/** object types are keyed in a weak map on object identity */
|
|
15
|
+
obj?: WeakMap<MemoObjectKey, CacheEntry<T>>;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* Given a base entry, either traverse or build the cache tree that matches the provided args
|
|
@@ -21,4 +21,4 @@ export type CacheEntry<T = unknown> = {
|
|
|
21
21
|
* @param args - array of arguments to use to progress deeper into the cache
|
|
22
22
|
*/
|
|
23
23
|
export declare function getCacheEntry(entry: CacheEntry, args: unknown[]): CacheEntry;
|
|
24
|
-
//# sourceMappingURL=getCacheEntry.d.ts.map
|
|
24
|
+
//# sourceMappingURL=getCacheEntry.d.ts.map
|
|
@@ -5,21 +5,21 @@
|
|
|
5
5
|
* @param val - value to use as the key for progressing to the next level of the cache
|
|
6
6
|
*/
|
|
7
7
|
function jumpToCacheEntry(entry, val) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
if (val === undefined || val === null) {
|
|
9
|
+
// undefined or null just routes directly to the empty object. This avoids the issues of string collisions with 'null' or 'undefined'
|
|
10
|
+
// when using the string key map, it also avoids creating the WeakMap (since null is technically typoef object), particularly in cases
|
|
11
|
+
// where null is just being set on non-object types.
|
|
12
|
+
return (entry.empty ??= {});
|
|
13
|
+
}
|
|
14
|
+
if (typeof val === 'object' || typeof val === 'function') {
|
|
15
|
+
// objects and functions will be treated as key values in a WeakMap
|
|
16
|
+
const byObj = (entry.obj ??= new WeakMap());
|
|
17
|
+
return byObj.get(val) || byObj.set(val, {}).get(val);
|
|
18
|
+
}
|
|
19
|
+
// otherwise convert everything to a string and store it in the str object (using it as a map)
|
|
20
|
+
const key = val + '';
|
|
21
|
+
const byString = (entry.str ??= {});
|
|
22
|
+
return (byString[key] ??= {});
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Given a base entry, either traverse or build the cache tree that matches the provided args
|
|
@@ -28,11 +28,9 @@ function jumpToCacheEntry(entry, val) {
|
|
|
28
28
|
* @param args - array of arguments to use to progress deeper into the cache
|
|
29
29
|
*/
|
|
30
30
|
export function getCacheEntry(entry, args) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
? args.reduce((previous, arg) => jumpToCacheEntry(previous, arg), entry)
|
|
36
|
-
: (entry.noargs ??= {});
|
|
31
|
+
// in the case where the args array exists and is > 0 length:
|
|
32
|
+
// - walk the cache from entry, like a linked list, jumping to the next entry by key, building it up as you go
|
|
33
|
+
// - otherwise if there are no args just use the noargs branch
|
|
34
|
+
return args && args.length > 0 ? args.reduce((previous, arg) => jumpToCacheEntry(previous, arg), entry) : (entry.noargs ??= {});
|
|
37
35
|
}
|
|
38
|
-
//# sourceMappingURL=getCacheEntry.js.map
|
|
36
|
+
//# sourceMappingURL=getCacheEntry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCacheEntry.js","sourceRoot":"","sources":["../../src/memo-cache/getCacheEntry.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,KAAiB,EAAE,GAAQ;
|
|
1
|
+
{"version":3,"file":"getCacheEntry.js","sourceRoot":"","sources":["../../src/memo-cache/getCacheEntry.ts"],"names":[],"mappings":"AAqBA;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,KAAiB,EAAE,GAAQ,EAAc;IACjE,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACtC,sIAAsI;QACtI,sIAAsI;QACtI,oDAAoD;QACpD,OAAO,CAAC,KAAK,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;QACzD,mEAAmE;QACnE,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,IAAI,OAAO,EAA6B,CAAC,CAAC;QACvE,OAAO,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvD,CAAC;IACD,8FAA8F;IAC9F,MAAM,GAAG,GAAG,GAAG,GAAG,EAAE,CAAC;IACrB,MAAM,QAAQ,GAAG,CAAC,KAAK,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;IACpC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;AAAA,CAC/B;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAiB,EAAE,IAAe,EAAc;IAC5E,6DAA6D;IAC7D,8GAA8G;IAC9G,8DAA8D;IAC9D,OAAO,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAC5B,CAAC,CAAE,IAAI,CAAC,MAAM,CAAC,CAAC,QAAoB,EAAE,GAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,CAAC,EAAE,KAAK,CAAgB;QAC7G,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,EAAE,CAAC,CAAC;AAAA,CAC3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=getCacheEntry.test.d.ts.map
|
|
2
|
+
//# sourceMappingURL=getCacheEntry.test.d.ts.map
|
|
@@ -1,95 +1,95 @@
|
|
|
1
1
|
import { getCacheEntry } from './getCacheEntry';
|
|
2
2
|
function compareResults(base, args, argsNoMatch) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const e1 = getCacheEntry(base, args);
|
|
4
|
+
expect(getCacheEntry(base, args)).toBe(e1);
|
|
5
|
+
if (argsNoMatch) {
|
|
6
|
+
expect(getCacheEntry(base, argsNoMatch)).not.toBe(e1);
|
|
7
|
+
}
|
|
8
8
|
}
|
|
9
9
|
describe('Memo cache unit tests', () => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
10
|
+
test('undefined args to return noargs', () => {
|
|
11
|
+
const base = {};
|
|
12
|
+
expect(getCacheEntry(base, undefined)).toBe(base.noargs);
|
|
13
|
+
});
|
|
14
|
+
test('empty args array to return noargs entry', () => {
|
|
15
|
+
const base = {};
|
|
16
|
+
expect(getCacheEntry(base, [])).toBe(base.noargs);
|
|
17
|
+
});
|
|
18
|
+
test('undefined goes to empty entry', () => {
|
|
19
|
+
const base = {};
|
|
20
|
+
expect(getCacheEntry(base, [undefined])).toBe(base.empty);
|
|
21
|
+
});
|
|
22
|
+
test('null to go to empty entry', () => {
|
|
23
|
+
const base = {};
|
|
24
|
+
expect(getCacheEntry(base, [null])).toBe(base.empty);
|
|
25
|
+
});
|
|
26
|
+
test('string gets keyed correctly', () => {
|
|
27
|
+
const base = {};
|
|
28
|
+
const key = 'foo';
|
|
29
|
+
expect(getCacheEntry(base, [key])).toBe(base.str[key]);
|
|
30
|
+
});
|
|
31
|
+
test('number gets keyed correctly', () => {
|
|
32
|
+
const base = {};
|
|
33
|
+
const val = 235;
|
|
34
|
+
const key = val + '';
|
|
35
|
+
expect(getCacheEntry(base, [val])).toBe(base.str[key]);
|
|
36
|
+
});
|
|
37
|
+
test('bool gets keyed correctly', () => {
|
|
38
|
+
const base = {};
|
|
39
|
+
const val = true;
|
|
40
|
+
const key = val + '';
|
|
41
|
+
expect(getCacheEntry(base, [val])).toBe(base.str[key]);
|
|
42
|
+
});
|
|
43
|
+
test('false bool gets keyed correctly', () => {
|
|
44
|
+
const base = {};
|
|
45
|
+
const val = false;
|
|
46
|
+
const key = val + '';
|
|
47
|
+
expect(getCacheEntry(base, [val])).toBe(base.str[key]);
|
|
48
|
+
});
|
|
49
|
+
test('object gets keyed correctly', () => {
|
|
50
|
+
const base = {};
|
|
51
|
+
const key = {};
|
|
52
|
+
expect(getCacheEntry(base, [key])).toBe(base.obj.get(key));
|
|
53
|
+
});
|
|
54
|
+
test('function gets keyed correctly', () => {
|
|
55
|
+
const base = {};
|
|
56
|
+
const key = () => {
|
|
57
|
+
return 'hello world';
|
|
58
|
+
};
|
|
59
|
+
expect(getCacheEntry(base, [key])).toBe(base.obj.get(key));
|
|
60
|
+
});
|
|
61
|
+
test('basic string retrieval', () => {
|
|
62
|
+
compareResults({}, ['hello', 'world'], ['hello world']);
|
|
63
|
+
});
|
|
64
|
+
test('mixed keys with strings', () => {
|
|
65
|
+
compareResults({}, ['hello', 1, true, undefined, 'world'], ['hello', 1, true, '', 'world']);
|
|
66
|
+
});
|
|
67
|
+
test('basic object matches', () => {
|
|
68
|
+
const obj = {};
|
|
69
|
+
compareResults({}, [obj]);
|
|
70
|
+
});
|
|
71
|
+
test('mixed object and string matches', () => {
|
|
72
|
+
const obj = {};
|
|
73
|
+
compareResults({}, [obj, 'hello', 1, 'world']);
|
|
74
|
+
});
|
|
75
|
+
test('mixed obj and strings with obj at end', () => {
|
|
76
|
+
const obj = {};
|
|
77
|
+
const obj2 = {};
|
|
78
|
+
compareResults({}, ['hello', 1, 'world', obj], ['hello', 1, 'world', obj2]);
|
|
79
|
+
});
|
|
80
|
+
test('hybrid sets', () => {
|
|
81
|
+
const obj = {};
|
|
82
|
+
const obj2 = {};
|
|
83
|
+
compareResults({}, ['hello', obj, 'world', 1, false, obj2, undefined]);
|
|
84
|
+
});
|
|
85
|
+
test('sub cache on object', () => {
|
|
86
|
+
const obj = {};
|
|
87
|
+
const args1 = ['hello', obj];
|
|
88
|
+
const base = {};
|
|
89
|
+
const subRoot = getCacheEntry(base, args1);
|
|
90
|
+
const args2 = ['world', base];
|
|
91
|
+
const target = getCacheEntry(subRoot, args2);
|
|
92
|
+
expect(getCacheEntry(base, [...args1, ...args2])).toBe(target);
|
|
93
|
+
});
|
|
94
94
|
});
|
|
95
|
-
//# sourceMappingURL=getCacheEntry.test.js.map
|
|
95
|
+
//# sourceMappingURL=getCacheEntry.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getCacheEntry.test.js","sourceRoot":"","sources":["../../src/memo-cache/getCacheEntry.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,SAAS,cAAc,CAAC,IAAe,EAAE,IAAW,EAAE,WAAmB;
|
|
1
|
+
{"version":3,"file":"getCacheEntry.test.js","sourceRoot":"","sources":["../../src/memo-cache/getCacheEntry.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAQhD,SAAS,cAAc,CAAC,IAAe,EAAE,IAAW,EAAE,WAAmB,EAAQ;IAC/E,MAAM,EAAE,GAAG,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACrC,MAA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AAa,CAAC,IAAI,EAAE,CAAC,GAAG,KAAK,EAAE,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAAA,CAChE,CAAC,CAAC;AAAA,CACJ,CAAC,CAAC"}
|
|
@@ -20,4 +20,4 @@ export declare function getMemoCache(globalKey?: object): GetMemoValue;
|
|
|
20
20
|
* to retrieve the same cache from the global call. If not specified the returned cache will be completely isolated.
|
|
21
21
|
*/
|
|
22
22
|
export declare function getTypedMemoCache<T>(globalKey?: object): GetTypedMemoValue<T>;
|
|
23
|
-
//# sourceMappingURL=getMemoCache.d.ts.map
|
|
23
|
+
//# sourceMappingURL=getMemoCache.d.ts.map
|
|
@@ -9,12 +9,12 @@ const _baseEntry = {};
|
|
|
9
9
|
* @param keys - an ordered array of values of any type, used as keys to look up the entry
|
|
10
10
|
*/
|
|
11
11
|
function getMemoValueWorker(entry, factory, keys) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const foundEntry = getCacheEntry(entry, keys);
|
|
13
|
+
// check the key being set, not the value to disambiguate an undefined factory result/value from never having run the factory
|
|
14
|
+
if (!Object.prototype.hasOwnProperty.call(foundEntry, 'value')) {
|
|
15
|
+
foundEntry.value = typeof factory === 'function' ? factory() : factory;
|
|
16
|
+
}
|
|
17
|
+
return [foundEntry.value, (fact, args) => getMemoValueWorker(foundEntry, fact, args)];
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* Get a memo cache instance, this can either be completely self-contained or associated with a global key
|
|
@@ -23,8 +23,8 @@ function getMemoValueWorker(entry, factory, keys) {
|
|
|
23
23
|
* to retrieve the same cache from the global call. If not specified the returned cache will be completely isolated.
|
|
24
24
|
*/
|
|
25
25
|
export function getMemoCache(globalKey) {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const entry = globalKey ? getCacheEntry(_baseEntry, [globalKey]) : {};
|
|
27
|
+
return (fact, args) => getMemoValueWorker(entry, fact, args);
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Get a typed memo cache instance, this can either be completely self-contained or associated with a global key
|
|
@@ -33,7 +33,7 @@ export function getMemoCache(globalKey) {
|
|
|
33
33
|
* to retrieve the same cache from the global call. If not specified the returned cache will be completely isolated.
|
|
34
34
|
*/
|
|
35
35
|
export function getTypedMemoCache(globalKey) {
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const entry = globalKey ? getCacheEntry(_baseEntry, [globalKey]) : {};
|
|
37
|
+
return (fact, args) => getMemoValueWorker(entry, fact, args);
|
|
38
38
|
}
|
|
39
|
-
//# sourceMappingURL=getMemoCache.js.map
|
|
39
|
+
//# sourceMappingURL=getMemoCache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getMemoCache.js","sourceRoot":"","sources":["../../src/memo-cache/getMemoCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAYhD,oEAAoE;AACpE,MAAM,UAAU,GAAe,EAAE,CAAC;AAElC;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAI,KAAiB,EAAE,OAA4B,EAAE,IAAe;
|
|
1
|
+
{"version":3,"file":"getMemoCache.js","sourceRoot":"","sources":["../../src/memo-cache/getMemoCache.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAYhD,oEAAoE;AACpE,MAAM,UAAU,GAAe,EAAE,CAAC;AAElC;;;;;;GAMG;AACH,SAAS,kBAAkB,CAAI,KAAiB,EAAE,OAA4B,EAAE,IAAe,EAAqB;IAClH,MAAM,UAAU,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC9C,6HAA6H;IAC7H,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,EAAE,CAAC;QAC/D,UAA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