@ungap/esxtoken
TypeScript icon, indicating that this package has built-in type declarations

0.4.2 • Public • Published

ESXToken

EXPERIMENTAL THIS PROJECT IS BROKEN AND UNDER HEAVY REFACTORING - FEEL FREE TO PLAY WITH IT BUT DON'T USE IT IN PRODUCTION

The latest ESXToken polyfill as discussed in TC39.


v0.3 Note differently from @ungap/esx components, elements, or fragments, are unique only if these are outer ESX templates. Repeated updates will always change their attributes or children, if actually changed, but the only unique reference that matters is the outer one, which can always be weakly related and mapped accordingly.


While the poly is extremely fine-tuned for terseness, performance, and its current Babel transformer, the abstract representation of the proposal is the following one:

class ESXToken {
  static ATTRIBUTE: number;
  static INTERPOLATION: number;
  static STATIC: number;
  static FRAGMENT: number;
  static ELEMENT: number;
  static COMPONENT: number;
}

interface ESXAttribute {
  type = ESXToken.ATTRIBUTE;
  dynamic: boolean;
  name: string;
  value: unknown;
}

interface ESXInterpolation {
  type = ESXToken.INTERPOLATION;
  value: unknown;
}

interface ESXStatic {
  type = ESXToken.STATIC;
  value: string;
}

interface ESXNode extends ESXToken {
  id: null | object;
  children: (ESXStatic | ESXInterpolation | ESXNode)[];
  get properties(): object?;
}

class ESXFragment extends ESXNode {
  type = ESXToken.FRAGMENT;
}

class ESXElement extends ESXNode {
  type = ESXToken.ELEMENT;
  name: string;
  value: string;
  attributes: (ESXAttribute | ESXInterpolation)[];
}

class ESXComponent extends ESXNode {
  type = ESXToken.COMPONENT;
  name: string;
  value: function;
  attributes: (ESXAttribute | ESXInterpolation)[];
}

Readme

Keywords

Package Sidebar

Install

npm i @ungap/esxtoken

Weekly Downloads

48

Version

0.4.2

License

ISC

Unpacked Size

5.18 kB

Total Files

6

Last publish

Collaborators

  • webreflection