Loading .vscode/settings.json +1 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ "docloader", "eddsa", "fedi", "fedibird", "fedify", "fediverse", "followable", Loading CHANGES.md +16 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,22 @@ To be released. - Added `ActorCallbackSetters.mapHandle()` method. - Added `ActorHandleMapper` type. - Added `quoteUrl` property to `Article`, `ChatMessage`, `Note`, and `Question` classes in Activity Vocabulary API. - Added `Article.quoteUrl` property. - `new Article()` constructor now accepts `quoteUrl` option. - `Article.clone()` method now accepts `quoteUrl` option. - Added `ChatMessage.quoteUrl` property. - `new ChatMessage()` constructor now accepts `quoteUrl` option. - `ChatMessage.clone()` method now accepts `quoteUrl` option. - Added `Note.quoteUrl` property. - `new Note()` constructor now accepts `quoteUrl` option. - `Note.clone()` method now accepts `quoteUrl` option. - Added `Question.quoteUrl` property. - `new Question()` constructor now accepts `quoteUrl` option. - `Question.clone()` method now accepts `quoteUrl` option. - Removed `expand` option of `Object.toJsonLd()` method, which was deprecated in version 0.14.0. Use `format: "expand"` option instead. Loading src/codegen/__snapshots__/class.test.ts.snap +6591 −5183 File changed.Preview size limit exceeded, changes collapsed. Show changes src/codegen/codec.ts +42 −10 Original line number Diff line number Diff line Loading @@ -104,22 +104,33 @@ export async function* generateEncoder( ); compactItems.push(item); } if (compactItems.length > 0) { `; if (property.functional || property.container !== "list") { yield ` if (compactItems.length > 1) { result[${JSON.stringify(property.compactName)}] = compactItems; } else if (compactItems.length === 1) { result[${JSON.stringify(property.compactName)}] = compactItems[0]; } result[${JSON.stringify(property.compactName)}] = compactItems.length > 1 ? compactItems : compactItems[0]; `; if (property.functional && property.redundantProperties != null) { for (const prop of property.redundantProperties) { yield ` result[${JSON.stringify(prop.compactName)}] = compactItems.length > 1 ? compactItems : compactItems[0]; `; } } } else { yield ` if (compactItems.length > 0) { result[${JSON.stringify(property.compactName)}] = compactItems; } `; } yield ` } `; } yield ` result["type"] = ${JSON.stringify(type.compactName ?? type.uri)}; Loading Loading @@ -171,7 +182,7 @@ export async function* generateEncoder( yield `; } if (array.length > 0) { values[${JSON.stringify(property.uri)}] = ( const propValue = ( `; if (!property.functional && property.container === "list") { yield `{ "@list": array }`; Loading @@ -180,6 +191,16 @@ export async function* generateEncoder( } yield ` ); values[${JSON.stringify(property.uri)}] = propValue; `; if (property.functional && property.redundantProperties != null) { for (const prop of property.redundantProperties) { yield ` values[${JSON.stringify(prop.uri)}] = propValue; `; } } yield ` } `; } Loading Loading @@ -317,7 +338,18 @@ export async function* generateDecoder( yield await generateField(property, types, "const "); const arrayVariable = `${variable}__array`; yield ` const ${arrayVariable} = values[${JSON.stringify(property.uri)}]; let ${arrayVariable} = values[${JSON.stringify(property.uri)}]; `; if (property.functional && property.redundantProperties != null) { for (const prop of property.redundantProperties) { yield ` if (${arrayVariable} == null || ${arrayVariable}.length < 1) { ${arrayVariable} = values[${JSON.stringify(prop.uri)}]; } `; } } yield ` for ( const v of ${arrayVariable} == null ? [] Loading src/codegen/field.ts +3 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,9 @@ export async function getFieldName( "SHA-1", new TextEncoder().encode(propertyUri), ); return `${prefix}_${encodeBase58(hashedUri)}`; const match = propertyUri.match(/#([A-Za-z0-9_]+)$/); const suffix = match == null ? "" : `_${match[1]}`; return `${prefix}_${encodeBase58(hashedUri)}${suffix}`; } export async function generateField( Loading Loading
.vscode/settings.json +1 −0 Original line number Diff line number Diff line Loading @@ -79,6 +79,7 @@ "docloader", "eddsa", "fedi", "fedibird", "fedify", "fediverse", "followable", Loading
CHANGES.md +16 −0 Original line number Diff line number Diff line Loading @@ -15,6 +15,22 @@ To be released. - Added `ActorCallbackSetters.mapHandle()` method. - Added `ActorHandleMapper` type. - Added `quoteUrl` property to `Article`, `ChatMessage`, `Note`, and `Question` classes in Activity Vocabulary API. - Added `Article.quoteUrl` property. - `new Article()` constructor now accepts `quoteUrl` option. - `Article.clone()` method now accepts `quoteUrl` option. - Added `ChatMessage.quoteUrl` property. - `new ChatMessage()` constructor now accepts `quoteUrl` option. - `ChatMessage.clone()` method now accepts `quoteUrl` option. - Added `Note.quoteUrl` property. - `new Note()` constructor now accepts `quoteUrl` option. - `Note.clone()` method now accepts `quoteUrl` option. - Added `Question.quoteUrl` property. - `new Question()` constructor now accepts `quoteUrl` option. - `Question.clone()` method now accepts `quoteUrl` option. - Removed `expand` option of `Object.toJsonLd()` method, which was deprecated in version 0.14.0. Use `format: "expand"` option instead. Loading
src/codegen/__snapshots__/class.test.ts.snap +6591 −5183 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/codegen/codec.ts +42 −10 Original line number Diff line number Diff line Loading @@ -104,22 +104,33 @@ export async function* generateEncoder( ); compactItems.push(item); } if (compactItems.length > 0) { `; if (property.functional || property.container !== "list") { yield ` if (compactItems.length > 1) { result[${JSON.stringify(property.compactName)}] = compactItems; } else if (compactItems.length === 1) { result[${JSON.stringify(property.compactName)}] = compactItems[0]; } result[${JSON.stringify(property.compactName)}] = compactItems.length > 1 ? compactItems : compactItems[0]; `; if (property.functional && property.redundantProperties != null) { for (const prop of property.redundantProperties) { yield ` result[${JSON.stringify(prop.compactName)}] = compactItems.length > 1 ? compactItems : compactItems[0]; `; } } } else { yield ` if (compactItems.length > 0) { result[${JSON.stringify(property.compactName)}] = compactItems; } `; } yield ` } `; } yield ` result["type"] = ${JSON.stringify(type.compactName ?? type.uri)}; Loading Loading @@ -171,7 +182,7 @@ export async function* generateEncoder( yield `; } if (array.length > 0) { values[${JSON.stringify(property.uri)}] = ( const propValue = ( `; if (!property.functional && property.container === "list") { yield `{ "@list": array }`; Loading @@ -180,6 +191,16 @@ export async function* generateEncoder( } yield ` ); values[${JSON.stringify(property.uri)}] = propValue; `; if (property.functional && property.redundantProperties != null) { for (const prop of property.redundantProperties) { yield ` values[${JSON.stringify(prop.uri)}] = propValue; `; } } yield ` } `; } Loading Loading @@ -317,7 +338,18 @@ export async function* generateDecoder( yield await generateField(property, types, "const "); const arrayVariable = `${variable}__array`; yield ` const ${arrayVariable} = values[${JSON.stringify(property.uri)}]; let ${arrayVariable} = values[${JSON.stringify(property.uri)}]; `; if (property.functional && property.redundantProperties != null) { for (const prop of property.redundantProperties) { yield ` if (${arrayVariable} == null || ${arrayVariable}.length < 1) { ${arrayVariable} = values[${JSON.stringify(prop.uri)}]; } `; } } yield ` for ( const v of ${arrayVariable} == null ? [] Loading
src/codegen/field.ts +3 −1 Original line number Diff line number Diff line Loading @@ -10,7 +10,9 @@ export async function getFieldName( "SHA-1", new TextEncoder().encode(propertyUri), ); return `${prefix}_${encodeBase58(hashedUri)}`; const match = propertyUri.match(/#([A-Za-z0-9_]+)$/); const suffix = match == null ? "" : `_${match[1]}`; return `${prefix}_${encodeBase58(hashedUri)}${suffix}`; } export async function generateField( Loading