@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,137 @@
|
|
|
1
|
+
# DIAGNOSTICS
|
|
2
|
+
|
|
3
|
+
A deeply frozen object of every code the framework reports. `ToolkitDiagnosticCode` is the exact union of its strings, plus any `'<namespace>.<name>'` a consumer reports.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { DIAGNOSTICS } from '@studiometa/js-toolkit';
|
|
7
|
+
|
|
8
|
+
DIAGNOSTICS.component.loadFailed; // 'component.load-failed'
|
|
9
|
+
DIAGNOSTICS.responsive.unknownBreakpoint; // 'responsive.unknown-breakpoint'
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## `attribute`
|
|
13
|
+
|
|
14
|
+
| Key | Code | Reported when |
|
|
15
|
+
| ------------------ | ----------------------------- | --------------------------------------------------------------------------- |
|
|
16
|
+
| `unknownQualifier` | `attribute.unknown-qualifier` | a watched namespace with a finite vocabulary gets an unknown qualifier head |
|
|
17
|
+
|
|
18
|
+
## `callback`
|
|
19
|
+
|
|
20
|
+
Every one of these is **reported and continued**: the failing callback is skipped, the others run.
|
|
21
|
+
|
|
22
|
+
| Key | Code |
|
|
23
|
+
| -------------------------------- | -------------------------------------------- |
|
|
24
|
+
| `signalFailed` | `callback.signal-failed` |
|
|
25
|
+
| `contextSubscriptionFailed` | `callback.context-subscription-failed` |
|
|
26
|
+
| `contextTeardownFailed` | `callback.context-teardown-failed` |
|
|
27
|
+
| `attributeWatcherFailed` | `callback.attribute-watcher-failed` |
|
|
28
|
+
| `serviceFailed` | `callback.service-failed` |
|
|
29
|
+
| `schedulerTickFailed` | `callback.scheduler-tick-failed` |
|
|
30
|
+
| `scheduledTaskFailed` | `callback.scheduled-task-failed` |
|
|
31
|
+
| `domUpdateRunnerFailed` | `callback.dom-update-runner-failed` |
|
|
32
|
+
| `extendableEventExtensionFailed` | `callback.extendable-event-extension-failed` |
|
|
33
|
+
|
|
34
|
+
A scheduled task also **rejects its own promise** with the same value.
|
|
35
|
+
|
|
36
|
+
## `component`
|
|
37
|
+
|
|
38
|
+
| Key | Code | Reported when |
|
|
39
|
+
| -------------------------- | -------------------------------------- | ----------------------------------------------------------------- |
|
|
40
|
+
| `loadFailed` | `component.load-failed` | a lazy import fails — once per name, never retried |
|
|
41
|
+
| `mountFailed` | `component.mount-failed` | a mount fails |
|
|
42
|
+
| `lifecycleFailed` | `component.lifecycle-failed` | `mounted()` or `unmounted()` throws |
|
|
43
|
+
| `invalidMountStrategy` | `component.invalid-mount-strategy` | a `data-mount` value is unusable — the component stays unmounted |
|
|
44
|
+
| `invalidFamilyDeclaration` | `component.invalid-family-declaration` | a `config.components` value is neither a `Base` class nor a thunk |
|
|
45
|
+
| `configConflict` | `component.config-conflict` | `@component` and `static config` declare one key differently |
|
|
46
|
+
|
|
47
|
+
## `event`
|
|
48
|
+
|
|
49
|
+
| Key | Code | Reported when |
|
|
50
|
+
| -------------------- | ---------------------------- | ---------------------------------------------- |
|
|
51
|
+
| `invalidEmitPayload` | `event.invalid-emit-payload` | `$emit()` gets a payload that is not an object |
|
|
52
|
+
|
|
53
|
+
The event still dispatches.
|
|
54
|
+
|
|
55
|
+
## `manifest`
|
|
56
|
+
|
|
57
|
+
| Key | Code | Reported when |
|
|
58
|
+
| ---------------- | -------------------------- | ----------------------------------------- |
|
|
59
|
+
| `duplicateToken` | `manifest.duplicate-token` | a manifest declares a token already owned |
|
|
60
|
+
|
|
61
|
+
## `option`
|
|
62
|
+
|
|
63
|
+
| Key | Code | Reported when |
|
|
64
|
+
| ---------------- | ------------------------ | ---------------------------------------------------------- |
|
|
65
|
+
| `literalDefault` | `option.literal-default` | an `Array` or `Object` default is a literal, not a factory |
|
|
66
|
+
|
|
67
|
+
The value is then used as declared and **shared** between instances.
|
|
68
|
+
|
|
69
|
+
## `protocol`
|
|
70
|
+
|
|
71
|
+
| Key | Code | Reported when |
|
|
72
|
+
| -------------------- | ------------------------------- | ------------------------------------------------------------------- |
|
|
73
|
+
| `lateRegistration` | `protocol.late-registration` | a negotiated-event listener calls `wrap`/`waitUntil` after dispatch |
|
|
74
|
+
| `unappliedDomUpdate` | `protocol.unapplied-dom-update` | a claimed runner resolves without calling `apply` |
|
|
75
|
+
|
|
76
|
+
In both cases the change still happens.
|
|
77
|
+
|
|
78
|
+
## `ref`
|
|
79
|
+
|
|
80
|
+
| Key | Code | Reported when |
|
|
81
|
+
| ---------- | -------------- | ------------------------------------------------------------------------------------ |
|
|
82
|
+
| `mismatch` | `ref.mismatch` | `config.refs` and `data-ref` disagree on the `[]` suffix — once per instance and ref |
|
|
83
|
+
|
|
84
|
+
## `registry`
|
|
85
|
+
|
|
86
|
+
| Key | Code | Reported when |
|
|
87
|
+
| ------------------ | ----------------------------- | ----------------------------------------------------- |
|
|
88
|
+
| `conflict` | `registry.conflict` | a name is registered twice — the second is ignored |
|
|
89
|
+
| `lazyNameMismatch` | `registry.lazy-name-mismatch` | a loaded class's `config.name` differs from its token |
|
|
90
|
+
|
|
91
|
+
## `responsive`
|
|
92
|
+
|
|
93
|
+
| Key | Code | Reported when |
|
|
94
|
+
| ------------------- | ------------------------------- | --------------------------------------------------------------------------- |
|
|
95
|
+
| `unknownBreakpoint` | `responsive.unknown-breakpoint` | a `:<suffix>` names no configured breakpoint — including the v3 list syntax |
|
|
96
|
+
|
|
97
|
+
## `scheduler`
|
|
98
|
+
|
|
99
|
+
| Key | Code | Reported when |
|
|
100
|
+
| ---------------------- | ---------------------------------- | ---------------------------------- |
|
|
101
|
+
| `backgroundPostFailed` | `scheduler.background-post-failed` | a background turn cannot be posted |
|
|
102
|
+
|
|
103
|
+
## `service`
|
|
104
|
+
|
|
105
|
+
| Key | Code | Reported when |
|
|
106
|
+
| --------------- | ------------------------ | ---------------------------------------------------------------------------------------------------- |
|
|
107
|
+
| `missingTarget` | `service.missing-target` | a caller-supplied mixin `target` resolver returns `undefined` or `null` — **no subscription starts** |
|
|
108
|
+
|
|
109
|
+
## `storage`
|
|
110
|
+
|
|
111
|
+
| Key | Code | Reported when |
|
|
112
|
+
| ------------------- | ---------------------------- | ------------------------------------------------ |
|
|
113
|
+
| `accessFailed` | `storage.access-failed` | a provider's area is refused or full |
|
|
114
|
+
| `serializeFailed` | `storage.serialize-failed` | serialization throws — **nothing is written** |
|
|
115
|
+
| `deserializeFailed` | `storage.deserialize-failed` | deserialization throws — the default is returned |
|
|
116
|
+
|
|
117
|
+
## `swap`
|
|
118
|
+
|
|
119
|
+
| Key | Code | Reported when |
|
|
120
|
+
| ------------- | ------------------- | --------------------------------------------------------------------- |
|
|
121
|
+
| `selfIgnored` | `swap.self-ignored` | `self` is passed with `append`/`prepend`, or content holds no element |
|
|
122
|
+
|
|
123
|
+
## Consumer codes
|
|
124
|
+
|
|
125
|
+
`ToolkitDiagnosticCode` also accepts any `` `${string}.${string}` ``, so a consumer reports on the same channel with its own namespace:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import { warn } from '@studiometa/js-toolkit';
|
|
129
|
+
|
|
130
|
+
warn('carousel.no-slides', 'A Carousel with no slide does nothing.', { component: 'Carousel' });
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Import it on its own
|
|
134
|
+
|
|
135
|
+
```js
|
|
136
|
+
import { DIAGNOSTICS } from '@studiometa/js-toolkit/DIAGNOSTICS';
|
|
137
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# EVENTS
|
|
2
|
+
|
|
3
|
+
A deeply frozen object of the events the framework itself dispatches, all namespaced `js-toolkit:`.
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { EVENTS } from '@studiometa/js-toolkit';
|
|
7
|
+
|
|
8
|
+
EVENTS.component.mounted; // 'js-toolkit:component:mounted'
|
|
9
|
+
EVENTS.component.unmounted; // 'js-toolkit:component:unmounted'
|
|
10
|
+
EVENTS.dom.update; // 'js-toolkit:dom:update'
|
|
11
|
+
EVENTS.diagnostic; // 'js-toolkit:diagnostic'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## The events
|
|
15
|
+
|
|
16
|
+
| Constant | Name | Dispatched from | Cancelable |
|
|
17
|
+
| ---------------------------- | -------------------------------- | ------------------------- | ---------- |
|
|
18
|
+
| `EVENTS.component.mounted` | `js-toolkit:component:mounted` | the element, **bubbling** | no |
|
|
19
|
+
| `EVENTS.component.unmounted` | `js-toolkit:component:unmounted` | `document` | no |
|
|
20
|
+
| `EVENTS.dom.update` | `js-toolkit:dom:update` | the given node, bubbling | no |
|
|
21
|
+
| `EVENTS.diagnostic` | `js-toolkit:diagnostic` | the element or `document` | **yes** |
|
|
22
|
+
|
|
23
|
+
See [Instance events](../instance-events.md) for the lifecycle pair, [`domUpdate()`](../dom/domUpdate.md) for the update event, and [Diagnostics](index.md) for the diagnostic.
|
|
24
|
+
|
|
25
|
+
## The convention
|
|
26
|
+
|
|
27
|
+
- **Public framework events** use this object and the `js-toolkit:` namespace.
|
|
28
|
+
- **Private framework transports** use module-local namespaced constants and **do not join `EVENTS`** — the context request is one.
|
|
29
|
+
- **Component events** are typed lower-kebab string literals declared through the props type's `$emits` key. They have no namespace: a component event is `open`, not `js-toolkit:open`.
|
|
30
|
+
- A payload is **one object** in `CustomEvent.detail`, or the platform value `null`.
|
|
31
|
+
- Diagnostic events are cancelable, so monitoring can suppress the default output only.
|
|
32
|
+
|
|
33
|
+
Only what a consumer can usefully listen to is exported. That is the whole rule for whether something belongs here.
|
|
34
|
+
|
|
35
|
+
## Import it on its own
|
|
36
|
+
|
|
37
|
+
```js
|
|
38
|
+
import { EVENTS } from '@studiometa/js-toolkit/EVENTS';
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The generated subpath keeps the frozen object importable without the root barrel — which matters on a page with no build step, where a barrel import downloads the barrel's whole graph.
|
|
42
|
+
|
|
43
|
+
## `EVENTS.error` is removed
|
|
44
|
+
|
|
45
|
+
With **no alias**. `EVENTS.error`, `ToolkitErrorDetail` and `ToolkitErrorStage` are gone; `EVENTS.diagnostic` and the [`DIAGNOSTICS`](DIAGNOSTICS.md) codes replace them.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Diagnostics
|
|
2
|
+
|
|
3
|
+
Everything the framework recovers from is reported on **one** cancelable event, and nothing in core calls `console.warn()` or `console.error()` directly.
|
|
4
|
+
|
|
5
|
+
## The exports
|
|
6
|
+
|
|
7
|
+
- [`EVENTS`](EVENTS.md) — the framework event names
|
|
8
|
+
- [`DIAGNOSTICS`](DIAGNOSTICS.md) — every code
|
|
9
|
+
- [`reportDiagnostic(code, message, error, ctx?)`](reportDiagnostic.md) — report an error
|
|
10
|
+
- [`warn(code, message, ctx?)`](warn.md) — report a warning
|
|
11
|
+
|
|
12
|
+
From inside a component, `$warn()` and `$error()` fill the component name in.
|
|
13
|
+
|
|
14
|
+
## The detail
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
type ToolkitDiagnosticDetail =
|
|
18
|
+
| {
|
|
19
|
+
readonly severity: 'warning';
|
|
20
|
+
readonly code: ToolkitDiagnosticCode;
|
|
21
|
+
readonly message: string;
|
|
22
|
+
readonly component?: string;
|
|
23
|
+
readonly error?: never;
|
|
24
|
+
}
|
|
25
|
+
| {
|
|
26
|
+
readonly severity: 'error';
|
|
27
|
+
readonly code: ToolkitDiagnosticCode;
|
|
28
|
+
readonly message: string;
|
|
29
|
+
readonly component?: string;
|
|
30
|
+
readonly error: unknown;
|
|
31
|
+
};
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
An **error** detail requires the original caught value; a **warning** carries none. That is a union, not an optional field, so a listener that reads `detail.error` has already narrowed on `severity`.
|
|
35
|
+
|
|
36
|
+
## Listening
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import { DIAGNOSTICS, EVENTS, type ToolkitDiagnosticDetail } from '@studiometa/js-toolkit';
|
|
40
|
+
|
|
41
|
+
declare function monitor(code: string, detail: ToolkitDiagnosticDetail): void;
|
|
42
|
+
document.addEventListener(EVENTS.diagnostic, (rawEvent) => {
|
|
43
|
+
const event = rawEvent as CustomEvent<ToolkitDiagnosticDetail>;
|
|
44
|
+
monitor(event.detail.code, event.detail);
|
|
45
|
+
|
|
46
|
+
if (event.detail.code === DIAGNOSTICS.responsive.unknownBreakpoint) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Every diagnostic starts on its relevant connected element, or on `document` when there is none, with `{ bubbles: true, composed: true, cancelable: true }`.
|
|
53
|
+
|
|
54
|
+
**Dispatch always happens before the default output.** An uncancelled warning calls `console.warn()` once with exactly `[js-toolkit:<code>] <message>`; an uncancelled error calls `reportError(detail.error)` with the original value. `preventDefault()` suppresses **that output only** and changes no framework decision.
|
|
55
|
+
|
|
56
|
+
## Read next
|
|
57
|
+
|
|
58
|
+
[Diagnostics](../../guide/going-further/handling-diagnostics.md).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# reportDiagnostic
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
reportDiagnostic(
|
|
5
|
+
code: ToolkitDiagnosticCode,
|
|
6
|
+
message: string,
|
|
7
|
+
error: unknown,
|
|
8
|
+
context?: { component?: string; target?: Element },
|
|
9
|
+
): CustomEvent<ToolkitDiagnosticDetail>
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Reports an **error** on the diagnostic channel. The original caught value is required.
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { reportDiagnostic } from '@studiometa/js-toolkit';
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
JSON.parse('{');
|
|
21
|
+
} catch (error) {
|
|
22
|
+
reportDiagnostic('carousel.bad-config', 'The config attribute is not valid JSON.', error, {
|
|
23
|
+
component: 'Carousel',
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Parameters**
|
|
29
|
+
|
|
30
|
+
- `code` — a namespaced string. Core codes come from [`DIAGNOSTICS`](DIAGNOSTICS.md); a consumer uses its own `'<namespace>.<name>'`.
|
|
31
|
+
- `message` — one sentence, and it should say what to do about it.
|
|
32
|
+
- `error` — **required.** The original value, passed through untouched.
|
|
33
|
+
- `context.component` — the reporting component's name.
|
|
34
|
+
- `context.target` — the element to dispatch from. Defaults to `document`.
|
|
35
|
+
|
|
36
|
+
**Return value**
|
|
37
|
+
|
|
38
|
+
- the dispatched event, so a caller can read `defaultPrevented`.
|
|
39
|
+
|
|
40
|
+
## What happens
|
|
41
|
+
|
|
42
|
+
1. The event is dispatched — **always before any output** — with `{ bubbles: true, composed: true, cancelable: true }`.
|
|
43
|
+
2. If nothing cancelled it, `reportError(detail.error)` is called with the original value.
|
|
44
|
+
|
|
45
|
+
`preventDefault()` suppresses that call and nothing else.
|
|
46
|
+
|
|
47
|
+
## From a component
|
|
48
|
+
|
|
49
|
+
`$error(code, message, error)` is the same call with the component name filled in:
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
this.$error('carousel.bad-config', 'The config attribute is not valid JSON.', error);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## When to report and when to throw
|
|
56
|
+
|
|
57
|
+
| The failure is | Do |
|
|
58
|
+
| ---------------------------- | ------------------- |
|
|
59
|
+
| something you recovered from | report it |
|
|
60
|
+
| the caller's to handle | **throw or reject** |
|
|
61
|
+
|
|
62
|
+
Core follows the same rule: decorator and manifest-adapter misuse, shared-runtime incompatibility, service startup rollback, caller-owned teardown, `viewTransition()` and `swap()` all throw. A channel is for what was survived.
|
|
63
|
+
|
|
64
|
+
## See also
|
|
65
|
+
|
|
66
|
+
- [`warn()`](warn.md) — a warning, with no error value
|
|
67
|
+
- [`captureDiagnostics()`](../test/index.md) — reading the channel in a test
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# warn
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
warn(
|
|
5
|
+
code: ToolkitDiagnosticCode,
|
|
6
|
+
message: string,
|
|
7
|
+
context?: { component?: string; target?: Element },
|
|
8
|
+
): CustomEvent<ToolkitDiagnosticDetail>
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Reports a **warning** on the diagnostic channel. A warning carries no error value — that is the difference from [`reportDiagnostic()`](reportDiagnostic.md), and it is a union in the type rather than an optional field.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { warn } from '@studiometa/js-toolkit';
|
|
17
|
+
|
|
18
|
+
warn('carousel.no-slides', 'A Carousel with no slide does nothing. Add `data-component="Slide"`.', {
|
|
19
|
+
component: 'Carousel',
|
|
20
|
+
});
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Return value**
|
|
24
|
+
|
|
25
|
+
- the dispatched event, so a caller can read `defaultPrevented`.
|
|
26
|
+
|
|
27
|
+
## What happens
|
|
28
|
+
|
|
29
|
+
1. The event is dispatched — **always before any output**.
|
|
30
|
+
2. If nothing cancelled it, `console.warn()` is called **once**, with exactly `[js-toolkit:<code>] <message>`:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
[js-toolkit:option.literal-default] Panel: the `tween` option default must be a factory function.
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
That exact format is what makes the console output greppable and what lets a listener reproduce it.
|
|
37
|
+
|
|
38
|
+
## From a component
|
|
39
|
+
|
|
40
|
+
`$warn(code, message)` fills the component name in:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
this.$warn('carousel.no-slides', 'A Carousel with no slide does nothing.');
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Deduplication
|
|
47
|
+
|
|
48
|
+
Core's own warnings are deduplicated by weak owner plus a misuse key, in a revisioned shared-runtime slot — so a misuse is reported once per instance, per element or per declaration, and it works across independently evaluated copies of the package **without retaining** instances, elements, declarations, runners or manifest inputs.
|
|
49
|
+
|
|
50
|
+
The public `warn()` does not deduplicate. Call it where the condition is detected once.
|
|
51
|
+
|
|
52
|
+
## Write a message that says what to do
|
|
53
|
+
|
|
54
|
+
The framework's own messages name the component, the thing that is wrong and the correction — `option.literal-default` names the option and the factory form to write instead. A warning a reader cannot act on is noise on a channel meant for monitoring.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Breakpoints
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
BREAKPOINTS: Readonly<Record<string, string>>
|
|
5
|
+
getBreakpoints(): Record<string, string>
|
|
6
|
+
setBreakpoints(next: Record<string, string>): void
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The named breakpoint set is the single source of truth for every responsive spelling in the framework.
|
|
10
|
+
|
|
11
|
+
## The defaults
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import { BREAKPOINTS, getBreakpoints } from '@studiometa/js-toolkit';
|
|
15
|
+
|
|
16
|
+
getBreakpoints(); // the current set
|
|
17
|
+
BREAKPOINTS; // the defaults
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
| Name | Min width |
|
|
21
|
+
| ------ | --------- |
|
|
22
|
+
| `xxs` | `0rem` |
|
|
23
|
+
| `xs` | `30rem` |
|
|
24
|
+
| `s` | `48rem` |
|
|
25
|
+
| `m` | `64rem` |
|
|
26
|
+
| `l` | `80rem` |
|
|
27
|
+
| `xl` | `90rem` |
|
|
28
|
+
| `xxl` | `120rem` |
|
|
29
|
+
| `xxxl` | `160rem` |
|
|
30
|
+
|
|
31
|
+
These are the names every `data-component:<name>` and `data-option-<x>:<name>` suffix is checked against.
|
|
32
|
+
|
|
33
|
+
## Replacing them
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
import { setBreakpoints } from '@studiometa/js-toolkit';
|
|
37
|
+
|
|
38
|
+
setBreakpoints({
|
|
39
|
+
xs: '0rem',
|
|
40
|
+
s: '48rem',
|
|
41
|
+
m: '64rem',
|
|
42
|
+
l: '80rem',
|
|
43
|
+
xl: '96rem',
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
`setBreakpoints()` is the single source of breakpoint truth, and calling it does three things at once:
|
|
48
|
+
|
|
49
|
+
1. **rebuilds the scoped attribute names** — every `data-component:<name>` and every `data-option-<x>:<name>` spelling;
|
|
50
|
+
2. **replaces that slice of the observer's `attributeFilter`**, draining the records of the previous filter first;
|
|
51
|
+
3. **emits at once** on [`useBreakpoint()`](../services/useBreakpoint.md), so a subscriber sees the new active name immediately.
|
|
52
|
+
|
|
53
|
+
## The values are in `rem`
|
|
54
|
+
|
|
55
|
+
And in a media query, `rem` resolves against the **initial** font size, not against the root element. That is deliberate: a breakpoint that moved when a component changed the root font size would not be a breakpoint.
|
|
56
|
+
|
|
57
|
+
## What uses them
|
|
58
|
+
|
|
59
|
+
| Feature | How |
|
|
60
|
+
| ------------------------------------------------------------------------------ | ---------------------------------------------- |
|
|
61
|
+
| [responsive options](../html/data-option.md#every-option-is-responsive) | `data-option-x:<name>`, cascading upwards |
|
|
62
|
+
| [responsive components](../html/data-component.md#responsive-declarations) | `data-component:<name>`, replacing not merging |
|
|
63
|
+
| [`useBreakpoint()`](../services/useBreakpoint.md) | the active name, as a service |
|
|
64
|
+
|
|
65
|
+
**A suffix that names no configured breakpoint** gives one `responsive.unknown-breakpoint` warning and is ignored — including the v3 list syntax `:xxs:xs:s`.
|
|
66
|
+
|
|
67
|
+
## What it costs
|
|
68
|
+
|
|
69
|
+
- The `MediaQueryList` objects are built **once**.
|
|
70
|
+
- The active name is **memoised for the length of one task**, through `utils/memo`. `setBreakpoints()` and the `change` handler of a running service clear that memo at once.
|
|
71
|
+
- A `matchMedia` subscription opens only for a component that declares [`option<Name>Changed()`](../methods-hooks-options.md); connected elements with a scoped `data-component` share **one** reference-counted subscription. A page with plain declarations and read-only options opens **none**.
|
|
72
|
+
|
|
73
|
+
The breakpoint service is part of the core graph on every page. What a page pays is the subscriptions it asks for.
|
|
74
|
+
|
|
75
|
+
**The defaults and Tailwind**
|
|
76
|
+
|
|
77
|
+
The current default breakpoints are **not** aligned with `@studiometa/tailwind-config`. That alignment is a separate product decision. Call `setBreakpoints()` to match your own scale.
|
|
78
|
+
|
|
79
|
+
## There is no `defineFeatures()`
|
|
80
|
+
|
|
81
|
+
Breakpoints are the one configurable feature, and `setBreakpoints()` is it. Attribute names and the attribute prefix are not configurable.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# domUpdate
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
domUpdate(target: Node, mutate: () => void | Promise<void>, detail?: Record<string, unknown>): Promise<void>
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Announces a DOM mutation before it happens, so anything above the node can **take it over**.
|
|
8
|
+
|
|
9
|
+
This is the _take-over_ mode of the negotiated-event mechanism. The _delay_ mode is [`emitExtendable()`](emitExtendable.md).
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The code that mutates announces instead of mutating:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { domUpdate } from '@studiometa/js-toolkit';
|
|
17
|
+
|
|
18
|
+
await domUpdate(this.$el, () => this.$el.replaceChildren(fragment));
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
An ancestor claims it:
|
|
22
|
+
|
|
23
|
+
```js
|
|
24
|
+
import { EVENTS, viewTransition } from '@studiometa/js-toolkit';
|
|
25
|
+
|
|
26
|
+
this.$on(EVENTS.dom.update, ({ detail }) => detail.wrap(viewTransition));
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## The detail
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
interface DomUpdateDetail {
|
|
33
|
+
wrap(runner: DomUpdateRunner): void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type DomUpdateRunner =
|
|
37
|
+
| ((apply: () => void | Promise<void>) => void | Promise<unknown>)
|
|
38
|
+
| { update(mutate: () => void | Promise<void>): void | Promise<unknown> };
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The event is `EVENTS.dom.update` — `'js-toolkit:dom:update'` — dispatched on `target` as a bubbling, **non-cancelable** `CustomEvent`.
|
|
42
|
+
|
|
43
|
+
**The detail is one object**, like every other v4 event. A decorated handler reads `{ payload: { wrap } }` for what a raw listener reads as `event.detail`.
|
|
44
|
+
|
|
45
|
+
## What a claim composes with
|
|
46
|
+
|
|
47
|
+
| Claim | Effect |
|
|
48
|
+
| --------------------------------------------- | -------------------------------------------------------------------- |
|
|
49
|
+
| `wrap(viewTransition)` | the change plays as one batched native view transition |
|
|
50
|
+
| `wrap((apply) => this.$write(apply).promise)` | the change lands in the `write` phase, batched, cancelled on unmount |
|
|
51
|
+
| `wrap(motionView)` | any object with `update(mutate)` — which `MotionView` already is |
|
|
52
|
+
|
|
53
|
+
**Neither runner is the default.** The ancestor chooses the lane, because it knows whether the region animates.
|
|
54
|
+
|
|
55
|
+
## The rules
|
|
56
|
+
|
|
57
|
+
- **`defaultPrevented` is ignored.** The step is announced, not proposed.
|
|
58
|
+
- **The last claim wins.** Take-over mode keeps one runner.
|
|
59
|
+
- **A registration is valid only while the event dispatches.** A listener that keeps `wrap` and calls it later is reported as `protocol.late-registration` and ignored.
|
|
60
|
+
- **The work of the emitter always completes.** A runner that throws, rejects, or resolves without calling `apply` loses the animation, never the change — and that last case is reported as `protocol.unapplied-dom-update`.
|
|
61
|
+
- **An unclaimed `domUpdate()` is synchronous.** With no listener, the mutation runs before the returned promise exists.
|
|
62
|
+
- A failing runner is reported as `callback.dom-update-runner-failed`.
|
|
63
|
+
|
|
64
|
+
## It has no `Base` path
|
|
65
|
+
|
|
66
|
+
The helper dispatches its own event and is absent from `$emits`, so the negotiation code and the optional view-transition import stay out of the `Base` module graph. **Plain DOM code uses the same function with no instance.**
|
|
67
|
+
|
|
68
|
+
## With `swap()`
|
|
69
|
+
|
|
70
|
+
`domUpdate()` produces exactly the `wrap` that [`swap()`](swap.md) takes, and nothing else. Resilience policy stays here.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# emitExtendable
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
emitExtendable(target: Node, event: string, detail?: Record<string, unknown>): Promise<void>
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Announces a step before it happens, so anything above the node can **delay** it.
|
|
8
|
+
|
|
9
|
+
This is the _delay_ mode of the negotiated-event mechanism. The _take-over_ mode is [`domUpdate()`](domUpdate.md).
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
The choreography announces its step and waits:
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { emitExtendable } from '@studiometa/js-toolkit';
|
|
17
|
+
|
|
18
|
+
async close() {
|
|
19
|
+
await emitExtendable(this.$el, 'close');
|
|
20
|
+
this.$el.close();
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
An ancestor asks for more time:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
this.$on('close', ({ detail }) => detail.waitUntil(this.leave()));
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## The detail
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
interface ExtendableDetail {
|
|
34
|
+
waitUntil(extension: Extension): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type Extension = PromiseLike<unknown> | (() => unknown) | Record<string, unknown>;
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
`waitUntil()` accepts three shapes:
|
|
41
|
+
|
|
42
|
+
| Shape | Example |
|
|
43
|
+
| ------------------------- | ------------------------------- |
|
|
44
|
+
| a thenable | `waitUntil(this.leave())` |
|
|
45
|
+
| a function | `waitUntil(() => this.enter())` |
|
|
46
|
+
| an object with the method | `waitUntil(transitioner)` |
|
|
47
|
+
|
|
48
|
+
**The duck-typed method has the name of the event**: `close()` for the `close` step of a dialog, `update(mutate)` for a DOM change. The function form covers any pair of method names.
|
|
49
|
+
|
|
50
|
+
The event is dispatched on `target` as a bubbling, **non-cancelable** `CustomEvent`.
|
|
51
|
+
|
|
52
|
+
## The rules
|
|
53
|
+
|
|
54
|
+
- **`defaultPrevented` is ignored.** The step is announced, not proposed.
|
|
55
|
+
- **Every registration is kept and all are awaited**, because two components that animate out must both be awaited. This is where it differs from `domUpdate()`, which keeps one.
|
|
56
|
+
- **A registration is valid only while the event dispatches.** A listener that keeps `waitUntil` and calls it later is reported as `protocol.late-registration` and ignored.
|
|
57
|
+
- **The step happens anyway.** An extension that rejects is swallowed, and reported as `callback.extendable-event-extension-failed`.
|
|
58
|
+
|
|
59
|
+
## It has no `Base` path
|
|
60
|
+
|
|
61
|
+
The helper dispatches its own event and is absent from `$emits`. Plain DOM code uses the same function with no instance.
|
|
62
|
+
|
|
63
|
+
## Which mode to reach for
|
|
64
|
+
|
|
65
|
+
| You are announcing | Use |
|
|
66
|
+
| ----------------------------------------------------- | --------------------------------- |
|
|
67
|
+
| an **action** someone may want to perform differently | [`domUpdate()`](domUpdate.md) |
|
|
68
|
+
| a **moment** someone may want to postpone | `emitExtendable()` |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# DOM
|
|
2
|
+
|
|
3
|
+
The functions that change the document, negotiate a change, or watch an attribute the framework does not read.
|
|
4
|
+
|
|
5
|
+
## Changing content
|
|
6
|
+
|
|
7
|
+
- [`swap(target, content, options?)`](swap.md) — replace, prepend, append or morph, and wait for the framework to catch up
|
|
8
|
+
- [`whenDOMSettled()`](whenDOMSettled.md) — the completion boundary
|
|
9
|
+
|
|
10
|
+
## Negotiating a change
|
|
11
|
+
|
|
12
|
+
- [`domUpdate(target, mutate, detail?)`](domUpdate.md) — announce a mutation so an ancestor can take it over
|
|
13
|
+
- [`emitExtendable(target, event, detail?)`](emitExtendable.md) — announce a step so an ancestor can delay it
|
|
14
|
+
|
|
15
|
+
## Watching attributes
|
|
16
|
+
|
|
17
|
+
- [`watchAttributes(el, callback)`](watchAttributes.md) — every attribute of one element
|
|
18
|
+
- [`watchAttributeNamespace(el, ns, bind, options?)`](watchAttributeNamespace.md) — a namespace whose names cannot be enumerated
|
|
19
|
+
|
|
20
|
+
## Breakpoints
|
|
21
|
+
|
|
22
|
+
- [`BREAKPOINTS`, `getBreakpoints()`, `setBreakpoints()`](breakpoints.md)
|
|
23
|
+
|
|
24
|
+
## Read next
|
|
25
|
+
|
|
26
|
+
[The mutation engine](../../guide/concepts/mutation-engine.md) and [The attribute grammar](../../guide/concepts/attribute-grammar.md).
|