kuinetic 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/esm/chunk-LWS4OSLX.mjs +730 -0
- package/dist/esm/chunk-QZIJ7WZI.mjs +3312 -0
- package/dist/esm/chunk-R3TGDJKA.mjs +1264 -0
- package/dist/esm/core/index.mjs +34 -0
- package/dist/esm/effects/index.mjs +27 -0
- package/dist/esm/index.mjs +52 -0
- package/dist/kuinetic.all.js +5291 -0
- package/dist/kuinetic.css +2338 -0
- package/dist/kuinetic.js +5281 -0
- package/dist/types/core/activation.d.ts +21 -0
- package/dist/types/core/animator.d.ts +216 -0
- package/dist/types/core/attrs.d.ts +15 -0
- package/dist/types/core/capabilities.d.ts +19 -0
- package/dist/types/core/channels.d.ts +25 -0
- package/dist/types/core/compile.d.ts +49 -0
- package/dist/types/core/dom-watcher.d.ts +35 -0
- package/dist/types/core/effect-context.d.ts +49 -0
- package/dist/types/core/element-config.d.ts +52 -0
- package/dist/types/core/flip.d.ts +80 -0
- package/dist/types/core/gesture.d.ts +99 -0
- package/dist/types/core/index.d.ts +14 -0
- package/dist/types/core/instances.d.ts +98 -0
- package/dist/types/core/js-effect-preparer.d.ts +46 -0
- package/dist/types/core/js-params.d.ts +124 -0
- package/dist/types/core/owned-styles.d.ts +44 -0
- package/dist/types/core/params.d.ts +65 -0
- package/dist/types/core/parse.d.ts +22 -0
- package/dist/types/core/path-morph.d.ts +83 -0
- package/dist/types/core/play.d.ts +48 -0
- package/dist/types/core/registry.d.ts +38 -0
- package/dist/types/core/reporter.d.ts +35 -0
- package/dist/types/core/scroll-scheduler.d.ts +153 -0
- package/dist/types/core/spring.d.ts +83 -0
- package/dist/types/core/stagger.d.ts +19 -0
- package/dist/types/core/style-plan.d.ts +56 -0
- package/dist/types/core/types.d.ts +239 -0
- package/dist/types/effects/catalog/ambient.d.ts +18 -0
- package/dist/types/effects/catalog/core.d.ts +19 -0
- package/dist/types/effects/catalog/feedback.d.ts +21 -0
- package/dist/types/effects/catalog/index.d.ts +21 -0
- package/dist/types/effects/catalog/interaction-shared.d.ts +56 -0
- package/dist/types/effects/catalog/interaction.d.ts +22 -0
- package/dist/types/effects/catalog/media.d.ts +13 -0
- package/dist/types/effects/catalog/numbers-shared.d.ts +103 -0
- package/dist/types/effects/catalog/numbers.d.ts +31 -0
- package/dist/types/effects/catalog/shared.d.ts +3 -0
- package/dist/types/effects/catalog/text-shared.d.ts +180 -0
- package/dist/types/effects/catalog/text.d.ts +17 -0
- package/dist/types/effects/forms/index.d.ts +14 -0
- package/dist/types/effects/forms/primitives.d.ts +32 -0
- package/dist/types/effects/gestures/index.d.ts +19 -0
- package/dist/types/effects/gestures/primitives.d.ts +2 -0
- package/dist/types/effects/index.d.ts +19 -0
- package/dist/types/effects/layout/index.d.ts +12 -0
- package/dist/types/effects/layout/presets.d.ts +9 -0
- package/dist/types/effects/layout/primitives.d.ts +2 -0
- package/dist/types/effects/navigation/index.d.ts +30 -0
- package/dist/types/effects/scroll-mechanics/index.d.ts +14 -0
- package/dist/types/effects/scroll-mechanics/presets.d.ts +6 -0
- package/dist/types/effects/scroll-mechanics/primitives.d.ts +2 -0
- package/dist/types/effects/scroll-mechanics/tracker.d.ts +55 -0
- package/dist/types/effects/shared.d.ts +26 -0
- package/dist/types/effects/svg/index.d.ts +13 -0
- package/dist/types/effects/three-d/index.d.ts +20 -0
- package/dist/types/index.d.ts +16 -0
- package/package.json +78 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { PrepareContext } from '../../core/effect-context.js';
|
|
2
|
+
import type { ScrollFrame } from '../../core/scroll-scheduler.js';
|
|
3
|
+
import type { Cleanup } from '../../core/types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Progress tracking — the single mechanism every scroll-mechanics effect is built on.
|
|
6
|
+
*
|
|
7
|
+
* Pinning, scrollytelling, horizontal scroll, and media scrubbing differ only in what they *do*
|
|
8
|
+
* with a number between 0 and 1. Computing that number once, in one place, is what keeps the whole
|
|
9
|
+
* category to one listener, one rAF, and one measurement per resize.
|
|
10
|
+
*
|
|
11
|
+
* Geometry is read through an injected measurer: jsdom reports zeroes for every rect, so a tracker
|
|
12
|
+
* that called `getBoundingClientRect` directly could not be tested at all.
|
|
13
|
+
*/
|
|
14
|
+
export interface ElementGeometry {
|
|
15
|
+
/** Distance from the scrollport's top edge to the element's top edge. Negative once past it. */
|
|
16
|
+
top: number;
|
|
17
|
+
height: number;
|
|
18
|
+
}
|
|
19
|
+
export type Measurer = (el: Element) => ElementGeometry;
|
|
20
|
+
export declare const domGeometry: Measurer;
|
|
21
|
+
export interface TrackOptions {
|
|
22
|
+
/**
|
|
23
|
+
* Scroll distance the effect spans, as an authored CSS length. Defaults to the element's own
|
|
24
|
+
* height, which is what makes `pin-section` behave sensibly with no configuration.
|
|
25
|
+
*/
|
|
26
|
+
distance?: string;
|
|
27
|
+
measure?: Measurer;
|
|
28
|
+
}
|
|
29
|
+
export type ProgressHandler = (progress: number, frame: ScrollFrame) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Drive `onProgress` with the element's scroll progress in [0, 1].
|
|
32
|
+
*
|
|
33
|
+
* Progress is 0 when the element's top reaches the top of the scrollport and 1 once the scroll has
|
|
34
|
+
* advanced by `distance`. Measurements are cached against the scheduler's epoch, so a frame costs
|
|
35
|
+
* arithmetic rather than a layout flush.
|
|
36
|
+
*
|
|
37
|
+
* @param el - Element whose position drives progress.
|
|
38
|
+
* @param ctx - Prepare context supplying the scheduler and root resolver.
|
|
39
|
+
* @param options - Distance and an optional injected measurer.
|
|
40
|
+
* @param onProgress - Called once per scheduled frame.
|
|
41
|
+
* @returns Teardown that unsubscribes from the scheduler.
|
|
42
|
+
* @complexity O(1) per frame after the first measurement of each epoch; O(1) space.
|
|
43
|
+
* @overallScore 100
|
|
44
|
+
*/
|
|
45
|
+
export declare function trackProgress(el: Element, ctx: PrepareContext, options: TrackOptions, onProgress: ProgressHandler): Cleanup;
|
|
46
|
+
/**
|
|
47
|
+
* Progress from the element's offset and the span it travels.
|
|
48
|
+
*
|
|
49
|
+
* @param top - Element top relative to the scrollport; negative once scrolled past.
|
|
50
|
+
* @param span - Pixels of scrolling the effect covers.
|
|
51
|
+
* @returns Progress in [0, 1]; 0 for a non-positive span.
|
|
52
|
+
* @complexity O(1) time and space.
|
|
53
|
+
* @overallScore 100
|
|
54
|
+
*/
|
|
55
|
+
export declare function progressFrom(top: number, span: number): number;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Activation, ParameterSchema, Primitive, ReducedMotionPolicy, Timeline } from '../core/types.js';
|
|
2
|
+
export interface CssPrimitiveOptions {
|
|
3
|
+
parameters?: ParameterSchema;
|
|
4
|
+
timelines?: Timeline[];
|
|
5
|
+
activations?: Activation[];
|
|
6
|
+
defaultActivation?: Activation;
|
|
7
|
+
reducedMotion?: ReducedMotionPolicy;
|
|
8
|
+
perfClass?: Primitive['perfClass'];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Build the metadata shared by every CSS-keyframe-rendered primitive.
|
|
12
|
+
*
|
|
13
|
+
* The one factory for "a CSS-keyframes `Primitive` with the shared timing defaults
|
|
14
|
+
* (`duration`/`delay`/`ease`/`stagger`), `renderer: 'css-keyframes'`, and a default
|
|
15
|
+
* activation/perfClass/reducedMotion policy" — every category under `effects/` that renders
|
|
16
|
+
* with CSS keyframes builds its primitives through this, so a change to a shared default only
|
|
17
|
+
* has one call site to update.
|
|
18
|
+
*
|
|
19
|
+
* @param id - Stable primitive identifier.
|
|
20
|
+
* @param channels - CSS property groups owned by the primitive.
|
|
21
|
+
* @param options - Optional schema and lifecycle overrides.
|
|
22
|
+
* @returns A CSS-keyframe primitive ready for registry registration.
|
|
23
|
+
* @complexity O(p) time and space in parameter count.
|
|
24
|
+
* @overallScore 100
|
|
25
|
+
*/
|
|
26
|
+
export declare function cssPrimitive(id: string, channels: string[], options?: CssPrimitiveOptions): Primitive;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Registry } from '../../core/registry.js';
|
|
2
|
+
import type { Preset, Primitive } from '../../core/types.js';
|
|
3
|
+
export declare const SVG_PRIMITIVES: Primitive[];
|
|
4
|
+
export declare const SVG_PRESETS: Preset[];
|
|
5
|
+
/**
|
|
6
|
+
* Register the SVG morph catalog.
|
|
7
|
+
*
|
|
8
|
+
* @param registry - Registry to populate.
|
|
9
|
+
* @returns The same registry, for chaining.
|
|
10
|
+
* @complexity O(n) time in the number of primitives and presets.
|
|
11
|
+
* @overallScore 100
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerSvg(registry: Registry): Registry;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Preset, Primitive } from '../../core/types.js';
|
|
2
|
+
import type { Registry } from '../../core/registry.js';
|
|
3
|
+
/**
|
|
4
|
+
* 3D, perspective, and page-transition effects — all CSS-rendered.
|
|
5
|
+
*
|
|
6
|
+
* Nothing here needs JavaScript: the browser interpolates `rotate`, `clip-path`, and `opacity`
|
|
7
|
+
* natively, so these cost a keyframe block and a registry row each. That ratio is the whole
|
|
8
|
+
* architecture, and it is why tripling the catalog does not triple the payload.
|
|
9
|
+
*/
|
|
10
|
+
export declare const THREE_D_PRIMITIVES: Primitive[];
|
|
11
|
+
export declare const THREE_D_PRESETS: Preset[];
|
|
12
|
+
/**
|
|
13
|
+
* Register the 3D and page-transition catalog.
|
|
14
|
+
*
|
|
15
|
+
* @param registry - Registry to populate.
|
|
16
|
+
* @returns The same registry, for chaining.
|
|
17
|
+
* @complexity O(n) time in the number of primitives and presets.
|
|
18
|
+
* @overallScore 100
|
|
19
|
+
*/
|
|
20
|
+
export declare function registerThreeD(registry: Registry): Registry;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Animator } from './core/animator.js';
|
|
2
|
+
import type { AnimatorOptions } from './core/animator.js';
|
|
3
|
+
export * from './core/index.js';
|
|
4
|
+
export { COMBOS, PRESETS, PRIMITIVES, createRegistry } from './effects/index.js';
|
|
5
|
+
/**
|
|
6
|
+
* Create an animator with the bundled effect catalog registered.
|
|
7
|
+
*
|
|
8
|
+
* Importing this module has no side effects — nothing is scanned and the document is not
|
|
9
|
+
* touched until `.start()` is called. That keeps SSR, hydration, and tests deterministic.
|
|
10
|
+
*
|
|
11
|
+
* import { kuinetic } from 'kuinetic'
|
|
12
|
+
* import 'kuinetic/css'
|
|
13
|
+
* kuinetic({ observe: true }).start()
|
|
14
|
+
*/
|
|
15
|
+
export declare function kuinetic(options?: AnimatorOptions): Animator;
|
|
16
|
+
export default kuinetic;
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "kuinetic",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Declarative web animation from HTML attributes. Native CSS where possible, JS only where necessary.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"sideEffects": [
|
|
8
|
+
"*.css"
|
|
9
|
+
],
|
|
10
|
+
"main": "./dist/esm/index.mjs",
|
|
11
|
+
"module": "./dist/esm/index.mjs",
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"unpkg": "dist/kuinetic.js",
|
|
14
|
+
"jsdelivr": "dist/kuinetic.js",
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/types/index.d.ts",
|
|
21
|
+
"default": "./dist/esm/index.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./core": {
|
|
24
|
+
"types": "./dist/types/core/index.d.ts",
|
|
25
|
+
"default": "./dist/esm/core/index.mjs"
|
|
26
|
+
},
|
|
27
|
+
"./effects": {
|
|
28
|
+
"types": "./dist/types/effects/index.d.ts",
|
|
29
|
+
"default": "./dist/esm/effects/index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./css": "./dist/kuinetic.css",
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest",
|
|
37
|
+
"test:coverage": "vitest run --coverage",
|
|
38
|
+
"typecheck": "tsc --noEmit",
|
|
39
|
+
"lint": "eslint src test scripts",
|
|
40
|
+
"lint:deps": "depcruise src --config .dependency-cruiser.cjs",
|
|
41
|
+
"lint:dead": "knip",
|
|
42
|
+
"size": "npm run build:dist && size-limit",
|
|
43
|
+
"build": "npm run generate:css && esbuild src/index.ts --bundle --format=iife --global-name=kuinetic --outfile=demo/kuinetic.js && esbuild src/css/index.css --bundle --outfile=demo/kuinetic.css && npx @tailwindcss/cli -i demo/tailwind-entry.css -o demo/tailwind.css",
|
|
44
|
+
"build:dist": "npm run clean:dist && npm run generate:css && esbuild src/index.ts src/core/index.ts src/effects/index.ts --bundle --format=esm --splitting --outdir=dist/esm --out-extension:.js=.mjs && esbuild src/index.ts --bundle --format=iife --global-name=kuinetic --outfile=dist/kuinetic.js && esbuild src/css/index.css --bundle --outfile=dist/kuinetic.css && tsc -p tsconfig.build.json && node scripts/build-standalone.mjs",
|
|
45
|
+
"verify:standalone": "npm run build:dist && node scripts/verify-standalone.mjs",
|
|
46
|
+
"verify:pack": "npm run build:dist && node scripts/verify-pack.mjs",
|
|
47
|
+
"clean:dist": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
48
|
+
"prepack": "npm run build:dist",
|
|
49
|
+
"prepublishOnly": "node -e \"if (require('./package.json').version === '0.0.0') { console.error('Refusing to publish placeholder version 0.0.0 — bump package.json first.'); process.exit(1) }\"",
|
|
50
|
+
"dev": "npm run build && node scripts/dev-server.mjs",
|
|
51
|
+
"verify:browser": "npm run build && node scripts/verify-browser.mjs",
|
|
52
|
+
"test:browser": "npm run build && node scripts/run-browser-tests.mjs",
|
|
53
|
+
"generate:css": "node scripts/generate-preset-css.mjs",
|
|
54
|
+
"record": "npm run build && node scripts/verify-browser.mjs --record",
|
|
55
|
+
"check:showcase": "npm run build && node scripts/check-showcase.mjs"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@eslint/js": "^9.39.5",
|
|
59
|
+
"@size-limit/file": "^13.0.3",
|
|
60
|
+
"@tailwindcss/cli": "^4.3.3",
|
|
61
|
+
"@types/node": "^22.20.1",
|
|
62
|
+
"@vitest/coverage-v8": "^2.1.9",
|
|
63
|
+
"daisyui": "^5.7.16",
|
|
64
|
+
"dependency-cruiser": "^18.2.0",
|
|
65
|
+
"esbuild": "^0.21.5",
|
|
66
|
+
"eslint": "^9.39.5",
|
|
67
|
+
"eslint-plugin-sonarjs": "^3.0.7",
|
|
68
|
+
"globals": "^14.0.0",
|
|
69
|
+
"jsdom": "^25.0.1",
|
|
70
|
+
"knip": "^6.32.2",
|
|
71
|
+
"playwright-core": "^1.61.1",
|
|
72
|
+
"size-limit": "^13.0.3",
|
|
73
|
+
"tailwindcss": "^4.3.3",
|
|
74
|
+
"typescript": "^5.9.3",
|
|
75
|
+
"typescript-eslint": "^8.66.0",
|
|
76
|
+
"vitest": "^2.1.9"
|
|
77
|
+
}
|
|
78
|
+
}
|