npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tutao/licc

v259.241220.0

Published

little interface compiler

Downloads

974

Readme

licc - the little interprocess communications compiler

usage info: type licc --help

output

there are four kinds of json files licc understands. they are distinguished by their top-level type property.

structs

"type": "struct" definitions are simply generated into the output directory as a single source file of the platform-appropriate language.

enums

"type": "enum" definitions are generated similarly to structs

facades

"type": "facade" definitions can lead to several output files, depending on the definitions senders and receivers fields:

  • senders and receivers: the interface containing all methods
  • senders: one implementation of the interface in form of the SendDispatcher. It takes a transport instance that does the actual sending of the message and must be implemented manually.
  • receivers: one ReceiveDispatcher. It takes the actual, working implementation of the interface during construction and dispatches to it.
  • additionally, every platform that is on the receiving side of any facades gets one GlobalDispatcher implementation that dispatches to all receive dispatchers.

this leads to the following flow, with manually implemented components marked with *:

SENDING SIDE: *caller* => SendDispatcher => *outgoing transport*
RECEIVING SIDE: *incoming transport* => GlobalDispatcher => ReceiveDispatcher => *facade implementation*

Dispatch is achieved via string identifiers; the incoming transport will call GlobalDispatcher.dispatch("FacadeName", "methodName", arrayOfArgs) which calls the ReceiveDispatcher for FacadeName with ReceiveDispatcher.dispatch("methodName", arrayOfArgs). This call will be dispatched to the appropriate method as facadeName.methodName(arrayOfArgs[0], ..., arrayOfArgs[-1]).

typerefs

"type": "typeref" definitions are used to refer to types that are not defined in a definition file and are not primitives (that the generator therefore has no knowledge of). They have to contain a language-specific path to a definition of the type that the generator will generate a reexport for, which can then be referred to by the facades (which don't actually know the difference between a generated struct and such a reexport).

definition syntax

the schema format is described in lib/common.ts. each schema is a JSON5 file with a single data type or facade definition. as discussed above, the type (struct, enum, facade or typeref) is given by the type property of the contained json5 object. facades must have a senders and a receivers property listing the appropriate platforms.

Note: there is minimal validation. we don't detect duplicate method or argument definitions and do not do a very good job to validate type syntax.

structs

struct fields are given as an object with "fieldName": "fieldType" properties.

{
	name: "Foo",
	type: "struct",
	doc: "optional doc comment that explains the type's purpose",
	fields: {
		fieldName: "fieldType",
		...
	}
}

enums

{
	name: "QuuxEnum",
	type: "enum",
	doc: "optional doc comment that explains the type's purpose",
	values: [
		"Value1",
		"Value2",
		...
	]
}

facades

{
	name: "BarFacade",
	type: "facade",
	senders: [
		"web"
	],
	receivers: [
		"desktop",
		"ios"
	],
	doc: "optional doc comment explaining the scope of the facade",
	methods: {
		"methodName": {
			doc: "optional comment explaining the contract and purpose of the method",
			arg: [
				{
					argName1: "argType1"
				},
				{
					argName2: "argType2"
				},
				...
			],
			ret: "returnType"
		},
		...
	}
}

Note: method arg must be given as a list of single-property objects as above to preserve argument order.

typerefs

{
	name: "BazType",
	type: "typeref",
	location: {
		typescript: "../../src/somedir/BazType.js",
		kotlin: "de.tutao.tutanota.BazType"
	}
}

Note the .js extension on the typescript reference. Reference paths are resolved relative to the json file containing the typeref.

supported types:

  • nullable types, denoted with a ? suffix: string?
  • List<elementType>
  • Map<keyType, valueType>
  • the primitives listed in dist/parser.ts
  • "external" types (the ones that don't fit any of the above but are otherwise valid identifiers)
  • any combination of these

all type names must be valid identifiers in all supported output languages.

Known issues

  • the bytes primitive types is generating DataWrapper types for mobile, because we can't directly send byte arrays over the bridge and need some kind of marker that distinguishes plain strings from encoded byte arrays. Currently, this requirement to wrap byte arrays leaks out to consumers of the generated classes.
  • struct definitions are generated for every language regardless if they're mentioned in that languages' generated files.
  • it's theoretically possible two separate compilations of the same source files to yield different output because field order in json objects is not defined. this was not observed yet and is unlikely to become a problem.