@snap/valdi 1.0.7 → 1.0.11

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 (170) hide show
  1. package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/BUILD.bazel.template +16 -1
  2. package/.bootstrap/modules/polyglot_bridge_module/web/Calculator.ts +11 -0
  3. package/.bootstrap/modules/polyglot_bridge_module/web/tsconfig.json +16 -0
  4. package/.bootstrap/modules/polyglot_view_module/BUILD.bazel.template +75 -0
  5. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeView.kt.template +41 -0
  6. package/.bootstrap/modules/polyglot_view_module/android/PolyglotNativeViewAttributesBinder.kt.template +17 -0
  7. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.h +8 -0
  8. package/.bootstrap/modules/polyglot_view_module/ios/SCPolyglotView.m +23 -0
  9. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.h +8 -0
  10. package/.bootstrap/modules/polyglot_view_module/macos/SCPolyglotView.m +23 -0
  11. package/.bootstrap/modules/polyglot_view_module/src/PolyglotCustomView.tsx.template +23 -0
  12. package/.bootstrap/modules/polyglot_view_module/web/PolyglotWeb.ts.template +30 -0
  13. package/.bootstrap/modules/polyglot_view_module/web/tsconfig.json +16 -0
  14. package/.metadata/AGENTS.md.template +8 -274
  15. package/.metadata/skill-reference.tsx.template +8 -0
  16. package/.metadata/skill-tests-BUILD.bazel.template +21 -0
  17. package/.metadata/skill-tests-README.md.template +17 -0
  18. package/.metadata/skill.md.template +27 -0
  19. package/README.md +12 -3
  20. package/bundled-skills/CONTRIBUTING_SKILLS.md +74 -0
  21. package/bundled-skills/registry.json +21 -0
  22. package/bundled-skills/skills/valdi-android/skill.md +89 -0
  23. package/bundled-skills/skills/valdi-async/skill.md +246 -0
  24. package/bundled-skills/skills/valdi-async/tests/BUILD.bazel +19 -0
  25. package/bundled-skills/skills/valdi-async/tests/README.md +25 -0
  26. package/bundled-skills/skills/valdi-async/tests/src/reference.tsx +210 -0
  27. package/bundled-skills/skills/valdi-async/tests/tsconfig.json +1 -0
  28. package/bundled-skills/skills/valdi-bazel/skill.md +141 -0
  29. package/bundled-skills/skills/valdi-compiler/skill.md +108 -0
  30. package/bundled-skills/skills/valdi-component-tests/skill.md +430 -0
  31. package/bundled-skills/skills/valdi-component-tests/tests/BUILD.bazel +24 -0
  32. package/bundled-skills/skills/valdi-component-tests/tests/README.md +35 -0
  33. package/bundled-skills/skills/valdi-component-tests/tests/src/ProfileCard.tsx +38 -0
  34. package/bundled-skills/skills/valdi-component-tests/tests/test/ProfileCardTest.spec.tsx +107 -0
  35. package/bundled-skills/skills/valdi-component-tests/tests/tsconfig.json +1 -0
  36. package/bundled-skills/skills/valdi-cpp-runtime/skill.md +103 -0
  37. package/bundled-skills/skills/valdi-custom-view/skill.md +64 -0
  38. package/bundled-skills/skills/valdi-inspect/skill.md +199 -0
  39. package/bundled-skills/skills/valdi-ios/skill.md +93 -0
  40. package/bundled-skills/skills/valdi-migrate/skill.md +175 -0
  41. package/bundled-skills/skills/valdi-migrate/tests/BUILD.bazel +23 -0
  42. package/bundled-skills/skills/valdi-migrate/tests/README.md +70 -0
  43. package/bundled-skills/skills/valdi-migrate/tests/check_antipatterns.py +89 -0
  44. package/bundled-skills/skills/valdi-migrate/tests/compose_example.kt +94 -0
  45. package/bundled-skills/skills/valdi-migrate/tests/flutter_example.dart +129 -0
  46. package/bundled-skills/skills/valdi-migrate/tests/react_example.tsx +98 -0
  47. package/bundled-skills/skills/valdi-migrate/tests/src/expected_valdi.tsx +267 -0
  48. package/bundled-skills/skills/valdi-migrate/tests/tsconfig.json +3 -0
  49. package/bundled-skills/skills/valdi-overview/skill.md +63 -0
  50. package/bundled-skills/skills/valdi-perf/skill.md +197 -0
  51. package/bundled-skills/skills/valdi-perf/tests/BUILD.bazel +19 -0
  52. package/bundled-skills/skills/valdi-perf/tests/README.md +26 -0
  53. package/bundled-skills/skills/valdi-perf/tests/src/reference.tsx +202 -0
  54. package/bundled-skills/skills/valdi-perf/tests/tsconfig.json +1 -0
  55. package/bundled-skills/skills/valdi-polyglot-module/skill.md +124 -0
  56. package/bundled-skills/skills/valdi-profile/skill.md +126 -0
  57. package/bundled-skills/skills/valdi-setup/skill.md +129 -0
  58. package/bundled-skills/skills/valdi-testing/skill.md +65 -0
  59. package/bundled-skills/skills/valdi-tsx/skill.md +385 -0
  60. package/bundled-skills/skills/valdi-tsx/tests/BUILD.bazel +19 -0
  61. package/bundled-skills/skills/valdi-tsx/tests/README.md +29 -0
  62. package/bundled-skills/skills/valdi-tsx/tests/src/reference.tsx +173 -0
  63. package/bundled-skills/skills/valdi-tsx/tests/tsconfig.json +1 -0
  64. package/dist/commands/bootstrap.js +0 -7
  65. package/dist/commands/inspect.js +16 -0
  66. package/dist/commands/inspect_commands/contexts.js +55 -0
  67. package/dist/commands/inspect_commands/devices.js +53 -0
  68. package/dist/commands/inspect_commands/heap.js +59 -0
  69. package/dist/commands/inspect_commands/select.js +43 -0
  70. package/dist/commands/inspect_commands/snapshot.js +64 -0
  71. package/dist/commands/inspect_commands/status.js +68 -0
  72. package/dist/commands/inspect_commands/tree.js +86 -0
  73. package/dist/commands/newModule.js +10 -14
  74. package/dist/commands/profile.js +16 -0
  75. package/dist/commands/profile_commands/capture.js +106 -0
  76. package/dist/commands/skills.js +16 -0
  77. package/dist/commands/skills_commands/create.js +125 -0
  78. package/dist/commands/skills_commands/install.js +96 -0
  79. package/dist/commands/skills_commands/list.js +83 -0
  80. package/dist/commands/skills_commands/remove.js +41 -0
  81. package/dist/commands/skills_commands/update.js +59 -0
  82. package/dist/core/constants.js +0 -1
  83. package/dist/core/packageFiles.spec.js +29 -0
  84. package/dist/setup/versions.js +1 -1
  85. package/dist/utils/daemonClient.js +342 -0
  86. package/dist/utils/hermesClient.js +252 -0
  87. package/dist/utils/skillsAdapters.js +140 -0
  88. package/dist/utils/skillsRegistry.js +40 -0
  89. package/dist/utils/stringUtils.spec.js +1 -1
  90. package/package.json +20 -5
  91. package/.bazelignore +0 -2
  92. package/.bootstrap/modules/cpp_bridge_module/BUILD.bazel.template +0 -21
  93. package/.bootstrap/modules/cpp_bridge_module/cpp/CalculatorModuleFactory.cpp.template +0 -28
  94. package/.bootstrap/modules/ios_android_bridge_module/src/Calculator.d.ts +0 -4
  95. package/.bootstrap/modules/ios_android_view_module/BUILD.bazel.template +0 -41
  96. package/.bootstrap/modules/ios_android_view_module/android/CircleView.kt.template +0 -42
  97. package/.bootstrap/modules/ios_android_view_module/android/CircleViewAttributesBinder.kt.template +0 -60
  98. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.h +0 -6
  99. package/.bootstrap/modules/ios_android_view_module/ios/SCCCircleView.m +0 -82
  100. package/.bootstrap/modules/ios_android_view_module/src/Circle.tsx.template +0 -15
  101. package/.config/copyconfig.json +0 -10
  102. package/.editorconfig +0 -21
  103. package/.eslintignore +0 -1
  104. package/.eslintrc.js +0 -72
  105. package/.github/README.md +0 -164
  106. package/.metadata/.cursorrules.template +0 -60
  107. package/.prettierignore +0 -2
  108. package/.prettierrc.json +0 -7
  109. package/LINUX_COMPATIBILITY.md +0 -248
  110. package/prettier.config.js +0 -4
  111. package/scripts/sync-agents-md.sh +0 -44
  112. package/scripts/update-agents-templates.ts +0 -170
  113. package/spec/support/jasmine.json +0 -6
  114. package/src/commands/bootstrap.ts +0 -410
  115. package/src/commands/build.ts +0 -89
  116. package/src/commands/devSetup.ts +0 -17
  117. package/src/commands/doctor.ts +0 -1832
  118. package/src/commands/export.ts +0 -131
  119. package/src/commands/hotreload.ts +0 -108
  120. package/src/commands/install.ts +0 -93
  121. package/src/commands/lint.ts +0 -15
  122. package/src/commands/lint_commands/lintCheck.ts +0 -53
  123. package/src/commands/lint_commands/lintFormat.ts +0 -49
  124. package/src/commands/log.ts +0 -108
  125. package/src/commands/newModule.ts +0 -286
  126. package/src/commands/package.ts +0 -102
  127. package/src/commands/projectsync.ts +0 -488
  128. package/src/commands/test.ts +0 -68
  129. package/src/core/constants.ts +0 -98
  130. package/src/core/errors.ts +0 -10
  131. package/src/index.ts +0 -27
  132. package/src/setup/DevSetupHelper.ts +0 -290
  133. package/src/setup/linuxSetup.ts +0 -261
  134. package/src/setup/macOSSetup.ts +0 -156
  135. package/src/setup/setupEntryPoint.ts +0 -64
  136. package/src/setup/versions.ts +0 -8
  137. package/src/utils/ArgumentsResolver.ts +0 -23
  138. package/src/utils/BazelClient.ts +0 -285
  139. package/src/utils/Digraph.ts +0 -81
  140. package/src/utils/LoadingIndicator.ts +0 -43
  141. package/src/utils/applicationUtils.ts +0 -276
  142. package/src/utils/buildInfo.ts +0 -99
  143. package/src/utils/byString.ts +0 -3
  144. package/src/utils/cliUtils.ts +0 -112
  145. package/src/utils/copyBootstrapFiles.ts +0 -30
  146. package/src/utils/deviceUtils.ts +0 -76
  147. package/src/utils/errorUtils.ts +0 -63
  148. package/src/utils/fileUtils.ts +0 -257
  149. package/src/utils/githubUtils.ts +0 -102
  150. package/src/utils/jsonUtils.ts +0 -30
  151. package/src/utils/lintUtils.ts +0 -190
  152. package/src/utils/linuxDistro.spec.ts +0 -219
  153. package/src/utils/linuxDistro.ts +0 -326
  154. package/src/utils/logUtils.ts +0 -9
  155. package/src/utils/pathUtils.ts +0 -12
  156. package/src/utils/stringUtils.spec.ts +0 -95
  157. package/src/utils/stringUtils.ts +0 -103
  158. package/src/utils/tempDir.ts +0 -24
  159. package/src/utils/zipUtils.ts +0 -14
  160. package/test/ValdiSmokeTest.ts +0 -279
  161. package/test/helpers/AsyncHelpers.ts +0 -113
  162. package/test/helpers/CommandHelpers.ts +0 -37
  163. package/test/helpers/ProjectHelpers.ts +0 -153
  164. package/test/helpers/StreamHelpers.ts +0 -37
  165. package/test/helpers/TypeScriptClient.ts +0 -217
  166. package/tsconfig.dist.json +0 -8
  167. package/tsconfig.json +0 -42
  168. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/android/CalculatorModuleFactory.kt.template +0 -0
  169. /package/.bootstrap/modules/{ios_android_bridge_module → polyglot_bridge_module}/ios/SCCCalculatorModuleFactory.m.template +0 -0
  170. /package/.bootstrap/modules/{cpp_bridge_module → polyglot_bridge_module}/src/Calculator.d.ts +0 -0
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ALL_ADAPTERS = void 0;
4
+ exports.detectAdapters = detectAdapters;
5
+ exports.getAdapterByName = getAdapterByName;
6
+ const tslib_1 = require("tslib");
7
+ const fs = tslib_1.__importStar(require("fs"));
8
+ const path = tslib_1.__importStar(require("path"));
9
+ const os = tslib_1.__importStar(require("os"));
10
+ const ClaudeCodeAdapter = {
11
+ name: 'claude',
12
+ detect() {
13
+ const claudeDir = path.join(os.homedir(), '.claude');
14
+ return fs.existsSync(claudeDir);
15
+ },
16
+ install(skillName, content, meta) {
17
+ const skillDir = path.join(os.homedir(), '.claude', 'plugins', 'valdi', 'skills', skillName);
18
+ fs.mkdirSync(skillDir, { recursive: true });
19
+ const frontmatter = `---\nname: ${meta.name}\ndescription: ${meta.description}\n---\n\n`;
20
+ fs.writeFileSync(path.join(skillDir, 'SKILL.md'), frontmatter + content, 'utf8');
21
+ },
22
+ remove(skillName) {
23
+ const skillDir = path.join(os.homedir(), '.claude', 'plugins', 'valdi', 'skills', skillName);
24
+ if (fs.existsSync(skillDir)) {
25
+ fs.rmSync(skillDir, { recursive: true, force: true });
26
+ }
27
+ },
28
+ listInstalled() {
29
+ const skillsDir = path.join(os.homedir(), '.claude', 'plugins', 'valdi', 'skills');
30
+ if (!fs.existsSync(skillsDir))
31
+ return [];
32
+ return fs
33
+ .readdirSync(skillsDir)
34
+ .filter((entry) => fs.statSync(path.join(skillsDir, entry)).isDirectory());
35
+ },
36
+ };
37
+ const CursorAdapter = {
38
+ name: 'cursor',
39
+ detect() {
40
+ const cursorDir = path.join(os.homedir(), '.cursor');
41
+ return fs.existsSync(cursorDir);
42
+ },
43
+ install(skillName, content, meta) {
44
+ const rulesDir = path.join(os.homedir(), '.cursor', 'rules');
45
+ fs.mkdirSync(rulesDir, { recursive: true });
46
+ const frontmatter = `---\ndescription: ${meta.description}\nalwaysApply: false\n---\n\n`;
47
+ fs.writeFileSync(path.join(rulesDir, `valdi-${skillName}.mdc`), frontmatter + content, 'utf8');
48
+ },
49
+ remove(skillName) {
50
+ const filePath = path.join(os.homedir(), '.cursor', 'rules', `valdi-${skillName}.mdc`);
51
+ if (fs.existsSync(filePath)) {
52
+ fs.unlinkSync(filePath);
53
+ }
54
+ },
55
+ listInstalled() {
56
+ const rulesDir = path.join(os.homedir(), '.cursor', 'rules');
57
+ if (!fs.existsSync(rulesDir))
58
+ return [];
59
+ return fs
60
+ .readdirSync(rulesDir)
61
+ .filter((f) => f.startsWith('valdi-') && f.endsWith('.mdc'))
62
+ .map((f) => f.replace(/^valdi-/u, '').replace(/\.mdc$/u, ''));
63
+ },
64
+ };
65
+ const CopilotAdapter = {
66
+ name: 'copilot',
67
+ detect() {
68
+ const githubDir = path.join(process.cwd(), '.github');
69
+ return fs.existsSync(githubDir);
70
+ },
71
+ install(skillName, content, _meta) {
72
+ const githubDir = path.join(process.cwd(), '.github');
73
+ fs.mkdirSync(githubDir, { recursive: true });
74
+ const instructionsFile = path.join(githubDir, 'copilot-instructions.md');
75
+ const section = `\n\n## ${skillName}\n\n${content}`;
76
+ if (fs.existsSync(instructionsFile)) {
77
+ fs.appendFileSync(instructionsFile, section, 'utf8');
78
+ }
79
+ else {
80
+ fs.writeFileSync(instructionsFile, `# Copilot Instructions${section}`, 'utf8');
81
+ }
82
+ },
83
+ remove(skillName) {
84
+ const instructionsFile = path.join(process.cwd(), '.github', 'copilot-instructions.md');
85
+ if (!fs.existsSync(instructionsFile))
86
+ return;
87
+ const contents = fs.readFileSync(instructionsFile, 'utf8');
88
+ const sectionRegex = new RegExp(`\\n\\n## ${skillName}\\n[\\s\\S]*?(?=\\n\\n## |$)`, 'u');
89
+ const updated = contents.replace(sectionRegex, '');
90
+ fs.writeFileSync(instructionsFile, updated, 'utf8');
91
+ },
92
+ listInstalled() {
93
+ const instructionsFile = path.join(process.cwd(), '.github', 'copilot-instructions.md');
94
+ if (!fs.existsSync(instructionsFile))
95
+ return [];
96
+ const contents = fs.readFileSync(instructionsFile, 'utf8');
97
+ const matches = contents.match(/^## (valdi-\S+)/gmu);
98
+ if (!matches)
99
+ return [];
100
+ return matches.map((m) => m.replace(/^## /u, ''));
101
+ },
102
+ };
103
+ const GenericAdapter = {
104
+ name: 'generic',
105
+ detect() {
106
+ return true;
107
+ },
108
+ install(skillName, content, _meta) {
109
+ const skillsDir = path.join(os.homedir(), '.valdi', 'skills');
110
+ fs.mkdirSync(skillsDir, { recursive: true });
111
+ fs.writeFileSync(path.join(skillsDir, `${skillName}.md`), content, 'utf8');
112
+ },
113
+ remove(skillName) {
114
+ const filePath = path.join(os.homedir(), '.valdi', 'skills', `${skillName}.md`);
115
+ if (fs.existsSync(filePath)) {
116
+ fs.unlinkSync(filePath);
117
+ }
118
+ },
119
+ listInstalled() {
120
+ const skillsDir = path.join(os.homedir(), '.valdi', 'skills');
121
+ if (!fs.existsSync(skillsDir))
122
+ return [];
123
+ return fs
124
+ .readdirSync(skillsDir)
125
+ .filter((f) => f.endsWith('.md'))
126
+ .map((f) => f.replace(/\.md$/u, ''));
127
+ },
128
+ };
129
+ exports.ALL_ADAPTERS = [
130
+ ClaudeCodeAdapter,
131
+ CursorAdapter,
132
+ CopilotAdapter,
133
+ GenericAdapter,
134
+ ];
135
+ function detectAdapters() {
136
+ return exports.ALL_ADAPTERS.filter((a) => a.detect());
137
+ }
138
+ function getAdapterByName(name) {
139
+ return exports.ALL_ADAPTERS.find((a) => a.name === name);
140
+ }
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadLocalRegistry = loadLocalRegistry;
4
+ exports.fetchRegistry = fetchRegistry;
5
+ exports.fetchSkillContent = fetchSkillContent;
6
+ const tslib_1 = require("tslib");
7
+ const path = tslib_1.__importStar(require("path"));
8
+ const fs = tslib_1.__importStar(require("fs"));
9
+ function findBundledSkillsDir() {
10
+ const candidate = path.resolve(__dirname, '..', '..', 'bundled-skills');
11
+ return fs.existsSync(path.join(candidate, 'registry.json')) ? candidate : null;
12
+ }
13
+ function loadLocalRegistry() {
14
+ const bundledDir = findBundledSkillsDir();
15
+ if (bundledDir == null)
16
+ return null;
17
+ try {
18
+ return JSON.parse(fs.readFileSync(path.join(bundledDir, 'registry.json'), 'utf8'));
19
+ }
20
+ catch {
21
+ return null;
22
+ }
23
+ }
24
+ async function fetchRegistry() {
25
+ const local = loadLocalRegistry();
26
+ if (local != null) {
27
+ return local;
28
+ }
29
+ throw new Error('No bundled skills found. Re-install @snap/valdi to get the latest bundle.');
30
+ }
31
+ async function fetchSkillContent(skillPath) {
32
+ const bundledDir = findBundledSkillsDir();
33
+ if (bundledDir != null) {
34
+ const candidate = path.join(bundledDir, skillPath);
35
+ if (fs.existsSync(candidate)) {
36
+ return fs.readFileSync(candidate, 'utf8');
37
+ }
38
+ }
39
+ throw new Error(`Skill content not found for "${skillPath}". Re-install @snap/valdi to get the latest bundle.`);
40
+ }
@@ -75,7 +75,7 @@ describe('stringUtils', () => {
75
75
  expect((0, stringUtils_1.validateProjectName)('@#$')).toBeTruthy();
76
76
  });
77
77
  it('handles names that start with numbers', () => {
78
- expect((0, stringUtils_1.validateProjectName)('123project')).toBeNull();
78
+ expect((0, stringUtils_1.validateProjectName)('123project')).toContain('sanitized');
79
79
  });
80
80
  });
81
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@snap/valdi",
3
- "version": "1.0.7",
3
+ "version": "1.0.11",
4
4
  "description": "Valdi CLI tools for developers",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -8,14 +8,23 @@
8
8
  "url": "https://github.com/Snapchat/Valdi.git",
9
9
  "directory": "npm_modules/cli"
10
10
  },
