@snap/valdi 1.0.7 → 1.0.8

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 (160) hide show
  1. package/README.md +12 -3
  2. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  3. package/bundled-skills/registry.json +20 -0
  4. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  5. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  6. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  7. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  8. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  9. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  10. package/bundled-skills/skills/valdi-bazel/skill.md +122 -0
  11. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  12. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  13. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  14. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  15. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  16. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  17. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  18. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  19. package/bundled-skills/skills/valdi-custom-view/skill.md +62 -0
  20. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  21. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  22. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  23. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  24. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  25. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  26. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  27. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  28. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  29. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  30. package/bundled-skills/skills/valdi-overview/skill.md +63 -0
  31. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  32. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  33. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  34. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  35. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-polyglot-module/skill.md +85 -0
  37. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  38. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  39. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  40. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  41. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  42. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  43. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  44. package/dist/commands/bootstrap.js +0 -7
  45. package/dist/commands/newModule.js +10 -14
  46. package/dist/commands/skills.js +16 -0
  47. package/dist/commands/skills_commands/create.js +125 -0
  48. package/dist/commands/skills_commands/install.js +96 -0
  49. package/dist/commands/skills_commands/list.js +83 -0
  50. package/dist/commands/skills_commands/remove.js +41 -0
  51. package/dist/commands/skills_commands/update.js +59 -0
  52. package/dist/core/constants.js +0 -1
  53. package/dist/setup/versions.js +1 -1
  54. package/dist/utils/skillsAdapters.js +140 -0
  55. package/dist/utils/skillsRegistry.js +40 -0
  56. package/package.json +6 -1
  57. package/.bazelignore +0 -2
  58. package/.bootstrap/apps/cli_application/BUILD.bazel.template +0 -7
  59. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -11
  60. package/.bootstrap/apps/cli_application/modules/{{MODULE_NAME}}/src/index.ts +0 -1
  61. package/.bootstrap/apps/ui_application/.eslint.rc +0 -27
  62. package/.bootstrap/apps/ui_application/BUILD.bazel.template +0 -19
  63. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/BUILD.bazel.template +0 -21
  64. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/res/valdi@3x.png +0 -0
  65. package/.bootstrap/apps/ui_application/modules/{{MODULE_NAME}}/src/App.tsx +0 -133
  66. package/.bootstrap/apps/ui_application/package.json +0 -24
  67. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  68. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  69. package/.bootstrap/modules/cpp_bridge_module/src/Calculator.d.ts +0 -4
  70. package/.bootstrap/modules/ios_android_bridge_module/BUILD.bazel.template +0 -39
  71. package/.bootstrap/modules/ios_android_bridge_module/android/CalculatorModuleFactory.kt.template +0 -18
  72. package/.bootstrap/modules/ios_android_bridge_module/ios/SCCCalculatorModuleFactory.m.template +0 -31
  73. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  74. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  75. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  76. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  77. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  78. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  79. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  80. package/.bootstrap/modules/ui_component/BUILD.bazel.template +0 -34
  81. package/.bootstrap/modules/ui_component/src/NewModuleComponent.tsx +0 -45
  82. package/.config/copyconfig.json +0 -10
  83. package/.editorconfig +0 -21
  84. package/.eslintignore +0 -1
  85. package/.eslintrc.js +0 -72
  86. package/.github/README.md +0 -164
  87. package/.metadata/.bazelrc.template +0 -91
  88. package/.metadata/.bazelversion.template +0 -1
  89. package/.metadata/.cursorrules.template +0 -60
  90. package/.metadata/.editorconfig.template +0 -37
  91. package/.metadata/.eslintrc.js.template +0 -27
  92. package/.metadata/.gitignore.template +0 -4
  93. package/.metadata/.prettierrc.json.template +0 -7
  94. package/.metadata/.watchmanconfig.template +0 -8
  95. package/.metadata/AGENTS.md.template +0 -282
  96. package/.metadata/README.md.template +0 -31
  97. package/.metadata/WORKSPACE.template +0 -57
  98. package/.metadata/config.yaml.template +0 -1
  99. package/.metadata/package.json.template +0 -23
  100. package/.prettierignore +0 -2
  101. package/.prettierrc.json +0 -7
  102. package/LINUX_COMPATIBILITY.md +0 -248
  103. package/prettier.config.js +0 -4
  104. package/scripts/sync-agents-md.sh +0 -44
  105. package/scripts/update-agents-templates.ts +0 -170
  106. package/spec/support/jasmine.json +0 -6
  107. package/src/commands/bootstrap.ts +0 -410
  108. package/src/commands/build.ts +0 -89
  109. package/src/commands/devSetup.ts +0 -17
  110. package/src/commands/doctor.ts +0 -1832
  111. package/src/commands/export.ts +0 -131
  112. package/src/commands/hotreload.ts +0 -108
  113. package/src/commands/install.ts +0 -93
  114. package/src/commands/lint.ts +0 -15
  115. package/src/commands/lint_commands/lintCheck.ts +0 -53
  116. package/src/commands/lint_commands/lintFormat.ts +0 -49
  117. package/src/commands/log.ts +0 -108
  118. package/src/commands/newModule.ts +0 -286
  119. package/src/commands/package.ts +0 -102
  120. package/src/commands/projectsync.ts +0 -488
  121. package/src/commands/test.ts +0 -68
  122. package/src/core/constants.ts +0 -98
  123. package/src/core/errors.ts +0 -10
  124. package/src/index.ts +0 -27
  125. package/src/setup/DevSetupHelper.ts +0 -290
  126. package/src/setup/linuxSetup.ts +0 -261
  127. package/src/setup/macOSSetup.ts +0 -156
  128. package/src/setup/setupEntryPoint.ts +0 -64
  129. package/src/setup/versions.ts +0 -8
  130. package/src/utils/ArgumentsResolver.ts +0 -23
  131. package/src/utils/BazelClient.ts +0 -285
  132. package/src/utils/Digraph.ts +0 -81
  133. package/src/utils/LoadingIndicator.ts +0 -43
  134. package/src/utils/applicationUtils.ts +0 -276
  135. package/src/utils/buildInfo.ts +0 -99
  136. package/src/utils/byString.ts +0 -3
  137. package/src/utils/cliUtils.ts +0 -112
  138. package/src/utils/copyBootstrapFiles.ts +0 -30
  139. package/src/utils/deviceUtils.ts +0 -76
  140. package/src/utils/errorUtils.ts +0 -63
  141. package/src/utils/fileUtils.ts +0 -257
  142. package/src/utils/githubUtils.ts +0 -102
  143. package/src/utils/jsonUtils.ts +0 -30
  144. package/src/utils/lintUtils.ts +0 -190
  145. package/src/utils/linuxDistro.spec.ts +0 -219
  146. package/src/utils/linuxDistro.ts +0 -326
  147. package/src/utils/logUtils.ts +0 -9
  148. package/src/utils/pathUtils.ts +0 -12
  149. package/src/utils/stringUtils.spec.ts +0 -95
  150. package/src/utils/stringUtils.ts +0 -103
  151. package/src/utils/tempDir.ts +0 -24
  152. package/src/utils/zipUtils.ts +0 -14
  153. package/test/ValdiSmokeTest.ts +0 -279
  154. package/test/helpers/AsyncHelpers.ts +0 -113
  155. package/test/helpers/CommandHelpers.ts +0 -37
  156. package/test/helpers/ProjectHelpers.ts +0 -153
  157. package/test/helpers/StreamHelpers.ts +0 -37
  158. package/test/helpers/TypeScriptClient.ts +0 -217
  159. package/tsconfig.dist.json +0 -8
  160. package/tsconfig.json +0 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snap/valdi",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Valdi CLI tools for developers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,8 +12,13 @@
