@lipsjs/lips 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +185 -85
  2. package/dist/lips.js +6274 -0
  3. package/dist/lips.js.map +53 -0
  4. package/dist/lips.min.js +13 -2
  5. package/dist/lips.min.js.map +47 -43
  6. package/dist/mf2.min.js +4 -0
  7. package/dist/mf2.min.js.map +38 -0
  8. package/dist/precompile.min.js +23 -0
  9. package/dist/precompile.min.js.map +14 -0
  10. package/dist/runtime.min.js +5 -0
  11. package/dist/runtime.min.js.map +20 -0
  12. package/dist/stylis.min.js +3 -0
  13. package/dist/stylis.min.js.map +16 -0
  14. package/dist/types/events.d.ts +1 -1
  15. package/dist/types/i18n/engine.d.ts +14 -0
  16. package/dist/types/i18n/index.d.ts +122 -5
  17. package/dist/types/i18n/intl.d.ts +1 -0
  18. package/dist/types/i18n/lookup.d.ts +22 -0
  19. package/dist/types/ir/compiler.d.ts +226 -0
  20. package/dist/types/ir/expression.d.ts +149 -0
  21. package/dist/types/ir/facade.d.ts +138 -0
  22. package/dist/types/ir/host.d.ts +75 -0
  23. package/dist/types/ir/index.d.ts +18 -0
  24. package/dist/types/ir/parser.d.ts +124 -0
  25. package/dist/types/ir/policy.d.ts +95 -0
  26. package/dist/types/ir/router.d.ts +47 -0
  27. package/dist/types/ir/runtime.d.ts +130 -0
  28. package/dist/types/ir/signal.d.ts +28 -0
  29. package/dist/types/ir/style.d.ts +119 -0
  30. package/dist/types/ir/swap.d.ts +28 -0
  31. package/dist/types/ir/tree.d.ts +51 -0
  32. package/dist/types/lips.d.ts +33 -37
  33. package/dist/types/lynx/a11y.d.ts +61 -0
  34. package/dist/types/lynx/background.d.ts +71 -0
  35. package/dist/types/lynx/main.d.ts +46 -0
  36. package/dist/types/lynx/protocol.d.ts +52 -0
  37. package/dist/types/lynx/style.d.ts +49 -0
  38. package/dist/types/lynx/template.d.ts +37 -0
  39. package/dist/types/mf2.d.ts +14 -0
  40. package/dist/types/precompile.d.ts +85 -0
  41. package/dist/types/runtime.d.ts +16 -0
  42. package/dist/types/stylesheet.d.ts +21 -41
  43. package/dist/types/stylis.d.ts +2 -0
  44. package/dist/types/types.d.ts +176 -185
  45. package/dist/types/untrusted.d.ts +17 -0
  46. package/dist/untrusted.min.js +5 -0
  47. package/dist/untrusted.min.js.map +13 -0
  48. package/package.json +46 -10
  49. package/dist/test.component.min.js +0 -3
  50. package/dist/test.component.min.js.map +0 -50
  51. package/dist/test.stress.min.js +0 -476
  52. package/dist/test.stress.min.js.map +0 -50
  53. package/dist/types/component.d.ts +0 -107
  54. package/dist/types/constants.d.ts +0 -23
  55. package/dist/types/dws.d.ts +0 -14
  56. package/dist/types/iuc/index.d.ts +0 -25
  57. package/dist/types/iuc/tick.d.ts +0 -38
  58. package/dist/types/iuc.d.ts +0 -25
  59. package/dist/types/metrics.d.ts +0 -50
  60. package/dist/types/preprocess.d.ts +0 -2
  61. package/dist/types/signal.d.ts +0 -30
  62. package/dist/types/syntax/async.d.ts +0 -16
  63. package/dist/types/syntax/for.d.ts +0 -25
  64. package/dist/types/syntax/if.d.ts +0 -14
  65. package/dist/types/syntax/router.d.ts +0 -40
  66. package/dist/types/syntax/switch.d.ts +0 -16
  67. package/dist/types/tick.d.ts +0 -38
  68. package/dist/types/tps.d.ts +0 -11
  69. package/dist/types/uqs.d.ts +0 -37
  70. package/dist/types/utils.d.ts +0 -25
