Skip to content

Commit dd4a6d4

Browse files
committed
feat: add mode-jumptolink action
1 parent 338af9d commit dd4a6d4

15 files changed

Lines changed: 352 additions & 2 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DS_Store
2+
.merlin
3+
.log
4+
.ninja_log
5+
.cmi
6+
.ast
7+
.cmt
8+
.bsdeps
9+
.compiler.log
10+
11+
.idea/
12+
.vscode/
13+
jest_0/
14+
reference/
15+
node_modules/
16+
mine/
17+
dist/
18+
lib/bs/
19+
.bs.js
20+
.gen.tsx
21+
lib/js/
22+
lib/es6_global/
23+
24+
coverage
25+
26+
dist/
27+
28+
npm-debug
29+
30+
.bsb.lock
31+
32+
yarn.lock
33+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
var gulp = require("gulp");
2+
var path = require("path");
3+
var fs = require("fs");
4+
var publish = require("meta3d-tool-publish")
5+
var bundle = require("meta3d-tool-bundle-to-custom")
6+
var clipboard = require('clipboardy')
7+
8+
gulp.task("publish_local_env_bundle", function (done) {
9+
let filePath = "./src/Main.ts"
10+
11+
let bundleContent = bundle.bundle(
12+
bundle.getLocalModulePath(
13+
filePath
14+
),
15+
fs.readFileSync(filePath, "utf-8")
16+
)
17+
18+
let clipedBundleContent = `import { api } from "meta3d-type"
19+
import { service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
20+
` + bundleContent
21+
clipedBundleContent = clipedBundleContent.replace(/getContribute\s\=\s\(api\)/g, "getContribute = (api:api)")
22+
23+
clipboard.default.writeSync(
24+
clipedBundleContent
25+
)
26+
27+
28+
29+
publish.publishBundledContribute(
30+
"local",
31+
path.join(__dirname, "package.json"),
32+
bundleContent
33+
).then(() => {
34+
done()
35+
})
36+
});
37+
38+
39+
40+
// gulp.task("publish_local_env", function (done) {
41+
// publish.publishContribute(
42+
// "local",
43+
// path.join(__dirname, "package.json"),
44+
// path.join(__dirname, "dist/static/js", "main.js")
45+
// ).then(() => {
46+
// done()
47+
// })
48+
// });
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "meta3d-action-mod-jumptolink",
3+
"version": "1.3.1",
4+
"publisher": "meta3d",
5+
"protocol": {
6+
"name": "meta3d-action-mod-jumptolink-protocol"
7+
},
8+
"license": "MIT",
9+
"scripts": {
10+
"watch": "tsc -w -noEmit",
11+
"webpack": "webpack --config webpack.config.js",
12+
"meta3d:publish_dev_auto": "yarn version --patch --no-git-tag-version && yarn meta3d:publish_dev",
13+
"meta3d:publish_dev": "cross-env NODE_ENV=development npm run webpack && gulp publish_local_env_bundle",
14+
"meta3d:publish_pro": "cross-env NODE_ENV=production npm run webpack && gulp publish_production_env_bundle"
15+
},
16+
"keywords": [],
17+
"dependencies": {
18+
"meta3d-action-mod-jumptolink-protocol": "^1.3.0",
19+
"meta3d-editor-whole-protocol": "^1.3.0",
20+
"meta3d-type": "^1.3.0"
21+
},
22+
"devDependencies": {
23+
"clean-webpack-plugin": "^4.0.0",
24+
"cross-env": "^7.0.3",
25+
"cz-customizable": "^6.3.0",
26+
"gulp": "^4.0.2",
27+
"meta3d-tool-publish": "^1.3.0",
28+
"source-map-loader": "^3.0.0",
29+
"ts-loader": "^9.2.6",
30+
"typescript": "^5.1.0",
31+
"webpack": "^5.62.1",
32+
"webpack-cli": "^4.9.1"
33+
}
34+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { state as meta3dState, getContribute as getContributeMeta3D, api } from "meta3d-type"
2+
import { actionName, state } from "meta3d-action-mod-jumptolink-protocol"
3+
import { eventName, inputData } from "meta3d-action-mod-jumptolink-protocol/src/EventType"
4+
import { actionContribute, service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
5+
import { isChinese } from "meta3d-language-utils/src/Main"
6+
7+
export let getContribute: getContributeMeta3D<actionContribute<null, state>> = (api) => {
8+
return {
9+
actionName: actionName,
10+
init: (meta3dState) => {
11+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
12+
13+
return new Promise((resolve, reject) => {
14+
resolve(eventSourcingService.on<inputData>(meta3dState, eventName, 0, (meta3dState, [chineseLink, englishLink]) => {
15+
window.open(`${isChinese(api, meta3dState) ? chineseLink : englishLink}`, "_blank")
16+
17+
return Promise.resolve(meta3dState)
18+
}, (meta3dState) => {
19+
return Promise.resolve(meta3dState)
20+
}))
21+
})
22+
},
23+
handler: (meta3dState, uiData, actionParams) => {
24+
return new Promise<meta3dState>((resolve, reject) => {
25+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
26+
27+
resolve(eventSourcingService.addEvent<inputData>(meta3dState, {
28+
name: eventName,
29+
isOnlyRead: true,
30+
inputData: [actionParams]
31+
}))
32+
})
33+
34+
},
35+
createState: () => null
36+
}
37+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES6",
4+
"module": "ES6",
5+
"moduleResolution": "node",
6+
"sourceMap": true,
7+
"resolveJsonModule": true,
8+
"esModuleInterop": true,
9+
"jsx": "react",
10+
// "noEmit": true,
11+
// "noUnusedLocals": true,
12+
// "noUnusedParameters": true,
13+
"noImplicitReturns": true,
14+
"lib": [
15+
"DOM",
16+
"ESNext",
17+
],
18+
"types": [],
19+
// "strict": true
20+
},
21+
"include": [
22+
"./src"
23+
]
24+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
const path = require('path');
2+
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
3+
4+
module.exports = {
5+
entry: "./src/Main.ts",
6+
mode: process.env.NODE_ENV.trim() == 'production' ? 'production' : 'development',
7+
output: {
8+
path: path.resolve(__dirname, 'dist'),
9+
filename: 'static/js/[name].js',
10+
library: {
11+
name: 'Contribute',
12+
type: 'window',
13+
},
14+
},
15+
16+
// Enable sourcemaps for debugging webpack's output.
17+
// devtool: "source-map",
18+
19+
resolve: {
20+
extensions: ['.ts', '.tsx', '.js', '.jsx', '.scss'],
21+
modules: ['node_modules']
22+
},
23+
24+
module: {
25+
rules: [
26+
// All files with a '.ts' or '.tsx' extension will be handled by 'awesome-typescript-loader'.
27+
{
28+
test: /\.tsx?$/,
29+
exclude: /node_modules/,
30+
use: "ts-loader"
31+
},
32+
// All output '.js' files will have any sourcemaps re-processed by 'source-map-loader'.
33+
{
34+
enforce: 'pre',
35+
test: /\.js$/,
36+
loader: "source-map-loader"
37+
},
38+
]
39+
},
40+
plugins: [
41+
/**
42+
* All files inside webpack's output.path directory will be removed once, but the
43+
* directory itself will not be. If using webpack 4+'s default configuration,
44+
* everything under <PROJECT_DIR>/dist/ will be removed.
45+
* Use cleanOnceBeforeBuildPatterns to override this behavior.
46+
*
47+
* During rebuilds, all webpack assets that are not used anymore
48+
* will be removed automatically.
49+
*
50+
* See `Options and Defaults` for information
51+
*/
52+
new CleanWebpackPlugin(),
53+
// new HtmlWebpackPlugin({
54+
// template: './user.html',
55+
// filename: 'user.html',
56+
// }),
57+
],
58+
// When importing a module whose path matches one of the following, just
59+
// assume a corresponding global variable exists and use that instead.
60+
// This is important because it allows us to avoid bundling all of our
61+
// dependencies, which allows browsers to cache those libraries between builds.
62+
externals: {
63+
}
64+
};

doc/1.3.1.org

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3064,9 +3064,9 @@ TODO 去掉背景
30643064
# TODO pubilsh doc to website/doc
30653065

30663066

3067-
** TODO add doc link to editor
3067+
** DONE add doc link to editor
30683068

3069-
TODO add Link ui
3069+
# TODO add Link ui
30703070

30713071
TODO add doc link
30723072
give link judge by language

packages/editor-whole/ui/extensions/meta3d-imgui-webgl1-renderer/src/Main.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,9 @@ export let getExtensionService: getExtensionServiceMeta3D<
540540
textColored: ([r, g, b, a], text) => {
541541
ImGui.TextColored(new ImGui.Vec4(r, g, b, a), text);
542542
},
543+
textLink: (text) => {
544+
ImGui.TextLink(text)
545+
},
543546
inputTextarea: (label, [width, height], maxLength, value) => {
544547
// let buff = new ImGui.StringBuffer(1024 * 16 * Math.ceil(text.length / 1024), text)
545548

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.DS_Store
2+
.merlin
3+
.log
4+
.ninja_log
5+
.cmi
6+
.ast
7+
.cmt
8+
.bsdeps
9+
.compiler.log
10+
11+
.idea/
12+
.vscode/
13+
jest_0/
14+
reference/
15+
node_modules/
16+
mine/
17+
dist/
18+
lib/bs/
19+
.bs.js
20+
.gen.tsx
21+
lib/js/
22+
lib/es6_global/
23+
24+
coverage
25+
26+
dist/
27+
28+
npm-debug
29+
30+
.bsb.lock
31+
32+
yarn.lock
33+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
var gulp = require("gulp");
2+
var path = require("path");
3+
var publish = require("meta3d-tool-publish-protocol")
4+
5+
gulp.task("publish_local_env", function (done) {
6+
publish.publishContributeProtocol(
7+
"local",
8+
path.join(__dirname, "package.json"),
9+
path.join(__dirname, "icon.png")
10+
).then(() => {
11+
done()
12+
})
13+
});
14+
15+
gulp.task("publish_production_env", function (done) {
16+
publish.publishContributeProtocol(
17+
"production",
18+
path.join(__dirname, "package.json"),
19+
path.join(__dirname, "icon.png")
20+
).then(() => {
21+
done()
22+
})
23+
});

0 commit comments

Comments
 (0)