Skip to content

Commit

Permalink
chore: 分离插件测试网页
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Nov 13, 2024
1 parent f175e91 commit 257dae7
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dist/buildinfo.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions plugins/index.html → packages/apps/interpolate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ChatGPT-Telegram-Workers</title>
<script type="module" src="dist/interpolate.js"></script>
<script type="module" src="./dist/index.js"></script>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
Expand Down Expand Up @@ -133,7 +133,7 @@ <h2>preview</h2>

<script type="module">

import { interpolate } from './dist/interpolate.js';
import interpolate from './dist/index.js';

function updatePreview() {
const template = document.getElementById('template').value;
Expand Down
17 changes: 17 additions & 0 deletions packages/apps/interpolate/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "@chatgpt-telegram-workers/interpolate",
"type": "module",
"version": "1.10.2",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "pnpm vite build",
"clean": "rm -rf dist",
"dev": "pnpm vite"
},
"dependencies": {
"@chatgpt-telegram-workers/interp": "workspace:*"
},
"devDependencies": {
}
}
3 changes: 3 additions & 0 deletions packages/apps/interpolate/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { interpolate } from '@chatgpt-telegram-workers/interp';

export default interpolate;
11 changes: 11 additions & 0 deletions packages/apps/interpolate/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
},
"references": [
{ "path": "../../lib/interp" },
],
"include": ["src/**/*"]
}
7 changes: 7 additions & 0 deletions packages/apps/interpolate/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createShareConfig } from '../../../vite.config.shared';

export default createShareConfig({
root: __dirname,
nodeExternals: true,
excludeMonoRepoPackages: true,
});
3 changes: 3 additions & 0 deletions packages/lib/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
"build": "pnpm vite build",
"clean": "rm -rf dist"
},
"dependencies": {
"@chatgpt-telegram-workers/interp": "workspace:*"
},
"devDependencies": {
"telegram-bot-api-types": "^7.11.0",
"toml": "^3.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/lib/core/src/config/version.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const BUILD_TIMESTAMP = 1731503286;
export const BUILD_VERSION = '06ba860';
export const BUILD_TIMESTAMP = 1731510288;
export const BUILD_VERSION = 'be75d39';
2 changes: 1 addition & 1 deletion packages/lib/core/src/plugins/template.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { interpolate } from './interpolate';
import { interpolate } from '@chatgpt-telegram-workers/interp';

/**
* TemplateInputType: 输入数据的类型,将Telegram输入的数据转换为对应的数据类型
Expand Down
5 changes: 4 additions & 1 deletion packages/lib/core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist"
"outDir": "./dist",
},
"references": [
{ "path": "../interp" }
],
"include": ["src/**/*"]
}
11 changes: 11 additions & 0 deletions packages/lib/interp/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "@chatgpt-telegram-workers/interp",
"type": "module",
"version": "1.10.2",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"scripts": {
"build": "pnpm vite build",
"clean": "rm -rf dist"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { interpolate } from './interpolate';
import { interpolate } from './index';

{
const template = 'Hello, {{name}}!';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ function evaluateExpression(expr: string, localData: any): undefined | any {
}
}

type Formatter = (value: any) => string;

export function interpolate(template: string, data: any, formatter: Formatter | null = null): string {
export function interpolate(template: string, data: any, formatter?: (value: any) => string): string {
const processConditional = (condition: string, trueBlock: string, falseBlock: string, localData: any): string => {
const result = evaluateExpression(condition, localData);
return result ? trueBlock : (falseBlock || '');
Expand Down
8 changes: 8 additions & 0 deletions packages/lib/interp/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"outDir": "./dist",
},
"include": ["src/**/*"]
}
5 changes: 5 additions & 0 deletions packages/lib/interp/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createShareConfig } from '../../../vite.config.shared';

export default createShareConfig({
root: __dirname,
});
2 changes: 1 addition & 1 deletion packages/lib/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
"clean": "rm -rf dist"
},
"dependencies": {
"@chatgpt-telegram-workers/core": "workspace:*",
"@ai-sdk/anthropic": "^0.0.56",
"@ai-sdk/azure": "^0.0.52",
"@ai-sdk/cohere": "^0.0.28",
"@ai-sdk/google": "^0.0.55",
"@ai-sdk/mistral": "^0.0.46",
"@ai-sdk/openai": "^0.0.72",
"@ai-sdk/provider": "^0.0.26",
"@chatgpt-telegram-workers/core": "workspace:*",
"ai": "^3.4.33"
},
"devDependencies": {
Expand Down
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
packages:
- packages/apps/*
- packages/lib/*
- packages/plugins/*
- packages/lib/*

0 comments on commit 257dae7

Please sign in to comment.