@octane-xplat/lottie 0.0.1 → 0.9.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.
Files changed (58) hide show
  1. package/README.md +36 -2
  2. package/dist/native/cx.mobile.js +11 -0
  3. package/dist/native/escape-props.js +39 -0
  4. package/dist/native/index.js +182 -0
  5. package/dist/native/layout-child.js +38 -0
  6. package/dist/native/octane-client-build.json +8 -0
  7. package/dist/native/vendor/ui-lottie/index.android.js +286 -0
  8. package/dist/native/vendor/ui-lottie/index.ios.js +214 -0
  9. package/dist/native/vendor/ui-lottie/src/lottie/index.common.js +50 -0
  10. package/dist/native/vendor/ui-lottie/src/lottie/utils.js +6 -0
  11. package/dist/web/escape-props.web.js +17 -0
  12. package/dist/web/index.js +332 -0
  13. package/dist/web/layout-child.web.js +47 -0
  14. package/dist/web/octane-client-build.json +8 -0
  15. package/package.json +81 -10
  16. package/platforms/android/include.gradle +7 -0
  17. package/platforms/android/java/com/nativescript/lottie/LottieAnimationView.java +92 -0
  18. package/platforms/android/lottie.aar +0 -0
  19. package/platforms/android/native-api-usage.json +16 -0
  20. package/platforms/ios/Podfile +5 -0
  21. package/src/Lottie.tsrx +161 -0
  22. package/src/Lottie.web.tsrx +135 -0
  23. package/src/cx.mobile.ts +8 -0
  24. package/src/escape-props.ts +65 -0
  25. package/src/escape-props.web.ts +25 -0
  26. package/src/index.ts +2 -0
  27. package/src/index.web.ts +2 -0
  28. package/src/layout-child.ts +57 -0
  29. package/src/layout-child.web.ts +108 -0
  30. package/src/native-elements.d.ts +8 -0
  31. package/src/props.ts +128 -0
  32. package/src/references.d.ts +3 -0
  33. package/src/vendor/ui-lottie/LICENSE.md +21 -0
  34. package/src/vendor/ui-lottie/src/lottie/index.android.ts +447 -0
  35. package/src/vendor/ui-lottie/src/lottie/index.common.ts +84 -0
  36. package/src/vendor/ui-lottie/src/lottie/index.d.ts +133 -0
  37. package/src/vendor/ui-lottie/src/lottie/index.ios.ts +345 -0
  38. package/src/vendor/ui-lottie/src/lottie/typings/android.d.ts +4149 -0
  39. package/src/vendor/ui-lottie/src/lottie/typings/android.nativescript.d.ts +12 -0
  40. package/src/vendor/ui-lottie/src/lottie/typings/dotlottie.ios.d.ts +14 -0
  41. package/src/vendor/ui-lottie/src/lottie/typings/ios.d.ts +384 -0
  42. package/src/vendor/ui-lottie/src/lottie/utils.ts +9 -0
  43. package/types/generated/.tsrx-typegen-manifest.json +18 -0
  44. package/types/generated/Lottie.d.ts +7 -0
  45. package/types/generated/Lottie.web.d.ts +7 -0
  46. package/types/generated/cx.mobile.d.ts +6 -0
  47. package/types/generated/escape-props.d.ts +15 -0
  48. package/types/generated/escape-props.web.d.ts +5 -0
  49. package/types/generated/index.d.ts +2 -0
  50. package/types/generated/index.web.d.ts +2 -0
  51. package/types/generated/layout-child.d.ts +6 -0
  52. package/types/generated/layout-child.web.d.ts +15 -0
  53. package/types/generated/props.d.ts +106 -0
  54. package/types/generated/vendor/ui-lottie/src/lottie/index.common.d.ts +30 -0
  55. package/types/generated/vendor/ui-lottie/src/lottie/index.ios.d.ts +35 -0
  56. package/types/generated/vendor/ui-lottie/src/lottie/utils.d.ts +1 -0
  57. package/index.d.ts +0 -1
  58. package/index.js +0 -2
