@studiometa/js-toolkit 3.7.0 → 3.8.1-beta.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/Base/index.d.ts +1 -1
- package/Base/index.js +4 -1
- package/Base/index.js.map +2 -2
- package/decorators/index.d.ts +15 -15
- package/decorators/index.js +50 -15
- package/decorators/index.js.map +2 -2
- package/decorators/withScrolledInView/index.d.ts +2 -2
- package/decorators/withScrolledInView/index.js +6 -2
- package/decorators/withScrolledInView/index.js.map +2 -2
- package/helpers/index.d.ts +13 -12
- package/helpers/index.js +28 -13
- package/helpers/index.js.map +2 -2
- package/helpers/registerComponent.d.ts +17 -3
- package/helpers/registerComponent.js +22 -3
- package/helpers/registerComponent.js.map +2 -2
- package/helpers/registerComponents.d.ts +22 -0
- package/helpers/registerComponents.js +21 -0
- package/helpers/registerComponents.js.map +7 -0
- package/index.d.ts +5 -5
- package/index.js +113 -6
- package/index.js.map +2 -2
- package/package.json +1 -1
- package/services/index.d.ts +9 -9
- package/services/index.js +52 -9
- package/services/index.js.map +2 -2
- package/utils/css/index.d.ts +1 -1
- package/utils/css/index.js +4 -1
- package/utils/css/index.js.map +2 -2
- package/utils/dom/index.d.ts +2 -2
- package/utils/dom/index.js +7 -2
- package/utils/dom/index.js.map +2 -2
- package/utils/index.d.ts +16 -16
- package/utils/index.js +249 -17
- package/utils/index.js.map +2 -2
- package/utils/math/index.d.ts +2 -2
- package/utils/math/index.js +49 -2
- package/utils/math/index.js.map +2 -2
- package/utils/storage.d.ts +1 -1
- package/utils/storage.js +36 -1
- package/utils/storage.js.map +2 -2
- package/utils/string/index.d.ts +13 -13
- package/utils/string/index.js +33 -13
- package/utils/string/index.js.map +2 -2
package/Base/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { Base, type BaseAsyncConstructor, type BaseChildren, type BaseConfig, type BaseConfigComponents, type BaseConstructor, type BaseEl, type BaseOptions, type BaseProps, type BaseRefs, type Managers, } from './Base.js';
|
|
2
2
|
export { getInstances } from './utils.js';
|
package/Base/index.js
CHANGED
package/Base/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/Base/index.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["export {\n Base,\n type BaseAsyncConstructor,\n type BaseChildren,\n type BaseConfig,\n type BaseConfigComponents,\n type BaseConstructor,\n type BaseEl,\n type BaseOptions,\n type BaseProps,\n type BaseRefs,\n type Managers,\n} from './Base.js';\nexport { getInstances } from './utils.js';\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,OAWK;AACP,SAAS,oBAAoB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/decorators/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
13
|
-
export
|
|
14
|
-
export
|
|
15
|
-
export
|
|
1
|
+
export { withBreakpointManager } from './withBreakpointManager.js';
|
|
2
|
+
export { withBreakpointObserver, type WithBreakpointObserverInterface, type WithBreakpointObserverProps, } from './withBreakpointObserver.js';
|
|
3
|
+
export { withDrag, type DragDecoratorOptions, type WithDragInterface } from './withDrag.js';
|
|
4
|
+
export { withExtraConfig } from './withExtraConfig.js';
|
|
5
|
+
export { withFreezedOptions, type WithFreezedOptionsInterface } from './withFreezedOptions.js';
|
|
6
|
+
export { withIntersectionObserver, type WithIntersectionObserverInterface, type WithIntersectionObserverProps, } from './withIntersectionObserver.js';
|
|
7
|
+
export { withMountOnMediaQuery, type withMountOnMediaQueryInterface, type withMountOnMediaQueryProps, } from './withMountOnMediaQuery.js';
|
|
8
|
+
export { withMountWhenInView, type WithMountWhenInViewInterface, type WithMountWhenInViewProps, } from './withMountWhenInView.js';
|
|
9
|
+
export { withMountWhenPrefersMotion } from './withMountWhenPrefersMotion.js';
|
|
10
|
+
export { withMutation, type MutationDecoratorOptions, type WithMutationInterface, } from './withMutation.js';
|
|
11
|
+
export { withName } from './withName.js';
|
|
12
|
+
export { withRelativePointer, type RelativePointerDecoratorOptions, type RelativePointerInterface, } from './withRelativePointer.js';
|
|
13
|
+
export { withResponsiveOptions } from './withResponsiveOptions.js';
|
|
14
|
+
export { withScrolledInView, type NormalizedOffset, type OffsetValue, type ScrollInViewProps, type WithScrolledInViewInterface, type WithScrolledInViewOptions, type WithScrolledInViewProps, } from './withScrolledInView/index.js';
|
|
15
|
+
export { getScopedGroups, withGroup, type WithGroupInterface, type WithGroupOptions, type WithGroupProps, } from './withGroup.js';
|
package/decorators/index.js
CHANGED
|
@@ -1,16 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { withBreakpointManager } from "./withBreakpointManager.js";
|
|
2
|
+
import {
|
|
3
|
+
withBreakpointObserver
|
|
4
|
+
} from "./withBreakpointObserver.js";
|
|
5
|
+
import { withDrag } from "./withDrag.js";
|
|
6
|
+
import { withExtraConfig } from "./withExtraConfig.js";
|
|
7
|
+
import { withFreezedOptions } from "./withFreezedOptions.js";
|
|
8
|
+
import {
|
|
9
|
+
withIntersectionObserver
|
|
10
|
+
} from "./withIntersectionObserver.js";
|
|
11
|
+
import {
|
|
12
|
+
withMountOnMediaQuery
|
|
13
|
+
} from "./withMountOnMediaQuery.js";
|
|
14
|
+
import {
|
|
15
|
+
withMountWhenInView
|
|
16
|
+
} from "./withMountWhenInView.js";
|
|
17
|
+
import { withMountWhenPrefersMotion } from "./withMountWhenPrefersMotion.js";
|
|
18
|
+
import {
|
|
19
|
+
withMutation
|
|
20
|
+
} from "./withMutation.js";
|
|
21
|
+
import { withName } from "./withName.js";
|
|
22
|
+
import {
|
|
23
|
+
withRelativePointer
|
|
24
|
+
} from "./withRelativePointer.js";
|
|
25
|
+
import { withResponsiveOptions } from "./withResponsiveOptions.js";
|
|
26
|
+
import {
|
|
27
|
+
withScrolledInView
|
|
28
|
+
} from "./withScrolledInView/index.js";
|
|
29
|
+
import {
|
|
30
|
+
getScopedGroups,
|
|
31
|
+
withGroup
|
|
32
|
+
} from "./withGroup.js";
|
|
33
|
+
export {
|
|
34
|
+
getScopedGroups,
|
|
35
|
+
withBreakpointManager,
|
|
36
|
+
withBreakpointObserver,
|
|
37
|
+
withDrag,
|
|
38
|
+
withExtraConfig,
|
|
39
|
+
withFreezedOptions,
|
|
40
|
+
withGroup,
|
|
41
|
+
withIntersectionObserver,
|
|
42
|
+
withMountOnMediaQuery,
|
|
43
|
+
withMountWhenInView,
|
|
44
|
+
withMountWhenPrefersMotion,
|
|
45
|
+
withMutation,
|
|
46
|
+
withName,
|
|
47
|
+
withRelativePointer,
|
|
48
|
+
withResponsiveOptions,
|
|
49
|
+
withScrolledInView
|
|
50
|
+
};
|
|
16
51
|
//# sourceMappingURL=index.js.map
|
package/decorators/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/decorators/index.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["export { withBreakpointManager } from './withBreakpointManager.js';\nexport {\n withBreakpointObserver,\n type WithBreakpointObserverInterface,\n type WithBreakpointObserverProps,\n} from './withBreakpointObserver.js';\nexport { withDrag, type DragDecoratorOptions, type WithDragInterface } from './withDrag.js';\nexport { withExtraConfig } from './withExtraConfig.js';\nexport { withFreezedOptions, type WithFreezedOptionsInterface } from './withFreezedOptions.js';\nexport {\n withIntersectionObserver,\n type WithIntersectionObserverInterface,\n type WithIntersectionObserverProps,\n} from './withIntersectionObserver.js';\nexport {\n withMountOnMediaQuery,\n type withMountOnMediaQueryInterface,\n type withMountOnMediaQueryProps,\n} from './withMountOnMediaQuery.js';\nexport {\n withMountWhenInView,\n type WithMountWhenInViewInterface,\n type WithMountWhenInViewProps,\n} from './withMountWhenInView.js';\nexport { withMountWhenPrefersMotion } from './withMountWhenPrefersMotion.js';\nexport {\n withMutation,\n type MutationDecoratorOptions,\n type WithMutationInterface,\n} from './withMutation.js';\nexport { withName } from './withName.js';\nexport {\n withRelativePointer,\n type RelativePointerDecoratorOptions,\n type RelativePointerInterface,\n} from './withRelativePointer.js';\nexport { withResponsiveOptions } from './withResponsiveOptions.js';\nexport {\n withScrolledInView,\n type NormalizedOffset,\n type OffsetValue,\n type ScrollInViewProps,\n type WithScrolledInViewInterface,\n type WithScrolledInViewOptions,\n type WithScrolledInViewProps,\n} from './withScrolledInView/index.js';\nexport {\n getScopedGroups,\n withGroup,\n type WithGroupInterface,\n type WithGroupOptions,\n type WithGroupProps,\n} from './withGroup.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,OAGK;AACP,SAAS,gBAAmE;AAC5E,SAAS,uBAAuB;AAChC,SAAS,0BAA4D;AACrE;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,OAGK;AACP;AAAA,EACE;AAAA,OAGK;AACP,SAAS,kCAAkC;AAC3C;AAAA,EACE;AAAA,OAGK;AACP,SAAS,gBAAgB;AACzB;AAAA,EACE;AAAA,OAGK;AACP,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAIK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
1
|
+
export { withScrolledInView, type ScrollInViewProps, type WithScrolledInViewInterface, type WithScrolledInViewOptions, type WithScrolledInViewProps, } from './withScrolledInView.js';
|
|
2
|
+
export { type NormalizedOffset, type OffsetValue } from './types.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/decorators/withScrolledInView/index.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["export {\n withScrolledInView,\n type ScrollInViewProps,\n type WithScrolledInViewInterface,\n type WithScrolledInViewOptions,\n type WithScrolledInViewProps,\n} from './withScrolledInView.js';\nexport { type NormalizedOffset, type OffsetValue } from './types.js';\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,OAKK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/helpers/index.d.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export
|
|
12
|
-
export
|
|
1
|
+
export { createApp, type CreateAppOptions } from './createApp.js';
|
|
2
|
+
export { defineFeatures } from './defineFeatures.js';
|
|
3
|
+
export { getClosestParent } from './getClosestParent.js';
|
|
4
|
+
export { getDirectChildren, isDirectChild } from './getDirectChildren.js';
|
|
5
|
+
export { getInstanceFromElement } from './getInstanceFromElement.js';
|
|
6
|
+
export { importOnInteraction } from './importOnInteraction.js';
|
|
7
|
+
export { importOnMediaQuery } from './importOnMediaQuery.js';
|
|
8
|
+
export { importWhenIdle } from './importWhenIdle.js';
|
|
9
|
+
export { importWhenPrefersMotion } from './importWhenPrefersMotion.js';
|
|
10
|
+
export { importWhenVisible } from './importWhenVisible.js';
|
|
11
|
+
export { logTree } from './logTree.js';
|
|
12
|
+
export { registerComponent } from './registerComponent.js';
|
|
13
|
+
export { registerComponents } from './registerComponents.js';
|
|
13
14
|
export { type QueryOptions, queryComponent, queryComponentAll, closestComponent, } from './queryComponent.js';
|
package/helpers/index.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { createApp } from "./createApp.js";
|
|
2
|
+
import { defineFeatures } from "./defineFeatures.js";
|
|
3
|
+
import { getClosestParent } from "./getClosestParent.js";
|
|
4
|
+
import { getDirectChildren, isDirectChild } from "./getDirectChildren.js";
|
|
5
|
+
import { getInstanceFromElement } from "./getInstanceFromElement.js";
|
|
6
|
+
import { importOnInteraction } from "./importOnInteraction.js";
|
|
7
|
+
import { importOnMediaQuery } from "./importOnMediaQuery.js";
|
|
8
|
+
import { importWhenIdle } from "./importWhenIdle.js";
|
|
9
|
+
import { importWhenPrefersMotion } from "./importWhenPrefersMotion.js";
|
|
10
|
+
import { importWhenVisible } from "./importWhenVisible.js";
|
|
11
|
+
import { logTree } from "./logTree.js";
|
|
12
|
+
import { registerComponent } from "./registerComponent.js";
|
|
13
|
+
import { registerComponents } from "./registerComponents.js";
|
|
13
14
|
import {
|
|
14
15
|
queryComponent,
|
|
15
16
|
queryComponentAll,
|
|
@@ -17,7 +18,21 @@ import {
|
|
|
17
18
|
} from "./queryComponent.js";
|
|
18
19
|
export {
|
|
19
20
|
closestComponent,
|
|
21
|
+
createApp,
|
|
22
|
+
defineFeatures,
|
|
23
|
+
getClosestParent,
|
|
24
|
+
getDirectChildren,
|
|
25
|
+
getInstanceFromElement,
|
|
26
|
+
importOnInteraction,
|
|
27
|
+
importOnMediaQuery,
|
|
28
|
+
importWhenIdle,
|
|
29
|
+
importWhenPrefersMotion,
|
|
30
|
+
importWhenVisible,
|
|
31
|
+
isDirectChild,
|
|
32
|
+
logTree,
|
|
20
33
|
queryComponent,
|
|
21
|
-
queryComponentAll
|
|
34
|
+
queryComponentAll,
|
|
35
|
+
registerComponent,
|
|
36
|
+
registerComponents
|
|
22
37
|
};
|
|
23
38
|
//# sourceMappingURL=index.js.map
|
package/helpers/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/helpers/index.ts"],
|
|
4
|
-
"sourcesContent": ["export
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["export { createApp, type CreateAppOptions } from './createApp.js';\nexport { defineFeatures } from './defineFeatures.js';\nexport { getClosestParent } from './getClosestParent.js';\nexport { getDirectChildren, isDirectChild } from './getDirectChildren.js';\nexport { getInstanceFromElement } from './getInstanceFromElement.js';\nexport { importOnInteraction } from './importOnInteraction.js';\nexport { importOnMediaQuery } from './importOnMediaQuery.js';\nexport { importWhenIdle } from './importWhenIdle.js';\nexport { importWhenPrefersMotion } from './importWhenPrefersMotion.js';\nexport { importWhenVisible } from './importWhenVisible.js';\nexport { logTree } from './logTree.js';\nexport { registerComponent } from './registerComponent.js';\nexport { registerComponents } from './registerComponents.js';\nexport {\n type QueryOptions,\n queryComponent,\n queryComponentAll,\n closestComponent,\n} from './queryComponent.js';\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAwC;AACjD,SAAS,sBAAsB;AAC/B,SAAS,wBAAwB;AACjC,SAAS,mBAAmB,qBAAqB;AACjD,SAAS,8BAA8B;AACvC,SAAS,2BAA2B;AACpC,SAAS,0BAA0B;AACnC,SAAS,sBAAsB;AAC/B,SAAS,+BAA+B;AACxC,SAAS,yBAAyB;AAClC,SAAS,eAAe;AACxB,SAAS,yBAAyB;AAClC,SAAS,0BAA0B;AACnC;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { BaseConstructor } from '../Base/Base.js';
|
|
2
2
|
/**
|
|
3
|
-
* Register globally and mount a given component
|
|
3
|
+
* Register globally and mount a given component.
|
|
4
|
+
*
|
|
5
|
+
* The component can be provided in any of the forms also accepted for child
|
|
6
|
+
* components in `config.components`:
|
|
7
|
+
* - a `Base` constructor;
|
|
8
|
+
* - a promise resolving to a constructor or a module namespace (`import(...)`);
|
|
9
|
+
* - a factory function returning such a promise (`() => import(...)`).
|
|
10
|
+
*
|
|
11
|
+
* Instances are mounted independently: an element that fails to mount is
|
|
12
|
+
* skipped (and logged in development) instead of failing the whole call, so
|
|
13
|
+
* the resolved array contains every instance that mounted successfully.
|
|
4
14
|
*
|
|
5
15
|
* @link https://js-toolkit.studiometa.dev/api/helpers/registerComponent.html
|
|
6
|
-
* @param ctor The component constructor or a
|
|
16
|
+
* @param ctor The component constructor, or a way to resolve it.
|
|
7
17
|
* @param nameOrSelector The name or selector to used for this component.
|
|
8
18
|
* @return A promise resolving to an array of mounted component instances.
|
|
9
19
|
*/
|
|
10
|
-
export declare function registerComponent<T extends BaseConstructor = BaseConstructor>(ctor: T | Promise<T
|
|
20
|
+
export declare function registerComponent<T extends BaseConstructor = BaseConstructor>(ctor: T | Promise<T | {
|
|
21
|
+
default: T;
|
|
22
|
+
}> | (() => Promise<T | {
|
|
23
|
+
default: T;
|
|
24
|
+
}>), nameOrSelector?: string): Promise<Awaited<InstanceType<T>>[]>;
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
+
import { isDev, isFunction } from "../utils/index.js";
|
|
1
2
|
async function registerComponent(ctor, nameOrSelector) {
|
|
3
|
+
if (isFunction(ctor) && !("$isBase" in ctor)) {
|
|
4
|
+
ctor = ctor(void 0);
|
|
5
|
+
}
|
|
6
|
+
let Ctor;
|
|
2
7
|
if (ctor instanceof Promise) {
|
|
3
|
-
|
|
8
|
+
const module = await ctor;
|
|
9
|
+
Ctor = "$isBase" in module ? module : module.default;
|
|
10
|
+
} else {
|
|
11
|
+
Ctor = ctor;
|
|
4
12
|
}
|
|
5
|
-
const
|
|
6
|
-
return
|
|
13
|
+
const results = await Promise.allSettled(Ctor.$register(nameOrSelector));
|
|
14
|
+
return results.flatMap((result) => {
|
|
15
|
+
if (result.status === "fulfilled") {
|
|
16
|
+
return [result.value];
|
|
17
|
+
}
|
|
18
|
+
if (isDev) {
|
|
19
|
+
console.error(
|
|
20
|
+
"[registerComponent] An instance failed to mount and was skipped.",
|
|
21
|
+
result.reason
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return [];
|
|
25
|
+
});
|
|
7
26
|
}
|
|
8
27
|
export {
|
|
9
28
|
registerComponent
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/helpers/registerComponent.ts"],
|
|
4
|
-
"sourcesContent": ["import { BaseConstructor } from '../Base/Base.js';\n\n/**\n * Register globally and mount a given component
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { BaseConstructor, BaseAsyncConstructor } from '../Base/Base.js';\nimport { isDev, isFunction } from '../utils/index.js';\n\n/**\n * Register globally and mount a given component.\n *\n * The component can be provided in any of the forms also accepted for child\n * components in `config.components`:\n * - a `Base` constructor;\n * - a promise resolving to a constructor or a module namespace (`import(...)`);\n * - a factory function returning such a promise (`() => import(...)`).\n *\n * Instances are mounted independently: an element that fails to mount is\n * skipped (and logged in development) instead of failing the whole call, so\n * the resolved array contains every instance that mounted successfully.\n *\n * @link https://js-toolkit.studiometa.dev/api/helpers/registerComponent.html\n * @param ctor The component constructor, or a way to resolve it.\n * @param nameOrSelector The name or selector to used for this component.\n * @return A promise resolving to an array of mounted component instances.\n */\nexport async function registerComponent<T extends BaseConstructor = BaseConstructor>(\n ctor: T | Promise<T | { default: T }> | (() => Promise<T | { default: T }>),\n nameOrSelector?: string,\n) {\n // Resolve factory functions such as `() => import('./Component.js')`, mirroring\n // how lazy child components are declared. A `Base` constructor is a function too,\n // so it is distinguished by its `$isBase` marker.\n if (isFunction(ctor) && !('$isBase' in ctor)) {\n ctor = (ctor as BaseAsyncConstructor)(undefined as never) as Promise<T | { default: T }>;\n }\n\n let Ctor: T;\n if (ctor instanceof Promise) {\n const module = await ctor;\n // A resolved `Base` constructor is used as-is; only a module namespace is\n // unwrapped. Keying on `$isBase` (like the async child resolution) avoids\n // mistaking a user-defined static `default` member for a module namespace.\n Ctor = ('$isBase' in module ? module : (module as { default: T }).default) as T;\n } else {\n Ctor = ctor;\n }\n\n const results = await Promise.allSettled(Ctor.$register(nameOrSelector));\n\n return results.flatMap((result) => {\n if (result.status === 'fulfilled') {\n return [result.value];\n }\n\n if (isDev) {\n console.error(\n '[registerComponent] An instance failed to mount and was skipped.',\n result.reason,\n );\n }\n\n return [];\n });\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,OAAO,kBAAkB;AAoBlC,eAAsB,kBACpB,MACA,gBACA;AAIA,MAAI,WAAW,IAAI,KAAK,EAAE,aAAa,OAAO;AAC5C,WAAQ,KAA8B,MAAkB;AAAA,EAC1D;AAEA,MAAI;AACJ,MAAI,gBAAgB,SAAS;AAC3B,UAAM,SAAS,MAAM;AAIrB,WAAQ,aAAa,SAAS,SAAU,OAA0B;AAAA,EACpE,OAAO;AACL,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,MAAM,QAAQ,WAAW,KAAK,UAAU,cAAc,CAAC;AAEvE,SAAO,QAAQ,QAAQ,CAAC,WAAW;AACjC,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO,CAAC,OAAO,KAAK;AAAA,IACtB;AAEA,QAAI,OAAO;AACT,cAAQ;AAAA,QACN;AAAA,QACA,OAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO,CAAC;AAAA,EACV,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { BaseConstructor } from '../Base/Base.js';
|
|
2
|
+
/**
|
|
3
|
+
* Register globally and mount multiple components at once.
|
|
4
|
+
*
|
|
5
|
+
* Each component accepts the same forms as {@link registerComponent}: a `Base`
|
|
6
|
+
* constructor, a promise resolving to a constructor or module namespace, or a
|
|
7
|
+
* factory function returning such a promise.
|
|
8
|
+
*
|
|
9
|
+
* Components are registered independently: a single failure (e.g. a rejected
|
|
10
|
+
* dynamic import) does not prevent the others from being registered, and the
|
|
11
|
+
* returned array contains every instance that mounted successfully. Failures
|
|
12
|
+
* are logged in development.
|
|
13
|
+
*
|
|
14
|
+
* @link https://js-toolkit.studiometa.dev/api/helpers/registerComponents.html
|
|
15
|
+
* @param ctors The components, or ways to resolve them.
|
|
16
|
+
* @return A promise resolving to a flat array of mounted component instances.
|
|
17
|
+
*/
|
|
18
|
+
export declare function registerComponents<T extends BaseConstructor = BaseConstructor>(...ctors: (T | Promise<T | {
|
|
19
|
+
default: T;
|
|
20
|
+
}> | (() => Promise<T | {
|
|
21
|
+
default: T;
|
|
22
|
+
}>))[]): Promise<Awaited<InstanceType<T>>[]>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isDev } from "../utils/index.js";
|
|
2
|
+
import { registerComponent } from "./registerComponent.js";
|
|
3
|
+
async function registerComponents(...ctors) {
|
|
4
|
+
const results = await Promise.allSettled(ctors.map((ctor) => registerComponent(ctor)));
|
|
5
|
+
return results.flatMap((result) => {
|
|
6
|
+
if (result.status === "fulfilled") {
|
|
7
|
+
return result.value;
|
|
8
|
+
}
|
|
9
|
+
if (isDev) {
|
|
10
|
+
console.error(
|
|
11
|
+
"[registerComponents] A component failed to register and was skipped.",
|
|
12
|
+
result.reason
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
return [];
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
registerComponents
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=registerComponents.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../packages/js-toolkit/helpers/registerComponents.ts"],
|
|
4
|
+
"sourcesContent": ["import { BaseConstructor } from '../Base/Base.js';\nimport { isDev } from '../utils/index.js';\nimport { registerComponent } from './registerComponent.js';\n\n/**\n * Register globally and mount multiple components at once.\n *\n * Each component accepts the same forms as {@link registerComponent}: a `Base`\n * constructor, a promise resolving to a constructor or module namespace, or a\n * factory function returning such a promise.\n *\n * Components are registered independently: a single failure (e.g. a rejected\n * dynamic import) does not prevent the others from being registered, and the\n * returned array contains every instance that mounted successfully. Failures\n * are logged in development.\n *\n * @link https://js-toolkit.studiometa.dev/api/helpers/registerComponents.html\n * @param ctors The components, or ways to resolve them.\n * @return A promise resolving to a flat array of mounted component instances.\n */\nexport async function registerComponents<T extends BaseConstructor = BaseConstructor>(\n ...ctors: (T | Promise<T | { default: T }> | (() => Promise<T | { default: T }>))[]\n) {\n const results = await Promise.allSettled(ctors.map((ctor) => registerComponent(ctor)));\n\n return results.flatMap((result) => {\n if (result.status === 'fulfilled') {\n return result.value;\n }\n\n if (isDev) {\n console.error(\n '[registerComponents] A component failed to register and was skipped.',\n result.reason,\n );\n }\n\n return [];\n });\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,aAAa;AACtB,SAAS,yBAAyB;AAkBlC,eAAsB,sBACjB,OACH;AACA,QAAM,UAAU,MAAM,QAAQ,WAAW,MAAM,IAAI,CAAC,SAAS,kBAAkB,IAAI,CAAC,CAAC;AAErF,SAAO,QAAQ,QAAQ,CAAC,WAAW;AACjC,QAAI,OAAO,WAAW,aAAa;AACjC,aAAO,OAAO;AAAA,IAChB;AAEA,QAAI,OAAO;AACT,cAAQ;AAAA,QACN;AAAA,QACA,OAAO;AAAA,MACT;AAAA,IACF;AAEA,WAAO,CAAC;AAAA,EACV,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const version: '3.6.0-beta.0';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
2
|
+
export { Base, getInstances, type BaseAsyncConstructor, type BaseChildren, type BaseConfig, type BaseConfigComponents, type BaseConstructor, type BaseEl, type BaseOptions, type BaseProps, type BaseRefs, type Managers, } from './Base/index.js';
|
|
3
|
+
export { type BaseDecorator, type BaseEventHookParams, type BaseInterface } from './Base/types.js';
|
|
4
|
+
export { getScopedGroups, withBreakpointManager, withBreakpointObserver, withDrag, withExtraConfig, withFreezedOptions, withGroup, withIntersectionObserver, withMountOnMediaQuery, withMountWhenInView, withMountWhenPrefersMotion, withMutation, withName, withRelativePointer, withResponsiveOptions, withScrolledInView, type DragDecoratorOptions, type MutationDecoratorOptions, type NormalizedOffset, type OffsetValue, type RelativePointerDecoratorOptions, type RelativePointerInterface, type ScrollInViewProps, type WithBreakpointObserverInterface, type WithBreakpointObserverProps, type WithDragInterface, type WithFreezedOptionsInterface, type WithGroupInterface, type WithGroupOptions, type WithGroupProps, type WithIntersectionObserverInterface, type WithIntersectionObserverProps, type WithMountWhenInViewInterface, type WithMountWhenInViewProps, type WithMutationInterface, type WithScrolledInViewInterface, type WithScrolledInViewOptions, type WithScrolledInViewProps, type withMountOnMediaQueryInterface, type withMountOnMediaQueryProps, } from './decorators/index.js';
|
|
5
|
+
export { closestComponent, createApp, defineFeatures, getClosestParent, getDirectChildren, getInstanceFromElement, importOnInteraction, importOnMediaQuery, importWhenIdle, importWhenPrefersMotion, importWhenVisible, isDirectChild, logTree, queryComponent, queryComponentAll, registerComponent, registerComponents, type CreateAppOptions, type QueryOptions, } from './helpers/index.js';
|
|
6
|
+
export { AbstractService, DragService, KeyService, LoadService, MutationService, PointerService, RafService, ResizeService, ScrollService, useDrag, useKey, useLoad, useMutation, usePointer, useRaf, useResize, useScroll, type DragServiceInterface, type DragServiceOptions, type DragServiceProps, type KeyServiceInterface, type KeyServiceProps, type LoadServiceInterface, type LoadServiceProps, type MutationServiceInterface, type MutationServiceOptions, type MutationServiceProps, type PointerServiceInterface, type PointerServiceProps, type RafServiceInterface, type RafServiceProps, type ResizeServiceInterface, type ResizeServiceProps, type ScrollServiceInterface, type ScrollServiceProps, type ServiceConfig, type ServiceInterface, } from './services/index.js';
|
package/index.js
CHANGED
|
@@ -1,10 +1,117 @@
|
|
|
1
1
|
const version = "3.6.0-beta.0";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import {
|
|
3
|
+
Base,
|
|
4
|
+
getInstances
|
|
5
|
+
} from "./Base/index.js";
|
|
6
|
+
import {
|
|
7
|
+
getScopedGroups,
|
|
8
|
+
withBreakpointManager,
|
|
9
|
+
withBreakpointObserver,
|
|
10
|
+
withDrag,
|
|
11
|
+
withExtraConfig,
|
|
12
|
+
withFreezedOptions,
|
|
13
|
+
withGroup,
|
|
14
|
+
withIntersectionObserver,
|
|
15
|
+
withMountOnMediaQuery,
|
|
16
|
+
withMountWhenInView,
|
|
17
|
+
withMountWhenPrefersMotion,
|
|
18
|
+
withMutation,
|
|
19
|
+
withName,
|
|
20
|
+
withRelativePointer,
|
|
21
|
+
withResponsiveOptions,
|
|
22
|
+
withScrolledInView
|
|
23
|
+
} from "./decorators/index.js";
|
|
24
|
+
import {
|
|
25
|
+
closestComponent,
|
|
26
|
+
createApp,
|
|
27
|
+
defineFeatures,
|
|
28
|
+
getClosestParent,
|
|
29
|
+
getDirectChildren,
|
|
30
|
+
getInstanceFromElement,
|
|
31
|
+
importOnInteraction,
|
|
32
|
+
importOnMediaQuery,
|
|
33
|
+
importWhenIdle,
|
|
34
|
+
importWhenPrefersMotion,
|
|
35
|
+
importWhenVisible,
|
|
36
|
+
isDirectChild,
|
|
37
|
+
logTree,
|
|
38
|
+
queryComponent,
|
|
39
|
+
queryComponentAll,
|
|
40
|
+
registerComponent,
|
|
41
|
+
registerComponents
|
|
42
|
+
} from "./helpers/index.js";
|
|
43
|
+
import {
|
|
44
|
+
AbstractService,
|
|
45
|
+
DragService,
|
|
46
|
+
KeyService,
|
|
47
|
+
LoadService,
|
|
48
|
+
MutationService,
|
|
49
|
+
PointerService,
|
|
50
|
+
RafService,
|
|
51
|
+
ResizeService,
|
|
52
|
+
ScrollService,
|
|
53
|
+
useDrag,
|
|
54
|
+
useKey,
|
|
55
|
+
useLoad,
|
|
56
|
+
useMutation,
|
|
57
|
+
usePointer,
|
|
58
|
+
useRaf,
|
|
59
|
+
useResize,
|
|
60
|
+
useScroll
|
|
61
|
+
} from "./services/index.js";
|
|
7
62
|
export {
|
|
8
|
-
|
|
63
|
+
AbstractService,
|
|
64
|
+
Base,
|
|
65
|
+
DragService,
|
|
66
|
+
KeyService,
|
|
67
|
+
LoadService,
|
|
68
|
+
MutationService,
|
|
69
|
+
PointerService,
|
|
70
|
+
RafService,
|
|
71
|
+
ResizeService,
|
|
72
|
+
ScrollService,
|
|
73
|
+
closestComponent,
|
|
74
|
+
createApp,
|
|
75
|
+
defineFeatures,
|
|
76
|
+
getClosestParent,
|
|
77
|
+
getDirectChildren,
|
|
78
|
+
getInstanceFromElement,
|
|
79
|
+
getInstances,
|
|
80
|
+
getScopedGroups,
|
|
81
|
+
importOnInteraction,
|
|
82
|
+
importOnMediaQuery,
|
|
83
|
+
importWhenIdle,
|
|
84
|
+
importWhenPrefersMotion,
|
|
85
|
+
importWhenVisible,
|
|
86
|
+
isDirectChild,
|
|
87
|
+
logTree,
|
|
88
|
+
queryComponent,
|
|
89
|
+
queryComponentAll,
|
|
90
|
+
registerComponent,
|
|
91
|
+
registerComponents,
|
|
92
|
+
useDrag,
|
|
93
|
+
useKey,
|
|
94
|
+
useLoad,
|
|
95
|
+
useMutation,
|
|
96
|
+
usePointer,
|
|
97
|
+
useRaf,
|
|
98
|
+
useResize,
|
|
99
|
+
useScroll,
|
|
100
|
+
version,
|
|
101
|
+
withBreakpointManager,
|
|
102
|
+
withBreakpointObserver,
|
|
103
|
+
withDrag,
|
|
104
|
+
withExtraConfig,
|
|
105
|
+
withFreezedOptions,
|
|
106
|
+
withGroup,
|
|
107
|
+
withIntersectionObserver,
|
|
108
|
+
withMountOnMediaQuery,
|
|
109
|
+
withMountWhenInView,
|
|
110
|
+
withMountWhenPrefersMotion,
|
|
111
|
+
withMutation,
|
|
112
|
+
withName,
|
|
113
|
+
withRelativePointer,
|
|
114
|
+
withResponsiveOptions,
|
|
115
|
+
withScrolledInView
|
|
9
116
|
};
|
|
10
117
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../packages/js-toolkit/index.ts"],
|
|
4
|
-
"sourcesContent": ["export const version = '3.6.0-beta.0' as const;\n\nexport
|
|
5
|
-
"mappings": "AAAO,MAAM,UAAU;AAEvB,
|
|
4
|
+
"sourcesContent": ["export const version = '3.6.0-beta.0' as const;\n\nexport {\n Base,\n getInstances,\n type BaseAsyncConstructor,\n type BaseChildren,\n type BaseConfig,\n type BaseConfigComponents,\n type BaseConstructor,\n type BaseEl,\n type BaseOptions,\n type BaseProps,\n type BaseRefs,\n type Managers,\n} from './Base/index.js';\nexport { type BaseDecorator, type BaseEventHookParams, type BaseInterface } from './Base/types.js';\nexport {\n getScopedGroups,\n withBreakpointManager,\n withBreakpointObserver,\n withDrag,\n withExtraConfig,\n withFreezedOptions,\n withGroup,\n withIntersectionObserver,\n withMountOnMediaQuery,\n withMountWhenInView,\n withMountWhenPrefersMotion,\n withMutation,\n withName,\n withRelativePointer,\n withResponsiveOptions,\n withScrolledInView,\n type DragDecoratorOptions,\n type MutationDecoratorOptions,\n type NormalizedOffset,\n type OffsetValue,\n type RelativePointerDecoratorOptions,\n type RelativePointerInterface,\n type ScrollInViewProps,\n type WithBreakpointObserverInterface,\n type WithBreakpointObserverProps,\n type WithDragInterface,\n type WithFreezedOptionsInterface,\n type WithGroupInterface,\n type WithGroupOptions,\n type WithGroupProps,\n type WithIntersectionObserverInterface,\n type WithIntersectionObserverProps,\n type WithMountWhenInViewInterface,\n type WithMountWhenInViewProps,\n type WithMutationInterface,\n type WithScrolledInViewInterface,\n type WithScrolledInViewOptions,\n type WithScrolledInViewProps,\n type withMountOnMediaQueryInterface,\n type withMountOnMediaQueryProps,\n} from './decorators/index.js';\nexport {\n closestComponent,\n createApp,\n defineFeatures,\n getClosestParent,\n getDirectChildren,\n getInstanceFromElement,\n importOnInteraction,\n importOnMediaQuery,\n importWhenIdle,\n importWhenPrefersMotion,\n importWhenVisible,\n isDirectChild,\n logTree,\n queryComponent,\n queryComponentAll,\n registerComponent,\n registerComponents,\n type CreateAppOptions,\n type QueryOptions,\n} from './helpers/index.js';\nexport {\n AbstractService,\n DragService,\n KeyService,\n LoadService,\n MutationService,\n PointerService,\n RafService,\n ResizeService,\n ScrollService,\n useDrag,\n useKey,\n useLoad,\n useMutation,\n usePointer,\n useRaf,\n useResize,\n useScroll,\n type DragServiceInterface,\n type DragServiceOptions,\n type DragServiceProps,\n type KeyServiceInterface,\n type KeyServiceProps,\n type LoadServiceInterface,\n type LoadServiceProps,\n type MutationServiceInterface,\n type MutationServiceOptions,\n type MutationServiceProps,\n type PointerServiceInterface,\n type PointerServiceProps,\n type RafServiceInterface,\n type RafServiceProps,\n type ResizeServiceInterface,\n type ResizeServiceProps,\n type ScrollServiceInterface,\n type ScrollServiceProps,\n type ServiceConfig,\n type ServiceInterface,\n} from './services/index.js';\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,UAAU;AAEvB;AAAA,EACE;AAAA,EACA;AAAA,OAWK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAyBK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAqBK;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
package/services/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
1
|
+
export { AbstractService, type ServiceConfig, type ServiceInterface } from './AbstractService.js';
|
|
2
|
+
export { DragService, useDrag, type DragServiceInterface, type DragServiceOptions, type DragServiceProps, } from './DragService.js';
|
|
3
|
+
export { KeyService, useKey, type KeyServiceInterface, type KeyServiceProps, } from './KeyService.js';
|
|
4
|
+
export { LoadService, useLoad, type LoadServiceInterface, type LoadServiceProps, } from './LoadService.js';
|
|
5
|
+
export { MutationService, useMutation, type MutationServiceInterface, type MutationServiceOptions, type MutationServiceProps, } from './MutationService.js';
|
|
6
|
+
export { PointerService, usePointer, type PointerServiceInterface, type PointerServiceProps, } from './PointerService.js';
|
|
7
|
+
export { RafService, useRaf, type RafServiceInterface, type RafServiceProps, } from './RafService.js';
|
|
8
|
+
export { ResizeService, useResize, type ResizeServiceInterface, type ResizeServiceProps, } from './ResizeService.js';
|
|
9
|
+
export { ScrollService, useScroll, type ScrollServiceInterface, type ScrollServiceProps, } from './ScrollService.js';
|