* 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( .web_extension(
WebExtension::new( WebExtension::new(
"7f33b723-fb58-4524-8733-dbedc4b7c095", "7f33b723-fb58-4524-8733-dbedc4b7c095",
"abc",
"1.0.0.0", "1.0.0.0",
"developer", "developer",
"Registry", "Registry",

View File

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

View File

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

View File

@ -1,5 +1,6 @@
export class WebExtension { export class WebExtension {
_id: string; _id: string;
_referenceId: string;
_version: string; _version: string;
_store: string; _store: string;
_storeType: string; _storeType: string;
@ -7,8 +8,15 @@ export class WebExtension {
[k: string]: string; [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._id = id;
this._referenceId = referenceId;
this._version = version; this._version = version;
this._store = store; this._store = store;
this._storeType = storeType; this._storeType = storeType;

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.0.201", "version": "0.0.202",
"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>",

View File

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

View File

@ -17209,7 +17209,7 @@ exports[`writer should write webextension 6`] = `
exports[`writer should write webextension 7`] = ` exports[`writer should write webextension 7`] = `
"<?xml version=\\"1.0\\" encoding=\\"UTF-8\\" standalone=\\"yes\\"?> "<?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: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:alternateReferences />
<we:properties> <we:properties>
<we:property name=\\"hello\\" value=\\"&quot;{\\\\&quot;hello\\\\&quot;:\\\\&quot;world\\\\&quot;}&quot;\\" /> <we:property name=\\"hello\\" value=\\"&quot;{\\\\&quot;hello\\\\&quot;:\\\\&quot;world\\\\&quot;}&quot;\\" />

View File

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