@linyjs/plugin-templates 0.0.1

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.
package/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Ling Plugin Templates
2
+
3
+ Templates for creating Ling framework plugins.
4
+
5
+ ## Usage
6
+
7
+ ```bash
8
+ npx @linyjs/cli init my-plugin
9
+ ```
10
+
11
+ Or manually:
12
+
13
+ ```bash
14
+ npm create @linyjs/plugin-templates my-plugin
15
+ ```
16
+
17
+ ## Structure
18
+
19
+ ```
20
+ my-plugin/
21
+ ├── package.json
22
+ ├── tsconfig.json
23
+ ├── README.md
24
+ └── src/
25
+ ├── server/
26
+ │ └── index.ts
27
+ └── client/
28
+ └── index.tsx
29
+ ```
30
+
31
+ ## Features
32
+
33
+ - ✅ TypeScript support
34
+ - ✅ React 19 support
35
+ - ✅ Zero-config build with `@linyjs/cli`
36
+ - ✅ Example server and client modules
37
+ - ✅ Ready to pack and deploy
38
+
39
+ ## Learn More
40
+
41
+ - [Plugin Development Guide](https://github.com/linyjs/ling/blob/main/spec/插件开发指南.md)
42
+ - [CLI Documentation](https://github.com/linyjs/ling/blob/main/packages/cli/README.md)
@@ -0,0 +1,41 @@
1
+ # My Plugin
2
+
3
+ A Ling framework plugin.
4
+
5
+ ## Getting Started
6
+
7
+ 1. Install dependencies:
8
+ ```bash
9
+ npm install
10
+ ```
11
+
12
+ 2. Build the plugin:
13
+ ```bash
14
+ npm run build
15
+ ```
16
+
17
+ 3. Pack for deployment:
18
+ ```bash
19
+ npx @linyjs/cli pack
20
+ ```
21
+
22
+ 4. Test locally:
23
+ ```bash
24
+ # Copy to extensions directory
25
+ cp my-plugin-1.0.0.mpk /path/to/ling/packages/ssr/extensions/
26
+
27
+ # Restart SSR server
28
+ cd /path/to/ling/packages/ssr
29
+ npx tsx src/demo/dev-server-with-pkg.tsx
30
+ ```
31
+
32
+ ## Development
33
+
34
+ - Edit `src/server/index.ts` for backend logic
35
+ - Edit `src/client/index.tsx` for frontend UI
36
+ - Run `npm run dev` for watch mode
37
+
38
+ ## Learn More
39
+
40
+ - [Plugin Development Guide](https://github.com/linyjs/ling/blob/main/spec/插件开发指南.md)
41
+ - [CLI Documentation](https://github.com/linyjs/ling/blob/main/packages/cli/README.md)
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "my-plugin",
3
+ "version": "1.0.0",
4
+ "description": "A Ling framework plugin",
5
+ "type": "module",
6
+ "scripts": {
7
+ "build": "tsc",
8
+ "dev": "tsc --watch",
9
+ "pack": "npx @linyjs/cli pack"
10
+ },
11
+ "dependencies": {
12
+ "@linyjs/server-module-interface": "^0.0.1",
13
+ "@linyjs/client-module-interface": "^0.0.1",
14
+ "react": "^19.0.0"
15
+ },
16
+ "devDependencies": {
17
+ "typescript": "^5.7.0",
18
+ "@types/react": "^19.0.0"
19
+ }
20
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Client Module Example
3
+ *
4
+ * This is a simple client module that provides a page route.
5
+ * Uncomment and modify the code below to create your own UI.
6
+ */
7
+
8
+ import type { IModule } from '@linyjs/client-module-interface';
9
+ import React from 'react';
10
+
11
+ // Example Page Component
12
+ function ExamplePage() {
13
+ return (
14
+ <div style={{ padding: '20px' }}>
15
+ <h1>Hello from Your Plugin!</h1>
16
+ <p>This is an example page.</p>
17
+ </div>
18
+ );
19
+ }
20
+
21
+ // Example Route Service
22
+ class ExampleRouteService {
23
+ basePath = '/example';
24
+
25
+ getRoutes() {
26
+ return [
27
+ {
28
+ path: '/',
29
+ component: ExamplePage,
30
+ key: 'example-page',
31
+ meta: { title: 'Example Page' }
32
+ }
33
+ ];
34
+ }
35
+ }
36
+
37
+ // Define the client module
38
+ export const exampleClientModule: IModule = {
39
+ name: 'exampleClient',
40
+ serviceDefs: [
41
+ {
42
+ serviceTag: 'exampleRoute',
43
+ serviceImpl: ExampleRouteService,
44
+ meta: { usageType: 'route' }
45
+ }
46
+ ]
47
+ };
48
+
49
+ // Export the module (required)
50
+ export default exampleClientModule;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Server Module Example
3
+ *
4
+ * This is a simple server module that provides an API endpoint.
5
+ * Uncomment and modify the code below to create your own API.
6
+ */
7
+
8
+ import type { IModule } from '@linyjs/server-module-interface';
9
+
10
+ // Example Controller
11
+ class ExampleController {
12
+ getRoutes() {
13
+ return [
14
+ {
15
+ method: 'GET' as const,
16
+ path: '/api/example',
17
+ middlewares: [],
18
+ responseType: 'json' as const,
19
+ handler: async (params: any, ctx: any) => {
20
+ return {
21
+ message: 'Hello from your plugin!',
22
+ timestamp: new Date().toISOString()
23
+ };
24
+ }
25
+ }
26
+ ];
27
+ }
28
+ }
29
+
30
+ // Define the server module
31
+ export const exampleServerModule: IModule = {
32
+ name: 'exampleServer',
33
+ serviceDefs: [
34
+ {
35
+ serviceTag: 'exampleController',
36
+ serviceImpl: ExampleController,
37
+ meta: { usageType: 'controller' }
38
+ }
39
+ ]
40
+ };
41
+
42
+ // Export the module (required)
43
+ export default exampleServerModule;
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "ESNext",
5
+ "lib": ["ES2020", "DOM"],
6
+ "jsx": "react-jsx",
7
+ "declaration": true,
8
+ "outDir": "./dist",
9
+ "rootDir": "./src",
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "moduleResolution": "node"
14
+ },
15
+ "include": ["src/**/*"]
16
+ }
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "@linyjs/plugin-templates",
3
+ "version": "0.0.1",
4
+ "description": "Templates for Ling framework plugins",
5
+ "keywords": [
6
+ "ling",
7
+ "plugin",
8
+ "templates"
9
+ ],
10
+ "license": "MIT",
11
+ "files": [
12
+ "default-template"
13
+ ]
14
+ }