favicons icon indicating copy to clipboard operation
favicons copied to clipboard

HTML Object Return - Add option to return html un-stringified (for use in libraries/plugins)

Open josh-hemphill opened this issue 1 year ago • 3 comments

closes #442 In other libraries/plugins, it's necessary to separately apply tag data and/or add their own, while still mostly following what favicons supplies.

It took more modification than I'd like to get all the types to return based on the options, but I seem to have got it right, all the tests pass (even made sure the tag order is the same so the snapshots pass), and the return types behave as I'd expect.

josh-hemphill avatar Oct 29 '23 12:10 josh-hemphill

Other option would be to expand FaviconResponse and add one more field.

export interface FaviconResponse {
  readonly images: FaviconImage[];
  readonly files: FaviconFile[];
  readonly html: FaviconHtmlElement[]; // string[]
  readonly htmlTags: FaviconHtmlTag[];
}

Then use htmlTags internally and convert htmlTags to html before a return. wdyt?

andy128k avatar Oct 29 '23 15:10 andy128k

That's kind of what I have it doing. But the different return type means that if you're using the un-stringified return, the stringification doesn't even have to run. Yeah, I guess it does mean not having the complex generic types, but at the cost of a little more having to run at runtime. I'll go ahead and make the change.

josh-hemphill avatar Oct 29 '23 18:10 josh-hemphill

Okay, the additional return did simplify things. Had to update most of the snapshots for the tests.

josh-hemphill avatar Oct 29 '23 19:10 josh-hemphill