11
- "publishConfig": { "access": "public" },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
12
14
  "bin": {
13
15
  "valdi": "dist/index.js"
14
16
  },
17
+ "files": [
18
+ "dist",
19
+ "bundled-skills",
20
+ ".metadata",
21
+ ".bootstrap"
22
+ ],
15
23
  "scripts": {
16
24
  "prepare": "npm run build",
25
+ "prebuild": "node scripts/bundle-skills.js",
17
26
  "build": "npm exec --package=typescript@5.9.2 tsc -- --project ./tsconfig.dist.json",
18
- "test": "ts-node node_modules/jasmine/bin/jasmine",
27
+ "test": "tsx node_modules/jasmine/bin/jasmine",
19
28
  "watch": "tsc --watch",
20
29
  "main": "ts-node ./src/index.ts",
21
30
  "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
@@ -51,9 +60,15 @@
51
60
  "@types/eslint": "^9.6.1",
52
61
  "@types/jasmine": "^5.1.7",
53
62
  "jasmine": "^5.6.0",
54
- "ts-node": "^10.9.2"
63
+ "ts-node": "^10.9.2",
64
+ "tsx": "^4.19.0"
55
65
  },
56
66
  "overrides": {
57
- "brace-expansion": "2.0.2"
67
+ "minimatch@3": {
68
+ "brace-expansion": "2.0.2"
69
+ },
70
+ "minimatch@9": {
71
+ "brace-expansion": "2.0.2"
72
+ }
58
73
  }