@@ -0,0 +1,16 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../node_modules/stylis/src/Enum.js", "../node_modules/stylis/src/Utility.js", "../node_modules/stylis/src/Tokenizer.js", "../node_modules/stylis/src/Parser.js", "../node_modules/stylis/src/Serializer.js", "../node_modules/stylis/src/Middleware.js", "../src/stylis.ts"],
4
+ "sourcesContent": [
5
+ "export var MS = '-ms-'\nexport var MOZ = '-moz-'\nexport var WEBKIT = '-webkit-'\n\nexport var COMMENT = 'comm'\nexport var RULESET = 'rule'\nexport var DECLARATION = 'decl'\n\nexport var PAGE = '@page'\nexport var MEDIA = '@media'\nexport var IMPORT = '@import'\nexport var CHARSET = '@charset'\nexport var VIEWPORT = '@viewport'\nexport var SUPPORTS = '@supports'\nexport var DOCUMENT = '@document'\nexport var NAMESPACE = '@namespace'\nexport var KEYFRAMES = '@keyframes'\nexport var FONT_FACE = '@font-face'\nexport var COUNTER_STYLE = '@counter-style'\nexport var FONT_FEATURE_VALUES = '@font-feature-values'\nexport var LAYER = '@layer'\nexport var SCOPE = '@scope'\n",
6
+ "/**\n * @param {number}\n * @return {number}\n */\nexport var abs = Math.abs\n\n/**\n * @param {number}\n * @return {string}\n */\nexport var from = String.fromCharCode\n\n/**\n * @param {object}\n * @return {object}\n */\nexport var assign = Object.assign\n\n/**\n * @param {string} value\n * @param {number} length\n * @return {number}\n */\nexport function hash (value, length) {\n\treturn charat(value, 0) ^ 45 ? (((((((length << 2) ^ charat(value, 0)) << 2) ^ charat(value, 1)) << 2) ^ charat(value, 2)) << 2) ^ charat(value, 3) : 0\n}\n\n/**\n * @param {string} value\n * @return {string}\n */\nexport function trim (value) {\n\treturn value.trim()\n}\n\n/**\n * @param {string} value\n * @param {RegExp} pattern\n * @return {string?}\n */\nexport function match (value, pattern) {\n\treturn (value = pattern.exec(value)) ? value[0] : value\n}\n\n/**\n * @param {string} value\n * @param {(string|RegExp)} pattern\n * @param {string} replacement\n * @return {string}\n */\nexport function replace (value, pattern, replacement) {\n\treturn value.replace(pattern, replacement)\n}\n\n/**\n * @param {string} value\n * @param {string} search\n * @param {number} position\n * @return {number}\n */\nexport function indexof (value, search, position) {\n\treturn value.indexOf(search, position)\n}\n\n/**\n * @param {string} value\n * @param {number} index\n * @return {number}\n */\nexport function charat (value, index) {\n\treturn value.charCodeAt(index) | 0\n}\n\n/**\n * @param {string} value\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function substr (value, begin, end) {\n\treturn value.slice(begin, end)\n}\n\n/**\n * @param {string} value\n * @return {number}\n */\nexport function strlen (value) {\n\treturn value.length\n}\n\n/**\n * @param {any[]} value\n * @return {number}\n */\nexport function sizeof (value) {\n\treturn value.length\n}\n\n/**\n * @param {any} value\n * @param {any[]} array\n * @return {any}\n */\nexport function append (value, array) {\n\treturn array.push(value), value\n}\n\n/**\n * @param {string[]} array\n * @param {function} callback\n * @return {string}\n */\nexport function combine (array, callback) {\n\treturn array.map(callback).join('')\n}\n\n/**\n * @param {string[]} array\n * @param {RegExp} pattern\n * @return {string[]}\n */\nexport function filter (array, pattern) {\n\treturn array.filter(function (value) { return !match(value, pattern) })\n}\n",
7
+ "import {from, trim, charat, strlen, substr, append, assign} from './Utility.js'\n\nexport var line = 1\nexport var column = 1\nexport var length = 0\nexport var position = 0\nexport var character = 0\nexport var characters = ''\n\n/**\n * @param {string} value\n * @param {object | null} root\n * @param {object | null} parent\n * @param {string} type\n * @param {string[] | string} props\n * @param {object[] | string} children\n * @param {object[]} siblings\n * @param {number} length\n */\nexport function node (value, root, parent, type, props, children, length, siblings) {\n\treturn {value: value, root: root, parent: parent, type: type, props: props, children: children, line: line, column: column, length: length, return: '', siblings: siblings}\n}\n\n/**\n * @param {object} root\n * @param {object} props\n * @return {object}\n */\nexport function copy (root, props) {\n\treturn assign(node('', null, null, '', null, null, 0, root.siblings), root, {length: -root.length}, props)\n}\n\n/**\n * @param {object} root\n */\nexport function lift (root) {\n\twhile (root.root)\n\t\troot = copy(root.root, {children: [root]})\n\n\tappend(root, root.siblings)\n}\n\n/**\n * @return {number}\n */\nexport function char () {\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function prev () {\n\tcharacter = position > 0 ? charat(characters, --position) : 0\n\n\tif (column--, character === 10)\n\t\tcolumn = 1, line--\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function next () {\n\tcharacter = position < length ? charat(characters, position++) : 0\n\n\tif (column++, character === 10)\n\t\tcolumn = 1, line++\n\n\treturn character\n}\n\n/**\n * @return {number}\n */\nexport function peek () {\n\treturn charat(characters, position)\n}\n\n/**\n * @return {number}\n */\nexport function caret () {\n\treturn position\n}\n\n/**\n * @param {number} begin\n * @param {number} end\n * @return {string}\n */\nexport function slice (begin, end) {\n\treturn substr(characters, begin, end)\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function token (type) {\n\tswitch (type) {\n\t\t// \\0 \\t \\n \\r \\s whitespace token\n\t\tcase 0: case 9: case 10: case 13: case 32:\n\t\t\treturn 5\n\t\t// ! + , / > @ ~ isolate token\n\t\tcase 33: case 43: case 44: case 47: case 62: case 64: case 126:\n\t\t// ; { } breakpoint token\n\t\tcase 59: case 123: case 125:\n\t\t\treturn 4\n\t\t// : accompanied token\n\t\tcase 58:\n\t\t\treturn 3\n\t\t// \" ' ( [ opening delimit token\n\t\tcase 34: case 39: case 40: case 91:\n\t\t\treturn 2\n\t\t// ) ] closing delimit token\n\t\tcase 41: case 93:\n\t\t\treturn 1\n\t}\n\n\treturn 0\n}\n\n/**\n * @param {string} value\n * @return {any[]}\n */\nexport function alloc (value) {\n\treturn line = column = 1, length = strlen(characters = value), position = 0, []\n}\n\n/**\n * @param {any} value\n * @return {any}\n */\nexport function dealloc (value) {\n\treturn characters = '', value\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function delimit (type) {\n\treturn trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)))\n}\n\n/**\n * @param {string} value\n * @return {string[]}\n */\nexport function tokenize (value) {\n\treturn dealloc(tokenizer(alloc(value)))\n}\n\n/**\n * @param {number} type\n * @return {string}\n */\nexport function whitespace (type) {\n\twhile (character = peek())\n\t\tif (character < 33)\n\t\t\tnext()\n\t\telse\n\t\t\tbreak\n\n\treturn token(type) > 2 || token(character) > 3 ? '' : ' '\n}\n\n/**\n * @param {string[]} children\n * @return {string[]}\n */\nexport function tokenizer (children) {\n\twhile (next())\n\t\tswitch (token(character)) {\n\t\t\tcase 0: append(identifier(position - 1), children)\n\t\t\t\tbreak\n\t\t\tcase 2: append(delimit(character), children)\n\t\t\t\tbreak\n\t\t\tdefault: append(from(character), children)\n\t\t}\n\n\treturn children\n}\n\n/**\n * @param {number} index\n * @param {number} count\n * @return {string}\n */\nexport function escaping (index, count) {\n\twhile (--count && next())\n\t\t// not 0-9 A-F a-f\n\t\tif (character < 48 || character > 102 || (character > 57 && character < 65) || (character > 70 && character < 97))\n\t\t\tbreak\n\n\treturn slice(index, caret() + (count < 6 && peek() == 32 && next() == 32))\n}\n\n/**\n * @param {number} type\n * @return {number}\n */\nexport function delimiter (type) {\n\twhile (next())\n\t\tswitch (character) {\n\t\t\t// ] ) \" '\n\t\t\tcase type:\n\t\t\t\treturn position\n\t\t\t// \" '\n\t\t\tcase 34: case 39:\n\t\t\t\tif (type !== 34 && type !== 39)\n\t\t\t\t\tdelimiter(character)\n\t\t\t\tbreak\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (type === 41)\n\t\t\t\t\tdelimiter(type)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tnext()\n\t\t\t\tbreak\n\t\t}\n\n\treturn position\n}\n\n/**\n * @param {number} type\n * @param {number} index\n * @return {number}\n */\nexport function commenter (type, index) {\n\twhile (next())\n\t\t// //\n\t\tif (type + character === 47 + 10)\n\t\t\tbreak\n\t\t// /*\n\t\telse if (type + character === 42 + 42 && peek() === 47)\n\t\t\tbreak\n\n\treturn '/*' + slice(index, position - 1) + '*' + from(type === 47 ? type : next())\n}\n\n/**\n * @param {number} index\n * @return {string}\n */\nexport function identifier (index) {\n\twhile (!token(peek()))\n\t\tnext()\n\n\treturn slice(index, position)\n}\n",
8
+ "import {COMMENT, RULESET, DECLARATION} from './Enum.js'\nimport {abs, charat, trim, from, sizeof, strlen, substr, append, replace, indexof} from './Utility.js'\nimport {node, char, prev, next, peek, token, caret, alloc, dealloc, delimit, whitespace, escaping, identifier, commenter} from './Tokenizer.js'\n\n/**\n * @param {string} value\n * @return {object[]}\n */\nexport function compile (value) {\n\treturn dealloc(parse('', null, null, null, [''], value = alloc(value), 0, [0], value))\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {string[]} rule\n * @param {string[]} rules\n * @param {string[]} rulesets\n * @param {number[]} pseudo\n * @param {number[]} points\n * @param {string[]} declarations\n * @return {object}\n */\nexport function parse (value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {\n\tvar index = 0\n\tvar offset = 0\n\tvar length = pseudo\n\tvar atrule = 0\n\tvar property = 0\n\tvar previous = 0\n\tvar variable = 1\n\tvar scanning = 1\n\tvar ampersand = 1\n\tvar character = 0\n\tvar type = ''\n\tvar props = rules\n\tvar children = rulesets\n\tvar reference = rule\n\tvar characters = type\n\n\twhile (scanning)\n\t\tswitch (previous = character, character = next()) {\n\t\t\t// (\n\t\t\tcase 40:\n\t\t\t\tif (previous != 108 && charat(characters, length - 1) == 58) {\n\t\t\t\t\tif (indexof(characters += replace(delimit(character), '&', '&\\f'), '&\\f', abs(index ? points[index - 1] : 0)) != -1)\n\t\t\t\t\t\tampersand = -1\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t// \" ' [\n\t\t\tcase 34: case 39: case 91:\n\t\t\t\tcharacters += delimit(character)\n\t\t\t\tbreak\n\t\t\t// \\t \\n \\r \\s\n\t\t\tcase 9: case 10: case 13: case 32:\n\t\t\t\tcharacters += whitespace(previous)\n\t\t\t\tbreak\n\t\t\t// \\\n\t\t\tcase 92:\n\t\t\t\tcharacters += escaping(caret() - 1, 7)\n\t\t\t\tcontinue\n\t\t\t// /\n\t\t\tcase 47:\n\t\t\t\tswitch (peek()) {\n\t\t\t\t\tcase 42: case 47:\n\t\t\t\t\t\tappend(comment(commenter(next(), caret()), root, parent, declarations), declarations)\n\t\t\t\t\t\tif ((token(previous || 1) == 5 || token(peek() || 1) == 5) && strlen(characters) && substr(characters, -1, void 0) !== ' ') characters += ' '\n\t\t\t\t\t\tbreak\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tcharacters += '/'\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t// {\n\t\t\tcase 123 * variable:\n\t\t\t\tpoints[index++] = strlen(characters) * ampersand\n\t\t\t// } ; \\0\n\t\t\tcase 125 * variable: case 59: case 0:\n\t\t\t\tswitch (character) {\n\t\t\t\t\t// \\0 }\n\t\t\t\t\tcase 0: case 125: scanning = 0\n\t\t\t\t\t// ;\n\t\t\t\t\tcase 59 + offset: if (ampersand == -1) characters = replace(characters, /\\f/g, '')\n\t\t\t\t\t\tif (property > 0 && (strlen(characters) - length || (variable === 0 && previous === 47)))\n\t\t\t\t\t\t\tappend(property > 32 ? declaration(characters + ';', rule, parent, length - 1, declarations) : declaration(replace(characters, ' ', '') + ';', rule, parent, length - 2, declarations), declarations)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @ ;\n\t\t\t\t\tcase 59: characters += ';'\n\t\t\t\t\t// { rule/at-rule\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tappend(reference = ruleset(characters, root, parent, index, offset, rules, points, type, props = [], children = [], length, rulesets), rulesets)\n\n\t\t\t\t\t\tif (character === 123)\n\t\t\t\t\t\t\tif (offset === 0)\n\t\t\t\t\t\t\t\tparse(characters, root, reference, reference, props, rulesets, length, points, children)\n\t\t\t\t\t\t\telse {\n\t\t\t\t\t\t\t\tswitch (atrule) {\n\t\t\t\t\t\t\t\t\t// c(ontainer)\n\t\t\t\t\t\t\t\t\tcase 99:\n\t\t\t\t\t\t\t\t\t\tif (charat(characters, 3) === 110) break\n\t\t\t\t\t\t\t\t\t// l(ayer)\n\t\t\t\t\t\t\t\t\tcase 108:\n\t\t\t\t\t\t\t\t\t\tif (charat(characters, 2) === 97) break\n\t\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\t\toffset = 0\n\t\t\t\t\t\t\t\t\t// d(ocument) m(edia) s(upports)\n\t\t\t\t\t\t\t\t\tcase 100: case 109: case 115:\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (offset) parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length, children), children), rules, children, length, points, rule ? props : children)\n\t\t\t\t\t\t\t\telse parse(characters, reference, reference, reference, [''], children, 0, points, children)\n\t\t\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tindex = offset = property = 0, variable = ampersand = 1, type = characters = '', length = pseudo\n\t\t\t\tbreak\n\t\t\t// :\n\t\t\tcase 58:\n\t\t\t\tlength = 1 + strlen(characters), property = previous\n\t\t\tdefault:\n\t\t\t\tif (variable < 1)\n\t\t\t\t\tif (character == 123)\n\t\t\t\t\t\t--variable\n\t\t\t\t\telse if (character == 125 && variable++ == 0 && prev() == 125)\n\t\t\t\t\t\tcontinue\n\n\t\t\t\tswitch (characters += from(character), character * variable) {\n\t\t\t\t\t// &\n\t\t\t\t\tcase 38:\n\t\t\t\t\t\tampersand = offset > 0 ? 1 : (characters += '\\f', -1)\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// ,\n\t\t\t\t\tcase 44:\n\t\t\t\t\t\tpoints[index++] = (strlen(characters) - 1) * ampersand, ampersand = 1\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// @\n\t\t\t\t\tcase 64:\n\t\t\t\t\t\t// -\n\t\t\t\t\t\tif (peek() === 45)\n\t\t\t\t\t\t\tcharacters += delimit(next())\n\n\t\t\t\t\t\tatrule = peek(), offset = length = strlen(type = characters += identifier(caret())), character++\n\t\t\t\t\t\tbreak\n\t\t\t\t\t// -\n\t\t\t\t\tcase 45:\n\t\t\t\t\t\tif (previous === 45 && strlen(characters) == 2)\n\t\t\t\t\t\t\tvariable = 0\n\t\t\t\t}\n\t\t}\n\n\treturn rulesets\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} index\n * @param {number} offset\n * @param {string[]} rules\n * @param {number[]} points\n * @param {string} type\n * @param {string[]} props\n * @param {string[]} children\n * @param {number} length\n * @param {object[]} siblings\n * @return {object}\n */\nexport function ruleset (value, root, parent, index, offset, rules, points, type, props, children, length, siblings) {\n\tvar post = offset - 1\n\tvar rule = offset === 0 ? rules : ['']\n\tvar size = sizeof(rule)\n\n\tfor (var i = 0, j = 0, k = 0; i < index; ++i)\n\t\tfor (var x = 0, y = substr(value, post + 1, post = abs(j = points[i])), z = value; x < size; ++x)\n\t\t\tif (z = trim(j > 0 ? rule[x] + ' ' + y : replace(y, /&\\f/g, rule[x])))\n\t\t\t\tprops[k++] = z\n\n\treturn node(value, root, parent, offset === 0 ? RULESET : type, props, children, length, siblings)\n}\n\n/**\n * @param {number} value\n * @param {object} root\n * @param {object?} parent\n * @param {object[]} siblings\n * @return {object}\n */\nexport function comment (value, root, parent, siblings) {\n\treturn node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings)\n}\n\n/**\n * @param {string} value\n * @param {object} root\n * @param {object?} parent\n * @param {number} length\n * @param {object[]} siblings\n * @return {object}\n */\nexport function declaration (value, root, parent, length, siblings) {\n\treturn node(value, root, parent, DECLARATION, substr(value, 0, length), substr(value, length + 1, -1), length, siblings)\n}\n",
9
+ "import {IMPORT, LAYER, COMMENT, RULESET, DECLARATION, KEYFRAMES, NAMESPACE} from './Enum.js'\nimport {strlen} from './Utility.js'\n\n/**\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function serialize (children, callback) {\n\tvar output = ''\n\n\tfor (var i = 0; i < children.length; i++)\n\t\toutput += callback(children[i], i, children, callback) || ''\n\n\treturn output\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n * @return {string}\n */\nexport function stringify (element, index, children, callback) {\n\tswitch (element.type) {\n\t\tcase LAYER: if (element.children.length) break\n\t\tcase IMPORT: case NAMESPACE: case DECLARATION: return element.return = element.return || element.value\n\t\tcase COMMENT: return ''\n\t\tcase KEYFRAMES: return element.return = element.value + '{' + serialize(element.children, callback) + '}'\n\t\tcase RULESET: if (!strlen(element.value = element.props.join(','))) return ''\n\t}\n\n\treturn strlen(children = serialize(element.children, callback)) ? element.return = element.value + '{' + children + '}' : ''\n}\n",
10
+ "import {MS, MOZ, WEBKIT, RULESET, KEYFRAMES, DECLARATION} from './Enum.js'\nimport {match, charat, substr, strlen, sizeof, replace, combine, filter, assign} from './Utility.js'\nimport {copy, lift, tokenize} from './Tokenizer.js'\nimport {serialize} from './Serializer.js'\nimport {prefix} from './Prefixer.js'\n\n/**\n * @param {function[]} collection\n * @return {function}\n */\nexport function middleware (collection) {\n\tvar length = sizeof(collection)\n\n\treturn function (element, index, children, callback) {\n\t\tvar output = ''\n\n\t\tfor (var i = 0; i < length; i++)\n\t\t\toutput += collection[i](element, index, children, callback) || ''\n\n\t\treturn output\n\t}\n}\n\n/**\n * @param {function} callback\n * @return {function}\n */\nexport function rulesheet (callback) {\n\treturn function (element) {\n\t\tif (!element.root)\n\t\t\tif (element = element.return)\n\t\t\t\tcallback(element)\n\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n * @param {function} callback\n */\nexport function prefixer (element, index, children, callback) {\n\tif (element.length > -1)\n\t\tif (!element.return)\n\t\t\tswitch (element.type) {\n\t\t\t\tcase DECLARATION: element.return = prefix(element.value, element.length, children)\n\t\t\t\t\treturn\n\t\t\t\tcase KEYFRAMES:\n\t\t\t\t\treturn serialize([copy(element, {value: replace(element.value, '@', '@' + WEBKIT)})], callback)\n\t\t\t\tcase RULESET:\n\t\t\t\t\tif (element.length)\n\t\t\t\t\t\treturn combine(children = element.props, function (value) {\n\t\t\t\t\t\t\tswitch (match(value, callback = /(::plac\\w+|:read-\\w+)/)) {\n\t\t\t\t\t\t\t\t// :read-(only|write)\n\t\t\t\t\t\t\t\tcase ':read-only': case ':read-write':\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(read-\\w+)/, ':' + MOZ + '$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [value]}))\n\t\t\t\t\t\t\t\t\tassign(element, {props: filter(children, callback)})\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\t// :placeholder\n\t\t\t\t\t\t\t\tcase '::placeholder':\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(plac\\w+)/, ':' + WEBKIT + 'input-$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(plac\\w+)/, ':' + MOZ + '$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [replace(value, /:(plac\\w+)/, MS + 'input-$1')]}))\n\t\t\t\t\t\t\t\t\tlift(copy(element, {props: [value]}))\n\t\t\t\t\t\t\t\t\tassign(element, {props: filter(children, callback)})\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn ''\n\t\t\t\t\t\t})\n\t\t\t}\n}\n\n/**\n * @param {object} element\n * @param {number} index\n * @param {object[]} children\n */\nexport function namespace (element) {\n\tswitch (element.type) {\n\t\tcase RULESET:\n\t\t\telement.props = element.props.map(function (value) {\n\t\t\t\treturn combine(tokenize(value), function (value, index, children) {\n\t\t\t\t\tswitch (charat(value, 0)) {\n\t\t\t\t\t\t// \\f\n\t\t\t\t\t\tcase 12:\n\t\t\t\t\t\t\treturn substr(value, 1, strlen(value))\n\t\t\t\t\t\t// \\0 ( + > ~\n\t\t\t\t\t\tcase 0: case 40: case 43: case 62: case 126:\n\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t// :\n\t\t\t\t\t\tcase 58:\n\t\t\t\t\t\t\tif (children[++index] === 'global')\n\t\t\t\t\t\t\t\tchildren[index] = '', children[++index] = '\\f' + substr(children[index], index = 1, -1)\n\t\t\t\t\t\t// \\s\n\t\t\t\t\t\tcase 32:\n\t\t\t\t\t\t\treturn index === 1 ? '' : value\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tswitch (index) {\n\t\t\t\t\t\t\t\tcase 0: element = value\n\t\t\t\t\t\t\t\t\treturn sizeof(children) > 1 ? '' : value\n\t\t\t\t\t\t\t\tcase index = sizeof(children) - 1: case 2:\n\t\t\t\t\t\t\t\t\treturn index === 2 ? value + element + element : value + element\n\t\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\t\treturn value\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t})\n\t\t\t})\n\t}\n}\n",
11
+ "/**\n * Opt-in CSS preprocessor.\n *\n * import Lips from '@lipsjs/lips'\n * import { stylisPreprocessor } from '@lipsjs/lips/stylis'\n *\n * const lips = new Lips({ stylePreprocessor: stylisPreprocessor })\n *\n * and for build-time precompilation:\n *\n * precompile( template, { name, preprocess: stylisPreprocessor })\n * lipsPlugin({ preprocess: stylisPreprocessor })\n *\n * WITHOUT it Lips still compiles, scopes and injects stylesheets: the\n * scope wrap `[rel=\"card\"] { … }` is ordinary CSS nesting, which every\n * engine with CSS nesting resolves natively (Chrome/Edge 112+, Safari\n * 16.5+, Firefox 117+), and the compiler itself hoists the at-rules that\n * cannot legally nest (`@keyframes`, `@font-face`, …) and compacts the\n * text.\n *\n * What Stylis adds is FLATTENING: `[rel=\"card\"] .a { … }` instead of a\n * nested block, for engines older than native nesting — where a nested\n * sheet is dropped whole. It also accepts Stylis-only syntax such as\n * `&-suffix` concatenation. It costs ~1.9 KB gzipped, which is why it is\n * a choice rather than a default.\n *\n * It does NOT vendor-prefix — the full build never did. Stylis's\n * `prefixer` emits mostly obsolete prefixes (`-webkit-box`,\n * `-ms-flexbox`, …) and nearly doubles the cost; if you need it anyway:\n *\n * import { compile, serialize, middleware, prefixer, stringify } from 'stylis'\n * new Lips({ stylePreprocessor: css => serialize( compile( css ), middleware([ prefixer, stringify ]) ) })\n *\n * NB: it is handed over as a VALUE, never wired by importing this module\n * for its side effect. Each published entry (`@lipsjs/lips`,\n * `@lipsjs/lips/precompile`, this one) is a separate bundle with its own\n * copy of the style compiler, so a global set from one is invisible to\n * the others — passing the function is the only wiring that crosses that\n * boundary.\n */\nimport { compile, serialize, stringify, middleware } from 'stylis'\n\n/** Hand this to `new Lips({ stylePreprocessor })` or `precompile(…, { preprocess })` */\nexport const stylisPreprocessor = ( css: string ) =>\n serialize( compile( css ), middleware([ stringify ]) )\n"
12
+ ],
13
+ "mappings": "AAIO,IAAI,EAAU,OACV,EAAU,OACV,EAAc,OAIlB,IAAI,EAAS,UAKb,IAAI,EAAY,aACZ,GAAY,aAIhB,IAAI,GAAQ,SChBZ,IAAI,EAAM,KAAK,IAMX,EAAO,OAAO,aAqBlB,SAAS,CAAK,CAAC,EAAO,CAC5B,OAAO,EAAM,KAAK,EAkBZ,SAAS,CAAQ,CAAC,EAAO,EAAS,EAAa,CACrD,OAAO,EAAM,QAAQ,EAAS,CAAW,EASnC,SAAS,EAAQ,CAAC,EAAO,EAAQ,EAAU,CACjD,OAAO,EAAM,QAAQ,EAAQ,CAAQ,EAQ/B,SAAS,CAAO,CAAC,EAAO,EAAO,CACrC,OAAO,EAAM,WAAW,CAAK,EAAI,EAS3B,SAAS,CAAO,CAAC,EAAO,EAAO,EAAK,CAC1C,OAAO,EAAM,MAAM,EAAO,CAAG,EAOvB,SAAS,CAAO,CAAC,EAAO,CAC9B,OAAO,EAAM,OAOP,SAAS,CAAO,CAAC,EAAO,CAC9B,OAAO,EAAM,OAQP,SAAS,CAAO,CAAC,EAAO,EAAO,CACrC,OAAO,EAAM,KAAK,CAAK,EAAG,ECvGpB,IAAI,EAAO,EACP,EAAS,EACT,GAAS,EACT,EAAW,EACX,EAAY,EACZ,EAAa,GAYjB,SAAS,CAAK,CAAC,EAAO,EAAM,EAAQ,EAAM,EAAO,EAAU,EAAQ,EAAU,CACnF,MAAO,CAAC,MAAO,EAAO,KAAM,EAAM,OAAQ,EAAQ,KAAM,EAAM,MAAO,EAAO,SAAU,EAAU,KAAM,EAAM,OAAQ,EAAQ,OAAQ,EAAQ,OAAQ,GAAI,SAAU,CAAQ,EAyBpK,SAAS,EAAK,EAAG,CACvB,OAAO,EAMD,SAAS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AS,EAAQ,MAAQ,IAAM,EAAU,EAAQ,SAAU,CAAQ,EAAI,SACjG,EAAS,GAAI,CAAC,EAAO,EAAQ,MAAQ,EAAQ,MAAM,KAAK,GAAG,CAAC,EAAG,MAAO,GAG5E,OAAO,EAAO,EAAW,EAAU,EAAQ,SAAU,CAAQ,CAAC,EAAI,EAAQ,OAAS,EAAQ,MAAQ,IAAM,EAAW,IAAM,GCvBpH,SAAS,EAAW,CAAC,EAAY,CACvC,IAAI,EAAS,EAAO,CAAU,EAE9B,OAAO,QAAS,CAAC,EAAS,EAAO,EAAU,EAAU,CACpD,IAAI,EAAS,GAEb,QAAS,EAAI,EAAG,EAAI,EAAQ,IAC3B,GAAU,EAAW,GAAG,EAAS,EAAO,EAAU,CAAQ,GAAK,GAEhE,OAAO,GCwBF,IAAM,GAAqB,CAAE,IACA,EAAW,GAAS,CAAI,EAAG,GAAW,CAAE,EAAU,CAAC,CAAE",
14
+ "debugId": "AF142D960144E6D064756E2164756E21",
15
+ "names": []
16
+ }
@@ -9,6 +9,6 @@ export default class Events {
9
9
  constructor(options?: EventOptions);
10
10
  on(_event: string, fn: EventListener): this;
11
11
  once(_event: string, fn: EventListener): this;
12
- off(_event: string): this;
12
+ off(_event: string, fn?: EventListener): this;
13
13
  emit(_event: string, ...params: any[]): void;
14
14
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The MessageFormat 2 engine: `messageformat` v4 with every function the
3
+ * standard defines — the default set (`:number`, `:integer`, `:currency`,
4
+ * `:percent`, `:offset`, `:string`) built in, and the draft set (`:date`,
5
+ * `:time`, `:datetime`, `:unit`) added. An engine without `Intl` gets the
6
+ * least of it first (`./intl`).
7
+ *
8
+ * It is a value handed to `I18N`, not an import of it, so the `./runtime`
9
+ * entry ships without it: the full build wires it in, and an app on
10
+ * `./runtime` that translates passes it from `@lipsjs/lips/i18n`.
11
+ */
12
+ import './intl';
13
+ import type { MessageFormatEngine } from '../types';
14
+ export declare const messageFormat: MessageFormatEngine;
@@ -1,19 +1,136 @@
1
- import type { Dictionary } from '../types';
1
+ import type { MessageFunction } from 'messageformat/functions';
2
+ import type { Dictionary, MessageFormatEngine } from '../types';
3
+ import { lookupTags, pick, type TranslatableName } from './lookup';
4
+ export { lookupTags, pick, type TranslatableName };
5
+ /**
6
+ * Every message is Unicode MessageFormat 2 (CLDR 47), formatted by
7
+ * `messageformat` — the same implementation the platform that serves
8
+ * the dictionaries checks them with, so a message means one thing on
9
+ * both sides of the wire. The engine is handed in (`./engine`), so a
10
+ * build that never translates ships without it. An entry is MF2 source:
11
+ *
12
+ * 'cart.items': `.input {$count :integer}
13
+ * .match $count
14
+ * 0 {{Your cart is empty}}
15
+ * one {{One item in your cart}}
16
+ * * {{{$count} items in your cart}}`
17
+ *
18
+ * or the same message as its data model (`parseMessage`'s JSON), which is
19
+ * how a server that parsed it once serves it.
20
+ *
21
+ * Dictionaries are keyed by full language tag (`fr`, `fr-CA`, `zh-Hant`)
22
+ * and read through RFC 4647 Lookup: a `fr-CA` reader is served from
23
+ * `fr-CA`, then `fr`, so a regional dictionary carries only what differs.
24
+ */
2
25
  export default class I18N {
26
+ private engine?;
3
27
  private currentLang;
4
28
  private DICTIONARIES;
29
+ /**
30
+ * MF2 functions a message may call, beyond the default ones built in
31
+ * (`:number`, `:integer`, `:currency`, `:percent`, `:offset`,
32
+ * `:string`). Starts with the draft set — `:date`, `:time`,
33
+ * `:datetime`, `:unit` — and takes a host's own, named with a
34
+ * namespace (`:app:money`) as MF2 asks of custom functions.
35
+ */
36
+ functions: Record<string, MessageFunction<any, any>>;
37
+ /**
38
+ * Reports a stable key that no dictionary entry answers. Left unset
39
+ * translation stays silent; the facade wires it to a console warning
40
+ * under `debug`, and a generator can wire it to collect the gaps.
41
+ */
42
+ onMissing?: (key: string, lang: string) => void;
43
+ /**
44
+ * Reports a message that does not parse, or that fails as it formats:
45
+ * a variable not given, an unknown function, a value its function
46
+ * cannot take. Rendering never throws for it — MF2 writes a fallback
47
+ * (`{$name}`) where the failing part was — so this is where it shows.
48
+ */
49
+ onError?: (error: unknown, key: string, lang: string) => void;
50
+ /**
51
+ * Fires whenever the dictionary set changes. The facade bumps a
52
+ * revision signal from here, which is what makes a dictionary that
53
+ * arrives LATE — an async load resolving after the language already
54
+ * switched — re-translate what is already on screen.
55
+ */
56
+ onChange?: () => void;
57
+ /** Async dictionary source, set by `setLoader` */
58
+ private loader?;
59
+ /** In-flight and settled loads, keyed by language tag */
60
+ private loading;
61
+ /** Each message as read by one language, parsed once: `null` where it does not parse */
62
+ private formatters;
63
+ /**
64
+ * `lang` is the initial language, normally `LipsConfig.lang`. Left
65
+ * out, it is read from the browser — which is the right default for
66
+ * an app that should follow the user's locale, but is not something
67
+ * a server render or a test can rely on being there.
68
+ */
69
+ constructor(lang?: string, engine?: MessageFormatEngine | undefined);
5
70
  set lang(value: string);
6
71
  get lang(): string;
7
- setDictionary(id: string, dico: Dictionary): void;
72
+ /** Register the dictionary for one language tag — `fr`, `fr-CA`, `zh-Hant` — whatever its casing. */
73
+ setDictionary(tag: string, dico: Dictionary): void;
74
+ /** Is a dictionary registered that a reader of `lang` is served from? */
75
+ has(lang: string): boolean;
8
76
  /**
77
+ * Register an async dictionary source, asked once per language tag:
78
+ *
79
+ * lips.i18n.setLoader( tag => import(`./languages/${tag}.json`).then( m => m.default ) )
9
80
  *
81
+ * Bundling every language up front costs every user all of them. With
82
+ * a loader, `setLanguage()` switches immediately (untranslated source
83
+ * text is a fine placeholder — it is real wording, not a blank) and
84
+ * the strings resolve when the dictionary lands. A `fr-CA` reader asks
85
+ * for `fr-CA` and `fr`: a source with no `fr-CA` answers `undefined`.
10
86
  */
11
- translate(text: string, lang?: string): {
87
+ setLoader(fn: (tag: string) => Promise<Dictionary | undefined>): this;
88
+ /**
89
+ * Ensure the dictionaries a reader of `lang` is served from are
90
+ * registered. Resolves immediately when they are, or when no loader is
91
+ * set — a missing dictionary is not an error, it just means
92
+ * untranslated output. Each tag is attempted ONCE: a rejected load is
93
+ * remembered so a missing language file does not re-fetch on every
94
+ * switch.
95
+ */
96
+ load(lang: string): Promise<void>;
97
+ /**
98
+ * The message `key` as a reader of `lang` reads it: from the first
99
+ * dictionary of the lookup chain that has it, formatting in `lang`
100
+ * itself — a `fr-CA` reader of a `fr` message still gets Canadian
101
+ * number and date conventions. `undefined` when no dictionary has it;
102
+ * `null` when the one that does holds a message that does not parse.
103
+ */
104
+ private message;
105
+ /**
106
+ * Translate a source string into `lang`, defaulting to the current
107
+ * language. A missing dictionary or a missing key is not an error: the
108
+ * source text passes through unchanged, so a partially translated
109
+ * dictionary degrades to the original wording rather than to a blank.
110
+ *
111
+ * `key` is a STABLE id (RFC-005 §3). Given one, it is what the
112
+ * dictionary is consulted for, and `text` becomes only the fallback
113
+ * wording — so rewording the source string keeps the translation.
114
+ * Without it the source text IS the key (the gettext model), which is
115
+ * fine for hand-written UI and lossy for generated UI.
116
+ *
117
+ * The entry is an MF2 message with nothing to fill: plain text, its
118
+ * `{`, `}` and `\` escaped as MF2 has them.
119
+ *
120
+ * NB: naming the current language explicitly must behave exactly like
121
+ * omitting it — an earlier guard returned the source text whenever
122
+ * `lang === currentLang`, which is precisely when a translation IS wanted.
123
+ */
124
+ translate(text: string, lang?: string, key?: string): {
12
125
  text: string;
13
126
  lang: string;
14
127
  };
15
128
  /**
16
- *
129
+ * The message `reference` formatted with `params` in `lang`, defaulting
130
+ * to the current language — what `@format="reference, { params }"`
131
+ * renders. `undefined` when no dictionary has it, reported as missing.
17
132
  */
18
- format(reference: string, params: Record<string, any>, local?: string): string | undefined;
133
+ format(reference: string, params: Record<string, unknown>, lang?: string): string | undefined;
134
+ /** The text of a translatable name a reader of `lang` reads, defaulting to the current language. */
135
+ pick(name: TranslatableName, lang?: string): string;
19
136
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The tags a reader of `tag` is served from, most specific first — RFC 4647
3
+ * §3.4 Lookup: the tag, then each shorter prefix, a single-letter subtag
4
+ * left at the end dropped with what followed it. `zh-Hant-TW` reads
5
+ * `zh-Hant` before `zh`, so a script is never skipped for its language.
6
+ *
7
+ * It is the same chain AB's `lookupTags` walks for a translatable name, and
8
+ * both are held to the RFC's own example, so a dictionary and a name stored
9
+ * on the platform fall back the same way for the same reader.
10
+ */
11
+ export declare function lookupTags(tag: string): string[];
12
+ /** A name said in more than one language: one text per language tag, and the one to fall back to. */
13
+ export type TranslatableName = {
14
+ readonly default: string;
15
+ readonly names: Readonly<Record<string, string>>;
16
+ };
17
+ /**
18
+ * The text of `name` a reader of `lang` reads: the first tag of its lookup
19
+ * chain the name has, matched whatever its casing, and the default text
20
+ * when none is. What a template shows for a platform name, as `self.pick( … )`.
21
+ */
22
+ export declare function pick(name: TranslatableName, lang: string): string;
@@ -0,0 +1,226 @@
1
+ /**
2
+ * Phase 2 — IR compiler (RFC-001 §4)
3
+ *
4
+ * TemplateAST → TemplateIR:
5
+ * - static HTML skeletons per block, ready for one-time <template>
6
+ * parsing + per-instance cloneNode
7
+ * - integer-path bind table (childNodes index walks — no string paths)
8
+ * - control-flow block nodes anchored by comment placeholders whose
9
+ * paths are precomputed (the compiler simulates browser text-node
10
+ * coalescing so paths survive the HTML round-trip)
11
+ * - deduped expression table; every authored expression is validated
12
+ * at compile time and its diagnostics re-anchored to template
13
+ * line/col
14
+ *
15
+ * The output is JSON-serializable and deterministic — it is the
16
+ * Modela artifact, the runtime render program, and the hot-swap
17
+ * diff unit.
18
+ *
19
+ * With `target: 'tree'` every block also carries `nodes`, the same
20
+ * skeleton as a structural tree, for hosts that build nodes one by
21
+ * one rather than parse markup (RFC-006 §4.1).
22
+ */
23
+ import type { TemplateNode, TemplateDiagnostic } from './parser';
24
+ export type Path = number[];
25
+ export type E = number;
26
+ export type CompInput = {
27
+ e: E;
28
+ } | {
29
+ lit: unknown;
30
+ };
31
+ export interface TemplateIR {
32
+ v: 1;
33
+ exprs: string[];
34
+ root: BlockIR;
35
+ }
36
+ /**
37
+ * One node of a block's structural skeleton (RFC-006 §4.1): the tree
38
+ * `html` encodes, for hosts with no HTML parser. Bind and block paths
39
+ * index it exactly as they index the parsed `html`.
40
+ *
41
+ * 'text' a static text run
42
+ * 0 an anchor — where a text bind or a block attaches
43
+ * [ tag, attrs?, children? ] an element and its static attributes
44
+ */
45
+ export type NodeIR = string | 0 | [tag: string, attrs?: Record<string, string>, children?: NodeIR[]];
46
+ export interface BlockIR {
47
+ html: string;
48
+ /** The skeleton as a tree — present when compiled with `target: 'tree'` */
49
+ nodes?: NodeIR[];
50
+ /**
51
+ * Scope variable names visible to this block's binds
52
+ * (iterator args, async arm args, let/const names —
53
+ * let names are block-scoped from block start, see RFC)
54
+ */
55
+ scope: string[];
56
+ binds: BindIR[];
57
+ blocks: ChildIR[];
58
+ }
59
+ /**
60
+ * `i18n` marks a bind as translatable; `ik` carries the STABLE key to
61
+ * look it up by (RFC-005 §3). Without `ik` the rendered text is its own
62
+ * key — reword the source and the translation is orphaned.
63
+ */
64
+ export type BindIR = {
65
+ t: 'text';
66
+ p: Path;
67
+ e: E;
68
+ i18n?: 1;
69
+ ik?: string;
70
+ } | {
71
+ t: 'attr';
72
+ p: Path;
73
+ name: string;
74
+ e: E;
75
+ i18n?: 1;
76
+ ik?: string;
77
+ } | {
78
+ t: 'prop';
79
+ p: Path;
80
+ name: string;
81
+ e: E;
82
+ i18n?: 1;
83
+ ik?: string;
84
+ ref?: string;
85
+ } | {
86
+ t: 'event';
87
+ p: Path;
88
+ name: string;
89
+ e: E;
90
+ } | {
91
+ t: 'spread';
92
+ p: Path;
93
+ e: E;
94
+ };
95
+ export interface ArmIR {
96
+ args: string[];
97
+ block: BlockIR;
98
+ }
99
+ /**
100
+ * One macro call-site assignment, in SOURCE ORDER so later
101
+ * entries override earlier ones (`<option key=k ...each/>` —
102
+ * the spread wins over `key` for keys it contains).
103
+ */
104
+ export type MacroSet = {
105
+ name: string;
106
+ ci: CompInput;
107
+ } | {
108
+ spread: E;
109
+ };
110
+ export type ChildIR = {
111
+ t: 'macro';
112
+ p: Path;
113
+ name: string;
114
+ sets: MacroSet[];
115
+ args: string[];
116
+ block: BlockIR;
117
+ } | {
118
+ t: 'if';
119
+ p: Path;
120
+ branches: {
121
+ when: E | null;
122
+ block: BlockIR;
123
+ }[];
124
+ } | {
125
+ t: 'for';
126
+ p: Path;
127
+ of?: E;
128
+ from?: CompInput;
129
+ to?: CompInput;
130
+ by?: CompInput;
131
+ args: string[];
132
+ block: BlockIR;
133
+ } | {
134
+ t: 'switch';
135
+ p: Path;
136
+ on: E;
137
+ cases: {
138
+ is: CompInput | null;
139
+ block: BlockIR;
140
+ }[];
141
+ } | {
142
+ t: 'async';
143
+ p: Path;
144
+ awaitE: E;
145
+ then?: ArmIR;
146
+ catch?: ArmIR;
147
+ loading?: BlockIR;
148
+ } | {
149
+ t: 'let';
150
+ p: Path;
151
+ const: boolean;
152
+ vars: Record<string, CompInput>;
153
+ } | {
154
+ t: 'log';
155
+ p: Path;
156
+ e: E;
157
+ }
158
+ /**
159
+ * `<context …>` / `<i18n lang=…>` — a context layer over the subtree
160
+ * (RFC-005 §4). `vars` are the provided keys; `lang` is the scoped
161
+ * language. One IR kind, two spellings: they differ only in which
162
+ * field they fill.
163
+ */
164
+ | {
165
+ t: 'provide';
166
+ p: Path;
167
+ vars: Record<string, CompInput>;
168
+ lang?: CompInput;
169
+ block: BlockIR;
170
+ } | {
171
+ t: 'comp';
172
+ p: Path;
173
+ name: string;
174
+ inputs: Record<string, CompInput>;
175
+ spreads: E[];
176
+ events: {
177
+ name: string;
178
+ e: E;
179
+ }[];
180
+ contents?: ArmIR;
181
+ } | {
182
+ t: 'dynamic';
183
+ p: Path;
184
+ tag: E;
185
+ inputs: Record<string, CompInput>;
186
+ spreads: E[];
187
+ events: {
188
+ name: string;
189
+ e: E;
190
+ }[];
191
+ contents?: ArmIR;
192
+ };
193
+ export interface CompileResult {
194
+ ir: TemplateIR;
195
+ diagnostics: TemplateDiagnostic[];
196
+ }
197
+ export interface CompileOptions {
198
+ /** `<macro [argv] name="X">…</macro>` definitions, inlined at call sites */
199
+ macros?: string;
200
+ /**
201
+ * The kind of host the IR is for. `'dom'` (default) needs only the
202
+ * `html` skeletons. `'tree'` is for hosts with no HTML parser
203
+ * (RFC-006 §4.1): blocks also carry `nodes`, comments are dropped
204
+ * (they mean nothing off the DOM), and `@html` is an error.
205
+ */
206
+ target?: 'dom' | 'tree';
207
+ /**
208
+ * Rewrites the parsed template before it compiles, reporting into
209
+ * `diagnostics` — how a host adapts the HTML-shaped vocabulary
210
+ * (`compileLynxTemplate`, RFC-006 §4.3). Macro bodies are not passed.
211
+ */
212
+ transform?: (nodes: TemplateNode[], diagnostics: TemplateDiagnostic[]) => void;
213
+ /**
214
+ * Inspects — and may rewrite — the parsed template AND the macros
215
+ * source before either compiles, reporting into `diagnostics` located
216
+ * against `src`, the source the nodes came from. How an untrusted
217
+ * template is held to its policy (RFC-007 §5.1): a refusal is reported
218
+ * where it is written, and the refused construct never compiles.
219
+ */
220
+ check?: (nodes: TemplateNode[], diagnostics: TemplateDiagnostic[], src: string) => void;
221
+ }
222
+ export declare const CONTROL_TAGS: Set<string>;
223
+ export declare const ARM_TAGS: Set<string>;
224
+ /** Standard HTML + common SVG tags — anything else is a component candidate */
225
+ export declare const HTML_TAGS: Set<string>;
226
+ export declare function compileTemplate(src: string, options?: CompileOptions): CompileResult;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Phase 2 — Expression subsystem (RFC-001 §5)
3
+ *
4
+ * A dedicated parser for the template expression subset with:
5
+ * - positioned, machine-readable diagnostics (never throws)
6
+ * - AST-derived precise dependency paths
7
+ * - two interchangeable executors over the same AST:
8
+ * compiled — one Function per unique expression
9
+ * interpreted — an AST walker that never builds a Function (CSP)
10
+ * Both are for templates you trust. Neither is a boundary: a template
11
+ * you did not write runs under a policy instead (RFC-007, ./policy).
12
+ *
13
+ * Grammar (expression-only, no statements):
14
+ * literals (number, string, boolean, null, undefined), identifiers,
15
+ * member access (incl. optional/computed), calls, unary ! - + and
16
+ * prefix/postfix ++ --, binary arithmetic/relational/equality,
17
+ * && || ??, ternary, arrow functions, assignment (= += -= *= /= %=),
18
+ * array/object literals with spread.
19
+ */
20
+ export interface ExprDiagnostic {
21
+ code: string;
22
+ message: string;
23
+ loc: {
24
+ offset: number;
25
+ length: number;
26
+ };
27
+ }
28
+ export type Expr = {
29
+ t: 'lit';
30
+ v: any;
31
+ }
32
+ /** `at`: where the name (or a member's key) starts in the source — for diagnostics */
33
+ | {
34
+ t: 'id';
35
+ name: string;
36
+ at?: number;
37
+ } | {
38
+ t: 'member';
39
+ obj: Expr;
40
+ prop: string | Expr;
41
+ computed: boolean;
42
+ optional: boolean;
43
+ at?: number;
44
+ } | {
45
+ t: 'call';
46
+ callee: Expr;
47
+ args: Expr[];
48
+ optional: boolean;
49
+ } | {
50
+ t: 'unary';
51
+ op: '!' | '-' | '+';
52
+ arg: Expr;
53
+ } | {
54
+ t: 'update';
55
+ op: '++' | '--';
56
+ arg: Expr;
57
+ prefix: boolean;
58
+ } | {
59
+ t: 'bin';
60
+ op: string;
61
+ l: Expr;
62
+ r: Expr;
63
+ } | {
64
+ t: 'logic';
65
+ op: '&&' | '||' | '??';
66
+ l: Expr;
67
+ r: Expr;
68
+ } | {
69
+ t: 'cond';
70
+ test: Expr;
71
+ cons: Expr;
72
+ alt: Expr;
73
+ } | {
74
+ t: 'assign';
75
+ op: string;
76
+ target: Expr;
77
+ value: Expr;
78
+ } | {
79
+ t: 'arrow';
80
+ params: string[];
81
+ body: Expr;
82
+ } | {
83
+ t: 'arr';
84
+ items: {
85
+ spread?: boolean;
86
+ value: Expr;
87
+ }[];
88
+ } | {
89
+ t: 'obj';
90
+ props: {
91
+ key?: string;
92
+ value: Expr;
93
+ spread?: boolean;
94
+ at?: number;
95
+ }[];
96
+ } | {
97
+ t: 'error';
98
+ };
99
+ export declare function parseExpression(src: string): {
100
+ ast: Expr;
101
+ diagnostics: ExprDiagnostic[];
102
+ };
103
+ /**
104
+ * Split an instruction (`on-click( fn, a, b )`, `<log( a, b )>`) on its
105
+ * top-level commas — strings and brackets are opaque.
106
+ */
107
+ export declare function splitTopLevel(src: string): string[];
108
+ /**
109
+ * Every root identifier an expression reads that is not bound by an
110
+ * arrow parameter — the head of each member chain, plus bare reads.
111
+ *
112
+ * The complement of `extractDeps`, which drops names it does not
113
+ * recognise. Callers that need to REPORT an unresolvable name (a
114
+ * stylesheet has no template position, so a `<for>` iterator in one
115
+ * can never resolve — RFC-004 §7.2) need to see them instead.
116
+ */
117
+ export declare function freeRoots(ast: Expr): string[];
118
+ /**
119
+ * Precise dependency paths from the AST: dotted member paths
120
+ * rooted at metavars (up to the first computed/call boundary),
121
+ * plus bare scope-variable reads. Arrow params shadow.
122
+ */
123
+ export declare function extractDeps(ast: Expr, scopeNames?: string[]): string[];
124
+ export interface ExprEnv {
125
+ state?: any;
126
+ input?: any;
127
+ context?: any;
128
+ static?: any;
129
+ self?: any;
130
+ arguments?: any;
131
+ scope?: Record<string, any>;
132
+ /**
133
+ * Effective language for this subtree, read reactively (RFC-005 §4).
134
+ * Set by `<i18n lang=…>`; absent means "the global language". Not an
135
+ * expression root — the evaluator only binds the named roots, so this
136
+ * rides along for the runtime's own use.
137
+ */
138
+ lang?: () => string;
139
+ }
140
+ export interface CompiledExpr {
141
+ run(env: ExprEnv): any;
142
+ source: string;
143
+ }
144
+ /**
145
+ * Compiled mode: one Function per unique (source, scopeNames) —
146
+ * strict-compatible, no `with`. Trusted contexts only.
147
+ */
148
+ export declare function compileExpression(src: string, scopeNames?: string[]): CompiledExpr;
149
+ export declare function interpretExpression(ast: Expr, env: ExprEnv): any;