@@ -0,0 +1,57 @@
1
+ import type { LayoutChildProps, FlexContainerProps } from './props'
2
+
3
+ // start/end shorthand → flex-start/flex-end.
4
+ const FLEX_JUSTIFY: Record<string, string> = { start: 'flex-start', end: 'flex-end' }
5
+ const FLEX_ALIGN: Record<string, string> = { start: 'flex-start', end: 'flex-end' }
6
+
7
+ /** NativeScript reads these attributes from each child view during parent
8
+ * layout. Values are forwarded with NativeScript's own property names.
9
+ * The flex-container props (justifyContent/alignItems/flexWrap/gap) land on
10
+ * the host flexboxlayout itself — its own attributes, not child metadata. */
11
+ export function layoutChildProps(props: LayoutChildProps & Partial<FlexContainerProps>) {
12
+ const result: Record<string, any> = {}
13
+ for (const key of [
14
+ 'row',
15
+ 'col',
16
+ 'rowSpan',
17
+ 'colSpan',
18
+ 'dock',
19
+ 'left',
20
+ 'top',
21
+ 'flexGrow',
22
+ 'flexShrink',
23
+ 'alignSelf',
24
+ 'order',
25
+ ] as const) {
26
+ if (props[key] !== undefined) {
27
+ result[key] = props[key]
28
+ }
29
+ }
30
+
31
+ if (props.justifyContent !== undefined) {
32
+ result.justifyContent = FLEX_JUSTIFY[props.justifyContent] ?? props.justifyContent
33
+ }
34
+
35
+ if (props.alignItems !== undefined) {
36
+ result.alignItems = FLEX_ALIGN[props.alignItems] ?? props.alignItems
37
+ }
38
+
39
+ if (props.flexWrap !== undefined) {
40
+ result.flexWrap =
41
+ props.flexWrap === true ? 'wrap' : props.flexWrap === false ? 'nowrap' : props.flexWrap
42
+ }
43
+
44
+ if (props.gap !== undefined) {
45
+ result.gap = props.gap
46
+ }
47
+
48
+ if (props.rowGap !== undefined) {
49
+ result.rowGap = props.rowGap
50
+ }
51
+
52
+ if (props.columnGap !== undefined) {
53
+ result.columnGap = props.columnGap
54
+ }
55
+
56
+ return result
57
+ }
@@ -0,0 +1,108 @@
1
+ import type { LayoutChildProps, FlexContainerProps } from './props'
2
+
3
+ /** The shared contract is "numbers are dips" (RN semantics), but octane's DOM
4
+ * renderer keeps React's unitless list — lineHeight is unitless there, so
5
+ * `style={{lineHeight: 40}}` would render a 40× multiplier instead of 40px.
6
+ * lineHeight is the one unitless-in-React prop that is a length in the
7
+ * shared vocabulary; force the px suffix. */
8
+ export function normStyle(style: any) {
9
+ if (style && typeof style.lineHeight === 'number') {
10
+ return { ...style, lineHeight: style.lineHeight + 'px' }
11
+ }
12
+
13
+ return style
14
+ }
15
+
16
+ // start/end shorthand → flex-start/flex-end (valid in both engines).
17
+ const FLEX_JUSTIFY: Record<string, string> = {
18
+ start: 'flex-start',
19
+ end: 'flex-end',
20
+ }
21
+
22
+ const FLEX_ALIGN: Record<string, string> = {
23
+ start: 'flex-start',
24
+ end: 'flex-end',
25
+ }
26
+
27
+ /** Convert parent-layout metadata to CSS on the web leaf. Native's `dock`
28
+ * attribute has no CSS equivalent and is ignored on web. Grid indices are
29
+ * zero-based in the shared API, matching NativeScript. */
30
+ export function layoutChildProps(
31
+ props: LayoutChildProps & Partial<FlexContainerProps> & { style?: any },
32
+ baseStyle = props.style,
33
+ ) {
34
+ const style = { ...normStyle(baseStyle) }
35
+ if (props.row !== undefined) {
36
+ style.gridRow = `${props.row + 1} / span ${props.rowSpan ?? 1}`
37
+ } else if (props.rowSpan !== undefined) {
38
+ style.gridRow = `span ${props.rowSpan}`
39
+ }
40
+
41
+ if (props.col !== undefined) {
42
+ style.gridColumn = `${props.col + 1} / span ${props.colSpan ?? 1}`
43
+ } else if (props.colSpan !== undefined) {
44
+ style.gridColumn = `span ${props.colSpan}`
45
+ }
46
+
47
+ if (props.left !== undefined) {
48
+ style.left = props.left
49
+ }
50
+
51
+ if (props.top !== undefined) {
52
+ style.top = props.top
53
+ }
54
+
55
+ if (props.flexGrow !== undefined) {
56
+ style.flexGrow = props.flexGrow
57
+ }
58
+
59
+ if (props.flexShrink !== undefined) {
60
+ style.flexShrink = props.flexShrink
61
+ }
62
+
63
+ if (props.alignSelf !== undefined) {
64
+ style.alignSelf = props.alignSelf
65
+ }
66
+
67
+ if (props.order !== undefined) {
68
+ style.order = props.order
69
+ }
70
+
71
+ // Flex-container props (View/Row/Pressable hosts) — RN vocabulary on the
72
+ // element style. Numbers become px via octane's style normalization.
73
+ if (props.justifyContent !== undefined) {
74
+ style.justifyContent = FLEX_JUSTIFY[props.justifyContent] ?? props.justifyContent
75
+ }
76
+
77
+ if (props.alignItems !== undefined) {
78
+ style.alignItems = FLEX_ALIGN[props.alignItems] ?? props.alignItems
79
+ }
80
+
81
+ if (props.flexWrap !== undefined) {
82
+ style.flexWrap =
83
+ props.flexWrap === true ? 'wrap' : props.flexWrap === false ? 'nowrap' : props.flexWrap
84
+ }
85
+
86
+ if (props.gap !== undefined) {
87
+ style.gap = props.gap
88
+ }
89
+
90
+ if (props.rowGap !== undefined) {
91
+ style.rowGap = props.rowGap
92
+ }
93
+
94
+ if (props.columnGap !== undefined) {
95
+ style.columnGap = props.columnGap
96
+ }
97
+
98
+ // The shared contract is "numbers are dips" (RN semantics), but octane's
99
+ // DOM renderer keeps React's unitless list — lineHeight is unitless there,
100
+ // so `style={{lineHeight: 40}}` would render a 40× multiplier instead of
101
+ // 40px. lineHeight is the one unitless-in-React prop that is a length in
102
+ // the shared vocabulary; force the px suffix.
103
+ if (typeof style.lineHeight === 'number') {
104
+ style.lineHeight = style.lineHeight + 'px'
105
+ }
106
+
107
+ return { style }
108
+ }
@@ -0,0 +1,8 @@
1
+ import { LottieView } from './vendor/ui-lottie/src/lottie'
2
+ import type { Attributes } from '@nativescript-community/octane/intrinsics'
3
+
4
+ declare module '@nativescript-community/octane/intrinsics' {
5
+ interface NativeScriptElements {
6
+ xplatlottie: Attributes<typeof LottieView>
7
+ }
8
+ }
package/src/props.ts ADDED
@@ -0,0 +1,128 @@
1
+ export interface LayoutChildProps {
2
+ row?: number
3
+ col?: number
4
+ rowSpan?: number
5
+ colSpan?: number
6
+ dock?: 'left' | 'top' | 'right' | 'bottom'
7
+ left?: number
8
+ top?: number
9
+ flexGrow?: number
10
+ flexShrink?: number
11
+ alignSelf?: string
12
+ order?: number
13
+ }
14
+
15
+ /** Flex-container props shared by View/Row/Pressable — RN vocabulary, applied
16
+ * to the host flexboxlayout natively and the element's style on web.
17
+ * `gap` is a dip number (px on web); NS supports it on FlexboxLayout only. */
18
+ export interface FlexContainerProps {
19
+ justifyContent?: 'start' | 'center' | 'end' | 'space-between' | 'space-around' | 'space-evenly'
20
+ alignItems?: 'start' | 'center' | 'end' | 'stretch' | 'baseline'
21
+ flexWrap?: boolean | 'wrap' | 'nowrap' | 'wrap-reverse'
22
+ gap?: number | string
23
+ rowGap?: number | string
24
+ columnGap?: number | string
25
+ }
26
+
27
+ export type Role =
28
+ | 'button'
29
+ | 'link'
30
+ | 'search'
31
+ | 'image'
32
+ | 'heading'
33
+ | 'adjustable'
34
+ | 'summary'
35
+ | 'text'
36
+ | 'none'
37
+ | 'progressbar'
38
+ | 'checkbox'
39
+ | 'switch'
40
+ | 'radio'
41
+ | 'spinbutton'
42
+ | 'tab'
43
+
44
+ export interface AccessibilityProps {
45
+ accessible?: boolean
46
+ accessibilityLabel?: string
47
+ accessibilityRole?: Role
48
+ accessibilityHint?: string
49
+ accessibilityValue?: string
50
+ accessibilityState?: {
51
+ disabled?: boolean
52
+ selected?: boolean
53
+ checked?: boolean
54
+ }
55
+ accessibilityLiveRegion?: 'none' | 'polite' | 'assertive'
56
+ }
57
+
58
+ export type LottieFit = 'contain' | 'cover' | 'fill'
59
+
60
+ export interface LottieEvent {
61
+ /** Animation duration in milliseconds once loaded (0 before then). */
62
+ duration?: number
63
+ /** Failure description. */
64
+ message?: string
65
+ }
66
+
67
+ export interface LottieHandle {
68
+ play(): void
69
+ pause(): void
70
+ /** Stop and reset the playhead to the start. */
71
+ stop(): void
72
+ /** Seek to a normalized position, 0..1. */
73
+ seekTo(progress: number): void
74
+ /** Playback speed multiplier (1 = normal). */
75
+ setSpeed(n: number): void
76
+ /** Current playhead position, 0..1. */
77
+ progress(): number
78
+ /** Animation duration in milliseconds (0 before load). */
79
+ duration(): number
80
+ isPlaying(): boolean
81
+ /** The platform surface (lottie-web AnimationItem / plugin LottieView). */
82
+ native: any
83
+ }
84
+
85
+ /** Lottie animation — lottie-web (svg renderer) on web, vendored
86
+ * ui-lottie (`src/vendor/ui-lottie` submodule, `octane-xplat/ui-lottie`
87
+ * @ `xplat-vendored`) on native.
88
+ * Progress is always normalized 0..1 and durations are milliseconds on
89
+ * every platform (the native plugin reports seconds on iOS). */
90
+ export interface LottieProps extends LayoutChildProps, AccessibilityProps {
91
+ className?: any
92
+ style?: any
93
+ id?: string
94
+ /** Remote URL; native also accepts `~/` bundle paths, absolute file
95
+ * paths, `res://` names, `.lottie`/`.zip` containers, and raw JSON
96
+ * strings starting with `{`. */
97
+ src?: string
98
+ /** Inline animation object — wins over `src` when both are given. */
99
+ data?: object
100
+ /** Start playing as soon as the composition loads. Default true —
101
+ * matches lottie-web; the native plugin's own default is false. */
102
+ autoPlay?: boolean
103
+ /** Repeat forever. Default false — a finite play is the least
104
+ * surprising shared contract (lottie-web's own default is true). */
105
+ loop?: boolean
106
+ /** Controlled playback — leave unset for uncontrolled play. */
107
+ playing?: boolean
108
+ /** Controlled playhead position, 0..1. */
109
+ progress?: number
110
+ /** Playback speed multiplier (1 = normal). */
111
+ speed?: number
112
+ /** Content fitting inside the frame: `contain` (letterbox, default),
113
+ * `cover` (crop to fill), `fill` (stretch). */
114
+ fit?: LottieFit
115
+ /** Composition parsed and ready — `e.duration` is the length in ms. */
116
+ onLoaded?: (e: LottieEvent) => void
117
+ /** Reached the end; does not fire per loop iteration. */
118
+ onEnded?: () => void
119
+ /** Load or parse failure. */
120
+ onError?: (e: LottieEvent) => void
121
+ /** Imperative handle — play/pause/seek plus `native` for anything the
122
+ * shared props don't cover. */
123
+ bind?: (h: LottieHandle) => void
124
+ /** Platform escape hatches, applied after the shared props. */
125
+ ios?: Record<string, any>
126
+ android?: Record<string, any>
127
+ web?: Record<string, any>
128
+ }
@@ -0,0 +1,3 @@
1
+ /// <reference types="@nativescript/types" />
2
+ /// <reference types="vite/client" />
3
+ /// <reference path="../node_modules/@nativescript/core/global-types.d.ts" />
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ nativescript-lottie
4
+ Copyright (c) 2017, Brad Martin
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.