59
74
  }
package/.bazelignore DELETED
@@ -1,2 +0,0 @@
1
- .metadata
2
- .bootstrap
@@ -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,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
@@ -1,15 +0,0 @@
1
- import 'valdi_tsx/src/JSX';
2
- import { View } from 'valdi_tsx/src/NativeTemplateElements';
3
-
4
- export interface CircleViewModel extends View {
5
- color: string;
6
- thickness: number;
7
- }
8
-
9
- export function Circle(viewModel: CircleViewModel) {
10
- <custom-view
11
- iosClass={'SCCCircleView'}
12
- androidClass={'com.snap.modules.{{MODULE_NAME}}.CircleView'}
13
- {...viewModel}
14
- />;
15
- }
@@ -1,10 +0,0 @@
1
- {
2
- "blacklist": [
3
- "open_source/\\.aswb",
4
- "open_source/bazel-.*",
5
- "open_source/cli",
6
- "open_source/docs",
7
- "open_source/\\.git.*",
8
- "\\.DS_Store"
9
- ]
10
- }
package/.editorconfig DELETED
@@ -1,21 +0,0 @@
1
- # EditorConfig is awesome: http://EditorConfig.org
2
-
3
- # top-most EditorConfig file
4
- root = true
5
-
6
- [*]
7
- # Unix-style newlines with a newline ending every file
8
- end_of_line = lf
9
- insert_final_newline = true
10
- trim_trailing_whitespace = true
11
-
12
- # 4 spaces for indentation
13
- indent_size = 4
14
- indent_style = space
15
-
16
- # 120 characters max per line
17
- max_line_length = 120
18
-
19
- # some files use 2 spaces for indentation
20
- [*.{json,yml,yaml}]
21
- indent_size = 2
package/.eslintignore DELETED
@@ -1 +0,0 @@
1
- /**/*.js
package/.eslintrc.js DELETED
@@ -1,72 +0,0 @@
1
- module.exports = {
2
- root: true,
3
- parser: '@typescript-eslint/parser',
4
- parserOptions: {
5
- tsconfigRootDir: __dirname,
6
- project: ['./tsconfig.json'],
7
- },
8
- plugins: ['@typescript-eslint', 'import'],
9
- extends: [
10
- 'eslint:recommended',
11
- 'plugin:@typescript-eslint/recommended',
12
- 'plugin:@typescript-eslint/recommended-requiring-type-checking',
13
- 'plugin:import/recommended',
14
- 'plugin:import/typescript',
15
- 'plugin:unicorn/recommended',
16
- 'prettier',
17
- ],
18
- rules: {
19
- eqeqeq: 'error',
20
- '@typescript-eslint/consistent-type-assertions': [
21
- 'warn',
22
- {
23
- assertionStyle: 'as',
24
- objectLiteralTypeAssertions: 'never',
25
- },
26
- ],
27
- '@typescript-eslint/consistent-type-imports': [
28
- 'error',
29
- {
30
- prefer: 'type-imports',
31
- },
32
- ],
33
- '@typescript-eslint/member-ordering': 'warn',
34
- '@typescript-eslint/no-inferrable-types': ['error', { ignoreParameters: true }],
35
- '@typescript-eslint/prefer-ts-expect-error': 'error',
36
- '@typescript-eslint/no-floating-promises': ['error', { ignoreVoid: true }],
37
- '@typescript-eslint/no-misused-promises': [
38
- 'error',
39
- {
40
- checksVoidReturn: false,
41
- },
42
- ],
43
- '@typescript-eslint/no-empty-function': 'off',
44
- 'import/default': 'off',
45
- 'import/namespace': 'off',
46
- 'import/no-unresolved': 'off',
47
- 'import/no-duplicates': 'error',
48
- 'import/no-named-as-default': 'error',
49
- 'import/order': ['warn', { alphabetize: { order: 'asc' } }],
50
- 'unicorn/filename-case': [
51
- 'error',
52
- {
53
- cases: {
54
- camelCase: true,
55
- pascalCase: true,
56
- },
57
- ignore: ['^.*CLI.*'],
58
- },
59
- ],
60
- 'unicorn/no-array-for-each': 'off',
61
- 'unicorn/no-array-reduce': 'off',
62
- 'unicorn/no-for-loop': 'off',
63
- 'unicorn/no-null': 'off',
64
- 'unicorn/prefer-node-protocol': 'off',
65
- 'unicorn/prefer-query-selector': 'off',
66
- 'unicorn/prefer-ternary': 'off',
67
- 'unicorn/prefer-top-level-await': 'off',
68
- 'unicorn/prefer-spread': 'off',
69
- 'unicorn/prevent-abbreviations': 'off',
70
- 'sort-imports': ['error', { allowSeparatedGroups: true, ignoreDeclarationSort: true }],
71
- },
72
- };