@studiometa/js-toolkit 4.0.0-alpha.2 → 4.0.0-alpha.3
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/dist/Base.d.ts +0 -2
- package/dist/Base.js +1 -2
- package/dist/Base.js.map +1 -1
- package/dist/attribute-namespaces.d.ts +0 -2
- package/dist/attribute-namespaces.js +1 -2
- package/dist/attributes.d.ts +0 -2
- package/dist/attributes.js +1 -2
- package/dist/children-watchers.d.ts +0 -2
- package/dist/children-watchers.js +1 -2
- package/dist/component-brand.d.ts +0 -2
- package/dist/component-brand.js +1 -2
- package/dist/component-declarations.d.ts +0 -2
- package/dist/component-declarations.js +1 -2
- package/dist/context-subscription.d.ts +0 -2
- package/dist/context-subscription.js +1 -2
- package/dist/context.d.ts +0 -2
- package/dist/context.js +1 -2
- package/dist/decorators.d.ts +0 -2
- package/dist/decorators.js +1 -2
- package/dist/diagnostic-contract.d.ts +0 -2
- package/dist/diagnostic-contract.js +1 -2
- package/dist/diagnostics.d.ts +0 -2
- package/dist/diagnostics.js +1 -2
- package/dist/document-order.d.ts +0 -2
- package/dist/document-order.js +1 -2
- package/dist/dom-mutations.d.ts +0 -2
- package/dist/dom-mutations.js +1 -2
- package/dist/events.d.ts +0 -2
- package/dist/events.js +1 -2
- package/dist/group.d.ts +0 -2
- package/dist/group.js +1 -2
- package/dist/instances.d.ts +0 -2
- package/dist/instances.js +1 -2
- package/dist/manifest.d.ts +0 -2
- package/dist/manifest.js +1 -2
- package/dist/mount-strategies.d.ts +0 -2
- package/dist/mount-strategies.js +1 -2
- package/dist/negotiated-events.d.ts +0 -2
- package/dist/negotiated-events.js +1 -2
- package/dist/protocol-symbols.d.ts +0 -2
- package/dist/protocol-symbols.js +1 -2
- package/dist/registry.d.ts +0 -2
- package/dist/registry.js +1 -2
- package/dist/responsive-options.d.ts +0 -2
- package/dist/responsive-options.js +1 -2
- package/dist/scheduler.d.ts +0 -2
- package/dist/scheduler.js +1 -2
- package/dist/scheduler.js.map +1 -1
- package/dist/services/breakpoint.d.ts +0 -2
- package/dist/services/breakpoint.js +1 -2
- package/dist/services/drag.d.ts +0 -2
- package/dist/services/drag.js +1 -2
- package/dist/services/in-view.d.ts +0 -2
- package/dist/services/in-view.js +1 -2
- package/dist/services/key.d.ts +0 -2
- package/dist/services/key.js +1 -2
- package/dist/services/media.d.ts +0 -2
- package/dist/services/media.js +1 -2
- package/dist/services/mixin.d.ts +0 -2
- package/dist/services/mixin.js +1 -2
- package/dist/services/mutation.d.ts +0 -2
- package/dist/services/mutation.js +1 -2
- package/dist/services/pointer.d.ts +0 -2
- package/dist/services/pointer.js +1 -2
- package/dist/services/raf.d.ts +0 -2
- package/dist/services/raf.js +1 -2
- package/dist/services/resize.d.ts +0 -2
- package/dist/services/resize.js +1 -2
- package/dist/services/scroll-progress-offset.d.ts +0 -2
- package/dist/services/scroll-progress-offset.js +1 -2
- package/dist/services/scroll-progress.d.ts +0 -2
- package/dist/services/scroll-progress.js +1 -2
- package/dist/services/scroll.d.ts +0 -2
- package/dist/services/scroll.js +1 -2
- package/dist/services/service.d.ts +0 -2
- package/dist/services/service.js +1 -2
- package/dist/services/toggle.d.ts +0 -2
- package/dist/services/toggle.js +1 -2
- package/dist/services/until.d.ts +0 -2
- package/dist/services/until.js +1 -2
- package/dist/shared-runtime.d.ts +0 -2
- package/dist/shared-runtime.js +1 -2
- package/dist/storage/createStorage.d.ts +0 -2
- package/dist/storage/createStorage.js +1 -2
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +1 -2
- package/dist/storage/providers.d.ts +0 -2
- package/dist/storage/providers.js +1 -2
- package/dist/storage/serializers.d.ts +0 -2
- package/dist/storage/serializers.js +1 -2
- package/dist/storage/sync.d.ts +0 -2
- package/dist/storage/sync.js +1 -2
- package/dist/storage/types.d.ts +0 -2
- package/dist/subpaths/BREAKPOINTS.js +1 -2
- package/dist/subpaths/Base.js +1 -2
- package/dist/subpaths/DIAGNOSTICS.js +1 -2
- package/dist/subpaths/DRAG_MODES.js +1 -2
- package/dist/subpaths/EVENTS.js +1 -2
- package/dist/subpaths/MOUNT_ATTRIBUTE.js +1 -2
- package/dist/subpaths/SWAP_MODES.js +1 -2
- package/dist/subpaths/children.js +1 -2
- package/dist/subpaths/component.js +1 -2
- package/dist/subpaths/createContext.js +1 -2
- package/dist/subpaths/createFallbackProvider.js +1 -2
- package/dist/subpaths/createGroup.js +1 -2
- package/dist/subpaths/createLocalStorage.js +1 -2
- package/dist/subpaths/createMemoryStorageProvider.js +1 -2
- package/dist/subpaths/createService.js +1 -2
- package/dist/subpaths/createServiceMixin.js +1 -2
- package/dist/subpaths/createSessionStorage.js +1 -2
- package/dist/subpaths/createStorage.js +1 -2
- package/dist/subpaths/createUrlSearchParamsInHashProvider.js +1 -2
- package/dist/subpaths/createUrlSearchParamsInHashStorage.js +1 -2
- package/dist/subpaths/createUrlSearchParamsProvider.js +1 -2
- package/dist/subpaths/createUrlSearchParamsStorage.js +1 -2
- package/dist/subpaths/defaultScheduler.js +1 -2
- package/dist/subpaths/defineManifest.js +1 -2
- package/dist/subpaths/domUpdate.js +1 -2
- package/dist/subpaths/emitExtendable.js +1 -2
- package/dist/subpaths/fromMetaGlob.js +1 -2
- package/dist/subpaths/fromWebpackContext.js +1 -2
- package/dist/subpaths/getBreakpoints.js +1 -2
- package/dist/subpaths/getInstance.js +1 -2
- package/dist/subpaths/getInstances.js +1 -2
- package/dist/subpaths/getMountedInstances.js +1 -2
- package/dist/subpaths/getUnmountedInstances.js +1 -2
- package/dist/subpaths/inject.js +1 -2
- package/dist/subpaths/injectContext.js +1 -2
- package/dist/subpaths/injectContextSync.js +1 -2
- package/dist/subpaths/jsonSerializer.js +1 -2
- package/dist/subpaths/localStorageProvider.js +1 -2
- package/dist/subpaths/memoryStorageProvider.js +1 -2
- package/dist/subpaths/namespaceQualifier.js +1 -2
- package/dist/subpaths/nextFrame.js +1 -2
- package/dist/subpaths/on.js +1 -2
- package/dist/subpaths/perTarget.js +1 -2
- package/dist/subpaths/provide.js +1 -2
- package/dist/subpaths/provideContext.js +1 -2
- package/dist/subpaths/provideRootContext.js +1 -2
- package/dist/subpaths/read.js +1 -2
- package/dist/subpaths/registerComponent.js +1 -2
- package/dist/subpaths/registerComponents.js +1 -2
- package/dist/subpaths/registerManifest.js +1 -2
- package/dist/subpaths/reportDiagnostic.js +1 -2
- package/dist/subpaths/sessionStorageProvider.js +1 -2
- package/dist/subpaths/setBreakpoints.js +1 -2
- package/dist/subpaths/signal.js +1 -2
- package/dist/subpaths/subscribeContext.js +1 -2
- package/dist/subpaths/swap.js +1 -2
- package/dist/subpaths/toggle.js +1 -2
- package/dist/subpaths/until.js +1 -2
- package/dist/subpaths/urlSearchParamsInHashProvider.js +1 -2
- package/dist/subpaths/urlSearchParamsProvider.js +1 -2
- package/dist/subpaths/useBreakpoint.js +1 -2
- package/dist/subpaths/useDrag.js +1 -2
- package/dist/subpaths/useInView.js +1 -2
- package/dist/subpaths/useKey.js +1 -2
- package/dist/subpaths/useMediaQuery.js +1 -2
- package/dist/subpaths/useMutation.js +1 -2
- package/dist/subpaths/usePointer.js +1 -2
- package/dist/subpaths/usePrefersReducedMotion.js +1 -2
- package/dist/subpaths/useRaf.js +1 -2
- package/dist/subpaths/useResize.js +1 -2
- package/dist/subpaths/useScroll.js +1 -2
- package/dist/subpaths/useScrollProgress.js +1 -2
- package/dist/subpaths/useWindowScroll.js +1 -2
- package/dist/subpaths/useWindowSize.js +1 -2
- package/dist/subpaths/utils/DEFAULT_DAMP_FACTOR.js +1 -2
- package/dist/subpaths/utils/INERTIA_FRAME.js +1 -2
- package/dist/subpaths/utils/MAX_SPRING_RATIO.js +1 -2
- package/dist/subpaths/utils/SCROLL_ALIGNMENTS.js +1 -2
- package/dist/subpaths/utils/SCROLL_AXES.js +1 -2
- package/dist/subpaths/utils/TRANSFORM_PROPS.js +1 -2
- package/dist/subpaths/utils/TRANSITION_OPTIONS.js +1 -2
- package/dist/subpaths/utils/camelCase.js +1 -2
- package/dist/subpaths/utils/capitalize.js +1 -2
- package/dist/subpaths/utils/clamp.js +1 -2
- package/dist/subpaths/utils/clamp01.js +1 -2
- package/dist/subpaths/utils/clampDampFactor.js +1 -2
- package/dist/subpaths/utils/createEaseInOut.js +1 -2
- package/dist/subpaths/utils/createEaseOut.js +1 -2
- package/dist/subpaths/utils/createElement.js +1 -2
- package/dist/subpaths/utils/createRange.js +1 -2
- package/dist/subpaths/utils/damp.js +1 -2
- package/dist/subpaths/utils/debounce.js +1 -2
- package/dist/subpaths/utils/decayOver.js +1 -2
- package/dist/subpaths/utils/deepmerge.js +1 -2
- package/dist/subpaths/utils/easeInCirc.js +1 -2
- package/dist/subpaths/utils/easeInCubic.js +1 -2
- package/dist/subpaths/utils/easeInExpo.js +1 -2
- package/dist/subpaths/utils/easeInOutCirc.js +1 -2
- package/dist/subpaths/utils/easeInOutCubic.js +1 -2
- package/dist/subpaths/utils/easeInOutExpo.js +1 -2
- package/dist/subpaths/utils/easeInOutQuad.js +1 -2
- package/dist/subpaths/utils/easeInOutQuart.js +1 -2
- package/dist/subpaths/utils/easeInOutQuint.js +1 -2
- package/dist/subpaths/utils/easeInOutSine.js +1 -2
- package/dist/subpaths/utils/easeInQuad.js +1 -2
- package/dist/subpaths/utils/easeInQuart.js +1 -2
- package/dist/subpaths/utils/easeInQuint.js +1 -2
- package/dist/subpaths/utils/easeInSine.js +1 -2
- package/dist/subpaths/utils/easeLinear.js +1 -2
- package/dist/subpaths/utils/easeOutCirc.js +1 -2
- package/dist/subpaths/utils/easeOutCubic.js +1 -2
- package/dist/subpaths/utils/easeOutExpo.js +1 -2
- package/dist/subpaths/utils/easeOutQuad.js +1 -2
- package/dist/subpaths/utils/easeOutQuart.js +1 -2
- package/dist/subpaths/utils/easeOutQuint.js +1 -2
- package/dist/subpaths/utils/easeOutSine.js +1 -2
- package/dist/subpaths/utils/enterTransition.js +1 -2
- package/dist/subpaths/utils/fold.js +1 -2
- package/dist/subpaths/utils/getOffsetSizes.js +1 -2
- package/dist/subpaths/utils/historyPush.js +1 -2
- package/dist/subpaths/utils/historyReplace.js +1 -2
- package/dist/subpaths/utils/inertiaDecay.js +1 -2
- package/dist/subpaths/utils/inertiaFinalValue.js +1 -2
- package/dist/subpaths/utils/inertiaStep.js +1 -2
- package/dist/subpaths/utils/inertiaTimeConstant.js +1 -2
- package/dist/subpaths/utils/isBoolean.js +1 -2
- package/dist/subpaths/utils/isDefined.js +1 -2
- package/dist/subpaths/utils/isFunction.js +1 -2
- package/dist/subpaths/utils/isNull.js +1 -2
- package/dist/subpaths/utils/isNumber.js +1 -2
- package/dist/subpaths/utils/isObject.js +1 -2
- package/dist/subpaths/utils/isString.js +1 -2
- package/dist/subpaths/utils/kebabCase.js +1 -2
- package/dist/subpaths/utils/leaveTransition.js +1 -2
- package/dist/subpaths/utils/lerp.js +1 -2
- package/dist/subpaths/utils/loadImage.js +1 -2
- package/dist/subpaths/utils/loadLink.js +1 -2
- package/dist/subpaths/utils/loadScript.js +1 -2
- package/dist/subpaths/utils/lockScroll.js +1 -2
- package/dist/subpaths/utils/lowerCase.js +1 -2
- package/dist/subpaths/utils/map.js +1 -2
- package/dist/subpaths/utils/matrix.js +1 -2
- package/dist/subpaths/utils/mean.js +1 -2
- package/dist/subpaths/utils/memo.js +1 -2
- package/dist/subpaths/utils/noop.js +1 -2
- package/dist/subpaths/utils/noopValue.js +1 -2
- package/dist/subpaths/utils/objectToURLSearchParams.js +1 -2
- package/dist/subpaths/utils/pascalCase.js +1 -2
- package/dist/subpaths/utils/random.js +1 -2
- package/dist/subpaths/utils/randomInt.js +1 -2
- package/dist/subpaths/utils/randomItem.js +1 -2
- package/dist/subpaths/utils/round.js +1 -2
- package/dist/subpaths/utils/saveActiveElement.js +1 -2
- package/dist/subpaths/utils/scrollPosition.js +1 -2
- package/dist/subpaths/utils/scrollTo.js +1 -2
- package/dist/subpaths/utils/selectorFor.js +1 -2
- package/dist/subpaths/utils/setClassesOrStyles.js +1 -2
- package/dist/subpaths/utils/smoothTo.js +1 -2
- package/dist/subpaths/utils/snakeCase.js +1 -2
- package/dist/subpaths/utils/spring.js +1 -2
- package/dist/subpaths/utils/throttle.js +1 -2
- package/dist/subpaths/utils/transform.js +1 -2
- package/dist/subpaths/utils/transition.js +1 -2
- package/dist/subpaths/utils/trapFocus.js +1 -2
- package/dist/subpaths/utils/untrapFocus.js +1 -2
- package/dist/subpaths/utils/upperCase.js +1 -2
- package/dist/subpaths/utils/wait.js +1 -2
- package/dist/subpaths/utils/withLeadingCharacters.js +1 -2
- package/dist/subpaths/utils/withLeadingSlash.js +1 -2
- package/dist/subpaths/utils/withTrailingCharacters.js +1 -2
- package/dist/subpaths/utils/withTrailingSlash.js +1 -2
- package/dist/subpaths/utils/withoutLeadingCharacters.js +1 -2
- package/dist/subpaths/utils/withoutLeadingCharactersRecursive.js +1 -2
- package/dist/subpaths/utils/withoutLeadingSlash.js +1 -2
- package/dist/subpaths/utils/withoutTrailingCharacters.js +1 -2
- package/dist/subpaths/utils/withoutTrailingCharactersRecursive.js +1 -2
- package/dist/subpaths/utils/withoutTrailingSlash.js +1 -2
- package/dist/subpaths/utils/wrap.js +1 -2
- package/dist/subpaths/viewTransition.js +1 -2
- package/dist/subpaths/warn.js +1 -2
- package/dist/subpaths/watchAttributeNamespace.js +1 -2
- package/dist/subpaths/watchAttributes.js +1 -2
- package/dist/subpaths/whenDOMSettled.js +1 -2
- package/dist/subpaths/withDrag.js +1 -2
- package/dist/subpaths/withInView.js +1 -2
- package/dist/subpaths/withKey.js +1 -2
- package/dist/subpaths/withMutation.js +1 -2
- package/dist/subpaths/withPointer.js +1 -2
- package/dist/subpaths/withRaf.js +1 -2
- package/dist/subpaths/withResize.js +1 -2
- package/dist/subpaths/withScroll.js +1 -2
- package/dist/subpaths/withScrollProgress.js +1 -2
- package/dist/subpaths/write.js +1 -2
- package/dist/swap.d.ts +0 -2
- package/dist/swap.js +1 -2
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.js +1 -2
- package/dist/utils/deepmerge.d.ts +0 -2
- package/dist/utils/deepmerge.js +1 -2
- package/dist/utils/dom.d.ts +0 -2
- package/dist/utils/dom.js +1 -2
- package/dist/utils/easings.d.ts +0 -2
- package/dist/utils/easings.js +1 -2
- package/dist/utils/focus.d.ts +0 -2
- package/dist/utils/focus.js +1 -2
- package/dist/utils/history.d.ts +0 -2
- package/dist/utils/history.js +1 -2
- package/dist/utils/is.d.ts +0 -2
- package/dist/utils/is.js +1 -2
- package/dist/utils/load.d.ts +0 -2
- package/dist/utils/load.js +1 -2
- package/dist/utils/maths.d.ts +0 -2
- package/dist/utils/maths.js +1 -2
- package/dist/utils/memo.d.ts +0 -2
- package/dist/utils/memo.js +1 -2
- package/dist/utils/noop.d.ts +0 -2
- package/dist/utils/noop.js +1 -2
- package/dist/utils/random.d.ts +0 -2
- package/dist/utils/random.js +1 -2
- package/dist/utils/scroll-lock.d.ts +0 -2
- package/dist/utils/scroll-lock.js +1 -2
- package/dist/utils/scrollTo.d.ts +0 -2
- package/dist/utils/scrollTo.js +1 -2
- package/dist/utils/selectors.d.ts +0 -2
- package/dist/utils/selectors.js +1 -2
- package/dist/utils/smoothTo.d.ts +0 -2
- package/dist/utils/smoothTo.js +1 -2
- package/dist/utils/strings.d.ts +0 -2
- package/dist/utils/strings.js +1 -2
- package/dist/utils/timing.d.ts +0 -2
- package/dist/utils/timing.js +1 -2
- package/dist/utils/transform.d.ts +0 -2
- package/dist/utils/transform.js +1 -2
- package/dist/utils/transition.d.ts +0 -2
- package/dist/utils/transition.js +1 -2
- package/dist/viewTransition.d.ts +0 -2
- package/dist/viewTransition.js +1 -2
- package/package.json +2 -2
package/dist/context.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSharedRuntimeSlot } from "./shared-runtime.js";
|
|
2
2
|
import { isolateCallbackFailure } from "./diagnostics.js";
|
|
3
|
-
|
|
3
|
+
// src/context.ts
|
|
4
4
|
const CONTEXT_REQUEST = "js-toolkit:context:request";
|
|
5
5
|
/**
|
|
6
6
|
* Create a typed context key.
|
|
@@ -167,7 +167,6 @@ function injectContextSync(el, key) {
|
|
|
167
167
|
});
|
|
168
168
|
return resolved;
|
|
169
169
|
}
|
|
170
|
-
//#endregion
|
|
171
170
|
export { cancelContextRequest, createContext, dispatchContextRequest, injectContext, injectContextSync, provideContext, provideRootContext, retainContextRequest, signal };
|
|
172
171
|
|
|
173
172
|
//# sourceMappingURL=context.js.map
|
package/dist/decorators.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ContextKey } from "./context.js";
|
|
2
2
|
import { Base, BaseConfig, BaseConstructor, ChildrenCollection, DelegatedEvent, GlobalEvent, RefEvent, WatchChildrenCallbacks } from "./Base.js";
|
|
3
|
-
//#region src/decorators.d.ts
|
|
4
3
|
/** Decorator syntax requires transpilation; use the function APIs without a build step. */
|
|
5
4
|
type ChildHandler<T extends Base = Base, K extends string = string> = (this: any, payload: DelegatedEvent<T, K>) => void;
|
|
6
5
|
type RefHandler<T extends HTMLElement = HTMLElement> = (this: any, payload: RefEvent<T>) => void;
|
|
@@ -66,5 +65,4 @@ declare function inject<T>(key: ContextKey<T>): ValueObserver<T | undefined>;
|
|
|
66
65
|
*/
|
|
67
66
|
declare function children<T extends Base = Base, Host = any>(name: string, callbacks?: WatchChildrenCallbacks<T> & ThisType<Host>): ValueDecorator<ChildrenCollection<T>>;
|
|
68
67
|
declare function children<T extends BaseConstructor, Host = any>(ComponentClass: T, callbacks?: WatchChildrenCallbacks<InstanceType<T>> & ThisType<Host>): ValueDecorator<ChildrenCollection<InstanceType<T>>>;
|
|
69
|
-
//#endregion
|
|
70
68
|
export { children, component, inject, on, provide, read, write };
|
package/dist/decorators.js
CHANGED
|
@@ -3,7 +3,7 @@ import { warnOnce } from "./diagnostics.js";
|
|
|
3
3
|
import { HANDLER_REGISTRATIONS } from "./protocol-symbols.js";
|
|
4
4
|
import { resolveConfig } from "./Base.js";
|
|
5
5
|
import { registerComponent } from "./registry.js";
|
|
6
|
-
|
|
6
|
+
// src/decorators.ts
|
|
7
7
|
/**
|
|
8
8
|
* Global targets use identity checks. Component classes use their merged config name because it is their mount identity.
|
|
9
9
|
* Other `EventTarget` values are invalid because decorators have no component instance or mount cycle.
|
|
@@ -183,7 +183,6 @@ function children(target, callbacks) {
|
|
|
183
183
|
});
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
|
-
//#endregion
|
|
187
186
|
export { children, component, inject, on, provide, read, write };
|
|
188
187
|
|
|
189
188
|
//# sourceMappingURL=decorators.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/diagnostic-contract.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Stable codes carried by toolkit diagnostics.
|
|
4
3
|
* @link https://js-toolkit-v4.studiometa.dev/api/diagnostics/DIAGNOSTICS.html
|
|
@@ -100,5 +99,4 @@ type ToolkitDiagnosticDetail = (ToolkitDiagnosticBaseDetail & {
|
|
|
100
99
|
readonly severity: 'error';
|
|
101
100
|
readonly error: unknown;
|
|
102
101
|
});
|
|
103
|
-
//#endregion
|
|
104
102
|
export { DIAGNOSTICS, ToolkitConsumerDiagnosticCode, ToolkitCoreDiagnosticCode, ToolkitDiagnosticCode, ToolkitDiagnosticDetail, ToolkitDiagnosticSeverity };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/diagnostic-contract.ts
|
|
2
2
|
const attribute = Object.freeze({ unknownQualifier: "attribute.unknown-qualifier" });
|
|
3
3
|
const callback = Object.freeze({
|
|
4
4
|
signalFailed: "callback.signal-failed",
|
|
@@ -60,7 +60,6 @@ const DIAGNOSTICS = Object.freeze({
|
|
|
60
60
|
storage,
|
|
61
61
|
swap
|
|
62
62
|
});
|
|
63
|
-
//#endregion
|
|
64
63
|
export { DIAGNOSTICS };
|
|
65
64
|
|
|
66
65
|
//# sourceMappingURL=diagnostic-contract.js.map
|
package/dist/diagnostics.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ToolkitDiagnosticCode, ToolkitDiagnosticDetail } from "./diagnostic-contract.js";
|
|
2
|
-
//#region src/diagnostics.d.ts
|
|
3
2
|
interface DiagnosticContext {
|
|
4
3
|
component?: string;
|
|
5
4
|
target?: Element;
|
|
@@ -37,5 +36,4 @@ declare function warn(code: ToolkitDiagnosticCode, message: string, { component,
|
|
|
37
36
|
* @internal
|
|
38
37
|
*/
|
|
39
38
|
declare function warnOnce(owner: object, key: string, code: ToolkitDiagnosticCode, message: string, context?: DiagnosticContext): CustomEvent<ToolkitDiagnosticDetail> | undefined;
|
|
40
|
-
//#endregion
|
|
41
39
|
export { isolateCallbackFailure, reportDiagnostic, warn, warnOnce };
|
package/dist/diagnostics.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getSharedRuntimeSlot } from "./shared-runtime.js";
|
|
2
|
-
|
|
2
|
+
// src/diagnostics.ts
|
|
3
3
|
function warningOwners() {
|
|
4
4
|
return getSharedRuntimeSlot("diagnostics:warnings", 1, () => ({ owners: /* @__PURE__ */ new WeakMap() })).owners;
|
|
5
5
|
}
|
|
@@ -96,7 +96,6 @@ function warnOnce(owner, key, code, message, context) {
|
|
|
96
96
|
keys.add(warningKey);
|
|
97
97
|
return warn(code, message, context);
|
|
98
98
|
}
|
|
99
|
-
//#endregion
|
|
100
99
|
export { isolateCallbackFailure, reportDiagnostic, warn, warnOnce };
|
|
101
100
|
|
|
102
101
|
//# sourceMappingURL=diagnostics.js.map
|
package/dist/document-order.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/document-order.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Document order, the only order DOM-anchored peers can agree on without
|
|
4
3
|
* either the coordinator or the mount sequence arbitrating it.
|
|
@@ -6,5 +5,4 @@
|
|
|
6
5
|
* Imports nothing, so ordering costs a consumer no component graph.
|
|
7
6
|
*/
|
|
8
7
|
declare function compareDocumentOrder(a: Node, b: Node): number;
|
|
9
|
-
//#endregion
|
|
10
8
|
export { compareDocumentOrder };
|
package/dist/document-order.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/document-order.ts
|
|
2
2
|
/**
|
|
3
3
|
* Document order, the only order DOM-anchored peers can agree on without
|
|
4
4
|
* either the coordinator or the mount sequence arbitrating it.
|
|
@@ -11,7 +11,6 @@ function compareDocumentOrder(a, b) {
|
|
|
11
11
|
if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
|
|
12
12
|
return 0;
|
|
13
13
|
}
|
|
14
|
-
//#endregion
|
|
15
14
|
export { compareDocumentOrder };
|
|
16
15
|
|
|
17
16
|
//# sourceMappingURL=document-order.js.map
|
package/dist/dom-mutations.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/dom-mutations.d.ts
|
|
2
1
|
interface DOMMutationRecord {
|
|
3
2
|
record: MutationRecord;
|
|
4
3
|
/** Removed subtree membership at observer delivery, before background work. */
|
|
@@ -73,5 +72,4 @@ declare function trackDOMLifecycleWork(work: Promise<unknown> | undefined): void
|
|
|
73
72
|
* @link https://js-toolkit-v4.studiometa.dev/api/dom/whenDOMSettled.html
|
|
74
73
|
*/
|
|
75
74
|
declare function whenDOMSettled(): Promise<void>;
|
|
76
|
-
//#endregion
|
|
77
75
|
export { AttributeChange, AttributeWatcher, DOMMutationProcessor, DOMMutationRecord, domVersion, isObservedDOMAttribute, registerDOMOptionAttributes, replaceDOMOptionAttributes, setDOMMutationProcessor, trackDOMLifecycleWork, watchAttributes, whenDOMSettled };
|
package/dist/dom-mutations.js
CHANGED
|
@@ -2,7 +2,7 @@ import { FRAMEWORK_ATTRIBUTES, isComponentAttribute, isNetChange, rememberPrevio
|
|
|
2
2
|
import { getSharedRuntimeSlot } from "./shared-runtime.js";
|
|
3
3
|
import { reportDiagnostic } from "./diagnostics.js";
|
|
4
4
|
import { defaultScheduler } from "./scheduler.js";
|
|
5
|
-
|
|
5
|
+
// src/dom-mutations.ts
|
|
6
6
|
const domMutationState = /* @__PURE__ */ getSharedRuntimeSlot("dom-mutations", 1, () => ({
|
|
7
7
|
observedAttributes: new Set(FRAMEWORK_ATTRIBUTES),
|
|
8
8
|
attributeWatchers: /* @__PURE__ */ new Set(),
|
|
@@ -232,7 +232,6 @@ async function whenDOMSettled() {
|
|
|
232
232
|
if (!domMutationState.processTask && lifecycleWork.size === 0 && (!domMutationState.processor || domMutationState.records.length === 0) && !hasWatchedAttributes()) return;
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
//#endregion
|
|
236
235
|
export { domVersion, isObservedDOMAttribute, registerDOMOptionAttributes, replaceDOMOptionAttributes, setDOMMutationProcessor, trackDOMLifecycleWork, watchAttributes, whenDOMSettled };
|
|
237
236
|
|
|
238
237
|
//# sourceMappingURL=dom-mutations.js.map
|
package/dist/events.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/events.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Public framework event names.
|
|
4
3
|
* @link https://js-toolkit-v4.studiometa.dev/api/diagnostics/EVENTS.html
|
|
@@ -13,5 +12,4 @@ declare const EVENTS: Readonly<{
|
|
|
13
12
|
}>;
|
|
14
13
|
readonly diagnostic: 'js-toolkit:diagnostic';
|
|
15
14
|
}>;
|
|
16
|
-
//#endregion
|
|
17
15
|
export { EVENTS };
|
package/dist/events.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/events.ts
|
|
2
2
|
const component = Object.freeze({
|
|
3
3
|
mounted: "js-toolkit:component:mounted",
|
|
4
4
|
unmounted: "js-toolkit:component:unmounted"
|
|
@@ -13,7 +13,6 @@ const EVENTS = Object.freeze({
|
|
|
13
13
|
dom,
|
|
14
14
|
diagnostic: "js-toolkit:diagnostic"
|
|
15
15
|
});
|
|
16
|
-
//#endregion
|
|
17
16
|
export { EVENTS };
|
|
18
17
|
|
|
19
18
|
//# sourceMappingURL=events.js.map
|
package/dist/group.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Signal } from "./context.js";
|
|
2
|
-
//#region src/group.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* What a group needs of a member: the element that decides its rank.
|
|
5
4
|
*
|
|
@@ -51,5 +50,4 @@ interface Group<T extends GroupMember = GroupMember> {
|
|
|
51
50
|
* @link https://js-toolkit-v4.studiometa.dev/api/context/createGroup.html
|
|
52
51
|
*/
|
|
53
52
|
declare function createGroup<T extends GroupMember = GroupMember>(): Group<T>;
|
|
54
|
-
//#endregion
|
|
55
53
|
export { Group, GroupMember, createGroup };
|
package/dist/group.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { signal } from "./context.js";
|
|
2
2
|
import { compareDocumentOrder } from "./document-order.js";
|
|
3
|
-
|
|
3
|
+
// src/group.ts
|
|
4
4
|
/**
|
|
5
5
|
* Create an empty group.
|
|
6
6
|
*
|
|
@@ -28,7 +28,6 @@ function createGroup() {
|
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
//#endregion
|
|
32
31
|
export { createGroup };
|
|
33
32
|
|
|
34
33
|
//# sourceMappingURL=group.js.map
|
package/dist/instances.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Base } from "./Base.js";
|
|
2
|
-
//#region src/instances.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Every instance built for a component name, in DOM order, mounted or not.
|
|
5
4
|
*
|
|
@@ -82,5 +81,4 @@ declare function getUnmountedInstances<T extends Base = Base>(el: Element): T[];
|
|
|
82
81
|
* @link https://js-toolkit-v4.studiometa.dev/api/registry/getInstance.html
|
|
83
82
|
*/
|
|
84
83
|
declare function getInstance<T extends Base = Base>(el: Element | null, name: string): T | undefined;
|
|
85
|
-
//#endregion
|
|
86
84
|
export { getInstance, getInstances, getMountedInstances, getUnmountedInstances };
|
package/dist/instances.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { INSTANCES } from "./protocol-symbols.js";
|
|
2
2
|
import { selectorFor } from "./utils/selectors.js";
|
|
3
|
-
|
|
3
|
+
// src/instances.ts
|
|
4
4
|
/**
|
|
5
5
|
* The one traversal behind the three plural lookups.
|
|
6
6
|
*
|
|
@@ -65,7 +65,6 @@ function getUnmountedInstances(target, root = document) {
|
|
|
65
65
|
function getInstance(el, name) {
|
|
66
66
|
return el?.[INSTANCES]?.get(name);
|
|
67
67
|
}
|
|
68
|
-
//#endregion
|
|
69
68
|
export { getInstance, getInstances, getMountedInstances, getUnmountedInstances };
|
|
70
69
|
|
|
71
70
|
//# sourceMappingURL=instances.js.map
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MountStrategy } from "./mount-strategies.js";
|
|
2
2
|
import { ComponentImporter } from "./Base.js";
|
|
3
3
|
import { ComponentManifest } from "./registry.js";
|
|
4
|
-
//#region src/manifest.d.ts
|
|
5
4
|
/** Lazy module importers keyed by the paths a bundler matched. */
|
|
6
5
|
type ModuleRecord = Record<string, ComponentImporter>;
|
|
7
6
|
/** Options accepted by {@link defineManifest}. */
|
|
@@ -32,5 +31,4 @@ declare function fromMetaGlob(glob: Record<string, unknown>): ModuleRecord;
|
|
|
32
31
|
* @link https://js-toolkit-v4.studiometa.dev/api/registry/fromWebpackContext.html
|
|
33
32
|
*/
|
|
34
33
|
declare function fromWebpackContext(context: WebpackContextLike): ModuleRecord;
|
|
35
|
-
//#endregion
|
|
36
34
|
export { DefineManifestOptions, ModuleRecord, WebpackContextLike, defineManifest, fromMetaGlob, fromWebpackContext };
|
package/dist/manifest.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { warnOnce } from "./diagnostics.js";
|
|
2
|
-
|
|
2
|
+
// src/manifest.ts
|
|
3
3
|
function deriveToken(path) {
|
|
4
4
|
const segments = path.split("/").filter((segment) => segment && segment !== ".");
|
|
5
5
|
const base = (segments.at(-1) ?? "").replace(/\.[^.]+$/, "");
|
|
@@ -43,7 +43,6 @@ function fromMetaGlob(glob) {
|
|
|
43
43
|
function fromWebpackContext(context) {
|
|
44
44
|
return Object.fromEntries(context.keys().map((key) => [key, () => Promise.resolve(context(key))]));
|
|
45
45
|
}
|
|
46
|
-
//#endregion
|
|
47
46
|
export { defineManifest, fromMetaGlob, fromWebpackContext };
|
|
48
47
|
|
|
49
48
|
//# sourceMappingURL=manifest.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/mount-strategies.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Control when an instance mounts.
|
|
4
3
|
* `in-view` and `media` are reversible; all other strategies mount once.
|
|
@@ -42,5 +41,4 @@ declare function mountStrategyBehaviour(strategy: string): MountStrategyBehaviou
|
|
|
42
41
|
* Apply a strategy and return its teardown and any eager work that DOM settlement must await.
|
|
43
42
|
*/
|
|
44
43
|
declare function applyMountStrategy(el: HTMLElement, strategy: string, { mount, unmount }: MountStrategyHooks): AppliedMountStrategy;
|
|
45
|
-
//#endregion
|
|
46
44
|
export { AppliedMountStrategy, MountStrategy, MountStrategyBehaviour, MountStrategyHooks, applyMountStrategy, mountStrategyBehaviour };
|
package/dist/mount-strategies.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSharedRuntimeSlot } from "./shared-runtime.js";
|
|
2
2
|
import { defaultScheduler } from "./scheduler.js";
|
|
3
|
-
|
|
3
|
+
// src/mount-strategies.ts
|
|
4
4
|
/** The one scope `interaction` takes; bare `interaction` is the element. */
|
|
5
5
|
const PAGE_SCOPE = "page";
|
|
6
6
|
/**
|
|
@@ -207,7 +207,6 @@ function applyMountStrategy(el, strategy, { mount, unmount }) {
|
|
|
207
207
|
eagerWork: task.promise
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
//#endregion
|
|
211
210
|
export { applyMountStrategy, mountStrategyBehaviour };
|
|
212
211
|
|
|
213
212
|
//# sourceMappingURL=mount-strategies.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/negotiated-events.d.ts
|
|
2
1
|
/** The DOM change itself: whatever the announcing component was about to do. */
|
|
3
2
|
type DomMutation = () => void | Promise<void>;
|
|
4
3
|
/** An object that can run a DOM change inside a transition. */
|
|
@@ -39,5 +38,4 @@ declare function domUpdate(target: Node, mutate: DomMutation, detail?: Record<st
|
|
|
39
38
|
* @link https://js-toolkit-v4.studiometa.dev/api/dom/emitExtendable.html
|
|
40
39
|
*/
|
|
41
40
|
declare function emitExtendable(target: Node, event: string, detail?: Record<string, unknown>): Promise<void>;
|
|
42
|
-
//#endregion
|
|
43
41
|
export { DomMutation, DomUpdateDetail, DomUpdateRunner, DomUpdateTransitioner, ExtendableDetail, ExtendableTransitioner, Extension, domUpdate, emitExtendable };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { reportDiagnostic, warnOnce } from "./diagnostics.js";
|
|
2
2
|
import { EVENTS } from "./events.js";
|
|
3
|
-
|
|
3
|
+
// src/negotiated-events.ts
|
|
4
4
|
/** Emit a bubbling event and collect synchronous registrations. */
|
|
5
5
|
function negotiate({ target, event, key, detail, accept }) {
|
|
6
6
|
let isDispatching = true;
|
|
@@ -92,7 +92,6 @@ async function emitExtendable(target, event, detail) {
|
|
|
92
92
|
});
|
|
93
93
|
await Promise.all(pending);
|
|
94
94
|
}
|
|
95
|
-
//#endregion
|
|
96
95
|
export { domUpdate, emitExtendable };
|
|
97
96
|
|
|
98
97
|
//# sourceMappingURL=negotiated-events.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/protocol-symbols.d.ts
|
|
2
1
|
/** Realm-stable private key with a `unique symbol` type. */
|
|
3
2
|
declare const HANDLER_REGISTRATIONS: unique symbol;
|
|
4
3
|
/**
|
|
@@ -20,5 +19,4 @@ declare const HANDLER_REGISTRATIONS: unique symbol;
|
|
|
20
19
|
* `$0[Symbol.for('@studiometa/js-toolkit/instances')]`.
|
|
21
20
|
*/
|
|
22
21
|
declare const INSTANCES: unique symbol;
|
|
23
|
-
//#endregion
|
|
24
22
|
export { HANDLER_REGISTRATIONS, INSTANCES };
|
package/dist/protocol-symbols.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/protocol-symbols.ts
|
|
2
2
|
/** Realm-stable private key with a `unique symbol` type. */
|
|
3
3
|
const HANDLER_REGISTRATIONS = Symbol.for("@studiometa/js-toolkit/handler-registrations");
|
|
4
4
|
/**
|
|
@@ -20,7 +20,6 @@ const HANDLER_REGISTRATIONS = Symbol.for("@studiometa/js-toolkit/handler-registr
|
|
|
20
20
|
* `$0[Symbol.for('@studiometa/js-toolkit/instances')]`.
|
|
21
21
|
*/
|
|
22
22
|
const INSTANCES = Symbol.for("@studiometa/js-toolkit/instances");
|
|
23
|
-
//#endregion
|
|
24
23
|
export { HANDLER_REGISTRATIONS, INSTANCES };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=protocol-symbols.js.map
|
package/dist/registry.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MountStrategy } from "./mount-strategies.js";
|
|
2
2
|
import { BaseConstructor, ComponentImporter } from "./Base.js";
|
|
3
|
-
//#region src/registry.d.ts
|
|
4
3
|
/** A lazy component importer and its optional pre-load mount strategy. */
|
|
5
4
|
interface ComponentManifestEntry {
|
|
6
5
|
load: ComponentImporter;
|
|
@@ -64,5 +63,4 @@ declare function registerManifest(entries: ComponentManifest): void;
|
|
|
64
63
|
* ```
|
|
65
64
|
*/
|
|
66
65
|
declare function resetRegistry(): void;
|
|
67
|
-
//#endregion
|
|
68
66
|
export { type ComponentImporter, ComponentManifest, ComponentManifestEntry, registerComponent, registerComponents, registerManifest, resetRegistry };
|
package/dist/registry.js
CHANGED
|
@@ -11,7 +11,7 @@ import { INSTANCES } from "./protocol-symbols.js";
|
|
|
11
11
|
import { selectorFor } from "./utils/selectors.js";
|
|
12
12
|
import { declaresBoolean, resolveConfig } from "./Base.js";
|
|
13
13
|
import { applyMountStrategy, mountStrategyBehaviour } from "./mount-strategies.js";
|
|
14
|
-
|
|
14
|
+
// src/registry.ts
|
|
15
15
|
observeResponsiveAttribute(COMPONENT_ATTRIBUTE);
|
|
16
16
|
const registryState = /* @__PURE__ */ getSharedRuntimeSlot("registry", 2, () => ({
|
|
17
17
|
registry: /* @__PURE__ */ new Map(),
|
|
@@ -436,7 +436,6 @@ function processMutations(records) {
|
|
|
436
436
|
applyOptionChanges(changes);
|
|
437
437
|
scanAddedNodes(records);
|
|
438
438
|
}
|
|
439
|
-
//#endregion
|
|
440
439
|
export { registerComponent, registerComponents, registerManifest, resetRegistry };
|
|
441
440
|
|
|
442
441
|
//# sourceMappingURL=registry.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/responsive-options.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* Exact scoped spellings used by declaration cascades and observer filters.
|
|
4
3
|
* @internal
|
|
@@ -30,5 +29,4 @@ declare function responsiveScopedRawValue(attribute: string, breakpoint: string,
|
|
|
30
29
|
declare function watchBreakpoint(callback: (previous: string) => void): () => void;
|
|
31
30
|
/** Warn once for each responsive attribute suffix that names no breakpoint. */
|
|
32
31
|
declare function checkResponsiveAttributes(el: HTMLElement, attributes: readonly string[]): void;
|
|
33
|
-
//#endregion
|
|
34
32
|
export { activeBreakpoint, checkResponsiveAttributes, observeResponsiveAttribute, responsiveAttributeNames, responsiveRawValue, responsiveScopedRawValue, watchBreakpoint };
|
|
@@ -4,7 +4,7 @@ import { getSharedRuntimeSlot } from "./shared-runtime.js";
|
|
|
4
4
|
import { warnOnce } from "./diagnostics.js";
|
|
5
5
|
import { registerDOMOptionAttributes, replaceDOMOptionAttributes } from "./dom-mutations.js";
|
|
6
6
|
import { breakpointNames, onBreakpointsReplaced, useBreakpoint } from "./services/breakpoint.js";
|
|
7
|
-
|
|
7
|
+
// src/responsive-options.ts
|
|
8
8
|
/**
|
|
9
9
|
* Responsive options cascade from the active breakpoint through narrower breakpoints to the unsuffixed base value.
|
|
10
10
|
*
|
|
@@ -100,7 +100,6 @@ function checkResponsiveAttributes(el, attributes) {
|
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
//#endregion
|
|
104
103
|
export { activeBreakpoint, checkResponsiveAttributes, observeResponsiveAttribute, responsiveAttributeNames, responsiveRawValue, responsiveScopedRawValue, watchBreakpoint };
|
|
105
104
|
|
|
106
105
|
//# sourceMappingURL=responsive-options.js.map
|
package/dist/scheduler.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/scheduler.d.ts
|
|
2
1
|
type SchedulerPhase = 'idle' | 'tick' | 'read' | 'write' | 'background';
|
|
3
2
|
/** Frame timestamp and elapsed time clamped to `[1, 40]` ms. */
|
|
4
3
|
interface TickProps {
|
|
@@ -47,5 +46,4 @@ declare const defaultScheduler: Scheduler;
|
|
|
47
46
|
* @link https://js-toolkit-v4.studiometa.dev/api/scheduler/nextFrame.html
|
|
48
47
|
*/
|
|
49
48
|
declare function nextFrame(): Promise<void>;
|
|
50
|
-
//#endregion
|
|
51
49
|
export { ScheduledTask, Scheduler, SchedulerPhase, TickCallback, TickProps, defaultScheduler, nextFrame };
|
package/dist/scheduler.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getSharedRuntimeSlot } from "./shared-runtime.js";
|
|
2
2
|
import { reportDiagnostic } from "./diagnostics.js";
|
|
3
|
-
|
|
3
|
+
// src/scheduler.ts
|
|
4
4
|
/** Background work budget per turn, measured from the drain start. */
|
|
5
5
|
const BACKGROUND_BUDGET = 5;
|
|
6
6
|
/** Clamp frame deltas to prevent jumps after long pauses. */
|
|
@@ -211,7 +211,6 @@ const defaultScheduler = /* @__PURE__ */ getSharedRuntimeSlot("scheduler:default
|
|
|
211
211
|
function nextFrame() {
|
|
212
212
|
return new Promise((resolve) => requestAnimationFrame(() => resolve()));
|
|
213
213
|
}
|
|
214
|
-
//#endregion
|
|
215
214
|
export { Scheduler, defaultScheduler, nextFrame };
|
|
216
215
|
|
|
217
216
|
//# sourceMappingURL=scheduler.js.map
|
package/dist/scheduler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduler.js","names":["#phase","#tickCallbacks","#lastFrameTime","#schedule","#add","#isIdle","#idleResolvers","#queues","#scheduleBackground","#isScheduled","#flush","#isBackgroundScheduled","#drainBackground","#run","#resolveIdle","#clampDelta","#hasFrameWork"],"sources":["../src/scheduler.ts"],"sourcesContent":["import { reportDiagnostic } from './diagnostics.js';\nimport { getSharedRuntimeSlot } from './shared-runtime.js';\n\n/** Background work budget per turn, measured from the drain start. */\nconst BACKGROUND_BUDGET = 5;\n\n/** Clamp frame deltas to prevent jumps after long pauses. */\nconst MIN_DELTA = 1;\nconst MAX_DELTA = 40;\n\n/** The first tick uses one 60 Hz frame because no prior timestamp exists. */\nconst DEFAULT_DELTA = 1000 / 60;\n\nexport type SchedulerPhase = 'idle' | 'tick' | 'read' | 'write' | 'background';\n\ntype QueueName = 'read' | 'write' | 'background';\n\n/** Queued frame phases in execution order. */\nconst FRAME_PHASES = ['read', 'write'] as const;\n\n/** Frame timestamp and elapsed time clamped to `[1, 40]` ms. */\nexport interface TickProps {\n readonly time: DOMHighResTimeStamp;\n readonly delta: number;\n}\n\nexport type TickCallback = (props: TickProps) => void;\n\n/** Pending background turns, and the port that runs them. */\nconst turns: Array<() => void> = [];\nlet channel: MessageChannel | undefined;\n\n/** Post background work through `scheduler.postTask`, with a `MessageChannel` fallback. */\nfunction postMessageTask(run: () => void): void {\n // Open the channel lazily so importing the module does not open a port.\n if (!channel) {\n channel = new MessageChannel();\n channel.port1.onmessage = () => turns.shift()?.();\n }\n turns.push(run);\n channel.port2.postMessage(null);\n}\n\nfunction postBackgroundTask(run: () => void): void {\n // Use the platform scheduler, not this module's scheduler.\n const nativeScheduler = globalThis.scheduler;\n if (typeof nativeScheduler?.postTask === 'function') {\n nativeScheduler.postTask(run, { priority: 'background' }).catch((error: unknown) => {\n reportDiagnostic(\n 'scheduler.background-post-failed',\n 'The native scheduler rejected a background post.',\n error,\n );\n postMessageTask(run);\n });\n return;\n }\n\n postMessageTask(run);\n}\n\n/**\n * Cancelable handle returned for every scheduled task. The promise resolves\n * with the task's return value, or `undefined` when the task was canceled.\n */\nexport interface ScheduledTask<T = unknown> {\n promise: Promise<T | undefined>;\n cancel(): void;\n}\n\ninterface QueueItem {\n fn: () => unknown;\n isCanceled: boolean;\n resolve: (value: unknown) => void;\n reject: (reason: unknown) => void;\n}\n\n/**\n * Frame-aligned scheduler with `tick → read → write` phases and an off-frame background lane.\n *\n * Tasks added to the active or completed phase wait for the next frame. Writes added during reads run in the same frame. Background work never requests a frame.\n */\nexport class Scheduler {\n #queues: Record<QueueName, QueueItem[]> = {\n read: [],\n write: [],\n background: [],\n };\n\n #phase: SchedulerPhase = 'idle';\n\n #isScheduled = false;\n\n #isBackgroundScheduled = false;\n\n #idleResolvers: Array<() => void> = [];\n\n #tickCallbacks = new Set<TickCallback>();\n\n /**\n * `-1` while nothing is subscribed, so the first tick after the loop wakes\n * reports `DEFAULT_DELTA` instead of a measurement it cannot make.\n */\n #lastFrameTime = -1;\n\n get phase(): SchedulerPhase {\n return this.#phase;\n }\n\n /**\n * Subscribe before the read phase. Tick subscribers do not keep `whenIdle()` pending.\n *\n * @returns Unsubscribe.\n */\n tick(callback: TickCallback): () => void {\n if (this.#tickCallbacks.size === 0) {\n this.#lastFrameTime = -1;\n }\n this.#tickCallbacks.add(callback);\n this.#schedule();\n return () => {\n this.#tickCallbacks.delete(callback);\n };\n }\n\n read<T>(fn: () => T): ScheduledTask<T> {\n return this.#add('read', fn);\n }\n\n write<T>(fn: () => T): ScheduledTask<T> {\n return this.#add('write', fn);\n }\n\n /** Schedule time-sliced low-priority work outside animation frames. */\n background<T>(fn: () => T): ScheduledTask<T> {\n return this.#add('background', fn);\n }\n\n /**\n * Resolves once every queue is empty and no flush is scheduled.\n */\n whenIdle(): Promise<void> {\n if (this.#isIdle()) {\n return Promise.resolve();\n }\n return new Promise((resolve) => this.#idleResolvers.push(resolve));\n }\n\n /**\n * Idleness is about queued tasks only: a tick subscription keeps the loop\n * running forever by design, and a live service must not make\n * `whenIdle()` wait for a queue that will never be the reason it resolves.\n */\n #isIdle(): boolean {\n return Object.values(this.#queues).every((queue) => queue.length === 0);\n }\n\n #add<T>(queueName: QueueName, fn: () => T): ScheduledTask<T> {\n let resolve!: (value: unknown) => void;\n let reject!: (reason: unknown) => void;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n // Mark the rejection as handled so callers that do not await never\n // trigger an unhandled rejection; awaiting callers still get the error.\n promise.catch(() => {});\n const item: QueueItem = { fn, isCanceled: false, resolve, reject };\n this.#queues[queueName].push(item);\n if (queueName === 'background') {\n this.#scheduleBackground();\n } else {\n this.#schedule();\n }\n return {\n promise: promise as Promise<T | undefined>,\n cancel() {\n item.isCanceled = true;\n },\n };\n }\n\n #schedule(): void {\n if (this.#isScheduled) {\n return;\n }\n this.#isScheduled = true;\n // Preserve the rAF timestamp for all callbacks in this frame.\n requestAnimationFrame((frameTime) => this.#flush(frameTime));\n }\n\n #scheduleBackground(): void {\n if (this.#isBackgroundScheduled) {\n return;\n }\n this.#isBackgroundScheduled = true;\n postBackgroundTask(() => this.#drainBackground());\n }\n\n /**\n * One background turn: run tasks until the time slice runs out, then hand\n * the thread back and post the next turn. The slice is measured from the\n * start of the drain, so a busy frame cannot spend the lane's budget.\n */\n #drainBackground(): void {\n this.#isBackgroundScheduled = false;\n const start = performance.now();\n const queue = this.#queues.background;\n\n this.#phase = 'background';\n while (queue.length > 0 && performance.now() - start < BACKGROUND_BUDGET) {\n this.#run(queue.shift() as QueueItem);\n }\n this.#phase = 'idle';\n\n if (queue.length > 0) {\n this.#scheduleBackground();\n }\n this.#resolveIdle();\n }\n\n #flush(frameTime: DOMHighResTimeStamp): void {\n this.#isScheduled = false;\n\n if (this.#tickCallbacks.size > 0) {\n this.#phase = 'tick';\n const props: TickProps = {\n time: frameTime,\n delta: this.#clampDelta(frameTime),\n };\n this.#lastFrameTime = frameTime;\n const callbacks = [...this.#tickCallbacks];\n for (const callback of callbacks) {\n // A subscription starts on the next frame. An unsubscribe takes\n // effect at once, including before the callback's turn in this tick.\n if (!this.#tickCallbacks.has(callback)) {\n continue;\n }\n try {\n callback(props);\n } catch (error) {\n // Reported and skipped, never unsubscribed: a subscription is\n // owned by whoever created it, not by the frame that broke.\n reportDiagnostic(\n 'callback.scheduler-tick-failed',\n 'A scheduler tick callback failed.',\n error,\n );\n }\n }\n }\n\n // Swap each phase queue before execution to prevent same-phase reentry.\n for (const phase of FRAME_PHASES) {\n this.#phase = phase;\n const batch = this.#queues[phase];\n this.#queues[phase] = [];\n for (const item of batch) {\n this.#run(item);\n }\n }\n\n this.#phase = 'idle';\n\n // The rAF loop exists for rendering work only. A pending background\n // task must not hold a frame open — it drains on its own turns.\n if (this.#hasFrameWork() || this.#tickCallbacks.size > 0) {\n this.#schedule();\n }\n this.#resolveIdle();\n }\n\n #hasFrameWork(): boolean {\n return FRAME_PHASES.some((phase) => this.#queues[phase].length > 0);\n }\n\n #clampDelta(frameTime: DOMHighResTimeStamp): number {\n if (this.#lastFrameTime < 0) {\n return DEFAULT_DELTA;\n }\n return Math.min(Math.max(frameTime - this.#lastFrameTime, MIN_DELTA), MAX_DELTA);\n }\n\n #resolveIdle(): void {\n if (this.#idleResolvers.length === 0 || !this.#isIdle()) {\n return;\n }\n const resolvers = this.#idleResolvers;\n this.#idleResolvers = [];\n for (const resolve of resolvers) {\n resolve();\n }\n }\n\n #run(item: QueueItem): void {\n if (item.isCanceled) {\n item.resolve(undefined);\n return;\n }\n try {\n item.resolve(item.fn());\n } catch (error) {\n // The task's promise keeps the original rejection for its owner. The\n // diagnostic reports the recovered scheduler failure independently.\n reportDiagnostic('callback.scheduled-task-failed', 'A scheduled task failed.', error);\n item.reject(error);\n }\n }\n}\n\n/**\n * The one frame-aligned scheduler: the clock of the framework.\n * @link https://js-toolkit-v4.studiometa.dev/api/scheduler/defaultScheduler.html\n */\nexport const defaultScheduler = /* @__PURE__ */ getSharedRuntimeSlot(\n 'scheduler:default',\n 1,\n () => new Scheduler(),\n);\n\n/**\n * Await the next animation frame.\n * @link https://js-toolkit-v4.studiometa.dev/api/scheduler/nextFrame.html\n */\nexport function nextFrame(): Promise<void> {\n return new Promise((resolve) => requestAnimationFrame(() => resolve()));\n}\n"],"mappings":";;;;AAIA,MAAM,oBAAoB;;AAG1B,MAAM,YAAY;AAClB,MAAM,YAAY;;AAGlB,MAAM,gBAAgB,MAAO;;AAO7B,MAAM,eAAe,CAAC,QAAQ,OAAO;;AAWrC,MAAM,QAA2B,CAAC;AAClC,IAAI;;AAGJ,SAAS,gBAAgB,KAAuB;CAE9C,IAAI,CAAC,SAAS;EACZ,UAAU,IAAI,eAAe;EAC7B,QAAQ,MAAM,kBAAkB,MAAM,MAAM,CAAC,GAAG;CAClD;CACA,MAAM,KAAK,GAAG;CACd,QAAQ,MAAM,YAAY,IAAI;AAChC;AAEA,SAAS,mBAAmB,KAAuB;CAEjD,MAAM,kBAAkB,WAAW;CACnC,IAAI,OAAO,iBAAiB,aAAa,YAAY;EACnD,gBAAgB,SAAS,KAAK,EAAE,UAAU,aAAa,CAAC,CAAC,CAAC,OAAO,UAAmB;GAClF,iBACE,oCACA,oDACA,KACF;GACA,gBAAgB,GAAG;EACrB,CAAC;EACD;CACF;CAEA,gBAAgB,GAAG;AACrB;;;;;;AAuBA,IAAa,YAAb,MAAuB;CACrB,UAA0C;EACxC,MAAM,CAAC;EACP,OAAO,CAAC;EACR,YAAY,CAAC;CACf;CAEA,SAAyB;CAEzB,eAAe;CAEf,yBAAyB;CAEzB,iBAAoC,CAAC;CAErC,iCAAiB,IAAI,IAAkB;;;;;CAMvC,iBAAiB;CAEjB,IAAI,QAAwB;EAC1B,OAAO,KAAKA;CAC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AqB;EACnB,IAAI,KAAKI,eAAe,WAAW,KAAK,CAAC,KAAKD,QAAQ,GACpD;EAEF,MAAM,YAAY,KAAKC;EACvB,KAAKA,iBAAiB,CAAC;EACvB,KAAK,MAAM,WAAW,WACpB,QAAQ;CAEZ;CAEA,KAAK,MAAuB;EAC1B,IAAI,KAAK,YAAY;GACnB,KAAK,QAAQ,KAAA,CAAS;GACtB;EACF;EACA,IAAI;GACF,KAAK,QAAQ,KAAK,GAAG,CAAC;EACxB,SAAS,OAAO;GAGd,iBAAiB,kCAAkC,4BAA4B,KAAK;GACpF,KAAK,OAAO,KAAK;EACnB;CACF;AACF;;;;;AAMA,MAAa,mBAAmC,qCAC9C,qBACA,SACM,IAAI,UAAU,CACtB;;;;;AAMA,SAAgB,YAA2B;CACzC,OAAO,IAAI,SAAS,YAAY,4BAA4B,QAAQ,CAAC,CAAC;AACxE"}
|
|
1
|
+
{"version":3,"file":"scheduler.js","names":[],"sources":["../src/scheduler.ts"],"sourcesContent":["import { reportDiagnostic } from './diagnostics.js';\nimport { getSharedRuntimeSlot } from './shared-runtime.js';\n\n/** Background work budget per turn, measured from the drain start. */\nconst BACKGROUND_BUDGET = 5;\n\n/** Clamp frame deltas to prevent jumps after long pauses. */\nconst MIN_DELTA = 1;\nconst MAX_DELTA = 40;\n\n/** The first tick uses one 60 Hz frame because no prior timestamp exists. */\nconst DEFAULT_DELTA = 1000 / 60;\n\nexport type SchedulerPhase = 'idle' | 'tick' | 'read' | 'write' | 'background';\n\ntype QueueName = 'read' | 'write' | 'background';\n\n/** Queued frame phases in execution order. */\nconst FRAME_PHASES = ['read', 'write'] as const;\n\n/** Frame timestamp and elapsed time clamped to `[1, 40]` ms. */\nexport interface TickProps {\n readonly time: DOMHighResTimeStamp;\n readonly delta: number;\n}\n\nexport type TickCallback = (props: TickProps) => void;\n\n/** Pending background turns, and the port that runs them. */\nconst turns: Array<() => void> = [];\nlet channel: MessageChannel | undefined;\n\n/** Post background work through `scheduler.postTask`, with a `MessageChannel` fallback. */\nfunction postMessageTask(run: () => void): void {\n // Open the channel lazily so importing the module does not open a port.\n if (!channel) {\n channel = new MessageChannel();\n channel.port1.onmessage = () => turns.shift()?.();\n }\n turns.push(run);\n channel.port2.postMessage(null);\n}\n\nfunction postBackgroundTask(run: () => void): void {\n // Use the platform scheduler, not this module's scheduler.\n const nativeScheduler = globalThis.scheduler;\n if (typeof nativeScheduler?.postTask === 'function') {\n nativeScheduler.postTask(run, { priority: 'background' }).catch((error: unknown) => {\n reportDiagnostic(\n 'scheduler.background-post-failed',\n 'The native scheduler rejected a background post.',\n error,\n );\n postMessageTask(run);\n });\n return;\n }\n\n postMessageTask(run);\n}\n\n/**\n * Cancelable handle returned for every scheduled task. The promise resolves\n * with the task's return value, or `undefined` when the task was canceled.\n */\nexport interface ScheduledTask<T = unknown> {\n promise: Promise<T | undefined>;\n cancel(): void;\n}\n\ninterface QueueItem {\n fn: () => unknown;\n isCanceled: boolean;\n resolve: (value: unknown) => void;\n reject: (reason: unknown) => void;\n}\n\n/**\n * Frame-aligned scheduler with `tick → read → write` phases and an off-frame background lane.\n *\n * Tasks added to the active or completed phase wait for the next frame. Writes added during reads run in the same frame. Background work never requests a frame.\n */\nexport class Scheduler {\n #queues: Record<QueueName, QueueItem[]> = {\n read: [],\n write: [],\n background: [],\n };\n\n #phase: SchedulerPhase = 'idle';\n\n #isScheduled = false;\n\n #isBackgroundScheduled = false;\n\n #idleResolvers: Array<() => void> = [];\n\n #tickCallbacks = new Set<TickCallback>();\n\n /**\n * `-1` while nothing is subscribed, so the first tick after the loop wakes\n * reports `DEFAULT_DELTA` instead of a measurement it cannot make.\n */\n #lastFrameTime = -1;\n\n get phase(): SchedulerPhase {\n return this.#phase;\n }\n\n /**\n * Subscribe before the read phase. Tick subscribers do not keep `whenIdle()` pending.\n *\n * @returns Unsubscribe.\n */\n tick(callback: TickCallback): () => void {\n if (this.#tickCallbacks.size === 0) {\n this.#lastFrameTime = -1;\n }\n this.#tickCallbacks.add(callback);\n this.#schedule();\n return () => {\n this.#tickCallbacks.delete(callback);\n };\n }\n\n read<T>(fn: () => T): ScheduledTask<T> {\n return this.#add('read', fn);\n }\n\n write<T>(fn: () => T): ScheduledTask<T> {\n return this.#add('write', fn);\n }\n\n /** Schedule time-sliced low-priority work outside animation frames. */\n background<T>(fn: () => T): ScheduledTask<T> {\n return this.#add('background', fn);\n }\n\n /**\n * Resolves once every queue is empty and no flush is scheduled.\n */\n whenIdle(): Promise<void> {\n if (this.#isIdle()) {\n return Promise.resolve();\n }\n return new Promise((resolve) => this.#idleResolvers.push(resolve));\n }\n\n /**\n * Idleness is about queued tasks only: a tick subscription keeps the loop\n * running forever by design, and a live service must not make\n * `whenIdle()` wait for a queue that will never be the reason it resolves.\n */\n #isIdle(): boolean {\n return Object.values(this.#queues).every((queue) => queue.length === 0);\n }\n\n #add<T>(queueName: QueueName, fn: () => T): ScheduledTask<T> {\n let resolve!: (value: unknown) => void;\n let reject!: (reason: unknown) => void;\n const promise = new Promise((res, rej) => {\n resolve = res;\n reject = rej;\n });\n // Mark the rejection as handled so callers that do not await never\n // trigger an unhandled rejection; awaiting callers still get the error.\n promise.catch(() => {});\n const item: QueueItem = { fn, isCanceled: false, resolve, reject };\n this.#queues[queueName].push(item);\n if (queueName === 'background') {\n this.#scheduleBackground();\n } else {\n this.#schedule();\n }\n return {\n promise: promise as Promise<T | undefined>,\n cancel() {\n item.isCanceled = true;\n },\n };\n }\n\n #schedule(): void {\n if (this.#isScheduled) {\n return;\n }\n this.#isScheduled = true;\n // Preserve the rAF timestamp for all callbacks in this frame.\n requestAnimationFrame((frameTime) => this.#flush(frameTime));\n }\n\n #scheduleBackground(): void {\n if (this.#isBackgroundScheduled) {\n return;\n }\n this.#isBackgroundScheduled = true;\n postBackgroundTask(() => this.#drainBackground());\n }\n\n /**\n * One background turn: run tasks until the time slice runs out, then hand\n * the thread back and post the next turn. The slice is measured from the\n * start of the drain, so a busy frame cannot spend the lane's budget.\n */\n #drainBackground(): void {\n this.#isBackgroundScheduled = false;\n const start = performance.now();\n const queue = this.#queues.background;\n\n this.#phase = 'background';\n while (queue.length > 0 && performance.now() - start < BACKGROUND_BUDGET) {\n this.#run(queue.shift() as QueueItem);\n }\n this.#phase = 'idle';\n\n if (queue.length > 0) {\n this.#scheduleBackground();\n }\n this.#resolveIdle();\n }\n\n #flush(frameTime: DOMHighResTimeStamp): void {\n this.#isScheduled = false;\n\n if (this.#tickCallbacks.size > 0) {\n this.#phase = 'tick';\n const props: TickProps = {\n time: frameTime,\n delta: this.#clampDelta(frameTime),\n };\n this.#lastFrameTime = frameTime;\n const callbacks = [...this.#tickCallbacks];\n for (const callback of callbacks) {\n // A subscription starts on the next frame. An unsubscribe takes\n // effect at once, including before the callback's turn in this tick.\n if (!this.#tickCallbacks.has(callback)) {\n continue;\n }\n try {\n callback(props);\n } catch (error) {\n // Reported and skipped, never unsubscribed: a subscription is\n // owned by whoever created it, not by the frame that broke.\n reportDiagnostic(\n 'callback.scheduler-tick-failed',\n 'A scheduler tick callback failed.',\n error,\n );\n }\n }\n }\n\n // Swap each phase queue before execution to prevent same-phase reentry.\n for (const phase of FRAME_PHASES) {\n this.#phase = phase;\n const batch = this.#queues[phase];\n this.#queues[phase] = [];\n for (const item of batch) {\n this.#run(item);\n }\n }\n\n this.#phase = 'idle';\n\n // The rAF loop exists for rendering work only. A pending background\n // task must not hold a frame open — it drains on its own turns.\n if (this.#hasFrameWork() || this.#tickCallbacks.size > 0) {\n this.#schedule();\n }\n this.#resolveIdle();\n }\n\n #hasFrameWork(): boolean {\n return FRAME_PHASES.some((phase) => this.#queues[phase].length > 0);\n }\n\n #clampDelta(frameTime: DOMHighResTimeStamp): number {\n if (this.#lastFrameTime < 0) {\n return DEFAULT_DELTA;\n }\n return Math.min(Math.max(frameTime - this.#lastFrameTime, MIN_DELTA), MAX_DELTA);\n }\n\n #resolveIdle(): void {\n if (this.#idleResolvers.length === 0 || !this.#isIdle()) {\n return;\n }\n const resolvers = this.#idleResolvers;\n this.#idleResolvers = [];\n for (const resolve of resolvers) {\n resolve();\n }\n }\n\n #run(item: QueueItem): void {\n if (item.isCanceled) {\n item.resolve(undefined);\n return;\n }\n try {\n item.resolve(item.fn());\n } catch (error) {\n // The task's promise keeps the original rejection for its owner. The\n // diagnostic reports the recovered scheduler failure independently.\n reportDiagnostic('callback.scheduled-task-failed', 'A scheduled task failed.', error);\n item.reject(error);\n }\n }\n}\n\n/**\n * The one frame-aligned scheduler: the clock of the framework.\n * @link https://js-toolkit-v4.studiometa.dev/api/scheduler/defaultScheduler.html\n */\nexport const defaultScheduler = /* @__PURE__ */ getSharedRuntimeSlot(\n 'scheduler:default',\n 1,\n () => new Scheduler(),\n);\n\n/**\n * Await the next animation frame.\n * @link https://js-toolkit-v4.studiometa.dev/api/scheduler/nextFrame.html\n */\nexport function nextFrame(): Promise<void> {\n return new Promise((resolve) => requestAnimationFrame(() => resolve()));\n}\n"],"mappings":";;;;AAIA,MAAM,oBAAoB;;AAG1B,MAAM,YAAY;AAClB,MAAM,YAAY;;AAGlB,MAAM,gBAAgB,MAAO;;AAO7B,MAAM,eAAe,CAAC,QAAQ,OAAO;;AAWrC,MAAM,QAA2B,CAAC;AAClC,IAAI;;AAGJ,SAAS,gBAAgB,KAAuB;CAE9C,IAAI,CAAC,SAAS;EACZ,UAAU,IAAI,eAAe;EAC7B,QAAQ,MAAM,kBAAkB,MAAM,MAAM,CAAC,GAAG;CAClD;CACA,MAAM,KAAK,GAAG;CACd,QAAQ,MAAM,YAAY,IAAI;AAChC;AAEA,SAAS,mBAAmB,KAAuB;CAEjD,MAAM,kBAAkB,WAAW;CACnC,IAAI,OAAO,iBAAiB,aAAa,YAAY;EACnD,gBAAgB,SAAS,KAAK,EAAE,UAAU,aAAa,CAAC,CAAC,CAAC,OAAO,UAAmB;GAClF,iBACE,oCACA,oDACA,KACF;GACA,gBAAgB,GAAG;EACrB,CAAC;EACD;CACF;CAEA,gBAAgB,GAAG;AACrB;;;;;;AAuBA,IA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AQ,MAAM,CAAC,SAAS,CAAC;CACpE;CAEA,YAAY,WAAwC;EAClD,IAAI,KAAK,iBAAiB,GACxB,OAAO;EAET,OAAO,KAAK,IAAI,KAAK,IAAI,YAAY,KAAK,gBAAgB,SAAS,GAAG,SAAS;CACjF;CAEA,eAAqB;EACnB,IAAI,KAAK,eAAe,WAAW,KAAK,CAAC,KAAK,QAAQ,GACpD;EAEF,MAAM,YAAY,KAAK;EACvB,KAAK,iBAAiB,CAAC;EACvB,KAAK,MAAM,WAAW,WACpB,QAAQ;CAEZ;CAEA,KAAK,MAAuB;EAC1B,IAAI,KAAK,YAAY;GACnB,KAAK,QAAQ,KAAA,CAAS;GACtB;EACF;EACA,IAAI;GACF,KAAK,QAAQ,KAAK,GAAG,CAAC;EACxB,SAAS,OAAO;GAGd,iBAAiB,kCAAkC,4BAA4B,KAAK;GACpF,KAAK,OAAO,KAAK;EACnB;CACF;AACF;;;;;AAMA,MAAa,mBAAmC,qCAC9C,qBACA,SACM,IAAI,UAAU,CACtB;;;;;AAMA,SAAgB,YAA2B;CACzC,OAAO,IAAI,SAAS,YAAY,4BAA4B,QAAQ,CAAC,CAAC;AACxE"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Service } from "./service.js";
|
|
2
|
-
//#region src/services/breakpoint.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* Default named viewport widths, ascending. Media-query `rem` uses the browser's initial font size, not the root element's computed size.
|
|
5
4
|
* @link https://js-toolkit-v4.studiometa.dev/api/dom/breakpoints.html
|
|
@@ -31,5 +30,4 @@ declare function onBreakpointsReplaced(callback: () => void): () => void;
|
|
|
31
30
|
* @link https://js-toolkit-v4.studiometa.dev/api/services/useBreakpoint.html
|
|
32
31
|
*/
|
|
33
32
|
declare function useBreakpoint(): Service<BreakpointProps>;
|
|
34
|
-
//#endregion
|
|
35
33
|
export { BREAKPOINTS, BreakpointProps, breakpointNames, getBreakpoints, onBreakpointsReplaced, setBreakpoints, useBreakpoint };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { memo } from "../utils/memo.js";
|
|
2
2
|
import { getSharedRuntimeSlot } from "../shared-runtime.js";
|
|
3
3
|
import { createService } from "./service.js";
|
|
4
|
-
|
|
4
|
+
// src/services/breakpoint.ts
|
|
5
5
|
/**
|
|
6
6
|
* Default named viewport widths, ascending. Media-query `rem` uses the browser's initial font size, not the root element's computed size.
|
|
7
7
|
* @link https://js-toolkit-v4.studiometa.dev/api/dom/breakpoints.html
|
|
@@ -124,7 +124,6 @@ function useBreakpoint() {
|
|
|
124
124
|
breakpointState.service ??= createBreakpointService();
|
|
125
125
|
return breakpointState.service;
|
|
126
126
|
}
|
|
127
|
-
//#endregion
|
|
128
127
|
export { BREAKPOINTS, breakpointNames, getBreakpoints, onBreakpointsReplaced, setBreakpoints, useBreakpoint };
|
|
129
128
|
|
|
130
129
|
//# sourceMappingURL=breakpoint.js.map
|
package/dist/services/drag.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Service } from "./service.js";
|
|
2
2
|
import { ServiceHandles, ServiceMixin, ServiceMixinOptions } from "./mixin.js";
|
|
3
|
-
//#region src/services/drag.d.ts
|
|
4
3
|
/** Anything that can be grabbed: an HTML element, or an SVG one. */
|
|
5
4
|
type DragTarget = HTMLElement | SVGElement;
|
|
6
5
|
/**
|
|
@@ -61,5 +60,4 @@ type DragMixinOptions = DragOptions & ServiceMixinOptions<DragTarget>;
|
|
|
61
60
|
* @link https://js-toolkit-v4.studiometa.dev/api/services/mixins.html
|
|
62
61
|
*/
|
|
63
62
|
declare const withDrag: ServiceMixin<DragHook & ServiceHandles<"dragged">, DragTarget, DragOptions>;
|
|
64
|
-
//#endregion
|
|
65
63
|
export { DRAG_MODES, DragHook, DragMixinOptions, DragMode, DragOptions, DragProps, DragTarget, useDrag, withDrag };
|
package/dist/services/drag.js
CHANGED
|
@@ -3,7 +3,7 @@ import { defaultScheduler } from "../scheduler.js";
|
|
|
3
3
|
import { createService, perTarget } from "./service.js";
|
|
4
4
|
import { INERTIA_FRAME, clampDampFactor, inertiaDecay, inertiaFinalValue, inertiaStep } from "../utils/maths.js";
|
|
5
5
|
import { createServiceMixin } from "./mixin.js";
|
|
6
|
-
|
|
6
|
+
// src/services/drag.ts
|
|
7
7
|
/**
|
|
8
8
|
* Drag lifecycle modes: `idle → start → drag → drop → inertia → stop → idle`.
|
|
9
9
|
* @link https://js-toolkit-v4.studiometa.dev/api/services/useDrag.html
|
|
@@ -265,7 +265,6 @@ const withDrag = /* @__PURE__ */ createServiceMixin({
|
|
|
265
265
|
target: (instance) => instance.$el,
|
|
266
266
|
use: (target, options) => useDrag(target, options)
|
|
267
267
|
});
|
|
268
|
-
//#endregion
|
|
269
268
|
export { DRAG_MODES, useDrag, withDrag };
|
|
270
269
|
|
|
271
270
|
//# sourceMappingURL=drag.js.map
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Service } from "./service.js";
|
|
2
2
|
import { ServiceHandles, ServiceMixin, ServiceMixinOptions } from "./mixin.js";
|
|
3
|
-
//#region src/services/in-view.d.ts
|
|
4
3
|
interface InViewProps {
|
|
5
4
|
/** Whether the target intersects its root, as the latest entry reports it. */
|
|
6
5
|
readonly isInView: boolean;
|
|
@@ -22,5 +21,4 @@ type InViewMixinOptions = IntersectionObserverInit & ServiceMixinOptions<Element
|
|
|
22
21
|
* @link https://js-toolkit-v4.studiometa.dev/api/services/mixins.html
|
|
23
22
|
*/
|
|
24
23
|
declare const withInView: ServiceMixin<InViewHook & ServiceHandles<"intersected">, Element, IntersectionObserverInit>;
|
|
25
|
-
//#endregion
|
|
26
24
|
export { InViewHook, InViewMixinOptions, InViewProps, useInView, withInView };
|
package/dist/services/in-view.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSharedRuntimeSlot } from "../shared-runtime.js";
|
|
2
2
|
import { createService, perTarget, stableKey } from "./service.js";
|
|
3
3
|
import { createServiceMixin } from "./mixin.js";
|
|
4
|
-
|
|
4
|
+
// src/services/in-view.ts
|
|
5
5
|
/** Give each observer root a stable serializable identity. */
|
|
6
6
|
function rootId(root, identity) {
|
|
7
7
|
let id = identity.ids.get(root);
|
|
@@ -77,7 +77,6 @@ const withInView = /* @__PURE__ */ createServiceMixin({
|
|
|
77
77
|
defaultImmediate: true,
|
|
78
78
|
use: (target, options) => useInView(target, options)
|
|
79
79
|
});
|
|
80
|
-
//#endregion
|
|
81
80
|
export { useInView, withInView };
|
|
82
81
|
|
|
83
82
|
//# sourceMappingURL=in-view.js.map
|
package/dist/services/key.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Service } from "./service.js";
|
|
2
2
|
import { ServiceHandles, ServiceMixin, ServiceMixinOptions } from "./mixin.js";
|
|
3
|
-
//#region src/services/key.d.ts
|
|
4
3
|
/** Anything a key event reaches: the document, an element, or the window. */
|
|
5
4
|
type KeyTarget = Document | Element | Window;
|
|
6
5
|
/**
|
|
@@ -66,5 +65,4 @@ type KeyMixinOptions = ServiceMixinOptions<KeyTarget>;
|
|
|
66
65
|
* @link https://js-toolkit-v4.studiometa.dev/api/services/mixins.html
|
|
67
66
|
*/
|
|
68
67
|
declare const withKey: ServiceMixin<KeyHook & ServiceHandles<"keyed">, KeyTarget, object>;
|
|
69
|
-
//#endregion
|
|
70
68
|
export { KEYS, Key, KeyFlags, KeyHook, KeyMixinOptions, KeyName, KeyProps, KeyTarget, useKey, withKey };
|