@amazon-devices/vega-carousel 0.1.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.
Files changed (71) hide show
  1. package/LICENSE +7 -0
  2. package/README.md +0 -0
  3. package/dist/Carousel/Carousel.d.ts +16 -0
  4. package/dist/Carousel/Carousel.js +102 -0
  5. package/dist/Carousel/Utils.d.ts +4 -0
  6. package/dist/Carousel/Utils.js +35 -0
  7. package/dist/Carousel/index.d.ts +7 -0
  8. package/dist/Carousel/index.js +23 -0
  9. package/dist/Carousel/types.d.ts +406 -0
  10. package/dist/Carousel/types.js +2 -0
  11. package/dist/CarouselData/CarouselDataAdapter.d.ts +141 -0
  12. package/dist/CarouselData/CarouselDataAdapter.js +67 -0
  13. package/dist/CarouselData/CarouselDataResolver.d.ts +100 -0
  14. package/dist/CarouselData/CarouselDataResolver.js +224 -0
  15. package/dist/CarouselData/CarouselDataTypes.d.ts +280 -0
  16. package/dist/CarouselData/CarouselDataTypes.js +84 -0
  17. package/dist/CarouselData/index.d.ts +3 -0
  18. package/dist/CarouselData/index.js +24 -0
  19. package/dist/CarouselScrollable/CarouselScrollable.d.ts +67 -0
  20. package/dist/CarouselScrollable/CarouselScrollable.js +77 -0
  21. package/dist/CarouselScrollable/CarouselScrollableProps.d.ts +499 -0
  22. package/dist/CarouselScrollable/CarouselScrollableProps.js +211 -0
  23. package/dist/CarouselScrollable/CarouselScrollableRef.d.ts +80 -0
  24. package/dist/CarouselScrollable/CarouselScrollableRef.js +7 -0
  25. package/dist/CarouselScrollable/CarouselScrollableTypes.d.ts +224 -0
  26. package/dist/CarouselScrollable/CarouselScrollableTypes.js +116 -0
  27. package/dist/CarouselScrollable/CarouselSimple.d.ts +71 -0
  28. package/dist/CarouselScrollable/CarouselSimple.js +111 -0
  29. package/dist/CarouselScrollable/CarouselSimpleProps.d.ts +29 -0
  30. package/dist/CarouselScrollable/CarouselSimpleProps.js +7 -0
  31. package/dist/CarouselScrollable/index.d.ts +6 -0
  32. package/dist/CarouselScrollable/index.js +27 -0
  33. package/dist/CarouselScrollable/native/CarouselNativeHostComponent.d.ts +109 -0
  34. package/dist/CarouselScrollable/native/CarouselNativeHostComponent.js +82 -0
  35. package/dist/CarouselScrollable/native/CarouselNativeItemHostComponent.d.ts +94 -0
  36. package/dist/CarouselScrollable/native/CarouselNativeItemHostComponent.js +42 -0
  37. package/dist/CarouselScrollable/native/CarouselNativeItemWrapper.d.ts +255 -0
  38. package/dist/CarouselScrollable/native/CarouselNativeItemWrapper.js +276 -0
  39. package/dist/CarouselScrollable/native/CarouselNativeLogic.d.ts +209 -0
  40. package/dist/CarouselScrollable/native/CarouselNativeLogic.js +349 -0
  41. package/dist/CarouselScrollable/native/CarouselNativeWrapper.d.ts +68 -0
  42. package/dist/CarouselScrollable/native/CarouselNativeWrapper.js +164 -0
  43. package/dist/CarouselScrollable/native/index.d.ts +5 -0
  44. package/dist/CarouselScrollable/native/index.js +26 -0
  45. package/dist/CarouselScrollable/recyclerview/JSRecyclerViewList.d.ts +25 -0
  46. package/dist/CarouselScrollable/recyclerview/JSRecyclerViewList.js +150 -0
  47. package/dist/index.d.ts +3 -0
  48. package/dist/index.js +24 -0
  49. package/dist/kepler/aarch64-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
  50. package/dist/kepler/aarch64-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  51. package/dist/kepler/aarch64-release/lib/com.amazon.keplerscript.carousel.so +0 -0
  52. package/dist/kepler/aarch64-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  53. package/dist/kepler/armv7-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
  54. package/dist/kepler/armv7-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  55. package/dist/kepler/armv7-release/lib/com.amazon.keplerscript.carousel.so +0 -0
  56. package/dist/kepler/armv7-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  57. package/dist/kepler/tm-manifest.json +1 -0
  58. package/dist/kepler/x86_64-debug/lib/com.amazon.keplerscript.carousel.so +0 -0
  59. package/dist/kepler/x86_64-debug/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  60. package/dist/kepler/x86_64-release/lib/com.amazon.keplerscript.carousel.so +0 -0
  61. package/dist/kepler/x86_64-release/lib/com.amazon.keplerscript.carousel.so.debug +0 -0
  62. package/dist/utils/CarouselLogger.d.ts +295 -0
  63. package/dist/utils/CarouselLogger.js +370 -0
  64. package/dist/utils/CarouselReactNativeUtilities.d.ts +108 -0
  65. package/dist/utils/CarouselReactNativeUtilities.js +150 -0
  66. package/dist/utils/HelperTypes.d.ts +5 -0
  67. package/dist/utils/HelperTypes.js +7 -0
  68. package/dist/utils/index.d.ts +3 -0
  69. package/dist/utils/index.js +24 -0
  70. package/package.json +1 -0
  71. package/react-native.config.js +22 -0
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Helper constant that is set to `true` when running tests.
3
+ */
4
+ export declare const isTest: boolean;
5
+ /**
6
+ * Wrapper function that calls {@link registerGeneratedViewConfig} from the
7
+ * {@link @amazon-devices/react-native-kepler/Libraries/Utilities} library when not
8
+ * running tests, and creates a Jest mock on tests.
9
+ */
10
+ export declare const registerGeneratedViewConfig: any;
11
+ /**
12
+ * Wrapper function that calls {@link codegenNativeCommands} from the
13
+ * {@link @amazon-devices/react-native-kepler/Libraries/Utilities} library when not
14
+ * running tests, and creates a Jest mock on tests.
15
+ */
16
+ export declare const codegenNativeCommands: any;
17
+ /**
18
+ * Helper type representing one entry on the `validAttributes` parameter for the
19
+ * {@link registerGeneratedViewConfig} function.
20
+ */
21
+ type ValidAttrsType = {
22
+ [key: string]: boolean;
23
+ };
24
+ /**
25
+ * Helper function that can create a "valid attributes" object from an object
26
+ * of default values.
27
+ *
28
+ * Since TypeScript can't return a list of properties for a type without it
29
+ * being instantiated into an object first, you're required to pass an object
30
+ * with default values for it to traverse.
31
+ *
32
+ * @template TypeT The type of the passed object to use to create a "valid
33
+ * attributes" map.
34
+ *
35
+ * @param {TypeT} defaultValues An object with fields containing any value. Each
36
+ * field with a value will have a "valid attribute" generated for it.
37
+ *
38
+ * @return {ValidAttrsType} Returns a full map-like object to be used as the
39
+ * `validAttributes` parameter for the
40
+ * {@link registerGeneratedViewConfig} function.
41
+ */
42
+ export declare function validAttributesFromDefaults<TypeT extends object>(defaultValues: TypeT): ValidAttrsType;
43
+ /**
44
+ * Helper type representing one entry of the `directEventTypes` attribute used
45
+ * with the {@link registerGeneratedViewConfig} function.
46
+ */
47
+ type EventRegistrationType = {
48
+ [eventName: string]: {
49
+ registrationName: string;
50
+ };
51
+ };
52
+ /**
53
+ * Helper type representing one entry of the input object required by the
54
+ * {@link buildDirectEvents} functions.
55
+ */
56
+ type BuildDirectEventsType = {
57
+ [key: string]: string;
58
+ };
59
+ /**
60
+ * Helper function used to build the `directEventType` attribute used with the
61
+ * {@link registerGeneratedViewConfig} function.
62
+ *
63
+ * This function requires a special syntax to be able to produce a valid output.
64
+ * It requires the `events` argument to be an object in the following format:
65
+ *
66
+ * ```ts
67
+ * const arg = {
68
+ * nativeEventName: "typeOfEvent",
69
+ * ...
70
+ * };
71
+ * ```
72
+ *
73
+ * If we used the exact arg showed above, it would mean that the native layer
74
+ * can emmit a `nativeEventName` event like in the following snipped:
75
+ *
76
+ * ```cpp
77
+ * if (!eventEmitter_) {
78
+ * eventEmitter_->emit("nativeEventName");
79
+ * }
80
+ * ```
81
+ *
82
+ * Then, in the JS layer, if we have the attribute `onNativeEventName` callback,
83
+ * such a callback would be invoked.
84
+ *
85
+ * Also, the generated `directEventType` for the example above would be:
86
+ *
87
+ * ```ts
88
+ * const directEventType = {
89
+ * typeOfEventNativeEventName: {
90
+ * registrationName: 'onNativeEventName',
91
+ * },
92
+ * }
93
+ * ```
94
+ *
95
+ * @param {BuildDirectEventsType} events The events object to be used to
96
+ * generate the `directEventType` attribute used with the
97
+ * {@link registerGeneratedViewConfig} function.
98
+ *
99
+ * @return {EventRegistrationType} Returns a valid object to be used by the
100
+ * {@link registerGeneratedViewConfig} function as the
101
+ * `directEventTypes` attribute.
102
+ *
103
+ * @see {@link registerGeneratedViewConfig}
104
+ * @see {@link EventRegistrationType}
105
+ * @see {@link BuildDirectEventsType}
106
+ */
107
+ export declare function buildDirectEvents(events: BuildDirectEventsType): EventRegistrationType;
108
+ export {};
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 - 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
4
+ *
5
+ * PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.buildDirectEvents = exports.validAttributesFromDefaults = exports.codegenNativeCommands = exports.registerGeneratedViewConfig = exports.isTest = void 0;
9
+ /**
10
+ * Helper constant that is set to `true` when running tests.
11
+ */
12
+ /* istanbul ignore next */
13
+ exports.isTest = typeof process !== 'undefined' &&
14
+ typeof process.env !== 'undefined' &&
15
+ (process.env.JEST_WORKER_ID !== undefined || process.env.NODE_ENV === 'test');
16
+ /**
17
+ * Wrapper function that calls {@link registerGeneratedViewConfig} from the
18
+ * {@link @amazon-devices/react-native-kepler/Libraries/Utilities} library when not
19
+ * running tests, and creates a Jest mock on tests.
20
+ */
21
+ exports.registerGeneratedViewConfig = exports.isTest
22
+ ? jest.fn()
23
+ : /* istanbul ignore next */
24
+ require('@amazon-devices/react-native-kepler/Libraries/Utilities/registerGeneratedViewConfig');
25
+ /**
26
+ * Helper function that creates an object with a set of Mock functions to be
27
+ * used in the {@link codegenNativeCommands} during tests.
28
+ */
29
+ function createMockCommands(keys) {
30
+ return keys.reduce((acc, key) => ({
31
+ ...acc,
32
+ [key]: jest.fn(),
33
+ }), {});
34
+ }
35
+ /**
36
+ * Wrapper function that calls {@link codegenNativeCommands} from the
37
+ * {@link @amazon-devices/react-native-kepler/Libraries/Utilities} library when not
38
+ * running tests, and creates a Jest mock on tests.
39
+ */
40
+ exports.codegenNativeCommands = exports.isTest
41
+ ? jest.fn((args) => createMockCommands(args.supportedCommands))
42
+ : /* istanbul ignore next */
43
+ require('@amazon-devices/react-native-kepler/Libraries/Utilities/codegenNativeCommands')
44
+ .default;
45
+ /**
46
+ * Helper function used to "fold" an array of strings into a full object of
47
+ * {@link ValidAttrsType}.
48
+ *
49
+ * This function is not intended to be used standalone, but as an argument in
50
+ * the {@link Array.reduce} function.
51
+ *
52
+ * @param {ValidAttrsType} attrs The cumulative object of all the past valid
53
+ * attributes.
54
+ * @param {string} prop The name of the next valid attribute to be folded.
55
+ *
56
+ * @return {ValidAttrsType} Returns the cumulative valid attributes after the
57
+ * last value is folded.
58
+ */
59
+ function foldValidAttrs(attrs, prop) {
60
+ return {
61
+ ...attrs,
62
+ [prop]: true,
63
+ };
64
+ }
65
+ /**
66
+ * Helper function that can create a "valid attributes" object from an object
67
+ * of default values.
68
+ *
69
+ * Since TypeScript can't return a list of properties for a type without it
70
+ * being instantiated into an object first, you're required to pass an object
71
+ * with default values for it to traverse.
72
+ *
73
+ * @template TypeT The type of the passed object to use to create a "valid
74
+ * attributes" map.
75
+ *
76
+ * @param {TypeT} defaultValues An object with fields containing any value. Each
77
+ * field with a value will have a "valid attribute" generated for it.
78
+ *
79
+ * @return {ValidAttrsType} Returns a full map-like object to be used as the
80
+ * `validAttributes` parameter for the
81
+ * {@link registerGeneratedViewConfig} function.
82
+ */
83
+ function validAttributesFromDefaults(defaultValues) {
84
+ const propNames = Object.keys(defaultValues);
85
+ return propNames.reduce(foldValidAttrs, {});
86
+ }
87
+ exports.validAttributesFromDefaults = validAttributesFromDefaults;
88
+ /**
89
+ * Helper function used to build the `directEventType` attribute used with the
90
+ * {@link registerGeneratedViewConfig} function.
91
+ *
92
+ * This function requires a special syntax to be able to produce a valid output.
93
+ * It requires the `events` argument to be an object in the following format:
94
+ *
95
+ * ```ts
96
+ * const arg = {
97
+ * nativeEventName: "typeOfEvent",
98
+ * ...
99
+ * };
100
+ * ```
101
+ *
102
+ * If we used the exact arg showed above, it would mean that the native layer
103
+ * can emmit a `nativeEventName` event like in the following snipped:
104
+ *
105
+ * ```cpp
106
+ * if (!eventEmitter_) {
107
+ * eventEmitter_->emit("nativeEventName");
108
+ * }
109
+ * ```
110
+ *
111
+ * Then, in the JS layer, if we have the attribute `onNativeEventName` callback,
112
+ * such a callback would be invoked.
113
+ *
114
+ * Also, the generated `directEventType` for the example above would be:
115
+ *
116
+ * ```ts
117
+ * const directEventType = {
118
+ * typeOfEventNativeEventName: {
119
+ * registrationName: 'onNativeEventName',
120
+ * },
121
+ * }
122
+ * ```
123
+ *
124
+ * @param {BuildDirectEventsType} events The events object to be used to
125
+ * generate the `directEventType` attribute used with the
126
+ * {@link registerGeneratedViewConfig} function.
127
+ *
128
+ * @return {EventRegistrationType} Returns a valid object to be used by the
129
+ * {@link registerGeneratedViewConfig} function as the
130
+ * `directEventTypes` attribute.
131
+ *
132
+ * @see {@link registerGeneratedViewConfig}
133
+ * @see {@link EventRegistrationType}
134
+ * @see {@link BuildDirectEventsType}
135
+ */
136
+ function buildDirectEvents(events) {
137
+ let directEvents = {};
138
+ const lowercase = (str) => str.toLowerCase();
139
+ const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1);
140
+ for (const event in events) {
141
+ const eventName = capitalize(event);
142
+ const eventType = lowercase(events[event]);
143
+ directEvents = {
144
+ ...directEvents,
145
+ [`${eventType}${eventName}`]: { registrationName: `on${eventName}` },
146
+ };
147
+ }
148
+ return directEvents;
149
+ }
150
+ exports.buildDirectEvents = buildDirectEvents;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This helper type is to indicate that the use of the TS type `any` is
3
+ * necessary in an API of this package.
4
+ */
5
+ export type AnyValue = any;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All rights reserved.
4
+ *
5
+ * PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from './HelperTypes';
2
+ export * from './CarouselLogger';
3
+ export * from './CarouselReactNativeUtilities';
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright (c) 2024 - 2025 Amazon.com, Inc. or its affiliates. All rights reserved.
4
+ *
5
+ * PROPRIETARY/CONFIDENTIAL. USE IS SUBJECT TO LICENSE TERMS.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ __exportStar(require("./HelperTypes"), exports);
23
+ __exportStar(require("./CarouselLogger"), exports);
24
+ __exportStar(require("./CarouselReactNativeUtilities"), exports);
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name": "@amazon-devices/vega-carousel", "version": "0.1.3", "main": "dist/index.js", "types": "dist/index.d.ts", "files": ["dist", "react-native.config.js", "THIRD_PARTY_NOTICES.txt"], "scripts": {"clean": "rm -rf build dist generated logs node_modules", "test:snapshot": "jest --colors --updateSnapshot", "start": "node node_modules/react-native/local-cli/cli.js start", "test": "jest --colors", "lint": "eslint src --ext .ts,.tsx", "lint:fix": "eslint src --ext .ts,.tsx --fix", "lint-staged": "lint-staged --allow-empty", "format": "clang-format -i --glob=\"native/**/*.{cpp,h}\"", "git-commit-template": "git-commit-template .git-commit-template", "compile": "tsc -p tsconfig-build.json", "build": "npm-run-all format compile"}, "dependencies": {"@amazon-devices/react-native-kepler": "^2.0.0", "ansi-colors": "^4.1.3", "react": "^18.2.0", "react-native": "^0.72.0", "recyclerlistview": "4.2.1"}, "devDependencies": {"@babel/core": "^7.20.0", "@babel/plugin-transform-private-methods": "^7.23.3", "@babel/runtime": "^7.20.0", "@bam.tech/jest-junit-reports-merger": "^1.1.0", "@react-native-community/eslint-config": "^3.2.0", "@testing-library/jest-native": "^5.4.3", "@testing-library/react-native": "^11.5.4", "@types/jest": "^28.0.0", "@types/react-test-renderer": "^18.0.0", "@typescript-eslint/eslint-plugin": "^5.18.0", "babel-jest": "^28.0.0", "clang-format": "^1.8.0", "eslint": "^8.19.0", "eslint-plugin-react-native": "^4.1.0", "git-commit-template": "^1.0.5", "lint-staged": "^12.3.7", "jest": "^28.0.0", "jest-junit": "^16.0.0", "metro-react-native-babel-preset": "^0.76.5", "npm-run-all": "^4.1.5", "prettier": "^3.0.0", "react": "^18.2.0", "react-native": "^0.72.0", "react-test-renderer": "18.2.0", "ts-jest": "^28.0.0", "typedoc": "^0.25.7", "typescript": "4.9.5", "@amazon-devices/kepler-cli-platform": "^0", "@react-native-community/cli": "^11.2.0"}, "resolutions": {"@types/react": "^18"}, "peerDependencies": {"react": "^18.2.0", "react-native": "^0.72.0"}, "kepler": {"projectType": "turbomodule", "toolchain": "clang", "targets": ["tv"], "os": ["vega"]}, "eslintConfig": {"extends": "@react-native-community", "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"], "root": true}, "prettier": {"arrowParens": "avoid", "bracketSameLine": true, "bracketSpacing": false, "singleQuote": true, "trailingComma": "all"}, "npm-pretty-much": {"allowUnsafeName": "reason for using a unsafe name"}, "license": "See license in LICENSE"}
@@ -0,0 +1,22 @@
1
+ module.exports = {
2
+ dependency: {
3
+ platforms: {
4
+ kepler: {
5
+ autolink: {
6
+ KeplerCarousel: {
7
+ uiComponentName: '/com.amazon.keplerscript.carousel',
8
+ linkDynamic: true,
9
+ provider: 'application',
10
+ turbomodules: [],
11
+ components: [
12
+ 'KeplerScrollable',
13
+ 'KeplerScrollableItemFrame',
14
+ 'CarouselNative',
15
+ 'CarouselNativeItem',
16
+ ],
17
+ },
18
+ },
19
+ },
20
+ },
21
+ },
22
+ };