@lipsjs/lips 0.2.0 → 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.
- package/README.md +67 -1
- package/dist/lips.js +3532 -1094
- package/dist/lips.js.map +44 -19
- package/dist/lips.min.js +13 -9
- package/dist/lips.min.js.map +44 -19
- package/dist/mf2.min.js +4 -0
- package/dist/mf2.min.js.map +38 -0
- package/dist/precompile.min.js +19 -16
- package/dist/precompile.min.js.map +7 -6
- package/dist/runtime.min.js +4 -3
- package/dist/runtime.min.js.map +13 -12
- package/dist/stylis.min.js +3 -0
- package/dist/stylis.min.js.map +16 -0
- package/dist/types/i18n/engine.d.ts +14 -0
- package/dist/types/i18n/index.d.ts +122 -5
- package/dist/types/i18n/intl.d.ts +1 -0
- package/dist/types/i18n/lookup.d.ts +22 -0
- package/dist/types/ir/compiler.d.ts +75 -2
- package/dist/types/ir/expression.d.ts +32 -3
- package/dist/types/ir/facade.d.ts +74 -30
- package/dist/types/ir/host.d.ts +75 -0
- package/dist/types/ir/index.d.ts +5 -2
- package/dist/types/ir/policy.d.ts +95 -0
- package/dist/types/ir/runtime.d.ts +54 -19
- package/dist/types/ir/signal.d.ts +6 -4
- package/dist/types/ir/style.d.ts +119 -0
- package/dist/types/ir/swap.d.ts +5 -0
- package/dist/types/ir/tree.d.ts +51 -0
- package/dist/types/lips.d.ts +20 -3
- package/dist/types/lynx/a11y.d.ts +61 -0
- package/dist/types/lynx/background.d.ts +71 -0
- package/dist/types/lynx/main.d.ts +46 -0
- package/dist/types/lynx/protocol.d.ts +52 -0
- package/dist/types/lynx/style.d.ts +49 -0
- package/dist/types/lynx/template.d.ts +37 -0
- package/dist/types/mf2.d.ts +14 -0
- package/dist/types/precompile.d.ts +30 -5
- package/dist/types/runtime.d.ts +1 -1
- package/dist/types/stylesheet.d.ts +12 -16
- package/dist/types/stylis.d.ts +2 -0
- package/dist/types/types.d.ts +138 -11
- package/dist/types/untrusted.d.ts +17 -0
- package/dist/untrusted.min.js +5 -0
- package/dist/untrusted.min.js.map +13 -0
- package/package.json +20 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var Y="comm",K="rule",_="decl";var Q="@import";var X="@namespace",rr="@keyframes";var er="@layer";var q=Math.abs,F=String.fromCharCode;function y(r){return r.trim()}function N(r,e,a){return r.replace(e,a)}function tr(r,e,a){return r.indexOf(e,a)}function m(r,e){return r.charCodeAt(e)|0}function A(r,e,a){return r.slice(e,a)}function p(r){return r.length}function W(r){return r.length}function L(r,e){return e.push(r),r}var j=1,l=1,ar=0,x=0,c=0,I="";function B(r,e,a,o,s,E,w,n){return{value:r,root:e,parent:a,type:o,props:s,children:E,line:j,column:l,length:w,return:"",siblings:n}}function or(){return c}function cr(){if(c=x>0?m(I,--x):0,l--,c===10)l=1,j--;return c}function h(){if(c=x<ar?m(I,x++):0,l++,c===10)l=1,j++;return c}function T(){return m(I,x)}function D(){return x}function V(r,e){return A(I,r,e)}function z(r){switch(r){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function nr(r){return j=l=1,ar=p(I=r),x=0,[]}function ir(r){return I="",r}function Z(r){return y(V(x-1,J(r===91?r+2:r===40?r+1:r)))}function sr(r){while(c=T())if(c<33)h();else break;return z(r)>2||z(c)>3?"":" "}function pr(r,e){while(--e&&h())if(c<48||c>102||c>57&&c<65||c>70&&c<97)break;return V(r,D()+(e<6&&T()==32&&h()==32))}function J(r){while(h())switch(c){case r:return x;case 34:case 39:if(r!==34&&r!==39)J(c);break;case 40:if(r===41)J(r);break;case 92:h();break}return x}function fr(r,e){while(h())if(r+c===57)break;else if(r+c===84&&T()===47)break;return"/*"+V(e,x-1)+"*"+F(r===47?r:h())}function ur(r){while(!z(T()))h();return V(r,x)}function Er(r){return ir(G("",null,null,null,[""],r=nr(r),0,[0],r))}function G(r,e,a,o,s,E,w,n,d){var M=0,v=0,f=w,P=0,O=0,g=0,u=1,U=1,k=1,i=0,R="",C=s,S=E,b=o,t=R;while(U)switch(g=i,i=h()){case 40:if(g!=108&&m(t,f-1)==58){if(tr(t+=N(Z(i),"&","&\f"),"&\f",q(M?n[M-1]:0))!=-1)k=-1;break}case 34:case 39:case 91:t+=Z(i);break;case 9:case 10:case 13:case 32:t+=sr(g);break;case 92:t+=pr(D()-1,7);continue;case 47:switch(T()){case 42:case 47:if(L(gr(fr(h(),D()),e,a,d),d),(z(g||1)==5||z(T()||1)==5)&&p(t)&&A(t,-1,void 0)!==" ")t+=" ";break;default:t+="/"}break;case 123*u:n[M++]=p(t)*k;case 125*u:case 59:case 0:switch(i){case 0:case 125:U=0;case 59+v:if(k==-1)t=N(t,/\f/g,"");if(O>0&&(p(t)-f||u===0&&g===47))L(O>32?hr(t+";",o,a,f-1,d):hr(N(t," ","")+";",o,a,f-2,d),d);break;case 59:t+=";";default:if(L(b=xr(t,e,a,M,v,s,n,R,C=[],S=[],f,E),E),i===123)if(v===0)G(t,e,b,b,C,E,f,n,S);else{switch(P){case 99:if(m(t,3)===110)break;case 108:if(m(t,2)===97)break;default:v=0;case 100:case 109:case 115:}if(v)G(r,b,b,o&&L(xr(r,b,b,0,0,s,n,R,s,C=[],f,S),S),s,S,f,n,o?C:S);else G(t,b,b,b,[""],S,0,n,S)}}M=v=O=0,u=k=1,R=t="",f=w;break;case 58:f=1+p(t),O=g;default:if(u<1){if(i==123)--u;else if(i==125&&u++==0&&cr()==125)continue}switch(t+=F(i),i*u){case 38:k=v>0?1:(t+="\f",-1);break;case 44:n[M++]=(p(t)-1)*k,k=1;break;case 64:if(T()===45)t+=Z(h());P=T(),v=f=p(R=t+=ur(D())),i++;break;case 45:if(g===45&&p(t)==2)u=0}}return E}function xr(r,e,a,o,s,E,w,n,d,M,v,f){var P=s-1,O=s===0?E:[""],g=W(O);for(var u=0,U=0,k=0;u<o;++u)for(var i=0,R=A(r,P+1,P=q(U=w[u])),C=r;i<g;++i)if(C=y(U>0?O[i]+" "+R:N(R,/&\f/g,O[i])))d[k++]=C;return B(r,e,a,s===0?K:n,d,M,v,f)}function gr(r,e,a,o){return B(r,e,a,Y,F(or()),A(r,2,-2),0,o)}function hr(r,e,a,o,s){return B(r,e,a,_,A(r,0,o),A(r,o+1,-1),o,s)}function H(r,e){var a="";for(var o=0;o<r.length;o++)a+=e(r[o],o,r,e)||"";return a}function vr(r,e,a,o){switch(r.type){case er:if(r.children.length)break;case Q:case X:case _:return r.return=r.return||r.value;case Y:return"";case rr:return r.return=r.value+"{"+H(r.children,o)+"}";case K:if(!p(r.value=r.props.join(",")))return""}return p(a=H(r.children,o))?r.return=r.value+"{"+a+"}":""}function br(r){var e=W(r);return function(a,o,s,E){var w="";for(var n=0;n<e;n++)w+=r[n](a,o,s,E)||"";return w}}var Fr=(r)=>H(Er(r),br([vr]));export{Fr as stylisPreprocessor};
|
|
2
|
+
|
|
3
|
+
//# debugId=AF142D960144E6D064756E2164756E21
|
|
@@ -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,IAA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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
|
+
}
|
|
@@ -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 {
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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;
|
|
@@ -15,8 +15,12 @@
|
|
|
15
15
|
* The output is JSON-serializable and deterministic — it is the
|
|
16
16
|
* Modela artifact, the runtime render program, and the hot-swap
|
|
17
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).
|
|
18
22
|
*/
|
|
19
|
-
import type { TemplateDiagnostic } from './parser';
|
|
23
|
+
import type { TemplateNode, TemplateDiagnostic } from './parser';
|
|
20
24
|
export type Path = number[];
|
|
21
25
|
export type E = number;
|
|
22
26
|
export type CompInput = {
|
|
@@ -29,8 +33,20 @@ export interface TemplateIR {
|
|
|
29
33
|
exprs: string[];
|
|
30
34
|
root: BlockIR;
|
|
31
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[]];
|
|
32
46
|
export interface BlockIR {
|
|
33
47
|
html: string;
|
|
48
|
+
/** The skeleton as a tree — present when compiled with `target: 'tree'` */
|
|
49
|
+
nodes?: NodeIR[];
|
|
34
50
|
/**
|
|
35
51
|
* Scope variable names visible to this block's binds
|
|
36
52
|
* (iterator args, async arm args, let/const names —
|
|
@@ -40,23 +56,31 @@ export interface BlockIR {
|
|
|
40
56
|
binds: BindIR[];
|
|
41
57
|
blocks: ChildIR[];
|
|
42
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
|
+
*/
|
|
43
64
|
export type BindIR = {
|
|
44
65
|
t: 'text';
|
|
45
66
|
p: Path;
|
|
46
67
|
e: E;
|
|
47
68
|
i18n?: 1;
|
|
69
|
+
ik?: string;
|
|
48
70
|
} | {
|
|
49
71
|
t: 'attr';
|
|
50
72
|
p: Path;
|
|
51
73
|
name: string;
|
|
52
74
|
e: E;
|
|
53
75
|
i18n?: 1;
|
|
76
|
+
ik?: string;
|
|
54
77
|
} | {
|
|
55
78
|
t: 'prop';
|
|
56
79
|
p: Path;
|
|
57
80
|
name: string;
|
|
58
81
|
e: E;
|
|
59
82
|
i18n?: 1;
|
|
83
|
+
ik?: string;
|
|
60
84
|
ref?: string;
|
|
61
85
|
} | {
|
|
62
86
|
t: 'event';
|
|
@@ -72,11 +96,22 @@ export interface ArmIR {
|
|
|
72
96
|
args: string[];
|
|
73
97
|
block: BlockIR;
|
|
74
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
|
+
};
|
|
75
110
|
export type ChildIR = {
|
|
76
111
|
t: 'macro';
|
|
77
112
|
p: Path;
|
|
78
113
|
name: string;
|
|
79
|
-
|
|
114
|
+
sets: MacroSet[];
|
|
80
115
|
args: string[];
|
|
81
116
|
block: BlockIR;
|
|
82
117
|
} | {
|
|
@@ -119,6 +154,19 @@ export type ChildIR = {
|
|
|
119
154
|
t: 'log';
|
|
120
155
|
p: Path;
|
|
121
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;
|
|
122
170
|
} | {
|
|
123
171
|
t: 'comp';
|
|
124
172
|
p: Path;
|
|
@@ -149,5 +197,30 @@ export interface CompileResult {
|
|
|
149
197
|
export interface CompileOptions {
|
|
150
198
|
/** `<macro [argv] name="X">…</macro>` definitions, inlined at call sites */
|
|
151
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;
|
|
152
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>;
|
|
153
226
|
export declare function compileTemplate(src: string, options?: CompileOptions): CompileResult;
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
* - positioned, machine-readable diagnostics (never throws)
|
|
6
6
|
* - AST-derived precise dependency paths
|
|
7
7
|
* - two interchangeable executors over the same AST:
|
|
8
|
-
* compiled — one Function per unique expression
|
|
9
|
-
* interpreted —
|
|
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).
|
|
10
12
|
*
|
|
11
13
|
* Grammar (expression-only, no statements):
|
|
12
14
|
* literals (number, string, boolean, null, undefined), identifiers,
|
|
@@ -26,15 +28,19 @@ export interface ExprDiagnostic {
|
|
|
26
28
|
export type Expr = {
|
|
27
29
|
t: 'lit';
|
|
28
30
|
v: any;
|
|
29
|
-
}
|
|
31
|
+
}
|
|
32
|
+
/** `at`: where the name (or a member's key) starts in the source — for diagnostics */
|
|
33
|
+
| {
|
|
30
34
|
t: 'id';
|
|
31
35
|
name: string;
|
|
36
|
+
at?: number;
|
|
32
37
|
} | {
|
|
33
38
|
t: 'member';
|
|
34
39
|
obj: Expr;
|
|
35
40
|
prop: string | Expr;
|
|
36
41
|
computed: boolean;
|
|
37
42
|
optional: boolean;
|
|
43
|
+
at?: number;
|
|
38
44
|
} | {
|
|
39
45
|
t: 'call';
|
|
40
46
|
callee: Expr;
|
|
@@ -85,6 +91,7 @@ export type Expr = {
|
|
|
85
91
|
key?: string;
|
|
86
92
|
value: Expr;
|
|
87
93
|
spread?: boolean;
|
|
94
|
+
at?: number;
|
|
88
95
|
}[];
|
|
89
96
|
} | {
|
|
90
97
|
t: 'error';
|
|
@@ -93,6 +100,21 @@ export declare function parseExpression(src: string): {
|
|
|
93
100
|
ast: Expr;
|
|
94
101
|
diagnostics: ExprDiagnostic[];
|
|
95
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[];
|
|
96
118
|
/**
|
|
97
119
|
* Precise dependency paths from the AST: dotted member paths
|
|
98
120
|
* rooted at metavars (up to the first computed/call boundary),
|
|
@@ -107,6 +129,13 @@ export interface ExprEnv {
|
|
|
107
129
|
self?: any;
|
|
108
130
|
arguments?: any;
|
|
109
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;
|
|
110
139
|
}
|
|
111
140
|
export interface CompiledExpr {
|
|
112
141
|
run(env: ExprEnv): any;
|
|
@@ -18,77 +18,121 @@ import type { TemplateIR, CompileResult, CompileOptions } from './compiler';
|
|
|
18
18
|
*/
|
|
19
19
|
type CompilerFn = (src: string, options?: CompileOptions) => CompileResult;
|
|
20
20
|
export declare function setCompiler(fn: CompilerFn): void;
|
|
21
|
+
/**
|
|
22
|
+
* The style compiler is INJECTED for the same reason the template one is:
|
|
23
|
+
* a static import would pull the CSS scanner (and Stylis behind it) into
|
|
24
|
+
* the `./runtime` bundle, which exists precisely to ship neither.
|
|
25
|
+
*/
|
|
26
|
+
type StyleCompilerFn = (src: string, options: StyleCompileOptions) => StyleCompileResult;
|
|
27
|
+
export declare function setStyleCompiler(fn: StyleCompilerFn): void;
|
|
28
|
+
export declare function setMessageFormat(engine: MessageFormatEngine): void;
|
|
21
29
|
export declare function registerBuiltin(name: string, template: any): void;
|
|
22
30
|
import type { RuntimeOptions } from './runtime';
|
|
23
31
|
import Events from '../events';
|
|
32
|
+
import type { StyleIR, StyleCompileResult, StyleCompileOptions } from './style';
|
|
33
|
+
import type { Template, Metavars, LipsConfig, MessageFormatEngine } from '../types';
|
|
24
34
|
import I18N from '../i18n';
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
_static?: Record<string, any>;
|
|
33
|
-
context?: string[];
|
|
34
|
-
stylesheet?: string;
|
|
35
|
-
}
|
|
36
|
-
interface FacadeConfig {
|
|
37
|
-
engine?: string;
|
|
38
|
-
debug?: boolean;
|
|
39
|
-
context?: Record<string, any>;
|
|
35
|
+
/**
|
|
36
|
+
* The authoring shape IS the public `Template<MT>` — one type, not a
|
|
37
|
+
* parallel internal one. `FacadeTemplate` remains as the erased form
|
|
38
|
+
* used where the metavars are not known (caches, dynamic resolution).
|
|
39
|
+
*/
|
|
40
|
+
type FacadeTemplate = Template<any>;
|
|
41
|
+
type FacadeConfig<Context extends Object = Record<string, any>> = LipsConfig<Context> & {
|
|
40
42
|
mode?: 'compiled' | 'interpreted';
|
|
41
|
-
}
|
|
42
|
-
export declare class IRFacadeComponent extends Events {
|
|
43
|
+
};
|
|
44
|
+
export declare class IRFacadeComponent<MT extends Metavars = Metavars> extends Events {
|
|
43
45
|
private lips;
|
|
44
46
|
private template;
|
|
45
|
-
readonly state:
|
|
47
|
+
readonly state: MT['State'];
|
|
46
48
|
private instance;
|
|
47
49
|
private contextWatcher?;
|
|
48
50
|
private destroyed;
|
|
49
|
-
constructor(lips: IRLips
|
|
50
|
-
|
|
51
|
+
constructor(lips: IRLips<any>, name: string, template: Template<MT>, input: MT['Input'] | undefined, ir: TemplateIR, options: RuntimeOptions);
|
|
52
|
+
/**
|
|
53
|
+
* The component bus is bidirectional.
|
|
54
|
+
*
|
|
55
|
+
* Outward has always worked: a handler's `this.emit('save')` reaches
|
|
56
|
+
* `component.on('save')`. Inward is this override — `component.emit(
|
|
57
|
+
* 'reset')` also reaches `this.on('reset')` registered inside the
|
|
58
|
+
* component, so a holder of the handle can send a command without
|
|
59
|
+
* mutating state or reaching into internals.
|
|
60
|
+
*
|
|
61
|
+
* Argument handling matches what an internal emit already does:
|
|
62
|
+
* inward is raw (the caller owns the data), outward is deep-cleaned by
|
|
63
|
+
* `Events` so reactive proxies never escape the component.
|
|
64
|
+
*/
|
|
65
|
+
emit(event: string, ...args: any[]): void;
|
|
66
|
+
/**
|
|
67
|
+
* Live root ELEMENTS — matching `this.node` inside a handler. The
|
|
68
|
+
* instance's node list also carries the block's range markers, which
|
|
69
|
+
* are an internal detail no consumer should have to filter out.
|
|
70
|
+
*/
|
|
71
|
+
get node(): Element[];
|
|
51
72
|
appendTo(selector: string | Element): this;
|
|
52
73
|
swap(newIR: TemplateIR): import("./swap").SwapReport;
|
|
53
74
|
destroy(): void;
|
|
54
75
|
}
|
|
55
|
-
export declare class IRLips {
|
|
76
|
+
export declare class IRLips<Context extends Object = Record<string, any>> {
|
|
56
77
|
private config?;
|
|
57
78
|
debug: boolean;
|
|
58
79
|
private store;
|
|
59
80
|
private irCache;
|
|
60
81
|
private defCache;
|
|
82
|
+
private styleCache;
|
|
61
83
|
private context;
|
|
62
84
|
private __root?;
|
|
85
|
+
/**
|
|
86
|
+
* `new Lips({ untrusted: untrusted() })` — every template this instance
|
|
87
|
+
* renders is held to it (RFC-007). Passed by value from
|
|
88
|
+
* `@lipsjs/lips/untrusted`, so only an app that renders untrusted
|
|
89
|
+
* templates ships the policy.
|
|
90
|
+
*/
|
|
91
|
+
private u?;
|
|
63
92
|
i18n: I18N;
|
|
64
93
|
/** Language signal — translated binds subscribe through it */
|
|
65
94
|
private getLang;
|
|
66
95
|
private setLang;
|
|
96
|
+
/** Dictionary revision — bumped whenever a dictionary is registered */
|
|
97
|
+
private getRev;
|
|
67
98
|
/**
|
|
68
99
|
* Registered components resolved lazily — the runtime looks
|
|
69
100
|
* names up per render, so registration order doesn't matter.
|
|
70
101
|
*/
|
|
71
102
|
private componentsProxy;
|
|
72
|
-
constructor(config?: FacadeConfig | undefined);
|
|
73
|
-
register(name: string, template:
|
|
103
|
+
constructor(config?: FacadeConfig<Context> | undefined);
|
|
104
|
+
register<MT extends Metavars = Metavars>(name: string, template: Template<MT>): this;
|
|
74
105
|
unregister(name: string): this;
|
|
75
106
|
has(name: string): boolean;
|
|
76
107
|
private compile;
|
|
108
|
+
/**
|
|
109
|
+
* Compile `stylesheet` source to StyleIR, or take a precompiled `style`
|
|
110
|
+
* as-is. Cached per template object like the template IR — the sheet is
|
|
111
|
+
* per component type, so this runs once no matter how many instances.
|
|
112
|
+
*/
|
|
113
|
+
styleFor(name: string, template: FacadeTemplate): StyleIR | undefined;
|
|
77
114
|
private defFor;
|
|
78
|
-
render(name: string, template:
|
|
79
|
-
root(template:
|
|
80
|
-
|
|
115
|
+
render<MT extends Metavars = Metavars>(name: string, template: Template<MT>, input?: MT['Input']): IRFacadeComponent<MT>;
|
|
116
|
+
root<MT extends Metavars = Metavars>(template: Template<MT>, selector: string): IRFacadeComponent<any>;
|
|
117
|
+
/**
|
|
118
|
+
* The only way to change language. Writing `lips.i18n.lang` directly
|
|
119
|
+
* updates the dictionary lookup but not the signal, so nothing already
|
|
120
|
+
* rendered re-translates.
|
|
121
|
+
*/
|
|
122
|
+
setLanguage(lang: string): this;
|
|
81
123
|
getLanguage(): string;
|
|
82
124
|
useTranslator(support: string | string[], fn: (lang: string) => void): () => void;
|
|
83
|
-
|
|
84
|
-
|
|
125
|
+
/** Reactive store, indexed dynamically — Context only types the surface */
|
|
126
|
+
private get ctx();
|
|
127
|
+
getContext(): Context;
|
|
128
|
+
setContext(arg: (keyof Context & string) | Partial<Context>, value?: any): void;
|
|
85
129
|
/**
|
|
86
130
|
* Subscribe to a subset of context fields — the effect tracks
|
|
87
131
|
* exactly those keys, so unrelated context writes don't fire it.
|
|
88
132
|
* Returns an unsubscribe function.
|
|
89
133
|
*/
|
|
90
|
-
watchContext(fields: string[], fn: () => void): () => void;
|
|
91
|
-
useContext(fields: string[], fn: (ctx:
|
|
134
|
+
watchContext(fields: (keyof Context & string)[] | string[], fn: () => void): () => void;
|
|
135
|
+
useContext(fields: string[], fn: (ctx: Partial<Context>) => void): () => void;
|
|
92
136
|
dispose(): void;
|
|
93
137
|
}
|
|
94
138
|
export {};
|