create-lynx-library 0.2.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 (30) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/LICENSE +202 -0
  3. package/README.md +33 -0
  4. package/dist/cli.d.ts +53 -0
  5. package/dist/cli.js +242 -0
  6. package/dist/index.d.ts +31 -0
  7. package/dist/index.js +227 -0
  8. package/package.json +47 -0
  9. package/template-common/README.md +13 -0
  10. package/template-common/android/build.gradle.kts +18 -0
  11. package/template-common/android/src/main/AndroidManifest.xml +3 -0
  12. package/template-common/example/lynx.config.ts.tmpl +6 -0
  13. package/template-common/example/package.json +18 -0
  14. package/template-common/example/src/App.tsx.tmpl +9 -0
  15. package/template-common/example/src/index.tsx.tmpl +5 -0
  16. package/template-common/ios/build.podspec +11 -0
  17. package/template-common/lynx.lib.json +12 -0
  18. package/template-common/package.json +24 -0
  19. package/template-common/src/index.ts.tmpl +1 -0
  20. package/template-common/tsconfig.json +12 -0
  21. package/template-common/types/index.d.ts.tmpl +1 -0
  22. package/template-element/android/src/main/java/__ANDROID_PACKAGE_PATH__/__ELEMENT_CLASS_NAME__.java +21 -0
  23. package/template-element/ios/src/__ELEMENT_CLASS_NAME__.h +11 -0
  24. package/template-element/ios/src/__ELEMENT_CLASS_NAME__.m +11 -0
  25. package/template-native-module/android/src/main/java/__ANDROID_PACKAGE_PATH__/__MODULE_NAME__.java +31 -0
  26. package/template-native-module/ios/src/__MODULE_NAME__.h +12 -0
  27. package/template-native-module/ios/src/__MODULE_NAME__.m +27 -0
  28. package/template-service/android/src/main/java/__ANDROID_PACKAGE_PATH__/__SERVICE_NAME__.java +10 -0
  29. package/template-service/ios/src/__SERVICE_NAME__.h +16 -0
  30. package/template-service/ios/src/__SERVICE_NAME__.m +10 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # create-lynx-library
