Skip to content

Commit 72496b6

Browse files
committed
feat(editor): add upload career, mod icons
1 parent 6c8fcf1 commit 72496b6

41 files changed

Lines changed: 1207 additions & 5 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
7+
gulp.task("publish_local_env_bundle", function (done) {
8+
let filePath = "./src/Main.ts"
9+
10+
publish.publishBundledContribute(
11+
"local",
12+
path.join(__dirname, "package.json"),
13+
bundle.bundle(
14+
bundle.getLocalModulePath(
15+
filePath
16+
),
17+
fs.readFileSync(filePath, "utf-8")
18+
)
19+
).then(() => {
20+
done()
21+
})
22+
});
23+
24+
gulp.task("publish_production_env_bundle", function (done) {
25+
let filePath = "./src/Main.ts"
26+
27+
publish.publishBundledContribute(
28+
"production",
29+
path.join(__dirname, "package.json"),
30+
bundle.bundle(
31+
bundle.getLocalModulePath(
32+
filePath
33+
),
34+
fs.readFileSync(filePath, "utf-8")
35+
)
36+
).then(() => {
37+
done()
38+
})
39+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "meta3d-action-mod-career-load-careerpreview",
3+
"version": "1.3.1",
4+
"publisher": "meta3d",
5+
"repoLink": "",
6+
"protocol": {
7+
"name": "meta3d-action-mod-career-load-careerpreview-protocol"
8+
},
9+
"license": "MIT",
10+
"scripts": {
11+
"watch": "tsc -w -noEmit",
12+
"webpack": "webpack --config webpack.config.js",
13+
"meta3d:publish_dev_auto": "yarn version --patch --no-git-tag-version && yarn meta3d:publish_dev",
14+
"meta3d:publish_dev": "cross-env NODE_ENV=development npm run webpack && gulp publish_local_env_bundle",
15+
"meta3d:publish_pro": "cross-env NODE_ENV=production npm run webpack && gulp publish_production_env_bundle"
16+
},
17+
"keywords": [],
18+
"dependencies": {
19+
"meta3d-action-mod-career-load-careerpreview-protocol": "^1.3.0",
20+
"meta3d-editor-whole-protocol": "^1.3.0",
21+
"meta3d-type": "^1.3.0"
22+
},
23+
"devDependencies": {
24+
"clean-webpack-plugin": "^4.0.0",
25+
"cross-env": "^7.0.3",
26+
"cz-customizable": "^6.3.0",
27+
"gulp": "^4.0.2",
28+
"meta3d-tool-publish": "^1.3.0",
29+
"source-map-loader": "^3.0.0",
30+
"ts-loader": "^9.2.6",
31+
"typescript": "^5.1.0",
32+
"webpack": "^5.62.1",
33+
"webpack-cli": "^4.9.1"
34+
}
35+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { state as meta3dState, getContribute as getContributeMeta3D, api } from "meta3d-type"
2+
import { actionContribute, service as editorWholeService } from "meta3d-editor-whole-protocol/src/service/ServiceType"
3+
import { actionName, state, uiData } from "meta3d-action-mod-career-load-careerpreview-protocol"
4+
import { eventName, inputData, imageBase64 } from "meta3d-action-mod-career-load-careerpreview-protocol/src/EventType"
5+
import { importImage } from "meta3d-file-ts-utils/src/ImportFileUtils"
6+
7+
export let getContribute: getContributeMeta3D<actionContribute<uiData, 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, imageBase64) => {
15+
let state = api.nullable.getExn(api.action.getActionState<state>(meta3dState, actionName))
16+
meta3dState = api.action.setActionState(meta3dState, actionName, {
17+
...state,
18+
preview: api.nullable.return(imageBase64)
19+
})
20+
21+
return Promise.resolve(meta3dState)
22+
}, (meta3dState) => {
23+
return Promise.resolve(meta3dState)
24+
}))
25+
})
26+
},
27+
handler: (meta3dState, uiData) => {
28+
return new Promise<meta3dState>((resolve, reject) => {
29+
let eventSourcingService = api.nullable.getExn(api.getPackageService<editorWholeService>(meta3dState, "meta3d-editor-whole-protocol")).event(meta3dState).eventSourcing(meta3dState)
30+
31+
importImage((image: any, result: any) => {
32+
if (!(image.name.includes(".png") || image.name.includes(".jpg") || image.name.includes(".jpeg"))) {
33+
reject(new Error("文件后缀名应该是.png或者.jpg或者.jpeg"))
34+
}
35+
36+
resolve(eventSourcingService.addEvent<inputData>(meta3dState, {
37+
name: eventName,
38+
isOnlyRead: true,
39+
inputData: [result as imageBase64]
40+
}))
41+
}, (event: Event, image: any) => {
42+
reject(new Error(`读取${image.name}错误`))
43+
}, (loaded: number, total: number) => {
44+
// TODO show progress message
45+
console.log(`loading ${loaded / total} %`)
46+
}, () => {
47+
resolve(meta3dState)
48+
})
49+
})
50+
},
51+
createState: (meta3dState) => {
52+
return {
53+
preview: null
54+
}
55+
}
56+
}
57+
}
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+
};
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: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
7+
gulp.task("publish_local_env_bundle", function (done) {
8+
let filePath = "./src/Main.ts"
9+
10+
publish.publishBundledContribute(
11+
"local",
12+
path.join(__dirname, "package.json"),
13+
bundle.bundle(
14+
bundle.getLocalModulePath(
15+
filePath
16+
),
17+
fs.readFileSync(filePath, "utf-8")
18+
)
19+
).then(() => {
20+
done()
21+
})
22+
});
23+
24+
gulp.task("publish_production_env_bundle", function (done) {
25+
let filePath = "./src/Main.ts"
26+
27+
publish.publishBundledContribute(
28+
"production",
29+
path.join(__dirname, "package.json"),
30+
bundle.bundle(
31+
bundle.getLocalModulePath(
32+
filePath
33+
),
34+
fs.readFileSync(filePath, "utf-8")
35+
)
36+
).then(() => {
37+
done()
38+
})
39+
});
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "meta3d-action-mod-career-load-modpreview",
3+
"version": "1.3.1",
4+
"publisher": "meta3d",
5+
"repoLink": "",
6+
"protocol": {
7+
"name": "meta3d-action-mod-career-load-modpreview-protocol"
8+
},
9+
"license": "MIT",
10+
"scripts": {
11+
"watch": "tsc -w -noEmit",
12+
"webpack": "webpack --config webpack.config.js",
13+
"meta3d:publish_dev_auto": "yarn version --patch --no-git-tag-version && yarn meta3d:publish_dev",
14+
"meta3d:publish_dev": "cross-env NODE_ENV=development npm run webpack && gulp publish_local_env_bundle",
15+
"meta3d:publish_pro": "cross-env NODE_ENV=production npm run webpack && gulp publish_production_env_bundle"
16+
},
17+
"keywords": [],
18+
"dependencies": {
19+
"meta3d-action-mod-career-load-modpreview-protocol": "^1.3.0",
20+
"meta3d-editor-whole-protocol": "^1.3.0",
21+
"meta3d-type": "^1.3.0"
22+
},
23+
"devDependencies": {
24+
"clean-webpack-plugin": "^4.0.0",
25+
"cross-env": "^7.0.3",
26+
"cz-customizable": "^6.3.0",
27+
"gulp": "^4.0.2",
28+
"meta3d-tool-publish": "^1.3.0",
29+
"source-map-loader": "^3.0.0",
30+
"ts-loader": "^9.2.6",
31+
"typescript": "^5.1.0",
32+
"webpack": "^5.62.1",
33+
"webpack-cli": "^4.9.1"
34+
}
35+
}

0 commit comments

Comments
 (0)