gen bindings (#427)

* gen bindings

* fix: build

* fix

* 0.0.239

* 0.0.240
main
bokuweb 2022-01-28 15:36:03 +09:00 committed by GitHub
parent 0ea06da94c
commit 26e2f2f169
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 89 additions and 6 deletions

1
.gitignore vendored
View File

@ -16,5 +16,6 @@ vrt/report.html
reg.json reg.json
docx-core/tests/output/*.docx docx-core/tests/output/*.docx
docx-wasm/*.tgz docx-wasm/*.tgz
docx-core/bindings
docx-core/tests/output/*.json docx-core/tests/output/*.json
test.json test.json

48
Cargo.lock generated
View File

@ -2,6 +2,12 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "Inflector"
version = "0.11.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3"
[[package]] [[package]]
name = "adler" name = "adler"
version = "0.2.3" version = "0.2.3"
@ -176,6 +182,7 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"thiserror", "thiserror",
"ts-rs",
"wasm-bindgen", "wasm-bindgen",
"xml-rs", "xml-rs",
"zip", "zip",
@ -563,6 +570,15 @@ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]]
name = "termcolor"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "terminal_size" name = "terminal_size"
version = "0.1.16" version = "0.1.16"
@ -604,6 +620,29 @@ dependencies = [
"weezl", "weezl",
] ]
[[package]]
name = "ts-rs"
version = "6.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df082879c2ca6521d54bedd7d6d2e9407b7d457dede64415f1739d3a44a19b05"
dependencies = [
"thiserror",
"ts-rs-macros",
]
[[package]]
name = "ts-rs-macros"
version = "6.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f402688b565efbe1a0ffb296e201c12f1986fd02eba37f4dc62c13098a6218c1"
dependencies = [
"Inflector",
"proc-macro2",
"quote",
"syn",
"termcolor",
]
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.0" version = "0.2.0"
@ -686,6 +725,15 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-util"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "winapi-x86_64-pc-windows-gnu" name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0" version = "0.4.0"

View File

@ -27,6 +27,7 @@ zip = { version = "0.5.6", default-features = false, features = ["deflate"] }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
image = "0.23.14" image = "0.23.14"
ts-rs = "6.1"
[dev-dependencies] [dev-dependencies]
pretty_assertions = "1.0.0" pretty_assertions = "1.0.0"

View File

@ -0,0 +1,3 @@
import type { FontSchemeFont } from "./FontSchemeFont";
export interface FontGroup { latin: string, ea: string, cs: string, fonts: Array<FontSchemeFont>, }

View File

@ -0,0 +1,3 @@
import type { FontGroup } from "./FontGroup";
export interface FontScheme { majorFont: FontGroup, minorFont: FontGroup, }

View File

@ -0,0 +1,2 @@
export interface FontSchemeFont { script: string, typeface: string, }

View File

@ -0,0 +1,3 @@
import type { FontScheme } from "./FontScheme";
export interface Theme { fontSchema: FontScheme, }

View File

@ -1,13 +1,15 @@
use serde::Serialize; use serde::Serialize;
#[derive(Debug, Clone, PartialEq, Serialize)] #[derive(Debug, Clone, PartialEq, Serialize, ts_rs::TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct FontSchemeFont { pub struct FontSchemeFont {
pub script: String, pub script: String,
pub typeface: String, pub typeface: String,
} }
#[derive(Debug, Clone, PartialEq, Serialize, Default)] #[derive(Debug, Clone, PartialEq, Serialize, Default, ts_rs::TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct FontGroup { pub struct FontGroup {
pub latin: String, pub latin: String,
@ -16,7 +18,8 @@ pub struct FontGroup {
pub fonts: Vec<FontSchemeFont>, pub fonts: Vec<FontSchemeFont>,
} }
#[derive(Debug, Clone, PartialEq, Serialize, Default)] #[derive(Debug, Clone, PartialEq, Serialize, Default, ts_rs::TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct FontScheme { pub struct FontScheme {
pub major_font: FontGroup, pub major_font: FontGroup,

View File

@ -2,7 +2,8 @@ use serde::Serialize;
use super::*; use super::*;
#[derive(Debug, Clone, PartialEq, Serialize, Default)] #[derive(Debug, Clone, PartialEq, Serialize, Default, ts_rs::TS)]
#[ts(export)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Theme { pub struct Theme {
pub font_schema: FontScheme, pub font_schema: FontScheme,

View File

@ -0,0 +1,3 @@
import type { FontSchemeFont } from "./FontSchemeFont";
export interface FontGroup { latin: string, ea: string, cs: string, fonts: Array<FontSchemeFont>, }

View File

@ -0,0 +1,3 @@
import type { FontGroup } from "./FontGroup";
export interface FontScheme { majorFont: FontGroup, minorFont: FontGroup, }

View File

@ -0,0 +1,2 @@
export interface FontSchemeFont { script: string, typeface: string, }

View File

@ -0,0 +1,3 @@
import type { FontScheme } from "./FontScheme";
export interface Theme { fontSchema: FontScheme, }

View File

@ -4,6 +4,8 @@ import { NumberingsJSON } from "./numbering";
import { CommentJSON } from "./comment"; import { CommentJSON } from "./comment";
import { WebSettingsJSON } from "./web-settings"; import { WebSettingsJSON } from "./web-settings";
import { Theme as ThemeJSON } from "./bindings/Theme";
export type DocxJSON = { export type DocxJSON = {
contentType: { contentType: {
types: { types: {
@ -44,6 +46,7 @@ export type DocxJSON = {
settings: SettingsJSON; settings: SettingsJSON;
webSettings: WebSettingsJSON; webSettings: WebSettingsJSON;
fontTable: {}; fontTable: {};
themes: ThemeJSON[];
}; };
export type SettingsJSON = { export type SettingsJSON = {
@ -67,3 +70,5 @@ export * from "./web-settings";
export * from "./comment"; export * from "./comment";
export * from "./textbox-content"; export * from "./textbox-content";
export * from "./section-property"; export * from "./section-property";
export { ThemeJSON };

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.0.235", "version": "0.0.240",
"main": "dist/node/index.js", "main": "dist/node/index.js",
"browser": "dist/web/index.js", "browser": "dist/web/index.js",
"author": "bokuweb <bokuweb12@gmail.com>", "author": "bokuweb <bokuweb12@gmail.com>",
@ -14,9 +14,11 @@
"tsc:node": "tsc -p tsconfig.node.json", "tsc:node": "tsc -p tsconfig.node.json",
"tsc": "run-s tsc:*", "tsc": "run-s tsc:*",
"test": "npm run build && tsc && jest", "test": "npm run build && tsc && jest",
"build": "run-s wasm-pack tsc", "build": "run-s tsrs copy:bindings wasm-pack tsc",
"serve": "webpack-dev-server --open --config webpack.dev.js", "serve": "webpack-dev-server --open --config webpack.dev.js",
"copy": "cpy 'dist/node/pkg/package.json' 'dist/web/pkg'", "copy": "cpy 'dist/node/pkg/package.json' 'dist/web/pkg'",
"tsrs": "cd ../ && make test",
"copy:bindings": "cpy '../docx-core/bindings' './js/json/bindings'",
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"resolutions": { "resolutions": {