2
+
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Rename the Native Autolink scaffold flow to libraries and switch codegen manifests to `lynx.lib.json`. ([#2729](https://github.com/lynx-family/lynx-stack/pull/2729))
8
+
9
+ ### Patch Changes
10
+
11
+ - Update generated native library examples and package descriptions to use the current Lynx marker names. ([#2799](https://github.com/lynx-family/lynx-stack/pull/2799))
12
+
13
+ ## 0.1.0
14
+
15
+ ### Minor Changes
16
+
17
+ - Add the Native Autolink create-library package. ([#2587](https://github.com/lynx-family/lynx-stack/pull/2587))
18
+
19
+ ### Patch Changes
20
+
21
+ - Use published package versions for scaffolded autolink codegen dependencies instead of workspace placeholders. ([#2628](https://github.com/lynx-family/lynx-stack/pull/2628))
22
+
23
+ - Fix npm bin symlink entrypoint detection for the create library CLI. ([#2623](https://github.com/lynx-family/lynx-stack/pull/2623))
24
+
25
+ ## 0.0.0
26
+
27
+ ### Minor Changes
28
+
29
+ - Initial Native Autolink library scaffolding package.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # create-lynx-library
2
+
3
+ Create native Lynx libraries.
4
+
5
+ ```bash
6
+ npm create lynx-library
7
+ ```
8
+
9
+ The interactive flow lets you choose one or more library features:
10
+
11
+ - Native Module
12
+ - Element
13
+ - Service
14
+
15
+ For non-interactive usage:
16
+
17
+ ```bash
18
+ npm create lynx-library -- \
19
+ --dir ./lynx-button \
20
+ --features native-module,element,service \
21
+ --package-name @example/lynx-button \
22
+ --android-package com.example.button \
23
+ --module-name ButtonModule \
24
+ --element-name x-button \
25
+ --service-name ButtonService
26
+ ```
27
+
28
+ Use `--features all` to generate a package that contains all supported library
29
+ features.
30
+
31
+ Generated libraries include `lynx.lib.json`, JS facade sources, Android and
32
+ iOS native examples, an example app skeleton, and a `codegen` script powered by
33
+ the current published version of `@lynx-js/autolink-codegen`.
package/dist/cli.d.ts ADDED
@@ -0,0 +1,53 @@
1
+ import { multiselect } from '@clack/prompts';
2
+ import type { Readable } from 'node:stream';
3
+ import { text } from '@clack/prompts';
4
+ import type { Writable } from 'node:stream';
5
+
6
+ export declare interface CliOptions {
7
+ dir?: string;
8
+ features?: LibraryFeature[];
9
+ packageName?: string;
10
+ androidPackage?: string;
11
+ moduleName?: string;
12
+ elementName?: string;
13
+ serviceName?: string;
14
+ help: boolean;
15
+ }
16
+
17
+ export declare interface CliPrompts {
18
+ text: typeof text;
19
+ multiselect: typeof multiselect;
20
+ }
21
+
22
+ export declare interface CliRuntime {
23
+ input: Readable & {
24
+ isTTY?: boolean;
25
+ };
26
+ output: Writable & {
27
+ isTTY?: boolean;
28
+ };
29
+ info: (message: string) => void;
30
+ error: (message: string) => void;
31
+ prompts?: CliPrompts;
32
+ }
33
+
34
+ export declare function isCliEntrypoint(entrypoint?: string | undefined, moduleUrl?: string): boolean;
35
+
36
+ declare type LibraryFeature = 'native-module' | 'element' | 'service';
37
+
38
+ /**
39
+ * Runs the scaffold command from parsed and interactive CLI options.
40
+ */
41
+ export declare function main(argv?: string[], runtime?: CliRuntime): Promise<void>;
42
+
43
+ /**
44
+ * Parses command-line arguments for the library scaffold CLI.
45
+ */
46
+ export declare function parseArgs(argv: string[]): CliOptions;
47
+
48
+ /**
49
+ * Reports CLI failures using the same formatting as the executable entry point.
50
+ */
51
+ export declare function reportCliError(error: unknown, runtime?: CliRuntime): void;
52
+
53
+ export { }
package/dist/cli.js ADDED
@@ -0,0 +1,242 @@
1
+ #!/usr/bin/env node
2
+ import node_fs from "node:fs";
3
+ import node_path from "node:path";
4
+ import { stdin, stdout } from "node:process";
5
+ import { fileURLToPath } from "node:url";
6
+ import { cancel, isCancel, multiselect, text as prompts_text } from "@clack/prompts";
7
+ import { LIBRARY_FEATURES, parseLibraryFeatures, createLynxLibrary } from "./index.js";
8
+ const DEFAULT_RUNTIME = {
9
+ input: stdin,
10
+ output: stdout,
11
+ info (message) {
12
+ console.info(message);
13
+ },
14
+ error (message) {
15
+ console.error(message);
16
+ }
17
+ };
18
+ class CliCancelError extends Error {
19
+ name = 'CliCancelError';
20
+ }
21
+ const DEFAULT_PROMPTS = {
22
+ text: prompts_text,
23
+ multiselect: multiselect
24
+ };
25
+ const DEFAULT_PROJECT_NAME = 'lynx-library';
26
+ const LIBRARY_FEATURE_LABELS = {
27
+ 'native-module': 'Native Module',
28
+ element: 'Element',
29
+ service: 'Service'
30
+ };
31
+ const LIBRARY_FEATURE_HINTS = {
32
+ 'native-module': 'JS bridge APIs implemented by native code',
33
+ element: 'native UI element registered with Lynx',
34
+ service: 'native service implementation registered globally'
35
+ };
36
+ function parseArgs(argv) {
37
+ const options = {
38
+ help: false
39
+ };
40
+ for(let index = 0; index < argv.length; index += 1){
41
+ const arg = argv[index];
42
+ if (void 0 !== arg) {
43
+ if ('--help' === arg || '-h' === arg) {
44
+ options.help = true;
45
+ continue;
46
+ }
47
+ if ('--dir' === arg || '-d' === arg) {
48
+ options.dir = readValue(argv, index, arg);
49
+ index += 1;
50
+ continue;
51
+ }
52
+ if ('--features' === arg || '--feature' === arg) {
53
+ options.features = [
54
+ ...options.features ?? [],
55
+ ...parseLibraryFeatures(readValue(argv, index, arg))
56
+ ];
57
+ index += 1;
58
+ continue;
59
+ }
60
+ if ('--package-name' === arg) {
61
+ options.packageName = readValue(argv, index, arg);
62
+ index += 1;
63
+ continue;
64
+ }
65
+ if ('--android-package' === arg) {
66
+ options.androidPackage = readValue(argv, index, arg);
67
+ index += 1;
68
+ continue;
69
+ }
70
+ if ('--module-name' === arg) {
71
+ options.moduleName = readValue(argv, index, arg);
72
+ index += 1;
73
+ continue;
74
+ }
75
+ if ('--element-name' === arg) {
76
+ options.elementName = readValue(argv, index, arg);
77
+ index += 1;
78
+ continue;
79
+ }
80
+ if ('--service-name' === arg) {
81
+ options.serviceName = readValue(argv, index, arg);
82
+ index += 1;
83
+ continue;
84
+ }
85
+ if (arg.startsWith('-')) throw new Error(`Unknown option "${arg}"`);
86
+ if (void 0 !== options.dir) throw new Error(`Unexpected positional argument "${arg}"`);
87
+ options.dir = arg;
88
+ }
89
+ }
90
+ return options;
91
+ }
92
+ function readValue(argv, index, option) {
93
+ const value = argv[index + 1];
94
+ if (void 0 === value || value.startsWith('-')) throw new Error(`${option} requires a value`);
95
+ return value;
96
+ }
97
+ function printHelp(runtime) {
98
+ runtime.info(`Usage: create-lynx-library [dir] [options]
99
+
100
+ Options:
101
+ --dir, -d <dir> Target directory.
102
+ --feature, --features <list> Comma-separated list or "all".
103
+ --package-name <name> npm package name.
104
+ --android-package <name> Android package name for lynx.lib.json.
105
+ --module-name <name> Native module class name.
106
+ --element-name <name> Element tag name.
107
+ --service-name <name> Service class name.
108
+ --help, -h Show this help message.
109
+
110
+ Library features:
111
+ native-module JS bridge APIs implemented by native code.
112
+ element Native UI element registered with Lynx.
113
+ service Native service implementation registered globally.
114
+
115
+ Examples:
116
+ create-lynx-library
117
+ create-lynx-library lynx-button --features native-module,element,service
118
+ create-lynx-library lynx-kit --features all
119
+ `);
120
+ }
121
+ async function fillInteractiveOptions(options, runtime) {
122
+ const next = {
123
+ ...options
124
+ };
125
+ const needsPrompt = void 0 === next.dir || void 0 === next.features || 0 === next.features.length;
126
+ if (!needsPrompt) return next;
127
+ if (!runtime.input.isTTY || !runtime.output.isTTY) {
128
+ const missingOptions = [];
129
+ if (void 0 === next.dir) missingOptions.push('--dir');
130
+ if (void 0 === next.features || 0 === next.features.length) missingOptions.push('--features');
131
+ throw new Error(`Missing required options in non-interactive mode: ${missingOptions.join(', ')}`);
132
+ }
133
+ const prompts = getPrompts(runtime);
134
+ next.dir ??= checkCancel(await prompts.text({
135
+ input: runtime.input,
136
+ output: runtime.output,
137
+ message: 'Project name or path',
138
+ placeholder: DEFAULT_PROJECT_NAME,
139
+ defaultValue: DEFAULT_PROJECT_NAME,
140
+ validate (value) {
141
+ if (value?.trim().length === 0) return 'Project name is required';
142
+ }
143
+ }), runtime).trim();
144
+ if (void 0 === next.features || 0 === next.features.length) next.features = checkCancel(await prompts.multiselect({
145
+ input: runtime.input,
146
+ output: runtime.output,
147
+ message: 'Select library features (Use <space> to select, <enter> to continue)',
148
+ options: LIBRARY_FEATURES.map((feature)=>({
149
+ value: feature,
150
+ label: LIBRARY_FEATURE_LABELS[feature],
151
+ hint: LIBRARY_FEATURE_HINTS[feature]
152
+ })),
153
+ initialValues: [
154
+ ...LIBRARY_FEATURES
155
+ ],
156
+ required: true
157
+ }), runtime);
158
+ return next;
159
+ }
160
+ async function main(argv = process.argv.slice(2), runtime = DEFAULT_RUNTIME) {
161
+ const parsed = parseArgs(argv);
162
+ if (parsed.help) return void printHelp(runtime);
163
+ const options = await fillInteractiveOptions(parsed, runtime);
164
+ if (void 0 === options.dir || 0 === options.dir.trim().length) throw new Error('Target directory is required');
165
+ if (void 0 === options.features || 0 === options.features.length) throw new Error('At least one library feature is required');
166
+ const createOptions = {
167
+ dir: node_path.resolve(options.dir),
168
+ features: options.features
169
+ };
170
+ if (void 0 !== options.packageName) createOptions.packageName = options.packageName;
171
+ if (void 0 !== options.androidPackage) createOptions.androidPackage = options.androidPackage;
172
+ if (void 0 !== options.moduleName) createOptions.moduleName = options.moduleName;
173
+ if (void 0 !== options.elementName) createOptions.elementName = options.elementName;
174
+ if (void 0 !== options.serviceName) createOptions.serviceName = options.serviceName;
175
+ const files = createLynxLibrary(createOptions);
176
+ runtime.info(formatSuccessMessage({
177
+ dir: createOptions.dir,
178
+ filesCount: files.length,
179
+ packageManager: detectPackageManager(),
180
+ features: options.features
181
+ }));
182
+ }
183
+ function reportCliError(error, runtime = DEFAULT_RUNTIME) {
184
+ if (error instanceof CliCancelError) return;
185
+ runtime.error(error instanceof Error ? error.message : String(error));
186
+ process.exitCode = 1;
187
+ }
188
+ function isCliEntrypoint(entrypoint = process.argv[1], moduleUrl = import.meta.url) {
189
+ return void 0 !== entrypoint && normalizeEntrypointPath(entrypoint) === normalizeEntrypointPath(fileURLToPath(moduleUrl));
190
+ }
191
+ function normalizeEntrypointPath(filePath) {
192
+ const resolvedPath = node_path.resolve(filePath);
193
+ try {
194
+ return node_fs.realpathSync(resolvedPath);
195
+ } catch {
196
+ return resolvedPath;
197
+ }
198
+ }
199
+ function getPrompts(runtime) {
200
+ return runtime.prompts ?? DEFAULT_PROMPTS;
201
+ }
202
+ function checkCancel(value, runtime) {
203
+ if (isCancel(value)) {
204
+ cancel('Operation cancelled.', {
205
+ input: runtime.input,
206
+ output: runtime.output
207
+ });
208
+ throw new CliCancelError();
209
+ }
210
+ return value;
211
+ }
212
+ function formatSuccessMessage({ dir, filesCount, packageManager, features }) {
213
+ const selectedFeatures = LIBRARY_FEATURES.filter((feature)=>features.includes(feature));
214
+ const featureSummary = selectedFeatures.map((feature)=>` - ${LIBRARY_FEATURE_LABELS[feature]}`).join('\n');
215
+ const nextSteps = [
216
+ `1. cd ${formatTargetDir(dir)}`,
217
+ `2. ${packageManager} install`
218
+ ];
219
+ if (selectedFeatures.includes('native-module')) nextSteps.push(`3. ${packageManager} run codegen`);
220
+ return `Created ${filesCount} files in ${dir}
221
+
222
+ Library features:
223
+ ${featureSummary}
224
+
225
+ Next steps:
226
+ ${nextSteps.map((step)=>` ${step}`).join('\n')}`;
227
+ }
228
+ function detectPackageManager(userAgent = process.env['npm_config_user_agent']) {
229
+ const name = userAgent?.split(' ')[0]?.split('/')[0];
230
+ if ('bun' === name || 'pnpm' === name || 'yarn' === name) return name;
231
+ return 'npm';
232
+ }
233
+ function formatTargetDir(targetDir) {
234
+ const relativePath = node_path.relative(process.cwd(), targetDir);
235
+ if (0 === relativePath.length) return '.';
236
+ if (!relativePath.startsWith('..') && !node_path.isAbsolute(relativePath)) return relativePath;
237
+ return targetDir;
238
+ }
239
+ if (isCliEntrypoint()) main().catch((error)=>{
240
+ reportCliError(error);
241
+ });
242
+ export { isCliEntrypoint, main, parseArgs, reportCliError };
@@ -0,0 +1,31 @@
1
+ export declare interface CreatedFile {
2
+ path: string;
3
+ content: string;
4
+ }
5
+
6
+ /**
7
+ * Creates a Lynx library scaffold on disk.
8
+ */
9
+ export declare function createLynxLibrary(options: CreateLynxLibraryOptions): CreatedFile[];
10
+
11
+ export declare interface CreateLynxLibraryOptions {
12
+ dir: string;
13
+ features: LibraryFeature[];
14
+ packageName?: string;
15
+ androidPackage?: string;
16
+ moduleName?: string;
17
+ elementName?: string;
18
+ serviceName?: string;
19
+ dependencyVersions?: Record<string, string>;
20
+ }
21
+
22
+ export declare const LIBRARY_FEATURES: readonly LibraryFeature[];
23
+
24
+ export declare type LibraryFeature = 'native-module' | 'element' | 'service';
25
+
26
+ /**
27
+ * Parses a comma-separated library feature list from CLI input.
28
+ */
29
+ export declare function parseLibraryFeatures(source: string): LibraryFeature[];
30
+
31
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,227 @@
1
+ import node_fs from "node:fs";
2
+ import node_path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const LIBRARY_FEATURES = [
5
+ 'native-module',
6
+ 'element',
7
+ 'service'
8
+ ];
9
+ const PACKAGE_ROOT = node_path.resolve(node_path.dirname(fileURLToPath(import.meta.url)), '..');
10
+ const TEMPLATE_FILE_SUFFIX = '.tmpl';
11
+ const PACKAGE_JSON_DEPENDENCY_FIELDS = [
12
+ 'dependencies',
13
+ 'devDependencies',
14
+ 'optionalDependencies',
15
+ 'peerDependencies'
16
+ ];
17
+ function createLynxLibrary(options) {
18
+ const targetDir = node_path.resolve(options.dir);
19
+ if (node_fs.existsSync(targetDir)) {
20
+ const stat = node_fs.statSync(targetDir);
21
+ if (!stat.isDirectory()) throw new Error(`Target path is not a directory: ${targetDir}`);
22
+ if (node_fs.readdirSync(targetDir).length > 0) throw new Error(`Target directory is not empty: ${targetDir}`);
23
+ }
24
+ const features = new Set(options.features);
25
+ if (0 === features.size) throw new Error('At least one library feature must be selected');
26
+ for (const feature of features)if (!isLibraryFeature(feature)) throw new Error(`Unsupported library feature: ${String(feature)}`);
27
+ const context = createContext(options, features);
28
+ const files = createFiles(context);
29
+ for (const file of files){
30
+ const absolutePath = resolveInside(targetDir, file.path);
31
+ node_fs.mkdirSync(node_path.dirname(absolutePath), {
32
+ recursive: true
33
+ });
34
+ node_fs.writeFileSync(absolutePath, file.content);
35
+ }
36
+ return files;
37
+ }
38
+ function parseLibraryFeatures(source) {
39
+ const normalizedSource = source.trim().toLowerCase();
40
+ if ('all' === normalizedSource) return [
41
+ ...LIBRARY_FEATURES
42
+ ];
43
+ const features = normalizedSource.split(',').map((feature)=>feature.trim()).filter(Boolean);
44
+ if (0 === features.length) return [];
45
+ return features.map((feature)=>{
46
+ if (!isLibraryFeature(feature)) throw new Error(`Unsupported library feature "${feature}". Expected one of: ${LIBRARY_FEATURES.join(', ')}`);
47
+ return feature;
48
+ });
49
+ }
50
+ function createContext(options, features) {
51
+ const directoryName = node_path.basename(node_path.resolve(options.dir));
52
+ const packageName = options.packageName ?? normalizePackageName(directoryName);
53
+ const baseName = packageName.split('/').at(-1) ?? packageName;
54
+ const prefix = toPascalCase(baseName);
55
+ const moduleName = options.moduleName ?? `${prefix}Module`;
56
+ const elementName = options.elementName ?? `x-${toKebabCase(prefix)}`;
57
+ const serviceName = options.serviceName ?? `${prefix}Service`;
58
+ const elementPrefix = toPascalCase(elementName.replace(/^x-/, ''));
59
+ const androidPackage = options.androidPackage ?? `com.example.${toJavaPackageSegment(prefix)}`;
60
+ return {
61
+ packageName,
62
+ androidPackage,
63
+ androidPackagePath: androidPackage.replaceAll('.', '/'),
64
+ moduleName,
65
+ elementName,
66
+ elementClassName: `${elementPrefix}Element`,
67
+ serviceName,
68
+ serviceProtocolName: `${serviceName}Protocol`,
69
+ dependencyVersions: options.dependencyVersions ?? readDefaultDependencyVersions(),
70
+ features
71
+ };
72
+ }
73
+ function createFiles(context) {
74
+ const groups = [
75
+ 'template-common'
76
+ ];
77
+ if (context.features.has('native-module')) groups.push('template-native-module');
78
+ if (context.features.has('element')) groups.push('template-element');
79
+ if (context.features.has('service')) groups.push('template-service');
80
+ return groups.flatMap((group)=>createFilesFromTemplateGroup(group, context));
81
+ }
82
+ function createFilesFromTemplateGroup(group, context) {
83
+ const root = node_path.join(PACKAGE_ROOT, group);
84
+ const replacements = createTemplateReplacements(context);
85
+ return listTemplateFiles(root).map((absolutePath)=>{
86
+ const relativePath = toPosixPath(node_path.relative(root, absolutePath));
87
+ const renderedPath = renderTemplate(relativePath, replacements);
88
+ const filePath = stripTemplateFileSuffix(renderedPath);
89
+ const content = renderTemplate(node_fs.readFileSync(absolutePath, 'utf8'), replacements);
90
+ return {
91
+ path: filePath,
92
+ content: filePath.endsWith('package.json') ? replacePackageDependencyVersions(content, context.dependencyVersions, filePath) : content
93
+ };
94
+ });
95
+ }
96
+ function readDefaultDependencyVersions() {
97
+ const packageJson = JSON.parse(node_fs.readFileSync(node_path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
98
+ return packageJson.devDependencies ?? {};
99
+ }
100
+ function replacePackageDependencyVersions(source, dependencyVersions, filePath) {
101
+ let packageJson;
102
+ try {
103
+ packageJson = JSON.parse(source);
104
+ } catch (error) {
105
+ const message = error instanceof Error ? error.message : String(error);
106
+ throw new Error(`Invalid package.json template after rendering: ${filePath}: ${message}`);
107
+ }
108
+ const missingVersionPackages = new Set();
109
+ for (const field of PACKAGE_JSON_DEPENDENCY_FIELDS){
110
+ const dependencies = packageJson[field];
111
+ if (void 0 !== dependencies) {
112
+ for (const [name, version] of Object.entries(dependencies))if (version.startsWith('workspace:')) {
113
+ const replacement = dependencyVersions[name];
114
+ if (void 0 === replacement) missingVersionPackages.add(name);
115
+ else dependencies[name] = replacement;
116
+ }
117
+ }
118
+ }
119
+ if (missingVersionPackages.size > 0) throw new Error(`Template package.json "${filePath}" contains workspace dependencies without version mappings: ${Array.from(missingVersionPackages).join(', ')}. Add these packages to create-lynx-library's devDependencies.`);
120
+ return `${JSON.stringify(packageJson, null, 2)}\n`;
121
+ }
122
+ function listTemplateFiles(root) {
123
+ const files = [];
124
+ for (const entry of node_fs.readdirSync(root, {
125
+ withFileTypes: true
126
+ }).sort((left, right)=>left.name.localeCompare(right.name))){
127
+ const absolutePath = node_path.join(root, entry.name);
128
+ if (entry.isDirectory()) files.push(...listTemplateFiles(absolutePath));
129
+ else if (entry.isFile()) files.push(absolutePath);
130
+ }
131
+ return files;
132
+ }
133
+ function toPosixPath(filePath) {
134
+ return filePath.split(node_path.sep).join('/');
135
+ }
136
+ function stripTemplateFileSuffix(filePath) {
137
+ return filePath.endsWith(TEMPLATE_FILE_SUFFIX) ? filePath.slice(0, -TEMPLATE_FILE_SUFFIX.length) : filePath;
138
+ }
139
+ function createTemplateReplacements(context) {
140
+ return {
141
+ ANDROID_PACKAGE: context.androidPackage,
142
+ ANDROID_PACKAGE_PATH: context.androidPackagePath,
143
+ ELEMENT_CLASS_NAME: context.elementClassName,
144
+ ELEMENT_NAME: context.elementName,
145
+ EXAMPLE_ELEMENT: exampleElement(context),
146
+ EXAMPLE_IMPORT: exampleImport(context),
147
+ EXAMPLE_MODULE_BUTTON: exampleModuleButton(context),
148
+ IOS_SERVICE_API_DEPENDENCY: iosServiceApiDependency(context),
149
+ MODULE_NAME: context.moduleName,
150
+ PACKAGE_NAME: context.packageName,
151
+ PODSPEC_NAME: podspecName(context.packageName),
152
+ SERVICE_NAME: context.serviceName,
153
+ SERVICE_PROTOCOL_NAME: context.serviceProtocolName,
154
+ SOURCE_INDEX: sourceIndex(context),
155
+ TYPES_DECLARATION: typesDeclaration(context)
156
+ };
157
+ }
158
+ function renderTemplate(source, replacements) {
159
+ const rendered = source.replaceAll(/__([A-Z0-9_]+)__/g, (match, key)=>replacements[key] ?? match);
160
+ const unresolvedToken = /__[A-Z0-9_]+__/.exec(rendered);
161
+ if (null !== unresolvedToken) throw new Error(`Unresolved template token: ${unresolvedToken[0]}`);
162
+ return rendered;
163
+ }
164
+ function resolveInside(targetDir, filePath) {
165
+ const resolvedTargetDir = node_path.resolve(targetDir);
166
+ const absolutePath = node_path.resolve(resolvedTargetDir, filePath);
167
+ const relativePath = node_path.relative(resolvedTargetDir, absolutePath);
168
+ if ('..' === relativePath || relativePath.startsWith(`..${node_path.sep}`) || node_path.isAbsolute(relativePath)) throw new Error(`Generated path escapes target directory: ${filePath}`);
169
+ return absolutePath;
170
+ }
171
+ function sourceIndex(context) {
172
+ if (!context.features.has('native-module')) return `// Lynx library package entry.
173
+ `;
174
+ return `export { ${context.moduleName} } from '../generated/${context.moduleName}';
175
+ `;
176
+ }
177
+ function typesDeclaration(context) {
178
+ if (!context.features.has('native-module')) return `// Add native module declarations here and run npm run codegen.
179
+ `;
180
+ return `/** @lynxmodule */
181
+ export declare class ${context.moduleName} {
182
+ setValue(key: string, value: string): void;
183
+ getValue(key: string): string | null;
184
+ clear(): void;
185
+ }
186
+ `;
187
+ }
188
+ function exampleImport(context) {
189
+ if (!context.features.has('native-module')) return '';
190
+ return `import { ${context.moduleName} } from '${context.packageName}';
191
+
192
+ `;
193
+ }
194
+ function exampleModuleButton(context) {
195
+ if (!context.features.has('native-module')) return '';
196
+ return `<text bindtap={() => ${context.moduleName}.setValue('key', 'value')}>
197
+ Native module
198
+ </text>`;
199
+ }
200
+ function exampleElement(context) {
201
+ return context.features.has('element') ? `<${context.elementName} />` : '';
202
+ }
203
+ function iosServiceApiDependency(context) {
204
+ return context.features.has('service') ? " s.dependency 'LynxServiceAPI'" : '';
205
+ }
206
+ function normalizePackageName(name) {
207
+ return name.toLowerCase().replaceAll(/[^a-z0-9_-]/g, '-');
208
+ }
209
+ function toPascalCase(name) {
210
+ const words = name.split(/[^A-Z0-9]+/i).filter(Boolean);
211
+ const result = words.map((word)=>`${word.charAt(0).toUpperCase()}${word.slice(1)}`).join('');
212
+ return result.length > 0 ? result : 'LynxLibrary';
213
+ }
214
+ function toKebabCase(name) {
215
+ return name.replaceAll(/([a-z0-9])([A-Z])/g, '$1-$2').replaceAll(/[^A-Z0-9]+/gi, '-').replaceAll(/^-|-$/g, '').toLowerCase();
216
+ }
217
+ function toJavaPackageSegment(name) {
218
+ const segment = toKebabCase(name).replaceAll('-', '');
219
+ return segment.length > 0 ? segment : 'library';
220
+ }
221
+ function podspecName(packageName) {
222
+ return packageName.replace(/^@/, '').replaceAll('/', '-');
223
+ }
224
+ function isLibraryFeature(type) {
225
+ return LIBRARY_FEATURES.includes(type);
226
+ }
227
+ export { LIBRARY_FEATURES, createLynxLibrary, parseLibraryFeatures };
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "create-lynx-library",
3
+ "version": "0.2.0",
4
+ "description": "Create native Lynx libraries",
5
+ "keywords": [
6
+ "Lynx",
7
+ "Autolink",
8
+ "create"
9
+ ],
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "https://github.com/lynx-family/lynx-stack.git",
13
+ "directory": "packages/lynx/create-lynx-library"
14
+ },
15
+ "license": "Apache-2.0",
16
+ "sideEffects": false,
17
+ "type": "module",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.d.ts",
21
+ "default": "./dist/index.js"
22
+ }
23
+ },
24
+ "bin": {
25
+ "create-lynx-library": "./dist/cli.js"
26
+ },
27
+ "files": [
28
+ "CHANGELOG.md",
29
+ "README.md",
30
+ "dist",
31
+ "template-*/**"
32
+ ],
33
+ "dependencies": {
34
+ "@clack/prompts": "1.0.1"
35
+ },
36
+ "devDependencies": {
37
+ "@lynx-js/autolink-codegen": "^0.2.0"
38
+ },
39
+ "engines": {
40
+ "node": "^20 || ^22 || ^24"
41
+ },
42
+ "scripts": {
43
+ "build": "rslib build",
44
+ "dev": "rslib build --watch",
45
+ "test": "vitest run"
46
+ }
47
+ }
@@ -0,0 +1,13 @@
1
+ # **PACKAGE_NAME**
2
+
3
+ Native Lynx library.
4
+
5
+ ## Development
6
+
7
+ ```bash
8
+ npm install
9
+ npm run codegen
10
+ ```
11
+
12
+ The generated native specs are written to `generated/`, `android/`, and
13
+ `ios/`. The package is discovered by Lynx through `lynx.lib.json`.
@@ -0,0 +1,18 @@
1
+ plugins {
2
+ id("com.android.library")
3
+ }
4
+
5
+ android {
6
+ namespace = "__ANDROID_PACKAGE__"
7
+ compileSdk = 35
8
+
9
+ defaultConfig {
10
+ minSdk = 23
11
+ }
12
+ }
13
+
14
+ dependencies {
15
+ implementation("org.lynxsdk.lynx:lynx:0.0.1-alpha.1")
16
+ implementation("org.lynxsdk.lynx:service-api:0.0.1-alpha.1")
17
+ annotationProcessor("org.lynxsdk.lynx:lynx-processor:0.0.1-alpha.1")
18
+ }
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <application />
3
+ </manifest>
@@ -0,0 +1,6 @@
1
+ import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin';
2
+ import { defineConfig } from '@lynx-js/rspeedy';
3
+
4
+ export default defineConfig({
5
+ plugins: [pluginReactLynx()],
6
+ });
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "__PACKAGE_NAME__-example",
3
+ "private": true,
4
+ "type": "module",
5
+ "scripts": {
6
+ "build": "rspeedy build",
7
+ "dev": "rspeedy dev"
8
+ },
9
+ "dependencies": {
10
+ "@lynx-js/react": "^0.111.0",
11
+ "@lynx-js/react-rsbuild-plugin": "^0.11.0",
12
+ "@lynx-js/rspeedy": "^0.11.0",
13
+ "__PACKAGE_NAME__": "file:.."
14
+ },
15
+ "devDependencies": {
16
+ "typescript": "^5.9.3"
17
+ }
18
+ }
@@ -0,0 +1,9 @@
1
+ __EXAMPLE_IMPORT__export function App() {
2
+ return (
3
+ <view>
4
+ <text>__PACKAGE_NAME__</text>
5
+ __EXAMPLE_MODULE_BUTTON__
6
+ __EXAMPLE_ELEMENT__
7
+ </view>
8
+ );
9
+ }
@@ -0,0 +1,5 @@
1
+ import { root } from '@lynx-js/react';
2
+
3
+ import { App } from './App.js';
4
+
5
+ root.render(<App />);
@@ -0,0 +1,11 @@
1
+ Pod::Spec.new do |s|
2
+ s.name = '__PODSPEC_NAME__'
3
+ s.version = '0.0.1'
4
+ s.summary = 'Native Lynx library'
5
+ s.license = { :type => 'Apache-2.0' }
6
+ s.author = 'Lynx'
7
+ s.source = { :path => '..' }
8
+ s.source_files = 'src/**/*.{h,m,mm}'
9
+ s.dependency 'Lynx'
10
+ __IOS_SERVICE_API_DEPENDENCY__
11
+ end
@@ -0,0 +1,12 @@
1
+ {
2
+ "platforms": {
3
+ "android": {
4
+ "packageName": "__ANDROID_PACKAGE__",
5
+ "sourceDir": "android"
6
+ },
7
+ "ios": {
8
+ "sourceDir": "ios",
9
+ "podspecPath": "ios/build.podspec"
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "__PACKAGE_NAME__",
3
+ "version": "0.0.1",
4
+ "description": "A native Lynx library",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./src/index.ts",
8
+ "types": "./types/index.d.ts",
9
+ "files": [
10
+ "android",
11
+ "generated",
12
+ "ios",
13
+ "src",
14
+ "types",
15
+ "lynx.lib.json",
16
+ "README.md"
17
+ ],
18
+ "scripts": {
19
+ "codegen": "lynx-autolink-codegen"
20
+ },
21
+ "devDependencies": {
22
+ "@lynx-js/autolink-codegen": "workspace:*"
23
+ }
24
+ }
@@ -0,0 +1 @@
1
+ __SOURCE_INDEX__
@@ -0,0 +1,12 @@
1
+ {
2
+ "compilerOptions": {
3
+ "declaration": true,
4
+ "emitDeclarationOnly": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "Bundler",
7
+ "outDir": "dist",
8
+ "strict": true,
9
+ "target": "ES2022",
10
+ },
11
+ "include": ["src", "types", "generated"],
12
+ }
@@ -0,0 +1 @@
1
+ __TYPES_DECLARATION__
@@ -0,0 +1,21 @@
1
+ package __ANDROID_PACKAGE__;
2
+
3
+ import android.content.Context;
4
+ import android.widget.TextView;
5
+ import com.lynx.tasm.behavior.LynxContext;
6
+ import com.lynx.tasm.behavior.LynxElement;
7
+ import com.lynx.tasm.behavior.ui.LynxUI;
8
+
9
+ @LynxElement(name = "__ELEMENT_NAME__")
10
+ public class __ELEMENT_CLASS_NAME__ extends LynxUI<TextView> {
11
+ public __ELEMENT_CLASS_NAME__(LynxContext context) {
12
+ super(context);
13
+ }
14
+
15
+ @Override
16
+ protected TextView createView(Context context) {
17
+ TextView view = new TextView(context);
18
+ view.setText("__ELEMENT_NAME__");
19
+ return view;
20
+ }
21
+ }
@@ -0,0 +1,11 @@
1
+ #import <UIKit/UIKit.h>
2
+ #import <Lynx/LynxUI.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @LynxUIRegister("__ELEMENT_NAME__")
7
+ @interface __ELEMENT_CLASS_NAME__ : LynxUI<UILabel *>
8
+
9
+ @end
10
+
11
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,11 @@
1
+ #import "__ELEMENT_CLASS_NAME__.h"
2
+
3
+ @implementation __ELEMENT_CLASS_NAME__
4
+
5
+ - (UILabel *)createView {
6
+ UILabel *label = [[UILabel alloc] init];
7
+ label.text = @"__ELEMENT_NAME__";
8
+ return label;
9
+ }
10
+
11
+ @end
@@ -0,0 +1,31 @@
1
+ package __ANDROID_PACKAGE__;
2
+
3
+ import androidx.annotation.Nullable;
4
+ import com.lynx.jsbridge.LynxMethod;
5
+ import com.lynx.jsbridge.LynxNativeModule;
6
+ import com.lynx.tasm.behavior.LynxContext;
7
+ import __ANDROID_PACKAGE__.generated.__MODULE_NAME__Spec;
8
+
9
+ @LynxNativeModule(name = "__MODULE_NAME__")
10
+ public class __MODULE_NAME__ extends __MODULE_NAME__Spec {
11
+ public __MODULE_NAME__(LynxContext context) {
12
+ super(context);
13
+ }
14
+
15
+ @Override
16
+ @LynxMethod
17
+ public void setValue(String key, String value) {
18
+ }
19
+
20
+ @Override
21
+ @LynxMethod
22
+ @Nullable
23
+ public String getValue(String key) {
24
+ return null;
25
+ }
26
+
27
+ @Override
28
+ @LynxMethod
29
+ public void clear() {
30
+ }
31
+ }
@@ -0,0 +1,12 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Lynx/LynxModule.h>
3
+ #import "generated/__MODULE_NAME__Spec.h"
4
+
5
+ NS_ASSUME_NONNULL_BEGIN
6
+
7
+ @LynxNativeModuleRegister("__MODULE_NAME__")
8
+ @interface __MODULE_NAME__ : NSObject <__MODULE_NAME__Spec>
9
+
10
+ @end
11
+
12
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,27 @@
1
+ #import "__MODULE_NAME__.h"
2
+
3
+ @implementation __MODULE_NAME__
4
+
5
+ + (NSString *)name {
6
+ return @"__MODULE_NAME__";
7
+ }
8
+
9
+ + (NSDictionary<NSString *, NSString *> *)methodLookup {
10
+ return @{
11
+ @"setValue" : NSStringFromSelector(@selector(setValue:value:)),
12
+ @"getValue" : NSStringFromSelector(@selector(getValue:)),
13
+ @"clear" : NSStringFromSelector(@selector(clear)),
14
+ };
15
+ }
16
+
17
+ - (void)setValue:(NSString *)key value:(NSString *)value {
18
+ }
19
+
20
+ - (nullable NSString *)getValue:(NSString *)key {
21
+ return nil;
22
+ }
23
+
24
+ - (void)clear {
25
+ }
26
+
27
+ @end
@@ -0,0 +1,10 @@
1
+ package __ANDROID_PACKAGE__;
2
+
3
+ import com.lynx.tasm.service.LynxService;
4
+
5
+ @LynxService
6
+ public class __SERVICE_NAME__ {
7
+ public String name() {
8
+ return "__SERVICE_NAME__";
9
+ }
10
+ }
@@ -0,0 +1,16 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <LynxServiceAPI/ServiceAPI.h>
3
+
4
+ NS_ASSUME_NONNULL_BEGIN
5
+
6
+ @protocol __SERVICE_PROTOCOL_NAME__ <LynxServiceProtocol>
7
+
8
+ - (NSString *)name;
9
+
10
+ @end
11
+
12
+ @interface __SERVICE_NAME__ : NSObject <__SERVICE_PROTOCOL_NAME__>
13
+
14
+ @end
15
+
16
+ NS_ASSUME_NONNULL_END
@@ -0,0 +1,10 @@
1
+ #import "__SERVICE_NAME__.h"
2
+
3
+ @LynxServiceRegister(__SERVICE_NAME__, __SERVICE_PROTOCOL_NAME__)
4
+ @implementation __SERVICE_NAME__
5
+
6
+ - (NSString *)name {
7
+ return @"__SERVICE_NAME__";
8
+ }
9
+
10
+ @end