12
12
  "bin": {
13
13
  "valdi": "dist/index.js"
14
14
  },
15
+ "files": [
16
+ "dist",
17
+ "bundled-skills"
18
+ ],
15
19
  "scripts": {
16
20
  "prepare": "npm run build",
21
+ "prebuild": "node scripts/bundle-skills.js",
17
22
  "build": "npm exec --package=typescript@5.9.2 tsc -- --project ./tsconfig.dist.json",
18
23
  "test": "ts-node node_modules/jasmine/bin/jasmine",
19
24
  "watch": "tsc --watch",
package/.bazelignore DELETED
@@ -1,2 +0,0 @@
1
- .metadata
2
- .bootstrap
@@ -1,7 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_cli_application.bzl", "valdi_cli_application")
2
-
3
- valdi_cli_application(
4
- name = "{{MODULE_NAME}}_app",
5
- script_path = "{{MODULE_NAME}}/src/index",
6
- deps = ["//modules/{{MODULE_NAME}}"],
7
- )
@@ -1,11 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
-
3
- valdi_module(
4
- name = "{{MODULE_NAME}}",
5
- srcs = glob([
6
- "src/**/*.ts",
7
- "src/**/*.tsx",
8
- ]),
9
- visibility = ["//visibility:public"],
10
- deps = [],
11
- )
@@ -1 +0,0 @@
1
- console.log('Hello world!');
@@ -1,27 +0,0 @@
1
-
2
- module.exports = {
3
- root: true,
4
- parser: '@typescript-eslint/parser',
5
- parserOptions: {
6
- tsconfigRootDir: __dirname,
7
- project: ['./src/valdi/_configs/eslint.tsconfig.json'],
8
- },
9
- plugins: ['@typescript-eslint', 'unused-imports', 'rxjs', 'prettier', '@snapchat/eslint-plugin-valdi'],
10
- extends: [
11
- 'eslint:recommended',
12
- 'plugin:@typescript-eslint/recommended',
13
- 'plugin:import/recommended',
14
- 'plugin:import/typescript',
15
- 'prettier',
16
- ],
17
- rules: {
18
- '@snapchat/valdi/attributed-text-no-array-assignment': 'error',
19
- '@snapchat/valdi/jsx-no-lambda': 'error',
20
- '@snapchat/valdi/assign-timer-id': 'error',
21
- '@snapchat/valdi/only-const-enum': 'off',
22
- '@snapchat/valdi/no-implicit-index-import': 'error',
23
- '@snapchat/valdi/mutate-state-without-set-state': 'error',
24
- '@snapchat/valdi/no-import-from-test-outside-test-dir': 'error',
25
- '@snapchat/valdi/no-declare-test-without-describe': 'error',
26
- },
27
- };
@@ -1,19 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_application.bzl", "valdi_application")
2
- load("@valdi//bzl/valdi:valdi_exported_library.bzl", "valdi_exported_library")
3
-
4
- valdi_application(
5
- name = "{{MODULE_NAME}}_app",
6
- ios_bundle_id = "com.website.{{MODULE_NAME}}",
7
- ios_families = ["iphone"],
8
- root_component_path = "App@{{MODULE_NAME}}/src/App",
9
- title = "{{MODULE_NAME}}",
10
- version = "1.0.0",
11
- deps = ["//modules/{{MODULE_NAME}}"],
12
- )
13
-
14
- valdi_exported_library(
15
- name = "{{MODULE_NAME}}_export",
16
- ios_bundle_id = "com.website.{{MODULE_NAME}}.lib",
17
- ios_bundle_name = "{{MODULE_NAME_PASCAL_CASED}}",
18
- deps = ["//modules/{{MODULE_NAME}}"],
19
- )
@@ -1,21 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
-
3
- valdi_module(
4
- name = "{{MODULE_NAME}}",
5
- srcs = glob([
6
- "src/**/*.ts",
7
- "src/**/*.tsx",
8
- ]),
9
- res = glob([
10
- "res/**/*.jpeg",
11
- "res/**/*.jpg",
12
- "res/**/*.png",
13
- "res/**/*.svg",
14
- "res/**/*.webp",
15
- ]),
16
- visibility = ["//visibility:public"],
17
- deps = [
18
- "@valdi//src/valdi_modules/src/valdi/valdi_core",
19
- "@valdi//src/valdi_modules/src/valdi/valdi_tsx",
20
- ],
21
- )
@@ -1,133 +0,0 @@
1
- import { StatefulComponent } from 'valdi_core/src/Component';
2
- import { ImageView, Label, View } from 'valdi_tsx/src/NativeTemplateElements';
3
- import { Style } from 'valdi_core/src/Style';
4
- import { systemBoldFont, systemFont } from 'valdi_core/src/SystemFont';
5
- import { AttributedText } from 'valdi_tsx/src/AttributedText';
6
- import { AttributedTextBuilder } from 'valdi_core/src/utils/AttributedTextBuilder';
7
- import { Device } from 'valdi_core/src/Device';
8
- import { getDaemonClientManager } from 'valdi_core/src/debugging/DaemonClientManagerResolver';
9
- import { IDaemonClientManagerListener } from 'valdi_core/src/debugging/DaemonClientManager';
10
- import res from '../res';
11
-
12
- /**
13
- * @ViewModel
14
- * @ExportModel
15
- */
16
- export interface AppViewModel {}
17
-
18
- /**
19
- * @Context
20
- * @ExportModel
21
- */
22
- export interface AppComponentContext {}
23
-
24
- interface State {
25
- hotReloaderConnected: boolean;
26
- }
27
-
28
- /**
29
- * @Component
30
- * @ExportModel
31
- */
32
- export class App extends StatefulComponent<AppViewModel, AppComponentContext> implements IDaemonClientManagerListener {
33
- state: State = { hotReloaderConnected: false };
34
-
35
- onCreate(): void {
36
- console.log('On App create!');
37
- getDaemonClientManager().addListener(this);
38
- }
39
-
40
- onDestroy(): void {
41
- console.log('On App destroy!');
42
- getDaemonClientManager().removeListener(this);
43
- }
44
-
45
- onAvailabilityChanged(available: boolean): void {
46
- this.setState({ hotReloaderConnected: available });
47
- }
48
-
49
- onRender(): void {
50
- console.log('On App render!');
51
- <view style={styles.main}>
52
- <image style={styles.logo} src={res.valdi} />
53
- <layout padding={20}>
54
- <label style={styles.title} value={`Welcome to Valdi!`} />
55
- </layout>
56
- <label style={styles.subtitle} value={this.renderLabel()} />
57
- </view>;
58
- }
59
-
60
- private renderLabel(): AttributedText {
61
- const textBuilder = new AttributedTextBuilder();
62
-
63
- textBuilder.appendText('This is currently running on ');
64
- textBuilder.appendStyled({
65
- content: this.getPlatformString(),
66
- attributes: {
67
- color: 'red',
68
- font: systemBoldFont(20),
69
- },
70
- });
71
-
72
- textBuilder.appendText('\nHot reloader ');
73
- if (this.state.hotReloaderConnected) {
74
- textBuilder.appendStyled({
75
- content: 'connected',
76
- attributes: {
77
- color: 'green',
78
- font: systemBoldFont(20),
79
- },
80
- });
81
- } else {
82
- textBuilder.appendStyled({
83
- content: 'disconnected',
84
- attributes: {
85
- color: 'red',
86
- font: systemBoldFont(20),
87
- },
88
- });
89
- }
90
-
91
- return textBuilder.build();
92
- }
93
-
94
- private getPlatformString(): string {
95
- if (Device.isDesktop()) {
96
- return 'Desktop';
97
- } else if (Device.isIOS()) {
98
- return 'iOS';
99
- } else if (Device.isAndroid()) {
100
- return 'Android';
101
- } else {
102
- return 'Unknown';
103
- }
104
- }
105
- }
106
-
107
- const styles = {
108
- main: new Style<View>({
109
- backgroundColor: 'white',
110
- justifyContent: 'center',
111
- }),
112
- logo: new Style<ImageView>({
113
- width: 80,
114
- height: 80,
115
- alignSelf: 'center',
116
- borderRadius: 16,
117
- boxShadow: '0 0 3 rgba(0, 0, 0, 0.15)',
118
- }),
119
- title: new Style<Label>({
120
- color: 'black',
121
- font: systemBoldFont(24),
122
- accessibilityCategory: 'header',
123
- alignSelf: 'center',
124
- }),
125
-
126
- subtitle: new Style<Label>({
127
- alignSelf: 'center',
128
- color: 'black',
129
- font: systemFont(20),
130
- numberOfLines: 0,
131
- textAlign: 'center',
132
- }),
133
- };
@@ -1,24 +0,0 @@
1
- {
2
- "name": "hello_world",
3
- "version": "1.0.0",
4
- "description": "Valdi Helloworld app",
5
- "license": "ISC",
6
- "devDependencies": {
7
- "@snap/eslint-plugin-valdi": "1.0.2",
8
- "@types/eslint": "^9.6.1",
9
- "@types/jasmine": "^5.1.7",
10
- "@typescript-eslint/eslint-plugin": "^6.21.0",
11
- "@typescript-eslint/parser": "^6.21.0",
12
- "@typescript-eslint/utils": "^6.21.0",
13
- "eslint": "^8.27.0",
14
- "eslint-config-prettier": "^8.5.0",
15
- "eslint-plugin-import": "^2.26.0",
16
- "eslint-plugin-prettier": "^4.2.1",
17
- "eslint-plugin-rxjs": "^5.0.2",
18
- "eslint-plugin-unused-imports": "^3.2.0",
19
- "jasmine": "^5.6.0",
20
- "ts-node": "^10.9.2",
21
- "typescript": "5.3.3"
22
- }
23
- }
24
-
@@ -1,21 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
-
3
- cc_library(
4
- name = "{{MODULE_NAME}}_cpp_impl",
5
- srcs = glob(["cpp/**/*.cpp"]),
6
- hdrs = glob(["cpp/**/*.hpp"]),
7
- includes = [],
8
- deps = [":{{MODULE_NAME}}_cpp"],
9
- alwayslink = 1,
10
- )
11
-
12
- valdi_module(
13
- name = "{{MODULE_NAME}}",
14
- srcs = glob([
15
- "src/**/*.ts",
16
- "src/**/*.tsx",
17
- ]),
18
- native_deps = [":{{MODULE_NAME}}_cpp_impl"],
19
- visibility = ["//visibility:public"],
20
- deps = [],
21
- )
@@ -1,28 +0,0 @@
1
- #include "valdi_modules/{{MODULE_NAME}}/{{MODULE_NAME}}.hpp"
2
-
3
- using namespace Valdi;
4
-
5
- namespace snap::valdi_modules::{{MODULE_NAME}} {
6
-
7
- class CalculatorModuleFactoryImpl : public CalculatorModuleFactory {
8
- public:
9
- CalculatorModuleFactoryImpl() = default;
10
-
11
- Ref<CalculatorModule> onLoadModule() final {
12
- class CalculatorModuleImpl : public CalculatorModule {
13
- public:
14
- CalculatorModuleImpl() = default;
15
- ~CalculatorModuleImpl() override = default;
16
-
17
- double multiply(double left, double right) final {
18
- return left * right;
19
- }
20
- };
21
-
22
- return makeShared<CalculatorModuleImpl>();
23
- }
24
- };
25
-
26
- static auto registerCalculatorModuleFactory = RegisterModuleFactory::registerTyped<CalculatorModuleFactoryImpl>();
27
-
28
- } // namespace snap::valdi_modules::{{MODULE_NAME}}
@@ -1,4 +0,0 @@
1
- /**
2
- * @ExportModule
3
- */
4
- export declare function multiply(left: number, right: number): number;
@@ -1,39 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
- load("@valdi//bzl/valdi:valdi_android_library.bzl", "valdi_android_library")
3
-
4
- valdi_android_library(
5
- name = "android_impl",
6
- srcs = glob([
7
- "android/**/*.kt",
8
- ]),
9
- deps = [
10
- ":{{MODULE_NAME}}_api_kt",
11
- ],
12
- )
13
-
14
- objc_library(
15
- name = "ios_impl",
16
- srcs = glob([
17
- "ios/**/*.m",
18
- ]),
19
- hdrs = glob([
20
- "ios/**/*.h",
21
- ]),
22
- copts = ["-I."],
23
- deps = [
24
- ":{{MODULE_NAME}}_api_objc",
25
- ],
26
- )
27
-
28
- valdi_module(
29
- name = "{{MODULE_NAME}}",
30
- srcs = glob([
31
- "src/**/*.ts",
32
- "src/**/*.tsx",
33
- ]),
34
- android_deps = [":android_impl"],
35
- ios_deps = [":ios_impl"],
36
- ios_module_name = "{{MODULE_NAME_PASCAL_CASED}}",
37
- visibility = ["//visibility:public"],
38
- deps = [],
39
- )
@@ -1,18 +0,0 @@
1
- package com.snap.modules.{{MODULE_NAME}}
2
-
3
- import com.snapchat.client.valdi_core.ModuleFactory
4
- import com.snap.valdi.modules.RegisterValdiModule
5
- import com.snap.modules.{{MODULE_NAME}}.CalculatorModuleFactory
6
- import com.snap.modules.{{MODULE_NAME}}.CalculatorModule
7
-
8
- @RegisterValdiModule
9
- class CalculatorModuleFactoryImpl: CalculatorModuleFactory() {
10
-
11
- override fun onLoadModule(): CalculatorModule {
12
- return object: CalculatorModule {
13
- override fun multiply(left: Double, right: Double): Double {
14
- return left * right
15
- }
16
- }
17
- }
18
- }
@@ -1,31 +0,0 @@
1
- #import "valdi_core/SCValdiModuleFactoryRegistry.h"
2
- #import <{{MODULE_NAME_PASCAL_CASED}}Types/{{MODULE_NAME_PASCAL_CASED}}Types.h>
3
- #import <Foundation/Foundation.h>
4
-
5
- @interface SCCCalculatorModule: NSObject<{{MODULE_NAME_PASCAL_CASED}}CalculatorModule>
6
-
7
- @end
8
-
9
- @implementation SCCCalculatorModule
10
-
11
- - (double)multiplyWithLeft:(double)left right:(double)right
12
- {
13
- return left * right;
14
- }
15
-
16
- @end
17
-
18
- @interface SCCCalculatorModuleFactoryImpl : {{MODULE_NAME_PASCAL_CASED}}CalculatorModuleFactory
19
-
20
- @end
21
-
22
- @implementation SCCCalculatorModuleFactoryImpl
23
-
24
- VALDI_REGISTER_MODULE()
25
-
26
- - (id<{{MODULE_NAME_PASCAL_CASED}}CalculatorModule>)onLoadModule
27
- {
28
- return [SCCCalculatorModule new];
29
- }
30
-
31
- @end
@@ -1,4 +0,0 @@
1
- /**
2
- * @ExportModule
3
- */
4
- export declare function multiply(left: number, right: number): number;
@@ -1,41 +0,0 @@
1
- load("@valdi//bzl/valdi:valdi_module.bzl", "valdi_module")
2
- load("@valdi//bzl/valdi:valdi_android_library.bzl", "valdi_android_library")
3
-
4
- valdi_android_library(
5
- name = "android_impl",
6
- srcs = glob([
7
- "android/**/*.kt",
8
- ]),
9
- deps = [
10
- "@valdi//valdi:valdi_java",
11
- ],
12
- )
13
-
14
- objc_library(
15
- name = "ios_impl",
16
- srcs = glob([
17
- "ios/**/*.m",
18
- ]),
19
- hdrs = glob([
20
- "ios/**/*.h",
21
- ]),
22
- copts = ["-I."],
23
- deps = [
24
- "@valdi//valdi_core",
25
- ],
26
- )
27
-
28
- valdi_module(
29
- name = "{{MODULE_NAME}}",
30
- srcs = glob([
31
- "src/**/*.ts",
32
- "src/**/*.tsx",
33
- ]),
34
- android_deps = [":android_impl"],
35
- ios_deps = [":ios_impl"],
36
- ios_module_name = "{{MODULE_NAME_PASCAL_CASED}}",
37
- visibility = ["//visibility:public"],
38
- deps = [
39
- "@valdi//src/valdi_modules/src/valdi/valdi_tsx",
40
- ],
41
- )
@@ -1,42 +0,0 @@
1
- package com.snap.modules.{{MODULE_NAME}}
2
-
3
- import android.content.Context
4
- import android.graphics.*
5
- import androidx.annotation.Keep
6
- import com.snap.valdi.views.ValdiView
7
-
8
- @Keep
9
- class CircleView(context: Context): ValdiView(context) {
10
-
11
- var ringThickness: Float
12
- get() = paint.strokeWidth
13
- set(value) {
14
- this.paint.strokeWidth = value
15
- invalidate()
16
- }
17
-
18
- var ringColor: Int
19
- get() = this.paint.color
20
- set(value) {
21
- this.paint.color = value
22
- invalidate()
23
- }
24
-
25
- private val paint = Paint().apply {
26
- isAntiAlias = true
27
- style = Paint.Style.STROKE
28
- color = Color.TRANSPARENT
29
- }
30
-
31
- init {
32
- setWillNotDraw(false)
33
- }
34
-
35
- override fun onDraw(canvas: Canvas) {
36
- super.onDraw(canvas)
37
-
38
- val halfThickness = ringThickness / 2f
39
-
40
- canvas.drawOval(halfThickness, halfThickness, width.toFloat() - halfThickness, height.toFloat() - halfThickness, paint)
41
- }
42
- }
@@ -1,60 +0,0 @@
1
- package com.snap.modules.{{MODULE_NAME}}
2
-
3
- import android.content.Context
4
- import android.graphics.*
5
- import android.view.View
6
- import com.snap.valdi.attributes.*
7
- import com.snap.valdi.attributes.impl.animations.ValdiAnimator
8
-
9
- import com.snap.valdi.utils.CoordinateResolver
10
-
11
- @RegisterAttributesBinder
12
- class CircleViewAttributesBinder(context: Context): AttributesBinder<CircleView> {
13
-
14
- private val coordinateResolver = CoordinateResolver(context)
15
-
16
- override val viewClass: Class<CircleView>
17
- get() = CircleView::class.java
18
-
19
- fun applyThickness(view: CircleView, value: Float, @Suppress("UNUSED_PARAMETER") animator: ValdiAnimator?) {
20
- val resolvedValue = coordinateResolver.toPixelF(value)
21
- view.ringThickness = resolvedValue
22
- }
23
-
24
- fun resetThickness(view: CircleView, @Suppress("UNUSED_PARAMETER") animator: ValdiAnimator?) {
25
- view.ringThickness = 0f
26
- }
27
-
28
- fun applyColor(view: CircleView, value: Int, @Suppress("UNUSED_PARAMETER") animator: ValdiAnimator?) {
29
- view.ringColor = value
30
- }
31
-
32
- fun resetColor(view: CircleView, @Suppress("UNUSED_PARAMETER") animator: ValdiAnimator?) {
33
- view.ringColor = Color.TRANSPARENT
34
- }
35
-
36
- override fun bindAttributes(attributesBindingContext: AttributesBindingContext<CircleView>) {
37
- attributesBindingContext.bindFloatAttribute("thickness", false, this::applyThickness, this::resetThickness)
38
- attributesBindingContext.bindColorAttribute("color", false, this::applyColor, this::resetColor)
39
-
40
- attributesBindingContext.setMeasureDelegate(object: MeasureDelegate {
41
- override fun onMeasure(attributes: ViewLayoutAttributes,
42
- widthMeasureSpec: Int,
43
- heightMeasureSpec: Int,
44
- isRightToLeft: Boolean): MeasuredSize {
45
- val width = View.MeasureSpec.getSize(widthMeasureSpec)
46
- val widthMode = View.MeasureSpec.getMode(widthMeasureSpec)
47
- val height = View.MeasureSpec.getSize(heightMeasureSpec)
48
- val heightMode = View.MeasureSpec.getMode(heightMeasureSpec)
49
-
50
- if (widthMode == View.MeasureSpec.EXACTLY) {
51
- return MeasuredSize(width, width)
52
- } else if (heightMode == View.MeasureSpec.EXACTLY) {
53
- return MeasuredSize(height, height)
54
- } else {
55
- return MeasuredSize(0, 0)
56
- }
57
- }
58
- })
59
- }
60
- }
@@ -1,6 +0,0 @@
1
- #import "valdi_core/SCValdiView.h"
2
- #import <UIKit/UIKit.h>
3
-
4
- @interface SCCCircleView : SCValdiView
5
-
6
- @end
@@ -1,82 +0,0 @@
1
-
2
- #import "SCCCircleView.h"
3
- #import "valdi_core/SCValdiAttributesBinderBase.h"
4
-
5
- @implementation SCCCircleView {
6
- CGFloat _thickness;
7
- UIColor* _color;
8
- }
9
-
10
- - (instancetype)initWithFrame:(CGRect)frame {
11
- self = [super initWithFrame:frame];
12
-
13
- if (self) {
14
- self.opaque = NO;
15
- }
16
-
17
- return self;
18
- }
19
-
20
- - (BOOL)willEnqueueIntoValdiPool {
21
- return YES;
22
- }
23
-
24
- - (void)drawRect:(CGRect)rect {
25
- if (!_color) {
26
- return;
27
- }
28
-
29
- CGFloat halfLine = _thickness * 0.5f;
30
- CGRect insetRect = CGRectInset(self.bounds, halfLine, halfLine);
31
-
32
- UIBezierPath* circle = [UIBezierPath bezierPathWithOvalInRect:insetRect];
33
- circle.lineWidth = _thickness;
34
-
35
- [_color setStroke];
36
- [circle stroke];
37
- }
38
-
39
- - (BOOL)valdi_setThickness:(CGFloat)thickness {
40
- _thickness = thickness;
41
- [self setNeedsDisplay];
42
- return YES;
43
- }
44
-
45
- - (BOOL)valdi_setColor:(UIColor*)color {
46
- _color = color;
47
- [self setNeedsDisplay];
48
- return YES;
49
- }
50
-
51
- + (CGSize)valdi_onMeasureWithAttributes:(id<SCValdiViewLayoutAttributes>)attributes maxSize:(CGSize)maxSize {
52
- CGFloat minSize = MIN(maxSize.width, maxSize.height);
53
- return CGSizeMake(minSize, minSize);
54
- }
55
-
56
- + (void)bindAttributes:(id<SCValdiAttributesBinderProtocol>)attributesBinder {
57
- [attributesBinder bindAttribute:@"thickness"
58
- invalidateLayoutOnChange:NO
59
- withDoubleBlock:^BOOL(__kindof UIView* view, CGFloat attributeValue, id<SCValdiAnimatorProtocol> animator) {
60
- return [view valdi_setThickness:attributeValue];
61
- }
62
- resetBlock:^(__kindof UIView* view, id<SCValdiAnimatorProtocol> animator) {
63
- [view valdi_setThickness:0];
64
- }];
65
-
66
- [attributesBinder bindAttribute:@"color"
67
- invalidateLayoutOnChange:NO
68
- withColorBlock:^BOOL(__kindof UIView* view, UIColor* attributeValue, id<SCValdiAnimatorProtocol> animator) {
69
- return [view valdi_setColor:attributeValue];
70
- }
71
- resetBlock:^(__kindof UIView* view, id<SCValdiAnimatorProtocol> animator) {
72
- [view valdi_setColor:nil];
73
- }];
74
-
75
- [attributesBinder setMeasureDelegate:^CGSize(id<SCValdiViewLayoutAttributes> attributes,
76
- CGSize maxSize,
77
- UITraitCollection* traitCollection) {
78
- return [SCCCircleView valdi_onMeasureWithAttributes:attributes maxSize:maxSize];
79
- }];
80
- }
81
-
82
- @end