* fix:

* 0.0.202
main
bokuweb 2021-07-09 13:04:48 +09:00 committed by GitHub
parent 6c9b7a1c38
commit cf52509dc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 8 deletions

View File

@ -8,6 +8,7 @@ pub fn main() -> Result<(), DocxError> {
.web_extension(
WebExtension::new(
"7f33b723-fb58-4524-8733-dbedc4b7c095",
"abc",
"1.0.0.0",
"developer",
"Registry",

View File

@ -25,18 +25,21 @@ pub struct WebExtension {
pub version: String,
pub store: String,
pub store_type: String,
pub reference_id: String,
pub properties: Vec<WebExtensionProperty>,
}
impl WebExtension {
pub fn new(
id: impl Into<String>,
reference_id: impl Into<String>,
version: impl Into<String>,
store: impl Into<String>,
store_type: impl Into<String>,
) -> Self {
Self {
id: id.into(),
reference_id: reference_id.into(),
version: version.into(),
store: store.into(),
store_type: store_type.into(),
@ -47,8 +50,7 @@ impl WebExtension {
pub fn property(mut self, name: impl Into<String>, value: impl Into<String>) -> Self {
let v = value.into();
let v = format!("&quot;{}&quot;", escape(&v).replace("&quot;", "\\&quot;"));
self.properties
.push(WebExtensionProperty::new(name, &v));
self.properties.push(WebExtensionProperty::new(name, &v));
self
}
}
@ -62,7 +64,12 @@ impl BuildXML for WebExtension {
"http://schemas.microsoft.com/office/webextensions/webextension/2010/11",
&format!("{{{}}}", &self.id),
)
.webextension_reference(&self.id, &self.version, &self.store, &self.store_type)
.webextension_reference(
&self.reference_id,
&self.version,
&self.store,
&self.store_type,
)
.webextension_alternate_references()
.open_webextension_properties();
@ -92,6 +99,7 @@ mod tests {
fn test_build() {
let c = WebExtension::new(
"7f33b723-fb58-4524-8733-dbedc4b7c095",
"abcd",
"1.0.0.0",
"developer",
"Registry",
@ -102,7 +110,7 @@ mod tests {
str::from_utf8(&b).unwrap(),
r#"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<we:webextension xmlns:we="http://schemas.microsoft.com/office/webextensions/webextension/2010/11" id="{7f33b723-fb58-4524-8733-dbedc4b7c095}">
<we:reference id="7f33b723-fb58-4524-8733-dbedc4b7c095" version="1.0.0.0" store="developer" storeType="Registry" />
<we:reference id="abcd" version="1.0.0.0" store="developer" storeType="Registry" />
<we:alternateReferences />
<we:properties>
<we:property name="hello" value="&quot;world&quot;" />

View File

@ -877,6 +877,7 @@ export class Docx {
for (const e of this.webextensions) {
let ext = wasm.createWebExtension(
e._id,
e._referenceId,
e._version,
e._store,
e._storeType

View File

@ -1,5 +1,6 @@
export class WebExtension {
_id: string;
_referenceId: string;
_version: string;
_store: string;
_storeType: string;
@ -7,8 +8,15 @@ export class WebExtension {
[k: string]: string;
} = {};
constructor(id: string, version: string, store: string, storeType: string) {
constructor(
id: string,
referenceId: string,
version: string,
store: string,
storeType: string
) {
this._id = id;
this._referenceId = referenceId;
this._version = version;
this._store = store;
this._storeType = storeType;

View File

@ -1,6 +1,6 @@
{
"name": "docx-wasm",
"version": "0.0.201",
"version": "0.0.202",
"main": "dist/node/index.js",
"browser": "dist/web/index.js",
"author": "bokuweb <bokuweb12@gmail.com>",

View File

@ -7,11 +7,18 @@ pub struct WebExtension(docx_rs::WebExtension);
#[wasm_bindgen(js_name = createWebExtension)]
pub fn create_web_extension(
id: &str,
reference_id: &str,
version: &str,
store: &str,
store_type: &str,
) -> WebExtension {
WebExtension(docx_rs::WebExtension::new(id, version, store, store_type))
WebExtension(docx_rs::WebExtension::new(
id,
reference_id,
version,
store,
store_type,
))
}
impl WebExtension {

View File

@ -17209,7 +17209,7 @@ exports[`writer should write webextension 6`] = `
exports[`writer should write webextension 7`] = `
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?>
<we:webextension xmlns:we=\\"http://schemas.microsoft.com/office/webextensions/webextension/2010/11\\" id=\\"{7f33b723-fb58-4524-8733-dbedc4b7c095}\\">
<we:reference id=\\"7f33b723-fb58-4524-8733-dbedc4b7c095\\" version=\\"1.0.0.0\\" store=\\"developer\\" storeType=\\"Registry\\" />
<we:reference id=\\"abcd\\" version=\\"1.0.0.0\\" store=\\"developer\\" storeType=\\"Registry\\" />
<we:alternateReferences />
<we:properties>
<we:property name=\\"hello\\" value=\\"&quot;{\\\\&quot;hello\\\\&quot;:\\\\&quot;world\\\\&quot;}&quot;\\" />

View File

@ -303,6 +303,7 @@ describe("writer", () => {
.webextension(
new w.WebExtension(
"7f33b723-fb58-4524-8733-dbedc4b7c095",
"abcd",
"1.0.0.0",
"developer",
"Registry"