@studiometa/js-toolkit 4.0.0-alpha.1 → 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/README.md +10 -0
- 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 +6 -3
- package/skills/studiometa-js-toolkit/SKILL.md +87 -0
- package/skills/studiometa-js-toolkit/references/api/configuration.md +169 -0
- package/skills/studiometa-js-toolkit/references/api/context/createContext.md +46 -0
- package/skills/studiometa-js-toolkit/references/api/context/createGroup.md +67 -0
- package/skills/studiometa-js-toolkit/references/api/context/index.md +69 -0
- package/skills/studiometa-js-toolkit/references/api/context/injectContext.md +58 -0
- package/skills/studiometa-js-toolkit/references/api/context/injectContextSync.md +44 -0
- package/skills/studiometa-js-toolkit/references/api/context/provideContext.md +61 -0
- package/skills/studiometa-js-toolkit/references/api/context/provideRootContext.md +42 -0
- package/skills/studiometa-js-toolkit/references/api/context/signal.md +85 -0
- package/skills/studiometa-js-toolkit/references/api/context/subscribeContext.md +71 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/children.md +92 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/component.md +75 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/index.md +41 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/inject.md +73 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/on.md +149 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/provide.md +77 -0
- package/skills/studiometa-js-toolkit/references/api/decorators/read-write.md +93 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/DIAGNOSTICS.md +137 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/EVENTS.md +45 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/index.md +58 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/reportDiagnostic.md +67 -0
- package/skills/studiometa-js-toolkit/references/api/diagnostics/warn.md +54 -0
- package/skills/studiometa-js-toolkit/references/api/dom/breakpoints.md +81 -0
- package/skills/studiometa-js-toolkit/references/api/dom/domUpdate.md +70 -0
- package/skills/studiometa-js-toolkit/references/api/dom/emitExtendable.md +68 -0
- package/skills/studiometa-js-toolkit/references/api/dom/index.md +26 -0
- package/skills/studiometa-js-toolkit/references/api/dom/swap.md +105 -0
- package/skills/studiometa-js-toolkit/references/api/dom/watchAttributeNamespace.md +96 -0
- package/skills/studiometa-js-toolkit/references/api/dom/watchAttributes.md +56 -0
- package/skills/studiometa-js-toolkit/references/api/dom/whenDOMSettled.md +41 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-component.md +105 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-mount.md +69 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-option.md +106 -0
- package/skills/studiometa-js-toolkit/references/api/html/data-ref.md +63 -0
- package/skills/studiometa-js-toolkit/references/api/html/index.md +32 -0
- package/skills/studiometa-js-toolkit/references/api/index.md +73 -0
- package/skills/studiometa-js-toolkit/references/api/instance-events.md +75 -0
- package/skills/studiometa-js-toolkit/references/api/instance-methods.md +267 -0
- package/skills/studiometa-js-toolkit/references/api/instance-properties.md +90 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-events.md +149 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-lifecycle.md +90 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-options.md +96 -0
- package/skills/studiometa-js-toolkit/references/api/methods-hooks-services.md +164 -0
- package/skills/studiometa-js-toolkit/references/api/registry/defineManifest.md +57 -0
- package/skills/studiometa-js-toolkit/references/api/registry/fromMetaGlob.md +33 -0
- package/skills/studiometa-js-toolkit/references/api/registry/fromWebpackContext.md +37 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getInstance.md +52 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getInstances.md +48 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getMountedInstances.md +39 -0
- package/skills/studiometa-js-toolkit/references/api/registry/getUnmountedInstances.md +46 -0
- package/skills/studiometa-js-toolkit/references/api/registry/index.md +49 -0
- package/skills/studiometa-js-toolkit/references/api/registry/registerComponent.md +93 -0
- package/skills/studiometa-js-toolkit/references/api/registry/registerComponents.md +37 -0
- package/skills/studiometa-js-toolkit/references/api/registry/registerManifest.md +72 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/defaultScheduler.md +104 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/index.md +27 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/nextFrame.md +31 -0
- package/skills/studiometa-js-toolkit/references/api/scheduler/viewTransition.md +53 -0
- package/skills/studiometa-js-toolkit/references/api/services/createService.md +95 -0
- package/skills/studiometa-js-toolkit/references/api/services/createServiceMixin.md +81 -0
- package/skills/studiometa-js-toolkit/references/api/services/index.md +94 -0
- package/skills/studiometa-js-toolkit/references/api/services/mixins.md +148 -0
- package/skills/studiometa-js-toolkit/references/api/services/perTarget.md +65 -0
- package/skills/studiometa-js-toolkit/references/api/services/toggle.md +80 -0
- package/skills/studiometa-js-toolkit/references/api/services/until.md +44 -0
- package/skills/studiometa-js-toolkit/references/api/services/useBreakpoint.md +42 -0
- package/skills/studiometa-js-toolkit/references/api/services/useDrag.md +119 -0
- package/skills/studiometa-js-toolkit/references/api/services/useInView.md +64 -0
- package/skills/studiometa-js-toolkit/references/api/services/useKey.md +105 -0
- package/skills/studiometa-js-toolkit/references/api/services/useMediaQuery.md +45 -0
- package/skills/studiometa-js-toolkit/references/api/services/useMutation.md +69 -0
- package/skills/studiometa-js-toolkit/references/api/services/usePointer.md +91 -0
- package/skills/studiometa-js-toolkit/references/api/services/usePrefersReducedMotion.md +42 -0
- package/skills/studiometa-js-toolkit/references/api/services/useRaf.md +91 -0
- package/skills/studiometa-js-toolkit/references/api/services/useResize.md +60 -0
- package/skills/studiometa-js-toolkit/references/api/services/useScroll.md +88 -0
- package/skills/studiometa-js-toolkit/references/api/services/useScrollProgress.md +88 -0
- package/skills/studiometa-js-toolkit/references/api/services/useWindowScroll.md +25 -0
- package/skills/studiometa-js-toolkit/references/api/services/useWindowSize.md +25 -0
- package/skills/studiometa-js-toolkit/references/api/storage/createStorage.md +126 -0
- package/skills/studiometa-js-toolkit/references/api/storage/index.md +33 -0
- package/skills/studiometa-js-toolkit/references/api/storage/presets.md +58 -0
- package/skills/studiometa-js-toolkit/references/api/storage/providers.md +109 -0
- package/skills/studiometa-js-toolkit/references/api/test/index.md +214 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/attribute-grammar.md +93 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/mutation-engine.md +71 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/philosophy.md +78 -0
- package/skills/studiometa-js-toolkit/references/guide/concepts/the-registry.md +110 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/autoloading.md +104 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/handling-diagnostics.md +104 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/mount-strategies.md +95 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/scheduling-work.md +124 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/sharing-state.md +218 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/swapping-content.md +92 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/testing-components.md +137 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/typing-components.md +190 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/using-decorators.md +168 -0
- package/skills/studiometa-js-toolkit/references/guide/going-further/using-storage.md +125 -0
- package/skills/studiometa-js-toolkit/references/guide/index.md +163 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/installation.md +144 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/lifecycle-hooks.md +174 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/managing-components.md +229 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/managing-options.md +235 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/managing-refs.md +174 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/using-services.md +218 -0
- package/skills/studiometa-js-toolkit/references/guide/introduction/working-with-events.md +251 -0
- package/skills/studiometa-js-toolkit/references/guide/migration/v3-to-v4.md +373 -0
- package/skills/studiometa-js-toolkit/references/utils/css.md +98 -0
- package/skills/studiometa-js-toolkit/references/utils/dom.md +54 -0
- package/skills/studiometa-js-toolkit/references/utils/easings.md +217 -0
- package/skills/studiometa-js-toolkit/references/utils/focus.md +84 -0
- package/skills/studiometa-js-toolkit/references/utils/history.md +69 -0
- package/skills/studiometa-js-toolkit/references/utils/index.md +53 -0
- package/skills/studiometa-js-toolkit/references/utils/is.md +84 -0
- package/skills/studiometa-js-toolkit/references/utils/load.md +59 -0
- package/skills/studiometa-js-toolkit/references/utils/math.md +129 -0
- package/skills/studiometa-js-toolkit/references/utils/motion.md +218 -0
- package/skills/studiometa-js-toolkit/references/utils/objects.md +68 -0
- package/skills/studiometa-js-toolkit/references/utils/scroll.md +128 -0
- package/skills/studiometa-js-toolkit/references/utils/strings.md +176 -0
- package/skills/studiometa-js-toolkit/references/utils/timing.md +111 -0
- package/skills/studiometa-js-toolkit/references/utils/transitions.md +122 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Lifecycle hooks
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
mounted(): MountedReturn
|
|
5
|
+
unmounted(): void
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
type MountedReturn = void | (() => void) | MountedReturn[] | Promise<MountedReturn>;
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Both are meant to be overridden and neither needs a `super` call.
|
|
13
|
+
|
|
14
|
+
## `mounted()`
|
|
15
|
+
|
|
16
|
+
Runs when the element is in the document and the component's mount conditions are met. It runs **after** every `option<Name>Changed()` hook of the same cycle.
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
20
|
+
|
|
21
|
+
class Player extends Base {
|
|
22
|
+
static config = { name: 'Player' };
|
|
23
|
+
|
|
24
|
+
mounted() {
|
|
25
|
+
this.$el.setAttribute('aria-live', 'polite');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### It returns its cleanup
|
|
31
|
+
|
|
32
|
+
A function, an array of functions, sync or async. They run on the next `$unmount()`:
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import { Base, useScroll } from '@studiometa/js-toolkit';
|
|
36
|
+
|
|
37
|
+
class Header extends Base {
|
|
38
|
+
static config = { name: 'Header' };
|
|
39
|
+
|
|
40
|
+
mounted() {
|
|
41
|
+
return useScroll().subscribe(({ directionY }) => {
|
|
42
|
+
this.$el.classList.toggle('is-hidden', directionY > 0);
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
If an async `mounted()` resolves **after** the unmount, the cleanup runs immediately.
|
|
49
|
+
|
|
50
|
+
## `unmounted()`
|
|
51
|
+
|
|
52
|
+
Runs at the end of `$unmount()`, after the cycle's listeners are unbound, the `mounted()` cleanups have run and the scheduled tasks are cancelled.
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
56
|
+
|
|
57
|
+
class Player extends Base {
|
|
58
|
+
static config = { name: 'Player' };
|
|
59
|
+
|
|
60
|
+
unmounted() {
|
|
61
|
+
this.$el.removeAttribute('aria-live');
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
It stays available for the cases the returned cleanup does not fit. When both exist, the returned cleanup runs first.
|
|
67
|
+
|
|
68
|
+
## What triggers each
|
|
69
|
+
|
|
70
|
+
| Cause | Calls |
|
|
71
|
+
| ------------------------------------------- | --------------------------------------------- |
|
|
72
|
+
| the element enters the document | `mounted()` |
|
|
73
|
+
| a mount strategy's condition becomes true | `mounted()` |
|
|
74
|
+
| the element leaves the document | `unmounted()` |
|
|
75
|
+
| the component token leaves `data-component` | `unmounted()`, then the instance is dropped |
|
|
76
|
+
| a breakpoint withdraws the declaration | `unmounted()`, then the instance is dropped |
|
|
77
|
+
| a reversible strategy's condition ends | `unmounted()` |
|
|
78
|
+
| the node is **moved** | `unmounted()` then `mounted()`, same identity |
|
|
79
|
+
|
|
80
|
+
**Unmounting a parent does not unmount its children.**
|
|
81
|
+
|
|
82
|
+
## What is not a lifecycle hook
|
|
83
|
+
|
|
84
|
+
- **`updated()` does not exist.** For an option that chooses a resource, use [`option<Name>Changed()`](methods-hooks-options.md). For an attribute the framework does not read, use [`watchAttributes()`](dom/watchAttributes.md).
|
|
85
|
+
- **There is no permanent state.** A component never declares that its work is over. "Once per element" is a plain field — see [Lifecycle](../guide/introduction/lifecycle-hooks.md#do-this-once-per-element).
|
|
86
|
+
- **A service mixin never occupies either hook.** It overrides `$mount()`/`$unmount()`, so a class that writes its own `mounted()` without `super.mounted()` still subscribes.
|
|
87
|
+
|
|
88
|
+
## Failures
|
|
89
|
+
|
|
90
|
+
A hook that throws is reported once as `component.lifecycle-failed` and the cycle continues. It does not stop the other instances in the same batch.
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Options hooks
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
option<Name>Changed(change: OptionChange): OptionChangedReturn
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A declared method named after an option makes that option a **live effect**. A component without the convention pays no setup cost and reads its options directly.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { Base } from '@studiometa/js-toolkit';
|
|
13
|
+
|
|
14
|
+
function connect(url) {
|
|
15
|
+
return { dispose() {} };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
class Feed extends Base {
|
|
19
|
+
static config = {
|
|
20
|
+
name: 'Feed',
|
|
21
|
+
options: { source: String },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
optionSourceChanged({ value, previousValue, initial }) {
|
|
25
|
+
const connection = connect(value);
|
|
26
|
+
// The cleanup for *this* value.
|
|
27
|
+
return () => connection.dispose();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The method name is the option name in pascal case: `dragThreshold` is `optionDragThresholdChanged`.
|
|
33
|
+
|
|
34
|
+
## The payload
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
interface OptionChange<T = unknown> {
|
|
38
|
+
name: string;
|
|
39
|
+
value: T;
|
|
40
|
+
previousValue: T | undefined;
|
|
41
|
+
rawValue: string | null;
|
|
42
|
+
previousRawValue: string | null;
|
|
43
|
+
initial: boolean;
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
| Field | Meaning |
|
|
48
|
+
| ------------------ | ----------------------------------------------------- |
|
|
49
|
+
| `name` | the option name |
|
|
50
|
+
| `value` | the parsed value now |
|
|
51
|
+
| `previousValue` | the parsed value before, `undefined` on the first run |
|
|
52
|
+
| `rawValue` | the raw attribute string, `null` when absent |
|
|
53
|
+
| `previousRawValue` | the raw string before, `null` when it was absent |
|
|
54
|
+
| `initial` | `true` on the first run of a mount cycle |
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { Base, type OptionChange } from '@studiometa/js-toolkit';
|
|
58
|
+
|
|
59
|
+
class Feed extends Base {
|
|
60
|
+
static config = { name: 'Feed', options: { source: String } };
|
|
61
|
+
|
|
62
|
+
optionSourceChanged({ value, previousValue, initial }: OptionChange<string>) {
|
|
63
|
+
console.log(value, previousValue, initial);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## The return value
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
type OptionChangedReturn = void | (() => void);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Return a function to release what this value acquired. The previous cleanup runs **before** an update, and every active cleanup runs on `$unmount()`.
|
|
75
|
+
|
|
76
|
+
## When it runs
|
|
77
|
+
|
|
78
|
+
- **Before `mounted()`**, on each mount cycle, with `initial: true`.
|
|
79
|
+
- On an attribute change, once the batch is processed.
|
|
80
|
+
- On a **breakpoint crossing** that changes the resolved raw value.
|
|
81
|
+
- Removal of the attribute applies the declared default, which is a change like any other.
|
|
82
|
+
- A new mount starts each effect again with `initial: true`.
|
|
83
|
+
|
|
84
|
+
## Coalescing
|
|
85
|
+
|
|
86
|
+
Several writes to one attribute in one batch give **one** change, from the first old raw value to the final DOM value. A write that ends where it started is **not** a change.
|
|
87
|
+
|
|
88
|
+
The comparison uses raw strings, so a breakpoint crossing and an attribute write are the same kind of event. A crossing to the same resolved value announces nothing, and a write to `data-option-columns:s` while the viewport is at `l` announces nothing.
|
|
89
|
+
|
|
90
|
+
## What it costs
|
|
91
|
+
|
|
92
|
+
**A `matchMedia` subscription opens only for a component that declares one of these hooks.** `$unmount()` releases it. A page that only reads options holds no listener at all.
|
|
93
|
+
|
|
94
|
+
## Not for arbitrary attributes
|
|
95
|
+
|
|
96
|
+
This hook is for **declared options**. For an attribute the framework does not read, use [`watchAttributes()`](dom/watchAttributes.md), which shares the same coalescing rule and the same batch.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Services hooks
|
|
2
|
+
|
|
3
|
+
A service mixin binds one subscription per mount cycle, under the **one method name the service owns**. There is no `hook` option.
|
|
4
|
+
|
|
5
|
+
| Mixin | Hook | Props type |
|
|
6
|
+
| -------------------- | ---------------- | --------------------- |
|
|
7
|
+
| `withRaf` | `ticked` | `RafProps` |
|
|
8
|
+
| `withScroll` | `scrolled` | `ScrollProps` |
|
|
9
|
+
| `withResize` | `resized` | `ResizeProps` |
|
|
10
|
+
| `withPointer` | `moved` | `PointerProps` |
|
|
11
|
+
| `withDrag` | `dragged` | `DragProps` |
|
|
12
|
+
| `withKey` | `keyed` | `KeyProps` |
|
|
13
|
+
| `withInView` | `intersected` | `InViewProps` |
|
|
14
|
+
| `withMutation` | `mutated` | `MutationProps` |
|
|
15
|
+
| `withScrollProgress` | `scrolledInView` | `ScrollProgressProps` |
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import { Base, withScroll } from '@studiometa/js-toolkit';
|
|
21
|
+
|
|
22
|
+
class Header extends withScroll(Base) {
|
|
23
|
+
static config = { name: 'Header' };
|
|
24
|
+
|
|
25
|
+
scrolled({ y, directionY, isScrolling }) {
|
|
26
|
+
this.$el.classList.toggle('is-hidden', directionY > 0 && y > 100);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Mixins stack, and their `$services` keys accumulate:
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
import { Base, withRaf, withResize } from '@studiometa/js-toolkit';
|
|
35
|
+
|
|
36
|
+
class Parallax extends withRaf(withResize(Base)) {
|
|
37
|
+
static config = { name: 'Parallax' };
|
|
38
|
+
|
|
39
|
+
#height = 0;
|
|
40
|
+
|
|
41
|
+
resized({ height }) {
|
|
42
|
+
this.#height = height;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
ticked({ delta }) {
|
|
46
|
+
// …
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## A mixin never occupies a lifecycle hook
|
|
52
|
+
|
|
53
|
+
`mounted()` and `unmounted()` belong to the component author, so **nothing has to be chained**. A class that mixes a service in and writes its own `mounted()` without `super.mounted()` still subscribes: the framework's own `$mount()`/`$unmount()` pair carries the subscription.
|
|
54
|
+
|
|
55
|
+
The consequences are worth knowing:
|
|
56
|
+
|
|
57
|
+
- The subscription starts **once the whole of `mounted()` has run** — including an `immediate` first delivery, which therefore reaches a component that is fully set up.
|
|
58
|
+
- It is released **before `unmounted()`**, exactly where the mount cleanup used to release it.
|
|
59
|
+
- `$unmount()` releases unconditionally, so a manual subscription started outside a mount cycle is released too.
|
|
60
|
+
|
|
61
|
+
**A userland mixin still chains**
|
|
62
|
+
|
|
63
|
+
The rule is about what the mixin **overrides**, not about who wrote it. A mixin that puts its work in `mounted()` needs its subclasses to call `super.mounted()` — and the way not to need that is to override `$mount()`.
|
|
64
|
+
|
|
65
|
+
## Mixin options
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
interface ServiceMixinOptions<Target, Host = Base> {
|
|
69
|
+
target?: (instance: Host) => Target;
|
|
70
|
+
manual?: boolean;
|
|
71
|
+
immediate?: boolean;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**The options of a mixin are not the options of the service.** `target`, `manual` and `immediate` describe the subscription. They are removed before the underlying `use*()` call and they are absent from its options type.
|
|
76
|
+
|
|
77
|
+
A service's own options are passed in the same object and forwarded:
|
|
78
|
+
|
|
79
|
+
```js
|
|
80
|
+
class Slide extends withDrag(Base, { axis: 'x', inertia: false, immediate: true }) {}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### `target`
|
|
84
|
+
|
|
85
|
+
```js
|
|
86
|
+
withResize(Base, { target: (instance) => instance.$refs.inner });
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
A resolver that comes back with `undefined` or `null` reports `service.missing-target` and starts **no** subscription — because a renamed ref arrives here as nothing, and a service with a default target would otherwise observe the wrong thing and look like it worked.
|
|
90
|
+
|
|
91
|
+
A service whose **own** default target is nothing, like `withRaf`, is untouched.
|
|
92
|
+
|
|
93
|
+
**The resolver is typed against the host as declared**
|
|
94
|
+
|
|
95
|
+
A mixin is applied while the extends clause of its class is still being evaluated, so `withDrag(Base, …)` types its resolver against `Base`. A component reaching further names the shape it needs — `(instance as Base & { readonly target: HTMLElement }).target` — which is an assertion rather than a check. That is why core checks the result at runtime.
|
|
96
|
+
|
|
97
|
+
### `manual`
|
|
98
|
+
|
|
99
|
+
Declares the hook without running it. `$services.<hook>` is the switch:
|
|
100
|
+
|
|
101
|
+
```js
|
|
102
|
+
import { Base, withRaf } from '@studiometa/js-toolkit';
|
|
103
|
+
|
|
104
|
+
class SliderItem extends withRaf(Base, { manual: true }) {
|
|
105
|
+
static config = { name: 'SliderItem' };
|
|
106
|
+
|
|
107
|
+
ticked({ delta }) {}
|
|
108
|
+
|
|
109
|
+
onSelected() {
|
|
110
|
+
this.$services.ticked.start();
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
onSettled() {
|
|
114
|
+
this.$services.ticked.stop();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
`$services` is declared in the type as `ServiceHandles<'ticked'>`, so the key completes and a wrong name is a type error. Each handle is a [`Toggle`](services/toggle.md).
|
|
120
|
+
|
|
121
|
+
### `immediate`
|
|
122
|
+
|
|
123
|
+
Asks for the first delivery at subscribe time. The sources with a current value honour it; the ones without do nothing. `withInView` defaults it to `true`.
|
|
124
|
+
|
|
125
|
+
## `ticked` can return a render function
|
|
126
|
+
|
|
127
|
+
`withRaf` is the one hook whose return value is used: return a function and it runs in the `write` phase of the same frame.
|
|
128
|
+
|
|
129
|
+
```js
|
|
130
|
+
import { Base, withRaf } from '@studiometa/js-toolkit';
|
|
131
|
+
|
|
132
|
+
class Follower extends withRaf(Base) {
|
|
133
|
+
static config = { name: 'Follower' };
|
|
134
|
+
|
|
135
|
+
ticked({ delta }) {
|
|
136
|
+
const x = this.measure(delta);
|
|
137
|
+
return () => {
|
|
138
|
+
this.$el.style.transform = `translateX(${x}px)`;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
measure(delta) {
|
|
143
|
+
return delta;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The raf service collects the render functions of its callbacks and cancels a render whose subscriber left between the two phases.
|
|
149
|
+
|
|
150
|
+
## One hook per class, and that is the limit
|
|
151
|
+
|
|
152
|
+
A mixin binds one subscription, under one name, for each mount cycle. A component whose subscriptions are **one per markup declaration** — one per attribute, with its own modifiers and its own threshold, known only when the element is read — has no method to name and no fixed count. It calls `subscribe()` itself:
|
|
153
|
+
|
|
154
|
+
```js
|
|
155
|
+
mounted() {
|
|
156
|
+
return useScroll(this.$refs.panel).subscribe((props) => {});
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
`on<Event>` has the same shape: a handler name belongs to the class, while a set of events can be data. Neither limit is about a build step — `withRaf(Base)` is an ordinary call, and the name is fixed by how the class is written.
|
|
161
|
+
|
|
162
|
+
## Failures
|
|
163
|
+
|
|
164
|
+
A subscriber that throws is skipped and reported as `callback.service-failed`. Core dispatches the diagnostic first and calls `reportError()` only when no listener cancelled the event.
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# defineManifest
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
defineManifest({ modules, mountStrategy }: DefineManifestOptions): ComponentManifest
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Turns a map of module paths into a [manifest](registerManifest.md), deriving each `data-component` token from its path.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { defineManifest, fromMetaGlob, registerManifest } from '@studiometa/js-toolkit';
|
|
13
|
+
|
|
14
|
+
registerManifest(
|
|
15
|
+
defineManifest({
|
|
16
|
+
modules: fromMetaGlob(import.meta.glob('./components/*/index.js')),
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Parameters**
|
|
22
|
+
|
|
23
|
+
- `modules` (`ModuleRecord`) — a map of path to importer, from [`fromMetaGlob()`](fromMetaGlob.md), [`fromWebpackContext()`](fromWebpackContext.md), or written by hand.
|
|
24
|
+
- `mountStrategy` (`MountStrategy`, optional) — a package-wide default.
|
|
25
|
+
|
|
26
|
+
**Return value**
|
|
27
|
+
|
|
28
|
+
- `ComponentManifest`, ready for `registerManifest()`.
|
|
29
|
+
|
|
30
|
+
## Token derivation
|
|
31
|
+
|
|
32
|
+
The token is the file's base name, and **`index` falls back to the parent directory**:
|
|
33
|
+
|
|
34
|
+
| Path | Token |
|
|
35
|
+
| ------------------------------ | -------- |
|
|
36
|
+
| `./components/Slider.js` | `Slider` |
|
|
37
|
+
| `./components/Slider/index.js` | `Slider` |
|
|
38
|
+
| `./components/nav/Menu.js` | `Menu` |
|
|
39
|
+
|
|
40
|
+
Duplicate tokens give a warning and **keep the first path**.
|
|
41
|
+
|
|
42
|
+
## The package-wide strategy
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
defineManifest({
|
|
46
|
+
modules: fromMetaGlob(import.meta.glob('./components/*/index.js')),
|
|
47
|
+
mountStrategy: 'visible',
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Entry wrappers are emitted **only when the strategy is not `eager`**, so the default costs nothing in the output.
|
|
52
|
+
|
|
53
|
+
Any element still overrides it with `data-mount`, and a class's own `config.mountStrategy` takes over once it has loaded.
|
|
54
|
+
|
|
55
|
+
## What it is not
|
|
56
|
+
|
|
57
|
+
It carries the importer and the strategy, and nothing else. Informational metadata — `packageName`, `subpath`, `exportName`, `group`, `styles`, `integrations` — belongs in the output type of a generator, not in core.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# fromMetaGlob
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
fromMetaGlob(glob: Record<string, unknown>): ModuleRecord
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Adapts a Vite `import.meta.glob()` result for [`defineManifest()`](defineManifest.md).
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { defineManifest, fromMetaGlob, registerManifest } from '@studiometa/js-toolkit';
|
|
13
|
+
|
|
14
|
+
registerManifest(
|
|
15
|
+
defineManifest({
|
|
16
|
+
modules: fromMetaGlob(import.meta.glob('./components/*/index.js')),
|
|
17
|
+
}),
|
|
18
|
+
);
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Parameters**
|
|
22
|
+
|
|
23
|
+
- `glob` — the object `import.meta.glob()` returns, mapping each path to a lazy importer.
|
|
24
|
+
|
|
25
|
+
**Return value**
|
|
26
|
+
|
|
27
|
+
- `ModuleRecord` — a map of path to importer.
|
|
28
|
+
|
|
29
|
+
**Use the lazy form**
|
|
30
|
+
|
|
31
|
+
`import.meta.glob(pattern)` is lazy and gives one importer per path, which is the point. `import.meta.glob(pattern, { eager: true })` downloads everything up front, so a manifest built from it defers nothing — and the adapter **throws a `TypeError`** naming the first path that is not an importer function, rather than building a manifest that silently does nothing lazily.
|
|
32
|
+
|
|
33
|
+
The adapter adds **no bundler dependency**. It reads a plain object of functions, and core names Vite nowhere.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# fromWebpackContext
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
fromWebpackContext(context: WebpackContextLike): ModuleRecord
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Adapts an `import.meta.webpackContext()` result for [`defineManifest()`](defineManifest.md).
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
import { defineManifest, fromWebpackContext, registerManifest } from '@studiometa/js-toolkit';
|
|
13
|
+
|
|
14
|
+
registerManifest(
|
|
15
|
+
defineManifest({
|
|
16
|
+
modules: fromWebpackContext(
|
|
17
|
+
import.meta.webpackContext('./components', {
|
|
18
|
+
recursive: true,
|
|
19
|
+
regExp: /\/index\.js$/,
|
|
20
|
+
mode: 'lazy',
|
|
21
|
+
}),
|
|
22
|
+
),
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Parameters**
|
|
28
|
+
|
|
29
|
+
- `context` (`WebpackContextLike`) — anything with the `keys()` method and the callable shape of a webpack context.
|
|
30
|
+
|
|
31
|
+
**Return value**
|
|
32
|
+
|
|
33
|
+
- `ModuleRecord` — a map of path to a **deferred** importer, one per key.
|
|
34
|
+
|
|
35
|
+
The import of each key is deferred rather than performed, so nothing is downloaded when the manifest is built. Use `mode: 'lazy'` so webpack emits a chunk per module.
|
|
36
|
+
|
|
37
|
+
The adapter adds **no webpack dependency**. `WebpackContextLike` is a structural type, so the adapter is testable without a bundler and core names webpack nowhere.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# getInstance
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
getInstance<T extends Base = Base>(el: Element | null, name: string): T | undefined
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The instance of `name` on `el`, mounted or not.
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import { Base, getInstance } from '@studiometa/js-toolkit';
|
|
13
|
+
|
|
14
|
+
class Dialog extends Base {
|
|
15
|
+
static config = { name: 'Dialog' };
|
|
16
|
+
|
|
17
|
+
close() {}
|
|
18
|
+
}
|
|
19
|
+
// `el` may be null — a querySelector() result passes straight through.
|
|
20
|
+
const dialog = getInstance<Dialog>(document.querySelector('[data-component="Dialog"]'), 'Dialog');
|
|
21
|
+
|
|
22
|
+
if (dialog?.$isMounted) dialog.close();
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Parameters**
|
|
26
|
+
|
|
27
|
+
- `el` (`Element | null`) — the element to read.
|
|
28
|
+
- `name` (`string`) — the component name.
|
|
29
|
+
|
|
30
|
+
**Return value**
|
|
31
|
+
|
|
32
|
+
- `T | undefined`.
|
|
33
|
+
|
|
34
|
+
## Why it is a function of its own
|
|
35
|
+
|
|
36
|
+
One map read and no scan. The caller already holds the element and the name, so there is nothing left to search — which is what makes it different from a filter over [`getInstances()`](getInstances.md).
|
|
37
|
+
|
|
38
|
+
It is also the answer to "is this element's instance there yet", which every plural form loses by returning a list.
|
|
39
|
+
|
|
40
|
+
## Why `el` accepts `null` but the return is not
|
|
41
|
+
|
|
42
|
+
`el` accepts `null` so a `querySelector()` result can be passed straight through. The two ways of having no instance — no element, and an element without one — are the same answer to the caller, and `undefined` says it for both. Narrowing the parameter to `Element` would buy nothing back: the body reads an optional map either way, so the only thing a stricter type produces is a `!` at every call site asserting something the function never needed.
|
|
43
|
+
|
|
44
|
+
The **return** stays `T | undefined`, and that asymmetry is deliberate. An absent element is a fact the caller may reasonably not know; an absent instance is a fact the caller must handle.
|
|
45
|
+
|
|
46
|
+
## There is no `getMountedInstance`
|
|
47
|
+
|
|
48
|
+
The result is one object, so a caller who needs the live one reads `.$isMounted` on it. A second export would only hide that check behind an `undefined` that means two things.
|
|
49
|
+
|
|
50
|
+
## Detached elements
|
|
51
|
+
|
|
52
|
+
This form reads the element's instance map directly and never consults the DOM, so it answers for a detached element as readily as for a connected one.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# getInstances
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
getInstances<T extends Base = Base>(name: string, root?: ParentNode): T[]
|
|
5
|
+
getInstances<T extends Base = Base>(el: Element): T[]
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
**Every instance that exists** for a component name, mounted or not, in DOM order — or every instance on one element, in mount order.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { getInstances } from '@studiometa/js-toolkit';
|
|
14
|
+
|
|
15
|
+
const section = document.querySelector('section')!;
|
|
16
|
+
|
|
17
|
+
getInstances('Dialog'); // every Dialog in the document
|
|
18
|
+
getInstances('Dialog', section); // every Dialog built in a region
|
|
19
|
+
getInstances(section); // everything on one element
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Reach for it when the result is **counted or inspected**. When it is going to be _used_, prefer [`getMountedInstances()`](getMountedInstances.md) — every instance in that list has run `mounted()` and has not yet run `unmounted()`.
|
|
23
|
+
|
|
24
|
+
## The two overloads
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
(name: string, root?: ParentNode): T[]
|
|
28
|
+
(el: Element): T[]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
- **The name form** searches the descendants of `root`, which defaults to the document. `root` is a `ParentNode` and the call is `querySelectorAll`, so it never matches `root` itself.
|
|
32
|
+
- **The element form** reads the element's instance map directly and never consults the DOM, so it answers for a **detached** element as readily as for a connected one. The name form cannot: `document.querySelectorAll()` does not see a detached element. Pass the detached root as `root` when a name lookup has to reach inside it.
|
|
33
|
+
|
|
34
|
+
## How the narrowing works
|
|
35
|
+
|
|
36
|
+
`selectorFor(name)` over-matches on purpose — it lists the responsive spellings of `data-component` too — and **the instance-map read is what removes an inactive declaration**, because a breakpoint-withdrawn component is destroyed _and_ deleted from the map.
|
|
37
|
+
|
|
38
|
+
A matching element with no instance is skipped, and that is the whole narrowing. There is no mount filter, because it never did that work.
|
|
39
|
+
|
|
40
|
+
## Where the instances live
|
|
41
|
+
|
|
42
|
+
An element publishes its instances under `Symbol.for('@studiometa/js-toolkit/instances')`. That map is **not public API**; these four lookups are, and between them they express every read it answers. In a console:
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
$0[Symbol.for('@studiometa/js-toolkit/instances')];
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The element overload exists rather than a second export because both forms answer "which instances are there" and the argument picks the scope — and it keeps the map read in one place, which matters more now that the key is a symbol and no longer spellable as `el.__base__`.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# getMountedInstances
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
getMountedInstances<T extends Base = Base>(name: string, root?: ParentNode): T[]
|
|
5
|
+
getMountedInstances<T extends Base = Base>(el: Element): T[]
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
**The live instances** of a component name, in DOM order — or the live ones on one element, in mount order.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { getMountedInstances } from '@studiometa/js-toolkit';
|
|
14
|
+
|
|
15
|
+
// This is the safe list to call a method on.
|
|
16
|
+
getMountedInstances('Dialog').forEach((dialog) => dialog.$unmount());
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**This is the safe list to call a method on**: every instance in it has run `mounted()` and has not yet run `unmounted()`. Prefer it over [`getInstances()`](getInstances.md) whenever the result is going to be _used_ rather than counted or inspected.
|
|
20
|
+
|
|
21
|
+
## The two overloads
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
(name: string, root?: ParentNode): T[]
|
|
25
|
+
(el: Element): T[]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- **The name form** searches the descendants of `root`, which defaults to the document. `root` is a `ParentNode` and the call is `querySelectorAll`, so it never matches `root` itself.
|
|
29
|
+
- **The element form** reads the element's instance map directly and never consults the DOM, so it answers for a **detached** element as readily as for a connected one. The name form cannot: `document.querySelectorAll()` does not see a detached element. Pass the detached root as `root` when a name lookup has to reach inside it.
|
|
30
|
+
|
|
31
|
+
## How the narrowing works
|
|
32
|
+
|
|
33
|
+
`selectorFor(name)` over-matches on purpose — it lists the responsive spellings of `data-component` too — and **the instance-map read is what removes an inactive declaration**, because a breakpoint-withdrawn component is destroyed _and_ deleted from the map.
|
|
34
|
+
|
|
35
|
+
A matching element with no instance is skipped, and that is the whole narrowing. There is no mount filter, because it never did that work.
|
|
36
|
+
|
|
37
|
+
## There is no `getMountedInstance`
|
|
38
|
+
|
|
39
|
+
The singular [`getInstance()`](getInstance.md) returns one object, so a caller who needs the live one reads `.$isMounted` on it. A second export would only hide that check behind an `undefined` that means two things — no element, no instance, or an instance that is not mounted.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# getUnmountedInstances
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
getUnmountedInstances<T extends Base = Base>(name: string, root?: ParentNode): T[]
|
|
5
|
+
getUnmountedInstances<T extends Base = Base>(el: Element): T[]
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
The instances of a component name that **were built and are not mounted**, in DOM order — or the same on one element, in mount order.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```js
|
|
13
|
+
import { getUnmountedInstances } from '@studiometa/js-toolkit';
|
|
14
|
+
|
|
15
|
+
getUnmountedInstances('Video').length;
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What this population is
|
|
19
|
+
|
|
20
|
+
It is small and specific. It is what a **reversible** mount strategy leaves behind: `in-view` and `media:` unmount their instance when the condition stops holding and keep it for the crossing back, so the instance stays in the element's map with `$isMounted === false`.
|
|
21
|
+
|
|
22
|
+
A constructor that succeeded before a failing `mounted()` lands here too.
|
|
23
|
+
|
|
24
|
+
## What is _not_ here
|
|
25
|
+
|
|
26
|
+
- **A declaration whose class never arrived.** A lazy entry that has not loaded has no instance at all.
|
|
27
|
+
- **A declaration withdrawn by a breakpoint.** That instance is unmounted _and deleted_ from the map, so the name later declared again builds a new one.
|
|
28
|
+
- **A component still waiting on a mount strategy.** It has never been constructed.
|
|
29
|
+
|
|
30
|
+
Neither has an instance, so neither can be in a list of them.
|
|
31
|
+
|
|
32
|
+
## The two overloads
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
(name: string, root?: ParentNode): T[]
|
|
36
|
+
(el: Element): T[]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- **The name form** searches the descendants of `root`, which defaults to the document. `root` is a `ParentNode` and the call is `querySelectorAll`, so it never matches `root` itself.
|
|
40
|
+
- **The element form** reads the element's instance map directly and never consults the DOM, so it answers for a **detached** element as readily as for a connected one. The name form cannot: `document.querySelectorAll()` does not see a detached element. Pass the detached root as `root` when a name lookup has to reach inside it.
|
|
41
|
+
|
|
42
|
+
## How the narrowing works
|
|
43
|
+
|
|
44
|
+
`selectorFor(name)` over-matches on purpose — it lists the responsive spellings of `data-component` too — and **the instance-map read is what removes an inactive declaration**, because a breakpoint-withdrawn component is destroyed _and_ deleted from the map.
|
|
45
|
+
|
|
46
|
+
A matching element with no instance is skipped, and that is the whole narrowing. There is no mount filter, because it never did that work.
|