@studiometa/ui-motion 0.0.1 → 1.11.1

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.
@@ -0,0 +1,53 @@
1
+ //#region src/dependencies.ts
2
+ let motionInstance;
3
+ let motionPromise;
4
+ let motionProvided = false;
5
+ /**
6
+ * Inject the `motion` module the components should use.
7
+ *
8
+ * Call once, before the components mount (e.g. right before `createApp`). Once
9
+ * provided, `@studiometa/ui-motion` never imports `motion` by specifier — it
10
+ * uses this instance — so a host can supply its own build (a specific version,
11
+ * the smaller `motion/mini` entry, an import-map or CDN module).
12
+ *
13
+ * @param {MotionModule} instance The `motion` module namespace.
14
+ */
15
+ function provideMotion(instance) {
16
+ motionProvided = true;
17
+ motionInstance = instance;
18
+ motionPromise = Promise.resolve(instance);
19
+ }
20
+ /**
21
+ * Resolve the `motion` module: the injected instance when one was provided
22
+ * through {@link provideMotion}, otherwise a lazily loaded `import('motion')`.
23
+ *
24
+ * The result is memoized, so `motion` loads at most once and repeated calls
25
+ * are cheap. The resolved instance is also cached for {@link getMotion}.
26
+ *
27
+ * @returns {Promise<MotionModule>}
28
+ */
29
+ function resolveMotion() {
30
+ if (!motionPromise) motionPromise = import("motion").then((module) => {
31
+ const instance = module;
32
+ if (!motionProvided) motionInstance = instance;
33
+ return motionInstance;
34
+ });
35
+ return motionPromise;
36
+ }
37
+ /**
38
+ * Synchronously read the resolved `motion` module.
39
+ *
40
+ * Only valid after {@link resolveMotion} (or {@link provideMotion}) has run;
41
+ * it throws otherwise. Components read it on synchronous hot paths that are
42
+ * only ever reached once their animation — and therefore `motion` — is ready.
43
+ *
44
+ * @returns {MotionModule}
45
+ */
46
+ function getMotion() {
47
+ if (!motionInstance) throw new Error("[@studiometa/ui-motion] motion has not been resolved yet. Await resolveMotion() (or call provideMotion()) before reading it synchronously.");
48
+ return motionInstance;
49
+ }
50
+ //#endregion
51
+ export { getMotion, provideMotion, resolveMotion };
52
+
53
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.js","names":[],"sources":["../src/dependencies.ts"],"sourcesContent":["import type {\n animate,\n animateView,\n scroll,\n hover,\n press,\n inView,\n transformProps,\n readTransformValue,\n getComputedStyle,\n} from 'motion';\n\n/**\n * The subset of the `motion` module the components consume. Declared\n * structurally so a host can inject the full `motion` entry, the smaller\n * `motion/mini` entry or any compatible build — only the members listed here\n * are ever read. Everything but `animate` is optional because `motion/mini`\n * does not ship it: `animateView` powers `MotionView`, `scroll` powers\n * `MotionScrollTimeline`, and `hover`, `press` and `inView` power the\n * matching `Motion` gesture options.\n *\n * `transformProps`, `readTransformValue` and `getComputedStyle` are Motion's\n * own value readers. `Motion` uses them to capture the base value a gesture\n * returns to, the way Motion's `VisualElement.readValueFromInstance()` does.\n * They ship alongside the gesture functions in the full entry.\n */\nexport interface MotionModule {\n animate: typeof animate;\n animateView?: typeof animateView;\n scroll?: typeof scroll;\n hover?: typeof hover;\n press?: typeof press;\n inView?: typeof inView;\n transformProps?: typeof transformProps;\n readTransformValue?: typeof readTransformValue;\n getComputedStyle?: typeof getComputedStyle;\n}\n\nlet motionInstance: MotionModule | undefined;\nlet motionPromise: Promise<MotionModule> | undefined;\nlet motionProvided = false;\n\n/**\n * Inject the `motion` module the components should use.\n *\n * Call once, before the components mount (e.g. right before `createApp`). Once\n * provided, `@studiometa/ui-motion` never imports `motion` by specifier — it\n * uses this instance — so a host can supply its own build (a specific version,\n * the smaller `motion/mini` entry, an import-map or CDN module).\n *\n * @param {MotionModule} instance The `motion` module namespace.\n */\nexport function provideMotion(instance: MotionModule): void {\n motionProvided = true;\n motionInstance = instance;\n motionPromise = Promise.resolve(instance);\n}\n\n/**\n * Resolve the `motion` module: the injected instance when one was provided\n * through {@link provideMotion}, otherwise a lazily loaded `import('motion')`.\n *\n * The result is memoized, so `motion` loads at most once and repeated calls\n * are cheap. The resolved instance is also cached for {@link getMotion}.\n *\n * @returns {Promise<MotionModule>}\n */\nexport function resolveMotion(): Promise<MotionModule> {\n if (!motionPromise) {\n motionPromise = import('motion').then((module) => {\n const instance = module as MotionModule;\n // A provideMotion() call may have won the race while this import was in\n // flight: never let the fallback overwrite an injected instance. Returning\n // the authoritative instance also keeps callers that awaited this promise\n // before the injection consistent with the provided one.\n if (!motionProvided) {\n motionInstance = instance;\n }\n return motionInstance as MotionModule;\n });\n }\n\n return motionPromise;\n}\n\n/**\n * Synchronously read the resolved `motion` module.\n *\n * Only valid after {@link resolveMotion} (or {@link provideMotion}) has run;\n * it throws otherwise. Components read it on synchronous hot paths that are\n * only ever reached once their animation — and therefore `motion` — is ready.\n *\n * @returns {MotionModule}\n */\nexport function getMotion(): MotionModule {\n if (!motionInstance) {\n throw new Error(\n '[@studiometa/ui-motion] motion has not been resolved yet. Await resolveMotion() (or call provideMotion()) before reading it synchronously.',\n );\n }\n\n return motionInstance;\n}\n"],"mappings":";AAsCA,IAAI;AACJ,IAAI;AACJ,IAAI,iBAAiB;;;;;;;;;;;AAYrB,SAAgB,cAAc,UAA8B;AAC1D,kBAAiB;AACjB,kBAAiB;AACjB,iBAAgB,QAAQ,QAAQ,SAAS;;;;;;;;;;;AAY3C,SAAgB,gBAAuC;AACrD,KAAI,CAAC,cACH,iBAAgB,OAAO,UAAU,MAAM,WAAW;EAChD,MAAM,WAAW;AAKjB,MAAI,CAAC,eACH,kBAAiB;AAEnB,SAAO;GACP;AAGJ,QAAO;;;;;;;;;;;AAYT,SAAgB,YAA0B;AACxC,KAAI,CAAC,eACH,OAAM,IAAI,MACR,6IACD;AAGH,QAAO"}
@@ -0,0 +1,6 @@
1
+ import { MotionModule, provideMotion, resolveMotion } from "./dependencies.js";
2
+ import { Motion, MotionProps } from "./Motion.js";
3
+ import { MotionScrollTimeline, MotionScrollTimelineProps } from "./MotionScrollTimeline.js";
4
+ import { MotionSequence, MotionSequenceProps } from "./MotionSequence.js";
5
+ import { MotionView, MotionViewProps } from "./MotionView.js";
6
+ export { Motion, type MotionModule, type MotionProps, MotionScrollTimeline, type MotionScrollTimelineProps, MotionSequence, type MotionSequenceProps, MotionView, type MotionViewProps, provideMotion, resolveMotion };
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ import { provideMotion, resolveMotion } from "./dependencies.js";
2
+ import { Motion } from "./Motion.js";
3
+ import { MotionScrollTimeline } from "./MotionScrollTimeline.js";
4
+ import { MotionSequence } from "./MotionSequence.js";
5
+ import { MotionView } from "./MotionView.js";
6
+ export { Motion, MotionScrollTimeline, MotionSequence, MotionView, provideMotion, resolveMotion };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { ComponentManifest } from "@studiometa/js-toolkit";
2
+
3
+ //#region src/manifest.d.ts
4
+ declare const manifest: ComponentManifest;
5
+ //#endregion
6
+ export { manifest };
@@ -0,0 +1,45 @@
1
+ //#region src/manifest.ts
2
+ const manifest = {
3
+ Motion: {
4
+ token: "Motion",
5
+ packageName: "@studiometa/ui-motion",
6
+ subpath: "Motion",
7
+ exportName: "Motion",
8
+ strategy: "visible",
9
+ group: "motion",
10
+ load: () => import("./Motion.js").then(({ Motion }) => Motion)
11
+ },
12
+ MotionScrollTimeline: {
13
+ token: "MotionScrollTimeline",
14
+ packageName: "@studiometa/ui-motion",
15
+ subpath: "MotionScrollTimeline",
16
+ exportName: "MotionScrollTimeline",
17
+ strategy: "visible",
18
+ group: "motion",
19
+ children: ["Motion"],
20
+ load: () => import("./MotionScrollTimeline.js").then(({ MotionScrollTimeline }) => MotionScrollTimeline)
21
+ },
22
+ MotionSequence: {
23
+ token: "MotionSequence",
24
+ packageName: "@studiometa/ui-motion",
25
+ subpath: "MotionSequence",
26
+ exportName: "MotionSequence",
27
+ strategy: "visible",
28
+ group: "motion",
29
+ children: ["Motion"],
30
+ load: () => import("./MotionSequence.js").then(({ MotionSequence }) => MotionSequence)
31
+ },
32
+ MotionView: {
33
+ token: "MotionView",
34
+ packageName: "@studiometa/ui-motion",
35
+ subpath: "MotionView",
36
+ exportName: "MotionView",
37
+ strategy: "visible",
38
+ group: "motion",
39
+ load: () => import("./MotionView.js").then(({ MotionView }) => MotionView)
40
+ }
41
+ };
42
+ //#endregion
43
+ export { manifest };
44
+
45
+ //# sourceMappingURL=manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.js","names":[],"sources":["../src/manifest.ts"],"sourcesContent":["// This file is generated by scripts/generate-manifests.ts. Do not edit.\nimport type { ComponentManifest } from '@studiometa/js-toolkit';\n\nexport const manifest: ComponentManifest = {\n Motion: {\n token: 'Motion',\n packageName: '@studiometa/ui-motion',\n subpath: 'Motion',\n exportName: 'Motion',\n strategy: 'visible',\n group: 'motion',\n load: () => import('./Motion.js').then(({ Motion }) => Motion),\n },\n MotionScrollTimeline: {\n token: 'MotionScrollTimeline',\n packageName: '@studiometa/ui-motion',\n subpath: 'MotionScrollTimeline',\n exportName: 'MotionScrollTimeline',\n strategy: 'visible',\n group: 'motion',\n children: ['Motion'],\n load: () =>\n import('./MotionScrollTimeline.js').then(({ MotionScrollTimeline }) => MotionScrollTimeline),\n },\n MotionSequence: {\n token: 'MotionSequence',\n packageName: '@studiometa/ui-motion',\n subpath: 'MotionSequence',\n exportName: 'MotionSequence',\n strategy: 'visible',\n group: 'motion',\n children: ['Motion'],\n load: () => import('./MotionSequence.js').then(({ MotionSequence }) => MotionSequence),\n },\n MotionView: {\n token: 'MotionView',\n packageName: '@studiometa/ui-motion',\n subpath: 'MotionView',\n exportName: 'MotionView',\n strategy: 'visible',\n group: 'motion',\n load: () => import('./MotionView.js').then(({ MotionView }) => MotionView),\n },\n};\n"],"mappings":";AAGA,MAAa,WAA8B;CACzC,QAAQ;EACN,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YAAY,OAAO,eAAe,MAAM,EAAE,aAAa,OAAO;EAC/D;CACD,sBAAsB;EACpB,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,UAAU,CAAC,SAAS;EACpB,YACE,OAAO,6BAA6B,MAAM,EAAE,2BAA2B,qBAAqB;EAC/F;CACD,gBAAgB;EACd,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,UAAU,CAAC,SAAS;EACpB,YAAY,OAAO,uBAAuB,MAAM,EAAE,qBAAqB,eAAe;EACvF;CACD,YAAY;EACV,OAAO;EACP,aAAa;EACb,SAAS;EACT,YAAY;EACZ,UAAU;EACV,OAAO;EACP,YAAY,OAAO,mBAAmB,MAAM,EAAE,iBAAiB,WAAW;EAC3E;CACF"}
@@ -0,0 +1,36 @@
1
+ import { ComponentLoadStrategy } from "@studiometa/js-toolkit";
2
+
3
+ //#region ../../scripts/manifest-types.d.ts
4
+ /**
5
+ * Authoring types for the component manifest generator (`scripts/generate-manifests.ts`).
6
+ *
7
+ * The runtime manifest types (`ComponentManifest`, `ComponentManifestEntry`,
8
+ * `ComponentLoadStrategy`) now live in `@studiometa/js-toolkit`. These two authoring types are
9
+ * repository-local tooling contracts: they describe the hand-authored catalogs the generator reads
10
+ * (`packages/ui/catalog.ts`, `packages/ui-mapbox/src/catalog.ts`), never a published runtime surface.
11
+ */
12
+ /**
13
+ * Curated authoring metadata for a single component, consumed by the manifest generator. The
14
+ * `subpath` and `exportName` default to the `token` when omitted.
15
+ */
16
+ interface CuratedComponentMetadata {
17
+ token: string;
18
+ group: string;
19
+ children?: readonly string[];
20
+ styles?: readonly string[];
21
+ integrations?: readonly string[];
22
+ subpath?: string;
23
+ exportName?: string;
24
+ }
25
+ /**
26
+ * The authoring catalog for a component package: the list of its components, the default strategy
27
+ * they share, and the abstract exports that are intentionally excluded from the manifest.
28
+ */
29
+ interface ComponentCatalog {
30
+ packageName: string;
31
+ strategy: ComponentLoadStrategy;
32
+ components: readonly CuratedComponentMetadata[];
33
+ abstractExports: readonly string[];
34
+ }
35
+ //#endregion
36
+ export { ComponentCatalog };
package/package.json CHANGED
@@ -1,11 +1,66 @@
1
1
  {
2
2
  "name": "@studiometa/ui-motion",
3
- "version": "0.0.1",
3
+ "version": "1.11.1",
4
4
  "description": "Vanilla js-toolkit components to animate elements declaratively with Motion",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
8
  "type": "module",
9
+ "sideEffects": [
10
+ "./dist/autoload.js"
11
+ ],
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "typescript": "./src/index.ts",
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js"
19
+ },
20
+ "./autoload": {
21
+ "typescript": "./src/autoload.ts",
22
+ "types": "./dist/autoload.d.ts",
23
+ "import": "./dist/autoload.js"
24
+ },
25
+ "./manifest": {
26
+ "typescript": "./src/manifest.ts",
27
+ "types": "./dist/manifest.d.ts",
28
+ "import": "./dist/manifest.js"
29
+ },
30
+ "./Motion": {
31
+ "typescript": "./src/Motion.ts",
32
+ "types": "./dist/Motion.d.ts",
33
+ "import": "./dist/Motion.js"
34
+ },
35
+ "./MotionScrollTimeline": {
36
+ "typescript": "./src/MotionScrollTimeline.ts",
37
+ "types": "./dist/MotionScrollTimeline.d.ts",
38
+ "import": "./dist/MotionScrollTimeline.js"
39
+ },
40
+ "./MotionSequence": {
41
+ "typescript": "./src/MotionSequence.ts",
42
+ "types": "./dist/MotionSequence.d.ts",
43
+ "import": "./dist/MotionSequence.js"
44
+ },
45
+ "./MotionView": {
46
+ "typescript": "./src/MotionView.ts",
47
+ "types": "./dist/MotionView.d.ts",
48
+ "import": "./dist/MotionView.js"
49
+ },
50
+ "./dependencies": {
51
+ "typescript": "./src/dependencies.ts",
52
+ "types": "./dist/dependencies.d.ts",
53
+ "import": "./dist/dependencies.js"
54
+ },
55
+ "./*": {
56
+ "typescript": "./src/*.ts",
57
+ "types": "./dist/*.d.ts",
58
+ "import": "./dist/*.js"
59
+ }
60
+ },
61
+ "scripts": {
62
+ "build": "node scripts/build.js"
63
+ },
9
64
  "repository": {
10
65
  "type": "git",
11
66
  "url": "git+https://github.com/studiometa/ui.git"
@@ -22,5 +77,19 @@
22
77
  "bugs": {
23
78
  "url": "https://github.com/studiometa/ui/issues"
24
79
  },
25
- "homepage": "https://github.com/studiometa/ui#readme"
80
+ "homepage": "https://github.com/studiometa/ui#readme",
81
+ "peerDependencies": {
82
+ "@studiometa/js-toolkit": "^3.9.0",
83
+ "motion": "^13.0.0"
84
+ },
85
+ "devDependencies": {
86
+ "@studiometa/js-toolkit": "^3.9.0",
87
+ "motion": "^13.0.0",
88
+ "tsdown": "0.21.5"
89
+ },
90
+ "files": [
91
+ "dist",
92
+ "README.md",
93
+ "LICENSE.md"
94
+ ]
26
95
  }